]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
e2fsck: use root dir for lost+found when really desperate
authorDarrick J. Wong <darrick.wong@oracle.com>
Sun, 3 Aug 2014 02:18:30 +0000 (22:18 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 3 Aug 2014 02:18:30 +0000 (22:18 -0400)
If we're totally unable to allocate a lost+found directory, ask the
user if he would like to dump orphaned files in the root directory.
Hopefully this enables the user to delete enough files so that a
subsequent run of e2fsck will make more progress.  Better to cram lost
files in the rootdir than the current behavior, which is to fail at
linking them in, thereby leaving them as lost files.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/pass3.c
e2fsck/problem.c
e2fsck/problem.h
tests/f_nospc_create_lnf/expect.1 [new file with mode: 0644]
tests/f_nospc_create_lnf/expect.2 [new file with mode: 0644]
tests/f_nospc_create_lnf/image.gz [new file with mode: 0644]
tests/f_nospc_create_lnf/name [new file with mode: 0644]

index 31131ab5357bf79aaaf638ef3b3327bb878e2366..e6142ad560565df373150fba3ee2eafb5dea4b2f 100644 (file)
@@ -450,6 +450,12 @@ unlink:
                goto skip_new_block;
        }
        retval = ext2fs_new_block2(fs, 0, ctx->block_found_map, &blk);
+       if (retval == EXT2_ET_BLOCK_ALLOC_FAIL &&
+           fix_problem(ctx, PR_3_LPF_NO_SPACE, &pctx)) {
+               printf("Delete some files and re-run e2fsck.\n\n");
+               ctx->lost_and_found = EXT2_ROOT_INO;
+               return 0;
+       }
        if (retval) {
                pctx.errcode = retval;
                fix_problem(ctx, PR_3_ERR_LPF_NEW_BLOCK, &pctx);
@@ -464,6 +470,12 @@ skip_new_block:
         */
        retval = ext2fs_new_inode(fs, EXT2_ROOT_INO, 040700,
                                  ctx->inode_used_map, &ino);
+       if (retval == EXT2_ET_INODE_ALLOC_FAIL &&
+           fix_problem(ctx, PR_3_LPF_NO_SPACE, &pctx)) {
+               printf("Delete some files and re-run e2fsck.\n\n");
+               ctx->lost_and_found = EXT2_ROOT_INO;
+               return 0;
+       }
        if (retval) {
                pctx.errcode = retval;
                fix_problem(ctx, PR_3_ERR_LPF_NEW_INODE, &pctx);
index 2c9386f19e87a5eb813f8e32ff5c28e0df02b235..e68433b215c9373c2218e370a3f5872798360fee 100644 (file)
@@ -1630,6 +1630,11 @@ static struct e2fsck_problem problem_table[] = {
          N_("/@l has inline data\n"),
          PROMPT_CLEAR, 0 },
 
+       /* Cannot allocate /lost+found. */
+       { PR_3_LPF_NO_SPACE,
+         N_("Cannot allocate space for /@l.\nPlace lost files in root directory instead"),
+         PROMPT_NULL, 0 },
+
        /* Pass 3A Directory Optimization       */
 
        /* Pass 3A: Optimizing directories */
index 80ef4a22f6ce813b2ee6102ad1e10378e4ee7234..496e87328363ecf19c2158705887c810e1e4db9e 100644 (file)
@@ -973,6 +973,9 @@ struct problem_context {
 /* Lost+found has inline data */
 #define PR_3_LPF_INLINE_DATA           0x030018
 
+/* Cannot allocate lost+found */
+#define PR_3_LPF_NO_SPACE              0x030019
+
 /*
  * Pass 3a --- rehashing diretories
  */
diff --git a/tests/f_nospc_create_lnf/expect.1 b/tests/f_nospc_create_lnf/expect.1
new file mode 100644 (file)
index 0000000..fc20628
--- /dev/null
@@ -0,0 +1,28 @@
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+/lost+found not found.  Create? yes
+
+Cannot allocate space for /lost+found.
+Place lost files in root directory instead? yes
+
+Delete some files and re-run e2fsck.
+
+Pass 3A: Optimizing directories
+Pass 4: Checking reference counts
+Unattached inode 125
+Connect to /lost+found? yes
+
+Inode 125 ref count is 2, should be 1.  Fix? yes
+
+Pass 5: Checking group summary information
+Free blocks count wrong for group #0 (496, counted=495).
+Fix? yes
+
+Free blocks count wrong (496, counted=495).
+Fix? yes
+
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 128/128 files (0.0% non-contiguous), 17/512 blocks
+Exit status is 1
diff --git a/tests/f_nospc_create_lnf/expect.2 b/tests/f_nospc_create_lnf/expect.2
new file mode 100644 (file)
index 0000000..5a44649
--- /dev/null
@@ -0,0 +1,25 @@
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+/lost+found not found.  Create? yes
+
+Cannot allocate space for /lost+found.
+Place lost files in root directory instead? yes
+
+Delete some files and re-run e2fsck.
+
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+Block bitmap differences:  -9
+Fix? yes
+
+Free blocks count wrong for group #0 (494, counted=495).
+Fix? yes
+
+Free blocks count wrong (494, counted=495).
+Fix? yes
+
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 128/128 files (0.0% non-contiguous), 17/512 blocks
+Exit status is 1
diff --git a/tests/f_nospc_create_lnf/image.gz b/tests/f_nospc_create_lnf/image.gz
new file mode 100644 (file)
index 0000000..dc71b61
Binary files /dev/null and b/tests/f_nospc_create_lnf/image.gz differ
diff --git a/tests/f_nospc_create_lnf/name b/tests/f_nospc_create_lnf/name
new file mode 100644 (file)
index 0000000..df6c932
--- /dev/null
@@ -0,0 +1 @@
+no space to create lost+found