[Devel] [PATCH vz7 2/2] ploop: add device name to log messages
Alexander Atanasov
alexander.atanasov at virtuozzo.com
Fri Jan 20 12:03:40 MSK 2023
Add logging macros that take ploop object and print device name in the
generated log message. Switch pr_* macros to coresponging PL_* macros.
No functional changes.
https://jira.sw.ru/browse/PSBM-144575
Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
---
drivers/block/ploop/dev.c | 78 ++++++++++++++-----------------
drivers/block/ploop/fmt_ploop1.c | 17 ++++---
drivers/block/ploop/fmt_raw.c | 9 ++--
drivers/block/ploop/freeblks.c | 14 +++---
drivers/block/ploop/io_direct.c | 12 ++---
drivers/block/ploop/io_kaio.c | 35 +++++++-------
drivers/block/ploop/map.c | 6 +--
drivers/block/ploop/push_backup.c | 17 ++++---
drivers/block/ploop/sysfs.c | 10 ++--
include/linux/ploop/ploop.h | 6 +++
10 files changed, 97 insertions(+), 107 deletions(-)
diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index dfad24818216..6eb22168b5fe 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -1968,7 +1968,7 @@ ploop_entry_zero_req(struct ploop_request *preq)
level = map_get_index(preq, preq->req_cluster, &iblk);
if (level != top_delta->level) {
- pr_warn("Can't zero index on wrong level=%d "
+ PL_WARN(plo, "Can't zero index on wrong level=%d "
"(top_level=%d req_cluster=%u iblk=%u/%u)\n",
level, top_delta->level, preq->req_cluster,
iblk, preq->iblock);
@@ -2104,14 +2104,14 @@ ploop_entry_reloc_s_req(struct ploop_request *preq, iblock_t *iblk)
level = map_get_index(preq, preq->req_cluster, iblk);
if (level != top_delta->level) {
- pr_warn("Can't relocate block on wrong level=%d "
+ PL_WARN(plo, "Can't relocate block on wrong level=%d "
"(top_level=%d req_cluster=%u iblk=%u/%u)\n",
level, top_delta->level, preq->req_cluster,
*iblk, preq->iblock);
return -EIO;
}
if (preq->src_iblock != *iblk) {
- pr_warn("Can't relocate block due to wrong mapping: "
+ PL_WARN(plo, "Can't relocate block due to wrong mapping: "
"req_cluster=%u should point to iblk=%u while "
"map_get_index() calculated iblk=%u\n",
preq->req_cluster, preq->src_iblock, *iblk);
@@ -2251,7 +2251,7 @@ static int ploop_entry_discard_req(struct ploop_request *preq)
preq->dst_iblock = 0;
if (err) {
if (err == -EINVAL) {
- pr_warn("ploop_entry_discard_req1: "
+ PL_WARN(plo, "ploop_entry_discard_req1: "
"(%lu %u; %u %u; %u %u)\n",
preq->req_sector, preq->req_size,
preq->req_cluster, preq->iblock,
@@ -2273,7 +2273,7 @@ static int ploop_entry_discard_req(struct ploop_request *preq)
err = ploop_fb_add_free_extent(plo->fbd, preq->dst_cluster,
preq->dst_iblock, len);
if (err == -EINVAL) {
- pr_warn("ploop_entry_discard_req2: "
+ PL_WARN(plo, "ploop_entry_discard_req2: "
"(%lu %u; %u %u; %u %u)\n",
preq->req_sector, preq->req_size,
preq->req_cluster, preq->iblock,
@@ -2826,7 +2826,7 @@ restart:
case PLOOP_E_COMPLETE:
if (unlikely(test_bit(PLOOP_REQ_RELOC_S, &preq->state) &&
preq->error)) {
- pr_warn("RELOC_S completed with err %d"
+ PL_WARN(plo, "RELOC_S completed with err %d"
" (%u %u %u %u %u)\n",
preq->error, preq->req_cluster, preq->iblock,
preq->src_iblock, preq->dst_cluster,
@@ -3984,7 +3984,7 @@ static void rename_deltas(struct ploop_device * plo, int level)
"%d", delta->level);
#endif
if (err)
- pr_warn("rename_deltas: %d %d %d\n", err, level, delta->level);
+ PL_WARN(plo, "rename_deltas: %d %d %d\n", err, level, delta->level);
}
}
@@ -4014,8 +4014,7 @@ static int ploop_del_delta(struct ploop_device * plo, unsigned long arg)
return -EBUSY;
if (level == 0 && test_bit(PLOOP_S_RUNNING, &plo->state)) {
- pr_info("Can't del base delta on running ploop%d\n",
- plo->index);
+ PL_INFO(plo, "Can't del base delta on running\n");
return -EBUSY;
}
@@ -4196,8 +4195,7 @@ static int ploop_merge(struct ploop_device * plo)
err = ploop_prepare_merge(next, &sd);
if (err) {
- pr_warn("prepare_merge for ploop%d failed (%d)\n",
- plo->index, err);
+ PL_WARN(plo, "prepare_merge failed (%d)\n", err);
goto out;
}
@@ -4222,8 +4220,7 @@ static int ploop_merge(struct ploop_device * plo)
* in prepare_merge. Failed start_merge means
* abort of the device.
*/
- pr_warn("start_merge for ploop%d failed (%d)\n",
- plo->index, err);
+ PL_WARN(plo, "start_merge failed (%d)\n", err);
set_bit(PLOOP_S_ABORT, &plo->state);
}
@@ -4250,8 +4247,7 @@ already:
delta = map_top_delta(plo->trans_map);
if (test_bit(PLOOP_S_ABORT, &plo->state)) {
- pr_warn("merge for ploop%d failed (state ABORT)\n",
- plo->index);
+ PL_WARN(plo, "merge failed (state ABORT)\n");
err = -EIO;
}
@@ -4314,9 +4310,9 @@ static int ploop_bd_full(struct backing_dev_info *bdi, long long nr, int root)
static unsigned long full_warn_time;
if (printk_timed_ratelimit(&full_warn_time, 60*60*HZ))
- pr_warn("ploop%d: host disk is almost full "
+ PL_WARN(plo, "host disk is almost full "
"(%llu < %llu); CT sees -ENOSPC !\n",
- plo->index, buf.f_bfree * buf.f_bsize,
+ buf.f_bfree * buf.f_bsize,
reserved + nr);
rc = 1;
@@ -4400,6 +4396,7 @@ static int ploop_start(struct ploop_device * plo, struct block_device *bdev)
wake_up_process(plo->thread);
set_bit(PLOOP_S_RUNNING, &plo->state);
BUG_ON(list_empty(&plo->map.delta_list));
+ PL_INFO(plo, "Started\n");
return 0;
out_err:
@@ -4417,8 +4414,7 @@ static int ploop_stop(struct ploop_device * plo, struct block_device *bdev)
if (bdev != bdev->bd_contains) {
if (printk_ratelimit())
- pr_info("stop ploop%d failed (wrong bdev)\n",
- plo->index);
+ PL_INFO(plo, "stop failed (wrong bdev)\n");
return -ENODEV;
}
@@ -4428,8 +4424,8 @@ static int ploop_stop(struct ploop_device * plo, struct block_device *bdev)
holders = bdev->bd_contains->bd_holders;
mutex_unlock(&plo->ctl_mutex);
active = ploop_has_active_sb(plo, bdev);
- pr_info("stop ploop%d failed (holders=%d, sb=%d)\n",
- plo->index, holders, active);
+ PL_INFO(plo, "stop failed (holders=%d, sb=%d)\n",
+ holders, active);
mutex_lock(&plo->ctl_mutex);
}
return -EBUSY;
@@ -4439,38 +4435,35 @@ static int ploop_stop(struct ploop_device * plo, struct block_device *bdev)
return -EINVAL;
if (list_empty(&plo->map.delta_list)) {
- pr_info("stop ploop%d failed (no deltas)\n",
- plo->index);
+ PL_INFO(plo, "stop failed (no deltas)\n");
return -ENOENT;
}
cnt = atomic_read(&plo->open_count);
if (cnt > 1) {
if (printk_ratelimit())
- pr_info("stop ploop%d failed (cnt=%d)\n",
- plo->index, cnt);
+ PL_INFO(plo, "stop failed (cnt=%d)\n", cnt);
return -EBUSY;
}
cnt = atomic_read(&plo->maintenance_cnt);
if (plo->maintenance_type != PLOOP_MNTN_OFF && cnt) {
if (printk_ratelimit())
- pr_info("stop ploop%d failed "
- "(type=%d cnt=%d)\n",
- plo->index, plo->maintenance_type, cnt);
+ PL_INFO(plo, "stop failed (type=%d cnt=%d)\n",
+ plo->maintenance_type, cnt);
return -EBUSY;
}
if (plo->freeze_state != PLOOP_F_NORMAL) {
if (printk_ratelimit())
- pr_info("stop ploop%d failed (freeze_state=%d)\n",
- plo->index, plo->freeze_state);
+ PL_INFO(plo, "stop failed (freeze_state=%d)\n",
+ plo->freeze_state);
return -EBUSY;
}
active_reqs = plo->active_reqs;
if (active_reqs) {
- WARN_ONCE(1, "stop ploop%d failed (active_reqs=%d)\n",
+ WARN_ONCE(1, "ploop%d: stop failed (active_reqs=%d)\n",
plo->index, active_reqs);
return -EBUSY;
}
@@ -4535,6 +4528,7 @@ static int ploop_stop(struct ploop_device * plo, struct block_device *bdev)
if (plo->trans_map)
ploop_map_destroy(plo->trans_map);
+ PL_INFO(plo, "Stopped\n");
return 0;
}
@@ -4580,22 +4574,19 @@ static int ploop_clear(struct ploop_device * plo, struct block_device * bdev)
if (test_bit(PLOOP_S_RUNNING, &plo->state)) {
if (printk_ratelimit())
- pr_info("clear ploop%d failed (RUNNING)\n",
- plo->index);
+ PL_INFO(plo, "clear failed (RUNNING)\n");
return -EBUSY;
}
if (plo->maintenance_type == PLOOP_MNTN_TRACK) {
if (printk_ratelimit())
- pr_info("clear ploop%d failed (TRACK)\n",
- plo->index);
+ PL_INFO(plo, "clear failed (TRACK)\n");
return -EBUSY;
}
cnt = atomic_read(&plo->maintenance_cnt);
if (plo->maintenance_type != PLOOP_MNTN_OFF && cnt) {
if (printk_ratelimit())
- pr_info("clear ploop%d failed "
- "(type=%d cnt=%d)\n",
- plo->index, plo->maintenance_type, cnt);
+ PL_INFO(plo, "clear failed (type=%d cnt=%d)\n",
+ plo->maintenance_type, cnt);
return -EBUSY;
}
@@ -4962,14 +4953,14 @@ static int ploop_freeblks_ioc(struct ploop_device *plo, unsigned long arg)
extent.iblk, extent.len);
if (rc) {
if (rc == -EINVAL) {
- pr_warn("ploop_freeblks_ioc: n=%d\n", ctl.n_extents);
+ PL_WARN(plo, "ploop_freeblks_ioc: n=%d\n", ctl.n_extents);
for (i = 0; i < ctl.n_extents; i++) {
if (copy_from_user(&extent, &extents[i],
sizeof(extent))) {
pr_warn("copy failed: i=%d\n", i);
break;
}
- pr_warn("ploop_freeblks_ioc: i=%d: %u %u %u\n",
+ PL_WARN(plo, "ploop_freeblks_ioc: i=%d: %u %u %u\n",
i, extent.clu, extent.iblk, extent.len);
}
WARN_ONCE(1, "add_free_extent failed\n");
@@ -5443,8 +5434,7 @@ static int ploop_push_backup_io(struct ploop_device *plo, unsigned long arg)
return -EINVAL;
if (ploop_pb_check_uuid(pbd, ctl.cbt_uuid)) {
- pr_warn("ploop(%d): PUSH_BACKUP_IO uuid mismatch\n",
- plo->index);
+ PL_WARN(plo, "PUSH_BACKUP_IO uuid mismatch\n");
return -EINVAL;
}
@@ -5473,8 +5463,7 @@ static int ploop_push_backup_stop(struct ploop_device *plo, unsigned long arg)
return -EFAULT;
if (pbd && ploop_pb_check_uuid(pbd, ctl.cbt_uuid)) {
- pr_warn("ploop(%d): PUSH_BACKUP_STOP uuid mismatch\n",
- plo->index);
+ PL_WARN(plo, "PUSH_BACKUP_STOP uuid mismatch\n");
return -EINVAL;
}
@@ -6095,6 +6084,7 @@ static void __exit ploop_mod_exit(void)
unregister_blkdev(PLOOP_DEVICE_MAJOR, "ploop");
ploop_map_exit();
WARN_ON(atomic_read(&plo_count));
+ pr_info("ploop_dev: module unloaded\n");
}
module_init(ploop_mod_init);
module_exit(ploop_mod_exit);
diff --git a/drivers/block/ploop/fmt_ploop1.c b/drivers/block/ploop/fmt_ploop1.c
index 40a7919e1ec8..e59a9eb50ac2 100644
--- a/drivers/block/ploop/fmt_ploop1.c
+++ b/drivers/block/ploop/fmt_ploop1.c
@@ -34,7 +34,7 @@ static void ploop_set_holes_bitmap_bit(unsigned int nr, struct ploop_delta *delt
struct ploop1_private *ph = delta->priv;
if (WARN_ON_ONCE(nr >= ph->nr_clusters_in_bitmap)) {
- pr_err("nr=%u, nr_clusters=%u\n", nr, ph->nr_clusters_in_bitmap);
+ PL_ERR(delta->plo, "nr=%u, nr_clusters=%u\n", nr, ph->nr_clusters_in_bitmap);
return;
}
@@ -46,7 +46,7 @@ static void ploop_clear_holes_bitmap_bit(unsigned int nr, struct ploop_delta *de
struct ploop1_private *ph = delta->priv;
if (WARN_ON_ONCE(nr >= ph->nr_clusters_in_bitmap)) {
- pr_err("nr=%u, nr_clusters=%u\n", nr, ph->nr_clusters_in_bitmap);
+ PL_ERR(delta->plo, "nr=%u, nr_clusters=%u\n", nr, ph->nr_clusters_in_bitmap);
return;
}
@@ -221,8 +221,7 @@ static int populate_holes_bitmap(struct ploop_delta *delta,
* This may be a result of shrinking large disk
* to a small size.
*/
- pr_err("ploop%u: bat is bigger than disk size\n",
- delta->plo->index);
+ PL_ERR(delta->plo, "bat is bigger than disk size\n");
goto out;
}
/* Images with big BAT and small data may be shorter than nr_all_pages */
@@ -230,7 +229,7 @@ static int populate_holes_bitmap(struct ploop_delta *delta,
(ph->l1_off << 9) / PAGE_SIZE - consumed);
ret = delta->io.ops->sync_read_many(&delta->io, pages, count, sec);
if (ret) {
- pr_err("ploop: too short BAT\n");
+ PL_ERR(delta->plo, "too short BAT\n");
goto out;
}
@@ -594,8 +593,8 @@ ploop1_start_merge(struct ploop_delta * delta, struct ploop_snapdata * sd)
return err;
if (test_bit(PLOOP_S_ABORT, &delta->plo->state)) {
- pr_warn("ploop1_start_merge for ploop%d failed "
- "(state ABORT)\n", delta->plo->index);
+ PL_WARN(delta->plo, "ploop1_start_merge failed "
+ "(state ABORT)\n");
return -EIO;
}
@@ -698,7 +697,7 @@ static int expand_holes_bitmap(struct ploop_delta *delta,
holes_bitmap = kvmalloc(size, GFP_KERNEL);
if (!holes_bitmap) {
- pr_err("Can't allocate holes_bitmap\n");
+ PL_ERR(delta->plo, "Can't allocate holes_bitmap\n");
return -ENOMEM;
}
@@ -814,7 +813,7 @@ static int ploop1_complete_grow(struct ploop_delta * delta, u64 new_size)
vh_bsize = le32_to_cpu(vh->m_Sectors);
if (vh_bsize != (1 << delta->io.plo->cluster_log)) {
- pr_warn("grow: vh->m_Sectors=%u != 1<<plo->cluster_log=%u\n",
+ PL_WARN(delta->plo, "grow: vh->m_Sectors=%u != 1<<plo->cluster_log=%u\n",
vh_bsize, 1 << delta->io.plo->cluster_log);
return -EINVAL;
}
diff --git a/drivers/block/ploop/fmt_raw.c b/drivers/block/ploop/fmt_raw.c
index 6d4364581764..11eabfabda72 100644
--- a/drivers/block/ploop/fmt_raw.c
+++ b/drivers/block/ploop/fmt_raw.c
@@ -57,7 +57,7 @@ raw_open(struct ploop_delta * delta)
delta->io.alloc_head = pos >> (cluster_log + 9);
if (!delta->io.alloc_head) {
- pr_err("ploop: zero length file\n");
+ PL_ERR(delta->plo, "zero length file\n");
return -EINVAL;
}
@@ -85,11 +85,11 @@ raw_refresh(struct ploop_delta * delta)
pos = delta->io.ops->i_size_read(&delta->io);
if (pos & (cluster_size_in_bytes(delta->plo) - 1)) {
- pr_warn("raw delta is not aligned (%llu bytes)\n", pos);
+ PL_WARN(delta->plo, "raw delta is not aligned (%llu bytes)\n", pos);
return -EINVAL;
}
if ((pos >> (cluster_log + 9)) < delta->io.alloc_head) {
- pr_warn("raw delta was corrupted "
+ PL_WARN(delta->plo, "raw delta was corrupted "
"(old_size=%u new_size=%llu iblocks)\n",
delta->io.alloc_head,
pos >> (cluster_log + 9));
@@ -198,8 +198,7 @@ raw_start_merge(struct ploop_delta * delta, struct ploop_snapdata * sd)
return err;
if (test_bit(PLOOP_S_ABORT, &delta->plo->state)) {
- pr_warn(KERN_WARNING "raw_start_merge for ploop%d failed "
- "(state ABORT)\n", delta->plo->index);
+ PL_WARN(delta->plo, "raw_start_merge failed (state ABORT)\n");
return -EIO;
}
diff --git a/drivers/block/ploop/freeblks.c b/drivers/block/ploop/freeblks.c
index 46699c6a7c63..6b53660c973b 100644
--- a/drivers/block/ploop/freeblks.c
+++ b/drivers/block/ploop/freeblks.c
@@ -391,7 +391,7 @@ static int split_fb_extent(struct ploop_freeblks_extent *extent, u32 *off_p,
new_extent = kzalloc(sizeof(*new_extent), GFP_KERNEL);
if (new_extent == NULL) {
- pr_warn("Can't allocate new freeblks extent for splittig!\n");
+ PL_WARN(fbd->plo, "Can't allocate new freeblks extent for splittig!\n");
return -ENOMEM;
}
@@ -855,7 +855,7 @@ int ploop_fb_add_free_extent(struct ploop_freeblks_desc *fbd,
struct ploop_freeblks_extent *ex;
if (len == 0) {
- pr_warn("ploop_fb_add_free_extent(): empty extent! (%u/%u)\n",
+ PL_WARN(fbd->plo, "ploop_fb_add_free_extent(): empty extent! (%u/%u)\n",
clu, iblk);
return 0;
}
@@ -870,7 +870,7 @@ int ploop_fb_add_free_extent(struct ploop_freeblks_desc *fbd,
if (iblk + len > tmp->iblk) {
int c = &ex->list != &fbd->fbd_free_list;
- pr_warn("ploop_fb_add_free_extent(): next (%u %u %u) "
+ PL_WARN(fbd->plo, "ploop_fb_add_free_extent(): next (%u %u %u) "
"intersects with (%u %u %u); ex (%u %u %d)\n",
tmp->clu, tmp->iblk, tmp->len, clu, iblk, len,
c ? ex->clu : 0, c ? ex->iblk : 0, c ? ex->len : -1);
@@ -883,7 +883,7 @@ int ploop_fb_add_free_extent(struct ploop_freeblks_desc *fbd,
struct ploop_freeblks_extent *t = NULL;
if (ex->list.next != &fbd->fbd_free_list)
t = list_entry(ex->list.next, struct ploop_freeblks_extent, list);
- pr_warn("ploop_fb_add_free_extent(): ex (%u %u %u) "
+ PL_WARN(fbd->plo, "ploop_fb_add_free_extent(): ex (%u %u %u) "
"intersects with (%u %u %u); next (%u %u %d)\n",
ex->clu, ex->iblk, ex->len, clu, iblk, len,
t ? t->clu : 0, t ? t->iblk : 0, t ? t->len : -1);
@@ -915,7 +915,7 @@ int ploop_fb_add_reloc_extent(struct ploop_freeblks_desc *fbd,
struct ploop_relocblks_extent *rblk_extent;
if (len == 0) {
- pr_warn("ploop_fb_add_reloc_extent(): empty extent! (%u/%u)\n",
+ PL_WARN(fbd->plo, "ploop_fb_add_reloc_extent(): empty extent! (%u/%u)\n",
clu, iblk);
return 0;
}
@@ -924,7 +924,7 @@ int ploop_fb_add_reloc_extent(struct ploop_freeblks_desc *fbd,
rblk_extent = list_entry(fbd->fbd_reloc_list.prev,
struct ploop_relocblks_extent, list);
if (rblk_extent->iblk + rblk_extent->len > iblk) {
- pr_warn("ploop_fb_add_reloc_extent(): extents should be sorted\n");
+ PL_WARN(fbd->plo, "ploop_fb_add_reloc_extent(): extents should be sorted\n");
return -EINVAL;
}
@@ -932,7 +932,7 @@ int ploop_fb_add_reloc_extent(struct ploop_freeblks_desc *fbd,
rblk_extent = list_entry(rblk_extent->list.next,
struct ploop_relocblks_extent, list);
if (iblk + len > rblk_extent->iblk) {
- pr_warn("ploop_fb_add_reloc_extent(): intersected extents\n");
+ PL_WARN(fbd->plo, "ploop_fb_add_reloc_extent(): intersected extents\n");
return -EINVAL;
}
}
diff --git a/drivers/block/ploop/io_direct.c b/drivers/block/ploop/io_direct.c
index d2759447e23a..a3632b12be91 100644
--- a/drivers/block/ploop/io_direct.c
+++ b/drivers/block/ploop/io_direct.c
@@ -880,7 +880,7 @@ retry:
struct ploop_device *plo = io->plo;
struct block_device *dm_crypt_bdev;
- pr_warn("PLOOP: failed to invalidate page cache %d/%d\n", err, attempt2);
+ PL_WARN(plo, "failed to invalidate page cache %d/%d\n", err, attempt2);
if (attempt2)
return err;
attempt2 = 1;
@@ -915,7 +915,7 @@ static int dio_release_prealloced(struct ploop_io * io)
ret = dio_truncate(io, io->files.file, io->alloc_head);
if (ret)
- pr_warn("Can't release %llu prealloced bytes: "
+ PL_WARN(io->plo, "Can't release %llu prealloced bytes: "
"truncate to %llu failed (%d)\n",
io->prealloced_size - end_pos, end_pos, ret);
else
@@ -1764,7 +1764,7 @@ static int dio_autodetect(struct ploop_io *io, unsigned int id)
return -1;
if (inode->i_sb->s_bdev == NULL) {
- pr_warn("File on FS EXT(%s) without backing device\n", s_id);
+ PL_WARN(io->plo, "File on FS EXT(%s) without backing device\n", s_id);
return -1;
}
@@ -1773,12 +1773,12 @@ static int dio_autodetect(struct ploop_io *io, unsigned int id)
"File on FS w/o fallocate");
if (!file->f_op->unlocked_ioctl) {
- pr_warn("Cannot run on EXT4(%s): no unlocked_ioctl\n", s_id);
+ PL_WARN(io->plo, "Cannot run on EXT4(%s): no unlocked_ioctl\n", s_id);
return -1;
}
if (!file->f_op->fsync) {
- pr_warn("Cannot run on EXT4(%s): no fsync\n", s_id);
+ PL_WARN(io->plo, "Cannot run on EXT4(%s): no fsync\n", s_id);
return -1;
}
@@ -1789,7 +1789,7 @@ static int dio_autodetect(struct ploop_io *io, unsigned int id)
set_fs(fs);
if (err != 0) {
- pr_warn("Cannot run on EXT4(%s): failed FS_IOC_GETFLAGS (%d)\n",
+ PL_WARN(io->plo, "Cannot run on EXT4(%s): failed FS_IOC_GETFLAGS (%d)\n",
s_id, err);
return -1;
}
diff --git a/drivers/block/ploop/io_kaio.c b/drivers/block/ploop/io_kaio.c
index f9413e701736..35c0fad43baf 100644
--- a/drivers/block/ploop/io_kaio.c
+++ b/drivers/block/ploop/io_kaio.c
@@ -130,8 +130,7 @@ static void check_standby_mode(long res, struct ploop_device *plo) {
spin_unlock_irq(q->queue_lock);
if (!prev)
- pr_warn("ploop%d was switched into "
- "the standby mode\n", plo->index);
+ PL_WARN(plo,"was switched into the standby mode\n");
}
static void kaio_rw_aio_complete(u64 data, long res)
@@ -141,14 +140,14 @@ static void kaio_rw_aio_complete(u64 data, long res)
if (unlikely(res < 0)) {
struct bio *b = preq->aux_bio;
- pr_warn("kaio_rw_aio_complete: kaio failed with err=%ld "
+ PL_WARN(preq->plo, "kaio_rw_aio_complete: kaio failed with err=%ld "
"(rw=%s; state=%ld/0x%lx; clu=%d; iblk=%d; aux=%ld)\n",
res, (preq->req_rw & REQ_WRITE) ? "WRITE" : "READ",
preq->eng_state, preq->state, preq->req_cluster,
preq->iblock, b ? b->bi_sector : -1);
bio_list_for_each(b, &preq->bl)
- pr_warn(" bio=%p: bi_sector=%ld bi_size=%d\n",
+ PL_WARN(preq->plo," bio=%p: bi_sector=%ld bi_size=%d\n",
b, b->bi_sector, b->bi_size);
if (static_key_false(&ploop_standby_check))
check_standby_mode(res, preq->plo);
@@ -216,7 +215,7 @@ static int kaio_kernel_submit(struct file *file, struct kaio_req *kreq,
err = aio_kernel_submit(iocb);
if (err)
- pr_warn("kaio_kernel_submit: aio_kernel_submit failed with "
+ PL_WARN(kreq->preq->plo, "kaio_kernel_submit: aio_kernel_submit failed with "
"err=%d (rw=%s; state=%ld/0x%lx; pos=%lld; len=%ld)\n",
err, (rw & REQ_WRITE) ? "WRITE" : "READ",
kreq->preq->eng_state, kreq->preq->state, pos, count);
@@ -480,7 +479,7 @@ static int kaio_resubmit(struct ploop_request * preq)
preq->eng_state = PLOOP_E_DELTA_COPIED; /* skip bcopy() */
return 0;
default:
- pr_warn("Resubmit bad state %lu\n", preq->eng_state);
+ PL_WARN(preq->plo, "Resubmit bad state %lu\n", preq->eng_state);
BUG();
}
@@ -559,11 +558,10 @@ static int kaio_fsync_thread(void * data)
struct file *file = io->files.file;
err = vfs_fsync(file, 1);
if (err) {
- pr_warn("kaio_fsync_thread: vfs_fsync failed "
- "with err=%d (i_ino=%ld of level=%d "
- "on ploop%d)\n",
+ PL_WARN(plo, "kaio_fsync_thread: vfs_fsync failed "
+ "with err=%d (i_ino=%ld of level=%d\n",
err, io->files.inode->i_ino,
- io2level(io), plo->index);
+ io2level(io));
if (static_key_false(&ploop_standby_check))
check_standby_mode(err, plo);
PLOOP_REQ_SET_ERROR(preq, -EIO);
@@ -648,7 +646,7 @@ static int kaio_release_prealloced(struct ploop_io * io)
ret = kaio_truncate(io, io->files.file, io->alloc_head);
if (ret)
- pr_warn("Can't release %llu prealloced bytes: "
+ PL_WARN(io->plo, "Can't release %llu prealloced bytes: "
"truncate to %llu failed (%d)\n",
io->prealloced_size - end_pos, end_pos, ret);
else
@@ -747,7 +745,7 @@ kaio_io_page(struct ploop_io * io, int op, struct ploop_request * preq,
err = aio_kernel_submit(iocb);
if (err) {
- pr_warn("kaio_io_page: aio_kernel_submit failed with "
+ PL_WARN(preq->plo, "kaio_io_page: aio_kernel_submit failed with "
"err=%d (rw=%s; state=%ld/0x%lx; pos=%lld)\n",
err, (op == IOCB_CMD_WRITE_ITER) ? "WRITE" : "READ",
preq->eng_state, preq->state, pos);
@@ -862,7 +860,7 @@ kaio_sync_io(struct ploop_io * io, int op, struct page **pages,
err = aio_kernel_submit(iocb);
if (err) {
- pr_warn("kaio_sync_io: aio_kernel_submit failed with "
+ PL_WARN(io->plo, "kaio_sync_io: aio_kernel_submit failed with "
"err=%d (rw=%s; pos=%lld; len=%d off=%d)\n",
err, (op == IOCB_CMD_WRITE_ITER) ? "WRITE" : "READ",
pos, len, off);
@@ -877,7 +875,7 @@ kaio_sync_io(struct ploop_io * io, int op, struct page **pages,
wait_for_completion(&comp.comp);
if (!err && comp.error)
- pr_warn("kaio_sync_io: kaio failed with err=%d "
+ PL_WARN(io->plo, "kaio_sync_io: kaio failed with err=%d "
"(rw=%s; pos=%lld; len=%d off=%d)\n",
comp.error,
(op == IOCB_CMD_WRITE_ITER) ? "WRITE" : "READ",
@@ -1157,10 +1155,10 @@ static int __kaio_truncate(struct ploop_io * io, struct file * file, u64 pos)
mutex_unlock(&io->files.inode->i_mutex);
if (err) {
- pr_warn("__kaio_truncate(i_ino=%ld of level=%d on ploop%d, "
+ PL_WARN(io->plo, "__kaio_truncate(i_ino=%ld of level=%d, "
"pos=%lld): notify_change failed with err=%d "
"(i_size=%lld)\n",
- io->files.inode->i_ino, io2level(io), io->plo->index,
+ io->files.inode->i_ino, io2level(io),
pos, err, i_size_read(io->files.inode));
return err;
}
@@ -1168,10 +1166,9 @@ static int __kaio_truncate(struct ploop_io * io, struct file * file, u64 pos)
err = vfs_fsync(file, 0);
if (err)
- pr_warn("__kaio_truncate(i_ino=%ld of level=%d on ploop%d, "
+ PL_WARN(io->plo, "__kaio_truncate(i_ino=%ld of level=%d, "
"pos=%lld): vfs_fsync failed with err=%d\n",
- io->files.inode->i_ino, io2level(io), io->plo->index,
- pos, err);
+ io->files.inode->i_ino, io2level(io), pos, err);
return err;
}
diff --git a/drivers/block/ploop/map.c b/drivers/block/ploop/map.c
index 73ac24ac3304..d084a1bd271c 100644
--- a/drivers/block/ploop/map.c
+++ b/drivers/block/ploop/map.c
@@ -320,7 +320,7 @@ map_create(struct ploop_map * map, cluster_t block)
else if (block > entry->mn_end)
p = &(*p)->rb_right;
else
- pr_warn("map_create: Oops! block=%u; mn_range=[%u..%u]\n",
+ PL_WARN(plo, "map_create: Oops! block=%u; mn_range=[%u..%u]\n",
block, entry->mn_start, entry->mn_end);
}
@@ -700,7 +700,7 @@ void ploop_update_map(struct ploop_map * map, int level,
if (lvl == level)
p[idx] = iblk << ploop_map_log(map->plo);
else if (lvl < level)
- pr_warn("Unexpected condition: uptodate map_node %p "
+ PL_WARN(map->plo, "Unexpected condition: uptodate map_node %p "
"covering range %u..%u maps %u to %u on level "
"%d, while user-space merge detected mapping "
"on level %d\n", m, m->mn_start, m->mn_end,
@@ -943,7 +943,7 @@ void ploop_index_update(struct ploop_request * preq)
BUG_ON (test_bit(PLOOP_REQ_ZERO, &preq->state) && preq->iblock);
if (test_bit(PLOOP_REQ_ZERO, &preq->state) && !blk) {
- pr_warn("Either map_node is corrupted or bug in "
+ PL_WARN(plo, "Either map_node is corrupted or bug in "
"ploop-balloon (%u)\n", preq->req_cluster);
PLOOP_REQ_SET_ERROR(preq, -EIO);
goto corrupted;
diff --git a/drivers/block/ploop/push_backup.c b/drivers/block/ploop/push_backup.c
index 576eb36145e4..e2de05d705e9 100644
--- a/drivers/block/ploop/push_backup.c
+++ b/drivers/block/ploop/push_backup.c
@@ -129,8 +129,8 @@ int ploop_pb_cbt_map_release(struct ploop_pushbackup_desc *pbd, bool do_merge)
pbd->cbt_block_max,
pbd->cbt_block_bits);
if (ret)
- pr_warn("ploop(%d): blk_cbt_map_merge() failed with "
- "%d\n", pbd->plo->index, ret);
+ PL_WARN(pbd->plo, "blk_cbt_map_merge() failed with "
+ "%d\n", ret);
}
ploop_pb_map_free(pbd->cbt_map, pbd->cbt_block_max);
@@ -326,7 +326,7 @@ static int convert_map_to_map(struct ploop_pushbackup_desc *pbd)
u64 from_blk, to_blk;
if ((u64)from_max << from_bits != (u64)to_max << to_bits) {
- pr_warn("mismatch in map convert: %lu %lu ---> %u %d\n",
+ PL_WARN(pbd->plo, "mismatch in map convert: %lu %lu ---> %u %d\n",
from_max, from_bits, to_max, to_bits);
return -EINVAL;
}
@@ -426,9 +426,9 @@ void ploop_pb_fini(struct ploop_pushbackup_desc *pbd)
return;
if (!RB_EMPTY_ROOT(&pbd->pending_set.tree))
- pr_warn("ploop_pb_fini: pending_tree is not empty!\n");
+ PL_WARN(pbd->plo, "ploop_pb_fini: pending_tree is not empty!\n");
if (!RB_EMPTY_ROOT(&pbd->reported_set.tree))
- pr_warn("ploop_pb_fini: reported_tree is not empty!\n");
+ PL_WARN(pbd->plo, "ploop_pb_fini: reported_tree is not empty!\n");
if (pbd->health_monitor_thread) {
kthread_stop(pbd->health_monitor_thread);
@@ -491,7 +491,7 @@ static void ploop_pb_add_req_to_tree(struct ploop_request *preq,
mod_timer(&pbs->timer, preq->tstamp + timeout + 1);
if (pbs->list.prev->next != &pbs->list) {
- pr_warn("list_add corruption. pbs->list.prev->next should be "
+ PL_WARN(preq->plo, "list_add corruption. pbs->list.prev->next should be "
"&pbs->list (%p), but was %p. (pbs->list.prev=%p)."
" preq=%p\n",
&pbs->list, pbs->list.prev->next, pbs->list.prev, preq);
@@ -1046,10 +1046,9 @@ static bool ploop_pb_set_expired(struct pb_set *pbs)
spin_unlock_irqrestore(&pbd->ppb_lock, flags);
if (ret)
- pr_warn("Abort push_backup for ploop%d: found "
+ PL_WARN(plo, "Abort push_backup found "
"preq (clu=%d) in %s tree delayed for %u msecs\n",
- plo->index, clu, pbs->name,
- jiffies_to_msecs(jiffies - tstamp));
+ clu, pbs->name, jiffies_to_msecs(jiffies - tstamp));
return ret;
}
diff --git a/drivers/block/ploop/sysfs.c b/drivers/block/ploop/sysfs.c
index 0eaabcb72654..e27860810e27 100644
--- a/drivers/block/ploop/sysfs.c
+++ b/drivers/block/ploop/sysfs.c
@@ -358,7 +358,7 @@ static u32 show_aborted(struct ploop_device * plo)
static int store_aborted(struct ploop_device * plo, u32 val)
{
- pr_warn("ploop: Force %s aborted state for ploop%d\n",
+ PL_WARN(plo, "Force %s aborted state for ploop%d\n",
val ? "set" : "clear", plo->index);
if (val)
@@ -799,21 +799,21 @@ void ploop_sysfs_init(struct ploop_device * plo)
plo->pstat_dir = kobject_add_attr(plo->disk, "pstat", &pstat_ktype);
if (plo->pstat_dir) {
if (sysfs_create_group(plo->pstat_dir, &stats_group))
- pr_warn("ploop: were not able to create pstat dir\n");
+ PL_WARN(plo, "were not able to create pstat dir\n");
}
plo->pstate_dir = kobject_add_attr(plo->disk, "pstate", &pattr_ktype);
if (plo->pstate_dir) {
if (sysfs_create_group(plo->pstate_dir, &state_group))
- pr_warn("ploop: were not able to create pstate dir\n");
+ PL_WARN(plo, "were not able to create pstate dir\n");
}
plo->ptune_dir = kobject_add_attr(plo->disk, "ptune", &pattr_ktype);
if (plo->ptune_dir) {
if (sysfs_create_group(plo->ptune_dir, &tune_group))
- pr_warn("ploop: were not able to create ptune dir\n");
+ PL_WARN(plo, "were not able to create ptune dir\n");
}
if (kobject_add(&plo->kobj, kobject_get(&disk_to_dev(plo->disk)->kobj), "%s", "pdelta"))
- pr_warn("ploop: were not able to create pdelta dir\n");
+ PL_WARN(plo, "were not able to create pdelta dir\n");
}
void ploop_sysfs_uninit(struct ploop_device * plo)
diff --git a/include/linux/ploop/ploop.h b/include/linux/ploop/ploop.h
index d0f665796a42..8abd7d5217f0 100644
--- a/include/linux/ploop/ploop.h
+++ b/include/linux/ploop/ploop.h
@@ -983,4 +983,10 @@ extern void ploop_msg_once(struct ploop_device *plo, const char *, ...)
#define __TRACE(a...) do { } while (0)
#endif
+#define PL_FMT(fmt) "ploop%d: " fmt
+#define PL_DEV_IDX(plo) (plo ? plo->index : 0)
+#define PL_ERR(plo, fmt, ...) pr_err(PL_FMT(fmt), PL_DEV_IDX(plo), ##__VA_ARGS__)
+#define PL_INFO(plo, fmt, ...) pr_info(PL_FMT(fmt), PL_DEV_IDX(plo), ##__VA_ARGS__)
+#define PL_WARN(plo, fmt, ...) pr_warn(PL_FMT(fmt), PL_DEV_IDX(plo), ##__VA_ARGS__)
+
#endif /* _LINUX_PLOOP_H_ */
--
2.31.1
More information about the Devel
mailing list