From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Tejun Heo <tj@kernel.org>, Coly Li <colyli@suse.de>,
Song Liu <song@kernel.org>,
dm-devel@redhat.com, linux-bcache@vger.kernel.org,
linux-raid@vger.kernel.org, linux-s390@vger.kernel.org,
linux-block@vger.kernel.org
Subject: [PATCH 8/9] block: remove DISK_PITER_REVERSE
Date: Tue, 1 Dec 2020 17:54:23 +0100 [thread overview]
Message-ID: <20201201165424.2030647-9-hch@lst.de> (raw)
In-Reply-To: <20201201165424.2030647-1-hch@lst.de>
There is good reason to iterate backwards when deleting all partitions in
del_gendisk, just like we don't in blk_drop_partitions.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/genhd.c | 34 ++++------------------------------
include/linux/genhd.h | 1 -
2 files changed, 4 insertions(+), 31 deletions(-)
diff --git a/block/genhd.c b/block/genhd.c
index 65dba32df5474f..7730ddabebba92 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -182,24 +182,13 @@ static struct block_device *__disk_get_part(struct gendisk *disk, int partno)
void disk_part_iter_init(struct disk_part_iter *piter, struct gendisk *disk,
unsigned int flags)
{
- struct disk_part_tbl *ptbl;
-
- rcu_read_lock();
- ptbl = rcu_dereference(disk->part_tbl);
-
piter->disk = disk;
piter->part = NULL;
-
- if (flags & DISK_PITER_REVERSE)
- piter->idx = ptbl->len - 1;
- else if (flags & (DISK_PITER_INCL_PART0 | DISK_PITER_INCL_EMPTY_PART0))
+ if (flags & (DISK_PITER_INCL_PART0 | DISK_PITER_INCL_EMPTY_PART0))
piter->idx = 0;
else
piter->idx = 1;
-
piter->flags = flags;
-
- rcu_read_unlock();
}
/**
@@ -214,7 +203,6 @@ void disk_part_iter_init(struct disk_part_iter *piter, struct gendisk *disk,
struct block_device *disk_part_iter_next(struct disk_part_iter *piter)
{
struct disk_part_tbl *ptbl;
- int inc, end;
/* put the last partition */
disk_part_iter_exit(piter);
@@ -223,21 +211,8 @@ struct block_device *disk_part_iter_next(struct disk_part_iter *piter)
rcu_read_lock();
ptbl = rcu_dereference(piter->disk->part_tbl);
- /* determine iteration parameters */
- if (piter->flags & DISK_PITER_REVERSE) {
- inc = -1;
- if (piter->flags & (DISK_PITER_INCL_PART0 |
- DISK_PITER_INCL_EMPTY_PART0))
- end = -1;
- else
- end = 0;
- } else {
- inc = 1;
- end = ptbl->len;
- }
-
/* iterate to the next partition */
- for (; piter->idx != end; piter->idx += inc) {
+ for (; piter->idx != ptbl->len; piter->idx += 1) {
struct block_device *part;
part = rcu_dereference(ptbl->part[piter->idx]);
@@ -252,7 +227,7 @@ struct block_device *disk_part_iter_next(struct disk_part_iter *piter)
piter->part = bdgrab(part);
if (!piter->part)
continue;
- piter->idx += inc;
+ piter->idx += 1;
break;
}
@@ -776,8 +751,7 @@ void del_gendisk(struct gendisk *disk)
down_write(&bdev_lookup_sem);
/* invalidate stuff */
- disk_part_iter_init(&piter, disk,
- DISK_PITER_INCL_EMPTY | DISK_PITER_REVERSE);
+ disk_part_iter_init(&piter, disk, DISK_PITER_INCL_EMPTY);
while ((part = disk_part_iter_next(&piter))) {
invalidate_partition(part);
delete_partition(part);
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 191f5e4ae4e93b..425956ac9315fa 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -217,7 +217,6 @@ void disk_uevent(struct gendisk *disk, enum kobject_action action);
/*
* Smarter partition iterator without context limits.
*/
-#define DISK_PITER_REVERSE (1 << 0) /* iterate in the reverse direction */
#define DISK_PITER_INCL_EMPTY (1 << 1) /* include 0-sized parts */
#define DISK_PITER_INCL_PART0 (1 << 2) /* include partition 0 */
#define DISK_PITER_INCL_EMPTY_PART0 (1 << 3) /* include empty partition 0 */
--
2.29.2
next prev parent reply other threads:[~2020-12-01 16:55 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-01 16:54 store a pointer to the block_device in struct bio (again) Christoph Hellwig
2020-12-01 16:54 ` [PATCH 1/9] brd: remove the end of device check in brd_do_bvec Christoph Hellwig
2020-12-02 22:39 ` Tejun Heo
2020-12-01 16:54 ` [PATCH 2/9] dcssblk: " Christoph Hellwig
2020-12-02 22:39 ` Tejun Heo
2020-12-01 16:54 ` [PATCH 3/9] block: store a block_device pointer in struct bio Christoph Hellwig
2020-12-02 22:54 ` Tejun Heo
2020-12-03 6:39 ` Ming Lei
2020-12-03 7:10 ` Ming Lei
2020-12-03 8:29 ` Christoph Hellwig
2020-12-03 9:32 ` Ming Lei
2020-12-03 20:53 ` Keith Busch
2020-12-01 16:54 ` [PATCH 4/9] block: simplify submit_bio_checks a bit Christoph Hellwig
2020-12-02 22:55 ` Tejun Heo
2020-12-01 16:54 ` [PATCH 5/9] block: use ->bi_bdev for bio based I/O accounting Christoph Hellwig
2020-12-02 23:05 ` Tejun Heo
2020-12-01 16:54 ` [PATCH 6/9] blk-mq: use ->bi_bdev for " Christoph Hellwig
2020-12-02 23:06 ` Tejun Heo
2020-12-01 16:54 ` [PATCH 7/9] block: add a disk_uevent helper Christoph Hellwig
2020-12-02 23:08 ` Tejun Heo
2020-12-01 16:54 ` Christoph Hellwig [this message]
2020-12-02 23:15 ` [PATCH 8/9] block: remove DISK_PITER_REVERSE Tejun Heo
2020-12-01 16:54 ` [PATCH 9/9] block: use an xarray for disk->part_tbl Christoph Hellwig
2020-12-02 23:22 ` Tejun Heo
2020-12-02 22:35 ` store a pointer to the block_device in struct bio (again) Tejun Heo
2020-12-02 22:37 ` Tejun Heo
2020-12-04 16:43 ` Jens Axboe
2020-12-07 18:56 ` Qian Cai
2020-12-07 19:01 ` Christoph Hellwig
2020-12-07 20:20 ` Jens Axboe
2020-12-08 11:04 ` Christoph Hellwig
2020-12-08 13:08 ` Qian Cai
2020-12-08 13:38 ` Daniel Wagner
2020-12-08 14:15 ` 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=20201201165424.2030647-9-hch@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=colyli@suse.de \
--cc=dm-devel@redhat.com \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=song@kernel.org \
--cc=tj@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