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>
This commit is contained in:
Ryusuke Konishi
2016-08-02 14:05:10 -07:00
committed by Linus Torvalds
parent 6625689e15
commit feee880fa5
13 changed files with 283 additions and 275 deletions

View File

@@ -54,38 +54,37 @@ struct nilfs_recovery_block {
};
static int nilfs_warn_segment_error(int err)
static int nilfs_warn_segment_error(struct super_block *sb, int err)
{
const char *msg = NULL;
switch (err) {
case NILFS_SEG_FAIL_IO:
printk(KERN_WARNING
"NILFS warning: I/O error on loading last segment\n");
nilfs_msg(sb, KERN_ERR, "I/O error reading segment");
return -EIO;
case NILFS_SEG_FAIL_MAGIC:
printk(KERN_WARNING
"NILFS warning: Segment magic number invalid\n");
msg = "Magic number mismatch";
break;
case NILFS_SEG_FAIL_SEQ:
printk(KERN_WARNING
"NILFS warning: Sequence number mismatch\n");
msg = "Sequence number mismatch";
break;
case NILFS_SEG_FAIL_CHECKSUM_SUPER_ROOT:
printk(KERN_WARNING
"NILFS warning: Checksum error in super root\n");
msg = "Checksum error in super root";
break;
case NILFS_SEG_FAIL_CHECKSUM_FULL:
printk(KERN_WARNING
"NILFS warning: Checksum error in segment payload\n");
msg = "Checksum error in segment payload";
break;
case NILFS_SEG_FAIL_CONSISTENCY:
printk(KERN_WARNING
"NILFS warning: Inconsistent segment\n");
msg = "Inconsistency found";
break;
case NILFS_SEG_NO_SUPER_ROOT:
printk(KERN_WARNING
"NILFS warning: No super root in the last segment\n");
msg = "No super root in the last segment";
break;
default:
nilfs_msg(sb, KERN_ERR, "unrecognized segment error %d", err);
return -EINVAL;
}
nilfs_msg(sb, KERN_WARNING, "invalid segment: %s", msg);
return -EINVAL;
}
@@ -178,7 +177,7 @@ int nilfs_read_super_root_block(struct the_nilfs *nilfs, sector_t sr_block,
brelse(bh_sr);
failed:
return nilfs_warn_segment_error(ret);
return nilfs_warn_segment_error(nilfs->ns_sb, ret);
}
/**
@@ -553,11 +552,10 @@ static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs,
put_page(page);
failed_inode:
printk(KERN_WARNING
"NILFS warning: error recovering data block "
"(err=%d, ino=%lu, block-offset=%llu)\n",
err, (unsigned long)rb->ino,
(unsigned long long)rb->blkoff);
nilfs_msg(sb, KERN_WARNING,
"error %d recovering data block (ino=%lu, block-offset=%llu)",
err, (unsigned long)rb->ino,
(unsigned long long)rb->blkoff);
if (!err2)
err2 = err;
next:
@@ -680,8 +678,8 @@ static int nilfs_do_roll_forward(struct the_nilfs *nilfs,
}
if (nsalvaged_blocks) {
printk(KERN_INFO "NILFS (device %s): salvaged %lu blocks\n",
sb->s_id, nsalvaged_blocks);
nilfs_msg(sb, KERN_INFO, "salvaged %lu blocks",
nsalvaged_blocks);
ri->ri_need_recovery = NILFS_RECOVERY_ROLLFORWARD_DONE;
}
out:
@@ -692,10 +690,9 @@ static int nilfs_do_roll_forward(struct the_nilfs *nilfs,
confused:
err = -EINVAL;
failed:
printk(KERN_ERR
"NILFS (device %s): Error roll-forwarding "
"(err=%d, pseg block=%llu). ",
sb->s_id, err, (unsigned long long)pseg_start);
nilfs_msg(sb, KERN_ERR,
"error %d roll-forwarding partial segment at blocknr = %llu",
err, (unsigned long long)pseg_start);
goto out;
}
@@ -715,9 +712,8 @@ static void nilfs_finish_roll_forward(struct the_nilfs *nilfs,
set_buffer_dirty(bh);
err = sync_dirty_buffer(bh);
if (unlikely(err))
printk(KERN_WARNING
"NILFS warning: buffer sync write failed during "
"post-cleaning of recovery.\n");
nilfs_msg(nilfs->ns_sb, KERN_WARNING,
"buffer sync write failed during post-cleaning of recovery.");
brelse(bh);
}
@@ -752,8 +748,8 @@ int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs,
err = nilfs_attach_checkpoint(sb, ri->ri_cno, true, &root);
if (unlikely(err)) {
printk(KERN_ERR
"NILFS: error loading the latest checkpoint.\n");
nilfs_msg(sb, KERN_ERR,
"error %d loading the latest checkpoint", err);
return err;
}
@@ -764,8 +760,9 @@ int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs,
if (ri->ri_need_recovery == NILFS_RECOVERY_ROLLFORWARD_DONE) {
err = nilfs_prepare_segment_for_recovery(nilfs, sb, ri);
if (unlikely(err)) {
printk(KERN_ERR "NILFS: Error preparing segments for "
"recovery.\n");
nilfs_msg(sb, KERN_ERR,
"error %d preparing segment for recovery",
err);
goto failed;
}
@@ -778,8 +775,9 @@ int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs,
nilfs_detach_log_writer(sb);
if (unlikely(err)) {
printk(KERN_ERR "NILFS: Oops! recovery failed. "
"(err=%d)\n", err);
nilfs_msg(sb, KERN_ERR,
"error %d writing segment for recovery",
err);
goto failed;
}
@@ -961,5 +959,5 @@ int nilfs_search_super_root(struct the_nilfs *nilfs,
failed:
brelse(bh_sum);
nilfs_dispose_segment_list(&segments);
return (ret < 0) ? ret : nilfs_warn_segment_error(ret);
return ret < 0 ? ret : nilfs_warn_segment_error(nilfs->ns_sb, ret);
}