From: Dave Chinner <david@fromorbit.com>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: linux-fsdevel@vger.kernel.org,
Linux Containers <containers@lists.linux-foundation.org>,
linux-kernel@vger.kernel.org,
"Serge E. Hallyn" <serge@hallyn.com>, Ben Myers <bpm@sgi.com>,
Alex Elder <elder@kernel.org>
Subject: Re: [PATCH review 02/16] xfs: Store projectid as a single variable.
Date: Tue, 19 Feb 2013 11:36:08 +1100 [thread overview]
Message-ID: <20130219003608.GF26694@dastard> (raw)
In-Reply-To: <1361149870-27732-2-git-send-email-ebiederm@xmission.com>
On Sun, Feb 17, 2013 at 05:10:55PM -0800, Eric W. Biederman wrote:
> From: "Eric W. Biederman" <ebiederm@xmission.com>
>
> xfs_get_projid is torturous to read and it will not work at all when
> project ids are stored in a kprojid_t. So add a i_projid to
> xfs_inode, that is cheap to read and can handle future needs, and
> update all callers of xfs_get_projid to use i_projid.
>
> Retain xfs_set_projid to handle the needed double updates, as there
> are now two places the value needs to be set.
>
> In xfs_iread after filling in i_d drom the on-disk inode update the
> new i_projid field.
>
> Cc: Ben Myers <bpm@sgi.com>
> Cc: Alex Elder <elder@kernel.org>
> Cc: Dave Chinner <david@fromorbit.com>
> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
> ---
> fs/xfs/xfs_icache.c | 2 +-
> fs/xfs/xfs_inode.c | 6 +++++-
> fs/xfs/xfs_inode.h | 7 ++-----
> fs/xfs/xfs_ioctl.c | 6 +++---
> fs/xfs/xfs_iops.c | 2 +-
> fs/xfs/xfs_itable.c | 4 ++--
> fs/xfs/xfs_qm.c | 10 +++++-----
> fs/xfs/xfs_qm_bhv.c | 2 +-
> fs/xfs/xfs_rename.c | 2 +-
> fs/xfs/xfs_vnodeops.c | 6 +++---
> 10 files changed, 24 insertions(+), 23 deletions(-)
>
> diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
> index 96e344e..4f109ca 100644
> --- a/fs/xfs/xfs_icache.c
> +++ b/fs/xfs/xfs_icache.c
> @@ -1210,7 +1210,7 @@ xfs_inode_match_id(
> return 0;
>
> if (eofb->eof_flags & XFS_EOF_FLAGS_PRID &&
> - xfs_get_projid(ip) != eofb->eof_prid)
> + ip->i_projid != eofb->eof_prid)
> return 0;
Please retain the xfs_get_projid(ip) wrapper and do all the
necessary conversions via that wrapper. We don't need a second copy
of the project ID to support namespace aware project ID support.
> return 1;
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 66282dc..51c2597 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -1013,6 +1013,10 @@ xfs_iread(
> */
> if (dip->di_mode) {
> xfs_dinode_from_disk(&ip->i_d, dip);
> +
> + ip->i_projid = ((projid_t)ip->i_d.di_projid_hi << 16) |
> + ip->i_d.di_projid_lo;
> +
This does not belong here. At minimum, it would need to be in
xfs_iformat(). Further, if there is a requirement it is initialised
correctly, it needs to be zeroed in xfs_inode_alloc() where we pull
a newly allocated inode out of the slab.
As it is, however, having read further through the patches, I can't
really see why we need even need a separate variable - the
conversions shoul dbe done at the edge of the filesystem (i.e. VFS
and ioctl interfaces, and the core of the filesystem left completely
untouched.
> static inline void
> xfs_set_projid(struct xfs_inode *ip,
> prid_t projid)
> {
> + ip->i_projid = projid;
> ip->i_d.di_projid_hi = (__uint16_t) (projid >> 16);
> ip->i_d.di_projid_lo = (__uint16_t) (projid & 0xffff);
> }
As all you are doing is introduing a requirement that we keep two
variables in sync and increase the size of the struct xfs_inode
unnecessarily. History says this sort of duplication is a source of
subtle bugs....
> diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> index 2ea7d40..cf5b1d0 100644
> --- a/fs/xfs/xfs_itable.c
> +++ b/fs/xfs/xfs_itable.c
> @@ -91,8 +91,8 @@ xfs_bulkstat_one_int(
> * further change.
> */
> buf->bs_nlink = dic->di_nlink;
> - buf->bs_projid_lo = dic->di_projid_lo;
> - buf->bs_projid_hi = dic->di_projid_hi;
> + buf->bs_projid_lo = (u16)(ip->i_projid & 0xffff);
> + buf->bs_projid_hi = (u16)(ip->i_projid >> 16);
There is no need for this change at all. Even if we have a second
variable, the two are in sync and of reading from the dic is
perfectly OK.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2013-02-19 0:36 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-18 1:04 [PATCH review 00/16] userns: Completion of kuid/kgid/kprojid pushdown Eric W. Biederman
[not found] ` <87txpaph4n.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2013-02-18 1:10 ` [PATCH review 01/16] xfs: Convert uids and gids in xfs acls to/from kuids and kgids Eric W. Biederman
[not found] ` <1361149870-27732-1-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2013-02-18 1:10 ` [PATCH review 02/16] xfs: Store projectid as a single variable Eric W. Biederman
2013-02-19 0:36 ` Dave Chinner [this message]
2013-02-18 1:10 ` [PATCH review 03/16] xfs: Always read uids and gids from the vfs inode Eric W. Biederman
[not found] ` <1361149870-27732-3-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2013-02-19 1:14 ` Dave Chinner
2013-02-18 1:10 ` [PATCH review 04/16] xfs: Update inode uids, gids, and projids to be kuids, kgids, and kprojids Eric W. Biederman
2013-02-18 1:10 ` [PATCH review 05/16] xfs: Update xfs_ioctl_setattr to handle projids in any user namespace Eric W. Biederman
[not found] ` <1361149870-27732-5-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2013-02-19 1:55 ` Dave Chinner
2013-07-29 7:17 ` Gao feng
2013-07-29 7:51 ` Dave Chinner
2013-07-30 3:15 ` Gao feng
[not found] ` <51F72FE6.4080202-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2013-07-30 3:57 ` Dave Chinner
2013-07-30 4:04 ` Gao feng
2013-02-18 1:10 ` [PATCH review 06/16] xfs: Use kuids and kgids in xfs_setattr_nonsize Eric W. Biederman
2013-02-18 1:11 ` [PATCH review 07/16] xfs: Update ioctl(XFS_IOC_FREE_EOFBLOCKS) to handle callers in any userspace Eric W. Biederman
[not found] ` <1361149870-27732-7-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2013-02-19 1:48 ` Dave Chinner
2013-02-18 1:11 ` [PATCH review 11/16] xfs: Modify xfs_qm_dqget to take a struct kqid Eric W. Biederman
2013-02-18 1:11 ` [PATCH review 13/16] xfs: Use q_id instead of q_core.d_id Eric W. Biederman
2013-02-18 1:11 ` [PATCH review 14/16] xfs: Enable building with user namespaces enabled Eric W. Biederman
2013-02-18 1:11 ` [PATCH review 08/16] xfs: Use kprojids when allocating inodes Eric W. Biederman
[not found] ` <1361149870-27732-8-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2013-02-19 1:31 ` Dave Chinner
2013-02-18 1:11 ` [PATCH review 09/16] xfs: Modify xfs_qm_vop_dqalloc to take kuids, kgids, and kprojids Eric W. Biederman
[not found] ` <1361149870-27732-9-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2013-02-19 1:57 ` Dave Chinner
2013-02-18 1:11 ` [PATCH review 10/16] xfs: Push struct kqid into xfs_qm_scall_qmlim and xfs_qm_scall_getquota Eric W. Biederman
[not found] ` <1361149870-27732-10-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2013-02-19 2:27 ` Dave Chinner
2013-02-18 1:11 ` [PATCH review 12/16] xfs: Remember the kqid for a quota Eric W. Biederman
2013-02-18 1:11 ` [PATCH review 15/16] userns: Now that everything has been converted remove the unnecessary infrastructure Eric W. Biederman
2013-02-18 1:11 ` [PATCH review 16/16] userns: Remove the EXPERMINTAL kconfig tag Eric W. Biederman
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=20130219003608.GF26694@dastard \
--to=david@fromorbit.com \
--cc=bpm@sgi.com \
--cc=containers@lists.linux-foundation.org \
--cc=ebiederm@xmission.com \
--cc=elder@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=serge@hallyn.com \
/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;
as well as URLs for NNTP newsgroup(s).