From patchwork Fri Aug 1 18:11:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrick Wong X-Patchwork-Id: 375828 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3C8A5140111 for ; Sat, 2 Aug 2014 04:12:09 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755387AbaHASMI (ORCPT ); Fri, 1 Aug 2014 14:12:08 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:32949 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755184AbaHASMG (ORCPT ); Fri, 1 Aug 2014 14:12:06 -0400 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s71IC4cp020742 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 1 Aug 2014 18:12:05 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by ucsinet22.oracle.com (8.14.5+Sun/8.14.5) with ESMTP id s71IC4oa015801 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 1 Aug 2014 18:12:04 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by userz7022.oracle.com (8.14.5+Sun/8.14.4) with ESMTP id s71IC2Lj015694; Fri, 1 Aug 2014 18:12:02 GMT Received: from localhost (/24.21.154.84) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 01 Aug 2014 11:12:01 -0700 Subject: [PATCH 03/19] e2fsck: use root dir for lost+found when really desperate From: "Darrick J. Wong" To: tytso@mit.edu, darrick.wong@oracle.com Cc: linux-ext4@vger.kernel.org Date: Fri, 01 Aug 2014 11:11:59 -0700 Message-ID: <20140801181159.12496.97356.stgit@birch.djwong.org> In-Reply-To: <20140801181139.12496.14390.stgit@birch.djwong.org> References: <20140801181139.12496.14390.stgit@birch.djwong.org> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Source-IP: ucsinet22.oracle.com [156.151.31.94] Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Darrick J. Wong 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 --- e2fsck/pass3.c | 12 ++++++++++++ e2fsck/problem.c | 5 +++++ e2fsck/problem.h | 3 +++ tests/f_nospc_create_lnf/expect.1 | 28 ++++++++++++++++++++++++++++ tests/f_nospc_create_lnf/expect.2 | 25 +++++++++++++++++++++++++ tests/f_nospc_create_lnf/image.gz | Bin tests/f_nospc_create_lnf/name | 1 + 7 files changed, 74 insertions(+) create mode 100644 tests/f_nospc_create_lnf/expect.1 create mode 100644 tests/f_nospc_create_lnf/expect.2 create mode 100644 tests/f_nospc_create_lnf/image.gz create mode 100644 tests/f_nospc_create_lnf/name -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/e2fsck/pass3.c b/e2fsck/pass3.c index 31131ab..e6142ad 100644 --- a/e2fsck/pass3.c +++ b/e2fsck/pass3.c @@ -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); diff --git a/e2fsck/problem.c b/e2fsck/problem.c index 2c9386f..e68433b 100644 --- a/e2fsck/problem.c +++ b/e2fsck/problem.c @@ -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 */ diff --git a/e2fsck/problem.h b/e2fsck/problem.h index 80ef4a2..496e873 100644 --- a/e2fsck/problem.h +++ b/e2fsck/problem.h @@ -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 index 0000000..fc20628 --- /dev/null +++ b/tests/f_nospc_create_lnf/expect.1 @@ -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 index 0000000..5a44649 --- /dev/null +++ b/tests/f_nospc_create_lnf/expect.2 @@ -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 index 0000000000000000000000000000000000000000..dc71b61a0028603aac348c61b015fd3c0b25273a GIT binary patch literal 4201 zcmeHH{Zms{8qRK~jkCIDtaWjUB+hmRwcAP&l#L18rEX>XB6YHbwR~hNB9l_cB9?dw z^|cR~yu0%Y^^+H~E8nm+r1geq_qbpF4G;Bq-C{86ihtawoVqT5-#mKh!c)rt zC#DU(vVnp8NmGM_V=w=ET-7K0vM{(OZnZ?aiqZa}rOa^KXUiNX8qz8 z5d;N>he>UtXH7Bt0?F#)yfXcJpSBJ%xAhwjRy-Yask7za?73&ET8VEiFEYZbV$x`g zV>7ef$Vgro7qD^_7wdc+$m+!-{O&*Zko4%NI1b)~5Ra&_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