]>
Commit | Line | Data |
---|---|---|
99167358 GKH |
1 | From 7f556567036cb7f89aabe2f0954b08566b4efb53 Mon Sep 17 00:00:00 2001 |
2 | From: Hugh Dickins <hughd@google.com> | |
3 | Date: Sun, 10 Jul 2016 16:46:32 -0700 | |
4 | Subject: tmpfs: fix regression hang in fallocate undo | |
5 | ||
6 | From: Hugh Dickins <hughd@google.com> | |
7 | ||
8 | commit 7f556567036cb7f89aabe2f0954b08566b4efb53 upstream. | |
9 | ||
10 | The well-spotted fallocate undo fix is good in most cases, but not when | |
11 | fallocate failed on the very first page. index 0 then passes lend -1 | |
12 | to shmem_undo_range(), and that has two bad effects: (a) that it will | |
13 | undo every fallocation throughout the file, unrestricted by the current | |
14 | range; but more importantly (b) it can cause the undo to hang, because | |
15 | lend -1 is treated as truncation, which makes it keep on retrying until | |
16 | every page has gone, but those already fully instantiated will never go | |
17 | away. Big thank you to xfstests generic/269 which demonstrates this. | |
18 | ||
19 | Fixes: b9b4bb26af01 ("tmpfs: don't undo fallocate past its last page") | |
20 | Signed-off-by: Hugh Dickins <hughd@google.com> | |
21 | Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> | |
22 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
23 | ||
24 | --- | |
25 | mm/shmem.c | 8 +++++--- | |
26 | 1 file changed, 5 insertions(+), 3 deletions(-) | |
27 | ||
28 | --- a/mm/shmem.c | |
29 | +++ b/mm/shmem.c | |
30 | @@ -2236,9 +2236,11 @@ static long shmem_fallocate(struct file | |
31 | NULL); | |
32 | if (error) { | |
33 | /* Remove the !PageUptodate pages we added */ | |
34 | - shmem_undo_range(inode, | |
35 | - (loff_t)start << PAGE_SHIFT, | |
36 | - ((loff_t)index << PAGE_SHIFT) - 1, true); | |
37 | + if (index > start) { | |
38 | + shmem_undo_range(inode, | |
39 | + (loff_t)start << PAGE_SHIFT, | |
40 | + ((loff_t)index << PAGE_SHIFT) - 1, true); | |
41 | + } | |
42 | goto undone; | |
43 | } | |
44 |