All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] fat: Fix d_splice_alias() return code checking
@ 2014-10-19 10:39 Richard Weinberger
  2014-10-19 10:39   ` [Ocfs2-devel] " Richard Weinberger
  2014-10-20 12:34 ` [PATCH 1/2] fat: " Al Viro
  0 siblings, 2 replies; 9+ messages in thread
From: Richard Weinberger @ 2014-10-19 10:39 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel, Richard Weinberger, OGAWA Hirofumi

d_splice_alias() can return a valid dentry, NULL or an ERR_PTR.
Currently the code checks not for ERR_PTR.
Fix this by using IS_ERR_OR_NULL().

Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: Richard Weinberger <richard@nod.at>
---
 fs/fat/namei_vfat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
index 6df8d3d..8f93464 100644
--- a/fs/fat/namei_vfat.c
+++ b/fs/fat/namei_vfat.c
@@ -757,7 +757,7 @@ out:
 	mutex_unlock(&MSDOS_SB(sb)->s_lock);
 	dentry->d_time = dentry->d_parent->d_inode->i_version;
 	dentry = d_splice_alias(inode, dentry);
-	if (dentry)
+	if (!IS_ERR_OR_NULL(dentry))
 		dentry->d_time = dentry->d_parent->d_inode->i_version;
 	return dentry;
 
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/2] ocfs2: Fix d_splice_alias() return code checking
  2014-10-19 10:39 [PATCH 1/2] fat: Fix d_splice_alias() return code checking Richard Weinberger
@ 2014-10-19 10:39   ` Richard Weinberger
  2014-10-20 12:34 ` [PATCH 1/2] fat: " Al Viro
  1 sibling, 0 replies; 9+ messages in thread
From: Richard Weinberger @ 2014-10-19 10:39 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: linux-kernel, Richard Weinberger, Mark Fasheh, Joel Becker, ocfs2-devel

d_splice_alias() can return a valid dentry, NULL or an ERR_PTR.
Currently the code checks not for ERR_PTR and my oops in
ocfs2_dentry_attach_lock().
Fix this by using IS_ERR_OR_NULL().

Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: ocfs2-devel@oss.oracle.com
Signed-off-by: Richard Weinberger <richard@nod.at>
---
 fs/ocfs2/namei.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 8add6f1..b931e04 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -158,7 +158,7 @@ bail_add:
 		 * NOTE: This dentry already has ->d_op set from
 		 * ocfs2_get_parent() and ocfs2_get_dentry()
 		 */
-		if (ret)
+		if (!IS_ERR_OR_NULL(ret))
 			dentry = ret;
 
 		status = ocfs2_dentry_attach_lock(dentry, inode,
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Ocfs2-devel] [PATCH 2/2] ocfs2: Fix d_splice_alias() return code checking
@ 2014-10-19 10:39   ` Richard Weinberger
  0 siblings, 0 replies; 9+ messages in thread
From: Richard Weinberger @ 2014-10-19 10:39 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: linux-kernel, Richard Weinberger, Mark Fasheh, Joel Becker, ocfs2-devel

d_splice_alias() can return a valid dentry, NULL or an ERR_PTR.
Currently the code checks not for ERR_PTR and my oops in
ocfs2_dentry_attach_lock().
Fix this by using IS_ERR_OR_NULL().

Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: ocfs2-devel at oss.oracle.com
Signed-off-by: Richard Weinberger <richard@nod.at>
---
 fs/ocfs2/namei.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 8add6f1..b931e04 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -158,7 +158,7 @@ bail_add:
 		 * NOTE: This dentry already has ->d_op set from
 		 * ocfs2_get_parent() and ocfs2_get_dentry()
 		 */
-		if (ret)
+		if (!IS_ERR_OR_NULL(ret))
 			dentry = ret;
 
 		status = ocfs2_dentry_attach_lock(dentry, inode,
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] fat: Fix d_splice_alias() return code checking
  2014-10-19 10:39 [PATCH 1/2] fat: Fix d_splice_alias() return code checking Richard Weinberger
  2014-10-19 10:39   ` [Ocfs2-devel] " Richard Weinberger
@ 2014-10-20 12:34 ` Al Viro
  2014-10-23 15:21   ` OGAWA Hirofumi
  1 sibling, 1 reply; 9+ messages in thread
