summaryrefslogtreecommitdiff
path: root/fs/bcachefs/fs.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-06-14 22:29:54 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:07 -0400
commit68a507a2e8cdc9b90599bb5d220a696abdc54838 (patch)
tree5250c2cf969bea932b9f6f853ebdae29d8b50052 /fs/bcachefs/fs.c
parent8c3f6da9fc526e7ba0f6449efa1040084406e9ba (diff)
bcachefs: fix truncate with ATTR_MODE
After the v5.12 rebase, we started oopsing when truncate was passed ATTR_MODE, due to not passing mnt_userns to setattr_copy(). This refactors things so that truncate/extend finish by using bch2_setattr_nonsize(), which solves the problem. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/fs.c')
-rw-r--r--fs/bcachefs/fs.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c
index efb467316756..71e738b98967 100644
--- a/fs/bcachefs/fs.c
+++ b/fs/bcachefs/fs.c
@@ -662,6 +662,9 @@ static void bch2_setattr_copy(struct mnt_idmap *idmap,
if (ia_valid & ATTR_GID)
bi->bi_gid = from_kgid(i_user_ns(&inode->v), attr->ia_gid);
+ if (ia_valid & ATTR_SIZE)
+ bi->bi_size = attr->ia_size;
+
if (ia_valid & ATTR_ATIME)
bi->bi_atime = timespec_to_bch2_time(c, attr->ia_atime);
if (ia_valid & ATTR_MTIME)
@@ -682,9 +685,9 @@ static void bch2_setattr_copy(struct mnt_idmap *idmap,
}
}
-static int bch2_setattr_nonsize(struct mnt_idmap *idmap,
- struct bch_inode_info *inode,
- struct iattr *attr)
+int bch2_setattr_nonsize(struct mnt_idmap *idmap,
+ struct bch_inode_info *inode,
+ struct iattr *attr)
{
struct bch_fs *c = inode->v.i_sb->s_fs_info;
struct bch_qid qid;
@@ -808,7 +811,7 @@ static int bch2_setattr(struct mnt_idmap *idmap,
return ret;
return iattr->ia_valid & ATTR_SIZE
- ? bch2_truncate(inode, iattr)
+ ? bch2_truncate(idmap, inode, iattr)
: bch2_setattr_nonsize(idmap, inode, iattr);
}