[PATCH v2] target: remove initiatorname field in se_acl_lun

2015-08-13 Thread Spencer Baugh
From: Chris Zankel 

The initiatorname field in se_acl_lun is only a copy of the same field
in se_node_acl, so remove it and use the version in se_node_acl where
needed (it's actually only used for pr_debug)

Signed-off-by: Chris Zankel 
Signed-off-by: Spencer Baugh 
---
 drivers/target/target_core_device.c  | 8 +++-
 drivers/target/target_core_fabric_configfs.c | 2 +-
 include/target/target_core_base.h| 1 -
 3 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/target/target_core_device.c 
b/drivers/target/target_core_device.c
index 09e682b..c4a8db6 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -620,8 +620,6 @@ struct se_lun_acl *core_dev_init_initiator_node_lun_acl(
 
lacl->mapped_lun = mapped_lun;
lacl->se_lun_nacl = nacl;
-   snprintf(lacl->initiatorname, TRANSPORT_IQN_LEN, "%s",
-nacl->initiatorname);
 
return lacl;
 }
@@ -656,7 +654,7 @@ int core_dev_add_initiator_node_lun_acl(
" InitiatorNode: %s\n", tpg->se_tpg_tfo->get_fabric_name(),
tpg->se_tpg_tfo->tpg_get_tag(tpg), lun->unpacked_lun, 
lacl->mapped_lun,
(lun_access & TRANSPORT_LUNFLAGS_READ_WRITE) ? "RW" : "RO",
-   lacl->initiatorname);
+   nacl->initiatorname);
/*
 * Check to see if there are any existing persistent reservation APTPL
 * pre-registrations that need to be enabled for this LUN ACL..
@@ -688,7 +686,7 @@ int core_dev_del_initiator_node_lun_acl(
" InitiatorNode: %s Mapped LUN: %llu\n",
tpg->se_tpg_tfo->get_fabric_name(),
tpg->se_tpg_tfo->tpg_get_tag(tpg), lun->unpacked_lun,
-   lacl->initiatorname, lacl->mapped_lun);
+   nacl->initiatorname, lacl->mapped_lun);
 
return 0;
 }
@@ -701,7 +699,7 @@ void core_dev_free_initiator_node_lun_acl(
" Mapped LUN: %llu\n", tpg->se_tpg_tfo->get_fabric_name(),
tpg->se_tpg_tfo->tpg_get_tag(tpg),
tpg->se_tpg_tfo->get_fabric_name(),
-   lacl->initiatorname, lacl->mapped_lun);
+   lacl->se_lun_nacl->initiatorname, lacl->mapped_lun);
 
kfree(lacl);
 }
diff --git a/drivers/target/target_core_fabric_configfs.c 
b/drivers/target/target_core_fabric_configfs.c
index 48a3698..be42429 100644
--- a/drivers/target/target_core_fabric_configfs.c
+++ b/drivers/target/target_core_fabric_configfs.c
@@ -203,7 +203,7 @@ static ssize_t target_fabric_mappedlun_store_write_protect(
pr_debug("%s_ConfigFS: Changed Initiator ACL: %s"
" Mapped LUN: %llu Write Protect bit to %s\n",
se_tpg->se_tpg_tfo->get_fabric_name(),
-   lacl->initiatorname, lacl->mapped_lun, (op) ? "ON" : "OFF");
+   se_nacl->initiatorname, lacl->mapped_lun, (op) ? "ON" : "OFF");
 
return count;
 
diff --git a/include/target/target_core_base.h 
b/include/target/target_core_base.h
index 0a7c44e..b59b61a 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -598,7 +598,6 @@ struct se_ml_stat_grps {
 };
 
 struct se_lun_acl {
-   charinitiatorname[TRANSPORT_IQN_LEN];
u64 mapped_lun;
struct se_node_acl  *se_lun_nacl;
struct se_lun   *se_lun;
-- 
2.5.0.rc3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] target: remove unused lun_flags field from se_lun

2015-08-13 Thread Spencer Baugh
From: Chris Zankel 

The lun_flags field is not used, so drop it.

Signed-off-by: Chris Zankel 
Signed-off-by: Spencer Baugh 
---
 include/target/target_core_base.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/target/target_core_base.h 
b/include/target/target_core_base.h
index 17ae2d6..0a7c44e 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -685,7 +685,6 @@ struct se_lun {
 #define SE_LUN_LINK_MAGIC  0x7771
u32 lun_link_magic;
u32 lun_access;
-   u32 lun_flags;
u32 lun_index;
 
/* RELATIVE TARGET PORT IDENTIFER */
-- 
2.5.0.rc3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] target: Fix handling of small allocation lengths in REPORT LUNS

2015-08-13 Thread Spencer Baugh
From: Roland Dreier 

REPORT LUNS should not fail just because the allocation length is less
than 16.  The relevant section of SPC-4 is:

  4.2.5.6 Allocation length

  The ALLOCATION LENGTH field specifies the maximum number of bytes or
  blocks that an application client has allocated in the Data-In
  Buffer. The ALLOCATION LENGTH field specifies bytes unless a
  different requirement is stated in the command definition.

  An allocation length of zero specifies that no data shall be
  transferred. This condition shall not be considered an error.

So we should just truncate our response rather than return an error.

Signed-off-by: Roland Dreier 
Signed-off-by: Spencer Baugh 
---
 drivers/target/target_core_spc.c | 32 
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
index da6130a..43a27bf 100644
--- a/drivers/target/target_core_spc.c
+++ b/drivers/target/target_core_spc.c
@@ -1210,17 +1210,13 @@ sense_reason_t spc_emulate_report_luns(struct se_cmd 
*cmd)
struct se_dev_entry *deve;
struct se_session *sess = cmd->se_sess;
struct se_node_acl *nacl;
+   struct scsi_lun slun;
unsigned char *buf;
u32 lun_count = 0, offset = 8;
-
-   if (cmd->data_length < 16) {
-   pr_warn("REPORT LUNS allocation length %u too small\n",
-   cmd->data_length);
-   return TCM_INVALID_CDB_FIELD;
-   }
+   __be32 len;
 
buf = transport_kmap_data_sg(cmd);
-   if (!buf)
+   if (cmd->data_length && !buf)
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
 
/*
@@ -1241,10 +1237,12 @@ sense_reason_t spc_emulate_report_luns(struct se_cmd 
*cmd)
 * See SPC2-R20 7.19.
 */
lun_count++;
-   if ((offset + 8) > cmd->data_length)
+   if (offset >= cmd->data_length)
continue;
 
-   int_to_scsilun(deve->mapped_lun, (struct scsi_lun 
*)&buf[offset]);
+   int_to_scsilun(deve->mapped_lun, &slun);
+   memcpy(buf + offset, &slun,
+  min(8u, cmd->data_length - offset));
offset += 8;
}
rcu_read_unlock();
@@ -1257,16 +1255,18 @@ done:
 * If no LUNs are accessible, report virtual LUN 0.
 */
if (lun_count == 0) {
-   int_to_scsilun(0, (struct scsi_lun *)&buf[offset]);
+   int_to_scsilun(0, &slun);
+   if (cmd->data_length > 8)
+   memcpy(buf + offset, &slun,
+  min(8u, cmd->data_length - offset));
lun_count = 1;
}
 
-   lun_count *= 8;
-   buf[0] = ((lun_count >> 24) & 0xff);
-   buf[1] = ((lun_count >> 16) & 0xff);
-   buf[2] = ((lun_count >> 8) & 0xff);
-   buf[3] = (lun_count & 0xff);
-   transport_kunmap_data_sg(cmd);
+   if (buf) {
+   len = cpu_to_be32(lun_count * 8);
+   memcpy(buf, &len, min_t(int, sizeof len, cmd->data_length));
+   transport_kunmap_data_sg(cmd);
+   }
 
target_complete_cmd_with_length(cmd, GOOD, 8 + lun_count * 8);
return 0;
-- 
2.5.0.rc3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] RDMA/cma: fix IPv6 address resolution

2015-08-13 Thread Spencer Baugh
Resolving a link-local IPv6 address with an unspecified source address
was broken by commit 5462eddd7a, which prevented the IPv6 stack from
learning the scope id of the link-local IPv6 address, causing random
failures as the IP stack chose a random link to resolve the address on.

This commit 5462eddd7a made us bail out of cma_check_linklocal early if
the address passed in was not an IPv6 link-local address. On the address
resolution path, the address passed in is the source address; if the
source address is the unspecified address, which is not link-local, we
will bail out early.

This is mostly correct, but if the destination address is a link-local
address, then we will be following a link-local route, and we'll need to
tell the IPv6 stack what the scope id of the destination address is.
This used to be done by last line of cma_check_linklocal, which is
skipped when bailing out early:

dev_addr->bound_dev_if = sin6->sin6_scope_id;

(In cma_bind_addr, the sin6_scope_id of the source address is set to the
sin6_scope_id of the destination address, so this is correct)
This line is required in turn for the following line, L279 of
addr6_resolve, to actually inform the IPv6 stack of the scope id:

  fl6.flowi6_oif = addr->bound_dev_if;

Since we can only know we are in this failure case when we have access
to both the source IPv6 address and destination IPv6 address, we have to
deal with this further up the stack. So detect this failure case in
cma_bind_addr, and set bound_dev_if to the destination address scope id
to correct it.

