Skip to contentSkip to conversation

Adds two extended options and config file counterparts.

PATCH Applied Girish Shilamkar 2 participants 2 messages Jul 24, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 9/13 Adds two extended options and config file counterparts.

This patch adds two extended options and config file counterparts. On the command line:

-E clone=dup|zero

Select the block cloning method. "dup" is old behavior which remains the default. "zero" is a new method that substitutes zero-filled blocks for the shared blocks in all the files that claim them.

-E shared=preserve|lost+found|delete

Select the disposition of files containing shared blocks. "preserve" is the old behavior which remains the default. "lost+found" causes files to be unlinked after cloning so they will be reconnected to
/lost+found in pass 3. "delete" skips cloning entirely and simply
deletes the files.

In the config file:
[options]
clone=dup|zero
shared=preserve|lost+found|delete

e2fsck/e2fsck.h +13 -0
Index: e2fsprogs-1.40.1/e2fsck/e2fsck.h
===================================================================
@@ -183,6 +183,17 @@ struct resource_track {
 #define E2F_PASS_5	5
 #define E2F_PASS_1B	6
 
+typedef	enum { 
+	E2F_SHARED_PRESERVE = 0, 
+	E2F_SHARED_DELETE,
+	E2F_SHARED_LPF
+} shared_opt_t;
+
+typedef enum {
+	E2F_CLONE_DUP = 0,
+	E2F_CLONE_ZERO
+} clone_opt_t;
+
 /*
  * Define the extended attribute refcount structure
  */
@@ -332,6 +343,8 @@ struct e2fsck_struct {
 	time_t now;
 
 	int ext_attr_ver;
+	shared_opt_t shared;
+	clone_opt_t clone;
 
 	profile_t	profile;
 
e2fsck/unix.c +76 -0

100 lines not on this page · raw message

e2fsck/pass1b.c +37 -11

87 lines not on this page · raw message

e2fsck/problem.h +7 -1
Index: e2fsprogs-1.40.1/e2fsck/problem.h
===================================================================
@@ -542,7 +542,13 @@ struct problem_context {
 
 /* Couldn't clone file (error) */
 #define PR_1D_CLONE_ERROR	0x013008
-		
+
+/* File with shared blocks found */
+#define PR_1D_DISCONNECT_QUESTION 0x013009
+
+/* Couldn't unlink file (error) */
+#define PR_1D_DISCONNECT_ERROR	0x01300A
+
 /*
  * Pass 2 errors
  */
e2fsck/problem.c +8 -0
Index: e2fsprogs-1.40.1/e2fsck/problem.c
===================================================================
@@ -917,6 +917,14 @@ static struct e2fsck_problem problem_tab
 	{ PR_1D_CLONE_ERROR,
 	  N_("Couldn't clone file: %m\n"), PROMPT_NONE, 0 },
 
+	/* File with shared blocks found */
+	{ PR_1D_DISCONNECT_QUESTION,
+	  N_("File with shared blocks found\n"), PROMPT_CONNECT, 0 },
+
+	/* Couldn't unlink file (error) */
+	{ PR_1D_DISCONNECT_ERROR,
+	  N_("Couldn't unlink file: %m\n"), PROMPT_NONE, 0 },
+
 	/* Pass 2 errors */
 
 	/* Pass 2: Checking directory structure */
e2fsck/e2fsck.8.in +13 -0
Index: e2fsprogs-1.40.1/e2fsck/e2fsck.8.in
===================================================================
@@ -165,6 +165,19 @@ following options are supported:
 Assume the format of the extended attribute blocks in the filesystem is
 the specified version number.  The version number may be 1 or 2.  The
 default extended attribute version format is 2.
+.TP
+.BI clone= dup|zero
+Resolve files with shared blocks in pass 1D by giving each file a private
+copy of the blocks (dup);
+or replacing the shared blocks with private, zero-filled blocks (zero).  
+The default is dup.
+.TP
+.BI shared= preserve|lost+found|delete
+Files with shared blocks discovered in pass 1D are cloned and then left 
+in place (preserve); 
+cloned and then disconnected from their parent directory,
+then reconnected to /lost+found in pass 3 (lost+found); 
+or simply deleted (delete).  The default is preserve.
 .RE
 .TP
 .B \-f
e2fsck/e2fsck.conf.5.in +14 -0
Index: e2fsprogs-1.40.1/e2fsck/e2fsck.conf.5.in
===================================================================
@@ -92,6 +92,20 @@ This boolean relation controls whether o
 filesystem checks (either based on time or number of mounts) should 
 be doubled if the system is running on battery.  It defaults to 
 true.
+.TP
+.I clone
+This string relation controls the default handling of shared blocks in pass 1D.
+It can be set to dup or zero.  See the
+.I "-E clone" 
+option description in e2fsck(8).
+.TP
+.I shared
+This string relation controls the default disposition of files discovered to 
+have shared blocks in pass 1D.  It can be set to preserve, lost+found, 
+or delete.  See the
+.I "-E shared" 
+option description in e2fsck(8).
+
 .SH THE [problems] STANZA
 Each tag in the
 .I [problems] 
#1 lore raw
Quoted 10 lines · Girish Shilamkar

This patch adds two extended options and config file counterparts. On the command line:

-E shared=preserve|lost+found|delete

Select the disposition of files containing shared blocks. "preserve" is the old behavior which remains the default. "lost+found" causes files to be unlinked after cloning so they will be reconnected to
/lost+found in pass 3. "delete" skips cloning entirely and simply
deletes the files.

Jim Garlick and I discussed this back in April, and I pointed out a flaw in his patch. It doesn't correctly handle the case where the system administrator wishes to move an inode that contains blocks claimed by other inodes to lost+found, since it only unlinks the first filename of the inode. The result is that the inode loses one of its directory entries, but it doesn't get oved to lost+found.

Jim reworked the patch to solve this issue, by keeping a linked list of all of the directory entries where a particular inode could be found. This increases the memory used and increases the time to do pass 1C, though. The patch you have in your patch queue is the original version of the patch, not his updated one.

I'm still not happy with this approach, though, since it adds extra complexity and special case handling into e2fsprogs. I had made a counter-proposal as a better long-term approach, which Jim seemed to agree would meet his needs:

Quoted 9 lines

One of my long-term plans was to extend the fix_problem() function to log a detailed set of problems fixed into a file (either binary or XML) that could parsed by other programs as part of some kind of recovery process. What would get written out is the problem ID plus the entire problem_context structure, which has actually quite a lot of information. This would be enough for a lot of post-processing, including making it easier for people to implement policies such as deleted or archiving for review by the Site Security Officer any files which had some of their blocks cloned.

- Ted