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); From patchwork Wed Jan 7 23:44:12 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1334 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=1767829629; bh=LTWPYu3i3seAOK9NjKVqarsyfvAC7Mzkl77A3gmn+RU=; 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=JeIfHACPID12pyU+8Y+0O/txPlcpvVIMJ0MWYnCnURacwBYNG04M2eLHSRxDtj2p7 RIZemt0YBQ3pFd9F+/g6mfqeHxI43IMsdRQA2Y5Q7WL1+pIczDmzFsLyyw8midmW4o NRV4lAQjQ2EY/QUuvLpQCP6pDKyqjKQZG+6oGeSdE3NMkcvDF9cgjoy2GPfEL7dTdx G1673j7n/ji3tqBphCDaZ3kf/qgiXibNtZb64UUU14qwtIKa7Ux2xitM3w8vjv6Nsl 6rW55syd8Yl2fwF3ze5YLWi/vcv0ksf+GSYDGSR1TNn3aWfN/LWvG0lj23WcqbA4hO RyXeLEgKQSpDQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6B91E691A2 for ; Wed, 7 Jan 2026 16:47:09 -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 ysetT8OwaYMr for ; Wed, 7 Jan 2026 16:47:09 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829629; bh=LTWPYu3i3seAOK9NjKVqarsyfvAC7Mzkl77A3gmn+RU=; 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=JeIfHACPID12pyU+8Y+0O/txPlcpvVIMJ0MWYnCnURacwBYNG04M2eLHSRxDtj2p7 RIZemt0YBQ3pFd9F+/g6mfqeHxI43IMsdRQA2Y5Q7WL1+pIczDmzFsLyyw8midmW4o NRV4lAQjQ2EY/QUuvLpQCP6pDKyqjKQZG+6oGeSdE3NMkcvDF9cgjoy2GPfEL7dTdx G1673j7n/ji3tqBphCDaZ3kf/qgiXibNtZb64UUU14qwtIKa7Ux2xitM3w8vjv6Nsl 6rW55syd8Yl2fwF3ze5YLWi/vcv0ksf+GSYDGSR1TNn3aWfN/LWvG0lj23WcqbA4hO RyXeLEgKQSpDQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 46E1469195 for ; Wed, 7 Jan 2026 16:47:09 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829626; bh=bWZfDHLbD8Ig1uO2GoAWo2HiWxuSF3yW75NqjJyq0Iw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aMbOKRge6u+TFMecIEIY5ZG17k9kxwuwSLE0AT57EcrfBtCUfKSLdpkbxIi3/LLzz IqHWyNxHG6m3TKRggJsPPuzx3y5wPFj7p+5yDsjIt6pm82tXMY0b+oNhq2RmT7KvPl gnVj3DOoxRn9ZtEv0IB+vQhDP/+lea3zGq4eXDUZUlCNIE4qI7UtaGQ9FFsov7um3E vJ5KNySM56qqTL1YWK5yp1DsG3D5lMeYGHFT8VeU8Bi2/olk4sAxtvXPu5EqpSmM4R B7fu08tBFZ38L43MyySUljaiXFAPjTS+vRaS4pO1wUNser+PMiIBk1KKYA4bDlXXRi 16ul5JBYUKyfg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0D33D69187; Wed, 7 Jan 2026 16:47:06 -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 78MLeIXAT7-g; Wed, 7 Jan 2026 16:47:05 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829621; bh=/5FLomm/fridi9QJPSM6BVscZRyc/JCxMl+sQ6Fp89o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tATteQdVyGX2l6d8Q78XGJ+OHV8VQWSL5VGHWnJfUZweGnNVudK8pGRB4KuqJ1HaX 8RB3ANvmeu/KBg+odr62G4Y8idSdc8J+HWVq1sCOKMwI/QWfZbMGzw4HowIN08VHoY Ev15yihHvebpfrOegs2ho3WwOdIYbDHkUiUnSzXKwiHJyHAAp3/9i9hNQzQN05tYoM 8pRrS+kYY3zBByJtt1ZRb2mcD1QLMRv2cdMT7NU5HUmZixHNhl+WdGaEtcWT7imekh QlQ5KfE0edP8G5nhJBwGdLpN7fqnvGQU0inzIAk9m8a7yrBndXr/t9dTlRfRoxukhu KUQwCIytwRUzA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 98B1669146; Wed, 7 Jan 2026 16:47:01 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 7 Jan 2026 16:44:12 -0700 Message-ID: <20260107234426.3508161-3-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: 5MFKDNM35VKMX4SHG3JZ4WYV2CUQNABH X-Message-ID-Hash: 5MFKDNM35VKMX4SHG3JZ4WYV2CUQNABH 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 2/9] fs: ext4l: Add block conversion macros and use them 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 EXT4_LBLK_TO_B(), EXT4_LBLK_TO_PG() and EXT4_PG_TO_LBLK() macros to ext4.h to match the Linux kernel API. These convert between logical block numbers, byte offsets and page indices. Update inode.c to use these macros instead of inline shift operations, aligning the code with the Linux kernel source. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/ext4.h | 8 ++++++++ fs/ext4l/inode.c | 15 +++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/fs/ext4l/ext4.h b/fs/ext4l/ext4.h index a1c80dd7cdf..47054daffc2 100644 --- a/fs/ext4l/ext4.h +++ b/fs/ext4l/ext4.h @@ -342,6 +342,14 @@ struct ext4_io_submit { blkbits)) #define EXT4_B_TO_LBLK(inode, offset) \ (round_up((offset), i_blocksize(inode)) >> (inode)->i_blkbits) +#define EXT4_LBLK_TO_B(inode, lblk) ((loff_t)(lblk) << (inode)->i_blkbits) + +/* Translate a block number to a page index */ +#define EXT4_LBLK_TO_PG(inode, lblk) (EXT4_LBLK_TO_B((inode), (lblk)) >> \ + PAGE_SHIFT) +/* Translate a page index to a block number */ +#define EXT4_PG_TO_LBLK(inode, pnum) (((loff_t)(pnum) << PAGE_SHIFT) >> \ + (inode)->i_blkbits) /* Translate a block number to a cluster number */ #define EXT4_B2C(sbi, blk) ((blk) >> (sbi)->s_cluster_bits) diff --git a/fs/ext4l/inode.c b/fs/ext4l/inode.c index 415c9f7f62f..7001c7299cd 100644 --- a/fs/ext4l/inode.c +++ b/fs/ext4l/inode.c @@ -803,9 +803,8 @@ found: !(flags & EXT4_GET_BLOCKS_ZERO) && !ext4_is_quota_file(inode) && ext4_should_order_data(inode)) { - loff_t start_byte = - (loff_t)map->m_lblk << inode->i_blkbits; - loff_t length = (loff_t)map->m_len << inode->i_blkbits; + loff_t start_byte = EXT4_LBLK_TO_B(inode, map->m_lblk); + loff_t length = EXT4_LBLK_TO_B(inode, map->m_len); if (flags & EXT4_GET_BLOCKS_IO_SUBMIT) ret = ext4_jbd2_inode_add_wait(handle, inode, @@ -2384,7 +2383,7 @@ static int mpage_submit_partial_folio(struct mpage_da_data *mpd) * The mapped position should be within the current processing folio * but must not be the folio start position. */ - pos = ((loff_t)mpd->map.m_lblk) << inode->i_blkbits; + pos = EXT4_LBLK_TO_B(inode, mpd->map.m_lblk); if (WARN_ON_ONCE((folio_pos(folio) == pos) || !folio_contains(folio, pos >> PAGE_SHIFT))) return -EINVAL; @@ -2441,7 +2440,7 @@ static int mpage_map_and_submit_extent(handle_t *handle, io_end_vec = ext4_alloc_io_end_vec(io_end); if (IS_ERR(io_end_vec)) return PTR_ERR(io_end_vec); - io_end_vec->offset = ((loff_t)map->m_lblk) << inode->i_blkbits; + io_end_vec->offset = EXT4_LBLK_TO_B(inode, map->m_lblk); do { err = mpage_map_one_extent(handle, mpd); if (err < 0) { @@ -3481,8 +3480,8 @@ static void ext4_set_iomap(struct inode *inode, struct iomap *iomap, iomap->dax_dev = EXT4_SB(inode->i_sb)->s_daxdev; else iomap->bdev = inode->i_sb->s_bdev; - iomap->offset = (u64) map->m_lblk << blkbits; - iomap->length = (u64) map->m_len << blkbits; + iomap->offset = EXT4_LBLK_TO_B(inode, map->m_lblk); + iomap->length = EXT4_LBLK_TO_B(inode, map->m_len); if ((map->m_flags & EXT4_MAP_MAPPED) && !ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) @@ -3715,7 +3714,7 @@ retry: * i_disksize out to i_size. This could be beyond where direct I/O is * happening and thus expose allocated blocks to direct I/O reads. */ - else if (((loff_t)map->m_lblk << blkbits) >= i_size_read(inode)) + else if (EXT4_LBLK_TO_B(inode, map->m_lblk) >= i_size_read(inode)) m_flags = EXT4_GET_BLOCKS_CREATE; else if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) m_flags = EXT4_GET_BLOCKS_IO_CREATE_EXT; From patchwork Wed Jan 7 23:44:13 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1335 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=1767829634; bh=AT2LkD5GPLRt0WUm6ZiH/+VeINjbVIEkqr0XwPgKqmY=; 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=pW7Jmi3BrU7qokgRtIg3ZhTDe4ApGrv48s2I/42ww6WuJgwE8HtwD9XdSgJK3s/b9 vHkYpfyIdRXguCB9GGMz89PwDVeE05yXNFVZOasEgKSIY6G8SIOCirzKmf9D2RPRBK qdOpJ4Re7O5gPt68iEHayGr5sVgQK1AsKuH40QgywRRpTBDv3A9SuNUYy8Sh1e4Kon N5z41eCsfhPftahuJnnWYTXZFu5J/ctd7sB+VNMGhvPEd9VVUNSaTVwerMvZesHDpb PLjvcsVsy6JA3Qb1jNx9KilNa6JobQ+8m12KkbP6BJONdA5DwTRYggMhyvxdZlXO5a KmYWdUjRwqwmQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 12D9B69195 for ; Wed, 7 Jan 2026 16:47:14 -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 ZR6QQcoKca7W for ; Wed, 7 Jan 2026 16:47:14 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829633; bh=AT2LkD5GPLRt0WUm6ZiH/+VeINjbVIEkqr0XwPgKqmY=; 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=Qim7J3BI2k4hXiG4g0O9mfi6SL9VYgipmx+QpEKPitDVIwQX9fLVRF+4hUN1/AwU9 EnSnQPXzO1NyTWqbi/bRGsLvUy7HUspQ3wvJVENWgAfcxlQPrmYeh21YcLviWjXrK2 wZny9sMPcA5+C4C3Ab6S4GE5/H5aN/tCyMMX2hP09fIAe8CxMnqpg74QpSdXquxo4n +SkJZwLxyksu6IB7dKqA4o8sYbTwU8iEcskDzeuPt60IVJm1qoaDkBPqlAqkNmIarz i8l16Mf/Tac2RGqp4yc/2x9ow9JecBjktK3Ps538EmENfHnQyLY33ep03gyQRub9TR fvUVlL9QniFPA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D808969146 for ; Wed, 7 Jan 2026 16:47:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829631; bh=W5n7Nq27vE4C43b2Y9YHHFhQohR5teKubwFBadbEExc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hZRVRUFmeemw/8m7ZCoGUpjJM5DPY0ICJD2CV2wrnQUW8QcTRmvbm3QKz+C+ZFHUM BmxDKwTYG7Ra2VW3vWQILBAJURWGhnXzlLiQ+qGdbnj2/QbG3B1le2X2WcWfk3R68c yXCDt+Y3P5N7Ah8Wd9urg6gx7NZkIqJ5U1mEJkPqWE7Na+xOTtoYfjgSAN1N/P9xnt 3H4Dc6LG3GkxdyDktXE5oMRFxKf4tLoD0UUWKGjca1FJ0oM0+yF079q2iR1Ji4fXJ6 ZylIOYz7lhoqWB0YhaVlupLqIRxb1XczZFt5EyGjLGiEOQfz+90pYf5MUBj4BtQr/S 4MkPgKfnaEE6w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6407C691A6; Wed, 7 Jan 2026 16:47:11 -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 cdQ50CqDMKCz; Wed, 7 Jan 2026 16:47:11 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829626; bh=+TqT2Bjx6dLizmt8uJbDQVNhb7tzzlCY38tOaQxGakg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uUnZCBAnEFqIIxnxxmdghGcSmwhOZtzzdtObbyqYGsGbmSOYcWaYXF8m/NfylwjYV +y2CG5JXrUTED9aLma43FekWc33RZ6FMCJoq/8CWFri5LiY+m00EekXXwG7vlDFB5p N5/iw5ePkGBW4K70b3Q3MYx2f8vK2lCwswkm9C+1HZvY+b+e26H8HfsMOIAQomZifx 8RzdbWzwDwqz9i9w5bQv+quQH16Mbgvyv0ljUmrxLdyUw28tmZjXqn9Px9Wx+A6pFf h9BITF+9FgTjxH5mTSFYjIJ4KVxqQGwXT/9z6P5KVKanVkzERu0KoNaHEXVURredB9 pn+SE5uFmYZ1w== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 538EA69146; Wed, 7 Jan 2026 16:47:06 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 7 Jan 2026 16:44:13 -0700 Message-ID: <20260107234426.3508161-4-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: QOLN24HVZ66SIBLJNQ6BCZWBIMGLZLON X-Message-ID-Hash: QOLN24HVZ66SIBLJNQ6BCZWBIMGLZLON 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 3/9] fs: ext4l: Add m_seq field to ext4_map_blocks struct 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 the m_seq (extent status sequence) field to struct ext4_map_blocks to match the Linux kernel structure. This field is used in Linux for tracking extent status cache coherency but is unused in U-Boot's single-threaded environment. Update ext4_es_lookup_extent() to accept an optional m_seqp parameter matching the Linux kernel API, and update all call sites accordingly. The sequence value is never actually used in U-Boot, but having the field and parameter present allows the code to match Linux more closely. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/ext4.h | 1 + fs/ext4l/extents.c | 2 +- fs/ext4l/extents_status.c | 2 +- fs/ext4l/extents_status.h | 2 +- fs/ext4l/inode.c | 8 ++++---- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/fs/ext4l/ext4.h b/fs/ext4l/ext4.h index 47054daffc2..1cbeebaf0a6 100644 --- a/fs/ext4l/ext4.h +++ b/fs/ext4l/ext4.h @@ -235,6 +235,7 @@ struct ext4_map_blocks { ext4_lblk_t m_lblk; unsigned int m_len; unsigned int m_flags; + u64 m_seq; /* Extent status sequence (unused in U-Boot) */ }; /* diff --git a/fs/ext4l/extents.c b/fs/ext4l/extents.c index 955f587426b..d2103fbac83 100644 --- a/fs/ext4l/extents.c +++ b/fs/ext4l/extents.c @@ -2200,7 +2200,7 @@ static int ext4_fill_es_cache_info(struct inode *inode, while (block <= end) { next = 0; flags = 0; - if (!ext4_es_lookup_extent(inode, block, &next, &es)) + if (!ext4_es_lookup_extent(inode, block, &next, &es, NULL)) break; if (ext4_es_is_unwritten(&es)) flags |= FIEMAP_EXTENT_UNWRITTEN; diff --git a/fs/ext4l/extents_status.c b/fs/ext4l/extents_status.c index f557c7c23c2..706e267a79f 100644 --- a/fs/ext4l/extents_status.c +++ b/fs/ext4l/extents_status.c @@ -1037,7 +1037,7 @@ void ext4_es_cache_extent(struct inode *inode, ext4_lblk_t lblk, */ int ext4_es_lookup_extent(struct inode *inode, ext4_lblk_t lblk, ext4_lblk_t *next_lblk, - struct extent_status *es) + struct extent_status *es, u64 *m_seqp) { struct ext4_es_tree *tree; struct ext4_es_stats *stats; diff --git a/fs/ext4l/extents_status.h b/fs/ext4l/extents_status.h index 8f9c008d11e..e668cda0d92 100644 --- a/fs/ext4l/extents_status.h +++ b/fs/ext4l/extents_status.h @@ -148,7 +148,7 @@ extern void ext4_es_find_extent_range(struct inode *inode, struct extent_status *es); extern int ext4_es_lookup_extent(struct inode *inode, ext4_lblk_t lblk, ext4_lblk_t *next_lblk, - struct extent_status *es); + struct extent_status *es, u64 *m_seqp); extern bool ext4_es_scan_range(struct inode *inode, int (*matching_fn)(struct extent_status *es), ext4_lblk_t lblk, ext4_lblk_t end); diff --git a/fs/ext4l/inode.c b/fs/ext4l/inode.c index 7001c7299cd..04b7c734f7f 100644 --- a/fs/ext4l/inode.c +++ b/fs/ext4l/inode.c @@ -627,7 +627,7 @@ static int ext4_map_create_blocks(handle_t *handle, struct inode *inode, * extent status tree. */ if (flags & EXT4_GET_BLOCKS_PRE_IO && - ext4_es_lookup_extent(inode, map->m_lblk, NULL, &es)) { + ext4_es_lookup_extent(inode, map->m_lblk, NULL, &es, &map->m_seq)) { if (ext4_es_is_written(&es)) return retval; } @@ -701,7 +701,7 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode, ext4_check_map_extents_env(inode); /* Lookup extent status tree firstly */ - if (ext4_es_lookup_extent(inode, map->m_lblk, NULL, &es)) { + if (ext4_es_lookup_extent(inode, map->m_lblk, NULL, &es, &map->m_seq)) { if (ext4_es_is_written(&es) || ext4_es_is_unwritten(&es)) { map->m_pblk = ext4_es_pblock(&es) + map->m_lblk - es.es_lblk; @@ -1885,7 +1885,7 @@ static int ext4_da_map_blocks(struct inode *inode, struct ext4_map_blocks *map) ext4_check_map_extents_env(inode); /* Lookup extent status tree firstly */ - if (ext4_es_lookup_extent(inode, map->m_lblk, NULL, &es)) { + if (ext4_es_lookup_extent(inode, map->m_lblk, NULL, &es, NULL)) { map->m_len = min_t(unsigned int, map->m_len, es.es_len - (map->m_lblk - es.es_lblk)); @@ -1938,7 +1938,7 @@ add_delayed: * is held in write mode, before inserting a new da entry in * the extent status tree. */ - if (ext4_es_lookup_extent(inode, map->m_lblk, NULL, &es)) { + if (ext4_es_lookup_extent(inode, map->m_lblk, NULL, &es, NULL)) { map->m_len = min_t(unsigned int, map->m_len, es.es_len - (map->m_lblk - es.es_lblk)); From patchwork Wed Jan 7 23:44:14 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1337 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=1767829642; bh=P/9ayjpyxebE04eAMKucUCVicyaaIz9Yid2sr4S/gW4=; 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=cYO98PiZYwhib73IGmzqG1CDmlWwSD+VYK3blelFHg8PoGoxNAgNKCq9PXKnbEycY LUvNp5VBirVmbZ2bcf0oNc42zgjTPK+nDt339JmRo++wL06ubw9lSAaJ6ARs8xob2i U6mLVtmpiwST+EA+NikVq3Mu6CsQnT/2gDSZ3amUZlIwDHogPxyL8smsboRK8MsJI0 +Iij412mHoHUjoyAR7XmtgSHTqCCXvQ0Y7xmdxW+f2WSWtbiH4JGaYRzY+rrVQMXJp 1CfqPXaIjjAz3tTgqmLGUBThdbszIDjTp+L3udApzqm5PsVoJbRJpg//ScsjEc1WuH SH34hmlGB8u5A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 48364691AF for ; Wed, 7 Jan 2026 16:47:22 -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 5YMQux4iIo0E for ; Wed, 7 Jan 2026 16:47:22 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829642; bh=P/9ayjpyxebE04eAMKucUCVicyaaIz9Yid2sr4S/gW4=; 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=cYO98PiZYwhib73IGmzqG1CDmlWwSD+VYK3blelFHg8PoGoxNAgNKCq9PXKnbEycY LUvNp5VBirVmbZ2bcf0oNc42zgjTPK+nDt339JmRo++wL06ubw9lSAaJ6ARs8xob2i U6mLVtmpiwST+EA+NikVq3Mu6CsQnT/2gDSZ3amUZlIwDHogPxyL8smsboRK8MsJI0 +Iij412mHoHUjoyAR7XmtgSHTqCCXvQ0Y7xmdxW+f2WSWtbiH4JGaYRzY+rrVQMXJp 1CfqPXaIjjAz3tTgqmLGUBThdbszIDjTp+L3udApzqm5PsVoJbRJpg//ScsjEc1WuH SH34hmlGB8u5A== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2F678691AD for ; Wed, 7 Jan 2026 16:47:22 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829636; bh=QKROtd++HFhfs/z+VbLP4mslM+pToFgMjTjOAOD3rcw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cx9H+n+ch7QZbpCyNEgxo72BLdY1pPp2kkS4vBibnqMvLQZS9qNsxzUSdC0tqzr1A 9jB8PkfBOCwlKaZMb02crXJ5Jsbl0nKkaIzhgqJ29p9T8ahU8ls+ndw7p1AgGWU6Q8 LY8H64f0LPvGDCId8EkynYpjuSxC6TPj7bQVPW7ncrfFBUjQEh34mOCxn8AbyEnMD5 qNK089Qy+3+DkQb7DyxrYnnLxJsyTN9r/rxHqXaN7xh5wx9UhWV7pC0jn2BL0e4wjn yqMWD033Gwh4wfG65zb8qfxxCs8tRpuLqTKVoamyG920Cdn+rnczj2ayzrivKJlc6W On06dDsfgRz1Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D1FCE69195; Wed, 7 Jan 2026 16:47:16 -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 Gc8RhOnfWp35; Wed, 7 Jan 2026 16:47:16 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829631; bh=UJ2EOe5yTK2YQN9LWLihwnaRnvg1B6n0E8g7wA45XrI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FEphdchS1W2ObTKufC24c8pvkqHT73wtJ+4gUKj0KPGL2/aiAj6/pHJ05JIgoPuEE OMapKnOOH2Ks6tOt/qxBekwPaZ8v249nSUqpxVAJ7deLksK8okqyorCOdUVuwQrfd+ 8tzIpWQy1DgfiTRBUdNlZc0IXaRkVHaK7Jb8lsq8PVySZg4mDDHTWFEEH/xXNjLbxM V8OVYmXQ5+5YK9J/fb0kRA9/DReoRa6+i9oSaHD0ZHwR6K0l0fdVihPI4ujioFATmB O/j91IodAI5e/tXfdjHEv/3T5Nt5qQeTN7fy/bP4R058x5QvOZRzQ2c6Zi+gW3pxeh ibiB4c2IiAJJw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 1EC1569196; Wed, 7 Jan 2026 16:47:11 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 7 Jan 2026 16:44:14 -0700 Message-ID: <20260107234426.3508161-5-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: 7HV3N7LCJYTLZUMCAQLC65633RFYKWU2 X-Message-ID-Hash: 7HV3N7LCJYTLZUMCAQLC65633RFYKWU2 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 4/9] fs: ext4l: Add folio helper macros 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 folio_next_pos() and fgf_set_order() macros to ext4_uboot.h to match the Linux kernel API. folio_next_pos() returns the byte position following a folio, useful for checking if a folio extends past a given position. fgf_set_order() is a stub that returns 0 since U-Boot doesn't support large folios. In Linux, this is used to request a specific folio size when allocating. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/ext4_uboot.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 943cb31d694..2487d6fc70f 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1565,7 +1565,14 @@ static inline char *d_path(const struct path *path, char *buf, int buflen) #define folio_zero_range(f, s, l) do { } while (0) #define folio_mark_uptodate(f) do { } while (0) #define folio_next_index(f) ((f)->index + 1) +#define folio_next_pos(f) ((loff_t)folio_next_index(f) << PAGE_SHIFT) #define folio_mapped(f) (0) + +/* + * fgf_set_order - Set the order (size) for folio allocation + * U-Boot doesn't support large folios, so this is a no-op stub. + */ +#define fgf_set_order(size) (0) #define folio_clear_dirty_for_io(f) ({ (void)(f); 1; }) #define folio_clear_uptodate(f) do { } while (0) #define folio_batch_release(fb) do { } while (0) From patchwork Wed Jan 7 23:44:15 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1336 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=1767829639; bh=oahrnRJlqxfesqUOJgy5BbtYweVKEdunDYEsZuWIrIM=; 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=pn0PEIRb9bMCaQRaVWznfP4TNLyjSwD6dKgHqvL4r4zSU6jJwjfiUfILTXgli0tue 3mysxvfPQ03tSHfk8tLifxFes7KyeksDQM8+QHal4r+8Pumd2S8srV884OoNt156Pg yux+ya5p+rZieiFRmjh5TDy+QwQwpqCcgudiPYWsCYPTpJLBtxx7a7SAHsTb8pMDGH aB1NIyTLsPiJkJg6Ql8s9kl7rhO59jEZVc2aoG7k6mAqd9CIBMZtLeoSIW+55Rfy7U 6oMT3Z9ksD2fdUBB/HcP/lLPkt27JCHuBLh28HB3RURNrISQ3ZveMfD9Snk6oT1EZM fGedIgr9PIbzw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F331569146 for ; Wed, 7 Jan 2026 16:47:19 -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 DKFiBlKm-llC for ; Wed, 7 Jan 2026 16:47:19 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829639; bh=oahrnRJlqxfesqUOJgy5BbtYweVKEdunDYEsZuWIrIM=; 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=pn0PEIRb9bMCaQRaVWznfP4TNLyjSwD6dKgHqvL4r4zSU6jJwjfiUfILTXgli0tue 3mysxvfPQ03tSHfk8tLifxFes7KyeksDQM8+QHal4r+8Pumd2S8srV884OoNt156Pg yux+ya5p+rZieiFRmjh5TDy+QwQwpqCcgudiPYWsCYPTpJLBtxx7a7SAHsTb8pMDGH aB1NIyTLsPiJkJg6Ql8s9kl7rhO59jEZVc2aoG7k6mAqd9CIBMZtLeoSIW+55Rfy7U 6oMT3Z9ksD2fdUBB/HcP/lLPkt27JCHuBLh28HB3RURNrISQ3ZveMfD9Snk6oT1EZM fGedIgr9PIbzw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CAE0669195 for ; Wed, 7 Jan 2026 16:47:19 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829636; bh=7eQSse8H333ibdJoA38/XWiXaY4UFkULeVnPN9/Jmw8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aemztDIr/FNr+eYxdCkKNCorVFGUjpvAT3GS6T4o01vUO3krXlZtrjAvFgJJMMblU aL/yhLTJvR4k4tO83PpU1bEXCFOPdY+6ZNAR5kGHvpJ7UPSjcHrQ9AeTvOAWVtax7n HQVJArNVbSwI+nJhVsSCTRlTSZbm6ruMk1HHGBkc3sx4k60KOw1z4dh2KiGTsO0pmy RYoYyUfSTA9vk7YKWKXPdoA8UJs5TrNPeyyoSehp65kaARqgO5NsBtf4scDbp2i8bU 31Y9QNJGUr6D4nBIm3scYOQEiFCLf7eO0RBPUIVQNK/zt2CTePsV8FL6urohYEbLnJ h+LIerfgf1a9g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D1DE569146; Wed, 7 Jan 2026 16:47:16 -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 X2A133TltXi0; Wed, 7 Jan 2026 16:47:16 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829636; bh=DNwkD92NIcQrfz8SybUJEJHIeUDa2n1kwGQwltHijDw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wqvEuTrxw6UiyRPwaio6Xe0NNy2ZLv7bPYkposcQIFarvvCkHrVuzpUFjE8gFstyZ eUW0cZsXDMga4VnEcleFuL0vs3JqWinxbYzL+k8M30eYobvF/HNqGvd+MtWier+eCh bMs8dzpujMPxEmdLLRIQVqwk57FFdYdYYCDqX4Jq4DDYHq4Vu3vPZ+4iF0+zYBuoAg gi0fyooIeZFfFgI20NwiBNRUY7pShIJo2tXvNDiaPetrg1+5NrnDTlYOoxm2ft9O3R lZgGX60lYqMzPPhSB/XpWKMkM4dVbT97od7Cdwlopq9HvJZd4Z0UWA7Jegzt5NiNWk UkArVzs7WpgoQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D9DE369187; Wed, 7 Jan 2026 16:47:15 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 7 Jan 2026 16:44:15 -0700 Message-ID: <20260107234426.3508161-6-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: OS4XJEJADQRS3U4BV7622XCPFKFRUBPG X-Message-ID-Hash: OS4XJEJADQRS3U4BV7622XCPFKFRUBPG 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 5/9] fs: ext4l: Align verity.c, symlink.c and hash.c with Linux 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 verity.c: - Use EXT4_LBLK_TO_B() macro instead of inline shift symlink.c: - Change ext4_free_link() parameter from const void* to void* to match Linux kernel signature and remove unnecessary cast hash.c: - Return -EINVAL instead of -1 for error consistency Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/hash.c | 2 +- fs/ext4l/verity.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/ext4l/hash.c b/fs/ext4l/hash.c index 1ce0c2bcc84..58063a872d3 100644 --- a/fs/ext4l/hash.c +++ b/fs/ext4l/hash.c @@ -267,7 +267,7 @@ static int __ext4fs_dirhash(const struct inode *dir, const char *name, int len, combined_hash = fscrypt_fname_siphash(dir, &qname); } else { ext4_warning_inode(dir, "Siphash requires key"); - return -1; + return -EINVAL; } hash = (__u32)(combined_hash >> 32); diff --git a/fs/ext4l/verity.c b/fs/ext4l/verity.c index b0acb0c5031..415d9c4d8a3 100644 --- a/fs/ext4l/verity.c +++ b/fs/ext4l/verity.c @@ -302,7 +302,7 @@ static int ext4_get_verity_descriptor_location(struct inode *inode, end_lblk = le32_to_cpu(last_extent->ee_block) + ext4_ext_get_actual_len(last_extent); - desc_size_pos = (u64)end_lblk << inode->i_blkbits; + desc_size_pos = EXT4_LBLK_TO_B(inode, end_lblk); ext4_free_ext_path(path); if (desc_size_pos < sizeof(desc_size_disk)) From patchwork Wed Jan 7 23:44:16 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1338 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=1767829643; bh=2qjE8xeexSAi5R6G71g1yZlxTBDm+B+6bZS4pC2l8vg=; 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=BX8ZadqwWGHS/QTj5AZF0pNkqX1XVWuqUxAW6ffP4h3XQvm/sPFVP0/Xw/0MSUeHJ HSzilm7xgfH5+U2wxnfzI/ndY5k1buO+m1XWhC2ilKIWVdreoiEtHEhT+zHDkF3muT BB6qEqlZn2zwjMX63hKF1NVJkIu8uJjYxWuxImCifi1WwcsaVaFQJTchPfsRV41t+6 vcBeqQWgDW5plXSdsKlJF4PP5V7uT7vlR416tO+u4HQ3ofjrjE42a4k65l4JBRjE6e wYjUE/lWKhANokz0R6wJacuHEhmOn2k1+Rlc9uDL9o4H37gnANr8+wBKTxSYFACZlC TiF15dNqKb8Fg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 893BE691A2 for ; Wed, 7 Jan 2026 16:47:23 -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 9BWRvFKAzqIU for ; Wed, 7 Jan 2026 16:47:23 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829643; bh=2qjE8xeexSAi5R6G71g1yZlxTBDm+B+6bZS4pC2l8vg=; 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=BX8ZadqwWGHS/QTj5AZF0pNkqX1XVWuqUxAW6ffP4h3XQvm/sPFVP0/Xw/0MSUeHJ HSzilm7xgfH5+U2wxnfzI/ndY5k1buO+m1XWhC2ilKIWVdreoiEtHEhT+zHDkF3muT BB6qEqlZn2zwjMX63hKF1NVJkIu8uJjYxWuxImCifi1WwcsaVaFQJTchPfsRV41t+6 vcBeqQWgDW5plXSdsKlJF4PP5V7uT7vlR416tO+u4HQ3ofjrjE42a4k65l4JBRjE6e wYjUE/lWKhANokz0R6wJacuHEhmOn2k1+Rlc9uDL9o4H37gnANr8+wBKTxSYFACZlC TiF15dNqKb8Fg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6AF4D691A6 for ; Wed, 7 Jan 2026 16:47:23 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829641; bh=nR4g+8Y2EWiEw8uzrDL04Q5InOK6KFvAoi2HBQg8lw0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IP7py8BNSb9eB/RzGAY6UEaRGloxtLTRSIGKN+NeHaBVtJA+p0ZK9vhHQoVMTf9rL 7xbwhkFnENz37QU8UdtbbIkRMbi6qoqoHwbFODTP5LNJMO3Q2Yrubngm4sbi1ZItNY ncadmLnhJOW2ib9D23uXXuGjOrjkgD5EfEg3W+TQ7VBwLWOjMGhjh5IxP+55Hm//8e ysz2VXNCDue5CIm/iJU05LkDoEqAkcKvAhPIsKlP2ADLfY0L51+t3HgFCQRzsJHZeX HGUfXYtOUyPC4mVM4SyILrQJ5Wr49oI63JDiIyLhTziPz/lV+oEsX0PDYfjR/0371Z a91Pgd6JSFigQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B1B1D691A2; Wed, 7 Jan 2026 16:47:21 -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 OPpSma-9xhBY; Wed, 7 Jan 2026 16:47:21 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829637; bh=aZRTfk5MkSHVDL7AXIVRswPnGhrb9MTb9G19jFur2UU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WST7El4+okFEq4F7PAcgrVX+ipHfP1eFA9MHY2bbHHIaeizcJVL5ICMubCvbULfWc EbBXaICDMCtyWxWv89FQUj/BDUHNhhv+wGERqWhF7gsGkDR3dnzMmqtfuv3Edr/Enu DJE2yVjMHJP0BjhnwKcs7zzEOv/O7JKFsmpNEwIM2YkPtkhHlaMdEe6YKEKu8+/OnB KuJk2SCg1Pux3NYVLGnB4wwvcU/dT4GsVnP5XJ1sVAftO3Bb4mO2Rcgg50EbhhNZ/6 sMeZ6oQY32aggzY/KqLsZ1ts9mbDGbPFQuED68nzXSYyGbTsj8r+XpYbcIccnCKsSY QS0TIb7WqtsBQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id F17DF69187; Wed, 7 Jan 2026 16:47:16 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 7 Jan 2026 16:44:16 -0700 Message-ID: <20260107234426.3508161-7-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: AKUY3MQJ2KEDMRAUA5A72I6OO2JMQLKT X-Message-ID-Hash: AKUY3MQJ2KEDMRAUA5A72I6OO2JMQLKT 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 6/9] fs: ext4l: Use EXT4_MAX_ORPHAN_FILE_BLOCKS in orphan.c 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 the EXT4_MAX_ORPHAN_FILE_BLOCKS constant (512) and use it in the orphan file size check, matching the Linux kernel implementation. The previous hardcoded value of (8 << 20) assumed 16KB blocks to get 512 blocks, but the proper calculation uses the actual block size from the inode. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/orphan.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/ext4l/orphan.c b/fs/ext4l/orphan.c index 65d0d177c5d..0f5dcca1d96 100644 --- a/fs/ext4l/orphan.c +++ b/fs/ext4l/orphan.c @@ -7,6 +7,8 @@ #include "ext4.h" #include "ext4_jbd2.h" +#define EXT4_MAX_ORPHAN_FILE_BLOCKS 512 + static int ext4_orphan_file_add(handle_t *handle, struct inode *inode) { int i, j, start; @@ -596,7 +598,7 @@ int ext4_init_orphan_info(struct super_block *sb) * consuming absurd amounts of memory when pinning blocks of orphan * file in memory. */ - if (inode->i_size > 8 << 20) { + if (inode->i_size > (EXT4_MAX_ORPHAN_FILE_BLOCKS << inode->i_blkbits)) { ext4_msg(sb, KERN_ERR, "orphan file too big: %llu", (unsigned long long)inode->i_size); ret = -EFSCORRUPTED; From patchwork Wed Jan 7 23:44:17 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1339 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=1767829649; bh=nXW8JeABn3rUKGb9ZGZZhcaUpdr+P83RWqCJwmT75FU=; 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=biYAMCJACcWuD5nAZsVmIzznOQnODRHjDGzqDLvkuDP1Ga/ZnxgCrrSzXEG1X1HY9 avU5sqe3DBgzTut+yPv2Cy65dRVcg6KCAiec4BhHmdqB78j+NYzRuPStM2WhTQeLKg BKxniFfz/6Hw6PAwfofpvyrD0x9E62V27YhppwbhXWwvpLowH3xXTtXgfh4hTlnN7a /T2lNGI9kcoGM51B57sN99lPUIUSx7m40tINhEDkdMUI6ceMxFpA1MS1hdq6vTYTkA A7/tIYhE8g0xB2Yu87W3/wqXERLC9K9AGM6mnfgxhM0HUtJPQaymOKQ2qToEPM7S7e s6BZUr6XG35sg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CA48069146 for ; Wed, 7 Jan 2026 16:47:29 -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 rJA9suF1b80W for ; Wed, 7 Jan 2026 16:47:29 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829649; bh=nXW8JeABn3rUKGb9ZGZZhcaUpdr+P83RWqCJwmT75FU=; 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=biYAMCJACcWuD5nAZsVmIzznOQnODRHjDGzqDLvkuDP1Ga/ZnxgCrrSzXEG1X1HY9 avU5sqe3DBgzTut+yPv2Cy65dRVcg6KCAiec4BhHmdqB78j+NYzRuPStM2WhTQeLKg BKxniFfz/6Hw6PAwfofpvyrD0x9E62V27YhppwbhXWwvpLowH3xXTtXgfh4hTlnN7a /T2lNGI9kcoGM51B57sN99lPUIUSx7m40tINhEDkdMUI6ceMxFpA1MS1hdq6vTYTkA A7/tIYhE8g0xB2Yu87W3/wqXERLC9K9AGM6mnfgxhM0HUtJPQaymOKQ2qToEPM7S7e s6BZUr6XG35sg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id ACB1F69196 for ; Wed, 7 Jan 2026 16:47:29 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829646; bh=buw4q/ImIIjzeKT5Ra+gAcYhrCdggYIJ/hLx+PzHd40=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oG0t/in2VUbWvLYha35es13O2immshZMfUEXV59CUlGvvFExC2PdlD/8lH0j1/Hy7 43cXpuqBAnYywRJ7wdyYwvogmJ248izkJ4oa1VeaLVRjOhSxv+rxD2lZDoP9JUM9aT G5RZlylpnEaH28AYKVifacfOsGhRR/iUmZ2rJIv6OT57GJWyVi1j1Q+TxCVs9klC1o ShjwL09x29q10300W/Sduyvq/DrSyT4YOMg7bQFztGuJHpvPdFg01TC7Oeh0N6wU8P CpRoYLKEU2OvwlWAMgEzPXG1Y+elwdRCBnF0IxBssjxRaAESJi1dwn1yXR0ic+yd9s eXM1hjdpaea3Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8D3DC69146; Wed, 7 Jan 2026 16:47:26 -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 si_BaUqEYDQT; Wed, 7 Jan 2026 16:47:26 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829642; bh=jKwln7VjUoPSndg10sqhEKHZxycls3PFq+/vtdAwtEI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sZcMzu6RXJgqDQQNNolJ4zxjLBk0sNyWuco6rbetbnq8jRUgowuBQn/DVvwG4H5rf YcYYu12OK1CQfU87ApOWqILvEJ4uF+zUcEqepyCIw8LmhCr0YqUNemkejVo/hLwFO6 yeWX6adz5rMTnemTO5Wb/lk3QU26ziKLqQR2+sjIjqecjGkrl0jmXEPUiwD149hRet YqCi0r5M5EVcst2E6oXhjrxufMOmwQowrVBtFSEfdyyupXCGr14WHpkpfs+fZUpR0H n5D4YUPmSE9acmGa/0CTFbMAcGaI1rMAnUVAsFoYOzMnsXAMObEMNw+KXLL9ih3BBj zsdtY4Jo5gJaA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id F1AA4691A9; Wed, 7 Jan 2026 16:47:21 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 7 Jan 2026 16:44:17 -0700 Message-ID: <20260107234426.3508161-8-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: UDRCSDJVBUW37IFOEYET7AQQLLAV3SGC X-Message-ID-Hash: UDRCSDJVBUW37IFOEYET7AQQLLAV3SGC 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 7/9] fs: ext4l: Align ialloc.c, inode.c et al with Linux 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 Apply several small fixes to align with the Linux kernel ext4 code: - readpage.c: Use EXT4_PG_TO_LBLK macro instead of inline shifts for block calculations, matching the macro added in an earlier commit - xattr.c: Add error handling for ext4_get_inode_loc() call in ext4_xattr_inode_dec_ref_all() - ioctl.c: Add strnlen check for mount_opts to prevent reading past the buffer end - ialloc.c, inode.c: Remove ext4_clear_state_flags() calls which were removed in upstream Linux (the subsequent ext4_set_inode_state() handles the initialization) Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/ialloc.c | 1 - fs/ext4l/inode.c | 1 - fs/ext4l/ioctl.c | 4 ++++ fs/ext4l/readpage.c | 7 ++----- fs/ext4l/xattr.c | 6 +++++- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/fs/ext4l/ialloc.c b/fs/ext4l/ialloc.c index 5bbe8d6d359..baef744892b 100644 --- a/fs/ext4l/ialloc.c +++ b/fs/ext4l/ialloc.c @@ -1279,7 +1279,6 @@ got: ei->i_csum_seed = ext4_chksum(csum, (__u8 *)&gen, sizeof(gen)); } - ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */ ext4_set_inode_state(inode, EXT4_STATE_NEW); ei->i_extra_isize = sbi->s_want_extra_isize; diff --git a/fs/ext4l/inode.c b/fs/ext4l/inode.c index 04b7c734f7f..d0262fa53f2 100644 --- a/fs/ext4l/inode.c +++ b/fs/ext4l/inode.c @@ -5265,7 +5265,6 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino, ei->i_projid = make_kprojid(&init_user_ns, i_projid); set_nlink(inode, le16_to_cpu(raw_inode->i_links_count)); - ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */ ei->i_inline_off = 0; ei->i_dir_start_lookup = 0; ei->i_dtime = le32_to_cpu(raw_inode->i_dtime); diff --git a/fs/ext4l/ioctl.c b/fs/ext4l/ioctl.c index a93a7baae99..3dec26c939f 100644 --- a/fs/ext4l/ioctl.c +++ b/fs/ext4l/ioctl.c @@ -1394,6 +1394,10 @@ static int ext4_ioctl_set_tune_sb(struct file *filp, if (copy_from_user(¶ms, in, sizeof(params))) return -EFAULT; + if (strnlen(params.mount_opts, sizeof(params.mount_opts)) == + sizeof(params.mount_opts)) + return -E2BIG; + if ((params.set_flags & ~TUNE_OPS_SUPPORTED) != 0) return -EOPNOTSUPP; diff --git a/fs/ext4l/readpage.c b/fs/ext4l/readpage.c index 94361c01f08..7f1cb419339 100644 --- a/fs/ext4l/readpage.c +++ b/fs/ext4l/readpage.c @@ -199,9 +199,7 @@ int ext4_mpage_readpages(struct inode *inode, { struct bio *bio = NULL; sector_t last_block_in_bio = 0; - const unsigned blkbits = inode->i_blkbits; - const unsigned blocks_per_page = PAGE_SIZE >> blkbits; const unsigned blocksize = 1 << blkbits; sector_t next_block; sector_t block_in_file; @@ -237,9 +235,8 @@ int ext4_mpage_readpages(struct inode *inode, blocks_per_folio = folio_size(folio) >> blkbits; first_hole = blocks_per_folio; - block_in_file = next_block = - (sector_t)folio->index << (PAGE_SHIFT - blkbits); - last_block = block_in_file + nr_pages * blocks_per_page; + block_in_file = next_block = EXT4_PG_TO_LBLK(inode, folio->index); + last_block = EXT4_PG_TO_LBLK(inode, folio->index + nr_pages); last_block_in_file = (ext4_readpage_limit(inode) + blocksize - 1) >> blkbits; if (last_block > last_block_in_file) diff --git a/fs/ext4l/xattr.c b/fs/ext4l/xattr.c index bd89822a682..a17ce41eba3 100644 --- a/fs/ext4l/xattr.c +++ b/fs/ext4l/xattr.c @@ -1170,7 +1170,11 @@ ext4_xattr_inode_dec_ref_all(handle_t *handle, struct inode *parent, if (block_csum) end = (void *)bh->b_data + bh->b_size; else { - ext4_get_inode_loc(parent, &iloc); + err = ext4_get_inode_loc(parent, &iloc); + if (err) { + EXT4_ERROR_INODE(parent, "parent inode loc (error %d)", err); + return; + } end = (void *)ext4_raw_inode(&iloc) + EXT4_SB(parent->i_sb)->s_inode_size; } From patchwork Wed Jan 7 23:44:18 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1340 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=1767829654; bh=sGbzmxXC2UpmEpEhLpHCks9bK+SPirgYqp7rnowWMGQ=; 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=O49odasEdyc9B5DFRZ3O3D3uhOcO7mcA7tYi3uMsnzI2LsJAqvRsDfLLfwSvt4WG2 nIlatsqLD6Sql7h/z0jY9Az4K3of/cBAyZDzAiMQHhFXFR66eMp0ZCjZobpZyYh1rs /WIkUxkIWOzubAJq9lKROWbyOSp8byki6YrJxzZndKWpk68C21qlBr9VWKr8EDvC1T jjhoB09yEp5vs3jJPtFQqNg3WWDviaxvIoOsv+VJmU2m+lPFQtRk6DJpCCOAoPXV8p 1Fid4XkHau04BTBmQh2DMaOoVpi6WQ1LTwDVJkV7Dk30mENE4QanFTHnjpiosdE1Zk LMtiUKCmhgVyQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D6A5D69196 for ; Wed, 7 Jan 2026 16:47:34 -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 KMvcuzCSY7KX for ; Wed, 7 Jan 2026 16:47:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829654; bh=sGbzmxXC2UpmEpEhLpHCks9bK+SPirgYqp7rnowWMGQ=; 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=O49odasEdyc9B5DFRZ3O3D3uhOcO7mcA7tYi3uMsnzI2LsJAqvRsDfLLfwSvt4WG2 nIlatsqLD6Sql7h/z0jY9Az4K3of/cBAyZDzAiMQHhFXFR66eMp0ZCjZobpZyYh1rs /WIkUxkIWOzubAJq9lKROWbyOSp8byki6YrJxzZndKWpk68C21qlBr9VWKr8EDvC1T jjhoB09yEp5vs3jJPtFQqNg3WWDviaxvIoOsv+VJmU2m+lPFQtRk6DJpCCOAoPXV8p 1Fid4XkHau04BTBmQh2DMaOoVpi6WQ1LTwDVJkV7Dk30mENE4QanFTHnjpiosdE1Zk LMtiUKCmhgVyQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C5BD369146 for ; Wed, 7 Jan 2026 16:47:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829652; bh=6i6O+sQTvnBQRSaNXBK7+Ok2jMYPcMAk2pBrMHHw5l0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V1P2XPOft6sHkboaY7bed7Qb6vTJgdBi+DQR8BqP1BQc17NjvL4OdSaAotasDNBWj g5x+R6ELtCd9UmJnVJqpkpiFFw0D5ZLea7UPzDZpXkWt22AB+A+xA/GPkRkyPLJLX/ 5xZRulpVpXVUDGsrM5e+3gWTy3hTi0A2Qeom6c47TQvBsavRtkNImgSgZr+Hj6hzSb uY0yaviXAwHxss0VG/PGRrPv+8nf4kMbEPj4w/l68XeWF0mHYe/aF0QmzsPBNq9u0p TlaCJB3LdWwd8syKfN/5rPOXojw7nsTMoHggykkCyhlvVmoy4dXEq2+aJrC6WXY4ut oJOLQJDUYvbxw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9A07969196; Wed, 7 Jan 2026 16:47:32 -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 DUKn9JgZeDXC; Wed, 7 Jan 2026 16:47:32 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829647; bh=jqP6zt5mwQ3T5onWZmv2Th3RKu3j5X5gkWaAgAl2AFM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kUWLm3Oad90nHFXWNfGZkk2MWEc7PWTz/FRrdUWEUc0p6giHOSXimtqpOYvjiEDav yBAt/D/jJs0ARnh//JEYHaIgkR6OPchPA8+QGvXv771dfVDzfTqPZwfqRGssBMfJaR l/DhLto/0RwCDZ0WwunyGjZeinv5/TLyPBuafPkMwy4rSr0ageApcplda1B3djT1xn M1BQ5mKeO9sMOsCkPEH0aHa19bwBNnRebNLgEJWGPGAj9JpehsGW5vTGWGp2LMwUFU GN+SNwV+k+51hccL1Ed5f8uCvXr+ZRY53keVAYTxZmD1wSPeCwgptJWcszkC7UKWzO XYFSvhaeuHA/A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id CD87769187; Wed, 7 Jan 2026 16:47:26 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 7 Jan 2026 16:44:18 -0700 Message-ID: <20260107234426.3508161-9-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: UWKHTARI6PFFZ7QXLZSJAXLNEBMKVFMV X-Message-ID-Hash: UWKHTARI6PFFZ7QXLZSJAXLNEBMKVFMV 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 8/9] fs: ext4l: Rename EXT4_GET_BLOCKS_PRE_IO flag 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 Align with the Linux kernel's rename of this flag. The flag is used to indicate that newly allocated extents cannot be merged, and if an unwritten extent is found, it needs to be split. Rename to EXT4_GET_BLOCKS_SPLIT_NOMERGE to match Linux v6.12 Also update extents.c to: - Use EXT4_LBLK_TO_B() macro for block-to-byte conversion - Remove unnecessary initialisation of the 'len' variable in ext4_ext_find_hole() Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/ext4.h | 18 +++++++++++++----- fs/ext4l/extents.c | 18 +++++++++--------- fs/ext4l/inode.c | 2 +- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/fs/ext4l/ext4.h b/fs/ext4l/ext4.h index 1cbeebaf0a6..34dbc4f12b8 100644 --- a/fs/ext4l/ext4.h +++ b/fs/ext4l/ext4.h @@ -678,12 +678,20 @@ enum { /* Caller is from the delayed allocation writeout path * finally doing the actual allocation of delayed blocks */ #define EXT4_GET_BLOCKS_DELALLOC_RESERVE 0x0004 - /* caller is from the direct IO path, request to creation of an - unwritten extents if not allocated, split the unwritten - extent if blocks has been preallocated already*/ -#define EXT4_GET_BLOCKS_PRE_IO 0x0008 + /* + * This means that we cannot merge newly allocated extents, and if we + * found an unwritten extent, we need to split it. + */ +#define EXT4_GET_BLOCKS_SPLIT_NOMERGE 0x0008 #define EXT4_GET_BLOCKS_CONVERT 0x0010 -#define EXT4_GET_BLOCKS_IO_CREATE_EXT (EXT4_GET_BLOCKS_PRE_IO|\ + /* + * Caller is from the dio or dioread_nolock buffered IO, request to + * create an unwritten extent if it does not exist or split the + * found unwritten extent. Also do not merge the newly created + * unwritten extent, io end will convert unwritten to written, + * and try to merge the written extent. + */ +#define EXT4_GET_BLOCKS_IO_CREATE_EXT (EXT4_GET_BLOCKS_SPLIT_NOMERGE|\ EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT) /* Eventual metadata allocation (due to growing extent tree) * should not fail, so try to use reserved blocks for that.*/ diff --git a/fs/ext4l/extents.c b/fs/ext4l/extents.c index d2103fbac83..028d77272b5 100644 --- a/fs/ext4l/extents.c +++ b/fs/ext4l/extents.c @@ -320,7 +320,7 @@ ext4_force_split_extent_at(handle_t *handle, struct inode *inode, int nofail) { int unwritten = ext4_ext_is_unwritten(path[path->p_depth].p_ext); - int flags = EXT4_EX_NOCACHE | EXT4_GET_BLOCKS_PRE_IO; + int flags = EXT4_EX_NOCACHE | EXT4_GET_BLOCKS_SPLIT_NOMERGE; if (nofail) flags |= EXT4_GET_BLOCKS_METADATA_NOFAIL | EXT4_EX_NOFAIL; @@ -1989,7 +1989,7 @@ ext4_ext_insert_extent(handle_t *handle, struct inode *inode, } /* try to insert block into found extent and return */ - if (ex && !(gb_flags & EXT4_GET_BLOCKS_PRE_IO)) { + if (ex && !(gb_flags & EXT4_GET_BLOCKS_SPLIT_NOMERGE)) { /* * Try to see whether we should rather test the extent on @@ -2168,7 +2168,7 @@ has_space: merge: /* try to merge extents */ - if (!(gb_flags & EXT4_GET_BLOCKS_PRE_IO)) + if (!(gb_flags & EXT4_GET_BLOCKS_SPLIT_NOMERGE)) ext4_ext_try_to_merge(handle, inode, path, nearex); /* time to correct all indexes above */ @@ -3211,7 +3211,7 @@ static struct ext4_ext_path *ext4_split_extent_at(handle_t *handle, else ext4_ext_mark_initialized(ex); - if (!(flags & EXT4_GET_BLOCKS_PRE_IO)) + if (!(flags & EXT4_GET_BLOCKS_SPLIT_NOMERGE)) ext4_ext_try_to_merge(handle, inode, path, ex); err = ext4_ext_dirty(handle, inode, path + path->p_depth); @@ -3355,7 +3355,7 @@ static struct ext4_ext_path *ext4_split_extent(handle_t *handle, if (map->m_lblk + map->m_len < ee_block + ee_len) { split_flag1 = split_flag & EXT4_EXT_MAY_ZEROOUT; - flags1 = flags | EXT4_GET_BLOCKS_PRE_IO; + flags1 = flags | EXT4_GET_BLOCKS_SPLIT_NOMERGE; if (unwritten) split_flag1 |= EXT4_EXT_MARK_UNWRIT1 | EXT4_EXT_MARK_UNWRIT2; @@ -3726,7 +3726,7 @@ static struct ext4_ext_path *ext4_split_convert_extents(handle_t *handle, EXT4_EXT_MAY_ZEROOUT : 0; split_flag |= (EXT4_EXT_MARK_UNWRIT2 | EXT4_EXT_DATA_VALID2); } - flags |= EXT4_GET_BLOCKS_PRE_IO; + flags |= EXT4_GET_BLOCKS_SPLIT_NOMERGE; return ext4_split_extent(handle, inode, path, map, split_flag, flags, allocated); } @@ -3898,7 +3898,7 @@ ext4_ext_handle_unwritten_extents(handle_t *handle, struct inode *inode, *allocated, newblock); /* get_block() before submitting IO, split the extent */ - if (flags & EXT4_GET_BLOCKS_PRE_IO) { + if (flags & EXT4_GET_BLOCKS_SPLIT_NOMERGE) { path = ext4_split_convert_extents(handle, inode, map, path, flags | EXT4_GET_BLOCKS_CONVERT, allocated); if (IS_ERR(path)) @@ -4549,7 +4549,7 @@ retry: * allow a full retry cycle for any remaining allocations */ retries = 0; - epos = (loff_t)(map.m_lblk + ret) << blkbits; + epos = EXT4_LBLK_TO_B(inode, map.m_lblk + ret); inode_set_ctime_current(inode); if (new_size) { if (epos > new_size) @@ -5605,7 +5605,7 @@ static int ext4_insert_range(struct file *file, loff_t offset, loff_t len) path = ext4_split_extent_at(handle, inode, path, start_lblk, split_flag, EXT4_EX_NOCACHE | - EXT4_GET_BLOCKS_PRE_IO | + EXT4_GET_BLOCKS_SPLIT_NOMERGE | EXT4_GET_BLOCKS_METADATA_NOFAIL); } diff --git a/fs/ext4l/inode.c b/fs/ext4l/inode.c index d0262fa53f2..12f1333660f 100644 --- a/fs/ext4l/inode.c +++ b/fs/ext4l/inode.c @@ -626,7 +626,7 @@ static int ext4_map_create_blocks(handle_t *handle, struct inode *inode, * If the extent has been zeroed out, we don't need to update * extent status tree. */ - if (flags & EXT4_GET_BLOCKS_PRE_IO && + if (flags & EXT4_GET_BLOCKS_SPLIT_NOMERGE && ext4_es_lookup_extent(inode, map->m_lblk, NULL, &es, &map->m_seq)) { if (ext4_es_is_written(&es)) return retval; From patchwork Wed Jan 7 23:44:19 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1341 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=1767829656; bh=SrKjzAIsLpLGdvAdAgiJa1zpSdQQPyhFE6Lj0s0x/Dc=; 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=T0XxyqqG02UvB8ldQRXZknWlP/MpaHwTiXWMEXE3tncY8GEB79A0fPa+HvUpc7Rqo z/7MqkelIbeDg9ivy31ydPIKW2jNVWYskTXaB/Yxklr0AQxECA8zeGrOIztL+c+i0X QYSQtz5vvHMLNEApjOjRQiwVA5iSg9kHBtOBLx6gFmFkXrvggTGxF1LBCJsbCFNzJT cyEcfk9ZEmamIwIir0N3mch+6KyozID0aGerTm2SXG12McF92Tpi6uRjpxidepm1LR /eW02gHvn3agGstucNgDirWPxbMwMsmufnbm+fdlFoJgIQ5lotsYF6oGx9q20wO1Jw 7EVIOpOuLkxrA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3C442691A8 for ; Wed, 7 Jan 2026 16:47:36 -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 hjBeBiIKtexP for ; Wed, 7 Jan 2026 16:47:36 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829656; bh=SrKjzAIsLpLGdvAdAgiJa1zpSdQQPyhFE6Lj0s0x/Dc=; 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=T0XxyqqG02UvB8ldQRXZknWlP/MpaHwTiXWMEXE3tncY8GEB79A0fPa+HvUpc7Rqo z/7MqkelIbeDg9ivy31ydPIKW2jNVWYskTXaB/Yxklr0AQxECA8zeGrOIztL+c+i0X QYSQtz5vvHMLNEApjOjRQiwVA5iSg9kHBtOBLx6gFmFkXrvggTGxF1LBCJsbCFNzJT cyEcfk9ZEmamIwIir0N3mch+6KyozID0aGerTm2SXG12McF92Tpi6uRjpxidepm1LR /eW02gHvn3agGstucNgDirWPxbMwMsmufnbm+fdlFoJgIQ5lotsYF6oGx9q20wO1Jw 7EVIOpOuLkxrA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 11EB569195 for ; Wed, 7 Jan 2026 16:47:36 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829652; bh=rsG8di6MD30y25XbqX8qPT303sb/0+nmopdAtwSEPq8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EFc8z6RMtvD56vuI5m+mJGWw1hEDTYSgx1UC8imz/JrbCnjEEIE8sGJOCZG9fztUB FbIfPeD27ee2R7Fon5T8CCHaaCHwhPLmK4OaM2oDXpGJqXJSf0oRNcsoR9MdOu8cP8 1/m7GDoJ3p1FWcFOlmhAleK3jPBtOPehOSGTIEAiUCd2xEOcAxGMmxijpdZqZUtWLC ekkbDguU+JfZ7j1Pqt22ZuT/P4mUPeyrHpcYTv/iXFKVvXvP4UEyvP5hYuQlwr3vPv HfAAGZjOUk05G0E/H2Fj9122g2jjfaeXI+l12xU9J8TGhqvDna3J8Q6ThgRKanNSY/ PVCuODSLPTtVw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9A093691A2; Wed, 7 Jan 2026 16:47:32 -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 2YAKlt27g71j; Wed, 7 Jan 2026 16:47:32 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767829651; bh=8pKTeYH0GLbCLXrYRpcUbiHk/kQ8q8aTPoD2F5Xjmtc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fx0LjA6R+YMnNSUMTBQKqXHr1lCdyMBNzmaGuCFU+aGnf++3NRJcxW4bDGVhidlZ7 LTAqnv+UFahHIm3jJcS85GYQJeUsNMur55HBWPGAR4VAZ6Zkz8z7n6fwUS+0R6geu4 Nwk+8NAhbAaaCOy5zHpOjJvrZPWenRTRlmjkHmi5y3V7zG3xyHj+1FxMDD4b7DLw9f yQW8StiwSX0rSNFuE0YuKvvmaBeN4R+FQ8xFOwdlBNPrCE8F/hw3CUb2JAB8xtHAx+ OIy/Z0P7/plyxOpRpz4g1imd5inh1hzogF+YLF6czweii17Akejg5u0sOYf4erpPpI dMzp0YKQodNPQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 8D8AA69146; Wed, 7 Jan 2026 16:47:31 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 7 Jan 2026 16:44:19 -0700 Message-ID: <20260107234426.3508161-10-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: 2TCN6PM6VFLIBDI5ZYSMUJYTM6TO3IUF X-Message-ID-Hash: 2TCN6PM6VFLIBDI5ZYSMUJYTM6TO3IUF 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 9/9] fs: ext4l: Use conversion macros in inode.c 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 Update inode.c to use the block conversion macros and other helpers to align with the Linux kernel implementation: - Add wbc_to_tag() helper to ext4_uboot.h matching the Linux kernel version from include/linux/writeback.h - Use EXT4_LBLK_TO_B() for logical block to byte conversion - Use EXT4_PG_TO_LBLK() for page index to logical block conversion - Use EXT4_LBLK_TO_PG() for logical block to page conversion - Use folio_next_pos() instead of folio_pos() + folio_size() - Use i_blocksize() instead of (1 << blkbits) - Remove now-unused blkbits and bpp_bits local variables - Add WARN_ON_ONCE() check in ext4_block_write_begin() These changes make the code more consistent with Linux and reduce the line count difference. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/ext4_uboot.h | 7 +++++++ fs/ext4l/inode.c | 41 +++++++++++++++++------------------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 2487d6fc70f..c013b9605a4 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1337,6 +1337,13 @@ typedef unsigned int xa_mark_t; #define PAGECACHE_TAG_TOWRITE 1 #define PAGECACHE_TAG_WRITEBACK 2 +static inline xa_mark_t wbc_to_tag(struct writeback_control *wbc) +{ + if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) + return PAGECACHE_TAG_TOWRITE; + return PAGECACHE_TAG_DIRTY; +} + /* blk_plug - block I/O plugging stub */ struct blk_plug { int dummy; diff --git a/fs/ext4l/inode.c b/fs/ext4l/inode.c index 12f1333660f..2c60eaefa14 100644 --- a/fs/ext4l/inode.c +++ b/fs/ext4l/inode.c @@ -1140,8 +1140,7 @@ int ext4_block_write_begin(handle_t *handle, struct folio *folio, unsigned block_start, block_end; sector_t block; int err = 0; - unsigned blocksize = inode->i_sb->s_blocksize; - unsigned bbits; + unsigned int blocksize = i_blocksize(inode); struct buffer_head *bh, *head, *wait[2]; int nr_wait = 0; int i; @@ -1150,12 +1149,12 @@ int ext4_block_write_begin(handle_t *handle, struct folio *folio, BUG_ON(!folio_test_locked(folio)); BUG_ON(to > folio_size(folio)); BUG_ON(from > to); + WARN_ON_ONCE(blocksize > folio_size(folio)); head = folio_buffers(folio); if (!head) head = create_empty_buffers(folio, blocksize, 0); - bbits = ilog2(blocksize); - block = (sector_t)folio->index << (PAGE_SHIFT - bbits); + block = EXT4_PG_TO_LBLK(inode, folio->index); for (bh = head, block_start = 0; bh != head || !block_start; block++, block_start = block_end, bh = bh->b_this_page) { @@ -1296,8 +1295,8 @@ retry_grab: if (IS_ERR(folio)) return PTR_ERR(folio); - if (pos + len > folio_pos(folio) + folio_size(folio)) - len = folio_pos(folio) + folio_size(folio) - pos; + if (len > folio_next_pos(folio) - pos) + len = folio_next_pos(folio) - pos; from = offset_in_folio(folio, pos); to = from + len; @@ -2202,7 +2201,6 @@ static int mpage_process_folio(struct mpage_da_data *mpd, struct folio *folio, ext4_lblk_t lblk = *m_lblk; ext4_fsblk_t pblock = *m_pblk; int err = 0; - int blkbits = mpd->inode->i_blkbits; ssize_t io_end_size = 0; struct ext4_io_end_vec *io_end_vec = ext4_last_io_end_vec(io_end); @@ -2228,7 +2226,8 @@ static int mpage_process_folio(struct mpage_da_data *mpd, struct folio *folio, err = PTR_ERR(io_end_vec); goto out; } - io_end_vec->offset = (loff_t)mpd->map.m_lblk << blkbits; + io_end_vec->offset = EXT4_LBLK_TO_B(mpd->inode, + mpd->map.m_lblk); } *map_bh = true; goto out; @@ -2238,7 +2237,7 @@ static int mpage_process_folio(struct mpage_da_data *mpd, struct folio *folio, bh->b_blocknr = pblock++; } clear_buffer_unwritten(bh); - io_end_size += (1 << blkbits); + io_end_size += i_blocksize(mpd->inode); } while (lblk++, (bh = bh->b_this_page) != head); io_end_vec->size += io_end_size; @@ -2268,15 +2267,14 @@ static int mpage_map_and_submit_buffers(struct mpage_da_data *mpd) struct folio_batch fbatch; unsigned nr, i; struct inode *inode = mpd->inode; - int bpp_bits = PAGE_SHIFT - inode->i_blkbits; pgoff_t start, end; ext4_lblk_t lblk; ext4_fsblk_t pblock; int err; bool map_bh = false; - start = mpd->map.m_lblk >> bpp_bits; - end = (mpd->map.m_lblk + mpd->map.m_len - 1) >> bpp_bits; + start = EXT4_LBLK_TO_PG(inode, mpd->map.m_lblk); + end = EXT4_LBLK_TO_PG(inode, mpd->map.m_lblk + mpd->map.m_len - 1); pblock = mpd->map.m_pblk; folio_batch_init(&fbatch); @@ -2287,7 +2285,7 @@ static int mpage_map_and_submit_buffers(struct mpage_da_data *mpd) for (i = 0; i < nr; i++) { struct folio *folio = fbatch.folios[i]; - lblk = folio->index << bpp_bits; + lblk = EXT4_PG_TO_LBLK(inode, folio->index); err = mpage_process_folio(mpd, folio, &lblk, &pblock, &map_bh); /* @@ -2590,16 +2588,12 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd) pgoff_t end = mpd->end_pos >> PAGE_SHIFT; xa_mark_t tag; int i, err = 0; - int blkbits = mpd->inode->i_blkbits; ext4_lblk_t lblk; struct buffer_head *head; handle_t *handle = NULL; int bpp = ext4_journal_blocks_per_folio(mpd->inode); - if (mpd->wbc->sync_mode == WB_SYNC_ALL || mpd->wbc->tagged_writepages) - tag = PAGECACHE_TAG_TOWRITE; - else - tag = PAGECACHE_TAG_DIRTY; + tag = wbc_to_tag(mpd->wbc); mpd->map.m_len = 0; mpd->next_pos = mpd->start_pos; @@ -2629,7 +2623,7 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd) */ if (mpd->wbc->sync_mode == WB_SYNC_NONE && mpd->wbc->nr_to_write <= - mpd->map.m_len >> (PAGE_SHIFT - blkbits)) + EXT4_LBLK_TO_PG(mpd->inode, mpd->map.m_len)) goto out; /* If we can't merge this page, we are done. */ @@ -2681,7 +2675,7 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd) if (mpd->map.m_len == 0) mpd->start_pos = folio_pos(folio); - mpd->next_pos = folio_pos(folio) + folio_size(folio); + mpd->next_pos = folio_next_pos(folio); /* * Writeout when we cannot modify metadata is simple. * Just submit the page. For data=journal mode we @@ -2707,8 +2701,7 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd) mpage_folio_done(mpd, folio); } else { /* Add all dirty buffers to mpd */ - lblk = ((ext4_lblk_t)folio->index) << - (PAGE_SHIFT - blkbits); + lblk = EXT4_PG_TO_LBLK(mpd->inode, folio->index); head = folio_buffers(folio); err = mpage_process_page_bufs(mpd, head, head, lblk); @@ -3123,8 +3116,8 @@ retry: if (IS_ERR(folio)) return PTR_ERR(folio); - if (pos + len > folio_pos(folio) + folio_size(folio)) - len = folio_pos(folio) + folio_size(folio) - pos; + if (len > folio_next_pos(folio) - pos) + len = folio_next_pos(folio) - pos; ret = ext4_block_write_begin(NULL, folio, pos, len, ext4_da_get_block_prep);