Linux filesystem development
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] Defer evicting inodes to a workqueue
@ 2025-09-24  9:09 Matthew Wilcox (Oracle)
  2025-09-24  9:09 ` [RFC PATCH 1/2] Add in_reclaim() Matthew Wilcox (Oracle)
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Matthew Wilcox (Oracle) @ 2025-09-24  9:09 UTC (permalink / raw)
  To: Alexander Viro, Christian Brauner, Jan Kara
  Cc: Matthew Wilcox (Oracle), linux-fsdevel, Dave Chinner

Evicting an inode is a complex process which may require allocating
memory, running a transaction, etc, etc.  Doing it as part of reclaim
is a bad idea and leads to hard-to-reproduce bug reports.  This pair of
patches defers it to a workqueue if we're in reclaim.

Bugs:
https://lore.kernel.org/all/CALm_T+3j+dyK02UgPiv9z0f1oj-HM63oxhsB0JF9gVAjeVfm1Q@mail.gmail.com/
https://lore.kernel.org/all/CALm_T+2cEDUJvjh6Lv+6Mg9QJxGBVAHu-CY+okQgh-emWa7-1A@mail.gmail.com/
https://lore.kernel.org/all/20250326105914.3803197-1-matt@readmodwrite.com/

I don't know if this is a good idea, to be honest.  We're kind of lying
to reclaim by pretending that we've freed N inodes when actually we've
just queued them for eviction.  On the other hand, XFS has been doing
it for years, so perhaps it's not important.

I think the real solution here is to convert the Linux VFS to use the
same inode lifecycle as IRIX, but I don't fully understand the downsides
of that approach.  One major pro of course is that XFS wouldn't have to
work around the Linux VFS any more.

I do wonder if a better approach might be:

+++ b/fs/inode.c
@@ -883,6 +883,10 @@ void evict_inodes(struct super_block *sb)
                        spin_unlock(&inode->i_lock);
                        continue;
                }
+               if (in_reclaim() && (inode->i_state & I_DIRTY_ALL)) {
+                       spin_unlock(&inode->i_lock);
+                       continue;
+               }
 
                inode->i_state |= I_FREEING;
                inode_lru_list_del(inode);

Thoughts?

Matthew Wilcox (Oracle) (2):
  Add in_reclaim()
  fs: Defer evicting inodes to a workqueue

 fs/inode.c               | 36 ++++++++++++++++++++++++++++++++++--
 include/linux/sched/mm.h | 11 +++++++++++
 mm/page_alloc.c          | 10 +++++-----
 3 files changed, 50 insertions(+), 7 deletions(-)

-- 
2.47.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2025-10-07  0:41 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-24  9:09 [RFC PATCH 0/2] Defer evicting inodes to a workqueue Matthew Wilcox (Oracle)
2025-09-24  9:09 ` [RFC PATCH 1/2] Add in_reclaim() Matthew Wilcox (Oracle)
2025-09-24 11:37   ` Jan Kara
2025-09-24  9:09 ` [RFC PATCH 2/2] fs: Defer evicting inodes to a workqueue Matthew Wilcox (Oracle)
2025-09-24  9:28   ` Kiryl Shutsemau
2025-09-24  9:31     ` Matthew Wilcox
2025-09-24 11:42       ` Jan Kara
2025-09-24 10:04     ` Matthew Wilcox
2025-09-24 11:41   ` Jan Kara
2025-09-24 11:55   ` Mateusz Guzik
2025-09-24 11:34 ` [RFC PATCH 0/2] " Jan Kara
2025-09-24 17:45   ` Joanne Koong
2025-09-25 11:15     ` Jan Kara
2025-10-07  0:41 ` Dave Chinner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox