Commit df1c5d73 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'for-5.19/writeback-2022-05-22' of git://git.kernel.dk/linux-block

Pull writeback fix from Jens Axboe:
 "A single writeback fix that didn't belong in any other branch,
  correcting the number of skipped pages"

* tag 'for-5.19/writeback-2022-05-22' of git://git.kernel.dk/linux-block:
  fs-writeback: writeback_sb_inodes:Recalculate 'wrote' according skipped pages
parents 9836e93c 68f4c6eb
...@@ -1779,11 +1779,12 @@ static long writeback_sb_inodes(struct super_block *sb, ...@@ -1779,11 +1779,12 @@ static long writeback_sb_inodes(struct super_block *sb,
}; };
unsigned long start_time = jiffies; unsigned long start_time = jiffies;
long write_chunk; long write_chunk;
long wrote = 0; /* count both pages and inodes */ long total_wrote = 0; /* count both pages and inodes */
while (!list_empty(&wb->b_io)) { while (!list_empty(&wb->b_io)) {
struct inode *inode = wb_inode(wb->b_io.prev); struct inode *inode = wb_inode(wb->b_io.prev);
struct bdi_writeback *tmp_wb; struct bdi_writeback *tmp_wb;
long wrote;
if (inode->i_sb != sb) { if (inode->i_sb != sb) {
if (work->sb) { if (work->sb) {
...@@ -1859,7 +1860,9 @@ static long writeback_sb_inodes(struct super_block *sb, ...@@ -1859,7 +1860,9 @@ static long writeback_sb_inodes(struct super_block *sb,
wbc_detach_inode(&wbc); wbc_detach_inode(&wbc);
work->nr_pages -= write_chunk - wbc.nr_to_write; work->nr_pages -= write_chunk - wbc.nr_to_write;
wrote += write_chunk - wbc.nr_to_write; wrote = write_chunk - wbc.nr_to_write - wbc.pages_skipped;
wrote = wrote < 0 ? 0 : wrote;
total_wrote += wrote;
if (need_resched()) { if (need_resched()) {
/* /*
...@@ -1881,7 +1884,7 @@ static long writeback_sb_inodes(struct super_block *sb, ...@@ -1881,7 +1884,7 @@ static long writeback_sb_inodes(struct super_block *sb,
tmp_wb = inode_to_wb_and_lock_list(inode); tmp_wb = inode_to_wb_and_lock_list(inode);
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
if (!(inode->i_state & I_DIRTY_ALL)) if (!(inode->i_state & I_DIRTY_ALL))
wrote++; total_wrote++;
requeue_inode(inode, tmp_wb, &wbc); requeue_inode(inode, tmp_wb, &wbc);
inode_sync_complete(inode); inode_sync_complete(inode);
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
...@@ -1895,14 +1898,14 @@ static long writeback_sb_inodes(struct super_block *sb, ...@@ -1895,14 +1898,14 @@ static long writeback_sb_inodes(struct super_block *sb,
* bail out to wb_writeback() often enough to check * bail out to wb_writeback() often enough to check
* background threshold and other termination conditions. * background threshold and other termination conditions.
*/ */
if (wrote) { if (total_wrote) {
if (time_is_before_jiffies(start_time + HZ / 10UL)) if (time_is_before_jiffies(start_time + HZ / 10UL))
break; break;
if (work->nr_pages <= 0) if (work->nr_pages <= 0)
break; break;
} }
} }
return wrote; return total_wrote;
} }
static long __writeback_inodes_wb(struct bdi_writeback *wb, static long __writeback_inodes_wb(struct bdi_writeback *wb,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment