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=1796491204; b=nuX8tb476bV2/wB6g2BP0uZw9/asksBmXVyk5lizJB091CXlhyQXe3wmKjplngTgv8Cn +EZ5mKQ5A1j+IVKT6G1LN/mRkyDv8Ent22ix+Mu+P5oEkbfwWu7o9SlqqqN79vkwB8dAD M5JB+Nlm+lZBCUqmeupjj4u1VVMUSfxQPOgjveWtg9xSBZkNglPNucjROU430iuRn1LUm YwOkr0SwdX2eb5MB7Q5IIXrNifqcdgCgPw2CKdBJhiON8BJhOMYhuNskUBeMmLg9Sog3A RKXVoIzd283pj5pV/zjqKAuI3aw+c0M4Y4o3tEzZSXl1oIDrDi0SJEReYSFh0/n8Jbg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796491204; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=LA2arcoDjY6LfhF8IB0NajoDCvheEimq3e8wMUge6XI=; b=dcVidGM0WjdzXEG7euzRP+96V0buAB2sPK/IHr51UG4LV+2/kKb0608TGMBO0XaC6tgL lx2Bc0425LvzG7e/mW6nzKZGaax9JcItvOV94YXlkFajZmTBj2i07EA1o47lBA2ABc7Ko 2RBy9orMOIpSfBHVbtVOWUdytPsY+NTj1aQWM/9+ek6/96kDYjbkS6hHutuEfPZvDXJhY MIS5kCEir5P3fJCS3/JWDGvzoIWWlIQYpLyRRW66r6Soa2O9hkGzBxJTX1pwOO0FcpZTk cNGUEJ+AcOJb9K1FyjM1LPm75qhrYI4Op7i5BHDBNtJvR6jsudVxSraK0a2+aTHxH1Q== 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=Tayu1AOW; 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 DBFF1606A31F for ; Sat, 5 Dec 2026 17:20:04 +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=Tayu1AOW Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78A111F00936; Sat, 5 Dec 2026 17:20:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796491204; bh=LA2arcoDjY6LfhF8IB0NajoDCvheEimq3e8wMUge6XI=; h=Date:To:From:In-Reply-To:References:Subject; b=Tayu1AOWCe0YA6p9yUb4qh0Hz/AK+mdkdPznalX4nOim1Po484Crb07cmaZ4ChnGC 1QAW2y7ZXJ0b2E/AK8fGsXlJpDMTXlCe7R6B4ohgAP5pi8yjfMRfO6x+e5N3H82xqt WRZ7rE+tyQipFmOSI1qHBKL30qFzFYx0OCnE7djo= Date: Sat, 05 Dec 2026 09:20:04 -0800 To: mm-commits@vger.kernel.org,mark@fasheh.com,joseph.qi@linux.alibaba.com, jlbec@evilplan.org,hch@lst.de,heming.zhao@suse.com,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20261205143959.704982-5-joseph.qi@linux.alibaba.com> References: <20261205143959.704982-5-joseph.qi@linux.alibaba.com> Subject: + ocfs2-refactor-ocfs2_lock_allocators-and-add-a-dio-variant.patch added to mm-nonmm-unstable branch Message-Id: <20261205172004.78A111F00936@smtp.kernel.org> X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list The patch titled Subject: ocfs2: refactor ocfs2_lock_allocators() and add a dio variant has been added to the -mm mm-nonmm-unstable branch. Its filename is ocfs2-refactor-ocfs2_lock_allocators-and-add-a-dio-variant.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/ocfs2-refactor-ocfs2_lock_allocators-and-add-a-dio-variant.patch This patch will later appear in the mm-nonmm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm 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: Heming Zhao Subject: ocfs2: refactor ocfs2_lock_allocators() and add a dio variant Date: Sat, 05 Dec 2026 22:39:53 +0800 ocfs2_lock_allocators() derives the worst case number of extent records from clusters_to_add + 2 * extents_to_split, which assumes the caller inserts one record per cluster. A direct write does not: it allocates its whole contiguous range with a single ocfs2_add_inode_data() call, and ocfs2_add_clusters_in_btree() makes exactly one ocfs2_insert_extent() call, so at most one record is added. It does not split an extent either, because unwritten extents are converted when the io is done. Factor the reservation into __ocfs2_lock_allocators() taking max_recs_needed directly. ocfs2_lock_allocators() keeps its current computation, and ocfs2_lock_allocators_dio() passes one record when there is anything to allocate. Reserving metadata is still driven by ocfs2_num_free_extents(), which counts the free records in the rightmost leaf - the same block ocfs2_figure_insert_type() tests - so a tree that needs to grow still gets a metadata reservation. No functional change for existing callers. Link: https://patch.msgid.link/20261205143959.704982-5-joseph.qi@linux.alibaba.com Signed-off-by: Heming Zhao Signed-off-by: Joseph Qi Signed-off-by: Andrew Morton Co-developed-by: Joseph Qi Cc: Christoph Hellwig Cc: Mark Fasheh Cc: Joel Becker fs/ocfs2/suballoc.c | 50 ++++++++++++++++++++++++++++++++++++------ fs/ocfs2/suballoc.h | 5 ++++ 2 files changed, 49 insertions(+), 6 deletions(-) --- a/fs/ocfs2/suballoc.c~ocfs2-refactor-ocfs2_lock_allocators-and-add-a-dio-variant +++ a/fs/ocfs2/suballoc.c @@ -3242,15 +3242,20 @@ int ocfs2_release_clusters(handle_t *han * * File systems which don't support holes call this from * ocfs2_extend_allocation(). + * + * @clusters_to_add is the number of data clusters to reserve. + * @max_recs_needed is the worst case number of extent records this + * allocation can add. It is not always @clusters_to_add: a direct write + * inserts its whole contiguous range with one ocfs2_add_inode_data() call. */ -int ocfs2_lock_allocators(struct inode *inode, - struct ocfs2_extent_tree *et, - u32 clusters_to_add, u32 extents_to_split, - struct ocfs2_alloc_context **data_ac, - struct ocfs2_alloc_context **meta_ac) +static int __ocfs2_lock_allocators(struct inode *inode, + struct ocfs2_extent_tree *et, + u32 clusters_to_add, + u32 max_recs_needed, + struct ocfs2_alloc_context **data_ac, + struct ocfs2_alloc_context **meta_ac) { int ret = 0, num_free_extents; - unsigned int max_recs_needed = clusters_to_add + 2 * extents_to_split; struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); *meta_ac = NULL; @@ -3315,6 +3320,39 @@ out: } /* + * Reserve for an allocation which may add one extent record per cluster. A + * buffered write inserts each cluster separately, and splitting an unwritten + * extent can add two more records. + */ +int ocfs2_lock_allocators(struct inode *inode, + struct ocfs2_extent_tree *et, + u32 clusters_to_add, u32 extents_to_split, + struct ocfs2_alloc_context **data_ac, + struct ocfs2_alloc_context **meta_ac) +{ + return __ocfs2_lock_allocators(inode, et, clusters_to_add, + clusters_to_add + 2 * extents_to_split, + data_ac, meta_ac); +} + +/* + * A direct write allocates its whole contiguous range with a single + * ocfs2_add_inode_data() call, which inserts at most one extent record, and + * it does not split an extent here (unwritten extents are converted when the + * io is done). + */ +int ocfs2_lock_allocators_dio(struct inode *inode, + struct ocfs2_extent_tree *et, + u32 clusters_to_add, + struct ocfs2_alloc_context **data_ac, + struct ocfs2_alloc_context **meta_ac) +{ + return __ocfs2_lock_allocators(inode, et, clusters_to_add, + clusters_to_add ? 1 : 0, + data_ac, meta_ac); +} + +/* * Read the inode specified by blkno to get suballoc_slot and * suballoc_bit. */ --- a/fs/ocfs2/suballoc.h~ocfs2-refactor-ocfs2_lock_allocators-and-add-a-dio-variant +++ a/fs/ocfs2/suballoc.h @@ -203,6 +203,11 @@ int ocfs2_lock_allocators(struct inode * u32 clusters_to_add, u32 extents_to_split, struct ocfs2_alloc_context **data_ac, struct ocfs2_alloc_context **meta_ac); +int ocfs2_lock_allocators_dio(struct inode *inode, + struct ocfs2_extent_tree *et, + u32 clusters_to_add, + struct ocfs2_alloc_context **data_ac, + struct ocfs2_alloc_context **meta_ac); int ocfs2_test_inode_bit(struct ocfs2_super *osb, u64 blkno, int *res); _ Patches currently in -mm which might be from heming.zhao@suse.com are ocfs2-add-new-ocfs2_map_blocks-to-introduce-iomap-feature.patch ocfs2-switch-dio-read-path-from-buffer_head-to-iomap.patch ocfs2-add-ocfs2_get_clusters_uncached.patch ocfs2-refactor-ocfs2_lock_allocators-and-add-a-dio-variant.patch ocfs2-record-the-fsync-transaction-when-cow-makes-clusters-writable.patch ocfs2-rework-the-direct-write-context-for-multi-cluster-mappings.patch ocfs2-switch-dio-write-path-from-buffer_head-to-iomap.patch