Whamcloud - gitweb
LU-931 mdd: store lu_fid instead of pointer in md_capainfo
authorHongchao Zhang <hongchao.zhang@whamcloud.com>
Tue, 17 Jan 2012 04:10:25 +0000 (12:10 +0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 28 Mar 2012 03:59:30 +0000 (23:59 -0400)
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 <hongchao.zhang@whamcloud.com>
Change-Id: I00088cbfeb145ceac0477467a8b2436f6cf1e530
Reviewed-on: http://review.whamcloud.com/1979
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Mikhail Pershin <tappro@whamcloud.com>
Reviewed-by: wangdi <di.wang@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/md_object.h
lustre/mdd/mdd_internal.h
lustre/mdt/mdt_internal.h

index d4c5b66..ba8b711 100644 (file)
@@ -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];
 };
 
index c4cc4a4..34ebc3d 100644 (file)
@@ -622,7 +622,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;
 }
@@ -638,7 +638,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;
 }
 
index eefc76c..bc4618a 100644 (file)
@@ -857,7 +857,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;
 }
 
@@ -869,16 +869,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);