Commit bf3cb394 authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: allow single bulkstat of special inodes

Create a new bulk ireq flag 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.

The reason for adding the ability to query specifically the root
directory inode is that certain programs (xfsdump and xfsrestore) want
to confirm when they've been pointed to the root directory.  The
userspace code assumes the root directory is always the first result
from calling bulkstat with lastino == 0, but this isn't true if the
(initial btree roots + initial AGFL + inode alignment padding) is itself
long enough to be allocated to new inodes if all of those blocks should
happen to be free at the same time.  Rather than make userspace guess
at internal filesystem state, we provide a direct query.
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarAllison Collins <allison.henderson@oracle.com>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
parent 13d59a2a
...@@ -472,7 +472,18 @@ struct xfs_bulk_ireq { ...@@ -472,7 +472,18 @@ struct xfs_bulk_ireq {
*/ */
#define XFS_BULK_IREQ_AGNO (1 << 0) #define XFS_BULK_IREQ_AGNO (1 << 0)
#define XFS_BULK_IREQ_FLAGS_ALL (XFS_BULK_IREQ_AGNO) /*
* Return bulkstat information for a single inode, where @ino value is a
* special value, not a literal inode number. See the XFS_BULK_IREQ_SPECIAL_*
* values below. Not compatible with XFS_BULK_IREQ_AGNO.
*/
#define XFS_BULK_IREQ_SPECIAL (1 << 1)
#define XFS_BULK_IREQ_FLAGS_ALL (XFS_BULK_IREQ_AGNO | \
XFS_BULK_IREQ_SPECIAL)
/* Operate on the root directory inode. */
#define XFS_BULK_IREQ_SPECIAL_ROOT (1)
/* /*
* ioctl structures for v5 bulkstat and inumbers requests * ioctl structures for v5 bulkstat and inumbers requests
......
...@@ -853,6 +853,25 @@ xfs_bulk_ireq_setup( ...@@ -853,6 +853,25 @@ xfs_bulk_ireq_setup(
breq->ocount = 0; breq->ocount = 0;
breq->flags = 0; breq->flags = 0;
/*
* The @ino parameter is a special value, so we must look it up here.
* We're not allowed to have IREQ_AGNO, and we only return one inode
* worth of data.
*/
if (hdr->flags & XFS_BULK_IREQ_SPECIAL) {
if (hdr->flags & XFS_BULK_IREQ_AGNO)
return -EINVAL;
switch (hdr->ino) {
case XFS_BULK_IREQ_SPECIAL_ROOT:
hdr->ino = mp->m_sb.sb_rootino;
break;
default:
return -EINVAL;
}
breq->icount = 1;
}
/* /*
* The IREQ_AGNO flag means that we only want results from a given AG. * The IREQ_AGNO flag means that we only want results from a given AG.
* If @hdr->ino is zero, we start iterating in that AG. If @hdr->ino is * If @hdr->ino is zero, we start iterating in that AG. If @hdr->ino is
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment