From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.113 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796276411; b=emkjNb/rov60hytuWmGs3zi7TzaYaGqjlLOslZp9KZshgf4k/C2OotK/wYnNNbt8VlcF EqAn8nM2nkAqpz1ZI+ODYtpZsDP4LNMaF360ER6NoCacxElIRZYSwuuiR6EyZFW/ifL9Z oepby548JaMzeszraISH6VMdXXrAlQZ378Fmdt0fIqSu0z8USbFbMCxACu0ZFN3RewjAT uyqCGglmCrMFjA5eWs4Tywg1dp0wcMO3en9V4yxWSf7Qg/JQaHRKjLOJsKBnQ4TpRVI95 q9rIv67FYsrdNBHtopUMrFAKJtU2xg5lvNPXc+YSFaS0GQ4A7TJlTDJb5o9h3pHWBWA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796276411; h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:Cc:References:From: In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=5pGtNz9xM264T4dwvVO5N2MMxGwFROzjyUl0kXF/trM=; b=txflUhexB4ew8CXxh227afALzbtTy8mNsgDIbI362l9+V34JBpNOtTv9959vmyNVTJ4O hJXLlAyt819ea/1Em8QQ6rAlMSsq/yLdjHoPEuIwZbso0Qb8Pz0E3NHKeY4HJvDTnHfNK P2FNul/AQcQJ2Q6dJbnLirLopaJbrrxlrNnKJMkeqNHX1zAPkLD2ZQ8+jWiID3P9oUFzt gqGSj+ixYrOjk6QAk3lFAY0aws54/Ga67h6eS3iOIsZj/H/VPFcWm6RG2lL3o1PxNOCxp 0/nGfXTHIXx9HE+uXvn4XOSUbHT10Aa2aG/OmcOIAwSlRUNW4ltrIIG6wwAHPQXfEYA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=sOeukrVv; arc=none smtp.remote-ip=115.124.30.113 Received: from out30-113.freemail.mail.aliyun.com (out30-113.freemail.mail.aliyun.com [115.124.30.113]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0AEA2606A322; Thu, 3 Dec 2026 05:40:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0AEA2606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=sOeukrVv DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796276406; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=5pGtNz9xM264T4dwvVO5N2MMxGwFROzjyUl0kXF/trM=; b=sOeukrVvZDzjXjEU/UhSRIW+xXQjLsA5RnUws+er+z8aFfzY5pk9ZF7ImckUnYSVidzGso/oKCu8SNikKy22/+PlAYCPlE2d61seZX0s5+gHJD4ve6KHFqLkQZ6K9IrV02d3jHuEgfTcyWKj4XiEsvovw6jtq9J8geN+Sae/soo= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033065142238;MF=joseph.qi@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0XGD.iKx_1796276402; Received: from 30.221.129.217(mailfrom:joseph.qi@linux.alibaba.com fp:SMTPD_---0XGD.iKx_1796276402 cluster:ay36) by smtp.aliyun-inc.com; Thu, 03 Dec 2026 13:40:03 +0800 Message-ID: Date: Thu, 3 Dec 2026 13:40:02 +0800 X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH v15 06/10] ocfs2: rework the direct write context for multi-cluster mappings To: sashiko-reviews@lists.linux.dev, Heming Zhao , Christoph Hellwig Cc: Mark Fasheh , Joel Becker , Andrew Morton , "ocfs2-devel@lists.linux.dev" , "ocfs2-devel@lists.linux.dev" References: <20261202143507.1754776-1-joseph.qi@linux.alibaba.com> <20261202143507.1754776-7-joseph.qi@linux.alibaba.com> From: Joseph Qi In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 12/2/26 11:01 PM, sashiko-bot@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 1 potential > issue to consider: > - [Medium] ocfs2: mapped non-uptodate buffers left on folio if > ocfs2_dio_add_unwritten() fails > -- > > commit 011a09c7a7cba976cdcd3c888f0ffb4ea345272b > Author: Heming Zhao > > ocfs2: rework the direct write context for multi-cluster mappings > > This commit reworks the direct write context and unwritten extent tracking > to support multi-cluster mappings. > >> diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c >> index 21cdc5c29331d..4b76be5909689 100644 >> --- a/fs/ocfs2/aops.c >> +++ b/fs/ocfs2/aops.c > [ ... ] >> @@ -1881,11 +2438,34 @@ int ocfs2_write_begin_nolock(struct address_space *mapping, >> >> ret = ocfs2_write_cluster_by_desc(mapping, data_ac, meta_ac, wc, pos, >> len); >> + if (wc->w_clusters_unused) { >> + /* A direct write got a shorter chunk than reserved. */ >> + dquot_free_space(inode, >> + ocfs2_clusters_to_bytes(osb->sb, wc->w_clusters_unused)); >> + clusters_to_alloc -= wc->w_clusters_unused; >> + wc->w_clusters_unused = 0; >> + } >> + /* >> + * w_clen is final now, so this is the range whose head and tail >> + * folios may have been zeroed, whether or not the write succeeded. >> + * The caller needs it to clean up behind the locks. >> + */ >> + if (touched_end) >> + *touched_end = ocfs2_clusters_to_bytes(inode->i_sb, >> + wc->w_cpos + wc->w_clen); >> if (ret) { >> mlog_errno(ret); >> goto out_quota; >> } >> >> + if (type == OCFS2_WRITE_DIRECT) { >> + ret = ocfs2_dio_add_unwritten(inode, wc); >> + if (ret) { >> + mlog_errno(ret); >> + goto out_quota; >> + } >> + } > > [Severity: Medium] > If ocfs2_dio_add_unwritten() fails with -ENOMEM here, does the error path > leave BH_Mapped and !BH_Uptodate buffer_heads on the head and tail folios > in wc->w_folios[]? > > When cluster size exceeds page size, ocfs2_write_cluster_by_desc() -> > ocfs2_write_clusters_direct() -> ocfs2_prepare_cluster_folios() -> > ocfs2_prepare_folio_for_write() -> ocfs2_map_folio_blocks() attaches > buffer_heads to non-uptodate head or tail folios and maps them to the > physical blocks of the OCFS2_EXT_UNWRITTEN extent, leaving BH_Uptodate > clear until block_commit_write() in ocfs2_write_end_nolock(). Jumping to > out_quota commits the transaction and calls ocfs2_free_write_ctxt(), which > unlocks those folios without committing or invalidating their buffers > (and ocfs2_dio_wr_get_block() passes touched_end = NULL, performing no > folio cleanup). A subsequent buffered read within i_size via > block_read_full_folio() will see buffer_mapped(bh) && !buffer_uptodate(bh), > skip ocfs2_get_block(), and read the uninitialized disk blocks of the > unwritten extent into the page cache. > > Even once commit "ocfs2: switch dio write path from buffer_head to iomap" > adds ocfs2_dio_cleanup_clusters(), that cleanup runs after > ocfs2_free_write_ctxt() has unlocked the folios and after ip_alloc_sem and > the inode lock have been dropped, leaving a window for a concurrent > buffered read to issue a read bio on the mapped buffer before > truncate_inode_pages_range() runs. > It looks real, will fix it in next version. Thanks, Joseph