All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Chao Yu <chao@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH] f2fs: fix to check readonly condition correctly
Date: Mon, 3 Apr 2023 10:59:02 -0700	[thread overview]
Message-ID: <ZCsT5mRsZJqPXBzz@google.com> (raw)
In-Reply-To: <20230402112825.42486-1-chao@kernel.org>

On 04/02, Chao Yu wrote:
> This patch does below changes:
> 
> - If f2fs enables readonly feature or device is readonly, allow to
> mount readonly mode only
> - Introduce f2fs_dev_is_readonly() to indicate whether image or device
> is readonly
> - remove unnecessary f2fs_hw_is_readonly() in f2fs_write_checkpoint()
> and f2fs_convert_inline_inode()
> - enable FLUSH_MERGE only if f2fs is mounted as rw and image/device
> is writable

What is the problem to solve here?

> 
> Signed-off-by: Chao Yu <chao@kernel.org>
> ---
>  fs/f2fs/checkpoint.c |  2 +-
>  fs/f2fs/f2fs.h       | 10 +++++-----
>  fs/f2fs/inline.c     |  3 +--
>  fs/f2fs/super.c      | 13 +++++++------
>  4 files changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
> index 8e1db5752fff..1eef597ed393 100644
> --- a/fs/f2fs/checkpoint.c
> +++ b/fs/f2fs/checkpoint.c
> @@ -1604,7 +1604,7 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
>  	unsigned long long ckpt_ver;
>  	int err = 0;
>  
> -	if (f2fs_readonly(sbi->sb) || f2fs_hw_is_readonly(sbi))
> +	if (f2fs_readonly(sbi->sb))
>  		return -EROFS;
>  
>  	if (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED))) {
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index 2d4a7ef62537..7de95133478a 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -4446,6 +4446,11 @@ static inline bool f2fs_hw_is_readonly(struct f2fs_sb_info *sbi)
>  	return false;
>  }
>  
> +static inline bool f2fs_dev_is_readonly(struct f2fs_sb_info *sbi)
> +{
> +	return f2fs_sb_has_readonly(sbi) || f2fs_hw_is_readonly(sbi);
> +}
> +
>  static inline bool f2fs_lfs_mode(struct f2fs_sb_info *sbi)
>  {
>  	return F2FS_OPTION(sbi).fs_mode == FS_MODE_LFS;
> @@ -4546,11 +4551,6 @@ static inline void f2fs_handle_page_eio(struct f2fs_sb_info *sbi, pgoff_t ofs,
>  	}
>  }
>  
> -static inline bool f2fs_is_readonly(struct f2fs_sb_info *sbi)
> -{
> -	return f2fs_sb_has_readonly(sbi) || f2fs_readonly(sbi->sb);
> -}
> -
>  #define EFSBADCRC	EBADMSG		/* Bad CRC detected */
>  #define EFSCORRUPTED	EUCLEAN		/* Filesystem is corrupted */
>  
> diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
> index 72269e7efd26..2c36f2dc2317 100644
> --- a/fs/f2fs/inline.c
> +++ b/fs/f2fs/inline.c
> @@ -203,8 +203,7 @@ int f2fs_convert_inline_inode(struct inode *inode)
>  	struct page *ipage, *page;
>  	int err = 0;
>  
> -	if (!f2fs_has_inline_data(inode) ||
> -			f2fs_hw_is_readonly(sbi) || f2fs_readonly(sbi->sb))
> +	if (!f2fs_has_inline_data(inode) || f2fs_readonly(sbi->sb))
>  		return 0;
>  
>  	err = f2fs_dquot_initialize(inode);
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index d016f398fcad..db7649010c12 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -1382,15 +1382,16 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)
>  		return -EINVAL;
>  	}
>  
> -	if (f2fs_is_readonly(sbi) && test_opt(sbi, FLUSH_MERGE)) {
> +	if (f2fs_dev_is_readonly(sbi) && !f2fs_readonly(sbi->sb)) {
> +		f2fs_err(sbi, "Allow to mount readonly mode only");
> +		return -EROFS;
> +	}
> +
> +	if (f2fs_readonly(sbi->sb) && test_opt(sbi, FLUSH_MERGE)) {
>  		f2fs_err(sbi, "FLUSH_MERGE not compatible with readonly mode");
>  		return -EINVAL;
>  	}
>  
> -	if (f2fs_sb_has_readonly(sbi) && !f2fs_readonly(sbi->sb)) {
> -		f2fs_err(sbi, "Allow to mount readonly mode only");
> -		return -EROFS;
> -	}
>  	return 0;
>  }
>  
> @@ -2122,7 +2123,7 @@ static void default_options(struct f2fs_sb_info *sbi)
>  	set_opt(sbi, MERGE_CHECKPOINT);
>  	F2FS_OPTION(sbi).unusable_cap = 0;
>  	sbi->sb->s_flags |= SB_LAZYTIME;
> -	if (!f2fs_is_readonly(sbi))
> +	if (!f2fs_readonly(sbi->sb) && !f2fs_dev_is_readonly(sbi))
>  		set_opt(sbi, FLUSH_MERGE);
>  	if (f2fs_hw_support_discard(sbi) || f2fs_hw_should_discard(sbi))
>  		set_opt(sbi, DISCARD);
> -- 
> 2.36.1


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

  reply	other threads:[~2023-04-03 17:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-02 11:28 [f2fs-dev] [PATCH] f2fs: fix to check readonly condition correctly Chao Yu
2023-04-03 17:59 ` Jaegeuk Kim [this message]
2023-04-04 15:03   ` Chao Yu
2023-04-10  2:19   ` Chao Yu
2023-04-11 15:58     ` Chao Yu
2023-04-11 16:53       ` Jaegeuk Kim

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=ZCsT5mRsZJqPXBzz@google.com \
    --to=jaegeuk@kernel.org \
    --cc=chao@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.