- "del NAME" to /proc/scsi_tgt/groups/GROUP_NAME/names deletes name "NAME" from group
"GROUP_NAME"
+ - "move NAME NEW_GROUP_NAME" to /proc/scsi_tgt/groups/OLD_GROUP_NAME/names
+ moves name "NAME" from group "OLD_GROUP_NAME" to group "NEW_GROUP_NAME".
+
- "clear" to /proc/scsi_tgt/groups/GROUP_NAME/names clears the list of names
for group "GROUP_NAME"
- "del NAME" to /proc/scsi_tgt/groups/GROUP_NAME/names deletes name "NAME" from group
"GROUP_NAME"
+ - "move NAME NEW_GROUP_NAME" to /proc/scsi_tgt/groups/OLD_GROUP_NAME/names
+ moves name "NAME" from group "OLD_GROUP_NAME" to group "NEW_GROUP_NAME".
+
- "clear" to /proc/scsi_tgt/groups/GROUP_NAME/names clears the list of names
for group "GROUP_NAME"
#define PRINT_WARNING(format, args...) \
do { \
if (strcmp(INFO_FLAG, LOG_FLAG)) { \
- PRINT_LOG_FLAG(LOG_FLAG, "***WARNING*** " format, args); \
+ PRINT_LOG_FLAG(LOG_FLAG, "***WARNING***: " format, args); \
} \
- PRINT_LOG_FLAG(INFO_FLAG, "***WARNING*** " format, args); \
+ PRINT_LOG_FLAG(INFO_FLAG, "***WARNING***: " format, args); \
} while (0)
#define PRINT_ERROR(format, args...) \
do { \
if (strcmp(ERROR_FLAG, LOG_FLAG)) { \
- PRINT_LOG_FLAG(LOG_FLAG, "***ERROR*** " format, args); \
+ PRINT_LOG_FLAG(LOG_FLAG, "***ERROR***: " format, args); \
} \
- PRINT_LOG_FLAG(ERROR_FLAG, "***ERROR*** " format, args); \
+ PRINT_LOG_FLAG(ERROR_FLAG, "***ERROR***: " format, args); \
} while (0)
#define PRINT_CRIT_ERROR(format, args...) \
do { \
/* if (strcmp(CRIT_FLAG, LOG_FLAG)) \
{ \
- PRINT_LOG_FLAG(LOG_FLAG, "***CRITICAL ERROR*** " format, args); \
+ PRINT_LOG_FLAG(LOG_FLAG, "***CRITICAL ERROR***: " format, args); \
}*/ \
- PRINT_LOG_FLAG(CRIT_FLAG, "***CRITICAL ERROR*** " format, args); \
+ PRINT_LOG_FLAG(CRIT_FLAG, "***CRITICAL ERROR***: " format, args); \
} while (0)
#define PRINT_INFO(format, args...) \
#define PRINT_WARNING(format, args...) \
do { \
- PRINT(INFO_FLAG, "%s: ***WARNING*** " \
+ PRINT(INFO_FLAG, "%s: ***WARNING***: " \
format, LOG_PREFIX, args); \
} while (0)
#define PRINT_ERROR(format, args...) \
do { \
- PRINT(ERROR_FLAG, "%s: ***ERROR*** " \
+ PRINT(ERROR_FLAG, "%s: ***ERROR***: " \
format, LOG_PREFIX, args); \
} while (0)
#define PRINT_CRIT_ERROR(format, args...) \
do { \
- PRINT(CRIT_FLAG, "%s: ***CRITICAL ERROR*** " \
+ PRINT(CRIT_FLAG, "%s: ***CRITICAL ERROR***: " \
format, LOG_PREFIX, args); \
} while (0)
#define PRINT_WARNING(format, args...) \
do { \
- PRINT(INFO_FLAG, "***WARNING*** " \
+ PRINT(INFO_FLAG, "***WARNING***: " \
format, args); \
} while (0)
#define PRINT_ERROR(format, args...) \
do { \
- PRINT(ERROR_FLAG, "***ERROR*** " \
+ PRINT(ERROR_FLAG, "***ERROR***: " \
format, args); \
} while (0)
#define PRINT_CRIT_ERROR(format, args...) \
do { \
- PRINT(CRIT_FLAG, "***CRITICAL ERROR*** " \
+ PRINT(CRIT_FLAG, "***CRITICAL ERROR***: " \
format, args); \
} while (0)
}
/* The activity supposed to be suspended and scst_mutex held */
-int scst_acg_remove_name(struct scst_acg *acg, const char *name)
+int scst_acg_remove_name(struct scst_acg *acg, const char *name, bool reassign)
{
int res = -EINVAL;
struct scst_acn *n;
if (res == 0) {
PRINT_INFO("Removed name %s from group %s", name,
acg->acg_name);
- scst_check_reassign_sessions();
+ if (reassign)
+ scst_check_reassign_sessions();
} else
PRINT_ERROR("Unable to find name %s in group %s", name,
acg->acg_name);
out_err:
if (res == 0) {
- PRINT_INFO("Attached SCSI target mid-level at "
- "scsi%d, channel %d, id %d, lun %d, type %d",
- scsidp->host->host_no, scsidp->channel, scsidp->id,
- scsidp->lun, scsidp->type);
+ PRINT_INFO("Attached to scsi%d, channel %d, id %d, lun %d, "
+ "type %d", scsidp->host->host_no, scsidp->channel,
+ scsidp->id, scsidp->lun, scsidp->type);
} else {
- PRINT_ERROR("Failed to attach SCSI target mid-level "
- "at scsi%d, channel %d, id %d, lun %d, type %d",
- scsidp->host->host_no, scsidp->channel, scsidp->id,
- scsidp->lun, scsidp->type);
+ PRINT_ERROR("Failed to to scsi%d, channel %d, id %d, lun %d, "
+ "type %d", scsidp->host->host_no, scsidp->channel,
+ scsidp->id, scsidp->lun, scsidp->type);
}
TRACE_EXIT_RES(res);
put_disk(dev->rq_disk);
scst_free_device(dev);
- PRINT_INFO("Detached SCSI target mid-level from scsi%d, channel %d, "
- "id %d, lun %d, type %d", scsidp->host->host_no,
- scsidp->channel, scsidp->id, scsidp->lun, scsidp->type);
+ PRINT_INFO("Detached from scsi%d, channel %d, id %d, lun %d, type %d",
+ scsidp->host->host_no, scsidp->channel, scsidp->id,
+ scsidp->lun, scsidp->type);
out_unblock:
mutex_unlock(&scst_mutex);
scst_resume_activity();
out:
- if (res > 0) {
- PRINT_INFO("Attached SCSI target mid-level to virtual "
- "device %s (id %d)", dev_name, dev->virt_id);
- } else {
- PRINT_INFO("Failed to attach SCSI target mid-level to "
- "virtual device %s", dev_name);
- }
+ if (res > 0)
+ PRINT_INFO("Attached to virtual device %s (id %d)",
+ dev_name, dev->virt_id);
+ else
+ PRINT_INFO("Failed to attach to virtual device %s", dev_name);
TRACE_EXIT_RES(res);
return res;
scst_assign_dev_handler(dev, &scst_null_devtype);
- PRINT_INFO("Detached SCSI target mid-level from virtual device %s "
- "(id %d)", dev->virt_name, dev->virt_id);
+ PRINT_INFO("Detached from virtual device %s (id %d)",
+ dev->virt_name, dev->virt_id);
scst_free_device(dev);
int scst_acg_remove_dev(struct scst_acg *acg, struct scst_device *dev);
int scst_acg_add_name(struct scst_acg *acg, const char *name);
-int scst_acg_remove_name(struct scst_acg *acg, const char *name);
+int scst_acg_remove_name(struct scst_acg *acg, const char *name, bool reassign);
void __scst_acg_remove_acn(struct scst_acn *n);
int scst_prepare_request_sense(struct scst_cmd *orig_cmd);
#define SCST_PROC_ACTION_SET 4
#define SCST_PROC_ACTION_ADD 5
#define SCST_PROC_ACTION_CLEAR 6
-#define SCST_PROC_ACTION_DEL 7
-#define SCST_PROC_ACTION_VALUE 8
-#define SCST_PROC_ACTION_ASSIGN 9
-#define SCST_PROC_ACTION_ADD_GROUP 10
-#define SCST_PROC_ACTION_DEL_GROUP 11
-#define SCST_PROC_ACTION_RENAME_GROUP 12
+#define SCST_PROC_ACTION_MOVE 7
+#define SCST_PROC_ACTION_DEL 8
+#define SCST_PROC_ACTION_VALUE 9
+#define SCST_PROC_ACTION_ASSIGN 10
+#define SCST_PROC_ACTION_ADD_GROUP 11
+#define SCST_PROC_ACTION_DEL_GROUP 12
+#define SCST_PROC_ACTION_RENAME_GROUP 13
static struct proc_dir_entry *scst_proc_scsi_tgt;
static struct proc_dir_entry *scst_proc_groups_root;
" echo \"clear\" >/proc/scsi_tgt/groups/GROUP_NAME/devices\n"
"\n"
" echo \"add|del NAME\" >/proc/scsi_tgt/groups/GROUP_NAME/names\n"
+" echo \"move NAME NEW_GROUP_NAME\" >/proc/scsi_tgt/groups/OLD_GROUP_NAME/names\n"
" echo \"clear\" >/proc/scsi_tgt/groups/GROUP_NAME/names\n"
"\n"
" echo \"DEC|0xHEX|0OCT\" >/proc/scsi_tgt/threads\n"
case SCST_PROC_ACTION_ADD_GROUP:
case SCST_PROC_ACTION_DEL_GROUP:
case SCST_PROC_ACTION_RENAME_GROUP:
- if (strcmp(p, SCST_DEFAULT_ACG_NAME) == 0) {
- PRINT_ERROR("Attempt to add/delete/rename predefined "
- "group \"%s\"", p);
- res = -EINVAL;
- goto out_up_free;
- }
-
pp = p;
while (!isspace(*pp) && *pp != '\0')
pp++;
if (*pp != '\0') {
- switch (action) {
- case SCST_PROC_ACTION_ADD_GROUP:
- case SCST_PROC_ACTION_DEL_GROUP:
- PRINT_ERROR("Wrong acg name %s", p);
- res = -EINVAL;
- goto out_up_free;
- default:
- *pp = '\0';
+ *pp = '\0';
+ pp++;
+ while (isspace(*pp) && *pp != '\0')
pp++;
- while (isspace(*pp) && *pp != '\0')
- pp++;
- break;
+ if (*pp != '\0') {
+ switch (action) {
+ case SCST_PROC_ACTION_ADD_GROUP:
+ case SCST_PROC_ACTION_DEL_GROUP:
+ PRINT_ERROR("%s", "Too many "
+ "arguments");
+ res = -EINVAL;
+ goto out_up_free;
+ }
}
}
+ if (strcmp(p, SCST_DEFAULT_ACG_NAME) == 0) {
+ PRINT_ERROR("Attempt to add/delete/rename predefined "
+ "group \"%s\"", p);
+ res = -EINVAL;
+ goto out_up_free;
+ }
+
list_for_each_entry(a, &scst_acg_list, scst_acg_list_entry) {
if (strcmp(a->acg_name, p) == 0) {
TRACE_DBG("group (acg) %p %s found",
res = -EINVAL;
goto out_up_free;
}
+
p = pp;
while (!isspace(*pp) && *pp != '\0')
pp++;
if (*pp != '\0') {
- PRINT_ERROR("Wrong acg name %s", p);
- res = -EINVAL;
- goto out_up_free;
+ *pp = '\0';
+ pp++;
+ while (isspace(*pp) && *pp != '\0')
+ pp++;
+ if (*pp != '\0') {
+ PRINT_ERROR("%s", "Too many arguments");
+ res = -EINVAL;
+ goto out_up_free;
+ }
}
rc = scst_proc_rename_acg(acg, p);
break;
size_t length, loff_t *off)
{
int res = length, rc = 0, action;
- char *buffer, *p, *e;
+ char *buffer, *p, *pp = NULL;
struct scst_acg *acg =
(struct scst_acg *)PDE(file->f_dentry->d_inode)->data;
struct scst_acn *n, *nn;
/*
* Usage: echo "add|del NAME" >/proc/scsi_tgt/groups/GROUP_NAME/names
+ * or echo "move NAME NEW_GROUP_NAME" >/proc/scsi_tgt/groups/OLD_GROUP_NAME/names"
* or echo "clear" >/proc/scsi_tgt/groups/GROUP_NAME/names
*/
p = buffer;
} else if (!strncasecmp("del ", p, 4)) {
p += 4;
action = SCST_PROC_ACTION_DEL;
+ } else if (!strncasecmp("move ", p, 5)) {
+ p += 5;
+ action = SCST_PROC_ACTION_MOVE;
} else {
PRINT_ERROR("Unknown action \"%s\"", p);
res = -EINVAL;
switch (action) {
case SCST_PROC_ACTION_ADD:
case SCST_PROC_ACTION_DEL:
+ case SCST_PROC_ACTION_MOVE:
while (isspace(*p) && *p != '\0')
p++;
- e = p;
- while (!isspace(*e) && *e != '\0')
- e++;
- *e = 0;
+ pp = p;
+ while (!isspace(*pp) && *pp != '\0')
+ pp++;
+ if (*pp != '\0') {
+ *pp = '\0';
+ pp++;
+ while (isspace(*pp) && *pp != '\0')
+ pp++;
+ if (*pp != '\0') {
+ switch (action) {
+ case SCST_PROC_ACTION_ADD:
+ case SCST_PROC_ACTION_DEL:
+ PRINT_ERROR("%s", "Too many "
+ "arguments");
+ res = -EINVAL;
+ goto out_free;
+ }
+ }
+ }
break;
}
rc = scst_acg_add_name(acg, p);
break;
case SCST_PROC_ACTION_DEL:
- rc = scst_acg_remove_name(acg, p);
+ rc = scst_acg_remove_name(acg, p, true);
break;
+ case SCST_PROC_ACTION_MOVE:
+ {
+ struct scst_acg *a, *new_acg = NULL;
+ char *name = p;
+ p = pp;
+ while (!isspace(*pp) && *pp != '\0')
+ pp++;
+ if (*pp != '\0') {
+ *pp = '\0';
+ pp++;
+ while (isspace(*pp) && *pp != '\0')
+ pp++;
+ if (*pp != '\0') {
+ PRINT_ERROR("%s", "Too many arguments");
+ res = -EINVAL;
+ goto out_free_unlock;
+ }
+ }
+ list_for_each_entry(a, &scst_acg_list, scst_acg_list_entry) {
+ if (strcmp(a->acg_name, p) == 0) {
+ TRACE_DBG("group (acg) %p %s found",
+ a, a->acg_name);
+ new_acg = a;
+ break;
+ }
+ }
+ if (new_acg == NULL) {
+ PRINT_ERROR("Group %s not found", p);
+ res = -EINVAL;
+ goto out_free_unlock;
+ }
+ rc = scst_acg_remove_name(acg, name, false);
+ if (rc != 0)
+ goto out_free_unlock;
+ rc = scst_acg_add_name(new_acg, name);
+ break;
+ }
case SCST_PROC_ACTION_CLEAR:
list_for_each_entry_safe(n, nn, &acg->acn_list,
acn_list_entry) {
break;
}
+out_free_unlock:
mutex_unlock(&scst_mutex);
out_free_resume: