Whamcloud - gitweb
LU-9679 various: use OBD_ALLOC_PTR_ARRAY() and others 50/38250/8
authorMr NeilBrown <neilb@suse.de>
Thu, 14 Nov 2019 03:20:01 +0000 (14:20 +1100)
committerOleg Drokin <green@whamcloud.com>
Thu, 14 May 2020 05:38:45 +0000 (05:38 +0000)
Use:
  OBD_ALLOC_PTR_ARRAY
  OBD_FREE_PTR_ARRAY
  OBD_ALLOC_PTR_ARRAY_LARGE
  OBD_FREE_PTR_ARRAY_LARGE

for allocating and freeing arrays in various modules.

Test-Parameters: trivial
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I0c65759e99fde15168f190ea74cd88b3cb01f667
Reviewed-on: https://review.whamcloud.com/38250
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Yang Sheng <ys@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
16 files changed:
lustre/include/lustre_compat.h
lustre/lfsck/lfsck_engine.c
lustre/lfsck/lfsck_striped_dir.c
lustre/llite/dir.c
lustre/llite/rw26.c
lustre/lmv/lmv_obd.c
lustre/mdc/mdc_request.c
lustre/mgc/mgc_request.c
lustre/mgs/mgs_nids.c
lustre/obdecho/echo_client.c
lustre/ofd/ofd_objects.c
lustre/osc/osc_request.c
lustre/osp/osp_object.c
lustre/osp/osp_sync.c
lustre/quota/qmt_lock.c
lustre/quota/qsd_reint.c

index 89b3ad1..bf73cc2 100644 (file)
@@ -319,7 +319,7 @@ __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *iter)
                struct iovec *iov_copy;
                int count = 0;
 
                struct iovec *iov_copy;
                int count = 0;
 
-               OBD_ALLOC(iov_copy, sizeof(*iov_copy) * iter->nr_segs);
+               OBD_ALLOC_PTR_ARRAY(iov_copy, iter->nr_segs);
                if (!iov_copy)
                        return -ENOMEM;
 
                if (!iov_copy)
                        return -ENOMEM;
 
@@ -328,7 +328,7 @@ __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *iter)
 
                bytes = __generic_file_aio_write(iocb, iov_copy, count,
                                                 &iocb->ki_pos);
 
                bytes = __generic_file_aio_write(iocb, iov_copy, count,
                                                 &iocb->ki_pos);
-               OBD_FREE(iov_copy, sizeof(*iov_copy) * iter->nr_segs);
+               OBD_FREE_PTR_ARRAY(iov_copy, iter->nr_segs);
 
                if (bytes > 0)
                        iov_iter_advance(iter, bytes);
 
                if (bytes > 0)
                        iov_iter_advance(iter, bytes);
