Commit a6a8bd6d authored by Pavel Emelianov's avatar Pavel Emelianov Committed by Linus Torvalds

Make AFS use seq_list_xxx helpers

These proc files show some header before dumping the list, so the
seq_list_start_head() is used.
Signed-off-by: default avatarPavel Emelianov <xemul@openvz.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b4ef0296
...@@ -201,23 +201,9 @@ static int afs_proc_cells_open(struct inode *inode, struct file *file) ...@@ -201,23 +201,9 @@ static int afs_proc_cells_open(struct inode *inode, struct file *file)
*/ */
static void *afs_proc_cells_start(struct seq_file *m, loff_t *_pos) static void *afs_proc_cells_start(struct seq_file *m, loff_t *_pos)
{ {
struct list_head *_p;
loff_t pos = *_pos;
/* lock the list against modification */ /* lock the list against modification */
down_read(&afs_proc_cells_sem); down_read(&afs_proc_cells_sem);
return seq_list_start_head(&afs_proc_cells, *_pos);
/* allow for the header line */
if (!pos)
return (void *) 1;
pos--;
/* find the n'th element in the list */
list_for_each(_p, &afs_proc_cells)
if (!pos--)
break;
return _p != &afs_proc_cells ? _p : NULL;
} }
/* /*
...@@ -225,14 +211,7 @@ static void *afs_proc_cells_start(struct seq_file *m, loff_t *_pos) ...@@ -225,14 +211,7 @@ static void *afs_proc_cells_start(struct seq_file *m, loff_t *_pos)
*/ */
static void *afs_proc_cells_next(struct seq_file *p, void *v, loff_t *pos) static void *afs_proc_cells_next(struct seq_file *p, void *v, loff_t *pos)
{ {
struct list_head *_p; return seq_list_next(v, &afs_proc_cells, pos);
(*pos)++;
_p = v;
_p = v == (void *) 1 ? afs_proc_cells.next : _p->next;
return _p != &afs_proc_cells ? _p : NULL;
} }
/* /*
...@@ -250,7 +229,7 @@ static int afs_proc_cells_show(struct seq_file *m, void *v) ...@@ -250,7 +229,7 @@ static int afs_proc_cells_show(struct seq_file *m, void *v)
{ {
struct afs_cell *cell = list_entry(v, struct afs_cell, proc_link); struct afs_cell *cell = list_entry(v, struct afs_cell, proc_link);
if (v == (void *) 1) { if (v == &afs_proc_cells) {
/* display header on line 1 */ /* display header on line 1 */
seq_puts(m, "USE NAME\n"); seq_puts(m, "USE NAME\n");
return 0; return 0;
...@@ -503,26 +482,13 @@ static int afs_proc_cell_volumes_release(struct inode *inode, struct file *file) ...@@ -503,26 +482,13 @@ static int afs_proc_cell_volumes_release(struct inode *inode, struct file *file)
*/ */
static void *afs_proc_cell_volumes_start(struct seq_file *m, loff_t *_pos) static void *afs_proc_cell_volumes_start(struct seq_file *m, loff_t *_pos)
{ {
struct list_head *_p;
struct afs_cell *cell = m->private; struct afs_cell *cell = m->private;
loff_t pos = *_pos;
_enter("cell=%p pos=%Ld", cell, *_pos); _enter("cell=%p pos=%Ld", cell, *_pos);
/* lock the list against modification */ /* lock the list against modification */
down_read(&cell->vl_sem); down_read(&cell->vl_sem);
return seq_list_start_head(&cell->vl_list, *_pos);
/* allow for the header line */
if (!pos)
return (void *) 1;
pos--;
/* find the n'th element in the list */
list_for_each(_p, &cell->vl_list)
if (!pos--)
break;
return _p != &cell->vl_list ? _p : NULL;
} }
/* /*
...@@ -531,17 +497,10 @@ static void *afs_proc_cell_volumes_start(struct seq_file *m, loff_t *_pos) ...@@ -531,17 +497,10 @@ static void *afs_proc_cell_volumes_start(struct seq_file *m, loff_t *_pos)
static void *afs_proc_cell_volumes_next(struct seq_file *p, void *v, static void *afs_proc_cell_volumes_next(struct seq_file *p, void *v,
loff_t *_pos) loff_t *_pos)
{ {
struct list_head *_p;
struct afs_cell *cell = p->private; struct afs_cell *cell = p->private;
_enter("cell=%p pos=%Ld", cell, *_pos); _enter("cell=%p pos=%Ld", cell, *_pos);
return seq_list_next(v, &cell->vl_list, _pos);
(*_pos)++;
_p = v;
_p = (v == (void *) 1) ? cell->vl_list.next : _p->next;
return (_p != &cell->vl_list) ? _p : NULL;
} }
/* /*
...@@ -569,11 +528,12 @@ const char afs_vlocation_states[][4] = { ...@@ -569,11 +528,12 @@ const char afs_vlocation_states[][4] = {
*/ */
static int afs_proc_cell_volumes_show(struct seq_file *m, void *v) static int afs_proc_cell_volumes_show(struct seq_file *m, void *v)
{ {
struct afs_cell *cell = m->private;
struct afs_vlocation *vlocation = struct afs_vlocation *vlocation =
list_entry(v, struct afs_vlocation, link); list_entry(v, struct afs_vlocation, link);
/* display header on line 1 */ /* display header on line 1 */
if (v == (void *) 1) { if (v == &cell->vl_list) {
seq_puts(m, "USE STT VLID[0] VLID[1] VLID[2] NAME\n"); seq_puts(m, "USE STT VLID[0] VLID[1] VLID[2] NAME\n");
return 0; return 0;
} }
...@@ -734,26 +694,13 @@ static int afs_proc_cell_servers_release(struct inode *inode, ...@@ -734,26 +694,13 @@ static int afs_proc_cell_servers_release(struct inode *inode,
static void *afs_proc_cell_servers_start(struct seq_file *m, loff_t *_pos) static void *afs_proc_cell_servers_start(struct seq_file *m, loff_t *_pos)
__acquires(m->private->servers_lock) __acquires(m->private->servers_lock)
{ {
struct list_head *_p;
struct afs_cell *cell = m->private; struct afs_cell *cell = m->private;
loff_t pos = *_pos;
_enter("cell=%p pos=%Ld", cell, *_pos); _enter("cell=%p pos=%Ld", cell, *_pos);
/* lock the list against modification */ /* lock the list against modification */
read_lock(&cell->servers_lock); read_lock(&cell->servers_lock);
return seq_list_start_head(&cell->servers, *_pos);
/* allow for the header line */
if (!pos)
return (void *) 1;
pos--;
/* find the n'th element in the list */
list_for_each(_p, &cell->servers)
if (!pos--)
break;
return _p != &cell->servers ? _p : NULL;
} }
/* /*
...@@ -762,17 +709,10 @@ static void *afs_proc_cell_servers_start(struct seq_file *m, loff_t *_pos) ...@@ -762,17 +709,10 @@ static void *afs_proc_cell_servers_start(struct seq_file *m, loff_t *_pos)
static void *afs_proc_cell_servers_next(struct seq_file *p, void *v, static void *afs_proc_cell_servers_next(struct seq_file *p, void *v,
loff_t *_pos) loff_t *_pos)
{ {
struct list_head *_p;
struct afs_cell *cell = p->private; struct afs_cell *cell = p->private;
_enter("cell=%p pos=%Ld", cell, *_pos); _enter("cell=%p pos=%Ld", cell, *_pos);
return seq_list_next(v, &cell->servers, _pos);
(*_pos)++;
_p = v;
_p = v == (void *) 1 ? cell->servers.next : _p->next;
return _p != &cell->servers ? _p : NULL;
} }
/* /*
...@@ -791,11 +731,12 @@ static void afs_proc_cell_servers_stop(struct seq_file *p, void *v) ...@@ -791,11 +731,12 @@ static void afs_proc_cell_servers_stop(struct seq_file *p, void *v)
*/ */
static int afs_proc_cell_servers_show(struct seq_file *m, void *v) static int afs_proc_cell_servers_show(struct seq_file *m, void *v)
{ {
struct afs_cell *cell = m->private;
struct afs_server *server = list_entry(v, struct afs_server, link); struct afs_server *server = list_entry(v, struct afs_server, link);
char ipaddr[20]; char ipaddr[20];
/* display header on line 1 */ /* display header on line 1 */
if (v == (void *) 1) { if (v == &cell->servers) {
seq_puts(m, "USE ADDR STATE\n"); seq_puts(m, "USE ADDR STATE\n");
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