Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp2095983lqe; Tue, 9 Apr 2024 09:22:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVMGwKRiamvU1kQohaHRyYHoV/lGweiYvaoc3q9eqhibZy9MUYwuQRBsicJ3niqbdHMVgVaEBg+LOk/QrN7WBSWZUeLfMhcYQHNNP69aw== X-Google-Smtp-Source: AGHT+IFmWJMAMqVhw1TKLb+PNDSthY2yz7GmrsrxgATnagJBA5rjdBN5Rge6niM9HkQ3aU+89hu+ X-Received: by 2002:a05:6a00:178f:b0:6ec:ebf4:439a with SMTP id s15-20020a056a00178f00b006ecebf4439amr59535pfg.5.1712679726737; Tue, 09 Apr 2024 09:22:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712679726; cv=pass; d=google.com; s=arc-20160816; b=mB+8/nHVI+nlGKAD2q0V1aaiG/wiGpZ9OlO82h/DEN8f02Sh5sI6wK7TmtHaL2Oq8I UXP0mfLuFebUt4rhI2+HskZT7jln5H81u7VIm8dGqkhwA8TJ9SKTtt82+qhCgoTDWG+4 S44gLvhZdxOd1z07azNFrfK1iAejgBZV/LyqcvNYJptlFntZUEXIICoFUr4IWAFHwxjn xqrZepH5pdHYtRe05Z23GYxJj4ql30ulapP1jfyCkm1v2hKZizBEFehQ0qc+HmpHMPJE JzSzdITIWkkln32bKq5jPR3W4RzcwJ1IIMzDSqKrgmoTgijWv6UbOHwYxb9NjCBFghjN UUPw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=xxRl0SlTWno/yLh+y785Q+lwhh+ELRLLFCZYcUARExY=; fh=88ordQM3YAVuEm+nnf51kDjZTPogHdIrcFjp7hp5DQs=; b=bnQix9XEVFmPG+ti1hz8+teE9O0lhKt45iJtBfmaOUgq7ZsrQX0vZkHbk7ZVquYroJ IFURh7oiG+drAqHeP63T8aLMBzeSqTCliTVohv5CENSHCV74Hnjq2OdZcnu5jZBDOAc5 sXpjKpnHsyNWqBj+yHlbqcyIhWCRi5ocBhsHfManfULsga4xKFDhhnX41zEN+BmfrGMg cGrIDw5e1836qDmMQ1b/2lOwNFS12HCJSsXn+9nOVJ8Zpfv5iISyIIYRxrVIyRTT+J0X IAMCoCMV876687i7GhHDwKYZB4TGz5vUBLsIk3UoovLZYMuY0my0dPNaDl0GyYmlWhLl mbrw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="bx/6Um3G"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-137310-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137310-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. [139.178.88.99]) by mx.google.com with ESMTPS id s14-20020a63450e000000b005dc12137745si8780949pga.151.2024.04.09.09.22.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 09:22:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137310-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="bx/6Um3G"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-137310-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137310-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 6D10028161F for ; Tue, 9 Apr 2024 16:22:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F2CC213E05E; Tue, 9 Apr 2024 16:22:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bx/6Um3G" 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 2B613137C2A for ; Tue, 9 Apr 2024 16:22:00 +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=1712679721; cv=none; b=sjvPIYty492or4TLT0inupCIeEUynX5eJmcXBe6OEWLrK8K5T921ti46ksb8tGD7A2ks8cjrZYr3HeGbfv1G5Ey5gAITW1Tvug1x5JMJMANgbU1/AgYCFG8kD9SVI11dDREVvOOTegj7ccfsE/JkVEmtC3yQHo15U8TiHz9jgyc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712679721; c=relaxed/simple; bh=j25mVSV7JaOAYPymcWENzF72xWe8UKWzEPPYmINrrTY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KpPKBUj9zMNbr8JUno1ONSW0eCjTiH0GVZb/bVjCYR/srhWWMBqAkVahodmADb/6X1j47kp4puRzcbNge0Fc93RhpoWaS1aX+0CRHRkUZ2scA/9Ynu71QQ5jRGZ5XEMvb83Z/5BHBjkH0R8xUZx4R5jWs0nXZzfG6HnuvxAKdqY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bx/6Um3G; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 850D5C433F1; Tue, 9 Apr 2024 16:22:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712679720; bh=j25mVSV7JaOAYPymcWENzF72xWe8UKWzEPPYmINrrTY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bx/6Um3GCGFEJdmkNmAM/2vbAgjap7/1jyuTvs2ybQfzvNzcP1cbp1FYKlGohexhA jLypVhSW1clknwS0KoF/IoOboJEuL3xKLqvN0XLZuEJQSk8d1p4GRGE73iGBYTD555 l82nSAcpJYVI+QVIlQzGkEE2vXbKHdyLG+LfO1kEdm+LfbQdupLWktkiJsrqzE0VFO sOGIcQeBbP3KaOjpyJ8IQSbBJ5peFVieuXS8FurIOfNkUV8EGm82yqfmwYyiYoz3VT 6WZwEIZlL6+JHqfC7ruGoHVkPA0mus8C/Wa9IQ7iOF84uz7LHmyW0e2JH2n7C/7eNd IiT7mahfgIgLg== Date: Tue, 9 Apr 2024 16:21:58 +0000 From: Jaegeuk Kim To: Chao Yu Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Light Hsieh =?utf-8?B?KOisneaYjueHiCk=?= Subject: Re: [f2fs-dev] [PATCH] f2fs: don't set RO when shutting down f2fs Message-ID: References: <20240404195254.556896-1-jaegeuk@kernel.org> <2c195fee-c71c-4e44-b24f-9880b3c1b6c4@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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2c195fee-c71c-4e44-b24f-9880b3c1b6c4@kernel.org> On 04/09, Chao Yu wrote: > On 2024/4/5 3:52, Jaegeuk Kim wrote: > > Shutdown does not check the error of thaw_super due to readonly, which > > causes a deadlock like below. > > > > f2fs_ioc_shutdown(F2FS_GOING_DOWN_FULLSYNC) issue_discard_thread > > - bdev_freeze > > - freeze_super > > - f2fs_stop_checkpoint() > > - f2fs_handle_critical_error - sb_start_write > > - set RO - waiting > > - bdev_thaw > > - thaw_super_locked > > - return -EINVAL, if sb_rdonly() > > - f2fs_stop_discard_thread > > -> wait for kthread_stop(discard_thread); > > > > Reported-by: "Light Hsieh (謝明燈)" > > Signed-off-by: Jaegeuk Kim > > --- > > fs/f2fs/super.c | 11 +++++++++-- > > 1 file changed, 9 insertions(+), 2 deletions(-) > > > > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c > > index df9765b41dac..ba6288e870c5 100644 > > --- a/fs/f2fs/super.c > > +++ b/fs/f2fs/super.c > > @@ -4135,9 +4135,16 @@ void f2fs_handle_critical_error(struct f2fs_sb_info *sbi, unsigned char reason, > > if (shutdown) > > set_sbi_flag(sbi, SBI_IS_SHUTDOWN); > > - /* continue filesystem operators if errors=continue */ > > - if (continue_fs || f2fs_readonly(sb)) > > + /* > > + * Continue filesystem operators if errors=continue. Should not set > > + * RO by shutdown, since RO bypasses thaw_super which can hang the > > + * system. > > + */ > > + if (continue_fs || f2fs_readonly(sb) || > > + reason == STOP_CP_REASON_SHUTDOWN) { > > + f2fs_warn(sbi, "Stopped filesystem due to readon: %d", reason); > > return; > > Do we need to set RO after bdev_thaw() in f2fs_do_shutdown()? IIRC, shutdown doesn't need to set RO as we stopped the checkpoint. I'm more concerned on any side effect caused by this RO change. > > Thanks, > > > + } > > f2fs_warn(sbi, "Remounting filesystem read-only"); > > /*