Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1942848ybj; Wed, 6 May 2020 08:00:52 -0700 (PDT) X-Google-Smtp-Source: APiQypJ1F+xfDVLeX3DOEI8Y3WCMhFAFFjPNJ8TS2DoXiTQe9fNJ/9ao3Gvc9IEnJEsG/ZyLTE/M X-Received: by 2002:a05:6402:1b91:: with SMTP id cc17mr7152821edb.46.1588777251645; Wed, 06 May 2020 08:00:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588777251; cv=none; d=google.com; s=arc-20160816; b=cM3csQ1X7YIXNJBKCXTfCuOPQBT+zs3gBHqaCiN67CQoifEEXKhOMkf21Q6RIMmi6w kDVm7GbsPvvLriTzhE9vD3Jc2W2Lg4gZWl7f9gmidPdeOphw8iHSD9pAJsXqLsekSZB8 PavW+CV/batf2W3JH7IeaaN9b4y4KSoNeJXBSDthm8dn2ljr91zI4vPqJIH1RCeCyMp2 CBJQyAipyUNli4lUCsCcU9F2znph5G9lpSP60ds2GZmF28e+fALu0bD9pjztW42kvyRO eP485MW3IeeQyIfDJs2FaDLfokimDobw+lV71bZ2cTvoCFqH+ta/qtIhNTexUp3aFGKV F6gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=aT4yOgEge3hTF3FaTKwc4a+1Sl1Mq9yw9j7lWipHnrc=; b=eTO8MiqJNGBtcJWk3JSIP+1UxaKO0JGTfhcxfwBogYQuXad+lyuLuzi0TnsvwOjTXf A/zmxGl81hS3hsmXLWVm2v4MQrQAw2EcrtZISrz5x1Qjz7GbI8Ez+1fUddhy2QXA2kH2 dpa03f1+kh93OuCtJWx9PiwYWhqzs5tTde3uXte7h6/dbUSpmiokMwx7csIUlA82uWyc lACR0eNSnGW80PD/J92oYmz6F8EsYgU/ip3BF3Cx5Z+Ikj/fYbjAISOrfZBa68Co3kr1 VR24Vi/SgXfs3j9s4gWeTsCUJlT1OlDEqBT11HrehsAvNwIyBqXg4TmSIWQc/CF2H7VF YiMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Xx0fK9Fb; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ss10si1338529ejb.103.2020.05.06.08.00.27; Wed, 06 May 2020 08:00:51 -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=@kernel.org header.s=default header.b=Xx0fK9Fb; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729363AbgEFO4K (ORCPT + 99 others); Wed, 6 May 2020 10:56:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:45746 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729078AbgEFO4J (ORCPT ); Wed, 6 May 2020 10:56:09 -0400 Received: from localhost (unknown [104.132.1.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2B32C208D5; Wed, 6 May 2020 14:56:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588776969; bh=LEE9kaUuq3swcyipv2Z5cVdwEM6Qz9YdRajLpVMAeUs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Xx0fK9FbNR3TwpC9RsM9U17z+Mt/rhgEorkbaAzNLrrJ5WXebxTK6DxpMb2Sts2Kt 2WZlLZ3Z4qZT1yyx73AZOjHrvnd1l+JnjbHu8P9OJ7Gz9mYE7Cx8da7oJKDsWObkY/ Ym2zOZ0YfaUYi7Ja/4gf4WIJLkZzi6HrVMsxYrx0= Date: Wed, 6 May 2020 07:56:08 -0700 From: Jaegeuk Kim To: Chao Yu Cc: Chao Yu , kernel-team@android.com, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: Re: [f2fs-dev] [PATCH] f2fs: change maximum zstd compression buffer size Message-ID: <20200506145608.GD107238@google.com> References: <20200504143039.155644-1-jaegeuk@kernel.org> <7177aab9-630e-e077-7005-0023c93134b3@kernel.org> <20200505230559.GA203407@google.com> <9aaeac5e-4511-5c81-653c-23a85b3c335a@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9aaeac5e-4511-5c81-653c-23a85b3c335a@huawei.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/06, Chao Yu wrote: > On 2020/5/6 7:05, Jaegeuk Kim wrote: > > On 05/05, Chao Yu wrote: > >> On 2020-5-4 22:30, Jaegeuk Kim wrote: > >>> From: Daeho Jeong > >>> > >>> Current zstd compression buffer size is one page and header size less > >>> than cluster size. By this, zstd compression always succeeds even if > >>> the real compression data is failed to fit into the buffer size, and > >>> eventually reading the cluster returns I/O error with the corrupted > >>> compression data. > >> > >> What's the root cause of this issue? I didn't get it. > >> > >>> > >>> Signed-off-by: Daeho Jeong > >>> --- > >>> fs/f2fs/compress.c | 4 ++-- > >>> 1 file changed, 2 insertions(+), 2 deletions(-) > >>> > >>> diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c > >>> index 4c7eaeee52336..a9fa8049b295f 100644 > >>> --- a/fs/f2fs/compress.c > >>> +++ b/fs/f2fs/compress.c > >>> @@ -313,7 +313,7 @@ static int zstd_init_compress_ctx(struct compress_ctx *cc) > >>> cc->private = workspace; > >>> cc->private2 = stream; > >>> > >>> - cc->clen = cc->rlen - PAGE_SIZE - COMPRESS_HEADER_SIZE; > >>> + cc->clen = ZSTD_compressBound(PAGE_SIZE << cc->log_cluster_size); > >> > >> In my machine, the value is 66572 which is much larger than size of dst > >> buffer, so, in where we can tell the real size of dst buffer to zstd > >> compressor? Otherwise, if compressed data size is larger than dst buffer > >> size, when we flush compressed data into dst buffer, we may suffer overflow. > > > > Could you give it a try compress_log_size=2 and check decompression works? > > I tried some samples before submitting the patch, did you encounter app's data > corruption when using zstd algorithm? If so, let me check this issue. Daeho reported: 1. cp -a src_file comp_dir/dst_file (comp_dir is a directory for compression) 2. sync comp_dir/dst_file 3. echo 3 > /proc/sys/vm/drop_caches 4. cat comp_dir/dst_file > dump (it returns I/O error depending on the file). > > Thanks, > > > > >> > >>> return 0; > >>> } > >>> > >>> @@ -330,7 +330,7 @@ static int zstd_compress_pages(struct compress_ctx *cc) > >>> ZSTD_inBuffer inbuf; > >>> ZSTD_outBuffer outbuf; > >>> int src_size = cc->rlen; > >>> - int dst_size = src_size - PAGE_SIZE - COMPRESS_HEADER_SIZE; > >>> + int dst_size = cc->clen; > >>> int ret; > >>> > >>> inbuf.pos = 0; > >>> > > > > > > _______________________________________________ > > Linux-f2fs-devel mailing list > > Linux-f2fs-devel@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel > > . > >