[PATCH-RESEND 10/23] staging/lustre/lov: only dump header in lsm_lmm_verify

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Andreas Dilger <andreas.dilger@xxxxxxxxx>

If lsm_lmm_verify_*() find an error in the lov_mds_md header
structure, don't dump the full stripe information, since this
can be totally bogus (e.g. if stripe_count == -1 or similar).
Instead, just dump the header information for debugging.

Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3271
Lustre-change: http://review.whamcloud.com/6261
Signed-off-by: Andreas Dilger <andreas.dilger@xxxxxxxxx>
Reviewed-by: Bob Glossman <bob.glossman@xxxxxxxxx>
Reviewed-by: John Hammond <johnlockwoodhammond@xxxxxxxxx>
Reviewed-by: Oleg Drokin <oleg.drokin@xxxxxxxxx>
Signed-off-by: Peng Tao <tao.peng@xxxxxxx>
Signed-off-by: Andreas Dilger <andreas.dilger@xxxxxxxxx>
---
 drivers/staging/lustre/lustre/lov/lov_ea.c       |   15 +++++++--------
 drivers/staging/lustre/lustre/lov/lov_internal.h |    1 +
 drivers/staging/lustre/lustre/lov/lov_pack.c     |    3 ++-
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c b/drivers/staging/lustre/lustre/lov/lov_ea.c
index 481e863..340dbcf 100644
--- a/drivers/staging/lustre/lustre/lov/lov_ea.c
+++ b/drivers/staging/lustre/lustre/lov/lov_ea.c
@@ -57,30 +57,29 @@ struct lovea_unpack_args {
 static int lsm_lmm_verify_common(struct lov_mds_md *lmm, int lmm_bytes,
 				 __u16 stripe_count)
 {
-
 	if (stripe_count == 0 || stripe_count > LOV_V1_INSANE_STRIPE_COUNT) {
 		CERROR("bad stripe count %d\n", stripe_count);
-		lov_dump_lmm(D_WARNING, lmm);
+		lov_dump_lmm_common(D_WARNING, lmm);
 		return -EINVAL;
 	}
 
 	if (lmm_oi_id(&lmm->lmm_oi) == 0) {
 		CERROR("zero object id\n");
-		lov_dump_lmm(D_WARNING, lmm);
+		lov_dump_lmm_common(D_WARNING, lmm);
 		return -EINVAL;
 	}
 
 	if (lmm->lmm_pattern != cpu_to_le32(LOV_PATTERN_RAID0)) {
 		CERROR("bad striping pattern\n");
-		lov_dump_lmm(D_WARNING, lmm);
+		lov_dump_lmm_common(D_WARNING, lmm);
 		return -EINVAL;
 	}
 
 	if (lmm->lmm_stripe_size == 0 ||
-	     (le32_to_cpu(lmm->lmm_stripe_size)&(LOV_MIN_STRIPE_SIZE-1)) != 0) {
+	    (le32_to_cpu(lmm->lmm_stripe_size)&(LOV_MIN_STRIPE_SIZE-1)) != 0) {
 		CERROR("bad stripe size %u\n",
 		       le32_to_cpu(lmm->lmm_stripe_size));
-		lov_dump_lmm(D_WARNING, lmm);
+		lov_dump_lmm_common(D_WARNING, lmm);
 		return -EINVAL;
 	}
 	return 0;
@@ -202,7 +201,7 @@ static int lsm_lmm_verify_v1(struct lov_mds_md_v1 *lmm, int lmm_bytes,
 	if (lmm_bytes < lov_mds_md_size(*stripe_count, LOV_MAGIC_V1)) {
 		CERROR("LOV EA V1 too small: %d, need %d\n",
 		       lmm_bytes, lov_mds_md_size(*stripe_count, LOV_MAGIC_V1));
-		lov_dump_lmm_v1(D_WARNING, lmm);
+		lov_dump_lmm_common(D_WARNING, lmm);
 		return -EINVAL;
 	}
 
@@ -272,7 +271,7 @@ static int lsm_lmm_verify_v3(struct lov_mds_md *lmmv1, int lmm_bytes,
 	if (lmm_bytes < lov_mds_md_size(*stripe_count, LOV_MAGIC_V3)) {
 		CERROR("LOV EA V3 too small: %d, need %d\n",
 		       lmm_bytes, lov_mds_md_size(*stripe_count, LOV_MAGIC_V3));
-		lov_dump_lmm_v3(D_WARNING, lmm);
+		lov_dump_lmm_common(D_WARNING, lmm);
 		return -EINVAL;
 	}
 
diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h
index 146d5e3..16770d1 100644
--- a/drivers/staging/lustre/lustre/lov/lov_internal.h
+++ b/drivers/staging/lustre/lustre/lov/lov_internal.h
@@ -271,6 +271,7 @@ int lov_free_memmd(struct lov_stripe_md **lsmp);
 
 void lov_dump_lmm_v1(int level, struct lov_mds_md_v1 *lmm);
 void lov_dump_lmm_v3(int level, struct lov_mds_md_v3 *lmm);
+void lov_dump_lmm_common(int level, void *lmmp);
 void lov_dump_lmm(int level, void *lmm);
 
 /* lov_ea.c */
diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c
index 8bb57aa..492948a 100644
--- a/drivers/staging/lustre/lustre/lov/lov_pack.c
+++ b/drivers/staging/lustre/lustre/lov/lov_pack.c
@@ -51,7 +51,7 @@
 
 #include "lov_internal.h"
 
-static void lov_dump_lmm_common(int level, void *lmmp)
+void lov_dump_lmm_common(int level, void *lmmp)
 {
 	struct lov_mds_md *lmm = lmmp;
 	struct ost_id	oi;
@@ -74,6 +74,7 @@ static void lov_dump_lmm_objects(int level, struct lov_ost_data *lod,
 	if (stripe_count > LOV_V1_INSANE_STRIPE_COUNT) {
 		CDEBUG(level, "bad stripe_count %u > max_stripe_count %u\n",
 		       stripe_count, LOV_V1_INSANE_STRIPE_COUNT);
+		return;
 	}
 
 	for (i = 0; i < stripe_count; ++i, ++lod) {
-- 
1.7.9.5

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux