* [PATCH] xfs_db: add alignment filter to freesp command
@ 2016-11-17 23:19 Eric Sandeen
2016-11-18 12:54 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Eric Sandeen @ 2016-11-17 23:19 UTC (permalink / raw)
To: linux-xfs
This adds an alignment filter to the xfs_db freesp command, i.e.
xfs_db> freesp -A 4
will show only 4-block aligned free extents.
This can be useful for finding freespace suitable for allocations
with specific alignment requirements, such as inode allocation.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
diff --git a/db/freesp.c b/db/freesp.c
index 27e9f5a..c3ca2f3 100644
--- a/db/freesp.c
+++ b/db/freesp.c
@@ -54,6 +54,7 @@ static int usage(void);
static int agcount;
static xfs_agnumber_t *aglist;
+static int alignment;
static int countflag;
static int dumpflag;
static int equalsize;
@@ -67,7 +68,7 @@ static long long totexts;
static const cmdinfo_t freesp_cmd =
{ "freesp", NULL, freesp_f, 0, -1, 0,
- "[-bcdfs] [-a agno]... [-e binsize] [-h h1]... [-m binmult]",
+ "[-bcdfs] [-A alignment] [-a agno]... [-e binsize] [-h h1]... [-m binmult]",
"summarize free space for filesystem", NULL };
static int
@@ -147,8 +148,11 @@ init(
totblocks = totexts = 0;
aglist = NULL;
hist = NULL;
- while ((c = getopt(argc, argv, "a:bcde:h:m:s")) != EOF) {
+ while ((c = getopt(argc, argv, "A:a:bcde:h:m:s")) != EOF) {
switch (c) {
+ case 'A':
+ alignment = atoi(optarg);
+ break;
case 'a':
aglistadd(optarg);
break;
@@ -372,6 +376,9 @@ addtohist(
{
int i;
+ if (alignment && (XFS_AGB_TO_FSB(mp,agno,agbno) % alignment))
+ return;
+
if (dumpflag)
dbprintf("%8d %8d %8d\n", agno, agbno, len);
totexts++;
diff --git a/man/man8/xfs_db.8 b/man/man8/xfs_db.8
index 460d89d..2c89769 100644
--- a/man/man8/xfs_db.8
+++ b/man/man8/xfs_db.8
@@ -512,12 +512,17 @@ enables processing of realtime control file data.
enables processing of realtime file data.
.RE
.TP
-.BI "freesp [\-bcds] [\-a " ag "] ... [\-e " i "] [\-h " h1 "] ... [\-m " m ]
+.BI "freesp [\-bcds] [\-A " alignment "] [\-a " ag "] ... [\-e " i "] [\-h " h1 "] ... [\-m " m ]
Summarize free space for the filesystem. The free blocks are examined
and totalled, and displayed in the form of a histogram, with a count
of extents in each range of free extent sizes.
.RS 1.0i
.TP 0.4i
+.B \-A
+reports only free extents with starting blocks aligned to
+.I alignment
+blocks.
+.TP
.B \-a
adds
.I ag
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] xfs_db: add alignment filter to freesp command
2016-11-17 23:19 [PATCH] xfs_db: add alignment filter to freesp command Eric Sandeen
@ 2016-11-18 12:54 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2016-11-18 12:54 UTC (permalink / raw)
To: Eric Sandeen; +Cc: linux-xfs
On Thu, Nov 17, 2016 at 05:19:15PM -0600, Eric Sandeen wrote:
> This adds an alignment filter to the xfs_db freesp command, i.e.
>
> xfs_db> freesp -A 4
>
> will show only 4-block aligned free extents.
>
> This can be useful for finding freespace suitable for allocations
> with specific alignment requirements, such as inode allocation.
>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Looks fine,
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-11-18 12:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-17 23:19 [PATCH] xfs_db: add alignment filter to freesp command Eric Sandeen
2016-11-18 12:54 ` Christoph Hellwig
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.