From: Dhruvesh Rathore <adrscube@gmail.com>
To: xfs@oss.sgi.com
Subject: [PATCH 1/4] xfs: Accounting for AGFL blocks in xfs_spaceman
Date: Wed, 28 Jan 2015 20:03:06 +0530 [thread overview]
Message-ID: <54c8f328.c38c460a.08e6.ffffc69b@mx.google.com> (raw)
The xfs_spaceman utility previously failed to account for AGFL blocks.
Old output (Before changes).
$ sudo xfs_spaceman -c "freesp" /media/xfs
from to extents blocks pct
1024 2047 1 1262 0.04
4096 8191 1 5126 0.15
8192 16383 3 35344 1.05
32768 65535 1 43989 1.31
262144 524287 3 1334894 39.78
524288 967428 2 1934840 57.66
As you can see the AGFL blocks were unaccounted (4 per AG, and there
were 4 AGs in this filesystem).
This patch is concerned with adding a new function which will walk the free
extents in AGFL and account for these AGFL blocks, while file system scanning.
New output (After implementing this patch).
$ uname -a
Linux dhruv-MacBookAir 3.18.0-rc7+ #3 SMP Thu Dec 25 15:29:59 IST 2014 x86_64 x86_64 x86_64 GNU/Linux
$ sudo xfs_spaceman -V
xfs_spaceman version 3.2.2
$ sudo xfs_spaceman -c "freesp" /media/xfs
from to extents blocks pct
1 1 16 16 0.00
1024 2047 1 1262 0.04
4096 8191 1 5126 0.15
8192 16383 3 35344 1.05
32768 65535 1 43989 1.31
262144 524287 3 1334894 39.78
524288 967428 2 1934840 57.66
-------------------------------------------------------------------------------------------
Signed-off-by: Dhruvesh Rathore <dhruvesh_r@outlook.com>
Signed-off-by: Amey Ruikar <ameyruikar@yahoo.com>
Signed-off-by: Somdeep Dey <somdeepdey10@gmail.com>
---
fs/xfs/libxfs/xfs_alloc.c | 53 ++++++++++++++
1 file changed, 53 insertions(+)
--- a/fs/xfs/libxfs/xfs_alloc.c 2015-01-28 15:25:02.396172903 +0530
+++ b/fs/xfs/libxfs/xfs_alloc.c 2015-01-28 15:13:46.936198272 +0530
@@ -2697,6 +2697,56 @@
}
+/*
+ * When we map free space we need to take into account the blocks
+ * that are indexed by the AGFL. They aren't found by walking the
+ * free space btrees, so we have to walk each AGFL to find them.
+ */
+static int
+xfs_alloc_agfl_freespace_map(
+ struct xfs_mount *mp,
+ struct xfs_agf *agf,
+ struct fiemap_extent_info *fieinfo,
+ xfs_agnumber_t agno)
+{
+ xfs_buf_t *agflbp;
+ __be32 *agfl_bno;
+ int i;
+ int error = 0;
+
+ error = xfs_alloc_read_agfl(mp, NULL, be32_to_cpu(agf->agf_seqno), &agflbp);
+
+ if (error)
+ return error;
+
+ agfl_bno = XFS_BUF_TO_AGFL_BNO(mp, agflbp);
+
+ for(i = be32_to_cpu(agf->agf_flfirst);
+ i <= be32_to_cpu(agf->agf_fllast);) {
+
+ xfs_daddr_t dbno;
+ xfs_fileoff_t dlen;
+ int flags = 0;
+
+ /*
+ * Use daddr format for all range/len calculations as that is
+ * the format the range/len variables are supplied in by
+ * userspace.
+ */
+
+ dbno = XFS_AGB_TO_DADDR(mp, agno, be32_to_cpu(agfl_bno[i]));
+ dlen = XFS_FSB_TO_BB(mp, 1);
+
+ error = -fiemap_fill_next_extent(fieinfo,BBTOB(dbno),
+ BBTOB(dbno), BBTOB(dlen), flags);
+ if (error)
+ break;
+ if (++i == XFS_AGFL_SIZE(mp))
+ i = 0;
+ }
+ xfs_buf_relse(agflbp);
+ return error;
+}
/*
* Map the freespace from the requested range in the requested order.
@@ -2803,6 +2853,9 @@
}
XFS_WANT_CORRUPTED_GOTO(i == 1, del_cursor);
+ /* Account for the free blocks in AGFL */
+ error = xfs_alloc_agfl_freespace_map(mp, XFS_BUF_TO_AGF(agbp), fieinfo, agno);
+
if (!bycnt) {
/*
* if we are doing a bno ordered lookup, we can just
-------------------------------------------------------------------------------------------
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next reply other threads:[~2015-01-28 14:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-28 14:33 Dhruvesh Rathore [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-01-29 13:23 [PATCH 1/4] xfs: Accounting for AGFL blocks in xfs_spaceman Dhruvesh Rathore
2015-02-10 7:25 ` Dave Chinner
2015-02-11 16:07 ` Dhruvesh Rathore
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54c8f328.c38c460a.08e6.ffffc69b@mx.google.com \
--to=adrscube@gmail.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox