summaryrefslogtreecommitdiff
path: root/linux
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-07-10 20:31:34 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-07-15 17:36:15 -0400
commitc8bec83e307f28751c433ba1d3f648429fb5a34c (patch)
tree6e70e0cf8f25117f706214d86a0689ee8495dca0 /linux
parent1c156d5c4667c1c2e2949b229dfef75696196d35 (diff)
Update bcachefs sources to e14d7c7195 bcachefs: Compression levels
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'linux')
-rw-r--r--linux/blkdev.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/linux/blkdev.c b/linux/blkdev.c
index 45b03fba..ea901a46 100644
--- a/linux/blkdev.c
+++ b/linux/blkdev.c
@@ -183,16 +183,19 @@ struct block_device *blkdev_get_by_path(const char *path, fmode_t mode,
else if (mode & FMODE_WRITE)
flags = O_WRONLY;
+ if (!(mode & FMODE_BUFFERED))
+ flags |= O_DIRECT;
+
#if 0
/* using O_EXCL doesn't work with opening twice for an O_SYNC fd: */
if (mode & FMODE_EXCL)
flags |= O_EXCL;
#endif
- buffered_fd = open(path, flags);
+ buffered_fd = open(path, flags & ~O_DIRECT);
if (buffered_fd < 0)
return ERR_PTR(-errno);
- fd = open(path, flags|O_DIRECT);
+ fd = open(path, flags);
if (fd < 0)
fd = dup(buffered_fd);
if (fd < 0) {
@@ -200,9 +203,9 @@ struct block_device *blkdev_get_by_path(const char *path, fmode_t mode,
return ERR_PTR(-errno);
}
- sync_fd = open(path, flags|O_DIRECT|O_SYNC);
+ sync_fd = open(path, flags|O_SYNC);
if (sync_fd < 0)
- sync_fd = open(path, flags|O_SYNC);
+ sync_fd = open(path, (flags & ~O_DIRECT)|O_SYNC);
if (sync_fd < 0) {
close(fd);
close(buffered_fd);