Received: by 10.213.65.68 with SMTP id h4csp2114732imn; Sun, 8 Apr 2018 20:05:06 -0700 (PDT) X-Google-Smtp-Source: AIpwx48sybHhJEZc/1oyY7XFlGL6P/AHH7z1tX4KVnobLV1Ru8MGUaX04VNfSdFGjkHm5FebbKv2 X-Received: by 2002:a17:902:b7c7:: with SMTP id v7-v6mr7070499plz.190.1523243106008; Sun, 08 Apr 2018 20:05:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243105; cv=none; d=google.com; s=arc-20160816; b=c+FdSYJJtpUJl2StXVeNIRm91t9cpJXd7gfm82zIGo5qHV078smiaAyg9MpeNHUVkw aYOG+upehd+NzmPW0UgIpivmMuVyPYQnYrHf6Zn61vK7wdr11X7olig8p+7lXWSbBfDC 4i73Z1jzNvKJmH1275Ftv2llyMl672+6HLZmU4WxfPQvQcXyLUCVENPTGvdU6ZAPuBSq JyTbwCcFxOoUymCUcTOz2+MNBplpMYplO9YrtKSzn4ZALbv5Hmj1uKW0C2KaxqIL0ckC PqkctD35slKwX7mBDJL51Q7N+WrWDliZ6ty8vjbaCrOaQN9wMKSqfbuiZv9zfWR5T3gX KpOQ== 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=sfe0ZV3tS9EaTSvJhqgSjHClUNSBUDl5SscQrGYjar/itb9cToGhwmDSfUONTnKpoR Pa5TQL1OLP4XLDREzlmtbi0i2jFMCsChB0hOEDdh4nCIwuVZsTXTfH9FLpP3LFP7tfzT tveZzBT4i5H+3tukPgsYktfnAixzPlEzZmun+yP4vxsNoi/JtWB5rvzFYEJZL1HBk+4Y usTl4pc8bOOCji7xsCkhsWd+a1ZmIc4D9mze3PHCIwlpG/gGquMB/8GAb63hNvaJ2uJH p82bND/b4UxK4aU2JZyfspqux8OrIknzdMDTXSXnGSwoaa4QrRFwH84QTm1B6vhdaFF6 WrHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=hAuRcLNv; 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 q61-v6si13230124plb.729.2018.04.08.20.04.29; Sun, 08 Apr 2018 20:05:05 -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=hAuRcLNv; 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 S933147AbeDIAje (ORCPT + 99 others); Sun, 8 Apr 2018 20:39:34 -0400 Received: from mail-co1nam03on0104.outbound.protection.outlook.com ([104.47.40.104]:37663 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933056AbeDIAj1 (ORCPT ); Sun, 8 Apr 2018 20:39:27 -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=hAuRcLNv+80VuRocGyIwpUKqPZv2VFB8xrWHt+ylEJ8ZxrC+OXtNZkcWaGM3I++hVKkjevUQVppiftz9vHajQg9MGmYqqbg/hABC+X4f/AMUOSFfqiJap9oLze0NPpS0iJF68OTMqqZA2nCrxOeDZSn6N1a9yXnTaG82NF2VDKc= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1125.namprd21.prod.outlook.com (52.132.130.150) 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:39:22 +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:39:22 +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.4 158/162] bcache: return attach error when no cache set exist Thread-Topic: [PATCH AUTOSEL for 4.4 158/162] bcache: return attach error when no cache set exist Thread-Index: AQHTz5nhhhhDwYWBF020iSxr0BGu+A== Date: Mon, 9 Apr 2018 00:29:54 +0000 Message-ID: <20180409002738.163941-158-alexander.levin@microsoft.com> References: <20180409002738.163941-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002738.163941-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;DM5PR2101MB1125;7:KYLW2PQx21ruQfXjNIfKI21ufUq+xDPlsqcMPieqF0XmZEpoy11joj18HNEC49A99D+JJmg+DDhtQscbAoIMO2ljXHk6YFHkf6aDK3b2Kdyts6UlHSjKlmVIKCLQjXJYQ/WErlt3xV1HSBo2mVJMOC7zuolyL4zgU1RC/u8wQ0wOhg3jBpoRcAVSX0yHYBeLhuOaewC5q2rfpOSzYwOuN3v3ygcOT1qoN4XBI41Ijuy7vHlHcvivmFsMizVoBU0I;20:gX5mQQKDyVePpqYP166dfPtO1RmEzFO2wxF3ifIiKQDLMyEHOWBzOPgumOiS04PmTiBFBBNv+I9NtflWeijOSWqK63S+qPtK0zx2cv9n5ZPS2ujYWPr1FifEzKSnbRXQ1f9SKQiSXbqrCnHhpNWnpf5yXo8AnP5Qq0wkrNBQPnI= X-MS-Office365-Filtering-Correlation-Id: 325f2f63-395c-4bfa-e0fb-08d59db25646 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(48565401081)(2017052603328)(7193020);SRVR:DM5PR2101MB1125; x-ms-traffictypediagnostic: DM5PR2101MB1125: 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)(3002001)(93006095)(93001095)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB1125;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1125; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39860400002)(39380400002)(366004)(376002)(396003)(189003)(199004)(2906002)(25786009)(6512007)(10090500001)(3280700002)(10290500003)(6666003)(3660700001)(316002)(110136005)(54906003)(11346002)(107886003)(2616005)(476003)(446003)(36756003)(99286004)(86612001)(53936002)(4326008)(486006)(6436002)(3846002)(81156014)(305945005)(5250100002)(1076002)(102836004)(14454004)(66066001)(5890100001)(7736002)(105586002)(81166006)(106356001)(8676002)(97736004)(6116002)(6506007)(6486002)(5660300001)(186003)(76176011)(22452003)(72206003)(478600001)(2501003)(2900100001)(26005)(86362001)(8936002)(68736007)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1125;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: JCRviiMrFlu9D5pWqEANm6PnOxv51TdNdnaVe4SoCZvZcevBxMxnPTtB6HvfMpnNbPjtFX/R68531sxtJDs1AJQMW73yaDZEich243PFkoqsFiABP4Y7cPzmTMv5WuMC20vz2PP6zuHvbTPmnOxv7e/+eWCsVEz2iVqes88/eSDru0WDfq2njWVW0s+k/k75nlBbbiw5c+2nwL5Wlgqmag2Hx8YxwG/nemSZR96me3xpD58OTP68EFqC8TmHw4zdCVR9oUGN6PRF7O1u/xMJSqjjS3iVfu6bznWnicK7R4xW3bgZhU1G/uLFSYDJzZHB/I1AYEB2ayYHF9L09o/NFAF1aM3ai/eWZIiF6hdfLNFlgULU3N2yR8HbeUcQbL9Tk5DZKFwrttvnHRfSR31Rr+4HnWS02lVrEb0DixpaBD4= 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: 325f2f63-395c-4bfa-e0fb-08d59db25646 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:29:54.3496 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1125 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