Unverified Commit f861646a authored by Christian Brauner's avatar Christian Brauner Committed by Christian Brauner (Microsoft)
Browse files

quota: port to mnt_idmap



Convert to struct mnt_idmap.

Last cycle we merged the necessary infrastructure in
256c8aed ("fs: introduce dedicated idmap type for mounts").
This is just the conversion to struct mnt_idmap.

Currently we still pass around the plain namespace that was attached to a
mount. This is in general pretty convenient but it makes it easy to
conflate namespaces that are relevant on the filesystem with namespaces
that are relevent on the mount level. Especially for non-vfs developers
without detailed knowledge in this area this can be a potential source for
bugs.

Once the conversion to struct mnt_idmap is done all helpers down to the
really low-level helpers will take a struct mnt_idmap argument instead of
two namespace arguments. This way it becomes impossible to conflate the two
eliminating the possibility of any bugs. All of the vfs and all filesystems
only operate on struct mnt_idmap.

Acked-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarChristian Brauner (Microsoft) <brauner@kernel.org>
parent 9452e93e
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -1621,7 +1621,6 @@ int ext2_getattr(struct mnt_idmap *idmap, const struct path *path,
int ext2_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
		 struct iattr *iattr)
{
	struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
	struct inode *inode = d_inode(dentry);
	int error;

@@ -1629,14 +1628,14 @@ int ext2_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
	if (error)
		return error;

	if (is_quota_modification(mnt_userns, inode, iattr)) {
	if (is_quota_modification(&nop_mnt_idmap, inode, iattr)) {
		error = dquot_initialize(inode);
		if (error)
			return error;
	}
	if (i_uid_needs_update(mnt_userns, iattr, inode) ||
	    i_gid_needs_update(mnt_userns, iattr, inode)) {
		error = dquot_transfer(mnt_userns, inode, iattr);
	if (i_uid_needs_update(&nop_mnt_idmap, iattr, inode) ||
	    i_gid_needs_update(&nop_mnt_idmap, iattr, inode)) {
		error = dquot_transfer(&nop_mnt_idmap, inode, iattr);
		if (error)
			return error;
	}
+2 −2
Original line number Diff line number Diff line
@@ -5467,7 +5467,7 @@ int ext4_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
	if (error)
		return error;

	if (is_quota_modification(mnt_userns, inode, attr)) {
	if (is_quota_modification(idmap, inode, attr)) {
		error = dquot_initialize(inode);
		if (error)
			return error;
@@ -5491,7 +5491,7 @@ int ext4_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
		 * counts xattr inode references.
		 */
		down_read(&EXT4_I(inode)->xattr_sem);
		error = dquot_transfer(mnt_userns, inode, attr);
		error = dquot_transfer(idmap, inode, attr);
		up_read(&EXT4_I(inode)->xattr_sem);

		if (error) {
+2 −2
Original line number Diff line number Diff line
@@ -965,7 +965,7 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
	if (err)
		return err;

	if (is_quota_modification(mnt_userns, inode, attr)) {
	if (is_quota_modification(idmap, inode, attr)) {
		err = f2fs_dquot_initialize(inode);
		if (err)
			return err;
@@ -973,7 +973,7 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
	if (i_uid_needs_update(mnt_userns, attr, inode) ||
	    i_gid_needs_update(mnt_userns, attr, inode)) {
		f2fs_lock_op(F2FS_I_SB(inode));
		err = dquot_transfer(mnt_userns, inode, attr);
		err = dquot_transfer(idmap, inode, attr);
		if (err) {
			set_sbi_flag(F2FS_I_SB(inode),
					SBI_QUOTA_NEED_REPAIR);
+1 −1
Original line number Diff line number Diff line
@@ -266,7 +266,7 @@ static int recover_quota_data(struct inode *inode, struct page *page)
	if (!attr.ia_valid)
		return 0;

	err = dquot_transfer(&init_user_ns, inode, &attr);
	err = dquot_transfer(&nop_mnt_idmap, inode, &attr);
	if (err)
		set_sbi_flag(F2FS_I_SB(inode), SBI_QUOTA_NEED_REPAIR);
	return err;
+2 −2
Original line number Diff line number Diff line
@@ -95,14 +95,14 @@ int jfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
	if (rc)
		return rc;

	if (is_quota_modification(&init_user_ns, inode, iattr)) {
	if (is_quota_modification(&nop_mnt_idmap, inode, iattr)) {
		rc = dquot_initialize(inode);
		if (rc)
			return rc;
	}
	if ((iattr->ia_valid & ATTR_UID && !uid_eq(iattr->ia_uid, inode->i_uid)) ||
	    (iattr->ia_valid & ATTR_GID && !gid_eq(iattr->ia_gid, inode->i_gid))) {
		rc = dquot_transfer(&init_user_ns, inode, iattr);
		rc = dquot_transfer(&nop_mnt_idmap, inode, iattr);
		if (rc)
			return rc;
	}
Loading