Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2062019ybl; Thu, 29 Aug 2019 03:03:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqySFYjQ8KvsfbpQ1ZDuVjJYLP1PgxU8YHvojOaLiv8xsgmvGqkZ0P0Opvuc7NS41/Psifdq X-Received: by 2002:a17:902:e85:: with SMTP id 5mr9335441plx.16.1567072993918; Thu, 29 Aug 2019 03:03:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567072993; cv=none; d=google.com; s=arc-20160816; b=Go0yYDNS3e2Y9PufEQ1PyxFVX2TQB7KT+HJQMMSwSE/ljk6RLpw+7A2zuLYV71m0Xo z1sAeNl9TBK/YatG3/lDjgbEfwdL8LyhnRU0XOXX1rtQZHkTw0F3JJS61oRt3+SE4Co5 kGeqP07G8Ctv4pRedBA5hojYfJYqb28+eXOfV4oX6RozABldwrDj9qm/iptpzwinEk3A m8P3/6eIOs6+dWWpWmy328q0fnfWaVMdc1eaCwcqLKECZGE673Uz+TxiE5CZfTEQhNlP 9yVSOk86OFK023An43eke16SimsPSbB/Cz5Bdjp4sB3A0MCbThRejI7SW5UI9H3J3Pz+ KwwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ojvjtMNTisxFOJO+an7pTOSumsB4I4+hef57OZeho2g=; b=lwnM+uciw1RwORBEDdko9GaWZJKiMmM2NJj8CrYz2Mt1bElghurdaADH15tIskMVtT NUOPgWbqnHRXBdtmdUY3Eb0SH3oJOlk4zVqe77HVOSIZs1DPHBCImzzcj6oxnNtBgcpb dqo+Fxc3ogBWyZ7M3xTumpV9vDmoJs8cWDKH/3CG210sM0ULKxNgySJQiYSWRBoN1ZE7 91mhDJJ2GtWmsSLFJjUj91y6Hr1nSBEVEvBNhYCix/55TzQtKizCMCbnasmuB0AIRXvp gTWzgGb8LxKoDUNu0DQnXgJi/YCqoyM00rLrs+sHX4jwX9Kad3xdSleNj9zyvYXh6pRO FTMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=bp3AoDSf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o19si1479169pll.344.2019.08.29.03.02.53; Thu, 29 Aug 2019 03:03:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=bp3AoDSf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727116AbfH2KAH (ORCPT + 99 others); Thu, 29 Aug 2019 06:00:07 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:48500 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726417AbfH2KAH (ORCPT ); Thu, 29 Aug 2019 06:00:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ojvjtMNTisxFOJO+an7pTOSumsB4I4+hef57OZeho2g=; b=bp3AoDSf4qgAAB94kJbT59OqP rpIL3QyW0xfu/xvUkLXN5yOKH7n2pp+OydVGEZ/oBOSbxu+Re3oKrCJwJhV2F8VxSBfruw9yJc2Lr zgJRrFH+tzVm2xXqGYY/MyB88arocy0WOjfXW+to+6MAiA9EfgpdQ4kWGYPwFbAUVCrQ0Isc43K9V wxozfqLEkdTZtDKNmiFa7DXImCx5UY3tHfD3x36AeTA9mj+P6o7U0GewJXuhXja5VpWidq6Su0M6X CV4kpTix605UaB6UnorPay44KwdvOP8/gOAjHF3t6wT2EXXI+uCkweUskHxQxsZwDiEpYHsTd3gjk TVDORcw4w==; Received: from hch by bombadil.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1i3HDe-0007NV-H4; Thu, 29 Aug 2019 09:59:54 +0000 Date: Thu, 29 Aug 2019 02:59:54 -0700 From: Christoph Hellwig To: Gao Xiang Cc: Alexander Viro , Greg Kroah-Hartman , Andrew Morton , Stephen Rothwell , Theodore Ts'o , Pavel Machek , David Sterba , Amir Goldstein , Christoph Hellwig , "Darrick J . Wong" , Dave Chinner , Jaegeuk Kim , Jan Kara , Linus Torvalds , linux-fsdevel@vger.kernel.org, devel@driverdev.osuosl.org, LKML , linux-erofs@lists.ozlabs.org, Chao Yu , Miao Xie , Li Guifu , Fang Wei Subject: Re: [PATCH v6 01/24] erofs: add on-disk layout Message-ID: <20190829095954.GB20598@infradead.org> References: <20190802125347.166018-1-gaoxiang25@huawei.com> <20190802125347.166018-2-gaoxiang25@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190802125347.166018-2-gaoxiang25@huawei.com> User-Agent: Mutt/1.11.4 (2019-03-13) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > --- /dev/null > +++ b/fs/erofs/erofs_fs.h > @@ -0,0 +1,316 @@ > +/* SPDX-License-Identifier: GPL-2.0-only OR Apache-2.0 */ > +/* > + * linux/fs/erofs/erofs_fs.h Please remove the pointless file names in the comment headers. > +struct erofs_super_block { > +/* 0 */__le32 magic; /* in the little endian */ > +/* 4 */__le32 checksum; /* crc32c(super_block) */ > +/* 8 */__le32 features; /* (aka. feature_compat) */ > +/* 12 */__u8 blkszbits; /* support block_size == PAGE_SIZE only */ Please remove all the byte offset comments. That is something that can easily be checked with gdb or pahole. > +/* 64 */__u8 volume_name[16]; /* volume name */ > +/* 80 */__le32 requirements; /* (aka. feature_incompat) */ > + > +/* 84 */__u8 reserved2[44]; > +} __packed; /* 128 bytes */ Please don't add __packed. In this case I think you don't need it (but double check with pahole), but even if you would need it using proper padding fields and making sure all fields are naturally aligned will give you much better code generation on architectures that don't support native unaligned access. > +/* > + * erofs inode data mapping: > + * 0 - inode plain without inline data A: > + * inode, [xattrs], ... | ... | no-holed data > + * 1 - inode VLE compression B (legacy): > + * inode, [xattrs], extents ... | ... > + * 2 - inode plain with inline data C: > + * inode, [xattrs], last_inline_data, ... | ... | no-holed data > + * 3 - inode compression D: > + * inode, [xattrs], map_header, extents ... | ... > + * 4~7 - reserved > + */ > +enum { > + EROFS_INODE_FLAT_PLAIN, This one doesn't actually seem to be used. > + EROFS_INODE_FLAT_COMPRESSION_LEGACY, why are we adding a legacy field to a brand new file system? > + EROFS_INODE_FLAT_INLINE, > + EROFS_INODE_FLAT_COMPRESSION, > + EROFS_INODE_LAYOUT_MAX It seems like these come from the on-disk format, in which case they should have explicit values assigned to them. Btw, I think it generally helps file system implementation quality if you use a separate header for the on-disk structures vs in-memory structures, as that keeps it clear in everyones mind what needs to stay persistent and what can be chenged easily. > +static bool erofs_inode_is_data_compressed(unsigned int datamode) > +{ > + if (datamode == EROFS_INODE_FLAT_COMPRESSION) > + return true; > + return datamode == EROFS_INODE_FLAT_COMPRESSION_LEGACY; > +} This looks like a really obsfucated way to write: return datamode == EROFS_INODE_FLAT_COMPRESSION || datamode == EROFS_INODE_FLAT_COMPRESSION_LEGACY; > +/* 28 */__le32 i_reserved2; > +} __packed; Sane comment as above. > + > +/* 32 bytes on-disk inode */ > +#define EROFS_INODE_LAYOUT_V1 0 > +/* 64 bytes on-disk inode */ > +#define EROFS_INODE_LAYOUT_V2 1 > + > +struct erofs_inode_v2 { > +/* 0 */__le16 i_advise; Why do we have two inode version in a newly added file system? > +#define ondisk_xattr_ibody_size(count) ({\ > + u32 __count = le16_to_cpu(count); \ > + ((__count) == 0) ? 0 : \ > + sizeof(struct erofs_xattr_ibody_header) + \ > + sizeof(__u32) * ((__count) - 1); }) This would be much more readable as a function. > +#define EROFS_XATTR_ENTRY_SIZE(entry) EROFS_XATTR_ALIGN( \ > + sizeof(struct erofs_xattr_entry) + \ > + (entry)->e_name_len + le16_to_cpu((entry)->e_value_size)) Same here. > +/* available compression algorithm types */ > +enum { > + Z_EROFS_COMPRESSION_LZ4, > + Z_EROFS_COMPRESSION_MAX > +}; Seems like an on-disk value again that should use explicitly assigned numbers.