public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Chandan Babu R <chandan.babu@oracle.com>
To: djwong@kernel.org
Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org,
	amir73il@gmail.com, leah.rumancik@gmail.com
Subject: [PATCH 5.4 CANDIDATE 03/17] xfs: ensure that the inode uid/gid match values match the icdinode ones
Date: Tue, 11 Apr 2023 09:05:00 +0530	[thread overview]
Message-ID: <20230411033514.58024-4-chandan.babu@oracle.com> (raw)
In-Reply-To: <20230411033514.58024-1-chandan.babu@oracle.com>

From: Christoph Hellwig <hch@lst.de>

commit 3d8f2821502d0b60bac2789d0bea951fda61de0c upstream.

Instead of only synchronizing the uid/gid values in xfs_setup_inode,
ensure that they always match to prepare for removing the icdinode
fields.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
---
 fs/xfs/libxfs/xfs_inode_buf.c | 2 ++
 fs/xfs/xfs_icache.c           | 4 ++++
 fs/xfs/xfs_inode.c            | 8 ++++++--
 fs/xfs/xfs_iops.c             | 3 ---
 4 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index e1faf48eb002..c7e4d51fe975 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -223,7 +223,9 @@ xfs_inode_from_disk(
 
 	to->di_format = from->di_format;
 	to->di_uid = be32_to_cpu(from->di_uid);
+	inode->i_uid = xfs_uid_to_kuid(to->di_uid);
 	to->di_gid = be32_to_cpu(from->di_gid);
+	inode->i_gid = xfs_gid_to_kgid(to->di_gid);
 	to->di_flushiter = be16_to_cpu(from->di_flushiter);
 
 	/*
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index 8e6dc04c14d4..f1451642ce38 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -289,6 +289,8 @@ xfs_reinit_inode(
 	uint64_t	version = inode_peek_iversion(inode);
 	umode_t		mode = inode->i_mode;
 	dev_t		dev = inode->i_rdev;
+	kuid_t		uid = inode->i_uid;
+	kgid_t		gid = inode->i_gid;
 
 	error = inode_init_always(mp->m_super, inode);
 
@@ -297,6 +299,8 @@ xfs_reinit_inode(
 	inode_set_iversion_queried(inode, version);
 	inode->i_mode = mode;
 	inode->i_rdev = dev;
+	inode->i_uid = uid;
+	inode->i_gid = gid;
 	return error;
 }
 
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 891f03a3fd91..99f82bdb3db9 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -806,15 +806,19 @@ xfs_ialloc(
 
 	inode->i_mode = mode;
 	set_nlink(inode, nlink);
-	ip->i_d.di_uid = xfs_kuid_to_uid(current_fsuid());
-	ip->i_d.di_gid = xfs_kgid_to_gid(current_fsgid());
+	inode->i_uid = current_fsuid();
+	ip->i_d.di_uid = xfs_kuid_to_uid(inode->i_uid);
 	inode->i_rdev = rdev;
 	ip->i_d.di_projid = prid;
 
 	if (pip && XFS_INHERIT_GID(pip)) {
+		inode->i_gid = VFS_I(pip)->i_gid;
 		ip->i_d.di_gid = pip->i_d.di_gid;
 		if ((VFS_I(pip)->i_mode & S_ISGID) && S_ISDIR(mode))
 			inode->i_mode |= S_ISGID;
+	} else {
+		inode->i_gid = current_fsgid();
+		ip->i_d.di_gid = xfs_kgid_to_gid(inode->i_gid);
 	}
 
 	/*
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 05adfea93ad9..838acd7f2e47 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -1288,9 +1288,6 @@ xfs_setup_inode(
 	/* make the inode look hashed for the writeback code */
 	inode_fake_hash(inode);
 
-	inode->i_uid    = xfs_uid_to_kuid(ip->i_d.di_uid);
-	inode->i_gid    = xfs_gid_to_kgid(ip->i_d.di_gid);
-
 	i_size_write(inode, ip->i_d.di_size);
 	xfs_diflags_to_iflags(inode, ip);
 
-- 
2.39.1


  parent reply	other threads:[~2023-04-11  3:35 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-11  3:34 [PATCH 5.4 CANDIDATE 00/17] xfs stable candidate patches for 5.4.y (from v5.11 & v5.12) Chandan Babu R
2023-04-11  3:34 ` [PATCH 5.4 CANDIDATE 01/17] xfs: show the proper user quota options Chandan Babu R
2023-04-11  3:34 ` [PATCH 5.4 CANDIDATE 02/17] xfs: merge the projid fields in struct xfs_icdinode Chandan Babu R
2023-04-11  3:35 ` Chandan Babu R [this message]
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 04/17] xfs: remove the icdinode di_uid/di_gid members Chandan Babu R
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 05/17] xfs: remove the kuid/kgid conversion wrappers Chandan Babu R
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 06/17] xfs: add a new xfs_sb_version_has_v3inode helper Chandan Babu R
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 07/17] xfs: only check the superblock version for dinode size calculation Chandan Babu R
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 08/17] xfs: simplify di_flags2 inheritance in xfs_ialloc Chandan Babu R
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 09/17] xfs: simplify a check in xfs_ioctl_setattr_check_cowextsize Chandan Babu R
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 10/17] xfs: remove the di_version field from struct icdinode Chandan Babu R
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 11/17] xfs: fix up non-directory creation in SGID directories Chandan Babu R
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 12/17] xfs: set inode size after creating symlink Chandan Babu R
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 13/17] xfs: report corruption only as a regular error Chandan Babu R
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 14/17] xfs: shut down the filesystem if we screw up quota reservation Chandan Babu R
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 15/17] xfs: consider shutdown in bmapbt cursor delete assert Chandan Babu R
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 16/17] xfs: don't reuse busy extents on extent trim Chandan Babu R
2023-04-11  3:35 ` [PATCH 5.4 CANDIDATE 17/17] xfs: force log and push AIL to clear pinned inodes when aborting mount Chandan Babu R
2023-04-11 18:15 ` [PATCH 5.4 CANDIDATE 00/17] xfs stable candidate patches for 5.4.y (from v5.11 & v5.12) Darrick J. Wong

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=20230411033514.58024-4-chandan.babu@oracle.com \
    --to=chandan.babu@oracle.com \
    --cc=amir73il@gmail.com \
    --cc=djwong@kernel.org \
    --cc=leah.rumancik@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox