@@ -247,28 +247,41 @@ static bool inode_dirtied_after(struct inode *inode, unsigned long t)
247247 return ret ;
248248}
249249
250+ #define EXPIRE_DIRTY_ATIME 0x0001
251+
250252/*
251253 * Move expired (dirtied before work->older_than_this) dirty inodes from
252254 * @delaying_queue to @dispatch_queue.
253255 */
254256static int move_expired_inodes (struct list_head * delaying_queue ,
255257 struct list_head * dispatch_queue ,
258+ int flags ,
256259 struct wb_writeback_work * work )
257260{
261+ unsigned long * older_than_this = NULL ;
262+ unsigned long expire_time ;
258263 LIST_HEAD (tmp );
259264 struct list_head * pos , * node ;
260265 struct super_block * sb = NULL ;
261266 struct inode * inode ;
262267 int do_sb_sort = 0 ;
263268 int moved = 0 ;
264269
270+ if ((flags & EXPIRE_DIRTY_ATIME ) == 0 )
271+ older_than_this = work -> older_than_this ;
272+ else if ((work -> reason == WB_REASON_SYNC ) == 0 ) {
273+ expire_time = jiffies - (HZ * 86400 );
274+ older_than_this = & expire_time ;
275+ }
265276 while (!list_empty (delaying_queue )) {
266277 inode = wb_inode (delaying_queue -> prev );
267- if (work -> older_than_this &&
268- inode_dirtied_after (inode , * work -> older_than_this ))
278+ if (older_than_this &&
279+ inode_dirtied_after (inode , * older_than_this ))
269280 break ;
270281 list_move (& inode -> i_wb_list , & tmp );
271282 moved ++ ;
283+ if (flags & EXPIRE_DIRTY_ATIME )
284+ set_bit (__I_DIRTY_TIME_EXPIRED , & inode -> i_state );
272285 if (sb_is_blkdev_sb (inode -> i_sb ))
273286 continue ;
274287 if (sb && sb != inode -> i_sb )
@@ -309,9 +322,12 @@ static int move_expired_inodes(struct list_head *delaying_queue,
309322static void queue_io (struct bdi_writeback * wb , struct wb_writeback_work * work )
310323{
311324 int moved ;
325+
312326 assert_spin_locked (& wb -> list_lock );
313327 list_splice_init (& wb -> b_more_io , & wb -> b_io );
314- moved = move_expired_inodes (& wb -> b_dirty , & wb -> b_io , work );
328+ moved = move_expired_inodes (& wb -> b_dirty , & wb -> b_io , 0 , work );
329+ moved += move_expired_inodes (& wb -> b_dirty_time , & wb -> b_io ,
330+ EXPIRE_DIRTY_ATIME , work );
315331 trace_writeback_queue_io (wb , work , moved );
316332}
317333
@@ -435,6 +451,8 @@ static void requeue_inode(struct inode *inode, struct bdi_writeback *wb,
435451 * updates after data IO completion.
436452 */
437453 redirty_tail (inode , wb );
454+ } else if (inode -> i_state & I_DIRTY_TIME ) {
455+ list_move (& inode -> i_wb_list , & wb -> b_dirty_time );
438456 } else {
439457 /* The inode is clean. Remove from writeback lists. */
440458 list_del_init (& inode -> i_wb_list );
@@ -481,7 +499,13 @@ __writeback_single_inode(struct inode *inode, struct writeback_control *wbc)
481499 spin_lock (& inode -> i_lock );
482500
483501 dirty = inode -> i_state & I_DIRTY ;
484- inode -> i_state &= ~I_DIRTY ;
502+ if (((dirty & (I_DIRTY_SYNC | I_DIRTY_DATASYNC )) &&
503+ (inode -> i_state & I_DIRTY_TIME )) ||
504+ (inode -> i_state & I_DIRTY_TIME_EXPIRED )) {
505+ dirty |= I_DIRTY_TIME | I_DIRTY_TIME_EXPIRED ;
506+ trace_writeback_lazytime (inode );
507+ }
508+ inode -> i_state &= ~dirty ;
485509
486510 /*
487511 * Paired with smp_mb() in __mark_inode_dirty(). This allows
@@ -501,8 +525,10 @@ __writeback_single_inode(struct inode *inode, struct writeback_control *wbc)
501525
502526 spin_unlock (& inode -> i_lock );
503527
528+ if (dirty & I_DIRTY_TIME )
529+ mark_inode_dirty_sync (inode );
504530 /* Don't write the inode if only I_DIRTY_PAGES was set */
505- if (dirty & ( I_DIRTY_SYNC | I_DIRTY_DATASYNC ) ) {
531+ if (dirty & ~ I_DIRTY_PAGES ) {
506532 int err = write_inode (inode , wbc );
507533 if (ret == 0 )
508534 ret = err ;
@@ -550,7 +576,7 @@ writeback_single_inode(struct inode *inode, struct bdi_writeback *wb,
550576 * make sure inode is on some writeback list and leave it there unless
551577 * we have completely cleaned the inode.
552578 */
553- if (!(inode -> i_state & I_DIRTY ) &&
579+ if (!(inode -> i_state & I_DIRTY_ALL ) &&
554580 (wbc -> sync_mode != WB_SYNC_ALL ||
555581 !mapping_tagged (inode -> i_mapping , PAGECACHE_TAG_WRITEBACK )))
556582 goto out ;
@@ -565,7 +591,7 @@ writeback_single_inode(struct inode *inode, struct bdi_writeback *wb,
565591 * If inode is clean, remove it from writeback lists. Otherwise don't
566592 * touch it. See comment above for explanation.
567593 */
568- if (!(inode -> i_state & I_DIRTY ))
594+ if (!(inode -> i_state & I_DIRTY_ALL ))
569595 list_del_init (& inode -> i_wb_list );
570596 spin_unlock (& wb -> list_lock );
571597 inode_sync_complete (inode );
@@ -707,7 +733,7 @@ static long writeback_sb_inodes(struct super_block *sb,
707733 wrote += write_chunk - wbc .nr_to_write ;
708734 spin_lock (& wb -> list_lock );
709735 spin_lock (& inode -> i_lock );
710- if (!(inode -> i_state & I_DIRTY ))
736+ if (!(inode -> i_state & I_DIRTY_ALL ))
711737 wrote ++ ;
712738 requeue_inode (inode , wb , & wbc );
713739 inode_sync_complete (inode );
@@ -1145,40 +1171,52 @@ static noinline void block_dump___mark_inode_dirty(struct inode *inode)
11451171 * page->mapping->host, so the page-dirtying time is recorded in the internal
11461172 * blockdev inode.
11471173 */
1174+ #define I_DIRTY_INODE (I_DIRTY_SYNC | I_DIRTY_DATASYNC)
11481175void __mark_inode_dirty (struct inode * inode , int flags )
11491176{
11501177 struct super_block * sb = inode -> i_sb ;
11511178 struct backing_dev_info * bdi = NULL ;
1179+ int dirtytime ;
1180+
1181+ trace_writeback_mark_inode_dirty (inode , flags );
11521182
11531183 /*
11541184 * Don't do this for I_DIRTY_PAGES - that doesn't actually
11551185 * dirty the inode itself
11561186 */
1157- if (flags & (I_DIRTY_SYNC | I_DIRTY_DATASYNC )) {
1187+ if (flags & (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_TIME )) {
11581188 trace_writeback_dirty_inode_start (inode , flags );
11591189
11601190 if (sb -> s_op -> dirty_inode )
11611191 sb -> s_op -> dirty_inode (inode , flags );
11621192
11631193 trace_writeback_dirty_inode (inode , flags );
11641194 }
1195+ if (flags & I_DIRTY_INODE )
1196+ flags &= ~I_DIRTY_TIME ;
1197+ dirtytime = flags & I_DIRTY_TIME ;
11651198
11661199 /*
11671200 * Paired with smp_mb() in __writeback_single_inode() for the
11681201 * following lockless i_state test. See there for details.
11691202 */
11701203 smp_mb ();
11711204
1172- if ((inode -> i_state & flags ) == flags )
1205+ if (((inode -> i_state & flags ) == flags ) ||
1206+ (dirtytime && (inode -> i_state & I_DIRTY_INODE )))
11731207 return ;
11741208
11751209 if (unlikely (block_dump ))
11761210 block_dump___mark_inode_dirty (inode );
11771211
11781212 spin_lock (& inode -> i_lock );
1213+ if (dirtytime && (inode -> i_state & I_DIRTY_INODE ))
1214+ goto out_unlock_inode ;
11791215 if ((inode -> i_state & flags ) != flags ) {
11801216 const int was_dirty = inode -> i_state & I_DIRTY ;
11811217
1218+ if (flags & I_DIRTY_INODE )
1219+ inode -> i_state &= ~I_DIRTY_TIME ;
11821220 inode -> i_state |= flags ;
11831221
11841222 /*
@@ -1225,8 +1263,10 @@ void __mark_inode_dirty(struct inode *inode, int flags)
12251263 }
12261264
12271265 inode -> dirtied_when = jiffies ;
1228- list_move (& inode -> i_wb_list , & bdi -> wb .b_dirty );
1266+ list_move (& inode -> i_wb_list , dirtytime ?
1267+ & bdi -> wb .b_dirty_time : & bdi -> wb .b_dirty );
12291268 spin_unlock (& bdi -> wb .list_lock );
1269+ trace_writeback_dirty_inode_enqueue (inode );
12301270
12311271 if (wakeup_bdi )
12321272 bdi_wakeup_thread_delayed (bdi );
0 commit comments