public inbox for linux-bcachefs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bcachefs: avoid returning private error code in bch2_xattr_bcachefs_set
@ 2024-03-01  3:17 Hongbo Li
  2024-03-01  3:26 ` Jinjie Ruan
  0 siblings, 1 reply; 6+ messages in thread
From: Hongbo Li @ 2024-03-01  3:17 UTC (permalink / raw)
  To: kent.overstreet, bfoster; +Cc: linux-bcachefs, ruanjinjie, lihongbo22

Avoid the private error code return to caller. The error code
should be transformed into genernal error code.

Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
 fs/bcachefs/xattr.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/bcachefs/xattr.c b/fs/bcachefs/xattr.c
index 9c0d2316031b..754f17bba68e 100644
--- a/fs/bcachefs/xattr.c
+++ b/fs/bcachefs/xattr.c
@@ -544,11 +544,11 @@ static int bch2_xattr_bcachefs_set(const struct xattr_handler *handler,
 		kfree(buf);
 
 		if (ret < 0)
-			return ret;
+			goto err_class_exit;
 
 		ret = bch2_opt_check_may_set(c, opt_id, v);
 		if (ret < 0)
-			return ret;
+			goto err_class_exit;
 
 		s.v = v + 1;
 		s.defined = true;
@@ -595,6 +595,7 @@ static int bch2_xattr_bcachefs_set(const struct xattr_handler *handler,
 	     (opt_id == Opt_compression && !inode_opt_get(c, &inode->ei_inode, background_compression))))
 		bch2_set_rebalance_needs_scan(c, inode->ei_inode.bi_inum);
 
+err_class_exit:
 	return bch2_err_class(ret);
 }
 
-- 
2.34.1


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

* Re: [PATCH] bcachefs: avoid returning private error code in bch2_xattr_bcachefs_set
  2024-03-01  3:17 [PATCH] bcachefs: avoid returning private error code in bch2_xattr_bcachefs_set Hongbo Li
@ 2024-03-01  3:26 ` Jinjie Ruan
  2024-03-01  3:29   ` Kent Overstreet
  2024-03-01  5:45   ` Su Yue
  0 siblings, 2 replies; 6+ messages in thread
From: Jinjie Ruan @ 2024-03-01  3:26 UTC (permalink / raw)
  To: Hongbo Li, kent.overstreet, bfoster; +Cc: linux-bcachefs



On 2024/3/1 11:17, Hongbo Li wrote:
> Avoid the private error code return to caller. The error code
> should be transformed into genernal error code.
> 
> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
> ---
>  fs/bcachefs/xattr.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/bcachefs/xattr.c b/fs/bcachefs/xattr.c
> index 9c0d2316031b..754f17bba68e 100644
> --- a/fs/bcachefs/xattr.c
> +++ b/fs/bcachefs/xattr.c
> @@ -544,11 +544,11 @@ static int bch2_xattr_bcachefs_set(const struct xattr_handler *handler,
>  		kfree(buf);
>  
>  		if (ret < 0)
> -			return ret;
> +			goto err_class_exit;
>  
>  		ret = bch2_opt_check_may_set(c, opt_id, v);
>  		if (ret < 0)
> -			return ret;
> +			goto err_class_exit;
>  
>  		s.v = v + 1;
>  		s.defined = true;
> @@ -595,6 +595,7 @@ static int bch2_xattr_bcachefs_set(const struct xattr_handler *handler,
>  	     (opt_id == Opt_compression && !inode_opt_get(c, &inode->ei_inode, background_compression))))
>  		bch2_set_rebalance_needs_scan(c, inode->ei_inode.bi_inum);
>  
> +err_class_exit:
>  	return bch2_err_class(ret);

那前面的return -ENOMEM和return -EINVAL不用转换吗

>  }
>  

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

* Re: [PATCH] bcachefs: avoid returning private error code in bch2_xattr_bcachefs_set
  2024-03-01  3:26 ` Jinjie Ruan
@ 2024-03-01  3:29   ` Kent Overstreet
  2024-03-01  3:41     ` Hongbo Li
  2024-03-01  5:45   ` Su Yue
  1 sibling, 1 reply; 6+ messages in thread
From: Kent Overstreet @ 2024-03-01  3:29 UTC (permalink / raw)
  To: Jinjie Ruan; +Cc: Hongbo Li, bfoster, linux-bcachefs

