diff mbox series

[v8,02/20] xfs: Check for -ENOATTR or -EEXIST

Message ID 20200403221229.4995-3-allison.henderson@oracle.com (mailing list archive)
State Superseded
Headers show
Series xfs: Delay Ready Attributes | expand

Commit Message

Allison Henderson April 3, 2020, 10:12 p.m. UTC
Delayed operations cannot return error codes.  So we must check for
these conditions first before starting set or remove operations

Signed-off-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/libxfs/xfs_attr.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Brian Foster April 6, 2020, 2:31 p.m. UTC | #1
On Fri, Apr 03, 2020 at 03:12:11PM -0700, Allison Collins wrote:
> Delayed operations cannot return error codes.  So we must check for
> these conditions first before starting set or remove operations
> 
> Signed-off-by: Allison Collins <allison.henderson@oracle.com>
> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  fs/xfs/libxfs/xfs_attr.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
> index 2a0d3d3..f7e289e 100644
> --- a/fs/xfs/libxfs/xfs_attr.c
> +++ b/fs/xfs/libxfs/xfs_attr.c
> @@ -404,6 +404,17 @@ xfs_attr_set(
>  				args->total, 0, quota_flags);
>  		if (error)
>  			goto out_trans_cancel;
> +
> +		error = xfs_has_attr(args);
> +		if (error == -EEXIST && (args->attr_flags & XATTR_CREATE))
> +			goto out_trans_cancel;
> +
> +		if (error == -ENOATTR && (args->attr_flags & XATTR_REPLACE))
> +			goto out_trans_cancel;
> +
> +		if (error != -ENOATTR && error != -EEXIST)
> +			goto out_trans_cancel;

I'd kill off the whitespace between the above error checks. Otherwise
looks good to me:

Reviewed-by: Brian Foster <bfoster@redhat.com>

> +
>  		error = xfs_attr_set_args(args);
>  		if (error)
>  			goto out_trans_cancel;
> @@ -411,6 +422,10 @@ xfs_attr_set(
>  		if (!args->trans)
>  			goto out_unlock;
>  	} else {
> +		error = xfs_has_attr(args);
> +		if (error != -EEXIST)
> +			goto out_trans_cancel;
> +
>  		error = xfs_attr_remove_args(args);
>  		if (error)
>  			goto out_trans_cancel;
> -- 
> 2.7.4
>
Allison Henderson April 6, 2020, 11:14 p.m. UTC | #2
On 4/6/20 7:31 AM, Brian Foster wrote:
> On Fri, Apr 03, 2020 at 03:12:11PM -0700, Allison Collins wrote:
>> Delayed operations cannot return error codes.  So we must check for
>> these conditions first before starting set or remove operations
>>
>> Signed-off-by: Allison Collins <allison.henderson@oracle.com>
>> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
>> ---
>>   fs/xfs/libxfs/xfs_attr.c | 15 +++++++++++++++
>>   1 file changed, 15 insertions(+)
>>
>> diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
>> index 2a0d3d3..f7e289e 100644
>> --- a/fs/xfs/libxfs/xfs_attr.c
>> +++ b/fs/xfs/libxfs/xfs_attr.c
>> @@ -404,6 +404,17 @@ xfs_attr_set(
>>   				args->total, 0, quota_flags);
>>   		if (error)
>>   			goto out_trans_cancel;
>> +
>> +		error = xfs_has_attr(args);
>> +		if (error == -EEXIST && (args->attr_flags & XATTR_CREATE))
>> +			goto out_trans_cancel;
>> +
>> +		if (error == -ENOATTR && (args->attr_flags & XATTR_REPLACE))
>> +			goto out_trans_cancel;
>> +
>> +		if (error != -ENOATTR && error != -EEXIST)
>> +			goto out_trans_cancel;
> 
> I'd kill off the whitespace between the above error checks. Otherwise
> looks good to me:
> 
> Reviewed-by: Brian Foster <bfoster@redhat.com>
Alrighty, will do.  Thanks!

Allison
> 
>> +
>>   		error = xfs_attr_set_args(args);
>>   		if (error)
>>   			goto out_trans_cancel;
>> @@ -411,6 +422,10 @@ xfs_attr_set(
>>   		if (!args->trans)
>>   			goto out_unlock;
>>   	} else {
>> +		error = xfs_has_attr(args);
>> +		if (error != -EEXIST)
>> +			goto out_trans_cancel;
>> +
>>   		error = xfs_attr_remove_args(args);
>>   		if (error)
>>   			goto out_trans_cancel;
>> -- 
>> 2.7.4
>>
>
Chandan Rajendra April 15, 2020, 6:43 a.m. UTC | #3
On Saturday, April 4, 2020 3:42 AM Allison Collins wrote: 
> Delayed operations cannot return error codes.  So we must check for
> these conditions first before starting set or remove operations
>

The changes are logically correct.

Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>

> Signed-off-by: Allison Collins <allison.henderson@oracle.com>
> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  fs/xfs/libxfs/xfs_attr.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
> index 2a0d3d3..f7e289e 100644
> --- a/fs/xfs/libxfs/xfs_attr.c
> +++ b/fs/xfs/libxfs/xfs_attr.c
> @@ -404,6 +404,17 @@ xfs_attr_set(
>  				args->total, 0, quota_flags);
>  		if (error)
>  			goto out_trans_cancel;
> +
> +		error = xfs_has_attr(args);
> +		if (error == -EEXIST && (args->attr_flags & XATTR_CREATE))
> +			goto out_trans_cancel;
> +
> +		if (error == -ENOATTR && (args->attr_flags & XATTR_REPLACE))
> +			goto out_trans_cancel;
> +
> +		if (error != -ENOATTR && error != -EEXIST)
> +			goto out_trans_cancel;
> +
>  		error = xfs_attr_set_args(args);
>  		if (error)
>  			goto out_trans_cancel;
> @@ -411,6 +422,10 @@ xfs_attr_set(
>  		if (!args->trans)
>  			goto out_unlock;
>  	} else {
> +		error = xfs_has_attr(args);
> +		if (error != -EEXIST)
> +			goto out_trans_cancel;
> +
>  		error = xfs_attr_remove_args(args);
>  		if (error)
>  			goto out_trans_cancel;
>
diff mbox series

Patch

diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
index 2a0d3d3..f7e289e 100644
--- a/fs/xfs/libxfs/xfs_attr.c
+++ b/fs/xfs/libxfs/xfs_attr.c
@@ -404,6 +404,17 @@  xfs_attr_set(
 				args->total, 0, quota_flags);
 		if (error)
 			goto out_trans_cancel;
+
+		error = xfs_has_attr(args);
+		if (error == -EEXIST && (args->attr_flags & XATTR_CREATE))
+			goto out_trans_cancel;
+
+		if (error == -ENOATTR && (args->attr_flags & XATTR_REPLACE))
+			goto out_trans_cancel;
+
+		if (error != -ENOATTR && error != -EEXIST)
+			goto out_trans_cancel;
+
 		error = xfs_attr_set_args(args);
 		if (error)
 			goto out_trans_cancel;
@@ -411,6 +422,10 @@  xfs_attr_set(
 		if (!args->trans)
 			goto out_unlock;
 	} else {
+		error = xfs_has_attr(args);
+		if (error != -EEXIST)
+			goto out_trans_cancel;
+
 		error = xfs_attr_remove_args(args);
 		if (error)
 			goto out_trans_cancel;