xfsprogs: Introduce a new subcommand agstate to xfs_fio
PATCH 1/2 xfsprogs: Introduce a new subcommand agstate to xfs_fio
Introduce a new xfs_io command: agstate.
This command is used to get/set state for a given allocation group.
--- include/xfs_ag.h | 32 ++++++++++++++++++++++++++++---- include/xfs_fs.h | 2 ++ io/Makefile | 2 +- io/init.c | 1 + 4 files changed, 32 insertions(+), 5 deletions(-)
include/xfs_ag.h +28 -4
@@ -69,6 +69,10 @@ typedef struct xfs_agf {__be32 agf_freeblks;/* total free blocks */ __be32 agf_longest;/* longest free space */ __be32 agf_btreeblks;/* # of blocks held in AGF btrees */ +/* +* state +*/ +__be32 agf_state;/* persistent a.g. state */ } xfs_agf_t;#define XFS_AGF_MAGICNUM 0x00000001
@@ -83,7 +87,8 @@ typedef struct xfs_agf {#define XFS_AGF_FREEBLKS 0x00000200#define XFS_AGF_LONGEST 0x00000400#define XFS_AGF_BTREEBLKS 0x00000800 -#define XFS_AGF_NUM_BITS 12 +#define XFS_AGF_STATE 0x00001000 +#define XFS_AGF_NUM_BITS 13#define XFS_AGF_ALL_BITS ((1 << XFS_AGF_NUM_BITS) - 1)#define XFS_AGF_FLAGS \
@@ -98,7 +103,8 @@ typedef struct xfs_agf { { XFS_AGF_FLCOUNT, "FLCOUNT" }, \ { XFS_AGF_FREEBLKS, "FREEBLKS" }, \ { XFS_AGF_LONGEST, "LONGEST" }, \ - { XFS_AGF_BTREEBLKS, "BTREEBLKS" } + { XFS_AGF_BTREEBLKS, "BTREEBLKS" }, \ + { XFS_AGF_STATE, "STATE" } /* disk block (xfs_daddr_t) in the AG */ #define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log))
@@ -184,8 +190,8 @@ typedef struct xfs_agfl {struct xfs_busy_extent {#ifdef __KERNEL__struct rb_node rb_node;/* ag by-bno indexed search tree */ -#endif struct list_head list;/* transaction busy extent list */ +#endif xfs_agnumber_t agno;xfs_agblock_t bno;xfs_extlen_t length;
@@ -197,7 +203,7 @@ struct xfs_busy_extent {* to improve the performance of allocation group selection. */ #define XFS_PAGB_NUM_SLOTS 128 - +typedef int atomic_t ;/* to make compiler happy */ typedef struct xfs_perag { struct xfs_mount *pag_mount; /* owner filesystem */ xfs_agnumber_t pag_agno; /* AG this structure belongs to */
@@ -243,9 +249,27 @@ typedef struct xfs_perag {struct rcu_head rcu_head;#endif int pagb_count;/* pagb slots in use */ +__uint32_t pag_state;/* persistent a.g. state */ } xfs_perag_t;/* +* Structure for ioctl per a.g. state get/set. +*/ +typedef struct xfs_ioc_agstate { +xfs_agnumber_t agno; +__uint32_t state; +}xfs_ioc_agstate_t ; + +/* +* Skip an AG with below state for inodes/blocks allocation. +*/ +#define XFS_AG_STATE_ALLOC_DENY (1 << 0) +extern int xfs_get_agstate (struct xfs_mount *mp, +struct xfs_ioc_agstate *agstate); +extern int xfs_set_agstate (struct xfs_mount *mp, +struct xfs_ioc_agstate *agstate); + +/* * tags for inode radix tree */ #define XFS_ICI_NO_TAG (-1)/* special flag for an untagged lookup
include/xfs_fs.h +2 -0
@@ -483,6 +483,8 @@ typedef struct xfs_handle {#define XFS_IOC_ATTRMULTI_BY_HANDLE _IOW ('X', 123, struct xfs_fsop_attrmulti_handlereq)#define XFS_IOC_FSGEOMETRY _IOR ('X', 124, struct xfs_fsop_geom)#define XFS_IOC_GOINGDOWN _IOR ('X', 125, __uint32_t) +#define XFS_IOC_SET_AGSTATE _IOW ('X', 126, struct xfs_ioc_agstate) +#define XFS_IOC_GET_AGSTATE _IOR ('X', 127, struct xfs_ioc_agstate)/* XFS_IOC_GETFSUUID ---------- deprecated 140 */
io/Makefile +1 -1
@@ -9,7 +9,7 @@ LTCOMMAND = xfs_io LSRCFILES = xfs_bmap.sh xfs_freeze.sh xfs_mkfile.sh HFILES = init.h io.h CFILES = init.c \ - attr.c bmap.c file.c freeze.c fsync.c getrusage.c imap.c mmap.c \ + agstate.c attr.c bmap.c file.c freeze.c fsync.c getrusage.c imap.c mmap.c \ open.c parent.c pread.c prealloc.c pwrite.c shutdown.c truncate.c LLDLIBS = $(LIBXCMD) $(LIBHANDLE)
io/init.c +1 -0
@@ -54,6 +54,7 @@ init_cvtnum(static void init_commands (void ) { +agstate_init ();attr_init ();bmap_init ();fadvise_init ();
Signature · 6 lines
1.7.9.5 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 3 lines · Jeff Liu
Introduce a new
xfs_iocommand: agstate.This command is used to get/set state for a given allocation group.
xfs_io is not the place for this command.
A couple of weeks ago I started writing an xfs_spaceman module and an ioctl interface for exactly this purpose, I just hadn't got around to completing it and the kernel patch to test it so I hadn't posted it. Once the userspace release is out of the way, I'll post the patches to get xfs_spaceman into xfs_progs, and we can use that for this AG control from the start.
The reason for this is that the AG state in future is going to be a lot more complex than just enabling/disabling allocation, and the ioctl interface I prototyped supports a lot of that future functionality.
The patch is below so you can see what sort of AG control/state functionality I think we'll be needing sooner rather than later, and the interface I think we should be using...
Quoted 7 lines
Signed-off-by Jie Liu <[email protected]>--- include/xfs_ag.h | 32 ++++++++++++++++++++++++++++---- include/xfs_fs.h | 2 ++ io/Makefile | 2 +- io/init.c | 1 + 4 files changed, 32 insertions(+), 5 deletions(-)
FWIW, I think you forgot to include the file that introduces the command in the patch :)
Cheers,
Dave.
Signature · 18 lines
Dave Chinner [email protected] spaceman: AG state control From: Dave Chinner <[email protected]> Add support for a new allocation group state control ioctl. This allows control of various AG parameters, such as whether inode allocation is allowed in the AG, metadata preference, whether new allocations are allowed, etc. This requires a new ioctl. Signed-off-by: Dave Chinner <[email protected]> --- spaceman/Makefile | 2 +- spaceman/ag.c | 221 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 222 insertions(+), 1 deletion(-)
spaceman/Makefile +1 -1
@@ -8,7 +8,7 @@ include $(TOPDIR)/include/builddefs LTCOMMAND = xfs_spaceman HFILES = init.h space.h CFILES = init.c \ - file.c freesp.c prealloc.c trim.c + ag.c file.c freesp.c prealloc.c trim.c LLDLIBS = $(LIBXCMD) LTDEPENDENCIES = $(LIBXCMD)
spaceman/ag.c new file +221 -0
221 lines not on this page · raw message
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 6 lines · Dave Chinner
Quoted 3 lines · Jeff Liu
Introduce a new
xfs_iocommand: agstate.This command is used to get/set state for a given allocation group.
xfs_iois not the place for this command.
I was also wonder why we place the agflags command on there since xfs_io is aimed at examining the regular file I/O paths, but I can not found out a better place while implementing it.
Quoted 8 lines
A couple of weeks ago I started writing an
xfs_spacemanmodule and an ioctl interface for exactly this purpose, I just hadn't got around to completing it and the kernel patch to test it so I hadn't posted it. Once the userspace release is out of the way, I'll post the patches to getxfs_spacemanintoxfs_progs, and we can use that for this AG control from the start.
Quoted 4 lines
The reason for this is that the AG state in future is going to be a lot more complex than just enabling/disabling allocation, and the ioctl interface I prototyped supports a lot of that future functionality.
Definitely, so that we can have fine-granted AG controls, that's why I didn't chose to re-base/post the previous agflags patch but proposed the agstate command because the naming would sounds more reasonable.
Quoted 4 lines
The patch is below so you can see what sort of AG control/state functionality I think we'll be needing sooner rather than later, and the interface I think we should be using...
Ok, I'll waiting for this feature. :)
BTW, Does it sounds make sense if we implement parent pointer support at first?
http://www.xfs.org/index.php/Unfinished_work#Parent_Pointers.2FCreate.2BEA
I propose this because it would reduce many efforts for implementing xfs_shrinkfs command, and reduce the overhead for iterating overall file systems to find out files which are located at offline AGs.
Quoted 11 lines
Quoted 8 lines
Signed-off-by Jie Liu <[email protected]>--- include/xfs_ag.h | 32 ++++++++++++++++++++++++++++---- include/xfs_fs.h | 2 ++ io/Makefile | 2 +- io/init.c | 1 + 4 files changed, 32 insertions(+), 5 deletions(-)FWIW, I think you forgot to include the file that introduces the command in the patch :)
Oops! sorry for the mistake.
Thanks,
-Jeff
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 10 lines · Jeff Liu
Quoted 6 lines · Dave Chinner
Quoted 3 lines · Jeff Liu
Introduce a new
xfs_iocommand: agstate.This command is used to get/set state for a given allocation group.
xfs_iois not the place for this command.I was also wonder why we place the agflags command on there since
xfs_iois aimed at examining the regular file I/O paths, but I can not found out a better place while implementing it.
Right. That's exactly why I'm adding the xfs_spaceman command :)
Quoted 7 lines
Quoted 7 lines
A couple of weeks ago I started writing an
xfs_spacemanmodule and an ioctl interface for exactly this purpose, I just hadn't got around to completing it and the kernel patch to test it so I hadn't posted it. Once the userspace release is out of the way, I'll post the patches to getxfs_spacemanintoxfs_progs, and we can use that for this AG control from the start.
Quoted 8 lines
Quoted 4 lines
The reason for this is that the AG state in future is going to be a lot more complex than just enabling/disabling allocation, and the ioctl interface I prototyped supports a lot of that future functionality.
Definitely, so that we can have fine-granted AG controls, that's why I didn't chose to re-base/post the previous agflags patch but proposed the agstate command because the naming would sounds more reasonable.
*nod*
Quoted 6 lines
Quoted 4 lines
The patch is below so you can see what sort of AG control/state functionality I think we'll be needing sooner rather than later, and the interface I think we should be using...
Ok, I'll waiting for this feature. :)
Quoted 7 lines
BTW, Does it sounds make sense if we implement parent pointer support at first?
http://www.xfs.org/index.php/Unfinished_work#Parent_Pointers.2FCreate.2BEA
I propose this because it would reduce many efforts for implementingxfs_shrinkfscommand, and reduce the overhead for iterating overall file systems to find out files which are located at offline AGs.
That does need to be completed, though it's more of an optimisation for the shrink process than absolutely necessary functionality. Similarly for the rmap allocation btree (tracks used space and it's owner) that I'm also working on. Being able to walk the used space in an AG directly and immediately resolve the owner without a directory tree walk or inode scan will make things ever faster....
Hence I think just having shrink dumb and slow as a first step is just fine and speed can wait until we have all the necessary infrastructure in place.
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs