Skip to content

Commit

Permalink
exfat: Use a more common logging style
Browse files Browse the repository at this point in the history
Remove the direct use of KERN_<LEVEL> in functions by creating
separate exfat_<level> macros.

Miscellanea:

o Remove several unnecessary terminating newlines in formats
o Realign arguments and fit to 80 columns where appropriate

Signed-off-by: Joe Perches <[email protected]>
Signed-off-by: Namjae Jeon <[email protected]>
  • Loading branch information
JoePerches authored and namjaejeon committed Jun 9, 2020
1 parent 197298a commit d1727d5
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 74 deletions.
8 changes: 3 additions & 5 deletions fs/exfat/balloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ static int exfat_allocate_bitmap(struct super_block *sb,
need_map_size = ((EXFAT_DATA_CLUSTER_COUNT(sbi) - 1) / BITS_PER_BYTE)
+ 1;
if (need_map_size != map_size) {
exfat_msg(sb, KERN_ERR,
"bogus allocation bitmap size(need : %u, cur : %lld)",
need_map_size, map_size);
exfat_err(sb, "bogus allocation bitmap size(need : %u, cur : %lld)",
need_map_size, map_size);
/*
* Only allowed when bogus allocation
* bitmap size is large
Expand Down Expand Up @@ -192,8 +191,7 @@ void exfat_clear_bitmap(struct inode *inode, unsigned int clu)
(1 << sbi->sect_per_clus_bits), GFP_NOFS, 0);

if (ret_discard == -EOPNOTSUPP) {
exfat_msg(sb, KERN_ERR,
"discard not supported by device, disabling");
exfat_err(sb, "discard not supported by device, disabling");
opts->discard = 0;
}
}
Expand Down
9 changes: 4 additions & 5 deletions fs/exfat/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -720,9 +720,8 @@ static int exfat_dir_readahead(struct super_block *sb, sector_t sec)
return 0;

if (sec < sbi->data_start_sector) {
exfat_msg(sb, KERN_ERR,
"requested sector is invalid(sect:%llu, root:%llu)",
(unsigned long long)sec, sbi->data_start_sector);
exfat_err(sb, "requested sector is invalid(sect:%llu, root:%llu)",
(unsigned long long)sec, sbi->data_start_sector);
return -EIO;
}

Expand Down Expand Up @@ -750,7 +749,7 @@ struct exfat_dentry *exfat_get_dentry(struct super_block *sb,
sector_t sec;

if (p_dir->dir == DIR_DELETED) {
exfat_msg(sb, KERN_ERR, "abnormal access to deleted dentry\n");
exfat_err(sb, "abnormal access to deleted dentry");
return NULL;
}

Expand Down Expand Up @@ -853,7 +852,7 @@ struct exfat_entry_set_cache *exfat_get_dentry_set(struct super_block *sb,
struct buffer_head *bh;

if (p_dir->dir == DIR_DELETED) {
exfat_msg(sb, KERN_ERR, "access to deleted dentry\n");
exfat_err(sb, "access to deleted dentry");
return NULL;
}

Expand Down
7 changes: 7 additions & 0 deletions fs/exfat/exfat_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,13 @@ void __exfat_fs_error(struct super_block *sb, int report, const char *fmt, ...)
fmt, ## args)
void exfat_msg(struct super_block *sb, const char *lv, const char *fmt, ...)
__printf(3, 4) __cold;
#define exfat_err(sb, fmt, ...) \
exfat_msg(sb, KERN_ERR, fmt, ##__VA_ARGS__)
#define exfat_warn(sb, fmt, ...) \
exfat_msg(sb, KERN_WARNING, fmt, ##__VA_ARGS__)
#define exfat_info(sb, fmt, ...) \
exfat_msg(sb, KERN_INFO, fmt, ##__VA_ARGS__)

void exfat_get_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts,
u8 tz, __le16 time, __le16 date, u8 time_ms);
void exfat_truncate_atime(struct timespec64 *ts);
Expand Down
13 changes: 5 additions & 8 deletions fs/exfat/fatent.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ int exfat_free_cluster(struct inode *inode, struct exfat_chain *p_chain)

/* check cluster validation */
if (p_chain->dir < 2 && p_chain->dir >= sbi->num_clusters) {
exfat_msg(sb, KERN_ERR, "invalid start cluster (%u)",
p_chain->dir);
exfat_err(sb, "invalid start cluster (%u)", p_chain->dir);
return -EIO;
}

Expand Down Expand Up @@ -305,8 +304,7 @@ int exfat_zeroed_cluster(struct inode *dir, unsigned int clu)
return 0;

release_bhs:
exfat_msg(sb, KERN_ERR, "failed zeroed sect %llu\n",
(unsigned long long)blknr);
exfat_err(sb, "failed zeroed sect %llu\n", (unsigned long long)blknr);
for (i = 0; i < n; i++)
bforget(bhs[i]);
return err;
Expand Down Expand Up @@ -337,9 +335,8 @@ int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc,
/* find new cluster */
if (hint_clu == EXFAT_EOF_CLUSTER) {
if (sbi->clu_srch_ptr < EXFAT_FIRST_CLUSTER) {
exfat_msg(sb, KERN_ERR,
"sbi->clu_srch_ptr is invalid (%u)\n",
sbi->clu_srch_ptr);
exfat_err(sb, "sbi->clu_srch_ptr is invalid (%u)\n",
sbi->clu_srch_ptr);
sbi->clu_srch_ptr = EXFAT_FIRST_CLUSTER;
}

Expand All @@ -350,7 +347,7 @@ int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc,

/* check cluster validation */
if (hint_clu < EXFAT_FIRST_CLUSTER && hint_clu >= sbi->num_clusters) {
exfat_msg(sb, KERN_ERR, "hint_cluster is invalid (%u)\n",
exfat_err(sb, "hint_cluster is invalid (%u)",
hint_clu);
hint_clu = EXFAT_FIRST_CLUSTER;
if (p_chain->flags == ALLOC_NO_FAT_CHAIN) {
Expand Down
4 changes: 2 additions & 2 deletions fs/exfat/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void __exfat_fs_error(struct super_block *sb, int report, const char *fmt, ...)
va_start(args, fmt);
vaf.fmt = fmt;
vaf.va = &args;
exfat_msg(sb, KERN_ERR, "error, %pV\n", &vaf);
exfat_err(sb, "error, %pV", &vaf);
va_end(args);
}

Expand All @@ -41,7 +41,7 @@ void __exfat_fs_error(struct super_block *sb, int report, const char *fmt, ...)
sb->s_id);
} else if (opts->errors == EXFAT_ERRORS_RO && !sb_rdonly(sb)) {
sb->s_flags |= SB_RDONLY;
exfat_msg(sb, KERN_ERR, "Filesystem has been set read-only");
exfat_err(sb, "Filesystem has been set read-only");
}
}

Expand Down
26 changes: 10 additions & 16 deletions fs/exfat/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -773,8 +773,8 @@ static struct dentry *exfat_lookup(struct inode *dir, struct dentry *dentry,
if (d_unhashed(alias)) {
WARN_ON(alias->d_name.hash_len !=
dentry->d_name.hash_len);
exfat_msg(sb, KERN_INFO,
"rehashed a dentry(%p) in read lookup", alias);
exfat_info(sb, "rehashed a dentry(%p) in read lookup",
alias);
d_drop(dentry);
d_rehash(alias);
} else if (!S_ISDIR(i_mode)) {
Expand Down Expand Up @@ -819,7 +819,7 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry)
exfat_chain_dup(&cdir, &ei->dir);
entry = ei->entry;
if (ei->dir.dir == DIR_DELETED) {
exfat_msg(sb, KERN_ERR, "abnormal access to deleted dentry");
exfat_err(sb, "abnormal access to deleted dentry");
err = -ENOENT;
goto unlock;
}
Expand Down Expand Up @@ -974,7 +974,7 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry)
entry = ei->entry;

if (ei->dir.dir == DIR_DELETED) {
exfat_msg(sb, KERN_ERR, "abnormal access to deleted dentry");
exfat_err(sb, "abnormal access to deleted dentry");
err = -ENOENT;
goto unlock;
}
Expand All @@ -986,9 +986,8 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry)
err = exfat_check_dir_empty(sb, &clu_to_free);
if (err) {
if (err == -EIO)
exfat_msg(sb, KERN_ERR,
"failed to exfat_check_dir_empty : err(%d)",
err);
exfat_err(sb, "failed to exfat_check_dir_empty : err(%d)",
err);
goto unlock;
}

Expand All @@ -1009,9 +1008,7 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry)

