Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp736182imu; Tue, 27 Nov 2018 21:25:06 -0800 (PST) X-Google-Smtp-Source: AFSGD/W1W0mEu2gFcFaneHXBqXDPQFpjRr5gs6aaQyZrV/xK6ytYgjnm1tfaxDdyH9f4iRVs2OQz X-Received: by 2002:a63:2849:: with SMTP id o70mr31285247pgo.155.1543382706221; Tue, 27 Nov 2018 21:25:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543382706; cv=none; d=google.com; s=arc-20160816; b=fDV4bNex8lentOLI9RK8ECf/G+FeuUKHNyn9s+W9lGf/L2fLoSfRMtwSFaj1gzfAY4 ztAi+hRjqq7C3e6DHtSp8CkrUj4zvFlEBDw0YzZGLWolJdkx2zGGz5X2/r07EdcOb0V0 l0gRf22Waz2xuQpCvbrVUKK/C4tNFa2x0KUjxnxqMht/d09f2NVMXVe0hcFH3G+SohRC kTAIzlhKuOMOWeb+VL6Kw4cX2SUggAFgjsLbWUSNdaKHqQaLMT+afqBPcZaQcB0xAL0A EEluq0aFu7PTafc2QGESoHBKO8xwETN3h1myTOJXPk0+NBmQE7cpZXzlWr9IEzVY0ZWH CKZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=M6KDT99q+AHq3H5h55or9b+0G0YiTpLvNM9SQ/YTN04=; b=JC5jYtU1M3A5DpqRMV6pH6+EKTO6xsXzqFuvY3CIhBkhDKN1pez0ddyvsSPDK/UTjw EhAwqM1RhAQnVTw9xfm4mqjgZPvao0ELfeCdjQtJa8l0x1uSylcYIkSrE+NW1UJ13qbq fz/KPPfl8R82OGAslZnJCiWMfxFiDAfN4Zx/gUFvIvqwDYX+EpFe/HYRqhloHQLscMQV VGiqVttUfaDqXarXP3qY5hXNyQPfpvaedjQwftWRiM28xqQzOZEqA6mM+et2d3MGH8DW GFg/if1cZg+zD8U0mObKvxGzaLnSKXgqkXfzSGNnVL0NgmOp866MD78tsQckDONXhUaY A8Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=w0UezZXe; 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=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c21si6118886plo.165.2018.11.27.21.24.51; Tue, 27 Nov 2018 21:25:06 -0800 (PST) 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=@oracle.com header.s=corp-2018-07-02 header.b=w0UezZXe; 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=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727647AbeK1QXN (ORCPT + 99 others); Wed, 28 Nov 2018 11:23:13 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:60938 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726894AbeK1QXN (ORCPT ); Wed, 28 Nov 2018 11:23:13 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wAS5J6tZ056646; Wed, 28 Nov 2018 05:22:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2018-07-02; bh=M6KDT99q+AHq3H5h55or9b+0G0YiTpLvNM9SQ/YTN04=; b=w0UezZXe7P8zr1gSEZteC20EF+T7meCDC2XxkJuWaQKVWIXsuvwt+jml/MD74Dm5U0YP bEsENKWpewxx4UM0MMhjNBwyaidBhngTsm9Voz9JBjaQToBCzcCeujP/xwSTnLhXnZhk JxTIDF/QaiSUqRMpGhNXQZnKLY6mcDrP+nI0r+iz8miZsFaT4NwAGhQYb6NmQ4xxLe/Z lVuKLMxE0iG1CYterx/pDjpH0Xf8y9rV1mHXYd7ruhoGO8OGZlk6yQxOnbPwdOV1VC5h R0S2LGLNq8FSHlrY3g4FkK970XG9ENzXsBbYfARtvn0dhwlUm7T5uEohETTUOC6dNFks PA== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2nxxkqfyx6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Nov 2018 05:22:49 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wAS5MmKU030858 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Nov 2018 05:22:48 GMT Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wAS5MlbN006464; Wed, 28 Nov 2018 05:22:47 GMT Received: from localhost (/10.159.132.173) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 27 Nov 2018 21:22:47 -0800 Date: Tue, 27 Nov 2018 21:22:45 -0800 From: "Darrick J. Wong" To: Dave Chinner Cc: Allison Henderson , linux-block@vger.kernel.org, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, martin.petersen@oracle.com, shirley.ma@oracle.com, bob.liu@oracle.com Subject: Re: [PATCH v1 5/7] xfs: Add device retry Message-ID: <20181128052245.GD8125@magnolia> References: <1543376991-5764-1-git-send-email-allison.henderson@oracle.com> <1543376991-5764-6-git-send-email-allison.henderson@oracle.com> <20181128050850.GJ6311@dastard> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181128050850.GJ6311@dastard> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9090 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811280048 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 28, 2018 at 04:08:50PM +1100, Dave Chinner wrote: > On Tue, Nov 27, 2018 at 08:49:49PM -0700, Allison Henderson wrote: > > Check to see if the _xfs_buf_read fails. If so loop over the > > available mirrors and retry the read > > > > Signed-off-by: Allison Henderson > > --- > > fs/xfs/xfs_buf.c | 28 +++++++++++++++++++++++++++- > > 1 file changed, 27 insertions(+), 1 deletion(-) > > > > diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c > > index dd8ba59..f102d01 100644 > > --- a/fs/xfs/xfs_buf.c > > +++ b/fs/xfs/xfs_buf.c > > @@ -21,6 +21,7 @@ > > #include > > #include > > #include > > +#include > > > > #include "xfs_format.h" > > #include "xfs_log_format.h" > > @@ -808,6 +809,8 @@ xfs_buf_read_map( > > const struct xfs_buf_ops *ops) > > { > > struct xfs_buf *bp; > > + struct request_queue *q; > > + unsigned short i; > > > > flags |= XBF_READ; > > > > @@ -820,7 +823,30 @@ xfs_buf_read_map( > > if (!(bp->b_flags & XBF_DONE)) { > > XFS_STATS_INC(target->bt_mount, xb_get_read); > > bp->b_ops = ops; > > - _xfs_buf_read(bp, flags); > > + q = bdev_get_queue(bp->b_target->bt_bdev); > > + > > + /* > > + * Mirrors are indexed 1 - n, specified through the rw_hint. > > + * Setting the hint to 0 is unspecified and allows the block > > + * layer to decide. > > + */ > > + for (i = 0; i <= blk_queue_get_mirrors(q); i++) { > > + bp->b_error = 0; > > + bp->b_rw_hint = i; > > + _xfs_buf_read(bp, flags); > > So the first time through this loop the block layer devices what > device to read from, then we iterate devices 1..n on error. > > Whihc means if device 0 is the only one with good information in it, > we may not ever actually read from it. > > I'd suggest that a hint of "-1" (or equivalent max value) should be > used for "device selects mirror leg" rather than 0, so we can > actually read from the first device on command. "read from the first device on command" => "set bio.bi_rw_hint = 1"... > i.e. > bp->b_error = 0; > bp->b_rw_hint = -1; ...which is confusing. The intended behavior for this RFC (though not so well documented) is that bi_rw_hint == 0 means "let the device choose", and rw_hint > 1 means "choose mirror (rw_hint - 1)". That's sort of an odd behavior because now we have: blk_queue_get_mirrors(q) returns 5 (as in 5 mirrors) but we access the 5 mirrors as indices 1-5, not 0-4 like most programmers would probably expect. Also, I think it's probably necessary to create a #define to attach a name to the "let the device choose" value... #define BIO_RW_HINT_ANY_MIRROR (0) for (i = BIO_RW_HINT_ANY_MIRROR; i <= blk_queue_get_mirrors(q); i++) { ... bp->b_rw_hint = i; ... _xfs_buf_read(bp, flags); ... } (or offset things -1 like you propose) --D > _xfs_buf_read(bp, flags); > > if (!bp->b_error) > return bp; > > /* manual iteration to find a good copy */ > for (i = 0; i <= blk_queue_get_mirrors(q); i++) { > bp->b_error = 0; > bp->b_rw_hint = i; > _xfs_buf_read(bp, flags); > ...... > > + > > + switch (bp->b_error) { > > + case -EIO: > > + case -EFSCORRUPTED: > > + case -EFSBADCRC: > > + /* loop again */ > > + continue; > > + default: > > + goto retry_done; > > Just return bp here, don't need a jump label for it. > > Cheers, > > Dave. > -- > Dave Chinner > david@fromorbit.com