linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Subject: [PATCH 4/5] f2fs: should fail mount when trying to recover data on read-only dev
Date: Tue, 27 Jan 2015 15:31:42 -0800	[thread overview]
Message-ID: <1422401503-4769-4-git-send-email-jaegeuk@kernel.org> (raw)
In-Reply-To: <1422401503-4769-1-git-send-email-jaegeuk@kernel.org>

If device is read-only, we should not proceed data recovery.
But, if the previous checkpoint was done by normal clean shutdown, it's safe to
proceed the recovery, since there will be no data to be recovered.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/super.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 0ca1fb2..7039969 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1149,6 +1149,15 @@ try_onemore:
 
 	/* recover fsynced data */
 	if (!test_opt(sbi, DISABLE_ROLL_FORWARD)) {
+		/*
+		 * mount should be failed, when device has readonly mode, and
+		 * previous checkpoint was not done by clean system shutdown.
+		 */
+		if (bdev_read_only(sb->s_bdev) &&
+				!is_set_ckpt_flags(sbi->ckpt, CP_UMOUNT_FLAG)) {
+			err = -EROFS;
+			goto free_kobj;
+		}
 		err = recover_fsync_data(sbi);
 		if (err) {
 			f2fs_msg(sb, KERN_ERR,
-- 
2.1.1


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/

  parent reply	other threads:[~2015-01-27 23:31 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-27 23:31 [PATCH 1/5] f2fs: fix not to drop mount options when retrying fill_super Jaegeuk Kim
2015-01-27 23:31 ` [PATCH 2/5] f2fs: support norecovery mount option Jaegeuk Kim
2015-01-29 11:52   ` Chao Yu
2015-01-29 18:27     ` Jaegeuk Kim
2015-01-29 18:31       ` [f2fs-dev] [PATCH 2/5 v2] " Jaegeuk Kim
2015-01-30  5:11         ` Chao Yu
2015-01-30  5:10       ` [PATCH 2/5] " Chao Yu
2015-01-27 23:31 ` [PATCH 3/5] f2fs: avoid write_checkpoint if f2fs is mounted readonly Jaegeuk Kim
2015-01-29 11:55   ` Chao Yu
2015-01-27 23:31 ` Jaegeuk Kim [this message]
2015-01-29 12:16   ` [PATCH 4/5] f2fs: should fail mount when trying to recover data on read-only dev Chao Yu
2015-01-29 21:39     ` Jaegeuk Kim
2015-01-30  5:12       ` Chao Yu
2015-01-30  5:15   ` Chao Yu
2015-01-27 23:31 ` [PATCH 5/5] f2fs: introduce a batched trim Jaegeuk Kim
2015-01-29 12:38   ` Chao Yu
2015-01-29 21:41     ` Jaegeuk Kim
2015-01-30  5:13       ` Chao Yu
2015-02-02 23:29         ` [PATCH 5/5 v2] " Jaegeuk Kim
2015-02-03  2:48           ` [f2fs-dev] " Changman Lee
2015-02-03 20:10             ` [f2fs-dev] [PATCH 5/5 v3] " Jaegeuk Kim
2015-02-05  9:30               ` Chao Yu
2015-02-06  6:18                 ` [f2fs-dev] [PATCH 5/5 v4] " Jaegeuk Kim
2015-02-06  8:20                   ` Chao Yu
2015-02-07 15:57                   ` Leon Romanovsky
2015-02-09  7:04                     ` Jaegeuk Kim
2015-01-29 11:24 ` [PATCH 1/5] f2fs: fix not to drop mount options when retrying fill_super Chao Yu
2015-01-29 18:21   ` [PATCH 1/5 v2] " Jaegeuk Kim
2015-01-30  5:02     ` Chao Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1422401503-4769-4-git-send-email-jaegeuk@kernel.org \
    --to=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).