From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com ([209.132.183.28]:35996 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726977AbfGCNZ2 (ORCPT ); Wed, 3 Jul 2019 09:25:28 -0400 Date: Wed, 3 Jul 2019 09:25:25 -0400 From: Brian Foster Subject: Re: [PATCH 9/9] xfs: allow bulkstat_single of special inodes Message-ID: <20190703132525.GI26057@bfoster> References: <156158193320.495715.6675123051075804739.stgit@magnolia> <156158199168.495715.1433536766420003523.stgit@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <156158199168.495715.1433536766420003523.stgit@magnolia> Sender: linux-xfs-owner@vger.kernel.org List-ID: List-Id: xfs To: "Darrick J. Wong" Cc: linux-xfs@vger.kernel.org, allison.henderson@oracle.com On Wed, Jun 26, 2019 at 01:46:31PM -0700, Darrick J. Wong wrote: > From: Darrick J. Wong > > Create a new ireq flag (for single bulkstats) that enables userspace to > ask us for a special inode number instead of interpreting @ino as a > literal inode number. This enables us to query the root inode easily. > Seems reasonable, though what's the use case for this? A brief description in the commit log would be helpful. > Signed-off-by: Darrick J. Wong > Reviewed-by: Allison Collins > --- > fs/xfs/libxfs/xfs_fs.h | 11 ++++++++++- > fs/xfs/xfs_ioctl.c | 10 ++++++++++ > 2 files changed, 20 insertions(+), 1 deletion(-) > > > diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h > index 77c06850ac52..1489bce07d66 100644 > --- a/fs/xfs/libxfs/xfs_fs.h > +++ b/fs/xfs/libxfs/xfs_fs.h > @@ -482,7 +482,16 @@ struct xfs_ireq { > uint64_t reserved[2]; /* must be zero */ > }; > > -#define XFS_IREQ_FLAGS_ALL (0) > +/* > + * The @ino value is a special value, not a literal inode number. See the > + * XFS_IREQ_SPECIAL_* values below. > + */ > +#define XFS_IREQ_SPECIAL (1 << 0) > + > +#define XFS_IREQ_FLAGS_ALL (XFS_IREQ_SPECIAL) > + > +/* Operate on the root directory inode. */ > +#define XFS_IREQ_SPECIAL_ROOT (1) > > /* > * ioctl structures for v5 bulkstat and inumbers requests > diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c > index f71341cd8340..3bb5f980fabf 100644 > --- a/fs/xfs/xfs_ioctl.c > +++ b/fs/xfs/xfs_ioctl.c > @@ -961,6 +961,16 @@ xfs_ireq_setup( > memchr_inv(hdr->reserved, 0, sizeof(hdr->reserved))) > return -EINVAL; > > + if (hdr->flags & XFS_IREQ_SPECIAL) { > + switch (hdr->ino) { > + case XFS_IREQ_SPECIAL_ROOT: > + hdr->ino = mp->m_sb.sb_rootino; > + break; Do you envision other ->ino magic values? I'm curious about the need for the special flag along with a magic inode value as opposed to just a "root dir" flag or some such. Brian > + default: > + return -EINVAL; > + } > + } > + > if (XFS_INO_TO_AGNO(mp, hdr->ino) >= mp->m_sb.sb_agcount) > return -EINVAL; > >