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>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
        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);
        }
 
        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;
 
 
 
        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;
        }