mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
ext4: fix ext4_da_block_invalidatepages() to handle page range properly
If ext4_da_block_invalidatepages() is called because of a failure from ext4_map_blocks() in mpage_da_map_and_submit(), it's supposed to clean up -- including unlock -- all the pages in the mpd structure. But these values may not match up, even on a system in which block size == page size: mpd->b_blocknr != mpd->first_page mpd->b_size != (mpd->next_page - mpd->first_page) ext4_da_block_invalidatepages() has been using b_blocknr and b_size; this patch changes it to use first_page and next_page. Tested: I injected a small number (5%) of failures in ext4_map_blocks() in the case that the flags contain EXT4_GET_BLOCKS_DELALLOC_RESERVE, and ran fsstress on this kernel. Without this patch, I got hung tasks every time. With this patch, I see no hangs in many runs of fsstress. Signed-off-by: Curt Wohlgemuth <curtw@google.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This commit is contained in:
parent
e0fd9b9076
commit
c7f5938adc
1 changed files with 4 additions and 7 deletions
|
@ -2165,8 +2165,7 @@ static int mpage_da_submit_io(struct mpage_da_data *mpd,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ext4_da_block_invalidatepages(struct mpage_da_data *mpd,
|
static void ext4_da_block_invalidatepages(struct mpage_da_data *mpd)
|
||||||
sector_t logical, long blk_cnt)
|
|
||||||
{
|
{
|
||||||
int nr_pages, i;
|
int nr_pages, i;
|
||||||
pgoff_t index, end;
|
pgoff_t index, end;
|
||||||
|
@ -2174,9 +2173,8 @@ static void ext4_da_block_invalidatepages(struct mpage_da_data *mpd,
|
||||||
struct inode *inode = mpd->inode;
|
struct inode *inode = mpd->inode;
|
||||||
struct address_space *mapping = inode->i_mapping;
|
struct address_space *mapping = inode->i_mapping;
|
||||||
|
|
||||||
index = logical >> (PAGE_CACHE_SHIFT - inode->i_blkbits);
|
index = mpd->first_page;
|
||||||
end = (logical + blk_cnt - 1) >>
|
end = mpd->next_page - 1;
|
||||||
(PAGE_CACHE_SHIFT - inode->i_blkbits);
|
|
||||||
while (index <= end) {
|
while (index <= end) {
|
||||||
nr_pages = pagevec_lookup(&pvec, mapping, index, PAGEVEC_SIZE);
|
nr_pages = pagevec_lookup(&pvec, mapping, index, PAGEVEC_SIZE);
|
||||||
if (nr_pages == 0)
|
if (nr_pages == 0)
|
||||||
|
@ -2312,8 +2310,7 @@ static void mpage_da_map_and_submit(struct mpage_da_data *mpd)
|
||||||
ext4_print_free_blocks(mpd->inode);
|
ext4_print_free_blocks(mpd->inode);
|
||||||
}
|
}
|
||||||
/* invalidate all the pages */
|
/* invalidate all the pages */
|
||||||
ext4_da_block_invalidatepages(mpd, next,
|
ext4_da_block_invalidatepages(mpd);
|
||||||
mpd->b_size >> mpd->inode->i_blkbits);
|
|
||||||
|
|
||||||
/* Mark this page range as having been completed */
|
/* Mark this page range as having been completed */
|
||||||
mpd->io_done = 1;
|
mpd->io_done = 1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue