Re: [PATCH 01/22] xfs: query the per-AG reservation counters

Darrick J. Wong
2017-07-24T19:07:11Z

On Mon, Jul 24, 2017 at 08:25:16AM +1000, Dave Chinner wrote:
> On Thu, Jul 20, 2017 at 09:38:35PM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> >
> > Establish an ioctl for userspace to query the original and current
> > per-AG reservation counts. This will be used by xfs_scrub to
> > check that the vfs counters are at least somewhat sane.
> >
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> > fs/xfs/libxfs/xfs_fs.h | 10 ++++++++++
> > fs/xfs/xfs_fsops.c | 29 +++++++++++++++++++++++++++++
> > fs/xfs/xfs_fsops.h | 2 ++
> > fs/xfs/xfs_ioctl.c | 16 ++++++++++++++++
> > fs/xfs/xfs_ioctl32.c | 1 +
> > 5 files changed, 58 insertions(+)
> >
> >
> > diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h
> > index 8c61f21..5dedab9 100644
> > --- a/fs/xfs/libxfs/xfs_fs.h
> > +++ b/fs/xfs/libxfs/xfs_fs.h
> > @@ -469,6 +469,15 @@ typedef struct xfs_swapext
> > #define XFS_FSOP_GOING_FLAGS_NOLOGFLUSH 0x2 /* don't flush log nor data */
> >
> > /*
> > + * AG reserved block counters
> > + */
> > +struct xfs_fsop_ag_resblks {
> > + __u64 resblks; /* blocks reserved now */
>
> current_reservation
>
> > + __u64 resblks_orig; /* blocks reserved at mount time */
>
> mount_reservation;
>
> > + __u64 reserved[2];

So long as I'm going to add a flags field I might as well bump this
whole structure up to a full 64 bytes.

struct xfs_fsop_ag_resblks {
__u32 flags; /* output flags, none defined now */
__u32 reserved; /* zero */
__u64 current_resv; /* blocks reserved now */
__u64 mount_resv; /* blocks reserved at mount time */
__u64 reserved[5]; /* zero */
};

> > +};
>
> Also, any new structure we pass to userspace should be versioned
> from the start. At minimum, a flags field so we can, in future, tell
> userspace what the reserved space means in future.

Will do.

> > +
> > +/* Query the per-AG reservations to see how many blocks we have reserved. */
> > +int
> > +xfs_fs_get_ag_reserve_blocks(
> > + struct xfs_mount *mp,
> > + struct xfs_fsop_ag_resblks *out)
> > +{
> > + struct xfs_ag_resv *r;
> > + struct xfs_perag *pag;
> > + xfs_agnumber_t agno;
> > +
> > + out->resblks = 0;
> > + out->resblks_orig = 0;
> > + out->reserved[0] = out->reserved[1] = 0;
>
> memset() the structure so we don't forget in future to zero it
> properly.

Ok.

--D

>
> Cheers,
>
> Dave.
> --
> Dave Chinner
> david@fromorbit.com
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html