From: Pavel Emelianov <xemul@sw.ru>
To: Andrew Morton <akpm@osdl.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
axboe@kernel.dk, devel@openvz.org
Subject: [PATCH 4/15] Make block layer /proc files use seq_list_xxx helpers
Date: Fri, 18 May 2007 13:32:12 +0400 [thread overview]
Message-ID: <464D729C.6080603@sw.ru> (raw)
In-Reply-To: <464D6E87.7060605@sw.ru>
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();
next prev parent reply other threads:[~2007-05-18 9:28 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-18 9:14 [PATCH 0/15] Make common helpers for seq_files that work with list_head-s (v2) Pavel Emelianov
2007-05-18 9:21 ` [PATCH 1/15] The helper functions itselves Pavel Emelianov
2007-05-18 9:25 ` [PATCH 2/15] Make AFS use seq_list_xxx helpers Pavel Emelianov
2007-05-18 9:28 ` [PATCH 3/15] Make ATM driver " Pavel Emelianov
2007-05-18 9:32 ` Pavel Emelianov [this message]
2007-05-18 9:34 ` [PATCH 5/15] Make crypto API " Pavel Emelianov
2007-05-18 10:13 ` Herbert Xu
2007-05-18 9:37 ` [PATCH 6/15] Make input layer " Pavel Emelianov
2007-05-18 9:41 ` [PATCH 7/15] Make ISDN CAPI " Pavel Emelianov
2007-05-18 9:43 ` [PATCH 8/15] Make /proc/misc " Pavel Emelianov
2007-05-18 9:46 ` [PATCH 9/15] Make /proc/modules " Pavel Emelianov
2007-05-18 9:53 ` [PATCH 10/15] Make some network-related proc files " Pavel Emelianov
2007-05-18 10:24 ` David Miller
2007-05-18 9:59 ` [PATCH 1/15] The helper functions itselves David Howells
2007-05-18 10:00 ` [PATCH 11/15] Make some netfilter-related proc files use seq_list_xxx helpers Pavel Emelianov
2007-05-18 10:04 ` [PATCH 12/15] Make NFS client " Pavel Emelianov
2007-05-18 17:42 ` Trond Myklebust
2007-05-18 10:07 ` [PATCH 13/15] Make /proc/tty/drivers " Pavel Emelianov
2007-05-18 10:11 ` [PATCH 14/15] Make /proc/slabinfo " Pavel Emelianov
2007-05-18 10:14 ` [PATCH 15/15] Make /proc/self/mounts(tats) " Pavel Emelianov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=464D729C.6080603@sw.ru \
--to=xemul@sw.ru \
--cc=akpm@osdl.org \
--cc=axboe@kernel.dk \
--cc=devel@openvz.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome