All of lore.kernel.org
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: dai.ngo@oracle.com
Cc: chuck.lever@oracle.com, linux-nfs@vger.kernel.org,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v3 2/3] nfsd: Initial implementation of NFSv4 Courteous Server
Date: Wed, 22 Sep 2021 21:18:24 -0400	[thread overview]
Message-ID: <20210923011824.GD22937@fieldses.org> (raw)
In-Reply-To: <f38c8587-d5db-d07e-6e28-351221be4a69@oracle.com>

On Wed, Sep 22, 2021 at 03:16:34PM -0700, dai.ngo@oracle.com wrote:
> 
> On 9/22/21 2:14 PM, J. Bruce Fields wrote:
> >On Thu, Sep 16, 2021 at 02:22:11PM -0400, Dai Ngo wrote:
> >>+/*
> >>+ * If the conflict happens due to a NFSv4 request then check for
> >>+ * courtesy client and set rq_conflict_client so that upper layer
> >>+ * can destroy the conflict client and retry the call.
> >>+ */
> >>+static bool
> >>+nfsd_check_courtesy_client(struct nfs4_delegation *dp)
> >>+{
> >>+	struct svc_rqst *rqst;
> >>+	struct nfs4_client *clp = dp->dl_recall.cb_clp;
> >>+	struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
> >>+	bool ret = false;
> >>+
> >>+	if (!i_am_nfsd()) {
> >>+		if (test_bit(NFSD4_COURTESY_CLIENT, &clp->cl_flags)) {
> >>+			set_bit(NFSD4_DESTROY_COURTESY_CLIENT, &clp->cl_flags);
> >>+			mod_delayed_work(laundry_wq, &nn->laundromat_work, 0);
> >>+			return true;
> >>+		}
> >>+		return false;
> >>+	}
> >>+	rqst = kthread_data(current);
> >>+	if (rqst->rq_prog != NFS_PROGRAM || rqst->rq_vers < 4)
> >>+		return false;
> >>+	rqst->rq_conflict_client = NULL;
> >>+
> >>+	spin_lock(&nn->client_lock);
> >>+	if (test_bit(NFSD4_COURTESY_CLIENT, &clp->cl_flags) &&
> >>+				!mark_client_expired_locked(clp)) {
> >>+		rqst->rq_conflict_client = clp;
> >>+		ret = true;
> >>+	}
> >>+	spin_unlock(&nn->client_lock);
> >Check whether this is safe; I think the flc_lock may be taken inside of
> >this lock elsewhere, resulting in a potential deadlock?
> >
> >rqst doesn't need any locking as it's only being used by this thread, so
> >it's the client expiration stuff that's the problem, I guess.
> 
> mark_client_expired_locked needs to acquire cl_lock. I think the lock
> ordering is ok, client_lock -> cl_lock. nfsd4_exchange_id uses this
> lock ordering.

It's flc_lock (see locks.c) that I'm worried about.  I've got a lockdep
warning here, taking a closer look....

nfsd4_release_lockowner takes clp->cl_lock and then fcl_lock.

Here we're taking fcl_lock and then client_lock.

As you say, elsewhere client_lock is taken and then cl_lock.

So that's the loop, I think.

--b.

  reply	other threads:[~2021-09-23  1:18 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-16 18:22 [PATCH RFC v3 0/2] nfsd: Initial implementation of NFSv4 Courteous Server Dai Ngo
2021-09-16 18:22 ` [PATCH v3 1/3] fs/lock: add new callback, lm_expire_lock, to lock_manager_operations Dai Ngo
2021-09-16 18:22 ` [PATCH v3 2/3] nfsd: Initial implementation of NFSv4 Courteous Server Dai Ngo
2021-09-22 21:14   ` J. Bruce Fields
2021-09-22 22:16     ` dai.ngo
2021-09-23  1:18       ` J. Bruce Fields [this message]
2021-09-23 17:09         ` dai.ngo
2021-09-23  1:34   ` J. Bruce Fields
2021-09-23 17:09     ` dai.ngo
2021-09-23 19:32       ` J. Bruce Fields
2021-09-24 20:53         ` dai.ngo
2021-09-16 18:22 ` [PATCH v3 3/3] nfsd: back channel stuck in SEQ4_STATUS_CB_PATH_DOWN Dai Ngo
2021-09-16 19:00   ` Chuck Lever III
2021-09-16 19:55     ` Bruce Fields
2021-09-16 20:15       ` dai.ngo
2021-09-17 18:23         ` dai.ngo
2021-09-23  1:47 ` [PATCH RFC v3 0/2] nfsd: Initial implementation of NFSv4 Courteous Server J. Bruce Fields
2021-09-23 17:15   ` dai.ngo
2021-09-23 19:37     ` dai.ngo

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=20210923011824.GD22937@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=chuck.lever@oracle.com \
    --cc=dai.ngo@oracle.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    /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.