Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1940319pxf; Fri, 26 Mar 2021 20:58:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbVqGrkpG9BRRkwAEg1iRD7jFSeA4SbKGXJV7n1veTqSghTwLltXD//Ymgi70YPRt6E0KR X-Received: by 2002:a17:906:72d1:: with SMTP id m17mr18140026ejl.118.1616817520537; Fri, 26 Mar 2021 20:58:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616817520; cv=none; d=google.com; s=arc-20160816; b=XzeHTPsBG7UyzRJk5AUZZHJQU69CGvUWUWbY6laUHK7Szp0fksNBpR8X8QjG2oOfWy 3JRlrmmho9arv81hVH/BSLwLGvg7nbFYeUTi/7etgjnqS5hf2DlOtY5lCniQrjrIS/hj luwe4/Yt0mQgBfbl1Zs3vt70P4oaxaVqvJIlhtmrUGmpYvm39MnNv63BAkRvF7YhJY9q 2NuKnu7mexrQrvL1kPrXF3C+fYo4FA/ZKSqW1ry12KECg/y07giZkpxa9vapxlOijxgd Ipm364HWWn3zj6MpLNa1dRQSwd/P4Oz/fqUIEH3QKsas6O6TnGSH5/goB8OGDqdEH9dw njqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=X0tRARu0MegMUcBxQZECsDMdTCraDyBuqxwTQHTyjb8=; b=k3Ume23Tn5ss9opmcAKbN/fxJvsLN0LRhyHRTQfTgsviRp/x0SNvR/9+3FsXyYRoN5 xYVfM1P3bcKXIPwlJDKd0POcUHsXqqrRE0vO2NKZGGaye6Va38Hx5jO1Z8xk/yE4jGcm FjkqloApbzWP67TlOdnpoTJfUrzKZKPp4W8Y1tgjKag8ch7RP9ks2AfUqB4XDs61MbKf Quk0EkYpb72DPsSKFIj8v2MyPodpRe1SHAt3qbjnWXsrx8JPsrcSuSsMqPVySBKBnGaE ntpD9FbrqTMwD+9X03DawcJXYgIIJ1Q3x2M4H985GxRekzs9ESbx3tTMnP0M70+mqlls nZtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aol.com header.s=a2048 header.b=hhkhWUXi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=aol.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id zj12si8049323ejb.508.2021.03.26.20.58.18; Fri, 26 Mar 2021 20:58:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@aol.com header.s=a2048 header.b=hhkhWUXi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=aol.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231351AbhC0Du0 (ORCPT + 99 others); Fri, 26 Mar 2021 23:50:26 -0400 Received: from sonic313-21.consmr.mail.gq1.yahoo.com ([98.137.65.84]:34264 "EHLO sonic313-21.consmr.mail.gq1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230318AbhC0DuL (ORCPT ); Fri, 26 Mar 2021 23:50:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1616817011; bh=X0tRARu0MegMUcBxQZECsDMdTCraDyBuqxwTQHTyjb8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=hhkhWUXi0QRBVXLr+Z9fvBCV5hekCUVnUM/NmSLLRhnAaz2pMJvqTeazJ/abx5W/rINpsEsV2j4G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loxk1enu7AdCZ3s0sTtB_evTV8BkyfwL5v576lostSckIb7tXTzShFb XlEsx0XpMqN6OEw45JEQjO6E1zmk1SchThh2mI7xVzCIc81sEA_E37cpWpmjzTfbzFmeEi6GLNrZ U4h01.L.HpHxVVIHUqnI4XnaGj5AN14NUx1Ioygtd_FLnjcI49ZdPVgFxiTskS6iqQK8JrkIHayD MWTi4zOqf6nhn2.LWSh7lxafdMzgyN4lVKchGOfN9x5DQilkcHadfyK3Y9NQ1jUH8s1oupk9CsGa 9rQbGypRdIcmSYiSmW58- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic313.consmr.mail.gq1.yahoo.com with HTTP; Sat, 27 Mar 2021 03:50:11 +0000 Received: by kubenode529.mail-prod1.omega.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID b79f63fb2a60f2e9a0e41858735ab882; Sat, 27 Mar 2021 03:50:04 +0000 (UTC) From: Gao Xiang To: linux-erofs@lists.ozlabs.org, Chao Yu , Chao Yu Cc: LKML , Gao Xiang Subject: [PATCH 3/4] erofs: introduce on-disk lz4 fs configurations Date: Sat, 27 Mar 2021 11:49:35 +0800 Message-Id: <20210327034936.12537-4-hsiangkao@aol.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210327034936.12537-1-hsiangkao@aol.com> References: <20210327034936.12537-1-hsiangkao@aol.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Length: 3317 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gao Xiang Introduce z_erofs_lz4_cfgs to store all lz4 configurations. Currently it's only max_distance, but will be used for new features later. Signed-off-by: Gao Xiang --- fs/erofs/decompressor.c | 15 +++++++++++++-- fs/erofs/erofs_fs.h | 6 ++++++ fs/erofs/internal.h | 8 +++++--- fs/erofs/super.c | 2 +- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c index 93411e9df9b6..97538ff24a19 100644 --- a/fs/erofs/decompressor.c +++ b/fs/erofs/decompressor.c @@ -29,9 +29,20 @@ struct z_erofs_decompressor { }; int z_erofs_load_lz4_config(struct super_block *sb, - struct erofs_super_block *dsb) + struct erofs_super_block *dsb, + struct z_erofs_lz4_cfgs *lz4, int size) { - u16 distance = le16_to_cpu(dsb->lz4_max_distance); + u16 distance; + + if (lz4) { + if (size < sizeof(struct z_erofs_lz4_cfgs)) { + erofs_err(sb, "invalid lz4 cfgs, size=%u", size); + return -EINVAL; + } + distance = le16_to_cpu(lz4->max_distance); + } else { + distance = le16_to_cpu(dsb->lz4_max_distance); + } EROFS_SB(sb)->lz4.max_distance_pages = distance ? DIV_ROUND_UP(distance, PAGE_SIZE) + 1 : diff --git a/fs/erofs/erofs_fs.h b/fs/erofs/erofs_fs.h index b27d0e4e4ab5..1322ae63944b 100644 --- a/fs/erofs/erofs_fs.h +++ b/fs/erofs/erofs_fs.h @@ -196,6 +196,12 @@ enum { Z_EROFS_COMPRESSION_MAX }; +/* 14 bytes (+ length field = 16 bytes) */ +struct z_erofs_lz4_cfgs { + __le16 max_distance; + u8 reserved[12]; +} __packed; + /* * bit 0 : COMPACTED_2B indexes (0 - off; 1 - on) * e.g. for 4k logical cluster size, 4B if compacted 2B is off; diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index 1de60992c3dd..46b977f348eb 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -441,7 +441,8 @@ int erofs_try_to_free_all_cached_pages(struct erofs_sb_info *sbi, int erofs_try_to_free_cached_page(struct address_space *mapping, struct page *page); int z_erofs_load_lz4_config(struct super_block *sb, - struct erofs_super_block *dsb); + struct erofs_super_block *dsb, + struct z_erofs_lz4_cfgs *lz4, int len); #else static inline void erofs_shrinker_register(struct super_block *sb) {} static inline void erofs_shrinker_unregister(struct super_block *sb) {} @@ -450,9 +451,10 @@ static inline void erofs_exit_shrinker(void) {} static inline int z_erofs_init_zip_subsystem(void) { return 0; } static inline void z_erofs_exit_zip_subsystem(void) {} static inline int z_erofs_load_lz4_config(struct super_block *sb, - struct erofs_super_block *dsb) + struct erofs_super_block *dsb, + struct z_erofs_lz4_cfgs *lz4, int len) { - if (dsb->lz4_max_distance) { + if (lz4 || dsb->lz4_max_distance) { erofs_err(sb, "lz4 algorithm isn't enabled"); return -EINVAL; } diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 3212e4f73f85..1ca8da3f2125 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -189,7 +189,7 @@ static int erofs_read_superblock(struct super_block *sb) } /* parse on-disk compression configurations */ - ret = z_erofs_load_lz4_config(sb, dsb); + ret = z_erofs_load_lz4_config(sb, dsb, NULL, 0); out: kunmap(page); put_page(page); -- 2.20.1