All of lore.kernel.org
 help / color / mirror / Atom feed
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 v3] proc/mounts: add cursor
Date: Fri, 10 Apr 2020 02:11:19 +0100	[thread overview]
Message-ID: <20200410011119.GH23230@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20200409212214.GG28467@miu.piliscsaba.redhat.com>

On Thu, Apr 09, 2020 at 11:22:14PM +0200, Miklos Szeredi wrote:

> @@ -1249,42 +1277,50 @@ struct vfsmount *mnt_clone_internal(cons
>  static void *m_start(struct seq_file *m, loff_t *pos)
>  {
>  	struct proc_mounts *p = m->private;
> +	struct mount *mnt = NULL;
>  
>  	down_read(&namespace_sem);
> -	if (p->cached_event == p->ns->event) {
> -		void *v = p->cached_mount;
> -		if (*pos == p->cached_index)
> -			return v;
> -		if (*pos == p->cached_index + 1) {
> -			v = seq_list_next(v, &p->ns->list, &p->cached_index);
> -			return p->cached_mount = v;
> -		}
> -	}
> +	lock_ns_list(p->ns);
> +	if (!*pos)
> +		list_move(&p->cursor.mnt_list, &p->ns->list);
> +	if (!list_empty(&p->cursor.mnt_list))
> +		mnt = mnt_skip_cursors(p->ns, &p->cursor);
> +	unlock_ns_list(p->ns);

Huh?  What's that if (!list_empty()) about?  The case where we have reached
the end of list, then did a read() with an lseek() in between?

If so, then this is out of place under your spinlock; "is on the list"
state changes only synchronously (seq_file ->lock serializes all of
that).  *If* this is what you've meant, I'd suggest
	/* read after we'd reached the end? */
	if (*pos && list_empty(...))
		return NULL;
	lock_ns_list(p->ns);
	if (!*pos)
		list_move(...); /* rewind on lseek or initial read */
	mnt = mnt_skip_cursors(...);
	unlock_ns_list(p->ns);

Or am I misreading your intent there?  Confused...

  reply	other threads:[~2020-04-10  1:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-09 21:22 [PATCH v3] proc/mounts: add cursor Miklos Szeredi
2020-04-10  1:11 ` Al Viro [this message]
2020-04-10  5:07   ` Miklos Szeredi

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=20200410011119.GH23230@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.