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

Configure Feed

Select the types of activity you want to include in your feed.

block/rnbd-proto: Handle PREFLUSH flag properly for IOs

In RNBD client, for a WRITE request of size 0, with only the REQ_PREFLUSH
bit set, while converting from bio_opf to rnbd_opf, we do REQ_OP_WRITE to
RNBD_OP_WRITE, and then check if the rq is flush through function
op_is_flush. That function checks both REQ_PREFLUSH and REQ_FUA flag, and
if any of them is set, the RNBD_F_FUA is set.
On the RNBD server side, while converting the RNBD flags to req flags, if
the RNBD_F_FUA flag is set, we just set the REQ_FUA flag. This means we
have lost the PREFLUSH flag, and added the REQ_FUA flag in its place.

This commits adds a new RNBD_F_PREFLUSH flag, and also adds separate
handling for REQ_PREFLUSH flag. On the server side, if the RNBD_F_PREFLUSH
is present, the REQ_PREFLUSH is added to the bio.

Since it is a change in the wire protocol, bump the minor version of
protocol.
The change is backwards compatible, and does not change the functionality
if either the client or the server is running older/newer versions.
If the client side is running the older version, both REQ_PREFLUSH and
REQ_FUA is converted to RNBD_F_FUA. The server running newer one would
still add only the REQ_FUA flag which is what happens when both client and
server is running the older version.
If the client side is running the newer version, just like before a
RNBD_F_FUA is added, but now a RNBD_F_PREFLUSH is also added to the
rnbd_opf. In case the server is running the older version the
RNBD_F_PREFLUSH is ignored, and only the RNBD_F_FUA is processed.

Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com>
Reviewed-by: Jack Wang <jinpu.wang@ionos.com>
Reviewed-by: Florian-Ewald Mueller <florian-ewald.mueller@ionos.com>
Signed-off-by: Grzegorz Prajsner <grzegorz.prajsner@ionos.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Md Haris Iqbal and committed by
Jens Axboe
483cbec3 9e371032

+9 -1
+9 -1
drivers/block/rnbd/rnbd-proto.h
··· 18 18 #include <rdma/ib.h> 19 19 20 20 #define RNBD_PROTO_VER_MAJOR 2 21 - #define RNBD_PROTO_VER_MINOR 0 21 + #define RNBD_PROTO_VER_MINOR 1 22 22 23 23 /* The default port number the RTRS server is listening on. */ 24 24 #define RTRS_PORT 1234 ··· 197 197 * 198 198 * @RNBD_F_SYNC: request is sync (sync write or read) 199 199 * @RNBD_F_FUA: forced unit access 200 + * @RNBD_F_PREFLUSH: request for cache flush 200 201 */ 201 202 enum rnbd_io_flags { 202 203 ··· 212 211 /* Flags */ 213 212 RNBD_F_SYNC = 1<<(RNBD_OP_BITS + 0), 214 213 RNBD_F_FUA = 1<<(RNBD_OP_BITS + 1), 214 + RNBD_F_PREFLUSH = 1<<(RNBD_OP_BITS + 2) 215 215 }; 216 216 217 217 static inline u32 rnbd_op(u32 flags) ··· 260 258 if (rnbd_opf & RNBD_F_FUA) 261 259 bio_opf |= REQ_FUA; 262 260 261 + if (rnbd_opf & RNBD_F_PREFLUSH) 262 + bio_opf |= REQ_PREFLUSH; 263 + 263 264 return bio_opf; 264 265 } 265 266 ··· 301 296 302 297 if (op_is_flush(rq->cmd_flags)) 303 298 rnbd_opf |= RNBD_F_FUA; 299 + 300 + if (rq->cmd_flags & REQ_PREFLUSH) 301 + rnbd_opf |= RNBD_F_PREFLUSH; 304 302 305 303 return rnbd_opf; 306 304 }