diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2011-07-12 14:48:39 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2011-07-20 20:47:50 -0400 |
commit | f15146380d28b746df3c8b81b392812eb982382a (patch) | |
tree | bf43b38b60c21bd01b007c9636062783d406eb29 /drivers/md/md.c | |
parent | 72c5052ddc3956d847f21c2b8d55c93664a51b2c (diff) |
fs: seq_file - add event counter to simplify poll() support
Moving the event counter into the dynamically allocated 'struc seq_file'
allows poll() support without the need to allocate its own tracking
structure.
All current users are switched over to use the new counter.
Requested-by: Andrew Morton akpm@linux-foundation.org
Acked-by: NeilBrown <neilb@suse.de>
Tested-by: Lucas De Marchi lucas.demarchi@profusion.mobi
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r-- | drivers/md/md.c | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 91e31e260b4a..dfc9425db70b 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -6394,16 +6394,11 @@ static void md_seq_stop(struct seq_file *seq, void *v) | |||
6394 | mddev_put(mddev); | 6394 | mddev_put(mddev); |
6395 | } | 6395 | } |
6396 | 6396 | ||
6397 | struct mdstat_info { | ||
6398 | int event; | ||
6399 | }; | ||
6400 | |||
6401 | static int md_seq_show(struct seq_file *seq, void *v) | 6397 | static int md_seq_show(struct seq_file *seq, void *v) |
6402 | { | 6398 | { |
6403 | mddev_t *mddev = v; | 6399 | mddev_t *mddev = v; |
6404 | sector_t sectors; | 6400 | sector_t sectors; |
6405 | mdk_rdev_t *rdev; | 6401 | mdk_rdev_t *rdev; |
6406 | struct mdstat_info *mi = seq->private; | ||
6407 | struct bitmap *bitmap; | 6402 | struct bitmap *bitmap; |
6408 | 6403 | ||
6409 | if (v == (void*)1) { | 6404 | if (v == (void*)1) { |
@@ -6415,7 +6410,7 @@ static int md_seq_show(struct seq_file *seq, void *v) | |||
6415 | 6410 | ||
6416 | spin_unlock(&pers_lock); | 6411 | spin_unlock(&pers_lock); |
6417 | seq_printf(seq, "\n"); | 6412 | seq_printf(seq, "\n"); |
6418 | mi->event = atomic_read(&md_event_count); | 6413 | seq->poll_event = atomic_read(&md_event_count); |
6419 | return 0; | 6414 | return 0; |
6420 | } | 6415 | } |
6421 | if (v == (void*)2) { | 6416 | if (v == (void*)2) { |
@@ -6527,26 +6522,21 @@ static const struct seq_operations md_seq_ops = { | |||
6527 | 6522 | ||
6528 | static int md_seq_open(struct inode *inode, struct file *file) | 6523 | static int md_seq_open(struct inode *inode, struct file *file) |
6529 | { | 6524 | { |
6525 | struct seq_file *seq; | ||
6530 | int error; | 6526 | int error; |
6531 | struct mdstat_info *mi = kmalloc(sizeof(*mi), GFP_KERNEL); | ||
6532 | if (mi == NULL) | ||
6533 | return -ENOMEM; | ||
6534 | 6527 | ||
6535 | error = seq_open(file, &md_seq_ops); | 6528 | error = seq_open(file, &md_seq_ops); |
6536 | if (error) | 6529 | if (error) |
6537 | kfree(mi); | 6530 | return error; |
6538 | else { | 6531 | |
6539 | struct seq_file *p = file->private_data; | 6532 | seq = file->private_data; |
6540 | p->private = mi; | 6533 | seq->poll_event = atomic_read(&md_event_count); |
6541 | mi->event = atomic_read(&md_event_count); | ||
6542 | } | ||
6543 | return error; | 6534 | return error; |
6544 | } | 6535 | } |
6545 | 6536 | ||
6546 | static unsigned int mdstat_poll(struct file *filp, poll_table *wait) | 6537 | static unsigned int mdstat_poll(struct file *filp, poll_table *wait) |
6547 | { | 6538 | { |
6548 | struct seq_file *m = filp->private_data; | 6539 | struct seq_file *seq = filp->private_data; |
6549 | struct mdstat_info *mi = m->private; | ||
6550 | int mask; | 6540 | int mask; |
6551 | 6541 | ||
6552 | poll_wait(filp, &md_event_waiters, wait); | 6542 | poll_wait(filp, &md_event_waiters, wait); |
@@ -6554,7 +6544,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait) | |||
6554 | /* always allow read */ | 6544 | /* always allow read */ |
6555 | mask = POLLIN | POLLRDNORM; | 6545 | mask = POLLIN | POLLRDNORM; |
6556 | 6546 | ||
6557 | if (mi->event != atomic_read(&md_event_count)) | 6547 | if (seq->poll_event != atomic_read(&md_event_count)) |
6558 | mask |= POLLERR | POLLPRI; | 6548 | mask |= POLLERR | POLLPRI; |
6559 | return mask; | 6549 | return mask; |
6560 | } | 6550 | } |