Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

block: treat REQ_FUA and REQ_PREFLUSH as synchronous

Instead of requiring everyone to specify the REQ_SYNC flag aѕ well.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>

authored by

Christoph Hellwig and committed by
Jens Axboe
b685d3d6 6f6b2917

+10 -4
+7 -1
include/linux/blk_types.h
··· 216 216 return (op & 1); 217 217 } 218 218 219 + /* 220 + * Reads are always treated as synchronous, as are requests with the FUA or 221 + * PREFLUSH flag. Other operations may be marked as synchronous using the 222 + * REQ_SYNC flag. 223 + */ 219 224 static inline bool op_is_sync(unsigned int op) 220 225 { 221 - return (op & REQ_OP_MASK) == REQ_OP_READ || (op & REQ_SYNC); 226 + return (op & REQ_OP_MASK) == REQ_OP_READ || 227 + (op & (REQ_SYNC | REQ_FUA | REQ_PREFLUSH)); 222 228 } 223 229 224 230 typedef unsigned int blk_qc_t;
+3 -3
include/linux/fs.h
··· 199 199 #define READ_SYNC 0 200 200 #define WRITE_SYNC (REQ_SYNC | REQ_NOIDLE) 201 201 #define WRITE_ODIRECT REQ_SYNC 202 - #define WRITE_FLUSH (REQ_SYNC | REQ_NOIDLE | REQ_PREFLUSH) 203 - #define WRITE_FUA (REQ_SYNC | REQ_NOIDLE | REQ_FUA) 204 - #define WRITE_FLUSH_FUA (REQ_SYNC | REQ_NOIDLE | REQ_PREFLUSH | REQ_FUA) 202 + #define WRITE_FLUSH (REQ_NOIDLE | REQ_PREFLUSH) 203 + #define WRITE_FUA (REQ_NOIDLE | REQ_FUA) 204 + #define WRITE_FLUSH_FUA (REQ_NOIDLE | REQ_PREFLUSH | REQ_FUA) 205 205 206 206 /* 207 207 * Attribute flags. These should be or-ed together to figure out what