Repository navigation
Commit 05bf86b
tmpfs: fix race between swapoff and writepage
Shame on me! Commit b1dea80 "tmpfs: fix race between umount and
writepage" fixed the advertized race, but introduced another: as even
its comment makes clear, we cannot safely rely on a peek at list_empty()
while holding no lock - until info->swapped is set, shmem_unuse_inode()
may delete any formerly-swapped inode from the shmem_swaplist, which
in this case would leave a swap area impossible to swapoff.
Although I don't relish taking the mutex every time, I don't care much
for the alternatives either; and at least the peek at list_empty() in
shmem_evict_inode() (a hotter path since most inodes would never have
been swapped) remains safe, because we already truncated the whole file.
Signed-off-by: Hugh Dickins <hughd@google.com>
Cc: stable@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>1 parent afa4979 commit 05bf86b
1 file changed
Lines changed: 4 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1037 | 1037 | | |
1038 | 1038 | | |
1039 | 1039 | | |
1040 | | - | |
1041 | 1040 | | |
1042 | 1041 | | |
1043 | 1042 | | |
| |||
1072 | 1071 | | |
1073 | 1072 | | |
1074 | 1073 | | |
1075 | | - | |
| 1074 | + | |
1076 | 1075 | | |
1077 | | - | |
1078 | | - | |
1079 | | - | |
| 1076 | + | |
| 1077 | + | |
1080 | 1078 | | |
1081 | 1079 | | |
1082 | 1080 | | |
1083 | | - | |
| 1081 | + | |
1084 | 1082 | | |
1085 | 1083 | | |
1086 | 1084 | | |
| |||
0 commit comments