[PATCH] Updated field is not always written to disk during truncate (3 of 6)

[email protected] Wed, 7 Jul 2004 16:41:35 -0500
Newsgroups gmane.comp.file-systems.jfs.patches
Message-ID <[email protected]>
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2004/07/06 08:31:31-05:00 [email protected] 
#   JFS: Updated field isn't always written to disk during truncate
#   
#   There is a possibility that a change to header.next is not logged
#   or written to disk if it is the only change to an xtree leaf page.
#   
#   Signed-off-by: Dave Kleikamp <[email protected]>
# 
diff -Nru a/fs/jfs/jfs_xtree.c b/fs/jfs/jfs_xtree.c
--- a/fs/jfs/jfs_xtree.c	2004-07-07 16:37:53 -05:00
+++ b/fs/jfs/jfs_xtree.c	2004-07-07 16:37:53 -05:00
@@ -3495,7 +3495,17 @@
 	 * a page that was formerly to the right, let's make sure that the
 	 * next pointer is zero.
 	 */
-	p->header.next = 0;
+	if (p->header.next) {
+		if (log)
+			/*
+			 * Make sure this change to the header is logged.
+			 * If we really truncate this leaf, the flag
+			 * will be changed to tlckTRUNCATE
+			 */
+			tlck = txLock(tid, ip, mp, tlckXTREE|tlckGROW);
+		BT_MARK_DIRTY(mp, ip);
+		p->header.next = 0;
+	}
 
 	freed = 0;