From patchwork Wed Jan 7 23:44:11 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1333 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829621; bh=3pBXa6voSWAheImeUBV1Yei22INLv2P9s8F18qEY51g=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Glsz8el+NNxelRjYRZrCWy4RdrVmdY8ySUiuX5jFvaXNnDoHy+S8lqiA+7CxliLty RRB/5HC+JIzUS+hrURzyAAKVOWkYIvSo2WHynNNHJMwvTex+e4e48Z3yMYNmEPoPd9 T9gv+qCM+Us1Kil9H9LJ5o2914Ew+jTpFZeWDaNMZ8DdCYVYoPxf9StAJovGOi+bx3 PQh6RvqHYHs/Ic2PCA1Rv+MkyqRkkLsT+UDHP44jqM6EtGR5Gepjhzms6j1HbE8VK1 UXv64n/ehJG9pDF3mOHZL2Q2/4kT6ZD1l94xdn+4d6NtEyIw1pKmmKz6S/uG9mAC4Z PP0feVw7pWL6g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E8E8A691A2 for ; Wed, 7 Jan 2026 16:47:01 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id ceYpHZmLGjeD for ; Wed, 7 Jan 2026 16:47:01 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829621; bh=3pBXa6voSWAheImeUBV1Yei22INLv2P9s8F18qEY51g=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Glsz8el+NNxelRjYRZrCWy4RdrVmdY8ySUiuX5jFvaXNnDoHy+S8lqiA+7CxliLty RRB/5HC+JIzUS+hrURzyAAKVOWkYIvSo2WHynNNHJMwvTex+e4e48Z3yMYNmEPoPd9 T9gv+qCM+Us1Kil9H9LJ5o2914Ew+jTpFZeWDaNMZ8DdCYVYoPxf9StAJovGOi+bx3 PQh6RvqHYHs/Ic2PCA1Rv+MkyqRkkLsT+UDHP44jqM6EtGR5Gepjhzms6j1HbE8VK1 UXv64n/ehJG9pDF3mOHZL2Q2/4kT6ZD1l94xdn+4d6NtEyIw1pKmmKz6S/uG9mAC4Z PP0feVw7pWL6g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D71BF69196 for ; Wed, 7 Jan 2026 16:47:01 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829620; bh=B1iHt5hUCxVlq4TnxdonkdB4a4J3ufUmtKi/l6CTz0A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VRB+febepC+57ihg6ps/OfTQHQUGJbn3Hk7NL8pnHGlrQYhM4OQf6PXmqIyb+hA8M 5LivcrHzVQeWSHHniXdIj4olcokov2Tcr90TTBO2GsjW0EmQCtULmFvDMC41Fr+Qm3 eDVVwgAEtc7zuPiaHPTH7z4uo0Fpk+Imlf+4MR06Ho9/Ad4noYJqlw2GA7au1yRlkH umSLl9ExmRYLZO3ShtwnxoCvmwh+lnJ+gsEQbjoxo0/zef8nBzE/PvrE95TPQo/Ppu 6WcFT/E5F//YFjw0izN152tMZpXMqC/kEPBAXIsRPnmBBXLpPLAYa/O6LG4+b/VoCz Pc6dvcSF9kIOg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 802EC69187; Wed, 7 Jan 2026 16:47:00 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 2tpeZJXVufBE; Wed, 7 Jan 2026 16:47:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829616; bh=7nU4VLYFLElf6VbRSgz4UlhrM4X0YODE2ZAu6q57O54=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PujuBxYHUQF2e+iVaiaW45n3o+Q7hzHc/YWlUFafrX5RlAzT9hKpx/7p9/CzeVHf0 HW+mgBByzBW8E02uQOQI3NOaGdliN1GvE4rcaLql//SVps6jsqpnB8RV/dJAi57unG nSeDfnMvSXzDPvCihpzwjIz8wWuH+v6fN/TvyBTO7sxLwewvnlYhjtyqP50GAhBWoR CtSf2iQs8rfL3yUHjJb7qMIDDafjZtb5vGDeqAYmqSqdFkwOzkarWZKQdBBiwTCX5k 6SDRsyO31J7Wtwpf+6Yav+PNvsuyd+iJl1wAkMuFLyI7QZoYuBFGfUCd00kMrocA3P v2GgMTco9QMqg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 260F569146; Wed, 7 Jan 2026 16:46:56 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 7 Jan 2026 16:44:11 -0700 Message-ID: <20260107234426.3508161-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260107234426.3508161-1-sjg@u-boot.org> References: <20260107234426.3508161-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: GXMUB2CBBHF62XF7GP7HZAZARTB3EM7E X-Message-ID-Hash: GXMUB2CBBHF62XF7GP7HZAZARTB3EM7E X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 1/9] fs: ext4l: Add inode state accessor functions List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add inode_state_read_once(), inode_state_clear() and related accessor functions to ext4_uboot.h to match the Linux kernel API. These are simplified versions for U-Boot's single-threaded environment - Linux uses READ_ONCE/WRITE_ONCE with lockdep assertions, while U-Boot uses direct access. Update inode.c and orphan.c to use these new accessors instead of direct i_state field access, aligning them with the Linux kernel source. Co-developed-by: Claude Opus 4.5 --- fs/ext4l/ext4_uboot.h | 46 +++++++++++++++++++++++++++++++++++++++++++ fs/ext4l/inode.c | 10 +++++----- fs/ext4l/orphan.c | 4 ++-- 3 files changed, 53 insertions(+), 7 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index b3da5bfa002..943cb31d694 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -934,6 +934,52 @@ static inline void simple_inode_init_ts(struct inode *inode) inode->i_ctime = ts; } +/* + * Inode state accessors - simplified for single-threaded U-Boot. + * Linux uses READ_ONCE/WRITE_ONCE and lockdep assertions; we use direct access. + */ +static inline unsigned long inode_state_read_once(struct inode *inode) +{ + return inode->i_state; +} + +static inline unsigned long inode_state_read(struct inode *inode) +{ + return inode->i_state; +} + +static inline void inode_state_set_raw(struct inode *inode, unsigned long flags) +{ + inode->i_state |= flags; +} + +static inline void inode_state_set(struct inode *inode, unsigned long flags) +{ + inode->i_state |= flags; +} + +static inline void inode_state_clear_raw(struct inode *inode, + unsigned long flags) +{ + inode->i_state &= ~flags; +} + +static inline void inode_state_clear(struct inode *inode, unsigned long flags) +{ + inode->i_state &= ~flags; +} + +static inline void inode_state_assign_raw(struct inode *inode, + unsigned long flags) +{ + inode->i_state = flags; +} + +static inline void inode_state_assign(struct inode *inode, unsigned long flags) +{ + inode->i_state = flags; +} + #define QSTR_INIT(n, l) { .name = (const unsigned char *)(n), .len = (l) } /* dotdot_name for ".." lookups */ diff --git a/fs/ext4l/inode.c b/fs/ext4l/inode.c index dc151c068bb..415c9f7f62f 100644 --- a/fs/ext4l/inode.c +++ b/fs/ext4l/inode.c @@ -403,7 +403,7 @@ void ext4_check_map_extents_env(struct inode *inode) if (!S_ISREG(inode->i_mode) || IS_NOQUOTA(inode) || IS_VERITY(inode) || is_special_ino(inode->i_sb, inode->i_ino) || - (inode->i_state & (I_FREEING | I_WILL_FREE | I_NEW)) || + (inode_state_read_once(inode) & (I_FREEING | I_WILL_FREE | I_NEW)) || ext4_test_inode_flag(inode, EXT4_INODE_EA_INODE) || ext4_verity_in_progress(inode)) return; @@ -3451,7 +3451,7 @@ static bool ext4_inode_datasync_dirty(struct inode *inode) /* Any metadata buffers to write? */ if (!list_empty(&inode->i_mapping->i_private_list)) return true; - return inode->i_state & I_DIRTY_DATASYNC; + return inode_state_read_once(inode) & I_DIRTY_DATASYNC; } static void ext4_set_iomap(struct inode *inode, struct iomap *iomap, @@ -4530,7 +4530,7 @@ int ext4_truncate(struct inode *inode) * or it's a completely new inode. In those cases we might not * have i_rwsem locked because it's not necessary. */ - if (!(inode->i_state & (I_NEW|I_FREEING))) + if (!(inode_state_read_once(inode) & (I_NEW | I_FREEING))) WARN_ON(!inode_is_locked(inode)); trace_ext4_truncate_enter(inode); @@ -5188,7 +5188,7 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino, inode = iget_locked(sb, ino); if (!inode) return ERR_PTR(-ENOMEM); - if (!(inode->i_state & I_NEW)) { + if (!(inode_state_read_once(inode) & I_NEW)) { ret = check_igot_inode(inode, flags, function, line); if (ret) { iput(inode); @@ -5527,7 +5527,7 @@ static void __ext4_update_other_inode_time(struct super_block *sb, if (inode_is_dirtytime_only(inode)) { struct ext4_inode_info *ei = EXT4_I(inode); - inode->i_state &= ~I_DIRTY_TIME; + inode_state_clear(inode, I_DIRTY_TIME); spin_unlock(&inode->i_lock); spin_lock(&ei->i_raw_lock); diff --git a/fs/ext4l/orphan.c b/fs/ext4l/orphan.c index b142c1bd21f..65d0d177c5d 100644 --- a/fs/ext4l/orphan.c +++ b/fs/ext4l/orphan.c @@ -115,7 +115,7 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode) if (!sbi->s_journal || is_bad_inode(inode)) return 0; - WARN_ON_ONCE(!(inode->i_state & (I_NEW | I_FREEING)) && + WARN_ON_ONCE(!(inode_state_read_once(inode) & (I_NEW | I_FREEING)) && !inode_is_locked(inode)); if (ext4_inode_orphan_tracked(inode)) return 0; @@ -240,7 +240,7 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode) if (!sbi->s_journal && !(sbi->s_mount_state & EXT4_ORPHAN_FS)) return 0; - WARN_ON_ONCE(!(inode->i_state & (I_NEW | I_FREEING)) && + WARN_ON_ONCE(!(inode_state_read_once(inode) & (I_NEW | I_FREEING)) && !inode_is_locked(inode)); if (ext4_test_inode_state(inode, EXT4_STATE_ORPHAN_FILE)) return ext4_orphan_file_del(handle, inode);