[PATCH] fix race (10 of 12)

[email protected] (Dave Kleikamp) Thu, 31 Mar 2005 14:50:05 -0600 (CST)
Newsgroups gmane.comp.file-systems.jfs.patches
Message-ID <[email protected]>
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2005/03/29 15:42:14-06:00 [email protected] 
#   JFS: fix race
#   
#   recheck mp->log and mp->lsn in remove_from_logsync() in case of a race
#   
#   Signed-off-by: Dave Kleikamp <[email protected]>
# 
diff -Nru a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
--- a/fs/jfs/jfs_metapage.c	2005-03-31 14:19:02 -06:00
+++ b/fs/jfs/jfs_metapage.c	2005-03-31 14:19:02 -06:00
@@ -307,13 +307,21 @@
 {
 	struct jfs_log *log = mp->log;
 	unsigned long flags;
+/*
+ * This can race.  Recheck that log hasn't been set to null, and after
+ * acquiring logsync lock, recheck lsn
+ */
+	if (!log)
+		return;
 
 	LOGSYNC_LOCK(log, flags);
-	mp->log = NULL;
-	mp->lsn = 0;
-	mp->clsn = 0;
-	log->count--;
-	list_del(&mp->synclist);
+	if (mp->lsn) {
+		mp->log = NULL;
+		mp->lsn = 0;
+		mp->clsn = 0;
+		log->count--;
+		list_del(&mp->synclist);
+	}
 	LOGSYNC_UNLOCK(log, flags);
 }
 


-------------------------------------------------------
This SF.net email is sponsored by Demarc:
A global provider of Threat Management Solutions.
Download our HomeAdmin security software for free today!
http://www.demarc.com/info/Sentarus/hamr30