History

Merge tag 'block-5.14-2021-07-08' of git://git.kernel.dk/linux-block

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 ...

Linus Torvalds committed 5 years ago

Commit a022f7d2 parents 3de6295 a73176343 files · +346 −520Browse files

Unified · Split

43 files
  1. arch/um/drivers/ubd_kern.c +26 −134
  2. block/blk-cgroup.c +15 −0
  3. block/blk-core.c +1 −3
  4. block/blk-exec.c +22 −3
  5. block/blk-mq.c +1 −2
  6. block/bsg-lib.c +1 −1
  7. block/bsg.c +1 −1
  8. block/genhd.c +2 −2
  9. block/partitions/core.c +17 −12
  10. block/scsi_ioctl.c +3 −3
  11. drivers/block/loop.c +70 −99
  12. drivers/block/mtip32xx/mtip32xx.c +42 −108
  13. drivers/block/nbd.c +59 −1
  14. drivers/block/null_blk/main.c +0 −1
  15. drivers/block/pktcdvd.c +1 −1
  16. drivers/cdrom/cdrom.c +1 −1
  17. drivers/mmc/core/block.c +5 −24
  18. drivers/mmc/core/queue.c +10 −13
  19. drivers/mmc/core/queue.h +1 −1
  20. drivers/nvme/host/core.c +29 −36
  21. drivers/nvme/host/fabrics.c +6 −7
  22. drivers/nvme/host/fabrics.h +1 −1
  23. drivers/nvme/host/fc.c +1 −1
  24. drivers/nvme/host/ioctl.c +1 −5
  25. drivers/nvme/host/nvme.h +2 −2
  26. drivers/nvme/host/rdma.c +1 −2
  27. drivers/nvme/host/tcp.c +1 −1
  28. drivers/nvme/target/loop.c +1 −1
  29. drivers/nvme/target/passthru.c +4 −4
  30. drivers/nvme/target/tcp.c +0 −1
  31. drivers/s390/block/dasd.c +0 −1
  32. drivers/s390/block/dasd_eckd.c +1 −1
  33. drivers/s390/block/dasd_eckd.h +4 −2
  34. drivers/scsi/scsi_error.c +1 −1
  35. drivers/scsi/scsi_lib.c +4 −4
  36. drivers/scsi/sg.c +1 −1
  37. drivers/scsi/st.c +1 −1
  38. drivers/target/target_core_pscsi.c +1 −1
  39. fs/nfsd/blocklayout.c +1 −1
  40. include/linux/blk-mq.h +0 −2
  41. include/linux/blk_types.h +0 −3
  42. include/linux/blkdev.h +6 −31
  43. include/uapi/linux/nbd-netlink.h +1 −0
