From: Jeff Layton <jlayton@redhat.com> To: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-xfs@vger.kernel.org Subject: [RFC PATCH v1 25/30] fs: add a "force" parameter to inode_inc_iversion Date: Wed, 21 Dec 2016 12:03:42 -0500 [thread overview] Message-ID: <1482339827-7882-26-git-send-email-jlayton@redhat.com> (raw) In-Reply-To: <1482339827-7882-1-git-send-email-jlayton@redhat.com> In some coming changes, we will want to avoid changing the i_version counter in some cases as that may allow us to avoid having to log a metadata change to the inode. In other cases we will want to forcibly change it even when it's not strictly required (i.e. if we're going to log a time change to disk anyway). Add a parameter to tell the incrementing routine to forcibly bump the counter. For now, everyone sets this to "true" and the value is ignored, but later patches will change this. Signed-off-by: Jeff Layton <jlayton@redhat.com> --- fs/btrfs/file.c | 4 ++-- fs/btrfs/inode.c | 34 +++++++++++++++++----------------- fs/btrfs/ioctl.c | 4 ++-- fs/btrfs/xattr.c | 2 +- fs/ext2/super.c | 2 +- fs/ext4/inode.c | 4 ++-- fs/ext4/namei.c | 2 +- fs/inode.c | 2 +- fs/ocfs2/namei.c | 2 +- include/linux/fs.h | 2 +- 10 files changed, 29 insertions(+), 29 deletions(-) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index b5c5da215d05..f301afaf9af5 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -1804,7 +1804,7 @@ static void update_time_for_write(struct inode *inode) inode->i_ctime = now; if (IS_I_VERSION(inode)) - inode_inc_iversion(inode); + inode_inc_iversion(inode, true); } static ssize_t btrfs_file_write_iter(struct kiocb *iocb, @@ -2636,7 +2636,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len) if (!trans) goto out_free; - inode_inc_iversion(inode); + inode_inc_iversion(inode, true); inode->i_mtime = inode->i_ctime = current_time(inode); trans->block_rsv = &fs_info->trans_block_rsv; diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index a56a45a3e992..a03e5a1d5e05 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -4086,8 +4086,8 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans, goto out; btrfs_i_size_write(dir, dir->i_size - name_len * 2); - inode_inc_iversion(inode); - inode_inc_iversion(dir); + inode_inc_iversion(inode, true); + inode_inc_iversion(dir, true); inode->i_ctime = dir->i_mtime = dir->i_ctime = current_time(inode); ret = btrfs_update_inode(trans, root, dir); @@ -4232,7 +4232,7 @@ int btrfs_unlink_subvol(struct btrfs_trans_handle *trans, } btrfs_i_size_write(dir, dir->i_size - name_len * 2); - inode_inc_iversion(dir); + inode_inc_iversion(dir, true); dir->i_mtime = dir->i_ctime = current_time(dir); ret = btrfs_update_inode_fallback(trans, root, dir); if (ret) @@ -5000,7 +5000,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr) * explicitly if it wants a timestamp update. */ if (newsize != oldsize) { - inode_inc_iversion(inode); + inode_inc_iversion(inode, true); if (!(mask & (ATTR_CTIME | ATTR_MTIME))) inode->i_ctime = inode->i_mtime = current_time(inode); @@ -5122,7 +5122,7 @@ static int btrfs_setattr(struct dentry *dentry, struct iattr *attr) if (attr->ia_valid) { setattr_copy(inode, attr); - inode_inc_iversion(inode); + inode_inc_iversion(inode, true); err = btrfs_dirty_inode(inode); if (!err && attr->ia_valid & ATTR_MODE) @@ -6030,7 +6030,7 @@ static int btrfs_update_time(struct inode *inode, struct timespec *now, return -EROFS; if (flags & S_VERSION) - inode_inc_iversion(inode); + inode_inc_iversion(inode, true); if (flags & S_CTIME) inode->i_ctime = *now; if (flags & S_MTIME) @@ -6354,7 +6354,7 @@ int btrfs_add_link(struct btrfs_trans_handle *trans, btrfs_i_size_write(parent_inode, parent_inode->i_size + name_len * 2); - inode_inc_iversion(parent_inode); + inode_inc_iversion(parent_inode, true); parent_inode->i_mtime = parent_inode->i_ctime = current_time(parent_inode); ret = btrfs_update_inode(trans, root, parent_inode); @@ -6576,7 +6576,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir, /* There are several dir indexes for this inode, clear the cache. */ BTRFS_I(inode)->dir_index = 0ULL; inc_nlink(inode); - inode_inc_iversion(inode); + inode_inc_iversion(inode, true); inode->i_ctime = current_time(inode); ihold(inode); set_bit(BTRFS_INODE_COPY_EVERYTHING, &BTRFS_I(inode)->runtime_flags); @@ -9576,10 +9576,10 @@ static int btrfs_rename_exchange(struct inode *old_dir, } /* Update inode version and ctime/mtime. */ - inode_inc_iversion(old_dir); - inode_inc_iversion(new_dir); - inode_inc_iversion(old_inode); - inode_inc_iversion(new_inode); + inode_inc_iversion(old_dir, true); + inode_inc_iversion(new_dir, true); + inode_inc_iversion(old_inode, true); + inode_inc_iversion(new_inode, true); old_dir->i_ctime = old_dir->i_mtime = ctime; new_dir->i_ctime = new_dir->i_mtime = ctime; old_inode->i_ctime = ctime; @@ -9858,9 +9858,9 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, goto out_fail; } - inode_inc_iversion(old_dir); - inode_inc_iversion(new_dir); - inode_inc_iversion(old_inode); + inode_inc_iversion(old_dir, true); + inode_inc_iversion(new_dir, true); + inode_inc_iversion(old_inode, true); old_dir->i_ctime = old_dir->i_mtime = new_dir->i_ctime = new_dir->i_mtime = old_inode->i_ctime = current_time(old_dir); @@ -9887,7 +9887,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, } if (new_inode) { - inode_inc_iversion(new_inode); + inode_inc_iversion(new_inode, true); new_inode->i_ctime = current_time(new_inode); if (unlikely(btrfs_ino(new_inode) == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)) { @@ -10408,7 +10408,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode, cur_offset += ins.offset; *alloc_hint = ins.objectid + ins.offset; - inode_inc_iversion(inode); + inode_inc_iversion(inode, true); inode->i_ctime = current_time(inode); BTRFS_I(inode)->flags |= BTRFS_INODE_PREALLOC; if (!(mode & FALLOC_FL_KEEP_SIZE) && diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 33f967d30b2a..c2d845b73e58 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -348,7 +348,7 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg) } btrfs_update_iflags(inode); - inode_inc_iversion(inode); + inode_inc_iversion(inode, true); inode->i_ctime = current_time(inode); ret = btrfs_update_inode(trans, root, inode); @@ -3294,7 +3294,7 @@ static int clone_finish_inode_update(struct btrfs_trans_handle *trans, struct btrfs_root *root = BTRFS_I(inode)->root; int ret; - inode_inc_iversion(inode); + inode_inc_iversion(inode, true); if (!no_time_update) inode->i_mtime = inode->i_ctime = current_time(inode); /* diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c index 9621c7f2503e..b9a5475754b8 100644 --- a/fs/btrfs/xattr.c +++ b/fs/btrfs/xattr.c @@ -253,7 +253,7 @@ int __btrfs_setxattr(struct btrfs_trans_handle *trans, if (ret) goto out; - inode_inc_iversion(inode); + inode_inc_iversion(inode, true); inode->i_ctime = current_time(inode); set_bit(BTRFS_INODE_COPY_EVERYTHING, &BTRFS_I(inode)->runtime_flags); ret = btrfs_update_inode(trans, root, inode); diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 5c9ba3b3f77b..db8251e9fbd9 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -1542,7 +1542,7 @@ static ssize_t ext2_quota_write(struct super_block *sb, int type, return err; if (inode->i_size < off+len-towrite) i_size_write(inode, off+len-towrite); - inode_inc_iversion(inode); + inode_inc_iversion(inode, true); inode->i_mtime = inode->i_ctime = current_time(inode); mark_inode_dirty(inode); return len - towrite; diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 5603e1782c65..cd1c255944b3 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -5253,7 +5253,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) return -EINVAL; if (IS_I_VERSION(inode) && attr->ia_size != inode->i_size) - inode_inc_iversion(inode); + inode_inc_iversion(inode, true); if (ext4_should_order_data(inode) && (attr->ia_size < inode->i_size)) { @@ -5488,7 +5488,7 @@ int ext4_mark_iloc_dirty(handle_t *handle, int err = 0; if (IS_I_VERSION(inode)) - inode_inc_iversion(inode); + inode_inc_iversion(inode, true); /* the do_update_inode consumes one bh->b_count */ get_bh(iloc->bh); diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index a8f812162dd6..3c5110817a55 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -3379,7 +3379,7 @@ static int ext4_setent(handle_t *handle, struct ext4_renament *ent, ent->de->inode = cpu_to_le32(ino); if (ext4_has_feature_filetype(ent->dir->i_sb)) ent->de->file_type = file_type; - inode_inc_iversion(ent->dir); + inode_inc_iversion(ent->dir, true); ent->dir->i_ctime = ent->dir->i_mtime = current_time(ent->dir); ext4_mark_inode_dirty(handle, ent->dir); diff --git a/fs/inode.c b/fs/inode.c index 88110fd0b282..2484d91ae8ef 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1625,7 +1625,7 @@ int generic_update_time(struct inode *inode, struct timespec *time, int flags) if (flags & S_ATIME) inode->i_atime = *time; if (flags & S_VERSION) - inode_inc_iversion(inode); + inode_inc_iversion(inode, true); if (flags & S_CTIME) inode->i_ctime = *time; if (flags & S_MTIME) diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index c045826b716a..387cfa36c7b7 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c @@ -1520,7 +1520,7 @@ static int ocfs2_rename(struct inode *old_dir, mlog_errno(status); goto bail; } - inode_inc_iversion(new_dir); + inode_inc_iversion(new_dir, true); if (S_ISDIR(new_inode->i_mode)) ocfs2_set_links_count(newfe, 0); diff --git a/include/linux/fs.h b/include/linux/fs.h index 075c915fe2b1..75323e7b6954 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2013,7 +2013,7 @@ inode_set_iversion_read(struct inode *inode, const u64 new) * The filesystem has to be mounted with MS_I_VERSION flag. */ static inline bool -inode_inc_iversion(struct inode *inode) +inode_inc_iversion(struct inode *inode, bool force) { spin_lock(&inode->i_lock); inode_inc_iversion_locked(inode); -- 2.7.4
next prev parent reply other threads:[~2016-12-21 17:06 UTC|newest] Thread overview: 87+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-12-21 17:03 [RFC PATCH v1 00/30] fs: inode->i_version rework and optimization Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 01/30] lustre: don't set f_version in ll_readdir Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 02/30] ecryptfs: remove unnecessary i_version bump Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 03/30] ceph: remove the bump of i_version Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 04/30] f2fs: don't bother setting i_version Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 05/30] hpfs: don't bother with the i_version counter Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 06/30] jfs: remove initialization of " Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 07/30] nilfs2: remove inode->i_version initialization Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 08/30] orangefs: remove initialization of i_version Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 09/30] reiserfs: remove unneeded i_version bump Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 10/30] ntfs: remove i_version handling Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 11/30] fs: new API for handling i_version Jeff Layton 2017-03-03 22:36 ` J. Bruce Fields 2017-03-04 0:09 ` Jeff Layton 2017-03-03 23:55 ` NeilBrown 2017-03-04 1:58 ` Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 12/30] fat: convert to new i_version API Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 13/30] affs: " Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 14/30] afs: " Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 15/30] btrfs: " Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 16/30] exofs: switch " Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 17/30] ext2: convert " Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 18/30] ext4: " Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 19/30] nfs: " Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 20/30] nfsd: " Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 21/30] ocfs2: " Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 22/30] ufs: use " Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 23/30] xfs: convert to " Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 24/30] IMA: switch IMA over " Jeff Layton 2016-12-21 17:03 ` Jeff Layton [this message] 2016-12-21 17:03 ` [RFC PATCH v1 26/30] fs: only set S_VERSION when updating times if it has been queried Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 27/30] xfs: avoid setting XFS_ILOG_CORE if i_version doesn't need incrementing Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 28/30] btrfs: only dirty the inode in btrfs_update_time if something was changed Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 29/30] fs: track whether the i_version has been queried with an i_state flag Jeff Layton 2017-03-04 0:03 ` NeilBrown 2017-03-04 0:43 ` Jeff Layton 2016-12-21 17:03 ` [RFC PATCH v1 30/30] fs: convert i_version counter over to an atomic64_t Jeff Layton 2016-12-22 8:38 ` Amir Goldstein 2016-12-22 13:27 ` Jeff Layton 2017-03-04 0:00 ` NeilBrown 2016-12-22 8:45 ` [RFC PATCH v1 00/30] fs: inode->i_version rework and optimization Christoph Hellwig 2016-12-22 14:42 ` Jeff Layton 2017-03-20 21:43 ` J. Bruce Fields 2017-03-21 13:45 ` Christoph Hellwig 2017-03-21 16:30 ` J. Bruce Fields 2017-03-21 17:23 ` Jeff Layton 2017-03-21 17:37 ` J. Bruce Fields 2017-03-21 17:51 ` J. Bruce Fields 2017-03-21 18:30 ` J. Bruce Fields 2017-03-21 18:46 ` Jeff Layton 2017-03-21 19:13 ` J. Bruce Fields 2017-03-21 21:54 ` Jeff Layton 2017-03-29 11:15 ` Jan Kara 2017-03-29 17:54 ` Jeff Layton 2017-03-29 23:41 ` Dave Chinner 2017-03-30 11:24 ` Jeff Layton 2017-04-04 18:38 ` J. Bruce Fields 2017-03-30 6:47 ` Jan Kara 2017-03-30 11:11 ` Jeff Layton 2017-03-30 16:12 ` J. Bruce Fields 2017-03-30 18:35 ` Jeff Layton 2017-03-30 21:11 ` Boaz Harrosh 2017-04-04 18:31 ` J. Bruce Fields 2017-04-05 1:43 ` NeilBrown 2017-04-05 8:05 ` Jan Kara 2017-04-05 18:14 ` J. Bruce Fields 2017-05-11 18:59 ` J. Bruce Fields 2017-05-11 22:22 ` NeilBrown 2017-05-12 16:21 ` J. Bruce Fields 2017-10-30 13:21 ` Jeff Layton 2017-05-12 8:27 ` Jan Kara 2017-05-12 15:56 ` J. Bruce Fields 2017-05-12 11:01 ` Jeff Layton 2017-05-12 15:57 ` J. Bruce Fields 2017-04-06 1:12 ` NeilBrown 2017-04-06 7:22 ` Jan Kara 2017-04-05 17:26 ` J. Bruce Fields 2017-04-01 23:05 ` Dave Chinner 2017-04-03 14:00 ` Jan Kara 2017-04-04 12:34 ` Dave Chinner 2017-04-04 17:53 ` J. Bruce Fields 2017-04-05 1:26 ` NeilBrown 2017-03-21 21:45 ` Dave Chinner 2017-03-22 19:53 ` Jeff Layton 2017-03-03 23:00 ` J. Bruce Fields 2017-03-04 0:53 ` Jeff Layton 2017-03-08 17:29 ` J. Bruce Fields
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1482339827-7882-26-git-send-email-jlayton@redhat.com \ --to=jlayton@redhat.com \ --cc=linux-btrfs@vger.kernel.org \ --cc=linux-ext4@vger.kernel.org \ --cc=linux-fsdevel@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-nfs@vger.kernel.org \ --cc=linux-xfs@vger.kernel.org \ --subject='Re: [RFC PATCH v1 25/30] fs: add a "force" parameter to inode_inc_iversion' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).