seq_file: remove m->version
The process maps file was the only user of version (introduced back in 2005). Now that it uses ppos instead, we can remove it. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Link: http://lkml.kernel.org/r/20200317193201.9924-4-adobriyan@gmail.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
4781f2c3ab
commit
b829a0f0f2
@ -67,13 +67,6 @@ int seq_open(struct file *file, const struct seq_operations *op)
|
|||||||
// to the lifetime of the file.
|
// to the lifetime of the file.
|
||||||
p->file = file;
|
p->file = file;
|
||||||
|
|
||||||
/*
|
|
||||||
* Wrappers around seq_open(e.g. swaps_open) need to be
|
|
||||||
* aware of this. If they set f_version themselves, they
|
|
||||||
* should call seq_open first and then set f_version.
|
|
||||||
*/
|
|
||||||
file->f_version = 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* seq_files support lseek() and pread(). They do not implement
|
* seq_files support lseek() and pread(). They do not implement
|
||||||
* write() at all, but we clear FMODE_PWRITE here for historical
|
* write() at all, but we clear FMODE_PWRITE here for historical
|
||||||
@ -94,7 +87,6 @@ static int traverse(struct seq_file *m, loff_t offset)
|
|||||||
int error = 0;
|
int error = 0;
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
m->version = 0;
|
|
||||||
m->index = 0;
|
m->index = 0;
|
||||||
m->count = m->from = 0;
|
m->count = m->from = 0;
|
||||||
if (!offset)
|
if (!offset)
|
||||||
@ -160,26 +152,12 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
|
|||||||
|
|
||||||
mutex_lock(&m->lock);
|
mutex_lock(&m->lock);
|
||||||
|
|
||||||
/*
|
|
||||||
* seq_file->op->..m_start/m_stop/m_next may do special actions
|
|
||||||
* or optimisations based on the file->f_version, so we want to
|
|
||||||
* pass the file->f_version to those methods.
|
|
||||||
*
|
|
||||||
* seq_file->version is just copy of f_version, and seq_file
|
|
||||||
* methods can treat it simply as file version.
|
|
||||||
* It is copied in first and copied out after all operations.
|
|
||||||
* It is convenient to have it as part of structure to avoid the
|
|
||||||
* need of passing another argument to all the seq_file methods.
|
|
||||||
*/
|
|
||||||
m->version = file->f_version;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if request is to read from zero offset, reset iterator to first
|
* if request is to read from zero offset, reset iterator to first
|
||||||
* record as it might have been already advanced by previous requests
|
* record as it might have been already advanced by previous requests
|
||||||
*/
|
*/
|
||||||
if (*ppos == 0) {
|
if (*ppos == 0) {
|
||||||
m->index = 0;
|
m->index = 0;
|
||||||
m->version = 0;
|
|
||||||
m->count = 0;
|
m->count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +168,6 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
|
|||||||
if (err) {
|
if (err) {
|
||||||
/* With prejudice... */
|
/* With prejudice... */
|
||||||
m->read_pos = 0;
|
m->read_pos = 0;
|
||||||
m->version = 0;
|
|
||||||
m->index = 0;
|
m->index = 0;
|
||||||
m->count = 0;
|
m->count = 0;
|
||||||
goto Done;
|
goto Done;
|
||||||
@ -243,7 +220,6 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
|
|||||||
m->buf = seq_buf_alloc(m->size <<= 1);
|
m->buf = seq_buf_alloc(m->size <<= 1);
|
||||||
if (!m->buf)
|
if (!m->buf)
|
||||||
goto Enomem;
|
goto Enomem;
|
||||||
m->version = 0;
|
|
||||||
p = m->op->start(m, &m->index);
|
p = m->op->start(m, &m->index);
|
||||||
}
|
}
|
||||||
m->op->stop(m, p);
|
m->op->stop(m, p);
|
||||||
@ -287,7 +263,6 @@ Done:
|
|||||||
*ppos += copied;
|
*ppos += copied;
|
||||||
m->read_pos += copied;
|
m->read_pos += copied;
|
||||||
}
|
}
|
||||||
file->f_version = m->version;
|
|
||||||
mutex_unlock(&m->lock);
|
mutex_unlock(&m->lock);
|
||||||
return copied;
|
return copied;
|
||||||
Enomem:
|
Enomem:
|
||||||
@ -313,7 +288,6 @@ loff_t seq_lseek(struct file *file, loff_t offset, int whence)
|
|||||||
loff_t retval = -EINVAL;
|
loff_t retval = -EINVAL;
|
||||||
|
|
||||||
mutex_lock(&m->lock);
|
mutex_lock(&m->lock);
|
||||||
m->version = file->f_version;
|
|
||||||
switch (whence) {
|
switch (whence) {
|
||||||
case SEEK_CUR:
|
case SEEK_CUR:
|
||||||
offset += file->f_pos;
|
offset += file->f_pos;
|
||||||
@ -329,7 +303,6 @@ loff_t seq_lseek(struct file *file, loff_t offset, int whence)
|
|||||||
/* with extreme prejudice... */
|
/* with extreme prejudice... */
|
||||||
file->f_pos = 0;
|
file->f_pos = 0;
|
||||||
m->read_pos = 0;
|
m->read_pos = 0;
|
||||||
m->version = 0;
|
|
||||||
m->index = 0;
|
m->index = 0;
|
||||||
m->count = 0;
|
m->count = 0;
|
||||||
} else {
|
} else {
|
||||||
@ -340,7 +313,6 @@ loff_t seq_lseek(struct file *file, loff_t offset, int whence)
|
|||||||
file->f_pos = offset;
|
file->f_pos = offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file->f_version = m->version;
|
|
||||||
mutex_unlock(&m->lock);
|
mutex_unlock(&m->lock);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ struct seq_file {
|
|||||||
size_t pad_until;
|
size_t pad_until;
|
||||||
loff_t index;
|
loff_t index;
|
||||||
loff_t read_pos;
|
loff_t read_pos;
|
||||||
u64 version;
|
|
||||||
struct mutex lock;
|
struct mutex lock;
|
||||||
const struct seq_operations *op;
|
const struct seq_operations *op;
|
||||||
int poll_event;
|
int poll_event;
|
||||||
|
Loading…
Reference in New Issue
Block a user