Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp644353rwp; Wed, 12 Jul 2023 21:09:28 -0700 (PDT) X-Google-Smtp-Source: APBJJlFdhDjI0vRHQDILAwukb+DwCg+Bd6OwDsmbA/bFCnweZiwrTd0Q2XJDeoDWFIYNQQmWt+V5 X-Received: by 2002:a05:6808:14c6:b0:3a3:e86b:c852 with SMTP id f6-20020a05680814c600b003a3e86bc852mr446633oiw.56.1689221368097; Wed, 12 Jul 2023 21:09:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689221368; cv=none; d=google.com; s=arc-20160816; b=LObLbrK3H96rKGoYmv2oSoBiNWGqKpsIEN0DgCBP69377fwMVsFir6nBGCnWSANu4D M83LGidvUXsp+iOhrT+MirOi4KLhIIXtXPjdRc1iPsKysA2DMLjQ+vGv+egsnFSXu8J2 UFy+AE+FgTgydImXxCSK8pcvIVuS3coddy/ADw0iAn8XeoxrFGeY3Pe8ICJQ3XVm/hH8 EWzMp2DHwUlJfGKtxaVEafiWbplaW1KoDe4o7dVHhsVMJD7t283iDmvSq7g6hMrCn8+D VALolHmfqY2ua7KOTEm3ksKb6Diq0ukmZu8AKpojWPo259/44bHjHhnxxQpEF4sEg9Yv tbEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=D24A6QofWZemDlPz48EjW/sTrD+H0oJ7GpKnTJ+BXtE=; fh=3Voaj2RZhaquYXMdMKEEuhCWmHNLtKegL9+lT7fSdDM=; b=xvjXyQfDKYOpDxu1CUphMTUYAD7C3b1JIUZKRkaZyEU2lp6rYsZf/VgLBRDwkjt/3U E3lix7RscyyzT0PMdAsLaYrmlM0gakAGnZiq2HW4EjlP6pOIlOx7DFfjuT5JJalbIwCs 6P7vf+Kx0ergdT6c8yZFOGTiiyGslrAAtPBTCg0tEPBMzoI5oMMylkV4KHrsQj6Egt9l 9/Tm2Njr9FugOUnaUNesH1OMbVZjd+EIbCOAPeCdxdLDG77O/kWsJJKRy6C4T+DcCcUg AW2u4w09VCPf5s+zkbb8ObY5BBdW6DE7ysq70Vdu5K7wDn7wmtVmxRqJuQ2d1zRbIOPZ htkQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n35-20020a634d63000000b0055baed6d244si4128296pgl.193.2023.07.12.21.09.16; Wed, 12 Jul 2023 21:09:28 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233657AbjGMDe4 (ORCPT + 99 others); Wed, 12 Jul 2023 23:34:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233507AbjGMDex (ORCPT ); Wed, 12 Jul 2023 23:34:53 -0400 Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E8C92102 for ; Wed, 12 Jul 2023 20:34:50 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R411e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0VnFF9Mx_1689219285; Received: from 30.97.48.217(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0VnFF9Mx_1689219285) by smtp.aliyun-inc.com; Thu, 13 Jul 2023 11:34:46 +0800 Message-ID: <042c1a3e-2004-c416-a368-b2f6676bb7c0@linux.alibaba.com> Date: Thu, 13 Jul 2023 11:34:45 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v3 2/2] erofs: boost negative xattr lookup with bloom filter To: Jingbo Xu , chao@kernel.org, huyue2@coolpad.com, linux-erofs@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, alexl@redhat.com References: <20230712115123.33712-1-jefflexu@linux.alibaba.com> <20230712115123.33712-3-jefflexu@linux.alibaba.com> From: Gao Xiang In-Reply-To: <20230712115123.33712-3-jefflexu@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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 2023/7/12 19:51, Jingbo Xu wrote: > Optimise the negative xattr lookup with bloom filter. > > The bit value for the bloom filter map has a reverse semantics for > compatibility. That is, the bit value of 0 indicates existence, while > the bit value of 1 indicates the absence of corresponding xattr. > > This feature is enabled only when xattr_filter_reserved is non-zero. > The on-disk format for the filter map may change in the future, in which > case the reserved flag will be set non-zero and we don't need bothering > the compatible bits again at that time. For now disable the optimization > if this reserved flag is non-zero. > > Signed-off-by: Jingbo Xu > --- > fs/erofs/internal.h | 3 +++ > fs/erofs/super.c | 1 + > fs/erofs/xattr.c | 13 +++++++++++++ > 3 files changed, 17 insertions(+) > > diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h > index 36e32fa542f0..ebcad25e3750 100644 > --- a/fs/erofs/internal.h > +++ b/fs/erofs/internal.h > @@ -151,6 +151,7 @@ struct erofs_sb_info { > u32 xattr_prefix_start; > u8 xattr_prefix_count; > struct erofs_xattr_prefix_item *xattr_prefixes; > + unsigned int xattr_filter_reserved; > #endif > u16 device_id_mask; /* valid bits of device id to be used */ > > @@ -251,6 +252,7 @@ EROFS_FEATURE_FUNCS(fragments, incompat, INCOMPAT_FRAGMENTS) > EROFS_FEATURE_FUNCS(dedupe, incompat, INCOMPAT_DEDUPE) > EROFS_FEATURE_FUNCS(xattr_prefixes, incompat, INCOMPAT_XATTR_PREFIXES) > EROFS_FEATURE_FUNCS(sb_chksum, compat, COMPAT_SB_CHKSUM) > +EROFS_FEATURE_FUNCS(xattr_filter, compat, COMPAT_XATTR_FILTER) > > /* atomic flag definitions */ > #define EROFS_I_EA_INITED_BIT 0 > @@ -270,6 +272,7 @@ struct erofs_inode { > unsigned char inode_isize; > unsigned int xattr_isize; > > + unsigned long xattr_name_filter; > unsigned int xattr_shared_count; > unsigned int *xattr_shared_xattrs; > > diff --git a/fs/erofs/super.c b/fs/erofs/super.c > index 9d6a3c6158bd..72122323300e 100644 > --- a/fs/erofs/super.c > +++ b/fs/erofs/super.c > @@ -388,6 +388,7 @@ static int erofs_read_superblock(struct super_block *sb) > sbi->xattr_blkaddr = le32_to_cpu(dsb->xattr_blkaddr); > sbi->xattr_prefix_start = le32_to_cpu(dsb->xattr_prefix_start); > sbi->xattr_prefix_count = dsb->xattr_prefix_count; > + sbi->xattr_filter_reserved = dsb->xattr_filter_reserved; > #endif > sbi->islotbits = ilog2(sizeof(struct erofs_inode_compact)); > sbi->root_nid = le16_to_cpu(dsb->root_nid); > diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c > index 40178b6e0688..eb1d1974d4b3 100644 > --- a/fs/erofs/xattr.c > +++ b/fs/erofs/xattr.c > @@ -5,6 +5,7 @@ > * Copyright (C) 2021-2022, Alibaba Cloud > */ > #include > +#include > #include "xattr.h" > > struct erofs_xattr_iter { > @@ -87,6 +88,7 @@ static int erofs_init_inode_xattrs(struct inode *inode) > } > > ih = it.kaddr + erofs_blkoff(sb, it.pos); > + vi->xattr_name_filter = le32_to_cpu(ih->h_name_filter); > vi->xattr_shared_count = ih->h_shared_count; > vi->xattr_shared_xattrs = kmalloc_array(vi->xattr_shared_count, > sizeof(uint), GFP_KERNEL); > @@ -392,7 +394,10 @@ int erofs_getxattr(struct inode *inode, int index, const char *name, > void *buffer, size_t buffer_size) > { > int ret; > + uint32_t bit; > struct erofs_xattr_iter it; > + struct erofs_inode *vi = EROFS_I(inode); > + struct erofs_sb_info *sbi = EROFS_SB(inode->i_sb); > > if (!name) > return -EINVAL; > @@ -401,6 +406,14 @@ int erofs_getxattr(struct inode *inode, int index, const char *name, > if (ret) > return ret; > > + /* the reserved flag is non-zero if hashing algorithm changes */ > + if (erofs_sb_has_xattr_filter(sbi) && !sbi->xattr_filter_reserved) { > + bit = xxh32(name, strlen(name), EROFS_XATTR_FILTER_SEED + index); should we enable xxh32 by using CONFIG_XXHASH? Thanks, Gao Xiang