Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp2115747lqe; Tue, 9 Apr 2024 09:55:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV9aRjc5N/qujfDr1FVzUMKZblNau0+V0JxgeM/n4Xg0lX1dR9OdjGJhA45BVch1xqnF4LLqb/m+StGDyFkKVmA9bJaySYcaMIApusf2A== X-Google-Smtp-Source: AGHT+IEFJpS6CX9XOfWBDiCL9O7zMufHSVs2u88I1i7vvx7BAcw8JyiguA55PVyEe/3lS+un6Zy0 X-Received: by 2002:a05:6871:208:b0:220:a138:f59f with SMTP id t8-20020a056871020800b00220a138f59fmr192314oad.31.1712681703615; Tue, 09 Apr 2024 09:55:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712681703; cv=pass; d=google.com; s=arc-20160816; b=YNLykVhLaBs+2dqC9UnB1MWk67+i4YDKgGljyiq34RRW/8H+wKINNMVgAwRN4Zw7Rr cxNhXt4HpqhAyTMVfkMp4ko1EoAAALbzo1jJ2Ao4Zb8VxMgu3mmL2/+cUii7tPW/Ulxc pW7+nd1GQsLA4C98M0R0/TsFUBcF9xAIZ9uy7u7VPEpnKNyexMuhpFqvRSQtempY18Og WiJRSzsPf6iDV9eDh0kRrKPL8INnQ2Bd/imrxHyaiSR59Sj9LfydsuCNNVeJ+h+puIXB fpJly2A4KOMU84s18zu4CWqJzf6OILCUuInjscooUQnnSxbcAmaJI2D6XQte+LHH13Zt Ujvg== 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=sj947wh/8AagoE/UzZUwNebBgRd8VQAvBFHc1LfpTVw=; fh=ycytaAEdXxFrYxPqjfAthX4YhMAesuQ92EKIm3EEYjo=; b=gFxBIEaVA/8Tpgs8VPE9tXgrK479gGxD3FQ7OhUYI1cwRPoL38a5NHhADpEOMQH+yR 0q8ro1x7sujyErCVb69Uz/WqOgIwv42neSvWaeJo26bLP/RVpvT+PpXAAb6riO15/uyw 651zIHhY1j5syIri1mGWdCGIJM3T3Oqv0zkGz/NyJNJcF2w07loURWj0w78fa1weUIal CIohwlZ6Tu3d+5Hwl27YC69G7ozInxvpHDd6w309wo91uHUqOLWu5vdHTaPLAazj/Y0X pVgo3Z/NmT4rOGzx687n7vUTtiU+F13NwvzweL57paPcDpAEkuV9kdRz+v0X+tfFIznJ vkVw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tNtj7sO3; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-137309-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137309-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 20-20020a631354000000b005d4af343858si8791876pgt.361.2024.04.09.09.55.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 09:55:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137309-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=tNtj7sO3; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-137309-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137309-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 8B952B2ADBA for ; Tue, 9 Apr 2024 16:20:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 20AB213DDDF; Tue, 9 Apr 2024 16:20:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tNtj7sO3" 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 4AF0F13DDD4 for ; Tue, 9 Apr 2024 16:20:21 +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=1712679621; cv=none; b=P6c6kGeaDKFk/aAywLYJmLssXp8dBiAkP1ZR0rmChp7pOHfebzpA+4RFKy5v12ABO7xEFZzkt5CO01NCu0b0Ppb4yJDeAg8Q8sfPdNi7E4GdnnFCaEHMaUCG+zpmTV8CmoteK0oUKnqe/5sCJ0m9RbzvVq6Qhnm2VmIH7aepybM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712679621; c=relaxed/simple; bh=vA77VMKw+Zk+qUpi/Fg+f2xXCoVaVTSiTo5V6KCtvCI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ESTZJa9xRTw4mTz9LGkNaYsVu3yi+gkH4jCWe4ARr0irT5BRaHVkq/dDSIMfisjkVGFx7lWvYXfkdJiYIQCfYlpGZSR8skVmkSRMZKI4pbuoMuGtUmJhHW8SDl6SF5KtXiUwX7qYySVlWXFdsT5+L4H7cwDlzIogTx7iy3QSkNM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tNtj7sO3; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6BB1C433C7; Tue, 9 Apr 2024 16:20:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712679620; bh=vA77VMKw+Zk+qUpi/Fg+f2xXCoVaVTSiTo5V6KCtvCI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tNtj7sO3rQIpfn7QUaprFA1g3UWIIxL0NL6ByQZMXWZrTUHPiQrGqkuVWnQDAnd7t AyDZ04EA6A1ZmCCaYCfE76Pkhqy9RfgMX220ZsVPAa4YJD3TBF9yymnDmW+RQ2Q3i6 nYdlHaTTgxeSXkKZg+xuba5X83crSBpnmozVuLHS87OLewcnKDakM1Gj3gI6goYQWh M//PFgqny4MeN70sgzKnS5yp1fakYvyjMqeqtvCascOLmOXXWYSCVoeEAjQkPa4peA Jk0QL8uJXuRI5rNenaJOHcz1F9jaBqBhzVGTL2J/5iq+97uNsvrV+nyFeyf/xb3vsn sJPJWGARlCw4w== Date: Tue, 9 Apr 2024 16:20:19 +0000 From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Light Hsieh =?utf-8?B?KOisneaYjueHiCk=?= Subject: Re: [PATCH v2] f2fs: don't set RO when shutting down f2fs Message-ID: References: <20240404195254.556896-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-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240404195254.556896-1-jaegeuk@kernel.org> 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 --- Change log from v1: - use better variable - fix typo fs/f2fs/super.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 8ac4734c2df6..df32573d1f62 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -4159,9 +4159,15 @@ 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) || shutdown) { + f2fs_warn(sbi, "Stopped filesystem due to reason: %d", reason); return; + } f2fs_warn(sbi, "Remounting filesystem read-only"); /* -- 2.44.0.478.gd926399ef9-goog