Pull more block updates from Jens Axboe: "A combination of changes that ended up depending on both the driver and core branch (and/or the IDE removal), and a few late arriving fixes. In detail: - Fix io ticks wrap-around issue (Chunguang) - nvme-tcp sock locking fix (Maurizio) - s390-dasd fixes (Kees, Christoph) - blk_execute_rq polling support (Keith) - blk-cgroup RCU iteration fix (Yu) - nbd backend ID addition (Prasanna) - Partition deletion fix (Yufen) - Use blk_mq_alloc_disk for mmc, mtip32xx, ubd (Christoph) - Removal of now dead block request types due to IDE removal (Christoph) - Loop probing and control device cleanups (Christoph) - Device uevent fix (Christoph) - Misc cleanups/fixes (Tetsuo, Christoph)" * tag 'block-5.14-2021-07-08' of git://git.kernel.dk/linux-block: (34 commits) blk-cgroup: prevent rcu_sched detected stalls warnings while iterating blkgs block: fix the problem of io_ticks becoming smaller nvme-tcp: can't set sk_user_data without write_lock loop: remove unused variable in loop_set_status() block: remove the bdgrab in blk_drop_partitions block: grab a device refcount in disk_uevent s390/dasd: Avoid field over-reading memcpy() dasd: unexport dasd_set_target_state block: check disk exist before trying to add partition ubd: remove dead code in ubd_setup_common nvme: use return value from blk_execute_rq() block: return errors from blk_execute_rq() nvme: use blk_execute_rq() for passthrough commands block: support polling through blk_execute_rq block: remove REQ_OP_SCSI_{IN,OUT} block: mark blk_mq_init_queue_data static loop: rewrite loop_exit using idr_for_each_entry loop: split loop_lookup loop: don't allow deleting an unspecified loop device loop: move loop_ctl_mutex locking into loop_add ...
Unified · Split
| @@ -125,9 +125,7 @@ static const struct block_device_operations ubd_blops = { · 124 unmodified lines | |||
| 125 | }; | 125 | }; |
| 126 | 126 | ||
| 127 | /* Protected by ubd_lock */ | 127 | /* Protected by ubd_lock */ |
| 128 | static int fake_major = UBD_MAJOR; | ||
| 129 | static struct gendisk *ubd_gendisk[MAX_DEV]; | 128 | static struct gendisk *ubd_gendisk[MAX_DEV]; |
| 130 | static struct gendisk *fake_gendisk[MAX_DEV]; | ||
| 131 | 129 | ||
| 132 | #ifdef CONFIG_BLK_DEV_UBD_SYNC | 130 | #ifdef CONFIG_BLK_DEV_UBD_SYNC |
| 133 | #define OPEN_FLAGS ((struct openflags) { .r = 1, .w = 1, .s = 1, .c = 0, \ | 131 | #define OPEN_FLAGS ((struct openflags) { .r = 1, .w = 1, .s = 1, .c = 0, \ |
| @@ -197,54 +195,19 @@ struct ubd { · 63 unmodified lines | |||
| 197 | /* Protected by ubd_lock */ | 195 | /* Protected by ubd_lock */ |
| 198 | static struct ubd ubd_devs[MAX_DEV] = { [0 ... MAX_DEV - 1] = DEFAULT_UBD }; | 196 | static struct ubd ubd_devs[MAX_DEV] = { [0 ... MAX_DEV - 1] = DEFAULT_UBD }; |
| 199 | 197 | ||
| 200 | /* Only changed by fake_ide_setup which is a setup */ | ||
| 201 | static int fake_ide = 0; | ||
| 202 | static struct proc_dir_entry *proc_ide_root = NULL; | ||
| 203 | static struct proc_dir_entry *proc_ide = NULL; | ||
| 204 | |||
| 205 | static blk_status_t ubd_queue_rq(struct blk_mq_hw_ctx *hctx, | 198 | static blk_status_t ubd_queue_rq(struct blk_mq_hw_ctx *hctx, |
| 206 | const struct blk_mq_queue_data *bd); | 199 | const struct blk_mq_queue_data *bd); |
| 207 | 200 | ||
| 208 | static void make_proc_ide(void) | ||
| 209 | { | ||
| 210 | proc_ide_root = proc_mkdir("ide", NULL); | ||
| 211 | proc_ide = proc_mkdir("ide0", proc_ide_root); | ||
| 212 | } | ||
| 213 | |||
| 214 | static int fake_ide_media_proc_show(struct seq_file *m, void *v) | ||
| 215 | { | ||
| 216 | seq_puts(m, "disk\n"); | ||
| 217 | return 0; | ||
| 218 | } | ||
| 219 | |||
| 220 | static void make_ide_entries(const char *dev_name) | ||
| 221 | { | ||
| 222 | struct proc_dir_entry *dir, *ent; | ||
| 223 | char name[64]; | ||
| 224 | |||
| 225 | if(proc_ide_root == NULL) make_proc_ide(); | ||
| 226 | |||
| 227 | dir = proc_mkdir(dev_name, proc_ide); | ||
| 228 | if(!dir) return; | ||
| 229 | |||
| 230 | ent = proc_create_single("media", S_IRUGO, dir, | ||
| 231 | fake_ide_media_proc_show); | ||
| 232 | if(!ent) return; | ||
| 233 | snprintf(name, sizeof(name), "ide0/%s", dev_name); | ||
| 234 | proc_symlink(dev_name, proc_ide_root, name); | ||
| 235 | } | ||
| 236 | |||
| 237 | static int fake_ide_setup(char *str) | 201 | static int fake_ide_setup(char *str) |
| 238 | { | 202 | { |
| 239 | fake_ide = 1; | 203 | pr_warn("The fake_ide option has been removed\n"); |
| 240 | return 1; | 204 | return 1; |
| 241 | } | 205 | } |
| 242 | |||
| 243 | __setup("fake_ide", fake_ide_setup); | 206 | __setup("fake_ide", fake_ide_setup); |
| 244 | 207 | ||
| 245 | __uml_help(fake_ide_setup, | 208 | __uml_help(fake_ide_setup, |
| 246 | "fake_ide\n" | 209 | "fake_ide\n" |
| 247 | " Create ide0 entries that map onto ubd devices.\n\n" | 210 | " Obsolete stub.\n\n" |
| 248 | ); | 211 | ); |
| 249 | 212 | ||
| 250 | static int parse_unit(char **ptr) | 213 | static int parse_unit(char **ptr) |
| @@ -280,36 +243,14 @@ static int ubd_setup_common(char *str, int *index_out, char **error_out) · 29 unmodified lines | |||
| 280 | if(index_out) *index_out = -1; | 243 | if(index_out) *index_out = -1; |
| 281 | n = *str; | 244 | n = *str; |
| 282 | if(n == '='){ | 245 | if(n == '='){ |
| 283 | char *end; | ||
| 284 | int major; | ||
| 285 | |||
| 286 | str++; | 246 | str++; |
| 287 | if(!strcmp(str, "sync")){ | 247 | if(!strcmp(str, "sync")){ |
| 288 | global_openflags = of_sync(global_openflags); | 248 | global_openflags = of_sync(global_openflags); |
| 289 | return err; | 249 | return err; |
| 290 | } | 250 | } |
| 291 | 251 | ||
| 292 | err = -EINVAL; | 252 | pr_warn("fake major not supported any more\n"); |
| 293 | major = simple_strtoul(str, &end, 0); | 253 | return 0; |
| 294 | if((*end != '\0') || (end == str)){ | ||
| 295 | *error_out = "Didn't parse major number"; | ||
| 296 | return err; | ||
| 297 | } | ||
| 298 | |||
| 299 | mutex_lock(&ubd_lock); | ||
| 300 | if (fake_major != UBD_MAJOR) { | ||
| 301 | *error_out = "Can't assign a fake major twice"; | ||
| 302 | goto out1; | ||
| 303 | } | ||
| 304 | |||
| 305 | fake_major = major; | ||
| 306 | |||
| 307 | printk(KERN_INFO "Setting extra ubd major number to %d\n", | ||
| 308 | major); | ||
| 309 | err = 0; | ||
| 310 | out1: | ||
| 311 | mutex_unlock(&ubd_lock); | ||
| 312 | return err; | ||
| 313 | } | 254 | } |
| 314 | 255 | ||
| 315 | n = parse_unit(&str); | 256 | n = parse_unit(&str); |
| @@ -874,7 +815,6 @@ static void ubd_device_release(struct device *dev) · 558 unmodified lines | |||
| 874 | { | 815 | { |
| 875 | struct ubd *ubd_dev = dev_get_drvdata(dev); | 816 | struct ubd *ubd_dev = dev_get_drvdata(dev); |
| 876 | 817 | ||
| 877 | blk_cleanup_queue(ubd_dev->queue); | ||
| 878 | blk_mq_free_tag_set(&ubd_dev->tag_set); | 818 | blk_mq_free_tag_set(&ubd_dev->tag_set); |
| 879 | *ubd_dev = ((struct ubd) DEFAULT_UBD); | 819 | *ubd_dev = ((struct ubd) DEFAULT_UBD); |
| 880 | } | 820 | } |
| @@ -914,41 +854,25 @@ static const struct attribute_group *ubd_attr_groups[] = { · 33 unmodified lines | |||
| 914 | NULL, | 854 | NULL, |
| 915 | }; | 855 | }; |
| 916 | 856 | ||
| 917 | static int ubd_disk_register(int major, u64 size, int unit, | 857 | static void ubd_disk_register(int major, u64 size, int unit, |
| 918 | struct gendisk **disk_out) | 858 | struct gendisk *disk) |
| 919 | { | 859 | { |
| 920 | struct device *parent = NULL; | ||
| 921 | struct gendisk *disk; | ||
| 922 | |||
| 923 | disk = alloc_disk(1 << UBD_SHIFT); | ||
| 924 | if(disk == NULL) | ||
| 925 | return -ENOMEM; | ||
| 926 | |||
| 927 | disk->major = major; | 860 | disk->major = major; |
| 928 | disk->first_minor = unit << UBD_SHIFT; | 861 | disk->first_minor = unit << UBD_SHIFT; |
| 862 | disk->minors = 1 << UBD_SHIFT; | ||
| 929 | disk->fops = &ubd_blops; | 863 | disk->fops = &ubd_blops; |
| 930 | set_capacity(disk, size / 512); | 864 | set_capacity(disk, size / 512); |
| 931 | if (major == UBD_MAJOR) | 865 | sprintf(disk->disk_name, "ubd%c", 'a' + unit); |
| 932 | sprintf(disk->disk_name, "ubd%c", 'a' + unit); | 866 | |
| 933 | else | 867 | ubd_devs[unit].pdev.id = unit; |
| 934 | sprintf(disk->disk_name, "ubd_fake%d", unit); | 868 | ubd_devs[unit].pdev.name = DRIVER_NAME; |
| 935 | 869 | ubd_devs[unit].pdev.dev.release = ubd_device_release; | |
| 936 | /* sysfs register (not for ide fake devices) */ | 870 | dev_set_drvdata(&ubd_devs[unit].pdev.dev, &ubd_devs[unit]); |
| 937 | if (major == UBD_MAJOR) { | 871 | platform_device_register(&ubd_devs[unit].pdev); |
| 938 | ubd_devs[unit].pdev.id = unit; | ||
| 939 | ubd_devs[unit].pdev.name = DRIVER_NAME; | ||
| 940 | ubd_devs[unit].pdev.dev.release = ubd_device_release; | ||
| 941 | dev_set_drvdata(&ubd_devs[unit].pdev.dev, &ubd_devs[unit]); | ||
| 942 | platform_device_register(&ubd_devs[unit].pdev); | ||
| 943 | parent = &ubd_devs[unit].pdev.dev; | ||
| 944 | } | ||
| 945 | 872 | ||
| 946 | disk->private_data = &ubd_devs[unit]; | 873 | disk->private_data = &ubd_devs[unit]; |
| 947 | disk->queue = ubd_devs[unit].queue; | 874 | disk->queue = ubd_devs[unit].queue; |
| 948 | device_add_disk(parent, disk, ubd_attr_groups); | 875 | device_add_disk(&ubd_devs[unit].pdev.dev, disk, ubd_attr_groups); |
| 949 | |||
| 950 | *disk_out = disk; | ||
| 951 | return 0; | ||
| 952 | } | 876 | } |
| 953 | 877 | ||
| 954 | #define ROUND_BLOCK(n) ((n + (SECTOR_SIZE - 1)) & (-SECTOR_SIZE)) | 878 | #define ROUND_BLOCK(n) ((n + (SECTOR_SIZE - 1)) & (-SECTOR_SIZE)) |
| @@ -960,6 +884,7 @@ static const struct blk_mq_ops ubd_mq_ops = { · 5 unmodified lines | |||
| 960 | static int ubd_add(int n, char **error_out) | 884 | static int ubd_add(int n, char **error_out) |
| 961 | { | 885 | { |
| 962 | struct ubd *ubd_dev = &ubd_devs[n]; | 886 | struct ubd *ubd_dev = &ubd_devs[n]; |
| 887 | struct gendisk *disk; | ||
| 963 | int err = 0; | 888 | int err = 0; |
| 964 | 889 | ||
| 965 | if(ubd_dev->file == NULL) | 890 | if(ubd_dev->file == NULL) |
| @@ -984,43 +909,24 @@ static int ubd_add(int n, char **error_out) · 18 unmodified lines | |||
| 984 | if (err) | 909 | if (err) |
| 985 | goto out; | 910 | goto out; |
| 986 | 911 | ||
| 987 | ubd_dev->queue = blk_mq_init_queue(&ubd_dev->tag_set); | 912 | disk = blk_mq_alloc_disk(&ubd_dev->tag_set, ubd_dev); |
| 988 | if (IS_ERR(ubd_dev->queue)) { | 913 | if (IS_ERR(disk)) { |
| 989 | err = PTR_ERR(ubd_dev->queue); | 914 | err = PTR_ERR(disk); |
| 990 | goto out_cleanup_tags; | 915 | goto out_cleanup_tags; |
| 991 | } | 916 | } |
| 917 | ubd_dev->queue = disk->queue; | ||
| 992 | 918 | ||
| 993 | ubd_dev->queue->queuedata = ubd_dev; | ||
| 994 | blk_queue_write_cache(ubd_dev->queue, true, false); | 919 | blk_queue_write_cache(ubd_dev->queue, true, false); |
| 995 | |||
| 996 | blk_queue_max_segments(ubd_dev->queue, MAX_SG); | 920 | blk_queue_max_segments(ubd_dev->queue, MAX_SG); |
| 997 | blk_queue_segment_boundary(ubd_dev->queue, PAGE_SIZE - 1); | 921 | blk_queue_segment_boundary(ubd_dev->queue, PAGE_SIZE - 1); |
| 998 | err = ubd_disk_register(UBD_MAJOR, ubd_dev->size, n, &ubd_gendisk[n]); | 922 | ubd_disk_register(UBD_MAJOR, ubd_dev->size, n, disk); |
| 999 | if(err){ | 923 | ubd_gendisk[n] = disk; |
| 1000 | *error_out = "Failed to register device"; | 924 | return 0; |
| 1001 | goto out_cleanup_tags; | ||
| 1002 | } | ||
| 1003 | |||
| 1004 | if (fake_major != UBD_MAJOR) | ||
| 1005 | ubd_disk_register(fake_major, ubd_dev->size, n, | ||
| 1006 | &fake_gendisk[n]); | ||
| 1007 | |||
| 1008 | /* | ||
| 1009 | * Perhaps this should also be under the "if (fake_major)" above | ||
| 1010 | * using the fake_disk->disk_name | ||
| 1011 | */ | ||
| 1012 | if (fake_ide) | ||
| 1013 | make_ide_entries(ubd_gendisk[n]->disk_name); | ||
| 1014 | |||
| 1015 | err = 0; | ||
| 1016 | out: | ||
| 1017 | return err; | ||
| 1018 | 925 | ||
| 1019 | out_cleanup_tags: | 926 | out_cleanup_tags: |
| 1020 | blk_mq_free_tag_set(&ubd_dev->tag_set); | 927 | blk_mq_free_tag_set(&ubd_dev->tag_set); |
| 1021 | if (!(IS_ERR(ubd_dev->queue))) | 928 | out: |
| 1022 | blk_cleanup_queue(ubd_dev->queue); | 929 | return err; |
| 1023 | goto out; | ||
| 1024 | } | 930 | } |
| 1025 | 931 | ||
| 1026 | static int ubd_config(char *str, char **error_out) | 932 | static int ubd_config(char *str, char **error_out) |
| @@ -1123,13 +1029,7 @@ static int ubd_remove(int n, char **error_out) · 96 unmodified lines | |||
| 1123 | ubd_gendisk[n] = NULL; | 1029 | ubd_gendisk[n] = NULL; |
| 1124 | if(disk != NULL){ | 1030 | if(disk != NULL){ |
| 1125 | del_gendisk(disk); | 1031 | del_gendisk(disk); |
| 1126 | put_disk(disk); | 1032 | blk_cleanup_disk(disk); |
| 1127 | } | ||
| 1128 | |||
| 1129 | if(fake_gendisk[n] != NULL){ | ||
| 1130 | del_gendisk(fake_gendisk[n]); | ||
| 1131 | put_disk(fake_gendisk[n]); | ||
| 1132 | fake_gendisk[n] = NULL; | ||
| 1133 | } | 1033 | } |
| 1134 | 1034 | ||
| 1135 | err = 0; | 1035 | err = 0; |
| @@ -1188,14 +1088,6 @@ static int __init ubd_init(void) · 52 unmodified lines | |||
| 1188 | if (register_blkdev(UBD_MAJOR, "ubd")) | 1088 | if (register_blkdev(UBD_MAJOR, "ubd")) |
| 1189 | return -1; | 1089 | return -1; |
| 1190 | 1090 | ||
| 1191 | if (fake_major != UBD_MAJOR) { | ||
| 1192 | char name[sizeof("ubd_nnn\0")]; | ||
| 1193 | |||
| 1194 | snprintf(name, sizeof(name), "ubd_%d", fake_major); | ||
| 1195 | if (register_blkdev(fake_major, "ubd")) | ||
| 1196 | return -1; | ||
| 1197 | } | ||
| 1198 | |||
| 1199 | irq_req_buffer = kmalloc_array(UBD_REQ_BUFFER_SIZE, | 1091 | irq_req_buffer = kmalloc_array(UBD_REQ_BUFFER_SIZE, |
| 1200 | sizeof(struct io_thread_req *), | 1092 | sizeof(struct io_thread_req *), |
| 1201 | GFP_KERNEL | 1093 | GFP_KERNEL |
| @@ -56,6 +56,8 @@ static LIST_HEAD(all_blkcgs); /* protected by blkcg_pol_mutex */ · 55 unmodified lines | |||
| 56 | bool blkcg_debug_stats = false; | 56 | bool blkcg_debug_stats = false; |
| 57 | static struct workqueue_struct *blkcg_punt_bio_wq; | 57 | static struct workqueue_struct *blkcg_punt_bio_wq; |
| 58 | 58 | ||
| 59 | #define BLKG_DESTROY_BATCH_SIZE 64 | ||
| 60 | |||
| 59 | static bool blkcg_policy_enabled(struct request_queue *q, | 61 | static bool blkcg_policy_enabled(struct request_queue *q, |
| 60 | const struct blkcg_policy *pol) | 62 | const struct blkcg_policy *pol) |
| 61 | { | 63 | { |
| @@ -422,7 +424,9 @@ static void blkg_destroy(struct blkcg_gq *blkg) · 360 unmodified lines | |||
| 422 | static void blkg_destroy_all(struct request_queue *q) | 424 | static void blkg_destroy_all(struct request_queue *q) |
| 423 | { | 425 | { |
| 424 | struct blkcg_gq *blkg, *n; | 426 | struct blkcg_gq *blkg, *n; |
| 427 | int count = BLKG_DESTROY_BATCH_SIZE; | ||
| 425 | 428 | ||
| 429 | restart: | ||
| 426 | spin_lock_irq(&q->queue_lock); | 430 | spin_lock_irq(&q->queue_lock); |
| 427 | list_for_each_entry_safe(blkg, n, &q->blkg_list, q_node) { | 431 | list_for_each_entry_safe(blkg, n, &q->blkg_list, q_node) { |
| 428 | struct blkcg *blkcg = blkg->blkcg; | 432 | struct blkcg *blkcg = blkg->blkcg; |
| @@ -430,6 +434,17 @@ static void blkg_destroy_all(struct request_queue *q) · 1 unmodified line | |||
| 430 | spin_lock(&blkcg->lock); | 434 | spin_lock(&blkcg->lock); |
| 431 | blkg_destroy(blkg); | 435 | blkg_destroy(blkg); |
| 432 | spin_unlock(&blkcg->lock); | 436 | spin_unlock(&blkcg->lock); |
| 437 | |||
| 438 | /* | ||
| 439 | * in order to avoid holding the spin lock for too long, release | ||
| 440 | * it when a batch of blkgs are destroyed. | ||
| 441 | */ | ||
| 442 | if (!(--count)) { | ||
| 443 | count = BLKG_DESTROY_BATCH_SIZE; | ||
| 444 | spin_unlock_irq(&q->queue_lock); | ||
| 445 | cond_resched(); | ||
| 446 | goto restart; | ||
| 447 | } | ||
| 433 | } | 448 | } |
| 434 | 449 | ||
| 435 | q->root_blkg = NULL; | 450 | q->root_blkg = NULL; |
| @@ -142,8 +142,6 @@ static const char *const blk_op_name[] = { · 141 unmodified lines | |||
| 142 | REQ_OP_NAME(ZONE_APPEND), | 142 | REQ_OP_NAME(ZONE_APPEND), |
| 143 | REQ_OP_NAME(WRITE_SAME), | 143 | REQ_OP_NAME(WRITE_SAME), |
| 144 | REQ_OP_NAME(WRITE_ZEROES), | 144 | REQ_OP_NAME(WRITE_ZEROES), |
| 145 | REQ_OP_NAME(SCSI_IN), | ||
| 146 | REQ_OP_NAME(SCSI_OUT), | ||
| 147 | REQ_OP_NAME(DRV_IN), | 145 | REQ_OP_NAME(DRV_IN), |
| 148 | REQ_OP_NAME(DRV_OUT), | 146 | REQ_OP_NAME(DRV_OUT), |
| 149 | }; | 147 | }; |
| @@ -1243,7 +1241,7 @@ static void update_io_ticks(struct block_device *part, unsigned long now, · 1093 unmodified lines | |||
| 1243 | unsigned long stamp; | 1241 | unsigned long stamp; |
| 1244 | again: | 1242 | again: |
| 1245 | stamp = READ_ONCE(part->bd_stamp); | 1243 | stamp = READ_ONCE(part->bd_stamp); |
| 1246 | if (unlikely(stamp != now)) { | 1244 | if (unlikely(time_after(now, stamp))) { |
| 1247 | if (likely(cmpxchg(&part->bd_stamp, stamp, now) == stamp)) | 1245 | if (likely(cmpxchg(&part->bd_stamp, stamp, now) == stamp)) |
| 1248 | __part_stat_add(part, io_ticks, end ? now - stamp : 1); | 1246 | __part_stat_add(part, io_ticks, end ? now - stamp : 1); |
| 1249 | } | 1247 | } |
| @@ -21,7 +21,7 @@ static void blk_end_sync_rq(struct request *rq, blk_status_t error) · 20 unmodified lines | |||
| 21 | { | 21 | { |
| 22 | struct completion *waiting = rq->end_io_data; | 22 | struct completion *waiting = rq->end_io_data; |
| 23 | 23 | ||
| 24 | rq->end_io_data = NULL; | 24 | rq->end_io_data = (void *)(uintptr_t)error; |
| 25 | 25 | ||
| 26 | /* | 26 | /* |
| 27 | * complete last, if this is a stack request the process (and thus | 27 | * complete last, if this is a stack request the process (and thus |
| @@ -63,6 +63,19 @@ void blk_execute_rq_nowait(struct gendisk *bd_disk, struct request *rq, · 35 unmodified lines | |||
| 63 | } | 63 | } |
| 64 | EXPORT_SYMBOL_GPL(blk_execute_rq_nowait); | 64 | EXPORT_SYMBOL_GPL(blk_execute_rq_nowait); |
| 65 | 65 | ||
| 66 | static bool blk_rq_is_poll(struct request *rq) | ||
| 67 | { | ||
| 68 | return rq->mq_hctx && rq->mq_hctx->type == HCTX_TYPE_POLL; | ||
| 69 | } | ||
| 70 | |||
| 71 | static void blk_rq_poll_completion(struct request *rq, struct completion *wait) | ||
| 72 | { | ||
| 73 | do { | ||
| 74 | blk_poll(rq->q, request_to_qc_t(rq->mq_hctx, rq), true); | ||
| 75 | cond_resched(); | ||
| 76 | } while (!completion_done(wait)); | ||
| 77 | } | ||
| 78 | |||
| 66 | /** | 79 | /** |
| 67 | * blk_execute_rq - insert a request into queue for execution | 80 | * blk_execute_rq - insert a request into queue for execution |
| 68 | * @bd_disk: matching gendisk | 81 | * @bd_disk: matching gendisk |
| @@ -72,8 +85,9 @@ EXPORT_SYMBOL_GPL(blk_execute_rq_nowait); · 3 unmodified lines | |||
| 72 | * Description: | 85 | * Description: |
| 73 | * Insert a fully prepared request at the back of the I/O scheduler queue | 86 | * Insert a fully prepared request at the back of the I/O scheduler queue |
| 74 | * for execution and wait for completion. | 87 | * for execution and wait for completion. |
| 88 | * Return: The blk_status_t result provided to blk_mq_end_request(). | ||
| 75 | */ | 89 | */ |
| 76 | void blk_execute_rq(struct gendisk *bd_disk, struct request *rq, int at_head) | 90 | blk_status_t blk_execute_rq(struct gendisk *bd_disk, struct request *rq, int at_head) |
| 77 | { | 91 | { |
| 78 | DECLARE_COMPLETION_ONSTACK(wait); | 92 | DECLARE_COMPLETION_ONSTACK(wait); |
| 79 | unsigned long hang_check; | 93 | unsigned long hang_check; |
| @@ -83,9 +97,14 @@ void blk_execute_rq(struct gendisk *bd_disk, struct request *rq, int at_head) · 3 unmodified lines | |||
| 83 | 97 | ||
| 84 | /* Prevent hang_check timer from firing at us during very long I/O */ | 98 | /* Prevent hang_check timer from firing at us during very long I/O */ |
| 85 | hang_check = sysctl_hung_task_timeout_secs; | 99 | hang_check = sysctl_hung_task_timeout_secs; |
| 86 | if (hang_check) | 100 | |
| 101 | if (blk_rq_is_poll(rq)) | ||
| 102 | blk_rq_poll_completion(rq, &wait); | ||
| 103 | else if (hang_check) | ||
| 87 | while (!wait_for_completion_io_timeout(&wait, hang_check * (HZ/2))); | 104 | while (!wait_for_completion_io_timeout(&wait, hang_check * (HZ/2))); |
| 88 | else | 105 | else |
| 89 | wait_for_completion_io(&wait); | 106 | wait_for_completion_io(&wait); |
| 107 | |||
| 108 | return (blk_status_t)(uintptr_t)rq->end_io_data; | ||
| 90 | } | 109 | } |
| 91 | EXPORT_SYMBOL(blk_execute_rq); | 110 | EXPORT_SYMBOL(blk_execute_rq); |
| @@ -3109,7 +3109,7 @@ void blk_mq_release(struct request_queue *q) · 3108 unmodified lines | |||
| 3109 | blk_mq_sysfs_deinit(q); | 3109 | blk_mq_sysfs_deinit(q); |
| 3110 | } | 3110 | } |
| 3111 | 3111 | ||
| 3112 | struct request_queue *blk_mq_init_queue_data(struct blk_mq_tag_set *set, | 3112 | static struct request_queue *blk_mq_init_queue_data(struct blk_mq_tag_set *set, |
| 3113 | void *queuedata) | 3113 | void *queuedata) |
| 3114 | { | 3114 | { |
| 3115 | struct request_queue *q; | 3115 | struct request_queue *q; |
| @@ -3126,7 +3126,6 @@ struct request_queue *blk_mq_init_queue_data(struct blk_mq_tag_set *set, · 10 unmodified lines | |||
| 3126 | } | 3126 | } |
| 3127 | return q; | 3127 | return q; |
| 3128 | } | 3128 | } |
| 3129 | EXPORT_SYMBOL_GPL(blk_mq_init_queue_data); | ||
| 3130 | 3129 | ||
| 3131 | struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *set) | 3130 | struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *set) |
| 3132 | { | 3131 | { |
| @@ -45,7 +45,7 @@ static int bsg_transport_fill_hdr(struct request *rq, struct sg_io_v4 *hdr, · 44 unmodified lines | |||
| 45 | return PTR_ERR(job->request); | 45 | return PTR_ERR(job->request); |
| 46 | 46 | ||
| 47 | if (hdr->dout_xfer_len && hdr->din_xfer_len) { | 47 | if (hdr->dout_xfer_len && hdr->din_xfer_len) { |
| 48 | job->bidi_rq = blk_get_request(rq->q, REQ_OP_SCSI_IN, 0); | 48 | job->bidi_rq = blk_get_request(rq->q, REQ_OP_DRV_IN, 0); |
| 49 | if (IS_ERR(job->bidi_rq)) { | 49 | if (IS_ERR(job->bidi_rq)) { |
| 50 | ret = PTR_ERR(job->bidi_rq); | 50 | ret = PTR_ERR(job->bidi_rq); |
| 51 | goto out; | 51 | goto out; |
| @@ -154,7 +154,7 @@ static int bsg_sg_io(struct request_queue *q, fmode_t mode, void __user *uarg) · 153 unmodified lines | |||
| 154 | return ret; | 154 | return ret; |
| 155 | 155 | ||
| 156 | rq = blk_get_request(q, hdr.dout_xfer_len ? | 156 | rq = blk_get_request(q, hdr.dout_xfer_len ? |
| 157 | REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, 0); | 157 | REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0); |
| 158 | if (IS_ERR(rq)) | 158 | if (IS_ERR(rq)) |
| 159 | return PTR_ERR(rq); | 159 | return PTR_ERR(rq); |
| 160 | 160 | ||
| @@ -365,12 +365,12 @@ void disk_uevent(struct gendisk *disk, enum kobject_action action) · 364 unmodified lines | |||
| 365 | xa_for_each(&disk->part_tbl, idx, part) { | 365 | xa_for_each(&disk->part_tbl, idx, part) { |
| 366 | if (bdev_is_partition(part) && !bdev_nr_sectors(part)) | 366 | if (bdev_is_partition(part) && !bdev_nr_sectors(part)) |
| 367 | continue; | 367 | continue; |
| 368 | if (!bdgrab(part)) | 368 | if (!kobject_get_unless_zero(&part->bd_device.kobj)) |
| 369 | continue; | 369 | continue; |
| 370 | 370 | ||
| 371 | rcu_read_unlock(); | 371 | rcu_read_unlock(); |
| 372 | kobject_uevent(bdev_kobj(part), action); | 372 | kobject_uevent(bdev_kobj(part), action); |
| 373 | bdput(part); | 373 | put_device(&part->bd_device); |
| 374 | rcu_read_lock(); | 374 | rcu_read_lock(); |
| 375 | } | 375 | } |
| 376 | rcu_read_unlock(); | 376 | rcu_read_unlock(); |
| @@ -453,17 +453,26 @@ int bdev_add_partition(struct block_device *bdev, int partno, · 452 unmodified lines | |||
| 453 | sector_t start, sector_t length) | 453 | sector_t start, sector_t length) |
| 454 | { | 454 | { |
| 455 | struct block_device *part; | 455 | struct block_device *part; |
| 456 | struct gendisk *disk = bdev->bd_disk; | ||
| 457 | int ret; | ||
| 456 | 458 | ||
| 457 | mutex_lock(&bdev->bd_disk->open_mutex); | 459 | mutex_lock(&disk->open_mutex); |
| 458 | if (partition_overlaps(bdev->bd_disk, start, length, -1)) { | 460 | if (!(disk->flags & GENHD_FL_UP)) { |
| 459 | mutex_unlock(&bdev->bd_disk->open_mutex); | 461 | ret = -ENXIO; |
| 460 | return -EBUSY; | 462 | goto out; |
| 463 | } | ||
| 464 | |||
| 465 | if (partition_overlaps(disk, start, length, -1)) { | ||
| 466 | ret = -EBUSY; | ||
| 467 | goto out; | ||
| 461 | } | 468 | } |
| 462 | 469 | ||
| 463 | part = add_partition(bdev->bd_disk, partno, start, length, | 470 | part = add_partition(disk, partno, start, length, |
| 464 | ADDPART_FLAG_NONE, NULL); | 471 | ADDPART_FLAG_NONE, NULL); |
| 465 | mutex_unlock(&bdev->bd_disk->open_mutex); | 472 | ret = PTR_ERR_OR_ZERO(part); |
| 466 | return PTR_ERR_OR_ZERO(part); | 473 | out: |
| 474 | mutex_unlock(&disk->open_mutex); | ||
| 475 | return ret; | ||
| 467 | } | 476 | } |
| 468 | 477 | ||
| 469 | int bdev_del_partition(struct block_device *bdev, int partno) | 478 | int bdev_del_partition(struct block_device *bdev, int partno) |
| @@ -537,12 +546,8 @@ void blk_drop_partitions(struct gendisk *disk) · 67 unmodified lines | |||
| 537 | 546 | ||
| 538 | lockdep_assert_held(&disk->open_mutex); | 547 | lockdep_assert_held(&disk->open_mutex); |
| 539 | 548 | ||
| 540 | xa_for_each_start(&disk->part_tbl, idx, part, 1) { | 549 | xa_for_each_start(&disk->part_tbl, idx, part, 1) |
| 541 | if (!bdgrab(part)) | ||
| 542 | continue; | ||
| 543 | delete_partition(part); | 550 | delete_partition(part); |
| 544 | bdput(part); | ||
| 545 | } | ||
| 546 | } | 551 | } |
| 547 | 552 | ||
| 548 | static bool blk_add_partition(struct gendisk *disk, | 553 | static bool blk_add_partition(struct gendisk *disk, |
| @@ -313,7 +313,7 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk, · 312 unmodified lines | |||
| 313 | at_head = 1; | 313 | at_head = 1; |
| 314 | 314 | ||
| 315 | ret = -ENOMEM; | 315 | ret = -ENOMEM; |
| 316 | rq = blk_get_request(q, writing ? REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, 0); | 316 | rq = blk_get_request(q, writing ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0); |
| 317 | if (IS_ERR(rq)) | 317 | if (IS_ERR(rq)) |
| 318 | return PTR_ERR(rq); | 318 | return PTR_ERR(rq); |
| 319 | req = scsi_req(rq); | 319 | req = scsi_req(rq); |
| @@ -435,7 +435,7 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode, · 115 unmodified lines | |||
| 435 | 435 | ||
| 436 | } | 436 | } |
| 437 | 437 | ||
| 438 | rq = blk_get_request(q, in_len ? REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, 0); | 438 | rq = blk_get_request(q, in_len ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0); |
| 439 | if (IS_ERR(rq)) { | 439 | if (IS_ERR(rq)) { |
| 440 | err = PTR_ERR(rq); | 440 | err = PTR_ERR(rq); |
| 441 | goto error_free_buffer; | 441 | goto error_free_buffer; |
| @@ -524,7 +524,7 @@ static int __blk_send_generic(struct request_queue *q, struct gendisk *bd_disk, · 82 unmodified lines | |||
| 524 | struct request *rq; | 524 | struct request *rq; |
| 525 | int err; | 525 | int err; |
| 526 | 526 | ||
| 527 | rq = blk_get_request(q, REQ_OP_SCSI_OUT, 0); | 527 | rq = blk_get_request(q, REQ_OP_DRV_OUT, 0); |
| 528 | if (IS_ERR(rq)) | 528 | if (IS_ERR(rq)) |
| 529 | return PTR_ERR(rq); | 529 | return PTR_ERR(rq); |
| 530 | rq->timeout = BLK_DEFAULT_SG_TIMEOUT; | 530 | rq->timeout = BLK_DEFAULT_SG_TIMEOUT; |
| @@ -1434,7 +1434,6 @@ static int · 1433 unmodified lines | |||
| 1434 | loop_set_status(struct loop_device *lo, const struct loop_info64 *info) | 1434 | loop_set_status(struct loop_device *lo, const struct loop_info64 *info) |
| 1435 | { | 1435 | { |
| 1436 | int err; | 1436 | int err; |
| 1437 | struct block_device *bdev; | ||
| 1438 | kuid_t uid = current_uid(); | 1437 | kuid_t uid = current_uid(); |
| 1439 | int prev_lo_flags; | 1438 | int prev_lo_flags; |
| 1440 | bool partscan = false; | 1439 | bool partscan = false; |
| @@ -1503,7 +1502,6 @@ out_unfreeze: · 62 unmodified lines | |||
| 1503 | if (!err && (lo->lo_flags & LO_FLAGS_PARTSCAN) && | 1502 | if (!err && (lo->lo_flags & LO_FLAGS_PARTSCAN) && |
| 1504 | !(prev_lo_flags & LO_FLAGS_PARTSCAN)) { | 1503 | !(prev_lo_flags & LO_FLAGS_PARTSCAN)) { |
| 1505 | lo->lo_disk->flags &= ~GENHD_FL_NO_PART_SCAN; | 1504 | lo->lo_disk->flags &= ~GENHD_FL_NO_PART_SCAN; |
| 1506 | bdev = lo->lo_device; | ||
| 1507 | partscan = true; | 1505 | partscan = true; |
| 1508 | } | 1506 | } |
| 1509 | out_unlock: | 1507 | out_unlock: |
| @@ -2237,7 +2235,7 @@ static const struct blk_mq_ops loop_mq_ops = { · 727 unmodified lines | |||
| 2237 | .complete = lo_complete_rq, | 2235 | .complete = lo_complete_rq, |
| 2238 | }; | 2236 | }; |
| 2239 | 2237 | ||
| 2240 | static int loop_add(struct loop_device **l, int i) | 2238 | static int loop_add(int i) |
| 2241 | { | 2239 | { |
| 2242 | struct loop_device *lo; | 2240 | struct loop_device *lo; |
| 2243 | struct gendisk *disk; | 2241 | struct gendisk *disk; |
| @@ -2247,9 +2245,12 @@ static int loop_add(struct loop_device **l, int i) · 3 unmodified lines | |||
| 2247 | lo = kzalloc(sizeof(*lo), GFP_KERNEL); | 2245 | lo = kzalloc(sizeof(*lo), GFP_KERNEL); |
| 2248 | if (!lo) | 2246 | if (!lo) |
| 2249 | goto out; | 2247 | goto out; |
| 2250 | |||
| 2251 | lo->lo_state = Lo_unbound; | 2248 | lo->lo_state = Lo_unbound; |
| 2252 | 2249 | ||
| 2250 | err = mutex_lock_killable(&loop_ctl_mutex); | ||
| 2251 | if (err) | ||
| 2252 | goto out_free_dev; | ||
| 2253 | |||
| 2253 | /* allocate id, if @id >= 0, we're requesting that specific id */ | 2254 | /* allocate id, if @id >= 0, we're requesting that specific id */ |
| 2254 | if (i >= 0) { | 2255 | if (i >= 0) { |
| 2255 | err = idr_alloc(&loop_index_idr, lo, i, i + 1, GFP_KERNEL); | 2256 | err = idr_alloc(&loop_index_idr, lo, i, i + 1, GFP_KERNEL); |
| @@ -2259,7 +2260,7 @@ static int loop_add(struct loop_device **l, int i) · 3 unmodified lines | |||
| 2259 | err = idr_alloc(&loop_index_idr, lo, 0, 0, GFP_KERNEL); | 2260 | err = idr_alloc(&loop_index_idr, lo, 0, 0, GFP_KERNEL); |
| 2260 | } | 2261 | } |
| 2261 | if (err < 0) | 2262 | if (err < 0) |
| 2262 | goto out_free_dev; | 2263 | goto out_unlock; |
| 2263 | i = err; | 2264 | i = err; |
| 2264 | 2265 | ||
| 2265 | err = -ENOMEM; | 2266 | err = -ENOMEM; |
| @@ -2326,13 +2327,15 @@ static int loop_add(struct loop_device **l, int i) · 60 unmodified lines | |||
| 2326 | disk->queue = lo->lo_queue; | 2327 | disk->queue = lo->lo_queue; |
| 2327 | sprintf(disk->disk_name, "loop%d", i); | 2328 | sprintf(disk->disk_name, "loop%d", i); |
| 2328 | add_disk(disk); | 2329 | add_disk(disk); |
| 2329 | *l = lo; | 2330 | mutex_unlock(&loop_ctl_mutex); |
| 2330 | return lo->lo_number; | 2331 | return i; |
| 2331 | 2332 | ||
| 2332 | out_cleanup_tags: | 2333 | out_cleanup_tags: |
| 2333 | blk_mq_free_tag_set(&lo->tag_set); | 2334 | blk_mq_free_tag_set(&lo->tag_set); |
| 2334 | out_free_idr: | 2335 | out_free_idr: |
| 2335 | idr_remove(&loop_index_idr, i); | 2336 | idr_remove(&loop_index_idr, i); |
| 2337 | out_unlock: | ||
| 2338 | mutex_unlock(&loop_ctl_mutex); | ||
| 2336 | out_free_dev: | 2339 | out_free_dev: |
| 2337 | kfree(lo); | 2340 | kfree(lo); |
| 2338 | out: | 2341 | out: |
| @@ -2348,109 +2351,86 @@ static void loop_remove(struct loop_device *lo) · 9 unmodified lines | |||
| 2348 | kfree(lo); | 2351 | kfree(lo); |
| 2349 | } | 2352 | } |
| 2350 | 2353 | ||
| 2351 | static int find_free_cb(int id, void *ptr, void *data) | 2354 | static void loop_probe(dev_t dev) |
| 2352 | { | 2355 | { |
| 2353 | struct loop_device *lo = ptr; | 2356 | int idx = MINOR(dev) >> part_shift; |
| 2354 | struct loop_device **l = data; | ||
| 2355 | 2357 | ||
| 2356 | if (lo->lo_state == Lo_unbound) { | 2358 | if (max_loop && idx >= max_loop) |
| 2357 | *l = lo; | 2359 | return; |
| 2358 | return 1; | 2360 | loop_add(idx); |
| 2359 | } | ||
| 2360 | return 0; | ||
| 2361 | } | 2361 | } |
| 2362 | 2362 | ||
| 2363 | static int loop_lookup(struct loop_device **l, int i) | 2363 | static int loop_control_remove(int idx) |
| 2364 | { | 2364 | { |
| 2365 | struct loop_device *lo; | 2365 | struct loop_device *lo; |
| 2366 | int ret = -ENODEV; | 2366 | int ret; |
| 2367 | 2367 | ||
| 2368 | if (i < 0) { | 2368 | if (idx < 0) { |
| 2369 | int err; | 2369 | pr_warn("deleting an unspecified loop device is not supported.\n"); |
| 2370 | return -EINVAL; | ||
| 2371 | } | ||
| 2372 | |||
| 2373 | ret = mutex_lock_killable(&loop_ctl_mutex); | ||
| 2374 | if (ret) | ||
| 2375 | return ret; | ||
| 2370 | 2376 | ||
| 2371 | err = idr_for_each(&loop_index_idr, &find_free_cb, &lo); | 2377 | lo = idr_find(&loop_index_idr, idx); |
| 2372 | if (err == 1) { | 2378 | if (!lo) { |
| 2373 | *l = lo; | 2379 | ret = -ENODEV; |
| 2374 | ret = lo->lo_number; | 2380 | goto out_unlock_ctrl; |
| 2375 | } | ||
| 2376 | goto out; | ||
| 2377 | } | 2381 | } |
| 2378 | 2382 | ||
| 2379 | /* lookup and return a specific i */ | 2383 | ret = mutex_lock_killable(&lo->lo_mutex); |
| 2380 | lo = idr_find(&loop_index_idr, i); | 2384 | if (ret) |
| 2381 | if (lo) { | 2385 | goto out_unlock_ctrl; |
| 2382 | *l = lo; | 2386 | if (lo->lo_state != Lo_unbound || |
| 2383 | ret = lo->lo_number; | 2387 | atomic_read(&lo->lo_refcnt) > 0) { |
| 2388 | mutex_unlock(&lo->lo_mutex); | ||
| 2389 | ret = -EBUSY; | ||
| 2390 | goto out_unlock_ctrl; | ||
| 2384 | } | 2391 | } |
| 2385 | out: | 2392 | lo->lo_state = Lo_deleting; |
| 2393 | mutex_unlock(&lo->lo_mutex); | ||
| 2394 | |||
| 2395 | idr_remove(&loop_index_idr, lo->lo_number); | ||
| 2396 | loop_remove(lo); | ||
| 2397 | out_unlock_ctrl: | ||
| 2398 | mutex_unlock(&loop_ctl_mutex); | ||
| 2386 | return ret; | 2399 | return ret; |
| 2387 | } | 2400 | } |
| 2388 | 2401 | ||
| 2389 | static void loop_probe(dev_t dev) | 2402 | static int loop_control_get_free(int idx) |
| 2390 | { | 2403 | { |
| 2391 | int idx = MINOR(dev) >> part_shift; | ||
| 2392 | struct loop_device *lo; | 2404 | struct loop_device *lo; |
| 2405 | int id, ret; | ||
| 2393 | 2406 | ||
| 2394 | if (max_loop && idx >= max_loop) | 2407 | ret = mutex_lock_killable(&loop_ctl_mutex); |
| 2395 | return; | 2408 | if (ret) |
| 2396 | 2409 | return ret; | |
| 2397 | mutex_lock(&loop_ctl_mutex); | 2410 | idr_for_each_entry(&loop_index_idr, lo, id) { |
| 2398 | if (loop_lookup(&lo, idx) < 0) | 2411 | if (lo->lo_state == Lo_unbound) |
| 2399 | loop_add(&lo, idx); | 2412 | goto found; |
| 2413 | } | ||
| 2400 | mutex_unlock(&loop_ctl_mutex); | 2414 | mutex_unlock(&loop_ctl_mutex); |
| 2415 | return loop_add(-1); | ||
| 2416 | found: | ||
| 2417 | mutex_unlock(&loop_ctl_mutex); | ||
| 2418 | return id; | ||
| 2401 | } | 2419 | } |
| 2402 | 2420 | ||
| 2403 | static long loop_control_ioctl(struct file *file, unsigned int cmd, | 2421 | static long loop_control_ioctl(struct file *file, unsigned int cmd, |
| 2404 | unsigned long parm) | 2422 | unsigned long parm) |
| 2405 | { | 2423 | { |
| 2406 | struct loop_device *lo; | ||
| 2407 | int ret; | ||
| 2408 | |||
| 2409 | ret = mutex_lock_killable(&loop_ctl_mutex); | ||
| 2410 | if (ret) | ||
| 2411 | return ret; | ||
| 2412 | |||
| 2413 | ret = -ENOSYS; | ||
| 2414 | switch (cmd) { | 2424 | switch (cmd) { |
| 2415 | case LOOP_CTL_ADD: | 2425 | case LOOP_CTL_ADD: |
| 2416 | ret = loop_lookup(&lo, parm); | 2426 | return loop_add(parm); |
| 2417 | if (ret >= 0) { | ||
| 2418 | ret = -EEXIST; | ||
| 2419 | break; | ||
| 2420 | } | ||
| 2421 | ret = loop_add(&lo, parm); | ||
| 2422 | break; | ||
| 2423 | case LOOP_CTL_REMOVE: | 2427 | case LOOP_CTL_REMOVE: |
| 2424 | ret = loop_lookup(&lo, parm); | 2428 | return loop_control_remove(parm); |
| 2425 | if (ret < 0) | ||
| 2426 | break; | ||
| 2427 | ret = mutex_lock_killable(&lo->lo_mutex); | ||
| 2428 | if (ret) | ||
| 2429 | break; | ||
| 2430 | if (lo->lo_state != Lo_unbound) { | ||
| 2431 | ret = -EBUSY; | ||
| 2432 | mutex_unlock(&lo->lo_mutex); | ||
| 2433 | break; | ||
| 2434 | } | ||
| 2435 | if (atomic_read(&lo->lo_refcnt) > 0) { | ||
| 2436 | ret = -EBUSY; | ||
| 2437 | mutex_unlock(&lo->lo_mutex); | ||
| 2438 | break; | ||
| 2439 | } | ||
| 2440 | lo->lo_state = Lo_deleting; | ||
| 2441 | mutex_unlock(&lo->lo_mutex); | ||
| 2442 | idr_remove(&loop_index_idr, lo->lo_number); | ||
| 2443 | loop_remove(lo); | ||
| 2444 | break; | ||
| 2445 | case LOOP_CTL_GET_FREE: | 2429 | case LOOP_CTL_GET_FREE: |
| 2446 | ret = loop_lookup(&lo, -1); | 2430 | return loop_control_get_free(parm); |
| 2447 | if (ret >= 0) | 2431 | default: |
| 2448 | break; | 2432 | return -ENOSYS; |
| 2449 | ret = loop_add(&lo, -1); | ||
| 2450 | } | 2433 | } |
| 2451 | mutex_unlock(&loop_ctl_mutex); | ||
| 2452 | |||
| 2453 | return ret; | ||
| 2454 | } | 2434 | } |
| 2455 | 2435 | ||
| 2456 | static const struct file_operations loop_ctl_fops = { | 2436 | static const struct file_operations loop_ctl_fops = { |
| @@ -2473,7 +2453,6 @@ MODULE_ALIAS("devname:loop-control"); · 16 unmodified lines | |||
| 2473 | static int __init loop_init(void) | 2453 | static int __init loop_init(void) |
| 2474 | { | 2454 | { |
| 2475 | int i, nr; | 2455 | int i, nr; |
| 2476 | struct loop_device *lo; | ||
| 2477 | int err; | 2456 | int err; |
| 2478 | 2457 | ||
| 2479 | part_shift = 0; | 2458 | part_shift = 0; |
| @@ -2525,10 +2504,8 @@ static int __init loop_init(void) · 45 unmodified lines | |||
| 2525 | } | 2504 | } |
| 2526 | 2505 | ||
| 2527 | /* pre-create number of devices given by config or max_loop */ | 2506 | /* pre-create number of devices given by config or max_loop */ |
| 2528 | mutex_lock(&loop_ctl_mutex); | ||
| 2529 | for (i = 0; i < nr; i++) | 2507 | for (i = 0; i < nr; i++) |
| 2530 | loop_add(&lo, i); | 2508 | loop_add(i); |
| 2531 | mutex_unlock(&loop_ctl_mutex); | ||
| 2532 | 2509 | ||
| 2533 | printk(KERN_INFO "loop: module loaded\n"); | 2510 | printk(KERN_INFO "loop: module loaded\n"); |
| 2534 | return 0; | 2511 | return 0; |
| @@ -2539,26 +2516,20 @@ err_out: · 4 unmodified lines | |||
| 2539 | return err; | 2516 | return err; |
| 2540 | } | 2517 | } |
| 2541 | 2518 | ||
| 2542 | static int loop_exit_cb(int id, void *ptr, void *data) | ||
| 2543 | { | ||
| 2544 | struct loop_device *lo = ptr; | ||
| 2545 | |||
| 2546 | loop_remove(lo); | ||
| 2547 | return 0; | ||
| 2548 | } | ||
| 2549 | |||
| 2550 | static void __exit loop_exit(void) | 2519 | static void __exit loop_exit(void) |
| 2551 | { | 2520 | { |
| 2552 | mutex_lock(&loop_ctl_mutex); | 2521 | struct loop_device *lo; |
| 2553 | 2522 | int id; | |
| 2554 | idr_for_each(&loop_index_idr, &loop_exit_cb, NULL); | ||
| 2555 | idr_destroy(&loop_index_idr); | ||
| 2556 | 2523 | ||
| 2557 | unregister_blkdev(LOOP_MAJOR, "loop"); | 2524 | unregister_blkdev(LOOP_MAJOR, "loop"); |
| 2558 | |||
| 2559 | misc_deregister(&loop_misc); | 2525 | misc_deregister(&loop_misc); |
| 2560 | 2526 | ||
| 2527 | mutex_lock(&loop_ctl_mutex); | ||
| 2528 | idr_for_each_entry(&loop_index_idr, lo, id) | ||
| 2529 | loop_remove(lo); | ||
| 2561 | mutex_unlock(&loop_ctl_mutex); | 2530 | mutex_unlock(&loop_ctl_mutex); |
| 2531 | |||
| 2532 | idr_destroy(&loop_index_idr); | ||
| 2562 | } | 2533 | } |
| 2563 | 2534 | ||
| 2564 | module_init(loop_init); | 2535 | module_init(loop_init); |
| @@ -2160,6 +2160,20 @@ static ssize_t mtip_hw_show_status(struct device *dev, · 2159 unmodified lines | |||
| 2160 | 2160 | ||
| 2161 | static DEVICE_ATTR(status, 0444, mtip_hw_show_status, NULL); | 2161 | static DEVICE_ATTR(status, 0444, mtip_hw_show_status, NULL); |
| 2162 | 2162 | ||
| 2163 | static struct attribute *mtip_disk_attrs[] = { | ||
| 2164 | &dev_attr_status.attr, | ||
| 2165 | NULL, | ||
| 2166 | }; | ||
| 2167 | |||
| 2168 | static const struct attribute_group mtip_disk_attr_group = { | ||
| 2169 | .attrs = mtip_disk_attrs, | ||
| 2170 | }; | ||
| 2171 | |||
| 2172 | static const struct attribute_group *mtip_disk_attr_groups[] = { | ||
| 2173 | &mtip_disk_attr_group, | ||
| 2174 | NULL, | ||
| 2175 | }; | ||
| 2176 | |||
| 2163 | /* debugsfs entries */ | 2177 | /* debugsfs entries */ |
| 2164 | 2178 | ||
| 2165 | static ssize_t show_device_status(struct device_driver *drv, char *buf) | 2179 | static ssize_t show_device_status(struct device_driver *drv, char *buf) |
| @@ -2374,47 +2388,6 @@ static const struct file_operations mtip_flags_fops = { · 208 unmodified lines | |||
| 2374 | .llseek = no_llseek, | 2388 | .llseek = no_llseek, |
| 2375 | }; | 2389 | }; |
| 2376 | 2390 | ||
| 2377 | /* | ||
| 2378 | * Create the sysfs related attributes. | ||
| 2379 | * | ||
| 2380 | * @dd Pointer to the driver data structure. | ||
| 2381 | * @kobj Pointer to the kobj for the block device. | ||
| 2382 | * | ||
| 2383 | * return value | ||
| 2384 | * 0 Operation completed successfully. | ||
| 2385 | * -EINVAL Invalid parameter. | ||
| 2386 | */ | ||
| 2387 | static int mtip_hw_sysfs_init(struct driver_data *dd, struct kobject *kobj) | ||
| 2388 | { | ||
| 2389 | if (!kobj || !dd) | ||
| 2390 | return -EINVAL; | ||
| 2391 | |||
| 2392 | if (sysfs_create_file(kobj, &dev_attr_status.attr)) | ||
| 2393 | dev_warn(&dd->pdev->dev, | ||
| 2394 | "Error creating 'status' sysfs entry\n"); | ||
| 2395 | return 0; | ||
| 2396 | } | ||
| 2397 | |||
| 2398 | /* | ||
| 2399 | * Remove the sysfs related attributes. | ||
| 2400 | * | ||
| 2401 | * @dd Pointer to the driver data structure. | ||
| 2402 | * @kobj Pointer to the kobj for the block device. | ||
| 2403 | * | ||
| 2404 | * return value | ||
| 2405 | * 0 Operation completed successfully. | ||
| 2406 | * -EINVAL Invalid parameter. | ||
| 2407 | */ | ||
| 2408 | static int mtip_hw_sysfs_exit(struct driver_data *dd, struct kobject *kobj) | ||
| 2409 | { | ||
| 2410 | if (!kobj || !dd) | ||
| 2411 | return -EINVAL; | ||
| 2412 | |||
| 2413 | sysfs_remove_file(kobj, &dev_attr_status.attr); | ||
| 2414 | |||
| 2415 | return 0; | ||
| 2416 | } | ||
| 2417 | |||
| 2418 | static int mtip_hw_debugfs_init(struct driver_data *dd) | 2391 | static int mtip_hw_debugfs_init(struct driver_data *dd) |
| 2419 | { | 2392 | { |
| 2420 | if (!dfs_parent) | 2393 | if (!dfs_parent) |
| @@ -3566,7 +3539,6 @@ static int mtip_block_initialize(struct driver_data *dd) · 1145 unmodified lines | |||
| 3566 | int rv = 0, wait_for_rebuild = 0; | 3539 | int rv = 0, wait_for_rebuild = 0; |
| 3567 | sector_t capacity; | 3540 | sector_t capacity; |
| 3568 | unsigned int index = 0; | 3541 | unsigned int index = 0; |
| 3569 | struct kobject *kobj; | ||
| 3570 | 3542 | ||
| 3571 | if (dd->disk) | 3543 | if (dd->disk) |
| 3572 | goto skip_create_disk; /* hw init done, before rebuild */ | 3544 | goto skip_create_disk; /* hw init done, before rebuild */ |
| @@ -3576,35 +3548,6 @@ static int mtip_block_initialize(struct driver_data *dd) · 3 unmodified lines | |||
| 3576 | goto protocol_init_error; | 3548 | goto protocol_init_error; |
| 3577 | } | 3549 | } |
| 3578 | 3550 | ||
| 3579 | dd->disk = alloc_disk_node(MTIP_MAX_MINORS, dd->numa_node); | ||
| 3580 | if (dd->disk == NULL) { | ||
| 3581 | dev_err(&dd->pdev->dev, | ||
| 3582 | "Unable to allocate gendisk structure\n"); | ||
| 3583 | rv = -EINVAL; | ||
| 3584 | goto alloc_disk_error; | ||
| 3585 | } | ||
| 3586 | |||
| 3587 | rv = ida_alloc(&rssd_index_ida, GFP_KERNEL); | ||
| 3588 | if (rv < 0) | ||
| 3589 | goto ida_get_error; | ||
| 3590 | index = rv; | ||
| 3591 | |||
| 3592 | rv = rssd_disk_name_format("rssd", | ||
| 3593 | index, | ||
| 3594 | dd->disk->disk_name, | ||
| 3595 | DISK_NAME_LEN); | ||
| 3596 | if (rv) | ||
| 3597 | goto disk_index_error; | ||
| 3598 | |||
| 3599 | dd->disk->major = dd->major; | ||
| 3600 | dd->disk->first_minor = index * MTIP_MAX_MINORS; | ||
| 3601 | dd->disk->minors = MTIP_MAX_MINORS; | ||
| 3602 | dd->disk->fops = &mtip_block_ops; | ||
| 3603 | dd->disk->private_data = dd; | ||
| 3604 | dd->index = index; | ||
| 3605 | |||
| 3606 | mtip_hw_debugfs_init(dd); | ||
| 3607 | |||
| 3608 | memset(&dd->tags, 0, sizeof(dd->tags)); | 3551 | memset(&dd->tags, 0, sizeof(dd->tags)); |
| 3609 | dd->tags.ops = &mtip_mq_ops; | 3552 | dd->tags.ops = &mtip_mq_ops; |
| 3610 | dd->tags.nr_hw_queues = 1; | 3553 | dd->tags.nr_hw_queues = 1; |
| @@ -3623,17 +3566,35 @@ static int mtip_block_initialize(struct driver_data *dd) · 12 unmodified lines | |||
| 3623 | goto block_queue_alloc_tag_error; | 3566 | goto block_queue_alloc_tag_error; |
| 3624 | } | 3567 | } |
| 3625 | 3568 | ||
| 3626 | /* Allocate the request queue. */ | 3569 | dd->disk = blk_mq_alloc_disk(&dd->tags, dd); |
| 3627 | dd->queue = blk_mq_init_queue(&dd->tags); | 3570 | if (IS_ERR(dd->disk)) { |
| 3628 | if (IS_ERR(dd->queue)) { | ||
| 3629 | dev_err(&dd->pdev->dev, | 3571 | dev_err(&dd->pdev->dev, |
| 3630 | "Unable to allocate request queue\n"); | 3572 | "Unable to allocate request queue\n"); |
| 3631 | rv = -ENOMEM; | 3573 | rv = -ENOMEM; |
| 3632 | goto block_queue_alloc_init_error; | 3574 | goto block_queue_alloc_init_error; |
| 3633 | } | 3575 | } |
| 3576 | dd->queue = dd->disk->queue; | ||
| 3577 | |||
| 3578 | rv = ida_alloc(&rssd_index_ida, GFP_KERNEL); | ||
| 3579 | if (rv < 0) | ||
| 3580 | goto ida_get_error; | ||
| 3581 | index = rv; | ||
| 3582 | |||
| 3583 | rv = rssd_disk_name_format("rssd", | ||
| 3584 | index, | ||
| 3585 | dd->disk->disk_name, | ||
| 3586 | DISK_NAME_LEN); | ||
| 3587 | if (rv) | ||
| 3588 | goto disk_index_error; | ||
| 3589 | |||
| 3590 | dd->disk->major = dd->major; | ||
| 3591 | dd->disk->first_minor = index * MTIP_MAX_MINORS; | ||
| 3592 | dd->disk->minors = MTIP_MAX_MINORS; | ||
| 3593 | dd->disk->fops = &mtip_block_ops; | ||
| 3594 | dd->disk->private_data = dd; | ||
| 3595 | dd->index = index; | ||
| 3634 | 3596 | ||
| 3635 | dd->disk->queue = dd->queue; | 3597 | mtip_hw_debugfs_init(dd); |
| 3636 | dd->queue->queuedata = dd; | ||
| 3637 | 3598 | ||
| 3638 | skip_create_disk: | 3599 | skip_create_disk: |
| 3639 | /* Initialize the protocol layer. */ | 3600 | /* Initialize the protocol layer. */ |
| @@ -3672,17 +3633,7 @@ skip_create_disk: · 32 unmodified lines | |||
| 3672 | set_capacity(dd->disk, capacity); | 3633 | set_capacity(dd->disk, capacity); |
| 3673 | 3634 | ||
| 3674 | /* Enable the block device and add it to /dev */ | 3635 | /* Enable the block device and add it to /dev */ |
| 3675 | device_add_disk(&dd->pdev->dev, dd->disk, NULL); | 3636 | device_add_disk(&dd->pdev->dev, dd->disk, mtip_disk_attr_groups); |
| 3676 | |||
| 3677 | /* | ||
| 3678 | * Now that the disk is active, initialize any sysfs attributes | ||
| 3679 | * managed by the protocol layer. | ||
| 3680 | */ | ||
| 3681 | kobj = kobject_get(&disk_to_dev(dd->disk)->kobj); | ||
| 3682 | if (kobj) { | ||
| 3683 | mtip_hw_sysfs_init(dd, kobj); | ||
| 3684 | kobject_put(kobj); | ||
| 3685 | } | ||
| 3686 | 3637 | ||
| 3687 | if (dd->mtip_svc_handler) { | 3638 | if (dd->mtip_svc_handler) { |
| 3688 | set_bit(MTIP_DDF_INIT_DONE_BIT, &dd->dd_flag); | 3639 | set_bit(MTIP_DDF_INIT_DONE_BIT, &dd->dd_flag); |
| @@ -3709,23 +3660,17 @@ start_service_thread: · 20 unmodified lines | |||
| 3709 | kthread_run_error: | 3660 | kthread_run_error: |
| 3710 | /* Delete our gendisk. This also removes the device from /dev */ | 3661 | /* Delete our gendisk. This also removes the device from /dev */ |
| 3711 | del_gendisk(dd->disk); | 3662 | del_gendisk(dd->disk); |
| 3712 | |||
| 3713 | read_capacity_error: | 3663 | read_capacity_error: |
| 3714 | init_hw_cmds_error: | 3664 | init_hw_cmds_error: |
| 3715 | blk_cleanup_queue(dd->queue); | ||
| 3716 | block_queue_alloc_init_error: | ||
| 3717 | blk_mq_free_tag_set(&dd->tags); | ||
| 3718 | block_queue_alloc_tag_error: | ||
| 3719 | mtip_hw_debugfs_exit(dd); | 3665 | mtip_hw_debugfs_exit(dd); |
| 3720 | disk_index_error: | 3666 | disk_index_error: |
| 3721 | ida_free(&rssd_index_ida, index); | 3667 | ida_free(&rssd_index_ida, index); |
| 3722 | |||
| 3723 | ida_get_error: | 3668 | ida_get_error: |
| 3724 | put_disk(dd->disk); | 3669 | blk_cleanup_disk(dd->disk); |
| 3725 | 3670 | block_queue_alloc_init_error: | |
| 3726 | alloc_disk_error: | 3671 | blk_mq_free_tag_set(&dd->tags); |
| 3672 | block_queue_alloc_tag_error: | ||
| 3727 | mtip_hw_exit(dd); /* De-initialize the protocol layer. */ | 3673 | mtip_hw_exit(dd); /* De-initialize the protocol layer. */ |
| 3728 | |||
| 3729 | protocol_init_error: | 3674 | protocol_init_error: |
| 3730 | return rv; | 3675 | return rv; |
| 3731 | } | 3676 | } |
| @@ -3751,8 +3696,6 @@ static bool mtip_no_dev_cleanup(struct request *rq, void *data, bool reserv) · 19 unmodified lines | |||
| 3751 | */ | 3696 | */ |
| 3752 | static int mtip_block_remove(struct driver_data *dd) | 3697 | static int mtip_block_remove(struct driver_data *dd) |
| 3753 | { | 3698 | { |
| 3754 | struct kobject *kobj; | ||
| 3755 | |||
| 3756 | mtip_hw_debugfs_exit(dd); | 3699 | mtip_hw_debugfs_exit(dd); |
| 3757 | 3700 | ||
| 3758 | if (dd->mtip_svc_handler) { | 3701 | if (dd->mtip_svc_handler) { |
| @@ -3761,15 +3704,6 @@ static int mtip_block_remove(struct driver_data *dd) · 2 unmodified lines | |||
| 3761 | kthread_stop(dd->mtip_svc_handler); | 3704 | kthread_stop(dd->mtip_svc_handler); |
| 3762 | } | 3705 | } |
| 3763 | 3706 | ||
| 3764 | /* Clean up the sysfs attributes, if created */ | ||
| 3765 | if (test_bit(MTIP_DDF_INIT_DONE_BIT, &dd->dd_flag)) { | ||
| 3766 | kobj = kobject_get(&disk_to_dev(dd->disk)->kobj); | ||
| 3767 | if (kobj) { | ||
| 3768 | mtip_hw_sysfs_exit(dd, kobj); | ||
| 3769 | kobject_put(kobj); | ||
| 3770 | } | ||
| 3771 | } | ||
| 3772 | |||
| 3773 | if (!dd->sr) { | 3707 | if (!dd->sr) { |
| 3774 | /* | 3708 | /* |
| 3775 | * Explicitly wait here for IOs to quiesce, | 3709 | * Explicitly wait here for IOs to quiesce, |
| @@ -79,6 +79,7 @@ struct link_dead_args { · 78 unmodified lines | |||
| 79 | #define NBD_RT_HAS_CONFIG_REF 4 | 79 | #define NBD_RT_HAS_CONFIG_REF 4 |
| 80 | #define NBD_RT_BOUND 5 | 80 | #define NBD_RT_BOUND 5 |
| 81 | #define NBD_RT_DISCONNECT_ON_CLOSE 6 | 81 | #define NBD_RT_DISCONNECT_ON_CLOSE 6 |
| 82 | #define NBD_RT_HAS_BACKEND_FILE 7 | ||
| 82 | 83 | ||
| 83 | #define NBD_DESTROY_ON_DISCONNECT 0 | 84 | #define NBD_DESTROY_ON_DISCONNECT 0 |
| 84 | #define NBD_DISCONNECT_REQUESTED 1 | 85 | #define NBD_DISCONNECT_REQUESTED 1 |
| @@ -119,6 +120,8 @@ struct nbd_device { · 34 unmodified lines | |||
| 119 | 120 | ||
| 120 | struct completion *destroy_complete; | 121 | struct completion *destroy_complete; |
| 121 | unsigned long flags; | 122 | unsigned long flags; |
| 123 | |||
| 124 | char *backend; | ||
| 122 | }; | 125 | }; |
| 123 | 126 | ||
| 124 | #define NBD_CMD_REQUEUED 1 | 127 | #define NBD_CMD_REQUEUED 1 |
| @@ -216,6 +219,20 @@ static const struct device_attribute pid_attr = { · 91 unmodified lines | |||
| 216 | .show = pid_show, | 219 | .show = pid_show, |
| 217 | }; | 220 | }; |
| 218 | 221 | ||
| 222 | static ssize_t backend_show(struct device *dev, | ||
| 223 | struct device_attribute *attr, char *buf) | ||
| 224 | { | ||
| 225 | struct gendisk *disk = dev_to_disk(dev); | ||
| 226 | struct nbd_device *nbd = (struct nbd_device *)disk->private_data; | ||
| 227 | |||
| 228 | return sprintf(buf, "%s\n", nbd->backend ?: ""); | ||
| 229 | } | ||
| 230 | |||
| 231 | static const struct device_attribute backend_attr = { | ||
| 232 | .attr = { .name = "backend", .mode = 0444}, | ||
| 233 | .show = backend_show, | ||
| 234 | }; | ||
| 235 | |||
| 219 | static void nbd_dev_remove(struct nbd_device *nbd) | 236 | static void nbd_dev_remove(struct nbd_device *nbd) |
| 220 | { | 237 | { |
| 221 | struct gendisk *disk = nbd->disk; | 238 | struct gendisk *disk = nbd->disk; |
| @@ -1211,6 +1228,12 @@ static void nbd_config_put(struct nbd_device *nbd) · 989 unmodified lines | |||
| 1211 | &config->runtime_flags)) | 1228 | &config->runtime_flags)) |
| 1212 | device_remove_file(disk_to_dev(nbd->disk), &pid_attr); | 1229 | device_remove_file(disk_to_dev(nbd->disk), &pid_attr); |
| 1213 | nbd->task_recv = NULL; | 1230 | nbd->task_recv = NULL; |
| 1231 | if (test_and_clear_bit(NBD_RT_HAS_BACKEND_FILE, | ||
| 1232 | &config->runtime_flags)) { | ||
| 1233 | device_remove_file(disk_to_dev(nbd->disk), &backend_attr); | ||
| 1234 | kfree(nbd->backend); | ||
| 1235 | nbd->backend = NULL; | ||
| 1236 | } | ||
| 1214 | nbd_clear_sock(nbd); | 1237 | nbd_clear_sock(nbd); |
| 1215 | if (config->num_connections) { | 1238 | if (config->num_connections) { |
| 1216 | int i; | 1239 | int i; |
| @@ -1270,7 +1293,7 @@ static int nbd_start_device(struct nbd_device *nbd) · 53 unmodified lines | |||
| 1270 | 1293 | ||
| 1271 | error = device_create_file(disk_to_dev(nbd->disk), &pid_attr); | 1294 | error = device_create_file(disk_to_dev(nbd->disk), &pid_attr); |
| 1272 | if (error) { | 1295 | if (error) { |
| 1273 | dev_err(disk_to_dev(nbd->disk), "device_create_file failed!\n"); | 1296 | dev_err(disk_to_dev(nbd->disk), "device_create_file failed for pid!\n"); |
| 1274 | return error; | 1297 | return error; |
| 1275 | } | 1298 | } |
| 1276 | set_bit(NBD_RT_HAS_PID_FILE, &config->runtime_flags); | 1299 | set_bit(NBD_RT_HAS_PID_FILE, &config->runtime_flags); |
| @@ -1657,6 +1680,7 @@ static int nbd_dev_add(int index) · 380 unmodified lines | |||
| 1657 | BLK_MQ_F_BLOCKING; | 1680 | BLK_MQ_F_BLOCKING; |
| 1658 | nbd->tag_set.driver_data = nbd; | 1681 | nbd->tag_set.driver_data = nbd; |
| 1659 | nbd->destroy_complete = NULL; | 1682 | nbd->destroy_complete = NULL; |
| 1683 | nbd->backend = NULL; | ||
| 1660 | 1684 | ||
| 1661 | err = blk_mq_alloc_tag_set(&nbd->tag_set); | 1685 | err = blk_mq_alloc_tag_set(&nbd->tag_set); |
| 1662 | if (err) | 1686 | if (err) |
| @@ -1743,6 +1767,7 @@ static const struct nla_policy nbd_attr_policy[NBD_ATTR_MAX + 1] = { · 80 unmodified lines | |||
| 1743 | [NBD_ATTR_SOCKETS] = { .type = NLA_NESTED}, | 1767 | [NBD_ATTR_SOCKETS] = { .type = NLA_NESTED}, |
| 1744 | [NBD_ATTR_DEAD_CONN_TIMEOUT] = { .type = NLA_U64 }, | 1768 | [NBD_ATTR_DEAD_CONN_TIMEOUT] = { .type = NLA_U64 }, |
| 1745 | [NBD_ATTR_DEVICE_LIST] = { .type = NLA_NESTED}, | 1769 | [NBD_ATTR_DEVICE_LIST] = { .type = NLA_NESTED}, |
| 1770 | [NBD_ATTR_BACKEND_IDENTIFIER] = { .type = NLA_STRING}, | ||
| 1746 | }; | 1771 | }; |
| 1747 | 1772 | ||
| 1748 | static const struct nla_policy nbd_sock_policy[NBD_SOCK_MAX + 1] = { | 1773 | static const struct nla_policy nbd_sock_policy[NBD_SOCK_MAX + 1] = { |
| @@ -1945,6 +1970,23 @@ again: · 196 unmodified lines | |||
| 1945 | } | 1970 | } |
| 1946 | } | 1971 | } |
| 1947 | ret = nbd_start_device(nbd); | 1972 | ret = nbd_start_device(nbd); |
| 1973 | if (ret) | ||
| 1974 | goto out; | ||
| 1975 | if (info->attrs[NBD_ATTR_BACKEND_IDENTIFIER]) { | ||
| 1976 | nbd->backend = nla_strdup(info->attrs[NBD_ATTR_BACKEND_IDENTIFIER], | ||
| 1977 | GFP_KERNEL); | ||
| 1978 | if (!nbd->backend) { | ||
| 1979 | ret = -ENOMEM; | ||
| 1980 | goto out; | ||
| 1981 | } | ||
| 1982 | } | ||
| 1983 | ret = device_create_file(disk_to_dev(nbd->disk), &backend_attr); | ||
| 1984 | if (ret) { | ||
| 1985 | dev_err(disk_to_dev(nbd->disk), | ||
| 1986 | "device_create_file failed for backend!\n"); | ||
| 1987 | goto out; | ||
| 1988 | } | ||
| 1989 | set_bit(NBD_RT_HAS_BACKEND_FILE, &config->runtime_flags); | ||
| 1948 | out: | 1990 | out: |
| 1949 | mutex_unlock(&nbd->config_lock); | 1991 | mutex_unlock(&nbd->config_lock); |
| 1950 | if (!ret) { | 1992 | if (!ret) { |
| @@ -2037,6 +2079,22 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info) · 86 unmodified lines | |||
| 2037 | index); | 2079 | index); |
| 2038 | return -EINVAL; | 2080 | return -EINVAL; |
| 2039 | } | 2081 | } |
| 2082 | if (nbd->backend) { | ||
| 2083 | if (info->attrs[NBD_ATTR_BACKEND_IDENTIFIER]) { | ||
| 2084 | if (nla_strcmp(info->attrs[NBD_ATTR_BACKEND_IDENTIFIER], | ||
| 2085 | nbd->backend)) { | ||
| 2086 | mutex_unlock(&nbd_index_mutex); | ||
| 2087 | dev_err(nbd_to_dev(nbd), | ||
| 2088 | "backend image doesn't match with %s\n", | ||
| 2089 | nbd->backend); | ||
| 2090 | return -EINVAL; | ||
| 2091 | } | ||
| 2092 | } else { | ||
| 2093 | mutex_unlock(&nbd_index_mutex); | ||
| 2094 | dev_err(nbd_to_dev(nbd), "must specify backend\n"); | ||
| 2095 | return -EINVAL; | ||
| 2096 | } | ||
| 2097 | } | ||
| 2040 | if (!refcount_inc_not_zero(&nbd->refs)) { | 2098 | if (!refcount_inc_not_zero(&nbd->refs)) { |
| 2041 | mutex_unlock(&nbd_index_mutex); | 2099 | mutex_unlock(&nbd_index_mutex); |
| 2042 | printk(KERN_ERR "nbd: device at index %d is going down\n", | 2100 | printk(KERN_ERR "nbd: device at index %d is going down\n", |
| @@ -1849,7 +1849,6 @@ static int null_add_dev(struct nullb_device *dev) · 1848 unmodified lines | |||
| 1849 | if (!null_setup_fault()) | 1849 | if (!null_setup_fault()) |
| 1850 | goto out_cleanup_tags; | 1850 | goto out_cleanup_tags; |
| 1851 | 1851 | ||
| 1852 | rv = -ENOMEM; | ||
| 1853 | nullb->tag_set->timeout = 5 * HZ; | 1852 | nullb->tag_set->timeout = 5 * HZ; |
| 1854 | nullb->disk = blk_mq_alloc_disk(nullb->tag_set, nullb); | 1853 | nullb->disk = blk_mq_alloc_disk(nullb->tag_set, nullb); |
| 1855 | if (IS_ERR(nullb->disk)) { | 1854 | if (IS_ERR(nullb->disk)) { |
| @@ -704,7 +704,7 @@ static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command * · 703 unmodified lines | |||
| 704 | int ret = 0; | 704 | int ret = 0; |
| 705 | 705 | ||
| 706 | rq = blk_get_request(q, (cgc->data_direction == CGC_DATA_WRITE) ? | 706 | rq = blk_get_request(q, (cgc->data_direction == CGC_DATA_WRITE) ? |
| 707 | REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, 0); | 707 | REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0); |
| 708 | if (IS_ERR(rq)) | 708 | if (IS_ERR(rq)) |
| 709 | return PTR_ERR(rq); | 709 | return PTR_ERR(rq); |
| 710 | 710 | ||
| @@ -2186,7 +2186,7 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf, · 2185 unmodified lines | |||
| 2186 | 2186 | ||
| 2187 | len = nr * CD_FRAMESIZE_RAW; | 2187 | len = nr * CD_FRAMESIZE_RAW; |
| 2188 | 2188 | ||
| 2189 | rq = blk_get_request(q, REQ_OP_SCSI_IN, 0); | 2189 | rq = blk_get_request(q, REQ_OP_DRV_IN, 0); |
| 2190 | if (IS_ERR(rq)) { | 2190 | if (IS_ERR(rq)) { |
| 2191 | ret = PTR_ERR(rq); | 2191 | ret = PTR_ERR(rq); |
| 2192 | break; | 2192 | break; |
| @@ -202,7 +202,7 @@ static void mmc_blk_put(struct mmc_blk_data *md) · 201 unmodified lines | |||
| 202 | md->usage--; | 202 | md->usage--; |
| 203 | if (md->usage == 0) { | 203 | if (md->usage == 0) { |
| 204 | int devidx = mmc_get_devidx(md->disk); | 204 | int devidx = mmc_get_devidx(md->disk); |
| 205 | blk_put_queue(md->queue.queue); | 205 | |
| 206 | ida_simple_remove(&mmc_blk_ida, devidx); | 206 | ida_simple_remove(&mmc_blk_ida, devidx); |
| 207 | put_disk(md->disk); | 207 | put_disk(md->disk); |
| 208 | kfree(md); | 208 | kfree(md); |
| @@ -2319,39 +2319,22 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, · 2110 unmodified lines | |||
| 2319 | */ | 2319 | */ |
| 2320 | md->read_only = mmc_blk_readonly(card); | 2320 | md->read_only = mmc_blk_readonly(card); |
| 2321 | 2321 | ||
| 2322 | md->disk = alloc_disk(perdev_minors); | 2322 | md->disk = mmc_init_queue(&md->queue, card); |
| 2323 | if (md->disk == NULL) { | 2323 | if (IS_ERR(md->disk)) { |
| 2324 | ret = -ENOMEM; | 2324 | ret = PTR_ERR(md->disk); |
| 2325 | goto err_kfree; | 2325 | goto err_kfree; |
| 2326 | } | 2326 | } |
| 2327 | 2327 | ||
| 2328 | INIT_LIST_HEAD(&md->part); | 2328 | INIT_LIST_HEAD(&md->part); |
| 2329 | INIT_LIST_HEAD(&md->rpmbs); | 2329 | INIT_LIST_HEAD(&md->rpmbs); |
| 2330 | md->usage = 1; | 2330 | md->usage = 1; |
| 2331 | |||
| 2332 | ret = mmc_init_queue(&md->queue, card); | ||
| 2333 | if (ret) | ||
| 2334 | goto err_putdisk; | ||
| 2335 | |||
| 2336 | md->queue.blkdata = md; | 2331 | md->queue.blkdata = md; |
| 2337 | 2332 | ||
| 2338 | /* | ||
| 2339 | * Keep an extra reference to the queue so that we can shutdown the | ||
| 2340 | * queue (i.e. call blk_cleanup_queue()) while there are still | ||
| 2341 | * references to the 'md'. The corresponding blk_put_queue() is in | ||
| 2342 | * mmc_blk_put(). | ||
| 2343 | */ | ||
| 2344 | if (!blk_get_queue(md->queue.queue)) { | ||
| 2345 | mmc_cleanup_queue(&md->queue); | ||
| 2346 | ret = -ENODEV; | ||
| 2347 | goto err_putdisk; | ||
| 2348 | } | ||
| 2349 | |||
| 2350 | md->disk->major = MMC_BLOCK_MAJOR; | 2333 | md->disk->major = MMC_BLOCK_MAJOR; |
| 2334 | md->disk->minors = perdev_minors; | ||
| 2351 | md->disk->first_minor = devidx * perdev_minors; | 2335 | md->disk->first_minor = devidx * perdev_minors; |
| 2352 | md->disk->fops = &mmc_bdops; | 2336 | md->disk->fops = &mmc_bdops; |
| 2353 | md->disk->private_data = md; | 2337 | md->disk->private_data = md; |
| 2354 | md->disk->queue = md->queue.queue; | ||
| 2355 | md->parent = parent; | 2338 | md->parent = parent; |
| 2356 | set_disk_ro(md->disk, md->read_only || default_ro); | 2339 | set_disk_ro(md->disk, md->read_only || default_ro); |
| 2357 | md->disk->flags = GENHD_FL_EXT_DEVT; | 2340 | md->disk->flags = GENHD_FL_EXT_DEVT; |
| @@ -2400,8 +2383,6 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, · 42 unmodified lines | |||
| 2400 | 2383 | ||
| 2401 | return md; | 2384 | return md; |
| 2402 | 2385 | ||
| 2403 | err_putdisk: | ||
| 2404 | put_disk(md->disk); | ||
| 2405 | err_kfree: | 2386 | err_kfree: |
| 2406 | kfree(md); | 2387 | kfree(md); |
| 2407 | out: | 2388 | out: |
| @@ -424,9 +424,10 @@ static inline bool mmc_merge_capable(struct mmc_host *host) · 423 unmodified lines | |||
| 424 | * | 424 | * |
| 425 | * Initialise a MMC card request queue. | 425 | * Initialise a MMC card request queue. |
| 426 | */ | 426 | */ |
| 427 | int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card) | 427 | struct gendisk *mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card) |
| 428 | { | 428 | { |
| 429 | struct mmc_host *host = card->host; | 429 | struct mmc_host *host = card->host; |
| 430 | struct gendisk *disk; | ||
| 430 | int ret; | 431 | int ret; |
| 431 | 432 | ||
| 432 | mq->card = card; | 433 | mq->card = card; |
| @@ -464,26 +465,22 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card) · 31 unmodified lines | |||
| 464 | 465 | ||
| 465 | ret = blk_mq_alloc_tag_set(&mq->tag_set); | 466 | ret = blk_mq_alloc_tag_set(&mq->tag_set); |
| 466 | if (ret) | 467 | if (ret) |
| 467 | return ret; | 468 | return ERR_PTR(ret); |
| 469 | |||
| 468 | 470 | ||
| 469 | mq->queue = blk_mq_init_queue(&mq->tag_set); | 471 | disk = blk_mq_alloc_disk(&mq->tag_set, mq); |
| 470 | if (IS_ERR(mq->queue)) { | 472 | if (IS_ERR(disk)) { |
| 471 | ret = PTR_ERR(mq->queue); | 473 | blk_mq_free_tag_set(&mq->tag_set); |
| 472 | goto free_tag_set; | 474 | return disk; |
| 473 | } | 475 | } |
| 476 | mq->queue = disk->queue; | ||
| 474 | 477 | ||
| 475 | if (mmc_host_is_spi(host) && host->use_spi_crc) | 478 | if (mmc_host_is_spi(host) && host->use_spi_crc) |
| 476 | blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, mq->queue); | 479 | blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, mq->queue); |
| 477 | |||
| 478 | mq->queue->queuedata = mq; | ||
| 479 | blk_queue_rq_timeout(mq->queue, 60 * HZ); | 480 | blk_queue_rq_timeout(mq->queue, 60 * HZ); |
| 480 | 481 | ||
| 481 | mmc_setup_queue(mq, card); | 482 | mmc_setup_queue(mq, card); |
| 482 | return 0; | 483 | return disk; |
| 483 | |||
| 484 | free_tag_set: | ||
| 485 | blk_mq_free_tag_set(&mq->tag_set); | ||
| 486 | return ret; | ||
| 487 | } | 484 | } |
| 488 | 485 | ||
| 489 | void mmc_queue_suspend(struct mmc_queue *mq) | 486 | void mmc_queue_suspend(struct mmc_queue *mq) |
| @@ -94,7 +94,7 @@ struct mmc_queue { · 93 unmodified lines | |||
| 94 | struct work_struct complete_work; | 94 | struct work_struct complete_work; |
| 95 | }; | 95 | }; |
| 96 | 96 | ||
| 97 | extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *); | 97 | struct gendisk *mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card); |
| 98 | extern void mmc_cleanup_queue(struct mmc_queue *); | 98 | extern void mmc_cleanup_queue(struct mmc_queue *); |
| 99 | extern void mmc_queue_suspend(struct mmc_queue *); | 99 | extern void mmc_queue_suspend(struct mmc_queue *); |
| 100 | extern void mmc_queue_resume(struct mmc_queue *); | 100 | extern void mmc_queue_resume(struct mmc_queue *); |
| @@ -609,6 +609,7 @@ EXPORT_SYMBOL_NS_GPL(nvme_put_ns, NVME_TARGET_PASSTHRU); · 608 unmodified lines | |||
| 609 | 609 | ||
| 610 | static inline void nvme_clear_nvme_request(struct request *req) | 610 | static inline void nvme_clear_nvme_request(struct request *req) |
| 611 | { | 611 | { |
| 612 | nvme_req(req)->status = 0; | ||
| 612 | nvme_req(req)->retries = 0; | 613 | nvme_req(req)->retries = 0; |
| 613 | nvme_req(req)->flags = 0; | 614 | nvme_req(req)->flags = 0; |
| 614 | req->rq_flags |= RQF_DONTPREP; | 615 | req->rq_flags |= RQF_DONTPREP; |
| @@ -631,6 +632,8 @@ static inline void nvme_init_request(struct request *req, · 16 unmodified lines | |||
| 631 | cmd->common.flags &= ~NVME_CMD_SGL_ALL; | 632 | cmd->common.flags &= ~NVME_CMD_SGL_ALL; |
| 632 | 633 | ||
| 633 | req->cmd_flags |= REQ_FAILFAST_DRIVER; | 634 | req->cmd_flags |= REQ_FAILFAST_DRIVER; |
| 635 | if (req->mq_hctx->type == HCTX_TYPE_POLL) | ||
| 636 | req->cmd_flags |= REQ_HIPRI; | ||
| 634 | nvme_clear_nvme_request(req); | 637 | nvme_clear_nvme_request(req); |
| 635 | memcpy(nvme_req(req)->cmd, cmd, sizeof(*cmd)); | 638 | memcpy(nvme_req(req)->cmd, cmd, sizeof(*cmd)); |
| 636 | } | 639 | } |
| @@ -1029,29 +1032,23 @@ blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req) · 392 unmodified lines | |||
| 1029 | } | 1032 | } |
| 1030 | EXPORT_SYMBOL_GPL(nvme_setup_cmd); | 1033 | EXPORT_SYMBOL_GPL(nvme_setup_cmd); |
| 1031 | 1034 | ||
| 1032 | static void nvme_end_sync_rq(struct request *rq, blk_status_t error) | 1035 | /* |
| 1036 | * Return values: | ||
| 1037 | * 0: success | ||
| 1038 | * >0: nvme controller's cqe status response | ||
| 1039 | * <0: kernel error in lieu of controller response | ||
| 1040 | */ | ||
| 1041 | static int nvme_execute_rq(struct gendisk *disk, struct request *rq, | ||
| 1042 | bool at_head) | ||
| 1033 | { | 1043 | { |
| 1034 | struct completion *waiting = rq->end_io_data; | 1044 | blk_status_t status; |
| 1035 | 1045 | ||
| 1036 | rq->end_io_data = NULL; | 1046 | status = blk_execute_rq(disk, rq, at_head); |
| 1037 | complete(waiting); | 1047 | if (nvme_req(rq)->flags & NVME_REQ_CANCELLED) |
| 1038 | } | 1048 | return -EINTR; |
| 1039 | 1049 | if (nvme_req(rq)->status) | |
| 1040 | static void nvme_execute_rq_polled(struct request_queue *q, | 1050 | return nvme_req(rq)->status; |
| 1041 | struct gendisk *bd_disk, struct request *rq, int at_head) | 1051 | return blk_status_to_errno(status); |
| 1042 | { | ||
| 1043 | DECLARE_COMPLETION_ONSTACK(wait); | ||
| 1044 | |||
| 1045 | WARN_ON_ONCE(!test_bit(QUEUE_FLAG_POLL, &q->queue_flags)); | ||
| 1046 | |||
| 1047 | rq->cmd_flags |= REQ_HIPRI; | ||
| 1048 | rq->end_io_data = &wait; | ||
| 1049 | blk_execute_rq_nowait(bd_disk, rq, at_head, nvme_end_sync_rq); | ||
| 1050 | |||
| 1051 | while (!completion_done(&wait)) { | ||
| 1052 | blk_poll(q, request_to_qc_t(rq->mq_hctx, rq), true); | ||
| 1053 | cond_resched(); | ||
| 1054 | } | ||
| 1055 | } | 1052 | } |
| 1056 | 1053 | ||
| 1057 | /* | 1054 | /* |
| @@ -1061,7 +1058,7 @@ static void nvme_execute_rq_polled(struct request_queue *q, · 3 unmodified lines | |||
| 1061 | int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, | 1058 | int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, |
| 1062 | union nvme_result *result, void *buffer, unsigned bufflen, | 1059 | union nvme_result *result, void *buffer, unsigned bufflen, |
| 1063 | unsigned timeout, int qid, int at_head, | 1060 | unsigned timeout, int qid, int at_head, |
| 1064 | blk_mq_req_flags_t flags, bool poll) | 1061 | blk_mq_req_flags_t flags) |
| 1065 | { | 1062 | { |
| 1066 | struct request *req; | 1063 | struct request *req; |
| 1067 | int ret; | 1064 | int ret; |
| @@ -1082,16 +1079,9 @@ int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, · 14 unmodified lines | |||
| 1082 | goto out; | 1079 | goto out; |
| 1083 | } | 1080 | } |
| 1084 | 1081 | ||
| 1085 | if (poll) | 1082 | ret = nvme_execute_rq(NULL, req, at_head); |
| 1086 | nvme_execute_rq_polled(req->q, NULL, req, at_head); | 1083 | if (result && ret >= 0) |
| 1087 | else | ||
| 1088 | blk_execute_rq(NULL, req, at_head); | ||
| 1089 | if (result) | ||
| 1090 | *result = nvme_req(req)->result; | 1084 | *result = nvme_req(req)->result; |
| 1091 | if (nvme_req(req)->flags & NVME_REQ_CANCELLED) | ||
| 1092 | ret = -EINTR; | ||
| 1093 | else | ||
| 1094 | ret = nvme_req(req)->status; | ||
| 1095 | out: | 1085 | out: |
| 1096 | blk_mq_free_request(req); | 1086 | blk_mq_free_request(req); |
| 1097 | return ret; | 1087 | return ret; |
| @@ -1102,7 +1092,7 @@ int nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, · 4 unmodified lines | |||
| 1102 | void *buffer, unsigned bufflen) | 1092 | void *buffer, unsigned bufflen) |
| 1103 | { | 1093 | { |
| 1104 | return __nvme_submit_sync_cmd(q, cmd, NULL, buffer, bufflen, 0, | 1094 | return __nvme_submit_sync_cmd(q, cmd, NULL, buffer, bufflen, 0, |
| 1105 | NVME_QID_ANY, 0, 0, false); | 1095 | NVME_QID_ANY, 0, 0); |
| 1106 | } | 1096 | } |
| 1107 | EXPORT_SYMBOL_GPL(nvme_submit_sync_cmd); | 1097 | EXPORT_SYMBOL_GPL(nvme_submit_sync_cmd); |
| 1108 | 1098 | ||
| @@ -1179,18 +1169,21 @@ static void nvme_passthru_end(struct nvme_ctrl *ctrl, u32 effects) · 70 unmodified lines | |||
| 1179 | } | 1169 | } |
| 1180 | } | 1170 | } |
| 1181 | 1171 | ||
| 1182 | void nvme_execute_passthru_rq(struct request *rq) | 1172 | int nvme_execute_passthru_rq(struct request *rq) |
| 1183 | { | 1173 | { |
| 1184 | struct nvme_command *cmd = nvme_req(rq)->cmd; | 1174 | struct nvme_command *cmd = nvme_req(rq)->cmd; |
| 1185 | struct nvme_ctrl *ctrl = nvme_req(rq)->ctrl; | 1175 | struct nvme_ctrl *ctrl = nvme_req(rq)->ctrl; |
| 1186 | struct nvme_ns *ns = rq->q->queuedata; | 1176 | struct nvme_ns *ns = rq->q->queuedata; |
| 1187 | struct gendisk *disk = ns ? ns->disk : NULL; | 1177 | struct gendisk *disk = ns ? ns->disk : NULL; |
| 1188 | u32 effects; | 1178 | u32 effects; |
| 1179 | int ret; | ||
| 1189 | 1180 | ||
| 1190 | effects = nvme_passthru_start(ctrl, ns, cmd->common.opcode); | 1181 | effects = nvme_passthru_start(ctrl, ns, cmd->common.opcode); |
| 1191 | blk_execute_rq(disk, rq, 0); | 1182 | ret = nvme_execute_rq(disk, rq, false); |
| 1192 | if (effects) /* nothing to be done for zero cmd effects */ | 1183 | if (effects) /* nothing to be done for zero cmd effects */ |
| 1193 | nvme_passthru_end(ctrl, effects); | 1184 | nvme_passthru_end(ctrl, effects); |
| 1185 | |||
| 1186 | return ret; | ||
| 1194 | } | 1187 | } |
| 1195 | EXPORT_SYMBOL_NS_GPL(nvme_execute_passthru_rq, NVME_TARGET_PASSTHRU); | 1188 | EXPORT_SYMBOL_NS_GPL(nvme_execute_passthru_rq, NVME_TARGET_PASSTHRU); |
| 1196 | 1189 | ||
| @@ -1465,7 +1458,7 @@ static int nvme_features(struct nvme_ctrl *dev, u8 op, unsigned int fid, · 268 unmodified lines | |||
| 1465 | c.features.dword11 = cpu_to_le32(dword11); | 1458 | c.features.dword11 = cpu_to_le32(dword11); |
| 1466 | 1459 | ||
| 1467 | ret = __nvme_submit_sync_cmd(dev->admin_q, &c, &res, | 1460 | ret = __nvme_submit_sync_cmd(dev->admin_q, &c, &res, |
| 1468 | buffer, buflen, 0, NVME_QID_ANY, 0, 0, false); | 1461 | buffer, buflen, 0, NVME_QID_ANY, 0, 0); |
| 1469 | if (ret >= 0 && result) | 1462 | if (ret >= 0 && result) |
| 1470 | *result = le32_to_cpu(res.u32); | 1463 | *result = le32_to_cpu(res.u32); |
| 1471 | return ret; | 1464 | return ret; |
| @@ -2047,7 +2040,7 @@ int nvme_sec_submit(void *data, u16 spsp, u8 secp, void *buffer, size_t len, · 575 unmodified lines | |||
| 2047 | cmd.common.cdw11 = cpu_to_le32(len); | 2040 | cmd.common.cdw11 = cpu_to_le32(len); |
| 2048 | 2041 | ||
| 2049 | return __nvme_submit_sync_cmd(ctrl->admin_q, &cmd, NULL, buffer, len, 0, | 2042 | return __nvme_submit_sync_cmd(ctrl->admin_q, &cmd, NULL, buffer, len, 0, |
| 2050 | NVME_QID_ANY, 1, 0, false); | 2043 | NVME_QID_ANY, 1, 0); |
| 2051 | } | 2044 | } |
| 2052 | EXPORT_SYMBOL_GPL(nvme_sec_submit); | 2045 | EXPORT_SYMBOL_GPL(nvme_sec_submit); |
| 2053 | #endif /* CONFIG_BLK_SED_OPAL */ | 2046 | #endif /* CONFIG_BLK_SED_OPAL */ |
| @@ -154,7 +154,7 @@ int nvmf_reg_read32(struct nvme_ctrl *ctrl, u32 off, u32 *val) · 153 unmodified lines | |||
| 154 | cmd.prop_get.offset = cpu_to_le32(off); | 154 | cmd.prop_get.offset = cpu_to_le32(off); |
| 155 | 155 | ||
| 156 | ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, &res, NULL, 0, 0, | 156 | ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, &res, NULL, 0, 0, |
| 157 | NVME_QID_ANY, 0, 0, false); | 157 | NVME_QID_ANY, 0, 0); |
| 158 | 158 | ||
| 159 | if (ret >= 0) | 159 | if (ret >= 0) |
| 160 | *val = le64_to_cpu(res.u64); | 160 | *val = le64_to_cpu(res.u64); |
| @@ -200,7 +200,7 @@ int nvmf_reg_read64(struct nvme_ctrl *ctrl, u32 off, u64 *val) · 39 unmodified lines | |||
| 200 | cmd.prop_get.offset = cpu_to_le32(off); | 200 | cmd.prop_get.offset = cpu_to_le32(off); |
| 201 | 201 | ||
| 202 | ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, &res, NULL, 0, 0, | 202 | ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, &res, NULL, 0, 0, |
| 203 | NVME_QID_ANY, 0, 0, false); | 203 | NVME_QID_ANY, 0, 0); |
| 204 | 204 | ||
| 205 | if (ret >= 0) | 205 | if (ret >= 0) |
| 206 | *val = le64_to_cpu(res.u64); | 206 | *val = le64_to_cpu(res.u64); |
| @@ -245,7 +245,7 @@ int nvmf_reg_write32(struct nvme_ctrl *ctrl, u32 off, u32 val) · 38 unmodified lines | |||
| 245 | cmd.prop_set.value = cpu_to_le64(val); | 245 | cmd.prop_set.value = cpu_to_le64(val); |
| 246 | 246 | ||
| 247 | ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, NULL, NULL, 0, 0, | 247 | ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, NULL, NULL, 0, 0, |
| 248 | NVME_QID_ANY, 0, 0, false); | 248 | NVME_QID_ANY, 0, 0); |
| 249 | if (unlikely(ret)) | 249 | if (unlikely(ret)) |
| 250 | dev_err(ctrl->device, | 250 | dev_err(ctrl->device, |
| 251 | "Property Set error: %d, offset %#x\n", | 251 | "Property Set error: %d, offset %#x\n", |
| @@ -391,7 +391,7 @@ int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl) · 139 unmodified lines | |||
| 391 | 391 | ||
| 392 | ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, &res, | 392 | ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, &res, |
| 393 | data, sizeof(*data), 0, NVME_QID_ANY, 1, | 393 | data, sizeof(*data), 0, NVME_QID_ANY, 1, |
| 394 | BLK_MQ_REQ_RESERVED | BLK_MQ_REQ_NOWAIT, false); | 394 | BLK_MQ_REQ_RESERVED | BLK_MQ_REQ_NOWAIT); |
| 395 | if (ret) { | 395 | if (ret) { |
| 396 | nvmf_log_connect_error(ctrl, ret, le32_to_cpu(res.u32), | 396 | nvmf_log_connect_error(ctrl, ret, le32_to_cpu(res.u32), |
| 397 | &cmd, data); | 397 | &cmd, data); |
| @@ -415,7 +415,6 @@ EXPORT_SYMBOL_GPL(nvmf_connect_admin_queue); · 17 unmodified lines | |||
| 415 | * @qid: NVMe I/O queue number for the new I/O connection between | 415 | * @qid: NVMe I/O queue number for the new I/O connection between |
| 416 | * host and target (note qid == 0 is illegal as this is | 416 | * host and target (note qid == 0 is illegal as this is |
| 417 | * the Admin queue, per NVMe standard). | 417 | * the Admin queue, per NVMe standard). |
| 418 | * @poll: Whether or not to poll for the completion of the connect cmd. | ||
| 419 | * | 418 | * |
| 420 | * This function issues a fabrics-protocol connection | 419 | * This function issues a fabrics-protocol connection |
| 421 | * of a NVMe I/O queue (via NVMe Fabrics "Connect" command) | 420 | * of a NVMe I/O queue (via NVMe Fabrics "Connect" command) |
| @@ -427,7 +426,7 @@ EXPORT_SYMBOL_GPL(nvmf_connect_admin_queue); · 5 unmodified lines | |||
| 427 | * > 0: NVMe error status code | 426 | * > 0: NVMe error status code |
| 428 | * < 0: Linux errno error code | 427 | * < 0: Linux errno error code |
| 429 | */ | 428 | */ |
| 430 | int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid, bool poll) | 429 | int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid) |
| 431 | { | 430 | { |
| 432 | struct nvme_command cmd = { }; | 431 | struct nvme_command cmd = { }; |
| 433 | struct nvmf_connect_data *data; | 432 | struct nvmf_connect_data *data; |
| @@ -453,7 +452,7 @@ int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid, bool poll) · 19 unmodified lines | |||
| 453 | 452 | ||
| 454 | ret = __nvme_submit_sync_cmd(ctrl->connect_q, &cmd, &res, | 453 | ret = __nvme_submit_sync_cmd(ctrl->connect_q, &cmd, &res, |
| 455 | data, sizeof(*data), 0, qid, 1, | 454 | data, sizeof(*data), 0, qid, 1, |
| 456 | BLK_MQ_REQ_RESERVED | BLK_MQ_REQ_NOWAIT, poll); | 455 | BLK_MQ_REQ_RESERVED | BLK_MQ_REQ_NOWAIT); |
| 457 | if (ret) { | 456 | if (ret) { |
| 458 | nvmf_log_connect_error(ctrl, ret, le32_to_cpu(res.u32), | 457 | nvmf_log_connect_error(ctrl, ret, le32_to_cpu(res.u32), |
| 459 | &cmd, data); | 458 | &cmd, data); |
| @@ -182,7 +182,7 @@ int nvmf_reg_read32(struct nvme_ctrl *ctrl, u32 off, u32 *val); · 181 unmodified lines | |||
| 182 | int nvmf_reg_read64(struct nvme_ctrl *ctrl, u32 off, u64 *val); | 182 | int nvmf_reg_read64(struct nvme_ctrl *ctrl, u32 off, u64 *val); |
| 183 | int nvmf_reg_write32(struct nvme_ctrl *ctrl, u32 off, u32 val); | 183 | int nvmf_reg_write32(struct nvme_ctrl *ctrl, u32 off, u32 val); |
| 184 | int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl); | 184 | int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl); |
| 185 | int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid, bool poll); | 185 | int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid); |
| 186 | int nvmf_register_transport(struct nvmf_transport_ops *ops); | 186 | int nvmf_register_transport(struct nvmf_transport_ops *ops); |
| 187 | void nvmf_unregister_transport(struct nvmf_transport_ops *ops); | 187 | void nvmf_unregister_transport(struct nvmf_transport_ops *ops); |
| 188 | void nvmf_free_options(struct nvmf_ctrl_options *opts); | 188 | void nvmf_free_options(struct nvmf_ctrl_options *opts); |
| @@ -2346,7 +2346,7 @@ nvme_fc_connect_io_queues(struct nvme_fc_ctrl *ctrl, u16 qsize) · 2345 unmodified lines | |||
| 2346 | (qsize / 5)); | 2346 | (qsize / 5)); |
| 2347 | if (ret) | 2347 | if (ret) |
| 2348 | break; | 2348 | break; |
| 2349 | ret = nvmf_connect_io_queue(&ctrl->ctrl, i, false); | 2349 | ret = nvmf_connect_io_queue(&ctrl->ctrl, i); |
| 2350 | if (ret) | 2350 | if (ret) |
| 2351 | break; | 2351 | break; |
| 2352 | 2352 | ||
| @@ -93,11 +93,7 @@ static int nvme_submit_user_cmd(struct request_queue *q, · 92 unmodified lines | |||
| 93 | } | 93 | } |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | nvme_execute_passthru_rq(req); | 96 | ret = nvme_execute_passthru_rq(req); |
| 97 | if (nvme_req(req)->flags & NVME_REQ_CANCELLED) | ||
| 98 | ret = -EINTR; | ||
| 99 | else | ||
| 100 | ret = nvme_req(req)->status; | ||
| 101 | if (result) | 97 | if (result) |
| 102 | *result = le64_to_cpu(nvme_req(req)->result.u64); | 98 | *result = le64_to_cpu(nvme_req(req)->result.u64); |
| 103 | if (meta && !ret && !write) { | 99 | if (meta && !ret && !write) { |
| @@ -658,7 +658,7 @@ int nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, · 657 unmodified lines | |||
| 658 | int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, | 658 | int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, |
| 659 | union nvme_result *result, void *buffer, unsigned bufflen, | 659 | union nvme_result *result, void *buffer, unsigned bufflen, |
| 660 | unsigned timeout, int qid, int at_head, | 660 | unsigned timeout, int qid, int at_head, |
| 661 | blk_mq_req_flags_t flags, bool poll); | 661 | blk_mq_req_flags_t flags); |
| 662 | int nvme_set_features(struct nvme_ctrl *dev, unsigned int fid, | 662 | int nvme_set_features(struct nvme_ctrl *dev, unsigned int fid, |
| 663 | unsigned int dword11, void *buffer, size_t buflen, | 663 | unsigned int dword11, void *buffer, size_t buflen, |
| 664 | u32 *result); | 664 | u32 *result); |
| @@ -876,7 +876,7 @@ static inline bool nvme_ctrl_sgl_supported(struct nvme_ctrl *ctrl) · 211 unmodified lines | |||
| 876 | 876 | ||
| 877 | u32 nvme_command_effects(struct nvme_ctrl *ctrl, struct nvme_ns *ns, | 877 | u32 nvme_command_effects(struct nvme_ctrl *ctrl, struct nvme_ns *ns, |
| 878 | u8 opcode); | 878 | u8 opcode); |
| 879 | void nvme_execute_passthru_rq(struct request *rq); | 879 | int nvme_execute_passthru_rq(struct request *rq); |
| 880 | struct nvme_ctrl *nvme_ctrl_from_file(struct file *file); | 880 | struct nvme_ctrl *nvme_ctrl_from_file(struct file *file); |
| 881 | struct nvme_ns *nvme_find_get_ns(struct nvme_ctrl *ctrl, unsigned nsid); | 881 | struct nvme_ns *nvme_find_get_ns(struct nvme_ctrl *ctrl, unsigned nsid); |
| 882 | void nvme_put_ns(struct nvme_ns *ns); | 882 | void nvme_put_ns(struct nvme_ns *ns); |
| @@ -680,11 +680,10 @@ static void nvme_rdma_stop_io_queues(struct nvme_rdma_ctrl *ctrl) · 679 unmodified lines | |||
| 680 | static int nvme_rdma_start_queue(struct nvme_rdma_ctrl *ctrl, int idx) | 680 | static int nvme_rdma_start_queue(struct nvme_rdma_ctrl *ctrl, int idx) |
| 681 | { | 681 | { |
| 682 | struct nvme_rdma_queue *queue = &ctrl->queues[idx]; | 682 | struct nvme_rdma_queue *queue = &ctrl->queues[idx]; |
| 683 | bool poll = nvme_rdma_poll_queue(queue); | ||
| 684 | int ret; | 683 | int ret; |
| 685 | 684 | ||
| 686 | if (idx) | 685 | if (idx) |
| 687 | ret = nvmf_connect_io_queue(&ctrl->ctrl, idx, poll); | 686 | ret = nvmf_connect_io_queue(&ctrl->ctrl, idx); |
| 688 | else | 687 | else |
| 689 | ret = nvmf_connect_admin_queue(&ctrl->ctrl); | 688 | ret = nvmf_connect_admin_queue(&ctrl->ctrl); |
| 690 | 689 | ||
| @@ -1574,7 +1574,7 @@ static int nvme_tcp_start_queue(struct nvme_ctrl *nctrl, int idx) · 1573 unmodified lines | |||
| 1574 | int ret; | 1574 | int ret; |
| 1575 | 1575 | ||
| 1576 | if (idx) | 1576 | if (idx) |
| 1577 | ret = nvmf_connect_io_queue(nctrl, idx, false); | 1577 | ret = nvmf_connect_io_queue(nctrl, idx); |
| 1578 | else | 1578 | else |
| 1579 | ret = nvmf_connect_admin_queue(nctrl); | 1579 | ret = nvmf_connect_admin_queue(nctrl); |
| 1580 | 1580 | ||
| @@ -337,7 +337,7 @@ static int nvme_loop_connect_io_queues(struct nvme_loop_ctrl *ctrl) · 336 unmodified lines | |||
| 337 | int i, ret; | 337 | int i, ret; |
| 338 | 338 | ||
| 339 | for (i = 1; i < ctrl->ctrl.queue_count; i++) { | 339 | for (i = 1; i < ctrl->ctrl.queue_count; i++) { |
| 340 | ret = nvmf_connect_io_queue(&ctrl->ctrl, i, false); | 340 | ret = nvmf_connect_io_queue(&ctrl->ctrl, i); |
| 341 | if (ret) | 341 | if (ret) |
| 342 | return ret; | 342 | return ret; |
| 343 | set_bit(NVME_LOOP_Q_LIVE, &ctrl->queues[i].flags); | 343 | set_bit(NVME_LOOP_Q_LIVE, &ctrl->queues[i].flags); |
| @@ -153,11 +153,10 @@ static void nvmet_passthru_execute_cmd_work(struct work_struct *w) · 152 unmodified lines | |||
| 153 | { | 153 | { |
| 154 | struct nvmet_req *req = container_of(w, struct nvmet_req, p.work); | 154 | struct nvmet_req *req = container_of(w, struct nvmet_req, p.work); |
| 155 | struct request *rq = req->p.rq; | 155 | struct request *rq = req->p.rq; |
| 156 | u16 status; | 156 | int status; |
| 157 | 157 | ||
| 158 | nvme_execute_passthru_rq(rq); | 158 | status = nvme_execute_passthru_rq(rq); |
| 159 | 159 | ||
| 160 | status = nvme_req(rq)->status; | ||
| 161 | if (status == NVME_SC_SUCCESS && | 160 | if (status == NVME_SC_SUCCESS && |
| 162 | req->cmd->common.opcode == nvme_admin_identify) { | 161 | req->cmd->common.opcode == nvme_admin_identify) { |
| 163 | switch (req->cmd->identify.cns) { | 162 | switch (req->cmd->identify.cns) { |
| @@ -168,7 +167,8 @@ static void nvmet_passthru_execute_cmd_work(struct work_struct *w) · 4 unmodified lines | |||
| 168 | nvmet_passthru_override_id_ns(req); | 167 | nvmet_passthru_override_id_ns(req); |
| 169 | break; | 168 | break; |
| 170 | } | 169 | } |
| 171 | } | 170 | } else if (status < 0) |
| 171 | status = NVME_SC_INTERNAL; | ||
| 172 | 172 | ||
| 173 | req->cqe->result = nvme_req(rq)->result; | 173 | req->cqe->result = nvme_req(rq)->result; |
| 174 | nvmet_req_complete(req, status); | 174 | nvmet_req_complete(req, status); |
| @@ -1497,7 +1497,6 @@ static void nvmet_tcp_state_change(struct sock *sk) · 1496 unmodified lines | |||
| 1497 | case TCP_CLOSE_WAIT: | 1497 | case TCP_CLOSE_WAIT: |
| 1498 | case TCP_CLOSE: | 1498 | case TCP_CLOSE: |
| 1499 | /* FALLTHRU */ | 1499 | /* FALLTHRU */ |
| 1500 | sk->sk_user_data = NULL; | ||
| 1501 | nvmet_tcp_schedule_release_queue(queue); | 1500 | nvmet_tcp_schedule_release_queue(queue); |
| 1502 | break; | 1501 | break; |
| 1503 | default: | 1502 | default: |
| @@ -621,7 +621,6 @@ void dasd_set_target_state(struct dasd_device *device, int target) · 620 unmodified lines | |||
| 621 | mutex_unlock(&device->state_mutex); | 621 | mutex_unlock(&device->state_mutex); |
| 622 | dasd_put_device(device); | 622 | dasd_put_device(device); |
| 623 | } | 623 | } |
| 624 | EXPORT_SYMBOL(dasd_set_target_state); | ||
| 625 | 624 | ||
| 626 | /* | 625 | /* |
| 627 | * Enable devices with device numbers in [from..to]. | 626 | * Enable devices with device numbers in [from..to]. |
| @@ -746,7 +746,7 @@ static void create_uid(struct dasd_eckd_private *private) · 745 unmodified lines | |||
| 746 | memcpy(uid->vendor, private->ned->HDA_manufacturer, | 746 | memcpy(uid->vendor, private->ned->HDA_manufacturer, |
| 747 | sizeof(uid->vendor) - 1); | 747 | sizeof(uid->vendor) - 1); |
| 748 | EBCASC(uid->vendor, sizeof(uid->vendor) - 1); | 748 | EBCASC(uid->vendor, sizeof(uid->vendor) - 1); |
| 749 | memcpy(uid->serial, private->ned->HDA_location, | 749 | memcpy(uid->serial, &private->ned->serial, |
| 750 | sizeof(uid->serial) - 1); | 750 | sizeof(uid->serial) - 1); |
| 751 | EBCASC(uid->serial, sizeof(uid->serial) - 1); | 751 | EBCASC(uid->serial, sizeof(uid->serial) - 1); |
| 752 | uid->ssid = private->gneq->subsystemID; | 752 | uid->ssid = private->gneq->subsystemID; |
| @@ -332,8 +332,10 @@ struct dasd_ned { · 331 unmodified lines | |||
| 332 | __u8 dev_type[6]; | 332 | __u8 dev_type[6]; |
| 333 | __u8 dev_model[3]; | 333 | __u8 dev_model[3]; |
| 334 | __u8 HDA_manufacturer[3]; | 334 | __u8 HDA_manufacturer[3]; |
| 335 | __u8 HDA_location[2]; | 335 | struct { |
| 336 | __u8 HDA_seqno[12]; | 336 | __u8 HDA_location[2]; |
| 337 | __u8 HDA_seqno[12]; | ||
| 338 | } serial; | ||
| 337 | __u8 ID; | 339 | __u8 ID; |
| 338 | __u8 unit_addr; | 340 | __u8 unit_addr; |
| 339 | } __attribute__ ((packed)); | 341 | } __attribute__ ((packed)); |
| @@ -1997,7 +1997,7 @@ static void scsi_eh_lock_door(struct scsi_device *sdev) · 1996 unmodified lines | |||
| 1997 | struct request *req; | 1997 | struct request *req; |
| 1998 | struct scsi_request *rq; | 1998 | struct scsi_request *rq; |
| 1999 | 1999 | ||
| 2000 | req = blk_get_request(sdev->request_queue, REQ_OP_SCSI_IN, 0); | 2000 | req = blk_get_request(sdev->request_queue, REQ_OP_DRV_IN, 0); |
| 2001 | if (IS_ERR(req)) | 2001 | if (IS_ERR(req)) |
| 2002 | return; | 2002 | return; |
| 2003 | rq = scsi_req(req); | 2003 | rq = scsi_req(req); |
| @@ -215,7 +215,7 @@ int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, · 214 unmodified lines | |||
| 215 | 215 | ||
| 216 | req = blk_get_request(sdev->request_queue, | 216 | req = blk_get_request(sdev->request_queue, |
| 217 | data_direction == DMA_TO_DEVICE ? | 217 | data_direction == DMA_TO_DEVICE ? |
| 218 | REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, | 218 | REQ_OP_DRV_OUT : REQ_OP_DRV_IN, |
| 219 | rq_flags & RQF_PM ? BLK_MQ_REQ_PM : 0); | 219 | rq_flags & RQF_PM ? BLK_MQ_REQ_PM : 0); |
| 220 | if (IS_ERR(req)) | 220 | if (IS_ERR(req)) |
| 221 | return PTR_ERR(req); | 221 | return PTR_ERR(req); |
| @@ -543,7 +543,7 @@ static bool scsi_end_request(struct request *req, blk_status_t error, · 321 unmodified lines | |||
| 543 | if (blk_queue_add_random(q)) | 543 | if (blk_queue_add_random(q)) |
| 544 | add_disk_randomness(req->rq_disk); | 544 | add_disk_randomness(req->rq_disk); |
| 545 | 545 | ||
| 546 | if (!blk_rq_is_scsi(req)) { | 546 | if (!blk_rq_is_passthrough(req)) { |
| 547 | WARN_ON_ONCE(!(cmd->flags & SCMD_INITIALIZED)); | 547 | WARN_ON_ONCE(!(cmd->flags & SCMD_INITIALIZED)); |
| 548 | cmd->flags &= ~SCMD_INITIALIZED; | 548 | cmd->flags &= ~SCMD_INITIALIZED; |
| 549 | } | 549 | } |
| @@ -1113,7 +1113,7 @@ void scsi_init_command(struct scsi_device *dev, struct scsi_cmnd *cmd) · 563 unmodified lines | |||
| 1113 | bool in_flight; | 1113 | bool in_flight; |
| 1114 | int budget_token = cmd->budget_token; | 1114 | int budget_token = cmd->budget_token; |
| 1115 | 1115 | ||
| 1116 | if (!blk_rq_is_scsi(rq) && !(flags & SCMD_INITIALIZED)) { | 1116 | if (!blk_rq_is_passthrough(rq) && !(flags & SCMD_INITIALIZED)) { |
| 1117 | flags |= SCMD_INITIALIZED; | 1117 | flags |= SCMD_INITIALIZED; |
| 1118 | scsi_initialize_rq(rq); | 1118 | scsi_initialize_rq(rq); |
| 1119 | } | 1119 | } |
| @@ -1554,7 +1554,7 @@ static blk_status_t scsi_prepare_cmd(struct request *req) · 434 unmodified lines | |||
| 1554 | * Special handling for passthrough commands, which don't go to the ULP | 1554 | * Special handling for passthrough commands, which don't go to the ULP |
| 1555 | * at all: | 1555 | * at all: |
| 1556 | */ | 1556 | */ |
| 1557 | if (blk_rq_is_scsi(req)) | 1557 | if (blk_rq_is_passthrough(req)) |
| 1558 | return scsi_setup_scsi_cmnd(sdev, req); | 1558 | return scsi_setup_scsi_cmnd(sdev, req); |
| 1559 | 1559 | ||
| 1560 | if (sdev->handler && sdev->handler->prep_fn) { | 1560 | if (sdev->handler && sdev->handler->prep_fn) { |
| @@ -1759,7 +1759,7 @@ sg_start_req(Sg_request *srp, unsigned char *cmd) · 1758 unmodified lines | |||
| 1759 | * not expect an EWOULDBLOCK from this condition. | 1759 | * not expect an EWOULDBLOCK from this condition. |
| 1760 | */ | 1760 | */ |
| 1761 | rq = blk_get_request(q, hp->dxfer_direction == SG_DXFER_TO_DEV ? | 1761 | rq = blk_get_request(q, hp->dxfer_direction == SG_DXFER_TO_DEV ? |
| 1762 | REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, 0); | 1762 | REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0); |
| 1763 | if (IS_ERR(rq)) { | 1763 | if (IS_ERR(rq)) { |
| 1764 | kfree(long_cmdp); | 1764 | kfree(long_cmdp); |
| 1765 | return PTR_ERR(rq); | 1765 | return PTR_ERR(rq); |
| @@ -549,7 +549,7 @@ static int st_scsi_execute(struct st_request *SRpnt, const unsigned char *cmd, · 548 unmodified lines | |||
| 549 | 549 | ||
| 550 | req = blk_get_request(SRpnt->stp->device->request_queue, | 550 | req = blk_get_request(SRpnt->stp->device->request_queue, |
| 551 | data_direction == DMA_TO_DEVICE ? | 551 | data_direction == DMA_TO_DEVICE ? |
| 552 | REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, 0); | 552 | REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0); |
| 553 | if (IS_ERR(req)) | 553 | if (IS_ERR(req)) |
| 554 | return PTR_ERR(req); | 554 | return PTR_ERR(req); |
| 555 | rq = scsi_req(req); | 555 | rq = scsi_req(req); |
| @@ -982,7 +982,7 @@ pscsi_execute_cmd(struct se_cmd *cmd) · 981 unmodified lines | |||
| 982 | 982 | ||
| 983 | req = blk_get_request(pdv->pdv_sd->request_queue, | 983 | req = blk_get_request(pdv->pdv_sd->request_queue, |
| 984 | cmd->data_direction == DMA_TO_DEVICE ? | 984 | cmd->data_direction == DMA_TO_DEVICE ? |
| 985 | REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, 0); | 985 | REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0); |
| 986 | if (IS_ERR(req)) { | 986 | if (IS_ERR(req)) { |
| 987 | pr_err("PSCSI: blk_get_request() failed\n"); | 987 | pr_err("PSCSI: blk_get_request() failed\n"); |
| 988 | ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; | 988 | ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
| @@ -236,7 +236,7 @@ again: · 235 unmodified lines | |||
| 236 | if (!buf) | 236 | if (!buf) |
| 237 | return -ENOMEM; | 237 | return -ENOMEM; |
| 238 | 238 | ||
| 239 | rq = blk_get_request(q, REQ_OP_SCSI_IN, 0); | 239 | rq = blk_get_request(q, REQ_OP_DRV_IN, 0); |
| 240 | if (IS_ERR(rq)) { | 240 | if (IS_ERR(rq)) { |
| 241 | error = -ENOMEM; | 241 | error = -ENOMEM; |
| 242 | goto out_free_buf; | 242 | goto out_free_buf; |
| @@ -439,8 +439,6 @@ enum { · 438 unmodified lines | |||
| 439 | struct gendisk *__blk_mq_alloc_disk(struct blk_mq_tag_set *set, | 439 | struct gendisk *__blk_mq_alloc_disk(struct blk_mq_tag_set *set, |
| 440 | void *queuedata); | 440 | void *queuedata); |
| 441 | struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *); | 441 | struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *); |
| 442 | struct request_queue *blk_mq_init_queue_data(struct blk_mq_tag_set *set, | ||
| 443 | void *queuedata); | ||
| 444 | int blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, | 442 | int blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, |
| 445 | struct request_queue *q); | 443 | struct request_queue *q); |
| 446 | void blk_mq_unregister_dev(struct device *, struct request_queue *); | 444 | void blk_mq_unregister_dev(struct device *, struct request_queue *); |
| @@ -351,9 +351,6 @@ enum req_opf { · 350 unmodified lines | |||
| 351 | /* reset all the zone present on the device */ | 351 | /* reset all the zone present on the device */ |
| 352 | REQ_OP_ZONE_RESET_ALL = 17, | 352 | REQ_OP_ZONE_RESET_ALL = 17, |
| 353 | 353 | ||
| 354 | /* SCSI passthrough using struct scsi_request */ | ||
| 355 | REQ_OP_SCSI_IN = 32, | ||
| 356 | REQ_OP_SCSI_OUT = 33, | ||
| 357 | /* Driver private requests */ | 354 | /* Driver private requests */ |
| 358 | REQ_OP_DRV_IN = 34, | 355 | REQ_OP_DRV_IN = 34, |
| 359 | REQ_OP_DRV_OUT = 35, | 356 | REQ_OP_DRV_OUT = 35, |
| @@ -240,42 +240,15 @@ struct request { · 239 unmodified lines | |||
| 240 | void *end_io_data; | 240 | void *end_io_data; |
| 241 | }; | 241 | }; |
| 242 | 242 | ||
| 243 | static inline bool blk_op_is_scsi(unsigned int op) | 243 | static inline bool blk_op_is_passthrough(unsigned int op) |
| 244 | { | ||
| 245 | return op == REQ_OP_SCSI_IN || op == REQ_OP_SCSI_OUT; | ||
| 246 | } | ||
| 247 | |||
| 248 | static inline bool blk_op_is_private(unsigned int op) | ||
| 249 | { | 244 | { |
| 245 | op &= REQ_OP_MASK; | ||
| 250 | return op == REQ_OP_DRV_IN || op == REQ_OP_DRV_OUT; | 246 | return op == REQ_OP_DRV_IN || op == REQ_OP_DRV_OUT; |
| 251 | } | 247 | } |
| 252 | 248 | ||
| 253 | static inline bool blk_rq_is_scsi(struct request *rq) | ||
| 254 | { | ||
| 255 | return blk_op_is_scsi(req_op(rq)); | ||
| 256 | } | ||
| 257 | |||
| 258 | static inline bool blk_rq_is_private(struct request *rq) | ||
| 259 | { | ||
| 260 | return blk_op_is_private(req_op(rq)); | ||
| 261 | } | ||
| 262 | |||
| 263 | static inline bool blk_rq_is_passthrough(struct request *rq) | 249 | static inline bool blk_rq_is_passthrough(struct request *rq) |
| 264 | { | 250 | { |
| 265 | return blk_rq_is_scsi(rq) || blk_rq_is_private(rq); | 251 | return blk_op_is_passthrough(req_op(rq)); |
| 266 | } | ||
| 267 | |||
| 268 | static inline bool bio_is_passthrough(struct bio *bio) | ||
| 269 | { | ||
| 270 | unsigned op = bio_op(bio); | ||
| 271 | |||
| 272 | return blk_op_is_scsi(op) || blk_op_is_private(op); | ||
| 273 | } | ||
| 274 | |||
| 275 | static inline bool blk_op_is_passthrough(unsigned int op) | ||
| 276 | { | ||
| 277 | return (blk_op_is_scsi(op & REQ_OP_MASK) || | ||
| 278 | blk_op_is_private(op & REQ_OP_MASK)); | ||
| 279 | } | 252 | } |
| 280 | 253 | ||
| 281 | static inline unsigned short req_get_ioprio(struct request *req) | 254 | static inline unsigned short req_get_ioprio(struct request *req) |
| @@ -936,10 +909,12 @@ extern int blk_rq_map_kern(struct request_queue *, struct request *, void *, uns · 654 unmodified lines | |||
| 936 | extern int blk_rq_map_user_iov(struct request_queue *, struct request *, | 909 | extern int blk_rq_map_user_iov(struct request_queue *, struct request *, |
| 937 | struct rq_map_data *, const struct iov_iter *, | 910 | struct rq_map_data *, const struct iov_iter *, |
| 938 | gfp_t); | 911 | gfp_t); |
| 939 | extern void blk_execute_rq(struct gendisk *, struct request *, int); | ||
| 940 | extern void blk_execute_rq_nowait(struct gendisk *, | 912 | extern void blk_execute_rq_nowait(struct gendisk *, |
| 941 | struct request *, int, rq_end_io_fn *); | 913 | struct request *, int, rq_end_io_fn *); |
| 942 | 914 | ||
| 915 | blk_status_t blk_execute_rq(struct gendisk *bd_disk, struct request *rq, | ||
| 916 | int at_head); | ||
| 917 | |||
| 943 | /* Helper to convert REQ_OP_XXX to its string format XXX */ | 918 | /* Helper to convert REQ_OP_XXX to its string format XXX */ |
| 944 | extern const char *blk_op_str(unsigned int op); | 919 | extern const char *blk_op_str(unsigned int op); |
| 945 | 920 | ||
| @@ -35,6 +35,7 @@ enum { · 34 unmodified lines | |||
| 35 | NBD_ATTR_SOCKETS, | 35 | NBD_ATTR_SOCKETS, |
| 36 | NBD_ATTR_DEAD_CONN_TIMEOUT, | 36 | NBD_ATTR_DEAD_CONN_TIMEOUT, |
| 37 | NBD_ATTR_DEVICE_LIST, | 37 | NBD_ATTR_DEVICE_LIST, |
| 38 | NBD_ATTR_BACKEND_IDENTIFIER, | ||
| 38 | __NBD_ATTR_MAX, | 39 | __NBD_ATTR_MAX, |
| 39 | }; | 40 | }; |
| 40 | #define NBD_ATTR_MAX (__NBD_ATTR_MAX - 1) | 41 | #define NBD_ATTR_MAX (__NBD_ATTR_MAX - 1) |