[PATCH] Serialization fix (7 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/08 08:14:37-06:00 [email protected] 
#   JFS: Serialization fix
#   
#   Fix a serialization problem when metapages were being added to the
#   logsynclist while the page was undergoing i/o
#   
#   Signed-off-by: Dave Kleikamp <[email protected]>
# 
diff -Nru a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
--- a/fs/jfs/jfs_dmap.c	2005-03-31 14:18:39 -06:00
+++ b/fs/jfs/jfs_dmap.c	2005-03-31 14:18:39 -06:00
@@ -505,6 +505,7 @@
 					   0);
 			if (mp == NULL)
 				return -EIO;
+			metapage_wait_for_io(mp);
 		}
 		dp = (struct dmap *) mp->data;
 
diff -Nru a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
--- a/fs/jfs/jfs_imap.c	2005-03-31 14:18:39 -06:00
+++ b/fs/jfs/jfs_imap.c	2005-03-31 14:18:39 -06:00
@@ -2808,6 +2808,7 @@
 	IREAD_UNLOCK(ipimap);
 	if (rc)
 		return (rc);
+	metapage_wait_for_io(mp);
 	iagp = (struct iag *) mp->data;
 	/* get the inode number and extent number of the inode within
 	 * the iag and the inode number within the extent.
diff -Nru a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
--- a/fs/jfs/jfs_metapage.c	2005-03-31 14:18:39 -06:00
+++ b/fs/jfs/jfs_metapage.c	2005-03-31 14:18:39 -06:00
@@ -324,12 +324,11 @@
 
 	for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) {
 		mp = page_to_mp(page, offset);
-		if (!mp)
-			continue;
-		if (!test_and_clear_bit(META_io, &mp->flag))
-			continue;
-		if (mp->lsn)
-			remove_from_logsync(mp);
+		if (mp && test_bit(META_io, &mp->flag)) {
+			if (mp->lsn)
+				remove_from_logsync(mp);
+			clear_bit(META_io, &mp->flag);
+		}
 		/*
 		 * I'd like to call drop_metapage here, but I don't think it's
 		 * safe unless I have the page locked
diff -Nru a/fs/jfs/jfs_metapage.h b/fs/jfs/jfs_metapage.h
--- a/fs/jfs/jfs_metapage.h	2005-03-31 14:18:39 -06:00
+++ b/fs/jfs/jfs_metapage.h	2005-03-31 14:18:39 -06:00
@@ -112,6 +112,16 @@
 }
 
 /*
+ * This serializes access to mp->lsn when metapages are added to logsynclist
+ * without setting nohomeok.  i.e. updating imap & dmap
+ */
+static inline void metapage_wait_for_io(struct metapage *mp)
+{
+	if (test_bit(META_io, &mp->flag))
+		wait_on_page_writeback(mp->page);
+}
+
+/*
  * This is called when already holding the metapage
  */
 static inline void _metapage_homeok(struct metapage *mp)


-------------------------------------------------------
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