Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+107 -87
+1 -1
MAINTAINERS
··· 7854 7854 L: target-devel@vger.kernel.org 7855 7855 L: http://groups.google.com/group/linux-iscsi-target-dev 7856 7856 W: http://www.linux-iscsi.org 7857 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/nab/lio-core.git master 7857 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending.git master 7858 7858 S: Supported 7859 7859 F: drivers/target/ 7860 7860 F: include/target/
+26 -37
drivers/target/iscsi/iscsi_target.c
··· 1250 1250 1251 1251 static void iscsit_do_crypto_hash_buf( 1252 1252 struct hash_desc *hash, 1253 - unsigned char *buf, 1253 + const void *buf, 1254 1254 u32 payload_length, 1255 1255 u32 padding, 1256 1256 u8 *pad_bytes, ··· 2524 2524 if (conn->conn_ops->HeaderDigest) { 2525 2525 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 2526 2526 2527 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 2528 - (unsigned char *)hdr, ISCSI_HDR_LEN, 2529 - 0, NULL, (u8 *)header_digest); 2527 + iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 2528 + ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 2530 2529 2531 2530 cmd->tx_size += ISCSI_CRC_LEN; 2532 2531 pr_debug("Attaching CRC32C HeaderDigest to" ··· 2661 2662 if (conn->conn_ops->HeaderDigest) { 2662 2663 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 2663 2664 2664 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 2665 - (unsigned char *)cmd->pdu, ISCSI_HDR_LEN, 2666 - 0, NULL, (u8 *)header_digest); 2665 + iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, cmd->pdu, 2666 + ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 2667 2667 2668 2668 iov[0].iov_len += ISCSI_CRC_LEN; 2669 2669 tx_size += ISCSI_CRC_LEN; ··· 2839 2841 if (conn->conn_ops->HeaderDigest) { 2840 2842 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 2841 2843 2842 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 2843 - (unsigned char *)&cmd->pdu[0], ISCSI_HDR_LEN, 2844 - 0, NULL, (u8 *)header_digest); 2844 + iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, &cmd->pdu[0], 2845 + ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 2845 2846 2846 2847 iov[0].iov_len += ISCSI_CRC_LEN; 2847 2848 tx_size += ISCSI_CRC_LEN; ··· 2897 2900 if (conn->conn_ops->HeaderDigest) { 2898 2901 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 2899 2902 2900 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 2901 - (unsigned char *)hdr, ISCSI_HDR_LEN, 2902 - 0, NULL, (u8 *)header_digest); 2903 + iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 2904 + ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 2903 2905 2904 2906 tx_size += ISCSI_CRC_LEN; 2905 2907 pr_debug("Attaching CRC32C HeaderDigest to" ··· 2945 2949 if (conn->conn_ops->HeaderDigest) { 2946 2950 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 2947 2951 2948 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 2949 - (unsigned char *)hdr, ISCSI_HDR_LEN, 2950 - 0, NULL, (u8 *)header_digest); 2952 + iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 2953 + ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 2951 2954 2952 2955 iov[0].iov_len += ISCSI_CRC_LEN; 2953 2956 tx_size += ISCSI_CRC_LEN; ··· 3035 3040 if (conn->conn_ops->HeaderDigest) { 3036 3041 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 3037 3042 3038 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 3039 - (unsigned char *)hdr, ISCSI_HDR_LEN, 3040 - 0, NULL, (u8 *)header_digest); 3043 + iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 3044 + ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 3041 3045 3042 3046 cmd->iov_misc[0].iov_len += ISCSI_CRC_LEN; 3043 3047 tx_size += ISCSI_CRC_LEN; ··· 3250 3256 if (conn->conn_ops->HeaderDigest) { 3251 3257 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 3252 3258 3253 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 3254 - (unsigned char *)cmd->pdu, ISCSI_HDR_LEN, 3255 - 0, NULL, (u8 *)header_digest); 3259 + iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, cmd->pdu, 3260 + ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 3256 3261 3257 3262 iov[0].iov_len += ISCSI_CRC_LEN; 3258 3263 tx_size += ISCSI_CRC_LEN; ··· 3322 3329 if (conn->conn_ops->HeaderDigest) { 3323 3330 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 3324 3331 3325 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 3326 - (unsigned char *)hdr, ISCSI_HDR_LEN, 3327 - 0, NULL, (u8 *)header_digest); 3332 + iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 3333 + ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 3328 3334 3329 3335 cmd->iov_misc[0].iov_len += ISCSI_CRC_LEN; 3330 3336 tx_size += ISCSI_CRC_LEN; ··· 3496 3504 if (conn->conn_ops->HeaderDigest) { 3497 3505 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 3498 3506 3499 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 3500 - (unsigned char *)hdr, ISCSI_HDR_LEN, 3501 - 0, NULL, (u8 *)header_digest); 3507 + iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 3508 + ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 3502 3509 3503 3510 iov[0].iov_len += ISCSI_CRC_LEN; 3504 3511 tx_size += ISCSI_CRC_LEN; ··· 3548 3557 struct iscsi_cmd *cmd, 3549 3558 struct iscsi_conn *conn) 3550 3559 { 3551 - u32 iov_count = 0, tx_size = 0; 3552 - struct iscsi_reject *hdr; 3560 + struct iscsi_reject *hdr = (struct iscsi_reject *)&cmd->pdu[0]; 3553 3561 struct kvec *iov; 3562 + u32 iov_count = 0, tx_size; 3554 3563 3555 - iscsit_build_reject(cmd, conn, (struct iscsi_reject *)&cmd->pdu[0]); 3564 + iscsit_build_reject(cmd, conn, hdr); 3556 3565 3557 3566 iov = &cmd->iov_misc[0]; 3558 3567 iov[iov_count].iov_base = cmd->pdu; ··· 3565 3574 if (conn->conn_ops->HeaderDigest) { 3566 3575 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 3567 3576 3568 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 3569 - (unsigned char *)hdr, ISCSI_HDR_LEN, 3570 - 0, NULL, (u8 *)header_digest); 3577 + iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 3578 + ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 3571 3579 3572 3580 iov[0].iov_len += ISCSI_CRC_LEN; 3573 3581 tx_size += ISCSI_CRC_LEN; ··· 3575 3585 } 3576 3586 3577 3587 if (conn->conn_ops->DataDigest) { 3578 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 3579 - (unsigned char *)cmd->buf_ptr, ISCSI_HDR_LEN, 3580 - 0, NULL, (u8 *)&cmd->data_crc); 3588 + iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, cmd->buf_ptr, 3589 + ISCSI_HDR_LEN, 0, NULL, (u8 *)&cmd->data_crc); 3581 3590 3582 3591 iov[iov_count].iov_base = &cmd->data_crc; 3583 3592 iov[iov_count++].iov_len = ISCSI_CRC_LEN;
+4 -3
drivers/target/iscsi/iscsi_target_erl1.c
··· 823 823 /* 824 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 827 list_add_tail(&ooo_cmdsn->ooo_list, 828 828 &sess->sess_ooo_cmdsn_list); 829 829 else { ··· 833 833 */ 834 834 list_for_each_entry(ooo_tmp, &sess->sess_ooo_cmdsn_list, 835 835 ooo_list) { 836 - if (ooo_tmp->cmdsn < ooo_cmdsn->cmdsn) 836 + if (iscsi_sna_lt(ooo_tmp->cmdsn, ooo_cmdsn->cmdsn)) 837 837 continue; 838 838 839 + /* Insert before this entry */ 839 840 list_add(&ooo_cmdsn->ooo_list, 840 - &ooo_tmp->ooo_list); 841 + ooo_tmp->ooo_list.prev); 841 842 break; 842 843 } 843 844 }
+4 -4
drivers/target/iscsi/iscsi_target_parameters.c
··· 436 436 /* 437 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 440 PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH, 441 441 TYPERANGE_BOOL_AND, USE_LEADING_ONLY); 442 442 if (!param) ··· 529 529 SET_PSTATE_NEGOTIATE(param); 530 530 } else if (!strcmp(param->name, OFMARKINT)) { 531 531 SET_PSTATE_NEGOTIATE(param); 532 - } else if (!strcmp(param->name, RDMAEXTENTIONS)) { 532 + } else if (!strcmp(param->name, RDMAEXTENSIONS)) { 533 533 if (iser == true) 534 534 SET_PSTATE_NEGOTIATE(param); 535 535 } else if (!strcmp(param->name, INITIATORRECVDATASEGMENTLENGTH)) { ··· 580 580 param->state &= ~PSTATE_NEGOTIATE; 581 581 else if (!strcmp(param->name, OFMARKINT)) 582 582 param->state &= ~PSTATE_NEGOTIATE; 583 - else if (!strcmp(param->name, RDMAEXTENTIONS)) 583 + else if (!strcmp(param->name, RDMAEXTENSIONS)) 584 584 param->state &= ~PSTATE_NEGOTIATE; 585 585 else if (!strcmp(param->name, INITIATORRECVDATASEGMENTLENGTH)) 586 586 param->state &= ~PSTATE_NEGOTIATE; ··· 1977 1977 ops->SessionType = !strcmp(param->value, DISCOVERY); 1978 1978 pr_debug("SessionType: %s\n", 1979 1979 param->value); 1980 - } else if (!strcmp(param->name, RDMAEXTENTIONS)) { 1980 + } else if (!strcmp(param->name, RDMAEXTENSIONS)) { 1981 1981 ops->RDMAExtensions = !strcmp(param->value, YES); 1982 1982 pr_debug("RDMAExtensions: %s\n", 1983 1983 param->value);
+2 -2
drivers/target/iscsi/iscsi_target_parameters.h
··· 91 91 /* 92 92 * Parameter names of iSCSI Extentions for RDMA (iSER). See RFC-5046 93 93 */ 94 - #define RDMAEXTENTIONS "RDMAExtensions" 94 + #define RDMAEXTENSIONS "RDMAExtensions" 95 95 #define INITIATORRECVDATASEGMENTLENGTH "InitiatorRecvDataSegmentLength" 96 96 #define TARGETRECVDATASEGMENTLENGTH "TargetRecvDataSegmentLength" 97 97 ··· 142 142 /* 143 143 * Initial values for iSER parameters following RFC-5046 Section 6 144 144 */ 145 - #define INITIAL_RDMAEXTENTIONS NO 145 + #define INITIAL_RDMAEXTENSIONS NO 146 146 #define INITIAL_INITIATORRECVDATASEGMENTLENGTH "262144" 147 147 #define INITIAL_TARGETRECVDATASEGMENTLENGTH "8192" 148 148
+9 -2
drivers/target/target_core_configfs.c
··· 1584 1584 .store = target_core_store_dev_udev_path, 1585 1585 }; 1586 1586 1587 + static 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 + 1587 1594 static ssize_t target_core_store_dev_enable( 1588 1595 void *p, 1589 1596 const char *page, ··· 1616 1609 static struct target_core_configfs_attribute target_core_attr_dev_enable = { 1617 1610 .attr = { .ca_owner = THIS_MODULE, 1618 1611 .ca_name = "enable", 1619 - .ca_mode = S_IWUSR }, 1620 - .show = NULL, 1612 + .ca_mode = S_IRUGO | S_IWUSR }, 1613 + .show = target_core_show_dev_enable, 1621 1614 .store = target_core_store_dev_enable, 1622 1615 }; 1623 1616
-14
drivers/target/target_core_device.c
··· 68 68 struct se_dev_entry *deve = se_cmd->se_deve; 69 69 70 70 deve->total_cmds++; 71 - deve->total_bytes += se_cmd->data_length; 72 71 73 72 if ((se_cmd->data_direction == DMA_TO_DEVICE) && 74 73 (deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY)) { ··· 83 84 deve->write_bytes += se_cmd->data_length; 84 85 else if (se_cmd->data_direction == DMA_FROM_DEVICE) 85 86 deve->read_bytes += se_cmd->data_length; 86 - 87 - deve->deve_cmds++; 88 87 89 88 se_lun = deve->se_lun; 90 89 se_cmd->se_lun = deve->se_lun; ··· 270 273 nacl->device_list = NULL; 271 274 272 275 return 0; 273 - } 274 - 275 - void core_dec_lacl_count(struct se_node_acl *se_nacl, struct se_cmd *se_cmd) 276 - { 277 - struct se_dev_entry *deve; 278 - unsigned long flags; 279 - 280 - spin_lock_irqsave(&se_nacl->device_list_lock, flags); 281 - deve = se_nacl->device_list[se_cmd->orig_fe_lun]; 282 - deve->deve_cmds--; 283 - spin_unlock_irqrestore(&se_nacl->device_list_lock, flags); 284 276 } 285 277 286 278 void core_update_device_list_access(
+2 -7
drivers/target/target_core_file.c
··· 153 153 struct request_queue *q = bdev_get_queue(inode->i_bdev); 154 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 157 * Determine the number of bytes from i_size_read() minus 162 158 * one (1) logical sector from underlying struct block_device ··· 199 203 goto fail; 200 204 } 201 205 202 - dev->dev_attrib.hw_block_size = FD_BLOCKSIZE; 203 - dev->dev_attrib.hw_max_sectors = FD_MAX_SECTORS; 204 - 205 206 /* 206 207 * Limit UNMAP emulation to 8k Number of LBAs (NoLB) 207 208 */ ··· 219 226 220 227 fd_dev->fd_block_size = dev->dev_attrib.hw_block_size; 221 228 229 + dev->dev_attrib.hw_block_size = FD_BLOCKSIZE; 230 + dev->dev_attrib.hw_max_sectors = FD_MAX_SECTORS; 222 231 dev->dev_attrib.hw_queue_depth = FD_MAX_DEVICE_QUEUE_DEPTH; 223 232 224 233 if (fd_dev->fbd_flags & FDBD_HAS_BUFFERED_IO_WCE) {
+2
drivers/target/target_core_iblock.c
··· 615 615 rw = WRITE_FUA; 616 616 else if (!(q->flush_flags & REQ_FLUSH)) 617 617 rw = WRITE_FUA; 618 + else 619 + rw = WRITE; 618 620 } else { 619 621 rw = WRITE; 620 622 }
-1
drivers/target/target_core_internal.h
··· 8 8 struct se_dev_entry *core_get_se_deve_from_rtpi(struct se_node_acl *, u16); 9 9 int core_free_device_list_for_node(struct se_node_acl *, 10 10 struct se_portal_group *); 11 - void core_dec_lacl_count(struct se_node_acl *, struct se_cmd *); 12 11 void core_update_device_list_access(u32, u32, struct se_node_acl *); 13 12 int core_enable_device_list_for_node(struct se_lun *, struct se_lun_acl *, 14 13 u32, u32, struct se_node_acl *, struct se_portal_group *);
+18 -3
drivers/target/target_core_rd.c
··· 291 291 u32 src_len; 292 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 299 tmp = cmd->t_task_lba * se_dev->dev_attrib.block_size; 295 300 rd_offset = do_div(tmp, PAGE_SIZE); 296 301 rd_page = tmp; ··· 378 373 } 379 374 380 375 enum { 381 - Opt_rd_pages, Opt_err 376 + Opt_rd_pages, Opt_rd_nullio, Opt_err 382 377 }; 383 378 384 379 static match_table_t tokens = { 385 380 {Opt_rd_pages, "rd_pages=%d"}, 381 + {Opt_rd_nullio, "rd_nullio=%d"}, 386 382 {Opt_err, NULL} 387 383 }; 388 384 ··· 414 408 " Count: %u\n", rd_dev->rd_page_count); 415 409 rd_dev->rd_flags |= RDF_HAS_PAGE_COUNT; 416 410 break; 411 + case Opt_rd_nullio: 412 + match_int(args, &arg); 413 + if (arg != 1) 414 + break; 415 + 416 + pr_debug("RAMDISK: Setting NULLIO flag: %d\n", arg); 417 + rd_dev->rd_flags |= RDF_NULLIO; 418 + break; 417 419 default: 418 420 break; 419 421 } ··· 438 424 ssize_t bl = sprintf(b, "TCM RamDisk ID: %u RamDisk Makeup: rd_mcp\n", 439 425 rd_dev->rd_dev_id); 440 426 bl += sprintf(b + bl, " PAGES/PAGE_SIZE: %u*%lu" 441 - " SG_table_count: %u\n", rd_dev->rd_page_count, 442 - PAGE_SIZE, rd_dev->sg_table_count); 427 + " SG_table_count: %u nullio: %d\n", rd_dev->rd_page_count, 428 + PAGE_SIZE, rd_dev->sg_table_count, 429 + !!(rd_dev->rd_flags & RDF_NULLIO)); 443 430 return bl; 444 431 } 445 432
+1
drivers/target/target_core_rd.h
··· 22 22 } ____cacheline_aligned; 23 23 24 24 #define RDF_HAS_PAGE_COUNT 0x01 25 + #define RDF_NULLIO 0x02 25 26 26 27 struct rd_dev { 27 28 struct se_device dev;
+5 -8
drivers/target/target_core_transport.c
··· 2163 2163 if (wait_for_tasks) 2164 2164 transport_wait_for_tasks(cmd); 2165 2165 2166 - core_dec_lacl_count(cmd->se_sess->se_node_acl, cmd); 2167 - 2168 2166 if (cmd->se_lun) 2169 2167 transport_lun_remove_cmd(cmd); 2170 2168 ··· 2211 2213 { 2212 2214 struct se_cmd *se_cmd = container_of(kref, struct se_cmd, cmd_kref); 2213 2215 struct se_session *se_sess = se_cmd->se_sess; 2214 - unsigned long flags; 2215 2216 2216 - spin_lock_irqsave(&se_sess->sess_cmd_lock, flags); 2217 2217 if (list_empty(&se_cmd->se_cmd_list)) { 2218 - spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); 2218 + spin_unlock(&se_sess->sess_cmd_lock); 2219 2219 se_cmd->se_tfo->release_cmd(se_cmd); 2220 2220 return; 2221 2221 } 2222 2222 if (se_sess->sess_tearing_down && se_cmd->cmd_wait_set) { 2223 - spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); 2223 + spin_unlock(&se_sess->sess_cmd_lock); 2224 2224 complete(&se_cmd->cmd_wait_comp); 2225 2225 return; 2226 2226 } 2227 2227 list_del(&se_cmd->se_cmd_list); 2228 - spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); 2228 + spin_unlock(&se_sess->sess_cmd_lock); 2229 2229 2230 2230 se_cmd->se_tfo->release_cmd(se_cmd); 2231 2231 } ··· 2234 2238 */ 2235 2239 int target_put_sess_cmd(struct se_session *se_sess, struct se_cmd *se_cmd) 2236 2240 { 2237 - return kref_put(&se_cmd->cmd_kref, target_release_cmd_kref); 2241 + return kref_put_spinlock_irqsave(&se_cmd->cmd_kref, target_release_cmd_kref, 2242 + &se_sess->sess_cmd_lock); 2238 2243 } 2239 2244 EXPORT_SYMBOL(target_put_sess_cmd); 2240 2245
+33
include/linux/kref.h
··· 19 19 #include <linux/atomic.h> 20 20 #include <linux/kernel.h> 21 21 #include <linux/mutex.h> 22 + #include <linux/spinlock.h> 22 23 23 24 struct kref { 24 25 atomic_t refcount; ··· 97 96 static inline int kref_put(struct kref *kref, void (*release)(struct kref *kref)) 98 97 { 99 98 return kref_sub(kref, 1, release); 99 + } 100 + 101 + /** 102 + * kref_put_spinlock_irqsave - decrement refcount for object. 103 + * @kref: object. 104 + * @release: pointer to the function that will clean up the object when the 105 + * last reference to the object is released. 106 + * This pointer is required, and it is not acceptable to pass kfree 107 + * in as this function. 108 + * @lock: lock to take in release case 109 + * 110 + * Behaves identical to kref_put with one exception. If the reference count 111 + * drops to zero, the lock will be taken atomically wrt dropping the reference 112 + * count. The release function has to call spin_unlock() without _irqrestore. 113 + */ 114 + static inline int kref_put_spinlock_irqsave(struct kref *kref, 115 + void (*release)(struct kref *kref), 116 + spinlock_t *lock) 117 + { 118 + unsigned long flags; 119 + 120 + WARN_ON(release == NULL); 121 + if (atomic_add_unless(&kref->refcount, -1, 1)) 122 + return 0; 123 + spin_lock_irqsave(lock, flags); 124 + if (atomic_dec_and_test(&kref->refcount)) { 125 + release(kref); 126 + local_irq_restore(flags); 127 + return 1; 128 + } 129 + spin_unlock_irqrestore(lock, flags); 130 + return 0; 100 131 } 101 132 102 133 static inline int kref_put_mutex(struct kref *kref,
-5
include/target/target_core_base.h
··· 463 463 #define CMD_T_ABORTED (1 << 0) 464 464 #define CMD_T_ACTIVE (1 << 1) 465 465 #define CMD_T_COMPLETE (1 << 2) 466 - #define CMD_T_QUEUED (1 << 3) 467 466 #define CMD_T_SENT (1 << 4) 468 467 #define CMD_T_STOP (1 << 5) 469 468 #define CMD_T_FAILED (1 << 6) ··· 571 572 bool def_pr_registered; 572 573 /* See transport_lunflags_table */ 573 574 u32 lun_flags; 574 - u32 deve_cmds; 575 575 u32 mapped_lun; 576 - u32 average_bytes; 577 - u32 last_byte_count; 578 576 u32 total_cmds; 579 - u32 total_bytes; 580 577 u64 pr_res_key; 581 578 u64 creation_time; 582 579 u32 attach_count;