Skip to content

Commit 08259d5

Browse files
Hugh Dickinstorvalds
authored andcommitted
mm: add comment on swap_duplicate's error code
swap_duplicate()'s loop appears to miss out on returning the error code from __swap_duplicate(), except when that's -ENOMEM. In fact this is intentional: prior to -ENOMEM for swap_count_continuation, swap_duplicate() was void (and the case only occurs when copy_one_pte() hits a corrupt pte). But that's surprising behaviour, which certainly deserves a comment. Signed-off-by: Hugh Dickins <hughd@google.com> Reported-by: Huang Shijie <shijie8@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent c08c6e1 commit 08259d5

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎mm/swapfile.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2161,7 +2161,11 @@ void swap_shmem_alloc(swp_entry_t entry)
21612161
}
21622162

21632163
/*
2164-
* increase reference count of swap entry by 1.
2164+
* Increase reference count of swap entry by 1.
2165+
* Returns 0 for success, or -ENOMEM if a swap_count_continuation is required
2166+
* but could not be atomically allocated. Returns 0, just as if it succeeded,
2167+
* if __swap_duplicate() fails for another reason (-EINVAL or -ENOENT), which
2168+
* might occur if a page table entry has got corrupted.
21652169
*/
21662170
int swap_duplicate(swp_entry_t entry)
21672171
{

0 commit comments

Comments
 (0)