All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, linux-raid@vger.kernel.org,
	linux-scsi@vger.kernel.org, linux-ext4@vger.kernel.org,
	reiserfs-devel@vger.kernel.org
Subject: [PATCH 05/21] block: remove alloc_part_info and free_part_info
Date: Thu, 12 Mar 2020 16:19:23 +0100	[thread overview]
Message-ID: <20200312151939.645254-6-hch@lst.de> (raw)
In-Reply-To: <20200312151939.645254-1-hch@lst.de>

There isn't any good reason not to simply open code the allocation and
freeing of the partition_meta_info structure.  Especially as one of
the branches in alloc_part_info is entirely dead code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/partition-generic.c |  6 ++++--
 include/linux/genhd.h     | 15 +--------------
 2 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/block/partition-generic.c b/block/partition-generic.c
index cc1133bf0119..a36ace0e2161 100644
--- a/block/partition-generic.c
+++ b/block/partition-generic.c
@@ -249,7 +249,9 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
 	p->policy = get_disk_ro(disk);
 
 	if (info) {
-		struct partition_meta_info *pinfo = alloc_part_info(disk);
+		struct partition_meta_info *pinfo;
+
+		pinfo = kzalloc_node(sizeof(*pinfo), GFP_KERNEL, disk->node_id);
 		if (!pinfo) {
 			err = -ENOMEM;
 			goto out_free_stats;
@@ -308,7 +310,7 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
 	return p;
 
 out_free_info:
-	free_part_info(p);
+	kfree(p->info);
 out_free_stats:
 	free_part_stats(p);
 out_free:
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 49f1836e7b81..30e0f17cd5ff 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -418,19 +418,6 @@ void part_dec_in_flight(struct request_queue *q, struct hd_struct *part,
 void part_inc_in_flight(struct request_queue *q, struct hd_struct *part,
 			int rw);
 
-static inline struct partition_meta_info *alloc_part_info(struct gendisk *disk)
-{
-	if (disk)
-		return kzalloc_node(sizeof(struct partition_meta_info),
-				    GFP_KERNEL, disk->node_id);
-	return kzalloc(sizeof(struct partition_meta_info), GFP_KERNEL);
-}
-
-static inline void free_part_info(struct hd_struct *part)
-{
-	kfree(part->info);
-}
-
 void update_io_ticks(struct hd_struct *part, unsigned long now);
 
 /* block/genhd.c */
@@ -706,7 +693,7 @@ static inline void hd_struct_kill(struct hd_struct *part)
 static inline void hd_free_part(struct hd_struct *part)
 {
 	free_part_stats(part);
-	free_part_info(part);
+	kfree(part->info);
 	percpu_ref_exit(&part->ref);
 }
 
-- 
2.24.1

  parent reply	other threads:[~2020-03-12 15:19 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-12 15:19 cleanup the partitioning code Christoph Hellwig
2020-03-12 15:19 ` [PATCH 01/21] block: remove the blk_lookup_devt export Christoph Hellwig
2020-03-12 15:19 ` [PATCH 02/21] block: remove __bdevname Christoph Hellwig
2020-03-13 14:19   ` Theodore Y. Ts'o
2020-03-12 15:19 ` [PATCH 03/21] block: move disk_name and related helpers out of partition-generic.c Christoph Hellwig
2020-03-12 15:19 ` [PATCH 04/21] block: move sysfs methods shared by disks and partitions to genhd.c Christoph Hellwig
2020-03-12 15:19 ` Christoph Hellwig [this message]
2020-03-12 15:19 ` [PATCH 06/21] scsi: simplify scsi_bios_ptable Christoph Hellwig
2020-03-12 15:19 ` [PATCH 07/21] scsi: move scsicam_bios_param to the end of scsicam.c Christoph Hellwig
2020-03-12 15:19 ` [PATCH 08/21] scsi: simplify scsi_partsize Christoph Hellwig
2020-03-12 15:19 ` [PATCH 09/21] block: unexport read_dev_sector and put_dev_sector Christoph Hellwig
2020-03-12 15:19 ` [PATCH 10/21] block: cleanup how md_autodetect_dev is called Christoph Hellwig
2020-03-12 15:19 ` [PATCH 11/21] block: remove warn_no_part Christoph Hellwig
2020-03-12 15:19 ` [PATCH 12/21] block: declare all partition detection routines in check.h Christoph Hellwig
2020-03-12 15:19 ` [PATCH 13/21] block: remove block/partitions/karma.h Christoph Hellwig
2020-03-12 15:19 ` [PATCH 14/21] block: remove block/partitions/osf.h Christoph Hellwig
2020-03-12 15:19 ` [PATCH 15/21] block: remove block/partitions/sgi.h Christoph Hellwig
2020-03-12 15:19 ` [PATCH 16/21] block: remove block/partitions/sun.h Christoph Hellwig
2020-03-12 15:19 ` [PATCH 17/21] block: move struct partition out of genhd.h Christoph Hellwig
2020-03-12 15:19 ` [PATCH 18/21] block: move the *_PARTITION enum " Christoph Hellwig
2020-03-12 15:19 ` [PATCH 19/21] partitions/msdos: remove LINUX_SWAP_PARTITION Christoph Hellwig
2020-03-12 15:19 ` [PATCH 20/21] block: move the various x86 Unix label formats out of genhd.h Christoph Hellwig
2020-03-12 15:19   ` Christoph Hellwig
2020-03-12 15:19 ` [PATCH 21/21] block: merge partition-generic.c and check.c Christoph Hellwig
2020-03-23 16:52 ` cleanup the partitioning code Christoph Hellwig
2020-03-23 16:55   ` Jens Axboe
2020-03-23 16:57     ` Jens Axboe
2020-03-23 17:05       ` Christoph Hellwig
2020-03-23 19:32     ` Jens Axboe
2020-03-24  7:25 cleanup the partitioning code v2 Christoph Hellwig
2020-03-24  7:25 ` [PATCH 05/21] block: remove alloc_part_info and free_part_info Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200312151939.645254-6-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=reiserfs-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.