add patch move-error-report-out-of-atomic-context
[ext4-patch-queue.git] / dont-keep-using-page-if-inline-conversion-fails
blobb310909b9a61b70377ac244620911cfcca599c68
1 ext4: don't keep using page if inline conversion fails
3 From: "Darrick J. Wong" <darrick.wong@oracle.com>
5 If inline->extent conversion fails (most probably due to ENOSPC) and
6 we release the temporary page that we allocated to transfer the file
7 contents, don't keep using the page pointer after releasing the page.
8 This occasionally leads to complaints about evicting locked pages or
9 hangs when blocksize > pagesize, because it's possible for the page to
10 get reallocated elsewhere in the meantime.
12 Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
13 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
14 Reviewed-by: Jan Kara <jack@suse.cz>
15 Cc: Tao Ma <tm@tao.ma>
16 ---
17  fs/ext4/inline.c |    4 +++-
18  1 file changed, 3 insertions(+), 1 deletion(-)
21 diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
22 index bea662b..378aadf 100644
23 --- a/fs/ext4/inline.c
24 +++ b/fs/ext4/inline.c
25 @@ -594,6 +594,7 @@ retry:
26         if (ret) {
27                 unlock_page(page);
28                 page_cache_release(page);
29 +               page = NULL;
30                 ext4_orphan_add(handle, inode);
31                 up_write(&EXT4_I(inode)->xattr_sem);
32                 sem_held = 0;
33 @@ -613,7 +614,8 @@ retry:
34         if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
35                 goto retry;
37 -       block_commit_write(page, from, to);
38 +       if (page)
39 +               block_commit_write(page, from, to);
40  out:
41         if (page) {
42                 unlock_page(page);