aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2024-01-09 09:40:35 -0800
committerDarrick J. Wong <djwong@kernel.org>2024-05-10 17:22:24 -0700
commit9d1b51127a34c9aae094f47ff3fbd83ea9173802 (patch)
tree6acb809c7525d9cb876702b92c5f0566452d269a
parent55f4d521716132b70fe178a13f21dd2953e289a3 (diff)
downloadxfsprogs-dev-noalloc-ags.tar.gz
xfs_io: enhance the aginfo command to control the noalloc flagnoalloc-ags_2024-05-10noalloc-ags
Augment the aginfo command to be able to set and clear the noalloc state for an AG. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
-rw-r--r--io/aginfo.c45
-rw-r--r--man/man8/xfs_io.86
2 files changed, 45 insertions, 6 deletions
diff --git a/io/aginfo.c b/io/aginfo.c
index 43e0e9c21b..8345d25c55 100644
--- a/io/aginfo.c
+++ b/io/aginfo.c
@@ -19,9 +19,11 @@ static cmdinfo_t rginfo_cmd;
static int
report_aginfo(
struct xfs_fd *xfd,
- xfs_agnumber_t agno)
+ xfs_agnumber_t agno,
+ int oflag)
{
struct xfs_ag_geometry ageo = { 0 };
+ bool update = false;
int ret;
ret = -xfrog_ag_geometry(xfd->fd, agno, &ageo);
@@ -30,6 +32,26 @@ report_aginfo(
return 1;
}
+ switch (oflag) {
+ case 0:
+ ageo.ag_flags |= XFS_AG_FLAG_UPDATE;
+ ageo.ag_flags &= ~XFS_AG_FLAG_NOALLOC;
+ update = true;
+ break;
+ case 1:
+ ageo.ag_flags |= (XFS_AG_FLAG_UPDATE | XFS_AG_FLAG_NOALLOC);
+ update = true;
+ break;
+ }
+
+ if (update) {
+ ret = -xfrog_ag_geometry(xfd->fd, agno, &ageo);
+ if (ret) {
+ xfrog_perror(ret, "aginfo update");
+ return 1;
+ }
+ }
+
printf(_("AG: %u\n"), ageo.ag_number);
printf(_("Blocks: %u\n"), ageo.ag_length);
printf(_("Free Blocks: %u\n"), ageo.ag_freeblks);
@@ -51,6 +73,7 @@ aginfo_f(
struct xfs_fd xfd = XFS_FD_INIT(file->fd);
unsigned long long x;
xfs_agnumber_t agno = NULLAGNUMBER;
+ int oflag = -1;
int c;
int ret = 0;
@@ -61,7 +84,7 @@ aginfo_f(
return 1;
}
- while ((c = getopt(argc, argv, "a:")) != EOF) {
+ while ((c = getopt(argc, argv, "a:o:")) != EOF) {
switch (c) {
case 'a':
errno = 0;
@@ -74,16 +97,27 @@ aginfo_f(
}
agno = x;
break;
+ case 'o':
+ errno = 0;
+ x = strtoll(optarg, NULL, 10);
+ if (!errno && x != 0 && x != 1)
+ errno = ERANGE;
+ if (errno) {
+ perror("aginfo");
+ return 1;
+ }
+ oflag = x;
+ break;
default:
return command_usage(&aginfo_cmd);
}
}
if (agno != NULLAGNUMBER) {
- ret = report_aginfo(&xfd, agno);
+ ret = report_aginfo(&xfd, agno, oflag);
} else {
for (agno = 0; !ret && agno < xfd.fsgeom.agcount; agno++) {
- ret = report_aginfo(&xfd, agno);
+ ret = report_aginfo(&xfd, agno, oflag);
}
}
@@ -98,6 +132,7 @@ aginfo_help(void)
"Report allocation group geometry.\n"
"\n"
" -a agno -- Report on the given allocation group.\n"
+" -o state -- Change the NOALLOC state for this allocation group.\n"
"\n"));
}
@@ -107,7 +142,7 @@ static cmdinfo_t aginfo_cmd = {
.cfunc = aginfo_f,
.argmin = 0,
.argmax = -1,
- .args = "[-a agno]",
+ .args = "[-a agno] [-o state]",
.flags = CMD_NOMAP_OK,
.help = aginfo_help,
};
diff --git a/man/man8/xfs_io.8 b/man/man8/xfs_io.8
index 0b1a32e956..d669a9f71c 100644
--- a/man/man8/xfs_io.8
+++ b/man/man8/xfs_io.8
@@ -1237,7 +1237,7 @@ for the current memory mapping.
.SH FILESYSTEM COMMANDS
.TP
-.BI "aginfo [ \-a " agno " ]"
+.BI "aginfo [ \-a " agno " ] [ \-o " nr " ]"
Show information about or update the state of allocation groups.
.RE
.RS 1.0i
@@ -1245,6 +1245,10 @@ Show information about or update the state of allocation groups.
.TP
.BI \-a
Act only on a specific allocation group.
+.TP
+.BI \-o
+If 0, clear the NOALLOC flag.
+If 1, set the NOALLOC flag.
.PD
.RE