From: Justin Husted Date: Mon, 7 Oct 2019 21:21:39 +0000 (-0700) Subject: Fix fuse read/write to not segfault on unaligned IO. X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=52771aa7d2f9284e86069ef6274c92b9757c313e;p=bcachefs-tools-debian Fix fuse read/write to not segfault on unaligned IO. --- diff --git a/cmd_fusemount.c b/cmd_fusemount.c index 91c9360..90d3d86 100644 --- a/cmd_fusemount.c +++ b/cmd_fusemount.c @@ -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; }