Skip to contentSkip to conversation

f2fs: Introduce some information prints in the mount path

PATCH In review Namjae Jeon 3 participants 7 messages Dec 22, 2012 – Dec 26, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/5 f2fs: Introduce some information prints in the mount path

From: Namjae Jeon <[email protected]>

Added few informative prints in the mount path, to convey proper error in case of mount failure.

---
 fs/f2fs/super.c |   46 ++++++++++++++++++++++++++++++++++++----------
 1 file changed, 36 insertions(+), 10 deletions(-)
fs/f2fs/super.c +36 -10
index cf0ffb8..86f8549 100644
@@ -342,19 +342,29 @@ static int sanity_check_raw_super(struct f2fs_super_block *raw_super)
 {
 	unsigned int blocksize;
 
-	if (F2FS_SUPER_MAGIC != le32_to_cpu(raw_super->magic))
+	if (F2FS_SUPER_MAGIC != le32_to_cpu(raw_super->magic)) {
+		pr_info("Magic Mismatch, valid(0x%x) - read(0x%x)\n",
+			F2FS_SUPER_MAGIC, le32_to_cpu(raw_super->magic));
 		return 1;
+	}
 
 	/* Currently, support only 4KB block size */
 	blocksize = 1 << le32_to_cpu(raw_super->log_blocksize);
-	if (blocksize != PAGE_CACHE_SIZE)
+	if (blocksize != PAGE_CACHE_SIZE) {
+		pr_info("Not valid blocksize (%u), supports only 4KB\n",
+			blocksize);
 		return 1;
+	}
 	if (le32_to_cpu(raw_super->log_sectorsize) !=
-					F2FS_LOG_SECTOR_SIZE)
+					F2FS_LOG_SECTOR_SIZE) {
+		pr_info("Not valid log sectorsize\n");
 		return 1;
+	}
 	if (le32_to_cpu(raw_super->log_sectors_per_block) !=
-					F2FS_LOG_SECTORS_PER_BLOCK)
+					F2FS_LOG_SECTORS_PER_BLOCK) {
+			pr_info("Not valid log sectors per block\n");
 		return 1;
+	}
 	return 0;
 }
 
@@ -415,13 +425,16 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 		return -ENOMEM;
 
 	/* set a temporary block size */
-	if (!sb_set_blocksize(sb, F2FS_BLKSIZE))
+	if (!sb_set_blocksize(sb, F2FS_BLKSIZE)) {
+		pr_err("unable to set blocksize\n");
 		goto free_sbi;
+	}
 
 	/* read f2fs raw super block */
 	raw_super_buf = sb_bread(sb, 0);
 	if (!raw_super_buf) {
 		err = -EIO;
+		pr_err("unable to read superblock\n");
 		goto free_sbi;
 	}
 	raw_super = (struct f2fs_super_block *)
@@ -443,8 +456,10 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 		goto free_sb_buf;
 
 	/* sanity checking of raw super */
-	if (sanity_check_raw_super(raw_super))
+	if (sanity_check_raw_super(raw_super)) {
+		pr_err("Not a valid F2FS filesystem\n");
 		goto free_sb_buf;
+	}
 
 	sb->s_maxbytes = max_file_size(le32_to_cpu(raw_super->log_blocksize));
 	sb->s_max_links = F2FS_LINK_MAX;
@@ -478,18 +493,23 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 	/* get an inode for meta space */
 	sbi->meta_inode = f2fs_iget(sb, F2FS_META_INO(sbi));
 	if (IS_ERR(sbi->meta_inode)) {
+		pr_err("Failed to read F2FS meta data inode\n");
 		err = PTR_ERR(sbi->meta_inode);
 		goto free_sb_buf;
 	}
 
 	err = get_valid_checkpoint(sbi);
-	if (err)
+	if (err) {
+		pr_err("Failed to get valid F2FS checkpoint\n");
 		goto free_meta_inode;
+	}
 
 	/* sanity checking of checkpoint */
 	err = -EINVAL;
-	if (sanity_check_ckpt(raw_super, sbi->ckpt))
+	if (sanity_check_ckpt(raw_super, sbi->ckpt)) {
+		pr_err("Not a valid F2FS checkpoint\n");
 		goto free_cp;
+	}
 
 	sbi->total_valid_node_count =
 				le32_to_cpu(sbi->ckpt->valid_node_count);