arch/um/drivers/ubd_kern.c+26−134
@@ -125,9 +125,7 @@ static const struct block_device_operations ubd_blops = { · 124 unmodified lines
125125 };
126126
127127 /* Protected by ubd_lock */
128−static int fake_major = UBD_MAJOR;
129128 static struct gendisk *ubd_gendisk[MAX_DEV];
130−static struct gendisk *fake_gendisk[MAX_DEV];
131129
132130 #ifdef CONFIG_BLK_DEV_UBD_SYNC
133131 #define OPEN_FLAGS ((struct openflags) { .r = 1, .w = 1, .s = 1, .c = 0, \
@@ -197,54 +195,19 @@ struct ubd { · 63 unmodified lines
197195 /* Protected by ubd_lock */
198196 static struct ubd ubd_devs[MAX_DEV] = { [0 ... MAX_DEV - 1] = DEFAULT_UBD };
199197
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−
205198 static blk_status_t ubd_queue_rq(struct blk_mq_hw_ctx *hctx,
206199 const struct blk_mq_queue_data *bd);
207200
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−
237201 static int fake_ide_setup(char *str)
238202 {
239− fake_ide = 1;
203+ pr_warn("The fake_ide option has been removed\n");
240204 return 1;
241205 }
242−
243206 __setup("fake_ide", fake_ide_setup);
244207
245208 __uml_help(fake_ide_setup,
246209 "fake_ide\n"
247−" Create ide0 entries that map onto ubd devices.\n\n"
210+" Obsolete stub.\n\n"
248211 );
249212
250213 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
280243 if(index_out) *index_out = -1;
281244 n = *str;
282245 if(n == '='){
283− char *end;
284− int major;
285−
286246 str++;
287247 if(!strcmp(str, "sync")){
288248 global_openflags = of_sync(global_openflags);
289249 return err;
290250 }
291251
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;
313254 }
314255
315256 n = parse_unit(&str);
@@ -874,7 +815,6 @@ static void ubd_device_release(struct device *dev) · 558 unmodified lines
874815 {
875816 struct ubd *ubd_dev = dev_get_drvdata(dev);
876817
877− blk_cleanup_queue(ubd_dev->queue);
878818 blk_mq_free_tag_set(&ubd_dev->tag_set);
879819 *ubd_dev = ((struct ubd) DEFAULT_UBD);
880820 }
@@ -914,41 +854,25 @@ static const struct attribute_group *ubd_attr_groups[] = { · 33 unmodified lines
914854 NULL,
915855 };
916856
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)
919859 {
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−
927860 disk->major = major;
928861 disk->first_minor = unit << UBD_SHIFT;
862+ disk->minors = 1 << UBD_SHIFT;
929863 disk->fops = &ubd_blops;
930864 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);
945872
946873 disk->private_data = &ubd_devs[unit];
947874 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);
952876 }
953877
954878 #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
960884 static int ubd_add(int n, char **error_out)
961885 {
962886 struct ubd *ubd_dev = &ubd_devs[n];
887+ struct gendisk *disk;
963888 int err = 0;
964889
965890 if(ubd_dev->file == NULL)
@@ -984,43 +909,24 @@ static int ubd_add(int n, char **error_out) · 18 unmodified lines
984909 if (err)
985910 goto out;
986911
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);
990915 goto out_cleanup_tags;
991916 }
917+ ubd_dev->queue = disk->queue;
992918
993− ubd_dev->queue->queuedata = ubd_dev;
994919 blk_queue_write_cache(ubd_dev->queue, true, false);
995−
996920 blk_queue_max_segments(ubd_dev->queue, MAX_SG);
997921 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;
1018925
1019926 out_cleanup_tags:
1020927 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;
1024930 }
1025931
1026932 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
11231029 ubd_gendisk[n] = NULL;
11241030 if(disk != NULL){
11251031 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);
11331033 }
11341034
11351035 err = 0;
@@ -1188,14 +1088,6 @@ static int __init ubd_init(void) · 52 unmodified lines
11881088 if (register_blkdev(UBD_MAJOR, "ubd"))
11891089 return -1;
11901090
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−
11991091 irq_req_buffer = kmalloc_array(UBD_REQ_BUFFER_SIZE,
12001092 sizeof(struct io_thread_req *),
12011093 GFP_KERNEL
block/blk-cgroup.c+15−0
@@ -56,6 +56,8 @@ static LIST_HEAD(all_blkcgs); /* protected by blkcg_pol_mutex */ · 55 unmodified lines
5656 bool blkcg_debug_stats = false;
5757 static struct workqueue_struct *blkcg_punt_bio_wq;
5858
59+#define BLKG_DESTROY_BATCH_SIZE 64
60+
5961 static bool blkcg_policy_enabled(struct request_queue *q,
6062 const struct blkcg_policy *pol)
6163 {
@@ -422,7 +424,9 @@ static void blkg_destroy(struct blkcg_gq *blkg) · 360 unmodified lines
422424 static void blkg_destroy_all(struct request_queue *q)
423425 {
424426 struct blkcg_gq *blkg, *n;
427+ int count = BLKG_DESTROY_BATCH_SIZE;
425428
429+restart:
426430 spin_lock_irq(&q->queue_lock);
427431 list_for_each_entry_safe(blkg, n, &q->blkg_list, q_node) {
428432 struct blkcg *blkcg = blkg->blkcg;
@@ -430,6 +434,17 @@ static void blkg_destroy_all(struct request_queue *q) · 1 unmodified line
430434 spin_lock(&blkcg->lock);
431435 blkg_destroy(blkg);
432436 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+ }
433448 }
434449
435450 q->root_blkg = NULL;
block/blk-core.c+1−3
@@ -142,8 +142,6 @@ static const char *const blk_op_name[] = { · 141 unmodified lines
142142 REQ_OP_NAME(ZONE_APPEND),
143143 REQ_OP_NAME(WRITE_SAME),
144144 REQ_OP_NAME(WRITE_ZEROES),
145− REQ_OP_NAME(SCSI_IN),
146− REQ_OP_NAME(SCSI_OUT),
147145 REQ_OP_NAME(DRV_IN),
148146 REQ_OP_NAME(DRV_OUT),
149147 };
@@ -1243,7 +1241,7 @@ static void update_io_ticks(struct block_device *part, unsigned long now, · 1093 unmodified lines
12431241 unsigned long stamp;
12441242 again:
12451243 stamp = READ_ONCE(part->bd_stamp);
1246− if (unlikely(stamp != now)) {
1244+ if (unlikely(time_after(now, stamp))) {
12471245 if (likely(cmpxchg(&part->bd_stamp, stamp, now) == stamp))
12481246 __part_stat_add(part, io_ticks, end ? now - stamp : 1);
12491247 }
block/blk-exec.c+22−3
@@ -21,7 +21,7 @@ static void blk_end_sync_rq(struct request *rq, blk_status_t error) · 20 unmodified lines
2121 {
2222 struct completion *waiting = rq->end_io_data;
2323
24− rq->end_io_data = NULL;
24+ rq->end_io_data = (void *)(uintptr_t)error;
2525
2626 /*
2727 * 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
6363 }
6464 EXPORT_SYMBOL_GPL(blk_execute_rq_nowait);
6565
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+
6679 /**
6780 * blk_execute_rq - insert a request into queue for execution
6881 * @bd_disk: matching gendisk
@@ -72,8 +85,9 @@ EXPORT_SYMBOL_GPL(blk_execute_rq_nowait); · 3 unmodified lines
7285 * Description:
7386 * Insert a fully prepared request at the back of the I/O scheduler queue
7487 * for execution and wait for completion.
88+ * Return: The blk_status_t result provided to blk_mq_end_request().
7589 */
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)
7791 {
7892 DECLARE_COMPLETION_ONSTACK(wait);
7993 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
8397
8498 /* Prevent hang_check timer from firing at us during very long I/O */
8599 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)
87104 while (!wait_for_completion_io_timeout(&wait, hang_check * (HZ/2)));
88105 else
89106 wait_for_completion_io(&wait);
107+
108+ return (blk_status_t)(uintptr_t)rq->end_io_data;
90109 }
91110 EXPORT_SYMBOL(blk_execute_rq);
block/blk-mq.c+1−2
@@ -3109,7 +3109,7 @@ void blk_mq_release(struct request_queue *q) · 3108 unmodified lines
31093109 blk_mq_sysfs_deinit(q);
31103110 }
31113111
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,
31133113 void *queuedata)
31143114 {
31153115 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
31263126 }
31273127 return q;
31283128 }
3129−EXPORT_SYMBOL_GPL(blk_mq_init_queue_data);
31303129
31313130 struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *set)
31323131 {
block/bsg-lib.c+1−1
@@ -45,7 +45,7 @@ static int bsg_transport_fill_hdr(struct request *rq, struct sg_io_v4 *hdr, · 44 unmodified lines
4545 return PTR_ERR(job->request);
4646
4747 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);
4949 if (IS_ERR(job->bidi_rq)) {
5050 ret = PTR_ERR(job->bidi_rq);
5151 goto out;
block/bsg.c+1−1
@@ -154,7 +154,7 @@ static int bsg_sg_io(struct request_queue *q, fmode_t mode, void __user *uarg) · 153 unmodified lines
154154 return ret;
155155
156156 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);
158158 if (IS_ERR(rq))
159159 return PTR_ERR(rq);
160160
block/genhd.c+2−2
@@ -365,12 +365,12 @@ void disk_uevent(struct gendisk *disk, enum kobject_action action) · 364 unmodified lines
365365 xa_for_each(&disk->part_tbl, idx, part) {
366366 if (bdev_is_partition(part) && !bdev_nr_sectors(part))
367367 continue;
368− if (!bdgrab(part))
368+ if (!kobject_get_unless_zero(&part->bd_device.kobj))
369369 continue;
370370
371371 rcu_read_unlock();
372372 kobject_uevent(bdev_kobj(part), action);
373− bdput(part);
373+ put_device(&part->bd_device);
374374 rcu_read_lock();
375375 }
376376 rcu_read_unlock();
block/partitions/core.c+17−12
@@ -453,17 +453,26 @@ int bdev_add_partition(struct block_device *bdev, int partno, · 452 unmodified lines
453453 sector_t start, sector_t length)
454454 {
455455 struct block_device *part;
456+ struct gendisk *disk = bdev->bd_disk;
457+ int ret;
456458
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;
461468 }
462469
463− part = add_partition(bdev->bd_disk, partno, start, length,
470+ part = add_partition(disk, partno, start, length,
464471 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;
467476 }
468477
469478 int bdev_del_partition(struct block_device *bdev, int partno)
@@ -537,12 +546,8 @@ void blk_drop_partitions(struct gendisk *disk) · 67 unmodified lines
537546
538547 lockdep_assert_held(&disk->open_mutex);
539548
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)
543550 delete_partition(part);
544− bdput(part);
545− }
546551 }
547552
548553 static bool blk_add_partition(struct gendisk *disk,
block/scsi_ioctl.c+3−3
@@ -313,7 +313,7 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk, · 312 unmodified lines
313313 at_head = 1;
314314
315315 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);
317317 if (IS_ERR(rq))
318318 return PTR_ERR(rq);
319319 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
435435
436436 }
437437
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);
439439 if (IS_ERR(rq)) {
440440 err = PTR_ERR(rq);
441441 goto error_free_buffer;
@@ -524,7 +524,7 @@ static int __blk_send_generic(struct request_queue *q, struct gendisk *bd_disk, · 82 unmodified lines
524524 struct request *rq;
525525 int err;
526526
527− rq = blk_get_request(q, REQ_OP_SCSI_OUT, 0);
527+ rq = blk_get_request(q, REQ_OP_DRV_OUT, 0);
528528 if (IS_ERR(rq))
529529 return PTR_ERR(rq);
530530 rq->timeout = BLK_DEFAULT_SG_TIMEOUT;
drivers/block/loop.c+70−99
@@ -1434,7 +1434,6 @@ static int · 1433 unmodified lines
14341434 loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
14351435 {
14361436 int err;
1437− struct block_device *bdev;
14381437 kuid_t uid = current_uid();
14391438 int prev_lo_flags;
14401439 bool partscan = false;
@@ -1503,7 +1502,6 @@ out_unfreeze: · 62 unmodified lines
15031502 if (!err && (lo->lo_flags & LO_FLAGS_PARTSCAN) &&
15041503 !(prev_lo_flags & LO_FLAGS_PARTSCAN)) {
15051504 lo->lo_disk->flags &= ~GENHD_FL_NO_PART_SCAN;
1506− bdev = lo->lo_device;
15071505 partscan = true;
15081506 }
15091507 out_unlock:
@@ -2237,7 +2235,7 @@ static const struct blk_mq_ops loop_mq_ops = { · 727 unmodified lines
22372235 .complete = lo_complete_rq,
22382236 };
22392237
2240−static int loop_add(struct loop_device **l, int i)
2238+static int loop_add(int i)
22412239 {
22422240 struct loop_device *lo;
22432241 struct gendisk *disk;
@@ -2247,9 +2245,12 @@ static int loop_add(struct loop_device **l, int i) · 3 unmodified lines
22472245 lo = kzalloc(sizeof(*lo), GFP_KERNEL);
22482246 if (!lo)
22492247 goto out;
2250−
22512248 lo->lo_state = Lo_unbound;
22522249
2250+ err = mutex_lock_killable(&loop_ctl_mutex);
2251+ if (err)
2252+ goto out_free_dev;
2253+
22532254 /* allocate id, if @id >= 0, we're requesting that specific id */
22542255 if (i >= 0) {
22552256 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
22592260 err = idr_alloc(&loop_index_idr, lo, 0, 0, GFP_KERNEL);
22602261 }
22612262 if (err < 0)
2262− goto out_free_dev;
2263+ goto out_unlock;
22632264 i = err;
22642265
22652266 err = -ENOMEM;
@@ -2326,13 +2327,15 @@ static int loop_add(struct loop_device **l, int i) · 60 unmodified lines
23262327 disk->queue = lo->lo_queue;
23272328 sprintf(disk->disk_name, "loop%d", i);
23282329 add_disk(disk);
2329− *l = lo;
2330− return lo->lo_number;
2330+ mutex_unlock(&loop_ctl_mutex);
2331+ return i;
23312332
23322333 out_cleanup_tags:
23332334 blk_mq_free_tag_set(&lo->tag_set);
23342335 out_free_idr:
23352336 idr_remove(&loop_index_idr, i);
2337+out_unlock:
2338+ mutex_unlock(&loop_ctl_mutex);
23362339 out_free_dev:
23372340 kfree(lo);
23382341 out:
@@ -2348,109 +2351,86 @@ static void loop_remove(struct loop_device *lo) · 9 unmodified lines
23482351 kfree(lo);
23492352 }
23502353
2351−static int find_free_cb(int id, void *ptr, void *data)
2354+static void loop_probe(dev_t dev)
23522355 {
2353− struct loop_device *lo = ptr;
2354− struct loop_device **l = data;
2356+ int idx = MINOR(dev) >> part_shift;
23552357
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);
23612361 }
23622362
2363−static int loop_lookup(struct loop_device **l, int i)
2363+static int loop_control_remove(int idx)
23642364 {
23652365 struct loop_device *lo;
2366− int ret = -ENODEV;
2366+ int ret;
23672367
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;
23702376
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;
23772381 }
23782382
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;
23842391 }
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);
23862399 return ret;
23872400 }
23882401
2389−static void loop_probe(dev_t dev)
2402+static int loop_control_get_free(int idx)
23902403 {
2391− int idx = MINOR(dev) >> part_shift;
23922404 struct loop_device *lo;
2405+ int id, ret;
23932406
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+ }
24002414 mutex_unlock(&loop_ctl_mutex);
2415+ return loop_add(-1);
2416+found:
2417+ mutex_unlock(&loop_ctl_mutex);
2418+ return id;
24012419 }
24022420
24032421 static long loop_control_ioctl(struct file *file, unsigned int cmd,
24042422 unsigned long parm)
24052423 {
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;
24142424 switch (cmd) {
24152425 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);
24232427 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);
24452429 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;
24502433 }
2451− mutex_unlock(&loop_ctl_mutex);
2452−
2453− return ret;
24542434 }
24552435
24562436 static const struct file_operations loop_ctl_fops = {
@@ -2473,7 +2453,6 @@ MODULE_ALIAS("devname:loop-control"); · 16 unmodified lines
24732453 static int __init loop_init(void)
24742454 {
24752455 int i, nr;
2476− struct loop_device *lo;
24772456 int err;
24782457
24792458 part_shift = 0;
@@ -2525,10 +2504,8 @@ static int __init loop_init(void) · 45 unmodified lines
25252504 }
25262505
25272506 /* pre-create number of devices given by config or max_loop */
2528− mutex_lock(&loop_ctl_mutex);
25292507 for (i = 0; i < nr; i++)
2530− loop_add(&lo, i);
2531− mutex_unlock(&loop_ctl_mutex);
2508+ loop_add(i);
25322509
25332510 printk(KERN_INFO "loop: module loaded\n");
25342511 return 0;
@@ -2539,26 +2516,20 @@ err_out: · 4 unmodified lines
25392516 return err;
25402517 }
25412518
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−
25502519 static void __exit loop_exit(void)
25512520 {
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;
25562523
25572524 unregister_blkdev(LOOP_MAJOR, "loop");
2558−
25592525 misc_deregister(&loop_misc);
25602526
2527+ mutex_lock(&loop_ctl_mutex);
2528+ idr_for_each_entry(&loop_index_idr, lo, id)
2529+ loop_remove(lo);
25612530 mutex_unlock(&loop_ctl_mutex);
2531+
2532+ idr_destroy(&loop_index_idr);
25622533 }
25632534
25642535 module_init(loop_init);
drivers/block/mtip32xx/mtip32xx.c+42−108
@@ -2160,6 +2160,20 @@ static ssize_t mtip_hw_show_status(struct device *dev, · 2159 unmodified lines
21602160
21612161 static DEVICE_ATTR(status, 0444, mtip_hw_show_status, NULL);
21622162
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+
21632177 /* debugsfs entries */
21642178
21652179 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
23742388 .llseek = no_llseek,
23752389 };
23762390
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−
24182391 static int mtip_hw_debugfs_init(struct driver_data *dd)
24192392 {
24202393 if (!dfs_parent)
@@ -3566,7 +3539,6 @@ static int mtip_block_initialize(struct driver_data *dd) · 1145 unmodified lines
35663539 int rv = 0, wait_for_rebuild = 0;
35673540 sector_t capacity;
35683541 unsigned int index = 0;
3569− struct kobject *kobj;
35703542
35713543 if (dd->disk)
35723544 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
35763548 goto protocol_init_error;
35773549 }
35783550
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−
36083551 memset(&dd->tags, 0, sizeof(dd->tags));
36093552 dd->tags.ops = &mtip_mq_ops;
36103553 dd->tags.nr_hw_queues = 1;
@@ -3623,17 +3566,35 @@ static int mtip_block_initialize(struct driver_data *dd) · 12 unmodified lines
36233566 goto block_queue_alloc_tag_error;
36243567 }
36253568
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)) {
36293571 dev_err(&dd->pdev->dev,
36303572 "Unable to allocate request queue\n");
36313573 rv = -ENOMEM;
36323574 goto block_queue_alloc_init_error;
36333575 }
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;
36343596
3635− dd->disk->queue = dd->queue;
3636− dd->queue->queuedata = dd;
3597+ mtip_hw_debugfs_init(dd);
36373598
36383599 skip_create_disk:
36393600 /* Initialize the protocol layer. */
@@ -3672,17 +3633,7 @@ skip_create_disk: · 32 unmodified lines
36723633 set_capacity(dd->disk, capacity);
36733634
36743635 /* 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);
36863637
36873638 if (dd->mtip_svc_handler) {
36883639 set_bit(MTIP_DDF_INIT_DONE_BIT, &dd->dd_flag);
@@ -3709,23 +3660,17 @@ start_service_thread: · 20 unmodified lines
37093660 kthread_run_error:
37103661 /* Delete our gendisk. This also removes the device from /dev */
37113662 del_gendisk(dd->disk);
3712−
37133663 read_capacity_error:
37143664 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:
37193665 mtip_hw_debugfs_exit(dd);
37203666 disk_index_error:
37213667 ida_free(&rssd_index_ida, index);
3722−
37233668 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:
37273673 mtip_hw_exit(dd); /* De-initialize the protocol layer. */
3728−
37293674 protocol_init_error:
37303675 return rv;
37313676 }
@@ -3751,8 +3696,6 @@ static bool mtip_no_dev_cleanup(struct request *rq, void *data, bool reserv) · 19 unmodified lines
37513696 */
37523697 static int mtip_block_remove(struct driver_data *dd)
37533698 {
3754− struct kobject *kobj;
3755−
37563699 mtip_hw_debugfs_exit(dd);
37573700
37583701 if (dd->mtip_svc_handler) {
@@ -3761,15 +3704,6 @@ static int mtip_block_remove(struct driver_data *dd) · 2 unmodified lines
37613704 kthread_stop(dd->mtip_svc_handler);
37623705 }
37633706
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−
37733707 if (!dd->sr) {
37743708 /*
37753709 * Explicitly wait here for IOs to quiesce,
drivers/block/nbd.c+59−1
@@ -79,6 +79,7 @@ struct link_dead_args { · 78 unmodified lines
7979 #define NBD_RT_HAS_CONFIG_REF 4
8080 #define NBD_RT_BOUND 5
8181 #define NBD_RT_DISCONNECT_ON_CLOSE 6
82+#define NBD_RT_HAS_BACKEND_FILE 7
8283
8384 #define NBD_DESTROY_ON_DISCONNECT 0
8485 #define NBD_DISCONNECT_REQUESTED 1
@@ -119,6 +120,8 @@ struct nbd_device { · 34 unmodified lines
119120
120121 struct completion *destroy_complete;
121122 unsigned long flags;
123+
124+ char *backend;
122125 };
123126
124127 #define NBD_CMD_REQUEUED 1
@@ -216,6 +219,20 @@ static const struct device_attribute pid_attr = { · 91 unmodified lines
216219 .show = pid_show,
217220 };
218221
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+
219236 static void nbd_dev_remove(struct nbd_device *nbd)
220237 {
221238 struct gendisk *disk = nbd->disk;
@@ -1211,6 +1228,12 @@ static void nbd_config_put(struct nbd_device *nbd) · 989 unmodified lines
12111228 &config->runtime_flags))
12121229 device_remove_file(disk_to_dev(nbd->disk), &pid_attr);
12131230 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+ }
12141237 nbd_clear_sock(nbd);
12151238 if (config->num_connections) {
12161239 int i;
@@ -1270,7 +1293,7 @@ static int nbd_start_device(struct nbd_device *nbd) · 53 unmodified lines
12701293
12711294 error = device_create_file(disk_to_dev(nbd->disk), &pid_attr);
12721295 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");
12741297 return error;
12751298 }
12761299 set_bit(NBD_RT_HAS_PID_FILE, &config->runtime_flags);
@@ -1657,6 +1680,7 @@ static int nbd_dev_add(int index) · 380 unmodified lines
16571680 BLK_MQ_F_BLOCKING;
16581681 nbd->tag_set.driver_data = nbd;
16591682 nbd->destroy_complete = NULL;
1683+ nbd->backend = NULL;
16601684
16611685 err = blk_mq_alloc_tag_set(&nbd->tag_set);
16621686 if (err)
@@ -1743,6 +1767,7 @@ static const struct nla_policy nbd_attr_policy[NBD_ATTR_MAX + 1] = { · 80 unmodified lines
17431767 [NBD_ATTR_SOCKETS] = { .type = NLA_NESTED},
17441768 [NBD_ATTR_DEAD_CONN_TIMEOUT] = { .type = NLA_U64 },
17451769 [NBD_ATTR_DEVICE_LIST] = { .type = NLA_NESTED},
1770+ [NBD_ATTR_BACKEND_IDENTIFIER] = { .type = NLA_STRING},
17461771 };
17471772
17481773 static const struct nla_policy nbd_sock_policy[NBD_SOCK_MAX + 1] = {
@@ -1945,6 +1970,23 @@ again: · 196 unmodified lines
19451970 }
19461971 }
19471972 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);
19481990 out:
19491991 mutex_unlock(&nbd->config_lock);
19501992 if (!ret) {
@@ -2037,6 +2079,22 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info) · 86 unmodified lines
20372079 index);
20382080 return -EINVAL;
20392081 }
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+ }
20402098 if (!refcount_inc_not_zero(&nbd->refs)) {
20412099 mutex_unlock(&nbd_index_mutex);
20422100 printk(KERN_ERR "nbd: device at index %d is going down\n",
drivers/block/null_blk/main.c+0−1
@@ -1849,7 +1849,6 @@ static int null_add_dev(struct nullb_device *dev) · 1848 unmodified lines
18491849 if (!null_setup_fault())
18501850 goto out_cleanup_tags;
18511851
1852− rv = -ENOMEM;
18531852 nullb->tag_set->timeout = 5 * HZ;
18541853 nullb->disk = blk_mq_alloc_disk(nullb->tag_set, nullb);
18551854 if (IS_ERR(nullb->disk)) {
drivers/block/pktcdvd.c+1−1
@@ -704,7 +704,7 @@ static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command * · 703 unmodified lines
704704 int ret = 0;
705705
706706 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);
708708 if (IS_ERR(rq))
709709 return PTR_ERR(rq);
710710
drivers/cdrom/cdrom.c+1−1
@@ -2186,7 +2186,7 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf, · 2185 unmodified lines
21862186
21872187 len = nr * CD_FRAMESIZE_RAW;
21882188
2189− rq = blk_get_request(q, REQ_OP_SCSI_IN, 0);
2189+ rq = blk_get_request(q, REQ_OP_DRV_IN, 0);
21902190 if (IS_ERR(rq)) {
21912191 ret = PTR_ERR(rq);
21922192 break;
drivers/mmc/core/block.c+5−24
@@ -202,7 +202,7 @@ static void mmc_blk_put(struct mmc_blk_data *md) · 201 unmodified lines
202202 md->usage--;
203203 if (md->usage == 0) {
204204 int devidx = mmc_get_devidx(md->disk);
205− blk_put_queue(md->queue.queue);
205+
206206 ida_simple_remove(&mmc_blk_ida, devidx);
207207 put_disk(md->disk);
208208 kfree(md);
@@ -2319,39 +2319,22 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, · 2110 unmodified lines
23192319 */
23202320 md->read_only = mmc_blk_readonly(card);
23212321
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);
23252325 goto err_kfree;
23262326 }
23272327
23282328 INIT_LIST_HEAD(&md->part);
23292329 INIT_LIST_HEAD(&md->rpmbs);
23302330 md->usage = 1;
2331−
2332− ret = mmc_init_queue(&md->queue, card);
2333− if (ret)
2334− goto err_putdisk;
2335−
23362331 md->queue.blkdata = md;
23372332
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−
23502333 md->disk->major = MMC_BLOCK_MAJOR;
2334+ md->disk->minors = perdev_minors;
23512335 md->disk->first_minor = devidx * perdev_minors;
23522336 md->disk->fops = &mmc_bdops;
23532337 md->disk->private_data = md;
2354− md->disk->queue = md->queue.queue;
23552338 md->parent = parent;
23562339 set_disk_ro(md->disk, md->read_only || default_ro);
23572340 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
24002383
24012384 return md;
24022385
2403− err_putdisk:
2404− put_disk(md->disk);
24052386 err_kfree:
24062387 kfree(md);
24072388 out:
drivers/mmc/core/queue.c+10−13
@@ -424,9 +424,10 @@ static inline bool mmc_merge_capable(struct mmc_host *host) · 423 unmodified lines
424424 *
425425 * Initialise a MMC card request queue.
426426 */
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)
428428 {
429429 struct mmc_host *host = card->host;
430+ struct gendisk *disk;
430431 int ret;
431432
432433 mq->card = card;
@@ -464,26 +465,22 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card) · 31 unmodified lines
464465
465466 ret = blk_mq_alloc_tag_set(&mq->tag_set);
466467 if (ret)
467− return ret;
468+ return ERR_PTR(ret);
469+
468470
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;
473475 }
476+ mq->queue = disk->queue;
474477
475478 if (mmc_host_is_spi(host) && host->use_spi_crc)
476479 blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, mq->queue);
477−
478− mq->queue->queuedata = mq;
479480 blk_queue_rq_timeout(mq->queue, 60 * HZ);
480481
481482 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;
487484 }
488485
489486 void mmc_queue_suspend(struct mmc_queue *mq)
drivers/mmc/core/queue.h+1−1
@@ -94,7 +94,7 @@ struct mmc_queue { · 93 unmodified lines
9494 struct work_struct complete_work;
9595 };
9696
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);
9898 extern void mmc_cleanup_queue(struct mmc_queue *);
9999 extern void mmc_queue_suspend(struct mmc_queue *);
100100 extern void mmc_queue_resume(struct mmc_queue *);
drivers/nvme/host/core.c+29−36
@@ -609,6 +609,7 @@ EXPORT_SYMBOL_NS_GPL(nvme_put_ns, NVME_TARGET_PASSTHRU); · 608 unmodified lines
609609
610610 static inline void nvme_clear_nvme_request(struct request *req)
611611 {
612+ nvme_req(req)->status = 0;
612613 nvme_req(req)->retries = 0;
613614 nvme_req(req)->flags = 0;
614615 req->rq_flags |= RQF_DONTPREP;
@@ -631,6 +632,8 @@ static inline void nvme_init_request(struct request *req, · 16 unmodified lines
631632 cmd->common.flags &= ~NVME_CMD_SGL_ALL;
632633
633634 req->cmd_flags |= REQ_FAILFAST_DRIVER;
635+ if (req->mq_hctx->type == HCTX_TYPE_POLL)
636+ req->cmd_flags |= REQ_HIPRI;
634637 nvme_clear_nvme_request(req);
635638 memcpy(nvme_req(req)->cmd, cmd, sizeof(*cmd));
636639 }
@@ -1029,29 +1032,23 @@ blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req) · 392 unmodified lines
10291032 }
10301033 EXPORT_SYMBOL_GPL(nvme_setup_cmd);
10311034
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)
10331043 {
1034− struct completion *waiting = rq->end_io_data;
1044+ blk_status_t status;
10351045
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);
10551052 }
10561053
10571054 /*
@@ -1061,7 +1058,7 @@ static void nvme_execute_rq_polled(struct request_queue *q, · 3 unmodified lines
10611058 int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
10621059 union nvme_result *result, void *buffer, unsigned bufflen,
10631060 unsigned timeout, int qid, int at_head,
1064− blk_mq_req_flags_t flags, bool poll)
1061+ blk_mq_req_flags_t flags)
10651062 {
10661063 struct request *req;
10671064 int ret;
@@ -1082,16 +1079,9 @@ int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, · 14 unmodified lines
10821079 goto out;
10831080 }
10841081
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)
10901084 *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;
10951085 out:
10961086 blk_mq_free_request(req);
10971087 return ret;
@@ -1102,7 +1092,7 @@ int nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, · 4 unmodified lines
11021092 void *buffer, unsigned bufflen)
11031093 {
11041094 return __nvme_submit_sync_cmd(q, cmd, NULL, buffer, bufflen, 0,
1105− NVME_QID_ANY, 0, 0, false);
1095+ NVME_QID_ANY, 0, 0);
11061096 }
11071097 EXPORT_SYMBOL_GPL(nvme_submit_sync_cmd);
11081098
@@ -1179,18 +1169,21 @@ static void nvme_passthru_end(struct nvme_ctrl *ctrl, u32 effects) · 70 unmodified lines
11791169 }
11801170 }
11811171
1182−void nvme_execute_passthru_rq(struct request *rq)
1172+int nvme_execute_passthru_rq(struct request *rq)
11831173 {
11841174 struct nvme_command *cmd = nvme_req(rq)->cmd;
11851175 struct nvme_ctrl *ctrl = nvme_req(rq)->ctrl;
11861176 struct nvme_ns *ns = rq->q->queuedata;
11871177 struct gendisk *disk = ns ? ns->disk : NULL;
11881178 u32 effects;
1179+ int ret;
11891180
11901181 effects = nvme_passthru_start(ctrl, ns, cmd->common.opcode);
1191− blk_execute_rq(disk, rq, 0);
1182+ ret = nvme_execute_rq(disk, rq, false);
11921183 if (effects) /* nothing to be done for zero cmd effects */
11931184 nvme_passthru_end(ctrl, effects);
1185+
1186+ return ret;
11941187 }
11951188 EXPORT_SYMBOL_NS_GPL(nvme_execute_passthru_rq, NVME_TARGET_PASSTHRU);
11961189
@@ -1465,7 +1458,7 @@ static int nvme_features(struct nvme_ctrl *dev, u8 op, unsigned int fid, · 268 unmodified lines
14651458 c.features.dword11 = cpu_to_le32(dword11);
14661459
14671460 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);
14691462 if (ret >= 0 && result)
14701463 *result = le32_to_cpu(res.u32);
14711464 return ret;
@@ -2047,7 +2040,7 @@ int nvme_sec_submit(void *data, u16 spsp, u8 secp, void *buffer, size_t len, · 575 unmodified lines
20472040 cmd.common.cdw11 = cpu_to_le32(len);
20482041
20492042 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);
20512044 }
20522045 EXPORT_SYMBOL_GPL(nvme_sec_submit);
20532046 #endif /* CONFIG_BLK_SED_OPAL */
drivers/nvme/host/fabrics.c+6−7
@@ -154,7 +154,7 @@ int nvmf_reg_read32(struct nvme_ctrl *ctrl, u32 off, u32 *val) · 153 unmodified lines
154154 cmd.prop_get.offset = cpu_to_le32(off);
155155
156156 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);
158158
159159 if (ret >= 0)
160160 *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
200200 cmd.prop_get.offset = cpu_to_le32(off);
201201
202202 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);
204204
205205 if (ret >= 0)
206206 *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
245245 cmd.prop_set.value = cpu_to_le64(val);
246246
247247 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);
249249 if (unlikely(ret))
250250 dev_err(ctrl->device,
251251 "Property Set error: %d, offset %#x\n",
@@ -391,7 +391,7 @@ int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl) · 139 unmodified lines
391391
392392 ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, &res,
393393 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);
395395 if (ret) {
396396 nvmf_log_connect_error(ctrl, ret, le32_to_cpu(res.u32),
397397 &cmd, data);
@@ -415,7 +415,6 @@ EXPORT_SYMBOL_GPL(nvmf_connect_admin_queue); · 17 unmodified lines
415415 * @qid: NVMe I/O queue number for the new I/O connection between
416416 * host and target (note qid == 0 is illegal as this is
417417 * the Admin queue, per NVMe standard).
418− * @poll: Whether or not to poll for the completion of the connect cmd.
419418 *
420419 * This function issues a fabrics-protocol connection
421420 * 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
427426 * > 0: NVMe error status code
428427 * < 0: Linux errno error code
429428 */
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)
431430 {
432431 struct nvme_command cmd = { };
433432 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
453452
454453 ret = __nvme_submit_sync_cmd(ctrl->connect_q, &cmd, &res,
455454 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);
457456 if (ret) {
458457 nvmf_log_connect_error(ctrl, ret, le32_to_cpu(res.u32),
459458 &cmd, data);
drivers/nvme/host/fabrics.h+1−1
@@ -182,7 +182,7 @@ int nvmf_reg_read32(struct nvme_ctrl *ctrl, u32 off, u32 *val); · 181 unmodified lines
182182 int nvmf_reg_read64(struct nvme_ctrl *ctrl, u32 off, u64 *val);
183183 int nvmf_reg_write32(struct nvme_ctrl *ctrl, u32 off, u32 val);
184184 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);
186186 int nvmf_register_transport(struct nvmf_transport_ops *ops);
187187 void nvmf_unregister_transport(struct nvmf_transport_ops *ops);
188188 void nvmf_free_options(struct nvmf_ctrl_options *opts);
drivers/nvme/host/fc.c+1−1
@@ -2346,7 +2346,7 @@ nvme_fc_connect_io_queues(struct nvme_fc_ctrl *ctrl, u16 qsize) · 2345 unmodified lines
23462346 (qsize / 5));
23472347 if (ret)
23482348 break;
2349− ret = nvmf_connect_io_queue(&ctrl->ctrl, i, false);
2349+ ret = nvmf_connect_io_queue(&ctrl->ctrl, i);
23502350 if (ret)
23512351 break;
23522352
drivers/nvme/host/ioctl.c+1−5
@@ -93,11 +93,7 @@ static int nvme_submit_user_cmd(struct request_queue *q, · 92 unmodified lines
9393 }
9494 }
9595
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);
10197 if (result)
10298 *result = le64_to_cpu(nvme_req(req)->result.u64);
10399 if (meta && !ret && !write) {
drivers/nvme/host/nvme.h+2−2
@@ -658,7 +658,7 @@ int nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, · 657 unmodified lines
658658 int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
659659 union nvme_result *result, void *buffer, unsigned bufflen,
660660 unsigned timeout, int qid, int at_head,
661− blk_mq_req_flags_t flags, bool poll);
661+ blk_mq_req_flags_t flags);
662662 int nvme_set_features(struct nvme_ctrl *dev, unsigned int fid,
663663 unsigned int dword11, void *buffer, size_t buflen,
664664 u32 *result);
@@ -876,7 +876,7 @@ static inline bool nvme_ctrl_sgl_supported(struct nvme_ctrl *ctrl) · 211 unmodified lines
876876
877877 u32 nvme_command_effects(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
878878 u8 opcode);
879−void nvme_execute_passthru_rq(struct request *rq);
879+int nvme_execute_passthru_rq(struct request *rq);
880880 struct nvme_ctrl *nvme_ctrl_from_file(struct file *file);
881881 struct nvme_ns *nvme_find_get_ns(struct nvme_ctrl *ctrl, unsigned nsid);
882882 void nvme_put_ns(struct nvme_ns *ns);
drivers/nvme/host/rdma.c+1−2
@@ -680,11 +680,10 @@ static void nvme_rdma_stop_io_queues(struct nvme_rdma_ctrl *ctrl) · 679 unmodified lines
680680 static int nvme_rdma_start_queue(struct nvme_rdma_ctrl *ctrl, int idx)
681681 {
682682 struct nvme_rdma_queue *queue = &ctrl->queues[idx];
683− bool poll = nvme_rdma_poll_queue(queue);
684683 int ret;
685684
686685 if (idx)
687− ret = nvmf_connect_io_queue(&ctrl->ctrl, idx, poll);
686+ ret = nvmf_connect_io_queue(&ctrl->ctrl, idx);
688687 else
689688 ret = nvmf_connect_admin_queue(&ctrl->ctrl);
690689
drivers/nvme/host/tcp.c+1−1
@@ -1574,7 +1574,7 @@ static int nvme_tcp_start_queue(struct nvme_ctrl *nctrl, int idx) · 1573 unmodified lines
15741574 int ret;
15751575
15761576 if (idx)
1577− ret = nvmf_connect_io_queue(nctrl, idx, false);
1577+ ret = nvmf_connect_io_queue(nctrl, idx);
15781578 else
15791579 ret = nvmf_connect_admin_queue(nctrl);
15801580
drivers/nvme/target/loop.c+1−1
@@ -337,7 +337,7 @@ static int nvme_loop_connect_io_queues(struct nvme_loop_ctrl *ctrl) · 336 unmodified lines
337337 int i, ret;
338338
339339 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);
341341 if (ret)
342342 return ret;
343343 set_bit(NVME_LOOP_Q_LIVE, &ctrl->queues[i].flags);
drivers/nvme/target/passthru.c+4−4
@@ -153,11 +153,10 @@ static void nvmet_passthru_execute_cmd_work(struct work_struct *w) · 152 unmodified lines
153153 {
154154 struct nvmet_req *req = container_of(w, struct nvmet_req, p.work);
155155 struct request *rq = req->p.rq;
156− u16 status;
156+ int status;
157157
158− nvme_execute_passthru_rq(rq);
158+ status = nvme_execute_passthru_rq(rq);
159159
160− status = nvme_req(rq)->status;
161160 if (status == NVME_SC_SUCCESS &&
162161 req->cmd->common.opcode == nvme_admin_identify) {
163162 switch (req->cmd->identify.cns) {
@@ -168,7 +167,8 @@ static void nvmet_passthru_execute_cmd_work(struct work_struct *w) · 4 unmodified lines
168167 nvmet_passthru_override_id_ns(req);
169168 break;
170169 }
171− }
170+ } else if (status < 0)
171+ status = NVME_SC_INTERNAL;
172172
173173 req->cqe->result = nvme_req(rq)->result;
174174 nvmet_req_complete(req, status);
drivers/nvme/target/tcp.c+0−1
@@ -1497,7 +1497,6 @@ static void nvmet_tcp_state_change(struct sock *sk) · 1496 unmodified lines
14971497 case TCP_CLOSE_WAIT:
14981498 case TCP_CLOSE:
14991499 /* FALLTHRU */
1500− sk->sk_user_data = NULL;
15011500 nvmet_tcp_schedule_release_queue(queue);
15021501 break;
15031502 default:
drivers/s390/block/dasd.c+0−1
@@ -621,7 +621,6 @@ void dasd_set_target_state(struct dasd_device *device, int target) · 620 unmodified lines
621621 mutex_unlock(&device->state_mutex);
622622 dasd_put_device(device);
623623 }
624−EXPORT_SYMBOL(dasd_set_target_state);
625624
626625 /*
627626 * Enable devices with device numbers in [from..to].
drivers/s390/block/dasd_eckd.c+1−1
@@ -746,7 +746,7 @@ static void create_uid(struct dasd_eckd_private *private) · 745 unmodified lines
746746 memcpy(uid->vendor, private->ned->HDA_manufacturer,
747747 sizeof(uid->vendor) - 1);
748748 EBCASC(uid->vendor, sizeof(uid->vendor) - 1);
749− memcpy(uid->serial, private->ned->HDA_location,
749+ memcpy(uid->serial, &private->ned->serial,
750750 sizeof(uid->serial) - 1);
751751 EBCASC(uid->serial, sizeof(uid->serial) - 1);
752752 uid->ssid = private->gneq->subsystemID;
drivers/s390/block/dasd_eckd.h+4−2
@@ -332,8 +332,10 @@ struct dasd_ned { · 331 unmodified lines
332332 __u8 dev_type[6];
333333 __u8 dev_model[3];
334334 __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;
337339 __u8 ID;
338340 __u8 unit_addr;
339341 } __attribute__ ((packed));
drivers/scsi/scsi_error.c+1−1
@@ -1997,7 +1997,7 @@ static void scsi_eh_lock_door(struct scsi_device *sdev) · 1996 unmodified lines
19971997 struct request *req;
19981998 struct scsi_request *rq;
19991999
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);
20012001 if (IS_ERR(req))
20022002 return;
20032003 rq = scsi_req(req);
drivers/scsi/scsi_lib.c+4−4
@@ -215,7 +215,7 @@ int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, · 214 unmodified lines
215215
216216 req = blk_get_request(sdev->request_queue,
217217 data_direction == DMA_TO_DEVICE ?
218− REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN,
218+ REQ_OP_DRV_OUT : REQ_OP_DRV_IN,
219219 rq_flags & RQF_PM ? BLK_MQ_REQ_PM : 0);
220220 if (IS_ERR(req))
221221 return PTR_ERR(req);
@@ -543,7 +543,7 @@ static bool scsi_end_request(struct request *req, blk_status_t error, · 321 unmodified lines
543543 if (blk_queue_add_random(q))
544544 add_disk_randomness(req->rq_disk);
545545
546− if (!blk_rq_is_scsi(req)) {
546+ if (!blk_rq_is_passthrough(req)) {
547547 WARN_ON_ONCE(!(cmd->flags & SCMD_INITIALIZED));
548548 cmd->flags &= ~SCMD_INITIALIZED;
549549 }
@@ -1113,7 +1113,7 @@ void scsi_init_command(struct scsi_device *dev, struct scsi_cmnd *cmd) · 563 unmodified lines
11131113 bool in_flight;
11141114 int budget_token = cmd->budget_token;
11151115
1116− if (!blk_rq_is_scsi(rq) && !(flags & SCMD_INITIALIZED)) {
1116+ if (!blk_rq_is_passthrough(rq) && !(flags & SCMD_INITIALIZED)) {
11171117 flags |= SCMD_INITIALIZED;
11181118 scsi_initialize_rq(rq);
11191119 }
@@ -1554,7 +1554,7 @@ static blk_status_t scsi_prepare_cmd(struct request *req) · 434 unmodified lines
15541554 * Special handling for passthrough commands, which don't go to the ULP
15551555 * at all:
15561556 */
1557− if (blk_rq_is_scsi(req))
1557+ if (blk_rq_is_passthrough(req))
15581558 return scsi_setup_scsi_cmnd(sdev, req);
15591559
15601560 if (sdev->handler && sdev->handler->prep_fn) {
drivers/scsi/sg.c+1−1
@@ -1759,7 +1759,7 @@ sg_start_req(Sg_request *srp, unsigned char *cmd) · 1758 unmodified lines
17591759 * not expect an EWOULDBLOCK from this condition.
17601760 */
17611761 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);
17631763 if (IS_ERR(rq)) {
17641764 kfree(long_cmdp);
17651765 return PTR_ERR(rq);
drivers/scsi/st.c+1−1
@@ -549,7 +549,7 @@ static int st_scsi_execute(struct st_request *SRpnt, const unsigned char *cmd, · 548 unmodified lines
549549
550550 req = blk_get_request(SRpnt->stp->device->request_queue,
551551 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);
553553 if (IS_ERR(req))
554554 return PTR_ERR(req);
555555 rq = scsi_req(req);
drivers/target/target_core_pscsi.c+1−1
@@ -982,7 +982,7 @@ pscsi_execute_cmd(struct se_cmd *cmd) · 981 unmodified lines
982982
983983 req = blk_get_request(pdv->pdv_sd->request_queue,
984984 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);
986986 if (IS_ERR(req)) {
987987 pr_err("PSCSI: blk_get_request() failed\n");
988988 ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
fs/nfsd/blocklayout.c+1−1
@@ -236,7 +236,7 @@ again: · 235 unmodified lines
236236 if (!buf)
237237 return -ENOMEM;
238238
239− rq = blk_get_request(q, REQ_OP_SCSI_IN, 0);
239+ rq = blk_get_request(q, REQ_OP_DRV_IN, 0);
240240 if (IS_ERR(rq)) {
241241 error = -ENOMEM;
242242 goto out_free_buf;
include/linux/blk-mq.h+0−2
@@ -439,8 +439,6 @@ enum { · 438 unmodified lines
439439 struct gendisk *__blk_mq_alloc_disk(struct blk_mq_tag_set *set,
440440 void *queuedata);
441441 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);
444442 int blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
445443 struct request_queue *q);
446444 void blk_mq_unregister_dev(struct device *, struct request_queue *);
include/linux/blk_types.h+0−3
@@ -351,9 +351,6 @@ enum req_opf { · 350 unmodified lines
351351 /* reset all the zone present on the device */
352352 REQ_OP_ZONE_RESET_ALL = 17,
353353
354− /* SCSI passthrough using struct scsi_request */
355− REQ_OP_SCSI_IN = 32,
356− REQ_OP_SCSI_OUT = 33,
357354 /* Driver private requests */
358355 REQ_OP_DRV_IN = 34,
359356 REQ_OP_DRV_OUT = 35,
include/linux/blkdev.h+6−31
@@ -240,42 +240,15 @@ struct request { · 239 unmodified lines
240240 void *end_io_data;
241241 };
242242
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)
249244 {
245+ op &= REQ_OP_MASK;
250246 return op == REQ_OP_DRV_IN || op == REQ_OP_DRV_OUT;
251247 }
252248
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−
263249 static inline bool blk_rq_is_passthrough(struct request *rq)
264250 {
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));
279252 }
280253
281254 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
936909 extern int blk_rq_map_user_iov(struct request_queue *, struct request *,
937910 struct rq_map_data *, const struct iov_iter *,
938911 gfp_t);
939−extern void blk_execute_rq(struct gendisk *, struct request *, int);
940912 extern void blk_execute_rq_nowait(struct gendisk *,
941913 struct request *, int, rq_end_io_fn *);
942914
915+blk_status_t blk_execute_rq(struct gendisk *bd_disk, struct request *rq,
916+ int at_head);
917+
943918 /* Helper to convert REQ_OP_XXX to its string format XXX */
944919 extern const char *blk_op_str(unsigned int op);
945920
include/uapi/linux/nbd-netlink.h+1−0
@@ -35,6 +35,7 @@ enum { · 34 unmodified lines
3535 NBD_ATTR_SOCKETS,
3636 NBD_ATTR_DEAD_CONN_TIMEOUT,
3737 NBD_ATTR_DEVICE_LIST,
38+ NBD_ATTR_BACKEND_IDENTIFIER,
3839 __NBD_ATTR_MAX,
3940 };
4041 #define NBD_ATTR_MAX (__NBD_ATTR_MAX - 1)