Skip to contentSkip to conversation

Lustre e2fsprogs patch series

PATCH In review Andreas Dilger 4 participants 37 messages Feb 2, 2008 – Mar 17, 2008

lore
Share & tools
lore
#0 lore raw

cover Lustre e2fsprogs patch series

The following series of emails will contain the large part of the e2fsprogs patch series that is used for Lustre. It will not contain the regression tests for EXTENTS nor the DIR_NLINK features, as those are very large and were previously submitted.

A full tarball that includes the patches, series, and regression tests will be uploaded to ftp://ftp.lustre.org/pub/lustre/other/e2fsprogs/

Patch series:

e2fsprogs-specdotin.patch
e2fsprogs-eacheck.patch
e2fsprogs-extended_ops.patch
e2fsprogs-tests-f_unsorted_EAs.patch
e2fsprogs-tests-f_ea_checks.patch
e2fsprogs-nlinks.patch
e2fsprogs-extents.patch
e2fsprogs-config-before-cmdline.patch
e2fsprogs-SLES10--m-support.patch
e2fsprogs-uninit.patch
e2fsprogs-nlinks-flag.patch
e2fsprogs-expand-extra-isize.patch
e2fsprogs-tests-f_expisize.patch
e2fsprogs-tests-f_expisize_ea_del.patch
e2fsprogs-ibadness-counter.patch
e2fsprogs-tests-f_ibadness.patch
e2fsprogs-tests-f_ibadness_bad_extents.patch
e2fsprogs-tests-f_random_corruption.patch
e2fsprogs-stride_option.patch
e2fsprogs-mmp.patch
e2fsprogs-journal_chksum.patch
e2fsprogs-tests-f_jchksum_bblk.patch
e2fsprogs-tests-f_jchksum_blast_trans.patch
e2fsprogs-tests-f_jchksum_remount.patch
e2fsprogs-i_size-corruption.patch
e2fsprogs-fiemap.patch
e2fsprogs-debugfs-supported_features.patch
e2fsprogs-lts-make_rpms.patch

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#1 lore raw

PATCH 1/28 e2fsprogs-specdotin.patch

Add the distro type to the RPM release number, so that it is possible release multiple distro packages without having conflicting RPM package names.

Allow the RPM built from upstream to replace the split packages provided by the distros. At some point in the future it may be desirable to also split the RPM built by this spec file, but this is complicated by the fact that SLES and RHEL have different splits.

e2fsprogs.spec.in +10 -1
Index: e2fsprogs-1.40.5/e2fsprogs.spec.in
===================================================================
@@ -6,13 +6,22 @@
 Summary: Utilities for managing the second extended (ext2) filesystem.
 Name: e2fsprogs
 Version: @E2FSPROGS_PKGVER@
-Release: 0
+Release: 0%{_vendor}
 License: GPLv2
 Group: System Environment/Base
 Source:  ftp://download.sourceforge.net/pub/sourceforge/e2fsprogs/e2fsprogs-%{version}.tar.gz
 Url: http://e2fsprogs.sourceforge.net/
 Prereq: /sbin/ldconfig
 BuildRoot: %{_tmppath}/%{name}-root
+%if %{_vendor} == "suse"
+Group: System/Filesystems
+Provides: e2fsbn ext2fs libcom_err = %{version}
+Obsoletes: ext2fs libcom_err < %{version}
+%else
+Group: System Environment/Base
+Obsoletes: e2fsprogs-libs < %{version}
+Provides: e2fsprogs-libs = %{version}
+%endif
 
 %description
 The e2fsprogs package contains a number of utilities for creating,

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#2 lore raw

PATCH 2/28 e2fsprogs-eacheck.patch

In reply to Andreas Dilger

Verify in-inode EA structure.
Allow in-inode EAs to have a checksum.
Connect zero-length inodes that have an EA to lost+found.

e2fsck/e2fsck.h +3 -0
Index: e2fsprogs-1.40.5/e2fsck/e2fsck.h
===================================================================
@@ -478,6 +478,9 @@ extern void init_resource_track(struct r
 extern int inode_has_valid_blocks(struct ext2_inode *inode);
 extern void e2fsck_read_inode(e2fsck_t ctx, unsigned long ino,
 			      struct ext2_inode * inode, const char * proc);
+extern void e2fsck_read_inode_full(e2fsck_t ctx, unsigned long ino,
+				   struct ext2_inode *inode,
+				   const int bufsize, const char *proc);
 extern void e2fsck_write_inode(e2fsck_t ctx, unsigned long ino,
 			       struct ext2_inode * inode, const char * proc);
 extern void e2fsck_write_inode_full(e2fsck_t ctx, unsigned long ino,
e2fsck/pass1.c +28 -9
Index: e2fsprogs-1.40.5/e2fsck/pass1.c
===================================================================
@@ -264,6 +264,7 @@ static void check_ea_in_inode(e2fsck_t c
 	remain = storage_size - sizeof(__u32); 
 
 	while (!EXT2_EXT_IS_LAST_ENTRY(entry)) {
+		__u32 hash;
 
 		/* header eats this space */
 		remain -= sizeof(struct ext2_ext_attr_entry);
@@ -291,9 +292,12 @@ static void check_ea_in_inode(e2fsck_t c
 			problem = PR_1_ATTR_VALUE_BLOCK;
 			goto fix;
 		}
-		
-		/* e_hash must be 0 in inode's ea */
-		if (entry->e_hash != 0) {
+
+		hash = ext2fs_ext_attr_hash_entry(entry,
+						  start + entry->e_value_offs);
+
+		/* e_hash may be 0 in older inode's ea */
+		if (entry->e_hash != 0 && entry->e_hash != hash) {
 			pctx->num = entry->e_hash;
 			problem = PR_1_ATTR_HASH;
 			goto fix;
@@ -308,15 +312,12 @@ fix:
 	 * it seems like a corruption. it's very unlikely we could repair
 	 * EA(s) in automatic fashion -bzzz
 	 */
-#if 0
-	problem = PR_1_ATTR_HASH;
-#endif
 	if (problem == 0 || !fix_problem(ctx, problem, pctx))
 		return;
 
-	/* simple remove all possible EA(s) */
+	/* simply remove all remaining EA(s) */
 	*((__u32 *)start) = 0UL;
-	e2fsck_write_inode_full(ctx, pctx->ino, pctx->inode,
+	e2fsck_write_inode_full(ctx, pctx->ino,(struct ext2_inode *)pctx->inode,
 				EXT2_INODE_SIZE(sb), "pass1");
 }
 
@@ -1360,10 +1361,13 @@ static int check_ext_attr(e2fsck_t ctx, 
 	entry = (struct ext2_ext_attr_entry *)(header+1);
 	end = block_buf + fs->blocksize;
 	while ((char *)entry < end && *(__u32 *)entry) {
+		__u32 hash;
+
 		if (region_allocate(region, (char *)entry - (char *)header,
 			           EXT2_EXT_ATTR_LEN(entry->e_name_len))) {
 			if (fix_problem(ctx, PR_1_EA_ALLOC_COLLISION, pctx))
 				goto clear_extattr;
+			break;
 		}
 		if ((ctx->ext_attr_ver == 1 &&
 		     (entry->e_name_len == 0 || entry->e_name_index != 0)) ||
@@ -1371,6 +1375,7 @@ static int check_ext_attr(e2fsck_t ctx, 
 		     entry->e_name_index == 0)) {
 			if (fix_problem(ctx, PR_1_EA_BAD_NAME, pctx))
 				goto clear_extattr;
+			break;
 		}
 		if (entry->e_value_block != 0) {
 			if (fix_problem(ctx, PR_1_EA_BAD_VALUE, pctx))
@@ -1387,6 +1392,17 @@ static int check_ext_attr(e2fsck_t ctx, 
 			if (fix_problem(ctx, PR_1_EA_ALLOC_COLLISION, pctx))
 				goto clear_extattr;
 		}
+
+		hash = ext2fs_ext_attr_hash_entry(entry, block_buf +
+							 entry->e_value_offs);
+
+		if (entry->e_hash != hash) {
+			pctx->num = entry->e_hash;
+			if (fix_problem(ctx, PR_1_ATTR_HASH, pctx))
+				goto clear_extattr;
+			entry->e_hash = hash;
+		}
+
 		entry = EXT2_EXT_ATTR_NEXT(entry);
 	}
 	if (region_allocate(region, (char *)entry - (char *)header, 4)) {
@@ -1508,8 +1524,11 @@ static void check_blocks(e2fsck_t ctx, s
 		}
 	}
 
-	if (inode->i_file_acl && check_ext_attr(ctx, pctx, block_buf))
+	if (inode->i_file_acl && check_ext_attr(ctx, pctx, block_buf)) {
+		if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
+			goto out;
 		pb.num_blocks++;
+	}
 
 	if (ext2fs_inode_has_valid_blocks(inode))
 		pctx->errcode = ext2fs_block_iterate2(fs, ino,
e2fsck/pass4.c +34 -18

122 lines not on this page · raw message

e2fsck/problem.c +1 -1
Index: e2fsprogs-1.40.5/e2fsck/problem.c
===================================================================
@@ -776,7 +776,7 @@ static struct e2fsck_problem problem_tab
 
 	/* invalid ea entry->e_hash */	
 	{ PR_1_ATTR_HASH,
-	  N_("@a in @i %i has a hash (%N) which is @n (must be 0)\n"),
+	  N_("@a in @i %i has a hash (%N) which is @n\n"),
 	  PROMPT_CLEAR, PR_PREEN_OK },
 
 	/* inode appears to be a directory */
e2fsck/util.c +14 -0
Index: e2fsprogs-1.40.5/e2fsck/util.c
===================================================================
@@ -393,6 +393,20 @@ void e2fsck_read_inode(e2fsck_t ctx, uns
 	}
 }
 
+void e2fsck_read_inode_full(e2fsck_t ctx, unsigned long ino,
+			    struct ext2_inode *inode, int bufsize,
+			    const char *proc)
+{
+	int retval;
+
+	retval = ext2fs_read_inode_full(ctx->fs, ino, inode, bufsize);
+	if (retval) {
+		com_err("ext2fs_read_inode_full", retval,
+			_("while reading inode %ld in %s"), ino, proc);
+		fatal_error(ctx, 0);
+	}
+}
+
 extern void e2fsck_write_inode_full(e2fsck_t ctx, unsigned long ino,
 			       struct ext2_inode * inode, int bufsize,
 			       const char *proc)
lib/ext2fs/ext2_ext_attr.h +1 -1
Index: e2fsprogs-1.40.5/lib/ext2fs/ext2_ext_attr.h
===================================================================
@@ -30,7 +30,7 @@ struct ext2_ext_attr_entry {
 	__u32	e_value_block;	/* disk block attribute is stored on (n/i) */
 	__u32	e_value_size;	/* size of attribute value */
 	__u32	e_hash;		/* hash value of name and value */
-#if 0
+#if 1
 	char	e_name[0];	/* attribute name */
 #endif
 };
lib/ext2fs/ext2fs.h +8 -0
Index: e2fsprogs-1.40.5/lib/ext2fs/ext2fs.h
===================================================================
@@ -75,10 +75,12 @@ typedef __u32		ext2_dirhash_t;
 #include "com_err.h"
 #include "ext2_io.h"
 #include "ext2_err.h"
+#include "ext2_ext_attr.h"
 #else
 #include <et/com_err.h>
 #include <ext2fs/ext2_io.h>
 #include <ext2fs/ext2_err.h>
+#include <ext2fs/ext2_ext_attr.h>
 #endif
 
 /*
@@ -711,6 +713,8 @@ extern errcode_t ext2fs_dup_handle(ext2_
 extern errcode_t ext2fs_expand_dir(ext2_filsys fs, ext2_ino_t dir);
 
 /* ext_attr.c */
+extern __u32 ext2fs_ext_attr_hash_entry(struct ext2_ext_attr_entry *entry,
+					void *data);
 extern errcode_t ext2fs_read_ext_attr(ext2_filsys fs, blk_t block, void *buf);
 extern errcode_t ext2fs_write_ext_attr(ext2_filsys fs, blk_t block,
 				       void *buf);
@@ -961,6 +965,10 @@ extern errcode_t ext2fs_create_resize_in
 /* swapfs.c */
 extern void ext2fs_swap_ext_attr(char *to, char *from, int bufsize, 
 				 int has_header);
+extern void ext2fs_swap_ext_attr_header(struct ext2_ext_attr_header *to_header,
+					struct ext2_ext_attr_header *from_hdr);
+extern void ext2fs_swap_ext_attr_entry(struct ext2_ext_attr_entry *to_entry,
+				       struct ext2_ext_attr_entry *from_entry);
 extern void ext2fs_swap_super(struct ext2_super_block * super);
 extern void ext2fs_swap_group_desc(struct ext2_group_desc *gdp);
 extern void ext2fs_swap_inode_full(ext2_filsys fs, struct ext2_inode_large *t,
lib/ext2fs/ext_attr.c +37 -0
Index: e2fsprogs-1.40.5/lib/ext2fs/ext_attr.c
===================================================================
@@ -23,6 +23,43 @@
 
 #include "ext2fs.h"
 
+#define NAME_HASH_SHIFT 5
+#define VALUE_HASH_SHIFT 16
+
+/*
+ * ext2_xattr_hash_entry()
+ *
+ * Compute the hash of an extended attribute.
+ */
+__u32 ext2fs_ext_attr_hash_entry(struct ext2_ext_attr_entry *entry, void *data)
+{
+	__u32 hash = 0;
+	char *name = entry->e_name;
+	int n;
+
+	for (n = 0; n < entry->e_name_len; n++) {
+		hash = (hash << NAME_HASH_SHIFT) ^
+		       (hash >> (8*sizeof(hash) - NAME_HASH_SHIFT)) ^
+		       *name++;
+	}
+
+	/* The hash needs to be calculated on the data in little-endian. */
+	if (entry->e_value_block == 0 && entry->e_value_size != 0) {
+		__u32 *value = (__u32 *)data;
+		for (n = (entry->e_value_size + EXT2_EXT_ATTR_ROUND) >>
+			 EXT2_EXT_ATTR_PAD_BITS; n; n--) {
+			hash = (hash << VALUE_HASH_SHIFT) ^
+			       (hash >> (8*sizeof(hash) - VALUE_HASH_SHIFT)) ^
+			       ext2fs_le32_to_cpu(*value++);
+		}
+	}
+
+	return hash;
+}
+
+#undef NAME_HASH_SHIFT
+#undef VALUE_HASH_SHIFT
+
 errcode_t ext2fs_read_ext_attr(ext2_filsys fs, blk_t block, void *buf)
 {
 	errcode_t	retval;
lib/ext2fs/swapfs.c +29 -16

67 lines not on this page · raw message

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group Sun Microsystems of Canada, Inc.

#3 lore raw

PATCH 3/28 e2fsprogs-extended_ops.patch

In reply to Andreas Dilger

Minor reformatting patch to make applying later patches easier.

e2fsck/unix.c +6 -6
Index: e2fsprogs-cfs/e2fsck/unix.c
===================================================================
@@ -537,14 +537,13 @@ static void parse_extended_opts(e2fsck_t
 				continue;
 			}
 			ea_ver = strtoul(arg, &p, 0);
-			if (*p ||
-			    ((ea_ver != 1) && (ea_ver != 2))) {
-				fprintf(stderr,
-					_("Invalid EA version.\n"));
+			if (*p == '\0' && (ea_ver == 1 || ea_ver == 2)) {
+				ctx->ext_attr_ver = ea_ver;
+			} else {
+				fprintf(stderr, _("Invalid EA version.\n"));
 				extended_usage++;
 				continue;
 			}
-			ctx->ext_attr_ver = ea_ver;
 		} else {
 			fprintf(stderr, _("Unknown extended option: %s\n"),
 				token);
@@ -558,7 +557,8 @@ static void parse_extended_opts(e2fsck_t
 		       "and may take an argument which\n"
 		       "is set off by an equals ('=') sign.  "
 			"Valid extended options are:\n"
-		       "\tea_ver=<ea_version (1 or 2)>\n\n"), stderr);
+		       "\tea_ver=<ea_version (1 or 2)>\n"
+		       "\n"), stderr);
 		exit(1);
 	}
 }

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#4 lore raw

Re: [PATCH][4/28] e2fsprogs-tests-f_unsorted_EAs.patch

In reply to Andreas Dilger

Attached binary patch.

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

Test case for allowing unsorted EAs in the fast in-inode space.

tests/f_unsorted_EAs/expect.1 new file +11 -0
Index: e2fsprogs-1.39/tests/f_unsorted_EAs/expect.1
===================================================================
@@ -0,0 +1,11 @@
+Adding dirhash hint to filesystem.
+
+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: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 12/2048 files (0.0% non-contiguous), 1294/2048 blocks
+Exit status is 1
tests/f_unsorted_EAs/expect.2 new file +7 -0
Index: e2fsprogs-1.39/tests/f_unsorted_EAs/expect.2
===================================================================
@@ -0,0 +1,7 @@
+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/2048 files (0.0% non-contiguous), 1294/2048 blocks
+Exit status is 0
tests/f_unsorted_EAs/name new file +1 -0
Index: e2fsprogs-1.39/tests/f_unsorted_EAs/name
===================================================================
@@ -0,0 +1 @@
+unsorted EAs in inode should not be deleted

*** /dev/null 2007-04-21 00:13:05.585391708 +0530
--- e2fsprogs-1.39/tests/f_unsorted_EAs/image.gz 2007-04-21 01:14:51.000000000 +0530
***************
*** 0 ****
--- 1,3 ----
+ �3)Fimage��y�eA���@f@Q�M��v�.�(���$� �� ˸�T�� &Yn����$ni�J����h���
+ I���s���������z}�9��{�sϹ�\����ʏ�ZX�b���UK-��Ts�w������N �lqaqa>la�K��,.�䚥���kl�N�������}�9��m�?��~����g���.���~�s¹�>��U�׌�c��yMZ��H�Җi��u�q�I�&�4m�xݩ�i�zm��|�����MWY%�[���ww��/?�:l���m�|��o{��� ƥw�/[�����/�����Lc��7�ħ�3�����p��߱�u������_�ޢ�n��v��q���F��䌻�O�����j�Z���Mr>�Q�4��5��}����O�o�_u��յ�v���4����b��j���x���^�����?��jV�����o{��m;dx�K���v�l����w���)�a�=kắU5ݬ��]> ����+ۮ��]8_�~^U���G�__���ꡫ˾��a(�ix]͚���>����Um�Ue��uY�CY�E_4u�6��n�*� -�"��l�GMV5}7=��� �Rvu;�~�d�e�a]�X5EWN�󪳪���5�,�ƭJkW����U�v�����,l����{��G��qG����r�ţ֯�����5׹��b���?�[f+�������Mg�1�4?6��i���.^3��t������nsb�����,=����������o��<ly�&K?7��\\������&[����.\?�|���� ����C�W]��*��o�3�_�\X8�;��c���U ;^�q�,.,�(m�V���cc����6����� �v���4����b��j���x���^�����?��jV�����o{��m;dx�K���v�l����w���)�!��l��V�t�zw�4l�k?�l�jw�|\�yUYt����~}9�ꪫ��.�������u5k�k��~�rV�uW�]_�eQeU}��}����i�h2���Rt�YY4yX�����a6+3$K���|�m���m�uyb�]9 ϫΪ~�r֌�܀���7���[�������k_����G��Y'>-������w���7��5�/
+ ��n��?]�pykm��5��<oMZ��H�Җi��u�q�I�&�4mkc��0�}�� ��v[���U��k��m6_u���=~ף�?�#����-7Z<j�z+���A��o���>����ʏ+V-,�x�@��=O\j�5?lqa��\�8�}����{�����f��7Z���IW=���_��6'�O���'|�or�]���ۥ���o|�cN8wק��ZGm\����q�����ܪ�����������/����Mi���z��{���Y��l>�iZ�n?���Ջ_�����t�O�z�4|Vv�O�n _�78 �f�����3�����V�ڼ���t��:q�>=}�S����?~��#�e��lV�u.Y�|����;|x� E�i�x�ˏN9w�7�t?����������m��i�A��v�}��C5�r5���#����~4 o����[^���!���6[�k���l�g��OQ������<=7����4W��|����|��{��a����.Ok���n5���v>�i>�KG�{����f6���]������K�{uɚ�q�l��mKߗ5}�T�eZ��I�{�o�ǵ��k~~e�ޱӡ�ηs�οg��iz����q��㚶���fy��p�#�7����,V��� g�g�vM1�;}�q�C�O���K���Ӹ+V�}}���0߷�j>/�����ї���i\���˷��}��s��4nh��k�ny������ڴ_��|^N�byz����quYΗ�r���^074�q��,��.z������|�v+�;�G�;��������V���q�7�qm_��]������� ��Xz�����p�����z>����� �}�4����>q���G�C/,߲4�*�q����y��>�)���{��2>�A��4n(��:�������[��k+����\���.���g��z���>�{]4�L�� ��ݑ]��Ϧ-�v������Ne_4UUU]�|_���UΛ}N�}�w�,ofu�uC޷r��窯�<���j����X�E�˽��z�Ű�=�u�w��əB�ߦ��_tycʫϪr�f�r)�w���Y�wϼi�}Q5y\��ڥ�2�y��0�����*�v�EFWՙ����߯�2K����V�Y�Y�u9.e�f�a6.�,S�rm6��~6��P����β��ܗM���l�Kζ(��n�Y��e;~Cg�d�ʾ��uY�fMf�j�j6~�f[6]YC�w�qCdJ}9��Y�)WtCSft�(+��6�!s8��P�_����!/�W�l>��.۫'1�u6S��k�a���*��g��Lp膪��-��m�t����h�-�G��7�f'���/�3�a�.Ҧ��Mó`YIY����_��%�ɏ[!�oh���m\����vwåq�3�YV�5��v�z�%D_����f��kY�U^< ��Yu� ���m5n��{V]f�js1P�*x�3WB=n���F��+r�U��%�"?��m���:�\6M5,����6k��eh�a\Q�d]��vVg�֤���˵Mf(���嚹������6�q�};���5K�y��3���r\�}���xfAʮ��{{#��쳖��f����KW�:{^?^M۠�o3�y�ta:m���?v���Y5 �|[��i���0���z<���_묥,H1�0r�2�s���d�7�8$�� U��7+:uhsQ_��m���2��Y��]��)�sdֳ������ �,\?t9 �}f:&ƳB����cs،GQ���� �e��|r|�h'9�d����#RN�I�CM0/�K������͚���*g�f���>��iG��>�!S�5�a���֍?���7G�p�<*�u�U2w�"K;��l���Yh�_� ���=�,'�q�Ϲ��Y^+;Q;��xͩ����r/ڏ�L3��&��� �-?T�xu=���ٸ���W��'ݜ@�����x�|�P� 6�]�x����k�,oNbUΠY����Ɠ����g���"狺�2b�-����҅k��>����-.,l�n�n�n��O��vH��vL��vJ�J�N��n�vN�M�K��]��ۧ���"��Juj�,��K���yH��=��ӝҝӞ�.��ni�t�t��w�g��t�t�4����M�M�K���������҃ҁ���tp:$=$�K��������T}d:*=<="=2=*��IǦ������������������t|zr:!�I���g�)���������������������y�trz~���tJ�����W�Ӌҋ�K�K���ߤ��W�W�W�W�פצ�M�K�O��>�!�1��ޔޜޒޚ�!�-��ޞޑޙޕޝ�1�'�7�Sz_z:=} }0}(���9}8}$}4},}<}"��>�>�>��J�I�M�K�O_H_Lg�sҹ�K������������t~� }3}+�K�v�0}'mH��.J�M�?��^�$]���.K�����+ҏ�O�Oӕ��o�g�����?�����jaa1�J���&�FiӴ:m�6Ok�ڴEZ��L[��Ӎ�M�6�i�t��]�y�E�e�>�N�!�n�1�^�)�*�:�~�M�9�6�.�vM�n�vK��T�*թI�Ԧ.�iH��=�� HwLwJwN{�����������=����ҽҽ�>�>i�t�t��_�z@�?�qz`: =(�JN�C�Cҡ�txzhzX:"��JO�H�L�JG�cұ鸴>=:=&=6=.=>=!=1=)���NH��4�YzJzj:1=-===#=3=+=;='=7�yz^:)�����"� ���2�0�U�������������7�����U���5��o�����ߥ�OoHoL��7�7�����HoK����w�w�w�w�L�I�M��ޗޟNOHLJg�NNIMKO�Hg�O�O�O���g�g���������tn�R�r:/}%}5}-}=}#��.H�L�J����.L�Iҿ���w���{�ti�~�,]�~�~�~�j�{6�O�Oӕ��o�g�����?��ǿ��Q���*m�6N���M��Y�<�Ik�i]�2m��N7N7Iۤ��m���v����i��;i���i��{i�t�t����6i�t�t��K�5�A�}�-�a*R��T�&�R��ԧ!��HwHwLwJwN{�����������=����ҽҽ�>�>i�t�t��_�z@�?�qz`: =(�JN�C�Cҡ�txzhzX:"��JO�H�L�JG�cұ鸴>=:=&=6=.=>=!=1=)���NH��4�YzJzj:1=-===#=3=+=;='=7�yz^:)�����"� ���2�0�U�������������7�����U���5��o�����ߥ�OoHoL��7�7�����HoK����w�w�w�w�L�I�M��ޗޟNOHLJg�NNIMKO�Hg�O�O�O���g�g���������tn�R�r:/}%}5}-}=}#��.H�L�J����.L�Iҿ���w���{�ti�~�,]�~�~�~��H?N?I?MW��ҿ����ӿ��H?����9�Ӫ�Q�8m�n�6M��fi�&�M[�ui˴U�:�8�$m�n��M7Kۥ��[�[�������諾ҭҭ��ۤ��m���.i����i��He�R��4Km�R���{�#�!�1�)�9�����JwO�H{�{�?J�J�N����}�}���~���i�������t`:(=8�II�������a�td:*=<="=2=*��IǦ������������������t|zr:!�I���g�)���������������������y�trz~���tJ�����W�Ӌҋ�K�K���ߤ��W�W�W�W�פצ�M�K�O��>�!�1��ޔޜޒޚ�!�-��ޞޑޙޕޝ�1�'�7�Sz_z:=} }0}(���9}8}$}4},}<}"��>�>�>��J�I�M�K�O_H_Lg�sҹ�K������������t~� }3}+�K�v�0}'mH��.J�M��Kҥ���ty�A�a�Q�"�8�$�4]��J��~��N���#�|��o��?�J���&�FiӴ:m�6Ok6��w���6��ݪ����A��V_w����׎?ߔv�ɮ�<��c�,��Y��L��4�?~�̇���ůO÷N��ĮL�ge�z�5����9�NûY��3=���/m��qxյy���n�N�k�O���)V/n?=~��v��;��y�K�M�69|��û����0 �(��S����8ݏn��:g~����C��}~�����z�q�PͲ\�4?�Ȼ>l�MÛ*�s��׼~q�4�-���Z�<?۟z����S�]�����<=7����4W��4��5��;�~�Ӹ����x���o8�VӸ�j��N��c�tĹW�i>�ifӸ~�5ϻl�|\?��q��Yw̆]�6�kʺ��˴����{��ߚ�kg������c�Cϝo��qWO�;%�}��8״�4��5����;������f��|�n8�=Ӹ�k�i�雍��~���_�<���]��������UT�yyŴ=o������N��~6_�=�-�G���ݧqC��_s�u��ߗ�w�צ������r���;��ǜ?���r�|����7?�������;le��p��qM=���n�y'���i}V������V���q�7�qm_��]������� ��Xz�����p�����z>����� �}�4����>q���G�C/,߲4�*�q����y��>�)���{��2>�A��4n(��:������{ڗ�h�ӻre���kN�`>������+�����u�|\3�g7TG�_�7�:o�M[������/�⋲/������r�/�f�_��7�������Y���놼o�4\��U_�yNח�P7��m��r/���rA1���n��5>9S���0��,��1��gU9t�\���J[��ʻg޴����<��r�RW�ռ�l���]]�E;�"������v\���U��̋Wyw��,�,Ë���i3�0x�)f�6��O?��r���ZZgY�i�˦�T�L��%g[�yX�f7�լi�2s�aM��,PY��l�dF���f}��ڲ�ʲ��s�"S��q5βL���2�3GY�]W�Q ��q>�\ϖ]Wd>��@_ ���e�l�r�����LMV\��l���l���6��j�l�,p[7ݬɥy9m���Ȭ�"s�fC͗}i�� �6��fX6 ςe%e���S���m&?n�l��Yzl��q�2�K�}� ��e̤gYq�L3�-�1�}��n��C�}-+�ʋgA�:k�n��<���-�yϪ�LTm.�\�w�J��m�6�Hٽ3cE�"��Ҽd[�g���6��Y��˦���}:{��f�7���0�+*���>���l�ܚ�u�w��� e�\3����~���F9��o籙H��&�8d�gv3{�2�����0̂�];��,F���g-�]�͐��%���%t��~�0��A��f>����t�NCݏˑW�U��ηU�ٝ��񘘍|�㡗���Zg-eA�鄑[�a��}'�i�!��l���Y�٨C���:g�l��n�i�����:�O��#��=�m���\f����a0�3�11�r d����f<���xxg�.����#G�8�ٸ&�n6�9�rr�NR�j��y�\���e_ɚ���*g��񬿌��)��l�Ly�׬��g�Z7�l��k�9�����mV�l�E�,�з�q�g��~5'�r<����l����=w<�f�gy��D�4w�94��n<r�ʽh?3͸��8��3D��P �����>g��g�T�I7'�b|�r<�3�92��xW8+9��Z9˛�X�3h�y|����d�t|�Yi���������_�p��-/�/����/�k�u�龺�����}�h����m�u?���L��ُV/�wݯ��~����]����i�����\��������޳Z�_8g��{������^7�ǝ7=�f��w�w�/޳���,����ֶt_��~����������l~�3��^wey�p���{��1��/��^s�q~v~���,�y���KV���gt��^�[�'�k���j~/��>�{���:��o4�/}��u���?_�� K��=�q��뎞O/o���|źk������=]��\b���s���gwy�0�|�ֵ�&w�C9� �g�� ���t��{Ӳ.��0��a�H��+u�n��}w���+��Ǜ��Dg^�&7d�U��hn6s�ڏ���b� �� �x�����f;����4_�t�(������x�ߏ/�Lw˿��BY��tn��&�(�n��|�Qe��W���5XuC3�����3�U1��gfu�e��E����4�l�&�♇>�ɜֹ��ڢ�ܘ�=��e7~VTY�y���r{�Κ�.�ωڢ�ˬ�<���2��yZ=k�Ǯ��l�O���a�W��}~5}�1~,Ҏ��6KÇb6}�1�.�N����?�����@����0_��r��
\ No newline at end of file

#5 lore raw

Re: [PATCH][5/28] e2fsprogs-tests-f_ea_checks.patch

In reply to Andreas Dilger

Attached binary test patch.

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

tests/f_ea_checks/expect.1 new file +57 -0
Index: e2fsprogs-cfs/tests/f_ea_checks/expect.1
===================================================================
@@ -0,0 +1,57 @@
+Pass 1: Checking inodes, blocks, and sizes
+Inode 13 has a bad extended attribute block 26.  Clear? yes
+
+Inode 13, i_blocks is 4, should be 2.  Fix? yes
+
+Extended attribute in inode 14 has a hash (1649340189) which is invalid
+Clear? yes
+
+Inode 14, i_blocks is 2, should be 0.  Fix? yes
+
+Inode 17 has a bad extended attribute block 28.  Clear? yes
+
+Inode 17, i_blocks is 4, should be 2.  Fix? yes
+
+Inode 16 has a bad extended attribute block 29.  Clear? yes
+
+Inode 16, i_blocks is 2, should be 0.  Fix? yes
+
+Inode 19 has a bad extended attribute block 33.  Clear? yes
+
+Inode 19, i_blocks is 2, should be 0.  Fix? yes
+
+Inode 12 has a bad extended attribute block 55.  Clear? yes
+
+Inode 12, i_blocks is 2, should be 0.  Fix? yes
+
+Inode 15, i_blocks is 2, should be 0.  Fix? yes
+
+Pass 2: Checking directory structure
+Extended attribute block for inode 15 (/far) is invalid (999).
+Clear? yes
+
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+Block bitmap differences:  -(26--29) -33 -55
+Fix? yes
+
+Free blocks count wrong for group #0 (481, counted=484).
+Fix? yes
+
+Free blocks count wrong (481, counted=484).
+Fix? yes
+
+Inode bitmap differences:  -18
+Fix? yes
+
+Free inodes count wrong for group #0 (47, counted=46).
+Fix? yes
+
+Free inodes count wrong (47, counted=46).
+Fix? yes
+
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 18/64 files (0.0% non-contiguous), 28/512 blocks
+Exit status is 1
tests/f_ea_checks/expect.2 new file +7 -0
Index: e2fsprogs-cfs/tests/f_ea_checks/expect.2
===================================================================
@@ -0,0 +1,7 @@
+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: 18/64 files (0.0% non-contiguous), 28/512 blocks
+Exit status is 0
tests/f_ea_checks/image.gz new file +4 -0
Index: e2fsprogs-cfs/tests/f_ea_checks/image.gz
===================================================================
@@ -0,0 +1,4 @@
+��,;Gimage.new��	tT��dDA
�V����M$�ybADA[-HKX���U+����UcQ����(Z&3I8�(R�� h-��A�RA�$Z����}��y�̻/����r���pվ�K���JjJJ��2��'TDY�+gu^5$�szJ���o���K��9��[�]lW5�q��o]�zчg�֏��T|J���[λ����g[4<�?n����>7�jS7tк�q|
R}��KKFz2*�����]��}���K�8�_��|�U>0�����7y��V����:���L�9Ʃp��(�Z��J��A��MFF2�%�d���ɨ���ɨ����(ۦΗ�?���e�d�ɨ�I��Cv/�G��eA����;}&�A�~�{���u���w����!���ȿ����P�4kx��i_�����ށ8���.M����F�g+;������̯���d����	���E��9���������DS-ߠ�{�G���Z~��Z����)UB��G������C���+��ԁ�������y}G�?�h�)FV�'�z�O�cʟ���In[��ljZz��a�y��S�3��^ZE���t��?����@��P����?�����m���#
����ߦ�����������e����}�P�
+}������������}���;�L�j���7��]�)��gO(�8;��9مC�f�����{b���󳖷>&v��i�>}WĎh�>6j��ئY�5�#��R.XZk�mY�ߕ>.4.|\�[�n�������N�➬��_~�g��Ksқ�V����t\,c��؜f�c�Z\ԿQ���^��Մ�w_�7kj��������^���������7_��Y.�iDx��Y���i��-X:qA��ď:��,�[9��X��&Ͼ.w��r�,�>��1�r�]ta��-r_���[����e���犟�s�҅K�/�2�c�5K��^��J^|2���7���qD�ҹ���tk�|qa��A�[Ң;��+:jr��[37�Xճd�ÓK�̝\R�scIʐ[Kz��*���Β��&��kY�ک��{Ly4����чv�r���8��#�s��#��=�sv�k�3~sJNV���m՗+vI\xZ��u+>e���*k������,Ll�:����{���6������h�J������sy����%���&����x��#�Ƕ	6=5)�[�i�,ؔ�2�gcp�Q��OM�������x�8on0qɄ`���5=]��o{]|��"��g�K�n8.��Ķ�u�C��ۜly��`꠬�����Xg�%��W.������k��D/�"�����u�=���h��gG'^U3�\�`���9{�Edn�_�N����^���}Rb��U�W��IP��#�÷�k�4�3?8������ő�Ffܾ*r��n���G�B���5V7���(#�s�������
�?���l죉-V&>Xv{�͙���7��{r����A��
+Z������P�ڻ�M;?�~i0l���9�n�ȸ`Fb��ى��]����xo|p�/w�7��XtR4{CF���u�?��l�蝢�7�I�i}_b�x���i��$^�R��:)8��� ��֠o�g��ߝ<|�9�3i�"���/z�������&��Q�/���{�۫%�9*3ѫu�Ĭ_l�_ۥJ�{�K#��9:�� ;�ᦓ������3�.�,���V5���P�����EC�
+��:=rl�#��ZY���"G�P�}���:�lP4iڜ�ճ�-2|9�8y�
\ No newline at end of file
tests/f_ea_checks/name new file +1 -0
Index: e2fsprogs-cfs/tests/f_ea_checks/name
===================================================================
@@ -0,0 +1 @@
+extended attribute block checks
#6 lore raw

Re: [PATCH][6/28] e2fsprogs-nlinks.patch

In reply to Andreas Dilger

Add support for the DIR_NLINK feature.

This patch includes the changes required to e2fsck to understand the nlink count changes made in the kernel. In pass2, while counting the links for a directory, if the link count exceeds 65000, its permanently set to EXT2_LINK_MAX + 10. In pass4, when the counted and actual nlink counts are compared, e2fsck does not flag an error if counted links = EXT2_NLINK_MAX + 10 and existing link count is 1.

It also handles the case when a directory had more than 65000 subdirs and they were later deleted. The nlink count of such a directory remains
1. In pass4 if counted links are 2 and if existing nlink count = 1, e2fsck corrects the nlink count without displaying any errors.

The file hard link count is also increased to 65000, but this cannot be exceeded.

e2fsck/pass2.c +6 -4
Index: e2fsprogs-1.40.1/e2fsck/pass2.c
===================================================================
@@ -717,7 +717,7 @@ static int check_dir_block(ext2_filsys f
 	blk_t			block_nr = db->blk;
 	ext2_ino_t 		ino = db->ino;
 	ext2_ino_t 		subdir_parent;
-	__u16			links;
+	__u32			links;
 	struct check_dir_struct	*cd;
 	char 			*buf;
 	e2fsck_t		ctx;
@@ -1024,9 +1024,11 @@ static int check_dir_block(ext2_filsys f
 			dups_found++;
 		} else
 			dict_alloc_insert(&de_dict, dirent, dirent);
-		
-		ext2fs_icount_increment(ctx->inode_count, dirent->inode,
-					&links);
+
+		ext2fs_icount_inc32(ctx->inode_count, dirent->inode, &links,
+				    ext2fs_test_inode_bitmap(ctx->inode_dir_map,
+							     dirent->inode) ?
+				    EXT2_LINK_MAX : (__u32)~0U);
 		if (links > 1)
 			ctx->fs_links_count++;
 		ctx->fs_total_count++;
e2fsck/pass4.c +14 -6
Index: e2fsprogs-1.40.1/e2fsck/pass4.c
===================================================================
@@ -99,7 +99,8 @@ void e2fsck_pass4(e2fsck_t ctx)
 	struct resource_track	rtrack;
 #endif
 	struct problem_context	pctx;
-	__u16	link_count, link_counted;
+	__u16	link_count;
+	__u32	link_counted;
 	char	*buf = 0;
 	int	group, maxgroup;
 	
@@ -145,7 +146,7 @@ void e2fsck_pass4(e2fsck_t ctx)
 		     ext2fs_test_inode_bitmap(ctx->inode_bb_map, i)))
 			continue;
 		ext2fs_icount_fetch(ctx->inode_link_info, i, &link_count);
-		ext2fs_icount_fetch(ctx->inode_count, i, &link_counted);
+		ext2fs_icount_fetch32(ctx->inode_count, i, &link_counted);
 		if (link_counted == 0) {
 			if (!buf)
 				buf = e2fsck_allocate_memory(ctx,
@@ -156,10 +157,12 @@ void e2fsck_pass4(e2fsck_t ctx)
 				continue;
 			ext2fs_icount_fetch(ctx->inode_link_info, i,
 					    &link_count);
-			ext2fs_icount_fetch(ctx->inode_count, i,
-					    &link_counted);
+			ext2fs_icount_fetch32(ctx->inode_count, i,
+					      &link_counted);
 		}
-		if (link_counted != link_count) {
+		if (link_counted != link_count &&
+		    !(ext2fs_test_inode_bitmap(ctx->inode_dir_map, i) &&
+		      link_count == 1 && link_counted > EXT2_LINK_MAX)) {
 			e2fsck_read_inode(ctx, i, inode, "pass4");
 			pctx.ino = i;
 			pctx.inode = inode;
@@ -169,7 +172,12 @@ void e2fsck_pass4(e2fsck_t ctx)
 					    PR_4_INCONSISTENT_COUNT, &pctx);
 			}
 			pctx.num = link_counted;
-			if (fix_problem(ctx, PR_4_BAD_REF_COUNT, &pctx)) {
+			/* i_link_count was previously exceeded, but no longer
+			 * is, fix this but don't consider it an error */
+			if ((LINUX_S_ISDIR(inode->i_mode) && link_counted > 1 &&
+			     (inode->i_flags & EXT2_INDEX_FL) &&
+			     link_count == 1 && !(ctx->options & E2F_OPT_NO)) ||
+			     (fix_problem(ctx, PR_4_BAD_REF_COUNT, &pctx))) {
 				inode->i_links_count = link_counted;
 				e2fsck_write_inode(ctx, i, inode, "pass4");
 			}
lib/ext2fs/ext2_fs.h +1 -0
Index: e2fsprogs-1.40.1/lib/ext2fs/ext2_fs.h
===================================================================
@@ -646,6 +646,7 @@ struct ext2_super_block {
 #define EXT2_FEATURE_INCOMPAT_SUPP	(EXT2_FEATURE_INCOMPAT_FILETYPE)
 #define EXT2_FEATURE_RO_COMPAT_SUPP	(EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
 					 EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
+					 EXT4_FEATURE_RO_COMPAT_DIR_NLINK| \
 					 EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
 
 /*
lib/ext2fs/ext2fs.h +10 -2
Index: e2fsprogs-1.40.1/lib/ext2fs/ext2fs.h
===================================================================
@@ -462,7 +462,8 @@ typedef struct ext2_icount *ext2_icount_
 					 EXT3_FEATURE_INCOMPAT_RECOVER)
 #endif
 #define EXT2_LIB_FEATURE_RO_COMPAT_SUPP	(EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|\
-					 EXT2_FEATURE_RO_COMPAT_LARGE_FILE)
+					 EXT2_FEATURE_RO_COMPAT_LARGE_FILE|\
+					 EXT4_FEATURE_RO_COMPAT_DIR_NLINK)
 
 /*
  * These features are only allowed if EXT2_FLAG_SOFTSUPP_FEATURES is passed
@@ -471,7 +472,6 @@ typedef struct ext2_icount *ext2_icount_
 #define EXT2_LIB_SOFTSUPP_INCOMPAT	(EXT3_FEATURE_INCOMPAT_EXTENTS)
 #define EXT2_LIB_SOFTSUPP_RO_COMPAT	(EXT4_FEATURE_RO_COMPAT_HUGE_FILE|\
 					 EXT4_FEATURE_RO_COMPAT_GDT_CSUM|\
-					 EXT4_FEATURE_RO_COMPAT_DIR_NLINK|\
 					 EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE)
 
 /*
@@ -795,12 +795,20 @@ extern errcode_t ext2fs_create_icount2(e
 extern errcode_t ext2fs_create_icount(ext2_filsys fs, int flags, 
 				      unsigned int size,
 				      ext2_icount_t *ret);
+extern errcode_t ext2fs_icount_fetch32(ext2_icount_t icount, ext2_ino_t ino,
+				       __u32 *ret);
 extern errcode_t ext2fs_icount_fetch(ext2_icount_t icount, ext2_ino_t ino,
 				     __u16 *ret);
+extern errcode_t ext2fs_icount_inc32(ext2_icount_t icount, ext2_ino_t ino,
+				     __u32 *ret, __u32 overflow);
 extern errcode_t ext2fs_icount_increment(ext2_icount_t icount, ext2_ino_t ino,
 					 __u16 *ret);
+extern errcode_t ext2fs_icount_dec32(ext2_icount_t icount, ext2_ino_t ino,
+				     __u32 *ret);
 extern errcode_t ext2fs_icount_decrement(ext2_icount_t icount, ext2_ino_t ino,
 					 __u16 *ret);
+extern errcode_t ext2fs_icount_store32(ext2_icount_t icount, ext2_ino_t ino,
+				       __u32 count);
 extern errcode_t ext2fs_icount_store(ext2_icount_t icount, ext2_ino_t ino,
 				     __u16 count);
 extern ext2_ino_t ext2fs_get_icount_size(ext2_icount_t icount);
lib/ext2fs/icount.c +62 -15

154 lines not on this page · raw message

e2fsck/pass3.c +6 -3
Index: e2fsprogs-1.40.1/e2fsck/pass3.c
===================================================================
@@ -581,19 +581,22 @@ errcode_t e2fsck_adjust_inode_count(e2fs
 #endif
 
 	if (adj == 1) {
-		ext2fs_icount_increment(ctx->inode_count, ino, 0);
+		ext2fs_icount_inc32(ctx->inode_count, ino, 0,
+				    ext2fs_test_inode_bitmap(ctx->inode_dir_map,
+							     ino) ?
+				    EXT2_LINK_MAX : ~0U);
 		if (inode.i_links_count == (__u16) ~0)
 			return 0;
 		ext2fs_icount_increment(ctx->inode_link_info, ino, 0);
 		inode.i_links_count++;
 	} else if (adj == -1) {
-		ext2fs_icount_decrement(ctx->inode_count, ino, 0);
+		ext2fs_icount_dec32(ctx->inode_count, ino, 0);
 		if (inode.i_links_count == 0)
 			return 0;
 		ext2fs_icount_decrement(ctx->inode_link_info, ino, 0);
 		inode.i_links_count--;
 	}
-	
+
 	retval = ext2fs_write_inode(fs, ino, &inode);
 	if (retval)
 		return retval;

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#7 lore raw

Re: [PATCH][0/28] e2fsprogs-extents.patch

In reply to Andreas Dilger

Support for checking 32-bit extents format inodes and the INCOMPAT_EXTENTS feature.

Clear the high 16 bits of extents and index entries, since the extents patches did not do this explicitly. Some parts of this code need fixing for checking > 32-bit block filesystems (when INCOMPAT_64BIT support is added), marked "FIXME: 48-bit support".

Verify extent headers in blocks, logical ordering of extents, logical ordering of indexes.

Add explicit checking of {d,t,}indirect and index blocks to detect corruption instead of implicitly doing this by checking the referred blocks and only block-at-a-time correctness. This avoids incorrectly invoking the very lengthy duplicate blocks pass for bad indirect/index blocks. We may want to tune the "threshold" for how many errors make a "bad" indirect/index block.

Add ability to split or remove extents in order to allow extent reallocation during the duplicate blocks pass.

e2fsck/Makefile.in +1 -0
Index: e2fsprogs-1.40.5/e2fsck/Makefile.in
===================================================================
@@ -256,6 +256,7 @@ super.o: $(srcdir)/super.c $(top_srcdir)
 pass1.o: $(srcdir)/pass1.c $(srcdir)/e2fsck.h \
  $(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h \
  $(top_srcdir)/lib/ext2fs/ext2fs.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
+ $(top_srcdir)/lib/ext2fs/ext3_extents.h \
  $(top_srcdir)/lib/et/com_err.h $(top_srcdir)/lib/ext2fs/ext2_io.h \
  $(top_builddir)/lib/ext2fs/ext2_err.h $(top_srcdir)/lib/ext2fs/bitops.h \
  $(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
e2fsck/e2fsck.h +1 -0
Index: e2fsprogs-1.40.5/e2fsck/e2fsck.h
===================================================================
@@ -328,6 +328,7 @@ struct e2fsck_struct {
 	__u32 large_files;
 	__u32 fs_ext_attr_inodes;
 	__u32 fs_ext_attr_blocks;
+	__u32 extent_files;
 
 	/* misc fields */
 	time_t now;
e2fsck/pass1.c +287 -30

450 lines not on this page · raw message

e2fsck/pass2.c +10 -1
Index: e2fsprogs-1.40.5/e2fsck/pass2.c
===================================================================
@@ -285,7 +285,16 @@ void e2fsck_pass2(e2fsck_t ctx)
 			ext2fs_mark_super_dirty(fs);
 		}
 	}
-	
+
+	if (!ctx->extent_files &&
+	    (sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_EXTENTS)) {
+		if (fs->flags & EXT2_FLAG_RW) {
+			sb->s_feature_incompat &=
+				~EXT3_FEATURE_INCOMPAT_EXTENTS;
+			ext2fs_mark_super_dirty(fs);
+		}
+	}
+
 #ifdef RESOURCE_TRACK
 	if (ctx->options & E2F_OPT_TIME2) {
 		e2fsck_clear_progbar(ctx);
e2fsck/problem.c +41 -0

53 lines not on this page · raw message

e2fsck/problem.h +28 -0
Index: e2fsprogs-1.40.5/e2fsck/problem.h
===================================================================
@@ -38,6 +38,7 @@ struct problem_context {
 #define PR_LATCH_LOW_DTIME 0x0070 /* Latch for pass1 orphaned list refugees */
 #define PR_LATCH_TOOBIG	0x0080	/* Latch for file to big errors */
 #define PR_LATCH_OPTIMIZE_DIR 0x0090 /* Latch for optimize directories */
+#define PR_LATCH_EXTENT_HI 0x00A0 /* Latch for extent high bits set */
 
 #define PR_LATCH(x)	((((x) & PR_LATCH_MASK) >> 4) - 1)
 
@@ -455,6 +456,33 @@ struct problem_context {
 /* inode appears to be a directory */
 #define PR_1_TREAT_AS_DIRECTORY		0x010055
 
+/* indirect block corrupt */
+#define PR_1_INDIRECT_BAD		0x010059
+
+/* wrong EXT3_FEATURE_INCOMPAT_EXTENTS flag */
+#define PR_1_EXTENT_FEATURE		0x010060
+
+/* EXT4_EXTENT_FL flag set on non-extent file */
+#define PR_1_SET_EXTENT_FL		0x010061
+
+/* EXT4_EXTENT_FL flag not set extent file */
+#define PR_1_UNSET_EXTENT_FL		0x010062
+
+/* extent index corrupt */
+#define PR_1_EXTENT_BAD			0x010063
+
+/* extent index corrupt */
+#define PR_1_EXTENT_IDX_BAD		0x010064
+
+/* extent/index has high 16 bits set - header */
+#define PR_1_EXTENT_HI			0x010065
+
+/* extent/index has high 16 bits set */
+#define PR_1_EXTENT_HI_LATCH		0x010066
+
+/* extent/index was modified & repaired - not really a problem */
+#define PR_1_EXTENT_CHANGED		0x010067
+
 /*
  * Pass 1b errors
  */
lib/ext2fs/Makefile.in +7 -0
Index: e2fsprogs-1.40.5/lib/ext2fs/Makefile.in
===================================================================
@@ -35,6 +35,7 @@ OBJS= $(DEBUGFS_LIB_OBJS) $(RESIZE_LIB_O
 	dir_iterate.o \
 	expanddir.o \
 	ext_attr.o \
+	extents.o \
 	finddev.o \
 	flushb.o \
 	freefs.o \
@@ -90,6 +91,7 @@ SRCS= ext2_err.c \
 	$(srcdir)/dupfs.c \
 	$(srcdir)/expanddir.c \
 	$(srcdir)/ext_attr.c \
+	$(srcdir)/extents.c \
 	$(srcdir)/fileio.c \
 	$(srcdir)/finddev.c \
 	$(srcdir)/flushb.c \
@@ -127,6 +129,7 @@ SRCS= ext2_err.c \
 	$(srcdir)/tst_bitops.c \
 	$(srcdir)/tst_byteswap.c \
 	$(srcdir)/tst_getsize.c \
+ 	$(srcdir)/tst_types.c \
 	$(srcdir)/tst_iscan.c \
 	$(srcdir)/unix_io.c \
 	$(srcdir)/unlink.c \
@@ -394,6 +397,10 @@ ext_attr.o: $(srcdir)/ext_attr.c $(srcdi
  $(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h \
  $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_io.h \
  $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h
+extents.o: $(srcdir)/extents.c $(srcdir)/ext2_fs.h \
+ $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext3_extents.h \
+ $(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h $(top_srcdir)/lib/et/com_err.h \
+ $(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h
 fileio.o: $(srcdir)/fileio.c $(srcdir)/ext2_fs.h \
  $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
  $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
lib/ext2fs/block.c +25 -32

103 lines not on this page · raw message

lib/ext2fs/block.h new file +33 -0
Index: e2fsprogs-1.40.5/lib/ext2fs/block.h
===================================================================
@@ -0,0 +1,33 @@
+/*
+ * block.h --- header for block iteration in block.c, extent.c
+ *
+ * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
+ *
+ * %Begin-Header%
+ * This file may be redistributed under the terms of the GNU Public
+ * License.
+ * %End-Header%
+ */
+
+struct block_context {
+	ext2_filsys	fs;
+	int (*func)(ext2_filsys	fs,
+		    blk_t	*blocknr,
+		    e2_blkcnt_t	bcount,
+		    blk_t	ref_blk,
+		    int		ref_offset,
+		    void	*priv_data);
+	e2_blkcnt_t	bcount;
+	int		bsize;
+	int		flags;
+	errcode_t	errcode;
+	char	*ind_buf;
+	char	*dind_buf;
+	char	*tind_buf;
+	void	*priv_data;
+};
+
+/* libext2fs nternal function, in extent.c */
+extern int block_iterate_extents(void *eh_buf, unsigned bufsize,blk_t ref_block,
+				 int ref_offset EXT2FS_ATTR((unused)),
+				 struct block_context *ctx);
lib/ext2fs/bmap.c +70 -0

88 lines not on this page · raw message

lib/ext2fs/ext2_err.et.in +12 -0
Index: e2fsprogs-1.40.5/lib/ext2fs/ext2_err.et.in
===================================================================
@@ -326,5 +326,17 @@ ec	EXT2_ET_TDB_ERR_NOEXIST,
 ec	EXT2_ET_TDB_ERR_RDONLY,
 	"TDB: Write not permitted"
 
+ec	EXT2_ET_EXTENT_HEADER_BAD,
+	"Corrupt extent header"
+
+ec	EXT2_ET_EXTENT_INDEX_BAD,
+	"Corrupt extent index"
+
+ec	EXT2_ET_EXTENT_LEAF_BAD,
+	"Corrupt extent"
+
+ec	EXT2_ET_EXTENT_NO_SPACE,
+	"No free space in extent map"
+
 	end
 
lib/ext2fs/ext2fs.h +22 -0
Index: e2fsprogs-1.40.5/lib/ext2fs/ext2fs.h
===================================================================
@@ -436,12 +436,14 @@ typedef struct ext2_icount *ext2_icount_
 					 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|\
 					 EXT2_FEATURE_INCOMPAT_META_BG|\
 					 EXT3_FEATURE_INCOMPAT_RECOVER|\
+ 					 EXT3_FEATURE_INCOMPAT_EXTENTS|\
 					 EXT4_FEATURE_INCOMPAT_FLEX_BG)
 #else
 #define EXT2_LIB_FEATURE_INCOMPAT_SUPP	(EXT2_FEATURE_INCOMPAT_FILETYPE|\
 					 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|\
 					 EXT2_FEATURE_INCOMPAT_META_BG|\
 					 EXT3_FEATURE_INCOMPAT_RECOVER|\
+					 EXT3_FEATURE_INCOMPAT_EXTENTS|\
 					 EXT4_FEATURE_INCOMPAT_FLEX_BG)
 #endif
 #define EXT2_LIB_FEATURE_RO_COMPAT_SUPP	(EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|\
@@ -722,6 +724,21 @@ extern errcode_t ext2fs_adjust_ea_refcou
 					   char *block_buf,
 					   int adjust, __u32 *newcount);
 
+/* extent.c */
+errcode_t ext2fs_extent_header_verify(struct ext3_extent_header *eh, int size);
+errcode_t ext2fs_extent_verify(ext2_filsys fs, struct ext3_extent *ex,
+			       struct ext3_extent *ex_prev,
+			       struct ext3_extent_idx *ix, int ix_len);
+errcode_t ext2fs_extent_index_verify(ext2_filsys fs,
+				     struct ext3_extent_idx *ix,
+				     struct ext3_extent_idx *ix_prev);
+errcode_t ext2fs_extent_remove(struct ext3_extent_header *eh,
+			       struct ext3_extent *ex);
+errcode_t ext2fs_extent_split(ext2_filsys fs, struct ext3_extent_header **eh,
+			      struct ext3_extent **ex, int count, int *flag);
+errcode_t ext2fs_extent_index_remove(struct ext3_extent_header *eh,
+				     struct ext3_extent_idx *ix);
+
 /* fileio.c */
 extern errcode_t ext2fs_file_open2(ext2_filsys fs, ext2_ino_t ino,
 				   struct ext2_inode *inode,
@@ -810,6 +827,8 @@ extern errcode_t ext2fs_image_bitmap_rea
 /* ind_block.c */
 errcode_t ext2fs_read_ind_block(ext2_filsys fs, blk_t blk, void *buf);
 errcode_t ext2fs_write_ind_block(ext2_filsys fs, blk_t blk, void *buf);
+errcode_t ext2fs_read_ext_block(ext2_filsys fs, blk_t blk, void *buf);
+errcode_t ext2fs_write_ext_block(ext2_filsys fs, blk_t blk, void *buf);
 
 /* initialize.c */
 extern errcode_t ext2fs_initialize(const char *name, int flags,
@@ -984,6 +1003,9 @@ extern void ext2fs_swap_inode_full(ext2_
 				   int bufsize);
 extern void ext2fs_swap_inode(ext2_filsys fs,struct ext2_inode *t,
 			      struct ext2_inode *f, int hostorder);
+extern void ext2fs_swap_extent_header(struct ext3_extent_header *eh);
+extern void ext2fs_swap_extent_index(struct ext3_extent_idx *ix);
+extern void ext2fs_swap_extent(struct ext3_extent *ex);
 
 /* valid_blk.c */
 extern int ext2fs_inode_has_valid_blocks(struct ext2_inode *inode);
lib/ext2fs/extents.c new file +475 -0

475 lines not on this page · raw message

lib/ext2fs/ind_block.c +82 -4

101 lines not on this page · raw message

lib/ext2fs/swapfs.c +64 -12

104 lines not on this page · raw message

lib/ext2fs/valid_blk.c +14 -2
Index: e2fsprogs-1.40.5/lib/ext2fs/valid_blk.c
===================================================================
@@ -19,6 +19,7 @@
 
 #include "ext2_fs.h"
 #include "ext2fs.h"
+#include "ext3_extents.h"
 
 /*
  * This function returns 1 if the inode's block entries actually
@@ -41,12 +42,23 @@ int ext2fs_inode_has_valid_blocks(struct
 	if (LINUX_S_ISLNK (inode->i_mode)) {
 		if (inode->i_file_acl == 0) {
 			/* With no EA block, we can rely on i_blocks */
-			if (inode->i_blocks == 0)
-				return 0;
+			if (inode->i_flags & EXT4_EXTENTS_FL) {
+				struct ext3_extent_header *eh;
+				eh = (struct ext3_extent_header *)inode->i_block;
+				if (eh->eh_entries == 0)
+					return 0;
+			} else {
+				if (inode->i_blocks == 0)
+					return 0;
+			}
 		} else {
 			/* With an EA block, life gets more tricky */
 			if (inode->i_size >= EXT2_N_BLOCKS*4)
 				return 1; /* definitely using i_block[] */
+			/*
+			 * we cant have EA + extents, so assume we aren't
+			 * using extents
+			 */
 			if (inode->i_size > 4 && inode->i_block[1] == 0)
 				return 1; /* definitely using i_block[] */
 			return 0; /* Probably a fast symlink */
tests/f_bad_disconnected_inode/expect.1 +6 -0
Index: e2fsprogs-1.40.5/tests/f_bad_disconnected_inode/expect.1
===================================================================
@@ -1,4 +1,10 @@
 Pass 1: Checking inodes, blocks, and sizes
+Inode 15 has EXTENT_FL set, but is not in extents format
+Fix? yes
+
+Inode 16 has EXTENT_FL set, but is not in extents format
+Fix? yes
+
 Pass 2: Checking directory structure
 Pass 3: Checking directory connectivity
 /lost+found not found.  Create? yes
tests/f_bbfile/expect.1 +24 -10
Index: e2fsprogs-1.40.5/tests/f_bbfile/expect.1
===================================================================
@@ -3,46 +3,60 @@ Filesystem did not have a UUID; generati
 Pass 1: Checking inodes, blocks, and sizes
 Group 0's inode bitmap (4) is bad.  Relocate? yes
 
+Inode 11 has corrupt indirect block
+Clear? yes
+
 Relocating group 0's inode bitmap from 4 to 43...
+Restarting e2fsck from the beginning...
+Pass 1: Checking inodes, blocks, and sizes
 
 Running additional passes to resolve blocks claimed by more than one inode...
 Pass 1B: Rescanning for multiply-claimed blocks
 Multiply-claimed block(s) in inode 2: 21
-Multiply-claimed block(s) in inode 11: 9 10 11 12 13 14 15 16 17 18 19 20
 Multiply-claimed block(s) in inode 12: 25 26
 Pass 1C: Scanning directories for inodes with multiply-claimed blocks
 Pass 1D: Reconciling multiply-claimed blocks
-(There are 3 inodes containing multiply-claimed blocks.)
+(There are 2 inodes containing multiply-claimed blocks.)
 
 File / (inode #2, mod time Sun Jan  2 08:29:13 1994) 
   has 1 multiply-claimed block(s), shared with 1 file(s):
 	<The bad blocks inode> (inode #1, mod time Sun Jul 17 00:47:58 1994)
 Clone multiply-claimed blocks? yes
 
-File /lost+found (inode #11, mod time Sun Jan  2 08:28:40 1994) 
-  has 12 multiply-claimed block(s), shared with 1 file(s):
-	<The bad blocks inode> (inode #1, mod time Sun Jul 17 00:47:58 1994)
-Clone multiply-claimed blocks? yes
-
 File /termcap (inode #12, mod time Sun Jan  2 08:29:13 1994) 
   has 2 multiply-claimed block(s), shared with 1 file(s):
 	<The bad blocks inode> (inode #1, mod time Sun Jul 17 00:47:58 1994)
 Clone multiply-claimed blocks? yes
 
 Pass 2: Checking directory structure
+Entry 'lost+found' in / (2) has deleted/unused inode 11.  Clear? yes
+
 Pass 3: Checking directory connectivity
+/lost+found not found.  Create? yes
+
 Pass 4: Checking reference counts
+Inode 2 ref count is 4, should be 3.  Fix? yes
+
 Pass 5: Checking group summary information
 Block bitmap differences:  +43
 Fix? yes
 
-Free blocks count wrong for group #0 (57, counted=41).
+Free blocks count wrong for group #0 (56, counted=52).
+Fix? yes
+
+Free blocks count wrong (56, counted=52).
+Fix? yes
+
+Free inodes count wrong for group #0 (19, counted=20).
+Fix? yes
+
+Directories count wrong for group #0 (3, counted=2).
 Fix? yes
 
-Free blocks count wrong (57, counted=41).
+Free inodes count wrong (19, counted=20).
 Fix? yes
 
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
-test_filesys: 12/32 files (0.0% non-contiguous), 59/100 blocks
+test_filesys: 12/32 files (0.0% non-contiguous), 48/100 blocks
 Exit status is 1
tests/f_bbfile/expect.2 +1 -1
Index: e2fsprogs-1.40.5/tests/f_bbfile/expect.2
===================================================================
@@ -3,5 +3,5 @@ Pass 2: Checking directory structure
 Pass 3: Checking directory connectivity
 Pass 4: Checking reference counts
 Pass 5: Checking group summary information
-test_filesys: 12/32 files (8.3% non-contiguous), 59/100 blocks
+test_filesys: 12/32 files (8.3% non-contiguous), 48/100 blocks
 Exit status is 0
tests/f_lotsbad/expect.1 +11 -24
Index: e2fsprogs-1.40.5/tests/f_lotsbad/expect.1
===================================================================
@@ -8,54 +8,41 @@ Inode 13, i_size is 15360, should be 122
 
 Inode 13, i_blocks is 32, should be 30.  Fix? yes
 
-Inode 12 has illegal block(s).  Clear? yes
+Inode 12 has corrupt indirect block
+Clear? yes
 
-Illegal block #12 (778398818) in inode 12.  CLEARED.
-Illegal block #13 (1768444960) in inode 12.  CLEARED.
-Illegal block #14 (1752375411) in inode 12.  CLEARED.
-Illegal block #15 (1684829551) in inode 12.  CLEARED.
-Illegal block #16 (1886349344) in inode 12.  CLEARED.
-Illegal block #17 (1819633253) in inode 12.  CLEARED.
-Illegal block #18 (1663072620) in inode 12.  CLEARED.
-Illegal block #19 (1735287144) in inode 12.  CLEARED.
-Illegal block #20 (1310731877) in inode 12.  CLEARED.
-Illegal block #21 (560297071) in inode 12.  CLEARED.
-Illegal block #22 (543512352) in inode 12.  CLEARED.
-Too many illegal blocks in inode 12.
-Clear inode? yes
+Inode 12, i_blocks is 34, should be 24.  Fix? yes
 
-Restarting e2fsck from the beginning...
-Pass 1: Checking inodes, blocks, and sizes
 Pass 2: Checking directory structure
-Entry 'termcap' in / (2) has deleted/unused inode 12.  Clear? yes
+Directory inode 13 has an unallocated block #16580876.  Allocate? yes
 
 Pass 3: Checking directory connectivity
 Pass 4: Checking reference counts
 Inode 2 ref count is 5, should be 4.  Fix? yes
 
 Pass 5: Checking group summary information
-Block bitmap differences:  -(27--41) -(44--45) -(74--90)
+Block bitmap differences:  -(38--41) -(74--90)
 Fix? yes
 
-Free blocks count wrong for group #0 (9, counted=43).
+Free blocks count wrong for group #0 (9, counted=30).
 Fix? yes
 
-Free blocks count wrong (9, counted=43).
+Free blocks count wrong (9, counted=30).
 Fix? yes
 
-Inode bitmap differences:  -12 -14
+Inode bitmap differences:  -14
 Fix? yes
 
-Free inodes count wrong for group #0 (18, counted=20).
+Free inodes count wrong for group #0 (18, counted=19).
 Fix? yes
 
 Directories count wrong for group #0 (4, counted=3).
 Fix? yes
 
-Free inodes count wrong (18, counted=20).
+Free inodes count wrong (18, counted=19).
 Fix? yes
 
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
-test_filesys: 12/32 files (0.0% non-contiguous), 57/100 blocks
+test_filesys: 13/32 files (7.7% non-contiguous), 70/100 blocks
 Exit status is 1
tests/f_lotsbad/expect.2 +13 -2
Index: e2fsprogs-1.40.5/tests/f_lotsbad/expect.2
===================================================================
@@ -1,7 +1,18 @@
 Pass 1: Checking inodes, blocks, and sizes
+Inode 13 is too big.  Truncate? yes
+
+Block #16580876 (37) causes directory to be too big.  CLEARED.
+Inode 13, i_size is 4093916160, should be 12288.  Fix? yes
+
+Inode 13, i_blocks is 32, should be 30.  Fix? yes
+
 Pass 2: Checking directory structure
+Directory inode 13 has an unallocated block #16580876.  Allocate? yes
+
 Pass 3: Checking directory connectivity
 Pass 4: Checking reference counts
 Pass 5: Checking group summary information
-test_filesys: 12/32 files (0.0% non-contiguous), 57/100 blocks
-Exit status is 0
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 13/32 files (15.4% non-contiguous), 70/100 blocks
+Exit status is 1
tests/f_messy_inode/expect.1 +18 -20
Index: e2fsprogs-1.40.5/tests/f_messy_inode/expect.1
===================================================================
@@ -1,38 +1,36 @@
 Filesystem did not have a UUID; generating one.
 
 Pass 1: Checking inodes, blocks, and sizes
-Inode 14 has illegal block(s).  Clear? yes
-
-Illegal block #2 (4294901760) in inode 14.  CLEARED.
-Illegal block #3 (4294901760) in inode 14.  CLEARED.
-Illegal block #4 (4294901760) in inode 14.  CLEARED.
-Illegal block #5 (4294901760) in inode 14.  CLEARED.
-Illegal block #6 (4294901760) in inode 14.  CLEARED.
-Illegal block #7 (4294901760) in inode 14.  CLEARED.
-Illegal block #8 (4294901760) in inode 14.  CLEARED.
-Illegal block #9 (4294901760) in inode 14.  CLEARED.
-Illegal block #10 (4294901760) in inode 14.  CLEARED.
-Inode 14, i_size is 18446462598732849291, should be 2048.  Fix? yes
-
-Inode 14, i_blocks is 18, should be 4.  Fix? yes
+Inode 14 has corrupt indirect block
+Clear? yes
 
+Restarting e2fsck from the beginning...
+Pass 1: Checking inodes, blocks, and sizes
 Pass 2: Checking directory structure
-i_file_acl for inode 14 (/MAKEDEV) is 4294901760, should be zero.
-Clear? yes
+Entry 'MAKEDEV' in / (2) has deleted/unused inode 14.  Clear? yes
 
 Pass 3: Checking directory connectivity
 Pass 4: Checking reference counts
 Pass 5: Checking group summary information
-Block bitmap differences:  -(43--49)
+Block bitmap differences:  -(41--49)
+Fix? yes
+
+Free blocks count wrong for group #0 (68, counted=77).
+Fix? yes
+
+Free blocks count wrong (68, counted=77).
+Fix? yes
+
+Inode bitmap differences:  -14
 Fix? yes
 
-Free blocks count wrong for group #0 (68, counted=75).
+Free inodes count wrong for group #0 (3, counted=4).
 Fix? yes
 
-Free blocks count wrong (68, counted=75).
+Free inodes count wrong (3, counted=4).
 Fix? yes
 
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
-test_filesys: 29/32 files (3.4% non-contiguous), 25/100 blocks
+test_filesys: 28/32 files (0.0% non-contiguous), 23/100 blocks
 Exit status is 1
tests/f_messy_inode/expect.2 +1 -1
Index: e2fsprogs-1.40.5/tests/f_messy_inode/expect.2
===================================================================
@@ -3,5 +3,5 @@ Pass 2: Checking directory structure
 Pass 3: Checking directory connectivity
 Pass 4: Checking reference counts
 Pass 5: Checking group summary information
-test_filesys: 29/32 files (0.0% non-contiguous), 25/100 blocks
+test_filesys: 28/32 files (0.0% non-contiguous), 23/100 blocks
 Exit status is 0

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#8 lore raw

Re: [PATCH][7/28] e2fsprogs-extents.patch

Support for checking 32-bit extents format inodes and the INCOMPAT_EXTENTS feature.

Clear the high 16 bits of extents and index entries, since the extents patches did not do this explicitly. Some parts of this code need fixing for checking > 32-bit block filesystems (when INCOMPAT_64BIT support is added), marked "FIXME: 48-bit support".

Verify extent headers in blocks, logical ordering of extents, logical ordering of indexes.

Add explicit checking of {d,t,}indirect and index blocks to detect corruption instead of implicitly doing this by checking the referred blocks and only block-at-a-time correctness. This avoids incorrectly invoking the very lengthy duplicate blocks pass for bad indirect/index blocks. We may want to tune the "threshold" for how many errors make a "bad" indirect/index block.

Add ability to split or remove extents in order to allow extent reallocation during the duplicate blocks pass.

e2fsck/Makefile.in +1 -0
Index: e2fsprogs-1.40.5/e2fsck/Makefile.in
===================================================================
@@ -256,6 +256,7 @@ super.o: $(srcdir)/super.c $(top_srcdir)
 pass1.o: $(srcdir)/pass1.c $(srcdir)/e2fsck.h \
  $(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h \
  $(top_srcdir)/lib/ext2fs/ext2fs.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
+ $(top_srcdir)/lib/ext2fs/ext3_extents.h \
  $(top_srcdir)/lib/et/com_err.h $(top_srcdir)/lib/ext2fs/ext2_io.h \
  $(top_builddir)/lib/ext2fs/ext2_err.h $(top_srcdir)/lib/ext2fs/bitops.h \
  $(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
e2fsck/e2fsck.h +1 -0
Index: e2fsprogs-1.40.5/e2fsck/e2fsck.h
===================================================================
@@ -328,6 +328,7 @@ struct e2fsck_struct {
 	__u32 large_files;
 	__u32 fs_ext_attr_inodes;
 	__u32 fs_ext_attr_blocks;
+	__u32 extent_files;
 
 	/* misc fields */
 	time_t now;
e2fsck/pass1.c +287 -30

450 lines not on this page · raw message

e2fsck/pass2.c +10 -1
Index: e2fsprogs-1.40.5/e2fsck/pass2.c
===================================================================
@@ -285,7 +285,16 @@ void e2fsck_pass2(e2fsck_t ctx)
 			ext2fs_mark_super_dirty(fs);
 		}
 	}
-	
+
+	if (!ctx->extent_files &&
+	    (sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_EXTENTS)) {
+		if (fs->flags & EXT2_FLAG_RW) {
+			sb->s_feature_incompat &=
+				~EXT3_FEATURE_INCOMPAT_EXTENTS;
+			ext2fs_mark_super_dirty(fs);
+		}
+	}
+
 #ifdef RESOURCE_TRACK
 	if (ctx->options & E2F_OPT_TIME2) {
 		e2fsck_clear_progbar(ctx);
e2fsck/problem.c +41 -0

53 lines not on this page · raw message

e2fsck/problem.h +28 -0
Index: e2fsprogs-1.40.5/e2fsck/problem.h
===================================================================
@@ -38,6 +38,7 @@ struct problem_context {
 #define PR_LATCH_LOW_DTIME 0x0070 /* Latch for pass1 orphaned list refugees */
 #define PR_LATCH_TOOBIG	0x0080	/* Latch for file to big errors */
 #define PR_LATCH_OPTIMIZE_DIR 0x0090 /* Latch for optimize directories */
+#define PR_LATCH_EXTENT_HI 0x00A0 /* Latch for extent high bits set */
 
 #define PR_LATCH(x)	((((x) & PR_LATCH_MASK) >> 4) - 1)
 
@@ -455,6 +456,33 @@ struct problem_context {
 /* inode appears to be a directory */
 #define PR_1_TREAT_AS_DIRECTORY		0x010055
 
+/* indirect block corrupt */
+#define PR_1_INDIRECT_BAD		0x010059
+
+/* wrong EXT3_FEATURE_INCOMPAT_EXTENTS flag */
+#define PR_1_EXTENT_FEATURE		0x010060
+
+/* EXT4_EXTENT_FL flag set on non-extent file */
+#define PR_1_SET_EXTENT_FL		0x010061
+
+/* EXT4_EXTENT_FL flag not set extent file */
+#define PR_1_UNSET_EXTENT_FL		0x010062
+
+/* extent index corrupt */
+#define PR_1_EXTENT_BAD			0x010063
+
+/* extent index corrupt */
+#define PR_1_EXTENT_IDX_BAD		0x010064
+
+/* extent/index has high 16 bits set - header */
+#define PR_1_EXTENT_HI			0x010065
+
+/* extent/index has high 16 bits set */
+#define PR_1_EXTENT_HI_LATCH		0x010066
+
+/* extent/index was modified & repaired - not really a problem */
+#define PR_1_EXTENT_CHANGED		0x010067
+
 /*
  * Pass 1b errors
  */
lib/ext2fs/Makefile.in +7 -0
Index: e2fsprogs-1.40.5/lib/ext2fs/Makefile.in
===================================================================
@@ -35,6 +35,7 @@ OBJS= $(DEBUGFS_LIB_OBJS) $(RESIZE_LIB_O
 	dir_iterate.o \
 	expanddir.o \
 	ext_attr.o \
+	extents.o \
 	finddev.o \
 	flushb.o \
 	freefs.o \
@@ -90,6 +91,7 @@ SRCS= ext2_err.c \
 	$(srcdir)/dupfs.c \
 	$(srcdir)/expanddir.c \
 	$(srcdir)/ext_attr.c \
+	$(srcdir)/extents.c \
 	$(srcdir)/fileio.c \
 	$(srcdir)/finddev.c \
 	$(srcdir)/flushb.c \
@@ -127,6 +129,7 @@ SRCS= ext2_err.c \
 	$(srcdir)/tst_bitops.c \
 	$(srcdir)/tst_byteswap.c \
 	$(srcdir)/tst_getsize.c \
+ 	$(srcdir)/tst_types.c \
 	$(srcdir)/tst_iscan.c \
 	$(srcdir)/unix_io.c \
 	$(srcdir)/unlink.c \
@@ -394,6 +397,10 @@ ext_attr.o: $(srcdir)/ext_attr.c $(srcdi
  $(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h \
  $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_io.h \
  $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h
+extents.o: $(srcdir)/extents.c $(srcdir)/ext2_fs.h \
+ $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext3_extents.h \
+ $(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h $(top_srcdir)/lib/et/com_err.h \
+ $(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h
 fileio.o: $(srcdir)/fileio.c $(srcdir)/ext2_fs.h \
  $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
  $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
lib/ext2fs/block.c +25 -32

103 lines not on this page · raw message

lib/ext2fs/block.h new file +33 -0
Index: e2fsprogs-1.40.5/lib/ext2fs/block.h
===================================================================
@@ -0,0 +1,33 @@
+/*
+ * block.h --- header for block iteration in block.c, extent.c
+ *
+ * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
+ *
+ * %Begin-Header%
+ * This file may be redistributed under the terms of the GNU Public
+ * License.
+ * %End-Header%
+ */
+
+struct block_context {
+	ext2_filsys	fs;
+	int (*func)(ext2_filsys	fs,
+		    blk_t	*blocknr,
+		    e2_blkcnt_t	bcount,
+		    blk_t	ref_blk,
+		    int		ref_offset,
+		    void	*priv_data);
+	e2_blkcnt_t	bcount;
+	int		bsize;
+	int		flags;
+	errcode_t	errcode;
+	char	*ind_buf;
+	char	*dind_buf;
+	char	*tind_buf;
+	void	*priv_data;
+};
+
+/* libext2fs nternal function, in extent.c */
+extern int block_iterate_extents(void *eh_buf, unsigned bufsize,blk_t ref_block,
+				 int ref_offset EXT2FS_ATTR((unused)),
+				 struct block_context *ctx);
lib/ext2fs/bmap.c +70 -0

88 lines not on this page · raw message

lib/ext2fs/ext2_err.et.in +12 -0
Index: e2fsprogs-1.40.5/lib/ext2fs/ext2_err.et.in
===================================================================
@@ -326,5 +326,17 @@ ec	EXT2_ET_TDB_ERR_NOEXIST,
 ec	EXT2_ET_TDB_ERR_RDONLY,
 	"TDB: Write not permitted"
 
+ec	EXT2_ET_EXTENT_HEADER_BAD,
+	"Corrupt extent header"
+
+ec	EXT2_ET_EXTENT_INDEX_BAD,
+	"Corrupt extent index"
+
+ec	EXT2_ET_EXTENT_LEAF_BAD,
+	"Corrupt extent"
+
+ec	EXT2_ET_EXTENT_NO_SPACE,
+	"No free space in extent map"
+
 	end
 
lib/ext2fs/ext2fs.h +22 -0
Index: e2fsprogs-1.40.5/lib/ext2fs/ext2fs.h
===================================================================
@@ -436,12 +436,14 @@ typedef struct ext2_icount *ext2_icount_
 					 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|\
 					 EXT2_FEATURE_INCOMPAT_META_BG|\
 					 EXT3_FEATURE_INCOMPAT_RECOVER|\
+ 					 EXT3_FEATURE_INCOMPAT_EXTENTS|\
 					 EXT4_FEATURE_INCOMPAT_FLEX_BG)
 #else
 #define EXT2_LIB_FEATURE_INCOMPAT_SUPP	(EXT2_FEATURE_INCOMPAT_FILETYPE|\
 					 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|\
 					 EXT2_FEATURE_INCOMPAT_META_BG|\
 					 EXT3_FEATURE_INCOMPAT_RECOVER|\
+					 EXT3_FEATURE_INCOMPAT_EXTENTS|\
 					 EXT4_FEATURE_INCOMPAT_FLEX_BG)
 #endif
 #define EXT2_LIB_FEATURE_RO_COMPAT_SUPP	(EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|\
@@ -722,6 +724,21 @@ extern errcode_t ext2fs_adjust_ea_refcou
 					   char *block_buf,
 					   int adjust, __u32 *newcount);
 
+/* extent.c */
+errcode_t ext2fs_extent_header_verify(struct ext3_extent_header *eh, int size);
+errcode_t ext2fs_extent_verify(ext2_filsys fs, struct ext3_extent *ex,
+			       struct ext3_extent *ex_prev,
+			       struct ext3_extent_idx *ix, int ix_len);
+errcode_t ext2fs_extent_index_verify(ext2_filsys fs,
+				     struct ext3_extent_idx *ix,
+				     struct ext3_extent_idx *ix_prev);
+errcode_t ext2fs_extent_remove(struct ext3_extent_header *eh,
+			       struct ext3_extent *ex);
+errcode_t ext2fs_extent_split(ext2_filsys fs, struct ext3_extent_header **eh,
+			      struct ext3_extent **ex, int count, int *flag);
+errcode_t ext2fs_extent_index_remove(struct ext3_extent_header *eh,
+				     struct ext3_extent_idx *ix);
+
 /* fileio.c */
 extern errcode_t ext2fs_file_open2(ext2_filsys fs, ext2_ino_t ino,
 				   struct ext2_inode *inode,
@@ -810,6 +827,8 @@ extern errcode_t ext2fs_image_bitmap_rea
 /* ind_block.c */
 errcode_t ext2fs_read_ind_block(ext2_filsys fs, blk_t blk, void *buf);
 errcode_t ext2fs_write_ind_block(ext2_filsys fs, blk_t blk, void *buf);
+errcode_t ext2fs_read_ext_block(ext2_filsys fs, blk_t blk, void *buf);
+errcode_t ext2fs_write_ext_block(ext2_filsys fs, blk_t blk, void *buf);
 
 /* initialize.c */
 extern errcode_t ext2fs_initialize(const char *name, int flags,
@@ -984,6 +1003,9 @@ extern void ext2fs_swap_inode_full(ext2_
 				   int bufsize);
 extern void ext2fs_swap_inode(ext2_filsys fs,struct ext2_inode *t,
 			      struct ext2_inode *f, int hostorder);
+extern void ext2fs_swap_extent_header(struct ext3_extent_header *eh);
+extern void ext2fs_swap_extent_index(struct ext3_extent_idx *ix);
+extern void ext2fs_swap_extent(struct ext3_extent *ex);
 
 /* valid_blk.c */
 extern int ext2fs_inode_has_valid_blocks(struct ext2_inode *inode);
lib/ext2fs/extents.c new file +475 -0

475 lines not on this page · raw message

lib/ext2fs/ind_block.c +82 -4

101 lines not on this page · raw message

lib/ext2fs/swapfs.c +64 -12

104 lines not on this page · raw message

lib/ext2fs/valid_blk.c +14 -2
Index: e2fsprogs-1.40.5/lib/ext2fs/valid_blk.c
===================================================================
@@ -19,6 +19,7 @@
 
 #include "ext2_fs.h"
 #include "ext2fs.h"
+#include "ext3_extents.h"
 
 /*
  * This function returns 1 if the inode's block entries actually
@@ -41,12 +42,23 @@ int ext2fs_inode_has_valid_blocks(struct
 	if (LINUX_S_ISLNK (inode->i_mode)) {
 		if (inode->i_file_acl == 0) {
 			/* With no EA block, we can rely on i_blocks */
-			if (inode->i_blocks == 0)
-				return 0;
+			if (inode->i_flags & EXT4_EXTENTS_FL) {
+				struct ext3_extent_header *eh;
+				eh = (struct ext3_extent_header *)inode->i_block;
+				if (eh->eh_entries == 0)
+					return 0;
+			} else {
+				if (inode->i_blocks == 0)
+					return 0;
+			}
 		} else {
 			/* With an EA block, life gets more tricky */
 			if (inode->i_size >= EXT2_N_BLOCKS*4)
 				return 1; /* definitely using i_block[] */
+			/*
+			 * we cant have EA + extents, so assume we aren't
+			 * using extents
+			 */
 			if (inode->i_size > 4 && inode->i_block[1] == 0)
 				return 1; /* definitely using i_block[] */
 			return 0; /* Probably a fast symlink */
tests/f_bad_disconnected_inode/expect.1 +6 -0
Index: e2fsprogs-1.40.5/tests/f_bad_disconnected_inode/expect.1
===================================================================
@@ -1,4 +1,10 @@
 Pass 1: Checking inodes, blocks, and sizes
+Inode 15 has EXTENT_FL set, but is not in extents format
+Fix? yes
+
+Inode 16 has EXTENT_FL set, but is not in extents format
+Fix? yes
+
 Pass 2: Checking directory structure
 Pass 3: Checking directory connectivity
 /lost+found not found.  Create? yes
tests/f_bbfile/expect.1 +24 -10
Index: e2fsprogs-1.40.5/tests/f_bbfile/expect.1
===================================================================
@@ -3,46 +3,60 @@ Filesystem did not have a UUID; generati
 Pass 1: Checking inodes, blocks, and sizes
 Group 0's inode bitmap (4) is bad.  Relocate? yes
 
+Inode 11 has corrupt indirect block
+Clear? yes
+
 Relocating group 0's inode bitmap from 4 to 43...
+Restarting e2fsck from the beginning...
+Pass 1: Checking inodes, blocks, and sizes
 
 Running additional passes to resolve blocks claimed by more than one inode...
 Pass 1B: Rescanning for multiply-claimed blocks
 Multiply-claimed block(s) in inode 2: 21
-Multiply-claimed block(s) in inode 11: 9 10 11 12 13 14 15 16 17 18 19 20
 Multiply-claimed block(s) in inode 12: 25 26
 Pass 1C: Scanning directories for inodes with multiply-claimed blocks
 Pass 1D: Reconciling multiply-claimed blocks
-(There are 3 inodes containing multiply-claimed blocks.)
+(There are 2 inodes containing multiply-claimed blocks.)
 
 File / (inode #2, mod time Sun Jan  2 08:29:13 1994) 
   has 1 multiply-claimed block(s), shared with 1 file(s):
 	<The bad blocks inode> (inode #1, mod time Sun Jul 17 00:47:58 1994)
 Clone multiply-claimed blocks? yes
 
-File /lost+found (inode #11, mod time Sun Jan  2 08:28:40 1994) 
-  has 12 multiply-claimed block(s), shared with 1 file(s):
-	<The bad blocks inode> (inode #1, mod time Sun Jul 17 00:47:58 1994)
-Clone multiply-claimed blocks? yes
-
 File /termcap (inode #12, mod time Sun Jan  2 08:29:13 1994) 
   has 2 multiply-claimed block(s), shared with 1 file(s):
 	<The bad blocks inode> (inode #1, mod time Sun Jul 17 00:47:58 1994)
 Clone multiply-claimed blocks? yes
 
 Pass 2: Checking directory structure
+Entry 'lost+found' in / (2) has deleted/unused inode 11.  Clear? yes
+
 Pass 3: Checking directory connectivity
+/lost+found not found.  Create? yes
+
 Pass 4: Checking reference counts
+Inode 2 ref count is 4, should be 3.  Fix? yes
+
 Pass 5: Checking group summary information
 Block bitmap differences:  +43
 Fix? yes
 
-Free blocks count wrong for group #0 (57, counted=41).
+Free blocks count wrong for group #0 (56, counted=52).
+Fix? yes
+
+Free blocks count wrong (56, counted=52).
+Fix? yes
+
+Free inodes count wrong for group #0 (19, counted=20).
+Fix? yes
+
+Directories count wrong for group #0 (3, counted=2).
 Fix? yes
 
-Free blocks count wrong (57, counted=41).
+Free inodes count wrong (19, counted=20).
 Fix? yes
 
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
-test_filesys: 12/32 files (0.0% non-contiguous), 59/100 blocks
+test_filesys: 12/32 files (0.0% non-contiguous), 48/100 blocks
 Exit status is 1
tests/f_bbfile/expect.2 +1 -1
Index: e2fsprogs-1.40.5/tests/f_bbfile/expect.2
===================================================================
@@ -3,5 +3,5 @@ Pass 2: Checking directory structure
 Pass 3: Checking directory connectivity
 Pass 4: Checking reference counts
 Pass 5: Checking group summary information
-test_filesys: 12/32 files (8.3% non-contiguous), 59/100 blocks
+test_filesys: 12/32 files (8.3% non-contiguous), 48/100 blocks
 Exit status is 0
tests/f_lotsbad/expect.1 +11 -24
Index: e2fsprogs-1.40.5/tests/f_lotsbad/expect.1
===================================================================
@@ -8,54 +8,41 @@ Inode 13, i_size is 15360, should be 122
 
 Inode 13, i_blocks is 32, should be 30.  Fix? yes
 
-Inode 12 has illegal block(s).  Clear? yes
+Inode 12 has corrupt indirect block
+Clear? yes
 
-Illegal block #12 (778398818) in inode 12.  CLEARED.
-Illegal block #13 (1768444960) in inode 12.  CLEARED.
-Illegal block #14 (1752375411) in inode 12.  CLEARED.
-Illegal block #15 (1684829551) in inode 12.  CLEARED.
-Illegal block #16 (1886349344) in inode 12.  CLEARED.
-Illegal block #17 (1819633253) in inode 12.  CLEARED.
-Illegal block #18 (1663072620) in inode 12.  CLEARED.
-Illegal block #19 (1735287144) in inode 12.  CLEARED.
-Illegal block #20 (1310731877) in inode 12.  CLEARED.
-Illegal block #21 (560297071) in inode 12.  CLEARED.
-Illegal block #22 (543512352) in inode 12.  CLEARED.
-Too many illegal blocks in inode 12.
-Clear inode? yes
+Inode 12, i_blocks is 34, should be 24.  Fix? yes
 
-Restarting e2fsck from the beginning...
-Pass 1: Checking inodes, blocks, and sizes
 Pass 2: Checking directory structure
-Entry 'termcap' in / (2) has deleted/unused inode 12.  Clear? yes
+Directory inode 13 has an unallocated block #16580876.  Allocate? yes
 
 Pass 3: Checking directory connectivity
 Pass 4: Checking reference counts
 Inode 2 ref count is 5, should be 4.  Fix? yes
 
 Pass 5: Checking group summary information
-Block bitmap differences:  -(27--41) -(44--45) -(74--90)
+Block bitmap differences:  -(38--41) -(74--90)
 Fix? yes
 
-Free blocks count wrong for group #0 (9, counted=43).
+Free blocks count wrong for group #0 (9, counted=30).
 Fix? yes
 
-Free blocks count wrong (9, counted=43).
+Free blocks count wrong (9, counted=30).
 Fix? yes
 
-Inode bitmap differences:  -12 -14
+Inode bitmap differences:  -14
 Fix? yes
 
-Free inodes count wrong for group #0 (18, counted=20).
+Free inodes count wrong for group #0 (18, counted=19).
 Fix? yes
 
 Directories count wrong for group #0 (4, counted=3).
 Fix? yes
 
-Free inodes count wrong (18, counted=20).
+Free inodes count wrong (18, counted=19).
 Fix? yes
 
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
-test_filesys: 12/32 files (0.0% non-contiguous), 57/100 blocks
+test_filesys: 13/32 files (7.7% non-contiguous), 70/100 blocks
 Exit status is 1
tests/f_lotsbad/expect.2 +13 -2
Index: e2fsprogs-1.40.5/tests/f_lotsbad/expect.2
===================================================================
@@ -1,7 +1,18 @@
 Pass 1: Checking inodes, blocks, and sizes
+Inode 13 is too big.  Truncate? yes
+
+Block #16580876 (37) causes directory to be too big.  CLEARED.
+Inode 13, i_size is 4093916160, should be 12288.  Fix? yes
+
+Inode 13, i_blocks is 32, should be 30.  Fix? yes
+
 Pass 2: Checking directory structure
+Directory inode 13 has an unallocated block #16580876.  Allocate? yes
+
 Pass 3: Checking directory connectivity
 Pass 4: Checking reference counts
 Pass 5: Checking group summary information
-test_filesys: 12/32 files (0.0% non-contiguous), 57/100 blocks
-Exit status is 0
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 13/32 files (15.4% non-contiguous), 70/100 blocks
+Exit status is 1
tests/f_messy_inode/expect.1 +18 -20
Index: e2fsprogs-1.40.5/tests/f_messy_inode/expect.1
===================================================================
@@ -1,38 +1,36 @@
 Filesystem did not have a UUID; generating one.
 
 Pass 1: Checking inodes, blocks, and sizes
-Inode 14 has illegal block(s).  Clear? yes
-
-Illegal block #2 (4294901760) in inode 14.  CLEARED.
-Illegal block #3 (4294901760) in inode 14.  CLEARED.
-Illegal block #4 (4294901760) in inode 14.  CLEARED.
-Illegal block #5 (4294901760) in inode 14.  CLEARED.
-Illegal block #6 (4294901760) in inode 14.  CLEARED.
-Illegal block #7 (4294901760) in inode 14.  CLEARED.
-Illegal block #8 (4294901760) in inode 14.  CLEARED.
-Illegal block #9 (4294901760) in inode 14.  CLEARED.
-Illegal block #10 (4294901760) in inode 14.  CLEARED.
-Inode 14, i_size is 18446462598732849291, should be 2048.  Fix? yes
-
-Inode 14, i_blocks is 18, should be 4.  Fix? yes
+Inode 14 has corrupt indirect block
+Clear? yes
 
+Restarting e2fsck from the beginning...
+Pass 1: Checking inodes, blocks, and sizes
 Pass 2: Checking directory structure
-i_file_acl for inode 14 (/MAKEDEV) is 4294901760, should be zero.
-Clear? yes
+Entry 'MAKEDEV' in / (2) has deleted/unused inode 14.  Clear? yes
 
 Pass 3: Checking directory connectivity
 Pass 4: Checking reference counts
 Pass 5: Checking group summary information
-Block bitmap differences:  -(43--49)
+Block bitmap differences:  -(41--49)
+Fix? yes
+
+Free blocks count wrong for group #0 (68, counted=77).
+Fix? yes
+
+Free blocks count wrong (68, counted=77).
+Fix? yes
+
+Inode bitmap differences:  -14
 Fix? yes
 
-Free blocks count wrong for group #0 (68, counted=75).
+Free inodes count wrong for group #0 (3, counted=4).
 Fix? yes
 
-Free blocks count wrong (68, counted=75).
+Free inodes count wrong (3, counted=4).
 Fix? yes
 
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
-test_filesys: 29/32 files (3.4% non-contiguous), 25/100 blocks
+test_filesys: 28/32 files (0.0% non-contiguous), 23/100 blocks
 Exit status is 1
tests/f_messy_inode/expect.2 +1 -1
Index: e2fsprogs-1.40.5/tests/f_messy_inode/expect.2
===================================================================
@@ -3,5 +3,5 @@ Pass 2: Checking directory structure
 Pass 3: Checking directory connectivity
 Pass 4: Checking reference counts
 Pass 5: Checking group summary information
-test_filesys: 29/32 files (0.0% non-contiguous), 25/100 blocks
+test_filesys: 28/32 files (0.0% non-contiguous), 23/100 blocks
 Exit status is 0

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#9 lore raw

Re: [PATCH][7/28] e2fsprogs-extents.patch

Quoted 21 lines · Andreas Dilger

Support for checking 32-bit extents format inodes and the INCOMPAT_EXTENTS feature.

Clear the high 16 bits of extents and index entries, since the extents patches did not do this explicitly. Some parts of this code need fixing for checking > 32-bit block filesystems (when INCOMPAT_64BIT support is added), marked "FIXME: 48-bit support".

Verify extent headers in blocks, logical ordering of extents, logical ordering of indexes.

Add explicit checking of {d,t,}indirect and index blocks to detect corruption instead of implicitly doing this by checking the referred blocks and only block-at-a-time correctness. This avoids incorrectly invoking the very lengthy duplicate blocks pass for bad indirect/index blocks. We may want to tune the "threshold" for how many errors make a "bad" indirect/index block.

Add ability to split or remove extents in order to allow extent reallocation during the duplicate blocks pass.

...

Quoted 14 lines
e2fsck/pass1.c +0 -10
@@ -904,21 +910,75 @@ void e2fsck_pass1(e2fsck_t ctx)
 			ctx->fs_sockets_count++;
 		} else
 			mark_inode_bad(ctx, ino);
-		if (inode->i_block[EXT2_IND_BLOCK])
-			ctx->fs_ind_count++;
-		if (inode->i_block[EXT2_DIND_BLOCK])
-			ctx->fs_dind_count++;
-		if (inode->i_block[EXT2_TIND_BLOCK])
-			ctx->fs_tind_count++;
-		if (inode->i_block[EXT2_IND_BLOCK] ||
-		    inode->i_block[EXT2_DIND_BLOCK] ||
-		    inode->i_block[EXT2_TIND_BLOCK] ||
-		    inode->i_file_acl) {

e2fsck/pass1.c void e2fsck_pass1(e2fsck_t ctx) · line 917

Quoted 10 lines
e2fsck/pass1.c +5 -5
-			inodes_to_process[process_inode_count].ino = ino;
-			inodes_to_process[process_inode_count].inode = *inode;
-			process_inode_count++;
-		} else
-			check_blocks(ctx, &pctx, block_buf);
+
+		eh = (struct ext3_extent_header *)inode->i_block;
+		if ((inode->i_flags & EXT4_EXTENTS_FL)) {
+			if ((LINUX_S_ISREG(inode->i_mode) ||
+			     LINUX_S_ISDIR(inode->i_mode)) &&

So this trips up on things like sockets, fifos, and block & char nodes.

Also this is unhappy:

e2fsck/pass1.c int e2fsck_pass1_check_device_inode(ext2 · line 145

Quoted 7 lines
e2fsck/pass1.c +1 -1
@@ -137,7 +141,7 @@ int e2fsck_pass1_check_device_inode(ext2
 	 * If the index flag is set, then this is a bogus
 	 * device/fifo/socket
 	 */
-	if (inode->i_flags & EXT2_INDEX_FL)
+	if (inode->i_flags & (EXT2_INDEX_FL | EXT4_EXTENTS_FL))
 		return 0;

Do we really care if these have the extents flag set? IOW should we make sure the kernel doesn't set the flag, or should we make e2fsck not care...

There are enough checks in e2fsck to show the intent was that these files should not have the extents flag set, but I'm not sure why it matters enough that the kernel needs to run around being sure to clear it....

Or... (rambling on now) it seems odd to me that zero-length files have the extents flag set at all; should we only set extents when we actually get a block allocated to the file? That would also take care of this from the kernel side I think.

-Eric

#10 lore raw

Re: [PATCH][7/28] e2fsprogs-extents.patch

Quoted 1 line · Eric Sandeen

So this trips up on things like sockets, fifos, and block & char nodes.

Just to demonstrate; doing this on ext4:

mknod mnt/block b 1 1
mknod mnt/char c 1 1
mknod mnt/fifo p
mksock mnt/sock

mkdir -p mnt/verylongdir12345678901234567890/verylongdir12345678901234567890/verylongdir12345678901234567890 ln -s mnt/verylongdir12345678901234567890/verylongdir12345678901234567890/verylongdir12345678901234567890 mnt/longlink

yields an unhappy fsck w/ e2fsprogs-interim:

e2fsck 1.40.6 (09-Feb-2008)
Pass 1: Checking inodes, blocks, and sizes Inode 12 has EXTENT_FL set, but is not in extents format Fix? no

Inode 13 has EXTENT_FL set, but is not in extents format Fix? no

Inode 14 has EXTENT_FL set, but is not in extents format Fix? no

Inode 15 has EXTENT_FL set, but is not in extents format Fix? no

Inode 17 has EXTENT_FL set, but is not in extents format Fix? no

Pass 2: Checking directory structure Inode 12 (/block) is an illegal block device. Clear? no

Inode 13 (/char) is an illegal character device. Clear? no

Inode 14 (/fifo) is an illegal FIFO. Clear? no

Inode 15 (/sock) is an illegal socket. Clear? no

Symlink /longlink (inode #17) is invalid. Clear? no

Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information

-Eric

#11 lore raw

Re: [PATCH][7/28] e2fsprogs-extents.patch

In reply to Eric Sandeen
Quoted 4 lines · Eric Sandeen

So this trips up on things like sockets, fifos, and block & char nodes.

Also this is unhappy:

Quoted 11 lines

e2fsck/pass1.c int e2fsck_pass1_check_device_inode(ext2 · line 145

Quoted 7 lines
e2fsck/pass1.c +1 -1
@@ -137,7 +141,7 @@ int e2fsck_pass1_check_device_inode(ext2
 	 * If the index flag is set, then this is a bogus
 	 * device/fifo/socket
 	 */
-	if (inode->i_flags & EXT2_INDEX_FL)
+	if (inode->i_flags & (EXT2_INDEX_FL | EXT4_EXTENTS_FL))
 		return 0;

Do we really care if these have the extents flag set? IOW should we make sure the kernel doesn't set the flag, or should we make e2fsck not care...

<Sigh>

I think we need to get kernel patches into mainline ASAP not to set the EXTENTS_FL --- be conservative in what you send --- and at least for now, e2fsck needs to accept (and not complain or core dump) if EXTENTS_FL is set for files where ext2fs_inode_has_valid_blocks() returns false --- be liberal in what you accept.

Eventually, after the kernel patches hit mainline, we could change e2fsck to automatically fix all of these in preen mode, just for cleanliness sake.

- Ted

#12 lore raw

Re: [PATCH][7/28] e2fsprogs-extents.patch

Quoted 16 lines · Theodore Tso
Quoted 4 lines · Eric Sandeen

So this trips up on things like sockets, fifos, and block & char nodes.

Also this is unhappy:

Quoted 10 lines

e2fsck/pass1.c int e2fsck_pass1_check_device_inode(ext2 · line 145

Quoted 7 lines
e2fsck/pass1.c +1 -1
@@ -137,7 +141,7 @@ int e2fsck_pass1_check_device_inode(ext2
 	 * If the index flag is set, then this is a bogus
 	 * device/fifo/socket
 	 */
-	if (inode->i_flags & EXT2_INDEX_FL)
+	if (inode->i_flags & (EXT2_INDEX_FL | EXT4_EXTENTS_FL))
 		return 0;

Do we really care if these have the extents flag set? IOW should we make sure the kernel doesn't set the flag, or should we make e2fsck not care...

Quoted 4 lines

<Sigh>

I think we need to get kernel patches into mainline ASAP not to set the EXTENTS_FL

You mean on devices/fifos/sockets ? Ok.

But today, with 2.6.25-rc1 and e2fsprogs-interim, long (non-fast) symlinks get clobbered by e2fsck, because:

Pass 1: Checking inodes, blocks, and sizes Inode 12 has EXTENT_FL set, but is not in extents format Fix? yes

Inode 12 has illegal block(s). Clear? yes

Illegal block #0 (127754) in inode 12. CLEARED.
Inode 12 is too big. Truncate? yes

Block #1 (4) causes symlink to be too big. CLEARED. Block #4 (1) causes symlink to be too big. CLEARED. Block #5 (4772) causes symlink to be too big. CLEARED. Inode 12, i_blocks is 2, should be 0. Fix? yes

Pass 2: Checking directory structure
Symlink /longlink (inode #12) is invalid.
Clear? yes

Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Block bitmap differences: -4772
Fix? yes

Free blocks count wrong for group #0 (3420, counted=3421). Fix? yes

Free blocks count wrong (26192, counted=26193).
Fix? yes

and *poof* it's gone. That one concerns me more... This *should* be in extents format, right, even though it's limited to one block...

Quoted 4 lines

and at least
for now, e2fsck needs to accept (and not complain or core dump) if EXTENTS_FL is set for files where ext2fs_inode_has_valid_blocks() returns false

well, if any filetypes are not supposed to have the extents flag set, and they're zero-length, I'd say go ahead & clear it, and even complain if you like - it's the design intent after all - I wouldn't worry about the noise at this stage. FWIW, I haven't seen a core dump. :)

-Eric

#13 lore raw

Re: [PATCH][7/28] e2fsprogs-extents.patch

Quoted 4 lines · Eric Sandeen
Quoted 2 lines

I think we need to get kernel patches into mainline ASAP not to set the EXTENTS_FL

You mean on devices/fifos/sockets ? Ok.

Yes, sorry for not being explicit.

Quoted 7 lines

But today, with 2.6.25-rc1 and e2fsprogs-interim, long (non-fast) symlinks get clobbered by e2fsck, because:

Pass 1: Checking inodes, blocks, and sizes Inode 12 has EXTENT_FL set, but is not in extents format Fix? yes

Yeah, my current development branch of e2fsprogs does the right thing, but e2fsprogs-interim doesn't. We need to add a test to make sure ext2fs_inode_has_valid_blocks(inode) before marking the inode bad and asking the user if the inode should be cleared.

Quoted 2 lines

and *poof* it's gone. That one concerns me more... This *should* be in extents format, right, even though it's limited to one block...

Well, for symlinks, they are only one block, so there is no reason for it to be using the extent format. So storing it as a single block number makes a lot more sense. It should just not be setting the EXTENTS_FL flag.

Quoted 4 lines

well, if any filetypes are not supposed to have the extents flag set, and they're zero-length, I'd say go ahead & clear it, and even complain if you like - it's the design intent after all - I wouldn't worry about the noise at this stage. FWIW, I haven't seen a core dump. :)

The current pu branch core dumps. My development branch has at least that problem fixed. :-)

- Ted

#14 lore raw

Re: [PATCH][7/28] e2fsprogs-extents.patch

In reply to Eric Sandeen
Quoted 7 lines · Eric Sandeen

e2fsck/pass1.c void e2fsck_pass1(e2fsck_t ctx) · line 913

Quoted 5 lines
e2fsck/pass1.c +4 -0
@@ -904,21 +910,75 @@ void e2fsck_pass1(e2fsck_t ctx)
+		eh = (struct ext3_extent_header *)inode->i_block;
+		if ((inode->i_flags & EXT4_EXTENTS_FL)) {
+			if ((LINUX_S_ISREG(inode->i_mode) ||
+			     LINUX_S_ISDIR(inode->i_mode)) &&

So this trips up on things like sockets, fifos, and block & char nodes.

Hrm, not impossible, since Lustre only uses extent-based filesystems for regular file storage.

Quoted 13 lines

Also this is unhappy:

e2fsck/pass1.c int e2fsck_pass1_check_device_inode(ext2 · line 145

Quoted 7 lines
e2fsck/pass1.c +1 -1
@@ -137,7 +141,7 @@ int e2fsck_pass1_check_device_inode(ext2
 	 * If the index flag is set, then this is a bogus
 	 * device/fifo/socket
 	 */
-	if (inode->i_flags & EXT2_INDEX_FL)
+	if (inode->i_flags & (EXT2_INDEX_FL | EXT4_EXTENTS_FL))
 		return 0;

Do we really care if these have the extents flag set? IOW should we make sure the kernel doesn't set the flag, or should we make e2fsck not care...

The Lustre extents patches clear the EXT4_EXTENTS_FL always (i.e. they are never set on directories) so we've never seen these problems.

Quoted 9 lines

There are enough checks in e2fsck to show the intent was that these files should not have the extents flag set, but I'm not sure why it matters enough that the kernel needs to run around being sure to clear it....

Or... (rambling on now) it seems odd to me that zero-length files have the extents flag set at all; should we only set extents when we actually get a block allocated to the file? That would also take care of this from the kernel side I think.

Yes, I'd be for e2fsck clearing this flag, but as I mentioned in the concall, I think it is better to have the kernel just stop inheriting all flags from the parent directory, or possibly just have a fixed range of flags that are being propogated to child inodes.

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#15 lore raw

Re: [PATCH][8/28] e2fsprogs-config-before-cmdline.patch

In reply to Andreas Dilger

The patch changes the order that the config file and command line are parsed so that command line has precedence. It also allows multiple -E options to be specified on the command line.

e2fsck/unix.c +7 -9
Index: e2fsprogs-1.40.4/e2fsck/unix.c
===================================================================
@@ -588,7 +588,6 @@ static errcode_t PRS(int argc, char *arg
 #ifdef HAVE_SIGNAL_H
 	struct sigaction	sa;
 #endif
-	char		*extended_opts = 0;
 	char		*cp;
 	int 		res;		/* result of sscanf */
 #ifdef CONFIG_JBD_DEBUG
@@ -619,6 +618,12 @@ static errcode_t PRS(int argc, char *arg
 		ctx->program_name = *argv;
 	else
 		ctx->program_name = "e2fsck";
+
+	if ((cp = getenv("E2FSCK_CONFIG")) != NULL)
+		config_fn[0] = cp;
+	profile_set_syntax_err_cb(syntax_err_report);
+	profile_init(config_fn, &ctx->profile);
+
 	while ((c = getopt (argc, argv, "panyrcC:B:dE:fvtFVM:b:I:j:P:l:L:N:SsDk")) != EOF)
 		switch (c) {
 		case 'C':
@@ -645,7 +650,7 @@ static errcode_t PRS(int argc, char *arg
 			ctx->options |= E2F_OPT_COMPRESS_DIRS;
 			break;
 		case 'E':
-			extended_opts = optarg;
+			parse_extended_opts(ctx, optarg);
 			break;
 		case 'p':
 		case 'a':
@@ -771,13 +776,6 @@ static errcode_t PRS(int argc, char *arg
 			argv[optind]);
 		fatal_error(ctx, 0);
 	}
-	if (extended_opts)
-		parse_extended_opts(ctx, extended_opts);
-
-	if ((cp = getenv("E2FSCK_CONFIG")) != NULL)
-		config_fn[0] = cp;
-	profile_set_syntax_err_cb(syntax_err_report);
-	profile_init(config_fn, &ctx->profile);
 
 	if (flush) {
 		fd = open(ctx->filesystem_name, O_RDONLY, 0);

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#16 lore raw

Re: [PATCH][9/28] e2fsprogs-SLES10--m-support.patch

In reply to Andreas Dilger

SLES9 patch to add "fsck -m" option to skip checking mounted filesystems. This isn't in their upstream e2fsprogs, since SLES uses the fsck in util-linux, but is needed for compatibility.

misc/fsck.8.in +4 -0
Index: e2fsprogs-1.40.1/misc/fsck.8.in
===================================================================
@@ -180,6 +180,10 @@ option, 
 will use the specified filesystem type.  If this type is not
 available, then the default file system type (currently ext2) is used. 
 .TP
+.B \-m
+Do not check mounted filesystems and return an exit code of 0
+for mounted filesystems.
+.TP
 .B \-A
 Walk through the
 .I /etc/fstab
misc/fsck.c +77 -2

127 lines not on this page · raw message

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#17 lore raw

Re: [PATCH][10/28] e2fsprogs-uninit.patch

In reply to Andreas Dilger

Support for the COMPAT_GDT_CSUM (uninit_groups) feature.

Allows skipping uninitialized inode and block bitmap checks, and skipping unused parts of the inode table. Can dramatically speed up e2fsck on large filesystems where the inode table is mostly unused.

debugfs/debugfs.c +15 -3
Index: e2fsprogs-1.40.5/debugfs/debugfs.c
===================================================================
@@ -286,7 +286,10 @@ void do_show_super_stats(int argc, char 
 	FILE 	*out;
 	struct ext2_group_desc *gdp;
 	int	c, header_only = 0;
-	int	numdirs = 0, first;
+	int	numdirs = 0, first, gdt_csum;
+
+	gdt_csum = EXT2_HAS_RO_COMPAT_FEATURE(current_fs->super,
+					      EXT4_FEATURE_RO_COMPAT_GDT_CSUM);
 
 	reset_getopt();
 	while ((c = getopt (argc, argv, "h")) != EOF) {
@@ -322,7 +325,7 @@ void do_show_super_stats(int argc, char 
 		        "inode table at %u\n"
 		        "           %d free %s, "
 		        "%d free %s, "
-		        "%d used %s\n",
+		        "%d used %s%s",
 		        i, gdp->bg_block_bitmap,
 		        gdp->bg_inode_bitmap, gdp->bg_inode_table,
 		        gdp->bg_free_blocks_count,
@@ -331,12 +334,21 @@ void do_show_super_stats(int argc, char 
 		        gdp->bg_free_inodes_count != 1 ? "inodes" : "inode",
 		        gdp->bg_used_dirs_count,
 		        gdp->bg_used_dirs_count != 1 ? "directories"
-				: "directory");
+				: "directory", gdt_csum ? ", " : "\n");
+		if (gdt_csum)
+			fprintf(out, "%d unused %s\n",
+				gdp->bg_itable_unused,
+				gdp->bg_itable_unused != 1 ? "inodes":"inode");
 		first = 1;
 		print_bg_opts(gdp, EXT2_BG_INODE_UNINIT, "Inode not init",
 			      &first, out);
 		print_bg_opts(gdp, EXT2_BG_BLOCK_UNINIT, "Block not init",
 			      &first, out);
+		if (gdt_csum) {
+			fprintf(out, "%sChecksum 0x%04x",
+				first ? "           [":", ", gdp->bg_checksum);
+			first = 0;
+		}
 		if (!first)
 			fputs("]\n", out);
 	}
debugfs/set_fields.c +15 -2
Index: e2fsprogs-1.40.5/debugfs/set_fields.c
===================================================================
@@ -36,6 +36,7 @@
 static struct ext2_super_block set_sb;
 static struct ext2_inode set_inode;
 static struct ext2_group_desc set_gd;
+static dgrp_t set_bg;
 static ext2_ino_t set_ino;
 static int array_idx;
 
@@ -57,6 +58,7 @@ static errcode_t parse_uuid(struct field
 static errcode_t parse_hashalg(struct field_set_info *info, char *arg);
 static errcode_t parse_time(struct field_set_info *info, char *arg);
 static errcode_t parse_bmap(struct field_set_info *info, char *arg);
+static errcode_t parse_gd_csum(struct field_set_info *info, char *arg);
 
 static struct field_set_info super_fields[] = {
 	{ "inodes_count", &set_sb.s_inodes_count, 4, parse_uint },
@@ -163,7 +165,7 @@ static struct field_set_info ext2_bg_fie
 	{ "flags", &set_gd.bg_flags, 2, parse_uint },
 	{ "reserved", &set_gd.bg_reserved, 2, parse_uint, FLAG_ARRAY, 2 },
 	{ "itable_unused", &set_gd.bg_itable_unused, 2, parse_uint },
-	{ "checksum", &set_gd.bg_checksum, 2, parse_uint },
+	{ "checksum", &set_gd.bg_checksum, 2, parse_gd_csum },
 	{ 0, 0, 0, 0 }
 };
 
@@ -376,6 +378,17 @@ static errcode_t parse_bmap(struct field
 	return retval;
 }
 
+static errcode_t parse_gd_csum(struct field_set_info *info, char *arg)
+{
+	__u16 *val = info->ptr;
+
+	if (strcmp(arg, "calc") == 0) {
+		*val = ext2fs_group_desc_csum(&set_sb, set_bg, &set_gd);
+		return 0;
+	}
+
+	return parse_uint(info, arg);
+}
 
 static void print_possible_fields(struct field_set_info *fields)
 {
@@ -495,7 +508,6 @@ void do_set_block_group_descriptor(int a
 		"\t\"set_block_group_descriptor -l\" will list the names of "
 		"the fields in a block group descriptor\n\twhich can be set.";
 	struct field_set_info	*ss;
-	dgrp_t			set_bg;
 	char			*end;
 
 	if ((argc == 2) && !strcmp(argv[1], "-l")) {
@@ -525,6 +537,7 @@ void do_set_block_group_descriptor(int a
 	}
 
 	set_gd = current_fs->group_desc[set_bg];
+	set_sb = *current_fs->super;
 
 	if (ss->func(ss, argv[3]) == 0) {
 		current_fs->group_desc[set_bg] = set_gd;
e2fsck/journal.c +2 -0
Index: e2fsprogs-1.40.5/e2fsck/journal.c
===================================================================
@@ -988,6 +988,8 @@ void e2fsck_move_ext3_journal(e2fsck_t c
 	ext2fs_unmark_inode_bitmap(fs->inode_map, ino);
 	ext2fs_mark_ib_dirty(fs);
 	fs->group_desc[group].bg_free_inodes_count++;
+	fs->group_desc[group].bg_checksum =
+		ext2fs_group_desc_csum(fs->super, group,&fs->group_desc[group]);
 	fs->super->s_free_inodes_count++;
 	return;
 
e2fsck/pass5.c +44 -17

129 lines not on this page · raw message

e2fsck/problem.c +46 -1

66 lines not on this page · raw message

e2fsck/problem.h +28 -1
Index: e2fsprogs-1.40.5/e2fsck/problem.h
===================================================================
@@ -197,6 +197,21 @@ struct problem_context {
 /* Superblock hint for external journal incorrect */
 #define PR_0_DIRHASH_HINT			0x000034
 
+/* Group descriptor N checksum is invalid */
+#define PR_0_GDT_CSUM				0x000035
+
+/* Group descriptor N marked uninitialized without feature set. */
+#define PR_0_GDT_UNINIT				0x000036
+
+/* Block bitmap is uninitialised but Inode bitmap in use. */
+#define PR_0_BB_UNINIT_IB_INIT			0x000037
+
+/* Group descriptor N has invalid unused inodes count. */
+#define PR_0_GDT_ITABLE_UNUSED			0x000038
+
+/* Last group block bitmap is uninitialized. */
+#define PR_0_BB_UNINIT_LAST			0x000039
+
 /*
  * Pass 1 errors
  */
@@ -742,6 +757,12 @@ struct problem_context {
 /* i_blocks_hi should be zero */
 #define PR_2_BLOCKS_HI_ZERO	0x020044
 
+/* Inode found in group where _INODE_UNINIT is set */
+#define PR_2_INOREF_BG_INO_UNINIT	0x020045
+
+/* Inode found in group unused inodes area */
+#define PR_2_INOREF_IN_UNUSED		0x020046
+
 /*
  * Pass 3 errors
  */
@@ -930,10 +951,16 @@ struct problem_context {
 
 /* Inode range not used, but marked in bitmap */
 #define PR_5_INODE_RANGE_UNUSED		0x050016
-	  
+
 /* Inode rangeused, but not marked used in bitmap */
 #define PR_5_INODE_RANGE_USED		0x050017
 
+/* Block in use but group is marked BLOCK_UNINIT */
+#define PR_5_BLOCK_UNINIT		0x050018
+
+/* Inode in use but group is marked INODE_UNINIT */
+#define PR_5_INODE_UNINIT		0x050019
+
 /*
  * Post-Pass 5 errors
  */
e2fsck/super.c +49 -0

67 lines not on this page · raw message

lib/ext2fs/Makefile.in +24 -4
Index: e2fsprogs-1.40.5/lib/ext2fs/Makefile.in
===================================================================
@@ -67,7 +67,9 @@ OBJS= $(DEBUGFS_LIB_OBJS) $(RESIZE_LIB_O
 	unix_io.o \
 	unlink.o \
 	valid_blk.o \
-	version.o
+	version.o \
+	crc16.o \
+	csum.o
 
 SRCS= ext2_err.c \
 	$(srcdir)/alloc.c \
@@ -131,6 +133,9 @@ SRCS= ext2_err.c \
 	$(srcdir)/tst_getsize.c \
  	$(srcdir)/tst_types.c \
 	$(srcdir)/tst_iscan.c \
+	$(srcdir)/tst_csum.c \
+	$(srcdir)/crc16.c \
+	$(srcdir)/csum.c \
 	$(srcdir)/unix_io.c \
 	$(srcdir)/unlink.c \
 	$(srcdir)/valid_blk.c \
@@ -189,11 +194,13 @@ ext2fs.pc: $(srcdir)/ext2fs.pc.in $(top_
 	@cd $(top_builddir); CONFIG_FILES=lib/ext2fs/ext2fs.pc ./config.status
 
 tst_badblocks: tst_badblocks.o freefs.o bitmaps.o rw_bitmaps.o \
-		read_bb_file.o write_bb_file.o badblocks.o 
+		read_bb_file.o write_bb_file.o badblocks.o csum.o \
+		crc16.o $(STATIC_LIBEXT2FS) 
 	@echo "	LD $@"
 	@$(CC) -o tst_badblocks tst_badblocks.o freefs.o \
 		read_bb_file.o write_bb_file.o badblocks.o rw_bitmaps.o \
-		inline.o bitops.o gen_bitmap.o bitmaps.o $(LIBCOM_ERR)
+		inline.o bitops.o gen_bitmap.o bitmaps.o  csum.o crc16.o \
+		 $(STATIC_LIBEXT2FS) $(LIBCOM_ERR)
 
 tst_icount: icount.c initialize.o  $(STATIC_LIBEXT2FS)
 	@echo "	LD $@"
@@ -225,6 +232,11 @@ tst_bitops: tst_bitops.o inline.o $(STAT
 	@$(CC) -o tst_bitops tst_bitops.o inline.o $(ALL_CFLAGS) \
 		$(STATIC_LIBEXT2FS) $(LIBCOM_ERR)
 
+tst_csum: tst_csum.o csum.o crc16.o $(STATIC_LIBEXT2FS) $(STATIC_LIBUUID)
+	@echo "	LD $@"
+	@$(CC) -o tst_csum csum.o tst_csum.o crc16.o $(STATIC_LIBEXT2FS) \
+		$(STATIC_LIBUUID) $(LIBCOM_ERR)
+
 tst_getsectsize: tst_getsectsize.o getsectsize.o $(STATIC_LIBEXT2FS)
 	@echo "	LD $@"
 	@$(CC) -o tst_sectgetsize tst_getsectsize.o getsectsize.o \
@@ -246,13 +258,15 @@ mkjournal: mkjournal.c $(STATIC_LIBEXT2F
 	@echo "	LD $@"
 	@$(CC) -o mkjournal $(srcdir)/mkjournal.c -DDEBUG $(STATIC_LIBEXT2FS) $(LIBCOM_ERR) $(ALL_CFLAGS)
 
-check:: tst_bitops tst_badblocks tst_iscan tst_types tst_icount tst_super_size
+check:: tst_bitops tst_badblocks tst_iscan tst_types tst_icount tst_super_size \
+	tst_csum
 	LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_bitops
 	LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_badblocks
 	LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_iscan
 	LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_types
 	LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_icount
 	LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_super_size
+	LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_csum
 
 installdirs::
 	@echo "	MKINSTALLDIRS $(libdir) $(includedir)/ext2fs"
@@ -360,6 +374,10 @@ closefs.o: $(srcdir)/closefs.c $(srcdir)
  $(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h \
  $(top_srcdir)/lib/et/com_err.h $(srcdir)/ext2_io.h \
  $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h
+crc16.o: $(srcdir)/crc16.c $(srcdir)/ext2_fs.h $(srcdir)/crc16.h \
+ $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h
+csum.o: $(srcdir)/csum.c $(srcdir)/ext2_fs.h \
+ $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h
 dblist.o: $(srcdir)/dblist.c $(srcdir)/ext2_fs.h \
  $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fsP.h \
  $(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h \
@@ -570,6 +588,8 @@ tst_byteswap.o: $(srcdir)/tst_byteswap.c
  $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
  $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
  $(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h
+tst_csum.o: $(srcdir)/tst_csum.c $(srcdir)/ext2_fs.h \
+ $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h
 tst_getsize.o: $(srcdir)/tst_getsize.c $(srcdir)/ext2_fs.h \
  $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
  $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
lib/ext2fs/alloc_stats.c +25 -0
Index: e2fsprogs-1.40.5/lib/ext2fs/alloc_stats.c
===================================================================
@@ -27,6 +27,27 @@ void ext2fs_inode_alloc_stats2(ext2_fils
 	fs->group_desc[group].bg_free_inodes_count -= inuse;
 	if (isdir)
 		fs->group_desc[group].bg_used_dirs_count += inuse;
+
+	/* We don't strictly need to be clearing these if inuse < 0
+	 * (i.e. freeing inodes) but it also means something is bad. */
+	fs->group_desc[group].bg_flags &= ~(EXT2_BG_INODE_UNINIT |
+					    EXT2_BG_BLOCK_UNINIT);
+	if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
+				       EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
+		ext2_ino_t first_unused_inode =	fs->super->s_inodes_per_group -
+			fs->group_desc[group].bg_itable_unused +
+			group * fs->super->s_inodes_per_group + 1;
+
+		if (ino >= first_unused_inode)
+			fs->group_desc[group].bg_itable_unused =
+				group * fs->super->s_inodes_per_group +
+				fs->super->s_inodes_per_group - ino;
+
+		fs->group_desc[group].bg_checksum =
+			ext2fs_group_desc_csum(fs->super, group,
+					       &fs->group_desc[group]);
+	}
+
 	fs->super->s_free_inodes_count -= inuse;
 	ext2fs_mark_super_dirty(fs);
 	ext2fs_mark_ib_dirty(fs);
@@ -46,6 +67,10 @@ void ext2fs_block_alloc_stats(ext2_filsy
 	else
 		ext2fs_unmark_block_bitmap(fs->block_map, blk);
 	fs->group_desc[group].bg_free_blocks_count -= inuse;
+	fs->group_desc[group].bg_flags &= ~EXT2_BG_BLOCK_UNINIT;
+	fs->group_desc[group].bg_checksum =
+		ext2fs_group_desc_csum(fs->super, group,&fs->group_desc[group]);
+
 	fs->super->s_free_blocks_count -= inuse;
 	ext2fs_mark_super_dirty(fs);
 	ext2fs_mark_bb_dirty(fs);
lib/ext2fs/alloc_tables.c +2 -3
Index: e2fsprogs-1.40.5/lib/ext2fs/alloc_tables.c
===================================================================
@@ -95,13 +95,12 @@ errcode_t ext2fs_allocate_group_table(ex
 			ext2fs_mark_block_bitmap(bmap, blk);
 		fs->group_desc[group].bg_inode_table = new_blk;
 	}
+	fs->group_desc[group].bg_checksum =
+		ext2fs_group_desc_csum(fs->super, group,&fs->group_desc[group]);
 
-	
 	return 0;
 }
 
-	
-
 errcode_t ext2fs_allocate_tables(ext2_filsys fs)
 {
 	errcode_t	retval;
lib/ext2fs/ext2_fs.h +1 -0
Index: e2fsprogs-1.40.5/lib/ext2fs/ext2_fs.h
===================================================================
@@ -173,6 +173,7 @@ struct ext4_group_desc
 
 #define EXT2_BG_INODE_UNINIT	0x0001 /* Inode table/bitmap not initialized */
 #define EXT2_BG_BLOCK_UNINIT	0x0002 /* Block bitmap not initialized */
+#define EXT2_BG_INODE_ZEROED	0x0004 /* On-disk itable initialized to zero */
 
 /*
  * Data structures used by the directory indexing feature
lib/ext2fs/ext2fs.h +10 -2
Index: e2fsprogs-1.40.5/lib/ext2fs/ext2fs.h
===================================================================
@@ -324,6 +324,7 @@ typedef struct ext2_struct_inode_scan *e
 #define EXT2_SF_BAD_EXTRA_BYTES	0x0004
 #define EXT2_SF_SKIP_MISSING_ITABLE	0x0008
 #define EXT2_SF_DO_LAZY		0x0010
+#define EXT2_SF_DO_CSUM		0x0020
 
 /*
  * ext2fs_check_if_mounted flags
@@ -448,7 +449,8 @@ typedef struct ext2_icount *ext2_icount_
 #endif
 #define EXT2_LIB_FEATURE_RO_COMPAT_SUPP	(EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|\
 					 EXT2_FEATURE_RO_COMPAT_LARGE_FILE|\
-					 EXT4_FEATURE_RO_COMPAT_DIR_NLINK)
+					 EXT4_FEATURE_RO_COMPAT_DIR_NLINK|\
+					 EXT4_FEATURE_RO_COMPAT_GDT_CSUM)
 
 /*
  * These features are only allowed if EXT2_FLAG_SOFTSUPP_FEATURES is passed
@@ -456,7 +458,6 @@ typedef struct ext2_icount *ext2_icount_
  */
 #define EXT2_LIB_SOFTSUPP_INCOMPAT	(EXT3_FEATURE_INCOMPAT_EXTENTS)
 #define EXT2_LIB_SOFTSUPP_RO_COMPAT	(EXT4_FEATURE_RO_COMPAT_HUGE_FILE|\
-					 EXT4_FEATURE_RO_COMPAT_GDT_CSUM|\
 					 EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE)
 
 /*
@@ -634,6 +635,13 @@ extern int ext2fs_super_and_bgd_loc(ext2
 				    int *ret_meta_bg);
 extern void ext2fs_update_dynamic_rev(ext2_filsys fs);
 
+/* csum.c */
+extern __u16 ext2fs_group_desc_csum(struct ext2_super_block *sb, __u32 group,
+				    struct ext2_group_desc *desc);
+extern int ext2fs_group_desc_csum_verify(struct ext2_super_block *sb,
+				     __u32 group, struct ext2_group_desc *desc);
+extern void ext2fs_set_gdt_csum(ext2_filsys fs);
+
 /* dblist.c */
 
 extern errcode_t ext2fs_get_num_dirs(ext2_filsys fs, ext2_ino_t *ret_num_dirs);
lib/ext2fs/inode.c +22 -6
Index: e2fsprogs-1.40.5/lib/ext2fs/inode.c
===================================================================
@@ -167,6 +167,9 @@ errcode_t ext2fs_open_inode_scan(ext2_fi
 	if (EXT2_HAS_COMPAT_FEATURE(fs->super, 
 				    EXT2_FEATURE_COMPAT_LAZY_BG))
 		scan->scan_flags |= EXT2_SF_DO_LAZY;
+	if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
+				       EXT4_FEATURE_RO_COMPAT_GDT_CSUM))
+		scan->scan_flags |= EXT2_SF_DO_LAZY | EXT2_SF_DO_CSUM;
 	*ret_scan = scan;
 	return 0;
 }
@@ -218,18 +221,29 @@ int ext2fs_inode_scan_flags(ext2_inode_s
  */
 static errcode_t get_next_blockgroup(ext2_inode_scan scan)
 {
+	ext2_filsys fs = scan->fs;
+
 	scan->current_group++;
 	scan->groups_left--;
-			
-	scan->current_block = scan->fs->
-		group_desc[scan->current_group].bg_inode_table;
+
+	scan->current_block =fs->group_desc[scan->current_group].bg_inode_table;
 
 	scan->current_inode = scan->current_group *
-		EXT2_INODES_PER_GROUP(scan->fs->super);
+		EXT2_INODES_PER_GROUP(fs->super);
 
 	scan->bytes_left = 0;
-	scan->inodes_left = EXT2_INODES_PER_GROUP(scan->fs->super);
-	scan->blocks_left = scan->fs->inode_blocks_per_group;
+	scan->inodes_left = EXT2_INODES_PER_GROUP(fs->super);
+	scan->blocks_left = fs->inode_blocks_per_group;
+	if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
+				       EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
+		scan->inodes_left -=
+			fs->group_desc[scan->current_group].bg_itable_unused;
+		scan->blocks_left =
+			(scan->inodes_left +
+			 (fs->blocksize / scan->inode_size - 1)) *
+			scan->inode_size / fs->blocksize;
+	}
+
 	return 0;
 }
 
@@ -417,6 +431,8 @@ errcode_t ext2fs_get_next_inode_full(ext
 	    (scan->fs->group_desc[scan->current_group].bg_flags &
 	     EXT2_BG_INODE_UNINIT))
 		goto force_new_group;
+	if (scan->inodes_left == 0)
+		goto force_new_group;
 	if (scan->current_block == 0) {
 		if (scan->scan_flags & EXT2_SF_SKIP_MISSING_ITABLE) {
 			goto force_new_group;
lib/ext2fs/rw_bitmaps.c +10 -4
Index: e2fsprogs-1.40.5/lib/ext2fs/rw_bitmaps.c
===================================================================
@@ -152,8 +152,10 @@ static errcode_t read_bitmaps(ext2_filsy
 
 	fs->write_bitmaps = ext2fs_write_bitmaps;
 
-	if (EXT2_HAS_COMPAT_FEATURE(fs->super, 
-				    EXT2_FEATURE_COMPAT_LAZY_BG))
+	if (EXT2_HAS_COMPAT_FEATURE(fs->super,
+				    EXT2_FEATURE_COMPAT_LAZY_BG) ||
+	    EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
+				       EXT4_FEATURE_RO_COMPAT_GDT_CSUM))
 		lazy_flag = 1;
 
 	retval = ext2fs_get_mem(strlen(fs->device_name) + 80, &buf);
@@ -233,7 +235,9 @@ static errcode_t read_bitmaps(ext2_filsy
 		if (block_bitmap) {
 			blk = fs->group_desc[i].bg_block_bitmap;
 			if (lazy_flag && fs->group_desc[i].bg_flags &
-			    EXT2_BG_BLOCK_UNINIT)
+			    EXT2_BG_BLOCK_UNINIT &&
+			    ext2fs_group_desc_csum_verify(fs->super, i,
+							  &fs->group_desc[i]))
 				blk = 0;
 			if (blk) {
 				retval = io_channel_read_blk(fs->io, blk,
@@ -254,7 +258,9 @@ static errcode_t read_bitmaps(ext2_filsy
 		if (inode_bitmap) {
 			blk = fs->group_desc[i].bg_inode_bitmap;
 			if (lazy_flag && fs->group_desc[i].bg_flags &
-			    EXT2_BG_INODE_UNINIT)
+			    EXT2_BG_INODE_UNINIT &&
+			    ext2fs_group_desc_csum_verify(fs->super, i,
+							  &fs->group_desc[i]))
 				blk = 0;
 			if (blk) {
 				retval = io_channel_read_blk(fs->io, blk,
misc/dumpe2fs.c +9 -4
Index: e2fsprogs-1.40.5/misc/dumpe2fs.c
===================================================================
@@ -112,7 +112,8 @@ static void print_bg_opts(ext2_filsys fs
 {
 	int first = 1, bg_flags;
 
-	if (fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_LAZY_BG)
+	if (fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_LAZY_BG ||
+	    fs->super->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_GDT_CSUM)
 		bg_flags = fs->group_desc[i].bg_flags;
 	else
 		bg_flags = 0;
@@ -210,11 +211,15 @@ static void list_desc (ext2_filsys fs)
 		diff = fs->group_desc[i].bg_inode_table - first_block;
 		if (diff > 0)
 			printf(" (+%ld)", diff);
-		printf (_("\n  %d free blocks, %d free inodes, "
-			  "%d directories\n"),
+		printf (_("\n  %u free blocks, %u free inodes, "
+			  "%u directories%s"),
 			fs->group_desc[i].bg_free_blocks_count,
 			fs->group_desc[i].bg_free_inodes_count,
-			fs->group_desc[i].bg_used_dirs_count);
+			fs->group_desc[i].bg_used_dirs_count,
+			fs->group_desc[i].bg_itable_unused ? "" : "\n");
+		if (fs->group_desc[i].bg_itable_unused)
+			printf (_(", %u unused inodes\n"),
+				fs->group_desc[i].bg_itable_unused);
 		if (block_bitmap) {
 			fputs(_("  Free blocks: "), stdout);
 			ext2fs_get_block_bitmap_range(fs->block_map, 
misc/mke2fs.c +32 -12

85 lines not on this page · raw message

misc/tune2fs.c +10 -2
Index: e2fsprogs-1.40.5/misc/tune2fs.c
===================================================================
@@ -100,7 +100,8 @@ static __u32 ok_features[3] = {
 		EXT2_FEATURE_COMPAT_DIR_INDEX,	/* Compat */
 	EXT2_FEATURE_INCOMPAT_FILETYPE|		/* Incompat */
 		EXT4_FEATURE_INCOMPAT_FLEX_BG,
-	EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER	/* R/O compat */
+	EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER |	/* R/O compat */
+		EXT4_FEATURE_RO_COMPAT_GDT_CSUM
 };
 
 /*
@@ -215,6 +216,8 @@ static int release_blocks_proc(ext2_fils
 	ext2fs_unmark_block_bitmap(fs->block_map,block);
 	group = ext2fs_group_of_blk(fs, block);
 	fs->group_desc[group].bg_free_blocks_count++;
+	fs->group_desc[group].bg_checksum =
+		ext2fs_group_desc_csum(fs->super, group,&fs->group_desc[group]);
 	fs->super->s_free_blocks_count++;
 	return 0;
 }
@@ -284,7 +287,7 @@ static void update_mntopts(ext2_filsys f
 static void update_feature_set(ext2_filsys fs, char *features)
 {
 	int sparse, old_sparse, filetype, old_filetype;
-	int journal, old_journal, dxdir, old_dxdir;
+	int journal, old_journal, dxdir, old_dxdir, uninit, old_uninit;
 	int flex_bg, old_flex_bg;
 	struct ext2_super_block *sb= fs->super;
 	__u32	old_compat, old_incompat, old_ro_compat;
@@ -303,6 +306,8 @@ static void update_feature_set(ext2_fils
 		EXT3_FEATURE_COMPAT_HAS_JOURNAL;
 	old_dxdir = sb->s_feature_compat &
 		EXT2_FEATURE_COMPAT_DIR_INDEX;
+	old_uninit = sb->s_feature_ro_compat &
+		EXT4_FEATURE_RO_COMPAT_GDT_CSUM;
 	if (e2p_edit_feature(features, &sb->s_feature_compat,
 			     ok_features)) {
 		fprintf(stderr, _("Invalid filesystem option set: %s\n"),
@@ -319,6 +324,8 @@ static void update_feature_set(ext2_fils
 		EXT3_FEATURE_COMPAT_HAS_JOURNAL;
 	dxdir = sb->s_feature_compat &
 		EXT2_FEATURE_COMPAT_DIR_INDEX;
+	uninit = sb->s_feature_ro_compat &
+		EXT4_FEATURE_RO_COMPAT_GDT_CSUM;
 	if (old_journal && !journal) {
 		if ((mount_flags & EXT2_MF_MOUNTED) &&
 		    !(mount_flags & EXT2_MF_READONLY)) {
@@ -373,6 +380,7 @@ static void update_feature_set(ext2_fils
 	     sb->s_feature_incompat))
 		ext2fs_update_dynamic_rev(fs);
 	if ((sparse != old_sparse) ||
+	    (uninit != old_uninit) ||
 	    (filetype != old_filetype)) {
 		sb->s_state &= ~EXT2_VALID_FS;
 		printf("\n%s\n", _(please_fsck));
misc/tune2fs.8.in +12 -2
Index: e2fsprogs-1.40.5/misc/tune2fs.8.in
===================================================================
@@ -411,10 +411,18 @@ option.
 .TP
 .B sparse_super
 Limit the number of backup superblocks to save space on large filesystems.
+.TP
+.B uninit_groups
+Allow the kernel to initialize bitmaps and inode tables and keep a high
+watermark for the unused inodes in a filesystem, to reduce
+.BR e2fsck (8)
+time.  This first e2fsck run after enabling this feature will take the
+full time, but subsequent e2fsck runs will take only a fraction of the
+original time, depending on how full the file system is.
 .RE
 .IP
 After setting or clearing 
-.B sparse_super
+.BR sparse_super , " uninit_groups" ,
 and 
 .B filetype 
 filesystem features,
@@ -433,7 +441,9 @@ can be run to convert existing directori
 Linux kernels before 2.0.39 and many 2.1 series kernels do not support
 the filesystems that use any of these features.
 Enabling certain filesystem features may prevent the filesystem from
-being mounted by kernels which do not support those features.
+being mounted by kernels which do not support those features.  The
+.B uninit_groups
+feature is not yet supported by any officially released kernel.
 .TP
 .BI \-r " reserved-blocks-count"
 Set the number of reserved filesystem blocks.
resize/resize2fs.c +24 -5
Index: e2fsprogs-1.40.5/resize/resize2fs.c
===================================================================
@@ -339,7 +339,9 @@ retry:
 		numblocks = fs->super->s_blocks_per_group;
 	i = old_fs->group_desc_count - 1;
 	fs->group_desc[i].bg_free_blocks_count += (numblocks-old_numblocks);
-		
+	fs->group_desc[i].bg_checksum =
+		ext2fs_group_desc_csum(fs->super, i, &fs->group_desc[i]);
+
 	/*
 	 * If the number of block groups is staying the same, we're
 	 * done and can exit now.  (If the number block groups is
@@ -414,6 +416,8 @@ retry:
 		fs->group_desc[i].bg_free_inodes_count =
 			fs->super->s_inodes_per_group;
 		fs->group_desc[i].bg_used_dirs_count = 0;
+		fs->group_desc[i].bg_checksum =
+			ext2fs_group_desc_csum(fs->super, i,&fs->group_desc[i]);
 
 		retval = ext2fs_allocate_group_table(fs, i, 0);
 		if (retval) goto errout;
@@ -1222,9 +1226,13 @@ static errcode_t inode_scan_and_fix(ext2
 		if (retval) goto errout;
 
 		group = (new_inode-1) / EXT2_INODES_PER_GROUP(rfs->new_fs->super);
-		if (LINUX_S_ISDIR(inode.i_mode))
+		if (LINUX_S_ISDIR(inode.i_mode)) {
 			rfs->new_fs->group_desc[group].bg_used_dirs_count++;
-		
+			rfs->new_fs->group_desc[group].bg_checksum =
+				ext2fs_group_desc_csum(rfs->new_fs->super,group,
+					       &rfs->new_fs->group_desc[group]);
+		}
+
 #ifdef RESIZE2FS_DEBUG
 		if (rfs->flags & RESIZE_DEBUG_INODEMAP)
 			printf("Inode moved %u->%u\n", ino, new_inode);
@@ -1477,6 +1485,9 @@ static errcode_t move_itables(ext2_resiz
 			ext2fs_unmark_block_bitmap(fs->block_map, blk);
 
 		rfs->old_fs->group_desc[i].bg_inode_table = new_blk;
+		rfs->old_fs->group_desc[i].bg_checksum =
+			ext2fs_group_desc_csum(rfs->old_fs->super, i,
+					       &rfs->old_fs->group_desc[i]);
 		ext2fs_mark_super_dirty(rfs->old_fs);
 		ext2fs_flush(rfs->old_fs);
 
@@ -1574,8 +1585,12 @@ static errcode_t ext2fs_calculate_summar
 		count++;
 		if ((count == fs->super->s_blocks_per_group) ||
 		    (blk == fs->super->s_blocks_count-1)) {
-			fs->group_desc[group++].bg_free_blocks_count =
+			fs->group_desc[group].bg_free_blocks_count =
 				group_free;
+			fs->group_desc[group].bg_checksum =
+				ext2fs_group_desc_csum(fs->super, group,
+						       &fs->group_desc[group]);
+			group++;
 			count = 0;
 			group_free = 0;
 		}
@@ -1599,8 +1614,12 @@ static errcode_t ext2fs_calculate_summar
 		count++;
 		if ((count == fs->super->s_inodes_per_group) ||
 		    (ino == fs->super->s_inodes_count)) {
-			fs->group_desc[group++].bg_free_inodes_count =
+			fs->group_desc[group].bg_free_inodes_count =
 				group_free;
+			fs->group_desc[group].bg_checksum =
+				ext2fs_group_desc_csum(fs->super, group,
+						       &fs->group_desc[group]);
+			group++;
 			count = 0;
 			group_free = 0;
 		}
lib/ext2fs/initialize.c +2 -0
Index: e2fsprogs-1.40.5/lib/ext2fs/initialize.c
===================================================================
@@ -375,6 +375,8 @@ ipg_retry:
 		fs->group_desc[i].bg_free_inodes_count =
 			fs->super->s_inodes_per_group;
 		fs->group_desc[i].bg_used_dirs_count = 0;
+		fs->group_desc[i].bg_checksum =
+			ext2fs_group_desc_csum(fs->super, i,&fs->group_desc[i]);
 	}
 	
 	c = (char) 255;
e2fsck/pass2.c +68 -9

114 lines not on this page · raw message

lib/ext2fs/openfs.c +16 -0
Index: e2fsprogs-1.40.5/lib/ext2fs/openfs.c
===================================================================
@@ -303,6 +303,22 @@ errcode_t ext2fs_open2(const char *name,
 
 	fs->stride = fs->super->s_raid_stride;
 
+	/*
+	 * If recovery is from backup superblock, Clear _UNININT flags &
+	 * reset bg_itable_unused to zero
+	 */
+	if (superblock > 1 && EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
+					EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
+		struct ext2_group_desc *gd;
+		for (i = 0, gd = fs->group_desc; i < fs->group_desc_count;
+		     i++, gd++) {
+			gd->bg_flags &= ~EXT2_BG_BLOCK_UNINIT;
+			gd->bg_flags &= ~EXT2_BG_INODE_UNINIT;
+			gd->bg_itable_unused = 0;
+		}
+		ext2fs_mark_super_dirty(fs);
+	}
+
 	*ret_fs = fs;
 	return 0;
 cleanup:
e2fsck/unix.c +4 -0
Index: e2fsprogs-1.40.5/e2fsck/unix.c
===================================================================
@@ -1380,6 +1380,10 @@ no_journal:
 		}
 	}
 
+	if (sb->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_GDT_CSUM &&
+	    !(ctx->options & E2F_OPT_READONLY))
+		ext2fs_set_gdt_csum(ctx->fs);
+
 	e2fsck_write_bitmaps(ctx);
 #ifdef RESOURCE_TRACK
 	io_channel_flush(ctx->fs->io);
e2fsck/e2fsck.h +2 -0
Index: e2fsprogs-1.40.5/e2fsck/e2fsck.h
===================================================================
@@ -482,6 +482,8 @@ extern void e2fsck_read_bitmaps(e2fsck_t
 extern void e2fsck_write_bitmaps(e2fsck_t ctx);
 extern void preenhalt(e2fsck_t ctx);
 extern char *string_copy(e2fsck_t ctx, const char *str, int len);
+extern errcode_t e2fsck_zero_blocks(ext2_filsys fs, blk_t blk, int num,
+				    blk_t *ret_blk, int *ret_count);
 #ifdef RESOURCE_TRACK
 extern void print_resource_track(const char *desc,
 				 struct resource_track *track,
lib/ext2fs/csum.c new file +150 -0

150 lines not on this page · raw message

lib/ext2fs/crc16.c new file +61 -0

61 lines not on this page · raw message

lib/ext2fs/crc16.h new file +47 -0

47 lines not on this page · raw message

lib/ext2fs/tst_csum.c new file +140 -0

140 lines not on this page · raw message

lib/e2p/feature.c +1 -1
Index: e2fsprogs-1.40.5/lib/e2p/feature.c
===================================================================
@@ -45,7 +45,7 @@ static struct feature feature_list[] = {
 	{	E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_HUGE_FILE,
 			"huge_file" },
 	{	E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_GDT_CSUM,
-			"gdt_checksum" },
+			"uninit_groups" },
 	{	E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_DIR_NLINK,
 			"dir_nlink" },
 	{	E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE,
misc/mke2fs.8.in +7 -1
Index: e2fsprogs-1.40.5/misc/mke2fs.8.in
===================================================================
@@ -214,7 +214,7 @@ for the filesystem.  (For administrators
 filesystems on RAID arrays, it is preferable to use the
 .I stride
 RAID parameter as part of the
-.B \-R
+.B \-E
 option rather than manipulating the number of blocks per group.)  
 This option is generally used by developers who
 are developing test cases.  
@@ -412,6 +412,12 @@ Store file type information in directory
 Create an ext3 journal (as if using the
 .B \-j
 option).
+.TP
+.B uninit_groups
+Create a filesystem without initializing all of the groups.  This can reduce
+.BR e2fsck (8)
+time dramatically.  This feature causes the filesystem to be read-only in
+older kernels is not supported in most Linux kernels, use with caution.
 @[email protected]
 @[email protected] journal_dev
 @JDEV@Create an external ext3 journal on the given device
e2fsck/util.c +61 -0

70 lines not on this page · raw message

resize/main.c +7 -0
Index: e2fsprogs-1.40.5/resize/main.c
===================================================================
@@ -298,6 +298,13 @@ int main (int argc, char ** argv)
 		printf (_("Couldn't find valid filesystem superblock.\n"));
 		exit (1);
 	}
+
+	if (fs->super->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_GDT_CSUM) {
+		com_err(program_name, EXT2_ET_RO_UNSUPP_FEATURE,
+			":- uninit_groups");
+		exit(1);
+	}
+
 	/*
 	 * Check for compatibility with the feature sets.  We need to
 	 * be more stringent than ext2fs_open().
tests/f_dupfsblks/expect.1 +2 -1
Index: e2fsprogs-1.40.5/tests/f_dupfsblks/expect.1
===================================================================
@@ -44,7 +44,8 @@ Salvage? yes
 Directory inode 12, block 3, offset 0: directory corrupted
 Salvage? yes
 
-Entry '' in ??? (12) has deleted/unused inode 32.  Clear? yes
+Entry '' in ??? (12) has a zero-length name.
+Clear? yes
 
 Directory inode 12, block 4, offset 100: directory corrupted
 Salvage? yes
tests/f_uninit_last_uninit/expect.1 new file +9 -0
Index: e2fsprogs-1.40.5/tests/f_uninit_last_uninit/expect.1
===================================================================
@@ -0,0 +1,9 @@
+last group block bitmap uninitialized.  Fix? yes
+
+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: 11/32 files (9.1% non-contiguous), 105/10000 blocks
+Exit status is 0
tests/f_uninit_last_uninit/expect.2 new file +7 -0
Index: e2fsprogs-1.40.5/tests/f_uninit_last_uninit/expect.2
===================================================================
@@ -0,0 +1,7 @@
+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: 11/32 files (9.1% non-contiguous), 105/10000 blocks
+Exit status is 0
tests/f_uninit_last_uninit/name new file +2 -0
Index: e2fsprogs-1.40.5/tests/f_uninit_last_uninit/name
===================================================================
@@ -0,0 +1,2 @@
+last group has BLOCK_UNINIT set
+
tests/f_uninit_last_uninit/script new file +20 -0
Index: e2fsprogs-1.40.5/tests/f_uninit_last_uninit/script
===================================================================
@@ -0,0 +1,20 @@
+SKIP_GUNZIP="true"
+
+touch $TMPFILE
+$MKE2FS -N 32 -F -o Linux -O uninit_groups -b 1024 $TMPFILE 10000 > /dev/null 2>&1 
+$DEBUGFS -w $TMPFILE << EOF > /dev/null 2>&1
+set_current_time 200704102100
+set_super_value lastcheck 0
+set_super_value hash_seed null
+set_super_value mkfs_time 0
+set_bg 1 flags 0x7
+set_bg 1 checksum calc
+q
+EOF
+
+E2FSCK_TIME=200704102100
+export E2FSCK_TIME
+
+. $cmd_dir/run_e2fsck
+
+unset E2FSCK_TIME
tests/m_lazy/expect.1 new file +158 -0

158 lines not on this page · raw message

tests/m_lazy/script new file +4 -0
Index: e2fsprogs-1.40.5/tests/m_lazy/script
===================================================================
@@ -0,0 +1,4 @@
+DESCRIPTION="lazy group feature"
+FS_SIZE=131072
+MKE2FS_OPTS="-O ^resize_inode,lazy_bg"
+. $cmd_dir/run_mke2fs
tests/m_lazy_resize/expect.1 new file +166 -0

166 lines not on this page · raw message

tests/m_lazy_resize/script new file +4 -0
Index: e2fsprogs-1.40.5/tests/m_lazy_resize/script
===================================================================
@@ -0,0 +1,4 @@
+DESCRIPTION="lazy group feature with resize_inode"
+FS_SIZE=131072
+MKE2FS_OPTS="-O resize_inode,lazy_bg"
+. $cmd_dir/run_mke2fs
tests/m_raid_opt/expect.1 +22 -11
Index: e2fsprogs-1.40.5/tests/m_raid_opt/expect.1
===================================================================
@@ -46,57 +46,68 @@ Setting filetype for entry '..' in ??? (
 Directory inode 11, block 1, offset 0: directory corrupted
 Salvage? yes
 
-Entry '' in ??? (11) has deleted/unused inode 1063.  Clear? yes
+Entry '' in ??? (11) has a zero-length name.
+Clear? yes
 
 Directory inode 11, block 2, offset 0: directory corrupted
 Salvage? yes
 
-Entry '' in ??? (11) has deleted/unused inode 1064.  Clear? yes
+Entry '' in ??? (11) has a zero-length name.
+Clear? yes
 
 Directory inode 11, block 3, offset 0: directory corrupted
 Salvage? yes
 
-Entry '' in ??? (11) has deleted/unused inode 1065.  Clear? yes
+Entry '' in ??? (11) has a zero-length name.
+Clear? yes
 
 Directory inode 11, block 4, offset 0: directory corrupted
 Salvage? yes
 
-Entry '' in ??? (11) has deleted/unused inode 1066.  Clear? yes
+Entry '' in ??? (11) has a zero-length name.
+Clear? yes
 
 Directory inode 11, block 5, offset 0: directory corrupted
 Salvage? yes
 
-Entry '' in ??? (11) has deleted/unused inode 1067.  Clear? yes
+Entry '' in ??? (11) has a zero-length name.
+Clear? yes
 
 Directory inode 11, block 6, offset 0: directory corrupted
 Salvage? yes
 
-Entry '' in ??? (11) has deleted/unused inode 1068.  Clear? yes
+Entry '' in ??? (11) has a zero-length name.
+Clear? yes
 
 Directory inode 11, block 7, offset 0: directory corrupted
 Salvage? yes
 
-Entry '' in ??? (11) has deleted/unused inode 1069.  Clear? yes
+Entry '' in ??? (11) has a zero-length name.
+Clear? yes
 
 Directory inode 11, block 8, offset 0: directory corrupted
 Salvage? yes
 
-Entry '' in ??? (11) has deleted/unused inode 1070.  Clear? yes
+Entry '' in ??? (11) has a zero-length name.
+Clear? yes
 
 Directory inode 11, block 9, offset 0: directory corrupted
 Salvage? yes
 
-Entry '' in ??? (11) has deleted/unused inode 1071.  Clear? yes
+Entry '' in ??? (11) has a zero-length name.
+Clear? yes
 
 Directory inode 11, block 10, offset 0: directory corrupted
 Salvage? yes
 
-Entry '' in ??? (11) has deleted/unused inode 1072.  Clear? yes
+Entry '' in ??? (11) has a zero-length name.
+Clear? yes
 
 Directory inode 11, block 11, offset 0: directory corrupted
 Salvage? yes
 
-Entry '' in ??? (11) has deleted/unused inode 1073.  Clear? yes
+Entry '' in ??? (11) has a zero-length name.
+Clear? yes
 
 Pass 3: Checking directory connectivity
 '..' in / (2) is <The NULL inode> (0), should be / (2).
tests/m_uninit/expect.1 new file +166 -0

166 lines not on this page · raw message

tests/m_uninit/script new file +4 -0
Index: e2fsprogs-1.40.5/tests/m_uninit/script
===================================================================
@@ -0,0 +1,4 @@
+DESCRIPTION="uninitialized group feature"
+FS_SIZE=131072
+MKE2FS_OPTS="-O uninit_groups"
+. $cmd_dir/run_mke2fs

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#18 lore raw

Re: [PATCH][10/28] e2fsprogs-uninit.patch

What is the intended use of the SF_DO_CSUM flag? I see where it is defined, and where it gets sets, but as far as I can tell nothing actually tests for it or uses it.

- Ted

Quoted 16 lines · Andreas Dilger

Index: e2fsprogs-1.40.5/lib/ext2fs/ext2fs.h

+#define EXT2_SF_DO_CSUM 0x0020

Index: e2fsprogs-1.40.5/lib/ext2fs/inode.c
===================================================================

lib/ext2fs/inode.c +3 -0
@@ -167,6 +167,9 @@ errcode_t ext2fs_open_inode_scan(ext2_fi
 	if (EXT2_HAS_COMPAT_FEATURE(fs->super, 
 				    EXT2_FEATURE_COMPAT_LAZY_BG))
 		scan->scan_flags |= EXT2_SF_DO_LAZY;
+	if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
+				       EXT4_FEATURE_RO_COMPAT_GDT_CSUM))
+		scan->scan_flags |= EXT2_SF_DO_LAZY | EXT2_SF_DO_CSUM;
#19 lore raw

Re: [PATCH][10/28] e2fsprogs-uninit.patch

Quoted 3 lines · Theodore Ts'o

What is the intended use of the SF_DO_CSUM flag? I see where it is defined, and where it gets sets, but as far as I can tell nothing actually tests for it or uses it.

Probably a hold-over from a previous version of the code. It sets the SF_DO_LAZY flag if GDT_CSUM is set, causing ext2fs_get_next_inode_full() to skip the BG_INODE_UNINT groups. It's up to you if it would be better to keep SF_DO_CSUM and check for it explicitly (possibly using it for something else later), or to overload SF_DO_LAZY as we do currently.

Quoted 6 lines · Andreas Dilger
Quoted 4 lines

Index: e2fsprogs-1.40.5/lib/ext2fs/ext2fs.h

+#define EXT2_SF_DO_CSUM 0x0020

Quoted 11 lines

lib/ext2fs/inode.c errcode_t ext2fs_open_inode_scan(ext2_fi · line 172

Quoted 11 lines

Index: e2fsprogs-1.40.5/lib/ext2fs/inode.c
===================================================================

lib/ext2fs/inode.c +3 -0
@@ -167,6 +167,9 @@ errcode_t ext2fs_open_inode_scan(ext2_fi
 	if (EXT2_HAS_COMPAT_FEATURE(fs->super, 
 				    EXT2_FEATURE_COMPAT_LAZY_BG))
 		scan->scan_flags |= EXT2_SF_DO_LAZY;
+	if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
+				       EXT4_FEATURE_RO_COMPAT_GDT_CSUM))
+		scan->scan_flags |= EXT2_SF_DO_LAZY | EXT2_SF_DO_CSUM;

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#20 lore raw

Re: [PATCH][10/28] e2fsprogs-uninit.patch

In reply to Andreas Dilger

Review void check_super_block(e2fsck_t ctx)

Quoted 3 lines · Andreas Dilger

Index: e2fsprogs-1.40.5/e2fsck/super.c
===================================================================

(quoted diff) +0 -0
@@ -626,6 +631,50 @@ void check_super_block(e2fsck_t ctx)
	...

e2fsck/super.c void check_super_block(e2fsck_t ctx) · line 642

Quoted 9 lines
e2fsck/super.c +9 -0
+		if (!ext2fs_group_desc_csum_verify(sb, i, gd)) {
+			if (fix_problem(ctx, PR_0_GDT_CSUM, &pctx)) {
+				gd->bg_flags &=	~(EXT2_BG_BLOCK_UNINIT |
+				                  EXT2_BG_INODE_UNINIT);
+				gd->bg_itable_unused = 0;
+			}
+			ext2fs_unmark_valid(fs);
+		}
+
	...

Review void check_super_block(e2fsck_t ctx) · line 641

Quoted 2 lines
(quoted diff) +2 -0
+
+		gd->bg_checksum = ext2fs_group_desc_csum(fs->super, i, gd);

This last looks horribly wrong. check_super_block() is merely supposed to check to see if the superblock and block gorup descriptos looks OK, and to mark the filesystem as invalid if anything looks insane. It should *not* modifying the block group descriptor, and it certainly should not be doing so without first checking to see if the filesystem has been opened read/only or calling ext2fs_mark_super_dirty(fs) after making a change (that it shouldn't do).

In fact there already is a check to see if the checksum has verified correctly (see the first part of the patch which I quoted), so I think the best thing to do is to remove that last bit. I'm not sure why it's there at all, in fact....

- Ted

#21 lore raw

Re: [PATCH][11/28] e2fsprogs-nlinks-flag.patch

In reply to Andreas Dilger

If there are any directories with > 65000 subdirectories, enable the DIR_NLINK feature in the superblock. If there are any directories that formerly had > 65000 subdirs (i_links_count == 1) but no longer do, don't consider this an error to alert the user about, but silently fix the link count to the currently counted link count.

The DIR_NLINK feature is not disabled if set but no many-subdir directories are found, so that the kernel is not required to enable it on-the-fly. The admin should set it with tune2fs instead.

e2fsck/pass4.c +14 -0
Index: e2fsprogs-1.40.5/e2fsck/pass4.c
===================================================================
@@ -101,6 +101,7 @@ void e2fsck_pass4(e2fsck_t ctx)
 	struct problem_context	pctx;
 	__u16	link_count;
 	__u32	link_counted;
+	__u32   many_subdirs = 0;
 	char	*buf = 0;
 	int	group, maxgroup;
 	
@@ -182,7 +183,20 @@ void e2fsck_pass4(e2fsck_t ctx)
 				e2fsck_write_inode(ctx, i, inode, "pass4");
 			}
 		}
+		if (link_count == 1 && link_counted > EXT2_LINK_MAX)
+			many_subdirs++;
 	}
+
+	if (many_subdirs) {
+		if (!(fs->super->s_feature_ro_compat &
+		      EXT4_FEATURE_RO_COMPAT_DIR_NLINK) &&
+		    fix_problem(ctx, PR_4_FEATURE_DIR_NLINK, &pctx)) {
+			fs->super->s_feature_ro_compat |=
+				EXT4_FEATURE_RO_COMPAT_DIR_NLINK;
+			ext2fs_mark_super_dirty(fs);
+		}
+	}
+
 	ext2fs_free_icount(ctx->inode_link_info); ctx->inode_link_info = 0;
 	ext2fs_free_icount(ctx->inode_count); ctx->inode_count = 0;
 	ext2fs_free_inode_bitmap(ctx->inode_bb_map);
e2fsck/problem.c +5 -0
Index: e2fsprogs-1.40.5/e2fsck/problem.c
===================================================================
@@ -1371,6 +1371,11 @@ static struct e2fsck_problem problem_tab
 	  "They @s the same!\n"),
 	  PROMPT_NONE, 0 },
 
+	/* DIR_NLINK flag not set but dirs with > 65000 subdirs found */
+	{ PR_4_FEATURE_DIR_NLINK,
+	  N_("@f has @d with > 65000 subdirs, but no DIR_NLINK flag in @S.\n"),
+          PROMPT_FIX, 0 },
+
 	/* Pass 5 errors */
 		  
 	/* Pass 5: Checking group summary information */
e2fsck/problem.h +4 -0
Index: e2fsprogs-1.40.5/e2fsck/problem.h
===================================================================
@@ -824,6 +824,10 @@ struct problem_context {
 /* Inconsistent inode count information cached */
 #define PR_4_INCONSISTENT_COUNT	0x040004
 
+/* Directory with > EXT2_LINK_MAX subdirs found but
+ * EXT4_FEATURE_RO_COMPAT_DIR_NLINK flag is not set */
+#define PR_4_FEATURE_DIR_NLINK	0x040005
+
 /*
  * Pass 5 errors
  */
misc/tune2fs.8.in +4 -0
Index: e2fsprogs-1.40.5/misc/tune2fs.8.in
===================================================================
@@ -400,6 +400,10 @@ The following filesystem features can be
 .B dir_index
 Use hashed b-trees to speed up lookups in large directories.
 .TP
+.B dir_nlink
+Allow directories to have more than 65000 subdirectories (read-only
+compatible).
+.TP
 .B filetype
 Store file type information in directory entries.
 .TP
misc/tune2fs.c +15 -1
Index: e2fsprogs-1.40.5/misc/tune2fs.c
===================================================================
@@ -100,7 +100,8 @@ static __u32 ok_features[3] = {
 	EXT2_FEATURE_INCOMPAT_FILETYPE|		/* Incompat */
 		EXT4_FEATURE_INCOMPAT_FLEX_BG,
 	EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER |	/* R/O compat */
-		EXT4_FEATURE_RO_COMPAT_GDT_CSUM
+		EXT4_FEATURE_RO_COMPAT_GDT_CSUM |
+		EXT4_FEATURE_RO_COMPAT_DIR_NLINK,
 };
 
 /*
@@ -286,6 +287,7 @@ static void update_feature_set(ext2_fils
 	int sparse, old_sparse, filetype, old_filetype;
 	int journal, old_journal, dxdir, old_dxdir;
 	int flex_bg, old_flex_bg;
+	int dir_nlink, old_dir_nlink;
 	struct ext2_super_block *sb= fs->super;
 	__u32	old_compat, old_incompat, old_ro_compat;
 
@@ -295,6 +297,8 @@ static void update_feature_set(ext2_fils
 
 	old_sparse = sb->s_feature_ro_compat &
 		EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER;
+	old_dir_nlink = sb->s_feature_ro_compat &
+		EXT4_FEATURE_RO_COMPAT_DIR_NLINK;
 	old_filetype = sb->s_feature_incompat &
 		EXT2_FEATURE_INCOMPAT_FILETYPE;
 	old_flex_bg = sb->s_feature_incompat &
@@ -311,6 +315,8 @@ static void update_feature_set(ext2_fils
 	}
 	sparse = sb->s_feature_ro_compat &
 		EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER;
+	dir_nlink = sb->s_feature_ro_compat &
+		EXT4_FEATURE_RO_COMPAT_DIR_NLINK;
 	filetype = sb->s_feature_incompat &
 		EXT2_FEATURE_INCOMPAT_FILETYPE;
 	flex_bg = sb->s_feature_incompat &
@@ -359,6 +365,14 @@ static void update_feature_set(ext2_fils
 		if (uuid_is_null((unsigned char *) sb->s_hash_seed))
 			uuid_generate((unsigned char *) sb->s_hash_seed);
 	}
+
+	if (old_dir_nlink && !dir_nlink) {
+		fputs(_("The dir_nlink flag was cleared.  "
+			"Please run e2fsck before using the filesystem\n"
+			"to verify no many-linked directories exist or "
+			"data loss may result.\n"), stderr);
+	}
+
 	if (!flex_bg && old_flex_bg) {
 		if (ext2fs_check_desc(fs)) {
 			fputs(_("Clearing the flex_bg flag would "

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#22 lore raw

Re: [PATCH][12/28] e2fsprogs-expand-extra-isize.patch

In reply to Andreas Dilger

This patch adds a "-E expand_extra_isize" feature which makes sure that _every_ used inode has i_extra_isize >= s_min_extra_isize if s_min_extra_isize is set. Else it makes sure that i_extra_isize of every inode is equal to sizeof(ext2_inode_large) - 128.

This is useful for the case where nanosecond timestamps or 64-bit inode version fields are required for all inodes in the filesystem.

lib/ext2fs/ext_attr.c +913 -3
Index: e2fsprogs-1.40.5/lib/ext2fs/ext_attr.c
===================================================================
@@ -17,6 +17,7 @@
 #endif
 #include <string.h>
 #include <time.h>
+#include <errno.h>
 
 #include "ext2_fs.h"
 #include "ext2_ext_attr.h"
@@ -60,11 +61,39 @@ __u32 ext2fs_ext_attr_hash_entry(struct 
 #undef NAME_HASH_SHIFT
 #undef VALUE_HASH_SHIFT
 
+#define BLOCK_HASH_SHIFT 16
+/*
+ * Re-compute the extended attribute hash value after an entry has changed.
+ */
+static void ext2fs_attr_rehash(struct ext2_ext_attr_header *header,
+			       struct ext2_ext_attr_entry *entry)
+{
+	struct ext2_ext_attr_entry *here;
+	__u32 hash = 0;
+
+	entry->e_hash = ext2fs_ext_attr_hash_entry(entry, (char *) header +
+						   entry->e_value_offs);
+
+	here = ENTRY(header+1);
+	while (!EXT2_EXT_IS_LAST_ENTRY(here)) {
+		if (!here->e_hash) {
+			/* Block is not shared if an entry's hash value == 0 */
+			hash = 0;
+			break;
+		}
+		hash = (hash << BLOCK_HASH_SHIFT) ^
+		       (hash >> (8*sizeof(hash) - BLOCK_HASH_SHIFT)) ^
+		       here->e_hash;
+		here = EXT2_EXT_ATTR_NEXT(here);
+	}
+	header->h_hash = hash;
+}
+
 errcode_t ext2fs_read_ext_attr(ext2_filsys fs, blk_t block, void *buf)
 {
 	errcode_t	retval;
 
- 	retval = io_channel_read_blk(fs->io, block, 1, buf);
+	retval = io_channel_read_blk(fs->io, block, 1, buf);
 	if (retval)
 		return retval;
 #ifdef WORDS_BIGENDIAN
@@ -88,7 +117,7 @@ errcode_t ext2fs_write_ext_attr(ext2_fil
 #else
 	write_buf = (char *) inbuf;
 #endif
- 	retval = io_channel_write_blk(fs->io, block, 1, write_buf);
+	retval = io_channel_write_blk(fs->io, block, 1, write_buf);
 	if (buf)
 		ext2fs_free_mem(&buf);
 	if (!retval)
@@ -122,7 +151,10 @@ errcode_t ext2fs_adjust_ea_refcount(ext2
 	if (retval)
 		goto errout;
 
-	header = (struct ext2_ext_attr_header *) block_buf;
+	header = BHDR(block_buf);
+	if (header->h_magic != EXT2_EXT_ATTR_MAGIC)
+		return EXT2_ET_EA_BAD_MAGIC;
+
 	header->h_refcount += adjust;
 	if (newcount)
 		*newcount = header->h_refcount;
@@ -136,3 +168,881 @@ errout:
 		ext2fs_free_mem(&buf);
 	return retval;
 }
+
+struct ext2_attr_info {
+	int name_index;
+	const char *name;
+	const char *value;
+	int value_len;
+};
+
+struct ext2_attr_search {
+	struct ext2_ext_attr_entry *first;
+	char *base;
+	char *end;
+	struct ext2_ext_attr_entry *here;
+	int not_found;
+};
+
+struct ext2_attr_ibody_find {
+	ext2_ino_t ino;
+	struct ext2_attr_search s;
+};
+
+struct ext2_attr_block_find {
+	struct ext2_attr_search s;
+	char *block;
+};
+
+void ext2fs_attr_shift_entries(struct ext2_ext_attr_entry *entry,
+			       int value_offs_shift, char *to,
+			       char *from, int n)
+{
+	struct ext2_ext_attr_entry *last = entry;
+
+	/* Adjust the value offsets of the entries */
+	for (; !EXT2_EXT_IS_LAST_ENTRY(last); last = EXT2_EXT_ATTR_NEXT(last)) {
+		if (!last->e_value_block && last->e_value_size) {
+			last->e_value_offs = last->e_value_offs +
+							value_offs_shift;
+		}
+	}
+	/* Shift the entries by n bytes */
+	memmove(to, from, n);
+}
+
+/*
+ * This function returns the free space present in the inode or the EA block.
+ * total is number of bytes taken up by the EA entries and is used to shift the
+ * EAs in ext2fs_expand_extra_isize().
+ */
+int ext2fs_attr_free_space(struct ext2_ext_attr_entry *last,
+			   int *min_offs, char *base, int *total)
+{
+	for (; !EXT2_EXT_IS_LAST_ENTRY(last); last = EXT2_EXT_ATTR_NEXT(last)) {
+		*total += EXT2_EXT_ATTR_LEN(last->e_name_len);
+		if (!last->e_value_block && last->e_value_size) {
+			int offs = last->e_value_offs;
+			if (offs < *min_offs)
+				*min_offs = offs;
+		}
+	}
+
+	return (*min_offs - ((char *)last - base) - sizeof(__u32));
+}
+
+static errcode_t ext2fs_attr_check_names(struct ext2_ext_attr_entry *entry,
+					 char *end)
+{
+	while (!EXT2_EXT_IS_LAST_ENTRY(entry)) {
+		struct ext2_ext_attr_entry *next = EXT2_EXT_ATTR_NEXT(entry);
+		if ((char *)next >= end)
+			return EXT2_ET_EA_BAD_ENTRIES;
+		entry = next;
+	}
+	return 0;
+}
+
+static errcode_t ext2fs_attr_find_entry(struct ext2_ext_attr_entry **pentry,
+					int name_index, const char *name,
+					int size, int sorted)
+{
+	struct ext2_ext_attr_entry *entry;
+	int name_len;
+	int cmp = 1;
+
+	if (name == NULL)
+		return EXT2_ET_EA_BAD_NAME;
+
+	name_len = strlen(name);
+	entry = *pentry;
+	for (; !EXT2_EXT_IS_LAST_ENTRY(entry);
+		entry = EXT2_EXT_ATTR_NEXT(entry)) {
+		cmp = name_index - entry->e_name_index;
+		if (!cmp)
+			cmp = name_len - entry->e_name_len;
+		if (!cmp)
+			cmp = memcmp(name, entry->e_name, name_len);
+		if (cmp <= 0 && (sorted || cmp == 0))
+			break;
+	}
+	*pentry = entry;
+
+	return cmp ? EXT2_ET_EA_NAME_NOT_FOUND : 0;
+}
+
+static errcode_t ext2fs_attr_block_find(ext2_filsys fs,struct ext2_inode *inode,
+					struct ext2_attr_info *i,
+					struct ext2_attr_block_find *bs)
+{
+	struct ext2_ext_attr_header *header;
+	errcode_t error;
+
+	if (inode->i_file_acl) {
+		/* The inode already has an extended attribute block. */
+		error = ext2fs_get_mem(fs->blocksize, &bs->block);
+		if (error)
+			return error;
+		error = ext2fs_read_ext_attr(fs, inode->i_file_acl, bs->block);
+		if (error)
+			goto cleanup;
+
+		header = BHDR(bs->block);
+		if (header->h_magic != EXT2_EXT_ATTR_MAGIC) {
+			error = EXT2_ET_EA_BAD_MAGIC;
+			goto cleanup;
+		}
+
+		/* Find the named attribute. */
+		bs->s.base = bs->block;
+		bs->s.first = (struct ext2_ext_attr_entry *)(header + 1);
+		bs->s.end = bs->block + fs->blocksize;
+		bs->s.here = bs->s.first;
+		error = ext2fs_attr_find_entry(&bs->s.here, i->name_index,
+					       i->name, fs->blocksize, 1);
+		if (error && error != EXT2_ET_EA_NAME_NOT_FOUND)
+			goto cleanup;
+		bs->s.not_found = error;
+	}
+	error = 0;
+
+cleanup:
+	if (error && bs->block)
+		ext2fs_free_mem(&bs->block);
+	return error;
+}
+
+static errcode_t ext2fs_attr_ibody_find(ext2_filsys fs,
+					struct ext2_inode_large *inode,
+					struct ext2_attr_info *i,
+					struct ext2_attr_ibody_find *is)
+{
+	__u32 *eamagic;
+	char *start;
+	errcode_t error;
+
+	if (EXT2_INODE_SIZE(fs->super) == EXT2_GOOD_OLD_INODE_SIZE)
+		return 0;
+
+	if (inode->i_extra_isize == 0)
+		return 0;
+	eamagic = IHDR(inode);
+
+	start = (char *) inode + EXT2_GOOD_OLD_INODE_SIZE +
+				inode->i_extra_isize + sizeof(__u32);
+	is->s.first = (struct ext2_ext_attr_entry *) start;
+	is->s.base = start;
+	is->s.here = is->s.first;
+	is->s.end = (char *) inode + EXT2_INODE_SIZE(fs->super);
+	if (*eamagic == EXT2_EXT_ATTR_MAGIC) {
+		error = ext2fs_attr_check_names((struct ext2_ext_attr_entry *)
+						start, is->s.end);
+		if (error)
+			return error;
+		/* Find the named attribute. */
+		error = ext2fs_attr_find_entry(&is->s.here, i->name_index,
+					       i->name, is->s.end -
+					       (char *)is->s.base, 0);
+		if (error && error != EXT2_ET_EA_NAME_NOT_FOUND)
+			return error;
+		is->s.not_found = error;
+	}
+
+	return 0;
+}
+
+static errcode_t ext2fs_attr_set_entry(ext2_filsys fs, struct ext2_attr_info *i,
+				       struct ext2_attr_search *s)
+{
+	struct ext2_ext_attr_entry *last;
+	int free, min_offs = s->end - s->base, name_len = strlen(i->name);
+
+	/* Compute min_offs and last. */
+	for (last = s->first; !EXT2_EXT_IS_LAST_ENTRY(last);
+	     last = EXT2_EXT_ATTR_NEXT(last)) {
+		if (!last->e_value_block && last->e_value_size) {
+			int offs = last->e_value_offs;
+
+			if (offs < min_offs)
+				min_offs = offs;
+		}
+	}
+	free = min_offs - ((char *)last - s->base) - sizeof(__u32);
+
+	if (!s->not_found) {
+		if (!s->here->e_value_block && s->here->e_value_size) {
+			int size = s->here->e_value_size;
+			free += EXT2_EXT_ATTR_SIZE(size);
+		}
+		free += EXT2_EXT_ATTR_LEN(name_len);
+	}
+	if (i->value) {
+		if (free < EXT2_EXT_ATTR_LEN(name_len) +
+			   EXT2_EXT_ATTR_SIZE(i->value_len))
+			return EXT2_ET_EA_NO_SPACE;
+	}
+
+	if (i->value && s->not_found) {
+		/* Insert the new name. */
+		int size = EXT2_EXT_ATTR_LEN(name_len);
+		int rest = (char *)last - (char *)s->here + sizeof(__u32);
+
+		memmove((char *)s->here + size, s->here, rest);
+		memset(s->here, 0, size);
+		s->here->e_name_index = i->name_index;
+		s->here->e_name_len = name_len;
+		memcpy(s->here->e_name, i->name, name_len);
+	} else {
+		if (!s->here->e_value_block && s->here->e_value_size) {
+			char *first_val = s->base + min_offs;
+			int offs = s->here->e_value_offs;
+			char *val = s->base + offs;
+			int size = EXT2_EXT_ATTR_SIZE(s->here->e_value_size);
+
+			if (i->value &&
+			    size == EXT2_EXT_ATTR_SIZE(i->value_len)) {
+				/* The old and the new value have the same
+				   size. Just replace. */
+				s->here->e_value_size = i->value_len;
+				memset(val + size - EXT2_EXT_ATTR_PAD, 0,
+				       EXT2_EXT_ATTR_PAD); /* Clear pad bytes */
+				memcpy(val, i->value, i->value_len);
+				return 0;
+			}
+
+			/* Remove the old value. */
+			memmove(first_val + size, first_val, val - first_val);
+			memset(first_val, 0, size);
+			s->here->e_value_size = 0;
+			s->here->e_value_offs = 0;
+			min_offs += size;
+
+			/* Adjust all value offsets. */
+			last = s->first;
+			while (!EXT2_EXT_IS_LAST_ENTRY(last)) {
+				int o = last->e_value_offs;
+
+				if (!last->e_value_block &&
+				    last->e_value_size && o < offs)
+					last->e_value_offs = o + size;
+				last = EXT2_EXT_ATTR_NEXT(last);
+			}
+		}
+		if (!i->value) {
+			/* Remove the old name. */
+			int size = EXT2_EXT_ATTR_LEN(name_len);
+
+			last = ENTRY((char *)last - size);
+			memmove((char *)s->here, (char *)s->here + size,
+				(char *)last - (char *)s->here + sizeof(__u32));
+			memset(last, 0, size);
+		}
+	}
+
+	if (i->value) {
+		/* Insert the new value. */
+		s->here->e_value_size = i->value_len;
+		if (i->value_len) {
+			int size = EXT2_EXT_ATTR_SIZE(i->value_len);
+			char *val = s->base + min_offs - size;
+
+			s->here->e_value_offs = min_offs - size;
+			memset(val + size - EXT2_EXT_ATTR_PAD, 0,
+			       EXT2_EXT_ATTR_PAD); /* Clear the pad bytes. */
+			memcpy(val, i->value, i->value_len);
+		}
+	}
+
+	return 0;
+}
+
+static errcode_t ext2fs_attr_block_set(ext2_filsys fs, struct ext2_inode *inode,
+				       struct ext2_attr_info *i,
+				       struct ext2_attr_block_find *bs)
+{
+	struct ext2_attr_search *s = &bs->s;
+	char *new_buf = NULL, *old_block = NULL;
+	blk_t blk;
+	int clear_flag = 0;
+	errcode_t error;
+
+	if (i->value && i->value_len > fs->blocksize)
+		return EXT2_ET_EA_NO_SPACE;
+
+	if (s->base) {
+		if (BHDR(s->base)->h_refcount != 1) {
+			int offset = (char *)s->here - bs->block;
+
+			/* Decrement the refcount of the shared block */
+			old_block = s->base;
+			BHDR(s->base)->h_refcount -= 1;
+
+			error = ext2fs_get_mem(fs->blocksize, &s->base);
+			if (error)
+				goto cleanup;
+			clear_flag = 1;
+			memcpy(s->base, bs->block, fs->blocksize);
+			s->first = ENTRY(BHDR(s->base)+1);
+			BHDR(s->base)->h_refcount = 1;
+			s->here = ENTRY(s->base + offset);
+			s->end = s->base + fs->blocksize;
+		}
+	} else {
+		error = ext2fs_get_mem(fs->blocksize, &s->base);
+		if (error)
+			goto cleanup;
+		clear_flag = 1;
+		memset(s->base, 0, fs->blocksize);
+		BHDR(s->base)->h_magic = EXT2_EXT_ATTR_MAGIC;
+		BHDR(s->base)->h_blocks = 1;
+		BHDR(s->base)->h_refcount = 1;
+		s->first = ENTRY(BHDR(s->base)+1);
+		s->here = ENTRY(BHDR(s->base)+1);
+		s->end = s->base + fs->blocksize;
+	}
+
+	error = ext2fs_attr_set_entry(fs, i, s);
+	if (error)
+		goto cleanup;
+
+	if (!EXT2_EXT_IS_LAST_ENTRY(s->first))
+		ext2fs_attr_rehash(BHDR(s->base), s->here);
+
+	if (!EXT2_EXT_IS_LAST_ENTRY(s->first)) {
+		if (bs->block && bs->block == s->base) {
+			/* We are modifying this block in-place */
+			new_buf = bs->block;
+			blk = inode->i_file_acl;
+			error = ext2fs_write_ext_attr(fs, blk, s->base);
+			if (error)
+				goto cleanup;
+		} else {
+			/* We need to allocate a new block */
+			error = ext2fs_new_block(fs, 0, 0, &blk);
+			if (error)
+				goto cleanup;
+			ext2fs_block_alloc_stats(fs, blk, +1);
+			error = ext2fs_write_ext_attr(fs, blk, s->base);
+			if (error)
+				goto cleanup;
+			new_buf = s->base;
+			if (old_block) {
+				BHDR(s->base)->h_refcount -= 1;
+				error = ext2fs_write_ext_attr(fs,
+							      inode->i_file_acl,
+							      s->base);
+				if (error)
+					goto cleanup;
+			}
+		}
+	}
+
+	/* Update the i_blocks if we added a new EA block */
+	if (!inode->i_file_acl && new_buf)
+		inode->i_blocks += fs->blocksize / 512;
+	/* Update the inode. */
+	inode->i_file_acl = new_buf ? blk : 0;
+
+cleanup:
+	if (clear_flag)
+		ext2fs_free_mem(&s->base);
+	return 0;
+}
+
+static errcode_t ext2fs_attr_ibody_set(ext2_filsys fs,
+				       struct ext2_inode_large *inode,
+				       struct ext2_attr_info *i,
+				       struct ext2_attr_ibody_find *is)
+{
+	__u32 *eamagic;
+	struct ext2_attr_search *s = &is->s;
+	errcode_t error;
+
+	if (EXT2_INODE_SIZE(fs->super) == EXT2_GOOD_OLD_INODE_SIZE)
+		return EXT2_ET_EA_NO_SPACE;
+
+	error = ext2fs_attr_set_entry(fs, i, s);
+	if (error)
+		return error;
+
+	eamagic = IHDR(inode);
+	if (!EXT2_EXT_IS_LAST_ENTRY(s->first))
+		*eamagic = EXT2_EXT_ATTR_MAGIC;
+	else
+		*eamagic = 0;
+
+	return ext2fs_write_inode_full(fs, is->ino, (struct ext2_inode *)inode,
+				       EXT2_INODE_SIZE(fs->super));
+}
+
+
+errcode_t ext2fs_attr_set(ext2_filsys fs, ext2_ino_t ino,
+			  struct ext2_inode *inode,
+			  int name_index, const char *name, const char *value,
+			  int value_len, int flags)
+{
+	struct ext2_inode_large *inode_large = NULL;
+	struct ext2_attr_info i = {
+		.name_index = name_index,
+		.name = name,
+		.value = value,
+		.value_len = value_len,
+	};
+	struct ext2_attr_ibody_find is = {
+		.ino = ino,
+		.s = { .not_found = -ENODATA, },
+	};
+	struct ext2_attr_block_find bs = {
+		.s = { .not_found = -ENODATA, },
+	};
+	errcode_t error;
+
+	if (!name)
+		return EXT2_ET_EA_BAD_NAME;
+	if (strlen(name) > 255)
+		return EXT2_ET_EA_NAME_TOO_BIG;
+
+	if (EXT2_INODE_SIZE(fs->super) > EXT2_GOOD_OLD_INODE_SIZE) {
+		inode_large = (struct ext2_inode_large *)inode;
+
+		error = ext2fs_attr_ibody_find(fs, inode_large, &i, &is);
+		if (error)
+			goto cleanup;
+	}
+	if (is.s.not_found) {
+		error = ext2fs_attr_block_find(fs, inode, &i, &bs);
+		if (error)
+			goto cleanup;
+	}
+
+	if (is.s.not_found && bs.s.not_found) {
+		error = EXT2_ET_EA_NAME_NOT_FOUND;
+		if (flags & XATTR_REPLACE)
+			goto cleanup;
+		error = 0;
+		if (!value)
+			goto cleanup;
+	} else {
+		error = EXT2_ET_EA_NAME_EXISTS;
+		if (flags & XATTR_CREATE)
+			goto cleanup;
+	}
+
+	if (!value) {
+		if (!is.s.not_found &&
+		    (EXT2_INODE_SIZE(fs->super) > EXT2_GOOD_OLD_INODE_SIZE))
+			error = ext2fs_attr_ibody_set(fs, inode_large, &i, &is);
+		else if (!bs.s.not_found)
+			error = ext2fs_attr_block_set(fs, inode, &i, &bs);
+	} else {
+		if (EXT2_INODE_SIZE(fs->super) > EXT2_GOOD_OLD_INODE_SIZE)
+			error = ext2fs_attr_ibody_set(fs, inode_large, &i, &is);
+		if (!error && !bs.s.not_found) {
+			i.value = NULL;
+			error = ext2fs_attr_block_set(fs, inode, &i, &bs);
+		} else if (error == EXT2_ET_EA_NO_SPACE) {
+			error = ext2fs_attr_block_set(fs, inode, &i, &bs);
+			if (error)
+				goto cleanup;
+			if (!is.s.not_found) {
+				i.value = NULL;
+				if (EXT2_INODE_SIZE(fs->super) >
+				    EXT2_GOOD_OLD_INODE_SIZE)
+					error = ext2fs_attr_ibody_set(fs,
+							inode_large, &i, &is);
+			}
+		}
+	}
+
+cleanup:
+	return error;
+}
+
+static errcode_t ext2fs_attr_check_block(ext2_filsys fs, char *buffer)
+{
+	if (BHDR(buffer)->h_magic != (EXT2_EXT_ATTR_MAGIC) ||
+	    BHDR(buffer)->h_blocks != 1)
+		return EXT2_ET_EA_BAD_MAGIC;
+
+	return ext2fs_attr_check_names((struct ext2_ext_attr_entry *)
+				       (BHDR(buffer) + 1),
+				       buffer + fs->blocksize);
+}
+
+static errcode_t ext2fs_attr_block_get(ext2_filsys fs, struct ext2_inode *inode,
+				       int name_index, const char *name,
+				       void *buffer, size_t buffer_size,
+				       int *easize)
+{
+	struct ext2_ext_attr_header *header = NULL;
+	struct ext2_ext_attr_entry *entry;
+	char *block_buf = NULL;
+	errcode_t error;
+
+	error = EXT2_ET_EA_NAME_NOT_FOUND;
+	if (!inode->i_file_acl)
+		goto cleanup;
+
+	error = ext2fs_get_mem(fs->blocksize, &block_buf);
+	if (error)
+		return error;
+	error = ext2fs_read_ext_attr(fs, inode->i_file_acl, block_buf);
+	if (error)
+		goto cleanup;
+
+	error = ext2fs_attr_check_block(fs, block_buf);
+	if (error)
+		goto cleanup;
+
+	header = BHDR(block_buf);
+	entry = (struct ext2_ext_attr_entry *)(header+1);
+	error = ext2fs_attr_find_entry(&entry, name_index, name,
+				       fs->blocksize, 1);
+	if (error)
+		goto cleanup;
+	if (easize)
+		*easize = entry->e_value_size;
+	if (buffer) {
+		error = EXT2_ET_EA_TOO_BIG;
+		if (entry->e_value_size > buffer_size)
+			goto cleanup;
+		memcpy(buffer, block_buf + entry->e_value_offs,
+		       entry->e_value_size);
+	}
+
+cleanup:
+	if (block_buf)
+		ext2fs_free_mem (&block_buf);
+	return error;
+}
+
+static errcode_t ext2fs_attr_ibody_get(ext2_filsys fs,
+				       struct ext2_inode_large *inode,
+				       int name_index, const char *name,
+				       void *buffer, size_t buffer_size,
+				       int *easize)
+{
+	struct ext2_ext_attr_entry *entry;
+	int error;
+	char *end, *start;
+	__u32 *eamagic;
+
+	if (EXT2_INODE_SIZE(fs->super) == EXT2_GOOD_OLD_INODE_SIZE)
+		return EXT2_ET_EA_NAME_NOT_FOUND;
+
+	eamagic = IHDR(inode);
+	error = ext2fs_attr_check_block(fs, buffer);
+	if (error)
+		return error;
+
+	start = (char *)inode + EXT2_GOOD_OLD_INODE_SIZE +
+				inode->i_extra_isize + sizeof(__u32);
+	entry = (struct ext2_ext_attr_entry *)start;
+	end = (char *)inode + EXT2_INODE_SIZE(fs->super);
+	error = ext2fs_attr_check_names(entry, end);
+	if (error)
+		goto cleanup;
+	error = ext2fs_attr_find_entry(&entry, name_index, name,
+				       end - (char *)entry, 0);
+	if (error)
+		goto cleanup;
+	if (easize)
+		*easize = entry->e_value_size;
+	if (buffer) {
+		error = EXT2_ET_EA_TOO_BIG;
+		if (entry->e_value_size > buffer_size)
+			goto cleanup;
+		memcpy(buffer, start + entry->e_value_offs,entry->e_value_size);
+	}
+
+cleanup:
+	return error;
+}
+
+
+errcode_t ext2fs_attr_get(ext2_filsys fs, struct ext2_inode *inode,
+			  int name_index, const char *name, char *buffer,
+			  size_t buffer_size, int *easize)
+{
+	errcode_t error;
+
+	error = ext2fs_attr_ibody_get(fs, (struct ext2_inode_large *)inode,
+				      name_index, name, buffer, buffer_size,
+				      easize);
+	if (error == EXT2_ET_EA_NAME_NOT_FOUND)
+		error = ext2fs_attr_block_get(fs, inode, name_index, name,
+					      buffer, buffer_size, easize);
+
+	return error;
+}
+
+char *ext2_attr_index_prefix[] = {
+	[EXT2_ATTR_INDEX_USER] = EXT2_ATTR_INDEX_USER_PREFIX,
+	[EXT2_ATTR_INDEX_POSIX_ACL_ACCESS] = EXT2_ATTR_INDEX_POSIX_ACL_ACCESS_PREFIX,
+	[EXT2_ATTR_INDEX_POSIX_ACL_DEFAULT] = EXT2_ATTR_INDEX_POSIX_ACL_DEFAULT_PREFIX,
+	[EXT2_ATTR_INDEX_TRUSTED] = EXT2_ATTR_INDEX_TRUSTED_PREFIX,
+	[EXT2_ATTR_INDEX_LUSTRE] = EXT2_ATTR_INDEX_LUSTRE_PREFIX,
+	[EXT2_ATTR_INDEX_SECURITY] = EXT2_ATTR_INDEX_SECURITY_PREFIX,
+	NULL
+};
+
+int ext2fs_attr_get_next_attr(struct ext2_ext_attr_entry *entry, int name_index,
+			      char *buffer, int buffer_size, int start)
+{
+	const int prefix_len = strlen(ext2_attr_index_prefix[name_index]);
+	int total_len;
+
+	if (!start && !EXT2_EXT_IS_LAST_ENTRY(entry))
+		entry = EXT2_EXT_ATTR_NEXT(entry);
+
+	for (; !EXT2_EXT_IS_LAST_ENTRY(entry);
+	     entry = EXT2_EXT_ATTR_NEXT(entry)) {
+		if (!name_index)
+			break;
+		if (name_index == entry->e_name_index)
+			break;
+	}
+	if (EXT2_EXT_IS_LAST_ENTRY(entry))
+		return 0;
+
+	total_len = prefix_len + entry->e_name_len + 1;
+	if (buffer && total_len <= buffer_size) {
+		memcpy(buffer, ext2_attr_index_prefix[name_index], prefix_len);
+		memcpy(buffer + prefix_len, entry->e_name, entry->e_name_len);
+		buffer[prefix_len + entry->e_name_len] = '\0';
+	}
+
+	return total_len;
+}
+
+errcode_t ext2fs_expand_extra_isize(ext2_filsys fs, ext2_ino_t ino,
+				    struct ext2_inode_large *inode,
+				    int new_extra_isize, int *ret,
+				    int *needed_size)
+{
+	struct ext2_inode *inode_buf = NULL;
+	__u32 *eamagic = NULL;
+	struct ext2_ext_attr_header *header = NULL;
+	struct ext2_ext_attr_entry *entry = NULL, *last = NULL;
+	struct ext2_attr_ibody_find is = {
+		.ino = ino,
+		.s = { .not_found = EXT2_ET_EA_NO_SPACE, },
+	};
+	struct ext2_attr_block_find bs = {
+		.s = { .not_found = EXT2_ET_EA_NO_SPACE, },
+	};
+	char *start, *end, *block_buf = NULL, *buffer =NULL, *b_entry_name=NULL;
+	int total_ino = 0, total_blk, free, offs, tried_min_extra_isize = 0;
+	int s_min_extra_isize = fs->super->s_min_extra_isize;
+	errcode_t error = 0;
+
+	if (needed_size)
+		*needed_size = new_extra_isize;
+	error = ext2fs_get_mem(fs->blocksize, &block_buf);
+	if (error)
+		return error;
+
+	if (inode == NULL) {
+		error = ext2fs_get_mem(EXT2_INODE_SIZE(fs->super), &inode_buf);
+		if (error)
+			goto cleanup;
+
+		error = ext2fs_read_inode_full(fs, ino, inode_buf,
+					       EXT2_INODE_SIZE(fs->super));
+		if (error)
+			goto cleanup;
+
+		inode = (struct ext2_inode_large *)inode_buf;
+	}
+
+retry:
+	if (inode->i_extra_isize >= new_extra_isize)
+		goto cleanup;
+
+	eamagic = IHDR(inode);
+	/* No extended attributes present */
+	if (*eamagic != EXT2_EXT_ATTR_MAGIC) {
+		memset((char *)inode + EXT2_GOOD_OLD_INODE_SIZE +
+		       inode->i_extra_isize, 0,
+		       EXT2_INODE_SIZE(fs->super) - EXT2_GOOD_OLD_INODE_SIZE -
+		       inode->i_extra_isize);
+		inode->i_extra_isize = new_extra_isize;
+		if (needed_size)
+			*needed_size = 0;
+		goto write_inode;
+	}
+
+	start = (char *) inode + EXT2_GOOD_OLD_INODE_SIZE +
+					inode->i_extra_isize + sizeof(__u32);
+	end = (char *) inode + EXT2_INODE_SIZE(fs->super);
+	last = entry = (struct ext2_ext_attr_entry *) start;
+	offs = end - start;
+	/* Consider space takenup by magic number */
+	total_ino = sizeof(__u32);
+	free = ext2fs_attr_free_space(last, &offs, start, &total_ino);
+
+	/* Enough free space available in the inode for expansion */
+	if (free >= new_extra_isize) {
+		ext2fs_attr_shift_entries(entry, inode->i_extra_isize -
+				new_extra_isize, (char *)inode +
+				EXT2_GOOD_OLD_INODE_SIZE + new_extra_isize,
+				(char *)start - sizeof(__u32), total_ino);
+		inode->i_extra_isize = new_extra_isize;
+		if (needed_size)
+			*needed_size = 0;
+		goto write_inode;
+	}
+
+	if (inode->i_file_acl) {
+		error = ext2fs_read_ext_attr(fs, inode->i_file_acl, block_buf);
+		if (error)
+			 goto cleanup;
+
+		header = BHDR(block_buf);
+		if (header->h_magic != EXT2_EXT_ATTR_MAGIC) {
+			error = EXT2_ET_EA_BAD_MAGIC;
+			goto cleanup;
+		}
+		end = block_buf + fs->blocksize;
+		last = entry = (struct ext2_ext_attr_entry *)(header+1);
+		start = (char *) entry;
+		offs = end - start;
+		free = ext2fs_attr_free_space(last, &offs, start, &total_blk);
+		if (free < new_extra_isize) {
+			if (!tried_min_extra_isize && s_min_extra_isize) {
+				tried_min_extra_isize++;
+				new_extra_isize = s_min_extra_isize;
+				goto retry;
+			}
+			if (ret)
+				*ret = EXT2_EXPAND_EISIZE_NOSPC;
+			error = EXT2_ET_EA_NO_SPACE;
+			goto cleanup;
+		}
+	} else {
+		if (ret && *ret == EXT2_EXPAND_EISIZE_UNSAFE) {
+			*ret = EXT2_EXPAND_EISIZE_NEW_BLOCK;
+			error = 0;
+			goto cleanup;
+		}
+		free = fs->blocksize;
+	}
+
+	while (new_extra_isize > 0) {
+		int offs, size, entry_size;
+		struct ext2_ext_attr_entry *small_entry = NULL;
+		struct ext2_attr_info i = {
+			.value = NULL,
+			.value_len = 0,
+		};
+		unsigned int total_size, shift_bytes, temp = ~0U, extra_isize=0;
+
+		start = (char *) inode + EXT2_GOOD_OLD_INODE_SIZE +
+					inode->i_extra_isize + sizeof(__u32);
+		end = (char *) inode + EXT2_INODE_SIZE(fs->super);
+		last = (struct ext2_ext_attr_entry *) start;
+
+		/* Find the entry best suited to be pushed into EA block */
+		entry = NULL;
+		for (; !EXT2_EXT_IS_LAST_ENTRY(last);
+			last = EXT2_EXT_ATTR_NEXT(last)) {
+			total_size = EXT2_EXT_ATTR_SIZE(last->e_value_size) +
+					EXT2_EXT_ATTR_LEN(last->e_name_len);
+			if (total_size <= free && total_size < temp) {
+				if (total_size < new_extra_isize) {
+					small_entry = last;
+				} else {
+					entry = last;
+					temp = total_size;
+				}
+			}
+		}
+
+		if (entry == NULL) {
+			if (small_entry) {
+				entry = small_entry;
+			} else {
+				if (!tried_min_extra_isize &&
+				    s_min_extra_isize) {
+					tried_min_extra_isize++;
+					new_extra_isize = s_min_extra_isize;
+					goto retry;
+				}
+				if (ret)
+					*ret = EXT2_EXPAND_EISIZE_NOSPC;
+				error = EXT2_ET_EA_NO_SPACE;
+				goto cleanup;
+			}
+		}
+		offs = entry->e_value_offs;
+		size = entry->e_value_size;
+		entry_size = EXT2_EXT_ATTR_LEN(entry->e_name_len);
+		i.name_index = entry->e_name_index;
+		error = ext2fs_get_mem(size, &buffer);
+		if (error)
+			goto cleanup;
+		error = ext2fs_get_mem(entry->e_name_len + 1, &b_entry_name);
+		if (error)
+			goto cleanup;
+		/* Save the entry name and the entry value */
+		memcpy((char *)buffer, (char *) start + offs,
+		       EXT2_EXT_ATTR_SIZE(size));
+		memcpy((char *)b_entry_name, (char *)entry->e_name,
+		       entry->e_name_len);
+		b_entry_name[entry->e_name_len] = '\0';
+		i.name = b_entry_name;
+
+		error = ext2fs_attr_ibody_find(fs, inode, &i, &is);
+		if (error)
+			goto cleanup;
+
+		error = ext2fs_attr_set_entry(fs, &i, &is.s);
+		if (error)
+			goto cleanup;
+
+		entry = (struct ext2_ext_attr_entry *) start;
+		if (entry_size + EXT2_EXT_ATTR_SIZE(size) >= new_extra_isize)
+			shift_bytes = new_extra_isize;
+		else
+			shift_bytes = entry_size + EXT2_EXT_ATTR_SIZE(size);
+		ext2fs_attr_shift_entries(entry, inode->i_extra_isize -
+			shift_bytes, (char *)inode +
+			EXT2_GOOD_OLD_INODE_SIZE + extra_isize + shift_bytes,
+			(char *)start - sizeof(__u32), total_ino - entry_size);
+
+		extra_isize += shift_bytes;
+		new_extra_isize -= shift_bytes;
+		if (needed_size)
+			*needed_size = new_extra_isize;
+		inode->i_extra_isize = extra_isize;
+
+		i.name = b_entry_name;
+		i.value = buffer;
+		i.value_len = size;
+		error = ext2fs_attr_block_find(fs, (struct ext2_inode *) inode,
+					       &i, &bs);
+		if (error)
+			goto cleanup;
+
+		/* Add entry which was removed from the inode into the block */
+		error = ext2fs_attr_block_set(fs, (struct ext2_inode *) inode,
+					      &i, &bs);
+		if (error)
+			goto cleanup;
+	}
+
+write_inode:
+	error = ext2fs_write_inode_full(fs, ino, (struct ext2_inode *) inode,
+					EXT2_INODE_SIZE(fs->super));
+cleanup:
+	if (inode_buf)
+		ext2fs_free_mem(&inode_buf);
+	if (block_buf)
+		ext2fs_free_mem(&block_buf);
+	if (buffer)
+		ext2fs_free_mem(&buffer);
+	if (b_entry_name)
+		ext2fs_free_mem(&b_entry_name);
+
+	return error;
+}
e2fsck/unix.c +55 -0

73 lines not on this page · raw message

lib/ext2fs/ext2_ext_attr.h +29 -0
Index: e2fsprogs-1.40.5/lib/ext2fs/ext2_ext_attr.h
===================================================================
@@ -15,6 +15,9 @@
 /* Maximum number of references to one attribute block */
 #define EXT2_EXT_ATTR_REFCOUNT_MAX	1024
 
+#define XATTR_CREATE    0x1     /* set value, fail if attr already exists */
+#define XATTR_REPLACE   0x2     /* set value, fail if attr does not exist */
+
 struct ext2_ext_attr_header {
 	__u32	h_magic;	/* magic number for identification */
 	__u32	h_refcount;	/* reference count */
@@ -35,6 +38,32 @@ struct ext2_ext_attr_entry {
 #endif
 };
 
+#define BHDR(block) ((struct ext2_ext_attr_header *) block)
+#define IHDR(inode)			   	\
+	((__u32 *) ((char *)inode +	     	\
+		    EXT2_GOOD_OLD_INODE_SIZE +  \
+		    (inode)->i_extra_isize))
+#define ENTRY(ptr) ((struct ext2_ext_attr_entry *)(ptr))
+
+/* Name indexes */
+#define EXT2_ATTR_INDEX_USER		    	1
+#define EXT2_ATTR_INDEX_POSIX_ACL_ACCESS	2
+#define EXT2_ATTR_INDEX_POSIX_ACL_DEFAULT	3
+#define EXT2_ATTR_INDEX_TRUSTED			4
+#define EXT2_ATTR_INDEX_LUSTRE			5
+#define EXT2_ATTR_INDEX_SECURITY		6
+#define EXT2_ATTR_INDEX_MAX			7
+
+#define EXT2_ATTR_INDEX_USER_PREFIX		 "user."
+#define EXT2_ATTR_INDEX_POSIX_ACL_ACCESS_PREFIX	 "system.posix_acl_access"
+#define EXT2_ATTR_INDEX_POSIX_ACL_DEFAULT_PREFIX "system.posix_acl_default"
+#define EXT2_ATTR_INDEX_TRUSTED_PREFIX		 "trusted."
+#define EXT2_ATTR_INDEX_LUSTRE_PREFIX		 "lustre."
+#define EXT2_ATTR_INDEX_SECURITY_PREFIX		 "security."
+
+#define EXT2_ATTR_PREFIX(index) (index ## _PREFIX)
+#define EXT2_ATTR_PREFIX_LEN(index) (index ## _PRE_LEN)
+
 #define EXT2_EXT_ATTR_PAD_BITS		2
 #define EXT2_EXT_ATTR_PAD		((unsigned) 1<<EXT2_EXT_ATTR_PAD_BITS)
 #define EXT2_EXT_ATTR_ROUND		(EXT2_EXT_ATTR_PAD-1)
e2fsck/e2fsck.h +10 -0
Index: e2fsprogs-1.40.5/e2fsck/e2fsck.h
===================================================================
@@ -173,6 +173,7 @@ struct resource_track {
 #define E2F_FLAG_RESTARTED	0x0200 /* E2fsck has been restarted */
 #define E2F_FLAG_RESIZE_INODE	0x0400 /* Request to recreate resize inode */
 #define E2F_FLAG_GOT_DEVSIZE	0x0800 /* Device size has been fetched */
+#define E2F_FLAG_EXPAND_EISIZE	0x2000 /* Expand the inodes (i_extra_isize) */
 
 /*
  * Defines for indicating the e2fsck pass number
@@ -350,6 +351,15 @@ struct e2fsck_struct {
 	profile_t	profile;
 	int blocks_per_page;
 
+	/* Expand large inodes to atleast these many bytes */
+	int want_extra_isize;
+	/* minimum i_extra_isize found in used inodes. Should not be lesser
+	 * than s_min_extra_isize.
+	 */
+	__u32 min_extra_isize;
+	int fs_unexpanded_inodes;
+	ext2fs_inode_bitmap expand_eisize_map;
+
 	/*
 	 * For the use of callers of the e2fsck functions; not used by
 	 * e2fsck functions themselves.
lib/ext2fs/ext2_fs.h +8 -0
Index: e2fsprogs-1.40.5/lib/ext2fs/ext2_fs.h
===================================================================
@@ -404,10 +404,17 @@ struct ext2_inode_large {
 	__u32	i_atime_extra;	/* extra Access time (nsec << 2 | epoch) */
 	__u32	i_crtime;	/* File creation time */
 	__u32	i_crtime_extra;	/* extra File creation time (nsec << 2 | epoch)*/
+	__u32   i_version_hi;   /* high 32 bits for 64-bit version */
 };
 
 #define i_size_high	i_dir_acl
 
+#define EXT2_FITS_IN_INODE(inode, field)		\
+	((offsetof(struct ext2_inode_large, field) +	\
+	 sizeof((inode)->field)) <=			\
+	 		 (EXT2_GOOD_OLD_INODE_SIZE +	\
+	     		  (inode)->i_extra_isize))	\
+
 #if defined(__KERNEL__) || defined(__linux__)
 #define i_reserved1	osd1.linux1.l_i_reserved1
 #define i_frag		osd2.linux2.l_i_frag
@@ -634,6 +641,7 @@ struct ext2_super_block {
 #define EXT2_FEATURE_RO_COMPAT_SUPP	(EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
 					 EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
 					 EXT4_FEATURE_RO_COMPAT_DIR_NLINK| \
+					 EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE| \
 					 EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
 
 /*
e2fsck/pass1.c +192 -7

250 lines not on this page · raw message

lib/ext2fs/ext2fs.h +17 -0
Index: e2fsprogs-1.40.5/lib/ext2fs/ext2fs.h
===================================================================
@@ -406,6 +406,12 @@ typedef struct ext2_icount *ext2_icount_
 #define EXT2_CHECK_MAGIC(struct, code) \
 	  if ((struct)->magic != (code)) return (code)
 
+/*
+ * Flags for returning status of ext2fs_expand_extra_isize()
+ */
+#define EXT2_EXPAND_EISIZE_UNSAFE	0x0001
+#define EXT2_EXPAND_EISIZE_NEW_BLOCK 	0x0002
+#define EXT2_EXPAND_EISIZE_NOSPC	0x0004
 
 /*
  * For ext2 compression support
@@ -450,6 +456,7 @@ typedef struct ext2_icount *ext2_icount_
 #define EXT2_LIB_FEATURE_RO_COMPAT_SUPP	(EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|\
 					 EXT2_FEATURE_RO_COMPAT_LARGE_FILE|\
 					 EXT4_FEATURE_RO_COMPAT_DIR_NLINK|\
+					 EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE| \
 					 EXT4_FEATURE_RO_COMPAT_GDT_CSUM)
 
 /*
@@ -725,6 +732,16 @@ extern errcode_t ext2fs_expand_dir(ext2_
 /* ext_attr.c */
 extern __u32 ext2fs_ext_attr_hash_entry(struct ext2_ext_attr_entry *entry,
 					void *data);
+int ext2fs_attr_get_next_attr(struct ext2_ext_attr_entry *entry, int name_index,
+			      char *buffer, int buffer_size, int start);
+errcode_t ext2fs_attr_set(ext2_filsys fs, ext2_ino_t ino,
+			  struct ext2_inode *inode,
+			  int name_index, const char *name, const char *value,
+			  int value_len, int flags);
+extern errcode_t ext2fs_expand_extra_isize(ext2_filsys fs, ext2_ino_t ino,
+					   struct ext2_inode_large *inode,
+					   int new_extra_isize, int *ret,
+					   int *needed_size);
 extern errcode_t ext2fs_read_ext_attr(ext2_filsys fs, blk_t block, void *buf);
 extern errcode_t ext2fs_write_ext_attr(ext2_filsys fs, blk_t block,
 				       void *buf);
e2fsck/problem.h +32 -0
Index: e2fsprogs-1.40.5/e2fsck/problem.h
===================================================================
@@ -212,6 +212,16 @@ struct problem_context {
 /* Last group block bitmap is uninitialized. */
 #define PR_0_BB_UNINIT_LAST			0x000039
 
+/* Invalid s_min_extra_isize */
+#define PR_0_MIN_EXTRA_ISIZE_INVALID		0x00003A
+
+/* Invalid s_want_extra_isize */
+#define PR_0_WANT_EXTRA_ISIZE_INVALID		0x00003B
+
+/* Clear EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE flag */
+#define PR_0_CLEAR_EXTRA_ISIZE			0x00003C
+
+
 /*
  * Pass 1 errors
  */
@@ -498,6 +508,25 @@ struct problem_context {
 /* extent/index was modified & repaired - not really a problem */
 #define PR_1_EXTENT_CHANGED		0x010067
 
+/* Warning for user that all inodes need to be expanded atleast by
+ * s_min_extra_isize
+ */
+#define PR_1_EXPAND_EISIZE_WARNING	0x010068
+
+/* Expand the inode */
+#define PR_1_EXPAND_EISIZE		0x010069
+
+/* Delete an EA so that EXTRA_ISIZE may be enabled */
+#define PR_1_EISIZE_DELETE_EA		0x01006A
+
+/* An EA needs to be deleted by e2fsck is being run with -p or -y */
+#define PR_1_EA_BLK_NOSPC		0x01006B
+
+/* Disable EXTRA_ISIZE feature as inode cannot be expanded
+ * without deletion of an EA
+ */
+#define PR_1_CLEAR_EXTRA_ISIZE		0x01006C
+
 /*
  * Pass 1b errors
  */
@@ -961,6 +990,9 @@ struct problem_context {
 /* Inode in use but group is marked INODE_UNINIT */
 #define PR_5_INODE_UNINIT		0x050019
 
+/* Expand the inodes which need a new EA block */
+#define PR_5_EXPAND_EISIZE		0x05001a
+
 /*
  * Post-Pass 5 errors
  */
e2fsck/problem.c +50 -0

68 lines not on this page · raw message

e2fsck/e2fsck.c +1 -0
Index: e2fsprogs-1.40.5/e2fsck/e2fsck.c
===================================================================
@@ -151,6 +151,7 @@ errcode_t e2fsck_reset_context(e2fsck_t 
 	ctx->fs_tind_count = 0;
 	ctx->fs_fragmented = 0;
 	ctx->large_files = 0;
+	ctx->fs_unexpanded_inodes = 0;
 
 	/* Reset the superblock to the user's requested value */
 	ctx->superblock = ctx->use_superblock;
e2fsck/pass5.c +36 -0
Index: e2fsprogs-1.40.5/e2fsck/pass5.c
===================================================================
@@ -64,6 +64,42 @@ void e2fsck_pass5(e2fsck_t ctx)
 	ext2fs_free_block_bitmap(ctx->block_found_map);
 	ctx->block_found_map = 0;
 
+	if (ctx->flags & E2F_FLAG_EXPAND_EISIZE) {
+		int min_extra_isize;
+
+		if (!ctx->expand_eisize_map)
+			goto set_min_extra_isize;
+
+		for (pctx.ino = 1; pctx.ino < ctx->fs->super->s_inodes_count;
+		     pctx.ino++) {
+			if (ext2fs_test_inode_bitmap(ctx->expand_eisize_map,
+			    pctx.ino)) {
+				fix_problem(ctx, PR_5_EXPAND_EISIZE, &pctx);
+				ext2fs_expand_extra_isize(ctx->fs, pctx.ino, 0,
+							  ctx->want_extra_isize,
+							  NULL, NULL);
+			}
+		}
+		ext2fs_free_inode_bitmap(ctx->expand_eisize_map);
+
+set_min_extra_isize:
+		if (ctx->fs->super->s_min_extra_isize)
+			min_extra_isize = ctx->fs->super->s_min_extra_isize;
+		else
+			min_extra_isize = ctx->want_extra_isize;
+		if (ctx->min_extra_isize >= min_extra_isize &&
+		    !ctx->fs_unexpanded_inodes) {
+			ctx->fs->super->s_min_extra_isize =ctx->min_extra_isize;
+			ctx->fs->super->s_feature_ro_compat |=
+					EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE;
+		} else {
+			ctx->fs->super->s_min_extra_isize = 0;
+			ctx->fs->super->s_feature_ro_compat &=
+					~EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE;
+		}
+		ext2fs_mark_super_dirty(ctx->fs);
+	}
+
 #ifdef RESOURCE_TRACK
 	if (ctx->options & E2F_OPT_TIME2) {
 		e2fsck_clear_progbar(ctx);
lib/ext2fs/ext2_err.et.in +24 -0
Index: e2fsprogs-1.40.5/lib/ext2fs/ext2_err.et.in
===================================================================
@@ -338,5 +338,29 @@ ec	EXT2_ET_EXTENT_LEAF_BAD,
 ec	EXT2_ET_EXTENT_NO_SPACE,
 	"No free space in extent map"
 
+ec	EXT2_ET_EA_BAD_MAGIC,
+	"Extended attribute block has bad magic value"
+
+ec	EXT2_ET_EA_BAD_ENTRIES,
+	"Extended attribute block has bad entries"
+
+ec	EXT2_ET_EA_NO_SPACE,
+	"No free space for extended attribute"
+
+ec	EXT2_ET_EA_TOO_BIG,
+	"Extended attribute too big for buffer"
+
+ec	EXT2_ET_EA_NAME_TOO_BIG,
+	"Extended attribute name too big for header"
+
+ec	EXT2_ET_EA_BAD_NAME,
+	"Extended attribute name is bad"
+
+ec	EXT2_ET_EA_NAME_NOT_FOUND,
+	"Extended attribute name not found"
+
+ec	EXT2_ET_EA_NAME_EXISTS,
+	"Extended attribute name already exists"
+
 	end
 

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#23 lore raw

Re: [PATCH][14/28] e2fsprogs-tests-f_expisize_ea_del.patch

In reply to Andreas Dilger

Test case for expanding inode size where there is not enough room for the requested new inode size. Prompt user to delete one or more EAs (default is to abort).

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

Test case for expanding inode size where there is not enough room for the requested new inode size. Prompt user to delete one or more EAs (default is to abort).

tests/f_expisize_ea_del/expect.1 new file +10 -0
Index: e2fsprogs-1.39/tests/f_expisize_ea_del/expect.1
===================================================================
@@ -0,0 +1,10 @@
+Adding dirhash hint to filesystem.
+
+Pass 1: Checking inodes, blocks, and sizes
+Expanding inode 12.
+An EA needs to be deleted for inode 12 but e2fsck is being run
+with -p or -y mode.
+Abort? yes
+
+e2fsck: aborted
+Exit status is 8
tests/f_expisize_ea_del/expect.2 new file +11 -0
Index: e2fsprogs-1.39/tests/f_expisize_ea_del/expect.2
===================================================================
@@ -0,0 +1,11 @@
+Adding dirhash hint to filesystem.
+
+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: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 12/2048 files (8.3% non-contiguous), 2106/8192 blocks
+Exit status is 1
tests/f_expisize_ea_del/name new file +1 -0
Index: e2fsprogs-1.39/tests/f_expisize_ea_del/name
===================================================================
@@ -0,0 +1 @@
+EA needs deletion but running in -p or -y mode
tests/f_expisize_ea_del/script new file +4 -0
Index: e2fsprogs-1.39/tests/f_expisize_ea_del/script
===================================================================
@@ -0,0 +1,4 @@
+FSCK_OPT="-fy -E expand_extra_isize"
+SECOND_FSCK_OPT=-yf
+
+. $cmd_dir/run_e2fsck

*** /dev/null 2007-06-06 13:12:35.347432049 +0530
--- e2fsprogs-1.39/tests/f_expisize_ea_del/image.gz 2007-06-06 15:58:17.000000000 +0530
***************
*** 0 ****
--- 1,5 ----
+ ���fFimage�� �Tu��7��"��
+ **("�(�h��Rڡ�.��"`^��D�fy�yV�yTfdey����y�]�G�g%������#��|��";og�7�g��yoע�V�ԫ(�)��]�bQUQ��_ޫ�l��1��Rѧ�l�~�v�s�����6}^ۺwE1�����s��k�����:vި���ά�ܻ�d����q���'�����.������[T��e��JCӰ4<m��I#�ȴmղ��u����ީO�[ԍ�EUv eh1u�C�(�؛�����?(�/|펩Ӕg����輫lx��i��EE���V�7���C��}n� ��\v�_*�{�׽y����x��K���v���n�<��ӖiH�* M���u�&�H#ӶiTK�`eus��?����_Eѭ�v��|ôQ�����&i@�4 L�U�M'�����ϊu����������_���R��a,����_�7���/k����:����ul�����WP3���S�:�v����qoy��u��F��63�N�~o�ͬ��\��ߦ�n3�hUz�h�MMm�� 3�|4���i�kgL�i�U]3���mm����>��V�������wE����m��KѦbj��ٛ��2��x�E�RMm����K��E-�?P&*�0��0��0��0��0��x�h���2�JU�uZ-�)��G�(VOk���C�:��E��
+ Śi��5uKk��G��I��R���]+��� ?��@e����2��lr�5ύ�?g��{;oTu���w�׍�o���&�U4ֿ��� �W6�^�n�*�#�ۗ���2ֻ�~��;�.����3��w����15c�j��wk���E�a�(�K���i�4 m���Ҡ��x�C+֥s�u�7�pI�h���������/�6��r[v�S��0�-3�[,1���G��_���?��Wy;�?V�|�|N���{@iv���[<��w|V5u'��*�s2���Z/T-�$Ы�l��1u��>��gK��տ^���K�e�6��0�h8�����9o�=��r�^��λ�ơc{�|[��w�����fw��~lQY�ӖiH�* M���u�&�H#ӶiT�����'�__��+k͏�m�Ž�U<աT]�lܱ��&�_}@ͤ'O9h���3<R�\�}Z;mzm�N��4:m�vHH;�1i��s��vI�����i�4.��J�Ӈ҇��i���������o�/}"}2}*MH���:�jҤt`�������4-MO�iF:8�L���tH�t:4�OG�#�g�Q���4'�MǤcӼ��4?}>��O'��I��tJ:5}!������NOg�3�Y��tN:7�����O_I� �E��tI�4}5}-}=]�.OW�+�U���tM�6]��O�L�J�N7���wӂ��tS�~�A�a�9�(�8ݒnM������tW�I�i�;ݓ~��M������/��������P�uz8=�M��ߤ��������0�>�!�1�)�9=������NϤg�s�o�����(��^L/���+��������ZZ���o�T�Z���2�JU�uZ-�ImS��zZ#�OR��)uN]Қi��5uKk��G��I��R��~����i��a�(�K���i�4 m���Ҡ�y�" N[�!i�44 K���i�4"�L۶|}�_Ѹ���������Z�+�o�_^��A+���ci�[^~p�e�o���2Z���k6�7�|��-�������<�����ߩ�ﭷ�U�K]��6�W�y�ۘ��4�l����������<��ۛ�7��+�����/3?�T��fR��{8�oe4@�������ӻx�{�S�a�����Uf���R���wq�?�����8����y"`�X�?����������2S�T��y��g柸���K��_���˗� 5NK�_�Do{ �a����U���f���n|]y��?X����-o�s��d�����R��������\���9�W���9��w����?�����W��N���Ks^����m����"��������wk�?������� P���6��P����7�������o[?;y�u��X˿MK,ۛ-&-������Z��k�_���{(��[�(���!�W_�����JU4]�ݞ��uTׯ��'5[5|��X�������+���������m�(��;�(�������������_��=�Z�~B��W���ŭ����c�?�������(����_�ހ��k�P�㿽�e;�;�P�㿣�e9��wtr���7��ya�u}���9�g��v����75`���n;�������a��z��9vZ|����?�7z��7z[ǣ��m�����z��Y����s������NF����s�:���e�����7��O7������JOͷ����8a�
+ x-�ݛ�w6�,��u㿋�e;�״7�l��Z�����jo@Y����;�9�����^0�K_ZUjW�j����a �96w^�*x^�LJ
+ ��:�� ������?���r>���h��}�om{�v�w�7�l�{�v���7�l��:���o��E1�UQl_e_@���}�!} �Ƥ����il�%�vK��=Ҹ�g�+�OJN{�}�G�G����Ӿi������4!ML���t@�I�ҁir��JSӴ4=զ��43�J��!����tX:<��L�IG�Ϧ�Ӝ47��M�������t\:>��NL'���)���tZ�b�R:=���Lg���9��t^�r:?}%]�.L���%��������tY�<]��LW���7�5��t]�>}3}+};ݐ��nL�M ���M����������tK�5ݖnOw�;�]�'���tO�Y�7ݗ~��O�H��/ӯ�C�����Hz4=�~�OO�ߦ'��������������T�K�kz:=��Mϥ�����Ӣ�Bz1��^N��W�?�?ӿ�kiq*�u��*R�T�Z�V�*�N��6�mj�VOk���C�:�ΩKZ3����ni��=�H=�:iݴ^��O�S��7m�6L�~��8m��M���Y�6O[��i�4$m���aix�:m�F��i�4*m������[��i�4&�vNLc�.i״[�=�ƥ=�^i|�P�p�;�>�>�>�>��M��O�O�O� ib�?U�RM��L�ӔtP�����6�H��iV��I�N������td�L:*}6�椹�tl��>��ϧ����tb:)��NI��/���ӗ���tf:+���I��җ���+�ta�(]�.I������������te�*]����Iצ�����[�����tc�nZ���nJ�O?H?L7���[ҭ�t{�#ݙ�J?I?Mw�{��ҽ���t�Ez =�~�~�J�N�Gң����xz"�6=�~��ߧ?�?�?�?���_�_����lz.�-�==��ҋ��rz%��������^K�SQU�T�Z���2�JU�uZ-�ImS��zZ#�OR��)uN]Қi��5uKk��G��I��R��~����i��a�(�K���i�4 m���Ҡ�y�" N[�!i�44 K���i�4"�LۦQi�4��������i�4&�vNLc�.i״[�=�ƥ=�^i|�P�p�;�>�>�>�>��M��O�O�O� ib�?U�RM��L�ӔtP�����6�H��iV��I�N������td�L:*}6�椹�tl��>��ϧ����tb:)��NI��/���ӗ���tf:+���I��җ���+�ta�(]�.I������������te�*]����Iצ�����[�����tc�nZ���nJ�O?H?L7���[ҭ�t{�#ݙ�J?I?Mw�{��ҽ���t�Ez =�~�~�J�N�Gң����xz"�6=�~��ߧ?�?�?�?���_�_����lz.�-�==��ҋ��rz%��������^K�SѺ(J�"�H��ej��R�Zj�ڦvi��Fj�:���SꜺ�5�Z�k��N�S��3���M�^i��;�I}�iôQ�����&i@�4 L��Ai�E��LC�Vihk�i�ʪ�R��u��u{,}iU�]E�﫧) �VS[;q��͋[�}|d����'N���5��<堩�j�Ϩ�T]�6s��X��]�u�M��5v�mgU�4�5}Jѿ�����������4�)�.�Z�w�]��������T��`\顊��8�ۓ]����;���w���������_��=�Z�~B��W��ۻ|�o�/��}�]��Ӧ�ΘT��ٍ��m޾f�^S�Ľ�.��7��%?ٓen��;����������8��ȝ�
\ No newline at end of file

#24 lore raw

Re: [PATCH][15/28] e2fsprogs-ibadness-counter.patch

In reply to Andreas Dilger

The present e2fsck code checks the inode, per field basis. It doesn't take into consideration to total sanity of the inode. This may cause e2fsck turning a garbage inode into an apparently sane inode ("It is a vessel of fertilizer, and none may abide its strength.").

The following patch adds a heuristics to detect the degree of badness of an inode. icount mechanism is used to keep track of the badness of every inode. The badness is increased as various fields in inode are found to be corrupt. Badness above a certain threshold value results in deletion of the inode. The default threshold value is 7, it can be specified to e2fsck using "-E inode_badness_threshold=<value>"

This can avoid lengthy pass1b shared block processing, where a corrupt chunk of the inode table has resulted in a bunch of garbage inodes suddenly having shared blocks with a lot of good inodes (or each other).

e2fsck/e2fsck.h +18 -1
Index: e2fsprogs-1.40.4/e2fsck/e2fsck.h
===================================================================
@@ -11,6 +11,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <stddef.h>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
@@ -195,6 +196,18 @@ typedef enum {
 	E2F_CLONE_ZERO
 } clone_opt_t;
 
+#define EXT4_FITS_IN_INODE(ext4_inode, einode, field)	\
+	((offsetof(typeof(*ext4_inode), field) +	\
+	  sizeof(ext4_inode->field))			\
+	<= (EXT2_GOOD_OLD_INODE_SIZE +			\
+	    (einode)->i_extra_isize))			\
+
+#define BADNESS_NORMAL 		1
+#define BADNESS_HIGH		2
+#define BADNESS_THRESHOLD	8
+#define BADNESS_BAD_MODE	100
+#define BADNESS_LARGE_FILE 	2199023255552ULL
+
 /*
  * Define the extended attribute refcount structure
  */
@@ -229,7 +242,6 @@ struct e2fsck_struct {
 			unsigned long max);
 
 	ext2fs_inode_bitmap inode_used_map; /* Inodes which are in use */
-	ext2fs_inode_bitmap inode_bad_map; /* Inodes which are bad somehow */
 	ext2fs_inode_bitmap inode_dir_map; /* Inodes which are directories */
 	ext2fs_inode_bitmap inode_bb_map; /* Inodes which are in bad blocks */
 	ext2fs_inode_bitmap inode_imagic_map; /* AFS inodes */
@@ -244,6 +256,8 @@ struct e2fsck_struct {
 	 */
 	ext2_icount_t	inode_count;
 	ext2_icount_t inode_link_info;
+	ext2_icount_t inode_badness;
+	int inode_badness_threshold;
 
 	ext2_refcount_t	refcount;
 	ext2_refcount_t refcount_extra;
@@ -344,6 +358,7 @@ struct e2fsck_struct {
 	/* misc fields */
 	time_t now;
 	time_t time_fudge;	/* For working around buggy init scripts */
+	time_t now_tolerance_val;
 	int ext_attr_ver;
         shared_opt_t shared;
         clone_opt_t clone;
@@ -454,6 +469,8 @@ extern int e2fsck_pass1_check_device_ino
 					   struct ext2_inode *inode);
 extern int e2fsck_pass1_check_symlink(ext2_filsys fs,
 				      struct ext2_inode *inode, char *buf);
+extern void e2fsck_mark_inode_bad(e2fsck_t ctx, ino_t ino, int count);
+extern int is_inode_bad(e2fsck_t ctx, ino_t ino);
 
 /* pass2.c */
 extern int e2fsck_process_bad_inode(e2fsck_t ctx, ext2_ino_t dir,
e2fsck/pass1.c +117 -38

340 lines not on this page · raw message

e2fsck/pass4.c +1 -0
Index: e2fsprogs-1.40.4/e2fsck/pass4.c
===================================================================
@@ -185,6 +185,7 @@ void e2fsck_pass4(e2fsck_t ctx)
 	}
 	ext2fs_free_icount(ctx->inode_link_info); ctx->inode_link_info = 0;
 	ext2fs_free_icount(ctx->inode_count); ctx->inode_count = 0;
+	ext2fs_free_icount(ctx->inode_badness); ctx->inode_badness = 0;
 	ext2fs_free_inode_bitmap(ctx->inode_bb_map);
 	ctx->inode_bb_map = 0;
 	ext2fs_free_inode_bitmap(ctx->inode_imagic_map);
e2fsck/pass2.c +63 -20

182 lines not on this page · raw message

e2fsck/problem.c +5 -0
Index: e2fsprogs-1.40.4/e2fsck/problem.c
===================================================================
@@ -1316,6 +1316,11 @@ static struct e2fsck_problem problem_tab
 	  N_("@i %i found in @g %g unused inodes area.  "),
 	  PROMPT_FIX, PR_PREEN_OK },
 
+	/* Inode too bad */
+	{ PR_2_INODE_TOOBAD,
+	  N_("@i %i is badly corrupt (badness value = %N).  "),
+	  PROMPT_CLEAR, PR_PREEN_OK },
+
 	/* Pass 3 errors */
 
 	/* Pass 3: Checking directory connectivity */
e2fsck/problem.h +3 -0
Index: e2fsprogs-1.40.4/e2fsck/problem.h
===================================================================
@@ -792,6 +792,9 @@ struct problem_context {
 /* Inode found in group unused inodes area */
 #define PR_2_INOREF_IN_UNUSED		0x020046
 
+/* Inode completely corrupt */
+#define PR_2_INODE_TOOBAD		0x020047
+
 /*
  * Pass 3 errors
  */
lib/ext2fs/icount.c +18 -0
Index: e2fsprogs-1.40.4/lib/ext2fs/icount.c
===================================================================
@@ -462,6 +462,23 @@ static errcode_t get_inode_count(ext2_ic
 	return 0;
 }
 
+int ext2fs_icount_is_set(ext2_icount_t icount, ext2_ino_t ino)
+{
+	__u16 result;
+
+	if (ext2fs_test_inode_bitmap(icount->single, ino))
+		return 1;
+	else if (icount->multiple) {
+		if (ext2fs_test_inode_bitmap(icount->multiple, ino))
+			return 1;
+		return 0;
+	}
+	ext2fs_icount_fetch(icount, ino, &result);
+	if (result)
+		return 1;
+	return 0;
+}
+
 errcode_t ext2fs_icount_validate(ext2_icount_t icount, FILE *out)
 {
 	errcode_t	ret = 0;
@@ -501,6 +518,7 @@ errcode_t ext2fs_icount_fetch32(ext2_ico
 		*ret = 0;
 		return 0;
 	}
+
 	get_inode_count(icount, ino, ret);
 	return 0;
 }
e2fsck/pass1b.c +2 -2
Index: e2fsprogs-1.40.4/e2fsck/pass1b.c
===================================================================
@@ -613,8 +613,8 @@ static void delete_file(e2fsck_t ctx, ex
 		fix_problem(ctx, PR_1B_BLOCK_ITERATE, &pctx);
 	ext2fs_unmark_inode_bitmap(ctx->inode_used_map, ino);
 	ext2fs_unmark_inode_bitmap(ctx->inode_dir_map, ino);
-	if (ctx->inode_bad_map)
-		ext2fs_unmark_inode_bitmap(ctx->inode_bad_map, ino);
+ 	if (ctx->inode_badness)
+ 		e2fsck_mark_inode_bad(ctx, ino, 0);
 	ext2fs_inode_alloc_stats2(fs, ino, -1, LINUX_S_ISDIR(inode.i_mode));
 
 	/* Inode may have changed by block_iterate, so reread it */
e2fsck/unix.c +16 -0
Index: e2fsprogs-1.40.4/e2fsck/unix.c
===================================================================
@@ -624,6 +624,18 @@ static void parse_extended_opts(e2fsck_t
 				extended_usage++;
 				continue;
 			}
+		/* -E inode_badness_threshold=<value> */
+ 		} else if (strcmp(token, "inode_badness_threshold") == 0) {
+ 			if (!arg) {
+ 				extended_usage++;
+ 				continue;
+ 			}
+ 			ctx->inode_badness_threshold = strtoul(arg, &p, 0);
+			if (*p != '\0' || (ctx->inode_badness_threshold > 200)){
+				fprintf(stderr, _("Invalid badness value.\n"));
+				extended_usage++;
+				continue;
+			}
 		} else {
 			fprintf(stderr, _("Unknown extended option: %s\n"),
 				token);
@@ -639,6 +646,7 @@ static void parse_extended_opts(e2fsck_t
 		       "\tshared=<preserve|lost+found|delete>\n"
 		       "\tclone=<dup|zero>\n"
 		       "\tea_ver=<ea_version (1 or 2)>\n"
+ 		       "\tinode_badness_threhold=(value)\n"
  		       "\texpand_extra_isize\n"
 		       "\n"), stderr);
 		exit(1);
@@ -703,6 +711,9 @@ static errcode_t PRS(int argc, char *arg
 	profile_init(config_fn, &ctx->profile);
 	initialize_profile_options(ctx);
 
+	ctx->inode_badness_threshold = BADNESS_THRESHOLD;
+	ctx->now_tolerance_val = 172800; /* Two days */
+
 	while ((c = getopt (argc, argv, "panyrcC:B:dE:fvtFVM:b:I:j:P:l:L:N:SsDk")) != EOF)
 		switch (c) {
 		case 'C':
e2fsck/e2fsck.c +0 -4
Index: e2fsprogs-1.40.4/e2fsck/e2fsck.c
===================================================================
@@ -105,10 +105,6 @@ errcode_t e2fsck_reset_context(e2fsck_t 
 		ext2fs_free_inode_bitmap(ctx->inode_bb_map);
 		ctx->inode_bb_map = 0;
 	}
-	if (ctx->inode_bad_map) {
-		ext2fs_free_inode_bitmap(ctx->inode_bad_map);
-		ctx->inode_bad_map = 0;
-	}
 	if (ctx->inode_imagic_map) {
 		ext2fs_free_inode_bitmap(ctx->inode_imagic_map);
 		ctx->inode_imagic_map = 0;
e2fsck/e2fsck.8.in +7 -0
Index: e2fsprogs-1.40.4/e2fsck/e2fsck.8.in
===================================================================
@@ -191,6 +191,13 @@ in place (preserve); 
 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 inode_badness_threshold= threshold_value
+A badness counter is associated with every inode, which determines the degree
+of inode corruption. Each error found in the inode will increase the badness by
+1 or 2, and inodes with a badness at or above
+.I threshold_value will be prompted for deletion. The default
+.I threshold_value is 7.
 .RE
 .TP
 .B \-f
tests/f_bad_disconnected_inode/expect.1 +4 -10
Index: e2fsprogs-1.40.4/tests/f_bad_disconnected_inode/expect.1
===================================================================
@@ -39,10 +39,7 @@ Clear? yes
 i_blocks_hi for inode 16 (...) is 62762, should be zero.
 Clear? yes
 
-Unattached inode 16
-Connect to /lost+found? yes
-
-Inode 16 ref count is 5925, should be 1.  Fix? yes
+Inode 16 is badly corrupt (badness value = 10).  Clear? yes
 
 Pass 5: Checking group summary information
 Block bitmap differences:  -(9--19)
@@ -54,19 +51,16 @@ Fix? yes
 Free blocks count wrong (79, counted=91).
 Fix? yes
 
-Inode bitmap differences:  +16
-Fix? yes
-
-Free inodes count wrong for group #0 (7, counted=4).
+Free inodes count wrong for group #0 (8, counted=5).
 Fix? yes
 
 Directories count wrong for group #0 (3, counted=2).
 Fix? yes
 
-Free inodes count wrong (7, counted=4).
+Free inodes count wrong (8, counted=5).
 Fix? yes
 
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
-test_filesys: 12/16 files (0.0% non-contiguous), 9/100 blocks
+test_filesys: 11/16 files (0.0% non-contiguous), 9/100 blocks
 Exit status is 1
tests/f_bad_disconnected_inode/expect.2 +1 -1
Index: e2fsprogs-1.40.4/tests/f_bad_disconnected_inode/expect.2
===================================================================
@@ -3,5 +3,5 @@ Pass 2: Checking directory structure
 Pass 3: Checking directory connectivity
 Pass 4: Checking reference counts
 Pass 5: Checking group summary information
-test_filesys: 12/16 files (0.0% non-contiguous), 9/100 blocks
+test_filesys: 11/16 files (0.0% non-contiguous), 9/100 blocks
 Exit status is 0
lib/ext2fs/ext2fs.h +1 -0
Index: e2fsprogs-1.40.4/lib/ext2fs/ext2fs.h
===================================================================
@@ -831,6 +831,7 @@ extern errcode_t ext2fs_initialize(const
 
 /* icount.c */
 extern void ext2fs_free_icount(ext2_icount_t icount);
+extern int ext2fs_icount_is_set(ext2_icount_t icount, ext2_ino_t ino);
 extern errcode_t ext2fs_create_icount_tdb(ext2_filsys fs, char *tdb_dir,
 					  int flags, ext2_icount_t *ret);
 extern errcode_t ext2fs_create_icount2(ext2_filsys fs, int flags, 

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#25 lore raw

Re: [PATCH][16/28] e2fsprogs-tests-f_ibadness.patch

In reply to Andreas Dilger

Test case for bad inode detection, and fixes for old test cases.

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

Test case for bad inode detection, and fixes for old test cases.

tests/f_ibadness/name new file +1 -0
Index: e2fsprogs-1.39/tests/f_ibadness/name
===================================================================
@@ -0,0 +1 @@
+Inode with badness = 8
tests/f_ibadness/expect.1 new file +40 -0
Index: e2fsprogs-1.39/tests/f_ibadness/expect.1
===================================================================
@@ -0,0 +1,40 @@
+Pass 1: Checking inodes, blocks, and sizes
+Inode 13 is in use, but has dtime set.  Fix? yes
+
+Inode 13 has illegal block(s).  Clear? yes
+
+Illegal block #0 (4294967295) in inode 13.  CLEARED.
+Illegal block #1 (4294967295) in inode 13.  CLEARED.
+Inode 13, i_blocks is 3453453, should be 140.  Fix? yes
+
+Pass 2: Checking directory structure
+i_file_acl for inode 13 (/testfile) is 345, should be zero.
+Clear? yes
+
+i_faddr for inode 13 (/testfile) is 34534, should be zero.
+Clear? yes
+
+Inode 13 is badly corrupt (badness value = 9).  Clear? yes
+
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+Block bitmap differences:  -(1368--1369)
+Fix? yes
+
+Free blocks count wrong for group #0 (6823, counted=6825).
+Fix? yes
+
+Free blocks count wrong (14691, counted=14693).
+Fix? yes
+
+Free inodes count wrong for group #0 (2039, counted=2037).
+Fix? yes
+
+Free inodes count wrong (4087, counted=4085).
+Fix? yes
+
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 11/4096 files (9.1% non-contiguous), 1691/16384 blocks
+Exit status is 1
tests/f_ibadness/expect.2 new file +7 -0
Index: e2fsprogs-1.39/tests/f_ibadness/expect.2
===================================================================
@@ -0,0 +1,7 @@
+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: 11/4096 files (9.1% non-contiguous), 1691/16384 blocks
+Exit status is 0

*** /dev/null 2007-06-21 14:46:07.320441196 +0530
--- e2fsprogs-1.39/tests/f_ibadness/image.gz 2007-06-21 15:42:01.000000000 +0530
***************
*** 0 ****
--- 1,27 ----
+ �SKzFimage���]W^`ٻ ;���Zl�Ȓ,��fY^���V1��� S��Y���Xֲ��{�!! ��@I�J*� )��
+ $a!�A�����}e��%�}?�e��n��s��8�[�i<��>�����8pG��N�<p`��&Ͼ��N�=p�U���y������_ʓV����Ϗx(����{_����N���O��/]����Ƽa�W6�� ?������ر����o��͟����?��g/ǿ�D\�x:�o�xs�["�񶈷G<��w�̶;�a�{,�tę������������ǵ:�L�O|r��^n���'^ֱ�z����W��a�z?�?�[����}땮ط&\��ot�þ��ط>������a���?�[���}�C]��o}����w�þ��ط>����G��a��h�?�[���}�c]��o}�����w�þ� �ط>����'��a��d�?�[����}����}�.�?�[�\��o����֧��aߺ����=�ط�u�þ5���}k����a�?�[���a�:���}����c�ط�w�þu���� �?�[��a�z����C�ط^���}�5�ط^���}�u�ط^���}�a�?�[']��o=���}����G]��o����֧��aߚv�þ�[��|��/���1�?د���g�`�l����/M��/?p�#�p����>�/;pgc�3wH�y�}����/���ǁ�|����;v��ں���+��]�y]���t�#��户D�5�mo�x&�3#f�t|w�����J��<��fb��x<≈s��d��� #.E<��������<�o�r�x�W�8���0����/����?p��&_y�M_q�lw̼"�9t��~���A�|�[㫷E�=♈ό������������W���r{~�K�s������X��;�<������8x�roc�k�����݁z�w\[Z�P�ϼ�wlv76�g����0p���e���/� �����?��\���p��������-^V&��x����xe�D���;��>�!�{@|XćG|D�GF|T�GG|L��F|\��G|B�'F|R�'G|JD'⮈C�:��5:p��{"���8q_đ���Մ�#�G�w��x0⡈WG�&���x}��'#�8�h�">-bڡg��ɓ���~���_�(/�!���G?���������_8����������z�dw�1S��L��;��xl\z����O�����c�M?�������� |,
+ �#�D��'�j����'�T x������ɳUTE��mL7%���G<q.��#��8q!�bĥ���P#���~O��7b�U��玗�Z��&�싷[~J�׾h�l���lLw����'��[U���>�{��t��q~��/k�g�2�^���N���_>|��q�7_�?�].??M�_���?���.Ǽ�D\�x:�o�xs�["�񶈷G<��w�������]����;��z�K������z��<k�"^T��x��n��oo����_io���|������)��ϟ�����玴����g����WV7����w�Oý�m���ս������5���"�"�#"#��"�G܈X�xGij�+�����ώX�؈،؊x.�f���"��9�x!�s#>/��#��_�E_�%_�e_�_�U_�5_�u_� ��M��-��m����]��=��{"�/��F������ �F�@�F���?�G"�h�E���?��?�'"�dğ��ш?�g"~,��#�l�OD���?�"~2�/F�T�OG�L�_���%�F�����#�oF�����w"�n��E�����"�a�?����$�F��������"�_F���_����&��F���_����!�?F�����_"~)�#~%�F�����w��#Ҝ�_����?#�W����?�7�7#~뎢�yGĝ/�xy�+"�/"2�^1q0�">0�">8�C">4��"><�#">2�">:�c">6��">>�">1�">9�S":wE�xUħF�qOĽ�S�#�8q4�X���#ND<�`�C��xM�k#^����#NF<q*�ш7D|Z�t�c�#�D�D��x<≈s��d��� #.E<��#�D\�x:�o�xs�["�񶈷G<�烿����r����y�����>����߸���?�n,����_fo����SN%U�3Yz�������������(������}������#<���� {���Yw80���_n_�~3��|�B�bD7�Z���K�x6b9b%b5������[�E܌x>�V�;#>'�]/D|n��E|~Ļ#� � #�(�#�$�K#�,��#�"�+#�*�#�&�k#�.��#�!�#�)�#�%�[#�-��#�#�;#�+�#�'�{#~O��E�ވ����?�D�������?�#�H�����?��#~8�G"�Dğ��S?�#�LďE�xğ����?��#�B�OF�ň���鈟��K9�D�Ո���#~6�oD�͈��#�N�ߍ������#�A�?��G�8�D�ӈ���<�_D�ˈ� �:��D�ۈ��>�?D�Lj��#�K�/E�rįD�׈���#~5�=����#�7"�g������'��F�f�oE���wF�,����x����xe�D�������������Ј�������Ȉ���舏��؈�����O��ĈO���O��D�q(�U�qw�=�FLFLE��/�H�шc�G�8�@ăE�:�5��x]��#�8�Hĩ�G#��i��E��81q6��'"�E|zē�#.D\���T�gD\��q5��7F�)��o�xk��"��L�gF�F|�ˤ����8��э�q=�F�R�;"��X�X�X��E�E|v�z�F�f�V�s7#����ΈωxW� ��y���/��ˆ/���/��҈/��򈯈�ʈ���ꈯ��ڈ�����o��ƈo���o��ֈo������Έ�����ވ��}�7��E|���0�"~0�E��?�G#~(�E������?�'#�TďF��?�c?�g#~"��E�����1�"~:�g"�R�_��+5�E������3�oE�툿�w#~.��E����#�Q�?��'�4�E�|�?���2�_E�BĿ��7�6��E�bĿ���1�?E����K��+�5�E���_�xOįE�z��������"�w�������[^~��wF�,����x����xe�D�������������Ј�������Ȉ���舏��؈�����O��ĈO���O��D�q(�U�qw�=�FLFLE��/�H�шc�G�8�@ăE�:�5��x]��#�8�Hĩ�G#��i��E��81q6��'"�E|zē�#.D\���T�gD\��q5��7F�)��o�xk��"��L�gF�F|V��˥����8�э�q=�F�R�;"��X�X�X��E�E|v�z�F�f�V�s7#����ΈωxW� ��y���/��ˆ/���/��҈/��򈯈�ʈ���ꈯ��ڈ�����o��ƈo���o��ֈo������Έ�����ވ��}�7��E|���0�"~0�E��?�G#~(�E������?�'#�TďF��?�c?�g#~"��E�����1�"~:�g"�R�_��+5�E������3�oE�툿�w#~.��E����#�Q�?��'�4�E�|�?���2�_E�BĿ��7�6��E�bĿ���1�?E����K��+�5�E���_�xOįE�z��������"�w�������[^q��wF�,����x����xe�D�������������Ј�������Ȉ���舏��؈�����O��ĈO���O��D�q(�U�qw�=�FLFLE��/�H�шc�G�8�@ăE�:�5��x]��#�8�Hĩ�G#��i��E��81q6��'"�E|zē�#.D\���T�gD\��q5��7F���4�}���vw��66N[�=���yՉN�Z������g�lt?{����4���X�[M_m��v�V{������r7�#���ڭ���76;���:'^����?��:�����k;Wot{���n��ƽ�c������^_Z=�Dwn��~w��ꍥ�ε��nge�Vg��Y�..ml�/�omv;[�1a^�����F�j�_|�������B�������F�X^���bs�)�J�����R�ln��{.�>����ލ�_�WZ��[�ݕ�#i&s������奘$�[^��\Z�k����:ݹ��\.�w�h����#�-u���vekc3m�r�����6����K�_���.��V7�l��0;x����]ج~?�Y�ۜ+�����K�ڈ:+�ۋ�s(W��Es������u�� ��1��M^Z��[_��\�66u�3���2��V�捥jgl䵌�+plbb28��f6&��͏����c��f�������[�s��A����j7��v���#P�>>����9�Ҙ���g�2w}i����A���3)�9p����Z���)�y�W�I5�ŭ��|�I�? 듶:�����8��1��z��j��qeml�m���݌$���ۺ~�yv�ݼ1����fQ��)��]�q���]�V����#u����*j�,�`qk=_���j�|9]���s����p����Ngrzy�F/�UL�g����[݈����p�ؚ�������Dop��9�Է�{>�c�������S��un.E6���޳1����׋�an�VlO$[ ���G#�&��d����זV���HVg�\z���8��\�nƮ__]�NN�I_۵���HJ�W���h�ͥ�n�ɵ�c��7���\�|�������뫽<Ywuq����W����؍C�ɟߌO�O���?f�67�ۋ�O�`�"�di��|��{q[I3�V.V�����.�̞}���+�}P~k����8v�r��^�817�U�c����ؘ��x2�o�*q�t�m�=������������q7���]Xݜ�,�L���2N�k��#�<e���w��F7�y����9�����l�ʦN�\�H��Y�N�2���$�Y�z�]�T�"_+��lL:f�����t�m-��NGi6���X�U�6/n�F$����o]����z�+�SF�`���ʄw�����v�ވ[u,�Zc�o��*���1v[g�|���ϸr���٫oyj�=�م��ɔ�l��a.����|>q.�_l����Bl��܈�$���y��?��ÿx}}-fp}���V�θC?���Ȇ�k3]�q۽�34۝W}W�o���%�O��]s$������"��V��b�ؿ ���;�r�em{E��N�D�R�������98Q휸��ϓ'�V�����Fʚ<|"�n#e1����s��������_�=mյ���+�`u�T���e���|ɤ����'b1E:2���R�g��V��ָ�'��b��o��e��[;d��&O;�U��X��z[�����?S:����_���O��Z�[�<G�{��9�܈��(~�_Z�����9����ٴr1Q:�&&�'�Ƀ/�:�e�+g�[�S���*7�1����<3�+�N���)�eg{�͒G����,G֡�;�g�6P�����l����A�L�K�d}㚝�z�C�v��'�;6ޖ� �o�}����OΞ����so�����b�s'��s��ƭw��l��]I9����me�\ M��8jks�E>.2aq�ǚ�oF�"�c�F�e��#r���Ő��<��k9���+��W�^���ZM匩����S�s�b��D[��gh�M��`��Ω��8j�v�NWe:V+s�FIm+e�"{�\B���F��-G��rwsk}5gh� p�.�&_ܑ1ފ�x�:���y����njb������n�\��ȳ�=w�ҽ��x%N��fQ^݈�O�(vo嗴􍹕T��Ȇ�d�dq���QY�,s��y-��]�����Υ����}���[T�]C���!���,��2�u"�u�*�.v��\[���6:�,���bw�Q��]���?)~���k��7�Ƨ��y_�%���.ͦymt��L�����33o�={��t�<4�\�z%>��dbb=�t��{S��S:)��v�b����E��|l�z�� ��{+�K|�0�JM�g�����iwc���t�/,�/�*n��c�*�����.�(���ԑF6���l�-����0�?و2\칹T��XIE�֙����X��M;�~�"㔾���i��G:7�H���?n\�sK���7���J�+[9W�>�E��*�uS ̍���n��4�b7r�*��Tعw�?��f�wm���ɞ����� ��̊}�^���b�:�K��G���F�Xf��z�mM��H�W�w��x�ر]�m.<}u���3�����SO�\<�O�tØH+3�tꡓ���#�$e�z%>�ᄅ�j-$��-=3��F�sv⅃տN�fm�Z��̳;'Z�ۥZc���N�ŋ:�y��\T�|S�i�c�,�ٓ*�P���J7��KQ<׻:�O;�"i����E�N�1�d���:�ͦ�����5�i�D�d����ũ0��GO�;�h1U|P�o��������裝�7�8o�?�Y�EdG���82�����?.W��u��"o��Hk���w�c��]���>Z�ͦ+1���Tm��i��zG:C�{����q �Z�G�^UG.S�w��r�y��#qp���:��8���޵�m�q�&��`���#��6�»ZfJ5��Ĺ�Z�� >*q���u;�;��G��a���� ���=��]��]�9�^�R��IU������+O͜>7}>.��ǯ�*aQ�P��j�|J왻&�?c� �C��H���uuu�d^b=�#��g�\��x����U�pW�rf�*~�����Wf��7�����F�����f�tus}i�ʿ �^c~G:�r�~h�}苻h\6�K��"v�̜�S?�|�Z��O��8�q��-�<�C���s��ws����E� F�*ʛ�=�tF�B�͝>��㋗.�5��F≲|�_�|U�Z��ŋ9�#�Fw.�Re�o���;GU|ݘ���+Q�TF�g��֯W0�*�g�PE���e�;�J�Gҧ�'������ݼߎDh%r�9U*+D���"m�N�ɱ�75p�5�?,3����"�d{��r;O���Kgf/�?Ә�s��4ǂ��X�����ժne#J�cgv_�Q��]���i��n=�@:_cǥ���]�z�����1���T'�~Q�*�@��T�6��EOzHY�\5�&�LٸA,m�(���|:����B�4�̋#�轢�pt` #�yʵŖ��O�U��쮼����+�积\�����L����<�Th���᱊e�Tw.?>M����(y�ժ��h}������c*�n���;��0�������y�T�^�T�Q�<���vg�f�?�y�<Ӌ5/��[+y L}2OQ_9��3�8}af����<��^�*��r�����;�]�x�g�{Kl�V������7��~z������͞�O>v_�q����E0vo4�9
+ � �f������F}ۛG���M��[�U�%�q-\�<4z�#f�p�P��u��"|�s���W5�e��e1���;��2��n�^:{6n�#�myaT�j4z���j]�ҝ���_ݕo�;�U��vk� 6�V6�mJ!����RO�{�vŃ��ϋ���Q{�� ���U��ݽ�Ū�Ǹ�ϿI��2;C���o�?��n̎xb���/��%?���S�"�p����n2�$�b�m�N@_8��p]������+����T���l��*�c�]��1˭����\����Re��z������T~\���[���k�GR=���w�󝍪�z� �p֯���<}�'.���jĮ�=Wԩ{1�R(�#-��dq?�;j>g�R����#s��׶�����#��S��a>'���Se�e���"�������c���s��n��[Iy����o/�W�~��&�qy����pU���-�����ԑT^����T�坳,���4t����b�_�R�*c��uw/���q�s�ˈ`Ţ}�D>�ڹÜ�.�s��ƥٵ��qߏ�\�W�X)r_�ͅ����i6骍c1"˜v�ѱ��d^�|��-���+����k{5����>W�.�*R����-:?��h�Wo3�Q5����g�����#�lUS6�}4��S���1E��3��#��.A�Ϙѹ�Si���]&���a���}�N��^�ƪd+�/{,��;��9\/b��pa��s�뫯�WN���2H~¼��:[&���[�E8\&�wRq��%�V |,��W/����ũ�0�[�I����8Ĺ��o�y�~���R��/��6o��aP�f��[�ݻ�k^�S<ջ�V�K�M��/Q�Z//ߪ���e�x���yҜR[���F�x�g��l�o�1=�Je����v&�aAn����[���8~���|�ı�{�3g�>3��'��H+��S���D����+�����E�b�p:$��DѦ�|�y���Z��VMj�9�~�����q��RN��g�u�B����]|�ͳW�=s�r?mX��@���/�<>�}���':��3��ϵY��F�,���gQ颉m�� U�Wu�w��9�Ifiu�[}�����_���}����i�� ��G=��?�H�x�Ԉ�4�I�'���V.��m�JQ�1�26� j��)�8��Kޝ�.�x�8�����)T���~b�����c�+!o�iZ�Yq�N��������u_q�����7"�"��l�r�J�jD/b-�#�#6"6#�"����|ĭ�wF|NĻ"^��܈ϋ���wG|A�F|Q�G|IėF|YėG|E�WF|U�WG|M��F|]��G|C�7F|S�7G|KķF|[ķG|G�wF|W�wG|O���»0(ߡR��h����ͭ&g'�g�)��o���C�1bq'��U���X4�,�ܑ�[�v�#z�ʜso�V�]v��տG�0��+���b�V���{:ǟ?{6W��h<�oN��z�����1A�'���)1Q쩼�G:'����>7���-����h��wIzl��EL�j7=p;�)Opb� ���^����KAW/�LGn��ld�fN_�t�-Ua�(?5�i��?�]��+߿C��9���T>R]6xVRMvhD��P]�HE���"�\��F컵����٥Q��S�F~
+ �hE]䂫fևc�׭#�͹}p,ycLֶ��NN��������n���t���Q{:�iUV7Sz}f�zws�x�����QZ�X��b��l~��P|P'M��鿲&��r�i�4gkҽ�]�a�Uu���Ҵ����W��T .b��[�έ�vŮ.�{"�[�\w9�Ħ�W�����S}4�vVߤ�5�x(�M�J�V󃲜/��+�}��>��ڶN���i�ғ�k��������ȩN��/��MY�8]�y�8�ߞz�噙���-�6q�7����o��Fk҉ܢy�n�\65o��Sޓ#Z�oӠ}�u��������F�g�W�"%�>�d=��{����������X���*�O��|���ER��7͡�p���k���#������suj���/��K�|?�Z������fw1�
+ �����6�w��)c��W�(�H3�S�V�6gۻt�b�N�wjnb2;��&�)�i�>y�{kE}�=����^z���S�gf.�}���#=13}f�r\��yN� �qAl��&�+ks�i �p6nSO_��=}��SqÊ{L��p��*�f/5*��n��f����7yO�m����3�#�W-X&��*� �v�Lܗ������C�;���;�n���豧����F�LN<}�|�GbO�����~��1o�ڇ�ۡ�u^��bځE}EUw��g)�?6����5Yz��"��,&��8�wP�?KSiߜȹ���KUU��Nz��B���*�.�^z: ��3� �w}��5�E���T������һ��Y=X����rfe{٩F����e��u㍲F/f�Q֠� �X����U��H�LbQo�n*������Ҿ�V�[;4UVLϭ������>/�;ͥgV��x䙏���|�髱����za�����F:P^dEC�w�ʗnj7;�إ�W�����y�b�ު.7����[ֻ��އ77�Y���������l�k�G6�U�>�ˆ c�����_�����b��T�򎷏Z�ܜMo�׭$G~Ym�Юle:���x��P��m9��v:5N_z�����=գ�q�[���?����L��x�n�, VK�U�M��^{����x��v�Rc.E��⨴���X��Tk~�����n�'_CoN* k��<�%Б�M�F.Χ�Sq����p�=� �_K~`�~M.���魯ݘ[-���^��T�X�o�^�T�W<����珑�[̯�_I+��q�Xx�9�V�U��R���s����
+ ������*q����t�E�&��N�Oc���F���FY���n=��Sa���f>z7{�K�"r�����>��\��Ȫ_�x�-��s+��X���Ӹ���r}s�UQ�����ɲ�� ��<C�c���v�r���p��f�v��>S=�z�am�����(����o��7�67���F������E@��beQ[<��JS7
+ ���j$�ź����+�li�1���*��=w���Ž�ˆ.�f� ��z'Z����x^�d�T�H������乧"��ʹ��Ϟ+��ȉQ^�� Nd\��@�Ժ_�?E��ϛ'Y���Z��\u��˪?�b�Z� G��Rγ:U�~=u^0U�����<��͸�_��G̦.��;9�}3W* ��V޹�9�k�ZӬ��ô�ʋ�F�'�sk��#����zg5U����zo�q���Rr�_jڨQ.��=�6���':U�r�6Z���]&��T��T��W�=~q�|���<9�Lh���7��:��'*J�Q,-�+�l-S���[��UڀV,�E�JB[����-�����^�g�V /���*��K*�c2�ر�2�Jk����l�����v���>���o5<k�h����)*i�;��Qy�F���1���Ց�/�%�Q?ο��s�j���K�gZ�|�}���y����C�ٜN�8��ݮۗ��<���q��vk۶$������c��Nv���ng�\v���6+[�e�=v����MjN5���L�A*�j�+����'�fR��}�4P��SO��H����?�����(}�V�1�)k��g͛踃]۲+��׺� �_Vi�U4�-W:(�,g"Z�{<KF�eB}u�r�/�Tȋ��n��o�5N�|wH�̅�t�H����K�� I���}en�����;D�V�`�q�ҥ��t��\��������TZ��6�,4�v������#�����;�s�U�~�qƯ��-�X����������vm �]=��yޮ��҃����h�X揊�Bz7O|�j�V^����n�O&����jc�gm<po�����<cF61Ӹ��I}h���yë������lZ���u�S?,������S�͞e��n�(
+ �y�b�Eq>�,�� *�F�X���ؼ/�O�_4zF���j�R���z�ri��z�����i�b J��u�����nyn�?��m,-ߊ�>�� }ꌲ^��d.��Mw6ֺ �'ᅹ�#o��8�MVe�s���sfv>E��Ν9cR�O������'��� U]���c�_�rFa����M�ӳ��}���t=�j�;e3�~c�X�KvdZ}K����8�i���z�v6�q�P�鍢q����W���ݸ�^,��>}~f�r��n�̕H0���e���P p� �P��mӦ�FM͇��7=F��es��._�Zlq�v�*8�nN�^�/��/�

+ i��S�q�RzV?x=l{�,6w�E��3Wf.�q�L}
>&�0���:���m{u���[�]���]�,��6���j�!Qxɒ���n��Z�|����Iw�������%��#��'�Zz'��Ժ�UQ#\Uo7���z5u�W�@�gq�����;+���[�,��J���T�u�in7��;=7z7�ҋ���Z����ϳ��|a���z�zKҫ@����t7/:�.~8���	r�r��^�:��u��[�e��yc��w��o�{�5\�{�|����������Α��i��]�ӟ�ݻV��ގ��]�J��"��﮼�E��fʷUj�i��j|3���_醴SǓUOp������N��U��ZȏϚ}wF^���͔
�,~�Zw�_>1Hdzx�_3��Ɖ�^-0�/_�,N�N1���������F�8�ڸ�0����w�淮�4�X�Ș��G�V���y���As�Ժ�-����oݴ�b���w���4:7��y�~C��<<P�}:2����O�J����t[+塎�v�[���!����)�����~�6����Y�F����?E�{��3�/�6�<P�{��1	����-Ǐ=�PV��yq)��e���7#=��b��9t:�zkE2X|%�oҋ�ݛy�C/���E��";R^�ݢ��|���-�e҅��$s�H�d���L�V�q�s�ٺb;�v�k�(#���r�r�g��|�E�ㅕ:��݅u|�W�����QyU�^>n#n��ܶ;�8�[��]��#Ӂ���KWf�x�򙇫^���Hoc�c7��ӟ�K��˓�SޢƘ���_����^��r��㖸����;-�9��e.v��m-o6t��X��۝��-.�f������N�}�����ds�E&t�g@���{9�0�L���r�˼>S�{�]��Ү���V��s'�U+�H��f�O<��L�>�C�z���]��V��(?Wo��X*r�/bc�z,{/��+Ϟo\�u[�V1�qa4{��?Jk�QЯ��ͅ��a?��NC���$L3��������4n/���ۮ�9X��?�5I��P��6��b��]�%w_�S6�l>�,�,/⥲|ck�7�D�'&E�\q�J�Y����"f��W�lj٬_/נl����O?q�3�*�I�}����t�u��s�xN4����\��'��?v�����'�n���Ž�yՏs�����_�d9���J6�aخ��w����u��s}U�#w[�l�~��8ީ��1Ǻ��W.�~�3�s�����&vcĺ��]���>�ګ�xo��J}����j��Τz*R���2���E�8w�~&��;z՛ߛ������bg%�p�f�Qe���y.��U�:╁/����n.i�E��e/j7�
�������Po�N���~gr�~L�<��w�~�z�����>�]_�vk�{�H����q��������L�o�l� ��l)���m)�@eh�{2�:U�Ƕ�˴��k[:1�z5�D��]^O���v��U}�Ο�*��<+v_�0��+z��ne[ȁ*�F*8x$�e�mO�]���w
+ �-ٷ=���/��1xש�m�j	/6��B�]���tvL?�{NJ۪�j��_�
Ğ�oo�}km��2�͏�br�]|z��V�!�G�\����'_�f�f����6?���4� ���:��o�z�3�V�{�U~s�q���\�V�p�9�ڷ��+��1#?To�M9ĸ�5��g��`q�s�:n���C��e���aʫ�O��)HU4�?�@o����a���@U,�o%�=(�iU�������pp��W7���^�u��

+ E�^D�}���g�����սi$��z7Ո�MߨF�-ǧ*GPL�(u���[k�f��1����#i������}��$S�0]e ���8� ��7&d1fs�#�F�GO����#E�F�K��HW��/��N�i{\��W危�~��f��E�e�y]'��Tt8WV��,F�:Zu?p�l1?�,���H�U���I��/��Ԝ��)cۦO_oQkAu��\.��gfZ�m �1�\�C�-_}��:�qyf��;[�Փ����yuwh
+ ��{���<�FUJ�:�ח ��={:�X�n�G�J���T��Ͼ����9(sz��FFo�}J+���Z�[�Y�قcă�q�1˩[K�\��ql����E�QgSy)������ӗ�V����.���ҵ�2���R��~.� ��ӿ���W�ŦN1���fo�?�z���9�ܴw"����;X6�-�*�����K)~Z �8��7�(׮?����a����_cF哢�0�����W�����E��~yr�nSʜ�N��G_g�~�,6s�r��S�ˣqNuW�n��D�v��.��̛����J����;�8�����ٌߡ�y�e�X�[�[��ϭ��~r'-�}���{m�=Xw��� )�p��tzS=|c��r�T��Ǹ\*���n�fr=�e����G��NkD�ݎG��b��ԣ~m\�àՍ��Gv�t�݇R��t?j|ۨI=���b�w;S�����G�WO�r�u�WS��W��H���l�_��;��W�w��f�n��鋧g�Gr�OG�:s���A�>ў*�h4�*[.~�x@��^�6�� �B��ڪ��m������G�]�|��%/���f���G����w���[�p����آ�`���5��������w��_<�p�d1�goD�99��5"����s_C3X�9�n2펭G ���U�����7��oo[* ��q�~Us�o�@O�YP�wou�A��W��?�QN� ��\㖞��Vm!�n2:wo���4�6�������K�U�� c^hu�؁���?.�t���7)��W���ط���8� �g\����շ<53|ZN�Cq��D������l;���l c�M�<�Tg��.�9��yΗ��Er��IEnj�i��&���x=X�{�"w���d3 KLkQU�V�5���0�y��;΅���S/��<�s�^����<y훩o���4P�=صj��Z�͢j����M�p�F��"�yQ�Ѫߣ��͝:?����6���T���X�47[>3�^��BU��:N��?F>s�K��@/�w�~��C��:�1�rx�T������� ��ݡ�oC{��:��nQf��}�@$s�;t ��}a7��=�b�B۾�b�b��ǃ[4d��x6ɽO�b v�ua��n��߷�hJ��k�e��F�ʑTݱY�U�1���kQ&� � �S>'�ar:�pw1�5��!�� �l�;�Mӗ/����Ý�59�}~/��w����j�i�~������q8sml�NHz5c}��&{�7v�>�y���sgf;��N��Je؁�NV�X����=�ly��qQr�l���������R_+[˛Ki��幥��p�7�b���U����U��6;Uء����-i��2|�� ��O{\�]�e�8�/�����zIj䃧�n�<�+��L���08Q?x�kyck>�N崠��d+籑�ɛ���5�EV��:[=i�� <D���-�"R{��p����W1�IӋ]����Փ��k��pMŸGK�;�6Գ�_�~�.�]�Qd>˹��Çƻ�1Z4�8\�e|�DU#Ѩ��/+��N���*Ƿ�-Xr��|���w�Q&�~v�5��ŏ�gs%�d��^�7�\�U�F5��ԛ�d�S�X�e��n���[3&��ON����E��Jû�GG(H�:%,�VV����<��Ӯ��w�7�*�}�F���+6�a9E��)�_>-�HA�G~�d�M>�*;��i��f=��ϛ��N�/���{�F�Z�7]>7ԍ�P��Vj�D�Thv��]¹�L<rѲf�ڲ=�7�f���ͨ�1�N�a(�2�(.�b �X��'�O��R��c���U)Lu2�Gb�[��,�Ru�:0X]���r�]aZ�������J7�r���Ln�0�xG0~���NU�WŖ��Kܝb��֫�!ǝ �+�T����`���j{s�������}t�j�F7�Ő}ێ�70���:cGꛪ���k����+��MG�;W�/���,^�NǨ�w.�Tϛ7�{eL+����}�ݭf���M�d:�#
+ �#2���UU/|Ę��<����k� ��{��w�꘮s*����Y��M �������n 4�ow�r����V�����7�{ы�-ees�3�����sJ�S���U��ʺ�<�l������I��쏭�f�D*����c�W���^�P��]��s�޲?�Hc�/����ɡYϦ���T�+N�u�z��4�O���G�F�<7:ʽ�N�7s�X���6���iR�����j�Y3Ⓔ��f�Ż��뺀�ʿ���e��j���X�o�~��ܕv��(�OC�ͭn��J/���h�o)E���#�3���p7��}�Z��kY����@c ��.I�����me��[6.{P>$����հ��Í�~���Żk�pӳϝ�j� G�����w�ّ��>G���{�j��_xY..U�~I�� O��zn˪�je�z9��(&ۮ��X�|�����K���*,�ME˕�n���S����Q���G�^�ӗΟ?w�����"<�d��,a�$5=�lt�������苹<���5z��=QlX�Q9�nj=n��g{��w���V:������������^f�Q,��v�c��;z�6j^h5�J��t��.�� �o�";�|٥@���IAc��r����� ]��Sg ������ưU=����ҎK~����w��1 �]����4w^��@
+ ��Ў�"�D}�Ɲ�#��߰�}��_F,�u��*�q��o��)X|\�$�i�u�ʈ����P��L���zk���og�OOL_yb7���:���vWih�\��+>��M`�4-�n��H��z��bAy;̵�c+�ʱ�r;���B;���)r �_��JUϢ��\w|��,r�i�AZ[�ps��2#6xb(�V6k��;��:�C��9�l⓪�nl�>�}�.��Lݩ�i�Į�~[m����.���e�uw󊃔~���i�Ӥ���8�YR�9l��)��h�zp���ڪFϢ��2O��@;��7qό�Z-�]����KOTw���i�Z�ٯ�,����#E7�բ�Q���M��nV&����P�1Xr������Xq�.�e����W/Ϥ�bs�e�y]���E�::�nt{��|cƿ�\������dn��C������g��NϦ��:�j~�ĥ�3� e�Q�Е|�sO�e��2�ޝ{���M �T�J�����o�"����>�k^꥾nVW��E�=�>�>K��pbD�������U�8X��Q��W�ِ+��<��J�m���??WM�^��A͋6�'�e��͛�J�����s����o_d؋�ӯS>���8���_�{������)��Xe�'[k���.��lO���>�������'�ϟ��p�=������68M�Ƒ�[��X.��۴�@ˋ�l����ZM���\�����\wy�����Bʼnݭƙ���>1zۇ^w褖�q�KC䵻�ͽ�n�Z��
+ K���8��֗o5͌��%���w�Ƹ(���/�a�/�ϥ�aѬh���|�k�7����ro�=�y������jkߘW0�қu�GU�&�y����n�"���5�e�n��EztZ(���RK���gs�����4D�|,�W�/�k�[k�K���C���hȱ^v�x�j�J�"%j�Y�&�;
+ �k�~�|�ocn����E�����KWg.�ZS�j~�%5��k�8X�wW ð�ri��ȳ�aV�Ce(�")+��n���ku�<��E�/�
+ %��y���m��J�9�2KŸ;�j�4�<�O�]�Y���F���T9�ґ|D�g���k��T�w�2��]YX�5Y��ƪ��]���X�b�������H � �ב� (�����C�_7�
+ )zx��޶��P#���G�Enq>q&6{u-g�Hg-��5Й�`6�_cT���ѿlf8�����P5�1cV�Z��cSS��v�;��7�j_��͛K �����j����+R�'Eo0�\�=�C�4�Y�Q7N�GN�4�t4�Rx��]#�.�K��Ϝ��oev��<���3QTJ/d�ƝMǰz���W�ͧ�����ߖ��C�:���[[K�FJ��6�C7����� s���z�d\��LRY���l��W�����vc�SѰzcq�Z1]ٶ�LZc=���O�\��#Y��t�̛�cY<k�}ꬭw�K'D�_��v�J��5�}_�v�w�#�-*g�(���fZoQs��.��w|���*�r��b�1����f}�����7�l�KJRKݍ�v�F�U
+ ���b���^w4��2��f�N4RϷ�q{��z�;��MOߌ}fW�'�5�]����U�����N?1}���
+ �DYm7�)ύ���nnH��Ց����zd[�9Áq�>��ǁUEZs]O=!.��sq������vh��4N�#�]5�����J�n��գ扥�GO��ş�.�fzt2M�8�R�����>h�Vu�VT��g��U��~������󑁈�>�:��t^�混�y�E��K��,Ł���瓹ݛz{Fq�*>(J;/ũ��� ��K�2��{�����n����3{i��.���L-��zD�y�{�}b/�������k4qH̋_}�.�xr�]�������N�IB�Q���-�(�E��lE����9B���Y{>�o����z�P���˹{m���;����4ͭ9�+2����g����-��E{��<Tt�Yt�0���lpX���g��I���O8rd����f���������T �~��������u�ν�?I��Rok�5�js������I�T����te���Ɵ�<�Hg���-o�9�{׫�l�1b���x�e>p`�մ7n��9�q��קO���M������OUI�;�d���ИzC��V|[��u�y�3Wң��j0��!�uc�N�Ƨ�yFͪ��!<z�olI��5�������ㅡ�W=l���@��bЯ�:

+ ڱ����3���rA�*n��Z=�ߘۘ-{G+R�fgթ�1Pʨư-�����ȸ��=k�Gzc<2Нp��b��t�G.`�>�6��-�-F���3g�|h��3��t�W�7��M�Lp̃�rS�i���t��>j\�֘�/�&O��F��	B}u���z�����l��W/]z����ӏ]�ƍ�x����]ԼVu�W����I*̶nq��|┺��}�Ll�_Ϧ��)瞏au͌�w�C�7Ƥ�v����\����F���φF���φ%�V�P?�_V���_��G�c�����K���/�Q��{�����v��F�p�V�xi2w�4���p�ƲS���s���1�ӤbZ��z&�H�m*�ƃ;L9��#���PYv�6sq���3�S��1P��ƒפ���
��r^hw���=��A��T�;�ß�v�9����9�z�`ôGOu�ieu�=��lz�6bxu��X��}�7Wv��Ey��3���l��@������.�����~���m_���ԉ��`�允�!�qZ:����iS��X�\j�?W�X
ažr���T6�[�ǥv��V$+[7����s�T�:��*r�����O<05�oRՁԑj��S����_����i(�j�Sy�V),>Io��;�S�����3D�߶6d�S���#=��V�}�>�h90p���^C;w�Jc`�*�U���<��f�����D�k����/����#��2�j����z$��}~-J�[��H�/���k��pm]��ٳk�x���6w=�h;95����+R���j՟e�	�-x4Wu�-d�?�_����~�W=j��<���Ωk^l�\�j/��`R�٭=���v.�ש���J�i/o`>�t>w2��h:x��K<l�e��\
�J���oۦ����*n�����\�Y�{�+�R�,�kZ�ͺˉ��k5�4�kk��5�'廙{��o�g˘�O�q�"�&�w�<&wk&�7"�m�)]�>0&������G/�l;�H�A�������9����>?U��s��Ɛe�HX�:5�L��/vs��ǨcY���������Z6	n�|���^Z�kx��:������w����\�Z]Ƚc.�*T>���_�^픕�uK�4���<�fIϿ���su��i���ߊ{��[���r-�լ�-*f���w�U�C=��T�4ͩIYsZ�tZϹ*��,&�ھucQ���dԅ�CO]������]|��_(~���곑�K}��m�&��Q����T��}q;,��ӣ2��_�#���(���ɻ����o��^����qӟ��m0�,��N�x�\���Y��$�z�hSR�LN5wȈ�[��|i��h��������V�|Kq���cyR���E�BX^�2
�nMʞz��9?���Cq+����:5��Rw���[�Sv�+�����/�›e��^�<���?���swv�Mu����*S�Fg����]��qU^��Vw�[V�I�����^b�z���*���	Z�5蓧/^������e�3X�Y�/^��x�����L����j��>
�3�zz������!�+���m��`-�*��T:�"e.�/��~�1y��G:�c_���K�_�ؾ
�
z�w��̮������?���k����eǨk��ܣר�o�P��vc��P�L�~�F�垪���sm�̙�S�Q.Y�=�9�o���OsK�}m9�0)3w�������<��Z~r����=[4ߙ̣��V���E�.
�ST���q��ZU3����c',�Y�����>��9�ߌ��Z�Ec�b{RS��6�{������m�6�7�����f�P�C׶���Ρ���.y����fo����1,�S 嶺�[�f�/���u���{0���|Uj�ۈoR
�F��͹|b;*;�;�]^�_O}�TO�s�q������$I3I�uo� ��!G��Q��Km|#�]��k�����5�i�,��,����7�V�U'~1lGNR�i���\�]��,��nv���<tE��ٛJZ�b���Ս��r7ı��k7|����66�O����G7ֺK�r�0m|�n�},|�V�k�i��Ӵ�Y9uq�W{�fUG<�b�#���ܭr���"�n�,�������Ĺ��[i��Ov�Ǯ+[w]+�CY��b#����X�釹��`��XQ}0�)P���:�	D�Լ�Zs=�l�#��]�j�n�����*���/Rs��Z�>Ū��nj���}?�jͮڀ#EV��
;T�?Nݽx���}y�
oxCQ�VOX�gR29С�`�6��Jz3�v_/�ON0P+P�jn�q��Z�ܿ}����' ŝn�Uw��=��7}ꭹk/ے�ds�3��.7�}B�q>�~�X/�H�EϑN�]X`�����4֣��J$��?����[1C�j�zS7������쭥�
��T=�ͧdjus��Vo+]��o���p#�9R��iH��mʳ�H1����<���<Q�fc�臧j���gǦ����S����K���d��d��3�dY�z�L������;�j1һx��l��3�bC��z�98p!����Y�hg�h���N-Vr��@K���ozvr����p�hO�h�p"���~k��3�<�xաIk��jͿ������[.�?w�����N?��������X^���=��e��ŧ/���7��:ʽ�Z�T����j�e�~��`/CE�X7��o+�5Ǿ�������x&T6W�E��e�H���j|<�i�Zh47�ߛ��l6���79��h��9���)���;���o��RU�,j?Ƿ�����_]���H7�R=�pS�G;'رo��Lg/L_|K�XU��V�Ղfb�����nj���S�,0{!��~|f�rm�EE��h�R<�l���v�S��׳���P&֣[I�ܗ՝x�W��V�U���fN��~*����h�T잁Rl�(�Q�-�튇���og6�z�#I�Ǥ�Q��?C.ƙ,s$��Ǻ���Q�B�O~�ߔ�
+ �v"�:ޙ�7,��S����l��r���e��V��-���m�����E��p9�Jч��F[�N��ϻ,��w�^���^��r��W��?�ne,G��L�M��IR��&j߿�k�O/C�����9��:��ȁ�g�nDSc��	n~��8�r�uF��Sh�S��]u�ٺ�ZOW��׸�Ϝ�=����%�t0u{�Q/ة.����RY�6��J]�6�ߕ�����m/}�t����c\�#�J��"cW=�)9l�q7��n���,�\�mv.*D�J�r���%�Je���������\.�/A?�M��V�>'���S�I��1U�P\�&�A#%�{-���C���V�Ek���⥓�;�y�:���%�y�ǵ�
g��7�����ظ���y
��;�-R�����Rn��*w��lJS���z��ȶ�U�O�2G3�ic���h���p슏����fԣ\E��t�Ae���l���J|�#��
�}Z���NU�ҙ<���c��l��[y����c�Τխqݢ���<��]���z��|��S�Ų&<gQ�6�2��R�κX�c�ϋ*�*��~���(ؗ��
+ �T�\VPݨ�w�͝��"�Z�[K�7�e��*��Fz�x:�H'����4��M�U��ӴQٲ�S��?���.#�f�ׯ��*���-�
lw�&���ǎU�Ѹ��Y��w����Qd���\Nsg�_����(^6ht������l�^�Y?�؎F�n�YE<�B�KKe;��.��0}�-��4s�U�j��;����p/����4��^�]�[ܐ�;��:�h�
��X�P532��̡=���KO?5{f����瞺z���K���=9��+��������������ꄁ]P�foD�3��XX�Zp{�"�j�*6�q���L�߀s�܀�L_�
hf��kE1t�-��m�q_���O���\$�����N�h�q��E��<�y.J�7��{�WN��~�DŽ��FYy%�6{+�<��G��[��|Wm:����{��v"��L��^q�]�-�V��:�����Zocci~�zX?���*ˁ#3���e�t�)�?�6o�չ�|
+ 5z��vn|�O���o�6~SWL���e�����^��O(���GO��Λ��s��z�XV9�T�+��6<50��|y����sf���Ѐ����W�7��J#GOl��Ew8y��xc�ֽs8��]L���R��pZJ���6oΗe�4�t�+����}�~�z�}�A�p����4�Z9Hiu��k�1�Y���DZ��8m~�y���Zia����*R����^�n�~|�J�����h��Qܼ�n����݌�Z6-7�Dꆹ<���=�c|���w��kSÜn��+���Ë��h{P���o��f.\��ЋX�f�!�곹mu9iZс��r��ՙ˳W�ݮ6N��롵��_ohn��˗.�^��y����\�4�ذ�R�3�ǶF��Ɖ�tr����~�R]�Zo��qM��L�ꌫ��K�_���Y��n�h�T��r�5bo�_�9�ߑ1�F{'578�ڈ1<�l�[ͪ5jqc�Fn�vۖ�ظ�i�S�tE��P����W\vu,��G�ÎV�Q��R�Y,v7�����'G��;��D��g���ƥl�jLo�r@��$��×<:�JjcT���y��7h������V�zrc�hB��<W��[��Mf���m�k�j��a����5+�G�B�|�ޠui|U���>v,���`� �l�L��4H[��ó�Y|��嵡��v�=�V�}�Ϋ�*���Z��_�Z�)�_9�ٱܵ��k��ً�E�J��
bt��R?��\]xœ�T����Ժ��,�]����O�{�~�~๗+�lhݿ��ʌ�;�?����{�Z[yɥ|9֭Grw�e�b.5�X\��3qSe��s��S�f?Xգ��	�zN�sI��7m�;:���|g�
+ ��uK�w�{d��ݘ.�O7_wO7�����j��Z����v�}<w5w�p��ų�ϝewt-K+9�*Y��f�jК���}��2�5���.��i+S�ok�-�U�:QZ/�|���w��#ש�~�_Fk�������:�{��z�����P4��m�]e�[^�@�
+ �|�E�ݦ���Z�n|�G;�s�=��U�n�;��#?�gi�=Q�Ȼ�7R���q�\Z_�Z��~��]��Ws6���x��nW~2e�S���zѤ?>�͡��*ͦ�6�ʫg���"W��������ޱ���'�"K�?M��-���	��1�|r��%Co��sS��f���"G��rL���l&Q�-\֝�-t����۸��gP�K���O��\Y%W�uu�����M����>1}����3����2��곻�a,{��Ƚ�w��կ`]zf̰M�{�lԚ^�ݞ�e��v�{w_NԽh��.wL���]��=�K�kN��5�w���*��)�ڣe�#vG�I�e�};~�
�";������N5F_^u�xi��/����a��SnZ$�e���腭��.js'����垲�Q���'Hw�~j(�<YN4p��)o�������Q5Q�b��j|V�0�؝U�������G�����S<�y���}����A{�;u�A`��6�����]J����%�Kй�D#�يR������[K�HD#��<ɛ�3g�8'3��fR�hKio*�Ǟ�r��o����ѹ����C��������s]�A�&㘽]ɟ�UK�W�������,f�˕|�y�����]�t��>�fM��c!Ƌ�R��D��Z�mD��V��D�����(�
�+F����?vf���||���U�ϩݦ����U�j������=8�o=���]�]

\ No newline at end of file

#26 lore raw

Re: [PATCH][18/28] e2fsprogs-tests-f_random_corruption.patch

In reply to Andreas Dilger

The f_random_corruption test enables a random subset of filesystem features, picks one of the valid filesystem block and inode sizes, and a random device size and creates a new filesystem with those parameters.

It is possible to disable the running of the test by setting the environment variable F_RANDOM_CORRUPTION=skip. By default the test script is run only one time, but setting the LOOP_COUNT variable allows the test to run multiple times.

If the script is running as root the filesystem is mounted and populated with file data to allow a more useful test filesystem to be generated. In some cases the kernel may not support the requested filesystem features and the filesystem cannot be mounted. This is not considered a test failure.

The resulting filesystem is corrupted with both random data and by shifting data from one part of the device to another and then repaired by e2fsck. In some rare cases the random corruption is severe enough that the filesystem is not recoverable (e.g. small filesystem with no backup superblock has bad superblock corruption) but in most cases "e2fsck -fy" should be able to fix all errors in some way.

After e2fsck has repaired the filesystem, it is optionally mounted (if the environment variable MOUNT_AFTER_CORRUPTION=yes is set) and the test files created in the filesystem are deleted. This verifies that the fixes in the filesystem are sufficient for the kernel to use the filesystem without error. Since there is some possibility of the kernel oopsing if there is a filesystem bug, this part of the test is not enabled by default.

tests/f_random_corruption/script new file +277 -0
Index: e2fsprogs-1.40.4/tests/f_random_corruption/script
===================================================================
@@ -0,0 +1,277 @@
+# This is to make sure that if this test fails other tests can still be run
+# instead of doing an exit. We break before the end of the loop.
+export LOOP_COUNT=${LOOP_COUNT:-1}
+export COUNT=0
+
+while [ $COUNT -lt $LOOP_COUNT ]; do
+[ "$F_RANDOM_CORRUPTION" = "skip" ] && echo "skipped" && break
+
+# choose block and inode sizes randomly
+BLK_SIZES=(1024 2048 4096)
+INODE_SIZES=(128 256 512 1024)
+
+SEED=$(head -1 /dev/urandom | od -N 1 | awk '{ print $2 }')
+RANDOM=$SEED
+
+IMAGE=${IMAGE:-$TMPFILE}
+DATE=`date '+%Y%m%d%H%M%S'`
+ARCHIVE=$IMAGE.$DATE
+SIZE=${SIZE:-$(( 192000 + RANDOM + RANDOM )) }
+FS_TYPE=${FS_TYPE:-ext3}
+BLK_SIZE=${BLK_SIZES[(( $RANDOM % ${#BLK_SIZES[*]} ))]}
+INODE_SIZE=${INODE_SIZES[(( $RANDOM % ${#INODE_SIZES[*]} ))]}
+DEF_FEATURES="sparse_super,filetype,dir_index"
+FEATURES=${FEATURES:-$DEF_FEATURES}
+MOUNT_OPTS="-o loop"
+MNTPT=$test_dir/temp
+OUT=$test_name.log
+FAILED=$test_name.failed
+OKFILE=$test_name.ok
+
+# Do you want to try and mount the filesystem?
+MOUNT_AFTER_CORRUPTION=${MOUNT_AFTER_CORRUPTION:-"no"}
+# Do you want to remove the files from the mounted filesystem?
+# Ideally use it only in test environment.
+REMOVE_FILES=${REMOVE_FILES:-"no"}
+
+# In KB
+CORRUPTION_SIZE=${CORRUPTION_SIZE:-64}
+CORRUPTION_ITERATIONS=${CORRUPTION_ITERATIONS:-5}
+
+MKFS=../misc/mke2fs
+E2FSCK=../e2fsck/e2fsck
+FIRST_FSCK_OPTS="-fyv"
+SECOND_FSCK_OPTS="-fyv"
+
+# Lets check if the image can fit in the current filesystem.
+BASE_DIR=`dirname $IMAGE`
+BASE_AVAIL_BLOCKS=`df -P -k $BASE_DIR  | awk '/%/ { print $4 }'`
+
+if (( BASE_AVAIL_BLOCKS < NUM_BLKS * (BLK_SIZE / 1024) )); then
+	echo "$BASE_DIR does not have enough space to accomodate test image."
+	echo "Skipping test...."
+	break;
+fi
+
+# Lets have a journal more times than not.
+HAVE_JOURNAL=$((RANDOM % 12 ))
+if (( HAVE_JOURNAL == 0 )); then
+	FS_TYPE="ext2"
+	HAVE_JOURNAL=""
+else
+	HAVE_JOURNAL="-j"
+fi
+
+# Experimental features should not be used too often.
+LAZY_BG=$(( $RANDOM % 12 ))
+if (( LAZY_BG == 0 )); then
+	FEATURES=$FEATURES,lazy_bg
+fi
+ 
+# meta_bg and resize_inode features should not be enabled simultaneously
+META_BG=$(( $RANDOM % 12 ))
+if (( META_BG == 0 )); then
+	FEATURES=$FEATURES,meta_bg
+else
+	FEATURES=$FEATURES,resize_inode
+fi
+
+modprobe ext4 2> /dev/null
+modprobe ext4dev 2> /dev/null
+
+# If ext4 is present in the kernel then we can play with ext4 options
+EXT4=`grep ext4 /proc/filesystems`
+if [ -n "$EXT4" ]; then
+	USE_EXT4=$((RANDOM % 2 ))
+	if (( USE_EXT4 == 1 )); then
+		FS_TYPE="ext4dev"
+	fi
+fi
+
+if [ "$FS_TYPE" = "ext4dev" ]; then
+	UNINIT_GROUPS=$((RANDOM % 12 ))
+	if (( UNINIT_GROUPS == 0 )); then
+		FEATURES=$FEATURES,uninit_groups
+	fi
+	EXPAND_ESIZE=$((RANDOM % 12 ))
+	if (( EXPAND_EISIZE == 0 )); then
+		FIRST_FSCK_OPTS=$FIRST_FSCK_OPTS," -E expand_extra_isize"
+	fi
+fi
+
+MKFS_OPTS="$HAVE_JOURNAL -b $BLK_SIZE -I $INODE_SIZE -O $FEATURES"
+
+NUM_BLKS=$(((SIZE * 1024) / BLK_SIZE))
+
+log()
+{
+	[ "$VERBOSE" ] && echo "$*"
+	echo "$*" >> $OUT
+}
+
+error()
+{
+	log "$*"
+	echo "$*" >> $FAILED
+}
+
+unset_vars()
+{
+	unset IMAGE DATE ARCHIVE FS_TYPE SIZE BLK_SIZE MKFS_OPTS MOUNT_OPTS
+	unset E2FSCK FIRST_FSCK_OPTS SECOND_FSCK_OPTS OUT FAILED OKFILE
+}
+
+cleanup()
+{
+	[ "$1" ] && error "$*" || error "Error occured..."
+	umount -f $MNTPT > /dev/null 2>&1 | tee -a $OUT
+	cp $OUT $OUT.$DATE
+	echo " failed"
+	echo "*** This appears to be a bug in e2fsprogs ***"
+	echo "Please contact [email protected] for further assistance."
+	echo "Include $OUT.$DATE, and save $ARCHIVE locally for reference."
+	unset_vars
+	break;
+}
+
+echo -n "Random corruption test for e2fsck:"
+# Truncate the output log file
+rm -f $FAILED $OKFILE
+> $OUT
+
+get_random_location()
+{
+	total=$1
+
+	tmp=$(((RANDOM * 32768) % total))
+
+	# Try and have more corruption in metadata at the start of the
+	# filesystem.
+	if ((tmp % 3 == 0 || tmp % 5 == 0 || tmp % 7 == 0)); then
+		tmp=$((tmp % 32768))
+	fi
+
+	echo $tmp
+}
+
+make_fs_dirty()
+{
+	from=`get_random_location $NUM_BLKS`
+
+	# Number of blocks to write garbage into should be within fs and should
+	# not be too many.
+	num_blks_to_dirty=$((RANDOM % $1))
+
+	# write garbage into the selected blocks
+	[ ! -c /dev/urandom ] && return
+	log "writing ${num_blks_to_dirty}kB random garbage at offset ${from}kB"
+	dd if=/dev/urandom of=$IMAGE bs=1kB seek=$from conv=notrunc \
+		count=$num_blks_to_dirty >> $OUT 2>&1
+}
+
+
+touch $IMAGE
+log "Format the filesystem image..."
+log
+# Write some garbage blocks into the filesystem to make sure e2fsck has to do
+# a more difficult job than checking blocks of zeroes.
+log "Copy some random data into filesystem image...."
+make_fs_dirty 32768
+log "$MKFS $MKFS_OPTS -F $IMAGE $NUM_BLKS >> $OUT"
+$MKFS $MKFS_OPTS -F $IMAGE $NUM_BLKS >> $OUT 2>&1
+if [ $? -ne 0 ]; then
+	zero_size=`grep "Device size reported to be zero" $OUT`
+	short_write=`grep "Attempt to write block from filesystem resulted in short write" $OUT`
+
+	if (( zero_size != 0 || short_write != 0 )); then
+		echo "mkfs failed due to device size of 0 or a short write. This is harmless and need not be reported."
+	else
+		cleanup "mkfs failed - internal error during operation. Aborting random regression test..."
+	fi
+fi
+
+if [ `id -u` = 0 ]; then
+	mkdir -p $MNTPT
+	if [ $? -ne 0 ]; then
+		log "Failed to create or find mountpoint...."
+	else
+		mount -t $FS_TYPE $MOUNT_OPTS $IMAGE $MNTPT 2>&1 | tee -a $OUT
+		if [ $? -ne 0 ]; then
+			log "Unable to mount file system - skipped"
+		else
+			df -h $MNTPT >> $OUT
+			df -i $MNTPT >> $OUT
+			log "Copying data into the test filesystem..."
+
+			cp -r ../ $MNTPT >> $OUT 2>&1
+			sync
+			umount -f $MNTPT > /dev/null 2>&1 | tee -a $OUT
+		fi
+	fi
+else
+	log "skipping mount test for non-root user"
+fi
+
+log "Corrupt the image by moving around blocks of data..."
+log
+for (( i = 0; i < $CORRUPTION_ITERATIONS; i++ )); do
+	from=`get_random_location $NUM_BLKS`
+	to=`get_random_location $NUM_BLKS`
+
+	log "Moving ${CORRUPTION_SIZE}kB from block ${from}kB to ${to}kB"
+	dd if=$IMAGE of=$IMAGE bs=1k count=$CORRUPTION_SIZE conv=notrunc skip=$from seek=$to >> $OUT 2>&1
+
+	# more corruption by overwriting blocks from within the filesystem.
+	make_fs_dirty $CORRUPTION_SIZE
+done
+
+# Copy the image for reproducing the bug.
+cp --sparse=always $IMAGE $ARCHIVE >> $OUT 2>&1
+
+log "First pass of fsck..."
+$E2FSCK $FIRST_FSCK_OPTS $IMAGE >> $OUT 2>&1
+RET=$?
+
+# Run e2fsck for the second time and check if the problem gets solved.
+# After we can report error with pass1.
+[ $((RET & 1)) == 0 ] || log "The first fsck corrected errors"
+[ $((RET & 2)) == 0 ] || error "The first fsck wants a reboot"
+[ $((RET & 4)) == 0 ] || error "The first fsck left uncorrected errors"
+[ $((RET & 8)) == 0 ] || error "The first fsck reports an operational error"
+[ $((RET & 16)) == 0 ] || error "The first fsck reports there was a usage error"
+[ $((RET & 32)) == 0 ] || error "The first fsck reports it was cancelled"
+[ $((RET & 128)) == 0 ] || error "The first fsck reports a library error"
+
+log "---------------------------------------------------------"
+
+log "Second pass of fsck..."
+$E2FSCK $SECOND_FSCK_OPTS $IMAGE >> $OUT 2>&1
+RET=$?
+[ $((RET & 1)) == 0 ] || cleanup "The second fsck corrected errors!"
+[ $((RET & 2)) == 0 ] || cleanup "The second fsck wants a reboot"
+[ $((RET & 4)) == 0 ] || cleanup "The second fsck left uncorrected errors"
+[ $((RET & 8)) == 0 ] || cleanup "The second fsck reports an operational error"
+[ $((RET & 16)) == 0 ] || cleanup "The second fsck reports a usage error"
+[ $((RET & 32)) == 0 ] || cleanup "The second fsck reports it was cancelled"
+[ $((RET & 128)) == 0 ] || cleanup "The second fsck reports a library error"
+
+[ -f $FAILED ] && cleanup
+
+if [ "$MOUNT_AFTER_CORRUPTION" = "yes" ]; then
+	mount -t $FS_TYPE $MOUNT_OPTS $IMAGE $MNTPT 2>&1 | tee -a $OUT
+	[ $? -ne 0 ] && log "Unable to mount file system - skipped"
+
+	[ "$REMOVE_FILES" = "yes" ] && rm -rf $MNTPT/* >> $OUT
+	umount -f $MNTPT > /dev/null 2>&1 | tee -a $OUT
+fi
+
+rm -f $ARCHIVE
+
+# Report success
+echo " ok"
+echo "Succeeded..." > $OKFILE
+
+unset_vars
+
+COUNT=$((COUNT + 1))
+done
tests/Makefile.in +3 -1
Index: e2fsprogs-1.40.4/tests/Makefile.in
===================================================================
@@ -24,6 +24,8 @@ test_script: test_script.in Makefile
 	@chmod +x test_script
 
 check:: test_script
+	@echo "Removing remnants of earlier tests..."
+	$(RM) -f *~ *.log *.new *.failed *.ok test.img2*
 	@echo "Running e2fsprogs test suite..."
 	@echo " "
 	@./test_script
@@ -63,7 +65,7 @@ testend: test_script ${TDIR}/image
 	@echo "If all is well, edit ${TDIR}/name and rename ${TDIR}."
 
 clean::
-	$(RM) -f *~ *.log *.new *.failed *.ok test.img test_script
+	$(RM) -f *~ *.log *.new *.failed *.ok test.img* test_script
 
 distclean:: clean
 	$(RM) -f Makefile

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#27 lore raw

Re: [PATCH][19/28] e2fsprogs-stride_option.patch

In reply to Andreas Dilger

Add support for setting the s_raid_stride and s_raid_stripe_width fields in the superblock via mke2fs and tune2fs.c. This is useful for mballoc to align block allocation on the RAID stripe boundaries.

Fix up the debugfs "ssv" command to set a number of new superblock fields.

lib/ext2fs/initialize.c +2 -0
Index: e2fsprogs-1.40.5/lib/ext2fs/initialize.c
===================================================================
@@ -156,6 +156,8 @@ errcode_t ext2fs_initialize(const char *
 	set_field(s_feature_incompat, 0);
 	set_field(s_feature_ro_compat, 0);
 	set_field(s_first_meta_bg, 0);
+	set_field(s_raid_stride, 0);		/* default stride size: 0 */
+	set_field(s_raid_stripe_width, 0);	/* default stripe width: 0 */
 	set_field(s_flags, 0);
 	if (super->s_feature_incompat & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP) {
 		retval = EXT2_ET_UNSUPP_FEATURE;
misc/mke2fs.c +36 -9

93 lines not on this page · raw message

misc/tune2fs.c +44 -1

69 lines not on this page · raw message

misc/mke2fs.8.in +16 -3
Index: e2fsprogs-1.40.5/misc/mke2fs.8.in
===================================================================
@@ -179,10 +179,23 @@ option is still accepted for backwards c
 following extended options are supported:
 .RS 1.2i
 .TP
-.BI stride= stripe-size
+.BI stride= stride-size
 Configure the filesystem for a RAID array with
-.I stripe-size
-filesystem blocks per stripe.
+.I stride-size
+filesystem blocks. This is the number of blocks read or written to disk
+before moving to next disk. This mostly affects placement of filesystem
+metadata like bitmaps at
+.BR mke2fs (2)
+time to avoid placing them on a single disk, which can hurt the performanace.
+It may also be used by block allocator.
+.TP
+.BI stripe-width= stripe-width
+Configure the filesystem for a RAID array with
+.I stripe-width
+filesystem blocks per stripe. This is typically be stride-size * N, where
+N is the number of data disks in the RAID (e.g. RAID 5 N+1, RAID 6 N+2).
+This allows the block allocator to prevent read-modify-write of the
+parity in a RAID stripe if possible when the data is written.
 .TP
 .BI resize= max-online-resize
 Reserve enough space so that the block group descriptor table can grow
misc/tune2fs.8.in +29 -0
Index: e2fsprogs-1.40.5/misc/tune2fs.8.in
===================================================================
@@ -65,6 +65,10 @@ tune2fs \- adjust tunable filesystem par
 .I extended-options
 ]
 [
+.B \-E
+.I extended-options
+]
+[
 .B \-L
 .I volume-name
 ]
@@ -163,6 +167,31 @@ Clear the test_fs flag, indicating the f
 using production-level filesystem code.
 .RE
 .TP
+.BI \-E " extended-options"
+Set extended options for the filesystem.  Extended options are comma
+separated, and may take an argument using the equals ('=') sign.
+The following extended options are supported:
+.RS 1.2i
+.TP
+.BI stride= stride-size
+Configure the filesystem for a RAID array with
+.I stride-size
+filesystem blocks. This is the number of blocks read or written to disk
+before moving to next disk. This mostly affects placement of filesystem
+metadata like bitmaps at
+.BR mke2fs (2)
+time to avoid placing them on a single disk, which can hurt the performanace.
+It may also be used by block allocator.
+.TP
+.BI stripe-width= stripe-width
+Configure the filesystem for a RAID array with
+.I stripe-width
+filesystem blocks per stripe. This is typically be stride-size * N, where
+N is the number of data disks in the RAID (e.g. RAID 5 N+1, RAID 6 N+2).
+This allows the block allocator to prevent read-modify-write of the
+parity in a RAID stripe if possible when the data is written.
+.RE
+.TP
 .B \-f
 Force the tune2fs operation to complete even in the face of errors.  This 
 option is useful when removing the 
debugfs/set_fields.c +33 -7
Index: e2fsprogs-1.40.5/debugfs/set_fields.c
===================================================================
@@ -9,12 +9,18 @@
  * %End-Header%
  */
 
-#define _XOPEN_SOURCE 500 /* for inclusion of strptime() */
+#define _XOPEN_SOURCE 600 /* for inclusion of strptime() and strtoull */
+
+#ifdef HAVE_STRTOULL
+#define STRTOULL strtoull
+#else
+#define STRTOULL strtoul
+#endif
 
 #include <stdio.h>
 #include <unistd.h>
-#include <stdlib.h>
 #include <ctype.h>
+#include <stdlib.h>
 #include <string.h>
 #include <strings.h>
 #include <time.h>
@@ -103,7 +109,6 @@ static struct field_set_info super_field
 		  parse_uint },
 	{ "reserved_gdt_blocks", &set_sb.s_reserved_gdt_blocks, 2,
 		  parse_uint },
-	/* s_padding1 */
 	{ "journal_uuid", &set_sb.s_journal_uuid, 16, parse_uuid },
 	{ "journal_inum", &set_sb.s_journal_inum, 4, parse_uint },
 	{ "journal_dev", &set_sb.s_journal_dev, 4, parse_uint },
@@ -111,13 +116,22 @@ static struct field_set_info super_field
 	{ "hash_seed", &set_sb.s_hash_seed, 16, parse_uuid },
 	{ "def_hash_version", &set_sb.s_def_hash_version, 1, parse_hashalg },
 	{ "jnl_backup_type", &set_sb.s_jnl_backup_type, 1, parse_uint },
-	/* s_reserved_word_pad */
+	{ "desc_size", &set_sb.s_desc_size, 2, parse_uint },
 	{ "default_mount_opts", &set_sb.s_default_mount_opts, 4, parse_uint },
 	{ "first_meta_bg", &set_sb.s_first_meta_bg, 4, parse_uint },
 	{ "mkfs_time", &set_sb.s_mkfs_time, 4, parse_time },
 	{ "jnl_blocks", &set_sb.s_jnl_blocks[0], 4, parse_uint, FLAG_ARRAY, 
 	  17 },
+	{ "blocks_count_hi", &set_sb.s_blocks_count_hi, 4, parse_uint },
+	{ "r_blocks_count_hi", &set_sb.s_r_blocks_count_hi, 4, parse_uint },
+	{ "min_extra_isize", &set_sb.s_min_extra_isize, 2, parse_uint },
+	{ "want_extra_isize", &set_sb.s_want_extra_isize, 2, parse_uint },
 	{ "flags", &set_sb.s_flags, 4, parse_uint },
+	{ "raid_stride", &set_sb.s_raid_stride, 2, parse_uint },
+	{ "min_extra_isize", &set_sb.s_min_extra_isize, 4, parse_uint },
+	{ "mmp_interval", &set_sb.s_mmp_interval, 2, parse_uint },
+	{ "mmp_block", &set_sb.s_mmp_block, 8, parse_uint },
+	{ "raid_stripe_width", &set_sb.s_raid_stripe_width, 4, parse_uint },
 	{ 0, 0, 0, 0 }
 };
 
@@ -144,6 +158,7 @@ static struct field_set_info inode_field
 	{ "generation", &set_inode.i_generation, 4, parse_uint },
 	{ "file_acl", &set_inode.i_file_acl, 4, parse_uint },
 	{ "dir_acl", &set_inode.i_dir_acl, 4, parse_uint },
+	{ "size_high", &set_inode.i_size_high, 4, parse_uint },
 	{ "faddr", &set_inode.i_faddr, 4, parse_uint },
 	{ "blocks_hi", &set_inode.osd2.linux2.l_i_blocks_hi, 2, parse_uint },
 	{ "frag", &set_inode.osd2.hurd2.h_i_frag, 1, parse_uint },
@@ -229,9 +244,10 @@ static struct field_set_info *find_field
 
 static errcode_t parse_uint(struct field_set_info *info, char *arg)
 {
-	unsigned long	num;
+	unsigned long long num, limit;
 	char *tmp;
 	union {
+		__u64	*ptr64;
 		__u32	*ptr32;
 		__u16	*ptr16;
 		__u8	*ptr8;
@@ -241,13 +257,23 @@ static errcode_t parse_uint(struct field
 	if (info->flags & FLAG_ARRAY)
 		u.ptr8 += array_idx * info->size;
 
-	num = strtoul(arg, &tmp, 0);
-	if (*tmp) {
+	errno = 0;
+	num = STRTOULL(arg, &tmp, 0);
+	if (*tmp || errno) {
 		fprintf(stderr, "Couldn't parse '%s' for field %s.\n",
 			arg, info->name);
 		return EINVAL;
 	}
+	limit = ~0ULL >> ((8 - info->size) * 8);
+	if (num > limit) {
+		fprintf(stderr, "Value '%s' exceeds field %s maximum %llu.\n",
+			arg, info->name, limit);
+		return EINVAL;
+	}
 	switch (info->size) {
+	case 8:
+		*u.ptr64 = num;
+		break;
 	case 4:
 		*u.ptr32 = num;
 		break;
lib/blkid/read.c +3 -3
Index: e2fsprogs-1.40.5/lib/blkid/read.c
===================================================================
@@ -10,6 +10,8 @@
  * %End-Header%
  */
 
+#define _XOPEN_SOURCE 600 /* for inclusion of strtoull */
+
 #include <stdio.h>
 #include <ctype.h>
 #include <string.h>
@@ -26,7 +28,6 @@
 #include "uuid/uuid.h"
 
 #ifdef HAVE_STRTOULL
-#define __USE_ISOC9X
 #define STRTOULL strtoull /* defined in stdlib.h if you try hard enough */
 #else
 /* FIXME: need to support real strtoull here */
@@ -319,8 +320,7 @@ static int parse_tag(blkid_cache cache, 
 	else if (!strcmp(name, "PRI"))
 		dev->bid_pri = strtol(value, 0, 0);
 	else if (!strcmp(name, "TIME"))
-		/* FIXME: need to parse a long long eventually */
-		dev->bid_time = strtol(value, 0, 0);
+		dev->bid_time = STRTOULL(value, 0, 0);
 	else
 		ret = blkid_set_tag(dev, name, value, strlen(value));
 

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#28 lore raw

Re: [PATCH][20/28] e2fsprogs-mmp.patch

In reply to Andreas Dilger

Add multi-mount protection support to libext2fs (INCOMPAT_MMP feature).

This allows mke2fs, e2fsck, and others to detect if the filesystem is mounted on a remote node (on SAN disks) and avoid corrupting the filesystem. For e2fsprogs this only means that it check the MMP block to see if the filesystem is in use, and mark the filesystem busy while e2fsck is running on the system.

There is no requirement that e2fsck updates the MMP block in any regular interval, but e2fsck does this occasionally to provide additional information to the sysadmin in case of conflict.

lib/e2p/feature.c +2 -0
Index: e2fsprogs-1.40.5/lib/e2p/feature.c
===================================================================
@@ -67,6 +67,8 @@ static struct feature feature_list[] = {
 			"extent" },
 	{	E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_64BIT,
 			"64bit" },
+	{       E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_MMP,
+			"mmp" },
 	{       E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_FLEX_BG,
                         "flex_bg"},
 	{	0, 0, 0 },
lib/ext2fs/ext2_fs.h +29 -20

73 lines not on this page · raw message

lib/ext2fs/ext2fs.h +30 -2
Index: e2fsprogs-1.40.5/lib/ext2fs/ext2fs.h
===================================================================
@@ -171,6 +171,7 @@ typedef struct ext2_file *ext2_file_t;
 #define EXT2_FLAG_IMAGE_FILE		0x2000
 #define EXT2_FLAG_EXCLUSIVE		0x4000
 #define EXT2_FLAG_SOFTSUPP_FEATURES	0x8000
+#define EXT2_FLAG_SKIP_MMP		0x10000
 
 /*
  * Special flag in the ext2 inode i_flag field that means that this is
@@ -185,6 +186,15 @@ typedef struct ext2_file *ext2_file_t;
  */
 #define EXT2_MKJOURNAL_V1_SUPER	0x0000001
 
+/*
+ * The timestamp in the MMP structure will be updated by e2fsck at some
+ * arbitary intervals (start of passes, after every EXT2_MMP_INODE_INTERVAL
+ * inodes in pass1 and pass1b).  There is no guarantee that e2fsck is updating
+ * the MMP block in a timely manner, and the updates it does are purely for
+ * the convenience of the sysadmin and not for automatic validation.
+ */
+#define EXT2_MMP_INODE_INTERVAL 20000
+
 struct struct_ext2_filsys {
 	errcode_t			magic;
 	io_channel			io;
@@ -228,6 +238,15 @@ struct struct_ext2_filsys {
 	 */
 	struct ext2_inode_cache		*icache;
 	io_channel			image_io;
+
+	/*
+	 * Buffer for Multiple mount protection(MMP) block.
+	 */
+	char *mmp_buf;
+	/*
+	 * Time at which e2fsck last updated the MMP block.
+	 */
+	long mmp_last_written;
 };
 
 #if EXT2_FLAT_INCLUDES
@@ -444,14 +463,16 @@ typedef struct ext2_icount *ext2_icount_
 					 EXT2_FEATURE_INCOMPAT_META_BG|\
 					 EXT3_FEATURE_INCOMPAT_RECOVER|\
  					 EXT3_FEATURE_INCOMPAT_EXTENTS|\
-					 EXT4_FEATURE_INCOMPAT_FLEX_BG)
+					 EXT4_FEATURE_INCOMPAT_FLEX_BG|\
+					 EXT4_FEATURE_INCOMPAT_MMP)
 #else
 #define EXT2_LIB_FEATURE_INCOMPAT_SUPP	(EXT2_FEATURE_INCOMPAT_FILETYPE|\
 					 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|\
 					 EXT2_FEATURE_INCOMPAT_META_BG|\
 					 EXT3_FEATURE_INCOMPAT_RECOVER|\
 					 EXT3_FEATURE_INCOMPAT_EXTENTS|\
-					 EXT4_FEATURE_INCOMPAT_FLEX_BG)
+					 EXT4_FEATURE_INCOMPAT_FLEX_BG|\
+					 EXT4_FEATURE_INCOMPAT_MMP)
 #endif
 #define EXT2_LIB_FEATURE_RO_COMPAT_SUPP	(EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|\
 					 EXT2_FEATURE_RO_COMPAT_LARGE_FILE|\
@@ -995,6 +1016,12 @@ errcode_t ext2fs_link(ext2_filsys fs, ex
 errcode_t ext2fs_unlink(ext2_filsys fs, ext2_ino_t dir, const char *name,
 			ext2_ino_t ino, int flags);
 
+/* mmp.c */
+errcode_t ext2fs_read_mmp(ext2_filsys fs, blk_t mmp_blk, char *buf);
+errcode_t ext2fs_write_mmp(ext2_filsys fs, blk_t mmp_blk, char *buf);
+errcode_t ext2fs_enable_mmp(ext2_filsys fs);
+long int ext2fs_mmp_new_seq();
+
 /* read_bb.c */
 extern errcode_t ext2fs_read_bb_inode(ext2_filsys fs,
 				      ext2_badblocks_list *bb_list);
@@ -1032,6 +1059,7 @@ extern void ext2fs_swap_inode(ext2_filsy
 extern void ext2fs_swap_extent_header(struct ext3_extent_header *eh);
 extern void ext2fs_swap_extent_index(struct ext3_extent_idx *ix);
 extern void ext2fs_swap_extent(struct ext3_extent *ex);
+extern void ext2fs_swap_mmp(struct mmp_struct *mmp);
 
 /* valid_blk.c */
 extern int ext2fs_inode_has_valid_blocks(struct ext2_inode *inode);
misc/tune2fs.c +111 -4

193 lines not on this page · raw message

e2fsck/pass1.c +13 -0
Index: e2fsprogs-1.40.5/e2fsck/pass1.c
===================================================================
@@ -795,7 +795,20 @@ void e2fsck_pass1(e2fsck_t ctx)
 	    (fs->super->s_mtime < fs->super->s_inodes_count))
 		busted_fs_time = 1;
 
+	if ((fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_MMP) &&
+	    !(fs->super->s_mmp_block < fs->super->s_first_data_block ||
+	      fs->super->s_mmp_block >= fs->super->s_blocks_count))
+		ext2fs_mark_block_bitmap(ctx->block_found_map,
+					 fs->super->s_mmp_block);
+
 	while (1) {
+		if (ino % EXT2_MMP_INODE_INTERVAL == 0) {
+			errcode_t error;
+
+			error = e2fsck_mmp_update(fs);
+			if (error)
+				fatal_error(ctx, 0);
+		}
 		old_op = ehandler_operation(_("getting next inode from scan"));
 		pctx.errcode = ext2fs_get_next_inode_full(scan, &ino, 
 							  inode, inode_size);
e2fsck/unix.c +17 -0
Index: e2fsprogs-1.40.5/e2fsck/unix.c
===================================================================
@@ -1076,6 +1076,23 @@ restart:
 			       "to do a read-only\n"
 			       "check of the device.\n"));
 #endif
+		else if (retval == EXT2_ET_MMP_BAD_BLOCK) {
+			if (fix_problem(ctx, PR_0_MMP_INVALID_BLK, &pctx)) {
+				fs->super->s_mmp_block = 0;
+				ext2fs_mark_super_dirty(fs);
+			}
+		}
+		else if (retval == EXT2_ET_MMP_FAILED) {
+			dump_mmp_msg((struct mmp_struct *)fs->mmp_buf,
+				     _("Device is already active on another node."));
+		}
+		else if (retval == EXT2_ET_MMP_FSCK_ON) {
+			dump_mmp_msg((struct mmp_struct *)fs->mmp_buf,
+				     _("It seems as if e2fsck is running on the "
+				     "filesystem.\nIf you are sure that e2fsck is "
+				     "not running then use \"tune2fs -O ^mmp {device}\" "
+				     "followed by \"tune2fs -O mmp {device}\""));
+		}
 		else
 			fix_problem(ctx, PR_0_SB_CORRUPT, &pctx);
 		fatal_error(ctx, 0);
e2fsck/problem.c +5 -0
Index: e2fsprogs-1.40.5/e2fsck/problem.c
===================================================================
@@ -389,6 +389,11 @@ static struct e2fsck_problem problem_tab
 	  PROMPT_NONE, 0 },
 
 
+	/* Superblock has invalid MMP block. */
+	{ PR_0_MMP_INVALID_BLK,
+	  N_("@S has invalid MMP block.  "),
+	  PROMPT_CLEAR, PR_PREEN_OK },
+
 	/* Pass 1 errors */
 
 	/* Pass 1: Checking inodes, blocks, and sizes */
e2fsck/problem.h +3 -0
Index: e2fsprogs-1.40.5/e2fsck/problem.h
===================================================================
@@ -222,6 +222,9 @@ struct problem_context {
 #define PR_0_CLEAR_EXTRA_ISIZE			0x00003C
 
 
+/* Superblock has invalid MMP block. */
+#define PR_0_MMP_INVALID_BLK			0x00003A
+
 /*
  * Pass 1 errors
  */
lib/ext2fs/swapfs.c +10 -0
Index: e2fsprogs-1.40.5/lib/ext2fs/swapfs.c
===================================================================
@@ -70,6 +70,8 @@ void ext2fs_swap_super(struct ext2_super
 	sb->s_min_extra_isize = ext2fs_swab16(sb->s_min_extra_isize);
 	sb->s_want_extra_isize = ext2fs_swab16(sb->s_want_extra_isize);
 	sb->s_flags = ext2fs_swab32(sb->s_flags);
+	sb->s_mmp_update_interval = ext2fs_swab16(sb->s_mmp_update_interval);
+	sb->s_mmp_block = ext2fs_swab64(sb->s_mmp_block);
 	for (i=0; i < 4; i++)
 		sb->s_hash_seed[i] = ext2fs_swab32(sb->s_hash_seed[i]);
 	for (i=0; i < 17; i++)
@@ -310,4 +312,12 @@ void ext2fs_swap_inode(ext2_filsys fs, s
 				sizeof(struct ext2_inode));
 }
 
+void ext2fs_swap_mmp(struct mmp_struct *mmp)
+{
+	mmp->mmp_magic = ext2fs_swab32(mmp->mmp_magic);
+	mmp->mmp_seq = ext2fs_swab32(mmp->mmp_seq);
+	mmp->mmp_time = ext2fs_swab64(mmp->mmp_time);
+	mmp->mmp_check_interval = ext2fs_swab16(mmp->mmp_check_interval);
+}
+
 #endif
lib/ext2fs/openfs.c +104 -0

128 lines not on this page · raw message

lib/ext2fs/ext2_err.et.in +20 -0
Index: e2fsprogs-1.40.5/lib/ext2fs/ext2_err.et.in
===================================================================
@@ -362,5 +362,25 @@ ec	EXT2_ET_EA_NAME_NOT_FOUND,
 ec	EXT2_ET_EA_NAME_EXISTS,
 	"Extended attribute name already exists"
 
+ec	EXT2_ET_MMP_MAGIC_INVALID,
+	"MMP: Invalid magic number in MMP block"
+
+ec	EXT2_ET_MMP_FAILED,
+	"MMP: Device already active on another node"
+
+ec	EXT2_ET_MMP_FSCK_ON,
+	"MMP: Seems as if fsck is already being run on the filesystem."
+
+ec	EXT2_ET_MMP_BAD_BLOCK,
+	"MMP: MMP block number beyond filesystem range."
+
+ec	EXT2_ET_MMP_UNKNOWN_SEQ,
+	"MMP: MMP sequence is beyond EXT2_MMP_SEQ_MAX. This filesystem "
+	"seems to be undergoing an unknown operation."
+
+ec	EXT2_ET_MMP_FSCK_ABORT,
+	"MMP: Expected sequence not found. Filesystem may be mounted while "
+	"fsck was running"
+
 	end
 
lib/ext2fs/closefs.c +51 -0

63 lines not on this page · raw message

e2fsck/e2fsck.c +4 -0
Index: e2fsprogs-1.40.5/e2fsck/e2fsck.c
===================================================================
@@ -186,6 +186,7 @@ int e2fsck_run(e2fsck_t ctx)
 {
 	int	i;
 	pass_t	e2fsck_pass;
+	int error;
 
 #ifdef HAVE_SETJMP_H
 	if (setjmp(ctx->abort_loc)) {
@@ -198,6 +199,9 @@ int e2fsck_run(e2fsck_t ctx)
 	for (i=0; (e2fsck_pass = e2fsck_passes[i]); i++) {
 		if (ctx->flags & E2F_FLAG_RUN_RETURN)
 			break;
+		error = e2fsck_mmp_update(ctx->fs);
+		if (error)
+		      	fatal_error(ctx, 0);
 		e2fsck_pass(ctx);
 		if (ctx->progress)
 			(void) (ctx->progress)(ctx, 0, 0, 0);
e2fsck/e2fsck.h +2 -0
Index: e2fsprogs-1.40.5/e2fsck/e2fsck.h
===================================================================
@@ -535,6 +535,8 @@ extern void mtrace_print(char *mesg);
 extern blk_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs,
 			   const char *name, io_manager manager);
 extern int ext2_file_type(unsigned int mode);
+errcode_t e2fsck_mmp_update(ext2_filsys fs);
+void dump_mmp_msg(struct mmp_struct *mmp, const char *msg);
 
 /* unix.c */
 extern void e2fsck_clear_progbar(e2fsck_t ctx);
lib/ext2fs/Makefile.in +3 -0
Index: e2fsprogs-1.40.5/lib/ext2fs/Makefile.in
===================================================================
@@ -55,6 +55,7 @@ OBJS= $(DEBUGFS_LIB_OBJS) $(RESIZE_LIB_O
 	lookup.o \
 	mkdir.o \
 	mkjournal.o \
+	mmp.o \
 	native.o \
 	newdir.o \
 	openfs.o \
@@ -116,6 +117,7 @@ SRCS= ext2_err.c \
 	$(srcdir)/lookup.c \
 	$(srcdir)/mkdir.c \
 	$(srcdir)/mkjournal.c \
+	$(srcdir)/mmp.c	\
 	$(srcdir)/namei.c \
 	$(srcdir)/native.c \
 	$(srcdir)/newdir.c \
@@ -502,6 +504,7 @@ mkdir.o: $(srcdir)/mkdir.c $(srcdir)/ext
  $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h \
  $(srcdir)/ext2_fs.h $(srcdir)/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
  $(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h
+mmp.o: $(srcdir)/ext2_fs.h $(srcdir)/ext2fs.h
 mkjournal.o: $(srcdir)/mkjournal.c $(srcdir)/ext2_fs.h \
  $(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/e2p/e2p.h \
  $(srcdir)/ext2_fs.h $(srcdir)/ext2fs.h $(srcdir)/ext3_extents.h \
lib/ext2fs/mmp.c new file +139 -0

139 lines not on this page · raw message

e2fsck/pass1b.c +7 -0
Index: e2fsprogs-1.40.5/e2fsck/pass1b.c
===================================================================
@@ -272,6 +272,13 @@ static void pass1b(e2fsck_t ctx, char *b
 	pb.pctx = &pctx;
 	pctx.str = "pass1b";
 	while (1) {
+		if (ino % EXT2_MMP_INODE_INTERVAL == 0) {
+			errcode_t error;
+
+			error = e2fsck_mmp_update(fs);
+			if (error)
+				fatal_error(ctx, 0);
+		}
 		pctx.errcode = ext2fs_get_next_inode(scan, &ino, &inode);
 		if (pctx.errcode == EXT2_ET_BAD_BLOCK_IN_INODE_TABLE)
 			continue;
misc/tune2fs.8.in +8 -0
Index: e2fsprogs-1.40.5/misc/tune2fs.8.in
===================================================================
@@ -438,6 +438,11 @@ Setting the filesystem feature is equiva
 .B \-j
 option.
 .TP
+.B mmp
+Enable or disable multiple mount protection(MMP) feature. MMP helps to protect
+the filesystem from being multiply mounted and is useful in shared storage
+environment.
+.TP
 .B sparse_super
 Limit the number of backup superblocks to save space on large filesystems.
 .TP
@@ -474,6 +479,9 @@ being mounted by kernels which do not su
 .B uninit_groups
 feature is not yet supported by any officially released kernel.
 .TP
+.BI \-p " mmp_check_interval"
+Set the desired MMP check interval in seconds. It is 5 seconds by default.
+.TP
 .BI \-r " reserved-blocks-count"
 Set the number of reserved filesystem blocks.
 .TP
misc/mke2fs.c +16 -2
Index: e2fsprogs-1.40.5/misc/mke2fs.c
===================================================================
@@ -922,7 +922,8 @@ static __u32 ok_features[3] = {
 	EXT2_FEATURE_INCOMPAT_FILETYPE|		/* Incompat */
 		EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|
 		EXT2_FEATURE_INCOMPAT_META_BG|
-		EXT4_FEATURE_INCOMPAT_FLEX_BG,
+		EXT4_FEATURE_INCOMPAT_FLEX_BG|
+		EXT4_FEATURE_INCOMPAT_MMP,
 	EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|	/* R/O compat */
 		EXT4_FEATURE_RO_COMPAT_GDT_CSUM
 };
@@ -1803,8 +1804,21 @@ int main (int argc, char *argv[])
 	}
 no_journal:
 
-	if (!super_only)
+	if (!super_only) {
 		ext2fs_set_gdt_csum(fs);
+		if (fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_MMP) {
+			retval = ext2fs_enable_mmp(fs);
+			if (retval) {
+				fprintf(stderr, _("\nError while enabling "
+					"multiple mount protection feature."));
+				exit(1);
+			}
+			printf(_("Multiple mount protection has been enabled. "
+				 "The MMP update interval has been set to "
+				 "%d seconds.\n"),
+				 fs->super->s_mmp_update_interval);
+		}
+	}
 	if (!quiet)
 		printf(_("Writing superblocks and "
 		       "filesystem accounting information: "));
e2fsck/util.c +58 -0

61 lines not on this page · raw message

lib/ext2fs/bitops.h +6 -0
Index: e2fsprogs-1.40.5/lib/ext2fs/bitops.h
===================================================================
@@ -329,6 +329,12 @@ _INLINE_ __u32 ext2fs_swab32(__u32 val)
 		((val<<8)&0xFF0000) | (val<<24));
 }
 
+_INLINE_ __u64 ext2fs_swab64(__u64 val)
+{
+	return (ext2fs_swab32(val >> 32) |
+		(((__u64)ext2fs_swab32(val & 0xFFFFFFFFUL)) << 32));
+}
+
 #endif /* !_EXT2_HAVE_ASM_SWAB */
 
 #if !defined(_EXT2_HAVE_ASM_FINDBIT_)
debugfs/set_fields.c +1 -1
Index: e2fsprogs-1.40.5/debugfs/set_fields.c
===================================================================
@@ -129,7 +129,7 @@ static struct field_set_info super_field
 	{ "flags", &set_sb.s_flags, 4, parse_uint },
 	{ "raid_stride", &set_sb.s_raid_stride, 2, parse_uint },
 	{ "min_extra_isize", &set_sb.s_min_extra_isize, 4, parse_uint },
-	{ "mmp_interval", &set_sb.s_mmp_interval, 2, parse_uint },
+	{ "mmp_update_interval", &set_sb.s_mmp_update_interval, 2, parse_uint },
 	{ "mmp_block", &set_sb.s_mmp_block, 8, parse_uint },
 	{ "raid_stripe_width", &set_sb.s_raid_stripe_width, 4, parse_uint },
 	{ 0, 0, 0, 0 }

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#29 lore raw

Re: [PATCH][21/28] e2fsprogs-journal_chksum.patch

In reply to Andreas Dilger

E2fsprogs part of Journal Checksum feature.

This adds support for journals with the INCOMPAT_ASYNC_COMMIT and COMPAT_CHECKSUM features.

If CHECKSUM is set, each transaction has a checksum of the full transaction and it is verified before the transaction is replayed. If any interior block is missing or corrupted, or if the transaction is incomplete it will not be replayed.

The ASYNC_COMMIT feature allows the kernel to avoid waiting for the transaction (meta)data to commit before writing the journal commit block.

lib/ext2fs/kernel-jbd.h +30 -3
Index: e2fsprogs-1.40.2/lib/ext2fs/kernel-jbd.h
===================================================================
@@ -108,7 +108,29 @@ typedef struct journal_header_s
 	__u32		h_sequence;
 } journal_header_t;
 
+/*
+ * Checksum types.
+ */
+#define JFS_CRC32_CHKSUM   1
+#define JFS_MD5_CHKSUM     2
+#define JFS_SHA1_CHKSUM    3
+
+#define JFS_CRC32_CHKSUM_SIZE 4
 
+#define JFS_CHECKSUM_BYTES (32 / sizeof(__u32))
+/*
+ * Commit block header for storing transactional checksums:
+ */
+struct commit_header
+{
+	__u32		h_magic;
+	__u32		h_blocktype;
+	__u32		h_sequence;
+	unsigned char   h_chksum_type;
+	unsigned char   h_chksum_size;
+	unsigned char   h_padding[2];
+	__u32		h_chksum[JFS_CHECKSUM_BYTES];
+};
 /* 
  * The block tag: used to describe a single buffer in the journal 
  */
@@ -194,12 +216,17 @@ typedef struct journal_superblock_s
 	((j)->j_format_version >= 2 &&					\
 	 ((j)->j_superblock->s_feature_incompat & cpu_to_be32((mask))))
 
-#define JFS_FEATURE_INCOMPAT_REVOKE	0x00000001
+#define JFS_FEATURE_COMPAT_CHECKSUM    0x00000001
+
+#define JFS_FEATURE_INCOMPAT_REVOKE		0x00000001
+/*#define JFS_FEATURE_INCOMPAT_64BIT             0x00000002*/
+#define JFS_FEATURE_INCOMPAT_ASYNC_COMMIT	0x00000004
 
 /* Features known to this kernel version: */
-#define JFS_KNOWN_COMPAT_FEATURES	0
+#define JFS_KNOWN_COMPAT_FEATURES	JFS_FEATURE_COMPAT_CHECKSUM
 #define JFS_KNOWN_ROCOMPAT_FEATURES	0
-#define JFS_KNOWN_INCOMPAT_FEATURES	JFS_FEATURE_INCOMPAT_REVOKE
+#define JFS_KNOWN_INCOMPAT_FEATURES	(JFS_FEATURE_INCOMPAT_REVOKE| \
+					JFS_FEATURE_INCOMPAT_ASYNC_COMMIT)
 
 #ifdef __KERNEL__
 
lib/ext2fs/crc32.h new file +28 -0
Index: e2fsprogs-1.40.2/lib/ext2fs/crc32.h
===================================================================
@@ -0,0 +1,28 @@
+/*
+ * crc32.h
+ * See crc32.c for license and changes
+ */
+#ifndef _LINUX_CRC32_H
+#define _LINUX_CRC32_H
+
+typedef unsigned int u32;
+typedef unsigned char u8;
+
+extern u32 crc32_le(u32 crc, unsigned char const *p, size_t len);
+extern u32 crc32_be(u32 crc, unsigned char const *p, size_t len);
+extern u32 bitreverse(u32 in);
+
+#define crc32(seed, data, length)  crc32_le(seed, (unsigned char const *)data, length)
+
+/*
+ * Helpers for hash table generation of ethernet nics:
+ *
+ * Ethernet sends the least significant bit of a byte first, thus crc32_le
+ * is used. The output of crc32_le is bit reversed [most significant bit
+ * is in bit nr 0], thus it must be reversed before use. Except for
+ * nics that bit swap the result internally...
+ */
+#define ether_crc(length, data)    bitreverse(crc32_le(~0, data, length))
+#define ether_crc_le(length, data) crc32_le(~0, data, length)
+
+#endif /* _LINUX_CRC32_H */
lib/ext2fs/crc32.c new file +519 -0

519 lines not on this page · raw message

lib/ext2fs/crc32defs.h new file +32 -0
Index: e2fsprogs-1.40.2/lib/ext2fs/crc32defs.h
===================================================================
@@ -0,0 +1,32 @@
+/*
+ * There are multiple 16-bit CRC polynomials in common use, but this is
+ * *the* standard CRC-32 polynomial, first popularized by Ethernet.
+ * x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x^1+x^0
+ */
+#define CRCPOLY_LE 0xedb88320
+#define CRCPOLY_BE 0x04c11db7
+
+/* How many bits at a time to use.  Requires a table of 4<<CRC_xx_BITS bytes. */
+/* For less performance-sensitive, use 4 */
+#ifndef CRC_LE_BITS
+# define CRC_LE_BITS 8
+#endif
+#ifndef CRC_BE_BITS
+# define CRC_BE_BITS 8
+#endif
+
+/*
+ * Little-endian CRC computation.  Used with serial bit streams sent
+ * lsbit-first.  Be sure to use cpu_to_le32() to append the computed CRC.
+ */
+#if CRC_LE_BITS > 8 || CRC_LE_BITS < 1 || CRC_LE_BITS & CRC_LE_BITS-1
+# error CRC_LE_BITS must be a power of 2 between 1 and 8
+#endif
+
+/*
+ * Big-endian CRC computation.  Used with serial bit streams sent
+ * msbit-first.  Be sure to use cpu_to_be32() to append the computed CRC.
+ */
+#if CRC_BE_BITS > 8 || CRC_BE_BITS < 1 || CRC_BE_BITS & CRC_BE_BITS-1
+# error CRC_BE_BITS must be a power of 2 between 1 and 8
+#endif
lib/ext2fs/crc32table.h new file +135 -0

135 lines not on this page · raw message

lib/ext2fs/crc32_user.h new file +45 -0

45 lines not on this page · raw message

lib/ext2fs/Makefile.in +8 -3
Index: e2fsprogs-1.40.2/lib/ext2fs/Makefile.in
===================================================================
@@ -69,6 +69,7 @@ OBJS= $(DEBUGFS_LIB_OBJS) $(RESIZE_LIB_O
 	unlink.o \
 	valid_blk.o \
 	version.o \
+	crc32.o \
 	crc16.o \
 	csum.o
 
@@ -143,6 +144,7 @@ SRCS= ext2_err.c \
 	$(srcdir)/tst_types.c \
 	$(srcdir)/tst_iscan.c \
 	$(srcdir)/tst_csum.c \
+	$(srcdir)/crc32.c \
 	$(srcdir)/crc16.c \
 	$(srcdir)/csum.c
 
@@ -234,10 +236,11 @@ tst_bitops: tst_bitops.o inline.o $(STAT
 	@$(CC) -o tst_bitops tst_bitops.o inline.o $(ALL_CFLAGS) \
 		$(STATIC_LIBEXT2FS) $(LIBCOM_ERR)
 
-tst_csum: tst_csum.o csum.o crc16.o $(STATIC_LIBEXT2FS) $(STATIC_LIBUUID)
+tst_csum: tst_csum.o csum.o crc16.o crc32.o $(STATIC_LIBEXT2FS) \
+		$(STATIC_LIBUUID)
 	@echo "	LD $@"
-	@$(CC) -o tst_csum csum.o tst_csum.o crc16.o $(STATIC_LIBEXT2FS) \
-		$(STATIC_LIBUUID) $(LIBCOM_ERR)
+	@$(CC) -o tst_csum csum.o tst_csum.o crc16.o crc32.o \
+		$(STATIC_LIBEXT2FS) $(STATIC_LIBUUID) $(LIBCOM_ERR)
 
 tst_getsectsize: tst_getsectsize.o getsectsize.o $(STATIC_LIBEXT2FS)
 	@echo "	LD $@"
@@ -384,6 +387,8 @@ cmp_bitmaps.o: $(srcdir)/cmp_bitmaps.c $
  $(srcdir)/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h $(srcdir)/bitops.h
 crc16.o: $(srcdir)/crc16.c $(srcdir)/ext2_fs.h $(srcdir)/crc16.h \
  $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h
+crc32.o: $(srcdir)/crc32.c $(srcdir)/ext2_fs.h $(srcdir)/crc16.h \
+ $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h
 csum.o: $(srcdir)/csum.c $(srcdir)/ext2_fs.h \
  $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/ext2fs.h $(srcdir)/ext2_fs.h
 dblist.o: $(srcdir)/dblist.c $(srcdir)/ext2_fs.h \
e2fsck/e2fsck.h +2 -0
Index: e2fsprogs-1.40.2/e2fsck/e2fsck.h
===================================================================
@@ -30,10 +30,12 @@
 #if EXT2_FLAT_INCLUDES
 #include "ext2_fs.h"
 #include "ext2fs.h"
+#include "crc32.h"
 #include "blkid.h"
 #else
 #include "ext2fs/ext2_fs.h"
 #include "ext2fs/ext2fs.h"
+#include "ext2fs/crc32.h"
 #include "blkid/blkid.h"
 #endif
 
e2fsck/recovery.c +142 -7

187 lines not on this page · raw message

lib/ext2fs/tst_csum.c +53 -19

97 lines not on this page · raw message

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#30 lore raw

Re: [PATCH][25/28] e2fsprogs-i_size-corruption.patch

In reply to Andreas Dilger

Fix handling of block preallocation support in cases where the kernel PAGE_SIZE is larger than the filesystem blocksize.

e2fsck/pass1.c +1 -1
Index: e2fsprogs-1.40.2/e2fsck/pass1.c
===================================================================
@@ -2103,7 +2103,7 @@ static void check_blocks(e2fsck_t ctx, s
 		if ((pb.last_block >= 0) &&
 		    /* allow allocated blocks to end of PAGE_SIZE */
 		    (size < (__u64)pb.last_block * fs->blocksize) &&
-		    (pb.last_block / blkpg * blkpg != pb.last_block ||
+		    ((pb.last_block+1) / blkpg * blkpg != (pb.last_block+1) ||
 		     size < (__u64)(pb.last_block & ~(blkpg-1)) *fs->blocksize))
 			bad_size = 3;
 		else if (size > ext2_max_sizes[fs->super->s_log_block_size])

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#31 lore raw

Re: [PATCH][26/28] e2fsprogs-fiemap.patch

In reply to Andreas Dilger

Add support for ioctl(FIEMAP) to filefrag. If the kernel supports FIEMAP the filefrag program prefers this more efficient mechanism to get extent information instead of repeated FIBMAP calls.

misc/filefrag.c +122 -25
Index: e2fsprogs-1.40.2/misc/filefrag.c
===================================================================
@@ -38,11 +38,47 @@ extern int optind;
 #include <sys/vfs.h>
 #include <sys/ioctl.h>
 #include <linux/fd.h>
+#include <ext2fs/ext2_types.h>
 
 int verbose = 0;
 
-#define FIBMAP	   _IO(0x00,1)	/* bmap access */
-#define FIGETBSZ   _IO(0x00,2)	/* get the block size used for bmap */
+struct fiemap_extent {
+	__u64 fe_offset; /* offset in bytes for the start of the extent */
+	__u64 fe_length; /* length in bytes for the extent */
+	__u32 fe_flags;  /* returned FIEMAP_EXTENT_* flags for the extent */
+	__u32 fe_lun;    /* logical device number for extent (starting at 0) */
+};
+
+struct fiemap {
+	__u64 fm_start;	 	/* logical starting byte offset (in/out) */
+	__u64 fm_length;	/* logical length of map (in/out) */
+	__u32 fm_flags;	 	/* FIEMAP_FLAG_* flags for request (in/out) */
+	__u32 fm_extent_count;  /* number of extents in fm_extents (in/out) */
+	__u64 fm_unused;
+	struct fiemap_extent fm_extents[0];
+};
+
+#define FIEMAP_FLAG_SYNC	0x00000001 /* sync file data before map */
+#define FIEMAP_FLAG_HSM_READ    0x00000002 /* get data from HSM before map */
+#define FIEMAP_FLAG_NUM_EXTENTS 0x00000004 /* return only number of extents */
+#define FIEMAP_FLAG_INCOMPAT    0xff000000 /* error for unknown flags in here */
+
+#define FIEMAP_EXTENT_HOLE      0x00000001 /* has no data or space allocation */
+#define FIEMAP_EXTENT_UNWRITTEN 0x00000002 /* space allocated, but no data */
+#define FIEMAP_EXTENT_UNMAPPED  0x00000004 /* has data but no space allocation*/
+#define FIEMAP_EXTENT_ERROR     0x00000008 /* mapping error, errno in fe_start*/
+#define FIEMAP_EXTENT_NO_DIRECT 0x00000010 /* cannot access data directly */
+#define FIEMAP_EXTENT_LAST      0x00000020 /* last extent in the file */
+#define FIEMAP_EXTENT_DELALLOC  0x00000040 /* has data but not yet written,
+					      must have EXTENT_UNKNOWN set */
+#define FIEMAP_EXTENT_SECONDARY 0x00000080 /* data (also) in secondary storage,
+					      not in primary if EXTENT_UNKNOWN*/
+#define FIEMAP_EXTENT_EOF       0x00000100 /* if fm_start+fm_len is beyond EOF*/
+
+
+#define FIBMAP		_IO(0x00, 1)	/* bmap access */
+#define FIGETBSZ	_IO(0x00, 2)	/* get the block size used for bmap */
+#define EXT4_IOC_FIEMAP	_IOWR('f', 10, struct fiemap) /* get file  extent info*/
 
 #define EXT4_EXTENTS_FL			0x00080000 /* Inode uses extents */
 #define	EXT3_IOC_GETFLAGS		_IOR('f', 1, long)
@@ -71,6 +107,62 @@ static unsigned long get_bmap(int fd, un
 	return b;
 }
 
+int filefrag_fiemap(int fd, int bs, int *num_extents)
+{
+	char buf[4096] = "";
+	struct fiemap *fiemap = (struct fiemap *)buf;
+	int count = (sizeof(buf) - sizeof(*fiemap)) /
+			sizeof(struct fiemap_extent);
+	__u64 logical_blk = 0, last_blk = 0;
+	unsigned long flags;
+	int tot_extents = 0;
+	int eof = 0;
+	int i;
+	int rc;
+
+	memset(fiemap, 0, sizeof(struct fiemap));
+	fiemap->fm_extent_count = count;
+	fiemap->fm_length = ~0ULL;
+	if (!verbose)
+		flags |= FIEMAP_FLAG_NUM_EXTENTS;
+
+	do {
+		fiemap->fm_length = ~0ULL;
+		fiemap->fm_flags = flags;
+		fiemap->fm_extent_count = count;
+		rc = ioctl (fd, EXT4_IOC_FIEMAP, (unsigned long) fiemap);
+		if (rc)
+			return rc;
+
+		if (!verbose) {
+			*num_extents = fiemap->fm_extent_count;
+			goto out;
+		}
+
+		for (i = 0; i < fiemap->fm_extent_count; i++) {
+			__u64 phy_blk;
+			unsigned long ext_len;
+
+			phy_blk = fiemap->fm_extents[i].fe_offset / bs;
+			ext_len = fiemap->fm_extents[i].fe_length / bs;
+			if (logical_blk && (phy_blk != last_blk+1))
+				printf("Discontinuity: Block %llu is at %llu "
+				       "(was %llu)\n", logical_blk, phy_blk,
+				       last_blk);
+			logical_blk += ext_len;
+			last_blk = phy_blk + ext_len - 1;
+			if (fiemap->fm_extents[i].fe_flags & FIEMAP_EXTENT_EOF)
+				eof = 1;
+		}
+		fiemap->fm_start += fiemap->fm_length;
+		tot_extents += fiemap->fm_extent_count;
+	} while (0);
+
+	*num_extents = tot_extents;
+out:
+	return 0;
+}
+
 #define EXT2_DIRECT	12
 
 static void frag_report(const char *filename)
@@ -86,7 +178,7 @@ static void frag_report(const char *file
 	unsigned long	block, last_block = 0, numblocks, i;
 	long		bpib;	/* Blocks per indirect block */
 	long		cylgroups;
-	int		discont = 0, expected;
+	int		num_extents = 0, expected;
 	int		is_ext2 = 0;
 	unsigned int	flags;
 
@@ -135,7 +227,8 @@ static void frag_report(const char *file
 	if (ioctl(fd, EXT3_IOC_GETFLAGS, &flags) < 0)
 		flags = 0;
 	if (flags & EXT4_EXTENTS_FL) {
-		printf("File is stored in extents format\n");
+		if (verbose)
+			printf("File is stored in extents format\n");
 		is_ext2 = 0;
 	}
 	if (verbose)
@@ -148,32 +241,36 @@ static void frag_report(const char *file
 		printf("First block: %lu\nLast block: %lu\n",
 		       get_bmap(fd, 0), get_bmap(fd, numblocks - 1));
 	}
-	for (i=0; i < numblocks; i++) {
-		if (is_ext2 && last_block) {
-			if (((i-EXT2_DIRECT) % bpib) == 0)
-				last_block++;
-			if (((i-EXT2_DIRECT-bpib) % (bpib*bpib)) == 0)
-				last_block++;
-			if (((i-EXT2_DIRECT-bpib-bpib*bpib) % (bpib*bpib*bpib)) == 0)
-				last_block++;
-		}
-		block = get_bmap(fd, i);
-		if (block == 0)
-			continue;
-		if (last_block && (block != last_block +1) ) {
-			if (verbose)
-				printf("Discontinuity: Block %ld is at %lu (was %lu)\n",
-				       i, block, last_block);
-			discont++;
+	if (is_ext2 || (filefrag_fiemap(fd, bs, &num_extents) != 0)) {
+		for (i = 0; i < numblocks; i++) {
+			if (is_ext2 && last_block) {
+				if (((i-EXT2_DIRECT) % bpib) == 0)
+					last_block++;
+				if (((i-EXT2_DIRECT-bpib) % (bpib*bpib)) == 0)
+					last_block++;
+				if (((i-EXT2_DIRECT-bpib-bpib*bpib) %
+							(bpib*bpib*bpib)) == 0)
+					last_block++;
+			}
+			block = get_bmap(fd, i);
+			if (block == 0)
+				continue;
+			if (last_block && (block != last_block+1) ) {
+				if (verbose)
+					printf("Discontinuity: Block %ld is at "
+					       "%lu (was %lu)\n",
+					       i, block, last_block+1);
+				num_extents++;
+			}
+			last_block = block;
 		}
-		last_block = block;
 	}
-	if (discont==0)
+	if (num_extents == 1)
 		printf("%s: 1 extent found", filename);
 	else
-		printf("%s: %d extents found", filename, discont+1);
+		printf("%s: %d extents found", filename, num_extents);
 	expected = (numblocks/((bs*8)-(fsinfo.f_files/8/cylgroups)-3))+1;
-	if (is_ext2 && expected != discont+1)
+	if (is_ext2 && expected != num_extents)
 		printf(", perfection would be %d extent%s\n", expected,
 			(expected>1) ? "s" : "");
 	else

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#32 lore raw

Re: [PATCH][27/28] e2fsprogs-debugfs-supported_features.patch

In reply to Andreas Dilger

Print out the currently supported features of e2fsprogs/libext2fs via a new "debugfs supported_features" command.

debugfs/debug_cmds.ct +3 -0
Index: e2fsprogs-1.40.2/debugfs/debug_cmds.ct
===================================================================
@@ -154,5 +154,8 @@ request	do_dump_unused, "Dump unused blo
 request do_set_current_time, "Set current time to use when setting filesystme fields",
 	set_current_time;
 
+request do_supported_features, "Print features supported by this version of e2fsprogs",
+	supported_features;
+
 end;
 
debugfs/debugfs.c +38 -0
Index: e2fsprogs-1.40.2/debugfs/debugfs.c
===================================================================
@@ -1772,6 +1772,44 @@ void do_set_current_time(int argc, char 
 	}
 }
 
+void do_supported_features(int argc, char *argv[])
+{
+        FILE	*out = stdout;
+        int	i, j, ret;
+        __u32	supp[3] = { EXT2_LIB_FEATURE_COMPAT_SUPP,
+			    EXT2_LIB_FEATURE_INCOMPAT_SUPP,
+			    EXT2_LIB_FEATURE_RO_COMPAT_SUPP };
+	__u32	m;
+	int compat;
+	unsigned int feature_flag;
+
+	if (argc >= 1) {
+		ret = e2p_string2feature(argv[1], &compat, &feature_flag);
+		if (ret)
+			goto err;
+
+		if (!(supp[compat] & feature_flag))
+			goto err;
+
+		fprintf(out, "Supported feature: %s\n", argv[1]);
+	} else {
+		fprintf(out, "Supported features:");
+	        for (i = 0; i < 3; i++) {
+		        for (j = 0, m = 1; j < 32; j++, m <<= 1) {
+			        if (supp[i] & m)
+        			        fprintf(out, " %s",
+						e2p_feature2string(i, m));
+	        	}
+		}
+	        fprintf(out, "\n");
+	}
+
+	return;
+
+err:
+	com_err(argv[0], 0, "Unknown feature: %s\n", argv[1]);
+}
+
 static int source_file(const char *cmd_file, int sci_idx)
 {
 	FILE		*f;
lib/ext2fs/ext2_fs.h +1 -2
Index: e2fsprogs-1.40.2/lib/ext2fs/ext2_fs.h
===================================================================
@@ -656,8 +656,7 @@ struct ext2_super_block {
 #define EXT2_FEATURE_RO_COMPAT_SUPP	(EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
 					 EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
 					 EXT4_FEATURE_RO_COMPAT_DIR_NLINK| \
-					 EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE| \
-					 EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
+					 EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE)
 
 /*
  * Default values for user and/or group using reserved blocks

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#33 lore raw

Re: [PATCH][28/28] e2fsprogs-lts-make_rpms.patch

In reply to Andreas Dilger

Allow "make rpm" to take some extra configure options from the build environment without having to patch the code.

Build the tarball in a temporary directory instead of the e2fsprogs source directory.

contrib/build-rpm +17 -6
diff -Naur e2fsprogs-1.40.2/contrib/build-rpm e2fsprogs-1.40.2.new/contrib/build-rpm
@@ -1,5 +1,10 @@
 #!/bin/sh
 
+# enable xtrace output if requested
+if [ -n ${ENABLE_XTRACE:-''} ]; then
+    set -x
+fi
+
 # Build an e2fsprogs RPM from cvs
 
 pwd=`pwd`
@@ -8,8 +13,11 @@
 pkgvers=`grep Version: e2fsprogs.spec | awk '{print $2;}'`
 builddir=${pkgname}-${pkgvers}
 
+# ensure that $TMP is set to something
+TMP=${TMP:-'/tmp'}
+
 cd ..
-tmpdir=`mktemp -d rpmtmp.XXXXXX`
+tmpdir=`mktemp -d ${RPM_TMPDIR:-$TMP}/rpmtmp.XXXXXX`
 
 # We need to build a tarball for the SRPM using $builddir as the 
 # directory name (since that's what RPM will expect it to unpack
@@ -25,10 +33,13 @@
 (cd $tmpdir && tar czfh ${builddir}.tar.gz $EXCLUDE $builddir)
 
 [ "`rpmbuild --version 2> /dev/null`" ] && RPM=rpmbuild || RPM=rpm
-$RPM --define "_sourcedir `pwd`/$tmpdir" -ba $currdir/e2fsprogs.spec
-
-ret=$?
-rm -rf $tmpdir
-exit $?
 
+$RPM --define "_sourcedir $tmpdir" \
+     --define "_topdir ${RPM_TOPDIR:-$(rpm -E %_topdir)}" \
+     --define "_tmpdir ${RPM_TMPDIR:-$TMP}" \
+     --define "extra_config_flags ${EXTRA_CONFIG_FLAGS:-''}" \
+     -ba $currdir/e2fsprogs.spec
 
+rpm_exit=$?
+rm -rf $tmpdir
+exit $rpm_exit
e2fsprogs.spec.in +2 -1
diff -Naur e2fsprogs-1.40.2/e2fsprogs.spec.in e2fsprogs-1.40.2.new/e2fsprogs.spec.in
@@ -50,7 +50,8 @@
 %setup
 
 %build
-%configure --enable-elf-shlibs --enable-nls
+%configure --enable-elf-shlibs --enable-nls \
+	%{?extra_config_flags:%extra_config_flags}
 make
 
 %install

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#34 lore raw
In reply to Andreas Dilger
Quoted 7 lines · Andreas Dilger

The following series of emails will contain the large part of the e2fsprogs patch series that is used for Lustre. It will not contain the regression tests for EXTENTS nor the DIR_NLINK features, as those are very large and were previously submitted.

A full tarball that includes the patches, series, and regression tests will be uploaded to ftp://ftp.lustre.org/pub/lustre/other/e2fsprogs/

Hey Andreas,

I've applied these patches to the tip of "maint", and exported it as "e2fsprogs-interim" on the e2fsprogs git repository. There quite a few patch conflicts, mostly due to some changes that had happened on the tip of maint, but also apparently because your patchset was missing the flex bg changes. I haven't applied them yet, but I'll probably tack them at the end.

If you could sanity check to make sure they are sane, I would appreciate it.

- Ted

#35 lore raw
Quoted 18 lines · Theodore Tso
Quoted 7 lines · Andreas Dilger

The following series of emails will contain the large part of the e2fsprogs patch series that is used for Lustre. It will not contain the regression tests for EXTENTS nor the DIR_NLINK features, as those are very large and were previously submitted.

A full tarball that includes the patches, series, and regression tests will be uploaded to ftp://ftp.lustre.org/pub/lustre/other/e2fsprogs/

Hey Andreas,

I've applied these patches to the tip of "maint", and exported it as "e2fsprogs-interim" on the e2fsprogs git repository. There quite a few patch conflicts, mostly due to some changes that had happened on the tip of maint, but also apparently because your patchset was missing the flex bg changes. I haven't applied them yet, but I'll probably tack them at the end.

Quoted 3 lines

If you could sanity check to make sure they are sane, I would appreciate it.

Needed this diff to get it build

                from ../../../lib/ext2fs/crc16.h:18,
                 from ../../../lib/ext2fs/crc16.c:9:

/usr/include/sys/types.h:46: error: conflicting types for 'loff_t' /usr/include/linux/types.h:30: error: previous declaration of 'loff_t' was here /usr/include/sys/types.h:62: error: conflicting types for 'dev_t' /usr/include/linux/types.h:13: error: previous declaration of 'dev_t' was here In file included from /usr/include/sys/types.h:133,

                 from /usr/include/stdlib.h:438,
                 from ../../../lib/ext2fs/crc16.h:18,
                 from ../../../lib/ext2fs/crc16.c:9
lib/ext2fs/crc16.c +0 -1
index 5d87e10..246813f 100644
@@ -5,7 +5,6 @@
  * Version 2. See the file COPYING for more details.
  */
 
-#include <linux/types.h>
 #include "crc16.h"
 
 /** CRC table for the CRC-16. The poly is 0x8005 (x^16 + x^15 + x^2 + 1) */
#36 lore raw
In reply to Theodore Tso
Quoted 6 lines · Theodore Ts'o
Quoted 4 lines · Andreas Dilger

The following series of emails will contain the large part of the e2fsprogs patch series that is used for Lustre. It will not contain the regression tests for EXTENTS nor the DIR_NLINK features, as those are very large and were previously submitted.

Quoted 6 lines

I've applied these patches to the tip of "maint", and exported it as "e2fsprogs-interim" on the e2fsprogs git repository. There quite a few patch conflicts, mostly due to some changes that had happened on the tip of maint, but also apparently because your patchset was missing the flex bg changes. I haven't applied them yet, but I'll probably tack them at the end.

The patch was based on e2fsprogs-1.40.5. Also note that the majority of patches are intended for upstream inclusion, with the exception of the extents patches, which you are reworking.

Quoted 2 lines
Quoted 2 lines

A full tarball that includes the patches, series, and regression tests will be uploaded to ftp://ftp.lustre.org/pub/lustre/other/e2fsprogs/

This didn't work out, as our FTP site was subsumed into a Sun-hosted download site that week and I'm no longer able to make public-access uploads. I have to find some other location to host that tarball.

Quoted 2 lines

If you could sanity check to make sure they are sane, I would appreciate it.

I need to catch up from travelling last week, hopefully I'll get to it by the end of this week.

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.