[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1e6c8bb039a6f1e76347b3214be78326b403c57d.1755806649.git.josef@toxicpanda.com>
Date: Thu, 21 Aug 2025 16:18:19 -0400
From: Josef Bacik <josef@...icpanda.com>
To: linux-fsdevel@...r.kernel.org,
linux-btrfs@...r.kernel.org,
kernel-team@...com,
linux-ext4@...r.kernel.org,
linux-xfs@...r.kernel.org,
brauner@...nel.org,
viro@...IV.linux.org.uk
Subject: [PATCH 08/50] fs: hold an i_obj_count reference while on the LRU list
While on the LRU list we need to make sure the object itself does not
disappear, so hold an i_obj_count reference.
This is a little wonky currently as we're dropping the reference before
we call evict(), because currently we drop the last reference right
before we free the inode. This will be fixed in a future patch when the
freeing of the inode is moved under the control of the i_obj_count
reference.
Signed-off-by: Josef Bacik <josef@...icpanda.com>
---
fs/inode.c | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/fs/inode.c b/fs/inode.c
index 1ff46d9417de..7e506050a0bc 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -542,10 +542,12 @@ static void __inode_add_lru(struct inode *inode, bool rotate)
if (!mapping_shrinkable(&inode->i_data))
return;
- if (list_lru_add_obj(&inode->i_sb->s_inode_lru, &inode->i_lru))
+ if (list_lru_add_obj(&inode->i_sb->s_inode_lru, &inode->i_lru)) {
+ iobj_get(inode);
this_cpu_inc(nr_unused);
- else if (rotate)
+ } else if (rotate) {
inode->i_state |= I_REFERENCED;
+ }
}
struct wait_queue_head *inode_bit_waitqueue(struct wait_bit_queue_entry *wqe,
@@ -571,8 +573,10 @@ void inode_add_lru(struct inode *inode)
static void inode_lru_list_del(struct inode *inode)
{
- if (list_lru_del_obj(&inode->i_sb->s_inode_lru, &inode->i_lru))
+ if (list_lru_del_obj(&inode->i_sb->s_inode_lru, &inode->i_lru)) {
+ iobj_put(inode);
this_cpu_dec(nr_unused);
+ }
}
static void inode_pin_lru_isolating(struct inode *inode)
@@ -861,6 +865,15 @@ static void dispose_list(struct list_head *head)
inode = list_first_entry(head, struct inode, i_lru);
list_del_init(&inode->i_lru);
+ /*
+ * This is going right here for now only because we are
+ * currently not using the i_obj_count reference for anything,
+ * and it needs to hit 0 when we call evict().
+ *
+ * This will be moved when we change the lifetime rules in a
+ * future patch.
+ */
+ iobj_put(inode);
evict(inode);
cond_resched();
}
@@ -897,6 +910,7 @@ void evict_inodes(struct super_block *sb)
}
inode->i_state |= I_FREEING;
+ iobj_get(inode);
inode_lru_list_del(inode);
spin_unlock(&inode->i_lock);
list_add(&inode->i_lru, &dispose);
--
2.49.0
Powered by blists - more mailing lists