On Fri, Mar 01, 2024 at 11:26:51AM +0800, Jinjie Ruan wrote:
> 
> 
> On 2024/3/1 11:17, Hongbo Li wrote:
> > Avoid the private error code return to caller. The error code
> > should be transformed into genernal error code.
> > 
> > Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
> > ---
> >  fs/bcachefs/xattr.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/fs/bcachefs/xattr.c b/fs/bcachefs/xattr.c
> > index 9c0d2316031b..754f17bba68e 100644
> > --- a/fs/bcachefs/xattr.c
> > +++ b/fs/bcachefs/xattr.c
> > @@ -544,11 +544,11 @@ static int bch2_xattr_bcachefs_set(const struct xattr_handler *handler,
> >  		kfree(buf);
> >  
> >  		if (ret < 0)
> > -			return ret;
> > +			goto err_class_exit;
> >  
> >  		ret = bch2_opt_check_may_set(c, opt_id, v);
> >  		if (ret < 0)
> > -			return ret;
> > +			goto err_class_exit;
> >  
> >  		s.v = v + 1;
> >  		s.defined = true;
> > @@ -595,6 +595,7 @@ static int bch2_xattr_bcachefs_set(const struct xattr_handler *handler,
> >  	     (opt_id == Opt_compression && !inode_opt_get(c, &inode->ei_inode, background_compression))))
> >  		bch2_set_rebalance_needs_scan(c, inode->ei_inode.bi_inum);
> >  
> > +err_class_exit:
> >  	return bch2_err_class(ret);
> 
> 那前面的return -ENOMEM和return -EINVAL不用转换吗

Don't follow?

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

* Re: [PATCH] bcachefs: avoid returning private error code in bch2_xattr_bcachefs_set
  2024-03-01  3:29   ` Kent Overstreet
@ 2024-03-01  3:41     ` Hongbo Li
  2024-03-01  3:53       ` Kent Overstreet
  0 siblings, 1 reply; 6+ messages in thread
From: Hongbo Li @ 2024-03-01  3:41 UTC (permalink / raw)
  To: Kent Overstreet, Jinjie Ruan; +Cc: bfoster, linux-bcachefs

Here, ENOMEM and EINVAL are not from internal interface. So I think 
these can return directly.

On 2024/3/1 11:29, Kent Overstreet wrote:
> On Fri, Mar 01, 2024 at 11:26:51AM +0800, Jinjie Ruan wrote:
>>
>>
>> On 2024/3/1 11:17, Hongbo Li wrote:
>>> Avoid the private error code return to caller. The error code
>>> should be transformed into genernal error code.
>>>
>>> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
>>> ---
>>>   fs/bcachefs/xattr.c | 5 +++--
>>>   1 file changed, 3 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/fs/bcachefs/xattr.c b/fs/bcachefs/xattr.c
>>> index 9c0d2316031b..754f17bba68e 100644
>>> --- a/fs/bcachefs/xattr.c
>>> +++ b/fs/bcachefs/xattr.c
>>> @@ -544,11 +544,11 @@ static int bch2_xattr_bcachefs_set(const struct xattr_handler *handler,
>>>   		kfree(buf);
>>>   
>>>   		if (ret < 0)
>>> -			return ret;
>>> +			goto err_class_exit;
>>>   
>>>   		ret = bch2_opt_check_may_set(c, opt_id, v);
>>>   		if (ret < 0)
>>> -			return ret;
>>> +			goto err_class_exit;
>>>   
>>>   		s.v = v + 1;
>>>   		s.defined = true;
>>> @@ -595,6 +595,7 @@ static int bch2_xattr_bcachefs_set(const struct xattr_handler *handler,
>>>   	     (opt_id == Opt_compression && !inode_opt_get(c, &inode->ei_inode, background_compression))))
>>>   		bch2_set_rebalance_needs_scan(c, inode->ei_inode.bi_inum);
>>>   
>>> +err_class_exit:
>>>   	return bch2_err_class(ret);
>>
>> 那前面的return -ENOMEM和return -EINVAL不用转换吗
> 
> Don't follow?

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

* Re: [PATCH] bcachefs: avoid returning private error code in bch2_xattr_bcachefs_set
  2024-03-01  3:41     ` Hongbo Li