@@ -511,17 +531,22 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 
 	/* setup f2fs internal modules */
 	err = build_segment_manager(sbi);
-	if (err)
+	if (err) {
+		pr_err("Failed to initialize F2FS segment manager\n");
 		goto free_sm;
+	}
 	err = build_node_manager(sbi);
-	if (err)
+	if (err) {
+		pr_err("Failed to initialize F2FS node manager\n");
 		goto free_nm;
+	}
 
 	build_gc_manager(sbi);
 
 	/* get an inode for node space */
 	sbi->node_inode = f2fs_iget(sb, F2FS_NODE_INO(sbi));
 	if (IS_ERR(sbi->node_inode)) {
+		pr_err("Failed to read node inode\n");
 		err = PTR_ERR(sbi->node_inode);
 		goto free_nm;
 	}
@@ -534,6 +559,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 	/* read root inode and dentry */
 	root = f2fs_iget(sb, F2FS_ROOT_INO(sbi));
 	if (IS_ERR(root)) {
+		pr_err("Failed to read root inode\n");
 		err = PTR_ERR(root);
 		goto free_node_inode;
 	}
Signature · 1 line
1.7.9.5
#1 lore raw

Hi,

Could you make them follow the file system convention? Something like "F2FS: blah blah~".

Otherwise, how about adding a debugging function to express the prefix? Thanks,

2012-12-22 (토), 12:08 +0900, Namjae Jeon:

Quoted 138 lines

From: Namjae Jeon <[email protected]>

Added few informative prints in the mount path, to convey proper error in case of mount failure.

---
 fs/f2fs/super.c |   46 ++++++++++++++++++++++++++++++++++++----------
 1 file changed, 36 insertions(+), 10 deletions(-)
fs/f2fs/super.c +36 -10
index cf0ffb8..86f8549 100644
@@ -342,19 +342,29 @@ static int sanity_check_raw_super(struct f2fs_super_block *raw_super)
 {
 	unsigned int blocksize;
 
-	if (F2FS_SUPER_MAGIC != le32_to_cpu(raw_super->magic))
+	if (F2FS_SUPER_MAGIC != le32_to_cpu(raw_super->magic)) {
+		pr_info("Magic Mismatch, valid(0x%x) - read(0x%x)\n",
+			F2FS_SUPER_MAGIC, le32_to_cpu(raw_super->magic));
 		return 1;
+	}
 
 	/* Currently, support only 4KB block size */
 	blocksize = 1 << le32_to_cpu(raw_super->log_blocksize);
-	if (blocksize != PAGE_CACHE_SIZE)
+	if (blocksize != PAGE_CACHE_SIZE) {
+		pr_info("Not valid blocksize (%u), supports only 4KB\n",
+			blocksize);
 		return 1;
+	}
 	if (le32_to_cpu(raw_super->log_sectorsize) !=
-					F2FS_LOG_SECTOR_SIZE)
+					F2FS_LOG_SECTOR_SIZE) {
+		pr_info("Not valid log sectorsize\n");
 		return 1;
+	}
 	if (le32_to_cpu(raw_super->log_sectors_per_block) !=
-					F2FS_LOG_SECTORS_PER_BLOCK)
+					F2FS_LOG_SECTORS_PER_BLOCK) {
+			pr_info("Not valid log sectors per block\n");
 		return 1;
+	}
 	return 0;
 }
 
@@ -415,13 +425,16 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 		return -ENOMEM;
 
 	/* set a temporary block size */
-	if (!sb_set_blocksize(sb, F2FS_BLKSIZE))
+	if (!sb_set_blocksize(sb, F2FS_BLKSIZE)) {
+		pr_err("unable to set blocksize\n");
 		goto free_sbi;
+	}
 
 	/* read f2fs raw super block */
 	raw_super_buf = sb_bread(sb, 0);
 	if (!raw_super_buf) {
 		err = -EIO;
+		pr_err("unable to read superblock\n");
 		goto free_sbi;
 	}
 	raw_super = (struct f2fs_super_block *)
@@ -443,8 +456,10 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 		goto free_sb_buf;
 
 	/* sanity checking of raw super */
