mirror of
https://github.com/kdave/btrfs-progs
synced 2024-12-28 17:12:17 +00:00
btrfs-progs: use direct-io for zoned device
We need to use direct-IO for zoned devices to preserve the write ordering. Instead of detecting if the device is zoned or not, we simply use direct-IO for any kind of device (even if emulated zoned mode on a regular device). Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
4a8d85f730
commit
e9696b06f0
@ -1382,6 +1382,9 @@ struct btrfs_fs_info *open_ctree_fs_info(struct open_ctree_flags *ocf)
|
||||
if (!(ocf->flags & OPEN_CTREE_WRITES))
|
||||
oflags = O_RDONLY;
|
||||
|
||||
if ((oflags & O_RDWR) && zoned_model(ocf->filename) == ZONED_HOST_MANAGED)
|
||||
oflags |= O_DIRECT;
|
||||
|
||||
fp = open(ocf->filename, oflags);
|
||||
if (fp < 0) {
|
||||
error("cannot open '%s': %m", ocf->filename);
|
||||
|
@ -455,6 +455,9 @@ int btrfs_open_devices(struct btrfs_fs_info *fs_info,
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((flags & O_RDWR) && zoned_model(device->name) == ZONED_HOST_MANAGED)
|
||||
flags |= O_DIRECT;
|
||||
|
||||
fd = open(device->name, flags);
|
||||
if (fd < 0) {
|
||||
ret = -errno;
|
||||
|
@ -893,6 +893,7 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
|
||||
bool ssd = false;
|
||||
bool zoned = false;
|
||||
bool force_overwrite = false;
|
||||
int oflags;
|
||||
char *source_dir = NULL;
|
||||
bool source_dir_set = false;
|
||||
bool shrink_rootdir = false;
|
||||
@ -1305,12 +1306,16 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
|
||||
|
||||
dev_cnt--;
|
||||
|
||||
oflags = O_RDWR;
|
||||
if (zoned && zoned_model(file) == ZONED_HOST_MANAGED)
|
||||
oflags |= O_DIRECT;
|
||||
|
||||
/*
|
||||
* Open without O_EXCL so that the problem should not occur by the
|
||||
* following operation in kernel:
|
||||
* (btrfs_register_one_device() fails if O_EXCL is on)
|
||||
*/
|
||||
fd = open(file, O_RDWR);
|
||||
fd = open(file, oflags);
|
||||
if (fd < 0) {
|
||||
error("unable to open %s: %m", file);
|
||||
goto error;
|
||||
|
Loading…
Reference in New Issue
Block a user