public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Michael Ellerman <michael@ellerman•id.au>
To: arnd@arndb•de
Cc: linuxppc-dev@ozlabs•org, paulus@samba•org,
	cbe-oss-dev@ozlabs•org, linux-kernel@vger•kernel.org
Subject: Re: [patch 07/20] spufs: fix deadlock in spu_create error path
Date: Tue, 20 Jun 2006 11:16:52 +1000	[thread overview]
Message-ID: <1150766213.7054.6.camel@localhost.localdomain> (raw)
In-Reply-To: <20060619183404.966781000@klappe.arndb.de>

[-- Attachment #1: Type: text/plain, Size: 2487 bytes --]

On Mon, 2006-06-19 at 20:33 +0200, arnd@arndb•de wrote:
> plain text document attachment (spufs-rmdir-3.diff)
> From: Michael Ellerman <michael@ellerman•id.au>
> 
> spufs_rmdir tries to acquire the spufs root
> i_mutex, which is already held by spufs_create_thread.
> 
> This was tracked as Bug #H9512.
> 
> Signed-off-by: Arnd Bergmann <arnd.bergmann@de•ibm.com>

I should have signed this off when I sent it .. but FWIW:

Signed-off-by: Michael Ellerman <michael@ellerman•id.au>

> ---
> 
> Index: powerpc.git/arch/powerpc/platforms/cell/spufs/inode.c
> ===================================================================
> --- powerpc.git.orig/arch/powerpc/platforms/cell/spufs/inode.c
> +++ powerpc.git/arch/powerpc/platforms/cell/spufs/inode.c
> @@ -157,20 +157,12 @@ static void spufs_prune_dir(struct dentr
>  	mutex_unlock(&dir->d_inode->i_mutex);
>  }
>  
> +/* Caller must hold root->i_mutex */
>  static int spufs_rmdir(struct inode *root, struct dentry *dir_dentry)
>  {
> -	struct spu_context *ctx;
> -
>  	/* remove all entries */
> -	mutex_lock(&root->i_mutex);
>  	spufs_prune_dir(dir_dentry);
> -	mutex_unlock(&root->i_mutex);
>  
> -	/* We have to give up the mm_struct */
> -	ctx = SPUFS_I(dir_dentry->d_inode)->i_ctx;
> -	spu_forget(ctx);
> -
> -	/* XXX Do we need to hold i_mutex here ? */
>  	return simple_rmdir(root, dir_dentry);
>  }
>  
> @@ -199,16 +191,23 @@ out:
>  
>  static int spufs_dir_close(struct inode *inode, struct file *file)
>  {
> +	struct spu_context *ctx;
>  	struct inode *dir;
>  	struct dentry *dentry;
>  	int ret;
>  
>  	dentry = file->f_dentry;
>  	dir = dentry->d_parent->d_inode;
> +	ctx = SPUFS_I(dentry->d_inode)->i_ctx;
>  
> +	mutex_lock(&dir->i_mutex);
>  	ret = spufs_rmdir(dir, dentry);
> +	mutex_unlock(&dir->i_mutex);
>  	WARN_ON(ret);
>  
> +	/* We have to give up the mm_struct */
> +	spu_forget(ctx);
> +
>  	return dcache_dir_close(inode, file);
>  }
>  
> @@ -324,8 +323,13 @@ long spufs_create_thread(struct nameidat
>  	 * in error path of *_open().
>  	 */
>  	ret = spufs_context_open(dget(dentry), mntget(nd->mnt));
> -	if (ret < 0)
> -		spufs_rmdir(nd->dentry->d_inode, dentry);
> +	if (ret < 0) {
> +		WARN_ON(spufs_rmdir(nd->dentry->d_inode, dentry));
> +		mutex_unlock(&nd->dentry->d_inode->i_mutex);
> +		spu_forget(SPUFS_I(dentry->d_inode)->i_ctx);
> +		dput(dentry);
> +		goto out;
> +	}
>  
>  out_dput:
>  	dput(dentry);


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 191 bytes --]

  reply	other threads:[~2006-06-20  1:16 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-19 18:33 [patch 00/20] cell: patches for 2.6.18 arnd
2006-06-19 18:33 ` [patch 01/20] cell: add RAS support arnd
2006-06-20 15:43   ` [Cbe-oss-dev] " Olof Johansson
2006-06-20 16:26     ` Arnd Bergmann
2006-06-20 17:50       ` Olof Johansson
2006-06-20 19:00         ` Geoff Levand
2006-06-21  1:46     ` Benjamin Herrenschmidt
2006-06-19 18:33 ` [patch 02/20] cell: fix interrupt priority handling arnd
2006-06-19 18:33 ` [patch 03/20] cell: update defconfig arnd
2006-06-19 18:33 ` [patch 04/20] cell: register SPUs as sysdevs arnd
2006-06-19 18:33 ` [patch 05/20] cell: always build spu base into the kernel arnd
2006-06-19 18:33 ` [patch 06/20] spufs: restore mapping of mssync register arnd
2006-06-19 18:33 ` [patch 07/20] spufs: fix deadlock in spu_create error path arnd
2006-06-20  1:16   ` Michael Ellerman [this message]
2006-06-19 18:33 ` [patch 08/20] spufs: set up correct SLB entries for 64k pages arnd
2006-06-19 18:33 ` [patch 09/20] spufs: add a phys-id attribute to each SPU context arnd
2006-06-19 18:33 ` [patch 10/20] spufs: fix initial state of wbox file arnd
2006-06-19 18:33 ` [patch 11/20] spufs: use kzalloc in create_spu arnd
2006-06-19 18:33 ` [patch 12/20] spufs: dont try to access SPE channel 1 count arnd
2006-06-19 18:33 ` [patch 13/20] spufs: split the Cell BE support into generic and platform dependant parts arnd
2006-06-19 18:33 ` [patch 14/20] spufs: further abstract priv1 register access arnd
2006-06-19 18:33 ` [patch 15/20] spufs: fix spu irq affinity setting arnd
2006-06-19 18:33 ` [patch 16/20] spufs: remove stop_code from struct spu arnd
2006-06-19 18:33 ` [patch 17/20] spufs: fix Makefile for "make clean" arnd
2006-06-19 18:33 ` [patch 18/20] spufs: clear class2 interrupt status before wakeup arnd
2006-06-19 18:33 ` [patch 19/20] spufs: fail spu_create with invalid flags arnd
2006-06-19 18:33 ` [patch 20/20] spufs: one more fix for 64k pages arnd

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=1150766213.7054.6.camel@localhost.localdomain \
    --to=michael@ellerman$(echo .)id.au \
    --cc=arnd@arndb$(echo .)de \
    --cc=cbe-oss-dev@ozlabs$(echo .)org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=linuxppc-dev@ozlabs$(echo .)org \
    --cc=paulus@samba$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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