diff options
author | Josef Bacik <josef@redhat.com> | 2012-03-26 09:46:47 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-06-01 12:07:52 -0400 |
commit | e41f941a23115e84a8550b3d901a13a14b2edc2f (patch) | |
tree | 4f9d029be67bb3be91b5b7c5a28cf3e5c1508e7a /fs | |
parent | c3b2da314834499f34cba94f7053e55f6d6f92d8 (diff) |
Btrfs: move over to use ->update_time
Btrfs had been doing it's own file_update_time so we could catch ENOSPC
properly, so just update our btrfs_update_time to work with the new stuff and
then we'll be fancy later. Thanks,
Signed-off-by: Josef Bacik <josef@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/ctree.h | 1 | ||||
-rw-r--r-- | fs/btrfs/file.c | 2 | ||||
-rw-r--r-- | fs/btrfs/inode.c | 53 |
3 files changed, 15 insertions, 41 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 8fd72331d600..ba8743b9a825 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -2922,7 +2922,6 @@ int btrfs_readpage(struct file *file, struct page *page); | |||
2922 | void btrfs_evict_inode(struct inode *inode); | 2922 | void btrfs_evict_inode(struct inode *inode); |
2923 | int btrfs_write_inode(struct inode *inode, struct writeback_control *wbc); | 2923 | int btrfs_write_inode(struct inode *inode, struct writeback_control *wbc); |
2924 | int btrfs_dirty_inode(struct inode *inode); | 2924 | int btrfs_dirty_inode(struct inode *inode); |
2925 | int btrfs_update_time(struct file *file); | ||
2926 | struct inode *btrfs_alloc_inode(struct super_block *sb); | 2925 | struct inode *btrfs_alloc_inode(struct super_block *sb); |
2927 | void btrfs_destroy_inode(struct inode *inode); | 2926 | void btrfs_destroy_inode(struct inode *inode); |
2928 | int btrfs_drop_inode(struct inode *inode); | 2927 | int btrfs_drop_inode(struct inode *inode); |
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 53bf2d764bbc..974beb84ed61 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
@@ -1404,7 +1404,7 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb, | |||
1404 | goto out; | 1404 | goto out; |
1405 | } | 1405 | } |
1406 | 1406 | ||
1407 | err = btrfs_update_time(file); | 1407 | err = file_update_time(file); |
1408 | if (err) { | 1408 | if (err) { |
1409 | mutex_unlock(&inode->i_mutex); | 1409 | mutex_unlock(&inode->i_mutex); |
1410 | goto out; | 1410 | goto out; |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index ceb7b9c9edcc..3c1723a9ae6f 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -4431,46 +4431,18 @@ int btrfs_dirty_inode(struct inode *inode) | |||
4431 | * This is a copy of file_update_time. We need this so we can return error on | 4431 | * This is a copy of file_update_time. We need this so we can return error on |
4432 | * ENOSPC for updating the inode in the case of file write and mmap writes. | 4432 | * ENOSPC for updating the inode in the case of file write and mmap writes. |
4433 | */ | 4433 | */ |
4434 | int btrfs_update_time(struct file *file) | 4434 | static int btrfs_update_time(struct inode *inode, struct timespec *now, |
4435 | int flags) | ||
4435 | { | 4436 | { |
4436 | struct inode *inode = file->f_path.dentry->d_inode; | 4437 | if (flags & S_VERSION) |
4437 | struct timespec now; | ||
4438 | int ret; | ||
4439 | enum { S_MTIME = 1, S_CTIME = 2, S_VERSION = 4 } sync_it = 0; | ||
4440 | |||
4441 | /* First try to exhaust all avenues to not sync */ | ||
4442 | if (IS_NOCMTIME(inode)) | ||
4443 | return 0; | ||
4444 | |||
4445 | now = current_fs_time(inode->i_sb); | ||
4446 | if (!timespec_equal(&inode->i_mtime, &now)) | ||
4447 | sync_it = S_MTIME; | ||
4448 | |||
4449 | if (!timespec_equal(&inode->i_ctime, &now)) | ||
4450 | sync_it |= S_CTIME; | ||
4451 | |||
4452 | if (IS_I_VERSION(inode)) | ||
4453 | sync_it |= S_VERSION; | ||
4454 | |||
4455 | if (!sync_it) | ||
4456 | return 0; | ||
4457 | |||
4458 | /* Finally allowed to write? Takes lock. */ | ||
4459 | if (mnt_want_write_file(file)) | ||
4460 | return 0; | ||
4461 | |||
4462 | /* Only change inode inside the lock region */ | ||
4463 | if (sync_it & S_VERSION) | ||
4464 | inode_inc_iversion(inode); | 4438 | inode_inc_iversion(inode); |
4465 | if (sync_it & S_CTIME) | 4439 | if (flags & S_CTIME) |
4466 | inode->i_ctime = now; | 4440 | inode->i_ctime = *now; |
4467 | if (sync_it & S_MTIME) | 4441 | if (flags & S_MTIME) |
4468 | inode->i_mtime = now; | 4442 | inode->i_mtime = *now; |
4469 | ret = btrfs_dirty_inode(inode); | 4443 | if (flags & S_ATIME) |
4470 | if (!ret) | 4444 | inode->i_atime = *now; |
4471 | mark_inode_dirty_sync(inode); | 4445 | return btrfs_dirty_inode(inode); |
4472 | mnt_drop_write(file->f_path.mnt); | ||
4473 | return ret; | ||
4474 | } | 4446 | } |
4475 | 4447 | ||
4476 | /* | 4448 | /* |
@@ -6576,7 +6548,7 @@ int btrfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
6576 | 6548 | ||
6577 | ret = btrfs_delalloc_reserve_space(inode, PAGE_CACHE_SIZE); | 6549 | ret = btrfs_delalloc_reserve_space(inode, PAGE_CACHE_SIZE); |
6578 | if (!ret) { | 6550 | if (!ret) { |
6579 | ret = btrfs_update_time(vma->vm_file); | 6551 | ret = file_update_time(vma->vm_file); |
6580 | reserved = 1; | 6552 | reserved = 1; |
6581 | } | 6553 | } |
6582 | if (ret) { | 6554 | if (ret) { |
@@ -7647,6 +7619,7 @@ static const struct inode_operations btrfs_file_inode_operations = { | |||
7647 | .permission = btrfs_permission, | 7619 | .permission = btrfs_permission, |
7648 | .fiemap = btrfs_fiemap, | 7620 | .fiemap = btrfs_fiemap, |
7649 | .get_acl = btrfs_get_acl, | 7621 | .get_acl = btrfs_get_acl, |
7622 | .update_time = btrfs_update_time, | ||
7650 | }; | 7623 | }; |
7651 | static const struct inode_operations btrfs_special_inode_operations = { | 7624 | static const struct inode_operations btrfs_special_inode_operations = { |
7652 | .getattr = btrfs_getattr, | 7625 | .getattr = btrfs_getattr, |
@@ -7657,6 +7630,7 @@ static const struct inode_operations btrfs_special_inode_operations = { | |||
7657 | .listxattr = btrfs_listxattr, | 7630 | .listxattr = btrfs_listxattr, |
7658 | .removexattr = btrfs_removexattr, | 7631 | .removexattr = btrfs_removexattr, |
7659 | .get_acl = btrfs_get_acl, | 7632 | .get_acl = btrfs_get_acl, |
7633 | .update_time = btrfs_update_time, | ||
7660 | }; | 7634 | }; |
7661 | static const struct inode_operations btrfs_symlink_inode_operations = { | 7635 | static const struct inode_operations btrfs_symlink_inode_operations = { |
7662 | .readlink = generic_readlink, | 7636 | .readlink = generic_readlink, |
@@ -7670,6 +7644,7 @@ static const struct inode_operations btrfs_symlink_inode_operations = { | |||
7670 | .listxattr = btrfs_listxattr, | 7644 | .listxattr = btrfs_listxattr, |
7671 | .removexattr = btrfs_removexattr, | 7645 | .removexattr = btrfs_removexattr, |
7672 | .get_acl = btrfs_get_acl, | 7646 | .get_acl = btrfs_get_acl, |
7647 | .update_time = btrfs_update_time, | ||
7673 | }; | 7648 | }; |
7674 | 7649 | ||
7675 | const struct dentry_operations btrfs_dentry_operations = { | 7650 | const struct dentry_operations btrfs_dentry_operations = { |