aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorNamjae Jeon <namjae.jeon@samsung.com>2012-12-30 00:52:05 -0500
committerJaegeuk Kim <jaegeuk.kim@samsung.com>2013-01-03 19:42:59 -0500
commita07ef784356cf9157bd9bed5254cbb9a82d33722 (patch)
treef2356b791f7d961c42a8c7488ac70828c5ba9fc0 /fs
parent5f738967e89584f99c6a11c6bf09b16c50b6a03e (diff)
f2fs: introduce f2fs_msg to ease adding information prints
Introduced f2fs_msg function to differentiate f2fs specific messages in the log. And, added few informative prints in the mount path, to convey proper error in case of mount failure. Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com> Signed-off-by: Amit Sahrawat <a.sahrawat@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/f2fs/f2fs.h2
-rw-r--r--fs/f2fs/super.c80
2 files changed, 65 insertions, 17 deletions
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 13c6dfbb7183..8199ee9f5875 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -877,6 +877,8 @@ bool f2fs_empty_dir(struct inode *);
877 * super.c 877 * super.c
878 */ 878 */
879int f2fs_sync_fs(struct super_block *, int); 879int f2fs_sync_fs(struct super_block *, int);
880extern __printf(3, 4)
881void f2fs_msg(struct super_block *, const char *, const char *, ...);
880 882
881/* 883/*
882 * hash.c 884 * hash.c
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 08a94c814bdc..afa7ef0c4ba7 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -53,6 +53,18 @@ static match_table_t f2fs_tokens = {
53 {Opt_err, NULL}, 53 {Opt_err, NULL},
54}; 54};
55 55
56void f2fs_msg(struct super_block *sb, const char *level, const char *fmt, ...)
57{
58 struct va_format vaf;
59 va_list args;
60
61 va_start(args, fmt);
62 vaf.fmt = fmt;
63 vaf.va = &args;
64 printk("%sF2FS-fs (%s): %pV\n", level, sb->s_id, &vaf);
65 va_end(args);
66}
67
56static void init_once(void *foo) 68static void init_once(void *foo)
57{ 69{
58 struct f2fs_inode_info *fi = (struct f2fs_inode_info *) foo; 70 struct f2fs_inode_info *fi = (struct f2fs_inode_info *) foo;
@@ -247,7 +259,8 @@ static const struct export_operations f2fs_export_ops = {
247 .get_parent = f2fs_get_parent, 259 .get_parent = f2fs_get_parent,
248}; 260};
249 261
250static int parse_options(struct f2fs_sb_info *sbi, char *options) 262static int parse_options(struct super_block *sb, struct f2fs_sb_info *sbi,
263 char *options)
251{ 264{
252 substring_t args[MAX_OPT_ARGS]; 265 substring_t args[MAX_OPT_ARGS];
253 char *p; 266 char *p;
@@ -286,7 +299,8 @@ static int parse_options(struct f2fs_sb_info *sbi, char *options)
286 break; 299 break;
287#else 300#else
288 case Opt_nouser_xattr: 301 case Opt_nouser_xattr:
289 pr_info("nouser_xattr options not supported\n"); 302 f2fs_msg(sb, KERN_INFO,
303 "nouser_xattr options not supported");
290 break; 304 break;
291#endif 305#endif
292#ifdef CONFIG_F2FS_FS_POSIX_ACL 306#ifdef CONFIG_F2FS_FS_POSIX_ACL
@@ -295,7 +309,7 @@ static int parse_options(struct f2fs_sb_info *sbi, char *options)
295 break; 309 break;
296#else 310#else
297 case Opt_noacl: 311 case Opt_noacl:
298 pr_info("noacl options not supported\n"); 312 f2fs_msg(sb, KERN_INFO, "noacl options not supported");
299 break; 313 break;
300#endif 314#endif
301 case Opt_active_logs: 315 case Opt_active_logs:
@@ -309,8 +323,9 @@ static int parse_options(struct f2fs_sb_info *sbi, char *options)
309 set_opt(sbi, DISABLE_EXT_IDENTIFY); 323 set_opt(sbi, DISABLE_EXT_IDENTIFY);
310 break; 324 break;
311 default: 325 default:
312 pr_err("Unrecognized mount option \"%s\" or missing value\n", 326 f2fs_msg(sb, KERN_ERR,
313 p); 327 "Unrecognized mount option \"%s\" or missing value",
328 p);
314 return -EINVAL; 329 return -EINVAL;
315 } 330 }
316 } 331 }
@@ -337,23 +352,36 @@ static loff_t max_file_size(unsigned bits)
337 return result; 352 return result;
338} 353}
339 354
340static int sanity_check_raw_super(struct f2fs_super_block *raw_super) 355static int sanity_check_raw_super(struct super_block *sb,
356 struct f2fs_super_block *raw_super)
341{ 357{
342 unsigned int blocksize; 358 unsigned int blocksize;
343 359
344 if (F2FS_SUPER_MAGIC != le32_to_cpu(raw_super->magic)) 360 if (F2FS_SUPER_MAGIC != le32_to_cpu(raw_super->magic)) {
361 f2fs_msg(sb, KERN_INFO,
362 "Magic Mismatch, valid(0x%x) - read(0x%x)",
363 F2FS_SUPER_MAGIC, le32_to_cpu(raw_super->magic));
345 return 1; 364 return 1;
365 }
346 366
347 /* Currently, support only 4KB block size */ 367 /* Currently, support only 4KB block size */
348 blocksize = 1 << le32_to_cpu(raw_super->log_blocksize); 368 blocksize = 1 << le32_to_cpu(raw_super->log_blocksize);
349 if (blocksize != PAGE_CACHE_SIZE) 369 if (blocksize != PAGE_CACHE_SIZE) {
370 f2fs_msg(sb, KERN_INFO,
371 "Invalid blocksize (%u), supports only 4KB\n",
372 blocksize);
350 return 1; 373 return 1;
374 }
351 if (le32_to_cpu(raw_super->log_sectorsize) != 375 if (le32_to_cpu(raw_super->log_sectorsize) !=
352 F2FS_LOG_SECTOR_SIZE) 376 F2FS_LOG_SECTOR_SIZE) {
377 f2fs_msg(sb, KERN_INFO, "Invalid log sectorsize");
353 return 1; 378 return 1;
379 }
354 if (le32_to_cpu(raw_super->log_sectors_per_block) != 380 if (le32_to_cpu(raw_super->log_sectors_per_block) !=
355 F2FS_LOG_SECTORS_PER_BLOCK) 381 F2FS_LOG_SECTORS_PER_BLOCK) {
382 f2fs_msg(sb, KERN_INFO, "Invalid log sectors per block");
356 return 1; 383 return 1;
384 }
357 return 0; 385 return 0;
358} 386}
359 387
@@ -414,13 +442,16 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
414 return -ENOMEM; 442 return -ENOMEM;
415 443
416 /* set a temporary block size */ 444 /* set a temporary block size */
417 if (!sb_set_blocksize(sb, F2FS_BLKSIZE)) 445 if (!sb_set_blocksize(sb, F2FS_BLKSIZE)) {
446 f2fs_msg(sb, KERN_ERR, "unable to set blocksize");
418 goto free_sbi; 447 goto free_sbi;
448 }
419 449
420 /* read f2fs raw super block */ 450 /* read f2fs raw super block */
421 raw_super_buf = sb_bread(sb, 0); 451 raw_super_buf = sb_bread(sb, 0);
422 if (!raw_super_buf) { 452 if (!raw_super_buf) {
423 err = -EIO; 453 err = -EIO;
454 f2fs_msg(sb, KERN_ERR, "unable to read superblock");
424 goto free_sbi; 455 goto free_sbi;
425 } 456 }
426 raw_super = (struct f2fs_super_block *) 457 raw_super = (struct f2fs_super_block *)
@@ -438,12 +469,14 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
438 set_opt(sbi, POSIX_ACL); 469 set_opt(sbi, POSIX_ACL);
439#endif 470#endif
440 /* parse mount options */ 471 /* parse mount options */
441 if (parse_options(sbi, (char *)data)) 472 if (parse_options(sb, sbi, (char *)data))
442 goto free_sb_buf; 473 goto free_sb_buf;
443 474
444 /* sanity checking of raw super */ 475 /* sanity checking of raw super */
445 if (sanity_check_raw_super(raw_super)) 476 if (sanity_check_raw_super(sb, raw_super)) {
477 f2fs_msg(sb, KERN_ERR, "Can't find a valid F2FS filesystem");
446 goto free_sb_buf; 478 goto free_sb_buf;
479 }
447 480
448 sb->s_maxbytes = max_file_size(le32_to_cpu(raw_super->log_blocksize)); 481 sb->s_maxbytes = max_file_size(le32_to_cpu(raw_super->log_blocksize));
449 sb->s_max_links = F2FS_LINK_MAX; 482 sb->s_max_links = F2FS_LINK_MAX;
@@ -477,18 +510,23 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
477 /* get an inode for meta space */ 510 /* get an inode for meta space */
478 sbi->meta_inode = f2fs_iget(sb, F2FS_META_INO(sbi)); 511 sbi->meta_inode = f2fs_iget(sb, F2FS_META_INO(sbi));
479 if (IS_ERR(sbi->meta_inode)) { 512 if (IS_ERR(sbi->meta_inode)) {
513 f2fs_msg(sb, KERN_ERR, "Failed to read F2FS meta data inode");
480 err = PTR_ERR(sbi->meta_inode); 514 err = PTR_ERR(sbi->meta_inode);
481 goto free_sb_buf; 515 goto free_sb_buf;
482 } 516 }
483 517
484 err = get_valid_checkpoint(sbi); 518 err = get_valid_checkpoint(sbi);
485 if (err) 519 if (err) {
520 f2fs_msg(sb, KERN_ERR, "Failed to get valid F2FS checkpoint");
486 goto free_meta_inode; 521 goto free_meta_inode;
522 }
487 523
488 /* sanity checking of checkpoint */ 524 /* sanity checking of checkpoint */
489 err = -EINVAL; 525 err = -EINVAL;
490 if (sanity_check_ckpt(raw_super, sbi->ckpt)) 526 if (sanity_check_ckpt(raw_super, sbi->ckpt)) {
527 f2fs_msg(sb, KERN_ERR, "Invalid F2FS checkpoint");
491 goto free_cp; 528 goto free_cp;
529 }
492 530
493 sbi->total_valid_node_count = 531 sbi->total_valid_node_count =
494 le32_to_cpu(sbi->ckpt->valid_node_count); 532 le32_to_cpu(sbi->ckpt->valid_node_count);
@@ -510,17 +548,24 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
510 548
511 /* setup f2fs internal modules */ 549 /* setup f2fs internal modules */
512 err = build_segment_manager(sbi); 550 err = build_segment_manager(sbi);
513 if (err) 551 if (err) {
552 f2fs_msg(sb, KERN_ERR,
553 "Failed to initialize F2FS segment manager");
514 goto free_sm; 554 goto free_sm;
555 }
515 err = build_node_manager(sbi); 556 err = build_node_manager(sbi);
516 if (err) 557 if (err) {
558 f2fs_msg(sb, KERN_ERR,
559 "Failed to initialize F2FS node manager");
517 goto free_nm; 560 goto free_nm;
561 }
518 562
519 build_gc_manager(sbi); 563 build_gc_manager(sbi);
520 564
521 /* get an inode for node space */ 565 /* get an inode for node space */
522 sbi->node_inode = f2fs_iget(sb, F2FS_NODE_INO(sbi)); 566 sbi->node_inode = f2fs_iget(sb, F2FS_NODE_INO(sbi));
523 if (IS_ERR(sbi->node_inode)) { 567 if (IS_ERR(sbi->node_inode)) {
568 f2fs_msg(sb, KERN_ERR, "Failed to read node inode");
524 err = PTR_ERR(sbi->node_inode); 569 err = PTR_ERR(sbi->node_inode);
525 goto free_nm; 570 goto free_nm;
526 } 571 }
@@ -533,6 +578,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
533 /* read root inode and dentry */ 578 /* read root inode and dentry */
534 root = f2fs_iget(sb, F2FS_ROOT_INO(sbi)); 579 root = f2fs_iget(sb, F2FS_ROOT_INO(sbi));
535 if (IS_ERR(root)) { 580 if (IS_ERR(root)) {
581 f2fs_msg(sb, KERN_ERR, "Failed to read root inode");
536 err = PTR_ERR(root); 582 err = PTR_ERR(root);
537 goto free_node_inode; 583 goto free_node_inode;
538 } 584 }