summaryrefslogtreecommitdiff
path: root/mm/shmem.c
diff options
context:
space:
mode:
authorAndrew Morton <akpm@linux-foundation.org>2022-12-09 19:31:11 -0800
committerAndrew Morton <akpm@linux-foundation.org>2022-12-09 19:31:11 -0800
commit3b91010500eba3601e906b0e92cf84fab4d895d1 (patch)
tree6724b9c611dc32115bb2e0d7a6f45d007830b2b8 /mm/shmem.c
parente0ff428042335c7b62785b3cf911c427a618bc86 (diff)
parent4a7ba45b1a435e7097ca0f79a847d0949d0eb088 (diff)
Merge branch 'mm-hotfixes-stable' into mm-stable
Diffstat (limited to 'mm/shmem.c')
-rw-r--r--mm/shmem.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/mm/shmem.c b/mm/shmem.c
index f418d21205be..17adb7f6f6e4 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -950,6 +950,15 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend,
cond_resched();
}
+ /*
+ * When undoing a failed fallocate, we want none of the partial folio
+ * zeroing and splitting below, but shall want to truncate the whole
+ * folio when !uptodate indicates that it was added by this fallocate,
+ * even when [lstart, lend] covers only a part of the folio.
+ */
+ if (unfalloc)
+ goto whole_folios;
+
same_folio = (lstart >> PAGE_SHIFT) == (lend >> PAGE_SHIFT);
folio = shmem_get_partial_folio(inode, lstart >> PAGE_SHIFT);
if (folio) {
@@ -975,6 +984,8 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend,
folio_put(folio);
}
+whole_folios:
+
index = start;
while (index < end) {
cond_resched();