From patchwork Thu Apr 4 19:52:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jaegeuk Kim X-Patchwork-Id: 13618190 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D76F0CD1288 for ; Thu, 4 Apr 2024 19:53:20 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rsT9C-0001EW-V6; Thu, 04 Apr 2024 19:53:19 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rsT9A-0001E6-DG for linux-f2fs-devel@lists.sourceforge.net; Thu, 04 Apr 2024 19:53:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:Content-Type:MIME-Version :Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Y91C08Mc6Rlym0gl9NzU95QfKkuIxf+2dktRYRPE2ZE=; b=jLkQiOsoIgkMBmJwWv8Ukpmwlm QDcGtwUKwvYHvFDJt107DkovsdASbXK0TuxZFpzbzCsUx+eWcz33MmcrfUaKoBKjcnFK5IWxwKDni hEhMjf1TpOUxa32VJP3mXDz33Bn2YycV/BQXI8zExRCtXQoWkyqTtFSbnEr5IjMV7soc=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date: Subject:Cc:To:From:Sender:Reply-To:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=Y91C08Mc6Rlym0gl9NzU95QfKkuIxf+2dktRYRPE2ZE=; b=a rYU+ZyPMN7dIXeBqk6It5GYArI+cFn1cKWGM8Lj24Q7xbmrkomqnrqaFA3jkdejRB5EA+h/vGVS6b gmJgCLzk4XjcI5ufr4bsJ0CLOtXPTRLhu2cPLlvD/GAZ4fIa3VXvK9sTY3NKH0gDsA6qj2C8+SE1x kzOTk67JlpxU0nPs=; Received: from sin.source.kernel.org ([145.40.73.55]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1rsT96-0003qa-8a for linux-f2fs-devel@lists.sourceforge.net; Thu, 04 Apr 2024 19:53:17 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 4C65BCE346E; Thu, 4 Apr 2024 19:53:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78796C43390; Thu, 4 Apr 2024 19:52:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712260379; bh=ieg3chWZv+yjKObSx+3pR+vukItMhYCKSo8GVacn5UQ=; h=From:To:Cc:Subject:Date:From; b=sBVqG7gizLXMXmHsu/0hQ7s1fzGrQCPlyq+YBxYYu8hqF/k9B2fd1V8gu39r52jj9 zULIHj0khYLtaVIZc2wjgOuDKJMFbaMpaYTxplMkh215mWwHdnkNA7SXjvqphMdJpP 3/P93Z2MZc8lY+8zNrINgnXr70YuVkPC1jdlYuyyElqdLXCttoUHxJzTdLAKthXU+V +lZsDY/lEgUBGvA+xDzQwWFBfhSwLDoIxRKh37x82QKqRjilOEEPo6Wkwvl16Z+Y2/ cTMuuk6wM2v1r7vb95eiIzypYs+vCyqplg3vkFxBIg612uWn+AOK62qM00lw97j+vE uKJFzRlYpzCVA== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Date: Thu, 4 Apr 2024 19:52:54 +0000 Message-ID: <20240404195254.556896-1-jaegeuk@kernel.org> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog MIME-Version: 1.0 X-Headers-End: 1rsT96-0003qa-8a Subject: [f2fs-dev] [PATCH] f2fs: don't set RO when shutting down f2fs X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jaegeuk Kim , =?utf-8?b?TGlnaHQgSHNpZWggKOisneaYjg==?= =?utf-8?b?54eIKQ==?= Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net 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 Reported-by: "Light Hsieh (謝明燈)" Signed-off-by: Jaegeuk Kim Reviewed-by: Daeho Jeong Reviewed-by: Chao Yu --- 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; + } f2fs_warn(sbi, "Remounting filesystem read-only"); /*