[Devel] [PATCH 2/2] dm-ploop: refactor dm target status callback
Alexander Mikhalitsyn
alexander.mikhalitsyn at virtuozzo.com
Wed Jun 8 01:14:43 MSK 2022
After 91ccbbac17 ("dm ima: measure data on table load") a new STATUSTYPE_IMA was introduced.
For qcow2 it triggered compile time warning:
warning: drivers/md/dm-qcow2-target.c:897:9: warning: enumeration value ‘STATUSTYPE_IMA’ not handled in switch [-Wswitch]
but for dm-ploop is not. That's because we have no switch operator in status callback implementation there.
That's not perfect, it's better to have all status_type_t enum cases handled explicitly.
This patch changes behavior. Now for STATUSTYPE_INFO we always return nothing, and for STATUSTYPE_TABLE
we returing some data. This not breaks anything because we have no usage of this ioctl(DM_IOCTL) in our userspace.
https://jira.sw.ru/browse/PSBM-140279
Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn at virtuozzo.com>
---
drivers/md/dm-ploop-target.c | 41 +++++++++++++++++++++++-------------
1 file changed, 26 insertions(+), 15 deletions(-)
diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c
index b4607d2bab65..d7cc2fbba537 100644
--- a/drivers/md/dm-ploop-target.c
+++ b/drivers/md/dm-ploop-target.c
@@ -452,22 +452,33 @@ static void ploop_status(struct dm_target *ti, status_type_t type,
char stat[32], *p = stat;
ssize_t sz = 0;
- down_read(&ploop->ctl_rwsem);
- if (ploop->falloc_new_clu)
- *p++ = 'f';
- if (READ_ONCE(ploop->noresume))
- *p++ = 'n';
- if (READ_ONCE(ploop->event_enospc))
- *p++ = 's';
- if (p == stat)
- *p++ = 'o';
- if (ploop->skip_off)
- p += sprintf(p, " off=%llu", ploop->skip_off);
- *p++ = '\0';
- up_read(&ploop->ctl_rwsem);
+ switch (type) {
+ case STATUSTYPE_INFO:
+ result[0] = '\0';
+ break;
+ case STATUSTYPE_TABLE:
+ down_read(&ploop->ctl_rwsem);
+ if (ploop->falloc_new_clu)
+ *p++ = 'f';
+ if (READ_ONCE(ploop->noresume))
+ *p++ = 'n';
+ if (READ_ONCE(ploop->event_enospc))
+ *p++ = 's';
+ if (p == stat)
+ *p++ = 'o';
+ if (ploop->skip_off)
+ p += sprintf(p, " off=%llu", ploop->skip_off);
+ *p++ = '\0';
+ up_read(&ploop->ctl_rwsem);
+
+ BUG_ON(p - stat >= sizeof(stat));
+ DMEMIT("%u v2 %u %s", ploop->nr_deltas, (u32)CLU_TO_SEC(ploop, 1), stat);
- BUG_ON(p - stat >= sizeof(stat));
- DMEMIT("%u v2 %u %s", ploop->nr_deltas, (u32)CLU_TO_SEC(ploop, 1), stat);
+ break;
+ case STATUSTYPE_IMA:
+ result[0] = '\0';
+ break;
+ }
}
static void ploop_set_wants_suspend(struct dm_target *ti, bool wants)
--
2.36.1
More information about the Devel
mailing list