Skip to content

Commit 18d107a

Browse files
committed
drastic read performance improvements by setting backing_id when only reading
1 parent 63d874e commit 18d107a

3 files changed

Lines changed: 11 additions & 17 deletions

File tree

src/fs_context.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct Fs {
2525

2626
std::string fuse_mount_options;
2727
bool direct_io{false};
28-
bool passthrough{false};
28+
bool passthrough{true};
2929

3030
bool force_uid_enabled{false};
3131
uid_t force_uid{0};

src/main.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,6 @@ int main(int argc, char *argv[]) {
5858
start_quota = true;
5959
quota_limit = options["quota"].as<uint64_t>();
6060
quota_interval = options["quota-rescan-interval"].as<int>();
61-
62-
if (fs.passthrough) {
63-
std::println(stderr, "NOTICE: Disabling passthrough for quota enforcement.");
64-
fs.passthrough = false;
65-
}
6661
}
6762

6863
bool start_socket = false;

src/operations.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ static void sfs_init(void *userdata, fuse_conn_info *conn) {
152152
if (!fuse_set_feature_flag(conn, FUSE_CAP_PASSTHROUGH))
153153
fs.passthrough = false;
154154

155-
if (fs.timeout && !fs.passthrough)
155+
if (fs.timeout)
156156
fuse_set_feature_flag(conn, FUSE_CAP_WRITEBACK_CACHE);
157157

158158
fuse_set_feature_flag(conn, FUSE_CAP_FLOCK_LOCKS);
@@ -525,17 +525,22 @@ static void sfs_fsyncdir(fuse_req_t req, fuse_ino_t ino, int datasync, fuse_file
525525
}
526526

527527
static void do_passthrough_open(fuse_req_t req, fuse_ino_t ino, int fd, fuse_file_info *fi) {
528+
bool is_write = (fi->flags & O_WRONLY) || (fi->flags & O_RDWR);
529+
530+
debug_print("is_write: {}, flags: {}", is_write, fi->flags);
531+
528532
Inode &inode = get_inode(ino);
529533
if (inode.backing_id) {
530534
fi->backing_id = inode.backing_id;
531-
} else if (!(inode.backing_id = fuse_passthrough_open(req, fd))) {
535+
} else if (is_write) {
536+
debug_print("not handling fuse_passthrough due to writing.");
537+
}
538+
if (!(inode.backing_id = fuse_passthrough_open(req, fd))) {
532539
debug_print("fuse_passthrough_open failed for inode {}, disabling rw passthrough.", ino);
533-
fs.passthrough = false;
534540
} else {
535541
fi->backing_id = inode.backing_id;
536542
}
537-
if (fi->backing_id)
538-
fi->keep_cache = false;
543+
fi->keep_cache = false;
539544
}
540545

541546
static void sfs_create_open_flags(fuse_file_info *fi) {
@@ -574,8 +579,6 @@ static void sfs_create(fuse_req_t req, fuse_ino_t parent, const char *name, mode
574579

575580
sfs_create_open_flags(fi);
576581

577-
if (fs.passthrough)
578-
do_passthrough_open(req, e.ino, fd, fi);
579582
fuse_reply_create(req, &e, fi);
580583
}
581584

@@ -667,10 +670,6 @@ static void sfs_read(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off, fus
667670
static void sfs_write_buf(fuse_req_t req, fuse_ino_t ino, fuse_bufvec *in_buf, off_t off,
668671
fuse_file_info *fi) {
669672
Inode &inode = get_inode(ino);
670-
if (fs.passthrough && !fs.direct_io) {
671-
fuse_reply_err(req, EIO);
672-
return;
673-
}
674673

675674
size_t size = fuse_buf_size(in_buf);
676675
uint64_t write_end = off + size;

0 commit comments

Comments
 (0)