Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp833621rwo; Sat, 22 Jul 2023 00:43:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlEmnxWsNCCemGKAmuXjfizNgPzyuG0b1zPoGkr6O6gcdjShZsuLny6cFP4YoBOQo4u+k6Sx X-Received: by 2002:a05:6402:8c9:b0:521:aa4b:24f3 with SMTP id d9-20020a05640208c900b00521aa4b24f3mr3724202edz.24.1690011797847; Sat, 22 Jul 2023 00:43:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690011797; cv=none; d=google.com; s=arc-20160816; b=nmygvATUifU0AgMpmmBlUQUCg1gsDIJui1m5pVoF7/hyPq3bbhLJeKhgWbzKwsKxrC DVwSNkOeeKRFh1BYjgnYS4/q9L4zKof+4DJCPF2RJT8C/gEZKxS6rWzem0b05uBemi0S As+wAJ84fWkoRgOZaar6F6rrNo6QH21+5lH1grroedBrkNe/JMoLnHxM5Oj1yJR2cT2I /sehM9QxeXiWSP7hUGA71SNto70mbPZRQ8thB+JP2JrZ2Gpaw7tZSLqsaY3BFN2WhB1p JLbNeV7ctKaFoBhhrMQJusHj8rY9qZpIvzMIR1EJ2szf8IycwBmdQRzngVeqz5yucS3h FX3A== 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-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=A00T7YT21x2/34YdUsnoj8VmmwBXc57NrEKfvG1Z28M=; fh=72Ipvzpuref36+udAaOTH9bUPlPol4oJHvJBYsg/flQ=; b=oUwn244G0S81EfjC6iCAYCjKE2sgQ8CaWjZZO0wb2VR/tEOHrcvR8qApLbAPtt6DJF hSsI57lQHmxYcasCIvwKeWAmHkBM3GsvudallAcQGZL/FqTsrljjC/hEc3vtKBAQxdSY QQmCHwTRghGWgvquip5zq4aFvNXUdPFcJznRCDQQfe+sTQUoGC2fAfRdSjDEapkXamOe 73mFI0gWzBmMLmvF2YFUA4HCuyNWsjI+4CUEMDERyVsGw7aocBkDsD5Xpj9wvn8EpfBW GSpa2zjvHxqJHp5/YOsijK1p621XL7fj/qBN6gWkLxmjS5UO10hNPX52VCmoPeQdLmoP YdRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Shb1jczF; 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 i26-20020a056402055a00b0051e52bd68f2si3391228edx.192.2023.07.22.00.42.51; Sat, 22 Jul 2023 00:43:17 -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=Shb1jczF; 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 S229679AbjGVHFN (ORCPT + 99 others); Sat, 22 Jul 2023 03:05:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229653AbjGVHFM (ORCPT ); Sat, 22 Jul 2023 03:05: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 9001635A1 for ; Sat, 22 Jul 2023 00:05:11 -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 2252560A77 for ; Sat, 22 Jul 2023 07:05:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9DD6C433C8; Sat, 22 Jul 2023 07:05:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690009510; bh=4Jb4Cg+dWbYRID2Lg5Gvj8jeSy+YZqmSa/1jEqqwL40=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Shb1jczFIibxGcSa/6yY5b0bFTQRdHwoSVO3f5cSDCx+siFotwfB4ALFBuRq8jfej UHB66OstXwAfYKICFPzjKBPO0EB3Qe9BtUKHQ7tJmPdL1LS0O27EOD3JXBjUJs9tq/ R5NFxSPIcoAeCtiE2y7UjA4bW9VQN7uyoGz3ZjyPy1du6hXuUJ7TLMEQvG9sQrrz5o S2+813KKV2xjPKmdqgkjDPOvVxc7NE8J1fxuv0xSxyYWnZO8fafzgwHajs5dp4dnQ9 eR0A537WzzXajxzn/3cYZfF2YlkLqIrBP3EAGdOyd/q7O2rKBP9L98r6vhKFedrxkg zZpJ9B83/na0w== Date: Sat, 22 Jul 2023 15:05:04 +0800 From: Gao Xiang To: Jingbo Xu Cc: linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 2/2] erofs: boost negative xattr lookup with bloom filter Message-ID: Mail-Followup-To: Jingbo Xu , 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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230721104923.20236-3-jefflexu@linux.alibaba.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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 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. Thanks, Gao Xiang