Skip to content

Commit 28a8f0d

Browse files
Mike Christieaxboe
authored andcommitted
block, drivers, fs: rename REQ_FLUSH to REQ_PREFLUSH
To avoid confusion between REQ_OP_FLUSH, which is handled by request_fn drivers, and upper layers requesting the block layer perform a flush sequence along with possibly a WRITE, this patch renames REQ_FLUSH to REQ_PREFLUSH. Signed-off-by: Mike Christie <mchristi@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Jens Axboe <axboe@fb.com>
1 parent a418090 commit 28a8f0d

39 files changed

+102
-98
lines changed

Documentation/block/writeback_cache_control.txt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ a forced cache flush, and the Force Unit Access (FUA) flag for requests.
2020
Explicit cache flushes
2121
----------------------
2222

23-
The REQ_FLUSH flag can be OR ed into the r/w flags of a bio submitted from
23+
The REQ_PREFLUSH flag can be OR ed into the r/w flags of a bio submitted from
2424
the filesystem and will make sure the volatile cache of the storage device
2525
has been flushed before the actual I/O operation is started. This explicitly
2626
guarantees that previously completed write requests are on non-volatile
27-
storage before the flagged bio starts. In addition the REQ_FLUSH flag can be
27+
storage before the flagged bio starts. In addition the REQ_PREFLUSH flag can be
2828
set on an otherwise empty bio structure, which causes only an explicit cache
2929
flush without any dependent I/O. It is recommend to use
3030
the blkdev_issue_flush() helper for a pure cache flush.
@@ -41,21 +41,21 @@ signaled after the data has been committed to non-volatile storage.
4141
Implementation details for filesystems
4242
--------------------------------------
4343

44-
Filesystems can simply set the REQ_FLUSH and REQ_FUA bits and do not have to
44+
Filesystems can simply set the REQ_PREFLUSH and REQ_FUA bits and do not have to
4545
worry if the underlying devices need any explicit cache flushing and how
46-
the Forced Unit Access is implemented. The REQ_FLUSH and REQ_FUA flags
46+
the Forced Unit Access is implemented. The REQ_PREFLUSH and REQ_FUA flags
4747
may both be set on a single bio.
4848

4949

5050
Implementation details for make_request_fn based block drivers
5151
--------------------------------------------------------------
5252

53-
These drivers will always see the REQ_FLUSH and REQ_FUA bits as they sit
53+
These drivers will always see the REQ_PREFLUSH and REQ_FUA bits as they sit
5454
directly below the submit_bio interface. For remapping drivers the REQ_FUA
5555
bits need to be propagated to underlying devices, and a global flush needs
56-
to be implemented for bios with the REQ_FLUSH bit set. For real device
57-
drivers that do not have a volatile cache the REQ_FLUSH and REQ_FUA bits
58-
on non-empty bios can simply be ignored, and REQ_FLUSH requests without
56+
to be implemented for bios with the REQ_PREFLUSH bit set. For real device
57+
drivers that do not have a volatile cache the REQ_PREFLUSH and REQ_FUA bits
58+
on non-empty bios can simply be ignored, and REQ_PREFLUSH requests without
5959
data can be completed successfully without doing any work. Drivers for
6060
devices with volatile caches need to implement the support for these
6161
flags themselves without any help from the block layer.
@@ -65,16 +65,16 @@ Implementation details for request_fn based block drivers
6565
--------------------------------------------------------------
6666

6767
For devices that do not support volatile write caches there is no driver
68-
support required, the block layer completes empty REQ_FLUSH requests before
69-
entering the driver and strips off the REQ_FLUSH and REQ_FUA bits from
68+
support required, the block layer completes empty REQ_PREFLUSH requests before
69+
entering the driver and strips off the REQ_PREFLUSH and REQ_FUA bits from
7070
requests that have a payload. For devices with volatile write caches the
7171
driver needs to tell the block layer that it supports flushing caches by
7272
doing:
7373

7474
blk_queue_write_cache(sdkp->disk->queue, true, false);
7575

