Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-linus-20180302' of git://git.kernel.dk/linux-block

Pull block fixes from Jens Axboe:
"A collection of fixes for this series. This is a little larger than
usual at this time, but that's mainly because I was out on vacation
last week. Nothing in here is major in any way, it's just two weeks of
fixes. This contains:

- NVMe pull from Keith, with a set of fixes from the usual suspects.

- mq-deadline zone unlock fix from Damien, fixing an issue with the
SMR zone locking added for 4.16.

- two bcache fixes sent in by Michael, with changes from Coly and
Tang.

- comment typo fix from Eric for blktrace.

- return-value error handling fix for nbd, from Gustavo.

- fix a direct-io case where we don't defer to a completion handler,
making us sleep from IRQ device completion. From Jan.

- a small series from Jan fixing up holes around handling of bdev
references.

- small set of regression fixes from Jiufei, mostly fixing problems
around the gendisk pointer -> partition index change.

- regression fix from Ming, fixing a boundary issue with the discard
page cache invalidation.

- two-patch series from Ming, fixing both a core blk-mq-sched and
kyber issue around token freeing on a requeue condition"

* tag 'for-linus-20180302' of git://git.kernel.dk/linux-block: (24 commits)
block: fix a typo
block: display the correct diskname for bio
block: fix the count of PGPGOUT for WRITE_SAME
mq-deadline: Make sure to always unlock zones
nvmet: fix PSDT field check in command format
nvme-multipath: fix sysfs dangerously created links
nbd: fix return value in error handling path
bcache: fix kcrashes with fio in RAID5 backend dev
bcache: correct flash only vols (check all uuids)
blktrace_api.h: fix comment for struct blk_user_trace_setup
blockdev: Avoid two active bdev inodes for one device
genhd: Fix BUG in blkdev_open()
genhd: Fix use after free in __blkdev_get()
genhd: Add helper put_disk_and_module()
genhd: Rename get_disk() to get_disk_and_module()
genhd: Fix leaked module reference for NVME devices
direct-io: Fix sleep in atomic due to sync AIO
nvme-pci: Fix nvme queue cleanup if IRQ setup fails
block: kyber: fix domain token leak during requeue
blk-mq: don't call io sched's .requeue_request when requeueing rq to ->dispatch
...

+145 -82
+2 -9
block/blk-cgroup.c
··· 812 812 struct gendisk *disk; 813 813 struct request_queue *q; 814 814 struct blkcg_gq *blkg; 815 - struct module *owner; 816 815 unsigned int major, minor; 817 816 int key_len, part, ret; 818 817 char *body; ··· 903 904 spin_unlock_irq(q->queue_lock); 904 905 rcu_read_unlock(); 905 906 fail: 906 - owner = disk->fops->owner; 907 - put_disk(disk); 908 - module_put(owner); 907 + put_disk_and_module(disk); 909 908 /* 910 909 * If queue was bypassing, we should retry. Do so after a 911 910 * short msleep(). It isn't strictly necessary but queue ··· 928 931 void blkg_conf_finish(struct blkg_conf_ctx *ctx) 929 932 __releases(ctx->disk->queue->queue_lock) __releases(rcu) 930 933 { 931 - struct module *owner; 932 - 933 934 spin_unlock_irq(ctx->disk->queue->queue_lock); 934 935 rcu_read_unlock(); 935 - owner = ctx->disk->fops->owner; 936 - put_disk(ctx->disk); 937 - module_put(owner); 936 + put_disk_and_module(ctx->disk); 938 937 } 939 938 EXPORT_SYMBOL_GPL(blkg_conf_finish); 940 939
+1 -1
block/blk-core.c
··· 2434 2434 unsigned int count; 2435 2435 2436 2436 if (unlikely(bio_op(bio) == REQ_OP_WRITE_SAME)) 2437 - count = queue_logical_block_size(bio->bi_disk->queue); 2437 + count = queue_logical_block_size(bio->bi_disk->queue) >> 9; 2438 2438 else 2439 2439 count = bio_sectors(bio); 2440 2440
+3 -1
block/blk-mq.c
··· 712 712 713 713 trace_block_rq_requeue(q, rq); 714 714 wbt_requeue(q->rq_wb, &rq->issue_stat); 715 - blk_mq_sched_requeue_request(rq); 716 715 717 716 if (blk_mq_rq_state(rq) != MQ_RQ_IDLE) { 718 717 blk_mq_rq_update_state(rq, MQ_RQ_IDLE); ··· 723 724 void blk_mq_requeue_request(struct request *rq, bool kick_requeue_list) 724 725 { 725 726 __blk_mq_requeue_request(rq); 727 + 728 + /* this request will be re-inserted to io scheduler queue */ 729 + blk_mq_sched_requeue_request(rq); 726 730 727 731 BUG_ON(blk_queued_rq(rq)); 728 732 blk_mq_add_to_requeue_list(rq, true, kick_requeue_list);
+40 -8
block/genhd.c
··· 547 547 { 548 548 struct gendisk *p = data; 549 549 550 - if (!get_disk(p)) 550 + if (!get_disk_and_module(p)) 551 551 return -1; 552 552 return 0; 553 553 } ··· 717 717 blk_integrity_del(disk); 718 718 disk_del_events(disk); 719 719 720 + /* 721 + * Block lookups of the disk until all bdevs are unhashed and the 722 + * disk is marked as dead (GENHD_FL_UP cleared). 723 + */ 724 + down_write(&disk->lookup_sem); 720 725 /* invalidate stuff */ 721 726 disk_part_iter_init(&piter, disk, 722 727 DISK_PITER_INCL_EMPTY | DISK_PITER_REVERSE); ··· 736 731 bdev_unhash_inode(disk_devt(disk)); 737 732 set_capacity(disk, 0); 738 733 disk->flags &= ~GENHD_FL_UP; 734 + up_write(&disk->lookup_sem); 739 735 740 736 if (!(disk->flags & GENHD_FL_HIDDEN)) 741 737 sysfs_remove_link(&disk_to_dev(disk)->kobj, "bdi"); ··· 815 809 816 810 spin_lock_bh(&ext_devt_lock); 817 811 part = idr_find(&ext_devt_idr, blk_mangle_minor(MINOR(devt))); 818 - if (part && get_disk(part_to_disk(part))) { 812 + if (part && get_disk_and_module(part_to_disk(part))) { 819 813 *partno = part->partno; 820 814 disk = part_to_disk(part); 821 815 } 822 816 spin_unlock_bh(&ext_devt_lock); 823 817 } 824 818 825 - if (disk && unlikely(disk->flags & GENHD_FL_HIDDEN)) { 826 - put_disk(disk); 819 + if (!disk) 820 + return NULL; 821 + 822 + /* 823 + * Synchronize with del_gendisk() to not return disk that is being 824 + * destroyed. 825 + */ 826 + down_read(&disk->lookup_sem); 827 + if (unlikely((disk->flags & GENHD_FL_HIDDEN) || 828 + !(disk->flags & GENHD_FL_UP))) { 829 + up_read(&disk->lookup_sem); 830 + put_disk_and_module(disk); 827 831 disk = NULL; 832 + } else { 833 + up_read(&disk->lookup_sem); 828 834 } 829 835 return disk; 830 836 } ··· 1436 1418 kfree(disk); 1437 1419 return NULL; 1438 1420 } 1421 + init_rwsem(&disk->lookup_sem); 1439 1422 disk->node_id = node_id; 1440 1423 if (disk_expand_part_tbl(disk, 0)) { 1441 1424 free_part_stats(&disk->part0); ··· 1472 1453 } 1473 1454 EXPORT_SYMBOL(__alloc_disk_node); 1474 1455 1475 - struct kobject *get_disk(struct gendisk *disk) 1456 + struct kobject *get_disk_and_module(struct gendisk *disk) 1476 1457 { 1477 1458 struct module *owner; 1478 1459 struct kobject *kobj; ··· 1490 1471 return kobj; 1491 1472 1492 1473 } 1493 - 1494 - EXPORT_SYMBOL(get_disk); 1474 + EXPORT_SYMBOL(get_disk_and_module); 1495 1475 1496 1476 void put_disk(struct gendisk *disk) 1497 1477 { 1498 1478 if (disk) 1499 1479 kobject_put(&disk_to_dev(disk)->kobj); 1500 1480 } 1501 - 1502 1481 EXPORT_SYMBOL(put_disk); 1482 + 1483 + /* 1484 + * This is a counterpart of get_disk_and_module() and thus also of 1485 + * get_gendisk(). 1486 + */ 1487 + void put_disk_and_module(struct gendisk *disk) 1488 + { 1489 + if (disk) { 1490 + struct module *owner = disk->fops->owner; 1491 + 1492 + put_disk(disk); 1493 + module_put(owner); 1494 + } 1495 + } 1496 + EXPORT_SYMBOL(put_disk_and_module); 1503 1497 1504 1498 static void set_disk_ro_uevent(struct gendisk *gd, int ro) 1505 1499 {
+1 -1
block/ioctl.c
··· 225 225 226 226 if (start + len > i_size_read(bdev->bd_inode)) 227 227 return -EINVAL; 228 - truncate_inode_pages_range(mapping, start, start + len); 228 + truncate_inode_pages_range(mapping, start, start + len - 1); 229 229 return blkdev_issue_discard(bdev, start >> 9, len >> 9, 230 230 GFP_KERNEL, flags); 231 231 }
+1
block/kyber-iosched.c
··· 833 833 .limit_depth = kyber_limit_depth, 834 834 .prepare_request = kyber_prepare_request, 835 835 .finish_request = kyber_finish_request, 836 + .requeue_request = kyber_finish_request, 836 837 .completed_request = kyber_completed_request, 837 838 .dispatch_request = kyber_dispatch_request, 838 839 .has_work = kyber_has_work,
+13 -3
block/mq-deadline.c
··· 536 536 } 537 537 538 538 /* 539 + * Nothing to do here. This is defined only to ensure that .finish_request 540 + * method is called upon request completion. 541 + */ 542 + static void dd_prepare_request(struct request *rq, struct bio *bio) 543 + { 544 + } 545 + 546 + /* 539 547 * For zoned block devices, write unlock the target zone of 540 548 * completed write requests. Do this while holding the zone lock 541 549 * spinlock so that the zone is never unlocked while deadline_fifo_request() 542 - * while deadline_next_request() are executing. 550 + * or deadline_next_request() are executing. This function is called for 551 + * all requests, whether or not these requests complete successfully. 543 552 */ 544 - static void dd_completed_request(struct request *rq) 553 + static void dd_finish_request(struct request *rq) 545 554 { 546 555 struct request_queue *q = rq->q; 547 556 ··· 765 756 .ops.mq = { 766 757 .insert_requests = dd_insert_requests, 767 758 .dispatch_request = dd_dispatch_request, 768 - .completed_request = dd_completed_request, 759 + .prepare_request = dd_prepare_request, 760 + .finish_request = dd_finish_request, 769 761 .next_request = elv_rb_latter_request, 770 762 .former_request = elv_rb_former_request, 771 763 .bio_merge = dd_bio_merge,
+6
block/partition-generic.c
··· 51 51 52 52 EXPORT_SYMBOL(bdevname); 53 53 54 + const char *bio_devname(struct bio *bio, char *buf) 55 + { 56 + return disk_name(bio->bi_disk, bio->bi_partno, buf); 57 + } 58 + EXPORT_SYMBOL(bio_devname); 59 + 54 60 /* 55 61 * There's very little reason to use this, you should really 56 62 * have a struct block_device just about everywhere and use
+1 -1
drivers/block/amiflop.c
··· 1758 1758 if (unit[drive].type->code == FD_NODRIVE) 1759 1759 return NULL; 1760 1760 *part = 0; 1761 - return get_disk(unit[drive].gendisk); 1761 + return get_disk_and_module(unit[drive].gendisk); 1762 1762 } 1763 1763 1764 1764 static int __init amiga_floppy_probe(struct platform_device *pdev)
+1 -1
drivers/block/ataflop.c
··· 1917 1917 if (drive >= FD_MAX_UNITS || type > NUM_DISK_MINORS) 1918 1918 return NULL; 1919 1919 *part = 0; 1920 - return get_disk(unit[drive].disk); 1920 + return get_disk_and_module(unit[drive].disk); 1921 1921 } 1922 1922 1923 1923 static int __init atari_floppy_init (void)
+1 -1
drivers/block/brd.c
··· 456 456 457 457 mutex_lock(&brd_devices_mutex); 458 458 brd = brd_init_one(MINOR(dev) / max_part, &new); 459 - kobj = brd ? get_disk(brd->brd_disk) : NULL; 459 + kobj = brd ? get_disk_and_module(brd->brd_disk) : NULL; 460 460 mutex_unlock(&brd_devices_mutex); 461 461 462 462 if (new)
+1 -1
drivers/block/floppy.c
··· 4505 4505 if (((*part >> 2) & 0x1f) >= ARRAY_SIZE(floppy_type)) 4506 4506 return NULL; 4507 4507 *part = 0; 4508 - return get_disk(disks[drive]); 4508 + return get_disk_and_module(disks[drive]); 4509 4509 } 4510 4510 4511 4511 static int __init do_floppy_init(void)
+1 -1
drivers/block/loop.c
··· 1922 1922 if (err < 0) 1923 1923 kobj = NULL; 1924 1924 else 1925 - kobj = get_disk(lo->lo_disk); 1925 + kobj = get_disk_and_module(lo->lo_disk); 1926 1926 mutex_unlock(&loop_index_mutex); 1927 1927 1928 1928 *part = 0;
+1 -1
drivers/block/nbd.c
··· 1591 1591 if (new_index < 0) { 1592 1592 mutex_unlock(&nbd_index_mutex); 1593 1593 printk(KERN_ERR "nbd: failed to add new device\n"); 1594 - return ret; 1594 + return new_index; 1595 1595 } 1596 1596 nbd = idr_find(&nbd_index_idr, new_index); 1597 1597 }
+1 -1
drivers/block/pktcdvd.c
··· 1122 1122 pkt->sector = new_sector; 1123 1123 1124 1124 bio_reset(pkt->bio); 1125 - bio_set_set(pkt->bio, pd->bdev); 1125 + bio_set_dev(pkt->bio, pd->bdev); 1126 1126 bio_set_op_attrs(pkt->bio, REQ_OP_WRITE, 0); 1127 1127 pkt->bio->bi_iter.bi_sector = new_sector; 1128 1128 pkt->bio->bi_iter.bi_size = pkt->frames * CD_FRAMESIZE;
+1 -1
drivers/block/swim.c
··· 799 799 return NULL; 800 800 801 801 *part = 0; 802 - return get_disk(swd->unit[drive].disk); 802 + return get_disk_and_module(swd->unit[drive].disk); 803 803 } 804 804 805 805 static int swim_add_floppy(struct swim_priv *swd, enum drive_location location)
+1 -1
drivers/block/z2ram.c
··· 332 332 static struct kobject *z2_find(dev_t dev, int *part, void *data) 333 333 { 334 334 *part = 0; 335 - return get_disk(z2ram_gendisk); 335 + return get_disk_and_module(z2ram_gendisk); 336 336 } 337 337 338 338 static struct request_queue *z2_queue;
+1 -1
drivers/ide/ide-probe.c
··· 928 928 { 929 929 struct gendisk *p = data; 930 930 931 - if (!get_disk(p)) 931 + if (!get_disk_and_module(p)) 932 932 return -1; 933 933 return 0; 934 934 }
+1 -1
drivers/md/bcache/request.c
··· 659 659 static void search_free(struct closure *cl) 660 660 { 661 661 struct search *s = container_of(cl, struct search, cl); 662 - bio_complete(s); 663 662 664 663 if (s->iop.bio) 665 664 bio_put(s->iop.bio); 666 665 666 + bio_complete(s); 667 667 closure_debug_destroy(cl); 668 668 mempool_free(s, s->d->c->search); 669 669 }
+1 -1
drivers/md/bcache/super.c
··· 1274 1274 struct uuid_entry *u; 1275 1275 1276 1276 for (u = c->uuids; 1277 - u < c->uuids + c->devices_max_used && !ret; 1277 + u < c->uuids + c->nr_uuids && !ret; 1278 1278 u++) 1279 1279 if (UUID_FLASH_ONLY(u)) 1280 1280 ret = flash_dev_run(c, u);
+3 -9
drivers/nvme/host/core.c
··· 2844 2844 } 2845 2845 2846 2846 static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid, 2847 - struct nvme_id_ns *id, bool *new) 2847 + struct nvme_id_ns *id) 2848 2848 { 2849 2849 struct nvme_ctrl *ctrl = ns->ctrl; 2850 2850 bool is_shared = id->nmic & (1 << 0); ··· 2860 2860 ret = PTR_ERR(head); 2861 2861 goto out_unlock; 2862 2862 } 2863 - 2864 - *new = true; 2865 2863 } else { 2866 2864 struct nvme_ns_ids ids; 2867 2865 ··· 2871 2873 ret = -EINVAL; 2872 2874 goto out_unlock; 2873 2875 } 2874 - 2875 - *new = false; 2876 2876 } 2877 2877 2878 2878 list_add_tail(&ns->siblings, &head->list); ··· 2941 2945 struct nvme_id_ns *id; 2942 2946 char disk_name[DISK_NAME_LEN]; 2943 2947 int node = dev_to_node(ctrl->dev), flags = GENHD_FL_EXT_DEVT; 2944 - bool new = true; 2945 2948 2946 2949 ns = kzalloc_node(sizeof(*ns), GFP_KERNEL, node); 2947 2950 if (!ns) ··· 2966 2971 if (id->ncap == 0) 2967 2972 goto out_free_id; 2968 2973 2969 - if (nvme_init_ns_head(ns, nsid, id, &new)) 2974 + if (nvme_init_ns_head(ns, nsid, id)) 2970 2975 goto out_free_id; 2971 2976 nvme_setup_streams_ns(ctrl, ns); 2972 2977 ··· 3032 3037 pr_warn("%s: failed to register lightnvm sysfs group for identification\n", 3033 3038 ns->disk->disk_name); 3034 3039 3035 - if (new) 3036 - nvme_mpath_add_disk(ns->head); 3040 + nvme_mpath_add_disk(ns->head); 3037 3041 nvme_mpath_add_disk_links(ns); 3038 3042 return; 3039 3043 out_unlink_ns:
+1 -1
drivers/nvme/host/fabrics.c
··· 493 493 */ 494 494 int nvmf_register_transport(struct nvmf_transport_ops *ops) 495 495 { 496 - if (!ops->create_ctrl || !ops->module) 496 + if (!ops->create_ctrl) 497 497 return -EINVAL; 498 498 499 499 down_write(&nvmf_transports_rwsem);
+10 -5
drivers/nvme/host/multipath.c
··· 198 198 { 199 199 if (!head->disk) 200 200 return; 201 - device_add_disk(&head->subsys->dev, head->disk); 202 - if (sysfs_create_group(&disk_to_dev(head->disk)->kobj, 203 - &nvme_ns_id_attr_group)) 204 - pr_warn("%s: failed to create sysfs group for identification\n", 205 - head->disk->disk_name); 201 + 202 + mutex_lock(&head->subsys->lock); 203 + if (!(head->disk->flags & GENHD_FL_UP)) { 204 + device_add_disk(&head->subsys->dev, head->disk); 205 + if (sysfs_create_group(&disk_to_dev(head->disk)->kobj, 206 + &nvme_ns_id_attr_group)) 207 + pr_warn("%s: failed to create sysfs group for identification\n", 208 + head->disk->disk_name); 209 + } 210 + mutex_unlock(&head->subsys->lock); 206 211 } 207 212 208 213 void nvme_mpath_add_disk_links(struct nvme_ns *ns)
+4 -1
drivers/nvme/host/pci.c
··· 1459 1459 nvmeq->cq_vector = qid - 1; 1460 1460 result = adapter_alloc_cq(dev, qid, nvmeq); 1461 1461 if (result < 0) 1462 - return result; 1462 + goto release_vector; 1463 1463 1464 1464 result = adapter_alloc_sq(dev, qid, nvmeq); 1465 1465 if (result < 0) ··· 1473 1473 return result; 1474 1474 1475 1475 release_sq: 1476 + dev->online_queues--; 1476 1477 adapter_delete_sq(dev, qid); 1477 1478 release_cq: 1478 1479 adapter_delete_cq(dev, qid); 1480 + release_vector: 1481 + nvmeq->cq_vector = -1; 1479 1482 return result; 1480 1483 } 1481 1484
+2 -2
drivers/nvme/host/rdma.c
··· 1051 1051 struct nvme_rdma_device *dev = queue->device; 1052 1052 struct ib_device *ibdev = dev->dev; 1053 1053 1054 - if (!blk_rq_bytes(rq)) 1054 + if (!blk_rq_payload_bytes(rq)) 1055 1055 return; 1056 1056 1057 1057 if (req->mr) { ··· 1166 1166 1167 1167 c->common.flags |= NVME_CMD_SGL_METABUF; 1168 1168 1169 - if (!blk_rq_bytes(rq)) 1169 + if (!blk_rq_payload_bytes(rq)) 1170 1170 return nvme_rdma_set_sg_null(c); 1171 1171 1172 1172 req->sg_table.sgl = req->first_sgl;
+6 -3
drivers/nvme/target/core.c
··· 520 520 goto fail; 521 521 } 522 522 523 - /* either variant of SGLs is fine, as we don't support metadata */ 524 - if (unlikely((flags & NVME_CMD_SGL_ALL) != NVME_CMD_SGL_METABUF && 525 - (flags & NVME_CMD_SGL_ALL) != NVME_CMD_SGL_METASEG)) { 523 + /* 524 + * For fabrics, PSDT field shall describe metadata pointer (MPTR) that 525 + * contains an address of a single contiguous physical buffer that is 526 + * byte aligned. 527 + */ 528 + if (unlikely((flags & NVME_CMD_SGL_ALL) != NVME_CMD_SGL_METABUF)) { 526 529 status = NVME_SC_INVALID_FIELD | NVME_SC_DNR; 527 530 goto fail; 528 531 }
+2 -2
drivers/nvme/target/loop.c
··· 184 184 return BLK_STS_OK; 185 185 } 186 186 187 - if (blk_rq_bytes(req)) { 187 + if (blk_rq_payload_bytes(req)) { 188 188 iod->sg_table.sgl = iod->first_sgl; 189 189 if (sg_alloc_table_chained(&iod->sg_table, 190 190 blk_rq_nr_phys_segments(req), ··· 193 193 194 194 iod->req.sg = iod->sg_table.sgl; 195 195 iod->req.sg_cnt = blk_rq_map_sg(req->q, req, iod->sg_table.sgl); 196 - iod->req.transfer_len = blk_rq_bytes(req); 196 + iod->req.transfer_len = blk_rq_payload_bytes(req); 197 197 } 198 198 199 199 blk_mq_start_request(req);
+32 -17
fs/block_dev.c
··· 1058 1058 return 0; 1059 1059 } 1060 1060 1061 + static struct gendisk *bdev_get_gendisk(struct block_device *bdev, int *partno) 1062 + { 1063 + struct gendisk *disk = get_gendisk(bdev->bd_dev, partno); 1064 + 1065 + if (!disk) 1066 + return NULL; 1067 + /* 1068 + * Now that we hold gendisk reference we make sure bdev we looked up is 1069 + * not stale. If it is, it means device got removed and created before 1070 + * we looked up gendisk and we fail open in such case. Associating 1071 + * unhashed bdev with newly created gendisk could lead to two bdevs 1072 + * (and thus two independent caches) being associated with one device 1073 + * which is bad. 1074 + */ 1075 + if (inode_unhashed(bdev->bd_inode)) { 1076 + put_disk_and_module(disk); 1077 + return NULL; 1078 + } 1079 + return disk; 1080 + } 1081 + 1061 1082 /** 1062 1083 * bd_start_claiming - start claiming a block device 1063 1084 * @bdev: block device of interest ··· 1115 1094 * @bdev might not have been initialized properly yet, look up 1116 1095 * and grab the outer block device the hard way. 1117 1096 */ 1118 - disk = get_gendisk(bdev->bd_dev, &partno); 1097 + disk = bdev_get_gendisk(bdev, &partno); 1119 1098 if (!disk) 1120 1099 return ERR_PTR(-ENXIO); 1121 1100 ··· 1132 1111 else 1133 1112 whole = bdgrab(bdev); 1134 1113 1135 - module_put(disk->fops->owner); 1136 - put_disk(disk); 1114 + put_disk_and_module(disk); 1137 1115 if (!whole) 1138 1116 return ERR_PTR(-ENOMEM); 1139 1117 ··· 1427 1407 static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) 1428 1408 { 1429 1409 struct gendisk *disk; 1430 - struct module *owner; 1431 1410 int ret; 1432 1411 int partno; 1433 1412 int perm = 0; 1413 + bool first_open = false; 1434 1414 1435 1415 if (mode & FMODE_READ) 1436 1416 perm |= MAY_READ; ··· 1450 1430 restart: 1451 1431 1452 1432 ret = -ENXIO; 1453 - disk = get_gendisk(bdev->bd_dev, &partno); 1433 + disk = bdev_get_gendisk(bdev, &partno); 1454 1434 if (!disk) 1455 1435 goto out; 1456 - owner = disk->fops->owner; 1457 1436 1458 1437 disk_block_events(disk); 1459 1438 mutex_lock_nested(&bdev->bd_mutex, for_part); 1460 1439 if (!bdev->bd_openers) { 1440 + first_open = true; 1461 1441 bdev->bd_disk = disk; 1462 1442 bdev->bd_queue = disk->queue; 1463 1443 bdev->bd_contains = bdev; ··· 1483 1463 bdev->bd_queue = NULL; 1484 1464 mutex_unlock(&bdev->bd_mutex); 1485 1465 disk_unblock_events(disk); 1486 - put_disk(disk); 1487 - module_put(owner); 1466 + put_disk_and_module(disk); 1488 1467 goto restart; 1489 1468 } 1490 1469 } ··· 1543 1524 if (ret) 1544 1525 goto out_unlock_bdev; 1545 1526 } 1546 - /* only one opener holds refs to the module and disk */ 1547 - put_disk(disk); 1548 - module_put(owner); 1549 1527 } 1550 1528 bdev->bd_openers++; 1551 1529 if (for_part) 1552 1530 bdev->bd_part_count++; 1553 1531 mutex_unlock(&bdev->bd_mutex); 1554 1532 disk_unblock_events(disk); 1533 + /* only one opener holds refs to the module and disk */ 1534 + if (!first_open) 1535 + put_disk_and_module(disk); 1555 1536 return 0; 1556 1537 1557 1538 out_clear: ··· 1565 1546 out_unlock_bdev: 1566 1547 mutex_unlock(&bdev->bd_mutex); 1567 1548 disk_unblock_events(disk); 1568 - put_disk(disk); 1569 - module_put(owner); 1549 + put_disk_and_module(disk); 1570 1550 out: 1571 1551 bdput(bdev); 1572 1552 ··· 1788 1770 disk->fops->release(disk, mode); 1789 1771 } 1790 1772 if (!bdev->bd_openers) { 1791 - struct module *owner = disk->fops->owner; 1792 - 1793 1773 disk_put_part(bdev->bd_part); 1794 1774 bdev->bd_part = NULL; 1795 1775 bdev->bd_disk = NULL; ··· 1795 1779 victim = bdev->bd_contains; 1796 1780 bdev->bd_contains = NULL; 1797 1781 1798 - put_disk(disk); 1799 - module_put(owner); 1782 + put_disk_and_module(disk); 1800 1783 } 1801 1784 mutex_unlock(&bdev->bd_mutex); 1802 1785 bdput(bdev);
+1 -2
fs/direct-io.c
··· 1274 1274 */ 1275 1275 if (dio->is_async && iov_iter_rw(iter) == WRITE) { 1276 1276 retval = 0; 1277 - if ((iocb->ki_filp->f_flags & O_DSYNC) || 1278 - IS_SYNC(iocb->ki_filp->f_mapping->host)) 1277 + if (iocb->ki_flags & IOCB_DSYNC) 1279 1278 retval = dio_set_defer_completion(dio); 1280 1279 else if (!dio->inode->i_sb->s_dio_done_wq) { 1281 1280 /*
+1 -3
include/linux/bio.h
··· 511 511 extern struct bio_vec *bvec_alloc(gfp_t, int, unsigned long *, mempool_t *); 512 512 extern void bvec_free(mempool_t *, struct bio_vec *, unsigned int); 513 513 extern unsigned int bvec_nr_vecs(unsigned short idx); 514 + extern const char *bio_devname(struct bio *bio, char *buffer); 514 515 515 516 #define bio_set_dev(bio, bdev) \ 516 517 do { \ ··· 529 528 530 529 #define bio_dev(bio) \ 531 530 disk_devt((bio)->bi_disk) 532 - 533 - #define bio_devname(bio, buf) \ 534 - __bdevname(bio_dev(bio), (buf)) 535 531 536 532 #ifdef CONFIG_BLK_CGROUP 537 533 int bio_associate_blkcg(struct bio *bio, struct cgroup_subsys_state *blkcg_css);
+3 -1
include/linux/genhd.h
··· 198 198 void *private_data; 199 199 200 200 int flags; 201 + struct rw_semaphore lookup_sem; 201 202 struct kobject *slave_dir; 202 203 203 204 struct timer_rand_state *random; ··· 601 600 extern void printk_all_partitions(void); 602 601 603 602 extern struct gendisk *__alloc_disk_node(int minors, int node_id); 604 - extern struct kobject *get_disk(struct gendisk *disk); 603 + extern struct kobject *get_disk_and_module(struct gendisk *disk); 605 604 extern void put_disk(struct gendisk *disk); 605 + extern void put_disk_and_module(struct gendisk *disk); 606 606 extern void blk_register_region(dev_t devt, unsigned long range, 607 607 struct module *module, 608 608 struct kobject *(*probe)(dev_t, int *, void *),
+1 -1
include/uapi/linux/blktrace_api.h
··· 131 131 #define BLKTRACE_BDEV_SIZE 32 132 132 133 133 /* 134 - * User setup structure passed with BLKTRACESTART 134 + * User setup structure passed with BLKTRACESETUP 135 135 */ 136 136 struct blk_user_trace_setup { 137 137 char name[BLKTRACE_BDEV_SIZE]; /* output */