From: <tang.junhui@zte.com.cn>
To: mwilck@suse.com
Cc: dm-devel@redhat.com
Subject: Re: [PATCH] uevent_can_discard: optimize devpath check
Date: Thu, 2 Mar 2017 16:35:34 +0800 (CST) [thread overview]
Message-ID: <201703021635342010121@zte.com.cn> (raw)
[-- Attachment #1.1.1: Type: text/plain, Size: 2302 bytes --]
It looks fine to me.
Regards,
Tang Junhui
> This uses roughly 10% cycles of the sscanf-based implementation.
>
> Improves: ee8888f0 "multipath-tools: improve processing efficiency..."
> Signed-off-by: Martin Wilck <mwilck@suse.com>
> ---
> libmultipath/uevent.c | 37 +++++++++++++++++++++++--------------
> 1 file changed, 23 insertions(+), 14 deletions(-)
>
> diff --git a/libmultipath/uevent.c b/libmultipath/uevent.c
> index 6e2527bd..367e129a 100644
> --- a/libmultipath/uevent.c
> +++ b/libmultipath/uevent.c
> @@ -143,26 +143,35 @@ uevent_need_merge(void)
> return need_merge
> }
>
> +static bool
> +uevent_can_discard_by_devpath(const char *devpath)
> +{
> + static const char BLOCK[] = "/block/"
> + const char *tmp = strstr(devpath, BLOCK)
> +
> + if (tmp == NULL) {
> + condlog(4, "no /block/ in '%s'", devpath)
> + return true
> + }
> + tmp += sizeof(BLOCK) - 1
> + if (*tmp == '\0')
> + /* just ".../block/" - discard */
> + return true
> + /*
> + * If there are more path elements after ".../block/xyz",
> + * it's a partition - discard it but don't discard ".../block/sda/".
> + */
> + tmp = strchr(tmp, '/')
> + return tmp != NULL && *(tmp + 1) != '\0'
> +}
> +
> bool
> uevent_can_discard(struct uevent *uev)
> {
> - char *tmp
> - char a[11], b[11]
> struct config * conf
>
> - /*
> - * keep only block devices, discard partitions
> - */
> - tmp = strstr(uev->devpath, "/block/")
> - if (tmp == NULL){
> - condlog(4, "no /block/ in '%s'", uev->devpath)
> + if (uevent_can_discard_by_devpath(uev->devpath))
> return true
> - }
> - if (sscanf(tmp, "/block/%10s", a) != 1 ||
> - sscanf(tmp, "/block/%10[^/]/%10s", a, b) == 2) {
> - condlog(4, "discard event on %s", uev->devpath)
> - return true
> - }
>
> /*
> * do not filter dm devices by devnode
> --
> 2.12.0
[-- Attachment #1.1.2: Type: text/html , Size: 3315 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
next reply other threads:[~2017-03-02 8:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-02 8:35 tang.junhui [this message]
-- strict thread matches above, loose matches on Subject: below --
2017-03-01 17:22 [PATCH] uevent_can_discard: optimize devpath check Martin Wilck
2017-03-16 6:42 ` Christophe Varoqui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201703021635342010121@zte.com.cn \
--to=tang.junhui@zte.com.cn \
--cc=dm-devel@redhat.com \
--cc=mwilck@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox