All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: djwong@kernel.org
Cc: Christoph Hellwig <hch@lst.de>,
	Christian Brauner <christian.brauner@ubuntu.com>,
	linux-xfs@vger.kernel.org, hch@lst.de, dchinner@redhat.com,
	christian.brauner@ubuntu.com
Subject: [PATCH 1/4] xfs: fix quota accounting when a mount is idmapped
Date: Sun, 07 Mar 2021 12:25:46 -0800	[thread overview]
Message-ID: <161514874609.698643.4736582270457949683.stgit@magnolia> (raw)
In-Reply-To: <161514874040.698643.2749449122589431232.stgit@magnolia>

From: Darrick J. Wong <djwong@kernel.org>

Nowadays, we indirectly use the idmap-aware helper functions in the VFS
to set the initial uid and gid of a file being created.  Unfortunately,
we didn't convert the quota code, which means we attach the wrong dquots
to files created on an idmapped mount.

Fixes: f736d93d76d3 ("xfs: support idmapped mounts")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
---
 fs/xfs/xfs_inode.c   |   14 ++++++++------
 fs/xfs/xfs_symlink.c |    3 ++-
 2 files changed, 10 insertions(+), 7 deletions(-)


diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 46a861d55e48..f93370bd7b1e 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1007,9 +1007,10 @@ xfs_create(
 	/*
 	 * Make sure that we have allocated dquot(s) on disk.
 	 */
-	error = xfs_qm_vop_dqalloc(dp, current_fsuid(), current_fsgid(), prid,
-					XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT,
-					&udqp, &gdqp, &pdqp);
+	error = xfs_qm_vop_dqalloc(dp, fsuid_into_mnt(mnt_userns),
+			fsgid_into_mnt(mnt_userns), prid,
+			XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT,
+			&udqp, &gdqp, &pdqp);
 	if (error)
 		return error;
 
@@ -1157,9 +1158,10 @@ xfs_create_tmpfile(
 	/*
 	 * Make sure that we have allocated dquot(s) on disk.
 	 */
-	error = xfs_qm_vop_dqalloc(dp, current_fsuid(), current_fsgid(), prid,
-				XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT,
-				&udqp, &gdqp, &pdqp);
+	error = xfs_qm_vop_dqalloc(dp, fsuid_into_mnt(mnt_userns),
+			fsgid_into_mnt(mnt_userns), prid,
+			XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT,
+			&udqp, &gdqp, &pdqp);
 	if (error)
 		return error;
 
diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
index 1379013d74b8..7f368b10ded1 100644
--- a/fs/xfs/xfs_symlink.c
+++ b/fs/xfs/xfs_symlink.c
@@ -182,7 +182,8 @@ xfs_symlink(
 	/*
 	 * Make sure that we have allocated dquot(s) on disk.
 	 */
-	error = xfs_qm_vop_dqalloc(dp, current_fsuid(), current_fsgid(), prid,
+	error = xfs_qm_vop_dqalloc(dp, fsuid_into_mnt(mnt_userns),
+			fsgid_into_mnt(mnt_userns), prid,
 			XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT,
 			&udqp, &gdqp, &pdqp);
 	if (error)


  reply	other threads:[~2021-03-07 20:26 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-07 20:25 [PATCHSET v2 0/4] xfs: small fixes for 5.12 Darrick J. Wong
2021-03-07 20:25 ` Darrick J. Wong [this message]
2021-03-07 22:28   ` [PATCH 1/4] xfs: fix quota accounting when a mount is idmapped Dave Chinner
2021-03-07 20:25 ` [PATCH 2/4] xfs: avoid buffer deadlocks when walking fs inodes Darrick J. Wong
2021-03-07 20:36   ` [PATCH v2.1 " Darrick J. Wong
2021-03-07 22:37     ` Dave Chinner
2021-03-08  3:56       ` Darrick J. Wong
2021-03-08  7:56     ` Christoph Hellwig
2021-03-07 20:25 ` [PATCH 3/4] xfs: force log and push AIL to clear pinned inodes when aborting mount Darrick J. Wong
2021-03-07 23:01   ` Dave Chinner
2021-03-08  4:47     ` Darrick J. Wong
2021-03-08  4:48   ` [PATCH v2.1 " Darrick J. Wong
2021-03-08  9:16     ` Christoph Hellwig
2021-03-08 23:42     ` Dave Chinner
2021-03-08  7:53   ` [PATCH " Christoph Hellwig
2021-03-07 20:26 ` [PATCH 4/4] xfs: drop freeze protection when running GETFSMAP Darrick J. Wong
2021-03-07 23:05   ` Dave Chinner
2021-03-08  4:45     ` Darrick J. Wong
2021-03-08  7:55   ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=161514874609.698643.4736582270457949683.stgit@magnolia \
    --to=djwong@kernel.org \
    --cc=christian.brauner@ubuntu.com \
    --cc=dchinner@redhat.com \
    --cc=hch@lst.de \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.