diff options
author | Dave Kleikamp <shaggy@austin.ibm.com> | 2006-03-14 14:44:00 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-14 17:00:48 -0500 |
commit | a488edc914aa1d766a4e2c982b5ae03d5657ec1b (patch) | |
tree | f31e123b8d979d5a01260cbfa12ba2052254df85 | |
parent | 0f511ea70600efb1e06d7b55e1c51a83aff8713c (diff) |
[PATCH] JFS: Take logsync lock before testing mp->lsn
This fixes a race where lsn could be cleared before taking the lock
Signed-off-by: Dave Kleikamp <shaggy@austin.ibm.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | fs/jfs/jfs_dmap.c | 7 | ||||
-rw-r--r-- | fs/jfs/jfs_imap.c | 6 |
2 files changed, 4 insertions, 9 deletions
diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c index 2967b7393415..79b5404db100 100644 --- a/fs/jfs/jfs_dmap.c +++ b/fs/jfs/jfs_dmap.c | |||
@@ -532,10 +532,10 @@ dbUpdatePMap(struct inode *ipbmap, | |||
532 | 532 | ||
533 | lastlblkno = lblkno; | 533 | lastlblkno = lblkno; |
534 | 534 | ||
535 | LOGSYNC_LOCK(log, flags); | ||
535 | if (mp->lsn != 0) { | 536 | if (mp->lsn != 0) { |
536 | /* inherit older/smaller lsn */ | 537 | /* inherit older/smaller lsn */ |
537 | logdiff(diffp, mp->lsn, log); | 538 | logdiff(diffp, mp->lsn, log); |
538 | LOGSYNC_LOCK(log, flags); | ||
539 | if (difft < diffp) { | 539 | if (difft < diffp) { |
540 | mp->lsn = lsn; | 540 | mp->lsn = lsn; |
541 | 541 | ||
@@ -548,20 +548,17 @@ dbUpdatePMap(struct inode *ipbmap, | |||
548 | logdiff(diffp, mp->clsn, log); | 548 | logdiff(diffp, mp->clsn, log); |
549 | if (difft > diffp) | 549 | if (difft > diffp) |
550 | mp->clsn = tblk->clsn; | 550 | mp->clsn = tblk->clsn; |
551 | LOGSYNC_UNLOCK(log, flags); | ||
552 | } else { | 551 | } else { |
553 | mp->log = log; | 552 | mp->log = log; |
554 | mp->lsn = lsn; | 553 | mp->lsn = lsn; |
555 | 554 | ||
556 | /* insert bp after tblock in logsync list */ | 555 | /* insert bp after tblock in logsync list */ |
557 | LOGSYNC_LOCK(log, flags); | ||
558 | |||
559 | log->count++; | 556 | log->count++; |
560 | list_add(&mp->synclist, &tblk->synclist); | 557 | list_add(&mp->synclist, &tblk->synclist); |
561 | 558 | ||
562 | mp->clsn = tblk->clsn; | 559 | mp->clsn = tblk->clsn; |
563 | LOGSYNC_UNLOCK(log, flags); | ||
564 | } | 560 | } |
561 | LOGSYNC_UNLOCK(log, flags); | ||
565 | } | 562 | } |
566 | 563 | ||
567 | /* write the last buffer. */ | 564 | /* write the last buffer. */ |
diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c index 31b4aa13dd4b..4efa0d0eec39 100644 --- a/fs/jfs/jfs_imap.c +++ b/fs/jfs/jfs_imap.c | |||
@@ -2844,11 +2844,11 @@ diUpdatePMap(struct inode *ipimap, | |||
2844 | */ | 2844 | */ |
2845 | lsn = tblk->lsn; | 2845 | lsn = tblk->lsn; |
2846 | log = JFS_SBI(tblk->sb)->log; | 2846 | log = JFS_SBI(tblk->sb)->log; |
2847 | LOGSYNC_LOCK(log, flags); | ||
2847 | if (mp->lsn != 0) { | 2848 | if (mp->lsn != 0) { |
2848 | /* inherit older/smaller lsn */ | 2849 | /* inherit older/smaller lsn */ |
2849 | logdiff(difft, lsn, log); | 2850 | logdiff(difft, lsn, log); |
2850 | logdiff(diffp, mp->lsn, log); | 2851 | logdiff(diffp, mp->lsn, log); |
2851 | LOGSYNC_LOCK(log, flags); | ||
2852 | if (difft < diffp) { | 2852 | if (difft < diffp) { |
2853 | mp->lsn = lsn; | 2853 | mp->lsn = lsn; |
2854 | /* move mp after tblock in logsync list */ | 2854 | /* move mp after tblock in logsync list */ |
@@ -2860,17 +2860,15 @@ diUpdatePMap(struct inode *ipimap, | |||
2860 | logdiff(diffp, mp->clsn, log); | 2860 | logdiff(diffp, mp->clsn, log); |
2861 | if (difft > diffp) | 2861 | if (difft > diffp) |
2862 | mp->clsn = tblk->clsn; | 2862 | mp->clsn = tblk->clsn; |
2863 | LOGSYNC_UNLOCK(log, flags); | ||
2864 | } else { | 2863 | } else { |
2865 | mp->log = log; | 2864 | mp->log = log; |
2866 | mp->lsn = lsn; | 2865 | mp->lsn = lsn; |
2867 | /* insert mp after tblock in logsync list */ | 2866 | /* insert mp after tblock in logsync list */ |
2868 | LOGSYNC_LOCK(log, flags); | ||
2869 | log->count++; | 2867 | log->count++; |
2870 | list_add(&mp->synclist, &tblk->synclist); | 2868 | list_add(&mp->synclist, &tblk->synclist); |
2871 | mp->clsn = tblk->clsn; | 2869 | mp->clsn = tblk->clsn; |
2872 | LOGSYNC_UNLOCK(log, flags); | ||
2873 | } | 2870 | } |
2871 | LOGSYNC_UNLOCK(log, flags); | ||
2874 | write_metapage(mp); | 2872 | write_metapage(mp); |
2875 | return (0); | 2873 | return (0); |
2876 | } | 2874 | } |