From: Bobi Jam Date: Wed, 23 Jan 2013 03:08:10 +0000 (+0800) Subject: LU-2590 obdclass: correct swab lov_mds_md X-Git-Tag: 2.3.61~13 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=11ae0dc7cdb2a2417b988f7970ad26c3ac1002aa LU-2590 obdclass: correct swab lov_mds_md For caller's convenience, the 2nd parameter of obd_free_diskmd() could be host endianness, it needs swab to LE if necessary, while just lov_mds_md header needs it for figuring out how much memory needs to be freed. Signed-off-by: Bobi Jam Change-Id: I537e83b56b4be6e08a7431bfda1de71efefa33ee Reviewed-on: http://review.whamcloud.com/5145 Tested-by: Hudson Reviewed-by: Prakash Surya Reviewed-by: Andreas Dilger Tested-by: Maloo --- diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index 944c602..c39825c 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -753,11 +753,21 @@ static inline int obd_alloc_diskmd(struct obd_export *exp, } static inline int obd_free_diskmd(struct obd_export *exp, - struct lov_mds_md **disk_tgt) -{ - LASSERT(disk_tgt); - LASSERT(*disk_tgt); - return obd_packmd(exp, disk_tgt, NULL); + struct lov_mds_md **disk_tgt) +{ + LASSERT(disk_tgt); + LASSERT(*disk_tgt); + /* + * LU-2590, for caller's convenience, *disk_tgt could be host + * endianness, it needs swab to LE if necessary, while just + * lov_mds_md header needs it for figuring out how much memory + * needs to be freed. + */ + if ((cpu_to_le32(LOV_MAGIC) != LOV_MAGIC) && + (((*disk_tgt)->lmm_magic == LOV_MAGIC_V1) || + ((*disk_tgt)->lmm_magic == LOV_MAGIC_V3))) + lustre_swab_lov_mds_md(*disk_tgt); + return obd_packmd(exp, disk_tgt, NULL); } /* Unpack an MD struct from disk to in-memory format.