Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp569974imm; Fri, 14 Sep 2018 03:02:27 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ+4a/veROnrb7aWcgEQyfG71qp7CVO1mh/glk9/GJfWwfizE0K9YkZG0p9I64mR8rF7g5k X-Received: by 2002:a17:902:b902:: with SMTP id bf2-v6mr11501977plb.185.1536919347187; Fri, 14 Sep 2018 03:02:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536919347; cv=none; d=google.com; s=arc-20160816; b=poaufFjTtXSB9yHxyFCDwjFaI52TgcWrfjDkI6QOQaIqrkJYKmXDzjhq+urKrLPTGd fJpBB14z/461GelJH92q1/RkIVS56Zd8AaVBSWIo7DxVJL7gJKVxNUUnDuzU8nQPuoSO 5sNRrsHooQtVEkRq8D0JUwwSudsWt/X3Ur9c5x7AeeWWOtdhn7PYrPYr4S/dt+oRdv/z fkbOghNcmoT/fDEBtVB2NYtLQ9pOhbwTadYl809Z3sjmHjzHvwZZ8MK/7AuG4jH/zyIa kYLMMq7+44AWFtJBeUCcL8iqRsQ9Ned1YypIeXU/R+nxtB32WKTpcpcz11sm9x+xFOa3 7AbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=e4pWO4dzqajRXWSzjOSixuAjGArvdw4a5oVb90z4chs=; b=lc8K8T81MfVSvSZ+YiWyo9u1PDz86zopjenzhShpg1ZgozjraeOQeAfgD12g1l1QNe EQcC0EzoYA/FpXDzVYgQhBEwCZybfIXMOKVZrhHy9siTmfeyO6kUewSVnU6ENeCIjq+b x56RINl2sWLhn9HhViRzegnQRYw7bBaFmSiRVlfWunvQtCmKKE8h4HKop/rcC97lxQUB r5qAXdFNfTy6mHwg03FYApzeMuQrVOmtTqPGM1zqYD6ABqFmvmxD/KqdNpMM6nbkGUOg rANfx6wNvz+2IrQs982E8iZWbkXyjVJ0/CLplVECfiYRiP3/PmFkpaANg5zhcTp49r2O TXdw== 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 s36-v6si6746173pld.8.2018.09.14.03.02.11; Fri, 14 Sep 2018 03:02:27 -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 S1728096AbeINPOZ (ORCPT + 99 others); Fri, 14 Sep 2018 11:14:25 -0400 Received: from mx2.suse.de ([195.135.220.15]:39670 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726868AbeINPOY (ORCPT ); Fri, 14 Sep 2018 11:14:24 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id C22F2AE66; Fri, 14 Sep 2018 10:00:37 +0000 (UTC) Subject: Re: [PATCH] add label interface for cache device in sysfs To: Dongbo Cao Cc: kent.overstreet@gmail.com, linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180914095120.2699-1-cdbdyx@163.com> From: Coly Li Message-ID: Date: Fri, 14 Sep 2018 18:00:37 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <20180914095120.2699-1-cdbdyx@163.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/14/18 5:51 PM, Dongbo Cao wrote: > label interface will be called by bcache tools in user space. > > Signed-off-by: Dongbo Cao Hi Dongbo, In your change I see you set superblock label to cache set. What is the use case for doing this ? Thanks. Coly Li > --- > drivers/md/bcache/sysfs.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c > index 225b15aa..e64c718f 100644 > --- a/drivers/md/bcache/sysfs.c > +++ b/drivers/md/bcache/sysfs.c > @@ -950,6 +950,13 @@ SHOW(__bch_cache) > return ret; > } > > + if (attr == &sysfs_label) { > + memcpy(buf, ca->sb.label, SB_LABEL_SIZE); > + buf[SB_LABEL_SIZE + 1] = '\0'; > + strcat(buf, "\n"); > + return strlen(buf); > + } > + > return 0; > } > SHOW_LOCKED(bch_cache) > @@ -993,6 +1000,17 @@ STORE(__bch_cache) > atomic_set(&ca->io_errors, 0); > } > > + if (attr == &sysfs_label) { > + if (size > SB_LABEL_SIZE) > + return -EINVAL; > + memcpy(ca->sb.label, buf, size); > + if (size < SB_LABEL_SIZE) > + ca->sb.label[size] = '\0'; > + if (size && ca->sb.label[size - 1] == '\n') > + ca->sb.label[size - 1] = '\0'; > + bcache_write_super(ca->set); > + } > + > return size; > } > STORE_LOCKED(bch_cache) > @@ -1009,6 +1027,7 @@ static struct attribute *bch_cache_files[] = { > &sysfs_io_errors, > &sysfs_clear_stats, > &sysfs_cache_replacement_policy, > + &sysfs_label, > NULL > }; > KTYPE(bch_cache);