index 3be7606..f278c1d 100644 (file)
@@ -274,7 +274,7 @@ static int lfsck_load_stripe_lmv(const struct lu_env *env,
                else
                        stripes = lmv->lmv_stripe_count;
 
                else
                        stripes = lmv->lmv_stripe_count;
 
-               OBD_ALLOC_LARGE(lslr, sizeof(*lslr) * stripes);
+               OBD_ALLOC_PTR_ARRAY_LARGE(lslr, stripes);
                if (lslr == NULL) {
                        OBD_FREE_PTR(llmv);
 
                if (lslr == NULL) {
                        OBD_FREE_PTR(llmv);
 
index b2459af..2e7bef7 100644 (file)
@@ -168,14 +168,13 @@ void lfsck_lmv_put(const struct lu_env *env, struct lfsck_lmv *llmv)
 
                        LASSERT(llmv->ll_lslr != NULL);
 
 
                        LASSERT(llmv->ll_lslr != NULL);
 
-                       OBD_FREE_LARGE(llmv->ll_lslr,
-                                      sizeof(*llmv->ll_lslr) *
-                                      llmv->ll_stripes_allocated);
+                       OBD_FREE_PTR_ARRAY_LARGE(llmv->ll_lslr,
+                                                llmv->ll_stripes_allocated);
                        OBD_FREE_PTR(llu);
                } else {
                        if (llmv->ll_lslr != NULL)
                        OBD_FREE_PTR(llu);
                } else {
                        if (llmv->ll_lslr != NULL)
-                               OBD_FREE_LARGE(llmv->ll_lslr,
-                                       sizeof(*llmv->ll_lslr) *
+                               OBD_FREE_PTR_ARRAY_LARGE(
+                                       llmv->ll_lslr,
                                        llmv->ll_stripes_allocated);
 
                        OBD_FREE_PTR(llmv);
                                        llmv->ll_stripes_allocated);
 
                        OBD_FREE_PTR(llmv);
@@ -510,7 +509,7 @@ static int lfsck_record_lmv(const struct lu_env *env,
                int new_stripes = index + 1;
                size_t old_size = sizeof(*lslr) * llmv->ll_stripes_allocated;
 
                int new_stripes = index + 1;
                size_t old_size = sizeof(*lslr) * llmv->ll_stripes_allocated;
 
-               OBD_ALLOC_LARGE(new_lslr, sizeof(*new_lslr) * new_stripes);
+               OBD_ALLOC_PTR_ARRAY_LARGE(new_lslr, new_stripes);
                if (new_lslr == NULL) {
                        llmv->ll_failed = 1;
 
                if (new_lslr == NULL) {
                        llmv->ll_failed = 1;
 
@@ -1360,7 +1359,7 @@ int lfsck_namespace_notify_lmv_master_local(const struct lu_env *env,
        else
                count = lmv4->lmv_stripe_count;
 
        else
                count = lmv4->lmv_stripe_count;
 
-       OBD_ALLOC_LARGE(lslr, sizeof(*lslr) * count);
+       OBD_ALLOC_PTR_ARRAY_LARGE(lslr, count);
        if (lslr == NULL) {
                OBD_FREE_PTR(llu);
 
        if (lslr == NULL) {
                OBD_FREE_PTR(llu);
 
index 66a72f7..cf6e43c 100644 (file)
@@ -1274,7 +1274,7 @@ int ll_rmfid(struct file *file, void __user *arg)
        OBD_ALLOC(lfa, size);
        if (!lfa)
                RETURN(-ENOMEM);
        OBD_ALLOC(lfa, size);
        if (!lfa)
                RETURN(-ENOMEM);
-       OBD_ALLOC(rcs, sizeof(int) * nr);
+       OBD_ALLOC_PTR_ARRAY(rcs, nr);
        if (!rcs)
                GOTO(free_lfa, rc = -ENOMEM);
 
        if (!rcs)
                GOTO(free_lfa, rc = -ENOMEM);
 
@@ -1292,7 +1292,7 @@ int ll_rmfid(struct file *file, void __user *arg)
        }
 
 free_rcs:
        }
 
 free_rcs:
-       OBD_FREE(rcs, sizeof(int) * nr);
+       OBD_FREE_PTR_ARRAY(rcs, nr);
 free_lfa:
        OBD_FREE(lfa, size);
 
 free_lfa:
        OBD_FREE(lfa, size);
 
index 7507d6e..6e889a1 100644 (file)
@@ -185,7 +185,7 @@ static void ll_free_user_pages(struct page **pages, int npages)
 #if defined(HAVE_DIO_ITER)
        kvfree(pages);
 #else
 #if defined(HAVE_DIO_ITER)
        kvfree(pages);
 #else
-       OBD_FREE_LARGE(pages, npages * sizeof(*pages));
+       OBD_FREE_PTR_ARRAY_LARGE(pages, npages);
 #endif
 }
 
 #endif
 }
 
@@ -224,7 +224,7 @@ static ssize_t ll_get_user_pages(int rw, struct iov_iter *iter,
 
        size = min_t(size_t, maxsize, iter->iov->iov_len);
        page_count = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
 
        size = min_t(size_t, maxsize, iter->iov->iov_len);
        page_count = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
-       OBD_ALLOC_LARGE(*pages, page_count * sizeof(**pages));
+       OBD_ALLOC_PTR_ARRAY_LARGE(*pages, page_count);
        if (*pages == NULL)
                return -ENOMEM;
 
        if (*pages == NULL)
                return -ENOMEM;
 
index 25b09c4..421a9b7 100644 (file)
@@ -2936,10 +2936,10 @@ static int lmv_rmfid(struct obd_export *exp, struct fid_array *fa,
        }
 
        /* split FIDs by targets */
        }
 
        /* split FIDs by targets */
-       OBD_ALLOC(fas, sizeof(fas) * tgt_count);
+       OBD_ALLOC_PTR_ARRAY(fas, tgt_count);
        if (fas == NULL)
                GOTO(out, rc = -ENOMEM);
        if (fas == NULL)
                GOTO(out, rc = -ENOMEM);
-       OBD_ALLOC(rcs, sizeof(int *) * tgt_count);
+       OBD_ALLOC_PTR_ARRAY(rcs, tgt_count);
        if (rcs == NULL)
                GOTO(out_fas, rc = -ENOMEM);
 
        if (rcs == NULL)
                GOTO(out_fas, rc = -ENOMEM);
 
@@ -2959,7 +2959,7 @@ static int lmv_rmfid(struct obd_export *exp, struct fid_array *fa,
                if (!fas[idx])
                        GOTO(out, rc = -ENOMEM);
                if (!rcs[idx])
                if (!fas[idx])
                        GOTO(out, rc = -ENOMEM);
                if (!rcs[idx])
-                       OBD_ALLOC(rcs[idx], sizeof(int) * fa->fa_nr);
+                       OBD_ALLOC_PTR_ARRAY(rcs[idx], fa->fa_nr);
                if (!rcs[idx])
                        GOTO(out, rc = -ENOMEM);
 
                if (!rcs[idx])
                        GOTO(out, rc = -ENOMEM);
 
@@ -2998,13 +2998,13 @@ out:
                        OBD_FREE(fas[i], offsetof(struct fid_array,
                                                fa_fids[fa->fa_nr]));
                if (rcs && rcs[i])
                        OBD_FREE(fas[i], offsetof(struct fid_array,
                                                fa_fids[fa->fa_nr]));
                if (rcs && rcs[i])
-                       OBD_FREE(rcs[i], sizeof(int) * fa->fa_nr);
+                       OBD_FREE_PTR_ARRAY(rcs[i], fa->fa_nr);
        }
        if (rcs)
        }
        if (rcs)
-               OBD_FREE(rcs, sizeof(int *) * tgt_count);
+               OBD_FREE_PTR_ARRAY(rcs, tgt_count);
 out_fas:
        if (fas)
 out_fas:
        if (fas)
-               OBD_FREE(fas, sizeof(fas) * tgt_count);
+               OBD_FREE_PTR_ARRAY(fas, tgt_count);
 
        RETURN(rc);
 }
 
        RETURN(rc);
 }
index 233be24..79c127c 100644 (file)
@@ -1347,7 +1347,7 @@ static int mdc_read_page_remote(void *data, struct page *page0)
        fid = &op_data->op_fid1;
        LASSERT(inode != NULL);
 
        fid = &op_data->op_fid1;
        LASSERT(inode != NULL);
 
-       OBD_ALLOC(page_pool, sizeof(page_pool[0]) * max_pages);
+       OBD_ALLOC_PTR_ARRAY(page_pool, max_pages);
        if (page_pool != NULL) {
                page_pool[0] = page0;
        } else {
        if (page_pool != NULL) {
                page_pool[0] = page0;
        } else {
@@ -1416,7 +1416,7 @@ static int mdc_read_page_remote(void *data, struct page *page0)
        }
 
        if (page_pool != &page0)
        }
 
        if (page_pool != &page0)
-               OBD_FREE(page_pool, sizeof(page_pool[0]) * max_pages);
+               OBD_FREE_PTR_ARRAY(page_pool, max_pages);
 
        RETURN(rc);
 }
 
        RETURN(rc);
 }
