From patchwork Fri Jun 3 06:55:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12870037 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 6394CCCA485 for ; Mon, 6 Jun 2022 06:46:27 +0000 (UTC) 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-618-foeRoiHAOMuLsoOQs2P1pQ-1; Mon, 06 Jun 2022 02:46:23 -0400 X-MC-Unique: foeRoiHAOMuLsoOQs2P1pQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0D57E29ABA35; Mon, 6 Jun 2022 06:46:21 +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 EE6702166B2A; Mon, 6 Jun 2022 06:46:20 +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 BFBA31947B93; Mon, 6 Jun 2022 06:46:19 +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 CF9C71947040 for ; Fri, 3 Jun 2022 07:58:44 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id AC679C27E92; Fri, 3 Jun 2022 07:58:44 +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 A6982C27E8F for ; Fri, 3 Jun 2022 07:58:44 +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 8841385A5B9 for ; Fri, 3 Jun 2022 07:58:44 +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-445-Em0Ujhx4O-qgzjXt9NgBtw-1; Fri, 03 Jun 2022 03:58:43 -0400 X-MC-Unique: Em0Ujhx4O-qgzjXt9NgBtw-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 2535ehw2004306; Fri, 3 Jun 2022 06:55:50 GMT Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gf08e198j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Jun 2022 06:55:49 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 2536q0XS027501; Fri, 3 Jun 2022 06:55:48 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2048.outbound.protection.outlook.com [104.47.73.48]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3gc8k25ntm-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Jun 2022 06:55:48 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by BYAPR10MB2789.namprd10.prod.outlook.com (2603:10b6:a03:82::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.19; Fri, 3 Jun 2022 06:55:46 +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.5293.019; Fri, 3 Jun 2022 06:55:46 +0000 From: Mike Christie To: linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, hch@lst.de, axboe@kernel.dk, martin.petersen@oracle.com, james.bottomley@hansenpartnership.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Date: Fri, 3 Jun 2022 01:55:26 -0500 Message-Id: <20220603065536.5641-2-michael.christie@oracle.com> In-Reply-To: <20220603065536.5641-1-michael.christie@oracle.com> References: <20220603065536.5641-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR16CA0012.namprd16.prod.outlook.com (2603:10b6:3:c0::22) 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: 8bb12f8c-d5f9-450d-33bc-08da452e15bb X-MS-TrafficTypeDiagnostic: BYAPR10MB2789:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: HAO8eR703Op82WTF3hb0uBbuFcuTwbbMtams+rV7omrEVIHwnknuaawx6GshvZI/rHJMyOsq7aQdSsmQFsGhBaCulzaZTKebGYhpNBamp2sS7277ezwnsJAQ+o09+0HO9M1jTA/WTZiNAleqB6VV8w1jSStSXM3ABALINMVxWISK78vlMz+RPhIJUdbDer0QdJ5W2HQMBak4OFrh7I89agQMRo/0py4RzXhHiAYW6/sIBYDtkKy0tDbp8tkGp569w2YZED2lgKW0bv3qzyo38t+o8QcQM+Vu+1BYVgOtq8CnHGBAXFfA7XyhsNISfFZzaA4kP43s0z+yG2ZUZ9Ip9zdkZqe/sYsrYVwrH9j0g65DVGO65yOFUVsgXFyUxNpUH9UFUUo1LBEgzNWcN/69syPAJLRb44dVGaR4ueWEXJ1rmivhfPLYHN22xGy/FzQOBV5QhdZ3cGgwskLJ48DTEosUNeCgcPUarcxmT6FtIotBuO9OiUx/kna325CDQm2gPPJ5yZyyXVd28KGyW7ukJ28wDE160eOa9zDoqWVu4G895DX5UtLW/LS//UJgDmH0ulQBdJCu6KBh/noru5LvuUIsHtObBCB3zOb1cr7XE6xEib3EMB97SOCRoUiATiHOYfaAw6+3iuvZ4OEIUfcFR+YLZhb4W24W67/VlUeDIpeorhwaDJXIwitbhM4257jqBnHNb2b1nXjkgf7WB/QFSg== 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:(13230001)(366004)(66946007)(8676002)(38350700002)(38100700002)(66476007)(4326008)(66556008)(86362001)(83380400001)(36756003)(8936002)(107886003)(6486002)(2616005)(316002)(5660300002)(1076003)(6512007)(26005)(2906002)(6506007)(52116002)(186003)(6666004)(508600001); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LL2JU0ZDPRD7ZuvjsiYQuzv91hsxt0wf+vceUSbD7gcEPeSW2F3jbWx3h8a6QmVNEKUZprrFNsdhe2mkR4Ebvl4TKEUDq/Stypu5IR5u91T97tUVlr1mJsK3UTzagPkZe+GU2myEAD1SFjDVXYg0vXXd2ZVxv2QuZcYhN2oZdlDzvkc643F8rx2iZFM6hWYYjHnFCVkBFrPh8gzkcXm6Ljt9iiBecIRoPNkCAdMKMMDbpbHDFQYMmJ9QvHgyGaKPLGKqwkQ9AK7ixg1MLp3AEd5e6fQxhAS8ZlH67D74a9HSxQRKMRR8AJ7dh3H42492ds8gvlKAzQ3pPKYZq/VQHSo1/EaRiR+5ZnhzNkCYsG4d15DXj3LR5GooPd5+xZzt6K0rvVt5MpMNMdNzP4Lod+xhx0lIFBO6O/tNLRruBqx6ZJOUOK6dCPt0Lp54nLnWc2Hgpg1FYCxx1jJoCSGk57zbkS0uI4Aw/UEUN4hWnnyPZK37EO/SZ2eU7Bh3HzVusVu6x1QKGyBd0ejL2+5097NmxD5KPuytXhcQw6iGQQXaKrxFwOASUByDDkNrzt9VdhU/HepG2/YZnJkqGtFeJ49WReNzjVlmRuQyf9L+nsxiVUXxEJu1PE3b5jnr1UiuCOyk/addU0b3/L11LXv/j7HDyQYTx+og1aPikF/MbPgGX+fzZnY11bARdeJpY7ig91g4Uq+bvQOHSo9TT8Nnm7EkErrPqM587jNcgmCwrTp1ZazuKAJ2IZ0UaENy2UDnhl2QTMjEAJN/Lug44RKuPf0+a1/eckovDAydQ2L6dBYB/p+94Y2VwBp31+u/NGNyOvMYeXFuuP9YR3Dmr/7J/VM5ktgL1xeDdyt3F2jAcC0jlWx5/faVbSyPH1Edd2+6vhg9+Y+I41L0RjSFkBwGKlvAZssGIN1yAmQq3iJHjjLRGfVWeDe9c4dlrUpFJRUsw5e9T93ry6qEAaYZ/mkf/CAa5tx8MACNQZ4ZoeJAMUNEZAl8tmsckE0ogMnD93kFFYKSo4LZcq+t7gAFU952fu5hY49BzmJIIx9WI4f7/kEMn64ceeRglSwOsSjVnew00CbWmX1P6aJgt9qmWklZ8o5Xq/eVoJVWXRI01j7H0TMyuw35e+61jmT3jXILSIMnDzcdTvx6tZpMR55utdXe1xXzr7b2WRS6KyXTFwff7CezoBmsuUvVCSuajGPGUE0AF/aCbWHPiWgmeeBfP0txBUxGQoFhnhjTBrnN0Z/jkChlDDGnM1VDYXNOMMafNhhSgaUkd3w6KDaD8Rk++ZG0Fx/0eeB1Y6nr8ilW+20UjTYon+ajA5LC/HPoqjsSVG6igZFMryfKNfIKNdPJs9gOQ9FY9hLtOHJ0u/a1jq9ekbTlTCc4lNREzB0hrzqoiVeyvxKEMqfeFY6CCBuLaedHfuygFoHmvEMmXOZ74vGvMNT1njKWKxNEIh6xgSuQq2MKwj+SpACXDnSac4XJbGnrseP29wbuB9kmAscWCZvY69ykUE0/g96+ouqy7ZbA3+zhMYPElea04yGysT1lkxt3VfPqnl7LyjpmND88qDlH8rrQXIepv5RpwvdzyR2KdLv3P9ucTHzsYE65ItHiYRMKNMqHzf9Gs0w4hOimI4g2X0yVXXTfv+2mZU8yUQEvC8m6IKz7Cgf+0eZOKyEKx36oJzAZ/9Jeyq+urQt/JJl1ZmCMEFM4rGsswvUUgdoI1cCDDNQH1pXvK+vSoTnsIwQqNRKGYn5fZUFWQeekoUa4URU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8bb12f8c-d5f9-450d-33bc-08da452e15bb X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2022 06:55:46.4248 (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: EvZ2bhMeAuhbbvSmv6TrxtmoY/7BTDlTI0vcG+GFw00C2i4ULexosBMMrX0Oi8hGtQ/mB4PUOtdWhMzUdSupn0ppfEwcAopcfjU1ygp8qdc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2789 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517, 18.0.874 definitions=2022-06-03_02:2022-06-02, 2022-06-03 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 suspectscore=0 spamscore=0 phishscore=0 malwarescore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206030029 X-Proofpoint-GUID: LFBZ-pwQHIw-Dvhm8RgRRGnsglZUq_l5 X-Proofpoint-ORIG-GUID: LFBZ-pwQHIw-Dvhm8RgRRGnsglZUq_l5 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: Mon, 06 Jun 2022 06:46:16 +0000 Subject: [dm-devel] [PATCH 01/11] scsi: target: Rename sbc_ops to exec_cmd_ops 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.6 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 next patches allow us to call the block layer's pr_ops from the backends. This will require allowing the backends to hook into the cmd processing for SPC commands, so this renames sbc_ops to a more generic exec_cmd_ops. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig --- drivers/target/target_core_file.c | 4 ++-- drivers/target/target_core_iblock.c | 4 ++-- drivers/target/target_core_rd.c | 4 ++-- drivers/target/target_core_sbc.c | 13 +++++++------ include/target/target_core_backend.h | 4 ++-- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c index 8190b840065f..4f00563c5016 100644 --- a/drivers/target/target_core_file.c +++ b/drivers/target/target_core_file.c @@ -900,7 +900,7 @@ static void fd_free_prot(struct se_device *dev) fd_dev->fd_prot_file = NULL; } -static struct sbc_ops fd_sbc_ops = { +static struct exec_cmd_ops fd_exec_cmd_ops = { .execute_rw = fd_execute_rw, .execute_sync_cache = fd_execute_sync_cache, .execute_write_same = fd_execute_write_same, @@ -910,7 +910,7 @@ static struct sbc_ops fd_sbc_ops = { static sense_reason_t fd_parse_cdb(struct se_cmd *cmd) { - return sbc_parse_cdb(cmd, &fd_sbc_ops); + return sbc_parse_cdb(cmd, &fd_exec_cmd_ops); } static const struct target_backend_ops fileio_ops = { diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index 87ede165ddba..9b0d788f6744 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c @@ -871,7 +871,7 @@ static unsigned int iblock_get_io_opt(struct se_device *dev) return bdev_io_opt(bd); } -static struct sbc_ops iblock_sbc_ops = { +static struct exec_cmd_ops iblock_exec_cmd_ops = { .execute_rw = iblock_execute_rw, .execute_sync_cache = iblock_execute_sync_cache, .execute_write_same = iblock_execute_write_same, @@ -881,7 +881,7 @@ static struct sbc_ops iblock_sbc_ops = { static sense_reason_t iblock_parse_cdb(struct se_cmd *cmd) { - return sbc_parse_cdb(cmd, &iblock_sbc_ops); + return sbc_parse_cdb(cmd, &iblock_exec_cmd_ops); } static bool iblock_get_write_cache(struct se_device *dev) diff --git a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c index 6648c1c90e19..6f67cc09c2b5 100644 --- a/drivers/target/target_core_rd.c +++ b/drivers/target/target_core_rd.c @@ -643,14 +643,14 @@ static void rd_free_prot(struct se_device *dev) rd_release_prot_space(rd_dev); } -static struct sbc_ops rd_sbc_ops = { +static struct exec_cmd_ops rd_exec_cmd_ops = { .execute_rw = rd_execute_rw, }; static sense_reason_t rd_parse_cdb(struct se_cmd *cmd) { - return sbc_parse_cdb(cmd, &rd_sbc_ops); + return sbc_parse_cdb(cmd, &rd_exec_cmd_ops); } static const struct target_backend_ops rd_mcp_ops = { diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index ca1b2312d6e7..e08d06dacbfc 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c @@ -192,7 +192,7 @@ EXPORT_SYMBOL(sbc_get_write_same_sectors); static sense_reason_t sbc_execute_write_same_unmap(struct se_cmd *cmd) { - struct sbc_ops *ops = cmd->protocol_data; + struct exec_cmd_ops *ops = cmd->protocol_data; sector_t nolb = sbc_get_write_same_sectors(cmd); sense_reason_t ret; @@ -279,7 +279,8 @@ static inline unsigned long long transport_lba_64_ext(unsigned char *cdb) } static sense_reason_t -sbc_setup_write_same(struct se_cmd *cmd, unsigned char flags, struct sbc_ops *ops) +sbc_setup_write_same(struct se_cmd *cmd, unsigned char flags, + struct exec_cmd_ops *ops) { struct se_device *dev = cmd->se_dev; sector_t end_lba = dev->transport->get_blocks(dev) + 1; @@ -404,7 +405,7 @@ static sense_reason_t xdreadwrite_callback(struct se_cmd *cmd, bool success, static sense_reason_t sbc_execute_rw(struct se_cmd *cmd) { - struct sbc_ops *ops = cmd->protocol_data; + struct exec_cmd_ops *ops = cmd->protocol_data; return ops->execute_rw(cmd, cmd->t_data_sg, cmd->t_data_nents, cmd->data_direction); @@ -620,7 +621,7 @@ static sense_reason_t compare_and_write_callback(struct se_cmd *cmd, bool succes static sense_reason_t sbc_compare_and_write(struct se_cmd *cmd) { - struct sbc_ops *ops = cmd->protocol_data; + struct exec_cmd_ops *ops = cmd->protocol_data; struct se_device *dev = cmd->se_dev; sense_reason_t ret; int rc; @@ -818,7 +819,7 @@ sbc_check_dpofua(struct se_device *dev, struct se_cmd *cmd, unsigned char *cdb) } sense_reason_t -sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops) +sbc_parse_cdb(struct se_cmd *cmd, struct exec_cmd_ops *ops) { struct se_device *dev = cmd->se_dev; unsigned char *cdb = cmd->t_task_cdb; @@ -1167,7 +1168,7 @@ EXPORT_SYMBOL(sbc_get_device_type); static sense_reason_t sbc_execute_unmap(struct se_cmd *cmd) { - struct sbc_ops *ops = cmd->protocol_data; + struct exec_cmd_ops *ops = cmd->protocol_data; struct se_device *dev = cmd->se_dev; unsigned char *buf, *ptr = NULL; sector_t lba; diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index 675f3a1fe613..4e6cf1bf3b87 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -61,7 +61,7 @@ struct target_backend_ops { struct configfs_attribute **tb_dev_action_attrs; }; -struct sbc_ops { +struct exec_cmd_ops { sense_reason_t (*execute_rw)(struct se_cmd *cmd, struct scatterlist *, u32, enum dma_data_direction); sense_reason_t (*execute_sync_cache)(struct se_cmd *cmd); @@ -85,7 +85,7 @@ sense_reason_t spc_emulate_report_luns(struct se_cmd *cmd); sense_reason_t spc_emulate_inquiry_std(struct se_cmd *, unsigned char *); sense_reason_t spc_emulate_evpd_83(struct se_cmd *, unsigned char *); -sense_reason_t sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops); +sense_reason_t sbc_parse_cdb(struct se_cmd *cmd, struct exec_cmd_ops *ops); u32 sbc_get_device_rev(struct se_device *dev); u32 sbc_get_device_type(struct se_device *dev); sector_t sbc_get_write_same_sectors(struct se_cmd *cmd); From patchwork Fri Jun 3 06:55:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12870035 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 E7EBCCCA484 for ; Mon, 6 Jun 2022 06:46:26 +0000 (UTC) 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-628-52YeX3eIMhiFaDYcQt1LVQ-1; Mon, 06 Jun 2022 02:46:22 -0400 X-MC-Unique: 52YeX3eIMhiFaDYcQt1LVQ-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 1E7A01C13954; Mon, 6 Jun 2022 06:46:20 +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 3C950406AD44; Mon, 6 Jun 2022 06:46:19 +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 0F95E1947B91; Mon, 6 Jun 2022 06:46:18 +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 7E48C1947040 for ; Fri, 3 Jun 2022 07:55:45 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5F3FA40EC002; Fri, 3 Jun 2022 07:55:45 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5A4F740EC000 for ; Fri, 3 Jun 2022 07:55:45 +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 3C6202809CDC for ; Fri, 3 Jun 2022 07:55:45 +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-455-E-t5oSkFOqSe3b-nUQAB-w-1; Fri, 03 Jun 2022 03:55:43 -0400 X-MC-Unique: E-t5oSkFOqSe3b-nUQAB-w-1 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2536WAcT031063; Fri, 3 Jun 2022 06:55:51 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gbc4xv7sr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Jun 2022 06:55:51 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 2536oNha025389; Fri, 3 Jun 2022 06:55:50 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2041.outbound.protection.outlook.com [104.47.73.41]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3gc8p5nyqv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Jun 2022 06:55:50 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by BYAPR10MB2789.namprd10.prod.outlook.com (2603:10b6:a03:82::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.19; Fri, 3 Jun 2022 06:55:47 +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.5293.019; Fri, 3 Jun 2022 06:55:47 +0000 From: Mike Christie To: linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, hch@lst.de, axboe@kernel.dk, martin.petersen@oracle.com, james.bottomley@hansenpartnership.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Date: Fri, 3 Jun 2022 01:55:27 -0500 Message-Id: <20220603065536.5641-3-michael.christie@oracle.com> In-Reply-To: <20220603065536.5641-1-michael.christie@oracle.com> References: <20220603065536.5641-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR16CA0012.namprd16.prod.outlook.com (2603:10b6:3:c0::22) 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: 13013204-413d-48a1-8ba6-08da452e1658 X-MS-TrafficTypeDiagnostic: BYAPR10MB2789:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: PyoYuQoFsqLXXhbBY3e9lZfKhmG3uswM53GkJZqQLeZmvKIDGYDyvMc4w95PviNFeggdruNW6JHRvCz3Zt+MG2LKq6gwbMV5PRxXm+yveULHX094FfirC/OpIKczwpwyt44REf3CxyGqfDhJqD8sq74Fm0TaOoOdTRf9rhrOeheqGxSNcew6PXrJWb8i9YoLPLW5kZV4y1bhVGB4hSq9QmmnnJv5hXfILfUTzSx/NMBJ6Vyni5eHKD40LZznfaFD6/6/acj+JZVpoYx7OGwbOztBNtbmQUXPi+AAi7jV6me3cUMOtmuVPHNTyj0t7KBeN0wlSVjJ7VOBfh3Irz9sT0zmR8gy5/7lcrqgt/0PFUDAMpsdX2jlQ/Z1YIrMCTwcHlCcjAqiubmcO9S/aZ26LKtksVJhvOX8PkGwDHjf3b+0Nzk0KxISv9Hg6fG8hTFHiw4UGEzXjGSnRNFvuQrpAhLHyLv0f9P8bNySCLOMsyUCEWvmu8cI0OwKe6EMbWnRuoTL8FML4M8KjtQ9pYt5RNcZ/lt6BU2xiF2wuZox0DOCXTMf5/Y54QjGMcl/vtVvdEVraXUBaD2wUYAZHv0phPhl8C5shYP29tZ5ta+miCP5wSUvuXt88h/gqqVhxaboi+oVKABRlAHk8LFuK0gWe/mIrrEEnRO3z22qXpu3w1WV7hAd1oJiU3hL1yB0pMp5+T4KVtA3kKL6GLZ66SpL2w== 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:(13230001)(366004)(66946007)(8676002)(38350700002)(38100700002)(66476007)(4326008)(66556008)(86362001)(83380400001)(36756003)(8936002)(107886003)(6486002)(2616005)(316002)(5660300002)(1076003)(6512007)(26005)(2906002)(6506007)(52116002)(186003)(6666004)(508600001); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gNj80u2XJHDo2tF64dtrYCqQhFgi6E7UROY973/MD5GG9plsgHBmdE0GlpKBXIvdxa8TzDM3ElrQqBxJkkqO9aOq/vbBQshm33KGxGZKkuRyZnmesgMU5g0uAIyCwnjr1U/pqgIT61qTkqYSzrY6TRrNYabh2tYJfcevZAsKYDEEtHczLxUN4+5DWHIa+TWM/Zw4/QI2Z5hgHyV3mf78kzXHsSC0pNhQECuKIudpfXb84N0ofUscnKWwwfJj0nal8U2zNTnPaNwEy1zFYc9gA6mabh61swG0Dvx9CRwrYgwxhEuiBPDe6nb8uV/L/h/to0+0o45Ap3IdAV3tlDAzI2O2hwTD0wlbRI6E5xms8VWZQPq2eYXqiR2z6+zMk62UUiXS16Hkm1cKXR/upNrTuX+KOqeJAZB0XMn2VmN8Z/gYvhJpYLDn7CZtTX12o661YLnqKUkXk6i34WqSUCAjg514Bat5Il4BEFOLLHjrQxbk1OdXqpIhNvv3m2q5hZLaZCJNSY5bcJ3/T9z6IllklqT213wUWGXHK3dOGku5sY8TE5oulaoGbiM8PcN9Oqur85eAY3fijblgb5c8NwGjdzJ+vgCH4zfbYq7JdSz3nun6WCks51gRHFdTvQu4TLrAutrSlb5A3MlENoXpzVQ+beOqVSuTdnGrj8WYM9hrULpNKHEOrsdqFMTYyFk6qSJB+LOuRP1wyFxfXlSfZyymRf0C3bNJMUsBOlvfbhhqXHwRr0Zmo7ivfF+s6DWHyq5aG6SeFLV2xnUWvnjgAOkjHVFbpnouTdEYULGKWslmzGRcCYHM4LDWPgRXpeVBPU5tZhEDEOH1gWO3BJ+92E6bc37jo4b/lxIdtFTzPEESLSQuoD/TgQbRApimkhDShRWs03Mb62vk6qLdQGmf5eti5zwavJR6uo35G8eQLCAbtZ9ewLka9Xr8sfx226lP4lvwKuGn3Z0rOzmM2DJC+7jdeGr9H2KPpHg+3tL3UQfwZhHhCv31fkPRAkyxR3/7g/CwWIIM73w7JG2fovUYOES4QdZYCI5PMBCF2m2M90hLx2u2GCmVUhZz/TMTGqXWvT3oA0Pc3TK/YYPkK2aHdPKs7H3VT1e3GumXkn56Wz/TpJqILBFMRr8a995QEX5wKf4lcEzw2gQtUcfxi9Jy+vR8C2UWBXO54jA2RfZOGO6TSOe1aJl54onSN05ozc057Mw638QdPqCL8jKuhkvHpfHHtrVXdV44xlA/920MFY+SPgV3C64uuljpWGSdkdHV3sFEj3qNwMkZFQvJgbEG30Ux0A1TQpjJEhA5V+8Odg6ZOQcwtYD7/I2SwzpqXY+bkqtju3obskvRZkOpsrTtHAdsoWzs14kUkzXjEsO6TzgoHcgI8IYOnxUxlcowEBLOXESfttqnupIexEjYiTG5LnCw/16KfTQquzaP4RZmjgIT9csjzAVrw2qfA/UIWETpPrv4LlVvL+WTZhrqe1tWFHF9JQAjX4wxVjypon2SY9WAVuFuoWFndhAehSae22BUQ3VB556jBZH+cFp/S5yCYyrBzvM9SxLN01ETgJSEZkp0502gdNfoYY5SP7g4uTHxtKL0qmGPBh6iCDPKsiJ007huK+NveHZYhY6ec6q3gB7a3Uvk4p2RbsZsvY6HRUwWJc0/yzC5VaFmDV7haeA8J2tGXOD32aEvvLwlIOBr3c5LwOOVtaEr5cEPBki89pf3EcdSYc9fkUugaJzr/RrH/CA9lgDWQwFnGO9Yh6Oi04RJHyQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 13013204-413d-48a1-8ba6-08da452e1658 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2022 06:55:47.3622 (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: UuOX49pnZXy7ArwaM5/M3zmaxf77nIsxK19EfEsxLbi72SCGMrzcbk48KSp3gmYfDdK3qf2cnPoTnGoNPC6aYcNYWbDWR/n5kQZ2E31AZGE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2789 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517, 18.0.874 definitions=2022-06-03_02:2022-06-02, 2022-06-03 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206030029 X-Proofpoint-GUID: 2mA602Lx5tx4xaov-SEWvrPdlvWNQOU0 X-Proofpoint-ORIG-GUID: 2mA602Lx5tx4xaov-SEWvrPdlvWNQOU0 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: Mon, 06 Jun 2022 06:46:16 +0000 Subject: [dm-devel] [PATCH 02/11] scsi: Rename sd_pr_command. 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 Rename sd_pr_command to sd_pr_out_command to match a sd_pr_in_command helper added in the next patches. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig --- drivers/scsi/sd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index dc6e55761fd1..24e61647064c 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1703,7 +1703,7 @@ static char sd_pr_type(enum pr_type type) } }; -static int sd_pr_command(struct block_device *bdev, u8 sa, +static int sd_pr_out_command(struct block_device *bdev, u8 sa, u64 key, u64 sa_key, u8 type, u8 flags) { struct scsi_disk *sdkp = scsi_disk(bdev->bd_disk); @@ -1739,7 +1739,7 @@ static int sd_pr_register(struct block_device *bdev, u64 old_key, u64 new_key, { if (flags & ~PR_FL_IGNORE_KEY) return -EOPNOTSUPP; - return sd_pr_command(bdev, (flags & PR_FL_IGNORE_KEY) ? 0x06 : 0x00, + return sd_pr_out_command(bdev, (flags & PR_FL_IGNORE_KEY) ? 0x06 : 0x00, old_key, new_key, 0, (1 << 0) /* APTPL */); } @@ -1749,24 +1749,24 @@ static int sd_pr_reserve(struct block_device *bdev, u64 key, enum pr_type type, { if (flags) return -EOPNOTSUPP; - return sd_pr_command(bdev, 0x01, key, 0, sd_pr_type(type), 0); + return sd_pr_out_command(bdev, 0x01, key, 0, sd_pr_type(type), 0); } static int sd_pr_release(struct block_device *bdev, u64 key, enum pr_type type) { - return sd_pr_command(bdev, 0x02, key, 0, sd_pr_type(type), 0); + return sd_pr_out_command(bdev, 0x02, key, 0, sd_pr_type(type), 0); } static int sd_pr_preempt(struct block_device *bdev, u64 old_key, u64 new_key, enum pr_type type, bool abort) { - return sd_pr_command(bdev, abort ? 0x05 : 0x04, old_key, new_key, + return sd_pr_out_command(bdev, abort ? 0x05 : 0x04, old_key, new_key, sd_pr_type(type), 0); } static int sd_pr_clear(struct block_device *bdev, u64 key) { - return sd_pr_command(bdev, 0x03, key, 0, 0, 0); + return sd_pr_out_command(bdev, 0x03, key, 0, 0, 0); } static const struct pr_ops sd_pr_ops = { From patchwork Fri Jun 3 06:55:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12870038 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 C9F7AC433EF for ; Mon, 6 Jun 2022 06:46:27 +0000 (UTC) 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-111-nHwMZXg5Pj21Wf9qr-aM1A-1; Mon, 06 Jun 2022 02:46:23 -0400 X-MC-Unique: nHwMZXg5Pj21Wf9qr-aM1A-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9D5441C13961; Mon, 6 Jun 2022 06:46:21 +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 876572166B2D; Mon, 6 Jun 2022 06:46:21 +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 AACDE1947B99; Mon, 6 Jun 2022 06:46:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E0A6F1947040 for ; Fri, 3 Jun 2022 08:19:36 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D2F5F492CA2; Fri, 3 Jun 2022 08:19:36 +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 CD870492C3B for ; Fri, 3 Jun 2022 08:19: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 B0F14101A54E for ; Fri, 3 Jun 2022 08:19:36 +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-498-LhkUw7XbOC-FNhK_aW5hYg-1; Fri, 03 Jun 2022 04:19:32 -0400 X-MC-Unique: LhkUw7XbOC-FNhK_aW5hYg-1 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2533AiJT010186; Fri, 3 Jun 2022 06:55:52 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gbc4xv7ss-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Jun 2022 06:55:52 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 2536oNhb025389; Fri, 3 Jun 2022 06:55:51 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2041.outbound.protection.outlook.com [104.47.73.41]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3gc8p5nyqv-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Jun 2022 06:55:51 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by BYAPR10MB2789.namprd10.prod.outlook.com (2603:10b6:a03:82::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.19; Fri, 3 Jun 2022 06:55:49 +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.5293.019; Fri, 3 Jun 2022 06:55:49 +0000 From: Mike Christie To: linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, hch@lst.de, axboe@kernel.dk, martin.petersen@oracle.com, james.bottomley@hansenpartnership.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Date: Fri, 3 Jun 2022 01:55:28 -0500 Message-Id: <20220603065536.5641-4-michael.christie@oracle.com> In-Reply-To: <20220603065536.5641-1-michael.christie@oracle.com> References: <20220603065536.5641-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR16CA0012.namprd16.prod.outlook.com (2603:10b6:3:c0::22) 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: c8b685ff-424d-4383-3378-08da452e16e5 X-MS-TrafficTypeDiagnostic: BYAPR10MB2789:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: DbtBCNp2kG0FzxJBAY8tdIuAGZTMbuj/SL0pieGO53Ius98GLsCSGkSOjGJxiNU/Gm1UojX4fZ5UVdwQQzz49pXZwEVcK7DuGe22f5hmAFsGM3iHc+2HjBzoMMsep/8nrs7WJb1dTDzn3VfAXiqtBv0sGqmEvlQqd6OB9Mun/IveyOeKJpSqeGM25ewIaiPU0aI8r93YQN64bJJEf4co32W2gGwrRt+gp772F8uATuRY7rJuUlk737UjJTcK2Ml7D+f+zRFaXbUbrOMe5hDix854D+GgkD2BFbgfKiQV1MqBNneOdYlt5DuJ/awIzR6niEtqr/5Ck/x2Naq5fuygUjsUzc5NA49ktBuXPMsyAFzVKUXbQEXPT90eEZnLYOlQwFDFwFva6CtQhk8XbiZ5CYGZJxLpz09fwxGlB1HXycyheR3XOyh7wp0EPh5bTDU6E0UV1/fTQ31JcMck2qUUb5t2nthkM0TBf7GcXvP3CKLu38PLkakN81cZN2bIcFHEk1/+T4NX6yvV0uOZrTSNEh6mhD7t/lg2pQMSwsKe6Qq6E3S+q//zPRRPR7+b+f6V6XUj0aAmuAEGfCRTJyBsQLoh0FnACx62Ee4S7Qd6IUyZHn+JTG3f+gp01ouNQ3ZasmrgyfzQRNk7kUtfP02o7RxRaKZBu+nwN/QdSfn+o2e9cbKz4hWIRLNdif//qRvNVUOeomiP8sNex1Nzu4v54Q== 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:(13230001)(366004)(66946007)(8676002)(38350700002)(38100700002)(66476007)(4326008)(66556008)(86362001)(83380400001)(36756003)(8936002)(107886003)(6486002)(2616005)(316002)(5660300002)(1076003)(6512007)(26005)(2906002)(6506007)(52116002)(186003)(6666004)(508600001); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0Zvam5uYFAekBXXYpt9TmVkd3NPxITb0GagFo+4pgulHdKKnKgOYx5LTANIKvEilZ7sr3U6b65s7K9c0oaquRLe8o0SZZ1RWU1595LGWnVcu00gaWj6lg+XuhM02Ce5xMNR3R30CKcF7h+8os502i9P2hk/9U1U1/cOv69H5UiOmocVn8YFJ3nh1uH+g4Zp6lv3UTiF8zn3JsrETCfzkG8CmOuMCvdgL/5MQjYdcZMmyNy6fhRa9ZUCB7+xHeEqp0s2PuHV/E6P4JbRTJ1Kve3GsZ2GEq+mLVroTf+sx2qYyFYuKrUhLatxOiWHlqap1QwTcRQV1iHqTn838y0mGGHlMGfBXbcNjSK4yLEFO1hQ0SObWRM3jH1rj/Ah0c2GnF+vTHoIa/UD5zuBNg50ZGUJHIwQVpjkKzEhuKodwIe6ekUBC6qonTDcfUkKUrf4CZ6uUnX1cScIYhafJg4FtxSJLXiMfk0qsmUR1OMG12Ald1OV8I2sz0hkOAhQXNfYBt/FRpxXE8CXMG/26EnCX3Dp9Rc+Vn8d+V8qNHRyb+0xbGr4QZOnxndVaqnpf/IBRlmd1Ztq+rgSSekHh8Z1J164DkiY+HLs9lHf6OhxRrbkiNUEsLEidkcutN3bxZSviYqn/n1iCFQKa8oekzB+DkYBDAOZrLNI+igmJ1RegVzJFneEwRSfuMXZBP3Xv/2UpYe2kwHSfaWjzE8WChVA2hlwxjpIMPY7uAdP+uyJO7gHsS2cNAN/YI84SrpWC1UfQf8cBpm9Dn7xS35BM+6e8TvCGno2+M51jWWr/bQcozFDd9LYZHP6T90GkDjLARiqsnkyG9W7hiFgC3kSeB1sWes2wAajhCpqGM9ZXqdbckfVZsWzi6r5vBYVegtEjmZAbDw1i6+xrhbj29GFC2C4W3OTJ20z6lTWwrPeE9Pzgh62djFY96XsLgrGqVHJuRb8pnxv+Ol3ydv8ICTFdim2zwruXK/qmYNNCrpM/nPnC3NFshAjHb2PI1GLySqQ6Vr896Ny7Lz/zfdchMamA12bhaH4ixxRtyp0Nxj2T57SvfrH6ulhY1xiF/RcJllsW2UH8G9zmyPrmkiQyfttywixIuHnU/+CmgoyL2QZHKycsoj8Qj6z5jJKspEE5uhDZd/Bx5JHn59aG4LLDaboiwIBMfY42Sfqpgris8Br4/Lf2xE6b9tPUKLFOe9zzkjTEF65L/tmYdJ1I4OXVkptzVTy/AJqHwiYDcjVCmxvDGpSJW2fZawhfsTrz8joj6tXJpfOqy+lLKH5nNnmyiqEUCOZUxBDlJfWIO2CIAfN706w7V3p9ZzSD0k5Ke4VBqUxvo9K9UJ2gl5pEqGzbzzZxoVa4J/ORQBue44cG4k1iLfqlspIAwTraZoxsDL6oFqNtUvPa524BYyZmkxH4YfEzjO1gnOP+hTTCKGQEuEBVftbptBXcbK1LK4bSBFOwBnySdgcSTyNc5J7zHYg7zBQRZz+789OzxNoBpCwbNZTsNKoVeG1C8H5NA0TYMysTb01G05ZoR6zkyBh3u7GVFEg5GfwFdfm7jYmd11BO9AHKpJlZeEtfiFZ8k1f55icvzqLzlrF8rCADE3YkCee0457hAlBEle4Feu1843mj6tazZD60IgRJ/ZeKla7BDI2Hk/XRqI7zZnEIfANbzx0W+PNrlhpCCspEtmXDSFbB0Koi0v9zvFNsX2e1FnlwexhuIy8VAaMnaAWyJzBunLMhgvU3LPrrOqUIp0MZIPdawBo0xkNrKfM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c8b685ff-424d-4383-3378-08da452e16e5 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2022 06:55:48.2684 (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: mTUN4mmG6Om3PfqZcbc8wNvfmVfcBVhZpzkG1OiJLzfxehuyPisQUaahztkbTnKXsoWrk3EKIbKBOezgQQ0IQjGb6Ktv+N6cQ5GwMuHjhD0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2789 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517, 18.0.874 definitions=2022-06-03_02:2022-06-02, 2022-06-03 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206030029 X-Proofpoint-GUID: slBpevspyyqvYQ2UcdU8SrUfmIapUBgp X-Proofpoint-ORIG-GUID: slBpevspyyqvYQ2UcdU8SrUfmIapUBgp 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.9 X-Mailman-Approved-At: Mon, 06 Jun 2022 06:46:17 +0000 Subject: [dm-devel] [PATCH 03/11] scsi: Move sd_pr_type to header to share. 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.6 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 LIO is going to want to do the same block to/from SCSI pr types as sd.c so this moves the sd_pr_type helper to a new file and adds a helper to go from the SCSI value to the block one. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig --- drivers/scsi/sd.c | 29 +++++----------------- include/scsi/scsi_block_pr.h | 47 ++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 23 deletions(-) create mode 100644 include/scsi/scsi_block_pr.h diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 24e61647064c..765fca0f38c7 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -67,6 +67,7 @@ #include #include #include +#include #include "sd.h" #include "scsi_priv.h" @@ -1683,26 +1684,6 @@ static int sd_get_unique_id(struct gendisk *disk, u8 id[16], return ret; } -static char sd_pr_type(enum pr_type type) -{ - switch (type) { - case PR_WRITE_EXCLUSIVE: - return 0x01; - case PR_EXCLUSIVE_ACCESS: - return 0x03; - case PR_WRITE_EXCLUSIVE_REG_ONLY: - return 0x05; - case PR_EXCLUSIVE_ACCESS_REG_ONLY: - return 0x06; - case PR_WRITE_EXCLUSIVE_ALL_REGS: - return 0x07; - case PR_EXCLUSIVE_ACCESS_ALL_REGS: - return 0x08; - default: - return 0; - } -}; - static int sd_pr_out_command(struct block_device *bdev, u8 sa, u64 key, u64 sa_key, u8 type, u8 flags) { @@ -1749,19 +1730,21 @@ static int sd_pr_reserve(struct block_device *bdev, u64 key, enum pr_type type, { if (flags) return -EOPNOTSUPP; - return sd_pr_out_command(bdev, 0x01, key, 0, sd_pr_type(type), 0); + return sd_pr_out_command(bdev, 0x01, key, 0, + block_pr_type_to_scsi(type), 0); } static int sd_pr_release(struct block_device *bdev, u64 key, enum pr_type type) { - return sd_pr_out_command(bdev, 0x02, key, 0, sd_pr_type(type), 0); + return sd_pr_out_command(bdev, 0x02, key, 0, + block_pr_type_to_scsi(type), 0); } static int sd_pr_preempt(struct block_device *bdev, u64 old_key, u64 new_key, enum pr_type type, bool abort) { return sd_pr_out_command(bdev, abort ? 0x05 : 0x04, old_key, new_key, - sd_pr_type(type), 0); + block_pr_type_to_scsi(type), 0); } static int sd_pr_clear(struct block_device *bdev, u64 key) diff --git a/include/scsi/scsi_block_pr.h b/include/scsi/scsi_block_pr.h new file mode 100644 index 000000000000..7d137c067331 --- /dev/null +++ b/include/scsi/scsi_block_pr.h @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _SCSI_BLOCK_PR_H +#define _SCSI_BLOCK_PR_H + +#include + +static inline char block_pr_type_to_scsi(enum pr_type type) +{ + switch (type) { + case PR_WRITE_EXCLUSIVE: + return 0x01; + case PR_EXCLUSIVE_ACCESS: + return 0x03; + case PR_WRITE_EXCLUSIVE_REG_ONLY: + return 0x05; + case PR_EXCLUSIVE_ACCESS_REG_ONLY: + return 0x06; + case PR_WRITE_EXCLUSIVE_ALL_REGS: + return 0x07; + case PR_EXCLUSIVE_ACCESS_ALL_REGS: + return 0x08; + default: + return 0; + } +}; + +static inline enum pr_type scsi_pr_type_to_block(char type) +{ + switch (type) { + case 0x01: + return PR_WRITE_EXCLUSIVE; + case 0x03: + return PR_EXCLUSIVE_ACCESS; + case 0x05: + return PR_WRITE_EXCLUSIVE_REG_ONLY; + case 0x06: + return PR_EXCLUSIVE_ACCESS_REG_ONLY; + case 0x07: + return PR_WRITE_EXCLUSIVE_ALL_REGS; + case 0x08: + return PR_EXCLUSIVE_ACCESS_ALL_REGS; + default: + return 0; + } +} + +#endif From patchwork Fri Jun 3 06:55:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12870039 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 AA6B7C433EF for ; Mon, 6 Jun 2022 06:47:03 +0000 (UTC) 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-669-ek8zC3C5Msq0dzJqJD4CEQ-1; Mon, 06 Jun 2022 02:46:22 -0400 X-MC-Unique: ek8zC3C5Msq0dzJqJD4CEQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 52C2C101A54E; Mon, 6 Jun 2022 06:46:20 +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 3F99E2166B2A; Mon, 6 Jun 2022 06:46:20 +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 E662319451F0; Mon, 6 Jun 2022 06:46:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 66C851947040 for ; Fri, 3 Jun 2022 08:29:47 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 42C2B1410F37; Fri, 3 Jun 2022 08:29: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 3DC411410F36 for ; Fri, 3 Jun 2022 08:29:47 +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 E5C00101AA46 for ; Fri, 3 Jun 2022 08:29: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-552-5y5Lpo3rPuiZkqrBtY7oSg-1; Fri, 03 Jun 2022 04:29:45 -0400 X-MC-Unique: 5y5Lpo3rPuiZkqrBtY7oSg-1 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2533AiJV010186; Fri, 3 Jun 2022 06:55:52 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gbc4xv7sv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Jun 2022 06:55:52 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 2536oNhc025389; Fri, 3 Jun 2022 06:55:51 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2041.outbound.protection.outlook.com [104.47.73.41]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3gc8p5nyqv-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Jun 2022 06:55:51 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by BYAPR10MB2789.namprd10.prod.outlook.com (2603:10b6:a03:82::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.19; Fri, 3 Jun 2022 06:55:49 +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.5293.019; Fri, 3 Jun 2022 06:55:49 +0000 From: Mike Christie To: linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, hch@lst.de, axboe@kernel.dk, martin.petersen@oracle.com, james.bottomley@hansenpartnership.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Date: Fri, 3 Jun 2022 01:55:29 -0500 Message-Id: <20220603065536.5641-5-michael.christie@oracle.com> In-Reply-To: <20220603065536.5641-1-michael.christie@oracle.com> References: <20220603065536.5641-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR16CA0012.namprd16.prod.outlook.com (2603:10b6:3:c0::22) 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: b3834d5f-bc5a-49ad-b456-08da452e176a X-MS-TrafficTypeDiagnostic: BYAPR10MB2789:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: TTw0BtoMvlrTbC/la2h4ZsZYxenE1okmCjtLrorXweFslk+QJTA3vMutGuMSjS021tkaOhiWt9vwUWgFYGgeS2scUb9bczd9A+iSii4TbBdM/5SL4U5p++V+FjyB4R5AMypzF47HmtF4uHxCLf89a6/aw23naioyGKpIS7Jpc3zL/ibZB36Y+RsUlv1IX1eSFacmIgi72QtLhB1hKlVrgEYgar+/hCKK4Jr80cUipw8SHJMQmlPtr92YffdMesTXoMyk/apsDPYm0A9e6EVRsdRGMlUUHRL0ocAmxJ29k9Utm+8j93sWjAgm/9Y3C3CiRMQ7seJnAHb8bpn2iALCHyhDFe9k0M8SjaeEXukIFTFJQnhakhj3fC1yuC/88CN4KB+CV/mCWbkuPIEBQ/ytoQ4EQ8JVKjo/x9nCHYSGGskIBUdF8ytPL34WCEUwrypwToCgkNKzw5JKOZdeQtLhAYNweLdQv0R8UeMmH/H2UrLHl/yuEsFx7N8FQbNxgO0k/HNvIuczm/PxNaLuFDgelw4heZxlwrEgXq9neUJx2c9zdJv+9Lcn7DBL6A1lz9X27J9RSM90s6fXxLK0l6W1jcKXiyIrvB663dy6hZ+1Sf3RuJGsrjxzWFoDRg81ysJkGe7jOvux1RutObF2dnrOEDs3hozeq3X+yHvlEHsu/iowsxNZtB14A1e9AseE6IzX8/Fbt3xbKp0v4La+SPAPLA== 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:(13230001)(366004)(66946007)(8676002)(38350700002)(38100700002)(66476007)(4326008)(66556008)(86362001)(83380400001)(36756003)(8936002)(107886003)(6486002)(2616005)(316002)(5660300002)(1076003)(6512007)(26005)(2906002)(6506007)(52116002)(186003)(6666004)(508600001); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: q7B+2KzXDdKVaa7mfc2pF9DubtoSL1H2ql7Uv5IUza3lSjNOEA5xw5n/XXiN5D7amh/5blIHTXIc+PIL+aP1BChN2cyvZunCOCuwna4dFJZlcu2yWOav6mNeG3OUcWZv3M9Vj18fncf7qPunJ138rZMUBAmcQdjF+4N3F2edP52BwX/FH6m4c/Ao4qcalgC51PksYRgFVd7qhjjkIB5ZOmYvdiKLVrJRQuTmRT2C1TdRfCso0gGXYXsME2Z+QhXeeWE1pYa+FkDPLMnYdnCxDk08WOaUjdYJtzKP4kkEQB7U2uXXMOiAoBIx7UIepsOOD3WmXAtL6XdgpUynMAhjmAaWzFFTjHZOmQzg8Cklss65oHRl/MEkjLQHLMbYYKSW8Ee5kK3wfQHx1syaFn6Pswap7vPgKsvHcb5CryBcF+ACpxvtzpjT/7KIxg1Sj1S/wqcLQc2SXK+CFhu8TYvxvKkd05t296W+PBS2Pss5m5Xdjd4/M5jLwxLoX0mTgdgX4q2UOahWFUIpFjcFk3JQ5+fn0MufT9AP0N8Epe6Utd60Rix4SWjeA0BM+wFL1U49dREl8mOpXmmLc8AscK8vAZeXRJykHQqDyVQ5KrJ9OFyX+Rt985CGRIuagTZTqBHWV/hWs5az0s34kEu9CyS/e7R8VkzMZOdIEswOWRP8oUtdN48Qoir4eDatX+L4zVHTfcJpoqlKe4lXs4zov5WO4JLGVBjLMWBeTk2HbAY+1Jo5HpT57zvw1CvL0sZTiWNteddIdipy2Lb7QT0FC2OQBE0n+cgez/nqZJbytllei9NYyIl41vDnyQjlJNkqWG7ZCajSJXM+YWQk6J8kA3Tw/iFDeeAKfGYyeBNmlvkcVcPZ4EKaUtJJUcNet4BxTRPK7ghA5qFWRV4b9TRJULIfoQYxO6wy64GR6qbvRjx1pvZzWRrVNUqz1s7xjtGHCfnGIpHAo5Swjf5Ox8LOpKoAjAYIjHi4DTPRFOHrQ3aeFueRIk7vdieGBWvddDe0xCnRBMIHC4sKJ83FJHfM7j1Kc0woCt4/ex1w4syDgah8p9h+DVgYwK4SU/IK1D9l5OMX75vEHmKKKKw7Kq95xzJys0mX9e1wruAT5meZ1m+mjqVQkNr9h894px2A20u6qE5QdpqPxqcLeS+K2ZBEGB3ZOZ9/kipNKvtzHNn4t1GANzXZpvN4qJ4YqvWlx7aFrbzCZNMOcc9k2tZVjPoLp7zwfN+L3SVjgyIDF7Zucw3j/NW2AGwpNHDCoc8gbzv6eGUFFJm7Q06oVZg5qGVsoG/q9l8Kwqi0Bpp9W2OqIcYxjEQrs+oAPlF72xnuSK6tMQQS7Y1pW0qH38yHgkV69I2OVO0OMi1nFVNlF12aewAKvaeC6fwIIAU9pgCGbK08STiLE541OEXBQBjku7byrFl4sWx1+XGdpLhnwF0Ie3JjOpaOxn0dqVaZAyv1HFGaxLfg7QZSJdXLUiH76HLBMX99BU1vD0S1A3r9+8InjFihqzlIBAbBF4EjVyfeXpoonEWvlRhxOR3Eze5cDaQm3eArHhfpDpXc8e2cyxVcrASfuErcZiDbKF+qGeAwkr3CGHyRhDDSIDor3es3cHyKmVHXPi03xo2cdD3v8f5itos95hXM2qTqPp+6lSR5S96Ua9I+WpUBh703eOoZQys2SKwGIKUB0kEGMgyWlQTaS+qXzb+ysQ4vSXbV+sIHmRk8/IPRoIznZcsQt9c+2op0p2fmkoVerBcNQ408RK3RxIsJ8ks= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b3834d5f-bc5a-49ad-b456-08da452e176a X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2022 06:55:49.1746 (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: Zv8EKqhi/AIaEwusXmn78d7CFPIPxuQA+PDKCFggltSppARlwUai73pDUzFKsTcZc05UQGyRSUvuzwEsMoAsBRoRHqLtm4mnx5z8nn5yads= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2789 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517, 18.0.874 definitions=2022-06-03_02:2022-06-02, 2022-06-03 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206030029 X-Proofpoint-GUID: 55Clha1AkpeCod82uKrc2wirAmUI9ZKb X-Proofpoint-ORIG-GUID: 55Clha1AkpeCod82uKrc2wirAmUI9ZKb 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.7 X-Mailman-Approved-At: Mon, 06 Jun 2022 06:46:17 +0000 Subject: [dm-devel] [PATCH 04/11] block: Add PR callouts for read keys and reservation 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.6 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 Add callouts for reading keys and reservations. Note: This only initially adds the struct definitions in the kernel as I'm not sure if we wanted to export the interface to userspace yet. We may want to refine internally for LIO and when we can enable it for NVMe then add the finished interface to userspace. The latter is not done, because NVMe's report reservation command is similar to SCSI's read full status where they return a remote and local ID as well as the key/reservation info. However, a lot of SCSI devices don't do remote/local ID parts correctly. It seems that read full status might not be used very often so does not get a lot of testing. Signed-off-by: Mike Christie --- include/linux/pr.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/linux/pr.h b/include/linux/pr.h index 94ceec713afe..21a8eb8b34b5 100644 --- a/include/linux/pr.h +++ b/include/linux/pr.h @@ -4,6 +4,18 @@ #include +struct pr_keys { + u32 generation; + u32 num_keys; + u64 keys[]; +}; + +struct pr_held_reservation { + u64 key; + u32 type; + u32 generation; +}; + struct pr_ops { int (*pr_register)(struct block_device *bdev, u64 old_key, u64 new_key, u32 flags); @@ -14,6 +26,10 @@ struct pr_ops { int (*pr_preempt)(struct block_device *bdev, u64 old_key, u64 new_key, enum pr_type type, bool abort); int (*pr_clear)(struct block_device *bdev, u64 key); + int (*pr_read_keys)(struct block_device *bdev, + struct pr_keys *keys_info, int keys_info_len); + int (*pr_read_reservation)(struct block_device *bdev, + struct pr_held_reservation *rsv); }; #endif /* LINUX_PR_H */ From patchwork Fri Jun 3 06:55:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12868722 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 313FEC43334 for ; Fri, 3 Jun 2022 07:18:08 +0000 (UTC) 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-657-K-Il45h_P9yGdzNx3dc6xw-1; Fri, 03 Jun 2022 03:18:04 -0400 X-MC-Unique: K-Il45h_P9yGdzNx3dc6xw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 345A618A6529; Fri, 3 Jun 2022 07:18:02 +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 18CB683B8E; Fri, 3 Jun 2022 07:18:02 +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 2ED351947057; Fri, 3 Jun 2022 07:18:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BDF911947040 for ; Fri, 3 Jun 2022 06:57:04 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 923872166B2C; Fri, 3 Jun 2022 06:57:04 +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 8CB282166B26 for ; Fri, 3 Jun 2022 06:57:04 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.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 71D56101AA45 for ; Fri, 3 Jun 2022 06:57:04 +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-554-bkVjNYpBNg6ucup8bYrMPw-1; Fri, 03 Jun 2022 02:57:02 -0400 X-MC-Unique: bkVjNYpBNg6ucup8bYrMPw-1 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2531DiSX007640; Fri, 3 Jun 2022 06:55:53 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gbc4xv7sy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Jun 2022 06:55:52 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 2536oNhd025389; Fri, 3 Jun 2022 06:55:52 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2041.outbound.protection.outlook.com [104.47.73.41]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3gc8p5nyqv-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Jun 2022 06:55:52 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by BYAPR10MB2789.namprd10.prod.outlook.com (2603:10b6:a03:82::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.19; Fri, 3 Jun 2022 06:55:50 +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.5293.019; Fri, 3 Jun 2022 06:55:50 +0000 From: Mike Christie To: linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, hch@lst.de, axboe@kernel.dk, martin.petersen@oracle.com, james.bottomley@hansenpartnership.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Date: Fri, 3 Jun 2022 01:55:30 -0500 Message-Id: <20220603065536.5641-6-michael.christie@oracle.com> In-Reply-To: <20220603065536.5641-1-michael.christie@oracle.com> References: <20220603065536.5641-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR16CA0012.namprd16.prod.outlook.com (2603:10b6:3:c0::22) 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: 55a7c3e5-f2cf-449a-8310-08da452e17fe X-MS-TrafficTypeDiagnostic: BYAPR10MB2789:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: tCICC4H/zQkRM6oGQrGH/h0cjjLQJI1bDnhgBTKfCDIhEpA7ZolriFTZ54qePMD2zqB+7qmB5XdJDt7RC4nKciPbKE5u6RBq4NNM6K0Sw4/hHPImPe7/aAiKkkhj/57gLTUzCUYvGrV7PgUM8o2RqejSa9yYyKpk+kArnRhf4n7gE2DpqohNAB/6x9BzsxntCl+E6PN1rmFaX0BgkKa9Gsk3lWauF6AXWrm8DJeTGu1avbn6cwUchNxDnhM1pPQMqSQ7QZh1YlUskLNZfZeVQOVdLK4Pkv2xpowbkpfXaJOgJSQHz6DQUJ9M8llm2QWoUQ66k8WRER766SiIZTBLjklrfhGVuFZTAW6EfrjMmE7PjV6+VOSqpzlhRM5/XF8yHCqeIGdvhx2LUHDwVkYLZmZJVhsKHWVJvi+SHHAMg8tYRLPYHRP2BasNLg6Sj2CozON9O72hIiuMJbqwn/10r9QYhQriSdo9ryZ+MdmiJCMPB8E3AhyTW3jVTKe1++6RqsEGUeOflWRfcMi9I2TQs6UuUWyHF52uLAHPFtp39izCLo46YBqfFw22YbmJgrD8ei6psJAdGwhXsSL5bVCab/hrjc0IwvntVi2L7vKw6Yvw2As9y+kpiDZd4+qpftbubl1emNZ1Yq2j2yOQqxGZ6RSOHhTePFq3+Uh57Iq3YecCuixqeQ4OjPoi1ZbeBNc38kxf/XyvqiYjCq6WgS4/zA== 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:(13230001)(366004)(66946007)(8676002)(38350700002)(38100700002)(66476007)(4326008)(66556008)(86362001)(83380400001)(36756003)(8936002)(107886003)(6486002)(2616005)(316002)(5660300002)(1076003)(6512007)(26005)(2906002)(6506007)(52116002)(186003)(6666004)(508600001); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hahcfZK1Ee2+vQaR+D2dQaTwygXJfGMpQCqq8R17ySdBkiL9N4TNrQtPOg7gdOPa8Z/zq5PBPa0dAFFiBkU67q5VhOE1x9wdSv+17gHINsJBoj+1nKrJGibecX/JYYUG6ZcVR8/QGNqh2flsYu+RsyjEgL7UzBXN4iz1TW7kSvvQ0EghjPEEJuL4Ry7GOQtu9M4clUbcV+oBvCh17CwyBQA4kTiqa8WUoNTcxtl4+WjcGKd1QARg5az41kGVGmI5zFWaoXvCXzLdGaPETXDz2eVIJXl4OqOhrqXaPftpXB2q2Iu/byxCsKPZ9xbnNSGiXWmL33ZGT/V1Y7swuIDDHmrGVRpl1ykxy2gEmO42TtIIz9mnyTqwskb435gLciIZlwB9IZCvPqMWp9DmUuqoNyKJ2hjlTP4hRBly2NkLv8/tSBN26FJk7ocrUrZuHFMKVPnPXAqJvBrIH0f3D5fIjQ50DuMuDOHxmNw4TkixFOHV+nEn5D7LlOmR0xPsWt28YfCHzTGR2u+tulrwhRWcfb8fBnst4xYWUT4/QAuTh8IvqfgtbMsf2bTsPTTJ6iT1FHkEEO5WxjQiA32GLd0YOFoJjI7c7bLfQJpWmIkTvpEdYp6D6cpGlKJcY+CnGhVUVzcjb5u0RbF3mYrodLQej274muNCnkLboczh2DbTbBUD9KlDECciG7OhHX1ljAAF7Ln/Su8ZAGOqJYxifVtCLqq930GYB6sHQHmLJyzqpn2YlwAbNDCWRLL7ljFO82KnRxV82QpXm+aqb0SV2J4pF5xdV/Ja2+4tB0C5BSo4Y59rNT0uJgpccBnd4ikWDoRhEZE3JM7F3E6lgh5fbKGNPICba18jrLk+f4ZBPrErE1UhfVEPIIR1a2MFQdh3ZZUroMrOMqJ5fAhZY2YAhUl1U63wG23ZN2MW7e5W0Bi5bYz6jEE2ZdxkSA6eJWvFQkGXfEycKUAMiAGOBe68wnjdpRzFjvhsPTWcPvgf5GrqzviLC5E9sKxxc6gIBMxUBliJI5HS1ZObz6BssoUnPN+m8KmsoB3tIxq7XtqoYJ/gbravz8Q5w0TuX5yt96WmHWcrIhR1+PsnXKTG1x/P/OWLcCzCuVtE6s3nVvqYZi5KEAYPuY+3zq8IPPTekoYgFVuMfivs4STXiyr5Ucy+kkUBtgN20H10c8fZ+kfMEPzuQwTHwIYQB2oaqVMa9d6T90rwzNVLfIC+GNkgucMQC4dR3BJoouoNKgye3hjUPCcA/5sX6AM0FNMrLt70R6SwTvEZEcMSHjGP63iPYJLfGkHqzg0Awmk9Aq4kQzF0X2O98ZyOKqj7jazSpuEZfSPQT1hsj+PT07GsBbQrOn0EImEpygSwfdR1+SzKxumo7GvRQj/OEtwwFsD4keEaEajggHXbd+oXdNThPMhE6IrqDLqlntWFRfuELzmK/g82hUuGLbHXFvrVKj9A4QloWfkO0n5JSMW4r1UV/QYOOZ26yswS5QMD2qa940SPcDW2PkBWXmpAZgVjfCM/aJsILzJIA3tIcR87Pdh/5JLrhmqO8+DDf/nYIYxiLtOphFZ1K/ju8zGjEfsuFcCrKJzhD3REamfRgqlmmwytneSb5qyeEywuweloDLIsIDa4B4nDN7IwKdgJxty/of7HP0CglNPnLDIz43oTACEbjm9HXRyRb+lE2TAOlmGy/2D8nbtKv644ysrOaBU7pm8oVLEHMa/UcqSTZu7I9816I1rDaKcjsKYsEhV58sYy/Z9mGIo9H1kmXbM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 55a7c3e5-f2cf-449a-8310-08da452e17fe X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2022 06:55:50.1432 (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: POIJMB9DhMLr3cqTv9C61cFA7AMZYSJdJrmI5ZeJMTAx04q3LOM/OM7RJWIm1DjIfWIoma50xKjltpcjgBMwjI3mddzFMyTDbonDOlGaVxA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2789 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517, 18.0.874 definitions=2022-06-03_02:2022-06-02, 2022-06-03 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206030029 X-Proofpoint-GUID: P9n1_VNzfceYzCx-i2OkdUdejI3hzJhk X-Proofpoint-ORIG-GUID: P9n1_VNzfceYzCx-i2OkdUdejI3hzJhk 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.6 X-Mailman-Approved-At: Fri, 03 Jun 2022 07:17:56 +0000 Subject: [dm-devel] [PATCH 05/11] scsi: Add support for block PR read keys/reservation. 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.79 on 10.11.54.5 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 adds support in sd.c for the block PR read keys and read reservation callouts. Signed-off-by: Mike Christie --- drivers/scsi/sd.c | 88 +++++++++++++++++++++++++++++++++++++++ include/scsi/scsi_proto.h | 5 +++ 2 files changed, 93 insertions(+) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 765fca0f38c7..71283aaf3e82 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1684,6 +1684,92 @@ static int sd_get_unique_id(struct gendisk *disk, u8 id[16], return ret; } +static int sd_pr_in_command(struct block_device *bdev, u8 sa, + unsigned char *data, int data_len) +{ + struct scsi_disk *sdkp = scsi_disk(bdev->bd_disk); + struct scsi_device *sdev = sdkp->device; + struct scsi_sense_hdr sshdr; + u8 cmd[10] = { 0, }; + int result; + + cmd[0] = PERSISTENT_RESERVE_IN; + cmd[1] = sa; + put_unaligned_be16(data_len, &cmd[7]); + + result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, data, data_len, + &sshdr, SD_TIMEOUT, sdkp->max_retries, NULL); + if (scsi_status_is_check_condition(result) && + scsi_sense_valid(&sshdr)) { + sdev_printk(KERN_INFO, sdev, "PR command failed: %d\n", result); + scsi_print_sense_hdr(sdev, NULL, &sshdr); + } + + return result; +} + +static int sd_pr_read_keys(struct block_device *bdev, struct pr_keys *keys_info, + int keys_info_len) +{ + u8 *data = (u8 *)keys_info; + int result, i, data_offset; + + if (keys_info_len < 8) + return -EINVAL; + + result = sd_pr_in_command(bdev, READ_KEYS, data, keys_info_len); + if (result) + return result; + /* + * The device gives us the info in BE, but users want it in a easier + * to use format so we convert it for them. + */ + keys_info->generation = get_unaligned_be32(&data[0]); + keys_info->num_keys = get_unaligned_be32(&data[4]) / 8; + + data_offset = 8; + for (i = 0; i < keys_info->num_keys; i++) { + if (data_offset + 8 > keys_info_len - 8) + return -EOVERFLOW; + + keys_info->keys[i] = get_unaligned_be64(&data[data_offset]); + data_offset += 8; + } + + return result; +} + +static int sd_pr_read_reservation(struct block_device *bdev, + struct pr_held_reservation *rsv) +{ + struct scsi_disk *sdkp = scsi_disk(bdev->bd_disk); + struct scsi_device *sdev = sdkp->device; + u8 data[24] = { 0, }; + int result, len; + + result = sd_pr_in_command(bdev, READ_RESERVATION, data, sizeof(data)); + if (result) + return result; + + memset(rsv, 0, sizeof(*rsv)); + len = get_unaligned_be32(&data[4]); + if (!len) + return result; + + /* Make sure we have at least the key and type */ + if (len < 14) { + sdev_printk(KERN_INFO, sdev, + "READ RESERVATION failed due to short return buffer of %d bytes\n", + len); + return -EINVAL; + } + + rsv->generation = get_unaligned_be32(&data[0]); + rsv->key = get_unaligned_be64(&data[8]); + rsv->type = scsi_pr_type_to_block(data[21] & 0x0f); + return 0; +} + static int sd_pr_out_command(struct block_device *bdev, u8 sa, u64 key, u64 sa_key, u8 type, u8 flags) { @@ -1758,6 +1844,8 @@ static const struct pr_ops sd_pr_ops = { .pr_release = sd_pr_release, .pr_preempt = sd_pr_preempt, .pr_clear = sd_pr_clear, + .pr_read_keys = sd_pr_read_keys, + .pr_read_reservation = sd_pr_read_reservation, }; static void scsi_disk_free_disk(struct gendisk *disk) diff --git a/include/scsi/scsi_proto.h b/include/scsi/scsi_proto.h index f017843a8124..07ff33ea27e9 100644 --- a/include/scsi/scsi_proto.h +++ b/include/scsi/scsi_proto.h @@ -151,6 +151,11 @@ #define ZO_FINISH_ZONE 0x02 #define ZO_OPEN_ZONE 0x03 #define ZO_RESET_WRITE_POINTER 0x04 +/* values for PR in service action */ +#define READ_KEYS 0x00 +#define READ_RESERVATION 0x01 +#define REPORT_CAPABILITES 0x02 +#define READ_FULL_STATUS 0x03 /* values for variable length command */ #define XDREAD_32 0x03 #define XDWRITE_32 0x04 From patchwork Fri Jun 3 06:55:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12870040 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 7E127C43334 for ; Mon, 6 Jun 2022 06:47:05 +0000 (UTC) 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-220-1SevBIsdOUCwancecuAcjw-1; Mon, 06 Jun 2022 02:46:21 -0400 X-MC-Unique: 1SevBIsdOUCwancecuAcjw-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 524171DC2427; Mon, 6 Jun 2022 06:46:20 +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 3EC541415101; Mon, 6 Jun 2022 06:46:20 +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 03ACA1947B9E; Mon, 6 Jun 2022 06:46:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 688041947040 for ; Fri, 3 Jun 2022 07:28:44 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 490112166B2E; Fri, 3 Jun 2022 07:28:44 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 440F12166B2D for ; Fri, 3 Jun 2022 07:28:44 +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 22A803806720 for ; Fri, 3 Jun 2022 07:28:44 +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-468-rk1jKUkjPwmjYIFA_yIUbw-1; Fri, 03 Jun 2022 03:28:42 -0400 X-MC-Unique: rk1jKUkjPwmjYIFA_yIUbw-1 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2533RLC7018224; Fri, 3 Jun 2022 06:55:53 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gf8rwrbeu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Jun 2022 06:55:53 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 2536oNhe025389; Fri, 3 Jun 2022 06:55:52 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2041.outbound.protection.outlook.com [104.47.73.41]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3gc8p5nyqv-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Jun 2022 06:55:52 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by BYAPR10MB2789.namprd10.prod.outlook.com (2603:10b6:a03:82::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.19; Fri, 3 Jun 2022 06:55:51 +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.5293.019; Fri, 3 Jun 2022 06:55:51 +0000 From: Mike Christie To: linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, hch@lst.de, axboe@kernel.dk, martin.petersen@oracle.com, james.bottomley@hansenpartnership.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Date: Fri, 3 Jun 2022 01:55:31 -0500 Message-Id: <20220603065536.5641-7-michael.christie@oracle.com> In-Reply-To: <20220603065536.5641-1-michael.christie@oracle.com> References: <20220603065536.5641-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR16CA0012.namprd16.prod.outlook.com (2603:10b6:3:c0::22) 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: bd23a3e4-912d-4224-2ae2-08da452e188b X-MS-TrafficTypeDiagnostic: BYAPR10MB2789:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: iReRVgQOkF1GRV6cY2JXE2vU/RO+JGJCwK1VUhbkuAqOZj3UXTSFiwvr7c56wWdZ4PXCGxmz9QVs8eCv8p2hnUByzDkGQ8G9zcDuvctjVDt6PKsVlZz93jPeZQ9kR+gNqzbsSmmulnChEKBbz3ZHdBTOo7Ls/Olq2+Z7gGoU/hZk0jLpx0Vd+NhrRJqNAv+zXWpBjEUocc0br+SFc13uHFxDRNVXoNaijmsm1I0mKWKUQIp6GNaMs09Y6Qj4qobHL1wsaCopuq6wlcqAP0qxt9NJ8wG/8EjydYFYNP+yjzcWwQ4w6wTWqyxK5ZrFhgeYlhyGRyu5Po0tttrHwLMoLgeFlkFPX43nuanU7gF0Pmv+ufc2u5AM0BXKO7WYNcQRsV5EFFcoL/6yc4FKJeSF0mdZltqZN9nI707xXol5Azn6Eyn0gbxZYs/Lrd0lmE/IRihi95OIHcjnvfRiJQZyNa7O2YdEI/sQQo8Q9RmLNVpP4nlLLdtQrkgJTHlIIXg1pAcOK2Dnqu4Hq8IYwpq5c/3c/N/XoBnPcFFKfPXiIvJvcXD9WvcaCiXBbMwplEI7nDMV/hZXG8w3W2GvoaOsQDvk2A8tlF7N9xx8ZxwbNoOp1sT+Wvb7kHLQBteE//cy7k6jtDsqStloDsVHb0B/tx7zA8ZssjbWLvYnPDz8uTC1DYEIr0d1zM9RQ7xbbQ+GGW8YojxyzVDtNXJh9lQ4/g== 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:(13230001)(366004)(66946007)(8676002)(38350700002)(38100700002)(66476007)(4326008)(66556008)(86362001)(83380400001)(36756003)(8936002)(107886003)(6486002)(2616005)(316002)(5660300002)(1076003)(6512007)(26005)(2906002)(6506007)(52116002)(186003)(6666004)(508600001); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +R8Sjq9a9gBhiz4yxU2sLZHJBsWRtSmMj0wUqvSMH33SsWXTvltaEvJtJIEmwRQDEcpB8Ga8yRCZcMKnSwlgE0wS7DS9huhFgCSOO+3M/tNN/jCzwJX0qcZ+wlNkf+4pT+aNC4YzjcA6WVdse3btiAEZqj3kAXpu84XLlT7DdOAlEbbtNgCL5n2ly6f+2cSV+2xZnYJazt0pyemt06CEzoXOD6RSetBBicOOD/X41rJzgHE/sXgFDZ/O4XUj+3Jbd1qL8eY7S7I3ID9s/K+tHflhqrgARjBZWA+CXj87B9nJA395HGehWRYoUoyRr8NgqMrv6Z4I94zjv9Jz+2I8/9gb4bvmRrvLJjBKK5IgcCv4Y+u+/nj2FJ/7oyNGKNpWmJ9PiLqwU5WXO8A6hBKUToKA5/RT3biB04p6n3d9435FdE5gnNBDgHUKI44OUbJDlOhBen3hTY0xa4chzQB4OYDwvzIjMxe5Eq76wuhcl+cM+Lq6orfLKikhXGP+LDiqd0kS88oDx2UPUV3uKvxqwHVmw37C1BW/fAZGibFufT75E+Q/0nZ2A1RwW7Bxjz3iwo4zuctCtfyxfeVDGq2oFxap24aTrSpptwqyPGgBm0560ir9KIr9MIBoXoM0xjHln630wMy8AuNXumhfCdFMy5YDrszX1APxYChkEP9L5UibbSQ+C0jPHOvYBmYW4oxyUrvobmR6IuWdGfVmyI6gRodUa7p1mMba6DqDCQFRZAxeoR+7TILk5AeiAlLCK+hHNHOUbyCriR9JL7CNkmhFzUJ3cRvUJLUSlGgLZaOb+sU1SKyui9gM/UrLqaSDtQSuMvgAk8PbGN8K+YB0eGPOpkY+SDavXFKPbsdr1kgDXDduRdADNuIZe9o4YHR23k8iZdEERTjtM25l1FP47fuF7xF7Kyf0k+e0aIlUFGaEkbNtJwHt0oyfGit4NKTyGxQTgsV9vmWuick88UCLp1J8/McM6gttY2aAO1yU3vWdrlXQqMr8umrM4ebkfZjU1kotxIBEuLImIadgfWTchzLsk8arGcmj8j3CzLaQJDxXqbS9CUk0+FqeIhenmWzp25EJPOeeHNaGLESVtT2f25lLWPngdEHMDqHyuDMy1t5cVfyU2bBMQ2FCKPEzJVrGXAlSXqnnlGutKSb0vhRZD3WVTVTTVvTZ7doCSrSSSjGMt4gDiwtSgJMt6F7eLfkNLcduB8hL9GltNTkkkt9zphdxPGkdjcUv+F2J+6+04KkH4MSpkOlC5TXZ91eHeglMzTTHRIksLEOE1VdLSpw0q/S2LdjR4Qstphu/vndVZrUz3z7EnQShyfqgodt6G3S+fdYUL+lCKeC++456DgU2K24gygf+oGFr2tSX4dDIBuVSicUoNBV6lPEZ3GrQmGiOWhUzaKPcTYHNpiuan4IF/MjJM9yBFXEoEzKj5miRgli5WN8YGQZnybepNz9ttNoThjXtKoCjLT4Cm/f0tSh//dRA60O4I4EhpyZGgvZBB80Z31c0lTNP7mYcsPwLrg1KGUkief/YLDQF2wLlqPuVERn6qdyAiUOelighNLiMKEmRm9y97cc4os/vaCPwHeCsz9OGK/UIoK97XA3ReKVaE02qZYn+zeZKn6OiU1cONusakWEIHYRhU7rqzWzifm5UPHvDk6aHkjtZKNCN24euP5xPYXQhT1MvP1BJ1g6bjVw9rF8EjdpfoxYkdJs6niE0K//klvCjPfa+Q/ZYJZFGC41h0obwJaMVRoY1y8vhu5Wh2k8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd23a3e4-912d-4224-2ae2-08da452e188b X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2022 06:55:51.0650 (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: eeExv4M7MMoVkwa8ewfHBeHCldG1D+B24K2HXW7/ku86Swt+zyK+JmxLVEC3dzg2YkboasjaNOeRPRTQ5wjyDtZvAgkF7uceQv/lcRfSoLE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2789 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517, 18.0.874 definitions=2022-06-03_02:2022-06-02, 2022-06-03 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206030029 X-Proofpoint-GUID: 9g460uK30znmom4prnA6w7b226RLM_WW X-Proofpoint-ORIG-GUID: 9g460uK30znmom4prnA6w7b226RLM_WW 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.6 X-Mailman-Approved-At: Mon, 06 Jun 2022 06:46:16 +0000 Subject: [dm-devel] [PATCH 06/11] dm: Add support for block PR read keys/reservation. 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 This adds support in dm for the block PR read keys and read reservation callouts. Signed-off-by: Mike Christie --- drivers/md/dm.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 82957bd460e8..ca544dfc3210 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -3114,12 +3114,56 @@ static int dm_pr_clear(struct block_device *bdev, u64 key) return r; } +static int dm_pr_read_keys(struct block_device *bdev, struct pr_keys *keys, + int keys_data_len) +{ + struct mapped_device *md = bdev->bd_disk->private_data; + const struct pr_ops *ops; + int r, srcu_idx; + + r = dm_prepare_ioctl(md, &srcu_idx, &bdev); + if (r < 0) + goto out; + + ops = bdev->bd_disk->fops->pr_ops; + if (ops && ops->pr_read_keys) + r = ops->pr_read_keys(bdev, keys, keys_data_len); + else + r = -EOPNOTSUPP; +out: + dm_unprepare_ioctl(md, srcu_idx); + return r; +} + +static int dm_pr_read_reservation(struct block_device *bdev, + struct pr_held_reservation *rsv) +{ + struct mapped_device *md = bdev->bd_disk->private_data; + const struct pr_ops *ops; + int r, srcu_idx; + + r = dm_prepare_ioctl(md, &srcu_idx, &bdev); + if (r < 0) + goto out; + + ops = bdev->bd_disk->fops->pr_ops; + if (ops && ops->pr_read_reservation) + r = ops->pr_read_reservation(bdev, rsv); + else + r = -EOPNOTSUPP; +out: + dm_unprepare_ioctl(md, srcu_idx); + return r; +} + static const struct pr_ops dm_pr_ops = { .pr_register = dm_pr_register, .pr_reserve = dm_pr_reserve, .pr_release = dm_pr_release, .pr_preempt = dm_pr_preempt, .pr_clear = dm_pr_clear, + .pr_read_keys = dm_pr_read_keys, + .pr_read_reservation = dm_pr_read_reservation, }; static const struct block_device_operations dm_blk_dops = { From patchwork Fri Jun 3 06:55:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12868721 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 3405CCCA47F for ; Fri, 3 Jun 2022 07:18:07 +0000 (UTC) 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-655-Bd4KxK03MeSNj6Byd-Xbxg-1; Fri, 03 Jun 2022 03:18:02 -0400 X-MC-Unique: Bd4KxK03MeSNj6Byd-Xbxg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5105638349D6; Fri, 3 Jun 2022 07:18:00 +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 2117B82894; Fri, 3 Jun 2022 07:17: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 CE3B41947041; Fri, 3 Jun 2022 07:17:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 379461947040 for ; Fri, 3 Jun 2022 06:57:04 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 12D032166B2C; Fri, 3 Jun 2022 06:57:04 +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 0D7742166B26 for ; Fri, 3 Jun 2022 06:57:04 +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 E1BF0802812 for ; Fri, 3 Jun 2022 06:57:03 +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-340-F0kfkm5MNmepH97mq_-6dw-1; Fri, 03 Jun 2022 02:57:01 -0400 X-MC-Unique: F0kfkm5MNmepH97mq_-6dw-1 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2536WAcW031063; Fri, 3 Jun 2022 06:55:55 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gbc4xv7t2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Jun 2022 06:55:55 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 2536oJOJ001834; Fri, 3 Jun 2022 06:55:54 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2048.outbound.protection.outlook.com [104.47.73.48]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3gc8hyxp2g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Jun 2022 06:55:54 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by BYAPR10MB2789.namprd10.prod.outlook.com (2603:10b6:a03:82::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.19; Fri, 3 Jun 2022 06:55:52 +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.5293.019; Fri, 3 Jun 2022 06:55:52 +0000 From: Mike Christie To: linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, hch@lst.de, axboe@kernel.dk, martin.petersen@oracle.com, james.bottomley@hansenpartnership.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Date: Fri, 3 Jun 2022 01:55:32 -0500 Message-Id: <20220603065536.5641-8-michael.christie@oracle.com> In-Reply-To: <20220603065536.5641-1-michael.christie@oracle.com> References: <20220603065536.5641-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR16CA0012.namprd16.prod.outlook.com (2603:10b6:3:c0::22) 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: 5790e06b-0eb1-433e-34f8-08da452e191a X-MS-TrafficTypeDiagnostic: BYAPR10MB2789:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: /QnULvd01LXt4ttlO4Z+oDmHbHFdcYRYM4/lJpt5wnDTXEtFrsxufIBAQQcoOh2FFkiye3WRumnnvq3D2KbDkj18slzVfSMDfqv/mUYqlGtnjTwsNQowMteld1wmSWJWvMuL+rXrVJzSrwb9g3zd2HHQDZnKiSsSmrwimQ5exJPyywLtJ/S9IcYXPIfMhdoLT1n96V4Azl1DzQCk4Jb7s/mGjZGt+4W450zS2viVGp8gk2c3lZE9kUIwNwvPwt5dhtgCCU9d7zG02GnqzvmUvaSdLfjdV64TkLsnClZt+iDfs8jp888AJOa9AOqL9FvC1742ZbXpZrP4QWm/f6Sfi0m9hNeLZdS4eqRjTM+mnRIN1sc3z5GV2ILgtbglM/xVRagBQGX4UTtXfe2+jI4AaegdCu26QklUh3Ms5Xc6/DY5xbNnPsLIIZ5X+cO4fTayTkg4OTb/W/vxAHmSHFzZifD2TtjtON64vb/8PB/Wbe2Qw5CqBQN8MfyQYRoxMh4Oeh1+4sU53IetW3SM7tWk+enQV0WyHwpVH2tQrmXfwW9KoXIasurUH7Bmo9OkZ90vSD3a8+u2CBEQyArrRxR/huD57qzhnXEn0SGJ9YK6ULHyVLysiCpF361emN0XLZsyWGGY0eQeGf3p5wVjJ3hwTtQ5r6mgAvzz+BOBrsKqRf8BKxMbX67dr/7sgs/FL5HKjKnvxlQU6hUNZPGd31HoMA== 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:(13230001)(366004)(66946007)(8676002)(38350700002)(38100700002)(66476007)(4326008)(66556008)(86362001)(83380400001)(36756003)(8936002)(107886003)(6486002)(2616005)(316002)(5660300002)(1076003)(6512007)(26005)(2906002)(6506007)(52116002)(186003)(6666004)(508600001); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: e4mIjZTeJCJ2fvBBlArfqVXaCtmDZ6NXVPuigh2mNORcPAX7/gxR40H1RkdAEPwixfZ1st13+f01RiK+Xcrwf74/erVz/QYJ237vuEvCfR5wN2dK0M/EcAIc0eLIAF6Q9lszdCD3U0psDf/XLdScKTIGKGoc0kTjw5GjRIP8EVcTKkt4rhdvf3H8PHpRjhCssXVGivLnha4ObgUqXDj9y5i3hq/6VleT8dS9oTl2+ppxJ1ELi4nr7c5ZJn2ImXXI8K7BrIfUSJ7V/0EtDmGUrX+99Ipz07WcOwMqPTuP3GwV/gd1q3LsuubypFezzAJuUca4X2kPdm0tCQjpr4Si8H1jXtrrvHAsLNhFcznJU8Pvcu3X81iKjGhvkwwdXZiAGxmn3tU0DeKd99Q9a4kml72dqTK7YkD3ILgur544hQo/0zZiJpsnlXZtuB5M3LH80XhjbTPFhOvLg4Hp85tHbyZwBr5eb6x8rbzkLntWe/f8S9kIuhlzik1Jt38KFmUUrpo6nlzeheGkMZv2sGM5dogSCSUAAy3Up1bmxYBd/8pS92jZTURFdfGjiKRh9YmZIOgK1Bl1O05mkWAuiUDj8fEshlv/cf2wf/HEpRqTYQQmQcfAwL6yrZHpNVokohbo+OgHaPdg4TME42Ez7h9skpW7XGFkCxm6eZENKQVWou6dTxrfd2hD7FxlITBx+HzZ5NAn95Q1CXGlUJcPrubqFl4EHZON/YJX8Bi9ybRiGtolOjc//bsaEC/wCFeEtJSWASQZhG4nfgMy+N810TAqUSCRftK1MbJXrYdg7woeeTBnXrZu50zevVwJ2xdL4ccXVjSsdFNh+as18AhqSc5lVzfYlFUWekYjWYPDd8NctEUpNgJ6xaN5UzWBpD9T6K+/ujqRIYFv/tJ+t/1ujvqdsSqHlLgHxWqEGEKZ9b5xV4oRHx9RRwOdA997OHrvH+d6e/CV7h314gHIeXr/BD/jYRdz+MQRI6gpsazQPSUwP+luW/SvcV5rXI8Shke1eGKGuksRpgK08lBobeOmpX/f6REqO/kuLeGhYh5PW3hBoCWH40H+/6AkykUO3pEoIzeGMcPfFb9erEIdZWvdIXEJL4scUTkCKpv5V5835zbw+48wTem/k4kJxaBFOD2M1glGnw7OOGHc7xpHbE1Q1YDYlCmfp6L+P3lnv/TGafhV1rTO8DwIAEiG5le9Pn/gPPYXM9plZ8vnJJFrfz56PRDRvzHLjhBc8H7nNMr02enFhVCBjV+m1qGndIOPolRj2LCLrpoNGKyJIxUvhSykVGhmds5qq4YfQvghm0h64CKM5KTTVHdov8w41DUJxGTE/m4LMJXrbW2VlrDLOwSV2P0LUoyQpd0eo8aqCjLssOLvCaF+kEg+cbF1SkcBNHvozzOqZTTovqwjQzhCNUlzRvpztqCLKgIlXp43eri2srNuHna1JpHWherQcvmzrBPXx36yNlJmhLFJ0yywUNxA3nPhwp1GY7hDqApPQtR6NDb8XMEj5GM5I/xZyTi/gR1Hmz1affaenxzTtdlU+CXc4QtsfVM9idDxCVrhTu3RfBFSsZWYiBX5To1l8VsKSBc4PZulMF6K1ZHUtXgfr6Sb1DmOH5OG6ju/GtOwr9SiUPgNn4Q0XO95DsjLXn18oYjW997u9AgOYGuwBVXXhzJuMLksXMvf1cX1tCmX+LRboiskN1Zb3iVWS59HSlrrpkoqu/BPY6qHzNVxCWQEWXfM33hiAtnGP5IRJVPmFZkcPKeQxsg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5790e06b-0eb1-433e-34f8-08da452e191a X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2022 06:55:51.9712 (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: TzCDcBPit35isa/iw5DsycI1cHBUZ6XDWc9JiMLQ84MvorMFsigIhypvvItyHtrwS2G1b1Sksoc9DAIC7w55Bttq24Nwjcvzjk139WmmqZw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2789 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517, 18.0.874 definitions=2022-06-03_02:2022-06-02, 2022-06-03 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206030029 X-Proofpoint-GUID: 3Xn1q6a3uQs727qhJyalTg13ldZpLP0y X-Proofpoint-ORIG-GUID: 3Xn1q6a3uQs727qhJyalTg13ldZpLP0y 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.6 X-Mailman-Approved-At: Fri, 03 Jun 2022 07:17:56 +0000 Subject: [dm-devel] [PATCH 07/11] scsi: target: Allow backends to hook into PR handling. 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.79 on 10.11.54.5 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 For the cases where you want to export a device to a VM via a single I_T nexus and want to passthrough the PR handling to the physical/real device you have to use pscsi or tcmu. Both are good for specific uses however for the case where you want good performance, and are not using SCSI devices directly (using DM/MD RAID or multipath devices) then we are out of luck. The following patches allow iblock to mimimally hook into the LIO PR code and then pass the PR handling to the physical device. Note that like with the tcmu an pscsi cases it's only supported when you export the device via one I_T nexus. This patch adds the initial LIO callouts. The next patch will modify iblock. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig --- drivers/target/target_core_pr.c | 60 ++++++++++++++++++++++++++++ include/target/target_core_backend.h | 5 +++ 2 files changed, 65 insertions(+) diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c index 3829b61b56c1..1c11f884e12f 100644 --- a/drivers/target/target_core_pr.c +++ b/drivers/target/target_core_pr.c @@ -3531,6 +3531,26 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key, return ret; } +static sense_reason_t +target_try_pr_out_pt(struct se_cmd *cmd, u8 sa, u64 res_key, u64 sa_res_key, + u8 type, bool aptpl, bool all_tg_pt, bool spec_i_pt) +{ + struct exec_cmd_ops *ops = cmd->protocol_data; + + if (!cmd->se_sess || !cmd->se_lun) { + pr_err("SPC-3 PR: se_sess || struct se_lun is NULL!\n"); + return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; + } + + if (!ops->execute_pr_out) { + pr_err("SPC-3 PR: Device has been configured for PR passthrough but it's not supported by the backend.\n"); + return TCM_UNSUPPORTED_SCSI_OPCODE; + } + + return ops->execute_pr_out(cmd, sa, res_key, sa_res_key, type, + aptpl, all_tg_pt, spec_i_pt); +} + /* * See spc4r17 section 6.14 Table 170 */ @@ -3634,6 +3654,12 @@ target_scsi3_emulate_pr_out(struct se_cmd *cmd) return TCM_PARAMETER_LIST_LENGTH_ERROR; } + if (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR) { + ret = target_try_pr_out_pt(cmd, sa, res_key, sa_res_key, type, + aptpl, all_tg_pt, spec_i_pt); + goto done; + } + /* * (core_scsi3_emulate_pro_* function parameters * are defined by spc4r17 Table 174: @@ -3675,6 +3701,7 @@ target_scsi3_emulate_pr_out(struct se_cmd *cmd) return TCM_INVALID_CDB_FIELD; } +done: if (!ret) target_complete_cmd(cmd, SAM_STAT_GOOD); return ret; @@ -4032,6 +4059,33 @@ core_scsi3_pri_read_full_status(struct se_cmd *cmd) return 0; } +static sense_reason_t target_try_pr_in_pt(struct se_cmd *cmd) +{ + struct exec_cmd_ops *ops = cmd->protocol_data; + unsigned char *buf; + sense_reason_t ret; + + if (cmd->data_length < 8) { + pr_err("PRIN SA SCSI Data Length: %u too small\n", + cmd->data_length); + return TCM_INVALID_CDB_FIELD; + } + + if (!ops->execute_pr_in) { + pr_err("SPC-3 PR: Device has been configured for PR passthrough but it's not supported by the backend.\n"); + return TCM_UNSUPPORTED_SCSI_OPCODE; + } + + buf = transport_kmap_data_sg(cmd); + if (!buf) + return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; + + ret = ops->execute_pr_in(cmd, cmd->t_task_cdb[1] & 0x1f, buf); + + transport_kunmap_data_sg(cmd); + return ret; +} + sense_reason_t target_scsi3_emulate_pr_in(struct se_cmd *cmd) { @@ -4053,6 +4107,11 @@ target_scsi3_emulate_pr_in(struct se_cmd *cmd) return TCM_RESERVATION_CONFLICT; } + if (cmd->se_dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR) { + ret = target_try_pr_in_pt(cmd); + goto done; + } + switch (cmd->t_task_cdb[1] & 0x1f) { case PRI_READ_KEYS: ret = core_scsi3_pri_read_keys(cmd); @@ -4072,6 +4131,7 @@ target_scsi3_emulate_pr_in(struct se_cmd *cmd) return TCM_INVALID_CDB_FIELD; } +done: if (!ret) target_complete_cmd(cmd, SAM_STAT_GOOD); return ret; diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index 4e6cf1bf3b87..0b7f540be84f 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -68,6 +68,11 @@ struct exec_cmd_ops { sense_reason_t (*execute_write_same)(struct se_cmd *cmd); sense_reason_t (*execute_unmap)(struct se_cmd *cmd, sector_t lba, sector_t nolb); + sense_reason_t (*execute_pr_out)(struct se_cmd *cmd, u8 sa, u64 key, + u64 sa_key, u8 type, bool aptpl, + bool all_tg_pt, bool spec_i_pt); + sense_reason_t (*execute_pr_in)(struct se_cmd *cmd, u8 sa, + unsigned char *param_data); }; int transport_backend_register(const struct target_backend_ops *); From patchwork Fri Jun 3 06:55:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12870036 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 24A76CCA473 for ; Mon, 6 Jun 2022 06:46:25 +0000 (UTC) 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-669-QiYQl3RYNeK05Fj5h_5_RQ-1; Mon, 06 Jun 2022 02:46:22 -0400 X-MC-Unique: QiYQl3RYNeK05Fj5h_5_RQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2298029ABA2B; Mon, 6 Jun 2022 06:46:20 +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 BF1FA2166B26; Mon, 6 Jun 2022 06:46:18 +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 A557B19451EF; Mon, 6 Jun 2022 06:46:17 +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 A7ACB1947040 for ; Fri, 3 Jun 2022 08:29:06 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 86F71C27E92; Fri, 3 Jun 2022 08:29:06 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 81E4DC23DC9 for ; Fri, 3 Jun 2022 08:29:06 +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 66B83811E76 for ; Fri, 3 Jun 2022 08:29:06 +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-386-fgBcR-4WMuiOL5jgpcT7hQ-1; Fri, 03 Jun 2022 04:29:04 -0400 X-MC-Unique: fgBcR-4WMuiOL5jgpcT7hQ-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 2535egi5004301; Fri, 3 Jun 2022 06:55:56 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gf08e198r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Jun 2022 06:55:55 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 2536oJOK001834; Fri, 3 Jun 2022 06:55:55 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2048.outbound.protection.outlook.com [104.47.73.48]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3gc8hyxp2g-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Jun 2022 06:55:55 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by BYAPR10MB2789.namprd10.prod.outlook.com (2603:10b6:a03:82::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.19; Fri, 3 Jun 2022 06:55:53 +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.5293.019; Fri, 3 Jun 2022 06:55:52 +0000 From: Mike Christie To: linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, hch@lst.de, axboe@kernel.dk, martin.petersen@oracle.com, james.bottomley@hansenpartnership.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Date: Fri, 3 Jun 2022 01:55:33 -0500 Message-Id: <20220603065536.5641-9-michael.christie@oracle.com> In-Reply-To: <20220603065536.5641-1-michael.christie@oracle.com> References: <20220603065536.5641-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR16CA0012.namprd16.prod.outlook.com (2603:10b6:3:c0::22) 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: 562c0e60-29d6-4949-b5d8-08da452e199f X-MS-TrafficTypeDiagnostic: BYAPR10MB2789:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: wL3ybMrxn6e4NN776nsKhMa9Ll+GJWlMO49BjoJfkXqOZDuUjujg6rmXosjqWlIKuXt3fdOKYjZ9xigquW4Avm2OLB7yWGXyMsI8Iz0Mzxi8UR9wdZjzXSkx7bVGajPLNFOxp9W9rJoZFjy7Ahsi9CEkM02KvUV45S0Wl5MuNrbgC2ChMt0W0pdw+tVK3BPhkLMbONi8DtlJ2VHVrLCXHIDgNaYctkD7DFsc54tzmfAusK04x0IyrTMFnnr7iVgY6VDzkGkRNGUs7PduzWx/qC70BVPz0/JaHST1AMXOdPARSxFH17yPxkhifwdQvRlFOI1gsv7LfgSdYUXgRswVg9BnovJigecyBHk0tvEPYBaWT0r99Z6rIwXoR1Bt+isRVtzbPuCwtsG5tVlPSjTolVzVIDjMAkm00uAtP7FohnKI1PfpxnwWmMQGVHa7b5wJhGkeV/hbqmTegkOQJohlXLDudui8sdMUn3T+DJdlzf5gaiEa0bX2uYJxFMZSwS76LvFwYozEJeZEx628PKv+aEJ0UE7RBaCXPQfSycYPelbSQnI2PuRjArzlxZHBjRe7DjbCyr6ztLd3zh2B5Ju7pYDt5yINIXYt1xna7I3U5Nw1FvXVDa5nT8qCrNTYdfneVmQYv2Jq9v4NxBYiopBVlCabAaiLcRsZRLcP/wfa4XQZtwq2URWkHeSQkrHOEIvrr9x6CRhdvs92PJ0CEH3bzQ== 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:(13230001)(366004)(66946007)(8676002)(38350700002)(38100700002)(66476007)(4326008)(66556008)(86362001)(83380400001)(36756003)(8936002)(107886003)(6486002)(2616005)(316002)(5660300002)(1076003)(6512007)(26005)(2906002)(6506007)(52116002)(186003)(30864003)(6666004)(508600001); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PhEbCTZIBl/sNqsOEH7fG1RIsrKnP0/n80gQxhNcatalRrU69ikAE9Zc01fzquiALZ/9kQs5wGclxcVgfRIFQytmSbuyeqwnfN/x25PVJpr9g1f60Gr/WYYHSfHjlQ8bfqkQiA7RUiF822IEEsDVTkMgEpQ/oN1ixBbt78i2R/qJWJT+SyQdfMXRd6z9PYSuzXSiv0j7L5iuZNtEGoAG82oOynVHd3xDaJLQYeVYNlaVNYdUwZCNAH3NV5wlYleO9sveD9VfsHYwsLSBDbdCJTcOc7u7BrsEGv4ZoiuevOmbQ6cykXqYz2n74Z+Ppqm0ZeNAQLno6U7alblPeyjO+MxpxnYl3g3RboxTRYgfZ2nRy8PPjk8142uzSvrohWyloOUrm0ea7ZSN4w2w+zXDn/D38LJL4+DfcZ6gv3ucYf7XYNK+8LIg+1sVoUhOZkIi0gwkpdIpBg/EPk1IORXqGZ+X9pcVUmu8BXLaW9eSiOo2ov6WDWzrRZGd8fPUklRSuQmYCVsNTBdg0+0+vQLbMbT4HulGWuPlXa9oiWr4Jn3wlvdJWnVYa/faIZQBtGsoDnk6LoeRzEZI5nvPclUKyjxaqhBM5/oNj9C0sXSeXXUmyVpXCyPa1dF7Axd6DmyQOL9yuFaZBNlt1HFPjZRFW+gdoWlZX6bpyXEw2FzcH0PY4VKDjk7okXWTwsi/fQ06JIcPbONLJjLris4cGK/+kJLcygJfy7JewsKdFErgJJg2RUXmz5bEuVIPv/jCk3zLFMb84DKjkdp8PLTIbG3bcBrZKiWNpQQs/E3XqxFgHrH1K3ZNAm4lK1nm66KTzZ6VNu+zthnZ1st0fkn9psQjQTK1yrcg7uzpdumMuytN07T/dsc2i6r3rJLCmSHqRjh3rb0iWklKbbklTuWP2euIObm/MmjBxJB+wQSC2CBTq1irgI7nUgwFWK+4BoM62mn9H/EH6zke71JLo97olAtOzcLFPfqleHXRhz154xWcSQydK674sqhQr+H7kkeiuS77hSAr8BYUszq39jBMIJl9XcekoDtfs1G6U5DQ20YTnNqzNaCTj9yZg9EvRExL78szz45cq5R2SfH4SacJ/7fLC1IHifgrav/jzZuHtGL1s84l2WMebfKJMPdjRsNmVQ96yrXeNh1owIq/kcbJEYOSp7wZgWnSOB798g25mbAl/ofZV4aj0f78PWajX++hp3kyXC6rZU7E4jWJMXwGUtEp6ASe+tsuWJWsBQtLO1Wj8KPL4ENQgtz5JLYeAcbNG74n49puNE9PYFN+EagtbY1zN+DxNn9YGULsb2eUSbEC71H2OGYots417EIdhSHIw6BLQpI3O6Wr9kg8CqH4fZwPQ+O5+t3Eu9hOvjmSF71SnG3dO1YnCZqBIcbXVijkPfFv2N1jTt2q5xrGJJUm5HnWXXGdZ2yv+rJpYq5UfFcVGoj6JNMJUKDCtSdgdcvTJqC6bVruX90/p+Lic/mlahas6Yldto+PnWAjXjZScboyWq1zrTrJYp0qPMRQmP9Ma9/6XqSHq30FY4F8p9MtC+o62Le/BupgyF15QLyRUvBra1kqnnDWpGVCXF9mWkPU/Xvns2n39+PQcuAix6nkE3Cb57rVXevhL+rItefnZA5BGFQuWUdecimpdBrsO5DO1Yjt1u6MJZAMiW4q9dxRXkyywGa3Ll4kH9jUmlpAzhU8SMLEOzZbMPtFd+A6aiC/jMF5kdvktQJdUac3oCSv6z3U3ZtU1vKmHFNutgq0sGMqask= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 562c0e60-29d6-4949-b5d8-08da452e199f X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2022 06:55:52.9243 (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: pTr4fCgLboqe5H3hj5NuJfVrIfjziOOEL8QdvIUFN7YN0U0EvQMD7lRI2phUm4A3+2C8IGPRGO7KLVcdJuoZ02tDv9HbFEXB8XkSewmAGpg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2789 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517, 18.0.874 definitions=2022-06-03_02:2022-06-02, 2022-06-03 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206030029 X-Proofpoint-GUID: AFyugBDX9QtpPaGUSZV9DeJ0-Le7wSSU X-Proofpoint-ORIG-GUID: AFyugBDX9QtpPaGUSZV9DeJ0-Le7wSSU 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: Mon, 06 Jun 2022 06:46:17 +0000 Subject: [dm-devel] [PATCH 08/11] scsi: target: Add block PR support to iblock. 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.6 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 adds support for the block PR callouts to target_core_iblock. This patch doesn't attempt to implement the entire spec because there's no way to test it all. It only supports what's required for windows clustering right now. Signed-off-by: Mike Christie --- drivers/target/target_core_iblock.c | 312 ++++++++++++++++++++++++++++ 1 file changed, 312 insertions(+) diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index 9b0d788f6744..e8cf201e59ca 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c @@ -23,13 +23,16 @@ #include #include #include +#include #include +#include #include #include #include #include "target_core_iblock.h" +#include "target_core_pr.h" #define IBLOCK_MAX_BIO_PER_TASK 32 /* max # of bios to submit at a time */ #define IBLOCK_BIO_POOL_SIZE 128 @@ -822,6 +825,295 @@ iblock_execute_rw(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents, return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; } +static sense_reason_t iblock_execute_pr_out(struct se_cmd *cmd, u8 sa, u64 key, + u64 sa_key, u8 type, bool aptpl, + bool all_tg_pt, bool spec_i_pt) +{ + struct se_device *dev = cmd->se_dev; + struct iblock_dev *ib_dev = IBLOCK_DEV(dev); + struct block_device *bdev = ib_dev->ibd_bd; + const struct pr_ops *ops = bdev->bd_disk->fops->pr_ops; + int ret; + + if (!ops) { + pr_err("Block device does not support pr_ops but iblock device has been configured for PR passthrough.\n"); + return TCM_UNSUPPORTED_SCSI_OPCODE; + } + + switch (sa) { + case PRO_REGISTER_AND_MOVE: + pr_err("PRO_REGISTER_AND_MOVE is not supported by iblock PR passthrough.\n"); + return TCM_UNSUPPORTED_SCSI_OPCODE; + case PRO_REPLACE_LOST_RESERVATION: + pr_err("PRO_REPLACE_LOST_RESERVATION is not supported by iblock PR passthrough.\n"); + return TCM_UNSUPPORTED_SCSI_OPCODE; + case PRO_REGISTER: + case PRO_REGISTER_AND_IGNORE_EXISTING_KEY: + if (!ops->pr_register) { + pr_err("block device does not support pr_register.\n"); + return TCM_UNSUPPORTED_SCSI_OPCODE; + } + + /* + * We only support one target port. We don't know the target + * port config at this level and the block layer has a + * different view. + */ + if (spec_i_pt || all_tg_pt) { + pr_err("SPC-3 PR: SPEC_I_PT and ALL_TG_PT are not supported by PR passthrough.\n"); + + return TCM_UNSUPPORTED_SCSI_OPCODE; + } + + /* The block layer pr ops always enables aptpl */ + if (!aptpl) + pr_info("APTPL not set by initiator, but will be used.\n"); + + ret = ops->pr_register(bdev, key, sa_key, + sa == PRO_REGISTER ? 0 : PR_FL_IGNORE_KEY); + break; + case PRO_RESERVE: + if (!ops->pr_reserve) { + pr_err("block_device does not support pr_reserve.\n"); + return TCM_UNSUPPORTED_SCSI_OPCODE; + } + + switch (type) { + case PR_TYPE_WRITE_EXCLUSIVE_REGONLY: + case PR_TYPE_EXCLUSIVE_ACCESS_REGONLY: + break; + default: + return TCM_UNSUPPORTED_SCSI_OPCODE; + } + + ret = ops->pr_reserve(bdev, key, scsi_pr_type_to_block(type), 0); + break; + case PRO_CLEAR: + if (!ops->pr_clear) { + pr_err("block_device does not support pr_clear.\n"); + return TCM_UNSUPPORTED_SCSI_OPCODE; + } + + ret = ops->pr_clear(bdev, key); + break; + case PRO_PREEMPT: + case PRO_PREEMPT_AND_ABORT: + if (!ops->pr_clear) { + pr_err("block_device does not support pr_preempt.\n"); + return TCM_UNSUPPORTED_SCSI_OPCODE; + } + + switch (type) { + case PR_TYPE_WRITE_EXCLUSIVE_REGONLY: + case PR_TYPE_EXCLUSIVE_ACCESS_REGONLY: + break; + default: + return TCM_UNSUPPORTED_SCSI_OPCODE; + } + + ret = ops->pr_preempt(bdev, key, sa_key, + scsi_pr_type_to_block(type), + sa == PRO_PREEMPT ? false : true); + break; + default: + pr_err("Unknown PERSISTENT_RESERVE_OUT SA: 0x%02x\n", sa); + return TCM_UNSUPPORTED_SCSI_OPCODE; + } + + if (ret) + return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; + + return TCM_NO_SENSE; +} + +static void iblock_pr_report_caps(unsigned char *param_data) +{ + u16 len = 8; + + put_unaligned_be16(len, ¶m_data[0]); + /* + * When using the pr_ops passthrough method we only support exporting + * the device through one target port because from the backend module + * level we can't see the target port config. As a result we only + * support registration directly from the I_T nexus the cmd is sent + * through and do not set ATP_C here. + * + * The block layer pr_ops do not support passing in initiators so + * we don't set SIP_C here. + */ + /* PTPL_C: Persistence across Target Power Loss bit */ + param_data[2] |= 0x01; + /* + * We are filling in the PERSISTENT RESERVATION TYPE MASK below, so + * set the TMV: Task Mask Valid bit. + */ + param_data[3] |= 0x80; + /* + * Change ALLOW COMMANDs to 0x20 or 0x40 later from Table 166 + */ + param_data[3] |= 0x10; /* ALLOW COMMANDs field 001b */ + /* + * PTPL_A: Persistence across Target Power Loss Active bit. The block + * layer pr ops always enables this so report it active. + */ + param_data[3] |= 0x01; + /* + * Setup the PERSISTENT RESERVATION TYPE MASK from Table 212 spc4r37. + * + * We are only supporting the following to simplify conversions we + * may need to do between what the initiator sends us and what is + * below us if there is a multipath device. + */ + param_data[4] |= 0x40; /* PR_TYPE_EXCLUSIVE_ACCESS_REGONLY */ + param_data[4] |= 0x20; /* PR_TYPE_WRITE_EXCLUSIVE_REGONLY */ +} + +static int iblock_pr_read_keys(struct se_cmd *cmd, unsigned char *param_data) +{ + struct se_device *dev = cmd->se_dev; + struct iblock_dev *ib_dev = IBLOCK_DEV(dev); + struct block_device *bdev = ib_dev->ibd_bd; + const struct pr_ops *ops = bdev->bd_disk->fops->pr_ops; + int i, ret, len, paths, data_offset; + struct pr_keys *keys; + + if (!ops) { + pr_err("Block device does not support pr_ops but iblock device has been configured for PR passthrough.\n"); + return TCM_UNSUPPORTED_SCSI_OPCODE; + } + + if (!ops->pr_read_keys) { + pr_err("Block device does not support read_keys.\n"); + return TCM_UNSUPPORTED_SCSI_OPCODE; + } + + /* + * We don't know what's under us, but dm-multipath will register every + * path with the same key, so start off with enough space for 16 paths. + */ + paths = 16; +retry: + len = sizeof(*keys) + (8 * paths); + + keys = kzalloc(len, GFP_KERNEL); + if (!keys) + return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; + + ret = ops->pr_read_keys(bdev, keys, len); + if (ret == -EOVERFLOW) { + kfree(keys); + paths *= 2; + goto retry; + } else if (ret) { + ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; + goto free_keys; + } + + ret = TCM_NO_SENSE; + + put_unaligned_be32(keys->generation, ¶m_data[0]); + if (!keys->num_keys) { + put_unaligned_be32(0, ¶m_data[4]); + goto free_keys; + } + + /* + * We only support a single I_T Nexus so there should only be one + * key. There might be a multipath device under us but the initiator + * does not know this. So, here we make sure the registered keys are + * the same and that we only return the one key to match what the + * initiator had sent us. + */ + put_unaligned_be32(8, ¶m_data[4]); + + data_offset = 8; + for (i = 0; i < keys->num_keys; i++) { + if (data_offset + 8 > cmd->data_length) + break; + + if (i == 0) { + put_unaligned_be64(keys->keys[i], + ¶m_data[data_offset]); + } else if (keys->keys[i] != keys->keys[i - 1]) { + pr_err("Detected mismatched keys 0x%016llx and 0x%016llx\n", + keys->keys[i], keys->keys[i - 1]); + ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; + goto free_keys; + } + + data_offset += 8; + } + +free_keys: + kfree(keys); + return ret; +} + +static int iblock_pr_read_reservation(struct se_cmd *cmd, + unsigned char *param_data) +{ + struct se_device *dev = cmd->se_dev; + struct iblock_dev *ib_dev = IBLOCK_DEV(dev); + struct block_device *bdev = ib_dev->ibd_bd; + const struct pr_ops *ops = bdev->bd_disk->fops->pr_ops; + struct pr_held_reservation rsv; + + if (!ops) { + pr_err("Block device does not support pr_ops but iblock device has been configured for PR passthrough.\n"); + return TCM_UNSUPPORTED_SCSI_OPCODE; + } + + if (!ops->pr_read_reservation) { + pr_err("Block device does not support read_keys.\n"); + return TCM_UNSUPPORTED_SCSI_OPCODE; + } + + if (ops->pr_read_reservation(bdev, &rsv)) + return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; + + put_unaligned_be32(rsv.generation, ¶m_data[0]); + if (!rsv.key) { + put_unaligned_be32(0, ¶m_data[4]); + return TCM_NO_SENSE; + } + + put_unaligned_be32(16, ¶m_data[4]); + + if (cmd->data_length < 16) + return TCM_NO_SENSE; + put_unaligned_be64(rsv.key, ¶m_data[8]); + + if (cmd->data_length < 22) + return TCM_NO_SENSE; + param_data[21] = block_pr_type_to_scsi(rsv.type); + + return TCM_NO_SENSE; +} + +static sense_reason_t iblock_execute_pr_in(struct se_cmd *cmd, u8 sa, + unsigned char *param_data) +{ + sense_reason_t ret; + + switch (sa) { + case PRI_REPORT_CAPABILITIES: + iblock_pr_report_caps(param_data); + break; + case PRI_READ_KEYS: + ret = iblock_pr_read_keys(cmd, param_data); + break; + case PRI_READ_RESERVATION: + ret = iblock_pr_read_reservation(cmd, param_data); + break; + case PRI_READ_FULL_STATUS: + default: + pr_err("Unknown PERSISTENT_RESERVE_IN SA: 0x%02x\n", sa); + return TCM_UNSUPPORTED_SCSI_OPCODE; + } + + return ret; +} + static sector_t iblock_get_blocks(struct se_device *dev) { struct iblock_dev *ib_dev = IBLOCK_DEV(dev); @@ -876,11 +1168,30 @@ static struct exec_cmd_ops iblock_exec_cmd_ops = { .execute_sync_cache = iblock_execute_sync_cache, .execute_write_same = iblock_execute_write_same, .execute_unmap = iblock_execute_unmap, + .execute_pr_out = iblock_execute_pr_out, + .execute_pr_in = iblock_execute_pr_in, }; static sense_reason_t iblock_parse_cdb(struct se_cmd *cmd) { + unsigned char *cdb = cmd->t_task_cdb; + struct se_device *dev = cmd->se_dev; + + switch (cdb[0]) { + case RESERVE: + case RESERVE_10: + case RELEASE: + case RELEASE_10: + /* + * The block layer pr_ops don't support the old RESERVE/RELEASE + * commands. + */ + if (dev->dev_attrib.emulate_pr && + (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR)) + return TCM_UNSUPPORTED_SCSI_OPCODE; + } + return sbc_parse_cdb(cmd, &iblock_exec_cmd_ops); } @@ -896,6 +1207,7 @@ static bool iblock_get_write_cache(struct se_device *dev) static const struct target_backend_ops iblock_ops = { .name = "iblock", .inquiry_prod = "IBLOCK", + .transport_flags_changeable = TRANSPORT_FLAG_PASSTHROUGH_PGR, .inquiry_rev = IBLOCK_VERSION, .owner = THIS_MODULE, .attach_hba = iblock_attach_hba, From patchwork Fri Jun 3 06:55:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12868720 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 E5FC1CCA473 for ; Fri, 3 Jun 2022 07:18:06 +0000 (UTC) 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-206-_o-u4fdcOLyoPdJBqnRBOg-1; Fri, 03 Jun 2022 03:18:02 -0400 X-MC-Unique: _o-u4fdcOLyoPdJBqnRBOg-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 243933C10155; Fri, 3 Jun 2022 07:18:01 +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 1097C1410DDB; Fri, 3 Jun 2022 07:18:01 +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 A17991947051; Fri, 3 Jun 2022 07:17:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 13D3A1947040 for ; Fri, 3 Jun 2022 06:58:10 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D7202403371; Fri, 3 Jun 2022 06:58:10 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D20FA492C3B for ; Fri, 3 Jun 2022 06:58:10 +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 B676529ABA18 for ; Fri, 3 Jun 2022 06:58:10 +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-167-E404Wy-PMieQaQkFBjOZNw-1; Fri, 03 Jun 2022 02:58:08 -0400 X-MC-Unique: E404Wy-PMieQaQkFBjOZNw-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 2535ehw4004306; Fri, 3 Jun 2022 06:56:02 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gf08e1990-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Jun 2022 06:56:02 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 2536oJc3001837; Fri, 3 Jun 2022 06:56:01 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2040.outbound.protection.outlook.com [104.47.73.40]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3gc8hyxp4e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Jun 2022 06:56:01 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by BYAPR10MB2789.namprd10.prod.outlook.com (2603:10b6:a03:82::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.19; Fri, 3 Jun 2022 06:55:59 +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.5293.019; Fri, 3 Jun 2022 06:55:53 +0000 From: Mike Christie To: linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, hch@lst.de, axboe@kernel.dk, martin.petersen@oracle.com, james.bottomley@hansenpartnership.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Date: Fri, 3 Jun 2022 01:55:34 -0500 Message-Id: <20220603065536.5641-10-michael.christie@oracle.com> In-Reply-To: <20220603065536.5641-1-michael.christie@oracle.com> References: <20220603065536.5641-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR16CA0012.namprd16.prod.outlook.com (2603:10b6:3:c0::22) 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: 8e8d97fd-1afa-4bb2-e6de-08da452e1a35 X-MS-TrafficTypeDiagnostic: BYAPR10MB2789:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: aqkmLGh9hWMHx2Z5REmDpEPFab6u+AQcFa46AeRivwJ+vu5al5rhQuyptNBx9wM/0wUk7K0hzimWDi1qFIMTd4gCBF7fDu6Sq4gajNDrj/LC9QILMmaapunZtiwjkvDiHNl0aN9ZwhIdRQ6MYKRuQOus0OTAyl/1y4JMb8tIW59hPtg6J/EnDSLInoCbJg5QTIte3oqL8WsOArvX1pWPE9dfrb/HOgddKQDRAQ9yU7zG1ueFbYx7J0+Ue6iLEoShFcrIwVoHx0TLUlbQ4QjI7P12NBmcqeSHIyHekb5TagtTDflW+0fyeyFQ7142TA8DlbmeIq0xpcKB3oSAPe56qZDpZ7Vsi8Y+OEqm9K3s7o6f5BwNN3EpS1o0P1a1TooLPgpsBVPAxbDwJukCfndnVGPMd9Z99E1Q/yp5NPGt4WKnqoI8fDo6d4alDbdZ5Od0bjAsbXJsC/mqrUNLabkQP9i7FuhUiyvi7cXQpeM0y0LfUS9/V0VpZ+KK7IdWR0LzBXqN04Z9jglBvJ0L+yA0DXeBJ2tRAC00ZeQ8DP3VmHCozxO4CNcctHGp+EIA0ZGDYi9Xk9PcBUbHJHvsakno06a8HMVBB3NhqbgljCEOqamjwMQxmWDWcjO4HW58Y+2EbJjVjgfNZkW+O1/foVMUGyi1eVnhDiBR7mjdoxaxLv8hu03LbHriDqDpLb02VTZ32WfmZP7Xy0d1AyavVOLvMA== 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:(13230001)(366004)(66946007)(8676002)(38350700002)(38100700002)(66476007)(4326008)(66556008)(86362001)(83380400001)(36756003)(8936002)(107886003)(6486002)(2616005)(316002)(5660300002)(1076003)(6512007)(26005)(2906002)(6506007)(52116002)(186003)(6666004)(508600001); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: r1NEaBwDYtDElM9m+5zo5xYYy6sOSDR0rI2L+9aFCHeQJQDeFWfBFK4NPiF5bA/kc4yibS1dy4KIteKrkwluV6g5uTWgwSn7BySK0on7AuIV/S9cYXNRJns+ChzKpzfQJdO13QD2eBRa+rEkjLMZMwzinS/ucTFSukPKNGVjKNlnPBRjG26n6Y/yv8MNW6jzr3Sz1Kj/1V/RNtt7H185RvSNrA6wRVhJ3MeUp+YBPJrcykaVQMhAJGFoVk5XW7nPdWvWQVIY0ltHoGcHOKVw9CoIJhGw/bro2Fe5L6d/egDnOjIDAfrpX01PxjhQtAdpCBL1ROOStzcc9paJCRbYltt/WoS5iFKA+b9beQLjMybwYo9V5vxy/d0OjX02/a4AV7wCyUJ9JdDJfFsL0l4REPcepyaafv0B8z0MeUwS29+RDSBc5ofmpXB4YgUIay1VevMJSGmp9nRySdJ+I8IaA4Is3HKkFkmrJVRYDICIbOst0VhjDUgyImtlefLlRHkFLZ0bfYTFnJIwbWayOlKZL9i8ytUKtrhiJCWzGWWf6T0eQATATslfy0zjCKfHqmguldqB43wdpoM5anDCA9IIAk43AhaSHMD2IkcELGDAzqMa62lkslhNXYF+nP3H/8B6znqTuw6veokeHsSSQ7r1p9HoMtxceLI3ktgMgyliqLOHrp2rut6sphLZa3lgKXoPYaU93HQ43FOIrr/2ZgYXV9qPzWpgKUmND1YcrMtn5exp5gqQPUVo9H2JCaZlXGRjk0/znf9hQL/nok5HVhKzA3EAI84mmsWqmUVXj6N3kq6a41g0MRtBnYx3/Vt2Idn1eFp4jyg5gvQtpXn0f42KPY0z8HE3pEAmI2v6t6hSfa3QW/IMu2mVksv0vuZ03p4xiB+JCTpbDabpuiAQA9mqfimy3oESMhtvd6+kMWAphgsBeFfI9VG5mtY9yY6/KH5M1gbpQ4xGe1aKfCmFSK9lAI+KntcaNO+j+XZ6fbPczffN9zEcV9ubsLhcesdCJaPSdRkhhS2GLYh5nZfkrSnPQjhzW4Jv9qJWGVaNyGiKprGrJXMjQ/xmEIooQnEg2cUG5/OAqlqOKrHnkUuTjrfjUBZ7Fpw4ynUqYSMa5jUUdbBe7d3MbQUMp5InANQQjH4/kEF/2Mpy/9PoqFMiu4YQnB/8wgolvHt1ICCTZ7lU6QVAjDWl1deWU7xpeQVhVUi1e+dGZ4OQP6zfzDsvFUg9WjotLCI1LnDGzvkXC4086cvRVvgoghrUZhts5dNoBDYEIWYyM+xMXCGKWZoUsyRkicd+Xrs4O2crqEB9pZaAhQqHvty6fVNZWztZdY5CK49PZl0xV7RgxA6ZCQUpgr+v3Y3VUXRL/toiG5agzst9jpyE4j+Oh2+9HOGXIiD+38NFKMQ5NoZgxjRdutWcwEtN8WH8XxN5/GJ85GM55Yq+L/uE8hYQJD5mveMKevXUj9c1W/Vvm7VawULBabbMunpfbfeyv+Sw2EoG+47fiIfWl9tyTiNKd6+naScA/JYF09LGWX+LjGomUALT5b4EOjKR7nknBVI/X1788SH+m6+DiLeyvZnnDnLOB4W0X/dul+fV1prbMsMsZh8PlUk8TAXL1kPicpHMyT17If6x+7Hliua59X5DU21SZt+5qsu6NnkXVg7SZzTBcdoD6jHGM7D+5YuvBBBZMt8hVgeua0pYKkXMFgGTedSnX+uZZxjWqtf1gc2pXF4NHlYc7arcKGMWK2PEejulX7IYA+iEI2dSkkA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e8d97fd-1afa-4bb2-e6de-08da452e1a35 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2022 06:55:53.8461 (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: SKB7cKR+b8LCcmthW93AyPOVyXceKJKAE0Zq2nPCc5JXSFh5flKstyk586SRrRx0VMUIwAA1PQIKBgrAWnxY44t7zT8qhh8ZbTFH6JBKXbE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2789 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517, 18.0.874 definitions=2022-06-03_02:2022-06-02, 2022-06-03 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206030029 X-Proofpoint-GUID: zePY__pdhFrPldtr_SkdHA9SM-9WUb88 X-Proofpoint-ORIG-GUID: zePY__pdhFrPldtr_SkdHA9SM-9WUb88 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.10 X-Mailman-Approved-At: Fri, 03 Jun 2022 07:17:56 +0000 Subject: [dm-devel] [PATCH 09/11] block, nvme: Add error for reservation conflicts. 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 BLK_STS_NEXUS is used for nvme/scsi reservation conflicts and also general nexus failures. For the pr_ops use we want to know if an IO failed for specifically a reservation conflict so we can report that error upwards to a VM. This patch adds a new error code for this case and converts nvme. The next patch converts scsi because it's a little more complicated. Signed-off-by: Mike Christie --- block/blk-core.c | 1 + drivers/nvme/host/core.c | 2 +- include/linux/blk_types.h | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/block/blk-core.c b/block/blk-core.c index bc0506772152..3908ac4a70b6 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -171,6 +171,7 @@ static const struct { /* zone device specific errors */ [BLK_STS_ZONE_OPEN_RESOURCE] = { -ETOOMANYREFS, "open zones exceeded" }, [BLK_STS_ZONE_ACTIVE_RESOURCE] = { -EOVERFLOW, "active zones exceeded" }, + [BLK_STS_RSV_CONFLICT] = { -EBADE, "resevation conflict" }, /* everything else not covered above: */ [BLK_STS_IOERR] = { -EIO, "I/O" }, diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index e1846d04817f..9b77d8eb480c 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -268,7 +268,7 @@ static blk_status_t nvme_error_status(u16 status) case NVME_SC_INVALID_PI: return BLK_STS_PROTECTION; case NVME_SC_RESERVATION_CONFLICT: - return BLK_STS_NEXUS; + return BLK_STS_RSV_CONFLICT; case NVME_SC_HOST_PATH_ERROR: return BLK_STS_TRANSPORT; case NVME_SC_ZONE_TOO_MANY_ACTIVE: diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index 1973ef9bd40f..927d9d30e1df 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -162,6 +162,9 @@ typedef u16 blk_short_t; */ #define BLK_STS_OFFLINE ((__force blk_status_t)17) +/* NVMe/SCSI reservation conflict. */ +#define BLK_STS_RSV_CONFLICT ((__force blk_status_t)18) + /** * blk_path_error - returns true if error may be path related * @error: status the request was completed with @@ -183,6 +186,7 @@ static inline bool blk_path_error(blk_status_t error) case BLK_STS_NEXUS: case BLK_STS_MEDIUM: case BLK_STS_PROTECTION: + case BLK_STS_RSV_CONFLICT: return false; } From patchwork Fri Jun 3 06:55:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12868717 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 F1FABC433EF for ; Fri, 3 Jun 2022 07:18:03 +0000 (UTC) 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-668-bb0BRRz8Noevn_VrV9AbRg-1; Fri, 03 Jun 2022 03:18:01 -0400 X-MC-Unique: bb0BRRz8Noevn_VrV9AbRg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 50D461C0CE85; Fri, 3 Jun 2022 07:18:00 +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 CE58F2026D07; Fri, 3 Jun 2022 07:17:59 +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 23C0C1947060; Fri, 3 Jun 2022 07:17:58 +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 95BF51947040 for ; Fri, 3 Jun 2022 06:58:12 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 86AF9C27E92; Fri, 3 Jun 2022 06:58:12 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast07.extmail.prod.ext.rdu2.redhat.com [10.11.55.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 81A48C23DBF for ; Fri, 3 Jun 2022 06:58:12 +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 654473C0F752 for ; Fri, 3 Jun 2022 06:58:12 +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-639-vkpyYbgdPzCVebOJG7vv3w-1; Fri, 03 Jun 2022 02:58:10 -0400 X-MC-Unique: vkpyYbgdPzCVebOJG7vv3w-1 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2531ZDGo019365; Fri, 3 Jun 2022 06:56:02 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gf8rwrbf6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Jun 2022 06:56:02 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 2536oJc4001837; Fri, 3 Jun 2022 06:56:02 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2040.outbound.protection.outlook.com [104.47.73.40]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3gc8hyxp4e-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Jun 2022 06:56:01 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by BYAPR10MB2789.namprd10.prod.outlook.com (2603:10b6:a03:82::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.19; Fri, 3 Jun 2022 06:56:00 +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.5293.019; Fri, 3 Jun 2022 06:56:00 +0000 From: Mike Christie To: linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, hch@lst.de, axboe@kernel.dk, martin.petersen@oracle.com, james.bottomley@hansenpartnership.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Date: Fri, 3 Jun 2022 01:55:35 -0500 Message-Id: <20220603065536.5641-11-michael.christie@oracle.com> In-Reply-To: <20220603065536.5641-1-michael.christie@oracle.com> References: <20220603065536.5641-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR16CA0012.namprd16.prod.outlook.com (2603:10b6:3:c0::22) 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: 40893671-3b67-41cd-ca12-08da452e1abd X-MS-TrafficTypeDiagnostic: BYAPR10MB2789:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: KeOR0yMzESPKEwLyGdKwcIyJyRSFo3O/kOlSst/HrjQgTOED4V0AV3Vh1IpwUpVWy3edHmvkkVimx7LHegAJeCBqUqh+oRUFEKreynpOl3NgqJzmwKQE+O6MmAt+O5mLVUhlxS940xtYsVwJwCpOExA5QQ8zGEDxNPNxU3Ho76PwIcPb/R9H22gQGu5QfzIIHo366kSpBfJDAs4eF4geOAKDIOG6G01XSEVuFPHpLYIDa9GFyn60cGObCPOo+c4gPxTzx8+slUC/gdoIX6NJV17e3HpSsyqrhu+hSX88xjGKxEKjsXWDC2pQoc+wSIzxJkAKv/HOG3MlYWuFiIbXuEwLWebGbgc9cMkHY4bly8f5syV928JkJT4mVybSinOVsRR00WX8+nqNwl7uhUS6BEZwku/VohsRje/+0HzBXybk3pih62y4R5s9TXz5qFXIAKsS6qmUonL/TYLKSDxws/AZ9rEAaf9qMRIzfAisbUCoRq8k5uVJxSqMDr6hxXUxHXkNIkGhL1w5TNybCP1rgaNSoxUoNlTYr2O0O2u7rKEP2+5137V980NPgdAfXhB/Dt6rxBFlwPC1yDJsrcjueDUEoa1LwUudsearXBxA37sIVr/Pk4tVq1ZspNyvpwzgpqAblvScETgGKtRjpwlbMSmHlP8QmC87jUR32DZtuTBMdxPvoUC+wATAXZwJfreMZJdtnlbbpxE4Qsd7SCHMNw== 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:(13230001)(366004)(66946007)(8676002)(38350700002)(38100700002)(66476007)(4326008)(66556008)(86362001)(83380400001)(36756003)(8936002)(107886003)(6486002)(2616005)(316002)(5660300002)(1076003)(6512007)(26005)(2906002)(6506007)(52116002)(186003)(6666004)(508600001); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iPx+Rubzu6tnTqcVVEGg+KKIzIRu5Q5+tl1dJ4L1xpEaHP/5blRt+5coDOLuJUAhUetDytsORvIyB/xyOC70zZynssncQJWo2iOsoZNABqtqBBAPk8FasoVsrxUs6q6jOSSAymtk2fSEdVLkVzKOqAWhP3Pun/Sv2/JbjUhRMXvKYtO5QnHf0EtfvWkSuTqi/B7LS79E1KuxQ7waoER07L10gM9CMkvI7c6AYMteyVyAgY0oPXBJlfn/IXrYkZzRY9KYfzswjww/9bJqu35gJN1fMpOQj+hZzLJwX09Iqv7TQRGlb9prYUxcFD0/3IYfasww4LEdvQEMF9mOg76s4rVmnWCdYRPVfRQRLtJ/2wUI49gTBkxQCccSpT2WRt1SNeiikgWMbqMvz7cHyrodaww3Ksd4wjPx7Dc/ux/k1YUemcc/9N9VOgszSviPpbrMlmZGSL/cFHh4z0WON4mY/cCm5w3FaVrgEWt/HyRqCt4T6+jazAGckKvGxTPMJb225Iab7KzFiwr86yjgV2I7NeB3g0LIX+jmcILYYqWTxjMvlLNG+dUFPDJJ3He6iN6tpBZEOjJsViQ01mD+XgvV3HJTSc93+K+WIZcuog2gAuQL8PNp7WOkpjY2HfqxIhXixrD3ORn6pXts2yapcBq8iv40nj+Co+ePpEKGAEvKmPOb8ozK50OuuPTbBQ5d3JVAh/Y84/Ci6EWtIW7+khp9rpKsPuxJBY4nCslkMLdnFuq67JDO3mXxQIVVNvSQcQSx8mHHalRxEE2E6s88vei5jXWe/jj6Rkt+WCSRormWvKUgUNCzPuEU0qP8BAvwKHhTghfNMfhSUsoLX7Wx0FUwrc1LKAgLiz8ap8ajkeCQgFzKWlxqnj4tEtTZoha8fki4nRATBPVOy5x6qGTZLSP0Xzq9oufsfxQjk1y4jJVJhvRf2+JHNR/PAioH7Dw8qs5Wgm3Fy2o9jvmdvQXoab9dn8/z0dUuVx8xn7jJY0CqACZLl9UIz+cQtNrjXZzJBoGufQDmmq7SvhUXj7eBaJW/UGXhKV34TwnssOoLzSoeJ/lvqBs3xLG/UsGXyvab0jNUGTRFOIdFiRY0cXchr636DPCoxa8rXqK31I80WKDnXC0qRNDqPE6oXb/cTgge6rZCi6q0Fw4MMBsmVUKkiJCn5Gd570TVELLPWsXXlYtMBDMQTHrCxjn/juAaipxN3RqEn66GPa2AiLPif+hnIoDFUYzYAeEMNmzPy6xqRxjwsuY2G+IOM18mXGcmAJnEV2bbXV7TDM3KTG9eg1E+d4+s9K39aOCrRmqCavx9m4Dc/Afa/jXfxMktyqW4sFQi535DKza1lwc5hh8SudVlTUEx3kkqJKECnDq0mPiJf29XkYJVrk2mw8Mx2tQhQPb0Xp9r5XRgk4wrUUazHxbf9ERRb4/SrRMBWe5yUBcaWBNpjQ2H74TXHSuLoX/lP7/WVRuM2fNqrrz9Jwq9p46LR+vRacZaN9XryI45M6/07PaEVmYuGmZL3kFn8UD6PqCUQ/Iq9REAd+KQyCoPgdf1gOaXJQU2iiO0PD5EXXrMD/tY3nHnOxpcfXbe80XGsG2iNFZClKXKIUhLfs3Zqq95u7mKd5KL8+w6Pos7PvPhdGT5+3I6Da8RcUgywujVG6HKpdPB9X3Ogj9/giHyGgGKtEn23z3wnjAxfzDUEmpxqoKocXKFhI3EuY5JYkAyJrGtmTuFDi7nkHk/oEyPRjn8DUZqZz2mCo+Mc8HlkQ/W7g6Ebwc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 40893671-3b67-41cd-ca12-08da452e1abd X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2022 06:55:54.8460 (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: nWhfROPj0TPnSPVYZyqv23BD1YUTKIZZqB4r6XZwWB7/cvn/a/POqedg2y6GHqJe/Ld8jugdR4FUDDct71GPHC71CuSJhZjOxiTV7ve6pfc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2789 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517, 18.0.874 definitions=2022-06-03_02:2022-06-02, 2022-06-03 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206030029 X-Proofpoint-GUID: xyZOZP5iyoXz9InAwD2vOS8W45amKg3G X-Proofpoint-ORIG-GUID: xyZOZP5iyoXz9InAwD2vOS8W45amKg3G 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: Fri, 03 Jun 2022 07:17:56 +0000 Subject: [dm-devel] [PATCH 10/11] scsi: Use BLK_STS_RSV_CONFLICT for reservation conflicts 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.4 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 has scsi use BLK_STS_RSV_CONFLICT for reservation conflicts so upper layers like lio can distinguish this between a general nexus error and a reservation conflict. For the latter we can then report that error to VMs. Signed-off-by: Mike Christie --- drivers/scsi/scsi_error.c | 1 - drivers/scsi/scsi_lib.c | 11 ++++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index cdaca13ac1f1..621627486e5c 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -1985,7 +1985,6 @@ enum scsi_disposition scsi_decide_disposition(struct scsi_cmnd *scmd) case SAM_STAT_RESERVATION_CONFLICT: sdev_printk(KERN_INFO, scmd->device, "reservation conflict\n"); - set_host_byte(scmd, DID_NEXUS_FAILURE); return SUCCESS; /* causes immediate i/o error */ } return FAILED; diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 8d18cc7e510e..623dc1cee51e 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -597,7 +597,7 @@ static blk_status_t scsi_result_to_blk_status(struct scsi_cmnd *cmd, int result) case DID_OK: if (scsi_status_is_good(result)) return BLK_STS_OK; - return BLK_STS_IOERR; + break; case DID_TRANSPORT_FAILFAST: case DID_TRANSPORT_MARGINAL: return BLK_STS_TRANSPORT; @@ -613,9 +613,14 @@ static blk_status_t scsi_result_to_blk_status(struct scsi_cmnd *cmd, int result) case DID_MEDIUM_ERROR: set_host_byte(cmd, DID_OK); return BLK_STS_MEDIUM; - default: - return BLK_STS_IOERR; } + + switch (get_status_byte(cmd)) { + case SAM_STAT_RESERVATION_CONFLICT: + return BLK_STS_RSV_CONFLICT; + } + + return BLK_STS_IOERR; } /** From patchwork Fri Jun 3 06:55:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12868719 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 5130CC433EF for ; Fri, 3 Jun 2022 07:18:06 +0000 (UTC) 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-168-_Am64D9GNiewtTecsZQsrg-1; Fri, 03 Jun 2022 03:18:02 -0400 X-MC-Unique: _Am64D9GNiewtTecsZQsrg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AFE92811E81; Fri, 3 Jun 2022 07:18:00 +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 9AC3F2026D07; Fri, 3 Jun 2022 07:18:00 +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 69A75194704A; Fri, 3 Jun 2022 07:17:58 +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 A4F3A194704A for ; Fri, 3 Jun 2022 06:58:12 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 93B4F2026D07; Fri, 3 Jun 2022 06:58:12 +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 8EF132026D64 for ; Fri, 3 Jun 2022 06:58:12 +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 6F3AA1C05AE1 for ; Fri, 3 Jun 2022 06:58:12 +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-394-iBEz3jDLOVWXiF89NiPQkg-1; Fri, 03 Jun 2022 02:58:10 -0400 X-MC-Unique: iBEz3jDLOVWXiF89NiPQkg-1 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2534esIM016519; Fri, 3 Jun 2022 06:56:03 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gf8rwrbf7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Jun 2022 06:56:03 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 2536oJc5001837; Fri, 3 Jun 2022 06:56:02 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2040.outbound.protection.outlook.com [104.47.73.40]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3gc8hyxp4e-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Jun 2022 06:56:02 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by BYAPR10MB2789.namprd10.prod.outlook.com (2603:10b6:a03:82::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.19; Fri, 3 Jun 2022 06:56:00 +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.5293.019; Fri, 3 Jun 2022 06:56:00 +0000 From: Mike Christie To: linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, hch@lst.de, axboe@kernel.dk, martin.petersen@oracle.com, james.bottomley@hansenpartnership.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Date: Fri, 3 Jun 2022 01:55:36 -0500 Message-Id: <20220603065536.5641-12-michael.christie@oracle.com> In-Reply-To: <20220603065536.5641-1-michael.christie@oracle.com> References: <20220603065536.5641-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR16CA0012.namprd16.prod.outlook.com (2603:10b6:3:c0::22) 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: f742ceaf-61b8-4ad6-bfbc-08da452e1b58 X-MS-TrafficTypeDiagnostic: BYAPR10MB2789:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: SFNkQ189PXFW+x692fgbhBCfAZNnFG6StmyH/2RUW8lAucY4mX4qmARj2V3f9GF/r4yv99qBIZsA0ieWnHTWTJa4HVEF7Bl8kPNyahK2Vz8MOA3Sb34jG9yO9UP6cN7V/RkXwfTR/wik9HNEft1ersaRoKOYAS1M4CDM/Uh+55OvDcTq4LNxEEWs7gvEeGRsMErnVLxDkXkhXII6lt0fst1F51A6kggQkp7oVFvqdHHP0RFpARjTFSCzpBE+eL7tmJGVmmv/AKbcjocaha325Ci3vg3/90Ki0Yviv2FjkTdZ67T2wx4arK5TZjgihRkq2M8XTnPNBM3U86HMnA2hzEAnsMoCXX2u88pk4gAvER0pncKMM0ACSN/vNW2kZ/NatYhxFLx4KKsMhMxx5M2EgozTdL9qe6YUmT8ZQrRnJjmmbVqLPRUpsMQPbLi1fclyoKeFnaSEkN2qczILJThDxcocvvO2mD8zEkPx50a9Wj038Xcg8u7oHUQGJYBqz9zj/FfJejZHievA0Lok4WdA28xWdO+s7DOdw8HZw6rg1Qs6RzNbXX10d03MOy8QMLwai1Pn0ODpYqDr/0Y7yZFibMqBiUnSmxceQ5wuX2A+ktr6Kxg9nfjPx9HErEmNEdBmFKG4j9TPEfbSuLZJdhsRPktolDQIt3WUYOLCnYkOnVjBnPYRqe68daSvacf5qB1XPYX3Zx7X5kwsEXstfQwwxg== 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:(13230001)(366004)(66946007)(8676002)(38350700002)(38100700002)(66476007)(4326008)(66556008)(86362001)(83380400001)(36756003)(8936002)(107886003)(6486002)(2616005)(316002)(5660300002)(1076003)(6512007)(26005)(2906002)(6506007)(52116002)(186003)(6666004)(508600001); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EAjqUtGX5fjLP4Krt3fKksOWUgXtnlQH64/n+UrXyNuAfyDvkplnGQyyLb0RAScf0+hvWNRad65URT2n3j4ZA0IK7h4QjonjpE7/TlVqc70jpkj7Rqclx9Krc3d8lSwKHi/WqH5ojw/73bwhDmzCTAUFJZymQS2sVjAFSRER+FdrXqJld2LMFRzsZ8w/keZHek8waQp6mXXcw2k8vUtBRyQR3M9UJpyJWGpuah325C+Efw2qMUT2Ji+9U3vOBrQ7HBEEUxiekxRrqeGLUz9+jhKBci74EPFnJI0ICU6KjU3tsU7O/Yhn0uk7HL1AHA3jatUONRmmPEmlbhIQWQ0RBR9G3kntxgfR0Hly0SFPoj0wJUEqSPeUYeH8FF4nfazuyN+pMuay20iZfsE37E4SZyfVjummB9FqFQJwd5ujgtpC2mZ/DGrj9h+YRIJyKSrwXMQn4PZ9ChsqXCizSMHcJ0F33vX3122VQxAGWXILvg7MFXZvqME75XLxaVuT6JcnGEFboBBA1DRotU2DEkQ/tjqU95GfDk4RDhWY3i95odbCKvWNxZsdE4prjOoQVWikqAD0dJW4Yygz3zEbRe8pGA1vhNd4aJy0silJDZw2A8ftOo0um8Tc76KCjZB0IclKX4uqsvY+OiyN7N33Bgh7cQQNtf7KfIDUIre02qT7iw13EZtT+PcAf2upZplsGv2l1cS6ZweXQU8WVluxR9gJFKrB8B7PZvbw1fNS7+7s049ZXo7s/Qic86kXb5ImWfQR4EXQCHk+ClPgyqjMiVLJPI4L4EqAssg2gkk+Zy6AE3VBEwxvTHOMg31MWYBclGE2junSaFnIdhnnKfcz/4u3TSgse8or/RhIZkaDz1k4lh8dmUebw4decgIkkWACo2JTJUNRv5GApU2DB+ivy6YTnUnyDsRjT/RsZduyt1IWCJW0nY9c5WE0v2tm1SOp78V761cSWNEjqcp22wAKeYhsVy7kD1YozJMm2lo13N6IMbhyp0oxqjC/680M3V9o+JvGTUi4RPB67c16tXz7OjYAAmV5tdp7Mg/lofw3Wiw3thu04Yb7dfRsEbUlsecJ8pVx7yHPc4IWfsgeBMH8voZNiJwE/EE28pIo/ZFBN0GCH09FYNLT2XmOi6uvQnqJPXu2l3DGaBpkRiboTGZ5mItaCdsoiC4G6CdAGN5J5/esINGQrRU4y3ENrocgB0yynxnmntD/7qjlsbIDx+zmjYCrzTr6hyykvGsa8t09f9nsLZVOV2x5zsFPLy4/7KuGKhny17Xy7vEugbn7rR9s7hlJ/s4ZGMHUyP9UYJ78Hb3Wv43pDKLJZxf6anmdw1HHEqkmnVsQRzmfy+Ru8tqrS/es+RQsifC66p1x8FLfOPbHRjOTyERv2+1K6BMTu5fajIBygNYKuog8rt6qdbJHWuPN9WDhJjTuXcm6vYI6f1RMSAWhd6xeEtGh9T1hgz7CedgDFxqaPqLWN8oByBpYSNAccdB8HSn/lgsp+mcKgNFDlWzH+J+mhQFtiCraTzOXe1MZyWPtWM5AjgQ5T1UxvqnjxS1geQ9gVZ/4bBrOQYZOTQCYczTXWyB5ZteaZ33KtZN8dxJhcrq77pjIGLIGM0Km6YuQGjTzH6c0ZdP7tCuNFe4CVNblqisgyycpBuf/pWcOngWIJ2qbbi/pAfHwNuSk2Yg7Ja53JI3C+oOgNMF0wl++oK0KJCT+zGVVzXlyhTurkqt45iHP0Ip/CuzOoEI3Ghyj+scFgblRPNOLd8ahmC8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f742ceaf-61b8-4ad6-bfbc-08da452e1b58 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2022 06:55:55.8459 (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: 3mY2xzVm2VN945w7chvns6fBsMBqZrdb4GRoA6Pvbk3Gv/8Y54UHj0oHT7KVMFBG/GaIzeSstTOFeZKWd56y4wdu6mc6no3FuGKDTHDXjRg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2789 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517, 18.0.874 definitions=2022-06-03_02:2022-06-02, 2022-06-03 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206030029 X-Proofpoint-GUID: WuDPelidR2xkIuX7mJU-_LS-mhObuxqO X-Proofpoint-ORIG-GUID: WuDPelidR2xkIuX7mJU-_LS-mhObuxqO 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 X-Mailman-Approved-At: Fri, 03 Jun 2022 07:17:56 +0000 Subject: [dm-devel] [PATCH 11/11] scsi: target: Handle BLK_STS_RSV_CONFLICT. 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.4 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 If we get a BLK_STS_RSV_CONFLICT report it to the initiator instead of using the SAM_STAT_CHECK_CONDITION which gets translated to a generic error that initiators don't know how to handle. Signed-off-by: Mike Christie --- drivers/target/target_core_iblock.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index e8cf201e59ca..2a964b57303a 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c @@ -309,7 +309,7 @@ static unsigned long long iblock_emulate_read_cap_with_block_size( return blocks_long; } -static void iblock_complete_cmd(struct se_cmd *cmd) +static void iblock_complete_cmd(struct se_cmd *cmd, blk_status_t blk_status) { struct iblock_req *ibr = cmd->priv; u8 status; @@ -317,7 +317,9 @@ static void iblock_complete_cmd(struct se_cmd *cmd) if (!refcount_dec_and_test(&ibr->pending)) return; - if (atomic_read(&ibr->ib_bio_err_cnt)) + if (blk_status == BLK_STS_RSV_CONFLICT) + status = SAM_STAT_RESERVATION_CONFLICT; + else if (atomic_read(&ibr->ib_bio_err_cnt)) status = SAM_STAT_CHECK_CONDITION; else status = SAM_STAT_GOOD; @@ -330,6 +332,7 @@ static void iblock_bio_done(struct bio *bio) { struct se_cmd *cmd = bio->bi_private; struct iblock_req *ibr = cmd->priv; + blk_status_t blk_status = bio->bi_status; if (bio->bi_status) { pr_err("bio error: %p, err: %d\n", bio, bio->bi_status); @@ -342,7 +345,7 @@ static void iblock_bio_done(struct bio *bio) bio_put(bio); - iblock_complete_cmd(cmd); + iblock_complete_cmd(cmd, blk_status); } static struct bio *iblock_get_bio(struct se_cmd *cmd, sector_t lba, u32 sg_num, @@ -755,7 +758,7 @@ iblock_execute_rw(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents, if (!sgl_nents) { refcount_set(&ibr->pending, 1); - iblock_complete_cmd(cmd); + iblock_complete_cmd(cmd, BLK_STS_OK); return 0; } @@ -813,7 +816,7 @@ iblock_execute_rw(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents, } iblock_submit_bios(&list); - iblock_complete_cmd(cmd); + iblock_complete_cmd(cmd, BLK_STS_OK); return 0; fail_put_bios: