From: Dave Chinner <david@fromorbit.com>
To: xfs@oss.sgi.com
Subject: [PATCH 05/30] xfsprogs: Support new AGFL format
Date: Fri, 17 May 2013 21:13:00 +1000 [thread overview]
Message-ID: <1368789205-19969-6-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1368789205-19969-1-git-send-email-david@fromorbit.com>
From: Dave Chinner <dchinner@redhat.com>
With the addition of CRCs to the filesystem format, the AGFL has a
new format structure definition. Existing code that pulls freelist
blocks out via dereferencing agfl->agfl_bno no longer works as the
location of the free list is now variable depending on the disk
format in use.
Hence all the users of agfl_bno need ot be converted to extract the
location of the first free list entry from the AGFL and grab entries
relative to that first entry. It's a simple change, but needs to be
made in several places as there is very little code reuse within and
between the different utilities in xfsprogs.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
db/check.c | 6 +++++-
db/freesp.c | 7 ++++++-
repair/phase5.c | 6 ++++--
repair/scan.c | 6 +++---
4 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/db/check.c b/db/check.c
index 353530b..127e407 100644
--- a/db/check.c
+++ b/db/check.c
@@ -3806,6 +3806,7 @@ scan_freelist(
xfs_agblock_t bno;
uint count;
int i;
+ __be32 *freelist;
if (XFS_SB_BLOCK(mp) != XFS_AGFL_BLOCK(mp) &&
XFS_AGF_BLOCK(mp) != XFS_AGFL_BLOCK(mp) &&
@@ -3835,9 +3836,12 @@ scan_freelist(
return;
}
+ /* open coded XFS_BUF_TO_AGFL_BNO */
+ freelist = xfs_sb_version_hascrc(&((mp)->m_sb)) ? &agfl->agfl_bno[0]
+ : (__be32 *)agfl;
count = 0;
for (;;) {
- bno = be32_to_cpu(agfl->agfl_bno[i]);
+ bno = be32_to_cpu(freelist[i]);
set_dbmap(seqno, bno, 1, DBM_FREELIST, seqno,
XFS_AGFL_BLOCK(mp));
count++;
diff --git a/db/freesp.c b/db/freesp.c
index 472b1f7..228ca07 100644
--- a/db/freesp.c
+++ b/db/freesp.c
@@ -231,6 +231,7 @@ scan_freelist(
xfs_agfl_t *agfl;
xfs_agblock_t bno;
int i;
+ __be32 *agfl_bno;
if (be32_to_cpu(agf->agf_flcount) == 0)
return;
@@ -240,6 +241,10 @@ scan_freelist(
agfl = iocur_top->data;
i = be32_to_cpu(agf->agf_flfirst);
+ /* open coded XFS_BUF_TO_AGFL_BNO */
+ agfl_bno = xfs_sb_version_hascrc(&mp->m_sb) ? &agfl->agfl_bno[0]
+ : (__be32 *)agfl;
+
/* verify agf values before proceeding */
if (be32_to_cpu(agf->agf_flfirst) >= XFS_AGFL_SIZE(mp) ||
be32_to_cpu(agf->agf_fllast) >= XFS_AGFL_SIZE(mp)) {
@@ -250,7 +255,7 @@ scan_freelist(
}
for (;;) {
- bno = be32_to_cpu(agfl->agfl_bno[i]);
+ bno = be32_to_cpu(agfl_bno[i]);
addtohist(seqno, bno, 1);
if (i == be32_to_cpu(agf->agf_fllast))
break;
diff --git a/repair/phase5.c b/repair/phase5.c
index 1f71cac..c7cef4f 100644
--- a/repair/phase5.c
+++ b/repair/phase5.c
@@ -1208,6 +1208,7 @@ build_agf_agfl(xfs_mount_t *mp,
int j;
xfs_agfl_t *agfl;
xfs_agf_t *agf;
+ __be32 *freelist;
agf_buf = libxfs_getbuf(mp->m_dev,
XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR(mp)),
@@ -1277,19 +1278,20 @@ build_agf_agfl(xfs_mount_t *mp,
XFS_AG_DADDR(mp, agno, XFS_AGFL_DADDR(mp)),
mp->m_sb.sb_sectsize/BBSIZE);
agfl = XFS_BUF_TO_AGFL(agfl_buf);
+ freelist = XFS_BUF_TO_AGFL_BNO(mp, agfl_buf);
memset(agfl, 0, mp->m_sb.sb_sectsize);
/*
* ok, now grab as many blocks as we can
*/
i = j = 0;
while (bno_bt->num_free_blocks > 0 && i < XFS_AGFL_SIZE(mp)) {
- agfl->agfl_bno[i] = cpu_to_be32(
+ freelist[i] = cpu_to_be32(
get_next_blockaddr(agno, 0, bno_bt));
i++;
}
while (bcnt_bt->num_free_blocks > 0 && i < XFS_AGFL_SIZE(mp)) {
- agfl->agfl_bno[i] = cpu_to_be32(
+ freelist[i] = cpu_to_be32(
get_next_blockaddr(agno, 0, bcnt_bt));
i++;
}
diff --git a/repair/scan.c b/repair/scan.c
index 76bb7f1..f79342a 100644
--- a/repair/scan.c
+++ b/repair/scan.c
@@ -1041,12 +1041,12 @@ scan_freelist(
xfs_agf_t *agf,
struct aghdr_cnts *agcnts)
{
- xfs_agfl_t *agfl;
xfs_buf_t *agflbuf;
xfs_agnumber_t agno;
xfs_agblock_t bno;
int count;
int i;
+ __be32 *freelist;
agno = be32_to_cpu(agf->agf_seqno);
@@ -1065,7 +1065,7 @@ scan_freelist(
do_abort(_("can't read agfl block for ag %d\n"), agno);
return;
}
- agfl = XFS_BUF_TO_AGFL(agflbuf);
+ freelist = XFS_BUF_TO_AGFL_BNO(mp, agflbuf);
i = be32_to_cpu(agf->agf_flfirst);
if (no_modify) {
@@ -1080,7 +1080,7 @@ scan_freelist(
count = 0;
for (;;) {
- bno = be32_to_cpu(agfl->agfl_bno[i]);
+ bno = be32_to_cpu(freelist[i]);
if (verify_agbno(mp, agno, bno))
set_bmap(agno, bno, XR_E_FREE);
else
--
1.7.10.4
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2013-05-17 11:13 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-17 11:12 [PATCH 00/30] xfsprogs: Initial CRC support Dave Chinner
2013-05-17 11:12 ` [PATCH 01/30] mkfs: fix realtime device initialisation Dave Chinner
2013-07-22 20:46 ` Ben Myers
2013-05-17 11:12 ` [PATCH 02/30] logprint: fix wrapped log dump issue Dave Chinner
2013-05-17 11:12 ` [PATCH 03/30] libxfs: add crc format changes to generic btrees Dave Chinner
2013-05-17 11:12 ` [PATCH 04/30] xfsprogs: add crc format chagnes to ag headers Dave Chinner
2013-05-17 11:13 ` Dave Chinner [this message]
2013-05-17 11:13 ` [PATCH 06/30] libxfs: change quota buffer formats Dave Chinner
2013-05-17 11:13 ` [PATCH 07/30] libxfs: add version 3 inode support Dave Chinner
2013-05-17 11:13 ` [PATCH 08/30] libxfs: add support for crc headers on remote symlinks Dave Chinner
2013-05-17 11:13 ` [PATCH 09/30] xfs: add CRC checks to block format directory blocks Dave Chinner
2013-05-17 11:13 ` [PATCH 10/30] xfs: add CRC checking to dir2 free blocks Dave Chinner
2013-05-17 11:13 ` [PATCH 11/30] xfs: add CRC checking to dir2 data blocks Dave Chinner
2013-05-17 11:13 ` [PATCH 12/30] xfs: add CRC checking to dir2 leaf blocks Dave Chinner
2013-05-17 11:13 ` [PATCH 13/30] xfs: shortform directory offsets change for dir3 format Dave Chinner
2013-05-17 11:13 ` [PATCH 14/30] xfs: add CRCs to dir2/da node blocks Dave Chinner
2013-05-17 11:13 ` [PATCH 15/30] xfs: add CRCs to attr leaf blocks Dave Chinner
2013-05-17 11:13 ` [PATCH 16/30] xfs: split remote attribute code out Dave Chinner
2013-05-17 11:13 ` [PATCH 17/30] xfs: add CRC protection to remote attributes Dave Chinner
2013-05-17 11:13 ` [PATCH 18/30] xfs: add buffer types to directory and attribute buffers Dave Chinner
2013-05-17 11:13 ` [PATCH 19/30] xfs: buffer type overruns blf_flags field Dave Chinner
2013-05-17 11:13 ` [PATCH 20/30] xfs: add CRC checks to the superblock Dave Chinner
2013-05-17 11:13 ` [PATCH 21/30] xfs: implement extended feature masks Dave Chinner
2013-05-17 11:13 ` [PATCH 22/30] xfsprogs: Add verifiers to libxfs buffer interfaces Dave Chinner
2013-05-17 11:13 ` [PATCH 23/30] patch xfsprogs-mkfs-crc-support-2 Dave Chinner
2013-05-17 11:13 ` [PATCH 24/30] xfsprogs: add crc format support to repair Dave Chinner
2013-05-17 11:13 ` [PATCH 25/30] xfs_repair: update for dir/attr crc format changes Dave Chinner
2013-05-17 11:13 ` [PATCH 26/30] xfsprogs: disable xfs_check for CRC enabled filesystems Dave Chinner
2013-05-17 11:13 ` [PATCH 27/30] xfs_db: disable modification for CRC enabled filessytems Dave Chinner
2013-05-17 11:13 ` [PATCH 28/30] libxfs: determine inode size from version number, not struct xfs_dinode Dave Chinner
2013-05-17 11:13 ` [PATCH 29/30] xfsdb: support version 5 superblock in versionnum command Dave Chinner
2013-05-17 11:13 ` [PATCH 30/30] xfsprogs: add crc format support to db Dave Chinner
2013-05-17 20:54 ` [PATCH 00/30] xfsprogs: Initial CRC support Michael L. Semon
2013-05-18 3:25 ` Dave Chinner
2013-05-18 5:07 ` Jeff Liu
2013-05-18 5:39 ` Dave Chinner
2013-05-18 6:27 ` Michael L. Semon
2013-05-18 8:46 ` Jeff Liu
2013-05-18 5:40 ` Michael L. Semon
2013-05-18 6:27 ` Dave Chinner
2013-05-18 7:42 ` Michael L. Semon
2013-05-18 18:13 ` Michael L. Semon
2013-05-20 6:52 ` [PATCH 0/6] xfsprogs: more CRC support patches Dave Chinner
2013-05-20 6:52 ` [PATCH 1/6] xfs_repair: always use incore header for directory block checks Dave Chinner
2013-05-20 6:52 ` [PATCH 2/6] xfs_db: convert directory parsing to use libxfs structure Dave Chinner
2013-05-20 6:53 ` [PATCH 3/6] xfs_db: factor some common dir2 field parsing code Dave Chinner
2013-05-20 6:53 ` [PATCH 4/6] xfs_db: update field printing for dir crc format changes Dave Chinner
2013-05-20 6:53 ` [PATCH 5/6] xfs_repair: convert directory parsing to use libxfs structure Dave Chinner
2013-05-20 6:53 ` [PATCH 6/6] xfs_repair: make directory freespace table CRC format aware Dave Chinner
2013-05-20 16:11 ` [PATCH 0/6] xfsprogs: more CRC support patches Michael L. Semon
2013-05-23 12:36 ` [PATCH 0/2] xfsprogs: yet " Dave Chinner
2013-05-23 12:36 ` [PATCH 1/2] xfs_db: add CRC information to dquot output Dave Chinner
2013-05-23 12:36 ` [PATCH 2/2] xfs_db: add CRC support for attribute fork structures Dave Chinner
2013-05-27 7:14 ` [PATCH 0/4] xfsprogs: more CRC patches Dave Chinner
2013-05-27 7:14 ` [PATCH 1/4] mkfs.xfs: validate options for CRCs up front Dave Chinner
2013-05-27 7:14 ` [PATCH 2/4] xfsprogs: support CRC enabled filesystem detection Dave Chinner
2013-05-27 7:14 ` [PATCH 3/4] xfs_mdrestore: recalculate sb CRC before writing Dave Chinner
2013-05-27 7:14 ` [PATCH 4/4] xfs_metadump: requires some object CRC recalculation Dave Chinner
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=1368789205-19969-6-git-send-email-david@fromorbit.com \
--to=david@fromorbit.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