index 86eeb93..f5734a0 100644 (file)
@@ -1611,25 +1611,25 @@ static int mgc_process_recover_nodemap_log(struct obd_device *obd,
        if (cld_is_nodemap(cld) && (mgc_conn->c_peer.nid == LNET_NID_LO_0))
                GOTO(out, rc = 0);
 
        if (cld_is_nodemap(cld) && (mgc_conn->c_peer.nid == LNET_NID_LO_0))
                GOTO(out, rc = 0);
 
-        /* allocate buffer for bulk transfer.
-         * if this is the first time for this mgs to read logs,
-         * CONFIG_READ_NRPAGES_INIT will be used since it will read all logs
-         * once; otherwise, it only reads increment of logs, this should be
-         * small and CONFIG_READ_NRPAGES will be used.
-         */
-        nrpages = CONFIG_READ_NRPAGES;
+       /* allocate buffer for bulk transfer.
+        * if this is the first time for this mgs to read logs,
+        * CONFIG_READ_NRPAGES_INIT will be used since it will read all logs
+        * once; otherwise, it only reads increment of logs, this should be
+        * small and CONFIG_READ_NRPAGES will be used.
+        */
+       nrpages = CONFIG_READ_NRPAGES;
        if (cfg->cfg_last_idx == 0 || cld_is_nodemap(cld))
        if (cfg->cfg_last_idx == 0 || cld_is_nodemap(cld))
-                nrpages = CONFIG_READ_NRPAGES_INIT;
+               nrpages = CONFIG_READ_NRPAGES_INIT;
 
 
-        OBD_ALLOC(pages, sizeof(*pages) * nrpages);
-        if (pages == NULL)
-                GOTO(out, rc = -ENOMEM);
+       OBD_ALLOC_PTR_ARRAY(pages, nrpages);
+       if (pages == NULL)
+               GOTO(out, rc = -ENOMEM);
 
 
-        for (i = 0; i < nrpages; i++) {
+       for (i = 0; i < nrpages; i++) {
                pages[i] = alloc_page(GFP_KERNEL);
                pages[i] = alloc_page(GFP_KERNEL);
-                if (pages[i] == NULL)
-                        GOTO(out, rc = -ENOMEM);
-        }
+               if (pages[i] == NULL)
+                       GOTO(out, rc = -ENOMEM);
+       }
 
 again:
 #ifdef HAVE_SERVER_SUPPORT
 
 again:
 #ifdef HAVE_SERVER_SUPPORT
@@ -1791,7 +1791,7 @@ out:
                                break;
                        __free_page(pages[i]);
                }
                                break;
                        __free_page(pages[i]);
                }
