Home » Mailing lists » Devel » [PATCH 0/15] Make common helpers for seq_files that work with list_head-s (v2)
[PATCH 4/15] Make block layer /proc files use seq_list_xxx helpers [message #13052 is a reply to message #13048] |
Fri, 18 May 2007 09:27   |
xemul
Messages: 248 Registered: November 2005
|
Senior Member |
|
|
The /proc/partitions .show callback checked the *v to be
the first element in list to show the header. Now *v is the
struct list_head pointer and it is checked for the head of
the list.
The comment in /proc/diskstats .show handler is also updated
not to forget it in the future.
Signed-off-by: Pavel Emelianov <xemul@openvz.org>
---
diff --git a/block/genhd.c b/block/genhd.c
index 863a8c0..8813c14 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -270,22 +270,13 @@ void __init printk_all_partitions(void)
/* iterator */
static void *part_start(struct seq_file *part, loff_t *pos)
{
- struct list_head *p;
- loff_t l = *pos;
-
mutex_lock(&block_subsys_lock);
- list_for_each(p, &block_subsys.list)
- if (!l--)
- return list_entry(p, struct gendisk, kobj.entry);
- return NULL;
+ return seq_list_start_head(&block_subsys.list, *pos);
}
static void *part_next(struct seq_file *part, void *v, loff_t *pos)
{
- struct list_head *p = ((struct gendisk *)v)->kobj.entry.next;
- ++*pos;
- return p==&block_subsys.list ? NULL :
- list_entry(p, struct gendisk, kobj.entry);
+ return seq_list_next(v, &block_subsys.list, pos);
}
static void part_stop(struct seq_file *part, void *v)
@@ -295,13 +286,16 @@ static void part_stop(struct seq_file *p
static int show_partition(struct seq_file *part, void *v)
{
- struct gendisk *sgp = v;
+ struct gendisk *sgp;
int n;
char buf[BDEVNAME_SIZE];
- if (&sgp->kobj.entry == block_subsys.list.next)
+ if (v == &block_subsys.list) {
seq_puts(part, "major minor #blocks name\n\n");
+ return 0;
+ }
+ sgp = list_entry(v, struct gendisk, kobj.entry);
/* Don't show non-partitionable removeable devices or empty devices */
if (!get_capacity(sgp) ||
(sgp->minors == 1 && (sgp->flags & GENHD_FL_REMOVABLE)))
@@ -622,22 +616,13 @@ decl_subsys(block, &ktype_block, &block_
/* iterator */
static void *diskstats_start(struct seq_file *part, loff_t *pos)
{
- loff_t k = *pos;
- struct list_head *p;
-
mutex_lock(&block_subsys_lock);
- list_for_each(p, &block_subsys.list)
- if (!k--)
- return list_entry(p, struct gendisk, kobj.entry);
- return NULL;
+ return seq_list_start(&block_subsys.list, *pos);
}
static void *diskstats_next(struct seq_file *part, void *v, loff_t *pos)
{
- struct list_head *p = ((struct gendisk *)v)->kobj.entry.next;
- ++*pos;
- return p==&block_subsys.list ? NULL :
- list_entry(p, struct gendisk, kobj.entry);
+ return seq_list_next(v, &block_subsys.list, pos);
}
static void diskstats_stop(struct seq_file *part, void *v)
@@ -647,18 +632,21 @@ static void diskstats_stop(struct seq_fi
static int diskstats_show(struct seq_file *s, void *v)
{
- struct gendisk *gp = v;
+ struct gendisk *gp;
char buf[BDEVNAME_SIZE];
int n = 0;
/*
- if (&sgp->kobj.entry == block_subsys.kset.list.next)
+ if (v == &block_subsys.list) {
seq_puts(s, "major minor name"
" rio rmerge rsect ruse wio wmerge "
"wsect wuse running use aveq"
"\n\n");
+ return 0;
+ }
*/
+ gp = list_entry(v, struct gendisk, kobj.entry);
preempt_disable();
disk_round_stats(gp);
preempt_enable();
|
|
|
 |
|
[PATCH 0/15] Make common helpers for seq_files that work with list_head-s (v2)
By: xemul on Fri, 18 May 2007 09:11
|
 |
|
[PATCH 1/15] The helper functions itselves
By: xemul on Fri, 18 May 2007 09:17
|
 |
|
Re: [PATCH 1/15] The helper functions itselves
|
 |
|
[PATCH 2/15] Make AFS use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 09:20
|
 |
|
[PATCH 3/15] Make ATM driver use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 09:23
|
 |
|
[PATCH 4/15] Make block layer /proc files use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 09:27
|
 |
|
[PATCH 5/15] Make crypto API use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 09:29
|
 |
|
Re: [PATCH 5/15] Make crypto API use seq_list_xxx helpers
|
 |
|
[PATCH 6/15] Make input layer use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 09:33
|
 |
|
[PATCH 7/15] Make ISDN CAPI use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 09:36
|
 |
|
Re: [PATCH 7/15] Make ISDN CAPI use seq_list_xxx helpers
|
 |
|
[PATCH 8/15] Make /proc/misc use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 09:39
|
 |
|
[PATCH 9/15] Make /proc/modules use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 09:41
|
 |
|
[PATCH 10/15] Make some network-related proc files use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 09:48
|
 |
|
Re: [PATCH 10/15] Make some network-related proc files use seq_list_xxx helpers
By: davem on Fri, 18 May 2007 10:24
|
 |
|
[PATCH 11/15] Make some netfilter-related proc files use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 09:55
|
 |
|
[PATCH 12/15] Make NFS client use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 10:00
|
 |
|
Re: [PATCH 12/15] Make NFS client use seq_list_xxx helpers
|
 |
|
[PATCH 13/15] Make /proc/tty/drivers use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 10:02
|
 |
|
[PATCH 14/15] Make /proc/slabinfo use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 10:06
|
 |
|
[PATCH 15/15] Make /proc/self/mounts(tats) use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 10:10
|
Goto Forum:
Current Time: Sat Sep 06 21:34:14 GMT 2025
Total time taken to generate the page: 0.13422 seconds
|