From 422ac1e37a1686e503d60a95aa2ac3a8fa13bd17 Mon Sep 17 00:00:00 2001 From: Henri Doreau Date: Tue, 16 Sep 2014 12:34:07 +0200 Subject: [PATCH] LU-5631 obdclass: Proper swabbing of llog_rec_tail. A variable-length structure preceeds llog_rec_tail within an llog block. Thus cr_tail shouldn't be accessed directly as a structure member but its actual location should be computed dynamically. Signed-off-by: Henri Doreau Change-Id: I2d244797d107cf52f647e19b2db780138e910925 Reviewed-on: http://review.whamcloud.com/11937 Tested-by: Jenkins Reviewed-by: jacques-Charles Lafoucriere Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/obdclass/llog_swab.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/lustre/obdclass/llog_swab.c b/lustre/obdclass/llog_swab.c index a647a4b..25e249a 100644 --- a/lustre/obdclass/llog_swab.c +++ b/lustre/obdclass/llog_swab.c @@ -171,16 +171,17 @@ void lustre_swab_llog_rec(struct llog_rec_hdr *rec) } case CHANGELOG_REC: { - struct llog_changelog_rec *cr = (struct llog_changelog_rec*)rec; - - __swab16s(&cr->cr.cr_namelen); - __swab16s(&cr->cr.cr_flags); - __swab32s(&cr->cr.cr_type); - __swab64s(&cr->cr.cr_index); - __swab64s(&cr->cr.cr_prev); - __swab64s(&cr->cr.cr_time); - lustre_swab_lu_fid(&cr->cr.cr_tfid); - lustre_swab_lu_fid(&cr->cr.cr_pfid); + struct llog_changelog_rec *cr = + (struct llog_changelog_rec *)rec; + + __swab16s(&cr->cr.cr_namelen); + __swab16s(&cr->cr.cr_flags); + __swab32s(&cr->cr.cr_type); + __swab64s(&cr->cr.cr_index); + __swab64s(&cr->cr.cr_prev); + __swab64s(&cr->cr.cr_time); + lustre_swab_lu_fid(&cr->cr.cr_tfid); + lustre_swab_lu_fid(&cr->cr.cr_pfid); if (CHANGELOG_REC_EXTENDED(&cr->cr)) { struct llog_changelog_ext_rec *ext = (struct llog_changelog_ext_rec *)rec; @@ -191,8 +192,10 @@ void lustre_swab_llog_rec(struct llog_rec_hdr *rec) } else { tail = &cr->cr_tail; } - break; - } + tail = (struct llog_rec_tail *)((char *)tail + + cr->cr.cr_namelen); + break; + } case CHANGELOG_USER_REC: { struct llog_changelog_user_rec *cur = @@ -275,10 +278,10 @@ void lustre_swab_llog_rec(struct llog_rec_hdr *rec) rec->lrh_type, rec); } - if (tail) { - __swab32s(&tail->lrt_len); - __swab32s(&tail->lrt_index); - } + if (tail) { + __swab32s(&tail->lrt_len); + __swab32s(&tail->lrt_index); + } } EXPORT_SYMBOL(lustre_swab_llog_rec); -- 1.8.3.1