Received: by 10.213.65.68 with SMTP id h4csp2199193imn; Sun, 8 Apr 2018 22:18:41 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+d1iYCKunqnGJRyUI2vmq/ijaINXcibpXsZfffX1U+U0P63ZsUCs4qe20wWpzcFly09HfZ X-Received: by 10.98.118.130 with SMTP id r124mr27734003pfc.238.1523251121059; Sun, 08 Apr 2018 22:18:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523251121; cv=none; d=google.com; s=arc-20160816; b=M222pdvoSxQQEnw7Cmghv/3UX1kFpuNMh4F5+H9Vtwfh5lm+xIK9ZShgKZmTk98n5K aZhqzdXb7i4lYNznmgdhKEkUNCv8hXKOO0JA+7Z9MHWqvcggBNVQk3GzfUeL63fKmxG9 iDulsCnAb7v7zZ3b6m483BMPRCXoIPxvzF811PXjKntZ2q+QG2Jxi8yo0BvXuqgi7q3s CvFD5HMqhuJ74Dok9O61AWIKlxkfe4aZJ8H2IdWomCMcZqN6GC/zT5UwpQvR/eKCjztT TC1Ueo3fA67QuyfYNtY+bsWe+Taw9ll5CvuCWs4yGDUuIlb4+l7Jl7o8cClF5m4eBk+a LmaQ== 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=BGqNP6qDw6TvVsUfEYzGInN4ueeSRhJnK1GbVIP9Qlg=; b=KGG6nb6XIslu+Z9TW1+mRmnoZseiF050XZgUQGvSK9EDO+ZSaR9Q4GHhEB6AUBkSP9 ryaEiOCUdB1XVwuUjGLjpId1ppW0u6z/yMJnbVI5A/1AKePQ4hNiKExTZa1p6m5PwfyT iBxw5Bv+THc1g0CnbZES7Y/hRtSsI+ZngmKdTiWHAxtF3jjZygsp9CATX1275NvN0SeP 3h45grx4th4/fY5viM3Mkp7BsoteoFuweAYfX1cI/s1yqbrU6nmSNu61VVC2lxU1oenZ r3vBQFMXA10Ev2/W0GaN80+2JzmYdUJGnlPzvkqcCS05ITxrUaqolSvvyXeoMg3TTbh2 ls2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=MZvMMBHK; 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 a90-v6si14622638plc.732.2018.04.08.22.18.04; Sun, 08 Apr 2018 22: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=@microsoft.com header.s=selector1 header.b=MZvMMBHK; 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 S1754412AbeDIAVO (ORCPT + 99 others); Sun, 8 Apr 2018 20:21:14 -0400 Received: from mail-bn3nam01on0124.outbound.protection.outlook.com ([104.47.33.124]:4000 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753254AbeDIAVJ (ORCPT ); Sun, 8 Apr 2018 20:21:09 -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=BGqNP6qDw6TvVsUfEYzGInN4ueeSRhJnK1GbVIP9Qlg=; b=MZvMMBHKdzDzeNdmdOG0G9tSL0vKlmBUJ38LSnyhwMkFxMIklCwI5+YCZzgmbVnZXBHD+LbguZmW+z5pEj4Z57KeM6YbJZlwFoxJPZrz5BH/wN65ftmucfjCEcS/9C+McS45zInL/mEF2iViL8fT3hI19ez0ujmFmcvzyHFqTQ8= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1110.namprd21.prod.outlook.com (52.132.131.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:21:06 +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:21:06 +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.15 163/189] bcache: return attach error when no cache set exist Thread-Topic: [PATCH AUTOSEL for 4.15 163/189] bcache: return attach error when no cache set exist Thread-Index: AQHTz5haGR2iRpd76keGFnORsw68xQ== Date: Mon, 9 Apr 2018 00:18:58 +0000 Message-ID: <20180409001637.162453-163-alexander.levin@microsoft.com> References: <20180409001637.162453-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001637.162453-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;DM5PR2101MB1110;7:XD9T82PgmQASZSV5IW/ksrdi/y/bkXQo1/IOTebaRHui29Ut59gwReqWJaC/6P+ImHbQ+dk/NCwUs+KJ+Hy26Cyk0ZzyiBlNkRdtSkRVQ83aN1d5eMKWfH9jypxhXh7FdZ1rw+XDr0+YjDMZXCyt49hlVJ4e67hWOTYwZzZ0E61EC3gYgcLcqNAI4rRsBFfUhUVHDMtoQ2IfsNrCyLIos8N6qooT3qAmRG4aVoHn0AUJtAMU1zap7OhiwZPO45uP;20:QHAztTMfkI6oJZRGmGluSHzfzP1xQ7GYuzjJw4JvS8qbL1F1xTwXqhzpy9IbXtmnyg6aH6mmDBWn1gu8CPW5YtpzWBMsCiwr/qogPMoYCKe4uXAihZvHM3bDlC16VZnYoCyGj0nsW6TmsylIHegKB6BsLCsb2u9XkyBBdobUVlM= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: ecd5abee-201d-4287-1021-08d59dafc94f x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1110; x-ms-traffictypediagnostic: DM5PR2101MB1110: 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)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011);SRVR:DM5PR2101MB1110;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1110; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(366004)(346002)(396003)(39380400002)(39860400002)(199004)(189003)(5660300001)(478600001)(86612001)(3846002)(6116002)(106356001)(6486002)(72206003)(25786009)(10290500003)(8936002)(6436002)(76176011)(2616005)(6506007)(2900100001)(97736004)(486006)(26005)(36756003)(10090500001)(81166006)(8676002)(81156014)(102836004)(2906002)(99286004)(11346002)(476003)(3660700001)(66066001)(6512007)(86362001)(53936002)(105586002)(5890100001)(186003)(5250100002)(14454004)(22452003)(6666003)(2501003)(446003)(7736002)(316002)(1076002)(110136005)(3280700002)(54906003)(68736007)(107886003)(4326008)(305945005)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1110;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: apBPBm2ljoARFLdFHNgIdTjaO7M0IUkaGm60Bq8jZXWdm1XWMPfQ5OCI/16v6TKe9Go+d6nraLXerDtKN0vkbdeVcwFVMoH4rUHhKMZ5YTuzCjuyG1UhQc/8NWT+igzsbgpA47/caZoOrza4YAETh5NK1P/8zhUUP8HyCyJLcaZr5DFLCboOAnByg0ROGt/CzEJxFbOoKoOi9svTDq4OVq8mpooMLw5kBlMrSTh/3LUdgnfRKPQ8xVuhNylEV2fwxXFEfIlpTU0GUF9nZsZlip6Rfe9udOWwgxpdNvTKgMIj3Wt3BhekOkjrKsXbFmdmhEvYCEHtZxFXAV8TDdhiT/VTlHWjMUZETf2o6NiJO3HXzYwKsfoKvNulvvKKWkWICcNXpi/3HK60uu43ZQd6PypLD6DSR7izlfgkwN+MYeg= 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: ecd5abee-201d-4287-1021-08d59dafc94f X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:18:58.8774 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1110 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 c54028b92bc0..6316399aa230 100644 --- a/drivers/md/bcache/sysfs.c +++ b/drivers/md/bcache/sysfs.c @@ -195,7 +195,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 @@ -272,6 +272,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) @@ -279,7 +280,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