lkml.org 
[lkml]   [2008]   [Aug]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] block: fix partition info printouts
Date
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


\
 
 \ /
  Last update: 2008-08-25 11:21    [W:0.099 / U:42.772 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site