[Devel] [PATCH RHEL9 COMMIT] ploop: simplify ploop_status
Konstantin Khorenko
khorenko at virtuozzo.com
Tue Oct 26 20:33:19 MSK 2021
The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-4.vz9.10.17
------>
commit 31f8f226e2d73defb45dafff9cb69f6d6752a344
Author: Cyrill Gorcunov <gorcunov at gmail.com>
Date: Tue Oct 26 20:33:18 2021 +0300
ploop: simplify ploop_status
We can get rid of sprintf usage when encoding the status.
Just fill the string directly.
Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
Acked-by: Kirill TKhai <ktkhai at virtuozzo.com>
---
drivers/md/dm-ploop-target.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c
index bd68d5fb272b..0d693ccd387d 100644
--- a/drivers/md/dm-ploop-target.c
+++ b/drivers/md/dm-ploop-target.c
@@ -445,22 +445,23 @@ static void ploop_status(struct dm_target *ti, status_type_t type,
unsigned int maxlen)
{
struct ploop *ploop = ti->private;
- char stat[32] = { 0 }, *p = stat;
+ char stat[32], *p = stat;
ssize_t sz = 0;
down_read(&ploop->ctl_rwsem);
if (ploop->falloc_new_clu)
- p += sprintf(p, "f");
+ *p++ = 'f';
if (ploop->tracking_bitmap)
- p += sprintf(p, "t");
+ *p++ = 't';
if (READ_ONCE(ploop->noresume))
- p += sprintf(p, "n");
+ *p++ = 'n';
if (READ_ONCE(ploop->event_enospc))
- p += sprintf(p, "s");
+ *p++ = 's';
if (p == stat)
- p += sprintf(p, "o");
+ *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));
More information about the Devel
mailing list