Merged revisions 5671,5687-5697,5723 via svnmerge from

svn+ssh://yanb123@svn.code.sf.net/p/scst/svn/branches/3.0.x

................
  r5671 | bvassche | 2014-07-10 09:27:29 +0300 (Thu, 10 Jul 2014) | 1 line
  
  scst: Create /var/lib/scst/pr and /var/lib/scst/vdev_mode_pages during installation (merge r5669 and r5670 from trunk)
................
  r5687 | bvassche | 2014-07-20 08:59:31 +0300 (Sun, 20 Jul 2014) | 1 line
  
  iscsi-scst: Handle data buffers with non-zero offset correctly (merge r5683 from trunk)
................
  r5688 | bvassche | 2014-07-20 09:01:49 +0300 (Sun, 20 Jul 2014) | 1 line
  
  Makefile: Only report which RPMs have been built if "make rpm" is run as a non-privileged user (merge r5560 from trunk)
................
  r5689 | bvassche | 2014-07-20 09:03:55 +0300 (Sun, 20 Jul 2014) | 1 line
  
  fcst: Remove an unused variable (merge r5605 from trunk)
................
  r5690 | bvassche | 2014-07-20 09:04:43 +0300 (Sun, 20 Jul 2014) | 1 line
  
  fcst: Move exch_done() calls into ft_cmd_done() (merge r5606 from trunk)
................
  r5691 | bvassche | 2014-07-20 09:05:27 +0300 (Sun, 20 Jul 2014) | 1 line
  
  fcst: Handle frame send failures properly (merge r5607 from trunk)
................
  r5692 | bvassche | 2014-07-20 09:07:57 +0300 (Sun, 20 Jul 2014) | 1 line
  
  qla2x00t: Documentation / source code comment / log messages spelling fix (merge r5555 from trunk)
................
  r5693 | bvassche | 2014-07-20 09:46:28 +0300 (Sun, 20 Jul 2014) | 1 line
  
  scst: Make lockdep_assert_held() easier to use (merge r5573 from trunk)
................
  r5694 | bvassche | 2014-07-20 09:47:58 +0300 (Sun, 20 Jul 2014) | 1 line
  
  scst: Leave out FSF mail address (merge r5572 from trunk)
................
  r5695 | bvassche | 2014-07-20 09:52:12 +0300 (Sun, 20 Jul 2014) | 1 line
  
  Change BUG_ON(1) into BUG() (merge r5618 from trunk)
................
  r5696 | bvassche | 2014-07-20 09:54:00 +0300 (Sun, 20 Jul 2014) | 1 line
  
  iscsi-scst: Suppress a compiler warning (merge r5614 from trunk)
................
  r5697 | bvassche | 2014-07-20 10:03:04 +0300 (Sun, 20 Jul 2014) | 1 line
  
  scst/include/scst.h: Define lockdep_assert_held() only once (follow-up for r5693)
................
  r5723 | vlnb | 2014-08-21 08:21:55 +0300 (Thu, 21 Aug 2014) | 11 lines
  
  Merged revisions 5721 via svnmerge from 
  svn+ssh://vlnb@svn.code.sf.net/p/scst/svn/trunk
  
  ........
    r5721 | vlnb | 2014-08-20 22:17:47 -0700 (Wed, 20 Aug 2014) | 5 lines
    
    Fix incorrect address computation during receive PDUs preparations
    
    Found and fix suggested by Кирилл Тюшев <kirill.tyushev8@gmail.com>
  ........
................


