Skip to content

Commit 2d11e73

Browse files
Hugh Dickinstorvalds
authored andcommitted
mm/filemap: fix find_lock_entries hang on 32-bit THP
No problem on 64-bit, or without huge pages, but xfstests generic/308 hung uninterruptibly on 32-bit huge tmpfs. Since commit 0cc3b0e ("Clarify (and fix) in 4.13 MAX_LFS_FILESIZE macros"), MAX_LFS_FILESIZE is only a PAGE_SIZE away from wrapping 32-bit xa_index to 0, so the new find_lock_entries() has to be extra careful when handling a THP. Link: https://lkml.kernel.org/r/alpine.LSU.2.11.2104211735430.3299@eggly.anvils Fixes: 5c211ba ("mm: add and use find_lock_entries") Signed-off-by: Hugh Dickins <hughd@google.com> Cc: Matthew Wilcox <willy@infradead.org> Cc: William Kucharski <william.kucharski@oracle.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Jan Kara <jack@suse.cz> Cc: Dave Chinner <dchinner@redhat.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> Cc: Yang Shi <yang.shi@linux.alibaba.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 2896900 commit 2d11e73

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

mm/filemap.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1969,8 +1969,14 @@ unsigned find_lock_entries(struct address_space *mapping, pgoff_t start,
19691969
put:
19701970
put_page(page);
19711971
next:
1972-
if (!xa_is_value(page) && PageTransHuge(page))
1973-
xas_set(&xas, page->index + thp_nr_pages(page));
1972+
if (!xa_is_value(page) && PageTransHuge(page)) {
1973+
unsigned int nr_pages = thp_nr_pages(page);
1974+
1975+
/* Final THP may cross MAX_LFS_FILESIZE on 32-bit */
1976+
xas_set(&xas, page->index + nr_pages);
1977+
if (xas.xa_index < nr_pages)
1978+
break;
1979+
}
19741980
}
19751981
rcu_read_unlock();
19761982

0 commit comments

Comments
 (0)