Whamcloud - gitweb
LU-9679 target: use OBD_ALLOC_PTR_ARRAY() and FREE 55/38255/2
authorMr NeilBrown <neilb@suse.de>
Thu, 14 Nov 2019 03:20:01 +0000 (14:20 +1100)
committerOleg Drokin <green@whamcloud.com>
Wed, 20 May 2020 08:23:00 +0000 (08:23 +0000)
Use:
  OBD_ALLOC_PTR_ARRAY
  OBD_FREE_PTR_ARRAY

for allocating and freeing arrays in target.

Test-Parameters: trivial
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I844a12e810c8a0bd6fb13ca047000de7f265988d
Reviewed-on: https://review.whamcloud.com/38255
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
lustre/target/out_handler.c
lustre/target/out_lib.c
lustre/target/tgt_handler.c
lustre/target/tgt_main.c
lustre/target/update_records.c

index e91c338..448de3b 100644 (file)
@@ -996,7 +996,7 @@ int out_handle(struct tgt_session_info *tsi)
        if (update_buf_count == 0)
                RETURN(err_serious(-EPROTO));
 
-       OBD_ALLOC(update_bufs, sizeof(*update_bufs) * update_buf_count);
+       OBD_ALLOC_PTR_ARRAY(update_bufs, update_buf_count);
        if (update_bufs == NULL)
                RETURN(err_serious(-ENOMEM));
 
@@ -1231,7 +1231,7 @@ out_free:
                        }
                }
 
-               OBD_FREE(update_bufs, sizeof(*update_bufs) * update_buf_count);
+               OBD_FREE_PTR_ARRAY(update_bufs, update_buf_count);
        }
 
        if (desc != NULL)
index 173e4d4..d42187f 100644 (file)
@@ -439,7 +439,7 @@ static int tx_extend_args(struct thandle_exec_args *ta, int new_alloc_ta)
        if (ta->ta_alloc_args >= new_alloc_ta)
                return 0;
 
-       OBD_ALLOC(new_ta, sizeof(*new_ta) * new_alloc_ta);
+       OBD_ALLOC_PTR_ARRAY(new_ta, new_alloc_ta);
        if (new_ta == NULL)
                return -ENOMEM;
 
@@ -456,8 +456,7 @@ static int tx_extend_args(struct thandle_exec_args *ta, int new_alloc_ta)
 
        /* free the old args */
        if (ta->ta_args != NULL)
-               OBD_FREE(ta->ta_args, sizeof(ta->ta_args[0]) *
-                                     ta->ta_alloc_args);
+               OBD_FREE_PTR_ARRAY(ta->ta_args, ta->ta_alloc_args);
 
        ta->ta_args = new_ta;
        ta->ta_alloc_args = new_alloc_ta;
@@ -467,7 +466,7 @@ out:
                        if (new_ta[i] != NULL)
                                OBD_FREE_PTR(new_ta[i]);
                }
-               OBD_FREE(new_ta, sizeof(*new_ta) * new_alloc_ta);
+               OBD_FREE_PTR_ARRAY(new_ta, new_alloc_ta);
        }
        return rc;
 }
index 67788f6..c9a57bb 100644 (file)
@@ -1194,7 +1194,7 @@ static int tgt_obd_idx_read(struct tgt_session_info *tsi)
        rdpg->rp_npages = (rdpg->rp_count + PAGE_SIZE - 1) >> PAGE_SHIFT;
 
        /* allocate pages to store the containers */
-       OBD_ALLOC(rdpg->rp_pages, rdpg->rp_npages * sizeof(rdpg->rp_pages[0]));
+       OBD_ALLOC_PTR_ARRAY(rdpg->rp_pages, rdpg->rp_npages);
        if (rdpg->rp_pages == NULL)
                GOTO(out, rc = -ENOMEM);
        for (i = 0; i < rdpg->rp_npages; i++) {
@@ -1221,8 +1221,7 @@ out:
                for (i = 0; i < rdpg->rp_npages; i++)
                        if (rdpg->rp_pages[i])
                                __free_page(rdpg->rp_pages[i]);
-               OBD_FREE(rdpg->rp_pages,
-                        rdpg->rp_npages * sizeof(rdpg->rp_pages[0]));
+               OBD_FREE_PTR_ARRAY(rdpg->rp_pages, rdpg->rp_npages);
        }
        return rc;
 }
index bdd05e7..b774eb0 100644 (file)
@@ -663,8 +663,7 @@ static void tgt_key_fini(const struct lu_context *ctx,
        }
 
        if (args->ta_args != NULL)
-               OBD_FREE(args->ta_args, sizeof(args->ta_args[0]) *
-                                       args->ta_alloc_args);
+               OBD_FREE_PTR_ARRAY(args->ta_args, args->ta_alloc_args);
        OBD_SLAB_FREE_PTR(info, tgt_thread_kmem);
 }
 
index 5fb706c..56a833c 100644 (file)
@@ -1200,8 +1200,7 @@ static void update_key_fini(const struct lu_context *ctx,
        }
 
        if (args->ta_args != NULL)
-               OBD_FREE(args->ta_args, sizeof(args->ta_args[0]) *
-                        args->ta_alloc_args);
+               OBD_FREE_PTR_ARRAY(args->ta_args, args->ta_alloc_args);
 
        if (info->uti_tur.tur_update_records != NULL)
                OBD_FREE_LARGE(info->uti_tur.tur_update_records,