-               OBD_FREE(pages, sizeof(*pages) * nrpages);
+               OBD_FREE_PTR_ARRAY(pages, nrpages);
        }
        return rc;
 }
        }
        return rc;
 }
index 5b34d14..0d00403 100644 (file)
@@ -636,7 +636,7 @@ int mgs_get_ir_logs(struct ptlrpc_request *req)
        CDEBUG(D_MGS, "Reading IR log %s bufsize %ld.\n",
               body->mcb_name, bufsize);
 
        CDEBUG(D_MGS, "Reading IR log %s bufsize %ld.\n",
               body->mcb_name, bufsize);
 
-       OBD_ALLOC(pages, sizeof(*pages) * nrpages);
+       OBD_ALLOC_PTR_ARRAY(pages, nrpages);
        if (!pages)
                GOTO(out, rc = -ENOMEM);
 
        if (!pages)
                GOTO(out, rc = -ENOMEM);
 
@@ -682,7 +682,7 @@ out:
                        __free_page(pages[i]);
                }
 
                        __free_page(pages[i]);
                }
 
-               OBD_FREE(pages, sizeof(*pages) * nrpages);
+               OBD_FREE_PTR_ARRAY(pages, nrpages);
        }
 
        if (fsdb)
        }
 
        if (fsdb)
