Commit de89de6e authored by Theodore Ts'o's avatar Theodore Ts'o

ext4: Restore wbc->range_start in ext4_da_writepages()

To solve a lock inversion problem, we implement part of the
range_cyclic algorithm in ext4_da_writepages().  (See commit 2acf2c26
for more details.)

As part of that change wbc->range_start was modified by ext4's
writepages function, which causes its callers to get confused since
they aren't expecting the filesystem to modify it.  The simplest fix
is to save and restore wbc->range_start in ext4_da_writepages.
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent 98a56ab3
...@@ -2749,6 +2749,7 @@ static int ext4_da_writepages(struct address_space *mapping, ...@@ -2749,6 +2749,7 @@ static int ext4_da_writepages(struct address_space *mapping,
long pages_skipped; long pages_skipped;
int range_cyclic, cycled = 1, io_done = 0; int range_cyclic, cycled = 1, io_done = 0;
int needed_blocks, ret = 0, nr_to_writebump = 0; int needed_blocks, ret = 0, nr_to_writebump = 0;
loff_t range_start = wbc->range_start;
struct ext4_sb_info *sbi = EXT4_SB(mapping->host->i_sb); struct ext4_sb_info *sbi = EXT4_SB(mapping->host->i_sb);
trace_ext4_da_writepages(inode, wbc); trace_ext4_da_writepages(inode, wbc);
...@@ -2917,6 +2918,7 @@ static int ext4_da_writepages(struct address_space *mapping, ...@@ -2917,6 +2918,7 @@ static int ext4_da_writepages(struct address_space *mapping,
if (!no_nrwrite_index_update) if (!no_nrwrite_index_update)
wbc->no_nrwrite_index_update = 0; wbc->no_nrwrite_index_update = 0;
wbc->nr_to_write -= nr_to_writebump; wbc->nr_to_write -= nr_to_writebump;
wbc->range_start = range_start;
trace_ext4_da_writepages_result(inode, wbc, ret, pages_written); trace_ext4_da_writepages_result(inode, wbc, ret, pages_written);
return ret; return ret;
} }
......
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