Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp12936056rwd; Fri, 23 Jun 2023 12:58:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4fc2GvehXyLP0LhDJ//hqZ1Zqqp9jCck9P9P8prB91hspGIeDPT4QWu5nNoZRjA8bSkPZF X-Received: by 2002:a05:6a20:8e14:b0:122:de52:eaf3 with SMTP id y20-20020a056a208e1400b00122de52eaf3mr11676379pzj.16.1687550301971; Fri, 23 Jun 2023 12:58:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687550301; cv=none; d=google.com; s=arc-20160816; b=Rz3d3grVWSuuNtdRmXD2X5nPmrZQYGpcdbK5EWh5eQeURfsQJ93J+y5ZxiQiBzDHrN 75DJioMyUtRWbbsZR3qNbJXngomBoIUDLGnoU1w+WaGMXXavK07VV7N/nrOdI1UlqgUa d3Ix+6iM4s6cw+K6OqJ0vQTaGcm/+HVeadStD20g1qyl3OmFQvG4QXgEeeLtOXXdcOHp 3RKMyIDLCcrDM23wEpOlwAltKzx7Ar/Yxhwg3WjH6b8WNjORR+/ZqX5MrthavMRxDLsY W0muWayxToYo20ZcrEymuweyJlTcgUiA0YDD4KqcymiVtctHt+w90PSazFggb0gtxzck EyOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=mXBy0AaOYC8q+ZTQDhtqjJ6Nh3JsUHeZl6f+Js0D0Bo=; b=RaJmbGWqeOY0Xeg5S5A4b8o80OYm48gGXjLClWbccSj+cgVsW35XgCVTfHW+eXfLEW lV3qYNYgUxgt6Vidav+vWcwnKQGC/ZgQuuE6UbnPzbaVfBcXJ3D70U6QabocVQBwErZQ PACXYuIw9enHFTDXLKCW992V+eat9BBm+0S5JZasYzVSlYe9BkmChBmx44xAur5yprRo INL3S7ABRY2rUEnlmwmlFUKqEbBQr4vcVVa9uZ1XIq384M+kEhj2jlssSuxPxP/bes1v 9eZ8MIyNigTtd3ErE3YTHqTEZgRtoXGfcd0Qh/QzUK6LjzG8iSu6sAk0PxpA8rEvSj0V Fp8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gxUi9P87; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r21-20020aa79635000000b00668871bc9b1si6731303pfg.210.2023.06.23.12.58.08; Fri, 23 Jun 2023 12:58:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gxUi9P87; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231274AbjFWTHf (ORCPT + 99 others); Fri, 23 Jun 2023 15:07:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230317AbjFWTHe (ORCPT ); Fri, 23 Jun 2023 15:07:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DC8C2100 for ; Fri, 23 Jun 2023 12:07:32 -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 7540461AFE for ; Fri, 23 Jun 2023 19:07:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AAB0CC433C0; Fri, 23 Jun 2023 19:07:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687547250; bh=3oIrKT+DwvrEWaVxD5JTgNFQgRwhlYyZXMKFAb4an9c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gxUi9P87k5n0u+hDcsZKcvsli/1yQ/u2ZG1slRAUCrG6d4kwy+TBzpAEdn7ufosx5 cnI6viiDgcY4spSPRXJVltmixK3H+jd7eyS7bDVNpimkZgJyvaT4POV6QcGtZ1dnqE lj9OIq/G0yGf+jG41LjctjFOGUgkjIriMMBCUxnRGxGSTfqF1p3XhYdx77WMN/TMR5 3pGt09TR63vePyCOxuoedNqzin+5vFl6ixKPUbUkg0s1xvzz/quY6eVTlucKuf36+z gGObUR8zOvR90ImbnQxd3CpxMfUzig9AFTVK64OfLZuVdCw2y9lfpl+/WZOSu+wFhc iWXKpV8fIIyfw== Date: Fri, 23 Jun 2023 12:07:29 -0700 From: Jaegeuk Kim To: Chao Yu Cc: =?utf-8?B?5L2V5LqR6JW+KFl1bmxlaSBoZSk=?= , 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: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; > > > > > > 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,