From 3a78e12f100e43e2996976d06a95a1b8e61b33ff Mon Sep 17 00:00:00 2001 From: Hongchao Zhang Date: Tue, 17 Jan 2012 12:10:25 +0800 Subject: [PATCH] LU-931 mdd: store lu_fid instead of pointer in md_capainfo in md_capainfo, mc_fid contains at most 5 pointers to lu_fid, and if the corresponding lu_fid is freed, the pointer isn't notified about it, then the pointer will point to freed memory! Signed-off-by: Hongchao Zhang Change-Id: I00088cbfeb145ceac0477467a8b2436f6cf1e530 Reviewed-on: http://review.whamcloud.com/1979 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Mikhail Pershin Reviewed-by: wangdi Reviewed-by: Oleg Drokin --- lustre/include/md_object.h | 2 +- lustre/mdd/mdd_internal.h | 4 ++-- lustre/mdt/mdt_internal.h | 8 +++----- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lustre/include/md_object.h b/lustre/include/md_object.h index f44453a..cd52a7d 100644 --- a/lustre/include/md_object.h +++ b/lustre/include/md_object.h @@ -100,7 +100,7 @@ enum { struct md_capainfo { __u32 mc_auth; __u32 mc_padding; - const struct lu_fid *mc_fid[MD_CAPAINFO_MAX]; + struct lu_fid mc_fid[MD_CAPAINFO_MAX]; struct lustre_capa *mc_capa[MD_CAPAINFO_MAX]; }; diff --git a/lustre/mdd/mdd_internal.h b/lustre/mdd/mdd_internal.h index 84b6b04..4bdf444 100644 --- a/lustre/mdd/mdd_internal.h +++ b/lustre/mdd/mdd_internal.h @@ -603,7 +603,7 @@ static inline struct lustre_capa *mdd_object_capa(const struct lu_env *env, if (!ci) return BYPASS_CAPA; for (i = 0; i < MD_CAPAINFO_MAX; i++) - if (ci->mc_fid[i] && lu_fid_eq(ci->mc_fid[i], fid)) + if (lu_fid_eq(&ci->mc_fid[i], fid)) return ci->mc_capa[i]; return NULL; } @@ -619,7 +619,7 @@ static inline void mdd_set_capainfo(const struct lu_env *env, int offset, /* NB: in mdt_init0 */ if (!ci) return; - ci->mc_fid[offset] = fid; + ci->mc_fid[offset] = *fid; ci->mc_capa[offset] = capa; } diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index b2889ed..c96eebe 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -860,7 +860,7 @@ static inline void mdt_set_capainfo(struct mdt_thread_info *info, int offset, ci = md_capainfo(info->mti_env); LASSERT(ci); - ci->mc_fid[offset] = fid; + ci->mc_fid[offset] = *fid; ci->mc_capa[offset] = capa; } @@ -872,16 +872,14 @@ static inline void mdt_dump_capainfo(struct mdt_thread_info *info) if (!ci) return; for (i = 0; i < MD_CAPAINFO_MAX; i++) { - if (!ci->mc_fid[i]) - continue; if (!ci->mc_capa[i]) { CERROR("no capa for index %d "DFID"\n", - i, PFID(ci->mc_fid[i])); + i, PFID(&ci->mc_fid[i])); continue; } if (ci->mc_capa[i] == BYPASS_CAPA) { CERROR("bypass for index %d "DFID"\n", - i, PFID(ci->mc_fid[i])); + i, PFID(&ci->mc_fid[i])); continue; } DEBUG_CAPA(D_ERROR, ci->mc_capa[i], "index %d", i); -- 1.8.3.1