[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231119194740.94101-20-ryncsn@gmail.com>
Date: Mon, 20 Nov 2023 03:47:35 +0800
From: Kairui Song <ryncsn@...il.com>
To: linux-mm@...ck.org
Cc: Andrew Morton <akpm@...ux-foundation.org>,
"Huang, Ying" <ying.huang@...el.com>,
David Hildenbrand <david@...hat.com>,
Hugh Dickins <hughd@...gle.com>,
Johannes Weiner <hannes@...xchg.org>,
Matthew Wilcox <willy@...radead.org>,
Michal Hocko <mhocko@...e.com>, linux-kernel@...r.kernel.org,
Kairui Song <kasong@...cent.com>
Subject: [PATCH 19/24] shmem, swap: refactor error check on OOM or race
From: Kairui Song <kasong@...cent.com>
It should always check if a swap entry is already swaped in on error,
fix potential false error issue.
Signed-off-by: Kairui Song <kasong@...cent.com>
---
mm/shmem.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/mm/shmem.c b/mm/shmem.c
index 81d129aa66d1..6154b5b68b8f 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1857,13 +1857,11 @@ static int shmem_swapin_folio(struct inode *inode, pgoff_t index,
page = swapin_page_non_fault(swap, gfp, mpol, ilx, fault_mm, &result);
mpol_cond_put(mpol);
- if (PTR_ERR(page) == -EBUSY) {
- if (!shmem_confirm_swap(mapping, index, swap))
- return -EEXIST;
+ if (IS_ERR_OR_NULL(page)) {
+ if (!page)
+ error = -ENOMEM;
else
- return -EINVAL;
- } else if (!page) {
- error = -ENOMEM;
+ error = -EINVAL;
goto failed;
} else {
folio = page_folio(page);
--
2.42.0
Powered by blists - more mailing lists