From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D6E5C433B4 for ; Thu, 29 Apr 2021 21:08:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 356B16143F for ; Thu, 29 Apr 2021 21:08:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233357AbhD2VJM (ORCPT ); Thu, 29 Apr 2021 17:09:12 -0400 Received: from mx2.suse.de ([195.135.220.15]:59594 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233284AbhD2VJM (ORCPT ); Thu, 29 Apr 2021 17:09:12 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1619730504; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NciCyiZPbzmP9EScIm/d+xm3xtaz9st0CdLXaGyBKAA=; b=bApUfTXPm/wI2imdS+EWNVSHT9FhuAD8easnpdKfveQU7U/CVv5lzGOwSzrWx6DlcQYJGd Tlva44Ae2NbHP+ldNvBZRofz55QGL/5NP4kSBtALg5PZq2eSwAzJMOyIxkUK/Kpnhbl4jg SGmJ4/R91TIzL/7zsQFA6ugLSz6uvvo= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 6B6BFB20E; Thu, 29 Apr 2021 21:08:24 +0000 (UTC) Message-ID: <413c998fd75f6bc9c7f70d8a1a2b107b443a75a0.camel@suse.com> Subject: Re: [dm-devel] [RFC PATCH v2 2/2] dm: add CONFIG_DM_MULTIPATH_SG_IO - failover for SG_IO on dm-multipath From: Martin Wilck To: Bart Van Assche , Mike Snitzer , Alasdair G Kergon , dm-devel@redhat.com, Hannes Reinecke Cc: Daniel Wagner , linux-block@vger.kernel.org, Paolo Bonzini , Christoph Hellwig Date: Thu, 29 Apr 2021 23:08:23 +0200 In-Reply-To: <5d1967f2-8017-c711-dec0-3ffe751974de@acm.org> References: <20210429155024.4947-1-mwilck@suse.com> <20210429155024.4947-3-mwilck@suse.com> <5d1967f2-8017-c711-dec0-3ffe751974de@acm.org> Content-Type: text/plain; charset="ISO-8859-15" User-Agent: Evolution 3.38.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org On Thu, 2021-04-29 at 09:32 -0700, Bart Van Assche wrote: > On 4/29/21 8:50 AM, mwilck@suse.com wrote: > > +       if (hdr.dxfer_len > (queue_max_hw_sectors(bdev->bd_disk- > > >queue) << 9)) > > +               return -EIO; > > How about using SECTOR_SHIFT instead of the number 9? no problem. That line was just copied from the scsi_ioctl code. > > > +               /* > > +                * Errors resulting from invalid parameters > > shouldn't be retried > > +                * on another path. > > +                */ > > +               switch (rc) { > > +               case -ENOIOCTLCMD: > > +               case -EFAULT: > > +               case -EINVAL: > > +               case -EPERM: > > +                       goto out; > > +               default: > > +                       break; > > +               } > > Will -ENOMEM result in an immediate retry? Is that what's desired? No, I overlooked that case. Thanks for pointing this out. > > > +               if (rhdr.info & SG_INFO_CHECK) { > > +                       int result; > > +                       blk_status_t sts; > > + > > +                       __set_status_byte(&result, rhdr.status); > > +                       __set_msg_byte(&result, rhdr.msg_status); > > +                       __set_host_byte(&result, rhdr.host_status); > > +                       __set_driver_byte(&result, > > rhdr.driver_status); > > + > > +                       sts = __scsi_result_to_blk_status(&result, > > result); > > +                       rhdr.host_status = host_byte(result); > > + > > +                       /* See if this is a target or path error. > > */ > > +                       if (sts == BLK_STS_OK) > > +                               rc = 0; > > +                       else if (blk_path_error(sts)) > > +                               rc = -EIO; > > +                       else { > > +                               rc = blk_status_to_errno(sts); > > +                               goto out; > > +                       } > > +               } > > Will SAM_STAT_CHECK_CONDITION be treated as an I/O error? Is that > what's > desired? If not, does that mean that scsi_result_to_blk_status() > shouldn't be used but instead that a custom SCSI result conversion is > needed? This mimics the logic for regular SCSI block I/O. By default, CHECK CONDITION indeed maps to a BLK_STS_IO_ERR, and will be treated as a path error. As you probably know, there are some exceptions that are handled in the SCSI mid-layer beforehand. For example, check_sense() sets DID_TARGET_FAILURE or DID_MEDIUM_ERROR for certain sense codes, which map to target errors. So yes, I think this is correct. > If __scsi_result_to_blk_status() is the right function to call, how > about making that function accept the driver status, host status, msg > and SAM status as four separate arguments such that the > __set_*_byte() > calls can be left out? > > > +                       char *argv[2] = { "fail_path", bdbuf }; > > Can the above array be declared static? How would that work? The function needs to be reentrant, and bdbuf is on the stack. I don't see an issue here, it's really just two pointers on the stack. Regards, Martin From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75CB0C433ED for ; Thu, 29 Apr 2021 21:08:46 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BF22C6143F for ; Thu, 29 Apr 2021 21:08:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BF22C6143F Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=tempfail smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-402-ZlJ6RSEvOcq4KTzMM2Flwg-1; Thu, 29 Apr 2021 17:08:42 -0400 X-MC-Unique: ZlJ6RSEvOcq4KTzMM2Flwg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DF918107ACE3; Thu, 29 Apr 2021 21:08:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0F2A15D9C6; Thu, 29 Apr 2021 21:08:37 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 65DDC4ED79; Thu, 29 Apr 2021 21:08:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13TL8U7K012218 for ; Thu, 29 Apr 2021 17:08:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 93EBC113B51; Thu, 29 Apr 2021 21:08:30 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8F01F113B79 for ; Thu, 29 Apr 2021 21:08:28 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 502C610115E2 for ; Thu, 29 Apr 2021 21:08:28 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-46-ASHM0huoPS69xZr47HIVBw-1; Thu, 29 Apr 2021 17:08:26 -0400 X-MC-Unique: ASHM0huoPS69xZr47HIVBw-1 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 6B6BFB20E; Thu, 29 Apr 2021 21:08:24 +0000 (UTC) Message-ID: <413c998fd75f6bc9c7f70d8a1a2b107b443a75a0.camel@suse.com> From: Martin Wilck To: Bart Van Assche , Mike Snitzer , Alasdair G Kergon , dm-devel@redhat.com, Hannes Reinecke Date: Thu, 29 Apr 2021 23:08:23 +0200 In-Reply-To: <5d1967f2-8017-c711-dec0-3ffe751974de@acm.org> References: <20210429155024.4947-1-mwilck@suse.com> <20210429155024.4947-3-mwilck@suse.com> <5d1967f2-8017-c711-dec0-3ffe751974de@acm.org> User-Agent: Evolution 3.38.4 MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 13TL8U7K012218 X-loop: dm-devel@redhat.com Cc: linux-block@vger.kernel.org, Bonzini , Paolo, Christoph Hellwig , Daniel Wagner Subject: Re: [dm-devel] [RFC PATCH v2 2/2] dm: add CONFIG_DM_MULTIPATH_SG_IO - failover for SG_IO on dm-multipath X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable On Thu, 2021-04-29 at 09:32 -0700, Bart Van Assche wrote: > On 4/29/21 8:50 AM, mwilck@suse.com=A0wrote: > > +=A0=A0=A0=A0=A0=A0=A0if (hdr.dxfer_len > (queue_max_hw_sectors(bdev->b= d_disk- > > >queue) << 9)) > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return -EIO; >=20 > How about using SECTOR_SHIFT instead of the number 9? no problem. That line was just copied from the scsi_ioctl code. >=20 > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 * Errors resulting from = invalid parameters > > shouldn't be retried > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 * on another path. > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 */ > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0switch (rc) { > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0case -ENOIOCTLCMD: > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0case -EFAULT: > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0case -EINVAL: > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0case -EPERM: > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0g= oto out; > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0default: > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0b= reak; > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0} >=20 > Will -ENOMEM result in an immediate retry? Is that what's desired? No, I overlooked that case. Thanks for pointing this out.=20 >=20 > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0if (rhdr.info & SG_INFO_C= HECK) { > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0i= nt result; > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0b= lk_status_t sts; > > + > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0_= _set_status_byte(&result, rhdr.status); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0_= _set_msg_byte(&result, rhdr.msg_status); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0_= _set_host_byte(&result, rhdr.host_status); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0_= _set_driver_byte(&result, > > rhdr.driver_status); > > + > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0s= ts =3D __scsi_result_to_blk_status(&result, > > result); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0r= hdr.host_status =3D host_byte(result); > > + > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/= * See if this is a target or path error. > > */ > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0i= f (sts =3D=3D BLK_STS_OK) > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0rc =3D 0; > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0e= lse if (blk_path_error(sts)) > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0rc =3D -EIO; > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0e= lse { > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0rc =3D blk_status_to_errno(sts); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0goto out; > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0} > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0} >=20 > Will SAM_STAT_CHECK_CONDITION be treated as an I/O error? Is that > what's > desired? If not, does that mean that scsi_result_to_blk_status() > shouldn't be used but instead that a custom SCSI result conversion is > needed? This mimics the logic for regular SCSI block I/O. By default, CHECK CONDITION indeed maps to a BLK_STS_IO_ERR, and will be treated as a path error. As you probably know, there are some exceptions that are handled in the SCSI mid-layer beforehand. For example, check_sense() sets DID_TARGET_FAILURE or DID_MEDIUM_ERROR for certain sense codes, which map to target errors. So yes, I think this is correct. > If __scsi_result_to_blk_status() is the right function to call, how > about making that function accept the driver status, host status, msg > and SAM status as four separate arguments such that the > __set_*_byte() > calls can be left out? >=20 > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0c= har *argv[2] =3D { "fail_path", bdbuf }; >=20 > Can the above array be declared static? How would that work? The function needs to be reentrant, and bdbuf is on the stack. I don't see an issue here, it's really just two pointers on the stack. Regards, Martin -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel