Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp174662imm; Thu, 31 May 2018 21:38:40 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLEMk7OgDZWBI/PfQ43S2CT1yj3DGba3wURtbuaBZRq91fY4TGlC1FpRUK7Dm1eJPpEmm1u X-Received: by 2002:a62:1282:: with SMTP id 2-v6mr9444184pfs.243.1527827920377; Thu, 31 May 2018 21:38:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527827920; cv=none; d=google.com; s=arc-20160816; b=Q6iR7YmZc5/3ypl5EyIzPfp7RYOJ+UE5LkBBbLxShZf+nRFc9b40+2xHTCLWZwUVG5 2QM/OnyMpvG2SqtdIjvH/9EGFby2FPBseiTy6TiSebwAHR2qlZmeti1IogvPqpIxm9ae zKNw1VXApB//m7mrLOmIVdQvCHY7wNDqkdO6GCuqS1QEaYAH9juxAcmjVBUXDfVJwC1b hmedbwMNWwq+pPvMxLed5ob87rC13NkS+xAQcVvHp6vnS+roUI6LxRaMQc5GDvHqhMdX yzGA1J+6JL2bVqbe7P0sH8MTEwdFO+/4AlizE9w9kevknp3wrgDWJB4sTyTwks+wpiiO 7iSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=7ZcddddTp7DZQhi2MjSfoK27+ZDflIxRNEkbe9Os6uE=; b=L/3JNCRvJZebXxO5An1BFmhU2AIA+mSNQ+/5XWNWunUjgu8KOd7N36fEMedsPtTP9Z MryRdx+4BuQgsftsHJHjFjug4RcntR4nrwu2jqKA5sArVeMlnGJ0ywadmIGfj5C/6z8G NEloOcfeQrNuLgIk1YDJrmAXQ/kTmL1ClIDUNtW4sy2zmNjxNkyCZ3/fNQWBYhIQMq2Q g3qkaAp/HWRupc9ZbzrWG+52lonnEMDF1PldIrnfuRN6q5DQti4n9T2NT/048OUzL+Le eMxjZbP32AlAKoght4eCixywME4CzS9j+CgCP9VZGqH8B0NHMvIQe5l5x0VDchrjxFCp GKtw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p5-v6si36657966plk.537.2018.05.31.21.38.14; Thu, 31 May 2018 21:38:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750850AbeFAEgi (ORCPT + 99 others); Fri, 1 Jun 2018 00:36:38 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8246 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750738AbeFAEgh (ORCPT ); Fri, 1 Jun 2018 00:36:37 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 2C6423499A353; Fri, 1 Jun 2018 12:36:21 +0800 (CST) Received: from [127.0.0.1] (10.177.29.40) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.382.0; Fri, 1 Jun 2018 12:36:20 +0800 Subject: Re: [PATCH v2 19/21] bcache: use match_string() helper To: Coly Li , References: <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com> <1527765086-19873-20-git-send-email-xieyisheng1@huawei.com> CC: , Kent Overstreet , From: Yisheng Xie Message-ID: <36b9f53d-66bd-076e-7c2e-045ca2fd4406@huawei.com> Date: Fri, 1 Jun 2018 12:32:00 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.29.40] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Coly, On 2018/6/1 11:45, Coly Li wrote: > On 2018/5/31 7:11 PM, Yisheng Xie wrote: >> match_string() returns the index of an array for a matching string, >> which can be used instead of open coded variant. >> >> Cc: Kent Overstreet >> Cc: linux-bcache@vger.kernel.org >> Signed-off-by: Yisheng Xie > > Hi Yishenng, > > Andy Shevchenko submitted a patch to > replace the whole bch_read_string_list() with __sysfs_match_string(). > And this patch is applied in Jens' block tree, will go into mainline > kernel in v4.18. > > If you search bcache mailing list, you may find a patch named with > "bcache: Replace bch_read_string_list() by __sysfs_match_string()". > > That means this patch will conflict with existing changes. Get it, and thanks for this information. Sorry Andy, for doing this once more. Thanks Yisheng > > Thanks. > > Coly Li > >> --- >> drivers/md/bcache/util.c | 9 ++------- >> 1 file changed, 2 insertions(+), 7 deletions(-) >> >> diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c >> index 74febd5..cd1f4fd 100644 >> --- a/drivers/md/bcache/util.c >> +++ b/drivers/md/bcache/util.c >> @@ -136,22 +136,17 @@ ssize_t bch_snprint_string_list(char *buf, size_t size, const char * const list[ >> >> ssize_t bch_read_string_list(const char *buf, const char * const list[]) >> { >> - size_t i; >> + ssize_t i; >> char *s, *d = kstrndup(buf, PAGE_SIZE - 1, GFP_KERNEL); >> if (!d) >> return -ENOMEM; >> >> s = strim(d); >> >> - for (i = 0; list[i]; i++) >> - if (!strcmp(list[i], s)) >> - break; >> + i = match_string(list, -1, s); >> >> kfree(d); >> >> - if (!list[i]) >> - return -EINVAL; >> - >> return i; >> } >> >> > > >