diff options
-rw-r--r-- | block/bsg.c | 37 | ||||
-rw-r--r-- | block/ll_rw_blk.c | 4 | ||||
-rw-r--r-- | include/linux/blkdev.h | 5 | ||||
-rw-r--r-- | include/linux/bsg.h | 10 | ||||
-rw-r--r-- | include/linux/genhd.h | 2 |
5 files changed, 29 insertions, 29 deletions
diff --git a/block/bsg.c b/block/bsg.c index 0427ece9b6d8..4ea4bedb413f 100644 --- a/block/bsg.c +++ b/block/bsg.c | |||
@@ -34,7 +34,6 @@ | |||
34 | static char bsg_version[] = "block layer sg (bsg) 0.4"; | 34 | static char bsg_version[] = "block layer sg (bsg) 0.4"; |
35 | 35 | ||
36 | struct bsg_device { | 36 | struct bsg_device { |
37 | struct gendisk *disk; | ||
38 | request_queue_t *queue; | 37 | request_queue_t *queue; |
39 | spinlock_t lock; | 38 | spinlock_t lock; |
40 | struct list_head busy_list; | 39 | struct list_head busy_list; |
@@ -46,7 +45,7 @@ struct bsg_device { | |||
46 | int done_cmds; | 45 | int done_cmds; |
47 | wait_queue_head_t wq_done; | 46 | wait_queue_head_t wq_done; |
48 | wait_queue_head_t wq_free; | 47 | wait_queue_head_t wq_free; |
49 | char name[BDEVNAME_SIZE]; | 48 | char name[BUS_ID_SIZE]; |
50 | int max_queue; | 49 | int max_queue; |
51 | unsigned long flags; | 50 | unsigned long flags; |
52 | }; | 51 | }; |
@@ -375,7 +374,7 @@ static void bsg_add_command(struct bsg_device *bd, request_queue_t *q, | |||
375 | dprintk("%s: queueing rq %p, bc %p\n", bd->name, rq, bc); | 374 | dprintk("%s: queueing rq %p, bc %p\n", bd->name, rq, bc); |
376 | 375 | ||
377 | rq->end_io_data = bc; | 376 | rq->end_io_data = bc; |
378 | blk_execute_rq_nowait(q, bd->disk, rq, 1, bsg_rq_end_io); | 377 | blk_execute_rq_nowait(q, NULL, rq, 1, bsg_rq_end_io); |
379 | } | 378 | } |
380 | 379 | ||
381 | static inline struct bsg_command *bsg_next_done_cmd(struct bsg_device *bd) | 380 | static inline struct bsg_command *bsg_next_done_cmd(struct bsg_device *bd) |
@@ -741,7 +740,7 @@ out: | |||
741 | } | 740 | } |
742 | 741 | ||
743 | static struct bsg_device *bsg_add_device(struct inode *inode, | 742 | static struct bsg_device *bsg_add_device(struct inode *inode, |
744 | struct gendisk *disk, | 743 | struct request_queue *rq, |
745 | struct file *file) | 744 | struct file *file) |
746 | { | 745 | { |
747 | struct bsg_device *bd = NULL; | 746 | struct bsg_device *bd = NULL; |
@@ -753,17 +752,16 @@ static struct bsg_device *bsg_add_device(struct inode *inode, | |||
753 | if (!bd) | 752 | if (!bd) |
754 | return ERR_PTR(-ENOMEM); | 753 | return ERR_PTR(-ENOMEM); |
755 | 754 | ||
756 | bd->disk = disk; | 755 | bd->queue = rq; |
757 | bd->queue = disk->queue; | 756 | kobject_get(&rq->kobj); |
758 | kobject_get(&disk->queue->kobj); | ||
759 | bsg_set_block(bd, file); | 757 | bsg_set_block(bd, file); |
760 | 758 | ||
761 | atomic_set(&bd->ref_count, 1); | 759 | atomic_set(&bd->ref_count, 1); |
762 | bd->minor = iminor(inode); | 760 | bd->minor = iminor(inode); |
763 | mutex_lock(&bsg_mutex); | 761 | mutex_lock(&bsg_mutex); |
764 | hlist_add_head(&bd->dev_list,&bsg_device_list[bsg_list_idx(bd->minor)]); | 762 | hlist_add_head(&bd->dev_list, &bsg_device_list[bsg_list_idx(bd->minor)]); |
765 | 763 | ||
766 | strncpy(bd->name, disk->disk_name, sizeof(bd->name) - 1); | 764 | strncpy(bd->name, rq->bsg_dev.class_dev->class_id, sizeof(bd->name) - 1); |
767 | dprintk("bound to <%s>, max queue %d\n", | 765 | dprintk("bound to <%s>, max queue %d\n", |
768 | format_dev_t(buf, inode->i_rdev), bd->max_queue); | 766 | format_dev_t(buf, inode->i_rdev), bd->max_queue); |
769 | 767 | ||
@@ -817,7 +815,7 @@ static struct bsg_device *bsg_get_device(struct inode *inode, struct file *file) | |||
817 | if (!bcd) | 815 | if (!bcd) |
818 | return ERR_PTR(-ENODEV); | 816 | return ERR_PTR(-ENODEV); |
819 | 817 | ||
820 | return bsg_add_device(inode, bcd->disk, file); | 818 | return bsg_add_device(inode, bcd->queue, file); |
821 | } | 819 | } |
822 | 820 | ||
823 | static int bsg_open(struct inode *inode, struct file *file) | 821 | static int bsg_open(struct inode *inode, struct file *file) |
@@ -900,7 +898,7 @@ bsg_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
900 | case SG_EMULATED_HOST: | 898 | case SG_EMULATED_HOST: |
901 | case SCSI_IOCTL_SEND_COMMAND: { | 899 | case SCSI_IOCTL_SEND_COMMAND: { |
902 | void __user *uarg = (void __user *) arg; | 900 | void __user *uarg = (void __user *) arg; |
903 | return scsi_cmd_ioctl(file, bd->queue, bd->disk, cmd, uarg); | 901 | return scsi_cmd_ioctl(file, bd->queue, NULL, cmd, uarg); |
904 | } | 902 | } |
905 | case SG_IO: { | 903 | case SG_IO: { |
906 | struct request *rq; | 904 | struct request *rq; |
@@ -915,7 +913,7 @@ bsg_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
915 | return PTR_ERR(rq); | 913 | return PTR_ERR(rq); |
916 | 914 | ||
917 | bio = rq->bio; | 915 | bio = rq->bio; |
918 | blk_execute_rq(bd->queue, bd->disk, rq, 0); | 916 | blk_execute_rq(bd->queue, NULL, rq, 0); |
919 | blk_complete_sgv4_hdr_rq(rq, &hdr, bio); | 917 | blk_complete_sgv4_hdr_rq(rq, &hdr, bio); |
920 | 918 | ||
921 | if (copy_to_user(uarg, &hdr, sizeof(hdr))) | 919 | if (copy_to_user(uarg, &hdr, sizeof(hdr))) |
@@ -945,24 +943,23 @@ static struct file_operations bsg_fops = { | |||
945 | .owner = THIS_MODULE, | 943 | .owner = THIS_MODULE, |
946 | }; | 944 | }; |
947 | 945 | ||
948 | void bsg_unregister_disk(struct gendisk *disk) | 946 | void bsg_unregister_queue(struct request_queue *q) |
949 | { | 947 | { |
950 | struct bsg_class_device *bcd = &disk->bsg_dev; | 948 | struct bsg_class_device *bcd = &q->bsg_dev; |
951 | 949 | ||
952 | if (!bcd->class_dev) | 950 | if (!bcd->class_dev) |
953 | return; | 951 | return; |
954 | 952 | ||
955 | mutex_lock(&bsg_mutex); | 953 | mutex_lock(&bsg_mutex); |
956 | sysfs_remove_link(&bcd->disk->queue->kobj, "bsg"); | 954 | sysfs_remove_link(&q->kobj, "bsg"); |
957 | class_device_destroy(bsg_class, MKDEV(BSG_MAJOR, bcd->minor)); | 955 | class_device_destroy(bsg_class, MKDEV(BSG_MAJOR, bcd->minor)); |
958 | bcd->class_dev = NULL; | 956 | bcd->class_dev = NULL; |
959 | list_del_init(&bcd->list); | 957 | list_del_init(&bcd->list); |
960 | mutex_unlock(&bsg_mutex); | 958 | mutex_unlock(&bsg_mutex); |
961 | } | 959 | } |
962 | 960 | ||
963 | int bsg_register_disk(struct gendisk *disk) | 961 | int bsg_register_queue(struct request_queue *q, char *name) |
964 | { | 962 | { |
965 | request_queue_t *q = disk->queue; | ||
966 | struct bsg_class_device *bcd; | 963 | struct bsg_class_device *bcd; |
967 | dev_t dev; | 964 | dev_t dev; |
968 | 965 | ||
@@ -972,7 +969,7 @@ int bsg_register_disk(struct gendisk *disk) | |||
972 | if (!q->request_fn) | 969 | if (!q->request_fn) |
973 | return 0; | 970 | return 0; |
974 | 971 | ||
975 | bcd = &disk->bsg_dev; | 972 | bcd = &q->bsg_dev; |
976 | memset(bcd, 0, sizeof(*bcd)); | 973 | memset(bcd, 0, sizeof(*bcd)); |
977 | INIT_LIST_HEAD(&bcd->list); | 974 | INIT_LIST_HEAD(&bcd->list); |
978 | 975 | ||
@@ -980,8 +977,8 @@ int bsg_register_disk(struct gendisk *disk) | |||
980 | dev = MKDEV(BSG_MAJOR, bsg_device_nr); | 977 | dev = MKDEV(BSG_MAJOR, bsg_device_nr); |
981 | bcd->minor = bsg_device_nr; | 978 | bcd->minor = bsg_device_nr; |
982 | bsg_device_nr++; | 979 | bsg_device_nr++; |
983 | bcd->disk = disk; | 980 | bcd->queue = q; |
984 | bcd->class_dev = class_device_create(bsg_class, NULL, dev, bcd->dev, "%s", disk->disk_name); | 981 | bcd->class_dev = class_device_create(bsg_class, NULL, dev, bcd->dev, "%s", name); |
985 | if (!bcd->class_dev) | 982 | if (!bcd->class_dev) |
986 | goto err; | 983 | goto err; |
987 | list_add_tail(&bcd->list, &bsg_class_list); | 984 | list_add_tail(&bcd->list, &bsg_class_list); |
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c index 3795e0708a22..74a5498c29a1 100644 --- a/block/ll_rw_blk.c +++ b/block/ll_rw_blk.c | |||
@@ -4091,7 +4091,7 @@ int blk_register_queue(struct gendisk *disk) | |||
4091 | return ret; | 4091 | return ret; |
4092 | } | 4092 | } |
4093 | 4093 | ||
4094 | ret = bsg_register_disk(disk); | 4094 | ret = bsg_register_queue(q, disk->disk_name); |
4095 | if (ret) { | 4095 | if (ret) { |
4096 | elv_unregister_queue(q); | 4096 | elv_unregister_queue(q); |
4097 | kobject_unregister(&q->kobj); | 4097 | kobject_unregister(&q->kobj); |
@@ -4106,7 +4106,7 @@ void blk_unregister_queue(struct gendisk *disk) | |||
4106 | request_queue_t *q = disk->queue; | 4106 | request_queue_t *q = disk->queue; |
4107 | 4107 | ||
4108 | if (q && q->request_fn) { | 4108 | if (q && q->request_fn) { |
4109 | bsg_unregister_disk(disk); | 4109 | bsg_unregister_queue(q); |
4110 | elv_unregister_queue(q); | 4110 | elv_unregister_queue(q); |
4111 | 4111 | ||
4112 | kobject_uevent(&q->kobj, KOBJ_REMOVE); | 4112 | kobject_uevent(&q->kobj, KOBJ_REMOVE); |
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 2746632c2267..24b474e05a44 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/bio.h> | 14 | #include <linux/bio.h> |
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/stringify.h> | 16 | #include <linux/stringify.h> |
17 | #include <linux/bsg.h> | ||
17 | 18 | ||
18 | #include <asm/scatterlist.h> | 19 | #include <asm/scatterlist.h> |
19 | 20 | ||
@@ -470,6 +471,10 @@ struct request_queue | |||
470 | unsigned int bi_size; | 471 | unsigned int bi_size; |
471 | 472 | ||
472 | struct mutex sysfs_lock; | 473 | struct mutex sysfs_lock; |
474 | |||
475 | #if defined(CONFIG_BLK_DEV_BSG) | ||
476 | struct bsg_class_device bsg_dev; | ||
477 | #endif | ||
473 | }; | 478 | }; |
474 | 479 | ||
475 | #define QUEUE_FLAG_CLUSTER 0 /* cluster several segments into 1 */ | 480 | #define QUEUE_FLAG_CLUSTER 0 /* cluster several segments into 1 */ |
diff --git a/include/linux/bsg.h b/include/linux/bsg.h index 2154a6dfbd53..0475a6d3ff6a 100644 --- a/include/linux/bsg.h +++ b/include/linux/bsg.h | |||
@@ -47,16 +47,16 @@ struct bsg_class_device { | |||
47 | struct class_device *class_dev; | 47 | struct class_device *class_dev; |
48 | struct device *dev; | 48 | struct device *dev; |
49 | int minor; | 49 | int minor; |
50 | struct gendisk *disk; | ||
51 | struct list_head list; | 50 | struct list_head list; |
51 | struct request_queue *queue; | ||
52 | }; | 52 | }; |
53 | 53 | ||
54 | extern int bsg_register_disk(struct gendisk *); | 54 | extern int bsg_register_queue(struct request_queue *, char *); |
55 | extern void bsg_unregister_disk(struct gendisk *); | 55 | extern void bsg_unregister_queue(struct request_queue *); |
56 | #else | 56 | #else |
57 | struct bsg_class_device { }; | 57 | struct bsg_class_device { }; |
58 | #define bsg_register_disk(disk) (0) | 58 | #define bsg_register_queue(disk, name) (0) |
59 | #define bsg_unregister_disk(disk) do { } while (0) | 59 | #define bsg_unregister_queue(disk) do { } while (0) |
60 | #endif | 60 | #endif |
61 | 61 | ||
62 | #endif /* __KERNEL__ */ | 62 | #endif /* __KERNEL__ */ |
diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 8c43d7032612..9756fc102a83 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h | |||
@@ -67,7 +67,6 @@ struct partition { | |||
67 | #include <linux/string.h> | 67 | #include <linux/string.h> |
68 | #include <linux/fs.h> | 68 | #include <linux/fs.h> |
69 | #include <linux/workqueue.h> | 69 | #include <linux/workqueue.h> |
70 | #include <linux/bsg.h> | ||
71 | 70 | ||
72 | struct partition { | 71 | struct partition { |
73 | unsigned char boot_ind; /* 0x80 - active */ | 72 | unsigned char boot_ind; /* 0x80 - active */ |
@@ -92,7 +91,6 @@ struct hd_struct { | |||
92 | #ifdef CONFIG_FAIL_MAKE_REQUEST | 91 | #ifdef CONFIG_FAIL_MAKE_REQUEST |
93 | int make_it_fail; | 92 | int make_it_fail; |
94 | #endif | 93 | #endif |
95 | struct bsg_class_device bsg_dev; | ||
96 | }; | 94 | }; |
97 | 95 | ||
98 | #define GENHD_FL_REMOVABLE 1 | 96 | #define GENHD_FL_REMOVABLE 1 |