From patchwork Tue Dec 30 23:41:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1135 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=1767138309; bh=dW45BHo+d637kwbE817je7aG3/bUJmog4vVenLVb11Q=; 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=TIfzNTkCWhylzbQ6jYU00Wi+AjJoz5fXCPAYkJZNYo0Rrr27ZZPC5Aki4w2XNzzgr aupvX8lCd7sc5HeTaVEc2M4NsdslMwAAGOLiONQHtTLY1CaJnk/Qd+XyROb1rRwN2r dioBojVro1jwPtENHmrDmqCn4FRO9SkD6NDzF5kiKg67wBV/r/WmqHR/EakC5ujcN5 AlDd3CP/7FzeVbDuCp+PzXFP0qdNHjTMUghU9c0o10LuxsrWLkBo5O7dAw3go55TUq M6hhqY3pDgyRppOwzu2CduwporTLpjmQu6Kik00u6OL1ayI1fTduMcAtT4toFHOeUq YCuumTmZR7lsA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BB22C68FA8 for ; Tue, 30 Dec 2025 16:45: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 9KGkWEJM1NlY for ; Tue, 30 Dec 2025 16:45:09 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767138309; bh=dW45BHo+d637kwbE817je7aG3/bUJmog4vVenLVb11Q=; 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=TIfzNTkCWhylzbQ6jYU00Wi+AjJoz5fXCPAYkJZNYo0Rrr27ZZPC5Aki4w2XNzzgr aupvX8lCd7sc5HeTaVEc2M4NsdslMwAAGOLiONQHtTLY1CaJnk/Qd+XyROb1rRwN2r dioBojVro1jwPtENHmrDmqCn4FRO9SkD6NDzF5kiKg67wBV/r/WmqHR/EakC5ujcN5 AlDd3CP/7FzeVbDuCp+PzXFP0qdNHjTMUghU9c0o10LuxsrWLkBo5O7dAw3go55TUq M6hhqY3pDgyRppOwzu2CduwporTLpjmQu6Kik00u6OL1ayI1fTduMcAtT4toFHOeUq YCuumTmZR7lsA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A9DF068C06 for ; Tue, 30 Dec 2025 16:45:09 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767138308; bh=0JFwz3oCrwQvig6iMCrxhhJzJrohD4WkhoRegGJbff0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YdJR2KhXpIhkyBug4ag4iLs6nS/tbvwABI5xNmbdNu59kksqK1I8xbVYfOLHQyw1B uZGqYpGCIHcJz+MigOZkspviadd6ONZWUXwHi0w/l3P2mwSr9cQUnUXrZBRhGlCKRv MGm5X/LY+RSD9kHUt3NqvwJ5wYSjdQlc+K12fqY4owY3i6qF6sabWBMlMVZmA5EDxl mSI/8tq2EJFkHHYiu0DnI4IQtIgHzoRoTWetOqNvQk3oZ2sE97qp3smVsfmxFaWP8l suD5/m3Qkbi1DXSk0gF/uiY3Zn/WPPGFnJnvZaZEUlByUYlWlu347Xl7XetE/fwtiE xBb0EOLgo0QVA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 48D8D64E2A; Tue, 30 Dec 2025 16:45:08 -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 rWxlEzkh468W; Tue, 30 Dec 2025 16:45:08 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767138308; bh=ZNX4zRSTw+nLyuNQxYT5E+D0R4MA7YRoc9R8+SaR6Dc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VK/SD1eliAvRCXN01v8L7dOyG5LMlynXiV/3oE2+coM0QJRmuaG+wxtSWrD9pOaav jeXrGrVB28La8UEkZpVfVFoNPD2GuftVGc5QkGF01tPlKxCqG7dniwcCqqM7EeBGsj rNLXSLvspRJBhXW//cNiA8yGoQ+hnhcTGJ2Z3FEEO/PPJUMbiXFFtRzF+SHi1F10U9 pELl+FAfyJZG6egjuDiDlo/wDNS7n0hETPfVLkd0RxouNJ1m6CfjEY72pvFD0TWweG B52w0zbP7Jxcj6wGEvb+WkN3wIx/Ym/unXCGhs6KrdkScCAAL4UhKSFTNL7vWIT3OV BAC7GGoCLuahQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B137F68C0F; Tue, 30 Dec 2025 16:45:07 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 30 Dec 2025 16:41:24 -0700 Message-ID: <20251230234134.906477-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251230234134.906477-1-sjg@u-boot.org> References: <20251230234134.906477-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: YZCINMDOC5XNTPY5IV3RQOZ2YXIYMSLL X-Message-ID-Hash: YZCINMDOC5XNTPY5IV3RQOZ2YXIYMSLL 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: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 12/15] ext4l: Implement iput() to evict deleted inodes 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 Implement iput() to properly handle inode reference counting and eviction. When the reference count drops to zero and the inode has no links (i_nlink == 0), call ext4_evict_inode() to free the inode's data blocks and the inode itself. This is required for unlink operations to properly free filesystem resources. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/ext4_uboot.h | 4 ++-- fs/ext4l/stub.c | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 5c66e35662d..18ea2b1bcd4 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -491,8 +491,8 @@ int __ext4_xattr_set_credits(struct super_block *sb, struct inode *inode, /* RCU barrier - stub */ #define rcu_barrier() do { } while (0) -/* inode/dentry operations - stubs */ -#define iput(inode) do { } while (0) +/* inode/dentry operations */ +void iput(struct inode *inode); /* current task - from linux/sched.h */ #include diff --git a/fs/ext4l/stub.c b/fs/ext4l/stub.c index ce68ec28b20..2b7618df64c 100644 --- a/fs/ext4l/stub.c +++ b/fs/ext4l/stub.c @@ -587,6 +587,29 @@ struct dentry *d_make_root(struct inode *inode) return de; } +/** + * iput() - Release a reference to an inode + * @inode: Inode to release + * + * Decrements the inode reference count. When the reference count reaches + * zero and the inode has no links, the inode is evicted (freed). + */ +void iput(struct inode *inode) +{ + if (!inode) + return; + + if (atomic_dec_and_test(&inode->i_count)) { + /* Last reference - check if inode should be evicted */ + if (inode->i_nlink == 0 && inode->i_sb && + inode->i_sb->s_op && inode->i_sb->s_op->evict_inode) { + inode->i_sb->s_op->evict_inode(inode); + /* Sync dirty buffers after eviction */ + bh_cache_sync(); + } + } +} + /* percpu init rwsem */ int percpu_init_rwsem(struct percpu_rw_semaphore *sem) {