diff mbox series

[3/3] writeback: Drop I_DIRTY_TIME_EXPIRE

Message ID 20200601091904.4786-3-jack@suse.cz (mailing list archive)
State New, archived
Headers show
Series writeback: Lazytime handling fix and cleanups | expand

Commit Message

Jan Kara June 1, 2020, 9:18 a.m. UTC
The only use of I_DIRTY_TIME_EXPIRE is to detect in
__writeback_single_inode() that inode got there because flush worker
decided it's time to writeback the dirty inode time stamps (either
because we are syncing or because of age). However we can detect this
directly in __writeback_single_inode() and there's no need for the
strange propagation with I_DIRTY_TIME_EXPIRE flag.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/ext4/inode.c                  |  2 +-
 fs/fs-writeback.c                | 15 +++++----------
 fs/xfs/libxfs/xfs_trans_inode.c  |  4 ++--
 include/linux/fs.h               |  1 -
 include/trace/events/writeback.h |  1 -
 5 files changed, 8 insertions(+), 15 deletions(-)

Comments

Christoph Hellwig June 10, 2020, 3:11 p.m. UTC | #1
On Mon, Jun 01, 2020 at 11:18:57AM +0200, Jan Kara wrote:
> The only use of I_DIRTY_TIME_EXPIRE is to detect in
> __writeback_single_inode() that inode got there because flush worker
> decided it's time to writeback the dirty inode time stamps (either
> because we are syncing or because of age). However we can detect this
> directly in __writeback_single_inode() and there's no need for the
> strange propagation with I_DIRTY_TIME_EXPIRE flag.

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

One nit below:

>  	if (inode->i_state & I_DIRTY_TIME) {
>  		if ((dirty & I_DIRTY_INODE) ||
> -		    wbc->sync_mode == WB_SYNC_ALL ||
> -		    unlikely(inode->i_state & I_DIRTY_TIME_EXPIRED) ||
> +		    wbc->sync_mode == WB_SYNC_ALL || wbc->for_sync ||
>  		    unlikely(time_after(jiffies,
>  					(inode->dirtied_time_when +
>  					 dirtytime_expire_interval * HZ)))) {
> -			dirty |= I_DIRTY_TIME | I_DIRTY_TIME_EXPIRED;
> +			dirty |= I_DIRTY_TIME;
>  			trace_writeback_lazytime(inode);
>  		}
> -	} else
> -		inode->i_state &= ~I_DIRTY_TIME_EXPIRED;
> +	}

We can also drop some indentation here.  And remove the totally silly
unlikely, something like:

	if ((inode->i_state & I_DIRTY_TIME) &&
	    ((dirty & I_DIRTY_INODE) ||
	     wbc->sync_mode == WB_SYNC_ALL || wbc->for_sync ||
	     time_after(jiffies, inode->dirtied_time_when +
			dirtytime_expire_interval * HZ)))) {
		dirty |= I_DIRTY_TIME;
		trace_writeback_lazytime(inode);
	}
Jan Kara June 10, 2020, 4:20 p.m. UTC | #2
On Wed 10-06-20 08:11:41, Christoph Hellwig wrote:
> On Mon, Jun 01, 2020 at 11:18:57AM +0200, Jan Kara wrote:
> > The only use of I_DIRTY_TIME_EXPIRE is to detect in
> > __writeback_single_inode() that inode got there because flush worker
> > decided it's time to writeback the dirty inode time stamps (either
> > because we are syncing or because of age). However we can detect this
> > directly in __writeback_single_inode() and there's no need for the
> > strange propagation with I_DIRTY_TIME_EXPIRE flag.
> 
> Looks good:
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> 
> One nit below:
> 
> >  	if (inode->i_state & I_DIRTY_TIME) {
> >  		if ((dirty & I_DIRTY_INODE) ||
> > -		    wbc->sync_mode == WB_SYNC_ALL ||
> > -		    unlikely(inode->i_state & I_DIRTY_TIME_EXPIRED) ||
> > +		    wbc->sync_mode == WB_SYNC_ALL || wbc->for_sync ||
> >  		    unlikely(time_after(jiffies,
> >  					(inode->dirtied_time_when +
> >  					 dirtytime_expire_interval * HZ)))) {
> > -			dirty |= I_DIRTY_TIME | I_DIRTY_TIME_EXPIRED;
> > +			dirty |= I_DIRTY_TIME;
> >  			trace_writeback_lazytime(inode);
> >  		}
> > -	} else
> > -		inode->i_state &= ~I_DIRTY_TIME_EXPIRED;
> > +	}
> 
> We can also drop some indentation here.  And remove the totally silly
> unlikely, something like:
> 
> 	if ((inode->i_state & I_DIRTY_TIME) &&
> 	    ((dirty & I_DIRTY_INODE) ||
> 	     wbc->sync_mode == WB_SYNC_ALL || wbc->for_sync ||
> 	     time_after(jiffies, inode->dirtied_time_when +
> 			dirtytime_expire_interval * HZ)))) {
> 		dirty |= I_DIRTY_TIME;
> 		trace_writeback_lazytime(inode);
> 	}

Sure, I've done this. Once fstests run passes, I'll send v2 (likely
tomorrow).

								Honza
diff mbox series

