From patchwork Sun Jul 17 22:45:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12920673 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 8FCC7C43334 for ; Sun, 17 Jul 2022 22:45:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658097952; 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=lkA1HMu6kPJofQj533+gu1plaYOQvY/l682R6gq4KHs=; b=ViXMphrN1T1YpaI4l0V970W1eXZJUhyFDeogajkhUe71m987F8uArULh4UKLPiabiS/Vt6 lvOVOMO3Y0rAqgX33qdsrxZd9wxswG2wlLa5Kd/E4ujbL6++pBeWQrt2cUDW+t0N62VG/V 8+Y69TSgPEww552yCtnbNKQt8LYBz3I= 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-528-81csthcmMTqWoqDZ2AAJYQ-1; Sun, 17 Jul 2022 18:45:49 -0400 X-MC-Unique: 81csthcmMTqWoqDZ2AAJYQ-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 E0D9D185A79C; Sun, 17 Jul 2022 22:45:47 +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 CC6F0492C3B; Sun, 17 Jul 2022 22:45:47 +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 AC5A61947054; Sun, 17 Jul 2022 22:45:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1D5841947054 for ; Sun, 17 Jul 2022 22:45:47 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 03F8B400DFC9; Sun, 17 Jul 2022 22:45:47 +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 F369B40CF8E8 for ; Sun, 17 Jul 2022 22:45:46 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (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 D86F91019C8D for ; Sun, 17 Jul 2022 22:45:46 +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-124-SY7JnvaUOVal0iWXOpCs6w-1; Sun, 17 Jul 2022 18:45:35 -0400 X-MC-Unique: SY7JnvaUOVal0iWXOpCs6w-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 26H94EYv023597; Sun, 17 Jul 2022 22:45:25 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 3hbmxs1uvk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 17 Jul 2022 22:45:25 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 26HJc6rY004037; Sun, 17 Jul 2022 22:45:24 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2173.outbound.protection.outlook.com [104.47.55.173]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3hc1k3bras-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 17 Jul 2022 22:45:24 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM6PR10MB4137.namprd10.prod.outlook.com (2603:10b6:5:217::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.19; Sun, 17 Jul 2022 22:45:17 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50%6]) with mapi id 15.20.5438.023; Sun, 17 Jul 2022 22:45:17 +0000 From: Mike Christie To: dm-devel@redhat.com, snitzer@redhat.com, hch@infradead.org Date: Sun, 17 Jul 2022 17:45:05 -0500 Message-Id: <20220717224508.10404-2-michael.christie@oracle.com> In-Reply-To: <20220717224508.10404-1-michael.christie@oracle.com> References: <20220717224508.10404-1-michael.christie@oracle.com> X-ClientProxiedBy: CH0PR04CA0009.namprd04.prod.outlook.com (2603:10b6:610:76::14) 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: b5bf14ee-6b92-4ffc-5a83-08da684604d7 X-MS-TrafficTypeDiagnostic: DM6PR10MB4137:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: oC7Y8+3ijJsMPriNV0RhIH5ALPlqHZIe9cUbPc/X4h+IBb3sc7yWB9U1Gaelp6v/4FXTm28QJBZpsAmy5YvGnk5Mw+hzU+FmfA3QWDb0kBhPJH2AyYVqs9xTsPcHDIl61tZKkzr6Ha+lqGGqmTPy0iD/a8b2f7+2pp0dGtePQ1F4+5hsQBolslYkE+EnuqzZwk853qzcAzAEq0pGnrfF67C4kf6pnzkRZC/aMwbQNgc/FnqZWyrf5fXqtfja4eQtR9PIXXyfDQdenZyNtnnAQwOvGVBxi+DviBLidwEuKnRNtLs+XECGSBWMPxi1g8jezDnAzxNpG2/STYPYsRNlfpcMtGgeIlsrT03LiSQogQR8CPXre/NeyOQ/6fKJR9ywm5y1bFhDfiWRg6UZqfZmlY+fXDllMQc3sTh9hwG/5Z1oGZyBN0f1tzwd0adLllD175CEB48MzFQquoR23D5I8mAhDPLWRPFNsdMgDcctH+89X9IPomthT0IQ3Ots3BMIy/Z7L1wf3avHR/3Sjh0ECnCsktqLAzY4yGD1LNUvq6Pim+L8/1sjSSdujPlvIwzTtBA3NAEtlWvZMuyfFDjQSNU9Di2BtxQMCtJkUE0oUKu6Eq/Mkvimq4JDAyLQFlCk4wcxz51camDDHKIrXvxhaSYcomuDGRVfh7yXww36GDcWDp4/8eEMQP/MSpxAIVjJDSthlfMro+v+Sq3XypNNfniOVdOfZAN4JI/oeJv3jc9syw/JbMdixyMDxxAkzroy2AdS2mIKg09Z/2TETBqw5BY2MfV2pz+D2gaCCcaHf3oMC8MkNAMy4+xSyrDmpXWC 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)(396003)(376002)(136003)(346002)(39860400002)(366004)(316002)(36756003)(2616005)(6512007)(38350700002)(26005)(38100700002)(1076003)(107886003)(186003)(83380400001)(6666004)(4326008)(8676002)(66946007)(5660300002)(8936002)(2906002)(41300700001)(52116002)(66476007)(86362001)(6506007)(66556008)(478600001)(6486002); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nIub+Kc6rG1Ljjw4kUCBRsdt3wTtQFUwzrxxNiyeh9/ftE0NLYPB+Mj7bF7FJzEqGKeZGo+ejgTEfOGENtJ99xlR400HirbiiuLGfx2NJbTD3csKxg2VIKBzQqcoRkjIfZAKDxqt3nUG0Ra+4EyLOYoIubUYxtUt4fK7ke65yUrgtVub+CrSmW9v1BKTtZx82Wlb6cw91fDDbIdXYIJ6f8GZw8O3RBtyHhoFRAJCkFDY9ifwPmGXrLwIsW8qF7vGM418rjS2X/J54S+t6mVZPyeRTaOgt+aTqoqkZh8oPVm+hbQQL83+6hrPMLBZIeeKB/61dR58USJ4fOZKDJnH8ozoS9rRLC7G9JLfEH4hB00lJ42JWf10WPgaRWV8MzidM3HnbeadBBuFIRhh9MnYaS1olXUwr8OlYaMIdrZ0FPQXMJdiSfzVeuBQ8g/6yND+c4mX+ozm9G4YlMjwiMG1y0+8kGPGGj0bl1/ZJlcf4U7wUipNOCm3Rs647gfxA7+Gf/vioMKjld+0rqlLrDtO7I+VSexJvkj3acgP75UEoFwV3siT+MGI69DuMGgFtxAlUIbms+MOu7/dshqagEQD/pEW9YCZALsYU1QU39sbsJ21eGpICK7jMJHBNMzYHAp6K/fdIic5FMuha2tfSBJiaG7ZAhY5CyZ+lNiEVU7CCFUAMyWoCNIaZuFyExJoRhffvhfACLPevsV4P7G843IuEp7XmXsocKydS64xNSMqvIKyaTbQr0gO01JCLEYTWbQYRzVFtleZiDtAwViLhZtGNbqlX6BZUry6ED4gyZjyBbexEQXXo7foncFpIBHg3vCIUJmoe/meM3viIbFUyGzd38u+oIgHfJn/n0L/NYiSkXbpA3I9ZQjgjRkq4oeXDRTeIAGEvdMkD0EL/jLZxIwvLzEC0SCVD/TTNyjgrFMnRB0XDJlLSC5QcO7VnfVscmPuwiv5MjKL6gB815rVdmM+eaiWxMYzh96/abD0dcGIi/6+bCWfjERTSRr2mvHnavL+pK+kb1UvWil2m/g2cWzvSXuNnlGEg75CVPDiCRhrtweyKBJnFxMY4KAmQcCjisizz+mUFAogzeg81Vyyi9V5CEGvWzLp2IZgTfeTIZxQYisVJeqWz+TMb+UB52UCBbou+fjCTFcoGr5WFm00uEW0OukBWcnlhln3zSWItufFuYr4ycURKb7KeVoUSbtR7K4wpBwmQwCursd/GQvNZOpc5acsMFbNdWA87iosZNbmSeb7gqdWHs0lt3NKl5sXFBkOzqY2Zp4yX0epKl2XvIm/eD8cVa89zj/MWKAYMcBlSnjkDaMyjmW/fW8quXmrWa/sYRTWGB2H71VE3BxmnI1hbHuB5O9ACHGLgOQjNLCpQkHoyfNSY5KQajsJQjyg2q2c57QH7ZrqKxJgaRRRzhyU4Op6Hk03PRRXVBJg49ocgSc8qCDiynnUT6M3GAr39ujMxXDd+17l7c0qVzUQvq177DCNom1GUnopqQAiaGT76034hsKE2OrwHoiXaWqq0aE7QATmkeL98xMijCVdi4LBtDOhxaTyn53mr6sN9nFM1D5GBM3TkCWSOwJAUBHnFvk5fnmWR7CyZGhlHneHfbJMYw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b5bf14ee-6b92-4ffc-5a83-08da684604d7 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2022 22:45:16.5974 (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: 3KApA8n17+W9Ei1qNLIypzla+GQ3lEfxMyXu8M13Ympr1Fg6JJqyiPIyujqzCYAaABkvaJtwpchoUwmUUglXbZeeCzOGWpzbmu/c/POI6CM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4137 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-17_16,2022-07-15_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 mlxlogscore=833 malwarescore=0 adultscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207170108 X-Proofpoint-GUID: uYqfyh9nuO_HI0c1vLaFrzA-CkF_G-uu X-Proofpoint-ORIG-GUID: uYqfyh9nuO_HI0c1vLaFrzA-CkF_G-uu 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.84 on 10.11.54.1 Subject: [dm-devel] [PATCH v2 1/4] 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 of the type things we will have to track. 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 Sun Jul 17 22:45:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12920671 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 F139AC43334 for ; Sun, 17 Jul 2022 22:45:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658097947; 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=rqSNQcaKcqs/zhDyx18bA0Xphwo18LG4y5d/wwEMgZ8=; b=XqwqPAr3lLvO4qPAQ0nUfSRe4FbIpGykIzqL1crUoDUk91BGkyvrm6LYC4/AK8fuJHwjMT EOXvCyWKj4CWBdwU89E3jU+JDlNDraHoARZfsAoDp9F4YADcwmpwPRIk28Ye/K+aOYug/j qf7/2fU6GX5wFthf4rKXVxw+OqhqomY= 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-359-_jHJH2qUOpmELqqjlLeUuA-1; Sun, 17 Jul 2022 18:45:43 -0400 X-MC-Unique: _jHJH2qUOpmELqqjlLeUuA-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 BEEDC1019DE1; Sun, 17 Jul 2022 22:45:41 +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 E3A38492CA2; Sun, 17 Jul 2022 22:45:40 +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 BA05B194704E; Sun, 17 Jul 2022 22:45:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 03ED6194704A for ; Sun, 17 Jul 2022 22:45:39 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EBB532026D64; Sun, 17 Jul 2022 22:45:38 +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 E6A2A2027EB4 for ; Sun, 17 Jul 2022 22:45:38 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (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 C481C801755 for ; Sun, 17 Jul 2022 22:45:38 +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-589-h1kfqEVyNY6KJs1xvChpiA-1; Sun, 17 Jul 2022 18:45:36 -0400 X-MC-Unique: h1kfqEVyNY6KJs1xvChpiA-1 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26H94FbI018603; Sun, 17 Jul 2022 22:45:25 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 3hbnvt9uqa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 17 Jul 2022 22:45:25 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 26HJc6rZ004037; Sun, 17 Jul 2022 22:45:24 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2173.outbound.protection.outlook.com [104.47.55.173]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3hc1k3bras-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 17 Jul 2022 22:45:24 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM6PR10MB4137.namprd10.prod.outlook.com (2603:10b6:5:217::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.19; Sun, 17 Jul 2022 22:45:17 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50%6]) with mapi id 15.20.5438.023; Sun, 17 Jul 2022 22:45:17 +0000 From: Mike Christie To: dm-devel@redhat.com, snitzer@redhat.com, hch@infradead.org Date: Sun, 17 Jul 2022 17:45:06 -0500 Message-Id: <20220717224508.10404-3-michael.christie@oracle.com> In-Reply-To: <20220717224508.10404-1-michael.christie@oracle.com> References: <20220717224508.10404-1-michael.christie@oracle.com> X-ClientProxiedBy: CH0PR04CA0009.namprd04.prod.outlook.com (2603:10b6:610:76::14) 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: bf142fde-6385-4195-91c2-08da68460510 X-MS-TrafficTypeDiagnostic: DM6PR10MB4137:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: 2h0Z/DakWjwTyz2txH6aWyJEPda7bBUIlwEfC9vpOTqyJ04OCH3hBIc2pvIOwDERMkAuINSM+bs1iA1t5/o7tQDuZR7VXRlVZmEcCHVgNB0HIv5lB55C0i05OCeiq32bMOFUcb0f4SRv7abPA70fndyINS65kPSXIK8Pb7zE/nHmcdSmImntV0DlC4b02JSF2b3z+q6Wv+6fJq7qLBYuVPFQ5swEJMnwM3sDr+sr1PA0mZCcRGQMMDsoGN3/JarvxxIdB8EEmW6F+7LkyA/ArH4I2c72euwEXTLui2hpFpLuNJ6ua7i43ftB05tVcxZVRIaLuVijWZIf0kevYBoRZjwxycVf6q41NoUZ0BrUMImJy3nIMff+rSuffmwZxl1bcjqTTRsaWU1XcGF/r3Jsv57Mce6Y3TcqxzOJqYxwYTvEGEETj2q5xcSqqcZjZogoliRsv/c0rKiBn/MI055YVq1gOm+bjAa9COvmC06gjSbUnZJs6geXXtHjGNk0yD2BqNbzvQf9DbzESyGp797Vve/kgk9uAJxndSM+24OMDlAW8bLDygReUiK5PPuB23J85Liv+PFP/Xv7BnYJzdVyUfM8BhW3WPUOuKzOkMv8nAkZ2jmdrIfRY2kI4+rV/k14t6MZkhdhDu07+w62udGEUgxkzGbHyzzPnRvOcYWffPvMaxNBZ66+s4zZFH9hd5bWagfySnZ0/kCNyFPFuU7dGW5mBvUNKCBPOaokPy4Y4qB6Xm5umA71cQ4AkmKItNVCaoY88HLhS7Em2tz3433ne/km556c3PtZaD8YrTHno6PdOrf9t4R+pmw2m/YXhJiH 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)(396003)(376002)(136003)(346002)(39860400002)(366004)(316002)(36756003)(2616005)(6512007)(38350700002)(26005)(38100700002)(1076003)(107886003)(186003)(83380400001)(6666004)(4326008)(8676002)(66946007)(5660300002)(8936002)(2906002)(41300700001)(52116002)(66476007)(86362001)(6506007)(66556008)(478600001)(6486002); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DPnn0cd90YnRe658vHRDVOm2tJeKAdAFMuICenNOdIYc5ioP6eJ5F0f9SCzq/0mFX3fFwMzRfm1d/LPEmKerRTChhyhLEIfy3ONWT9E6CKRr8KeK4pbon1rOtWqejwblCn80wt9lWSTtpy08e088YNxpWy3Dv0W30B72r+DRR4JyPM7giMe7dVrDb/Xu0KA6NrT3zgDPQHNm2pTasn6QiIOgK9yq2pxmL1wob3HeQWCFlfli5uFaqx8R7p0yWkExdqZDaCyGedSI/zMbQ3ffTEVAQ1Z52+L+3INnxbZKqmltFpO+6ixp7og63j8JUdMLsta1rtWGZ9BEYwYR9YcOcN5Vw05GFQWZ3iBq+RcEkQXU1mFCx/ouGpRLxkGayKQ2DF8S56o6jA+x50wNI2OXiXyGxoVSfvlK6IGDdeOXlpB9kU1BlNEjlniHLSIBr5T43ObuzXrn003pzoJfuq6PMV0mi35aqIPXvySRWvOoAJX7ws3aXr3mgXhh7BB6P5Ffz/ZvmZI8ztAQMBCXQxuUyYbe6IZwIcytDjpnfcmShA7oL8jkKUIE1S5wZbVp9pAmzeinF8mM2oFw9AuRAxxpY++BElHkjsyhON0AyRAVdrW/hR14QENSsj5fSlyedSJe7Zj3YzYE6n5FmznKzJ3x8u5RRsZ+lA1kF23ZH1ATRgcoJAuubaxCOrQokB1mG+ITDpvtNOJI+u4a5o+tMR+a1M47V+sMT9Ovuxfx2ekPvu6Su2U0frI7B7UCF3kagLEE23SrUkrAw40njRosRkp6rxbKi8UhSXCTiANgKVlN+0pXjwQ9zDrMD1ISuZBeRVEjh+6q3jJN5aKxuOHICZ4bDd1VIJ0dXR0QDbk+B1Y/NL765fR+0hltQiHuHjhdiu6KGfYZ/bkQfC8k6r/D/R4tKFLb4iFz3ioqonI1oxJ0LRN6ADs3Iczrhtn/mjBKCrHiJSnlpYwRnrmusAinGu+9aRp0k0qRSfnW+oTKbCgPKFHD6vSgtuCVC6hz4AFkA2n/oZPyPa6cR/kLWqdb7gM3vZdoIIaa2Z6rEnJVDbQYKmtICO63ovjOb8/UntUxpAc48fXwc7l2Is2LZDx/0iWxLn7bpR6sCyksbO4PmANStFyJwV/3M0A2eD1pIDaVmzIE8UhRqDj8NYV7wpi4Lo+RdrEUduWOJ6it7x/pk0BEFaDk5eVvfAhJhc+1/+Npf7DEFaohrkYG7iTRomJEJyB2MJiVhxnIoxAT/6KfevU1z8yTl/GhRBdKzkfJzYaY2x55MqZm5J8iv2PTkR4yZxCu1bJvzPLdfHVkWOuHE71va7VOT2xSDwHmc3ozAwRFPp8QPjFLL8c2S9bNuKSSrGs26XvWnWO/PqIIqiwe9jjvfJ9VJTWI8nmhKecjQf9s0/RfZmbXuaU8IFyLWLugYRGOU1/2KHVyUzB5bn7HCy2PwfktxOWO/MBbZx+atyc0ZSyGyZ5Ve7sEHuU6A67W2ZNi4it0C/uvbZh2y2g0J3BubtjvvV27uWLUsMTfcSi6jSE4XpF3KdpAxyrRQw8u6cu1udWj1eMY3486fBhgrj3mMb98YLxKHO14mpU+DW3qZ1F//+ZDjVYu6a/MmerfQUIqeg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: bf142fde-6385-4195-91c2-08da68460510 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2022 22:45:17.0036 (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: ym8VwButm/oogbz36eCyPgrJZfsEeN7JpUpoze2y+wUbDkCMm+WVTgmf+78rT8LQohEaJexib6WPcSSNHNFqNS3Hgzhj2aFcL6hyCMWSkso= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4137 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-17_16,2022-07-15_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207170108 X-Proofpoint-GUID: 8TYh8rk0NGntQmw3EjgMvNGrvGBU_hr0 X-Proofpoint-ORIG-GUID: 8TYh8rk0NGntQmw3EjgMvNGrvGBU_hr0 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.78 on 10.11.54.4 Subject: [dm-devel] [PATCH v2 2/4] 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.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 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. Windows failover clustering will produce the type of pattern above. With this patch, we will now pass its validation test for this case. 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 Sun Jul 17 22:45:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12920672 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 43266C433EF for ; Sun, 17 Jul 2022 22:45:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658097951; 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=t79LL527BOkAkJ/Pa7p0jhtdZBxe8pbTSRxRQ6wwqIE=; b=MiaKp5RXDbOtszRFPmQMndj4r0beueCTKP7kGg9z64/FlcuPotuvffeEQVwrkIyEDiTi4L yue/TcZvBY7eDN/Gsyv++agqHFk76w8RK4ZQyFNM1FAz3ZSIN+CHqG6ufFSVKm+nqmRdbh t4FQcCi0r5LpZl6JMld+nINIty4jMBY= 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-356-UxEzXiaUP1SVVgTDlxcvSA-1; Sun, 17 Jul 2022 18:45:43 -0400 X-MC-Unique: UxEzXiaUP1SVVgTDlxcvSA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BF0CE8039AD; Sun, 17 Jul 2022 22:45:41 +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 67E5C1121314; Sun, 17 Jul 2022 22:45:41 +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 3ABF41947075; Sun, 17 Jul 2022 22:45:41 +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 425F5194704E for ; Sun, 17 Jul 2022 22:45:40 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 360A1906B6; Sun, 17 Jul 2022 22:45:40 +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 3144A906B9 for ; Sun, 17 Jul 2022 22:45:40 +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 0D02380418F for ; Sun, 17 Jul 2022 22:45:40 +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-37-7k9ULwNjMa6MiB-2jpHtKA-1; Sun, 17 Jul 2022 18:45:36 -0400 X-MC-Unique: 7k9ULwNjMa6MiB-2jpHtKA-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 26H94UWp002464; Sun, 17 Jul 2022 22:45: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 3hbn7a1v77-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 17 Jul 2022 22:45:26 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 26HJc6ra004037; Sun, 17 Jul 2022 22:45:25 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2173.outbound.protection.outlook.com [104.47.55.173]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3hc1k3bras-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 17 Jul 2022 22:45:25 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM6PR10MB4137.namprd10.prod.outlook.com (2603:10b6:5:217::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.19; Sun, 17 Jul 2022 22:45:17 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50%6]) with mapi id 15.20.5438.023; Sun, 17 Jul 2022 22:45:17 +0000 From: Mike Christie To: dm-devel@redhat.com, snitzer@redhat.com, hch@infradead.org Date: Sun, 17 Jul 2022 17:45:07 -0500 Message-Id: <20220717224508.10404-4-michael.christie@oracle.com> In-Reply-To: <20220717224508.10404-1-michael.christie@oracle.com> References: <20220717224508.10404-1-michael.christie@oracle.com> X-ClientProxiedBy: CH0PR04CA0009.namprd04.prod.outlook.com (2603:10b6:610:76::14) 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: 4f61da92-54f0-4abf-16cc-08da68460558 X-MS-TrafficTypeDiagnostic: DM6PR10MB4137:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: CW+sZPi4sSuqCIY/mLZI3rZnhKvJkDTgC5R1nspEv/z3cAE2XCcwatpuUFDczdEME0pwI+5rCkuPcL+jvz1yPKHnGJDstQeMsAF36BJVOkc2TACFE5qRlO7NIER68TNahqXSDW4sc+U9G3qr0PHCMvkuMO4yuyqzo6UOZlPnkEH9b0J3HVrmfTT64NbbEVzrhsgLq5NO/zDO9G7oYRSlW10VqS8Xo8SkiBeKpvZjfQuquNnO2QnXJ70ce1ae7R9uPA59ypmJjSCUHM1KoOwfS9bz0Rc0BUZK7ZFRyt8XPk07LV/otx6SRYCgxhPx2/XOd5NE9VEe0Za+nzPS2obGB9jpkqU3/GYyinPCEeagd3KIH/stduGjMWprb/L0mkqUZkTJkW6EWBNyEbazDJ9wa7p/9wjsJaNYoYAojadJxzeUMsSpGz2+y/TBkdajQbZZgZwe1eJV3j08+nR37Tn9JCiTIJMYyXB6vYdUhsm2/tWT440Z8FU5UDnAlDF8LzK4INCarK6Uh1KXCYbNHrc0wPs3MgGB/7uKnaC1yj6cNYwsW/Jql+BSwoGePINObohOMDYswjMTJyMSqne0oiKjhVCM7cmdBZtNNDC2YJn7Ih9o0vdqeR9pbCJvInw1WmfjUTmCfkrig31m60Au2gALQJBp3tL54m3veDl7zbto9RRjYQR04bdlO+8wMrORL8GpSlWu5NxSAxfr9DuKOkb69VxMtzjeGqzZXyHaYV8mCorgZfQBIDLETp6C1QEhNomqT3OYCjU0cG0O/i5IqZ0GgJN/CxLGtWdNkh3GDqwB2CH4BN0pRJ7E/XzOaDZ0P5Wx 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)(396003)(376002)(136003)(346002)(39860400002)(366004)(316002)(36756003)(2616005)(6512007)(38350700002)(26005)(38100700002)(1076003)(107886003)(186003)(83380400001)(6666004)(4326008)(8676002)(66946007)(5660300002)(8936002)(2906002)(41300700001)(52116002)(66476007)(86362001)(6506007)(66556008)(478600001)(6486002); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: luzqZK6YuRVnS0xivkV6/fozfWupy44BkTXNXY9NIyN8N2jzcJc5qSgrqMaJHfxo4dIGIxDvvXwCix7w6PGks04tFLNnQXU201GHOl2JtaPPrVw9/hRXq/7sqvc+ohJNoLO05f327kDBId92mi6fSqAB8xN70Lijai8rgMSJTCvs4QQgb2ykEYqHAxMuFTSvCJxSlFwACn7C0dINrH9KbMDaPmzC5FjTMPXAU1esw0d25cwIBlIL8odHLzGPtK7ijezghttIvqeGCC4KAZzdnb1c1IKKLPGwmdZ/7A8P/Vj7YWnh9iPHtImLhV/WmKL0eMmWyqSY98yon4Pk0bHEbc7/TrM1T+PUu73vFsyPm+bVrhTbfOOeaEGMwCp+BD1Ud+H+M4PYejZ2dsnOkE7bRpXwR82qSdUcYoiSkwdhS4hiDGvP27v3sVUvHUuoOBFu1Kqs9HMAFUiHGGsdcdubpGOfn6Eg2nSElhsNDJodjg97IjWOVDRhA01hYRSKqvpz4QDGQriMG6ToncwSHDsZbtXZDt9uGRGpCrre0fACzvEAVUVGYwo9jpMyjWqRNb7ucvAqEp+uJQLHKK+OfEjT+20AF4I1Xx5Vcnxe24HmwCQhIpBKuodPmOFdAXGhEdnHcJdupsu9KdpUP16Sql7C7P6bubqovmloeFoLTZB9reUPz/b3YHDLzhgBEPwyJ38T2aNdhzbsTGkaJAceu4dybzB4phlSWeVjRg4nPQejCyrobnk7cQ7/I/Mx3XJx/xepMOguHnlSkgE1j6Pf+6nBl77uXG8Hm8Wmwobqu6lH3k1OCN6P1w7qY0NtMFMrTVe6gnz7OcTtbrzZ2aLXxCgqsnwrDc5+lak9d8dkbk2Uv4usvlK/L+QhvqncsFIhYCq9NSrcrPAtPUr7LJnNdDFcof42MLAj5tVHHcDMXOfZyMgp4o7kFfmqMBlTE9NWXeNTFw76+X+tRd8HkxnaYjDRQFA4VVB+wLatNhNhBYdPfK3MuyFDe8rZKf6G8hxPUy2MN7WCxWaRSvyd6b02r3XTzLNhq74WcpkDlo/Hz2xfMcweT9TxcWK79AaLfkmFolreTLs8Pr8z3P9bzJAwh+OxxeF7lWTtuLH8diZ2j3An53vazmPJa1nzDPJQnvnuzTMh97mRcYbq1mmmMcl1ic6ldfVmmpQRP13nSq0N95rq3xjBX7QV2xRn7i8pBPCpRKq7q9kCwMDAjK1OGLJY3yaP/16+qPg4n+O0Sam9fc/CveBvxlDATJvPZF8vkmcEoGMFUS1sI6xldiKvmgFN7fMtPfXWCS51q0fwQnYsTB9SbRnn4WLgFD4O8q100uy/v5XbTG3uq7j1/ku6pGKcq/m+n03+XvuT2HC7/JGF1RlHcXWkhhvIRxzkFf0DbIE46vxYXYDVuC/8wsBzdx9YKJz5j+I+zzPkS9urSSSkfNycFhHRH4kDyGpIyGjw+89eZnDcss00ItvUN7K2aQKZSTr75q2LqUucUZresahSWgYBQ+UeBMTKbickIGdaK/Fa6n7UF73o+Zc/KUZTJS35+8N7yHEJp5/cAVDqykm7fqQW9/bE5qZtfWEM6VH6GhhDmS5BhocXrnBdLC5XPHCdRUsQGg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4f61da92-54f0-4abf-16cc-08da68460558 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2022 22:45:17.3942 (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: dqjjNQfablW0PpEzhgK5sGwWObBb6jSZz0d8Gui9ziC/0oLSr8OKxU+zDXqebSc1q+HouFO/AGuy2OifF0g+qdzu/UHZdy4AYxUffC0xe6U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4137 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-17_16,2022-07-15_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207170108 X-Proofpoint-ORIG-GUID: PMSBBtq2cmpLyWv36PCnjw4NA7CO6Wdt X-Proofpoint-GUID: PMSBBtq2cmpLyWv36PCnjw4NA7CO6Wdt 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 Subject: [dm-devel] [PATCH v2 3/4] 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.78 on 10.11.54.3 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. It has been tested with windows failover clustering's validation test which checks this case, and it has been tested manually (the libiscsi PGR tests don't have a test case for this yet, but I will be adding one). 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, From patchwork Sun Jul 17 22:45:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12920669 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 DC3CEC433EF for ; Sun, 17 Jul 2022 22:45:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658097944; 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=bTLnbuP8th1RL3oeuXUaWR3yqsPYajh6G7AmrTTmOrY=; b=JX24t3RcVQhirAqnlKw/sxsnlowmf5jVJ1A1OQyAjFt/NMCqAiE1W/HcYIhtKeEYvQyLSa 1C0eOoyQ8AoL8mg44kE77yxCO7VoyccnrwyjfOkSOmgKyjcuDwjbi0E6s9MO1/vXeR+i6e s4giKOhDLPWVlkI4KAXKtqUGLz1gcbY= 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-400-A-PxnGFRP9S5X0UouRfJVQ-1; Sun, 17 Jul 2022 18:45:43 -0400 X-MC-Unique: A-PxnGFRP9S5X0UouRfJVQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C01EA1C04B7D; Sun, 17 Jul 2022 22:45:41 +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 54BDD492C3B; Sun, 17 Jul 2022 22:45:38 +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 0BFDB1947054; Sun, 17 Jul 2022 22:45:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5EF72194704A for ; Sun, 17 Jul 2022 22:45:37 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 39BB01121315; Sun, 17 Jul 2022 22:45:37 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 347A31121314 for ; Sun, 17 Jul 2022 22:45:37 +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 1387E85A586 for ; Sun, 17 Jul 2022 22:45:37 +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-591-O4ZetcyiNLmhEkp5G0V9Iw-1; Sun, 17 Jul 2022 18:45:34 -0400 X-MC-Unique: O4ZetcyiNLmhEkp5G0V9Iw-1 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26H94D3r018487; Sun, 17 Jul 2022 22:45: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 3hbnvt9uqb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 17 Jul 2022 22:45:26 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 26HJc6rb004037; Sun, 17 Jul 2022 22:45:25 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2173.outbound.protection.outlook.com [104.47.55.173]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3hc1k3bras-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 17 Jul 2022 22:45:25 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by DM6PR10MB4137.namprd10.prod.outlook.com (2603:10b6:5:217::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.19; Sun, 17 Jul 2022 22:45:18 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50%6]) with mapi id 15.20.5438.023; Sun, 17 Jul 2022 22:45:18 +0000 From: Mike Christie To: dm-devel@redhat.com, snitzer@redhat.com, hch@infradead.org Date: Sun, 17 Jul 2022 17:45:08 -0500 Message-Id: <20220717224508.10404-5-michael.christie@oracle.com> In-Reply-To: <20220717224508.10404-1-michael.christie@oracle.com> References: <20220717224508.10404-1-michael.christie@oracle.com> X-ClientProxiedBy: CH0PR04CA0009.namprd04.prod.outlook.com (2603:10b6:610:76::14) 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: a7c1ead1-5d37-4cae-ebbc-08da6846058e X-MS-TrafficTypeDiagnostic: DM6PR10MB4137:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: B1B4iRfHxQ5C8iT7/EHiPF6qm+JmyCu2qUiL+bxOhDcBjOz6bAJoTCwGcGrDA+QLI72izmn3+RxUXlk9VGLMWLD76U6jhnRTEYeJilAOqKCmRQyQcr1G23mdTLGz2wR5Djr7V2mJG45+VWf0NZjz0EFmaHHLj8ENuLiKglS43xF7LM0oU3QXbvKVluGmtJ2zp9GyBF/zvR91adtlmkwTIURY7vha3erGKgpSER0FTJVEC704D/5vA9C9A1UdIRYOw1v6wXSGRrgocpcG9J6f4yqhjKV7GRV42bNSSagHzmG5O6RBi0YbzdI1kpXzrvloWCyCFB8RFivxvjwWxN3QMRT2wcoLxKaJQr+FDvjep/M1baIXfwJ4eAHNO5MY0W0GH6Bdhhfv9qgvowObg1SdWwdO/Kc2w6LA8CmX5WsIkT3gdNwa8g4nj6pHrD6bG81brRqV1s65thwUsBy9SygBvj7IqlYwxwRleygaVFOjsUFo7L9F9f+WB69yMbfUnCM4HdlF/7tDDv8TvhJk3mOwulq18CD3xVr3RnjM9m/4GW8xqOP5C5XPcv1O7kpHzGZuEvX0UGjPUXCqa7Q2exMjqbaOxyHL/koXkMkuk8+FEJJkbvrGOgPgE+Dg+p8zhY6gpdGTTLKgxUOxMP1ZDZfSAkpnh2RVENnGWIQhBeZVmeX+nncfBW3vX0IAlb0t4O69tCSKTeXcX8p4Y0bDhMU9B0ZdLiFDITr441p3I7kIOl/k2hzMWePhvE+wS4Vmh2FY6jjNLPvL32O1MgRkG3y4onKOf50Tq8U9NvljY4GtUe7+b89vqTiGRISH+RaLbKBp 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)(396003)(376002)(136003)(346002)(39860400002)(366004)(316002)(36756003)(2616005)(6512007)(38350700002)(26005)(38100700002)(1076003)(107886003)(186003)(83380400001)(6666004)(4326008)(8676002)(66946007)(5660300002)(8936002)(2906002)(41300700001)(52116002)(66476007)(86362001)(6506007)(66556008)(478600001)(6486002); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: x/prbX02m7i9S16zlP18R12veYXeHUOAKDMvu0s7g/8q7sLb0kqfws/aSwvzh/8/UyiBwJD8i6IdWtCeWIf3FxGyucLSrZ1EEm5I0SNse0lfSMfsMeLzgVJXBQSdbJG6A404zbVhHsazp94yuEE3LwEhKrKLpZCQwzf54KpGSli9a1yTg50vjqG2CBIY8XiXn7toh8eW4gjr1PQaL1vKRymu5o5gvhBNIid2VB2hBwnUVvmd2SI4pTk3mKbna5/OTs0C/+XRSgOVtyeOFLr4sLuKZRJqWC8lu46LF37Cs/ubCxacaw4R1uImqNJ8KqFbozVftIAGEKzGaEOPKQlwSNqzMc6r56EGAHGqUTMR3vWLBuYcoCLdwDIOsplFYX9y1OYFOk9mz9znKIOngw8t43P6ddz0lkXbom8d/SqZbRVkve+LxLcAJuyKSDdBq0DIq0f8pFjrmvh5oNFNFDG7YAv/12xeUxismJKrFeYf8GejNT3yfe4EzeZ+Kj+1teEfJL0a2BsQMhsRTADLA4iSufzYNSt6Kz7VQPU/mDQX0dhGoBbMNQ76YCdv8GDWCobiVuvjOa9IB9abRWdQajonzx9VF+dmG4rn6EGcwEuO9PJ+ntdlzSzZTtqwrx8oCHwUQ44t1vvjZaetDjfB3pMlChERhdgpk2tcPuDF/4yI8B8ewgfFvsoxLrqxSPBa1bFIlY0osB9EPvYgF3HcXbbbdovmEuJ214BXK4hPFJPWUU/arhW4OoM9pcu/x+5SXSEYglZsEQixtSCojriYqBOkzA/9LQ6WxUwMo9u4DQTJqvkdgkoNRehUan9zN73AT7AxD8bulpHIaTnVBkRIwwF8P9WEy2fvqiBTk0L9oUdNMIPVk5IUNOoBBWqEkNBFLRHUsTzVK4BaWrWzYLUXqUInn3a3hUnsrwn1AAj3Gk07lO8G/+sOwe21b/TcmxIfSyvMdxllCeOdqOowaef2pCckV7I5l9l2DboaqUxr1art4JYi0rd77VgAhRbsC3K2zNzXrPu0Vqa3dHrdhnvIJBRd7RZneh0NPGar7tvAF8WjLoRaE/ceHgmRt6sujn6Qqn8qHVrlKmRoIgIo4oQ2LNLpmSxNX9XfSbWIIGDhI5M/4mb7KzV0OZv8DcIVOGCV2tjyFzTuKtNxlO5MlOqK/EKdoJjzexGA1fDcDhl7Cmiugdts8dhcpnaJjtR0hIZJ86DF6SEbae/EP63GZGpGmUhIpicGXQvUU8YzOUb/bdt78csIT9SYdSMEg5jmehiT3mbiRsrfkzgLPDNASxRVd6/mtqZIRuPghEgQAPNOMSAFNTrKOdnauHJBJ8GjlM7jSwqJjn8Jfw7O0DKG9izZcjk6kE0YxzxAgNJibC6KrXtflIkT547an6icQvddt16od2YbaAbBr+/g5gvCpJ2dbWkvH6a6vRYvtA+3hiYFzAWUgpAktvaUO8KtHvnfoIL8UZMCVL+lskAw7jfFz32FAx++/RiUP9SmdH/xhbIt3kagRJkqQa4c5TinmXQ5hMBTqKeap52qBPSOj4TOKIZ8WmaqhYGHZMZS7copNzst0HwRbHQA41pdCnr67cK2WilhKO4iyYUuQ/xk/EhjeB/lC1xXfw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a7c1ead1-5d37-4cae-ebbc-08da6846058e X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2022 22:45:17.7692 (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: c7B6HzpBI1hUjdysCimsYPUaHIWNUN2qJ5sGbB0dHLY8pj8ggUfG5hJRlvNsJXmUk4IOTCpKdq22gnPE5wX5idIMqfvB4mMQTsl28c5nm74= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4137 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-17_16,2022-07-15_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207170108 X-Proofpoint-GUID: So18iWCxOpL1PRtRl8m4eIC2_cE4zdgp X-Proofpoint-ORIG-GUID: So18iWCxOpL1PRtRl8m4eIC2_cE4zdgp 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.78 on 10.11.54.3 Subject: [dm-devel] [PATCH v2 4/4] dm: Start pr_preempt 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.10 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 pr_preempt has a similar issue as reserve where for all the reservation types except the All Registrants ones the preempt can create a reservation. And a follow up reservation or release needs to go down the same path the preempt did. This has the pr_preempt work like reserve and release where we always start from the first path in the first group. This patch has been tested with windows failover clustering's validation test and libiscsi's PGR tests to check for regressions. They both don't have tests to verify this case, so I tested it manually. Signed-off-by: Mike Christie --- drivers/md/dm.c | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index c31f99c9d2b2..7f23dde45088 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -3046,6 +3046,7 @@ struct dm_pr { u64 old_key; u64 new_key; u32 flags; + bool abort; bool fail_early; int ret; enum pr_type type; @@ -3218,25 +3219,41 @@ static int dm_pr_release(struct block_device *bdev, u64 key, enum pr_type type) return pr.ret; } +static int __dm_pr_preempt(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_preempt) { + pr->ret = -EOPNOTSUPP; + return -1; + } + + pr->ret = ops->pr_preempt(dev->bdev, pr->old_key, pr->new_key, pr->type, + pr->abort); + if (!pr->ret) + return -1; + + return 0; +} + static int dm_pr_preempt(struct block_device *bdev, u64 old_key, u64 new_key, enum pr_type type, bool abort) { - struct mapped_device *md = bdev->bd_disk->private_data; - const struct pr_ops *ops; - int r, srcu_idx; + struct dm_pr pr = { + .new_key = new_key, + .old_key = old_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_preempt, &pr); + if (ret) + return ret; - ops = bdev->bd_disk->fops->pr_ops; - if (ops && ops->pr_preempt) - r = ops->pr_preempt(bdev, old_key, new_key, type, abort); - else - r = -EOPNOTSUPP; -out: - dm_unprepare_ioctl(md, srcu_idx); - return r; + return pr.ret; } static int dm_pr_clear(struct block_device *bdev, u64 key)