summaryrefslogtreecommitdiff
path: root/cmd_fusemount.c
diff options
context:
space:
mode:
authorJustin Husted <sigstop@gmail.com>2019-10-07 14:21:39 -0700
committerKent Overstreet <kent.overstreet@gmail.com>2019-10-18 16:23:39 -0400
commit52771aa7d2f9284e86069ef6274c92b9757c313e (patch)
tree64f2870d4a956e4b95abec738cd0f1b72c57e0f5 /cmd_fusemount.c
parent415a3651fc8851056a0ab3946b90e123b113bac7 (diff)
Fix fuse read/write to not segfault on unaligned IO.
Diffstat (limited to 'cmd_fusemount.c')
-rw-r--r--cmd_fusemount.c14
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;
}