Skip to content

Commit e1df8b0

Browse files
committed
Merge branch 'writeback-plugging'
Fix up the writeback plugging introduced in commit d353d75 ("writeback: plug writeback at a high level") that then caused problems due to the unplug happening with a spinlock held. * writeback-plugging: writeback: plug writeback in wb_writeback() and writeback_inodes_wb() Revert "writeback: plug writeback at a high level"
2 parents dfb22fc + 505a666 commit e1df8b0

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

fs/fs-writeback.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,6 +1380,10 @@ static long writeback_chunk_size(struct bdi_writeback *wb,
13801380
* Write a portion of b_io inodes which belong to @sb.
13811381
*
13821382
* Return the number of pages and/or inodes written.
1383+
*
1384+
* NOTE! This is called with wb->list_lock held, and will
1385+
* unlock and relock that for each inode it ends up doing
1386+
* IO for.
13831387
*/
13841388
static long writeback_sb_inodes(struct super_block *sb,
13851389
struct bdi_writeback *wb,
@@ -1398,9 +1402,7 @@ static long writeback_sb_inodes(struct super_block *sb,
13981402
unsigned long start_time = jiffies;
13991403
long write_chunk;
14001404
long wrote = 0; /* count both pages and inodes */
1401-
struct blk_plug plug;
14021405

1403-
blk_start_plug(&plug);
14041406
while (!list_empty(&wb->b_io)) {
14051407
struct inode *inode = wb_inode(wb->b_io.prev);
14061408

@@ -1498,7 +1500,6 @@ static long writeback_sb_inodes(struct super_block *sb,
14981500
break;
14991501
}
15001502
}
1501-
blk_finish_plug(&plug);
15021503
return wrote;
15031504
}
15041505

@@ -1545,12 +1546,15 @@ static long writeback_inodes_wb(struct bdi_writeback *wb, long nr_pages,
15451546
.range_cyclic = 1,
15461547
.reason = reason,
15471548
};
1549+
struct blk_plug plug;
15481550

1551+
blk_start_plug(&plug);
15491552
spin_lock(&wb->list_lock);
15501553
if (list_empty(&wb->b_io))
15511554
queue_io(wb, &work);
15521555
__writeback_inodes_wb(wb, &work);
15531556
spin_unlock(&wb->list_lock);
1557+
blk_finish_plug(&plug);
15541558

15551559
return nr_pages - work.nr_pages;
15561560
}
@@ -1578,10 +1582,12 @@ static long wb_writeback(struct bdi_writeback *wb,
15781582
unsigned long oldest_jif;
15791583
struct inode *inode;
15801584
long progress;
1585+
struct blk_plug plug;
15811586

15821587
oldest_jif = jiffies;
15831588
work->older_than_this = &oldest_jif;
15841589

1590+
blk_start_plug(&plug);
15851591
spin_lock(&wb->list_lock);
15861592
for (;;) {
15871593
/*
@@ -1661,6 +1667,7 @@ static long wb_writeback(struct bdi_writeback *wb,
16611667
}
16621668
}
16631669
spin_unlock(&wb->list_lock);
1670+
blk_finish_plug(&plug);
16641671

16651672
return nr_pages - work->nr_pages;
16661673
}

0 commit comments

Comments
 (0)