]> git.baikalelectronics.ru Git - kernel.git/commit
tmpfs: fix data loss from failed fallocate
authorHugh Dickins <hughd@google.com>
Mon, 5 Dec 2022 00:51:50 +0000 (16:51 -0800)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 10 Dec 2022 02:41:16 +0000 (18:41 -0800)
commitdc16c1439b8d7ff45d6d04a22f790059c209f0be
tree161340d0e58642c08678989c972b19a8299a8705
parent5d76ae32e2e9e6b89ad0b304a1de3a83f76608ee
tmpfs: fix data loss from failed fallocate

Fix tmpfs data loss when the fallocate system call is interrupted by a
signal, or fails for some other reason.  The partial folio handling in
shmem_undo_range() forgot to consider this unfalloc case, and was liable
to erase or truncate out data which had already been committed earlier.

It turns out that none of the partial folio handling there is appropriate
for the unfalloc case, which just wants to proceed to removal of whole
folios: which find_get_entries() provides, even when partially covered.

Original patch by Rui Wang.

Link: https://lore.kernel.org/linux-mm/33b85d82.7764.1842e9ab207.Coremail.chenguoqic@163.com/
Link: https://lkml.kernel.org/r/a5dac112-cf4b-7af-a33-f386e347fd38@google.com
Fixes: 265408ca6163 ("truncate,shmem: Handle truncates that split large folios")
Signed-off-by: Hugh Dickins <hughd@google.com>
Reported-by: Guoqi Chen <chenguoqic@163.com>
Link: https://lore.kernel.org/all/20221101032248.819360-1-kernel@hev.cc/
Cc: Rui Wang <kernel@hev.cc>
Cc: Huacai Chen <chenhuacai@loongson.cn>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Cc: <stable@vger.kernel.org> [5.17+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/shmem.c