public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: Fix error path in xfs_get_acl
@ 2015-10-11 13:23 Andreas Gruenbacher
  2015-10-12  0:45 ` Dave Chinner
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Gruenbacher @ 2015-10-11 13:23 UTC (permalink / raw)
  To: Dave Chinner, xfs

Error codes from xfs_attr_get other than -ENOATTR were not properly 
reported.  Fix that, and clean the code up somewhat.

In addition, the declaration of struct xfs_inode in xfs_acl.h isn't needed.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
 fs/xfs/xfs_acl.c | 19 +++++++------------
 fs/xfs/xfs_acl.h |  1 -
 2 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c
index 4b64167..0f4ee92 100644
--- a/fs/xfs/xfs_acl.c
+++ b/fs/xfs/xfs_acl.c
@@ -122,7 +122,7 @@ struct posix_acl *
 xfs_get_acl(struct inode *inode, int type)
 {
 	struct xfs_inode *ip = XFS_I(inode);
-	struct posix_acl *acl = NULL;
+	struct posix_acl *acl;
 	struct xfs_acl *xfs_acl;
 	unsigned char *ea_name;
 	int error;
@@ -158,18 +158,13 @@ xfs_get_acl(struct inode *inode, int type)
 		 * cache entry, for any other error assume it is transient and
 		 * leave the cache entry as ACL_NOT_CACHED.
 		 */
-		if (error == -ENOATTR)
-			goto out_update_cache;
-		goto out;
-	}
+		acl = (error == -ENOATTR) ? NULL : ERR_PTR(error);
+	} else
+		acl = xfs_acl_from_disk(xfs_acl,
+					XFS_ACL_MAX_ENTRIES(ip->i_mount));
 
-	acl = xfs_acl_from_disk(xfs_acl, XFS_ACL_MAX_ENTRIES(ip->i_mount));
-	if (IS_ERR(acl))
-		goto out;
-
-out_update_cache:
-	set_cached_acl(inode, type, acl);
-out:
+	if (!IS_ERR(acl))
+		set_cached_acl(inode, type, acl);
 	kmem_free(xfs_acl);
 	return acl;
 }
diff --git a/fs/xfs/xfs_acl.h b/fs/xfs/xfs_acl.h
index 3841b07..9ee0a0d 100644
--- a/fs/xfs/xfs_acl.h
+++ b/fs/xfs/xfs_acl.h
@@ -20,7 +20,6 @@
 
 struct inode;
 struct posix_acl;
-struct xfs_inode;
 
 #ifdef CONFIG_XFS_POSIX_ACL
 extern struct posix_acl *xfs_get_acl(struct inode *inode, int type);
-- 
2.5.0

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH] xfs: Fix error path in xfs_get_acl
  2015-10-11 13:23 [PATCH] xfs: Fix error path in xfs_get_acl Andreas Gruenbacher
@ 2015-10-12  0:45 ` Dave Chinner
  2015-10-12  3:05   ` Andreas Gruenbacher
  0 siblings, 1 reply; 4+ messages in thread
From: Dave Chinner @ 2015-10-12  0:45 UTC (permalink / raw)
  To: Andreas Gruenbacher; +Cc: xfs

On Sun, Oct 11, 2015 at 03:23:11PM +0200, Andreas Gruenbacher wrote:
> Error codes from xfs_attr_get other than -ENOATTR were not properly 
> reported.  Fix that, and clean the code up somewhat.

Test case for xfstests?

> In addition, the declaration of struct xfs_inode in xfs_acl.h isn't needed.
> 
> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
> ---
>  fs/xfs/xfs_acl.c | 19 +++++++------------
>  fs/xfs/xfs_acl.h |  1 -
>  2 files changed, 7 insertions(+), 13 deletions(-)
> 
> diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c
> index 4b64167..0f4ee92 100644
> --- a/fs/xfs/xfs_acl.c
> +++ b/fs/xfs/xfs_acl.c
> @@ -122,7 +122,7 @@ struct posix_acl *
>  xfs_get_acl(struct inode *inode, int type)
>  {
>  	struct xfs_inode *ip = XFS_I(inode);
> -	struct posix_acl *acl = NULL;
> +	struct posix_acl *acl;
>  	struct xfs_acl *xfs_acl;
>  	unsigned char *ea_name;
>  	int error;
> @@ -158,18 +158,13 @@ xfs_get_acl(struct inode *inode, int type)
>  		 * cache entry, for any other error assume it is transient and
>  		 * leave the cache entry as ACL_NOT_CACHED.
>  		 */
> -		if (error == -ENOATTR)
> -			goto out_update_cache;
> -		goto out;
> -	}
> +		acl = (error == -ENOATTR) ? NULL : ERR_PTR(error);

AFAICT, this single line here is the bugfix, right?

So the entire patch could simply be replaced by:

 		if (error == -ENOATTR)
 			goto out_update_cache;
+		acl = ERR_PTR(error);
 		goto out;
 	}

Or have I missed the missed the fix in all the code rearranging you
did?

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH] xfs: Fix error path in xfs_get_acl
  2015-10-12  0:45 ` Dave Chinner
