Commit ac65ece4 authored by Tejun Heo's avatar Tejun Heo Committed by Jens Axboe

block: fix partition info printouts

Recent block_class iteration updates 5c6f35c5..27f30251 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: default avatarTejun Heo <tj@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
parent 5a3ceb86
...@@ -236,7 +236,7 @@ static int printk_partition(struct device *dev, void *data) ...@@ -236,7 +236,7 @@ static int printk_partition(struct device *dev, void *data)
int n; int n;
if (dev->type != &disk_type) if (dev->type != &disk_type)
goto exit; return 0;
sgp = dev_to_disk(dev); sgp = dev_to_disk(dev);
/* /*
...@@ -244,7 +244,7 @@ static int printk_partition(struct device *dev, void *data) ...@@ -244,7 +244,7 @@ static int printk_partition(struct device *dev, void *data)
*/ */
if (get_capacity(sgp) == 0 || if (get_capacity(sgp) == 0 ||
(sgp->flags & GENHD_FL_SUPPRESS_PARTITION_INFO)) (sgp->flags & GENHD_FL_SUPPRESS_PARTITION_INFO))
goto exit; return 0;
/* /*
* Note, unlike /proc/partitions, I am showing the numbers in * Note, unlike /proc/partitions, I am showing the numbers in
...@@ -264,15 +264,15 @@ static int printk_partition(struct device *dev, void *data) ...@@ -264,15 +264,15 @@ static int printk_partition(struct device *dev, void *data)
/* now show the partitions */ /* now show the partitions */
for (n = 0; n < sgp->minors - 1; ++n) { for (n = 0; n < sgp->minors - 1; ++n) {
if (sgp->part[n] == NULL) if (sgp->part[n] == NULL)
goto exit; continue;
if (sgp->part[n]->nr_sects == 0) if (sgp->part[n]->nr_sects == 0)
goto exit; continue;
printk(" %02x%02x %10llu %s\n", printk(" %02x%02x %10llu %s\n",
sgp->major, n + 1 + sgp->first_minor, sgp->major, n + 1 + sgp->first_minor,
(unsigned long long)sgp->part[n]->nr_sects >> 1, (unsigned long long)sgp->part[n]->nr_sects >> 1,
disk_name(sgp, n + 1, buf)); disk_name(sgp, n + 1, buf));
} }
exit:
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment