From: Trond Myklebust <trondmy@primarydata.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Schumaker Anna <anna.schumaker@netapp.com>,
List Linux NFS Mailing <linux-nfs@vger.kernel.org>,
List Linux Kernel Mailing <linux-kernel@vger.kernel.org>,
"tglx@linutronix.de" <tglx@linutronix.de>
Subject: Re: [PATCH v3] NFSv4: replace seqcount_t with a rw_semaphore
Date: Mon, 31 Oct 2016 15:30:02 +0000 [thread overview]
Message-ID: <51E3F753-2D1F-4370-BFEB-BD8356D622A1@primarydata.com> (raw)
In-Reply-To: <20161031131958.mrrez5t7sow75p6v@linutronix.de>
> On Oct 31, 2016, at 09:19, Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:
>
> The raw_write_seqcount_begin() in nfs4_reclaim_open_state() bugs me
> because it maps to preempt_disable() in -RT which I can't have at this
> point. So I took a look at the code.
> It the lockdep part was removed in commit abbec2da13f0 ("NFS: Use
> raw_write_seqcount_begin/end int nfs4_reclaim_open_state") because
> lockdep complained. The whole seqcount thing was introduced in commit
> c137afabe330 ("NFSv4: Allow the state manager to mark an open_owner as
> being recovered").
> Trond Myklebust confirms that there i only one writer thread at
> nfs4_reclaim_open_state()
>
> The list_for_each_entry() in nfs4_reclaim_open_state:
> It seems that this lock protects the ->so_states list among other
> atomic_t & flags members. So at the begin of the loop we inc ->count
> ensuring that this field is not removed while we use it. So we drop the
> ->so_lock loc during the loop it seems. And after nfs4_reclaim_locks()
> invocation we nfs4_put_open_state() and grab the ->so_lock again. So if
> we were the last user of this struct and we remove it, then the
> following list_next_entry() invocation is a use-after-free. Even if we
> use list_for_each_entry_safe() there is no guarantee that the following
> member is still valid because it might have been removed by someone
> invoking nfs4_put_open_state() on it, right?
> So there is this.
>
> However to address my initial problem I have here a patch :) So it uses
> a rw_semaphore which ensures that there is only one writer at a time or
> multiple reader. So it should be basically what is happening now plus a
> tiny tiny tiny lock plus lockdep coverage. I tried to this myself but I
> don't manage to get into this code path at all so I might be doing
> something wrong.
>
> Could you please check if this patch is working for you and whether my
> list_for_each_entry() observation is correct or not?
>
> v2…v3: replace the seqlock with a RW semaphore.
>
NACK. That will deadlock. The reason why we use a seqlock there is precisely because we cannot allow ordinary RPC calls to lock out the recovery thread. If the server reboots, then ordinary RPC calls will fail until the recovery thread has had a chance to re-establish the state.
next prev parent reply other threads:[~2016-10-31 15:30 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-21 16:47 [RFC PATCH] NFSv4: replace seqcount_t with a seqlock_t Sebastian Andrzej Siewior
2016-10-25 6:52 ` [lkp] [NFSv4] 931437ee2c: BUG: sleeping function called from invalid context at mm/slab.h:393 kernel test robot
2016-10-28 21:08 ` Sebastian Andrzej Siewior
2016-10-28 21:05 ` [PATCH v2] NFSv4: replace seqcount_t with a seqlock_t Sebastian Andrzej Siewior
2016-10-28 22:24 ` Trond Myklebust
2016-10-31 10:46 ` Sebastian Andrzej Siewior
2016-10-31 13:19 ` [PATCH v3] NFSv4: replace seqcount_t with a rw_semaphore Sebastian Andrzej Siewior
2016-10-31 15:30 ` Trond Myklebust [this message]
2016-10-31 15:56 ` Sebastian Andrzej Siewior
2016-10-31 16:11 ` Trond Myklebust
2016-11-02 17:11 ` Sebastian Andrzej Siewior
2016-11-02 17:37 ` Trond Myklebust
2016-11-02 17:15 ` [PATCH v4] NFSv4: replace seqcount_t with a seqlock_t Sebastian Andrzej Siewior
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=51E3F753-2D1F-4370-BFEB-BD8356D622A1@primarydata.com \
--to=trondmy@primarydata.com \
--cc=anna.schumaker@netapp.com \
--cc=bigeasy@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=tglx@linutronix.de \
/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
all inboxes | Powered by JetHome®