Skip to content

Commit a288709

Browse files
committed
Merge branch 'for-2.6.37/barrier' of git://git.kernel.dk/linux-2.6-block
* 'for-2.6.37/barrier' of git://git.kernel.dk/linux-2.6-block: (46 commits) xen-blkfront: disable barrier/flush write support Added blk-lib.c and blk-barrier.c was renamed to blk-flush.c block: remove BLKDEV_IFL_WAIT aic7xxx_old: removed unused 'req' variable block: remove the BH_Eopnotsupp flag block: remove the BLKDEV_IFL_BARRIER flag block: remove the WRITE_BARRIER flag swap: do not send discards as barriers fat: do not send discards as barriers ext4: do not send discards as barriers jbd2: replace barriers with explicit flush / FUA usage jbd2: Modify ASYNC_COMMIT code to not rely on queue draining on barrier jbd: replace barriers with explicit flush / FUA usage nilfs2: replace barriers with explicit flush / FUA usage reiserfs: replace barriers with explicit flush / FUA usage gfs2: replace barriers with explicit flush / FUA usage btrfs: replace barriers with explicit flush / FUA usage xfs: replace barriers with explicit flush / FUA usage block: pass gfp_mask and flags to sb_issue_discard dm: convey that all flushes are processed as empty ...
2 parents 8abfc6e + 005a1d1 commit a288709

80 files changed

Lines changed: 845 additions & 1921 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Documentation/DocBook/kernel-api.tmpl‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,8 @@ X!Earch/x86/kernel/mca_32.c
257257
!Iblock/blk-sysfs.c
258258
!Eblock/blk-settings.c
259259
!Eblock/blk-exec.c
260-
!Eblock/blk-barrier.c
260+
!Eblock/blk-flush.c
261+
!Eblock/blk-lib.c
261262
!Eblock/blk-tag.c
262263
!Iblock/blk-tag.c
263264
!Eblock/blk-integrity.c

‎Documentation/block/00-INDEX‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
00-INDEX
22
- This file
3-
barrier.txt
4-
- I/O Barriers
53
biodoc.txt
64
- Notes on the Generic Block Layer Rewrite in Linux 2.5
75
capability.txt
@@ -16,3 +14,5 @@ stat.txt
1614
- Block layer statistics in /sys/block/<dev>/stat
1715
switching-sched.txt
1816
- Switching I/O schedulers at runtime
17+
writeback_cache_control.txt
18+
- Control of volatile write back caches

‎Documentation/block/barrier.txt‎

Lines changed: 0 additions & 261 deletions
This file was deleted.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
2+
Explicit volatile write back cache control
3+
=====================================
4+
5+
Introduction
6+
------------
7+
8+
Many storage devices, especially in the consumer market, come with volatile
9+
write back caches. That means the devices signal I/O completion to the
10+
operating system before data actually has hit the non-volatile storage. This
11+
behavior obviously speeds up various workloads, but it means the operating
12+
system needs to force data out to the non-volatile storage when it performs
13+
a data integrity operation like fsync, sync or an unmount.
14+
15+
The Linux block layer provides two simple mechanisms that let filesystems
16+
control the caching behavior of the storage device. These mechanisms are
17+
a forced cache flush, and the Force Unit Access (FUA) flag for requests.
18+
19+
20+
Explicit cache flushes
21+
----------------------
22+
23+
The REQ_FLUSH flag can be OR ed into the r/w flags of a bio submitted from
24+
the filesystem and will make sure the volatile cache of the storage device
25+
has been flushed before the actual I/O operation is started. This explicitly
26+
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
28+
set on an otherwise empty bio structure, which causes only an explicit cache
29+
flush without any dependent I/O. It is recommend to use
30+
the blkdev_issue_flush() helper for a pure cache flush.
31+
32+
33+
Forced Unit Access
34+
-----------------
35+
36+
The REQ_FUA flag can be OR ed into the r/w flags of a bio submitted from the
37+
filesystem and will make sure that I/O completion for this request is only
38+
signaled after the data has been committed to non-volatile storage.
39+
40+
41+
Implementation details for filesystems
42+
--------------------------------------
43+
44+
Filesystems can simply set the REQ_FLUSH and REQ_FUA bits and do not have to
45+
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
47+
may both be set on a single bio.
48+
49+
50+
Implementation details for make_request_fn based block drivers
51+
--------------------------------------------------------------
52+
53+
These drivers will always see the REQ_FLUSH 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_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
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.
62+
63+
64+
Implementation details for request_fn based block drivers
65+
--------------------------------------------------------------
66+
67+
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
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:
73+
74+
blk_queue_flush(sdkp->disk->queue, REQ_FLUSH);
75+
76+
and handle empty REQ_FLUSH requests in its prep_fn/request_fn. Note that
77+
REQ_FLUSH requests with a payload are automatically turned into a sequence
78+
of an empty REQ_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:
81+
82+
blk_queue_flush(sdkp->disk->queue, REQ_FLUSH | REQ_FUA);
83+
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_FLUSH request after the actual write.

0 commit comments

Comments
 (0)