-	if (sanity_check_raw_super(raw_super))
+	if (sanity_check_raw_super(raw_super)) {
+		pr_err("Not a valid F2FS filesystem\n");
 		goto free_sb_buf;
+	}
 
 	sb->s_maxbytes = max_file_size(le32_to_cpu(raw_super->log_blocksize));
 	sb->s_max_links = F2FS_LINK_MAX;
@@ -478,18 +493,23 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 	/* get an inode for meta space */
 	sbi->meta_inode = f2fs_iget(sb, F2FS_META_INO(sbi));
 	if (IS_ERR(sbi->meta_inode)) {
+		pr_err("Failed to read F2FS meta data inode\n");
 		err = PTR_ERR(sbi->meta_inode);
 		goto free_sb_buf;
 	}
 
 	err = get_valid_checkpoint(sbi);
-	if (err)
+	if (err) {
+		pr_err("Failed to get valid F2FS checkpoint\n");
 		goto free_meta_inode;
+	}
 
 	/* sanity checking of checkpoint */
 	err = -EINVAL;
-	if (sanity_check_ckpt(raw_super, sbi->ckpt))
+	if (sanity_check_ckpt(raw_super, sbi->ckpt)) {
+		pr_err("Not a valid F2FS checkpoint\n");
 		goto free_cp;
+	}
 
 	sbi->total_valid_node_count =
 				le32_to_cpu(sbi->ckpt->valid_node_count);
@@ -511,17 +531,22 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 
 	/* setup f2fs internal modules */
 	err = build_segment_manager(sbi);
-	if (err)
+	if (err) {
+		pr_err("Failed to initialize F2FS segment manager\n");
 		goto free_sm;
+	}
 	err = build_node_manager(sbi);
-	if (err)
+	if (err) {
+		pr_err("Failed to initialize F2FS node manager\n");
 		goto free_nm;
+	}
 
 	build_gc_manager(sbi);
 
 	/* get an inode for node space */
 	sbi->node_inode = f2fs_iget(sb, F2FS_NODE_INO(sbi));
 	if (IS_ERR(sbi->node_inode)) {
+		pr_err("Failed to read node inode\n");
 		err = PTR_ERR(sbi->node_inode);
 		goto free_nm;
 	}
@@ -534,6 +559,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 	/* read root inode and dentry */
 	root = f2fs_iget(sb, F2FS_ROOT_INO(sbi));
 	if (IS_ERR(root)) {
+		pr_err("Failed to read root inode\n");
 		err = PTR_ERR(root);
 		goto free_node_inode;
 	}
Signature · 2 lines
Jaegeuk Kim
Samsung
#2 lore raw

2012/12/26, Jaegeuk Kim <[email protected]>:

Quoted 1 line

Hi,

Hi Jaegeuk.

Quoted 3 lines

Could you make them follow the file system convention? Something like "F2FS: blah blah~".

Yes, I agree.

Quoted 2 lines

Otherwise, how about adding a debugging function to express the prefix?

Okay, I will send you the patches included your suggestion.

Thanks.

Quoted 143 lines

Thanks,

2012-12-22 (토), 12:08 +0900, Namjae Jeon:

Quoted 140 lines

From: Namjae Jeon <[email protected]>

Added few informative prints in the mount path, to convey proper error in case of mount failure.

---
 fs/f2fs/super.c |   46 ++++++++++++++++++++++++++++++++++++----------
 1 file changed, 36 insertions(+), 10 deletions(-)
fs/f2fs/super.c +18 -5
index cf0ffb8..86f8549 100644
@@ -342,19 +342,29 @@ static int sanity_check_raw_super(struct
 f2fs_super_block *raw_super)
 {
 	unsigned int blocksize;
 
-	if (F2FS_SUPER_MAGIC != le32_to_cpu(raw_super->magic))
+	if (F2FS_SUPER_MAGIC != le32_to_cpu(raw_super->magic)) {
+		pr_info("Magic Mismatch, valid(0x%x) - read(0x%x)\n",
+			F2FS_SUPER_MAGIC, le32_to_cpu(raw_super->magic));
 		return 1;
+	}
 
 	/* Currently, support only 4KB block size */
 	blocksize = 1 << le32_to_cpu(raw_super->log_blocksize);
-	if (blocksize != PAGE_CACHE_SIZE)
+	if (blocksize != PAGE_CACHE_SIZE) {
+		pr_info("Not valid blocksize (%u), supports only 4KB\n",
+			blocksize);
 		return 1;
+	}
 	if (le32_to_cpu(raw_super->log_sectorsize) !=
-					F2FS_LOG_SECTOR_SIZE)
+					F2FS_LOG_SECTOR_SIZE) {
+		pr_info("Not valid log sectorsize\n");
 		return 1;
+	}
 	if (le32_to_cpu(raw_super->log_sectors_per_block) !=
-					F2FS_LOG_SECTORS_PER_BLOCK)
+					F2FS_LOG_SECTORS_PER_BLOCK) {
+			pr_info("Not valid log sectors per block\n");
 		return 1;
+	}
 	return 0;
 }
