summaryrefslogtreecommitdiff
path: root/libbcachefs/super-io.c
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 /libbcachefs/super-io.c
parent1c156d5c4667c1c2e2949b229dfef75696196d35 (diff)
Update bcachefs sources to e14d7c7195 bcachefs: Compression levels
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'libbcachefs/super-io.c')
-rw-r--r--libbcachefs/super-io.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/libbcachefs/super-io.c b/libbcachefs/super-io.c
index 35325381..e9ce3f33 100644
--- a/libbcachefs/super-io.c
+++ b/libbcachefs/super-io.c
@@ -658,11 +658,18 @@ int bch2_read_super(const char *path, struct bch_opts *opts,
struct printbuf err = PRINTBUF;
__le64 *i;
int ret;
-
+#ifndef __KERNEL__
+retry:
+#endif
memset(sb, 0, sizeof(*sb));
sb->mode = FMODE_READ;
sb->have_bio = true;
+#ifndef __KERNEL__
+ if (opt_get(*opts, direct_io) == false)
+ sb->mode |= FMODE_BUFFERED;
+#endif
+
if (!opt_get(*opts, noexcl))
sb->mode |= FMODE_EXCL;
@@ -747,7 +754,13 @@ int bch2_read_super(const char *path, struct bch_opts *opts,
got_super:
if (le16_to_cpu(sb->sb->block_size) << 9 <
- bdev_logical_block_size(sb->bdev)) {
+ bdev_logical_block_size(sb->bdev) &&
+ opt_get(*opts, direct_io)) {
+#ifndef __KERNEL__
+ opt_set(*opts, direct_io, false);
+ bch2_free_super(sb);
+ goto retry;
+#endif
prt_printf(&err, "block size (%u) smaller than device block size (%u)",
le16_to_cpu(sb->sb->block_size) << 9,
bdev_logical_block_size(sb->bdev));