From patchwork Tue Aug 9 00:04:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12939202 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 074E5C25B08 for ; Tue, 9 Aug 2022 00:04:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660003499; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=HMseTRug6oyZmhGNnSs5+rOGkwP1jQD1P5Mz6hEXQE0=; b=AC8+pqvOUWKs/oGbkf6tyNiEXTAOQ7YyPKSk1AyH+NbAWQLe9IV5Ued703Sd/SOwdH4Xzv bMozjjlND0MOHEiFRcfP/FNRs3xDCFdx+Oo4CQxkaHuzsY7uNXhfIBpy/Dxcw4a00trvLz 5+9xkH5900j7Qh9iv73D9WUwdpwNgb0= 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-515-RDQ0l2jUPhmRxVJ0bIQJnA-1; Mon, 08 Aug 2022 20:04:55 -0400 X-MC-Unique: RDQ0l2jUPhmRxVJ0bIQJnA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A452D38005D4; Tue, 9 Aug 2022 00:04:53 +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 697E7C15BA3; Tue, 9 Aug 2022 00:04:51 +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 BE0B71946A6A; Tue, 9 Aug 2022 00:04:50 +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 9BEBB1946A50 for ; Tue, 9 Aug 2022 00:04:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 90DE1C15BA6; Tue, 9 Aug 2022 00:04:49 +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 8B7DCC15BA3 for ; Tue, 9 Aug 2022 00:04:48 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D02BB38005D6 for ; Tue, 9 Aug 2022 00:04:48 +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-503-KhV_XFmqPzSwBvoI2ccOsw-1; Mon, 08 Aug 2022 20:04:46 -0400 X-MC-Unique: KhV_XFmqPzSwBvoI2ccOsw-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 278NwJlD007174; Tue, 9 Aug 2022 00:04:26 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 3hsg69n1d9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:26 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 278M0hsb032829; Tue, 9 Aug 2022 00:04:25 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3hser2cbnw-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:25 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SN6PR10MB2590.namprd10.prod.outlook.com (2603:10b6:805:45::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Tue, 9 Aug 2022 00:04:23 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50%6]) with mapi id 15.20.5504.020; Tue, 9 Aug 2022 00:04:23 +0000 From: Mike Christie To: bvanassche@acm.org, linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, linux-nvme@lists.infradead.org, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Date: Mon, 8 Aug 2022 19:04:00 -0500 Message-Id: <20220809000419.10674-2-michael.christie@oracle.com> In-Reply-To: <20220809000419.10674-1-michael.christie@oracle.com> References: <20220809000419.10674-1-michael.christie@oracle.com> X-ClientProxiedBy: CH2PR05CA0041.namprd05.prod.outlook.com (2603:10b6:610:38::18) 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: 8123884c-29a3-4ac6-1225-08da799ab710 X-MS-TrafficTypeDiagnostic: SN6PR10MB2590:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: ZwP4yV1pR/3z8r+5lJA38aDQk1xZHPIawUbA5SFi1+g+eCsfE00eCeUS7wAn6QZ+6r2C8AUyGHZBIuZWXHKIVfP4xgD5mq91OvVB0ezigUGJ/YLvUlqGF61IRt13eR14nPiduVXtcF+nklNY6VHhI7CqXoxHtt+NdKf1lEMBClWN5gTK5AJGYxPAzfOcYxW1XZOFIHIU8o7yWChkZg9+0hmbeL8NyX4bRx9rwZdYvP2BzXFsuu4IkLUFhIeTMwDi7KFZR8x7InsNuRYI3Bh1HJK8bMvxeEHPoDQCytRDCEUzLc/i3Q39L/g/RgGmah9fGzgKAc0s4FOowddDrxt/6VtlVveUkgf6tRNqRjNvMi6wLnyuywIU4ygyfF2nIAbEPzjrUu+45UZkGARJvFxfy7lDBYmHEtnERNyYzr5R6m4D+X7mYQeH8v6Qz2DQUq/nRTUKE8DnETPLeEjEFL2H19bHqC3WlOeeDqd+ZCEzxiBZBXwrdpts3vz9IHNQrQI9AgzJ7DMEUegN/vDfOK7FJUzG0JM8kPpb81+nUhWgbbRdPFAOSsYECddQZfYQLffNbTQMexYmOSbKNew3rLnEQemYD28zjdTJsvZN6VCtI465i5/4hk9Hl7b6iY8FDNEHMlXXNnOsJYtvpAjyyI8o2RTEFBW4aLapcwF53239FRjQtpL1mHsCQXARPymyFZQcZgwj+KtGIyeyGCs4BDGmaVANaGVuJ2pzemZ+BH9NV4QFjxnVEzs/vn+3wO2JUkhI62v6fWeDJrWj6J7rjY56bDugSsbSFg1VC3QLSCUGo94= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(346002)(396003)(39860400002)(366004)(136003)(376002)(2906002)(83380400001)(6512007)(26005)(6506007)(186003)(1076003)(2616005)(36756003)(107886003)(38100700002)(86362001)(921005)(66476007)(6486002)(316002)(4326008)(6666004)(8936002)(66556008)(66946007)(8676002)(478600001)(5660300002)(41300700001); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: g+vI3MMH2s1WqLOlbVq5cYUzDX9DYwtdgQbxTx7gK2AS8OtDeBK1+2VSMXl3n7YdFSaUb020Y24tsH7qiIZX5ketq4IZ7A2ZROu2zGZBR0Bvzn608HM83qlNgpM0+r10uaarMs1dgfDAtudmU1KrwmxN4zX4QmAYRGJ5mU3NYM9HR2G02gbjYRv2ETcOuX+BZTO8dWD9+FnTqIU3QpRgkBA2QdifYJB8YGO/etM3MvxCE8xs18WwZw6AzSnF9VSMXhlyP9rbol8uipv4G2p/X6MeQwppZj8BqZa8zWOzkiZiQoYtcyC7Bwe9NjS16Ig0S5d2jX3a2pD7BXyiPQV9IAJOhgbimpv+jsQEqmFTnDL8kOi+cybg9w/C09gRFCWY0IzZTN2bwrVvOziW4hSB1K6bu4uqWYejOchcE/nFKbssqLHHQ+i00F27ybzN5qwdvegdS1Ena37hztTXEnx57BF0sIXG3+rSCjTxYPYbqm/OYN0GnkZ9eEClMdXjXfgtiWFLoAyX5ZK8hW4eKtct+Wfd+TdhU/56Bix8RwAMvUxtPnaQifn6vjMENaCkWy+7+JUYJtRQdj9OYSV0PWwkmovZYNJnclHwp2KkC/7r1o7OnKX9SK3RRVelpbVb9MwLJBmisM/oKaJnVLQyHuJwQQUgg6MofidXGS38LZHej4m4lYSGFghYujiLrJGoj6r2fXtTrQl/qdZkfJwDWDjUTYqeYaK+jEv/MB5kOlAZt5Xw8CtJVl90PMB+WKeE9GHpFq+5oR4llyjfo7pemm1kFWgk5YOizXbXZew4j9YZJG6SQ7tuwLQUUPyVakX0mkfnnu0EanOSljv6eC1S12+LZwc6IPOg6CmyFr5BH/0lMjGq2QieQN0C3O1atNAQ3gK3iK6SA7avS1KPicPaTV//hIwgfCNgwI6ta+nJMXrIV/uFX+kJ7g/O/SH8w4Mf4HXX5Jsc6wBFYSXCBhYEEMUb/ARBZTT8tHPjs52nZOTP6nuqyuS5TkevOhy9f+7GHMbkPbC0Il+laNgKnlBrh1OmdZJlLAF4GnLQ/wBIxM0O0SaLio67Vd5E5UjGPTvwdgC3o6YYHbhCoyaer/4MHamKeEQSRwo+7ivwEhTU0xWl5egQ/at5lzJWF9LT75RdconH/lT4F7+uHRcCtOTjG0vGzdP13CiZwiWkKXkuuiUBeKJ02IijhcW9oALh2+S563Rcpg3vJuG7KaOlNEKPwxdYeijdP7W0lqaDHtsgLFDukaaJ9XIFkspm3lgt9CbJzeb1LEMqq96oGPEyk4Wr4XcQ/RoFX7yA7wgXc79wWvp/s6Wm5XAOQaW7Y7s29cz9YU45crBqzVlhtZA74skc3Pv0Evn4H9/0Hzu3mp7oYQsZUB4VOd+JRm+momYJsFvL/4Ef6naeje1h82yQuSPMBoXQHh6tD7z5kDBl7lysS2JRJqNWOFVZ9U4Bu77IpVLapGLp/nbp1/IVhNil4+N808DbdoPkjwEauA1xsDFzVGRZY1ZSx/cRlafXz6PJz5p7zDwpwbh8rH3PSsnc9VexVL9nZrhSmYxUJJFEOhaPHodIDpMhhqJh1W4GFGvPAfYCr70ODJWl89LyWijxR8p8NjZpww== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8123884c-29a3-4ac6-1225-08da799ab710 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2022 00:04:23.1273 (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: ofT7aIcOQgOIWgC+6iDF4OYBWv9ObyQqcf6fmkRtEsU383EhwfqMK3MiGicczbTJc6jJuN5j2kqxj517gS3xa9bl2gUFrfDuRnr4GSZ4ZCI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB2590 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-08_14,2022-08-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2208080105 X-Proofpoint-ORIG-GUID: kEnnU2xUAS40oK5N9V7RK2G4FHB5Yg87 X-Proofpoint-GUID: kEnnU2xUAS40oK5N9V7RK2G4FHB5Yg87 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 Subject: [dm-devel] [PATCH v2 01/20] 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.85 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Add callouts for reading keys and reservations. This allows LIO to support the READ_KEYS and READ_RESERVATION commands and will allow dm-multipath to optimize it's error handling so it can check if it's getting an error because there's an existing reservation or if we need to retry different paths. 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. read_keys and read_reservation are exactly what dm-multipath and LIO need, but for a userspace interface we may want something like SCSI's READ_FULL_STATUS and NVMe's report reservation commands. Those are overkill for dm/LIO and READ_FULL_STATUS is sometimes broken for SCSI devices. Signed-off-by: Mike Christie --- include/linux/pr.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/linux/pr.h b/include/linux/pr.h index 94ceec713afe..79b3d2853a20 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,18 @@ 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); + /* + * pr_read_keys - Read the registered keys and return them in the + * pr_keys->keys array. The keys array will have been allocated at the + * end of the pr_keys struct and is keys_len bytes. If there are more + * keys than can fit in the array, success will still be returned and + * pr_keys->num_keys will reflect the total number of keys the device + * contains, so the caller can retry with a larger array. + */ + int (*pr_read_keys)(struct block_device *bdev, + struct pr_keys *keys_info, u32 keys_len); + int (*pr_read_reservation)(struct block_device *bdev, + struct pr_held_reservation *rsv); }; #endif /* LINUX_PR_H */ From patchwork Tue Aug 9 00:04:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12939247 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F294AC00140 for ; Tue, 9 Aug 2022 00:07:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660003621; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=VzJupSgTJartYDqkBcx/VJ07y7KlhaOo3BLBaO5mQkM=; b=g0eEHAX1OQbUv7x7pWaZnT4IHuGxgBcBO8YK4IAGTZgxdkr7idleXb6YbYxeGVK14RjIsN 3yfC9pohwG0nOF/ITgRnUcUzYO+kygcD5Hb14QbV4GUBp0NCe0IGXlTBxizmhNZ24cRK89 y5gCy7PIEBqo+2jtiyunj06LAbxN4Fw= 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-399-mN0AhMtHPSyDoJQEkdYczQ-1; Mon, 08 Aug 2022 20:06:57 -0400 X-MC-Unique: mN0AhMtHPSyDoJQEkdYczQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 959CA3C0D188; Tue, 9 Aug 2022 00:06:55 +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 829561121314; Tue, 9 Aug 2022 00:06:55 +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 55C501946A50; Tue, 9 Aug 2022 00:06:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5DCCA1946A4F for ; Tue, 9 Aug 2022 00:06:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2D14740CFD0A; Tue, 9 Aug 2022 00:06:53 +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 28CE640CF8F2 for ; Tue, 9 Aug 2022 00:06:52 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3020985A587 for ; Tue, 9 Aug 2022 00:06:52 +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-580-uY8eN5hENaq2kKQUNDwIEw-1; Mon, 08 Aug 2022 20:06:50 -0400 X-MC-Unique: uY8eN5hENaq2kKQUNDwIEw-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 278NwJlE007174; Tue, 9 Aug 2022 00:04:27 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 3hsg69n1da-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:27 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 278M0hMc032819; Tue, 9 Aug 2022 00:04:26 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2170.outbound.protection.outlook.com [104.47.55.170]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3hser2cbp5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:26 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SN6PR10MB2590.namprd10.prod.outlook.com (2603:10b6:805:45::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Tue, 9 Aug 2022 00:04:24 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50%6]) with mapi id 15.20.5504.020; Tue, 9 Aug 2022 00:04:24 +0000 From: Mike Christie To: bvanassche@acm.org, linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, linux-nvme@lists.infradead.org, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Date: Mon, 8 Aug 2022 19:04:01 -0500 Message-Id: <20220809000419.10674-3-michael.christie@oracle.com> In-Reply-To: <20220809000419.10674-1-michael.christie@oracle.com> References: <20220809000419.10674-1-michael.christie@oracle.com> X-ClientProxiedBy: CH2PR05CA0057.namprd05.prod.outlook.com (2603:10b6:610:38::34) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 888f022c-bcdf-4486-5180-08da799ab7f7 X-MS-TrafficTypeDiagnostic: SN6PR10MB2590:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: 6uOkE0tHJOvcHrLB1gvu5VdlN7G54Dz9d3d8z5TSFbDDBQf4Q4X2IlTy70/xZVzIBfIbasrw5y3ihavLS1sKaAAuw7u4qVfDcXRgHFHojbAemLuPPNgJgQABQuPFzLjGyuY/KPPGAQ6J5niyQlyxFocHAyKzHrGvC/GXeNRQrXpERGv2MtVJb+V+AGrpFZPM65AMT9+UBOQ9dCR7+K58zM6Tg/fjNovAkRETOzVYOeZVao/90JW2cM6bnvkB3oW/v+QZodPIiFyoCii2sSq/3JOrORFEil9jqzbUNmVyIsGiYYEYo7UGMhfcGhcP3plSEOY0z1ICiMcYy2N0lCsBTSGZSEsOuRT3qIrrL8Bf1mUNRFYroj0xWIeFaMKUQnGZxFd2an7uyPIvSz4r7RkHuIW8Dr6UHucm31zrnMAT8WqRNHzuuUlVm5GlCKY5BMODZZGnEN/gpxbQXkxEcaLAkI5VqB1yv7ZinHzgRYl6jZcVFJHP2ED237Zc/q0bX7ntqVES/Uh4t0/6CWPEDlD68sCvin9TZNEZxHDuTDLQQmuRQaE4bGizi83lgZERm+H8+jWmxZxJ4/YT1kdvIzJtkqAYTCRC/JKjqF53RELsKheUHFO5GKYiJHuzVr/gKYhjUUO5PqJ4xZ1Inh3nycheq3Y6e2M1m9InBtVfGniWMZQOaun6wFNPWus58boqqHV2BOVOQhySjRmBBK/rTii3rZqH/oLTX2GiGnXVjIEl8GfAqmZqOKsdxwCSgEj6cKUKswD0gAfo1ROkGFC7DWVqUyYdxNPgF5cJaZc9FRlbxn8= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(346002)(396003)(39860400002)(366004)(136003)(376002)(2906002)(83380400001)(6512007)(26005)(6506007)(186003)(1076003)(2616005)(36756003)(107886003)(38100700002)(86362001)(921005)(66476007)(6486002)(316002)(4326008)(6666004)(8936002)(66556008)(66946007)(8676002)(478600001)(5660300002)(41300700001); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bW1uqUiKivVvpNup7FuMLb9Mw7HgqtE8ElxiAVRbFxFhat8ZG6ECmSlkaUAMO1jnLQXKz2XnutUbVSwwJFolBZJZeK7PWIpELsD/8ADaKXphiERXjnjcjxZNSDwjYb+zjmh3KRDazJ6D8BlrLAoUMX5GfZD0VDd1QaObNykLb8umcUAhTcig73shqtsCnxj7nwQ2F135YwaerKi3xjSJJkqrJm8BewjYbagwkyJRCZgmMu4IWMFvrPb2QmHgAn9HWfIcR4SmicMZCr1YZt13CBKqbOTHfyHT49UeQ4K+o7DRV9Hl+WOE/ssdkDLeSZQBkFRd3bOIDcDP5uw7+4jOi0YcPFb7OoJqAGoCQnnztvCKLB2iOOJD0qtLP6mfs384G/y4RDUzWDjhlH3wJGULL/eD63EQ0TrJXkdXmWT37MhdfTfMIkMwkIANELnhhduk9M7E9Ce47q6TTeB+XqybU4wQyH6mBXDNIC525Q2JqNcV355077yJ7o6ryJCW5kJgxfdIGQaF8bCCrWuXA1kH/v9kKHMbGUpCsdUZHkFz5a8MDJJzSzjyQN8UXK9aSegUqD0RJEJ60IKqHhRaiHrWPerZp+O2HdvpReirizFL0Gm3PH77JuHqYjtNzi09lFQp6aazh7Aa5WN3P+5wb/u7DBwkIykzPT76xXfxssizNo6Eou3LplD3oKkBX0IY1yuE9BBkk8UvB2jHoex/12QhSqzRZBNdoxHhWMAwESB72o8oZE8JeXS4BfpsK1dELpNcxYUlWp28+23Nf5wg/rAqt4Nw9vo8/u0GNhGr9U+jlzueQWKJoHrxu5QSnO4ouhugzvYNi/l7L1CdS6vNljMsi7TvmOy927Xkh7Tx36DxP3fTZ0IfqqkJuQF/PDSrjeYPVmjwNFp6ij0jVsLLlYlERx7MK9se1LXmO55ereh59WqTWBUB9gYmecbYRlw9PLaSNijlwn7bwnmSIHfQotO9NSbxto9otghQC8rk2Q7KF4y37JlVWQwmRBB/4nBLegKsgpVbJBC3QfwxR/UeLgfykKAU5fcBbyh82mDro48t7ecmopHs/CWdBm8R8EHjPFy0utCcyh/FssV+uavIoXOlfrg+yaUp/LfZ8rjUeYq4Tfs48RGnlochKrg8D4pgQJJKOIt7ZYYUb20L5+KwC9ikXBBVsY4rQA5HNfhI+IT9tItMeFNH9euLXiWHuUZ9a5s3KfPUTBACBpTNSfwxTcUgbesSm2huu77/tcRgalLxaQfCh0/jmptPHZuGZsbGu+JgI8G+vnbfl7jC0xiMnH/7Ox7Y+sqOXYRbdeGTfjtJ4/V5rHj0oUWCGNDpHKg0cOtTXq+WdjUb/XtT0tff+tW2wEqW2qcFi8eo7OnaHzvHBxVZ84dgU4OjKNoQA4KPb8EcrrRkcLgd29ippxDrrjsb3Run1ULdfBHQJfkqCfFthPjyBqry2LdRzBeT0H95QQKvRXv5pfcD5x4YMS4GPEDGPbWtHqdOodHOAyN4YFDfyNFHooPzaeIIuZCGzHnlX5RyOCYpR2WKD9tzEbI4VBdDu84mdOKXnQFZ8KBMh0CH2mSRhrBjLoCaDbwglzodJtBpAbRgpLeXlrvYqEv+IeQqYQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 888f022c-bcdf-4486-5180-08da799ab7f7 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2022 00:04:24.5959 (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: FXSPriSWbeDDS05iHg7sZDuFnfufZPvB48I2DTQZ1VkPYY75wYGrpmtl9hW3yEoeFnywJdK0FsGKU1qgXuZR0Q4BxDV14D8CU6qzkMLbCvw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB2590 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-08_14,2022-08-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2208080105 X-Proofpoint-ORIG-GUID: bGrHAruvhI1AYZ1Z1WXe7RRfx1mFhe0E X-Proofpoint-GUID: bGrHAruvhI1AYZ1Z1WXe7RRfx1mFhe0E 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.1 Subject: [dm-devel] [PATCH v2 02/20] 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.78 on 10.11.54.3 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 8f79fa6318fe..18ea9ea6bd68 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1702,7 +1702,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); @@ -1738,7 +1738,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 */); } @@ -1748,24 +1748,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 Tue Aug 9 00:04:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12939203 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4997FC25B0F for ; Tue, 9 Aug 2022 00:05:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660003499; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=NkAaKgCxsQqKUndtdKw9cLCxo2nDwLnVU5SLufM3jqA=; b=TB36xvA71YNc9H5zaCwmoPLq1xh6MABvfI1P3YPGgSoLzqmLTiM9BCmQCIUd68smr9CCRx 7r9sXmXCH6oGmVyEm6tt2ryG4LOcX8vlOjvn2xbBMIjvI00TYVLfBtZa5LugwXXO7aYWZ6 Lar83Jkn1KGQvRIVbDVXyTK3JaO5wgE= 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-407-vqbPf7jAMIW0DC2DVR32cA-1; Mon, 08 Aug 2022 20:04:55 -0400 X-MC-Unique: vqbPf7jAMIW0DC2DVR32cA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A54BB8037B5; Tue, 9 Aug 2022 00:04:53 +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 16DE6C15BAA; Tue, 9 Aug 2022 00:04:52 +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 0FCA71932221; Tue, 9 Aug 2022 00:04:51 +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 9BA431946A4F for ; Tue, 9 Aug 2022 00:04:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9098FC15BA4; Tue, 9 Aug 2022 00:04:49 +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 8B723C15BA1 for ; Tue, 9 Aug 2022 00:04:49 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F0C3338005D7 for ; Tue, 9 Aug 2022 00:04:48 +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-342-anrooHT7NeKvUuIa-eUXBA-1; Mon, 08 Aug 2022 20:04:47 -0400 X-MC-Unique: anrooHT7NeKvUuIa-eUXBA-1 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 278Nx9td021117; Tue, 9 Aug 2022 00:04:28 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 3hsgut539v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:28 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 278M0hMe032819; Tue, 9 Aug 2022 00:04:27 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2170.outbound.protection.outlook.com [104.47.55.170]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3hser2cbp5-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:27 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SN6PR10MB2590.namprd10.prod.outlook.com (2603:10b6:805:45::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Tue, 9 Aug 2022 00:04:26 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50%6]) with mapi id 15.20.5504.020; Tue, 9 Aug 2022 00:04:26 +0000 From: Mike Christie To: bvanassche@acm.org, linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, linux-nvme@lists.infradead.org, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Date: Mon, 8 Aug 2022 19:04:02 -0500 Message-Id: <20220809000419.10674-4-michael.christie@oracle.com> In-Reply-To: <20220809000419.10674-1-michael.christie@oracle.com> References: <20220809000419.10674-1-michael.christie@oracle.com> X-ClientProxiedBy: CH2PR05CA0038.namprd05.prod.outlook.com (2603:10b6:610:38::15) 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: 0556ffe8-5a5b-47aa-a561-08da799ab8d2 X-MS-TrafficTypeDiagnostic: SN6PR10MB2590:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: SixcG/Srx8yJk6wsq4ukG1fGTSj2JWOHxpSITkLbt9iJbSB7qkc6YpruJxF42DaeAMke52u04FaAAewLD3zA+TWXiV2WcmYghcU551pmX1gCb73qgMyC9nndcSt51/cg6Kyycx9XjTVsWfCW4Ct3N7S6YmC+X0Onfk0hao6HEsTS6qAR2eU9cUwg3YR644mHRpAWvOtgYoT/nPDz6qNZPzNrSIvktUV8/l/4E/E5Su56ivVHgV7xlRk++h+AQopJ1sl7tWxsh0hOvUzlF/jkHPNRJt5ITNaYra9p8QZPcnX3ok2XKSxsc4X4E5bKdrBGYUdTQ6zfUprxVSqqiDztnGRWbJtJHP9IgV7nx1DoyFUnvSKQas64O9gSWznCpDeVgUSZmjxyKKYX2ETnCbJ+DDc9LRoqiIYIVv8fyP3vBQcmspyXBBDpSn7VChFL1Ej7hH59SAjnfun2ir0KM274mWSZo7Oj+ArSRiB+tV8DisPjMFREUgqTaV9+pURCyZadQ/K7zxEoPFAhsN8o6+lb6gt9Ol0Q8mDXNf9Jeo74ZQvT7a+U+nSj5uyPz7ec9D7REGrt+S8b93znXBB5/nFVpTbwOXHn8+iuYC5nRr5oBS37D75up4FTuFu9i7TPIundtAcKpdXe4PZLhVDPTF2dVdzQRL9STnOhPI6JwzYtRD+scuer0O2PEPR1VaiLgqZ1gvcuck9cq6fjCGP52ht5J0RvmYPaoS5bo+OewwKCJg40UMATfEV3OAfCUVXhmOvcTV26oQ1OlBM4kKuEZSM4U13SKK8hpXgWGsdTXkl48zg= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(346002)(396003)(39860400002)(366004)(136003)(376002)(2906002)(83380400001)(6512007)(26005)(6506007)(186003)(1076003)(2616005)(36756003)(107886003)(38100700002)(86362001)(921005)(66476007)(6486002)(316002)(4326008)(6666004)(8936002)(66556008)(66946007)(8676002)(478600001)(5660300002)(41300700001); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CGUWVvHfpxA1StwZPKVv9q03fZOKNbyvnHlyxS0X0ng0lrPk3flvvetLQ5fdzvurLc4x84q1j/mKi53MUxV+hsR3JS0vNc52Iji5OjUnaSSkWWBdmUSj/H2J8rMtDuX/tOzvRp+gNO28VKw1eaReUpfyqP8F1FykPQeKhzkVpfP0g/HtuIxPjUTZmYEP5zD1x511lEskhSyo4uxYbASTzKjyEeiDEnGcHgNH2Q8ippnqV4iWp2wuvHdpMgBIYg0uHSmc7+ZCfjmWvOXC9JVhJoeF36qgCi0PgDBfigr0EjYOwo5VwfHZitcaxkssFwPoQzJXryIIG0lubSHQ6FXF5j2Yogd7dnwJ59LIIBHsgepHt8GBmrqKyqlyIDj4t9yJoc8+5wcvhrV3cQkrxBKsDzHSRuzolgnShwTbgPNAeSZAdJg1aorMO9rfprKUOybNjwWq9usayBaPRYtzLfMeFAjuuWPRJJAGX9CgOqQrdiPx4dbiz7wrabccmBP0WABDJImtAaptxy89nADWqYDIO4+h8fK8o30sLKs00BgnpSNUc01LOQhdni2uX1Z/AaMBpX7iBi+L8iJ42tJtfaqMn9q5JULhh/tdIqMOtM1Jf6viJHevXtBjWh5dqXDybfeiJp7do5SObAuOrTWbM9PceVnb8tOecfGqJYJnl5t92QGa1m5viRGC/9MOXJwMqXyZJSbXNcu8xU3rFAc4VJP7YYUEZfblEgINa8F8rQTt5JDvgVGZbgULUykcG48wmOCWvEgfM2AHPF7Wd1Q5uQLZJ8XfSn9FIvBY+IotGCUNjdrT0f0qJGoU3x5dZE0gxIP7bHHBw3VJKQfcnbR0Y4KLc2WfX2lFvXgT+PcO2LsJhltTgmKbznb1j3aHC+ni2axcS/TJQH5B3pp9Kfzk77cLaGFZ+SeMpX4LrjTECqUqCdih6rrBNEF4rwlRwAuzWb1IjHUyWzIlw6i6xmyfK9jThNrC5W85Zx4fEsFlx2Z64GeHTGEugmeIgAJi47nvWTlHhdWTMfB2/Jvb2qZJLxlqcYe3/ljJVWQOI/PracouiYfZqICtf7WAk76IgQUIaagUSt6EDSDMY0As7xDg/mqIAwL8jynI3dHf4AWgBYbwQiCUgwdkj+IOjFD4eTQuJifEk71dSsIC/ewWFVKVylx3s62NVsFOZuoUxR7MZJ7W4qSZBRCy3SCeU7QB98LRP/rUFLJJse+V9DukmYbBW8se3eo/5zzkjcWv+MDoo/gPM89Pyjb84ICpWoMH8+1eEEkPHLKhxmYOiRubze58q1H4p79xmYTjocsZm3UW7uKlkuXZyI++vfZ0bW7Lmn8rKxuRrN7aUSP8UAblJT+sHRWYgO4cItzV9DdzfCvSTzd+h6RTIkHQdY9NhKbPomtw5mLCx3xMLP5p+D7bZ+jApHiFQeih5f+rBdrjdakbPszD69GouqW6eifyWJwm7B84axX/dCPePE2OkA0zuNo8V8UJqwqQJGMWwf6gFgjVncGA8g5pPekfUbudCp219uwxDDAr6/yNKJyIFbLNs7VFdyKM+uT59UuaF1hfK5hNhUTPTBprUARA/i/Vs3QTugs1bPMyAU4Oci3hjH9488XARWylrA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0556ffe8-5a5b-47aa-a561-08da799ab8d2 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2022 00:04:26.0177 (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: P9Jz7OSkaJ1Ab2NX9pZV7m13piU7A/DRyZ2EZYZjbt3/BFeaOGba+njZ8ui/dS6oWyv+FQMTrdn3BxRhZz/HbQQ+olKryHThNpn5F2Z5F80= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB2590 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-08_14,2022-08-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2208080105 X-Proofpoint-ORIG-GUID: XuNzfgvyCDYAH_8UH82znH44PauVgU-D X-Proofpoint-GUID: XuNzfgvyCDYAH_8UH82znH44PauVgU-D 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 Subject: [dm-devel] [PATCH v2 03/20] 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.85 on 10.11.54.8 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 18ea9ea6bd68..88ce1464527c 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" @@ -1682,26 +1683,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) { @@ -1748,19 +1729,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..36d6e742fd98 --- /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 u8 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(u8 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 Tue Aug 9 00:04:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12939201 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 07849C3F6B0 for ; Tue, 9 Aug 2022 00:04:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660003499; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=myRzwcyd5z8rrd/4EKNxz8DksEy+Spu+YFGP5mYqe3U=; b=e2KZ20EdpwSw007PAPKwkHwz4+pNVHfSP7kCC0L/Qo7EaWDLZtgOKYufOd1t9ziTJg24y1 AV45aU//hog+AElQNH0hpp1Nmt/Yo3k4tg+uFGVK2VWhg5DYQ6/yyvRMQ4VDRrbsEz/lW+ sbTu2AmhvSLlVq2qq7mgtrTs7DJAeDg= 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-421-mF3Sfi1sNkeWuk0D3XN2_g-1; Mon, 08 Aug 2022 20:04:55 -0400 X-MC-Unique: mF3Sfi1sNkeWuk0D3XN2_g-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 A35E2858EED; Tue, 9 Aug 2022 00:04:53 +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 872A940CFD0B; Tue, 9 Aug 2022 00:04:52 +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 044581946A61; Tue, 9 Aug 2022 00:04:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B78EE1946A4F for ; Tue, 9 Aug 2022 00:04:50 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A87D01121315; Tue, 9 Aug 2022 00:04:50 +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 A3CF91121314 for ; Tue, 9 Aug 2022 00:04:50 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 87954802D2C for ; Tue, 9 Aug 2022 00:04:50 +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-463-SHrt679gMqSvETxfTHyUIQ-1; Mon, 08 Aug 2022 20:04:48 -0400 X-MC-Unique: SHrt679gMqSvETxfTHyUIQ-1 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 278NweGD020677; Tue, 9 Aug 2022 00:04:30 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 3hsgut539w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:30 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 278M0hLj038089; Tue, 9 Aug 2022 00:04:29 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2174.outbound.protection.outlook.com [104.47.55.174]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3hu0n32vhn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:29 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SN6PR10MB2590.namprd10.prod.outlook.com (2603:10b6:805:45::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Tue, 9 Aug 2022 00:04:27 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50%6]) with mapi id 15.20.5504.020; Tue, 9 Aug 2022 00:04:27 +0000 From: Mike Christie To: bvanassche@acm.org, linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, linux-nvme@lists.infradead.org, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Date: Mon, 8 Aug 2022 19:04:03 -0500 Message-Id: <20220809000419.10674-5-michael.christie@oracle.com> In-Reply-To: <20220809000419.10674-1-michael.christie@oracle.com> References: <20220809000419.10674-1-michael.christie@oracle.com> X-ClientProxiedBy: CH2PR05CA0069.namprd05.prod.outlook.com (2603:10b6:610:38::46) 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: 2b553e5a-1671-403c-3277-08da799ab9c8 X-MS-TrafficTypeDiagnostic: SN6PR10MB2590:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: qBeZ1/C0AVFv2b1X7vO15Wqx7Oi9ABTIEU499SYZkF3F+ssDMfvboFspgfSUppqA/mvq/O15MZvnFtVtHcNHx1AjZxqUyM8mfgj5fzYuC+XO/0xX6uE5oo5b3xcnkraC/OBphkpzHrUIp0G8/wKjSPx72niunTKLOl9P6ZGIl/7mmi8Zqaa+tBDgML1U42xNGrYEPUXQ4kohjpo0lBLYKT5cGYrd0lkQJMyjGNTZ8LP9v0wcCnnwxlPZj0jod3X/2Fyw3nDh3p4Z7VsucN3zfvdkkUtIPraAmpjxaHd0ntITezhHaOwKkreSeERTOvF/GprJ0Gd8wJ15h7ZtToB1xkDRocjBosPbD3I+DpEm59L1MWYyxYWSg7M+2eGm0cJl+YJYkeNePiH+B7SDtTx1vzO7ezhljiGKDpWoo7vqBjuo+oyfRULK4JCy6RGJmlaPpw2GZhnZPmgSut7MuoDSa0q5lk1twbpqOOI+eGdFW+RmG1oSTyhBVa+S5N8Ca21ozX4iPUWHpm63PwvkR4+9fgeAmIcTF4qC7d6slAFVNq7v+maJ3zeEuQ+qu1thu3YQuBnSUvfgslxlZOUMQShrnhIwbIFlY4vkk1fexDCTdeQzoMeEdU4zvs8/Xcw+nouDh93Mj4rqGeavO7XlsHKTo/z10v9krt7BPQ1DHc4KzRZovxI8WD47kQuvM90O1I+11Kxn4APY8x4j7hGZyC5smKv2jGcVBFhHenadk98niPFmE428mUBGqbql6h4serGOuD5cG4e6Mpb3B/c2ufP6jZ/iYxIRZKfpeu3fUgGD9Lw= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(346002)(396003)(39860400002)(366004)(136003)(376002)(2906002)(83380400001)(6512007)(26005)(6506007)(186003)(1076003)(2616005)(36756003)(107886003)(38100700002)(86362001)(921005)(66476007)(6486002)(316002)(4326008)(6666004)(8936002)(66556008)(66946007)(8676002)(478600001)(5660300002)(41300700001); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: q8DYItR18LfX+rGG23l5lC3T270xZy3KHo6C3GJ4GV8pP6AegXahAli8wk9DE1BQWFqoAU8rvb+Ylr+WxCX/ZD0fQMc56cpnzf83+tY0jRTUBUEKnJBePaSE1KLPC5FeTdGLT6Jwnwb3w/hWgNajAp/4I3TsP3n2avpi8R3IWOX0csmUU69njiY1h8J3WWLwakoSk/OEjYf568T95fCQSxUjQoucwroHazlvxaKvhldlAg02SmSRr8uIeazm2eNJk2HJN4SmhJC8Zvr+36IwKajo5N9oDo9D+6ImIjb7B6754S0JkTd3EC0Jn5/Ep6XxURhhz+RqnH7w7sAuLp+z4PBUfd+YoYLOJxOmprIq5C0VvbZHHQDpS7i8zUSchZIxosymGajeA3sqDor2dRaO7uTEP1w9yW+QS1G1r8KrMuV8E85tWw0iUTLu9LlYaLS6Jv/0r/TtqnUif2rD1NzxQwYWDxXZpvmoi6qkcoUb8/IRsXQNkGpB8VaIRVzEzCpKKMPBVS5W56o4PbItbxH2xC+bSatjqYbwBYNSNuCn+11XEXlKAYrAU4wizHBi3M2PGHfahphT+L0FxwcYrMbls2fViluqRHMUtCgrMpnwIImsvBD7cV+oMnvhIT2lXGwGVCxQMB6As4qRCAvHNr4gF0uDtOfGRZwGxQEIFU/buNT1AWOSvf8fpsKGbFQygOfN8c55snxdlxg8B3GgHXv69E0jjeSsFiFfnGczV7Tu/FDT9jQ+RBNfPHMY/7cQy/FNP1AHH/BZZXyr7mPNOUDpdsTpuEIwPORnouU82+GrJkHlBuvqjmJrd2wiFoWsiuGFX9SAdQ9ETQL2Zl5cm9RVcsAoe4Ydd+GLrEunwbslHpDJm1KnFKKMygdQCECkuq6TJqO6l7xfIbjdzUfZhYdSoMgsHB+1e24uTzdg02kFf7gQ9SJmrQOp8QEHExcm/UhY+8GQ2LLZa/ulBG9m6Ipntgjl8tpwPnRuHD+ZDRBqZisYnJDsFE+JKbNlQuyIqLPZ9q3dvng2/cxkUocnNYRvHXU3ls1qEDpP6vIa4Jgso4dCNcPbUX7NS9msXENwNBqiu0MLnfg1leQ8UzwKBsYiaWaNQ5LVnKwfeflq+u65FZHaybEI/LXT80uL1iRywYqohGsRMImVv7Eh0acGGivQWMnyj7SLjSE/DTJgo2f+nyglWF1zYTH7EWy05v/xSHQ+/Mxu/3h8Xwfdvo/lwtfdtmRepmgJb7HPT2vHnsDtonlhukTAYpKVpqd0iPXc0e2xkRZPiOGOvEbmjymXB5fEAlIHaSzN2OtBEBORfghaZd0LRoL0Ari1gbkcAx6eyKCLtS0BIydyUEV6N0QpIGFI2tbhazYmJZOQP5pWJdwlFcBJZpslUOyhEKgh7bhSWBAJSj7hWKQS07SbbVF6C+feo6kpg1+UbgSZ+v9ZD0OVybSGz/uN/MRggaoi+elvwdH183oEPfJZ37QxuJTA3+4TnpihltTxnDp4d6zYuMqNHnllRcz9JkLlBjklA9I4TEMLvG1AfwPnx+Uptblm66RyCwpF3+Yc7le76nGDCqsAPi2ElberLivRAf6TKWssX2qi8TaaOnB6rZFdb87pLCfINA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2b553e5a-1671-403c-3277-08da799ab9c8 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2022 00:04:27.6269 (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: 9agbnp4WCGuGJMDswSCeErMl0hu/WUKaJ11I2+7E10yMaEoIeg9ydZD2Dy+betCwAssikz6sZQbuLZCheLcyRhWm/Y4ofSXtXlKG2vKjqmA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB2590 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-08_14,2022-08-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 suspectscore=0 adultscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2208080105 X-Proofpoint-ORIG-GUID: PhKwCM5YkdKfu68vMR_CzI-sVOpHy0x2 X-Proofpoint-GUID: PhKwCM5YkdKfu68vMR_CzI-sVOpHy0x2 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Subject: [dm-devel] [PATCH v2 04/20] 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.84 on 10.11.54.1 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 88ce1464527c..f1d4d0568075 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1683,6 +1683,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, + u32 keys_len) +{ + int result, i, data_offset, num_copy_keys; + int data_len = keys_len + 8; + u8 *data; + + data = kzalloc(data_len, GFP_KERNEL); + if (!data) + return -ENOMEM; + + result = sd_pr_in_command(bdev, READ_KEYS, data, data_len); + if (result) + goto free_data; + + keys_info->generation = get_unaligned_be32(&data[0]); + keys_info->num_keys = get_unaligned_be32(&data[4]) / 8; + + data_offset = 8; + num_copy_keys = min(keys_len / 8, keys_info->num_keys); + + for (i = 0; i < num_copy_keys; i++) { + keys_info->keys[i] = get_unaligned_be64(&data[data_offset]); + data_offset += 8; + } + +free_data: + kfree(data); + 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) { @@ -1757,6 +1843,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 c03e35fc382c..0fd6e295375a 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 Tue Aug 9 00:04:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12939205 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A98B0C48BE4 for ; Tue, 9 Aug 2022 00:05:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660003499; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=CFD/SM9suJbEfoSPDPLkZRDMWvMamxh7g6zkaX8harU=; b=hE6Cwmk5iNiYO1sp3ligwTwfxPoTgC9HZ6o7pshndODQVyI0g6FSHcIjviKBTXNL8baeJZ diqrG0LsSnCM3YlQloIetGcImp5vgiYTV+cUQvhU1WytpcP6UKKGZVXV12prtOaecmbOkx z0AcRdkkmb9/VO3FG8RoDLMi3gRLeRM= 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-324-C8TLP39WPJiW7rhCe4aOKQ-1; Mon, 08 Aug 2022 20:04:56 -0400 X-MC-Unique: C8TLP39WPJiW7rhCe4aOKQ-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 D1A8C824061; Tue, 9 Aug 2022 00:04:54 +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 C10092026D64; Tue, 9 Aug 2022 00:04:54 +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 801821946A50; Tue, 9 Aug 2022 00:04:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 067231946A4F for ; Tue, 9 Aug 2022 00:04:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id DFCFB1121319; Tue, 9 Aug 2022 00:04:52 +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 DB3261121315 for ; Tue, 9 Aug 2022 00:04:52 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BF40585A58D for ; Tue, 9 Aug 2022 00:04:52 +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-447-9CswjlHFMvSzff2DZtwCXw-1; Mon, 08 Aug 2022 20:04:50 -0400 X-MC-Unique: 9CswjlHFMvSzff2DZtwCXw-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 278Nwkdr007763; Tue, 9 Aug 2022 00:04:32 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 3hsg69n1de-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:32 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 278M0hoB038112; Tue, 9 Aug 2022 00:04:31 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2174.outbound.protection.outlook.com [104.47.55.174]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3hu0n32vj1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:31 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SN6PR10MB2590.namprd10.prod.outlook.com (2603:10b6:805:45::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Tue, 9 Aug 2022 00:04:29 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50%6]) with mapi id 15.20.5504.020; Tue, 9 Aug 2022 00:04:29 +0000 From: Mike Christie To: bvanassche@acm.org, linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, linux-nvme@lists.infradead.org, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Date: Mon, 8 Aug 2022 19:04:04 -0500 Message-Id: <20220809000419.10674-6-michael.christie@oracle.com> In-Reply-To: <20220809000419.10674-1-michael.christie@oracle.com> References: <20220809000419.10674-1-michael.christie@oracle.com> X-ClientProxiedBy: CH2PR05CA0044.namprd05.prod.outlook.com (2603:10b6:610:38::21) 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: 4e9dbac0-1d8f-49ff-4af3-08da799abaa8 X-MS-TrafficTypeDiagnostic: SN6PR10MB2590:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: B5G5EfQlhiqwsnpOkUCsIdSsm4LRB2zQsBrAFHJmyZsxQIVtdgmvm05aTdk3ndXwvIrnfWkiD2lHI3bkXg0UWivAXHqZ+wq7VCrpu+ctjrGoAYhWxCQ+Y8wsStT3WRZzZfTMDR79467syqSqYO5k2gNvzKCLlUOHrakStLmrXrdztCPSi2oTW/LjW/Ow6BbdAU+ykk8/Th1wiRnX/96cHzKSKF40ul39m/OKG+1M7QtS/QN9+3mGSgPpmniyxP/gowmyL6cQEyJMTRKTnHVA5mFS+6K3up+rFHG9WvzR/2ueGa+yKvadlb7HCR8JkMSRUBHU18VIygJLvP9xaR8ZKvTWPVzQJDqj2Q5toG70Cn3wBZc3Ip3Pf6ERJ5mDzAHoIm0oEjGwugc5g0f/kJDVQMiv49NkRPVMLkYxloP5TOm0zMuCBDtkfF9n3LtDyU72dsoYdGYIL/WWX7Pthw66fIqQCC/b3S65WPXTHVCUxEspJqLtgiy869vj0kdLIo6NynifZjyAldz24iCfsdQOl6SEeoxfsmiIXaCdILq9IYQ83O39O83ICLvIgfmN5mn+NEy1aFz95SNAy/F1osFELDmhNnDIvHrHZuTBA8sWSfjgosQb2OOexRbAPPdmvBr+VsTWEplsuzYLGwNFMyZEM1apE4gL4OWmB+5Akuaoo2gUDeuCyt196NFJZyt5xOtL0rhGf6VoTUZu6ynW/NeWYUFY9oOWOhU/l97kGQCarUj+XVrwuyWVBsyzF5t841Tfl93JaSXeqQlZO+Ocan9qwTsGrOsM72RwkGtmJJYe5gM= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(346002)(396003)(39860400002)(366004)(136003)(376002)(2906002)(83380400001)(6512007)(26005)(6506007)(186003)(1076003)(2616005)(36756003)(107886003)(38100700002)(86362001)(921005)(66476007)(6486002)(316002)(4326008)(6666004)(8936002)(66556008)(66946007)(8676002)(478600001)(5660300002)(41300700001); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6Ao6nZjBfSfXcZYIxJ5ahtNt6qNGYkecdjr0KAZZsLVEPRfM+i5/zXE30/HvXVuRhW48auQECvyBJrUscwDkx45gCSSsw6KSuVPZqdSO+h9vEgJ9MofNWYITfhhA6HomAG/T5NxvuN13nk7Y6c4Ru/8BrTfby04PGe7UQ2RS0NO81zBaS/r5p8FvjO2XrVoYvHtYPVEwd8yCX8rtn1Da71wDmo+pW34PD0qUM6lUIdLtYDmEljZg0YBNHbT8AQ44XOpShpKYdKcgiEZjJqkhJwfYaQwhzcPxD1k+OvKKn7E0AbdNtqfTJZCXsibBViirZ090ZbJz4GEll2v89Q0+KgjdKX1ZF00L6hfCaxiCFUXUs75yE4gXSxDTMO5TKJ0zgqJ61/UN5LD9ZldS0hF0R/q9PHg0VoSqqSY3JyogyxD4nYHt/6WcwMcJ08l1OB1tqzHzFv0a7Jdh7dNSDlhW/HFmWtSJR3sPV9FAyCpsqrWuw+CL7GWIkN8Px1C2ECe7cvEzU62UO8rnKq2byE+g8/gdH9fplq69nAXJTGfE1g8fB764OCXb53lHYNCci8NBgQ6RKmPX1O/qGib2CWeLH92J8JfeG1zH2pboEiDZg4zcmVrb4QXoSlDtbFCjR9H71nJy5KYGYsOwzOqL4rS5toE9wNkRPrr6syiE5LcVXLBOzgiu9wcm15KMzxm0pO167bW+wQ4BLD6bLnSDl4IivPQF+KPnh7Te+NxzE+QwlVDk4RPhiqByRU2pLi1sk217AKUr397lLY5o2c+ZeBG8Bw6agkref0/bt+gLtE94q9PBH9+Jig1yIIoNr/pat4pE6ZDGVJatakWrtVwv+xxZtlnWqNYHoI32HxytSQROttmNTajDGi3PXSNW5CebmfsEL7XGM0BI+yGiuRWJUpQ3AFCDjH1p6sSGSYZZLeOyHsa5Weaxrt26njdyAyc3MqzUbIRWAsa5MS397SBi3XEdPRFcrg+bGr/5YJPw4TKzDNPymIdpYP7dkB+w2NvFy8wHQzj3Y0/KTk3JRjMmbo3Dz4oyKKH+I+hw4wMDmC/+ijhmlvocIVOzmyDq0K4VZw/nhU4CxCiaixCXQSf36yvE7SqpFNOVO/rvG9OohR+89/s/eKijGvDUvzUjigpmsVU1HEMZACt5IAZO0KddH5Io7xsygrXwbgmTnyj6t6W16/ZCq4lZDa2yLxYjfsQ+7Vhlo0YVk5RGvW7h1bG5wDj5gy89Stu68rkYWJ6egFTsvHhNXo/IBiAZJHngJJd2tXxc34dTwrGON3iMEErYAwKsyj5nrYnVoF/UUO4y9phbX+5LIEWY6Z1/sZ1E2gNzjTWMv96wutq9rNkoOY6KuRYJxCel2vDAE8dpaIwGlT8a4FszNS3CTx2D48k7nIAnJiYZwZu4sFCTW8Ka8AnoItwVmDAB8raVEQZFAAtvgoRgM3ntokLdvzKRXvIRxmebkjbVW6vB73ULc0mHUPdKLrj3MbsTsGdjmbuhQzzQKD+9KNe+Gwf2icspXiJuB9e0CPPaFB4GCRY1mZuqzvpXVL4oiaV3/r2JTetcCmSvvzNWxTMhQqMvoLhPZVRXk54e6PdFdRaHkR+TkVpTETNnzjV8Pg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e9dbac0-1d8f-49ff-4af3-08da799abaa8 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2022 00:04:29.1424 (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: P2YyYQgz4U5r+TQrWnjRg+9E96YSGN0p1r/F/PCGd8bELUnojezpl7u48wpuhSTolD++bfvWlSCMVjtWCwcAkpuM+wLFFBdYIU4cN6lUl4w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB2590 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-08_14,2022-08-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 suspectscore=0 adultscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2208080105 X-Proofpoint-ORIG-GUID: gI-7VgP1RgYsg1kSWbDMQiHzUxnkSrLY X-Proofpoint-GUID: gI-7VgP1RgYsg1kSWbDMQiHzUxnkSrLY X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Subject: [dm-devel] [PATCH v2 05/20] 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.78 on 10.11.54.4 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 60549b65c799..1b15295bdf24 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -3313,12 +3313,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, + u32 keys_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_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 Tue Aug 9 00:04:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12939200 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 56ABFC25B0D for ; Tue, 9 Aug 2022 00:04:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660003498; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=DqgxW5Sc8g2+1cwR7bWSVwDVKRSKsYdBjxiRjl0PK38=; b=Ex4Xpc79ozrneSuRC5KKMTaiNWcqaMEajdNqTRhBczmx5n8iRoThwPmY1MUqUVpnlFLf7m /g8gVg9HUn6WUU3uHFQTWDp5tpx/SFiEuFLpFQguuezHvmzSM2k85UbIFIGfW1MGWoLm2a JtW9hfidooGF7G500jNRZKc4Q9/wLCU= 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-564-rkSzhx5kN12vjXgnF9xvJw-1; Mon, 08 Aug 2022 20:04:55 -0400 X-MC-Unique: rkSzhx5kN12vjXgnF9xvJw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A544C1857F08; Tue, 9 Aug 2022 00:04:53 +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 345F6C15BA1; Tue, 9 Aug 2022 00:04:50 +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 CE61A1946A50; Tue, 9 Aug 2022 00:04:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 70F7C1946A4F for ; Tue, 9 Aug 2022 00:04:48 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 61E08404C324; Tue, 9 Aug 2022 00:04:48 +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 5D47540CF8F2 for ; Tue, 9 Aug 2022 00:04: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 6140838005C7 for ; Tue, 9 Aug 2022 00:04:47 +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-624-c0By10RNMm28Hmr-ikONgA-1; Mon, 08 Aug 2022 20:04:45 -0400 X-MC-Unique: c0By10RNMm28Hmr-ikONgA-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 278Nwhfe031116; Tue, 9 Aug 2022 00:04:33 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3hsew155h1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:33 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 278M0h7m011564; Tue, 9 Aug 2022 00:04:33 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3hser26u66-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:33 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SN6PR10MB2590.namprd10.prod.outlook.com (2603:10b6:805:45::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Tue, 9 Aug 2022 00:04:30 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50%6]) with mapi id 15.20.5504.020; Tue, 9 Aug 2022 00:04:30 +0000 From: Mike Christie To: bvanassche@acm.org, linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, linux-nvme@lists.infradead.org, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Date: Mon, 8 Aug 2022 19:04:05 -0500 Message-Id: <20220809000419.10674-7-michael.christie@oracle.com> In-Reply-To: <20220809000419.10674-1-michael.christie@oracle.com> References: <20220809000419.10674-1-michael.christie@oracle.com> X-ClientProxiedBy: CH0PR03CA0107.namprd03.prod.outlook.com (2603:10b6:610:cd::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: 810305f1-e851-4261-2a1f-08da799abb6e X-MS-TrafficTypeDiagnostic: SN6PR10MB2590:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: ZLbQmnE+SciC8CgqiQEjDbMUB+rHVC8D65aseWW1OjttJu5XM32Cl71pCOvoV8szjsr68xjnMOLJJS8j8p8bmYSmdgtB+xT7MU/sPcI40dLV0P9G5slFQaVo9V27CiA8q5jeBqKv1vQFJ3P9WduK0NH0bIOpqpDmGLJV/Qp96Zo3cXEc/QhfbKWyoa2ZF7ti9M9UenwmqLzDjHaM7+maXyRUcPgGufMxlHhmWOv+AAtOloyCFPUrG05TtKljCgcfY7cYV789jYinNWT2w/3+nKlTFT5VqxaMUXP3Id6SKyAXd5UU5plDt6kcufkB57p6YiHnPOSPWHxWDij94016uNKaMffrIdlrhbimUoWAv7Sm+b7jS4EWACiaV6Nt1h06CxO4JpDCrT94inFpV3frrRBns6j/7B/aExaEnTQu8kvm2EGZVLRXpBYRVSjOeH/2pDLDQhFgh/T+sj2fEBy1cPG+JFIzew1bohuJE5M/4xKvpGwrj7hhQsBoCDzd9Y3oeFksgpsMDAeW2znfJYL8lZ84dkc4ZOmKMt5HFtkr1+nOzi/DHWaMyQpDZbSkmYUfVVm29/DBdFmL3Q9mX9q1pkoPitNe1sMFe/6lF4KPdNuTy2BrSo3dYWybdMG2qguAWuTowflpXpfpCkQgVhQtjLw8aVKgjC8alGUsLYzR72/rRn1nLYTHW78W06zKGAhmlVIimzUyVCGyo2yQnK/7J0IYNNE4AhlyiK2xZKOorztGphoe1uczni/xTlrMVuD9o1RagTnn5I0jOooFla95Jzd5HP5lLzvxWZ8iLI6Sl6s= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(346002)(396003)(39860400002)(366004)(136003)(376002)(2906002)(83380400001)(6512007)(26005)(6506007)(186003)(1076003)(2616005)(36756003)(107886003)(38100700002)(86362001)(921005)(66476007)(6486002)(316002)(4326008)(6666004)(8936002)(66556008)(66946007)(8676002)(478600001)(5660300002)(41300700001); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gEK1IA1Sw8w3QZL4hrbyjV/3MFfRYzJC3AbH0b6t/ucV3Tl2ycMz804Qaq+rGmZiFLMCX3lNxTHAyzFl+BEZVTSthVSJQgAtVKIJq9KXk4+7EbhgsSeyiUPCxhk9dSCbG8r91+OlZdYsYMFEIii86j/u/RS/aPWdEmvH9KLV0n/6MGnxj+IMzLkOHLLYMImgEhFdI6KWAjkp6/nLASRlLMcC5xV0p2q1Oevt67djq4iBGHW/k/i5BHBTwxVecPA/BlM87UiizwXJZluowpT/br0R3gA6WTqOHiPeH88nfa2ue09N8s8sCncM2Ez7Nl3mPir22mqUOVBszIAW+TlCr5y3KDxGcbztO5HAier7Q9tIlRha0bQqmUf3RzLtghEsekdUqXa+9Bt6MljwyQEopVhWQC0iNBAnrX6XxHzfIbpjgp8N01TfpLzNsjCakkwTF9736F+Lir0YKw12m1D0s5UOjChzsIHwYuD30N8OMn8VFHHKCnTwDwD8W0Ix7Z5KzokkRENGdYPq/xvmFxgKBvwNwbKxm7vD9Tl38sVpogfJBUCtd+NKdNZ/8cZywLRC5LOTfupQW0d2PAb+dMpQiGJFVPw5vl/98GhyZjQsQFgJ56drFIC2dRLHSejklUss0VXqDbboCNTF7k5aq+T5QftqNYrRcG6jWlhgKhujPyhZrXIATQAV7xl+n9ln8lNjo5fabw+EEKMeD/t5aFUqEQSBDjkb1xWLLAyMvYQvMyY1prQQa7R73doI04Sk2rKIXxQ+9I4x+RNSQp/jTdezURBw3sHaLCFULH/PeIqN39jmd1iBj633iImWSzBTiLUs8ZksdyJ+WwDtAqGN1a/hrf8IuHfamGSbVeYg6NZVQE0I37tMSuFzcKWj/m3t6MAxoGFMIPn50DbS/Y/baUFsoJKH3gMi1eTX+Rg5ijNuL7F0CLbxrlOYyWzzCBS+79Zbu9XgpbN4u+Od3JmLCpHESIIvDgrD49uQcI9qVUg9W8Y7qdUhaGktLbaabreT/2SDj2eo1WAK5nCds2rTnZn5Q8MSjGpNiyS4x2WjJi5ntSKw3DXc1l3CmtXYSxSKaH5iOfT8kKU01GOFdhDRxdwy0gjb1r85w97UCayv5GReBloqViO8zeDyNPOJc95PXs1PYp4TK38AkLrk3RkG7Nos23Z/WzRjafuNalMrD80iLicycOUoiTlNgoh/pRMT01QjJRgD6T9LBZNeDMnGdy2y2OyfuaQTlbLDsx6xiwc780bjwxLE5s0wRcJNyb140Mxs1Y2uu3QFimBc0SyluzPfoINFL/FJXrUANHvVd8gyFc/buE0Mr6CwdcipOkVfQNQ3+rN2/jFOhYBUPZBhqgDvqyLPneIhYXGpKY5DsGbnprAyPVMPt0Yc831KwKDt/8xyuvVLg3de68AVrNamOkUEB9G3tPLoWzkQ/8dLOOypMoBWDMi3L98CNvMsCxwD1MhSTUzztR0nd6OsDQfrZJyZujQ6x59WfIDpVMUIFXr3Jpim8hmE8ddXGs0Z0o9kaV5XBSP0E5JcB4n9FaB0KsiaI/+Vnq6z42GEvVXoL5ihjfreX7f8f78/XvH7B7br4DD3Q6VM2/PFkElCVg7+Qcy6Lw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 810305f1-e851-4261-2a1f-08da799abb6e X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2022 00:04:30.4079 (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: tQtA0//l3RyHrTqfMDsovRRUteaEkLBKQ01EskRJ6bwzibHel9TrYxnY96P7aLkGX9bYrWvleW2Q96oa24Nj7u3hAgZ2rRJqA2XzOzssaKQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB2590 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-08_14,2022-08-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 phishscore=0 mlxscore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2208080105 X-Proofpoint-ORIG-GUID: srLBY5e238ujbu17K3Eqokh7WukeXQEp X-Proofpoint-GUID: srLBY5e238ujbu17K3Eqokh7WukeXQEp 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.1 Subject: [dm-devel] [PATCH v2 06/20] nvme: Fix reservation status related structs 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.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com This fixes the following issues with the reservation status structs: 1. resv10 is bytes 23:10 so it should be 14 bytes. 2. regctl_ds only supports 64 bit host IDs. Signed-off-by: Mike Christie --- include/linux/nvme.h | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/include/linux/nvme.h b/include/linux/nvme.h index ae53d74f3696..ae4a76076420 100644 --- a/include/linux/nvme.h +++ b/include/linux/nvme.h @@ -757,20 +757,37 @@ enum { NVME_LBART_ATTRIB_HIDE = 1 << 1, }; +struct nvme_registered_ctrl { + __le16 cntlid; + __u8 rcsts; + __u8 rsvd3[5]; + __le64 hostid; + __le64 rkey; +}; + +struct nvme_registered_ctrl_ext { + __le16 cntlid; + __u8 rcsts; + __u8 rsvd3[5]; + __le64 rkey; + __u8 hostid[16]; + __u8 rsvd32[32]; +}; + struct nvme_reservation_status { __le32 gen; __u8 rtype; __u8 regctl[2]; __u8 resv5[2]; __u8 ptpls; - __u8 resv10[13]; - struct { - __le16 cntlid; - __u8 rcsts; - __u8 resv3[5]; - __le64 hostid; - __le64 rkey; - } regctl_ds[]; + __u8 resv10[14]; + union { + struct { + __u8 rsvd24[40]; + struct nvme_registered_ctrl_ext regctl_eds[0]; + }; + struct nvme_registered_ctrl regctl_ds[0]; + }; }; enum nvme_async_event_type { From patchwork Tue Aug 9 00:04:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12939206 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A0810C28B2B for ; Tue, 9 Aug 2022 00:05:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660003499; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Nl01s08NRxTqBBZVtTm7HvQY3uHCfnygWHCK4NuLC4E=; b=RLPm6t3WYfFdlwO2zR0girMlwbvL67tIlo3GJ6li4Kwlq08yttP8taDb/qj8ZmjFygn3i0 UVCXB1N1eY3oIxVj2YZM4A/juI2UoJhca36l5o/CyazJcf5PtXsqAnaH1+5ccLmN8Ykt0H R2Nv6mNoORyCXrq0e2ZM5j0Iaq0GEGM= 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-517-PnN9bzJLOnG8y7-dsf6oJw-1; Mon, 08 Aug 2022 20:04:56 -0400 X-MC-Unique: PnN9bzJLOnG8y7-dsf6oJw-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 5B9C0801585; Tue, 9 Aug 2022 00:04:54 +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 49C622026D4C; Tue, 9 Aug 2022 00:04:54 +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 387441946A5A; Tue, 9 Aug 2022 00:04:53 +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 DBE781946A5A for ; Tue, 9 Aug 2022 00:04:51 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C19CB1415128; Tue, 9 Aug 2022 00:04:51 +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 BCF2A1415124 for ; Tue, 9 Aug 2022 00:04:51 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 71CD11C05B02 for ; Tue, 9 Aug 2022 00:04:51 +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-526-QsYjBY4vNFK31ppv3Q9n4g-1; Mon, 08 Aug 2022 20:04:49 -0400 X-MC-Unique: QsYjBY4vNFK31ppv3Q9n4g-1 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 278NweGF020677; Tue, 9 Aug 2022 00:04:34 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3hsgut53a1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:34 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 278M0h7n011564; Tue, 9 Aug 2022 00:04:33 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3hser26u66-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:33 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SN6PR10MB2590.namprd10.prod.outlook.com (2603:10b6:805:45::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Tue, 9 Aug 2022 00:04:31 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50%6]) with mapi id 15.20.5504.020; Tue, 9 Aug 2022 00:04:31 +0000 From: Mike Christie To: bvanassche@acm.org, linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, linux-nvme@lists.infradead.org, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Date: Mon, 8 Aug 2022 19:04:06 -0500 Message-Id: <20220809000419.10674-8-michael.christie@oracle.com> In-Reply-To: <20220809000419.10674-1-michael.christie@oracle.com> References: <20220809000419.10674-1-michael.christie@oracle.com> X-ClientProxiedBy: CH0PR03CA0196.namprd03.prod.outlook.com (2603:10b6:610:e4::21) 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: 7f5e2cf6-692e-4914-946a-08da799abc1e X-MS-TrafficTypeDiagnostic: SN6PR10MB2590:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: FPNjE1eVnZaAauowI7QaXchWa14QA5JrnBwEWBq0R47tO5yvZf5RKcKcseGnbjMZhJDm4/BacuH6M7M9pSrKVg3STJ44GWoRO4Wgw15Nzt34k8z+qtfguJtwEISoJZundwmyE7AntbMTfeEftMFg/ajn5g/pb4zvQjb758bWabhDOHMZeKooDTiX0L5Cw7poW5tBf0iR8avgeEvVVe6QNt2Q1+GHZXj6K5XGLuIzibKU47UVKhM5chEjFXUIsGy2YwZYIifrGCc2JYS0RPTixP5iCRMtzDJfbIMYVfs4TRXzLM9D9/I6PVxCecqNZNqTWG0weDKucmx8YDR/LR3rQ8fyaOYQ12MXfHtTfSiecJniC6HsuYX/8uVz0zUKX9Afxy4auuX9WCjAWUPkjadUN3dlLsmpHt2Y6yNpXFNpLPkW640Sjq+wcDCJv/kc+9FOSm8c+WqwXwXOGjJmYcnjrNrGKWc9siDQHk2U69VKRtdQbhZVmkK6T11feFewjMCqmEOecKNfbdr7TPWSh+11jRAmkLQk0eTEOY2hRI+g4+hmXiC5bmkv+gfI52Xj5oMoT9bBblohg1OFQ1hrjfKTaDOJJ6jSaG4F6N3hUgs1iQhSuirnNM9Hsn0NUNJh+kZXWFjhBX44ZAKRq01DrPj+cwg7qwvg8kPw/xIW3JpwVgw0VEbxY8HP4fdF178fpNdvX8w22Uq2ABkOUHRQC9kDllXxixI6K1R2F/hYkLzQvOw2jDA8TCZ3/dr4bumqM27euBAlInvb+69Q73opvK1O62C/G5zcSA3jEVEvau4tsok= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(346002)(396003)(39860400002)(366004)(136003)(376002)(2906002)(83380400001)(6512007)(26005)(6506007)(186003)(1076003)(2616005)(36756003)(107886003)(38100700002)(86362001)(921005)(66476007)(6486002)(316002)(4326008)(6666004)(8936002)(66556008)(66946007)(8676002)(478600001)(5660300002)(41300700001); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2Bvu9/4+f85oUOCkUtotIBbP2HqYgss2MZR+1vdG6TmvLySZM7+ndqy+DeGL6T9Nmr3WBIhcWhnhASPjH8IzIJ6eTeFwQnDpeIr+YfHFGnsjRpLL2+eDvOKegAoAYr8a5PCgdvvWXwaaGORWfp7H42m8G721ofzX0z7O1NKMAUPCeglHb4mG2CKHs+6e8DMWAVQmulnQdcESGnwZ2VCpB3tZYe9s+wZpqs1zVtn+ymPTVvSC+Gbwc7tvnVQ3JksVXs8uHutL/8XOv26qOnvPyH0+NHuqjkLEV+3M7QtAmyHmnUmMUyGbb6vCWSH1XZi1/dqWv0Say3pwHD89rYvZ6WnGigo7wANis7kkJqyFaKUdAly3VYucuMAG7vMGG8XfoY2Ewr1n4Xw5cDCFwSpfEIBG264vbWPHWvIDJTulos4yd5YfRTKNA4hG9wOCMHeZrn2kzkWmiqtSx4Wlj9SbKN39apBuGafuU2RZG7uw+2foPDymtJG3G7LX5zmHfE17ATnHGnR9Axq4oqLTFAr02dHSgMIk2DpdxIc1CU6qB8Z98EjLT8T3BTxFmBHjKwvGpUzpMixxXQiDga3k5Hf92jvmGZCo3PVlIKpheZKMjJAe9iWXZEfgyMBftdVCvroIAlExH+sfQfAwBBiHIqJSTgl8ihiNBBmQFgjPlah0pXsLKnpzitNxdOUNKnUcLnf7EX+0ntLkIcA3R1ju8vF9jLxZppeS6UNKdb0aZRrK0xoDMfIhILq1iMolzbQsl6r4iAtq66nzdrBHF6gzSYf5ht8zXmCZ/jLEsDwkQnrddaqwl5LOoR1/cmCnBytyESGMp9XWlt4xdJxk8e2VakEQ91TWB/llqbtvXewwOb7Brf54Qr2Ygf7yBwvTPe8w53Cqp+9xokSoUfX3nmgcTpHhWQ0tK7toUMK6/hszjh/AJgEFZxgvWCuo+n1QhjdZ1S25bZ6Q/PBlLD4IzcPj5I/4rfhF2KXvMVC3wzXnzbswh6RlbYRnJGKiIM5ibRcaxYO4aJsamG1Z2yA4ED1eQXlm/TE5bii98a0/2SElRm+uwyRaWYxeGWh0sfnWYnustDYdezUSy5CvEZTouzMvg9iI5f6SOc15Q59iz8a8CuqVHDKG5fPiMPKooc2o79w68RbbD8DW6DXrQr6p6uB0/bQo41C5LT5cBf/e1xKdtGlFoyFGpy/ZSVYLLHYSnmBYCSfs+gbCrXEVZnUQ8LRKdcPsxqPMAQ19bhgB4dIW7XH7HQOUUJ6qkWdVlqBWQYpiQeYLwwSwl8wUN4SdbALfsLLKZap3BRyoxUf2srlR8pxCadeGasjdena3PM23fEZOanInUGnrn53aTEY1kuCWTPvgjZQf+h5hXBnUDxTkrb0+9N+stUNtBsoa6WOUcBNHLIqMXhv59pbt4eM0Uukba3k4bWpAV5kIwEX4hVlpoUsdRfyCVh2wTVr1B78OUVxjJCBh/FH5SxFgVkmr1ct61qHgzbChFzIDiG6aav7BngjFW50k1t/od0IXedlO4zqJ0DP6H7bXJQdLRX73cLaZ2VadUC7rvZesgmC3UMmqrtlnQY97tSEkg37wQ2vR5yzG7pSOpn0YKOnpGqKBm7LHyhhv4Q== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7f5e2cf6-692e-4914-946a-08da799abc1e X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2022 00:04:31.5797 (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: kMvn1ZkNBdm86LzEP/vwfPucUgJhhwP6vlOqQ+8F+PJR9cbclFW+GWLSk98IZpqWgGdYvpuuWI+2w7fN6vOJ5Md0YCywWMVMeHTAs5yFJB8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB2590 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-08_14,2022-08-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 phishscore=0 mlxscore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2208080105 X-Proofpoint-ORIG-GUID: jJcrh_hnpl-ld1fjQ_QgDWpEF08LTI07 X-Proofpoint-GUID: jJcrh_hnpl-ld1fjQ_QgDWpEF08LTI07 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 Subject: [dm-devel] [PATCH v2 07/20] nvme: Don't hardcode the data len for pr commands. 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 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Reservation Report support needs to pass in a variable sized buffer, so this patch has the pr command helpers take a data length argument. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig --- drivers/nvme/host/core.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index af367b22871b..3f223641f321 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2085,7 +2085,7 @@ static char nvme_pr_type(enum pr_type type) } static int nvme_send_ns_head_pr_command(struct block_device *bdev, - struct nvme_command *c, u8 data[16]) + struct nvme_command *c, u8 *data, unsigned int data_len) { struct nvme_ns_head *head = bdev->bd_disk->private_data; int srcu_idx = srcu_read_lock(&head->srcu); @@ -2094,17 +2094,17 @@ static int nvme_send_ns_head_pr_command(struct block_device *bdev, if (ns) { c->common.nsid = cpu_to_le32(ns->head->ns_id); - ret = nvme_submit_sync_cmd(ns->queue, c, data, 16); + ret = nvme_submit_sync_cmd(ns->queue, c, data, data_len); } srcu_read_unlock(&head->srcu, srcu_idx); return ret; } static int nvme_send_ns_pr_command(struct nvme_ns *ns, struct nvme_command *c, - u8 data[16]) + u8 *data, unsigned int data_len) { c->common.nsid = cpu_to_le32(ns->head->ns_id); - return nvme_submit_sync_cmd(ns->queue, c, data, 16); + return nvme_submit_sync_cmd(ns->queue, c, data, data_len); } static int nvme_pr_command(struct block_device *bdev, u32 cdw10, @@ -2121,8 +2121,10 @@ static int nvme_pr_command(struct block_device *bdev, u32 cdw10, if (IS_ENABLED(CONFIG_NVME_MULTIPATH) && bdev->bd_disk->fops == &nvme_ns_head_ops) - return nvme_send_ns_head_pr_command(bdev, &c, data); - return nvme_send_ns_pr_command(bdev->bd_disk->private_data, &c, data); + return nvme_send_ns_head_pr_command(bdev, &c, data, + sizeof(data)); + return nvme_send_ns_pr_command(bdev->bd_disk->private_data, &c, data, + sizeof(data)); } static int nvme_pr_register(struct block_device *bdev, u64 old, From patchwork Tue Aug 9 00:04:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12939280 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 93976C00140 for ; Tue, 9 Aug 2022 00:55:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660006509; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=JmM4Wdj0Oe6RfIN3Re5dL8veuLtlxShzXFFOqEyYdeY=; b=i/SpgLKRzL8laSynMv8YSivkOvz9+nYMn6nVRRJpHEwygGQeXY3yaObsBtkTzALX7fHDT3 deJR2L/SMDdmJYgMjxr5CpnXe+Nh7vnbW46g3JlXvOdbpGSTddoEkzvaOzB8STS5tXz2aJ lPaTZ23vDsqjzAerRl0XohuHpjng4cI= 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-195-COO04EzANZuc3FjC9R7sjg-1; Mon, 08 Aug 2022 20:55:06 -0400 X-MC-Unique: COO04EzANZuc3FjC9R7sjg-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 362F71824603; Tue, 9 Aug 2022 00:55:04 +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 D807B2166B26; Tue, 9 Aug 2022 00:55:03 +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 ABBE51946A50; Tue, 9 Aug 2022 00:55:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D1D2C1946A4F for ; Tue, 9 Aug 2022 00:55:01 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B69A51121315; Tue, 9 Aug 2022 00:55:01 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B1B2F1121314 for ; Tue, 9 Aug 2022 00:55:01 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 91AB08037B5 for ; Tue, 9 Aug 2022 00:55:01 +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-18-Obye74lnMUyh7H0c1shzUg-1; Mon, 08 Aug 2022 20:54:59 -0400 X-MC-Unique: Obye74lnMUyh7H0c1shzUg-1 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 278NweGG020677; Tue, 9 Aug 2022 00:04:37 GMT Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3hsgut53a4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:36 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 278M0h90013949; Tue, 9 Aug 2022 00:04:35 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3hser8emfh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:35 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SN6PR10MB2590.namprd10.prod.outlook.com (2603:10b6:805:45::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Tue, 9 Aug 2022 00:04:33 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50%6]) with mapi id 15.20.5504.020; Tue, 9 Aug 2022 00:04:33 +0000 From: Mike Christie To: bvanassche@acm.org, linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, linux-nvme@lists.infradead.org, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Date: Mon, 8 Aug 2022 19:04:07 -0500 Message-Id: <20220809000419.10674-9-michael.christie@oracle.com> In-Reply-To: <20220809000419.10674-1-michael.christie@oracle.com> References: <20220809000419.10674-1-michael.christie@oracle.com> X-ClientProxiedBy: CH0PR03CA0187.namprd03.prod.outlook.com (2603:10b6:610:e4::12) 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: d056eec4-709b-45c3-a8c4-08da799abd3c X-MS-TrafficTypeDiagnostic: SN6PR10MB2590:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: 6gK8004ju5ayGXYBsD9z74FRAKm2tYkS2cCC1KEzTn/CkBJ6p7vn9oC77hOEvQ8QgV1H2rzSN8dsuffqn3sHQc1n+RpJlPBRUnmzfFnYknxrDX0p3yW1qeE1S1Njf7is+98yKCzxqLCGQMLuuXMbilhDzy2hF882/LBdKCU3budcLR/dPmdCDXOX6VGJKHB4AyC5bZx4n9VLJ2uMNeh2RPPzFMm67LmwLJJOaigL0buKamImKrM9S7bCTKTuhlurS0NntNRfVRjs4pwuGwa+unmHfnfWxPs6O/gjntqHE2YYfJp8KOhEqPJ6NZR72b8RtuNm/RZQJeGa/WwuV1yLRmNr6rUIsuqxSw2LN5AWLFmhS/j/C0bImSSiNANdhiKAvgBzZAdgr46a0+5vbZh3ryR12pJTKGDVUjLPMgUwe1Tt4wSuAljS7qWgbyBTC2swPbLdDYBmL0SbPhlLfRCMDL1fcsc8/oTXYxSGVG7gt+GkL/gR5cmYlwFcAcxPWlXEdnOo6tAO4GOR3CCzQeG8Xhq051DTgTsOQRBpjFKFkI/z3QEOLZhFeXj1J9iBEkpln4PwfaHRWR6on+o8ji/oCnLXf+oBSMDZ/AKNr2oT1Pz5JgFa7wD6mwS81kxZOHT9iBCFL+8mal681cKHtYPgiyeZlHeQX4tqirqyIF5IXCKQOjWJN/h5gmWxW700M55lxb9ZtCwBmpza4mlaUQA+WaUQGSfGaz26gIxYoH55yPTfuTNe4sGBiHtF/nL98Yf89tuznagcArKI+MUJ3AfaZadVze6UTjWSHyw41m5Jlzc= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(346002)(396003)(39860400002)(366004)(136003)(376002)(2906002)(83380400001)(6512007)(26005)(6506007)(186003)(1076003)(2616005)(36756003)(107886003)(38100700002)(86362001)(921005)(66476007)(6486002)(316002)(4326008)(6666004)(8936002)(66556008)(66946007)(8676002)(478600001)(5660300002)(41300700001); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Votud9S0PXyelVsKXD4y4LZ7XV1DONTI58JrlOC+/mxEkHpiK5hSZAmhBlDjHpw/O6+nzFhAXkwpAiH4ERlkQgAClrjDTsgVhpmphr8cdhXZhImT4zVykb2TZzG1jVp5yeLfJgQQtAm9nFtu91Mq4WCJ3JteRCxl5WarxvNTdO3Qvet0rMLzZqOG5jYaHBiB4F3hdvcSiWd+9Nr1BO7EyAL4yGfBq5+SaRWUbMgFoMpp4mp8rIRtfCVyjhnKefYsjJfxgicO/R2CkXWcXvZmENRhmSsl9gNflpfF4pscuBzkRha+NTJMtBnGudBI9ZuxaN9orzNHgo7uOrL/XWM33m9XyzRW9tiSq0lvuQ8uYx7YDRBn7qKTUZJozwpbcWj/RhlT4J+YAazNwM25Srb1R0K+kbpVTcKN61fHgnta9D/QAHWAOkirNiOnBEmfxCeB3vc3mrYAvy6JUFHwrd2vmNj4FmedacX0yZs5ax++/hMhNLWsJK4cvi3m+dS6zSg5FlsctS/T8J1GFhbinfLjeIqH7uIp18bzEyz9RDEbm3SpzT+8EGoiEiJB6vbvqV1qBduJGVFoR85P/935Ox64a5UHGvF7wj2rV9EUOipI1z67cN8jQupBVOzfP8IoGHHcresFPG3NaFR9fKYW2tKoJgqgG2rsc0+sheBxzJx4yFWSObcvHR6Jg4JiBlmPKGfsGZRQXPLpVV29POG0o9NgfyIHj25+cRVodP46OlxZ86mOQAU3YXGNVLRNzs2XSqunnT+re2bT+Q313xgUqFIWDUzHhkNFSOAfLnjddi4cMb/i3vdkSQN88TJL2e4QHxZoorpg/iA0LpJJ1ZA0JG2c9n0DyV0wJH3Pei8nKEHORcyOG6+JOaOO0lhZgyN/y+uhsq7r8Rhq0yqqQ68LGqSHe4M0q727u5OZu6Qs2LkDdGHtjq1y8x1lN70BJsuMTD25JJQj/2AVMVzkFVEBd1+EqOggkJrfSueZ9Tl24N4mG1LA9qWrpyYeG8NWLa9qZoDllb9tIqr1FDX7X5X2WVQvxrz2pYxzrxLx4ci1ti2FnEX1lQxnJepFB94Ef33HhwTFqoTTeQIZ7Vkz5XuQKEEpn5I9r+P4kJBbJo7ayUTDamE0M1WRE93WXb+x3KMRe+Ed3Xf8Tyk0IQcz+7Q+5Z0BLoros6jUPI/nxVScA+56ZliAAFi/afNINVGTIHQoUTaFsxXRY9xGEgq/s/C86j0vLoP9WTtmupDSgm8ckvPdXJqVVhAddElfERII92sTbGCxwPUeVWmwd5GjEoy+i3SBNBigOx0J/fyFoXQx1K7tPvhruf2nnqodHrxioU0+yv4GcTdfT7yRz9Q0K6CvF569Zm6yt41OmA7XA+vZ48ivxnLy9dkjvLUG7yf5aXF7kvwPqwutro85Ejh8ZEPMeIGVuy8T7jQ1Kn/fW/xFsPRjYMZouFs59dPtXxS6FozK3UaOOIl72kpEUAHflsEJrtEBvewRyucfUwuI9jzBWqfXcUvfKKqy0cp2465YobyRkabjkKG6CatYklohA6vVzeko53UhEhFYMwjyMPMu2BPHM1aRQWD/UqJ5LY/GCmKMVXmIWvVfWoIddzh0qtRvegI6LA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d056eec4-709b-45c3-a8c4-08da799abd3c X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2022 00:04:33.5015 (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: +hTokK0iXqj83/0h83VxSnTTY7GClIqGHV7X2PXB7CInEaDSRmIXeuXGTReuGixGqxbjstvO+wq8BJFkUzRmTTsdZZKTdzd2TANnxO0Ga6M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB2590 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-08_14,2022-08-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 suspectscore=0 adultscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2208080105 X-Proofpoint-ORIG-GUID: GYO9T0WwwwTr_637bGbSW-W4N6RMW1Yd X-Proofpoint-GUID: GYO9T0WwwwTr_637bGbSW-W4N6RMW1Yd X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Subject: [dm-devel] [PATCH v2 08/20] nvme: Add helper to convert to a pr_ops PR type 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 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com This adds a helper to go from the NVMe spec PR type value to the block layer pr_type, so for Reservation Report support we can convert from its value. Signed-off-by: Mike Christie --- drivers/nvme/host/core.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 3f223641f321..0dc768ae0c16 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2064,6 +2064,26 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_ns_info *info) } } +static enum pr_type block_pr_type(u8 nvme_type) +{ + switch (nvme_type) { + case 1: + return PR_WRITE_EXCLUSIVE; + case 2: + return PR_EXCLUSIVE_ACCESS; + case 3: + return PR_WRITE_EXCLUSIVE_REG_ONLY; + case 4: + return PR_EXCLUSIVE_ACCESS_REG_ONLY; + case 5: + return PR_WRITE_EXCLUSIVE_ALL_REGS; + case 6: + return PR_EXCLUSIVE_ACCESS_ALL_REGS; + default: + return 0; + } +} + static char nvme_pr_type(enum pr_type type) { switch (type) { From patchwork Tue Aug 9 00:04:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12939212 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 96CDBC00140 for ; Tue, 9 Aug 2022 00:06:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660003591; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=I3Vpl9YXfXlh08C+Tkt0//GvcTtad6WT+TpYG0DXZQo=; b=C9Yr4Ngg9XzW8ndltCmnJNo8OtiIrRHAj9bMacSbBXCfLkGG/Yr/OcIVTxIztEmyUKua/6 YFVKWdVnMeyeVRq0V+vxrh3E7CzG96f8M9PS1OxL1dqSjMbkuhC3m8R9fja1tQiaMlWB9q aTWG0/SsxAqkm4E858ZgFlIskosRI9M= 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-59-Ec8E9lF2PwuHDs9oLnvK0g-1; Mon, 08 Aug 2022 20:06:28 -0400 X-MC-Unique: Ec8E9lF2PwuHDs9oLnvK0g-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 3E029380391F; Tue, 9 Aug 2022 00:06:25 +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 288479459C; Tue, 9 Aug 2022 00:06:25 +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 4C5361930E1F; Tue, 9 Aug 2022 00:06:11 +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 7D1461931A6B for ; Tue, 9 Aug 2022 00:06:10 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 599502166B2A; Tue, 9 Aug 2022 00:06:10 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5532A2166B29 for ; Tue, 9 Aug 2022 00:06: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 351CF8039A5 for ; Tue, 9 Aug 2022 00:06: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-573-JUXGkzBIO_2pFgFxsBWmLA-1; Mon, 08 Aug 2022 20:06:08 -0400 X-MC-Unique: JUXGkzBIO_2pFgFxsBWmLA-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 278NxYXJ000317; Tue, 9 Aug 2022 00:04:38 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 3hsew155h6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:38 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 278M0i97013162; Tue, 9 Aug 2022 00:04:36 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3hu0q2b9kk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:36 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SN6PR10MB2590.namprd10.prod.outlook.com (2603:10b6:805:45::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Tue, 9 Aug 2022 00:04:35 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50%6]) with mapi id 15.20.5504.020; Tue, 9 Aug 2022 00:04:35 +0000 From: Mike Christie To: bvanassche@acm.org, linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, linux-nvme@lists.infradead.org, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Date: Mon, 8 Aug 2022 19:04:08 -0500 Message-Id: <20220809000419.10674-10-michael.christie@oracle.com> In-Reply-To: <20220809000419.10674-1-michael.christie@oracle.com> References: <20220809000419.10674-1-michael.christie@oracle.com> X-ClientProxiedBy: CH0PR03CA0209.namprd03.prod.outlook.com (2603:10b6:610:e4::34) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b1af35c0-77a4-44ec-d3a2-08da799abe2f X-MS-TrafficTypeDiagnostic: SN6PR10MB2590:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: bmRw3ED0LiOs5/vbwSR+TtTDg7QusfcJLka1fUrZjQwZg1vmppFq8pVILCBlVvO2GH7pD0rqJDSPyfvazIl5ZGJKOsT8BemjyN/rW2FogyaCBmFT5i2GUAy3/cyPRJAnHAi3K6B+9JwCoBwfDVeet7CRjSnkfBMQZHOc8cOs8DcYgSy3aoDXPQ1zZuw2wIhXqdwGfC4VJ58877Gw5L1JKpVzhAWbz8PFl2bXK6hv90MMNQoEIoJSpQ8QZFVXISYhdSrhbmf/kcA9c+Wn9HeTnLMfieieQkqReO+jdg7u/clq7OrGoP6WPXn0aSkGxQ3HgihfSDzyiCNJQisuc/ilBSLf9qdEWJu//HJZAqWMPjjgZOrdnYe0D7WtHJWEPzTazb/sNjeVuOoII2co2k9Lc4Srvv5y3Zrlqb+Bm3BJJ9bhgCcBAe/9cMo6J5n4aNa1YZfu6kc+2VwepISWpLY3Ct8SxoUOv26/5oT9DXBhvi2HSdKoi3ruL/gnqR5oKia4D0SrDpTjW+Y5ucmhNPin+H4v4YeSPCaQ6uII6yOCKwx19JKxr2SxFl3GuX7IIwEROX+Jv47z/5dTSMsmLWQP3WePC9kg10nRGQBHWFB3YtrsV5jansqL2T2Vyl3dXZurPMu1zPPlgAe8eTF4SU3CDclPZr/9A6j244QzLfi6aZUMyEPC0GLhH/AOxJHkukaZHaxdHtqIhBSwGqHhXHP2FnpTU9LxHU76JgmEqFPih6eCUZbVdvxivxoKAp+Jk8+dE4AMzw0Sb3fsCyAfAobLmq3FTiSbGuf7umnS9SDylWE= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(346002)(396003)(39860400002)(366004)(136003)(376002)(2906002)(83380400001)(6512007)(26005)(6506007)(186003)(1076003)(2616005)(36756003)(107886003)(38100700002)(86362001)(921005)(66476007)(6486002)(316002)(4326008)(6666004)(8936002)(66556008)(66946007)(8676002)(478600001)(5660300002)(41300700001); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 15Oj6XpeIhuRej44OkZxD3bGjMYvBxHiYm19ukKht/oIDRxVqxx7W9h2Wx5YLfj1OISVrlnxOPNnN2oIcOH4Ir9BvA0krI0IJvAF6hwGkcxc2rurjN6sH0CPuppoAbL5FGmc3GZivIdxbwqfRUu4zSAedtSYfdrtW0xvgYF5HMDTwlWLNoNwYlyhDrLMH6bOFlii2LlgOR2QNlXW8mAMHDcfz9ViL7gYa68st7KmqRB7QmaKTCxChN7c0LMpx3VKynh4glx0vxqsC5jr27oM8MtPWmyiVZp3WzuX1TxnM16aKFBtnpeDeIYEUbgMRPK9YOPu92TihI0SJ0Zv4MC30R736CeYIkDHJ59DyMGuW7jNZPluCmQaD72Wtoh2Qo4sgBJWy0XqHJ/psxHnp91oWu7F4Yo5/1vKkqVewiqfldBw5CSP7juEoSIwxRLj2y1TCddajehaw/MwADwL2roJVL1BdA/AyCB/Nwy4SXtdG+eMcZXn3u8UyRWYINfLV654rGA5XMvn1nKBiUM9uvipKys4fSTl50RzgT/BQTfMUfpgRwB7m+rGxl7NwnMS1IQmSmisAHh51ScZikrgcDFu7fsqIYCSE8EyhfmpZyJ60qv8pnGU7wwQDVbmZutd6MbMyrRf61yrx8K3GGx4vLjY9Mgsg+lDGnwwAkIzABgYUAk4EhY79QPCB4kRIPZVpjHtMsAudlitwi1txE3BEGV3r3JW12yWFsE+S4iLruG6W5lnrgokxR+NybOjdCxuNvWj9GTBs8xSJwPn62+omjB+AtxvCGTlQBF+xkAduyiE3l3UoW/ZN/WJYNtIaPPXWQDTEMlhUI/zH18bQWs29qRYp1HwpQa8D2qGtOH0To2gTT4kRzEOUzMhuJX3gmHGKQkgghbp9GwDI7fPkYBjZcYGF+aAUZ0+E4G6Fnfq0MArR26bP4UqguvYhChvl6KZTrONczeQ1HJPUx1wPkL7G6wBfCniwgDfcEJk+M6O8eQSql9HKuDb4rkTTMZwmZRUJHpNnKXKos6xATOIuXue2JftJXp+NDudl/opxCho+m7qYnbsFnsYU7B/yUtp5z0MP1cBcwQovqq58g3PIFhUIO915IO+HFNhT85IQ+V49OXAt1XV0yn6avJ2JovtUNPBfnl/5li3Gs/0sIVnS8J2MC2wNL89sHFwPVboYqnNs+XWDoO5k6RfFcljpJZz6CiGopW3B+ER31xp24+X84CZsSDb5vTEGIYw5c/lLW7yz1H7nbO5HpQDQzxVZIzZOpSXHZ0PoohpR9NzLvRk42jrRrsrpjbxX+Ry4M7RPs2pbj6A8gkfyLgkWuhjYct1wJuDwNAJmN+hmvAhHKoI+/M3KvHbNKL/JvybUpJWBD5aeFi0f9kFG5UyKEgdh3++9DMvhz4MvcWSHzXGcJk7zJsdRC+ZGNxpzl/YAonlsdH1A1eLdswBzLuFAkPMZp9XFxpbGiWN06BgEY4DA1xA1JjFLtYRlr3AAamzyKcZatHji/vrJ5xtx/cNJ/uCAShKLqpcSwK8vkK2RCBM3CTZRdxBoT6bO57RWTFNlOIwOTjaesmgE/DyOFtGTiEaUQ6J7MX5VOPyfBy2bpgAMyQ4TC8QvkNEAg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b1af35c0-77a4-44ec-d3a2-08da799abe2f X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2022 00:04:35.0326 (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: DXSmkbqGc8ANh4seI4wfza6ZEcOSrVaL/WYImjnx6D72647yYzkR/FlEFQk1leVqTyI4FPxuEiAsI0loV1xHIEjY/+FrjOXlW3nOFdG+MqY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB2590 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-08_14,2022-08-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 adultscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2208080105 X-Proofpoint-ORIG-GUID: h9vD1FbRq9vWMjTaCa3vo4Tnu9fEzJ1Q X-Proofpoint-GUID: h9vD1FbRq9vWMjTaCa3vo4Tnu9fEzJ1Q 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 Subject: [dm-devel] [PATCH v2 09/20] nvme: Add helper to execute Reservation Report 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 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com This adds a helper to execute the Reservation Report. The next patches will then convert call it and convert that info to read_keys and read_reservation. Signed-off-by: Mike Christie --- drivers/nvme/host/core.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 0dc768ae0c16..6b22a5dec122 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2196,6 +2196,33 @@ static int nvme_pr_release(struct block_device *bdev, u64 key, enum pr_type type return nvme_pr_command(bdev, cdw10, key, 0, nvme_cmd_resv_release); } +static int nvme_pr_resv_report(struct block_device *bdev, u8 *data, + u32 data_len, bool *eds) +{ + struct nvme_command c = { }; + int ret; + + c.common.opcode = nvme_cmd_resv_report; + c.common.cdw10 = cpu_to_le32(nvme_bytes_to_numd(data_len)); + c.common.cdw11 = 1; + *eds = true; + +retry: + if (IS_ENABLED(CONFIG_NVME_MULTIPATH) && + bdev->bd_disk->fops == &nvme_ns_head_ops) + ret = nvme_send_ns_head_pr_command(bdev, &c, data, data_len); + else + ret = nvme_send_ns_pr_command(bdev->bd_disk->private_data, &c, + data, data_len); + if (ret == NVME_SC_HOST_ID_INCONSIST && c.common.cdw11) { + c.common.cdw11 = 0; + *eds = false; + goto retry; + } + + return ret; +} + const struct pr_ops nvme_pr_ops = { .pr_register = nvme_pr_register, .pr_reserve = nvme_pr_reserve, From patchwork Tue Aug 9 00:04:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12939250 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C65D0C3F6B0 for ; Tue, 9 Aug 2022 00:07:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660003626; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=N+4HmivAdTUk3zb0z1MLXUK+hqFeKwe4ZfsBqFiHBs0=; b=iElnF1boi9g8E02QLxhXNOeUkVaa0rYiZVQYzE43w3so1X95nSzs3unkdollp7viO+THE+ x0YzKo9orLMCQ3oQIKso1o7/YrH/UYomtRhz1BC51qEI2iBkoOWI0of/8UsO4pSL4jddhf SdjThywk5kF0q578NY2kx++esBojVEg= 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-562-cR-PTWE4MR2JmnI9YGLBKg-1; Mon, 08 Aug 2022 20:07:03 -0400 X-MC-Unique: cR-PTWE4MR2JmnI9YGLBKg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5A7EA3C0D18E; Tue, 9 Aug 2022 00:07: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 44221C15BA4; Tue, 9 Aug 2022 00:07: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 BB4031946A6A; Tue, 9 Aug 2022 00:07:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B2FD61946A4F for ; Tue, 9 Aug 2022 00:07:00 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A72C1400E88D; Tue, 9 Aug 2022 00:07:00 +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 A283140B42B5 for ; Tue, 9 Aug 2022 00:07:00 +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 85E4F811E84 for ; Tue, 9 Aug 2022 00:07:00 +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-427-rgJVHwr8Mwy_DhZkFTyS3g-1; Mon, 08 Aug 2022 20:06:58 -0400 X-MC-Unique: rgJVHwr8Mwy_DhZkFTyS3g-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 278NwJlH007174; Tue, 9 Aug 2022 00:04:40 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3hsg69n1dr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:40 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 278M0wO8034454; Tue, 9 Aug 2022 00:04:38 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3hser2d9y0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:38 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SN6PR10MB2590.namprd10.prod.outlook.com (2603:10b6:805:45::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Tue, 9 Aug 2022 00:04:37 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50%6]) with mapi id 15.20.5504.020; Tue, 9 Aug 2022 00:04:37 +0000 From: Mike Christie To: bvanassche@acm.org, linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, linux-nvme@lists.infradead.org, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Date: Mon, 8 Aug 2022 19:04:09 -0500 Message-Id: <20220809000419.10674-11-michael.christie@oracle.com> In-Reply-To: <20220809000419.10674-1-michael.christie@oracle.com> References: <20220809000419.10674-1-michael.christie@oracle.com> X-ClientProxiedBy: CH0PR03CA0186.namprd03.prod.outlook.com (2603:10b6:610:e4::11) 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: 0965737e-6a41-4ce0-aa77-08da799abf71 X-MS-TrafficTypeDiagnostic: SN6PR10MB2590:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: iwkhN4zbMM73KCM4GdHdr7afukkWihCTifjCw5jMKCxXFB8bzB2PJlBLbaLLSCzSsUMZKgiZeOnCiKPgexdvJjnhI7qXXa6hX/0CF42Kadpt0dxC74zsjsopkV0ks1Pn7qGBLK+ooECgA2uouUuH7td3PNyEsfvvLJgScYHCgER4bJP8vEtBFumR2DMsiiX+Lg3C33dXPUv2hiDVfcrCFqMBsVdDfepA+Jtd8RpHg3uhkaqBOVTwk70PwIhnWwRYAg9SB/SOpg2PtPt/7IBVsW2jH7A8wM0Ff033uMb1A53AvIYXO/iAMqXGMU5KivQCrgHtdFP6Cr3IxikwMBKL5ISF7PM5w9D6kLy+pF5xErGeFliW3qvTTogOpNkrhEpR48KPygcNw5Yr6yjecmyPS7S0NO48VBm81w0u9DFkDjPfUKjWhFIhwfmLeAD+C3RE63yiNiXaG8nlFv+3bROnykoA2F9Nw7xG0ZsU8lKVUtyCRD8vGo0/CPx8JkYwSWdnkbsTScb4mtZjY+kVN6/b1ODul88NTfYNy4e/YcZtI/Q0d2C9t5knjeD6cTCkHwXATBzvtXOnDqQt+1ROssik361K3vxlY8i8k9KZz9qltXXwjd2hCOaeIiiR98EPggzns1vMVUNLMfOP7c7J0H7exm2c+nlndPK+fn5fmy+/nijkp8sWrOJNy7Ic1W/vdNoLpe9/MRN6gF1uFzt5QQOqwzYLTBGUslH8XuiyWYMEqohlZl3izppErKxbX2/h35Y+eBpssZVJ2RtPrFCdvyhA3nS72XbedkU66nkunxrMcDQ= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(346002)(396003)(39860400002)(366004)(136003)(376002)(2906002)(83380400001)(6512007)(26005)(6506007)(186003)(1076003)(2616005)(36756003)(107886003)(38100700002)(86362001)(921005)(66476007)(6486002)(316002)(4326008)(6666004)(8936002)(66556008)(66946007)(8676002)(478600001)(5660300002)(41300700001); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2Sv41cQSx4TkA1F05e0eLByN4+jCg7vY5eYzJsFZc0PJ94zEiXKEvTTyvHYwoLQYUkjOqJwYmEYv3K7Wopv9ta3BM+qmQ9NBHQa56gMGlybpDlbefOUrqBhmtfPjyiPYOXvMtPRjh4FA7FJ1+I9K4iYw+as6ifMOWD7QXnegrmF9hbDO2YnUCgV5NbDQTxX3eYstNUyRnbcT6jPznrKX5DX7KJEyI/Eee7X9jYnJ7XXMiP4LsJ45TI5UIFK9k16vJQ3lQ8yG4sYFtACbPq9tIfrXzrQh7ZQgDClEpcgF/5201X9CrEuZvqK5RVOahKYWuWTc7fjwvyvugKj9w6N6AP3B/cPdFJb1z01IxzBQMkr5cG9tTKaWtE2x7qEoMh3bWuJXL+lw9347f7QY9eLEhG08xqtymvAL+DYPKr+OcnV4FDFaUKjrW0OOYVlH2Lj0MJUJeo1DE+91dfwWXo3ynGBH1oHExymn/bMI+pCaMdeL6zHBhmN7g6tvHXmYWaCxTf5VUMhpsWZCpv9WjOraFlKQfgm+dAAOuh9/wKfFBhd3zR8v6ymlg7J0tANEqYkWHMkJr8zDH7ylINGkFKnj7YZczdgCQN3PTButBEeGtYhcNsYy8xLLMQMqxPKSsir0jUaZ3luUKp30u0qY9w3+nzLlncAciZyZCNdwdQTS9aKA46czFY8CM+w6tNuB7Ayf4df3Ays4vpCTT990TyNFcvZoekIgeDCda1BTIln3tCT2ayVFfbXvPx66PSUgcpAG87qlSTB3gN4AvVrOkjnTgk8Z/huksBH9gi17NyLuyVprA6KeZxukFnpEN+yxs2G7t6juEzLrlCiDc4+MCVwqNbxFvfIbsIhpUb2Vm7Nu004JLcy6wa4hsURpouWZYuF0RjW8d6h8alNLYq2AHzJzLku/BxcCzMWU4Op8TP0aCXoOna/Wl8TbRL1jJ9bLpVKUOOCEMlLnlMxmfSOKqMrslnpjFbVQdhBkt2czM6bCnR++RBMwpWtnh1tcLHjdCRSO6kdVlrFwCEkVlnCLtsXzAwPXR37CaY0EU+kUuZxEVA++C6YP5V55SWFBjuucjdJh+BkrOfdM24iSk4n/5rsWkk4kksnye179g9EWRNkrE+ARjDQ0aIuy2hSmYKlWh6NlUGHJjcoltfqGBloOWHUBEHt4NqkFS2LTe3daDSYgOdXKgpCVIZtLIsJzhagJ0Icx2kaNgIEuSfMMPpj6aDNVVKGLGRjpr3CdmO73300q1Xlnds/jI1FamdesoL+QWuiI0cICtmBD894wjJYMi6CHGIJNyEHdlg5HiczStoBym+x64mG66VniZthbE29r0s8h9NVzXevXYPAGxWDPTq0Q3+zjYq8oFDqnlYT7TO7uwQvxpL6qS6qc9qHCg2rEQKCxoayloYUDZD7px5LpPb7nLrBUHrg8dBUZXMkxek/atneOUMvTMKjQVFCuYSGTKV8bgDWgbD7N1TB7szVYqeD6iiJi0PFcYeY3XlkvrTxyvIrexzfcZxi/PedEaReL9B/WaZ5ecJdJDouLISA2xlbdpxsS9L4FxrIcS4BlG1NIPZPWsFNLEogsO3CGy21v8NRYURilzzd1NorLdct1xnuR3Q== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0965737e-6a41-4ce0-aa77-08da799abf71 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2022 00:04:37.1730 (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: Zumiu28o+wnRIEOav1QCmuA1P7rbC47Sa8VkqLo6VbQ0YKZmDzdf2mYwtIjpOtWipAndeCKCpUWyoxjCxOBoFjgJTlZSgomNZ1M/e9Zde1E= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB2590 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-08_14,2022-08-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 phishscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2208080105 X-Proofpoint-ORIG-GUID: rXq1RCRo4rKc5f-vg60VMPq0Hx5Y6W63 X-Proofpoint-GUID: rXq1RCRo4rKc5f-vg60VMPq0Hx5Y6W63 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.1 Subject: [dm-devel] [PATCH v2 10/20] nvme: Add pr_ops read_keys support 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.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com This patch adds support for the pr_ops read_keys callout by calling the NVMe Reservation Report helper, then parsing that info to get the controller's registered keys. Because the callout is only used in the kernel where the callers do not know about controller/host IDs, the callout just returns the registered keys which is required by the SCSI PR in READ KEYS command. Signed-off-by: Mike Christie --- drivers/nvme/host/core.c | 45 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 6b22a5dec122..230e5deca391 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2223,12 +2223,57 @@ static int nvme_pr_resv_report(struct block_device *bdev, u8 *data, return ret; } +static int nvme_pr_read_keys(struct block_device *bdev, + struct pr_keys *keys_info, u32 keys_len) +{ + struct nvme_reservation_status *status; + u32 data_len, num_ret_keys; + int ret, i; + bool eds; + u8 *data; + + /* + * Assume we are using 128-bit host IDs and allocate a buffer large + * enough to get enough keys to fill the return keys buffer. + */ + num_ret_keys = keys_len / 8; + data_len = sizeof(*status) + + num_ret_keys * sizeof(struct nvme_registered_ctrl_ext); + data = kzalloc(data_len, GFP_KERNEL); + if (!data) + return -ENOMEM; + + ret = nvme_pr_resv_report(bdev, data, data_len, &eds); + if (ret) + goto free_data; + + status = (struct nvme_reservation_status *)data; + keys_info->generation = le32_to_cpu(status->gen); + keys_info->num_keys = get_unaligned_le16(&status->regctl); + + num_ret_keys = min(num_ret_keys, keys_info->num_keys); + for (i = 0; i < num_ret_keys; i++) { + if (eds) { + keys_info->keys[i] = + le64_to_cpu(status->regctl_eds[i].rkey); + } else { + keys_info->keys[i] = + le64_to_cpu(status->regctl_ds[i].rkey); + } + } + +free_data: + kfree(data); + return ret; +} + const struct pr_ops nvme_pr_ops = { .pr_register = nvme_pr_register, .pr_reserve = nvme_pr_reserve, .pr_release = nvme_pr_release, .pr_preempt = nvme_pr_preempt, .pr_clear = nvme_pr_clear, + .pr_read_keys = nvme_pr_read_keys, }; #ifdef CONFIG_BLK_SED_OPAL From patchwork Tue Aug 9 00:04:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12939279 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B8994C00140 for ; Tue, 9 Aug 2022 00:49:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660006142; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=cD5ply0tRJTf6HVrXNBjXs+jyKHdUKVd+4JI+LhER+o=; b=KoM/lR6OG/VocDglPWYByMcNWmKKCR9mX2dP8ay3FJNRNEgR3Hj+je5WlI1x2m00gOo3FO 8+dY1pxDcFtiw1dWOAX9pKODouAF2UuQxef0yudJpKxL/n3Nnvvz6wdRWol08hshTklBTl tlpJGQ3MslgApsBTvQk4R8yPdSrDA+E= 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-6-ekzJNv9aNtqiRzJHSV2-OQ-1; Mon, 08 Aug 2022 20:48:59 -0400 X-MC-Unique: ekzJNv9aNtqiRzJHSV2-OQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 973AC85A58A; Tue, 9 Aug 2022 00:48:57 +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 3D086400E403; Tue, 9 Aug 2022 00:48:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0DC6A1946A55; Tue, 9 Aug 2022 00:48:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 842CD1946A4F for ; Tue, 9 Aug 2022 00:48:56 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 684F49457F; Tue, 9 Aug 2022 00:48:56 +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 63A6818ECC for ; Tue, 9 Aug 2022 00:48:56 +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 3ED8A1C06901 for ; Tue, 9 Aug 2022 00:48:56 +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-650-8mCZfz0-NMaxbEXUNkAE1Q-1; Mon, 08 Aug 2022 20:48:54 -0400 X-MC-Unique: 8mCZfz0-NMaxbEXUNkAE1Q-1 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 278NweGJ020677; Tue, 9 Aug 2022 00:04:42 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 3hsgut53aa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:41 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 278M0hHn032800; Tue, 9 Aug 2022 00:04:41 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2174.outbound.protection.outlook.com [104.47.55.174]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3hser2cbrd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:40 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SN6PR10MB2590.namprd10.prod.outlook.com (2603:10b6:805:45::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Tue, 9 Aug 2022 00:04:38 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50%6]) with mapi id 15.20.5504.020; Tue, 9 Aug 2022 00:04:38 +0000 From: Mike Christie To: bvanassche@acm.org, linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, linux-nvme@lists.infradead.org, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Date: Mon, 8 Aug 2022 19:04:10 -0500 Message-Id: <20220809000419.10674-12-michael.christie@oracle.com> In-Reply-To: <20220809000419.10674-1-michael.christie@oracle.com> References: <20220809000419.10674-1-michael.christie@oracle.com> X-ClientProxiedBy: CH2PR18CA0044.namprd18.prod.outlook.com (2603:10b6:610:55::24) 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: 4c50eed6-b28f-45d6-7306-08da799ac062 X-MS-TrafficTypeDiagnostic: SN6PR10MB2590:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: cYaXt14XyEP3f879pPAFFtLBsRfRz2bpRQtZ11ny5nTvpLgKYW3aEi2iHVpvWBE4MBh1DGXTX7s+IjaD033dUyQxj0b0UTqnK4eFfOZjqhG8vYLmROd8lKnDvZ+yrzx3JA/iNL1EAcXKdrUUaJRtZbIywyCZQ7D2lKKGD/Be2tivqcSlNlJUoKAKnMttDjKH0d0z+SmDDqLDB33A2dJ3jmJEg7Q0GW6i0JUc0dJJawPodPtBXKc9iQ1rY9hJvOBdxyz2u1PL4UAihU2OrWv7+aCpd0K/48SzfIIdH7SKHdcTcCLU1NpVSayFTGCCk+4pqAaCw8Z+h6sZcylQwr31XDIO7Azl4aqumhjNr2/T16VfR7d/XzpncyvluQrtM1iHoScFjxrgjn8JcIktZzk35OA4mBkEN0o2mCPFRurL6/yBs5f6xq4VYAM2+wkfPL7rPLBWoFDCAqgBXWHNBj6wmMSfy9xvtbwLLALlNH9J1HadPD4n5RjVFhXlNqspovzrbwL4ythPDHYwAsgHRx/GfXx/5VQZcNrEv+2beXpUIiVlXTCjjL+d7xHZFF1jY9yFKJiO+OEcW0CGeeEViJh49IDi//2rPjZ/ocWYk4Vnoj62BRNhdEe8urYq2TUya+vGXFsjlE+VMlml2YSjBxo1lzjhMH1pE8jt0WTmGcoLYPkxlaXPCLxoLR47DbTrpsa07oRYgrmN8WrM9Gv8JBQW4Z0g/BJm0TgXOSnHjC6TvF7ptvcaJyGuPBqXZ9qEgXijgKYnme9R5we8IR3ws0QdyjK7Visgbxvrxnz8Za5aRIA= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(346002)(396003)(39860400002)(366004)(136003)(376002)(2906002)(83380400001)(6512007)(26005)(6506007)(186003)(1076003)(2616005)(36756003)(107886003)(38100700002)(86362001)(921005)(66476007)(6486002)(316002)(4326008)(6666004)(8936002)(66556008)(66946007)(8676002)(478600001)(5660300002)(41300700001); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1c6RnEyEJY+HQJo13NuxrkD4Y+Mia5m7ds0aJSxmaPATYjZQ2oUZVHne0OIP3r4hNO2d68OhCoju5yXbV8sFBgyvbUdrAdtBMtLWTzVXbmXEdXlZJYFlwijJpNiQozr9znfwGvFCaH1mhY+sEVWXhZeSJRtC2C74Lphg1r2tkuX4ItpUf7++yrVc08jYtfpW2CYxgq8Cb6zpVK7CEVYz6a+ZYMKLC/rrCfH2w3XxuLiAP8bzFCaThcghEKymC5L7Jyz3KUbeH1p3RfVUTfEyHibNcmcbECHt8PefIwNQmn+pqhyhsgIuri5R8QFuzbNr78B3DtITnaFfOcm1FjFe2CVG4Q/k2tYJ7dPmadOR3RsKD68+KnNuM2DOmqbnq2/G3MSbZgcUvyvNRtYjRRahxKXFl1z3UFblLFQDpfHAvxNsIsgtSYE/AKe9GM+z/ksVC+7z+jtoV8N1jc/sanFPqEci1KPB6Il3bCDBhsivsYhOyWNb31FaXQEltXUWHd+OgA+/cUF1VavqR3ovzENnJVYmurqSeC7AvdJO2lHA5/DrS7u5Qp9FZbvLEZ7ql6ix2H9y6SkLchirWwuLpSdlgcU+6i38xcEruOPrYCh0gSgSTRW1E6APT12E98+tv/8aZUvoRg/l/APB/cpdJMm70RFL4dVqtex8PKRCDuRVRyjvDp8CXJ5u0rwcDqH0fQcQOQC0YsIgWQEBAyrL/UNElONZvR22zUW5UgxMJEV8ZdIW5yRQbqKd60ugflW5F7niUwAPfsEmHrcqYikKF355Qx2yjCO3ZraUq/8u41zLRM0vnat1K27tOXfOEYHNLh7Sl0NOa7qZrxDvirZAMVeebmVX7Ahj2e0Zm3j+cG6YEe6JiDm2kSO6yeGTG2WV2W2MSVshYy2YbXR2T1xHh6V3ITnqJbCFBbltaqD3RdGKvz7IR33q+wUt1I3Xw78sFyDvo6WyOWYkhS2FcBBi+8L6TGQNwm9skj0q5Gegw1UtaWLDUEj4z80HnUvGWDAJHwmajxjfoUo73NYV5PiFHQGqE3K5NyqyAbpub/2jiNNACTEF9pq7hr0MI9KEWd8FRqw+hnaaKoeV1Vh3MrhhLZtMl33zgC5qrU1vk5hGzJLkJbm641JYNRoOm+zxzeNLQcIe82ctXAwsUHQ+GjTzmZrXwADa1PCwJKvgdzx+mXvnAJtDlKvNezce2t4oxOYP6VNk+MmhMaDAW55KMvMrlyXM1l9yCR7sTF22raLt+1eq+3Bx3znwjCGsFCKMGhIV9IyUMiip9gImTr7JN3BlR2CZyx6xnsEfvT1K+BW+DLIz1fz/7KbHG1FWRWmxCJhn0nPnc133UnsiOIzBzZgGzPhp8WkMkbT47jzp4JTc8qLsWbr07PNkZagu6T1q9diLPMKwAAL+3rC0KABhcyQR+AjSn4Av5nWhi9azD3IET4lIy/fdGEO6MYAceKNZI83irL06yTgTy6CdR7z3yn3C7TSJN+rFvw/b0xRF0rnf8g4Lh67DZpuuZzisxVkFTMAFZHFYJ9opgDI3BJ9cLOHtzIED4aSvk9CeB18wt5zm6Gic7Ns3Ab/QmgEhrCGW4vXW/Jvk3wVrIV+l+uQJNsJYJwpNkg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4c50eed6-b28f-45d6-7306-08da799ac062 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2022 00:04:38.7354 (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: yex6dyQzfFbVS7lOwkdc/7B7kYPoZbl0fwiSU5KPI3EIgjf3y0wnryw1hIRwfoPAsduvJ3FUe8sZvo+iOUO+deyA9x1LCynZU0du+bsTc6M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB2590 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-08_14,2022-08-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2208080105 X-Proofpoint-ORIG-GUID: KSxOCj_gnIkONoC4guM_FB7JPr5LkXGS X-Proofpoint-GUID: KSxOCj_gnIkONoC4guM_FB7JPr5LkXGS X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Subject: [dm-devel] [PATCH v2 11/20] nvme: Add pr_ops read_reservation support 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.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com This patch adds support for the pr_ops read_reservation callout by calling the NVMe Reservation Report helper. It then parses that info to detect if there is a reservation and if there is then convert the returned info to a pr_ops pr_held_reservation struct. Signed-off-by: Mike Christie --- drivers/nvme/host/core.c | 68 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 230e5deca391..5bbc1d84a87e 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2267,6 +2267,73 @@ static int nvme_pr_read_keys(struct block_device *bdev, return ret; } +static int nvme_pr_read_reservation(struct block_device *bdev, + struct pr_held_reservation *resv) +{ + struct nvme_reservation_status tmp_status, *status; + int ret, i, num_regs; + u32 data_len; + bool eds; + u8 *data; + + memset(resv, 0, sizeof(*resv)); + +retry: + /* + * Get the number of registrations so we know how big to allocate + * the response buffer. + */ + ret = nvme_pr_resv_report(bdev, (u8 *)&tmp_status, sizeof(tmp_status), + &eds); + if (ret) + return 0; + + num_regs = get_unaligned_le16(&tmp_status.regctl); + if (!num_regs) { + resv->generation = le32_to_cpu(tmp_status.gen); + return 0; + } + + data_len = sizeof(*status) + + num_regs * sizeof(struct nvme_registered_ctrl_ext); + data = kzalloc(data_len, GFP_KERNEL); + if (!data) + return -ENOMEM; + + ret = nvme_pr_resv_report(bdev, data, data_len, &eds); + if (ret) + goto free_data; + status = (struct nvme_reservation_status *)data; + + if (num_regs != get_unaligned_le16(&status->regctl)) { + kfree(data); + goto retry; + } + + resv->generation = le32_to_cpu(status->gen); + resv->type = block_pr_type(status->rtype); + + for (i = 0; i < num_regs; i++) { + if (eds) { + if (status->regctl_eds[i].rcsts) { + resv->key = + le64_to_cpu(status->regctl_eds[i].rkey); + break; + } + } else { + if (status->regctl_ds[i].rcsts) { + resv->key = + le64_to_cpu(status->regctl_ds[i].rkey); + break; + } + } + } + +free_data: + kfree(data); + return ret; +} + const struct pr_ops nvme_pr_ops = { .pr_register = nvme_pr_register, .pr_reserve = nvme_pr_reserve, @@ -2274,6 +2341,7 @@ const struct pr_ops nvme_pr_ops = { .pr_preempt = nvme_pr_preempt, .pr_clear = nvme_pr_clear, .pr_read_keys = nvme_pr_read_keys, + .pr_read_reservation = nvme_pr_read_reservation, }; #ifdef CONFIG_BLK_SED_OPAL From patchwork Tue Aug 9 00:04:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12939211 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1F5F4C25B0C for ; Tue, 9 Aug 2022 00:06:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660003587; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=jZeDxou6+JCAgGUcz05MgpgPf2UjpauZqxWlDzB59Wg=; b=Lg4TKGPYk/ZFPdwTJ+B1pKqehQQoz6tNEwMxlDoEB30FvH17lGw+jD3X7flc6+OExAU923 n3K4PldX65g0g0C3qDSNHTjWNAJIABgpAFCnKHKgFPXA2tZMv7k84UsaYVsyvEGPKDfOxv MXMtve6w4V+ri5TLHd34wq36eNSBS8k= 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-101-YpxD4lsLOJukkmZBbmTn3w-1; Mon, 08 Aug 2022 20:06:22 -0400 X-MC-Unique: YpxD4lsLOJukkmZBbmTn3w-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 70B2F858F0C; Tue, 9 Aug 2022 00:06:19 +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 5B00C400F36; Tue, 9 Aug 2022 00:06: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 BA8BC1931A48; Tue, 9 Aug 2022 00:06:08 +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 A476B1946A5A for ; Tue, 9 Aug 2022 00:06:06 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 78E87492CA4; Tue, 9 Aug 2022 00:06:06 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 73701492CA2 for ; Tue, 9 Aug 2022 00:06:05 +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 9BCB61857F07 for ; Tue, 9 Aug 2022 00:06:05 +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-136-TrTZWC1EMoyoePJfNdI94g-1; Mon, 08 Aug 2022 20:06:03 -0400 X-MC-Unique: TrTZWC1EMoyoePJfNdI94g-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 278Nwhfh031116; Tue, 9 Aug 2022 00:04:44 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 3hsew155hd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:43 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 278M0hHm038083; Tue, 9 Aug 2022 00:04:42 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3hu0n32vm1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:42 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by CH0PR10MB4907.namprd10.prod.outlook.com (2603:10b6:610:db::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Tue, 9 Aug 2022 00:04:40 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50%6]) with mapi id 15.20.5504.020; Tue, 9 Aug 2022 00:04:40 +0000 From: Mike Christie To: bvanassche@acm.org, linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, linux-nvme@lists.infradead.org, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Date: Mon, 8 Aug 2022 19:04:11 -0500 Message-Id: <20220809000419.10674-13-michael.christie@oracle.com> In-Reply-To: <20220809000419.10674-1-michael.christie@oracle.com> References: <20220809000419.10674-1-michael.christie@oracle.com> X-ClientProxiedBy: CH2PR03CA0026.namprd03.prod.outlook.com (2603:10b6:610:59::36) 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: 94268674-7043-401b-76fb-08da799ac14e X-MS-TrafficTypeDiagnostic: CH0PR10MB4907:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: iBioCe4eQegoq/BAzd0UTbmqJ8/yyeekOqSbZkT1eCCEsg1LcJIIA7gkfNuCLv10DNuAmUbRbXuVZo/hq6gWp0aVbc6xTrKO5XHNsRxVGXD0E+rxrDcUd8mMT+YoQ2DOHiCo3dyoJQdSzD48RQuraZZ5tx5mcuf3xR3d5HV8sEdPJTn/K1eubhl/HlIpQDXv4ct1AtMJdQUD90ccbDcdqQSvCbpj5Yc68+GkN3QyPA5H5jv+q0DWrwbxRqgKxD65xjIS3IEsjXuwcoRZIwSMt1mKnTLabrjZu8409TChZ0/TMeq59e8lJCTCSPqS/hCfdv4SSZghyD/pyYBlPrM0Jp1JniNvZalKYXkZwsgGBPzq0GbyNIJffTAvk96D4W3JD4XHAVFSjmQ5Qy7VS6y3Hj9sKOxiqeWOxRHE6JkW951t4L4/zZ2xe4fdZ/7YrW0EuVtMREv8nfyqj1/EUk08MbLQD2DZGEILxlz8uznDRQYwXxM8v8tc42afaL8l7X8na/s8Q1g4rt4qsV7iLjjx7wGvdCdxfGbjA2RvM/jA6RhgLxo/hEj3djFEb/XvPbg7JdGmEovTCRFRpugdRKKJLGRCKbjCQ9uNkFTB2h3b+17jRBQVSwn/e0VNdQbRG7bqzQ6WEx6/1lgCK1iuL6yS+/fq9eTCgX1un4cDimIOxIznS1tT32sst4cgxRLYE3WpgTe3ID1UAlDrGBTGog/NUA579VIm3HhI5Jv99+qYNOi/uWfvtXj9xN9U30wq6FvwRUj7R5OK7QKpDslfWwkDjuHBKZmwe3Yj89y/ZyblLcw= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(396003)(366004)(136003)(346002)(376002)(39860400002)(921005)(30864003)(6666004)(41300700001)(6512007)(26005)(2906002)(6506007)(83380400001)(2616005)(107886003)(38100700002)(86362001)(186003)(6486002)(1076003)(316002)(66476007)(66556008)(36756003)(8676002)(66946007)(4326008)(8936002)(478600001)(5660300002); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WxZkQG0Ys9yuX6piL/fTGOi+vnM/DC5zLWYUlONLZspohHiz1uiuwQk2yNvTokhUX1QYUdLvGoE5oV1lRToDrf7pLc+flc3f9tuJ1OirIr/sDzuSCiI/G6L6Pb14v7qcvGT2jwPgvZT99M4+cNlps1Pu45iSEFvFu7BW4CeEW41mbi5OKU7Z/A6UxBYp51KS1QEqNZJqSnQeRHtnqkiRQaTAicYWpYNXUERJjdmfIuF6McUGEi5qxNaX9xyA09jp+bJG4eCyjfZOKnFW+07G2R/k+LN6Tc9l3yyOyG2uNWO2qhDEQ2TtXO565S8AK18LOZzgRLxRddor8UGTUKw+8qHhGpqT2i663MDeQWqMqZYYrpvMbrQTNm+KtICZin4UFHcIKPsO4zNkbGGYZ4OAk+LDSEl2QHVAmrq1lgT6qaGxgfOtcVUdOSP8PwKV5Z5thXH/45DGzCKgnDBNCYypx4Y6ffclkpsh0n9Fr2ZT2fPpXWPZDQCpWelYOlYq+Dx7USoKmo+P25vvNpq3/eOlDd0U0V81Qv146jOlPol4CqihzKrx8kB4svQlFwbMfqzvA1ei9xWR2ROtXSZSIH6DKXmcsDyGpVzFdUOnoeT3okKs3MFvVwNKAG+AiUy6drSthHTl7H6/PasV03gIB/03Vo6Jg9tSzinN019qg/AARs0Si+fYWA0m1aCQye92Vhlfc2nN7I0ty/14DSyp6611fNzXPVz87dZr6NKUxSXOO8g8PoGdVx8Ldx5c7oxmLUbWJnWQ2fpDV2r7mzAMDll3S8sH3V8Bwzk+xJWbVbtDkfT0Nk8D+M57VZSHlUJlrxQ62tBhj2eHRxWNVBFl8/WK7mw5qZgR9bnFMmMxobIYvDaY4i/QKVO4ZdQFJpHJJT5TcqJpsOHTtufqIgNVtAmZg92X1Urj2yYhCIlu+PXkKu35IKbEJe6ZECoI6lihkC1sLkzjHpeMxs91sR3GENRZpVYG5A4ZJSokOu2X0ygk1DqCPFjU/4Pto3s2gzfNyd9rbvYKmNv41LN2hAXx0ma5jhkDE65SMtRyRnq+aeEZn/51xyXcem89w4IyovwHjwfy7QOmCsoTlD89vpTfCkDGRzg75UA7CVjzExT41/iY5FmT9CZBvz6rS+OVywvZqQt8+KpX7AF0vAw+bhBDDGPJ52fK18HFs8PhHNUGYbSHC+7jaCd7TK70t9MzzXNPIGE17H3m4hKNLXUp9zs2qyeDfHKoIx768OeMW8t4ACoBA/1K7vuVUF/jzHFYAIZZUYyGoYU/2posVXpR03pdoCO9XwSZWjylFjtMh0VExf4K40HczQUIUOQKSlQeRHDIaVCXuMxVhjFc618vcX4XN4kZeLGe9aJU345+OdGxpktmXxwJxsfcRWf/Mb+egxcJOfFmnf5LP2BrVwkBiv0dCmHMBtWWh9L1YA9PbBz4fu4ntD2Hzcw6AlKVQ6c8TTZNQDmcO4rINerwqJm1DIlC89zw/PUPX9qKrmjyqPufXlT0am+npli/OBx92eXZ/V+wLGZl0XKYnn5RdvPOsv4Q8lu3eIvh4HsxA0kDzdf/YgDwtGgPBjOiVJgwK/OGnIXWpXawn65FtEPxsGZutfmLI6MqWQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 94268674-7043-401b-76fb-08da799ac14e X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2022 00:04:40.2822 (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: qtdzf0ScS+Vi4WLMbaFpU/GjP6UWz+unUyzPxNRmXADN7sQUO6wAHHdt6ygGdeM0+qHZCdDCBEqS9RjS52fF8ME09ItBcTEbIRCEgBCL2Y4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4907 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-08_14,2022-08-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 suspectscore=0 adultscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2208080105 X-Proofpoint-ORIG-GUID: tH9uBTu_fO3DKVP_iPwPdgiv6VS1fukI X-Proofpoint-GUID: tH9uBTu_fO3DKVP_iPwPdgiv6VS1fukI X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Mimecast-Bulk-Signature: yes X-Mimecast-Spam-Signature: bulk X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Subject: [dm-devel] [PATCH v2 12/20] block, nvme, scsi, dm: Add blk_status to pr_ops callouts. X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mike Christie Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Kernel pr_ops users like LIO need to be able to know about if a failure was a result of a reservation conflict and then be able to convert from the lower level's definition of that error to SCSI so it can be returned to the initiator. To do this they currently have to know the lower level device type and this can be difficult when we have dm-multipath between LIO and the device. dm-multipath would also like to be able to distiguish between path failures and reservation conflict so they can optimize their error handlers for their pr_ops. To handle both cases, this patch adds a blk_status_t arg to the pr_ops callouts. The lower levels will convert their device specific error to the blk_status_t then the upper levels can easily check that code without knowing the device type. It also allows us to keep userspace compat where it expects a negative -Exyz error code if the command fails before it's sent to the device or a device/tranport specific value if the error is > 0. This patch just wires in the blk_status_t to the pr_ops callouts. The next patches will then have the drivers pass up a blk_status_t. Signed-off-by: Mike Christie --- block/ioctl.c | 11 ++++++----- drivers/md/dm.c | 41 +++++++++++++++++++++++++--------------- drivers/nvme/host/core.c | 16 +++++++++------- drivers/scsi/sd.c | 21 +++++++++++--------- fs/nfs/blocklayout/dev.c | 4 ++-- fs/nfsd/blocklayout.c | 6 +++--- include/linux/pr.h | 17 ++++++++++------- 7 files changed, 68 insertions(+), 48 deletions(-) diff --git a/block/ioctl.c b/block/ioctl.c index 60121e89052b..72338c56e235 100644 --- a/block/ioctl.c +++ b/block/ioctl.c @@ -269,7 +269,8 @@ static int blkdev_pr_register(struct block_device *bdev, if (reg.flags & ~PR_FL_IGNORE_KEY) return -EOPNOTSUPP; - return ops->pr_register(bdev, reg.old_key, reg.new_key, reg.flags); + return ops->pr_register(bdev, reg.old_key, reg.new_key, reg.flags, + NULL); } static int blkdev_pr_reserve(struct block_device *bdev, @@ -287,7 +288,7 @@ static int blkdev_pr_reserve(struct block_device *bdev, if (rsv.flags & ~PR_FL_IGNORE_KEY) return -EOPNOTSUPP; - return ops->pr_reserve(bdev, rsv.key, rsv.type, rsv.flags); + return ops->pr_reserve(bdev, rsv.key, rsv.type, rsv.flags, NULL); } static int blkdev_pr_release(struct block_device *bdev, @@ -305,7 +306,7 @@ static int blkdev_pr_release(struct block_device *bdev, if (rsv.flags) return -EOPNOTSUPP; - return ops->pr_release(bdev, rsv.key, rsv.type); + return ops->pr_release(bdev, rsv.key, rsv.type, NULL); } static int blkdev_pr_preempt(struct block_device *bdev, @@ -323,7 +324,7 @@ static int blkdev_pr_preempt(struct block_device *bdev, if (p.flags) return -EOPNOTSUPP; - return ops->pr_preempt(bdev, p.old_key, p.new_key, p.type, abort); + return ops->pr_preempt(bdev, p.old_key, p.new_key, p.type, abort, NULL); } static int blkdev_pr_clear(struct block_device *bdev, @@ -341,7 +342,7 @@ static int blkdev_pr_clear(struct block_device *bdev, if (c.flags) return -EOPNOTSUPP; - return ops->pr_clear(bdev, c.key); + return ops->pr_clear(bdev, c.key, NULL); } static int blkdev_flushbuf(struct block_device *bdev, fmode_t mode, diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 1b15295bdf24..ac39e5d303b9 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -3080,7 +3080,8 @@ struct dm_pr { bool abort; bool fail_early; int ret; - enum pr_type type; + enum pr_type type; + blk_status_t *blk_stat; }; static int dm_call_pr(struct block_device *bdev, iterate_devices_callout_fn fn, @@ -3131,7 +3132,8 @@ static int __dm_pr_register(struct dm_target *ti, struct dm_dev *dev, return -1; } - ret = ops->pr_register(dev->bdev, pr->old_key, pr->new_key, pr->flags); + ret = ops->pr_register(dev->bdev, pr->old_key, pr->new_key, pr->flags, + pr->blk_stat); if (!ret) return 0; @@ -3145,7 +3147,7 @@ static int __dm_pr_register(struct dm_target *ti, struct dm_dev *dev, } static int dm_pr_register(struct block_device *bdev, u64 old_key, u64 new_key, - u32 flags) + u32 flags, blk_status_t *blk_stat) { struct dm_pr pr = { .old_key = old_key, @@ -3153,6 +3155,7 @@ static int dm_pr_register(struct block_device *bdev, u64 old_key, u64 new_key, .flags = flags, .fail_early = true, .ret = 0, + .blk_stat = blk_stat, }; int ret; @@ -3190,7 +3193,8 @@ static int __dm_pr_reserve(struct dm_target *ti, struct dm_dev *dev, return -1; } - pr->ret = ops->pr_reserve(dev->bdev, pr->old_key, pr->type, pr->flags); + pr->ret = ops->pr_reserve(dev->bdev, pr->old_key, pr->type, pr->flags, + pr->blk_stat); if (!pr->ret) return -1; @@ -3198,7 +3202,7 @@ static int __dm_pr_reserve(struct dm_target *ti, struct dm_dev *dev, } static int dm_pr_reserve(struct block_device *bdev, u64 key, enum pr_type type, - u32 flags) + u32 flags, blk_status_t *blk_stat) { struct dm_pr pr = { .old_key = key, @@ -3206,6 +3210,7 @@ static int dm_pr_reserve(struct block_device *bdev, u64 key, enum pr_type type, .type = type, .fail_early = false, .ret = 0, + .blk_stat = blk_stat, }; int ret; @@ -3233,19 +3238,22 @@ static int __dm_pr_release(struct dm_target *ti, struct dm_dev *dev, return -1; } - pr->ret = ops->pr_release(dev->bdev, pr->old_key, pr->type); + pr->ret = ops->pr_release(dev->bdev, pr->old_key, pr->type, + pr->blk_stat); if (pr->ret) return -1; return 0; } -static int dm_pr_release(struct block_device *bdev, u64 key, enum pr_type type) +static int dm_pr_release(struct block_device *bdev, u64 key, enum pr_type type, + blk_status_t *blk_stat) { struct dm_pr pr = { .old_key = key, .type = type, .fail_early = false, + .blk_stat = blk_stat, }; int ret; @@ -3268,7 +3276,7 @@ static int __dm_pr_preempt(struct dm_target *ti, struct dm_dev *dev, } pr->ret = ops->pr_preempt(dev->bdev, pr->old_key, pr->new_key, pr->type, - pr->abort); + pr->abort, pr->blk_stat); if (!pr->ret) return -1; @@ -3276,13 +3284,14 @@ static int __dm_pr_preempt(struct dm_target *ti, struct dm_dev *dev, } static int dm_pr_preempt(struct block_device *bdev, u64 old_key, u64 new_key, - enum pr_type type, bool abort) + enum pr_type type, bool abort, blk_status_t *blk_stat) { struct dm_pr pr = { .new_key = new_key, .old_key = old_key, .type = type, .fail_early = false, + .blk_stat = blk_stat, }; int ret; @@ -3293,7 +3302,8 @@ static int dm_pr_preempt(struct block_device *bdev, u64 old_key, u64 new_key, return pr.ret; } -static int dm_pr_clear(struct block_device *bdev, u64 key) +static int dm_pr_clear(struct block_device *bdev, u64 key, + blk_status_t *blk_stat) { struct mapped_device *md = bdev->bd_disk->private_data; const struct pr_ops *ops; @@ -3305,7 +3315,7 @@ static int dm_pr_clear(struct block_device *bdev, u64 key) ops = bdev->bd_disk->fops->pr_ops; if (ops && ops->pr_clear) - r = ops->pr_clear(bdev, key); + r = ops->pr_clear(bdev, key, blk_stat); else r = -EOPNOTSUPP; out: @@ -3314,7 +3324,7 @@ static int dm_pr_clear(struct block_device *bdev, u64 key) } static int dm_pr_read_keys(struct block_device *bdev, struct pr_keys *keys, - u32 keys_len) + u32 keys_len, blk_status_t *blk_stat) { struct mapped_device *md = bdev->bd_disk->private_data; const struct pr_ops *ops; @@ -3326,7 +3336,7 @@ static int dm_pr_read_keys(struct block_device *bdev, struct pr_keys *keys, ops = bdev->bd_disk->fops->pr_ops; if (ops && ops->pr_read_keys) - r = ops->pr_read_keys(bdev, keys, keys_len); + r = ops->pr_read_keys(bdev, keys, keys_len, blk_stat); else r = -EOPNOTSUPP; out: @@ -3335,7 +3345,8 @@ static int dm_pr_read_keys(struct block_device *bdev, struct pr_keys *keys, } static int dm_pr_read_reservation(struct block_device *bdev, - struct pr_held_reservation *rsv) + struct pr_held_reservation *rsv, + blk_status_t *blk_stat) { struct mapped_device *md = bdev->bd_disk->private_data; const struct pr_ops *ops; @@ -3347,7 +3358,7 @@ static int dm_pr_read_reservation(struct block_device *bdev, ops = bdev->bd_disk->fops->pr_ops; if (ops && ops->pr_read_reservation) - r = ops->pr_read_reservation(bdev, rsv); + r = ops->pr_read_reservation(bdev, rsv, blk_stat); else r = -EOPNOTSUPP; out: diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 5bbc1d84a87e..49bd745d28e2 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2148,7 +2148,7 @@ static int nvme_pr_command(struct block_device *bdev, u32 cdw10, } static int nvme_pr_register(struct block_device *bdev, u64 old, - u64 new, unsigned flags) + u64 new, unsigned flags, blk_status_t *blk_stat) { u32 cdw10; @@ -2162,7 +2162,7 @@ static int nvme_pr_register(struct block_device *bdev, u64 old, } static int nvme_pr_reserve(struct block_device *bdev, u64 key, - enum pr_type type, unsigned flags) + enum pr_type type, unsigned flags, blk_status_t *blk_stat) { u32 cdw10; @@ -2175,21 +2175,23 @@ static int nvme_pr_reserve(struct block_device *bdev, u64 key, } static int nvme_pr_preempt(struct block_device *bdev, u64 old, u64 new, - enum pr_type type, bool abort) + enum pr_type type, bool abort, blk_status_t *blk_stat) { u32 cdw10 = nvme_pr_type(type) << 8 | (abort ? 2 : 1); return nvme_pr_command(bdev, cdw10, old, new, nvme_cmd_resv_acquire); } -static int nvme_pr_clear(struct block_device *bdev, u64 key) +static int nvme_pr_clear(struct block_device *bdev, u64 key, + blk_status_t *blk_stat) { u32 cdw10 = 1 | (key ? 1 << 3 : 0); return nvme_pr_command(bdev, cdw10, key, 0, nvme_cmd_resv_register); } -static int nvme_pr_release(struct block_device *bdev, u64 key, enum pr_type type) +static int nvme_pr_release(struct block_device *bdev, u64 key, enum pr_type type, + blk_status_t *blk_stat) { u32 cdw10 = nvme_pr_type(type) << 8 | (key ? 1 << 3 : 0); @@ -2224,7 +2226,7 @@ static int nvme_pr_resv_report(struct block_device *bdev, u8 *data, } static int nvme_pr_read_keys(struct block_device *bdev, - struct pr_keys *keys_info, u32 keys_len) + struct pr_keys *keys_info, u32 keys_len, blk_status_t *blk_stat) { struct nvme_reservation_status *status; u32 data_len, num_ret_keys; @@ -2268,7 +2270,7 @@ static int nvme_pr_read_keys(struct block_device *bdev, } static int nvme_pr_read_reservation(struct block_device *bdev, - struct pr_held_reservation *resv) + struct pr_held_reservation *resv, blk_status_t *blk_stat) { struct nvme_reservation_status tmp_status, *status; int ret, i, num_regs; diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index f1d4d0568075..bf080de9866d 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1708,7 +1708,7 @@ static int sd_pr_in_command(struct block_device *bdev, u8 sa, } static int sd_pr_read_keys(struct block_device *bdev, struct pr_keys *keys_info, - u32 keys_len) + u32 keys_len, blk_status_t *blk_stat) { int result, i, data_offset, num_copy_keys; int data_len = keys_len + 8; @@ -1739,7 +1739,8 @@ static int sd_pr_read_keys(struct block_device *bdev, struct pr_keys *keys_info, } static int sd_pr_read_reservation(struct block_device *bdev, - struct pr_held_reservation *rsv) + struct pr_held_reservation *rsv, + blk_status_t *blk_stat) { struct scsi_disk *sdkp = scsi_disk(bdev->bd_disk); struct scsi_device *sdev = sdkp->device; @@ -1769,8 +1770,8 @@ static int sd_pr_read_reservation(struct block_device *bdev, return 0; } -static int sd_pr_out_command(struct block_device *bdev, u8 sa, - u64 key, u64 sa_key, u8 type, u8 flags) +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); struct scsi_device *sdev = sdkp->device; @@ -1801,7 +1802,7 @@ static int sd_pr_out_command(struct block_device *bdev, u8 sa, } static int sd_pr_register(struct block_device *bdev, u64 old_key, u64 new_key, - u32 flags) + u32 flags, blk_status_t *blk_stat) { if (flags & ~PR_FL_IGNORE_KEY) return -EOPNOTSUPP; @@ -1811,7 +1812,7 @@ static int sd_pr_register(struct block_device *bdev, u64 old_key, u64 new_key, } static int sd_pr_reserve(struct block_device *bdev, u64 key, enum pr_type type, - u32 flags) + u32 flags, blk_status_t *blk_stat) { if (flags) return -EOPNOTSUPP; @@ -1819,20 +1820,22 @@ static int sd_pr_reserve(struct block_device *bdev, u64 key, enum pr_type type, block_pr_type_to_scsi(type), 0); } -static int sd_pr_release(struct block_device *bdev, u64 key, enum pr_type type) +static int sd_pr_release(struct block_device *bdev, u64 key, enum pr_type type, + blk_status_t *blk_stat) { 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) + enum pr_type type, bool abort, blk_status_t *blk_stat) { return sd_pr_out_command(bdev, abort ? 0x05 : 0x04, old_key, new_key, block_pr_type_to_scsi(type), 0); } -static int sd_pr_clear(struct block_device *bdev, u64 key) +static int sd_pr_clear(struct block_device *bdev, u64 key, + blk_status_t *blk_stat) { return sd_pr_out_command(bdev, 0x03, key, 0, 0, 0); } diff --git a/fs/nfs/blocklayout/dev.c b/fs/nfs/blocklayout/dev.c index 5e56da748b2a..8726c1473d55 100644 --- a/fs/nfs/blocklayout/dev.c +++ b/fs/nfs/blocklayout/dev.c @@ -29,7 +29,7 @@ bl_free_device(struct pnfs_block_dev *dev) int error; error = ops->pr_register(dev->bdev, dev->pr_key, 0, - false); + false, NULL); if (error) pr_err("failed to unregister PR key.\n"); } @@ -382,7 +382,7 @@ bl_parse_scsi(struct nfs_server *server, struct pnfs_block_dev *d, goto out_blkdev_put; } - error = ops->pr_register(d->bdev, 0, d->pr_key, true); + error = ops->pr_register(d->bdev, 0, d->pr_key, true, NULL); if (error) { pr_err("pNFS: failed to register key for block device %s.", d->bdev->bd_disk->disk_name); diff --git a/fs/nfsd/blocklayout.c b/fs/nfsd/blocklayout.c index b6d01d51a746..a302ea026f72 100644 --- a/fs/nfsd/blocklayout.c +++ b/fs/nfsd/blocklayout.c @@ -277,7 +277,7 @@ nfsd4_block_get_device_info_scsi(struct super_block *sb, goto out_free_dev; } - ret = ops->pr_register(sb->s_bdev, 0, NFSD_MDS_PR_KEY, true); + ret = ops->pr_register(sb->s_bdev, 0, NFSD_MDS_PR_KEY, true, NULL); if (ret) { pr_err("pNFS: failed to register key for device %s.\n", sb->s_id); @@ -285,7 +285,7 @@ nfsd4_block_get_device_info_scsi(struct super_block *sb, } ret = ops->pr_reserve(sb->s_bdev, NFSD_MDS_PR_KEY, - PR_EXCLUSIVE_ACCESS_REG_ONLY, 0); + PR_EXCLUSIVE_ACCESS_REG_ONLY, 0, NULL); if (ret) { pr_err("pNFS: failed to reserve device %s.\n", sb->s_id); @@ -331,7 +331,7 @@ nfsd4_scsi_fence_client(struct nfs4_layout_stateid *ls) struct block_device *bdev = ls->ls_file->nf_file->f_path.mnt->mnt_sb->s_bdev; bdev->bd_disk->fops->pr_ops->pr_preempt(bdev, NFSD_MDS_PR_KEY, - nfsd4_scsi_pr_key(clp), 0, true); + nfsd4_scsi_pr_key(clp), 0, true, NULL); } const struct nfsd4_layout_ops scsi_layout_ops = { diff --git a/include/linux/pr.h b/include/linux/pr.h index 79b3d2853a20..2cbe97f06490 100644 --- a/include/linux/pr.h +++ b/include/linux/pr.h @@ -18,14 +18,15 @@ struct pr_held_reservation { struct pr_ops { int (*pr_register)(struct block_device *bdev, u64 old_key, u64 new_key, - u32 flags); + u32 flags, blk_status_t *blk_stat); int (*pr_reserve)(struct block_device *bdev, u64 key, - enum pr_type type, u32 flags); + enum pr_type type, u32 flags, blk_status_t *blk_stat); int (*pr_release)(struct block_device *bdev, u64 key, - enum pr_type type); + enum pr_type type, blk_status_t *blk_stat); 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); + enum pr_type type, bool abort, blk_status_t *blk_stat); + int (*pr_clear)(struct block_device *bdev, u64 key, + blk_status_t *blk_stat); /* * pr_read_keys - Read the registered keys and return them in the * pr_keys->keys array. The keys array will have been allocated at the @@ -35,9 +36,11 @@ struct pr_ops { * contains, so the caller can retry with a larger array. */ int (*pr_read_keys)(struct block_device *bdev, - struct pr_keys *keys_info, u32 keys_len); + struct pr_keys *keys_info, u32 keys_len, + blk_status_t *blk_stat); int (*pr_read_reservation)(struct block_device *bdev, - struct pr_held_reservation *rsv); + struct pr_held_reservation *rsv, + blk_status_t *blk_stat); }; #endif /* LINUX_PR_H */ From patchwork Tue Aug 9 00:04:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12939248 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2FE96C25B0C for ; Tue, 9 Aug 2022 00:07:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660003623; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=5ux8A7IPA70e2QG2BoDbD0volq9eYaWbZkR6U1dt7Hs=; b=B/0OM4M1le1Q/5jVu96X+u2I9SvkzONiah2Tf5z9KhiBtvHa6WIpVNYW2UfWU/IbMhX4rV ZJYCL++vZ+VeOW2VVxM0pPjGC7PeclZuXkp/xuWGZkXLh2yuZrWTAtILg9Nos2qrdJ2m7R CXMkmakMEVf0I9VAY2aahN0fenYZY7s= 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-172-OudkS7QTMa2AHGoWdAs9LA-1; Mon, 08 Aug 2022 20:07:00 -0400 X-MC-Unique: OudkS7QTMa2AHGoWdAs9LA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D8FD98039A2; Tue, 9 Aug 2022 00:06:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C57161121314; Tue, 9 Aug 2022 00:06: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 99E6F1946A50; Tue, 9 Aug 2022 00:06:58 +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 8D8E61946A4F for ; Tue, 9 Aug 2022 00:06:57 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7E112404E4D3; Tue, 9 Aug 2022 00:06:57 +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 7966340C1288 for ; Tue, 9 Aug 2022 00:06:56 +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 83C07823F01 for ; Tue, 9 Aug 2022 00:06:56 +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-478-PDWAkqx0MZ-3o021runfFQ-1; Mon, 08 Aug 2022 20:06:54 -0400 X-MC-Unique: PDWAkqx0MZ-3o021runfFQ-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 278NwfQ2031102; Tue, 9 Aug 2022 00:04:43 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 3hsew155he-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:43 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 278M0hHn038083; Tue, 9 Aug 2022 00:04:43 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3hu0n32vm1-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:42 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by CH0PR10MB4907.namprd10.prod.outlook.com (2603:10b6:610:db::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Tue, 9 Aug 2022 00:04:41 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50%6]) with mapi id 15.20.5504.020; Tue, 9 Aug 2022 00:04:41 +0000 From: Mike Christie To: bvanassche@acm.org, linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, linux-nvme@lists.infradead.org, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Date: Mon, 8 Aug 2022 19:04:12 -0500 Message-Id: <20220809000419.10674-14-michael.christie@oracle.com> In-Reply-To: <20220809000419.10674-1-michael.christie@oracle.com> References: <20220809000419.10674-1-michael.christie@oracle.com> X-ClientProxiedBy: CH2PR03CA0015.namprd03.prod.outlook.com (2603:10b6:610:59::25) 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: e269e834-feed-46e8-b865-08da799ac216 X-MS-TrafficTypeDiagnostic: CH0PR10MB4907:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: /gBU3888B5l9SwWMOsjgyf47OE5b2UVx4IDjQUk1Aumpw+EWIKegXNblHnII542wERDv5VZuQAeozpCYhuW0haiL36K2MOJcmQ4WdzZVJZHQIWCRHSY8Y64Aele5OzcY+/wuK32B4jMJG87G5PT7JKs2tTJWIyM4W4rJGHZLowvegrz0pYfImyxJ9feT5rK3zkC1gRX2OjwPUi2fgN990bz82onL8KBtTPSmu/pPWzQDyDw9zCl1H1FrsviLCnB6L1M2S02C2RM81agCHwGhIfsSri+mDqvSwr0p0/fmZAMszEHLQEKFFa/CABhQ3pQ5eZO2adoanoit5Kvn9ihJzr07F3ZYm6zfmHEfqOP/SMZ3le8G0bfYgI/uL75+hXFmFxkQFatRsYxgkzQ3QFeXAvePMVMwG6SAPNUeHcXqdxKER0C/iwEBgfYFWgf3RoyMxCy5cRGG7hq/ietMXWcYeVjOHV8Mfyxl/bkPBzH6uMgZw+ykLqSkAnkTQnHUTt1tgfFW3hq5+iorhHHuFuePEn4BMpBjM+YHFAjgMBmlb5FZgfgHWDWbtb0M7yDcwCZsSuKz3NPuPwgymt+UtMQXLyDsMK5M4F9yDGVdZ969DIYDSK3lIZTc06xKCEDfU9CwQenE5/Nf7X7E6IboJ9c1OSoVpNGWa7Y7Ykq93RYdfdEBMdyS0ZbW62BJhTE6zDEMUzHR/Goyjtl12p59KZrwMGQFuyahvhsw/X+W4LfUd3qcPTPxpzUp3EePaOzLzuYDlbHZBhasLqjZKPbek5dHRUqsa0oZ+V//p1AFdCKFBUA= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(396003)(366004)(136003)(346002)(376002)(39860400002)(921005)(6666004)(41300700001)(6512007)(26005)(2906002)(6506007)(83380400001)(2616005)(107886003)(38100700002)(86362001)(186003)(6486002)(1076003)(316002)(66476007)(66556008)(36756003)(8676002)(66946007)(4326008)(8936002)(478600001)(5660300002); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +HyS8pSGXQuNg4Bi8v9joHGp1owqfy7JjY6ruZLC4Tf/zX4L2mvg74M0tdkTkgKSPWF5RzOj5gXON2Cr1dRQtO7rH+1I5zLqRUig/3YGUtxA6QFUUgPeb1RN6ac3qutbPv5SkydiANu9xPtcPE3uh37Hg9iqcw3S2HtB8UN8cgmo48m0M02j0Miaims6/kxn7JRlUW3ty0QiXZP2bjtlA7Qkh6vw1icACbHyvmY9C4eNY00WJL7ojYHSHsaFIB2thOzoANgiKb1TmQalddcmUTMre9iBluiVZkjDFPcbg4WrdHlV8NWTo2WRI/Tt6/8UrJeIFkXxqIgf1TCUkcynPcR7fxpGhYFWKcseqlR03SCv+2jlLslPcOiN+/CvVwk6W35cCj1mMAX+Yif6TwfIEvpxm4de54Vz82JuH05L4N/ImaMazDZVYlqA18HykxnHi6Ok59vFzSmyCIlyMQIqCpRnhgRI5me3k+IbC+LX/7drKEraHevk5ExiSOOMonWTlB9AAHlJspOSNokF+KUpsQM8GdBjo+1434j3kEAutM8op/VusGvB3ORfbaenADPK2vxeRMB7z5qY2bzPi6TK3jveUGjCar5oCBTiTbUShUKn8qjzMW+GE5MAWC1KfQgbgfQpYqOoRXZq0gqBKRfmhB4s5lcfJ+NIYLNGs5ZBVZWGA6Z1PoHE4YQvKD3QId3hLJob1kz9kpW3jb4Tis5E50vivmx9aztOfBIoL3V0DOD3An0TlIQJy2IkCtuRSn2bn2+6sfVtCHK1SSmAH3/+YIFy1Ho9Di5wbDO2dc7bPcWlSp4c/QMMd5WRzFriK/bjZSNpr36rIwh7seqGG5liewvnoygqEoZmZD3dD5w4bIGmZFf7Syde7QKOr+liKRzqC5H1/Djl+TpgSw4zVeGf0GoOnEBr7cU8RCtaZ3iDMG5W+ovV6M57xldo/ZdVqwpFdCtZeQ8PyLpJtY7u54k3CB6d81r2noGRwgWPRtsC9/HVPnCsYxtSDDgeffiaPDSct8GaHtLGPYpHptuk+SkYjTKHDst4Wl4zoJtF4m8jv9CqKYxiqe5GTtwCjQtsglEPHDOH7A2KFImmPP1939AL0BB/hcA0mtgb7wMFSR9slyKnvWnQB/P34Tio6alaOcaBHe8NF6ggRgFYrdIdTmfqC6gTnjXUN68DA272iCMBx/Z8joUMFMKw26miK2sjD/59QgT7FjGaEFnXc6pqxOARC4hGY/nPwPeyl4rtSA43H7ya5mlqoregiHQTN8ie2jK9a9O8iWuB5mRXXhCKIG6PLxB7nbTaDSh4v2pU0Lidr1mgdcJ6ziNvhqz66B35rFt/dn+hpoN5biTf/AywHXfbyJx2Gy/z/P5UdufNdoUnxB/TxCs1vZ9iDe6kTaeqHGTXjooZw5Og9OHmok+ON4CqY1ZbQDEArUYBO3baum+pjmL9Qftm4pAU0rUpgvPNfjPXoTpZ95Y+tLW5uDl35AA5LZP+QeliUCc4AgBjrlQl8Ik3dA0zciYd6NYo2noQXYfE31PUAX1SvTK+bckP0JL/JGdfTPsJN2fslaru6VuQBD49u8A0XjIK6WqXrtFudsY7+E26+HqOxaiMhVx1bqcK+Q== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e269e834-feed-46e8-b865-08da799ac216 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2022 00:04:41.5946 (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: /fIZWQSPZxJ09X568Uh5tLLOvZ7lM/kqp+WUvIxZdS6igrm1bg9Ey/wpP/he8PSTp7SNAiewnT/Kl1pfL98GSgOAzgDFUanpdz99RSetTwo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4907 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-08_14,2022-08-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 suspectscore=0 adultscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2208080105 X-Proofpoint-ORIG-GUID: iyKs7l8dH-6h1VKOxmJ8RCxmKHj35kHJ X-Proofpoint-GUID: iyKs7l8dH-6h1VKOxmJ8RCxmKHj35kHJ 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 Subject: [dm-devel] [PATCH v2 13/20] nvme: Have nvme pr_ops return a blk_status_t X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mike Christie Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com This patch has the nvme pr_ops convert from a nvme status value to a blk_status_t. Signed-off-by: Mike Christie --- drivers/nvme/host/core.c | 54 ++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 49bd745d28e2..46188b3d9df8 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2105,7 +2105,8 @@ static char nvme_pr_type(enum pr_type type) } static int nvme_send_ns_head_pr_command(struct block_device *bdev, - struct nvme_command *c, u8 *data, unsigned int data_len) + struct nvme_command *c, u8 *data, unsigned int data_len, + blk_status_t *blk_stat) { struct nvme_ns_head *head = bdev->bd_disk->private_data; int srcu_idx = srcu_read_lock(&head->srcu); @@ -2115,20 +2116,28 @@ static int nvme_send_ns_head_pr_command(struct block_device *bdev, if (ns) { c->common.nsid = cpu_to_le32(ns->head->ns_id); ret = nvme_submit_sync_cmd(ns->queue, c, data, data_len); + if (blk_stat && ret >= 0) + *blk_stat = nvme_error_status(ret); } srcu_read_unlock(&head->srcu, srcu_idx); return ret; } static int nvme_send_ns_pr_command(struct nvme_ns *ns, struct nvme_command *c, - u8 *data, unsigned int data_len) + u8 *data, unsigned int data_len, blk_status_t *blk_stat) { + int ret; + c->common.nsid = cpu_to_le32(ns->head->ns_id); - return nvme_submit_sync_cmd(ns->queue, c, data, data_len); + ret = nvme_submit_sync_cmd(ns->queue, c, data, data_len); + if (blk_stat && ret >= 0) + *blk_stat = nvme_error_status(ret); + return ret; } static int nvme_pr_command(struct block_device *bdev, u32 cdw10, - u64 key, u64 sa_key, u8 op) + u64 key, u64 sa_key, u8 op, + blk_status_t *blk_stat) { struct nvme_command c = { }; u8 data[16] = { 0, }; @@ -2142,9 +2151,9 @@ static int nvme_pr_command(struct block_device *bdev, u32 cdw10, if (IS_ENABLED(CONFIG_NVME_MULTIPATH) && bdev->bd_disk->fops == &nvme_ns_head_ops) return nvme_send_ns_head_pr_command(bdev, &c, data, - sizeof(data)); - return nvme_send_ns_pr_command(bdev->bd_disk->private_data, &c, data, - sizeof(data)); + sizeof(data), blk_stat); + return nvme_send_ns_pr_command(bdev->bd_disk->private_data, &c, + data, sizeof(data), blk_stat); } static int nvme_pr_register(struct block_device *bdev, u64 old, @@ -2158,7 +2167,8 @@ static int nvme_pr_register(struct block_device *bdev, u64 old, cdw10 = old ? 2 : 0; cdw10 |= (flags & PR_FL_IGNORE_KEY) ? 1 << 3 : 0; cdw10 |= (1 << 30) | (1 << 31); /* PTPL=1 */ - return nvme_pr_command(bdev, cdw10, old, new, nvme_cmd_resv_register); + return nvme_pr_command(bdev, cdw10, old, new, nvme_cmd_resv_register, + blk_stat); } static int nvme_pr_reserve(struct block_device *bdev, u64 key, @@ -2171,7 +2181,8 @@ static int nvme_pr_reserve(struct block_device *bdev, u64 key, cdw10 = nvme_pr_type(type) << 8; cdw10 |= ((flags & PR_FL_IGNORE_KEY) ? 1 << 3 : 0); - return nvme_pr_command(bdev, cdw10, key, 0, nvme_cmd_resv_acquire); + return nvme_pr_command(bdev, cdw10, key, 0, nvme_cmd_resv_acquire, + blk_stat); } static int nvme_pr_preempt(struct block_device *bdev, u64 old, u64 new, @@ -2179,7 +2190,8 @@ static int nvme_pr_preempt(struct block_device *bdev, u64 old, u64 new, { u32 cdw10 = nvme_pr_type(type) << 8 | (abort ? 2 : 1); - return nvme_pr_command(bdev, cdw10, old, new, nvme_cmd_resv_acquire); + return nvme_pr_command(bdev, cdw10, old, new, nvme_cmd_resv_acquire, + blk_stat); } static int nvme_pr_clear(struct block_device *bdev, u64 key, @@ -2187,7 +2199,8 @@ static int nvme_pr_clear(struct block_device *bdev, u64 key, { u32 cdw10 = 1 | (key ? 1 << 3 : 0); - return nvme_pr_command(bdev, cdw10, key, 0, nvme_cmd_resv_register); + return nvme_pr_command(bdev, cdw10, key, 0, nvme_cmd_resv_register, + blk_stat); } static int nvme_pr_release(struct block_device *bdev, u64 key, enum pr_type type, @@ -2195,11 +2208,12 @@ static int nvme_pr_release(struct block_device *bdev, u64 key, enum pr_type type { u32 cdw10 = nvme_pr_type(type) << 8 | (key ? 1 << 3 : 0); - return nvme_pr_command(bdev, cdw10, key, 0, nvme_cmd_resv_release); + return nvme_pr_command(bdev, cdw10, key, 0, nvme_cmd_resv_release, + blk_stat); } static int nvme_pr_resv_report(struct block_device *bdev, u8 *data, - u32 data_len, bool *eds) + u32 data_len, bool *eds, blk_status_t *blk_stat) { struct nvme_command c = { }; int ret; @@ -2210,12 +2224,16 @@ static int nvme_pr_resv_report(struct block_device *bdev, u8 *data, *eds = true; retry: + if (blk_stat) + *blk_stat = 0; + if (IS_ENABLED(CONFIG_NVME_MULTIPATH) && bdev->bd_disk->fops == &nvme_ns_head_ops) - ret = nvme_send_ns_head_pr_command(bdev, &c, data, data_len); + ret = nvme_send_ns_head_pr_command(bdev, &c, data, data_len, + blk_stat); else ret = nvme_send_ns_pr_command(bdev->bd_disk->private_data, &c, - data, data_len); + data, data_len, blk_stat); if (ret == NVME_SC_HOST_ID_INCONSIST && c.common.cdw11) { c.common.cdw11 = 0; *eds = false; @@ -2245,7 +2263,7 @@ static int nvme_pr_read_keys(struct block_device *bdev, if (!data) return -ENOMEM; - ret = nvme_pr_resv_report(bdev, data, data_len, &eds); + ret = nvme_pr_resv_report(bdev, data, data_len, &eds, blk_stat); if (ret) goto free_data; @@ -2286,7 +2304,7 @@ static int nvme_pr_read_reservation(struct block_device *bdev, * the response buffer. */ ret = nvme_pr_resv_report(bdev, (u8 *)&tmp_status, sizeof(tmp_status), - &eds); + &eds, blk_stat); if (ret) return 0; @@ -2302,7 +2320,7 @@ static int nvme_pr_read_reservation(struct block_device *bdev, if (!data) return -ENOMEM; - ret = nvme_pr_resv_report(bdev, data, data_len, &eds); + ret = nvme_pr_resv_report(bdev, data, data_len, &eds, blk_stat); if (ret) goto free_data; status = (struct nvme_reservation_status *)data; From patchwork Tue Aug 9 00:04:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12939210 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4E6BBC00140 for ; Tue, 9 Aug 2022 00:06:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660003586; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=slN9z2zyF4vuvrdmNFSHp5PGgKXT9Xo5XJKnl4T8kCw=; b=ZT/11E0vF8KhRbyRjIVkOmVQucAEbba5cEjaaGDdL/8dku8aTGxJGyIgOujJr2gHxXzu+a tL5jp720W1QMCFVW356vRsxVfJ7EL91evlGji6gD3RBwSfCw7qwMIfSU6+seRHj33uNTnU o3hIUKtwsasTV80jcNxQvfZd4obZVEc= 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-398-60L5O73kMuGuiLxgQ-12pw-1; Mon, 08 Aug 2022 20:06:21 -0400 X-MC-Unique: 60L5O73kMuGuiLxgQ-12pw-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 E10E8280EE33; Tue, 9 Aug 2022 00:06:19 +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 C8C8994585; Tue, 9 Aug 2022 00:06: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 E61971931A52; Tue, 9 Aug 2022 00:06:08 +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 1DBF31946A5A for ; Tue, 9 Aug 2022 00:06:06 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1388E40D2853; Tue, 9 Aug 2022 00:06:06 +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 0E9D440D282F for ; Tue, 9 Aug 2022 00:06:04 +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 8AC24280EE2E for ; Tue, 9 Aug 2022 00:06:04 +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-213-C6TPZmh3NPaEczx0d9cBgQ-1; Mon, 08 Aug 2022 20:06:02 -0400 X-MC-Unique: C6TPZmh3NPaEczx0d9cBgQ-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 278NwIiD007165; Tue, 9 Aug 2022 00:04:46 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3hsg69n1e1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:46 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 278M0wO9034454; Tue, 9 Aug 2022 00:04:45 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2102.outbound.protection.outlook.com [104.47.58.102]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3hser2da0q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:45 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by CH0PR10MB4907.namprd10.prod.outlook.com (2603:10b6:610:db::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Tue, 9 Aug 2022 00:04:43 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50%6]) with mapi id 15.20.5504.020; Tue, 9 Aug 2022 00:04:43 +0000 From: Mike Christie To: bvanassche@acm.org, linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, linux-nvme@lists.infradead.org, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Date: Mon, 8 Aug 2022 19:04:13 -0500 Message-Id: <20220809000419.10674-15-michael.christie@oracle.com> In-Reply-To: <20220809000419.10674-1-michael.christie@oracle.com> References: <20220809000419.10674-1-michael.christie@oracle.com> X-ClientProxiedBy: CH2PR03CA0006.namprd03.prod.outlook.com (2603:10b6:610:59::16) 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: 8874b115-c290-46f3-d0d6-08da799ac2f6 X-MS-TrafficTypeDiagnostic: CH0PR10MB4907:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: b/JJ6lpmlZEhiBohok6kFkbGBwAoEdjdTxzXSer1fqLkiXvSrrw8IrMAN1lNxz5qFr2oWJFbT/XUpmOAf3YpHSNHAcubXEbRL+9W7uPJEpXqVHJqIe9P7GhUWpKb82qT4vNQn2SIr/W/svH7J4eEBPEtm0H2uaZedo7IG9j96V8QVJEG4yyB3tAP0tv4heaTu3Lo4/hH6yJ9Mc8oQY6yJfXb+16wFZajzwzhqkO5GS+cu/HHVueIUI+vRl1KiBTowN9MlvOZCoLhOt+t3jk4+UEkH5BH6BIPXzWzFR7Ga8pzcF6kACJvMzE7isjQvpZnO3NpyG9CRiw1d7PNF+DdEy+wKT+66pIOlNRUMdrzU/5jE8gHRIbUvC3mFPdcDNQb+wNEeX+tn+E9DQHrGNOWDhFfkGY4/626eVDkGjeYP7SUjHmPoezaI0WTbTZtAUCmkEzUxQUJCJ7AaQEng/kAn4lOGt45Ko5pki8W+Sz5DPYLaGWbWmE1jvQHA+A8SxhANaKmbAukH82+kuYHg8nWE0owKeISaeLAbLRMmNe9ZTm+BA9Q62aisrm8P19tCR7fQEkIEfxxMQ+AkOXTw2RBGJ64woiBkpS9v2LTBsNDsw1dX4MPDuraH9d7maMZxEZmB2IQEM9GwC8YRc4Ths8d50AQXygrcc7Hxo/VII7HCoW4BOBfLQm9lchddFUNdkTMV82CWWEfpe24NcWYO18jtltnu3bCNF2d3d5rKzHkKycGRd0q1aI9p21ghVQ4AWRIdt01b7PhlhQLHy4/DI9PRFw4SaKjSBz/WTj4MMaGXxw= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(396003)(366004)(136003)(346002)(376002)(39860400002)(921005)(6666004)(41300700001)(6512007)(26005)(2906002)(6506007)(83380400001)(2616005)(107886003)(38100700002)(86362001)(186003)(6486002)(1076003)(316002)(66476007)(66556008)(36756003)(8676002)(66946007)(4326008)(8936002)(478600001)(5660300002); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /eOoq/2LRGtDIPc89ZXWSsy9muV82DbcC6hpbHiuorLtUIpnjQeSf10upXxwYFQTI1Rhq2ld5X4j5rFsaD5X1E0sqVBBw3nIMDlS08pBFcHI7258yoLOqQqxs1PsoxfYchu0wtYNZnPWQcK6+NxcEKzTIogGuCsPrg8Tbx/TZzFwq84s8QzBgZLdBORZXxGpVj5g202ZvRq7ypAUt0DsAntDjos8EE3tVsZdl5QDED6X903p3VZfmvMbZhvIQJH+5a8j+8vncr9Oz00kID6AieiQYBfFhZKYd66fFF0AZ0dPGSvmUrsWC8KlRW4mKv5E+qJPOZEMhCiMR/3Xr5MEtpw9ki0RZZOPOxMKHf6A2qHeVPA7XEUJxfzgUxqKqwTuLGMBFImumxN/j66ZgQX4UaKTTHzNHq3OXwe9mkG6p+u7+CK6YZ7a1ukpDeEprIVs8Pbtht8Gk3nlBIFnR51cFxmFBlTQgsqvk2EP94Z7VNdXX8iv9Nuk9iMkMtmZePyTgMG4zCbzk1mo7CkQGeSut7r4wmK9yWLs/BzIn3zDW4NkKFAHzbxpvCgYdk9rGybH9xpbGcXnHYbG61MzSWCm66ZsgwsniV0H/mqWRzCwI6hbTDeOpM0cLMmRzuDtapOf8F+wefcJbcg5/u1EzJJEFVV+DXJhfiBRQqG7d9nWbH95JNrkAQYGu4yiT5FDDtb1x2BxpIBuea2CnJ3jdTxnqoKqqu0wbbysJ7jh0nfRgSZ9UG4Tl2wxJvpNxFbjvaIcHcKP1KA9yYHaso2ni1fOi++ksai5/xghIdmTomvWOGZI+bvQjMwQmAU9i2dmuA6d72MUqUiKzpPzXFmeLpB0PfRoHDAZjgicnnfEWHSDG9Uv8GXwo/dL9JnGFSEN9jdS6RvYIpkMaWtL/StnPoY3jbtb8Hr2Z6M5+NrRAoJ/mmc5NnxsWXiTHQ2/9q0VCR888hu1/eLdD7yuVYoS+WM2e+PvL5FDkNwN1V/+OahQltpFK0ctJPDcKWXFbbPQE1kcf2uxO/i88pzSJvO8xhEWj5ity1XfFiz4JacojBAtO3y5G1ZE9PQ0DwGL3TiL+7i8rmRB0VDJZ1k9OMq4szTmH/3551zm5iOIO4Aysa/8n2+hCDg6vIj5s7jkpwh1PHL8TialePdMTbCRfPmoYtwApOZEK+pU/6uYujLsFxXCWIdImc6XtJ27pkTQSBy1l+b2pLlSE8pX9GblsITy78LjpVtMrI2O6pGvSIUFnSsE84dmSD673tHrAWYsFFvRlVUJUkQkFMeooyBQXMyVQhOecDSmwkf444xtZK/xNrgp40XNICr3gIJM7Tj/ML5gIpUUvQG6gGPE0xLTnJSkCaGhyDCuMkQriHRuAxigqAX4hhtniAc8TzHlCqDPnNqecwSvw8/npz6PauA25eE2MPdZaohuOgBHgaYfOl9ev7er+Prnmq+2j1rD+j8pVf3ytGirfMIxIxKdVBz0VfJeWByG5p+eibiIL7An2PiIKK+6LRBl+SGcXpeINOjTSVgAkQxkBYupsixULQedARCsKKCM9bY/cDMVjfVSAqI6MzMUIN5LiXWj+JPgJcnnM4n73ZaFa3YFiPIDi7/xIo/k3CiCcg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8874b115-c290-46f3-d0d6-08da799ac2f6 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2022 00:04:43.0788 (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: au53tZraDiAjdOSK1D9NnCqVOCpxmhdS+6pEfIzoMLsolqeJ67XVOX/53OrRUMr4ZhS1UHpQNqigIIcStEKX3Mv0f8zvF0lSLqVuxTBhVOo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4907 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-08_14,2022-08-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 phishscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2208080105 X-Proofpoint-ORIG-GUID: Y0VAjduY87uUNDlhDcuZtj02BaigFyBp X-Proofpoint-GUID: Y0VAjduY87uUNDlhDcuZtj02BaigFyBp 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 Subject: [dm-devel] [PATCH v2 14/20] scsi: Retry pr_ops commands if a UA is returned. 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 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com It's common to get a UA when doing PR commands. It could be due to a target restarting, transport level relogin or other PR commands like a release causing it. The upper layers don't get the sense and in some cases have no idea if it's a SCSI device, so this has the sd layer retry. Signed-off-by: Mike Christie --- drivers/scsi/sd.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index bf080de9866d..61e88c7ffa44 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1683,6 +1683,8 @@ static int sd_get_unique_id(struct gendisk *disk, u8 id[16], return ret; } +#define SCSI_PR_UA_RETRIES 5 + static int sd_pr_in_command(struct block_device *bdev, u8 sa, unsigned char *data, int data_len) { @@ -1690,8 +1692,9 @@ static int sd_pr_in_command(struct block_device *bdev, u8 sa, struct scsi_device *sdev = sdkp->device; struct scsi_sense_hdr sshdr; u8 cmd[10] = { 0, }; - int result; + int result, ua_retries = SCSI_PR_UA_RETRIES; +retry: cmd[0] = PERSISTENT_RESERVE_IN; cmd[1] = sa; put_unaligned_be16(data_len, &cmd[7]); @@ -1700,6 +1703,9 @@ static int sd_pr_in_command(struct block_device *bdev, u8 sa, &sshdr, SD_TIMEOUT, sdkp->max_retries, NULL); if (scsi_status_is_check_condition(result) && scsi_sense_valid(&sshdr)) { + if (sshdr.sense_key == UNIT_ATTENTION && ua_retries-- > 0) + goto retry; + sdev_printk(KERN_INFO, sdev, "PR command failed: %d\n", result); scsi_print_sense_hdr(sdev, NULL, &sshdr); } @@ -1776,10 +1782,11 @@ static int sd_pr_out_command(struct block_device *bdev, u8 sa, u64 key, struct scsi_disk *sdkp = scsi_disk(bdev->bd_disk); struct scsi_device *sdev = sdkp->device; struct scsi_sense_hdr sshdr; - int result; + int result, ua_retries = SCSI_PR_UA_RETRIES; u8 cmd[16] = { 0, }; u8 data[24] = { 0, }; +retry: cmd[0] = PERSISTENT_RESERVE_OUT; cmd[1] = sa; cmd[2] = type; @@ -1794,6 +1801,9 @@ static int sd_pr_out_command(struct block_device *bdev, u8 sa, u64 key, if (scsi_status_is_check_condition(result) && scsi_sense_valid(&sshdr)) { + if (sshdr.sense_key == UNIT_ATTENTION && ua_retries-- > 0) + goto retry; + sdev_printk(KERN_INFO, sdev, "PR command failed: %d\n", result); scsi_print_sense_hdr(sdev, NULL, &sshdr); } From patchwork Tue Aug 9 00:04:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12939249 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 70F30C25B08 for ; Tue, 9 Aug 2022 00:07:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660003626; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=TMLWT/71B1+2SHTnhe+lTgjU7oC15mQny2m3dLN0+Bg=; b=f97XA9E0R0LMFGA9FiybUUHLWESCZW79scb3bgREyL60dvNiDgf7lTZCgYk0mpNSwbT1k0 ESKY65fQQNCpp10XnGA2HxXDd/q/BnwzUcQ6r1RgAJrqXe70Y53JXJAN5lZYFkWNPLSiUw e9i4TCxhLWcXIEGVGQsYMliP69boPgc= 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-562-ePr03g5wPHup8WqB4jD0Kw-1; Mon, 08 Aug 2022 20:07:03 -0400 X-MC-Unique: ePr03g5wPHup8WqB4jD0Kw-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 E139C80A0B9; Tue, 9 Aug 2022 00:07: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 CCE4C2166B26; Tue, 9 Aug 2022 00:07: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 88A3A1946A50; Tue, 9 Aug 2022 00:07:01 +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 3C09A1946A4F for ; Tue, 9 Aug 2022 00:07:00 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2166F492CA2; Tue, 9 Aug 2022 00:07:00 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1CB76492C3B for ; Tue, 9 Aug 2022 00:07:00 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F39428001EA for ; Tue, 9 Aug 2022 00:06:59 +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-653-93ahaJ6KNNmZwHXZnRpcHw-1; Mon, 08 Aug 2022 20:06:58 -0400 X-MC-Unique: 93ahaJ6KNNmZwHXZnRpcHw-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 278Nwhfj031116; Tue, 9 Aug 2022 00:04:47 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3hsew155hk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:47 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 278M0wOA034454; Tue, 9 Aug 2022 00:04:45 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2102.outbound.protection.outlook.com [104.47.58.102]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3hser2da0q-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:45 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by CH0PR10MB4907.namprd10.prod.outlook.com (2603:10b6:610:db::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Tue, 9 Aug 2022 00:04:44 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50%6]) with mapi id 15.20.5504.020; Tue, 9 Aug 2022 00:04:44 +0000 From: Mike Christie To: bvanassche@acm.org, linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, linux-nvme@lists.infradead.org, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Date: Mon, 8 Aug 2022 19:04:14 -0500 Message-Id: <20220809000419.10674-16-michael.christie@oracle.com> In-Reply-To: <20220809000419.10674-1-michael.christie@oracle.com> References: <20220809000419.10674-1-michael.christie@oracle.com> X-ClientProxiedBy: CH2PR03CA0013.namprd03.prod.outlook.com (2603:10b6:610:59::23) 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: 4e026638-f8f5-4c3d-d4c7-08da799ac3e2 X-MS-TrafficTypeDiagnostic: CH0PR10MB4907:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: l6dQiQk4CJoci2YIlEjENFhiBDEKX3oQjnb2kgzxP2k35S/lQnH5PL+33AdcGYiEB+g7UnxM94Gj4T+nigZbYI4L5tPvp3MCQ2bK/16eWKttWpzyCi5kL3W/zlJs8QtH/PxlsUv1s45LQcHzbcYKo7rtH5VofIi9I55m7HLUhbcEDX+Pe0snxi3IqGghu7LO88Ylvb+5wRsyC3gc/aIRHxj5dD+BFOnwqxPBjnOU2n8UwPA3Wu4psOAxzzWbBSn6gDkcLDs3qs2FauxLk3m/3uSpfYDNaUYyZpphKnXelLTPGY/910PAZuC6XAck5uXRuKGULyzEMofX3M5dpFo2A/ua15OITHW/UsMWOUzkszNxusqSAESJMPoXApFlkdBgB1olo4wXlavrWAfzew02fMFTllOuGzw0cPWM9pzdvhRia4Lx620JLctYZ9yDXoBdHOAX3/t5ECx8STM4JcY2bSwpRfQJetj5M/lDKpqxP/Zou4zDuDBY4z9oDuEfMqtZ6N/UepVn+fEBg9B3fZn5v1Gu+MvhqBkPqWhf+Skh9i2W6KSC+ho6DnfUpfzSOdUJp96+AVzBu4Ho7vNZ6Ksjbjbanen5SZqfYPcQlSzuWPR/ssT9/3gqb6K8Wuyf+OoLU7voqzY1tBrkxaravLIb2hsBo65i7tI9wi0JVMDEnSjzwLIDGvp5c6/GLuwyXJjtu47SzOigq8EoD8cpta78xky0qfQEKaMUVxhiG67tJuUd8jm9lC6uupKk49TxpMYMGFDUZfrEQJhMj1VZThxH5e1Ya/h2Ib3vWE4I/WXCovE= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(396003)(366004)(136003)(346002)(376002)(39860400002)(921005)(6666004)(41300700001)(6512007)(26005)(2906002)(6506007)(83380400001)(2616005)(107886003)(38100700002)(86362001)(186003)(6486002)(1076003)(316002)(66476007)(66556008)(36756003)(8676002)(66946007)(4326008)(8936002)(478600001)(5660300002); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VGPAvg+HVdIYIMtlW4dZZ5GVmcftTne/n8BcwXIreyXVNPzLRyZmgGzN4NhXI4WtFS/2p/Evim1j92/BFYNz6U4EGtzhtxMetWvgpBP12Thqqvu3s+CXcOwepQM14PdgEKcaLiVIaREQ21/kg6EU7ezyX8+F4Wwyvy5zezgTz0l5taMINHM2xHXmd/riYw+aP8fronCI4hQUOdXrnT2JbjyqEuGTcyTF9+JR2QFxfrlr0rp3+BtZin4srhw029dy3d5mKMrNmNzshBcs6SByuulgJvbHNyVjjPHPuJ6B1PKRZctXpBwiaDDWEECrhP36/kCrTSpugPS03Xx3kKgzxQwaGIirbxV2tu0fn5ppm9yVcgFmguYgkdQmiJpcbOAKZiTjhkCeUAsEo+adIFzKOSBRfpqNbL6uv2YDX/A4BWSPW5F1pnPdaFVSy8X097gLySeaULFDM6HnRaoEXFDhSIcEA6bRaRn8Ek9dF6ezM/LbLmUBSSQHtKT6h576zu59o7G3XmzUNOUHxV4VpXHeLiwefT+WcITTbRUrjMxyaDYknjjiTpg+Izl4Z0ifwXuudBOGb27gHE4Ibc/vLlBkpZcV+Rg+50/lQYjnqAIK5oWoMRNfsQsIGP9PmgRKoJkOxl6p0nhU+sMm5Zj9EEUqQUt/B1TCqJbcyp7kD6y8INhV2pggisMq+hb26ihv/BemefrzU3iySVi8Tb4R7q2u5f7irC82uW9yWvbtjLg29EDEoPN21pahddtUGnXR7WYMsk0qQB+p9GWJ0ZAk/LcVzUgw5thHIIfyDYdFeNEWSVGsOVXGX2aHPYn+7tNY/fbPxE5TfsHMKFaWLwXjK+1d+FFckxoLPgDlm1bshunZeKB+pM+T+E2Bj3HwoMANBQgD/Dlx/P1nSbFJxTnFatxoovlJmpyZRzoMKnhZQ7ivRFedDI5Uj2KRY+5ZeBPEl1b/Aq25ODg6ipmHtPCbm8kgg17ApeaINKYSsBBVtVoMat7QjOaXwU0M1moOjDufe7EPN8S0RnTNPUuFgEGk+VGHfe8bV4EXyRhRgPVZnnNIwqTELjpKWUpYEh4/jIoMHniT/+fv/UFvzLHnbPbf/UnIN/38sJVjUaGeLPNz1L7FFJvKAix4GZCRxWexbCOBJ1M8OLZQKXkyTI9vOXMRWrib+Vo+JeJqFTMT7i3qSWcUbi2aflnFhrlymMOK/I4AFxI/VAIE2SF+d9BnNsAJ3Q0b7qyG9Fx289MP86ZvGK92pTNqnNIAHgSajOicpLfYDbxyetGDz5F/2Qm8jSrzI5QjLJoUwtNSqadvWI3FGQ0qfuTJpDlrrnthZCdm+BfVb5TMX4ytPKyArFfWru5NloTK+GFp18lkLQfFQYmm4W/nSOlJ/twowW4w4IqGUJ4EpUMat7uehOVqexRzGXMCLhi9eIRawN5DfBM39qkmh26MajBqHw8M4PE/PXEquU0nEnA3ano5bG36C1puhAFiinQNy2lAIjJ2DgGMglJ1j+x9THJQTmItsKMZmzo+NrCcS23Wi0f65odTNKIMM4Nujawoh1QwlwtQxLh1QgwHBS85ERy9UxhIj5IJss/p90TgfNk6F2y9gJiejif6wyIWda6LpA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e026638-f8f5-4c3d-d4c7-08da799ac3e2 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2022 00:04:44.5787 (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: UAsYdiRwxLGLg14hxrHoLUiG3ly5vj2SlFqjKBsEMG6ubq6wVOD1Qy2IslUsrsBEZky7hAOP3m6jYOJsriWIP7HN4eKHL0aLMuDB2A6NUiw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4907 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-08_14,2022-08-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 phishscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2208080105 X-Proofpoint-ORIG-GUID: eGr85Xv6ZWE4f5jBH31vF5JyTyVnOliB X-Proofpoint-GUID: eGr85Xv6ZWE4f5jBH31vF5JyTyVnOliB 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 Subject: [dm-devel] [PATCH v2 15/20] scsi: Export scsi_result_to_blk_status. 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 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Export scsi_result_to_blk_status so the sd pr_ops can get a BLK_STS error that can be returned to other kernel pr ops users. Signed-off-by: Mike Christie --- drivers/scsi/scsi_lib.c | 3 ++- include/scsi/scsi_cmnd.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index a2a3a9bd5ba1..d7825ff8915d 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -587,7 +587,7 @@ static inline u8 get_scsi_ml_byte(int result) * * Translate a SCSI result code into a blk_status_t value. */ -static blk_status_t scsi_result_to_blk_status(int result) +blk_status_t scsi_result_to_blk_status(int result) { /* * Check the scsi-ml byte first in case we converted a host or status @@ -618,6 +618,7 @@ static blk_status_t scsi_result_to_blk_status(int result) return BLK_STS_IOERR; } } +EXPORT_SYMBOL_GPL(scsi_result_to_blk_status); /** * scsi_rq_err_bytes - determine number of bytes till the next failure boundary diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index bac55decf900..c4de69ba859f 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -155,6 +155,7 @@ static inline void *scsi_cmd_priv(struct scsi_cmnd *cmd) void scsi_done(struct scsi_cmnd *cmd); void scsi_done_direct(struct scsi_cmnd *cmd); +blk_status_t scsi_result_to_blk_status(int result); extern void scsi_finish_command(struct scsi_cmnd *cmd); extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count, From patchwork Tue Aug 9 00:04:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12939251 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0CE6CC00140 for ; Tue, 9 Aug 2022 00:07:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660003641; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=UlV6tqr7kPviV5RI0k6KwhF7GAYhjJASD5jAufJvkeo=; b=hMfjrqq+ek3A47tg3rKEp4gHUdPBI6ytODf6IS7TV0/aF4WiB83tt6+cMDpLAE7I3WOKwJ ywpSoJDb/qc2c9KJAgpYG6msmQP8hdPIse80AQszO+O55kFVT+iCmnHjnQxTtj94yul76f J0RpjGdRm47vKuXV9+/e0+3rulMhy7s= 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-134-9Ta3BNrCP2mEyQTLR-zIjQ-1; Mon, 08 Aug 2022 20:05:21 -0400 X-MC-Unique: 9Ta3BNrCP2mEyQTLR-zIjQ-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 25C993C0D188; Tue, 9 Aug 2022 00:05:19 +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 11CE72166B29; Tue, 9 Aug 2022 00:05: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 C173D1946A50; Tue, 9 Aug 2022 00:05:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F20C91946A4F for ; Tue, 9 Aug 2022 00:05:17 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E36051121315; Tue, 9 Aug 2022 00:05:17 +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 DEA301121314 for ; Tue, 9 Aug 2022 00:05:17 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B2355801585 for ; Tue, 9 Aug 2022 00:05:17 +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-497-PnDWohS1OWuon3H3Rbc6rw-1; Mon, 08 Aug 2022 20:05:15 -0400 X-MC-Unique: PnDWohS1OWuon3H3Rbc6rw-1 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 278NwVuV028542; Tue, 9 Aug 2022 00:04:48 GMT Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3hseqcn0mj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:48 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 278M0if4014103; Tue, 9 Aug 2022 00:04:47 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2102.outbound.protection.outlook.com [104.47.58.102]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3hser8emhy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:47 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by CH0PR10MB4907.namprd10.prod.outlook.com (2603:10b6:610:db::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Tue, 9 Aug 2022 00:04:46 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50%6]) with mapi id 15.20.5504.020; Tue, 9 Aug 2022 00:04:45 +0000 From: Mike Christie To: bvanassche@acm.org, linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, linux-nvme@lists.infradead.org, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Date: Mon, 8 Aug 2022 19:04:15 -0500 Message-Id: <20220809000419.10674-17-michael.christie@oracle.com> In-Reply-To: <20220809000419.10674-1-michael.christie@oracle.com> References: <20220809000419.10674-1-michael.christie@oracle.com> X-ClientProxiedBy: CH2PR03CA0029.namprd03.prod.outlook.com (2603:10b6:610:59::39) 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: 8e1c2df3-de6e-4612-dacd-08da799ac4af X-MS-TrafficTypeDiagnostic: CH0PR10MB4907:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: r/1GW7KuDsLs7WeMwueB6JREcwwT73ev/U76Xy+0HO1xlzEuWuvXQw+Qje5TT5thxDrBgqQWvo1NU44jMoPSevWVdUaJCHmS2vZBVM74JNYs8i+Dt2Q6VKujD5CXODzvln2+IDUQeXu9iqam33dL8JBNoKh7v2Svpk/Xl12xF1Pme1cSZ+VVoX/2SgdmIBBP8hvZmrDq98VjZKRSFbzc/J9NUxbg627Nb/dER2HZ7/Xcf/8sZdLqNw/LBJuSAqBXkG8LsBGLUy72IsbU9Hj5+DiCmRrlhST23Y+aRuk6Z5bHwh3+R0YOS8bH6qPhZIUVYHCI60zrYlmRl2vSCFnCeL6zNWSDPHUBbeNZ+4x4tWJZ5A5tYl6YxK1wBtTxYePqaydHtLkYXL97KQvECObG0E5ASZn/4bWvMAeTnx3MizoylX85LGn2XeuhgGQR4BkescaTP6wM/n1P4Cg3qX7A7oCFDWJ6zvscs832eJXARligU3geNFV5UoVMZvRG2//pWnvdIXTXZc6JiIPETtPHDXuQhZMfJh19aj5/7ugm/e5A1O+VzZKSDxxP8p6LmfyMfjEv78IVv3OgX6x2mytaot7O5fqGOCFWMyk1LcV/veaa1VQ5gbIdkmFZLKwSIPgOV0Rg2NHS3Ev20Mm7FroghfglcmO4hLNfbaxJP8bMkQPi1Ca5M4P1XN2BqzTDDDwP6DmQN5ep7EY4yYcd7GxjOn0qwBpkRXpricTvPT44BYOGPu+zVVgoUdGLJapaPl588HxXi7JyHn2y/Sa990Ql0vx8X+K5cqSY+3j8KSY0JG8= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(396003)(366004)(136003)(346002)(376002)(39860400002)(921005)(6666004)(41300700001)(6512007)(26005)(2906002)(6506007)(83380400001)(2616005)(107886003)(38100700002)(86362001)(186003)(6486002)(1076003)(316002)(66476007)(66556008)(36756003)(8676002)(66946007)(4326008)(8936002)(478600001)(5660300002); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: scM1GqmpTc4LsYdtitXVJnVVUSZ2B1dsgIA31wBla5C7e4HaEfIm6bBRcPv+aIKKhOII8KrmBM+d1eapeVdoZ5bQ5ZqWQ30NY/zwuLvaJYQa8htPgJStFN1HF06eMgfbDhuRWlRFCD6B1ycxF/AsL7HCwXD3H+kjQoK67nYTZUrXwQraanVSvdY6JwG3+TAG8Nn6YCk1VRTBqibc5CMoKcFNGgUSRkjFnq4XyA/QgdlbYcTJ0P92qUxIZKLOvsHe3qSNZ3bU11aZOIoOFPqFSpm2K71joObv1wEY2I9b6afvH2eN1eMWngvaaLzqY/QbVfqycuXdrX67FaS5dUvh92BAfIAPS4UWOWyJ/2VAud7u4StB02SavKqjHVIj35MRPN36ZSzFNerPPHdESejwa84CnL7t/B00J76X0NGvsNA7RgIED5SLkpU9oiYs9TBTsAoHQuxdBLks/oqWNkZ/7Bn7qglkzj2Nk8AFVvm2qgHaxDeHfKcjK7Upm7rJNhvSWDxMa/a19FlKxRkscs5UT/KetNSAwdJWka4GSQzkVfedrz2uLQ16p8JpJ2Uv+b3Ozcuuj5ZPlXEKX3J7GwlDHj7JX6eMSna/gSinJ6b1Tcqx1nnHEk8C4q7Vdhtbzz0y+Fy7LY2coyePMr5L0DzryjsfZnOtue+lroNfwRzqVnw9tWSFslAa7cbfqyGaeOokKQHJkpBixGYY8eJrZUYMbv3l7ctLgY47Ut+jPLE0wRFE2Uoe97Uo3+UEkkv9ORWZ5j91s1tpqjODxJs12tAVt4dEckQhUnIVLS03JAx+tmOmIGTrFXHAA9jcbFQpyx6sfqYv0BGhrjK8bR5PPcEcxo+4dAhYEXkR+pyLbAVhxJYQ3m7XvfCuZVglUfS0KtTBbvcBDRCy96QAfHmCqIM7U7/ZOmmGMgbHZ1hF7ZF9d+iqyXcXzVcs2LOVvzZ1hcintRhFrHjuc6EXM8jXmBvTUt9klF7XV6aIsf5HgfS8dew8jEyDpQkxv9Sg3vt1uDfE0m7B3CgYFVMQkc7diVB11ZVuumV4lrkaa3bImttMohKH4FF/JXXVIysctiU8cXjlZI4Gs4kZoNXO8j5C7PaLyhcFj0IP5xYz4oQARGmvz1oSB1TL8BJURcaF8a35WNCfmzCIKdCpEro7M6me7b4ms+eSFSY+ld9hiIpJDqlqEQvadYt0QNE3pzObA8BV2Qrjx7QggvPZiCYmvCdoYSybViiRDrjd8yClDRQR61aZFc2khPLvevvgTuqTEouI99UH6FcvyTwL1B+5l7/bMaDMOiqvic+tNe7toKALQrOlmvBwZ/3TFxZXclvJjzzkPk77mdCJruVj6a+mHixyzzbtppnma9TM5WiRSgR6s5H5WTVdCEtU56u5kFK6ZBEVtSZLmfkVi28/D8eusmlDS1JmZzcDd26dpNO92m4Wa4m3wlFhRPjxaA3p9MRnCGIgDkpnuAFLoqr8ToEF5BoR+lga3k+KIbU2ykcK8BkwuJQVNkOHIdANSDg7+g6cWr6d4exqVnfH7wd1GGZVLPQgnR4FysEMaJkx6ZbIpbKtEnkWc6ChisOnU4dsxbLUDzASwJpjy92ybPoPdAKgTUR1S5kmMw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e1c2df3-de6e-4612-dacd-08da799ac4af X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2022 00:04:45.9380 (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: rkcRt3rUE67iHYvlYrJUs66CyfeG8H96Q6GBzQ62cIoLEY55hX/k+Jy9rjIdhOt4uM4Fu2vOKTcvQzN+R9UC3YQfc3GMGcjDkOo5OFVDAo8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4907 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-08_14,2022-08-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 suspectscore=0 adultscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2208080105 X-Proofpoint-ORIG-GUID: OT81z6P8j08-tVbkdrnIe3ptuUH7nlob X-Proofpoint-GUID: OT81z6P8j08-tVbkdrnIe3ptuUH7nlob X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Subject: [dm-devel] [PATCH v2 16/20] scsi: Have sd pr_ops return a blk_status_t 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 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com This patch has the sd pr_ops convert from the low level SCSI errors to a blk_status_t. Signed-off-by: Mike Christie --- drivers/scsi/sd.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 61e88c7ffa44..31b4eafadc44 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1686,7 +1686,8 @@ static int sd_get_unique_id(struct gendisk *disk, u8 id[16], #define SCSI_PR_UA_RETRIES 5 static int sd_pr_in_command(struct block_device *bdev, u8 sa, - unsigned char *data, int data_len) + unsigned char *data, int data_len, + blk_status_t *blk_stat) { struct scsi_disk *sdkp = scsi_disk(bdev->bd_disk); struct scsi_device *sdev = sdkp->device; @@ -1710,6 +1711,9 @@ static int sd_pr_in_command(struct block_device *bdev, u8 sa, scsi_print_sense_hdr(sdev, NULL, &sshdr); } + if (blk_stat && result >= 0) + *blk_stat = scsi_result_to_blk_status(result); + return result; } @@ -1724,7 +1728,7 @@ static int sd_pr_read_keys(struct block_device *bdev, struct pr_keys *keys_info, if (!data) return -ENOMEM; - result = sd_pr_in_command(bdev, READ_KEYS, data, data_len); + result = sd_pr_in_command(bdev, READ_KEYS, data, data_len, blk_stat); if (result) goto free_data; @@ -1753,7 +1757,8 @@ static int sd_pr_read_reservation(struct block_device *bdev, u8 data[24] = { 0, }; int result, len; - result = sd_pr_in_command(bdev, READ_RESERVATION, data, sizeof(data)); + result = sd_pr_in_command(bdev, READ_RESERVATION, data, sizeof(data), + blk_stat); if (result) return result; @@ -1777,7 +1782,7 @@ static int sd_pr_read_reservation(struct block_device *bdev, } static int sd_pr_out_command(struct block_device *bdev, u8 sa, u64 key, - u64 sa_key, u8 type, u8 flags) + u64 sa_key, u8 type, u8 flags, blk_status_t *blk_stat) { struct scsi_disk *sdkp = scsi_disk(bdev->bd_disk); struct scsi_device *sdev = sdkp->device; @@ -1808,6 +1813,9 @@ static int sd_pr_out_command(struct block_device *bdev, u8 sa, u64 key, scsi_print_sense_hdr(sdev, NULL, &sshdr); } + if (blk_stat && result >= 0) + *blk_stat = scsi_result_to_blk_status(result); + return result; } @@ -1818,7 +1826,8 @@ static int sd_pr_register(struct block_device *bdev, u64 old_key, u64 new_key, return -EOPNOTSUPP; return sd_pr_out_command(bdev, (flags & PR_FL_IGNORE_KEY) ? 0x06 : 0x00, old_key, new_key, 0, - (1 << 0) /* APTPL */); + (1 << 0) /* APTPL */, + blk_stat); } static int sd_pr_reserve(struct block_device *bdev, u64 key, enum pr_type type, @@ -1827,27 +1836,27 @@ 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, - block_pr_type_to_scsi(type), 0); + block_pr_type_to_scsi(type), 0, blk_stat); } static int sd_pr_release(struct block_device *bdev, u64 key, enum pr_type type, blk_status_t *blk_stat) { return sd_pr_out_command(bdev, 0x02, key, 0, - block_pr_type_to_scsi(type), 0); + block_pr_type_to_scsi(type), 0, blk_stat); } static int sd_pr_preempt(struct block_device *bdev, u64 old_key, u64 new_key, enum pr_type type, bool abort, blk_status_t *blk_stat) { return sd_pr_out_command(bdev, abort ? 0x05 : 0x04, old_key, new_key, - block_pr_type_to_scsi(type), 0); + block_pr_type_to_scsi(type), 0, blk_stat); } static int sd_pr_clear(struct block_device *bdev, u64 key, blk_status_t *blk_stat) { - return sd_pr_out_command(bdev, 0x03, key, 0, 0, 0); + return sd_pr_out_command(bdev, 0x03, key, 0, 0, 0, blk_stat); } static const struct pr_ops sd_pr_ops = { From patchwork Tue Aug 9 00:04:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12939209 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E527EC00140 for ; Tue, 9 Aug 2022 00:06:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660003580; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=7jxIXRwvFCdWVquGNOO5QhkBge0UIqqlNr5Smilv5U4=; b=bBavZ7uXeybQmXIEi6xWjHwDp8DDKLpZ7V+sY6UcqDbEtLy6CKNt+oOd1BPzYMHpCwGhgZ o5MNUXtLliNCtyB2RKNNLWJcmehNssXd4NlgHDeKFzDD78gdfO0PkvLojdYprCc2DDkRes lM+GGkgl6EeK4zEUtbKwBUxltN9diY0= 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-157-cMnBo985P6GrMn6NoqCfHQ-1; Mon, 08 Aug 2022 20:06:17 -0400 X-MC-Unique: cMnBo985P6GrMn6NoqCfHQ-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 50F87801585; Tue, 9 Aug 2022 00:06:15 +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 3D26F40CF8F2; Tue, 9 Aug 2022 00:06:15 +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 ACC151946A50; Tue, 9 Aug 2022 00:06:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 94F4F1946A4F for ; Tue, 9 Aug 2022 00:06:03 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 79618404C324; Tue, 9 Aug 2022 00:06:03 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 74245404C6F2 for ; Tue, 9 Aug 2022 00:06:02 +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 B29841857F07 for ; Tue, 9 Aug 2022 00:06:02 +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-593-hLL0g2TbPIeisLEDI1E9NQ-1; Mon, 08 Aug 2022 20:06:01 -0400 X-MC-Unique: hLL0g2TbPIeisLEDI1E9NQ-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 278NwJlJ007174; Tue, 9 Aug 2022 00:04:50 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3hsg69n1e5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:50 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 278M0wKw034430; Tue, 9 Aug 2022 00:04:49 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2049.outbound.protection.outlook.com [104.47.74.49]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3hser2da1g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:49 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by CH0PR10MB4907.namprd10.prod.outlook.com (2603:10b6:610:db::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Tue, 9 Aug 2022 00:04:47 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50%6]) with mapi id 15.20.5504.020; Tue, 9 Aug 2022 00:04:47 +0000 From: Mike Christie To: bvanassche@acm.org, linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, linux-nvme@lists.infradead.org, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Date: Mon, 8 Aug 2022 19:04:16 -0500 Message-Id: <20220809000419.10674-18-michael.christie@oracle.com> In-Reply-To: <20220809000419.10674-1-michael.christie@oracle.com> References: <20220809000419.10674-1-michael.christie@oracle.com> X-ClientProxiedBy: CH2PR03CA0028.namprd03.prod.outlook.com (2603:10b6:610:59::38) 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: 969d6b0e-ac62-403a-b5c2-08da799ac5b3 X-MS-TrafficTypeDiagnostic: CH0PR10MB4907:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: 1KumX07/vQr5FOAxiH1/nW0jPngObRpQgXtDp4zFP9rSNvzkHzHnTHZGFO53LkQh+s2mQnS0VqoYVz1u/mIwzy4TeA/8jwR5sIY1ZGrB/7hSF1bR2u0IpxcSMtErk4P2aQvSpIB5X5FQdDCAB/cM5sAx5L/n9jrdYmUSWCjsoDckjLStDJEMo4K/MF6P1uJs2gKzYVQqixZQcb1aLZGJ1HZUYmC/SQ+b+jS4s1BC5G0+resmPeUylXe/mYIOwpmKuJQROxWgW1hqTYqZWTvUwFTDRJfq99xqGL+I+4LaRwA0Rp6/j+RnUd8SOTN04rl3UAyOjAzg/Mn8L36ZmSfJntg7UvnSetZWUshwSx4i9xXfQsU30m1UQH7l8X/iYshOL6VNLK18VvHTLa+nFgZZ0xj1pM+OIcTD5OzevZT84Fmo7WLFyBr5LoAe1WpBz+ymWGrZRwgijK0lNQUgHVMlsRvS1je6ACiY0qfGQ1lvwDSlD8TvILnT+GI7TtyVOVjRwJvXmVHDpxDwJah/0tlnnmsalZyXCMO7UGPB4g77a82ZkLctCFvIknjhtFJZGecZUqdhJ3gCuIEjERD46l3ybx5y4ZPUAEvvZdlgflut8LLF7mQ8sjUEsp9vDeYGsQxL+RGfe1rTD8nUqP/crMbzyyRatGO5CnJOoiDT7ySnWVJFcNOeMKbtodhWZEfzehMjtZX0coyye/HeXJQBY8dgJGQteNXBvxRnZwCMVYawvMLM6xbvu4rDZUQiGacdg84LFtF7DowpZWRnUvckB7ikrpBaUc4dKxICge+HlZHXP/0= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(396003)(366004)(136003)(346002)(376002)(39860400002)(921005)(6666004)(41300700001)(6512007)(26005)(2906002)(6506007)(83380400001)(2616005)(107886003)(38100700002)(86362001)(186003)(6486002)(1076003)(316002)(66476007)(66556008)(36756003)(8676002)(66946007)(4326008)(8936002)(478600001)(5660300002); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: S5ufcYqIpEbWVO4/sB+X9bFnDfXtMqZcd0/0s7IFVwYe6hhbTXCPTCjBOICHpLcRLp+z59xCHKIyjeCfwOkh3ODAJ13q1Zh6BiLRH+XVTWiaoQMYC1Eex5u7H04mySEYed7ndZpEOKVOxGtL0SsJZDsmAGsV1pdncoADv20K6CwxsUcQV5FIkGhoobFNgYGU12M1yVuz8CMeXpdJ5FDL/DXrIOTZ/oZ61zUs5cKMrTBOl08KzPnff8f7Zh9qwOmB4CZ2A7eRR7ZS/lIKkWLk4wfbAVzYuCPD18C7lPPQYT4iE+fARyjr0phbrMLgG1AcPfI2zwfUcewuFOIbo/iHGj8fA+ge//sOLdILaOgSqbxde5sYJcJK4uFGgRvPonlI+A/Mkft43KcgZBpM7C5I6EZuF8OMNvsWhQwH9tiIWw+Qi9VSf6zgWp+Q3xwiyp4DkHCiITHAYcuSM6+lwlflHNrf5vvXB7OWZEJcmaU+HdHMaUbaMhjzSRN4AOePKl3K6go2Zta5Reo9rxALIkCJWE1c7NvVKrkQtQM73X3xzNa8n/LyLJqQ3gikRG59QJLgST8QtS4RrkJAUbopBVWGUAK8VOvZNcTasQNKDMxn35njQ0XZs2VxjFRCGQdX8ZVLhOD2jDrN+W1JpAne5Wpn1HykqGuHxho9MGJw7bk1XcalIokcteOpFgaY4KUdCNBpicDoOkg5IX8VWiZAlPU+PHCfO3fyOmugH7URklxdHWNAFLiEVQdMl0Fek7Q5mou1FLuHgfi0b4p0LTSbqTi2YVO1lonOiDB2cSUrgpxkd3EM1PsSqH2tVKUSQzyxr9H1sVWB/DzsEVdADUgkHeFAJHSwx2PVeiAlWf2PK/6i7mRn9vYyiCDdlDBWCdVkq9Pp2UdfY1W87QSyWbV+hi0f3eDBk4pdAR/bKRtUmiST8VlCQXIGTPr87HpzV+CsUcV3FRV8IMgD04FA7bP7eQzK1VAYNklvq0hqt3pAjAEuD4LB2Zp+QJyZbVpMZ4EbNl8qVOwTFuHDKC3LC7L82giReJ8GJMYC2QfsNmhhQTKkrmabapw2GbDzKN3e5yjmC4ZtUPZhU1GHOzgBCDvq4Z3UWQnOOvBzJFEf6ht4+ywb/GmxtErlP1+mE5+yY9xc7lqjQdtKbF6YJ+nyQg15bCGeJUFrMfshECIOtcj2uJ/dajLxpwj8FnXcCcAGsN+5p9RPqiKAVyy6xZSCPHrHF+HToaoQIaA9BYzgYRuSa6+TG+DYKB2ZV918nbE4zNcrb2lnoKvjCIpK2tVSENLPzmJH1rPPZk/F/HMhPsIR6t07kEM8saqBMPpt60j/Ab0bb2wtBfMPNiKzxNzvn01tGR86oc9alxPuL9SVNwQ1tDj9Nz5oOClJrCMIttwI4DpfaNx//Y0WpSnhn1UkPQsQs1+TXB+G4OwRXKckigS+nOdfZpKq93MCYw2b5Ry5keKbIlPabxepsmXk+7hiPoboVwvdlQeZMc7HcB/liiQ55FaKaKyzfWB4X+Xh0MWytIIL8BjofucT9LZW/xB6brAMgelwOvSfsgLumq2pSctLy4dYwMshBjVrCgVWRyOznzd/oadi9lM4FKLjXkoOfCo8h9Ahhw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 969d6b0e-ac62-403a-b5c2-08da799ac5b3 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2022 00:04:47.6566 (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: OiYdbz9gDXBg6M8LoaPz2BpXCiLbDNFbX8nVv3JZGb1v0mU56L1eLXhCSMqvq1+evFhQrid7xqc141j6mP9NV4e549sY0LyOAPERpY5/qlQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4907 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-08_14,2022-08-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 phishscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2208080105 X-Proofpoint-ORIG-GUID: gxgiBdDmaUvgmjeqe_JLM9OkmoMbwc7F X-Proofpoint-GUID: gxgiBdDmaUvgmjeqe_JLM9OkmoMbwc7F 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.1 Subject: [dm-devel] [PATCH v2 17/20] 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.84 on 10.11.54.1 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 28aa643be5d5..8336c0e0b1db 100644 --- a/drivers/target/target_core_file.c +++ b/drivers/target/target_core_file.c @@ -903,7 +903,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, @@ -913,7 +913,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 8351c974cee3..5db7318b4822 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c @@ -878,7 +878,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, @@ -888,7 +888,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 1e3216de1e04..74133efda529 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; @@ -348,7 +349,7 @@ sbc_setup_write_same(struct se_cmd *cmd, unsigned char flags, struct sbc_ops *op 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); @@ -564,7 +565,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; @@ -762,7 +763,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; @@ -1074,7 +1075,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 a3c193df25b3..c5df78959532 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -62,7 +62,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); @@ -86,7 +86,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 Tue Aug 9 00:04:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12939208 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C52C4C00140 for ; Tue, 9 Aug 2022 00:05:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660003526; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=MCcNGoo4EGqhGl5lht0YJgQLQ8Z9DdY4fhbkILfHtgI=; b=BdLKaNmlWUcoVUi4R/AW6ipNK4gaNviug+M5xcMZk3XrsSe6ADJvxpnRGK58CWZ/p/3La4 3Xqn9GRMerB7vZXxb3h8a2DXh8yPO6L5uo2hKXEeIcvaRdwyQc9BBi5V8pKjLC7nnmEYhP CG1QXYzGPxAhkZnZkKpz7aE4PdGWUIo= 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-538-4LfoIfEPMgGvbMbkGT-65A-1; Mon, 08 Aug 2022 20:05:23 -0400 X-MC-Unique: 4LfoIfEPMgGvbMbkGT-65A-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 39897811E87; Tue, 9 Aug 2022 00:05:22 +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 2696E40C1288; Tue, 9 Aug 2022 00:05:22 +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 061AC1946A50; Tue, 9 Aug 2022 00:05:22 +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 624FB1946A4F for ; Tue, 9 Aug 2022 00:05:20 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 447DB40315F; Tue, 9 Aug 2022 00:05:20 +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 3FE4D492C3B for ; Tue, 9 Aug 2022 00:05:20 +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 E4EA385A5B9 for ; Tue, 9 Aug 2022 00:05:19 +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-491-sNCGsDIxONK0-fVB927-dA-1; Mon, 08 Aug 2022 20:05:17 -0400 X-MC-Unique: sNCGsDIxONK0-fVB927-dA-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 278NxAsO032222; Tue, 9 Aug 2022 00:04:52 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3hsew155hr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:52 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 278M0h2Q011667; Tue, 9 Aug 2022 00:04:51 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2044.outbound.protection.outlook.com [104.47.74.44]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3hser26u9w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:51 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by CH0PR10MB4907.namprd10.prod.outlook.com (2603:10b6:610:db::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Tue, 9 Aug 2022 00:04:49 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50%6]) with mapi id 15.20.5504.020; Tue, 9 Aug 2022 00:04:49 +0000 From: Mike Christie To: bvanassche@acm.org, linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, linux-nvme@lists.infradead.org, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Date: Mon, 8 Aug 2022 19:04:17 -0500 Message-Id: <20220809000419.10674-19-michael.christie@oracle.com> In-Reply-To: <20220809000419.10674-1-michael.christie@oracle.com> References: <20220809000419.10674-1-michael.christie@oracle.com> X-ClientProxiedBy: CH0PR03CA0290.namprd03.prod.outlook.com (2603:10b6:610:e6::25) 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: df5b1605-b635-4f2c-bbcd-08da799ac680 X-MS-TrafficTypeDiagnostic: CH0PR10MB4907:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: SRyUywUhZVQSyOIpFl58obc+FDLbFHv9uBvVQvq1CRJhogEtrigxe6GsLHoxgP2JoHxEUP6m3NDLG6nzNIdH/etD+bw4JIuDZUd4GGbtThPd1mPq/mGU4o43xKK12EH18epGjfbimvnCUyndk7KQA72+2Smh7UvqI3M6qYfKmpdgkVhj7mPyr2ZgrQsEx8O7PIi3AVcilG0+9qlzwZYS7DnflZCH7R1R6JvVUVXU2Ynsix/XTGwMX4EMZAfx7w5udwWizeqykKmGX3/6tWMl3qFzSkWXSeXDIVScX6Q98atSWWPSZXEB1ltMm4pS9bZGbY4CakdsXv6XZPi89LR4IJXGXcnuDOoERoBHREV05MjoIeH7J1g2Jvsw2HPvGPKb5HwqJthHNsgiOzhoI6dXAOlYOSL/O/dPG9ogIHbeu8lHoR2mkwQEBF2uSDr7buvmT6jxV26LcQaCiA6KmtRNlkTIKoZCK+zHoL81P9ND73U5GV4L8rvFDDhjbgCIYqmnB1x8FY0qR654W/1TdwGoXvfbP7SDTBJo5doWM/XTJC3I/+XmYjmMy+HmdaL4bGzqitCMojwPa8Olfxjl0N32lIWoRzmRtQyaDyLauQ+eALFvJUz3ECdHnrzj1VI0foEGS4K/I9Ac7pDlLkNKnh0iGgbqUOWS4Dr6+pWP+NvMV6m9+GSsOCUk3DleJZRC1JQN7SUkWyw5GzQ9MfWyrV8evSBKIUePXi/fxcYcYouUmctRQse7cLBS313hV4dQAjFpGCC48Igu/h52YHYRRRqwvugx6q2cigDdhnXYO3XVhZ8= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(396003)(366004)(136003)(346002)(376002)(39860400002)(921005)(6666004)(41300700001)(6512007)(26005)(2906002)(6506007)(83380400001)(2616005)(107886003)(38100700002)(86362001)(186003)(6486002)(1076003)(316002)(66476007)(66556008)(36756003)(8676002)(66946007)(4326008)(8936002)(478600001)(5660300002); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Y5E/RdMS9ib1MD3Wq1NEpj4kesMir6PCRPh99lpV5ywUMUKEZ1u+ZBQzLIYoNS+0Ina+EJRSzfsiG6fDhG0+9BiMNqQZCfE2YPbB0NhypagPu/5jKz2nP9omulg8hOEyve3DdfoJ161g4sTrYCBF2EtpJiJ9kDxSmIzOdf7XSTb1Sd279aLRl95kHflsWveSaAifWjvHvyAR8W5ebrshvrl1NP86LaVJlo/xYvJX6UGi3zJqU4hh/tiTEx42r3o2lNeWuDsT5QYf9CN9+8BkanIXSCYdoWMG2+yMEVbVpmVQIs6FIYMJrhbBRqYXFQLwq22jnAZevLHgYUba8W+/MZA6W0RR04d6x7EWeKiH2fSEcXOTpkrjIeiXl6ijuhnbbG/TU5uYegMIlbh/OQUrXxJPK9uqa8ljIJT1B7TH8yAbN7vgG0832nRMR/sihrBgofEixRnM8AcwVjBNy4vOA7b9zUgEPBZ38H1/PNXLrXCqfZeR+/hZsDaskxJX756TcGkoszOY/WhCjMrLMZI4MucDVCyKc07HjqQwmfptC0jgaRzX9Eb2KFDNuK+2sxqrqULM6KDdk5roBKMmR3lVnS/hurPDhsv010DQ00zkT0z799k7oKya+8+rhfaCsS8+mriUOTCCnqT0aomiVojM7QOFt/sHdf4xh3GHXPJ6bC4d/fD54BnwHOoruvXqi5xZUQXYuv/SioA6P8bYI/zy55VqEDwBbHuiY0xmiGyhr8CZT4lUSqz8F/UDy3TG/Q0it4X0ivi4yzoGFBs3gesIj58tdUzHJ7B4o6lfknFWnCOffHwr2pVvzBV/ETwJl0eZq3c8IuVECtzTRGfDRD7mz7Pg4PrwmH368pE8pQehccOTgYFDjWKxqFnnI7UCm2rL0ek8XYT3lKNCmHgNqcbsD3ViXXkcgysC+QCwDLX35xLaKDmz34P9oUkNrRcZWOuOVmBuNAAbwpFy1T+v0FskDWPvwW7taFWYxrz9dD9V1sB6iU2ZkZ3pZINiSHgNLXrvSGZ3C0QI/yGyGb28MIIG+J+6+/p+uTeOSu9S0khmtG/1VPjkKnPOb+eX0J/uRH1ZgKJR3+9p04mg4GQaWZhzWWMqvzrZ2wV6cl9Vp+X/kr10WYfqv5GWsQPuCy1QzT5rQdbYlTwpn83NSQTvh/5tufUVjyy2kR+VehdvB1Nf8+7W6S6xPWB9KXzOaRc0clzGxkhBs2gGZy0fRm34CB4DXN++Ayf3qUbAl7w4l8U2jw03SVXEfI9ewllcET+lwyDeUFTLKsPYeDRtI3OufJAE7eYlKzukI1gXfStbT8J+2wt1WDrW4Eo22ZqY7bZa3Qt+41LopB/ndkjn9lFr1Uc3LvIIfyGsRXl3HFMLC1ewE8ElQAg3fH4QIVL2DxdnCXkLZlKC/rAcDD/gBYPRFjKAYKt6MsjuB/k/9rMUOnTNN+dR+sk4+/QzTAgEq1FYNxpYE2HTkq62kPhvnsN2g4f8V9mEE9tG5MftoIHSndLInx3DNHaikOkEWmxH9sebEjHi+/AGgpMqARa1kyvbxEk0YburmqFmdbIubZXiANEBYKOKgTfgBBlnqp9N+/3YaXFjOuxqfjGvf72UuMyNrcKcSQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: df5b1605-b635-4f2c-bbcd-08da799ac680 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2022 00:04:49.0471 (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: b42WbomUboO9n7kSGgbqTM5OPPgtRD4tBEKekiUrz9fSQzcuPCQ/kJJ1J/xaHj3hgJTsLyNz5s6K0y+DRsivWwbpb2l7eWXEVO6C6QseqQ4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4907 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-08_14,2022-08-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 phishscore=0 mlxscore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2208080105 X-Proofpoint-ORIG-GUID: N5_fbjBG0w_KIA77jhx5TAnC25NlXBlj X-Proofpoint-GUID: N5_fbjBG0w_KIA77jhx5TAnC25NlXBlj 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 Subject: [dm-devel] [PATCH v2 18/20] 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.84 on 10.11.54.2 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 c5df78959532..84bfdfb14997 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -69,6 +69,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 Tue Aug 9 00:04:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12939207 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DA671C25B08 for ; Tue, 9 Aug 2022 00:05:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660003527; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ARZv8/3+alakANZFW3r8j7yPh1884iN5kZV5VaOBI+M=; b=IaKVFdjd7pFaXcPJkghASybtvAGMMxS/OnlRoKrAv6BJEoBdzath6ABTCu5oWP1uXejqO7 P7xrQN1fGza2ETiGShdmLPJdBuATLxiUI0gasyN6SVTFtQe17blmdVzh+mtgIRIUMUglz/ v0hAponVcnJ3qiTW5kkpa8TVxzrk1fQ= 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-179-6T4kvIFRNQyNBeR1PgVB8A-1; Mon, 08 Aug 2022 20:05:23 -0400 X-MC-Unique: 6T4kvIFRNQyNBeR1PgVB8A-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BF42585A58C; Tue, 9 Aug 2022 00:05: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 AD109492C3B; Tue, 9 Aug 2022 00:05: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 78AA31946A50; Tue, 9 Aug 2022 00:05:21 +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 7DA761946A50 for ; Tue, 9 Aug 2022 00:05:19 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7126DC15BA4; Tue, 9 Aug 2022 00:05:19 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6C2A1C15BA3 for ; Tue, 9 Aug 2022 00:05:18 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 988E21857F02 for ; Tue, 9 Aug 2022 00:05:18 +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-194-MGSTGV61MoyE_1FewO0xbQ-1; Mon, 08 Aug 2022 20:05:16 -0400 X-MC-Unique: MGSTGV61MoyE_1FewO0xbQ-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 278NwJlL007174; Tue, 9 Aug 2022 00:04:54 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3hsg69n1e7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:54 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 278M0w1O034406; Tue, 9 Aug 2022 00:04:53 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2107.outbound.protection.outlook.com [104.47.58.107]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3hser2da23-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:53 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by CH0PR10MB4907.namprd10.prod.outlook.com (2603:10b6:610:db::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Tue, 9 Aug 2022 00:04:51 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50%6]) with mapi id 15.20.5504.020; Tue, 9 Aug 2022 00:04:51 +0000 From: Mike Christie To: bvanassche@acm.org, linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, linux-nvme@lists.infradead.org, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Date: Mon, 8 Aug 2022 19:04:18 -0500 Message-Id: <20220809000419.10674-20-michael.christie@oracle.com> In-Reply-To: <20220809000419.10674-1-michael.christie@oracle.com> References: <20220809000419.10674-1-michael.christie@oracle.com> X-ClientProxiedBy: CH2PR04CA0019.namprd04.prod.outlook.com (2603:10b6:610:52::29) 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: 8eb14b18-0d20-426a-2c3b-08da799ac7fe X-MS-TrafficTypeDiagnostic: CH0PR10MB4907:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: xSXUTXmUpYbqJQhK/E88BfiiElvlS+rZ5thbuRvaJwt5Aob4PIesAmqO3FP52qX1NwYfhCSH9SfOlxqjBWaCdH7x43JI2VeCqnCXdlkktSn1t64gyGM6em2O/0G2akYOKHbwUSsLNtqYmU1U79n/xToCHsNdU+2QE5YmhocpjvRrraU4Vea8VN/jK5T/deYV3ixHY5+HdFmi5Xw6asSjy7H/mUeCTq0GPJRfTlm7KvI+fUaKmSUBmwCIWY4+9Cl5tjTv67nYZbjslZ/495+fj8tTlWfk6scS4swy9Ae+942ltAnWbj8BschON+ehX/V8KsomWooiBnn97KYAjeBp4EkIXbFexgwFEIHRv92j4xZIklAipajoqmNYd+EEa8JuZQ+2xOuO/UGwyOMHiA/6h6MDcTmYJaL3noiZEXi+4Ep3IxecEu6EL0RO1pawCjokggLc1L5AbxwjjSsyLYFrsgGKTjlA2CO7P4U4hh+sVATVSfGI1+F2DpllrrpwVxmu4wlqcawPnBoLPN7/diaJEu01xeA8JdS1Xyimy7wrg9L9nQ3u79czKgE58Z1f2y4wTA6FxuasrDKCASMsPCTungcoLQ1qXHr1z2lWsgMQXYoqDZo3fW1nCeT96jDftDHHaQFJnnPVVOf5eVLcGDQuwsPul2TQUST7exJBHPaQXYAVx/snPxL6dX+C2WwXFg9v1510wudYpn10M5rb+WhQZBLM50Gjy2oez77rA+EtJKyutPcaaiRZwg1kXtTAxL9Pz9uOUAPkshuBJlbHZirlx1I/EPd8evWaSFAvWM3MWw8= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(396003)(366004)(136003)(346002)(376002)(39860400002)(921005)(6666004)(41300700001)(6512007)(26005)(2906002)(6506007)(83380400001)(2616005)(107886003)(38100700002)(86362001)(186003)(6486002)(1076003)(316002)(66476007)(66556008)(36756003)(8676002)(66946007)(4326008)(8936002)(478600001)(5660300002); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mw+H76u5QmxRhNzaqC3RBQipU5R0cWsHES79Peu1Wom/4BAugcm7b3rbMqk88AIJMKdjFjJ+sB/vL1/qAE6MxnUNoS4ARtANC+tLaOZzGCxCPsVtZbiz0sHAR8ezNQoBUqaeZEtlQKaGOs01JWXeQaAjRS+7Xb3Hj5T6+0SDs5NdesZPJ/Z8zZTfEYNCvPD8g/A/x8Wml1jFOFHZeKuugTpepKDK0sVQtmr6XL72ZX8D0Z+4NHFr7HoyrQR71lppoJuhJL8pJq70DUsIDkpiNO0alKunhrT8G8Qu0duBKcbuyt7juN5XUwcSv9M8i9dOu77/tugRM95+4Qlj9JQ+HtY5oGp8TvpR9x7OW5IAEazKIv13bO1Tg00PEWS75T8WwEOlZpdQMWxoDfsDgRiEmCjSBYpjSbkCL1w7avT86zIaTvYmydymQH8uwPhCdpdXKoh+TgdStxiUHko1AfnArWhBFxF/jKGQZFUJ7qFG01R/IS/EuiLk9XClxRqHs5jWQFouyeuB/WAEMF/AjWnrqmRnaTLEse6O9PnUWW0CQ9NFwX2C1+dbhH48RkAAUyfD1il1yltN0xwU422qRRIgaKAmbv95DPr51U3pkPW4bu8SY5wj745HGAwYKqD1jm7XwJABWrGchij81eJJ+vyl+E41+1x/THl/QTKO8sN7yLpbOitl0UeLk6kft2VR6LzZpPgDFG8qgn62Dhn8SkK3fkdTljuxp10UgVnMDOdj9Azh56x8iau3nCiruWWvEv59SgWn1IcBh94bHWREkUCgKwGlCEsSh6X78hNzIFJs3NUXZrshz+tCzslKB2Sm6AmvF1q+EFTHoa3MeSX6DygHBNu0CT0N8jZ95erpKjs59r5c98gN5ZbVj58cKqGgw8dpqMDRLSwNYwFdNSj18J6mlZ4uiT6+lMz6gZtwATOUn5MawYe7jNvZ3/IKxZKlG5mZR6P1LeIt4EjWKB56lZz7zfncudB2/W3mQkjBylPgQOw7rbB8uoVUIWV4sSVmINJLhUvLbCP20Uo/vzoRiju0mkGZ2V2ZRNz4xuzEm7h2yhi5Uv2A2eU3jRVITzz4msqceOLP8SWkAnN00fE2iayCWixL02dXGH8C959s/7GqVtqjM1+xNFnL7OuFmvGyBFxDRIY/Lwm/jqNWJSNDGDip3IDJnICtwAWSRWf3p88rSreJTKzy1OGuBXZ9uPKul/RICgVEn+qGebbFfhtfEQCLY/NCexdsAkLsOKgCmozEYE9HrEAk16qchTxTx/G7m+snlQ71wh2HVUhQNd/Zkk3VT1+8Jwx3XxACArVNOJ5rK3ntcBSzAcygXvCAZnGCle6FdxWaVb1VrsTVOsdWHN7Qv/StlLWCoo/Xa+xKQ4xmH2gCtVl/RUYmIde7gcZ7u1QL3/miB6sDLyWH8FBhqkhFxfz4USsN2OZEa7ki3ST0hdSGII7mTrZCCqWfBDr2sTH8QXxfDAwDI63DB+QKvgxtGuVz6nkWjA7vCEI82bIgAJ1Qar5CFlGjByCKK7RUPltwo/gxA8PPwl9I5Rlhg5mAmCjlFgMMvt7SWuMmUDBWCjAFrQJmxmzS60epEundJUA6LqYSLEA7rGBJWkZUSsRdZQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8eb14b18-0d20-426a-2c3b-08da799ac7fe X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2022 00:04:51.5156 (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: oDGuw/Wz417FlExaHc+bhuSq0y/ZsEiuXtYbx1O6G06u3zYoVPq3QhBBQI3ytUIIZkjfiEeQ/RENsNAfVjSni+b7rcpjh7A0zVu8Y3XP73w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4907 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-08_14,2022-08-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 phishscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2208080105 X-Proofpoint-ORIG-GUID: PY4y6kUInA91WvtEeWojCi2195ABQ2d0 X-Proofpoint-GUID: PY4y6kUInA91WvtEeWojCi2195ABQ2d0 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 Subject: [dm-devel] [PATCH v2 19/20] scsi: target: Don't support SCSI-2 RESERVE/RELEASE X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mike Christie Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com The pr_ops don't support SCSI-2 RESERVE/RELEASE so fail them during parsing. Signed-off-by: Mike Christie --- drivers/target/target_core_spc.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c index c14441c89bed..64ac9b92f8cf 100644 --- a/drivers/target/target_core_spc.c +++ b/drivers/target/target_core_spc.c @@ -1314,12 +1314,25 @@ spc_parse_cdb(struct se_cmd *cmd, unsigned int *size) struct se_device *dev = cmd->se_dev; unsigned char *cdb = cmd->t_task_cdb; - if (!dev->dev_attrib.emulate_pr && - ((cdb[0] == PERSISTENT_RESERVE_IN) || - (cdb[0] == PERSISTENT_RESERVE_OUT) || - (cdb[0] == RELEASE || cdb[0] == RELEASE_10) || - (cdb[0] == RESERVE || cdb[0] == RESERVE_10))) { - return TCM_UNSUPPORTED_SCSI_OPCODE; + switch (cdb[0]) { + case RESERVE: + case RESERVE_10: + case RELEASE: + case RELEASE_10: + if (!dev->dev_attrib.emulate_pr) + return TCM_UNSUPPORTED_SCSI_OPCODE; + /* + * The block layer pr_ops don't support the old RESERVE/RELEASE + * commands. + */ + if (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR) + return TCM_UNSUPPORTED_SCSI_OPCODE; + break; + case PERSISTENT_RESERVE_IN: + case PERSISTENT_RESERVE_OUT: + if (!dev->dev_attrib.emulate_pr) + return TCM_UNSUPPORTED_SCSI_OPCODE; + break; } switch (cdb[0]) { From patchwork Tue Aug 9 00:04:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12939252 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D5F3EC00140 for ; Tue, 9 Aug 2022 00:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660003658; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=zx3XU793bss7NRdXh9+wb4MuFi3arPN9dleeEkFZ85I=; b=henEKoqiYRLMBJpuY89HWx4JIK9aVr36ABLMUh2L8+rwQi2A0Kl4CAWHtvK6BC4ow6m4dI 9fhG9amT4kzPoWorjDkwCit2Fb9pOcXU24fxsaugs/Ksfgjz9N+yX5nXg4BIR7tj1jsSd4 FZz3mrlNQFVN80CsTAzjTUS3bvt+UhU= 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-325-rg3RzSnfOxyzIFcVBjOt0A-1; Mon, 08 Aug 2022 20:07:34 -0400 X-MC-Unique: rg3RzSnfOxyzIFcVBjOt0A-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CF0CB38035A1; Tue, 9 Aug 2022 00:07:32 +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 BA5E0400F36; Tue, 9 Aug 2022 00:07:32 +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 166141946A55; Tue, 9 Aug 2022 00:07:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 18DA91946A4F for ; Tue, 9 Aug 2022 00:07:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id ED2BE1121315; Tue, 9 Aug 2022 00:07:30 +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 E7E9D1121314 for ; Tue, 9 Aug 2022 00:07:30 +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 C6E9D38035A2 for ; Tue, 9 Aug 2022 00:07:30 +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-251-h2Ms8ONIPKqygssbdRK4IQ-1; Mon, 08 Aug 2022 20:07:29 -0400 X-MC-Unique: h2Ms8ONIPKqygssbdRK4IQ-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 278Nwhfm031116; Tue, 9 Aug 2022 00:04:56 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 3hsew155ht-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:56 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 278M0huv013005; Tue, 9 Aug 2022 00:04:54 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2102.outbound.protection.outlook.com [104.47.58.102]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3hu0q2b9q5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Aug 2022 00:04:54 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by CH0PR10MB4907.namprd10.prod.outlook.com (2603:10b6:610:db::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Tue, 9 Aug 2022 00:04:52 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::8dee:d667:f326:1d50%6]) with mapi id 15.20.5504.020; Tue, 9 Aug 2022 00:04:52 +0000 From: Mike Christie To: bvanassche@acm.org, linux-block@vger.kernel.org, dm-devel@redhat.com, snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, linux-nvme@lists.infradead.org, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Date: Mon, 8 Aug 2022 19:04:19 -0500 Message-Id: <20220809000419.10674-21-michael.christie@oracle.com> In-Reply-To: <20220809000419.10674-1-michael.christie@oracle.com> References: <20220809000419.10674-1-michael.christie@oracle.com> X-ClientProxiedBy: CH2PR04CA0023.namprd04.prod.outlook.com (2603:10b6:610:52::33) 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: 2e802cc7-5061-4d76-948c-08da799ac8cd X-MS-TrafficTypeDiagnostic: CH0PR10MB4907:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: c41la7kRcYMM3TqH+mIfwx977NIhQ7pKLjMZyIZb8f1lCrxd8O9lbC4l4IZQdeqCJt1ABj9wWNo2DO4F8r1fc7jeo9hh1ZPouQs4xrXVl6lSqjZkOCklRIcHfrye1SDXLi2JGddo1vKKBpK79VMVemP2MCuj100Fex53fUEdgZPpwkCEMfNsEnuuj+B4AUIfalA7rgwv/MW6LgwpjHFluZdkV2Ibo7pFKrpBhREPtxgZZC0B2lp/pjRlQ922ms82//UlYVEtuOvTDneqY1T2Ncgas+5RCamdzuAAxkahGhJe5DcY+q2Aa1tA7KnycOLhsm3ktdE+27lFr1B8w3Np0rO2enWz2Nl+86ta6WgrvbJPKQ0JByCoEyn7ii5qM+Tqt2924J6fAYnXgWKVMDXMbSSVVhlM+ZvUFRolP/ZxMf7SpCePvqMURH86fOTwT6tS3A/eyR0OxEJFaN8YurMwuA/WRw8tPbIvw9CdCKjL59NlyGn/2zuKVnpjE8A653t7fHNjzJ6Bq0MkjXWt+N3RRvR9iQj6vJhHe3tWCwqmN5Mx7xWgf7KhhEgR9iQ4htjaNa6sdlX9z/JrbT+xon2jgwNrz7A1hUO9PVpF5sS2s70cPJzFl278/l/HDEiNMLVRgQHBMdehHUXnZJEj9LR31eKqrqKn/8mklvuRXGufxW1SOT+4BgzMyKNjVtKbqgn+e5b8rZfM61UrKHw268bNhcEOp8kNiLO40lecu6Ag/XAvNWGRbr7AXsf9pmorFBjm7fr8jAUB00j16AjQu6yS12Y2Zg9e/42kHKDkEzwG9Jg= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(396003)(366004)(136003)(346002)(376002)(39860400002)(921005)(30864003)(6666004)(41300700001)(6512007)(26005)(2906002)(6506007)(83380400001)(2616005)(107886003)(38100700002)(86362001)(186003)(6486002)(1076003)(316002)(66476007)(66556008)(36756003)(8676002)(66946007)(4326008)(8936002)(478600001)(5660300002); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KIZQel2f27JgYUzVC1vhZNL6/Gj2JOi9gb0uFjoGFShJMgw0wO+066LZqnvb0DdDI/HffchghryNF3vHPsHJcjA6S1CFta/Bv/FJfweAzklKJHYAHm6YSTD7rR8m+To1xWwaReDxHaNMNsGxfsqetqXpcN1jPZo58mgoJZVJry6oCS9k6CZ0+dw509WwQQ37OlGlbtKQmapGC6iWYubn6Jzxn3s0Eu4sOIjOb8R6CfntUISwWeFzZWctrc7RbrqvQld4M1u3T3NqIVW7RUUEyF9qZgs4qY8G9KsCGBVG7+v9qkgfukOBCuICZTJf8j6BrGcUcdDb6kAP8/7AF6yn1YZh5zOCPIAk2H5sVq7AKJ4p4/cf5e8eGYFERsJqxyVHGIrbd7AnfC6/DwLMfnxcmwjJ45nO5Je1XSXK71iNzzLVMR3ptJ3EBxPWU+dkXdqAQkMnyE4pnjm6Qf7Aox+e2GCgI9vfUawFh2jlb4ML0M5YFsgZd8SdRjOJ/m5+mpuxysjhPg/0tiNAqYmyKNMqU5YFmWinftKwAGNfAX6kmWrd4I7Dxb7JxqZXXg8voiMkdkImkwlrQFFoaVsDoj0byW98k0Su8EFUElgbTYHwjxaqApvELVUrOjjidQn0A0+GS0Jj8G1Ht1RFlexvMGcq5ZQ9bZPfZZeoeAY141bq1+TX7pI9ixY4JkLftLGGXlefDtNiNVAgzL0Oh9NKTU64p8QXzPEaWty7RVTsWrtTSDaUgGMfblncAx0tEcuuQ2Dh3qwEjo/td/mGBeoEhsgrp6IKMS9Lp04CSjiQLJsGbD2pXZjXnlqkHL61EuoWUbyU1HSkVogdlZLOOzVkQgRO0C8DGBZOJvSbUyc1vEigFC9tjxuY4TRGxqDpYPmB/ps2A2MGcFgpkJXBahvfEU+txdUn7wNV+oIlNVUerf85fJf16Kew3nWTo5MJBqco9cVVv51OdL99sHicPj+k8lmeRFG1h9KjKDN9QTpJu44NsSUki7h25CgDkmWF46WmKh6ookluSij4neLxQCdFNPAqq3LeRm6eCduYgrRmIlJzq1GYiCRK9cY/fl4K7V5hJ/hOjtmJh24C77bRAy+cyVW4QT2UGUQHJoU9ljujyx0QUZ2HYA6dh1dphrJcvD9tbuSowUNtid7X7QMAmClVVpDL9TDZj0/kMPgOHQGszsZrScxUMam2PYemxlWwcBIVonANPwXd3IdKgjCnx++O7GU/0sGPa5LjjcFhUI7cwUyxRdECv4tkfqgE9yRCv4Z7jezlAaHgnNkRSZDIMQglGMYoiSrFBH3xV8hnOrgAVThdzxq+Dwgt3jD25EDdk4ssZAsqaOnLR2oxS9PYM3M7AgGnqtughzFC1h65sC5TX9+MeEObLTVMhY5xDHIlEpxNKdzi72Xcm5jDRNFnnTwFGw/6Xy39ES/puuwJcYfqSAw6MITUC6M237OTV4TVDtvC7jHYX5FbkWD1narJhKOiGuKwjTsITmQ0NCMTiZZo9OLCWU4EKXLLazi0C78FxFarKuFEiBWEKhf8QMBZT3m1Wx4hEd7XpB4ncuWW9CrW2JTR0o16yuANecRtdDzubm+VXEsfDczLqbv4QuG3P4Z8gp8RfQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2e802cc7-5061-4d76-948c-08da799ac8cd X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2022 00:04:52.8593 (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: 8M6GK8lGA2a4E+6TZinQKbpLazolIMymBK2ccPd9RXfEYET4upu2pzkk097IY4Y6lVcQI5Kfl8DqqIXMSqwctQ01Rw5YxuHMo3vL7jexryI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4907 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-08_14,2022-08-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 adultscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2208080105 X-Proofpoint-ORIG-GUID: eONwk7P5Gt-kvBU0S-4RHwbJbT4n7Weh X-Proofpoint-GUID: eONwk7P5Gt-kvBU0S-4RHwbJbT4n7Weh X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Subject: [dm-devel] [PATCH v2 20/20] 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.85 on 10.11.54.10 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 support it all like SPEC_I_PT and ALL_TG_PT. This only supports exporting the iblock device from one path on the local target. Signed-off-by: Mike Christie --- drivers/target/target_core_iblock.c | 292 +++++++++++++++++++++++++++- 1 file changed, 287 insertions(+), 5 deletions(-) diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index 5db7318b4822..caf6958dd75d 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 @@ -310,7 +313,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; @@ -318,7 +321,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_NEXUS) + status = SAM_STAT_RESERVATION_CONFLICT; + else if (atomic_read(&ibr->ib_bio_err_cnt)) status = SAM_STAT_CHECK_CONDITION; else status = SAM_STAT_GOOD; @@ -331,6 +336,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); @@ -343,7 +349,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, @@ -759,7 +765,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; } @@ -817,7 +823,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: @@ -829,6 +835,279 @@ 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; + blk_status_t blk_stat = 0; + 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, + &blk_stat); + break; + case PRO_RESERVE: + if (!ops->pr_reserve) { + pr_err("block_device does not support pr_reserve.\n"); + return TCM_UNSUPPORTED_SCSI_OPCODE; + } + + ret = ops->pr_reserve(bdev, key, scsi_pr_type_to_block(type), 0, + &blk_stat); + 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, &blk_stat); + 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; + } + + ret = ops->pr_preempt(bdev, key, sa_key, + scsi_pr_type_to_block(type), + sa == PRO_PREEMPT ? false : true, + &blk_stat); + break; + case PRO_RELEASE: + if (!ops->pr_clear) { + pr_err("block_device does not support pr_pclear.\n"); + return TCM_UNSUPPORTED_SCSI_OPCODE; + } + + ret = ops->pr_release(bdev, key, scsi_pr_type_to_block(type), + &blk_stat); + break; + default: + pr_err("Unknown PERSISTENT_RESERVE_OUT SA: 0x%02x\n", sa); + return TCM_UNSUPPORTED_SCSI_OPCODE; + } + + if (!ret) + return TCM_NO_SENSE; + else if (blk_stat == BLK_STS_NEXUS) + return TCM_RESERVATION_CONFLICT; + else + return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; +} + +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. + */ + param_data[4] |= 0x80; /* PR_TYPE_EXCLUSIVE_ACCESS_ALLREG */ + param_data[4] |= 0x40; /* PR_TYPE_EXCLUSIVE_ACCESS_REGONLY */ + param_data[4] |= 0x20; /* PR_TYPE_WRITE_EXCLUSIVE_REGONLY */ + param_data[4] |= 0x08; /* PR_TYPE_EXCLUSIVE_ACCESS */ + param_data[4] |= 0x02; /* PR_TYPE_WRITE_EXCLUSIVE */ + param_data[5] |= 0x01; /* PR_TYPE_EXCLUSIVE_ACCESS_ALLREG */ +} + +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 = 8 * paths; + keys = kzalloc(sizeof(*keys) + len, GFP_KERNEL); + if (!keys) + return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; + + ret = ops->pr_read_keys(bdev, keys, len, NULL); + if (!ret) { + if (keys->num_keys > paths) { + 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; + } + + put_unaligned_be32(8 * keys->num_keys, ¶m_data[4]); + + data_offset = 8; + for (i = 0; i < keys->num_keys; i++) { + if (data_offset + 8 > cmd->data_length) + break; + + put_unaligned_be64(keys->keys[i], ¶m_data[data_offset]); + 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, NULL)) + return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; + + put_unaligned_be32(rsv.generation, ¶m_data[0]); + if (!block_pr_type_to_scsi(rsv.type)) { + 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 = TCM_NO_SENSE; + + 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); @@ -883,6 +1162,8 @@ 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 @@ -899,6 +1180,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,