2023-06-13 09:39:03

by Yunlei He

[permalink] [raw]
Subject: [f2fs-dev][PATCH] f2fs: not allowed to set file both cold and hot

File set both cold and hot advise bit is confusion, so
return EINVAL to avoid this case.

Signed-off-by: Yunlei He <[email protected]>
---
fs/f2fs/xattr.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
index 213805d3592c..917f3ac9f1a1 100644
--- a/fs/f2fs/xattr.c
+++ b/fs/f2fs/xattr.c
@@ -127,6 +127,9 @@ static int f2fs_xattr_advise_set(const struct xattr_handler *handler,
return -EINVAL;

new_advise = new_advise & FADVISE_MODIFIABLE_BITS;
+ if ((new_advise & FADVISE_COLD_BIT) && (new_advise & FADVISE_HOT_BIT))
+ return -EINVAL;
+
new_advise |= old_advise & ~FADVISE_MODIFIABLE_BITS;

F2FS_I(inode)->i_advise = new_advise;
--
2.40.1

________________________________
OPPO

本电子邮件及其附件含有OPPO公司的保密信息,仅限于邮件指明的收件人(包含个人及群组)使用。禁止任何人在未经授权的情况下以任何形式使用。如果您错收了本邮件,切勿传播、分发、复制、印刷或使用本邮件之任何部分或其所载之任何内容,并请立即以电子邮件通知发件人并删除本邮件及其附件。
网络通讯固有缺陷可能导致邮件被截留、修改、丢失、破坏或包含计算机病毒等不安全情况,OPPO对此类错误或遗漏而引致之任何损失概不承担责任并保留与本邮件相关之一切权利。
除非明确说明,本邮件及其附件无意作为在任何国家或地区之要约、招揽或承诺,亦无意作为任何交易或合同之正式确认。 发件人、其所属机构或所属机构之关联机构或任何上述机构之股东、董事、高级管理人员、员工或其他任何人(以下称“发件人”或“OPPO”)不因本邮件之误送而放弃其所享之任何权利,亦不对因故意或过失使用该等信息而引发或可能引发的损失承担任何责任。
文化差异披露:因全球文化差异影响,单纯以YES\OK或其他简单词汇的回复并不构成发件人对任何交易或合同之正式确认或接受,请与发件人再次确认以获得明确书面意见。发件人不对任何受文化差异影响而导致故意或错误使用该等信息所造成的任何直接或间接损害承担责任。
This e-mail and its attachments contain confidential information from OPPO, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you are not the intended recipient, please do not read, copy, distribute, or use this information. If you have received this transmission in error, please notify the sender immediately by reply e-mail and then delete this message.
Electronic communications may contain computer viruses or other defects inherently, may not be accurately and/or timely transmitted to other systems, or may be intercepted, modified ,delayed, deleted or interfered. OPPO shall not be liable for any damages that arise or may arise from such matter and reserves all rights in connection with the email.
Unless expressly stated, this e-mail and its attachments are provided without any warranty, acceptance or promise of any kind in any country or region, nor constitute a formal confirmation or acceptance of any transaction or contract. The sender, together with its affiliates or any shareholder, director, officer, employee or any other person of any such institution (hereinafter referred to as "sender" or "OPPO") does not waive any rights and shall not be liable for any damages that arise or may arise from the intentional or negligent use of such information.
Cultural Differences Disclosure: Due to global cultural differences, any reply with only YES\OK or other simple words does not constitute any confirmation or acceptance of any transaction or contract, please confirm with the sender again to ensure clear opinion in written form. The sender shall not be responsible for any direct or indirect damages resulting from the intentional or misuse of such information.


2023-06-20 01:02:00

by Chao Yu

[permalink] [raw]
Subject: Re: [f2fs-dev][PATCH] f2fs: not allowed to set file both cold and hot

On 2023/6/13 16:52, Yunlei He wrote:
> File set both cold and hot advise bit is confusion, so
> return EINVAL to avoid this case.
>
> Signed-off-by: Yunlei He <[email protected]>
> ---
> fs/f2fs/xattr.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
> index 213805d3592c..917f3ac9f1a1 100644
> --- a/fs/f2fs/xattr.c
> +++ b/fs/f2fs/xattr.c
> @@ -127,6 +127,9 @@ static int f2fs_xattr_advise_set(const struct xattr_handler *handler,
> return -EINVAL;
>
> new_advise = new_advise & FADVISE_MODIFIABLE_BITS;
> + if ((new_advise & FADVISE_COLD_BIT) && (new_advise & FADVISE_HOT_BIT))
> + return -EINVAL;

Yunlei,

What about the below case:

1. f2fs_xattr_advise_set(FADVISE_COLD_BIT)
2. f2fs_xattr_advise_set(FADVISE_HOT_BIT)

Thanks,

> +
> new_advise |= old_advise & ~FADVISE_MODIFIABLE_BITS;
>
> F2FS_I(inode)->i_advise = new_advise;
> --

2023-06-20 03:03:14

by Yunlei He

[permalink] [raw]
Subject: Re: [f2fs-dev][PATCH] f2fs: not allowed to set file both cold and hot


On 2023/6/20 8:33, Chao Yu wrote:
> On 2023/6/13 16:52, Yunlei He wrote:
>> File set both cold and hot advise bit is confusion, so
>> return EINVAL to avoid this case.
>>
>> Signed-off-by: Yunlei He <[email protected]>
>> ---
>>   fs/f2fs/xattr.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
>> index 213805d3592c..917f3ac9f1a1 100644
>> --- a/fs/f2fs/xattr.c
>> +++ b/fs/f2fs/xattr.c
>> @@ -127,6 +127,9 @@ static int f2fs_xattr_advise_set(const struct
>> xattr_handler *handler,
>>                  return -EINVAL;
>>
>>          new_advise = new_advise & FADVISE_MODIFIABLE_BITS;
>> +       if ((new_advise & FADVISE_COLD_BIT) && (new_advise &
>> FADVISE_HOT_BIT))
>> +               return -EINVAL;
>
> Yunlei,
>
> What about the below case:
>
> 1. f2fs_xattr_advise_set(FADVISE_COLD_BIT)
> 2. f2fs_xattr_advise_set(FADVISE_HOT_BIT)

Hi,  Chao,

    I test this case work well with this patch,  case below will return
-EINVAL:

    f2fs_xattr_advise_set(FADVISE_COLD_BIT | FADVISE_HOT_BIT)

Thanks,

>
> Thanks,
>
>> +
>>          new_advise |= old_advise & ~FADVISE_MODIFIABLE_BITS;
>>
>>          F2FS_I(inode)->i_advise = new_advise;
>> --

2023-06-20 08:32:52

by Chao Yu

[permalink] [raw]
Subject: Re: [f2fs-dev][PATCH] f2fs: not allowed to set file both cold and hot

On 2023/6/20 10:42, 何云蕾(Yunlei he) wrote:
>
> On 2023/6/20 8:33, Chao Yu wrote:
>> On 2023/6/13 16:52, Yunlei He wrote:
>>> File set both cold and hot advise bit is confusion, so
>>> return EINVAL to avoid this case.
>>>
>>> Signed-off-by: Yunlei He <[email protected]>
>>> ---
>>>   fs/f2fs/xattr.c | 3 +++
>>>   1 file changed, 3 insertions(+)
>>>
>>> diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
>>> index 213805d3592c..917f3ac9f1a1 100644
>>> --- a/fs/f2fs/xattr.c
>>> +++ b/fs/f2fs/xattr.c
>>> @@ -127,6 +127,9 @@ static int f2fs_xattr_advise_set(const struct xattr_handler *handler,
>>>                  return -EINVAL;
>>>
>>>          new_advise = new_advise & FADVISE_MODIFIABLE_BITS;
>>> +       if ((new_advise & FADVISE_COLD_BIT) && (new_advise & FADVISE_HOT_BIT))
>>> +               return -EINVAL;
>>
>> Yunlei,
>>
>> What about the below case:
>>
>> 1. f2fs_xattr_advise_set(FADVISE_COLD_BIT)
>> 2. f2fs_xattr_advise_set(FADVISE_HOT_BIT)
>
> Hi,  Chao,
>
>     I test this case work well with this patch,  case below will return -EINVAL:
>
>     f2fs_xattr_advise_set(FADVISE_COLD_BIT | FADVISE_HOT_BIT)

Correct, I missed to check below statement.

new_advise |= old_advise & ~FADVISE_MODIFIABLE_BITS;

Anyway, the patch looks good to me.

Reviewed-by: Chao Yu <[email protected]>

Thanks,

2023-06-23 19:58:22

by Jaegeuk Kim

[permalink] [raw]
Subject: Re: [f2fs-dev][PATCH] f2fs: not allowed to set file both cold and hot

On 06/20, Chao Yu wrote:
> On 2023/6/20 10:42, 何云蕾(Yunlei he) wrote:
> >
> > On 2023/6/20 8:33, Chao Yu wrote:
> > > On 2023/6/13 16:52, Yunlei He wrote:
> > > > File set both cold and hot advise bit is confusion, so
> > > > return EINVAL to avoid this case.
> > > >
> > > > Signed-off-by: Yunlei He <[email protected]>
> > > > ---
> > > >   fs/f2fs/xattr.c | 3 +++
> > > >   1 file changed, 3 insertions(+)
> > > >
> > > > diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
> > > > index 213805d3592c..917f3ac9f1a1 100644
> > > > --- a/fs/f2fs/xattr.c
> > > > +++ b/fs/f2fs/xattr.c
> > > > @@ -127,6 +127,9 @@ static int f2fs_xattr_advise_set(const struct xattr_handler *handler,
> > > >                  return -EINVAL;
> > > >
> > > >          new_advise = new_advise & FADVISE_MODIFIABLE_BITS;
> > > > +       if ((new_advise & FADVISE_COLD_BIT) && (new_advise & FADVISE_HOT_BIT))
> > > > +               return -EINVAL;

Why not this to allow setting one bit only?

@@ -123,7 +123,8 @@ static int f2fs_xattr_advise_set(const struct xattr_handler *handler,
return -EINVAL;

new_advise = *(char *)value;
- if (new_advise & ~FADVISE_MODIFIABLE_BITS)
+ if (new_advise & ~FADVISE_MODIFIABLE_BITS ||
+ new_advise == FADVISE_MODIFIABLE_BITS)
return -EINVAL;

> > >
> > > Yunlei,
> > >
> > > What about the below case:
> > >
> > > 1. f2fs_xattr_advise_set(FADVISE_COLD_BIT)
> > > 2. f2fs_xattr_advise_set(FADVISE_HOT_BIT)
> >
> > Hi,  Chao,
> >
> >     I test this case work well with this patch,  case below will return -EINVAL:
> >
> >     f2fs_xattr_advise_set(FADVISE_COLD_BIT | FADVISE_HOT_BIT)
>
> Correct, I missed to check below statement.
>
> new_advise |= old_advise & ~FADVISE_MODIFIABLE_BITS;
>
> Anyway, the patch looks good to me.
>
> Reviewed-by: Chao Yu <[email protected]>
>
> Thanks,

2023-06-26 13:36:50

by Jaegeuk Kim

[permalink] [raw]
Subject: Re: [f2fs-dev][PATCH] f2fs: not allowed to set file both cold and hot

On 06/25, 何云蕾(Yunlei he) wrote:
>
> On 2023/6/24 3:07, Jaegeuk Kim wrote:
> > On 06/20, Chao Yu wrote:
> > > On 2023/6/20 10:42, 何云蕾(Yunlei he) wrote:
> > > > On 2023/6/20 8:33, Chao Yu wrote:
> > > > > On 2023/6/13 16:52, Yunlei He wrote:
> > > > > > File set both cold and hot advise bit is confusion, so
> > > > > > return EINVAL to avoid this case.
> > > > > >
> > > > > > Signed-off-by: Yunlei He<[email protected]>
> > > > > > ---
> > > > > >   fs/f2fs/xattr.c | 3 +++
> > > > > >   1 file changed, 3 insertions(+)
> > > > > >
> > > > > > diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
> > > > > > index 213805d3592c..917f3ac9f1a1 100644
> > > > > > --- a/fs/f2fs/xattr.c
> > > > > > +++ b/fs/f2fs/xattr.c
> > > > > > @@ -127,6 +127,9 @@ static int f2fs_xattr_advise_set(const struct xattr_handler *handler,
> > > > > >                  return -EINVAL;
> > > > > >
> > > > > >          new_advise = new_advise & FADVISE_MODIFIABLE_BITS;
> > > > > > +       if ((new_advise & FADVISE_COLD_BIT) && (new_advise & FADVISE_HOT_BIT))
> > > > > > +               return -EINVAL;
> > Why not this to allow setting one bit only?
> >
> > @@ -123,7 +123,8 @@ static int f2fs_xattr_advise_set(const struct xattr_handler *handler,
> > return -EINVAL;
> >
> > new_advise = *(char *)value;
> > - if (new_advise & ~FADVISE_MODIFIABLE_BITS)
> > + if (new_advise & ~FADVISE_MODIFIABLE_BITS ||
> > + new_advise == FADVISE_MODIFIABLE_BITS)
> > return -EINVAL;
>
> Hi,Jaegeuk,
>
> If new modifiable advise bit is added in the future, maybe multi-bits
> is allowed?
>

Looks like making a single bit assumption would be better in general at this
moment.

> Thanks
>
> >
> > > > > Yunlei,
> > > > >
> > > > > What about the below case:
> > > > >
> > > > > 1. f2fs_xattr_advise_set(FADVISE_COLD_BIT)
> > > > > 2. f2fs_xattr_advise_set(FADVISE_HOT_BIT)
> > > > Hi,  Chao,
> > > >
> > > >     I test this case work well with this patch,  case below will return -EINVAL:
> > > >
> > > >     f2fs_xattr_advise_set(FADVISE_COLD_BIT | FADVISE_HOT_BIT)
> > > Correct, I missed to check below statement.
> > >
> > > new_advise |= old_advise & ~FADVISE_MODIFIABLE_BITS;
> > >
> > > Anyway, the patch looks good to me.
> > >
> > > Reviewed-by: Chao Yu<[email protected]>
> > >
> > > Thanks,