<div class="zcontentRow"> <p>It  looks fine to me.</p><p><br></p><p>Regards,</p><p>Tang Junhui</p><p><br></p><p>> This uses roughly 10% cycles of the sscanf-based implementation.</p><p>> </p><p>> Improves: ee8888f0 "multipath-tools: improve processing efficiency..."</p><p>> Signed-off-by: Martin Wilck <mwilck@suse.com></p><p>> ---</p><p>>  libmultipath/uevent.c | 37 +++++++++++++++++++++++--------------</p><p>>  1 file changed, 23 insertions(+), 14 deletions(-)</p><p>> </p><p>> diff --git a/libmultipath/uevent.c b/libmultipath/uevent.c</p><p>> index 6e2527bd..367e129a 100644</p><p>> --- a/libmultipath/uevent.c</p><p>> +++ b/libmultipath/uevent.c</p><p>> @@ -143,26 +143,35 @@ uevent_need_merge(void)</p><p>>      return need_merge;</p><p>>  }</p><p>>  </p><p>> +static bool</p><p>> +uevent_can_discard_by_devpath(const char *devpath)</p><p>> +{</p><p>> +    static const char BLOCK[] = "/block/";</p><p>> +    const char *tmp = strstr(devpath, BLOCK);</p><p>> +</p><p>> +    if (tmp == NULL) {</p><p>> +        condlog(4, "no /block/ in '%s'", devpath);</p><p>> +        return true;</p><p>> +    }</p><p>> +    tmp += sizeof(BLOCK) - 1;</p><p>> +    if (*tmp == '\0')</p><p>> +        /* just ".../block/" - discard */</p><p>> +        return true;</p><p>> +    /*</p><p>> +     * If there are more path elements after ".../block/xyz",</p><p>> +     * it's a partition - discard it; but don't discard ".../block/sda/".</p><p>> +     */</p><p>> +    tmp = strchr(tmp, '/');</p><p>> +    return tmp != NULL && *(tmp + 1) != '\0';</p><p>> +}</p><p>> +</p><p>>  bool</p><p>>  uevent_can_discard(struct uevent *uev)</p><p>>  {</p><p>> -    char *tmp;</p><p>> -    char a[11], b[11];</p><p>>      struct config * conf;</p><p>>  </p><p>> -    /*</p><p>> -     * keep only block devices, discard partitions</p><p>> -     */</p><p>> -    tmp = strstr(uev->devpath, "/block/");</p><p>> -    if (tmp == NULL){</p><p>> -        condlog(4, "no /block/ in '%s'", uev->devpath);</p><p>> +    if (uevent_can_discard_by_devpath(uev->devpath))</p><p>>          return true;</p><p>> -    }</p><p>> -    if (sscanf(tmp, "/block/%10s", a) != 1 ||</p><p>> -        sscanf(tmp, "/block/%10[^/]/%10s", a, b) == 2) {</p><p>> -        condlog(4, "discard event on %s", uev->devpath);</p><p>> -        return true;</p><p>> -    }</p><p>>  </p><p>>      /* </p><p>>       * do not filter dm devices by devnode</p><p>> -- </p><p>> 2.12.0</p><p><br></p><p><br></p><div><div class="zhistoryRow" style="display:block"><div id="zwriteHistoryContainer"><div class="control-group zhistoryPanel"><p><br></p></div></div></div></div><p><br></p> </div>