Signed-off-by: Spencer Baugh 
---
 drivers/infiniband/core/cma.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 6a6b60a..3b71154 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -2188,8 +2188,11 @@ static int cma_bind_addr(struct rdma_cm_id *id, struct 
sockaddr *src_addr,
src_addr = (struct sockaddr *) &id->route.addr.src_addr;
src_addr->sa_family = dst_addr->sa_family;
if (dst_addr->sa_family == AF_INET6) {
-   ((struct sockaddr_in6 *) src_addr)->sin6_scope_id =
-   ((struct sockaddr_in6 *) 
dst_addr)->sin6_scope_id;
+   struct sockaddr_in6 *src_addr6 = (struct sockaddr_in6 
*) src_addr;
+   struct sockaddr_in6 *dst_addr6 = (struct sockaddr_in6 
*) dst_addr;
+   src_addr6->sin6_scope_id = dst_addr6->sin6_scope_id;
+   if (ipv6_addr_type(&dst_addr6->sin6_addr) & 
IPV6_ADDR_LINKLOCAL)
+   id->route.addr.dev_addr.bound_dev_if = 
dst_addr6->sin6_scope_id;
} else if (dst_addr->sa_family == AF_IB) {
((struct sockaddr_ib *) src_addr)->sib_pkey =
((struct sockaddr_ib *) dst_addr)->sib_pkey;
-- 
2.5.0.rc3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] target: Fix handling of small allocation lengths in REPORT LUNS

2015-08-12 Thread Spencer Baugh
From: Roland Dreier 

REPORT LUNS should not fail just because the allocation length is less
than 16.  The relevant section of SPC-4 is:

  4.2.5.6 Allocation length

  The ALLOCATION LENGTH field specifies the maximum number of bytes or
  blocks that an application client has allocated in the Data-In
  Buffer. The ALLOCATION LENGTH field specifies bytes unless a
  different requirement is stated in the command definition.

  An allocation length of zero specifies that no data shall be
  transferred. This condition shall not be considered an error.

So we should just truncate our response rather than return an error.

Signed-off-by: Roland Dreier 
Signed-off-by: Spencer Baugh 
---
 drivers/target/target_core_spc.c | 32 
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
index b5ba1ec..67487e1 100644
--- a/drivers/target/target_core_spc.c
+++ b/drivers/target/target_core_spc.c
@@ -1203,17 +1203,13 @@ sense_reason_t spc_emulate_report_luns(struct se_cmd 
*cmd)
struct se_dev_entry *deve;
struct se_session *sess = cmd->se_sess;
struct se_node_acl *nacl;
+   struct scsi_lun slun;
unsigned char *buf;
u32 lun_count = 0, offset = 8;
-
-   if (cmd->data_length < 16) {
-   pr_warn("REPORT LUNS allocation length %u too small\n",
-   cmd->data_length);
-   return TCM_INVALID_CDB_FIELD;
-   }
+   __be32 len;
 
buf = transport_kmap_data_sg(cmd);
-   if (!buf)
+   if (cmd->data_length && !buf)
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
 
/*
@@ -1222,7 +1218,10 @@ sense_reason_t spc_emulate_report_luns(struct se_cmd 
*cmd)
 * a $FABRIC_MOD.  In that case, report LUN=0 only.
 */
if (!sess) {
-   int_to_scsilun(0, (struct scsi_lun *)&buf[offset]);
+   int_to_scsilun(0, &slun);
+   if (cmd->data_length > 8)
+   memcpy(buf + offset, &slun,
+  min(8u, cmd->data_length - offset));
lun_count = 1;
goto done;
}
@@ -1236,10 +1235,12 @@ sense_reason_t spc_emulate_report_luns(struct se_cmd 
*cmd)
 * See SPC2-R20 7.19.
 */
lun_count++;
-   if ((offset + 8) > cmd->data_length)
+   if (offset >= cmd->data_length)
continue;
 
-   int_to_scsilun(deve->mapped_lun, (struct scsi_lun 
*)&buf[offset]);
+   int_to_scsilun(deve->mapped_lun, &slun);
+   memcpy(buf + offset, &slun,
+  min(8u, cmd->data_length - offset));
offset += 8;
}
rcu_read_unlock();
@@ -1248,12 +1249,11 @@ sense_reason_t spc_emulate_report_luns(struct se_cmd 
*cmd)
 * See SPC3 r07, page 159.
 */
 done:
-   lun_count *= 8;
-   buf[0] = ((lun_count >> 24) & 0xff);
-   buf[1] = ((lun_count >> 16) & 0xff);
-   buf[2] = ((lun_count >> 8) & 0xff);
-   buf[3] = (lun_count & 0xff);
-   transport_kunmap_data_sg(cmd);
+   if (buf) {
+   len = cpu_to_be32(lun_count * 8);
+   memcpy(buf, &len, min_t(int, sizeof len, cmd->data_length));
+   transport_kunmap_data_sg(cmd);
+   }
 
target_complete_cmd_with_length(cmd, GOOD, 8 + lun_count * 8);
return 0;
-- 
2.5.0.rc3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] target: add support for START_STOP_UNIT SCSI opcode

2015-07-23 Thread Spencer Baugh
From: Brian Bunker 

AIX servers using VIOS servers that virtualize FC cards will have a
problem booting without support for START_STOP_UNIT.

v2: Cite sb3r36 exactly, clean up if conditions

Signed-off-by: Brian Bunker 
Signed-off-by: Spencer Baugh 
---
 drivers/target/target_core_sbc.c | 36 
 1 file changed, 36 insertions(+)

diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
index e318ddb..85c3c0a 100644
--- a/drivers/target/target_core_sbc.c
+++ b/drivers/target/target_core_sbc.c
@@ -154,6 +154,38 @@ sbc_emulate_readcapacity_16(struct se_cmd *cmd)
return 0;
 }
 
+static sense_reason_t
+sbc_emulate_startstop(struct se_cmd *cmd)
+{
+   unsigned char *cdb = cmd->t_task_cdb;
+
+   /*
+* See sb3r36 section 5.25
+* Immediate bit should be set since there is nothing to complete
+* POWER CONDITION MODIFIER 0h
+*/
+   if (!(cdb[1] & 1) || cdb[2] || cdb[3])
+   return TCM_INVALID_CDB_FIELD;
+
+   /*
+* See sb3r36 section 5.25
+* POWER CONDITION 0h START_VALID - process START and LOEJ
+*/
+   if (cdb[4] >> 4 & 0xf)
+   return TCM_INVALID_CDB_FIELD;
+
+   /*
+* See sb3r36 section 5.25
+* LOEJ 0h - nothing to load or unload
+* START 1h - we are ready
+*/
+   if (!(cdb[4] & 1) || (cdb[4] & 2) || (cdb[4] & 4))
+   return TCM_INVALID_CDB_FIELD;
+
+   target_complete_cmd(cmd, SAM_STAT_GOOD);
+   return 0;
+}
+
 sector_t sbc_get_write_same_sectors(struct se_cmd *cmd)
 {
u32 num_blocks;
@@ -1069,6 +1101,10 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
size = 0;
cmd->execute_cmd = sbc_emulate_noop;
break;
+   case START_STOP:
+   size = 0;
+   cmd->execute_cmd = sbc_emulate_startstop;
+   break;
default:
ret = spc_parse_cdb(cmd, &size);
if (ret)
-- 
2.5.0.rc3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] target: fix crash in cmd tracing when cmd didn't match a LUN

2015-07-23 Thread Spencer Baugh
From: Alexei Potashnik 

If command didn't match a LUN and we're sending check condition, the
target_cmd_complete ftrace point will crash because it assumes that
cmd->t_task_cdb has been set.

The fix will temporarily set t_task_cdb to the se_cmd buffer
and copy first 6 bytes of cdb in there as soon as possible.
At a later point t_task_cdb is reset to the correct buffer,
but until then traces and printks don't cause a crash.

Signed-off-by: Alexei Potashnik 
Signed-off-by: Spencer Baugh 
---
 drivers/target/iscsi/iscsi_target.c|  4 ++--
 drivers/target/target_core_device.c| 11 +--
 drivers/target/target_core_transport.c |  9 +
 include/target/target_core_fabric.h|  2 +-
 4 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target.c 
