Commit 5c093a1c authored by Baolin Wang's avatar Baolin Wang Committed by Euler
Browse files

mm: shmem: fix the update of 'shmem_falloc->nr_unswapped'

mainline inclusion
from mainline-v6.13-rc1
commit d77b90d2b2642655b5f60953c36ad887257e1802
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBGFBA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d77b90d2b2642655b5f60953c36ad887257e1802

--------------------------------

The 'shmem_falloc->nr_unswapped' is used to record how many writepage
refused to swap out because fallocate() is allocating, but after shmem
supports large folio swap out, the update of 'shmem_falloc->nr_unswapped'
does not use the correct number of pages in the large folio, which may
lead to fallocate() not exiting as soon as possible.

Anyway, this is found through code inspection, and I am not sure whether
it would actually cause serious issues.

Link: https://lkml.kernel.org/r/f66a0119d0564c2c37c84f045835b870d1b2196f.1734593154.git.baolin.wang@linux.alibaba.com


Fixes: 809bc86517cc ("mm: shmem: support large folio swap out")
Signed-off-by: default avatarBaolin Wang <baolin.wang@linux.alibaba.com>
Acked-by: default avatarDavid Hildenbrand <david@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarWang Lian <dev01404@linx-info.com>
---
parent c01cfed1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1524,7 +1524,7 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc)
			    !shmem_falloc->waitq &&
			    index >= shmem_falloc->start &&
			    index < shmem_falloc->next)
				shmem_falloc->nr_unswapped++;
				shmem_falloc->nr_unswapped += nr_pages;
			else
				shmem_falloc = NULL;
			spin_unlock(&inode->i_lock);