All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] loop: Remove redundant status flag operation
@ 2020-06-12  2:43 Yang Xu
  2020-08-01  3:04 ` Yang Xu
  0 siblings, 1 reply; 4+ messages in thread
From: Yang Xu @ 2020-06-12  2:43 UTC (permalink / raw)
  To: linux-block; +Cc: Yang Xu, Martijn Coenen

Since ~LOOP_SET_STATUS_SETTABLE_FLAG is always a subset of ~LOOP_SET_STATUS_CLEARABLE_FLAGS
,remove this redundant flags operation.

Cc: Martijn Coenen <maco@android.com>
Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
 drivers/block/loop.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index c33bbbf..2a61079 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1391,8 +1391,6 @@ static int loop_clr_fd(struct loop_device *lo)
 
 	/* Mask out flags that can't be set using LOOP_SET_STATUS. */
 	lo->lo_flags &= LOOP_SET_STATUS_SETTABLE_FLAGS;
-	/* For those flags, use the previous values instead */
-	lo->lo_flags |= prev_lo_flags & ~LOOP_SET_STATUS_SETTABLE_FLAGS;
 	/* For flags that can't be cleared, use previous values too */
 	lo->lo_flags |= prev_lo_flags & ~LOOP_SET_STATUS_CLEARABLE_FLAGS;
 
-- 
1.8.3.1




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

* Re: [PATCH] loop: Remove redundant status flag operation
  2020-06-12  2:43 [PATCH] loop: Remove redundant status flag operation Yang Xu
@ 2020-08-01  3:04 ` Yang Xu
  2020-08-06  7:45   ` Martijn Coenen
  0 siblings, 1 reply; 4+ messages in thread
From: Yang Xu @ 2020-08-01  3:04 UTC (permalink / raw)
  To: linux-block; +Cc: Martijn Coenen

Hi
Ping.

> Since ~LOOP_SET_STATUS_SETTABLE_FLAG is always a subset of ~LOOP_SET_STATUS_CLEARABLE_FLAGS
> ,remove this redundant flags operation.
> 
> Cc: Martijn Coenen <maco@android.com>
> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
> ---
>   drivers/block/loop.c | 2 --
>   1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> index c33bbbf..2a61079 100644
> --- a/drivers/block/loop.c
> +++ b/drivers/block/loop.c
> @@ -1391,8 +1391,6 @@ static int loop_clr_fd(struct loop_device *lo)
>   
>   	/* Mask out flags that can't be set using LOOP_SET_STATUS. */
>   	lo->lo_flags &= LOOP_SET_STATUS_SETTABLE_FLAGS;
> -	/* For those flags, use the previous values instead */
> -	lo->lo_flags |= prev_lo_flags & ~LOOP_SET_STATUS_SETTABLE_FLAGS;
>   	/* For flags that can't be cleared, use previous values too */
>   	lo->lo_flags |= prev_lo_flags & ~LOOP_SET_STATUS_CLEARABLE_FLAGS;
>   
> 



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

* Re: [PATCH] loop: Remove redundant status flag operation
  2020-08-01  3:04 ` Yang Xu
@ 2020-08-06  7:45   ` Martijn Coenen
  2020-08-06  8:03     ` Yang Xu
  0 siblings, 1 reply; 4+ messages in thread
From: Martijn Coenen @ 2020-08-06  7:45 UTC (permalink / raw)
  To: Yang Xu; +Cc: linux-block

Hi Yang,

Thanks for the patch! I think it's correct, but I wonder whether it's
confusing to read, especially since the comment says "For flags that
can't be cleared, use previous values too" - it might not be obvious
to the reader that ~SETTABLE is a subset of ~CLEARABLE, and they might
think "well what about the settable flags we just cleared?"

To be honest I wouldn't mind leaving the code as-is, since it more
clearly describes what happens, and presumably the compiler will be
smart enough to optimize this anyway. But if you have other ideas on
how to remove this line and make things easier to understand, let me
know.

Best,
Martijn