b/drivers/target/iscsi/iscsi_target.c
index f615d75..98899f1 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -1003,8 +1003,8 @@ int iscsit_setup_scsi_cmd(struct iscsi_conn *conn, struct 
iscsi_cmd *cmd,
 
target_get_sess_cmd(&cmd->se_cmd, true);
 
-   cmd->sense_reason = transport_lookup_cmd_lun(&cmd->se_cmd,
-scsilun_to_int(&hdr->lun));
+   cmd->sense_reason = transport_lookup_cmd_lun_cdb(&cmd->se_cmd,
+
scsilun_to_int(&hdr->lun), hdr->cdb);
if (cmd->sense_reason)
goto attach_cmd;
 
diff --git a/drivers/target/target_core_device.c 
b/drivers/target/target_core_device.c
index c4a8db6..acf84cf 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -56,13 +56,20 @@ static struct se_hba *lun0_hba;
 struct se_device *g_lun0_dev;
 
 sense_reason_t
-transport_lookup_cmd_lun(struct se_cmd *se_cmd, u64 unpacked_lun)
+transport_lookup_cmd_lun_cdb(struct se_cmd *se_cmd, u64 unpacked_lun, unsigned 
char *cdb)
 {
struct se_lun *se_lun = NULL;
struct se_session *se_sess = se_cmd->se_sess;
struct se_node_acl *nacl = se_sess->se_node_acl;
struct se_dev_entry *deve;
 
+   /* Temporarily set t_task_cdb to the se_cmd buffer and save a portion
+* of cdb in there (fabrics must provide at least 6 bytes). t_task_cdb
+* will be correctly replaced in target_setup_cmd_from_cdb. Until then
+* tracing and printks can access t_task_cdb without causing a crash. */
+   se_cmd->t_task_cdb = se_cmd->__t_task_cdb;
+   memcpy(se_cmd->t_task_cdb, cdb, 6);
+
rcu_read_lock();
deve = target_nacl_find_deve(nacl, unpacked_lun);
if (deve) {
@@ -142,7 +149,7 @@ transport_lookup_cmd_lun(struct se_cmd *se_cmd, u64 
unpacked_lun)
 
return 0;
 }
-EXPORT_SYMBOL(transport_lookup_cmd_lun);
+EXPORT_SYMBOL(transport_lookup_cmd_lun_cdb);
 
 int transport_lookup_tmr_lun(struct se_cmd *se_cmd, u64 unpacked_lun)
 {
diff --git a/drivers/target/target_core_transport.c 
b/drivers/target/target_core_transport.c
index f6626bb..1f761a3 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1210,15 +1210,16 @@ target_setup_cmd_from_cdb(struct se_cmd *cmd, unsigned 
char *cdb)
 * setup the pointer from __t_task_cdb to t_task_cdb.
 */
if (scsi_command_size(cdb) > sizeof(cmd->__t_task_cdb)) {
-   cmd->t_task_cdb = kzalloc(scsi_command_size(cdb),
-   GFP_KERNEL);
-   if (!cmd->t_task_cdb) {
+   unsigned char *ptr = kzalloc(scsi_command_size(cdb),
+GFP_KERNEL);
+   if (!ptr) {
pr_err("Unable to allocate cmd->t_task_cdb"
" %u > sizeof(cmd->__t_task_cdb): %lu ops\n",
scsi_command_size(cdb),
(unsigned long)sizeof(cmd->__t_task_cdb));
return TCM_OUT_OF_RESOURCES;
}
+   cmd->t_task_cdb = ptr;
} else
cmd->t_task_cdb = &cmd->__t_task_cdb[0];
/*
@@ -1404,7 +1405,7 @@ int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, 
struct se_session *se_sess
/*
 * Locate se_lun pointer and attach it to struct se_cmd
 */
-   rc = transport_lookup_cmd_lun(se_cmd, unpacked_lun);
+   rc = transport_lookup_cmd_lun_cdb(se_cmd, unpacked_lun, cdb);
if (rc) {
transport_send_check_condition_and_sense(se_cmd, rc, 0);
target_put_sess_cmd(se_cmd);
diff --git a/include/target/target_core_fabric.h 
b/include/target/target_core_fabric.h
index 18afef9..bfa6368 100644
--- a/include/target/target_core_fabric.h
+++ b/include/target/target_core_fabric.h
@@ -116,7 +116,7 @@ vo

[PATCH] e1000: make eeprom read/write scheduler friendly

2015-07-23 Thread Spencer Baugh
From: Joern Engel 

Code was responsible for ~150ms scheduler latencies.

Signed-off-by: Joern Engel 
Signed-off-by: Spencer Baugh 
---
 drivers/net/ethernet/intel/e1000/e1000_hw.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/intel/e1000/e1000_hw.c 
b/drivers/net/ethernet/intel/e1000/e1000_hw.c
index 45c8c864..e74e9dd 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_hw.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_hw.c
@@ -106,7 +106,7 @@ u16 
e1000_igp_cable_length_table[IGP01E1000_AGC_LENGTH_TABLE_SIZE] = {
120, 120
 };
 
-static DEFINE_SPINLOCK(e1000_eeprom_lock);
+static DEFINE_MUTEX(e1000_eeprom_lock);
 static DEFINE_SPINLOCK(e1000_phy_lock);
 
 /**
@@ -3882,9 +3882,9 @@ static s32 e1000_spi_eeprom_ready(struct e1000_hw *hw)
 s32 e1000_read_eeprom(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
 {
s32 ret;
-   spin_lock(&e1000_eeprom_lock);
+   mutex_lock(&e1000_eeprom_lock);
ret = e1000_do_read_eeprom(hw, offset, words, data);
-   spin_unlock(&e1000_eeprom_lock);
+   mutex_unlock(&e1000_eeprom_lock);
return ret;
 }
 
@@ -3972,6 +3972,7 @@ static s32 e1000_do_read_eeprom(struct e1000_hw *hw, u16 
offset, u16 words,
 */
data[i] = e1000_shift_in_ee_bits(hw, 16);
e1000_standby_eeprom(hw);
+   cond_resched();
}
}
 
@@ -4056,9 +4057,9 @@ s32 e1000_update_eeprom_checksum(struct e1000_hw *hw)
 s32 e1000_write_eeprom(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
 {
s32 ret;
-   spin_lock(&e1000_eeprom_lock);
+   mutex_lock(&e1000_eeprom_lock);
ret = e1000_do_write_eeprom(hw, offset, words, data);
-   spin_unlock(&e1000_eeprom_lock);
+   mutex_unlock(&e1000_eeprom_lock);
return ret;
 }
 
@@ -4124,6 +4125,7 @@ static s32 e1000_write_eeprom_spi(struct e1000_hw *hw, 
u16 offset, u16 words,
return -E1000_ERR_EEPROM;
 
e1000_standby_eeprom(hw);
+   cond_resched();
 
/*  Send the WRITE ENABLE command (8 bit opcode )  */
e1000_shift_out_ee_bits(hw, EEPROM_WREN_OPCODE_SPI,
@@ -4232,6 +4234,7 @@ static s32 e1000_write_eeprom_microwire(struct e1000_hw 
*hw, u16 offset,
 
/* Recover from write */
e1000_standby_eeprom(hw);
+   cond_resched();
 
words_written++;
}
-- 
2.5.0.rc3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] block: round timeouts to 100ms instead of 1s

2015-07-23 Thread Spencer Baugh
From: Joern Engel 

Users can request timeouts as low as 1s.  However, whatever the request
timeout happens to be, we always round it up by up to 1s.  So at the
lower end the rounding doubles the user-requested timeout.

Reduce the impact of rounding for small timeout values.

Curious side note: The staggering done in round_jiffies_common() has the
effect of firing timers at slightly different times on different cpus.
The intended result seems to be that not all cpus handle timers at the
same time.

However, this trick only works if the timeout calculation and the firing
of the timer happen on the same cpu.  For block queues the effect is
that instead of bunching timers to trigger just once per second, they
trigger about once per second _per cpu_.  Or rather they used to before
this patch.  So on reasonably-sized systems the timers can actually
trigger less frequently, in spite of better precision.

Signed-off-by: Joern Engel 
Signed-off-by: Spencer Baugh 
---
 block/blk-timeout.c | 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/block/blk-timeout.c b/block/blk-timeout.c
index 246dfb1..0d06162 100644
--- a/block/blk-timeout.c
+++ b/block/blk-timeout.c
@@ -127,6 +127,17 @@ static void blk_rq_check_expired(struct request *rq, 
unsigned long *next_timeout
}
 }
 
+/*
+ * With SSDs it gets realistic to set a short timeout of 1s.  But if
+ * every timeout gets rounded up by as much as a second, the effective
+ * limit is 2s.  Round jiffies a bit more precisely to about 100ms
+ * instead.
+ */
+static unsigned long round_jiffies_up_100ms(unsigned long j)
+{
+   return round_up(j, rounddown_pow_of_two(HZ / 10));
+}
+
 void blk_rq_timed_out_timer(unsigned long data)
 {
struct request_queue *q = (struct request_queue *) data;
@@ -140,7 +151,7 @@ void blk_rq_timed_out_timer(unsigned long data)
blk_rq_check_expired(rq, &next, &next_set);
 
if (next_set)
-   mod_timer(&q->timeout, round_jiffies_up(next));
+   mod_timer(&q->timeout, round_jiffies_up_100ms(next));
 
spin_unlock_irqrestore(q->queue_lock, flags);
 }
@@ -170,7 +181,7 @@ unsigned long blk_rq_timeout(unsigned long timeout)
 {
unsigned long maxt;
 
-   maxt = round_jiffies_up(jiffies + BLK_MAX_TIMEOUT);
+   maxt = round_jiffies_up_100ms(jiffies + BLK_MAX_TIMEOUT);
if (time_after(timeout, maxt))
timeout = maxt;
 
@@ -215,7 +226,7 @@ void blk_add_timer(struct request *req)
 * than an existing one, modify the timer. Round up to next nearest
 * second.
 */
-   expiry = blk_rq_timeout(round_jiffies_up(req->deadline));
+   expiry = blk_rq_timeout(round_jiffies_up_100ms(req->deadline));
 
if (!timer_pending(&q->timeout) ||
time_before(expiry, q->timeout.expires)) {
-- 
2.5.0.rc3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] mm: add resched points to remap_pmd_range/ioremap_pmd_range

2015-07-23 Thread Spencer Baugh
From: Joern Engel 

Mapping large memory spaces can be slow and prevent high-priority
realtime threads from preempting lower-priority threads for a long time.
In my case it was a 256GB mapping causing at least 950ms scheduler
delay.  Problem detection is ratelimited and depends on interrupts
happening at the right time, so actual delay is likely worse.

[ cut here ]
WARNING: at arch/x86/kernel/irq.c:182 do_IRQ+0x126/0x140()
Thread not rescheduled for 36 jiffies
CPU: 14 PID: 6684 Comm: foo Tainted: G   O 3.10.59+
 0009 883f7fbc3ee0 8163a12c 883f7fbc3f18
 8103f131 887f48275ac0 0012 007c
  887f5bc11fd8 883f7fbc3f78 8103f19c
Call Trace:
   [] dump_stack+0x19/0x1b
 [] warn_slowpath_common+0x61/0x80
 [] warn_slowpath_fmt+0x4c/0x50
 [] ? rcu_irq_exit+0x77/0xc0
 [] do_IRQ+0x126/0x140
 [] common_interrupt+0x6f/0x6f
   [] ? set_pageblock_migratetype+0x28/0x30
 [] ? clear_page_c_e+0x7/0x10
 [] ? get_page_from_freelist+0x5b3/0x880
 [] __alloc_pages_nodemask+0xe3/0x810
 [] ? trace_hardirqs_on_thunk+0x3a/0x3c
 [] alloc_pages_current+0x86/0x120
 [] __get_free_pages+0xe/0x50
 [] pte_alloc_one_kernel+0x15/0x20
 [] __pte_alloc_kernel+0x1d/0xf0
 [] ioremap_page_range+0x2cc/0x320
 [] __ioremap_caller+0x1e9/0x2b0
 [] ioremap_nocache+0x17/0x20
 [] pci_iomap+0x55/0xb0
 [] vfio_pci_mmap+0x1ea/0x210 [vfio_pci]
 [] vfio_device_fops_mmap+0x23/0x30 [vfio]
 [] mmap_region+0x3d8/0x5e0
 [] do_mmap_pgoff+0x305/0x3c0
 [] ? call_rwsem_down_write_failed+0x13/0x20
 [] vm_mmap_pgoff+0x67/0xa0
 [] SyS_mmap_pgoff+0x272/0x2e0
 [] SyS_mmap+0x22/0x30
 [] system_call_fastpath+0x16/0x1b
---[ end trace 6b0a8d2341444bdd ]---
[ cut here ]
WARNING: at arch/x86/kernel/irq.c:182 do_IRQ+0x126/0x140()
Thread not rescheduled for 95 jiffies
CPU: 14 PID: 6684 Comm: foo Tainted: GW  O 3.10.59+
 0009 883f7fbc3ee0 8163a12c 883f7fbc3f18
 8103f131 887f48275ac0 002f 007c
  7fadd1e0 883f7fbc3f78 8103f19c
Call Trace:
   [] dump_stack+0x19/0x1b
 [] warn_slowpath_common+0x61/0x80
 [] warn_slowpath_fmt+0x4c/0x50
 [] ? rcu_irq_exit+0x77/0xc0
 [] do_IRQ+0x126/0x140
 [] common_interrupt+0x6f/0x6f
   [] ? _raw_spin_lock+0x13/0x30
 [] __pte_alloc+0x31/0xc0
 [] remap_pfn_range+0x45c/0x470
 [] vfio_pci_mmap+0x148/0x210 [vfio_pci]
 [] vfio_device_fops_mmap+0x23/0x30 [vfio]
 [] mmap_region+0x3d8/0x5e0
 [] do_mmap_pgoff+0x305/0x3c0
 [] ? call_rwsem_down_write_failed+0x13/0x20
 [] vm_mmap_pgoff+0x67/0xa0
 [] SyS_mmap_pgoff+0x272/0x2e0
 [] SyS_mmap+0x22/0x30
 [] system_call_fastpath+0x16/0x1b
---[ end trace 6b0a8d2341444bde ]---
[ cut here ]
WARNING: at arch/x86/kernel/irq.c:182 do_IRQ+0x126/0x140()
Thread not rescheduled for 45 jiffies
CPU: 18 PID: 21726 Comm: foo Tainted: G   O 3.10.59+
 0009 88203f203ee0 8163a13c 88203f203f18
 8103f131 881ec5f1ad60 0016 006e
  c939a6dd8000 88203f203f78 8103f19c
Call Trace:
   [] dump_stack+0x19/0x1b
 [] warn_slowpath_common+0x61/0x80
 [] warn_slowpath_fmt+0x4c/0x50
 [] ? rcu_irq_exit+0x77/0xc0
 [] do_IRQ+0x126/0x140
 [] common_interrupt+0x6f/0x6f
   [] ? retint_restore_args+0x13/0x13
 [] ? free_memtype+0x87/0x150
 [] ? vunmap_page_range+0x1e6/0x2a0
 [] remove_vm_area+0x51/0x70
 [] iounmap+0x67/0xa0
 [] pci_iounmap+0x35/0x40
 [] vfio_pci_release+0x9a/0x150 [vfio_pci]
 [] vfio_device_fops_release+0x1c/0x40 [vfio]
 [] __fput+0xdb/0x220
 [] fput+0xe/0x10
 [] task_work_run+0xbc/0xe0
 [] do_exit+0x3ce/0xe50
 [] do_group_exit+0x3f/0xa0
 [] get_signal_to_deliver+0x1a9/0x5b0
 [] do_signal+0x48/0x5e0
 [] ? k_getrusage+0x368/0x3d0
 [] ? default_wake_function+0x12/0x20
 [] ? kprobe_flush_task+0xc0/0x150
 [] ? finish_task_switch+0xc4/0xe0
 [] do_notify_resume+0x65/0x80
 [] retint_signal+0x4d/0x9f
---[ end trace 3506c05e4a0af3e5 ]---

Signed-off-by: Joern Engel 
Signed-off-by: Spencer Baugh 
---
 lib/ioremap.c | 1 +
 mm/memory.c   | 1 +
 mm/vmalloc.c  | 1 +
 3 files changed, 3 insertions(+)

diff --git a/lib/ioremap.c b/lib/ioremap.c
index 86c8911..d38e46d 100644
--- a/lib/ioremap.c
+++ b/lib/ioremap.c
@@ -90,6 +90,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long 
addr,
 
if (ioremap_pte_range(pmd, addr, next, phys_addr + addr, prot))
return -ENOMEM;
+   cond_resched();
} while (pmd++, addr = next, addr != end);
return 0;
 }
diff --git a/mm/memory.c b/mm/memory.c
index 388dcf9..1541880 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1656,6 +1656,7 @@ static inline int remap_pmd_range(struct mm_struct *mm, 
pud_t *pud,
if (remap_pte_range(mm, pmd, addr, next,
pfn + (addr >> PAGE_SHIFT), prot))
return -

[PATCH] aer: add cond_resched to aer_isr

2015-07-23 Thread Spencer Baugh
From: Joern Engel 

Multiple nested loops.  I have observed 590ms scheduler latency caused
by this loop and interrupts.  Interrupts were responsible for 190ms, the
rest could have been avoided with a cond_resched.

Signed-off-by: Joern Engel 
Signed-off-by: Spencer Baugh 
---
 drivers/pci/pcie/aer/aerdrv_core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/pcie/aer/aerdrv_core.c 
b/drivers/pci/pcie/aer/aerdrv_core.c
index 9803e3d..32b1b5c 100644
--- a/drivers/pci/pcie/aer/aerdrv_core.c
+++ b/drivers/pci/pcie/aer/aerdrv_core.c
@@ -780,8 +780,10 @@ void aer_isr(struct work_struct *work)
struct aer_err_source uninitialized_var(e_src);
 
mutex_lock(&rpc->rpc_mutex);
-   while (get_e_source(rpc, &e_src))
+   while (get_e_source(rpc, &e_src)) {
aer_isr_one_error(p_device, &e_src);
+   cond_resched();
+   }
mutex_unlock(&rpc->rpc_mutex);
 
wake_up(&rpc->wait_release);
-- 
2.5.0.rc3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] hugetlb: cond_resched for set_max_huge_pages and follow_hugetlb_page

2015-07-23 Thread Spencer Baugh
From: Joern Engel 

~150ms scheduler latency for both observed in the wild.

Signed-off-by: Joern Engel 
Signed-off-by: Spencer Baugh 
---
 mm/hugetlb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index a8c3087..2eb6919 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1836,6 +1836,7 @@ static unsigned long set_max_huge_pages(struct hstate *h, 
unsigned long count,
ret = alloc_fresh_gigantic_page(h, nodes_allowed);
else
ret = alloc_fresh_huge_page(h, nodes_allowed);
+   cond_resched();
spin_lock(&hugetlb_lock);
if (!ret)
goto out;
@@ -3521,6 +3522,7 @@ long follow_hugetlb_page(struct mm_struct *mm, struct 
vm_area_struct *vma,
spin_unlock(ptl);
ret = hugetlb_fault(mm, vma, vaddr,
(flags & FOLL_WRITE) ? FAULT_FLAG_WRITE : 0);
+   cond_resched();
if (!(ret & VM_FAULT_ERROR))
continue;
 
-- 
2.5.0.rc3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3] target: Drop iSCSI use of mutex around max_cmd_sn increment

2015-07-23 Thread Spencer Baugh

From: Roland Dreier 

In a performance profile, taking a mutex in iscsit_increment_maxcmdsn()
shows up very high.  However taking a mutex around "sess->max_cmd_sn += 1"
seems pretty silly: we're not serializing against other contexts in
any useful way.

I did a quick audit and there don't appear to be any other places that
use max_cmd_sn within the mutex more than once, so this lock can't be
providing any useful serialization.

v2: Get correct values for logging
v3: Fix whitespace damage

Signed-off-by: Roland Dreier 
Signed-off-by: Spencer Baugh 
---
 drivers/target/iscsi/iscsi_target.c  | 18 +-
 drivers/target/iscsi/iscsi_target_configfs.c |  6 --
 drivers/target/iscsi/iscsi_target_device.c   |  7 ++-
 drivers/target/iscsi/iscsi_target_login.c|  2 +-
 drivers/target/iscsi/iscsi_target_nego.c |  9 +++--
 drivers/target/iscsi/iscsi_target_tmr.c  |  2 +-
 drivers/target/iscsi/iscsi_target_util.c |  7 ---
 include/target/iscsi/iscsi_target_core.h |  2 +-
 8 files changed, 25 insertions(+), 28 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target.c 
b/drivers/target/iscsi/iscsi_target.c
index ebb1ece..f615d75 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -2555,7 +2555,7 @@ static int iscsit_send_conn_drop_async_message(
cmd->stat_sn= conn->stat_sn++;
hdr->statsn = cpu_to_be32(cmd->stat_sn);
hdr->exp_cmdsn  = cpu_to_be32(conn->sess->exp_cmd_sn);
-   hdr->max_cmdsn  = cpu_to_be32(conn->sess->max_cmd_sn);
+   hdr->max_cmdsn  = cpu_to_be32((u32) 
atomic_read(&conn->sess->max_cmd_sn));
hdr->async_event= ISCSI_ASYNC_MSG_DROPPING_CONNECTION;
hdr->param1 = cpu_to_be16(cmd->logout_cid);
hdr->param2 = 
cpu_to_be16(conn->sess->sess_ops->DefaultTime2Wait);
@@ -2627,7 +2627,7 @@ iscsit_build_datain_pdu(struct iscsi_cmd *cmd, struct 
iscsi_conn *conn,
hdr->statsn = cpu_to_be32(0x);
 
hdr->exp_cmdsn  = cpu_to_be32(conn->sess->exp_cmd_sn);
-   hdr->max_cmdsn  = cpu_to_be32(conn->sess->max_cmd_sn);
+   hdr->max_cmdsn  = cpu_to_be32((u32) 
atomic_read(&conn->sess->max_cmd_sn));
hdr->datasn = cpu_to_be32(datain->data_sn);
hdr->offset = cpu_to_be32(datain->offset);
 
@@ -2838,7 +2838,7 @@ iscsit_build_logout_rsp(struct iscsi_cmd *cmd, struct 
iscsi_conn *conn,
 
iscsit_increment_maxcmdsn(cmd, conn->sess);
hdr->exp_cmdsn  = cpu_to_be32(conn->sess->exp_cmd_sn);
-   hdr->max_cmdsn  = cpu_to_be32(conn->sess->max_cmd_sn);
+   hdr->max_cmdsn  = cpu_to_be32((u32) 
atomic_read(&conn->sess->max_cmd_sn));
 
pr_debug("Built Logout Response ITT: 0x%08x StatSN:"
" 0x%08x Response: 0x%02x CID: %hu on CID: %hu\n",
@@ -2901,7 +2901,7 @@ iscsit_build_nopin_rsp(struct iscsi_cmd *cmd, struct 
iscsi_conn *conn,
iscsit_increment_maxcmdsn(cmd, conn->sess);
 
hdr->exp_cmdsn  = cpu_to_be32(conn->sess->exp_cmd_sn);
-   hdr->max_cmdsn  = cpu_to_be32(conn->sess->max_cmd_sn);
+   hdr->max_cmdsn  = cpu_to_be32((u32) 
atomic_read(&conn->sess->max_cmd_sn));
 
pr_debug("Built NOPIN %s Response ITT: 0x%08x, TTT: 0x%08x,"
" StatSN: 0x%08x, Length %u\n", (nopout_response) ?
@@ -3048,7 +3048,7 @@ static int iscsit_send_r2t(
hdr->ttt= cpu_to_be32(r2t->targ_xfer_tag);
hdr->statsn = cpu_to_be32(conn->stat_sn);
hdr->exp_cmdsn  = cpu_to_be32(conn->sess->exp_cmd_sn);
-   hdr->max_cmdsn  = cpu_to_be32(conn->sess->max_cmd_sn);
+   hdr->max_cmdsn  = cpu_to_be32((u32) 
atomic_read(&conn->sess->max_cmd_sn));
hdr->r2tsn  = cpu_to_be32(r2t->r2t_sn);
hdr->data_offset= cpu_to_be32(r2t->offset);
hdr->data_length= cpu_to_be32(r2t->xfer_len);
@@ -3201,7 +3201,7 @@ void iscsit_build_rsp_pdu(struct iscsi_cmd *cmd, struct 
iscsi_conn *conn,
 
iscsit_increment_maxcmdsn(cmd, conn->sess);
hdr->exp_cmdsn  = cpu_to_be32(conn->sess->exp_cmd_sn);
-   hdr->max_cmdsn  = cpu_to_be32(conn->sess->max_cmd_sn);
+   hdr->max_cmdsn  = cpu_to_be32((u32) 
atomic_read(&conn->sess->max_cmd_sn));
 
pr_debug("Built SCSI Response, ITT: 0x%08x, StatSN: 0x%08x,"
" Response: 0x%02x, SAM Status: 0x%02x, CID: %hu\n",
@@ -3320,7 +3320,7 @

[PATCH v2] target: Drop iSCSI use of mutex around max_cmd_sn increment

2015-07-23 Thread Spencer Baugh

From: Roland Dreier 

In a performance profile, taking a mutex in iscsit_increment_maxcmdsn()
shows up very high.  However taking a mutex around "sess->max_cmd_sn += 1"
seems pretty silly: we're not serializing against other contexts in
any useful way.

I did a quick audit and there don't appear to be any other places that
use max_cmd_sn within the mutex more than once, so this lock can't be
providing any useful serialization.

v2: Get correct values for logging

Signed-off-by: Roland Dreier 
Signed-off-by: Spencer Baugh 
---
 drivers/target/iscsi/iscsi_target.c  | 18 +-
 drivers/target/iscsi/iscsi_target_configfs.c |  6 --
 drivers/target/iscsi/iscsi_target_device.c   |  7 ++-
 drivers/target/iscsi/iscsi_target_login.c|  2 +-
 drivers/target/iscsi/iscsi_target_nego.c |  9 +++--
 drivers/target/iscsi/iscsi_target_tmr.c  |  2 +-
 drivers/target/iscsi/iscsi_target_util.c |  7 ---
 include/target/iscsi/iscsi_target_core.h |  2 +-
 8 files changed, 25 insertions(+), 28 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target.c 
b/drivers/target/iscsi/iscsi_target.c
index ebb1ece..635ec06c 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -2555,7 +2555,7 @@ static int iscsit_send_conn_drop_async_message(
cmd->stat_sn= conn->stat_sn++;
hdr->statsn = cpu_to_be32(cmd->stat_sn);
hdr->exp_cmdsn  = cpu_to_be32(conn->sess->exp_cmd_sn);
-   hdr->max_cmdsn  = cpu_to_be32(conn->sess->max_cmd_sn);
+   hdr->max_cmdsn  = cpu_to_be32((u32) 
atomic_read(&conn->sess->max_cmd_sn));
hdr->async_event= ISCSI_ASYNC_MSG_DROPPING_CONNECTION;
hdr->param1 = cpu_to_be16(cmd->logout_cid);
hdr->param2 = 
cpu_to_be16(conn->sess->sess_ops->DefaultTime2Wait);
@@ -2627,7 +2627,7 @@ iscsit_build_datain_pdu(struct iscsi_cmd *cmd, struct 
iscsi_conn *conn,
hdr->statsn = cpu_to_be32(0x);
 
hdr->exp_cmdsn  = cpu_to_be32(conn->sess->exp_cmd_sn);
-   hdr->max_cmdsn  = cpu_to_be32(conn->sess->max_cmd_sn);
+   hdr->max_cmdsn  = cpu_to_be32((u32) 
atomic_read(&conn->sess->max_cmd_sn));
hdr->datasn = cpu_to_be32(datain->data_sn);
hdr->offset = cpu_to_be32(datain->offset);
 
@@ -2838,7 +2838,7 @@ iscsit_build_logout_rsp(struct iscsi_cmd *cmd, struct 
iscsi_conn *conn,
 
iscsit_increment_maxcmdsn(cmd, conn->sess);
hdr->exp_cmdsn  = cpu_to_be32(conn->sess->exp_cmd_sn);
-   hdr->max_cmdsn  = cpu_to_be32(conn->sess->max_cmd_sn);
+   hdr->max_cmdsn  = cpu_to_be32((u32) 
atomic_read(&conn->sess->max_cmd_sn));
 
pr_debug("Built Logout Response ITT: 0x%08x StatSN:"
" 0x%08x Response: 0x%02x CID: %hu on CID: %hu\n",
@@ -2901,7 +2901,7 @@ iscsit_build_nopin_rsp(struct iscsi_cmd *cmd, struct 
iscsi_conn *conn,
iscsit_increment_maxcmdsn(cmd, conn->sess);
 
hdr->exp_cmdsn  = cpu_to_be32(conn->sess->exp_cmd_sn);
-   hdr->max_cmdsn  = cpu_to_be32(conn->sess->max_cmd_sn);
+   hdr->max_cmdsn  = cpu_to_be32((u32) 
atomic_read(&conn->sess->max_cmd_sn));
 
pr_debug("Built NOPIN %s Response ITT: 0x%08x, TTT: 0x%08x,"
" StatSN: 0x%08x, Length %u\n", (nopout_response) ?
@@ -3048,7 +3048,7 @@ static int iscsit_send_r2t(
hdr->ttt= cpu_to_be32(r2t->targ_xfer_tag);
hdr->statsn = cpu_to_be32(conn->stat_sn);
hdr->exp_cmdsn  = cpu_to_be32(conn->sess->exp_cmd_sn);
-   hdr->max_cmdsn  = cpu_to_be32(conn->sess->max_cmd_sn);
+   hdr->max_cmdsn  = cpu_to_be32((u32) 
atomic_read(&conn->sess->max_cmd_sn));
hdr->r2tsn  = cpu_to_be32(r2t->r2t_sn);
hdr->data_offset= cpu_to_be32(r2t->offset);
hdr->data_length= cpu_to_be32(r2t->xfer_len);
@@ -3201,7 +3201,7 @@ void iscsit_build_rsp_pdu(struct iscsi_cmd *cmd, struct 
iscsi_conn *conn,
 
iscsit_increment_maxcmdsn(cmd, conn->sess);
hdr->exp_cmdsn  = cpu_to_be32(conn->sess->exp_cmd_sn);
-   hdr->max_cmdsn  = cpu_to_be32(conn->sess->max_cmd_sn);
+   hdr->max_cmdsn  = cpu_to_be32((u32) 
atomic_read(&conn->sess->max_cmd_sn));
 
pr_debug("Built SCSI Response, ITT: 0x%08x, StatSN: 0x%08x,"
" Response: 0x%02x, SAM Status: 0x%02x, CID: %hu\n",
@@ -3320,7 +3320,7 @@ iscsit_build_task_mgt_rsp(s

[PATCH] target: respond to unknown initiators with sensible REPORT LUNS list length

2015-07-22 Thread Spencer Baugh
From: Roland Dreier 

Solaris seems to go beserk if we respond to REPORT LUNS with a
LUN LIST LENGTH of 0.

Signed-off-by: Roland Dreier 
Signed-off-by: Spencer Baugh 
---
 drivers/target/target_core_spc.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
index 87d4adb..d8a32e5 100644
--- a/drivers/target/target_core_spc.c
+++ b/drivers/target/target_core_spc.c
@@ -1241,6 +1241,13 @@ sense_reason_t spc_emulate_report_luns(struct se_cmd 
*cmd)
 * See SPC3 r07, page 159.
 */
 done:
+   /*
+* If no real LUNs are accessible, report an allocation length
+* of 1 LUN to account for virtual LUN 0.
+*/
+   if (lun_count == 0)
+   lun_count = 1;
+
lun_count *= 8;
buf[0] = ((lun_count >> 24) & 0xff);
buf[1] = ((lun_count >> 16) & 0xff);
-- 
2.5.0.rc3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] target: allow underflow/overflow for PR OUT etc. commands

2015-07-22 Thread Spencer Baugh
From: Roland Dreier 

It's not necessarily a fatal error if a command with a data-out phase
has a data length that differs from the transport data length (e.g.
PERSISTENT RESERVE OUT might have a parameter list length in the CDB
that's smaller than the FC_DL field), so allow these commands.  The
Windows compliance test sends them.

Signed-off-by: Roland Dreier 
Signed-off-by: Spencer Baugh 
---
 drivers/target/target_core_transport.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/target/target_core_transport.c 
b/drivers/target/target_core_transport.c
index ac002a7..f6626bb 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1087,9 +1087,9 @@ target_cmd_size_check(struct se_cmd *cmd, unsigned int 
size)
" 0x%02x\n", cmd->se_tfo->get_fabric_name(),
cmd->data_length, size, cmd->t_task_cdb[0]);
 
-   if (cmd->data_direction == DMA_TO_DEVICE) {
-   pr_err("Rejecting underflow/overflow"
-   " WRITE data\n");
+   if (cmd->data_direction == DMA_TO_DEVICE &&
+   cmd->se_cmd_flags & SCF_SCSI_DATA_CDB) {
+   pr_err("Rejecting underflow/overflow WRITE data\n");
return TCM_INVALID_CDB_FIELD;
}
/*
-- 
2.5.0.rc3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] target: Drop iSCSI use of mutex around max_cmd_sn increment

2015-07-22 Thread Spencer Baugh
From: Roland Dreier 

In a performance profile, taking a mutex in iscsit_increment_maxcmdsn()
shows up very high.  However taking a mutex around "sess->max_cmd_sn += 1"
seems pretty silly: we're not serializing against other contexts in
any useful way.

I did a quick audit and there don't appear to be any other places that
use max_cmd_sn within the mutex more than once, so this lock can't be
providing any useful serialization.

Signed-off-by: Roland Dreier 
Signed-off-by: Spencer Baugh 
---
 drivers/target/iscsi/iscsi_target.c  | 18 +-
 drivers/target/iscsi/iscsi_target_configfs.c |  4 ++--
 drivers/target/iscsi/iscsi_target_device.c   |  8 +++-
 drivers/target/iscsi/iscsi_target_login.c|  2 +-
 drivers/target/iscsi/iscsi_target_nego.c |  9 +++--
 drivers/target/iscsi/iscsi_target_tmr.c  |  2 +-
 drivers/target/iscsi/iscsi_target_util.c |  7 ---
 include/target/iscsi/iscsi_target_core.h |  2 +-
 8 files changed, 24 insertions(+), 28 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target.c 
b/drivers/target/iscsi/iscsi_target.c
index ebb1ece..635ec06c 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -2555,7 +2555,7 @@ static int iscsit_send_conn_drop_async_message(
cmd->stat_sn= conn->stat_sn++;
hdr->statsn = cpu_to_be32(cmd->stat_sn);
hdr->exp_cmdsn  = cpu_to_be32(conn->sess->exp_cmd_sn);
-   hdr->max_cmdsn  = cpu_to_be32(conn->sess->max_cmd_sn);
+   hdr->max_cmdsn  = cpu_to_be32((u32) 
atomic_read(&conn->sess->max_cmd_sn));
hdr->async_event= ISCSI_ASYNC_MSG_DROPPING_CONNECTION;
hdr->param1 = cpu_to_be16(cmd->logout_cid);
hdr->param2 = 
cpu_to_be16(conn->sess->sess_ops->DefaultTime2Wait);
@@ -2627,7 +2627,7 @@ iscsit_build_datain_pdu(struct iscsi_cmd *cmd, struct 
iscsi_conn *conn,
hdr->statsn = cpu_to_be32(0x);
 
hdr->exp_cmdsn  = cpu_to_be32(conn->sess->exp_cmd_sn);
-   hdr->max_cmdsn  = cpu_to_be32(conn->sess->max_cmd_sn);
+   hdr->max_cmdsn  = cpu_to_be32((u32) 
atomic_read(&conn->sess->max_cmd_sn));
hdr->datasn = cpu_to_be32(datain->data_sn);
hdr->offset = cpu_to_be32(datain->offset);
 
@@ -2838,7 +2838,7 @@ iscsit_build_logout_rsp(struct iscsi_cmd *cmd, struct 
iscsi_conn *conn,
 
iscsit_increment_maxcmdsn(cmd, conn->sess);
hdr->exp_cmdsn  = cpu_to_be32(conn->sess->exp_cmd_sn);
-   hdr->max_cmdsn  = cpu_to_be32(conn->sess->max_cmd_sn);
+   hdr->max_cmdsn  = cpu_to_be32((u32) 
atomic_read(&conn->sess->max_cmd_sn));
 
pr_debug("Built Logout Response ITT: 0x%08x StatSN:"
" 0x%08x Response: 0x%02x CID: %hu on CID: %hu\n",
@@ -2901,7 +2901,7 @@ iscsit_build_nopin_rsp(struct iscsi_cmd *cmd, struct 
iscsi_conn *conn,
iscsit_increment_maxcmdsn(cmd, conn->sess);
 
hdr->exp_cmdsn  = cpu_to_be32(conn->sess->exp_cmd_sn);
-   hdr->max_cmdsn  = cpu_to_be32(conn->sess->max_cmd_sn);
+   hdr->max_cmdsn  = cpu_to_be32((u32) 
atomic_read(&conn->sess->max_cmd_sn));
 
pr_debug("Built NOPIN %s Response ITT: 0x%08x, TTT: 0x%08x,"
" StatSN: 0x%08x, Length %u\n", (nopout_response) ?
@@ -3048,7 +3048,7 @@ static int iscsit_send_r2t(
hdr->ttt= cpu_to_be32(r2t->targ_xfer_tag);
hdr->statsn = cpu_to_be32(conn->stat_sn);
hdr->exp_cmdsn  = cpu_to_be32(conn->sess->exp_cmd_sn);
-   hdr->max_cmdsn  = cpu_to_be32(conn->sess->max_cmd_sn);
+   hdr->max_cmdsn  = cpu_to_be32((u32) 
atomic_read(&conn->sess->max_cmd_sn));
hdr->r2tsn  = cpu_to_be32(r2t->r2t_sn);
hdr->data_offset= cpu_to_be32(r2t->offset);
hdr->data_length= cpu_to_be32(r2t->xfer_len);
@@ -3201,7 +3201,7 @@ void iscsit_build_rsp_pdu(struct iscsi_cmd *cmd, struct 
iscsi_conn *conn,
 
iscsit_increment_maxcmdsn(cmd, conn->sess);
hdr->exp_cmdsn  = cpu_to_be32(conn->sess->exp_cmd_sn);
-   hdr->max_cmdsn  = cpu_to_be32(conn->sess->max_cmd_sn);
+   hdr->max_cmdsn  = cpu_to_be32((u32) 
atomic_read(&conn->sess->max_cmd_sn));
 
pr_debug("Built SCSI Response, ITT: 0x%08x, StatSN: 0x%08x,"
" Response: 0x%02x, SAM Status: 0x%02x, CID: %hu\n",
@@ -3320,7 +3320,7 @@ iscsit_build_task_mgt_rsp(struct iscsi_cmd *cmd, struct 
iscsi_c

[PATCH] qla2xxx: remove unused rval

2015-07-22 Thread Spencer Baugh
From: Joern Engel 

We don't touch the return value of qla2x00_loop_resync in
qla2x00_do_dpc, so don't bother collecting it. Fixes a compiler warning.

Signed-off-by: Joern Engel 
Signed-off-by: Spencer Baugh 
---
 drivers/scsi/qla2xxx/qla_os.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index a28815b..b9ee115 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -4793,7 +4793,6 @@ qla2x00_disable_board_on_pci_error(struct work_struct 
*work)
 static int
 qla2x00_do_dpc(void *data)
 {
-   int rval;
scsi_qla_host_t *base_vha;
struct qla_hw_data *ha;
 
@@ -5025,7 +5024,7 @@ loop_resync_check:
if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE,
&base_vha->dpc_flags))) {
 
-   rval = qla2x00_loop_resync(base_vha);
+   qla2x00_loop_resync(base_vha);
 
clear_bit(LOOP_RESYNC_ACTIVE,
&base_vha->dpc_flags);
-- 
2.5.0.rc3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] target: improve unsupported opcode message

2015-07-22 Thread Spencer Baugh
From: Joern Engel 

Make the warning about unsupported SCSI opcode more useful:

 - Add in the initiator name so we know who's sending it.
 - Print the warning even for opcodes that spc_parse_cdb() knows about
   but that we don't handle.

Signed-off-by: Joern Engel 
Signed-off-by: Spencer Baugh 
---
 drivers/target/target_core_spc.c   | 3 ---
 drivers/target/target_core_transport.c | 5 +
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
index b074443..87d4adb 100644
--- a/drivers/target/target_core_spc.c
+++ b/drivers/target/target_core_spc.c
@@ -1405,9 +1405,6 @@ spc_parse_cdb(struct se_cmd *cmd, unsigned int *size)
}
break;
default:
-   pr_warn("TARGET_CORE[%s]: Unsupported SCSI Opcode"
-   " 0x%02x, sending CHECK_CONDITION.\n",
-   cmd->se_tfo->get_fabric_name(), cdb[0]);
return TCM_UNSUPPORTED_SCSI_OPCODE;
}
 
diff --git a/drivers/target/target_core_transport.c 
b/drivers/target/target_core_transport.c
index ce8574b..ac002a7 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1246,6 +1246,11 @@ target_setup_cmd_from_cdb(struct se_cmd *cmd, unsigned 
char *cdb)
}
 
ret = dev->transport->parse_cdb(cmd);
+   if (ret == TCM_UNSUPPORTED_SCSI_OPCODE)
+   pr_warn_ratelimited("%s/%s: Unsupported SCSI Opcode 0x%02x, 
sending CHECK_CONDITION.\n",
+   cmd->se_tfo->get_fabric_name(),
+   cmd->se_sess->se_node_acl->initiatorname,
+   cmd->t_task_cdb[0]);
if (ret)
return ret;
 
-- 
2.5.0.rc3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] target: fix crash in cmd tracing when cmd didn't match a LUN

2015-07-21 Thread Spencer Baugh

Please disregard, depends on another patch. Will send again later. Sorry
for the noise.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] qla2xxx: Return the fabric command state for non-task management requests

2015-07-21 Thread Spencer Baugh
From: Dilip Kumar Uppugandla 

Invoking get_cmd_state for qla2xxx always returns 0. Instead change it
to return the actual fabric state from qla_tgt_cmd. This will help with
debugging.

Signed-off-by: Dilip Kumar Uppugandla 
Signed-off-by: Spencer Baugh 
---
 drivers/scsi/qla2xxx/tcm_qla2xxx.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c 
b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index d9a8c60..e859586 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -420,6 +420,12 @@ static void tcm_qla2xxx_set_default_node_attrs(struct 
se_node_acl *nacl)
 
 static int tcm_qla2xxx_get_cmd_state(struct se_cmd *se_cmd)
 {
+   if (!(se_cmd->se_cmd_flags & SCF_SCSI_TMR_CDB)) {
+   struct qla_tgt_cmd *cmd = container_of(se_cmd,
+   struct qla_tgt_cmd, se_cmd);
+   return cmd->state;
+   }
+
return 0;
 }
 
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] target/iscsi: Fix double free of a TUR followed by a solicited NOPOUT

2015-07-21 Thread Spencer Baugh
From: Alexei Potashnik 

Make sure all non-READ SCSI commands get targ_xfer_tag initialized
to 0x, not just WRITEs.

Double-free of a TUR cmd object occurs under the following scenario:

1. TUR received (targ_xfer_tag is uninitialized and left at 0)
2. TUR status sent
3. First unsolicited NOPIN is sent to initiator (gets targ_xfer_tag of 0)
4. NOPOUT for NOPIN (with TTT=0) arrives
 - its ExpStatSN acks TUR status, TUR is queued for removal
 - LIO tries to find NOPIN with TTT=0, but finds the same TUR instead,
   TUR is queued for removal for the 2nd time

Signed-off-by: Alexei Potashnik 
Signed-off-by: Spencer Baugh 
---
 drivers/target/iscsi/iscsi_target.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/target/iscsi/iscsi_target.c 
b/drivers/target/iscsi/iscsi_target.c
index a4cf58c..ebb1ece 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -970,7 +970,7 @@ int iscsit_setup_scsi_cmd(struct iscsi_conn *conn, struct 
iscsi_cmd *cmd,
conn->sess->init_task_tag = cmd->init_task_tag = hdr->itt;
if (hdr->flags & ISCSI_FLAG_CMD_READ) {
cmd->targ_xfer_tag = session_get_next_ttt(conn->sess);
-   } else if (hdr->flags & ISCSI_FLAG_CMD_WRITE)
+   } else
cmd->targ_xfer_tag = 0x;
cmd->cmd_sn = be32_to_cpu(hdr->cmdsn);
cmd->exp_stat_sn= be32_to_cpu(hdr->exp_statsn);
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] soft lockup: kill realtime threads before panic

2015-07-21 Thread Spencer Baugh
From: Joern Engel 

We have observed cases where the soft lockup detector triggered, but no
kernel bug existed.  Instead we had a buggy realtime thread that
monopolized a cpu.  So let's kill the responsible party and not panic
the entire system.

Signed-off-by: Joern Engel 
Signed-off-by: Spencer Baugh 
---
 kernel/watchdog.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index a6ffa43..2355bd5 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -428,7 +428,10 @@ static enum hrtimer_restart watchdog_timer_fn(struct 
hrtimer *hrtimer)
}
 
add_taint(TAINT_SOFTLOCKUP, LOCKDEP_STILL_OK);
-   if (softlockup_panic)
+   if (rt_prio(current->prio)) {
+   pr_emerg("killing realtime thread\n");
+   send_sig(SIGILL, current, 0);
+   } else if (softlockup_panic)
panic("softlockup: hung tasks");
__this_cpu_write(soft_watchdog_warn, true);
} else
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] target: fix crash in cmd tracing when cmd didn't match a LUN

2015-07-21 Thread Spencer Baugh
From: Alexei Potashnik 

If command didn't match a LUN and we're sending check condition, the
target_cmd_complete ftrace point will crash because it assumes that
cmd->t_task_cdb has been set.

The fix will temporarily set t_task_cdb to the se_cmd buffer
and copy first 6 bytes of cdb in there as soon as possible.
At a later point t_task_cdb is reset to the correct buffer,
but until then traces and printks don't cause a crash.

Signed-off-by: Alexei Potashnik 
Signed-off-by: Spencer Baugh 
---
 drivers/target/target_core_device.c| 7 +++
 drivers/target/target_core_transport.c | 7 ---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/target/target_core_device.c 
b/drivers/target/target_core_device.c
index c4a8db6..b74dfb2 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -63,6 +63,13 @@ transport_lookup_cmd_lun(struct se_cmd *se_cmd, u64 
unpacked_lun)
struct se_node_acl *nacl = se_sess->se_node_acl;
struct se_dev_entry *deve;
 
+   /* Temporarily set t_task_cdb to the se_cmd buffer and save a portion
+* of cdb in there (fabrics must provide at least 6 bytes). t_task_cdb
+* will be correctly replaced in target_setup_cmd_from_cdb. Until then
+* tracing and printks can access t_task_cdb without causing a crash. */
+   se_cmd->t_task_cdb = se_cmd->__t_task_cdb;
+   memcpy(se_cmd->t_task_cdb, cdb, 6);
+
rcu_read_lock();
deve = target_nacl_find_deve(nacl, unpacked_lun);
if (deve) {
diff --git a/drivers/target/target_core_transport.c 
b/drivers/target/target_core_transport.c
index ce8574b..8dd15c7 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1210,15 +1210,16 @@ target_setup_cmd_from_cdb(struct se_cmd *cmd, unsigned 
char *cdb)
 * setup the pointer from __t_task_cdb to t_task_cdb.
 */
if (scsi_command_size(cdb) > sizeof(cmd->__t_task_cdb)) {
-   cmd->t_task_cdb = kzalloc(scsi_command_size(cdb),
-   GFP_KERNEL);
-   if (!cmd->t_task_cdb) {
+   unsigned char *ptr = kzalloc(scsi_command_size(cdb),
+GFP_KERNEL);
+   if (!ptr) {
pr_err("Unable to allocate cmd->t_task_cdb"
" %u > sizeof(cmd->__t_task_cdb): %lu ops\n",
scsi_command_size(cdb),
(unsigned long)sizeof(cmd->__t_task_cdb));
return TCM_OUT_OF_RESOURCES;
}
+   cmd->t_task_cdb = ptr;
} else
cmd->t_task_cdb = &cmd->__t_task_cdb[0];
/*
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] target: add support for START_STOP_UNIT SCSI opcode

2015-07-21 Thread Spencer Baugh
From: Brian Bunker 

AIX servers using VIOS servers that virtualize FC cards will have a
problem booting without support for START_STOP_UNIT.

Signed-off-by: Brian Bunker 
Signed-off-by: Spencer Baugh 
---
 drivers/target/target_core_sbc.c | 33 +
 1 file changed, 33 insertions(+)

diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
index e318ddb..996e584 100644
--- a/drivers/target/target_core_sbc.c
+++ b/drivers/target/target_core_sbc.c
@@ -154,6 +154,35 @@ sbc_emulate_readcapacity_16(struct se_cmd *cmd)
return 0;
 }
 
+static sense_reason_t
+sbc_emulate_startstop(struct se_cmd *cmd)
+{
+   unsigned char *cdb = cmd->t_task_cdb;
+
+   /* From SBC-3:
+* Immediate bit should be set since there is nothing to complete
+* POWER CONDITION MODIFIER 0h
+*/
+   if (!(cdb[1] & 1) || (cdb[2] | cdb[3]))
+   return TCM_INVALID_CDB_FIELD;
+
+   /* From SBC-3:
+* POWER CONDITION 0h START_VALID - process START and LOEJ
+*/
+   if (cdb[4] >> 4 & 0xf)
+   return TCM_INVALID_CDB_FIELD;
+
+   /* From SBC-3:
+* LOEJ 0h - nothing to load or unload
+* START 1h - we are ready
+*/
+   if (!(cdb[4] & 1) || ((cdb[4] & 2) | (cdb[4] & 4)))
+   return TCM_INVALID_CDB_FIELD;
+
+   target_complete_cmd(cmd, SAM_STAT_GOOD);
+   return 0;
+}
+
 sector_t sbc_get_write_same_sectors(struct se_cmd *cmd)
 {
u32 num_blocks;
@@ -1069,6 +1098,10 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
size = 0;
cmd->execute_cmd = sbc_emulate_noop;
break;
+   case START_STOP:
+   size = 0;
+   cmd->execute_cmd = sbc_emulate_startstop;
+   break;
default:
ret = spc_parse_cdb(cmd, &size);
if (ret)
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] target: remove unused lun_flags field from se_lun

2015-07-21 Thread Spencer Baugh
Christoph Hellwig  writes:

> Looks good,
>
> but what's up with your From lines:
>
> On Mon, Jul 20, 2015 at 04:29:49PM -0700, Spencer Baugh wrote:
>> From: Spencer Baugh 
>> 
>> From: Chris Zankel 
>
> plus another address for you in the actual email From line.  Who
> did actually write this patch?

Sorry, ignore the first From: line; the correct one is
From: Chris Zankel 
for both patches
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] target/iscsi: fix digest computation for chained SGs

2015-07-20 Thread Spencer Baugh
From: Alexei Potashnik 

Current implementation assumes that all the buffers of an IO are linked
with a single SG list. Which makes it fail if SG chaining is used.

Signed-off-by: Alexei Potashnik 
---
 drivers/target/iscsi/iscsi_target.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target.c 
b/drivers/target/iscsi/iscsi_target.c
index 4e68b62..a4cf58c 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -1209,7 +1209,6 @@ static u32 iscsit_do_crypto_hash_sg(
u8 *pad_bytes)
 {
u32 data_crc;
-   u32 i;
struct scatterlist *sg;
unsigned int page_off;
 
@@ -1218,15 +1217,15 @@ static u32 iscsit_do_crypto_hash_sg(
sg = cmd->first_data_sg;
page_off = cmd->first_data_sg_off;
 
-   i = 0;
while (data_length) {
-   u32 cur_len = min_t(u32, data_length, (sg[i].length - 
page_off));
+   u32 cur_len = min_t(u32, data_length, (sg->length - page_off));
 
-   crypto_hash_update(hash, &sg[i], cur_len);
+   crypto_hash_update(hash, sg, cur_len);
 
data_length -= cur_len;
page_off = 0;
-   i++;
+   /* iscsit_map_iovec has already checked for invalid sg pointers 
*/
+   sg = sg_next(sg);
}
 
if (padding) {
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] target: remove unused lun_flags field from se_lun

2015-07-20 Thread Spencer Baugh
From: Spencer Baugh 

From: Chris Zankel 

The lun_flags field is not used, so drop it.

Signed-off-by: Chris Zankel 
---
 include/target/target_core_base.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/target/target_core_base.h 
b/include/target/target_core_base.h
index 17ae2d6..0a7c44e 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -685,7 +685,6 @@ struct se_lun {
 #define SE_LUN_LINK_MAGIC  0x7771
u32 lun_link_magic;
u32 lun_access;
-   u32 lun_flags;
u32 lun_index;
 
/* RELATIVE TARGET PORT IDENTIFER */
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] target: remove initiatorname field in se_acl_lun

2015-07-20 Thread Spencer Baugh
From: Spencer Baugh 

From: Chris Zankel 

The initiatorname field in se_acl_lun is only a copy of the same field
in se_node_acl, so remove it and use the version in se_node_acl where
needed (it's actually only used for pr_debug)

Signed-off-by: Chris Zankel 
---
 drivers/target/target_core_device.c  | 8 +++-
 drivers/target/target_core_fabric_configfs.c | 2 +-
 include/target/target_core_base.h| 1 -
 3 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/target/target_core_device.c 
b/drivers/target/target_core_device.c
index 09e682b..c4a8db6 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -620,8 +620,6 @@ struct se_lun_acl *core_dev_init_initiator_node_lun_acl(
 
lacl->mapped_lun = mapped_lun;
lacl->se_lun_nacl = nacl;
-   snprintf(lacl->initiatorname, TRANSPORT_IQN_LEN, "%s",
-nacl->initiatorname);
 
return lacl;
 }
@@ -656,7 +654,7 @@ int core_dev_add_initiator_node_lun_acl(
" InitiatorNode: %s\n", tpg->se_tpg_tfo->get_fabric_name(),
tpg->se_tpg_tfo->tpg_get_tag(tpg), lun->unpacked_lun, 
lacl->mapped_lun,
(lun_access & TRANSPORT_LUNFLAGS_READ_WRITE) ? "RW" : "RO",
-   lacl->initiatorname);
+   nacl->initiatorname);
/*
 * Check to see if there are any existing persistent reservation APTPL
 * pre-registrations that need to be enabled for this LUN ACL..
@@ -688,7 +686,7 @@ int core_dev_del_initiator_node_lun_acl(
" InitiatorNode: %s Mapped LUN: %llu\n",
tpg->se_tpg_tfo->get_fabric_name(),
tpg->se_tpg_tfo->tpg_get_tag(tpg), lun->unpacked_lun,
-   lacl->initiatorname, lacl->mapped_lun);
+   nacl->initiatorname, lacl->mapped_lun);
 
return 0;
 }
@@ -701,7 +699,7 @@ void core_dev_free_initiator_node_lun_acl(
" Mapped LUN: %llu\n", tpg->se_tpg_tfo->get_fabric_name(),
tpg->se_tpg_tfo->tpg_get_tag(tpg),
tpg->se_tpg_tfo->get_fabric_name(),
-   lacl->initiatorname, lacl->mapped_lun);
+   lacl->se_lun_nacl->initiatorname, lacl->mapped_lun);
 
kfree(lacl);
 }
diff --git a/drivers/target/target_core_fabric_configfs.c 
b/drivers/target/target_core_fabric_configfs.c
index 48a3698..be42429 100644
--- a/drivers/target/target_core_fabric_configfs.c
+++ b/drivers/target/target_core_fabric_configfs.c
@@ -203,7 +203,7 @@ static ssize_t target_fabric_mappedlun_store_write_protect(
pr_debug("%s_ConfigFS: Changed Initiator ACL: %s"
" Mapped LUN: %llu Write Protect bit to %s\n",
se_tpg->se_tpg_tfo->get_fabric_name(),
-   lacl->initiatorname, lacl->mapped_lun, (op) ? "ON" : "OFF");
+   se_nacl->initiatorname, lacl->mapped_lun, (op) ? "ON" : "OFF");
 
return count;
 
diff --git a/include/target/target_core_base.h 
b/include/target/target_core_base.h
index 0a7c44e..b59b61a 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -598,7 +598,6 @@ struct se_ml_stat_grps {
 };
 
 struct se_lun_acl {
-   charinitiatorname[TRANSPORT_IQN_LEN];
u64 mapped_lun;
struct se_node_acl  *se_lun_nacl;
struct se_lun   *se_lun;
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] lustre: ptlrpc: add "ptlrpc_internal.h" to sec_gc.c

2014-12-20 Thread Spencer Baugh
ptlrpc_internal.h contains the prototypes for sptlrpc_gc_init() and
sptlrpc_gc_fini(), which are defined in sec_gc.c.

This removes the following sparse warnings:

drivers/staging/lustre/lustre/ptlrpc/sec_gc.c:217:5: warning: symbol 
'sptlrpc_gc_init' was not declared. Should it be static?
drivers/staging/lustre/lustre/ptlrpc/sec_gc.c:241:6: warning: symbol 
'sptlrpc_gc_fini' was not declared. Should it be static?

Signed-off-by: Spencer Baugh 
---
 drivers/staging/lustre/lustre/ptlrpc/sec_gc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c 
b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c
index c500aff..81de68e 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c
@@ -47,6 +47,8 @@
 #include "../include/lustre_net.h"
 #include "../include/lustre_sec.h"
 
+#include "ptlrpc_internal.h"
+
 #define SEC_GC_INTERVAL (30 * 60)
 
 
-- 
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] staging: lustre: fix pointer whitespace style

2014-09-14 Thread Spencer Baugh
Fix errors reported by checkpatch of this kind:
ERROR: "foo * bar" should be "foo *bar"

Signed-off-by: Spencer Baugh 
---
 drivers/staging/lustre/lustre/include/lustre_import.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h 
b/drivers/staging/lustre/lustre/include/lustre_import.h
index 7bf82e0..51f3e98 100644
--- a/drivers/staging/lustre/lustre/include/lustre_import.h
+++ b/drivers/staging/lustre/lustre/include/lustre_import.h
@@ -103,9 +103,9 @@ enum lustre_imp_state {
 };
 
 /** Returns test string representation of numeric import state \a state */
-static inline char * ptlrpc_import_state_name(enum lustre_imp_state state)
+static inline char *ptlrpc_import_state_name(enum lustre_imp_state state)
 {
-   static char* import_state_names[] = {
+   static char *import_state_names[] = {
"", "CLOSED",  "NEW", "DISCONN",
"CONNECTING", "REPLAY", "REPLAY_LOCKS", "REPLAY_WAIT",
"RECOVER", "FULL", "EVICTED",
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] staging: lustre: fix function definition style

2014-09-14 Thread Spencer Baugh
Fix errors reported by checkpatch of this kind:
ERROR: open brace '{' following function declarations go on the next line

Signed-off-by: Spencer Baugh 
---
 drivers/staging/lustre/lustre/include/lustre_import.h | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h 
b/drivers/staging/lustre/lustre/include/lustre_import.h
index 8304a55..7bf82e0 100644
--- a/drivers/staging/lustre/lustre/include/lustre_import.h
+++ b/drivers/staging/lustre/lustre/include/lustre_import.h
@@ -346,21 +346,24 @@ static inline unsigned int at_timeout2est(unsigned int 
val)
return (max((val << 2) / 5, 5U) - 4);
 }
 
-static inline void at_reset(struct adaptive_timeout *at, int val) {
+static inline void at_reset(struct adaptive_timeout *at, int val)
+{
spin_lock(&at->at_lock);
at->at_current = val;
at->at_worst_ever = val;
at->at_worst_time = get_seconds();
spin_unlock(&at->at_lock);
 }
-static inline void at_init(struct adaptive_timeout *at, int val, int flags) {
+static inline void at_init(struct adaptive_timeout *at, int val, int flags)
+{
memset(at, 0, sizeof(*at));
spin_lock_init(&at->at_lock);
at->at_flags = flags;
at_reset(at, val);
 }
 extern unsigned int at_min;
-static inline int at_get(struct adaptive_timeout *at) {
+static inline int at_get(struct adaptive_timeout *at)
+{
return (at->at_current > at_min) ? at->at_current : at_min;
 }
 int at_measured(struct adaptive_timeout *at, unsigned int val);
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/3] staging: lustre: fix pointer whitespace style

2014-09-06 Thread Spencer Baugh
Fix errors reported by checkpatch of this kind:
ERROR: "foo * bar" should be "foo *bar"

Signed-off-by: Spencer Baugh 
---
 drivers/staging/lustre/lustre/include/lustre_import.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h 
b/drivers/staging/lustre/lustre/include/lustre_import.h
index feb4291..b71877b 100644
--- a/drivers/staging/lustre/lustre/include/lustre_import.h
+++ b/drivers/staging/lustre/lustre/include/lustre_import.h
@@ -103,9 +103,9 @@ enum lustre_imp_state {
 };
 
 /** Returns test string representation of numeric import state \a state */
-static inline char * ptlrpc_import_state_name(enum lustre_imp_state state)
+static inline char *ptlrpc_import_state_name(enum lustre_imp_state state)
 {
-   static char* import_state_names[] = {
+   static char *import_state_names[] = {
"", "CLOSED",  "NEW", "DISCONN",
"CONNECTING", "REPLAY", "REPLAY_LOCKS", "REPLAY_WAIT",
"RECOVER", "FULL", "EVICTED",
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] staging: lustre: remove trailing whitespace

2014-09-06 Thread Spencer Baugh
Fix errors reported by checkpatch of this kind:
ERROR: trailing whitespace

Signed-off-by: Spencer Baugh 
---
 drivers/staging/lustre/lustre/include/lustre_import.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h 
b/drivers/staging/lustre/lustre/include/lustre_import.h
index b71877b..51f3e98 100644
--- a/drivers/staging/lustre/lustre/include/lustre_import.h
+++ b/drivers/staging/lustre/lustre/include/lustre_import.h
@@ -346,7 +346,7 @@ static inline unsigned int at_timeout2est(unsigned int val)
return (max((val << 2) / 5, 5U) - 4);
 }
 
-static inline void at_reset(struct adaptive_timeout *at, int val) 
+static inline void at_reset(struct adaptive_timeout *at, int val)
 {
spin_lock(&at->at_lock);
at->at_current = val;
@@ -354,7 +354,7 @@ static inline void at_reset(struct adaptive_timeout *at, 
int val)
at->at_worst_time = get_seconds();
spin_unlock(&at->at_lock);
 }
-static inline void at_init(struct adaptive_timeout *at, int val, int flags) 
+static inline void at_init(struct adaptive_timeout *at, int val, int flags)
 {
memset(at, 0, sizeof(*at));
spin_lock_init(&at->at_lock);
@@ -362,7 +362,7 @@ static inline void at_init(struct adaptive_timeout *at, int 
val, int flags)
at_reset(at, val);
 }
 extern unsigned int at_min;
-static inline int at_get(struct adaptive_timeout *at) 
+static inline int at_get(struct adaptive_timeout *at)
 {
return (at->at_current > at_min) ? at->at_current : at_min;
 }
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/3] staging: lustre: fix function definition style

2014-09-06 Thread Spencer Baugh
Fix errors reported by checkpatch of this kind:
ERROR: open brace '{' following function declarations go on the next line

Signed-off-by: Spencer Baugh 
---
 drivers/staging/lustre/lustre/include/lustre_import.h | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h 
b/drivers/staging/lustre/lustre/include/lustre_import.h
index 8304a55..feb4291 100644
--- a/drivers/staging/lustre/lustre/include/lustre_import.h
+++ b/drivers/staging/lustre/lustre/include/lustre_import.h
@@ -346,21 +346,24 @@ static inline unsigned int at_timeout2est(unsigned int 
val)
return (max((val << 2) / 5, 5U) - 4);
 }
 
-static inline void at_reset(struct adaptive_timeout *at, int val) {
+static inline void at_reset(struct adaptive_timeout *at, int val) 
+{
spin_lock(&at->at_lock);
at->at_current = val;
at->at_worst_ever = val;
at->at_worst_time = get_seconds();
spin_unlock(&at->at_lock);
 }
-static inline void at_init(struct adaptive_timeout *at, int val, int flags) {
+static inline void at_init(struct adaptive_timeout *at, int val, int flags) 
+{
memset(at, 0, sizeof(*at));
spin_lock_init(&at->at_lock);
at->at_flags = flags;
at_reset(at, val);
 }
 extern unsigned int at_min;
-static inline int at_get(struct adaptive_timeout *at) {
+static inline int at_get(struct adaptive_timeout *at) 
+{
return (at->at_current > at_min) ? at->at_current : at_min;
 }
 int at_measured(struct adaptive_timeout *at, unsigned int val);
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: fix style in lustre_import.h

2014-08-22 Thread Spencer Baugh
This patch fixes style errors and warnings reported by
scripts/checkpatch.pl

Signed-off-by: Spencer Baugh 

---
 .../staging/lustre/lustre/include/lustre_import.h   | 21 -
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h 
b/drivers/staging/lustre/lustre/include/lustre_import.h
index 8304a55..b39b283 100644
--- a/drivers/staging/lustre/lustre/include/lustre_import.h
+++ b/drivers/staging/lustre/lustre/include/lustre_import.h
@@ -103,15 +103,15 @@ enum lustre_imp_state {
 };
 
 /** Returns test string representation of numeric import state \a state */
-static inline char * ptlrpc_import_state_name(enum lustre_imp_state state)
+static inline char *ptlrpc_import_state_name(enum lustre_imp_state state)
 {
-   static char* import_state_names[] = {
+   static char *import_state_names[] = {
"", "CLOSED",  "NEW", "DISCONN",
"CONNECTING", "REPLAY", "REPLAY_LOCKS", "REPLAY_WAIT",
"RECOVER", "FULL", "EVICTED",
};
 
-   LASSERT (state <= LUSTRE_IMP_EVICTED);
+   LASSERT(state <= LUSTRE_IMP_EVICTED);
return import_state_names[state];
 }
 
@@ -302,12 +302,12 @@ struct obd_import {
intimp_connect_error;
 
__u32imp_msg_magic;
-   __u32imp_msghdr_flags;   /* adjusted based on 
server capability */
+   __u32imp_msghdr_flags;   /* adjusted based on server 
capability */
 
-   struct ptlrpc_request_pool *imp_rq_pool;  /* emergency request 
pool */
+   struct ptlrpc_request_pool *imp_rq_pool; /* emergency request pool */
 
struct imp_atimp_at; /* adaptive timeout data */
-   time_t  imp_last_reply_time;/* for health check */
+   time_t  imp_last_reply_time; /* for health check */
 };
 
 typedef void (*obd_import_callback)(struct obd_import *imp, void *closure,
@@ -346,21 +346,24 @@ static inline unsigned int at_timeout2est(unsigned int 
val)
return (max((val << 2) / 5, 5U) - 4);
 }
 
-static inline void at_reset(struct adaptive_timeout *at, int val) {
+static inline void at_reset(struct adaptive_timeout *at, int val)
+{
spin_lock(&at->at_lock);
at->at_current = val;
at->at_worst_ever = val;
at->at_worst_time = get_seconds();
spin_unlock(&at->at_lock);
 }
-static inline void at_init(struct adaptive_timeout *at, int val, int flags) {
+static inline void at_init(struct adaptive_timeout *at, int val, int flags)
+{
memset(at, 0, sizeof(*at));
spin_lock_init(&at->at_lock);
at->at_flags = flags;
at_reset(at, val);
 }
 extern unsigned int at_min;
-static inline int at_get(struct adaptive_timeout *at) {
+static inline int at_get(struct adaptive_timeout *at)
+{
return (at->at_current > at_min) ? at->at_current : at_min;
 }
 int at_measured(struct adaptive_timeout *at, unsigned int val);
-- 
2.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/