Currently, directories cannot be fallocated, which means that the only
way they get bigger is for the kernel to append blocks one by one.
Therefore, if we encounter a logical block offset that is too big, we
needn't bother adding it to the dblist for pass2 processing, because
it's unlikely to contain a valid directory block. The code that
handles extent based directories also does not add toobig blocks to
the dblist.
Note that we can easily cause e2fsck to fail with ENOMEM if we start
feeding it really large logical block offsets, as the dblist
implementation will try to realloc() an array big enough to hold it.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
blk = *block_nr = 0;
ret_code = BLOCK_CHANGED;
p->inode_modified = 1;
+ /*
+ * If the directory block is too big and is beyond the
+ * end of the FS, don't bother trying to add it for
+ * processing -- the kernel would never have created a
+ * directory this large, and we risk an ENOMEM abort.
+ * In any case, the toobig handler for extent-based
+ * directories also doesn't feed toobig blocks to
+ * pass 2.
+ */
+ if (problem == PR_1_TOOBIG_DIR)
+ return ret_code;
goto mark_dir;
} else
return 0;
--- /dev/null
+Pass 1: Checking inodes, blocks, and sizes
+Inode 12 is too big. Truncate? yes
+
+Block #1074791435 (13) causes directory to be too big. CLEARED.
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+test_filesys: 12/128 files (8.3% non-contiguous), 22/512 blocks
+Exit status is 0
--- /dev/null
+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/128 files (8.3% non-contiguous), 22/512 blocks
+Exit status is 0
--- /dev/null
+crash e2fsck with a dir with an impossibly high logical blk offset