From: Tahsin Erdogan <tahsin@google.com>
To: Theodore Ts'o <tytso@mit.edu>, Andreas Dilger <adilger@dilger.ca>,
linux-ext4@vger.kernel.org
Cc: Tahsin Erdogan <tahsin@google.com>
Subject: [PATCH] e2fsck: eliminate bad update link count attempt
Date: Mon, 17 Jul 2017 05:50:35 -0700 [thread overview]
Message-ID: <20170717125035.12852-1-tahsin@google.com> (raw)
Extended attribute inodes have a link count of 1 but they are not
attached to any directories. When an xattr inode with zero ea
references is found, the remedy is to reconnect it to lost+found dir.
Since reconnect operation increments the link count, it would normally
become 2 but to avoid that, check_ea_inode() sets the link count to
zero in anticipation of reconnect operation. And it does it even when
e2fsck is invoked with -n option which causes a fatal e2fsck failure
as can be demonstrated with the following test script:
mke2fs -b 4096 -I 256 -F -O extent,ea_inode /dev/sdb 1G
mount /dev/sdb /mnt/sdb
touch /mnt/sdb/x
setfattr -n user.ie1 -v $(python -c "print 'v'*5000") /mnt/sdb/x
umount /dev/sdb
debugfs -w -R 'rm x' /dev/sdb
e2fsck -f -n /dev/sdb
In this case, e2fsck fails with the following error:
e2fsck 1.43.5-WIP (17-Feb-2017)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
ext2fs_write_inode: Attempt to write to filesystem opened read-only
while writing inode 13 in check_ea_inode
e2fsck: aborted
Setting link count to zero is not really required because e2fsck will
detect the discrepancy in link count and offer to fix it.
Signed-off-by: Tahsin Erdogan <tahsin@google.com>
---
e2fsck/pass4.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/e2fsck/pass4.c b/e2fsck/pass4.c
index 663f87ab59c0..b23347cdb6b0 100644
--- a/e2fsck/pass4.c
+++ b/e2fsck/pass4.c
@@ -122,17 +122,8 @@ static void check_ea_inode(e2fsck_t ctx, ext2_ino_t i,
if (ctx->ea_inode_refs)
ea_refcount_fetch(ctx->ea_inode_refs, i, &actual_refs);
- if (!actual_refs) {
- /*
- * There are no attribute references to the ea_inode.
- * Zero the link count so that when inode is linked to
- * lost+found it has correct link count.
- */
- inode->i_links_count = 0;
- e2fsck_write_inode(ctx, i, EXT2_INODE(inode), "check_ea_inode");
- ext2fs_icount_store(ctx->inode_link_info, i, 0);
+ if (!actual_refs)
return;
- }
/*
* There are some attribute references, link_counted is now considered
--
2.13.2.932.g7449e964c-goog
next reply other threads:[~2017-07-17 12:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-17 12:50 Tahsin Erdogan [this message]
2017-07-24 4:11 ` [PATCH] e2fsck: eliminate bad update link count attempt Theodore Ts'o
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=20170717125035.12852-1-tahsin@google.com \
--to=tahsin@google.com \
--cc=adilger@dilger.ca \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/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;
as well as URLs for NNTP newsgroup(s).