From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC7FAEB64DA for ; Mon, 26 Jun 2023 13:17:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229800AbjFZNRP (ORCPT ); Mon, 26 Jun 2023 09:17:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229853AbjFZNRM (ORCPT ); Mon, 26 Jun 2023 09:17:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84339139 for ; Mon, 26 Jun 2023 06:17:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BF1F960DEF for ; Mon, 26 Jun 2023 13:17:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1061BC433C0; Mon, 26 Jun 2023 13:17:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687785421; bh=s9k+AYqgePpeMVIbOwnHOPJNWdEtQMP7MRlarPpl/SE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dxpMk344RbkBco6lAhRjhfZSdjHK+F0rXhq4r0mHKjP5qC9mkEEtnk0P7JDMgsxV9 px+GwSerrEXQuF3KiZyME/abRD/PStDlqgkn2HP87G8m6Z4WpvYeQyGIxQv0x2PaQH UtGTAZJHzH4CRHdnooI6HegYKvJGVeml5UlW/d+Fkf0QNqFfmKlxlISq9WKimtGmEx 5hmUeqA5ozE13cXa19HyFgk/O/0+91E0ieIIOVDJyZwNoZ1vD6IRwLwTH35HjZdhO6 OACXaeNCstOPTK7dEKQXe/JaYLMyMPtDWxCcHB3HIWY4DSUs+9SVo7HTa9KykkM6lS z3BRjLwJvflkg== Date: Mon, 26 Jun 2023 06:16:59 -0700 From: Jaegeuk Kim To: =?utf-8?B?5L2V5LqR6JW+KFl1bmxlaSBoZSk=?= Cc: Chao Yu , linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [f2fs-dev][PATCH] f2fs: not allowed to set file both cold and hot Message-ID: References: <20230613085250.3648491-1-heyunlei@oppo.com> <6c527e97-c4a6-dc58-13fb-516f77e5e068@oppo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > > > > > --- > > > > > >   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 > > > > > > Thanks,