summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2019-06-18 05:48:42 -0400
committerJaegeuk Kim <jaegeuk@kernel.org>2019-07-02 18:40:40 -0400
commitdcbb4c10e6d9693cc9d6fa493b4d130b66a60c7d (patch)
treeb725d2166c9325de23807cc204abc7c153813aa4
parent8740edc3e5cca78e20ac3ba0127f61ab7cdb4d2f (diff)
f2fs: introduce f2fs_<level> macros to wrap f2fs_printk()
- Add and use f2fs_<level> macros - Convert f2fs_msg to f2fs_printk - Remove level from f2fs_printk and embed the level in the format - Coalesce formats and align multi-line arguments - Remove unnecessary duplicate extern f2fs_msg f2fs.h Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Chao Yu <yuchao0@huawei.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--fs/f2fs/checkpoint.c34
-rw-r--r--fs/f2fs/dir.c10
-rw-r--r--fs/f2fs/extent_cache.c7
-rw-r--r--fs/f2fs/f2fs.h38
-rw-r--r--fs/f2fs/file.c21
-rw-r--r--fs/f2fs/gc.c23
-rw-r--r--fs/f2fs/inline.c12
-rw-r--r--fs/f2fs/inode.c72
-rw-r--r--fs/f2fs/namei.c10
-rw-r--r--fs/f2fs/node.c30
-rw-r--r--fs/f2fs/recovery.c37
-rw-r--r--fs/f2fs/segment.c61
-rw-r--r--fs/f2fs/segment.h10
-rw-r--r--fs/f2fs/super.c493
14 files changed, 351 insertions, 507 deletions
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 7b4a0fd59512..a5ae1ef1a6d0 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -146,8 +146,8 @@ static bool __is_bitmap_valid(struct f2fs_sb_info *sbi, block_t blkaddr,
146 146
147 exist = f2fs_test_bit(offset, se->cur_valid_map); 147 exist = f2fs_test_bit(offset, se->cur_valid_map);
148 if (!exist && type == DATA_GENERIC_ENHANCE) { 148 if (!exist && type == DATA_GENERIC_ENHANCE) {
149 f2fs_msg(sbi->sb, KERN_ERR, "Inconsistent error " 149 f2fs_err(sbi, "Inconsistent error blkaddr:%u, sit bitmap:%d",
150 "blkaddr:%u, sit bitmap:%d", blkaddr, exist); 150 blkaddr, exist);
151 set_sbi_flag(sbi, SBI_NEED_FSCK); 151 set_sbi_flag(sbi, SBI_NEED_FSCK);
152 WARN_ON(1); 152 WARN_ON(1);
153 } 153 }
@@ -184,8 +184,8 @@ bool f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi,
184 case DATA_GENERIC_ENHANCE_READ: 184 case DATA_GENERIC_ENHANCE_READ:
185 if (unlikely(blkaddr >= MAX_BLKADDR(sbi) || 185 if (unlikely(blkaddr >= MAX_BLKADDR(sbi) ||
186 blkaddr < MAIN_BLKADDR(sbi))) { 186 blkaddr < MAIN_BLKADDR(sbi))) {
187 f2fs_msg(sbi->sb, KERN_WARNING, 187 f2fs_warn(sbi, "access invalid blkaddr:%u",
188 "access invalid blkaddr:%u", blkaddr); 188 blkaddr);
189 set_sbi_flag(sbi, SBI_NEED_FSCK); 189 set_sbi_flag(sbi, SBI_NEED_FSCK);
190 WARN_ON(1); 190 WARN_ON(1);
191 return false; 191 return false;
@@ -657,9 +657,8 @@ static int recover_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino)
657 657
658err_out: 658err_out:
659 set_sbi_flag(sbi, SBI_NEED_FSCK); 659 set_sbi_flag(sbi, SBI_NEED_FSCK);
660 f2fs_msg(sbi->sb, KERN_WARNING, 660 f2fs_warn(sbi, "%s: orphan failed (ino=%x), run fsck to fix.",
661 "%s: orphan failed (ino=%x), run fsck to fix.", 661 __func__, ino);
662 __func__, ino);
663 return err; 662 return err;
664} 663}
665 664
@@ -676,13 +675,12 @@ int f2fs_recover_orphan_inodes(struct f2fs_sb_info *sbi)
676 return 0; 675 return 0;
677 676
678 if (bdev_read_only(sbi->sb->s_bdev)) { 677 if (bdev_read_only(sbi->sb->s_bdev)) {
679 f2fs_msg(sbi->sb, KERN_INFO, "write access " 678 f2fs_info(sbi, "write access unavailable, skipping orphan cleanup");
680 "unavailable, skipping orphan cleanup");
681 return 0; 679 return 0;
682 } 680 }
683 681
684 if (s_flags & SB_RDONLY) { 682 if (s_flags & SB_RDONLY) {
685 f2fs_msg(sbi->sb, KERN_INFO, "orphan cleanup on readonly fs"); 683 f2fs_info(sbi, "orphan cleanup on readonly fs");
686 sbi->sb->s_flags &= ~SB_RDONLY; 684 sbi->sb->s_flags &= ~SB_RDONLY;
687 } 685 }
688 686
@@ -827,15 +825,14 @@ static int get_checkpoint_version(struct f2fs_sb_info *sbi, block_t cp_addr,
827 if (crc_offset < CP_MIN_CHKSUM_OFFSET || 825 if (crc_offset < CP_MIN_CHKSUM_OFFSET ||
828 crc_offset > CP_CHKSUM_OFFSET) { 826 crc_offset > CP_CHKSUM_OFFSET) {
829 f2fs_put_page(*cp_page, 1); 827 f2fs_put_page(*cp_page, 1);
830 f2fs_msg(sbi->sb, KERN_WARNING, 828 f2fs_warn(sbi, "invalid crc_offset: %zu", crc_offset);
831 "invalid crc_offset: %zu", crc_offset);
832 return -EINVAL; 829 return -EINVAL;
833 } 830 }
834 831
835 crc = f2fs_checkpoint_chksum(sbi, *cp_block); 832 crc = f2fs_checkpoint_chksum(sbi, *cp_block);
836 if (crc != cur_cp_crc(*cp_block)) { 833 if (crc != cur_cp_crc(*cp_block)) {
837 f2fs_put_page(*cp_page, 1); 834 f2fs_put_page(*cp_page, 1);
838 f2fs_msg(sbi->sb, KERN_WARNING, "invalid crc value"); 835 f2fs_warn(sbi, "invalid crc value");
839 return -EINVAL; 836 return -EINVAL;
840 } 837 }
841 838
@@ -858,9 +855,8 @@ static struct page *validate_checkpoint(struct f2fs_sb_info *sbi,
858 855
859 if (le32_to_cpu(cp_block->cp_pack_total_block_count) > 856 if (le32_to_cpu(cp_block->cp_pack_total_block_count) >
860 sbi->blocks_per_seg) { 857 sbi->blocks_per_seg) {
861 f2fs_msg(sbi->sb, KERN_WARNING, 858 f2fs_warn(sbi, "invalid cp_pack_total_block_count:%u",
862 "invalid cp_pack_total_block_count:%u", 859 le32_to_cpu(cp_block->cp_pack_total_block_count));
863 le32_to_cpu(cp_block->cp_pack_total_block_count));
864 goto invalid_cp; 860 goto invalid_cp;
865 } 861 }
866 pre_version = *version; 862 pre_version = *version;
@@ -1559,8 +1555,7 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
1559 if (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED))) { 1555 if (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED))) {
1560 if (cpc->reason != CP_PAUSE) 1556 if (cpc->reason != CP_PAUSE)
1561 return 0; 1557 return 0;
1562 f2fs_msg(sbi->sb, KERN_WARNING, 1558 f2fs_warn(sbi, "Start checkpoint disabled!");
1563 "Start checkpoint disabled!");
1564 } 1559 }
1565 mutex_lock(&sbi->cp_mutex); 1560 mutex_lock(&sbi->cp_mutex);
1566 1561
@@ -1626,8 +1621,7 @@ stop:
1626 stat_inc_cp_count(sbi->stat_info); 1621 stat_inc_cp_count(sbi->stat_info);
1627 1622
1628 if (cpc->reason & CP_RECOVERY) 1623 if (cpc->reason & CP_RECOVERY)
1629 f2fs_msg(sbi->sb, KERN_NOTICE, 1624 f2fs_notice(sbi, "checkpoint: version = %llx", ckpt_ver);
1630 "checkpoint: version = %llx", ckpt_ver);
1631 1625
1632 /* do checkpoint periodically */ 1626 /* do checkpoint periodically */
1633 f2fs_update_time(sbi, CP_TIME); 1627 f2fs_update_time(sbi, CP_TIME);
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index 64cb61c42b95..0e78edbb8e16 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -218,9 +218,8 @@ struct f2fs_dir_entry *__f2fs_find_entry(struct inode *dir,
218 218
219 max_depth = F2FS_I(dir)->i_current_depth; 219 max_depth = F2FS_I(dir)->i_current_depth;
220 if (unlikely(max_depth > MAX_DIR_HASH_DEPTH)) { 220 if (unlikely(max_depth > MAX_DIR_HASH_DEPTH)) {
221 f2fs_msg(F2FS_I_SB(dir)->sb, KERN_WARNING, 221 f2fs_warn(F2FS_I_SB(dir), "Corrupted max_depth of %lu: %u",
222 "Corrupted max_depth of %lu: %u", 222 dir->i_ino, max_depth);
223 dir->i_ino, max_depth);
224 max_depth = MAX_DIR_HASH_DEPTH; 223 max_depth = MAX_DIR_HASH_DEPTH;
225 f2fs_i_depth_write(dir, max_depth); 224 f2fs_i_depth_write(dir, max_depth);
226 } 225 }
@@ -816,9 +815,8 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
816 bit_pos += GET_DENTRY_SLOTS(le16_to_cpu(de->name_len)); 815 bit_pos += GET_DENTRY_SLOTS(le16_to_cpu(de->name_len));
817 if (unlikely(bit_pos > d->max || 816 if (unlikely(bit_pos > d->max ||
818 le16_to_cpu(de->name_len) > F2FS_NAME_LEN)) { 817 le16_to_cpu(de->name_len) > F2FS_NAME_LEN)) {
819 f2fs_msg(sbi->sb, KERN_WARNING, 818 f2fs_warn(sbi, "%s: corrupted namelen=%d, run fsck to fix.",
820 "%s: corrupted namelen=%d, run fsck to fix.", 819 __func__, le16_to_cpu(de->name_len));
821 __func__, le16_to_cpu(de->name_len));
822 set_sbi_flag(sbi, SBI_NEED_FSCK); 820 set_sbi_flag(sbi, SBI_NEED_FSCK);
823 err = -EINVAL; 821 err = -EINVAL;
824 goto out; 822 goto out;
diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c
index caf77fe8ac07..e60078460ad1 100644
--- a/fs/f2fs/extent_cache.c
+++ b/fs/f2fs/extent_cache.c
@@ -184,10 +184,9 @@ bool f2fs_check_rb_tree_consistence(struct f2fs_sb_info *sbi,
184 next_re = rb_entry(next, struct rb_entry, rb_node); 184 next_re = rb_entry(next, struct rb_entry, rb_node);
185 185
186 if (cur_re->ofs + cur_re->len > next_re->ofs) { 186 if (cur_re->ofs + cur_re->len > next_re->ofs) {
187 f2fs_msg(sbi->sb, KERN_INFO, "inconsistent rbtree, " 187 f2fs_info(sbi, "inconsistent rbtree, cur(%u, %u) next(%u, %u)",
188 "cur(%u, %u) next(%u, %u)", 188 cur_re->ofs, cur_re->len,
189 cur_re->ofs, cur_re->len, 189 next_re->ofs, next_re->len);
190 next_re->ofs, next_re->len);
191 return false; 190 return false;
192 } 191 }
193 192
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 5c983268a303..2be2b16573c3 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1808,7 +1808,20 @@ enospc:
1808 return -ENOSPC; 1808 return -ENOSPC;
1809} 1809}
1810 1810
1811void f2fs_msg(struct super_block *sb, const char *level, const char *fmt, ...); 1811__printf(2, 3)
1812void f2fs_printk(struct f2fs_sb_info *sbi, const char *fmt, ...);
1813
1814#define f2fs_err(sbi, fmt, ...) \
1815 f2fs_printk(sbi, KERN_ERR fmt, ##__VA_ARGS__)
1816#define f2fs_warn(sbi, fmt, ...) \
1817 f2fs_printk(sbi, KERN_WARNING fmt, ##__VA_ARGS__)
1818#define f2fs_notice(sbi, fmt, ...) \
1819 f2fs_printk(sbi, KERN_NOTICE fmt, ##__VA_ARGS__)
1820#define f2fs_info(sbi, fmt, ...) \
1821 f2fs_printk(sbi, KERN_INFO fmt, ##__VA_ARGS__)
1822#define f2fs_debug(sbi, fmt, ...) \
1823 f2fs_printk(sbi, KERN_DEBUG fmt, ##__VA_ARGS__)
1824
1812static inline void dec_valid_block_count(struct f2fs_sb_info *sbi, 1825static inline void dec_valid_block_count(struct f2fs_sb_info *sbi,
1813 struct inode *inode, 1826 struct inode *inode,
1814 block_t count) 1827 block_t count)
@@ -1824,11 +1837,10 @@ static inline void dec_valid_block_count(struct f2fs_sb_info *sbi,
1824 sbi->current_reserved_blocks + count); 1837 sbi->current_reserved_blocks + count);
1825 spin_unlock(&sbi->stat_lock); 1838 spin_unlock(&sbi->stat_lock);
1826 if (unlikely(inode->i_blocks < sectors)) { 1839 if (unlikely(inode->i_blocks < sectors)) {
1827 f2fs_msg(sbi->sb, KERN_WARNING, 1840 f2fs_warn(sbi, "Inconsistent i_blocks, ino:%lu, iblocks:%llu, sectors:%llu",
1828 "Inconsistent i_blocks, ino:%lu, iblocks:%llu, sectors:%llu", 1841 inode->i_ino,
1829 inode->i_ino, 1842 (unsigned long long)inode->i_blocks,
1830 (unsigned long long)inode->i_blocks, 1843 (unsigned long long)sectors);
1831 (unsigned long long)sectors);
1832 set_sbi_flag(sbi, SBI_NEED_FSCK); 1844 set_sbi_flag(sbi, SBI_NEED_FSCK);
1833 return; 1845 return;
1834 } 1846 }
@@ -2066,10 +2078,9 @@ static inline void dec_valid_node_count(struct f2fs_sb_info *sbi,
2066 dquot_free_inode(inode); 2078 dquot_free_inode(inode);
2067 } else { 2079 } else {
2068 if (unlikely(inode->i_blocks == 0)) { 2080 if (unlikely(inode->i_blocks == 0)) {
2069 f2fs_msg(sbi->sb, KERN_WARNING, 2081 f2fs_warn(sbi, "Inconsistent i_blocks, ino:%lu, iblocks:%llu",
2070 "Inconsistent i_blocks, ino:%lu, iblocks:%llu", 2082 inode->i_ino,
2071 inode->i_ino, 2083 (unsigned long long)inode->i_blocks);
2072 (unsigned long long)inode->i_blocks);
2073 set_sbi_flag(sbi, SBI_NEED_FSCK); 2084 set_sbi_flag(sbi, SBI_NEED_FSCK);
2074 return; 2085 return;
2075 } 2086 }
@@ -2839,9 +2850,8 @@ static inline void verify_blkaddr(struct f2fs_sb_info *sbi,
2839 block_t blkaddr, int type) 2850 block_t blkaddr, int type)
2840{ 2851{
2841 if (!f2fs_is_valid_blkaddr(sbi, blkaddr, type)) { 2852 if (!f2fs_is_valid_blkaddr(sbi, blkaddr, type)) {
2842 f2fs_msg(sbi->sb, KERN_ERR, 2853 f2fs_err(sbi, "invalid blkaddr: %u, type: %d, run fsck to fix.",
2843 "invalid blkaddr: %u, type: %d, run fsck to fix.", 2854 blkaddr, type);
2844 blkaddr, type);
2845 f2fs_bug_on(sbi, 1); 2855 f2fs_bug_on(sbi, 1);
2846 } 2856 }
2847} 2857}
@@ -2972,8 +2982,6 @@ int f2fs_quota_sync(struct super_block *sb, int type);
2972void f2fs_quota_off_umount(struct super_block *sb); 2982void f2fs_quota_off_umount(struct super_block *sb);
2973int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover); 2983int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover);
2974int f2fs_sync_fs(struct super_block *sb, int sync); 2984int f2fs_sync_fs(struct super_block *sb, int sync);
2975extern __printf(3, 4)
2976void f2fs_msg(struct super_block *sb, const char *level, const char *fmt, ...);
2977int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi); 2985int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi);
2978 2986
2979/* 2987/*
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 74600c4205da..1331cae6b5c2 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -1837,9 +1837,8 @@ static int f2fs_ioc_start_atomic_write(struct file *filp)
1837 * f2fs_is_atomic_file. 1837 * f2fs_is_atomic_file.
1838 */ 1838 */
1839 if (get_dirty_pages(inode)) 1839 if (get_dirty_pages(inode))
1840 f2fs_msg(F2FS_I_SB(inode)->sb, KERN_WARNING, 1840 f2fs_warn(F2FS_I_SB(inode), "Unexpected flush for atomic writes: ino=%lu, npages=%u",
1841 "Unexpected flush for atomic writes: ino=%lu, npages=%u", 1841 inode->i_ino, get_dirty_pages(inode));
1842 inode->i_ino, get_dirty_pages(inode));
1843 ret = filemap_write_and_wait_range(inode->i_mapping, 0, LLONG_MAX); 1842 ret = filemap_write_and_wait_range(inode->i_mapping, 0, LLONG_MAX);
1844 if (ret) { 1843 if (ret) {
1845 up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); 1844 up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
@@ -2274,8 +2273,7 @@ static int f2fs_ioc_write_checkpoint(struct file *filp, unsigned long arg)
2274 return -EROFS; 2273 return -EROFS;
2275 2274
2276 if (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED))) { 2275 if (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED))) {
2277 f2fs_msg(sbi->sb, KERN_INFO, 2276 f2fs_info(sbi, "Skipping Checkpoint. Checkpoints currently disabled.");
2278 "Skipping Checkpoint. Checkpoints currently disabled.");
2279 return -EINVAL; 2277 return -EINVAL;
2280 } 2278 }
2281 2279
@@ -2660,10 +2658,8 @@ static int f2fs_ioc_flush_device(struct file *filp, unsigned long arg)
2660 2658
2661 if (!f2fs_is_multi_device(sbi) || sbi->s_ndevs - 1 <= range.dev_num || 2659 if (!f2fs_is_multi_device(sbi) || sbi->s_ndevs - 1 <= range.dev_num ||
2662 __is_large_section(sbi)) { 2660 __is_large_section(sbi)) {
2663 f2fs_msg(sbi->sb, KERN_WARNING, 2661 f2fs_warn(sbi, "Can't flush %u in %d for segs_per_sec %u != 1",
2664 "Can't flush %u in %d for segs_per_sec %u != 1", 2662 range.dev_num, sbi->s_ndevs, sbi->segs_per_sec);
2665 range.dev_num, sbi->s_ndevs,
2666 sbi->segs_per_sec);
2667 return -EINVAL; 2663 return -EINVAL;
2668 } 2664 }
2669 2665
@@ -2948,10 +2944,9 @@ int f2fs_pin_file_control(struct inode *inode, bool inc)
2948 fi->i_gc_failures[GC_FAILURE_PIN] + 1); 2944 fi->i_gc_failures[GC_FAILURE_PIN] + 1);
2949 2945
2950 if (fi->i_gc_failures[GC_FAILURE_PIN] > sbi->gc_pin_file_threshold) { 2946 if (fi->i_gc_failures[GC_FAILURE_PIN] > sbi->gc_pin_file_threshold) {
2951 f2fs_msg(sbi->sb, KERN_WARNING, 2947 f2fs_warn(sbi, "%s: Enable GC = ino %lx after %x GC trials",
2952 "%s: Enable GC = ino %lx after %x GC trials", 2948 __func__, inode->i_ino,
2953 __func__, inode->i_ino, 2949 fi->i_gc_failures[GC_FAILURE_PIN]);
2954 fi->i_gc_failures[GC_FAILURE_PIN]);
2955 clear_inode_flag(inode, FI_PIN_FILE); 2950 clear_inode_flag(inode, FI_PIN_FILE);
2956 return -EAGAIN; 2951 return -EAGAIN;
2957 } 2952 }
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index e19b49b02d1b..c65f87f11de0 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -618,9 +618,8 @@ static bool is_alive(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
618 } 618 }
619 619
620 if (sum->version != dni->version) { 620 if (sum->version != dni->version) {
621 f2fs_msg(sbi->sb, KERN_WARNING, 621 f2fs_warn(sbi, "%s: valid data with mismatched node version.",
622 "%s: valid data with mismatched node version.", 622 __func__);
623 __func__);
624 set_sbi_flag(sbi, SBI_NEED_FSCK); 623 set_sbi_flag(sbi, SBI_NEED_FSCK);
625 } 624 }
626 625
@@ -1183,9 +1182,8 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi,
1183 1182
1184 sum = page_address(sum_page); 1183 sum = page_address(sum_page);
1185 if (type != GET_SUM_TYPE((&sum->footer))) { 1184 if (type != GET_SUM_TYPE((&sum->footer))) {
1186 f2fs_msg(sbi->sb, KERN_ERR, "Inconsistent segment (%u) " 1185 f2fs_err(sbi, "Inconsistent segment (%u) type [%d, %d] in SSA and SIT",
1187 "type [%d, %d] in SSA and SIT", 1186 segno, type, GET_SUM_TYPE((&sum->footer)));
1188 segno, type, GET_SUM_TYPE((&sum->footer)));
1189 set_sbi_flag(sbi, SBI_NEED_FSCK); 1187 set_sbi_flag(sbi, SBI_NEED_FSCK);
1190 f2fs_stop_checkpoint(sbi, false); 1188 f2fs_stop_checkpoint(sbi, false);
1191 goto skip; 1189 goto skip;
@@ -1397,8 +1395,8 @@ static int free_segment_range(struct f2fs_sb_info *sbi, unsigned int start,
1397 1395
1398 next_inuse = find_next_inuse(FREE_I(sbi), end + 1, start); 1396 next_inuse = find_next_inuse(FREE_I(sbi), end + 1, start);
1399 if (next_inuse <= end) { 1397 if (next_inuse <= end) {
1400 f2fs_msg(sbi->sb, KERN_ERR, 1398 f2fs_err(sbi, "segno %u should be free but still inuse!",
1401 "segno %u should be free but still inuse!", next_inuse); 1399 next_inuse);
1402 f2fs_bug_on(sbi, 1); 1400 f2fs_bug_on(sbi, 1);
1403 } 1401 }
1404 return err; 1402 return err;
@@ -1455,14 +1453,12 @@ int f2fs_resize_fs(struct f2fs_sb_info *sbi, __u64 block_count)
1455 return 0; 1453 return 0;
1456 1454
1457 if (is_sbi_flag_set(sbi, SBI_NEED_FSCK)) { 1455 if (is_sbi_flag_set(sbi, SBI_NEED_FSCK)) {
1458 f2fs_msg(sbi->sb, KERN_ERR, 1456 f2fs_err(sbi, "Should run fsck to repair first.");
1459 "Should run fsck to repair first.");
1460 return -EINVAL; 1457 return -EINVAL;
1461 } 1458 }
1462 1459
1463 if (test_opt(sbi, DISABLE_CHECKPOINT)) { 1460 if (test_opt(sbi, DISABLE_CHECKPOINT)) {
1464 f2fs_msg(sbi->sb, KERN_ERR, 1461 f2fs_err(sbi, "Checkpoint should be enabled.");
1465 "Checkpoint should be enabled.");
1466 return -EINVAL; 1462 return -EINVAL;
1467 } 1463 }
1468 1464
@@ -1526,8 +1522,7 @@ int f2fs_resize_fs(struct f2fs_sb_info *sbi, __u64 block_count)
1526out: 1522out:
1527 if (err) { 1523 if (err) {
1528 set_sbi_flag(sbi, SBI_NEED_FSCK); 1524 set_sbi_flag(sbi, SBI_NEED_FSCK);
1529 f2fs_msg(sbi->sb, KERN_ERR, 1525 f2fs_err(sbi, "resize_fs failed, should run fsck to repair!");
1530 "resize_fs failed, should run fsck to repair!");
1531 1526
1532 MAIN_SECS(sbi) += secs; 1527 MAIN_SECS(sbi) += secs;
1533 spin_lock(&sbi->stat_lock); 1528 spin_lock(&sbi->stat_lock);
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 404d2462a0fe..0d2764c9912d 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -140,10 +140,8 @@ int f2fs_convert_inline_page(struct dnode_of_data *dn, struct page *page)
140 if (unlikely(dn->data_blkaddr != NEW_ADDR)) { 140 if (unlikely(dn->data_blkaddr != NEW_ADDR)) {
141 f2fs_put_dnode(dn); 141 f2fs_put_dnode(dn);
142 set_sbi_flag(fio.sbi, SBI_NEED_FSCK); 142 set_sbi_flag(fio.sbi, SBI_NEED_FSCK);
143 f2fs_msg(fio.sbi->sb, KERN_WARNING, 143 f2fs_warn(fio.sbi, "%s: corrupted inline inode ino=%lx, i_addr[0]:0x%x, run fsck to fix.",
144 "%s: corrupted inline inode ino=%lx, i_addr[0]:0x%x, " 144 __func__, dn->inode->i_ino, dn->data_blkaddr);
145 "run fsck to fix.",
146 __func__, dn->inode->i_ino, dn->data_blkaddr);
147 return -EINVAL; 145 return -EINVAL;
148 } 146 }
149 147
@@ -383,10 +381,8 @@ static int f2fs_move_inline_dirents(struct inode *dir, struct page *ipage,
383 if (unlikely(dn.data_blkaddr != NEW_ADDR)) { 381 if (unlikely(dn.data_blkaddr != NEW_ADDR)) {
384 f2fs_put_dnode(&dn); 382 f2fs_put_dnode(&dn);
385 set_sbi_flag(F2FS_P_SB(page), SBI_NEED_FSCK); 383 set_sbi_flag(F2FS_P_SB(page), SBI_NEED_FSCK);
386 f2fs_msg(F2FS_P_SB(page)->sb, KERN_WARNING, 384 f2fs_warn(F2FS_P_SB(page), "%s: corrupted inline inode ino=%lx, i_addr[0]:0x%x, run fsck to fix.",
387 "%s: corrupted inline inode ino=%lx, i_addr[0]:0x%x, " 385 __func__, dir->i_ino, dn.data_blkaddr);
388 "run fsck to fix.",
389 __func__, dir->i_ino, dn.data_blkaddr);
390 err = -EINVAL; 386 err = -EINVAL;
391 goto out; 387 goto out;
392 } 388 }
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index 8838e55e7416..9ea3aedb8213 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -176,9 +176,8 @@ bool f2fs_inode_chksum_verify(struct f2fs_sb_info *sbi, struct page *page)
176 calculated = f2fs_inode_chksum(sbi, page); 176 calculated = f2fs_inode_chksum(sbi, page);
177 177
178 if (provided != calculated) 178 if (provided != calculated)
179 f2fs_msg(sbi->sb, KERN_WARNING, 179 f2fs_warn(sbi, "checksum invalid, nid = %lu, ino_of_node = %x, %x vs. %x",
180 "checksum invalid, nid = %lu, ino_of_node = %x, %x vs. %x", 180 page->index, ino_of_node(page), provided, calculated);
181 page->index, ino_of_node(page), provided, calculated);
182 181
183 return provided == calculated; 182 return provided == calculated;
184} 183}
@@ -202,50 +201,41 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page)
202 iblocks = le64_to_cpu(F2FS_INODE(node_page)->i_blocks); 201 iblocks = le64_to_cpu(F2FS_INODE(node_page)->i_blocks);
203 if (!iblocks) { 202 if (!iblocks) {
204 set_sbi_flag(sbi, SBI_NEED_FSCK); 203 set_sbi_flag(sbi, SBI_NEED_FSCK);
205 f2fs_msg(sbi->sb, KERN_WARNING, 204 f2fs_warn(sbi, "%s: corrupted inode i_blocks i_ino=%lx iblocks=%llu, run fsck to fix.",
206 "%s: corrupted inode i_blocks i_ino=%lx iblocks=%llu, " 205 __func__, inode->i_ino, iblocks);
207 "run fsck to fix.",
208 __func__, inode->i_ino, iblocks);
209 return false; 206 return false;
210 } 207 }
211 208
212 if (ino_of_node(node_page) != nid_of_node(node_page)) { 209 if (ino_of_node(node_page) != nid_of_node(node_page)) {
213 set_sbi_flag(sbi, SBI_NEED_FSCK); 210 set_sbi_flag(sbi, SBI_NEED_FSCK);
214 f2fs_msg(sbi->sb, KERN_WARNING, 211 f2fs_warn(sbi, "%s: corrupted inode footer i_ino=%lx, ino,nid: [%u, %u] run fsck to fix.",
215 "%s: corrupted inode footer i_ino=%lx, ino,nid: " 212 __func__, inode->i_ino,
216 "[%u, %u] run fsck to fix.", 213 ino_of_node(node_page), nid_of_node(node_page));
217 __func__, inode->i_ino,
218 ino_of_node(node_page), nid_of_node(node_page));
219 return false; 214 return false;
220 } 215 }
221 216
222 if (f2fs_sb_has_flexible_inline_xattr(sbi) 217 if (f2fs_sb_has_flexible_inline_xattr(sbi)
223 && !f2fs_has_extra_attr(inode)) { 218 && !f2fs_has_extra_attr(inode)) {
224 set_sbi_flag(sbi, SBI_NEED_FSCK); 219 set_sbi_flag(sbi, SBI_NEED_FSCK);
225 f2fs_msg(sbi->sb, KERN_WARNING, 220 f2fs_warn(sbi, "%s: corrupted inode ino=%lx, run fsck to fix.",
226 "%s: corrupted inode ino=%lx, run fsck to fix.", 221 __func__, inode->i_ino);
227 __func__, inode->i_ino);
228 return false; 222 return false;
229 } 223 }
230 224
231 if (f2fs_has_extra_attr(inode) && 225 if (f2fs_has_extra_attr(inode) &&
232 !f2fs_sb_has_extra_attr(sbi)) { 226 !f2fs_sb_has_extra_attr(sbi)) {
233 set_sbi_flag(sbi, SBI_NEED_FSCK); 227 set_sbi_flag(sbi, SBI_NEED_FSCK);
234 f2fs_msg(sbi->sb, KERN_WARNING, 228 f2fs_warn(sbi, "%s: inode (ino=%lx) is with extra_attr, but extra_attr feature is off",
235 "%s: inode (ino=%lx) is with extra_attr, " 229 __func__, inode->i_ino);
236 "but extra_attr feature is off",
237 __func__, inode->i_ino);
238 return false; 230 return false;
239 } 231 }
240 232
241 if (fi->i_extra_isize > F2FS_TOTAL_EXTRA_ATTR_SIZE || 233 if (fi->i_extra_isize > F2FS_TOTAL_EXTRA_ATTR_SIZE ||
242 fi->i_extra_isize % sizeof(__le32)) { 234 fi->i_extra_isize % sizeof(__le32)) {
243 set_sbi_flag(sbi, SBI_NEED_FSCK); 235 set_sbi_flag(sbi, SBI_NEED_FSCK);
244 f2fs_msg(sbi->sb, KERN_WARNING, 236 f2fs_warn(sbi, "%s: inode (ino=%lx) has corrupted i_extra_isize: %d, max: %zu",
245 "%s: inode (ino=%lx) has corrupted i_extra_isize: %d, " 237 __func__, inode->i_ino, fi->i_extra_isize,
246 "max: %zu", 238 F2FS_TOTAL_EXTRA_ATTR_SIZE);
247 __func__, inode->i_ino, fi->i_extra_isize,
248 F2FS_TOTAL_EXTRA_ATTR_SIZE);
249 return false; 239 return false;
250 } 240 }
251 241
@@ -255,11 +245,9 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page)
255 (!fi->i_inline_xattr_size || 245 (!fi->i_inline_xattr_size ||
256 fi->i_inline_xattr_size > MAX_INLINE_XATTR_SIZE)) { 246 fi->i_inline_xattr_size > MAX_INLINE_XATTR_SIZE)) {
257 set_sbi_flag(sbi, SBI_NEED_FSCK); 247 set_sbi_flag(sbi, SBI_NEED_FSCK);
258 f2fs_msg(sbi->sb, KERN_WARNING, 248 f2fs_warn(sbi, "%s: inode (ino=%lx) has corrupted i_inline_xattr_size: %d, max: %zu",
259 "%s: inode (ino=%lx) has corrupted " 249 __func__, inode->i_ino, fi->i_inline_xattr_size,
260 "i_inline_xattr_size: %d, max: %zu", 250 MAX_INLINE_XATTR_SIZE);
261 __func__, inode->i_ino, fi->i_inline_xattr_size,
262 MAX_INLINE_XATTR_SIZE);
263 return false; 251 return false;
264 } 252 }
265 253
@@ -272,11 +260,9 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page)
272 !f2fs_is_valid_blkaddr(sbi, ei->blk + ei->len - 1, 260 !f2fs_is_valid_blkaddr(sbi, ei->blk + ei->len - 1,
273 DATA_GENERIC_ENHANCE))) { 261 DATA_GENERIC_ENHANCE))) {
274 set_sbi_flag(sbi, SBI_NEED_FSCK); 262 set_sbi_flag(sbi, SBI_NEED_FSCK);
275 f2fs_msg(sbi->sb, KERN_WARNING, 263 f2fs_warn(sbi, "%s: inode (ino=%lx) extent info [%u, %u, %u] is incorrect, run fsck to fix",
276 "%s: inode (ino=%lx) extent info [%u, %u, %u] " 264 __func__, inode->i_ino,
277 "is incorrect, run fsck to fix", 265 ei->blk, ei->fofs, ei->len);
278 __func__, inode->i_ino,
279 ei->blk, ei->fofs, ei->len);
280 return false; 266 return false;
281 } 267 }
282 } 268 }
@@ -284,19 +270,15 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page)
284 if (f2fs_has_inline_data(inode) && 270 if (f2fs_has_inline_data(inode) &&
285 (!S_ISREG(inode->i_mode) && !S_ISLNK(inode->i_mode))) { 271 (!S_ISREG(inode->i_mode) && !S_ISLNK(inode->i_mode))) {
286 set_sbi_flag(sbi, SBI_NEED_FSCK); 272 set_sbi_flag(sbi, SBI_NEED_FSCK);
287 f2fs_msg(sbi->sb, KERN_WARNING, 273 f2fs_warn(sbi, "%s: inode (ino=%lx, mode=%u) should not have inline_data, run fsck to fix",
288 "%s: inode (ino=%lx, mode=%u) should not have " 274 __func__, inode->i_ino, inode->i_mode);
289 "inline_data, run fsck to fix",
290 __func__, inode->i_ino, inode->i_mode);
291 return false; 275 return false;
292 } 276 }
293 277
294 if (f2fs_has_inline_dentry(inode) && !S_ISDIR(inode->i_mode)) { 278 if (f2fs_has_inline_dentry(inode) && !S_ISDIR(inode->i_mode)) {
295 set_sbi_flag(sbi, SBI_NEED_FSCK); 279 set_sbi_flag(sbi, SBI_NEED_FSCK);
296 f2fs_msg(sbi->sb, KERN_WARNING, 280 f2fs_warn(sbi, "%s: inode (ino=%lx, mode=%u) should not have inline_dentry, run fsck to fix",
297 "%s: inode (ino=%lx, mode=%u) should not have " 281 __func__, inode->i_ino, inode->i_mode);
298 "inline_dentry, run fsck to fix",
299 __func__, inode->i_ino, inode->i_mode);
300 return false; 282 return false;
301 } 283 }
302 284
@@ -785,8 +767,7 @@ void f2fs_handle_failed_inode(struct inode *inode)
785 err = f2fs_get_node_info(sbi, inode->i_ino, &ni); 767 err = f2fs_get_node_info(sbi, inode->i_ino, &ni);
786 if (err) { 768 if (err) {
787 set_sbi_flag(sbi, SBI_NEED_FSCK); 769 set_sbi_flag(sbi, SBI_NEED_FSCK);
788 f2fs_msg(sbi->sb, KERN_WARNING, 770 f2fs_warn(sbi, "May loss orphan inode, run fsck to fix.");
789 "May loss orphan inode, run fsck to fix.");
790 goto out; 771 goto out;
791 } 772 }
792 773
@@ -794,8 +775,7 @@ void f2fs_handle_failed_inode(struct inode *inode)
794 err = f2fs_acquire_orphan_inode(sbi); 775 err = f2fs_acquire_orphan_inode(sbi);
795 if (err) { 776 if (err) {
796 set_sbi_flag(sbi, SBI_NEED_FSCK); 777 set_sbi_flag(sbi, SBI_NEED_FSCK);
797 f2fs_msg(sbi->sb, KERN_WARNING, 778 f2fs_warn(sbi, "Too many orphan inodes, run fsck to fix.");
798 "Too many orphan inodes, run fsck to fix.");
799 } else { 779 } else {
800 f2fs_add_orphan_inode(inode); 780 f2fs_add_orphan_inode(inode);
801 } 781 }
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 0f77f9242751..c5b99042e6f2 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -385,9 +385,8 @@ static int __recover_dot_dentries(struct inode *dir, nid_t pino)
385 int err = 0; 385 int err = 0;
386 386
387 if (f2fs_readonly(sbi->sb)) { 387 if (f2fs_readonly(sbi->sb)) {
388 f2fs_msg(sbi->sb, KERN_INFO, 388 f2fs_info(sbi, "skip recovering inline_dots inode (ino:%lu, pino:%u) in readonly mountpoint",
389 "skip recovering inline_dots inode (ino:%lu, pino:%u) " 389 dir->i_ino, pino);
390 "in readonly mountpoint", dir->i_ino, pino);
391 return 0; 390 return 0;
392 } 391 }
393 392
@@ -484,9 +483,8 @@ static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry,
484 if (IS_ENCRYPTED(dir) && 483 if (IS_ENCRYPTED(dir) &&
485 (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) && 484 (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) &&
486 !fscrypt_has_permitted_context(dir, inode)) { 485 !fscrypt_has_permitted_context(dir, inode)) {
487 f2fs_msg(inode->i_sb, KERN_WARNING, 486 f2fs_warn(F2FS_I_SB(inode), "Inconsistent encryption contexts: %lu/%lu",
488 "Inconsistent encryption contexts: %lu/%lu", 487 dir->i_ino, inode->i_ino);
489 dir->i_ino, inode->i_ino);
490 err = -EPERM; 488 err = -EPERM;
491 goto out_iput; 489 goto out_iput;
492 } 490 }
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 865f1525df32..4d9b4c58d8a9 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -34,9 +34,8 @@ int f2fs_check_nid_range(struct f2fs_sb_info *sbi, nid_t nid)
34{ 34{
35 if (unlikely(nid < F2FS_ROOT_INO(sbi) || nid >= NM_I(sbi)->max_nid)) { 35 if (unlikely(nid < F2FS_ROOT_INO(sbi) || nid >= NM_I(sbi)->max_nid)) {
36 set_sbi_flag(sbi, SBI_NEED_FSCK); 36 set_sbi_flag(sbi, SBI_NEED_FSCK);
37 f2fs_msg(sbi->sb, KERN_WARNING, 37 f2fs_warn(sbi, "%s: out-of-range nid=%x, run fsck to fix.",
38 "%s: out-of-range nid=%x, run fsck to fix.", 38 __func__, nid);
39 __func__, nid);
40 return -EINVAL; 39 return -EINVAL;
41 } 40 }
42 return 0; 41 return 0;
@@ -1189,10 +1188,8 @@ int f2fs_remove_inode_page(struct inode *inode)
1189 } 1188 }
1190 1189
1191 if (unlikely(inode->i_blocks != 0 && inode->i_blocks != 8)) { 1190 if (unlikely(inode->i_blocks != 0 && inode->i_blocks != 8)) {
1192 f2fs_msg(F2FS_I_SB(inode)->sb, KERN_WARNING, 1191 f2fs_warn(F2FS_I_SB(inode), "Inconsistent i_blocks, ino:%lu, iblocks:%llu",
1193 "Inconsistent i_blocks, ino:%lu, iblocks:%llu", 1192 inode->i_ino, (unsigned long long)inode->i_blocks);
1194 inode->i_ino,
1195 (unsigned long long)inode->i_blocks);
1196 set_sbi_flag(F2FS_I_SB(inode), SBI_NEED_FSCK); 1193 set_sbi_flag(F2FS_I_SB(inode), SBI_NEED_FSCK);
1197 } 1194 }
1198 1195
@@ -1380,11 +1377,10 @@ repeat:
1380 } 1377 }
1381page_hit: 1378page_hit:
1382 if(unlikely(nid != nid_of_node(page))) { 1379 if(unlikely(nid != nid_of_node(page))) {
1383 f2fs_msg(sbi->sb, KERN_WARNING, "inconsistent node block, " 1380 f2fs_warn(sbi, "inconsistent node block, nid:%lu, node_footer[nid:%u,ino:%u,ofs:%u,cpver:%llu,blkaddr:%u]",
1384 "nid:%lu, node_footer[nid:%u,ino:%u,ofs:%u,cpver:%llu,blkaddr:%u]", 1381 nid, nid_of_node(page), ino_of_node(page),
1385 nid, nid_of_node(page), ino_of_node(page), 1382 ofs_of_node(page), cpver_of_node(page),
1386 ofs_of_node(page), cpver_of_node(page), 1383 next_blkaddr_of_node(page));
1387 next_blkaddr_of_node(page));
1388 err = -EINVAL; 1384 err = -EINVAL;
1389out_err: 1385out_err:
1390 ClearPageUptodate(page); 1386 ClearPageUptodate(page);
@@ -1752,9 +1748,8 @@ continue_unlock:
1752 break; 1748 break;
1753 } 1749 }
1754 if (!ret && atomic && !marked) { 1750 if (!ret && atomic && !marked) {
1755 f2fs_msg(sbi->sb, KERN_DEBUG, 1751 f2fs_debug(sbi, "Retry to write fsync mark: ino=%u, idx=%lx",
1756 "Retry to write fsync mark: ino=%u, idx=%lx", 1752 ino, last_page->index);
1757 ino, last_page->index);
1758 lock_page(last_page); 1753 lock_page(last_page);
1759 f2fs_wait_on_page_writeback(last_page, NODE, true, true); 1754 f2fs_wait_on_page_writeback(last_page, NODE, true, true);
1760 set_page_dirty(last_page); 1755 set_page_dirty(last_page);
@@ -2304,8 +2299,7 @@ static int __f2fs_build_free_nids(struct f2fs_sb_info *sbi,
2304 if (ret) { 2299 if (ret) {
2305 up_read(&nm_i->nat_tree_lock); 2300 up_read(&nm_i->nat_tree_lock);
2306 f2fs_bug_on(sbi, !mount); 2301 f2fs_bug_on(sbi, !mount);
2307 f2fs_msg(sbi->sb, KERN_ERR, 2302 f2fs_err(sbi, "NAT is corrupt, run fsck to fix it");
2308 "NAT is corrupt, run fsck to fix it");
2309 return ret; 2303 return ret;
2310 } 2304 }
2311 } 2305 }
@@ -2915,7 +2909,7 @@ static int __get_nat_bitmaps(struct f2fs_sb_info *sbi)
2915 nm_i->full_nat_bits = nm_i->nat_bits + 8; 2909 nm_i->full_nat_bits = nm_i->nat_bits + 8;
2916 nm_i->empty_nat_bits = nm_i->full_nat_bits + nat_bits_bytes; 2910 nm_i->empty_nat_bits = nm_i->full_nat_bits + nat_bits_bytes;
2917 2911
2918 f2fs_msg(sbi->sb, KERN_NOTICE, "Found nat_bits in checkpoint"); 2912 f2fs_notice(sbi, "Found nat_bits in checkpoint");
2919 return 0; 2913 return 0;
2920} 2914}
2921 2915
diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index e04f82b3f4fc..72c2c4ba795f 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -188,10 +188,9 @@ out:
188 name = "<encrypted>"; 188 name = "<encrypted>";
189 else 189 else
190 name = raw_inode->i_name; 190 name = raw_inode->i_name;
191 f2fs_msg(inode->i_sb, KERN_NOTICE, 191 f2fs_notice(F2FS_I_SB(inode), "%s: ino = %x, name = %s, dir = %lx, err = %d",
192 "%s: ino = %x, name = %s, dir = %lx, err = %d", 192 __func__, ino_of_node(ipage), name,
193 __func__, ino_of_node(ipage), name, 193 IS_ERR(dir) ? 0 : dir->i_ino, err);
194 IS_ERR(dir) ? 0 : dir->i_ino, err);
195 return err; 194 return err;
196} 195}
197 196
@@ -292,9 +291,8 @@ static int recover_inode(struct inode *inode, struct page *page)
292 else 291 else
293 name = F2FS_INODE(page)->i_name; 292 name = F2FS_INODE(page)->i_name;
294 293
295 f2fs_msg(inode->i_sb, KERN_NOTICE, 294 f2fs_notice(F2FS_I_SB(inode), "recover_inode: ino = %x, name = %s, inline = %x",
296 "recover_inode: ino = %x, name = %s, inline = %x", 295 ino_of_node(page), name, raw->i_inline);
297 ino_of_node(page), name, raw->i_inline);
298 return 0; 296 return 0;
299} 297}
300 298
@@ -371,10 +369,9 @@ next:
371 /* sanity check in order to detect looped node chain */ 369 /* sanity check in order to detect looped node chain */
372 if (++loop_cnt >= free_blocks || 370 if (++loop_cnt >= free_blocks ||
373 blkaddr == next_blkaddr_of_node(page)) { 371 blkaddr == next_blkaddr_of_node(page)) {
374 f2fs_msg(sbi->sb, KERN_NOTICE, 372 f2fs_notice(sbi, "%s: detect looped node chain, blkaddr:%u, next:%u",
375 "%s: detect looped node chain, " 373 __func__, blkaddr,
376 "blkaddr:%u, next:%u", 374 next_blkaddr_of_node(page));
377 __func__, blkaddr, next_blkaddr_of_node(page));
378 f2fs_put_page(page, 1); 375 f2fs_put_page(page, 1);
379 err = -EINVAL; 376 err = -EINVAL;
380 break; 377 break;
@@ -553,10 +550,9 @@ retry_dn:
553 f2fs_bug_on(sbi, ni.ino != ino_of_node(page)); 550 f2fs_bug_on(sbi, ni.ino != ino_of_node(page));
554 551
555 if (ofs_of_node(dn.node_page) != ofs_of_node(page)) { 552 if (ofs_of_node(dn.node_page) != ofs_of_node(page)) {
556 f2fs_msg(sbi->sb, KERN_WARNING, 553 f2fs_warn(sbi, "Inconsistent ofs_of_node, ino:%lu, ofs:%u, %u",
557 "Inconsistent ofs_of_node, ino:%lu, ofs:%u, %u", 554 inode->i_ino, ofs_of_node(dn.node_page),
558 inode->i_ino, ofs_of_node(dn.node_page), 555 ofs_of_node(page));
559 ofs_of_node(page));
560 err = -EFAULT; 556 err = -EFAULT;
561 goto err; 557 goto err;
562 } 558 }
@@ -642,11 +638,9 @@ retry_prev:
642err: 638err:
643 f2fs_put_dnode(&dn); 639 f2fs_put_dnode(&dn);
644out: 640out:
645 f2fs_msg(sbi->sb, KERN_NOTICE, 641 f2fs_notice(sbi, "recover_data: ino = %lx (i_size: %s) recovered = %d, err = %d",
646 "recover_data: ino = %lx (i_size: %s) recovered = %d, err = %d", 642 inode->i_ino, file_keep_isize(inode) ? "keep" : "recover",
647 inode->i_ino, 643 recovered, err);
648 file_keep_isize(inode) ? "keep" : "recover",
649 recovered, err);
650 return err; 644 return err;
651} 645}
652 646
@@ -734,8 +728,7 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
734#endif 728#endif
735 729
736 if (s_flags & SB_RDONLY) { 730 if (s_flags & SB_RDONLY) {
737 f2fs_msg(sbi->sb, KERN_INFO, 731 f2fs_info(sbi, "recover fsync data on readonly fs");
738 "recover fsync data on readonly fs");
739 sbi->sb->s_flags &= ~SB_RDONLY; 732 sbi->sb->s_flags &= ~SB_RDONLY;
740 } 733 }
741 734
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 198b2e68a487..4a6133cc9112 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1757,8 +1757,7 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
1757 devi = f2fs_target_device_index(sbi, blkstart); 1757 devi = f2fs_target_device_index(sbi, blkstart);
1758 if (blkstart < FDEV(devi).start_blk || 1758 if (blkstart < FDEV(devi).start_blk ||
1759 blkstart > FDEV(devi).end_blk) { 1759 blkstart > FDEV(devi).end_blk) {
1760 f2fs_msg(sbi->sb, KERN_ERR, "Invalid block %x", 1760 f2fs_err(sbi, "Invalid block %x", blkstart);
1761 blkstart);
1762 return -EIO; 1761 return -EIO;
1763 } 1762 }
1764 blkstart -= FDEV(devi).start_blk; 1763 blkstart -= FDEV(devi).start_blk;
@@ -1771,10 +1770,9 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
1771 1770
1772 if (sector & (bdev_zone_sectors(bdev) - 1) || 1771 if (sector & (bdev_zone_sectors(bdev) - 1) ||
1773 nr_sects != bdev_zone_sectors(bdev)) { 1772 nr_sects != bdev_zone_sectors(bdev)) {
1774 f2fs_msg(sbi->sb, KERN_ERR, 1773 f2fs_err(sbi, "(%d) %s: Unaligned zone reset attempted (block %x + %x)",
1775 "(%d) %s: Unaligned zone reset attempted (block %x + %x)", 1774 devi, sbi->s_ndevs ? FDEV(devi).path : "",
1776 devi, sbi->s_ndevs ? FDEV(devi).path: "", 1775 blkstart, blklen);
1777 blkstart, blklen);
1778 return -EIO; 1776 return -EIO;
1779 } 1777 }
1780 trace_f2fs_issue_reset_zone(bdev, blkstart); 1778 trace_f2fs_issue_reset_zone(bdev, blkstart);
@@ -2138,15 +2136,14 @@ static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del)
2138 mir_exist = f2fs_test_and_set_bit(offset, 2136 mir_exist = f2fs_test_and_set_bit(offset,
2139 se->cur_valid_map_mir); 2137 se->cur_valid_map_mir);
2140 if (unlikely(exist != mir_exist)) { 2138 if (unlikely(exist != mir_exist)) {
2141 f2fs_msg(sbi->sb, KERN_ERR, "Inconsistent error " 2139 f2fs_err(sbi, "Inconsistent error when setting bitmap, blk:%u, old bit:%d",
2142 "when setting bitmap, blk:%u, old bit:%d", 2140 blkaddr, exist);
2143 blkaddr, exist);
2144 f2fs_bug_on(sbi, 1); 2141 f2fs_bug_on(sbi, 1);
2145 } 2142 }
2146#endif 2143#endif
2147 if (unlikely(exist)) { 2144 if (unlikely(exist)) {
2148 f2fs_msg(sbi->sb, KERN_ERR, 2145 f2fs_err(sbi, "Bitmap was wrongly set, blk:%u",
2149 "Bitmap was wrongly set, blk:%u", blkaddr); 2146 blkaddr);
2150 f2fs_bug_on(sbi, 1); 2147 f2fs_bug_on(sbi, 1);
2151 se->valid_blocks--; 2148 se->valid_blocks--;
2152 del = 0; 2149 del = 0;
@@ -2167,15 +2164,14 @@ static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del)
2167 mir_exist = f2fs_test_and_clear_bit(offset, 2164 mir_exist = f2fs_test_and_clear_bit(offset,
2168 se->cur_valid_map_mir); 2165 se->cur_valid_map_mir);
2169 if (unlikely(exist != mir_exist)) { 2166 if (unlikely(exist != mir_exist)) {
2170 f2fs_msg(sbi->sb, KERN_ERR, "Inconsistent error " 2167 f2fs_err(sbi, "Inconsistent error when clearing bitmap, blk:%u, old bit:%d",
2171 "when clearing bitmap, blk:%u, old bit:%d", 2168 blkaddr, exist);
2172 blkaddr, exist);
2173 f2fs_bug_on(sbi, 1); 2169 f2fs_bug_on(sbi, 1);
2174 } 2170 }
2175#endif 2171#endif
2176 if (unlikely(!exist)) { 2172 if (unlikely(!exist)) {
2177 f2fs_msg(sbi->sb, KERN_ERR, 2173 f2fs_err(sbi, "Bitmap was wrongly cleared, blk:%u",
2178 "Bitmap was wrongly cleared, blk:%u", blkaddr); 2174 blkaddr);
2179 f2fs_bug_on(sbi, 1); 2175 f2fs_bug_on(sbi, 1);
2180 se->valid_blocks++; 2176 se->valid_blocks++;
2181 del = 0; 2177 del = 0;
@@ -2683,9 +2679,8 @@ unlock:
2683 up_write(&SIT_I(sbi)->sentry_lock); 2679 up_write(&SIT_I(sbi)->sentry_lock);
2684 2680
2685 if (segno != curseg->segno) 2681 if (segno != curseg->segno)
2686 f2fs_msg(sbi->sb, KERN_NOTICE, 2682 f2fs_notice(sbi, "For resize: curseg of type %d: %u ==> %u",
2687 "For resize: curseg of type %d: %u ==> %u", 2683 type, segno, curseg->segno);
2688 type, segno, curseg->segno);
2689 2684
2690 mutex_unlock(&curseg->curseg_mutex); 2685 mutex_unlock(&curseg->curseg_mutex);
2691 up_read(&SM_I(sbi)->curseg_lock); 2686 up_read(&SM_I(sbi)->curseg_lock);
@@ -2823,8 +2818,7 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)
2823 goto out; 2818 goto out;
2824 2819
2825 if (is_sbi_flag_set(sbi, SBI_NEED_FSCK)) { 2820 if (is_sbi_flag_set(sbi, SBI_NEED_FSCK)) {
2826 f2fs_msg(sbi->sb, KERN_WARNING, 2821 f2fs_warn(sbi, "Found FS corruption, run fsck to fix.");
2827 "Found FS corruption, run fsck to fix.");
2828 return -EIO; 2822 return -EIO;
2829 } 2823 }
2830 2824
@@ -3585,9 +3579,8 @@ static int restore_curseg_summaries(struct f2fs_sb_info *sbi)
3585 /* sanity check for summary blocks */ 3579 /* sanity check for summary blocks */
3586 if (nats_in_cursum(nat_j) > NAT_JOURNAL_ENTRIES || 3580 if (nats_in_cursum(nat_j) > NAT_JOURNAL_ENTRIES ||
3587 sits_in_cursum(sit_j) > SIT_JOURNAL_ENTRIES) { 3581 sits_in_cursum(sit_j) > SIT_JOURNAL_ENTRIES) {
3588 f2fs_msg(sbi->sb, KERN_ERR, 3582 f2fs_err(sbi, "invalid journal entries nats %u sits %u\n",
3589 "invalid journal entries nats %u sits %u\n", 3583 nats_in_cursum(nat_j), sits_in_cursum(sit_j));
3590 nats_in_cursum(nat_j), sits_in_cursum(sit_j));
3591 return -EINVAL; 3584 return -EINVAL;
3592 } 3585 }
3593 3586
@@ -4155,9 +4148,8 @@ static int build_sit_entries(struct f2fs_sb_info *sbi)
4155 4148
4156 start = le32_to_cpu(segno_in_journal(journal, i)); 4149 start = le32_to_cpu(segno_in_journal(journal, i));
4157 if (start >= MAIN_SEGS(sbi)) { 4150 if (start >= MAIN_SEGS(sbi)) {
4158 f2fs_msg(sbi->sb, KERN_ERR, 4151 f2fs_err(sbi, "Wrong journal entry on segno %u",
4159 "Wrong journal entry on segno %u", 4152 start);
4160 start);
4161 set_sbi_flag(sbi, SBI_NEED_FSCK); 4153 set_sbi_flag(sbi, SBI_NEED_FSCK);
4162 err = -EINVAL; 4154 err = -EINVAL;
4163 break; 4155 break;
@@ -4196,9 +4188,8 @@ static int build_sit_entries(struct f2fs_sb_info *sbi)
4196 up_read(&curseg->journal_rwsem); 4188 up_read(&curseg->journal_rwsem);
4197 4189
4198 if (!err && total_node_blocks != valid_node_count(sbi)) { 4190 if (!err && total_node_blocks != valid_node_count(sbi)) {
4199 f2fs_msg(sbi->sb, KERN_ERR, 4191 f2fs_err(sbi, "SIT is corrupted node# %u vs %u",
4200 "SIT is corrupted node# %u vs %u", 4192 total_node_blocks, valid_node_count(sbi));
4201 total_node_blocks, valid_node_count(sbi));
4202 set_sbi_flag(sbi, SBI_NEED_FSCK); 4193 set_sbi_flag(sbi, SBI_NEED_FSCK);
4203 err = -EINVAL; 4194 err = -EINVAL;
4204 } 4195 }
@@ -4314,12 +4305,10 @@ static int sanity_check_curseg(struct f2fs_sb_info *sbi)
4314 if (!f2fs_test_bit(blkofs, se->cur_valid_map)) 4305 if (!f2fs_test_bit(blkofs, se->cur_valid_map))
4315 continue; 4306 continue;
4316out: 4307out:
4317 f2fs_msg(sbi->sb, KERN_ERR, 4308 f2fs_err(sbi,
4318 "Current segment's next free block offset is " 4309 "Current segment's next free block offset is inconsistent with bitmap, logtype:%u, segno:%u, type:%u, next_blkoff:%u, blkofs:%u",
4319 "inconsistent with bitmap, logtype:%u, " 4310 i, curseg->segno, curseg->alloc_type,
4320 "segno:%u, type:%u, next_blkoff:%u, blkofs:%u", 4311 curseg->next_blkoff, blkofs);
4321 i, curseg->segno, curseg->alloc_type,
4322 curseg->next_blkoff, blkofs);
4323 return -EINVAL; 4312 return -EINVAL;
4324 } 4313 }
4325 } 4314 }
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index 429007b8036e..166ac0f07a4e 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -693,9 +693,8 @@ static inline int check_block_count(struct f2fs_sb_info *sbi,
693 } while (cur_pos < sbi->blocks_per_seg); 693 } while (cur_pos < sbi->blocks_per_seg);
694 694
695 if (unlikely(GET_SIT_VBLOCKS(raw_sit) != valid_blocks)) { 695 if (unlikely(GET_SIT_VBLOCKS(raw_sit) != valid_blocks)) {
696 f2fs_msg(sbi->sb, KERN_ERR, 696 f2fs_err(sbi, "Mismatch valid blocks %d vs. %d",
697 "Mismatch valid blocks %d vs. %d", 697 GET_SIT_VBLOCKS(raw_sit), valid_blocks);
698 GET_SIT_VBLOCKS(raw_sit), valid_blocks);
699 set_sbi_flag(sbi, SBI_NEED_FSCK); 698 set_sbi_flag(sbi, SBI_NEED_FSCK);
700 return -EINVAL; 699 return -EINVAL;
701 } 700 }
@@ -703,9 +702,8 @@ static inline int check_block_count(struct f2fs_sb_info *sbi,
703 /* check segment usage, and check boundary of a given segment number */ 702 /* check segment usage, and check boundary of a given segment number */
704 if (unlikely(GET_SIT_VBLOCKS(raw_sit) > sbi->blocks_per_seg 703 if (unlikely(GET_SIT_VBLOCKS(raw_sit) > sbi->blocks_per_seg
705 || segno > TOTAL_SEGS(sbi) - 1)) { 704 || segno > TOTAL_SEGS(sbi) - 1)) {
706 f2fs_msg(sbi->sb, KERN_ERR, 705 f2fs_err(sbi, "Wrong valid blocks %d or segno %u",
707 "Wrong valid blocks %d or segno %u", 706 GET_SIT_VBLOCKS(raw_sit), segno);
708 GET_SIT_VBLOCKS(raw_sit), segno);
709 set_sbi_flag(sbi, SBI_NEED_FSCK); 707 set_sbi_flag(sbi, SBI_NEED_FSCK);
710 return -EINVAL; 708 return -EINVAL;
711 } 709 }
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 049a5957532e..2a40944d0810 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -205,15 +205,20 @@ static match_table_t f2fs_tokens = {
205 {Opt_err, NULL}, 205 {Opt_err, NULL},
206}; 206};
207 207
208void f2fs_msg(struct super_block *sb, const char *level, const char *fmt, ...) 208void f2fs_printk(struct f2fs_sb_info *sbi, const char *fmt, ...)
209{ 209{
210 struct va_format vaf; 210 struct va_format vaf;
211 va_list args; 211 va_list args;
212 int level;
212 213
213 va_start(args, fmt); 214 va_start(args, fmt);
214 vaf.fmt = fmt; 215
216 level = printk_get_level(fmt);
217 vaf.fmt = printk_skip_level(fmt);
215 vaf.va = &args; 218 vaf.va = &args;
216 printk("%sF2FS-fs (%s): %pV\n", level, sb->s_id, &vaf); 219 printk("%c%cF2FS-fs (%s): %pV\n",
220 KERN_SOH_ASCII, level, sbi->sb->s_id, &vaf);
221
217 va_end(args); 222 va_end(args);
218} 223}
219 224
@@ -226,21 +231,19 @@ static inline void limit_reserve_root(struct f2fs_sb_info *sbi)
226 if (test_opt(sbi, RESERVE_ROOT) && 231 if (test_opt(sbi, RESERVE_ROOT) &&
227 F2FS_OPTION(sbi).root_reserved_blocks > limit) { 232 F2FS_OPTION(sbi).root_reserved_blocks > limit) {
228 F2FS_OPTION(sbi).root_reserved_blocks = limit; 233 F2FS_OPTION(sbi).root_reserved_blocks = limit;
229 f2fs_msg(sbi->sb, KERN_INFO, 234 f2fs_info(sbi, "Reduce reserved blocks for root = %u",
230 "Reduce reserved blocks for root = %u", 235 F2FS_OPTION(sbi).root_reserved_blocks);
231 F2FS_OPTION(sbi).root_reserved_blocks);
232 } 236 }
233 if (!test_opt(sbi, RESERVE_ROOT) && 237 if (!test_opt(sbi, RESERVE_ROOT) &&
234 (!uid_eq(F2FS_OPTION(sbi).s_resuid, 238 (!uid_eq(F2FS_OPTION(sbi).s_resuid,
235 make_kuid(&init_user_ns, F2FS_DEF_RESUID)) || 239 make_kuid(&init_user_ns, F2FS_DEF_RESUID)) ||
236 !gid_eq(F2FS_OPTION(sbi).s_resgid, 240 !gid_eq(F2FS_OPTION(sbi).s_resgid,
237 make_kgid(&init_user_ns, F2FS_DEF_RESGID)))) 241 make_kgid(&init_user_ns, F2FS_DEF_RESGID))))
238 f2fs_msg(sbi->sb, KERN_INFO, 242 f2fs_info(sbi, "Ignore s_resuid=%u, s_resgid=%u w/o reserve_root",
239 "Ignore s_resuid=%u, s_resgid=%u w/o reserve_root", 243 from_kuid_munged(&init_user_ns,
240 from_kuid_munged(&init_user_ns, 244 F2FS_OPTION(sbi).s_resuid),
241 F2FS_OPTION(sbi).s_resuid), 245 from_kgid_munged(&init_user_ns,
242 from_kgid_munged(&init_user_ns, 246 F2FS_OPTION(sbi).s_resgid));
243 F2FS_OPTION(sbi).s_resgid));
244} 247}
245 248
246static void init_once(void *foo) 249static void init_once(void *foo)
@@ -261,35 +264,29 @@ static int f2fs_set_qf_name(struct super_block *sb, int qtype,
261 int ret = -EINVAL; 264 int ret = -EINVAL;
262 265
263 if (sb_any_quota_loaded(sb) && !F2FS_OPTION(sbi).s_qf_names[qtype]) { 266 if (sb_any_quota_loaded(sb) && !F2FS_OPTION(sbi).s_qf_names[qtype]) {
264 f2fs_msg(sb, KERN_ERR, 267 f2fs_err(sbi, "Cannot change journaled quota options when quota turned on");
265 "Cannot change journaled "
266 "quota options when quota turned on");
267 return -EINVAL; 268 return -EINVAL;
268 } 269 }
269 if (f2fs_sb_has_quota_ino(sbi)) { 270 if (f2fs_sb_has_quota_ino(sbi)) {
270 f2fs_msg(sb, KERN_INFO, 271 f2fs_info(sbi, "QUOTA feature is enabled, so ignore qf_name");
271 "QUOTA feature is enabled, so ignore qf_name");
272 return 0; 272 return 0;
273 } 273 }
274 274
275 qname = match_strdup(args); 275 qname = match_strdup(args);
276 if (!qname) { 276 if (!qname) {
277 f2fs_msg(sb, KERN_ERR, 277 f2fs_err(sbi, "Not enough memory for storing quotafile name");
278 "Not enough memory for storing quotafile name");
279 return -ENOMEM; 278 return -ENOMEM;
280 } 279 }
281 if (F2FS_OPTION(sbi).s_qf_names[qtype]) { 280 if (F2FS_OPTION(sbi).s_qf_names[qtype]) {
282 if (strcmp(F2FS_OPTION(sbi).s_qf_names[qtype], qname) == 0) 281 if (strcmp(F2FS_OPTION(sbi).s_qf_names[qtype], qname) == 0)
283 ret = 0; 282 ret = 0;
284 else 283 else
285 f2fs_msg(sb, KERN_ERR, 284 f2fs_err(sbi, "%s quota file already specified",
286 "%s quota file already specified",
287 QTYPE2NAME(qtype)); 285 QTYPE2NAME(qtype));
288 goto errout; 286 goto errout;
289 } 287 }
290 if (strchr(qname, '/')) { 288 if (strchr(qname, '/')) {
291 f2fs_msg(sb, KERN_ERR, 289 f2fs_err(sbi, "quotafile must be on filesystem root");
292 "quotafile must be on filesystem root");
293 goto errout; 290 goto errout;
294 } 291 }
295 F2FS_OPTION(sbi).s_qf_names[qtype] = qname; 292 F2FS_OPTION(sbi).s_qf_names[qtype] = qname;
@@ -305,8 +302,7 @@ static int f2fs_clear_qf_name(struct super_block *sb, int qtype)
305 struct f2fs_sb_info *sbi = F2FS_SB(sb); 302 struct f2fs_sb_info *sbi = F2FS_SB(sb);
306 303
307 if (sb_any_quota_loaded(sb) && F2FS_OPTION(sbi).s_qf_names[qtype]) { 304 if (sb_any_quota_loaded(sb) && F2FS_OPTION(sbi).s_qf_names[qtype]) {
308 f2fs_msg(sb, KERN_ERR, "Cannot change journaled quota options" 305 f2fs_err(sbi, "Cannot change journaled quota options when quota turned on");
309 " when quota turned on");
310 return -EINVAL; 306 return -EINVAL;
311 } 307 }
312 kvfree(F2FS_OPTION(sbi).s_qf_names[qtype]); 308 kvfree(F2FS_OPTION(sbi).s_qf_names[qtype]);
@@ -322,8 +318,7 @@ static int f2fs_check_quota_options(struct f2fs_sb_info *sbi)
322 * to support legacy quotas in quota files. 318 * to support legacy quotas in quota files.
323 */ 319 */
324 if (test_opt(sbi, PRJQUOTA) && !f2fs_sb_has_project_quota(sbi)) { 320 if (test_opt(sbi, PRJQUOTA) && !f2fs_sb_has_project_quota(sbi)) {
325 f2fs_msg(sbi->sb, KERN_ERR, "Project quota feature not enabled. " 321 f2fs_err(sbi, "Project quota feature not enabled. Cannot enable project quota enforcement.");
326 "Cannot enable project quota enforcement.");
327 return -1; 322 return -1;
328 } 323 }
329 if (F2FS_OPTION(sbi).s_qf_names[USRQUOTA] || 324 if (F2FS_OPTION(sbi).s_qf_names[USRQUOTA] ||
@@ -343,21 +338,18 @@ static int f2fs_check_quota_options(struct f2fs_sb_info *sbi)
343 338
344 if (test_opt(sbi, GRPQUOTA) || test_opt(sbi, USRQUOTA) || 339 if (test_opt(sbi, GRPQUOTA) || test_opt(sbi, USRQUOTA) ||
345 test_opt(sbi, PRJQUOTA)) { 340 test_opt(sbi, PRJQUOTA)) {
346 f2fs_msg(sbi->sb, KERN_ERR, "old and new quota " 341 f2fs_err(sbi, "old and new quota format mixing");
347 "format mixing");
348 return -1; 342 return -1;
349 } 343 }
350 344
351 if (!F2FS_OPTION(sbi).s_jquota_fmt) { 345 if (!F2FS_OPTION(sbi).s_jquota_fmt) {
352 f2fs_msg(sbi->sb, KERN_ERR, "journaled quota format " 346 f2fs_err(sbi, "journaled quota format not specified");
353 "not specified");
354 return -1; 347 return -1;
355 } 348 }
356 } 349 }
357 350
358 if (f2fs_sb_has_quota_ino(sbi) && F2FS_OPTION(sbi).s_jquota_fmt) { 351 if (f2fs_sb_has_quota_ino(sbi) && F2FS_OPTION(sbi).s_jquota_fmt) {
359 f2fs_msg(sbi->sb, KERN_INFO, 352 f2fs_info(sbi, "QUOTA feature is enabled, so ignore jquota_fmt");
360 "QUOTA feature is enabled, so ignore jquota_fmt");
361 F2FS_OPTION(sbi).s_jquota_fmt = 0; 353 F2FS_OPTION(sbi).s_jquota_fmt = 0;
362 } 354 }
363 return 0; 355 return 0;
@@ -425,8 +417,7 @@ static int parse_options(struct super_block *sb, char *options)
425 break; 417 break;
426 case Opt_nodiscard: 418 case Opt_nodiscard:
427 if (f2fs_sb_has_blkzoned(sbi)) { 419 if (f2fs_sb_has_blkzoned(sbi)) {
428 f2fs_msg(sb, KERN_WARNING, 420 f2fs_warn(sbi, "discard is required for zoned block devices");
429 "discard is required for zoned block devices");
430 return -EINVAL; 421 return -EINVAL;
431 } 422 }
432 clear_opt(sbi, DISCARD); 423 clear_opt(sbi, DISCARD);
@@ -458,20 +449,16 @@ static int parse_options(struct super_block *sb, char *options)
458 break; 449 break;
459#else 450#else
460 case Opt_user_xattr: 451 case Opt_user_xattr:
461 f2fs_msg(sb, KERN_INFO, 452 f2fs_info(sbi, "user_xattr options not supported");
462 "user_xattr options not supported");
463 break; 453 break;
464 case Opt_nouser_xattr: 454 case Opt_nouser_xattr:
465 f2fs_msg(sb, KERN_INFO, 455 f2fs_info(sbi, "nouser_xattr options not supported");
466 "nouser_xattr options not supported");
467 break; 456 break;
468 case Opt_inline_xattr: 457 case Opt_inline_xattr:
469 f2fs_msg(sb, KERN_INFO, 458 f2fs_info(sbi, "inline_xattr options not supported");
470 "inline_xattr options not supported");
471 break; 459 break;
472 case Opt_noinline_xattr: 460 case Opt_noinline_xattr:
473 f2fs_msg(sb, KERN_INFO, 461 f2fs_info(sbi, "noinline_xattr options not supported");
474 "noinline_xattr options not supported");
475 break; 462 break;
476#endif 463#endif
477#ifdef CONFIG_F2FS_FS_POSIX_ACL 464#ifdef CONFIG_F2FS_FS_POSIX_ACL
@@ -483,10 +470,10 @@ static int parse_options(struct super_block *sb, char *options)
483 break; 470 break;
484#else 471#else
485 case Opt_acl: 472 case Opt_acl:
486 f2fs_msg(sb, KERN_INFO, "acl options not supported"); 473 f2fs_info(sbi, "acl options not supported");
487 break; 474 break;
488 case Opt_noacl: 475 case Opt_noacl:
489 f2fs_msg(sb, KERN_INFO, "noacl options not supported"); 476 f2fs_info(sbi, "noacl options not supported");
490 break; 477 break;
491#endif 478#endif
492 case Opt_active_logs: 479 case Opt_active_logs:
@@ -536,9 +523,8 @@ static int parse_options(struct super_block *sb, char *options)
536 if (args->from && match_int(args, &arg)) 523 if (args->from && match_int(args, &arg))
537 return -EINVAL; 524 return -EINVAL;
538 if (test_opt(sbi, RESERVE_ROOT)) { 525 if (test_opt(sbi, RESERVE_ROOT)) {
539 f2fs_msg(sb, KERN_INFO, 526 f2fs_info(sbi, "Preserve previous reserve_root=%u",
540 "Preserve previous reserve_root=%u", 527 F2FS_OPTION(sbi).root_reserved_blocks);
541 F2FS_OPTION(sbi).root_reserved_blocks);
542 } else { 528 } else {
543 F2FS_OPTION(sbi).root_reserved_blocks = arg; 529 F2FS_OPTION(sbi).root_reserved_blocks = arg;
544 set_opt(sbi, RESERVE_ROOT); 530 set_opt(sbi, RESERVE_ROOT);
@@ -549,8 +535,7 @@ static int parse_options(struct super_block *sb, char *options)
549 return -EINVAL; 535 return -EINVAL;
550 uid = make_kuid(current_user_ns(), arg); 536 uid = make_kuid(current_user_ns(), arg);
551 if (!uid_valid(uid)) { 537 if (!uid_valid(uid)) {
552 f2fs_msg(sb, KERN_ERR, 538 f2fs_err(sbi, "Invalid uid value %d", arg);
553 "Invalid uid value %d", arg);
554 return -EINVAL; 539 return -EINVAL;
555 } 540 }
556 F2FS_OPTION(sbi).s_resuid = uid; 541 F2FS_OPTION(sbi).s_resuid = uid;
@@ -560,8 +545,7 @@ static int parse_options(struct super_block *sb, char *options)
560 return -EINVAL; 545 return -EINVAL;
561 gid = make_kgid(current_user_ns(), arg); 546 gid = make_kgid(current_user_ns(), arg);
562 if (!gid_valid(gid)) { 547 if (!gid_valid(gid)) {
563 f2fs_msg(sb, KERN_ERR, 548 f2fs_err(sbi, "Invalid gid value %d", arg);
564 "Invalid gid value %d", arg);
565 return -EINVAL; 549 return -EINVAL;
566 } 550 }
567 F2FS_OPTION(sbi).s_resgid = gid; 551 F2FS_OPTION(sbi).s_resgid = gid;
@@ -574,9 +558,7 @@ static int parse_options(struct super_block *sb, char *options)
574 if (strlen(name) == 8 && 558 if (strlen(name) == 8 &&
575 !strncmp(name, "adaptive", 8)) { 559 !strncmp(name, "adaptive", 8)) {
576 if (f2fs_sb_has_blkzoned(sbi)) { 560 if (f2fs_sb_has_blkzoned(sbi)) {
577 f2fs_msg(sb, KERN_WARNING, 561 f2fs_warn(sbi, "adaptive mode is not allowed with zoned block device feature");
578 "adaptive mode is not allowed with "
579 "zoned block device feature");
580 kvfree(name); 562 kvfree(name);
581 return -EINVAL; 563 return -EINVAL;
582 } 564 }
@@ -594,9 +576,8 @@ static int parse_options(struct super_block *sb, char *options)
594 if (args->from && match_int(args, &arg)) 576 if (args->from && match_int(args, &arg))
595 return -EINVAL; 577 return -EINVAL;
596 if (arg <= 0 || arg > __ilog2_u32(BIO_MAX_PAGES)) { 578 if (arg <= 0 || arg > __ilog2_u32(BIO_MAX_PAGES)) {
597 f2fs_msg(sb, KERN_WARNING, 579 f2fs_warn(sbi, "Not support %d, larger than %d",
598 "Not support %d, larger than %d", 580 1 << arg, BIO_MAX_PAGES);
599 1 << arg, BIO_MAX_PAGES);
600 return -EINVAL; 581 return -EINVAL;
601 } 582 }
602 F2FS_OPTION(sbi).write_io_size_bits = arg; 583 F2FS_OPTION(sbi).write_io_size_bits = arg;
@@ -617,13 +598,11 @@ static int parse_options(struct super_block *sb, char *options)
617 break; 598 break;
618#else 599#else
619 case Opt_fault_injection: 600 case Opt_fault_injection:
620 f2fs_msg(sb, KERN_INFO, 601 f2fs_info(sbi, "fault_injection options not supported");
621 "fault_injection options not supported");
622 break; 602 break;
623 603
624 case Opt_fault_type: 604 case Opt_fault_type:
625 f2fs_msg(sb, KERN_INFO, 605 f2fs_info(sbi, "fault_type options not supported");
626 "fault_type options not supported");
627 break; 606 break;
628#endif 607#endif
629 case Opt_lazytime: 608 case Opt_lazytime:
@@ -703,8 +682,7 @@ static int parse_options(struct super_block *sb, char *options)
703 case Opt_jqfmt_vfsv0: 682 case Opt_jqfmt_vfsv0:
704 case Opt_jqfmt_vfsv1: 683 case Opt_jqfmt_vfsv1:
705 case Opt_noquota: 684 case Opt_noquota:
706 f2fs_msg(sb, KERN_INFO, 685 f2fs_info(sbi, "quota operations not supported");
707 "quota operations not supported");
708 break; 686 break;
709#endif 687#endif
710 case Opt_whint: 688 case Opt_whint:
@@ -766,16 +744,14 @@ static int parse_options(struct super_block *sb, char *options)
766 case Opt_test_dummy_encryption: 744 case Opt_test_dummy_encryption:
767#ifdef CONFIG_FS_ENCRYPTION 745#ifdef CONFIG_FS_ENCRYPTION
768 if (!f2fs_sb_has_encrypt(sbi)) { 746 if (!f2fs_sb_has_encrypt(sbi)) {
769 f2fs_msg(sb, KERN_ERR, "Encrypt feature is off"); 747 f2fs_err(sbi, "Encrypt feature is off");
770 return -EINVAL; 748 return -EINVAL;
771 } 749 }
772 750
773 F2FS_OPTION(sbi).test_dummy_encryption = true; 751 F2FS_OPTION(sbi).test_dummy_encryption = true;
774 f2fs_msg(sb, KERN_INFO, 752 f2fs_info(sbi, "Test dummy encryption mode enabled");
775 "Test dummy encryption mode enabled");
776#else 753#else
777 f2fs_msg(sb, KERN_INFO, 754 f2fs_info(sbi, "Test dummy encryption mount option ignored");
778 "Test dummy encryption mount option ignored");
779#endif 755#endif
780 break; 756 break;
781 case Opt_checkpoint_disable_cap_perc: 757 case Opt_checkpoint_disable_cap_perc:
@@ -804,9 +780,8 @@ static int parse_options(struct super_block *sb, char *options)
804 clear_opt(sbi, DISABLE_CHECKPOINT); 780 clear_opt(sbi, DISABLE_CHECKPOINT);
805 break; 781 break;
806 default: 782 default:
807 f2fs_msg(sb, KERN_ERR, 783 f2fs_err(sbi, "Unrecognized mount option \"%s\" or missing value",
808 "Unrecognized mount option \"%s\" or missing value", 784 p);
809 p);
810 return -EINVAL; 785 return -EINVAL;
811 } 786 }
812 } 787 }
@@ -815,23 +790,18 @@ static int parse_options(struct super_block *sb, char *options)
815 return -EINVAL; 790 return -EINVAL;
816#else 791#else
817 if (f2fs_sb_has_quota_ino(sbi) && !f2fs_readonly(sbi->sb)) { 792 if (f2fs_sb_has_quota_ino(sbi) && !f2fs_readonly(sbi->sb)) {
818 f2fs_msg(sbi->sb, KERN_INFO, 793 f2fs_info(sbi, "Filesystem with quota feature cannot be mounted RDWR without CONFIG_QUOTA");
819 "Filesystem with quota feature cannot be mounted RDWR "
820 "without CONFIG_QUOTA");
821 return -EINVAL; 794 return -EINVAL;
822 } 795 }
823 if (f2fs_sb_has_project_quota(sbi) && !f2fs_readonly(sbi->sb)) { 796 if (f2fs_sb_has_project_quota(sbi) && !f2fs_readonly(sbi->sb)) {
824 f2fs_msg(sb, KERN_ERR, 797 f2fs_err(sbi, "Filesystem with project quota feature cannot be mounted RDWR without CONFIG_QUOTA");
825 "Filesystem with project quota feature cannot be "
826 "mounted RDWR without CONFIG_QUOTA");
827 return -EINVAL; 798 return -EINVAL;
828 } 799 }
829#endif 800#endif
830 801
831 if (F2FS_IO_SIZE_BITS(sbi) && !test_opt(sbi, LFS)) { 802 if (F2FS_IO_SIZE_BITS(sbi) && !test_opt(sbi, LFS)) {
832 f2fs_msg(sb, KERN_ERR, 803 f2fs_err(sbi, "Should set mode=lfs with %uKB-sized IO",
833 "Should set mode=lfs with %uKB-sized IO", 804 F2FS_IO_SIZE_KB(sbi));
834 F2FS_IO_SIZE_KB(sbi));
835 return -EINVAL; 805 return -EINVAL;
836 } 806 }
837 807
@@ -840,15 +810,11 @@ static int parse_options(struct super_block *sb, char *options)
840 810
841 if (!f2fs_sb_has_extra_attr(sbi) || 811 if (!f2fs_sb_has_extra_attr(sbi) ||
842 !f2fs_sb_has_flexible_inline_xattr(sbi)) { 812 !f2fs_sb_has_flexible_inline_xattr(sbi)) {
843 f2fs_msg(sb, KERN_ERR, 813 f2fs_err(sbi, "extra_attr or flexible_inline_xattr feature is off");
844 "extra_attr or flexible_inline_xattr "
845 "feature is off");
846 return -EINVAL; 814 return -EINVAL;
847 } 815 }
848 if (!test_opt(sbi, INLINE_XATTR)) { 816 if (!test_opt(sbi, INLINE_XATTR)) {
849 f2fs_msg(sb, KERN_ERR, 817 f2fs_err(sbi, "inline_xattr_size option should be set with inline_xattr option");
850 "inline_xattr_size option should be "
851 "set with inline_xattr option");
852 return -EINVAL; 818 return -EINVAL;
853 } 819 }
854 820
@@ -857,16 +823,14 @@ static int parse_options(struct super_block *sb, char *options)
857 823
858 if (F2FS_OPTION(sbi).inline_xattr_size < min_size || 824 if (F2FS_OPTION(sbi).inline_xattr_size < min_size ||
859 F2FS_OPTION(sbi).inline_xattr_size > max_size) { 825 F2FS_OPTION(sbi).inline_xattr_size > max_size) {
860 f2fs_msg(sb, KERN_ERR, 826 f2fs_err(sbi, "inline xattr size is out of range: %d ~ %d",
861 "inline xattr size is out of range: %d ~ %d", 827 min_size, max_size);
862 min_size, max_size);
863 return -EINVAL; 828 return -EINVAL;
864 } 829 }
865 } 830 }
866 831
867 if (test_opt(sbi, DISABLE_CHECKPOINT) && test_opt(sbi, LFS)) { 832 if (test_opt(sbi, DISABLE_CHECKPOINT) && test_opt(sbi, LFS)) {
868 f2fs_msg(sb, KERN_ERR, 833 f2fs_err(sbi, "LFS not compatible with checkpoint=disable\n");
869 "LFS not compatible with checkpoint=disable\n");
870 return -EINVAL; 834 return -EINVAL;
871 } 835 }
872 836
@@ -1488,8 +1452,7 @@ static int f2fs_disable_checkpoint(struct f2fs_sb_info *sbi)
1488 block_t unusable; 1452 block_t unusable;
1489 1453
1490 if (s_flags & SB_RDONLY) { 1454 if (s_flags & SB_RDONLY) {
1491 f2fs_msg(sbi->sb, KERN_ERR, 1455 f2fs_err(sbi, "checkpoint=disable on readonly fs");
1492 "checkpoint=disable on readonly fs");
1493 return -EINVAL; 1456 return -EINVAL;
1494 } 1457 }
1495 sbi->sb->s_flags |= SB_ACTIVE; 1458 sbi->sb->s_flags |= SB_ACTIVE;
@@ -1592,8 +1555,8 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
1592 /* recover superblocks we couldn't write due to previous RO mount */ 1555 /* recover superblocks we couldn't write due to previous RO mount */
1593 if (!(*flags & SB_RDONLY) && is_sbi_flag_set(sbi, SBI_NEED_SB_WRITE)) { 1556 if (!(*flags & SB_RDONLY) && is_sbi_flag_set(sbi, SBI_NEED_SB_WRITE)) {
1594 err = f2fs_commit_super(sbi, false); 1557 err = f2fs_commit_super(sbi, false);
1595 f2fs_msg(sb, KERN_INFO, 1558 f2fs_info(sbi, "Try to recover all the superblocks, ret: %d",
1596 "Try to recover all the superblocks, ret: %d", err); 1559 err);
1597 if (!err) 1560 if (!err)
1598 clear_sbi_flag(sbi, SBI_NEED_SB_WRITE); 1561 clear_sbi_flag(sbi, SBI_NEED_SB_WRITE);
1599 } 1562 }
@@ -1634,15 +1597,13 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
1634 /* disallow enable/disable extent_cache dynamically */ 1597 /* disallow enable/disable extent_cache dynamically */
1635 if (no_extent_cache == !!test_opt(sbi, EXTENT_CACHE)) { 1598 if (no_extent_cache == !!test_opt(sbi, EXTENT_CACHE)) {
1636 err = -EINVAL; 1599 err = -EINVAL;
1637 f2fs_msg(sbi->sb, KERN_WARNING, 1600 f2fs_warn(sbi, "switch extent_cache option is not allowed");
1638 "switch extent_cache option is not allowed");
1639 goto restore_opts; 1601 goto restore_opts;
1640 } 1602 }
1641 1603
1642 if ((*flags & SB_RDONLY) && test_opt(sbi, DISABLE_CHECKPOINT)) { 1604 if ((*flags & SB_RDONLY) && test_opt(sbi, DISABLE_CHECKPOINT)) {
1643 err = -EINVAL; 1605 err = -EINVAL;
1644 f2fs_msg(sbi->sb, KERN_WARNING, 1606 f2fs_warn(sbi, "disabling checkpoint not compatible with read-only");
1645 "disabling checkpoint not compatible with read-only");
1646 goto restore_opts; 1607 goto restore_opts;
1647 } 1608 }
1648 1609
@@ -1712,8 +1673,7 @@ skip:
1712restore_gc: 1673restore_gc:
1713 if (need_restart_gc) { 1674 if (need_restart_gc) {
1714 if (f2fs_start_gc_thread(sbi)) 1675 if (f2fs_start_gc_thread(sbi))
1715 f2fs_msg(sbi->sb, KERN_WARNING, 1676 f2fs_warn(sbi, "background gc thread has stopped");
1716 "background gc thread has stopped");
1717 } else if (need_stop_gc) { 1677 } else if (need_stop_gc) {
1718 f2fs_stop_gc_thread(sbi); 1678 f2fs_stop_gc_thread(sbi);
1719 } 1679 }
@@ -1852,8 +1812,7 @@ static qsize_t *f2fs_get_reserved_space(struct inode *inode)
1852static int f2fs_quota_on_mount(struct f2fs_sb_info *sbi, int type) 1812static int f2fs_quota_on_mount(struct f2fs_sb_info *sbi, int type)
1853{ 1813{
1854 if (is_set_ckpt_flags(sbi, CP_QUOTA_NEED_FSCK_FLAG)) { 1814 if (is_set_ckpt_flags(sbi, CP_QUOTA_NEED_FSCK_FLAG)) {
1855 f2fs_msg(sbi->sb, KERN_ERR, 1815 f2fs_err(sbi, "quota sysfile may be corrupted, skip loading it");
1856 "quota sysfile may be corrupted, skip loading it");
1857 return 0; 1816 return 0;
1858 } 1817 }
1859 1818
@@ -1869,8 +1828,7 @@ int f2fs_enable_quota_files(struct f2fs_sb_info *sbi, bool rdonly)
1869 if (f2fs_sb_has_quota_ino(sbi) && rdonly) { 1828 if (f2fs_sb_has_quota_ino(sbi) && rdonly) {
1870 err = f2fs_enable_quotas(sbi->sb); 1829 err = f2fs_enable_quotas(sbi->sb);
1871 if (err) { 1830 if (err) {
1872 f2fs_msg(sbi->sb, KERN_ERR, 1831 f2fs_err(sbi, "Cannot turn on quota_ino: %d", err);
1873 "Cannot turn on quota_ino: %d", err);
1874 return 0; 1832 return 0;
1875 } 1833 }
1876 return 1; 1834 return 1;
@@ -1883,8 +1841,8 @@ int f2fs_enable_quota_files(struct f2fs_sb_info *sbi, bool rdonly)
1883 enabled = 1; 1841 enabled = 1;
1884 continue; 1842 continue;
1885 } 1843 }
1886 f2fs_msg(sbi->sb, KERN_ERR, 1844 f2fs_err(sbi, "Cannot turn on quotas: %d on %d",
1887 "Cannot turn on quotas: %d on %d", err, i); 1845 err, i);
1888 } 1846 }
1889 } 1847 }
1890 return enabled; 1848 return enabled;
@@ -1905,8 +1863,7 @@ static int f2fs_quota_enable(struct super_block *sb, int type, int format_id,
1905 1863
1906 qf_inode = f2fs_iget(sb, qf_inum); 1864 qf_inode = f2fs_iget(sb, qf_inum);
1907 if (IS_ERR(qf_inode)) { 1865 if (IS_ERR(qf_inode)) {
1908 f2fs_msg(sb, KERN_ERR, 1866 f2fs_err(F2FS_SB(sb), "Bad quota inode %u:%lu", type, qf_inum);
1909 "Bad quota inode %u:%lu", type, qf_inum);
1910 return PTR_ERR(qf_inode); 1867 return PTR_ERR(qf_inode);
1911 } 1868 }
1912 1869
@@ -1919,17 +1876,17 @@ static int f2fs_quota_enable(struct super_block *sb, int type, int format_id,
1919 1876
1920static int f2fs_enable_quotas(struct super_block *sb) 1877static int f2fs_enable_quotas(struct super_block *sb)
1921{ 1878{
1879 struct f2fs_sb_info *sbi = F2FS_SB(sb);
1922 int type, err = 0; 1880 int type, err = 0;
1923 unsigned long qf_inum; 1881 unsigned long qf_inum;
1924 bool quota_mopt[MAXQUOTAS] = { 1882 bool quota_mopt[MAXQUOTAS] = {
1925 test_opt(F2FS_SB(sb), USRQUOTA), 1883 test_opt(sbi, USRQUOTA),
1926 test_opt(F2FS_SB(sb), GRPQUOTA), 1884 test_opt(sbi, GRPQUOTA),
1927 test_opt(F2FS_SB(sb), PRJQUOTA), 1885 test_opt(sbi, PRJQUOTA),
1928 }; 1886 };
1929 1887
1930 if (is_set_ckpt_flags(F2FS_SB(sb), CP_QUOTA_NEED_FSCK_FLAG)) { 1888 if (is_set_ckpt_flags(F2FS_SB(sb), CP_QUOTA_NEED_FSCK_FLAG)) {
1931 f2fs_msg(sb, KERN_ERR, 1889 f2fs_err(sbi, "quota file may be corrupted, skip loading it");
1932 "quota file may be corrupted, skip loading it");
1933 return 0; 1890 return 0;
1934 } 1891 }
1935 1892
@@ -1942,10 +1899,8 @@ static int f2fs_enable_quotas(struct super_block *sb)
1942 DQUOT_USAGE_ENABLED | 1899 DQUOT_USAGE_ENABLED |
1943 (quota_mopt[type] ? DQUOT_LIMITS_ENABLED : 0)); 1900 (quota_mopt[type] ? DQUOT_LIMITS_ENABLED : 0));
1944 if (err) { 1901 if (err) {
1945 f2fs_msg(sb, KERN_ERR, 1902 f2fs_err(sbi, "Failed to enable quota tracking (type=%d, err=%d). Please run fsck to fix.",
1946 "Failed to enable quota tracking " 1903 type, err);
1947 "(type=%d, err=%d). Please run "
1948 "fsck to fix.", type, err);
1949 for (type--; type >= 0; type--) 1904 for (type--; type >= 0; type--)
1950 dquot_quota_off(sb, type); 1905 dquot_quota_off(sb, type);
1951 set_sbi_flag(F2FS_SB(sb), 1906 set_sbi_flag(F2FS_SB(sb),
@@ -2065,10 +2020,8 @@ void f2fs_quota_off_umount(struct super_block *sb)
2065 if (err) { 2020 if (err) {
2066 int ret = dquot_quota_off(sb, type); 2021 int ret = dquot_quota_off(sb, type);
2067 2022
2068 f2fs_msg(sb, KERN_ERR, 2023 f2fs_err(F2FS_SB(sb), "Fail to turn off disk quota (type: %d, err: %d, ret:%d), Please run fsck to fix it.",
2069 "Fail to turn off disk quota " 2024 type, err, ret);
2070 "(type: %d, err: %d, ret:%d), Please "
2071 "run fsck to fix it.", type, err, ret);
2072 set_sbi_flag(F2FS_SB(sb), SBI_QUOTA_NEED_REPAIR); 2025 set_sbi_flag(F2FS_SB(sb), SBI_QUOTA_NEED_REPAIR);
2073 } 2026 }
2074 } 2027 }
@@ -2361,55 +2314,49 @@ static inline bool sanity_check_area_boundary(struct f2fs_sb_info *sbi,
2361 (segment_count << log_blocks_per_seg); 2314 (segment_count << log_blocks_per_seg);
2362 2315
2363 if (segment0_blkaddr != cp_blkaddr) { 2316 if (segment0_blkaddr != cp_blkaddr) {
2364 f2fs_msg(sb, KERN_INFO, 2317 f2fs_info(sbi, "Mismatch start address, segment0(%u) cp_blkaddr(%u)",
2365 "Mismatch start address, segment0(%u) cp_blkaddr(%u)", 2318 segment0_blkaddr, cp_blkaddr);
2366 segment0_blkaddr, cp_blkaddr);
2367 return true; 2319 return true;
2368 } 2320 }
2369 2321
2370 if (cp_blkaddr + (segment_count_ckpt << log_blocks_per_seg) != 2322 if (cp_blkaddr + (segment_count_ckpt << log_blocks_per_seg) !=
2371 sit_blkaddr) { 2323 sit_blkaddr) {
2372 f2fs_msg(sb, KERN_INFO, 2324 f2fs_info(sbi, "Wrong CP boundary, start(%u) end(%u) blocks(%u)",
2373 "Wrong CP boundary, start(%u) end(%u) blocks(%u)", 2325 cp_blkaddr, sit_blkaddr,
2374 cp_blkaddr, sit_blkaddr, 2326 segment_count_ckpt << log_blocks_per_seg);
2375 segment_count_ckpt << log_blocks_per_seg);
2376 return true; 2327 return true;
2377 } 2328 }
2378 2329
2379 if (sit_blkaddr + (segment_count_sit << log_blocks_per_seg) != 2330 if (sit_blkaddr + (segment_count_sit << log_blocks_per_seg) !=
2380 nat_blkaddr) { 2331 nat_blkaddr) {
2381 f2fs_msg(sb, KERN_INFO, 2332 f2fs_info(sbi, "Wrong SIT boundary, start(%u) end(%u) blocks(%u)",
2382 "Wrong SIT boundary, start(%u) end(%u) blocks(%u)", 2333 sit_blkaddr, nat_blkaddr,
2383 sit_blkaddr, nat_blkaddr, 2334 segment_count_sit << log_blocks_per_seg);
2384 segment_count_sit << log_blocks_per_seg);
2385 return true; 2335 return true;
2386 } 2336 }
2387 2337
2388 if (nat_blkaddr + (segment_count_nat << log_blocks_per_seg) != 2338 if (nat_blkaddr + (segment_count_nat << log_blocks_per_seg) !=
2389 ssa_blkaddr) { 2339 ssa_blkaddr) {
2390 f2fs_msg(sb, KERN_INFO, 2340 f2fs_info(sbi, "Wrong NAT boundary, start(%u) end(%u) blocks(%u)",
2391 "Wrong NAT boundary, start(%u) end(%u) blocks(%u)", 2341 nat_blkaddr, ssa_blkaddr,
2392 nat_blkaddr, ssa_blkaddr, 2342 segment_count_nat << log_blocks_per_seg);
2393 segment_count_nat << log_blocks_per_seg);
2394 return true; 2343 return true;
2395 } 2344 }
2396 2345
2397 if (ssa_blkaddr + (segment_count_ssa << log_blocks_per_seg) != 2346 if (ssa_blkaddr + (segment_count_ssa << log_blocks_per_seg) !=
2398 main_blkaddr) { 2347 main_blkaddr) {
2399 f2fs_msg(sb, KERN_INFO, 2348 f2fs_info(sbi, "Wrong SSA boundary, start(%u) end(%u) blocks(%u)",
2400 "Wrong SSA boundary, start(%u) end(%u) blocks(%u)", 2349 ssa_blkaddr, main_blkaddr,
2401 ssa_blkaddr, main_blkaddr, 2350 segment_count_ssa << log_blocks_per_seg);
2402 segment_count_ssa << log_blocks_per_seg);
2403 return true; 2351 return true;
2404 } 2352 }
2405 2353
2406 if (main_end_blkaddr > seg_end_blkaddr) { 2354 if (main_end_blkaddr > seg_end_blkaddr) {
2407 f2fs_msg(sb, KERN_INFO, 2355 f2fs_info(sbi, "Wrong MAIN_AREA boundary, start(%u) end(%u) block(%u)",
2408 "Wrong MAIN_AREA boundary, start(%u) end(%u) block(%u)", 2356 main_blkaddr,
2409 main_blkaddr, 2357 segment0_blkaddr +
2410 segment0_blkaddr + 2358 (segment_count << log_blocks_per_seg),
2411 (segment_count << log_blocks_per_seg), 2359 segment_count_main << log_blocks_per_seg);
2412 segment_count_main << log_blocks_per_seg);
2413 return true; 2360 return true;
2414 } else if (main_end_blkaddr < seg_end_blkaddr) { 2361 } else if (main_end_blkaddr < seg_end_blkaddr) {
2415 int err = 0; 2362 int err = 0;
@@ -2426,12 +2373,11 @@ static inline bool sanity_check_area_boundary(struct f2fs_sb_info *sbi,
2426 err = __f2fs_commit_super(bh, NULL); 2373 err = __f2fs_commit_super(bh, NULL);
2427 res = err ? "failed" : "done"; 2374 res = err ? "failed" : "done";
2428 } 2375 }
2429 f2fs_msg(sb, KERN_INFO, 2376 f2fs_info(sbi, "Fix alignment : %s, start(%u) end(%u) block(%u)",
2430 "Fix alignment : %s, start(%u) end(%u) block(%u)", 2377 res, main_blkaddr,
2431 res, main_blkaddr, 2378 segment0_blkaddr +
2432 segment0_blkaddr + 2379 (segment_count << log_blocks_per_seg),
2433 (segment_count << log_blocks_per_seg), 2380 segment_count_main << log_blocks_per_seg);
2434 segment_count_main << log_blocks_per_seg);
2435 if (err) 2381 if (err)
2436 return true; 2382 return true;
2437 } 2383 }
@@ -2445,7 +2391,6 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,
2445 block_t total_sections, blocks_per_seg; 2391 block_t total_sections, blocks_per_seg;
2446 struct f2fs_super_block *raw_super = (struct f2fs_super_block *) 2392 struct f2fs_super_block *raw_super = (struct f2fs_super_block *)
2447 (bh->b_data + F2FS_SUPER_OFFSET); 2393 (bh->b_data + F2FS_SUPER_OFFSET);
2448 struct super_block *sb = sbi->sb;
2449 unsigned int blocksize; 2394 unsigned int blocksize;
2450 size_t crc_offset = 0; 2395 size_t crc_offset = 0;
2451 __u32 crc = 0; 2396 __u32 crc = 0;
@@ -2455,48 +2400,42 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,
2455 crc_offset = le32_to_cpu(raw_super->checksum_offset); 2400 crc_offset = le32_to_cpu(raw_super->checksum_offset);
2456 if (crc_offset != 2401 if (crc_offset !=
2457 offsetof(struct f2fs_super_block, crc)) { 2402 offsetof(struct f2fs_super_block, crc)) {
2458 f2fs_msg(sb, KERN_INFO, 2403 f2fs_info(sbi, "Invalid SB checksum offset: %zu",
2459 "Invalid SB checksum offset: %zu", 2404 crc_offset);
2460 crc_offset);
2461 return 1; 2405 return 1;
2462 } 2406 }
2463 crc = le32_to_cpu(raw_super->crc); 2407 crc = le32_to_cpu(raw_super->crc);
2464 if (!f2fs_crc_valid(sbi, crc, raw_super, crc_offset)) { 2408 if (!f2fs_crc_valid(sbi, crc, raw_super, crc_offset)) {
2465 f2fs_msg(sb, KERN_INFO, 2409 f2fs_info(sbi, "Invalid SB checksum value: %u", crc);
2466 "Invalid SB checksum value: %u", crc);
2467 return 1; 2410 return 1;
2468 } 2411 }
2469 } 2412 }
2470 2413
2471 if (F2FS_SUPER_MAGIC != le32_to_cpu(raw_super->magic)) { 2414 if (F2FS_SUPER_MAGIC != le32_to_cpu(raw_super->magic)) {
2472 f2fs_msg(sb, KERN_INFO, 2415 f2fs_info(sbi, "Magic Mismatch, valid(0x%x) - read(0x%x)",
2473 "Magic Mismatch, valid(0x%x) - read(0x%x)", 2416 F2FS_SUPER_MAGIC, le32_to_cpu(raw_super->magic));
2474 F2FS_SUPER_MAGIC, le32_to_cpu(raw_super->magic));
2475 return 1; 2417 return 1;
2476 } 2418 }
2477 2419
2478 /* Currently, support only 4KB page cache size */ 2420 /* Currently, support only 4KB page cache size */
2479 if (F2FS_BLKSIZE != PAGE_SIZE) { 2421 if (F2FS_BLKSIZE != PAGE_SIZE) {
2480 f2fs_msg(sb, KERN_INFO, 2422 f2fs_info(sbi, "Invalid page_cache_size (%lu), supports only 4KB",
2481 "Invalid page_cache_size (%lu), supports only 4KB", 2423 PAGE_SIZE);
2482 PAGE_SIZE);
2483 return 1; 2424 return 1;
2484 } 2425 }
2485 2426
2486 /* Currently, support only 4KB block size */ 2427 /* Currently, support only 4KB block size */
2487 blocksize = 1 << le32_to_cpu(raw_super->log_blocksize); 2428 blocksize = 1 << le32_to_cpu(raw_super->log_blocksize);
2488 if (blocksize != F2FS_BLKSIZE) { 2429 if (blocksize != F2FS_BLKSIZE) {
2489 f2fs_msg(sb, KERN_INFO, 2430 f2fs_info(sbi, "Invalid blocksize (%u), supports only 4KB",
2490 "Invalid blocksize (%u), supports only 4KB", 2431 blocksize);
2491 blocksize);
2492 return 1; 2432 return 1;
2493 } 2433 }
2494 2434
2495 /* check log blocks per segment */ 2435 /* check log blocks per segment */
2496 if (le32_to_cpu(raw_super->log_blocks_per_seg) != 9) { 2436 if (le32_to_cpu(raw_super->log_blocks_per_seg) != 9) {
2497 f2fs_msg(sb, KERN_INFO, 2437 f2fs_info(sbi, "Invalid log blocks per segment (%u)",
2498 "Invalid log blocks per segment (%u)", 2438 le32_to_cpu(raw_super->log_blocks_per_seg));
2499 le32_to_cpu(raw_super->log_blocks_per_seg));
2500 return 1; 2439 return 1;
2501 } 2440 }
2502 2441
@@ -2505,17 +2444,16 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,
2505 F2FS_MAX_LOG_SECTOR_SIZE || 2444 F2FS_MAX_LOG_SECTOR_SIZE ||
2506 le32_to_cpu(raw_super->log_sectorsize) < 2445 le32_to_cpu(raw_super->log_sectorsize) <
2507 F2FS_MIN_LOG_SECTOR_SIZE) { 2446 F2FS_MIN_LOG_SECTOR_SIZE) {
2508 f2fs_msg(sb, KERN_INFO, "Invalid log sectorsize (%u)", 2447 f2fs_info(sbi, "Invalid log sectorsize (%u)",
2509 le32_to_cpu(raw_super->log_sectorsize)); 2448 le32_to_cpu(raw_super->log_sectorsize));
2510 return 1; 2449 return 1;
2511 } 2450 }
2512 if (le32_to_cpu(raw_super->log_sectors_per_block) + 2451 if (le32_to_cpu(raw_super->log_sectors_per_block) +
2513 le32_to_cpu(raw_super->log_sectorsize) != 2452 le32_to_cpu(raw_super->log_sectorsize) !=
2514 F2FS_MAX_LOG_SECTOR_SIZE) { 2453 F2FS_MAX_LOG_SECTOR_SIZE) {
2515 f2fs_msg(sb, KERN_INFO, 2454 f2fs_info(sbi, "Invalid log sectors per block(%u) log sectorsize(%u)",
2516 "Invalid log sectors per block(%u) log sectorsize(%u)", 2455 le32_to_cpu(raw_super->log_sectors_per_block),
2517 le32_to_cpu(raw_super->log_sectors_per_block), 2456 le32_to_cpu(raw_super->log_sectorsize));
2518 le32_to_cpu(raw_super->log_sectorsize));
2519 return 1; 2457 return 1;
2520 } 2458 }
2521 2459
@@ -2529,59 +2467,51 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,
2529 2467
2530 if (segment_count > F2FS_MAX_SEGMENT || 2468 if (segment_count > F2FS_MAX_SEGMENT ||
2531 segment_count < F2FS_MIN_SEGMENTS) { 2469 segment_count < F2FS_MIN_SEGMENTS) {
2532 f2fs_msg(sb, KERN_INFO, 2470 f2fs_info(sbi, "Invalid segment count (%u)", segment_count);
2533 "Invalid segment count (%u)",
2534 segment_count);
2535 return 1; 2471 return 1;
2536 } 2472 }
2537 2473
2538 if (total_sections > segment_count || 2474 if (total_sections > segment_count ||
2539 total_sections < F2FS_MIN_SEGMENTS || 2475 total_sections < F2FS_MIN_SEGMENTS ||
2540 segs_per_sec > segment_count || !segs_per_sec) { 2476 segs_per_sec > segment_count || !segs_per_sec) {
2541 f2fs_msg(sb, KERN_INFO, 2477 f2fs_info(sbi, "Invalid segment/section count (%u, %u x %u)",
2542 "Invalid segment/section count (%u, %u x %u)", 2478 segment_count, total_sections, segs_per_sec);
2543 segment_count, total_sections, segs_per_sec);
2544 return 1; 2479 return 1;
2545 } 2480 }
2546 2481
2547 if ((segment_count / segs_per_sec) < total_sections) { 2482 if ((segment_count / segs_per_sec) < total_sections) {
2548 f2fs_msg(sb, KERN_INFO, 2483 f2fs_info(sbi, "Small segment_count (%u < %u * %u)",
2549 "Small segment_count (%u < %u * %u)", 2484 segment_count, segs_per_sec, total_sections);
2550 segment_count, segs_per_sec, total_sections);
2551 return 1; 2485 return 1;
2552 } 2486 }
2553 2487
2554 if (segment_count > (le64_to_cpu(raw_super->block_count) >> 9)) { 2488 if (segment_count > (le64_to_cpu(raw_super->block_count) >> 9)) {
2555 f2fs_msg(sb, KERN_INFO, 2489 f2fs_info(sbi, "Wrong segment_count / block_count (%u > %llu)",
2556 "Wrong segment_count / block_count (%u > %llu)", 2490 segment_count, le64_to_cpu(raw_super->block_count));
2557 segment_count, le64_to_cpu(raw_super->block_count));
2558 return 1; 2491 return 1;
2559 } 2492 }
2560 2493
2561 if (secs_per_zone > total_sections || !secs_per_zone) { 2494 if (secs_per_zone > total_sections || !secs_per_zone) {
2562 f2fs_msg(sb, KERN_INFO, 2495 f2fs_info(sbi, "Wrong secs_per_zone / total_sections (%u, %u)",
2563 "Wrong secs_per_zone / total_sections (%u, %u)", 2496 secs_per_zone, total_sections);
2564 secs_per_zone, total_sections);
2565 return 1; 2497 return 1;
2566 } 2498 }
2567 if (le32_to_cpu(raw_super->extension_count) > F2FS_MAX_EXTENSION || 2499 if (le32_to_cpu(raw_super->extension_count) > F2FS_MAX_EXTENSION ||
2568 raw_super->hot_ext_count > F2FS_MAX_EXTENSION || 2500 raw_super->hot_ext_count > F2FS_MAX_EXTENSION ||
2569 (le32_to_cpu(raw_super->extension_count) + 2501 (le32_to_cpu(raw_super->extension_count) +
2570 raw_super->hot_ext_count) > F2FS_MAX_EXTENSION) { 2502 raw_super->hot_ext_count) > F2FS_MAX_EXTENSION) {
2571 f2fs_msg(sb, KERN_INFO, 2503 f2fs_info(sbi, "Corrupted extension count (%u + %u > %u)",
2572 "Corrupted extension count (%u + %u > %u)", 2504 le32_to_cpu(raw_super->extension_count),
2573 le32_to_cpu(raw_super->extension_count), 2505 raw_super->hot_ext_count,
2574 raw_super->hot_ext_count, 2506 F2FS_MAX_EXTENSION);
2575 F2FS_MAX_EXTENSION);
2576 return 1; 2507 return 1;
2577 } 2508 }
2578 2509
2579 if (le32_to_cpu(raw_super->cp_payload) > 2510 if (le32_to_cpu(raw_super->cp_payload) >
2580 (blocks_per_seg - F2FS_CP_PACKS)) { 2511 (blocks_per_seg - F2FS_CP_PACKS)) {
2581 f2fs_msg(sb, KERN_INFO, 2512 f2fs_info(sbi, "Insane cp_payload (%u > %u)",
2582 "Insane cp_payload (%u > %u)", 2513 le32_to_cpu(raw_super->cp_payload),
2583 le32_to_cpu(raw_super->cp_payload), 2514 blocks_per_seg - F2FS_CP_PACKS);
2584 blocks_per_seg - F2FS_CP_PACKS);
2585 return 1; 2515 return 1;
2586 } 2516 }
2587 2517
@@ -2589,11 +2519,10 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,
2589 if (le32_to_cpu(raw_super->node_ino) != 1 || 2519 if (le32_to_cpu(raw_super->node_ino) != 1 ||
2590 le32_to_cpu(raw_super->meta_ino) != 2 || 2520 le32_to_cpu(raw_super->meta_ino) != 2 ||
2591 le32_to_cpu(raw_super->root_ino) != 3) { 2521 le32_to_cpu(raw_super->root_ino) != 3) {
2592 f2fs_msg(sb, KERN_INFO, 2522 f2fs_info(sbi, "Invalid Fs Meta Ino: node(%u) meta(%u) root(%u)",
2593 "Invalid Fs Meta Ino: node(%u) meta(%u) root(%u)", 2523 le32_to_cpu(raw_super->node_ino),
2594 le32_to_cpu(raw_super->node_ino), 2524 le32_to_cpu(raw_super->meta_ino),
2595 le32_to_cpu(raw_super->meta_ino), 2525 le32_to_cpu(raw_super->root_ino));
2596 le32_to_cpu(raw_super->root_ino));
2597 return 1; 2526 return 1;
2598 } 2527 }
2599 2528
@@ -2637,8 +2566,7 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi)
2637 2566
2638 if (unlikely(fsmeta < F2FS_MIN_SEGMENTS || 2567 if (unlikely(fsmeta < F2FS_MIN_SEGMENTS ||
2639 ovp_segments == 0 || reserved_segments == 0)) { 2568 ovp_segments == 0 || reserved_segments == 0)) {
2640 f2fs_msg(sbi->sb, KERN_ERR, 2569 f2fs_err(sbi, "Wrong layout: check mkfs.f2fs version");
2641 "Wrong layout: check mkfs.f2fs version");
2642 return 1; 2570 return 1;
2643 } 2571 }
2644 2572
@@ -2647,16 +2575,15 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi)
2647 log_blocks_per_seg = le32_to_cpu(raw_super->log_blocks_per_seg); 2575 log_blocks_per_seg = le32_to_cpu(raw_super->log_blocks_per_seg);
2648 if (!user_block_count || user_block_count >= 2576 if (!user_block_count || user_block_count >=
2649 segment_count_main << log_blocks_per_seg) { 2577 segment_count_main << log_blocks_per_seg) {
2650 f2fs_msg(sbi->sb, KERN_ERR, 2578 f2fs_err(sbi, "Wrong user_block_count: %u",
2651 "Wrong user_block_count: %u", user_block_count); 2579 user_block_count);
2652 return 1; 2580 return 1;
2653 } 2581 }
2654 2582
2655 valid_user_blocks = le64_to_cpu(ckpt->valid_block_count); 2583 valid_user_blocks = le64_to_cpu(ckpt->valid_block_count);
2656 if (valid_user_blocks > user_block_count) { 2584 if (valid_user_blocks > user_block_count) {
2657 f2fs_msg(sbi->sb, KERN_ERR, 2585 f2fs_err(sbi, "Wrong valid_user_blocks: %u, user_block_count: %u",
2658 "Wrong valid_user_blocks: %u, user_block_count: %u", 2586 valid_user_blocks, user_block_count);
2659 valid_user_blocks, user_block_count);
2660 return 1; 2587 return 1;
2661 } 2588 }
2662 2589
@@ -2664,9 +2591,8 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi)
2664 avail_node_count = sbi->total_node_count - sbi->nquota_files - 2591 avail_node_count = sbi->total_node_count - sbi->nquota_files -
2665 F2FS_RESERVED_NODE_NUM; 2592 F2FS_RESERVED_NODE_NUM;
2666 if (valid_node_count > avail_node_count) { 2593 if (valid_node_count > avail_node_count) {
2667 f2fs_msg(sbi->sb, KERN_ERR, 2594 f2fs_err(sbi, "Wrong valid_node_count: %u, avail_node_count: %u",
2668 "Wrong valid_node_count: %u, avail_node_count: %u", 2595 valid_node_count, avail_node_count);
2669 valid_node_count, avail_node_count);
2670 return 1; 2596 return 1;
2671 } 2597 }
2672 2598
@@ -2680,10 +2606,9 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi)
2680 for (j = i + 1; j < NR_CURSEG_NODE_TYPE; j++) { 2606 for (j = i + 1; j < NR_CURSEG_NODE_TYPE; j++) {
2681 if (le32_to_cpu(ckpt->cur_node_segno[i]) == 2607 if (le32_to_cpu(ckpt->cur_node_segno[i]) ==
2682 le32_to_cpu(ckpt->cur_node_segno[j])) { 2608 le32_to_cpu(ckpt->cur_node_segno[j])) {
2683 f2fs_msg(sbi->sb, KERN_ERR, 2609 f2fs_err(sbi, "Node segment (%u, %u) has the same segno: %u",
2684 "Node segment (%u, %u) has the same " 2610 i, j,
2685 "segno: %u", i, j, 2611 le32_to_cpu(ckpt->cur_node_segno[i]));
2686 le32_to_cpu(ckpt->cur_node_segno[i]));
2687 return 1; 2612 return 1;
2688 } 2613 }
2689 } 2614 }
@@ -2695,10 +2620,9 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi)
2695 for (j = i + 1; j < NR_CURSEG_DATA_TYPE; j++) { 2620 for (j = i + 1; j < NR_CURSEG_DATA_TYPE; j++) {
2696 if (le32_to_cpu(ckpt->cur_data_segno[i]) == 2621 if (le32_to_cpu(ckpt->cur_data_segno[i]) ==
2697 le32_to_cpu(ckpt->cur_data_segno[j])) { 2622 le32_to_cpu(ckpt->cur_data_segno[j])) {
2698 f2fs_msg(sbi->sb, KERN_ERR, 2623 f2fs_err(sbi, "Data segment (%u, %u) has the same segno: %u",
2699 "Data segment (%u, %u) has the same " 2624 i, j,
2700 "segno: %u", i, j, 2625 le32_to_cpu(ckpt->cur_data_segno[i]));
2701 le32_to_cpu(ckpt->cur_data_segno[i]));
2702 return 1; 2626 return 1;
2703 } 2627 }
2704 } 2628 }
@@ -2707,10 +2631,9 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi)
2707 for (j = i; j < NR_CURSEG_DATA_TYPE; j++) { 2631 for (j = i; j < NR_CURSEG_DATA_TYPE; j++) {
2708 if (le32_to_cpu(ckpt->cur_node_segno[i]) == 2632 if (le32_to_cpu(ckpt->cur_node_segno[i]) ==
2709 le32_to_cpu(ckpt->cur_data_segno[j])) { 2633 le32_to_cpu(ckpt->cur_data_segno[j])) {
2710 f2fs_msg(sbi->sb, KERN_ERR, 2634 f2fs_err(sbi, "Data segment (%u) and Data segment (%u) has the same segno: %u",
2711 "Data segment (%u) and Data segment (%u)" 2635 i, j,
2712 " has the same segno: %u", i, j, 2636 le32_to_cpu(ckpt->cur_node_segno[i]));
2713 le32_to_cpu(ckpt->cur_node_segno[i]));
2714 return 1; 2637 return 1;
2715 } 2638 }
2716 } 2639 }
@@ -2721,9 +2644,8 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi)
2721 2644
2722 if (sit_bitmap_size != ((sit_segs / 2) << log_blocks_per_seg) / 8 || 2645 if (sit_bitmap_size != ((sit_segs / 2) << log_blocks_per_seg) / 8 ||
2723 nat_bitmap_size != ((nat_segs / 2) << log_blocks_per_seg) / 8) { 2646 nat_bitmap_size != ((nat_segs / 2) << log_blocks_per_seg) / 8) {
2724 f2fs_msg(sbi->sb, KERN_ERR, 2647 f2fs_err(sbi, "Wrong bitmap size: sit: %u, nat:%u",
2725 "Wrong bitmap size: sit: %u, nat:%u", 2648 sit_bitmap_size, nat_bitmap_size);
2726 sit_bitmap_size, nat_bitmap_size);
2727 return 1; 2649 return 1;
2728 } 2650 }
2729 2651
@@ -2732,23 +2654,20 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi)
2732 if (cp_pack_start_sum < cp_payload + 1 || 2654 if (cp_pack_start_sum < cp_payload + 1 ||
2733 cp_pack_start_sum > blocks_per_seg - 1 - 2655 cp_pack_start_sum > blocks_per_seg - 1 -
2734 NR_CURSEG_TYPE) { 2656 NR_CURSEG_TYPE) {
2735 f2fs_msg(sbi->sb, KERN_ERR, 2657 f2fs_err(sbi, "Wrong cp_pack_start_sum: %u",
2736 "Wrong cp_pack_start_sum: %u", 2658 cp_pack_start_sum);
2737 cp_pack_start_sum);
2738 return 1; 2659 return 1;
2739 } 2660 }
2740 2661
2741 if (__is_set_ckpt_flags(ckpt, CP_LARGE_NAT_BITMAP_FLAG) && 2662 if (__is_set_ckpt_flags(ckpt, CP_LARGE_NAT_BITMAP_FLAG) &&
2742 le32_to_cpu(ckpt->checksum_offset) != CP_MIN_CHKSUM_OFFSET) { 2663 le32_to_cpu(ckpt->checksum_offset) != CP_MIN_CHKSUM_OFFSET) {
2743 f2fs_msg(sbi->sb, KERN_WARNING, 2664 f2fs_warn(sbi, "layout of large_nat_bitmap is deprecated, run fsck to repair, chksum_offset: %u",
2744 "layout of large_nat_bitmap is deprecated, " 2665 le32_to_cpu(ckpt->checksum_offset));
2745 "run fsck to repair, chksum_offset: %u",
2746 le32_to_cpu(ckpt->checksum_offset));
2747 return 1; 2666 return 1;
2748 } 2667 }
2749 2668
2750 if (unlikely(f2fs_cp_error(sbi))) { 2669 if (unlikely(f2fs_cp_error(sbi))) {
2751 f2fs_msg(sbi->sb, KERN_ERR, "A bug case: need to run fsck"); 2670 f2fs_err(sbi, "A bug case: need to run fsck");
2752 return 1; 2671 return 1;
2753 } 2672 }
2754 return 0; 2673 return 0;
@@ -2917,17 +2836,16 @@ static int read_raw_super_block(struct f2fs_sb_info *sbi,
2917 for (block = 0; block < 2; block++) { 2836 for (block = 0; block < 2; block++) {
2918 bh = sb_bread(sb, block); 2837 bh = sb_bread(sb, block);
2919 if (!bh) { 2838 if (!bh) {
2920 f2fs_msg(sb, KERN_ERR, "Unable to read %dth superblock", 2839 f2fs_err(sbi, "Unable to read %dth superblock",
2921 block + 1); 2840 block + 1);
2922 err = -EIO; 2841 err = -EIO;
2923 continue; 2842 continue;
2924 } 2843 }
2925 2844
2926 /* sanity checking of raw super */ 2845 /* sanity checking of raw super */
2927 if (sanity_check_raw_super(sbi, bh)) { 2846 if (sanity_check_raw_super(sbi, bh)) {
2928 f2fs_msg(sb, KERN_ERR, 2847 f2fs_err(sbi, "Can't find valid F2FS filesystem in %dth superblock",
2929 "Can't find valid F2FS filesystem in %dth superblock", 2848 block + 1);
2930 block + 1);
2931 err = -EINVAL; 2849 err = -EINVAL;
2932 brelse(bh); 2850 brelse(bh);
2933 continue; 2851 continue;
@@ -3057,36 +2975,32 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
3057#ifdef CONFIG_BLK_DEV_ZONED 2975#ifdef CONFIG_BLK_DEV_ZONED
3058 if (bdev_zoned_model(FDEV(i).bdev) == BLK_ZONED_HM && 2976 if (bdev_zoned_model(FDEV(i).bdev) == BLK_ZONED_HM &&
3059 !f2fs_sb_has_blkzoned(sbi)) { 2977 !f2fs_sb_has_blkzoned(sbi)) {
3060 f2fs_msg(sbi->sb, KERN_ERR, 2978 f2fs_err(sbi, "Zoned block device feature not enabled\n");
3061 "Zoned block device feature not enabled\n");
3062 return -EINVAL; 2979 return -EINVAL;
3063 } 2980 }
3064 if (bdev_zoned_model(FDEV(i).bdev) != BLK_ZONED_NONE) { 2981 if (bdev_zoned_model(FDEV(i).bdev) != BLK_ZONED_NONE) {
3065 if (init_blkz_info(sbi, i)) { 2982 if (init_blkz_info(sbi, i)) {
3066 f2fs_msg(sbi->sb, KERN_ERR, 2983 f2fs_err(sbi, "Failed to initialize F2FS blkzone information");
3067 "Failed to initialize F2FS blkzone information");
3068 return -EINVAL; 2984 return -EINVAL;
3069 } 2985 }
3070 if (max_devices == 1) 2986 if (max_devices == 1)
3071 break; 2987 break;
3072 f2fs_msg(sbi->sb, KERN_INFO, 2988 f2fs_info(sbi, "Mount Device [%2d]: %20s, %8u, %8x - %8x (zone: %s)",
3073 "Mount Device [%2d]: %20s, %8u, %8x - %8x (zone: %s)", 2989 i, FDEV(i).path,
3074 i, FDEV(i).path, 2990 FDEV(i).total_segments,
3075 FDEV(i).total_segments, 2991 FDEV(i).start_blk, FDEV(i).end_blk,
3076 FDEV(i).start_blk, FDEV(i).end_blk, 2992 bdev_zoned_model(FDEV(i).bdev) == BLK_ZONED_HA ?
3077 bdev_zoned_model(FDEV(i).bdev) == BLK_ZONED_HA ? 2993 "Host-aware" : "Host-managed");
3078 "Host-aware" : "Host-managed");
3079 continue; 2994 continue;
3080 } 2995 }
3081#endif 2996#endif
3082 f2fs_msg(sbi->sb, KERN_INFO, 2997 f2fs_info(sbi, "Mount Device [%2d]: %20s, %8u, %8x - %8x",
3083 "Mount Device [%2d]: %20s, %8u, %8x - %8x", 2998 i, FDEV(i).path,
3084 i, FDEV(i).path, 2999 FDEV(i).total_segments,
3085 FDEV(i).total_segments, 3000 FDEV(i).start_blk, FDEV(i).end_blk);
3086 FDEV(i).start_blk, FDEV(i).end_blk); 3001 }
3087 } 3002 f2fs_info(sbi,
3088 f2fs_msg(sbi->sb, KERN_INFO, 3003 "IO Block Size: %8d KB", F2FS_IO_SIZE_KB(sbi));
3089 "IO Block Size: %8d KB", F2FS_IO_SIZE_KB(sbi));
3090 return 0; 3004 return 0;
3091} 3005}
3092 3006
@@ -3132,7 +3046,7 @@ try_onemore:
3132 /* Load the checksum driver */ 3046 /* Load the checksum driver */
3133 sbi->s_chksum_driver = crypto_alloc_shash("crc32", 0, 0); 3047 sbi->s_chksum_driver = crypto_alloc_shash("crc32", 0, 0);
3134 if (IS_ERR(sbi->s_chksum_driver)) { 3048 if (IS_ERR(sbi->s_chksum_driver)) {
3135 f2fs_msg(sb, KERN_ERR, "Cannot load crc32 driver."); 3049 f2fs_err(sbi, "Cannot load crc32 driver.");
3136 err = PTR_ERR(sbi->s_chksum_driver); 3050 err = PTR_ERR(sbi->s_chksum_driver);
3137 sbi->s_chksum_driver = NULL; 3051 sbi->s_chksum_driver = NULL;
3138 goto free_sbi; 3052 goto free_sbi;
@@ -3140,7 +3054,7 @@ try_onemore:
3140 3054
3141 /* set a block size */ 3055 /* set a block size */
3142 if (unlikely(!sb_set_blocksize(sb, F2FS_BLKSIZE))) { 3056 if (unlikely(!sb_set_blocksize(sb, F2FS_BLKSIZE))) {
3143 f2fs_msg(sb, KERN_ERR, "unable to set blocksize"); 3057 f2fs_err(sbi, "unable to set blocksize");
3144 goto free_sbi; 3058 goto free_sbi;
3145 } 3059 }
3146 3060
@@ -3164,8 +3078,7 @@ try_onemore:
3164 */ 3078 */
3165#ifndef CONFIG_BLK_DEV_ZONED 3079#ifndef CONFIG_BLK_DEV_ZONED
3166 if (f2fs_sb_has_blkzoned(sbi)) { 3080 if (f2fs_sb_has_blkzoned(sbi)) {
3167 f2fs_msg(sb, KERN_ERR, 3081 f2fs_err(sbi, "Zoned block device support is not enabled");
3168 "Zoned block device support is not enabled");
3169 err = -EOPNOTSUPP; 3082 err = -EOPNOTSUPP;
3170 goto free_sb_buf; 3083 goto free_sb_buf;
3171 } 3084 }
@@ -3273,14 +3186,14 @@ try_onemore:
3273 /* get an inode for meta space */ 3186 /* get an inode for meta space */
3274 sbi->meta_inode = f2fs_iget(sb, F2FS_META_INO(sbi)); 3187 sbi->meta_inode = f2fs_iget(sb, F2FS_META_INO(sbi));
3275 if (IS_ERR(sbi->meta_inode)) { 3188 if (IS_ERR(sbi->meta_inode)) {
3276 f2fs_msg(sb, KERN_ERR, "Failed to read F2FS meta data inode"); 3189 f2fs_err(sbi, "Failed to read F2FS meta data inode");
3277 err = PTR_ERR(sbi->meta_inode); 3190 err = PTR_ERR(sbi->meta_inode);
3278 goto free_io_dummy; 3191 goto free_io_dummy;
3279 } 3192 }
3280 3193
3281 err = f2fs_get_valid_checkpoint(sbi); 3194 err = f2fs_get_valid_checkpoint(sbi);
3282 if (err) { 3195 if (err) {
3283 f2fs_msg(sb, KERN_ERR, "Failed to get valid F2FS checkpoint"); 3196 f2fs_err(sbi, "Failed to get valid F2FS checkpoint");
3284 goto free_meta_inode; 3197 goto free_meta_inode;
3285 } 3198 }
3286 3199
@@ -3297,7 +3210,7 @@ try_onemore:
3297 /* Initialize device list */ 3210 /* Initialize device list */
3298 err = f2fs_scan_devices(sbi); 3211 err = f2fs_scan_devices(sbi);
3299 if (err) { 3212 if (err) {
3300 f2fs_msg(sb, KERN_ERR, "Failed to find devices"); 3213 f2fs_err(sbi, "Failed to find devices");
3301 goto free_devices; 3214 goto free_devices;
3302 } 3215 }
3303 3216
@@ -3328,14 +3241,14 @@ try_onemore:
3328 /* setup f2fs internal modules */ 3241 /* setup f2fs internal modules */
3329 err = f2fs_build_segment_manager(sbi); 3242 err = f2fs_build_segment_manager(sbi);
3330 if (err) { 3243 if (err) {
3331 f2fs_msg(sb, KERN_ERR, 3244 f2fs_err(sbi, "Failed to initialize F2FS segment manager (%d)",
3332 "Failed to initialize F2FS segment manager (%d)", err); 3245 err);
3333 goto free_sm; 3246 goto free_sm;
3334 } 3247 }
3335 err = f2fs_build_node_manager(sbi); 3248 err = f2fs_build_node_manager(sbi);
3336 if (err) { 3249 if (err) {
3337 f2fs_msg(sb, KERN_ERR, 3250 f2fs_err(sbi, "Failed to initialize F2FS node manager (%d)",
3338 "Failed to initialize F2FS node manager (%d)", err); 3251 err);
3339 goto free_nm; 3252 goto free_nm;
3340 } 3253 }
3341 3254
@@ -3360,7 +3273,7 @@ try_onemore:
3360 /* get an inode for node space */ 3273 /* get an inode for node space */
3361 sbi->node_inode = f2fs_iget(sb, F2FS_NODE_INO(sbi)); 3274 sbi->node_inode = f2fs_iget(sb, F2FS_NODE_INO(sbi));
3362 if (IS_ERR(sbi->node_inode)) { 3275 if (IS_ERR(sbi->node_inode)) {
3363 f2fs_msg(sb, KERN_ERR, "Failed to read node inode"); 3276 f2fs_err(sbi, "Failed to read node inode");
3364 err = PTR_ERR(sbi->node_inode); 3277 err = PTR_ERR(sbi->node_inode);
3365 goto free_stats; 3278 goto free_stats;
3366 } 3279 }
@@ -3368,7 +3281,7 @@ try_onemore:
3368 /* read root inode and dentry */ 3281 /* read root inode and dentry */
3369 root = f2fs_iget(sb, F2FS_ROOT_INO(sbi)); 3282 root = f2fs_iget(sb, F2FS_ROOT_INO(sbi));
3370 if (IS_ERR(root)) { 3283 if (IS_ERR(root)) {
3371 f2fs_msg(sb, KERN_ERR, "Failed to read root inode"); 3284 f2fs_err(sbi, "Failed to read root inode");
3372 err = PTR_ERR(root); 3285 err = PTR_ERR(root);
3373 goto free_node_inode; 3286 goto free_node_inode;
3374 } 3287 }
@@ -3394,8 +3307,7 @@ try_onemore:
3394 if (f2fs_sb_has_quota_ino(sbi) && !f2fs_readonly(sb)) { 3307 if (f2fs_sb_has_quota_ino(sbi) && !f2fs_readonly(sb)) {
3395 err = f2fs_enable_quotas(sb); 3308 err = f2fs_enable_quotas(sb);
3396 if (err) 3309 if (err)
3397 f2fs_msg(sb, KERN_ERR, 3310 f2fs_err(sbi, "Cannot turn on quotas: error %d", err);
3398 "Cannot turn on quotas: error %d", err);
3399 } 3311 }
3400#endif 3312#endif
3401 /* if there are nt orphan nodes free them */ 3313 /* if there are nt orphan nodes free them */
@@ -3415,13 +3327,10 @@ try_onemore:
3415 if (f2fs_hw_is_readonly(sbi)) { 3327 if (f2fs_hw_is_readonly(sbi)) {
3416 if (!is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG)) { 3328 if (!is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG)) {
3417 err = -EROFS; 3329 err = -EROFS;
3418 f2fs_msg(sb, KERN_ERR, 3330 f2fs_err(sbi, "Need to recover fsync data, but write access unavailable");
3419 "Need to recover fsync data, but "
3420 "write access unavailable");
3421 goto free_meta; 3331 goto free_meta;
3422 } 3332 }
3423 f2fs_msg(sbi->sb, KERN_INFO, "write access " 3333 f2fs_info(sbi, "write access unavailable, skipping recovery");
3424 "unavailable, skipping recovery");
3425 goto reset_checkpoint; 3334 goto reset_checkpoint;
3426 } 3335 }
3427 3336
@@ -3436,8 +3345,8 @@ try_onemore:
3436 if (err != -ENOMEM) 3345 if (err != -ENOMEM)
3437 skip_recovery = true; 3346 skip_recovery = true;
3438 need_fsck = true; 3347 need_fsck = true;
3439 f2fs_msg(sb, KERN_ERR, 3348 f2fs_err(sbi, "Cannot recover all fsync data errno=%d",
3440 "Cannot recover all fsync data errno=%d", err); 3349 err);
3441 goto free_meta; 3350 goto free_meta;
3442 } 3351 }
3443 } else { 3352 } else {
@@ -3445,8 +3354,7 @@ try_onemore:
3445 3354
3446 if (!f2fs_readonly(sb) && err > 0) { 3355 if (!f2fs_readonly(sb) && err > 0) {
3447 err = -EINVAL; 3356 err = -EINVAL;
3448 f2fs_msg(sb, KERN_ERR, 3357 f2fs_err(sbi, "Need to recover fsync data");
3449 "Need to recover fsync data");
3450 goto free_meta; 3358 goto free_meta;
3451 } 3359 }
3452 } 3360 }
@@ -3477,17 +3385,16 @@ reset_checkpoint:
3477 /* recover broken superblock */ 3385 /* recover broken superblock */
3478 if (recovery) { 3386 if (recovery) {
3479 err = f2fs_commit_super(sbi, true); 3387 err = f2fs_commit_super(sbi, true);
3480 f2fs_msg(sb, KERN_INFO, 3388 f2fs_info(sbi, "Try to recover %dth superblock, ret: %d",
3481 "Try to recover %dth superblock, ret: %d", 3389 sbi->valid_super_block ? 1 : 2, err);
3482 sbi->valid_super_block ? 1 : 2, err);
3483 } 3390 }
3484 3391
3485 f2fs_join_shrinker(sbi); 3392 f2fs_join_shrinker(sbi);
3486 3393
3487 f2fs_tuning_parameters(sbi); 3394 f2fs_tuning_parameters(sbi);
3488 3395
3489 f2fs_msg(sbi->sb, KERN_NOTICE, "Mounted with checkpoint version = %llx", 3396 f2fs_notice(sbi, "Mounted with checkpoint version = %llx",
3490 cur_cp_version(F2FS_CKPT(sbi))); 3397 cur_cp_version(F2FS_CKPT(sbi)));
3491 f2fs_update_time(sbi, CP_TIME); 3398 f2fs_update_time(sbi, CP_TIME);
3492 f2fs_update_time(sbi, REQ_TIME); 3399 f2fs_update_time(sbi, REQ_TIME);
3493 clear_sbi_flag(sbi, SBI_CP_DISABLED_QUICK); 3400 clear_sbi_flag(sbi, SBI_CP_DISABLED_QUICK);