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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 89740C761A6 for ; Tue, 4 Apr 2023 08:20:02 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4PrLKY0fTRz3cMH for ; Tue, 4 Apr 2023 18:20:01 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.alibaba.com (client-ip=115.124.30.99; helo=out30-99.freemail.mail.aliyun.com; envelope-from=hsiangkao@linux.alibaba.com; receiver=) Received: from out30-99.freemail.mail.aliyun.com (out30-99.freemail.mail.aliyun.com [115.124.30.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4PrLKS2FJzz3bfk for ; Tue, 4 Apr 2023 18:19:54 +1000 (AEST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046049;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=2;SR=0;TI=SMTPD_---0VfL61xU_1680596389; Received: from 30.97.49.14(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0VfL61xU_1680596389) by smtp.aliyun-inc.com; Tue, 04 Apr 2023 16:19:50 +0800 Message-ID: <0b077f65-42b7-08f2-46cb-3d07131deeb5@linux.alibaba.com> Date: Tue, 4 Apr 2023 16:19:49 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH 3/6] erofs-utils: introduce on-disk format for extra xattr name prefix To: Jingbo Xu , linux-erofs@lists.ozlabs.org References: <20230404080224.77577-1-jefflexu@linux.alibaba.com> <20230404080224.77577-4-jefflexu@linux.alibaba.com> From: Gao Xiang In-Reply-To: <20230404080224.77577-4-jefflexu@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: linux-erofs@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development of Linux EROFS file system List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-erofs-bounces+linux-erofs=archiver.kernel.org@lists.ozlabs.org Sender: "Linux-erofs" On 2023/4/4 16:02, Jingbo Xu wrote: > Besides the predefined xattr name prefixes, introduces extra xattr name > prefixes, which works similarly as the predefined xattr name prefixees, > except that they are user specified. Besides the built-in xattr name prefixes, let's introduce user-defined extra xattr name prefixes, which works similarly as the pre-defined xattr name prefixees, except that they are user specified. > > When matched with a user specified extra xattr name prefix, only the > trailing part of the xattr name except the xattr name prefix will be > stored in erofs_xattr_entry.e_name. e_name is empty if the xattr name > matches exactly as the extra xattr name prefix. When a user-specified extra xattr name prefix is matched, only the trailing part of the xattr name which already eliminates the given prefix will be stored in `erofs_xattr_entry.e_name`. `e_name` can be empty if the xattr full name matches exactly as the name prefix. > > All extra xattr name prefixes are stored in the packed file. For each > extra xattr name prefix, the on-disk format in packed file can be shown > as (u8 prefix_len, prefix string), where the first u8 represents the > length of the prefix string (excluding '\0'), followed by the content of > the prefix string (including '\0'). Why we have to introduce a prefix_len here? > > Two fields are introduced to the on-disk superblock, where > ea_prefix_count represents the total number of the extra xattr name > prefixes recorded in the packed file, and ea_prefix_off represents the > start offset of recorded name prefixes in the packed file. > > When referring to an extra xattr name prefix, the highest bit (bit 7) of > erofs_xattr_entry.e_name_index is set, while the lower bits (bit 0-6) > as a whole represents the index of the referred name prefix among all > extra xattr name prefixes in the packed file. When an extra xattr name prefix is referred, the highest bit (bit 7) of `erofs_xattr_entry.e_name_index` is set, while the lower bits (bit 0-6) as a whole represents the index of the referred name prefix among all extra xattr name prefixes in the packed file. > > Signed-off-by: Jingbo Xu > --- > include/erofs_fs.h | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/include/erofs_fs.h b/include/erofs_fs.h > index 8835a76..3d8eb5f 100644 > --- a/include/erofs_fs.h > +++ b/include/erofs_fs.h > @@ -77,7 +77,9 @@ struct erofs_super_block { > } __packed u1; > __le16 extra_devices; /* # of devices besides the primary device */ > __le16 devt_slotoff; /* startoff = devt_slotoff * devt_slotsize */ > - __u8 reserved[6]; > + __u8 reserved; > + __u8 ea_prefix_count; /* # of extra xattr name prefix */ > + __le32 ea_prefix_off; /* start offset of extra prefixes in packed inode */ > __le64 packed_nid; /* nid of the special packed inode */ > __u8 reserved2[24]; > }; > @@ -228,6 +230,9 @@ struct erofs_xattr_ibody_header { > #define EROFS_XATTR_INDEX_LUSTRE 5 > #define EROFS_XATTR_INDEX_SECURITY 6 > > +#define EROFS_XATTR_EA_FLAG (1 << 7) > +#define EROFS_XATTR_EA_MASK (EROFS_XATTR_EINDEX_FLAG - 1) EROFS_EXTRA_XATTR_FLAG 0x80 EROFS_EXTRA_XATTR_MASK 0x7F ? Thanks, Gao Xiang > + > /* xattr entry (for both inline & shared xattrs) */ > struct erofs_xattr_entry { > __u8 e_name_len; /* length of name */