Whamcloud - gitweb
LU-6517 lmv: fix potential null pointer dereference
[fs/lustre-release.git] / lustre / lmv / lmv_obd.c
index fb990f8..5f16b32 100644 (file)
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/user_namespace.h>
+#ifdef HAVE_UIDGID_HEADER
+# include <linux/uidgid.h>
+#endif
 #include <linux/slab.h>
 #include <linux/pagemap.h>
 #include <linux/mm.h>
@@ -261,9 +265,8 @@ static int lmv_connect(const struct lu_env *env,
        RETURN(rc);
 }
 
-static int lmv_init_ea_size(struct obd_export *exp,
-                           __u32 easize, __u32 def_easize,
-                           __u32 cookiesize, __u32 def_cookiesize)
+static int lmv_init_ea_size(struct obd_export *exp, __u32 easize,
+                           __u32 def_easize)
 {
        struct obd_device       *obd = exp->exp_obd;
        struct lmv_obd          *lmv = &obd->u.lmv;
@@ -280,14 +283,7 @@ static int lmv_init_ea_size(struct obd_export *exp,
                 lmv->max_def_easize = def_easize;
                 change = 1;
         }
-        if (lmv->max_cookiesize < cookiesize) {
-                lmv->max_cookiesize = cookiesize;
-                change = 1;
-        }
-       if (lmv->max_def_cookiesize < def_cookiesize) {
-               lmv->max_def_cookiesize = def_cookiesize;
-               change = 1;
-       }
+
        if (change == 0)
                RETURN(0);
 
@@ -302,8 +298,7 @@ static int lmv_init_ea_size(struct obd_export *exp,
                        continue;
                }
 
-               rc = md_init_ea_size(tgt->ltd_exp, easize, def_easize,
-                                    cookiesize, def_cookiesize);
+               rc = md_init_ea_size(tgt->ltd_exp, easize, def_easize);
                if (rc) {
                        CERROR("%s: obd_init_ea_size() failed on MDT target %d:"
                               " rc = %d\n", obd->obd_name, i, rc);
@@ -388,8 +383,7 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
        tgt->ltd_exp = mdc_exp;
        lmv->desc.ld_active_tgt_count++;
 
-       md_init_ea_size(tgt->ltd_exp, lmv->max_easize, lmv->max_def_easize,
-                       lmv->max_cookiesize, lmv->max_def_cookiesize);
+       md_init_ea_size(tgt->ltd_exp, lmv->max_easize, lmv->max_def_easize);
 
        CDEBUG(D_CONFIG, "Connected to %s(%s) successfully (%d)\n",
                mdc_obd->obd_name, mdc_obd->obd_uuid.uuid,
@@ -518,7 +512,7 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
                } else {
                        int easize = sizeof(struct lmv_stripe_md) +
                                lmv->desc.ld_tgt_count * sizeof(struct lu_fid);
-                       lmv_init_ea_size(obd->obd_self_export, easize, 0, 0, 0);
+                       lmv_init_ea_size(obd->obd_self_export, easize, 0);
                }
        }
 
@@ -574,7 +568,7 @@ int lmv_check_connect(struct obd_device *obd)
        class_export_put(lmv->exp);
        lmv->connected = 1;
        easize = lmv_mds_md_size(lmv->desc.ld_tgt_count, LMV_MAGIC);
-       lmv_init_ea_size(obd->obd_self_export, easize, 0, 0, 0);
+       lmv_init_ea_size(obd->obd_self_export, easize, 0);
        mutex_unlock(&lmv->lmv_init_mutex);
        RETURN(0);
 
@@ -616,11 +610,11 @@ static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
                 mdc_obd->obd_force = obd->obd_force;
                 mdc_obd->obd_fail = obd->obd_fail;
                 mdc_obd->obd_no_recov = obd->obd_no_recov;
-        }
 
-       if (lmv->targets_proc_entry != NULL)
-               lprocfs_remove_proc_entry(mdc_obd->obd_name,
-                                         lmv->targets_proc_entry);
+               if (lmv->targets_proc_entry != NULL)
+                       lprocfs_remove_proc_entry(mdc_obd->obd_name,
+                                                 lmv->targets_proc_entry);
+       }
 
        rc = obd_fid_fini(tgt->ltd_exp->exp_obd);
        if (rc)
@@ -1171,9 +1165,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
                        mdc_obd = class_exp2obd(tgt->ltd_exp);
                        mdc_obd->obd_force = obddev->obd_force;
                        err = obd_iocontrol(cmd, tgt->ltd_exp, len, karg, uarg);
-                       if (err == -ENODATA && cmd == OBD_IOC_POLL_QUOTACHECK) {
-                               RETURN(err);
-                       } else if (err) {
+                       if (err) {
                                if (tgt->ltd_active) {
                                        CERROR("error: iocontrol MDC %s on MDT"
                                               " idx %d cmd %x: err = %d\n",
@@ -1371,7 +1363,6 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
        obd_str2uuid(&lmv->desc.ld_uuid, desc->ld_uuid.uuid);
        lmv->desc.ld_tgt_count = 0;
        lmv->desc.ld_active_tgt_count = 0;
-       lmv->max_cookiesize = 0;
        lmv->max_def_easize = 0;
        lmv->max_easize = 0;
        lmv->lmv_placement = PLACEMENT_CHAR_POLICY;
@@ -2759,8 +2750,7 @@ static int lmv_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
  * \retval negative    negated errno on failure
  */
 static int lmv_get_info(const struct lu_env *env, struct obd_export *exp,
-                        __u32 keylen, void *key, __u32 *vallen, void *val,
-                        struct lov_stripe_md *lsm)
+                       __u32 keylen, void *key, __u32 *vallen, void *val)
 {
         struct obd_device       *obd;
         struct lmv_obd          *lmv;
@@ -2792,14 +2782,12 @@ static int lmv_get_info(const struct lu_env *env, struct obd_export *exp,
                                continue;
 
                        if (!obd_get_info(env, tgt->ltd_exp, keylen, key,
-                                         vallen, val, NULL))
+                                         vallen, val))
                                RETURN(0);
                }
                RETURN(-EINVAL);
        } else if (KEY_IS(KEY_MAX_EASIZE) ||
                   KEY_IS(KEY_DEFAULT_EASIZE) ||
-                  KEY_IS(KEY_MAX_COOKIESIZE) ||
-                  KEY_IS(KEY_DEFAULT_COOKIESIZE) ||
                   KEY_IS(KEY_CONN_DATA)) {
                rc = lmv_check_connect(obd);
                if (rc)
@@ -2810,7 +2798,7 @@ static int lmv_get_info(const struct lu_env *env, struct obd_export *exp,
                 * desc.
                 */
                rc = obd_get_info(env, lmv->tgts[0]->ltd_exp, keylen, key,
-                                 vallen, val, NULL);
+                                 vallen, val);
                if (!rc && KEY_IS(KEY_CONN_DATA))
                        exp->exp_connect_data = *(struct obd_connect_data *)val;
                 RETURN(rc);
@@ -3445,32 +3433,6 @@ int lmv_quotactl(struct obd_device *unused, struct obd_export *exp,
         RETURN(rc);
 }
 
-int lmv_quotacheck(struct obd_device *unused, struct obd_export *exp,
-                   struct obd_quotactl *oqctl)
-{
-       struct obd_device       *obd = class_exp2obd(exp);
-       struct lmv_obd          *lmv = &obd->u.lmv;
-       struct lmv_tgt_desc     *tgt;
-       __u32                    i;
-       int                      rc = 0;
-       ENTRY;
-
-       for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
-               int err;
-               tgt = lmv->tgts[i];
-               if (tgt == NULL || tgt->ltd_exp == NULL || !tgt->ltd_active) {
-                       CERROR("lmv idx %d inactive\n", i);
-                       RETURN(-EIO);
-               }
-
-                err = obd_quotacheck(tgt->ltd_exp, oqctl);
-                if (err && !rc)
-                        rc = err;
-        }
-
-        RETURN(rc);
-}
-
 static int lmv_merge_attr(struct obd_export *exp,
                          const struct lmv_stripe_md *lsm,
                          struct cl_attr *attr,
@@ -3530,7 +3492,6 @@ struct obd_ops lmv_obd_ops = {
         .o_notify               = lmv_notify,
         .o_get_uuid             = lmv_get_uuid,
         .o_iocontrol            = lmv_iocontrol,
-        .o_quotacheck           = lmv_quotacheck,
         .o_quotactl             = lmv_quotactl
 };