Skip to content

Commit 254db57

Browse files
committed
GFS2: Support for I/O barriers
This patch adds barrier support to GFS2. There is not a lot of change really... we just add the barrier flag when we write journal header blocks. If the underlying device refuses to support them, we fall back to the previous way of doing things (wait for the I/O and hope) since there is nothing else we can do. There is no user configuration, barriers will always be on unless the device refuses to support them. This seems a reasonable solution to me since this is a correctness issue. Signed-off-by: Steven Whitehouse <[email protected]>
1 parent 6d80c39 commit 254db57

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

fs/gfs2/incore.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ enum {
432432
SDF_JOURNAL_CHECKED = 0,
433433
SDF_JOURNAL_LIVE = 1,
434434
SDF_SHUTDOWN = 2,
435+
SDF_NOBARRIERS = 3,
435436
};
436437

437438
#define GFS2_FSNAME_LEN 256

fs/gfs2/log.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/delay.h>
1919
#include <linux/kthread.h>
2020
#include <linux/freezer.h>
21+
#include <linux/bio.h>
2122

2223
#include "gfs2.h"
2324
#include "incore.h"
@@ -584,7 +585,6 @@ static void log_write_header(struct gfs2_sbd *sdp, u32 flags, int pull)
584585
memset(bh->b_data, 0, bh->b_size);
585586
set_buffer_uptodate(bh);
586587
clear_buffer_dirty(bh);
587-
unlock_buffer(bh);
588588

589589
gfs2_ail1_empty(sdp, 0);
590590
tail = current_tail(sdp);
@@ -601,8 +601,23 @@ static void log_write_header(struct gfs2_sbd *sdp, u32 flags, int pull)
601601
hash = gfs2_disk_hash(bh->b_data, sizeof(struct gfs2_log_header));
602602
lh->lh_hash = cpu_to_be32(hash);
603603

604-
set_buffer_dirty(bh);
605-
if (sync_dirty_buffer(bh))
604+
bh->b_end_io = end_buffer_write_sync;
605+
if (test_bit(SDF_NOBARRIERS, &sdp->sd_flags))
606+
goto skip_barrier;
607+
get_bh(bh);
608+
submit_bh(WRITE_BARRIER | (1 << BIO_RW_META), bh);
609+
wait_on_buffer(bh);
610+
if (buffer_eopnotsupp(bh)) {
611+
clear_buffer_eopnotsupp(bh);
612+
set_buffer_uptodate(bh);
613+
set_bit(SDF_NOBARRIERS, &sdp->sd_flags);
614+
lock_buffer(bh);
615+
skip_barrier:
616+
get_bh(bh);
617+
submit_bh(WRITE_SYNC | (1 << BIO_RW_META), bh);
618+
wait_on_buffer(bh);
619+
}
620+
if (!buffer_uptodate(bh))
606621
gfs2_io_error_bh(sdp, bh);
607622
brelse(bh);
608623

0 commit comments

Comments
 (0)