~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to drivers/target/target_core_transport.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno
  • Date: 2011-06-07 12:14:05 UTC
  • mfrom: (43.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20110607121405-i3h1rd7nrnd2b73h
Tags: 2.6.39-2
[ Ben Hutchings ]
* [x86] Enable BACKLIGHT_APPLE, replacing BACKLIGHT_MBP_NVIDIA
  (Closes: #627492)
* cgroups: Disable memory resource controller by default. Allow it
  to be enabled using kernel parameter 'cgroup_enable=memory'.
* rt2800usb: Enable support for more USB devices including
  Linksys WUSB600N (Closes: #596626) (this change was accidentally
  omitted from 2.6.39-1)
* [x86] Remove Celeron from list of processors supporting PAE. Most
  'Celeron M' models do not.
* Update debconf template translations:
  - Swedish (Martin Bagge) (Closes: #628932)
  - French (David Prévot) (Closes: #628191)
* aufs: Update for 2.6.39 (Closes: #627837)
* Add stable 2.6.39.1, including:
  - ext4: dont set PageUptodate in ext4_end_bio()
  - pata_cmd64x: fix boot crash on parisc (Closes: #622997, #622745)
  - ext3: Fix fs corruption when make_indexed_dir() fails
  - netfilter: nf_ct_sip: validate Content-Length in TCP SIP messages
  - sctp: fix race between sctp_bind_addr_free() and
    sctp_bind_addr_conflict()
  - sctp: fix memory leak of the ASCONF queue when free asoc
  - md/bitmap: fix saving of events_cleared and other state
  - cdc_acm: Fix oops when Droids MuIn LCD is connected
  - cx88: Fix conversion from BKL to fine-grained locks (Closes: #619827)
  - keys: Set cred->user_ns in key_replace_session_keyring (CVE-2011-2184)
  - tmpfs: fix race between truncate and writepage
  - nfs41: Correct offset for LAYOUTCOMMIT
  - xen/mmu: fix a race window causing leave_mm BUG()
  - ext4: fix possible use-after-free in ext4_remove_li_request()
  For the complete list of changes, see:
   http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.39.1
* Bump ABI to 2
* netfilter: Enable IP_SET, IP_SET_BITMAP_IP, IP_SET_BITMAP_IPMAC,
  IP_SET_BITMAP_PORT, IP_SET_HASH_IP, IP_SET_HASH_IPPORT,
  IP_SET_HASH_IPPORTIP, IP_SET_HASH_IPPORTNET, IP_SET_HASH_NET,
  IP_SET_HASH_NETPORT, IP_SET_LIST_SET, NETFILTER_XT_SET as modules
  (Closes: #629401)

[ Aurelien Jarno ]
* [mipsel/loongson-2f] Disable_SCSI_LPFC to workaround GCC ICE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#include <linux/slab.h>
35
35
#include <linux/blkdev.h>
36
36
#include <linux/spinlock.h>
37
 
#include <linux/smp_lock.h>
38
37
#include <linux/kthread.h>
39
38
#include <linux/in.h>
40
39
#include <linux/cdrom.h>
228
227
static int transport_set_sense_codes(struct se_cmd *cmd, u8 asc, u8 ascq);
229
228
static void transport_stop_all_task_timers(struct se_cmd *cmd);
230
229
 
231
 
int transport_emulate_control_cdb(struct se_task *task);
232
 
 
233
230
int init_se_global(void)
234
231
{
235
232
        struct se_global *global;
722
719
                        cmd->se_lun = NULL;
723
720
                        /*
724
721
                         * Some fabric modules like tcm_loop can release
725
 
                         * their internally allocated I/O refrence now and
 
722
                         * their internally allocated I/O reference now and
726
723
                         * struct se_cmd now.
727
724
                         */
728
725
                        if (CMD_TFO(cmd)->check_stop_free != NULL) {
1623
1620
        const char *inquiry_prod,
1624
1621
        const char *inquiry_rev)
1625
1622
{
1626
 
        int ret = 0, force_pt;
 
1623
        int force_pt;
1627
1624
        struct se_device  *dev;
1628
1625
 
1629
1626
        dev = kzalloc(sizeof(struct se_device), GFP_KERNEL);
1740
1737
        }
1741
1738
        scsi_dump_inquiry(dev);
1742
1739
 
 
1740
        return dev;
1743
1741
out:
1744
 
        if (!ret)
1745
 
                return dev;
1746
1742
        kthread_stop(dev->process_thread);
1747
1743
 
1748
1744
        spin_lock(&hba->device_lock);
2033
2029
         * If the received CDB has aleady been ABORTED by the generic
2034
2030
         * target engine, we now call transport_check_aborted_status()
2035
2031
         * to queue any delated TASK_ABORTED status for the received CDB to the
2036
 
         * fabric module as we are expecting no futher incoming DATA OUT
 
2032
         * fabric module as we are expecting no further incoming DATA OUT
2037
2033
         * sequences at this point.
2038
2034
         */
2039
2035
        if (transport_check_aborted_status(cmd, 1) != 0)
2505
2501
        if (SE_DEV(cmd)->dev_task_attr_type != SAM_TASK_ATTR_EMULATED)
2506
2502
                return 1;
2507
2503
        /*
2508
 
         * Check for the existance of HEAD_OF_QUEUE, and if true return 1
 
2504
         * Check for the existence of HEAD_OF_QUEUE, and if true return 1
2509
2505
         * to allow the passed struct se_cmd list of tasks to the front of the list.
2510
2506
         */
2511
2507
         if (cmd->sam_task_attr == TASK_ATTR_HOQ) {
2551
2547
        if (atomic_read(&SE_DEV(cmd)->dev_ordered_sync) != 0) {
2552
2548
                /*
2553
2549
                 * Otherwise, add cmd w/ tasks to delayed cmd queue that
2554
 
                 * will be drained upon competion of HEAD_OF_QUEUE task.
 
2550
                 * will be drained upon completion of HEAD_OF_QUEUE task.
2555
2551
                 */
2556
2552
                spin_lock(&SE_DEV(cmd)->delayed_cmd_lock);
2557
2553
                cmd->se_cmd_flags |= SCF_DELAYED_CMD_FROM_SAM_ATTR;
2593
2589
        }
2594
2590
        /*
2595
2591
         * Call transport_cmd_check_stop() to see if a fabric exception
2596
 
         * has occured that prevents execution.
 
2592
         * has occurred that prevents execution.
2597
2593
         */
2598
2594
        if (!(transport_cmd_check_stop(cmd, 0, TRANSPORT_PROCESSING))) {
2599
2595
                /*
3113
3109
        if (ret != 0) {
3114
3110
                cmd->transport_wait_for_tasks = &transport_nop_wait_for_tasks;
3115
3111
                /*
3116
 
                 * Set SCSI additional sense code (ASC) to 'LUN Not Accessable';
 
3112
                 * Set SCSI additional sense code (ASC) to 'LUN Not Accessible';
3117
3113
                 * The ALUA additional sense code qualifier (ASCQ) is determined
3118
3114
                 * by the ALUA primary or secondary access state..
3119
3115
                 */
3871
3867
                }
3872
3868
        }
3873
3869
        /*
3874
 
         * Check for a callback, used by amoungst other things
 
3870
         * Check for a callback, used by amongst other things
3875
3871
         * XDWRITE_READ_10 emulation.
3876
3872
         */
3877
3873
        if (cmd->transport_complete_callback)
4360
4356
                        printk(KERN_ERR "Unable to allocate struct se_mem\n");
4361
4357
                        goto out;
4362
4358
                }
4363
 
                INIT_LIST_HEAD(&se_mem->se_list);
4364
 
                se_mem->se_len = (length > dma_size) ? dma_size : length;
4365
4359
 
4366
4360
/* #warning FIXME Allocate contigous pages for struct se_mem elements */
4367
 
                se_mem->se_page = (struct page *) alloc_pages(GFP_KERNEL, 0);
 
4361
                se_mem->se_page = alloc_pages(GFP_KERNEL, 0);
4368
4362
                if (!(se_mem->se_page)) {
4369
4363
                        printk(KERN_ERR "alloc_pages() failed\n");
4370
4364
                        goto out;
4375
4369
                        printk(KERN_ERR "kmap_atomic() failed\n");
4376
4370
                        goto out;
4377
4371
                }
 
4372
                INIT_LIST_HEAD(&se_mem->se_list);
 
4373
                se_mem->se_len = (length > dma_size) ? dma_size : length;
4378
4374
                memset(buf, 0, se_mem->se_len);
4379
4375
                kunmap_atomic(buf, KM_IRQ0);
4380
4376
 
4393
4389
 
4394
4390
        return 0;
4395
4391
out:
 
4392
        if (se_mem)
 
4393
                __free_pages(se_mem->se_page, 0);
 
4394
        kmem_cache_free(se_mem_cache, se_mem);
4396
4395
        return -1;
4397
4396
}
4398
4397
 
4399
 
extern u32 transport_calc_sg_num(
 
4398
u32 transport_calc_sg_num(
4400
4399
        struct se_task *task,
4401
4400
        struct se_mem *in_se_mem,
4402
4401
        u32 task_offset)
5835
5834
        int ret;
5836
5835
 
5837
5836
        switch (tmr->function) {
5838
 
        case ABORT_TASK:
 
5837
        case TMR_ABORT_TASK:
5839
5838
                ref_cmd = tmr->ref_cmd;
5840
5839
                tmr->response = TMR_FUNCTION_REJECTED;
5841
5840
                break;
5842
 
        case ABORT_TASK_SET:
5843
 
        case CLEAR_ACA:
5844
 
        case CLEAR_TASK_SET:
 
5841
        case TMR_ABORT_TASK_SET:
 
5842
        case TMR_CLEAR_ACA:
 
5843
        case TMR_CLEAR_TASK_SET:
5845
5844
                tmr->response = TMR_TASK_MGMT_FUNCTION_NOT_SUPPORTED;
5846
5845
                break;
5847
 
        case LUN_RESET:
 
5846
        case TMR_LUN_RESET:
5848
5847
                ret = core_tmr_lun_reset(dev, tmr, NULL, NULL);
5849
5848
                tmr->response = (!ret) ? TMR_FUNCTION_COMPLETE :
5850
5849
                                         TMR_FUNCTION_REJECTED;
5851
5850
                break;
5852
 
#if 0
5853
 
        case TARGET_WARM_RESET:
5854
 
                transport_generic_host_reset(dev->se_hba);
5855
 
                tmr->response = TMR_FUNCTION_REJECTED;
5856
 
                break;
5857
 
        case TARGET_COLD_RESET:
5858
 
                transport_generic_host_reset(dev->se_hba);
5859
 
                transport_generic_cold_reset(dev->se_hba);
5860
 
                tmr->response = TMR_FUNCTION_REJECTED;
5861
 
                break;
5862
 
#endif
 
5851
        case TMR_TARGET_WARM_RESET:
 
5852
                tmr->response = TMR_FUNCTION_REJECTED;
 
5853
                break;
 
5854
        case TMR_TARGET_COLD_RESET:
 
5855
                tmr->response = TMR_FUNCTION_REJECTED;
 
5856
                break;
5863
5857
        default:
5864
5858
                printk(KERN_ERR "Uknown TMR function: 0x%02x.\n",
5865
5859
                                tmr->function);