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 07:04:22 +0100 [thread overview]
Message-ID: <20200410060422.GJ23230@ZenIV.linux.org.uk> (raw)
In-Reply-To: <CAJfpegvse9GrzncMOShNf80-7a6AMaAEGdbpL739RBzQmpQdMw@mail.gmail.com>
On Fri, Apr 10, 2020 at 07:23:47AM +0200, Miklos Szeredi wrote:
> > 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.
Sure, it's just that I suspect that result will be somewhat more
readable that way.
Incidentally, there might be another benefit - both &p->ns->list.next
and &p->mnt.mnt_list.next are not going to change. So calculation of
prev can be lifter out of lock_ns_list() and _that_ promises something
more tasty - all callers of mnt_skip_cursors() are immediately
surrounded by lock_ns_list()/unlock_ns_list() and those can be moved
inside the damn thing.
prev parent reply other threads:[~2020-04-10 6:04 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
2020-04-10 5:23 ` Miklos Szeredi
2020-04-10 6:04 ` Al Viro [this message]
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=20200410060422.GJ23230@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).