Re: [dm-devel] [PATCH v3 04/19] scsi: Add support for block PR read keys/reservation

2022-10-31 Thread Chaitanya Kulkarni
> +static inline enum pr_type scsi_pr_type_to_block(enum scsi_pr_type type) > +{ > + switch (type) { > + case SCSI_PR_WRITE_EXCLUSIVE: > + return PR_WRITE_EXCLUSIVE; > + case SCSI_PR_EXCLUSIVE_ACCESS: > + return PR_EXCLUSIVE_ACCESS; > + case

Re: [dm-devel] [PATCH v3 03/19] scsi: Move sd_pr_type to header to share

2022-10-31 Thread Chaitanya Kulkarni
On 10/26/22 16:19, Mike Christie wrote: > 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. The next patch will > then also add a helper to go from the SCSI value to the block one for use > with PERSISTENT_RESERVE_IN

Re: [dm-devel] [PATCH v3 02/19] scsi: Rename sd_pr_command

2022-10-31 Thread Chaitanya Kulkarni
On 10/26/22 16:19, Mike Christie wrote: > 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 ++-- > Reviewed-by: Chaitanya Kulkarni

Re: [dm-devel] [PATCH v3 07/19] nvme: Don't hardcode the data len for pr commands

2022-10-31 Thread Chaitanya Kulkarni
On 10/26/22 16:19, Mike Christie wrote: > 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 > --- Reviewed-by: Chaitanya Kulkarni -ck

Re: [dm-devel] [PATCH v3 08/19] nvme: Move pr code to it's own file

2022-10-31 Thread Chaitanya Kulkarni
On 10/26/22 16:19, Mike Christie wrote: > This patch moves the pr code to it's own file because I'm going to be > adding more functions and core.c is getting bigger. > > Signed-off-by: Mike Christie > --- > Thanks a lot for doing this ... Reviewed-by: Chaitanya Kulkarni -ck -- dm-devel

[dm-devel] [PATCH v3 17/19] scsi: target: Allow backends to hook into PR handling

2022-10-31 Thread Mike Christie
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

Re: [dm-devel] [PATCH v3 08/19] nvme: Move pr code to it's own file

2022-10-31 Thread Keith Busch
On Fri, Oct 28, 2022 at 11:06:29AM -0500, Mike Christie wrote: > On 10/27/22 12:06 PM, Keith Busch wrote: > > On Wed, Oct 26, 2022 at 06:19:34PM -0500, Mike Christie wrote: > >> This patch moves the pr code to it's own file because I'm going to be > >> adding more functions and core.c is getting

Re: [dm-devel] [PATCH v3 10/19] nvme: Move NVMe and Block PR types to an array

2022-10-31 Thread Mike Christie
On 10/27/22 10:18 AM, Keith Busch wrote: > On Wed, Oct 26, 2022 at 06:19:36PM -0500, Mike Christie wrote: >> For Reservation Report support we need to also convert from the NVMe spec >> PR type back to the block PR definition. This moves us to an array, so in >> the next patch we can add another

Re: [dm-devel] [PATCH v3 11/19] nvme: Add pr_ops read_reservation support

2022-10-31 Thread Mike Christie
On 10/30/22 3:18 AM, Christoph Hellwig wrote: >> +memset(resv, 0, sizeof(*resv)); > > Is there any good reason this isn't done by the caller? I will change it. I think it was leftover from when I was experimenting with some mulitpath support. It's not needed anymore. -- dm-devel mailing

Re: [dm-devel] [PATCH v3 10/19] nvme: Move NVMe and Block PR types to an array

2022-10-31 Thread Keith Busch
On Wed, Oct 26, 2022 at 06:19:36PM -0500, Mike Christie wrote: > For Reservation Report support we need to also convert from the NVMe spec > PR type back to the block PR definition. This moves us to an array, so in > the next patch we can add another helper to do the conversion without > having to

Re: [dm-devel] [PATCH v3 08/19] nvme: Move pr code to it's own file

2022-10-31 Thread Mike Christie
On 10/27/22 12:06 PM, Keith Busch wrote: > On Wed, Oct 26, 2022 at 06:19:34PM -0500, Mike Christie wrote: >> This patch moves the pr code to it's own file because I'm going to be >> adding more functions and core.c is getting bigger. >> >> Signed-off-by: Mike Christie > > Good idea. Credit goes

[dm-devel] [PATCH v3 01/19] block: Add PR callouts for read keys and reservation

2022-10-31 Thread Mike Christie
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

[dm-devel] [PATCH v3 12/19] block, nvme, scsi, dm: Add blk_status to pr_ops callouts

2022-10-31 Thread Mike Christie
LIO needs to be able to know if a failure was the 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. Windows clustering and test tools like libiscsi require this. dm-multipath would also like

Re: [dm-devel] [PATCH 7/7] block: store the holder kobject in bd_holder_disk

2022-10-31 Thread Yu Kuai
Hi 在 2022/10/30 23:31, Christoph Hellwig 写道: We hold a reference to the holder kobject for each bd_holder_disk, so to make the code a bit more robust, use a reference to it instead of the block_device. As long as no one clears ->bd_holder_dir in before freeing the disk, this isn't strictly

[dm-devel] [PATCH v3 09/19] nvme: Add pr_ops read_keys support

2022-10-31 Thread Mike Christie
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

[dm-devel] [PATCH v1] drivers/dm-crypt.c : remove redundant state settings after waking up

2022-10-31 Thread lizhe
The task status has been set to TASK_RUNNING in schedule(), no need to set again here Signed-off-by: lizhe --- drivers/md/dm-crypt.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 159c6806c19b..dd82e5aad729 100644 ---

[dm-devel] [PATCH v3 05/19] dm: Add support for block PR read keys/reservation

2022-10-31 Thread Mike Christie
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 95a1ee3d314e..f7f806890c92

Re: [dm-devel] [PATCH v3 12/19] block, nvme, scsi, dm: Add blk_status to pr_ops callouts

2022-10-31 Thread Mike Christie
On 10/30/22 3:20 AM, Christoph Hellwig wrote: > On Wed, Oct 26, 2022 at 06:19:38PM -0500, Mike Christie wrote: >> To handle both cases and keep userspace compatibility, this patch adds a >> blk_status_t arg to the pr_ops callouts. The lower levels will convert >> their device specific error to the

[dm-devel] [PATCH v3 04/19] scsi: Add support for block PR read keys/reservation

2022-10-31 Thread Mike Christie
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| 104 +++ include/scsi/scsi_block_pr.h | 20 +++ include/scsi/scsi_proto.h| 5 ++ 3 files changed, 129

Re: [dm-devel] [PATCH v3 10/19] nvme: Move NVMe and Block PR types to an array

2022-10-31 Thread Mike Christie
On 10/27/22 12:16 PM, Keith Busch wrote: > On Thu, Oct 27, 2022 at 12:13:06PM -0500, michael.chris...@oracle.com wrote: >> Oh wait there was also a >> >> 3. The pr_types come from userspace so if it passes us 10 >> and we just do: >> >> types[pr_type] >> >> then we would crash due an out of bounds

[dm-devel] [PATCH v3 07/19] nvme: Don't hardcode the data len for pr commands

2022-10-31 Thread Mike Christie
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

Re: [dm-devel] [PATCH v3 06/19] nvme: Fix reservation status related structs

2022-10-31 Thread Keith Busch
On Wed, Oct 26, 2022 at 06:19:32PM -0500, Mike Christie wrote: > 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. > > These are not currently used, but will be in this

[dm-devel] [PATCH v3 13/19] nvme: Have NVMe pr_ops return a blk_status_t

2022-10-31 Thread Mike Christie
If register or reserve hit a reservation conflict upper layers like LIO need to pass that error to the initiator. To do this it has to know the device/driver type so it can convert the return code because that's currently a NVMe specific value. Instead of having the upper layers figure out the

Re: [dm-devel] [PATCH v3 10/19] nvme: Move NVMe and Block PR types to an array

2022-10-31 Thread Keith Busch
On Thu, Oct 27, 2022 at 12:13:06PM -0500, michael.chris...@oracle.com wrote: > Oh wait there was also a > > 3. The pr_types come from userspace so if it passes us 10 > and we just do: > > types[pr_type] > > then we would crash due an out of bounds error. > > Similarly I thought there could be

[dm-devel] [PATCH v3 15/19] scsi: Have sd pr_ops return a blk_status_t

2022-10-31 Thread Mike Christie
If a register or reserve hit a reservation conflict upper layers like LIO need to pass that error to the initiator. To do this it has to know the device/driver type so it can convert the return code because that's currently a device/driver specific value. Instead of having the upper layers figure

[dm-devel] [PATCH v3 06/19] nvme: Fix reservation status related structs

2022-10-31 Thread Mike Christie
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. These are not currently used, but will be in this patchset which adds support for the reservation report command. Signed-off-by:

[dm-devel] [PATCH v3 08/19] nvme: Move pr code to it's own file

2022-10-31 Thread Mike Christie
This patch moves the pr code to it's own file because I'm going to be adding more functions and core.c is getting bigger. Signed-off-by: Mike Christie --- drivers/nvme/host/Makefile | 2 +- drivers/nvme/host/core.c | 120 --- drivers/nvme/host/nvme.h | 2

[dm-devel] [PATCH v3 19/19] scsi: target: Add block PR support to iblock

2022-10-31 Thread Mike Christie
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

Re: [dm-devel] [PATCH v3 09/19] nvme: Add pr_ops read_keys support

2022-10-31 Thread Mike Christie
On 10/30/22 3:17 AM, Christoph Hellwig wrote: > On Wed, Oct 26, 2022 at 06:19:35PM -0500, Mike Christie wrote: >> 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

[dm-devel] [PATCH v3 03/19] scsi: Move sd_pr_type to header to share

2022-10-31 Thread Mike Christie
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. The next patch will then also add a helper to go from the SCSI value to the block one for use with PERSISTENT_RESERVE_IN commands. Signed-off-by: Mike Christie Reviewed-by:

[dm-devel] [PATCH v3 02/19] scsi: Rename sd_pr_command

2022-10-31 Thread Mike Christie
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

Re: [dm-devel] [PATCH v3 07/19] nvme: Don't hardcode the data len for pr commands

2022-10-31 Thread Keith Busch
On Wed, Oct 26, 2022 at 06:19:33PM -0500, Mike Christie wrote: > 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 Looks good.

Re: [dm-devel] [PATCH v3 08/19] nvme: Move pr code to it's own file

2022-10-31 Thread Keith Busch
On Wed, Oct 26, 2022 at 06:19:34PM -0500, Mike Christie wrote: > This patch moves the pr code to it's own file because I'm going to be > adding more functions and core.c is getting bigger. > > Signed-off-by: Mike Christie Good idea. The nvme core file is getting a bit too big and too diverse in

[dm-devel] [PATCH v3 00/19] Use block pr_ops in LIO

2022-10-31 Thread Mike Christie
The following patches were built over Linus's tree and this patchset https://lore.kernel.org/all/20221023030403.33845-24-michael.chris...@oracle.com/t/ which allows the SCSI layer passthrough users to control retries for commands like PRs used in this patchset. The patches in this thread allow

Re: [dm-devel] [PATCH v3 10/19] nvme: Move NVMe and Block PR types to an array

2022-10-31 Thread michael . christie
On 10/27/22 12:06 PM, Mike Christie wrote: > On 10/27/22 10:18 AM, Keith Busch wrote: >> On Wed, Oct 26, 2022 at 06:19:36PM -0500, Mike Christie wrote: >>> For Reservation Report support we need to also convert from the NVMe spec >>> PR type back to the block PR definition. This moves us to an

[dm-devel] [PATCH v3 16/19] scsi: target: Rename sbc_ops to exec_cmd_ops

2022-10-31 Thread Mike Christie
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 ---

[dm-devel] [PATCH v3 14/19] scsi: Export scsi_result_to_blk_status

2022-10-31 Thread Mike Christie
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

[dm-devel] [PATCH v3 18/19] scsi: target: Don't support SCSI-2 RESERVE/RELEASE

2022-10-31 Thread Mike Christie
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

[dm-devel] [PATCH v3 11/19] nvme: Add pr_ops read_reservation support

2022-10-31 Thread Mike Christie
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 ---

[dm-devel] [PATCH v3 10/19] nvme: Move NVMe and Block PR types to an array

2022-10-31 Thread Mike Christie
For Reservation Report support we need to also convert from the NVMe spec PR type back to the block PR definition. This moves us to an array, so in the next patch we can add another helper to do the conversion without having to manage 2 switches. Signed-off-by: Mike Christie ---