From: Eric Biggers <ebiggers@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Theodore Ts'o <tytso@mit.edu>, Christoph Hellwig <hch@lst.de> Subject: [PATCH v3 11/11] ext4: simplify i_state checks in __ext4_update_other_inode_time() Date: Tue, 12 Jan 2021 11:02:53 -0800 [thread overview] Message-ID: <20210112190253.64307-12-ebiggers@kernel.org> (raw) In-Reply-To: <20210112190253.64307-1-ebiggers@kernel.org> From: Eric Biggers <ebiggers@google.com> Since I_DIRTY_TIME and I_DIRTY_INODE are mutually exclusive in i_state, there's no need to check for I_DIRTY_TIME && !I_DIRTY_INODE. Just check for I_DIRTY_TIME. Also introduce a helper function in include/linux/fs.h to do this check. Signed-off-by: Eric Biggers <ebiggers@google.com> --- fs/ext4/inode.c | 8 ++------ include/linux/fs.h | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 4cc6c7834312f..d809a06b6ef7f 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -4961,15 +4961,11 @@ static void __ext4_update_other_inode_time(struct super_block *sb, if (!inode) return; - if ((inode->i_state & (I_FREEING | I_WILL_FREE | I_NEW | - I_DIRTY_INODE)) || - ((inode->i_state & I_DIRTY_TIME) == 0)) + if (!inode_is_dirtytime_only(inode)) return; spin_lock(&inode->i_lock); - if (((inode->i_state & (I_FREEING | I_WILL_FREE | I_NEW | - I_DIRTY_INODE)) == 0) && - (inode->i_state & I_DIRTY_TIME)) { + if (inode_is_dirtytime_only(inode)) { struct ext4_inode_info *ei = EXT4_I(inode); inode->i_state &= ~I_DIRTY_TIME; diff --git a/include/linux/fs.h b/include/linux/fs.h index 45a0303b2aeb6..de0c789104c26 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2194,6 +2194,21 @@ static inline void mark_inode_dirty_sync(struct inode *inode) __mark_inode_dirty(inode, I_DIRTY_SYNC); } +/* + * Returns true if the given inode itself only has dirty timestamps (its pages + * may still be dirty) and isn't currently being allocated or freed. + * Filesystems should call this if when writing an inode when lazytime is + * enabled, they want to opportunistically write the timestamps of other inodes + * located very nearby on-disk, e.g. in the same inode block. This returns true + * if the given inode is in need of such an opportunistic update. Requires + * i_lock, or at least later re-checking under i_lock. + */ +static inline bool inode_is_dirtytime_only(struct inode *inode) +{ + return (inode->i_state & (I_DIRTY_TIME | I_NEW | + I_FREEING | I_WILL_FREE)) == I_DIRTY_TIME; +} + extern void inc_nlink(struct inode *inode); extern void drop_nlink(struct inode *inode); extern void clear_nlink(struct inode *inode); -- 2.30.0
WARNING: multiple messages have this Message-ID (diff)
From: Eric Biggers <ebiggers@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, Theodore Ts'o <tytso@mit.edu>, Christoph Hellwig <hch@lst.de>, linux-f2fs-devel@lists.sourceforge.net Subject: [f2fs-dev] [PATCH v3 11/11] ext4: simplify i_state checks in __ext4_update_other_inode_time() Date: Tue, 12 Jan 2021 11:02:53 -0800 [thread overview] Message-ID: <20210112190253.64307-12-ebiggers@kernel.org> (raw) In-Reply-To: <20210112190253.64307-1-ebiggers@kernel.org> From: Eric Biggers <ebiggers@google.com> Since I_DIRTY_TIME and I_DIRTY_INODE are mutually exclusive in i_state, there's no need to check for I_DIRTY_TIME && !I_DIRTY_INODE. Just check for I_DIRTY_TIME. Also introduce a helper function in include/linux/fs.h to do this check. Signed-off-by: Eric Biggers <ebiggers@google.com> --- fs/ext4/inode.c | 8 ++------ include/linux/fs.h | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 4cc6c7834312f..d809a06b6ef7f 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -4961,15 +4961,11 @@ static void __ext4_update_other_inode_time(struct super_block *sb, if (!inode) return; - if ((inode->i_state & (I_FREEING | I_WILL_FREE | I_NEW | - I_DIRTY_INODE)) || - ((inode->i_state & I_DIRTY_TIME) == 0)) + if (!inode_is_dirtytime_only(inode)) return; spin_lock(&inode->i_lock); - if (((inode->i_state & (I_FREEING | I_WILL_FREE | I_NEW | - I_DIRTY_INODE)) == 0) && - (inode->i_state & I_DIRTY_TIME)) { + if (inode_is_dirtytime_only(inode)) { struct ext4_inode_info *ei = EXT4_I(inode); inode->i_state &= ~I_DIRTY_TIME; diff --git a/include/linux/fs.h b/include/linux/fs.h index 45a0303b2aeb6..de0c789104c26 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2194,6 +2194,21 @@ static inline void mark_inode_dirty_sync(struct inode *inode) __mark_inode_dirty(inode, I_DIRTY_SYNC); } +/* + * Returns true if the given inode itself only has dirty timestamps (its pages + * may still be dirty) and isn't currently being allocated or freed. + * Filesystems should call this if when writing an inode when lazytime is + * enabled, they want to opportunistically write the timestamps of other inodes + * located very nearby on-disk, e.g. in the same inode block. This returns true + * if the given inode is in need of such an opportunistic update. Requires + * i_lock, or at least later re-checking under i_lock. + */ +static inline bool inode_is_dirtytime_only(struct inode *inode) +{ + return (inode->i_state & (I_DIRTY_TIME | I_NEW | + I_FREEING | I_WILL_FREE)) == I_DIRTY_TIME; +} + extern void inc_nlink(struct inode *inode); extern void drop_nlink(struct inode *inode); extern void clear_nlink(struct inode *inode); -- 2.30.0 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next prev parent reply other threads:[~2021-01-12 19:05 UTC|newest] Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-01-12 19:02 [PATCH v3 00/11] lazytime fix and cleanups Eric Biggers 2021-01-12 19:02 ` [f2fs-dev] " Eric Biggers 2021-01-12 19:02 ` [PATCH v3 01/11] fs: fix lazytime expiration handling in __writeback_single_inode() Eric Biggers 2021-01-12 19:02 ` [f2fs-dev] " Eric Biggers 2021-01-12 19:02 ` [PATCH v3 02/11] fs: correctly document the inode dirty flags Eric Biggers 2021-01-12 19:02 ` [f2fs-dev] " Eric Biggers 2021-01-12 19:02 ` [PATCH v3 03/11] fs: only specify I_DIRTY_TIME when needed in generic_update_time() Eric Biggers 2021-01-12 19:02 ` [f2fs-dev] " Eric Biggers 2021-01-12 19:02 ` [PATCH v3 04/11] fat: only specify I_DIRTY_TIME when needed in fat_update_time() Eric Biggers 2021-01-12 19:02 ` [f2fs-dev] " Eric Biggers 2021-01-12 19:02 ` [PATCH v3 05/11] fs: don't call ->dirty_inode for lazytime timestamp updates Eric Biggers 2021-01-12 19:02 ` [f2fs-dev] " Eric Biggers 2021-01-12 19:02 ` [PATCH v3 06/11] fs: pass only I_DIRTY_INODE flags to ->dirty_inode Eric Biggers 2021-01-12 19:02 ` [f2fs-dev] " Eric Biggers 2021-01-12 19:02 ` [PATCH v3 07/11] fs: clean up __mark_inode_dirty() a bit Eric Biggers 2021-01-12 19:02 ` [f2fs-dev] " Eric Biggers 2021-01-12 19:02 ` [PATCH v3 08/11] fs: drop redundant check from __writeback_single_inode() Eric Biggers 2021-01-12 19:02 ` [f2fs-dev] " Eric Biggers 2021-01-12 19:02 ` [PATCH v3 09/11] fs: improve comments for writeback_single_inode() Eric Biggers 2021-01-12 19:02 ` [f2fs-dev] " Eric Biggers 2021-01-12 19:02 ` [PATCH v3 10/11] gfs2: don't worry about I_DIRTY_TIME in gfs2_fsync() Eric Biggers 2021-01-12 19:02 ` [f2fs-dev] " Eric Biggers 2021-01-12 19:02 ` Eric Biggers [this message] 2021-01-12 19:02 ` [f2fs-dev] [PATCH v3 11/11] ext4: simplify i_state checks in __ext4_update_other_inode_time() Eric Biggers 2021-01-13 7:07 ` Christoph Hellwig 2021-01-13 7:07 ` [f2fs-dev] " Christoph Hellwig 2021-01-13 16:29 ` [PATCH v3 00/11] lazytime fix and cleanups Jan Kara 2021-01-13 16:29 ` [f2fs-dev] " Jan Kara 2021-01-13 18:49 ` Eric Biggers 2021-01-13 18:49 ` [f2fs-dev] " Eric Biggers
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=20210112190253.64307-12-ebiggers@kernel.org \ --to=ebiggers@kernel.org \ --cc=hch@lst.de \ --cc=linux-ext4@vger.kernel.org \ --cc=linux-f2fs-devel@lists.sourceforge.net \ --cc=linux-fsdevel@vger.kernel.org \ --cc=linux-xfs@vger.kernel.org \ --cc=tytso@mit.edu \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.