aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2019-07-03 23:36:29 -0400
committerDarrick J. Wong <darrick.wong@oracle.com>2019-07-04 10:52:24 -0400
commitbf3cb394479210a9ebcf8fef7a7f8fcabc7b9928 (patch)
treeb1e1742480e6775b16317046b6eec682d8f6ef7d /fs/xfs
parent13d59a2a61cbbb4cda13a0cba6d4d1fc537f5dd4 (diff)
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: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Allison Collins <allison.henderson@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/libxfs/xfs_fs.h13
-rw-r--r--fs/xfs/xfs_ioctl.c19
2 files changed, 31 insertions, 1 deletions
diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h
index d7b3b712b279..52d03a3a02a4 100644
--- a/fs/xfs/libxfs/xfs_fs.h
+++ b/fs/xfs/libxfs/xfs_fs.h
@@ -472,7 +472,18 @@ struct xfs_bulk_ireq {
472 */ 472 */
473#define XFS_BULK_IREQ_AGNO (1 << 0) 473#define XFS_BULK_IREQ_AGNO (1 << 0)
474 474
475#define XFS_BULK_IREQ_FLAGS_ALL (XFS_BULK_IREQ_AGNO) 475/*
476 * Return bulkstat information for a single inode, where @ino value is a
477 * special value, not a literal inode number. See the XFS_BULK_IREQ_SPECIAL_*
478 * values below. Not compatible with XFS_BULK_IREQ_AGNO.
479 */
480#define XFS_BULK_IREQ_SPECIAL (1 << 1)
481
482#define XFS_BULK_IREQ_FLAGS_ALL (XFS_BULK_IREQ_AGNO | \
483 XFS_BULK_IREQ_SPECIAL)
484
485/* Operate on the root directory inode. */
486#define XFS_BULK_IREQ_SPECIAL_ROOT (1)
476 487
477/* 488/*
478 * ioctl structures for v5 bulkstat and inumbers requests 489 * ioctl structures for v5 bulkstat and inumbers requests
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index e1e1d9d6c16d..6bf04e71325b 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -854,6 +854,25 @@ xfs_bulk_ireq_setup(
854 breq->flags = 0; 854 breq->flags = 0;
855 855
856 /* 856 /*
857 * The @ino parameter is a special value, so we must look it up here.
858 * We're not allowed to have IREQ_AGNO, and we only return one inode
859 * worth of data.
860 */
861 if (hdr->flags & XFS_BULK_IREQ_SPECIAL) {
862 if (hdr->flags & XFS_BULK_IREQ_AGNO)
863 return -EINVAL;
864
865 switch (hdr->ino) {
866 case XFS_BULK_IREQ_SPECIAL_ROOT:
867 hdr->ino = mp->m_sb.sb_rootino;
868 break;
869 default:
870 return -EINVAL;
871 }
872 breq->icount = 1;
873 }
874
875 /*
857 * The IREQ_AGNO flag means that we only want results from a given AG. 876 * The IREQ_AGNO flag means that we only want results from a given AG.
858 * If @hdr->ino is zero, we start iterating in that AG. If @hdr->ino is 877 * If @hdr->ino is zero, we start iterating in that AG. If @hdr->ino is
859 * beyond the specified AG then we return no results. 878 * beyond the specified AG then we return no results.