From patchwork Wed Feb 7 19:41:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Lyle X-Patchwork-Id: 10205901 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 45A43602D8 for ; Wed, 7 Feb 2018 19:42:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 359EB290F6 for ; Wed, 7 Feb 2018 19:42:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A5A829104; Wed, 7 Feb 2018 19:42:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0040290F6 for ; Wed, 7 Feb 2018 19:42:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754495AbeBGTmK (ORCPT ); Wed, 7 Feb 2018 14:42:10 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:39714 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754453AbeBGTmG (ORCPT ); Wed, 7 Feb 2018 14:42:06 -0500 Received: by mail-pg0-f65.google.com with SMTP id w17so696409pgv.6 for ; Wed, 07 Feb 2018 11:42:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lyle-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8828wevQFPlL6tInuOJ5T0LxLTzyfIkvEbrty7GMiok=; b=rOtYO+V2+pPjdOopspZu57KyVjjXjWXh0+ZNjVrsQOvriok3RfX1BR4fAjtwxWe+KS qqIoULi/5UUn1k1NMYuLDsgA48mgw/yTP4szXstKYr2cePMXKRvNyUUVFh2AH3GpUx2K BekJ+xOKAgyI6IshxMeYOnnqwBywakAurmnzOoBBtuo+avqKN6y5fMpdloN03TVuGwtM +1NLqN/u0SLuJ3PHmIEUm97lWMEoZLM4sO7FPi40LZfCKGzp6BbeE5DRx6znlCYgdbg9 W8G6Pcd18s8OHJ1F/y96vi/pr6eFSIVAQ0UDi4qFthc0lcDIEVgnf3BxWgkAsf5BhBmH Ab3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8828wevQFPlL6tInuOJ5T0LxLTzyfIkvEbrty7GMiok=; b=bC+nwHD9MF0kt/Qoz7c4QwQUh0OY7vI/dCg5biPJGsNRP8rDTDWvEh7aRLl64e3F3Y Yf+hV0SnfD68YUqBwArGAcLmibV5Upf+dFmGZAzyQLzzDOAiVlVBPu15sIyhHNWxXa8Q XYNasMMdy0cwaCDlCrOhyanPwHj72EfuyKs7dbnqMS7rlgx7FCNMSI3h85ktvRgtoUda 7Nh02xupJqCva6B8H0eqU2nZvCNFWUHJKZ/8vwFFdr8nnEb/jFUNhc+7f7YWzjSGLnq/ cuEuj17/S/e3bXQwC81zLDIYdOjuvI4t9GM8HVAbx8d9kADbbCOV2iNggOdbEIvNbJNO QrKA== X-Gm-Message-State: APf1xPBnfwRHU9BLFPMGPVnNxelgZMDYI+4wQebRNQtOoh59Ff878at7 rOlGHJ/Bq77edaYS6j2M5SRYMw== X-Google-Smtp-Source: AH8x227jjJugmDbJpvttDPQWKIAR0cMdV9g0PX8HnyosnrhsYifZ6KuAJah6AMQWDQC2fMWV565XsQ== X-Received: by 10.99.125.72 with SMTP id m8mr5806548pgn.146.1518032525565; Wed, 07 Feb 2018 11:42:05 -0800 (PST) Received: from midnight.lan (2600-6c52-6200-09b7-0000-0000-0000-0d66.dhcp6.chtrptr.net. [2600:6c52:6200:9b7::d66]) by smtp.gmail.com with ESMTPSA id q24sm6136554pgn.46.2018.02.07.11.42.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Feb 2018 11:42:04 -0800 (PST) From: Michael Lyle To: linux-bcache@vger.kernel.org, linux-block@vger.kernel.org Cc: axboe@fb.com, Tang Junhui Subject: [PATCH 7/8] bcache: return attach error when no cache set exist Date: Wed, 7 Feb 2018 11:41:45 -0800 Message-Id: <20180207194146.5095-8-mlyle@lyle.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180207194146.5095-1-mlyle@lyle.org> References: <20180207194146.5095-1-mlyle@lyle.org> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tang Junhui I attach a back-end device to a cache set, and the cache set is not registered yet, this back-end device did not attach successfully, and no error returned: [root]# echo 87859280-fec6-4bcc-20df7ca8f86b > /sys/block/sde/bcache/attach [root]# In sysfs_attach(), the return value "v" is initialized to "size" in the beginning, and if no cache set exist in bch_cache_sets, the "v" value would not change any more, and return to sysfs, sysfs regard it as success since the "size" is a positive number. This patch fixes this issue by assigning "v" with "-ENOENT" in the initialization. Signed-off-by: Tang Junhui Reviewed-by: Michael Lyle --- drivers/md/bcache/sysfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c index 4a6a697e1680..a7552f509f50 100644 --- a/drivers/md/bcache/sysfs.c +++ b/drivers/md/bcache/sysfs.c @@ -198,7 +198,7 @@ STORE(__cached_dev) { struct cached_dev *dc = container_of(kobj, struct cached_dev, disk.kobj); - ssize_t v = size; + ssize_t v; struct cache_set *c; struct kobj_uevent_env *env; @@ -275,6 +275,7 @@ STORE(__cached_dev) if (bch_parse_uuid(buf, dc->sb.set_uuid) < 16) return -EINVAL; + v = -ENOENT; list_for_each_entry(c, &bch_cache_sets, list) { v = bch_cached_dev_attach(dc, c); if (!v) @@ -282,7 +283,7 @@ STORE(__cached_dev) } pr_err("Can't attach %s: cache set not found", buf); - size = v; + return v; } if (attr == &sysfs_detach && dc->disk.c)