diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-04-19 21:01:03 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-04-19 21:01:03 -0400 |
commit | 8fd17795b2261ecb1bad2a6df09ef14c4957a3fb (patch) | |
tree | baab31275c20f5848f11688678158cf50875834e /fs/btrfs/super.c | |
parent | 7e38180e207c8707691c12395e990a5d583c5e71 (diff) |
Btrfs: early fsync support
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r-- | fs/btrfs/super.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index dff2db0d1dc2..f99c764a59db 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/mpage.h> | 11 | #include <linux/mpage.h> |
12 | #include <linux/swap.h> | 12 | #include <linux/swap.h> |
13 | #include <linux/writeback.h> | 13 | #include <linux/writeback.h> |
14 | #include <linux/statfs.h> | ||
14 | #include "ctree.h" | 15 | #include "ctree.h" |
15 | #include "disk-io.h" | 16 | #include "disk-io.h" |
16 | #include "transaction.h" | 17 | #include "transaction.h" |
@@ -932,6 +933,26 @@ out_unlock: | |||
932 | return err; | 933 | return err; |
933 | } | 934 | } |
934 | 935 | ||
936 | static int btrfs_sync_file(struct file *file, | ||
937 | struct dentry *dentry, int datasync) | ||
938 | { | ||
939 | struct inode *inode = dentry->d_inode; | ||
940 | struct btrfs_root *root = BTRFS_I(inode)->root; | ||
941 | int ret; | ||
942 | struct btrfs_trans_handle *trans; | ||
943 | |||
944 | mutex_lock(&root->fs_info->fs_mutex); | ||
945 | trans = btrfs_start_transaction(root, 1); | ||
946 | if (!trans) { | ||
947 | ret = -ENOMEM; | ||
948 | goto out; | ||
949 | } | ||
950 | ret = btrfs_commit_transaction(trans, root); | ||
951 | mutex_unlock(&root->fs_info->fs_mutex); | ||
952 | out: | ||
953 | return ret > 0 ? EIO : ret; | ||
954 | } | ||
955 | |||
935 | static int btrfs_sync_fs(struct super_block *sb, int wait) | 956 | static int btrfs_sync_fs(struct super_block *sb, int wait) |
936 | { | 957 | { |
937 | struct btrfs_trans_handle *trans; | 958 | struct btrfs_trans_handle *trans; |
@@ -2353,6 +2374,19 @@ static int btrfs_getattr(struct vfsmount *mnt, | |||
2353 | return 0; | 2374 | return 0; |
2354 | } | 2375 | } |
2355 | 2376 | ||
2377 | static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf) | ||
2378 | { | ||
2379 | struct btrfs_root *root = btrfs_sb(dentry->d_sb); | ||
2380 | struct btrfs_super_block *disk_super = root->fs_info->disk_super; | ||
2381 | |||
2382 | buf->f_namelen = BTRFS_NAME_LEN; | ||
2383 | buf->f_blocks = btrfs_super_total_blocks(disk_super); | ||
2384 | buf->f_bfree = buf->f_blocks - btrfs_super_blocks_used(disk_super); | ||
2385 | buf->f_bavail = buf->f_bfree; | ||
2386 | buf->f_bsize = dentry->d_sb->s_blocksize; | ||
2387 | buf->f_type = BTRFS_SUPER_MAGIC; | ||
2388 | return 0; | ||
2389 | } | ||
2356 | static struct file_system_type btrfs_fs_type = { | 2390 | static struct file_system_type btrfs_fs_type = { |
2357 | .owner = THIS_MODULE, | 2391 | .owner = THIS_MODULE, |
2358 | .name = "btrfs", | 2392 | .name = "btrfs", |
@@ -2362,7 +2396,6 @@ static struct file_system_type btrfs_fs_type = { | |||
2362 | }; | 2396 | }; |
2363 | 2397 | ||
2364 | static struct super_operations btrfs_super_ops = { | 2398 | static struct super_operations btrfs_super_ops = { |
2365 | .statfs = simple_statfs, | ||
2366 | .delete_inode = btrfs_delete_inode, | 2399 | .delete_inode = btrfs_delete_inode, |
2367 | .put_super = btrfs_put_super, | 2400 | .put_super = btrfs_put_super, |
2368 | .read_inode = btrfs_read_locked_inode, | 2401 | .read_inode = btrfs_read_locked_inode, |
@@ -2371,6 +2404,7 @@ static struct super_operations btrfs_super_ops = { | |||
2371 | .write_inode = btrfs_write_inode, | 2404 | .write_inode = btrfs_write_inode, |
2372 | .alloc_inode = btrfs_alloc_inode, | 2405 | .alloc_inode = btrfs_alloc_inode, |
2373 | .destroy_inode = btrfs_destroy_inode, | 2406 | .destroy_inode = btrfs_destroy_inode, |
2407 | .statfs = btrfs_statfs, | ||
2374 | }; | 2408 | }; |
2375 | 2409 | ||
2376 | static struct inode_operations btrfs_dir_inode_operations = { | 2410 | static struct inode_operations btrfs_dir_inode_operations = { |
@@ -2413,6 +2447,7 @@ static struct file_operations btrfs_file_operations = { | |||
2413 | .mmap = generic_file_mmap, | 2447 | .mmap = generic_file_mmap, |
2414 | .open = generic_file_open, | 2448 | .open = generic_file_open, |
2415 | .ioctl = btrfs_ioctl, | 2449 | .ioctl = btrfs_ioctl, |
2450 | .fsync = btrfs_sync_file, | ||
2416 | }; | 2451 | }; |
2417 | 2452 | ||
2418 | static int __init init_btrfs_fs(void) | 2453 | static int __init init_btrfs_fs(void) |