Patch

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 2a4aae6acdcb..038cfe85f9cb 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4881,7 +4881,7 @@  static int other_inode_match(struct inode * inode, unsigned long ino,
 	    (inode->i_state & I_DIRTY_TIME)) {
 		struct ext4_inode_info	*ei = EXT4_I(inode);
 
-		inode->i_state &= ~(I_DIRTY_TIME | I_DIRTY_TIME_EXPIRED);
+		inode->i_state &= ~I_DIRTY_TIME;
 		spin_unlock(&inode->i_lock);
 
 		spin_lock(&ei->i_raw_lock);
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index b9aa4ff83bbd..62e2e1ed345a 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -1237,7 +1237,6 @@  static bool inode_dirtied_after(struct inode *inode, unsigned long t)
  */
 static int move_expired_inodes(struct list_head *delaying_queue,
 			       struct list_head *dispatch_queue,
-			       int flags,
 			       unsigned long older_than_this)
 {
 	LIST_HEAD(tmp);
@@ -1254,8 +1253,6 @@  static int move_expired_inodes(struct list_head *delaying_queue,
 		list_move(&inode->i_io_list, &tmp);
 		moved++;
 		spin_lock(&inode->i_lock);
-		if (flags & EXPIRE_DIRTY_ATIME)
-			inode->i_state |= I_DIRTY_TIME_EXPIRED;
 		inode->i_state |= I_SYNC_QUEUED;
 		spin_unlock(&inode->i_lock);
 		if (sb_is_blkdev_sb(inode->i_sb))
@@ -1303,11 +1300,11 @@  static void queue_io(struct bdi_writeback *wb, struct wb_writeback_work *work,
 
 	assert_spin_locked(&wb->list_lock);
 	list_splice_init(&wb->b_more_io, &wb->b_io);
-	moved = move_expired_inodes(&wb->b_dirty, &wb->b_io, 0, older_than_this);
+	moved = move_expired_inodes(&wb->b_dirty, &wb->b_io, older_than_this);
 	if (!work->for_sync)
 		time_expire_jif = jiffies - dirtytime_expire_interval * HZ;
 	moved += move_expired_inodes(&wb->b_dirty_time, &wb->b_io,
-				     EXPIRE_DIRTY_ATIME, time_expire_jif);
+				     time_expire_jif);
 	if (moved)
 		wb_io_lists_populated(wb);
 	trace_writeback_queue_io(wb, work, older_than_this, moved);
@@ -1485,16 +1482,14 @@  __writeback_single_inode(struct inode *inode, struct writeback_control *wbc)
 	dirty = inode->i_state & I_DIRTY;
 	if (inode->i_state & I_DIRTY_TIME) {
 		if ((dirty & I_DIRTY_INODE) ||
-		    wbc->sync_mode == WB_SYNC_ALL ||
-		    unlikely(inode->i_state & I_DIRTY_TIME_EXPIRED) ||
+		    wbc->sync_mode == WB_SYNC_ALL || wbc->for_sync ||
 		    unlikely(time_after(jiffies,
 					(inode->dirtied_time_when +
 					 dirtytime_expire_interval * HZ)))) {
-			dirty |= I_DIRTY_TIME | I_DIRTY_TIME_EXPIRED;
+			dirty |= I_DIRTY_TIME;
 			trace_writeback_lazytime(inode);
 		}
-	} else
-		inode->i_state &= ~I_DIRTY_TIME_EXPIRED;
+	}
 	inode->i_state &= ~dirty;
 
 	/*
diff --git a/fs/xfs/libxfs/xfs_trans_inode.c b/fs/xfs/libxfs/xfs_trans_inode.c
index 2b8ccb5b975d..3c903f2c498d 100644
--- a/fs/xfs/libxfs/xfs_trans_inode.c
+++ b/fs/xfs/libxfs/xfs_trans_inode.c
@@ -96,9 +96,9 @@  xfs_trans_log_inode(
 	 * to log the timestamps, or will clear already cleared fields in the
 	 * worst case.
 	 */
-	if (inode->i_state & (I_DIRTY_TIME | I_DIRTY_TIME_EXPIRED)) {
+	if (inode->i_state & I_DIRTY_TIME) {
 		spin_lock(&inode->i_lock);
-		inode->i_state &= ~(I_DIRTY_TIME | I_DIRTY_TIME_EXPIRED);
+		inode->i_state &= ~I_DIRTY_TIME;
 		spin_unlock(&inode->i_lock);
 	}
 
diff --git a/include/linux/fs.h b/include/linux/fs.h
index b02290d19edd..2c141d53949f 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2177,7 +2177,6 @@  static inline void kiocb_clone(struct kiocb *kiocb, struct kiocb *kiocb_src,
 #define I_DIO_WAKEUP		(1 << __I_DIO_WAKEUP)
 #define I_LINKABLE		(1 << 10)
 #define I_DIRTY_TIME		(1 << 11)
-#define I_DIRTY_TIME_EXPIRED	(1 << 12)
 #define I_WB_SWITCH		(1 << 13)
 #define I_OVL_INUSE		(1 << 14)
 #define I_CREATING		(1 << 15)
diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h
index b4500bdee2c0..a48e1f83fcdc 100644
--- a/include/trace/events/writeback.h
+++ b/include/trace/events/writeback.h
@@ -20,7 +20,6 @@ 
 		{I_CLEAR,		"I_CLEAR"},		\
 		{I_SYNC,		"I_SYNC"},		\
 		{I_DIRTY_TIME,		"I_DIRTY_TIME"},	\
-		{I_DIRTY_TIME_EXPIRED,	"I_DIRTY_TIME_EXPIRED"}, \
 		{I_REFERENCED,		"I_REFERENCED"}		\
 	)