index 739d602..e25cae0 100644 (file)
@@ -2572,13 +2572,13 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa,
        if (rw == OBD_BRW_WRITE)
                brw_flags = OBD_BRW_ASYNC;
 
        if (rw == OBD_BRW_WRITE)
                brw_flags = OBD_BRW_ASYNC;
 
-       OBD_ALLOC(pga, npages * sizeof(*pga));
+       OBD_ALLOC_PTR_ARRAY(pga, npages);
        if (!pga)
                RETURN(-ENOMEM);
 
        if (!pga)
                RETURN(-ENOMEM);
 
-       OBD_ALLOC(pages, npages * sizeof(*pages));
+       OBD_ALLOC_PTR_ARRAY(pages, npages);
        if (!pages) {
        if (!pages) {
-               OBD_FREE(pga, npages * sizeof(*pga));
+               OBD_FREE_PTR_ARRAY(pga, npages);
                RETURN(-ENOMEM);
        }
 
                RETURN(-ENOMEM);
        }
 
@@ -2628,8 +2628,8 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa,
                }
                __free_page(pgp->pg);
        }
                }
                __free_page(pgp->pg);
        }
-       OBD_FREE(pga, npages * sizeof(*pga));
-       OBD_FREE(pages, npages * sizeof(*pages));
+       OBD_FREE_PTR_ARRAY(pga, npages);
+       OBD_FREE_PTR_ARRAY(pages, npages);
        RETURN(rc);
 }
 
        RETURN(rc);
 }
 
@@ -2653,7 +2653,7 @@ static int echo_client_prep_commit(const struct lu_env *env,
        apc = npages = batch >> PAGE_SHIFT;
        tot_pages = count >> PAGE_SHIFT;
 
        apc = npages = batch >> PAGE_SHIFT;
        tot_pages = count >> PAGE_SHIFT;
 
-       OBD_ALLOC_LARGE(lnb, apc * sizeof(*lnb));
+       OBD_ALLOC_PTR_ARRAY_LARGE(lnb, apc);
        if (!lnb)
                RETURN(-ENOMEM);
 
        if (!lnb)
                RETURN(-ENOMEM);
 
@@ -2719,7 +2719,7 @@ static int echo_client_prep_commit(const struct lu_env *env,
        }
 
 out:
        }
 
 out:
-       OBD_FREE_LARGE(lnb, apc * sizeof(*lnb));
+       OBD_FREE_PTR_ARRAY_LARGE(lnb, apc);
 
        RETURN(ret);
 }
 
        RETURN(ret);
 }
index d7ca9f3..6d55a99 100644 (file)
@@ -280,7 +280,7 @@ int ofd_precreate_objects(const struct lu_env *env, struct ofd_device *ofd,
                RETURN(rc = -ENOSPC);
        }
 
                RETURN(rc = -ENOSPC);
        }
 
-       OBD_ALLOC(batch, nr_saved * sizeof(*batch));
+       OBD_ALLOC_PTR_ARRAY(batch, nr_saved);
        if (batch == NULL)
                RETURN(-ENOMEM);
 
        if (batch == NULL)
                RETURN(-ENOMEM);
 
@@ -462,7 +462,7 @@ out:
                        continue;
                ofd_object_put(env, fo);
        }
                        continue;
                ofd_object_put(env, fo);
        }
