linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] f2fs: cover large section in sanity check of super
@ 2016-03-21 18:56 Jaegeuk Kim
  2016-03-21 18:56 ` [PATCH 2/2] f2fs: show current mount status Jaegeuk Kim
  2016-03-22  3:39 ` [f2fs-dev] [PATCH 1/2] f2fs: cover large section in sanity check of super Chao Yu
  0 siblings, 2 replies; 3+ messages in thread
From: Jaegeuk Kim @ 2016-03-21 18:56 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim, stable 4 . 5+

This patch fixes the bug which does not cover a large section case when checking
the sanity of superblock.

Reported-by: Matthias Prager <linux@matthiasprager.de>
Reported-by: David Gnedt <david.gnedt@davizone.at>
Cc: stable 4.5+ <stable@vger.kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/super.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 15bb81f..fc9147f 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1000,6 +1000,7 @@ static inline bool sanity_check_area_boundary(struct super_block *sb,
 	u32 segment_count_main = le32_to_cpu(raw_super->segment_count_main);
 	u32 segment_count = le32_to_cpu(raw_super->segment_count);
 	u32 log_blocks_per_seg = le32_to_cpu(raw_super->log_blocks_per_seg);
+	u32 segs_per_sec = le32_to_cpu(raw_super->segs_per_sec);
 
 	if (segment0_blkaddr != cp_blkaddr) {
 		f2fs_msg(sb, KERN_INFO,
@@ -1044,12 +1045,26 @@ static inline bool sanity_check_area_boundary(struct super_block *sb,
 		return true;
 	}
 
-	if (main_blkaddr + (segment_count_main << log_blocks_per_seg) !=
+	if (segs_per_sec == 1 &&
+		main_blkaddr + (segment_count_main << log_blocks_per_seg) !=
 		segment0_blkaddr + (segment_count << log_blocks_per_seg)) {
 		f2fs_msg(sb, KERN_INFO,
 			"Wrong MAIN_AREA boundary, start(%u) end(%u) blocks(%u)",
 			main_blkaddr,
-			segment0_blkaddr + (segment_count << log_blocks_per_seg),
+			segment0_blkaddr +
+			(segment_count << log_blocks_per_seg),
+			segment_count_main << log_blocks_per_seg);
+		return true;
+	}
+
+	if (segs_per_sec > 1 &&
+		main_blkaddr + (segment_count_main << log_blocks_per_seg) >
+		segment0_blkaddr + (segment_count << log_blocks_per_seg)) {
+		f2fs_msg(sb, KERN_INFO,
+			"Wrong MAIN_AREA boundary in large section, start(%u) end(%u) blocks(%u)",
+			main_blkaddr,
+			segment0_blkaddr +
+			(segment_count << log_blocks_per_seg),
 			segment_count_main << log_blocks_per_seg);
 		return true;
 	}
-- 
2.6.3


------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] f2fs: show current mount status
  2016-03-21 18:56 [PATCH 1/2] f2fs: cover large section in sanity check of super Jaegeuk Kim
@ 2016-03-21 18:56 ` Jaegeuk Kim
  2016-03-22  3:39 ` [f2fs-dev] [PATCH 1/2] f2fs: cover large section in sanity check of super Chao Yu
  1 sibling, 0 replies; 3+ messages in thread
From: Jaegeuk Kim @ 2016-03-21 18:56 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim

This patch remains the current mount status to f2fs status info.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/debug.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c
index 4fb6ef8..ff8730e 100644
--- a/fs/f2fs/debug.c
+++ b/fs/f2fs/debug.c
@@ -216,8 +216,9 @@ static int stat_show(struct seq_file *s, void *v)
 	list_for_each_entry(si, &f2fs_stat_list, stat_list) {
 		update_general_status(si->sbi);
 
-		seq_printf(s, "\n=====[ partition info(%pg). #%d ]=====\n",
-			si->sbi->sb->s_bdev, i++);
+		seq_printf(s, "\n=====[ partition info(%pg). #%d, %s]=====\n",
+			si->sbi->sb->s_bdev, i++,
+			f2fs_readonly(si->sbi->sb) ? "RO": "RW");
 		seq_printf(s, "[SB: 1] [CP: 2] [SIT: %d] [NAT: %d] ",
 			   si->sit_area_segs, si->nat_area_segs);
 		seq_printf(s, "[SSA: %d] [MAIN: %d",
-- 
2.6.3


------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [f2fs-dev] [PATCH 1/2] f2fs: cover large section in sanity check of super
  2016-03-21 18:56 [PATCH 1/2] f2fs: cover large section in sanity check of super Jaegeuk Kim
  2016-03-21 18:56 ` [PATCH 2/2] f2fs: show current mount status Jaegeuk Kim
@ 2016-03-22  3:39 ` Chao Yu
  1 sibling, 0 replies; 3+ messages in thread
From: Chao Yu @ 2016-03-22  3:39 UTC (permalink / raw)
  To: 'Jaegeuk Kim', linux-kernel, linux-fsdevel,
	linux-f2fs-devel
  Cc: 'stable 4 . 5+'

Hi Jaegeuk,

> -----Original Message-----
> From: Jaegeuk Kim [mailto:jaegeuk@kernel.org]
> Sent: Tuesday, March 22, 2016 2:56 AM
> To: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org;
> linux-f2fs-devel@lists.sourceforge.net
> Cc: Jaegeuk Kim; stable 4 . 5+
> Subject: [f2fs-dev] [PATCH 1/2] f2fs: cover large section in sanity check of super
> 
> This patch fixes the bug which does not cover a large section case when checking
> the sanity of superblock.
> 
> Reported-by: Matthias Prager <linux@matthiasprager.de>
> Reported-by: David Gnedt <david.gnedt@davizone.at>
> Cc: stable 4.5+ <stable@vger.kernel.org>
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  fs/f2fs/super.c | 19 +++++++++++++++++--
>  1 file changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index 15bb81f..fc9147f 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -1000,6 +1000,7 @@ static inline bool sanity_check_area_boundary(struct super_block *sb,
>  	u32 segment_count_main = le32_to_cpu(raw_super->segment_count_main);
>  	u32 segment_count = le32_to_cpu(raw_super->segment_count);
>  	u32 log_blocks_per_seg = le32_to_cpu(raw_super->log_blocks_per_seg);
> +	u32 segs_per_sec = le32_to_cpu(raw_super->segs_per_sec);
> 
>  	if (segment0_blkaddr != cp_blkaddr) {
>  		f2fs_msg(sb, KERN_INFO,
> @@ -1044,12 +1045,26 @@ static inline bool sanity_check_area_boundary(struct super_block *sb,
>  		return true;
>  	}
> 
> -	if (main_blkaddr + (segment_count_main << log_blocks_per_seg) !=
> +	if (segs_per_sec == 1 &&
> +		main_blkaddr + (segment_count_main << log_blocks_per_seg) !=
>  		segment0_blkaddr + (segment_count << log_blocks_per_seg)) {
>  		f2fs_msg(sb, KERN_INFO,
>  			"Wrong MAIN_AREA boundary, start(%u) end(%u) blocks(%u)",
>  			main_blkaddr,
> -			segment0_blkaddr + (segment_count << log_blocks_per_seg),
> +			segment0_blkaddr +
> +			(segment_count << log_blocks_per_seg),
> +			segment_count_main << log_blocks_per_seg);
> +		return true;
> +	}
> +
> +	if (segs_per_sec > 1 &&

if ((segs_per_sec > 1 || secs_per_zone > 1)) && ?

Thanks,

> +		main_blkaddr + (segment_count_main << log_blocks_per_seg) >
> +		segment0_blkaddr + (segment_count << log_blocks_per_seg)) {
> +		f2fs_msg(sb, KERN_INFO,
> +			"Wrong MAIN_AREA boundary in large section, start(%u) end(%u) blocks(%u)",
> +			main_blkaddr,
> +			segment0_blkaddr +
> +			(segment_count << log_blocks_per_seg),
>  			segment_count_main << log_blocks_per_seg);
>  		return true;
>  	}
> --
> 2.6.3
> 
> 
> ------------------------------------------------------------------------------
> Transform Data into Opportunity.
> Accelerate data analysis in your applications with
> Intel Data Analytics Acceleration Library.
> Click to learn more.
> http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-03-22  3:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-21 18:56 [PATCH 1/2] f2fs: cover large section in sanity check of super Jaegeuk Kim
2016-03-21 18:56 ` [PATCH 2/2] f2fs: show current mount status Jaegeuk Kim
2016-03-22  3:39 ` [f2fs-dev] [PATCH 1/2] f2fs: cover large section in sanity check of super Chao Yu

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).