@@ -415,13 +425,16 @@ static int f2fs_fill_super(struct super_block *sb,
 void *data, int silent)
 		return -ENOMEM;
 
 	/* set a temporary block size */
-	if (!sb_set_blocksize(sb, F2FS_BLKSIZE))
+	if (!sb_set_blocksize(sb, F2FS_BLKSIZE)) {
+		pr_err("unable to set blocksize\n");
 		goto free_sbi;
+	}
 
 	/* read f2fs raw super block */
 	raw_super_buf = sb_bread(sb, 0);
 	if (!raw_super_buf) {
 		err = -EIO;
+		pr_err("unable to read superblock\n");
 		goto free_sbi;
 	}
fs/f2fs/super.c +3 -1
 	raw_super = (struct f2fs_super_block *)
@@ -443,8 +456,10 @@ static int f2fs_fill_super(struct super_block *sb,
 void *data, int silent)
 		goto free_sb_buf;
 
 	/* sanity checking of raw super */
-	if (sanity_check_raw_super(raw_super))
+	if (sanity_check_raw_super(raw_super)) {
+		pr_err("Not a valid F2FS filesystem\n");
 		goto free_sb_buf;
+	}
 
 	sb->s_maxbytes = max_file_size(le32_to_cpu(raw_super->log_blocksize));
fs/f2fs/super.c +7 -2
 	sb->s_max_links = F2FS_LINK_MAX;
@@ -478,18 +493,23 @@ static int f2fs_fill_super(struct super_block *sb,
 void *data, int silent)
 	/* get an inode for meta space */
 	sbi->meta_inode = f2fs_iget(sb, F2FS_META_INO(sbi));
 	if (IS_ERR(sbi->meta_inode)) {
+		pr_err("Failed to read F2FS meta data inode\n");
 		err = PTR_ERR(sbi->meta_inode);
 		goto free_sb_buf;
 	}
 
 	err = get_valid_checkpoint(sbi);
-	if (err)
+	if (err) {
+		pr_err("Failed to get valid F2FS checkpoint\n");
 		goto free_meta_inode;
+	}
 
 	/* sanity checking of checkpoint */
 	err = -EINVAL;
-	if (sanity_check_ckpt(raw_super, sbi->ckpt))
+	if (sanity_check_ckpt(raw_super, sbi->ckpt)) {
+		pr_err("Not a valid F2FS checkpoint\n");
 		goto free_cp;
+	}
 
 	sbi->total_valid_node_count =
fs/f2fs/super.c +7 -2
 				le32_to_cpu(sbi->ckpt->valid_node_count);
@@ -511,17 +531,22 @@ static int f2fs_fill_super(struct super_block *sb,
 void *data, int silent)
 
 	/* setup f2fs internal modules */
 	err = build_segment_manager(sbi);
-	if (err)
+	if (err) {
+		pr_err("Failed to initialize F2FS segment manager\n");
 		goto free_sm;
+	}
 	err = build_node_manager(sbi);
-	if (err)
+	if (err) {
+		pr_err("Failed to initialize F2FS node manager\n");
 		goto free_nm;
+	}
 
 	build_gc_manager(sbi);
 
 	/* get an inode for node space */
 	sbi->node_inode = f2fs_iget(sb, F2FS_NODE_INO(sbi));
 	if (IS_ERR(sbi->node_inode)) {
+		pr_err("Failed to read node inode\n");
 		err = PTR_ERR(sbi->node_inode);
 		goto free_nm;
fs/f2fs/super.c +0 -0
 	}
