提交 1243172d 编写于 作者: Y Yu Kuai 提交者: Jens Axboe

nbd: use pr_err to output error message

Instead of using the long printk(KERN_ERR "nbd: ...") to
output error message, defining pr_fmt and using
the short pr_err("") to do that. The replacemen is done
by using the following command:

  sed -i 's/printk(KERN_ERR "nbd: /pr_err("/g' \
		  drivers/block/nbd.c

This patch also rewrap to 80 columns where possible.
Signed-off-by: NHou Tao <houtao1@huawei.com>
Signed-off-by: NYu Kuai <yukuai3@huawei.com>
Reviewed-by: NJosef Bacik <josef@toxicpanda.com>
Link: https://lore.kernel.org/r/20220521073749.3146892-7-yukuai3@huawei.comSigned-off-by: NJens Axboe <axboe@kernel.dk>
上级 858f1bf6
...@@ -1928,16 +1928,16 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info) ...@@ -1928,16 +1928,16 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info)
* MKDEV() expect that the max bits of first_minor is 20. * MKDEV() expect that the max bits of first_minor is 20.
*/ */
if (index < 0 || index > MINORMASK >> part_shift) { if (index < 0 || index > MINORMASK >> part_shift) {
printk(KERN_ERR "nbd: illegal input index %d\n", index); pr_err("illegal input index %d\n", index);
return -EINVAL; return -EINVAL;
} }
} }
if (!info->attrs[NBD_ATTR_SOCKETS]) { if (!info->attrs[NBD_ATTR_SOCKETS]) {
printk(KERN_ERR "nbd: must specify at least one socket\n"); pr_err("must specify at least one socket\n");
return -EINVAL; return -EINVAL;
} }
if (!info->attrs[NBD_ATTR_SIZE_BYTES]) { if (!info->attrs[NBD_ATTR_SIZE_BYTES]) {
printk(KERN_ERR "nbd: must specify a size in bytes for the device\n"); pr_err("must specify a size in bytes for the device\n");
return -EINVAL; return -EINVAL;
} }
again: again:
...@@ -1973,7 +1973,7 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info) ...@@ -1973,7 +1973,7 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info)
nbd_put(nbd); nbd_put(nbd);
if (index == -1) if (index == -1)
goto again; goto again;
printk(KERN_ERR "nbd: nbd%d already in use\n", index); pr_err("nbd%d already in use\n", index);
return -EBUSY; return -EBUSY;
} }
if (WARN_ON(nbd->config)) { if (WARN_ON(nbd->config)) {
...@@ -1985,7 +1985,7 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info) ...@@ -1985,7 +1985,7 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info)
if (IS_ERR(config)) { if (IS_ERR(config)) {
mutex_unlock(&nbd->config_lock); mutex_unlock(&nbd->config_lock);
nbd_put(nbd); nbd_put(nbd);
printk(KERN_ERR "nbd: couldn't allocate config\n"); pr_err("couldn't allocate config\n");
return PTR_ERR(config); return PTR_ERR(config);
} }
nbd->config = config; nbd->config = config;
...@@ -2041,7 +2041,7 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info) ...@@ -2041,7 +2041,7 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info)
struct nlattr *socks[NBD_SOCK_MAX+1]; struct nlattr *socks[NBD_SOCK_MAX+1];
if (nla_type(attr) != NBD_SOCK_ITEM) { if (nla_type(attr) != NBD_SOCK_ITEM) {
printk(KERN_ERR "nbd: socks must be embedded in a SOCK_ITEM attr\n"); pr_err("socks must be embedded in a SOCK_ITEM attr\n");
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
...@@ -2050,7 +2050,7 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info) ...@@ -2050,7 +2050,7 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info)
nbd_sock_policy, nbd_sock_policy,
info->extack); info->extack);
if (ret != 0) { if (ret != 0) {
printk(KERN_ERR "nbd: error processing sock list\n"); pr_err("error processing sock list\n");
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
...@@ -2122,7 +2122,7 @@ static int nbd_genl_disconnect(struct sk_buff *skb, struct genl_info *info) ...@@ -2122,7 +2122,7 @@ static int nbd_genl_disconnect(struct sk_buff *skb, struct genl_info *info)
return -EPERM; return -EPERM;
if (!info->attrs[NBD_ATTR_INDEX]) { if (!info->attrs[NBD_ATTR_INDEX]) {
printk(KERN_ERR "nbd: must specify an index to disconnect\n"); pr_err("must specify an index to disconnect\n");
return -EINVAL; return -EINVAL;
} }
index = nla_get_u32(info->attrs[NBD_ATTR_INDEX]); index = nla_get_u32(info->attrs[NBD_ATTR_INDEX]);
...@@ -2130,14 +2130,12 @@ static int nbd_genl_disconnect(struct sk_buff *skb, struct genl_info *info) ...@@ -2130,14 +2130,12 @@ static int nbd_genl_disconnect(struct sk_buff *skb, struct genl_info *info)
nbd = idr_find(&nbd_index_idr, index); nbd = idr_find(&nbd_index_idr, index);
if (!nbd) { if (!nbd) {
mutex_unlock(&nbd_index_mutex); mutex_unlock(&nbd_index_mutex);
printk(KERN_ERR "nbd: couldn't find device at index %d\n", pr_err("couldn't find device at index %d\n", index);
index);
return -EINVAL; return -EINVAL;
} }
if (!refcount_inc_not_zero(&nbd->refs)) { if (!refcount_inc_not_zero(&nbd->refs)) {
mutex_unlock(&nbd_index_mutex); mutex_unlock(&nbd_index_mutex);
printk(KERN_ERR "nbd: device at index %d is going down\n", pr_err("device at index %d is going down\n", index);
index);
return -EINVAL; return -EINVAL;
} }
mutex_unlock(&nbd_index_mutex); mutex_unlock(&nbd_index_mutex);
...@@ -2162,7 +2160,7 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info) ...@@ -2162,7 +2160,7 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info)
return -EPERM; return -EPERM;
if (!info->attrs[NBD_ATTR_INDEX]) { if (!info->attrs[NBD_ATTR_INDEX]) {
printk(KERN_ERR "nbd: must specify a device to reconfigure\n"); pr_err("must specify a device to reconfigure\n");
return -EINVAL; return -EINVAL;
} }
index = nla_get_u32(info->attrs[NBD_ATTR_INDEX]); index = nla_get_u32(info->attrs[NBD_ATTR_INDEX]);
...@@ -2170,8 +2168,7 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info) ...@@ -2170,8 +2168,7 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info)
nbd = idr_find(&nbd_index_idr, index); nbd = idr_find(&nbd_index_idr, index);
if (!nbd) { if (!nbd) {
mutex_unlock(&nbd_index_mutex); mutex_unlock(&nbd_index_mutex);
printk(KERN_ERR "nbd: couldn't find a device at index %d\n", pr_err("couldn't find a device at index %d\n", index);
index);
return -EINVAL; return -EINVAL;
} }
if (nbd->backend) { if (nbd->backend) {
...@@ -2192,8 +2189,7 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info) ...@@ -2192,8 +2189,7 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info)
} }
if (!refcount_inc_not_zero(&nbd->refs)) { if (!refcount_inc_not_zero(&nbd->refs)) {
mutex_unlock(&nbd_index_mutex); mutex_unlock(&nbd_index_mutex);
printk(KERN_ERR "nbd: device at index %d is going down\n", pr_err("device at index %d is going down\n", index);
index);
return -EINVAL; return -EINVAL;
} }
mutex_unlock(&nbd_index_mutex); mutex_unlock(&nbd_index_mutex);
...@@ -2257,7 +2253,7 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info) ...@@ -2257,7 +2253,7 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info)
struct nlattr *socks[NBD_SOCK_MAX+1]; struct nlattr *socks[NBD_SOCK_MAX+1];
if (nla_type(attr) != NBD_SOCK_ITEM) { if (nla_type(attr) != NBD_SOCK_ITEM) {
printk(KERN_ERR "nbd: socks must be embedded in a SOCK_ITEM attr\n"); pr_err("socks must be embedded in a SOCK_ITEM attr\n");
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
...@@ -2266,7 +2262,7 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info) ...@@ -2266,7 +2262,7 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info)
nbd_sock_policy, nbd_sock_policy,
info->extack); info->extack);
if (ret != 0) { if (ret != 0) {
printk(KERN_ERR "nbd: error processing sock list\n"); pr_err("error processing sock list\n");
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
...@@ -2483,7 +2479,7 @@ static int __init nbd_init(void) ...@@ -2483,7 +2479,7 @@ static int __init nbd_init(void)
BUILD_BUG_ON(sizeof(struct nbd_request) != 28); BUILD_BUG_ON(sizeof(struct nbd_request) != 28);
if (max_part < 0) { if (max_part < 0) {
printk(KERN_ERR "nbd: max_part must be >= 0\n"); pr_err("max_part must be >= 0\n");
return -EINVAL; return -EINVAL;
} }
...@@ -2562,10 +2558,10 @@ static void __exit nbd_cleanup(void) ...@@ -2562,10 +2558,10 @@ static void __exit nbd_cleanup(void)
nbd = list_first_entry(&del_list, struct nbd_device, list); nbd = list_first_entry(&del_list, struct nbd_device, list);
list_del_init(&nbd->list); list_del_init(&nbd->list);
if (refcount_read(&nbd->config_refs)) if (refcount_read(&nbd->config_refs))
printk(KERN_ERR "nbd: possibly leaking nbd_config (ref %d)\n", pr_err("possibly leaking nbd_config (ref %d)\n",
refcount_read(&nbd->config_refs)); refcount_read(&nbd->config_refs));
if (refcount_read(&nbd->refs) != 1) if (refcount_read(&nbd->refs) != 1)
printk(KERN_ERR "nbd: possibly leaking a device\n"); pr_err("possibly leaking a device\n");
nbd_put(nbd); nbd_put(nbd);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册