-       OBD_FREE(batch, nr_saved * sizeof(*batch));
+       OBD_FREE_PTR_ARRAY(batch, nr_saved);
 
        CDEBUG((objects == 0 && rc == 0) ? D_ERROR : D_OTHER,
               "created %d/%d objects: %d\n", objects, nr_saved, rc);
 
        CDEBUG((objects == 0 && rc == 0) ? D_ERROR : D_OTHER,
               "created %d/%d objects: %d\n", objects, nr_saved, rc);
index 074cf6b..00cc441 100644 (file)
@@ -2011,8 +2011,8 @@ static void sort_brw_pages(struct brw_page **array, int num)
 
 static void osc_release_ppga(struct brw_page **ppga, size_t count)
 {
 
 static void osc_release_ppga(struct brw_page **ppga, size_t count)
 {
-        LASSERT(ppga != NULL);
-        OBD_FREE(ppga, sizeof(*ppga) * count);
+       LASSERT(ppga != NULL);
+       OBD_FREE_PTR_ARRAY(ppga, count);
 }
 
 static int brw_interpret(const struct lu_env *env,
 }
 
 static int brw_interpret(const struct lu_env *env,
@@ -2207,7 +2207,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
        if (mem_tight)
                mpflag = cfs_memory_pressure_get_and_set();
 
        if (mem_tight)
                mpflag = cfs_memory_pressure_get_and_set();
 
-       OBD_ALLOC(pga, sizeof(*pga) * page_count);
+       OBD_ALLOC_PTR_ARRAY(pga, page_count);
        if (pga == NULL)
                GOTO(out, rc = -ENOMEM);
 
        if (pga == NULL)
                GOTO(out, rc = -ENOMEM);
 
@@ -2336,7 +2336,7 @@ out:
                if (oa)
                        OBD_SLAB_FREE_PTR(oa, osc_obdo_kmem);
                if (pga)
                if (oa)
                        OBD_SLAB_FREE_PTR(oa, osc_obdo_kmem);
                if (pga)
-                       OBD_FREE(pga, sizeof(*pga) * page_count);
+                       OBD_FREE_PTR_ARRAY(pga, page_count);
                /* this should happen rarely and is pretty bad, it makes the
                 * pending list not follow the dirty order */
                while (!list_empty(ext_list)) {
                /* this should happen rarely and is pretty bad, it makes the
                 * pending list not follow the dirty order */
                while (!list_empty(ext_list)) {
index b144611..759a548 100644 (file)
@@ -1761,7 +1761,7 @@ void osp_it_fini(const struct lu_env *env, struct dt_it *di)
                                __free_page(pages[i]);
                        }
                }
                                __free_page(pages[i]);
                        }
                }
-               OBD_FREE(pages, npages * sizeof(*pages));
+               OBD_FREE_PTR_ARRAY(pages, npages);
        }
        OBD_FREE_PTR(it);
 }
        }
        OBD_FREE_PTR(it);
 }
@@ -1795,7 +1795,7 @@ static int osp_it_fetch(const struct lu_env *env, struct osp_it *it)
        npages = min_t(unsigned int, OFD_MAX_BRW_SIZE, 1 << 20);
        npages /= PAGE_SIZE;
 
        npages = min_t(unsigned int, OFD_MAX_BRW_SIZE, 1 << 20);
        npages /= PAGE_SIZE;
 
-       OBD_ALLOC(pages, npages * sizeof(*pages));
+       OBD_ALLOC_PTR_ARRAY(pages, npages);
        if (pages == NULL)
                RETURN(-ENOMEM);
 
        if (pages == NULL)
                RETURN(-ENOMEM);
 
@@ -1971,7 +1971,7 @@ again0:
                        if (pages[i] != NULL)
                                __free_page(pages[i]);
                }
                        if (pages[i] != NULL)
                                __free_page(pages[i]);
                }
-               OBD_FREE(pages, it->ooi_total_npages * sizeof(*pages));
+               OBD_FREE_PTR_ARRAY(pages, it->ooi_total_npages);
 
                it->ooi_pos_page = 0;
                it->ooi_total_npages = 0;
 
                it->ooi_pos_page = 0;
                it->ooi_total_npages = 0;
