Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp169606lqp; Fri, 12 Apr 2024 14:00:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXex/tU2CrNb7w/XFFjPMxN+HgqRs/tR2w4nF0+F0vCvR/epWsfmKuOCc1NbuaHiwAXZ32aYO3NBdcp/KumMoQwKE+POB9vCosKxE+HBA== X-Google-Smtp-Source: AGHT+IFD84zfJQf4vYnajoTXQnFjC912yD1bvUI8Hu/kmKHfMfItX2OLwFLNzbUt1jnQeOxqqkZv X-Received: by 2002:a05:6a00:3d42:b0:6ea:afd2:b1dc with SMTP id lp2-20020a056a003d4200b006eaafd2b1dcmr4023823pfb.29.1712955631747; Fri, 12 Apr 2024 14:00:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712955631; cv=pass; d=google.com; s=arc-20160816; b=ig7sYz+TIS6uOgnK9gcggF46hQYa4gL9F5qdQk7zVqjoCmKxmFoW2o69ZFZLlhOJYD PNN2L7DTlcWeN7iHUmRAPEE5ZU6Ngl8F9DRZb8RvZhPvYawNm2D93gkufluXdI2TAiZV FRCx+MEwsgdR5vB7Hh/8f62PsTtfB2BIaqvbE46eSfY3XQ3dQvqIXwghIgIC+/gAICJs QhKwZOhXO3XsECHbJZZb3+Mviih2d7WiAURmhMzi4fi/clrvgjkRQ4CmgCIimLhaejQd KVxJotva9pp5QK5fEcP708mjDkZO18NibaSMFFvfMJKpVu/gvFJR8kM1TGenpOIXkaif TGWw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=YA2VHO3OyJZ4AyIoAfy2Q+30GZdKI2KAwzI622XwfJY=; fh=KuS+1UlV5gqHbJ37XPD8MCZ1v8KBm0nhjTGQI/haxiI=; b=dbzc3QsWdYfma/W3L9iirMn1FMASF2PAgQFk9BcNbROrmsDAn/0QHkPRhavkROXimb /F/VX1uDdTXqZKOTtc+KULwJWk1MMpvg18nI1cJM/rOGWcfUkstpu/qRe5cs26a04d7H uqsXk7skKNC14vFza/Lp7xgIaB6jfPTOD8GhCX8eWo8LdLFDx8FVhjz3hKQyx7YktgcE aBMNYmUkZTeJGHn0DKgNnQ7SCoLMIo8+TUyeNPaSM7O91Q+BkEclcPtQdHRD9X1UdEz9 BMolPtJt+63I/jVUFfYxV55LvnIyHks8ST317zdl0PboTZxY2m0QHJzpoBeDAGkMO4eV 9Osw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MW+cMZoo; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-143338-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143338-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 129-20020a630087000000b005d795f96f31si3751514pga.152.2024.04.12.14.00.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 14:00:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-143338-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MW+cMZoo; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-143338-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143338-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 2CE33B23951 for ; Fri, 12 Apr 2024 20:57:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 08B494CB35; Fri, 12 Apr 2024 20:57:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MW+cMZoo" 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 3522C39FD5 for ; Fri, 12 Apr 2024 20:57:26 +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=1712955447; cv=none; b=qnDhenMb3NoAsndyf6Ov9YGt38XrMQ+/A5X2MQ0ub3zaIXHDB/m92ATUYP/j2nHiD8pO1kAKiFaLwq87XV+klInNFRAotOCHwhytPcLpwzKsg8w0muKtSWF+SnR9Xx5MIlGuwrdrJ8YHuoMsDCG7+NIKoLgX3uJX3pImQ4Nlyt0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712955447; c=relaxed/simple; bh=N557OwkcMRzWWTkVtHcBibqTIxbQIgFLHLWudntz+/s=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=kFjoeqVDCZSqHklzdwDfD/hLZT4sXW+ni6RVaBim7DQ/mbd2hbU3qPlfVAUfvbq6DWoslAeKWN4Cgp5JuWSnvscTxdRXr95zmk79dhcR1m0MdsJkTRmP/qCpAtrng48EA8LNX/AosUlFcguGBgVXL3lm+2p2B3Xq6zhyIAw/iaM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MW+cMZoo; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E5E5C113CC; Fri, 12 Apr 2024 20:57:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712955446; bh=N557OwkcMRzWWTkVtHcBibqTIxbQIgFLHLWudntz+/s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MW+cMZoosDJKSB2cOLCkq7MkRggIbRTBeKR3ycmPur4UnWRKeCgOVtYKbKZ/bfvB5 XfIztRiqlQKc4zg5EITFk+mkch5AHSIL7EJhqRwcKvgrwgPoKHFNgQ7hDk4dCttDOz 3vaJr22oHJHxZvYMsSw5YSdEE/KilhCMRuB8ZRIPWr5Pw1njLmhsODQWPmGHf+H1Ti debFilfMRLdVoNLcAj3KVYNuWRVEV8PSqvvUmHrOUQdA6kD31c8rEK9OzOzBKiOGI1 iOYSWQpXmUXbxK+NrHyKEckrN7g9oBZ+3oA/eMr5rRpxHRsP9zTl+AUPNXQxbV0qzO r+nrs1TRE9uWQ== Date: Fri, 12 Apr 2024 20:57:24 +0000 From: Jaegeuk Kim To: Chao Yu Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: Re: [f2fs-dev] [PATCH 2/3] f2fs: clear writeback when compression failed Message-ID: References: <20240409203411.1885121-1-jaegeuk@kernel.org> <20240409203411.1885121-2-jaegeuk@kernel.org> <59414941-a15f-4eb0-8574-3b2a27d8ae69@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <59414941-a15f-4eb0-8574-3b2a27d8ae69@kernel.org> On 04/11, Chao Yu wrote: > On 2024/4/10 4:34, Jaegeuk Kim wrote: > > 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; > > *submitted = 0; ? And, it seems this is not enough to address kernel hang on wait_on_writeback while running fsstress + shutdown test. Stay tuned. > > Thanks, > > > + 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: