Skip to content

Commit

Permalink
JFS: Take logsync lock before testing mp->lsn
Browse files Browse the repository at this point in the history
This fixes a race where lsn could be cleared before taking the lock

Signed-off-by: Dave Kleikamp <[email protected]>
  • Loading branch information
Dave Kleikamp committed Mar 8, 2006
1 parent 5b3030e commit be0bf7d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
7 changes: 2 additions & 5 deletions fs/jfs/jfs_dmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,10 +532,10 @@ dbUpdatePMap(struct inode *ipbmap,

lastlblkno = lblkno;

LOGSYNC_LOCK(log, flags);
if (mp->lsn != 0) {
/* inherit older/smaller lsn */
logdiff(diffp, mp->lsn, log);
LOGSYNC_LOCK(log, flags);
if (difft < diffp) {
mp->lsn = lsn;

Expand All @@ -548,20 +548,17 @@ dbUpdatePMap(struct inode *ipbmap,
logdiff(diffp, mp->clsn, log);
if (difft > diffp)
mp->clsn = tblk->clsn;
LOGSYNC_UNLOCK(log, flags);
} else {
mp->log = log;
mp->lsn = lsn;

/* insert bp after tblock in logsync list */
LOGSYNC_LOCK(log, flags);

log->count++;
list_add(&mp->synclist, &tblk->synclist);

mp->clsn = tblk->clsn;
LOGSYNC_UNLOCK(log, flags);
}
LOGSYNC_UNLOCK(log, flags);
}

/* write the last buffer. */
Expand Down
6 changes: 2 additions & 4 deletions fs/jfs/jfs_imap.c
Original file line number Diff line number Diff line change
Expand Up @@ -2844,11 +2844,11 @@ diUpdatePMap(struct inode *ipimap,
*/
lsn = tblk->lsn;
log = JFS_SBI(tblk->sb)->log;
LOGSYNC_LOCK(log, flags);
if (mp->lsn != 0) {
/* inherit older/smaller lsn */
logdiff(difft, lsn, log);
logdiff(diffp, mp->lsn, log);
LOGSYNC_LOCK(log, flags);
if (difft < diffp) {
mp->lsn = lsn;
/* move mp after tblock in logsync list */
Expand All @@ -2860,17 +2860,15 @@ diUpdatePMap(struct inode *ipimap,
logdiff(diffp, mp->clsn, log);
if (difft > diffp)
mp->clsn = tblk->clsn;
LOGSYNC_UNLOCK(log, flags);
} else {
mp->log = log;
mp->lsn = lsn;
/* insert mp after tblock in logsync list */
LOGSYNC_LOCK(log, flags);
log->count++;
list_add(&mp->synclist, &tblk->synclist);
mp->clsn = tblk->clsn;
LOGSYNC_UNLOCK(log, flags);
}
LOGSYNC_UNLOCK(log, flags);
write_metapage(mp);
return (0);
}
Expand Down

0 comments on commit be0bf7d

Please sign in to comment.