Received: by 2002:ab2:687:0:b0:1f4:6588:b3a7 with SMTP id s7csp34653lqe; Tue, 9 Apr 2024 13:34:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWOArtvaHJ2LEIxxQ4VGls5oB+M7qgH3jt9e03n8D0uPdrMUGHjhWsL9mNumEUPyH3FunRQatyBC5ajqCxBDtakROWfQvyXRU6BhQUUHg== X-Google-Smtp-Source: AGHT+IEGrh+nAnsFRJi3sC4uXom2Dbq95Q64teiSdnY/8isdhWWRf1eqrV8PmAuyR4lcMIUigKyt X-Received: by 2002:a05:6870:b40c:b0:22e:a12c:ab4c with SMTP id x12-20020a056870b40c00b0022ea12cab4cmr711955oap.57.1712694886345; Tue, 09 Apr 2024 13:34:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712694886; cv=pass; d=google.com; s=arc-20160816; b=WHs+X7KAJKgG1CdnaYPFty2CyxbE9qmBeGBWedT7wCF43fv1yroLC0VudTSnE5eTx2 exCJjrSK+E90VtNrRCvXzD3utLnduA7vAn/KGyMzkkEsPnDB0ZNhSQKiRSs9KEkqk3UL +LCrfr5PIjEEFQ+bZFtVZvXEOEfWZVur1l1RGfYvyehz/RwavHm+35QEnMR7gsRgJhoN bw2EucblgXEgbsdLBaw/LrbmLvEKzuGBPIq4Mcj2LcSxM8zksNOpvtyxQ5INvPuee5Y2 qZtB3w3xHhC9XrlwqyR/WfFXqnptawcPpEV2MLiUvBmNIMDx/z7UvcgyAoLXm93spexZ uxmQ== 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=DViuD9q47sgWqUNVbmW7SyxVjvs0LravwJ40SFdxKG4=; fh=rqHW7NazYv3wAmgqDKAbZUXWTmf0VaM5epB9R4zfTUE=; b=Jkxmlc8Nm7ukYPypfJFVzV1CBMCHEctnxJWJkOPSc8vRytgG2cSJ7n4poxkONb0gwF uJ11IlW6QouQ1AYXIFur6R+VAu0QC6uTKdCwuCKsFBFQUtAs2tZy88iWUUVzRdUe9W3h /8hVR0LZ+IOAYueeHwf3XVfSNLp+Y/aJqS/S6nM+LE7e0EVbaTRTOoQQ7FHxSRcnghNb 5GYoIi+Sdxxp6/cmzUvxXqeiPv+bg73NOKi/Ud3smsAiwtc4AZU9ACiJ+criAFBXfyxH SHJpIKE8Gctlkg4HBdgKtkaoGEcOdT+6l1YqNCnG/JH+ox92ApQDwgfDl17obpm2HTig skjQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qYS5yUbp; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-137600-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137600-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n27-20020a634d5b000000b005db38f35248si9186997pgl.395.2024.04.09.13.34.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 13:34:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137600-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qYS5yUbp; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-137600-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137600-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 3417828464D for ; Tue, 9 Apr 2024 20:34:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DEC3B1586E7; Tue, 9 Apr 2024 20:34:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qYS5yUbp" 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 10E331586D2 for ; Tue, 9 Apr 2024 20:34:16 +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=1712694857; cv=none; b=AwCJCXIMXwaJdoRBobOfWcsox40Q61S0T8HHElNy1NmMrdA2AcI5M73sEj8NCFzIbGrDcX6JEpFy1SdC7WUgTehlF/wN7GQSKn7RlzDkfI8Fe4TV51syFxqYys4b+cDJfL/IP/1VWvUdYWSPKjIvykW+7YHWVBcELp72FXblbyk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712694857; c=relaxed/simple; bh=yuHHraFJs2uSx9hQ7hdbnjpoe1/DllEgPkr59YJ8+BU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GCmerm1a5dNKkwjppy3HjetQIRkvnhPSl7DJ62jvf5gph3Kc/85hFexvQaaNueagxJ80LSAXTlMa1obSkVTqwwKzrAjuRnFeO3oKuoUUfzYOV8OnPn5yf/bgy6qTEDn5Fs1heW9jEUDoyWGKK7GzCMaE7QMmuJQCB7h0P1e2NSI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qYS5yUbp; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A76CC433F1; Tue, 9 Apr 2024 20:34:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712694856; bh=yuHHraFJs2uSx9hQ7hdbnjpoe1/DllEgPkr59YJ8+BU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qYS5yUbp2j2MUkMS/chiuO59dZHMJNSE+6fhRmIqgrmpMsWsXPq11EPlEQFcnkp99 HnWtx8P31Ejg/zj46124biFba+Pz96KQDjmJKVU+nC6XcSZQgQBrrOUWr6bTKqcOpt 4DY6avaWW08lHV6cty4FKMK6+zo/lsMlbAqXZ2QUptl3W5G26MOWu3+z2vGtX2oXDs 4Id09by82cRuUMnEwQIiKdAKmEs7Wbybyr9PlYxfKOX5+66+MMC2k6H+jG2kqlTWlM f9eIVPMnKbWIBXfIGJ1Eg7iK8YGSTc0vbg1Dk3wDgGQL3U2XskeK37fh4nEmZ5AnTu exkNMIRLiJeUg== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Jaegeuk Kim Subject: [PATCH 2/3] f2fs: clear writeback when compression failed Date: Tue, 9 Apr 2024 20:34:10 +0000 Message-ID: <20240409203411.1885121-2-jaegeuk@kernel.org> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog In-Reply-To: <20240409203411.1885121-1-jaegeuk@kernel.org> References: <20240409203411.1885121-1-jaegeuk@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Let's stop issuing compressed writes and clear their writeback flags. Signed-off-by: Jaegeuk Kim --- fs/f2fs/compress.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c index d67c471ab5df..3a8ecc6aee84 100644 --- a/fs/f2fs/compress.c +++ b/fs/f2fs/compress.c @@ -1031,6 +1031,25 @@ static void set_cluster_writeback(struct compress_ctx *cc) } } +static void cancel_cluster_writeback(struct compress_ctx *cc, int submitted) +{ + int i; + + for (i = 0; i < cc->cluster_size; i++) { + if (!cc->rpages[i]) + continue; + if (i < submitted) { + if (i) + f2fs_wait_on_page_writeback(cc->rpages[i], + DATA, true, true); + inode_inc_dirty_pages(cc->inode); + lock_page(cc->rpages[i]); + } + clear_page_private_gcing(cc->rpages[i]); + end_page_writeback(cc->rpages[i]); + } +} + static void set_cluster_dirty(struct compress_ctx *cc) { int i; @@ -1232,7 +1251,6 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc, .page = NULL, .encrypted_page = NULL, .compressed_page = NULL, - .submitted = 0, .io_type = io_type, .io_wbc = wbc, .encrypted = fscrypt_inode_uses_fs_layer_crypto(cc->inode) ? @@ -1358,7 +1376,15 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc, fio.compressed_page = cc->cpages[i - 1]; cc->cpages[i - 1] = NULL; + fio.submitted = 0; f2fs_outplace_write_data(&dn, &fio); + if (unlikely(!fio.submitted)) { + cancel_cluster_writeback(cc, i); + + /* To call fscrypt_finalize_bounce_page */ + i = cc->valid_nr_cpages; + goto out_destroy_crypt; + } (*submitted)++; unlock_continue: inode_dec_dirty_pages(cc->inode); @@ -1392,8 +1418,11 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc, out_destroy_crypt: page_array_free(cc->inode, cic->rpages, cc->cluster_size); - for (--i; i >= 0; i--) + for (--i; i >= 0; i--) { + if (!cc->cpages[i]) + continue; fscrypt_finalize_bounce_page(&cc->cpages[i]); + } out_put_cic: kmem_cache_free(cic_entry_slab, cic); out_put_dnode: -- 2.44.0.478.gd926399ef9-goog