summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2020-08-24 14:57:48 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2020-08-25 13:09:39 -0400
commit419fbcd0f63c30aa8c5483cd503a00673cada0df (patch)
treeb77a28e35fa5b4ed19649f2fd67c59b4083be5c1
parentbb9230f31eae315fd95ad57f37f4d5b559a3ed4f (diff)
bcachefs: Some project id fixes
Inode options that are accessible via the xattr interface are stored with a +1 bias, so that a value of 0 means unset. We weren't handling this consistently. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r--fs/bcachefs/fs-ioctl.c6
-rw-r--r--fs/bcachefs/xattr.c6
2 files changed, 10 insertions, 2 deletions
diff --git a/fs/bcachefs/fs-ioctl.c b/fs/bcachefs/fs-ioctl.c
index 031e6d931171..0873d2f0928c 100644
--- a/fs/bcachefs/fs-ioctl.c
+++ b/fs/bcachefs/fs-ioctl.c
@@ -138,6 +138,10 @@ static int bch2_ioc_fssetxattr(struct bch_fs *c,
if (fa.fsx_projid >= U32_MAX)
return -EINVAL;
+ /*
+ * inode fields accessible via the xattr interface are stored with a +1
+ * bias, so that 0 means unset:
+ */
s.projid = fa.fsx_projid + 1;
ret = mnt_want_write_file(file);
@@ -151,7 +155,7 @@ static int bch2_ioc_fssetxattr(struct bch_fs *c,
}
mutex_lock(&inode->ei_update_lock);
- ret = bch2_set_projid(c, inode, s.projid);
+ ret = bch2_set_projid(c, inode, fa.fsx_projid);
if (ret)
goto err_unlock;
diff --git a/fs/bcachefs/xattr.c b/fs/bcachefs/xattr.c
index 725a6f3ef8ce..21f64cb7e402 100644
--- a/fs/bcachefs/xattr.c
+++ b/fs/bcachefs/xattr.c
@@ -511,7 +511,11 @@ static int bch2_xattr_bcachefs_set(const struct xattr_handler *handler,
mutex_lock(&inode->ei_update_lock);
if (inode_opt_id == Inode_opt_project) {
- ret = bch2_set_projid(c, inode, s.v);
+ /*
+ * inode fields accessible via the xattr interface are stored
+ * with a +1 bias, so that 0 means unset:
+ */
+ ret = bch2_set_projid(c, inode, s.v ? s.v - 1 : 0);
if (ret)
goto err;
}