From: Tejun Heo <tj@kernel.org>
To: jens.axboe@oracle.com, James.Bottomley@HansenPartnership.com,
bharrosh@panasas.com, greg.freemyer@gmail.com,
linux-scsi@vger.kernel.org, brking@linux.vnet.ibm.com,
liml@rtr.ca, viro@f
Cc: Tejun Heo <tj@kernel.org>
Subject: [PATCH 01/10] block: misc updates
Date: Mon, 14 Jul 2008 16:12:05 +0900 [thread overview]
Message-ID: <1216019534-29977-2-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1216019534-29977-1-git-send-email-tj@kernel.org>
This patch makes the following misc updates in preparation for
disk->part dereference fix and extended block devt support.
* implment part_to_disk()
* fix comment about gendisk->part indexing
* rename get_part() to disk_map_sector()
* don't use n which is always zero while printing disk information in
diskstats_show()
Signed-off-by: Tejun Heo <tj@kernel.org>
---
block/blk-core.c | 7 ++++---
block/blk-merge.c | 4 ++--
block/genhd.c | 4 ++--
drivers/block/aoe/aoecmd.c | 2 +-
include/linux/genhd.h | 13 ++++++++++---
5 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index 1905aab..bc832aa 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -60,7 +60,7 @@ static void drive_stat_acct(struct request *rq, int new_io)
if (!blk_fs_request(rq) || !rq->rq_disk)
return;
- part = get_part(rq->rq_disk, rq->sector);
+ part = disk_map_sector(rq->rq_disk, rq->sector);
if (!new_io)
__all_stat_inc(rq->rq_disk, part, merges[rw], rq->sector);
else {
@@ -1535,7 +1535,8 @@ static int __end_that_request_first(struct request *req, int error,
}
if (blk_fs_request(req) && req->rq_disk) {
- struct hd_struct *part = get_part(req->rq_disk, req->sector);
+ struct hd_struct *part =
+ disk_map_sector(req->rq_disk, req->sector);
const int rw = rq_data_dir(req);
all_stat_add(req->rq_disk, part, sectors[rw],
@@ -1723,7 +1724,7 @@ static void end_that_request_last(struct request *req, int error)
if (disk && blk_fs_request(req) && req != &req->q->bar_rq) {
unsigned long duration = jiffies - req->start_time;
const int rw = rq_data_dir(req);
- struct hd_struct *part = get_part(disk, req->sector);
+ struct hd_struct *part = disk_map_sector(disk, req->sector);
__all_stat_inc(disk, part, ios[rw], req->sector);
__all_stat_add(disk, part, ticks[rw], duration, req->sector);
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 651136a..e96d87d 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -467,8 +467,8 @@ static int attempt_merge(struct request_queue *q, struct request *req,
elv_merge_requests(q, req, next);
if (req->rq_disk) {
- struct hd_struct *part
- = get_part(req->rq_disk, req->sector);
+ struct hd_struct *part =
+ disk_map_sector(req->rq_disk, req->sector);
disk_round_stats(req->rq_disk);
req->rq_disk->in_flight--;
if (part) {
diff --git a/block/genhd.c b/block/genhd.c
index b646e7e..432c358 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -567,7 +567,7 @@ static int diskstats_show(struct seq_file *s, void *v)
{
struct gendisk *gp = v;
char buf[BDEVNAME_SIZE];
- int n = 0;
+ int n;
/*
if (&gp->dev.kobj.entry == block_class.devices.next)
@@ -581,7 +581,7 @@ static int diskstats_show(struct seq_file *s, void *v)
disk_round_stats(gp);
preempt_enable();
seq_printf(s, "%4d %4d %s %lu %lu %llu %u %lu %lu %llu %u %u %u %u\n",
- gp->major, n + gp->first_minor, disk_name(gp, n, buf),
+ gp->major, gp->first_minor, disk_name(gp, 0, buf),
disk_stat_read(gp, ios[0]), disk_stat_read(gp, merges[0]),
(unsigned long long)disk_stat_read(gp, sectors[0]),
jiffies_to_msecs(disk_stat_read(gp, ticks[0])),
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index 41f818b..ba40473 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -757,7 +757,7 @@ diskstats(struct gendisk *disk, struct bio *bio, ulong duration, sector_t sector
const int rw = bio_data_dir(bio);
struct hd_struct *part;
- part = get_part(disk, sector);
+ part = disk_map_sector(disk, sector);
all_stat_inc(disk, part, ios[rw], sector);
all_stat_add(disk, part, ticks[rw], duration, sector);
all_stat_add(disk, part, sectors[rw], n_sect, sector);
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index e485cf0..68d50a2 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -117,7 +117,7 @@ struct gendisk {
int minors; /* maximum number of minors, =1 for
* disks that can't be partitioned. */
char disk_name[32]; /* name of major driver */
- struct hd_struct **part; /* [indexed by minor] */
+ struct hd_struct **part; /* [indexed by minor - 1] */
struct block_device_operations *fops;
struct request_queue *queue;
void *private_data;
@@ -143,14 +143,21 @@ struct gendisk {
struct work_struct async_notify;
};
+static inline struct gendisk *part_to_disk(struct hd_struct *part)
+{
+ if (likely(part))
+ return dev_to_disk((part)->dev.parent);
+ return NULL;
+}
+
/*
* Macros to operate on percpu disk statistics:
*
* The __ variants should only be called in critical sections. The full
* variants disable/enable preemption.
*/
-static inline struct hd_struct *get_part(struct gendisk *gendiskp,
- sector_t sector)
+static inline struct hd_struct *disk_map_sector(struct gendisk *gendiskp,
+ sector_t sector)
{
struct hd_struct *part;
int i;
--
1.5.4.5
WARNING: multiple messages have this Message-ID (diff)
From: Tejun Heo <tj@kernel.org>
To: jens.axboe@oracle.com, James.Bottomley@HansenPartnership.com,
bharrosh@panasas.com, greg.freemyer@gmail.com,
linux-scsi@vger.kernel.org, brking@linux.vnet.ibm.com,
liml@rtr.ca, viro@ftp.linux.org.uk, linux-kernel@vger.kernel.org,
linux-ide@vger.kernel.org
Cc: Tejun Heo <tj@kernel.org>
Subject: [PATCH 01/10] block: misc updates
Date: Mon, 14 Jul 2008 16:12:05 +0900 [thread overview]
Message-ID: <1216019534-29977-2-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1216019534-29977-1-git-send-email-tj@kernel.org>
This patch makes the following misc updates in preparation for
disk->part dereference fix and extended block devt support.
* implment part_to_disk()
* fix comment about gendisk->part indexing
* rename get_part() to disk_map_sector()
* don't use n which is always zero while printing disk information in
diskstats_show()
Signed-off-by: Tejun Heo <tj@kernel.org>
---
block/blk-core.c | 7 ++++---
block/blk-merge.c | 4 ++--
block/genhd.c | 4 ++--
drivers/block/aoe/aoecmd.c | 2 +-
include/linux/genhd.h | 13 ++++++++++---
5 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index 1905aab..bc832aa 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -60,7 +60,7 @@ static void drive_stat_acct(struct request *rq, int new_io)
if (!blk_fs_request(rq) || !rq->rq_disk)
return;
- part = get_part(rq->rq_disk, rq->sector);
+ part = disk_map_sector(rq->rq_disk, rq->sector);
if (!new_io)
__all_stat_inc(rq->rq_disk, part, merges[rw], rq->sector);
else {
@@ -1535,7 +1535,8 @@ static int __end_that_request_first(struct request *req, int error,
}
if (blk_fs_request(req) && req->rq_disk) {
- struct hd_struct *part = get_part(req->rq_disk, req->sector);
+ struct hd_struct *part =
+ disk_map_sector(req->rq_disk, req->sector);
const int rw = rq_data_dir(req);
all_stat_add(req->rq_disk, part, sectors[rw],
@@ -1723,7 +1724,7 @@ static void end_that_request_last(struct request *req, int error)
if (disk && blk_fs_request(req) && req != &req->q->bar_rq) {
unsigned long duration = jiffies - req->start_time;
const int rw = rq_data_dir(req);
- struct hd_struct *part = get_part(disk, req->sector);
+ struct hd_struct *part = disk_map_sector(disk, req->sector);
__all_stat_inc(disk, part, ios[rw], req->sector);
__all_stat_add(disk, part, ticks[rw], duration, req->sector);
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 651136a..e96d87d 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -467,8 +467,8 @@ static int attempt_merge(struct request_queue *q, struct request *req,
elv_merge_requests(q, req, next);
if (req->rq_disk) {
- struct hd_struct *part
- = get_part(req->rq_disk, req->sector);
+ struct hd_struct *part =
+ disk_map_sector(req->rq_disk, req->sector);
disk_round_stats(req->rq_disk);
req->rq_disk->in_flight--;
if (part) {
diff --git a/block/genhd.c b/block/genhd.c
index b646e7e..432c358 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -567,7 +567,7 @@ static int diskstats_show(struct seq_file *s, void *v)
{
struct gendisk *gp = v;
char buf[BDEVNAME_SIZE];
- int n = 0;
+ int n;
/*
if (&gp->dev.kobj.entry == block_class.devices.next)
@@ -581,7 +581,7 @@ static int diskstats_show(struct seq_file *s, void *v)
disk_round_stats(gp);
preempt_enable();
seq_printf(s, "%4d %4d %s %lu %lu %llu %u %lu %lu %llu %u %u %u %u\n",
- gp->major, n + gp->first_minor, disk_name(gp, n, buf),
+ gp->major, gp->first_minor, disk_name(gp, 0, buf),
disk_stat_read(gp, ios[0]), disk_stat_read(gp, merges[0]),
(unsigned long long)disk_stat_read(gp, sectors[0]),
jiffies_to_msecs(disk_stat_read(gp, ticks[0])),
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index 41f818b..ba40473 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -757,7 +757,7 @@ diskstats(struct gendisk *disk, struct bio *bio, ulong duration, sector_t sector
const int rw = bio_data_dir(bio);
struct hd_struct *part;
- part = get_part(disk, sector);
+ part = disk_map_sector(disk, sector);
all_stat_inc(disk, part, ios[rw], sector);
all_stat_add(disk, part, ticks[rw], duration, sector);
all_stat_add(disk, part, sectors[rw], n_sect, sector);
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index e485cf0..68d50a2 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -117,7 +117,7 @@ struct gendisk {
int minors; /* maximum number of minors, =1 for
* disks that can't be partitioned. */
char disk_name[32]; /* name of major driver */
- struct hd_struct **part; /* [indexed by minor] */
+ struct hd_struct **part; /* [indexed by minor - 1] */
struct block_device_operations *fops;
struct request_queue *queue;
void *private_data;
@@ -143,14 +143,21 @@ struct gendisk {
struct work_struct async_notify;
};
+static inline struct gendisk *part_to_disk(struct hd_struct *part)
+{
+ if (likely(part))
+ return dev_to_disk((part)->dev.parent);
+ return NULL;
+}
+
/*
* Macros to operate on percpu disk statistics:
*
* The __ variants should only be called in critical sections. The full
* variants disable/enable preemption.
*/
-static inline struct hd_struct *get_part(struct gendisk *gendiskp,
- sector_t sector)
+static inline struct hd_struct *disk_map_sector(struct gendisk *gendiskp,
+ sector_t sector)
{
struct hd_struct *part;
int i;
--
1.5.4.5
next prev parent reply other threads:[~2008-07-14 7:16 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-14 7:12 [PATCHSET 2.6.26] block: implement extended devt, take #2 Tejun Heo
2008-07-14 7:12 ` Tejun Heo
2008-07-14 7:12 ` [PATCH 01/10] block: misc updates Tejun Heo
2008-07-14 7:12 ` Tejun Heo [this message]
2008-07-14 7:12 ` Tejun Heo
2008-07-14 7:12 ` [PATCH 02/10] block: make variable and argument names more consistent Tejun Heo
2008-07-14 7:12 ` Tejun Heo
2008-07-14 7:12 ` [PATCH 03/10] block: don't depend on consecutive minor space Tejun Heo
2008-07-14 7:12 ` Tejun Heo
2008-07-14 7:12 ` [PATCH 04/10] block: fix disk->part[] dereferencing race Tejun Heo
2008-07-14 7:12 ` Tejun Heo
2008-07-14 7:12 ` Tejun Heo
2008-07-14 7:12 ` [PATCH 05/10] block: always use __{disk|part|all}_stat_*() and kill non-underbarred versions Tejun Heo
2008-07-14 7:12 ` Tejun Heo
2008-07-14 7:12 ` Tejun Heo
2008-07-16 6:19 ` Peter Zijlstra
2008-07-14 7:12 ` [PATCH 06/10] block: drop underbars from __{disk|part|all}_stat_*() Tejun Heo
2008-07-14 7:12 ` Tejun Heo
2008-07-14 7:12 ` [PATCH 07/10] block: implement extended dev numbers Tejun Heo
2008-07-14 7:12 ` Tejun Heo
2008-07-14 7:12 ` Tejun Heo
2008-07-14 7:12 ` [PATCH 08/10] block: adjust formatting for large minors and add ext_range sysfs attr Tejun Heo
2008-07-14 7:12 ` Tejun Heo
2008-07-14 7:12 ` [PATCH 09/10] sd/ide-disk: apply extended minors to sd and ide Tejun Heo
2008-07-14 7:12 ` Tejun Heo
2008-07-14 7:12 ` Tejun Heo
2008-07-14 7:12 ` [PATCH 10/10] block: implement CONFIG_DEBUG_BLOCK_EXT_DEVT Tejun Heo
2008-07-14 7:12 ` Tejun Heo
2008-07-14 7:12 ` Tejun Heo
2008-07-14 7:15 ` [PATCHSET 2.6.26] block: implement extended devt, take #2 Tejun Heo
2008-07-14 7:15 ` Tejun Heo
2008-07-14 7:15 ` Tejun Heo
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=1216019534-29977-2-git-send-email-tj@kernel.org \
--to=tj@kernel.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=bharrosh@panasas.com \
--cc=brking@linux.vnet.ibm.com \
--cc=greg.freemyer@gmail.com \
--cc=jens.axboe@oracle.com \
--cc=liml@rtr.ca \
--cc=linux-scsi@vger.kernel.org \
--cc=viro@f \
/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.