Re: [PATCH 14/27] xfs: cleanup shortform directory inode number handling

Dave Chinner
2011-06-30T06:35:17Z

On Wed, Jun 29, 2011 at 10:01:23AM -0400, Christoph Hellwig wrote:
> Refactor the shortform directory helpers that deal with the 32-bit vs
> 64-bit wide inode numbers into more sensible helpers, and kill the
> xfs_intino_t typedef that is now superflous.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

A few consistency things, and a bit whitespacy, otherwise:

Reviewed-by: Dave Chinner <dchinner@redhat.com>

>
> Index: xfs/fs/xfs/xfs_dir2_sf.c
> ===================================================================
> --- xfs.orig/fs/xfs/xfs_dir2_sf.c 2010-05-25 11:40:59.357006075 +0200
> +++ xfs/fs/xfs/xfs_dir2_sf.c 2010-05-27 14:48:16.709004470 +0200
> @@ -59,6 +59,83 @@ static void xfs_dir2_sf_toino4(xfs_da_ar
> static void xfs_dir2_sf_toino8(xfs_da_args_t *args);
> #endif /* XFS_BIG_INUMS */
>
> +
> +/*
> + * Inode numbers in short-form directories can come in two versions,
> + * either 4 bytes or 8 bytes wide. These helpers deal with the
> + * two forms transparently by looking at the headers i8count field.
> + */
> +
> +static xfs_ino_t

Extra line there...

> +xfs_dir2_sf_get_ino(
> + struct xfs_dir2_sf *sfp,
> + xfs_dir2_inou_t *from)
> +{
> + if (sfp->hdr.i8count)
> + return XFS_GET_DIR_INO8(from->i8);
> + else
> + return XFS_GET_DIR_INO4(from->i4);
> +}
> +static void

And none there.

> +xfs_dir2_sf_put_inumber(
> + struct xfs_dir2_sf *sfp,
> + xfs_dir2_inou_t *to,
> + xfs_ino_t ino)
> +{
> + if (sfp->hdr.i8count)
> + XFS_PUT_DIR_INO8(ino, to->i8);
> + else
> + XFS_PUT_DIR_INO4(ino, to->i4);
> +}

Also, xfs_dir2_sf_get_ino() vs xfs_dir2_sf_put_inumber() - either
use _ino or _inumber as the suffix for both. _ino is probably more
consistent with the other functions...

> +
> +xfs_ino_t
> +xfs_dir2_sf_get_parent_ino(
> + struct xfs_dir2_sf *sfp)
> +{
> + return xfs_dir2_sf_get_ino(sfp, &sfp->hdr.parent);
> +}
> +
> +

Extra whitespace.

> +static void
> +xfs_dir2_sf_put_parent_ino(
> + struct xfs_dir2_sf *sfp,
> + xfs_ino_t ino)
> +{
> + xfs_dir2_sf_put_inumber(sfp, &sfp->hdr.parent, ino);
> +}
> +
> +

Extra whitespace.

> +/*
> + * In short-form directory entries the inode numbers are stored at variable
> + * offset behind the entry name. The inode numbers may only be accessed
> + * through the helpers below.
> + */
> +

Extra whitespace.

> +static xfs_dir2_inou_t *
> +xfs_dir2_sf_inop(
> + struct xfs_dir2_sf_entry *sfep)
> +{
> + return (xfs_dir2_inou_t *)&sfep->name[sfep->namelen];
> +}

Probably should be called xfs_dir2_sfe_inop() because it takes a
xfs_dir2_sf_entry, similar to the following functions use "sfe".

> +
> +xfs_ino_t
> +xfs_dir2_sfe_get_ino(
> + struct xfs_dir2_sf *sfp,
> + struct xfs_dir2_sf_entry *sfep)
> +{
> + return xfs_dir2_sf_get_ino(sfp, xfs_dir2_sf_inop(sfep));
> +}
> +
> +static void
> +xfs_dir2_sfe_put_ino(
> + struct xfs_dir2_sf *sfp,
> + struct xfs_dir2_sf_entry *sfep,
> + xfs_ino_t ino)
> +{
> + xfs_dir2_sf_put_inumber(sfp, xfs_dir2_sf_inop(sfep), ino);
> +}
> +
> +

Extra whitespace.

--
Dave Chinner
david@fromorbit.com