From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796086648; b=kSjHgk/NL13cCwExnlIDcaHcnWb4S5zuMZa/wxqI1tYKDe6hBBdaHu48neYQ8jUXHidr YaIk+OTzYuNS6WSc3uCaO/a/kVCIFOxqORPsqaKti4PW72cEpkir2WYCmJbh1VoUxpt+0 hiLkESrPIuIDp7Z76kv0x/NtrSYdZZo9Fgt33EBx2o3JOplIJtfTqN/lgAJXVUWa8X9f8 lpdaPetrLaMmyJjF5EDQ0qCSQeCcDRsNSRijQyrsPZ/EGdVwH9zTOjh8Gz9llqBoR8V45 A6npsqM3iRsl1Fz557nvThbWnT8TCnt50ED1dritsKI0l0V4nMPtrtwdeCzfs2ivyGg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796086648; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=kC3qdsXZBepmWjDRbMoIMNIVEGwG1Ii+UNnzbgmsXCo=; b=aNDzMeMuX6CNQ7L2EdldTfz1OJL/vpqeTM+/Q/68TqQGscJ/LT6X2zfhtaRJCzFjr7YI anCrnnN5W0gsdGKnsBVUY7XTriuN3nrY9sH7MDWdC7GfCc4r3QkyiRCIJwDHtG/k9IcfE EfhA7Xza4/zY9Yoj4HC7c7dwRZCVuaeH2e/b2yLyfhOYAWEv6f+gG0k08zJMxgc2UyYqi yerNXWREGSWX96o3EFG8lR5Oq1roJSRkq1EGWrtuaED+nig1KKdYlzvxk2zPjmMjDDooL sJHDQeiIJZ8HRI4mLqR5zPegcdP3zIuelhX+fNuHWfp9B28QH6FenCIacuZzB3GXZxg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=nhgca8DE; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B867D606A320; Tue, 1 Dec 2026 00:57:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=nhgca8DE Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E8FD1F00893; Tue, 1 Dec 2026 00:57:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796086648; bh=kC3qdsXZBepmWjDRbMoIMNIVEGwG1Ii+UNnzbgmsXCo=; h=Date:To:From:In-Reply-To:References:Subject; b=nhgca8DEvgJWWPk2IWXe8BCrRvho44NyWzb+kiAWULz6DE4M0cRxl2oOIDTc9eCmm yiDov5efTYPI0H3YQkDqXrzdAEGmuSeFdt7+22h+6O2xLGQEEZ5LtzjrccP2UNI3Jo lXT9XIya42nPA/BT9ZSPKRyknWdY0jm4gfBFcFZQ= Date: Mon, 30 Nov 2026 16:57:27 -0800 To: mm-commits@vger.kernel.org,zhangpeng362@huawei.com,yi.zhang@huawei.com, willy@infradead.org,wangkefeng.wang@huawei.com,tytso@mit.edu, stable@vger.kernel.org,ojaswin@linux.ibm.com,mcgrof@kernel.org, libaokun1@huawei.com,john.garry@linux.dev,jack@suse.cz, huang.ying.caritas@gmail.com,hare@suse.de,david@kernel.org, brauner@kernel.org,mason@kernel.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20261129-filemap_fixes-v1-2-1546675e3c97@kernel.org> References: <20261129-filemap_fixes-v1-2-1546675e3c97@kernel.org> Subject: + mm-filemap-update-the-folio-order-range-atomically.patch added to mm-new branch Message-Id: <20261201005728.3E8FD1F00893@smtp.kernel.org> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list The patch titled Subject: mm/filemap: update the folio order range atomically has been added to the -mm mm-new branch. Its filename is mm-filemap-update-the-folio-order-range-atomically.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-filemap-update-the-folio-order-range-atomically.patch This patch will later appear in the mm-new branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new. The mm-new branch of mm.git is not included in linux-next If a few days of testing in mm-new is successful, the patch will me moved into mm.git's mm-unstable branch, which is included in linux-next Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Chris Mason Subject: mm/filemap: update the folio order range atomically Date: Sun, 29 Nov 2026 10:05:10 +0100 mapping_set_folio_order_range() updates mapping->flags with a plain load and store, assuming that nobody can modify the flags concurrently. However, set_blocksize() and ext4_change_inode_journal_flag() call it on active inodes, and none of their locks protects from concurrent mm_take_all_locks(): set_blocksize() mm_take_all_locks() =============== =================== load mapping->flags test_and_set_bit(AS_MM_ALL_LOCKS) down_write(i_mmap_rwsem) store mapping->flags mm_drop_all_locks() bit is clear, no up_write() Consequently, we can lose concurrent setting/clearing of AS_MM_ALL_LOCKS, resulting in i_mmap_rwsem staying write-locked forever or being released by another task. Let's fix it by updating the order bits atomically, and document what callers on an active inode still have to ensure. This has medium urgency, as an unsuspecting admin can trigger it, leaving i_mmap_rwsem locked forever. [david@kernel.org: adjust comment and description] Link: https://patch.msgid.link/20261129-filemap_fixes-v1-2-1546675e3c97@kernel.org Fixes: 3c20917120ce ("block/bdev: enable large folio support for large logical block sizes") Fixes: 58fd191f99f3 ("ext4: make data=journal support large block size") Signed-off-by: Chris Mason Signed-off-by: David Hildenbrand (Arm) Signed-off-by: Andrew Morton Reviewed-by: Jan Kara Cc: Matthew Wilcox (Oracle) Cc: Ying Huang Cc: Kefeng Wang Cc: ZhangPeng Cc: Hannes Reinecke Cc: Christian Brauner Cc: Luis Chamberlain Cc: John Garry Cc: Zhang Yi Cc: Baokun Li Cc: Ojaswin Mujoo Cc: Theodore Ts'o Cc: include/linux/pagemap.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) --- a/include/linux/pagemap.h~mm-filemap-update-the-folio-order-range-atomically +++ a/include/linux/pagemap.h @@ -411,8 +411,8 @@ static inline size_t mapping_max_folio_s * something the core cannot know). * Do not tune it based on, eg, i_size. * - * Context: This should not be called while the inode is active as it - * is non-atomic. + * Context: Safe to be called while the inode is active. However, the page + * cache must be empty and must be kept empty while setting the order range. */ static inline void mapping_set_folio_order_range(struct address_space *mapping, unsigned int min, @@ -430,8 +430,8 @@ static inline void mapping_set_folio_ord if (max < min) max = min; - mapping->flags = (mapping->flags & ~AS_FOLIO_ORDER_MASK) | - (min << AS_FOLIO_ORDER_MIN) | (max << AS_FOLIO_ORDER_MAX); + set_mask_bits(&mapping->flags, AS_FOLIO_ORDER_MASK, + (min << AS_FOLIO_ORDER_MIN) | (max << AS_FOLIO_ORDER_MAX)); } static inline void mapping_set_folio_min_order(struct address_space *mapping, @@ -448,8 +448,7 @@ static inline void mapping_set_folio_min * indicate that the VFS can use large folios to cache the contents of * the file. * - * Context: This should not be called while the inode is active as it - * is non-atomic. + * Context: See mapping_set_folio_order_range(). */ static inline void mapping_set_large_folios(struct address_space *mapping) { _ Patches currently in -mm which might be from mason@kernel.org are mm-swap-fix-large-swap-in-across-swap-file-extents.patch hugetlbfs-do-not-grow-a-sealed-file-in-mmap.patch mm-hugetlb-keep-surplus-folios-that-are-reserved.patch mm-hugetlb-fix-reservation-leak-on-min_size=-mounts.patch mm-cachestat-count-each-page-only-once.patch mm-cachestat-restart-the-walk-after-each-entry.patch percpu-queue-the-balance-work-on-an-unbound-workqueue.patch mm-vma-fix-uncharge-after-failed-stack-relocation.patch mm-mremap-apply-the-mmap-offset-limits-on-expansion.patch mm-mremap-respect-guard-gaps-on-in-place-expansion.patch mm-vma-make-brk-mappings-non-executable-under-mdwe.patch mm-hmm-refuse-secretmem-vmas-in-hmm_range_fault.patch mm-mglru-count-all-generations-as-evictable.patch mm-mglru-test-pg_lru-before-taking-a-folio-reference.patch mm-mglru-report-root-reclaim-to-memorypressure_level.patch kfence-use-a-nofault-store-to-zero-the-guard-page.patch mm-hugetlb-fix-truncated-copy-result-in-uffdio_copy.patch hugetlbfs-fix-deadlock-between-hole-punching-and-memory-failure.patch hugetlbfs-recheck-the-vma-range-after-the-lock-wait.patch mm-hugetlb-dont-zap-non-present-entries-when-unmapping-a-folio.patch mm-hugetlb-unshare-pmds-of-a-split-vma-if-allocating-its-lock-fails.patch mm-hugetlb_cgroup-track-in-use-folios-per-cgroup.patch hugetlbfs-seal-shm_hugetlb-files-against-growth.patch mm-hugetlb-resolve-protnone-faults-without-a-uffd-bit.patch mm-filemap-update-the-folio-order-range-atomically.patch