From: Al Viro @ 2014-10-20 12:34 UTC (permalink / raw)
  To: Richard Weinberger; +Cc: linux-fsdevel, linux-kernel, OGAWA Hirofumi

On Sun, Oct 19, 2014 at 12:39:43PM +0200, Richard Weinberger wrote:
> d_splice_alias() can return a valid dentry, NULL or an ERR_PTR.
> Currently the code checks not for ERR_PTR.
> Fix this by using IS_ERR_OR_NULL().

Why do we need to set ->d_time for non-NULL inode anyway?  AFAICS,
it's never checked for positive dentries, and the moment when positive
dentry become negative is when we want to set it anyway.

What am I missing here?  Why not simply do this:

diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
index 6df8d3d..e2dc6bf 100644
--- a/fs/fat/namei_vfat.c
+++ b/fs/fat/namei_vfat.c
@@ -725,15 +725,14 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
 			inode = NULL;
 			goto out;
 		}
-		goto error;
+		inode = ERR_PTR(inode);
+		goto out;
 	}
 
 	inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos);
 	brelse(sinfo.bh);
-	if (IS_ERR(inode)) {
-		err = PTR_ERR(inode);
-		goto error;
-	}
+	if (IS_ERR(inode))
+		goto out;
 
 	alias = d_find_alias(inode);
 	if (alias && !vfat_d_anon_disconn(alias)) {
@@ -754,16 +753,10 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
 		dput(alias);
 
 out:
+	if (!inode)
+		dentry->d_time = dir->i_version;
 	mutex_unlock(&MSDOS_SB(sb)->s_lock);
-	dentry->d_time = dentry->d_parent->d_inode->i_version;
-	dentry = d_splice_alias(inode, dentry);
-	if (dentry)
-		dentry->d_time = dentry->d_parent->d_inode->i_version;
-	return dentry;
-
-error:
-	mutex_unlock(&MSDOS_SB(sb)->s_lock);
-	return ERR_PTR(err);
+	return d_splice_alias(inode, dentry);
 }
 
 static int vfat_create(struct inode *dir, struct dentry *dentry, umode_t mode,
@@ -793,7 +786,6 @@ static int vfat_create(struct inode *dir, struct dentry *dentry, umode_t mode,
 	inode->i_mtime = inode->i_atime = inode->i_ctime = ts;
 	/* timestamp is already written, so mark_inode_dirty() is unneeded. */
 
-	dentry->d_time = dentry->d_parent->d_inode->i_version;
 	d_instantiate(dentry, inode);
 out:
 	mutex_unlock(&MSDOS_SB(sb)->s_lock);
@@ -824,6 +816,7 @@ static int vfat_rmdir(struct inode *dir, struct dentry *dentry)
 	clear_nlink(inode);
 	inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC;
 	fat_detach(inode);
+	dentry->d_time = dir->i_version;
 out:
 	mutex_unlock(&MSDOS_SB(sb)->s_lock);
 
@@ -849,6 +842,7 @@ static int vfat_unlink(struct inode *dir, struct dentry *dentry)
 	clear_nlink(inode);
 	inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC;
 	fat_detach(inode);
+	dentry->d_time = dir->i_version;
 out:
 	mutex_unlock(&MSDOS_SB(sb)->s_lock);
 
@@ -889,7 +883,6 @@ static int vfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 	inode->i_mtime = inode->i_atime = inode->i_ctime = ts;
 	/* timestamp is already written, so mark_inode_dirty() is unneeded. */
 
-	dentry->d_time = dentry->d_parent->d_inode->i_version;
 	d_instantiate(dentry, inode);
 
 	mutex_unlock(&MSDOS_SB(sb)->s_lock);

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [Ocfs2-devel] [PATCH 2/2] ocfs2: Fix d_splice_alias() return code checking
  2014-10-19 10:39   ` [Ocfs2-devel] " Richard Weinberger
@ 2014-10-20 23:12     ` Andrew Morton
  -1 siblings, 0 replies; 9+ messages in thread
From: Andrew Morton @ 2014-10-20 23:12 UTC (permalink / raw)
  To: Richard Weinberger; +Cc: linux-fsdevel, ocfs2-devel, linux-kernel, Mark Fasheh

On Sun, 19 Oct 2014 12:39:44 +0200 Richard Weinberger <richard@nod.at> wrote:

> d_splice_alias() can return a valid dentry, NULL or an ERR_PTR.
> Currently the code checks not for ERR_PTR and my oops in
> ocfs2_dentry_attach_lock().

It's unclear what the second sentence is trying to tell us.  The patch
fixes an oops?  If so, a copy of the trace would be useful, as would an
explanation of why it occurred.  If not, I'm all confused.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Ocfs2-devel] [PATCH 2/2] ocfs2: Fix d_splice_alias() return code checking
@ 2014-10-20 23:12     ` Andrew Morton
  0 siblings, 0 replies; 9+ messages in thread
From: Andrew Morton @ 2014-10-20 23:12 UTC (permalink / raw)
  To: Richard Weinberger; +Cc: linux-fsdevel, ocfs2-devel, linux-kernel, Mark Fasheh

On Sun, 19 Oct 2014 12:39:44 +0200 Richard Weinberger <richard@nod.at> wrote:

> d_splice_alias() can return a valid dentry, NULL or an ERR_PTR.
> Currently the code checks not for ERR_PTR and my oops in
> ocfs2_dentry_attach_lock().

It's unclear what the second sentence is trying to tell us.  The patch
fixes an oops?  If so, a copy of the trace would be useful, as would an
explanation of why it occurred.  If not, I'm all confused.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Ocfs2-devel] [PATCH 2/2] ocfs2: Fix d_splice_alias() return code checking
  2014-10-20 23:12     ` Andrew Morton
@ 2014-10-22 20:33       ` Richard Weinberger
  -1 siblings, 0 replies; 9+ messages in thread
From: Richard Weinberger @ 2014-10-22 20:33 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-fsdevel, ocfs2-devel, linux-kernel, Mark Fasheh

Am 21.10.2014 um 01:12 schrieb Andrew Morton:
> On Sun, 19 Oct 2014 12:39:44 +0200 Richard Weinberger <richard@nod.at> wrote:
> 
>> d_splice_alias() can return a valid dentry, NULL or an ERR_PTR.
>> Currently the code checks not for ERR_PTR and my oops in
>> ocfs2_dentry_attach_lock().
> 
> It's unclear what the second sentence is trying to tell us.  The patch
> fixes an oops?  If so, a copy of the trace would be useful, as would an
> explanation of why it occurred.  If not, I'm all confused.

ocfs2_dentry_attach_lock() derefs the dentry pointer.
If d_splice_alias() returns ERR_PTR(-EIO) it will oops.

Thanks,
//richard

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Ocfs2-devel] [PATCH 2/2] ocfs2: Fix d_splice_alias() return code checking
@ 2014-10-22 20:33       ` Richard Weinberger
  0 siblings, 0 replies; 9+ messages in thread
From: Richard Weinberger @ 2014-10-22 20:33 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-fsdevel, ocfs2-devel, linux-kernel, Mark Fasheh

Am 21.10.2014 um 01:12 schrieb Andrew Morton:
> On Sun, 19 Oct 2014 12:39:44 +0200 Richard Weinberger <richard@nod.at> wrote:
> 
>> d_splice_alias() can return a valid dentry, NULL or an ERR_PTR.
>> Currently the code checks not for ERR_PTR and my oops in
>> ocfs2_dentry_attach_lock().
> 
> It's unclear what the second sentence is trying to tell us.  The patch
> fixes an oops?  If so, a copy of the trace would be useful, as would an
> explanation of why it occurred.  If not, I'm all confused.

ocfs2_dentry_attach_lock() derefs the dentry pointer.
If d_splice_alias() returns ERR_PTR(-EIO) it will oops.

Thanks,
//richard

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] fat: Fix d_splice_alias() return code checking
  2014-10-20 12:34 ` [PATCH 1/2] fat: " Al Viro
@ 2014-10-23 15:21   ` OGAWA Hirofumi
  0 siblings, 0 replies; 9+ messages in thread
From: OGAWA Hirofumi @ 2014-10-23 15:21 UTC (permalink / raw)
  To: Al Viro; +Cc: Richard Weinberger, linux-fsdevel, linux-kernel

Al Viro <viro@ZenIV.linux.org.uk> writes:

> On Sun, Oct 19, 2014 at 12:39:43PM +0200, Richard Weinberger wrote:
>> d_splice_alias() can return a valid dentry, NULL or an ERR_PTR.
>> Currently the code checks not for ERR_PTR.
>> Fix this by using IS_ERR_OR_NULL().
>
> Why do we need to set ->d_time for non-NULL inode anyway?  AFAICS,
> it's never checked for positive dentries, and the moment when positive
> dentry become negative is when we want to set it anyway.
>
> What am I missing here?  Why not simply do this:

Hm, at least, this changes behavior though (old one drops if parent
changed after target dentry created, then when become negative. New one
drops if changed parent after target became negative.).

However, looks like new behavior is workable. And I think it is worth to try.

Can you add Signed-off-by:?

> diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
> index 6df8d3d..e2dc6bf 100644
> --- a/fs/fat/namei_vfat.c
> +++ b/fs/fat/namei_vfat.c
> @@ -725,15 +725,14 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
>  			inode = NULL;
>  			goto out;
>  		}
> -		goto error;
> +		inode = ERR_PTR(inode);
> +		goto out;
>  	}
>  
>  	inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos);
>  	brelse(sinfo.bh);
> -	if (IS_ERR(inode)) {
> -		err = PTR_ERR(inode);
> -		goto error;
> -	}
> +	if (IS_ERR(inode))
> +		goto out;
>  
>  	alias = d_find_alias(inode);
>  	if (alias && !vfat_d_anon_disconn(alias)) {
> @@ -754,16 +753,10 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
>  		dput(alias);
>  
>  out:
> +	if (!inode)
> +		dentry->d_time = dir->i_version;
>  	mutex_unlock(&MSDOS_SB(sb)->s_lock);
> -	dentry->d_time = dentry->d_parent->d_inode->i_version;
> -	dentry = d_splice_alias(inode, dentry);
> -	if (dentry)
> -		dentry->d_time = dentry->d_parent->d_inode->i_version;
> -	return dentry;
> -
> -error:
> -	mutex_unlock(&MSDOS_SB(sb)->s_lock);
> -	return ERR_PTR(err);
> +	return d_splice_alias(inode, dentry);
>  }
>  
>  static int vfat_create(struct inode *dir, struct dentry *dentry, umode_t mode,
> @@ -793,7 +786,6 @@ static int vfat_create(struct inode *dir, struct dentry *dentry, umode_t mode,
>  	inode->i_mtime = inode->i_atime = inode->i_ctime = ts;
>  	/* timestamp is already written, so mark_inode_dirty() is unneeded. */
>  
> -	dentry->d_time = dentry->d_parent->d_inode->i_version;
>  	d_instantiate(dentry, inode);
>  out:
>  	mutex_unlock(&MSDOS_SB(sb)->s_lock);
> @@ -824,6 +816,7 @@ static int vfat_rmdir(struct inode *dir, struct dentry *dentry)
>  	clear_nlink(inode);
>  	inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC;
>  	fat_detach(inode);
> +	dentry->d_time = dir->i_version;
>  out:
>  	mutex_unlock(&MSDOS_SB(sb)->s_lock);
>  
> @@ -849,6 +842,7 @@ static int vfat_unlink(struct inode *dir, struct dentry *dentry)
>  	clear_nlink(inode);
>  	inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC;
>  	fat_detach(inode);
> +	dentry->d_time = dir->i_version;
>  out:
>  	mutex_unlock(&MSDOS_SB(sb)->s_lock);
>  
> @@ -889,7 +883,6 @@ static int vfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
>  	inode->i_mtime = inode->i_atime = inode->i_ctime = ts;
>  	/* timestamp is already written, so mark_inode_dirty() is unneeded. */
>  
> -	dentry->d_time = dentry->d_parent->d_inode->i_version;
>  	d_instantiate(dentry, inode);
>  
>  	mutex_unlock(&MSDOS_SB(sb)->s_lock);

-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-10-23 15:21 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-19 10:39 [PATCH 1/2] fat: Fix d_splice_alias() return code checking Richard Weinberger
2014-10-19 10:39 ` [PATCH 2/2] ocfs2: " Richard Weinberger
2014-10-19 10:39   ` [Ocfs2-devel] " Richard Weinberger
2014-10-20 23:12   ` Andrew Morton
2014-10-20 23:12     ` Andrew Morton
2014-10-22 20:33     ` Richard Weinberger
2014-10-22 20:33       ` Richard Weinberger
2014-10-20 12:34 ` [PATCH 1/2] fat: " Al Viro
2014-10-23 15:21   ` OGAWA Hirofumi

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.