From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.100 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793963712; b=JMH4V3GEHB4j0Cd75Y+CfpvuhFF1pTsayliacjryC2oOUJsLPQnZSV1vLts8dHbje1ck se+IGBxPdLCKy2SX2y5HtEfN77MRDLjxIKEO9yAsgk3Dux+AtcvR4cV1psJ4ahKWM2kbR 96xDLzkUgdWUJJ+IJcOoZ8SesdGvRpvGzXxugHsf+ut22x0IZmPaRwOH4IMv27GVyg2V+ 5SKQl6seUjwFeJ/TOUPSsunCl41YWrY1/5N5Vojl5/KVHKqSj4oNkThoxsvm7HAGDVgL6 CR2/CRreviBrMmyATpGoSAWHB6aDBH5M2FEu8ddx4FCvQrZx57rpbRlePo66fsd1afg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793963712; h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:From:To:Cc: Subject:Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=DzTSlh9T8WL7TXENBVvmpXROLhx1mNSREYu24yi9dUY=; b=I5pHntTLSnXaj8ovTa83+ZJeleqBRJFmZM/nzY1sjs8VP64bBApe3I9UFaTgHvMu4PMZ UFKP1mzE8QEf3u6gPJsGCN1Dikrx67+vRb+SuA/2PHkilOJwYCJlctGatZQIrpIDXDHcR Y6G70Lb1Y12YTrYODDFeFm6eB4A0X92NATJlDUA/71ZsS10zjNWSGP8PCYbF/oWmnnJtd LLshEzxguJMH60iKNlc7b7LAtATbLu/FE3j/h3hMk2Lp6TErBkUCz8EX399HmgTT8Mf7S WclSe/ZH0D80CXn6RAGG8Vxmw8qPCWjmXnL+4mX8ocoq8RIjIGDWNP0s6KEAZ8SYzMQ== 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=avazConF; arc=none smtp.remote-ip=115.124.30.100 Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) (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 90B8A606D827 for ; Fri, 6 Nov 2026 11:15:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 90B8A606D827 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=avazConF DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1793963708; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=DzTSlh9T8WL7TXENBVvmpXROLhx1mNSREYu24yi9dUY=; b=avazConFo68U6amjBQwowgKtI7C1/ZwCDK82zyuBQicSvWps1eYsddiceJR4Oxi/IbRgEPQGKA4nxCFlosOdfm2D8/2390+qYoJbbrY8d+XCOJxGv625LyI1JNIL+Tfd9UuQp1XAp3q2yuixVThxbT2Or2EFDfFFM1rHExiDhYk= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R961e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037033178;MF=joseph.qi@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0XEBd-49_1793963707; Received: from localhost(mailfrom:joseph.qi@linux.alibaba.com fp:SMTPD_---0XEBd-49_1793963707 cluster:ay36) by smtp.aliyun-inc.com; Fri, 06 Nov 2026 19:15:08 +0800 From: Joseph Qi To: Andrew Morton , Heming Zhao Cc: Mark Fasheh , Joel Becker , ocfs2-devel@lists.linux.dev, linux-kernel@vger.kernel.org, Joseph Qi Subject: [PATCH v2 10/31] ocfs2: abstract the inline data dinode guard and cluster check Date: Fri, 6 Nov 2026 19:14:37 +0800 Message-Id: <20261106111458.1467464-11-joseph.qi@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20261106111458.1467464-1-joseph.qi@linux.alibaba.com> References: <20261106111458.1467464-1-joseph.qi@linux.alibaba.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Introduce ocfs2_dinode_has_inline_data() for the OCFS2_INLINE_DATA_FL test that selects the id2.i_data union arm, and ocfs2_dinode_has_inline_clusters() for the rule that an inline-data inode must not also have allocated clusters. The guard stays above the sub-checks: reading id_count or i_clusters against the wrong id2 arm would produce false positives on valid inodes. No functional change intended. Signed-off-by: Joseph Qi --- fs/ocfs2/inode.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c index 17d546a9245d..2aac1918562a 100644 --- a/fs/ocfs2/inode.c +++ b/fs/ocfs2/inode.c @@ -164,6 +164,16 @@ static bool ocfs2_dinode_has_size_without_clusters(struct super_block *sb, return !ocfs2_sparse_alloc(OCFS2_SB(sb)) && S_ISREG(mode); } +static bool ocfs2_dinode_has_inline_data(struct ocfs2_dinode *di) +{ + return le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_DATA_FL; +} + +static bool ocfs2_dinode_has_inline_clusters(struct ocfs2_dinode *di) +{ + return le32_to_cpu(di->i_clusters) != 0; +} + void ocfs2_set_inode_flags(struct inode *inode) { unsigned int flags = OCFS2_I(inode)->ip_attr; @@ -1726,10 +1736,10 @@ int ocfs2_validate_inode_block(struct super_block *sb, if (rc) goto bail; - if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_DATA_FL) { + if (ocfs2_dinode_has_inline_data(di)) { struct ocfs2_inline_data *data = &di->id2.i_data; - if (le32_to_cpu(di->i_clusters)) { + if (ocfs2_dinode_has_inline_clusters(di)) { rc = ocfs2_error(sb, "Invalid dinode %llu: %u clusters\n", (unsigned long long)bh->b_blocknr, -- 2.39.3