diff options
-rw-r--r-- | fs/seq_file.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/fs/seq_file.c b/fs/seq_file.c index 4023d6be939b..aa242dc99373 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c | |||
@@ -140,9 +140,21 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos) | |||
140 | 140 | ||
141 | mutex_lock(&m->lock); | 141 | mutex_lock(&m->lock); |
142 | 142 | ||
143 | /* | ||
144 | * seq_file->op->..m_start/m_stop/m_next may do special actions | ||
145 | * or optimisations based on the file->f_version, so we want to | ||
146 | * pass the file->f_version to those methods. | ||
147 | * | ||
148 | * seq_file->version is just copy of f_version, and seq_file | ||
149 | * methods can treat it simply as file version. | ||
150 | * It is copied in first and copied out after all operations. | ||
151 | * It is convenient to have it as part of structure to avoid the | ||
152 | * need of passing another argument to all the seq_file methods. | ||
153 | */ | ||
154 | m->version = file->f_version; | ||
155 | |||
143 | /* Don't assume *ppos is where we left it */ | 156 | /* Don't assume *ppos is where we left it */ |
144 | if (unlikely(*ppos != m->read_pos)) { | 157 | if (unlikely(*ppos != m->read_pos)) { |
145 | m->read_pos = *ppos; | ||
146 | while ((err = traverse(m, *ppos)) == -EAGAIN) | 158 | while ((err = traverse(m, *ppos)) == -EAGAIN) |
147 | ; | 159 | ; |
148 | if (err) { | 160 | if (err) { |
@@ -152,21 +164,11 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos) | |||
152 | m->index = 0; | 164 | m->index = 0; |
153 | m->count = 0; | 165 | m->count = 0; |
154 | goto Done; | 166 | goto Done; |
167 | } else { | ||
168 | m->read_pos = *ppos; | ||
155 | } | 169 | } |
156 | } | 170 | } |
157 | 171 | ||
158 | /* | ||
159 | * seq_file->op->..m_start/m_stop/m_next may do special actions | ||
160 | * or optimisations based on the file->f_version, so we want to | ||
161 | * pass the file->f_version to those methods. | ||
162 | * | ||
163 | * seq_file->version is just copy of f_version, and seq_file | ||
164 | * methods can treat it simply as file version. | ||
165 | * It is copied in first and copied out after all operations. | ||
166 | * It is convenient to have it as part of structure to avoid the | ||
167 | * need of passing another argument to all the seq_file methods. | ||
168 | */ | ||
169 | m->version = file->f_version; | ||
170 | /* grab buffer if we didn't have one */ | 172 | /* grab buffer if we didn't have one */ |
171 | if (!m->buf) { | 173 | if (!m->buf) { |
172 | m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL); | 174 | m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL); |