]> git.sesse.net Git - bcachefs-tools-debian/commitdiff
Fix fuse read/write to not segfault on unaligned IO.
authorJustin Husted <sigstop@gmail.com>
Mon, 7 Oct 2019 21:21:39 +0000 (14:21 -0700)
committerKent Overstreet <kent.overstreet@gmail.com>
Fri, 18 Oct 2019 20:23:39 +0000 (16:23 -0400)
cmd_fusemount.c

index 91c93607c46b99b858b7930e4ebbf4ddd64e25ba..90d3d869fbf6a4c0492f8026128409cfb039a920 100644 (file)
@@ -73,7 +73,11 @@ static struct fuse_entry_param inode_to_entry(struct bch_fs *c,
 
 static void bcachefs_fuse_init(void *arg, struct fuse_conn_info *conn)
 {
-       conn->want |= FUSE_CAP_WRITEBACK_CACHE;
+       if (conn->capable & FUSE_CAP_WRITEBACK_CACHE) {
+               fuse_log(FUSE_LOG_DEBUG, "fuse_init: activating writeback\n");
+               conn->want |= FUSE_CAP_WRITEBACK_CACHE;
+       } else
+               fuse_log(FUSE_LOG_DEBUG, "fuse_init: writeback not capable\n");
 
        //conn->want |= FUSE_CAP_POSIX_ACL;
 }
@@ -378,7 +382,9 @@ static void bcachefs_fuse_read(fuse_req_t req, fuse_ino_t inum,
 {
        struct bch_fs *c = fuse_req_userdata(req);
 
-       if ((size|offset) & block_bytes(c)) {
+       if ((size|offset) & (block_bytes(c) - 1)) {
+               fuse_log(FUSE_LOG_DEBUG,
+                        "bcachefs_fuse_read: unaligned io not supported.\n");
                fuse_reply_err(req, EINVAL);
                return;
        }
@@ -430,7 +436,9 @@ static void bcachefs_fuse_write(fuse_req_t req, fuse_ino_t inum,
        struct bio_vec          bv;
        struct closure          cl;
 
-       if ((size|offset) & block_bytes(c)) {
+       if ((size|offset) & (block_bytes(c) - 1)) {
+               fuse_log(FUSE_LOG_DEBUG,
+                        "bcachefs_fuse_write: unaligned io not supported.\n");
                fuse_reply_err(req, EINVAL);
                return;
        }