From: Al Viro <viro@zeniv.linux.org.uk>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: Karel Zak <kzak@redhat.com>, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v4] proc/mounts: add cursor
Date: Fri, 10 Apr 2020 06:14:57 +0100 [thread overview]
Message-ID: <20200410051457.GI23230@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20200410050522.GI28467@miu.piliscsaba.redhat.com>
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);
next prev parent reply other threads:[~2020-04-10 5:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-10 5:05 [PATCH v4] proc/mounts: add cursor Miklos Szeredi
2020-04-10 5:14 ` Al Viro [this message]
2020-04-10 5:23 ` Miklos Szeredi
2020-04-10 6:04 ` Al Viro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200410051457.GI23230@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=kzak@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.