Skip to content

Commit c9ebc4b

Browse files
committed
gfs2: allow journal replay to hold sd_log_flush_lock
Before this patch, journal replays could stomp on log flushes and each other because both log flushes and journal replays used the same sd_log_bio. Function gfs2_log_flush prevents other log flushes from interfering by taking the sd_log_flush_lock rwsem during the flush. However, it does not protect against journal replays. This patch allows the journal replay to take the same sd_log_flush_lock rwsem so use of the sd_log_bio is not stomped. Signed-off-by: Bob Peterson <[email protected]>
1 parent 019dd66 commit c9ebc4b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

fs/gfs2/recovery.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,10 @@ void gfs2_recover_func(struct work_struct *work)
398398
fs_info(sdp, "jid=%u: Replaying journal...0x%x to 0x%x\n",
399399
jd->jd_jid, head.lh_tail, head.lh_blkno);
400400

401+
/* We take the sd_log_flush_lock here primarily to prevent log
402+
* flushes and simultaneous journal replays from stomping on
403+
* each other wrt sd_log_bio. */
404+
down_write(&sdp->sd_log_flush_lock);
401405
for (pass = 0; pass < 2; pass++) {
402406
lops_before_scan(jd, &head, pass);
403407
error = foreach_descriptor(jd, head.lh_tail,
@@ -408,6 +412,7 @@ void gfs2_recover_func(struct work_struct *work)
408412
}
409413

410414
clean_journal(jd, &head);
415+
up_write(&sdp->sd_log_flush_lock);
411416

412417
gfs2_glock_dq_uninit(&thaw_gh);
413418
t_rep = ktime_get();

0 commit comments

Comments
 (0)