From: Tejun Heo <tj@kernel.org>
To: Greg Kroah-Hartman <gregkh@suse.de>,
Abdel Benamrouche <draconux@gmail.com>
Cc: linux-kernel@vger.kernel.org, Tejun Heo <tj@kernel.org>,
Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH] block: fix partition info printouts
Date: Mon, 25 Aug 2008 18:15:36 +0900 [thread overview]
Message-ID: <1219655740-11672-2-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1219655740-11672-1-git-send-email-tj@kernel.org>
Recent block_class iteration updates 5c6f35c5..27f3025 broke partition
info printouts.
* printk_all_partitions(): Partition print out stops when it meets a
partition hole. Partition printing inner loop should continue
instead of exiting on empty partition slot.
* /proc/partitions and /proc/diskstats: If all information can't be
read in single read(), the information is truncated. This is
because find_start() doesn't actually update the counter containing
the initial seek. It runs to the end and ends up always reporting
EOF on the second read.
This patch fixes both problems.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
---
block/genhd.c | 19 ++++++++++---------
1 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/block/genhd.c b/block/genhd.c
index decc8f1..3a43c1d 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -238,7 +238,7 @@ static int printk_partition(struct device *dev, void *data)
int n;
if (dev->type != &disk_type)
- goto exit;
+ return 0;
sgp = dev_to_disk(dev);
/*
@@ -246,7 +246,7 @@ static int printk_partition(struct device *dev, void *data)
*/
if (get_capacity(sgp) == 0 ||
(sgp->flags & GENHD_FL_SUPPRESS_PARTITION_INFO))
- goto exit;
+ return 0;
/*
* Note, unlike /proc/partitions, I am showing the numbers in
@@ -266,15 +266,15 @@ static int printk_partition(struct device *dev, void *data)
/* now show the partitions */
for (n = 0; n < sgp->minors - 1; ++n) {
if (sgp->part[n] == NULL)
- goto exit;
+ continue;
if (sgp->part[n]->nr_sects == 0)
- goto exit;
+ continue;
printk(" %02x%02x %10llu %s\n",
sgp->major, n + 1 + sgp->first_minor,
(unsigned long long)sgp->part[n]->nr_sects >> 1,
disk_name(sgp, n + 1, buf));
}
-exit:
+
return 0;
}
@@ -294,11 +294,11 @@ void __init printk_all_partitions(void)
/* iterator */
static int find_start(struct device *dev, void *data)
{
- loff_t k = *(loff_t *)data;
+ loff_t *k = (loff_t *)data;
if (dev->type != &disk_type)
return 0;
- if (!k--)
+ if (!(*k)--)
return 1;
return 0;
}
@@ -312,7 +312,7 @@ static void *part_start(struct seq_file *part, loff_t *pos)
seq_puts(part, "major minor #blocks name\n\n");
mutex_lock(&block_class_lock);
- dev = class_find_device(&block_class, NULL, (void *)pos, find_start);
+ dev = class_find_device(&block_class, NULL, &n, find_start);
if (dev)
return dev_to_disk(dev);
return NULL;
@@ -569,9 +569,10 @@ static struct device_type disk_type = {
static void *diskstats_start(struct seq_file *part, loff_t *pos)
{
struct device *dev;
+ loff_t n = *pos;
mutex_lock(&block_class_lock);
- dev = class_find_device(&block_class, NULL, (void *)pos, find_start);
+ dev = class_find_device(&block_class, NULL, &n, find_start);
if (dev)
return dev_to_disk(dev);
return NULL;
--
1.5.4.5
next prev parent reply other threads:[~2008-08-25 9:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-25 9:15 [PATCHSET 1/3 blk-for-2.6.28] block: misc fixes and improvements Tejun Heo
2008-08-25 9:15 ` Tejun Heo [this message]
2008-08-25 9:15 ` [PATCH] block: don't grab block_class_lock unnecessarily Tejun Heo
2008-08-25 9:15 ` [PATCH] block: use class_dev_iterator instead of class_for_each_device() Tejun Heo
2008-08-25 9:15 ` [PATCH] block: allow deleting zero length partition Tejun Heo
2008-08-25 9:15 ` [PATCH] block: update add_partition() error handling Tejun Heo
2008-08-25 10:23 ` [PATCHSET 1/3 blk-for-2.6.28] block: misc fixes and improvements Tejun Heo
2008-08-25 14:47 ` Greg KH
2008-08-25 14:58 ` Tejun Heo
2008-08-25 14:59 ` Tejun Heo
2008-08-25 14:58 ` Jens Axboe
2008-08-25 21:42 ` Greg KH
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=1219655740-11672-2-git-send-email-tj@kernel.org \
--to=tj@kernel.org \
--cc=draconux@gmail.com \
--cc=gregkh@suse.de \
--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 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.