Whamcloud - gitweb
LU-6142 lov: Fix style issues for lov_dev.c 34/33534/2
authorArshad Hussain <arshad.super@gmail.com>
Sun, 21 Oct 2018 17:57:29 +0000 (23:27 +0530)
committerOleg Drokin <green@whamcloud.com>
Tue, 6 Nov 2018 06:40:33 +0000 (06:40 +0000)
This patch fixes issues reported by checkpatch for file
lustre/lov/lov_dev.c

Change-Id: I93dabb01b939328494146a45ffcb88edf1ed066c
Test-Parameters: trivial
Signed-off-by: Arshad Hussain <arshad.super@gmail.com>
Reviewed-on: https://review.whamcloud.com/33534
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Ben Evans <bevans@cray.com>
lustre/lov/lov_dev.c

index 52f022f..1faef7a 100644 (file)
@@ -49,34 +49,34 @@ struct kmem_cache *lov_session_kmem;
 struct kmem_cache *lovsub_object_kmem;
 
 struct lu_kmem_descr lov_caches[] = {
 struct kmem_cache *lovsub_object_kmem;
 
 struct lu_kmem_descr lov_caches[] = {
-        {
-                .ckd_cache = &lov_lock_kmem,
-                .ckd_name  = "lov_lock_kmem",
-                .ckd_size  = sizeof (struct lov_lock)
-        },
-        {
-                .ckd_cache = &lov_object_kmem,
-                .ckd_name  = "lov_object_kmem",
-                .ckd_size  = sizeof (struct lov_object)
-        },
-        {
-                .ckd_cache = &lov_thread_kmem,
-                .ckd_name  = "lov_thread_kmem",
-                .ckd_size  = sizeof (struct lov_thread_info)
-        },
-        {
-                .ckd_cache = &lov_session_kmem,
-                .ckd_name  = "lov_session_kmem",
-                .ckd_size  = sizeof (struct lov_session)
-        },
-        {
-                .ckd_cache = &lovsub_object_kmem,
-                .ckd_name  = "lovsub_object_kmem",
-                .ckd_size  = sizeof (struct lovsub_object)
-        },
-        {
-                .ckd_cache = NULL
-        }
+       {
+               .ckd_cache = &lov_lock_kmem,
+               .ckd_name  = "lov_lock_kmem",
+               .ckd_size  = sizeof(struct lov_lock)
+       },
+       {
+               .ckd_cache = &lov_object_kmem,
+               .ckd_name  = "lov_object_kmem",
+               .ckd_size  = sizeof(struct lov_object)
+       },
+       {
+               .ckd_cache = &lov_thread_kmem,
+               .ckd_name  = "lov_thread_kmem",
+               .ckd_size  = sizeof(struct lov_thread_info)
+       },
+       {
+               .ckd_cache = &lov_session_kmem,
+               .ckd_name  = "lov_session_kmem",
+               .ckd_size  = sizeof(struct lov_session)
+       },
+       {
+               .ckd_cache = &lovsub_object_kmem,
+               .ckd_name  = "lovsub_object_kmem",
+               .ckd_size  = sizeof(struct lovsub_object)
+       },
+       {
+               .ckd_cache = NULL
+       }
 };
 
 /*****************************************************************************
 };
 
 /*****************************************************************************
@@ -91,7 +91,7 @@ static void *lov_key_init(const struct lu_context *ctx,
        struct lov_thread_info *info;
 
        OBD_SLAB_ALLOC_PTR_GFP(info, lov_thread_kmem, GFP_NOFS);
        struct lov_thread_info *info;
 
        OBD_SLAB_ALLOC_PTR_GFP(info, lov_thread_kmem, GFP_NOFS);
-       if (info == NULL)
+       if (!info)
                info = ERR_PTR(-ENOMEM);
        return info;
 }
                info = ERR_PTR(-ENOMEM);
        return info;
 }
@@ -104,9 +104,9 @@ static void lov_key_fini(const struct lu_context *ctx,
 }
 
 struct lu_context_key lov_key = {
 }
 
 struct lu_context_key lov_key = {
-        .lct_tags = LCT_CL_THREAD,
-        .lct_init = lov_key_init,
-        .lct_fini = lov_key_fini
+       .lct_tags = LCT_CL_THREAD,
+       .lct_init = lov_key_init,
+       .lct_fini = lov_key_fini
 };
 
 static void *lov_session_key_init(const struct lu_context *ctx,
 };
 
 static void *lov_session_key_init(const struct lu_context *ctx,
@@ -115,22 +115,23 @@ static void *lov_session_key_init(const struct lu_context *ctx,
        struct lov_session *info;
 
        OBD_SLAB_ALLOC_PTR_GFP(info, lov_session_kmem, GFP_NOFS);
        struct lov_session *info;
 
        OBD_SLAB_ALLOC_PTR_GFP(info, lov_session_kmem, GFP_NOFS);
-       if (info == NULL)
+       if (!info)
                info = ERR_PTR(-ENOMEM);
        return info;
 }
 
 static void lov_session_key_fini(const struct lu_context *ctx,
                info = ERR_PTR(-ENOMEM);
        return info;
 }
 
 static void lov_session_key_fini(const struct lu_context *ctx,
-                                 struct lu_context_key *key, void *data)
+                                struct lu_context_key *key, void *data)
 {
 {
-        struct lov_session *info = data;
-        OBD_SLAB_FREE_PTR(info, lov_session_kmem);
+       struct lov_session *info = data;
+
+       OBD_SLAB_FREE_PTR(info, lov_session_kmem);
 }
 
 struct lu_context_key lov_session_key = {
 }
 
 struct lu_context_key lov_session_key = {
-        .lct_tags = LCT_SESSION,
-        .lct_init = lov_session_key_init,
-        .lct_fini = lov_session_key_fini
+       .lct_tags = LCT_SESSION,
+       .lct_init = lov_session_key_init,
+       .lct_fini = lov_session_key_fini
 };
 
 /* type constructor/destructor: lov_type_{init,fini,start,stop}() */
 };
 
 /* type constructor/destructor: lov_type_{init,fini,start,stop}() */
