mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-29 18:00:18 +00:00
Merge branch 'svn-trunk'
This commit is contained in:
@@ -156,4 +156,9 @@ struct scst_event_stpg_payload {
|
||||
struct scst_event_stpg_descr stpg_descriptors[0];
|
||||
};
|
||||
|
||||
#define SCST_EVENT_REG_VIRT_DEV 6
|
||||
struct scst_event_reg_vdev_payload {
|
||||
uint8_t device_name[SCST_MAX_NAME+10];
|
||||
};
|
||||
|
||||
#endif /* __SCST_EVENT_H */
|
||||
|
||||
@@ -484,6 +484,45 @@ out:
|
||||
return res;
|
||||
}
|
||||
|
||||
/* No locks */
|
||||
int scst_event_queue_reg_vdev(const char *dev_name)
|
||||
{
|
||||
int res = 0, event_entry_len;
|
||||
struct scst_event_entry *event_entry;
|
||||
struct scst_event *event;
|
||||
struct scst_event_reg_vdev_payload *payload;
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
event_entry_len = sizeof(*event_entry) + sizeof(*payload);
|
||||
event_entry = kzalloc(event_entry_len, GFP_ATOMIC);
|
||||
if (event_entry == NULL) {
|
||||
PRINT_ERROR("Unable to allocate event (size %d). Virtual "
|
||||
"device registration event is lost (device name %s)!",
|
||||
event_entry_len, dev_name);
|
||||
res = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
TRACE_MEM("event_entry %p (len %d) allocated", event_entry,
|
||||
event_entry_len);
|
||||
|
||||
event = &event_entry->event;
|
||||
|
||||
event->payload_len = sizeof(*payload);
|
||||
payload = (struct scst_event_reg_vdev_payload *)event->payload;
|
||||
|
||||
strlcpy(payload->device_name, dev_name,
|
||||
sizeof(payload->device_name));
|
||||
|
||||
scst_event_queue(SCST_EVENT_REG_VIRT_DEV,
|
||||
SCST_EVENT_SCST_CORE_ISSUER, event_entry);
|
||||
|
||||
out:
|
||||
TRACE_EXIT_RES(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
/* scst_event_mutex supposed to be held. Can release/reacquire it inside */
|
||||
static void scst_release_event_entry(struct scst_event_entry *e)
|
||||
{
|
||||
|
||||
@@ -1383,6 +1383,7 @@ int scst_register_virtual_device_node(struct scst_dev_type *dev_handler,
|
||||
|
||||
res = dev->virt_id;
|
||||
|
||||
scst_event_queue_reg_vdev(dev_name);
|
||||
PRINT_INFO("Attached to virtual device %s (id %d)", dev_name, res);
|
||||
|
||||
out:
|
||||
|
||||
@@ -872,6 +872,7 @@ int scst_event_queue_negative_luns_inquiry(const struct scst_tgt *tgt,
|
||||
const char *initiator_name);
|
||||
int scst_event_queue_ext_blocking_done(struct scst_device *dev, void *data, int len);
|
||||
int scst_event_queue_tm_fn_received(struct scst_mgmt_cmd *mcmd);
|
||||
int scst_event_queue_reg_vdev(const char *dev_name);
|
||||
|
||||
typedef void __printf(2, 3) (*scst_show_fn)(void *arg, const char *fmt, ...);
|
||||
void scst_trace_cmds(scst_show_fn show, void *arg);
|
||||
|
||||
@@ -85,6 +85,14 @@ static void usage(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void handle_reg_vdev_received(struct scst_event_user *event_user)
|
||||
{
|
||||
struct scst_event_reg_vdev_payload *p = (struct scst_event_reg_vdev_payload *)event_user->out_event.payload;
|
||||
printf("Virtual device %s registration received.\n", p->device_name);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void handle_tm_received(struct scst_event_user *event_user)
|
||||
{
|
||||
struct scst_event_tm_fn_received_payload *p = (struct scst_event_tm_fn_received_payload *)event_user->out_event.payload;
|
||||
@@ -278,6 +286,8 @@ again_poll:
|
||||
if (res != 0)
|
||||
PRINT_ERROR("SCST_EVENT_NOTIFY_DONE failed: %s "
|
||||
"(res %d)", strerror(errno), res);
|
||||
} else if (event_user->out_event.event_code == SCST_EVENT_REG_VIRT_DEV) {
|
||||
handle_reg_vdev_received(event_user);
|
||||
} else if (event_user->out_event.event_code == SCST_EVENT_TM_FN_RECEIVED)
|
||||
handle_tm_received(event_user);
|
||||
else if (event_user->out_event.event_code == SCST_EVENT_TM_FN_RECEIVED) {
|
||||
|
||||
Reference in New Issue
Block a user