From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: tytso@mit.edu, darrick.wong@oracle.com
Cc: linux-ext4@vger.kernel.org
Subject: [PATCH 19/24] e2fsck: always submit logical block 0 of a directory for pass 2
Date: Fri, 18 Jul 2014 15:54:38 -0700 [thread overview]
Message-ID: <20140718225438.31374.51461.stgit@birch.djwong.org> (raw)
In-Reply-To: <20140718225200.31374.85411.stgit@birch.djwong.org>
Always iterate logical block 0 in a directory, even if no physical
block has been allocated. Pass 2 will notice the lack of mapping and
offer to allocate a new directory block; this enables us to link the
directory into lost+found.
Previously, if there were no logical blocks mapped, we would fail to
pick up even block 0 of the directory for processing in pass 2. This
meant that e2fsck never allocated a block 0 and therefore wouldn't fix
the missing . and .. entries for the directory; subsequent e2fsck runs
would complain about (yet never fix) the problem.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
e2fsck/pass1.c | 15 +++++++++++++++
tests/f_emptydir/expect.1 | 19 +++++++++++++++++++
tests/f_emptydir/expect.2 | 7 +++++++
tests/f_emptydir/image.gz | Bin
tests/f_emptydir/name | 2 ++
5 files changed, 43 insertions(+)
create mode 100644 tests/f_emptydir/expect.1
create mode 100644 tests/f_emptydir/expect.2
create mode 100644 tests/f_emptydir/image.gz
create mode 100644 tests/f_emptydir/name
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index 756e3bb..7a16780 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -2652,6 +2652,21 @@ static int process_block(ext2_filsys fs,
return 0;
}
+ /*
+ * For a directory, add logical block zero for processing even if it's
+ * not mapped or we'll be perennially stuck with broken "." and ".."
+ * entries.
+ */
+ if (p->is_dir && blockcnt == 0 && blk == 0) {
+ pctx->errcode = ext2fs_add_dir_block2(fs->dblist, p->ino, 0, 0);
+ if (pctx->errcode) {
+ pctx->blk = blk;
+ pctx->num = blockcnt;
+ goto failed_add_dir_block;
+ }
+ p->last_db_block++;
+ }
+
if (blk == 0)
return 0;
diff --git a/tests/f_emptydir/expect.1 b/tests/f_emptydir/expect.1
new file mode 100644
index 0000000..c612621
--- /dev/null
+++ b/tests/f_emptydir/expect.1
@@ -0,0 +1,19 @@
+Pass 1: Checking inodes, blocks, and sizes
+Inode 12, i_size is 1024, should be 0. Fix? yes
+
+Pass 2: Checking directory structure
+Directory inode 12 has an unallocated block #0. Allocate? yes
+
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+Free blocks count wrong for group #0 (957, counted=956).
+Fix? yes
+
+Free blocks count wrong (957, counted=956).
+Fix? yes
+
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 12/256 files (8.3% non-contiguous), 1092/2048 blocks
+Exit status is 1
diff --git a/tests/f_emptydir/expect.2 b/tests/f_emptydir/expect.2
new file mode 100644
index 0000000..75c0515
--- /dev/null
+++ b/tests/f_emptydir/expect.2
@@ -0,0 +1,7 @@
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+test_filesys: 12/256 files (16.7% non-contiguous), 1092/2048 blocks
+Exit status is 0
diff --git a/tests/f_emptydir/image.gz b/tests/f_emptydir/image.gz
new file mode 100644
index 0000000000000000000000000000000000000000..1b6f8f8350312013782acd2d2136db9f77c896dd
GIT binary patch
literal 2710
zcmb2|=3q#<KR=j>`R(2P*;fK&7(PtDv+`@y*0o$s-fO#+L;_h{*-MK89Q_M7b7*zh
zYyFeBqqSrAuCMk51x12Ku7<u)Vht2zUHORDZ=U{i>*{Uop|AS0KmR=NeUi76+{vfX
zaYZMq6&YHm9(lp}utvs4uQeds?^oUm$-+mgS9ZSoE#bN1`s&M`$vaQ}*jpPq^Pa?G
z!*53`X0;Vq^S#ftEO~kQ+TqvoHL|wbUS2smy*@qp+L@V`E}QN9{bjN6{5W~ZeY^iX
zS?B%UZl3p~zYF!xK2N<J_%nv<>9(hrpDkN{)-=D*P$1dr-SVvCpMG1vyLWSwk=_*9
zsz3G3hHc4jGM?1yZb^60-6OlTodFd*c)z;5^V0vDe?D4?L|ohE8}D&x;)LzRm&GrY
zq^RT{PLEx&Wcu;EJ9o<J-dwx7`Q{#hdDEvY4?h=UUHx%avARy#-p!x(hn@N?ufdUf
zvGEW46MKdKj6eBL)I0oR{v<!)e*;KpgNDt`-OvA>kz8;`>g=wy^Zt6pEnfbH?{9_r
zHzl1{fBa|twEZ*L_3|}Kg<Chx>@1Aq>~5IVy5IhBOG30-dY5<YS)0#|OTGU&C-RzU
z|BX!jTewn8|5th*+qFZt15H&DPTu=(Az;6)-N4c`FxT~U+3~hx8<u~J{5j{(2XoJB
zVwZN=2mEVi{;7N2eB+(4EvNivKUJ4Kb$*%bpQHbC<9znoyqdmj_UrGr{x{dJ*U$LR
z-IbU3_xt^ftM%&7uhgIZe69ZaubUAWtRMW!{)X$FxBWNSV9SA0`TtixIoH1ksjGW=
zbJstezXgBNcN$)iN!$Lx{J2Dip{(|${gV&e`rpcQ|Np7^|1;~irN>?ET=`vE-=;d_
zJtHIv9Lhibk#`OG^8A0-y5INzM@KMc-?VPJ_n#RxhR}FFY?oem(PX95z0u}a*M#p?
zdyU*w-SSWT-W?~JTzcZS^n3ow`p0N`M!BOQFd71*Aut*OqaiRF0s|fb8>ZAS-!GLj
JV_;BV0054XfYJZ}
literal 0
HcmV?d00001
diff --git a/tests/f_emptydir/name b/tests/f_emptydir/name
new file mode 100644
index 0000000..d5bc660
--- /dev/null
+++ b/tests/f_emptydir/name
@@ -0,0 +1,2 @@
+always iterate dir block 0 or e2fsck goes into infinite loop
+
next prev parent reply other threads:[~2014-07-18 22:54 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-18 22:52 [PATCH 00/24] e2fsprogs patchbomb 7/14, part 1 Darrick J. Wong
2014-07-18 22:52 ` [PATCH 01/24] e4defrag: backwards-allocated files should be defragmented too Darrick J. Wong
2014-07-21 23:44 ` Akira Fujita
2014-07-22 16:32 ` Theodore Ts'o
2014-07-18 22:52 ` [PATCH 02/24] debugfs: Only print the first 60 bytes from i_block on a fast symlink Darrick J. Wong
2014-07-19 16:49 ` Andreas Dilger
2014-07-22 16:43 ` Theodore Ts'o
2014-07-22 20:39 ` Darrick J. Wong
2014-07-22 20:34 ` Darrick J. Wong
2014-07-18 22:52 ` [PATCH 03/24] debugfs: create idump command to dump an inode in hex Darrick J. Wong
2014-07-22 17:47 ` Theodore Ts'o
2014-07-18 22:52 ` [PATCH 04/24] debugfs: allow bmap to allocate blocks Darrick J. Wong
2014-07-22 17:52 ` Theodore Ts'o
2014-07-18 22:52 ` [PATCH 05/24] e2fsck: report correct inode number in pass1b Darrick J. Wong
2014-07-22 17:47 ` Theodore Ts'o
2014-07-18 22:52 ` [PATCH 06/24] e2fsck: don't offer to recreate the journal if fsck is aborting due to bad block bitmaps Darrick J. Wong
2014-07-22 17:58 ` Theodore Ts'o
2014-07-18 22:53 ` [PATCH 07/24] e2fsck: skip clearing bad extents if bitmaps are unreadable Darrick J. Wong
2014-07-22 17:58 ` Theodore Ts'o
2014-07-18 22:53 ` [PATCH 08/24] e2fsck: fix inode coherency issue when iterating an inode's blocks Darrick J. Wong
2014-07-22 18:58 ` Theodore Ts'o
2014-07-18 22:53 ` [PATCH 09/24] e2fsck: clear i_block if there are too many bad block mappings Darrick J. Wong
2014-07-22 18:59 ` Theodore Ts'o
2014-07-22 22:14 ` Darrick J. Wong
2014-07-22 22:48 ` Theodore Ts'o
2014-07-18 22:53 ` [PATCH 10/24] e2fsck: don't clobber critical metadata during check_blocks Darrick J. Wong
2014-07-25 1:03 ` Theodore Ts'o
2014-07-18 22:53 ` [PATCH 11/24] e2fsck: free ctx->fs, not fs, at the end of fsck Darrick J. Wong
2014-07-25 1:14 ` Theodore Ts'o
2014-07-18 22:53 ` [PATCH 12/24] e2fsck: force all block allocations to use block_found_map Darrick J. Wong
2014-07-25 2:18 ` Theodore Ts'o
2014-07-18 22:53 ` [PATCH 13/24] e2fsck: fix off-by-one bounds check on group number Darrick J. Wong
2014-07-25 2:20 ` Theodore Ts'o
2014-07-18 22:53 ` [PATCH 14/24] libext2fs: fix bounds check of the bitmap test range in get_free_blocks2 Darrick J. Wong
2014-07-25 11:13 ` Theodore Ts'o
2014-07-18 22:54 ` [PATCH 15/24] misc: fix problems with strncat Darrick J. Wong
2014-07-25 11:22 ` Theodore Ts'o
2014-07-18 22:54 ` [PATCH 16/24] e2fsck: don't crash during rehash Darrick J. Wong
2014-07-25 11:22 ` Theodore Ts'o
2014-07-18 22:54 ` [PATCH 17/24] e2fsck: reserve blocks for root/lost+found directory repair Darrick J. Wong
2014-07-25 12:12 ` Theodore Ts'o
2014-07-25 20:19 ` Darrick J. Wong
2014-07-18 22:54 ` [PATCH 18/24] e2fsck: collapse holes in extent-based directories Darrick J. Wong
2014-07-25 12:33 ` Theodore Ts'o
2014-07-18 22:54 ` Darrick J. Wong [this message]
2014-07-25 12:40 ` [PATCH 19/24] e2fsck: always submit logical block 0 of a directory for pass 2 Theodore Ts'o
2014-07-18 22:54 ` [PATCH 20/24] e2fsck: pass2 should not process directory blocks that are impossibly large Darrick J. Wong
2014-07-25 12:42 ` Theodore Ts'o
2014-07-18 22:55 ` [PATCH 21/24] e2fsck: clear uninit flag on directory extents Darrick J. Wong
2014-07-25 13:00 ` Theodore Ts'o
2014-07-18 22:55 ` [PATCH 22/24] e2fsck: check return value of ext2fs_extent_fix_parents() Darrick J. Wong
2014-07-25 12:51 ` Theodore Ts'o
2014-07-18 22:55 ` [PATCH 23/24] mke2fs: set error behavior at initialization time Darrick J. Wong
2014-07-25 13:00 ` Theodore Ts'o
2014-07-18 22:55 ` [PATCH 24/24] e2fuzz: Create a tool to fuzz ext* filesystems Darrick J. Wong
2014-07-25 13:16 ` 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=20140718225438.31374.51461.stgit@birch.djwong.org \
--to=darrick.wong@oracle.com \
--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).