aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-05-16 10:55:07 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-05-16 10:55:07 -0400
commit5c64e3a45d43c6e3fa87cbe02e10059171d10812 (patch)
tree4b913307a3f9785aebf6c9271f26ec79ab5db625
parentc240a539df4e2d50f86e2f31813ff6b7334cd493 (diff)
parentccf5ae83a6cf3d9cfe9a7038bfe7cd38ab03d5e1 (diff)
Merge branch 'queue' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending
Pull target fixes from Nicholas Bellinger: "A handful of fixes + minor changes this time around, along with one important >= v3.9 regression fix for IBLOCK backends. The highlights include: - Use FD_MAX_SECTORS in FILEIO for block_device as well as files (agrover) - Fix processing of out-of-order CmdSNs with iSBD driver (shlomo) - Close long-standing target_put_sess_cmd() vs. core_tmr_abort_task() race with the addition of kref_put_spinlock_irqsave() (joern + greg-kh) - Fix IBLOCK WCE=1 + DPOFUA=1 backend WRITE regression in >= v3.9 (nab + bootc) Note these four patches are CC'ed to stable. Also, there is still some work left to be done on the active I/O shutdown path in target_wait_for_sess_cmds() used by tcm_qla2xxx + ib_isert fabrics that is still being discussed on the list, and will hopefully be resolved soon." * 'queue' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: target: close target_put_sess_cmd() vs. core_tmr_abort_task() race target: removed unused transport_state flag target/iblock: Fix WCE=1 + DPOFUA=1 backend WRITE regression MAINTAINERS: Update target git tree URL iscsi-target: Fix typos in RDMAEXTENSIONS macro usage target/rd: Add ramdisk bit for NULLIO operation iscsi-target: Fix processing of OOO commands iscsi-target: Make buf param of iscsit_do_crypto_hash_buf() const void * iscsi-target: Fix NULL pointer dereference in iscsit_send_reject target: Have dev/enable show if TCM device is configured target: Use FD_MAX_SECTORS/FD_BLOCKSIZE for blockdevs using fileio target: Remove unused struct members in se_dev_entry
-rw-r--r--MAINTAINERS2
-rw-r--r--drivers/target/iscsi/iscsi_target.c63
-rw-r--r--drivers/target/iscsi/iscsi_target_erl1.c7
-rw-r--r--drivers/target/iscsi/iscsi_target_parameters.c8
-rw-r--r--drivers/target/iscsi/iscsi_target_parameters.h4
-rw-r--r--drivers/target/target_core_configfs.c11
-rw-r--r--drivers/target/target_core_device.c14
-rw-r--r--drivers/target/target_core_file.c9
-rw-r--r--drivers/target/target_core_iblock.c2
-rw-r--r--drivers/target/target_core_internal.h1
-rw-r--r--drivers/target/target_core_rd.c21
-rw-r--r--drivers/target/target_core_rd.h1
-rw-r--r--drivers/target/target_core_transport.c13
-rw-r--r--include/linux/kref.h33
-rw-r--r--include/target/target_core_base.h5
15 files changed, 107 insertions, 87 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index 3d7782b9f90d..3a7b07f513da 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7854,7 +7854,7 @@ L: linux-scsi@vger.kernel.org
7854L: target-devel@vger.kernel.org 7854L: target-devel@vger.kernel.org
7855L: http://groups.google.com/group/linux-iscsi-target-dev 7855L: http://groups.google.com/group/linux-iscsi-target-dev
7856W: http://www.linux-iscsi.org 7856W: http://www.linux-iscsi.org
7857T: git git://git.kernel.org/pub/scm/linux/kernel/git/nab/lio-core.git master 7857T: git git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending.git master
7858S: Supported 7858S: Supported
7859F: drivers/target/ 7859F: drivers/target/
7860F: include/target/ 7860F: include/target/
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index ffbc6a94be52..262ef1f23b38 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -1250,7 +1250,7 @@ static u32 iscsit_do_crypto_hash_sg(
1250 1250
1251static void iscsit_do_crypto_hash_buf( 1251static void iscsit_do_crypto_hash_buf(
1252 struct hash_desc *hash, 1252 struct hash_desc *hash,
1253 unsigned char *buf, 1253 const void *buf,
1254 u32 payload_length, 1254 u32 payload_length,
1255 u32 padding, 1255 u32 padding,
1256 u8 *pad_bytes, 1256 u8 *pad_bytes,
@@ -2524,9 +2524,8 @@ static int iscsit_send_conn_drop_async_message(
2524 if (conn->conn_ops->HeaderDigest) { 2524 if (conn->conn_ops->HeaderDigest) {
2525 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 2525 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN];
2526 2526
2527 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 2527 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr,
2528 (unsigned char *)hdr, ISCSI_HDR_LEN, 2528 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest);
2529 0, NULL, (u8 *)header_digest);
2530 2529
2531 cmd->tx_size += ISCSI_CRC_LEN; 2530 cmd->tx_size += ISCSI_CRC_LEN;
2532 pr_debug("Attaching CRC32C HeaderDigest to" 2531 pr_debug("Attaching CRC32C HeaderDigest to"
@@ -2662,9 +2661,8 @@ static int iscsit_send_datain(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
2662 if (conn->conn_ops->HeaderDigest) { 2661 if (conn->conn_ops->HeaderDigest) {
2663 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 2662 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN];
2664 2663
2665 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 2664 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, cmd->pdu,
2666 (unsigned char *)cmd->pdu, ISCSI_HDR_LEN, 2665 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest);
2667 0, NULL, (u8 *)header_digest);
2668 2666
2669 iov[0].iov_len += ISCSI_CRC_LEN; 2667 iov[0].iov_len += ISCSI_CRC_LEN;
2670 tx_size += ISCSI_CRC_LEN; 2668 tx_size += ISCSI_CRC_LEN;
@@ -2841,9 +2839,8 @@ iscsit_send_logout(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
2841 if (conn->conn_ops->HeaderDigest) { 2839 if (conn->conn_ops->HeaderDigest) {
2842 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 2840 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN];
2843 2841
2844 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 2842 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, &cmd->pdu[0],
2845 (unsigned char *)&cmd->pdu[0], ISCSI_HDR_LEN, 2843 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest);
2846 0, NULL, (u8 *)header_digest);
2847 2844
2848 iov[0].iov_len += ISCSI_CRC_LEN; 2845 iov[0].iov_len += ISCSI_CRC_LEN;
2849 tx_size += ISCSI_CRC_LEN; 2846 tx_size += ISCSI_CRC_LEN;
@@ -2900,9 +2897,8 @@ static int iscsit_send_unsolicited_nopin(
2900 if (conn->conn_ops->HeaderDigest) { 2897 if (conn->conn_ops->HeaderDigest) {
2901 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 2898 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN];
2902 2899
2903 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 2900 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr,
2904 (unsigned char *)hdr, ISCSI_HDR_LEN, 2901 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest);
2905 0, NULL, (u8 *)header_digest);
2906 2902
2907 tx_size += ISCSI_CRC_LEN; 2903 tx_size += ISCSI_CRC_LEN;
2908 pr_debug("Attaching CRC32C HeaderDigest to" 2904 pr_debug("Attaching CRC32C HeaderDigest to"
@@ -2949,9 +2945,8 @@ iscsit_send_nopin(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
2949 if (conn->conn_ops->HeaderDigest) { 2945 if (conn->conn_ops->HeaderDigest) {
2950 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 2946 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN];
2951 2947
2952 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 2948 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr,
2953 (unsigned char *)hdr, ISCSI_HDR_LEN, 2949 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest);
2954 0, NULL, (u8 *)header_digest);
2955 2950
2956 iov[0].iov_len += ISCSI_CRC_LEN; 2951 iov[0].iov_len += ISCSI_CRC_LEN;
2957 tx_size += ISCSI_CRC_LEN; 2952 tx_size += ISCSI_CRC_LEN;
@@ -3040,9 +3035,8 @@ static int iscsit_send_r2t(
3040 if (conn->conn_ops->HeaderDigest) { 3035 if (conn->conn_ops->HeaderDigest) {
3041 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 3036 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN];
3042 3037
3043 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 3038 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr,
3044 (unsigned char *)hdr, ISCSI_HDR_LEN, 3039 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest);
3045 0, NULL, (u8 *)header_digest);
3046 3040
3047 cmd->iov_misc[0].iov_len += ISCSI_CRC_LEN; 3041 cmd->iov_misc[0].iov_len += ISCSI_CRC_LEN;
3048 tx_size += ISCSI_CRC_LEN; 3042 tx_size += ISCSI_CRC_LEN;
@@ -3256,9 +3250,8 @@ static int iscsit_send_response(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
3256 if (conn->conn_ops->HeaderDigest) { 3250 if (conn->conn_ops->HeaderDigest) {
3257 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 3251 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN];
3258 3252
3259 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 3253 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, cmd->pdu,
3260 (unsigned char *)cmd->pdu, ISCSI_HDR_LEN, 3254 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest);
3261 0, NULL, (u8 *)header_digest);
3262 3255
3263 iov[0].iov_len += ISCSI_CRC_LEN; 3256 iov[0].iov_len += ISCSI_CRC_LEN;
3264 tx_size += ISCSI_CRC_LEN; 3257 tx_size += ISCSI_CRC_LEN;
@@ -3329,9 +3322,8 @@ iscsit_send_task_mgt_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
3329 if (conn->conn_ops->HeaderDigest) { 3322 if (conn->conn_ops->HeaderDigest) {
3330 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 3323 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN];
3331 3324
3332 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 3325 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr,
3333 (unsigned char *)hdr, ISCSI_HDR_LEN, 3326 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest);
3334 0, NULL, (u8 *)header_digest);
3335 3327
3336 cmd->iov_misc[0].iov_len += ISCSI_CRC_LEN; 3328 cmd->iov_misc[0].iov_len += ISCSI_CRC_LEN;
3337 tx_size += ISCSI_CRC_LEN; 3329 tx_size += ISCSI_CRC_LEN;
@@ -3504,9 +3496,8 @@ static int iscsit_send_text_rsp(
3504 if (conn->conn_ops->HeaderDigest) { 3496 if (conn->conn_ops->HeaderDigest) {
3505 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 3497 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN];
3506 3498
3507 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 3499 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr,
3508 (unsigned char *)hdr, ISCSI_HDR_LEN, 3500 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest);
3509 0, NULL, (u8 *)header_digest);
3510 3501
3511 iov[0].iov_len += ISCSI_CRC_LEN; 3502 iov[0].iov_len += ISCSI_CRC_LEN;
3512 tx_size += ISCSI_CRC_LEN; 3503 tx_size += ISCSI_CRC_LEN;
@@ -3557,11 +3548,11 @@ static int iscsit_send_reject(
3557 struct iscsi_cmd *cmd, 3548 struct iscsi_cmd *cmd,
3558 struct iscsi_conn *conn) 3549 struct iscsi_conn *conn)
3559{ 3550{
3560 u32 iov_count = 0, tx_size = 0; 3551 struct iscsi_reject *hdr = (struct iscsi_reject *)&cmd->pdu[0];
3561 struct iscsi_reject *hdr;
3562 struct kvec *iov; 3552 struct kvec *iov;
3553 u32 iov_count = 0, tx_size;
3563 3554
3564 iscsit_build_reject(cmd, conn, (struct iscsi_reject *)&cmd->pdu[0]); 3555 iscsit_build_reject(cmd, conn, hdr);
3565 3556
3566 iov = &cmd->iov_misc[0]; 3557 iov = &cmd->iov_misc[0];
3567 iov[iov_count].iov_base = cmd->pdu; 3558 iov[iov_count].iov_base = cmd->pdu;
@@ -3574,9 +3565,8 @@ static int iscsit_send_reject(
3574 if (conn->conn_ops->HeaderDigest) { 3565 if (conn->conn_ops->HeaderDigest) {
3575 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 3566 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN];
3576 3567
3577 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 3568 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr,
3578 (unsigned char *)hdr, ISCSI_HDR_LEN, 3569 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest);
3579 0, NULL, (u8 *)header_digest);
3580 3570
3581 iov[0].iov_len += ISCSI_CRC_LEN; 3571 iov[0].iov_len += ISCSI_CRC_LEN;
3582 tx_size += ISCSI_CRC_LEN; 3572 tx_size += ISCSI_CRC_LEN;
@@ -3585,9 +3575,8 @@ static int iscsit_send_reject(
3585 } 3575 }
3586 3576
3587 if (conn->conn_ops->DataDigest) { 3577 if (conn->conn_ops->DataDigest) {
3588 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 3578 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, cmd->buf_ptr,
3589 (unsigned char *)cmd->buf_ptr, ISCSI_HDR_LEN, 3579 ISCSI_HDR_LEN, 0, NULL, (u8 *)&cmd->data_crc);
3590 0, NULL, (u8 *)&cmd->data_crc);
3591 3580
3592 iov[iov_count].iov_base = &cmd->data_crc; 3581 iov[iov_count].iov_base = &cmd->data_crc;
3593 iov[iov_count++].iov_len = ISCSI_CRC_LEN; 3582 iov[iov_count++].iov_len = ISCSI_CRC_LEN;
diff --git a/drivers/target/iscsi/iscsi_target_erl1.c b/drivers/target/iscsi/iscsi_target_erl1.c
index 7816af6cdd12..40d9dbca987b 100644
--- a/drivers/target/iscsi/iscsi_target_erl1.c
+++ b/drivers/target/iscsi/iscsi_target_erl1.c
@@ -823,7 +823,7 @@ static int iscsit_attach_ooo_cmdsn(
823 /* 823 /*
824 * CmdSN is greater than the tail of the list. 824 * CmdSN is greater than the tail of the list.
825 */ 825 */
826 if (ooo_tail->cmdsn < ooo_cmdsn->cmdsn) 826 if (iscsi_sna_lt(ooo_tail->cmdsn, ooo_cmdsn->cmdsn))
827 list_add_tail(&ooo_cmdsn->ooo_list, 827 list_add_tail(&ooo_cmdsn->ooo_list,
828 &sess->sess_ooo_cmdsn_list); 828 &sess->sess_ooo_cmdsn_list);
829 else { 829 else {
@@ -833,11 +833,12 @@ static int iscsit_attach_ooo_cmdsn(
833 */ 833 */
834 list_for_each_entry(ooo_tmp, &sess->sess_ooo_cmdsn_list, 834 list_for_each_entry(ooo_tmp, &sess->sess_ooo_cmdsn_list,
835 ooo_list) { 835 ooo_list) {
836 if (ooo_tmp->cmdsn < ooo_cmdsn->cmdsn) 836 if (iscsi_sna_lt(ooo_tmp->cmdsn, ooo_cmdsn->cmdsn))
837 continue; 837 continue;
838 838
839 /* Insert before this entry */
839 list_add(&ooo_cmdsn->ooo_list, 840 list_add(&ooo_cmdsn->ooo_list,
840 &ooo_tmp->ooo_list); 841 ooo_tmp->ooo_list.prev);
841 break; 842 break;
842 } 843 }
843 } 844 }
diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c
index f690be9e5293..c2185fc31136 100644
--- a/drivers/target/iscsi/iscsi_target_parameters.c
+++ b/drivers/target/iscsi/iscsi_target_parameters.c
@@ -436,7 +436,7 @@ int iscsi_create_default_params(struct iscsi_param_list **param_list_ptr)
436 /* 436 /*
437 * Extra parameters for ISER from RFC-5046 437 * Extra parameters for ISER from RFC-5046
438 */ 438 */
439 param = iscsi_set_default_param(pl, RDMAEXTENTIONS, INITIAL_RDMAEXTENTIONS, 439 param = iscsi_set_default_param(pl, RDMAEXTENSIONS, INITIAL_RDMAEXTENSIONS,
440 PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH, 440 PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
441 TYPERANGE_BOOL_AND, USE_LEADING_ONLY); 441 TYPERANGE_BOOL_AND, USE_LEADING_ONLY);
442 if (!param) 442 if (!param)
@@ -529,7 +529,7 @@ int iscsi_set_keys_to_negotiate(
529 SET_PSTATE_NEGOTIATE(param); 529 SET_PSTATE_NEGOTIATE(param);
530 } else if (!strcmp(param->name, OFMARKINT)) { 530 } else if (!strcmp(param->name, OFMARKINT)) {
531 SET_PSTATE_NEGOTIATE(param); 531 SET_PSTATE_NEGOTIATE(param);
532 } else if (!strcmp(param->name, RDMAEXTENTIONS)) { 532 } else if (!strcmp(param->name, RDMAEXTENSIONS)) {
533 if (iser == true) 533 if (iser == true)
534 SET_PSTATE_NEGOTIATE(param); 534 SET_PSTATE_NEGOTIATE(param);
535 } else if (!strcmp(param->name, INITIATORRECVDATASEGMENTLENGTH)) { 535 } else if (!strcmp(param->name, INITIATORRECVDATASEGMENTLENGTH)) {
@@ -580,7 +580,7 @@ int iscsi_set_keys_irrelevant_for_discovery(
580 param->state &= ~PSTATE_NEGOTIATE; 580 param->state &= ~PSTATE_NEGOTIATE;
581 else if (!strcmp(param->name, OFMARKINT)) 581 else if (!strcmp(param->name, OFMARKINT))
582 param->state &= ~PSTATE_NEGOTIATE; 582 param->state &= ~PSTATE_NEGOTIATE;
583 else if (!strcmp(param->name, RDMAEXTENTIONS)) 583 else if (!strcmp(param->name, RDMAEXTENSIONS))
584 param->state &= ~PSTATE_NEGOTIATE; 584 param->state &= ~PSTATE_NEGOTIATE;
585 else if (!strcmp(param->name, INITIATORRECVDATASEGMENTLENGTH)) 585 else if (!strcmp(param->name, INITIATORRECVDATASEGMENTLENGTH))
586 param->state &= ~PSTATE_NEGOTIATE; 586 param->state &= ~PSTATE_NEGOTIATE;
@@ -1977,7 +1977,7 @@ void iscsi_set_session_parameters(
1977 ops->SessionType = !strcmp(param->value, DISCOVERY); 1977 ops->SessionType = !strcmp(param->value, DISCOVERY);
1978 pr_debug("SessionType: %s\n", 1978 pr_debug("SessionType: %s\n",
1979 param->value); 1979 param->value);
1980 } else if (!strcmp(param->name, RDMAEXTENTIONS)) { 1980 } else if (!strcmp(param->name, RDMAEXTENSIONS)) {
1981 ops->RDMAExtensions = !strcmp(param->value, YES); 1981 ops->RDMAExtensions = !strcmp(param->value, YES);
1982 pr_debug("RDMAExtensions: %s\n", 1982 pr_debug("RDMAExtensions: %s\n",
1983 param->value); 1983 param->value);
diff --git a/drivers/target/iscsi/iscsi_target_parameters.h b/drivers/target/iscsi/iscsi_target_parameters.h
index f31b9c4b83f2..915b06798505 100644
--- a/drivers/target/iscsi/iscsi_target_parameters.h
+++ b/drivers/target/iscsi/iscsi_target_parameters.h
@@ -91,7 +91,7 @@ extern void iscsi_set_session_parameters(struct iscsi_sess_ops *,
91/* 91/*
92 * Parameter names of iSCSI Extentions for RDMA (iSER). See RFC-5046 92 * Parameter names of iSCSI Extentions for RDMA (iSER). See RFC-5046
93 */ 93 */
94#define RDMAEXTENTIONS "RDMAExtensions" 94#define RDMAEXTENSIONS "RDMAExtensions"
95#define INITIATORRECVDATASEGMENTLENGTH "InitiatorRecvDataSegmentLength" 95#define INITIATORRECVDATASEGMENTLENGTH "InitiatorRecvDataSegmentLength"
96#define TARGETRECVDATASEGMENTLENGTH "TargetRecvDataSegmentLength" 96#define TARGETRECVDATASEGMENTLENGTH "TargetRecvDataSegmentLength"
97 97
@@ -142,7 +142,7 @@ extern void iscsi_set_session_parameters(struct iscsi_sess_ops *,
142/* 142/*
143 * Initial values for iSER parameters following RFC-5046 Section 6 143 * Initial values for iSER parameters following RFC-5046 Section 6
144 */ 144 */
145#define INITIAL_RDMAEXTENTIONS NO 145#define INITIAL_RDMAEXTENSIONS NO
146#define INITIAL_INITIATORRECVDATASEGMENTLENGTH "262144" 146#define INITIAL_INITIATORRECVDATASEGMENTLENGTH "262144"
147#define INITIAL_TARGETRECVDATASEGMENTLENGTH "8192" 147#define INITIAL_TARGETRECVDATASEGMENTLENGTH "8192"
148 148
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index 43b7ac6c5b1c..4a8bd36d3958 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -1584,6 +1584,13 @@ static struct target_core_configfs_attribute target_core_attr_dev_udev_path = {
1584 .store = target_core_store_dev_udev_path, 1584 .store = target_core_store_dev_udev_path,
1585}; 1585};
1586 1586
1587static ssize_t target_core_show_dev_enable(void *p, char *page)
1588{
1589 struct se_device *dev = p;
1590
1591 return snprintf(page, PAGE_SIZE, "%d\n", !!(dev->dev_flags & DF_CONFIGURED));
1592}
1593
1587static ssize_t target_core_store_dev_enable( 1594static ssize_t target_core_store_dev_enable(
1588 void *p, 1595 void *p,
1589 const char *page, 1596 const char *page,
@@ -1609,8 +1616,8 @@ static ssize_t target_core_store_dev_enable(
1609static struct target_core_configfs_attribute target_core_attr_dev_enable = { 1616static struct target_core_configfs_attribute target_core_attr_dev_enable = {
1610 .attr = { .ca_owner = THIS_MODULE, 1617 .attr = { .ca_owner = THIS_MODULE,
1611 .ca_name = "enable", 1618 .ca_name = "enable",
1612 .ca_mode = S_IWUSR }, 1619 .ca_mode = S_IRUGO | S_IWUSR },
1613 .show = NULL, 1620 .show = target_core_show_dev_enable,
1614 .store = target_core_store_dev_enable, 1621 .store = target_core_store_dev_enable,
1615}; 1622};
1616 1623
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index 2e4d655471bc..4630481b6043 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -68,7 +68,6 @@ transport_lookup_cmd_lun(struct se_cmd *se_cmd, u32 unpacked_lun)
68 struct se_dev_entry *deve = se_cmd->se_deve; 68 struct se_dev_entry *deve = se_cmd->se_deve;
69 69
70 deve->total_cmds++; 70 deve->total_cmds++;
71 deve->total_bytes += se_cmd->data_length;
72 71
73 if ((se_cmd->data_direction == DMA_TO_DEVICE) && 72 if ((se_cmd->data_direction == DMA_TO_DEVICE) &&
74 (deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY)) { 73 (deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY)) {
@@ -85,8 +84,6 @@ transport_lookup_cmd_lun(struct se_cmd *se_cmd, u32 unpacked_lun)
85 else if (se_cmd->data_direction == DMA_FROM_DEVICE) 84 else if (se_cmd->data_direction == DMA_FROM_DEVICE)
86 deve->read_bytes += se_cmd->data_length; 85 deve->read_bytes += se_cmd->data_length;
87 86
88 deve->deve_cmds++;
89
90 se_lun = deve->se_lun; 87 se_lun = deve->se_lun;
91 se_cmd->se_lun = deve->se_lun; 88 se_cmd->se_lun = deve->se_lun;
92 se_cmd->pr_res_key = deve->pr_res_key; 89 se_cmd->pr_res_key = deve->pr_res_key;
@@ -275,17 +272,6 @@ int core_free_device_list_for_node(
275 return 0; 272 return 0;
276} 273}
277 274
278void core_dec_lacl_count(struct se_node_acl *se_nacl, struct se_cmd *se_cmd)
279{
280 struct se_dev_entry *deve;
281 unsigned long flags;
282
283 spin_lock_irqsave(&se_nacl->device_list_lock, flags);
284 deve = se_nacl->device_list[se_cmd->orig_fe_lun];
285 deve->deve_cmds--;
286 spin_unlock_irqrestore(&se_nacl->device_list_lock, flags);
287}
288
289void core_update_device_list_access( 275void core_update_device_list_access(
290 u32 mapped_lun, 276 u32 mapped_lun,
291 u32 lun_access, 277 u32 lun_access,
diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
index 58ed683e04ae..1b1d544e927a 100644
--- a/drivers/target/target_core_file.c
+++ b/drivers/target/target_core_file.c
@@ -153,10 +153,6 @@ static int fd_configure_device(struct se_device *dev)
153 struct request_queue *q = bdev_get_queue(inode->i_bdev); 153 struct request_queue *q = bdev_get_queue(inode->i_bdev);
154 unsigned long long dev_size; 154 unsigned long long dev_size;
155 155
156 dev->dev_attrib.hw_block_size =
157 bdev_logical_block_size(inode->i_bdev);
158 dev->dev_attrib.hw_max_sectors = queue_max_hw_sectors(q);
159
160 /* 156 /*
161 * Determine the number of bytes from i_size_read() minus 157 * Determine the number of bytes from i_size_read() minus
162 * one (1) logical sector from underlying struct block_device 158 * one (1) logical sector from underlying struct block_device
@@ -203,9 +199,6 @@ static int fd_configure_device(struct se_device *dev)
203 goto fail; 199 goto fail;
204 } 200 }
205 201
206 dev->dev_attrib.hw_block_size = FD_BLOCKSIZE;
207 dev->dev_attrib.hw_max_sectors = FD_MAX_SECTORS;
208
209 /* 202 /*
210 * Limit UNMAP emulation to 8k Number of LBAs (NoLB) 203 * Limit UNMAP emulation to 8k Number of LBAs (NoLB)
211 */ 204 */
@@ -226,6 +219,8 @@ static int fd_configure_device(struct se_device *dev)
226 219
227 fd_dev->fd_block_size = dev->dev_attrib.hw_block_size; 220 fd_dev->fd_block_size = dev->dev_attrib.hw_block_size;
228 221
222 dev->dev_attrib.hw_block_size = FD_BLOCKSIZE;
223 dev->dev_attrib.hw_max_sectors = FD_MAX_SECTORS;
229 dev->dev_attrib.hw_queue_depth = FD_MAX_DEVICE_QUEUE_DEPTH; 224 dev->dev_attrib.hw_queue_depth = FD_MAX_DEVICE_QUEUE_DEPTH;
230 225
231 if (fd_dev->fbd_flags & FDBD_HAS_BUFFERED_IO_WCE) { 226 if (fd_dev->fbd_flags & FDBD_HAS_BUFFERED_IO_WCE) {
diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
index 07f5f94634bb..aa1620abec6d 100644
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -615,6 +615,8 @@ iblock_execute_rw(struct se_cmd *cmd)
615 rw = WRITE_FUA; 615 rw = WRITE_FUA;
616 else if (!(q->flush_flags & REQ_FLUSH)) 616 else if (!(q->flush_flags & REQ_FLUSH))
617 rw = WRITE_FUA; 617 rw = WRITE_FUA;
618 else
619 rw = WRITE;
618 } else { 620 } else {
619 rw = WRITE; 621 rw = WRITE;
620 } 622 }
diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h
index 853bab60e362..18d49df4d0ac 100644
--- a/drivers/target/target_core_internal.h
+++ b/drivers/target/target_core_internal.h
@@ -8,7 +8,6 @@ extern struct t10_alua_lu_gp *default_lu_gp;
8struct se_dev_entry *core_get_se_deve_from_rtpi(struct se_node_acl *, u16); 8struct se_dev_entry *core_get_se_deve_from_rtpi(struct se_node_acl *, u16);
9int core_free_device_list_for_node(struct se_node_acl *, 9int core_free_device_list_for_node(struct se_node_acl *,
10 struct se_portal_group *); 10 struct se_portal_group *);
11void core_dec_lacl_count(struct se_node_acl *, struct se_cmd *);
12void core_update_device_list_access(u32, u32, struct se_node_acl *); 11void core_update_device_list_access(u32, u32, struct se_node_acl *);
13int core_enable_device_list_for_node(struct se_lun *, struct se_lun_acl *, 12int core_enable_device_list_for_node(struct se_lun *, struct se_lun_acl *,
14 u32, u32, struct se_node_acl *, struct se_portal_group *); 13 u32, u32, struct se_node_acl *, struct se_portal_group *);
diff --git a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c
index e0b3c379aa14..0921a64b5550 100644
--- a/drivers/target/target_core_rd.c
+++ b/drivers/target/target_core_rd.c
@@ -291,6 +291,11 @@ rd_execute_rw(struct se_cmd *cmd)
291 u32 src_len; 291 u32 src_len;
292 u64 tmp; 292 u64 tmp;
293 293
294 if (dev->rd_flags & RDF_NULLIO) {
295 target_complete_cmd(cmd, SAM_STAT_GOOD);
296 return 0;
297 }
298
294 tmp = cmd->t_task_lba * se_dev->dev_attrib.block_size; 299 tmp = cmd->t_task_lba * se_dev->dev_attrib.block_size;
295 rd_offset = do_div(tmp, PAGE_SIZE); 300 rd_offset = do_div(tmp, PAGE_SIZE);
296 rd_page = tmp; 301 rd_page = tmp;
@@ -373,11 +378,12 @@ rd_execute_rw(struct se_cmd *cmd)
373} 378}
374 379
375enum { 380enum {
376 Opt_rd_pages, Opt_err 381 Opt_rd_pages, Opt_rd_nullio, Opt_err
377}; 382};
378 383
379static match_table_t tokens = { 384static match_table_t tokens = {
380 {Opt_rd_pages, "rd_pages=%d"}, 385 {Opt_rd_pages, "rd_pages=%d"},
386 {Opt_rd_nullio, "rd_nullio=%d"},
381 {Opt_err, NULL} 387 {Opt_err, NULL}
382}; 388};
383 389
@@ -408,6 +414,14 @@ static ssize_t rd_set_configfs_dev_params(struct se_device *dev,
408 " Count: %u\n", rd_dev->rd_page_count); 414 " Count: %u\n", rd_dev->rd_page_count);
409 rd_dev->rd_flags |= RDF_HAS_PAGE_COUNT; 415 rd_dev->rd_flags |= RDF_HAS_PAGE_COUNT;
410 break; 416 break;
417 case Opt_rd_nullio:
418 match_int(args, &arg);
419 if (arg != 1)
420 break;
421
422 pr_debug("RAMDISK: Setting NULLIO flag: %d\n", arg);
423 rd_dev->rd_flags |= RDF_NULLIO;
424 break;
411 default: 425 default:
412 break; 426 break;
413 } 427 }
@@ -424,8 +438,9 @@ static ssize_t rd_show_configfs_dev_params(struct se_device *dev, char *b)
424 ssize_t bl = sprintf(b, "TCM RamDisk ID: %u RamDisk Makeup: rd_mcp\n", 438 ssize_t bl = sprintf(b, "TCM RamDisk ID: %u RamDisk Makeup: rd_mcp\n",
425 rd_dev->rd_dev_id); 439 rd_dev->rd_dev_id);
426 bl += sprintf(b + bl, " PAGES/PAGE_SIZE: %u*%lu" 440 bl += sprintf(b + bl, " PAGES/PAGE_SIZE: %u*%lu"
427 " SG_table_count: %u\n", rd_dev->rd_page_count, 441 " SG_table_count: %u nullio: %d\n", rd_dev->rd_page_count,
428 PAGE_SIZE, rd_dev->sg_table_count); 442 PAGE_SIZE, rd_dev->sg_table_count,
443 !!(rd_dev->rd_flags & RDF_NULLIO));
429 return bl; 444 return bl;
430} 445}
431 446
diff --git a/drivers/target/target_core_rd.h b/drivers/target/target_core_rd.h
index 933b38b6e563..1789d1e14395 100644
--- a/drivers/target/target_core_rd.h
+++ b/drivers/target/target_core_rd.h
@@ -22,6 +22,7 @@ struct rd_dev_sg_table {
22} ____cacheline_aligned; 22} ____cacheline_aligned;
23 23
24#define RDF_HAS_PAGE_COUNT 0x01 24#define RDF_HAS_PAGE_COUNT 0x01
25#define RDF_NULLIO 0x02
25 26
26struct rd_dev { 27struct rd_dev {
27 struct se_device dev; 28 struct se_device dev;
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index f8388b4024aa..4a793362309d 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -2163,8 +2163,6 @@ void transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks)
2163 if (wait_for_tasks) 2163 if (wait_for_tasks)
2164 transport_wait_for_tasks(cmd); 2164 transport_wait_for_tasks(cmd);
2165 2165
2166 core_dec_lacl_count(cmd->se_sess->se_node_acl, cmd);
2167
2168 if (cmd->se_lun) 2166 if (cmd->se_lun)
2169 transport_lun_remove_cmd(cmd); 2167 transport_lun_remove_cmd(cmd);
2170 2168
@@ -2213,21 +2211,19 @@ static void target_release_cmd_kref(struct kref *kref)
2213{ 2211{
2214 struct se_cmd *se_cmd = container_of(kref, struct se_cmd, cmd_kref); 2212 struct se_cmd *se_cmd = container_of(kref, struct se_cmd, cmd_kref);
2215 struct se_session *se_sess = se_cmd->se_sess; 2213 struct se_session *se_sess = se_cmd->se_sess;
2216 unsigned long flags;
2217 2214
2218 spin_lock_irqsave(&se_sess->sess_cmd_lock, flags);
2219 if (list_empty(&se_cmd->se_cmd_list)) { 2215 if (list_empty(&se_cmd->se_cmd_list)) {
2220 spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); 2216 spin_unlock(&se_sess->sess_cmd_lock);
2221 se_cmd->se_tfo->release_cmd(se_cmd); 2217 se_cmd->se_tfo->release_cmd(se_cmd);
2222 return; 2218 return;
2223 } 2219 }
2224 if (se_sess->sess_tearing_down && se_cmd->cmd_wait_set) { 2220 if (se_sess->sess_tearing_down && se_cmd->cmd_wait_set) {
2225 spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); 2221 spin_unlock(&se_sess->sess_cmd_lock);
2226 complete(&se_cmd->cmd_wait_comp); 2222 complete(&se_cmd->cmd_wait_comp);
2227 return; 2223 return;
2228 } 2224 }
2229 list_del(&se_cmd->se_cmd_list); 2225 list_del(&se_cmd->se_cmd_list);
2230 spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); 2226 spin_unlock(&se_sess->sess_cmd_lock);
2231 2227
2232 se_cmd->se_tfo->release_cmd(se_cmd); 2228 se_cmd->se_tfo->release_cmd(se_cmd);
2233} 2229}
@@ -2238,7 +2234,8 @@ static void target_release_cmd_kref(struct kref *kref)
2238 */ 2234 */
2239int target_put_sess_cmd(struct se_session *se_sess, struct se_cmd *se_cmd) 2235int target_put_sess_cmd(struct se_session *se_sess, struct se_cmd *se_cmd)
2240{ 2236{
2241 return kref_put(&se_cmd->cmd_kref, target_release_cmd_kref); 2237 return kref_put_spinlock_irqsave(&se_cmd->cmd_kref, target_release_cmd_kref,
2238 &se_sess->sess_cmd_lock);
2242} 2239}
2243EXPORT_SYMBOL(target_put_sess_cmd); 2240EXPORT_SYMBOL(target_put_sess_cmd);
2244 2241
diff --git a/include/linux/kref.h b/include/linux/kref.h
index e15828fd71f1..484604d184be 100644
--- a/include/linux/kref.h
+++ b/include/linux/kref.h
@@ -19,6 +19,7 @@
19#include <linux/atomic.h> 19#include <linux/atomic.h>
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/mutex.h> 21#include <linux/mutex.h>
22#include <linux/spinlock.h>
22 23
23struct kref { 24struct kref {
24 atomic_t refcount; 25 atomic_t refcount;
@@ -98,6 +99,38 @@ static inline int kref_put(struct kref *kref, void (*release)(struct kref *kref)
98 return kref_sub(kref, 1, release); 99 return kref_sub(kref, 1, release);
99} 100}
100 101
102/**
103 * kref_put_spinlock_irqsave - decrement refcount for object.
104 * @kref: object.
105 * @release: pointer to the function that will clean up the object when the
106 * last reference to the object is released.
107 * This pointer is required, and it is not acceptable to pass kfree
108 * in as this function.
109 * @lock: lock to take in release case
110 *
111 * Behaves identical to kref_put with one exception. If the reference count
112 * drops to zero, the lock will be taken atomically wrt dropping the reference
113 * count. The release function has to call spin_unlock() without _irqrestore.
114 */
115static inline int kref_put_spinlock_irqsave(struct kref *kref,
116 void (*release)(struct kref *kref),
117 spinlock_t *lock)
118{
119 unsigned long flags;
120
121 WARN_ON(release == NULL);
122 if (atomic_add_unless(&kref->refcount, -1, 1))
123 return 0;
124 spin_lock_irqsave(lock, flags);
125 if (atomic_dec_and_test(&kref->refcount)) {
126 release(kref);
127 local_irq_restore(flags);
128 return 1;
129 }
130 spin_unlock_irqrestore(lock, flags);
131 return 0;
132}
133
101static inline int kref_put_mutex(struct kref *kref, 134static inline int kref_put_mutex(struct kref *kref,
102 void (*release)(struct kref *kref), 135 void (*release)(struct kref *kref),
103 struct mutex *lock) 136 struct mutex *lock)
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index c4af592f7057..e773dfa5f98f 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -463,7 +463,6 @@ struct se_cmd {
463#define CMD_T_ABORTED (1 << 0) 463#define CMD_T_ABORTED (1 << 0)
464#define CMD_T_ACTIVE (1 << 1) 464#define CMD_T_ACTIVE (1 << 1)
465#define CMD_T_COMPLETE (1 << 2) 465#define CMD_T_COMPLETE (1 << 2)
466#define CMD_T_QUEUED (1 << 3)
467#define CMD_T_SENT (1 << 4) 466#define CMD_T_SENT (1 << 4)
468#define CMD_T_STOP (1 << 5) 467#define CMD_T_STOP (1 << 5)
469#define CMD_T_FAILED (1 << 6) 468#define CMD_T_FAILED (1 << 6)
@@ -572,12 +571,8 @@ struct se_dev_entry {
572 bool def_pr_registered; 571 bool def_pr_registered;
573 /* See transport_lunflags_table */ 572 /* See transport_lunflags_table */
574 u32 lun_flags; 573 u32 lun_flags;
575 u32 deve_cmds;
576 u32 mapped_lun; 574 u32 mapped_lun;
577 u32 average_bytes;
578 u32 last_byte_count;
579 u32 total_cmds; 575 u32 total_cmds;
580 u32 total_bytes;
581 u64 pr_res_key; 576 u64 pr_res_key;
582 u64 creation_time; 577 u64 creation_time;
583 u32 attach_count; 578 u32 attach_count;