diff options
author | Justin Husted <sigstop@gmail.com> | 2019-10-07 14:21:39 -0700 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2019-10-18 16:23:39 -0400 |
commit | 52771aa7d2f9284e86069ef6274c92b9757c313e (patch) | |
tree | 64f2870d4a956e4b95abec738cd0f1b72c57e0f5 /cmd_fusemount.c | |
parent | 415a3651fc8851056a0ab3946b90e123b113bac7 (diff) |
Fix fuse read/write to not segfault on unaligned IO.
Diffstat (limited to 'cmd_fusemount.c')
-rw-r--r-- | cmd_fusemount.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/cmd_fusemount.c b/cmd_fusemount.c index 91c93607..90d3d869 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; } |