Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp871594rwo; Sat, 22 Jul 2023 01:44:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlH9KjDwV/G0KQq2CXNpB4ufv3VBLWm4xDmKfWZjHYv1/XYFk/IQ10OK50M5cQiH8RxG+5CB X-Received: by 2002:a17:902:ea08:b0:1ac:aba5:7885 with SMTP id s8-20020a170902ea0800b001acaba57885mr5742499plg.47.1690015441644; Sat, 22 Jul 2023 01:44:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690015441; cv=none; d=google.com; s=arc-20160816; b=cutawcqnzqPoHLHq0SVPCY4REw1QdtwdBeTfGIrLphUrmLjq3zxU54fea+51CV15AA dM2DYB82tmyGpqZAxtnQ1Vw7+ziI6VCjuv/7qfA7Nn/G6sQMQvL/i7W8kqaDoiVKqTuS Ee2vxVaOrZRKSu58wcn/85g/9X+Qx72GHyMFPBCA6Appo4aoXa4+yoIpaIZndtOV9IhO yZbvvLoOEjfwX8d9XCGR+GTPN44T0QI3lssgeqHdQOfTzLsD7ghJMQDpURw2p9OjBElx HlyEtBgLceoI5Bile6Nu5NUxnPAZyu91tQrFQVh94hEJnDKFn8L/dJP5At79JivHF7su wdPw== 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:to:content-language:subject:user-agent:mime-version:date :message-id; bh=nhjmdER3NrkTYbPJxlUcQoFE4WOvtf+kxbASKdNacNU=; fh=vi8KMhnjAeOzI16nmfng3TZgf26+PO2hjgF90aGwNP0=; b=ZDQsjpKsnQSt6o18FPw+l67JyyfAajGjwk4qh09zWzy8VwuawXJ8YRwX32f9kFlL6Z cMRlpq7bF0opezcB0pktDrtZfwQ18zQiqUi5hTk/Fz9hWzndgKkVhL/hOfgkhWfhlscK L5yAgXmQID98tO8cp1ehbh1wNcePjACs+QOwxUVBHZt0tjOPQoXjOHwHpyP14VSayT+x s883mYlqxvM7mkLCRCq2kMKAqxiFMtp2FhrQZpzyT+rkriZsIGFeRn2lh4EUuEi2LBRa rGBeZJLqs3k44if2e9+hyMP5+nSlRBxyhrK6r7qkOILLU+NvVJtFbusy3JGQwXhRXhwy 7MWg== 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 u13-20020a17090341cd00b001bb8df95094si102032ple.509.2023.07.22.01.43.50; Sat, 22 Jul 2023 01:44:01 -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 S230171AbjGVHdW (ORCPT + 99 others); Sat, 22 Jul 2023 03:33:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229546AbjGVHdU (ORCPT ); Sat, 22 Jul 2023 03:33:20 -0400 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E1B6211E for ; Sat, 22 Jul 2023 00:33:18 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R511e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=2;SR=0;TI=SMTPD_---0Vnx1zap_1690011193; Received: from 30.221.144.79(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0Vnx1zap_1690011193) by smtp.aliyun-inc.com; Sat, 22 Jul 2023 15:33:14 +0800 Message-ID: Date: Sat, 22 Jul 2023 15:33:11 +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 v5 2/2] erofs: boost negative xattr lookup with bloom filter Content-Language: en-US To: linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org References: <20230721104923.20236-1-jefflexu@linux.alibaba.com> <20230721104923.20236-3-jefflexu@linux.alibaba.com> From: Jingbo Xu In-Reply-To: Content-Type: text/plain; charset=UTF-8 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_BLOCKED,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 7/22/23 3:05 PM, Gao Xiang wrote: > On Fri, Jul 21, 2023 at 06:49:23PM +0800, 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. >> >> The initial version is _only_ enabled when xattr_filter_reserved is >> zero. The filter map internals 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/Kconfig | 1 + >> fs/erofs/internal.h | 3 +++ >> fs/erofs/super.c | 1 + >> fs/erofs/xattr.c | 14 ++++++++++++++ >> 4 files changed, 19 insertions(+) >> >> diff --git a/fs/erofs/Kconfig b/fs/erofs/Kconfig >> index f259d92c9720..f49669def828 100644 >> --- a/fs/erofs/Kconfig >> +++ b/fs/erofs/Kconfig >> @@ -38,6 +38,7 @@ config EROFS_FS_DEBUG >> config EROFS_FS_XATTR >> bool "EROFS extended attributes" >> depends on EROFS_FS >> + select XXHASH >> default y >> help >> Extended attributes are name:value pairs associated with inodes by >> diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h >> index 36e32fa542f0..3c1f89d8421b 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 int 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..e9b9ed6b28d2 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 hashbit; > > Why using `uint32_t` here rather than `unsigned int`? We don't use > `uint32_t` in the kernel codebase. > xxh32() returns uint32_t. -- Thanks, Jingbo