@ 2024-03-01  3:53       ` Kent Overstreet
  0 siblings, 0 replies; 6+ messages in thread
From: Kent Overstreet @ 2024-03-01  3:53 UTC (permalink / raw)
  To: Hongbo Li; +Cc: Jinjie Ruan, bfoster, linux-bcachefs

On Fri, Mar 01, 2024 at 11:41:43AM +0800, Hongbo Li wrote:
> Here, ENOMEM and EINVAL are not from internal interface. So I think these
> can return directly.

It's a good patch though, it makes things more consistent so we don't
accidentally get tripped up later - I'm applying it.

> 
> On 2024/3/1 11:29, Kent Overstreet wrote:
> > On Fri, Mar 01, 2024 at 11:26:51AM +0800, Jinjie Ruan wrote:
> > > 
> > > 
> > > On 2024/3/1 11:17, Hongbo Li wrote:
> > > > Avoid the private error code return to caller. The error code
> > > > should be transformed into genernal error code.
> > > > 
> > > > Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
> > > > ---
> > > >   fs/bcachefs/xattr.c | 5 +++--
> > > >   1 file changed, 3 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/fs/bcachefs/xattr.c b/fs/bcachefs/xattr.c
> > > > index 9c0d2316031b..754f17bba68e 100644
> > > > --- a/fs/bcachefs/xattr.c
> > > > +++ b/fs/bcachefs/xattr.c
> > > > @@ -544,11 +544,11 @@ static int bch2_xattr_bcachefs_set(const struct xattr_handler *handler,
> > > >   		kfree(buf);
> > > >   		if (ret < 0)
> > > > -			return ret;
> > > > +			goto err_class_exit;
> > > >   		ret = bch2_opt_check_may_set(c, opt_id, v);
> > > >   		if (ret < 0)
> > > > -			return ret;
> > > > +			goto err_class_exit;
> > > >   		s.v = v + 1;
> > > >   		s.defined = true;
> > > > @@ -595,6 +595,7 @@ static int bch2_xattr_bcachefs_set(const struct xattr_handler *handler,
> > > >   	     (opt_id == Opt_compression && !inode_opt_get(c, &inode->ei_inode, background_compression))))
> > > >   		bch2_set_rebalance_needs_scan(c, inode->ei_inode.bi_inum);
> > > > +err_class_exit:
> > > >   	return bch2_err_class(ret);
> > > 
> > > 那前面的return -ENOMEM和return -EINVAL不用转换吗
> > 
> > Don't follow?

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

* Re: [PATCH] bcachefs: avoid returning private error code in bch2_xattr_bcachefs_set
  2024-03-01  3:26 ` Jinjie Ruan
  2024-03-01  3:29   ` Kent Overstreet
@ 2024-03-01  5:45   ` Su Yue
  1 sibling, 0 replies; 6+ messages in thread
From: Su Yue @ 2024-03-01  5:45 UTC (permalink / raw)
  To: Jinjie Ruan; +Cc: Hongbo Li, kent.overstreet, bfoster, linux-bcachefs


On Fri 01 Mar 2024 at 11:26, Jinjie Ruan <ruanjinjie@huawei.com> 
wrote:

> On 2024/3/1 11:17, Hongbo Li wrote:
>> Avoid the private error code return to caller. The error code
>> should be transformed into genernal error code.
>>
>> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
>> ---
>>  fs/bcachefs/xattr.c | 5 +++--
>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/bcachefs/xattr.c b/fs/bcachefs/xattr.c
>> index 9c0d2316031b..754f17bba68e 100644
>> --- a/fs/bcachefs/xattr.c
>> +++ b/fs/bcachefs/xattr.c
>> @@ -544,11 +544,11 @@ static int bch2_xattr_bcachefs_set(const 
>> struct xattr_handler *handler,
>>  		kfree(buf);
>>
>>  		if (ret < 0)
>> -			return ret;
>> +			goto err_class_exit;
>>
>>  		ret = bch2_opt_check_may_set(c, opt_id, v);
>>  		if (ret < 0)
>> -			return ret;
>> +			goto err_class_exit;
>>
>>  		s.v = v + 1;
>>  		s.defined = true;
>> @@ -595,6 +595,7 @@ static int bch2_xattr_bcachefs_set(const 
>> struct xattr_handler *handler,
>>  	     (opt_id == Opt_compression && !inode_opt_get(c, 
>>  &inode->ei_inode, background_compression))))
>>  		bch2_set_rebalance_needs_scan(c, 
>>  inode->ei_inode.bi_inum);
>>
>> +err_class_exit:
>>  	return bch2_err_class(ret);
>
> 那前面的return -ENOMEM和return -EINVAL不用转换吗
>
Please reply in english. Thanks.

--
Su
>>  }
>>

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

end of thread, other threads:[~2024-03-01  5:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-01  3:17 [PATCH] bcachefs: avoid returning private error code in bch2_xattr_bcachefs_set Hongbo Li
2024-03-01  3:26 ` Jinjie Ruan
2024-03-01  3:29   ` Kent Overstreet
2024-03-01  3:41     ` Hongbo Li
2024-03-01  3:53       ` Kent Overstreet
2024-03-01  5:45   ` Su Yue

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