@@ -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
527527static 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
541546static 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
667670static 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