: Added support for ->create_virtdevice_from_fd()
PATCH 1/1 : Added support for ->create_virtdevice_from_fd()
Quoted 1 line
From
9c6293c1bfe82d04a215fab22a3a850ea879a137Mon Sep 17 00:00:00 2001
From: Nicholas Bellinger <[email protected]>
Date: Mon, 20 Oct 2008 23:33:01 -0700
Subject: [PATCH] [Target_Core_Mod/IBLOCK]: Added support for ->create_virtdevice_from_fd()
Added se_subsystem_api_t->create_virtdevice_from_fd() for locating and claiming struct block_device from a passed open file descriptor for Linux/BLOCK storage objects.
This patch also adds target_core_device.c:linux_blockdevice_claim_bd() for use with iblock_create_virtdevice_from_fd().
This patch relies upon commit 362d4ef391699b0282dfbef3da633a561d9cbde7 for the target_core_mod configfs infrastructure.
Signed-off-by Nicholas A. Bellinger <[email protected]>
--- drivers/lio-core/target_core_device.c | 19 +++++- drivers/lio-core/target_core_device.h | 1 + drivers/lio-core/target_core_iblock.c | 116 ++++++++++++++++++++++++++------- drivers/lio-core/target_core_iblock.h | 2 + 4 files changed, 112 insertions(+), 26 deletions(-)
drivers/lio-core/target_core_device.c +18 -1
@@ -64,7 +64,24 @@#undef TARGET_CORE_DEVICE_Cextern se_global_t *se_global; -extern __u32 iscsi_unpack_lun (unsigned char *); + +extern struct block_device *linux_blockdevice_claim_bd (struct block_device *bd,void *claim_ptr) +{ +if (blkdev_get (bd,FMODE_WRITE |FMODE_READ ,O_RDWR ) <0 ) +return (NULL ); +/* +* If no claim pointer was passed from claimee, use struct block_device. +*/ +if (!claim_ptr) + claim_ptr = (void *)bd; + +if (bd_claim (bd, claim_ptr) <0 ) { +blkdev_put (bd); +return (NULL ); + } + +return (bd); +}extern struct block_device *__linux_blockdevice_claim (int major,int minor,void *claim_ptr,int *ret) {
drivers/lio-core/target_core_device.h +1 -0
@@ -27,6 +27,7 @@#ifndef TARGET_CORE_DEVICE_H #define TARGET_CORE_DEVICE_H +extern struct block_device *linux_blockdevice_claim_bd (struct block_device *,void *);extern struct block_device *__linux_blockdevice_claim (int ,int ,void *,int *);extern struct block_device *linux_blockdevice_claim (int ,int ,void *);extern int linux_blockdevice_release (int ,int ,struct block_device *);
drivers/lio-core/target_core_iblock.c +91 -25
151 lines not on this page · raw message
drivers/lio-core/target_core_iblock.h +2 -0
@@ -66,6 +66,7 @@ extern int iblock_check_hba_params (se_hbainfo_t *, struct iscsi_target *, int);extern ssize_t iblock_set_configfs_dev_params (se_hba_t *,se_subsystem_dev_t *,const char *,ssize_t );extern ssize_t iblock_check_configfs_dev_params (se_hba_t *,se_subsystem_dev_t *);extern ssize_t iblock_show_configfs_dev_params (se_hba_t *,se_subsystem_dev_t *,char *); +extern se_device_t *iblock_create_virtdevice_from_fd (se_subsystem_dev_t *,const char *);extern int iblock_check_dev_params (se_hba_t *,struct iscsi_target *,se_dev_transport_info_t *);extern int iblock_check_virtdev_params (se_devinfo_t *di,struct iscsi_target *);extern void iblock_get_plugin_info (void *,char *,int *);
@@ -160,6 +161,7 @@ se_subsystem_spc_t iblock_template_spc = ISCSI_IBLOCK_SPC; check_configfs_dev_params: iblock_check_configfs_dev_params, \ set_configfs_dev_params: iblock_set_configfs_dev_params, \ show_configfs_dev_params: iblock_show_configfs_dev_params, \ + create_virtdevice_from_fd: iblock_create_virtdevice_from_fd, \ check_virtdev_params: iblock_check_virtdev_params, \ check_dev_params: iblock_check_dev_params, \ get_plugin_info: iblock_get_plugin_info, \
Signature · 1 line
1.5.4.1