Commit 780ad0f4 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] gendisks list switched to list_head

The list used to generate /proc/partitions turned into list_head one;
we also restore the old order of elements (originally we added to the end
of list; recent changes had reverted that, now we are back to original
order).
parent c9175716
......@@ -31,7 +31,7 @@ static rwlock_t gendisk_lock;
/*
* Global kernel list of partitioning information.
*/
static struct gendisk *gendisk_head;
static LIST_HEAD(gendisk_list);
/*
* TEMPORARY KLUDGE.
......@@ -75,8 +75,10 @@ static void add_gendisk(struct gendisk *gp)
write_lock(&gendisk_lock);
list_add(&gp->list, &gendisks[gp->major].list);
gp->next = gendisk_head;
gendisk_head = gp;
if (gp->minor_shift)
list_add_tail(&gp->full_list, &gendisk_list);
else
INIT_LIST_HEAD(&gp->full_list);
write_unlock(&gendisk_lock);
}
......@@ -92,13 +94,8 @@ EXPORT_SYMBOL(del_gendisk);
void unlink_gendisk(struct gendisk *disk)
{
struct gendisk **p;
write_lock(&gendisk_lock);
for (p = &gendisk_head; *p; p = &((*p)->next))
if (*p == disk)
break;
if (*p)
*p = (*p)->next;
list_del_init(&disk->full_list);
list_del_init(&disk->list);
write_unlock(&gendisk_lock);
}
......@@ -143,21 +140,21 @@ EXPORT_SYMBOL(get_gendisk);
/* iterator */
static void *part_start(struct seq_file *part, loff_t *pos)
{
loff_t k = *pos;
struct gendisk *sgp;
struct list_head *p;
loff_t l = *pos;
read_lock(&gendisk_lock);
for (sgp = gendisk_head; sgp; sgp = sgp->next) {
if (!k--)
return sgp;
}
list_for_each(p, &gendisk_list)
if (!l--)
return list_entry(p, struct gendisk, full_list);
return NULL;
}
static void *part_next(struct seq_file *part, void *v, loff_t *pos)
{
struct list_head *p = ((struct gendisk *)v)->full_list.next;
++*pos;
return ((struct gendisk *)v)->next;
return p==&gendisk_list ? NULL : list_entry(p, struct gendisk, full_list);
}
static void part_stop(struct seq_file *part, void *v)
......@@ -171,11 +168,11 @@ static int show_partition(struct seq_file *part, void *v)
int n;
char buf[64];
if (sgp == gendisk_head)
if (&sgp->full_list == gendisk_list.next)
seq_puts(part, "major minor #blocks name\n\n");
/* Don't show non-partitionable devices or empty devices */
if (!sgp->minor_shift || !get_capacity(sgp))
if (!get_capacity(sgp))
return 0;
/* show the full disk and all non-0 size partitions of it */
......
......@@ -78,10 +78,10 @@ struct gendisk {
get real minor */
struct hd_struct *part; /* [indexed by minor] */
struct gendisk *next;
struct block_device_operations *fops;
sector_t capacity;
struct list_head list;
struct list_head full_list;
int flags;
int number; /* devfs crap */
......
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