@@ -161,14 +162,14 @@ static struct lu_device *lov_device_fini(const struct lu_env *env,
 
        LASSERT(ld->ld_lov != NULL);
 
 
        LASSERT(ld->ld_lov != NULL);
 
-       if (ld->ld_lmv != NULL) {
+       if (ld->ld_lmv) {
                class_decref(ld->ld_lmv, "lov", d);
                ld->ld_lmv = NULL;
        }
 
                class_decref(ld->ld_lmv, "lov", d);
                ld->ld_lmv = NULL;
        }
 
-       if (ld->ld_md_tgts != NULL) {
+       if (ld->ld_md_tgts) {
                for (i = 0; i < ld->ld_md_tgts_nr; i++) {
                for (i = 0; i < ld->ld_md_tgts_nr; i++) {
-                       if (ld->ld_md_tgts[i].ldm_mdc == NULL)
+                       if (!ld->ld_md_tgts[i].ldm_mdc)
                                continue;
 
                        cl_stack_fini(env, ld->ld_md_tgts[i].ldm_mdc);
                                continue;
 
                        cl_stack_fini(env, ld->ld_md_tgts[i].ldm_mdc);
@@ -177,12 +178,12 @@ static struct lu_device *lov_device_fini(const struct lu_env *env,
                }
        }
 
                }
        }
 
-       if (ld->ld_target != NULL) {
+       if (ld->ld_target) {
                lov_foreach_target(ld, i) {
                        struct lovsub_device *lsd;
 
                        lsd = ld->ld_target[i];
                lov_foreach_target(ld, i) {
                        struct lovsub_device *lsd;
 
                        lsd = ld->ld_target[i];
-                       if (lsd != NULL) {
+                       if (lsd) {
                                cl_stack_fini(env, lovsub2cl_dev(lsd));
                                ld->ld_target[i] = NULL;
                        }
                                cl_stack_fini(env, lovsub2cl_dev(lsd));
                                ld->ld_target[i] = NULL;
                        }
@@ -192,7 +193,7 @@ static struct lu_device *lov_device_fini(const struct lu_env *env,
 }
 
 static int lov_device_init(const struct lu_env *env, struct lu_device *d,
 }
 
 static int lov_device_init(const struct lu_env *env, struct lu_device *d,
-                           const char *name, struct lu_device *next)
+                          const char *name, struct lu_device *next)
 {
        struct lov_device *ld = lu2lov_dev(d);
        int i;
 {
        struct lov_device *ld = lu2lov_dev(d);
        int i;
@@ -206,7 +207,7 @@ static int lov_device_init(const struct lu_env *env, struct lu_device *d,
                mdc = ld->ld_lov->lov_mdc_tgts[i].lmtd_mdc;
                idx = ld->ld_lov->lov_mdc_tgts[i].lmtd_index;
 
                mdc = ld->ld_lov->lov_mdc_tgts[i].lmtd_mdc;
                idx = ld->ld_lov->lov_mdc_tgts[i].lmtd_index;
 
-               if (mdc == NULL)
+               if (!mdc)
                        continue;
 
                rc = lov_mdc_dev_init(env, ld, mdc->obd_lu_dev, idx, i);
                        continue;
 
                rc = lov_mdc_dev_init(env, ld, mdc->obd_lu_dev, idx, i);
@@ -218,7 +219,7 @@ static int lov_device_init(const struct lu_env *env, struct lu_device *d,
                }
        }
 
                }
        }
 
-       if (ld->ld_target == NULL)
+       if (!ld->ld_target)
                RETURN(0);
 
        lov_foreach_target(ld, i) {
                RETURN(0);
 
        lov_foreach_target(ld, i) {
@@ -227,7 +228,7 @@ static int lov_device_init(const struct lu_env *env, struct lu_device *d,
                struct lov_tgt_desc *desc;
 
                desc = ld->ld_lov->lov_tgts[i];
                struct lov_tgt_desc *desc;
 
                desc = ld->ld_lov->lov_tgts[i];
-               if (desc == NULL)
+               if (!desc)
                        continue;
 
                cl = cl_type_setup(env, &ld->ld_site, &lovsub_device_type,
                        continue;
 
                cl = cl_type_setup(env, &ld->ld_site, &lovsub_device_type,
@@ -248,7 +249,7 @@ out_err:
 
 /* Free the lov specific data created for the back end lu_device. */
 static struct lu_device *lov_device_free(const struct lu_env *env,
 
 /* Free the lov specific data created for the back end lu_device. */
 static struct lu_device *lov_device_free(const struct lu_env *env,
-                                         struct lu_device *d)
+                                        struct lu_device *d)
 {
        struct lov_device *ld = lu2lov_dev(d);
        const int nr = ld->ld_target_nr;
 {
        struct lov_device *ld = lu2lov_dev(d);
        const int nr = ld->ld_target_nr;
@@ -277,16 +278,17 @@ static struct lu_device *lov_device_free(const struct lu_env *env,
 }
 
 static void lov_cl_del_target(const struct lu_env *env, struct lu_device *dev,
 }
 
 static void lov_cl_del_target(const struct lu_env *env, struct lu_device *dev,
-                              __u32 index)
+                             __u32 index)
 {
 {
-        struct lov_device *ld = lu2lov_dev(dev);
-        ENTRY;
+       struct lov_device *ld = lu2lov_dev(dev);
 
 
-        if (ld->ld_target[index] != NULL) {
-                cl_stack_fini(env, lovsub2cl_dev(ld->ld_target[index]));
-                ld->ld_target[index] = NULL;
-        }
-        EXIT;
+       ENTRY;
+
+       if (ld->ld_target[index]) {
+               cl_stack_fini(env, lovsub2cl_dev(ld->ld_target[index]));
+               ld->ld_target[index] = NULL;
+       }
+       EXIT;
 }
 
 static int lov_expand_targets(const struct lu_env *env, struct lov_device *dev)
 }
 
 static int lov_expand_targets(const struct lu_env *env, struct lov_device *dev)
@@ -304,7 +306,7 @@ static int lov_expand_targets(const struct lu_env *env, struct lov_device *dev)
                const size_t sz = sizeof(newd[0]);
 
                OBD_ALLOC(newd, tgt_size * sz);
                const size_t sz = sizeof(newd[0]);
 
                OBD_ALLOC(newd, tgt_size * sz);
-               if (newd != NULL) {
+               if (newd) {
                        if (sub_size > 0) {
                                memcpy(newd, dev->ld_target, sub_size * sz);
                                OBD_FREE(dev->ld_target, sub_size * sz);
                        if (sub_size > 0) {
                                memcpy(newd, dev->ld_target, sub_size * sz);
                                OBD_FREE(dev->ld_target, sub_size * sz);
@@ -321,26 +323,27 @@ static int lov_expand_targets(const struct lu_env *env, struct lov_device *dev)
 }
 
 static int lov_cl_add_target(const struct lu_env *env, struct lu_device *dev,
 }
 
 static int lov_cl_add_target(const struct lu_env *env, struct lu_device *dev,
-                             __u32 index)
+                            __u32 index)
 {
 {
-        struct obd_device    *obd = dev->ld_obd;
-        struct lov_device    *ld  = lu2lov_dev(dev);
-        struct lov_tgt_desc  *tgt;
-        struct lovsub_device *lsd;
-        struct cl_device     *cl;
-        int rc;
-        ENTRY;
+       struct obd_device    *obd = dev->ld_obd;
+       struct lov_device    *ld  = lu2lov_dev(dev);
+       struct lov_tgt_desc  *tgt;
+       struct lovsub_device *lsd;
+       struct cl_device     *cl;
+       int rc;
+
+       ENTRY;
 
        lov_tgts_getref(obd);
 
 
        lov_tgts_getref(obd);
 
-        tgt = obd->u.lov.lov_tgts[index];
-        LASSERT(tgt != NULL);
-        LASSERT(tgt->ltd_obd != NULL);
+       tgt = obd->u.lov.lov_tgts[index];
+       LASSERT(tgt != NULL);
+       LASSERT(tgt->ltd_obd != NULL);
 
 
-        if (!tgt->ltd_obd->obd_set_up) {
-                CERROR("Target %s not set up\n", obd_uuid2str(&tgt->ltd_uuid));
-                RETURN(-EINVAL);
-        }
+       if (!tgt->ltd_obd->obd_set_up) {
+               CERROR("Target %s not set up\n", obd_uuid2str(&tgt->ltd_uuid));
+               RETURN(-EINVAL);
+       }
 
        rc = lov_expand_targets(env, ld);
        if (rc == 0 && ld->ld_flags & LOV_DEV_INITIALIZED) {
 
        rc = lov_expand_targets(env, ld);
        if (rc == 0 && ld->ld_flags & LOV_DEV_INITIALIZED) {
@@ -389,7 +392,8 @@ static int lov_add_mdc_target(const struct lu_env *env, struct lu_device *d,
 
        LASSERT(mdc != NULL);
        if (ld->ld_md_tgts_nr == LOV_MDC_TGT_MAX) {
 
        LASSERT(mdc != NULL);
        if (ld->ld_md_tgts_nr == LOV_MDC_TGT_MAX) {
-               /* If the maximum value of LOV_MDC_TGT_MAX will become too
+               /*
+                * If the maximum value of LOV_MDC_TGT_MAX will become too
                 * small then all MD target handling must be rewritten in LOD
                 * manner, check lod_add_device() and related functionality.
                 */
                 * small then all MD target handling must be rewritten in LOD
                 * manner, check lod_add_device() and related functionality.
                 */
@@ -398,9 +402,11 @@ static int lov_add_mdc_target(const struct lu_env *env, struct lu_device *d,
                RETURN(-ERANGE);
        }
 
                RETURN(-ERANGE);
        }
 
-       /* grab FLD from lmv, do that here, when first MDC is added
-        * to be sure LMV is set up and can be found */
-       if (ld->ld_lmv == NULL) {
+       /*
+        * grab FLD from lmv, do that here, when first MDC is added
+        * to be sure LMV is set up and can be found
+        */
+       if (!ld->ld_lmv) {
                next = 0;
                while ((lmv_obd = class_devices_in_group(&lov_obd->obd_uuid,
                                                         &next)) != NULL) {
                next = 0;
                while ((lmv_obd = class_devices_in_group(&lov_obd->obd_uuid,
                                                         &next)) != NULL) {
@@ -409,7 +415,7 @@ static int lov_add_mdc_target(const struct lu_env *env, struct lu_device *d,
                                     strlen(LUSTRE_LMV_NAME)) == 0))
                                break;
                }
                                     strlen(LUSTRE_LMV_NAME)) == 0))
                                break;
                }
-               if (lmv_obd == NULL) {
+               if (!lmv_obd) {
                        CERROR("%s: cannot find LMV OBD by UUID (%s)\n",
                               lov_obd->obd_name,
                               obd_uuid2str(&lmv_obd->obd_uuid));
                        CERROR("%s: cannot find LMV OBD by UUID (%s)\n",
                               lov_obd->obd_name,
                               obd_uuid2str(&lmv_obd->obd_uuid));
@@ -443,7 +449,7 @@ static int lov_add_mdc_target(const struct lu_env *env, struct lu_device *d,
 }
 
 static int lov_process_config(const struct lu_env *env,
 }
 
 static int lov_process_config(const struct lu_env *env,
-                              struct lu_device *d, struct lustre_cfg *cfg)
+                             struct lu_device *d, struct lustre_cfg *cfg)
 {
        struct obd_device *obd = d->ld_obd;
        int cmd;
 {
        struct obd_device *obd = d->ld_obd;
        int cmd;
@@ -471,11 +477,13 @@ static int lov_process_config(const struct lu_env *env,
                break;
        case LCFG_ADD_MDC:
        {
                break;
        case LCFG_ADD_MDC:
        {
-               struct obd_device       *mdc;
-               struct obd_uuid          tgt_uuid;
+               struct obd_device *mdc;
+               struct obd_uuid tgt_uuid;
 
 
-               /* modify_mdc_tgts add 0:lustre-clilmv  1:lustre-MDT0000_UUID
-                * 2:0  3:1  4:lustre-MDT0000-mdc_UUID */
+               /*
+                * modify_mdc_tgts add 0:lustre-clilmv  1:lustre-MDT0000_UUID
+                * 2:0  3:1  4:lustre-MDT0000-mdc_UUID
+                */
                if (LUSTRE_CFG_BUFLEN(cfg, 1) > sizeof(tgt_uuid.uuid))
                        GOTO(out, rc = -EINVAL);
 
                if (LUSTRE_CFG_BUFLEN(cfg, 1) > sizeof(tgt_uuid.uuid))
                        GOTO(out, rc = -EINVAL);
 
@@ -487,7 +495,7 @@ static int lov_process_config(const struct lu_env *env,
 
                mdc = class_find_client_obd(&tgt_uuid, LUSTRE_MDC_NAME,
                                            &obd->obd_uuid);
 
                mdc = class_find_client_obd(&tgt_uuid, LUSTRE_MDC_NAME,
                                            &obd->obd_uuid);
-               if (mdc == NULL)
+               if (!mdc)
                        GOTO(out, rc = -ENODEV);
                rc = lov_add_mdc_target(env, d, mdc, index);
                break;
                        GOTO(out, rc = -ENODEV);
                rc = lov_add_mdc_target(env, d, mdc, index);
                break;
@@ -499,38 +507,38 @@ out:
 }
 
 static const struct lu_device_operations lov_lu_ops = {
 }
 
 static const struct lu_device_operations lov_lu_ops = {
-        .ldo_object_alloc      = lov_object_alloc,
-        .ldo_process_config    = lov_process_config,
+       .ldo_object_alloc      = lov_object_alloc,
+       .ldo_process_config    = lov_process_config,
 };
 
 static struct lu_device *lov_device_alloc(const struct lu_env *env,
 };
 
 static struct lu_device *lov_device_alloc(const struct lu_env *env,
-                                          struct lu_device_type *t,
-                                          struct lustre_cfg *cfg)
+                                         struct lu_device_type *t,
+                                         struct lustre_cfg *cfg)
 {
 {
-        struct lu_device *d;
-        struct lov_device *ld;
-        struct obd_device *obd;
-        int rc;
+       struct lu_device *d;
+       struct lov_device *ld;
+       struct obd_device *obd;
+       int rc;
 
 
-        OBD_ALLOC_PTR(ld);
-        if (ld == NULL)
-                RETURN(ERR_PTR(-ENOMEM));
+       OBD_ALLOC_PTR(ld);
+       if (!ld)
+               RETURN(ERR_PTR(-ENOMEM));
 
        cl_device_init(&ld->ld_cl, t);
        d = lov2lu_dev(ld);
        d->ld_ops = &lov_lu_ops;
 
 
        cl_device_init(&ld->ld_cl, t);
        d = lov2lu_dev(ld);
        d->ld_ops = &lov_lu_ops;
 
-        /* setup the LOV OBD */
-        obd = class_name2obd(lustre_cfg_string(cfg, 0));
-        LASSERT(obd != NULL);
-        rc = lov_setup(obd, cfg);
+       /* setup the LOV OBD */
+       obd = class_name2obd(lustre_cfg_string(cfg, 0));
+       LASSERT(obd != NULL);
+       rc = lov_setup(obd, cfg);
        if (rc)
                GOTO(out, rc);
 
        /* Alloc MDC devices array */
        /* XXX: need dynamic allocation at some moment */
        OBD_ALLOC(ld->ld_md_tgts, sizeof(*ld->ld_md_tgts) * LOV_MDC_TGT_MAX);
        if (rc)
                GOTO(out, rc);
 
        /* Alloc MDC devices array */
        /* XXX: need dynamic allocation at some moment */
        OBD_ALLOC(ld->ld_md_tgts, sizeof(*ld->ld_md_tgts) * LOV_MDC_TGT_MAX);
-       if (ld->ld_md_tgts == NULL)
+       if (!ld->ld_md_tgts)
                GOTO(out, rc = -ENOMEM);
 
        ld->ld_md_tgts_nr = 0;
                GOTO(out, rc = -ENOMEM);
 
        ld->ld_md_tgts_nr = 0;
@@ -538,7 +546,7 @@ static struct lu_device *lov_device_alloc(const struct lu_env *env,
        ld->ld_lov = &obd->u.lov;
        OBD_ALLOC(ld->ld_lov->lov_mdc_tgts,
                  sizeof(*ld->ld_lov->lov_mdc_tgts) * LOV_MDC_TGT_MAX);
        ld->ld_lov = &obd->u.lov;
        OBD_ALLOC(ld->ld_lov->lov_mdc_tgts,
                  sizeof(*ld->ld_lov->lov_mdc_tgts) * LOV_MDC_TGT_MAX);
-       if (ld->ld_lov->lov_mdc_tgts == NULL)
+       if (!ld->ld_lov->lov_mdc_tgts)
                GOTO(out_md_tgts, rc = -ENOMEM);
 
        rc = lu_site_init(&ld->ld_site, d);
                GOTO(out_md_tgts, rc = -ENOMEM);
 
        rc = lu_site_init(&ld->ld_site, d);
@@ -566,24 +574,24 @@ out:
 }
 
 static const struct lu_device_type_operations lov_device_type_ops = {
 }
 
 static const struct lu_device_type_operations lov_device_type_ops = {
-        .ldto_init = lov_type_init,
-        .ldto_fini = lov_type_fini,
+       .ldto_init = lov_type_init,
+       .ldto_fini = lov_type_fini,
 
 
-        .ldto_start = lov_type_start,
-        .ldto_stop  = lov_type_stop,
+       .ldto_start = lov_type_start,
+       .ldto_stop  = lov_type_stop,
 
 
-        .ldto_device_alloc = lov_device_alloc,
-        .ldto_device_free  = lov_device_free,
+       .ldto_device_alloc = lov_device_alloc,
+       .ldto_device_free  = lov_device_free,
 
 
-        .ldto_device_init    = lov_device_init,
-        .ldto_device_fini    = lov_device_fini
+       .ldto_device_init    = lov_device_init,
+       .ldto_device_fini    = lov_device_fini
 };
 
 struct lu_device_type lov_device_type = {
 };
 
 struct lu_device_type lov_device_type = {
-        .ldt_tags     = LU_DEVICE_CL,
-        .ldt_name     = LUSTRE_LOV_NAME,
-        .ldt_ops      = &lov_device_type_ops,
-        .ldt_ctx_tags = LCT_CL_THREAD
+       .ldt_tags     = LU_DEVICE_CL,
+       .ldt_name     = LUSTRE_LOV_NAME,
+       .ldt_ops      = &lov_device_type_ops,
+       .ldt_ctx_tags = LCT_CL_THREAD
 };
 
 /** @} lov */
 };
 
 /** @} lov */