Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp51607pxf; Tue, 30 Mar 2021 19:01:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXxvBzl5HPKB20lBauuHupsVyGf1mT6N6e65g6AndHMH5+gT6HeSAyVQmK4k6sFv4XIsES X-Received: by 2002:a05:6402:34c8:: with SMTP id w8mr844247edc.235.1617156105965; Tue, 30 Mar 2021 19:01:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617156105; cv=none; d=google.com; s=arc-20160816; b=kFFQvzdS9NdIkLZwX3SO+G3fXuh3qtUfSINvERNWzJPBhDGH4c+8SHWJ5cq173DL7d 37sPgtPdH3h6w/NbzkbzSCdz+TL7v9IXQXniINeoIrFPzCW9oPTqLdfdDbaQE0htHzd/ o+OpOqiKVKWl2/aoK/ErCnkKAlV8rjS60jYIXpfHEIGPQvz7KFoQMxg6kehVHqyc75qn fLPxQTMZoKTXsGafa08vFvOtJ3+Wrzl/hFmj5ts1x2Az7JKo5prvjE9g+iVYWt+BpEH/ chDJLk7jG98JmAAHSPpqHgc3pBLie7WK6eC2ydmRovRN9ouGOIys5RwPLHo88FKICJdQ KevQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5YfCydSS5GAHJLQmddLvMt1Yn/MzSsuxECm0rigLPk8=; b=kx7jDnzUcNiua+K34v/6YBm3lOXaZwlvjvwB0pYt7A/wYZ1WR9jCzN+93UocdAD9Ti M+Tt8NiNWtPTCP0ypvXDe8wTp0VbPf8FdELJjhc0QoVAvdoE3SdMKJhVfkCHpw27vHMN y1nRqXXKt91DS8kF2RPLIEeCySKDRjN2sWPfKXus1ZZsN40Z8jaRL2ylywGRXss5RaTl dHwIKuWfTpEcS1O4mO9lyZMoz1f4/30kzTm7yWfqrD2uH8dHKY3xnmmFW0isUsB499mo /sKhchzai4r+LwiCC0B8MznxlHL8qay8HPseD97mLw3SdUJOWvGF/kDfcT1vvWwW6PBS lQtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jOX7tJyu; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a7si649596edb.607.2021.03.30.19.00.55; Tue, 30 Mar 2021 19:01:45 -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=@kernel.org header.s=k20201202 header.b=jOX7tJyu; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232956AbhCaB6b (ORCPT + 99 others); Tue, 30 Mar 2021 21:58:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:52590 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230145AbhCaB54 (ORCPT ); Tue, 30 Mar 2021 21:57:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DF1D2619B1; Wed, 31 Mar 2021 01:57:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617155876; bh=w65uvHVY+51Wt+ySuWN/EFojpBAJPntcBukMYf783d0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jOX7tJyuD97xAvcSdXtFiV8VZNVDWlfo3jX0RHeCGGT+VVgdYpOMev3tqml/eF0uf RD7cRJ0t8lcVL5Sl2TlqUQVVKkMGXgK+yqt/iCvSvIPdrB6pQ46X1PhOifTT5OTTm8 42vp7Vh7Nznniut02LA4XylPuLDrrpUC4FASscF5Jl/OM7srQO/htXNSpq6GVOLa2J zgxilLZkpko0inT3zmAR5YuUvPJadzh4P7cJJnPVeHiOJuuOUgVmIf4DGROK8dfTRC utzGjaNlFmgLzoz1rC9jTNawnvbPIysmCv4toeThygthEcqmdSpZhNOv2kjkfRGRGB MkUtYHVDCWFuA== Date: Tue, 30 Mar 2021 18:57:54 -0700 From: Jaegeuk Kim To: Chao Yu Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: Re: [f2fs-dev] [PATCH] Revert "f2fs: give a warning only for readonly partition" Message-ID: References: <8b0b0782-a667-9edc-5ee9-98ac9f67b7b7@huawei.com> <84688aac-75da-1226-df4d-47ac97087c51@huawei.com> <4b64099b-064d-43a8-461d-b54007f2c16c@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/27, Chao Yu wrote: > On 2021/3/27 9:52, Chao Yu wrote: > > On 2021/3/27 1:30, Jaegeuk Kim wrote: > > > On 03/26, Chao Yu wrote: > > > > On 2021/3/26 9:19, Jaegeuk Kim wrote: > > > > > On 03/26, Chao Yu wrote: > > > > > > On 2021/3/25 9:59, Chao Yu wrote: > > > > > > > On 2021/3/25 6:44, Jaegeuk Kim wrote: > > > > > > > > On 03/24, Chao Yu wrote: > > > > > > > > > On 2021/3/24 12:22, Jaegeuk Kim wrote: > > > > > > > > > > On 03/24, Chao Yu wrote: > > > > > > > > > > > On 2021/3/24 2:39, Jaegeuk Kim wrote: > > > > > > > > > > > > On 03/23, Chao Yu wrote: > > > > > > > > > > > > > This reverts commit 938a184265d75ea474f1c6fe1da96a5196163789. > > > > > > > > > > > > > > > > > > > > > > > > > > Because that commit fails generic/050 testcase which expect failure > > > > > > > > > > > > > during mount a recoverable readonly partition. > > > > > > > > > > > > > > > > > > > > > > > > I think we need to change generic/050, since f2fs can recover this partition, > > > > > > > > > > > > > > > > > > > > > > Well, not sure we can change that testcase, since it restricts all generic > > > > > > > > > > > filesystems behavior. At least, ext4's behavior makes sense to me: > > > > > > > > > > > > > > > > > > > > > > journal_dev_ro = bdev_read_only(journal->j_dev); > > > > > > > > > > > really_read_only = bdev_read_only(sb->s_bdev) | journal_dev_ro; > > > > > > > > > > > > > > > > > > > > > > if (journal_dev_ro && !sb_rdonly(sb)) { > > > > > > > > > > > ext4_msg(sb, KERN_ERR, > > > > > > > > > > > "journal device read-only, try mounting with '-o ro'"); > > > > > > > > > > > err = -EROFS; > > > > > > > > > > > goto err_out; > > > > > > > > > > > } > > > > > > > > > > > > > > > > > > > > > > if (ext4_has_feature_journal_needs_recovery(sb)) { > > > > > > > > > > > if (sb_rdonly(sb)) { > > > > > > > > > > > ext4_msg(sb, KERN_INFO, "INFO: recovery " > > > > > > > > > > > "required on readonly filesystem"); > > > > > > > > > > > if (really_read_only) { > > > > > > > > > > > ext4_msg(sb, KERN_ERR, "write access " > > > > > > > > > > > "unavailable, cannot proceed " > > > > > > > > > > > "(try mounting with noload)"); > > > > > > > > > > > err = -EROFS; > > > > > > > > > > > goto err_out; > > > > > > > > > > > } > > > > > > > > > > > ext4_msg(sb, KERN_INFO, "write access will " > > > > > > > > > > > "be enabled during recovery"); > > > > > > > > > > > } > > > > > > > > > > > } > > > > > > > > > > > > > > > > > > > > > > > even though using it as readonly. And, valid checkpoint can allow for user to > > > > > > > > > > > > read all the data without problem. > > > > > > > > > > > > > > > > > > > > > > > > if (f2fs_hw_is_readonly(sbi)) { > > > > > > > > > > > > > > > > > > > > > > Since device is readonly now, all write to the device will fail, checkpoint can > > > > > > > > > > > not persist recovered data, after page cache is expired, user can see stale data. > > > > > > > > > > > > > > > > > > > > My point is, after mount with ro, there'll be no data write which preserves the > > > > > > > > > > current status. So, in the next time, we can recover fsync'ed data later, if > > > > > > > > > > user succeeds to mount as rw. Another point is, with the current checkpoint, we > > > > > > > > > > should not have any corrupted metadata. So, why not giving a chance to show what > > > > > > > > > > data remained to user? I think this can be doable only with CoW filesystems. > > > > > > > > > > > > > > > > > > I guess we're talking about the different things... > > > > > > > > > > > > > > > > > > Let me declare two different readonly status: > > > > > > > > > > > > > > > > > > 1. filesystem readonly: file system is mount with ro mount option, and > > > > > > > > > app from userspace can not modify any thing of filesystem, but filesystem > > > > > > > > > itself can modify data on device since device may be writable. > > > > > > > > > > > > > > > > > > 2. device readonly: device is set to readonly status via 'blockdev --setro' > > > > > > > > > command, and then filesystem should never issue any write IO to the device. > > > > > > > > > > > > > > > > > > So, what I mean is, *when device is readonly*, rather than f2fs mountpoint > > > > > > > > > is readonly (f2fs_hw_is_readonly() returns true as below code, instead of > > > > > > > > > f2fs_readonly() returns true), in this condition, we should not issue any > > > > > > > > > write IO to device anyway, because, AFAIK, write IO will fail due to > > > > > > > > > bio_check_ro() check. > > > > > > > > > > > > > > > > In that case, mount(2) will try readonly, no? > > > > > > > > > > > > > > Yes, if device is readonly, mount (2) can not mount/remount device to rw > > > > > > > mountpoint. > > > > > > > > > > > > Any other concern about this patch? > > > > > > > > > > Indeed we're talking about different things. :) > > > > > > > > > > This case is mount(ro) with device(ro) having some data to recover. > > > > > My point is why not giving a chance to mount(ro) to show the current data > > > > > covered by a valid checkpoint. This doesn't change anything in the disk, > > > > Got your idea. > > > > > > > > IMO, it has potential issue in above condition: > > > > > > > > > > > > > > > Since device is readonly now, all write to the device will fail, checkpoint can > > > > > > > > > > > not persist recovered data, after page cache is expired, user can see stale data. > > > > > > > > e.g. > > > > > > > > Recovery writes one inode and then triggers a checkpoint, all writes fail > > > > > > I'm confused. Currently we don't trigger the roll-forward recovery. > > > > Oh, my miss, sorry. :-P > > > > My point is in this condition we can return error and try to notice user to > > mount with disable_roll_forward or norecovery option, then at least user can > > know he should not expect last fsynced data in newly mounted image. > > > > Or we can use f2fs_recover_fsync_data() to check whether there is fsynced data, > > if there is no such data, then let mount() succeed. > > Something like this, maybe: > > --- > fs/f2fs/super.c | 17 +++++++++++++---- > 1 file changed, 13 insertions(+), 4 deletions(-) > > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c > index 954b1fe97d67..5e1a1caf412d 100644 > --- a/fs/f2fs/super.c > +++ b/fs/f2fs/super.c > @@ -3966,10 +3966,19 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) > * 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); Can we do like this? 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; > + if (!err) > + goto reset_checkpoint; > + else if (err < 0) > + goto free_meta; > + err = -EROFS; > + f2fs_err(sbi, "Need to recover fsync data, but " > + "write access unavailable, please try " > + "mount w/ disable_roll_forward or norecovery"); > + goto free_meta; > + } > + f2fs_info(sbi, "write access unavailable, skipping recovery"); > goto reset_checkpoint; > } > > -- > 2.29.2 > > Thanks, > > > > > Thanks, > > > > > > > > > due to device is readonly, once inode cache is reclaimed by vm, user will see > > > > old inode when reloading it, or even see corrupted fs if partial meta inode's > > > > cache is expired. > > > > > > > > Thoughts? > > > > > > > > Thanks, > > > > > > > > > and in the next time, it allows mount(rw|ro) with device(rw) to recover > > > > > the data seamlessly. > > > > > > > > > > > > > > > > > Thanks, > > > > > > > > > > > > > > > > > > > > Thanks, > > > > > > > > > > > > > > > > > > > > > > > # blockdev --setro /dev/vdb > > > > > > > > # mount -t f2fs /dev/vdb /mnt/test/ > > > > > > > > mount: /mnt/test: WARNING: source write-protected, mounted read-only. > > > > > > > > > > > > > > > > > > > > > > > > > > if (f2fs_hw_is_readonly(sbi)) { > > > > > > > > > - if (!is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG)) { > > > > > > > > > - err = -EROFS; > > > > > > > > > + if (!is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG)) > > > > > > > > > f2fs_err(sbi, "Need to recover fsync data, but write access unavailable"); > > > > > > > > > - goto free_meta; > > > > > > > > > - } > > > > > > > > > - f2fs_info(sbi, "write access unavailable, skipping recovery"); > > > > > > > > > + else > > > > > > > > > + f2fs_info(sbi, "write access unavailable, skipping recovery"); > > > > > > > > > goto reset_checkpoint; > > > > > > > > > } > > > > > > > > > > > > > > > > > > For the case of filesystem is readonly and device is writable, it's fine > > > > > > > > > to do recovery in order to let user to see fsynced data. > > > > > > > > > > > > > > > > > > Thanks, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Am I missing something? > > > > > > > > > > > > > > > > > > > > > > Thanks, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Fixes: 938a184265d7 ("f2fs: give a warning only for readonly partition") > > > > > > > > > > > > > Signed-off-by: Chao Yu > > > > > > > > > > > > > --- > > > > > > > > > > > > > fs/f2fs/super.c | 8 +++++--- > > > > > > > > > > > > > 1 file changed, 5 insertions(+), 3 deletions(-) > > > > > > > > > > > > > > > > > > > > > > > > > > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c > > > > > > > > > > > > > index b48281642e98..2b78ee11f093 100644 > > > > > > > > > > > > > --- a/fs/f2fs/super.c > > > > > > > > > > > > > +++ b/fs/f2fs/super.c > > > > > > > > > > > > > @@ -3952,10 +3952,12 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) > > > > > > > > > > > > > * previous checkpoint was not done by clean system shutdown. > > > > > > > > > > > > > */ > > > > > > > > > > > > > if (f2fs_hw_is_readonly(sbi)) { > > > > > > > > > > > > > - if (!is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG)) > > > > > > > > > > > > > + if (!is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG)) { > > > > > > > > > > > > > + err = -EROFS; > > > > > > > > > > > > > f2fs_err(sbi, "Need to recover fsync data, but write access unavailable"); > > > > > > > > > > > > > - else > > > > > > > > > > > > > - f2fs_info(sbi, "write access unavailable, skipping recovery"); > > > > > > > > > > > > > + goto free_meta; > > > > > > > > > > > > > + } > > > > > > > > > > > > > + f2fs_info(sbi, "write access unavailable, skipping recovery"); > > > > > > > > > > > > > goto reset_checkpoint; > > > > > > > > > > > > > } > > > > > > > > > > > > > -- > > > > > > > > > > > > > 2.29.2 > > > > > > > > > > > > . > > > > > > > > > > > > > > > > > > > > > > . > > > > > > > > > > > > > > > > > > . > > > > > > > > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > Linux-f2fs-devel mailing list > > > > > > > Linux-f2fs-devel@lists.sourceforge.net > > > > > > > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel > > > > > > > . > > > > > > > > > > > > . > > > > > > > > . > > > > > > > > > _______________________________________________ > > Linux-f2fs-devel mailing list > > Linux-f2fs-devel@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel > > . > >