[PATCH 1/1] JFS: don't dereference tlck->ip from txUpdateMap

[email protected] (Dave Kleikamp) Tue, 20 Sep 2005 15:43:31 -0500 (CDT)
Newsgroups gmane.comp.file-systems.jfs.patches
Message-ID <[email protected]>
JFS: don't dereference tlck->ip from txUpdateMap

The inode pointer may no longer be valid

Signed-off-by: Dave Kleikamp <[email protected]>

---
commit 438282d85de2c8f8c5183fdf55140e51a0b18670
tree ee90f834ebbf60d45b11d48c4a3fac82a1b62752
parent 6cb1269b9607649b5edf1c4e7818e0cf34a9db71
author Dave Kleikamp <[email protected]> Tue, 20 Sep 2005 14:58:11 -0500
committer Dave Kleikamp <[email protected]> Tue, 20 Sep 2005 14:58:11 -0500

 fs/jfs/jfs_txnmgr.c |    9 ++++++++-
 fs/jfs/jfs_txnmgr.h |    1 +
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c
--- a/fs/jfs/jfs_txnmgr.c
+++ b/fs/jfs/jfs_txnmgr.c
@@ -725,6 +725,9 @@ struct tlock *txLock(tid_t tid, struct i
 	else
 		tlck->flag = tlckINODELOCK;
 
+	if (S_ISDIR(ip->i_mode))
+		tlck->flag |= tlckDIRECTORY;
+
 	tlck->type = 0;
 
 	/* bind the tlock and the page */
@@ -1009,6 +1012,8 @@ struct tlock *txMaplock(tid_t tid, struc
 
 	/* bind the tlock and the object */
 	tlck->flag = tlckINODELOCK;
+	if (S_ISDIR(ip->i_mode))
+		tlck->flag |= tlckDIRECTORY;
 	tlck->ip = ip;
 	tlck->mp = NULL;
 
@@ -1077,6 +1082,8 @@ struct linelock *txLinelock(struct linel
 	linelock->flag = tlckLINELOCK;
 	linelock->maxcnt = TLOCKLONG;
 	linelock->index = 0;
+	if (tlck->flag & tlckDIRECTORY)
+		linelock->flag |= tlckDIRECTORY;
 
 	/* append linelock after tlock */
 	linelock->next = tlock->next;
@@ -2358,7 +2365,7 @@ static void txUpdateMap(struct tblock * 
 			 */
 			else {	/* (maplock->flag & mlckFREE) */
 
-				if (S_ISDIR(tlck->ip->i_mode))
+				if (tlck->flag & tlckDIRECTORY)
 					txFreeMap(ipimap, maplock,
 						  tblk, COMMIT_PWMAP);
 				else
diff --git a/fs/jfs/jfs_txnmgr.h b/fs/jfs/jfs_txnmgr.h
--- a/fs/jfs/jfs_txnmgr.h
+++ b/fs/jfs/jfs_txnmgr.h
@@ -122,6 +122,7 @@ extern struct tlock *TxLock;	/* transact
 #define tlckLOG			0x0800
 /* updateMap state */
 #define	tlckUPDATEMAP		0x0080
+#define	tlckDIRECTORY		0x0040
 /* freeLock state */
 #define tlckFREELOCK		0x0008
 #define tlckWRITEPAGE		0x0004


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php