git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/3.0.x-iser@5739 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Yan Burman
2014-08-27 13:49:04 +00:00
parent b990f13496
commit e8f0d9af09
67 changed files with 179 additions and 283 deletions
+22
View File
@@ -174,4 +174,26 @@ struct ft_tpg *ft_lport_find_tpg(struct fc_lport *);
struct ft_node_acl *ft_acl_get(struct ft_tpg *, struct fc_rport_priv *);
void ft_cmd_dump(struct scst_cmd *, const char *);
/* #define FCST_INJECT_SEND_ERRORS 2 */
#ifdef FCST_INJECT_SEND_ERRORS
#define FCST_INJ_SEND_ERR(e) \
({ \
int _error = 0; \
\
if (scst_random() % 62929 == 0) \
_error = -ENOMEM; \
if (FCST_INJECT_SEND_ERRORS >= 2 && scst_random() % 69491 == 0) \
_error = -ENXIO; \
if (_error) \
pr_warn("%s: injected seq_send() error %d\n", __func__, \
_error); \
else \
_error = (e); \
_error; \
})
#else
#define FCST_INJ_SEND_ERR(e) (e)
#endif
#endif /* __SCSI_FCST_H__ */
+57 -29
View File
@@ -212,13 +212,10 @@ static void ft_abort_cmd(struct scst_cmd *cmd)
struct ft_cmd *fcmd = scst_cmd_get_tgt_priv(cmd);
struct fc_seq *sp = fcmd->seq;
struct fc_exch *ep = fc_seq_exch(sp);
struct fc_lport *lport = ep->lp;
pr_err("%s: cmd %p ox_id %#x rx_id %#x state %d\n", __func__, cmd,
ep->oxid, ep->rxid, fcmd->state);
lport->tt.exch_done(sp);
spin_lock(&fcmd->lock);
switch (fcmd->state) {
case FT_STATE_NEW:
@@ -257,10 +254,13 @@ static void ft_abort_cmd(struct scst_cmd *cmd)
static void ft_cmd_done(struct ft_cmd *fcmd)
{
struct fc_frame *fp = fcmd->req_frame;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)
struct fc_lport *lport;
struct fc_seq *sp = fcmd->seq;
struct fc_lport *lport = fr_dev(fp);
lport = fr_dev(fp);
if (sp)
lport->tt.exch_done(sp);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)
if (fr_seq(fp))
lport->tt.seq_release(fr_seq(fp));
#endif
@@ -291,6 +291,7 @@ int ft_send_response(struct scst_cmd *cmd)
struct fc_exch *ep;
unsigned int slen;
size_t len;
enum ft_cmd_state prev_state;
int resid = 0;
int bi_resid = 0;
int error;
@@ -303,7 +304,7 @@ int ft_send_response(struct scst_cmd *cmd)
lport = ep->lp;
WARN_ON(fcmd->state != FT_STATE_NEW && fcmd->state != FT_STATE_DATA_IN);
ft_set_cmd_state(fcmd, FT_STATE_CMD_RSP_SENT);
prev_state = ft_set_cmd_state(fcmd, FT_STATE_CMD_RSP_SENT);
if (scst_cmd_aborted_on_xmit(cmd)) {
FT_IO_DBG("cmd aborted did %x oxid %x\n", ep->did, ep->oxid);
@@ -313,7 +314,8 @@ int ft_send_response(struct scst_cmd *cmd)
if (!scst_cmd_get_is_send_status(cmd)) {
FT_IO_DBG("send status not set. feature not implemented\n");
return SCST_TGT_RES_FATAL_ERROR;
error = SCST_TGT_RES_FATAL_ERROR;
goto err;
}
status = scst_cmd_get_status(cmd);
@@ -333,7 +335,7 @@ int ft_send_response(struct scst_cmd *cmd)
error = ft_send_read_data(cmd);
if (error) {
FT_ERR("ft_send_read_data returned %d\n", error);
return error;
goto err;
}
if (dir == SCST_DATA_BIDI) {
@@ -347,8 +349,10 @@ int ft_send_response(struct scst_cmd *cmd)
}
fp = fc_frame_alloc(lport, len);
if (!fp)
return SCST_TGT_RES_QUEUE_FULL;
if (!fp) {
error = SCST_TGT_RES_QUEUE_FULL;
goto err;
}
fcp = fc_frame_payload_get(fp, len);
memset(fcp, 0, sizeof(*fcp));
@@ -384,14 +388,26 @@ int ft_send_response(struct scst_cmd *cmd)
fc_fill_fc_hdr(fp, FC_RCTL_DD_CMD_STATUS, ep->did, ep->sid, FC_TYPE_FCP,
FC_FC_EX_CTX | FC_FC_LAST_SEQ | FC_FC_END_SEQ, 0);
error = lport->tt.seq_send(lport, fcmd->seq, fp);
if (error < 0)
error = FCST_INJ_SEND_ERR(lport->tt.seq_send(lport, fcmd->seq, fp));
if (error < 0) {
pr_err("Sending response for exchange with OX_ID %#x and RX_ID"
" %#x failed: %d\n", ep->oxid, ep->rxid, error);
error = error == -ENOMEM ? SCST_TGT_RES_QUEUE_FULL :
SCST_TGT_RES_FATAL_ERROR;
goto err;
}
done:
lport->tt.exch_done(fcmd->seq);
scst_tgt_cmd_done(cmd, SCST_CONTEXT_SAME);
return SCST_TGT_RES_SUCCESS;
err:
ft_set_cmd_state(fcmd, prev_state);
WARN_ONCE(error != SCST_TGT_RES_QUEUE_FULL &&
error != SCST_TGT_RES_FATAL_ERROR,
"%s: invalid error code %d\n",
__func__, error);
return error;
}
/*
@@ -452,6 +468,7 @@ int ft_send_xfer_rdy(struct scst_cmd *cmd)
struct fcp_txrdy *txrdy;
struct fc_lport *lport;
struct fc_exch *ep;
int error;
fcmd = scst_cmd_get_tgt_priv(cmd);
@@ -472,8 +489,17 @@ int ft_send_xfer_rdy(struct scst_cmd *cmd)
fcmd->seq = lport->tt.seq_start_next(fcmd->seq);
fc_fill_fc_hdr(fp, FC_RCTL_DD_DATA_DESC, ep->did, ep->sid, FC_TYPE_FCP,
FC_FC_EX_CTX | FC_FC_END_SEQ | FC_FC_SEQ_INIT, 0);
lport->tt.seq_send(lport, fcmd->seq, fp);
return SCST_TGT_RES_SUCCESS;
error = FCST_INJ_SEND_ERR(lport->tt.seq_send(lport, fcmd->seq, fp));
switch (error) {
case 0:
return SCST_TGT_RES_SUCCESS;
case -ENOMEM:
ft_set_cmd_state(fcmd, FT_STATE_NEW);
return SCST_TGT_RES_QUEUE_FULL;
default:
ft_set_cmd_state(fcmd, FT_STATE_NEW);
return SCST_TGT_RES_FATAL_ERROR;
}
}
/*
@@ -528,16 +554,14 @@ static void ft_send_resp_status(struct fc_frame *rx_fp, u32 status,
lport->tt.seq_send(lport, sp, fp);
out:
lport->tt.exch_done(fr_seq(rx_fp));
;
#else
fc_fill_reply_hdr(fp, rx_fp, FC_RCTL_DD_CMD_STATUS, 0);
sp = fr_seq(fp);
if (sp) {
if (sp)
lport->tt.seq_send(lport, sp, fp);
lport->tt.exch_done(sp);
} else {
else
lport->tt.frame_send(lport, fp);
}
#endif
}
@@ -651,7 +675,7 @@ static void ft_recv_cmd(struct ft_sess *sess, struct fc_frame *fp)
{
struct fc_seq *sp;
struct scst_cmd *cmd;
struct ft_cmd *fcmd;
struct ft_cmd *fcmd = NULL;
struct fcp_cmnd *fcp;
struct fc_lport *lport;
int data_dir;
@@ -659,6 +683,15 @@ static void ft_recv_cmd(struct ft_sess *sess, struct fc_frame *fp)
int cdb_len;
lport = sess->tport->lport;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
sp = fr_seq(fp);
#else
sp = lport->tt.seq_assign(lport, fp);
if (!sp)
goto busy;
#endif
fcmd = kzalloc(sizeof(*fcmd), GFP_ATOMIC);
if (!fcmd)
goto busy;
@@ -702,13 +735,6 @@ static void ft_recv_cmd(struct ft_sess *sess, struct fc_frame *fp)
scst_cmd_set_tgt_priv(cmd, fcmd);
cmd->state = FT_STATE_NEW;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
sp = fr_seq(fp);
#else
sp = lport->tt.seq_assign(lport, fp);
if (!sp)
goto busy;
#endif
fcmd->seq = sp;
lport->tt.seq_set_resp(sp, ft_recv_seq, cmd);
@@ -757,6 +783,8 @@ busy:
ft_send_resp_status(fp, SAM_STAT_BUSY, 0);
if (fcmd)
ft_cmd_done(fcmd);
else if (sp)
lport->tt.exch_done(sp);
}
/*
+11 -5
View File
@@ -17,8 +17,7 @@
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
* this program.
*/
#include <linux/kernel.h>
#include <linux/types.h>
@@ -176,10 +175,17 @@ int ft_send_read_data(struct scst_cmd *cmd)
remaining ? (FC_FC_EX_CTX | FC_FC_REL_OFF) :
(FC_FC_EX_CTX | FC_FC_REL_OFF | FC_FC_END_SEQ),
fh_off);
error = lport->tt.seq_send(lport, fcmd->seq, fp);
error = FCST_INJ_SEND_ERR(lport->tt.seq_send(lport, fcmd->seq,
fp));
if (error) {
WARN_ON(1);
/* XXX For now, initiator will retry */
pr_warn("Sending frame with oid %#x oxid %#x resp_len"
" %d failed at frame_off %u / remaining %zu"
" with error code %d - %s", ep->oid, ep->oxid,
scst_cmd_get_resp_data_len(cmd), frame_off,
remaining, error, error == -ENOMEM ?
"retrying" : "giving up");
return error == -ENOMEM ? SCST_TGT_RES_QUEUE_FULL :
SCST_TGT_RES_FATAL_ERROR;
} else
fcmd->read_data_len = frame_off;
}
-2
View File
@@ -350,10 +350,8 @@ static struct ft_sess *ft_sess_delete(struct ft_tport *tport, u32 port_id)
*/
static void ft_sess_close(struct ft_sess *sess)
{
struct fc_lport *lport;
u32 port_id;
lport = sess->tport->lport;
port_id = sess->port_id;
if (port_id == -1)
return;