[Pkg-lustre-svn-commit] updated: [a0fe8eb] bugzilla 21704 - lfsck doesn't work on pools

Patrick Winnertz winnie at debian.org
Thu Apr 19 12:54:40 UTC 2012


The following commit has been merged in the master branch:
commit a0fe8ebc7aaacb69117679403c9424cdea07520b
Author: Patrick Winnertz <winnie at debian.org>
Date:   Fri Sep 24 11:00:33 2010 +0200

    bugzilla 21704 - lfsck doesn't work on pools
    
    Signed-off-by: Patrick Winnertz <winnie at debian.org>

diff --git a/debian/patches/bug21704_mds_on_pools.patch b/debian/patches/bug21704_mds_on_pools.patch
new file mode 100644
index 0000000..b361bc2
--- /dev/null
+++ b/debian/patches/bug21704_mds_on_pools.patch
@@ -0,0 +1,287 @@
+diff -u e2fsprogs-1.41.12/e2fsck/lfsck.c e2fsprogs-1.41.12/e2fsck/lfsck.c
+--- e2fsprogs-1.41.12/e2fsck/lfsck.c
++++ e2fsprogs-1.41.12/e2fsck/lfsck.c
+@@ -922,7 +922,7 @@
+ 	}
+ 	lum->lmm_magic = LOV_USER_MAGIC;
+ 	lum->lmm_pattern = LOV_PATTERN_RAID0;
+-	lum->lmm_stripe_size = 65536;
++	lum->lmm_stripe_size = 1048576;
+ 	lum->lmm_stripe_offset = 0;
+ 	lum->lmm_stripe_count = 1;
+ 	lum->lmm_objects[0].l_object_id = ost_objid;
+@@ -1285,10 +1285,11 @@
+ 	return(rc);
+ }
+ 
+-int lfsck_validate_duplicate(__u64 mds_fid, const char *path,
+-			     __u32 ost_idx, __u64 ost_objid,
+-			     struct lov_user_md *lum)
++static int lfsck_validate_duplicate(__u64 mds_fid, const char *path,
++				    __u32 ost_idx, __u64 ost_objid)
+ {
++	struct lov_user_md *lum;
++	struct lov_user_ost_data_v1 *loi;
+ 	struct stat64 st;
+ 	int rc, i;
+ 
+@@ -1309,33 +1310,55 @@
+ 		return -EBADF;
+ 	}
+ 
++	lum = malloc(LOV_EA_MAX(lum));
++	if (lum == NULL) {
++		log_write("%s: out of memory allocating LOV EA (%u)\n",
++			  progname, LOV_EA_MAX(lum));
++		return -ENOMEM;
++	}
++
+ 	rc = llapi_file_get_stripe(path, lum);
+ 	if (rc < 0) {
+ 		log_write("%s: unable to get LOV EA on %s: %s\n",
+ 			  progname, path, strerror(-rc));
+-		return rc;
++		goto out;
+ 	}
+ 
+ 	if (lum->lmm_pattern != LOV_PATTERN_RAID0) {
+ 		log_write("%s: unknown LOV stripe pattern %#08x\n",
+ 			  progname, lum->lmm_pattern);
+-		return -EINVAL;
++		rc = -EINVAL;
++		goto out;
++	}
++
++	if (lum->lmm_magic == LOV_USER_MAGIC_V1) {
++		loi = lum->lmm_objects;
++	} else if (lum->lmm_magic == LOV_USER_MAGIC_V3) {
++		loi = ((struct lov_user_md_v3 *)lum)->lmm_objects;
++	} else {
++		log_write("%s: unknown LOV magic %#08x\n",
++			  progname, lum->lmm_magic);
++		rc = -EINVAL;
++		goto out;
+ 	}
+ 
+ 	/* Verify that the object in question is still in the file */
+-	for (i = 0; i < lum->lmm_stripe_count; i++){
+-		if (lum->lmm_objects[i].l_ost_idx == ost_idx &&
+-		    lum->lmm_objects[i].l_object_id == ost_objid)
++	for (i = 0; i < lum->lmm_stripe_count; i++, loi++) {
++		if (loi->l_ost_idx == ost_idx &&
++		    loi->l_object_id == ost_objid)
+ 			break;
+ 	}
+ 
+ 	if (i == lum->lmm_stripe_count) {
+ 		log_write("%s: couldn't find object %u:"LPU64" in\n"
+ 			  "\t%s\n", progname, ost_idx, ost_objid, path);
+-		return -EBADF;
++		rc = -EBADF;
++		goto out;
+ 	}
+ 
+-	return 0;
++out:
++	free(lum);
++	return rc;
+ }
+ 
+ #ifndef HAVE_LLAPI_CANCEL_OSC_LOCKS
+@@ -1387,7 +1410,6 @@
+ int lfsck_fix_duplicate(__u64 mds_fid, __u32 mds_generation,
+ 			__u32 ost_idx, __u64 ost_objid, DB *mds_direntdb)
+ {
+-	struct lov_user_md *lum;
+ 	char path_tmp[PATH_MAX] = { 0 }, path[PATH_MAX] = { 0 };
+ 	char tmp[PATH_MAX * 2 + 10] = { 0 };
+ 	const char *base;
+@@ -1410,14 +1432,7 @@
+ 		return 0;
+ 	}
+ 
+-	lum = malloc(LOV_EA_MAX(lum));
+-	if (lum == NULL) {
+-		log_write("%s: out of memory allocating LOV EA (%u)\n",
+-			  progname, LOV_EA_MAX(lum));
+-		return -ENOMEM;
+-	}
+-
+-	rc = lfsck_validate_duplicate(mds_fid, path, ost_idx, ost_objid, lum);
++	rc = lfsck_validate_duplicate(mds_fid, path, ost_idx, ost_objid);
+ 	if (rc < 0)
+ 		goto out;
+ 
+@@ -1466,7 +1481,6 @@
+ out:
+ 	VERBOSE(2, "unlink %s\n", path_tmp);
+ 	unlink(path_tmp);
+-	free(lum);
+ 
+ 	return rc;
+ }
+diff -u e2fsprogs-1.41.12/e2fsck/lfsck.h e2fsprogs-1.41.12/e2fsck/lfsck.h
+--- e2fsprogs-1.41.12/e2fsck/lfsck.h
++++ e2fsprogs-1.41.12/e2fsck/lfsck.h
+@@ -66,8 +66,7 @@
+ 
+ #define LOV_MAX_OSTS 2048       /* XXX - Not permanent, change */
+ #define LOV_EA_SIZE(lum, num) (sizeof(*lum) + num * sizeof(*lum->lmm_objects))
+-#define LOV_MAX_STRIPE_COUNT    160
+-#define LOV_EA_MAX(lum) LOV_EA_SIZE(lum, LOV_MAX_STRIPE_COUNT)
++#define LOV_EA_MAX(lum) LOV_EA_SIZE(lum, LOV_MAX_OSTS)
+ 
+ /*XXX*/
+ #define STRTOUL strtoul
+@@ -189,7 +188,7 @@
+ extern void letocpu_mds_objent(struct lfsck_mds_objent *mds_objent);
+ extern void cputole_ost_objent(struct lfsck_ost_objent *ost_objent);
+ extern void letocpu_ost_objent(struct lfsck_ost_objent *ost_objent);
+-extern void letocpu_lov_user_md_v1(struct lov_user_md_v1 *lmm);
++extern void letocpu_lov_user_md(struct lov_user_md *lmm);
+ 
+ #define MDS_START_DIRENT_TABLE sizeof(struct lfsck_mds_hdr)
+ 
+diff -u e2fsprogs-1.41.12/e2fsck/lfsck_common.c e2fsprogs-1.41.12/e2fsck/lfsck_common.c
+--- e2fsprogs-1.41.12/e2fsck/lfsck_common.c
++++ e2fsprogs-1.41.12/e2fsck/lfsck_common.c
+@@ -299,8 +299,9 @@
+ 	ost_objent->ost_bytes = ext2fs_le64_to_cpu(ost_objent->ost_bytes);
+ }
+ 
+-void letocpu_lov_user_md_v1(struct lov_user_md_v1 *lmm)
++void letocpu_lov_user_md(struct lov_user_md *lmm)
+ {
++	struct lov_user_ost_data_v1 *loi;
+ 	int i;
+ 
+ 	lmm->lmm_magic = ext2fs_le32_to_cpu(lmm->lmm_magic);
+@@ -309,15 +310,20 @@
+ 	lmm->lmm_object_gr = ext2fs_le64_to_cpu(lmm->lmm_object_gr);
+ 	lmm->lmm_stripe_size = ext2fs_le32_to_cpu(lmm->lmm_stripe_size);
+ 	lmm->lmm_stripe_count = ext2fs_le16_to_cpu(lmm->lmm_stripe_count);
+-	for (i = 0; i < lmm->lmm_stripe_count; i++) {
+-		lmm->lmm_objects[i].l_object_id =
+-			ext2fs_le64_to_cpu(lmm->lmm_objects[i].l_object_id);
+-		lmm->lmm_objects[i].l_object_gr =
+-			ext2fs_le64_to_cpu(lmm->lmm_objects[i].l_object_gr);
+-		lmm->lmm_objects[i].l_ost_gen =
+-			ext2fs_le32_to_cpu(lmm->lmm_objects[i].l_ost_gen);
+-		lmm->lmm_objects[i].l_ost_idx =
+-			ext2fs_le32_to_cpu(lmm->lmm_objects[i].l_ost_idx);
++	/* No swabbing needed for the lov_user_md_v3 lmm_pool_name */
++
++	if (lmm->lmm_magic == LOV_USER_MAGIC_V3)
++		loi = ((struct lov_user_md_v3 *)lmm)->lmm_objects;
++	else /* if (lmm->lmm_magic == LOV_USER_MAGIC_V1) */
++		loi = lmm->lmm_objects;
++	/* If there is a bad magic, this will be found immediately in the
++	 * call to lfsck_check_lov_ea() following this function. */
++
++	for (i = 0; i < lmm->lmm_stripe_count; i++, loi++) {
++		loi->l_object_id = ext2fs_le64_to_cpu(loi->l_object_id);
++		loi->l_object_gr = ext2fs_le64_to_cpu(loi->l_object_gr);
++		loi->l_ost_gen = ext2fs_le32_to_cpu(loi->l_ost_gen);
++		loi->l_ost_idx = ext2fs_le32_to_cpu(loi->l_ost_idx);
+ 	}
+ }
+ #endif
+diff -u e2fsprogs-1.41.12/e2fsck/pass6.c e2fsprogs-1.41.12/e2fsck/pass6.c
+--- e2fsprogs-1.41.12/e2fsck/pass6.c
++++ e2fsprogs-1.41.12/e2fsck/pass6.c
+@@ -214,12 +214,12 @@
+ }
+ 
+ static int e2fsck_lfsck_save_ea(e2fsck_t ctx, ext2_ino_t ino, __u32 generation,
+-				struct lov_user_md *mds_md)
++				struct lov_user_md *lmm)
+ {
+ 	ext2_filsys fs = ctx->fs;
+ 	struct lfsck_mds_szinfo szinfo;
++	struct lov_user_ost_data_v1 *loi;
+ 	__u64 mds_fid;
+-	__u32 stripe_count = 0;
+ 	int rc, i;
+ 	DBT key, data;
+ 	DB *dbp;
+@@ -269,14 +269,22 @@
+ 			lfsck_write_mds_hdrinfo(ctx, ctx->lfsck_oinfo);
+ 		}
+ 	}
++	if (lmm->lmm_magic == LOV_USER_MAGIC_V3)
++		loi = ((struct lov_user_md_v3 *)lmm)->lmm_objects;
++	else /* if (lmm->lmm_magic == LOV_USER_MAGIC_V1) */
++		loi = lmm->lmm_objects;
++
+ 	szinfo.mds_fid = ino;
+-	szinfo.mds_group = mds_md->lmm_object_gr;
+-	szinfo.mds_stripe_size = mds_md->lmm_stripe_size;
+-	szinfo.mds_stripe_start = mds_md->lmm_objects[0].l_ost_idx;
+-	szinfo.mds_stripe_count = mds_md->lmm_stripe_count;
++	/* XXX: We don't save the layout type here.  This doesn't matter for
++	 *      now, we don't really need the pool information for lfsck, but
++	 *      in the future we may need it for RAID-1 and other layouts. */
++	szinfo.mds_group = lmm->lmm_object_gr;
++	szinfo.mds_stripe_size = lmm->lmm_stripe_size;
++	szinfo.mds_stripe_start = loi->l_ost_idx;
++	szinfo.mds_stripe_count = lmm->lmm_stripe_count;
+ 	szinfo.mds_size = 0; /* XXX */
+ 	szinfo.mds_calc_size = 0;
+-	szinfo.mds_stripe_pattern = mds_md->lmm_pattern;
++	szinfo.mds_stripe_pattern = lmm->lmm_pattern;
+ 	memset(&key, 0, sizeof(key));
+ 	memset(&data, 0, sizeof(data));
+ 	mds_fid = szinfo.mds_fid;
+@@ -296,13 +304,12 @@
+ 		return (EIO);
+ 	}
+ #endif
+-	stripe_count = mds_md->lmm_stripe_count;
+-	for (i = 0; i < stripe_count; i++) {
+-		int ost_idx = mds_md->lmm_objects[i].l_ost_idx;
++	for (i = 0; i < lmm->lmm_stripe_count; i++, loi++) {
++		int ost_idx = loi->l_ost_idx;
+ 		struct lfsck_mds_objent mds_ent;
+ 		struct lfsck_ofile_ctx *ofile_ctx =
+ 					 &ctx->lfsck_oinfo->ofile_ctx[ost_idx];
+-		__u64 objid = mds_md->lmm_objects[i].l_object_id;
++		__u64 objid = loi->l_object_id;
+ 
+ 		if (ost_idx >= LOV_MAX_OSTS) {
+ 			fprintf(stderr, "invalid OST index %u ino %u[%d]\n",
+@@ -371,8 +378,9 @@
+ 
+ int lfsck_check_lov_ea(e2fsck_t ctx, struct lov_user_md *lmm)
+ {
+-	if (lmm->lmm_magic != LOV_USER_MAGIC_V1) {
+-		VERBOSE(ctx, "error: only handle v1 LOV EAs, not %08x\n",
++	if (lmm->lmm_magic != LOV_USER_MAGIC_V1 &&
++	    lmm->lmm_magic != LOV_USER_MAGIC_V3) {
++		VERBOSE(ctx, "error: only handle v1/v3 LOV EAs, not %08x\n",
+ 			lmm->lmm_magic);
+ 		return(-EINVAL);
+ 	}
+@@ -403,8 +411,8 @@
+ 
+ 	if (entry->e_name_index == EXT3_XATTR_INDEX_TRUSTED &&
+ 	    !strncmp(entry->e_name,XATTR_LUSTRE_MDS_LOV_EA,entry->e_name_len)){
+-		struct lov_user_md_v1 *lmm = value;
+-		letocpu_lov_user_md_v1(lmm);
++		struct lov_user_md *lmm = value;
++		letocpu_lov_user_md(lmm);
+ 
+ 		if (lfsck_check_lov_ea(ctx, lmm)) {
+ 			ctx->flags |= E2F_FLAG_ABORT;
+@@ -548,9 +556,10 @@
+ 
+ 	objent.ost_objid = objid;
+ 	objent.ost_flag = 0;
+-	objent.ost_size = inode.i_size;
+ 	if (LINUX_S_ISREG(inode.i_mode))
+-		objent.ost_size |= (__u64)inode.i_size_high << 32;
++		objent.ost_size = EXT2_I_SIZE(inode);
++	else
++		objent.ost_size = inode.i_size;
+ 	objent.ost_bytes = (__u64)inode.i_blocks * 512;
+ 
+ 	memset(&key, 0, sizeof(key));
diff --git a/debian/patches/series b/debian/patches/series
index 643518a..21fb004 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -31,3 +31,4 @@ e2fsprogs-add-io_channel_readahead.patch
 e2fsprogs-e2scan.patch 
 e2fsprogs-fid_in_dirent.patch
 static-linking.patch
+bug21704_mds_on_pools.patch

-- 
Repository for maintaining lidskfsprogs



More information about the Pkg-lustre-svn-commit mailing list