public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch 12/16] fix race between writeback and unlink
@ 2002-06-01  8:43 Andrew Morton
  2002-06-01 16:42 ` Linus Torvalds
  0 siblings, 1 reply; 27+ messages in thread
From: Andrew Morton @ 2002-06-01  8:43 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: lkml



Fixes a race between unlink and writeback: on the sys_sync() and
pdflush paths the caller does not have a reference against the inode.

So run __iget prior to dropping inode_lock.

Oleg Drokin reported this and seems to believe that it fixes the
crashes he was observing.  But I was never able to reproduce them..


=====================================

--- 2.5.19/fs/fs-writeback.c~sync-race	Sat Jun  1 01:18:12 2002
+++ 2.5.19-akpm/fs/fs-writeback.c	Sat Jun  1 01:18:12 2002
@@ -245,17 +245,19 @@ static void sync_sb_inodes(struct super_
 		if ((sync_mode == WB_SYNC_LAST) && (head->prev == head))
 			really_sync = 1;
 
+		BUG_ON(inode->i_state & I_FREEING);
+		__iget(inode);
 		__writeback_single_inode(inode, really_sync, nr_to_write);
-
 		if (sync_mode == WB_SYNC_HOLD) {
 			mapping->dirtied_when = jiffies;
 			list_del(&inode->i_list);
 			list_add(&inode->i_list, &inode->i_sb->s_dirty);
 		}
-
 		if (current_is_pdflush())
 			writeback_release(bdi);
-
+		spin_unlock(&inode_lock);
+		iput(inode);
+		spin_lock(&inode_lock);
 		if (nr_to_write && *nr_to_write <= 0)
 			break;
 	}


-

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

end of thread, other threads:[~2002-07-07 20:36 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-01  8:43 [patch 12/16] fix race between writeback and unlink Andrew Morton
2002-06-01 16:42 ` Linus Torvalds
2002-06-01 19:19   ` Andrew Morton
2002-06-01 20:04     ` William Lee Irwin III
2002-06-01 22:25       ` Andrew Morton
2002-06-03  4:27     ` [RFC] iput() cleanup (was Re: [patch 12/16] fix race between writeback and unlink) Linus Torvalds
2002-06-03 16:26       ` Andreas Dilger
2002-06-03 16:47         ` Linus Torvalds
2002-06-03 19:09       ` Chris Mason
2002-06-03 19:34         ` Linus Torvalds
2002-06-03 19:49           ` Chris Mason
2002-06-03 19:55             ` Linus Torvalds
2002-06-03 22:10     ` [patch 12/16] fix race between writeback and unlink Chris Mason
2002-06-03 22:19       ` Linus Torvalds
2002-06-03 22:30         ` Andrew Morton
2002-06-04 18:47           ` Linus Torvalds
2002-06-04 20:15             ` Andrew Morton
2002-06-04 20:23               ` Linus Torvalds
2002-06-04 20:40                 ` Andrew Morton
2002-06-04 21:37                   ` Linus Torvalds
2002-06-04 22:04                     ` Benjamin LaHaise
2002-06-04 22:08                     ` Andrew Morton
2002-07-07 20:38                     ` Riley Williams
2002-06-04 22:05                 ` Craig Milo Rogers
2002-06-04 22:08                   ` Linus Torvalds
2002-06-03 22:36         ` Chris Mason
2002-06-03 22:47           ` Andrew Morton

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