public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] umount versus iprune
@ 2003-02-20 13:39 Hugh Dickins
  2003-02-20 18:40 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Hugh Dickins @ 2003-02-20 13:39 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

When prune_icache coincides with unmounting, invalidate_inodes notices
the inode it's working on as busy but doesn't wait: Self-destruct in 5
seconds message, and later iput oopses on freed super_block.

Neither end is a fast path, so patch below just adds iprune_sem for
exclusion: if you've got a neater solution, great - I shied away from
games with i_state, and extending use of shrinker_sem felt like abuse.

Hugh

--- 2.5.62/fs/inode.c	Mon Feb 10 20:12:50 2003
+++ linux/fs/inode.c	Thu Feb 20 13:01:58 2003
@@ -81,6 +81,11 @@
 spinlock_t inode_lock = SPIN_LOCK_UNLOCKED;
 
 /*
+ * A semaphore to delay invalidate_inodes while prune_icache is busy.
+ */
+static DECLARE_MUTEX(iprune_sem);
+
+/*
  * Statistics gathering..
  */
 struct inodes_stat_t inodes_stat;
@@ -320,12 +325,14 @@
 	int busy;
 	LIST_HEAD(throw_away);
 
+	down(&iprune_sem);
 	spin_lock(&inode_lock);
 	busy = invalidate_list(&inode_in_use, sb, &throw_away);
 	busy |= invalidate_list(&inode_unused, sb, &throw_away);
 	busy |= invalidate_list(&sb->s_dirty, sb, &throw_away);
 	busy |= invalidate_list(&sb->s_io, sb, &throw_away);
 	spin_unlock(&inode_lock);
+	up(&iprune_sem);
 
 	dispose_list(&throw_away);
 
@@ -395,6 +402,7 @@
 	int nr_scanned;
 	unsigned long reap = 0;
 
+	down(&iprune_sem);
 	spin_lock(&inode_lock);
 	for (nr_scanned = 0; nr_scanned < nr_to_scan; nr_scanned++) {
 		struct inode *inode;
@@ -429,6 +437,7 @@
 	}
 	inodes_stat.nr_unused -= nr_pruned;
 	spin_unlock(&inode_lock);
+	up(&iprune_sem);
 	dispose_list(&freeable);
 	if (current_is_kswapd)
 		mod_page_state(kswapd_inodesteal, reap);


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

end of thread, other threads:[~2003-02-20 20:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-20 13:39 [PATCH] umount versus iprune Hugh Dickins
2003-02-20 18:40 ` Andrew Morton
2003-02-20 19:54   ` Hugh Dickins
2003-02-20 20:16     ` Hugh Dickins

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