diff options
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/aoe/aoe.h | 1 | ||||
-rw-r--r-- | drivers/block/aoe/aoecmd.c | 24 | ||||
-rw-r--r-- | drivers/block/aoe/aoedev.c | 18 | ||||
-rw-r--r-- | drivers/block/aoe/aoenet.c | 4 | ||||
-rw-r--r-- | drivers/block/cciss.c | 4 | ||||
-rw-r--r-- | drivers/block/cpqarray.c | 4 | ||||
-rw-r--r-- | drivers/block/floppy.c | 6 | ||||
-rw-r--r-- | drivers/block/nbd.c | 171 | ||||
-rw-r--r-- | drivers/block/pktcdvd.c | 11 | ||||
-rw-r--r-- | drivers/block/xen-blkfront.c | 2 |
10 files changed, 143 insertions, 102 deletions
diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h index 280e71ee744c..5b4c6e649c11 100644 --- a/drivers/block/aoe/aoe.h +++ b/drivers/block/aoe/aoe.h | |||
@@ -195,7 +195,6 @@ void aoedev_exit(void); | |||
195 | struct aoedev *aoedev_by_aoeaddr(int maj, int min); | 195 | struct aoedev *aoedev_by_aoeaddr(int maj, int min); |
196 | struct aoedev *aoedev_by_sysminor_m(ulong sysminor); | 196 | struct aoedev *aoedev_by_sysminor_m(ulong sysminor); |
197 | void aoedev_downdev(struct aoedev *d); | 197 | void aoedev_downdev(struct aoedev *d); |
198 | int aoedev_isbusy(struct aoedev *d); | ||
199 | int aoedev_flush(const char __user *str, size_t size); | 198 | int aoedev_flush(const char __user *str, size_t size); |
200 | 199 | ||
201 | int aoenet_init(void); | 200 | int aoenet_init(void); |
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c index d00293ba3b45..8fc429cf82b6 100644 --- a/drivers/block/aoe/aoecmd.c +++ b/drivers/block/aoe/aoecmd.c | |||
@@ -668,16 +668,16 @@ ataid_complete(struct aoedev *d, struct aoetgt *t, unsigned char *id) | |||
668 | u16 n; | 668 | u16 n; |
669 | 669 | ||
670 | /* word 83: command set supported */ | 670 | /* word 83: command set supported */ |
671 | n = le16_to_cpu(get_unaligned((__le16 *) &id[83<<1])); | 671 | n = get_unaligned_le16(&id[83 << 1]); |
672 | 672 | ||
673 | /* word 86: command set/feature enabled */ | 673 | /* word 86: command set/feature enabled */ |
674 | n |= le16_to_cpu(get_unaligned((__le16 *) &id[86<<1])); | 674 | n |= get_unaligned_le16(&id[86 << 1]); |
675 | 675 | ||
676 | if (n & (1<<10)) { /* bit 10: LBA 48 */ | 676 | if (n & (1<<10)) { /* bit 10: LBA 48 */ |
677 | d->flags |= DEVFL_EXT; | 677 | d->flags |= DEVFL_EXT; |
678 | 678 | ||
679 | /* word 100: number lba48 sectors */ | 679 | /* word 100: number lba48 sectors */ |
680 | ssize = le64_to_cpu(get_unaligned((__le64 *) &id[100<<1])); | 680 | ssize = get_unaligned_le64(&id[100 << 1]); |
681 | 681 | ||
682 | /* set as in ide-disk.c:init_idedisk_capacity */ | 682 | /* set as in ide-disk.c:init_idedisk_capacity */ |
683 | d->geo.cylinders = ssize; | 683 | d->geo.cylinders = ssize; |
@@ -688,12 +688,12 @@ ataid_complete(struct aoedev *d, struct aoetgt *t, unsigned char *id) | |||
688 | d->flags &= ~DEVFL_EXT; | 688 | d->flags &= ~DEVFL_EXT; |
689 | 689 | ||
690 | /* number lba28 sectors */ | 690 | /* number lba28 sectors */ |
691 | ssize = le32_to_cpu(get_unaligned((__le32 *) &id[60<<1])); | 691 | ssize = get_unaligned_le32(&id[60 << 1]); |
692 | 692 | ||
693 | /* NOTE: obsolete in ATA 6 */ | 693 | /* NOTE: obsolete in ATA 6 */ |
694 | d->geo.cylinders = le16_to_cpu(get_unaligned((__le16 *) &id[54<<1])); | 694 | d->geo.cylinders = get_unaligned_le16(&id[54 << 1]); |
695 | d->geo.heads = le16_to_cpu(get_unaligned((__le16 *) &id[55<<1])); | 695 | d->geo.heads = get_unaligned_le16(&id[55 << 1]); |
696 | d->geo.sectors = le16_to_cpu(get_unaligned((__le16 *) &id[56<<1])); | 696 | d->geo.sectors = get_unaligned_le16(&id[56 << 1]); |
697 | } | 697 | } |
698 | 698 | ||
699 | if (d->ssize != ssize) | 699 | if (d->ssize != ssize) |
@@ -779,7 +779,7 @@ aoecmd_ata_rsp(struct sk_buff *skb) | |||
779 | u16 aoemajor; | 779 | u16 aoemajor; |
780 | 780 | ||
781 | hin = (struct aoe_hdr *) skb_mac_header(skb); | 781 | hin = (struct aoe_hdr *) skb_mac_header(skb); |
782 | aoemajor = be16_to_cpu(get_unaligned(&hin->major)); | 782 | aoemajor = get_unaligned_be16(&hin->major); |
783 | d = aoedev_by_aoeaddr(aoemajor, hin->minor); | 783 | d = aoedev_by_aoeaddr(aoemajor, hin->minor); |
784 | if (d == NULL) { | 784 | if (d == NULL) { |
785 | snprintf(ebuf, sizeof ebuf, "aoecmd_ata_rsp: ata response " | 785 | snprintf(ebuf, sizeof ebuf, "aoecmd_ata_rsp: ata response " |
@@ -791,7 +791,7 @@ aoecmd_ata_rsp(struct sk_buff *skb) | |||
791 | 791 | ||
792 | spin_lock_irqsave(&d->lock, flags); | 792 | spin_lock_irqsave(&d->lock, flags); |
793 | 793 | ||
794 | n = be32_to_cpu(get_unaligned(&hin->tag)); | 794 | n = get_unaligned_be32(&hin->tag); |
795 | t = gettgt(d, hin->src); | 795 | t = gettgt(d, hin->src); |
796 | if (t == NULL) { | 796 | if (t == NULL) { |
797 | printk(KERN_INFO "aoe: can't find target e%ld.%d:%012llx\n", | 797 | printk(KERN_INFO "aoe: can't find target e%ld.%d:%012llx\n", |
@@ -806,9 +806,9 @@ aoecmd_ata_rsp(struct sk_buff *skb) | |||
806 | snprintf(ebuf, sizeof ebuf, | 806 | snprintf(ebuf, sizeof ebuf, |
807 | "%15s e%d.%d tag=%08x@%08lx\n", | 807 | "%15s e%d.%d tag=%08x@%08lx\n", |
808 | "unexpected rsp", | 808 | "unexpected rsp", |
809 | be16_to_cpu(get_unaligned(&hin->major)), | 809 | get_unaligned_be16(&hin->major), |
810 | hin->minor, | 810 | hin->minor, |
811 | be32_to_cpu(get_unaligned(&hin->tag)), | 811 | get_unaligned_be32(&hin->tag), |
812 | jiffies); | 812 | jiffies); |
813 | aoechr_error(ebuf); | 813 | aoechr_error(ebuf); |
814 | return; | 814 | return; |
@@ -873,7 +873,7 @@ aoecmd_ata_rsp(struct sk_buff *skb) | |||
873 | printk(KERN_INFO | 873 | printk(KERN_INFO |
874 | "aoe: unrecognized ata command %2.2Xh for %d.%d\n", | 874 | "aoe: unrecognized ata command %2.2Xh for %d.%d\n", |
875 | ahout->cmdstat, | 875 | ahout->cmdstat, |
876 | be16_to_cpu(get_unaligned(&hin->major)), | 876 | get_unaligned_be16(&hin->major), |
877 | hin->minor); | 877 | hin->minor); |
878 | } | 878 | } |
879 | } | 879 | } |
diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c index f9a1cd9edb77..a1d813ab0d6b 100644 --- a/drivers/block/aoe/aoedev.c +++ b/drivers/block/aoe/aoedev.c | |||
@@ -18,24 +18,6 @@ static void skbpoolfree(struct aoedev *d); | |||
18 | static struct aoedev *devlist; | 18 | static struct aoedev *devlist; |
19 | static DEFINE_SPINLOCK(devlist_lock); | 19 | static DEFINE_SPINLOCK(devlist_lock); |
20 | 20 | ||
21 | int | ||
22 | aoedev_isbusy(struct aoedev *d) | ||
23 | { | ||
24 | struct aoetgt **t, **te; | ||
25 | struct frame *f, *e; | ||
26 | |||
27 | t = d->targets; | ||
28 | te = t + NTARGETS; | ||
29 | for (; t < te && *t; t++) { | ||
30 | f = (*t)->frames; | ||
31 | e = f + (*t)->nframes; | ||
32 | for (; f < e; f++) | ||
33 | if (f->tag != FREETAG) | ||
34 | return 1; | ||
35 | } | ||
36 | return 0; | ||
37 | } | ||
38 | |||
39 | struct aoedev * | 21 | struct aoedev * |
40 | aoedev_by_aoeaddr(int maj, int min) | 22 | aoedev_by_aoeaddr(int maj, int min) |
41 | { | 23 | { |
diff --git a/drivers/block/aoe/aoenet.c b/drivers/block/aoe/aoenet.c index 18d243c73eee..d625169c8e48 100644 --- a/drivers/block/aoe/aoenet.c +++ b/drivers/block/aoe/aoenet.c | |||
@@ -128,7 +128,7 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt, | |||
128 | skb_push(skb, ETH_HLEN); /* (1) */ | 128 | skb_push(skb, ETH_HLEN); /* (1) */ |
129 | 129 | ||
130 | h = (struct aoe_hdr *) skb_mac_header(skb); | 130 | h = (struct aoe_hdr *) skb_mac_header(skb); |
131 | n = be32_to_cpu(get_unaligned(&h->tag)); | 131 | n = get_unaligned_be32(&h->tag); |
132 | if ((h->verfl & AOEFL_RSP) == 0 || (n & 1<<31)) | 132 | if ((h->verfl & AOEFL_RSP) == 0 || (n & 1<<31)) |
133 | goto exit; | 133 | goto exit; |
134 | 134 | ||
@@ -140,7 +140,7 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt, | |||
140 | printk(KERN_ERR | 140 | printk(KERN_ERR |
141 | "%s%d.%d@%s; ecode=%d '%s'\n", | 141 | "%s%d.%d@%s; ecode=%d '%s'\n", |
142 | "aoe: error packet from ", | 142 | "aoe: error packet from ", |
143 | be16_to_cpu(get_unaligned(&h->major)), | 143 | get_unaligned_be16(&h->major), |
144 | h->minor, skb->dev->name, | 144 | h->minor, skb->dev->name, |
145 | h->err, aoe_errlist[n]); | 145 | h->err, aoe_errlist[n]); |
146 | goto exit; | 146 | goto exit; |
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index cf6083a1f928..e539be5750dc 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c | |||
@@ -425,7 +425,7 @@ static void __devinit cciss_procinit(int i) | |||
425 | struct proc_dir_entry *pde; | 425 | struct proc_dir_entry *pde; |
426 | 426 | ||
427 | if (proc_cciss == NULL) | 427 | if (proc_cciss == NULL) |
428 | proc_cciss = proc_mkdir("cciss", proc_root_driver); | 428 | proc_cciss = proc_mkdir("driver/cciss", NULL); |
429 | if (!proc_cciss) | 429 | if (!proc_cciss) |
430 | return; | 430 | return; |
431 | pde = proc_create(hba[i]->devname, S_IWUSR | S_IRUSR | S_IRGRP | | 431 | pde = proc_create(hba[i]->devname, S_IWUSR | S_IRUSR | S_IRGRP | |
@@ -3700,7 +3700,7 @@ static void __exit cciss_cleanup(void) | |||
3700 | cciss_remove_one(hba[i]->pdev); | 3700 | cciss_remove_one(hba[i]->pdev); |
3701 | } | 3701 | } |
3702 | } | 3702 | } |
3703 | remove_proc_entry("cciss", proc_root_driver); | 3703 | remove_proc_entry("driver/cciss", NULL); |
3704 | } | 3704 | } |
3705 | 3705 | ||
3706 | static void fail_all_cmds(unsigned long ctlr) | 3706 | static void fail_all_cmds(unsigned long ctlr) |
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c index 69199185ff4b..09c14341e6e3 100644 --- a/drivers/block/cpqarray.c +++ b/drivers/block/cpqarray.c | |||
@@ -214,7 +214,7 @@ static struct proc_dir_entry *proc_array; | |||
214 | static void __init ida_procinit(int i) | 214 | static void __init ida_procinit(int i) |
215 | { | 215 | { |
216 | if (proc_array == NULL) { | 216 | if (proc_array == NULL) { |
217 | proc_array = proc_mkdir("cpqarray", proc_root_driver); | 217 | proc_array = proc_mkdir("driver/cpqarray", NULL); |
218 | if (!proc_array) return; | 218 | if (!proc_array) return; |
219 | } | 219 | } |
220 | 220 | ||
@@ -1796,7 +1796,7 @@ static void __exit cpqarray_exit(void) | |||
1796 | } | 1796 | } |
1797 | } | 1797 | } |
1798 | 1798 | ||
1799 | remove_proc_entry("cpqarray", proc_root_driver); | 1799 | remove_proc_entry("driver/cpqarray", NULL); |
1800 | } | 1800 | } |
1801 | 1801 | ||
1802 | module_init(cpqarray_init) | 1802 | module_init(cpqarray_init) |
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 7652e87d60c5..395f8ea7981c 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c | |||
@@ -4526,14 +4526,15 @@ static void __init parse_floppy_cfg_string(char *cfg) | |||
4526 | } | 4526 | } |
4527 | } | 4527 | } |
4528 | 4528 | ||
4529 | int __init init_module(void) | 4529 | static int __init floppy_module_init(void) |
4530 | { | 4530 | { |
4531 | if (floppy) | 4531 | if (floppy) |
4532 | parse_floppy_cfg_string(floppy); | 4532 | parse_floppy_cfg_string(floppy); |
4533 | return floppy_init(); | 4533 | return floppy_init(); |
4534 | } | 4534 | } |
4535 | module_init(floppy_module_init); | ||
4535 | 4536 | ||
4536 | void cleanup_module(void) | 4537 | static void __exit floppy_module_exit(void) |
4537 | { | 4538 | { |
4538 | int drive; | 4539 | int drive; |
4539 | 4540 | ||
@@ -4562,6 +4563,7 @@ void cleanup_module(void) | |||
4562 | /* eject disk, if any */ | 4563 | /* eject disk, if any */ |
4563 | fd_eject(0); | 4564 | fd_eject(0); |
4564 | } | 4565 | } |
4566 | module_exit(floppy_module_exit); | ||
4565 | 4567 | ||
4566 | module_param(floppy, charp, 0); | 4568 | module_param(floppy, charp, 0); |
4567 | module_param(FLOPPY_IRQ, int, 0); | 4569 | module_param(FLOPPY_IRQ, int, 0); |
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index f75bda16a1fc..ad98dda6037d 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
30 | #include <net/sock.h> | 30 | #include <net/sock.h> |
31 | #include <linux/net.h> | 31 | #include <linux/net.h> |
32 | #include <linux/kthread.h> | ||
32 | 33 | ||
33 | #include <asm/uaccess.h> | 34 | #include <asm/uaccess.h> |
34 | #include <asm/system.h> | 35 | #include <asm/system.h> |
@@ -55,6 +56,7 @@ static unsigned int debugflags; | |||
55 | 56 | ||
56 | static unsigned int nbds_max = 16; | 57 | static unsigned int nbds_max = 16; |
57 | static struct nbd_device *nbd_dev; | 58 | static struct nbd_device *nbd_dev; |
59 | static int max_part; | ||
58 | 60 | ||
59 | /* | 61 | /* |
60 | * Use just one lock (or at most 1 per NIC). Two arguments for this: | 62 | * Use just one lock (or at most 1 per NIC). Two arguments for this: |
@@ -337,7 +339,7 @@ static struct request *nbd_read_stat(struct nbd_device *lo) | |||
337 | } | 339 | } |
338 | 340 | ||
339 | req = nbd_find_request(lo, *(struct request **)reply.handle); | 341 | req = nbd_find_request(lo, *(struct request **)reply.handle); |
340 | if (unlikely(IS_ERR(req))) { | 342 | if (IS_ERR(req)) { |
341 | result = PTR_ERR(req); | 343 | result = PTR_ERR(req); |
342 | if (result != -ENOENT) | 344 | if (result != -ENOENT) |
343 | goto harderror; | 345 | goto harderror; |
@@ -441,6 +443,85 @@ static void nbd_clear_que(struct nbd_device *lo) | |||
441 | } | 443 | } |
442 | 444 | ||
443 | 445 | ||
446 | static void nbd_handle_req(struct nbd_device *lo, struct request *req) | ||
447 | { | ||
448 | if (!blk_fs_request(req)) | ||
449 | goto error_out; | ||
450 | |||
451 | nbd_cmd(req) = NBD_CMD_READ; | ||
452 | if (rq_data_dir(req) == WRITE) { | ||
453 | nbd_cmd(req) = NBD_CMD_WRITE; | ||
454 | if (lo->flags & NBD_READ_ONLY) { | ||
455 | printk(KERN_ERR "%s: Write on read-only\n", | ||
456 | lo->disk->disk_name); | ||
457 | goto error_out; | ||
458 | } | ||
459 | } | ||
460 | |||
461 | req->errors = 0; | ||
462 | |||
463 | mutex_lock(&lo->tx_lock); | ||
464 | if (unlikely(!lo->sock)) { | ||
465 | mutex_unlock(&lo->tx_lock); | ||
466 | printk(KERN_ERR "%s: Attempted send on closed socket\n", | ||
467 | lo->disk->disk_name); | ||
468 | req->errors++; | ||
469 | nbd_end_request(req); | ||
470 | return; | ||
471 | } | ||
472 | |||
473 | lo->active_req = req; | ||
474 | |||
475 | if (nbd_send_req(lo, req) != 0) { | ||
476 | printk(KERN_ERR "%s: Request send failed\n", | ||
477 | lo->disk->disk_name); | ||
478 | req->errors++; | ||
479 | nbd_end_request(req); | ||
480 | } else { | ||
481 | spin_lock(&lo->queue_lock); | ||
482 | list_add(&req->queuelist, &lo->queue_head); | ||
483 | spin_unlock(&lo->queue_lock); | ||
484 | } | ||
485 | |||
486 | lo->active_req = NULL; | ||
487 | mutex_unlock(&lo->tx_lock); | ||
488 | wake_up_all(&lo->active_wq); | ||
489 | |||
490 | return; | ||
491 | |||
492 | error_out: | ||
493 | req->errors++; | ||
494 | nbd_end_request(req); | ||
495 | } | ||
496 | |||
497 | static int nbd_thread(void *data) | ||
498 | { | ||
499 | struct nbd_device *lo = data; | ||
500 | struct request *req; | ||
501 | |||
502 | set_user_nice(current, -20); | ||
503 | while (!kthread_should_stop() || !list_empty(&lo->waiting_queue)) { | ||
504 | /* wait for something to do */ | ||
505 | wait_event_interruptible(lo->waiting_wq, | ||
506 | kthread_should_stop() || | ||
507 | !list_empty(&lo->waiting_queue)); | ||
508 | |||
509 | /* extract request */ | ||
510 | if (list_empty(&lo->waiting_queue)) | ||
511 | continue; | ||
512 | |||
513 | spin_lock_irq(&lo->queue_lock); | ||
514 | req = list_entry(lo->waiting_queue.next, struct request, | ||
515 | queuelist); | ||
516 | list_del_init(&req->queuelist); | ||
517 | spin_unlock_irq(&lo->queue_lock); | ||
518 | |||
519 | /* handle request */ | ||
520 | nbd_handle_req(lo, req); | ||
521 | } | ||
522 | return 0; | ||
523 | } | ||
524 | |||
444 | /* | 525 | /* |
445 | * We always wait for result of write, for now. It would be nice to make it optional | 526 | * We always wait for result of write, for now. It would be nice to make it optional |
446 | * in future | 527 | * in future |
@@ -456,65 +537,23 @@ static void do_nbd_request(struct request_queue * q) | |||
456 | struct nbd_device *lo; | 537 | struct nbd_device *lo; |
457 | 538 | ||
458 | blkdev_dequeue_request(req); | 539 | blkdev_dequeue_request(req); |
540 | |||
541 | spin_unlock_irq(q->queue_lock); | ||
542 | |||
459 | dprintk(DBG_BLKDEV, "%s: request %p: dequeued (flags=%x)\n", | 543 | dprintk(DBG_BLKDEV, "%s: request %p: dequeued (flags=%x)\n", |
460 | req->rq_disk->disk_name, req, req->cmd_type); | 544 | req->rq_disk->disk_name, req, req->cmd_type); |
461 | 545 | ||
462 | if (!blk_fs_request(req)) | ||
463 | goto error_out; | ||
464 | |||
465 | lo = req->rq_disk->private_data; | 546 | lo = req->rq_disk->private_data; |
466 | 547 | ||
467 | BUG_ON(lo->magic != LO_MAGIC); | 548 | BUG_ON(lo->magic != LO_MAGIC); |
468 | 549 | ||
469 | nbd_cmd(req) = NBD_CMD_READ; | 550 | spin_lock_irq(&lo->queue_lock); |
470 | if (rq_data_dir(req) == WRITE) { | 551 | list_add_tail(&req->queuelist, &lo->waiting_queue); |
471 | nbd_cmd(req) = NBD_CMD_WRITE; | 552 | spin_unlock_irq(&lo->queue_lock); |
472 | if (lo->flags & NBD_READ_ONLY) { | ||
473 | printk(KERN_ERR "%s: Write on read-only\n", | ||
474 | lo->disk->disk_name); | ||
475 | goto error_out; | ||
476 | } | ||
477 | } | ||
478 | |||
479 | req->errors = 0; | ||
480 | spin_unlock_irq(q->queue_lock); | ||
481 | |||
482 | mutex_lock(&lo->tx_lock); | ||
483 | if (unlikely(!lo->sock)) { | ||
484 | mutex_unlock(&lo->tx_lock); | ||
485 | printk(KERN_ERR "%s: Attempted send on closed socket\n", | ||
486 | lo->disk->disk_name); | ||
487 | req->errors++; | ||
488 | nbd_end_request(req); | ||
489 | spin_lock_irq(q->queue_lock); | ||
490 | continue; | ||
491 | } | ||
492 | |||
493 | lo->active_req = req; | ||
494 | 553 | ||
495 | if (nbd_send_req(lo, req) != 0) { | 554 | wake_up(&lo->waiting_wq); |
496 | printk(KERN_ERR "%s: Request send failed\n", | ||
497 | lo->disk->disk_name); | ||
498 | req->errors++; | ||
499 | nbd_end_request(req); | ||
500 | } else { | ||
501 | spin_lock(&lo->queue_lock); | ||
502 | list_add(&req->queuelist, &lo->queue_head); | ||
503 | spin_unlock(&lo->queue_lock); | ||
504 | } | ||
505 | |||
506 | lo->active_req = NULL; | ||
507 | mutex_unlock(&lo->tx_lock); | ||
508 | wake_up_all(&lo->active_wq); | ||
509 | 555 | ||
510 | spin_lock_irq(q->queue_lock); | 556 | spin_lock_irq(q->queue_lock); |
511 | continue; | ||
512 | |||
513 | error_out: | ||
514 | req->errors++; | ||
515 | spin_unlock(q->queue_lock); | ||
516 | nbd_end_request(req); | ||
517 | spin_lock(q->queue_lock); | ||
518 | } | 557 | } |
519 | } | 558 | } |
520 | 559 | ||
@@ -524,6 +563,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file, | |||
524 | struct nbd_device *lo = inode->i_bdev->bd_disk->private_data; | 563 | struct nbd_device *lo = inode->i_bdev->bd_disk->private_data; |
525 | int error; | 564 | int error; |
526 | struct request sreq ; | 565 | struct request sreq ; |
566 | struct task_struct *thread; | ||
527 | 567 | ||
528 | if (!capable(CAP_SYS_ADMIN)) | 568 | if (!capable(CAP_SYS_ADMIN)) |
529 | return -EPERM; | 569 | return -EPERM; |
@@ -572,10 +612,13 @@ static int nbd_ioctl(struct inode *inode, struct file *file, | |||
572 | error = -EINVAL; | 612 | error = -EINVAL; |
573 | file = fget(arg); | 613 | file = fget(arg); |
574 | if (file) { | 614 | if (file) { |
615 | struct block_device *bdev = inode->i_bdev; | ||
575 | inode = file->f_path.dentry->d_inode; | 616 | inode = file->f_path.dentry->d_inode; |
576 | if (S_ISSOCK(inode->i_mode)) { | 617 | if (S_ISSOCK(inode->i_mode)) { |
577 | lo->file = file; | 618 | lo->file = file; |
578 | lo->sock = SOCKET_I(inode); | 619 | lo->sock = SOCKET_I(inode); |
620 | if (max_part > 0) | ||
621 | bdev->bd_invalidated = 1; | ||
579 | error = 0; | 622 | error = 0; |
580 | } else { | 623 | } else { |
581 | fput(file); | 624 | fput(file); |
@@ -607,7 +650,12 @@ static int nbd_ioctl(struct inode *inode, struct file *file, | |||
607 | case NBD_DO_IT: | 650 | case NBD_DO_IT: |
608 | if (!lo->file) | 651 | if (!lo->file) |
609 | return -EINVAL; | 652 | return -EINVAL; |
653 | thread = kthread_create(nbd_thread, lo, lo->disk->disk_name); | ||
654 | if (IS_ERR(thread)) | ||
655 | return PTR_ERR(thread); | ||
656 | wake_up_process(thread); | ||
610 | error = nbd_do_it(lo); | 657 | error = nbd_do_it(lo); |
658 | kthread_stop(thread); | ||
611 | if (error) | 659 | if (error) |
612 | return error; | 660 | return error; |
613 | sock_shutdown(lo, 1); | 661 | sock_shutdown(lo, 1); |
@@ -620,6 +668,8 @@ static int nbd_ioctl(struct inode *inode, struct file *file, | |||
620 | lo->bytesize = 0; | 668 | lo->bytesize = 0; |
621 | inode->i_bdev->bd_inode->i_size = 0; | 669 | inode->i_bdev->bd_inode->i_size = 0; |
622 | set_capacity(lo->disk, 0); | 670 | set_capacity(lo->disk, 0); |
671 | if (max_part > 0) | ||
672 | ioctl_by_bdev(inode->i_bdev, BLKRRPART, 0); | ||
623 | return lo->harderror; | 673 | return lo->harderror; |
624 | case NBD_CLEAR_QUE: | 674 | case NBD_CLEAR_QUE: |
625 | /* | 675 | /* |
@@ -653,6 +703,7 @@ static int __init nbd_init(void) | |||
653 | { | 703 | { |
654 | int err = -ENOMEM; | 704 | int err = -ENOMEM; |
655 | int i; | 705 | int i; |
706 | int part_shift; | ||
656 | 707 | ||
657 | BUILD_BUG_ON(sizeof(struct nbd_request) != 28); | 708 | BUILD_BUG_ON(sizeof(struct nbd_request) != 28); |
658 | 709 | ||
@@ -660,8 +711,17 @@ static int __init nbd_init(void) | |||
660 | if (!nbd_dev) | 711 | if (!nbd_dev) |
661 | return -ENOMEM; | 712 | return -ENOMEM; |
662 | 713 | ||
714 | if (max_part < 0) { | ||
715 | printk(KERN_CRIT "nbd: max_part must be >= 0\n"); | ||
716 | return -EINVAL; | ||
717 | } | ||
718 | |||
719 | part_shift = 0; | ||
720 | if (max_part > 0) | ||
721 | part_shift = fls(max_part); | ||
722 | |||
663 | for (i = 0; i < nbds_max; i++) { | 723 | for (i = 0; i < nbds_max; i++) { |
664 | struct gendisk *disk = alloc_disk(1); | 724 | struct gendisk *disk = alloc_disk(1 << part_shift); |
665 | elevator_t *old_e; | 725 | elevator_t *old_e; |
666 | if (!disk) | 726 | if (!disk) |
667 | goto out; | 727 | goto out; |
@@ -696,17 +756,18 @@ static int __init nbd_init(void) | |||
696 | nbd_dev[i].file = NULL; | 756 | nbd_dev[i].file = NULL; |
697 | nbd_dev[i].magic = LO_MAGIC; | 757 | nbd_dev[i].magic = LO_MAGIC; |
698 | nbd_dev[i].flags = 0; | 758 | nbd_dev[i].flags = 0; |
759 | INIT_LIST_HEAD(&nbd_dev[i].waiting_queue); | ||
699 | spin_lock_init(&nbd_dev[i].queue_lock); | 760 | spin_lock_init(&nbd_dev[i].queue_lock); |
700 | INIT_LIST_HEAD(&nbd_dev[i].queue_head); | 761 | INIT_LIST_HEAD(&nbd_dev[i].queue_head); |
701 | mutex_init(&nbd_dev[i].tx_lock); | 762 | mutex_init(&nbd_dev[i].tx_lock); |
702 | init_waitqueue_head(&nbd_dev[i].active_wq); | 763 | init_waitqueue_head(&nbd_dev[i].active_wq); |
764 | init_waitqueue_head(&nbd_dev[i].waiting_wq); | ||
703 | nbd_dev[i].blksize = 1024; | 765 | nbd_dev[i].blksize = 1024; |
704 | nbd_dev[i].bytesize = 0; | 766 | nbd_dev[i].bytesize = 0; |
705 | disk->major = NBD_MAJOR; | 767 | disk->major = NBD_MAJOR; |
706 | disk->first_minor = i; | 768 | disk->first_minor = i << part_shift; |
707 | disk->fops = &nbd_fops; | 769 | disk->fops = &nbd_fops; |
708 | disk->private_data = &nbd_dev[i]; | 770 | disk->private_data = &nbd_dev[i]; |
709 | disk->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO; | ||
710 | sprintf(disk->disk_name, "nbd%d", i); | 771 | sprintf(disk->disk_name, "nbd%d", i); |
711 | set_capacity(disk, 0); | 772 | set_capacity(disk, 0); |
712 | add_disk(disk); | 773 | add_disk(disk); |
@@ -744,7 +805,9 @@ MODULE_DESCRIPTION("Network Block Device"); | |||
744 | MODULE_LICENSE("GPL"); | 805 | MODULE_LICENSE("GPL"); |
745 | 806 | ||
746 | module_param(nbds_max, int, 0444); | 807 | module_param(nbds_max, int, 0444); |
747 | MODULE_PARM_DESC(nbds_max, "How many network block devices to initialize."); | 808 | MODULE_PARM_DESC(nbds_max, "number of network block devices to initialize (default: 16)"); |
809 | module_param(max_part, int, 0444); | ||
810 | MODULE_PARM_DESC(max_part, "number of partitions per device (default: 0)"); | ||
748 | #ifndef NDEBUG | 811 | #ifndef NDEBUG |
749 | module_param(debugflags, int, 0644); | 812 | module_param(debugflags, int, 0644); |
750 | MODULE_PARM_DESC(debugflags, "flags for controlling debug output"); | 813 | MODULE_PARM_DESC(debugflags, "flags for controlling debug output"); |
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 3b806c9fb005..3ba1df93e9e3 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c | |||
@@ -2742,7 +2742,6 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev) | |||
2742 | int i; | 2742 | int i; |
2743 | int ret = 0; | 2743 | int ret = 0; |
2744 | char b[BDEVNAME_SIZE]; | 2744 | char b[BDEVNAME_SIZE]; |
2745 | struct proc_dir_entry *proc; | ||
2746 | struct block_device *bdev; | 2745 | struct block_device *bdev; |
2747 | 2746 | ||
2748 | if (pd->pkt_dev == dev) { | 2747 | if (pd->pkt_dev == dev) { |
@@ -2786,11 +2785,7 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev) | |||
2786 | goto out_mem; | 2785 | goto out_mem; |
2787 | } | 2786 | } |
2788 | 2787 | ||
2789 | proc = create_proc_entry(pd->name, 0, pkt_proc); | 2788 | proc_create_data(pd->name, 0, pkt_proc, &pkt_proc_fops, pd); |
2790 | if (proc) { | ||
2791 | proc->data = pd; | ||
2792 | proc->proc_fops = &pkt_proc_fops; | ||
2793 | } | ||
2794 | DPRINTK(DRIVER_NAME": writer %s mapped to %s\n", pd->name, bdevname(bdev, b)); | 2789 | DPRINTK(DRIVER_NAME": writer %s mapped to %s\n", pd->name, bdevname(bdev, b)); |
2795 | return 0; | 2790 | return 0; |
2796 | 2791 | ||
@@ -3099,7 +3094,7 @@ static int __init pkt_init(void) | |||
3099 | goto out_misc; | 3094 | goto out_misc; |
3100 | } | 3095 | } |
3101 | 3096 | ||
3102 | pkt_proc = proc_mkdir(DRIVER_NAME, proc_root_driver); | 3097 | pkt_proc = proc_mkdir("driver/"DRIVER_NAME, NULL); |
3103 | 3098 | ||
3104 | return 0; | 3099 | return 0; |
3105 | 3100 | ||
@@ -3115,7 +3110,7 @@ out2: | |||
3115 | 3110 | ||
3116 | static void __exit pkt_exit(void) | 3111 | static void __exit pkt_exit(void) |
3117 | { | 3112 | { |
3118 | remove_proc_entry(DRIVER_NAME, proc_root_driver); | 3113 | remove_proc_entry("driver/"DRIVER_NAME, NULL); |
3119 | misc_deregister(&pkt_misc); | 3114 | misc_deregister(&pkt_misc); |
3120 | 3115 | ||
3121 | pkt_debugfs_cleanup(); | 3116 | pkt_debugfs_cleanup(); |
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index d771da816d95..f2fff5799ddf 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c | |||
@@ -137,7 +137,7 @@ static void blkif_restart_queue_callback(void *arg) | |||
137 | schedule_work(&info->work); | 137 | schedule_work(&info->work); |
138 | } | 138 | } |
139 | 139 | ||
140 | int blkif_getgeo(struct block_device *bd, struct hd_geometry *hg) | 140 | static int blkif_getgeo(struct block_device *bd, struct hd_geometry *hg) |
141 | { | 141 | { |
142 | /* We don't have real geometry info, but let's at least return | 142 | /* We don't have real geometry info, but let's at least return |
143 | values consistent with the size of the device */ | 143 | values consistent with the size of the device */ |