From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 9/9] block: make the init_part_stats return value more logical
Date: Wed, 25 Mar 2020 16:48:43 +0100 [thread overview]
Message-ID: <20200325154843.1349040-10-hch@lst.de> (raw)
In-Reply-To: <20200325154843.1349040-1-hch@lst.de>
Return 0 / -ENOMEM instead of a boolean dressed up as int.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/genhd.c | 2 +-
block/partitions/core.c | 2 +-
include/linux/part_stat.h | 6 +++---
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/block/genhd.c b/block/genhd.c
index 6323cc789efa..95aef19ca8ed 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1644,7 +1644,7 @@ struct gendisk *__alloc_disk_node(int minors, int node_id)
disk = kzalloc_node(sizeof(struct gendisk), GFP_KERNEL, node_id);
if (disk) {
- if (!init_part_stats(&disk->part0)) {
+ if (init_part_stats(&disk->part0)) {
kfree(disk);
return NULL;
}
diff --git a/block/partitions/core.c b/block/partitions/core.c
index b79c4513629b..6509351cb9d3 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -377,7 +377,7 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
if (!p)
return ERR_PTR(-EBUSY);
- if (!init_part_stats(p)) {
+ if (init_part_stats(p)) {
err = -ENOMEM;
goto out_free;
}
diff --git a/include/linux/part_stat.h b/include/linux/part_stat.h
index ece607607a86..521ad787b0ec 100644
--- a/include/linux/part_stat.h
+++ b/include/linux/part_stat.h
@@ -48,8 +48,8 @@ static inline int init_part_stats(struct hd_struct *part)
{
part->dkstats = alloc_percpu(struct disk_stats);
if (!part->dkstats)
- return 0;
- return 1;
+ return -ENOMEM;
+ return 0;
}
static inline void free_part_stats(struct hd_struct *part)
@@ -72,7 +72,7 @@ static inline void part_stat_set_all(struct hd_struct *part, int value)
static inline int init_part_stats(struct hd_struct *part)
{
- return 1;
+ return 0;
}
static inline void free_part_stats(struct hd_struct *part)
--
2.25.1
next prev parent reply other threads:[~2020-03-25 15:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-25 15:48 decruft genhd.h v2 Christoph Hellwig
2020-03-25 15:48 ` [PATCH 1/9] block: mark block_depr static Christoph Hellwig
2020-03-25 15:48 ` [PATCH 2/9] block: mark part_in_flight and part_in_flight_rw static Christoph Hellwig
2020-03-26 0:17 ` Joe Perches
2020-03-25 15:48 ` [PATCH 3/9] block: unexport disk_get_part Christoph Hellwig
2020-03-25 15:48 ` [PATCH 4/9] block: unexport disk_map_sector_rcu Christoph Hellwig
2020-03-25 15:48 ` [PATCH 5/9] block: unexport get_gendisk Christoph Hellwig
2020-03-25 15:48 ` [PATCH 6/9] block: move guard_bio_eod to bio.c Christoph Hellwig
2020-03-25 15:48 ` [PATCH 7/9] block: move block layer internals out of include/linux/genhd.h Christoph Hellwig
2020-03-25 15:48 ` [PATCH 8/9] block: move the part_stat* helpers from genhd.h to a new header Christoph Hellwig
2020-03-25 15:48 ` Christoph Hellwig [this message]
2020-03-25 16:21 ` decruft genhd.h v2 Jens Axboe
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=20200325154843.1349040-10-hch@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®