linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukas Czerner <lczerner@redhat.com>
To: linux-ext4@vger.kernel.org
Cc: tytso@mit.edu, sandeen@redhat.com, adilger@dilger.ca,
	lczerner@redhat.com
Subject: [PATCH 3/7] e2fsck: Keep track of problems during the check
Date: Tue, 26 Oct 2010 19:54:14 +0200	[thread overview]
Message-ID: <1288115658-7004-4-git-send-email-lczerner@redhat.com> (raw)
In-Reply-To: <1288115658-7004-1-git-send-email-lczerner@redhat.com>

It might be useful to know whether or not there has been any problem
during the check. This commit add new variable problem_history into
e2fsck_struct in order to store error codes.

When problem occur and fix_problem() is invoked, problem code is stored
into problem_history. Note that only real problem are stored, hence
problems with PR_NO_PROBLEM are ignored. This commit also adds
PR_NO_PROBLEM flag into problem for informative purposes only.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
 e2fsck/e2fsck.h   |    1 +
 e2fsck/problem.c  |   31 +++++++++++++++++++++----------
 e2fsck/problem.h  |    3 +++
 e2fsck/problemP.h |    1 +
 4 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h
index d4df5f3..a6563cc 100644
--- a/e2fsck/e2fsck.h
+++ b/e2fsck/e2fsck.h
@@ -216,6 +216,7 @@ struct e2fsck_struct {
 	blk64_t	num_blocks;	/* Total number of blocks */
 	int	mount_flags;
 	blkid_cache blkid;	/* blkid cache */
+	__u32 problem_history;	/* store previous problem codes */
 
 #ifdef HAVE_SETJMP_H
 	jmp_buf	abort_loc;
diff --git a/e2fsck/problem.c b/e2fsck/problem.c
index 8032fda..9b987b0 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -407,7 +407,7 @@ static struct e2fsck_problem problem_table[] = {
 	/* Pass 1: Checking inodes, blocks, and sizes */
 	{ PR_1_PASS_HEADER,
 	  N_("Pass 1: Checking @is, @bs, and sizes\n"),
-	  PROMPT_NONE, 0 },
+	  PROMPT_NONE, PR_NO_PROBLEM },
 
 	/* Root directory is not an inode */
 	{ PR_1_ROOT_NO_DIR, N_("@r is not a @d.  "),
@@ -896,7 +896,7 @@ static struct e2fsck_problem problem_table[] = {
 	{ PR_1B_PASS_HEADER,
 	  N_("\nRunning additional passes to resolve @bs claimed by more than one @i...\n"
 	  "Pass 1B: Rescanning for @m @bs\n"),
-	  PROMPT_NONE, 0 },
+	  PROMPT_NONE, PR_NO_PROBLEM },
 
 	/* Duplicate/bad block(s) header */
 	{ PR_1B_DUP_BLOCK_HEADER,
@@ -937,13 +937,13 @@ static struct e2fsck_problem problem_table[] = {
 	/* Pass 1C: Scan directories for inodes with multiply-claimed blocks. */
 	{ PR_1C_PASS_HEADER,
 	  N_("Pass 1C: Scanning directories for @is with @m @bs\n"),
-	  PROMPT_NONE, 0 },
+	  PROMPT_NONE, PR_NO_PROBLEM },
 
 
 	/* Pass 1D: Reconciling multiply-claimed blocks */
 	{ PR_1D_PASS_HEADER,
 	  N_("Pass 1D: Reconciling @m @bs\n"),
-	  PROMPT_NONE, 0 },
+	  PROMPT_NONE, PR_NO_PROBLEM },
 
 	/* File has duplicate blocks */
 	{ PR_1D_DUP_FILE,
@@ -988,7 +988,7 @@ static struct e2fsck_problem problem_table[] = {
 	/* Pass 2: Checking directory structure */
 	{ PR_2_PASS_HEADER,
 	  N_("Pass 2: Checking @d structure\n"),
-	  PROMPT_NONE, 0 },
+	  PROMPT_NONE, PR_NO_PROBLEM },
 
 	/* Bad inode number for '.' */
 	{ PR_2_BAD_INODE_DOT,
@@ -1318,7 +1318,7 @@ static struct e2fsck_problem problem_table[] = {
 	/* Pass 3: Checking directory connectivity */
 	{ PR_3_PASS_HEADER,
 	  N_("Pass 3: Checking @d connectivity\n"),
-	  PROMPT_NONE, 0 },
+	  PROMPT_NONE, PR_NO_PROBLEM },
 
 	/* Root inode not allocated */
 	{ PR_3_NO_ROOT_INODE,
@@ -1440,7 +1440,7 @@ static struct e2fsck_problem problem_table[] = {
 	/* Pass 3A: Optimizing directories */
 	{ PR_3A_PASS_HEADER,
 	  N_("Pass 3A: Optimizing directories\n"),
-	  PROMPT_NONE, PR_PREEN_NOMSG },
+	  PROMPT_NONE, PR_NO_PROBLEM },
 
 	/* Error iterating over directories */
 	{ PR_3A_OPTIMIZE_ITER,
@@ -1455,7 +1455,7 @@ static struct e2fsck_problem problem_table[] = {
 	/* Rehashing dir header */
 	{ PR_3A_OPTIMIZE_DIR_HEADER,
 	  N_("Optimizing directories: "),
-	  PROMPT_NONE, PR_MSG_ONLY },
+	  PROMPT_NONE, PR_NO_PROBLEM },
 
 	/* Rehashing directory %d */
 	{ PR_3A_OPTIMIZE_DIR,
@@ -1472,7 +1472,7 @@ static struct e2fsck_problem problem_table[] = {
 	/* Pass 4: Checking reference counts */
 	{ PR_4_PASS_HEADER,
 	  N_("Pass 4: Checking reference counts\n"),
-	  PROMPT_NONE, 0 },
+	  PROMPT_NONE, PR_NO_PROBLEM },
 
 	/* Unattached zero-length inode */
 	{ PR_4_ZERO_LEN_INODE,
@@ -1501,7 +1501,7 @@ static struct e2fsck_problem problem_table[] = {
 	/* Pass 5: Checking group summary information */
 	{ PR_5_PASS_HEADER,
 	  N_("Pass 5: Checking @g summary information\n"),
-	  PROMPT_NONE, 0 },
+	  PROMPT_NONE, PR_NO_PROBLEM },
 
 	/* Padding at end of inode bitmap is not set. */
 	{ PR_5_INODE_BMAP_PADDING,
@@ -1629,6 +1629,13 @@ static struct e2fsck_problem problem_table[] = {
 	  N_("@g %g @i(s) in use but @g is marked INODE_UNINIT\n"),
 	  PROMPT_FIX, PR_PREEN_OK },
 
+	{ PR_5_DONT_DISCARD,
+	  N_("There has been some errors during the check. I will not "
+	     "attempt to discard free data and inode blocks for safety "
+	     "reasons. If you wish to discard free data and inode blocks, "
+	     "run e2fsck once again.\n"),
+	  PROMPT_NONE, PR_NO_PROBLEM },
+
 	/* Post-Pass 5 errors */
 
 	/* Recreate journal if E2F_FLAG_JOURNAL_INODE flag is set */
@@ -1755,6 +1762,10 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx)
 		printf(_("Unhandled error code (0x%x)!\n"), code);
 		return 0;
 	}
+	/* Keep track of real problems only */
+	if (!(ptr->flags & PR_NO_PROBLEM)) {
+		ctx->problem_history |= code;
+	}
 	if (!(ptr->flags & PR_CONFIG)) {
 		char	key[9], *new_desc;
 
diff --git a/e2fsck/problem.h b/e2fsck/problem.h
index 7c4c156..c3431ac 100644
--- a/e2fsck/problem.h
+++ b/e2fsck/problem.h
@@ -983,6 +983,9 @@ struct problem_context {
 /* Inode in use but group is marked INODE_UNINIT */
 #define PR_5_INODE_UNINIT		0x050019
 
+/* Do not attempt to discard */
+#define PR_5_DONT_DISCARD		0x05001A
+
 /*
  * Post-Pass 5 errors
  */
diff --git a/e2fsck/problemP.h b/e2fsck/problemP.h
index 6161189..ee6c1a3 100644
--- a/e2fsck/problemP.h
+++ b/e2fsck/problemP.h
@@ -41,3 +41,4 @@ struct latch_descr {
 #define PR_PREEN_NOHDR	0x040000 /* Don't print the preen header */
 #define PR_CONFIG	0x080000 /* This problem has been customized
 				    from the config file */
+#define PR_NO_PROBLEM	0x100000 /* Use No as an answer if preening */
-- 
1.7.2.3


  parent reply	other threads:[~2010-10-26 17:54 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-26 17:54 [PATCH 0/7] e2fsprogs: Using discard in e2fsprogs tools Lukas Czerner
2010-10-26 17:54 ` [PATCH 1/7] e2fsprogs: Add discard function into struct_io_manager Lukas Czerner
2010-11-16 18:28   ` Eric Sandeen
2010-11-16 20:16     ` Lukas Czerner
2010-11-16 21:09       ` Eric Sandeen
2010-11-18  9:52         ` Lukas Czerner
2010-10-26 17:54 ` [PATCH 2/7] e2fsprogs: Add discard_zeroes_data " Lukas Czerner
2010-11-16 18:46   ` Eric Sandeen
2010-10-26 17:54 ` Lukas Czerner [this message]
2010-11-16 20:03   ` [PATCH 3/7] e2fsck: Keep track of problems during the check Eric Sandeen
2010-10-26 17:54 ` [PATCH 4/7] e2fsck: Discard free data and inode blocks Lukas Czerner
2010-11-16 21:06   ` Eric Sandeen
2010-11-18 12:12     ` Lukas Czerner
2010-10-26 17:54 ` [PATCH 5/7] mke2fs: Change -K option to discard/nodiscard Lukas Czerner
2010-10-26 18:41   ` Eric Sandeen
2010-10-26 19:24   ` [PATCH 5/7] mke2fs: Deprecate -K option, introduce discard/nodiscard Lukas Czerner
2010-11-16 21:14   ` [PATCH 5/7] mke2fs: Change -K option to discard/nodiscard Eric Sandeen
2010-11-18 10:00     ` Lukas Czerner
2010-10-26 17:54 ` [PATCH 6/7] mke2fs: Use unix_discard() for discards Lukas Czerner
2010-11-16 21:17   ` Eric Sandeen
2010-10-26 17:54 ` [PATCH 7/7] mke2fs: Use io_manager discard_zeroes_data property Lukas Czerner
2010-11-16 21:18   ` Eric Sandeen

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=1288115658-7004-4-git-send-email-lczerner@redhat.com \
    --to=lczerner@redhat.com \
    --cc=adilger@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=sandeen@redhat.com \
    --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).