err = exfat_remove_entries(dir, &cdir, entry, 0, num_entries);
if (err) {
exfat_msg(sb, KERN_ERR,
"failed to exfat_remove_entries : err(%d)",
err);
exfat_err(sb, "failed to exfat_remove_entries : err(%d)", err);
goto unlock;
}
ei->dir.dir = DIR_DELETED;
Expand Down Expand Up @@ -1240,8 +1237,7 @@ static int __exfat_rename(struct inode *old_parent_inode,
return -EINVAL;

if (ei->dir.dir == DIR_DELETED) {
exfat_msg(sb, KERN_ERR,
"abnormal access to deleted source dentry");
exfat_err(sb, "abnormal access to deleted source dentry");
return -ENOENT;
}

Expand All @@ -1263,8 +1259,7 @@ static int __exfat_rename(struct inode *old_parent_inode,
new_ei = EXFAT_I(new_inode);

if (new_ei->dir.dir == DIR_DELETED) {
exfat_msg(sb, KERN_ERR,
"abnormal access to deleted target dentry");
exfat_err(sb, "abnormal access to deleted target dentry");
goto out;
}

Expand Down Expand Up @@ -1426,8 +1421,7 @@ static int exfat_rename(struct inode *old_dir, struct dentry *old_dentry,
if (S_ISDIR(new_inode->i_mode))
drop_nlink(new_inode);
} else {
exfat_msg(sb, KERN_WARNING,
"abnormal access to an inode dropped");
exfat_warn(sb, "abnormal access to an inode dropped");
WARN_ON(new_inode->i_nlink == 0);
}
new_inode->i_ctime = EXFAT_I(new_inode)->i_crtime =
Expand Down
20 changes: 8 additions & 12 deletions fs/exfat/nls.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,16 +503,14 @@ static int exfat_utf8_to_utf16(struct super_block *sb,
unilen = utf8s_to_utf16s(p_cstring, len, UTF16_HOST_ENDIAN,
(wchar_t *)uniname, MAX_NAME_LENGTH + 2);
if (unilen < 0) {
exfat_msg(sb, KERN_ERR,
"failed to %s (err : %d) nls len : %d",
__func__, unilen, len);
exfat_err(sb, "failed to %s (err : %d) nls len : %d",
__func__, unilen, len);
return unilen;
}

if (unilen > MAX_NAME_LENGTH) {
exfat_msg(sb, KERN_ERR,
"failed to %s (estr:ENAMETOOLONG) nls len : %d, unilen : %d > %d",
__func__, len, unilen, MAX_NAME_LENGTH);
exfat_err(sb, "failed to %s (estr:ENAMETOOLONG) nls len : %d, unilen : %d > %d",
__func__, len, unilen, MAX_NAME_LENGTH);
return -ENAMETOOLONG;
}

Expand Down Expand Up @@ -687,9 +685,8 @@ static int exfat_load_upcase_table(struct super_block *sb,

bh = sb_bread(sb, sector);
if (!bh) {
exfat_msg(sb, KERN_ERR,
"failed to read sector(0x%llx)\n",
(unsigned long long)sector);
exfat_err(sb, "failed to read sector(0x%llx)\n",
(unsigned long long)sector);
ret = -EIO;
goto free_table;
}
Expand Down Expand Up @@ -722,9 +719,8 @@ static int exfat_load_upcase_table(struct super_block *sb,
if (index >= 0xFFFF && utbl_checksum == checksum)
return 0;

exfat_msg(sb, KERN_ERR,
"failed to load upcase table (idx : 0x%08x, chksum : 0x%08x, utbl_chksum : 0x%08x)\n",
index, checksum, utbl_checksum);
exfat_err(sb, "failed to load upcase table (idx : 0x%08x, chksum : 0x%08x, utbl_chksum : 0x%08x)",
index, checksum, utbl_checksum);
ret = -EINVAL;
free_table:
exfat_free_upcase_table(sbi);
Expand Down
Loading

0 comments on commit d1727d5

Please sign in to comment.