summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2016-08-02 17:05:10 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-08-02 19:35:17 -0400
commitfeee880fa58254fcc1c78bc8b6446a435cc1baf0 (patch)
treec09328c3d4924f88778ac3d890b038a9fb8c0720
parent6625689e159fa1d43572ee113713ab23bec03131 (diff)
nilfs2: reduce bare use of printk() with nilfs_msg()
Replace most use of printk() in nilfs2 implementation with nilfs_msg(), and reduce the following checkpatch.pl warning: "WARNING: Prefer [subsystem eg: netdev]_crit([subsystem]dev, ... then dev_crit(dev, ... then pr_crit(... to printk(KERN_CRIT ..." This patch also fixes a minor checkpatch warning "WARNING: quoted string split across lines" that often accompanies the prior warning, and amends message format as needed. Link: http://lkml.kernel.org/r/1464875891-5443-5-git-send-email-konishi.ryusuke@lab.ntt.co.jp Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/nilfs2/btree.c58
-rw-r--r--fs/nilfs2/cpfile.c22
-rw-r--r--fs/nilfs2/dat.c19
-rw-r--r--fs/nilfs2/direct.c10
-rw-r--r--fs/nilfs2/inode.c11
-rw-r--r--fs/nilfs2/ioctl.c47
-rw-r--r--fs/nilfs2/recovery.c72
-rw-r--r--fs/nilfs2/segbuf.c6
-rw-r--r--fs/nilfs2/segment.c25
-rw-r--r--fs/nilfs2/sufile.c31
-rw-r--r--fs/nilfs2/super.c100
-rw-r--r--fs/nilfs2/sysfs.c30
-rw-r--r--fs/nilfs2/the_nilfs.c127
13 files changed, 283 insertions, 275 deletions
diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c
index 982d1e3df3a5..2c52693a69a4 100644
--- a/fs/nilfs2/btree.c
+++ b/fs/nilfs2/btree.c
@@ -339,12 +339,14 @@ static int nilfs_btree_node_lookup(const struct nilfs_btree_node *node,
339 * nilfs_btree_node_broken - verify consistency of btree node 339 * nilfs_btree_node_broken - verify consistency of btree node
340 * @node: btree node block to be examined 340 * @node: btree node block to be examined
341 * @size: node size (in bytes) 341 * @size: node size (in bytes)
342 * @inode: host inode of btree
342 * @blocknr: block number 343 * @blocknr: block number
343 * 344 *
344 * Return Value: If node is broken, 1 is returned. Otherwise, 0 is returned. 345 * Return Value: If node is broken, 1 is returned. Otherwise, 0 is returned.
345 */ 346 */
346static int nilfs_btree_node_broken(const struct nilfs_btree_node *node, 347static int nilfs_btree_node_broken(const struct nilfs_btree_node *node,
347 size_t size, sector_t blocknr) 348 size_t size, struct inode *inode,
349 sector_t blocknr)
348{ 350{
349 int level, flags, nchildren; 351 int level, flags, nchildren;
350 int ret = 0; 352 int ret = 0;
@@ -358,9 +360,10 @@ static int nilfs_btree_node_broken(const struct nilfs_btree_node *node,
358 (flags & NILFS_BTREE_NODE_ROOT) || 360 (flags & NILFS_BTREE_NODE_ROOT) ||
359 nchildren < 0 || 361 nchildren < 0 ||
360 nchildren > NILFS_BTREE_NODE_NCHILDREN_MAX(size))) { 362 nchildren > NILFS_BTREE_NODE_NCHILDREN_MAX(size))) {
361 printk(KERN_CRIT "NILFS: bad btree node (blocknr=%llu): " 363 nilfs_msg(inode->i_sb, KERN_CRIT,
362 "level = %d, flags = 0x%x, nchildren = %d\n", 364 "bad btree node (ino=%lu, blocknr=%llu): level = %d, flags = 0x%x, nchildren = %d",
363 (unsigned long long)blocknr, level, flags, nchildren); 365 inode->i_ino, (unsigned long long)blocknr, level,
366 flags, nchildren);
364 ret = 1; 367 ret = 1;
365 } 368 }
366 return ret; 369 return ret;
@@ -369,12 +372,12 @@ static int nilfs_btree_node_broken(const struct nilfs_btree_node *node,
369/** 372/**
370 * nilfs_btree_root_broken - verify consistency of btree root node 373 * nilfs_btree_root_broken - verify consistency of btree root node
371 * @node: btree root node to be examined 374 * @node: btree root node to be examined
372 * @ino: inode number 375 * @inode: host inode of btree
373 * 376 *
374 * Return Value: If node is broken, 1 is returned. Otherwise, 0 is returned. 377 * Return Value: If node is broken, 1 is returned. Otherwise, 0 is returned.
375 */ 378 */
376static int nilfs_btree_root_broken(const struct nilfs_btree_node *node, 379static int nilfs_btree_root_broken(const struct nilfs_btree_node *node,
377 unsigned long ino) 380 struct inode *inode)
378{ 381{
379 int level, flags, nchildren; 382 int level, flags, nchildren;
380 int ret = 0; 383 int ret = 0;
@@ -387,8 +390,9 @@ static int nilfs_btree_root_broken(const struct nilfs_btree_node *node,
387 level >= NILFS_BTREE_LEVEL_MAX || 390 level >= NILFS_BTREE_LEVEL_MAX ||
388 nchildren < 0 || 391 nchildren < 0 ||
389 nchildren > NILFS_BTREE_ROOT_NCHILDREN_MAX)) { 392 nchildren > NILFS_BTREE_ROOT_NCHILDREN_MAX)) {
390 pr_crit("NILFS: bad btree root (inode number=%lu): level = %d, flags = 0x%x, nchildren = %d\n", 393 nilfs_msg(inode->i_sb, KERN_CRIT,
391 ino, level, flags, nchildren); 394 "bad btree root (ino=%lu): level = %d, flags = 0x%x, nchildren = %d",
395 inode->i_ino, level, flags, nchildren);
392 ret = 1; 396 ret = 1;
393 } 397 }
394 return ret; 398 return ret;
@@ -396,13 +400,15 @@ static int nilfs_btree_root_broken(const struct nilfs_btree_node *node,
396 400
397int nilfs_btree_broken_node_block(struct buffer_head *bh) 401int nilfs_btree_broken_node_block(struct buffer_head *bh)
398{ 402{
403 struct inode *inode;
399 int ret; 404 int ret;
400 405
401 if (buffer_nilfs_checked(bh)) 406 if (buffer_nilfs_checked(bh))
402 return 0; 407 return 0;
403 408
409 inode = bh->b_page->mapping->host;
404 ret = nilfs_btree_node_broken((struct nilfs_btree_node *)bh->b_data, 410 ret = nilfs_btree_node_broken((struct nilfs_btree_node *)bh->b_data,
405 bh->b_size, bh->b_blocknr); 411 bh->b_size, inode, bh->b_blocknr);
406 if (likely(!ret)) 412 if (likely(!ret))
407 set_buffer_nilfs_checked(bh); 413 set_buffer_nilfs_checked(bh);
408 return ret; 414 return ret;
@@ -448,13 +454,15 @@ nilfs_btree_get_node(const struct nilfs_bmap *btree,
448 return node; 454 return node;
449} 455}
450 456
451static int 457static int nilfs_btree_bad_node(const struct nilfs_bmap *btree,
452nilfs_btree_bad_node(struct nilfs_btree_node *node, int level) 458 struct nilfs_btree_node *node, int level)
453{ 459{
454 if (unlikely(nilfs_btree_node_get_level(node) != level)) { 460 if (unlikely(nilfs_btree_node_get_level(node) != level)) {
455 dump_stack(); 461 dump_stack();
456 printk(KERN_CRIT "NILFS: btree level mismatch: %d != %d\n", 462 nilfs_msg(btree->b_inode->i_sb, KERN_CRIT,
457 nilfs_btree_node_get_level(node), level); 463 "btree level mismatch (ino=%lu): %d != %d",
464 btree->b_inode->i_ino,
465 nilfs_btree_node_get_level(node), level);
458 return 1; 466 return 1;
459 } 467 }
460 return 0; 468 return 0;
@@ -568,7 +576,7 @@ static int nilfs_btree_do_lookup(const struct nilfs_bmap *btree,
568 return ret; 576 return ret;
569 577
570 node = nilfs_btree_get_nonroot_node(path, level); 578 node = nilfs_btree_get_nonroot_node(path, level);
571 if (nilfs_btree_bad_node(node, level)) 579 if (nilfs_btree_bad_node(btree, node, level))
572 return -EINVAL; 580 return -EINVAL;
573 if (!found) 581 if (!found)
574 found = nilfs_btree_node_lookup(node, key, &index); 582 found = nilfs_btree_node_lookup(node, key, &index);
@@ -616,7 +624,7 @@ static int nilfs_btree_do_lookup_last(const struct nilfs_bmap *btree,
616 if (ret < 0) 624 if (ret < 0)
617 return ret; 625 return ret;
618 node = nilfs_btree_get_nonroot_node(path, level); 626 node = nilfs_btree_get_nonroot_node(path, level);
619 if (nilfs_btree_bad_node(node, level)) 627 if (nilfs_btree_bad_node(btree, node, level))
620 return -EINVAL; 628 return -EINVAL;
621 index = nilfs_btree_node_get_nchildren(node) - 1; 629 index = nilfs_btree_node_get_nchildren(node) - 1;
622 ptr = nilfs_btree_node_get_ptr(node, index, ncmax); 630 ptr = nilfs_btree_node_get_ptr(node, index, ncmax);
@@ -2072,8 +2080,10 @@ static int nilfs_btree_propagate(struct nilfs_bmap *btree,
2072 ret = nilfs_btree_do_lookup(btree, path, key, NULL, level + 1, 0); 2080 ret = nilfs_btree_do_lookup(btree, path, key, NULL, level + 1, 0);
2073 if (ret < 0) { 2081 if (ret < 0) {
2074 if (unlikely(ret == -ENOENT)) 2082 if (unlikely(ret == -ENOENT))
2075 printk(KERN_CRIT "%s: key = %llu, level == %d\n", 2083 nilfs_msg(btree->b_inode->i_sb, KERN_CRIT,
2076 __func__, (unsigned long long)key, level); 2084 "writing node/leaf block does not appear in b-tree (ino=%lu) at key=%llu, level=%d",
2085 btree->b_inode->i_ino,
2086 (unsigned long long)key, level);
2077 goto out; 2087 goto out;
2078 } 2088 }
2079 2089
@@ -2110,12 +2120,11 @@ static void nilfs_btree_add_dirty_buffer(struct nilfs_bmap *btree,
2110 if (level < NILFS_BTREE_LEVEL_NODE_MIN || 2120 if (level < NILFS_BTREE_LEVEL_NODE_MIN ||
2111 level >= NILFS_BTREE_LEVEL_MAX) { 2121 level >= NILFS_BTREE_LEVEL_MAX) {
2112 dump_stack(); 2122 dump_stack();
2113 printk(KERN_WARNING 2123 nilfs_msg(btree->b_inode->i_sb, KERN_WARNING,
2114 "%s: invalid btree level: %d (key=%llu, ino=%lu, " 2124 "invalid btree level: %d (key=%llu, ino=%lu, blocknr=%llu)",
2115 "blocknr=%llu)\n", 2125 level, (unsigned long long)key,
2116 __func__, level, (unsigned long long)key, 2126 btree->b_inode->i_ino,
2117 NILFS_BMAP_I(btree)->vfs_inode.i_ino, 2127 (unsigned long long)bh->b_blocknr);
2118 (unsigned long long)bh->b_blocknr);
2119 return; 2128 return;
2120 } 2129 }
2121 2130
@@ -2394,8 +2403,7 @@ int nilfs_btree_init(struct nilfs_bmap *bmap)
2394 2403
2395 __nilfs_btree_init(bmap); 2404 __nilfs_btree_init(bmap);
2396 2405
2397 if (nilfs_btree_root_broken(nilfs_btree_get_root(bmap), 2406 if (nilfs_btree_root_broken(nilfs_btree_get_root(bmap), bmap->b_inode))
2398 bmap->b_inode->i_ino))
2399 ret = -EIO; 2407 ret = -EIO;
2400 return ret; 2408 return ret;
2401} 2409}
diff --git a/fs/nilfs2/cpfile.c b/fs/nilfs2/cpfile.c
index 8a3d3b65af3f..19d9f4ae8347 100644
--- a/fs/nilfs2/cpfile.c
+++ b/fs/nilfs2/cpfile.c
@@ -332,9 +332,9 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile,
332 int ret, ncps, nicps, nss, count, i; 332 int ret, ncps, nicps, nss, count, i;
333 333
334 if (unlikely(start == 0 || start > end)) { 334 if (unlikely(start == 0 || start > end)) {
335 printk(KERN_ERR "%s: invalid range of checkpoint numbers: " 335 nilfs_msg(cpfile->i_sb, KERN_ERR,
336 "[%llu, %llu)\n", __func__, 336 "cannot delete checkpoints: invalid range [%llu, %llu)",
337 (unsigned long long)start, (unsigned long long)end); 337 (unsigned long long)start, (unsigned long long)end);
338 return -EINVAL; 338 return -EINVAL;
339 } 339 }
340 340
@@ -386,9 +386,9 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile,
386 cpfile, cno); 386 cpfile, cno);
387 if (ret == 0) 387 if (ret == 0)
388 continue; 388 continue;
389 printk(KERN_ERR 389 nilfs_msg(cpfile->i_sb, KERN_ERR,
390 "%s: cannot delete block\n", 390 "error %d deleting checkpoint block",
391 __func__); 391 ret);
392 break; 392 break;
393 } 393 }
394 } 394 }
@@ -991,14 +991,12 @@ int nilfs_cpfile_read(struct super_block *sb, size_t cpsize,
991 int err; 991 int err;
992 992
993 if (cpsize > sb->s_blocksize) { 993 if (cpsize > sb->s_blocksize) {
994 printk(KERN_ERR 994 nilfs_msg(sb, KERN_ERR,
995 "NILFS: too large checkpoint size: %zu bytes.\n", 995 "too large checkpoint size: %zu bytes", cpsize);
996 cpsize);
997 return -EINVAL; 996 return -EINVAL;
998 } else if (cpsize < NILFS_MIN_CHECKPOINT_SIZE) { 997 } else if (cpsize < NILFS_MIN_CHECKPOINT_SIZE) {
999 printk(KERN_ERR 998 nilfs_msg(sb, KERN_ERR,
1000 "NILFS: too small checkpoint size: %zu bytes.\n", 999 "too small checkpoint size: %zu bytes", cpsize);
1001 cpsize);
1002 return -EINVAL; 1000 return -EINVAL;
1003 } 1001 }
1004 1002
diff --git a/fs/nilfs2/dat.c b/fs/nilfs2/dat.c
index 7367610ea807..dffedb2f8817 100644
--- a/fs/nilfs2/dat.c
+++ b/fs/nilfs2/dat.c
@@ -349,10 +349,11 @@ int nilfs_dat_move(struct inode *dat, __u64 vblocknr, sector_t blocknr)
349 kaddr = kmap_atomic(entry_bh->b_page); 349 kaddr = kmap_atomic(entry_bh->b_page);
350 entry = nilfs_palloc_block_get_entry(dat, vblocknr, entry_bh, kaddr); 350 entry = nilfs_palloc_block_get_entry(dat, vblocknr, entry_bh, kaddr);
351 if (unlikely(entry->de_blocknr == cpu_to_le64(0))) { 351 if (unlikely(entry->de_blocknr == cpu_to_le64(0))) {
352 printk(KERN_CRIT "%s: vbn = %llu, [%llu, %llu)\n", __func__, 352 nilfs_msg(dat->i_sb, KERN_CRIT,
353 (unsigned long long)vblocknr, 353 "%s: invalid vblocknr = %llu, [%llu, %llu)",
354 (unsigned long long)le64_to_cpu(entry->de_start), 354 __func__, (unsigned long long)vblocknr,
355 (unsigned long long)le64_to_cpu(entry->de_end)); 355 (unsigned long long)le64_to_cpu(entry->de_start),
356 (unsigned long long)le64_to_cpu(entry->de_end));
356 kunmap_atomic(kaddr); 357 kunmap_atomic(kaddr);
357 brelse(entry_bh); 358 brelse(entry_bh);
358 return -EINVAL; 359 return -EINVAL;
@@ -479,14 +480,12 @@ int nilfs_dat_read(struct super_block *sb, size_t entry_size,
479 int err; 480 int err;
480 481
481 if (entry_size > sb->s_blocksize) { 482 if (entry_size > sb->s_blocksize) {
482 printk(KERN_ERR 483 nilfs_msg(sb, KERN_ERR, "too large DAT entry size: %zu bytes",
483 "NILFS: too large DAT entry size: %zu bytes.\n", 484 entry_size);
484 entry_size);
485 return -EINVAL; 485 return -EINVAL;
486 } else if (entry_size < NILFS_MIN_DAT_ENTRY_SIZE) { 486 } else if (entry_size < NILFS_MIN_DAT_ENTRY_SIZE) {
487 printk(KERN_ERR 487 nilfs_msg(sb, KERN_ERR, "too small DAT entry size: %zu bytes",
488 "NILFS: too small DAT entry size: %zu bytes.\n", 488 entry_size);
489 entry_size);
490 return -EINVAL; 489 return -EINVAL;
491 } 490 }
492 491
diff --git a/fs/nilfs2/direct.c b/fs/nilfs2/direct.c
index 251a44928405..96e3ed0d9652 100644
--- a/fs/nilfs2/direct.c
+++ b/fs/nilfs2/direct.c
@@ -337,14 +337,16 @@ static int nilfs_direct_assign(struct nilfs_bmap *bmap,
337 337
338 key = nilfs_bmap_data_get_key(bmap, *bh); 338 key = nilfs_bmap_data_get_key(bmap, *bh);
339 if (unlikely(key > NILFS_DIRECT_KEY_MAX)) { 339 if (unlikely(key > NILFS_DIRECT_KEY_MAX)) {
340 printk(KERN_CRIT "%s: invalid key: %llu\n", __func__, 340 nilfs_msg(bmap->b_inode->i_sb, KERN_CRIT,
341 (unsigned long long)key); 341 "%s (ino=%lu): invalid key: %llu", __func__,
342 bmap->b_inode->i_ino, (unsigned long long)key);
342 return -EINVAL; 343 return -EINVAL;
343 } 344 }
344 ptr = nilfs_direct_get_ptr(bmap, key); 345 ptr = nilfs_direct_get_ptr(bmap, key);
345 if (unlikely(ptr == NILFS_BMAP_INVALID_PTR)) { 346 if (unlikely(ptr == NILFS_BMAP_INVALID_PTR)) {
346 printk(KERN_CRIT "%s: invalid pointer: %llu\n", __func__, 347 nilfs_msg(bmap->b_inode->i_sb, KERN_CRIT,
347 (unsigned long long)ptr); 348 "%s (ino=%lu): invalid pointer: %llu", __func__,
349 bmap->b_inode->i_ino, (unsigned long long)ptr);
348 return -EINVAL; 350 return -EINVAL;
349 } 351 }
350 352
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index a0ebdb17e912..a965fcf77955 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -112,13 +112,10 @@ int nilfs_get_block(struct inode *inode, sector_t blkoff,
112 * However, the page having this block must 112 * However, the page having this block must
113 * be locked in this case. 113 * be locked in this case.
114 */ 114 */
115 printk(KERN_WARNING 115 nilfs_msg(inode->i_sb, KERN_WARNING,
116 "nilfs_get_block: a race condition " 116 "%s (ino=%lu): a race condition while inserting a data block at offset=%llu",
117 "while inserting a data block. " 117 __func__, inode->i_ino,
118 "(inode number=%lu, file block " 118 (unsigned long long)blkoff);
119 "offset=%llu)\n",
120 inode->i_ino,
121 (unsigned long long)blkoff);
122 err = 0; 119 err = 0;
123 } 120 }
124 nilfs_transaction_abort(inode->i_sb); 121 nilfs_transaction_abort(inode->i_sb);
diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c
index 358b57e2cdf9..827283fe9525 100644
--- a/fs/nilfs2/ioctl.c
+++ b/fs/nilfs2/ioctl.c
@@ -584,27 +584,25 @@ static int nilfs_ioctl_move_inode_block(struct inode *inode,
584 584
585 if (unlikely(ret < 0)) { 585 if (unlikely(ret < 0)) {
586 if (ret == -ENOENT) 586 if (ret == -ENOENT)
587 printk(KERN_CRIT 587 nilfs_msg(inode->i_sb, KERN_CRIT,
588 "%s: invalid virtual block address (%s): " 588 "%s: invalid virtual block address (%s): ino=%llu, cno=%llu, offset=%llu, blocknr=%llu, vblocknr=%llu",
589 "ino=%llu, cno=%llu, offset=%llu, " 589 __func__, vdesc->vd_flags ? "node" : "data",
590 "blocknr=%llu, vblocknr=%llu\n", 590 (unsigned long long)vdesc->vd_ino,
591 __func__, vdesc->vd_flags ? "node" : "data", 591 (unsigned long long)vdesc->vd_cno,
592 (unsigned long long)vdesc->vd_ino, 592 (unsigned long long)vdesc->vd_offset,
593 (unsigned long long)vdesc->vd_cno, 593 (unsigned long long)vdesc->vd_blocknr,
594 (unsigned long long)vdesc->vd_offset, 594 (unsigned long long)vdesc->vd_vblocknr);
595 (unsigned long long)vdesc->vd_blocknr,
596 (unsigned long long)vdesc->vd_vblocknr);
597 return ret; 595 return ret;
598 } 596 }
599 if (unlikely(!list_empty(&bh->b_assoc_buffers))) { 597 if (unlikely(!list_empty(&bh->b_assoc_buffers))) {
600 printk(KERN_CRIT "%s: conflicting %s buffer: ino=%llu, " 598 nilfs_msg(inode->i_sb, KERN_CRIT,
601 "cno=%llu, offset=%llu, blocknr=%llu, vblocknr=%llu\n", 599 "%s: conflicting %s buffer: ino=%llu, cno=%llu, offset=%llu, blocknr=%llu, vblocknr=%llu",
602 __func__, vdesc->vd_flags ? "node" : "data", 600 __func__, vdesc->vd_flags ? "node" : "data",
603 (unsigned long long)vdesc->vd_ino, 601 (unsigned long long)vdesc->vd_ino,
604 (unsigned long long)vdesc->vd_cno, 602 (unsigned long long)vdesc->vd_cno,
605 (unsigned long long)vdesc->vd_offset, 603 (unsigned long long)vdesc->vd_offset,
606 (unsigned long long)vdesc->vd_blocknr, 604 (unsigned long long)vdesc->vd_blocknr,
607 (unsigned long long)vdesc->vd_vblocknr); 605 (unsigned long long)vdesc->vd_vblocknr);
608 brelse(bh); 606 brelse(bh);
609 return -EEXIST; 607 return -EEXIST;
610 } 608 }
@@ -854,8 +852,8 @@ int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *nilfs,
854 return 0; 852 return 0;
855 853
856 failed: 854 failed:
857 printk(KERN_ERR "NILFS: GC failed during preparation: %s: err=%d\n", 855 nilfs_msg(nilfs->ns_sb, KERN_ERR, "error %d preparing GC: %s", ret,
858 msg, ret); 856 msg);
859 return ret; 857 return ret;
860} 858}
861 859
@@ -963,10 +961,11 @@ static int nilfs_ioctl_clean_segments(struct inode *inode, struct file *filp,
963 } 961 }
964 962
965 ret = nilfs_ioctl_move_blocks(inode->i_sb, &argv[0], kbufs[0]); 963 ret = nilfs_ioctl_move_blocks(inode->i_sb, &argv[0], kbufs[0]);
966 if (ret < 0) 964 if (ret < 0) {
967 printk(KERN_ERR "NILFS: GC failed during preparation: " 965 nilfs_msg(inode->i_sb, KERN_ERR,
968 "cannot read source blocks: err=%d\n", ret); 966 "error %d preparing GC: cannot read source blocks",
969 else { 967 ret);
968 } else {
970 if (nilfs_sb_need_update(nilfs)) 969 if (nilfs_sb_need_update(nilfs))
971 set_nilfs_discontinued(nilfs); 970 set_nilfs_discontinued(nilfs);
972 ret = nilfs_clean_segments(inode->i_sb, argv, kbufs); 971 ret = nilfs_clean_segments(inode->i_sb, argv, kbufs);
diff --git a/fs/nilfs2/recovery.c b/fs/nilfs2/recovery.c
index d893dc912b62..5139efed1888 100644
--- a/fs/nilfs2/recovery.c
+++ b/fs/nilfs2/recovery.c
@@ -54,38 +54,37 @@ struct nilfs_recovery_block {
54}; 54};
55 55
56 56
57static int nilfs_warn_segment_error(int err) 57static int nilfs_warn_segment_error(struct super_block *sb, int err)
58{ 58{
59 const char *msg = NULL;
60
59 switch (err) { 61 switch (err) {
60 case NILFS_SEG_FAIL_IO: 62 case NILFS_SEG_FAIL_IO:
61 printk(KERN_WARNING 63 nilfs_msg(sb, KERN_ERR, "I/O error reading segment");
62 "NILFS warning: I/O error on loading last segment\n");
63 return -EIO; 64 return -EIO;
64 case NILFS_SEG_FAIL_MAGIC: 65 case NILFS_SEG_FAIL_MAGIC:
65 printk(KERN_WARNING 66 msg = "Magic number mismatch";
66 "NILFS warning: Segment magic number invalid\n");
67 break; 67 break;
68 case NILFS_SEG_FAIL_SEQ: 68 case NILFS_SEG_FAIL_SEQ:
69 printk(KERN_WARNING 69 msg = "Sequence number mismatch";
70 "NILFS warning: Sequence number mismatch\n");
71 break; 70 break;
72 case NILFS_SEG_FAIL_CHECKSUM_SUPER_ROOT: 71 case NILFS_SEG_FAIL_CHECKSUM_SUPER_ROOT:
73 printk(KERN_WARNING 72 msg = "Checksum error in super root";
74 "NILFS warning: Checksum error in super root\n");
75 break; 73 break;
76 case NILFS_SEG_FAIL_CHECKSUM_FULL: 74 case NILFS_SEG_FAIL_CHECKSUM_FULL:
77 printk(KERN_WARNING 75 msg = "Checksum error in segment payload";
78 "NILFS warning: Checksum error in segment payload\n");
79 break; 76 break;
80 case NILFS_SEG_FAIL_CONSISTENCY: 77 case NILFS_SEG_FAIL_CONSISTENCY:
81 printk(KERN_WARNING 78 msg = "Inconsistency found";
82 "NILFS warning: Inconsistent segment\n");
83 break; 79 break;
84 case NILFS_SEG_NO_SUPER_ROOT: 80 case NILFS_SEG_NO_SUPER_ROOT:
85 printk(KERN_WARNING 81 msg = "No super root in the last segment";
86 "NILFS warning: No super root in the last segment\n");
87 break; 82 break;
83 default:
84 nilfs_msg(sb, KERN_ERR, "unrecognized segment error %d", err);
85 return -EINVAL;
88 } 86 }
87 nilfs_msg(sb, KERN_WARNING, "invalid segment: %s", msg);
89 return -EINVAL; 88 return -EINVAL;
90} 89}
91 90
@@ -178,7 +177,7 @@ int nilfs_read_super_root_block(struct the_nilfs *nilfs, sector_t sr_block,
178 brelse(bh_sr); 177 brelse(bh_sr);
179 178
180 failed: 179 failed:
181 return nilfs_warn_segment_error(ret); 180 return nilfs_warn_segment_error(nilfs->ns_sb, ret);
182} 181}
183 182
184/** 183/**
@@ -553,11 +552,10 @@ static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs,
553 put_page(page); 552 put_page(page);
554 553
555 failed_inode: 554 failed_inode:
556 printk(KERN_WARNING 555 nilfs_msg(sb, KERN_WARNING,
557 "NILFS warning: error recovering data block " 556 "error %d recovering data block (ino=%lu, block-offset=%llu)",
558 "(err=%d, ino=%lu, block-offset=%llu)\n", 557 err, (unsigned long)rb->ino,
559 err, (unsigned long)rb->ino, 558 (unsigned long long)rb->blkoff);
560 (unsigned long long)rb->blkoff);
561 if (!err2) 559 if (!err2)
562 err2 = err; 560 err2 = err;
563 next: 561 next:
@@ -680,8 +678,8 @@ static int nilfs_do_roll_forward(struct the_nilfs *nilfs,
680 } 678 }
681 679
682 if (nsalvaged_blocks) { 680 if (nsalvaged_blocks) {
683 printk(KERN_INFO "NILFS (device %s): salvaged %lu blocks\n", 681 nilfs_msg(sb, KERN_INFO, "salvaged %lu blocks",
684 sb->s_id, nsalvaged_blocks); 682 nsalvaged_blocks);
685 ri->ri_need_recovery = NILFS_RECOVERY_ROLLFORWARD_DONE; 683 ri->ri_need_recovery = NILFS_RECOVERY_ROLLFORWARD_DONE;
686 } 684 }
687 out: 685 out:
@@ -692,10 +690,9 @@ static int nilfs_do_roll_forward(struct the_nilfs *nilfs,
692 confused: 690 confused:
693 err = -EINVAL; 691 err = -EINVAL;
694 failed: 692 failed:
695 printk(KERN_ERR 693 nilfs_msg(sb, KERN_ERR,
696 "NILFS (device %s): Error roll-forwarding " 694 "error %d roll-forwarding partial segment at blocknr = %llu",
697 "(err=%d, pseg block=%llu). ", 695 err, (unsigned long long)pseg_start);
698 sb->s_id, err, (unsigned long long)pseg_start);
699 goto out; 696 goto out;
700} 697}
701 698
@@ -715,9 +712,8 @@ static void nilfs_finish_roll_forward(struct the_nilfs *nilfs,
715 set_buffer_dirty(bh); 712 set_buffer_dirty(bh);
716 err = sync_dirty_buffer(bh); 713 err = sync_dirty_buffer(bh);
717 if (unlikely(err)) 714 if (unlikely(err))
718 printk(KERN_WARNING 715 nilfs_msg(nilfs->ns_sb, KERN_WARNING,
719 "NILFS warning: buffer sync write failed during " 716 "buffer sync write failed during post-cleaning of recovery.");
720 "post-cleaning of recovery.\n");
721 brelse(bh); 717 brelse(bh);
722} 718}
723 719
@@ -752,8 +748,8 @@ int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs,
752 748
753 err = nilfs_attach_checkpoint(sb, ri->ri_cno, true, &root); 749 err = nilfs_attach_checkpoint(sb, ri->ri_cno, true, &root);
754 if (unlikely(err)) { 750 if (unlikely(err)) {
755 printk(KERN_ERR 751 nilfs_msg(sb, KERN_ERR,
756 "NILFS: error loading the latest checkpoint.\n"); 752 "error %d loading the latest checkpoint", err);
757 return err; 753 return err;
758 } 754 }
759 755
@@ -764,8 +760,9 @@ int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs,
764 if (ri->ri_need_recovery == NILFS_RECOVERY_ROLLFORWARD_DONE) { 760 if (ri->ri_need_recovery == NILFS_RECOVERY_ROLLFORWARD_DONE) {
765 err = nilfs_prepare_segment_for_recovery(nilfs, sb, ri); 761 err = nilfs_prepare_segment_for_recovery(nilfs, sb, ri);
766 if (unlikely(err)) { 762 if (unlikely(err)) {
767 printk(KERN_ERR "NILFS: Error preparing segments for " 763 nilfs_msg(sb, KERN_ERR,
768 "recovery.\n"); 764 "error %d preparing segment for recovery",
765 err);
769 goto failed; 766 goto failed;
770 } 767 }
771 768
@@ -778,8 +775,9 @@ int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs,
778 nilfs_detach_log_writer(sb); 775 nilfs_detach_log_writer(sb);
779 776
780 if (unlikely(err)) { 777 if (unlikely(err)) {
781 printk(KERN_ERR "NILFS: Oops! recovery failed. " 778 nilfs_msg(sb, KERN_ERR,
782 "(err=%d)\n", err); 779 "error %d writing segment for recovery",
780 err);
783 goto failed; 781 goto failed;
784 } 782 }
785 783
@@ -961,5 +959,5 @@ int nilfs_search_super_root(struct the_nilfs *nilfs,
961 failed: 959 failed:
962 brelse(bh_sum); 960 brelse(bh_sum);
963 nilfs_dispose_segment_list(&segments); 961 nilfs_dispose_segment_list(&segments);
964 return (ret < 0) ? ret : nilfs_warn_segment_error(ret); 962 return ret < 0 ? ret : nilfs_warn_segment_error(nilfs->ns_sb, ret);
965} 963}
diff --git a/fs/nilfs2/segbuf.c b/fs/nilfs2/segbuf.c
index a962d7d83447..6f87b2ac1aeb 100644
--- a/fs/nilfs2/segbuf.c
+++ b/fs/nilfs2/segbuf.c
@@ -514,7 +514,11 @@ static int nilfs_segbuf_wait(struct nilfs_segment_buffer *segbuf)
514 } while (--segbuf->sb_nbio > 0); 514 } while (--segbuf->sb_nbio > 0);
515 515
516 if (unlikely(atomic_read(&segbuf->sb_err) > 0)) { 516 if (unlikely(atomic_read(&segbuf->sb_err) > 0)) {
517 printk(KERN_ERR "NILFS: IO error writing segment\n"); 517 nilfs_msg(segbuf->sb_super, KERN_ERR,
518 "I/O error writing log (start-blocknr=%llu, block-count=%lu) in segment %llu",
519 (unsigned long long)segbuf->sb_pseg_start,
520 segbuf->sb_sum.nblocks,
521 (unsigned long long)segbuf->sb_segnum);
518 err = -EIO; 522 err = -EIO;
519 } 523 }
520 return err; 524 return err;
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
index e78b68a81aec..1cc968502e53 100644
--- a/fs/nilfs2/segment.c
+++ b/fs/nilfs2/segment.c
@@ -150,7 +150,8 @@ static void nilfs_dispose_list(struct the_nilfs *, struct list_head *, int);
150#define nilfs_cnt32_lt(a, b) nilfs_cnt32_gt(b, a) 150#define nilfs_cnt32_lt(a, b) nilfs_cnt32_gt(b, a)
151#define nilfs_cnt32_le(a, b) nilfs_cnt32_ge(b, a) 151#define nilfs_cnt32_le(a, b) nilfs_cnt32_ge(b, a)
152 152
153static int nilfs_prepare_segment_lock(struct nilfs_transaction_info *ti) 153static int nilfs_prepare_segment_lock(struct super_block *sb,
154 struct nilfs_transaction_info *ti)
154{ 155{
155 struct nilfs_transaction_info *cur_ti = current->journal_info; 156 struct nilfs_transaction_info *cur_ti = current->journal_info;
156 void *save = NULL; 157 void *save = NULL;
@@ -164,8 +165,7 @@ static int nilfs_prepare_segment_lock(struct nilfs_transaction_info *ti)
164 * it is saved and will be restored on 165 * it is saved and will be restored on
165 * nilfs_transaction_commit(). 166 * nilfs_transaction_commit().
166 */ 167 */
167 printk(KERN_WARNING 168 nilfs_msg(sb, KERN_WARNING, "journal info from a different FS");
168 "NILFS warning: journal info from a different FS\n");
169 save = current->journal_info; 169 save = current->journal_info;
170 } 170 }
171 if (!ti) { 171 if (!ti) {
@@ -215,7 +215,7 @@ int nilfs_transaction_begin(struct super_block *sb,
215 int vacancy_check) 215 int vacancy_check)
216{ 216{
217 struct the_nilfs *nilfs; 217 struct the_nilfs *nilfs;
218 int ret = nilfs_prepare_segment_lock(ti); 218 int ret = nilfs_prepare_segment_lock(sb, ti);
219 struct nilfs_transaction_info *trace_ti; 219 struct nilfs_transaction_info *trace_ti;
220 220
221 if (unlikely(ret < 0)) 221 if (unlikely(ret < 0))
@@ -2467,9 +2467,9 @@ int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv,
2467 int ret = nilfs_discard_segments(nilfs, sci->sc_freesegs, 2467 int ret = nilfs_discard_segments(nilfs, sci->sc_freesegs,
2468 sci->sc_nfreesegs); 2468 sci->sc_nfreesegs);
2469 if (ret) { 2469 if (ret) {
2470 printk(KERN_WARNING 2470 nilfs_msg(sb, KERN_WARNING,
2471 "NILFS warning: error %d on discard request, " 2471 "error %d on discard request, turning discards off for the device",
2472 "turning discards off for the device\n", ret); 2472 ret);
2473 nilfs_clear_opt(nilfs, DISCARD); 2473 nilfs_clear_opt(nilfs, DISCARD);
2474 } 2474 }
2475 } 2475 }
@@ -2551,10 +2551,9 @@ static int nilfs_segctor_thread(void *arg)
2551 /* start sync. */ 2551 /* start sync. */
2552 sci->sc_task = current; 2552 sci->sc_task = current;
2553 wake_up(&sci->sc_wait_task); /* for nilfs_segctor_start_thread() */ 2553 wake_up(&sci->sc_wait_task); /* for nilfs_segctor_start_thread() */
2554 printk(KERN_INFO 2554 nilfs_msg(sci->sc_super, KERN_INFO,
2555 "segctord starting. Construction interval = %lu seconds, " 2555 "segctord starting. Construction interval = %lu seconds, CP frequency < %lu seconds",
2556 "CP frequency < %lu seconds\n", 2556 sci->sc_interval / HZ, sci->sc_mjcp_freq / HZ);
2557 sci->sc_interval / HZ, sci->sc_mjcp_freq / HZ);
2558 2557
2559 spin_lock(&sci->sc_state_lock); 2558 spin_lock(&sci->sc_state_lock);
2560 loop: 2559 loop:
@@ -2628,8 +2627,8 @@ static int nilfs_segctor_start_thread(struct nilfs_sc_info *sci)
2628 if (IS_ERR(t)) { 2627 if (IS_ERR(t)) {
2629 int err = PTR_ERR(t); 2628 int err = PTR_ERR(t);
2630 2629
2631 printk(KERN_ERR "NILFS: error %d creating segctord thread\n", 2630 nilfs_msg(sci->sc_super, KERN_ERR,
2632 err); 2631 "error %d creating segctord thread", err);
2633 return err; 2632 return err;
2634 } 2633 }
2635 wait_event(sci->sc_wait_task, sci->sc_task != NULL); 2634 wait_event(sci->sc_wait_task, sci->sc_task != NULL);
diff --git a/fs/nilfs2/sufile.c b/fs/nilfs2/sufile.c
index 1963595a1580..5b495c469471 100644
--- a/fs/nilfs2/sufile.c
+++ b/fs/nilfs2/sufile.c
@@ -181,9 +181,9 @@ int nilfs_sufile_updatev(struct inode *sufile, __u64 *segnumv, size_t nsegs,
181 down_write(&NILFS_MDT(sufile)->mi_sem); 181 down_write(&NILFS_MDT(sufile)->mi_sem);
182 for (seg = segnumv; seg < segnumv + nsegs; seg++) { 182 for (seg = segnumv; seg < segnumv + nsegs; seg++) {
183 if (unlikely(*seg >= nilfs_sufile_get_nsegments(sufile))) { 183 if (unlikely(*seg >= nilfs_sufile_get_nsegments(sufile))) {
184 printk(KERN_WARNING 184 nilfs_msg(sufile->i_sb, KERN_WARNING,
185 "%s: invalid segment number: %llu\n", __func__, 185 "%s: invalid segment number: %llu",
186 (unsigned long long)*seg); 186 __func__, (unsigned long long)*seg);
187 nerr++; 187 nerr++;
188 } 188 }
189 } 189 }
@@ -240,8 +240,9 @@ int nilfs_sufile_update(struct inode *sufile, __u64 segnum, int create,
240 int ret; 240 int ret;
241 241
242 if (unlikely(segnum >= nilfs_sufile_get_nsegments(sufile))) { 242 if (unlikely(segnum >= nilfs_sufile_get_nsegments(sufile))) {
243 printk(KERN_WARNING "%s: invalid segment number: %llu\n", 243 nilfs_msg(sufile->i_sb, KERN_WARNING,
244 __func__, (unsigned long long)segnum); 244 "%s: invalid segment number: %llu",
245 __func__, (unsigned long long)segnum);
245 return -EINVAL; 246 return -EINVAL;
246 } 247 }
247 down_write(&NILFS_MDT(sufile)->mi_sem); 248 down_write(&NILFS_MDT(sufile)->mi_sem);
@@ -419,8 +420,9 @@ void nilfs_sufile_do_cancel_free(struct inode *sufile, __u64 segnum,
419 kaddr = kmap_atomic(su_bh->b_page); 420 kaddr = kmap_atomic(su_bh->b_page);
420 su = nilfs_sufile_block_get_segment_usage(sufile, segnum, su_bh, kaddr); 421 su = nilfs_sufile_block_get_segment_usage(sufile, segnum, su_bh, kaddr);
421 if (unlikely(!nilfs_segment_usage_clean(su))) { 422 if (unlikely(!nilfs_segment_usage_clean(su))) {
422 printk(KERN_WARNING "%s: segment %llu must be clean\n", 423 nilfs_msg(sufile->i_sb, KERN_WARNING,
423 __func__, (unsigned long long)segnum); 424 "%s: segment %llu must be clean", __func__,
425 (unsigned long long)segnum);
424 kunmap_atomic(kaddr); 426 kunmap_atomic(kaddr);
425 return; 427 return;
426 } 428 }
@@ -476,8 +478,9 @@ void nilfs_sufile_do_free(struct inode *sufile, __u64 segnum,
476 kaddr = kmap_atomic(su_bh->b_page); 478 kaddr = kmap_atomic(su_bh->b_page);
477 su = nilfs_sufile_block_get_segment_usage(sufile, segnum, su_bh, kaddr); 479 su = nilfs_sufile_block_get_segment_usage(sufile, segnum, su_bh, kaddr);
478 if (nilfs_segment_usage_clean(su)) { 480 if (nilfs_segment_usage_clean(su)) {
479 printk(KERN_WARNING "%s: segment %llu is already clean\n", 481 nilfs_msg(sufile->i_sb, KERN_WARNING,
480 __func__, (unsigned long long)segnum); 482 "%s: segment %llu is already clean",
483 __func__, (unsigned long long)segnum);
481 kunmap_atomic(kaddr); 484 kunmap_atomic(kaddr);
482 return; 485 return;
483 } 486 }
@@ -1175,14 +1178,12 @@ int nilfs_sufile_read(struct super_block *sb, size_t susize,
1175 int err; 1178 int err;
1176 1179
1177 if (susize > sb->s_blocksize) { 1180 if (susize > sb->s_blocksize) {
1178 printk(KERN_ERR 1181 nilfs_msg(sb, KERN_ERR,
1179 "NILFS: too large segment usage size: %zu bytes.\n", 1182 "too large segment usage size: %zu bytes", susize);
1180 susize);
1181 return -EINVAL; 1183 return -EINVAL;
1182 } else if (susize < NILFS_MIN_SEGMENT_USAGE_SIZE) { 1184 } else if (susize < NILFS_MIN_SEGMENT_USAGE_SIZE) {
1183 printk(KERN_ERR 1185 nilfs_msg(sb, KERN_ERR,
1184 "NILFS: too small segment usage size: %zu bytes.\n", 1186 "too small segment usage size: %zu bytes", susize);
1185 susize);
1186 return -EINVAL; 1187 return -EINVAL;
1187 } 1188 }
1188 1189
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 2d4d0bec711e..90c62b489857 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -214,8 +214,8 @@ static int nilfs_sync_super(struct super_block *sb, int flag)
214 } 214 }
215 215
216 if (unlikely(err)) { 216 if (unlikely(err)) {
217 printk(KERN_ERR 217 nilfs_msg(sb, KERN_ERR, "unable to write superblock: err=%d",
218 "NILFS: unable to write superblock (err=%d)\n", err); 218 err);
219 if (err == -EIO && nilfs->ns_sbh[1]) { 219 if (err == -EIO && nilfs->ns_sbh[1]) {
220 /* 220 /*
221 * sbp[0] points to newer log than sbp[1], 221 * sbp[0] points to newer log than sbp[1],
@@ -285,8 +285,7 @@ struct nilfs_super_block **nilfs_prepare_super(struct super_block *sb,
285 sbp[1]->s_magic == cpu_to_le16(NILFS_SUPER_MAGIC)) { 285 sbp[1]->s_magic == cpu_to_le16(NILFS_SUPER_MAGIC)) {
286 memcpy(sbp[0], sbp[1], nilfs->ns_sbsize); 286 memcpy(sbp[0], sbp[1], nilfs->ns_sbsize);
287 } else { 287 } else {
288 printk(KERN_CRIT "NILFS: superblock broke on dev %s\n", 288 nilfs_msg(sb, KERN_CRIT, "superblock broke");
289 sb->s_id);
290 return NULL; 289 return NULL;
291 } 290 }
292 } else if (sbp[1] && 291 } else if (sbp[1] &&
@@ -396,9 +395,9 @@ static int nilfs_move_2nd_super(struct super_block *sb, loff_t sb2off)
396 offset = sb2off & (nilfs->ns_blocksize - 1); 395 offset = sb2off & (nilfs->ns_blocksize - 1);
397 nsbh = sb_getblk(sb, newblocknr); 396 nsbh = sb_getblk(sb, newblocknr);
398 if (!nsbh) { 397 if (!nsbh) {
399 printk(KERN_WARNING 398 nilfs_msg(sb, KERN_WARNING,
400 "NILFS warning: unable to move secondary superblock " 399 "unable to move secondary superblock to block %llu",
401 "to block %llu\n", (unsigned long long)newblocknr); 400 (unsigned long long)newblocknr);
402 ret = -EIO; 401 ret = -EIO;
403 goto out; 402 goto out;
404 } 403 }
@@ -561,10 +560,9 @@ int nilfs_attach_checkpoint(struct super_block *sb, __u64 cno, int curr_mnt,
561 up_read(&nilfs->ns_segctor_sem); 560 up_read(&nilfs->ns_segctor_sem);
562 if (unlikely(err)) { 561 if (unlikely(err)) {
563 if (err == -ENOENT || err == -EINVAL) { 562 if (err == -ENOENT || err == -EINVAL) {
564 printk(KERN_ERR 563 nilfs_msg(sb, KERN_ERR,
565 "NILFS: Invalid checkpoint " 564 "Invalid checkpoint (checkpoint number=%llu)",
566 "(checkpoint number=%llu)\n", 565 (unsigned long long)cno);
567 (unsigned long long)cno);
568 err = -EINVAL; 566 err = -EINVAL;
569 } 567 }
570 goto failed; 568 goto failed;
@@ -660,9 +658,8 @@ static int nilfs_statfs(struct dentry *dentry, struct kstatfs *buf)
660 err = nilfs_ifile_count_free_inodes(root->ifile, 658 err = nilfs_ifile_count_free_inodes(root->ifile,
661 &nmaxinodes, &nfreeinodes); 659 &nmaxinodes, &nfreeinodes);
662 if (unlikely(err)) { 660 if (unlikely(err)) {
663 printk(KERN_WARNING 661 nilfs_msg(sb, KERN_WARNING,
664 "NILFS warning: fail to count free inodes: err %d.\n", 662 "failed to count free inodes: err=%d", err);
665 err);
666 if (err == -ERANGE) { 663 if (err == -ERANGE) {
667 /* 664 /*
668 * If nilfs_palloc_count_max_entries() returns 665 * If nilfs_palloc_count_max_entries() returns
@@ -794,9 +791,9 @@ static int parse_options(char *options, struct super_block *sb, int is_remount)
794 break; 791 break;
795 case Opt_snapshot: 792 case Opt_snapshot:
796 if (is_remount) { 793 if (is_remount) {
797 printk(KERN_ERR 794 nilfs_msg(sb, KERN_ERR,
798 "NILFS: \"%s\" option is invalid " 795 "\"%s\" option is invalid for remount",
799 "for remount.\n", p); 796 p);
800 return 0; 797 return 0;
801 } 798 }
802 break; 799 break;
@@ -810,8 +807,8 @@ static int parse_options(char *options, struct super_block *sb, int is_remount)
810 nilfs_clear_opt(nilfs, DISCARD); 807 nilfs_clear_opt(nilfs, DISCARD);
811 break; 808 break;
812 default: 809 default:
813 printk(KERN_ERR 810 nilfs_msg(sb, KERN_ERR,
814 "NILFS: Unrecognized mount option \"%s\"\n", p); 811 "unrecognized mount option \"%s\"", p);
815 return 0; 812 return 0;
816 } 813 }
817 } 814 }
@@ -847,12 +844,10 @@ static int nilfs_setup_super(struct super_block *sb, int is_mount)
847 mnt_count = le16_to_cpu(sbp[0]->s_mnt_count); 844 mnt_count = le16_to_cpu(sbp[0]->s_mnt_count);
848 845
849 if (nilfs->ns_mount_state & NILFS_ERROR_FS) { 846 if (nilfs->ns_mount_state & NILFS_ERROR_FS) {
850 printk(KERN_WARNING 847 nilfs_msg(sb, KERN_WARNING, "mounting fs with errors");
851 "NILFS warning: mounting fs with errors\n");
852#if 0 848#if 0
853 } else if (max_mnt_count >= 0 && mnt_count >= max_mnt_count) { 849 } else if (max_mnt_count >= 0 && mnt_count >= max_mnt_count) {
854 printk(KERN_WARNING 850 nilfs_msg(sb, KERN_WARNING, "maximal mount count reached");
855 "NILFS warning: maximal mount count reached\n");
856#endif 851#endif
857 } 852 }
858 if (!max_mnt_count) 853 if (!max_mnt_count)
@@ -915,17 +910,17 @@ int nilfs_check_feature_compatibility(struct super_block *sb,
915 features = le64_to_cpu(sbp->s_feature_incompat) & 910 features = le64_to_cpu(sbp->s_feature_incompat) &
916 ~NILFS_FEATURE_INCOMPAT_SUPP; 911 ~NILFS_FEATURE_INCOMPAT_SUPP;
917 if (features) { 912 if (features) {
918 printk(KERN_ERR "NILFS: couldn't mount because of unsupported " 913 nilfs_msg(sb, KERN_ERR,
919 "optional features (%llx)\n", 914 "couldn't mount because of unsupported optional features (%llx)",
920 (unsigned long long)features); 915 (unsigned long long)features);
921 return -EINVAL; 916 return -EINVAL;
922 } 917 }
923 features = le64_to_cpu(sbp->s_feature_compat_ro) & 918 features = le64_to_cpu(sbp->s_feature_compat_ro) &
924 ~NILFS_FEATURE_COMPAT_RO_SUPP; 919 ~NILFS_FEATURE_COMPAT_RO_SUPP;
925 if (!(sb->s_flags & MS_RDONLY) && features) { 920 if (!(sb->s_flags & MS_RDONLY) && features) {
926 printk(KERN_ERR "NILFS: couldn't mount RDWR because of " 921 nilfs_msg(sb, KERN_ERR,
927 "unsupported optional features (%llx)\n", 922 "couldn't mount RDWR because of unsupported optional features (%llx)",
928 (unsigned long long)features); 923 (unsigned long long)features);
929 return -EINVAL; 924 return -EINVAL;
930 } 925 }
931 return 0; 926 return 0;
@@ -941,13 +936,13 @@ static int nilfs_get_root_dentry(struct super_block *sb,
941 936
942 inode = nilfs_iget(sb, root, NILFS_ROOT_INO); 937 inode = nilfs_iget(sb, root, NILFS_ROOT_INO);
943 if (IS_ERR(inode)) { 938 if (IS_ERR(inode)) {
944 printk(KERN_ERR "NILFS: get root inode failed\n");
945 ret = PTR_ERR(inode); 939 ret = PTR_ERR(inode);
940 nilfs_msg(sb, KERN_ERR, "error %d getting root inode", ret);
946 goto out; 941 goto out;
947 } 942 }
948 if (!S_ISDIR(inode->i_mode) || !inode->i_blocks || !inode->i_size) { 943 if (!S_ISDIR(inode->i_mode) || !inode->i_blocks || !inode->i_size) {
949 iput(inode); 944 iput(inode);
950 printk(KERN_ERR "NILFS: corrupt root inode.\n"); 945 nilfs_msg(sb, KERN_ERR, "corrupt root inode");
951 ret = -EINVAL; 946 ret = -EINVAL;
952 goto out; 947 goto out;
953 } 948 }
@@ -975,7 +970,7 @@ static int nilfs_get_root_dentry(struct super_block *sb,
975 return ret; 970 return ret;
976 971
977 failed_dentry: 972 failed_dentry:
978 printk(KERN_ERR "NILFS: get root dentry failed\n"); 973 nilfs_msg(sb, KERN_ERR, "error %d getting root dentry", ret);
979 goto out; 974 goto out;
980} 975}
981 976
@@ -995,18 +990,18 @@ static int nilfs_attach_snapshot(struct super_block *s, __u64 cno,
995 ret = (ret == -ENOENT) ? -EINVAL : ret; 990 ret = (ret == -ENOENT) ? -EINVAL : ret;
996 goto out; 991 goto out;
997 } else if (!ret) { 992 } else if (!ret) {
998 printk(KERN_ERR "NILFS: The specified checkpoint is " 993 nilfs_msg(s, KERN_ERR,
999 "not a snapshot (checkpoint number=%llu).\n", 994 "The specified checkpoint is not a snapshot (checkpoint number=%llu)",
1000 (unsigned long long)cno); 995 (unsigned long long)cno);
1001 ret = -EINVAL; 996 ret = -EINVAL;
1002 goto out; 997 goto out;
1003 } 998 }
1004 999
1005 ret = nilfs_attach_checkpoint(s, cno, false, &root); 1000 ret = nilfs_attach_checkpoint(s, cno, false, &root);
1006 if (ret) { 1001 if (ret) {
1007 printk(KERN_ERR "NILFS: error loading snapshot " 1002 nilfs_msg(s, KERN_ERR,
1008 "(checkpoint number=%llu).\n", 1003 "error %d while loading snapshot (checkpoint number=%llu)",
1009 (unsigned long long)cno); 1004 ret, (unsigned long long)cno);
1010 goto out; 1005 goto out;
1011 } 1006 }
1012 ret = nilfs_get_root_dentry(s, root, root_dentry); 1007 ret = nilfs_get_root_dentry(s, root, root_dentry);
@@ -1101,8 +1096,9 @@ nilfs_fill_super(struct super_block *sb, void *data, int silent)
1101 cno = nilfs_last_cno(nilfs); 1096 cno = nilfs_last_cno(nilfs);
1102 err = nilfs_attach_checkpoint(sb, cno, true, &fsroot); 1097 err = nilfs_attach_checkpoint(sb, cno, true, &fsroot);
1103 if (err) { 1098 if (err) {
1104 printk(KERN_ERR "NILFS: error loading last checkpoint " 1099 nilfs_msg(sb, KERN_ERR,
1105 "(checkpoint number=%llu).\n", (unsigned long long)cno); 1100 "error %d while loading last checkpoint (checkpoint number=%llu)",
1101 err, (unsigned long long)cno);
1106 goto failed_unload; 1102 goto failed_unload;
1107 } 1103 }
1108 1104
@@ -1162,9 +1158,8 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data)
1162 err = -EINVAL; 1158 err = -EINVAL;
1163 1159
1164 if (!nilfs_valid_fs(nilfs)) { 1160 if (!nilfs_valid_fs(nilfs)) {
1165 printk(KERN_WARNING "NILFS (device %s): couldn't " 1161 nilfs_msg(sb, KERN_WARNING,
1166 "remount because the filesystem is in an " 1162 "couldn't remount because the filesystem is in an incomplete recovery state");
1167 "incomplete recovery state.\n", sb->s_id);
1168 goto restore_opts; 1163 goto restore_opts;
1169 } 1164 }
1170 1165
@@ -1196,10 +1191,9 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data)
1196 ~NILFS_FEATURE_COMPAT_RO_SUPP; 1191 ~NILFS_FEATURE_COMPAT_RO_SUPP;
1197 up_read(&nilfs->ns_sem); 1192 up_read(&nilfs->ns_sem);
1198 if (features) { 1193 if (features) {
1199 printk(KERN_WARNING "NILFS (device %s): couldn't " 1194 nilfs_msg(sb, KERN_WARNING,
1200 "remount RDWR because of unsupported optional " 1195 "couldn't remount RDWR because of unsupported optional features (%llx)",
1201 "features (%llx)\n", 1196 (unsigned long long)features);
1202 sb->s_id, (unsigned long long)features);
1203 err = -EROFS; 1197 err = -EROFS;
1204 goto restore_opts; 1198 goto restore_opts;
1205 } 1199 }
@@ -1262,8 +1256,8 @@ static int nilfs_identify(char *data, struct nilfs_super_data *sd)
1262 } 1256 }
1263 } 1257 }
1264 if (ret) 1258 if (ret)
1265 printk(KERN_ERR 1259 nilfs_msg(NULL, KERN_ERR,
1266 "NILFS: invalid mount option: %s\n", p); 1260 "invalid mount option: %s", p);
1267 } 1261 }
1268 if (!options) 1262 if (!options)
1269 break; 1263 break;
@@ -1344,10 +1338,10 @@ nilfs_mount(struct file_system_type *fs_type, int flags,
1344 } else if (!sd.cno) { 1338 } else if (!sd.cno) {
1345 if (nilfs_tree_is_busy(s->s_root)) { 1339 if (nilfs_tree_is_busy(s->s_root)) {
1346 if ((flags ^ s->s_flags) & MS_RDONLY) { 1340 if ((flags ^ s->s_flags) & MS_RDONLY) {
1347 printk(KERN_ERR "NILFS: the device already " 1341 nilfs_msg(s, KERN_ERR,
1348 "has a %s mount.\n", 1342 "the device already has a %s mount.",
1349 (s->s_flags & MS_RDONLY) ? 1343 (s->s_flags & MS_RDONLY) ?
1350 "read-only" : "read/write"); 1344 "read-only" : "read/write");
1351 err = -EBUSY; 1345 err = -EBUSY;
1352 goto failed_super; 1346 goto failed_super;
1353 } 1347 }
diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c
index 8ffa42b704d8..8e57bb91fe16 100644
--- a/fs/nilfs2/sysfs.c
+++ b/fs/nilfs2/sysfs.c
@@ -272,8 +272,8 @@ nilfs_checkpoints_checkpoints_number_show(struct nilfs_checkpoints_attr *attr,
272 err = nilfs_cpfile_get_stat(nilfs->ns_cpfile, &cpstat); 272 err = nilfs_cpfile_get_stat(nilfs->ns_cpfile, &cpstat);
273 up_read(&nilfs->ns_segctor_sem); 273 up_read(&nilfs->ns_segctor_sem);
274 if (err < 0) { 274 if (err < 0) {
275 printk(KERN_ERR "NILFS: unable to get checkpoint stat: err=%d\n", 275 nilfs_msg(nilfs->ns_sb, KERN_ERR,
276 err); 276 "unable to get checkpoint stat: err=%d", err);
277 return err; 277 return err;
278 } 278 }
279 279
@@ -295,8 +295,8 @@ nilfs_checkpoints_snapshots_number_show(struct nilfs_checkpoints_attr *attr,
295 err = nilfs_cpfile_get_stat(nilfs->ns_cpfile, &cpstat); 295 err = nilfs_cpfile_get_stat(nilfs->ns_cpfile, &cpstat);
296 up_read(&nilfs->ns_segctor_sem); 296 up_read(&nilfs->ns_segctor_sem);
297 if (err < 0) { 297 if (err < 0) {
298 printk(KERN_ERR "NILFS: unable to get checkpoint stat: err=%d\n", 298 nilfs_msg(nilfs->ns_sb, KERN_ERR,
299 err); 299 "unable to get checkpoint stat: err=%d", err);
300 return err; 300 return err;
301 } 301 }
302 302
@@ -414,8 +414,8 @@ nilfs_segments_dirty_segments_show(struct nilfs_segments_attr *attr,
414 err = nilfs_sufile_get_stat(nilfs->ns_sufile, &sustat); 414 err = nilfs_sufile_get_stat(nilfs->ns_sufile, &sustat);
415 up_read(&nilfs->ns_segctor_sem); 415 up_read(&nilfs->ns_segctor_sem);
416 if (err < 0) { 416 if (err < 0) {
417 printk(KERN_ERR "NILFS: unable to get segment stat: err=%d\n", 417 nilfs_msg(nilfs->ns_sb, KERN_ERR,
418 err); 418 "unable to get segment stat: err=%d", err);
419 return err; 419 return err;
420 } 420 }
421 421
@@ -789,14 +789,15 @@ nilfs_superblock_sb_update_frequency_store(struct nilfs_superblock_attr *attr,
789 789
790 err = kstrtouint(skip_spaces(buf), 0, &val); 790 err = kstrtouint(skip_spaces(buf), 0, &val);
791 if (err) { 791 if (err) {
792 printk(KERN_ERR "NILFS: unable to convert string: err=%d\n", 792 nilfs_msg(nilfs->ns_sb, KERN_ERR,
793 err); 793 "unable to convert string: err=%d", err);
794 return err; 794 return err;
795 } 795 }
796 796
797 if (val < NILFS_SB_FREQ) { 797 if (val < NILFS_SB_FREQ) {
798 val = NILFS_SB_FREQ; 798 val = NILFS_SB_FREQ;
799 printk(KERN_WARNING "NILFS: superblock update frequency cannot be lesser than 10 seconds\n"); 799 nilfs_msg(nilfs->ns_sb, KERN_WARNING,
800 "superblock update frequency cannot be lesser than 10 seconds");
800 } 801 }
801 802
802 down_write(&nilfs->ns_sem); 803 down_write(&nilfs->ns_sem);
@@ -999,7 +1000,8 @@ int nilfs_sysfs_create_device_group(struct super_block *sb)
999 nilfs->ns_dev_subgroups = kzalloc(devgrp_size, GFP_KERNEL); 1000 nilfs->ns_dev_subgroups = kzalloc(devgrp_size, GFP_KERNEL);
1000 if (unlikely(!nilfs->ns_dev_subgroups)) { 1001 if (unlikely(!nilfs->ns_dev_subgroups)) {
1001 err = -ENOMEM; 1002 err = -ENOMEM;
1002 printk(KERN_ERR "NILFS: unable to allocate memory for device group\n"); 1003 nilfs_msg(sb, KERN_ERR,
1004 "unable to allocate memory for device group");
1003 goto failed_create_device_group; 1005 goto failed_create_device_group;
1004 } 1006 }
1005 1007
@@ -1109,15 +1111,15 @@ int __init nilfs_sysfs_init(void)
1109 nilfs_kset = kset_create_and_add(NILFS_ROOT_GROUP_NAME, NULL, fs_kobj); 1111 nilfs_kset = kset_create_and_add(NILFS_ROOT_GROUP_NAME, NULL, fs_kobj);
1110 if (!nilfs_kset) { 1112 if (!nilfs_kset) {
1111 err = -ENOMEM; 1113 err = -ENOMEM;
1112 printk(KERN_ERR "NILFS: unable to create sysfs entry: err %d\n", 1114 nilfs_msg(NULL, KERN_ERR,
1113 err); 1115 "unable to create sysfs entry: err=%d", err);
1114 goto failed_sysfs_init; 1116 goto failed_sysfs_init;
1115 } 1117 }
1116 1118
1117 err = sysfs_create_group(&nilfs_kset->kobj, &nilfs_feature_attr_group); 1119 err = sysfs_create_group(&nilfs_kset->kobj, &nilfs_feature_attr_group);
1118 if (unlikely(err)) { 1120 if (unlikely(err)) {
1119 printk(KERN_ERR "NILFS: unable to create feature group: err %d\n", 1121 nilfs_msg(NULL, KERN_ERR,
1120 err); 1122 "unable to create feature group: err=%d", err);
1121 goto cleanup_sysfs_init; 1123 goto cleanup_sysfs_init;
1122 } 1124 }
1123 1125
diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c
index 702115164cf3..2dd75bf619ad 100644
--- a/fs/nilfs2/the_nilfs.c
+++ b/fs/nilfs2/the_nilfs.c
@@ -192,7 +192,10 @@ static int nilfs_store_log_cursor(struct the_nilfs *nilfs,
192 nilfs_get_segnum_of_block(nilfs, nilfs->ns_last_pseg); 192 nilfs_get_segnum_of_block(nilfs, nilfs->ns_last_pseg);
193 nilfs->ns_cno = nilfs->ns_last_cno + 1; 193 nilfs->ns_cno = nilfs->ns_last_cno + 1;
194 if (nilfs->ns_segnum >= nilfs->ns_nsegments) { 194 if (nilfs->ns_segnum >= nilfs->ns_nsegments) {
195 printk(KERN_ERR "NILFS invalid last segment number.\n"); 195 nilfs_msg(nilfs->ns_sb, KERN_ERR,
196 "pointed segment number is out of range: segnum=%llu, nsegments=%lu",
197 (unsigned long long)nilfs->ns_segnum,
198 nilfs->ns_nsegments);
196 ret = -EINVAL; 199 ret = -EINVAL;
197 } 200 }
198 return ret; 201 return ret;
@@ -216,12 +219,12 @@ int load_nilfs(struct the_nilfs *nilfs, struct super_block *sb)
216 int err; 219 int err;
217 220
218 if (!valid_fs) { 221 if (!valid_fs) {
219 printk(KERN_WARNING "NILFS warning: mounting unchecked fs\n"); 222 nilfs_msg(sb, KERN_WARNING, "mounting unchecked fs");
220 if (s_flags & MS_RDONLY) { 223 if (s_flags & MS_RDONLY) {
221 printk(KERN_INFO "NILFS: INFO: recovery " 224 nilfs_msg(sb, KERN_INFO,
222 "required for readonly filesystem.\n"); 225 "recovery required for readonly filesystem");
223 printk(KERN_INFO "NILFS: write access will " 226 nilfs_msg(sb, KERN_INFO,
224 "be enabled during recovery.\n"); 227 "write access will be enabled during recovery");
225 } 228 }
226 } 229 }
227 230
@@ -236,13 +239,12 @@ int load_nilfs(struct the_nilfs *nilfs, struct super_block *sb)
236 goto scan_error; 239 goto scan_error;
237 240
238 if (!nilfs_valid_sb(sbp[1])) { 241 if (!nilfs_valid_sb(sbp[1])) {
239 printk(KERN_WARNING 242 nilfs_msg(sb, KERN_WARNING,
240 "NILFS warning: unable to fall back to spare" 243 "unable to fall back to spare super block");
241 "super block\n");
242 goto scan_error; 244 goto scan_error;
243 } 245 }
244 printk(KERN_INFO 246 nilfs_msg(sb, KERN_INFO,
245 "NILFS: try rollback from an earlier position\n"); 247 "trying rollback from an earlier position");
246 248
247 /* 249 /*
248 * restore super block with its spare and reconfigure 250 * restore super block with its spare and reconfigure
@@ -255,10 +257,9 @@ int load_nilfs(struct the_nilfs *nilfs, struct super_block *sb)
255 /* verify consistency between two super blocks */ 257 /* verify consistency between two super blocks */
256 blocksize = BLOCK_SIZE << le32_to_cpu(sbp[0]->s_log_block_size); 258 blocksize = BLOCK_SIZE << le32_to_cpu(sbp[0]->s_log_block_size);
257 if (blocksize != nilfs->ns_blocksize) { 259 if (blocksize != nilfs->ns_blocksize) {
258 printk(KERN_WARNING 260 nilfs_msg(sb, KERN_WARNING,
259 "NILFS warning: blocksize differs between " 261 "blocksize differs between two super blocks (%d != %d)",
260 "two super blocks (%d != %d)\n", 262 blocksize, nilfs->ns_blocksize);
261 blocksize, nilfs->ns_blocksize);
262 goto scan_error; 263 goto scan_error;
263 } 264 }
264 265
@@ -277,7 +278,8 @@ int load_nilfs(struct the_nilfs *nilfs, struct super_block *sb)
277 278
278 err = nilfs_load_super_root(nilfs, sb, ri.ri_super_root); 279 err = nilfs_load_super_root(nilfs, sb, ri.ri_super_root);
279 if (unlikely(err)) { 280 if (unlikely(err)) {
280 printk(KERN_ERR "NILFS: error loading super root.\n"); 281 nilfs_msg(sb, KERN_ERR, "error %d while loading super root",
282 err);
281 goto failed; 283 goto failed;
282 } 284 }
283 285
@@ -288,30 +290,29 @@ int load_nilfs(struct the_nilfs *nilfs, struct super_block *sb)
288 __u64 features; 290 __u64 features;
289 291
290 if (nilfs_test_opt(nilfs, NORECOVERY)) { 292 if (nilfs_test_opt(nilfs, NORECOVERY)) {
291 printk(KERN_INFO "NILFS: norecovery option specified. " 293 nilfs_msg(sb, KERN_INFO,
292 "skipping roll-forward recovery\n"); 294 "norecovery option specified, skipping roll-forward recovery");
293 goto skip_recovery; 295 goto skip_recovery;
294 } 296 }
295 features = le64_to_cpu(nilfs->ns_sbp[0]->s_feature_compat_ro) & 297 features = le64_to_cpu(nilfs->ns_sbp[0]->s_feature_compat_ro) &
296 ~NILFS_FEATURE_COMPAT_RO_SUPP; 298 ~NILFS_FEATURE_COMPAT_RO_SUPP;
297 if (features) { 299 if (features) {
298 printk(KERN_ERR "NILFS: couldn't proceed with " 300 nilfs_msg(sb, KERN_ERR,
299 "recovery because of unsupported optional " 301 "couldn't proceed with recovery because of unsupported optional features (%llx)",
300 "features (%llx)\n", 302 (unsigned long long)features);
301 (unsigned long long)features);
302 err = -EROFS; 303 err = -EROFS;
303 goto failed_unload; 304 goto failed_unload;
304 } 305 }
305 if (really_read_only) { 306 if (really_read_only) {
306 printk(KERN_ERR "NILFS: write access " 307 nilfs_msg(sb, KERN_ERR,
307 "unavailable, cannot proceed.\n"); 308 "write access unavailable, cannot proceed");
308 err = -EROFS; 309 err = -EROFS;
309 goto failed_unload; 310 goto failed_unload;
310 } 311 }
311 sb->s_flags &= ~MS_RDONLY; 312 sb->s_flags &= ~MS_RDONLY;
312 } else if (nilfs_test_opt(nilfs, NORECOVERY)) { 313 } else if (nilfs_test_opt(nilfs, NORECOVERY)) {
313 printk(KERN_ERR "NILFS: recovery cancelled because norecovery " 314 nilfs_msg(sb, KERN_ERR,
314 "option was specified for a read/write mount\n"); 315 "recovery cancelled because norecovery option was specified for a read/write mount");
315 err = -EINVAL; 316 err = -EINVAL;
316 goto failed_unload; 317 goto failed_unload;
317 } 318 }
@@ -326,11 +327,12 @@ int load_nilfs(struct the_nilfs *nilfs, struct super_block *sb)
326 up_write(&nilfs->ns_sem); 327 up_write(&nilfs->ns_sem);
327 328
328 if (err) { 329 if (err) {
329 printk(KERN_ERR "NILFS: failed to update super block. " 330 nilfs_msg(sb, KERN_ERR,
330 "recovery unfinished.\n"); 331 "error %d updating super block. recovery unfinished.",
332 err);
331 goto failed_unload; 333 goto failed_unload;
332 } 334 }
333 printk(KERN_INFO "NILFS: recovery complete.\n"); 335 nilfs_msg(sb, KERN_INFO, "recovery complete");
334 336
335 skip_recovery: 337 skip_recovery:
336 nilfs_clear_recovery_info(&ri); 338 nilfs_clear_recovery_info(&ri);
@@ -338,7 +340,7 @@ int load_nilfs(struct the_nilfs *nilfs, struct super_block *sb)
338 return 0; 340 return 0;
339 341
340 scan_error: 342 scan_error:
341 printk(KERN_ERR "NILFS: error searching super root.\n"); 343 nilfs_msg(sb, KERN_ERR, "error %d while searching super root", err);
342 goto failed; 344 goto failed;
343 345
344 failed_unload: 346 failed_unload:
@@ -385,12 +387,11 @@ static int nilfs_store_disk_layout(struct the_nilfs *nilfs,
385 struct nilfs_super_block *sbp) 387 struct nilfs_super_block *sbp)
386{ 388{
387 if (le32_to_cpu(sbp->s_rev_level) < NILFS_MIN_SUPP_REV) { 389 if (le32_to_cpu(sbp->s_rev_level) < NILFS_MIN_SUPP_REV) {
388 printk(KERN_ERR "NILFS: unsupported revision " 390 nilfs_msg(nilfs->ns_sb, KERN_ERR,
389 "(superblock rev.=%d.%d, current rev.=%d.%d). " 391 "unsupported revision (superblock rev.=%d.%d, current rev.=%d.%d). Please check the version of mkfs.nilfs(2).",
390 "Please check the version of mkfs.nilfs.\n", 392 le32_to_cpu(sbp->s_rev_level),
391 le32_to_cpu(sbp->s_rev_level), 393 le16_to_cpu(sbp->s_minor_rev_level),
392 le16_to_cpu(sbp->s_minor_rev_level), 394 NILFS_CURRENT_REV, NILFS_MINOR_REV);
393 NILFS_CURRENT_REV, NILFS_MINOR_REV);
394 return -EINVAL; 395 return -EINVAL;
395 } 396 }
396 nilfs->ns_sbsize = le16_to_cpu(sbp->s_bytes); 397 nilfs->ns_sbsize = le16_to_cpu(sbp->s_bytes);
@@ -399,12 +400,14 @@ static int nilfs_store_disk_layout(struct the_nilfs *nilfs,
399 400
400 nilfs->ns_inode_size = le16_to_cpu(sbp->s_inode_size); 401 nilfs->ns_inode_size = le16_to_cpu(sbp->s_inode_size);
401 if (nilfs->ns_inode_size > nilfs->ns_blocksize) { 402 if (nilfs->ns_inode_size > nilfs->ns_blocksize) {
402 printk(KERN_ERR "NILFS: too large inode size: %d bytes.\n", 403 nilfs_msg(nilfs->ns_sb, KERN_ERR,
403 nilfs->ns_inode_size); 404 "too large inode size: %d bytes",
405 nilfs->ns_inode_size);
404 return -EINVAL; 406 return -EINVAL;
405 } else if (nilfs->ns_inode_size < NILFS_MIN_INODE_SIZE) { 407 } else if (nilfs->ns_inode_size < NILFS_MIN_INODE_SIZE) {
406 printk(KERN_ERR "NILFS: too small inode size: %d bytes.\n", 408 nilfs_msg(nilfs->ns_sb, KERN_ERR,
407 nilfs->ns_inode_size); 409 "too small inode size: %d bytes",
410 nilfs->ns_inode_size);
408 return -EINVAL; 411 return -EINVAL;
409 } 412 }
410 413
@@ -412,7 +415,9 @@ static int nilfs_store_disk_layout(struct the_nilfs *nilfs,
412 415
413 nilfs->ns_blocks_per_segment = le32_to_cpu(sbp->s_blocks_per_segment); 416 nilfs->ns_blocks_per_segment = le32_to_cpu(sbp->s_blocks_per_segment);
414 if (nilfs->ns_blocks_per_segment < NILFS_SEG_MIN_BLOCKS) { 417 if (nilfs->ns_blocks_per_segment < NILFS_SEG_MIN_BLOCKS) {
415 printk(KERN_ERR "NILFS: too short segment.\n"); 418 nilfs_msg(nilfs->ns_sb, KERN_ERR,
419 "too short segment: %lu blocks",
420 nilfs->ns_blocks_per_segment);
416 return -EINVAL; 421 return -EINVAL;
417 } 422 }
418 423
@@ -421,7 +426,9 @@ static int nilfs_store_disk_layout(struct the_nilfs *nilfs,
421 le32_to_cpu(sbp->s_r_segments_percentage); 426 le32_to_cpu(sbp->s_r_segments_percentage);
422 if (nilfs->ns_r_segments_percentage < 1 || 427 if (nilfs->ns_r_segments_percentage < 1 ||
423 nilfs->ns_r_segments_percentage > 99) { 428 nilfs->ns_r_segments_percentage > 99) {
424 printk(KERN_ERR "NILFS: invalid reserved segments percentage.\n"); 429 nilfs_msg(nilfs->ns_sb, KERN_ERR,
430 "invalid reserved segments percentage: %lu",
431 nilfs->ns_r_segments_percentage);
425 return -EINVAL; 432 return -EINVAL;
426 } 433 }
427 434
@@ -505,16 +512,16 @@ static int nilfs_load_super_block(struct the_nilfs *nilfs,
505 512
506 if (!sbp[0]) { 513 if (!sbp[0]) {
507 if (!sbp[1]) { 514 if (!sbp[1]) {
508 printk(KERN_ERR "NILFS: unable to read superblock\n"); 515 nilfs_msg(sb, KERN_ERR, "unable to read superblock");
509 return -EIO; 516 return -EIO;
510 } 517 }
511 printk(KERN_WARNING 518 nilfs_msg(sb, KERN_WARNING,
512 "NILFS warning: unable to read primary superblock " 519 "unable to read primary superblock (blocksize = %d)",
513 "(blocksize = %d)\n", blocksize); 520 blocksize);
514 } else if (!sbp[1]) { 521 } else if (!sbp[1]) {
515 printk(KERN_WARNING 522 nilfs_msg(sb, KERN_WARNING,
516 "NILFS warning: unable to read secondary superblock " 523 "unable to read secondary superblock (blocksize = %d)",
517 "(blocksize = %d)\n", blocksize); 524 blocksize);
518 } 525 }
519 526
520 /* 527 /*
@@ -536,14 +543,14 @@ static int nilfs_load_super_block(struct the_nilfs *nilfs,
536 } 543 }
537 if (!valid[swp]) { 544 if (!valid[swp]) {
538 nilfs_release_super_block(nilfs); 545 nilfs_release_super_block(nilfs);
539 printk(KERN_ERR "NILFS: Can't find nilfs on dev %s.\n", 546 nilfs_msg(sb, KERN_ERR, "couldn't find nilfs on the device");
540 sb->s_id);
541 return -EINVAL; 547 return -EINVAL;
542 } 548 }
543 549
544 if (!valid[!swp]) 550 if (!valid[!swp])
545 printk(KERN_WARNING "NILFS warning: broken superblock. " 551 nilfs_msg(sb, KERN_WARNING,
546 "using spare superblock (blocksize = %d).\n", blocksize); 552 "broken superblock, retrying with spare superblock (blocksize = %d)",
553 blocksize);
547 if (swp) 554 if (swp)
548 nilfs_swap_super_block(nilfs); 555 nilfs_swap_super_block(nilfs);
549 556
@@ -577,7 +584,7 @@ int init_nilfs(struct the_nilfs *nilfs, struct super_block *sb, char *data)
577 584
578 blocksize = sb_min_blocksize(sb, NILFS_MIN_BLOCK_SIZE); 585 blocksize = sb_min_blocksize(sb, NILFS_MIN_BLOCK_SIZE);
579 if (!blocksize) { 586 if (!blocksize) {
580 printk(KERN_ERR "NILFS: unable to set blocksize\n"); 587 nilfs_msg(sb, KERN_ERR, "unable to set blocksize");
581 err = -EINVAL; 588 err = -EINVAL;
582 goto out; 589 goto out;
583 } 590 }
@@ -596,8 +603,9 @@ int init_nilfs(struct the_nilfs *nilfs, struct super_block *sb, char *data)
596 blocksize = BLOCK_SIZE << le32_to_cpu(sbp->s_log_block_size); 603 blocksize = BLOCK_SIZE << le32_to_cpu(sbp->s_log_block_size);
597 if (blocksize < NILFS_MIN_BLOCK_SIZE || 604 if (blocksize < NILFS_MIN_BLOCK_SIZE ||
598 blocksize > NILFS_MAX_BLOCK_SIZE) { 605 blocksize > NILFS_MAX_BLOCK_SIZE) {
599 printk(KERN_ERR "NILFS: couldn't mount because of unsupported " 606 nilfs_msg(sb, KERN_ERR,
600 "filesystem blocksize %d\n", blocksize); 607 "couldn't mount because of unsupported filesystem blocksize %d",
608 blocksize);
601 err = -EINVAL; 609 err = -EINVAL;
602 goto failed_sbh; 610 goto failed_sbh;
603 } 611 }
@@ -605,10 +613,9 @@ int init_nilfs(struct the_nilfs *nilfs, struct super_block *sb, char *data)
605 int hw_blocksize = bdev_logical_block_size(sb->s_bdev); 613 int hw_blocksize = bdev_logical_block_size(sb->s_bdev);
606 614
607 if (blocksize < hw_blocksize) { 615 if (blocksize < hw_blocksize) {
608 printk(KERN_ERR 616 nilfs_msg(sb, KERN_ERR,
609 "NILFS: blocksize %d too small for device " 617 "blocksize %d too small for device (sector-size = %d)",
610 "(sector-size = %d).\n", 618 blocksize, hw_blocksize);
611 blocksize, hw_blocksize);
612 err = -EINVAL; 619 err = -EINVAL;
613 goto failed_sbh; 620 goto failed_sbh;
614 } 621 }