Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2177780imm; Mon, 28 May 2018 03:18:41 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoHrySNy6Rsx+u+b5P1sYD9JydwjosFxhu65rgYqs5BPEcy1BWcLsfTqo8E9MBWoBJXcBoX X-Received: by 2002:a17:902:264:: with SMTP id 91-v6mr12912334plc.341.1527502721876; Mon, 28 May 2018 03:18:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527502721; cv=none; d=google.com; s=arc-20160816; b=c0e6GeeAZJnO7gOs20UefxLekjN/0l6TWSgV+UzfykFKm5u2AplEy5CD3WQkrKLk4l 5/91C2mz5uEJ6H08vwHj7VdFud0CwjugGssboHD0DHeI/HISEz3jvlw/wrutiimVM1WR uX7zPPx1zFry+1bD9yavuA4ckWmgLtPJgYX85iuuPlN4aYdLLSNFKmpBvUmhh5cAYpyr XaXVbo0ijGlTYxqhgKIjjdTNRgC4B/uoGrjUAITEjDyahDiXOLrg0x51Lb62NJ7QWyl3 eR8itICtcIbR0jChZQv7vNvv+KJ7TWinyYge8X1js6GHW3s+j+eEECRZI6jhhbZbMmM1 SRWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=7RBPzVWMn1Sa8R8M/0F1MrK19uGD7MfrVomig8++who=; b=JGEAKLl/IXZWc7nt2L9tmsWoxge+iYdVJWDiPC3ou6THB/NkC+KtzIdLIBZ5Zbqjxz PYCmkINhEMWR1Xp7PQtHk13F9/gQeq9LR0O9C4WASM0Axs1NgKfCyOQY/9WwXjAGfEKJ IFGdp6Y28bm2wllhF9PI3Y6KeIQr5EZihZMHiPLrdWrJzX8zYg3KKRxV2Qx9t3TxQhB3 2cOx73MiDc40MzpLq7p8Fds4/MDFzEIXuFyZvt1c2ocf/7Uu0Ucj3fjW2lK0SNkInmon aN7PjBfc9iPqyIUZ2t1mmSkpWGYoXgVGGrPZRUM4ANNG1sxFT3TdJv9gcJTcY6KOwlbY Te1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mhQ03sTh; 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 h77-v6si2807939pfa.238.2018.05.28.03.18.27; Mon, 28 May 2018 03:18:41 -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; dkim=pass header.i=@kernel.org header.s=default header.b=mhQ03sTh; 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 S968650AbeE1KRK (ORCPT + 99 others); Mon, 28 May 2018 06:17:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:37204 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966943AbeE1KRD (ORCPT ); Mon, 28 May 2018 06:17:03 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3C305206B7; Mon, 28 May 2018 10:17:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527502622; bh=ZoYt7zbDJLofBuj4wN+shvkPUDAKFfOYG2JxVkGIDxk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mhQ03sTh/Qrg7pYKBepqrLuO7aXfeQzX/eNyucsNlRPWq++IESHUNzMweYJJl8lx2 SSuQQNQCRWRBO9kZYzRkU++CdamqQIc2X3UHWmkXDdnkRD/yCWOpYZyH3zaNKcXtwM VBu/VXvVhUOwUtQgDhOC7vkFEqYni/maznbIL2o0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tang Junhui , Michael Lyle , Jens Axboe , Sasha Levin Subject: [PATCH 4.4 068/268] bcache: return attach error when no cache set exist Date: Mon, 28 May 2018 12:00:42 +0200 Message-Id: <20180528100209.580998816@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100202.045206534@linuxfoundation.org> References: <20180528100202.045206534@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tang Junhui [ Upstream commit 7f4fc93d4713394ee8f1cd44c238e046e11b4f15 ] 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 Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/md/bcache/sysfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/drivers/md/bcache/sysfs.c +++ b/drivers/md/bcache/sysfs.c @@ -191,7 +191,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; @@ -268,6 +268,7 @@ STORE(__cached_dev) if (bch_parse_uuid(buf, set_uuid) < 16) return -EINVAL; + v = -ENOENT; list_for_each_entry(c, &bch_cache_sets, list) { v = bch_cached_dev_attach(dc, c, set_uuid); if (!v) @@ -275,7 +276,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)