target/rbd: distributed lun reset support
Subsystems (3)
cover target/rbd: distributed lun reset support
The following patches allow drivers like libceph/rbd to distribute execution of scsi task management functions across multiple nodes (still working on issues with distributed PRs).
In this patchset, I added a new type of callout/module for these cluster aware modules. The idea is that something like drbd could maybe do something optimized for them, or nbd could, or you could use dlm plus some file system, or do something cluster FS specific. For rbd we are making rados/libceph calls.
I am mostly looking for feedback on the hooks/callouts approach. I was not sure if we wanted to maybe instead do somethign like add new callouts to the request_queue (request_queue->reset_q) or block_device or add some new block layer REQ_TYPEs (REQ_TYPE_DEVICE_RESET or REQ_TYPE_PGR_REGISTER, etc). In this patchset I just added new callouts that modules can implement, because I thought this was most similar to how we do fabric modules and so it was a ok fit.
PATCH 1/5 rbd: rename rbd.c to rbd_main.c
From: Mike Christie <[email protected]>
This renames rbd.c to rbd_main.c to allow us to be able to share the code in the tcm rbd related files being added in the next patches and also keep the name of the module rbd.ko.
--- drivers/block/Makefile | 3 + drivers/block/rbd.c | 6433 ---------------------------------------------- drivers/block/rbd_main.c | 6433 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 6436 insertions(+), 6433 deletions(-) delete mode 100644 drivers/block/rbd.c create mode 100644 drivers/block/rbd_main.c
drivers/block/Makefile +3 -0
@@ -37,7 +37,10 @@ obj-$(CONFIG_BLK_DEV_HD) += hd.o obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o obj-$(CONFIG_XEN_BLKDEV_BACKEND) += xen-blkback/ obj-$(CONFIG_BLK_DEV_DRBD) += drbd/ + obj-$(CONFIG_BLK_DEV_RBD) += rbd.o +rbd-objs := rbd_main.o + obj-$(CONFIG_BLK_DEV_PCIESSD_MTIP32XX) += mtip32xx/ obj-$(CONFIG_BLK_DEV_RSXX) += rsxx/
drivers/block/rbd.c deleted +0 -6433
2,990 lines not on this page · raw message
drivers/block/rbd_main.c new file +6433 -0
6,433 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.8.3.1
Part of the diff is not shown here. View the raw message.
PATCH 2/5 target: add cluster device init hooks
In reply to [email protected]From: Mike Christie <[email protected]>
This adds the ability for devices like rbd that support clustering to be able to hook into lio and execute operations across nodes. This patch just allows a user to specify a module, like rbd, to hook into lio's device init code.
The next patches will hook it into the device reset support.
Note: we will need support for distributed PRs, but I am still working on them.
Note2: In this patchset I took the approach is just adding a new target module that hooks into the places we need to in lio. I made it se_device based, because I thought we might want to be able to support clustered files too one day.
Some alternatives are:
1. I could export functions in backend files like target_core_iblock.c, target_core_file.c, etc then implement my own backend which for rbd would call the exported functions from target_core_iblock.c and implement new callouts for operations like lun reset.
For block device specific implementations:
2. I could add callouts to the request_queue or block_device or gendisk, then we could have lio call those callouts.
3. I could add a new block req type for PRs and resets.
--- drivers/target/Makefile | 3 +- drivers/target/target_core_cluster.c | 87 +++++++++++++++++++++++++++++++++++ drivers/target/target_core_configfs.c | 38 +++++++++++++++ drivers/target/target_core_device.c | 4 ++ include/target/target_core_base.h | 3 ++ include/target/target_core_cluster.h | 33 +++++++++++++ 6 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 drivers/target/target_core_cluster.c create mode 100644 include/target/target_core_cluster.h
drivers/target/Makefile +2 -1
@@ -14,7 +14,8 @@ target_core_mod-y := target_core_configfs.o \ target_core_ua.o \ target_core_rd.o \ target_core_stat.o \ - target_core_xcopy.o + target_core_xcopy.o \ + target_core_cluster.o obj-$(CONFIG_TARGET_CORE) += target_core_mod.o
drivers/target/target_core_cluster.c new file +87 -0
87 lines not on this page · raw message
drivers/target/target_core_configfs.c +38 -0
@@ -40,6 +40,7 @@#include <target/target_core_base.h> #include <target/target_core_backend.h> #include <target/target_core_fabric.h> +#include <target/target_core_cluster.h> #include <target/target_core_fabric_configfs.h> #include <target/target_core_configfs.h> #include <target/configfs_macros.h>
@@ -1762,6 +1763,42 @@ static struct target_core_configfs_attribute target_core_attr_dev_lba_map = { .store = target_core_store_dev_lba_map, }; +static ssize_t target_core_store_dev_cluster_api ( +void *p, +const char *page, +size_t count) +{ +struct se_device *dev = p; +char name[16 ], newline; +int ret; + +memset (name,0 ,sizeof (name)); + ret =sscanf (page,"%16s %c" , name, &newline); +if (!strlen (name)) +return -EINVAL ; + + ret =core_cluster_attach (dev, name); +if (ret) +return ret; +return count; +} + +static ssize_t target_core_show_dev_cluster_api (void *p,char *page) +{ +struct se_device *dev = p; + +return snprintf (page,PAGE_SIZE ,"%s\n" , dev->cluster_api ? + dev->cluster_api->name :"none" ); +} + +static struct target_core_configfs_attribute target_core_attr_dev_cluster_api = { + .attr = { .ca_owner =THIS_MODULE , + .ca_name ="cluster_api" , + .ca_mode =S_IRUGO |S_IWUSR }, + .show = target_core_show_dev_cluster_api, + .store = target_core_store_dev_cluster_api, +}; +static struct configfs_attribute *target_core_dev_attrs[] = { &target_core_attr_dev_info.attr, &target_core_attr_dev_control.attr,
@@ -1770,6 +1807,7 @@ static struct configfs_attribute *target_core_dev_attrs[] = { &target_core_attr_dev_enable.attr, &target_core_attr_dev_alua_lu_gp.attr, &target_core_attr_dev_lba_map.attr, + &target_core_attr_dev_cluster_api.attr, NULL, };
drivers/target/target_core_device.c +4 -0
@@ -40,6 +40,7 @@#include <target/target_core_base.h> #include <target/target_core_backend.h> +#include <target/target_core_cluster.h> #include <target/target_core_fabric.h> #include "target_core_internal.h"
@@ -1638,6 +1639,9 @@ void target_free_device(struct se_device *dev)WARN_ON (!list_empty (&dev->dev_sep_list)); +if (dev->cluster_api) +core_cluster_detach (dev); +if (dev->dev_flags &DF_CONFIGURED ) {destroy_workqueue (dev->tmr_wq);
include/target/target_core_base.h +3 -0
@@ -818,6 +818,9 @@ struct se_device {struct se_lun xcopy_lun;/* Protection Information */ int prot_length; +/* cluster api template */ +struct se_cluster_api *cluster_api; +void *cluster_dev_data; };struct se_hba {
include/target/target_core_cluster.h new file +33 -0
@@ -0,0 +1,33 @@ +#ifndef TARGET_CORE_CLUSTER_H +#define TARGET_CORE_CLUSTER_H + +#include <linux/list.h> +#include <linux/module.h> +#include <linux/blkdev.h> + +struct se_device ; + +struct se_cluster_api { +char *name; +struct module *owner; +struct list_head api_list; + +int (*attach_device)(struct se_device *dev); +int (*detach_device)(struct se_device *dev); +/** +* reset_device - stop and cleanup running commands on all nodes. +* @dev: LU's request queue to execute reset for +* @timeout: timeout for reset operation +* +* Return 0 for success or -Exyz error code. If the operation +* takes longer than timeout seconds then -ETIMEDOUT should be returned. +*/ +int (*reset_device)(struct se_device *dev,u32 timeout); +}; + +extern int core_cluster_api_register (struct se_cluster_api *); +extern void core_cluster_api_unregister (struct se_cluster_api *api); +extern int core_cluster_attach (struct se_device *dev,char *name); +extern void core_cluster_detach (struct se_device *dev); + +#endif
Signature · 1 line
1.8.3.1
PATCH 3/5 target: lun reset cluster hook into support
In reply to [email protected]From: Mike Christie <[email protected]>
This patch allows a module to hook into the lun reset support.
--- drivers/target/target_core_tmr.c | 18 ++++++++++++++++-- include/target/target_core_fabric.h | 3 +++ 2 files changed, 19 insertions(+), 2 deletions(-)
drivers/target/target_core_tmr.c +16 -2
@@ -33,6 +33,7 @@#include <target/target_core_base.h> #include <target/target_core_backend.h> #include <target/target_core_fabric.h> +#include <target/target_core_cluster.h> #include <target/target_core_configfs.h> #include "target_core_internal.h"
@@ -323,7 +324,7 @@ static void core_tmr_drain_state_list( } } -int core_tmr_lun_reset( +int target_local_tmr_lun_reset( struct se_device *dev, struct se_tmr_req *tmr, struct list_head *preempt_and_abort_list,
@@ -380,10 +381,23 @@ int core_tmr_lun_reset( }atomic_long_inc (&dev->num_resets); -pr_debug ("LUN_RESET: %s for [%s] Complete\n" , (preempt_and_abort_list) ?"Preempt" :"TMR" , dev->transport->name);return 0 ; } +EXPORT_SYMBOL (target_local_tmr_lun_reset); +int core_tmr_lun_reset ( +struct se_device *dev, +struct se_tmr_req *tmr, +struct list_head *preempt_and_abort_list, +struct se_cmd *prout_cmd) +{ +if (dev->cluster_api) +return dev->cluster_api->reset_device (dev,0 ); +else +return target_local_tmr_lun_reset (dev, tmr, + preempt_and_abort_list, + prout_cmd); +}
include/target/target_core_fabric.h +3 -0
@@ -133,6 +133,9 @@ void target_wait_for_sess_cmds(struct se_session *);int core_alua_check_nonop_delay (struct se_cmd *); + +int target_local_tmr_lun_reset (struct se_device *,struct se_tmr_req *, +struct list_head *,struct se_cmd *);int core_tmr_alloc_req (struct se_cmd *,void *,u8 ,gfp_t );void core_tmr_release_req (struct se_tmr_req *);int transport_generic_handle_tmr (struct se_cmd *);
Signature · 1 line
1.8.3.1
PATCH 4/5 target: add helper to go from iblock to request queue
In reply to [email protected]From: Mike Christie <[email protected]>
rbd works with block_devices/request_queues. This patch adds a helper so we can easily go from the iblock device to the request queue in the rbd_tcm module.
--- drivers/target/target_core_iblock.c | 6 ++++++ include/target/target_core_backend.h | 4 ++++ 2 files changed, 10 insertions(+)
drivers/target/target_core_iblock.c +6 -0
@@ -53,6 +53,12 @@ static inline struct iblock_dev *IBLOCK_DEV(struct se_device *dev) return container_of(dev, struct iblock_dev, dev); } +struct request_queue *ibock_se_device_to_q (struct se_device *dev) +{ +struct iblock_dev *ib_dev =IBLOCK_DEV (dev); +return bdev_get_queue (ib_dev->ibd_bd); +} +EXPORT_SYMBOL (ibock_se_device_to_q);static struct se_subsystem_api iblock_template;
include/target/target_core_backend.h +4 -0
@@ -139,4 +139,8 @@ int se_dev_set_max_sectors(struct se_device *, u32);int se_dev_set_optimal_sectors (struct se_device *,u32 );int se_dev_set_block_size (struct se_device *,u32 ); +/* backend helper to map from se_device to its queue */ +struct request_queue ; +struct request_queue *ibock_se_device_to_q (struct se_device *dev); +#endif /* TARGET_CORE_BACKEND_H */
Signature · 1 line
1.8.3.1
PATCH 5/5 rbd: implment lio cluster api module
In reply to [email protected]From: Mike Christie <[email protected]>
This has rbd implement support for the lio cluster api added in the previous
patches.
The patch is a little messy. In the next revision I will break it up better. I am mostly trying to make sure that the module interface is ok here.
--- drivers/block/Kconfig | 12 +++++ drivers/block/Makefile | 1 + drivers/block/rbd.h | 51 ++++++++++++++++++ drivers/block/rbd_main.c | 55 +++++++++++-------- drivers/block/rbd_tcm.c | 135 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 233 insertions(+), 21 deletions(-) create mode 100644 drivers/block/rbd.h create mode 100644 drivers/block/rbd_tcm.c
drivers/block/Kconfig +12 -0
@@ -548,6 +548,18 @@ config BLK_DEV_RBD If unsure, say N. +config BLK_DEV_RBD_TCM + bool "Clustered TCM using Rados block devices (RBD)" + depends on BLK_DEV_RBD + select TARGET_CORE + select TCM_IBLOCK + default n + help + Say Y here if you want to export a RBD device through multiple + TCM nodes. + + If unsure, say N. + config BLK_DEV_RSXX tristate "IBM Flash Adapter 900GB Full Height PCIe Device Driver" depends on PCI
drivers/block/Makefile +1 -0
@@ -40,6 +40,7 @@ obj-$(CONFIG_BLK_DEV_DRBD) += drbd/ obj-$(CONFIG_BLK_DEV_RBD) += rbd.o rbd-objs := rbd_main.o +rbd-$(CONFIG_BLK_DEV_RBD_TCM) += rbd_tcm.o obj-$(CONFIG_BLK_DEV_PCIESSD_MTIP32XX) += mtip32xx/
drivers/block/rbd.h new file +51 -0
51 lines not on this page · raw message
drivers/block/rbd_main.c +34 -21
124 lines not on this page · raw message
drivers/block/rbd_tcm.c new file +135 -0
135 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Can you explain why you want to hook into the lun reset code? I know the PR code needs to issue implicit task aborts, but I don't understand the need to do something with lun resets.
As for the API: I would much prefer to have things at the block layer in some form than adding side band protocol for specific functionality.
Quoted 3 lines · Christoph Hellwig
Can you explain why you want to hook into the lun reset code? I know the PR code needs to issue implicit task aborts, but I don't understand the need to do something with lun resets.
I thought if you exported a LU through multiple LIO nodes and its ALUA state was active optimized/non-optimized on those nodes, then you would have to do similar cleanup across the cluster. For example, don't we have to fail commands on those other nodes, and then also depending on the TAS bit value return task aborted statuses?
Quoted 3 lines
As for the API: I would much prefer to have things at the block layer in some form than adding side band protocol for specific functionality.
Ok. For what you need for your NFS cluster work, will you have a request_queue or block_device or gendisk?
Quoted 10 lines · Mike Christie
Quoted 3 lines · Christoph Hellwig
Can you explain why you want to hook into the lun reset code? I know the PR code needs to issue implicit task aborts, but I don't understand the need to do something with lun resets.
I thought if you exported a LU through multiple LIO nodes and its ALUA state was active optimized/non-optimized on those nodes, then you would have to do similar cleanup across the cluster. For example, don't we have to fail commands on those other nodes, and then also depending on the TAS bit value return task aborted statuses?
Oh, you're actually implementing active/active exports. Yes, in that case we'll need to distribute LUN resets.
Quoted 6 lines
Quoted 3 lines
As for the API: I would much prefer to have things at the block layer in some form than adding side band protocol for specific functionality.
Ok. For what you need for your NFS cluster work, will you have a
request_queueorblock_deviceor gendisk?
All of them. It's just another consumer of the in-kernel block devices interface.
Quoted 9 lines · Christoph Hellwig
Quoted 6 lines
Quoted 3 lines
As for the API: I would much prefer to have things at the block layer in some form than adding side band protocol for specific functionality.
Ok. For what you need for your NFS cluster work, will you have a
request_queueorblock_deviceor gendisk?All of them. It's just another consumer of the in-kernel block devices interface.
Will users use lio with what you are working on?
I ask because I am thinking it might be better to implement my own se_subsystem_api and sbc_ops structs and in my backend just make libceph calls directly for callouts like sbc_ops->execute_rw. So I would not have a block_device or request_queue if I went that route.
If I do my own backend, for reset support (PR support will be similar with callouts added to the se_subsystem_api) I would just need the patch below.
drivers/target/target_core_tmr.c +15 -1
@@ -323,7 +323,7 @@ static void core_tmr_drain_state_list( } } -int core_tmr_lun_reset( +int target_core_local_tmr_lun_reset( struct se_device *dev, struct se_tmr_req *tmr, struct list_head *preempt_and_abort_list,
@@ -386,4 +386,18 @@ int core_tmr_lun_reset( dev->transport->name);return 0 ; } +EXPORT_SYMBOL (target_core_local_tmr_lun_reset); +int core_tmr_lun_reset ( +struct se_device *dev, +struct se_tmr_req *tmr, +struct list_head *preempt_and_abort_list, +struct se_cmd *prout_cmd) +{ +if (dev->transport->reset_device) +return dev->transport->reset_device (dev); +else +return target_core_local_tmr_lun_reset (dev, tmr, + preempt_and_abort_list, + prout_cmd); +}
include/target/target_core_backend.h +4 -0
@@ -31,6 +31,7 @@ struct se_subsystem_api {struct se_device *(*alloc_device)(struct se_hba *,const char *);int (*configure_device)(struct se_device *);void (*free_device)(struct se_device *device); +int (*reset_device)(struct se_device *);ssize_t (*set_configfs_dev_params)(struct se_device *,const char *,ssize_t );
@@ -139,4 +139,7 @@ int se_dev_set_max_sectors(struct se_device *, u32);int se_dev_set_optimal_sectors (struct se_device *,u32 );int se_dev_set_block_size (struct se_device *,u32 ); +int target_core_local_tmr_lun_reset (struct se_device *,struct se_tmr_req *, +struct list_head *,struct se_cmd *); +#endif /* TARGET_CORE_BACKEND_H */
Hi Mike,
Quoted 13 lines · Mike Christie
Quoted 9 lines · Christoph Hellwig
Quoted 6 lines
Quoted 3 lines
As for the API: I would much prefer to have things at the block layer in some form than adding side band protocol for specific functionality.
Ok. For what you need for your NFS cluster work, will you have a
request_queueorblock_deviceor gendisk?All of them. It's just another consumer of the in-kernel block devices interface.
Will users use lio with what you are working on?
Quoted 8 lines
I ask because I am thinking it might be better to implement my own
se_subsystem_apiandsbc_opsstructs and in my backend just make libceph calls directly for callouts likesbc_ops->execute_rw. So I would not have ablock_deviceorrequest_queueif I went that route.If I do my own backend, for reset support (PR support will be similar with callouts added to the
se_subsystem_api) I would just need the patch below.
<nod>
I think extending se_subsystem_api will be the preferred approach for supporting backend active/active distributed LUN_RESET.
Quoted 47 lines
drivers/target/target_core_tmr.c +15
-1@@ -323,7 +323,7 @@ static void core_tmr_drain_state_list( } } -int core_tmr_lun_reset( +int target_core_local_tmr_lun_reset( struct se_device *dev, struct se_tmr_req *tmr, struct list_head *preempt_and_abort_list,@@ -386,4 +386,18 @@ int core_tmr_lun_reset( dev->transport->name);return 0 ; } +EXPORT_SYMBOL (target_core_local_tmr_lun_reset); +int core_tmr_lun_reset ( +struct se_device *dev, +struct se_tmr_req *tmr, +struct list_head *preempt_and_abort_list, +struct se_cmd *prout_cmd) +{ +if (dev->transport->reset_device) +return dev->transport->reset_device (dev); +else +return target_core_local_tmr_lun_reset (dev, tmr, + preempt_and_abort_list, + prout_cmd); +}include/target/target_core_backend.h +1
-0@@ -31,6 +31,7 @@ struct se_subsystem_api {struct se_device *(*alloc_device)(struct se_hba *,const char *);int (*configure_device)(struct se_device *);void (*free_device)(struct se_device *device); +int (*reset_device)(struct se_device *);ssize_t (*set_configfs_dev_params)(struct se_device *,const char *,ssize_t );
include/target/target_core_backend.h int se_dev_set_max_sectors(struct se_device *, u32); · line 145
Quoted 7 lines
include/target/target_core_backend.h +3
-0@@ -139,4 +139,7 @@ int se_dev_set_max_sectors(struct se_device *, u32);int se_dev_set_optimal_sectors (struct se_device *,u32 );int se_dev_set_block_size (struct se_device *,u32 ); +int target_core_local_tmr_lun_reset (struct se_device *,struct se_tmr_req *, +struct list_head *,struct se_cmd *); +#endif /* TARGET_CORE_BACKEND_H */
The backend driver will also need to enforce it's own TAS setting when providing a custom LUN_RESET callback in order to disable this logic within target_core_mod.
For persistent reservations ops, se_subsystem_api will require a PREEMPT_AND_ABORT specific callback too, yes..?
Do you see any additional SPC-3 PR specific required callbacks..?
--nab
Quoted 4 lines · Mike Christie
Quoted 2 lines
All of them. It's just another consumer of the in-kernel block devices interface.
Will users use lio with what you are working on?
It's the other way around. The pNFS block device uses a block device it wants to use persistent reservations on. If we do have a proper in-kernel API for that it could also work on say RBD and NVMe as long as they provide a mapping for SCSI3 PRs. For NVMe that exists as a spec, and for RBD it seems like you're about to deliver one.
Quoted 8 lines
I ask because I am thinking it might be better to implement my own
se_subsystem_apiandsbc_opsstructs and in my backend just make libceph calls directly for callouts likesbc_ops->execute_rw. So I would not have ablock_deviceorrequest_queueif I went that route.If I do my own backend, for reset support (PR support will be similar with callouts added to the
se_subsystem_api) I would just need the patch below.
It's defintively simpler, so for prototyping it might be the way to go. I think in the long run going for a general block device API will be more useful for everyone involved.
Quoted 10 lines · On 05/05/2015 04:56 AM, [email protected] wrote:
The following patches allow drivers like libceph/rbd to distribute execution of scsi task management functions across multiple nodes (still working on issues with distributed PRs).
In this patchset, I added a new type of callout/module for these cluster aware modules. The idea is that something like drbd could maybe do something optimized for them, or nbd could, or you could use dlm plus some file system, or do something cluster FS specific. For rbd we are making rados/libceph calls.
Quoted 8 lines
I am mostly looking for feedback on the hooks/callouts approach. I was not sure if we wanted to maybe instead do somethign like add new callouts to the
request_queue(request_queue->reset_q) orblock_deviceor add some new block layerREQ_TYPEs(REQ_TYPE_DEVICE_RESETorREQ_TYPE_PGR_REGISTER, etc). In this patchset I just added new callouts that modules can implement, because I thought this was most similar to how we do fabric modules and so it was a ok fit.
Oh shoot. Sorry. Forgot to cc the lio list on the first set of ceph/rbd patches which this patchset is built on. They are here:
http://thread.gmane.org/gmane.comp.file-systems.ceph.devel/24553