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

« back to all changes in this revision

Viewing changes to drivers/target/target_core_iblock.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:
35
35
#include <linux/blkdev.h>
36
36
#include <linux/slab.h>
37
37
#include <linux/spinlock.h>
38
 
#include <linux/smp_lock.h>
39
38
#include <linux/bio.h>
40
39
#include <linux/genhd.h>
41
40
#include <linux/file.h>
130
129
        struct request_queue *q;
131
130
        struct queue_limits *limits;
132
131
        u32 dev_flags = 0;
 
132
        int ret = -EINVAL;
133
133
 
134
134
        if (!(ib_dev)) {
135
135
                printk(KERN_ERR "Unable to locate struct iblock_dev parameter\n");
136
 
                return 0;
 
136
                return ERR_PTR(ret);
137
137
        }
138
138
        memset(&dev_limits, 0, sizeof(struct se_dev_limits));
139
139
        /*
142
142
        ib_dev->ibd_bio_set = bioset_create(32, 64);
143
143
        if (!(ib_dev->ibd_bio_set)) {
144
144
                printk(KERN_ERR "IBLOCK: Unable to create bioset()\n");
145
 
                return 0;
 
145
                return ERR_PTR(-ENOMEM);
146
146
        }
147
147
        printk(KERN_INFO "IBLOCK: Created bio_set()\n");
148
148
        /*
154
154
 
155
155
        bd = blkdev_get_by_path(ib_dev->ibd_udev_path,
156
156
                                FMODE_WRITE|FMODE_READ|FMODE_EXCL, ib_dev);
157
 
        if (IS_ERR(bd))
 
157
        if (IS_ERR(bd)) {
 
158
                ret = PTR_ERR(bd);
158
159
                goto failed;
 
160
        }
159
161
        /*
160
162
         * Setup the local scope queue_limits from struct request_queue->limits
161
163
         * to pass into transport_add_device_to_core_hba() as struct se_dev_limits.
185
187
         * the QUEUE_FLAG_DISCARD bit for UNMAP/WRITE_SAME in SCSI + TRIM
186
188
         * in ATA and we need to set TPE=1
187
189
         */
188
 
        if (blk_queue_discard(bdev_get_queue(bd))) {
189
 
                struct request_queue *q = bdev_get_queue(bd);
190
 
 
 
190
        if (blk_queue_discard(q)) {
191
191
                DEV_ATTRIB(dev)->max_unmap_lba_count =
192
192
                                q->limits.max_discard_sectors;
193
193
                /*
213
213
        ib_dev->ibd_bd = NULL;
214
214
        ib_dev->ibd_major = 0;
215
215
        ib_dev->ibd_minor = 0;
216
 
        return NULL;
 
216
        return ERR_PTR(ret);
217
217
}
218
218
 
219
219
static void iblock_free_device(void *p)
392
392
{
393
393
        struct se_device *dev = task->task_se_cmd->se_dev;
394
394
        struct iblock_req *req = IBLOCK_REQ(task);
395
 
        struct iblock_dev *ibd = (struct iblock_dev *)req->ib_dev;
396
 
        struct request_queue *q = bdev_get_queue(ibd->ibd_bd);
397
395
        struct bio *bio = req->ib_bio, *nbio = NULL;
 
396
        struct blk_plug plug;
398
397
        int rw;
399
398
 
400
399
        if (task->task_data_direction == DMA_TO_DEVICE) {
412
411
                rw = READ;
413
412
        }
414
413
 
 
414
        blk_start_plug(&plug);
415
415
        while (bio) {
416
416
                nbio = bio->bi_next;
417
417
                bio->bi_next = NULL;
421
421
                submit_bio(rw, bio);
422
422
                bio = nbio;
423
423
        }
 
424
        blk_finish_plug(&plug);
424
425
 
425
 
        if (q->unplug_fn)
426
 
                q->unplug_fn(q);
427
426
        return PYX_TRANSPORT_SENT_TO_TRANSPORT;
428
427
}
429
428
 
469
468
                                               const char *page, ssize_t count)
470
469
{
471
470
        struct iblock_dev *ib_dev = se_dev->se_dev_su_ptr;
472
 
        char *orig, *ptr, *opts;
 
471
        char *orig, *ptr, *arg_p, *opts;
473
472
        substring_t args[MAX_OPT_ARGS];
474
473
        int ret = 0, arg, token;
475
474
 
492
491
                                ret = -EEXIST;
493
492
                                goto out;
494
493
                        }
495
 
 
496
 
                        ret = snprintf(ib_dev->ibd_udev_path, SE_UDEV_PATH_LEN,
497
 
                                "%s", match_strdup(&args[0]));
 
494
                        arg_p = match_strdup(&args[0]);
 
495
                        if (!arg_p) {
 
496
                                ret = -ENOMEM;
 
497
                                break;
 
498
                        }
 
499
                        snprintf(ib_dev->ibd_udev_path, SE_UDEV_PATH_LEN,
 
500
                                        "%s", arg_p);
 
501
                        kfree(arg_p);
498
502
                        printk(KERN_INFO "IBLOCK: Referencing UDEV path: %s\n",
499
503
                                        ib_dev->ibd_udev_path);
500
504
                        ib_dev->ibd_flags |= IBDF_HAS_UDEV_PATH;