Skip to content

Commit

Permalink
ext4: don't release page refs in ext4_end_bio()
Browse files Browse the repository at this point in the history
We can clear PageWriteback on each page when the IO
completes, but we can't release the references on the page
until we convert any uninitialized extents.

Without this patch, the use of the dioread_nolock mount
option can break buffered writes, because extents may
not be converted by the time a subsequent buffered read
comes in; if the page is not in the page cache, a read
will return zeros if the extent is still uninitialized.

I tested this with a (temporary) patch that adds a call
to msleep(1000) at the start of ext4_end_io_work(), to delay
processing of each DIO-unwritten work queue item.  With this
msleep(), a simple workload of

  fallocate
  write
  fadvise
  read

will fail without this patch, succeeds with it.

Signed-off-by: Curt Wohlgemuth <curtw@google.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
  • Loading branch information
Curt Wohlgemuth authored and Theodore Ts'o committed Mar 5, 2012
1 parent 491caa4 commit b43d17f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions fs/ext4/page-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ void ext4_ioend_wait(struct inode *inode)
static void put_io_page(struct ext4_io_page *io_page)
{
if (atomic_dec_and_test(&io_page->p_count)) {
end_page_writeback(io_page->p_page);
put_page(io_page->p_page);
kmem_cache_free(io_page_cachep, io_page);
}
Expand Down Expand Up @@ -234,9 +233,9 @@ static void ext4_end_bio(struct bio *bio, int error)
} while (bh != head);
}

put_io_page(io_end->pages[i]);
if (atomic_read(&io_end->pages[i]->p_count) == 1)
end_page_writeback(io_end->pages[i]->p_page);
}
io_end->num_io_pages = 0;
inode = io_end->inode;

if (error) {
Expand Down Expand Up @@ -428,6 +427,8 @@ int ext4_bio_write_page(struct ext4_io_submit *io,
* PageWriteback bit from the page to prevent the system from
* wedging later on.
*/
if (atomic_read(&io_page->p_count) == 1)
end_page_writeback(page);
put_io_page(io_page);
return ret;
}

0 comments on commit b43d17f

Please sign in to comment.