Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp70710ybk; Fri, 8 May 2020 18:58:37 -0700 (PDT) X-Google-Smtp-Source: APiQypI02cpbpXsoArIL4BCSscDGuwYUzAb6Fogt+uL99Ppgwc10DcluPejez+6W3HA5IMzRzSzA X-Received: by 2002:a17:906:8682:: with SMTP id g2mr4561090ejx.55.1588989517661; Fri, 08 May 2020 18:58:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588989517; cv=none; d=google.com; s=arc-20160816; b=c0upvuw15mgaEFF751asy7Uei9YKBhsHIO9dRVr7J6m5nOxPMuG4Bx6j022YyS5oVF S13t8gk5sGv7FPyTjlJn3BlIE7956Em9Ud77IzGP+vfrrR0a0WrHGZawCLGMZd0W4cvz 3sHpX5Xu+4hVgqjdH+9EedTnWzhOHcOAnHddFl5ANtkaTZEcYtxgAnA7xDZ/HFY4EeCk dBywP/jJzh2uBSoP15eF3xikvkx3+4aRqFx620voVu1bwh6Ey4VH0JFTYRca+Dya9Ng6 K2hzdznSAqLM6VEtiFWgn+O2Nx5+hoDKj0PkrhGNpE0oeTleTgsxM733144u9j85HKyb D6kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=Z6g2MlzeUowlNYAx3AIYE+LKP8u32Zdov99jteGZj3o=; b=ysNIbKQ8eilQT438eo/KApDihfVWJL7rR5vMinNPooNNqtLFqzXdXPIGPW9MQViiVX aODhe7o1/ESx01Z6Y58otiJ9PCwC2UaivvZTcvnRCvb/DyfTIzByV8oxPBX1Lu7A1C9a dlaHecjEUngs3GMynaDUgJeBiJRAiyyQ81uxX/AFhwEYvaQPGxpPEA+r2/qED8HHw+As 3r+R0ctGa2yvXH+zJM6M3qIjvhl4JaovvrG8JVn1ZCw+WMfaYuYS3bDCkeJdjZ5WIo4b qnMcUmvkH3i1jfSSHT7AsY4+i7MV1YNManHuPDuPaf6PUJtRKUoc5DMgpGYgTUP77sX7 gz3A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m26si2850134edj.197.2020.05.08.18.58.14; Fri, 08 May 2020 18:58:37 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728487AbgEIB4j (ORCPT + 99 others); Fri, 8 May 2020 21:56:39 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:34426 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727828AbgEIB4j (ORCPT ); Fri, 8 May 2020 21:56:39 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 198A688844991705F75E; Sat, 9 May 2020 09:56:37 +0800 (CST) Received: from [10.134.22.195] (10.134.22.195) by smtp.huawei.com (10.3.19.205) with Microsoft SMTP Server (TLS) id 14.3.487.0; Sat, 9 May 2020 09:56:33 +0800 Subject: Re: [f2fs-dev] [PATCH] f2fs: compress: allow lz4 to compress data partially To: Gao Xiang CC: , , , References: <20200508094709.40048-1-yuchao0@huawei.com> <20200508102306.GA18849@hsiangkao-HP-ZHAN-66-Pro-G1> From: Chao Yu Message-ID: <4db0121c-5555-b33d-d727-627ef1640f8d@huawei.com> Date: Sat, 9 May 2020 09:56:31 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200508102306.GA18849@hsiangkao-HP-ZHAN-66-Pro-G1> Content-Type: text/plain; charset="windows-1252" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.134.22.195] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Xiang, On 2020/5/8 18:23, Gao Xiang wrote: > Hi Chao, > > On Fri, May 08, 2020 at 05:47:09PM +0800, Chao Yu wrote: >> For lz4 worst compress case, caller should allocate buffer with size >> of LZ4_compressBound(inputsize) for target compressed data storing. >> >> However lz4 supports partial data compression, so we can get rid of >> output buffer size limitation now, then we can avoid 2 * 4KB size >> intermediate buffer allocation when log_cluster_size is 2, and avoid >> unnecessary compressing work of compressor if we can not save at >> least 4KB space. >> >> Suggested-by: Daeho Jeong >> Signed-off-by: Chao Yu >> --- >> fs/f2fs/compress.c | 15 +++++++++------ >> 1 file changed, 9 insertions(+), 6 deletions(-) >> >> diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c >> index 5e4947250262..23825f559bcf 100644 >> --- a/fs/f2fs/compress.c >> +++ b/fs/f2fs/compress.c >> @@ -228,7 +228,12 @@ static int lz4_init_compress_ctx(struct compress_ctx *cc) >> if (!cc->private) >> return -ENOMEM; >> >> - cc->clen = LZ4_compressBound(PAGE_SIZE << cc->log_cluster_size); >> + /* >> + * we do not change cc->clen to LZ4_compressBound(inputsize) to >> + * adapt worst compress case, because lz4 algorithm supports partial >> + * compression. > > Actually, in this case the lz4 compressed block is not valid (at least not ended > in a valid lz4 EOF), and AFAIK the current public lz4 API cannot keep on > compressing this block. so IMO "partial compression" for an invalid lz4 > block may be confusing. Yes, comments could be improved to avoid confusing. > > I think some words like "because lz4 implementation can handle output buffer > budget properly" or similar stuff could be better. It's better, let me change to use this, thanks for the advice. Thanks, > > The same to the patch title and the commit message. > > Thanks, > Gao Xiang > > >> + */ >> + cc->clen = cc->rlen - PAGE_SIZE - COMPRESS_HEADER_SIZE; >> return 0; >> } >> >> @@ -244,11 +249,9 @@ static int lz4_compress_pages(struct compress_ctx *cc) >> >> len = LZ4_compress_default(cc->rbuf, cc->cbuf->cdata, cc->rlen, >> cc->clen, cc->private); >> - if (!len) { >> - printk_ratelimited("%sF2FS-fs (%s): lz4 compress failed\n", >> - KERN_ERR, F2FS_I_SB(cc->inode)->sb->s_id); >> - return -EIO; >> - } >> + if (!len) >> + return -EAGAIN; >> + >> cc->clen = len; >> return 0; >> } >> -- >> 2.18.0.rc1 > . >