All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: sandeen@sandeen.net, djwong@kernel.org
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 1/4] xfs_repair: ignore empty xattr leaf blocks
Date: Tue, 12 Jul 2022 18:09:42 -0700	[thread overview]
Message-ID: <165767458269.891854.14449036597530410382.stgit@magnolia> (raw)
In-Reply-To: <165767457703.891854.2108521135190969641.stgit@magnolia>

From: Darrick J. Wong <djwong@kernel.org>

As detailed in the previous commit, empty xattr leaf blocks can be the
benign byproduct of the system going down during the multi-step process
of adding a large xattr to a file that has no xattrs.  If we find one at
attr fork offset 0, we should clear it, but this isn't a corruption.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 repair/attr_repair.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)


diff --git a/repair/attr_repair.c b/repair/attr_repair.c
index 2055d96e..c3a6d502 100644
--- a/repair/attr_repair.c
+++ b/repair/attr_repair.c
@@ -579,6 +579,26 @@ process_leaf_attr_block(
 	firstb = mp->m_sb.sb_blocksize;
 	stop = xfs_attr3_leaf_hdr_size(leaf);
 
+	/*
+	 * Empty leaf blocks at offset zero can occur as a race between
+	 * setxattr and the system going down, so we only take action if we're
+	 * running in modify mode.  See xfs_attr3_leaf_verify for details of
+	 * how we've screwed this up many times.
+	 */
+	if (!leafhdr.count && da_bno == 0) {
+		if (no_modify) {
+			do_log(
+	_("would clear empty leaf attr block 0, inode %" PRIu64 "\n"),
+					ino);
+			return 0;
+		}
+
+		do_warn(
+	_("will clear empty leaf attr block 0, inode %" PRIu64 "\n"),
+				ino);
+		return 1;
+	}
+
 	/* does the count look sorta valid? */
 	if (!leafhdr.count ||
 	    leafhdr.count * sizeof(xfs_attr_leaf_entry_t) + stop >


  reply	other threads:[~2022-07-13  1:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-13  1:09 [PATCHSET 0/4] xfsprogs: random fixes Darrick J. Wong
2022-07-13  1:09 ` Darrick J. Wong [this message]
2022-07-13  1:09 ` [PATCH 2/4] xfs_repair: Search for conflicts in inode_tree_ptrs[] when processing uncertain inodes Darrick J. Wong
2022-07-13  1:09 ` [PATCH 3/4] mkfs: complain about impossible log size constraints Darrick J. Wong
2022-07-14  1:17   ` Eric Sandeen
2022-07-14  2:03     ` Darrick J. Wong
2022-07-13  1:09 ` [PATCH 4/4] mkfs: terminate getsubopt arrays properly Darrick J. Wong
2022-07-14  1:39   ` Eric Sandeen
2022-07-14  1:59     ` Darrick J. Wong
2022-07-14  2:03       ` Eric Sandeen

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=165767458269.891854.14449036597530410382.stgit@magnolia \
    --to=djwong@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@sandeen.net \
    /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 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.