On Fri, Apr 10, 2020 at 7:14 AM Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote: > > On Fri, Apr 10, 2020 at 07:05:22AM +0200, Miklos Szeredi wrote: > > + /* read after we'd reached the end? */ > > + if (*pos && list_empty(&mnt->mnt_list)) > > + return NULL; > > + > > + lock_ns_list(p->ns); > > + if (!*pos) > > + mnt = list_first_entry(&p->ns->list, typeof(*mnt), mnt_list); > > + mnt = mnt_skip_cursors(p->ns, mnt); > > + unlock_ns_list(p->ns); > > > > - p->cached_event = p->ns->event; > > - p->cached_mount = seq_list_start(&p->ns->list, *pos); > > - p->cached_index = *pos; > > - return p->cached_mount; > > + return mnt; > > } > > Hmm... I wonder if it would be better to do something like > if (!*pos) > prev = &p->ns->list.next; > else > prev = &p->mnt.mnt_list.next; > mnt = mnt_skip_cursors(p->ns, prev); > > > static void *m_next(struct seq_file *m, void *v, loff_t *pos) > > { > > struct proc_mounts *p = m->private; > > + struct mount *mnt = v; > > + > > + lock_ns_list(p->ns); > > + mnt = mnt_skip_cursors(p->ns, list_next_entry(mnt, mnt_list)); > > ... and mnt = mnt_skip_cursors(p->ns, &mnt->mnt_list.next); If you prefer that, yes. Functionally it's equivalent. Thanks, Miklos