linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Trond Myklebust <Trond.Myklebust@netapp.com>
To: Jeff Layton <jlayton@redhat.com>
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATCH] nfs: don't queue synchronous NFSv4 close rpc_release to nfsiod
Date: Wed, 16 Feb 2011 09:09:14 -0500	[thread overview]
Message-ID: <1297865354.6596.13.camel@heimdal.trondhjem.org> (raw)
In-Reply-To: <1297813624.10103.34.camel@heimdal.trondhjem.org>

On Tue, 2011-02-15 at 18:47 -0500, Trond Myklebust wrote: 
> diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
> index 243fc09..11b71b1 100644
> --- a/net/sunrpc/sched.c
> +++ b/net/sunrpc/sched.c
> @@ -252,23 +252,39 @@ static void rpc_set_active(struct rpc_task *task)
>  
>  /*
>   * Mark an RPC call as having completed by clearing the 'active' bit
> + * and then waking up all tasks that were sleeping.
>   */
> -static void rpc_mark_complete_task(struct rpc_task *task)
> +static int rpc_complete_task(struct rpc_task *task)
>  {
> -	smp_mb__before_clear_bit();
> +	void *m = &task->tk_runstate;
> +	wait_queue_head_t *wq = bit_waitqueue(m, RPC_TASK_ACTIVE);
> +	struct wait_bit_key k = __WAIT_BIT_KEY_INITIALIZER(m, RPC_TASK_ACTIVE);
> +	unsigned long flags;
> +	int ret;
> +
> +	spin_lock_irqsave(&wq->lock, flags);
>  	clear_bit(RPC_TASK_ACTIVE, &task->tk_runstate);
> -	smp_mb__after_clear_bit();
> -	wake_up_bit(&task->tk_runstate, RPC_TASK_ACTIVE);
> +	if (waitqueue_active(wq))
> +		__wake_up_locked_key(wq, TASK_NORMAL, &k);
> +	ret = atomic_dec_and_test(&task->tk_count);
> +	spin_unlock_irqrestore(&wq->lock, flags);
> +	return ret;
>  }
>  
>  /*
>   * Allow callers to wait for completion of an RPC call
> + *
> + * Note the use of out_of_line_wait_on_bit() rather than wait_on_bit()
> + * to enforce taking of the wq->lock and hence avoid races with
> + * rpc_complete_task().
>   */
>  int __rpc_wait_for_completion_task(struct rpc_task *task, int (*action)(void *))
>  {
> +	BUG_ON(!RPC_IS_ASYNC(task));
> +
>  	if (action == NULL)
>  		action = rpc_wait_bit_killable;
> -	return wait_on_bit(&task->tk_runstate, RPC_TASK_ACTIVE,
> +	return out_of_line_wait_on_bit(&task->tk_runstate, RPC_TASK_ACTIVE,
>  			action, TASK_KILLABLE);
>  }
>  EXPORT_SYMBOL_GPL(__rpc_wait_for_completion_task);

Never mind. The above ordering scheme is broken by the fact that
'wake_bit_function' calls autoremove_wake_function, which again means
that finish_wait optimises away the spin lock.

Back to the drawing board...

-- 
Trond Myklebust
Linux NFS client maintainer

NetApp
Trond.Myklebust@netapp.com
www.netapp.com


  reply	other threads:[~2011-02-16 14:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-15 14:58 [PATCH] nfs: don't queue synchronous NFSv4 close rpc_release to nfsiod Jeff Layton
2011-02-15 15:31 ` Trond Myklebust
2011-02-15 16:30   ` Jeff Layton
2011-02-15 23:47     ` Trond Myklebust
2011-02-16 14:09       ` Trond Myklebust [this message]
2011-02-16 14:26         ` Trond Myklebust
2011-02-16 14:50           ` Jeff Layton
2011-02-16 15:21             ` Trond Myklebust
2011-02-16 18:13               ` Jeff Layton
2011-02-17 13:40                 ` Jeff Layton
2011-02-17 15:10                   ` Jeff Layton
2011-02-17 19:47                     ` Trond Myklebust
2011-02-17 21:37                       ` Jeff Layton
2011-02-18 20:04                         ` Jeff Layton
2011-02-18 20:54                           ` Trond Myklebust
2011-02-23 20:17                             ` Jeff Layton
2011-02-15 15:53 ` Tigran Mkrtchyan

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=1297865354.6596.13.camel@heimdal.trondhjem.org \
    --to=trond.myklebust@netapp.com \
    --cc=jlayton@redhat.com \
    --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 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).