Received: by 10.213.65.68 with SMTP id h4csp2120292imn; Sun, 8 Apr 2018 20:12:19 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/5XheRZ2k8CR4JLwAZq6IgRx/KFtTnlmHio9yGnOTS4E8AKgNgMuKt2f1TpL34Gz7zVGEQ X-Received: by 2002:a17:902:a9c2:: with SMTP id b2-v6mr2871606plr.181.1523243539438; Sun, 08 Apr 2018 20:12:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243539; cv=none; d=google.com; s=arc-20160816; b=rR4OSLTpvuEk1ae7omYdrb1QwSmOXHjeJ4Iv6ZjJSg1DZ1Ji/SRijm/uaNJ++DY3il hqEIQzMG4Kj95TCh7if5aDs1zftA8/EBLbYvV4fi2Df+7sKcpZiqe+ABm23LSpmUDayH E5DdaaSXVuFQIYK+z205rgsj/RdQtVK18IvGHy0KDlalzDah7bgzS6lJrN0urZJaAl5G 9JxbPgiN9AdAdtYtvjZP0QEArZ8zsDSpwloMuJxGSWT2zmcKaHWCJl0aHaE2K/9QqElM CY2FWUKk0uMMvm+KbgFKPSmsmBfyjna1n7DDowuNzTh/4QqWI1VlBAkbmDcjh9+CjW1T /YRA== 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=HMobdrt0ql5M/FK0Mt6oweBfHI/eATYMO9Of8B+4YS4=; b=IHAtkmt7ez2YuZB31ghMLKxtoCaF1HDUfv7JShbY5oRCdEEhqgxCYC3N2iLp/3Fbe1 0k///rdEMMEUDzWnQGC8tUmW9Jg09i31DeNnPRjAsa+b6oYURgTdUfoMVzY1kfjCRr2r kC6APfMw5woxjoNem02aLlTue6loLqT/sTO852y7hKdl1zyzsqogGyazNOZ/V6UF4xhs oGy83jg9tsvQmz/s/gnb+IBqrycxzCNGj1ZA9EcV5+QoBp6C0vWalbAI/Yf6C9BxkQ1P CUV02+ZCqTq1oTh7x+tcbVMSFSlcgl1Vm206pQUUYroNFF1MKM3i/osjJsoAtJiSGrcz DHcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=iaVpEQ/H; 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 x3-v6si14108408plo.479.2018.04.08.20.11.42; Sun, 08 Apr 2018 20:12:19 -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=iaVpEQ/H; 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 S1758136AbeDICzl (ORCPT + 99 others); Sun, 8 Apr 2018 22:55:41 -0400 Received: from mail-sn1nam02on0125.outbound.protection.outlook.com ([104.47.36.125]:42928 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755247AbeDIAZr (ORCPT ); Sun, 8 Apr 2018 20:25:47 -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=HMobdrt0ql5M/FK0Mt6oweBfHI/eATYMO9Of8B+4YS4=; b=iaVpEQ/HAzM7CA2+qAfBnDvYHvk9R+DWUU/apTUxIuJ/Oj1FEBD5GPOZYmMm1Uul4V7/6f1+nQBp7VpBw/2HidY79nlf+APU4Vw6IK83MxqhLGKpI+NujtEd7B5b8EZ1YrmmTLxBxnfuVmYpxvS0xKJMBdrsubesM+G3aHJ2ryM= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0725.namprd21.prod.outlook.com (10.167.107.167) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:25:44 +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:25:44 +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.14 139/161] bcache: return attach error when no cache set exist Thread-Topic: [PATCH AUTOSEL for 4.14 139/161] bcache: return attach error when no cache set exist Thread-Index: AQHTz5i+OnON5eHjjkaohUxM9Hv7rQ== Date: Mon, 9 Apr 2018 00:21:47 +0000 Message-ID: <20180409001936.162706-139-alexander.levin@microsoft.com> References: <20180409001936.162706-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001936.162706-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;DM5PR2101MB0725;7:j9YU6YqV15zEVAUWWllm5vgIparRh/tYW63lR0UIBCT+QZPD0/Z6OE2raxOucJeH1JOWIOWm0vficUIqWkVRUa0biaPy+Al4emLV4fL4oaYacz3tshvCN1aOHAd4ictvobTB4fdc3n9FisuVisNO93y42M8vk94zjq39hjvEY7DOwKk9vnwr91vw4CP2rGrWp8n4bdsbElPZEGIb3kNOMeYcukrmCwD09ql65tqfWWtyFRUztrmdDCunOAcDr5e6;20:Jsf36wRsnmB7rRXXUaOzqt2S0O2PS5AbgCghOJQrtIDW+CTmVnJgJJSTVo1b/6pTRYWP0YO2jHv5TIriTGGxuf5GmO5No8s2VG0iOQ8J/DIecTS+Ap0xM7uMbnpuIiXHJSKmzd/zipiEfGRZTezUYNZWCF4+JP7ABaVz0Edgl7A= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 657a4d41-41fb-41de-3dd4-08d59db06eb6 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0725; x-ms-traffictypediagnostic: DM5PR2101MB0725: 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)(5005006)(8121501046)(10201501046)(3231221)(944501327)(52105095)(93006095)(93001095)(3002001)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0725;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0725; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(346002)(366004)(376002)(396003)(39860400002)(199004)(189003)(6486002)(81166006)(26005)(6512007)(4326008)(6436002)(81156014)(8676002)(97736004)(186003)(36756003)(72206003)(53936002)(107886003)(2906002)(86362001)(76176011)(110136005)(305945005)(10090500001)(486006)(3660700001)(102836004)(5660300001)(14454004)(476003)(86612001)(446003)(99286004)(68736007)(66066001)(11346002)(54906003)(2616005)(1076002)(7736002)(5250100002)(25786009)(8936002)(478600001)(2900100001)(2501003)(3280700002)(105586002)(316002)(106356001)(22452003)(6506007)(3846002)(10290500003)(5890100001)(6116002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0725;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: DIzkQrNPNtB/uSqgD+zmJPNTuqOcY32/heZWCHXH38niT/+ZMaiICAtPjY1k99m20CbNUQ6YCcXqlSjceqT+vYl0O5rfkeXB+6xR0tC0q0VUW4IdNw/BnVbbYgzu0S9jRPT7hu5hoCafS1jOuQ0H3hKCcxbGGPa4UKK534YWm3NUJDPm/lBsB4ZFNKqX03N40N5+l45PuFMJAS5ai6kQcGo4ZLFV21PIK2cIkJAwK8XDaz3M1JoKhJlGKV0qeZKsypgR2kkWU+GHJllpXUwU0iNbjgUur6nZBVv7VgbHftSAUkFpyIxAdDcid9gCrGPGJgauVhFLj5uB0ClyHeFerfNC7rroXdYGTZJMsKDOmtK9h0FQfXYsJ9NjHfA6CBW7zYgd5GaPPx58EdF41av5C4MwNbCqgsFZHaLrPr4IaQA= 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: 657a4d41-41fb-41de-3dd4-08d59db06eb6 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:21:47.1280 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0725 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 6dd03cf9053b..5d81cd06af00 100644 --- a/drivers/md/bcache/sysfs.c +++ b/drivers/md/bcache/sysfs.c @@ -193,7 +193,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 @@ -270,6 +270,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) @@ -277,7 +278,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