From 28d082dd4654cb35f336ab89d3fe1f360c780a8d Mon Sep 17 00:00:00 2001 From: Tomohiro Kusumi Date: Sun, 9 Oct 2016 18:22:18 +0900 Subject: [PATCH] sys/dev/disk/dm: Make dmdebug() print __func__ and fix/remove dmdebug calls that could be cleaned up or simplified. --- sys/dev/disk/dm/device-mapper.c | 15 ++++++--------- sys/dev/disk/dm/dm.h | 2 +- sys/dev/disk/dm/dm_ioctl.c | 11 ++++------- sys/dev/disk/dm/dm_pdev.c | 11 +++++------ sys/dev/disk/dm/dm_table.c | 2 +- sys/dev/disk/dm/targets/flakey/dm_target_flakey.c | 7 +++---- .../disk/dm/targets/striped/dm_target_striped.c | 3 +-- 7 files changed, 21 insertions(+), 30 deletions(-) diff --git a/sys/dev/disk/dm/device-mapper.c b/sys/dev/disk/dm/device-mapper.c index ff055fd379..85c4d3e0b1 100644 --- a/sys/dev/disk/dm/device-mapper.c +++ b/sys/dev/disk/dm/device-mapper.c @@ -213,8 +213,7 @@ dmopen(struct dev_open_args *ap) dmv->is_open = 1; dm_dev_unbusy(dmv); - dmdebug("dm open routine called %" PRIu32 "\n", - minor(ap->a_head.a_dev)); + dmdebug("minor=%" PRIu32 "\n", minor(ap->a_head.a_dev)); return 0; } @@ -234,8 +233,7 @@ dmclose(struct dev_close_args *ap) dmv->is_open = 0; dm_dev_unbusy(dmv); - dmdebug("dm close routine called %" PRIu32 "\n", - minor(ap->a_head.a_dev)); + dmdebug("minor=%" PRIu32 "\n", minor(ap->a_head.a_dev)); return 0; } @@ -252,8 +250,6 @@ dmioctl(struct dev_ioctl_args *ap) prop_dictionary_t dm_dict_in; err = r = 0; - - dmdebug("dmioctl called\n"); KKASSERT(data != NULL); if ((r = disk_ioctl_switch(dev, cmd, data)) != ENOTTY) @@ -321,10 +317,10 @@ dm_ioctl_switch(u_long cmd) switch(cmd) { case NETBSD_DM_IOCTL: - dmdebug("dm NETBSD_DM_IOCTL called\n"); + dmdebug("NETBSD_DM_IOCTL called\n"); break; default: - dmdebug("dm unknown ioctl called\n"); + dmdebug("Unknown ioctl %lu called\n", cmd); return ENOTTY; break; /* NOT REACHED */ } @@ -362,10 +358,11 @@ disk_ioctl_switch(cdev_t dev, u_long cmd, void *data) dpart->media_blksize = DEV_BSIZE; dpart->fstype = FS_BSDFFS; } + dmdebug("DIOCGPART called\n"); break; default: - dmdebug("unknown disk_ioctl called\n"); + dmdebug("Unknown disk ioctl %lu called\n", cmd); return ENOTTY; break; /* NOT REACHED */ } diff --git a/sys/dev/disk/dm/dm.h b/sys/dev/disk/dm/dm.h index 396ec8567b..69cddc1385 100644 --- a/sys/dev/disk/dm/dm.h +++ b/sys/dev/disk/dm/dm.h @@ -274,7 +274,7 @@ int dm_pdev_init(void); int dm_pdev_uninit(void); #define dmdebug(format, ...) \ - do { if (dm_debug_level) kprintf(format, ## __VA_ARGS__); } while(0) + do { if (dm_debug_level) kprintf("%s: "format, __func__, ## __VA_ARGS__); } while(0) #define DM_TARGET_MODULE(name, evh) \ static moduledata_t name##_mod = { \ diff --git a/sys/dev/disk/dm/dm_ioctl.c b/sys/dev/disk/dm/dm_ioctl.c index 4b42288305..d692712465 100644 --- a/sys/dev/disk/dm/dm_ioctl.c +++ b/sys/dev/disk/dm/dm_ioctl.c @@ -724,8 +724,6 @@ dm_table_load_ioctl(prop_dictionary_t dm_dict) dm_dbg_print_flags(dmv->flags); tbl = dm_table_get_entry(&dmv->table_head, DM_TABLE_INACTIVE); - dmdebug("dmv->name = %s\n", dmv->name); - prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor); while ((target_dict = prop_object_iterator_next(iter)) != NULL) { @@ -753,10 +751,9 @@ dm_table_load_ioctl(prop_dictionary_t dm_dict) prop_dictionary_get_uint64(target_dict, DM_TABLE_LENGTH, &table_en->length); - dmdebug("dm_ioctl.c... table_en->start = %ju, " - "table_en->length = %ju\n", - (uintmax_t)table_en->start, - (uintmax_t)table_en->length); + dmdebug("table_en->start = %ju, table_en->length = %ju\n", + (uintmax_t)table_en->start, + (uintmax_t)table_en->length); table_en->target = target; table_en->dev = dmv; @@ -780,7 +777,7 @@ dm_table_load_ioctl(prop_dictionary_t dm_dict) * therfore I have to pass it to target init * routine and parse parameters there. */ - dmdebug("DM: str passed in is: \"%s\"\n", str); + dmdebug("String passed in is: \"%s\"\n", str); if ((ret = dm_table_init(target, table_en, str)) != 0) { dm_table_release(&dmv->table_head, DM_TABLE_INACTIVE); diff --git a/sys/dev/disk/dm/dm_pdev.c b/sys/dev/disk/dm/dm_pdev.c index 5dfd7a01d6..e2bd2bd4d4 100644 --- a/sys/dev/disk/dm/dm_pdev.c +++ b/sys/dev/disk/dm/dm_pdev.c @@ -130,7 +130,7 @@ dm_pdev_insert(const char *dev_name) if (dmp != NULL) { dmp->ref_cnt++; - dmdebug("dmp_pdev_insert pdev %s already in tree\n", dev_name); + dmdebug("pdev %s already in tree\n", dev_name); lockmgr(&dm_pdev_mutex, LK_RELEASE); return dmp; } @@ -142,7 +142,7 @@ dm_pdev_insert(const char *dev_name) error = dm_dk_lookup(dev_name, &dmp->pdev_vnode); if (error) { - dmdebug("dk_lookup on device: %s failed with error %d!\n", + dmdebug("Lookup on %s failed with error %d!\n", dev_name, error); dm_pdev_free(dmp); lockmgr(&dm_pdev_mutex, LK_RELEASE); @@ -151,7 +151,7 @@ dm_pdev_insert(const char *dev_name) dmp->ref_cnt = 1; if (dm_pdev_get_vattr(dmp, &va) == -1) { - dmdebug("makeudev %s failed\n", dev_name); + dmdebug("getattr on %s failed\n", dev_name); dm_pdev_free(dmp); lockmgr(&dm_pdev_mutex, LK_RELEASE); return NULL; @@ -169,8 +169,7 @@ dm_pdev_insert(const char *dev_name) (void *)&dmp->pdev_pinfo, 0, proc0.p_ucred, NULL, NULL); if (!error) { struct partinfo *dpart = &dmp->pdev_pinfo; - dmdebug("dmp_pdev_insert DIOCGPART " - "offset=%ju size=%ju blocks=%ju blksize=%d\n", + dmdebug("DIOCGPART offset=%ju size=%ju blocks=%ju blksize=%d\n", dpart->media_offset, dpart->media_size, dpart->media_blocks, @@ -182,7 +181,7 @@ dm_pdev_insert(const char *dev_name) TAILQ_INSERT_TAIL(&dm_pdev_list, dmp, next_pdev); lockmgr(&dm_pdev_mutex, LK_RELEASE); - dmdebug("dmp_pdev_insert pdev %s %s 0x%016jx\n", + dmdebug("pdev %s %s 0x%016jx\n", dmp->name, dmp->udev_name, (uintmax_t)dmp->udev); return dmp; diff --git a/sys/dev/disk/dm/dm_table.c b/sys/dev/disk/dm/dm_table.c index 2f13e3c63a..e18e70e94d 100644 --- a/sys/dev/disk/dm/dm_table.c +++ b/sys/dev/disk/dm/dm_table.c @@ -134,7 +134,7 @@ dm_table_destroy(dm_table_head_t *head, uint8_t table_id) lockmgr(&head->table_mtx, LK_EXCLUSIVE); - dmdebug("dm_table_destroy called with %d--%d\n", table_id, head->io_cnt); + dmdebug("table_id=%d io_cnt=%d\n", table_id, head->io_cnt); if (table_id == DM_TABLE_ACTIVE) id = head->cur_active_table; diff --git a/sys/dev/disk/dm/targets/flakey/dm_target_flakey.c b/sys/dev/disk/dm/targets/flakey/dm_target_flakey.c index e48c1b0397..480beb2b46 100644 --- a/sys/dev/disk/dm/targets/flakey/dm_target_flakey.c +++ b/sys/dev/disk/dm/targets/flakey/dm_target_flakey.c @@ -289,8 +289,8 @@ _flakey_write(dm_target_flakey_config_t *tfc, struct buf *bp) struct bio *bio = &bp->b_bio1; if (tfc->drop_writes) { - dmdebug("%s: bio=%p drop_writes offset=%ju\n", - __func__, bio, bio->bio_offset); + dmdebug("bio=%p drop_writes offset=%ju\n", + bio, bio->bio_offset); biodone(bio); return 0; } @@ -326,8 +326,7 @@ _flakey_corrupt_buf(dm_target_flakey_config_t *tfc, struct bio *bio) return 1; bp->b_data[tfc->corrupt_buf_byte - 1] = tfc->corrupt_buf_value; - dmdebug("%s: bio=%p dir=%c offset=%ju Nth=%u value=%u\n", - __func__, + dmdebug("bio=%p dir=%c offset=%ju Nth=%u value=%u\n", bio, FLAKEY_CORRUPT_DIR(tfc), bio->bio_offset, diff --git a/sys/dev/disk/dm/targets/striped/dm_target_striped.c b/sys/dev/disk/dm/targets/striped/dm_target_striped.c index a0c147ae92..d78dc3e07a 100644 --- a/sys/dev/disk/dm/targets/striped/dm_target_striped.c +++ b/sys/dev/disk/dm/targets/striped/dm_target_striped.c @@ -247,8 +247,7 @@ dm_target_stripe_iodone(struct bio *bio) KKASSERT(devnr < MAX_STRIPES); tsc->stripe_devs[devnr].num_error++; - dmdebug("stripe_iodone: device=%d error=%d\n", - devnr, bp->b_error); + dmdebug("device=%d error=%d\n", devnr, bp->b_error); } obio = pop_bio(bio); -- 2.41.0