lkml.org 
[lkml]   [2013]   [Feb]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH review 02/16] xfs: Store projectid as a single variable.
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


\
 
 \ /
  Last update: 2013-02-19 02:22    [W:0.185 / U:0.568 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site