Received: by 10.213.65.68 with SMTP id h4csp44416imn; Mon, 19 Mar 2018 19:00:57 -0700 (PDT) X-Google-Smtp-Source: AG47ELsn4ryNpu8Vt/csvsLpAUp8LRJ9+9ne1i8ahTl9p8Ow5jE9XD2ufjJGCdPLORWBtlA+g647 X-Received: by 2002:a17:902:b185:: with SMTP id s5-v6mr14428106plr.109.1521511257861; Mon, 19 Mar 2018 19:00:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521511257; cv=none; d=google.com; s=arc-20160816; b=ctKYcJh9etf4wPIJXk0R26DmMPxIMygzgJ5rJmSmy0heJ/wICu7nj9LVAoqKEYWq1R S7Tuv+rb7cYAjEOxiGnRRZyxhUZIFUhuqOZWvmFJbl2OnRLky3mPpMnGrs5yRgE3r2Jj sIfj86wMl7uHI2F2aIASvvgHzy+uGGm9nmL/+k0U0b78TlDAFtKQ6TjahJH8ULzubBPf vmd6kvTnfqoRVBBFbVNhdoXaw+AxQ2GUexGj4AS79V8g2JybpBAU1OW3JBq7UZI1yHaW qXm/PusDJHkxZ6EKj5pTaGKHcYU6poka9WTttHHpf8IfPr5agOK/VrhlC5RV0dwkOMIr Jm5A== 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=f7B2HkkpZoV8Po0iimLZbbOgdtKQVggXHs+5/HuL/qE=; b=DqBmz3YmpAmJSmXe6H4a95ismgxqxLAdSPa3mAnQWtnYcWcZ9Zw6SFKgVd8D23RzYv wfgur+iwbwxbSmE+7hCWtnlieAZnl126f+2KcuUGEaE7FTDIKkT0nKQP5+F5jTFegN9L gVPIhCLxG62O8F736t9AOV+EXrVFnrcVVVRKdBbsfkm/0KxeRbQSyOZA1a9PQseJWUmk VZI3gUBdnEdJpfrANxWmIbgTn8K4G0CE1TCkMboZ3CHZVMDMTTopRXfD4iyvQJAvIif2 +/zoJbkfVe7Oweu/LkKIIpXHVOogf9AGyNcNFyrhwGLSQ6DpGsJrUF7bRvLu8mQbCmJJ fXpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=n4xFWyzT; 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 a6si426322pfi.123.2018.03.19.19.00.43; Mon, 19 Mar 2018 19:00:57 -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=n4xFWyzT; 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 S936479AbeCSWYf (ORCPT + 99 others); Mon, 19 Mar 2018 18:24:35 -0400 Received: from mail-dm3nam03on0129.outbound.protection.outlook.com ([104.47.41.129]:48439 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933868AbeCSPtH (ORCPT ); Mon, 19 Mar 2018 11:49:07 -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=f7B2HkkpZoV8Po0iimLZbbOgdtKQVggXHs+5/HuL/qE=; b=n4xFWyzTwZ4IZ8AZu/WatUTvcTRCfMnESaky3PXvf4RUcxZZp7LEM7wTLAzfWO2AMGxCGXXyhBlBdHOpMnQznIS/TZFEqfbmhj7YHfpjwjyvX6X+Mfm+HZNNoSVZ4/amBs9dfG24hkYlawEOGhQ7Q+FB0DdRtnOuS8x2s5ZsPk4= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0936.namprd21.prod.outlook.com (52.132.131.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.609.2; Mon, 19 Mar 2018 15:49:01 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62%5]) with mapi id 15.20.0631.004; Mon, 19 Mar 2018 15:49:01 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Rui Hua , Michael Lyle , Jens Axboe , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 082/124] bcache: ret IOERR when read meets metadata error Thread-Topic: [PATCH AUTOSEL for 4.15 082/124] bcache: ret IOERR when read meets metadata error Thread-Index: AQHTv5m6dq+tSIwaV0+wUzdgcWa3/Q== Date: Mon, 19 Mar 2018 15:48:30 +0000 Message-ID: <20180319154645.11350-82-alexander.levin@microsoft.com> References: <20180319154645.11350-1-alexander.levin@microsoft.com> In-Reply-To: <20180319154645.11350-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;DM5PR2101MB0936;7:reI0cLTQoHp6FT67aA/2QW+DEbItmXvK0fR0GFvinfEhcZ1LJRuQsWaf3nneVUv+Ttch0pzwv3tfInOtxb3V9U6pj5JWuQu1DSVZSVwktcPcJWMOb7BQWDcBYxLH19A6LGNViS7o7oNTs0DIdgHxf7qUvRfNJXSqWRvbVZiGPR3V4KL4Sh37yi9fMixahWb2BYf0pXezpODsf3lXF9IzXcSpnPEiEEIKmUCrta5R6wnOhHwGeQxqweqXPZRtiCbz;20:a2QpZQoGUV6aSgowWGKPn6kycfVGoLOctjkMkplLrL4R3BKrReMTEMwKi2N9QYjg5Cx7kMy2ExXSn4Z5SZ/XQx8Tj8Dvn1TOfks17Rc6cIcmm4wk3AMNtq7rB1ltZACZsu50+oAeHlZjJIAt4AjfT++ruqR6iXST61TizBE9vxA= x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: ae17dcef-f3dc-4b6f-d40c-08d58db0ef78 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0936; x-ms-traffictypediagnostic: DM5PR2101MB0936: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(85827821059158)(788757137089); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(3231221)(944501300)(52105095)(6055026)(61426038)(61427038)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123562045)(6072148)(201708071742011);SRVR:DM5PR2101MB0936;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0936; x-forefront-prvs: 06167FAD59 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(346002)(39860400002)(366004)(376002)(396003)(199004)(189003)(2900100001)(3280700002)(2950100002)(10290500003)(66066001)(106356001)(76176011)(86612001)(6666003)(478600001)(5250100002)(6512007)(6486002)(107886003)(36756003)(97736004)(72206003)(25786009)(6436002)(53936002)(7736002)(2501003)(54906003)(110136005)(105586002)(10090500001)(2906002)(86362001)(305945005)(5660300001)(316002)(8676002)(6346003)(1076002)(3846002)(3660700001)(81156014)(4326008)(14454004)(26005)(6116002)(102836004)(8936002)(81166006)(6506007)(186003)(22452003)(39060400002)(59450400001)(99286004)(68736007)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0936;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: w09cVm2cmdEo3fal9TCPlpCo45RHxL2KGzWbZmJcrRelPP1aQOf470k83aaZDu1HG0MU0WOsjzXV8OHP3Pfo+w1/kq6ElBgXHzn1YTU78XRuqb0ZYLpjY7Hwfc1MQbOEfgapKd7KOUrpT7TOnk4Mj9GwZGgcaFaAu6mtS10gXpXJVZqlSeSahbgJFo/57b1LnF8OPirBjplxeeqgfeuBCU+35y2kxc8BLqLwP/9Kthz/p2/h1PbZ0Dhydjvahavg7XzpLkOUlfEYKjW4UoYsCQvd8Glyp63ngNzYUOjEEuX/77NYwxp6gQP2jF5mPb45juNGLNRpuzSPYXu1ZMb0Ag== 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: ae17dcef-f3dc-4b6f-d40c-08d58db0ef78 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Mar 2018 15:48:30.2369 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0936 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rui Hua [ Upstream commit b221fc130c49c50f4c2250d22e873420765a9fa2 ] The read request might meet error when searching the btree, but the error was not handled in cache_lookup(), and this kind of metadata failure will not go into cached_dev_read_error(), finally, the upper layer will receive bi_status=3D0. In this patch we judge the metadata error by the return value of bch_btree_map_keys(), there are two potential paths give rise to the error: 1. Because the btree is not totally cached in memery, we maybe get error when read btree node from cache device (see bch_btree_node_get()), the likely errno is -EIO, -ENOMEM 2. When read miss happens, bch_btree_insert_check_key() will be called to insert a "replace_key" to btree(see cached_dev_cache_miss(), just for doing preparatory work before insert the missed data to cache device), a failure can also happen in this situation, the likely errno is -ENOMEM bch_btree_map_keys() will return MAP_DONE in normal scenario, but we will get either -EIO or -ENOMEM in above two cases. if this happened, we should NOT recover data from backing device (when cache device is dirty) because we don't know whether bkeys the read request covered are all clean. And after that happened, s->iop.status is still its initially value(0) before we submit s->bio.bio, we set it to BLK_STS_IOERR, so it can go into cached_dev_read_error(), and finally it can be passed to upper layer, or recovered by reread from backing device. [edit by mlyle: patch formatting, word-wrap, comment spelling, commit log format] Signed-off-by: Hua Rui Reviewed-by: Michael Lyle Signed-off-by: Michael Lyle Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/md/bcache/request.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c index 643c3021624f..d1faaba6b93f 100644 --- a/drivers/md/bcache/request.c +++ b/drivers/md/bcache/request.c @@ -576,6 +576,7 @@ static void cache_lookup(struct closure *cl) { struct search *s =3D container_of(cl, struct search, iop.cl); struct bio *bio =3D &s->bio.bio; + struct cached_dev *dc; int ret; =20 bch_btree_op_init(&s->op, -1); @@ -588,6 +589,27 @@ static void cache_lookup(struct closure *cl) return; } =20 + /* + * We might meet err when searching the btree, If that happens, we will + * get negative ret, in this scenario we should not recover data from + * backing device (when cache device is dirty) because we don't know + * whether bkeys the read request covered are all clean. + * + * And after that happened, s->iop.status is still its initial value + * before we submit s->bio.bio + */ + if (ret < 0) { + BUG_ON(ret =3D=3D -EINTR); + if (s->d && s->d->c && + !UUID_FLASH_ONLY(&s->d->c->uuids[s->d->id])) { + dc =3D container_of(s->d, struct cached_dev, disk); + if (dc && atomic_read(&dc->has_dirty)) + s->recoverable =3D false; + } + if (!s->iop.status) + s->iop.status =3D BLK_STS_IOERR; + } + closure_return(cl); } =20 --=20 2.14.1