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 | 127 | /* Protected by ubd_lock */ |
| 128 | −static int fake_major = UBD_MAJOR; | |
| 129 | 128 | static struct gendisk *ubd_gendisk[MAX_DEV]; |
| 130 | −static struct gendisk *fake_gendisk[MAX_DEV]; | |
| 131 | 129 | |
| 132 | 130 | #ifdef CONFIG_BLK_DEV_UBD_SYNC |
| 133 | 131 | #define OPEN_FLAGS ((struct openflags) { .r = 1, .w = 1, .s = 1, .c = 0, \ |
| @@ -197,54 +195,19 @@ struct ubd { · 63 unmodified lines | ||
| 197 | 195 | /* Protected by ubd_lock */ |
| 198 | 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 | 198 | static blk_status_t ubd_queue_rq(struct blk_mq_hw_ctx *hctx, |
| 206 | 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 | 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 | 204 | return 1; |
| 241 | 205 | } |
| 242 | − | |
| 243 | 206 | __setup("fake_ide", fake_ide_setup); |
| 244 | 207 | |
| 245 | 208 | __uml_help(fake_ide_setup, |
| 246 | 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 | 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 | 243 | if(index_out) *index_out = -1; |
| 281 | 244 | n = *str; |
| 282 | 245 | if(n == '='){ |
| 283 | − char *end; | |
| 284 | − int major; | |
| 285 | − | |
| 286 | 246 | str++; |
| 287 | 247 | if(!strcmp(str, "sync")){ |
| 288 | 248 | global_openflags = of_sync(global_openflags); |
| 289 | 249 | return err; |
| 290 | 250 | } |
| 291 | 251 | |
| 292 | − err = -EINVAL; | |
| 293 | − major = simple_strtoul(str, &end, 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; | |
| 252 | + pr_warn("fake major not supported any more\n"); | |
| 253 | + return 0; | |
| 313 | 254 | } |
| 314 | 255 | |
| 315 | 256 | n = parse_unit(&str); |
| @@ -874,7 +815,6 @@ static void ubd_device_release(struct device *dev) · 558 unmodified lines | ||
| 874 | 815 | { |
| 875 | 816 | struct ubd *ubd_dev = dev_get_drvdata(dev); |
| 876 | 817 | |
| 877 | − blk_cleanup_queue(ubd_dev->queue); | |
| 878 | 818 | blk_mq_free_tag_set(&ubd_dev->tag_set); |
| 879 | 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 | 854 | NULL, |
| 915 | 855 | }; |
| 916 | 856 | |
| 917 | −static int ubd_disk_register(int major, u64 size, int unit, | |
| 918 | − struct gendisk **disk_out) | |
| 857 | +static void ubd_disk_register(int major, u64 size, int unit, | |
| 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 | 860 | disk->major = major; |
| 928 | 861 | disk->first_minor = unit << UBD_SHIFT; |
| 862 | + disk->minors = 1 << UBD_SHIFT; | |
| 929 | 863 | disk->fops = &ubd_blops; |
| 930 | 864 | set_capacity(disk, size / 512); |
| 931 | − if (major == UBD_MAJOR) | |
| 932 | − sprintf(disk->disk_name, "ubd%c", 'a' + unit); | |
| 933 | − else | |
| 934 | − sprintf(disk->disk_name, "ubd_fake%d", unit); | |
| 935 | − | |
| 936 | − /* sysfs register (not for ide fake devices) */ | |
| 937 | − if (major == UBD_MAJOR) { | |
| 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 | − } | |
| 865 | + sprintf(disk->disk_name, "ubd%c", 'a' + unit); | |
| 866 | + | |
| 867 | + ubd_devs[unit].pdev.id = unit; | |
| 868 | + ubd_devs[unit].pdev.name = DRIVER_NAME; | |
| 869 | + ubd_devs[unit].pdev.dev.release = ubd_device_release; | |
| 870 | + dev_set_drvdata(&ubd_devs[unit].pdev.dev, &ubd_devs[unit]); | |
| 871 | + platform_device_register(&ubd_devs[unit].pdev); | |
| 945 | 872 | |
| 946 | 873 | disk->private_data = &ubd_devs[unit]; |
| 947 | 874 | disk->queue = ubd_devs[unit].queue; |
| 948 | − device_add_disk(parent, disk, ubd_attr_groups); | |
| 949 | − | |
| 950 | − *disk_out = disk; | |
| 951 | − return 0; | |
| 875 | + device_add_disk(&ubd_devs[unit].pdev.dev, disk, ubd_attr_groups); | |
| 952 | 876 | } |
| 953 | 877 | |
| 954 | 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 | 884 | static int ubd_add(int n, char **error_out) |
| 961 | 885 | { |
| 962 | 886 | struct ubd *ubd_dev = &ubd_devs[n]; |
| 887 | + struct gendisk *disk; | |
| 963 | 888 | int err = 0; |
| 964 | 889 | |
| 965 | 890 | if(ubd_dev->file == NULL) |
| @@ -984,43 +909,24 @@ static int ubd_add(int n, char **error_out) · 18 unmodified lines | ||
| 984 | 909 | if (err) |
| 985 | 910 | goto out; |
| 986 | 911 | |
| 987 | − ubd_dev->queue = blk_mq_init_queue(&ubd_dev->tag_set); | |
| 988 | − if (IS_ERR(ubd_dev->queue)) { | |
| 989 | − err = PTR_ERR(ubd_dev->queue); | |
| 912 | + disk = blk_mq_alloc_disk(&ubd_dev->tag_set, ubd_dev); | |
| 913 | + if (IS_ERR(disk)) { | |
| 914 | + err = PTR_ERR(disk); | |
| 990 | 915 | goto out_cleanup_tags; |
| 991 | 916 | } |
| 917 | + ubd_dev->queue = disk->queue; | |
| 992 | 918 | |
| 993 | − ubd_dev->queue->queuedata = ubd_dev; | |
| 994 | 919 | blk_queue_write_cache(ubd_dev->queue, true, false); |
| 995 | − | |
| 996 | 920 | blk_queue_max_segments(ubd_dev->queue, MAX_SG); |
| 997 | 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]); | |
| 999 | − if(err){ | |
| 1000 | − *error_out = "Failed to register device"; | |
| 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; | |
| 922 | + ubd_disk_register(UBD_MAJOR, ubd_dev->size, n, disk); | |
| 923 | + ubd_gendisk[n] = disk; | |
| 924 | + return 0; | |
| 1018 | 925 | |
| 1019 | 926 | out_cleanup_tags: |
| 1020 | 927 | blk_mq_free_tag_set(&ubd_dev->tag_set); |
| 1021 | − if (!(IS_ERR(ubd_dev->queue))) | |
| 1022 | − blk_cleanup_queue(ubd_dev->queue); | |
| 1023 | − goto out; | |
| 928 | +out: | |
| 929 | + return err; | |
| 1024 | 930 | } |
| 1025 | 931 | |
| 1026 | 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 | 1029 | ubd_gendisk[n] = NULL; |
| 1124 | 1030 | if(disk != NULL){ |
| 1125 | 1031 | del_gendisk(disk); |
| 1126 | − put_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; | |
| 1032 | + blk_cleanup_disk(disk); | |
| 1133 | 1033 | } |
| 1134 | 1034 | |
| 1135 | 1035 | err = 0; |
| @@ -1188,14 +1088,6 @@ static int __init ubd_init(void) · 52 unmodified lines | ||
| 1188 | 1088 | if (register_blkdev(UBD_MAJOR, "ubd")) |
| 1189 | 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 | 1091 | irq_req_buffer = kmalloc_array(UBD_REQ_BUFFER_SIZE, |
| 1200 | 1092 | sizeof(struct io_thread_req *), |
| 1201 | 1093 | GFP_KERNEL |
| @@ -56,6 +56,8 @@ static LIST_HEAD(all_blkcgs); /* protected by blkcg_pol_mutex */ · 55 unmodified lines | ||
| 56 | 56 | bool blkcg_debug_stats = false; |
| 57 | 57 | static struct workqueue_struct *blkcg_punt_bio_wq; |
| 58 | 58 | |
| 59 | +#define BLKG_DESTROY_BATCH_SIZE 64 | |
| 60 | + | |
| 59 | 61 | static bool blkcg_policy_enabled(struct request_queue *q, |
| 60 | 62 | const struct blkcg_policy *pol) |
| 61 | 63 | { |
| @@ -422,7 +424,9 @@ static void blkg_destroy(struct blkcg_gq *blkg) · 360 unmodified lines | ||
| 422 | 424 | static void blkg_destroy_all(struct request_queue *q) |
| 423 | 425 | { |
| 424 | 426 | struct blkcg_gq *blkg, *n; |
| 427 | + int count = BLKG_DESTROY_BATCH_SIZE; | |
| 425 | 428 | |
| 429 | +restart: | |
| 426 | 430 | spin_lock_irq(&q->queue_lock); |
| 427 | 431 | list_for_each_entry_safe(blkg, n, &q->blkg_list, q_node) { |
| 428 | 432 | struct blkcg *blkcg = blkg->blkcg; |
| @@ -430,6 +434,17 @@ static void blkg_destroy_all(struct request_queue *q) · 1 unmodified line | ||
| 430 | 434 | spin_lock(&blkcg->lock); |
| 431 | 435 | blkg_destroy(blkg); |
| 432 | 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 | 450 | q->root_blkg = NULL; |
| @@ -142,8 +142,6 @@ static const char *const blk_op_name[] = { · 141 unmodified lines | ||
| 142 | 142 | REQ_OP_NAME(ZONE_APPEND), |
| 143 | 143 | REQ_OP_NAME(WRITE_SAME), |
| 144 | 144 | REQ_OP_NAME(WRITE_ZEROES), |
| 145 | − REQ_OP_NAME(SCSI_IN), | |
| 146 | − REQ_OP_NAME(SCSI_OUT), | |
| 147 | 145 | REQ_OP_NAME(DRV_IN), |
| 148 | 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 | 1241 | unsigned long stamp; |
| 1244 | 1242 | again: |
| 1245 | 1243 | stamp = READ_ONCE(part->bd_stamp); |
| 1246 | − if (unlikely(stamp != now)) { | |
| 1244 | + if (unlikely(time_after(now, stamp))) { | |
| 1247 | 1245 | if (likely(cmpxchg(&part->bd_stamp, stamp, now) == stamp)) |
| 1248 | 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 | 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 | 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 | 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 | 80 | * blk_execute_rq - insert a request into queue for execution |
| 68 | 81 | * @bd_disk: matching gendisk |
| @@ -72,8 +85,9 @@ EXPORT_SYMBOL_GPL(blk_execute_rq_nowait); · 3 unmodified lines | ||
| 72 | 85 | * Description: |
| 73 | 86 | * Insert a fully prepared request at the back of the I/O scheduler queue |
| 74 | 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 | 92 | DECLARE_COMPLETION_ONSTACK(wait); |
| 79 | 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 | 98 | /* Prevent hang_check timer from firing at us during very long I/O */ |
| 85 | 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 | 104 | while (!wait_for_completion_io_timeout(&wait, hang_check * (HZ/2))); |
| 88 | 105 | else |
| 89 | 106 | wait_for_completion_io(&wait); |
| 107 | + | |
| 108 | + return (blk_status_t)(uintptr_t)rq->end_io_data; | |
| 90 | 109 | } |
| 91 | 110 | EXPORT_SYMBOL(blk_execute_rq); |
| @@ -3109,7 +3109,7 @@ void blk_mq_release(struct request_queue *q) · 3108 unmodified lines | ||
| 3109 | 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 | 3113 | void *queuedata) |
| 3114 | 3114 | { |
| 3115 | 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 | 3127 | return q; |
| 3128 | 3128 | } |
| 3129 | −EXPORT_SYMBOL_GPL(blk_mq_init_queue_data); | |
| 3130 | 3129 | |
| 3131 | 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 | 45 | return PTR_ERR(job->request); |
| 46 | 46 | |
| 47 | 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 | 49 | if (IS_ERR(job->bidi_rq)) { |
| 50 | 50 | ret = PTR_ERR(job->bidi_rq); |
| 51 | 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 | 154 | return ret; |
| 155 | 155 | |
| 156 | 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 | 158 | if (IS_ERR(rq)) |
| 159 | 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 | 365 | xa_for_each(&disk->part_tbl, idx, part) { |
| 366 | 366 | if (bdev_is_partition(part) && !bdev_nr_sectors(part)) |
| 367 | 367 | continue; |
| 368 | − if (!bdgrab(part)) | |
| 368 | + if (!kobject_get_unless_zero(&part->bd_device.kobj)) | |
| 369 | 369 | continue; |
| 370 | 370 | |
| 371 | 371 | rcu_read_unlock(); |
| 372 | 372 | kobject_uevent(bdev_kobj(part), action); |
| 373 | − bdput(part); | |
| 373 | + put_device(&part->bd_device); | |
| 374 | 374 | rcu_read_lock(); |
| 375 | 375 | } |
| 376 | 376 | rcu_read_unlock(); |
| @@ -453,17 +453,26 @@ int bdev_add_partition(struct block_device *bdev, int partno, · 452 unmodified lines | ||
| 453 | 453 | sector_t start, sector_t length) |
| 454 | 454 | { |
| 455 | 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); | |
| 458 | − if (partition_overlaps(bdev->bd_disk, start, length, -1)) { | |
| 459 | − mutex_unlock(&bdev->bd_disk->open_mutex); | |
| 460 | − return -EBUSY; | |
| 459 | + mutex_lock(&disk->open_mutex); | |
| 460 | + if (!(disk->flags & GENHD_FL_UP)) { | |
| 461 | + ret = -ENXIO; | |
| 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 | 471 | ADDPART_FLAG_NONE, NULL); |
| 465 | − mutex_unlock(&bdev->bd_disk->open_mutex); | |
| 466 | − return PTR_ERR_OR_ZERO(part); | |
| 472 | + ret = PTR_ERR_OR_ZERO(part); | |
| 473 | +out: | |
| 474 | + mutex_unlock(&disk->open_mutex); | |
| 475 | + return ret; | |
| 467 | 476 | } |
| 468 | 477 | |
| 469 | 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 | 547 | lockdep_assert_held(&disk->open_mutex); |
| 539 | 548 | |
| 540 | − xa_for_each_start(&disk->part_tbl, idx, part, 1) { | |
| 541 | − if (!bdgrab(part)) | |
| 542 | − continue; | |
| 549 | + xa_for_each_start(&disk->part_tbl, idx, part, 1) | |
| 543 | 550 | delete_partition(part); |
| 544 | − bdput(part); | |
| 545 | − } | |
| 546 | 551 | } |
| 547 | 552 | |
| 548 | 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 | 313 | at_head = 1; |
| 314 | 314 | |
| 315 | 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 | 317 | if (IS_ERR(rq)) |
| 318 | 318 | return PTR_ERR(rq); |
| 319 | 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 | 439 | if (IS_ERR(rq)) { |
| 440 | 440 | err = PTR_ERR(rq); |
| 441 | 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 | 524 | struct request *rq; |
| 525 | 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 | 528 | if (IS_ERR(rq)) |
| 529 | 529 | return PTR_ERR(rq); |
| 530 | 530 | rq->timeout = BLK_DEFAULT_SG_TIMEOUT; |
| @@ -1434,7 +1434,6 @@ static int · 1433 unmodified lines | ||
| 1434 | 1434 | loop_set_status(struct loop_device *lo, const struct loop_info64 *info) |
| 1435 | 1435 | { |
| 1436 | 1436 | int err; |
| 1437 | − struct block_device *bdev; | |
| 1438 | 1437 | kuid_t uid = current_uid(); |
| 1439 | 1438 | int prev_lo_flags; |
| 1440 | 1439 | bool partscan = false; |
| @@ -1503,7 +1502,6 @@ out_unfreeze: · 62 unmodified lines | ||
| 1503 | 1502 | if (!err && (lo->lo_flags & LO_FLAGS_PARTSCAN) && |
| 1504 | 1503 | !(prev_lo_flags & LO_FLAGS_PARTSCAN)) { |
| 1505 | 1504 | lo->lo_disk->flags &= ~GENHD_FL_NO_PART_SCAN; |
| 1506 | − bdev = lo->lo_device; | |
| 1507 | 1505 | partscan = true; |
| 1508 | 1506 | } |
| 1509 | 1507 | out_unlock: |
| @@ -2237,7 +2235,7 @@ static const struct blk_mq_ops loop_mq_ops = { · 727 unmodified lines | ||
| 2237 | 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 | 2240 | struct loop_device *lo; |
| 2243 | 2241 | struct gendisk *disk; |
| @@ -2247,9 +2245,12 @@ static int loop_add(struct loop_device **l, int i) · 3 unmodified lines | ||
| 2247 | 2245 | lo = kzalloc(sizeof(*lo), GFP_KERNEL); |
| 2248 | 2246 | if (!lo) |
| 2249 | 2247 | goto out; |
| 2250 | − | |
| 2251 | 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 | 2254 | /* allocate id, if @id >= 0, we're requesting that specific id */ |
| 2254 | 2255 | if (i >= 0) { |
| 2255 | 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 | 2260 | err = idr_alloc(&loop_index_idr, lo, 0, 0, GFP_KERNEL); |
| 2260 | 2261 | } |
| 2261 | 2262 | if (err < 0) |
| 2262 | − goto out_free_dev; | |
| 2263 | + goto out_unlock; | |
| 2263 | 2264 | i = err; |
| 2264 | 2265 | |
| 2265 | 2266 | err = -ENOMEM; |
| @@ -2326,13 +2327,15 @@ static int loop_add(struct loop_device **l, int i) · 60 unmodified lines | ||
| 2326 | 2327 | disk->queue = lo->lo_queue; |
| 2327 | 2328 | sprintf(disk->disk_name, "loop%d", i); |
| 2328 | 2329 | add_disk(disk); |
| 2329 | − *l = lo; | |
| 2330 | − return lo->lo_number; | |
| 2330 | + mutex_unlock(&loop_ctl_mutex); | |
| 2331 | + return i; | |
| 2331 | 2332 | |
| 2332 | 2333 | out_cleanup_tags: |
| 2333 | 2334 | blk_mq_free_tag_set(&lo->tag_set); |
| 2334 | 2335 | out_free_idr: |
| 2335 | 2336 | idr_remove(&loop_index_idr, i); |
| 2337 | +out_unlock: | |
| 2338 | + mutex_unlock(&loop_ctl_mutex); | |
| 2336 | 2339 | out_free_dev: |
| 2337 | 2340 | kfree(lo); |
| 2338 | 2341 | out: |
| @@ -2348,109 +2351,86 @@ static void loop_remove(struct loop_device *lo) · 9 unmodified lines | ||
| 2348 | 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; | |
| 2354 | − struct loop_device **l = data; | |
| 2356 | + int idx = MINOR(dev) >> part_shift; | |
| 2355 | 2357 | |
| 2356 | − if (lo->lo_state == Lo_unbound) { | |
| 2357 | − *l = lo; | |
| 2358 | − return 1; | |
| 2359 | − } | |
| 2360 | − return 0; | |
| 2358 | + if (max_loop && idx >= max_loop) | |
| 2359 | + return; | |
| 2360 | + loop_add(idx); | |
| 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 | 2365 | struct loop_device *lo; |
| 2366 | − int ret = -ENODEV; | |
| 2366 | + int ret; | |
| 2367 | 2367 | |
| 2368 | − if (i < 0) { | |
| 2369 | − int err; | |
| 2368 | + if (idx < 0) { | |
| 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); | |
| 2372 | − if (err == 1) { | |
| 2373 | − *l = lo; | |
| 2374 | − ret = lo->lo_number; | |
| 2375 | − } | |
| 2376 | − goto out; | |
| 2377 | + lo = idr_find(&loop_index_idr, idx); | |
| 2378 | + if (!lo) { | |
| 2379 | + ret = -ENODEV; | |
| 2380 | + goto out_unlock_ctrl; | |
| 2377 | 2381 | } |
| 2378 | 2382 | |
| 2379 | − /* lookup and return a specific i */ | |
| 2380 | − lo = idr_find(&loop_index_idr, i); | |
| 2381 | − if (lo) { | |
| 2382 | − *l = lo; | |
| 2383 | − ret = lo->lo_number; | |
| 2383 | + ret = mutex_lock_killable(&lo->lo_mutex); | |
| 2384 | + if (ret) | |
| 2385 | + goto out_unlock_ctrl; | |
| 2386 | + if (lo->lo_state != Lo_unbound || | |
| 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 | 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 | 2404 | struct loop_device *lo; |
| 2405 | + int id, ret; | |
| 2393 | 2406 | |
| 2394 | − if (max_loop && idx >= max_loop) | |
| 2395 | − return; | |
| 2396 | − | |
| 2397 | − mutex_lock(&loop_ctl_mutex); | |
| 2398 | − if (loop_lookup(&lo, idx) < 0) | |
| 2399 | − loop_add(&lo, idx); | |
| 2407 | + ret = mutex_lock_killable(&loop_ctl_mutex); | |
| 2408 | + if (ret) | |
| 2409 | + return ret; | |
| 2410 | + idr_for_each_entry(&loop_index_idr, lo, id) { | |
| 2411 | + if (lo->lo_state == Lo_unbound) | |
| 2412 | + goto found; | |
| 2413 | + } | |
| 2400 | 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 | 2421 | static long loop_control_ioctl(struct file *file, unsigned int cmd, |
| 2404 | 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 | 2424 | switch (cmd) { |
| 2415 | 2425 | case LOOP_CTL_ADD: |
| 2416 | − ret = loop_lookup(&lo, parm); | |
| 2417 | − if (ret >= 0) { | |
| 2418 | − ret = -EEXIST; | |
| 2419 | − break; | |
| 2420 | − } | |
| 2421 | − ret = loop_add(&lo, parm); | |
| 2422 | − break; | |
| 2426 | + return loop_add(parm); | |
| 2423 | 2427 | case LOOP_CTL_REMOVE: |
| 2424 | − ret = loop_lookup(&lo, 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; | |
| 2428 | + return loop_control_remove(parm); | |
| 2445 | 2429 | case LOOP_CTL_GET_FREE: |
| 2446 | − ret = loop_lookup(&lo, -1); | |
| 2447 | − if (ret >= 0) | |
| 2448 | − break; | |
| 2449 | − ret = loop_add(&lo, -1); | |
| 2430 | + return loop_control_get_free(parm); | |
| 2431 | + default: | |
| 2432 | + return -ENOSYS; | |
| 2450 | 2433 | } |
| 2451 | − mutex_unlock(&loop_ctl_mutex); | |
| 2452 | − | |
| 2453 | − return ret; | |
| 2454 | 2434 | } |
| 2455 | 2435 | |
| 2456 | 2436 | static const struct file_operations loop_ctl_fops = { |
| @@ -2473,7 +2453,6 @@ MODULE_ALIAS("devname:loop-control"); · 16 unmodified lines | ||
| 2473 | 2453 | static int __init loop_init(void) |
| 2474 | 2454 | { |
| 2475 | 2455 | int i, nr; |
| 2476 | − struct loop_device *lo; | |
| 2477 | 2456 | int err; |
| 2478 | 2457 | |
| 2479 | 2458 | part_shift = 0; |
| @@ -2525,10 +2504,8 @@ static int __init loop_init(void) · 45 unmodified lines | ||
| 2525 | 2504 | } |
| 2526 | 2505 | |
| 2527 | 2506 | /* pre-create number of devices given by config or max_loop */ |
| 2528 | − mutex_lock(&loop_ctl_mutex); | |
| 2529 | 2507 | for (i = 0; i < nr; i++) |
| 2530 | − loop_add(&lo, i); | |
| 2531 | − mutex_unlock(&loop_ctl_mutex); | |
| 2508 | + loop_add(i); | |
| 2532 | 2509 | |
| 2533 | 2510 | printk(KERN_INFO "loop: module loaded\n"); |
| 2534 | 2511 | return 0; |
| @@ -2539,26 +2516,20 @@ err_out: · 4 unmodified lines | ||
| 2539 | 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 | 2519 | static void __exit loop_exit(void) |
| 2551 | 2520 | { |
| 2552 | − mutex_lock(&loop_ctl_mutex); | |
| 2553 | − | |
| 2554 | − idr_for_each(&loop_index_idr, &loop_exit_cb, NULL); | |
| 2555 | − idr_destroy(&loop_index_idr); | |
| 2521 | + struct loop_device *lo; | |
| 2522 | + int id; | |
| 2556 | 2523 | |
| 2557 | 2524 | unregister_blkdev(LOOP_MAJOR, "loop"); |
| 2558 | − | |
| 2559 | 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 | 2530 | mutex_unlock(&loop_ctl_mutex); |
| 2531 | + | |
| 2532 | + idr_destroy(&loop_index_idr); | |
| 2562 | 2533 | } |
| 2563 | 2534 | |
| 2564 | 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 | 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 | 2177 | /* debugsfs entries */ |
| 2164 | 2178 | |
| 2165 | 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 | 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 | 2391 | static int mtip_hw_debugfs_init(struct driver_data *dd) |
| 2419 | 2392 | { |
| 2420 | 2393 | if (!dfs_parent) |
| @@ -3566,7 +3539,6 @@ static int mtip_block_initialize(struct driver_data *dd) · 1145 unmodified lines | ||
| 3566 | 3539 | int rv = 0, wait_for_rebuild = 0; |
| 3567 | 3540 | sector_t capacity; |
| 3568 | 3541 | unsigned int index = 0; |
| 3569 | − struct kobject *kobj; | |
| 3570 | 3542 | |
| 3571 | 3543 | if (dd->disk) |
| 3572 | 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 | 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 | 3551 | memset(&dd->tags, 0, sizeof(dd->tags)); |
| 3609 | 3552 | dd->tags.ops = &mtip_mq_ops; |
| 3610 | 3553 | dd->tags.nr_hw_queues = 1; |
| @@ -3623,17 +3566,35 @@ static int mtip_block_initialize(struct driver_data *dd) · 12 unmodified lines | ||
| 3623 | 3566 | goto block_queue_alloc_tag_error; |
| 3624 | 3567 | } |
| 3625 | 3568 | |
| 3626 | − /* Allocate the request queue. */ | |
| 3627 | − dd->queue = blk_mq_init_queue(&dd->tags); | |
| 3628 | − if (IS_ERR(dd->queue)) { | |
| 3569 | + dd->disk = blk_mq_alloc_disk(&dd->tags, dd); | |
| 3570 | + if (IS_ERR(dd->disk)) { | |
| 3629 | 3571 | dev_err(&dd->pdev->dev, |
| 3630 | 3572 | "Unable to allocate request queue\n"); |
| 3631 | 3573 | rv = -ENOMEM; |
| 3632 | 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; | |
| 3636 | − dd->queue->queuedata = dd; | |
| 3597 | + mtip_hw_debugfs_init(dd); | |
| 3637 | 3598 | |
| 3638 | 3599 | skip_create_disk: |
| 3639 | 3600 | /* Initialize the protocol layer. */ |
| @@ -3672,17 +3633,7 @@ skip_create_disk: · 32 unmodified lines | ||
| 3672 | 3633 | set_capacity(dd->disk, capacity); |
| 3673 | 3634 | |
| 3674 | 3635 | /* Enable the block device and add it to /dev */ |
| 3675 | − device_add_disk(&dd->pdev->dev, dd->disk, NULL); | |
| 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 | − } | |
| 3636 | + device_add_disk(&dd->pdev->dev, dd->disk, mtip_disk_attr_groups); | |
| 3686 | 3637 | |
| 3687 | 3638 | if (dd->mtip_svc_handler) { |
| 3688 | 3639 | set_bit(MTIP_DDF_INIT_DONE_BIT, &dd->dd_flag); |
| @@ -3709,23 +3660,17 @@ start_service_thread: · 20 unmodified lines | ||
| 3709 | 3660 | kthread_run_error: |
| 3710 | 3661 | /* Delete our gendisk. This also removes the device from /dev */ |
| 3711 | 3662 | del_gendisk(dd->disk); |
| 3712 | − | |
| 3713 | 3663 | read_capacity_error: |
| 3714 | 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 | 3665 | mtip_hw_debugfs_exit(dd); |
| 3720 | 3666 | disk_index_error: |
| 3721 | 3667 | ida_free(&rssd_index_ida, index); |
| 3722 | − | |
| 3723 | 3668 | ida_get_error: |
| 3724 | − put_disk(dd->disk); | |
| 3725 | − | |
| 3726 | −alloc_disk_error: | |
| 3669 | + blk_cleanup_disk(dd->disk); | |
| 3670 | +block_queue_alloc_init_error: | |
| 3671 | + blk_mq_free_tag_set(&dd->tags); | |
| 3672 | +block_queue_alloc_tag_error: | |
| 3727 | 3673 | mtip_hw_exit(dd); /* De-initialize the protocol layer. */ |
| 3728 | − | |
| 3729 | 3674 | protocol_init_error: |
| 3730 | 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 | 3697 | static int mtip_block_remove(struct driver_data *dd) |
| 3753 | 3698 | { |
| 3754 | − struct kobject *kobj; | |
| 3755 | − | |
| 3756 | 3699 | mtip_hw_debugfs_exit(dd); |
| 3757 | 3700 | |
| 3758 | 3701 | if (dd->mtip_svc_handler) { |
| @@ -3761,15 +3704,6 @@ static int mtip_block_remove(struct driver_data *dd) · 2 unmodified lines | ||
| 3761 | 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 | 3707 | if (!dd->sr) { |
| 3774 | 3708 | /* |
| 3775 | 3709 | * Explicitly wait here for IOs to quiesce, |
| @@ -79,6 +79,7 @@ struct link_dead_args { · 78 unmodified lines | ||
| 79 | 79 | #define NBD_RT_HAS_CONFIG_REF 4 |
| 80 | 80 | #define NBD_RT_BOUND 5 |
| 81 | 81 | #define NBD_RT_DISCONNECT_ON_CLOSE 6 |
| 82 | +#define NBD_RT_HAS_BACKEND_FILE 7 | |
| 82 | 83 | |
| 83 | 84 | #define NBD_DESTROY_ON_DISCONNECT 0 |
| 84 | 85 | #define NBD_DISCONNECT_REQUESTED 1 |
| @@ -119,6 +120,8 @@ struct nbd_device { · 34 unmodified lines | ||
| 119 | 120 | |
| 120 | 121 | struct completion *destroy_complete; |
| 121 | 122 | unsigned long flags; |
| 123 | + | |
| 124 | + char *backend; | |
| 122 | 125 | }; |
| 123 | 126 | |
| 124 | 127 | #define NBD_CMD_REQUEUED 1 |
| @@ -216,6 +219,20 @@ static const struct device_attribute pid_attr = { · 91 unmodified lines | ||
| 216 | 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 | 236 | static void nbd_dev_remove(struct nbd_device *nbd) |
| 220 | 237 | { |
| 221 | 238 | struct gendisk *disk = nbd->disk; |
| @@ -1211,6 +1228,12 @@ static void nbd_config_put(struct nbd_device *nbd) · 989 unmodified lines | ||
| 1211 | 1228 | &config->runtime_flags)) |
| 1212 | 1229 | device_remove_file(disk_to_dev(nbd->disk), &pid_attr); |
| 1213 | 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 | 1237 | nbd_clear_sock(nbd); |
| 1215 | 1238 | if (config->num_connections) { |
| 1216 | 1239 | int i; |
| @@ -1270,7 +1293,7 @@ static int nbd_start_device(struct nbd_device *nbd) · 53 unmodified lines | ||
| 1270 | 1293 | |
| 1271 | 1294 | error = device_create_file(disk_to_dev(nbd->disk), &pid_attr); |
| 1272 | 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 | 1297 | return error; |
| 1275 | 1298 | } |
| 1276 | 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 | 1680 | BLK_MQ_F_BLOCKING; |
| 1658 | 1681 | nbd->tag_set.driver_data = nbd; |
| 1659 | 1682 | nbd->destroy_complete = NULL; |
| 1683 | + nbd->backend = NULL; | |
| 1660 | 1684 | |
| 1661 | 1685 | err = blk_mq_alloc_tag_set(&nbd->tag_set); |
| 1662 | 1686 | if (err) |
| @@ -1743,6 +1767,7 @@ static const struct nla_policy nbd_attr_policy[NBD_ATTR_MAX + 1] = { · 80 unmodified lines | ||
| 1743 | 1767 | [NBD_ATTR_SOCKETS] = { .type = NLA_NESTED}, |
| 1744 | 1768 | [NBD_ATTR_DEAD_CONN_TIMEOUT] = { .type = NLA_U64 }, |
| 1745 | 1769 | [NBD_ATTR_DEVICE_LIST] = { .type = NLA_NESTED}, |
| 1770 | + [NBD_ATTR_BACKEND_IDENTIFIER] = { .type = NLA_STRING}, | |
| 1746 | 1771 | }; |
| 1747 | 1772 | |
| 1748 | 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 | 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 | 1990 | out: |
| 1949 | 1991 | mutex_unlock(&nbd->config_lock); |
| 1950 | 1992 | if (!ret) { |
| @@ -2037,6 +2079,22 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info) · 86 unmodified lines | ||
| 2037 | 2079 | index); |
| 2038 | 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 | 2098 | if (!refcount_inc_not_zero(&nbd->refs)) { |
| 2041 | 2099 | mutex_unlock(&nbd_index_mutex); |
| 2042 | 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 | 1849 | if (!null_setup_fault()) |
| 1850 | 1850 | goto out_cleanup_tags; |
| 1851 | 1851 | |
| 1852 | − rv = -ENOMEM; | |
| 1853 | 1852 | nullb->tag_set->timeout = 5 * HZ; |
| 1854 | 1853 | nullb->disk = blk_mq_alloc_disk(nullb->tag_set, nullb); |
| 1855 | 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 | 704 | int ret = 0; |
| 705 | 705 | |
| 706 | 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 | 708 | if (IS_ERR(rq)) |
| 709 | 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 | 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 | 2190 | if (IS_ERR(rq)) { |
| 2191 | 2191 | ret = PTR_ERR(rq); |
| 2192 | 2192 | break; |
| @@ -202,7 +202,7 @@ static void mmc_blk_put(struct mmc_blk_data *md) · 201 unmodified lines | ||
| 202 | 202 | md->usage--; |
| 203 | 203 | if (md->usage == 0) { |
| 204 | 204 | int devidx = mmc_get_devidx(md->disk); |
| 205 | − blk_put_queue(md->queue.queue); | |
| 205 | + | |
| 206 | 206 | ida_simple_remove(&mmc_blk_ida, devidx); |
| 207 | 207 | put_disk(md->disk); |
| 208 | 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 | 2320 | md->read_only = mmc_blk_readonly(card); |
| 2321 | 2321 | |
| 2322 | − md->disk = alloc_disk(perdev_minors); | |
| 2323 | − if (md->disk == NULL) { | |
| 2324 | − ret = -ENOMEM; | |
| 2322 | + md->disk = mmc_init_queue(&md->queue, card); | |
| 2323 | + if (IS_ERR(md->disk)) { | |
| 2324 | + ret = PTR_ERR(md->disk); | |
| 2325 | 2325 | goto err_kfree; |
| 2326 | 2326 | } |
| 2327 | 2327 | |
| 2328 | 2328 | INIT_LIST_HEAD(&md->part); |
| 2329 | 2329 | INIT_LIST_HEAD(&md->rpmbs); |
| 2330 | 2330 | md->usage = 1; |
| 2331 | − | |
| 2332 | − ret = mmc_init_queue(&md->queue, card); | |
| 2333 | − if (ret) | |
| 2334 | − goto err_putdisk; | |
| 2335 | − | |
| 2336 | 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 | 2333 | md->disk->major = MMC_BLOCK_MAJOR; |
| 2334 | + md->disk->minors = perdev_minors; | |
| 2351 | 2335 | md->disk->first_minor = devidx * perdev_minors; |
| 2352 | 2336 | md->disk->fops = &mmc_bdops; |
| 2353 | 2337 | md->disk->private_data = md; |
| 2354 | − md->disk->queue = md->queue.queue; | |
| 2355 | 2338 | md->parent = parent; |
| 2356 | 2339 | set_disk_ro(md->disk, md->read_only || default_ro); |
| 2357 | 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 | 2384 | return md; |
| 2402 | 2385 | |
| 2403 | − err_putdisk: | |
| 2404 | − put_disk(md->disk); | |
| 2405 | 2386 | err_kfree: |
| 2406 | 2387 | kfree(md); |
| 2407 | 2388 | out: |
| @@ -424,9 +424,10 @@ static inline bool mmc_merge_capable(struct mmc_host *host) · 423 unmodified lines | ||
| 424 | 424 | * |
| 425 | 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 | 429 | struct mmc_host *host = card->host; |
| 430 | + struct gendisk *disk; | |
| 430 | 431 | int ret; |
| 431 | 432 | |
| 432 | 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 | 466 | ret = blk_mq_alloc_tag_set(&mq->tag_set); |
| 466 | 467 | if (ret) |
| 467 | − return ret; | |
| 468 | + return ERR_PTR(ret); | |
| 469 | + | |
| 468 | 470 | |
| 469 | − mq->queue = blk_mq_init_queue(&mq->tag_set); | |
| 470 | − if (IS_ERR(mq->queue)) { | |
| 471 | − ret = PTR_ERR(mq->queue); | |
| 472 | − goto free_tag_set; | |
| 471 | + disk = blk_mq_alloc_disk(&mq->tag_set, mq); | |
| 472 | + if (IS_ERR(disk)) { | |
| 473 | + blk_mq_free_tag_set(&mq->tag_set); | |
| 474 | + return disk; | |
| 473 | 475 | } |
| 476 | + mq->queue = disk->queue; | |
| 474 | 477 | |
| 475 | 478 | if (mmc_host_is_spi(host) && host->use_spi_crc) |
| 476 | 479 | blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, mq->queue); |
| 477 | − | |
| 478 | − mq->queue->queuedata = mq; | |
| 479 | 480 | blk_queue_rq_timeout(mq->queue, 60 * HZ); |
| 480 | 481 | |
| 481 | 482 | mmc_setup_queue(mq, card); |
| 482 | − return 0; | |
| 483 | − | |
| 484 | −free_tag_set: | |
| 485 | − blk_mq_free_tag_set(&mq->tag_set); | |
| 486 | − return ret; | |
| 483 | + return disk; | |
| 487 | 484 | } |
| 488 | 485 | |
| 489 | 486 | void mmc_queue_suspend(struct mmc_queue *mq) |
| @@ -94,7 +94,7 @@ struct mmc_queue { · 93 unmodified lines | ||
| 94 | 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 | 98 | extern void mmc_cleanup_queue(struct mmc_queue *); |
| 99 | 99 | extern void mmc_queue_suspend(struct mmc_queue *); |
| 100 | 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 | 610 | static inline void nvme_clear_nvme_request(struct request *req) |
| 611 | 611 | { |
| 612 | + nvme_req(req)->status = 0; | |
| 612 | 613 | nvme_req(req)->retries = 0; |
| 613 | 614 | nvme_req(req)->flags = 0; |
| 614 | 615 | req->rq_flags |= RQF_DONTPREP; |
| @@ -631,6 +632,8 @@ static inline void nvme_init_request(struct request *req, · 16 unmodified lines | ||
| 631 | 632 | cmd->common.flags &= ~NVME_CMD_SGL_ALL; |
| 632 | 633 | |
| 633 | 634 | req->cmd_flags |= REQ_FAILFAST_DRIVER; |
| 635 | + if (req->mq_hctx->type == HCTX_TYPE_POLL) | |
| 636 | + req->cmd_flags |= REQ_HIPRI; | |
| 634 | 637 | nvme_clear_nvme_request(req); |
| 635 | 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 | 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; | |
| 1037 | − complete(waiting); | |
| 1038 | −} | |
| 1039 | − | |
| 1040 | −static void nvme_execute_rq_polled(struct request_queue *q, | |
| 1041 | − struct gendisk *bd_disk, struct request *rq, int at_head) | |
| 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 | − } | |
| 1046 | + status = blk_execute_rq(disk, rq, at_head); | |
| 1047 | + if (nvme_req(rq)->flags & NVME_REQ_CANCELLED) | |
| 1048 | + return -EINTR; | |
| 1049 | + if (nvme_req(rq)->status) | |
| 1050 | + return nvme_req(rq)->status; | |
| 1051 | + return blk_status_to_errno(status); | |
| 1055 | 1052 | } |
| 1056 | 1053 | |
| 1057 | 1054 | /* |
| @@ -1061,7 +1058,7 @@ static void nvme_execute_rq_polled(struct request_queue *q, · 3 unmodified lines | ||
| 1061 | 1058 | int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, |
| 1062 | 1059 | union nvme_result *result, void *buffer, unsigned bufflen, |
| 1063 | 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 | 1063 | struct request *req; |
| 1067 | 1064 | int ret; |
| @@ -1082,16 +1079,9 @@ int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, · 14 unmodified lines | ||
| 1082 | 1079 | goto out; |
| 1083 | 1080 | } |
| 1084 | 1081 | |
| 1085 | − if (poll) | |
| 1086 | − nvme_execute_rq_polled(req->q, NULL, req, at_head); | |
| 1087 | − else | |
| 1088 | − blk_execute_rq(NULL, req, at_head); | |
| 1089 | − if (result) | |
| 1082 | + ret = nvme_execute_rq(NULL, req, at_head); | |
| 1083 | + if (result && ret >= 0) | |
| 1090 | 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 | 1085 | out: |
| 1096 | 1086 | blk_mq_free_request(req); |
| 1097 | 1087 | return ret; |
| @@ -1102,7 +1092,7 @@ int nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, · 4 unmodified lines | ||
| 1102 | 1092 | void *buffer, unsigned bufflen) |
| 1103 | 1093 | { |
| 1104 | 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 | 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 | 1174 | struct nvme_command *cmd = nvme_req(rq)->cmd; |
| 1185 | 1175 | struct nvme_ctrl *ctrl = nvme_req(rq)->ctrl; |
| 1186 | 1176 | struct nvme_ns *ns = rq->q->queuedata; |
| 1187 | 1177 | struct gendisk *disk = ns ? ns->disk : NULL; |
| 1188 | 1178 | u32 effects; |
| 1179 | + int ret; | |
| 1189 | 1180 | |
| 1190 | 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 | 1183 | if (effects) /* nothing to be done for zero cmd effects */ |
| 1193 | 1184 | nvme_passthru_end(ctrl, effects); |
| 1185 | + | |
| 1186 | + return ret; | |
| 1194 | 1187 | } |
| 1195 | 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 | 1458 | c.features.dword11 = cpu_to_le32(dword11); |
| 1466 | 1459 | |
| 1467 | 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 | 1462 | if (ret >= 0 && result) |
| 1470 | 1463 | *result = le32_to_cpu(res.u32); |
| 1471 | 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 | 2040 | cmd.common.cdw11 = cpu_to_le32(len); |
| 2048 | 2041 | |
| 2049 | 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 | 2045 | EXPORT_SYMBOL_GPL(nvme_sec_submit); |
| 2053 | 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 | 154 | cmd.prop_get.offset = cpu_to_le32(off); |
| 155 | 155 | |
| 156 | 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 | 159 | if (ret >= 0) |
| 160 | 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 | 200 | cmd.prop_get.offset = cpu_to_le32(off); |
| 201 | 201 | |
| 202 | 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 | 205 | if (ret >= 0) |
| 206 | 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 | 245 | cmd.prop_set.value = cpu_to_le64(val); |
| 246 | 246 | |
| 247 | 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 | 249 | if (unlikely(ret)) |
| 250 | 250 | dev_err(ctrl->device, |
| 251 | 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 | 392 | ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, &res, |
| 393 | 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 | 395 | if (ret) { |
| 396 | 396 | nvmf_log_connect_error(ctrl, ret, le32_to_cpu(res.u32), |
| 397 | 397 | &cmd, data); |
| @@ -415,7 +415,6 @@ EXPORT_SYMBOL_GPL(nvmf_connect_admin_queue); · 17 unmodified lines | ||
| 415 | 415 | * @qid: NVMe I/O queue number for the new I/O connection between |
| 416 | 416 | * host and target (note qid == 0 is illegal as this is |
| 417 | 417 | * the Admin queue, per NVMe standard). |
| 418 | − * @poll: Whether or not to poll for the completion of the connect cmd. | |
| 419 | 418 | * |
| 420 | 419 | * This function issues a fabrics-protocol connection |
| 421 | 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 | 426 | * > 0: NVMe error status code |
| 428 | 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 | 431 | struct nvme_command cmd = { }; |
| 433 | 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 | 453 | ret = __nvme_submit_sync_cmd(ctrl->connect_q, &cmd, &res, |
| 455 | 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 | 456 | if (ret) { |
| 458 | 457 | nvmf_log_connect_error(ctrl, ret, le32_to_cpu(res.u32), |
| 459 | 458 | &cmd, data); |
| @@ -182,7 +182,7 @@ int nvmf_reg_read32(struct nvme_ctrl *ctrl, u32 off, u32 *val); · 181 unmodified lines | ||
| 182 | 182 | int nvmf_reg_read64(struct nvme_ctrl *ctrl, u32 off, u64 *val); |
| 183 | 183 | int nvmf_reg_write32(struct nvme_ctrl *ctrl, u32 off, u32 val); |
| 184 | 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 | 186 | int nvmf_register_transport(struct nvmf_transport_ops *ops); |
| 187 | 187 | void nvmf_unregister_transport(struct nvmf_transport_ops *ops); |
| 188 | 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 | 2346 | (qsize / 5)); |
| 2347 | 2347 | if (ret) |
| 2348 | 2348 | break; |
| 2349 | − ret = nvmf_connect_io_queue(&ctrl->ctrl, i, false); | |
| 2349 | + ret = nvmf_connect_io_queue(&ctrl->ctrl, i); | |
| 2350 | 2350 | if (ret) |
| 2351 | 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); | |
| 97 | − if (nvme_req(req)->flags & NVME_REQ_CANCELLED) | |
| 98 | − ret = -EINTR; | |
| 99 | − else | |
| 100 | − ret = nvme_req(req)->status; | |
| 96 | + ret = nvme_execute_passthru_rq(req); | |
| 101 | 97 | if (result) |
| 102 | 98 | *result = le64_to_cpu(nvme_req(req)->result.u64); |
| 103 | 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 | 658 | int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, |
| 659 | 659 | union nvme_result *result, void *buffer, unsigned bufflen, |
| 660 | 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 | 662 | int nvme_set_features(struct nvme_ctrl *dev, unsigned int fid, |
| 663 | 663 | unsigned int dword11, void *buffer, size_t buflen, |
| 664 | 664 | u32 *result); |
| @@ -876,7 +876,7 @@ static inline bool nvme_ctrl_sgl_supported(struct nvme_ctrl *ctrl) · 211 unmodified lines | ||
| 876 | 876 | |
| 877 | 877 | u32 nvme_command_effects(struct nvme_ctrl *ctrl, struct nvme_ns *ns, |
| 878 | 878 | u8 opcode); |
| 879 | −void nvme_execute_passthru_rq(struct request *rq); | |
| 879 | +int nvme_execute_passthru_rq(struct request *rq); | |
| 880 | 880 | struct nvme_ctrl *nvme_ctrl_from_file(struct file *file); |
| 881 | 881 | struct nvme_ns *nvme_find_get_ns(struct nvme_ctrl *ctrl, unsigned nsid); |
| 882 | 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 | 680 | static int nvme_rdma_start_queue(struct nvme_rdma_ctrl *ctrl, int idx) |
| 681 | 681 | { |
| 682 | 682 | struct nvme_rdma_queue *queue = &ctrl->queues[idx]; |
| 683 | − bool poll = nvme_rdma_poll_queue(queue); | |
| 684 | 683 | int ret; |
| 685 | 684 | |
| 686 | 685 | if (idx) |
| 687 | − ret = nvmf_connect_io_queue(&ctrl->ctrl, idx, poll); | |
| 686 | + ret = nvmf_connect_io_queue(&ctrl->ctrl, idx); | |
| 688 | 687 | else |
| 689 | 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 | 1574 | int ret; |
| 1575 | 1575 | |
| 1576 | 1576 | if (idx) |
| 1577 | − ret = nvmf_connect_io_queue(nctrl, idx, false); | |
| 1577 | + ret = nvmf_connect_io_queue(nctrl, idx); | |
| 1578 | 1578 | else |
| 1579 | 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 | 337 | int i, ret; |
| 338 | 338 | |
| 339 | 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 | 341 | if (ret) |
| 342 | 342 | return ret; |
| 343 | 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 | 154 | struct nvmet_req *req = container_of(w, struct nvmet_req, p.work); |
| 155 | 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 | 160 | if (status == NVME_SC_SUCCESS && |
| 162 | 161 | req->cmd->common.opcode == nvme_admin_identify) { |
| 163 | 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 | 167 | nvmet_passthru_override_id_ns(req); |
| 169 | 168 | break; |
| 170 | 169 | } |
| 171 | − } | |
| 170 | + } else if (status < 0) | |
| 171 | + status = NVME_SC_INTERNAL; | |
| 172 | 172 | |
| 173 | 173 | req->cqe->result = nvme_req(rq)->result; |
| 174 | 174 | nvmet_req_complete(req, status); |
| @@ -1497,7 +1497,6 @@ static void nvmet_tcp_state_change(struct sock *sk) · 1496 unmodified lines | ||
| 1497 | 1497 | case TCP_CLOSE_WAIT: |
| 1498 | 1498 | case TCP_CLOSE: |
| 1499 | 1499 | /* FALLTHRU */ |
| 1500 | − sk->sk_user_data = NULL; | |
| 1501 | 1500 | nvmet_tcp_schedule_release_queue(queue); |
| 1502 | 1501 | break; |
| 1503 | 1502 | default: |
| @@ -621,7 +621,6 @@ void dasd_set_target_state(struct dasd_device *device, int target) · 620 unmodified lines | ||
| 621 | 621 | mutex_unlock(&device->state_mutex); |
| 622 | 622 | dasd_put_device(device); |
| 623 | 623 | } |
| 624 | −EXPORT_SYMBOL(dasd_set_target_state); | |
| 625 | 624 | |
| 626 | 625 | /* |
| 627 | 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 | 746 | memcpy(uid->vendor, private->ned->HDA_manufacturer, |
| 747 | 747 | sizeof(uid->vendor) - 1); |
| 748 | 748 | EBCASC(uid->vendor, sizeof(uid->vendor) - 1); |
| 749 | − memcpy(uid->serial, private->ned->HDA_location, | |
| 749 | + memcpy(uid->serial, &private->ned->serial, | |
| 750 | 750 | sizeof(uid->serial) - 1); |
| 751 | 751 | EBCASC(uid->serial, sizeof(uid->serial) - 1); |
| 752 | 752 | uid->ssid = private->gneq->subsystemID; |
| @@ -332,8 +332,10 @@ struct dasd_ned { · 331 unmodified lines | ||
| 332 | 332 | __u8 dev_type[6]; |
| 333 | 333 | __u8 dev_model[3]; |
| 334 | 334 | __u8 HDA_manufacturer[3]; |
| 335 | − __u8 HDA_location[2]; | |
| 336 | − __u8 HDA_seqno[12]; | |
| 335 | + struct { | |
| 336 | + __u8 HDA_location[2]; | |
| 337 | + __u8 HDA_seqno[12]; | |
| 338 | + } serial; | |
| 337 | 339 | __u8 ID; |
| 338 | 340 | __u8 unit_addr; |
| 339 | 341 | } __attribute__ ((packed)); |
| @@ -1997,7 +1997,7 @@ static void scsi_eh_lock_door(struct scsi_device *sdev) · 1996 unmodified lines | ||
| 1997 | 1997 | struct request *req; |
| 1998 | 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 | 2001 | if (IS_ERR(req)) |
| 2002 | 2002 | return; |
| 2003 | 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 | 216 | req = blk_get_request(sdev->request_queue, |
| 217 | 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 | 219 | rq_flags & RQF_PM ? BLK_MQ_REQ_PM : 0); |
| 220 | 220 | if (IS_ERR(req)) |
| 221 | 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 | 543 | if (blk_queue_add_random(q)) |
| 544 | 544 | add_disk_randomness(req->rq_disk); |
| 545 | 545 | |
| 546 | − if (!blk_rq_is_scsi(req)) { | |
| 546 | + if (!blk_rq_is_passthrough(req)) { | |
| 547 | 547 | WARN_ON_ONCE(!(cmd->flags & SCMD_INITIALIZED)); |
| 548 | 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 | 1113 | bool in_flight; |
| 1114 | 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 | 1117 | flags |= SCMD_INITIALIZED; |
| 1118 | 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 | 1554 | * Special handling for passthrough commands, which don't go to the ULP |
| 1555 | 1555 | * at all: |
| 1556 | 1556 | */ |
| 1557 | − if (blk_rq_is_scsi(req)) | |
| 1557 | + if (blk_rq_is_passthrough(req)) | |
| 1558 | 1558 | return scsi_setup_scsi_cmnd(sdev, req); |
| 1559 | 1559 | |
| 1560 | 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 | 1759 | * not expect an EWOULDBLOCK from this condition. |
| 1760 | 1760 | */ |
| 1761 | 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 | 1763 | if (IS_ERR(rq)) { |
| 1764 | 1764 | kfree(long_cmdp); |
| 1765 | 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 | 550 | req = blk_get_request(SRpnt->stp->device->request_queue, |
| 551 | 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 | 553 | if (IS_ERR(req)) |
| 554 | 554 | return PTR_ERR(req); |
| 555 | 555 | rq = scsi_req(req); |
| @@ -982,7 +982,7 @@ pscsi_execute_cmd(struct se_cmd *cmd) · 981 unmodified lines | ||
| 982 | 982 | |
| 983 | 983 | req = blk_get_request(pdv->pdv_sd->request_queue, |
| 984 | 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 | 986 | if (IS_ERR(req)) { |
| 987 | 987 | pr_err("PSCSI: blk_get_request() failed\n"); |
| 988 | 988 | ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
| @@ -236,7 +236,7 @@ again: · 235 unmodified lines | ||
| 236 | 236 | if (!buf) |
| 237 | 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 | 240 | if (IS_ERR(rq)) { |
| 241 | 241 | error = -ENOMEM; |
| 242 | 242 | goto out_free_buf; |
| @@ -439,8 +439,6 @@ enum { · 438 unmodified lines | ||
| 439 | 439 | struct gendisk *__blk_mq_alloc_disk(struct blk_mq_tag_set *set, |
| 440 | 440 | void *queuedata); |
| 441 | 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 | 442 | int blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, |
| 445 | 443 | struct request_queue *q); |
| 446 | 444 | void blk_mq_unregister_dev(struct device *, struct request_queue *); |
| @@ -351,9 +351,6 @@ enum req_opf { · 350 unmodified lines | ||
| 351 | 351 | /* reset all the zone present on the device */ |
| 352 | 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 | 354 | /* Driver private requests */ |
| 358 | 355 | REQ_OP_DRV_IN = 34, |
| 359 | 356 | REQ_OP_DRV_OUT = 35, |
| @@ -240,42 +240,15 @@ struct request { · 239 unmodified lines | ||
| 240 | 240 | void *end_io_data; |
| 241 | 241 | }; |
| 242 | 242 | |
| 243 | −static inline bool blk_op_is_scsi(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) | |
| 243 | +static inline bool blk_op_is_passthrough(unsigned int op) | |
| 249 | 244 | { |
| 245 | + op &= REQ_OP_MASK; | |
| 250 | 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 | 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); | |
| 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)); | |
| 251 | + return blk_op_is_passthrough(req_op(rq)); | |
| 279 | 252 | } |
| 280 | 253 | |
| 281 | 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 | 909 | extern int blk_rq_map_user_iov(struct request_queue *, struct request *, |
| 937 | 910 | struct rq_map_data *, const struct iov_iter *, |
| 938 | 911 | gfp_t); |
| 939 | −extern void blk_execute_rq(struct gendisk *, struct request *, int); | |
| 940 | 912 | extern void blk_execute_rq_nowait(struct gendisk *, |
| 941 | 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 | 918 | /* Helper to convert REQ_OP_XXX to its string format XXX */ |
| 944 | 919 | extern const char *blk_op_str(unsigned int op); |
| 945 | 920 | |
| @@ -35,6 +35,7 @@ enum { · 34 unmodified lines | ||
| 35 | 35 | NBD_ATTR_SOCKETS, |
| 36 | 36 | NBD_ATTR_DEAD_CONN_TIMEOUT, |
| 37 | 37 | NBD_ATTR_DEVICE_LIST, |
| 38 | + NBD_ATTR_BACKEND_IDENTIFIER, | |
| 38 | 39 | __NBD_ATTR_MAX, |
| 39 | 40 | }; |
| 40 | 41 | #define NBD_ATTR_MAX (__NBD_ATTR_MAX - 1) |