mirror of
https://github.com/SCST-project/scst.git
synced 2026-10-22 14:12:33 +00:00
scst: Keep diagnostic strings whole and space format fragments
Keep complete diagnostic strings together and separate adjacent portable format macros with spaces in the source. Preserve literal bytes, numeric escape boundaries, argument conversions and severity; move arguments to continuation lines where needed. Pass constant messages directly to the logging macros and use pr_info_once for the two latency notices. This helper is already available in Linux 3.10. Checkpatch reports SPLIT_STRING: quoted string split across lines Checkpatch reports CONCATENATED_STRING: Concatenated strings should use spaces between elements Checkpatch reports LONG_LINE, PREFER_PR_LEVEL. One example: line length of 102 exceeds 100 columns
This commit is contained in:
@@ -287,8 +287,7 @@ static int chap_decode_string(char *encoded, u8 *decode_buf, int buf_len, int en
|
||||
{
|
||||
if (encoding_fmt == HEX_FORMAT) {
|
||||
if ((strlen(encoded) - 2) > (2 * buf_len)) {
|
||||
log_error("%s(%d) BUG? "
|
||||
" buf[%d] !sufficient to decode string[%d]",
|
||||
log_error("%s(%d) BUG? buf[%d] !sufficient to decode string[%d]",
|
||||
__func__, __LINE__, buf_len, (int) strlen(encoded));
|
||||
return CHAP_TARGET_ERROR;
|
||||
}
|
||||
@@ -296,8 +295,7 @@ static int chap_decode_string(char *encoded, u8 *decode_buf, int buf_len, int en
|
||||
|
||||
} else if (encoding_fmt == BASE64_FORMAT) {
|
||||
if ((strlen(encoded) - 2) > ((buf_len - 1) / 3 + 1) * 4) {
|
||||
log_error("%s(%d) BUG? "
|
||||
" buf[%d] !sufficient to decode string[%d]",
|
||||
log_error("%s(%d) BUG? buf[%d] !sufficient to decode string[%d]",
|
||||
__func__, __LINE__, buf_len, (int) strlen(encoded));
|
||||
return CHAP_TARGET_ERROR;
|
||||
}
|
||||
|
||||
@@ -522,8 +522,8 @@ int __config_account_add(struct target *target, int dir, char *name, const char
|
||||
|
||||
/* Check for minimum RFC defined value */
|
||||
if (strlen(pass) < 12) {
|
||||
log_error("Secret for user %s is too short. At least 12 bytes "
|
||||
"are required\n", name);
|
||||
log_error("Secret for user %s is too short. At least 12 bytes are required\n",
|
||||
name);
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
@@ -545,8 +545,7 @@ int __config_account_add(struct target *target, int dir, char *name, const char
|
||||
struct iscsi_attr *old;
|
||||
|
||||
list_for_each_entry(old, list, ulist) {
|
||||
log_warning("Only one outgoing %s account is "
|
||||
"supported. Replacing the old one.\n",
|
||||
log_warning("Only one outgoing %s account is supported. Replacing the old one.\n",
|
||||
target ? "target" : "discovery");
|
||||
account_destroy(old);
|
||||
break;
|
||||
@@ -563,8 +562,8 @@ int __config_account_add(struct target *target, int dir, char *name, const char
|
||||
goto out_destroy;
|
||||
}
|
||||
|
||||
log_debug(1, "User %s (%p, sysfs name %s) added to target %s "
|
||||
"(direction %s)", ISCSI_USER_NAME(user), user, user->sysfs_name,
|
||||
log_debug(1, "User %s (%p, sysfs name %s) added to target %s (direction %s)",
|
||||
ISCSI_USER_NAME(user), user, user->sysfs_name,
|
||||
target ? target->name : "discovery",
|
||||
(dir == ISCSI_USER_DIR_OUTGOING) ? "outgoing" : "incoming");
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ int kernel_open(void)
|
||||
err = ioctl(ctlfd, REGISTER_USERD, ®);
|
||||
if (err != 0) {
|
||||
err = -errno;
|
||||
log_error("Unable to register: %s. Incompatible version of the "
|
||||
"kernel module?\n", strerror(errno));
|
||||
log_error("Unable to register: %s. Incompatible version of the kernel module?\n",
|
||||
strerror(errno));
|
||||
goto out_close;
|
||||
} else {
|
||||
log_debug(0, "max_data_seg_len %d, max_queued_cmds %d",
|
||||
@@ -266,8 +266,8 @@ int kernel_initiator_allowed(u32 tid, const char *full_initiator_name)
|
||||
err = ioctl(ctrl_fd, ISCSI_INITIATOR_ALLOWED, &info);
|
||||
if (err < 0) {
|
||||
err = -errno;
|
||||
log_error("Can't find out initiator %s permissions (%s, "
|
||||
"tid %u", full_initiator_name, strerror(errno), tid);
|
||||
log_error("Can't find out initiator %s permissions (%s, tid %u",
|
||||
full_initiator_name, strerror(errno), tid);
|
||||
}
|
||||
|
||||
return err;
|
||||
@@ -397,8 +397,7 @@ int kernel_session_create(struct connection *conn)
|
||||
res = ioctl(ctrl_fd, ADD_SESSION, &info);
|
||||
if (res < 0) {
|
||||
res = -errno;
|
||||
log_error("Can't create sess 0x%" PRIx64 " (tid %d, "
|
||||
"initiator %s): %s\n", conn->sess->sid.id64, conn->tid,
|
||||
log_error("Can't create sess 0x%" PRIx64 " (tid %d, initiator %s): %s\n", conn->sess->sid.id64, conn->tid,
|
||||
conn->sess->initiator, strerror(errno));
|
||||
}
|
||||
|
||||
|
||||
@@ -89,8 +89,8 @@ static int nl_read(int fd, void *data, int len, bool wait)
|
||||
if (res < 0)
|
||||
res = -EPIPE;
|
||||
else if (res < iov[1].iov_len)
|
||||
log_error("read netlink fd (%d) error: received %d"
|
||||
" bytes but expected %zd bytes (%d)", fd, res,
|
||||
log_error("read netlink fd (%d) error: received %d bytes but expected %zd bytes (%d)",
|
||||
fd, res,
|
||||
iov[1].iov_len, len);
|
||||
}
|
||||
|
||||
@@ -138,8 +138,8 @@ static int send_mgmt_cmd_res(u32 tid, u32 cookie, u32 req_cmd, int result,
|
||||
res = ioctl(ctrl_fd, MGMT_CMD_CALLBACK, &cinfo);
|
||||
if (res != 0) {
|
||||
res = -errno;
|
||||
log_error("Can't send mgmt reply (cookie %d, result %d, "
|
||||
"res %d): %s\n", cookie, result, res, strerror(errno));
|
||||
log_error("Can't send mgmt reply (cookie %d, result %d, res %d): %s\n",
|
||||
cookie, result, res, strerror(errno));
|
||||
}
|
||||
|
||||
return res;
|
||||
@@ -1315,8 +1315,7 @@ retry:
|
||||
|
||||
conn = conn_find(session, event.cid);
|
||||
if (!conn) {
|
||||
log_error("Connection %x for session %#" PRIx64 " not "
|
||||
"found", event.cid, event.sid);
|
||||
log_error("Connection %x for session %#" PRIx64 " not found", event.cid, event.sid);
|
||||
goto retry;
|
||||
}
|
||||
|
||||
|
||||
@@ -144,8 +144,8 @@ static int iscsid_request_send(int fd, const struct iscsi_adm_req *req)
|
||||
|
||||
if (ret != sizeof(*req)) {
|
||||
err = (ret < 0) ? -errno : -EIO;
|
||||
fprintf(stderr, "%s failed: written %d, to write %d, "
|
||||
"error: %s\n", __func__, ret, err, strerror(-err));
|
||||
fprintf(stderr, "%s failed: written %d, to write %d, error: %s\n",
|
||||
__func__, ret, err, strerror(-err));
|
||||
} else {
|
||||
err = 0;
|
||||
}
|
||||
|
||||
@@ -572,8 +572,7 @@ again:
|
||||
conn->req.bhs.datalength[2]);
|
||||
conn->rwsize = (conn->req.ahssize + conn->req.datasize + 3) & -4;
|
||||
if (conn->rwsize > INCOMING_BUFSIZE) {
|
||||
log_warning("Recv PDU with invalid size %d "
|
||||
"(max: %d)", conn->rwsize,
|
||||
log_warning("Recv PDU with invalid size %d (max: %d)", conn->rwsize,
|
||||
INCOMING_BUFSIZE);
|
||||
conn->state = STATE_DROP;
|
||||
goto out;
|
||||
|
||||
+17
-26
@@ -287,14 +287,12 @@ static int login_check_reinstatement(struct connection *conn)
|
||||
if (session) {
|
||||
if (req->sid.id.tsih == 0) {
|
||||
/* Kernel will do session reinstatement */
|
||||
log_debug(1, "Session sid %#" PRIx64 " reinstatement "
|
||||
"detected (tid %d, initiator %s)", req->sid.id64,
|
||||
log_debug(1, "Session sid %#" PRIx64 " reinstatement detected (tid %d, initiator %s)", req->sid.id64,
|
||||
conn->tid, conn->initiator);
|
||||
res = ISCSI_SESS_REINSTATEMENT;
|
||||
} else if (req->sid.id.tsih != session->sid.id.tsih) {
|
||||
log_error("TSIH for existing session sid %#" PRIx64
|
||||
") doesn't match (tid %d, initiator %s, sid requested "
|
||||
"%#" PRIx64, session->sid.id64, conn->tid,
|
||||
") doesn't match (tid %d, initiator %s, sid requested %#" PRIx64, session->sid.id64, conn->tid,
|
||||
conn->initiator, req->sid.id64);
|
||||
/* Fail the login */
|
||||
login_rsp_ini_err(conn, ISCSI_STATUS_SESSION_NOT_FOUND);
|
||||
@@ -305,16 +303,15 @@ static int login_check_reinstatement(struct connection *conn)
|
||||
|
||||
if (c) {
|
||||
/* Kernel will do connection reinstatement */
|
||||
log_debug(1, "Conn %x reinstatement "
|
||||
"detected (tid %d, sid %#" PRIx64
|
||||
log_debug(1, "Conn %x reinstatement detected (tid %d, sid %#" PRIx64
|
||||
"initiator %s)", conn->cid, conn->tid,
|
||||
req->sid.id64, conn->initiator);
|
||||
conn->sess = session;
|
||||
list_add_tail(&conn->clist, &session->conn_list);
|
||||
res = ISCSI_CONN_REINSTATEMENT;
|
||||
} else {
|
||||
log_error("Only a single connection supported "
|
||||
"(initiator %s)", conn->initiator);
|
||||
log_error("Only a single connection supported (initiator %s)",
|
||||
conn->initiator);
|
||||
/* Fail the login */
|
||||
login_rsp_ini_err(conn, ISCSI_STATUS_TOO_MANY_CONN);
|
||||
res = -1;
|
||||
@@ -323,8 +320,7 @@ static int login_check_reinstatement(struct connection *conn)
|
||||
}
|
||||
} else {
|
||||
if (req->sid.id.tsih != 0) {
|
||||
log_error("Requested TSIH not 0 (TSIH %d, tid %d, "
|
||||
"initiator %s, sid requisted %#" PRIx64 ")",
|
||||
log_error("Requested TSIH not 0 (TSIH %d, tid %d, initiator %s, sid requisted %#" PRIx64 ")",
|
||||
req->sid.id.tsih, conn->tid, conn->initiator,
|
||||
req->sid.id64);
|
||||
/* Fail the login */
|
||||
@@ -332,8 +328,7 @@ static int login_check_reinstatement(struct connection *conn)
|
||||
res = -1;
|
||||
goto out;
|
||||
} else {
|
||||
log_debug(1, "New session sid %#" PRIx64 "(tid %d, "
|
||||
"initiator %s)", req->sid.id64,
|
||||
log_debug(1, "New session sid %#" PRIx64 "(tid %d, initiator %s)", req->sid.id64,
|
||||
conn->tid, conn->initiator);
|
||||
}
|
||||
}
|
||||
@@ -443,8 +438,8 @@ static int text_check_params(struct connection *conn)
|
||||
for (i = 0, cnt = 0; session_keys[i].name; i++) {
|
||||
if (p[i].val != session_keys[i].rfc_def) {
|
||||
if (p[i].key_state == KEY_STATE_START) {
|
||||
log_debug(1, "Key %s was not negotiated, use RFC "
|
||||
"defined default %d", session_keys[i].name,
|
||||
log_debug(1, "Key %s was not negotiated, use RFC defined default %d",
|
||||
session_keys[i].name,
|
||||
session_keys[i].rfc_def);
|
||||
p[i].val = session_keys[i].rfc_def;
|
||||
continue;
|
||||
@@ -884,8 +879,8 @@ static void login_start(struct connection *conn)
|
||||
!target_portal_allowed(target, conn->target_portal,
|
||||
conn->initiator) ||
|
||||
!isns_scn_access_allowed(conn->tid, name)) {
|
||||
log_info("Initiator %s not allowed to connect to "
|
||||
"target %s", name, target_name);
|
||||
log_info("Initiator %s not allowed to connect to target %s",
|
||||
name, target_name);
|
||||
login_rsp_ini_err(conn, ISCSI_STATUS_TGT_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
@@ -925,9 +920,8 @@ static void login_start(struct connection *conn)
|
||||
target->sessions_count++;
|
||||
conn->sessions_count_incremented = 1;
|
||||
} else {
|
||||
log_warning("Initiator %s not allowed to connect to "
|
||||
"target %s - max sessions limit "
|
||||
"reached (%d)", name, target_name,
|
||||
log_warning("Initiator %s not allowed to connect to target %s - max sessions limit reached (%d)",
|
||||
name, target_name,
|
||||
target->target_params[key_max_sessions]);
|
||||
login_rsp_tgt_err(conn, ISCSI_STATUS_NO_RESOURCES);
|
||||
conn->state = STATE_EXIT;
|
||||
@@ -1207,8 +1201,7 @@ static void cmnd_exec_login(struct connection *conn)
|
||||
*/
|
||||
if (!list_empty(&conn->rsp_buf_list) &&
|
||||
!list_length_is_one(&conn->rsp_buf_list)) {
|
||||
log_error("Target error: \'key=value\' pairs spanning several "
|
||||
"Login PDUs are not implemented, yet\n");
|
||||
log_error("Target error: \'key=value\' pairs spanning several Login PDUs are not implemented, yet\n");
|
||||
goto target_err;
|
||||
}
|
||||
|
||||
@@ -1256,9 +1249,8 @@ static int text_scan_text(struct connection *conn)
|
||||
value = conn->sess->target->name;
|
||||
} else if (strcasecmp(value, "All") == 0) {
|
||||
if (conn->session_type != SESSION_DISCOVERY) {
|
||||
log_error("SendTargets=All allowed only in "
|
||||
"Discovery session, rejecting "
|
||||
"(initiator %s)", conn->initiator);
|
||||
log_error("SendTargets=All allowed only in Discovery session, rejecting (initiator %s)",
|
||||
conn->initiator);
|
||||
cmnd_reject(conn, ISCSI_REASON_PROTOCOL_ERROR);
|
||||
res = -EINVAL;
|
||||
goto out;
|
||||
@@ -1303,8 +1295,7 @@ static void cmnd_exec_text(struct connection *conn)
|
||||
else
|
||||
conn->ttt = ISCSI_RESERVED_TAG;
|
||||
} else if (list_empty(&conn->rsp_buf_list) || conn->ttt != req->ttt) {
|
||||
log_error("Rejecting unexpected text request. TTT recv %#x, "
|
||||
"expected %#x; %stext segments queued\n",
|
||||
log_error("Rejecting unexpected text request. TTT recv %#x, expected %#x; %stext segments queued\n",
|
||||
req->ttt, conn->ttt, list_empty(&conn->rsp_buf_list) ?
|
||||
"no " : "");
|
||||
cmnd_reject(conn, ISCSI_REASON_INVALID_PDU_FIELD);
|
||||
|
||||
@@ -49,8 +49,7 @@ static int driver_major(const char *dev)
|
||||
fclose(f);
|
||||
|
||||
if (devn < 0)
|
||||
printf("cannot find %s in /proc/devices - "
|
||||
"make sure the module is loaded\n", dev);
|
||||
printf("cannot find %s in /proc/devices - make sure the module is loaded\n", dev);
|
||||
|
||||
out:
|
||||
return devn;
|
||||
|
||||
@@ -174,7 +174,7 @@ out_free:
|
||||
|
||||
void session_free(struct session *session)
|
||||
{
|
||||
log_debug(1, "Freeing session sid %#"PRIx64, session->sid.id64);
|
||||
log_debug(1, "Freeing session sid %#" PRIx64, session->sid.id64);
|
||||
|
||||
if (session->target) {
|
||||
struct target *target = session->target;
|
||||
|
||||
+1
-2
@@ -953,8 +953,7 @@ static void dump_lockspace(const char *cl_dev_id)
|
||||
char *argv2 = kasprintf(GFP_KERNEL,
|
||||
"{ echo lockspace-dump-start;"
|
||||
" grep -aH '' /sys/kernel/debug/dlm/%s%s*;"
|
||||
" echo lockspace-dump-end; } 2>&1 |"
|
||||
" while read line; do logger \"$line\"; done",
|
||||
" echo lockspace-dump-end; } 2>&1 | while read line; do logger \"$line\"; done",
|
||||
SCST_DLM_LOCKSPACE_PFX, cl_dev_id);
|
||||
char *argv[] = { argv0, argv1, argv2, NULL };
|
||||
char *envp[] = {
|
||||
|
||||
+7
-7
@@ -6175,7 +6175,7 @@ static void scst_complete_request_sense(struct scst_cmd *req_cmd)
|
||||
TRACE_MGMT_DBG("REQUEST SENSE %p was aborted, but orig_cmd %p - not, retry",
|
||||
req_cmd, orig_cmd);
|
||||
} else {
|
||||
PRINT_ERROR("%s", "Unable to get the sense via REQUEST SENSE, returning HARDWARE ERROR");
|
||||
PRINT_ERROR("Unable to get the sense via REQUEST SENSE, returning HARDWARE ERROR");
|
||||
scst_set_cmd_error(orig_cmd,
|
||||
SCST_LOAD_SENSE(scst_sense_internal_failure));
|
||||
}
|
||||
@@ -7941,7 +7941,7 @@ struct scst_mgmt_cmd *scst_alloc_mgmt_cmd(gfp_t gfp_mask)
|
||||
|
||||
mcmd = mempool_alloc(scst_mgmt_mempool, gfp_mask);
|
||||
if (!mcmd) {
|
||||
PRINT_CRIT_ERROR("%s", "Allocation of management command failed, some commands and their data could leak");
|
||||
PRINT_CRIT_ERROR("Allocation of management command failed, some commands and their data could leak");
|
||||
goto out;
|
||||
}
|
||||
memset(mcmd, 0, sizeof(*mcmd));
|
||||
@@ -13391,7 +13391,7 @@ static void scst_alloc_set_UA(struct scst_tgt_dev *tgt_dev,
|
||||
|
||||
UA_entry = mempool_alloc(scst_ua_mempool, GFP_ATOMIC);
|
||||
if (!UA_entry) {
|
||||
PRINT_CRIT_ERROR("%s", "UNIT ATTENTION memory allocation failed. The UNIT ATTENTION on some sessions will be missed");
|
||||
PRINT_CRIT_ERROR("UNIT ATTENTION memory allocation failed. The UNIT ATTENTION on some sessions will be missed");
|
||||
PRINT_BUFFER("Lost UA", sense, sense_len);
|
||||
goto out;
|
||||
}
|
||||
@@ -16125,16 +16125,16 @@ static void __scst_update_latency_stats(struct scst_cmd *cmd,
|
||||
if (stat && ktime_to_ns(cmd->last_state_update) != 0) {
|
||||
delta = ktime_to_ns(ktime_sub(now, cmd->last_state_update));
|
||||
if (delta > NSEC_PER_SEC) {
|
||||
printk_once(KERN_INFO "%d: ignoring large time delta %lld\n",
|
||||
cmd->state, delta);
|
||||
pr_info_once("%d: ignoring large time delta %lld\n",
|
||||
cmd->state, delta);
|
||||
delta = 0;
|
||||
}
|
||||
do_div(delta, 100);
|
||||
#ifdef SCST_MEASURE_CLOCK_CYCLES
|
||||
deltac = nowc - cmd->last_state_update_tsc;
|
||||
if (deltac < 0 || deltac > tsc_khz * 1000) {
|
||||
printk_once(KERN_INFO "%d: ignoring large cc delta %lld\n",
|
||||
cmd->state, deltac);
|
||||
pr_info_once("%d: ignoring large cc delta %lld\n",
|
||||
cmd->state, deltac);
|
||||
deltac = 0;
|
||||
}
|
||||
do_div(deltac, 100);
|
||||
|
||||
@@ -846,9 +846,7 @@ static ssize_t scst_tgtt_mgmt_show(struct kobject *kobj, struct kobj_attribute *
|
||||
static const char help[] =
|
||||
"Usage: echo \"add_target target_name [parameters]\" >mgmt\n"
|
||||
" echo \"del_target target_name\" >mgmt\n"
|
||||
"%s%s"
|
||||
"%s"
|
||||
"\n"
|
||||
"%s%s%s\n"
|
||||
"where parameters are one or more param_name=value pairs separated by ';'\n\n"
|
||||
"%s%s%s%s%s%s%s%s%s%s\n";
|
||||
struct scst_tgt_template *tgtt;
|
||||
@@ -5908,9 +5906,7 @@ static ssize_t scst_devt_mgmt_show(struct kobject *kobj, struct kobj_attribute *
|
||||
static const char help[] =
|
||||
"Usage: echo \"add_device device_name [parameters]\" >mgmt\n"
|
||||
" echo \"del_device device_name\" >mgmt\n"
|
||||
"%s%s"
|
||||
"%s"
|
||||
"\n"
|
||||
"%s%s%s\n"
|
||||
"where parameters are one or more param_name=value pairs separated by ';'\n\n"
|
||||
"%s%s%s%s%s%s%s%s%s\n";
|
||||
struct scst_dev_type *devt;
|
||||
|
||||
@@ -1746,9 +1746,7 @@ static int __init scst_local_init(void)
|
||||
|
||||
#ifndef INSIDE_KERNEL_TREE
|
||||
#if defined(CONFIG_HIGHMEM4G) || defined(CONFIG_HIGHMEM64G)
|
||||
PRINT_ERROR("HIGHMEM kernel configurations are not supported. "
|
||||
"Consider changing VMSPLIT option or use a 64-bit configuration instead. "
|
||||
"See SCST core README file for details.");
|
||||
PRINT_ERROR("HIGHMEM kernel configurations are not supported. Consider changing VMSPLIT option or use a 64-bit configuration instead. See SCST core README file for details.");
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
#endif
|
||||
|
||||
+12
-14
@@ -212,14 +212,13 @@ int main(int argc, char **argv)
|
||||
switch (res) {
|
||||
case ESRCH:
|
||||
case EBUSY:
|
||||
TRACE_MGMT_DBG("SCST_EVENT_GET_NEXT_EVENT returned "
|
||||
"%d (%s)", res, strerror(res));
|
||||
TRACE_MGMT_DBG("SCST_EVENT_GET_NEXT_EVENT returned %d (%s)",
|
||||
res, strerror(res));
|
||||
/* fall through */
|
||||
case EINTR:
|
||||
continue;
|
||||
case EAGAIN:
|
||||
TRACE_DBG("SCST_EVENT_GET_NEXT_EVENT, returned "
|
||||
"EAGAIN (%d)", res);
|
||||
TRACE_DBG("SCST_EVENT_GET_NEXT_EVENT, returned EAGAIN (%d)", res);
|
||||
if (non_blocking)
|
||||
break;
|
||||
continue;
|
||||
@@ -240,8 +239,8 @@ again_poll:
|
||||
case ESRCH:
|
||||
case EBUSY:
|
||||
case EAGAIN:
|
||||
TRACE_MGMT_DBG("poll() returned %d "
|
||||
"(%s)", res, strerror(res));
|
||||
TRACE_MGMT_DBG("poll() returned %d (%s)",
|
||||
res, strerror(res));
|
||||
case EINTR:
|
||||
goto again_poll;
|
||||
default:
|
||||
@@ -267,8 +266,7 @@ again_poll:
|
||||
if (event_user->out_event.event_code == 0x12345) {
|
||||
struct scst_event_notify_done d;
|
||||
|
||||
PRINT_INFO("%s", "Press any key to send reply to event "
|
||||
"0x12345");
|
||||
PRINT_INFO("%s", "Press any key to send reply to event 0x12345");
|
||||
getchar();
|
||||
|
||||
memset(&d, 0, sizeof(d));
|
||||
@@ -276,8 +274,8 @@ again_poll:
|
||||
d.status = -19;
|
||||
res = ioctl(event_fd, SCST_EVENT_NOTIFY_DONE, &d);
|
||||
if (res != 0)
|
||||
PRINT_ERROR("SCST_EVENT_NOTIFY_DONE failed: %s "
|
||||
"(res %d)", strerror(errno), res);
|
||||
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) {
|
||||
@@ -290,8 +288,8 @@ again_poll:
|
||||
d.status = -20;
|
||||
res = ioctl(event_fd, SCST_EVENT_NOTIFY_DONE, &d);
|
||||
if (res != 0)
|
||||
PRINT_ERROR("SCST_EVENT_NOTIFY_DONE failed: %s "
|
||||
"(res %d)", strerror(errno), res);
|
||||
PRINT_ERROR("SCST_EVENT_NOTIFY_DONE failed: %s (res %d)",
|
||||
strerror(errno), res);
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -308,8 +306,8 @@ again_poll:
|
||||
|
||||
res = ioctl(event_fd, SCST_EVENT_DISALLOW_EVENT, &e);
|
||||
if (res != 0) {
|
||||
PRINT_ERROR("SCST_EVENT_DISALLOW_EVENT failed: "
|
||||
"%s (res %d)", strerror(errno), res);
|
||||
PRINT_ERROR("SCST_EVENT_DISALLOW_EVENT failed: %s (res %d)",
|
||||
strerror(errno), res);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
+53
-63
@@ -271,12 +271,12 @@ static int do_exec(struct vdisk_cmd *vcmd)
|
||||
#endif
|
||||
cmd->pbuf = (unsigned long)dev->alloc_fn(cmd->alloc_len);
|
||||
vcmd->may_need_to_free_pbuf = 1;
|
||||
TRACE_MEM("Buf %"PRIx64" alloced, len %d", cmd->pbuf,
|
||||
TRACE_MEM("Buf %" PRIx64 " alloced, len %d", cmd->pbuf,
|
||||
cmd->alloc_len);
|
||||
reply->pbuf = cmd->pbuf;
|
||||
if (cmd->pbuf == 0) {
|
||||
TRACE(TRACE_OUT_OF_MEM, "Unable to allocate buffer "
|
||||
"(len %d)", cmd->alloc_len);
|
||||
TRACE(TRACE_OUT_OF_MEM, "Unable to allocate buffer (len %d)",
|
||||
cmd->alloc_len);
|
||||
#ifndef DEBUG_NOMEM
|
||||
set_busy(vcmd);
|
||||
#endif
|
||||
@@ -288,12 +288,11 @@ static int do_exec(struct vdisk_cmd *vcmd)
|
||||
reply->resp_data_len = cmd->bufflen;
|
||||
|
||||
loff = (loff_t)lba_start << dev->block_shift;
|
||||
TRACE_DBG("cmd %d, buf %"PRIx64", lba_start %"PRId64", loff %"PRId64
|
||||
", data_len %"PRId64, vcmd->cmd->cmd_h, cmd->pbuf, lba_start,
|
||||
TRACE_DBG("cmd %d, buf %" PRIx64 ", lba_start %" PRId64 ", loff %" PRId64
|
||||
", data_len %" PRId64, vcmd->cmd->cmd_h, cmd->pbuf, lba_start,
|
||||
(uint64_t)loff, data_len);
|
||||
if (loff < 0 || data_len < 0 || ((loff + data_len) > dev->file_size)) {
|
||||
PRINT_INFO("Access beyond the end of the device "
|
||||
"(%"PRId64" of %"PRId64", len %"PRId64")", (uint64_t)loff,
|
||||
PRINT_INFO("Access beyond the end of the device (%" PRId64 " of %" PRId64 ", len %" PRId64 ")", (uint64_t)loff,
|
||||
(uint64_t)dev->file_size, data_len);
|
||||
set_cmd_error(vcmd, SCST_LOAD_SENSE(
|
||||
scst_sense_block_out_range_error));
|
||||
@@ -306,8 +305,8 @@ static int do_exec(struct vdisk_cmd *vcmd)
|
||||
case WRITE_16:
|
||||
fua = (cdb[1] & 0x8);
|
||||
if (cdb[1] & 0x8) {
|
||||
TRACE(TRACE_ORDER, "FUA(%d): loff=%"PRId64", "
|
||||
"data_len=%"PRId64, fua, (uint64_t)loff,
|
||||
TRACE(TRACE_ORDER, "FUA(%d): loff=%" PRId64 ", data_len=%" PRId64,
|
||||
fua, (uint64_t)loff,
|
||||
data_len);
|
||||
}
|
||||
break;
|
||||
@@ -329,7 +328,7 @@ static int do_exec(struct vdisk_cmd *vcmd)
|
||||
|
||||
tgt_dev = find_tgt_dev(dev, cmd->sess_h);
|
||||
if (!tgt_dev) {
|
||||
PRINT_ERROR("Session %"PRIx64" not found",
|
||||
PRINT_ERROR("Session %" PRIx64 " not found",
|
||||
cmd->sess_h);
|
||||
set_cmd_error(vcmd,
|
||||
SCST_LOAD_SENSE(scst_sense_hardw_error));
|
||||
@@ -341,8 +340,7 @@ static int do_exec(struct vdisk_cmd *vcmd)
|
||||
if (fua)
|
||||
exec_fsync(vcmd);
|
||||
} else {
|
||||
PRINT_WARNING("Attempt to write to read-only "
|
||||
"device %s", dev->name);
|
||||
PRINT_WARNING("Attempt to write to read-only device %s", dev->name);
|
||||
set_cmd_error(vcmd,
|
||||
SCST_LOAD_SENSE(scst_sense_data_protect));
|
||||
}
|
||||
@@ -355,7 +353,7 @@ static int do_exec(struct vdisk_cmd *vcmd)
|
||||
|
||||
tgt_dev = find_tgt_dev(dev, cmd->sess_h);
|
||||
if (!tgt_dev) {
|
||||
PRINT_ERROR("Session %"PRIx64" not found",
|
||||
PRINT_ERROR("Session %" PRIx64 " not found",
|
||||
cmd->sess_h);
|
||||
set_cmd_error(vcmd,
|
||||
SCST_LOAD_SENSE(scst_sense_hardw_error));
|
||||
@@ -367,8 +365,7 @@ static int do_exec(struct vdisk_cmd *vcmd)
|
||||
if (reply->status == 0)
|
||||
exec_verify(vcmd, loff);
|
||||
} else {
|
||||
PRINT_WARNING("Attempt to write to read-only "
|
||||
"device %s", dev->name);
|
||||
PRINT_WARNING("Attempt to write to read-only device %s", dev->name);
|
||||
set_cmd_error(vcmd,
|
||||
SCST_LOAD_SENSE(scst_sense_data_protect));
|
||||
}
|
||||
@@ -380,8 +377,7 @@ static int do_exec(struct vdisk_cmd *vcmd)
|
||||
if (data_len == 0)
|
||||
data_len = dev->file_size -
|
||||
((loff_t)lba_start << dev->block_shift);
|
||||
TRACE(TRACE_ORDER, "SYNCHRONIZE_CACHE: "
|
||||
"loff=%"PRId64", data_len=%"PRId64", immed=%d",
|
||||
TRACE(TRACE_ORDER, "SYNCHRONIZE_CACHE: loff=%" PRId64 ", data_len=%" PRId64 ", immed=%d",
|
||||
(uint64_t)loff, data_len, immed);
|
||||
/* ToDo: execute immediate synchronization in the background. */
|
||||
exec_fsync(vcmd);
|
||||
@@ -432,8 +428,8 @@ static int do_exec(struct vdisk_cmd *vcmd)
|
||||
if ((cmd->cdb[1] & 0x1f) == SAI_READ_CAPACITY_16) {
|
||||
exec_read_capacity16(vcmd);
|
||||
} else {
|
||||
TRACE_DBG("Invalid service action %d for SERVICE "
|
||||
"ACTION IN", cmd->cdb[1] & 0x1f);
|
||||
TRACE_DBG("Invalid service action %d for SERVICE ACTION IN",
|
||||
cmd->cdb[1] & 0x1f);
|
||||
set_cmd_error(vcmd,
|
||||
SCST_LOAD_SENSE(scst_sense_invalid_field_in_cdb));
|
||||
}
|
||||
@@ -458,8 +454,7 @@ static int do_alloc_mem(struct vdisk_cmd *vcmd)
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
TRACE_MEM("Alloc mem (cmd %d, sess_h %"PRIx64", cdb_len %d, "
|
||||
"alloc_len %d, queue_type %d, data_direction %d)",
|
||||
TRACE_MEM("Alloc mem (cmd %d, sess_h %" PRIx64 ", cdb_len %d, alloc_len %d, queue_type %d, data_direction %d)",
|
||||
cmd->cmd_h, cmd->alloc_cmd.sess_h,
|
||||
cmd->alloc_cmd.cdb_len, cmd->alloc_cmd.alloc_len,
|
||||
cmd->alloc_cmd.queue_type, cmd->alloc_cmd.data_direction);
|
||||
@@ -477,7 +472,7 @@ static int do_alloc_mem(struct vdisk_cmd *vcmd)
|
||||
#endif
|
||||
reply->alloc_reply.pbuf = (unsigned long)vcmd->dev->alloc_fn(
|
||||
cmd->alloc_cmd.alloc_len);
|
||||
TRACE_MEM("Buf %"PRIx64" alloced, len %d", reply->alloc_reply.pbuf,
|
||||
TRACE_MEM("Buf %" PRIx64 " alloced, len %d", reply->alloc_reply.pbuf,
|
||||
cmd->alloc_cmd.alloc_len);
|
||||
if (reply->alloc_reply.pbuf == 0) {
|
||||
TRACE(TRACE_OUT_OF_MEM, "Unable to allocate buffer (len %d)",
|
||||
@@ -496,7 +491,7 @@ static int do_cached_mem_free(struct vdisk_cmd *vcmd)
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
TRACE_MEM("Cached mem free (cmd %x, buf %"PRIx64")", cmd->cmd_h,
|
||||
TRACE_MEM("Cached mem free (cmd %x, buf %" PRIx64 ")", cmd->cmd_h,
|
||||
cmd->on_cached_mem_free.pbuf);
|
||||
|
||||
free((void *)(unsigned long)cmd->on_cached_mem_free.pbuf);
|
||||
@@ -517,8 +512,8 @@ static int do_on_free_cmd(struct vdisk_cmd *vcmd)
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
TRACE_DBG("On free cmd (cmd %u, resp_data_len %d, aborted %d, "
|
||||
"status %d, delivery_status %d)", cmd->cmd_h,
|
||||
TRACE_DBG("On free cmd (cmd %u, resp_data_len %d, aborted %d, status %d, delivery_status %d)",
|
||||
cmd->cmd_h,
|
||||
cmd->on_free_cmd.resp_data_len, cmd->on_free_cmd.aborted,
|
||||
cmd->on_free_cmd.status, cmd->on_free_cmd.delivery_status);
|
||||
|
||||
@@ -527,7 +522,7 @@ static int do_on_free_cmd(struct vdisk_cmd *vcmd)
|
||||
cmd->on_free_cmd.buffer_cached);
|
||||
|
||||
if (!cmd->on_free_cmd.buffer_cached && cmd->on_free_cmd.pbuf != 0) {
|
||||
TRACE_MEM("Freeing buf %"PRIx64, cmd->on_free_cmd.pbuf);
|
||||
TRACE_MEM("Freeing buf %" PRIx64, cmd->on_free_cmd.pbuf);
|
||||
free((void *)(unsigned long)cmd->on_free_cmd.pbuf);
|
||||
}
|
||||
|
||||
@@ -592,13 +587,13 @@ static int do_tm(struct vdisk_cmd *vcmd, int done)
|
||||
TRACE_ENTRY();
|
||||
|
||||
if (cmd->tm_cmd.fn <= SCST_TARGET_RESET)
|
||||
TRACE(TRACE_MGMT, "%s TM fn %d (sess_h %"PRIx64", "
|
||||
"cmd_h_to_abort %d)", done ? "Done" : "Received",
|
||||
TRACE(TRACE_MGMT, "%s TM fn %d (sess_h %" PRIx64 ", cmd_h_to_abort %d)",
|
||||
done ? "Done" : "Received",
|
||||
cmd->tm_cmd.fn, cmd->tm_cmd.sess_h,
|
||||
cmd->tm_cmd.cmd_h_to_abort);
|
||||
else
|
||||
TRACE_MGMT_DBG("%s TM fn %d (sess_h %"PRIx64", "
|
||||
"cmd_h_to_abort %d)", done ? "Done" : "Received",
|
||||
TRACE_MGMT_DBG("%s TM fn %d (sess_h %" PRIx64 ", cmd_h_to_abort %d)",
|
||||
done ? "Done" : "Received",
|
||||
cmd->tm_cmd.fn, cmd->tm_cmd.sess_h,
|
||||
cmd->tm_cmd.cmd_h_to_abort);
|
||||
|
||||
@@ -641,7 +636,7 @@ static int do_sess(struct vdisk_cmd *vcmd)
|
||||
|
||||
if (cmd->subcode == SCST_USER_ATTACH_SESS) {
|
||||
if (tgt_dev) {
|
||||
PRINT_ERROR("Session %"PRIx64" already exists)",
|
||||
PRINT_ERROR("Session %" PRIx64 " already exists)",
|
||||
cmd->sess.sess_h);
|
||||
res = EEXIST;
|
||||
goto reply;
|
||||
@@ -649,7 +644,7 @@ static int do_sess(struct vdisk_cmd *vcmd)
|
||||
|
||||
tgt_dev = find_empty_tgt_dev(vcmd->dev);
|
||||
if (!tgt_dev) {
|
||||
PRINT_ERROR("Too many initiators, session %"PRIx64
|
||||
PRINT_ERROR("Too many initiators, session %" PRIx64
|
||||
" refused)", cmd->sess.sess_h);
|
||||
res = ENOMEM;
|
||||
goto reply;
|
||||
@@ -657,21 +652,20 @@ static int do_sess(struct vdisk_cmd *vcmd)
|
||||
|
||||
tgt_dev->sess_h = cmd->sess.sess_h;
|
||||
|
||||
PRINT_INFO("Session from initiator %s (target %s) attached "
|
||||
"(LUN %"PRIx64", threads_num %d, rd_only %d, sess_h "
|
||||
"%"PRIx64")", cmd->sess.initiator_name,
|
||||
PRINT_INFO("Session from initiator %s (target %s) attached (LUN %" PRIx64 ", threads_num %d, rd_only %d, sess_h %" PRIx64 ")",
|
||||
cmd->sess.initiator_name,
|
||||
cmd->sess.target_name, cmd->sess.lun,
|
||||
cmd->sess.threads_num, cmd->sess.rd_only,
|
||||
cmd->sess.sess_h);
|
||||
} else {
|
||||
if (!tgt_dev) {
|
||||
PRINT_ERROR("Session %"PRIx64" not found)",
|
||||
PRINT_ERROR("Session %" PRIx64 " not found)",
|
||||
cmd->sess.sess_h);
|
||||
res = ESRCH;
|
||||
goto reply;
|
||||
}
|
||||
tgt_dev->sess_h = 0;
|
||||
PRINT_INFO("Session detached (sess_h %"PRIx64")",
|
||||
PRINT_INFO("Session detached (sess_h %" PRIx64 ")",
|
||||
cmd->sess.sess_h);
|
||||
}
|
||||
|
||||
@@ -824,8 +818,8 @@ void *main_loop(void *arg)
|
||||
#endif
|
||||
|
||||
if (use_multi) {
|
||||
TRACE_DBG("preplies %p (first: %p), replies_cnt %d, "
|
||||
"replies_done %d, cmds_cnt %d", (void *)(uintptr_t)multi.multi_cmd.preplies,
|
||||
TRACE_DBG("preplies %p (first: %p), replies_cnt %d, replies_done %d, cmds_cnt %d",
|
||||
(void *)(uintptr_t)multi.multi_cmd.preplies,
|
||||
&multi.replies[0], multi.multi_cmd.replies_cnt,
|
||||
multi.multi_cmd.replies_done, multi.multi_cmd.cmds_cnt);
|
||||
res = ioctl(scst_usr_fd, SCST_USER_REPLY_AND_GET_MULTI, &multi.multi_cmd);
|
||||
@@ -878,8 +872,8 @@ again_poll:
|
||||
case ESRCH:
|
||||
case EBUSY:
|
||||
case EAGAIN:
|
||||
TRACE_MGMT_DBG("poll() returned %d "
|
||||
"(%s)", res, strerror(res));
|
||||
TRACE_MGMT_DBG("poll() returned %d (%s)",
|
||||
res, strerror(res));
|
||||
case EINTR:
|
||||
goto again_poll;
|
||||
default:
|
||||
@@ -1010,7 +1004,7 @@ static void exec_inquiry(struct vdisk_cmd *vcmd)
|
||||
buf[num + 1] = 0x1; /* Vendor ID */
|
||||
memcpy(&buf[num + 4], VENDOR, 8);
|
||||
snprintf(t10_id, sizeof(buf) - num - 12,
|
||||
"%"PRIx64"-%s", dev_id_num, dev->name);
|
||||
"%" PRIx64 "-%s", dev_id_num, dev->name);
|
||||
i = strlen(t10_id) + 1;
|
||||
TRACE_DBG("t10_dev_id %s", t10_id);
|
||||
buf[num + 3] = 8 + i;
|
||||
@@ -1431,8 +1425,7 @@ static void exec_mode_select(struct vdisk_cmd *vcmd)
|
||||
mselect_6 = (cmd->cdb[0] == MODE_SELECT);
|
||||
|
||||
if (!(cmd->cdb[1] & PF) || (cmd->cdb[1] & SP)) {
|
||||
PRINT_ERROR("MODE SELECT: PF and/or SP are wrongly set "
|
||||
"(cdb[1]=%x)", cmd->cdb[1]);
|
||||
PRINT_ERROR("MODE SELECT: PF and/or SP are wrongly set (cdb[1]=%x)", cmd->cdb[1]);
|
||||
set_cmd_error(vcmd,
|
||||
SCST_LOAD_SENSE(scst_sense_invalid_field_in_cdb));
|
||||
goto out;
|
||||
@@ -1446,8 +1439,7 @@ static void exec_mode_select(struct vdisk_cmd *vcmd)
|
||||
if (address[offset - 1] == 8) {
|
||||
offset += 8;
|
||||
} else if (address[offset - 1] != 0) {
|
||||
PRINT_ERROR("%s", "MODE SELECT: Wrong parameters list "
|
||||
"length");
|
||||
PRINT_ERROR("%s", "MODE SELECT: Wrong parameters list length");
|
||||
set_cmd_error(vcmd,
|
||||
SCST_LOAD_SENSE(scst_sense_invalid_field_in_parm_list));
|
||||
goto out;
|
||||
@@ -1462,8 +1454,7 @@ static void exec_mode_select(struct vdisk_cmd *vcmd)
|
||||
}
|
||||
if ((address[offset] & 0x3f) == 0x8) { /* Caching page */
|
||||
if (address[offset + 1] != 18) {
|
||||
PRINT_ERROR("%s", "MODE SELECT: Invalid "
|
||||
"caching page request");
|
||||
PRINT_ERROR("%s", "MODE SELECT: Invalid caching page request");
|
||||
set_cmd_error(vcmd, SCST_LOAD_SENSE(
|
||||
scst_sense_invalid_field_in_parm_list));
|
||||
goto out;
|
||||
@@ -1705,14 +1696,14 @@ static void exec_read(struct vdisk_cmd *vcmd, loff_t loff)
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
TRACE_DBG("reading off %"PRId64", len %d", loff, length);
|
||||
TRACE_DBG("reading off %" PRId64 ", len %d", loff, length);
|
||||
if (dev->nullio) {
|
||||
err = length;
|
||||
} else {
|
||||
/* SEEK */
|
||||
err = lseek64(fd, loff, 0/*SEEK_SET*/);
|
||||
if (err != loff) {
|
||||
PRINT_ERROR("lseek trouble %"PRId64" != %"PRId64
|
||||
PRINT_ERROR("lseek trouble %" PRId64 " != %" PRId64
|
||||
" (errno %d)", (uint64_t)err, (uint64_t)loff,
|
||||
errno);
|
||||
set_cmd_error(vcmd, SCST_LOAD_SENSE(scst_sense_hardw_error));
|
||||
@@ -1723,7 +1714,7 @@ static void exec_read(struct vdisk_cmd *vcmd, loff_t loff)
|
||||
}
|
||||
|
||||
if (err < 0 || err < length) {
|
||||
PRINT_ERROR("read() returned %"PRId64" from %d (errno %d)",
|
||||
PRINT_ERROR("read() returned %" PRId64 " from %d (errno %d)",
|
||||
(uint64_t)err, length, errno);
|
||||
if (err == -EAGAIN) {
|
||||
set_busy(vcmd);
|
||||
@@ -1752,7 +1743,7 @@ static void exec_write(struct vdisk_cmd *vcmd, loff_t loff)
|
||||
TRACE_ENTRY();
|
||||
|
||||
restart:
|
||||
TRACE_DBG("writing off %"PRId64", len %d", loff, length);
|
||||
TRACE_DBG("writing off %" PRId64 ", len %d", loff, length);
|
||||
|
||||
if (dev->nullio) {
|
||||
err = length;
|
||||
@@ -1760,7 +1751,7 @@ restart:
|
||||
/* SEEK */
|
||||
err = lseek64(fd, loff, 0/*SEEK_SET*/);
|
||||
if (err != loff) {
|
||||
PRINT_ERROR("lseek trouble %"PRId64" != %"PRId64
|
||||
PRINT_ERROR("lseek trouble %" PRId64 " != %" PRId64
|
||||
" (errno %d)", (uint64_t)err, (uint64_t)loff,
|
||||
errno);
|
||||
set_cmd_error(vcmd,
|
||||
@@ -1773,8 +1764,8 @@ restart:
|
||||
}
|
||||
|
||||
if (err < 0) {
|
||||
PRINT_ERROR("write() returned %"PRId64" from %d (errno %d, "
|
||||
"cmd_h %x)", err, length, errno, vcmd->cmd->cmd_h);
|
||||
PRINT_ERROR("write() returned %" PRId64 " from %d (errno %d, cmd_h %x)",
|
||||
err, length, errno, vcmd->cmd->cmd_h);
|
||||
if (err == -EAGAIN) {
|
||||
set_busy(vcmd);
|
||||
} else {
|
||||
@@ -1789,8 +1780,7 @@ restart:
|
||||
*/
|
||||
TRACE_MGMT_DBG("write() returned %d from %d", (int)err, length);
|
||||
if (err == 0)
|
||||
PRINT_INFO("Suspicious: write() returned 0 from "
|
||||
"%d", length);
|
||||
PRINT_INFO("Suspicious: write() returned 0 from %d", length);
|
||||
length -= err;
|
||||
goto restart;
|
||||
}
|
||||
@@ -1827,7 +1817,7 @@ static void exec_verify(struct vdisk_cmd *vcmd, loff_t loff)
|
||||
if (!dev->nullio) {
|
||||
err = lseek64(fd, loff, 0/*SEEK_SET*/);
|
||||
if (err != loff) {
|
||||
PRINT_ERROR("lseek trouble %"PRId64" != %"PRId64
|
||||
PRINT_ERROR("lseek trouble %" PRId64 " != %" PRId64
|
||||
" (errno %d)", (uint64_t)err,
|
||||
(uint64_t)loff, errno);
|
||||
set_cmd_error(vcmd, SCST_LOAD_SENSE(scst_sense_hardw_error));
|
||||
@@ -1845,7 +1835,7 @@ static void exec_verify(struct vdisk_cmd *vcmd, loff_t loff)
|
||||
while (length > 0) {
|
||||
int64_t len_mem = (length > (int)sizeof(mem_verify)) ?
|
||||
(int)sizeof(mem_verify) : length;
|
||||
TRACE_DBG("Verify: length %"PRId64" - len_mem %"PRId64,
|
||||
TRACE_DBG("Verify: length %" PRId64 " - len_mem %" PRId64,
|
||||
length, len_mem);
|
||||
|
||||
if (!dev->nullio)
|
||||
@@ -1853,8 +1843,8 @@ static void exec_verify(struct vdisk_cmd *vcmd, loff_t loff)
|
||||
else
|
||||
err = len_mem;
|
||||
if (err < 0 || err < len_mem) {
|
||||
PRINT_ERROR("read() returned %"PRId64" from %"PRId64" "
|
||||
"(errno %d)", (uint64_t)err, len_mem, errno);
|
||||
PRINT_ERROR("read() returned %" PRId64 " from %" PRId64 " (errno %d)",
|
||||
(uint64_t)err, len_mem, errno);
|
||||
if (err == -EAGAIN) {
|
||||
set_busy(vcmd);
|
||||
} else {
|
||||
@@ -1864,7 +1854,7 @@ static void exec_verify(struct vdisk_cmd *vcmd, loff_t loff)
|
||||
goto out;
|
||||
}
|
||||
if (compare && memcmp(address, mem_verify, len_mem) != 0) {
|
||||
TRACE_DBG("Verify: error memcmp length %"PRId64, length);
|
||||
TRACE_DBG("Verify: error memcmp length %" PRId64, length);
|
||||
set_cmd_error(vcmd,
|
||||
SCST_LOAD_SENSE(scst_sense_miscompare_error));
|
||||
goto out;
|
||||
@@ -1874,7 +1864,7 @@ static void exec_verify(struct vdisk_cmd *vcmd, loff_t loff)
|
||||
}
|
||||
|
||||
if (length < 0) {
|
||||
PRINT_ERROR("Failure: %"PRId64, length);
|
||||
PRINT_ERROR("Failure: %" PRId64, length);
|
||||
set_cmd_error(vcmd, SCST_LOAD_SENSE(scst_sense_hardw_error));
|
||||
}
|
||||
|
||||
|
||||
+6
-9
@@ -147,12 +147,9 @@ static void usage(void)
|
||||
printf(" -o, --direct O_DIRECT mode\n");
|
||||
printf(" -n, --nullio NULLIO mode\n");
|
||||
printf(" -c, --nv_cache NV_CACHE mode\n");
|
||||
printf(" -p, --parse=type Parse type, one of \"std\" "
|
||||
"(default), \"call\" or \"excpt\"\n");
|
||||
printf(" -f, --on_free=type On free call type, one of \"ignore\" "
|
||||
"(default) or \"call\"\n");
|
||||
printf(" -m, --mem_reuse=type Memory reuse type, one of \"all\" "
|
||||
"(default), \"read\", \"write\" or \"none\"\n");
|
||||
printf(" -p, --parse=type Parse type, one of \"std\" (default), \"call\" or \"excpt\"\n");
|
||||
printf(" -f, --on_free=type On free call type, one of \"ignore\" (default) or \"call\"\n");
|
||||
printf(" -m, --mem_reuse=type Memory reuse type, one of \"all\" (default), \"read\", \"write\" or \"none\"\n");
|
||||
printf(" -l, --non_blocking Use non-blocking operations\n");
|
||||
printf(" -I, --vdisk_id=ID Vdisk ID (used in multi-targets setups)\n");
|
||||
printf(" -F, --flush=n Flush SGV cache each n seconds\n");
|
||||
@@ -356,12 +353,12 @@ static int start(int argc, char **argv)
|
||||
close(fd);
|
||||
|
||||
PRINT_INFO("%s", " ");
|
||||
PRINT_INFO("Virtual device \"%s\", path \"%s\", size %"PRId64"MB, "
|
||||
"block size %d, nblocks %"PRId64", options:", devs[i].name,
|
||||
PRINT_INFO("Virtual device \"%s\", path \"%s\", size %" PRId64 "MB, block size %d, nblocks %" PRId64 ", options:",
|
||||
devs[i].name,
|
||||
devs[i].file_name, (uint64_t)devs[i].file_size/1024/1024,
|
||||
devs[i].block_size, (uint64_t)devs[i].nblocks);
|
||||
|
||||
snprintf(devs[i].usn, sizeof(devs[i].usn), "%"PRIx64,
|
||||
snprintf(devs[i].usn, sizeof(devs[i].usn), "%" PRIx64,
|
||||
gen_dev_id_num(&devs[i]));
|
||||
TRACE_DBG("usn %s", devs[i].usn);
|
||||
|
||||
|
||||
+11
-12
@@ -144,8 +144,8 @@ static int invoke_stpg(const uint8_t *device_name,
|
||||
}
|
||||
env[6] = NULL;
|
||||
|
||||
PRINT_INFO("Invoking script %s with parameters: %s %s %s %s %s and environment: "
|
||||
"%s %s %s %s %s", stpg_path, args[1], args[2], args[3],
|
||||
PRINT_INFO("Invoking script %s with parameters: %s %s %s %s %s and environment: %s %s %s %s %s",
|
||||
stpg_path, args[1], args[2], args[3],
|
||||
args[4], args[5], env[1], env[2], env[3], env[4], env[5]);
|
||||
|
||||
c_pid = fork();
|
||||
@@ -191,8 +191,8 @@ static int wait_until_finished(pid_t pid, unsigned long deadline, int *status, i
|
||||
if (res != 0) {
|
||||
if (res < 0) {
|
||||
res = -errno;
|
||||
PRINT_ERROR("Waitpid for pid %d (child %d) "
|
||||
"failed: %d (%s)", pid, child,
|
||||
PRINT_ERROR("Waitpid for pid %d (child %d) failed: %d (%s)",
|
||||
pid, child,
|
||||
errno, strerror(errno));
|
||||
}
|
||||
break;
|
||||
@@ -241,8 +241,8 @@ static int handle_stpg_received(struct scst_event_user *event_user)
|
||||
continue;
|
||||
}
|
||||
|
||||
PRINT_WARNING("on_stpg %d (pid %d) did not finish on time - "
|
||||
"sending SIGTERM", k, pids[k]);
|
||||
PRINT_WARNING("on_stpg %d (pid %d) did not finish on time - sending SIGTERM",
|
||||
k, pids[k]);
|
||||
if (res == 0)
|
||||
res = -ETIMEDOUT;
|
||||
rc = killpg(pids[k], SIGTERM);
|
||||
@@ -255,12 +255,12 @@ static int handle_stpg_received(struct scst_event_user *event_user)
|
||||
continue;
|
||||
|
||||
while (1) {
|
||||
PRINT_WARNING("on_stpg %d (pid %d) did not finish on time - "
|
||||
"sending SIGKILL", k, pids[k]);
|
||||
PRINT_WARNING("on_stpg %d (pid %d) did not finish on time - sending SIGKILL",
|
||||
k, pids[k]);
|
||||
rc = killpg(pids[k], SIGKILL);
|
||||
if (rc < 0) {
|
||||
PRINT_ERROR("Failed to send SIGKILL to child %d "
|
||||
"(pid %d): %d/%s", k, pids[k], errno,
|
||||
PRINT_ERROR("Failed to send SIGKILL to child %d (pid %d): %d/%s",
|
||||
k, pids[k], errno,
|
||||
strerror(errno));
|
||||
break;
|
||||
}
|
||||
@@ -515,8 +515,7 @@ int main(int argc, char **argv)
|
||||
stpg_path = "/usr/local/bin/scst/scst_on_stpg";
|
||||
|
||||
if (access(stpg_path, X_OK) == -1) {
|
||||
PRINT_ERROR("Script file \" %s \"does not exist or not "
|
||||
"executable", stpg_path);
|
||||
PRINT_ERROR("Script file \" %s \"does not exist or not executable", stpg_path);
|
||||
res = -1;
|
||||
goto out_done;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user