Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5492285pxj; Wed, 26 May 2021 11:47:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkbRTduLwD4xz9EigvZtWdoezKZBlLjKopkXgPf2fMCAcUcV9ohT7XxrA1WA/sWjwAgteI X-Received: by 2002:a05:6402:35cc:: with SMTP id z12mr38772259edc.154.1622054871971; Wed, 26 May 2021 11:47:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622054871; cv=none; d=google.com; s=arc-20160816; b=yM/nWkzMns2uUANVf/t6dugcjugsmnnjj43X22snYfO/8lkeIz9lExLWnLJWEbhsGD rF2za8nhxpgHI28RhdNuAiaW1LakQl0CWmlKv9lXQSTd44z2JA6s9/GlW1JmMWyp/Q+G MW4FtK9wnu9GxZf+lVnQH9m4TQUrx0IM6e9Uk6TdYapjpDfn4pb62upjEUPWDUcKaX9g vrHGs4lAzsoffbN6cKvSueLoHMPMwjHAIoK3wbgkinKGlvpQMFUazC/slMZsFoHMk4My grKX3NSzUIfqCRrVf6/lLFKQVrMJxiii0FgPJxtFAq9xIAmJQYU5hrpuMAa+t6D7agLZ /0zw== 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:to:from:date:dkim-signature; bh=rIipovEWWlzOOHBmezkAJ5ezB10OgzhKSGJRdEKT8Is=; b=0VTosFhbNKoplOrbvhTXxH7VwgMu2gV3adgTGdvwU154wpQxefYdhK6kbwJV+o67kN RYiqKjt59oXE/cCMWvZ50Ba/ZOZkiAY6MMDZNyE3u4l++1yEll/ZszvJ1jba+yifr3sp rP+b3wyJUVJEm0hMPobblEM8tymNUFQq9zCARk4Qejg9KymtjMhnSMXeu1IlYTXVmQJQ 12imhr+5a6aiFBMbB6LXEp7KrnS0T29TlGeXVgEhyNn/n7BIXfdxkzFQDulM+4ry6RV0 zq7tol4+SJPdjoVvjV01aMpJrcKVXoyL9XE3j0g7kyYzGPvK0bm9V2AX/zpXIrBnCqOB lPIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QxYx4HS5; 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 c13si110016ede.455.2021.05.26.11.47.27; Wed, 26 May 2021 11:47:51 -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=QxYx4HS5; 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 S233308AbhEZOAy (ORCPT + 99 others); Wed, 26 May 2021 10:00:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:36284 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232939AbhEZOAy (ORCPT ); Wed, 26 May 2021 10:00:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A0FB16101E; Wed, 26 May 2021 13:59:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622037562; bh=E6SxjG86/NK12PE3EmEpctHxJlkfhLvj0WNIo/6ynGY=; h=Date:From:To:Subject:References:In-Reply-To:From; b=QxYx4HS5Ei/ud7cNS7Oj1FrBcKAuA5VdcbL1jR3uXg2hNCA+Syv84tSRBgZgCF3nt P5ZxdFTb47WNVRp76Z2hBBR5ODX28/RUIrsGwjp0k3g48mw2jontfY75lsKIgtNwL+ GiNZGIYKoV5HzgCVeOw2mLR0lsUfqAoJo3k3NUEcIB5rBUoPezNW7XrrBQiEsDPTQf 3pc2GJvUWdMJLi74vIsyKI+NK+YndkD1r2qJKcBjay1IA/eEfUBUt/Qh1M1t8dFHsQ 7OsFnFlmywOFbMGE2nGtw4WYlAkn0RgjzWk2715e6IoSCxqSyhD7I6Mrjzp3SDG+kU EWR28Kpy4FIMw== Date: Wed, 26 May 2021 06:59:21 -0700 From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: Re: [PATCH 2/2 v2] f2fs: support RO feature Message-ID: References: <20210521190217.2484099-1-jaegeuk@kernel.org> <20210521190217.2484099-2-jaegeuk@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210521190217.2484099-2-jaegeuk@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Given RO feature in superblock, we don't need to check provisioning/reserve spaces and SSA area. Signed-off-by: Jaegeuk Kim --- fs/f2fs/f2fs.h | 2 ++ fs/f2fs/segment.c | 4 ++++ fs/f2fs/super.c | 35 ++++++++++++++++++++++++++++++----- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index eaf57b5f3c4b..9ad502f92529 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -168,6 +168,7 @@ struct f2fs_mount_info { #define F2FS_FEATURE_SB_CHKSUM 0x0800 #define F2FS_FEATURE_CASEFOLD 0x1000 #define F2FS_FEATURE_COMPRESSION 0x2000 +#define F2FS_FEATURE_RO 0x4000 #define __F2FS_HAS_FEATURE(raw_super, mask) \ ((raw_super->feature & cpu_to_le32(mask)) != 0) @@ -940,6 +941,7 @@ static inline void set_new_dnode(struct dnode_of_data *dn, struct inode *inode, #define NR_CURSEG_DATA_TYPE (3) #define NR_CURSEG_NODE_TYPE (3) #define NR_CURSEG_INMEM_TYPE (2) +#define NR_CURSEG_RO_TYPE (2) #define NR_CURSEG_PERSIST_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) #define NR_CURSEG_TYPE (NR_CURSEG_INMEM_TYPE + NR_CURSEG_PERSIST_TYPE) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 8668df7870d0..02e0c38be7eb 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -4683,6 +4683,10 @@ static int sanity_check_curseg(struct f2fs_sb_info *sbi) struct seg_entry *se = get_seg_entry(sbi, curseg->segno); unsigned int blkofs = curseg->next_blkoff; + if (F2FS_HAS_FEATURE(sbi, F2FS_FEATURE_RO) && + i != CURSEG_HOT_DATA && i != CURSEG_HOT_NODE) + continue; + sanity_check_seg_type(sbi, curseg->seg_type); if (f2fs_test_bit(blkofs, se->cur_valid_map)) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index e70aca8f97bd..7769ed789b38 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1162,6 +1162,12 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount) */ if (F2FS_OPTION(sbi).active_logs != NR_CURSEG_TYPE) F2FS_OPTION(sbi).whint_mode = WHINT_MODE_OFF; + + if (F2FS_HAS_FEATURE(sbi, F2FS_FEATURE_RO) && !f2fs_readonly(sbi->sb)) { + f2fs_info(sbi, "Allow to mount readonly mode only"); + err = -EINVAL; + goto free_options; + } return 0; } @@ -1819,7 +1825,11 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root) static void default_options(struct f2fs_sb_info *sbi) { /* init some FS parameters */ - F2FS_OPTION(sbi).active_logs = NR_CURSEG_PERSIST_TYPE; + if (F2FS_HAS_FEATURE(sbi, F2FS_FEATURE_RO)) + F2FS_OPTION(sbi).active_logs = NR_CURSEG_RO_TYPE; + else + F2FS_OPTION(sbi).active_logs = NR_CURSEG_PERSIST_TYPE; + F2FS_OPTION(sbi).inline_xattr_size = DEFAULT_INLINE_XATTR_ADDRS; F2FS_OPTION(sbi).whint_mode = WHINT_MODE_OFF; F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_DEFAULT; @@ -2001,6 +2011,11 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data) if (f2fs_readonly(sb) && (*flags & SB_RDONLY)) goto skip; + if (F2FS_HAS_FEATURE(sbi, F2FS_FEATURE_RO) && !(*flags & SB_RDONLY)) { + err = -EROFS; + goto restore_opts; + } + #ifdef CONFIG_QUOTA if (!f2fs_readonly(sb) && (*flags & SB_RDONLY)) { err = dquot_suspend(sb, -1); @@ -3134,14 +3149,15 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi) ovp_segments = le32_to_cpu(ckpt->overprov_segment_count); reserved_segments = le32_to_cpu(ckpt->rsvd_segment_count); - if (unlikely(fsmeta < F2FS_MIN_META_SEGMENTS || + if (!F2FS_HAS_FEATURE(sbi, F2FS_FEATURE_RO) && + unlikely(fsmeta < F2FS_MIN_META_SEGMENTS || ovp_segments == 0 || reserved_segments == 0)) { f2fs_err(sbi, "Wrong layout: check mkfs.f2fs version"); return 1; } - user_block_count = le64_to_cpu(ckpt->user_block_count); - segment_count_main = le32_to_cpu(raw_super->segment_count_main); + segment_count_main = le32_to_cpu(raw_super->segment_count_main) + + F2FS_HAS_FEATURE(sbi, F2FS_FEATURE_RO) ? 1 : 0; log_blocks_per_seg = le32_to_cpu(raw_super->log_blocks_per_seg); if (!user_block_count || user_block_count >= segment_count_main << log_blocks_per_seg) { @@ -3172,6 +3188,10 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi) if (le32_to_cpu(ckpt->cur_node_segno[i]) >= main_segs || le16_to_cpu(ckpt->cur_node_blkoff[i]) >= blocks_per_seg) return 1; + + if (F2FS_HAS_FEATURE(sbi, F2FS_FEATURE_RO)) + goto check_data; + for (j = i + 1; j < NR_CURSEG_NODE_TYPE; j++) { if (le32_to_cpu(ckpt->cur_node_segno[i]) == le32_to_cpu(ckpt->cur_node_segno[j])) { @@ -3182,10 +3202,15 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi) } } } +check_data: for (i = 0; i < NR_CURSEG_DATA_TYPE; i++) { if (le32_to_cpu(ckpt->cur_data_segno[i]) >= main_segs || le16_to_cpu(ckpt->cur_data_blkoff[i]) >= blocks_per_seg) return 1; + + if (F2FS_HAS_FEATURE(sbi, F2FS_FEATURE_RO)) + goto skip_cross; + for (j = i + 1; j < NR_CURSEG_DATA_TYPE; j++) { if (le32_to_cpu(ckpt->cur_data_segno[i]) == le32_to_cpu(ckpt->cur_data_segno[j])) { @@ -3207,7 +3232,7 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi) } } } - +skip_cross: sit_bitmap_size = le32_to_cpu(ckpt->sit_ver_bitmap_bytesize); nat_bitmap_size = le32_to_cpu(ckpt->nat_ver_bitmap_bytesize); -- 2.32.0.rc0.204.g9fa02ecfa5-goog