7676
and handle empty REQ_OP_FLUSH requests in its prep_fn/request_fn. Note that
77-
REQ_FLUSH requests with a payload are automatically turned into a sequence
77+
REQ_PREFLUSH requests with a payload are automatically turned into a sequence
7878
of an empty REQ_OP_FLUSH request followed by the actual write by the block
7979
layer. For devices that also support the FUA bit the block layer needs
8080
to be told to pass through the REQ_FUA bit using:

Documentation/device-mapper/log-writes.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ Log Ordering
1414

1515
We log things in order of completion once we are sure the write is no longer in
1616
cache. This means that normal WRITE requests are not actually logged until the
17-
next REQ_FLUSH request. This is to make it easier for userspace to replay the
18-
log in a way that correlates to what is on disk and not what is in cache, to
19-
make it easier to detect improper waiting/flushing.
17+
next REQ_PREFLUSH request. This is to make it easier for userspace to replay
18+
the log in a way that correlates to what is on disk and not what is in cache,
19+
to make it easier to detect improper waiting/flushing.
2020

2121
This works by attaching all WRITE requests to a list once the write completes.
22-
Once we see a REQ_FLUSH request we splice this list onto the request and once
22+
Once we see a REQ_PREFLUSH request we splice this list onto the request and once
2323
the FLUSH request completes we log all of the WRITEs and then the FLUSH. Only
24-
completed WRITEs, at the time the REQ_FLUSH is issued, are added in order to
24+
completed WRITEs, at the time the REQ_PREFLUSH is issued, are added in order to
2525
simulate the worst case scenario with regard to power failures. Consider the
2626
following example (W means write, C means complete):
2727

block/blk-core.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ static bool blk_rq_should_init_elevator(struct bio *bio)
10291029
* Flush requests do not use the elevator so skip initialization.
10301030
* This allows a request to share the flush and elevator data.
10311031
*/
1032-
if (bio->bi_rw & (REQ_FLUSH | REQ_FUA))
1032+
if (bio->bi_rw & (REQ_PREFLUSH | REQ_FUA))
10331033
return false;
10341034

10351035
return true;
@@ -1736,7 +1736,7 @@ static blk_qc_t blk_queue_bio(struct request_queue *q, struct bio *bio)
17361736
return BLK_QC_T_NONE;
17371737
}
17381738

1739-
if (bio->bi_rw & (REQ_FLUSH | REQ_FUA)) {
1739+
if (bio->bi_rw & (REQ_PREFLUSH | REQ_FUA)) {
17401740
spin_lock_irq(q->queue_lock);
17411741
where = ELEVATOR_INSERT_FLUSH;
17421742
goto get_rq;
@@ -1968,9 +1968,9 @@ generic_make_request_checks(struct bio *bio)
19681968
* drivers without flush support don't have to worry
19691969
* about them.
19701970
*/
1971-
if ((bio->bi_rw & (REQ_FLUSH | REQ_FUA)) &&
1971+
if ((bio->bi_rw & (REQ_PREFLUSH | REQ_FUA)) &&
19721972
!test_bit(QUEUE_FLAG_WC, &q->queue_flags)) {
1973-
bio->bi_rw &= ~(REQ_FLUSH | REQ_FUA);
1973+
bio->bi_rw &= ~(REQ_PREFLUSH | REQ_FUA);
19741974
if (!nr_sectors) {
19751975
err = 0;
19761976
goto end_io;
@@ -2217,7 +2217,7 @@ int blk_insert_cloned_request(struct request_queue *q, struct request *rq)
22172217
*/
22182218
BUG_ON(blk_queued_rq(rq));
22192219

2220-
if (rq->cmd_flags & (REQ_FLUSH|REQ_FUA))
2220+
if (rq->cmd_flags & (REQ_PREFLUSH | REQ_FUA))
22212221
where = ELEVATOR_INSERT_FLUSH;
22222222

22232223
add_acct_request(q, rq, where);
@@ -3311,7 +3311,7 @@ void blk_flush_plug_list(struct blk_plug *plug, bool from_schedule)
33113311
/*
33123312
* rq is already accounted, so use raw insert
33133313
*/
3314-
if (rq->cmd_flags & (REQ_FLUSH | REQ_FUA))
3314+
if (rq->cmd_flags & (REQ_PREFLUSH | REQ_FUA))
33153315
__elv_add_request(q, rq, ELEVATOR_INSERT_FLUSH);
33163316
else
33173317
__elv_add_request(q, rq, ELEVATOR_INSERT_SORT_MERGE);

block/blk-flush.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
* optional steps - PREFLUSH, DATA and POSTFLUSH - according to the request
1111
* properties and hardware capability.
1212
*
13-
* If a request doesn't have data, only REQ_FLUSH makes sense, which
14-
* indicates a simple flush request. If there is data, REQ_FLUSH indicates
13+
* If a request doesn't have data, only REQ_PREFLUSH makes sense, which
14+
* indicates a simple flush request. If there is data, REQ_PREFLUSH indicates
1515
* that the device cache should be flushed before the data is executed, and
1616
* REQ_FUA means that the data must be on non-volatile media on request
1717
* completion.
@@ -20,11 +20,11 @@
2020
* difference. The requests are either completed immediately if there's no
2121
* data or executed as normal requests otherwise.
2222
*
23-
* If the device has writeback cache and supports FUA, REQ_FLUSH is
23+
* If the device has writeback cache and supports FUA, REQ_PREFLUSH is
2424
* translated to PREFLUSH but REQ_FUA is passed down directly with DATA.
2525
*
26-
* If the device has writeback cache and doesn't support FUA, REQ_FLUSH is
27-
* translated to PREFLUSH and REQ_FUA to POSTFLUSH.
26+
* If the device has writeback cache and doesn't support FUA, REQ_PREFLUSH
27+
* is translated to PREFLUSH and REQ_FUA to POSTFLUSH.
2828
*
2929
* The actual execution of flush is double buffered. Whenever a request
3030
* needs to execute PRE or POSTFLUSH, it queues at
@@ -103,7 +103,7 @@ static unsigned int blk_flush_policy(unsigned long fflags, struct request *rq)
103103
policy |= REQ_FSEQ_DATA;
104104

105105
if (fflags & (1UL << QUEUE_FLAG_WC)) {
106-
if (rq->cmd_flags & REQ_FLUSH)
106+
if (rq->cmd_flags & REQ_PREFLUSH)
107107
policy |= REQ_FSEQ_PREFLUSH;
108108
if (!(fflags & (1UL << QUEUE_FLAG_FUA)) &&
109109
(rq->cmd_flags & REQ_FUA))
@@ -391,9 +391,9 @@ void blk_insert_flush(struct request *rq)
391391

392392
/*
393393
* @policy now records what operations need to be done. Adjust
394-
* REQ_FLUSH and FUA for the driver.
394+
* REQ_PREFLUSH and FUA for the driver.
395395
*/
396-
rq->cmd_flags &= ~REQ_FLUSH;
396+
rq->cmd_flags &= ~REQ_PREFLUSH;
397397
if (!(fflags & (1UL << QUEUE_FLAG_FUA)))
398398
rq->cmd_flags &= ~REQ_FUA;
399399

block/blk-mq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,7 @@ static int blk_mq_direct_issue_request(struct request *rq, blk_qc_t *cookie)
12471247
static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)
12481248
{
12491249
const int is_sync = rw_is_sync(bio_op(bio), bio->bi_rw);
1250-
const int is_flush_fua = bio->bi_rw & (REQ_FLUSH | REQ_FUA);
1250+
const int is_flush_fua = bio->bi_rw & (REQ_PREFLUSH | REQ_FUA);
12511251
struct blk_map_ctx data;
12521252
struct request *rq;
12531253
unsigned int request_count = 0;
@@ -1344,7 +1344,7 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)
13441344
static blk_qc_t blk_sq_make_request(struct request_queue *q, struct bio *bio)
13451345
{
13461346
const int is_sync = rw_is_sync(bio_op(bio), bio->bi_rw);
1347-
const int is_flush_fua = bio->bi_rw & (REQ_FLUSH | REQ_FUA);
1347+
const int is_flush_fua = bio->bi_rw & (REQ_PREFLUSH | REQ_FUA);
13481348
struct blk_plug *plug;
13491349
unsigned int request_count = 0;
13501350
struct blk_map_ctx data;

drivers/block/drbd/drbd_actlog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ static int _drbd_md_sync_page_io(struct drbd_device *device,
148148
device->md_io.error = -ENODEV;
149149

150150
if ((op == REQ_OP_WRITE) && !test_bit(MD_NO_FUA, &device->flags))
151-
op_flags |= REQ_FUA | REQ_FLUSH;
151+
op_flags |= REQ_FUA | REQ_PREFLUSH;
152152
op_flags |= REQ_SYNC | REQ_NOIDLE;
153153

154154
bio = bio_alloc_drbd(GFP_NOIO);
@@ -847,7 +847,7 @@ int __drbd_change_sync(struct drbd_device *device, sector_t sector, int size,
847847
unsigned long count = 0;
848848
sector_t esector, nr_sectors;
849849

850-
/* This would be an empty REQ_FLUSH, be silent. */
850+
/* This would be an empty REQ_PREFLUSH, be silent. */
851851
if ((mode == SET_OUT_OF_SYNC) && size == 0)
852852
return 0;
853853

drivers/block/drbd/drbd_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1609,7 +1609,7 @@ static u32 bio_flags_to_wire(struct drbd_connection *connection,
16091609
if (connection->agreed_pro_version >= 95)
16101610
return (bio->bi_rw & REQ_SYNC ? DP_RW_SYNC : 0) |
16111611
(bio->bi_rw & REQ_FUA ? DP_FUA : 0) |
1612-
(bio->bi_rw & REQ_FLUSH ? DP_FLUSH : 0) |
1612+
(bio->bi_rw & REQ_PREFLUSH ? DP_FLUSH : 0) |
16131613
(bio_op(bio) == REQ_OP_DISCARD ? DP_DISCARD : 0);
16141614
else
16151615
return bio->bi_rw & REQ_SYNC ? DP_RW_SYNC : 0;

drivers/block/drbd/drbd_protocol.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ struct p_header100 {
112112
#define DP_MAY_SET_IN_SYNC 4
113113
#define DP_UNPLUG 8 /* not used anymore */
114114
#define DP_FUA 16 /* equals REQ_FUA */
115-
#define DP_FLUSH 32 /* equals REQ_FLUSH */
115+
#define DP_FLUSH 32 /* equals REQ_PREFLUSH */
116116
#define DP_DISCARD 64 /* equals REQ_DISCARD */
117117
#define DP_SEND_RECEIVE_ACK 128 /* This is a proto B write request */
118118
#define DP_SEND_WRITE_ACK 256 /* This is a proto C write request */

drivers/block/drbd/drbd_receiver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2158,7 +2158,7 @@ static unsigned long wire_flags_to_bio_flags(u32 dpf)
21582158
{
21592159
return (dpf & DP_RW_SYNC ? REQ_SYNC : 0) |
21602160
(dpf & DP_FUA ? REQ_FUA : 0) |
2161-
(dpf & DP_FLUSH ? REQ_FLUSH : 0);
2161+
(dpf & DP_FLUSH ? REQ_PREFLUSH : 0);
21622162
}
21632163

21642164
static unsigned long wire_flags_to_bio_op(u32 dpf)

drivers/block/drbd/drbd_req.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ static int drbd_process_write_request(struct drbd_request *req)
11321132
* replicating, in which case there is no point. */
11331133
if (unlikely(req->i.size == 0)) {
11341134
/* The only size==0 bios we expect are empty flushes. */
1135-
D_ASSERT(device, req->master_bio->bi_rw & REQ_FLUSH);
1135+
D_ASSERT(device, req->master_bio->bi_rw & REQ_PREFLUSH);
11361136
if (remote)
11371137
_req_mod(req, QUEUE_AS_DRBD_BARRIER);
11381138
return remote;

0 commit comments

Comments
 (0)