Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8fd17795 authored by Chris Mason's avatar Chris Mason Committed by David Woodhouse
Browse files

Btrfs: early fsync support

parent 7e38180e
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -7,6 +7,7 @@
* Get rid of struct ctree_path, limiting tree levels held at one time
* Get rid of struct ctree_path, limiting tree levels held at one time
* Add generation number to key pointer in nodes
* Add generation number to key pointer in nodes
* Add parent pointer back to extent map.
* Add parent pointer back to extent map.
* Implement real list of pending transactions
* Release
* Release
* Do real tree locking
* Do real tree locking
* Add extent mirroring (backup copies of blocks)
* Add extent mirroring (backup copies of blocks)
+1 −0
Original line number Original line Diff line number Diff line
@@ -256,6 +256,7 @@ struct btrfs_fs_info {
	struct inode *btree_inode;
	struct inode *btree_inode;
	struct mutex trans_mutex;
	struct mutex trans_mutex;
	struct mutex fs_mutex;
	struct mutex fs_mutex;
	struct list_head trans_list;
	struct crypto_hash *hash_tfm;
	struct crypto_hash *hash_tfm;
	spinlock_t hash_lock;
	spinlock_t hash_lock;
	struct kobject kobj;
	struct kobject kobj;
+1 −0
Original line number Original line Diff line number Diff line
@@ -528,6 +528,7 @@ struct btrfs_root *open_ctree(struct super_block *sb)
	init_bit_radix(&fs_info->pending_del_radix);
	init_bit_radix(&fs_info->pending_del_radix);
	INIT_RADIX_TREE(&fs_info->fs_roots_radix, GFP_NOFS);
	INIT_RADIX_TREE(&fs_info->fs_roots_radix, GFP_NOFS);
	INIT_RADIX_TREE(&fs_info->dev_radix, GFP_NOFS);
	INIT_RADIX_TREE(&fs_info->dev_radix, GFP_NOFS);
	INIT_LIST_HEAD(&fs_info->trans_list);
	sb_set_blocksize(sb, 4096);
	sb_set_blocksize(sb, 4096);
	fs_info->running_transaction = NULL;
	fs_info->running_transaction = NULL;
	fs_info->tree_root = tree_root;
	fs_info->tree_root = tree_root;
+0 −1
Original line number Original line Diff line number Diff line
@@ -100,7 +100,6 @@ int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
	BUG_ON(refs == 0);
	BUG_ON(refs == 0);
	if (refs == 1) {
	if (refs == 1) {
		ret = btrfs_del_item(trans, root, path);
		ret = btrfs_del_item(trans, root, path);
printk("deleting root %Lu %Lu %u\n", key->objectid, key->offset, key->flags);
	} else {
	} else {
		btrfs_set_root_refs(ri, refs - 1);
		btrfs_set_root_refs(ri, refs - 1);
printk("ref now %u root %Lu %Lu %u\n", refs -1, key->objectid, key->offset, key->flags);
printk("ref now %u root %Lu %Lu %u\n", refs -1, key->objectid, key->offset, key->flags);
+36 −1
Original line number Original line Diff line number Diff line
@@ -11,6 +11,7 @@
#include <linux/mpage.h>
#include <linux/mpage.h>
#include <linux/swap.h>
#include <linux/swap.h>
#include <linux/writeback.h>
#include <linux/writeback.h>
#include <linux/statfs.h>
#include "ctree.h"
#include "ctree.h"
#include "disk-io.h"
#include "disk-io.h"
#include "transaction.h"
#include "transaction.h"
@@ -932,6 +933,26 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
	return err;
	return err;
}
}


static int btrfs_sync_file(struct file *file,
			   struct dentry *dentry, int datasync)
{
	struct inode *inode = dentry->d_inode;
	struct btrfs_root *root = BTRFS_I(inode)->root;
	int ret;
	struct btrfs_trans_handle *trans;

	mutex_lock(&root->fs_info->fs_mutex);
	trans = btrfs_start_transaction(root, 1);
	if (!trans) {
		ret = -ENOMEM;
		goto out;
	}
	ret = btrfs_commit_transaction(trans, root);
	mutex_unlock(&root->fs_info->fs_mutex);
out:
	return ret > 0 ? EIO : ret;
}

static int btrfs_sync_fs(struct super_block *sb, int wait)
static int btrfs_sync_fs(struct super_block *sb, int wait)
{
{
	struct btrfs_trans_handle *trans;
	struct btrfs_trans_handle *trans;
@@ -2353,6 +2374,19 @@ static int btrfs_getattr(struct vfsmount *mnt,
	return 0;
	return 0;
}
}


static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf)
{
	struct btrfs_root *root = btrfs_sb(dentry->d_sb);
	struct btrfs_super_block *disk_super = root->fs_info->disk_super;

	buf->f_namelen = BTRFS_NAME_LEN;
	buf->f_blocks = btrfs_super_total_blocks(disk_super);
	buf->f_bfree = buf->f_blocks - btrfs_super_blocks_used(disk_super);
	buf->f_bavail = buf->f_bfree;
	buf->f_bsize = dentry->d_sb->s_blocksize;
	buf->f_type = BTRFS_SUPER_MAGIC;
	return 0;
}
static struct file_system_type btrfs_fs_type = {
static struct file_system_type btrfs_fs_type = {
	.owner		= THIS_MODULE,
	.owner		= THIS_MODULE,
	.name		= "btrfs",
	.name		= "btrfs",
@@ -2362,7 +2396,6 @@ static struct file_system_type btrfs_fs_type = {
};
};


static struct super_operations btrfs_super_ops = {
static struct super_operations btrfs_super_ops = {
	.statfs		= simple_statfs,
	.delete_inode	= btrfs_delete_inode,
	.delete_inode	= btrfs_delete_inode,
	.put_super	= btrfs_put_super,
	.put_super	= btrfs_put_super,
	.read_inode	= btrfs_read_locked_inode,
	.read_inode	= btrfs_read_locked_inode,
@@ -2371,6 +2404,7 @@ static struct super_operations btrfs_super_ops = {
	.write_inode	= btrfs_write_inode,
	.write_inode	= btrfs_write_inode,
	.alloc_inode	= btrfs_alloc_inode,
	.alloc_inode	= btrfs_alloc_inode,
	.destroy_inode	= btrfs_destroy_inode,
	.destroy_inode	= btrfs_destroy_inode,
	.statfs		= btrfs_statfs,
};
};


static struct inode_operations btrfs_dir_inode_operations = {
static struct inode_operations btrfs_dir_inode_operations = {
@@ -2413,6 +2447,7 @@ static struct file_operations btrfs_file_operations = {
	.mmap		= generic_file_mmap,
	.mmap		= generic_file_mmap,
	.open		= generic_file_open,
	.open		= generic_file_open,
	.ioctl		= btrfs_ioctl,
	.ioctl		= btrfs_ioctl,
	.fsync		= btrfs_sync_file,
};
};


static int __init init_btrfs_fs(void)
static int __init init_btrfs_fs(void)
Loading