Skip to content

Commit

Permalink
fuse: convert printk -> pr_*
Browse files Browse the repository at this point in the history
Functions, like pr_err, are a more modern variant of printing compared to
printk. They could be used to denoise sources by using needed level in
the print function name, and by automatically inserting per-driver /
function / ... print prefix as defined by pr_fmt macro. pr_* are also
said to be used in Documentation/process/coding-style.rst and more
recent code - for example overlayfs - uses them instead of printk.

Convert CUSE and FUSE to use the new pr_* functions.

CUSE output stays completely unchanged, while FUSE output is amended a
bit for "trying to steal weird page" warning - the second line now comes
also with "fuse:" prefix. I hope it is ok.

Suggested-by: Kirill Tkhai <[email protected]>
Signed-off-by: Kirill Smelkov <[email protected]>
Reviewed-by: Kirill Tkhai <[email protected]>
Signed-off-by: Miklos Szeredi <[email protected]>
  • Loading branch information
navytux authored and Miklos Szeredi committed Apr 24, 2019
1 parent 0cbade0 commit f229448
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
13 changes: 7 additions & 6 deletions fs/fuse/cuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
* closed.
*/

#define pr_fmt(fmt) "CUSE: " fmt

#include <linux/fuse.h>
#include <linux/cdev.h>
#include <linux/device.h>
Expand Down Expand Up @@ -225,7 +227,7 @@ static int cuse_parse_one(char **pp, char *end, char **keyp, char **valp)
return 0;

if (end[-1] != '\0') {
printk(KERN_ERR "CUSE: info not properly terminated\n");
pr_err("info not properly terminated\n");
return -EINVAL;
}

Expand All @@ -242,7 +244,7 @@ static int cuse_parse_one(char **pp, char *end, char **keyp, char **valp)
key = strstrip(key);

if (!strlen(key)) {
printk(KERN_ERR "CUSE: zero length info key specified\n");
pr_err("zero length info key specified\n");
return -EINVAL;
}

Expand Down Expand Up @@ -282,12 +284,11 @@ static int cuse_parse_devinfo(char *p, size_t len, struct cuse_devinfo *devinfo)
if (strcmp(key, "DEVNAME") == 0)
devinfo->name = val;
else
printk(KERN_WARNING "CUSE: unknown device info \"%s\"\n",
key);
pr_warn("unknown device info \"%s\"\n", key);
}

if (!devinfo->name || !strlen(devinfo->name)) {
printk(KERN_ERR "CUSE: DEVNAME unspecified\n");
pr_err("DEVNAME unspecified\n");
return -EINVAL;
}

Expand Down Expand Up @@ -341,7 +342,7 @@ static void cuse_process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
else
rc = register_chrdev_region(devt, 1, devinfo.name);
if (rc) {
printk(KERN_ERR "CUSE: failed to register chrdev region\n");
pr_err("failed to register chrdev region\n");
goto err;
}

Expand Down
4 changes: 2 additions & 2 deletions fs/fuse/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -906,8 +906,8 @@ static int fuse_check_page(struct page *page)
1 << PG_lru |
1 << PG_active |
1 << PG_reclaim))) {
printk(KERN_WARNING "fuse: trying to steal weird page\n");
printk(KERN_WARNING " page=%p index=%li flags=%08lx, count=%i, mapcount=%i, mapping=%p\n", page, page->index, page->flags, page_count(page), page_mapcount(page), page->mapping);
pr_warn("trying to steal weird page\n");
pr_warn(" page=%p index=%li flags=%08lx, count=%i, mapcount=%i, mapping=%p\n", page, page->index, page->flags, page_count(page), page_mapcount(page), page->mapping);
return 1;
}
return 0;
Expand Down
4 changes: 4 additions & 0 deletions fs/fuse/fuse_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#ifndef _FS_FUSE_I_H
#define _FS_FUSE_I_H

#ifndef pr_fmt
# define pr_fmt(fmt) "fuse: " fmt
#endif

#include <linux/fuse.h>
#include <linux/fs.h>
#include <linux/mount.h>
Expand Down
6 changes: 3 additions & 3 deletions fs/fuse/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1397,8 +1397,8 @@ static int __init fuse_init(void)
{
int res;

printk(KERN_INFO "fuse init (API version %i.%i)\n",
FUSE_KERNEL_VERSION, FUSE_KERNEL_MINOR_VERSION);
pr_info("init (API version %i.%i)\n",
FUSE_KERNEL_VERSION, FUSE_KERNEL_MINOR_VERSION);

INIT_LIST_HEAD(&fuse_conn_list);
res = fuse_fs_init();
Expand Down Expand Up @@ -1434,7 +1434,7 @@ static int __init fuse_init(void)

static void __exit fuse_exit(void)
{
printk(KERN_DEBUG "fuse exit\n");
pr_debug("exit\n");

fuse_ctl_cleanup();
fuse_sysfs_cleanup();
Expand Down

0 comments on commit f229448

Please sign in to comment.