diff options
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 55 |
1 files changed, 15 insertions, 40 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 3f2c8cbe5ba..a4f02501da4 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -3840,7 +3840,7 @@ void btrfs_evict_inode(struct inode *inode) | |||
3840 | btrfs_end_transaction(trans, root); | 3840 | btrfs_end_transaction(trans, root); |
3841 | btrfs_btree_balance_dirty(root, nr); | 3841 | btrfs_btree_balance_dirty(root, nr); |
3842 | no_delete: | 3842 | no_delete: |
3843 | end_writeback(inode); | 3843 | clear_inode(inode); |
3844 | return; | 3844 | return; |
3845 | } | 3845 | } |
3846 | 3846 | ||
@@ -4515,46 +4515,18 @@ int btrfs_dirty_inode(struct inode *inode) | |||
4515 | * This is a copy of file_update_time. We need this so we can return error on | 4515 | * This is a copy of file_update_time. We need this so we can return error on |
4516 | * ENOSPC for updating the inode in the case of file write and mmap writes. | 4516 | * ENOSPC for updating the inode in the case of file write and mmap writes. |
4517 | */ | 4517 | */ |
4518 | int btrfs_update_time(struct file *file) | 4518 | static int btrfs_update_time(struct inode *inode, struct timespec *now, |
4519 | int flags) | ||
4519 | { | 4520 | { |
4520 | struct inode *inode = file->f_path.dentry->d_inode; | 4521 | if (flags & S_VERSION) |
4521 | struct timespec now; | ||
4522 | int ret; | ||
4523 | enum { S_MTIME = 1, S_CTIME = 2, S_VERSION = 4 } sync_it = 0; | ||
4524 | |||
4525 | /* First try to exhaust all avenues to not sync */ | ||
4526 | if (IS_NOCMTIME(inode)) | ||
4527 | return 0; | ||
4528 | |||
4529 | now = current_fs_time(inode->i_sb); | ||
4530 | if (!timespec_equal(&inode->i_mtime, &now)) | ||
4531 | sync_it = S_MTIME; | ||
4532 | |||
4533 | if (!timespec_equal(&inode->i_ctime, &now)) | ||
4534 | sync_it |= S_CTIME; | ||
4535 | |||
4536 | if (IS_I_VERSION(inode)) | ||
4537 | sync_it |= S_VERSION; | ||
4538 | |||
4539 | if (!sync_it) | ||
4540 | return 0; | ||
4541 | |||
4542 | /* Finally allowed to write? Takes lock. */ | ||
4543 | if (mnt_want_write_file(file)) | ||
4544 | return 0; | ||
4545 | |||
4546 | /* Only change inode inside the lock region */ | ||
4547 | if (sync_it & S_VERSION) | ||
4548 | inode_inc_iversion(inode); | 4522 | inode_inc_iversion(inode); |
4549 | if (sync_it & S_CTIME) | 4523 | if (flags & S_CTIME) |
4550 | inode->i_ctime = now; | 4524 | inode->i_ctime = *now; |
4551 | if (sync_it & S_MTIME) | 4525 | if (flags & S_MTIME) |
4552 | inode->i_mtime = now; | 4526 | inode->i_mtime = *now; |
4553 | ret = btrfs_dirty_inode(inode); | 4527 | if (flags & S_ATIME) |
4554 | if (!ret) | 4528 | inode->i_atime = *now; |
4555 | mark_inode_dirty_sync(inode); | 4529 | return btrfs_dirty_inode(inode); |
4556 | mnt_drop_write(file->f_path.mnt); | ||
4557 | return ret; | ||
4558 | } | 4530 | } |
4559 | 4531 | ||
4560 | /* | 4532 | /* |
@@ -6605,7 +6577,7 @@ int btrfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
6605 | 6577 | ||
6606 | ret = btrfs_delalloc_reserve_space(inode, PAGE_CACHE_SIZE); | 6578 | ret = btrfs_delalloc_reserve_space(inode, PAGE_CACHE_SIZE); |
6607 | if (!ret) { | 6579 | if (!ret) { |
6608 | ret = btrfs_update_time(vma->vm_file); | 6580 | ret = file_update_time(vma->vm_file); |
6609 | reserved = 1; | 6581 | reserved = 1; |
6610 | } | 6582 | } |
6611 | if (ret) { | 6583 | if (ret) { |
@@ -7678,6 +7650,7 @@ static const struct inode_operations btrfs_file_inode_operations = { | |||
7678 | .permission = btrfs_permission, | 7650 | .permission = btrfs_permission, |
7679 | .fiemap = btrfs_fiemap, | 7651 | .fiemap = btrfs_fiemap, |
7680 | .get_acl = btrfs_get_acl, | 7652 | .get_acl = btrfs_get_acl, |
7653 | .update_time = btrfs_update_time, | ||
7681 | }; | 7654 | }; |
7682 | static const struct inode_operations btrfs_special_inode_operations = { | 7655 | static const struct inode_operations btrfs_special_inode_operations = { |
7683 | .getattr = btrfs_getattr, | 7656 | .getattr = btrfs_getattr, |
@@ -7688,6 +7661,7 @@ static const struct inode_operations btrfs_special_inode_operations = { | |||
7688 | .listxattr = btrfs_listxattr, | 7661 | .listxattr = btrfs_listxattr, |
7689 | .removexattr = btrfs_removexattr, | 7662 | .removexattr = btrfs_removexattr, |
7690 | .get_acl = btrfs_get_acl, | 7663 | .get_acl = btrfs_get_acl, |
7664 | .update_time = btrfs_update_time, | ||
7691 | }; | 7665 | }; |
7692 | static const struct inode_operations btrfs_symlink_inode_operations = { | 7666 | static const struct inode_operations btrfs_symlink_inode_operations = { |
7693 | .readlink = generic_readlink, | 7667 | .readlink = generic_readlink, |
@@ -7701,6 +7675,7 @@ static const struct inode_operations btrfs_symlink_inode_operations = { | |||
7701 | .listxattr = btrfs_listxattr, | 7675 | .listxattr = btrfs_listxattr, |
7702 | .removexattr = btrfs_removexattr, | 7676 | .removexattr = btrfs_removexattr, |
7703 | .get_acl = btrfs_get_acl, | 7677 | .get_acl = btrfs_get_acl, |
7678 | .update_time = btrfs_update_time, | ||
7704 | }; | 7679 | }; |
7705 | 7680 | ||
7706 | const struct dentry_operations btrfs_dentry_operations = { | 7681 | const struct dentry_operations btrfs_dentry_operations = { |