Commit c5a1858
mm: shmem: don't truncate page if memory failure happens
The current behavior of memory failure is to truncate the page cache
regardless of dirty or clean. If the page is dirty the later access will
get the obsolete data from disk without any notification to the users.
This may cause silent data loss. It is even worse for shmem since shmem
is in-memory filesystem, truncating page cache means discarding data
blocks. The later read would return all zero.
The right approach is to keep the corrupted page in page cache, any later
access would return error for syscalls or SIGBUS for page fault, until the
file is truncated, hole punched or removed. The regular storage backed
filesystems would be more complicated so this patch is focused on shmem.
This also unblock the support for soft offlining shmem THP.
[arnd@arndb.de: fix uninitialized variable use in me_pagecache_clean()]
Link: https://lkml.kernel.org/r/20211022064748.4173718-1-arnd@kernel.org
[Fix invalid pointer dereference in shmem_read_mapping_page_gfp() with a
slight different implementation from what Ajay Garg <ajaygargnsit@gmail.com>
and Muchun Song <songmuchun@bytedance.com> proposed and reworked the
error handling of shmem_write_begin() suggested by Linus]
Link: https://lore.kernel.org/linux-mm/20211111084617.6746-1-ajaygargnsit@gmail.com/
Link: https://lkml.kernel.org/r/20211020210755.23964-6-shy828301@gmail.com
Link: https://lkml.kernel.org/r/20211116193247.21102-1-shy828301@gmail.com
Signed-off-by: Yang Shi <shy828301@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Hugh Dickins <hughd@google.com>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Naoya Horiguchi <naoya.horiguchi@nec.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Peter Xu <peterx@redhat.com>
Cc: Ajay Garg <ajaygargnsit@gmail.com>
Cc: Muchun Song <songmuchun@bytedance.com>
Cc: Andy Lavr <andy.lavr@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>1 parent 969662c commit c5a1858
3 files changed
+61
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| |||
867 | 868 | | |
868 | 869 | | |
869 | 870 | | |
| 871 | + | |
870 | 872 | | |
871 | 873 | | |
872 | 874 | | |
| |||
895 | 897 | | |
896 | 898 | | |
897 | 899 | | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
898 | 906 | | |
899 | 907 | | |
900 | 908 | | |
901 | 909 | | |
902 | 910 | | |
903 | 911 | | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
904 | 915 | | |
905 | 916 | | |
906 | 917 | | |
907 | | - | |
908 | | - | |
909 | | - | |
910 | 918 | | |
911 | 919 | | |
912 | 920 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2462 | 2462 | | |
2463 | 2463 | | |
2464 | 2464 | | |
| 2465 | + | |
2465 | 2466 | | |
2466 | 2467 | | |
2467 | 2468 | | |
| |||
2472 | 2473 | | |
2473 | 2474 | | |
2474 | 2475 | | |
2475 | | - | |
| 2476 | + | |
| 2477 | + | |
| 2478 | + | |
| 2479 | + | |
| 2480 | + | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
| 2487 | + | |
| 2488 | + | |
2476 | 2489 | | |
2477 | 2490 | | |
2478 | 2491 | | |
| |||
2559 | 2572 | | |
2560 | 2573 | | |
2561 | 2574 | | |
| 2575 | + | |
| 2576 | + | |
| 2577 | + | |
| 2578 | + | |
| 2579 | + | |
| 2580 | + | |
2562 | 2581 | | |
2563 | 2582 | | |
2564 | 2583 | | |
| |||
3098 | 3117 | | |
3099 | 3118 | | |
3100 | 3119 | | |
3101 | | - | |
| 3120 | + | |
| 3121 | + | |
3102 | 3122 | | |
3103 | 3123 | | |
3104 | 3124 | | |
3105 | 3125 | | |
3106 | 3126 | | |
3107 | 3127 | | |
3108 | 3128 | | |
| 3129 | + | |
| 3130 | + | |
| 3131 | + | |
| 3132 | + | |
| 3133 | + | |
| 3134 | + | |
| 3135 | + | |
3109 | 3136 | | |
3110 | 3137 | | |
3111 | 3138 | | |
| |||
3756 | 3783 | | |
3757 | 3784 | | |
3758 | 3785 | | |
| 3786 | + | |
| 3787 | + | |
| 3788 | + | |
| 3789 | + | |
| 3790 | + | |
| 3791 | + | |
| 3792 | + | |
3759 | 3793 | | |
3760 | 3794 | | |
3761 | 3795 | | |
| |||
3766 | 3800 | | |
3767 | 3801 | | |
3768 | 3802 | | |
3769 | | - | |
| 3803 | + | |
3770 | 3804 | | |
3771 | 3805 | | |
3772 | 3806 | | |
| |||
4174 | 4208 | | |
4175 | 4209 | | |
4176 | 4210 | | |
4177 | | - | |
4178 | | - | |
4179 | | - | |
| 4211 | + | |
| 4212 | + | |
| 4213 | + | |
| 4214 | + | |
| 4215 | + | |
| 4216 | + | |
| 4217 | + | |
| 4218 | + | |
4180 | 4219 | | |
4181 | 4220 | | |
4182 | 4221 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
235 | 240 | | |
236 | 241 | | |
237 | 242 | | |
| |||
0 commit comments