mirror of
https://github.com/SCST-project/scst.git
synced 2026-07-20 06:52:18 +00:00
scst: Use sysfs_emit/sysfs_emit_at instead of scnprintf()
Replace scnprintf() with sysfs_emit() and sysfs_emit_at() in sysfs show handlers. These helper functions are specifically designed for sysfs output, providing safer handling of buffer lengths and consistency across kernel sysfs interfaces. This patch does not change any functionality.
This commit is contained in:
+10
-10
@@ -29,22 +29,22 @@ static ssize_t iscsi_version_show(struct kobject *kobj, struct kobj_attribute *a
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "%s\n", ISCSI_VERSION_STRING);
|
||||
ret += sysfs_emit_at(buf, ret, "%s\n", ISCSI_VERSION_STRING);
|
||||
|
||||
#ifdef CONFIG_SCST_EXTRACHECKS
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "EXTRACHECKS\n");
|
||||
ret += sysfs_emit_at(buf, ret, "EXTRACHECKS\n");
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SCST_TRACING
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "TRACING\n");
|
||||
ret += sysfs_emit_at(buf, ret, "TRACING\n");
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SCST_DEBUG
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "DEBUG\n");
|
||||
ret += sysfs_emit_at(buf, ret, "DEBUG\n");
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SCST_ISCSI_DEBUG_DIGEST_FAILURES
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "DEBUG_DIGEST_FAILURES\n");
|
||||
ret += sysfs_emit_at(buf, ret, "DEBUG_DIGEST_FAILURES\n");
|
||||
#endif
|
||||
|
||||
TRACE_EXIT();
|
||||
@@ -60,16 +60,16 @@ static ssize_t iscsi_open_state_show(struct kobject *kobj, struct kobj_attribute
|
||||
|
||||
switch (ctr_open_state) {
|
||||
case ISCSI_CTR_OPEN_STATE_CLOSED:
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "closed\n");
|
||||
ret = sysfs_emit(buf, "closed\n");
|
||||
break;
|
||||
case ISCSI_CTR_OPEN_STATE_OPEN:
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "open\n");
|
||||
ret = sysfs_emit(buf, "open\n");
|
||||
break;
|
||||
case ISCSI_CTR_OPEN_STATE_CLOSING:
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "closing\n");
|
||||
ret = sysfs_emit(buf, "closing\n");
|
||||
break;
|
||||
default:
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "unknown\n");
|
||||
ret = sysfs_emit(buf, "unknown\n");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -442,7 +442,7 @@ static ssize_t iscsi_attr_show(struct kobject *kobj, struct kobj_attribute *attr
|
||||
if (pos != 0)
|
||||
goto out;
|
||||
|
||||
pos = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%s\n", (char *)value);
|
||||
pos = sysfs_emit(buf, "%s\n", (char *)value);
|
||||
|
||||
kfree(value);
|
||||
|
||||
|
||||
+33
-33
@@ -35,43 +35,43 @@ static struct lockdep_map scst_conn_dep_map =
|
||||
STATIC_LOCKDEP_MAP_INIT("iscsi_conn_kref", &scst_conn_key);
|
||||
#endif
|
||||
|
||||
static int print_conn_state(char *p, size_t size, struct iscsi_conn *conn)
|
||||
static ssize_t print_conn_state(char *buf, size_t size, struct iscsi_conn *conn)
|
||||
{
|
||||
int pos = 0;
|
||||
ssize_t ret = 0;
|
||||
|
||||
if (conn->closing) {
|
||||
pos += scnprintf(p, size, "closing");
|
||||
ret += scnprintf(buf, size, "closing");
|
||||
goto out;
|
||||
}
|
||||
|
||||
switch (conn->rd_state) {
|
||||
case ISCSI_CONN_RD_STATE_PROCESSING:
|
||||
pos += scnprintf(&p[pos], size - pos, "read_processing ");
|
||||
ret += scnprintf(buf + ret, size - ret, "read_processing ");
|
||||
break;
|
||||
case ISCSI_CONN_RD_STATE_IN_LIST:
|
||||
pos += scnprintf(&p[pos], size - pos, "in_read_list ");
|
||||
ret += scnprintf(buf + ret, size - ret, "in_read_list ");
|
||||
break;
|
||||
}
|
||||
|
||||
switch (conn->wr_state) {
|
||||
case ISCSI_CONN_WR_STATE_PROCESSING:
|
||||
pos += scnprintf(&p[pos], size - pos, "write_processing ");
|
||||
ret += scnprintf(buf + ret, size - ret, "write_processing ");
|
||||
break;
|
||||
case ISCSI_CONN_WR_STATE_IN_LIST:
|
||||
pos += scnprintf(&p[pos], size - pos, "in_write_list ");
|
||||
ret += scnprintf(buf + ret, size - ret, "in_write_list ");
|
||||
break;
|
||||
case ISCSI_CONN_WR_STATE_SPACE_WAIT:
|
||||
pos += scnprintf(&p[pos], size - pos, "space_waiting ");
|
||||
ret += scnprintf(buf + ret, size - ret, "space_waiting ");
|
||||
break;
|
||||
}
|
||||
|
||||
if (test_bit(ISCSI_CONN_REINSTATING, &conn->conn_aflags))
|
||||
pos += scnprintf(&p[pos], size - pos, "reinstating ");
|
||||
else if (pos == 0)
|
||||
pos += scnprintf(&p[pos], size - pos, "established idle ");
|
||||
ret += scnprintf(buf + ret, size - ret, "reinstating ");
|
||||
else if (ret == 0)
|
||||
ret += scnprintf(buf + ret, size - ret, "established idle ");
|
||||
|
||||
out:
|
||||
return pos;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void iscsi_conn_release(struct kobject *kobj)
|
||||
@@ -98,17 +98,17 @@ static ssize_t iscsi_get_initiator_ip(struct iscsi_conn *conn, char *buf, int si
|
||||
|
||||
static ssize_t iscsi_conn_ip_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
|
||||
{
|
||||
int pos;
|
||||
struct iscsi_conn *conn;
|
||||
ssize_t ret;
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
conn = container_of(kobj, struct iscsi_conn, conn_kobj);
|
||||
|
||||
pos = iscsi_get_initiator_ip(conn, buf, SCST_SYSFS_BLOCK_SIZE);
|
||||
ret = iscsi_get_initiator_ip(conn, buf, SCST_SYSFS_BLOCK_SIZE);
|
||||
|
||||
TRACE_EXIT_RES(pos);
|
||||
return pos;
|
||||
TRACE_EXIT_RES(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct kobj_attribute iscsi_conn_ip_attr =
|
||||
@@ -116,8 +116,8 @@ static struct kobj_attribute iscsi_conn_ip_attr =
|
||||
|
||||
static ssize_t iscsi_get_target_ip(struct iscsi_conn *conn, char *buf, int size)
|
||||
{
|
||||
int pos;
|
||||
struct sock *sk;
|
||||
ssize_t ret;
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
@@ -127,40 +127,40 @@ static ssize_t iscsi_get_target_ip(struct iscsi_conn *conn, char *buf, int size)
|
||||
sk = conn->sock->sk;
|
||||
switch (sk->sk_family) {
|
||||
case AF_INET:
|
||||
pos = scnprintf(buf, size, "%pI4", &inet_sk(sk)->inet_saddr);
|
||||
ret = scnprintf(buf, size, "%pI4", &inet_sk(sk)->inet_saddr);
|
||||
break;
|
||||
#ifdef CONFIG_IPV6
|
||||
case AF_INET6:
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0)
|
||||
pos = scnprintf(buf, size, "[%pI6]", &inet6_sk(sk)->saddr);
|
||||
ret = scnprintf(buf, size, "[%pI6]", &inet6_sk(sk)->saddr);
|
||||
#else
|
||||
pos = scnprintf(buf, size, "[%pI6]", &sk->sk_v6_rcv_saddr);
|
||||
ret = scnprintf(buf, size, "[%pI6]", &sk->sk_v6_rcv_saddr);
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
pos = scnprintf(buf, size, "Unknown family %d", sk->sk_family);
|
||||
ret = scnprintf(buf, size, "Unknown family %d", sk->sk_family);
|
||||
break;
|
||||
}
|
||||
|
||||
TRACE_EXIT_RES(pos);
|
||||
return pos;
|
||||
TRACE_EXIT_RES(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t iscsi_conn_target_ip_show(struct kobject *kobj, struct kobj_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
int pos;
|
||||
struct iscsi_conn *conn;
|
||||
ssize_t ret;
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
conn = container_of(kobj, struct iscsi_conn, conn_kobj);
|
||||
|
||||
pos = iscsi_get_target_ip(conn, buf, SCST_SYSFS_BLOCK_SIZE);
|
||||
ret = iscsi_get_target_ip(conn, buf, SCST_SYSFS_BLOCK_SIZE);
|
||||
|
||||
TRACE_EXIT_RES(pos);
|
||||
return pos;
|
||||
TRACE_EXIT_RES(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct kobj_attribute iscsi_conn_target_ip_attr =
|
||||
@@ -176,7 +176,7 @@ static ssize_t iscsi_conn_transport_show(struct kobject *kobj, struct kobj_attri
|
||||
|
||||
conn = container_of(kobj, struct iscsi_conn, conn_kobj);
|
||||
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%s\n", conn->transport->name);
|
||||
ret = sysfs_emit(buf, "%s\n", conn->transport->name);
|
||||
|
||||
TRACE_EXIT_RES(ret);
|
||||
return ret;
|
||||
@@ -194,7 +194,7 @@ static ssize_t iscsi_conn_cid_show(struct kobject *kobj, struct kobj_attribute *
|
||||
|
||||
conn = container_of(kobj, struct iscsi_conn, conn_kobj);
|
||||
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%u", conn->cid);
|
||||
ret = sysfs_emit(buf, "%u", conn->cid);
|
||||
|
||||
TRACE_EXIT_RES(ret);
|
||||
return ret;
|
||||
@@ -205,17 +205,17 @@ static struct kobj_attribute iscsi_conn_cid_attr =
|
||||
|
||||
static ssize_t iscsi_conn_state_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
|
||||
{
|
||||
int pos;
|
||||
struct iscsi_conn *conn;
|
||||
ssize_t ret;
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
conn = container_of(kobj, struct iscsi_conn, conn_kobj);
|
||||
|
||||
pos = print_conn_state(buf, SCST_SYSFS_BLOCK_SIZE, conn);
|
||||
ret = print_conn_state(buf, SCST_SYSFS_BLOCK_SIZE, conn);
|
||||
|
||||
TRACE_EXIT_RES(pos);
|
||||
return pos;
|
||||
TRACE_EXIT_RES(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct kobj_attribute iscsi_conn_state_attr =
|
||||
|
||||
+13
-13
@@ -388,8 +388,8 @@ static ssize_t iscsi_sess_show_##name(struct kobject *kobj, \
|
||||
scst_sess = container_of(kobj, struct scst_session, sess_kobj); \
|
||||
sess = (struct iscsi_session *)scst_sess_get_tgt_priv(scst_sess); \
|
||||
\
|
||||
return scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%s\n", \
|
||||
iscsi_get_bool_value(sess->sess_params.name)); \
|
||||
return sysfs_emit(buf, "%s\n", \
|
||||
iscsi_get_bool_value(sess->sess_params.name)); \
|
||||
} \
|
||||
\
|
||||
static struct kobj_attribute iscsi_sess_attr_##name = \
|
||||
@@ -405,8 +405,8 @@ static ssize_t iscsi_sess_show_##name(struct kobject *kobj, \
|
||||
scst_sess = container_of(kobj, struct scst_session, sess_kobj); \
|
||||
sess = (struct iscsi_session *)scst_sess_get_tgt_priv(scst_sess); \
|
||||
\
|
||||
return scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d\n", \
|
||||
sess->sess_params.name); \
|
||||
return sysfs_emit(buf, "%d\n", \
|
||||
sess->sess_params.name); \
|
||||
} \
|
||||
\
|
||||
static struct kobj_attribute iscsi_sess_attr_##name = \
|
||||
@@ -423,8 +423,8 @@ static ssize_t iscsi_sess_show_##name(struct kobject *kobj, \
|
||||
scst_sess = container_of(kobj, struct scst_session, sess_kobj); \
|
||||
sess = (struct iscsi_session *)scst_sess_get_tgt_priv(scst_sess); \
|
||||
\
|
||||
return scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%s\n", \
|
||||
iscsi_get_digest_name(sess->sess_params.name, digest_name)); \
|
||||
return sysfs_emit(buf, "%s\n", \
|
||||
iscsi_get_digest_name(sess->sess_params.name, digest_name)); \
|
||||
} \
|
||||
\
|
||||
static struct kobj_attribute iscsi_sess_attr_##name = \
|
||||
@@ -451,7 +451,7 @@ static ssize_t iscsi_sess_sid_show(struct kobject *kobj, struct kobj_attribute *
|
||||
scst_sess = container_of(kobj, struct scst_session, sess_kobj);
|
||||
sess = (struct iscsi_session *)scst_sess_get_tgt_priv(scst_sess);
|
||||
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%llx\n", sess->sid);
|
||||
ret = sysfs_emit(buf, "%llx\n", sess->sid);
|
||||
|
||||
TRACE_EXIT_RES(ret);
|
||||
return ret;
|
||||
@@ -472,7 +472,7 @@ static ssize_t iscsi_sess_reinstating_show(struct kobject *kobj, struct kobj_att
|
||||
scst_sess = container_of(kobj, struct scst_session, sess_kobj);
|
||||
sess = (struct iscsi_session *)scst_sess_get_tgt_priv(scst_sess);
|
||||
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d\n", sess->sess_reinstating ? 1 : 0);
|
||||
ret = sysfs_emit(buf, "%d\n", sess->sess_reinstating ? 1 : 0);
|
||||
|
||||
TRACE_EXIT_RES(ret);
|
||||
return ret;
|
||||
@@ -497,11 +497,11 @@ static ssize_t iscsi_sess_thread_pid_show(struct kobject *kobj, struct kobj_attr
|
||||
|
||||
mutex_lock(&thr_pool->tp_mutex);
|
||||
list_for_each_entry(t, &thr_pool->threads_list, threads_list_entry)
|
||||
res += scnprintf(buf + res, SCST_SYSFS_BLOCK_SIZE - res, "%d%s",
|
||||
task_pid_vnr(t->thr),
|
||||
list_is_last(&t->threads_list_entry,
|
||||
&thr_pool->threads_list) ?
|
||||
"\n" : " ");
|
||||
res += sysfs_emit_at(buf, res, "%d%s",
|
||||
task_pid_vnr(t->thr),
|
||||
list_is_last(&t->threads_list_entry,
|
||||
&thr_pool->threads_list) ?
|
||||
"\n" : " ");
|
||||
mutex_unlock(&thr_pool->tp_mutex);
|
||||
|
||||
out:
|
||||
|
||||
@@ -404,7 +404,7 @@ static ssize_t iscsi_tgt_tid_show(struct kobject *kobj, struct kobj_attribute *a
|
||||
if (!tgt)
|
||||
goto out;
|
||||
|
||||
res = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%u\n", tgt->tid);
|
||||
res = sysfs_emit(buf, "%u\n", tgt->tid);
|
||||
|
||||
out:
|
||||
TRACE_EXIT_RES(res);
|
||||
@@ -577,8 +577,8 @@ static ssize_t iscsi_acg_sess_dedicated_threads_show(struct kobject *kobj,
|
||||
acg = container_of(kobj, struct scst_acg, acg_kobj);
|
||||
dedicated = scst_get_acg_tgt_priv(acg);
|
||||
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d\n%s",
|
||||
dedicated, dedicated ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
ret = sysfs_emit(buf, "%d\n%s",
|
||||
dedicated, dedicated ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
|
||||
TRACE_EXIT_RES(ret);
|
||||
return ret;
|
||||
|
||||
@@ -895,28 +895,27 @@ static ssize_t sqa_version_show(struct kobject *kobj,
|
||||
{
|
||||
ssize_t ret = 0;
|
||||
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret,
|
||||
"INTERFACE=%s\nSCST=%s\nQLOGIC=%s\n",
|
||||
SQA_VERSION, SCST_VERSION_NAME, QLA2XXX_VERSION);
|
||||
ret += sysfs_emit_at(buf, ret, "INTERFACE=%s\nSCST=%s\nQLOGIC=%s\n",
|
||||
SQA_VERSION, SCST_VERSION_NAME, QLA2XXX_VERSION);
|
||||
|
||||
#ifdef CONFIG_SCST_EXTRACHECKS
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "EXTRACHECKS\n");
|
||||
ret += sysfs_emit_at(buf, ret, "EXTRACHECKS\n");
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SCST_TRACING
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "TRACING\n");
|
||||
ret += sysfs_emit_at(buf, ret, "TRACING\n");
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SCST_DEBUG
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "DEBUG\n");
|
||||
ret += sysfs_emit_at(buf, ret, "DEBUG\n");
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_QLA_TGT_DEBUG_WORK_IN_THREAD
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "QLA_TGT_DEBUG_WORK_IN_THREAD\n");
|
||||
ret += sysfs_emit_at(buf, ret, "QLA_TGT_DEBUG_WORK_IN_THREAD\n");
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_QLA_TGT_DEBUG_SRR
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "DEBUG_SRR\n");
|
||||
ret += sysfs_emit_at(buf, ret, "DEBUG_SRR\n");
|
||||
#endif
|
||||
|
||||
TRACE_EXIT();
|
||||
@@ -935,8 +934,7 @@ static ssize_t sqa_hw_target_show(struct kobject *kobj,
|
||||
|
||||
tgt = sqa_tgt->qla_tgt;
|
||||
|
||||
return scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d\n",
|
||||
tgt->vha->vp_idx == 0 ? 1 : 0);
|
||||
return sysfs_emit(buf, "%d\n", tgt->vha->vp_idx == 0 ? 1 : 0);
|
||||
}
|
||||
|
||||
static ssize_t sqa_node_name_show(struct kobject *kobj,
|
||||
@@ -973,11 +971,10 @@ static ssize_t sqa_node_name_show(struct kobject *kobj,
|
||||
if (res != 0)
|
||||
goto out;
|
||||
|
||||
res = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%s\n", wwn);
|
||||
res = sysfs_emit(buf, "%s\n", wwn);
|
||||
|
||||
if (ha->tgt.node_name_set)
|
||||
res += scnprintf(buf + res, SCST_SYSFS_BLOCK_SIZE - res, "%s\n",
|
||||
SCST_SYSFS_KEY_MARK);
|
||||
res += sysfs_emit_at(buf, res, "%s\n", SCST_SYSFS_KEY_MARK);
|
||||
|
||||
kfree(wwn);
|
||||
|
||||
@@ -1072,7 +1069,7 @@ static ssize_t sqa_vp_parent_host_show(struct kobject *kobj,
|
||||
if (res != 0)
|
||||
goto out;
|
||||
|
||||
res = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%s\n%s\n", wwn, SCST_SYSFS_KEY_MARK);
|
||||
res = sysfs_emit(buf, "%s\n%s\n", wwn, SCST_SYSFS_KEY_MARK);
|
||||
|
||||
kfree(wwn);
|
||||
|
||||
@@ -1095,10 +1092,10 @@ static ssize_t sqa_show_expl_conf_enabled(struct kobject *kobj,
|
||||
tgt = sqa_tgt->qla_tgt;
|
||||
ha = tgt->ha;
|
||||
|
||||
return scnprintf(buffer, SCST_SYSFS_BLOCK_SIZE, "%d\n%s",
|
||||
ha->base_qpair->enable_explicit_conf,
|
||||
ha->base_qpair->enable_explicit_conf ?
|
||||
SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
return sysfs_emit(buffer, "%d\n%s",
|
||||
ha->base_qpair->enable_explicit_conf,
|
||||
ha->base_qpair->enable_explicit_conf ?
|
||||
SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
}
|
||||
|
||||
static ssize_t sqa_store_expl_conf_enabled(struct kobject *kobj,
|
||||
|
||||
@@ -6601,8 +6601,8 @@ out:
|
||||
}
|
||||
|
||||
|
||||
static ssize_t q2t_show_expl_conf_enabled(struct kobject *kobj,
|
||||
struct kobj_attribute *attr, char *buffer)
|
||||
static ssize_t q2t_show_expl_conf_enabled(struct kobject *kobj, struct kobj_attribute *attr,
|
||||
char *buffer)
|
||||
{
|
||||
struct scst_tgt *scst_tgt;
|
||||
struct q2t_tgt *tgt;
|
||||
@@ -6613,11 +6613,12 @@ static ssize_t q2t_show_expl_conf_enabled(struct kobject *kobj,
|
||||
tgt = scst_tgt_get_tgt_priv(scst_tgt);
|
||||
if (!tgt)
|
||||
goto out;
|
||||
|
||||
vha = tgt->vha;
|
||||
|
||||
res = scnprintf(buffer, PAGE_SIZE, "%d\n%s",
|
||||
vha->hw->enable_explicit_conf,
|
||||
vha->hw->enable_explicit_conf ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
res = sysfs_emit(buffer, "%d\n%s",
|
||||
vha->hw->enable_explicit_conf,
|
||||
vha->hw->enable_explicit_conf ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
|
||||
out:
|
||||
return res;
|
||||
@@ -6709,22 +6710,22 @@ static ssize_t q2t_version_show(struct kobject *kobj, struct kobj_attribute *att
|
||||
{
|
||||
size_t ret = 0;
|
||||
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "%s\n", Q2T_VERSION_STRING);
|
||||
ret += sysfs_emit_at(buf, ret, "%s\n", Q2T_VERSION_STRING);
|
||||
|
||||
#ifdef CONFIG_SCST_EXTRACHECKS
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "EXTRACHECKS\n");
|
||||
ret += sysfs_emit_at(buf, ret, "EXTRACHECKS\n");
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SCST_TRACING
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "TRACING\n");
|
||||
ret += sysfs_emit_at(buf, ret, "TRACING\n");
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SCST_DEBUG
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "DEBUG\n");
|
||||
ret += sysfs_emit_at(buf, ret, "DEBUG\n");
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_QLA_TGT_DEBUG_WORK_IN_THREAD
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "QLA_TGT_DEBUG_WORK_IN_THREAD\n");
|
||||
ret += sysfs_emit_at(buf, ret, "QLA_TGT_DEBUG_WORK_IN_THREAD\n");
|
||||
#endif
|
||||
|
||||
TRACE_EXIT();
|
||||
@@ -6733,7 +6734,7 @@ static ssize_t q2t_version_show(struct kobject *kobj, struct kobj_attribute *att
|
||||
|
||||
static ssize_t q2t_hw_target_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
|
||||
{
|
||||
return scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d\n", 1);
|
||||
return sysfs_emit(buf, "%d\n", 1);
|
||||
}
|
||||
|
||||
static ssize_t q2t_node_name_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
|
||||
@@ -6757,12 +6758,11 @@ static ssize_t q2t_node_name_show(struct kobject *kobj, struct kobj_attribute *a
|
||||
if (res != 0)
|
||||
goto out;
|
||||
|
||||
res = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%s\n", wwn);
|
||||
res = sysfs_emit(buf, "%s\n", wwn);
|
||||
|
||||
/* For virtual ports it's always key */
|
||||
if (vha->node_name_set || (vha->vp_idx != 0))
|
||||
res += scnprintf(buf + res, SCST_SYSFS_BLOCK_SIZE - res, "%s\n",
|
||||
SCST_SYSFS_KEY_MARK);
|
||||
res += sysfs_emit_at(buf, res, "%s\n", SCST_SYSFS_KEY_MARK);
|
||||
|
||||
kfree(wwn);
|
||||
|
||||
@@ -6860,12 +6860,11 @@ static ssize_t q2t_port_name_show(struct kobject *kobj, struct kobj_attribute *a
|
||||
if (res != 0)
|
||||
goto out;
|
||||
|
||||
res = scnprintf(buf, "%s\n", wwn);
|
||||
res = sysfs_emit(buf, "%s\n", wwn);
|
||||
|
||||
/* For virtual ports it's always key */
|
||||
if ((vha->vp_idx != 0) || vha->port_name_set)
|
||||
res += scnprintf(buf + res, SCST_SYSFS_BLOCK_SIZE - res, "%s\n",
|
||||
SCST_SYSFS_KEY_MARK);
|
||||
res += sysfs_emit_at(buf, res, "%s\n", SCST_SYSFS_KEY_MARK);
|
||||
|
||||
kfree(wwn);
|
||||
|
||||
@@ -6958,7 +6957,7 @@ static ssize_t q2t_vp_parent_host_show(struct kobject *kobj, struct kobj_attribu
|
||||
if (res != 0)
|
||||
goto out;
|
||||
|
||||
res = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%s\n%s\n", wwn, SCST_SYSFS_KEY_MARK);
|
||||
res = sysfs_emit(buf, "%s\n%s\n", wwn, SCST_SYSFS_KEY_MARK);
|
||||
|
||||
kfree(wwn);
|
||||
|
||||
|
||||
@@ -37,8 +37,11 @@
|
||||
#include <linux/iocontext.h>
|
||||
#include <linux/kobject_ns.h>
|
||||
#include <linux/scatterlist.h> /* struct scatterlist */
|
||||
#include <linux/shrinker.h>
|
||||
#include <linux/slab.h> /* kmalloc() */
|
||||
#include <linux/stddef.h> /* sizeof_field() */
|
||||
#include <linux/string.h>
|
||||
#include <linux/sysfs.h>
|
||||
#include <linux/timer.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include <linux/workqueue.h>
|
||||
@@ -1565,6 +1568,79 @@ static inline ssize_t strscpy(char *dest, const char *src, size_t count)
|
||||
#define __ATTR_RW(_name) __ATTR(_name, 0644, _name##_show, _name##_store)
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) && \
|
||||
(LINUX_VERSION_CODE >> 8 != KERNEL_VERSION(4, 9, 0) >> 8 || \
|
||||
LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 260)) && \
|
||||
(LINUX_VERSION_CODE >> 8 != KERNEL_VERSION(4, 14, 0) >> 8 || \
|
||||
LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 224)) && \
|
||||
(LINUX_VERSION_CODE >> 8 != KERNEL_VERSION(4, 19, 0) >> 8 || \
|
||||
LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 179)) && \
|
||||
(LINUX_VERSION_CODE >> 8 != KERNEL_VERSION(5, 4, 0) >> 8 || \
|
||||
LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 103))
|
||||
/*
|
||||
* See also commit 2efc459d06f1 ("sysfs: Add sysfs_emit and sysfs_emit_at to format sysfs output")
|
||||
* # v5.10.
|
||||
* See also commit f3c3dcf35532 # v4.9.260.
|
||||
* See also commit 390881843b4f # v4.14.224.
|
||||
* See also commit cb1f69d53ac8 # v4.19.179.
|
||||
* See also commit 5f4243642873 # v5.4.103.
|
||||
*/
|
||||
static inline __printf(2, 3)
|
||||
int sysfs_emit(char *buf, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
int len;
|
||||
|
||||
if (WARN(!buf ||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0)
|
||||
/*
|
||||
* For kernel releases older than 4.20, using the SLUB allocator will cause
|
||||
* this alignment check to fail as that allocator did NOT align kmalloc
|
||||
* allocations on a PAGE_SIZE boundary.
|
||||
*/
|
||||
false,
|
||||
#else
|
||||
offset_in_page(buf),
|
||||
#endif
|
||||
"invalid sysfs_emit: buf:%p\n", buf))
|
||||
return 0;
|
||||
|
||||
va_start(args, fmt);
|
||||
len = vscnprintf(buf, PAGE_SIZE, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static inline __printf(3, 4)
|
||||
int sysfs_emit_at(char *buf, int at, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
int len;
|
||||
|
||||
if (WARN(!buf ||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0)
|
||||
/*
|
||||
* For kernel releases older than 4.20, using the SLUB allocator will cause
|
||||
* this alignment check to fail as that allocator did NOT align kmalloc
|
||||
* allocations on a PAGE_SIZE boundary.
|
||||
*/
|
||||
false ||
|
||||
#else
|
||||
offset_in_page(buf) ||
|
||||
#endif
|
||||
at < 0 || at >= PAGE_SIZE,
|
||||
"invalid sysfs_emit_at: buf:%p at:%d\n", buf, at))
|
||||
return 0;
|
||||
|
||||
va_start(args, fmt);
|
||||
len = vscnprintf(buf + at, PAGE_SIZE - at, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
return len;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* <linux/t10-pi.h> */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0)
|
||||
|
||||
@@ -565,9 +565,9 @@ static ssize_t disk_sysfs_cluster_mode_show(struct kobject *kobj, struct kobj_at
|
||||
struct scst_device *dev = container_of(kobj, struct scst_device,
|
||||
dev_kobj);
|
||||
|
||||
return scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d\n%s",
|
||||
dev->cluster_mode,
|
||||
dev->cluster_mode ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
return sysfs_emit(buf, "%d\n%s",
|
||||
dev->cluster_mode,
|
||||
dev->cluster_mode ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
}
|
||||
|
||||
static int disk_sysfs_process_cluster_mode_store(struct scst_sysfs_work_item *work)
|
||||
|
||||
@@ -3897,10 +3897,10 @@ out:
|
||||
static ssize_t dev_user_sysfs_commands_show(struct kobject *kobj, struct kobj_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
int pos = 0, ppos, i;
|
||||
struct scst_device *dev;
|
||||
struct scst_user_dev *udev;
|
||||
unsigned long flags;
|
||||
int i, ret = 0, pos;
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
@@ -3913,26 +3913,24 @@ static ssize_t dev_user_sysfs_commands_show(struct kobject *kobj, struct kobj_at
|
||||
struct scst_user_cmd *ucmd;
|
||||
|
||||
list_for_each_entry(ucmd, head, hash_list_entry) {
|
||||
ppos = pos;
|
||||
pos += scnprintf(&buf[pos],
|
||||
SCST_SYSFS_BLOCK_SIZE - pos,
|
||||
"ucmd %p (state %x, ref %d), sent_to_user %d, seen_by_user %d, aborted %d, jammed %d, scst_cmd %p\n",
|
||||
ucmd, ucmd->state,
|
||||
atomic_read(&ucmd->ucmd_ref),
|
||||
ucmd->sent_to_user, ucmd->seen_by_user,
|
||||
ucmd->aborted, ucmd->jammed, ucmd->cmd);
|
||||
if (pos >= SCST_SYSFS_BLOCK_SIZE - 1) {
|
||||
ppos += scnprintf(&buf[ppos],
|
||||
SCST_SYSFS_BLOCK_SIZE - ppos, "...\n");
|
||||
pos = ppos;
|
||||
pos = ret;
|
||||
ret += sysfs_emit_at(buf, ret,
|
||||
"ucmd %p (state %x, ref %d), sent_to_user %d, seen_by_user %d, aborted %d, jammed %d, scst_cmd %p\n",
|
||||
ucmd, ucmd->state,
|
||||
atomic_read(&ucmd->ucmd_ref),
|
||||
ucmd->sent_to_user, ucmd->seen_by_user,
|
||||
ucmd->aborted, ucmd->jammed, ucmd->cmd);
|
||||
if (ret >= SCST_SYSFS_BLOCK_SIZE - 1) {
|
||||
pos += sysfs_emit_at(buf, pos, "...\n");
|
||||
ret = pos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
spin_unlock_irqrestore(&udev->udev_cmd_threads.cmd_list_lock, flags);
|
||||
|
||||
TRACE_EXIT_RES(pos);
|
||||
return pos;
|
||||
TRACE_EXIT_RES(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline int test_cleanup_list(void)
|
||||
|
||||
@@ -7734,8 +7734,8 @@ static ssize_t vdev_size_show(struct kobject *kobj, struct kobj_attribute *attr,
|
||||
*/
|
||||
key = !(virt_dev->nullio && size == VDISK_NULLIO_SIZE) && !size_shift;
|
||||
|
||||
return scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%llu\n%s",
|
||||
size >> size_shift, key ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
return sysfs_emit(buf, "%llu\n%s",
|
||||
size >> size_shift, key ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
}
|
||||
|
||||
static ssize_t vdev_sysfs_size_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
|
||||
@@ -7764,9 +7764,9 @@ static ssize_t vdisk_sysfs_blocksize_show(struct kobject *kobj, struct kobj_attr
|
||||
|
||||
dev = container_of(kobj, struct scst_device, dev_kobj);
|
||||
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d\n%s",
|
||||
dev->block_size, dev->block_size == (1 << DEF_DISK_BLOCK_SHIFT) ? "" :
|
||||
SCST_SYSFS_KEY_MARK "\n");
|
||||
ret = sysfs_emit(buf, "%d\n%s",
|
||||
dev->block_size, dev->block_size == (1 << DEF_DISK_BLOCK_SHIFT) ? "" :
|
||||
SCST_SYSFS_KEY_MARK "\n");
|
||||
|
||||
TRACE_EXIT_RES(ret);
|
||||
return ret;
|
||||
@@ -7807,9 +7807,9 @@ static ssize_t vdisk_opt_trans_len_show(struct kobject *kobj,
|
||||
container_of(kobj, struct scst_device, dev_kobj);
|
||||
struct scst_vdisk_dev *virt_dev = dev->dh_priv;
|
||||
|
||||
return scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d\n%s",
|
||||
virt_dev->opt_trans_len,
|
||||
virt_dev->opt_trans_len_set ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
return sysfs_emit(buf, "%d\n%s",
|
||||
virt_dev->opt_trans_len,
|
||||
virt_dev->opt_trans_len_set ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
}
|
||||
|
||||
static ssize_t vdisk_sysfs_rd_only_show(struct kobject *kobj, struct kobj_attribute *attr,
|
||||
@@ -7824,9 +7824,9 @@ static ssize_t vdisk_sysfs_rd_only_show(struct kobject *kobj, struct kobj_attrib
|
||||
dev = container_of(kobj, struct scst_device, dev_kobj);
|
||||
virt_dev = dev->dh_priv;
|
||||
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d\n%s",
|
||||
virt_dev->rd_only,
|
||||
virt_dev->rd_only == DEF_RD_ONLY ? "" : SCST_SYSFS_KEY_MARK "\n");
|
||||
ret = sysfs_emit(buf, "%d\n%s",
|
||||
virt_dev->rd_only,
|
||||
virt_dev->rd_only == DEF_RD_ONLY ? "" : SCST_SYSFS_KEY_MARK "\n");
|
||||
|
||||
TRACE_EXIT_RES(ret);
|
||||
return ret;
|
||||
@@ -7843,9 +7843,9 @@ static ssize_t vdisk_sysfs_wt_show(struct kobject *kobj, struct kobj_attribute *
|
||||
dev = container_of(kobj, struct scst_device, dev_kobj);
|
||||
virt_dev = dev->dh_priv;
|
||||
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d\n%s",
|
||||
virt_dev->wt_flag,
|
||||
virt_dev->wt_flag == DEF_WRITE_THROUGH ? "" : SCST_SYSFS_KEY_MARK "\n");
|
||||
ret = sysfs_emit(buf, "%d\n%s",
|
||||
virt_dev->wt_flag,
|
||||
virt_dev->wt_flag == DEF_WRITE_THROUGH ? "" : SCST_SYSFS_KEY_MARK "\n");
|
||||
|
||||
TRACE_EXIT_RES(ret);
|
||||
return ret;
|
||||
@@ -7862,9 +7862,9 @@ static ssize_t vdisk_sysfs_tp_show(struct kobject *kobj, struct kobj_attribute *
|
||||
dev = container_of(kobj, struct scst_device, dev_kobj);
|
||||
virt_dev = dev->dh_priv;
|
||||
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d\n%s",
|
||||
virt_dev->thin_provisioned,
|
||||
virt_dev->thin_provisioned_manually_set ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
ret = sysfs_emit(buf, "%d\n%s",
|
||||
virt_dev->thin_provisioned,
|
||||
virt_dev->thin_provisioned_manually_set ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
|
||||
TRACE_EXIT_RES(ret);
|
||||
return ret;
|
||||
@@ -7902,9 +7902,9 @@ static ssize_t vdisk_sysfs_expl_alua_show(struct kobject *kobj,
|
||||
struct scst_device *dev = container_of(kobj, struct scst_device,
|
||||
dev_kobj);
|
||||
|
||||
return scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d\n%s",
|
||||
dev->expl_alua,
|
||||
dev->expl_alua != DEF_EXPL_ALUA ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
return sysfs_emit(buf, "%d\n%s",
|
||||
dev->expl_alua,
|
||||
dev->expl_alua != DEF_EXPL_ALUA ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
}
|
||||
|
||||
static ssize_t vdisk_sysfs_expl_alua_store(struct kobject *kobj,
|
||||
@@ -7939,9 +7939,9 @@ static ssize_t vdisk_sysfs_nv_cache_show(struct kobject *kobj, struct kobj_attri
|
||||
dev = container_of(kobj, struct scst_device, dev_kobj);
|
||||
virt_dev = dev->dh_priv;
|
||||
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d\n%s",
|
||||
virt_dev->nv_cache,
|
||||
virt_dev->nv_cache == DEF_NV_CACHE ? "" : SCST_SYSFS_KEY_MARK "\n");
|
||||
ret = sysfs_emit(buf, "%d\n%s",
|
||||
virt_dev->nv_cache,
|
||||
virt_dev->nv_cache == DEF_NV_CACHE ? "" : SCST_SYSFS_KEY_MARK "\n");
|
||||
|
||||
TRACE_EXIT_RES(ret);
|
||||
return ret;
|
||||
@@ -7959,9 +7959,9 @@ static ssize_t vdisk_sysfs_o_direct_show(struct kobject *kobj, struct kobj_attri
|
||||
dev = container_of(kobj, struct scst_device, dev_kobj);
|
||||
virt_dev = dev->dh_priv;
|
||||
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d\n%s",
|
||||
virt_dev->o_direct_flag,
|
||||
virt_dev->o_direct_flag == DEF_O_DIRECT ? "" : SCST_SYSFS_KEY_MARK "\n");
|
||||
ret = sysfs_emit(buf, "%d\n%s",
|
||||
virt_dev->o_direct_flag,
|
||||
virt_dev->o_direct_flag == DEF_O_DIRECT ? "" : SCST_SYSFS_KEY_MARK "\n");
|
||||
|
||||
TRACE_EXIT_RES(ret);
|
||||
return ret;
|
||||
@@ -7974,9 +7974,9 @@ static ssize_t vdev_sysfs_dummy_show(struct kobject *kobj,
|
||||
dev_kobj);
|
||||
struct scst_vdisk_dev *virt_dev = dev->dh_priv;
|
||||
|
||||
return scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d\n%s",
|
||||
virt_dev->dummy,
|
||||
virt_dev->dummy != DEF_DUMMY ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
return sysfs_emit(buf, "%d\n%s",
|
||||
virt_dev->dummy,
|
||||
virt_dev->dummy != DEF_DUMMY ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
}
|
||||
|
||||
static ssize_t vdev_sysfs_rz_show(struct kobject *kobj,
|
||||
@@ -7987,9 +7987,9 @@ static ssize_t vdev_sysfs_rz_show(struct kobject *kobj,
|
||||
struct scst_vdisk_dev *virt_dev = dev->dh_priv;
|
||||
bool read_zero = virt_dev->read_zero;
|
||||
|
||||
return scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d\n%s",
|
||||
read_zero,
|
||||
read_zero != DEF_READ_ZERO ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
return sysfs_emit(buf, "%d\n%s",
|
||||
read_zero,
|
||||
read_zero != DEF_READ_ZERO ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
}
|
||||
|
||||
static ssize_t vdev_sysfs_rz_store(struct kobject *kobj,
|
||||
@@ -8033,11 +8033,10 @@ static ssize_t vdisk_sysfs_removable_show(struct kobject *kobj, struct kobj_attr
|
||||
dev = container_of(kobj, struct scst_device, dev_kobj);
|
||||
virt_dev = dev->dh_priv;
|
||||
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d\n", virt_dev->removable);
|
||||
ret = sysfs_emit(buf, "%d\n", virt_dev->removable);
|
||||
|
||||
if (virt_dev->dev->type != TYPE_ROM && virt_dev->removable != DEF_REMOVABLE)
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "%s\n",
|
||||
SCST_SYSFS_KEY_MARK);
|
||||
ret += sysfs_emit_at(buf, ret, "%s\n", SCST_SYSFS_KEY_MARK);
|
||||
|
||||
TRACE_EXIT_RES(ret);
|
||||
return ret;
|
||||
@@ -8054,11 +8053,10 @@ static ssize_t vdisk_sysfs_tst_show(struct kobject *kobj, struct kobj_attribute
|
||||
dev = container_of(kobj, struct scst_device, dev_kobj);
|
||||
virt_dev = dev->dh_priv;
|
||||
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d\n", virt_dev->tst);
|
||||
ret = sysfs_emit(buf, "%d\n", virt_dev->tst);
|
||||
|
||||
if (virt_dev->tst != DEF_TST)
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "%s\n",
|
||||
SCST_SYSFS_KEY_MARK);
|
||||
ret += sysfs_emit_at(buf, ret, "%s\n", SCST_SYSFS_KEY_MARK);
|
||||
|
||||
TRACE_EXIT_RES(ret);
|
||||
return ret;
|
||||
@@ -8076,11 +8074,10 @@ static ssize_t vdisk_sysfs_rotational_show(struct kobject *kobj, struct kobj_att
|
||||
dev = container_of(kobj, struct scst_device, dev_kobj);
|
||||
virt_dev = dev->dh_priv;
|
||||
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d\n", virt_dev->rotational);
|
||||
ret = sysfs_emit(buf, "%d\n", virt_dev->rotational);
|
||||
|
||||
if (virt_dev->rotational != DEF_ROTATIONAL)
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "%s\n",
|
||||
SCST_SYSFS_KEY_MARK);
|
||||
ret += sysfs_emit_at(buf, ret, "%s\n", SCST_SYSFS_KEY_MARK);
|
||||
|
||||
TRACE_EXIT_RES(ret);
|
||||
return ret;
|
||||
@@ -8175,7 +8172,7 @@ static ssize_t vdev_sysfs_filename_show(struct kobject *kobj, struct kobj_attrib
|
||||
if (res != 0)
|
||||
goto out_put;
|
||||
|
||||
res = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%s\n", work->res_buf);
|
||||
res = sysfs_emit(buf, "%s\n", work->res_buf);
|
||||
|
||||
out_put:
|
||||
scst_sysfs_work_put(work);
|
||||
@@ -8291,9 +8288,9 @@ static ssize_t vdev_sysfs_cluster_mode_show(struct kobject *kobj, struct kobj_at
|
||||
{
|
||||
struct scst_device *dev = container_of(kobj, struct scst_device, dev_kobj);
|
||||
|
||||
return scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d\n%s",
|
||||
dev->cluster_mode,
|
||||
dev->cluster_mode ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
return sysfs_emit(buf, "%d\n%s",
|
||||
dev->cluster_mode,
|
||||
dev->cluster_mode ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
}
|
||||
|
||||
static int vdev_sysfs_process_cluster_mode_store(struct scst_sysfs_work_item *work)
|
||||
@@ -8477,9 +8474,9 @@ static ssize_t vdev_sysfs_t10_vend_id_show(struct kobject *kobj,
|
||||
virt_dev = dev->dh_priv;
|
||||
|
||||
read_lock(&vdisk_serial_rwlock);
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%s\n%s",
|
||||
virt_dev->t10_vend_id,
|
||||
virt_dev->t10_vend_id_set ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
ret = sysfs_emit(buf, "%s\n%s",
|
||||
virt_dev->t10_vend_id,
|
||||
virt_dev->t10_vend_id_set ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
read_unlock(&vdisk_serial_rwlock);
|
||||
|
||||
TRACE_EXIT_RES(ret);
|
||||
@@ -8537,9 +8534,9 @@ static ssize_t vdev_sysfs_vend_specific_id_show(struct kobject *kobj,
|
||||
virt_dev = dev->dh_priv;
|
||||
|
||||
read_lock(&vdisk_serial_rwlock);
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%s\n%s",
|
||||
virt_dev->vend_specific_id,
|
||||
virt_dev->vend_specific_id_set ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
ret = sysfs_emit(buf, "%s\n%s",
|
||||
virt_dev->vend_specific_id,
|
||||
virt_dev->vend_specific_id_set ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
read_unlock(&vdisk_serial_rwlock);
|
||||
|
||||
TRACE_EXIT_RES(ret);
|
||||
@@ -8597,9 +8594,9 @@ static ssize_t vdev_sysfs_prod_id_show(struct kobject *kobj,
|
||||
virt_dev = dev->dh_priv;
|
||||
|
||||
read_lock(&vdisk_serial_rwlock);
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%s\n%s",
|
||||
virt_dev->prod_id,
|
||||
virt_dev->prod_id_set ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
ret = sysfs_emit(buf, "%s\n%s",
|
||||
virt_dev->prod_id,
|
||||
virt_dev->prod_id_set ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
read_unlock(&vdisk_serial_rwlock);
|
||||
|
||||
TRACE_EXIT_RES(ret);
|
||||
@@ -8657,9 +8654,9 @@ static ssize_t vdev_sysfs_prod_rev_lvl_show(struct kobject *kobj,
|
||||
virt_dev = dev->dh_priv;
|
||||
|
||||
read_lock(&vdisk_serial_rwlock);
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%s\n%s",
|
||||
virt_dev->prod_rev_lvl,
|
||||
virt_dev->prod_rev_lvl_set ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
ret = sysfs_emit(buf, "%s\n%s",
|
||||
virt_dev->prod_rev_lvl,
|
||||
virt_dev->prod_rev_lvl_set ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
read_unlock(&vdisk_serial_rwlock);
|
||||
|
||||
TRACE_EXIT_RES(ret);
|
||||
@@ -8718,9 +8715,9 @@ static ssize_t vdev_sysfs_scsi_device_name_show(struct kobject *kobj, struct kob
|
||||
virt_dev = dev->dh_priv;
|
||||
|
||||
read_lock(&vdisk_serial_rwlock);
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%s\n%s",
|
||||
virt_dev->scsi_device_name,
|
||||
virt_dev->scsi_device_name_set ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
ret = sysfs_emit(buf, "%s\n%s",
|
||||
virt_dev->scsi_device_name,
|
||||
virt_dev->scsi_device_name_set ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
read_unlock(&vdisk_serial_rwlock);
|
||||
|
||||
TRACE_EXIT_RES(ret);
|
||||
@@ -8777,9 +8774,9 @@ static ssize_t vdev_sysfs_t10_dev_id_show(struct kobject *kobj, struct kobj_attr
|
||||
virt_dev = dev->dh_priv;
|
||||
|
||||
read_lock(&vdisk_serial_rwlock);
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%s\n%s",
|
||||
virt_dev->t10_dev_id,
|
||||
virt_dev->t10_dev_id_set ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
ret = sysfs_emit(buf, "%s\n%s",
|
||||
virt_dev->t10_dev_id,
|
||||
virt_dev->t10_dev_id_set ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
read_unlock(&vdisk_serial_rwlock);
|
||||
|
||||
TRACE_EXIT_RES(ret);
|
||||
@@ -8846,14 +8843,13 @@ static ssize_t vdev_sysfs_eui64_id_show(struct kobject *kobj,
|
||||
|
||||
read_lock(&vdisk_serial_rwlock);
|
||||
if (virt_dev->eui64_id_len)
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "0x");
|
||||
ret += sysfs_emit_at(buf, ret, "0x");
|
||||
|
||||
for (i = 0; i < virt_dev->eui64_id_len; i++)
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "%02x",
|
||||
virt_dev->eui64_id[i]);
|
||||
ret += sysfs_emit_at(buf, ret, "%02x", virt_dev->eui64_id[i]);
|
||||
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "\n%s",
|
||||
virt_dev->eui64_id_len ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
ret += sysfs_emit_at(buf, ret, "\n%s",
|
||||
virt_dev->eui64_id_len ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
read_unlock(&vdisk_serial_rwlock);
|
||||
|
||||
return ret;
|
||||
@@ -8925,14 +8921,13 @@ static ssize_t vdev_sysfs_naa_id_show(struct kobject *kobj, struct kobj_attribut
|
||||
|
||||
read_lock(&vdisk_serial_rwlock);
|
||||
if (virt_dev->naa_id_len)
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "0x");
|
||||
ret += sysfs_emit_at(buf, ret, "0x");
|
||||
|
||||
for (i = 0; i < virt_dev->naa_id_len; i++)
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "%02x",
|
||||
virt_dev->naa_id[i]);
|
||||
ret += sysfs_emit_at(buf, ret, "%02x", virt_dev->naa_id[i]);
|
||||
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "\n%s",
|
||||
virt_dev->naa_id_len ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
ret += sysfs_emit_at(buf, ret, "\n%s",
|
||||
virt_dev->naa_id_len ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
read_unlock(&vdisk_serial_rwlock);
|
||||
|
||||
return ret;
|
||||
@@ -9000,9 +8995,9 @@ static ssize_t vdev_sysfs_usn_show(struct kobject *kobj, struct kobj_attribute *
|
||||
virt_dev = dev->dh_priv;
|
||||
|
||||
read_lock(&vdisk_serial_rwlock);
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%s\n%s",
|
||||
virt_dev->usn,
|
||||
virt_dev->usn_set ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
ret = sysfs_emit(buf, "%s\n%s",
|
||||
virt_dev->usn,
|
||||
virt_dev->usn_set ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
read_unlock(&vdisk_serial_rwlock);
|
||||
|
||||
TRACE_EXIT_RES(ret);
|
||||
@@ -9050,10 +9045,10 @@ static ssize_t vdev_sysfs_inq_vend_specific_show(struct kobject *kobj,
|
||||
virt_dev = dev->dh_priv;
|
||||
|
||||
read_lock(&vdisk_serial_rwlock);
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%.*s\n%s",
|
||||
virt_dev->inq_vend_specific_len,
|
||||
virt_dev->inq_vend_specific,
|
||||
virt_dev->inq_vend_specific_len ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
ret = sysfs_emit(buf, "%.*s\n%s",
|
||||
virt_dev->inq_vend_specific_len,
|
||||
virt_dev->inq_vend_specific,
|
||||
virt_dev->inq_vend_specific_len ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
read_unlock(&vdisk_serial_rwlock);
|
||||
|
||||
return ret;
|
||||
@@ -9069,9 +9064,9 @@ static ssize_t vdev_sysfs_active_show(struct kobject *kobj,
|
||||
dev = container_of(kobj, struct scst_device, dev_kobj);
|
||||
virt_dev = dev->dh_priv;
|
||||
|
||||
return scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d\n%s",
|
||||
virt_dev->dev_active,
|
||||
virt_dev->dev_active != DEF_DEV_ACTIVE ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
return sysfs_emit(buf, "%d\n%s",
|
||||
virt_dev->dev_active,
|
||||
virt_dev->dev_active != DEF_DEV_ACTIVE ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
}
|
||||
|
||||
static int vdev_sysfs_process_active_store(struct scst_sysfs_work_item *work)
|
||||
@@ -9188,9 +9183,9 @@ static ssize_t vdev_sysfs_bind_alua_state_show(struct kobject *kobj,
|
||||
bind_alua_state = virt_dev->bind_alua_state;
|
||||
spin_unlock(&virt_dev->flags_lock);
|
||||
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d\n%s",
|
||||
bind_alua_state,
|
||||
bind_alua_state != DEF_BIND_ALUA_STATE ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
ret = sysfs_emit(buf, "%d\n%s",
|
||||
bind_alua_state,
|
||||
bind_alua_state != DEF_BIND_ALUA_STATE ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
|
||||
TRACE_EXIT_RES(ret);
|
||||
return ret;
|
||||
@@ -9255,9 +9250,9 @@ static ssize_t vdev_async_show(struct kobject *kobj,
|
||||
container_of(kobj, struct scst_device, dev_kobj);
|
||||
struct scst_vdisk_dev *virt_dev = dev->dh_priv;
|
||||
|
||||
return scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d\n%s",
|
||||
virt_dev->async,
|
||||
virt_dev->async ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
return sysfs_emit(buf, "%d\n%s",
|
||||
virt_dev->async,
|
||||
virt_dev->async ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
}
|
||||
|
||||
static ssize_t vdev_dif_filename_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
|
||||
@@ -9271,9 +9266,9 @@ static ssize_t vdev_dif_filename_show(struct kobject *kobj, struct kobj_attribut
|
||||
dev = container_of(kobj, struct scst_device, dev_kobj);
|
||||
virt_dev = dev->dh_priv;
|
||||
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%s\n%s",
|
||||
virt_dev->dif_filename,
|
||||
virt_dev->dif_filename ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
ret = sysfs_emit(buf, "%s\n%s",
|
||||
virt_dev->dif_filename,
|
||||
virt_dev->dif_filename ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
|
||||
TRACE_EXIT_RES(ret);
|
||||
return ret;
|
||||
@@ -9308,10 +9303,10 @@ static ssize_t vdev_lb_per_pb_exp_show(struct kobject *kobj, struct kobj_attribu
|
||||
container_of(kobj, struct scst_device, dev_kobj);
|
||||
struct scst_vdisk_dev *virt_dev = dev->dh_priv;
|
||||
|
||||
return scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d\n%s",
|
||||
virt_dev->lb_per_pb_exp,
|
||||
virt_dev->lb_per_pb_exp == DEF_LB_PER_PB_EXP ? "" :
|
||||
SCST_SYSFS_KEY_MARK "\n");
|
||||
return sysfs_emit(buf, "%d\n%s",
|
||||
virt_dev->lb_per_pb_exp,
|
||||
virt_dev->lb_per_pb_exp == DEF_LB_PER_PB_EXP ? "" :
|
||||
SCST_SYSFS_KEY_MARK "\n");
|
||||
}
|
||||
|
||||
static struct kobj_attribute vdev_active_attr =
|
||||
|
||||
@@ -3715,10 +3715,10 @@ static ssize_t scst_cm_allow_not_conn_copy_show(struct kobject *kobj, struct kob
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d\n%s",
|
||||
scst_cm_allow_not_connected_copy,
|
||||
scst_cm_allow_not_connected_copy == SCST_ALLOW_NOT_CONN_COPY_DEF ?
|
||||
"" : SCST_SYSFS_KEY_MARK "\n");
|
||||
ret = sysfs_emit(buf, "%d\n%s",
|
||||
scst_cm_allow_not_connected_copy,
|
||||
scst_cm_allow_not_connected_copy == SCST_ALLOW_NOT_CONN_COPY_DEF ?
|
||||
"" : SCST_SYSFS_KEY_MARK "\n");
|
||||
|
||||
TRACE_EXIT_RES(ret);
|
||||
return ret;
|
||||
|
||||
+30
-30
@@ -1925,15 +1925,15 @@ static ssize_t sgv_sysfs_stat_show(struct kobject *kobj, struct kobj_attribute *
|
||||
merged += atomic_read(&pool->cache_acc[i].merged);
|
||||
}
|
||||
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%-30s %-11s %-11s %-11s %-11s",
|
||||
"Name", "Hit", "Total", "% merged", "Cached (P/I/O)");
|
||||
ret = sysfs_emit(buf, "%-30s %-11s %-11s %-11s %-11s",
|
||||
"Name", "Hit", "Total", "% merged", "Cached (P/I/O)");
|
||||
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret,
|
||||
"\n%-30s %-11d %-11d %-11d %d/%d/%d\n",
|
||||
pool->name, hit, total,
|
||||
allocated != 0 ? merged * 100 / allocated : 0,
|
||||
pool->cached_pages, pool->inactive_cached_pages,
|
||||
pool->cached_entries);
|
||||
ret += sysfs_emit_at(buf, ret,
|
||||
"\n%-30s %-11d %-11d %-11d %d/%d/%d\n",
|
||||
pool->name, hit, total,
|
||||
allocated != 0 ? merged * 100 / allocated : 0,
|
||||
pool->cached_pages, pool->inactive_cached_pages,
|
||||
pool->cached_entries);
|
||||
|
||||
for (i = 0; i < SGV_POOL_ELEMENTS; i++) {
|
||||
int t = atomic_read(&pool->cache_acc[i].total_alloc) -
|
||||
@@ -1941,12 +1941,12 @@ static ssize_t sgv_sysfs_stat_show(struct kobject *kobj, struct kobj_attribute *
|
||||
allocated = t * (1 << i);
|
||||
merged = atomic_read(&pool->cache_acc[i].merged);
|
||||
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret,
|
||||
" %-28s %-11d %-11d %d\n",
|
||||
pool->cache_names[i],
|
||||
atomic_read(&pool->cache_acc[i].hit_alloc),
|
||||
atomic_read(&pool->cache_acc[i].total_alloc),
|
||||
allocated != 0 ? merged * 100 / allocated : 0);
|
||||
ret += sysfs_emit_at(buf, ret,
|
||||
" %-28s %-11d %-11d %d\n",
|
||||
pool->cache_names[i],
|
||||
atomic_read(&pool->cache_acc[i].hit_alloc),
|
||||
atomic_read(&pool->cache_acc[i].total_alloc),
|
||||
allocated != 0 ? merged * 100 / allocated : 0);
|
||||
}
|
||||
|
||||
allocated = atomic_read(&pool->big_pages);
|
||||
@@ -1954,11 +1954,11 @@ static ssize_t sgv_sysfs_stat_show(struct kobject *kobj, struct kobj_attribute *
|
||||
oa = atomic_read(&pool->other_pages);
|
||||
om = atomic_read(&pool->other_merged);
|
||||
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret,
|
||||
" %-40s %d/%-9d %d/%d\n", "big/other",
|
||||
atomic_read(&pool->big_alloc), atomic_read(&pool->other_alloc),
|
||||
allocated != 0 ? merged * 100 / allocated : 0,
|
||||
oa != 0 ? om / oa : 0);
|
||||
ret += sysfs_emit_at(buf, ret,
|
||||
" %-40s %d/%-9d %d/%d\n", "big/other",
|
||||
atomic_read(&pool->big_alloc), atomic_read(&pool->other_alloc),
|
||||
allocated != 0 ? merged * 100 / allocated : 0,
|
||||
oa != 0 ? om / oa : 0);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -2008,18 +2008,18 @@ static ssize_t sgv_sysfs_global_stat_show(struct kobject *kobj, struct kobj_attr
|
||||
spin_unlock_bh(&sgv_pools_lock);
|
||||
|
||||
#ifdef CONFIG_SCST_NO_TOTAL_MEM_CHECKS
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%-42s %d\n", "Inactive pages",
|
||||
inactive_pages);
|
||||
ret = sysfs_emit(buf, "%-42s %d\n", "Inactive pages",
|
||||
inactive_pages);
|
||||
#else
|
||||
ret = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%-42s %d/%d\n%-42s %d/%d\n%-42s %d/%d\n"
|
||||
"%-42s %-11d\n",
|
||||
"Inactive/active pages", inactive_pages,
|
||||
atomic_read(&sgv_pages_total) - inactive_pages,
|
||||
"Hi/lo watermarks [pages]", sgv_hi_wmk, sgv_lo_wmk,
|
||||
"Hi watermark releases/failures",
|
||||
atomic_read(&sgv_releases_on_hiwmk),
|
||||
atomic_read(&sgv_releases_on_hiwmk_failed),
|
||||
"Other allocs", atomic_read(&sgv_other_total_alloc));
|
||||
ret = sysfs_emit(buf, "%-42s %d/%d\n%-42s %d/%d\n%-42s %d/%d\n"
|
||||
"%-42s %-11d\n",
|
||||
"Inactive/active pages", inactive_pages,
|
||||
atomic_read(&sgv_pages_total) - inactive_pages,
|
||||
"Hi/lo watermarks [pages]", sgv_hi_wmk, sgv_lo_wmk,
|
||||
"Hi watermark releases/failures",
|
||||
atomic_read(&sgv_releases_on_hiwmk),
|
||||
atomic_read(&sgv_releases_on_hiwmk_failed),
|
||||
"Other allocs", atomic_read(&sgv_other_total_alloc));
|
||||
#endif
|
||||
|
||||
TRACE_EXIT();
|
||||
|
||||
+268
-299
File diff suppressed because it is too large
Load Diff
+17
-17
@@ -246,19 +246,19 @@ static ssize_t scst_local_version_show(struct kobject *kobj, struct kobj_attribu
|
||||
{
|
||||
ssize_t ret = 0;
|
||||
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "%s/%s\n",
|
||||
SCST_LOCAL_VERSION, scst_local_version_date);
|
||||
ret += sysfs_emit_at(buf, ret, "%s/%s\n",
|
||||
SCST_LOCAL_VERSION, scst_local_version_date);
|
||||
|
||||
#ifdef CONFIG_SCST_EXTRACHECKS
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "EXTRACHECKS\n");
|
||||
ret += sysfs_emit_at(buf, ret, "EXTRACHECKS\n");
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SCST_TRACING
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "TRACING\n");
|
||||
ret += sysfs_emit_at(buf, ret, "TRACING\n");
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SCST_DEBUG
|
||||
ret += scnprintf(buf + ret, SCST_SYSFS_BLOCK_SIZE - ret, "DEBUG\n");
|
||||
ret += sysfs_emit_at(buf, ret, "DEBUG\n");
|
||||
#endif
|
||||
|
||||
TRACE_EXIT();
|
||||
@@ -271,10 +271,10 @@ static struct kobj_attribute scst_local_version_attr =
|
||||
|
||||
static ssize_t scst_local_stats_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
|
||||
{
|
||||
return scnprintf(buf, SCST_SYSFS_BLOCK_SIZE,
|
||||
"Aborts: %d, Device Resets: %d, Target Resets: %d\n",
|
||||
atomic_read(&num_aborts), atomic_read(&num_dev_resets),
|
||||
atomic_read(&num_target_resets));
|
||||
return sysfs_emit(buf,
|
||||
"Aborts: %d, Device Resets: %d, Target Resets: %d\n",
|
||||
atomic_read(&num_aborts), atomic_read(&num_dev_resets),
|
||||
atomic_read(&num_target_resets));
|
||||
}
|
||||
|
||||
static struct kobj_attribute scst_local_stats_attr =
|
||||
@@ -308,10 +308,10 @@ static ssize_t scst_local_scsi_transport_version_show(struct kobject *kobj,
|
||||
goto out_up;
|
||||
|
||||
if (tgt->scsi_transport_version != 0)
|
||||
res = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "0x%x\n%s",
|
||||
tgt->scsi_transport_version, SCST_SYSFS_KEY_MARK "\n");
|
||||
res = sysfs_emit(buf, "0x%x\n%s\n",
|
||||
tgt->scsi_transport_version, SCST_SYSFS_KEY_MARK);
|
||||
else
|
||||
res = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "0x%x\n", 0x0BE0); /* SAS */
|
||||
res = sysfs_emit(buf, "0x%x\n", 0x0BE0); /* SAS */
|
||||
|
||||
out_up:
|
||||
up_read(&scst_local_exit_rwsem);
|
||||
@@ -376,9 +376,9 @@ static ssize_t scst_local_phys_transport_version_show(struct kobject *kobj,
|
||||
if (!tgt)
|
||||
goto out_up;
|
||||
|
||||
res = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "0x%x\n%s",
|
||||
tgt->phys_transport_version,
|
||||
tgt->phys_transport_version != 0 ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
res = sysfs_emit(buf, "0x%x\n%s",
|
||||
tgt->phys_transport_version,
|
||||
tgt->phys_transport_version != 0 ? SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
|
||||
out_up:
|
||||
up_read(&scst_local_exit_rwsem);
|
||||
@@ -446,7 +446,7 @@ static ssize_t host_no_show(struct kobject *kobj, struct kobj_attribute *attr, c
|
||||
if (!host)
|
||||
return -EINVAL;
|
||||
|
||||
return scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%u\n", host->host_no);
|
||||
return sysfs_emit(buf, "%u\n", host->host_no);
|
||||
}
|
||||
|
||||
static struct kobj_attribute scst_local_host_no_attr = __ATTR_RO(host_no);
|
||||
@@ -479,7 +479,7 @@ static ssize_t scst_local_transport_id_show(struct kobject *kobj, struct kobj_at
|
||||
|
||||
res = 0;
|
||||
for (i = 0; i < tr_id_len; i++)
|
||||
res += scnprintf(buf + res, SCST_SYSFS_BLOCK_SIZE - res, "%c", tr_id[i]);
|
||||
res += sysfs_emit_at(buf, res, "%c", tr_id[i]);
|
||||
|
||||
if (!sess->transport_id)
|
||||
kfree(tr_id);
|
||||
|
||||
+29
-27
@@ -3956,11 +3956,10 @@ static ssize_t show_comp_v_mask(struct kobject *kobj,
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
|
||||
res = cpumask_scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, &sport->comp_v_mask);
|
||||
#else
|
||||
res = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%*pb",
|
||||
cpumask_pr_args(&sport->comp_v_mask));
|
||||
res = sysfs_emit(buf, "%*pb",
|
||||
cpumask_pr_args(&sport->comp_v_mask));
|
||||
#endif
|
||||
res += scnprintf(buf + res, SCST_SYSFS_BLOCK_SIZE - res, "\n%s\n",
|
||||
SCST_SYSFS_KEY_MARK);
|
||||
res += sysfs_emit_at(buf, res, "\n%s\n", SCST_SYSFS_KEY_MARK);
|
||||
|
||||
out:
|
||||
return res;
|
||||
@@ -4019,7 +4018,7 @@ static ssize_t srpt_show_device(struct kobject *kobj,
|
||||
goto out;
|
||||
|
||||
sdev = sport->sdev;
|
||||
res = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%s\n", dev_name(&sdev->device->dev));
|
||||
res = sysfs_emit(buf, "%s\n", dev_name(&sdev->device->dev));
|
||||
|
||||
out:
|
||||
return res;
|
||||
@@ -4055,7 +4054,7 @@ static ssize_t srpt_show_link_layer(struct kobject *kobj,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
res = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%s\n", lln);
|
||||
res = sysfs_emit(buf, "%s\n", lln);
|
||||
|
||||
out:
|
||||
return res;
|
||||
@@ -4074,10 +4073,10 @@ static ssize_t show_port_id(struct kobject *kobj, struct kobj_attribute *attr, c
|
||||
goto out;
|
||||
|
||||
mutex_lock(&sport->mutex);
|
||||
res = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%s\n%s",
|
||||
sport->port_id,
|
||||
strcmp(sport->port_id, DEFAULT_SRPT_ID_STRING) ?
|
||||
SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
res = sysfs_emit(buf, "%s\n%s",
|
||||
sport->port_id,
|
||||
strcmp(sport->port_id, DEFAULT_SRPT_ID_STRING) ?
|
||||
SCST_SYSFS_KEY_MARK "\n" : "");
|
||||
mutex_unlock(&sport->mutex);
|
||||
|
||||
out:
|
||||
@@ -4127,18 +4126,18 @@ static ssize_t show_login_info(struct kobject *kobj,
|
||||
if (!sport)
|
||||
goto out;
|
||||
|
||||
res = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE,
|
||||
"tid_ext=%016llx,ioc_guid=%016llx,pkey=ffff,dgid=%04x%04x%04x%04x%04x%04x%04x%04x,service_id=%016llx\n",
|
||||
srpt_service_guid, srpt_service_guid,
|
||||
be16_to_cpu(((__be16 *) sport->gid.raw)[0]),
|
||||
be16_to_cpu(((__be16 *) sport->gid.raw)[1]),
|
||||
be16_to_cpu(((__be16 *) sport->gid.raw)[2]),
|
||||
be16_to_cpu(((__be16 *) sport->gid.raw)[3]),
|
||||
be16_to_cpu(((__be16 *) sport->gid.raw)[4]),
|
||||
be16_to_cpu(((__be16 *) sport->gid.raw)[5]),
|
||||
be16_to_cpu(((__be16 *) sport->gid.raw)[6]),
|
||||
be16_to_cpu(((__be16 *) sport->gid.raw)[7]),
|
||||
srpt_service_guid);
|
||||
res = sysfs_emit(buf,
|
||||
"tid_ext=%016llx,ioc_guid=%016llx,pkey=ffff,dgid=%04x%04x%04x%04x%04x%04x%04x%04x,service_id=%016llx\n",
|
||||
srpt_service_guid, srpt_service_guid,
|
||||
be16_to_cpu(((__be16 *) sport->gid.raw)[0]),
|
||||
be16_to_cpu(((__be16 *) sport->gid.raw)[1]),
|
||||
be16_to_cpu(((__be16 *) sport->gid.raw)[2]),
|
||||
be16_to_cpu(((__be16 *) sport->gid.raw)[3]),
|
||||
be16_to_cpu(((__be16 *) sport->gid.raw)[4]),
|
||||
be16_to_cpu(((__be16 *) sport->gid.raw)[5]),
|
||||
be16_to_cpu(((__be16 *) sport->gid.raw)[6]),
|
||||
be16_to_cpu(((__be16 *) sport->gid.raw)[7]),
|
||||
srpt_service_guid);
|
||||
|
||||
out:
|
||||
return res;
|
||||
@@ -4167,7 +4166,7 @@ static ssize_t show_req_lim(struct kobject *kobj,
|
||||
if (!ch)
|
||||
return -ENOENT;
|
||||
|
||||
return scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d\n", ch->req_lim);
|
||||
return sysfs_emit(buf, "%d\n", ch->req_lim);
|
||||
}
|
||||
|
||||
static ssize_t show_req_lim_delta(struct kobject *kobj,
|
||||
@@ -4181,7 +4180,7 @@ static ssize_t show_req_lim_delta(struct kobject *kobj,
|
||||
if (!ch)
|
||||
return -ENOENT;
|
||||
|
||||
return scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d\n", ch->req_lim_delta);
|
||||
return sysfs_emit(buf, "%d\n", ch->req_lim_delta);
|
||||
}
|
||||
|
||||
static ssize_t show_ch_state(struct kobject *kobj, struct kobj_attribute *attr,
|
||||
@@ -4195,7 +4194,7 @@ static ssize_t show_ch_state(struct kobject *kobj, struct kobj_attribute *attr,
|
||||
if (!ch)
|
||||
return -ENOENT;
|
||||
|
||||
return scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%s\n", get_ch_state_name(ch->state));
|
||||
return sysfs_emit(buf, "%s\n", get_ch_state_name(ch->state));
|
||||
}
|
||||
|
||||
static ssize_t show_comp_vector(struct kobject *kobj,
|
||||
@@ -4205,9 +4204,12 @@ static ssize_t show_comp_vector(struct kobject *kobj,
|
||||
struct srpt_rdma_ch *ch;
|
||||
|
||||
sess = container_of(kobj, struct scst_session, sess_kobj);
|
||||
ch = scst_sess_get_tgt_priv(sess);
|
||||
|
||||
return ch ? scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%u\n", ch->comp_vector) : -ENOENT;
|
||||
ch = scst_sess_get_tgt_priv(sess);
|
||||
if (!ch)
|
||||
return -ENOENT;
|
||||
|
||||
return sysfs_emit(buf, "%u\n", ch->comp_vector);
|
||||
}
|
||||
|
||||
static const struct kobj_attribute srpt_req_lim_attr =
|
||||
|
||||
Reference in New Issue
Block a user