Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3893787ybz; Mon, 4 May 2020 11:39:42 -0700 (PDT) X-Google-Smtp-Source: APiQypJPxxlh0rDIjSO1vPlSf65kAl4joHKNhiT/t8jzCibkBrKSya1/3VKjElAFewkNg/6tSUL/ X-Received: by 2002:a50:b285:: with SMTP id p5mr16354225edd.150.1588617582222; Mon, 04 May 2020 11:39:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588617582; cv=none; d=google.com; s=arc-20160816; b=dsT8QUXKHNZipsqemGySoZZK6vXc4xDGItOX1P7blZXZSbsqX72rfUp4cBfpr0hC9G 23l70sqB0TL/ucd/uqZT1a6oqcJNL1bIEb+KBqeDcr5awmSuP9ZtVo64lyoWBplCIKv0 tH+xPkZv0m31gErn/p/kk8DlrQRG4iYHU9IaAUkyZ2kGru0JdFRZrGpb84BV/yRDC4OH nhLoF/RyDLz5RgnygGd5kyQYY6gqoyZFKkBe+Pd8DqdE0kQNlWpFs+OjqsnC016CdZ1D CZ2521VXWTOy4OPIKktFxL4yDrvdnfpC1xi3F6Pgr3c7AUpthTRpNK4Q4zeBjHVCRR9B UA8g== 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:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=xfRf1+Nu1KQ7VKg3sAoxtbOUpd1Vl1YVp4aNBzBltVs=; b=ArMTXb9wzC+DTUgNvPhInRP3AQvt8da0a/U/p3fzxd/SzLonKW6RiNAUkzObzw+84m RIEQiFUqDtjlyCI5s/s5rafFVDqqO6Ql1j7ygXACGS4FYyB4r02hHqjUzmZqJrgKi6Bl L/ewqFoOX2VXN4LZpQ1HI6dDIXEmG8HrjtfYJZ9spoDD5HfD5pZowBKTOr1NmBX4Vndb oaK0UnVMCseQ8teNp2QpM6q9fyTG6AHAUeUrfx4gTKjDHT0K6yHQe8/oGiOxYW1qmsLp KLnbNncs2TOKwhfC7NCUtBC6DPjwuGZgQFPVIeJdUYHFSSulpuZ/kmirp16ALumzVXT9 EKRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eEJaD0ZE; 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 c11si6839709ejs.396.2020.05.04.11.39.19; Mon, 04 May 2020 11:39:42 -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=eEJaD0ZE; 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 S1729060AbgEDOal (ORCPT + 99 others); Mon, 4 May 2020 10:30:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:42812 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728324AbgEDOak (ORCPT ); Mon, 4 May 2020 10:30:40 -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 85F6F20721; Mon, 4 May 2020 14:30:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588602640; bh=npyVMpEkCqP47vK/3mKvzs371ZtGgQITkgOQX9mdQjY=; h=From:To:Cc:Subject:Date:From; b=eEJaD0ZEz5VfWYlWTVpOTos5fOnwiNG3g/saqcrKdLWp78+xQuLIWaK/+6+jzg7A6 lUVoRHynjtW/MoTSZCXKP4hBWLOgKLvzHTEAx46W/NXdOqsy+yFe3tqORj1sPjyHsV VND1zcREbsOSfw7FDmp+OZpATxcM3scDDKAEmXFU= From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com Cc: Daeho Jeong Subject: [PATCH] f2fs: change maximum zstd compression buffer size Date: Mon, 4 May 2020 07:30:39 -0700 Message-Id: <20200504143039.155644-1-jaegeuk@kernel.org> X-Mailer: git-send-email 2.26.2.526.g744177e7f7-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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); 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; -- 2.26.2.526.g744177e7f7-goog