Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2619126lqp; Mon, 25 Mar 2024 04:46:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVMXJ0SR0owfCfxpBz1667ix4ES7AKD4iA5fDWXRf9pMR6ooqhxdesJOfonpsV1oe5GsBEYRy7l+2Oo7RXeC8F7PzJ77J6vOEzeBFQ9sw== X-Google-Smtp-Source: AGHT+IEnEXjgXJmf6cYRgRTJOOvh3/j38LBYD04AIjLJhXYdIyB2TFjO9Vg9tTZegRIhMbxn4Kpe X-Received: by 2002:a05:620a:22d8:b0:789:cb55:c853 with SMTP id o24-20020a05620a22d800b00789cb55c853mr6986424qki.31.1711367187269; Mon, 25 Mar 2024 04:46:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711367187; cv=pass; d=google.com; s=arc-20160816; b=g0rB068BnLJ3O4DhOxHkZ2FONhxbrcMA2oysy+JiE3KosyoReFQDWhxn058+uLUajz lryeCkktpYx8aZGmz+lfbEIbmdbCY4z8HeWukxRwy6On8NfjluqTFTBWh1IlOzP2kV7X qviWrdDUf4YK0OPSI23Vimro6M/reSjIfwOjlb9VRgF9hFRusIUv/7sifnO7YsmMN32M uAzrWe9fT1vmhJD7cfaATH/2SO9816VclknyScajlRDFHAvaSt33v4q1oUg4iwC8soD7 BXM9SozYj9I/jF2x5fqIxZZ2kF5qQb52CtJmPSAYLFI9rXAcmvpZswwyTeYJZTGwu04S yhFw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=+SnTtD7DXu5e70aTeT7mf3j2VKCUX7z/J4K9sspGLyo=; fh=knx7W2NmVnUC/zFrwBRIgr9mXwbfK/a68OS+I3fMY/c=; b=W0sxNPiVCRZV7klnT2MFNK5jd5/U8f4mDJzQfeqavfys2Y1L1eZ4k09FNiGDo1vmc/ s6wI6RKNHuR4vVF/CuAvtznDjv0nSuSOSfDd61+0hfye9XDgyQm848dwrIwHFA02E5bT jCIcloZ2VmptAcUQD6NwbMcXamNoVpJ5Cev+X+CnZxkY7/6IY2Kx6P6kpmrJcGMXPqxN zwuy+b8ha1LfIpzUxZwOqvyBBId7LWi94yzXjR50eTMc5pSx0D3TVrrG6CnwySN4bxPw /KOS2ZtG0I0jLrXMMbKBfTg0+ZR2mjeZuwdMuWuiyWIHK9vT5uRrrPeyfWx0SuUytGB/ cChA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="RDv/P/6p"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116205-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116205-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id wg8-20020a05620a568800b0078a56e66e5asi1944935qkn.530.2024.03.25.04.46.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 04:46:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116205-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="RDv/P/6p"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116205-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116205-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E50EE1C35380 for ; Mon, 25 Mar 2024 11:46:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9C787285299; Mon, 25 Mar 2024 03:33:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RDv/P/6p" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD5455C8EC; Sun, 24 Mar 2024 23:43:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323815; cv=none; b=WYlt9WmCVuthVCl8b51DUBLC7RJVi2Dx7fm5t9SAV9TULDb6rrj1ZcAKTUt2PTR4f/ajatkSs+fdDgHQzEu4lKFFOmRzoWaGUBhwPhHsJ9bAmjS/yvy6HqpVtDBDFC9vboQ5gfIt2mwjF1fftA/LPEFIacDNx10YX9YKKhz7Hp8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323815; c=relaxed/simple; bh=lWPRf6moaMYWz9EKtqw8AWmfhvGPBVr8HEaPz5qWn1s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZZE9nudWYpaYaEUOCx9j5prnR+7oMOuPlNn9W96+j/W+od2EHu4E7/+nV/l0Rn+trcpJvn/Wh5A83G6VLqvjx3pcYOI8V0O0G1cWTcUt+knQz1NVuYUvS3ReFKid4cUvvQUzvFApjP3XlvGrs/OvNiXfDH2kYgU/VReCRilaMRo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RDv/P/6p; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2AD1C433A6; Sun, 24 Mar 2024 23:43:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711323815; bh=lWPRf6moaMYWz9EKtqw8AWmfhvGPBVr8HEaPz5qWn1s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RDv/P/6prcxRUx+On7caPpCexDyJm63gcd+38FeIr1P26tFUUp2R7n6WOLyyRJFeN bmsmh9GtYB/wZVVhh4XqD4rYLuAoS6cJE7Bj/x6nEVezc4gfOB8I+YtYoKGR0Li+Xx otBjOMEK7GkOcpoYpzBg7kieYCD04TqZjryJcAo4SEM12Aifp4EIRVUF5xJ6peumDn uHy1cy3IeaL85Fyfi60t+VwGSQM6GeQgADkuCcmKWLW5u7Q6Lrv29nNDmS9qbrjeEh OQHz8+LFF0751b4EUBSJt17KHB3cz1zWWYKOrAO9+cFJz2U3Abcly4hC/Ygd+RanqF qvKUcDMVgzbpg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sheng Yong , Chao Yu , Jaegeuk Kim , Sasha Levin Subject: [PATCH 5.10 194/238] f2fs: compress: fix to check unreleased compressed cluster Date: Sun, 24 Mar 2024 19:39:42 -0400 Message-ID: <20240324234027.1354210-195-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324234027.1354210-1-sashal@kernel.org> References: <20240324234027.1354210-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Sheng Yong [ Upstream commit eb8fbaa53374e0a2d4381190abfe708481517bbb ] Compressed cluster may not be released due to we can fail in release_compress_blocks(), fix to handle reserved compressed cluster correctly in reserve_compress_blocks(). Fixes: 4c8ff7095bef ("f2fs: support data compression") Signed-off-by: Sheng Yong Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/file.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 55818bd510fb0..40e805014f719 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -3663,7 +3663,13 @@ static int reserve_compress_blocks(struct dnode_of_data *dn, pgoff_t count) goto next; } - if (__is_valid_data_blkaddr(blkaddr)) { + /* + * compressed cluster was not released due to it + * fails in release_compress_blocks(), so NEW_ADDR + * is a possible case. + */ + if (blkaddr == NEW_ADDR || + __is_valid_data_blkaddr(blkaddr)) { compr_blocks++; continue; } @@ -3673,6 +3679,11 @@ static int reserve_compress_blocks(struct dnode_of_data *dn, pgoff_t count) } reserved = cluster_size - compr_blocks; + + /* for the case all blocks in cluster were reserved */ + if (reserved == 1) + goto next; + ret = inc_valid_block_count(sbi, dn->inode, &reserved); if (ret) return ret; -- 2.43.0