@@ -46,41 +46,50 @@ worry if the underlying devices need any explicit cache flushing and how
46
46
the Forced Unit Access is implemented. The REQ_PREFLUSH and REQ_FUA flags
47
47
may both be set on a single bio.
48
48
49
+ Feature settings for block drivers
50
+ ----------------------------------
49
51
50
- Implementation details for bio based block drivers
51
- --------------------------------------------------------------
52
+ For devices that do not support volatile write caches there is no driver
53
+ support required, the block layer completes empty REQ_PREFLUSH requests before
54
+ entering the driver and strips off the REQ_PREFLUSH and REQ_FUA bits from
55
+ requests that have a payload.
52
56
53
- These drivers will always see the REQ_PREFLUSH and REQ_FUA bits as they sit
54
- directly below the submit_bio interface. For remapping drivers the REQ_FUA
55
- bits need to be propagated to underlying devices, and a global flush needs
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
59
- data can be completed successfully without doing any work. Drivers for
60
- devices with volatile caches need to implement the support for these
61
- flags themselves without any help from the block layer.
57
+ For devices with volatile write caches the driver needs to tell the block layer
58
+ that it supports flushing caches by setting the
62
59
60
+ BLK_FEAT_WRITE_CACHE
63
61
64
- Implementation details for request_fn based block drivers
65
- ---------------------------------------------------------
62
+ flag in the queue_limits feature field. For devices that also support the FUA
63
+ bit the block layer needs to be told to pass on the REQ_FUA bit by also setting
64
+ the
66
65
67
- For devices that do not support volatile write caches there is no driver
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
70
- requests that have a payload. For devices with volatile write caches the
71
- driver needs to tell the block layer that it supports flushing caches by
72
- doing::
66
+ BLK_FEAT_FUA
67
+
68
+ flag in the features field of the queue_limits structure.
69
+
70
+ Implementation details for bio based block drivers
71
+ --------------------------------------------------
72
+
73
+ For bio based drivers the REQ_PREFLUSH and REQ_FUA bit are simply passed on to
74
+ the driver if the driver sets the BLK_FEAT_WRITE_CACHE flag and the driver
75
+ needs to handle them.
76
+
77
+ *NOTE *: The REQ_FUA bit also gets passed on when the BLK_FEAT_FUA flags is
78
+ _not_ set. Any bio based driver that sets BLK_FEAT_WRITE_CACHE also needs to
79
+ handle REQ_FUA.
73
80
74
- blk_queue_write_cache(sdkp->disk->queue, true, false);
81
+ For remapping drivers the REQ_FUA bits need to be propagated to underlying
82
+ devices, and a global flush needs to be implemented for bios with the
83
+ REQ_PREFLUSH bit set.
75
84
76
- and handle empty REQ_OP_FLUSH requests in its prep_fn/request_fn. Note that
77
- REQ_PREFLUSH requests with a payload are automatically turned into a sequence
78
- of an empty REQ_OP_FLUSH request followed by the actual write by the block
79
- layer. For devices that also support the FUA bit the block layer needs
80
- to be told to pass through the REQ_FUA bit using::
85
+ Implementation details for blk-mq drivers
86
+ -----------------------------------------
81
87
82
- blk_queue_write_cache(sdkp->disk->queue, true, true);
88
+ When the BLK_FEAT_WRITE_CACHE flag is set, REQ_OP_WRITE | REQ_PREFLUSH requests
89
+ with a payload are automatically turned into a sequence of a REQ_OP_FLUSH
90
+ request followed by the actual write by the block layer.
83
91
84
- and the driver must handle write requests that have the REQ_FUA bit set
85
- in prep_fn/request_fn. If the FUA bit is not natively supported the block
86
- layer turns it into an empty REQ_OP_FLUSH request after the actual write.
92
+ When the BLK_FEAT_FUA flags is set, the REQ_FUA bit is simply passed on for the
93
+ REQ_OP_WRITE request, else a REQ_OP_FLUSH request is sent by the block layer
94
+ after the completion of the write request for bio submissions with the REQ_FUA
95
+ bit set.
0 commit comments