Treat REQ_FUA and REQ_PREFLUSH as synchronous
Subsystems (2)
Jan Kara
reviewerHello,
Commit b685d3d65ac7 "block: treat REQ_FUA and REQ_PREFLUSH as synchronous" made requests with REQ_FUA and REQ_PREFLUSH to be treated as synchronous and dropped REQ_SYNC from definitions of WRITE_FUA and friends. This however introduced a bunch of bugs to filesystems (I know about ext4, btrfs, f2fs, gfs2, reiserfs regressing because of this) because they implicitely expected REQ_FUA or REQ_PREFLUSH implies a synchronous request. At the first sight they do however generic_make_request_checks() will strip REQ_FUA and REQ_PREFLUSH flags from a bio if the underlying storage does not have volatile write cache and so writes suddenly become async. I will go and fix filesystems to explicitely set REQ_SYNC if they want sync behavior as that is a good cleanup anyway but I wanted to question whether it makes sense to treat REQ_FUA and REQ_PREFLUSH ops as synchronous in op_is_sync() since callers cannot rely on this anyway... Thoughts?
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 2 lines · Jan Kara
it makes sense to treat
REQ_FUAandREQ_PREFLUSHops as synchronous inop_is_sync()since callers cannot rely on this anyway... Thoughts?
I'm fine with treating them as sync.
Jens Axboe
maintainerQuoted 5 lines · Christoph Hellwig
Quoted 2 lines · Jan Kara
it makes sense to treat
REQ_FUAandREQ_PREFLUSHops as synchronous inop_is_sync()since callers cannot rely on this anyway... Thoughts?I'm fine with treating them as sync.
Yes me too. It makes sense to do so implicitly, and it avoids having to go and add REQ_SYNC in a bunch of places. That will also be more error proof in the future.
Jan, will you send a patch for that?
Signature · 1 line
Jens Axboe
Jan Kara
reviewerQuoted 5 lines · Jens Axboe
Quoted 4 lines · Christoph Hellwig
Quoted 2 lines · Jan Kara
it makes sense to treat
REQ_FUAandREQ_PREFLUSHops as synchronous inop_is_sync()since callers cannot rely on this anyway... Thoughts?
Quoted 7 lines
Quoted 1 line
I'm fine with treating them as sync.
Yes me too. It makes sense to do so implicitly, and it avoids having to go and add
REQ_SYNCin a bunch of places. That will also be more error proof in the future.Jan, will you send a patch for that?
Hum, so I've just sent out fixes to individual filesystems to set REQ_SYNC explicitely :-|. So would you prefer to do something like:
if (op_is_flush(bio->bi_opf) &&
!test_bit(QUEUE_FLAG_WC, &q->queue_flags)) {
bio->bi_opf &= ~(REQ_PREFLUSH | REQ_FUA);
+ bio->bi_opf |= REQ_SYNC;
if (!nr_sectors) {
err = 0;
goto end_io;
}
}in generic_make_request_checks()? Or just set it unconditionally in that function if we see REQ_FUA | REQ_PREFLUSH set? Because we cannot just add REQ_SYNC into REQ_FUA and REQ_PREFLUSH definitions as it used to be with WRITE_FUA & co. definitions...
In the end I think that modifying filesystems (and drivers/md) to set REQ_SYNC was the cleanest way to go as much as it was annoying...
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 2 lines · Jan Kara
in
generic_make_request_checks()? Or just set it unconditionally in that function if we seeREQ_FUA|REQ_PREFLUSHset?
Just add REQ_FUA and REQ_PREFLUSH to the test in op_is_sync.
Jan Kara
reviewerQuoted 5 lines · Christoph Hellwig
Quoted 2 lines · Jan Kara
in
generic_make_request_checks()? Or just set it unconditionally in that function if we seeREQ_FUA|REQ_PREFLUSHset?Just add
REQ_FUAandREQ_PREFLUSHto the test inop_is_sync.
It is there. The problem happens when REQ_FUA and REQ_PREFLUSH get stripped from bio because the underlying storage doesn't have volatile cache, the bio suddently becomes treated as async which regresses performance.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR