From: Brian Foster <bfoster@redhat.com>
To: xfs@oss.sgi.com
Subject: [PATCH 4/4] repair: helper to transition inode blocks to inode state
Date: Mon, 8 Jun 2015 07:29:24 -0400 [thread overview]
Message-ID: <1433762964-11502-5-git-send-email-bfoster@redhat.com> (raw)
In-Reply-To: <1433762964-11502-1-git-send-email-bfoster@redhat.com>
The state of each block in an inode chunk transitions from free state to
inode state as we process physical inodes on disk. We take care to
detect invalid transitions and warn the user if multiply claimed blocks
are detected.
This block of code is a largish switch statement that is executed twice
due to the implementation details of the inode processing loop. Factor
it into a new helper.
Signed-off-by: Brian Foster <bfoster@redhat.com>
---
repair/dino_chunks.c | 91 ++++++++++++++++++++++------------------------------
1 file changed, 39 insertions(+), 52 deletions(-)
diff --git a/repair/dino_chunks.c b/repair/dino_chunks.c
index 9b7d017..834227b 100644
--- a/repair/dino_chunks.c
+++ b/repair/dino_chunks.c
@@ -550,7 +550,42 @@ verify_aginode_chunk_irec(xfs_mount_t *mp,
return(irec);
}
+/*
+ * Set the state of an inode block during inode chunk processing. The block is
+ * expected to be in the free or inode state. If free, it transitions to the
+ * inode state. Warn if the block is in neither expected state as this indicates
+ * multiply claimed blocks.
+ */
+static void
+process_inode_agbno_state(
+ struct xfs_mount *mp,
+ xfs_agnumber_t agno,
+ xfs_agblock_t agbno)
+{
+ int state;
+ pthread_mutex_lock(&ag_locks[agno].lock);
+ state = get_bmap(agno, agbno);
+ switch (state) {
+ case XR_E_INO: /* already marked */
+ break;
+ case XR_E_UNKNOWN:
+ case XR_E_FREE:
+ case XR_E_FREE1:
+ set_bmap(agno, agbno, XR_E_INO);
+ break;
+ case XR_E_BAD_STATE:
+ do_error(_("bad state in block map %d\n"), state);
+ break;
+ default:
+ set_bmap(agno, agbno, XR_E_MULT);
+ do_warn(
+ _("inode block %" PRIu64 " multiply claimed, state was %d\n"),
+ XFS_AGB_TO_FSB(mp, agno, agbno), state);
+ break;
+ }
+ pthread_mutex_unlock(&ag_locks[agno].lock);
+}
/*
* processes an inode allocation chunk/block, returns 1 on I/O errors,
@@ -558,8 +593,6 @@ verify_aginode_chunk_irec(xfs_mount_t *mp,
*
* *bogus is set to 1 if the entire set of inodes is bad.
*/
-
-/* ARGSUSED */
static int
process_inode_chunk(
xfs_mount_t *mp,
@@ -578,7 +611,6 @@ process_inode_chunk(
int icnt;
int status;
int is_used;
- int state;
int ino_dirty;
int irec_offset;
int ibuf_offset;
@@ -757,29 +789,8 @@ next_readbuf:
/*
* mark block as an inode block in the incore bitmap
*/
- if (!is_inode_sparse(ino_rec, irec_offset)) {
- pthread_mutex_lock(&ag_locks[agno].lock);
- state = get_bmap(agno, agbno);
- switch (state) {
- case XR_E_INO: /* already marked */
- break;
- case XR_E_UNKNOWN:
- case XR_E_FREE:
- case XR_E_FREE1:
- set_bmap(agno, agbno, XR_E_INO);
- break;
- case XR_E_BAD_STATE:
- do_error(_("bad state in block map %d\n"), state);
- break;
- default:
- set_bmap(agno, agbno, XR_E_MULT);
- do_warn(
- _("inode block %" PRIu64 " multiply claimed, state was %d\n"),
- XFS_AGB_TO_FSB(mp, agno, agbno), state);
- break;
- }
- pthread_mutex_unlock(&ag_locks[agno].lock);
- }
+ if (!is_inode_sparse(ino_rec, irec_offset))
+ process_inode_agbno_state(mp, agno, agbno);
for (;;) {
agino = irec_offset + ino_rec->ino_startnum;
@@ -956,32 +967,8 @@ process_next:
ibuf_offset = 0;
agbno++;
- if (!is_inode_sparse(ino_rec, irec_offset)) {
- pthread_mutex_lock(&ag_locks[agno].lock);
- state = get_bmap(agno, agbno);
- switch (state) {
- case XR_E_INO: /* already marked */
- break;
- case XR_E_UNKNOWN:
- case XR_E_FREE:
- case XR_E_FREE1:
- set_bmap(agno, agbno, XR_E_INO);
- break;
- case XR_E_BAD_STATE:
- do_error(
- _("bad state in block map %d\n"),
- state);
- break;
- default:
- set_bmap(agno, agbno, XR_E_MULT);
- do_warn(
- _("inode block %" PRIu64 " multiply claimed, state was %d\n"),
- XFS_AGB_TO_FSB(mp, agno, agbno),
- state);
- break;
- }
- pthread_mutex_unlock(&ag_locks[agno].lock);
- }
+ if (!is_inode_sparse(ino_rec, irec_offset))
+ process_inode_agbno_state(mp, agno, agbno);
} else if (irec_offset == XFS_INODES_PER_CHUNK) {
/*
* get new irec (multiple chunks per block fs)
--
1.9.3
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
prev parent reply other threads:[~2015-06-08 11:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-08 11:29 [PATCH 0/4] xfsprogs/repair: sparse inode chunks cleanups Brian Foster
2015-06-08 11:29 ` [PATCH 1/4] repair: access helpers for on-disk inobt record freecount Brian Foster
2015-06-08 11:29 ` [PATCH 2/4] repair: helper for inode chunk alignment and start/end ino number verification Brian Foster
2015-06-08 11:29 ` [PATCH 3/4] repair: helper to import on-disk inobt records to in-core trees Brian Foster
2015-06-08 11:29 ` Brian Foster [this message]
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=1433762964-11502-5-git-send-email-bfoster@redhat.com \
--to=bfoster@redhat.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