@ 2015-10-12  3:05   ` Andreas Gruenbacher
  0 siblings, 0 replies; 4+ messages in thread
From: Andreas Gruenbacher @ 2015-10-12  3:05 UTC (permalink / raw)
  To: Dave Chinner; +Cc: xfs

On Mon, Oct 12, 2015 at 2:45 AM, Dave Chinner <david@fromorbit.com> wrote:
> Test case for xfstests?

I don't see an easy way to trigger this bug.

> So the entire patch could simply be replaced by:
>
>                 if (error == -ENOATTR)
>                         goto out_update_cache;
> +               acl = ERR_PTR(error);
>                 goto out;
>         }

If you prefer, yes.

Thanks,
Andreas

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH] xfs: Fix error path in xfs_get_acl
@ 2015-11-03 13:47 Andreas Gruenbacher
  0 siblings, 0 replies; 4+ messages in thread
From: Andreas Gruenbacher @ 2015-11-03 13:47 UTC (permalink / raw)
  To: Dave Chinner, xfs; +Cc: Andreas Gruenbacher

Here is another bugfix patch, previously discussed here:

  http://oss.sgi.com/archives/xfs/2015-10/msg00295.html

Thanks,
Andreas


Error codes from xfs_attr_get other than -ENOATTR were not properly
reported.  Fix that.

In addition, the declaration of struct xfs_inode in xfs_acl.h isn't needed.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
 fs/xfs/xfs_acl.c | 1 +
 fs/xfs/xfs_acl.h | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c
index 763e365..6bb470f 100644
--- a/fs/xfs/xfs_acl.c
+++ b/fs/xfs/xfs_acl.c
@@ -163,6 +163,7 @@ xfs_get_acl(struct inode *inode, int type)
 		 */
 		if (error == -ENOATTR)
 			goto out_update_cache;
+		acl = ERR_PTR(error);
 		goto out;
 	}
 
diff --git a/fs/xfs/xfs_acl.h b/fs/xfs/xfs_acl.h
index 75af0a4..52f8255 100644
--- a/fs/xfs/xfs_acl.h
+++ b/fs/xfs/xfs_acl.h
@@ -20,7 +20,6 @@
 
 struct inode;
 struct posix_acl;
-struct xfs_inode;
 
 #ifdef CONFIG_XFS_POSIX_ACL
 extern struct posix_acl *xfs_get_acl(struct inode *inode, int type);
-- 
2.5.0

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

end of thread, other threads:[~2015-11-03 13:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-11 13:23 [PATCH] xfs: Fix error path in xfs_get_acl Andreas Gruenbacher
2015-10-12  0:45 ` Dave Chinner
2015-10-12  3:05   ` Andreas Gruenbacher
  -- strict thread matches above, loose matches on Subject: below --
2015-11-03 13:47 Andreas Gruenbacher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox