Whamcloud - gitweb
fix a memleak @lustre_md->mea in ll_prep_inode().
authorhuanghua <huanghua>
Tue, 28 Nov 2006 15:24:20 +0000 (15:24 +0000)
committerhuanghua <huanghua>
Tue, 28 Nov 2006 15:24:20 +0000 (15:24 +0000)
lustre/llite/llite_lib.c
lustre/lmv/lmv_obd.c
lustre/mdc/mdc_request.c

index bd0d66e..6283137 100644 (file)
@@ -412,7 +412,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
                 CERROR("md_getattr failed for root: rc = %d\n", err);
                 GOTO(out_dt_fid, err);
         }
-
+        memset(&lmd, 0, sizeof(lmd));
         err = md_get_lustre_md(sbi->ll_md_exp, request, 
                                REPLY_REC_OFF, sbi->ll_dt_exp, sbi->ll_md_exp, 
                                &lmd);
@@ -424,10 +424,18 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
 
         LASSERT(fid_is_sane(&sbi->ll_root_fid));
         root = ll_iget(sb, ll_fid_build_ino(sbi, &sbi->ll_root_fid), &lmd);
+        md_free_lustre_md(sbi->ll_md_exp, &lmd);
         ptlrpc_req_finished(request);
 
         if (root == NULL || is_bad_inode(root)) {
-                md_free_lustre_md(sbi->ll_dt_exp, &lmd);
+                if (lmd.lsm)
+                        obd_free_memmd(sbi->ll_dt_exp, &lmd.lsm);
+#ifdef CONFIG_FS_POSIX_ACL
+                if (lmd.posix_acl) {
+                        posix_acl_release(lmd.posix_acl);
+                        lmd.posix_acl = NULL;
+                }
+#endif
                 CERROR("lustre_lite: bad iget4 for root\n");
                 GOTO(out_root, err = -EBADF);
         }
@@ -2110,6 +2118,7 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req,
         LASSERT(*inode || sb);
         sbi = sb ? ll_s2sbi(sb) : ll_i2sbi(*inode);
         prune_deathrow(sbi, 1);
+        memset(&md, 0, sizeof(struct lustre_md));
 
         rc = md_get_lustre_md(sbi->ll_md_exp, req, offset,
                               sbi->ll_dt_exp, sbi->ll_md_exp, &md);
@@ -2129,7 +2138,14 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req,
 
                 *inode = ll_iget(sb, ll_fid_build_ino(sbi, &md.body->fid1), &md);
                 if (*inode == NULL || is_bad_inode(*inode)) {
-                        md_free_lustre_md(sbi->ll_dt_exp, &md);
+                        if (md.lsm)
+                                obd_free_memmd(sbi->ll_dt_exp, &md.lsm);
+#ifdef CONFIG_FS_POSIX_ACL
+                        if (md.posix_acl) {
+                                posix_acl_release(md.posix_acl);
+                                md.posix_acl = NULL;
+                        }
+#endif
                         rc = -ENOMEM;
                         CERROR("new_inode -fatal: rc %d\n", rc);
                         GOTO(out, rc);
@@ -2139,6 +2155,7 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req,
         rc = obd_checkmd(sbi->ll_dt_exp, sbi->ll_md_exp,
                          ll_i2info(*inode)->lli_smd);
 out:
+        md_free_lustre_md(sbi->ll_md_exp, &md);
         RETURN(rc);
 }
 
index a6b9f99..914f64d 100644 (file)
@@ -2465,6 +2465,7 @@ int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp,
 
         if (*lsmp != NULL && lmm == NULL) {
                 OBD_FREE(*tmea, mea_size);
+                *lsmp = NULL;
                 RETURN(0);
         }
 
@@ -2576,6 +2577,8 @@ int lmv_free_lustre_md(struct obd_export *exp, struct lustre_md *md)
         struct lmv_obd *lmv = &obd->u.lmv;
 
         ENTRY;
+        if (md->mea)
+                obd_free_memmd(exp, (struct lov_stripe_md**)&md->mea);
         RETURN(md_free_lustre_md(lmv->tgts[0].ltd_exp, md));
 }
 
index 83cf5c3..27abf45 100644 (file)
@@ -606,15 +606,6 @@ out:
 int mdc_free_lustre_md(struct obd_export *exp, struct lustre_md *md)
 {
         ENTRY;
-        if (md->lsm)
-                obd_free_memmd(exp, &md->lsm);
-
-#ifdef CONFIG_FS_POSIX_ACL
-        if (md->posix_acl) {
-                posix_acl_release(md->posix_acl);
-                md->posix_acl = NULL;
-        }
-#endif
         RETURN(0);
 }