Received: by 10.213.65.68 with SMTP id h4csp2118931imn; Sun, 8 Apr 2018 20:10:26 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/qz9PEcQDh9wYxAqSopUoBsTi5nDyj3pguy3ljXhSONz7KExxcElFgV0RfG4Cgc2XTYJt+ X-Received: by 10.99.61.202 with SMTP id k193mr23876994pga.435.1523243426255; Sun, 08 Apr 2018 20:10:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243426; cv=none; d=google.com; s=arc-20160816; b=hkMWd4aSRgBj6D5FzHhr+845vV9qBqiqb39ogYw4UZL2EQS53prCwt1VtRPSv2QE5S R1alpfwx3BsUYcep0IPcfqsYVpm30FundhOKAwVETqzQOYsWgw4FzD76r2VrkP09yMs5 2Y2sYl6OALcokzPYvr43DasPMRe07enMidMoPFW2eLlWuohV4Ar4YOcSjMxonWZiGGBm jZbslWBZElSpEWooP6NBJ/pFyQ4AaTR6xbjjSLGhPJui4+ypjDtIRRlIgIlp/I+qrsP6 qAtdBrJ3WJGk2K2CCgImNaFUmMbyWBKVAaHgp9Sd7oS2BoA429auMzzCiXnljz2Gu6BU bHPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=wCF5xedl4bk9Kp7ZNoXBnhr0mw8rHfU3HqTN0oToiec=; b=LQOeRHEsBr6EK24FHWP2jgCwY/g3tiZZ6W8QF4trGRtaYLJXvESHNb7XL6VCYkcSLt vBMk11GdL+K6HqDGZDW9497BR+f9qnUiBgnHDNA3Xl6uCA73WnHbPl5CeNqlZI1j8je1 v5LDxu4eTvCixcphuvr+FVl7Je2TAbeNDETMrwwTQ45S+Ci6mboPQnzVQJ9ixnmvFfGe 3SG/+ey4GZHD1Ht/EPrsLbmXjvQEkKKd+9ZLgr07UY4mJE93tip1ZI4QGUjdtr3f/+fu xIEHtWGN/eqv+iVpQpE0G9UEy6bqnAw+XP/xsnp1B56yZh7ujavjOWpepelK9OlDSAnl Iu7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=EvRBIoxk; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 73-v6si16539286plf.286.2018.04.08.20.09.49; Sun, 08 Apr 2018 20:10:26 -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=@microsoft.com header.s=selector1 header.b=EvRBIoxk; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932966AbeDIBnO (ORCPT + 99 others); Sun, 8 Apr 2018 21:43:14 -0400 Received: from mail-by2nam01on0123.outbound.protection.outlook.com ([104.47.34.123]:51296 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932513AbeDIAeq (ORCPT ); Sun, 8 Apr 2018 20:34:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=wCF5xedl4bk9Kp7ZNoXBnhr0mw8rHfU3HqTN0oToiec=; b=EvRBIoxkowBKBdS1wHYGFzyAAxEHNgVuekObg5znpGLy+ZqjyaX1Xgxmt9DCetKJol9LM+br8R6EKc02mQgsOy426jcNyNnn0z1Q/cNpJcnBe0sn62YuYUnZv2lah5ijVqN0CybPuZX5+HIgYg3NqcxDZ1bCAj+xVVa1h0RVwdM= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0806.namprd21.prod.outlook.com (10.167.107.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.3; Mon, 9 Apr 2018 00:34:43 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:34:43 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Tang Junhui , Jens Axboe , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 284/293] bcache: return attach error when no cache set exist Thread-Topic: [PATCH AUTOSEL for 4.9 284/293] bcache: return attach error when no cache set exist Thread-Index: AQHTz5lsql1ublw1iEGbxSDPb32/Sw== Date: Mon, 9 Apr 2018 00:26:38 +0000 Message-ID: <20180409002239.163177-284-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0806;7:jgyVG76Tc1UG/JzyPBQjCTQ4eEeRuvQJJ0KKWjeGWMYFdRsS3qsl/bVkwd/n8XQ9OmhYRmB8SxAx8fIwKC1nh9fBWCczEieQV/F0+cGRkhMSiNqAkBy3fi+HCf+BfBgB62UNCx6/jQYo0VQm3gA88/3BpxM0TIq62sp0bqVKi0CwocnU6PHvL/D46O36MwGN5wipe5ZVJNb0cq8fuDZr1NFjZKqhXI5Q9A1+mmS70luiO2te5mqJmFuJkfpScDJs;20:Sf6rzJNRudJlmqVr/HILoxC9CTdcW/0fEOcsQtURKHhbZvCs4K7o23GsQiF5MmPztIkAPsNy2mPbVaZo91D0zPm4VC4k7F3vIRkC/VrbZ1zLL8S1pyaTla50pMMAVu120ZP2I5kr8XYYbYQ/Bh4zUTcBWhCHLh2LZt4ASlGAhFE= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 0b80b240-fb66-48c1-0c86-08d59db1b024 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0806; x-ms-traffictypediagnostic: DM5PR2101MB0806: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(3231221)(944501327)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123558120)(6072148)(201708071742011);SRVR:DM5PR2101MB0806;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0806; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39860400002)(376002)(396003)(366004)(39380400002)(199004)(189003)(2906002)(25786009)(2501003)(10290500003)(476003)(11346002)(446003)(97736004)(5250100002)(5890100001)(68736007)(2616005)(102836004)(6506007)(3846002)(3660700001)(486006)(3280700002)(305945005)(6666003)(99286004)(5660300001)(76176011)(1076002)(186003)(26005)(7736002)(6116002)(81156014)(81166006)(86612001)(4326008)(105586002)(10090500001)(2900100001)(54906003)(22452003)(316002)(36756003)(110136005)(107886003)(8676002)(6436002)(478600001)(53936002)(66066001)(6486002)(6512007)(86362001)(14454004)(72206003)(8936002)(106356001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0806;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: YjFQnOttpyh7GgmdebkxpeVPdf8nbW1KtZpWey2o0JArBcCMRGTr1F2hkPVZc0Nim3HwqvYUAJn5Cwrsb9LX1BA7imEo4WEfbnEzw1DF9whn45Qk5ZKlT+F3FSqifcyuT1hiTA44ba6R7iRSB3bBNyufugr1sebn8thZn9e1b8d0XHCEROVetuzVwim5mNtDU2szLe1st/El+Ek8aHnNsMCiwagMwwLkBgFaaVNdG5mnsi8jaFV3Xy8j2qRwhAuYBMjV120CPPyjrIfv0IZTik04JJ1dz5zBlYkHQyp1TiOSrMkyjqc9tpDYzU7yEAgjzUp+5AzaMvmM6yPieP7dSH4UFuDs2VBa17oUySyLnFIZLPP8hkIcYpFBMYXbh4CDW06p6B7HJ0VIw5/RheRxqhkV3nCbEzSsJL1cLMy6GQY= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0b80b240-fb66-48c1-0c86-08d59db1b024 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:26:38.3946 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0806 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 1efe31615281..5a5c1f1bd8a5 100644 --- a/drivers/md/bcache/sysfs.c +++ b/drivers/md/bcache/sysfs.c @@ -191,7 +191,7 @@ STORE(__cached_dev) { struct cached_dev *dc =3D container_of(kobj, struct cached_dev, disk.kobj); - ssize_t v =3D size; + ssize_t v; struct cache_set *c; struct kobj_uevent_env *env; =20 @@ -268,6 +268,7 @@ STORE(__cached_dev) if (bch_parse_uuid(buf, set_uuid) < 16) return -EINVAL; =20 + v =3D -ENOENT; list_for_each_entry(c, &bch_cache_sets, list) { v =3D bch_cached_dev_attach(dc, c, set_uuid); if (!v) @@ -275,7 +276,7 @@ STORE(__cached_dev) } =20 pr_err("Can't attach %s: cache set not found", buf); - size =3D v; + return v; } =20 if (attr =3D=3D &sysfs_detach && dc->disk.c) --=20 2.15.1