Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3058328pxj; Mon, 17 May 2021 16:41:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDjBm9dm3hnuqSZBJsYu+IkrtvHAbQRNvMrFWEx1p583SLnLvHnrI92qhIK9uv2CrfERTl X-Received: by 2002:a17:907:6289:: with SMTP id nd9mr2628162ejc.384.1621294892325; Mon, 17 May 2021 16:41:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621294892; cv=none; d=google.com; s=arc-20160816; b=GT8drJ6cbrmfLTXacgzUcRo3H8nO4pKO1/aRNWc6e3DeMYrqvggxhrbbJQeXe/5/bO p5XaHY3ZwMMFreeOAvTbnwsCGujCmJ+KGKoGQhJLpPLiOl7+A6rPS4IIwIgTeTgYh2T0 ItoeSo7G2fiumGtvalipQ4KMNbbpYBuYY3YQGVoRV/GLV0aTJqmHKrjrVYRlyv91n9XM RAHAGO0bh7E+RfsbQp+5YgaXttaqTipNzTcNj1iy99/+ZvLYajb69HquJyV8MDBCL19K Ri66ge0oOPPMDIHdvaS/1XTex4532RlTO/E3y7tGWbrA9HHI6zk80ght1/NonmVrYIYI cy5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LleZVl1FLQSfV78i942YENiUmGXUT01uYj0dslsj05w=; b=MZ55N30LNDl+VgzhK5eAFn3RU9J9RQtuUnLtkSWWfEV+aadFSKDbY9uJU3yODzNbqW XZBqzm9rwqAJ722d5AMYQ3IP0CQaIU7YYay6SYNxlZlA43zHGNwkqW9jiDDcBSgphB+I fim5uN+E1OSwo3OCM/0nm9goRV6jNeoM+VuBmI3DQP7wRcv1kQWp2kBZ83LTi1fdnggW QjI0WAN09NotOPQ1hnqqAl3pGXwllCAeSYaC6Tc2+cctqcPmZ1yf4JSV6meniLeW4ICh wrbKEzSz8gZppUm/nqrUl3L4GvlCBMwmXaXzkoeI/OY0F96oJt1SixDRdELywwzMVg/p Ebmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pBER9xt9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d4si119418eja.217.2021.05.17.16.41.07; Mon, 17 May 2021 16:41:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pBER9xt9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237348AbhEQOWp (ORCPT + 99 others); Mon, 17 May 2021 10:22:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:60192 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239201AbhEQOTN (ORCPT ); Mon, 17 May 2021 10:19:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F3EF861436; Mon, 17 May 2021 14:10:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260651; bh=KdfDzzyoqBNGKNTmKypKQG7wiIFEWHT0CY+kW87B8fk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pBER9xt9PNmhqtZJ0f+WylD/6C01wjBh+NHTAlYVqOztIQDcgC66I4OgQEMkwssb7 ScSdPtItmhL7iQQVSE4fSpUY7TwDXFs2GOz2fzKleSMGCmpo5cbXjvcG5iVRGSGGBu PvVyA5KlB9519Raupio76dNs20t8XuoZMT+/UPC8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chao Yu , Jaegeuk Kim , Sasha Levin Subject: [PATCH 5.12 143/363] f2fs: fix to restrict mount condition on readonly block device Date: Mon, 17 May 2021 16:00:09 +0200 Message-Id: <20210517140307.452923563@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chao Yu [ Upstream commit 23738e74472f9c5f3a05a68724a2ccfba97d283d ] When we mount an unclean f2fs image in a readonly block device, let's make mount() succeed only when there is no recoverable data in that image, otherwise after mount(), file fsyned won't be recovered as user expected. Fixes: 938a184265d7 ("f2fs: give a warning only for readonly partition") Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/super.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 1d010a3a144f..d852d96773a3 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -3929,10 +3929,18 @@ try_onemore: * previous checkpoint was not done by clean system shutdown. */ if (f2fs_hw_is_readonly(sbi)) { - if (!is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG)) - f2fs_err(sbi, "Need to recover fsync data, but write access unavailable"); - else - f2fs_info(sbi, "write access unavailable, skipping recovery"); + if (!is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG)) { + err = f2fs_recover_fsync_data(sbi, true); + if (err > 0) { + err = -EROFS; + f2fs_err(sbi, "Need to recover fsync data, but " + "write access unavailable, please try " + "mount w/ disable_roll_forward or norecovery"); + } + if (err < 0) + goto free_meta; + } + f2fs_info(sbi, "write access unavailable, skipping recovery"); goto reset_checkpoint; } -- 2.30.2