On Sat, Aug 1, 2020 at 5:04 AM Yang Xu <xuyang2018.jy@cn.fujitsu.com> wrote:
>
> Hi
> Ping.
>
> > Since ~LOOP_SET_STATUS_SETTABLE_FLAG is always a subset of ~LOOP_SET_STATUS_CLEARABLE_FLAGS
> > ,remove this redundant flags operation.
> >
> > Cc: Martijn Coenen <maco@android.com>
> > Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
> > ---
> >   drivers/block/loop.c | 2 --
> >   1 file changed, 2 deletions(-)
> >
> > diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> > index c33bbbf..2a61079 100644
> > --- a/drivers/block/loop.c
> > +++ b/drivers/block/loop.c
> > @@ -1391,8 +1391,6 @@ static int loop_clr_fd(struct loop_device *lo)
> >
> >       /* Mask out flags that can't be set using LOOP_SET_STATUS. */
> >       lo->lo_flags &= LOOP_SET_STATUS_SETTABLE_FLAGS;
> > -     /* For those flags, use the previous values instead */
> > -     lo->lo_flags |= prev_lo_flags & ~LOOP_SET_STATUS_SETTABLE_FLAGS;
> >       /* For flags that can't be cleared, use previous values too */
> >       lo->lo_flags |= prev_lo_flags & ~LOOP_SET_STATUS_CLEARABLE_FLAGS;
> >
> >
>
>

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

* Re: [PATCH] loop: Remove redundant status flag operation
  2020-08-06  7:45   ` Martijn Coenen
@ 2020-08-06  8:03     ` Yang Xu
  0 siblings, 0 replies; 4+ messages in thread
From: Yang Xu @ 2020-08-06  8:03 UTC (permalink / raw)
  To: Martijn Coenen; +Cc: linux-block

Hi Martijn


> Hi Yang,
> 
> Thanks for the patch! I think it's correct, but I wonder whether it's
> confusing to read, especially since the comment says "For flags that
> can't be cleared, use previous values too" - it might not be obvious
> to the reader that ~SETTABLE is a subset of ~CLEARABLE, and they might
> think "well what about the settable flags we just cleared?"
> 
> To be honest I wouldn't mind leaving the code as-is, since it more
> clearly describes what happens, and presumably the compiler will be
> smart enough to optimize this anyway. But if you have other ideas on
> how to remove this line and make things easier to understand, let me
> know.
> 
Thanks for your reply. From code readability, I agree with you and keep 
this code here is better. So ignore this patch.

Best Regards
Yang Xu
> Best,
> Martijn
> 
> On Sat, Aug 1, 2020 at 5:04 AM Yang Xu <xuyang2018.jy@cn.fujitsu.com> wrote:
>>
>> Hi
>> Ping.
>>
>>> Since ~LOOP_SET_STATUS_SETTABLE_FLAG is always a subset of ~LOOP_SET_STATUS_CLEARABLE_FLAGS
>>> ,remove this redundant flags operation.
>>>
>>> Cc: Martijn Coenen <maco@android.com>
>>> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
>>> ---
>>>    drivers/block/loop.c | 2 --
>>>    1 file changed, 2 deletions(-)
>>>
>>> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
>>> index c33bbbf..2a61079 100644
>>> --- a/drivers/block/loop.c
>>> +++ b/drivers/block/loop.c
>>> @@ -1391,8 +1391,6 @@ static int loop_clr_fd(struct loop_device *lo)
>>>
>>>        /* Mask out flags that can't be set using LOOP_SET_STATUS. */
>>>        lo->lo_flags &= LOOP_SET_STATUS_SETTABLE_FLAGS;
>>> -     /* For those flags, use the previous values instead */
>>> -     lo->lo_flags |= prev_lo_flags & ~LOOP_SET_STATUS_SETTABLE_FLAGS;
>>>        /* For flags that can't be cleared, use previous values too */
>>>        lo->lo_flags |= prev_lo_flags & ~LOOP_SET_STATUS_CLEARABLE_FLAGS;
>>>
>>>
>>
>>
> 
> 



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

end of thread, other threads:[~2020-08-06 11:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-12  2:43 [PATCH] loop: Remove redundant status flag operation Yang Xu
2020-08-01  3:04 ` Yang Xu
2020-08-06  7:45   ` Martijn Coenen
2020-08-06  8:03     ` Yang Xu

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.