Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 143963
b: refs/heads/master
c: 71982a4
h: refs/heads/master
i:
  143961: acd6be3
  143959: 76f3084
v: v3
  • Loading branch information
Tejun Heo authored and Jens Axboe committed Apr 22, 2009
1 parent c011989 commit 81ab4f0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a9e9dc24bbc3e084450a22cf4fb82f5f5d4cbeea
refs/heads/master: 71982a409f12c50d011325a4471aa20666bb908d
12 changes: 8 additions & 4 deletions trunk/block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void disk_part_iter_init(struct disk_part_iter *piter, struct gendisk *disk,

if (flags & DISK_PITER_REVERSE)
piter->idx = ptbl->len - 1;
else if (flags & DISK_PITER_INCL_PART0)
else if (flags & (DISK_PITER_INCL_PART0 | DISK_PITER_INCL_EMPTY_PART0))
piter->idx = 0;
else
piter->idx = 1;
Expand Down Expand Up @@ -134,7 +134,8 @@ struct hd_struct *disk_part_iter_next(struct disk_part_iter *piter)
/* determine iteration parameters */
if (piter->flags & DISK_PITER_REVERSE) {
inc = -1;
if (piter->flags & DISK_PITER_INCL_PART0)
if (piter->flags & (DISK_PITER_INCL_PART0 |
DISK_PITER_INCL_EMPTY_PART0))
end = -1;
else
end = 0;
Expand All @@ -150,7 +151,10 @@ struct hd_struct *disk_part_iter_next(struct disk_part_iter *piter)
part = rcu_dereference(ptbl->part[piter->idx]);
if (!part)
continue;
if (!(piter->flags & DISK_PITER_INCL_EMPTY) && !part->nr_sects)
if (!part->nr_sects &&
!(piter->flags & DISK_PITER_INCL_EMPTY) &&
!(piter->flags & DISK_PITER_INCL_EMPTY_PART0 &&
piter->idx == 0))
continue;

get_device(part_to_dev(part));
Expand Down Expand Up @@ -1011,7 +1015,7 @@ static int diskstats_show(struct seq_file *seqf, void *v)
"\n\n");
*/

disk_part_iter_init(&piter, gp, DISK_PITER_INCL_PART0);
disk_part_iter_init(&piter, gp, DISK_PITER_INCL_EMPTY_PART0);
while ((hd = disk_part_iter_next(&piter))) {
cpu = part_stat_lock();
part_round_stats(cpu, hd);
Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/genhd.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ static inline void disk_put_part(struct hd_struct *part)
#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 */

struct disk_part_iter {
struct gendisk *disk;
Expand Down

0 comments on commit 81ab4f0

Please sign in to comment.