From patchwork Thu Jul 7 20:27:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12910222 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A377FC433EF for ; Thu, 7 Jul 2022 20:30:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657225801; h=from:from:sender:sender:reply-to:subject:subject: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=lLF0W9/0U4F+8Ma3ZYcuEV+fXLVp+7qJLSLE6YGtqXk=; b=VPagvv0r8NU4272UVxe+rbUIMemDZU4D/SBGMeTqcONR9JVc4/CqrkLhMZYYfCFqGweUAI FO6rfpHfjyAVexAYDhscvAXJqMILtpkc34sPCQSJeWnbmJ4nWgQQPgP/gitu5ET5moQWGG 1nvsyovgRrKCAGz9h8qu5gD3avvqR/M= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-536-RifvFKh_PpKFa1UQFIzhWA-1; Thu, 07 Jul 2022 16:30:00 -0400 X-MC-Unique: RifvFKh_PpKFa1UQFIzhWA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4E5A93C0E227; Thu, 7 Jul 2022 20:29:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 00B7D492CA4; Thu, 7 Jul 2022 20:29:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E6EA71947B82; Thu, 7 Jul 2022 20:29:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 17D251947069 for ; Thu, 7 Jul 2022 20:27:36 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0B0838287E; Thu, 7 Jul 2022 20:27:36 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 056182EFA1 for ; Thu, 7 Jul 2022 20:27:36 +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 DEDF3185A7B2 for ; Thu, 7 Jul 2022 20:27:35 +0000 (UTC) Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-30-Vh9ukYK0O9mZ4RBGCdyoSA-1; Thu, 07 Jul 2022 16:27:34 -0400 X-MC-Unique: Vh9ukYK0O9mZ4RBGCdyoSA-1 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 267KCRts003646; Thu, 7 Jul 2022 20:27:26 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3h4ubye25h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Jul 2022 20:27:25 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 267K9vNj017175; Thu, 7 Jul 2022 20:27:25 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3h4udfs6ue-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Jul 2022 20:27:25 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by CY4PR1001MB2261.namprd10.prod.outlook.com (2603:10b6:910:41::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.21; Thu, 7 Jul 2022 20:27:18 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::f81d:b8ef:c5a4:9c9b]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::f81d:b8ef:c5a4:9c9b%3]) with mapi id 15.20.5395.020; Thu, 7 Jul 2022 20:27:18 +0000 From: Mike Christie To: dm-devel@redhat.com, snitzer@redhat.com, hch@infradead.org Date: Thu, 7 Jul 2022 15:27:09 -0500 Message-Id: <20220707202711.10836-2-michael.christie@oracle.com> In-Reply-To: <20220707202711.10836-1-michael.christie@oracle.com> References: <20220707202711.10836-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR02CA0167.namprd02.prod.outlook.com (2603:10b6:5:332::34) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 10a31b1d-23cc-4283-e9cc-08da6057168d X-MS-TrafficTypeDiagnostic: CY4PR1001MB2261:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: tYaubLRRAGgzh0TNuHz9MB+JE/XNBvnCWYk5Ua00h4v2Lt3w96l56wVNvfSwdrM9hMUFVscN3Pbs4lxqWXmopZ4xx/kD9GZqVu4m4k5vud35ZRr5TR8H/hVzHeZh0D1yC2bhrwRM+wbQVfL2aRa7RZo85J5OXNBOzxSscZTHRakuilzFi4xJj+v8r4BjEd7JizX7XmpOg3eUV6Fi49+zm9DFG/1Bb+DIrd4gJQOqZV2D5Tld8R4NMk8Bs1R6oi7RbzK+4/O/gpCBD3LviPUUu7ZKQq8zITZi+P/Uc9SEgNt4fJ6rzf/UN1TJcth8a8M4XavavJSf0gXCmDnDTIAw9eVrtPdCcdtnK8ymavW7TGFTIu0oP89kZu9J0OXSCqsj82C0qbsR9+V971WCmEzMPqBZcVPv118s9ijBcuObSUZsDgp8uLtxhe6zMUaH92pD6SqPHPoTNktz376S3K9R+L7pnNnGxT2Yk4X6Hp7ObjjiC8V3lwHFAZJV+5a7VnEALknILeNebK4TyfW/N7JAlc0GwDmEHEHHNhHOe3Bt6FELjk6QeuTS+G1YHtcrRdgQfotsJw1rbU+kM9P+B6sxiqGHpVBgI+0ZOiN8nhBb2Xhnz5Q5B97fWyVVF9EJ/jpLv4AQFdCoHK0VMpBw1TNt0mOFFwH1uFDq6p2nyhE68Dc5zjBv/CI+4CnTXEP3kqu3P86LiX1MtXjxWR2mek1z21WCPUNEfFDAoQ2svgjvO2NHvbR9J86jlko7npYOKhPMvcJMUih34yRqk6YMCFaML104x6UOmSzHOpLZK9KwswQYD5f/+Z52hgmZlqkyKlX9 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(136003)(376002)(396003)(346002)(366004)(39860400002)(83380400001)(8936002)(1076003)(2616005)(2906002)(36756003)(86362001)(5660300002)(6512007)(8676002)(66476007)(66556008)(66946007)(38350700002)(6666004)(4326008)(6506007)(52116002)(478600001)(26005)(316002)(41300700001)(186003)(107886003)(6486002)(38100700002); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Wp3qM3/8NrC2pRLoX17jrIZQ8BdAJAplHyER+uQFq12lzOyScGICKNb1yI+dEPgW19yHqVFaY1QID7W3xyimH+iEXZuXWH+dBrvY63WxbFZR4MnxMJaai03fG1bPoV8ZL7B5k+4pSUiMnY8HBs9QdJ0Fr4nXyKJBeTEXWy7JZ60Bddx+3vmWIGrjrFA4TW4iC/29zqjINpeSLiWv8cqeWVNr2J/zwxBU/3FPtQEOylND/eyfPdc9rX0Fr8/C8hlyjzMwlytu7/TF8grRQvHmsmw4VEJS/lRJAL6vy4EYwS7oQ5rL/oujGLWYvqpPcG2DkxFxEYCNBHX6pDLhgluGou+GHu/bdoDzSPVTDMgqT0UFN56tOqeMrJ9gwgxePhglEVCRekz48FCBNFbWjje45qZGMIRo3uwePmjIf9zw6T5SmXFS0bnpZjD2f2vaLilqWFz+doRDt6Gw+arMvT2tsOrG5QgoLB+EnhuMJ+ZFwsMWHIDf6uQJNc+TWOAyzPXSTES8dOF95WnDy78qIj7oV5GSkK58lbwhbMwbxgkvPviYoBDUAmxeMv/d121e8FBz2aeWuLXfD4rDU/WzWhcMN2RTUjwNtnI0BPLOfQW9Q/kvuFf5K3r1aVhq1LEIw2JmNgoz77OaHj8q2xBXjU3TjhWLgh9kU3A5N4am/hf12FRooieM9lxOcSrWtylqrzD40NMwulRXZkrGOVJhvMJ/CFt+cuii0rNoL32b/sR2DSWgnIVzIn0LBLX2NPPCsJvHCV53Q4CAR1M5ysnMaGc2Jywyk3xJdCytN9fAwV/5Empg2o2q5hi087hCRv541pk2x8dFf7qSGlwf7WCVlI1LuReahi6AwMfzSNLQQeDTNhd39B9Ky1jroX6/jNpKi89QKBX3+AKvyMgly1AW+pvF4Zw7BbfNH4WQVZmNHhQKWkwo6crThZ51LvYRqu+oybZEcK5NgEQqmt2+KjYKYGDAVOySv+QC3gkHWfVQvj21jXG7RtGOn9supn9qeD6anztm51JlO65qX9FaQMOB/ROl5QDKap2M/6ROR9/62PMM2YcRA7jRH3XxOjzUSpen1WhLNmWENjK7xFhTXjedKqOHEeY82xlgp6EfivN5+kJPRtVPK/lVzLOJTV7A3p9wkzUfZzu3mC1x0ppj+cnCqGCSZ1e78DmHOJ8qEypnJHVIY1NdhIZjmiEi+dEEb6iEuF8WnCW6A+D2jCevUHhBerCs3HcVCmOflWymeHBi0RRePZi/Sb0KZ9oWprqvieoMsCW0VfHO3zY1PMc6DcO/m06gnJeftuRm3g/3S7MF6/VeQz3w6MRvLWG87gEau7RNkon7/i6BoV9FqAGSZV4i6HtHWHRGXY8x4TsKkTAsqJjKDHROUqQwPDAr0pZ/u45xxBHVhXkVW41FdGr+tLXZJzKrnQ9tpGQ3mnYIAkxcX0dTuEDbXuKybWjwE/0SuLXvpbaHTzu90prvHjdAZU7KvzYXtsEFVoHMOsDNvoTdFT7UYNFJJSkf/KPIP1FEZKrqsha51r/nq7fNI78HH/RpO7taDucVlhdkkSRwwv0BUtfT9VAXyO1zoyz+13zDRtbatgUg8BDhpS8r+hRpxqydsV/Zdg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 10a31b1d-23cc-4283-e9cc-08da6057168d X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2022 20:27:18.4885 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: OaFbcJY9SWvF89yNkt9Y9PnY4LTd667t9ESOe6u1dQCMbI/5P6xV6wIkjQJl6Dn0wGopGoAPHwotSAbguJ0/BCjREj0vyEjQBSwcEieArpA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1001MB2261 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517, 18.0.883 definitions=2022-07-07_17:2022-06-28, 2022-07-07 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 suspectscore=0 spamscore=0 malwarescore=0 mlxlogscore=841 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207070081 X-Proofpoint-GUID: 4yVZkZP4mptp3mYRJqJsujJndQJmAiX3 X-Proofpoint-ORIG-GUID: 4yVZkZP4mptp3mYRJqJsujJndQJmAiX3 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-Mimecast-Bulk-Signature: yes X-Mimecast-Spam-Signature: bulk X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Mailman-Approved-At: Thu, 07 Jul 2022 20:29:55 +0000 Subject: [dm-devel] [PATCH 1/3] dm: Allow dm_call_pr to be used for path searches X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mike Christie Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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 The specs state that if you send a reserve down a path that is already the holder success must be returned and if it goes down a path that is not the holder reservation conflict must be returned. Windows failover clustering will send a second reservation and expects that a device returns success. The problem for multipathing is that for an All Registrants reservation, we can send the reserve down any path but for all other reservation types there is one path that is the holder. To handle this we could add PR state to dm but that can get nasty. Look at target_core_pr.c for an example. It will also get more complicated because other initiators can change the state so we will have to add in async event/sense handling. This patchset tries to keep dm simple and keep just doing passthrough. This patch modifies dm_call_pr to be able to find the first usable path that can execute our pr_op then return. When dm_pr_reserve is converted to dm_call_pr in the next patch for the normal case we will use the same path for every reserve. Signed-off-by: Mike Christie --- drivers/md/dm.c | 51 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 2b75f1ef7386..67b46ae896b1 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -3047,10 +3047,11 @@ struct dm_pr { u64 new_key; u32 flags; bool fail_early; + int ret; }; static int dm_call_pr(struct block_device *bdev, iterate_devices_callout_fn fn, - void *data) + struct dm_pr *pr) { struct mapped_device *md = bdev->bd_disk->private_data; struct dm_table *table; @@ -3070,7 +3071,8 @@ static int dm_call_pr(struct block_device *bdev, iterate_devices_callout_fn fn, if (!ti->type->iterate_devices) goto out; - ret = ti->type->iterate_devices(ti, fn, data); + ti->type->iterate_devices(ti, fn, pr); + ret = 0; out: dm_put_live_table(md, srcu_idx); return ret; @@ -3084,10 +3086,24 @@ static int __dm_pr_register(struct dm_target *ti, struct dm_dev *dev, { struct dm_pr *pr = data; const struct pr_ops *ops = dev->bdev->bd_disk->fops->pr_ops; + int ret; + + if (!ops || !ops->pr_register) { + pr->ret = -EOPNOTSUPP; + return -1; + } + + ret = ops->pr_register(dev->bdev, pr->old_key, pr->new_key, pr->flags); + if (!ret) + return 0; + + if (!pr->ret) + pr->ret = ret; + + if (pr->fail_early) + return -1; - if (!ops || !ops->pr_register) - return -EOPNOTSUPP; - return ops->pr_register(dev->bdev, pr->old_key, pr->new_key, pr->flags); + return 0; } static int dm_pr_register(struct block_device *bdev, u64 old_key, u64 new_key, @@ -3098,19 +3114,28 @@ static int dm_pr_register(struct block_device *bdev, u64 old_key, u64 new_key, .new_key = new_key, .flags = flags, .fail_early = true, + .ret = 0, }; int ret; ret = dm_call_pr(bdev, __dm_pr_register, &pr); - if (ret && new_key) { - /* unregister all paths if we failed to register any path */ - pr.old_key = new_key; - pr.new_key = 0; - pr.flags = 0; - pr.fail_early = false; - dm_call_pr(bdev, __dm_pr_register, &pr); - } + if (ret) + /* Didn't even get to register a path */ + return ret; + + if (!pr.ret) + return 0; + ret = pr.ret; + + if (!new_key) + return ret; + /* unregister all paths if we failed to register any path */ + pr.old_key = new_key; + pr.new_key = 0; + pr.flags = 0; + pr.fail_early = false; + dm_call_pr(bdev, __dm_pr_register, &pr); return ret; } From patchwork Thu Jul 7 20:27:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12910223 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CA9FFC43334 for ; Thu, 7 Jul 2022 20:30:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657225801; h=from:from:sender:sender:reply-to:subject:subject: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=RacktUl3+gRxoCunrbK0Xvl4+9cBEOJ26AYEOKhtkKE=; b=NNMVIHepgsNzq3W1UiZU8ClLiRg851CkR4omp2Sf8CUSwMO9kktpATh7hztclJMirCYhxi tjt5yNQlKMwn5cgIZKr9FOM8LZTaX2yyg1ZEawU/jfnzN0SLuUmNSb7KCdcBsRH3Q0NVuX HuK+7gkyezCLQNW/R9NDwWswJwN9WLQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-553-bNlPxVpwPYmAEYpM3Y58Dg-1; Thu, 07 Jul 2022 16:30:00 -0400 X-MC-Unique: bNlPxVpwPYmAEYpM3Y58Dg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 37584805F63; Thu, 7 Jul 2022 20:29:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3FC06154E080; Thu, 7 Jul 2022 20:29:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CA5591947069; Thu, 7 Jul 2022 20:29:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 81BE9194704C for ; Thu, 7 Jul 2022 20:27:35 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 65010C28118; Thu, 7 Jul 2022 20:27:35 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast10.extmail.prod.ext.rdu2.redhat.com [10.11.55.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6032EC27DB3 for ; Thu, 7 Jul 2022 20:27:35 +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 446821C1BD22 for ; Thu, 7 Jul 2022 20:27:35 +0000 (UTC) Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-212-q4Gw3dceP-65hrsmKEuD3g-1; Thu, 07 Jul 2022 16:27:33 -0400 X-MC-Unique: q4Gw3dceP-65hrsmKEuD3g-1 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 267KCvGF020796; Thu, 7 Jul 2022 20:27:26 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3h4uby6bgs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Jul 2022 20:27:26 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 267K9vNk017175; Thu, 7 Jul 2022 20:27:25 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3h4udfs6ue-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Jul 2022 20:27:25 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by CY4PR1001MB2261.namprd10.prod.outlook.com (2603:10b6:910:41::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.21; Thu, 7 Jul 2022 20:27:19 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::f81d:b8ef:c5a4:9c9b]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::f81d:b8ef:c5a4:9c9b%3]) with mapi id 15.20.5395.020; Thu, 7 Jul 2022 20:27:19 +0000 From: Mike Christie To: dm-devel@redhat.com, snitzer@redhat.com, hch@infradead.org Date: Thu, 7 Jul 2022 15:27:10 -0500 Message-Id: <20220707202711.10836-3-michael.christie@oracle.com> In-Reply-To: <20220707202711.10836-1-michael.christie@oracle.com> References: <20220707202711.10836-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR02CA0167.namprd02.prod.outlook.com (2603:10b6:5:332::34) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 864e4e53-1479-4893-f810-08da605716de X-MS-TrafficTypeDiagnostic: CY4PR1001MB2261:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: Y9grQpl5o5gDAWt9CeMhwJcFk8QaMn/GlKlLM/r8zFrMHAjO1X7qLrMguwj9tS9sC9AIqjz/Ut9LlQlXAACtdg8UnUqT/8vTyZNtQvefyuCSkqN/Oq4rta6f5eNPP0ldk6u4XsIjTBnYw/bPduAL9iMcvlQipczhuDJW04JCoqQxTXhSvyzY5oWaJ1KOQVp2Swa7UQnytLNx2IY5EA4OKfOqFnikKRrJnSKPUjQllpDdKGf3SpOOyOXFzpZ8wfOV3WxBiQY3fZcLTHESMHMWOvdYSWBdNZSX4EFppHMupqYCX5GbJsek2HbHDdQf5ls8dfY2jOb/bEi83p4YKKXzSWt95H/uFmNaXBm3agz3HZREXablbTgm4dAqvXVK0NJ2tfWLmzYlFosp2N7Hu2Vvav5oNexoyEbL1e9M3h63dZbLccQwImGot2y25gOdPC4RFmsFh9pKsJPPcGVyi52ZigRyBsQzkT9RKzwpeWDePX8xNtsjcSipcfiLigAswPFAPzx5hqiOHoGUR3pq4x9iZarbjfJTFbMnjrb3+pSlnAshD/yrfIqHNs7+h3sYewKCIX/DGpT/DnWYzGczNqu8cZvJS9G6ea4jE/FcOSxFZi69g2cjeXF2DZalk91CjjlzuxczA2yeYHcIygq8yxHBEN2ZZcelkXTUTwPvAEoE+03+NLuODvikoSTWvm2XxFpw5lsT8ZV8YEFHCpaV8fqStobLuecvTgGZ21GFjET94AmfVTH/7L8RGAILbvmhK32HyI847PoJ9YfU4+dyQUWvyRz/urn40wqyjEVUJLu2J3Dr+L4cDIsfbjleLwMoq0p7 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(136003)(376002)(396003)(346002)(366004)(39860400002)(83380400001)(8936002)(1076003)(2616005)(2906002)(36756003)(86362001)(5660300002)(6512007)(8676002)(66476007)(66556008)(66946007)(38350700002)(6666004)(4326008)(6506007)(52116002)(478600001)(26005)(316002)(41300700001)(186003)(107886003)(6486002)(38100700002); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZkdfNj0En0bYZOVTi2VrF4GfJ5SW9z/TyIQlvSxWUW7JQZOfMfFKAxd8Jib6ajpxXEX+iGzFaE3V6YMQwnqXAnGLX6+atnZYMKVoUustcLJo9dqX+pdnScOxIXJmSiSsuJ/XGfGU5J0iLG2LyLiIwwVXl94oocXgMBdF1Nl81ADWc2OEMgQ549hR2L47YtCZyN84I7wqEL6l/YXzE6ykGDKCCs68gbztcDBJVKjYrpeAu0o44GquPIn4cwHKQ4zGswSii4tUEV9NWaMwigr17dYrhri6XLPP6lGrGhHs7KoSLtDmkBhfsIdw90O1Vf9x9RRSnneRjcF2GwhfwpK/JR1Rw7ZYM9dXVjpHh+W9lBZ9E2n2l+FpTN76/HGiRBgluFZlBepSAKFbHPdCAHGwo81AMMtpsxHw/dn3X3G8U0LoJmOtn592pt4wJRacY93DHodMICwt6n65HItBKa9RoOaE19Cu4nkSAM2Yciq/f+jhepwCgf5ENSEmi+Bv3q5xTy0LQ9MC8bI/NAp+jt01Ux7rR6vq7oU+8+wbDo1CS86zdd5T2rwdkvoIgF/yXAXPsPgsiFNl/PNeOIpkmifoov8RtWNBO6oUdpAZ/7ntddZW1wZQEloRvjcaIOFsjIDYlPoIApWzM5QjgfM59SArrBaigFvpD4BkZj+8J+4FcV3EWK6rPoVQd5pji8axNoAWOv7LUXDiecxE8Q5bz6JFW9rvZKfubcnzB73CA9yDe6o4GY8o0cIaZST0tnLOvRdnitzt0JryInX32oDabr9VftRAjJ90Y6m3b+awdGWs5X9el+NzvSeuzi6qH6jZtq/TD9zokoWdA9BFCWEUqFYIANSOifxP06W3TvSEftHKVhFUHUg4zfPZ+s16VucKpdIPdKC7d5BnaoDJrSTrKEjkFmlCCSINRoRZIU9C/IdpMBKRw0Hw0NL+AugmOUQwf6e9gCmkvjq2kjCZhWYimsh9xXwhqJvc/gK/hO4yZDPs3KjbTaPiyNuGZSw4oCfKCBb8oGJFX7RCNwvrDnBFDHLOzQdR1ydco1WqvYV4L801Dj6eiSERnA8hfv1kYUPpNjPtXlchC8mGSiT1P2SmbGxlm4IlucpiH8d6rnbnHbtcFEIUyMvN9VT7be//OD1tBrHrGkdDsXkwl4LHM79MFt5aLGm60KzMIQhYxbTOGPk+eCrjOEbh10Zw8CVeRld/mtgR07jQryfczNkR64N0Sp3fE0uoWJdbcxG/UxFxiGxrq8qCgr0doDoNa5bZaJmJrNTH8MPMa3YrqRZmm3SRAEFY1mA1NFPc+CtozgIt+ZoKckHmlJjT9vzhceGEvc9whfRJ/Ze/Qju6EdFU/4ZVxSR4UEGstgeWItuzrQ4VsD8mRjU5GqcTALDEevNFkov+/za9uzexZOcvzUllJNwtmujeBlgGZZUEerwP/7qP4Xv1u57Mwui5n8AqxUYq+Eh+N+zZ3v8TiLqtkqMJc7IdTvjecJGTRKnCseSWk2mCuVALL3z4QcZSZllMc8iNqfPVnin++9rkk6bt8OyhzqufZTl2ka+pvAUdhgqG/LYZDt9Lr83/9QChPm6ZUAQ1aQAQpdvxWAwqf1VCaccyWN3sVVt9Og== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 864e4e53-1479-4893-f810-08da605716de X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2022 20:27:19.0041 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hrkbkySpCsYZnBiW6HBAgqP6VGrsYZ78ZFub/c+PHlq6xz+mGfcMHyQxrIXi7DkCfT7LgKBn30fZ+UITtZgaeGiR9NfUDHybD8dw4boZfyw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1001MB2261 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517, 18.0.883 definitions=2022-07-07_17:2022-06-28, 2022-07-07 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 suspectscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207070081 X-Proofpoint-ORIG-GUID: YXJTg61yaFBUIkBxVd7szGd-cuOQdGqV X-Proofpoint-GUID: YXJTg61yaFBUIkBxVd7szGd-cuOQdGqV 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.85 on 10.11.54.8 X-Mailman-Approved-At: Thu, 07 Jul 2022 20:29:55 +0000 Subject: [dm-devel] [PATCH 2/3] dm: Start pr_reserve from the same starting path X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mike Christie Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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 When an app does a pr_reserve it will go to whatever path we happen to be using at the time. This can result in errors where the app does a second pr_reserve call and expects success but gets a failure becuase the reserve is not done on the holder's path. This patch has us always start trying to do reserves from the first path in the first group. Signed-off-by: Mike Christie --- drivers/md/dm.c | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 67b46ae896b1..cdd1656b99d6 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -3048,6 +3048,7 @@ struct dm_pr { u32 flags; bool fail_early; int ret; + enum pr_type type; }; static int dm_call_pr(struct block_device *bdev, iterate_devices_callout_fn fn, @@ -3139,25 +3140,42 @@ static int dm_pr_register(struct block_device *bdev, u64 old_key, u64 new_key, return ret; } + +static int __dm_pr_reserve(struct dm_target *ti, struct dm_dev *dev, + sector_t start, sector_t len, void *data) +{ + struct dm_pr *pr = data; + const struct pr_ops *ops = dev->bdev->bd_disk->fops->pr_ops; + + if (!ops || !ops->pr_reserve) { + pr->ret = -EOPNOTSUPP; + return -1; + } + + pr->ret = ops->pr_reserve(dev->bdev, pr->old_key, pr->type, pr->flags); + if (!pr->ret) + return -1; + + return 0; +} + static int dm_pr_reserve(struct block_device *bdev, u64 key, enum pr_type type, u32 flags) { - struct mapped_device *md = bdev->bd_disk->private_data; - const struct pr_ops *ops; - int r, srcu_idx; + struct dm_pr pr = { + .old_key = key, + .flags = flags, + .type = type, + .fail_early = false, + .ret = 0, + }; + int ret; - r = dm_prepare_ioctl(md, &srcu_idx, &bdev); - if (r < 0) - goto out; + ret = dm_call_pr(bdev, __dm_pr_reserve, &pr); + if (ret) + return ret; - ops = bdev->bd_disk->fops->pr_ops; - if (ops && ops->pr_reserve) - r = ops->pr_reserve(bdev, key, type, flags); - else - r = -EOPNOTSUPP; -out: - dm_unprepare_ioctl(md, srcu_idx); - return r; + return pr.ret; } static int dm_pr_release(struct block_device *bdev, u64 key, enum pr_type type) From patchwork Thu Jul 7 20:27:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12910225 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 3A16DCCA479 for ; Thu, 7 Jul 2022 20:30:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657225807; h=from:from:sender:sender:reply-to:subject:subject: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=6dASHQIo5WZQmiPr/UGmmdVTnQDvbcirWcO50gk2LIo=; b=B9WNl60c0b3OLdMvnJjoGS4XVQjHqdW/BJERnGEXqJzDQGceo2FqVdUOgrv1UJOMW9Ye0s baTLruBsObGIFUc4UNsZVQ1klZS7tIqG/us30VXWZPiDf9UQdx9w5ismFLlpON7kb1SXjg ldhpnn636W8v9AcaY5wOtuMQIj78KGQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-508-W6or3w6xPGm3RJgUqU9ygg-1; Thu, 07 Jul 2022 16:29:59 -0400 X-MC-Unique: W6or3w6xPGm3RJgUqU9ygg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 35ED2805F53; Thu, 7 Jul 2022 20:29:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91B03404C6DE; Thu, 7 Jul 2022 20:29:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AC895194707F; Thu, 7 Jul 2022 20:29:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D6C27194704C for ; Thu, 7 Jul 2022 20:27:35 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B970B40357BA; Thu, 7 Jul 2022 20:27:35 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B44E2407EE6A for ; Thu, 7 Jul 2022 20:27:35 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.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 963AA963482 for ; Thu, 7 Jul 2022 20:27:35 +0000 (UTC) Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-641-y8tIttd6NRyWket8DuTciw-1; Thu, 07 Jul 2022 16:27:33 -0400 X-MC-Unique: y8tIttd6NRyWket8DuTciw-1 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 267KCLk0020294; Thu, 7 Jul 2022 20:27:27 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3h4uby6bgt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Jul 2022 20:27:26 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 267K9vNl017175; Thu, 7 Jul 2022 20:27:25 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3h4udfs6ue-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Jul 2022 20:27:25 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by CY4PR1001MB2261.namprd10.prod.outlook.com (2603:10b6:910:41::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.21; Thu, 7 Jul 2022 20:27:19 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::f81d:b8ef:c5a4:9c9b]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::f81d:b8ef:c5a4:9c9b%3]) with mapi id 15.20.5395.020; Thu, 7 Jul 2022 20:27:19 +0000 From: Mike Christie To: dm-devel@redhat.com, snitzer@redhat.com, hch@infradead.org Date: Thu, 7 Jul 2022 15:27:11 -0500 Message-Id: <20220707202711.10836-4-michael.christie@oracle.com> In-Reply-To: <20220707202711.10836-1-michael.christie@oracle.com> References: <20220707202711.10836-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR02CA0167.namprd02.prod.outlook.com (2603:10b6:5:332::34) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dc5f18b5-f759-42a2-41c7-08da6057172b X-MS-TrafficTypeDiagnostic: CY4PR1001MB2261:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: FFz6G2l2AndU4pu0vBDuzt4uaKIcWIJhjlc13RZeMsYUPgMv+EnI4lZp6OsRYn63oYphkVgkl5r4FD9/6VYsRlrNhRRgI2221/Lz/Ry66+hYLKAEB1PvGnngSMoWAtSiSLfJiJYqdOijI7uofFB47GxHE/j8AFAtwMsITgXilCbThBtJW9FDFZvA+MvX24NNchfFcScOaABIR/mrEHYbdKOYiM/YR7LjM6wTEZBiZVWAS5vCqeCKy96Wg7b5HkPbeGc/UMGeRov9qwCmOi4w87lt65SUb8lN6qyxjE1lSjUEnk1JP4IOFCuSNBITOkCxAESwlIlrEtaRlP0ZdeLv8k8e66bK4wT5YJ/aSPjeV+5W5PgfOnJDNwQjQXhjBoXw/i8i8vKgrH+QfBuhSzbJW1Q/XQ/OICFs6ambHEqKkCgpf3lkCfuHY1Zf8m7e7F3qlQYOuQ4bDPV/CcXq4iZwsrPP4lHns9gGKeEsItrS3ZFdLYJ3iTmTlKIJl6viKrpiNn6+d9I49oKDh5DfXcVzbRS+W6tNCHnTL1eYF7xi/CLeS7kW4rJbwc3rJAxdMxHV59GneYAlC4jAeLNoHuyQpEfriUmhy7lZUm9mHIaS/Gyyrw98U7k/a0BmIOFvk57kjnBFBC0zmpHYuRnzarBUdw9afVT/XXWy1qo3/XPFNdiIWMQsvwEtmi3ubDRTlJYXxxtFj85fLMa80LEReO/erGqGIwaGlXbM2Z53GBbnk2rR6hWDc/z3FPw/KdvCnI+4aocFbizkEvkd3dnwJwxeCT4JWCOwbFTTDmdV0v/M4mBnHEANbZv7ObZwPkWdheCQ X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(136003)(376002)(396003)(346002)(366004)(39860400002)(83380400001)(8936002)(1076003)(2616005)(2906002)(36756003)(86362001)(5660300002)(6512007)(8676002)(66476007)(66556008)(66946007)(38350700002)(6666004)(4326008)(6506007)(52116002)(478600001)(26005)(316002)(41300700001)(186003)(107886003)(6486002)(38100700002); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WoUPMT29s+0Mxm/iof6+tE8B4VHkz+wSj5X6VchucraWHn/j6l4JyBSOhTd8tsoM3EEZzka3NIrG9umclIO3zRx/e9jer0q5/VOdbdanrKSDb9H0CPYp8GRLqGpFA6sRZrLsSuguRjSYYbO8k7G53ouL71ojsF+q9ZTaFGg6aAG4/EEMo83lImSnhnn+18sBPCAq7pMRfaFVGveRepS+RM6M7em1I1ZDSjis9URZSf1SR8F/OFSHHhfSGmuMGIzMahBTaJP2inwDjysKzyLNv7rAXHrmT5QkYAMq8hPUlyscVjym0UsxYsa4s3/LaQS0T3ZCGdaTQsSfkvQ8+yPJfUNYChijpQI6oMC9vZRHn/Arkq36hLVz9KtDKcPUw6Wq4jFz36/7X+/g5PRTXem4GfG2NUDCihS4rOxLtB+4oWJ4oNh76/4io19ydXh4H3H+RrmZGKxW6pqDxPalRdfbxvZhNQWigWqV1FX9Ayr7U7+f8iewCtCEdWkclLM5gLeALzAEHGEN2fNQb2l9i91dviO/VYsN9372YbvM5QY3QR4QWehUpMdB6H8PWZdlgyMHnMEyFCYdyhe1WGfVWnQScr5w9MHPuXrE0sudKWmRS0JH84JXTOfomg51Ho8sqrw/nPvgI/xQ9J568si87MldJXFwGACNP/ehBMlkpfeSoyrYd/HgHmmjlntIe8XDGcnyvrS5VyvzCVBLSqV9sA9lLFj0LzBuKAJxYvpfCW3hu6jeM1Mx3F5ojWkd9oEW1aOAV75PqQLm/lQknYFU+uug8QprnyaKAmvqpxRX/EKrhsdBGkdSiWha5YvBsRHvAlBH2Oy/XIgvQD1Z8+QU7y3oVvyyA/Y7S4thdEmcTgxJ29eCqFQwt+oKrmWeEhn2O5Yx7yyXnV2mq9Pj+TPgarQtoE3sfxO7VVCqzZHLZ7MaMQq6acQZR/E3Ln4filpfMDPTTh83kWbL56TQZyCKTaA8SezvJf9mNV0eGShCZB92DV2Yv3hAfsOEGiAxFvoMLFMbPHyCqqk26DawUiFuI0QkjUoeRLzFNUSfWOOqdIAdAJwyn4bzYVaRWIvPHAM/JQMYgeH2t9VPHw+m266L1rlYOdRINcNQu8aiRr3fR6LEOHNlStB6JvQ45iXdcMosoCb9SGRZtG+FL9Vk3TEvwuaaTjsmFNmQxAs7voNBizr8A1Z722iv/r0qCrx9E0BFOIJift8p7bIDyCy6cp+Y4RmLMmKHrAOFSpuvvDL8iG3kMuzOgaO3JQ8FuYJPSaI5Sa5TpwMNivaLSkUP+c95LYQrXaAw76tK6XD6L7ueH2pbcY9Eqn+df+JjioTosya8J+b/62sfwrFJZ9U7k6SXVbDZIDO6WVehIsAGQA0dyuIbhWfnp0qxWo4LNfSqCzWJlwxiszR7S3RRJJs0+xDnG+OD/NFYW+UfRfB1hGdAG+XcDig0hJyt1q5RNjLgZgdnG2wZh6n8Kg4id/i4+OCd49y9N/Axt7f7Nb4L1CTpmsux1SkqgRZ/oy/HAxRbau70oHeQuxc/7bfyyPjDSkugq/0aKWvGZ1zsU2ciqSl3kRo/9b5BKhZ5KVF1WjwtHYvR+Ui6rcsiWEmG5ZT8XcMbap7JWg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: dc5f18b5-f759-42a2-41c7-08da6057172b X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2022 20:27:19.4884 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: idw84gwX+mJCzWvmLxtwwN40cJeZd1UUj6l4QlmGt2BbNwx6T1XKDxFt3hSZMFTldvHYbUoXDrHqx18jwTAPna8X7yEgQQIDjou4cA0pkSE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1001MB2261 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517, 18.0.883 definitions=2022-07-07_17:2022-06-28, 2022-07-07 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 suspectscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207070081 X-Proofpoint-ORIG-GUID: ZMV9PK7m3qlBkDKXIGYUwXJfNP6QHjGk X-Proofpoint-GUID: ZMV9PK7m3qlBkDKXIGYUwXJfNP6QHjGk 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.84 on 10.11.54.2 X-Mailman-Approved-At: Thu, 07 Jul 2022 20:29:55 +0000 Subject: [dm-devel] [PATCH 3/3] dm: Fix PR release handling for non All Registrants X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mike Christie Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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 This patch fixes a bug where we are leaving the reservation in place even though pr_release has run and returned success. If we have a Write Exclusive, Exclusive Access, or Write/Exclusive Registrants only reservation, the release must be sent down the path that is the reservation holder. The problem is multipath_prepare_ioctl most likely selected path N for the reservation, then later when we do the release multipath_prepare_ioctl will select a completely different path. The device will then return success becuase the nvme and scsi specs say to return success if there is no reservation or if the release is sent down from a path that is not the holder. We then think we have released the reservation. This patch has us loop over each path and send a release so we can make sure the release is executed on the correct path. Signed-off-by: Mike Christie --- drivers/md/dm.c | 48 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index cdd1656b99d6..c31f99c9d2b2 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -3178,24 +3178,44 @@ static int dm_pr_reserve(struct block_device *bdev, u64 key, enum pr_type type, return pr.ret; } +/* + * If there is a non-All Registrants type of reservation, the release must be + * sent down the holding path. For the cases where there is no reservation or + * the path is not the holder the device will also return success, so we must + * try each path to make sure we got the correct path. + */ +static int __dm_pr_release(struct dm_target *ti, struct dm_dev *dev, + sector_t start, sector_t len, void *data) +{ + struct dm_pr *pr = data; + const struct pr_ops *ops = dev->bdev->bd_disk->fops->pr_ops; + + if (!ops || !ops->pr_release) { + pr->ret = -EOPNOTSUPP; + return -1; + } + + pr->ret = ops->pr_release(dev->bdev, pr->old_key, pr->type); + if (pr->ret) + return -1; + + return 0; +} + static int dm_pr_release(struct block_device *bdev, u64 key, enum pr_type type) { - struct mapped_device *md = bdev->bd_disk->private_data; - const struct pr_ops *ops; - int r, srcu_idx; + struct dm_pr pr = { + .old_key = key, + .type = type, + .fail_early = false, + }; + int ret; - r = dm_prepare_ioctl(md, &srcu_idx, &bdev); - if (r < 0) - goto out; + ret = dm_call_pr(bdev, __dm_pr_release, &pr); + if (ret) + return ret; - ops = bdev->bd_disk->fops->pr_ops; - if (ops && ops->pr_release) - r = ops->pr_release(bdev, key, type); - else - r = -EOPNOTSUPP; -out: - dm_unprepare_ioctl(md, srcu_idx); - return r; + return pr.ret; } static int dm_pr_preempt(struct block_device *bdev, u64 old_key, u64 new_key,