All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vitaliy Gusev <gusev.vitaliy@nexenta.com>
To: tao.peng@emc.com
Cc: Trond.Myklebust@netapp.com, gusev.vitaliy@gmail.com,
	linux-nfs@vger.kernel.org
Subject: Re: [PATCH] nfs: fix inifinite loop at nfs4_layoutcommit_release
Date: Thu, 08 Sep 2011 17:02:12 +0400	[thread overview]
Message-ID: <4E68BCD4.9030202@nexenta.com> (raw)
In-Reply-To: <F19688880B763E40B28B2B462677FBF805C3299C9C@MX09A.corp.emc.com>

On 09/08/2011 02:00 PM, tao.peng@emc.com wrote:
> Hi, Gusev,

Hello Tao!

> Yes, you are right. How about following patch?
>
>  From 14c6da67565fb31c2d2775ccefd93251f348910d Mon Sep 17 00:00:00 2001
> From: Peng Tao<bergwolf@gmail.com>
> Date: Thu, 8 Sep 2011 00:57:02 -0400
> Subject: [PATCH] nfsv4: fix race in layoutcommit lseg list create/free
>
> Since there can be more than one layoutcommit proc happen the same time,
> lseg list create/free should be protected. Otherwise lseg list
> may get corrupted.
>
> Reported-by: Vitaliy Gusev<gusev.vitaliy@nexenta.com>
> Signed-off-by: Peng Tao<peng_tao@emc.com>
> ---
>   fs/nfs/nfs4proc.c |    2 ++
>   1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
> index 8c77039..da7c20c 100644
> --- a/fs/nfs/nfs4proc.c
> +++ b/fs/nfs/nfs4proc.c
> @@ -5964,6 +5964,7 @@ static void nfs4_layoutcommit_release(void *calldata)
>   	struct pnfs_layout_segment *lseg, *tmp;
>
>   	pnfs_cleanup_layoutcommit(data);
> +	spin_lock(&data->args.inode->i_lock);

I think lock over list_del_init(&lseg->pls_lc_list) is enough, because

1. here lseg is deleted from unique (placed in stack) data and there is 
no any race during deletion.


2. Only one thing must be protected - list_empty status at 
pnfs_list_write_lseg (after my patch).

    The problem is that list_del_init is placed before 
test_and_clear_bit and spinlock can be some kind of barrier for 
protection against adding lseg to new data->lseg_list at
pnfs_list_write_lseg.

    Do reordering list_del_init with test_and_clear_bit is not good, 
because lseg can be invalid after put_lseg.


>   	/* Matched by references in pnfs_set_layoutcommit */
>   	list_for_each_entry_safe(lseg, tmp,&data->lseg_list, pls_lc_list) {
>   		list_del_init(&lseg->pls_lc_list);
> @@ -5971,6 +5972,7 @@ static void nfs4_layoutcommit_release(void *calldata)
>   				&lseg->pls_flags))
>   			put_lseg(lseg);
>   	}
> +	spin_unlock(&data->args.inode->i_lock);
>   	put_rpccred(data->cred);
>   	kfree(data);
>   }


  reply	other threads:[~2011-09-08 13:13 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-28  6:22 [PATCH] nfs: fix inifinite loop at nfs4_layoutcommit_release Vitaliy Gusev
2011-09-06 19:29 ` Trond Myklebust
2011-09-06 22:13   ` Vitaliy Gusev
2011-09-06 22:32     ` Trond Myklebust
2011-09-08 10:21       ` tao.peng
2011-09-08 12:01         ` Myklebust, Trond
2011-09-08 15:00           ` Peng Tao
2011-09-08 17:05             ` Myklebust, Trond
2011-09-09  3:11               ` tao.peng
2011-09-09 18:20                 ` Trond Myklebust
2011-09-10  7:14                   ` Benny Halevy
2011-09-12 14:56                     ` Peng Tao
2011-09-12 20:31                       ` Benny Halevy
2011-09-12 21:10                         ` Trond Myklebust
2011-09-13  7:50                           ` Benny Halevy
2011-09-13  8:32                             ` tao.peng
2011-09-14  6:43                               ` Benny Halevy
2011-09-14  7:53                                 ` tao.peng
     [not found]                                   ` <F19688880B763E40B28B2B462677FBF805C3F7A911-AYrsSIZi/B2B3McK65YKY9BPR1lH4CV8@public.gmane.org>
2011-09-14 13:20                                     ` Benny Halevy
2011-09-13  8:09                           ` tao.peng
2011-09-14  6:46                             ` Benny Halevy
2011-09-13  7:02                         ` tao.peng
2011-09-13  7:54                           ` Benny Halevy
2011-09-12 14:48                   ` Peng Tao
2011-09-08 10:00     ` tao.peng
2011-09-08 13:02       ` Vitaliy Gusev [this message]
2011-09-08 15:09         ` Peng Tao
2011-09-09 17:46           ` Vitaliy Gusev
2011-09-12 14:42             ` Peng Tao

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=4E68BCD4.9030202@nexenta.com \
    --to=gusev.vitaliy@nexenta.com \
    --cc=Trond.Myklebust@netapp.com \
    --cc=gusev.vitaliy@gmail.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=tao.peng@emc.com \
    /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.