index 9ea2346..9eb38af 100644 (file)
@@ -1038,7 +1038,7 @@ static void osp_sync_process_committed(const struct lu_env *env,
        list_for_each(le, &list)
                count++;
        if (count > 2)
        list_for_each(le, &list)
                count++;
        if (count > 2)
-               OBD_ALLOC_LARGE(arr, sizeof(int) * count);
+               OBD_ALLOC_PTR_ARRAY_LARGE(arr, count);
        else
                arr = NULL;
        i = 0;
        else
                arr = NULL;
        i = 0;
@@ -1091,7 +1091,7 @@ static void osp_sync_process_committed(const struct lu_env *env,
                               PFID(&lgid.lgl_oi.oi_fid), i);
        }
        if (arr)
                               PFID(&lgid.lgl_oi.oi_fid), i);
        }
        if (arr)
-               OBD_FREE_LARGE(arr, sizeof(int) * count);
+               OBD_FREE_PTR_ARRAY_LARGE(arr, count);
 
        llog_ctxt_put(ctxt);
 
 
        llog_ctxt_put(ctxt);
 
index 69f5eb8..1e0a1a3 100644 (file)
@@ -554,7 +554,7 @@ static void qmt_free_lock_array(struct qmt_gl_lock_array *array)
                array->q_locks[i] = NULL;
        }
        array->q_cnt = 0;
                array->q_locks[i] = NULL;
        }
        array->q_cnt = 0;
-       OBD_FREE(array->q_locks, array->q_max * sizeof(*array->q_locks));
+       OBD_FREE_PTR_ARRAY(array->q_locks, array->q_max);
        array->q_locks = NULL;
        array->q_max = 0;
 }
        array->q_locks = NULL;
        array->q_max = 0;
 }
@@ -605,8 +605,7 @@ again:
                array->q_max = count + count / 2 + 10;
                count = 0;
                LASSERT(array->q_locks == NULL && array->q_cnt == 0);
                array->q_max = count + count / 2 + 10;
                count = 0;
                LASSERT(array->q_locks == NULL && array->q_cnt == 0);
-               OBD_ALLOC(array->q_locks,
-                         sizeof(*array->q_locks) * array->q_max);
+               OBD_ALLOC_PTR_ARRAY(array->q_locks, array->q_max);
                if (array->q_locks == NULL) {
                        array->q_max = 0;
                        RETURN(-ENOMEM);
                if (array->q_locks == NULL) {
                        array->q_max = 0;
                        RETURN(-ENOMEM);
index 5eac63f..ac9b86c 100644 (file)
@@ -207,7 +207,7 @@ static int qsd_reint_index(const struct lu_env *env, struct qsd_qtype_info *qqi,
        npages /= PAGE_SIZE;
 
        /* allocate pages for bulk index read */
        npages /= PAGE_SIZE;
 
        /* allocate pages for bulk index read */
-       OBD_ALLOC(pages, npages * sizeof(*pages));
+       OBD_ALLOC_PTR_ARRAY(pages, npages);
        if (pages == NULL)
                GOTO(out, rc = -ENOMEM);
        for (i = 0; i < npages; i++) {
        if (pages == NULL)
                GOTO(out, rc = -ENOMEM);
        for (i = 0; i < npages; i++) {
@@ -285,7 +285,7 @@ out:
                for (i = 0; i < npages; i++)
                        if (pages[i] != NULL)
                                __free_page(pages[i]);
                for (i = 0; i < npages; i++)
                        if (pages[i] != NULL)
                                __free_page(pages[i]);
-               OBD_FREE(pages, npages * sizeof(*pages));
+               OBD_FREE_PTR_ARRAY(pages, npages);
        }
 
        /* Update index version */
        }
 
        /* Update index version */