Skip to content

Commit

Permalink
BEFS: logging cleanup
Browse files Browse the repository at this point in the history
Summary:
 - all printk(KERN_foo converted to pr_foo()
 - add pr_fmt and remove redundant prefixes
 - convert befs_() to va_format (based on patch by Joe Perches)
 - remove non standard %Lu
 - use __func__ for all debugging

[[email protected]: fix printk warnings, reported by Fengguang]
Signed-off-by: Fabian Frederick <[email protected]>
Cc: Joe Perches <[email protected]>
Cc: Fengguang Wu <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Fabian Frederick authored and torvalds committed Apr 3, 2014
1 parent 91a52ab commit dac52fc
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 204 deletions.
2 changes: 1 addition & 1 deletion fs/befs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
#

obj-$(CONFIG_BEFS_FS) += befs.o

ccflags-$(CONFIG_BEFS_DEBUG) += -DDEBUG
befs-objs := datastream.o btree.o super.o inode.o debug.o io.o linuxvfs.o
3 changes: 3 additions & 0 deletions fs/befs/befs.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@ enum befs_err {

/****************************/
/* debug.c */
__printf(2, 3)
void befs_error(const struct super_block *sb, const char *fmt, ...);
__printf(2, 3)
void befs_warning(const struct super_block *sb, const char *fmt, ...);
__printf(2, 3)
void befs_debug(const struct super_block *sb, const char *fmt, ...);

void befs_dump_super_block(const struct super_block *sb, befs_super_block *);
Expand Down
93 changes: 48 additions & 45 deletions fs/befs/btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ befs_bt_read_super(struct super_block *sb, befs_data_stream * ds,
struct buffer_head *bh = NULL;
befs_disk_btree_super *od_sup = NULL;

befs_debug(sb, "---> befs_btree_read_super()");
befs_debug(sb, "---> %s", __func__);

bh = befs_read_datastream(sb, ds, 0, NULL);

Expand All @@ -162,11 +162,11 @@ befs_bt_read_super(struct super_block *sb, befs_data_stream * ds,
goto error;
}

befs_debug(sb, "<--- befs_btree_read_super()");
befs_debug(sb, "<--- %s", __func__);
return BEFS_OK;

error:
befs_debug(sb, "<--- befs_btree_read_super() ERROR");
befs_debug(sb, "<--- %s ERROR", __func__);
return BEFS_ERR;
}

Expand Down Expand Up @@ -195,16 +195,16 @@ befs_bt_read_node(struct super_block *sb, befs_data_stream * ds,
{
uint off = 0;

befs_debug(sb, "---> befs_bt_read_node()");
befs_debug(sb, "---> %s", __func__);

if (node->bh)
brelse(node->bh);

node->bh = befs_read_datastream(sb, ds, node_off, &off);
if (!node->bh) {
befs_error(sb, "befs_bt_read_node() failed to read "
"node at %Lu", node_off);
befs_debug(sb, "<--- befs_bt_read_node() ERROR");
befs_error(sb, "%s failed to read "
"node at %llu", __func__, node_off);
befs_debug(sb, "<--- %s ERROR", __func__);

return BEFS_ERR;
}
Expand All @@ -221,7 +221,7 @@ befs_bt_read_node(struct super_block *sb, befs_data_stream * ds,
node->head.all_key_length =
fs16_to_cpu(sb, node->od_node->all_key_length);

befs_debug(sb, "<--- befs_btree_read_node()");
befs_debug(sb, "<--- %s", __func__);
return BEFS_OK;
}

Expand Down Expand Up @@ -252,7 +252,7 @@ befs_btree_find(struct super_block *sb, befs_data_stream * ds,
befs_off_t node_off;
int res;

befs_debug(sb, "---> befs_btree_find() Key: %s", key);
befs_debug(sb, "---> %s Key: %s", __func__, key);

if (befs_bt_read_super(sb, ds, &bt_super) != BEFS_OK) {
befs_error(sb,
Expand All @@ -263,7 +263,7 @@ befs_btree_find(struct super_block *sb, befs_data_stream * ds,
this_node = kmalloc(sizeof (befs_btree_node),
GFP_NOFS);
if (!this_node) {
befs_error(sb, "befs_btree_find() failed to allocate %u "
befs_error(sb, "befs_btree_find() failed to allocate %zu "
"bytes of memory", sizeof (befs_btree_node));
goto error;
}
Expand All @@ -274,7 +274,7 @@ befs_btree_find(struct super_block *sb, befs_data_stream * ds,
node_off = bt_super.root_node_ptr;
if (befs_bt_read_node(sb, ds, this_node, node_off) != BEFS_OK) {
befs_error(sb, "befs_btree_find() failed to read "
"node at %Lu", node_off);
"node at %llu", node_off);
goto error_alloc;
}

Expand All @@ -285,7 +285,7 @@ befs_btree_find(struct super_block *sb, befs_data_stream * ds,
/* if no match, go to overflow node */
if (befs_bt_read_node(sb, ds, this_node, node_off) != BEFS_OK) {
befs_error(sb, "befs_btree_find() failed to read "
"node at %Lu", node_off);
"node at %llu", node_off);
goto error_alloc;
}
}
Expand All @@ -298,19 +298,19 @@ befs_btree_find(struct super_block *sb, befs_data_stream * ds,
kfree(this_node);

if (res != BEFS_BT_MATCH) {
befs_debug(sb, "<--- befs_btree_find() Key %s not found", key);
befs_debug(sb, "<--- %s Key %s not found", __func__, key);
*value = 0;
return BEFS_BT_NOT_FOUND;
}
befs_debug(sb, "<--- befs_btree_find() Found key %s, value %Lu",
befs_debug(sb, "<--- %s Found key %s, value %llu", __func__,
key, *value);
return BEFS_OK;

error_alloc:
kfree(this_node);
error:
*value = 0;
befs_debug(sb, "<--- befs_btree_find() ERROR");
befs_debug(sb, "<--- %s ERROR", __func__);
return BEFS_ERR;
}

Expand Down Expand Up @@ -343,7 +343,7 @@ befs_find_key(struct super_block *sb, befs_btree_node * node,
char *thiskey;
fs64 *valarray;

befs_debug(sb, "---> befs_find_key() %s", findkey);
befs_debug(sb, "---> %s %s", __func__, findkey);

*value = 0;

Expand All @@ -355,7 +355,7 @@ befs_find_key(struct super_block *sb, befs_btree_node * node,

eq = befs_compare_strings(thiskey, keylen, findkey, findkey_len);
if (eq < 0) {
befs_debug(sb, "<--- befs_find_key() %s not found", findkey);
befs_debug(sb, "<--- %s %s not found", __func__, findkey);
return BEFS_BT_NOT_FOUND;
}

Expand All @@ -373,8 +373,8 @@ befs_find_key(struct super_block *sb, befs_btree_node * node,
findkey_len);

if (eq == 0) {
befs_debug(sb, "<--- befs_find_key() found %s at %d",
thiskey, mid);
befs_debug(sb, "<--- %s found %s at %d",
__func__, thiskey, mid);

*value = fs64_to_cpu(sb, valarray[mid]);
return BEFS_BT_MATCH;
Expand All @@ -388,7 +388,7 @@ befs_find_key(struct super_block *sb, befs_btree_node * node,
*value = fs64_to_cpu(sb, valarray[mid + 1]);
else
*value = fs64_to_cpu(sb, valarray[mid]);
befs_debug(sb, "<--- befs_find_key() found %s at %d", thiskey, mid);
befs_debug(sb, "<--- %s found %s at %d", __func__, thiskey, mid);
return BEFS_BT_PARMATCH;
}

Expand Down Expand Up @@ -428,7 +428,7 @@ befs_btree_read(struct super_block *sb, befs_data_stream * ds,

uint key_sum = 0;

befs_debug(sb, "---> befs_btree_read()");
befs_debug(sb, "---> %s", __func__);

if (befs_bt_read_super(sb, ds, &bt_super) != BEFS_OK) {
befs_error(sb,
Expand All @@ -437,7 +437,7 @@ befs_btree_read(struct super_block *sb, befs_data_stream * ds,
}

if ((this_node = kmalloc(sizeof (befs_btree_node), GFP_NOFS)) == NULL) {
befs_error(sb, "befs_btree_read() failed to allocate %u "
befs_error(sb, "befs_btree_read() failed to allocate %zu "
"bytes of memory", sizeof (befs_btree_node));
goto error;
}
Expand All @@ -452,7 +452,7 @@ befs_btree_read(struct super_block *sb, befs_data_stream * ds,
kfree(this_node);
*value = 0;
*keysize = 0;
befs_debug(sb, "<--- befs_btree_read() Tree is EMPTY");
befs_debug(sb, "<--- %s Tree is EMPTY", __func__);
return BEFS_BT_EMPTY;
} else if (res == BEFS_ERR) {
goto error_alloc;
Expand All @@ -467,7 +467,8 @@ befs_btree_read(struct super_block *sb, befs_data_stream * ds,
*keysize = 0;
*value = 0;
befs_debug(sb,
"<--- befs_btree_read() END of keys at %Lu",
"<--- %s END of keys at %llu", __func__,
(unsigned long long)
key_sum + this_node->head.all_key_count);
brelse(this_node->bh);
kfree(this_node);
Expand All @@ -478,8 +479,8 @@ befs_btree_read(struct super_block *sb, befs_data_stream * ds,
node_off = this_node->head.right;

if (befs_bt_read_node(sb, ds, this_node, node_off) != BEFS_OK) {
befs_error(sb, "befs_btree_read() failed to read "
"node at %Lu", node_off);
befs_error(sb, "%s failed to read node at %llu",
__func__, (unsigned long long)node_off);
goto error_alloc;
}
}
Expand All @@ -492,11 +493,13 @@ befs_btree_read(struct super_block *sb, befs_data_stream * ds,

keystart = befs_bt_get_key(sb, this_node, cur_key, &keylen);

befs_debug(sb, "Read [%Lu,%d]: keysize %d", node_off, cur_key, keylen);
befs_debug(sb, "Read [%llu,%d]: keysize %d",
(long long unsigned int)node_off, (int)cur_key,
(int)keylen);

if (bufsize < keylen + 1) {
befs_error(sb, "befs_btree_read() keybuf too small (%u) "
"for key of size %d", bufsize, keylen);
befs_error(sb, "%s keybuf too small (%zu) "
"for key of size %d", __func__, bufsize, keylen);
brelse(this_node->bh);
goto error_alloc;
};
Expand All @@ -506,13 +509,13 @@ befs_btree_read(struct super_block *sb, befs_data_stream * ds,
*keysize = keylen;
keybuf[keylen] = '\0';

befs_debug(sb, "Read [%Lu,%d]: Key \"%.*s\", Value %Lu", node_off,
befs_debug(sb, "Read [%llu,%d]: Key \"%.*s\", Value %llu", node_off,
cur_key, keylen, keybuf, *value);

brelse(this_node->bh);
kfree(this_node);

befs_debug(sb, "<--- befs_btree_read()");
befs_debug(sb, "<--- %s", __func__);

return BEFS_OK;

Expand All @@ -522,7 +525,7 @@ befs_btree_read(struct super_block *sb, befs_data_stream * ds,
error:
*keysize = 0;
*value = 0;
befs_debug(sb, "<--- befs_btree_read() ERROR");
befs_debug(sb, "<--- %s ERROR", __func__);
return BEFS_ERR;
}

Expand All @@ -547,46 +550,46 @@ befs_btree_seekleaf(struct super_block *sb, befs_data_stream * ds,
befs_off_t * node_off)
{

befs_debug(sb, "---> befs_btree_seekleaf()");
befs_debug(sb, "---> %s", __func__);

if (befs_bt_read_node(sb, ds, this_node, *node_off) != BEFS_OK) {
befs_error(sb, "befs_btree_seekleaf() failed to read "
"node at %Lu", *node_off);
befs_error(sb, "%s failed to read "
"node at %llu", __func__, *node_off);
goto error;
}
befs_debug(sb, "Seekleaf to root node %Lu", *node_off);
befs_debug(sb, "Seekleaf to root node %llu", *node_off);

if (this_node->head.all_key_count == 0 && befs_leafnode(this_node)) {
befs_debug(sb, "<--- befs_btree_seekleaf() Tree is EMPTY");
befs_debug(sb, "<--- %s Tree is EMPTY", __func__);
return BEFS_BT_EMPTY;
}

while (!befs_leafnode(this_node)) {

if (this_node->head.all_key_count == 0) {
befs_debug(sb, "befs_btree_seekleaf() encountered "
"an empty interior node: %Lu. Using Overflow "
"node: %Lu", *node_off,
befs_debug(sb, "%s encountered "
"an empty interior node: %llu. Using Overflow "
"node: %llu", __func__, *node_off,
this_node->head.overflow);
*node_off = this_node->head.overflow;
} else {
fs64 *valarray = befs_bt_valarray(this_node);
*node_off = fs64_to_cpu(sb, valarray[0]);
}
if (befs_bt_read_node(sb, ds, this_node, *node_off) != BEFS_OK) {
befs_error(sb, "befs_btree_seekleaf() failed to read "
"node at %Lu", *node_off);
befs_error(sb, "%s failed to read "
"node at %llu", __func__, *node_off);
goto error;
}

befs_debug(sb, "Seekleaf to child node %Lu", *node_off);
befs_debug(sb, "Seekleaf to child node %llu", *node_off);
}
befs_debug(sb, "Node %Lu is a leaf node", *node_off);
befs_debug(sb, "Node %llu is a leaf node", *node_off);

return BEFS_OK;

error:
befs_debug(sb, "<--- befs_btree_seekleaf() ERROR");
befs_debug(sb, "<--- %s ERROR", __func__);
return BEFS_ERR;
}

Expand Down
Loading

0 comments on commit dac52fc

Please sign in to comment.