@@ -534,6 +559,7 @@ static int f2fs_fill_super(struct super_block *sb,
 void *data, int silent)
 	/* read root inode and dentry */
 	root = f2fs_iget(sb, F2FS_ROOT_INO(sbi));
 	if (IS_ERR(root)) {
Quoted 9 lines
Quoted 4 lines
fs/f2fs/super.c +1 -0
+		pr_err("Failed to read root inode\n");
 		err = PTR_ERR(root);
 		goto free_node_inode;

}

--
Jaegeuk Kim
Samsung

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 11 lines · Namjae Jeon

2012/12/26, Jaegeuk Kim <[email protected]>:

Quoted 1 line

Hi,

Hi Jaegeuk.

Quoted 3 lines

Could you make them follow the file system convention? Something like "F2FS: blah blah~".

Yes, I agree.

Quoted 2 lines

Otherwise, how about adding a debugging function to express the prefix?

Okay, I will send you the patches included your suggestion.

Add

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

before any #include

#4 lore raw

2012/12/26, Joe Perches <[email protected]>:

Quoted 10 lines · Namjae Jeon
Quoted 9 lines

2012/12/26, Jaegeuk Kim <[email protected]>:

Quoted 1 line

Hi,

Hi Jaegeuk.

Quoted 3 lines

Could you make them follow the file system convention? Something like "F2FS: blah blah~".

Yes, I agree.

Quoted 1 line
Quoted 8 lines
Quoted 2 lines
Quoted 1 line

Otherwise, how about adding a debugging function to express the prefix?

Okay, I will send you the patches included your suggestion.

Add

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

before any #include

Hi Joe.

I think we can have debugging message function for f2fs similar to ext4/fat like fat_msg, ext4_msg.
It is one time change but in the future it will allow more convenience to use that way.
What is your opinion ?

Or is that we have to to use pr_xxx function for error print instead of own print debug function ?

Thanks.

Quoted 2 lines
#5 lore raw
Quoted 5 lines · Namjae Jeon

2012/12/26, Joe Perches <[email protected]>:

Quoted 4 lines · Namjae Jeon
Quoted 3 lines

2012/12/26, Jaegeuk Kim <[email protected]>:

Quoted 2 lines

Could you make them follow the file system convention? Something like "F2FS: blah blah~".

Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

Yes, I agree.

Quoted 1 line

Otherwise, how about adding a debugging function to express the prefix?

Okay, I will send you the patches included your suggestion.

Add
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
before any #include

Hi Joe.

Hello Namjae

Quoted 8 lines

I think we can have debugging message function for f2fs similar to ext4/fat like fat_msg, ext4_msg.
It is one time change but in the future it will allow more convenience to use that way.
What is your opinion ?

Or is that we have to to use pr_xxx function for error print instead of own print debug function ?

Sure, make your own f2fs_dbg function/macro when
and if you have an object you want to pass along
with the format and args

something like:

fs2fs_printk(struct fs2fs_handle *f2h, const char *fmt, ...)

Otherwise, just use pr_debug/pr_<level>(fmt, ...)

cheers, Joe

#6 lore raw

2012/12/26, Joe Perches <[email protected]>:

Quoted 30 lines · Namjae Jeon
Quoted 5 lines

2012/12/26, Joe Perches <[email protected]>:

Quoted 4 lines · Namjae Jeon
Quoted 3 lines

2012/12/26, Jaegeuk Kim <[email protected]>:

Quoted 2 lines

Could you make them follow the file system convention? Something like "F2FS: blah blah~".

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

Yes, I agree.

Quoted 2 lines

Otherwise, how about adding a debugging function to express the prefix?

Okay, I will send you the patches included your suggestion.

Add
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
before any #include

Hi Joe.

Hello Namjae

Quoted 8 lines

I think we can have debugging message function for f2fs similar to ext4/fat like fat_msg, ext4_msg.
It is one time change but in the future it will allow more convenience to use that way.
What is your opinion ?

Or is that we have to to use pr_xxx function for error print instead of own print debug function ?

Sure, make your own f2fs_dbg function/macro when
and if you have an object you want to pass along
with the format and args

Quoted 5 lines

something like:

fs2fs_printk(struct fs2fs_handle *f2h, const char *fmt, ...)

Otherwise, just use pr_debug/pr_<level>(fmt, ...)

Okay, Thanks for reply!

Quoted 4 lines

cheers, Joe