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

Merge tag 'for-5.7/block-2020-03-29' of git://git.kernel.dk/linux-block

Pull block updates from Jens Axboe:

- Online capacity resizing (Balbir)

- Number of hardware queue change fixes (Bart)

- null_blk fault injection addition (Bart)

- Cleanup of queue allocation, unifying the node/no-node API
(Christoph)

- Cleanup of genhd, moving code to where it makes sense (Christoph)

- Cleanup of the partition handling code (Christoph)

- disk stat fixes/improvements (Konstantin)

- BFQ improvements (Paolo)

- Various fixes and improvements

* tag 'for-5.7/block-2020-03-29' of git://git.kernel.dk/linux-block: (72 commits)
block: return NULL in blk_alloc_queue() on error
block: move bio_map_* to blk-map.c
Revert "blkdev: check for valid request queue before issuing flush"
block: simplify queue allocation
bcache: pass the make_request methods to blk_queue_make_request
null_blk: use blk_mq_init_queue_data
block: add a blk_mq_init_queue_data helper
block: move the ->devnode callback to struct block_device_operations
block: move the part_stat* helpers from genhd.h to a new header
block: move block layer internals out of include/linux/genhd.h
block: move guard_bio_eod to bio.c
block: unexport get_gendisk
block: unexport disk_map_sector_rcu
block: unexport disk_get_part
block: mark part_in_flight and part_in_flight_rw static
block: mark block_depr static
block: factor out requeue handling from dispatch code
block/diskstats: replace time_in_queue with sum of request times
block/diskstats: accumulate all per-cpu counters in one pass
block/diskstats: more accurate approximation of io_ticks for slow disks
...

+1951 -2040
+4 -1
Documentation/admin-guide/iostats.rst
··· 100 100 101 101 Since 5.0 this field counts jiffies when at least one request was 102 102 started or completed. If request runs more than 2 jiffies then some 103 - I/O time will not be accounted unless there are other requests. 103 + I/O time might be not accounted in case of concurrent requests. 104 104 105 105 Field 11 -- weighted # of milliseconds spent doing I/Os (unsigned int) 106 106 This field is incremented at each I/O start, I/O completion, I/O ··· 142 142 are summed (possibly overflowing the unsigned long variable they are 143 143 summed to) and the result given to the user. There is no convenient 144 144 user interface for accessing the per-CPU counters themselves. 145 + 146 + Since 4.19 request times are measured with nanoseconds precision and 147 + truncated to milliseconds before showing in this interface. 145 148 146 149 Disks vs Partitions 147 150 -------------------
+4 -12
Documentation/block/capability.rst
··· 2 2 Generic Block Device Capability 3 3 =============================== 4 4 5 - This file documents the sysfs file block/<disk>/capability 5 + This file documents the sysfs file ``block/<disk>/capability``. 6 6 7 - capability is a hex word indicating which capabilities a specific disk 8 - supports. For more information on bits not listed here, see 9 - include/linux/genhd.h 7 + ``capability`` is a bitfield, printed in hexadecimal, indicating which 8 + capabilities a specific block device supports: 10 9 11 - GENHD_FL_MEDIA_CHANGE_NOTIFY 12 - ---------------------------- 13 - 14 - Value: 4 15 - 16 - When this bit is set, the disk supports Asynchronous Notification 17 - of media change events. These events will be broadcast to user 18 - space via kernel uevent. 10 + .. kernel-doc:: include/linux/genhd.h
-21
Documentation/scsi/scsi_mid_low_api.txt
··· 299 299 scsi_host_alloc - return a new scsi_host instance whose refcount==1 300 300 scsi_host_get - increments Scsi_Host instance's refcount 301 301 scsi_host_put - decrements Scsi_Host instance's refcount (free if 0) 302 - scsi_partsize - parse partition table into cylinders, heads + sectors 303 302 scsi_register - create and register a scsi host adapter instance. 304 303 scsi_remove_device - detach and remove a SCSI device 305 304 scsi_remove_host - detach and remove all SCSI devices owned by host ··· 469 470 * Defined in: drivers/scsi/hosts.c 470 471 **/ 471 472 void scsi_host_put(struct Scsi_Host *shost) 472 - 473 - 474 - /** 475 - * scsi_partsize - parse partition table into cylinders, heads + sectors 476 - * @buf: pointer to partition table 477 - * @capacity: size of (total) disk in 512 byte sectors 478 - * @cyls: outputs number of cylinders calculated via this pointer 479 - * @hds: outputs number of heads calculated via this pointer 480 - * @secs: outputs number of sectors calculated via this pointer 481 - * 482 - * Returns 0 on success, -1 on failure 483 - * 484 - * Might block: no 485 - * 486 - * Notes: Caller owns memory returned (free with kfree() ) 487 - * 488 - * Defined in: drivers/scsi/scsicam.c 489 - **/ 490 - int scsi_partsize(unsigned char *buf, unsigned long capacity, 491 - unsigned int *cyls, unsigned int *hds, unsigned int *secs) 492 473 493 474 494 475 /**
+1 -2
arch/m68k/emu/nfblock.c
··· 118 118 dev->bsize = bsize; 119 119 dev->bshift = ffs(bsize) - 10; 120 120 121 - dev->queue = blk_alloc_queue(GFP_KERNEL); 121 + dev->queue = blk_alloc_queue(nfhd_make_request, NUMA_NO_NODE); 122 122 if (dev->queue == NULL) 123 123 goto free_dev; 124 124 125 125 dev->queue->queuedata = dev; 126 - blk_queue_make_request(dev->queue, nfhd_make_request); 127 126 blk_queue_logical_block_size(dev->queue, bsize); 128 127 129 128 dev->disk = alloc_disk(16);
+1 -2
arch/xtensa/platforms/iss/simdisk.c
··· 267 267 spin_lock_init(&dev->lock); 268 268 dev->users = 0; 269 269 270 - dev->queue = blk_alloc_queue(GFP_KERNEL); 270 + dev->queue = blk_alloc_queue(simdisk_make_request, NUMA_NO_NODE); 271 271 if (dev->queue == NULL) { 272 272 pr_err("blk_alloc_queue failed\n"); 273 273 goto out_alloc_queue; 274 274 } 275 275 276 - blk_queue_make_request(dev->queue, simdisk_make_request); 277 276 dev->queue->queuedata = dev; 278 277 279 278 dev->gd = alloc_disk(SIMDISK_MINORS);
+1 -2
block/Makefile
··· 8 8 blk-exec.o blk-merge.o blk-softirq.o blk-timeout.o \ 9 9 blk-lib.o blk-mq.o blk-mq-tag.o blk-stat.o \ 10 10 blk-mq-sysfs.o blk-mq-cpumap.o blk-mq-sched.o ioctl.o \ 11 - genhd.o partition-generic.o ioprio.o \ 12 - badblocks.o partitions/ blk-rq-qos.o 11 + genhd.o ioprio.o badblocks.o partitions/ blk-rq-qos.o 13 12 14 13 obj-$(CONFIG_BOUNCE) += bounce.o 15 14 obj-$(CONFIG_BLK_SCSI_REQUEST) += scsi_ioctl.o
+52 -35
block/bfq-cgroup.c
··· 642 642 { 643 643 struct bfq_entity *entity = &bfqq->entity; 644 644 645 + /* 646 + * Get extra reference to prevent bfqq from being freed in 647 + * next possible expire or deactivate. 648 + */ 649 + bfqq->ref++; 650 + 645 651 /* If bfqq is empty, then bfq_bfqq_expire also invokes 646 652 * bfq_del_bfqq_busy, thereby removing bfqq and its entity 647 653 * from data structures related to current group. Otherwise we ··· 657 651 if (bfqq == bfqd->in_service_queue) 658 652 bfq_bfqq_expire(bfqd, bfqd->in_service_queue, 659 653 false, BFQQE_PREEMPTED); 660 - 661 - /* 662 - * get extra reference to prevent bfqq from being freed in 663 - * next possible deactivate 664 - */ 665 - bfqq->ref++; 666 654 667 655 if (bfq_bfqq_busy(bfqq)) 668 656 bfq_deactivate_bfqq(bfqd, bfqq, false, false); ··· 677 677 678 678 if (!bfqd->in_service_queue && !bfqd->rq_in_driver) 679 679 bfq_schedule_dispatch(bfqd); 680 - /* release extra ref taken above */ 680 + /* release extra ref taken above, bfqq may happen to be freed now */ 681 681 bfq_put_queue(bfqq); 682 682 } 683 683 ··· 714 714 715 715 if (entity->sched_data != &bfqg->sched_data) { 716 716 bic_set_bfqq(bic, NULL, 0); 717 - bfq_log_bfqq(bfqd, async_bfqq, 718 - "bic_change_group: %p %d", 719 - async_bfqq, async_bfqq->ref); 720 - bfq_put_queue(async_bfqq); 717 + bfq_release_process_ref(bfqd, async_bfqq); 721 718 } 722 719 } 723 720 ··· 815 818 /** 816 819 * bfq_reparent_leaf_entity - move leaf entity to the root_group. 817 820 * @bfqd: the device data structure with the root group. 818 - * @entity: the entity to move. 821 + * @entity: the entity to move, if entity is a leaf; or the parent entity 822 + * of an active leaf entity to move, if entity is not a leaf. 819 823 */ 820 824 static void bfq_reparent_leaf_entity(struct bfq_data *bfqd, 821 - struct bfq_entity *entity) 825 + struct bfq_entity *entity, 826 + int ioprio_class) 822 827 { 823 - struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); 828 + struct bfq_queue *bfqq; 829 + struct bfq_entity *child_entity = entity; 824 830 831 + while (child_entity->my_sched_data) { /* leaf not reached yet */ 832 + struct bfq_sched_data *child_sd = child_entity->my_sched_data; 833 + struct bfq_service_tree *child_st = child_sd->service_tree + 834 + ioprio_class; 835 + struct rb_root *child_active = &child_st->active; 836 + 837 + child_entity = bfq_entity_of(rb_first(child_active)); 838 + 839 + if (!child_entity) 840 + child_entity = child_sd->in_service_entity; 841 + } 842 + 843 + bfqq = bfq_entity_to_bfqq(child_entity); 825 844 bfq_bfqq_move(bfqd, bfqq, bfqd->root_group); 826 845 } 827 846 828 847 /** 829 - * bfq_reparent_active_entities - move to the root group all active 830 - * entities. 848 + * bfq_reparent_active_queues - move to the root group all active queues. 831 849 * @bfqd: the device data structure with the root group. 832 850 * @bfqg: the group to move from. 833 - * @st: the service tree with the entities. 851 + * @st: the service tree to start the search from. 834 852 */ 835 - static void bfq_reparent_active_entities(struct bfq_data *bfqd, 836 - struct bfq_group *bfqg, 837 - struct bfq_service_tree *st) 853 + static void bfq_reparent_active_queues(struct bfq_data *bfqd, 854 + struct bfq_group *bfqg, 855 + struct bfq_service_tree *st, 856 + int ioprio_class) 838 857 { 839 858 struct rb_root *active = &st->active; 840 - struct bfq_entity *entity = NULL; 859 + struct bfq_entity *entity; 841 860 842 - if (!RB_EMPTY_ROOT(&st->active)) 843 - entity = bfq_entity_of(rb_first(active)); 844 - 845 - for (; entity ; entity = bfq_entity_of(rb_first(active))) 846 - bfq_reparent_leaf_entity(bfqd, entity); 861 + while ((entity = bfq_entity_of(rb_first(active)))) 862 + bfq_reparent_leaf_entity(bfqd, entity, ioprio_class); 847 863 848 864 if (bfqg->sched_data.in_service_entity) 849 865 bfq_reparent_leaf_entity(bfqd, 850 - bfqg->sched_data.in_service_entity); 866 + bfqg->sched_data.in_service_entity, 867 + ioprio_class); 851 868 } 852 869 853 870 /** ··· 894 883 st = bfqg->sched_data.service_tree + i; 895 884 896 885 /* 897 - * The idle tree may still contain bfq_queues belonging 898 - * to exited task because they never migrated to a different 899 - * cgroup from the one being destroyed now. 900 - */ 901 - bfq_flush_idle_tree(st); 902 - 903 - /* 904 886 * It may happen that some queues are still active 905 887 * (busy) upon group destruction (if the corresponding 906 888 * processes have been forced to terminate). We move ··· 905 901 * There is no need to put the sync queues, as the 906 902 * scheduler has taken no reference. 907 903 */ 908 - bfq_reparent_active_entities(bfqd, bfqg, st); 904 + bfq_reparent_active_queues(bfqd, bfqg, st, i); 905 + 906 + /* 907 + * The idle tree may still contain bfq_queues 908 + * belonging to exited task because they never 909 + * migrated to a different cgroup from the one being 910 + * destroyed now. In addition, even 911 + * bfq_reparent_active_queues() may happen to add some 912 + * entities to the idle tree. It happens if, in some 913 + * of the calls to bfq_bfqq_move() performed by 914 + * bfq_reparent_active_queues(), the queue to move is 915 + * empty and gets expired. 916 + */ 917 + bfq_flush_idle_tree(st); 909 918 } 910 919 911 920 __bfq_deactivate_entity(entity, false);
+12 -6
block/bfq-iosched.c
··· 2716 2716 } 2717 2717 } 2718 2718 2719 - 2720 - static 2721 2719 void bfq_release_process_ref(struct bfq_data *bfqd, struct bfq_queue *bfqq) 2722 2720 { 2723 2721 /* ··· 6213 6215 return bfqq; 6214 6216 } 6215 6217 6216 - static void bfq_idle_slice_timer_body(struct bfq_queue *bfqq) 6218 + static void 6219 + bfq_idle_slice_timer_body(struct bfq_data *bfqd, struct bfq_queue *bfqq) 6217 6220 { 6218 - struct bfq_data *bfqd = bfqq->bfqd; 6219 6221 enum bfqq_expiration reason; 6220 6222 unsigned long flags; 6221 6223 6222 6224 spin_lock_irqsave(&bfqd->lock, flags); 6223 - bfq_clear_bfqq_wait_request(bfqq); 6224 6225 6226 + /* 6227 + * Considering that bfqq may be in race, we should firstly check 6228 + * whether bfqq is in service before doing something on it. If 6229 + * the bfqq in race is not in service, it has already been expired 6230 + * through __bfq_bfqq_expire func and its wait_request flags has 6231 + * been cleared in __bfq_bfqd_reset_in_service func. 6232 + */ 6225 6233 if (bfqq != bfqd->in_service_queue) { 6226 6234 spin_unlock_irqrestore(&bfqd->lock, flags); 6227 6235 return; 6228 6236 } 6237 + 6238 + bfq_clear_bfqq_wait_request(bfqq); 6229 6239 6230 6240 if (bfq_bfqq_budget_timeout(bfqq)) 6231 6241 /* ··· 6279 6273 * early. 6280 6274 */ 6281 6275 if (bfqq) 6282 - bfq_idle_slice_timer_body(bfqq); 6276 + bfq_idle_slice_timer_body(bfqd, bfqq); 6283 6277 6284 6278 return HRTIMER_NORESTART; 6285 6279 }
+1
block/bfq-iosched.h
··· 955 955 bool compensate, enum bfqq_expiration reason); 956 956 void bfq_put_queue(struct bfq_queue *bfqq); 957 957 void bfq_end_wr_async_queues(struct bfq_data *bfqd, struct bfq_group *bfqg); 958 + void bfq_release_process_ref(struct bfq_data *bfqd, struct bfq_queue *bfqq); 958 959 void bfq_schedule_dispatch(struct bfq_data *bfqd); 959 960 void bfq_put_async_queues(struct bfq_data *bfqd, struct bfq_group *bfqg); 960 961
+65 -515
block/bio.c
··· 17 17 #include <linux/cgroup.h> 18 18 #include <linux/blk-cgroup.h> 19 19 #include <linux/highmem.h> 20 + #include <linux/sched/sysctl.h> 20 21 21 22 #include <trace/events/block.h> 22 23 #include "blk.h" ··· 589 588 } 590 589 591 590 /** 591 + * guard_bio_eod - truncate a BIO to fit the block device 592 + * @bio: bio to truncate 593 + * 594 + * This allows us to do IO even on the odd last sectors of a device, even if the 595 + * block size is some multiple of the physical sector size. 596 + * 597 + * We'll just truncate the bio to the size of the device, and clear the end of 598 + * the buffer head manually. Truly out-of-range accesses will turn into actual 599 + * I/O errors, this only handles the "we need to be able to do I/O at the final 600 + * sector" case. 601 + */ 602 + void guard_bio_eod(struct bio *bio) 603 + { 604 + sector_t maxsector; 605 + struct hd_struct *part; 606 + 607 + rcu_read_lock(); 608 + part = __disk_get_part(bio->bi_disk, bio->bi_partno); 609 + if (part) 610 + maxsector = part_nr_sects_read(part); 611 + else 612 + maxsector = get_capacity(bio->bi_disk); 613 + rcu_read_unlock(); 614 + 615 + if (!maxsector) 616 + return; 617 + 618 + /* 619 + * If the *whole* IO is past the end of the device, 620 + * let it through, and the IO layer will turn it into 621 + * an EIO. 622 + */ 623 + if (unlikely(bio->bi_iter.bi_sector >= maxsector)) 624 + return; 625 + 626 + maxsector -= bio->bi_iter.bi_sector; 627 + if (likely((bio->bi_iter.bi_size >> 9) <= maxsector)) 628 + return; 629 + 630 + bio_truncate(bio, maxsector << 9); 631 + } 632 + 633 + /** 592 634 * bio_put - release a reference to a bio 593 635 * @bio: bio to release reference to 594 636 * ··· 723 679 } 724 680 EXPORT_SYMBOL(bio_clone_fast); 725 681 682 + const char *bio_devname(struct bio *bio, char *buf) 683 + { 684 + return disk_name(bio->bi_disk, bio->bi_partno, buf); 685 + } 686 + EXPORT_SYMBOL(bio_devname); 687 + 726 688 static inline bool page_is_mergeable(const struct bio_vec *bv, 727 689 struct page *page, unsigned int len, unsigned int off, 728 690 bool *same_page) ··· 780 730 * 781 731 * This should only be used by passthrough bios. 782 732 */ 783 - static int __bio_add_pc_page(struct request_queue *q, struct bio *bio, 733 + int __bio_add_pc_page(struct request_queue *q, struct bio *bio, 784 734 struct page *page, unsigned int len, unsigned int offset, 785 735 bool *same_page) 786 736 { ··· 1069 1019 int submit_bio_wait(struct bio *bio) 1070 1020 { 1071 1021 DECLARE_COMPLETION_ONSTACK_MAP(done, bio->bi_disk->lockdep_map); 1022 + unsigned long hang_check; 1072 1023 1073 1024 bio->bi_private = &done; 1074 1025 bio->bi_end_io = submit_bio_wait_endio; 1075 1026 bio->bi_opf |= REQ_SYNC; 1076 1027 submit_bio(bio); 1077 - wait_for_completion_io(&done); 1028 + 1029 + /* Prevent hang_check timer from firing at us during very long I/O */ 1030 + hang_check = sysctl_hung_task_timeout_secs; 1031 + if (hang_check) 1032 + while (!wait_for_completion_io_timeout(&done, 1033 + hang_check * (HZ/2))) 1034 + ; 1035 + else 1036 + wait_for_completion_io(&done); 1078 1037 1079 1038 return blk_status_to_errno(bio->bi_status); 1080 1039 } ··· 1194 1135 } 1195 1136 EXPORT_SYMBOL(bio_list_copy_data); 1196 1137 1197 - struct bio_map_data { 1198 - int is_our_pages; 1199 - struct iov_iter iter; 1200 - struct iovec iov[]; 1201 - }; 1202 - 1203 - static struct bio_map_data *bio_alloc_map_data(struct iov_iter *data, 1204 - gfp_t gfp_mask) 1205 - { 1206 - struct bio_map_data *bmd; 1207 - if (data->nr_segs > UIO_MAXIOV) 1208 - return NULL; 1209 - 1210 - bmd = kmalloc(struct_size(bmd, iov, data->nr_segs), gfp_mask); 1211 - if (!bmd) 1212 - return NULL; 1213 - memcpy(bmd->iov, data->iov, sizeof(struct iovec) * data->nr_segs); 1214 - bmd->iter = *data; 1215 - bmd->iter.iov = bmd->iov; 1216 - return bmd; 1217 - } 1218 - 1219 - /** 1220 - * bio_copy_from_iter - copy all pages from iov_iter to bio 1221 - * @bio: The &struct bio which describes the I/O as destination 1222 - * @iter: iov_iter as source 1223 - * 1224 - * Copy all pages from iov_iter to bio. 1225 - * Returns 0 on success, or error on failure. 1226 - */ 1227 - static int bio_copy_from_iter(struct bio *bio, struct iov_iter *iter) 1228 - { 1229 - struct bio_vec *bvec; 1230 - struct bvec_iter_all iter_all; 1231 - 1232 - bio_for_each_segment_all(bvec, bio, iter_all) { 1233 - ssize_t ret; 1234 - 1235 - ret = copy_page_from_iter(bvec->bv_page, 1236 - bvec->bv_offset, 1237 - bvec->bv_len, 1238 - iter); 1239 - 1240 - if (!iov_iter_count(iter)) 1241 - break; 1242 - 1243 - if (ret < bvec->bv_len) 1244 - return -EFAULT; 1245 - } 1246 - 1247 - return 0; 1248 - } 1249 - 1250 - /** 1251 - * bio_copy_to_iter - copy all pages from bio to iov_iter 1252 - * @bio: The &struct bio which describes the I/O as source 1253 - * @iter: iov_iter as destination 1254 - * 1255 - * Copy all pages from bio to iov_iter. 1256 - * Returns 0 on success, or error on failure. 1257 - */ 1258 - static int bio_copy_to_iter(struct bio *bio, struct iov_iter iter) 1259 - { 1260 - struct bio_vec *bvec; 1261 - struct bvec_iter_all iter_all; 1262 - 1263 - bio_for_each_segment_all(bvec, bio, iter_all) { 1264 - ssize_t ret; 1265 - 1266 - ret = copy_page_to_iter(bvec->bv_page, 1267 - bvec->bv_offset, 1268 - bvec->bv_len, 1269 - &iter); 1270 - 1271 - if (!iov_iter_count(&iter)) 1272 - break; 1273 - 1274 - if (ret < bvec->bv_len) 1275 - return -EFAULT; 1276 - } 1277 - 1278 - return 0; 1279 - } 1280 - 1281 1138 void bio_free_pages(struct bio *bio) 1282 1139 { 1283 1140 struct bio_vec *bvec; ··· 1203 1228 __free_page(bvec->bv_page); 1204 1229 } 1205 1230 EXPORT_SYMBOL(bio_free_pages); 1206 - 1207 - /** 1208 - * bio_uncopy_user - finish previously mapped bio 1209 - * @bio: bio being terminated 1210 - * 1211 - * Free pages allocated from bio_copy_user_iov() and write back data 1212 - * to user space in case of a read. 1213 - */ 1214 - int bio_uncopy_user(struct bio *bio) 1215 - { 1216 - struct bio_map_data *bmd = bio->bi_private; 1217 - int ret = 0; 1218 - 1219 - if (!bio_flagged(bio, BIO_NULL_MAPPED)) { 1220 - /* 1221 - * if we're in a workqueue, the request is orphaned, so 1222 - * don't copy into a random user address space, just free 1223 - * and return -EINTR so user space doesn't expect any data. 1224 - */ 1225 - if (!current->mm) 1226 - ret = -EINTR; 1227 - else if (bio_data_dir(bio) == READ) 1228 - ret = bio_copy_to_iter(bio, bmd->iter); 1229 - if (bmd->is_our_pages) 1230 - bio_free_pages(bio); 1231 - } 1232 - kfree(bmd); 1233 - bio_put(bio); 1234 - return ret; 1235 - } 1236 - 1237 - /** 1238 - * bio_copy_user_iov - copy user data to bio 1239 - * @q: destination block queue 1240 - * @map_data: pointer to the rq_map_data holding pages (if necessary) 1241 - * @iter: iovec iterator 1242 - * @gfp_mask: memory allocation flags 1243 - * 1244 - * Prepares and returns a bio for indirect user io, bouncing data 1245 - * to/from kernel pages as necessary. Must be paired with 1246 - * call bio_uncopy_user() on io completion. 1247 - */ 1248 - struct bio *bio_copy_user_iov(struct request_queue *q, 1249 - struct rq_map_data *map_data, 1250 - struct iov_iter *iter, 1251 - gfp_t gfp_mask) 1252 - { 1253 - struct bio_map_data *bmd; 1254 - struct page *page; 1255 - struct bio *bio; 1256 - int i = 0, ret; 1257 - int nr_pages; 1258 - unsigned int len = iter->count; 1259 - unsigned int offset = map_data ? offset_in_page(map_data->offset) : 0; 1260 - 1261 - bmd = bio_alloc_map_data(iter, gfp_mask); 1262 - if (!bmd) 1263 - return ERR_PTR(-ENOMEM); 1264 - 1265 - /* 1266 - * We need to do a deep copy of the iov_iter including the iovecs. 1267 - * The caller provided iov might point to an on-stack or otherwise 1268 - * shortlived one. 1269 - */ 1270 - bmd->is_our_pages = map_data ? 0 : 1; 1271 - 1272 - nr_pages = DIV_ROUND_UP(offset + len, PAGE_SIZE); 1273 - if (nr_pages > BIO_MAX_PAGES) 1274 - nr_pages = BIO_MAX_PAGES; 1275 - 1276 - ret = -ENOMEM; 1277 - bio = bio_kmalloc(gfp_mask, nr_pages); 1278 - if (!bio) 1279 - goto out_bmd; 1280 - 1281 - ret = 0; 1282 - 1283 - if (map_data) { 1284 - nr_pages = 1 << map_data->page_order; 1285 - i = map_data->offset / PAGE_SIZE; 1286 - } 1287 - while (len) { 1288 - unsigned int bytes = PAGE_SIZE; 1289 - 1290 - bytes -= offset; 1291 - 1292 - if (bytes > len) 1293 - bytes = len; 1294 - 1295 - if (map_data) { 1296 - if (i == map_data->nr_entries * nr_pages) { 1297 - ret = -ENOMEM; 1298 - break; 1299 - } 1300 - 1301 - page = map_data->pages[i / nr_pages]; 1302 - page += (i % nr_pages); 1303 - 1304 - i++; 1305 - } else { 1306 - page = alloc_page(q->bounce_gfp | gfp_mask); 1307 - if (!page) { 1308 - ret = -ENOMEM; 1309 - break; 1310 - } 1311 - } 1312 - 1313 - if (bio_add_pc_page(q, bio, page, bytes, offset) < bytes) { 1314 - if (!map_data) 1315 - __free_page(page); 1316 - break; 1317 - } 1318 - 1319 - len -= bytes; 1320 - offset = 0; 1321 - } 1322 - 1323 - if (ret) 1324 - goto cleanup; 1325 - 1326 - if (map_data) 1327 - map_data->offset += bio->bi_iter.bi_size; 1328 - 1329 - /* 1330 - * success 1331 - */ 1332 - if ((iov_iter_rw(iter) == WRITE && (!map_data || !map_data->null_mapped)) || 1333 - (map_data && map_data->from_user)) { 1334 - ret = bio_copy_from_iter(bio, iter); 1335 - if (ret) 1336 - goto cleanup; 1337 - } else { 1338 - if (bmd->is_our_pages) 1339 - zero_fill_bio(bio); 1340 - iov_iter_advance(iter, bio->bi_iter.bi_size); 1341 - } 1342 - 1343 - bio->bi_private = bmd; 1344 - if (map_data && map_data->null_mapped) 1345 - bio_set_flag(bio, BIO_NULL_MAPPED); 1346 - return bio; 1347 - cleanup: 1348 - if (!map_data) 1349 - bio_free_pages(bio); 1350 - bio_put(bio); 1351 - out_bmd: 1352 - kfree(bmd); 1353 - return ERR_PTR(ret); 1354 - } 1355 - 1356 - /** 1357 - * bio_map_user_iov - map user iovec into bio 1358 - * @q: the struct request_queue for the bio 1359 - * @iter: iovec iterator 1360 - * @gfp_mask: memory allocation flags 1361 - * 1362 - * Map the user space address into a bio suitable for io to a block 1363 - * device. Returns an error pointer in case of error. 1364 - */ 1365 - struct bio *bio_map_user_iov(struct request_queue *q, 1366 - struct iov_iter *iter, 1367 - gfp_t gfp_mask) 1368 - { 1369 - int j; 1370 - struct bio *bio; 1371 - int ret; 1372 - 1373 - if (!iov_iter_count(iter)) 1374 - return ERR_PTR(-EINVAL); 1375 - 1376 - bio = bio_kmalloc(gfp_mask, iov_iter_npages(iter, BIO_MAX_PAGES)); 1377 - if (!bio) 1378 - return ERR_PTR(-ENOMEM); 1379 - 1380 - while (iov_iter_count(iter)) { 1381 - struct page **pages; 1382 - ssize_t bytes; 1383 - size_t offs, added = 0; 1384 - int npages; 1385 - 1386 - bytes = iov_iter_get_pages_alloc(iter, &pages, LONG_MAX, &offs); 1387 - if (unlikely(bytes <= 0)) { 1388 - ret = bytes ? bytes : -EFAULT; 1389 - goto out_unmap; 1390 - } 1391 - 1392 - npages = DIV_ROUND_UP(offs + bytes, PAGE_SIZE); 1393 - 1394 - if (unlikely(offs & queue_dma_alignment(q))) { 1395 - ret = -EINVAL; 1396 - j = 0; 1397 - } else { 1398 - for (j = 0; j < npages; j++) { 1399 - struct page *page = pages[j]; 1400 - unsigned int n = PAGE_SIZE - offs; 1401 - bool same_page = false; 1402 - 1403 - if (n > bytes) 1404 - n = bytes; 1405 - 1406 - if (!__bio_add_pc_page(q, bio, page, n, offs, 1407 - &same_page)) { 1408 - if (same_page) 1409 - put_page(page); 1410 - break; 1411 - } 1412 - 1413 - added += n; 1414 - bytes -= n; 1415 - offs = 0; 1416 - } 1417 - iov_iter_advance(iter, added); 1418 - } 1419 - /* 1420 - * release the pages we didn't map into the bio, if any 1421 - */ 1422 - while (j < npages) 1423 - put_page(pages[j++]); 1424 - kvfree(pages); 1425 - /* couldn't stuff something into bio? */ 1426 - if (bytes) 1427 - break; 1428 - } 1429 - 1430 - bio_set_flag(bio, BIO_USER_MAPPED); 1431 - 1432 - /* 1433 - * subtle -- if bio_map_user_iov() ended up bouncing a bio, 1434 - * it would normally disappear when its bi_end_io is run. 1435 - * however, we need it for the unmap, so grab an extra 1436 - * reference to it 1437 - */ 1438 - bio_get(bio); 1439 - return bio; 1440 - 1441 - out_unmap: 1442 - bio_release_pages(bio, false); 1443 - bio_put(bio); 1444 - return ERR_PTR(ret); 1445 - } 1446 - 1447 - /** 1448 - * bio_unmap_user - unmap a bio 1449 - * @bio: the bio being unmapped 1450 - * 1451 - * Unmap a bio previously mapped by bio_map_user_iov(). Must be called from 1452 - * process context. 1453 - * 1454 - * bio_unmap_user() may sleep. 1455 - */ 1456 - void bio_unmap_user(struct bio *bio) 1457 - { 1458 - bio_release_pages(bio, bio_data_dir(bio) == READ); 1459 - bio_put(bio); 1460 - bio_put(bio); 1461 - } 1462 - 1463 - static void bio_invalidate_vmalloc_pages(struct bio *bio) 1464 - { 1465 - #ifdef ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE 1466 - if (bio->bi_private && !op_is_write(bio_op(bio))) { 1467 - unsigned long i, len = 0; 1468 - 1469 - for (i = 0; i < bio->bi_vcnt; i++) 1470 - len += bio->bi_io_vec[i].bv_len; 1471 - invalidate_kernel_vmap_range(bio->bi_private, len); 1472 - } 1473 - #endif 1474 - } 1475 - 1476 - static void bio_map_kern_endio(struct bio *bio) 1477 - { 1478 - bio_invalidate_vmalloc_pages(bio); 1479 - bio_put(bio); 1480 - } 1481 - 1482 - /** 1483 - * bio_map_kern - map kernel address into bio 1484 - * @q: the struct request_queue for the bio 1485 - * @data: pointer to buffer to map 1486 - * @len: length in bytes 1487 - * @gfp_mask: allocation flags for bio allocation 1488 - * 1489 - * Map the kernel address into a bio suitable for io to a block 1490 - * device. Returns an error pointer in case of error. 1491 - */ 1492 - struct bio *bio_map_kern(struct request_queue *q, void *data, unsigned int len, 1493 - gfp_t gfp_mask) 1494 - { 1495 - unsigned long kaddr = (unsigned long)data; 1496 - unsigned long end = (kaddr + len + PAGE_SIZE - 1) >> PAGE_SHIFT; 1497 - unsigned long start = kaddr >> PAGE_SHIFT; 1498 - const int nr_pages = end - start; 1499 - bool is_vmalloc = is_vmalloc_addr(data); 1500 - struct page *page; 1501 - int offset, i; 1502 - struct bio *bio; 1503 - 1504 - bio = bio_kmalloc(gfp_mask, nr_pages); 1505 - if (!bio) 1506 - return ERR_PTR(-ENOMEM); 1507 - 1508 - if (is_vmalloc) { 1509 - flush_kernel_vmap_range(data, len); 1510 - bio->bi_private = data; 1511 - } 1512 - 1513 - offset = offset_in_page(kaddr); 1514 - for (i = 0; i < nr_pages; i++) { 1515 - unsigned int bytes = PAGE_SIZE - offset; 1516 - 1517 - if (len <= 0) 1518 - break; 1519 - 1520 - if (bytes > len) 1521 - bytes = len; 1522 - 1523 - if (!is_vmalloc) 1524 - page = virt_to_page(data); 1525 - else 1526 - page = vmalloc_to_page(data); 1527 - if (bio_add_pc_page(q, bio, page, bytes, 1528 - offset) < bytes) { 1529 - /* we don't support partial mappings */ 1530 - bio_put(bio); 1531 - return ERR_PTR(-EINVAL); 1532 - } 1533 - 1534 - data += bytes; 1535 - len -= bytes; 1536 - offset = 0; 1537 - } 1538 - 1539 - bio->bi_end_io = bio_map_kern_endio; 1540 - return bio; 1541 - } 1542 - 1543 - static void bio_copy_kern_endio(struct bio *bio) 1544 - { 1545 - bio_free_pages(bio); 1546 - bio_put(bio); 1547 - } 1548 - 1549 - static void bio_copy_kern_endio_read(struct bio *bio) 1550 - { 1551 - char *p = bio->bi_private; 1552 - struct bio_vec *bvec; 1553 - struct bvec_iter_all iter_all; 1554 - 1555 - bio_for_each_segment_all(bvec, bio, iter_all) { 1556 - memcpy(p, page_address(bvec->bv_page), bvec->bv_len); 1557 - p += bvec->bv_len; 1558 - } 1559 - 1560 - bio_copy_kern_endio(bio); 1561 - } 1562 - 1563 - /** 1564 - * bio_copy_kern - copy kernel address into bio 1565 - * @q: the struct request_queue for the bio 1566 - * @data: pointer to buffer to copy 1567 - * @len: length in bytes 1568 - * @gfp_mask: allocation flags for bio and page allocation 1569 - * @reading: data direction is READ 1570 - * 1571 - * copy the kernel address into a bio suitable for io to a block 1572 - * device. Returns an error pointer in case of error. 1573 - */ 1574 - struct bio *bio_copy_kern(struct request_queue *q, void *data, unsigned int len, 1575 - gfp_t gfp_mask, int reading) 1576 - { 1577 - unsigned long kaddr = (unsigned long)data; 1578 - unsigned long end = (kaddr + len + PAGE_SIZE - 1) >> PAGE_SHIFT; 1579 - unsigned long start = kaddr >> PAGE_SHIFT; 1580 - struct bio *bio; 1581 - void *p = data; 1582 - int nr_pages = 0; 1583 - 1584 - /* 1585 - * Overflow, abort 1586 - */ 1587 - if (end < start) 1588 - return ERR_PTR(-EINVAL); 1589 - 1590 - nr_pages = end - start; 1591 - bio = bio_kmalloc(gfp_mask, nr_pages); 1592 - if (!bio) 1593 - return ERR_PTR(-ENOMEM); 1594 - 1595 - while (len) { 1596 - struct page *page; 1597 - unsigned int bytes = PAGE_SIZE; 1598 - 1599 - if (bytes > len) 1600 - bytes = len; 1601 - 1602 - page = alloc_page(q->bounce_gfp | gfp_mask); 1603 - if (!page) 1604 - goto cleanup; 1605 - 1606 - if (!reading) 1607 - memcpy(page_address(page), p, bytes); 1608 - 1609 - if (bio_add_pc_page(q, bio, page, bytes, 0) < bytes) 1610 - break; 1611 - 1612 - len -= bytes; 1613 - p += bytes; 1614 - } 1615 - 1616 - if (reading) { 1617 - bio->bi_end_io = bio_copy_kern_endio_read; 1618 - bio->bi_private = data; 1619 - } else { 1620 - bio->bi_end_io = bio_copy_kern_endio; 1621 - } 1622 - 1623 - return bio; 1624 - 1625 - cleanup: 1626 - bio_free_pages(bio); 1627 - bio_put(bio); 1628 - return ERR_PTR(-ENOMEM); 1629 - } 1630 1231 1631 1232 /* 1632 1233 * bio_set_pages_dirty() and bio_check_pages_dirty() are support functions ··· 1303 1752 schedule_work(&bio_dirty_work); 1304 1753 } 1305 1754 1306 - void update_io_ticks(struct hd_struct *part, unsigned long now) 1755 + void update_io_ticks(struct hd_struct *part, unsigned long now, bool end) 1307 1756 { 1308 1757 unsigned long stamp; 1309 1758 again: 1310 1759 stamp = READ_ONCE(part->stamp); 1311 1760 if (unlikely(stamp != now)) { 1312 1761 if (likely(cmpxchg(&part->stamp, stamp, now) == stamp)) { 1313 - __part_stat_add(part, io_ticks, 1); 1762 + __part_stat_add(part, io_ticks, end ? now - stamp : 1); 1314 1763 } 1315 1764 } 1316 1765 if (part->partno) { ··· 1326 1775 1327 1776 part_stat_lock(); 1328 1777 1329 - update_io_ticks(part, jiffies); 1778 + update_io_ticks(part, jiffies, false); 1330 1779 part_stat_inc(part, ios[sgrp]); 1331 1780 part_stat_add(part, sectors[sgrp], sectors); 1332 1781 part_inc_in_flight(q, part, op_is_write(op)); ··· 1344 1793 1345 1794 part_stat_lock(); 1346 1795 1347 - update_io_ticks(part, now); 1796 + update_io_ticks(part, now, true); 1348 1797 part_stat_add(part, nsecs[sgrp], jiffies_to_nsecs(duration)); 1349 - part_stat_add(part, time_in_queue, duration); 1350 1798 part_dec_in_flight(q, part, op_is_write(req_op)); 1351 1799 1352 1800 part_stat_unlock();
+1 -1
block/blk-cgroup.c
··· 1010 1010 * blkcg_init_queue - initialize blkcg part of request queue 1011 1011 * @q: request_queue to initialize 1012 1012 * 1013 - * Called from blk_alloc_queue_node(). Responsible for initializing blkcg 1013 + * Called from __blk_alloc_queue(). Responsible for initializing blkcg 1014 1014 * part of new request_queue @q. 1015 1015 * 1016 1016 * RETURNS:
+38 -44
block/blk-core.c
··· 346 346 347 347 blk_queue_flag_set(QUEUE_FLAG_NOMERGES, q); 348 348 blk_queue_flag_set(QUEUE_FLAG_NOXMERGES, q); 349 - blk_queue_flag_set(QUEUE_FLAG_DYING, q); 350 349 351 350 /* 352 351 * Drain all requests queued before DYING marking. Set DEAD flag to ··· 387 388 blk_put_queue(q); 388 389 } 389 390 EXPORT_SYMBOL(blk_cleanup_queue); 390 - 391 - struct request_queue *blk_alloc_queue(gfp_t gfp_mask) 392 - { 393 - return blk_alloc_queue_node(gfp_mask, NUMA_NO_NODE); 394 - } 395 - EXPORT_SYMBOL(blk_alloc_queue); 396 391 397 392 /** 398 393 * blk_queue_enter() - try to increase q->q_usage_counter ··· 464 471 { 465 472 } 466 473 467 - /** 468 - * blk_alloc_queue_node - allocate a request queue 469 - * @gfp_mask: memory allocation flags 470 - * @node_id: NUMA node to allocate memory from 471 - */ 472 - struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id) 474 + struct request_queue *__blk_alloc_queue(int node_id) 473 475 { 474 476 struct request_queue *q; 475 477 int ret; 476 478 477 479 q = kmem_cache_alloc_node(blk_requestq_cachep, 478 - gfp_mask | __GFP_ZERO, node_id); 480 + GFP_KERNEL | __GFP_ZERO, node_id); 479 481 if (!q) 480 482 return NULL; 481 483 482 484 q->last_merge = NULL; 483 485 484 - q->id = ida_simple_get(&blk_queue_ida, 0, 0, gfp_mask); 486 + q->id = ida_simple_get(&blk_queue_ida, 0, 0, GFP_KERNEL); 485 487 if (q->id < 0) 486 488 goto fail_q; 487 489 ··· 484 496 if (ret) 485 497 goto fail_id; 486 498 487 - q->backing_dev_info = bdi_alloc_node(gfp_mask, node_id); 499 + q->backing_dev_info = bdi_alloc_node(GFP_KERNEL, node_id); 488 500 if (!q->backing_dev_info) 489 501 goto fail_split; 490 502 ··· 530 542 if (blkcg_init_queue(q)) 531 543 goto fail_ref; 532 544 545 + blk_queue_dma_alignment(q, 511); 546 + blk_set_default_limits(&q->limits); 547 + 533 548 return q; 534 549 535 550 fail_ref: ··· 549 558 kmem_cache_free(blk_requestq_cachep, q); 550 559 return NULL; 551 560 } 552 - EXPORT_SYMBOL(blk_alloc_queue_node); 561 + 562 + struct request_queue *blk_alloc_queue(make_request_fn make_request, int node_id) 563 + { 564 + struct request_queue *q; 565 + 566 + if (WARN_ON_ONCE(!make_request)) 567 + return NULL; 568 + 569 + q = __blk_alloc_queue(node_id); 570 + if (!q) 571 + return NULL; 572 + q->make_request_fn = make_request; 573 + q->nr_requests = BLKDEV_MAX_RQ; 574 + return q; 575 + } 576 + EXPORT_SYMBOL(blk_alloc_queue); 553 577 554 578 bool blk_get_queue(struct request_queue *q) 555 579 { ··· 1127 1121 1128 1122 if (unlikely(blk_queue_enter(q, nowait ? BLK_MQ_REQ_NOWAIT : 0))) { 1129 1123 if (nowait && !blk_queue_dying(q)) 1130 - bio->bi_status = BLK_STS_AGAIN; 1124 + bio_wouldblock_error(bio); 1131 1125 else 1132 - bio->bi_status = BLK_STS_IOERR; 1133 - bio_endio(bio); 1126 + bio_io_error(bio); 1134 1127 return BLK_QC_T_NONE; 1135 1128 } 1136 1129 ··· 1208 1203 1209 1204 /** 1210 1205 * blk_cloned_rq_check_limits - Helper function to check a cloned request 1211 - * for new the queue limits 1206 + * for the new queue limits 1212 1207 * @q: the queue 1213 1208 * @rq: the request being checked 1214 1209 * ··· 1344 1339 part_stat_lock(); 1345 1340 part = req->part; 1346 1341 1347 - update_io_ticks(part, jiffies); 1342 + update_io_ticks(part, jiffies, true); 1348 1343 part_stat_inc(part, ios[sgrp]); 1349 1344 part_stat_add(part, nsecs[sgrp], now - req->start_time_ns); 1350 - part_stat_add(part, time_in_queue, nsecs_to_jiffies64(now - req->start_time_ns)); 1351 1345 part_dec_in_flight(req->q, part, rq_data_dir(req)); 1352 1346 1353 1347 hd_struct_put(part); ··· 1385 1381 rq->part = part; 1386 1382 } 1387 1383 1388 - update_io_ticks(part, jiffies); 1384 + update_io_ticks(part, jiffies, false); 1389 1385 1390 1386 part_stat_unlock(); 1391 1387 } ··· 1587 1583 } 1588 1584 EXPORT_SYMBOL_GPL(blk_rq_unprep_clone); 1589 1585 1590 - /* 1591 - * Copy attributes of the original request to the clone request. 1592 - * The actual data parts (e.g. ->cmd, ->sense) are not copied. 1593 - */ 1594 - static void __blk_rq_prep_clone(struct request *dst, struct request *src) 1595 - { 1596 - dst->__sector = blk_rq_pos(src); 1597 - dst->__data_len = blk_rq_bytes(src); 1598 - if (src->rq_flags & RQF_SPECIAL_PAYLOAD) { 1599 - dst->rq_flags |= RQF_SPECIAL_PAYLOAD; 1600 - dst->special_vec = src->special_vec; 1601 - } 1602 - dst->nr_phys_segments = src->nr_phys_segments; 1603 - dst->ioprio = src->ioprio; 1604 - dst->extra_len = src->extra_len; 1605 - } 1606 - 1607 1586 /** 1608 1587 * blk_rq_prep_clone - Helper function to setup clone request 1609 1588 * @rq: the request to be setup ··· 1599 1612 * 1600 1613 * Description: 1601 1614 * Clones bios in @rq_src to @rq, and copies attributes of @rq_src to @rq. 1602 - * The actual data parts of @rq_src (e.g. ->cmd, ->sense) 1603 - * are not copied, and copying such parts is the caller's responsibility. 1604 1615 * Also, pages which the original bios are pointing to are not copied 1605 1616 * and the cloned bios just point same pages. 1606 1617 * So cloned bios must be completed before original bios, which means ··· 1629 1644 rq->bio = rq->biotail = bio; 1630 1645 } 1631 1646 1632 - __blk_rq_prep_clone(rq, rq_src); 1647 + /* Copy attributes of the original request to the clone request. */ 1648 + rq->__sector = blk_rq_pos(rq_src); 1649 + rq->__data_len = blk_rq_bytes(rq_src); 1650 + if (rq_src->rq_flags & RQF_SPECIAL_PAYLOAD) { 1651 + rq->rq_flags |= RQF_SPECIAL_PAYLOAD; 1652 + rq->special_vec = rq_src->special_vec; 1653 + } 1654 + rq->nr_phys_segments = rq_src->nr_phys_segments; 1655 + rq->ioprio = rq_src->ioprio; 1656 + rq->extra_len = rq_src->extra_len; 1633 1657 1634 1658 return 0; 1635 1659
+2 -14
block/blk-flush.c
··· 160 160 * 161 161 * CONTEXT: 162 162 * spin_lock_irq(fq->mq_flush_lock) 163 - * 164 - * RETURNS: 165 - * %true if requests were added to the dispatch queue, %false otherwise. 166 163 */ 167 164 static void blk_flush_complete_seq(struct request *rq, 168 165 struct blk_flush_queue *fq, ··· 454 457 if (!q) 455 458 return -ENXIO; 456 459 457 - /* 458 - * some block devices may not have their queue correctly set up here 459 - * (e.g. loop device without a backing file) and so issuing a flush 460 - * here will panic. Ensure there is a request function before issuing 461 - * the flush. 462 - */ 463 - if (!q->make_request_fn) 464 - return -ENXIO; 465 - 466 460 bio = bio_alloc(gfp_mask, 0); 467 461 bio_set_dev(bio, bdev); 468 462 bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH; ··· 473 485 } 474 486 EXPORT_SYMBOL(blkdev_issue_flush); 475 487 476 - struct blk_flush_queue *blk_alloc_flush_queue(struct request_queue *q, 477 - int node, int cmd_size, gfp_t flags) 488 + struct blk_flush_queue *blk_alloc_flush_queue(int node, int cmd_size, 489 + gfp_t flags) 478 490 { 479 491 struct blk_flush_queue *fq; 480 492 int rq_sz = sizeof(struct request);
+7
block/blk-ioc.c
··· 84 84 * making it impossible to determine icq_cache. Record it in @icq. 85 85 */ 86 86 icq->__rcu_icq_cache = et->icq_cache; 87 + icq->flags |= ICQ_DESTROYED; 87 88 call_rcu(&icq->__rcu_head, icq_free_icq_rcu); 88 89 } 89 90 ··· 213 212 { 214 213 unsigned long flags; 215 214 215 + rcu_read_lock(); 216 216 while (!list_empty(icq_list)) { 217 217 struct io_cq *icq = list_entry(icq_list->next, 218 218 struct io_cq, q_node); 219 219 struct io_context *ioc = icq->ioc; 220 220 221 221 spin_lock_irqsave(&ioc->lock, flags); 222 + if (icq->flags & ICQ_DESTROYED) { 223 + spin_unlock_irqrestore(&ioc->lock, flags); 224 + continue; 225 + } 222 226 ioc_destroy_icq(icq); 223 227 spin_unlock_irqrestore(&ioc->lock, flags); 224 228 } 229 + rcu_read_unlock(); 225 230 } 226 231 227 232 /**
-3
block/blk-iocost.c
··· 46 46 * If needed, tools/cgroup/iocost_coef_gen.py can be used to generate 47 47 * device-specific coefficients. 48 48 * 49 - * If needed, tools/cgroup/iocost_coef_gen.py can be used to generate 50 - * device-specific coefficients. 51 - * 52 49 * 2. Control Strategy 53 50 * 54 51 * The device virtual time (vtime) is used as the primary control metric.
+508
block/blk-map.c
··· 11 11 12 12 #include "blk.h" 13 13 14 + struct bio_map_data { 15 + int is_our_pages; 16 + struct iov_iter iter; 17 + struct iovec iov[]; 18 + }; 19 + 20 + static struct bio_map_data *bio_alloc_map_data(struct iov_iter *data, 21 + gfp_t gfp_mask) 22 + { 23 + struct bio_map_data *bmd; 24 + 25 + if (data->nr_segs > UIO_MAXIOV) 26 + return NULL; 27 + 28 + bmd = kmalloc(struct_size(bmd, iov, data->nr_segs), gfp_mask); 29 + if (!bmd) 30 + return NULL; 31 + memcpy(bmd->iov, data->iov, sizeof(struct iovec) * data->nr_segs); 32 + bmd->iter = *data; 33 + bmd->iter.iov = bmd->iov; 34 + return bmd; 35 + } 36 + 37 + /** 38 + * bio_copy_from_iter - copy all pages from iov_iter to bio 39 + * @bio: The &struct bio which describes the I/O as destination 40 + * @iter: iov_iter as source 41 + * 42 + * Copy all pages from iov_iter to bio. 43 + * Returns 0 on success, or error on failure. 44 + */ 45 + static int bio_copy_from_iter(struct bio *bio, struct iov_iter *iter) 46 + { 47 + struct bio_vec *bvec; 48 + struct bvec_iter_all iter_all; 49 + 50 + bio_for_each_segment_all(bvec, bio, iter_all) { 51 + ssize_t ret; 52 + 53 + ret = copy_page_from_iter(bvec->bv_page, 54 + bvec->bv_offset, 55 + bvec->bv_len, 56 + iter); 57 + 58 + if (!iov_iter_count(iter)) 59 + break; 60 + 61 + if (ret < bvec->bv_len) 62 + return -EFAULT; 63 + } 64 + 65 + return 0; 66 + } 67 + 68 + /** 69 + * bio_copy_to_iter - copy all pages from bio to iov_iter 70 + * @bio: The &struct bio which describes the I/O as source 71 + * @iter: iov_iter as destination 72 + * 73 + * Copy all pages from bio to iov_iter. 74 + * Returns 0 on success, or error on failure. 75 + */ 76 + static int bio_copy_to_iter(struct bio *bio, struct iov_iter iter) 77 + { 78 + struct bio_vec *bvec; 79 + struct bvec_iter_all iter_all; 80 + 81 + bio_for_each_segment_all(bvec, bio, iter_all) { 82 + ssize_t ret; 83 + 84 + ret = copy_page_to_iter(bvec->bv_page, 85 + bvec->bv_offset, 86 + bvec->bv_len, 87 + &iter); 88 + 89 + if (!iov_iter_count(&iter)) 90 + break; 91 + 92 + if (ret < bvec->bv_len) 93 + return -EFAULT; 94 + } 95 + 96 + return 0; 97 + } 98 + 99 + /** 100 + * bio_uncopy_user - finish previously mapped bio 101 + * @bio: bio being terminated 102 + * 103 + * Free pages allocated from bio_copy_user_iov() and write back data 104 + * to user space in case of a read. 105 + */ 106 + static int bio_uncopy_user(struct bio *bio) 107 + { 108 + struct bio_map_data *bmd = bio->bi_private; 109 + int ret = 0; 110 + 111 + if (!bio_flagged(bio, BIO_NULL_MAPPED)) { 112 + /* 113 + * if we're in a workqueue, the request is orphaned, so 114 + * don't copy into a random user address space, just free 115 + * and return -EINTR so user space doesn't expect any data. 116 + */ 117 + if (!current->mm) 118 + ret = -EINTR; 119 + else if (bio_data_dir(bio) == READ) 120 + ret = bio_copy_to_iter(bio, bmd->iter); 121 + if (bmd->is_our_pages) 122 + bio_free_pages(bio); 123 + } 124 + kfree(bmd); 125 + bio_put(bio); 126 + return ret; 127 + } 128 + 129 + /** 130 + * bio_copy_user_iov - copy user data to bio 131 + * @q: destination block queue 132 + * @map_data: pointer to the rq_map_data holding pages (if necessary) 133 + * @iter: iovec iterator 134 + * @gfp_mask: memory allocation flags 135 + * 136 + * Prepares and returns a bio for indirect user io, bouncing data 137 + * to/from kernel pages as necessary. Must be paired with 138 + * call bio_uncopy_user() on io completion. 139 + */ 140 + static struct bio *bio_copy_user_iov(struct request_queue *q, 141 + struct rq_map_data *map_data, struct iov_iter *iter, 142 + gfp_t gfp_mask) 143 + { 144 + struct bio_map_data *bmd; 145 + struct page *page; 146 + struct bio *bio; 147 + int i = 0, ret; 148 + int nr_pages; 149 + unsigned int len = iter->count; 150 + unsigned int offset = map_data ? offset_in_page(map_data->offset) : 0; 151 + 152 + bmd = bio_alloc_map_data(iter, gfp_mask); 153 + if (!bmd) 154 + return ERR_PTR(-ENOMEM); 155 + 156 + /* 157 + * We need to do a deep copy of the iov_iter including the iovecs. 158 + * The caller provided iov might point to an on-stack or otherwise 159 + * shortlived one. 160 + */ 161 + bmd->is_our_pages = map_data ? 0 : 1; 162 + 163 + nr_pages = DIV_ROUND_UP(offset + len, PAGE_SIZE); 164 + if (nr_pages > BIO_MAX_PAGES) 165 + nr_pages = BIO_MAX_PAGES; 166 + 167 + ret = -ENOMEM; 168 + bio = bio_kmalloc(gfp_mask, nr_pages); 169 + if (!bio) 170 + goto out_bmd; 171 + 172 + ret = 0; 173 + 174 + if (map_data) { 175 + nr_pages = 1 << map_data->page_order; 176 + i = map_data->offset / PAGE_SIZE; 177 + } 178 + while (len) { 179 + unsigned int bytes = PAGE_SIZE; 180 + 181 + bytes -= offset; 182 + 183 + if (bytes > len) 184 + bytes = len; 185 + 186 + if (map_data) { 187 + if (i == map_data->nr_entries * nr_pages) { 188 + ret = -ENOMEM; 189 + break; 190 + } 191 + 192 + page = map_data->pages[i / nr_pages]; 193 + page += (i % nr_pages); 194 + 195 + i++; 196 + } else { 197 + page = alloc_page(q->bounce_gfp | gfp_mask); 198 + if (!page) { 199 + ret = -ENOMEM; 200 + break; 201 + } 202 + } 203 + 204 + if (bio_add_pc_page(q, bio, page, bytes, offset) < bytes) { 205 + if (!map_data) 206 + __free_page(page); 207 + break; 208 + } 209 + 210 + len -= bytes; 211 + offset = 0; 212 + } 213 + 214 + if (ret) 215 + goto cleanup; 216 + 217 + if (map_data) 218 + map_data->offset += bio->bi_iter.bi_size; 219 + 220 + /* 221 + * success 222 + */ 223 + if ((iov_iter_rw(iter) == WRITE && 224 + (!map_data || !map_data->null_mapped)) || 225 + (map_data && map_data->from_user)) { 226 + ret = bio_copy_from_iter(bio, iter); 227 + if (ret) 228 + goto cleanup; 229 + } else { 230 + if (bmd->is_our_pages) 231 + zero_fill_bio(bio); 232 + iov_iter_advance(iter, bio->bi_iter.bi_size); 233 + } 234 + 235 + bio->bi_private = bmd; 236 + if (map_data && map_data->null_mapped) 237 + bio_set_flag(bio, BIO_NULL_MAPPED); 238 + return bio; 239 + cleanup: 240 + if (!map_data) 241 + bio_free_pages(bio); 242 + bio_put(bio); 243 + out_bmd: 244 + kfree(bmd); 245 + return ERR_PTR(ret); 246 + } 247 + 248 + /** 249 + * bio_map_user_iov - map user iovec into bio 250 + * @q: the struct request_queue for the bio 251 + * @iter: iovec iterator 252 + * @gfp_mask: memory allocation flags 253 + * 254 + * Map the user space address into a bio suitable for io to a block 255 + * device. Returns an error pointer in case of error. 256 + */ 257 + static struct bio *bio_map_user_iov(struct request_queue *q, 258 + struct iov_iter *iter, gfp_t gfp_mask) 259 + { 260 + int j; 261 + struct bio *bio; 262 + int ret; 263 + 264 + if (!iov_iter_count(iter)) 265 + return ERR_PTR(-EINVAL); 266 + 267 + bio = bio_kmalloc(gfp_mask, iov_iter_npages(iter, BIO_MAX_PAGES)); 268 + if (!bio) 269 + return ERR_PTR(-ENOMEM); 270 + 271 + while (iov_iter_count(iter)) { 272 + struct page **pages; 273 + ssize_t bytes; 274 + size_t offs, added = 0; 275 + int npages; 276 + 277 + bytes = iov_iter_get_pages_alloc(iter, &pages, LONG_MAX, &offs); 278 + if (unlikely(bytes <= 0)) { 279 + ret = bytes ? bytes : -EFAULT; 280 + goto out_unmap; 281 + } 282 + 283 + npages = DIV_ROUND_UP(offs + bytes, PAGE_SIZE); 284 + 285 + if (unlikely(offs & queue_dma_alignment(q))) { 286 + ret = -EINVAL; 287 + j = 0; 288 + } else { 289 + for (j = 0; j < npages; j++) { 290 + struct page *page = pages[j]; 291 + unsigned int n = PAGE_SIZE - offs; 292 + bool same_page = false; 293 + 294 + if (n > bytes) 295 + n = bytes; 296 + 297 + if (!__bio_add_pc_page(q, bio, page, n, offs, 298 + &same_page)) { 299 + if (same_page) 300 + put_page(page); 301 + break; 302 + } 303 + 304 + added += n; 305 + bytes -= n; 306 + offs = 0; 307 + } 308 + iov_iter_advance(iter, added); 309 + } 310 + /* 311 + * release the pages we didn't map into the bio, if any 312 + */ 313 + while (j < npages) 314 + put_page(pages[j++]); 315 + kvfree(pages); 316 + /* couldn't stuff something into bio? */ 317 + if (bytes) 318 + break; 319 + } 320 + 321 + bio_set_flag(bio, BIO_USER_MAPPED); 322 + 323 + /* 324 + * subtle -- if bio_map_user_iov() ended up bouncing a bio, 325 + * it would normally disappear when its bi_end_io is run. 326 + * however, we need it for the unmap, so grab an extra 327 + * reference to it 328 + */ 329 + bio_get(bio); 330 + return bio; 331 + 332 + out_unmap: 333 + bio_release_pages(bio, false); 334 + bio_put(bio); 335 + return ERR_PTR(ret); 336 + } 337 + 338 + /** 339 + * bio_unmap_user - unmap a bio 340 + * @bio: the bio being unmapped 341 + * 342 + * Unmap a bio previously mapped by bio_map_user_iov(). Must be called from 343 + * process context. 344 + * 345 + * bio_unmap_user() may sleep. 346 + */ 347 + static void bio_unmap_user(struct bio *bio) 348 + { 349 + bio_release_pages(bio, bio_data_dir(bio) == READ); 350 + bio_put(bio); 351 + bio_put(bio); 352 + } 353 + 354 + static void bio_invalidate_vmalloc_pages(struct bio *bio) 355 + { 356 + #ifdef ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE 357 + if (bio->bi_private && !op_is_write(bio_op(bio))) { 358 + unsigned long i, len = 0; 359 + 360 + for (i = 0; i < bio->bi_vcnt; i++) 361 + len += bio->bi_io_vec[i].bv_len; 362 + invalidate_kernel_vmap_range(bio->bi_private, len); 363 + } 364 + #endif 365 + } 366 + 367 + static void bio_map_kern_endio(struct bio *bio) 368 + { 369 + bio_invalidate_vmalloc_pages(bio); 370 + bio_put(bio); 371 + } 372 + 373 + /** 374 + * bio_map_kern - map kernel address into bio 375 + * @q: the struct request_queue for the bio 376 + * @data: pointer to buffer to map 377 + * @len: length in bytes 378 + * @gfp_mask: allocation flags for bio allocation 379 + * 380 + * Map the kernel address into a bio suitable for io to a block 381 + * device. Returns an error pointer in case of error. 382 + */ 383 + static struct bio *bio_map_kern(struct request_queue *q, void *data, 384 + unsigned int len, gfp_t gfp_mask) 385 + { 386 + unsigned long kaddr = (unsigned long)data; 387 + unsigned long end = (kaddr + len + PAGE_SIZE - 1) >> PAGE_SHIFT; 388 + unsigned long start = kaddr >> PAGE_SHIFT; 389 + const int nr_pages = end - start; 390 + bool is_vmalloc = is_vmalloc_addr(data); 391 + struct page *page; 392 + int offset, i; 393 + struct bio *bio; 394 + 395 + bio = bio_kmalloc(gfp_mask, nr_pages); 396 + if (!bio) 397 + return ERR_PTR(-ENOMEM); 398 + 399 + if (is_vmalloc) { 400 + flush_kernel_vmap_range(data, len); 401 + bio->bi_private = data; 402 + } 403 + 404 + offset = offset_in_page(kaddr); 405 + for (i = 0; i < nr_pages; i++) { 406 + unsigned int bytes = PAGE_SIZE - offset; 407 + 408 + if (len <= 0) 409 + break; 410 + 411 + if (bytes > len) 412 + bytes = len; 413 + 414 + if (!is_vmalloc) 415 + page = virt_to_page(data); 416 + else 417 + page = vmalloc_to_page(data); 418 + if (bio_add_pc_page(q, bio, page, bytes, 419 + offset) < bytes) { 420 + /* we don't support partial mappings */ 421 + bio_put(bio); 422 + return ERR_PTR(-EINVAL); 423 + } 424 + 425 + data += bytes; 426 + len -= bytes; 427 + offset = 0; 428 + } 429 + 430 + bio->bi_end_io = bio_map_kern_endio; 431 + return bio; 432 + } 433 + 434 + static void bio_copy_kern_endio(struct bio *bio) 435 + { 436 + bio_free_pages(bio); 437 + bio_put(bio); 438 + } 439 + 440 + static void bio_copy_kern_endio_read(struct bio *bio) 441 + { 442 + char *p = bio->bi_private; 443 + struct bio_vec *bvec; 444 + struct bvec_iter_all iter_all; 445 + 446 + bio_for_each_segment_all(bvec, bio, iter_all) { 447 + memcpy(p, page_address(bvec->bv_page), bvec->bv_len); 448 + p += bvec->bv_len; 449 + } 450 + 451 + bio_copy_kern_endio(bio); 452 + } 453 + 454 + /** 455 + * bio_copy_kern - copy kernel address into bio 456 + * @q: the struct request_queue for the bio 457 + * @data: pointer to buffer to copy 458 + * @len: length in bytes 459 + * @gfp_mask: allocation flags for bio and page allocation 460 + * @reading: data direction is READ 461 + * 462 + * copy the kernel address into a bio suitable for io to a block 463 + * device. Returns an error pointer in case of error. 464 + */ 465 + static struct bio *bio_copy_kern(struct request_queue *q, void *data, 466 + unsigned int len, gfp_t gfp_mask, int reading) 467 + { 468 + unsigned long kaddr = (unsigned long)data; 469 + unsigned long end = (kaddr + len + PAGE_SIZE - 1) >> PAGE_SHIFT; 470 + unsigned long start = kaddr >> PAGE_SHIFT; 471 + struct bio *bio; 472 + void *p = data; 473 + int nr_pages = 0; 474 + 475 + /* 476 + * Overflow, abort 477 + */ 478 + if (end < start) 479 + return ERR_PTR(-EINVAL); 480 + 481 + nr_pages = end - start; 482 + bio = bio_kmalloc(gfp_mask, nr_pages); 483 + if (!bio) 484 + return ERR_PTR(-ENOMEM); 485 + 486 + while (len) { 487 + struct page *page; 488 + unsigned int bytes = PAGE_SIZE; 489 + 490 + if (bytes > len) 491 + bytes = len; 492 + 493 + page = alloc_page(q->bounce_gfp | gfp_mask); 494 + if (!page) 495 + goto cleanup; 496 + 497 + if (!reading) 498 + memcpy(page_address(page), p, bytes); 499 + 500 + if (bio_add_pc_page(q, bio, page, bytes, 0) < bytes) 501 + break; 502 + 503 + len -= bytes; 504 + p += bytes; 505 + } 506 + 507 + if (reading) { 508 + bio->bi_end_io = bio_copy_kern_endio_read; 509 + bio->bi_private = data; 510 + } else { 511 + bio->bi_end_io = bio_copy_kern_endio; 512 + } 513 + 514 + return bio; 515 + 516 + cleanup: 517 + bio_free_pages(bio); 518 + bio_put(bio); 519 + return ERR_PTR(-ENOMEM); 520 + } 521 + 14 522 /* 15 523 * Append a bio to a passthrough request. Only works if the bio can be merged 16 524 * into the request based on the driver constraints.
+38 -21
block/blk-mq.c
··· 1178 1178 1179 1179 #define BLK_MQ_RESOURCE_DELAY 3 /* ms units */ 1180 1180 1181 + static void blk_mq_handle_dev_resource(struct request *rq, 1182 + struct list_head *list) 1183 + { 1184 + struct request *next = 1185 + list_first_entry_or_null(list, struct request, queuelist); 1186 + 1187 + /* 1188 + * If an I/O scheduler has been configured and we got a driver tag for 1189 + * the next request already, free it. 1190 + */ 1191 + if (next) 1192 + blk_mq_put_driver_tag(next); 1193 + 1194 + list_add(&rq->queuelist, list); 1195 + __blk_mq_requeue_request(rq); 1196 + } 1197 + 1181 1198 /* 1182 1199 * Returns true if we did some work AND can potentially do more. 1183 1200 */ ··· 1262 1245 1263 1246 ret = q->mq_ops->queue_rq(hctx, &bd); 1264 1247 if (ret == BLK_STS_RESOURCE || ret == BLK_STS_DEV_RESOURCE) { 1265 - /* 1266 - * If an I/O scheduler has been configured and we got a 1267 - * driver tag for the next request already, free it 1268 - * again. 1269 - */ 1270 - if (!list_empty(list)) { 1271 - nxt = list_first_entry(list, struct request, queuelist); 1272 - blk_mq_put_driver_tag(nxt); 1273 - } 1274 - list_add(&rq->queuelist, list); 1275 - __blk_mq_requeue_request(rq); 1248 + blk_mq_handle_dev_resource(rq, list); 1276 1249 break; 1277 1250 } 1278 1251 ··· 2416 2409 init_waitqueue_func_entry(&hctx->dispatch_wait, blk_mq_dispatch_wake); 2417 2410 INIT_LIST_HEAD(&hctx->dispatch_wait.entry); 2418 2411 2419 - hctx->fq = blk_alloc_flush_queue(q, hctx->numa_node, set->cmd_size, 2420 - gfp); 2412 + hctx->fq = blk_alloc_flush_queue(hctx->numa_node, set->cmd_size, gfp); 2421 2413 if (!hctx->fq) 2422 2414 goto free_bitmap; 2423 2415 ··· 2724 2718 blk_mq_sysfs_deinit(q); 2725 2719 } 2726 2720 2727 - struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *set) 2721 + struct request_queue *blk_mq_init_queue_data(struct blk_mq_tag_set *set, 2722 + void *queuedata) 2728 2723 { 2729 2724 struct request_queue *uninit_q, *q; 2730 2725 2731 - uninit_q = blk_alloc_queue_node(GFP_KERNEL, set->numa_node); 2726 + uninit_q = __blk_alloc_queue(set->numa_node); 2732 2727 if (!uninit_q) 2733 2728 return ERR_PTR(-ENOMEM); 2729 + uninit_q->queuedata = queuedata; 2734 2730 2735 2731 /* 2736 2732 * Initialize the queue without an elevator. device_add_disk() will do ··· 2743 2735 blk_cleanup_queue(uninit_q); 2744 2736 2745 2737 return q; 2738 + } 2739 + EXPORT_SYMBOL_GPL(blk_mq_init_queue_data); 2740 + 2741 + struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *set) 2742 + { 2743 + return blk_mq_init_queue_data(set, NULL); 2746 2744 } 2747 2745 EXPORT_SYMBOL(blk_mq_init_queue); 2748 2746 ··· 2838 2824 memcpy(new_hctxs, hctxs, q->nr_hw_queues * 2839 2825 sizeof(*hctxs)); 2840 2826 q->queue_hw_ctx = new_hctxs; 2841 - q->nr_hw_queues = set->nr_hw_queues; 2842 2827 kfree(hctxs); 2843 2828 hctxs = new_hctxs; 2844 2829 } ··· 2939 2926 INIT_LIST_HEAD(&q->requeue_list); 2940 2927 spin_lock_init(&q->requeue_lock); 2941 2928 2942 - blk_queue_make_request(q, blk_mq_make_request); 2943 - 2944 - /* 2945 - * Do this after blk_queue_make_request() overrides it... 2946 - */ 2929 + q->make_request_fn = blk_mq_make_request; 2947 2930 q->nr_requests = set->queue_depth; 2948 2931 2949 2932 /* ··· 3032 3023 3033 3024 static int blk_mq_update_queue_map(struct blk_mq_tag_set *set) 3034 3025 { 3026 + /* 3027 + * blk_mq_map_queues() and multiple .map_queues() implementations 3028 + * expect that set->map[HCTX_TYPE_DEFAULT].nr_queues is set to the 3029 + * number of hardware queues. 3030 + */ 3031 + if (set->nr_maps == 1) 3032 + set->map[HCTX_TYPE_DEFAULT].nr_queues = set->nr_hw_queues; 3033 + 3035 3034 if (set->ops->map_queues && !is_kdump_kernel()) { 3036 3035 int i; 3037 3036
-36
block/blk-settings.c
··· 87 87 EXPORT_SYMBOL(blk_set_stacking_limits); 88 88 89 89 /** 90 - * blk_queue_make_request - define an alternate make_request function for a device 91 - * @q: the request queue for the device to be affected 92 - * @mfn: the alternate make_request function 93 - * 94 - * Description: 95 - * The normal way for &struct bios to be passed to a device 96 - * driver is for them to be collected into requests on a request 97 - * queue, and then to allow the device driver to select requests 98 - * off that queue when it is ready. This works well for many block 99 - * devices. However some block devices (typically virtual devices 100 - * such as md or lvm) do not benefit from the processing on the 101 - * request queue, and are served best by having the requests passed 102 - * directly to them. This can be achieved by providing a function 103 - * to blk_queue_make_request(). 104 - * 105 - * Caveat: 106 - * The driver that does this *must* be able to deal appropriately 107 - * with buffers in "highmemory". This can be accomplished by either calling 108 - * kmap_atomic() to get a temporary kernel mapping, or by calling 109 - * blk_queue_bounce() to create a buffer in normal memory. 110 - **/ 111 - void blk_queue_make_request(struct request_queue *q, make_request_fn *mfn) 112 - { 113 - /* 114 - * set defaults 115 - */ 116 - q->nr_requests = BLKDEV_MAX_RQ; 117 - 118 - q->make_request_fn = mfn; 119 - blk_queue_dma_alignment(q, 511); 120 - 121 - blk_set_default_limits(&q->limits); 122 - } 123 - EXPORT_SYMBOL(blk_queue_make_request); 124 - 125 - /** 126 90 * blk_queue_bounce_limit - set bounce buffer limit for queue 127 91 * @q: the request queue for the device 128 92 * @max_addr: the maximum address the device can handle
+1 -1
block/blk-zoned.c
··· 173 173 if (!op_is_zone_mgmt(op)) 174 174 return -EOPNOTSUPP; 175 175 176 - if (!nr_sectors || end_sector > capacity) 176 + if (end_sector <= sector || end_sector > capacity) 177 177 /* Out of range */ 178 178 return -EINVAL; 179 179
+136 -2
block/blk.h
··· 4 4 5 5 #include <linux/idr.h> 6 6 #include <linux/blk-mq.h> 7 + #include <linux/part_stat.h> 7 8 #include <xen/xen.h> 8 9 #include "blk-mq.h" 9 10 #include "blk-mq-sched.h" ··· 56 55 return hctx->fq->flush_rq == req; 57 56 } 58 57 59 - struct blk_flush_queue *blk_alloc_flush_queue(struct request_queue *q, 60 - int node, int cmd_size, gfp_t flags); 58 + struct blk_flush_queue *blk_alloc_flush_queue(int node, int cmd_size, 59 + gfp_t flags); 61 60 void blk_free_flush_queue(struct blk_flush_queue *q); 62 61 63 62 void blk_freeze_queue(struct request_queue *q); ··· 150 149 return bvec_gap_to_prev(req->q, &bip->bip_vec[bip->bip_vcnt - 1], 151 150 bip_next->bip_vec[0].bv_offset); 152 151 } 152 + 153 + void blk_integrity_add(struct gendisk *); 154 + void blk_integrity_del(struct gendisk *); 153 155 #else /* CONFIG_BLK_DEV_INTEGRITY */ 154 156 static inline bool integrity_req_gap_back_merge(struct request *req, 155 157 struct bio *next) ··· 173 169 return true; 174 170 } 175 171 static inline void bio_integrity_free(struct bio *bio) 172 + { 173 + } 174 + static inline void blk_integrity_add(struct gendisk *disk) 175 + { 176 + } 177 + static inline void blk_integrity_del(struct gendisk *disk) 176 178 { 177 179 } 178 180 #endif /* CONFIG_BLK_DEV_INTEGRITY */ ··· 223 213 } 224 214 225 215 struct hd_struct *__disk_get_part(struct gendisk *disk, int partno); 216 + 217 + ssize_t part_size_show(struct device *dev, struct device_attribute *attr, 218 + char *buf); 219 + ssize_t part_stat_show(struct device *dev, struct device_attribute *attr, 220 + char *buf); 221 + ssize_t part_inflight_show(struct device *dev, struct device_attribute *attr, 222 + char *buf); 223 + ssize_t part_fail_show(struct device *dev, struct device_attribute *attr, 224 + char *buf); 225 + ssize_t part_fail_store(struct device *dev, struct device_attribute *attr, 226 + const char *buf, size_t count); 226 227 227 228 #ifdef CONFIG_FAIL_IO_TIMEOUT 228 229 int blk_should_fake_timeout(struct request_queue *); ··· 374 353 #else 375 354 static inline void blk_queue_free_zone_bitmaps(struct request_queue *q) {} 376 355 #endif 356 + 357 + void part_dec_in_flight(struct request_queue *q, struct hd_struct *part, 358 + int rw); 359 + void part_inc_in_flight(struct request_queue *q, struct hd_struct *part, 360 + int rw); 361 + void update_io_ticks(struct hd_struct *part, unsigned long now, bool end); 362 + struct hd_struct *disk_map_sector_rcu(struct gendisk *disk, sector_t sector); 363 + 364 + int blk_alloc_devt(struct hd_struct *part, dev_t *devt); 365 + void blk_free_devt(dev_t devt); 366 + void blk_invalidate_devt(dev_t devt); 367 + char *disk_name(struct gendisk *hd, int partno, char *buf); 368 + #define ADDPART_FLAG_NONE 0 369 + #define ADDPART_FLAG_RAID 1 370 + #define ADDPART_FLAG_WHOLEDISK 2 371 + struct hd_struct *__must_check add_partition(struct gendisk *disk, int partno, 372 + sector_t start, sector_t len, int flags, 373 + struct partition_meta_info *info); 374 + void __delete_partition(struct percpu_ref *ref); 375 + void delete_partition(struct gendisk *disk, int partno); 376 + int disk_expand_part_tbl(struct gendisk *disk, int target); 377 + 378 + static inline int hd_ref_init(struct hd_struct *part) 379 + { 380 + if (percpu_ref_init(&part->ref, __delete_partition, 0, 381 + GFP_KERNEL)) 382 + return -ENOMEM; 383 + return 0; 384 + } 385 + 386 + static inline void hd_struct_get(struct hd_struct *part) 387 + { 388 + percpu_ref_get(&part->ref); 389 + } 390 + 391 + static inline int hd_struct_try_get(struct hd_struct *part) 392 + { 393 + return percpu_ref_tryget_live(&part->ref); 394 + } 395 + 396 + static inline void hd_struct_put(struct hd_struct *part) 397 + { 398 + percpu_ref_put(&part->ref); 399 + } 400 + 401 + static inline void hd_struct_kill(struct hd_struct *part) 402 + { 403 + percpu_ref_kill(&part->ref); 404 + } 405 + 406 + static inline void hd_free_part(struct hd_struct *part) 407 + { 408 + free_part_stats(part); 409 + kfree(part->info); 410 + percpu_ref_exit(&part->ref); 411 + } 412 + 413 + /* 414 + * Any access of part->nr_sects which is not protected by partition 415 + * bd_mutex or gendisk bdev bd_mutex, should be done using this 416 + * accessor function. 417 + * 418 + * Code written along the lines of i_size_read() and i_size_write(). 419 + * CONFIG_PREEMPTION case optimizes the case of UP kernel with preemption 420 + * on. 421 + */ 422 + static inline sector_t part_nr_sects_read(struct hd_struct *part) 423 + { 424 + #if BITS_PER_LONG==32 && defined(CONFIG_SMP) 425 + sector_t nr_sects; 426 + unsigned seq; 427 + do { 428 + seq = read_seqcount_begin(&part->nr_sects_seq); 429 + nr_sects = part->nr_sects; 430 + } while (read_seqcount_retry(&part->nr_sects_seq, seq)); 431 + return nr_sects; 432 + #elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPTION) 433 + sector_t nr_sects; 434 + 435 + preempt_disable(); 436 + nr_sects = part->nr_sects; 437 + preempt_enable(); 438 + return nr_sects; 439 + #else 440 + return part->nr_sects; 441 + #endif 442 + } 443 + 444 + /* 445 + * Should be called with mutex lock held (typically bd_mutex) of partition 446 + * to provide mutual exlusion among writers otherwise seqcount might be 447 + * left in wrong state leaving the readers spinning infinitely. 448 + */ 449 + static inline void part_nr_sects_write(struct hd_struct *part, sector_t size) 450 + { 451 + #if BITS_PER_LONG==32 && defined(CONFIG_SMP) 452 + write_seqcount_begin(&part->nr_sects_seq); 453 + part->nr_sects = size; 454 + write_seqcount_end(&part->nr_sects_seq); 455 + #elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPTION) 456 + preempt_disable(); 457 + part->nr_sects = size; 458 + preempt_enable(); 459 + #else 460 + part->nr_sects = size; 461 + #endif 462 + } 463 + 464 + struct request_queue *__blk_alloc_queue(int node_id); 465 + 466 + int __bio_add_pc_page(struct request_queue *q, struct bio *bio, 467 + struct page *page, unsigned int len, unsigned int offset, 468 + bool *same_page); 377 469 378 470 #endif /* BLK_INTERNAL_H */
+192 -27
block/genhd.c
··· 4 4 */ 5 5 6 6 #include <linux/module.h> 7 + #include <linux/ctype.h> 7 8 #include <linux/fs.h> 8 9 #include <linux/genhd.h> 9 10 #include <linux/kdev_t.h> ··· 27 26 #include "blk.h" 28 27 29 28 static DEFINE_MUTEX(block_class_lock); 30 - struct kobject *block_depr; 29 + static struct kobject *block_depr; 31 30 32 31 /* for extended dynamic devt allocation, currently only one major is used */ 33 32 #define NR_EXT_DEVT (1 << MINORBITS) ··· 46 45 static void disk_add_events(struct gendisk *disk); 47 46 static void disk_del_events(struct gendisk *disk); 48 47 static void disk_release_events(struct gendisk *disk); 48 + 49 + /* 50 + * Set disk capacity and notify if the size is not currently 51 + * zero and will not be set to zero 52 + */ 53 + void set_capacity_revalidate_and_notify(struct gendisk *disk, sector_t size, 54 + bool revalidate) 55 + { 56 + sector_t capacity = get_capacity(disk); 57 + 58 + set_capacity(disk, size); 59 + 60 + if (revalidate) 61 + revalidate_disk(disk); 62 + 63 + if (capacity != size && capacity != 0 && size != 0) { 64 + char *envp[] = { "RESIZE=1", NULL }; 65 + 66 + kobject_uevent_env(&disk_to_dev(disk)->kobj, KOBJ_CHANGE, envp); 67 + } 68 + } 69 + 70 + EXPORT_SYMBOL_GPL(set_capacity_revalidate_and_notify); 71 + 72 + /* 73 + * Format the device name of the indicated disk into the supplied buffer and 74 + * return a pointer to that same buffer for convenience. 75 + */ 76 + char *disk_name(struct gendisk *hd, int partno, char *buf) 77 + { 78 + if (!partno) 79 + snprintf(buf, BDEVNAME_SIZE, "%s", hd->disk_name); 80 + else if (isdigit(hd->disk_name[strlen(hd->disk_name)-1])) 81 + snprintf(buf, BDEVNAME_SIZE, "%sp%d", hd->disk_name, partno); 82 + else 83 + snprintf(buf, BDEVNAME_SIZE, "%s%d", hd->disk_name, partno); 84 + 85 + return buf; 86 + } 87 + 88 + const char *bdevname(struct block_device *bdev, char *buf) 89 + { 90 + return disk_name(bdev->bd_disk, bdev->bd_part->partno, buf); 91 + } 92 + EXPORT_SYMBOL(bdevname); 93 + 94 + #ifdef CONFIG_SMP 95 + static void part_stat_read_all(struct hd_struct *part, struct disk_stats *stat) 96 + { 97 + int cpu; 98 + 99 + memset(stat, 0, sizeof(struct disk_stats)); 100 + for_each_possible_cpu(cpu) { 101 + struct disk_stats *ptr = per_cpu_ptr(part->dkstats, cpu); 102 + int group; 103 + 104 + for (group = 0; group < NR_STAT_GROUPS; group++) { 105 + stat->nsecs[group] += ptr->nsecs[group]; 106 + stat->sectors[group] += ptr->sectors[group]; 107 + stat->ios[group] += ptr->ios[group]; 108 + stat->merges[group] += ptr->merges[group]; 109 + } 110 + 111 + stat->io_ticks += ptr->io_ticks; 112 + } 113 + } 114 + #else /* CONFIG_SMP */ 115 + static void part_stat_read_all(struct hd_struct *part, struct disk_stats *stat) 116 + { 117 + memcpy(stat, &part->dkstats, sizeof(struct disk_stats)); 118 + } 119 + #endif /* CONFIG_SMP */ 49 120 50 121 void part_inc_in_flight(struct request_queue *q, struct hd_struct *part, int rw) 51 122 { ··· 139 66 part_stat_local_dec(&part_to_disk(part)->part0, in_flight[rw]); 140 67 } 141 68 142 - unsigned int part_in_flight(struct request_queue *q, struct hd_struct *part) 69 + static unsigned int part_in_flight(struct request_queue *q, 70 + struct hd_struct *part) 143 71 { 144 72 int cpu; 145 73 unsigned int inflight; ··· 160 86 return inflight; 161 87 } 162 88 163 - void part_in_flight_rw(struct request_queue *q, struct hd_struct *part, 164 - unsigned int inflight[2]) 89 + static void part_in_flight_rw(struct request_queue *q, struct hd_struct *part, 90 + unsigned int inflight[2]) 165 91 { 166 92 int cpu; 167 93 ··· 217 143 218 144 return part; 219 145 } 220 - EXPORT_SYMBOL_GPL(disk_get_part); 221 146 222 147 /** 223 148 * disk_part_iter_init - initialize partition iterator ··· 372 299 } 373 300 return &disk->part0; 374 301 } 375 - EXPORT_SYMBOL_GPL(disk_map_sector_rcu); 376 302 377 303 /** 378 304 * disk_has_partitions ··· 1016 944 } 1017 945 return disk; 1018 946 } 1019 - EXPORT_SYMBOL(get_gendisk); 1020 947 1021 948 /** 1022 949 * bdget_disk - do bdget() by gendisk and partition number ··· 1261 1190 return sprintf(buf, "%d\n", get_disk_ro(disk) ? 1 : 0); 1262 1191 } 1263 1192 1193 + ssize_t part_size_show(struct device *dev, 1194 + struct device_attribute *attr, char *buf) 1195 + { 1196 + struct hd_struct *p = dev_to_part(dev); 1197 + 1198 + return sprintf(buf, "%llu\n", 1199 + (unsigned long long)part_nr_sects_read(p)); 1200 + } 1201 + 1202 + ssize_t part_stat_show(struct device *dev, 1203 + struct device_attribute *attr, char *buf) 1204 + { 1205 + struct hd_struct *p = dev_to_part(dev); 1206 + struct request_queue *q = part_to_disk(p)->queue; 1207 + struct disk_stats stat; 1208 + unsigned int inflight; 1209 + 1210 + part_stat_read_all(p, &stat); 1211 + inflight = part_in_flight(q, p); 1212 + 1213 + return sprintf(buf, 1214 + "%8lu %8lu %8llu %8u " 1215 + "%8lu %8lu %8llu %8u " 1216 + "%8u %8u %8u " 1217 + "%8lu %8lu %8llu %8u " 1218 + "%8lu %8u" 1219 + "\n", 1220 + stat.ios[STAT_READ], 1221 + stat.merges[STAT_READ], 1222 + (unsigned long long)stat.sectors[STAT_READ], 1223 + (unsigned int)div_u64(stat.nsecs[STAT_READ], NSEC_PER_MSEC), 1224 + stat.ios[STAT_WRITE], 1225 + stat.merges[STAT_WRITE], 1226 + (unsigned long long)stat.sectors[STAT_WRITE], 1227 + (unsigned int)div_u64(stat.nsecs[STAT_WRITE], NSEC_PER_MSEC), 1228 + inflight, 1229 + jiffies_to_msecs(stat.io_ticks), 1230 + (unsigned int)div_u64(stat.nsecs[STAT_READ] + 1231 + stat.nsecs[STAT_WRITE] + 1232 + stat.nsecs[STAT_DISCARD] + 1233 + stat.nsecs[STAT_FLUSH], 1234 + NSEC_PER_MSEC), 1235 + stat.ios[STAT_DISCARD], 1236 + stat.merges[STAT_DISCARD], 1237 + (unsigned long long)stat.sectors[STAT_DISCARD], 1238 + (unsigned int)div_u64(stat.nsecs[STAT_DISCARD], NSEC_PER_MSEC), 1239 + stat.ios[STAT_FLUSH], 1240 + (unsigned int)div_u64(stat.nsecs[STAT_FLUSH], NSEC_PER_MSEC)); 1241 + } 1242 + 1243 + ssize_t part_inflight_show(struct device *dev, struct device_attribute *attr, 1244 + char *buf) 1245 + { 1246 + struct hd_struct *p = dev_to_part(dev); 1247 + struct request_queue *q = part_to_disk(p)->queue; 1248 + unsigned int inflight[2]; 1249 + 1250 + part_in_flight_rw(q, p, inflight); 1251 + return sprintf(buf, "%8u %8u\n", inflight[0], inflight[1]); 1252 + } 1253 + 1264 1254 static ssize_t disk_capability_show(struct device *dev, 1265 1255 struct device_attribute *attr, char *buf) 1266 1256 { ··· 1360 1228 static DEVICE_ATTR(stat, 0444, part_stat_show, NULL); 1361 1229 static DEVICE_ATTR(inflight, 0444, part_inflight_show, NULL); 1362 1230 static DEVICE_ATTR(badblocks, 0644, disk_badblocks_show, disk_badblocks_store); 1231 + 1363 1232 #ifdef CONFIG_FAIL_MAKE_REQUEST 1233 + ssize_t part_fail_show(struct device *dev, 1234 + struct device_attribute *attr, char *buf) 1235 + { 1236 + struct hd_struct *p = dev_to_part(dev); 1237 + 1238 + return sprintf(buf, "%d\n", p->make_it_fail); 1239 + } 1240 + 1241 + ssize_t part_fail_store(struct device *dev, 1242 + struct device_attribute *attr, 1243 + const char *buf, size_t count) 1244 + { 1245 + struct hd_struct *p = dev_to_part(dev); 1246 + int i; 1247 + 1248 + if (count > 0 && sscanf(buf, "%d", &i) > 0) 1249 + p->make_it_fail = (i == 0) ? 0 : 1; 1250 + 1251 + return count; 1252 + } 1253 + 1364 1254 static struct device_attribute dev_attr_fail = 1365 1255 __ATTR(make-it-fail, 0644, part_fail_show, part_fail_store); 1366 - #endif 1256 + #endif /* CONFIG_FAIL_MAKE_REQUEST */ 1257 + 1367 1258 #ifdef CONFIG_FAIL_IO_TIMEOUT 1368 1259 static struct device_attribute dev_attr_fail_timeout = 1369 1260 __ATTR(io-timeout-fail, 0644, part_timeout_show, part_timeout_store); ··· 1533 1378 { 1534 1379 struct gendisk *disk = dev_to_disk(dev); 1535 1380 1536 - if (disk->devnode) 1537 - return disk->devnode(disk, mode); 1381 + if (disk->fops->devnode) 1382 + return disk->fops->devnode(disk, mode); 1538 1383 return NULL; 1539 1384 } 1540 1385 ··· 1560 1405 struct hd_struct *hd; 1561 1406 char buf[BDEVNAME_SIZE]; 1562 1407 unsigned int inflight; 1408 + struct disk_stats stat; 1563 1409 1564 1410 /* 1565 1411 if (&disk_to_dev(gp)->kobj.entry == block_class.devices.next) ··· 1572 1416 1573 1417 disk_part_iter_init(&piter, gp, DISK_PITER_INCL_EMPTY_PART0); 1574 1418 while ((hd = disk_part_iter_next(&piter))) { 1419 + part_stat_read_all(hd, &stat); 1575 1420 inflight = part_in_flight(gp->queue, hd); 1421 + 1576 1422 seq_printf(seqf, "%4d %7d %s " 1577 1423 "%lu %lu %lu %u " 1578 1424 "%lu %lu %lu %u " ··· 1584 1426 "\n", 1585 1427 MAJOR(part_devt(hd)), MINOR(part_devt(hd)), 1586 1428 disk_name(gp, hd->partno, buf), 1587 - part_stat_read(hd, ios[STAT_READ]), 1588 - part_stat_read(hd, merges[STAT_READ]), 1589 - part_stat_read(hd, sectors[STAT_READ]), 1590 - (unsigned int)part_stat_read_msecs(hd, STAT_READ), 1591 - part_stat_read(hd, ios[STAT_WRITE]), 1592 - part_stat_read(hd, merges[STAT_WRITE]), 1593 - part_stat_read(hd, sectors[STAT_WRITE]), 1594 - (unsigned int)part_stat_read_msecs(hd, STAT_WRITE), 1429 + stat.ios[STAT_READ], 1430 + stat.merges[STAT_READ], 1431 + stat.sectors[STAT_READ], 1432 + (unsigned int)div_u64(stat.nsecs[STAT_READ], 1433 + NSEC_PER_MSEC), 1434 + stat.ios[STAT_WRITE], 1435 + stat.merges[STAT_WRITE], 1436 + stat.sectors[STAT_WRITE], 1437 + (unsigned int)div_u64(stat.nsecs[STAT_WRITE], 1438 + NSEC_PER_MSEC), 1595 1439 inflight, 1596 - jiffies_to_msecs(part_stat_read(hd, io_ticks)), 1597 - jiffies_to_msecs(part_stat_read(hd, time_in_queue)), 1598 - part_stat_read(hd, ios[STAT_DISCARD]), 1599 - part_stat_read(hd, merges[STAT_DISCARD]), 1600 - part_stat_read(hd, sectors[STAT_DISCARD]), 1601 - (unsigned int)part_stat_read_msecs(hd, STAT_DISCARD), 1602 - part_stat_read(hd, ios[STAT_FLUSH]), 1603 - (unsigned int)part_stat_read_msecs(hd, STAT_FLUSH) 1440 + jiffies_to_msecs(stat.io_ticks), 1441 + (unsigned int)div_u64(stat.nsecs[STAT_READ] + 1442 + stat.nsecs[STAT_WRITE] + 1443 + stat.nsecs[STAT_DISCARD] + 1444 + stat.nsecs[STAT_FLUSH], 1445 + NSEC_PER_MSEC), 1446 + stat.ios[STAT_DISCARD], 1447 + stat.merges[STAT_DISCARD], 1448 + stat.sectors[STAT_DISCARD], 1449 + (unsigned int)div_u64(stat.nsecs[STAT_DISCARD], 1450 + NSEC_PER_MSEC), 1451 + stat.ios[STAT_FLUSH], 1452 + (unsigned int)div_u64(stat.nsecs[STAT_FLUSH], 1453 + NSEC_PER_MSEC) 1604 1454 ); 1605 1455 } 1606 1456 disk_part_iter_exit(&piter); ··· 1665 1499 class_dev_iter_exit(&iter); 1666 1500 return devt; 1667 1501 } 1668 - EXPORT_SYMBOL(blk_lookup_devt); 1669 1502 1670 1503 struct gendisk *__alloc_disk_node(int minors, int node_id) 1671 1504 {
+1
block/ioctl.c
··· 11 11 #include <linux/blktrace_api.h> 12 12 #include <linux/pr.h> 13 13 #include <linux/uaccess.h> 14 + #include "blk.h" 14 15 15 16 static int blkpg_do_ioctl(struct block_device *bdev, 16 17 struct blkpg_partition __user *upart, int op)
+1
block/opal_proto.h
··· 36 36 37 37 #define DTAERROR_NO_METHOD_STATUS 0x89 38 38 #define GENERIC_HOST_SESSION_NUM 0x41 39 + #define FIRST_TPER_SESSION_NUM 4096 39 40 40 41 #define TPER_SYNC_SUPPORTED 0x01 41 42 #define MBR_ENABLED_MASK 0x10
+178 -143
block/partition-generic.c block/partitions/core.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 /* 3 - * Code extracted from drivers/block/genhd.c 4 - * Copyright (C) 1991-1998 Linus Torvalds 5 - * Re-organised Feb 1998 Russell King 6 - * 7 - * We now have independent partition support from the 8 - * block drivers, which allows all the partition code to 9 - * be grouped in one location, and it to be mostly self 10 - * contained. 3 + * Copyright (C) 1991-1998 Linus Torvalds 4 + * Re-organised Feb 1998 Russell King 11 5 */ 12 - 13 - #include <linux/init.h> 14 - #include <linux/module.h> 15 6 #include <linux/fs.h> 16 7 #include <linux/slab.h> 17 - #include <linux/kmod.h> 18 8 #include <linux/ctype.h> 19 9 #include <linux/genhd.h> 10 + #include <linux/vmalloc.h> 20 11 #include <linux/blktrace_api.h> 12 + #include <linux/raid/detect.h> 13 + #include "check.h" 21 14 22 - #include "partitions/check.h" 23 - 24 - #ifdef CONFIG_BLK_DEV_MD 25 - extern void md_autodetect_dev(dev_t dev); 15 + static int (*check_part[])(struct parsed_partitions *) = { 16 + /* 17 + * Probe partition formats with tables at disk address 0 18 + * that also have an ADFS boot block at 0xdc0. 19 + */ 20 + #ifdef CONFIG_ACORN_PARTITION_ICS 21 + adfspart_check_ICS, 26 22 #endif 27 - 28 - /* 29 - * disk_name() is used by partition check code and the genhd driver. 30 - * It formats the devicename of the indicated disk into 31 - * the supplied buffer (of size at least 32), and returns 32 - * a pointer to that same buffer (for convenience). 33 - */ 23 + #ifdef CONFIG_ACORN_PARTITION_POWERTEC 24 + adfspart_check_POWERTEC, 25 + #endif 26 + #ifdef CONFIG_ACORN_PARTITION_EESOX 27 + adfspart_check_EESOX, 28 + #endif 34 29 35 - char *disk_name(struct gendisk *hd, int partno, char *buf) 30 + /* 31 + * Now move on to formats that only have partition info at 32 + * disk address 0xdc0. Since these may also have stale 33 + * PC/BIOS partition tables, they need to come before 34 + * the msdos entry. 35 + */ 36 + #ifdef CONFIG_ACORN_PARTITION_CUMANA 37 + adfspart_check_CUMANA, 38 + #endif 39 + #ifdef CONFIG_ACORN_PARTITION_ADFS 40 + adfspart_check_ADFS, 41 + #endif 42 + 43 + #ifdef CONFIG_CMDLINE_PARTITION 44 + cmdline_partition, 45 + #endif 46 + #ifdef CONFIG_EFI_PARTITION 47 + efi_partition, /* this must come before msdos */ 48 + #endif 49 + #ifdef CONFIG_SGI_PARTITION 50 + sgi_partition, 51 + #endif 52 + #ifdef CONFIG_LDM_PARTITION 53 + ldm_partition, /* this must come before msdos */ 54 + #endif 55 + #ifdef CONFIG_MSDOS_PARTITION 56 + msdos_partition, 57 + #endif 58 + #ifdef CONFIG_OSF_PARTITION 59 + osf_partition, 60 + #endif 61 + #ifdef CONFIG_SUN_PARTITION 62 + sun_partition, 63 + #endif 64 + #ifdef CONFIG_AMIGA_PARTITION 65 + amiga_partition, 66 + #endif 67 + #ifdef CONFIG_ATARI_PARTITION 68 + atari_partition, 69 + #endif 70 + #ifdef CONFIG_MAC_PARTITION 71 + mac_partition, 72 + #endif 73 + #ifdef CONFIG_ULTRIX_PARTITION 74 + ultrix_partition, 75 + #endif 76 + #ifdef CONFIG_IBM_PARTITION 77 + ibm_partition, 78 + #endif 79 + #ifdef CONFIG_KARMA_PARTITION 80 + karma_partition, 81 + #endif 82 + #ifdef CONFIG_SYSV68_PARTITION 83 + sysv68_partition, 84 + #endif 85 + NULL 86 + }; 87 + 88 + static struct parsed_partitions *allocate_partitions(struct gendisk *hd) 36 89 { 37 - if (!partno) 38 - snprintf(buf, BDEVNAME_SIZE, "%s", hd->disk_name); 39 - else if (isdigit(hd->disk_name[strlen(hd->disk_name)-1])) 40 - snprintf(buf, BDEVNAME_SIZE, "%sp%d", hd->disk_name, partno); 41 - else 42 - snprintf(buf, BDEVNAME_SIZE, "%s%d", hd->disk_name, partno); 90 + struct parsed_partitions *state; 91 + int nr; 43 92 44 - return buf; 93 + state = kzalloc(sizeof(*state), GFP_KERNEL); 94 + if (!state) 95 + return NULL; 96 + 97 + nr = disk_max_parts(hd); 98 + state->parts = vzalloc(array_size(nr, sizeof(state->parts[0]))); 99 + if (!state->parts) { 100 + kfree(state); 101 + return NULL; 102 + } 103 + 104 + state->limit = nr; 105 + 106 + return state; 45 107 } 46 108 47 - const char *bdevname(struct block_device *bdev, char *buf) 109 + static void free_partitions(struct parsed_partitions *state) 48 110 { 49 - return disk_name(bdev->bd_disk, bdev->bd_part->partno, buf); 111 + vfree(state->parts); 112 + kfree(state); 50 113 } 51 114 52 - EXPORT_SYMBOL(bdevname); 53 - 54 - const char *bio_devname(struct bio *bio, char *buf) 115 + static struct parsed_partitions *check_partition(struct gendisk *hd, 116 + struct block_device *bdev) 55 117 { 56 - return disk_name(bio->bi_disk, bio->bi_partno, buf); 57 - } 58 - EXPORT_SYMBOL(bio_devname); 118 + struct parsed_partitions *state; 119 + int i, res, err; 59 120 60 - /* 61 - * There's very little reason to use this, you should really 62 - * have a struct block_device just about everywhere and use 63 - * bdevname() instead. 64 - */ 65 - const char *__bdevname(dev_t dev, char *buffer) 66 - { 67 - scnprintf(buffer, BDEVNAME_SIZE, "unknown-block(%u,%u)", 68 - MAJOR(dev), MINOR(dev)); 69 - return buffer; 70 - } 121 + state = allocate_partitions(hd); 122 + if (!state) 123 + return NULL; 124 + state->pp_buf = (char *)__get_free_page(GFP_KERNEL); 125 + if (!state->pp_buf) { 126 + free_partitions(state); 127 + return NULL; 128 + } 129 + state->pp_buf[0] = '\0'; 71 130 72 - EXPORT_SYMBOL(__bdevname); 131 + state->bdev = bdev; 132 + disk_name(hd, 0, state->name); 133 + snprintf(state->pp_buf, PAGE_SIZE, " %s:", state->name); 134 + if (isdigit(state->name[strlen(state->name)-1])) 135 + sprintf(state->name, "p"); 136 + 137 + i = res = err = 0; 138 + while (!res && check_part[i]) { 139 + memset(state->parts, 0, state->limit * sizeof(state->parts[0])); 140 + res = check_part[i++](state); 141 + if (res < 0) { 142 + /* 143 + * We have hit an I/O error which we don't report now. 144 + * But record it, and let the others do their job. 145 + */ 146 + err = res; 147 + res = 0; 148 + } 149 + 150 + } 151 + if (res > 0) { 152 + printk(KERN_INFO "%s", state->pp_buf); 153 + 154 + free_page((unsigned long)state->pp_buf); 155 + return state; 156 + } 157 + if (state->access_beyond_eod) 158 + err = -ENOSPC; 159 + /* 160 + * The partition is unrecognized. So report I/O errors if there were any 161 + */ 162 + if (err) 163 + res = err; 164 + if (res) { 165 + strlcat(state->pp_buf, 166 + " unable to read partition table\n", PAGE_SIZE); 167 + printk(KERN_INFO "%s", state->pp_buf); 168 + } 169 + 170 + free_page((unsigned long)state->pp_buf); 171 + free_partitions(state); 172 + return ERR_PTR(res); 173 + } 73 174 74 175 static ssize_t part_partition_show(struct device *dev, 75 176 struct device_attribute *attr, char *buf) ··· 186 85 struct hd_struct *p = dev_to_part(dev); 187 86 188 87 return sprintf(buf, "%llu\n",(unsigned long long)p->start_sect); 189 - } 190 - 191 - ssize_t part_size_show(struct device *dev, 192 - struct device_attribute *attr, char *buf) 193 - { 194 - struct hd_struct *p = dev_to_part(dev); 195 - return sprintf(buf, "%llu\n",(unsigned long long)part_nr_sects_read(p)); 196 88 } 197 89 198 90 static ssize_t part_ro_show(struct device *dev, ··· 208 114 struct hd_struct *p = dev_to_part(dev); 209 115 return sprintf(buf, "%u\n", p->discard_alignment); 210 116 } 211 - 212 - ssize_t part_stat_show(struct device *dev, 213 - struct device_attribute *attr, char *buf) 214 - { 215 - struct hd_struct *p = dev_to_part(dev); 216 - struct request_queue *q = part_to_disk(p)->queue; 217 - unsigned int inflight; 218 - 219 - inflight = part_in_flight(q, p); 220 - return sprintf(buf, 221 - "%8lu %8lu %8llu %8u " 222 - "%8lu %8lu %8llu %8u " 223 - "%8u %8u %8u " 224 - "%8lu %8lu %8llu %8u " 225 - "%8lu %8u" 226 - "\n", 227 - part_stat_read(p, ios[STAT_READ]), 228 - part_stat_read(p, merges[STAT_READ]), 229 - (unsigned long long)part_stat_read(p, sectors[STAT_READ]), 230 - (unsigned int)part_stat_read_msecs(p, STAT_READ), 231 - part_stat_read(p, ios[STAT_WRITE]), 232 - part_stat_read(p, merges[STAT_WRITE]), 233 - (unsigned long long)part_stat_read(p, sectors[STAT_WRITE]), 234 - (unsigned int)part_stat_read_msecs(p, STAT_WRITE), 235 - inflight, 236 - jiffies_to_msecs(part_stat_read(p, io_ticks)), 237 - jiffies_to_msecs(part_stat_read(p, time_in_queue)), 238 - part_stat_read(p, ios[STAT_DISCARD]), 239 - part_stat_read(p, merges[STAT_DISCARD]), 240 - (unsigned long long)part_stat_read(p, sectors[STAT_DISCARD]), 241 - (unsigned int)part_stat_read_msecs(p, STAT_DISCARD), 242 - part_stat_read(p, ios[STAT_FLUSH]), 243 - (unsigned int)part_stat_read_msecs(p, STAT_FLUSH)); 244 - } 245 - 246 - ssize_t part_inflight_show(struct device *dev, struct device_attribute *attr, 247 - char *buf) 248 - { 249 - struct hd_struct *p = dev_to_part(dev); 250 - struct request_queue *q = part_to_disk(p)->queue; 251 - unsigned int inflight[2]; 252 - 253 - part_in_flight_rw(q, p, inflight); 254 - return sprintf(buf, "%8u %8u\n", inflight[0], inflight[1]); 255 - } 256 - 257 - #ifdef CONFIG_FAIL_MAKE_REQUEST 258 - ssize_t part_fail_show(struct device *dev, 259 - struct device_attribute *attr, char *buf) 260 - { 261 - struct hd_struct *p = dev_to_part(dev); 262 - 263 - return sprintf(buf, "%d\n", p->make_it_fail); 264 - } 265 - 266 - ssize_t part_fail_store(struct device *dev, 267 - struct device_attribute *attr, 268 - const char *buf, size_t count) 269 - { 270 - struct hd_struct *p = dev_to_part(dev); 271 - int i; 272 - 273 - if (count > 0 && sscanf(buf, "%d", &i) > 0) 274 - p->make_it_fail = (i == 0) ? 0 : 1; 275 - 276 - return count; 277 - } 278 - #endif 279 117 280 118 static DEVICE_ATTR(partition, 0444, part_partition_show, NULL); 281 119 static DEVICE_ATTR(start, 0444, part_start_show, NULL); ··· 395 369 p->policy = get_disk_ro(disk); 396 370 397 371 if (info) { 398 - struct partition_meta_info *pinfo = alloc_part_info(disk); 372 + struct partition_meta_info *pinfo; 373 + 374 + pinfo = kzalloc_node(sizeof(*pinfo), GFP_KERNEL, disk->node_id); 399 375 if (!pinfo) { 400 376 err = -ENOMEM; 401 377 goto out_free_stats; ··· 456 428 return p; 457 429 458 430 out_free_info: 459 - free_part_info(p); 431 + kfree(p->info); 460 432 out_free_stats: 461 433 free_part_stats(p); 462 434 out_free: ··· 553 525 return true; 554 526 } 555 527 556 - #ifdef CONFIG_BLK_DEV_MD 557 - if (state->parts[p].flags & ADDPART_FLAG_RAID) 528 + if (IS_BUILTIN(CONFIG_BLK_DEV_MD) && 529 + (state->parts[p].flags & ADDPART_FLAG_RAID)) 558 530 md_autodetect_dev(part_to_dev(part)->devt); 559 - #endif 531 + 560 532 return true; 561 533 } 562 534 ··· 630 602 return ret; 631 603 } 632 604 633 - unsigned char *read_dev_sector(struct block_device *bdev, sector_t n, Sector *p) 605 + void *read_part_sector(struct parsed_partitions *state, sector_t n, Sector *p) 634 606 { 635 - struct address_space *mapping = bdev->bd_inode->i_mapping; 607 + struct address_space *mapping = state->bdev->bd_inode->i_mapping; 636 608 struct page *page; 637 609 638 - page = read_mapping_page(mapping, (pgoff_t)(n >> (PAGE_SHIFT-9)), NULL); 639 - if (!IS_ERR(page)) { 640 - if (PageError(page)) 641 - goto fail; 642 - p->v = page; 643 - return (unsigned char *)page_address(page) + ((n & ((1 << (PAGE_SHIFT - 9)) - 1)) << 9); 644 - fail: 645 - put_page(page); 610 + if (n >= get_capacity(state->bdev->bd_disk)) { 611 + state->access_beyond_eod = true; 612 + return NULL; 646 613 } 614 + 615 + page = read_mapping_page(mapping, 616 + (pgoff_t)(n >> (PAGE_SHIFT - 9)), NULL); 617 + if (IS_ERR(page)) 618 + goto out; 619 + if (PageError(page)) 620 + goto out_put_page; 621 + 622 + p->v = page; 623 + return (unsigned char *)page_address(page) + 624 + ((n & ((1 << (PAGE_SHIFT - 9)) - 1)) << SECTOR_SHIFT); 625 + out_put_page: 626 + put_page(page); 627 + out: 647 628 p->v = NULL; 648 629 return NULL; 649 630 } 650 - 651 - EXPORT_SYMBOL(read_dev_sector);
+1 -2
block/partitions/Makefile
··· 3 3 # Makefile for the linux kernel. 4 4 # 5 5 6 - obj-$(CONFIG_BLOCK) := check.o 7 - 6 + obj-$(CONFIG_BLOCK) += core.o 8 7 obj-$(CONFIG_ACORN_PARTITION) += acorn.o 9 8 obj-$(CONFIG_AMIGA_PARTITION) += amiga.o 10 9 obj-$(CONFIG_ATARI_PARTITION) += atari.o
-1
block/partitions/acorn.c
··· 11 11 #include <linux/adfs_fs.h> 12 12 13 13 #include "check.h" 14 - #include "acorn.h" 15 14 16 15 /* 17 16 * Partition types. (Oh for reusability)
-15
block/partitions/acorn.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* 3 - * linux/fs/partitions/acorn.h 4 - * 5 - * Copyright (C) 1996-2001 Russell King. 6 - * 7 - * I _hate_ this partitioning mess - why can't we have one defined 8 - * format, and everyone stick to it? 9 - */ 10 - 11 - int adfspart_check_CUMANA(struct parsed_partitions *state); 12 - int adfspart_check_ADFS(struct parsed_partitions *state); 13 - int adfspart_check_ICS(struct parsed_partitions *state); 14 - int adfspart_check_POWERTEC(struct parsed_partitions *state); 15 - int adfspart_check_EESOX(struct parsed_partitions *state);
-1
block/partitions/aix.c
··· 6 6 */ 7 7 8 8 #include "check.h" 9 - #include "aix.h" 10 9 11 10 struct lvm_rec { 12 11 char lvm_id[4]; /* "_LVM" */
-2
block/partitions/aix.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - extern int aix_partition(struct parsed_partitions *state);
+4 -7
block/partitions/amiga.c
··· 14 14 #include <linux/affs_hardblocks.h> 15 15 16 16 #include "check.h" 17 - #include "amiga.h" 18 17 19 18 static __inline__ u32 20 19 checksum_block(__be32 *m, int size) ··· 41 42 goto rdb_done; 42 43 data = read_part_sector(state, blk, &sect); 43 44 if (!data) { 44 - if (warn_no_part) 45 - pr_err("Dev %s: unable to read RDB block %d\n", 46 - bdevname(state->bdev, b), blk); 45 + pr_err("Dev %s: unable to read RDB block %d\n", 46 + bdevname(state->bdev, b), blk); 47 47 res = -1; 48 48 goto rdb_done; 49 49 } ··· 83 85 blk *= blksize; /* Read in terms partition table understands */ 84 86 data = read_part_sector(state, blk, &sect); 85 87 if (!data) { 86 - if (warn_no_part) 87 - pr_err("Dev %s: unable to read partition block %d\n", 88 - bdevname(state->bdev, b), blk); 88 + pr_err("Dev %s: unable to read partition block %d\n", 89 + bdevname(state->bdev, b), blk); 89 90 res = -1; 90 91 goto rdb_done; 91 92 }
-7
block/partitions/amiga.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* 3 - * fs/partitions/amiga.h 4 - */ 5 - 6 - int amiga_partition(struct parsed_partitions *state); 7 -
-1
block/partitions/atari.h
··· 34 34 u16 checksum; /* checksum for bootable disks */ 35 35 } __packed; 36 36 37 - int atari_partition(struct parsed_partitions *state);
-198
block/partitions/check.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - /* 3 - * fs/partitions/check.c 4 - * 5 - * Code extracted from drivers/block/genhd.c 6 - * Copyright (C) 1991-1998 Linus Torvalds 7 - * Re-organised Feb 1998 Russell King 8 - * 9 - * We now have independent partition support from the 10 - * block drivers, which allows all the partition code to 11 - * be grouped in one location, and it to be mostly self 12 - * contained. 13 - * 14 - * Added needed MAJORS for new pairs, {hdi,hdj}, {hdk,hdl} 15 - */ 16 - 17 - #include <linux/slab.h> 18 - #include <linux/vmalloc.h> 19 - #include <linux/ctype.h> 20 - #include <linux/genhd.h> 21 - 22 - #include "check.h" 23 - 24 - #include "acorn.h" 25 - #include "amiga.h" 26 - #include "atari.h" 27 - #include "ldm.h" 28 - #include "mac.h" 29 - #include "msdos.h" 30 - #include "osf.h" 31 - #include "sgi.h" 32 - #include "sun.h" 33 - #include "ibm.h" 34 - #include "ultrix.h" 35 - #include "efi.h" 36 - #include "karma.h" 37 - #include "sysv68.h" 38 - #include "cmdline.h" 39 - 40 - int warn_no_part = 1; /*This is ugly: should make genhd removable media aware*/ 41 - 42 - static int (*check_part[])(struct parsed_partitions *) = { 43 - /* 44 - * Probe partition formats with tables at disk address 0 45 - * that also have an ADFS boot block at 0xdc0. 46 - */ 47 - #ifdef CONFIG_ACORN_PARTITION_ICS 48 - adfspart_check_ICS, 49 - #endif 50 - #ifdef CONFIG_ACORN_PARTITION_POWERTEC 51 - adfspart_check_POWERTEC, 52 - #endif 53 - #ifdef CONFIG_ACORN_PARTITION_EESOX 54 - adfspart_check_EESOX, 55 - #endif 56 - 57 - /* 58 - * Now move on to formats that only have partition info at 59 - * disk address 0xdc0. Since these may also have stale 60 - * PC/BIOS partition tables, they need to come before 61 - * the msdos entry. 62 - */ 63 - #ifdef CONFIG_ACORN_PARTITION_CUMANA 64 - adfspart_check_CUMANA, 65 - #endif 66 - #ifdef CONFIG_ACORN_PARTITION_ADFS 67 - adfspart_check_ADFS, 68 - #endif 69 - 70 - #ifdef CONFIG_CMDLINE_PARTITION 71 - cmdline_partition, 72 - #endif 73 - #ifdef CONFIG_EFI_PARTITION 74 - efi_partition, /* this must come before msdos */ 75 - #endif 76 - #ifdef CONFIG_SGI_PARTITION 77 - sgi_partition, 78 - #endif 79 - #ifdef CONFIG_LDM_PARTITION 80 - ldm_partition, /* this must come before msdos */ 81 - #endif 82 - #ifdef CONFIG_MSDOS_PARTITION 83 - msdos_partition, 84 - #endif 85 - #ifdef CONFIG_OSF_PARTITION 86 - osf_partition, 87 - #endif 88 - #ifdef CONFIG_SUN_PARTITION 89 - sun_partition, 90 - #endif 91 - #ifdef CONFIG_AMIGA_PARTITION 92 - amiga_partition, 93 - #endif 94 - #ifdef CONFIG_ATARI_PARTITION 95 - atari_partition, 96 - #endif 97 - #ifdef CONFIG_MAC_PARTITION 98 - mac_partition, 99 - #endif 100 - #ifdef CONFIG_ULTRIX_PARTITION 101 - ultrix_partition, 102 - #endif 103 - #ifdef CONFIG_IBM_PARTITION 104 - ibm_partition, 105 - #endif 106 - #ifdef CONFIG_KARMA_PARTITION 107 - karma_partition, 108 - #endif 109 - #ifdef CONFIG_SYSV68_PARTITION 110 - sysv68_partition, 111 - #endif 112 - NULL 113 - }; 114 - 115 - static struct parsed_partitions *allocate_partitions(struct gendisk *hd) 116 - { 117 - struct parsed_partitions *state; 118 - int nr; 119 - 120 - state = kzalloc(sizeof(*state), GFP_KERNEL); 121 - if (!state) 122 - return NULL; 123 - 124 - nr = disk_max_parts(hd); 125 - state->parts = vzalloc(array_size(nr, sizeof(state->parts[0]))); 126 - if (!state->parts) { 127 - kfree(state); 128 - return NULL; 129 - } 130 - 131 - state->limit = nr; 132 - 133 - return state; 134 - } 135 - 136 - void free_partitions(struct parsed_partitions *state) 137 - { 138 - vfree(state->parts); 139 - kfree(state); 140 - } 141 - 142 - struct parsed_partitions * 143 - check_partition(struct gendisk *hd, struct block_device *bdev) 144 - { 145 - struct parsed_partitions *state; 146 - int i, res, err; 147 - 148 - state = allocate_partitions(hd); 149 - if (!state) 150 - return NULL; 151 - state->pp_buf = (char *)__get_free_page(GFP_KERNEL); 152 - if (!state->pp_buf) { 153 - free_partitions(state); 154 - return NULL; 155 - } 156 - state->pp_buf[0] = '\0'; 157 - 158 - state->bdev = bdev; 159 - disk_name(hd, 0, state->name); 160 - snprintf(state->pp_buf, PAGE_SIZE, " %s:", state->name); 161 - if (isdigit(state->name[strlen(state->name)-1])) 162 - sprintf(state->name, "p"); 163 - 164 - i = res = err = 0; 165 - while (!res && check_part[i]) { 166 - memset(state->parts, 0, state->limit * sizeof(state->parts[0])); 167 - res = check_part[i++](state); 168 - if (res < 0) { 169 - /* We have hit an I/O error which we don't report now. 170 - * But record it, and let the others do their job. 171 - */ 172 - err = res; 173 - res = 0; 174 - } 175 - 176 - } 177 - if (res > 0) { 178 - printk(KERN_INFO "%s", state->pp_buf); 179 - 180 - free_page((unsigned long)state->pp_buf); 181 - return state; 182 - } 183 - if (state->access_beyond_eod) 184 - err = -ENOSPC; 185 - if (err) 186 - /* The partition is unrecognized. So report I/O errors if there were any */ 187 - res = err; 188 - if (res) { 189 - if (warn_no_part) 190 - strlcat(state->pp_buf, 191 - " unable to read partition table\n", PAGE_SIZE); 192 - printk(KERN_INFO "%s", state->pp_buf); 193 - } 194 - 195 - free_page((unsigned long)state->pp_buf); 196 - free_partitions(state); 197 - return ERR_PTR(res); 198 - }
+28 -13
block/partitions/check.h
··· 2 2 #include <linux/pagemap.h> 3 3 #include <linux/blkdev.h> 4 4 #include <linux/genhd.h> 5 + #include "../blk.h" 5 6 6 7 /* 7 8 * add_gd_partition adds a partitions details to the devices partition ··· 24 23 char *pp_buf; 25 24 }; 26 25 27 - void free_partitions(struct parsed_partitions *state); 26 + typedef struct { 27 + struct page *v; 28 + } Sector; 28 29 29 - struct parsed_partitions * 30 - check_partition(struct gendisk *, struct block_device *); 31 - 32 - static inline void *read_part_sector(struct parsed_partitions *state, 33 - sector_t n, Sector *p) 30 + void *read_part_sector(struct parsed_partitions *state, sector_t n, Sector *p); 31 + static inline void put_dev_sector(Sector p) 34 32 { 35 - if (n >= get_capacity(state->bdev->bd_disk)) { 36 - state->access_beyond_eod = true; 37 - return NULL; 38 - } 39 - return read_dev_sector(state->bdev, n, p); 33 + put_page(p.v); 40 34 } 41 35 42 36 static inline void ··· 47 51 } 48 52 } 49 53 50 - extern int warn_no_part; 51 - 54 + /* detection routines go here in alphabetical order: */ 55 + int adfspart_check_ADFS(struct parsed_partitions *state); 56 + int adfspart_check_CUMANA(struct parsed_partitions *state); 57 + int adfspart_check_EESOX(struct parsed_partitions *state); 58 + int adfspart_check_ICS(struct parsed_partitions *state); 59 + int adfspart_check_POWERTEC(struct parsed_partitions *state); 60 + int aix_partition(struct parsed_partitions *state); 61 + int amiga_partition(struct parsed_partitions *state); 62 + int atari_partition(struct parsed_partitions *state); 63 + int cmdline_partition(struct parsed_partitions *state); 64 + int efi_partition(struct parsed_partitions *state); 65 + int ibm_partition(struct parsed_partitions *); 66 + int karma_partition(struct parsed_partitions *state); 67 + int ldm_partition(struct parsed_partitions *state); 68 + int mac_partition(struct parsed_partitions *state); 69 + int msdos_partition(struct parsed_partitions *state); 70 + int osf_partition(struct parsed_partitions *state); 71 + int sgi_partition(struct parsed_partitions *state); 72 + int sun_partition(struct parsed_partitions *state); 73 + int sysv68_partition(struct parsed_partitions *state); 74 + int ultrix_partition(struct parsed_partitions *state);
-1
block/partitions/cmdline.c
··· 18 18 #include <linux/cmdline-parser.h> 19 19 20 20 #include "check.h" 21 - #include "cmdline.h" 22 21 23 22 static char *cmdline; 24 23 static struct cmdline_parts *bdev_parts;
-3
block/partitions/cmdline.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - 3 - int cmdline_partition(struct parsed_partitions *state);
-3
block/partitions/efi.h
··· 113 113 __le16 signature; 114 114 } __packed legacy_mbr; 115 115 116 - /* Functions */ 117 - extern int efi_partition(struct parsed_partitions *state); 118 - 119 116 #endif
-1
block/partitions/ibm.c
··· 15 15 #include <asm/vtoc.h> 16 16 17 17 #include "check.h" 18 - #include "ibm.h" 19 18 20 19 21 20 union label_t {
-2
block/partitions/ibm.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - int ibm_partition(struct parsed_partitions *);
+2 -1
block/partitions/karma.c
··· 8 8 */ 9 9 10 10 #include "check.h" 11 - #include "karma.h" 12 11 #include <linux/compiler.h> 12 + 13 + #define KARMA_LABEL_MAGIC 0xAB56 13 14 14 15 int karma_partition(struct parsed_partitions *state) 15 16 {
-9
block/partitions/karma.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* 3 - * fs/partitions/karma.h 4 - */ 5 - 6 - #define KARMA_LABEL_MAGIC 0xAB56 7 - 8 - int karma_partition(struct parsed_partitions *state); 9 -
+3 -3
block/partitions/ldm.c
··· 14 14 #include <linux/stringify.h> 15 15 #include <linux/kernel.h> 16 16 #include <linux/uuid.h> 17 + #include <linux/msdos_partition.h> 17 18 18 19 #include "ldm.h" 19 20 #include "check.h" 20 - #include "msdos.h" 21 21 22 22 /* 23 23 * ldm_debug/info/error/crit - Output an error message ··· 493 493 { 494 494 Sector sect; 495 495 u8 *data; 496 - struct partition *p; 496 + struct msdos_partition *p; 497 497 int i; 498 498 bool result = false; 499 499 ··· 508 508 if (*(__le16*) (data + 0x01FE) != cpu_to_le16 (MSDOS_LABEL_MAGIC)) 509 509 goto out; 510 510 511 - p = (struct partition*)(data + 0x01BE); 511 + p = (struct msdos_partition *)(data + 0x01BE); 512 512 for (i = 0; i < 4; i++, p++) 513 513 if (SYS_IND (p) == LDM_PARTITION) { 514 514 result = true;
-2
block/partitions/ldm.h
··· 193 193 struct list_head v_part; 194 194 }; 195 195 196 - int ldm_partition(struct parsed_partitions *state); 197 - 198 196 #endif /* _FS_PT_LDM_H_ */ 199 197
-1
block/partitions/mac.h
··· 42 42 /* ... more stuff */ 43 43 }; 44 44 45 - int mac_partition(struct parsed_partitions *state);
+151 -21
block/partitions/msdos.c
··· 18 18 * Check partition table on IDE disks for common CHS translations 19 19 * 20 20 * Re-organised Feb 1998 Russell King 21 + * 22 + * BSD disklabel support by Yossi Gottlieb <yogo@math.tau.ac.il> 23 + * updated by Marc Espie <Marc.Espie@openbsd.org> 24 + * 25 + * Unixware slices support by Andrzej Krzysztofowicz <ankry@mif.pg.gda.pl> 26 + * and Krzysztof G. Baranowski <kgb@knm.org.pl> 21 27 */ 22 28 #include <linux/msdos_fs.h> 29 + #include <linux/msdos_partition.h> 23 30 24 31 #include "check.h" 25 - #include "msdos.h" 26 32 #include "efi.h" 27 - #include "aix.h" 28 33 29 34 /* 30 35 * Many architectures don't like unaligned accesses, while ··· 40 35 41 36 #define SYS_IND(p) get_unaligned(&p->sys_ind) 42 37 43 - static inline sector_t nr_sects(struct partition *p) 38 + static inline sector_t nr_sects(struct msdos_partition *p) 44 39 { 45 40 return (sector_t)get_unaligned_le32(&p->nr_sects); 46 41 } 47 42 48 - static inline sector_t start_sect(struct partition *p) 43 + static inline sector_t start_sect(struct msdos_partition *p) 49 44 { 50 45 return (sector_t)get_unaligned_le32(&p->start_sect); 51 46 } 52 47 53 - static inline int is_extended_partition(struct partition *p) 48 + static inline int is_extended_partition(struct msdos_partition *p) 54 49 { 55 50 return (SYS_IND(p) == DOS_EXTENDED_PARTITION || 56 51 SYS_IND(p) == WIN98_EXTENDED_PARTITION || ··· 73 68 #define AIX_LABEL_MAGIC4 0xC1 74 69 static int aix_magic_present(struct parsed_partitions *state, unsigned char *p) 75 70 { 76 - struct partition *pt = (struct partition *) (p + 0x1be); 71 + struct msdos_partition *pt = (struct msdos_partition *) (p + 0x1be); 77 72 Sector sect; 78 73 unsigned char *d; 79 74 int slot, ret = 0; ··· 83 78 p[2] == AIX_LABEL_MAGIC3 && 84 79 p[3] == AIX_LABEL_MAGIC4)) 85 80 return 0; 86 - /* Assume the partition table is valid if Linux partitions exists */ 81 + 82 + /* 83 + * Assume the partition table is valid if Linux partitions exists. 84 + * Note that old Solaris/x86 partitions use the same indicator as 85 + * Linux swap partitions, so we consider that a Linux partition as 86 + * well. 87 + */ 87 88 for (slot = 1; slot <= 4; slot++, pt++) { 88 - if (pt->sys_ind == LINUX_SWAP_PARTITION || 89 - pt->sys_ind == LINUX_RAID_PARTITION || 90 - pt->sys_ind == LINUX_DATA_PARTITION || 91 - pt->sys_ind == LINUX_LVM_PARTITION || 92 - is_extended_partition(pt)) 89 + if (pt->sys_ind == SOLARIS_X86_PARTITION || 90 + pt->sys_ind == LINUX_RAID_PARTITION || 91 + pt->sys_ind == LINUX_DATA_PARTITION || 92 + pt->sys_ind == LINUX_LVM_PARTITION || 93 + is_extended_partition(pt)) 93 94 return 0; 94 95 } 95 96 d = read_part_sector(state, 7, &sect); ··· 133 122 sector_t first_sector, sector_t first_size, 134 123 u32 disksig) 135 124 { 136 - struct partition *p; 125 + struct msdos_partition *p; 137 126 Sector sect; 138 127 unsigned char *data; 139 128 sector_t this_sector, this_size; ··· 157 146 if (!msdos_magic_present(data + 510)) 158 147 goto done; 159 148 160 - p = (struct partition *) (data + 0x1be); 149 + p = (struct msdos_partition *) (data + 0x1be); 161 150 162 151 /* 163 152 * Usually, the first entry is the real data partition, ··· 221 210 put_dev_sector(sect); 222 211 } 223 212 213 + #define SOLARIS_X86_NUMSLICE 16 214 + #define SOLARIS_X86_VTOC_SANE (0x600DDEEEUL) 215 + 216 + struct solaris_x86_slice { 217 + __le16 s_tag; /* ID tag of partition */ 218 + __le16 s_flag; /* permission flags */ 219 + __le32 s_start; /* start sector no of partition */ 220 + __le32 s_size; /* # of blocks in partition */ 221 + }; 222 + 223 + struct solaris_x86_vtoc { 224 + unsigned int v_bootinfo[3]; /* info needed by mboot */ 225 + __le32 v_sanity; /* to verify vtoc sanity */ 226 + __le32 v_version; /* layout version */ 227 + char v_volume[8]; /* volume name */ 228 + __le16 v_sectorsz; /* sector size in bytes */ 229 + __le16 v_nparts; /* number of partitions */ 230 + unsigned int v_reserved[10]; /* free space */ 231 + struct solaris_x86_slice 232 + v_slice[SOLARIS_X86_NUMSLICE]; /* slice headers */ 233 + unsigned int timestamp[SOLARIS_X86_NUMSLICE]; /* timestamp */ 234 + char v_asciilabel[128]; /* for compatibility */ 235 + }; 236 + 224 237 /* james@bpgc.com: Solaris has a nasty indicator: 0x82 which also 225 238 indicates linux swap. Be careful before believing this is Solaris. */ 226 239 ··· 299 264 strlcat(state->pp_buf, " >\n", PAGE_SIZE); 300 265 #endif 301 266 } 267 + 268 + /* check against BSD src/sys/sys/disklabel.h for consistency */ 269 + #define BSD_DISKMAGIC (0x82564557UL) /* The disk magic number */ 270 + #define BSD_MAXPARTITIONS 16 271 + #define OPENBSD_MAXPARTITIONS 16 272 + #define BSD_FS_UNUSED 0 /* disklabel unused partition entry ID */ 273 + struct bsd_disklabel { 274 + __le32 d_magic; /* the magic number */ 275 + __s16 d_type; /* drive type */ 276 + __s16 d_subtype; /* controller/d_type specific */ 277 + char d_typename[16]; /* type name, e.g. "eagle" */ 278 + char d_packname[16]; /* pack identifier */ 279 + __u32 d_secsize; /* # of bytes per sector */ 280 + __u32 d_nsectors; /* # of data sectors per track */ 281 + __u32 d_ntracks; /* # of tracks per cylinder */ 282 + __u32 d_ncylinders; /* # of data cylinders per unit */ 283 + __u32 d_secpercyl; /* # of data sectors per cylinder */ 284 + __u32 d_secperunit; /* # of data sectors per unit */ 285 + __u16 d_sparespertrack; /* # of spare sectors per track */ 286 + __u16 d_sparespercyl; /* # of spare sectors per cylinder */ 287 + __u32 d_acylinders; /* # of alt. cylinders per unit */ 288 + __u16 d_rpm; /* rotational speed */ 289 + __u16 d_interleave; /* hardware sector interleave */ 290 + __u16 d_trackskew; /* sector 0 skew, per track */ 291 + __u16 d_cylskew; /* sector 0 skew, per cylinder */ 292 + __u32 d_headswitch; /* head switch time, usec */ 293 + __u32 d_trkseek; /* track-to-track seek, usec */ 294 + __u32 d_flags; /* generic flags */ 295 + #define NDDATA 5 296 + __u32 d_drivedata[NDDATA]; /* drive-type specific information */ 297 + #define NSPARE 5 298 + __u32 d_spare[NSPARE]; /* reserved for future use */ 299 + __le32 d_magic2; /* the magic number (again) */ 300 + __le16 d_checksum; /* xor of data incl. partitions */ 301 + 302 + /* filesystem and partition information: */ 303 + __le16 d_npartitions; /* number of partitions in following */ 304 + __le32 d_bbsize; /* size of boot area at sn0, bytes */ 305 + __le32 d_sbsize; /* max size of fs superblock, bytes */ 306 + struct bsd_partition { /* the partition table */ 307 + __le32 p_size; /* number of sectors in partition */ 308 + __le32 p_offset; /* starting sector */ 309 + __le32 p_fsize; /* filesystem basic fragment size */ 310 + __u8 p_fstype; /* filesystem type, see below */ 311 + __u8 p_frag; /* filesystem fragments per block */ 312 + __le16 p_cpg; /* filesystem cylinders per group */ 313 + } d_partitions[BSD_MAXPARTITIONS]; /* actually may be more */ 314 + }; 302 315 303 316 #if defined(CONFIG_BSD_DISKLABEL) 304 317 /* ··· 432 349 #endif 433 350 } 434 351 352 + #define UNIXWARE_DISKMAGIC (0xCA5E600DUL) /* The disk magic number */ 353 + #define UNIXWARE_DISKMAGIC2 (0x600DDEEEUL) /* The slice table magic nr */ 354 + #define UNIXWARE_NUMSLICE 16 355 + #define UNIXWARE_FS_UNUSED 0 /* Unused slice entry ID */ 356 + 357 + struct unixware_slice { 358 + __le16 s_label; /* label */ 359 + __le16 s_flags; /* permission flags */ 360 + __le32 start_sect; /* starting sector */ 361 + __le32 nr_sects; /* number of sectors in slice */ 362 + }; 363 + 364 + struct unixware_disklabel { 365 + __le32 d_type; /* drive type */ 366 + __le32 d_magic; /* the magic number */ 367 + __le32 d_version; /* version number */ 368 + char d_serial[12]; /* serial number of the device */ 369 + __le32 d_ncylinders; /* # of data cylinders per device */ 370 + __le32 d_ntracks; /* # of tracks per cylinder */ 371 + __le32 d_nsectors; /* # of data sectors per track */ 372 + __le32 d_secsize; /* # of bytes per sector */ 373 + __le32 d_part_start; /* # of first sector of this partition*/ 374 + __le32 d_unknown1[12]; /* ? */ 375 + __le32 d_alt_tbl; /* byte offset of alternate table */ 376 + __le32 d_alt_len; /* byte length of alternate table */ 377 + __le32 d_phys_cyl; /* # of physical cylinders per device */ 378 + __le32 d_phys_trk; /* # of physical tracks per cylinder */ 379 + __le32 d_phys_sec; /* # of physical sectors per track */ 380 + __le32 d_phys_bytes; /* # of physical bytes per sector */ 381 + __le32 d_unknown2; /* ? */ 382 + __le32 d_unknown3; /* ? */ 383 + __le32 d_pad[8]; /* pad */ 384 + 385 + struct unixware_vtoc { 386 + __le32 v_magic; /* the magic number */ 387 + __le32 v_version; /* version number */ 388 + char v_name[8]; /* volume name */ 389 + __le16 v_nslices; /* # of slices */ 390 + __le16 v_unknown1; /* ? */ 391 + __le32 v_reserved[10]; /* reserved */ 392 + struct unixware_slice 393 + v_slice[UNIXWARE_NUMSLICE]; /* slice headers */ 394 + } vtoc; 395 + }; /* 408 */ 396 + 435 397 /* 436 398 * Create devices for Unixware partitions listed in a disklabel, under a 437 399 * dos-like partition. See parse_extended() for more information. ··· 520 392 #endif 521 393 } 522 394 395 + #define MINIX_NR_SUBPARTITIONS 4 396 + 523 397 /* 524 398 * Minix 2.0.0/2.0.2 subpartition support. 525 399 * Anand Krishnamurthy <anandk@wiproge.med.ge.com> ··· 533 403 #ifdef CONFIG_MINIX_SUBPARTITION 534 404 Sector sect; 535 405 unsigned char *data; 536 - struct partition *p; 406 + struct msdos_partition *p; 537 407 int i; 538 408 539 409 data = read_part_sector(state, offset, &sect); 540 410 if (!data) 541 411 return; 542 412 543 - p = (struct partition *)(data + 0x1be); 413 + p = (struct msdos_partition *)(data + 0x1be); 544 414 545 415 /* The first sector of a Minix partition can have either 546 416 * a secondary MBR describing its subpartitions, or ··· 584 454 sector_t sector_size = bdev_logical_block_size(state->bdev) / 512; 585 455 Sector sect; 586 456 unsigned char *data; 587 - struct partition *p; 457 + struct msdos_partition *p; 588 458 struct fat_boot_sector *fb; 589 459 int slot; 590 460 u32 disksig; ··· 618 488 * partition table. Reject this in case the boot indicator 619 489 * is not 0 or 0x80. 620 490 */ 621 - p = (struct partition *) (data + 0x1be); 491 + p = (struct msdos_partition *) (data + 0x1be); 622 492 for (slot = 1; slot <= 4; slot++, p++) { 623 493 if (p->boot_ind != 0 && p->boot_ind != 0x80) { 624 494 /* ··· 640 510 } 641 511 642 512 #ifdef CONFIG_EFI_PARTITION 643 - p = (struct partition *) (data + 0x1be); 513 + p = (struct msdos_partition *) (data + 0x1be); 644 514 for (slot = 1 ; slot <= 4 ; slot++, p++) { 645 515 /* If this is an EFI GPT disk, msdos should ignore it. */ 646 516 if (SYS_IND(p) == EFI_PMBR_OSTYPE_EFI_GPT) { ··· 649 519 } 650 520 } 651 521 #endif 652 - p = (struct partition *) (data + 0x1be); 522 + p = (struct msdos_partition *) (data + 0x1be); 653 523 654 524 disksig = le32_to_cpup((__le32 *)(data + 0x1b8)); 655 525 ··· 696 566 strlcat(state->pp_buf, "\n", PAGE_SIZE); 697 567 698 568 /* second pass - output for each on a separate line */ 699 - p = (struct partition *) (0x1be + data); 569 + p = (struct msdos_partition *) (0x1be + data); 700 570 for (slot = 1 ; slot <= 4 ; slot++, p++) { 701 571 unsigned char id = SYS_IND(p); 702 572 int n;
-9
block/partitions/msdos.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* 3 - * fs/partitions/msdos.h 4 - */ 5 - 6 - #define MSDOS_LABEL_MAGIC 0xAA55 7 - 8 - int msdos_partition(struct parsed_partitions *state); 9 -
+1 -1
block/partitions/osf.c
··· 9 9 */ 10 10 11 11 #include "check.h" 12 - #include "osf.h" 13 12 14 13 #define MAX_OSF_PARTITIONS 18 14 + #define DISKLABELMAGIC (0x82564557UL) 15 15 16 16 int osf_partition(struct parsed_partitions *state) 17 17 {
-8
block/partitions/osf.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* 3 - * fs/partitions/osf.h 4 - */ 5 - 6 - #define DISKLABELMAGIC (0x82564557UL) 7 - 8 - int osf_partition(struct parsed_partitions *state);
+6 -1
block/partitions/sgi.c
··· 6 6 */ 7 7 8 8 #include "check.h" 9 - #include "sgi.h" 9 + 10 + #define SGI_LABEL_MAGIC 0x0be5a941 11 + 12 + enum { 13 + LINUX_RAID_PARTITION = 0xfd, /* autodetect RAID partition */ 14 + }; 10 15 11 16 struct sgi_disklabel { 12 17 __be32 magic_mushroom; /* Big fat spliff... */
-9
block/partitions/sgi.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* 3 - * fs/partitions/sgi.h 4 - */ 5 - 6 - extern int sgi_partition(struct parsed_partitions *state); 7 - 8 - #define SGI_LABEL_MAGIC 0x0be5a941 9 -
+8 -1
block/partitions/sun.c
··· 9 9 */ 10 10 11 11 #include "check.h" 12 - #include "sun.h" 12 + 13 + #define SUN_LABEL_MAGIC 0xDABE 14 + #define SUN_VTOC_SANITY 0x600DDEEE 15 + 16 + enum { 17 + SUN_WHOLE_DISK = 5, 18 + LINUX_RAID_PARTITION = 0xfd, /* autodetect RAID partition */ 19 + }; 13 20 14 21 int sun_partition(struct parsed_partitions *state) 15 22 {
-9
block/partitions/sun.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* 3 - * fs/partitions/sun.h 4 - */ 5 - 6 - #define SUN_LABEL_MAGIC 0xDABE 7 - #define SUN_VTOC_SANITY 0x600DDEEE 8 - 9 - int sun_partition(struct parsed_partitions *state);
-1
block/partitions/sysv68.c
··· 6 6 */ 7 7 8 8 #include "check.h" 9 - #include "sysv68.h" 10 9 11 10 /* 12 11 * Volume ID structure: on first 256-bytes sector of disk
-2
block/partitions/sysv68.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - extern int sysv68_partition(struct parsed_partitions *state);
-1
block/partitions/ultrix.c
··· 8 8 */ 9 9 10 10 #include "check.h" 11 - #include "ultrix.h" 12 11 13 12 int ultrix_partition(struct parsed_partitions *state) 14 13 {
-6
block/partitions/ultrix.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* 3 - * fs/partitions/ultrix.h 4 - */ 5 - 6 - int ultrix_partition(struct parsed_partitions *state);
+1 -1
block/sed-opal.c
··· 1056 1056 hsn = response_get_u64(&dev->parsed, 4); 1057 1057 tsn = response_get_u64(&dev->parsed, 5); 1058 1058 1059 - if (hsn == 0 && tsn == 0) { 1059 + if (hsn != GENERIC_HOST_SESSION_NUM || tsn < FIRST_TPER_SESSION_NUM) { 1060 1060 pr_debug("Couldn't authenticate session\n"); 1061 1061 return -EPERM; 1062 1062 }
+1 -3
drivers/block/brd.c
··· 381 381 spin_lock_init(&brd->brd_lock); 382 382 INIT_RADIX_TREE(&brd->brd_pages, GFP_ATOMIC); 383 383 384 - brd->brd_queue = blk_alloc_queue(GFP_KERNEL); 384 + brd->brd_queue = blk_alloc_queue(brd_make_request, NUMA_NO_NODE); 385 385 if (!brd->brd_queue) 386 386 goto out_free_dev; 387 - 388 - blk_queue_make_request(brd->brd_queue, brd_make_request); 389 387 390 388 /* This is so fdisk will align partitions on 4k, because of 391 389 * direct_access API needing 4k alignment, returning a PFN
+1 -2
drivers/block/drbd/drbd_main.c
··· 2801 2801 2802 2802 drbd_init_set_defaults(device); 2803 2803 2804 - q = blk_alloc_queue_node(GFP_KERNEL, NUMA_NO_NODE); 2804 + q = blk_alloc_queue(drbd_make_request, NUMA_NO_NODE); 2805 2805 if (!q) 2806 2806 goto out_no_q; 2807 2807 device->rq_queue = q; ··· 2828 2828 q->backing_dev_info->congested_fn = drbd_congested; 2829 2829 q->backing_dev_info->congested_data = device; 2830 2830 2831 - blk_queue_make_request(q, drbd_make_request); 2832 2831 blk_queue_write_cache(q, true, true); 2833 2832 /* Setting the max_hw_sectors to an odd value of 8kibyte here 2834 2833 This triggers a max_bio_size message upon first attach or connect */
+1
drivers/block/drbd/drbd_receiver.c
··· 33 33 #include <linux/random.h> 34 34 #include <linux/string.h> 35 35 #include <linux/scatterlist.h> 36 + #include <linux/part_stat.h> 36 37 #include "drbd_int.h" 37 38 #include "drbd_protocol.h" 38 39 #include "drbd_req.h"
+1
drivers/block/drbd/drbd_worker.c
··· 22 22 #include <linux/random.h> 23 23 #include <linux/string.h> 24 24 #include <linux/scatterlist.h> 25 + #include <linux/part_stat.h> 25 26 26 27 #include "drbd_int.h" 27 28 #include "drbd_protocol.h"
+65 -41
drivers/block/null_blk_main.c
··· 23 23 #ifdef CONFIG_BLK_DEV_NULL_BLK_FAULT_INJECTION 24 24 static DECLARE_FAULT_ATTR(null_timeout_attr); 25 25 static DECLARE_FAULT_ATTR(null_requeue_attr); 26 + static DECLARE_FAULT_ATTR(null_init_hctx_attr); 26 27 #endif 27 28 28 29 static inline u64 mb_per_tick(int mbps) ··· 102 101 103 102 static char g_requeue_str[80]; 104 103 module_param_string(requeue, g_requeue_str, sizeof(g_requeue_str), 0444); 104 + 105 + static char g_init_hctx_str[80]; 106 + module_param_string(init_hctx, g_init_hctx_str, sizeof(g_init_hctx_str), 0444); 105 107 #endif 106 108 107 109 static int g_queue_mode = NULL_Q_MQ; ··· 280 276 { \ 281 277 int (*apply_fn)(struct nullb_device *dev, TYPE new_value) = APPLY;\ 282 278 struct nullb_device *dev = to_nullb_device(item); \ 283 - TYPE uninitialized_var(new_value); \ 279 + TYPE new_value = 0; \ 284 280 int ret; \ 285 281 \ 286 282 ret = nullb_device_##TYPE##_attr_store(&new_value, page, count);\ ··· 306 302 if (!nullb) 307 303 return 0; 308 304 305 + /* 306 + * Make sure that null_init_hctx() does not access nullb->queues[] past 307 + * the end of that array. 308 + */ 309 + if (submit_queues > nr_cpu_ids) 310 + return -EINVAL; 309 311 set = nullb->tag_set; 310 312 blk_mq_update_nr_hw_queues(set, submit_queues); 311 313 return set->nr_hw_queues == submit_queues ? 0 : -ENOMEM; ··· 1418 1408 return null_handle_cmd(cmd, sector, nr_sectors, req_op(bd->rq)); 1419 1409 } 1420 1410 1421 - static const struct blk_mq_ops null_mq_ops = { 1422 - .queue_rq = null_queue_rq, 1423 - .complete = null_complete_rq, 1424 - .timeout = null_timeout_rq, 1425 - }; 1426 - 1427 1411 static void cleanup_queue(struct nullb_queue *nq) 1428 1412 { 1429 1413 kfree(nq->tag_map); ··· 1434 1430 kfree(nullb->queues); 1435 1431 } 1436 1432 1433 + static void null_exit_hctx(struct blk_mq_hw_ctx *hctx, unsigned int hctx_idx) 1434 + { 1435 + struct nullb_queue *nq = hctx->driver_data; 1436 + struct nullb *nullb = nq->dev->nullb; 1437 + 1438 + nullb->nr_queues--; 1439 + } 1440 + 1441 + static void null_init_queue(struct nullb *nullb, struct nullb_queue *nq) 1442 + { 1443 + init_waitqueue_head(&nq->wait); 1444 + nq->queue_depth = nullb->queue_depth; 1445 + nq->dev = nullb->dev; 1446 + } 1447 + 1448 + static int null_init_hctx(struct blk_mq_hw_ctx *hctx, void *driver_data, 1449 + unsigned int hctx_idx) 1450 + { 1451 + struct nullb *nullb = hctx->queue->queuedata; 1452 + struct nullb_queue *nq; 1453 + 1454 + #ifdef CONFIG_BLK_DEV_NULL_BLK_FAULT_INJECTION 1455 + if (g_init_hctx_str[0] && should_fail(&null_init_hctx_attr, 1)) 1456 + return -EFAULT; 1457 + #endif 1458 + 1459 + nq = &nullb->queues[hctx_idx]; 1460 + hctx->driver_data = nq; 1461 + null_init_queue(nullb, nq); 1462 + nullb->nr_queues++; 1463 + 1464 + return 0; 1465 + } 1466 + 1467 + static const struct blk_mq_ops null_mq_ops = { 1468 + .queue_rq = null_queue_rq, 1469 + .complete = null_complete_rq, 1470 + .timeout = null_timeout_rq, 1471 + .init_hctx = null_init_hctx, 1472 + .exit_hctx = null_exit_hctx, 1473 + }; 1474 + 1437 1475 static void null_del_dev(struct nullb *nullb) 1438 1476 { 1439 - struct nullb_device *dev = nullb->dev; 1477 + struct nullb_device *dev; 1478 + 1479 + if (!nullb) 1480 + return; 1481 + 1482 + dev = nullb->dev; 1440 1483 1441 1484 ida_simple_remove(&nullb_indexes, nullb->index); 1442 1485 ··· 1524 1473 .report_zones = null_report_zones, 1525 1474 }; 1526 1475 1527 - static void null_init_queue(struct nullb *nullb, struct nullb_queue *nq) 1528 - { 1529 - BUG_ON(!nullb); 1530 - BUG_ON(!nq); 1531 - 1532 - init_waitqueue_head(&nq->wait); 1533 - nq->queue_depth = nullb->queue_depth; 1534 - nq->dev = nullb->dev; 1535 - } 1536 - 1537 - static void null_init_queues(struct nullb *nullb) 1538 - { 1539 - struct request_queue *q = nullb->q; 1540 - struct blk_mq_hw_ctx *hctx; 1541 - struct nullb_queue *nq; 1542 - int i; 1543 - 1544 - queue_for_each_hw_ctx(q, hctx, i) { 1545 - if (!hctx->nr_ctx || !hctx->tags) 1546 - continue; 1547 - nq = &nullb->queues[i]; 1548 - hctx->driver_data = nq; 1549 - null_init_queue(nullb, nq); 1550 - nullb->nr_queues++; 1551 - } 1552 - } 1553 - 1554 1476 static int setup_commands(struct nullb_queue *nq) 1555 1477 { 1556 1478 struct nullb_cmd *cmd; ··· 1550 1526 1551 1527 static int setup_queues(struct nullb *nullb) 1552 1528 { 1553 - nullb->queues = kcalloc(nullb->dev->submit_queues, 1554 - sizeof(struct nullb_queue), 1529 + nullb->queues = kcalloc(nr_cpu_ids, sizeof(struct nullb_queue), 1555 1530 GFP_KERNEL); 1556 1531 if (!nullb->queues) 1557 1532 return -ENOMEM; ··· 1692 1669 return false; 1693 1670 if (!__null_setup_fault(&null_requeue_attr, g_requeue_str)) 1694 1671 return false; 1672 + if (!__null_setup_fault(&null_init_hctx_attr, g_init_hctx_str)) 1673 + return false; 1695 1674 #endif 1696 1675 return true; 1697 1676 } ··· 1737 1712 goto out_cleanup_queues; 1738 1713 1739 1714 nullb->tag_set->timeout = 5 * HZ; 1740 - nullb->q = blk_mq_init_queue(nullb->tag_set); 1715 + nullb->q = blk_mq_init_queue_data(nullb->tag_set, nullb); 1741 1716 if (IS_ERR(nullb->q)) { 1742 1717 rv = -ENOMEM; 1743 1718 goto out_cleanup_tags; 1744 1719 } 1745 - null_init_queues(nullb); 1746 1720 } else if (dev->queue_mode == NULL_Q_BIO) { 1747 - nullb->q = blk_alloc_queue_node(GFP_KERNEL, dev->home_node); 1721 + nullb->q = blk_alloc_queue(null_queue_bio, dev->home_node); 1748 1722 if (!nullb->q) { 1749 1723 rv = -ENOMEM; 1750 1724 goto out_cleanup_queues; 1751 1725 } 1752 - blk_queue_make_request(nullb->q, null_queue_bio); 1753 1726 rv = init_driver_queues(nullb); 1754 1727 if (rv) 1755 1728 goto out_cleanup_blk_queue; ··· 1811 1788 cleanup_queues(nullb); 1812 1789 out_free_nullb: 1813 1790 kfree(nullb); 1791 + dev->nullb = NULL; 1814 1792 out: 1815 1793 return rv; 1816 1794 }
+7 -8
drivers/block/pktcdvd.c
··· 2493 2493 { 2494 2494 struct request_queue *q = pd->disk->queue; 2495 2495 2496 - blk_queue_make_request(q, pkt_make_request); 2497 2496 blk_queue_logical_block_size(q, CD_FRAMESIZE); 2498 2497 blk_queue_max_hw_sectors(q, PACKET_MAX_SECTORS); 2499 2498 q->queuedata = pd; ··· 2678 2679 return attached_disk->fops->check_events(attached_disk, clearing); 2679 2680 } 2680 2681 2682 + static char *pkt_devnode(struct gendisk *disk, umode_t *mode) 2683 + { 2684 + return kasprintf(GFP_KERNEL, "pktcdvd/%s", disk->disk_name); 2685 + } 2686 + 2681 2687 static const struct block_device_operations pktcdvd_ops = { 2682 2688 .owner = THIS_MODULE, 2683 2689 .open = pkt_open, ··· 2690 2686 .ioctl = pkt_ioctl, 2691 2687 .compat_ioctl = blkdev_compat_ptr_ioctl, 2692 2688 .check_events = pkt_check_events, 2689 + .devnode = pkt_devnode, 2693 2690 }; 2694 - 2695 - static char *pktcdvd_devnode(struct gendisk *gd, umode_t *mode) 2696 - { 2697 - return kasprintf(GFP_KERNEL, "pktcdvd/%s", gd->disk_name); 2698 - } 2699 2691 2700 2692 /* 2701 2693 * Set up mapping from pktcdvd device to CD-ROM device. ··· 2748 2748 disk->fops = &pktcdvd_ops; 2749 2749 disk->flags = GENHD_FL_REMOVABLE; 2750 2750 strcpy(disk->disk_name, pd->name); 2751 - disk->devnode = pktcdvd_devnode; 2752 2751 disk->private_data = pd; 2753 - disk->queue = blk_alloc_queue(GFP_KERNEL); 2752 + disk->queue = blk_alloc_queue(pkt_make_request, NUMA_NO_NODE); 2754 2753 if (!disk->queue) 2755 2754 goto out_mem2; 2756 2755
+1 -2
drivers/block/ps3vram.c
··· 737 737 738 738 ps3vram_proc_init(dev); 739 739 740 - queue = blk_alloc_queue(GFP_KERNEL); 740 + queue = blk_alloc_queue(ps3vram_make_request, NUMA_NO_NODE); 741 741 if (!queue) { 742 742 dev_err(&dev->core, "blk_alloc_queue failed\n"); 743 743 error = -ENOMEM; ··· 746 746 747 747 priv->queue = queue; 748 748 queue->queuedata = dev; 749 - blk_queue_make_request(queue, ps3vram_make_request); 750 749 blk_queue_max_segments(queue, BLK_MAX_SEGMENTS); 751 750 blk_queue_max_segment_size(queue, BLK_MAX_SEGMENT_SIZE); 752 751 blk_queue_max_hw_sectors(queue, BLK_SAFE_MAX_SECTORS);
+1 -2
drivers/block/rsxx/dev.c
··· 248 248 return -ENOMEM; 249 249 } 250 250 251 - card->queue = blk_alloc_queue(GFP_KERNEL); 251 + card->queue = blk_alloc_queue(rsxx_make_request, NUMA_NO_NODE); 252 252 if (!card->queue) { 253 253 dev_err(CARD_TO_DEV(card), "Failed queue alloc\n"); 254 254 unregister_blkdev(card->major, DRIVER_NAME); ··· 269 269 blk_queue_logical_block_size(card->queue, blk_size); 270 270 } 271 271 272 - blk_queue_make_request(card->queue, rsxx_make_request); 273 272 blk_queue_max_hw_sectors(card->queue, blkdev_max_hw_sectors); 274 273 blk_queue_physical_block_size(card->queue, RSXX_HW_BLK_SIZE); 275 274
+1 -3
drivers/block/umem.c
··· 885 885 card->biotail = &card->bio; 886 886 spin_lock_init(&card->lock); 887 887 888 - card->queue = blk_alloc_queue_node(GFP_KERNEL, NUMA_NO_NODE); 888 + card->queue = blk_alloc_queue(mm_make_request, NUMA_NO_NODE); 889 889 if (!card->queue) 890 890 goto failed_alloc; 891 - 892 - blk_queue_make_request(card->queue, mm_make_request); 893 891 card->queue->queuedata = card; 894 892 895 893 tasklet_init(&card->tasklet, process_page, (unsigned long)card);
+1 -4
drivers/block/virtio_blk.c
··· 388 388 cap_str_10, 389 389 cap_str_2); 390 390 391 - set_capacity(vblk->disk, capacity); 391 + set_capacity_revalidate_and_notify(vblk->disk, capacity, true); 392 392 } 393 393 394 394 static void virtblk_config_changed_work(struct work_struct *work) 395 395 { 396 396 struct virtio_blk *vblk = 397 397 container_of(work, struct virtio_blk, config_work); 398 - char *envp[] = { "RESIZE=1", NULL }; 399 398 400 399 virtblk_update_capacity(vblk, true); 401 - revalidate_disk(vblk->disk); 402 - kobject_uevent_env(&disk_to_dev(vblk->disk)->kobj, KOBJ_CHANGE, envp); 403 400 } 404 401 405 402 static void virtblk_config_changed(struct virtio_device *vdev)
+1 -5
drivers/block/xen-blkfront.c
··· 2338 2338 unsigned long sector_size; 2339 2339 unsigned int physical_sector_size; 2340 2340 unsigned int binfo; 2341 - char *envp[] = { "RESIZE=1", NULL }; 2342 2341 int err, i; 2343 2342 struct blkfront_ring_info *rinfo; 2344 2343 ··· 2353 2354 return; 2354 2355 printk(KERN_INFO "Setting capacity to %Lu\n", 2355 2356 sectors); 2356 - set_capacity(info->gd, sectors); 2357 - revalidate_disk(info->gd); 2358 - kobject_uevent_env(&disk_to_dev(info->gd)->kobj, 2359 - KOBJ_CHANGE, envp); 2357 + set_capacity_revalidate_and_notify(info->gd, sectors, true); 2360 2358 2361 2359 return; 2362 2360 case BLKIF_STATE_SUSPENDED:
+2 -3
drivers/block/zram/zram_drv.c
··· 33 33 #include <linux/sysfs.h> 34 34 #include <linux/debugfs.h> 35 35 #include <linux/cpuhotplug.h> 36 + #include <linux/part_stat.h> 36 37 37 38 #include "zram_drv.h" 38 39 ··· 1895 1894 #ifdef CONFIG_ZRAM_WRITEBACK 1896 1895 spin_lock_init(&zram->wb_limit_lock); 1897 1896 #endif 1898 - queue = blk_alloc_queue(GFP_KERNEL); 1897 + queue = blk_alloc_queue(zram_make_request, NUMA_NO_NODE); 1899 1898 if (!queue) { 1900 1899 pr_err("Error allocating disk queue for device %d\n", 1901 1900 device_id); 1902 1901 ret = -ENOMEM; 1903 1902 goto out_free_idr; 1904 1903 } 1905 - 1906 - blk_queue_make_request(queue, zram_make_request); 1907 1904 1908 1905 /* gendisk structure */ 1909 1906 zram->disk = alloc_disk(1);
+1 -2
drivers/lightnvm/core.c
··· 380 380 goto err_dev; 381 381 } 382 382 383 - tqueue = blk_alloc_queue_node(GFP_KERNEL, dev->q->node); 383 + tqueue = blk_alloc_queue(tt->make_rq, dev->q->node); 384 384 if (!tqueue) { 385 385 ret = -ENOMEM; 386 386 goto err_disk; 387 387 } 388 - blk_queue_make_request(tqueue, tt->make_rq); 389 388 390 389 strlcpy(tdisk->disk_name, create->tgtname, sizeof(tdisk->disk_name)); 391 390 tdisk->flags = GENHD_FL_EXT_DEVT;
+2 -5
drivers/md/bcache/request.c
··· 1161 1161 1162 1162 /* Cached devices - read & write stuff */ 1163 1163 1164 - static blk_qc_t cached_dev_make_request(struct request_queue *q, 1165 - struct bio *bio) 1164 + blk_qc_t cached_dev_make_request(struct request_queue *q, struct bio *bio) 1166 1165 { 1167 1166 struct search *s; 1168 1167 struct bcache_device *d = bio->bi_disk->private_data; ··· 1265 1266 { 1266 1267 struct gendisk *g = dc->disk.disk; 1267 1268 1268 - g->queue->make_request_fn = cached_dev_make_request; 1269 1269 g->queue->backing_dev_info->congested_fn = cached_dev_congested; 1270 1270 dc->disk.cache_miss = cached_dev_cache_miss; 1271 1271 dc->disk.ioctl = cached_dev_ioctl; ··· 1299 1301 continue_at(cl, search_free, NULL); 1300 1302 } 1301 1303 1302 - static blk_qc_t flash_dev_make_request(struct request_queue *q, 1303 - struct bio *bio) 1304 + blk_qc_t flash_dev_make_request(struct request_queue *q, struct bio *bio) 1304 1305 { 1305 1306 struct search *s; 1306 1307 struct closure *cl;
+3
drivers/md/bcache/request.h
··· 37 37 void bch_data_insert(struct closure *cl); 38 38 39 39 void bch_cached_dev_request_init(struct cached_dev *dc); 40 + blk_qc_t cached_dev_make_request(struct request_queue *q, struct bio *bio); 41 + 40 42 void bch_flash_dev_request_init(struct bcache_device *d); 43 + blk_qc_t flash_dev_make_request(struct request_queue *q, struct bio *bio); 41 44 42 45 extern struct kmem_cache *bch_search_cache; 43 46
+6 -5
drivers/md/bcache/super.c
··· 816 816 } 817 817 818 818 static int bcache_device_init(struct bcache_device *d, unsigned int block_size, 819 - sector_t sectors) 819 + sector_t sectors, make_request_fn make_request_fn) 820 820 { 821 821 struct request_queue *q; 822 822 const size_t max_stripes = min_t(size_t, INT_MAX, ··· 866 866 d->disk->fops = &bcache_ops; 867 867 d->disk->private_data = d; 868 868 869 - q = blk_alloc_queue(GFP_KERNEL); 869 + q = blk_alloc_queue(make_request_fn, NUMA_NO_NODE); 870 870 if (!q) 871 871 return -ENOMEM; 872 872 873 - blk_queue_make_request(q, NULL); 874 873 d->disk->queue = q; 875 874 q->queuedata = d; 876 875 q->backing_dev_info->congested_data = d; ··· 1338 1339 q->limits.raid_partial_stripes_expensive; 1339 1340 1340 1341 ret = bcache_device_init(&dc->disk, block_size, 1341 - dc->bdev->bd_part->nr_sects - dc->sb.data_offset); 1342 + dc->bdev->bd_part->nr_sects - dc->sb.data_offset, 1343 + cached_dev_make_request); 1342 1344 if (ret) 1343 1345 return ret; 1344 1346 ··· 1451 1451 1452 1452 kobject_init(&d->kobj, &bch_flash_dev_ktype); 1453 1453 1454 - if (bcache_device_init(d, block_bytes(c), u->sectors)) 1454 + if (bcache_device_init(d, block_bytes(c), u->sectors, 1455 + flash_dev_make_request)) 1455 1456 goto err; 1456 1457 1457 1458 bcache_device_attach(d, c, u - c->uuids);
+5 -5
drivers/md/dm.c
··· 25 25 #include <linux/wait.h> 26 26 #include <linux/pr.h> 27 27 #include <linux/refcount.h> 28 + #include <linux/part_stat.h> 28 29 29 30 #define DM_MSG_PREFIX "core" 30 31 ··· 1939 1938 INIT_LIST_HEAD(&md->table_devices); 1940 1939 spin_lock_init(&md->uevent_lock); 1941 1940 1942 - md->queue = blk_alloc_queue_node(GFP_KERNEL, numa_node_id); 1943 - if (!md->queue) 1944 - goto bad; 1945 - md->queue->queuedata = md; 1946 1941 /* 1947 1942 * default to bio-based required ->make_request_fn until DM 1948 1943 * table is loaded and md->type established. If request-based 1949 1944 * table is loaded: blk-mq will override accordingly. 1950 1945 */ 1951 - blk_queue_make_request(md->queue, dm_make_request); 1946 + md->queue = blk_alloc_queue(dm_make_request, numa_node_id); 1947 + if (!md->queue) 1948 + goto bad; 1949 + md->queue->queuedata = md; 1952 1950 1953 1951 md->disk = alloc_disk_node(1, md->numa_node_id); 1954 1952 if (!md->disk)
+5 -4
drivers/md/md.c
··· 58 58 #include <linux/delay.h> 59 59 #include <linux/raid/md_p.h> 60 60 #include <linux/raid/md_u.h> 61 + #include <linux/raid/detect.h> 61 62 #include <linux/slab.h> 62 63 #include <linux/percpu-refcount.h> 64 + #include <linux/part_stat.h> 63 65 64 66 #include <trace/events/block.h> 65 67 #include "md.h" ··· 2493 2491 { 2494 2492 int err = 0; 2495 2493 struct block_device *bdev; 2496 - char b[BDEVNAME_SIZE]; 2497 2494 2498 2495 bdev = blkdev_get_by_dev(dev, FMODE_READ|FMODE_WRITE|FMODE_EXCL, 2499 2496 shared ? (struct md_rdev *)lock_rdev : rdev); 2500 2497 if (IS_ERR(bdev)) { 2501 - pr_warn("md: could not open %s.\n", __bdevname(dev, b)); 2498 + pr_warn("md: could not open device unknown-block(%u,%u).\n", 2499 + MAJOR(dev), MINOR(dev)); 2502 2500 return PTR_ERR(bdev); 2503 2501 } 2504 2502 rdev->bdev = bdev; ··· 5623 5621 mddev->hold_active = UNTIL_STOP; 5624 5622 5625 5623 error = -ENOMEM; 5626 - mddev->queue = blk_alloc_queue(GFP_KERNEL); 5624 + mddev->queue = blk_alloc_queue(md_make_request, NUMA_NO_NODE); 5627 5625 if (!mddev->queue) 5628 5626 goto abort; 5629 5627 mddev->queue->queuedata = mddev; 5630 5628 5631 - blk_queue_make_request(mddev->queue, md_make_request); 5632 5629 blk_set_stacking_limits(&mddev->queue->limits); 5633 5630 5634 5631 disk = alloc_disk(1 << shift);
+1 -2
drivers/nvdimm/blk.c
··· 249 249 internal_nlba = div_u64(nsblk->size, nsblk_internal_lbasize(nsblk)); 250 250 available_disk_size = internal_nlba * nsblk_sector_size(nsblk); 251 251 252 - q = blk_alloc_queue(GFP_KERNEL); 252 + q = blk_alloc_queue(nd_blk_make_request, NUMA_NO_NODE); 253 253 if (!q) 254 254 return -ENOMEM; 255 255 if (devm_add_action_or_reset(dev, nd_blk_release_queue, q)) 256 256 return -ENOMEM; 257 257 258 - blk_queue_make_request(q, nd_blk_make_request); 259 258 blk_queue_max_hw_sectors(q, UINT_MAX); 260 259 blk_queue_logical_block_size(q, nsblk_sector_size(nsblk)); 261 260 blk_queue_flag_set(QUEUE_FLAG_NONROT, q);
+1 -2
drivers/nvdimm/btt.c
··· 1521 1521 struct nd_namespace_common *ndns = nd_btt->ndns; 1522 1522 1523 1523 /* create a new disk and request queue for btt */ 1524 - btt->btt_queue = blk_alloc_queue(GFP_KERNEL); 1524 + btt->btt_queue = blk_alloc_queue(btt_make_request, NUMA_NO_NODE); 1525 1525 if (!btt->btt_queue) 1526 1526 return -ENOMEM; 1527 1527 ··· 1540 1540 btt->btt_disk->queue->backing_dev_info->capabilities |= 1541 1541 BDI_CAP_SYNCHRONOUS_IO; 1542 1542 1543 - blk_queue_make_request(btt->btt_queue, btt_make_request); 1544 1543 blk_queue_logical_block_size(btt->btt_queue, btt->sector_size); 1545 1544 blk_queue_max_hw_sectors(btt->btt_queue, UINT_MAX); 1546 1545 blk_queue_flag_set(QUEUE_FLAG_NONROT, btt->btt_queue);
+1 -2
drivers/nvdimm/pmem.c
··· 395 395 return -EBUSY; 396 396 } 397 397 398 - q = blk_alloc_queue_node(GFP_KERNEL, dev_to_node(dev)); 398 + q = blk_alloc_queue(pmem_make_request, dev_to_node(dev)); 399 399 if (!q) 400 400 return -ENOMEM; 401 401 ··· 433 433 pmem->virt_addr = addr; 434 434 435 435 blk_queue_write_cache(q, true, fua); 436 - blk_queue_make_request(q, pmem_make_request); 437 436 blk_queue_physical_block_size(q, PAGE_SIZE); 438 437 blk_queue_logical_block_size(q, pmem_sector_size(ndns)); 439 438 blk_queue_max_hw_sectors(q, UINT_MAX);
+1 -1
drivers/nvme/host/core.c
··· 1810 1810 ns->lba_shift > PAGE_SHIFT) 1811 1811 capacity = 0; 1812 1812 1813 - set_capacity(disk, capacity); 1813 + set_capacity_revalidate_and_notify(disk, capacity, false); 1814 1814 1815 1815 nvme_config_discard(disk, ns); 1816 1816 nvme_config_write_zeroes(disk, ns);
+1 -2
drivers/nvme/host/multipath.c
··· 377 377 if (!(ctrl->subsys->cmic & (1 << 1)) || !multipath) 378 378 return 0; 379 379 380 - q = blk_alloc_queue_node(GFP_KERNEL, ctrl->numa_node); 380 + q = blk_alloc_queue(nvme_ns_head_make_request, ctrl->numa_node); 381 381 if (!q) 382 382 goto out; 383 383 q->queuedata = head; 384 - blk_queue_make_request(q, nvme_ns_head_make_request); 385 384 blk_queue_flag_set(QUEUE_FLAG_NONROT, q); 386 385 /* set to a default value for 512 until disk is validated */ 387 386 blk_queue_logical_block_size(q, 512);
+1
drivers/nvme/target/admin-cmd.c
··· 6 6 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 7 7 #include <linux/module.h> 8 8 #include <linux/rculist.h> 9 + #include <linux/part_stat.h> 9 10 10 11 #include <generated/utsrelease.h> 11 12 #include <asm/unaligned.h>
+2 -2
drivers/s390/block/dcssblk.c
··· 636 636 } 637 637 dev_info->gd->major = dcssblk_major; 638 638 dev_info->gd->fops = &dcssblk_devops; 639 - dev_info->dcssblk_queue = blk_alloc_queue(GFP_KERNEL); 639 + dev_info->dcssblk_queue = 640 + blk_alloc_queue(dcssblk_make_request, NUMA_NO_NODE); 640 641 dev_info->gd->queue = dev_info->dcssblk_queue; 641 642 dev_info->gd->private_data = dev_info; 642 - blk_queue_make_request(dev_info->dcssblk_queue, dcssblk_make_request); 643 643 blk_queue_logical_block_size(dev_info->dcssblk_queue, 4096); 644 644 blk_queue_flag_set(QUEUE_FLAG_DAX, dev_info->dcssblk_queue); 645 645
+2 -2
drivers/s390/block/xpram.c
··· 343 343 xpram_disks[i] = alloc_disk(1); 344 344 if (!xpram_disks[i]) 345 345 goto out; 346 - xpram_queues[i] = blk_alloc_queue(GFP_KERNEL); 346 + xpram_queues[i] = blk_alloc_queue(xpram_make_request, 347 + NUMA_NO_NODE); 347 348 if (!xpram_queues[i]) { 348 349 put_disk(xpram_disks[i]); 349 350 goto out; 350 351 } 351 352 blk_queue_flag_set(QUEUE_FLAG_NONROT, xpram_queues[i]); 352 353 blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, xpram_queues[i]); 353 - blk_queue_make_request(xpram_queues[i], xpram_make_request); 354 354 blk_queue_logical_block_size(xpram_queues[i], 4096); 355 355 } 356 356
+5 -3
drivers/scsi/BusLogic.c
··· 36 36 #include <linux/jiffies.h> 37 37 #include <linux/dma-mapping.h> 38 38 #include <linux/slab.h> 39 + #include <linux/msdos_partition.h> 39 40 #include <scsi/scsicam.h> 40 41 41 42 #include <asm/dma.h> ··· 3411 3410 a partition table entry whose end_head matches one of the 3412 3411 standard BusLogic geometry translations (64/32, 128/32, or 255/63). 3413 3412 */ 3414 - if (*(unsigned short *) (buf + 64) == 0xAA55) { 3415 - struct partition *part1_entry = (struct partition *) buf; 3416 - struct partition *part_entry = part1_entry; 3413 + if (*(unsigned short *) (buf + 64) == MSDOS_LABEL_MAGIC) { 3414 + struct msdos_partition *part1_entry = 3415 + (struct msdos_partition *)buf; 3416 + struct msdos_partition *part_entry = part1_entry; 3417 3417 int saved_cyl = diskparam->cylinders, part_no; 3418 3418 unsigned char part_end_head = 0, part_end_sector = 0; 3419 3419
+4 -3
drivers/scsi/aacraid/linit.c
··· 33 33 #include <linux/syscalls.h> 34 34 #include <linux/delay.h> 35 35 #include <linux/kthread.h> 36 + #include <linux/msdos_partition.h> 36 37 37 38 #include <scsi/scsi.h> 38 39 #include <scsi/scsi_cmnd.h> ··· 329 328 buf = scsi_bios_ptable(bdev); 330 329 if (!buf) 331 330 return 0; 332 - if(*(__le16 *)(buf + 0x40) == cpu_to_le16(0xaa55)) { 333 - struct partition *first = (struct partition * )buf; 334 - struct partition *entry = first; 331 + if (*(__le16 *)(buf + 0x40) == cpu_to_le16(MSDOS_LABEL_MAGIC)) { 332 + struct msdos_partition *first = (struct msdos_partition *)buf; 333 + struct msdos_partition *entry = first; 335 334 int saved_cylinders = param->cylinders; 336 335 int num; 337 336 unsigned char end_head, end_sec;
+3 -10
drivers/scsi/aic7xxx/aic79xx_osm.c
··· 723 723 ahd_linux_biosparam(struct scsi_device *sdev, struct block_device *bdev, 724 724 sector_t capacity, int geom[]) 725 725 { 726 - uint8_t *bh; 727 726 int heads; 728 727 int sectors; 729 728 int cylinders; 730 - int ret; 731 729 int extended; 732 730 struct ahd_softc *ahd; 733 731 734 732 ahd = *((struct ahd_softc **)sdev->host->hostdata); 735 733 736 - bh = scsi_bios_ptable(bdev); 737 - if (bh) { 738 - ret = scsi_partsize(bh, capacity, 739 - &geom[2], &geom[0], &geom[1]); 740 - kfree(bh); 741 - if (ret != -1) 742 - return (ret); 743 - } 734 + if (scsi_partsize(bdev, capacity, geom)) 735 + return 0; 736 + 744 737 heads = 64; 745 738 sectors = 32; 746 739 cylinders = aic_sector_div(capacity, heads, sectors);
+3 -10
drivers/scsi/aic7xxx/aic7xxx_osm.c
··· 695 695 ahc_linux_biosparam(struct scsi_device *sdev, struct block_device *bdev, 696 696 sector_t capacity, int geom[]) 697 697 { 698 - uint8_t *bh; 699 698 int heads; 700 699 int sectors; 701 700 int cylinders; 702 - int ret; 703 701 int extended; 704 702 struct ahc_softc *ahc; 705 703 u_int channel; ··· 705 707 ahc = *((struct ahc_softc **)sdev->host->hostdata); 706 708 channel = sdev_channel(sdev); 707 709 708 - bh = scsi_bios_ptable(bdev); 709 - if (bh) { 710 - ret = scsi_partsize(bh, capacity, 711 - &geom[2], &geom[0], &geom[1]); 712 - kfree(bh); 713 - if (ret != -1) 714 - return (ret); 715 - } 710 + if (scsi_partsize(bdev, capacity, geom)) 711 + return 0; 712 + 716 713 heads = 64; 717 714 sectors = 32; 718 715 cylinders = aic_sector_div(capacity, heads, sectors);
+4 -9
drivers/scsi/arcmsr/arcmsr_hba.c
··· 353 353 static int arcmsr_bios_param(struct scsi_device *sdev, 354 354 struct block_device *bdev, sector_t capacity, int *geom) 355 355 { 356 - int ret, heads, sectors, cylinders, total_capacity; 357 - unsigned char *buffer;/* return copy of block device's partition table */ 356 + int heads, sectors, cylinders, total_capacity; 358 357 359 - buffer = scsi_bios_ptable(bdev); 360 - if (buffer) { 361 - ret = scsi_partsize(buffer, capacity, &geom[2], &geom[0], &geom[1]); 362 - kfree(buffer); 363 - if (ret != -1) 364 - return ret; 365 - } 358 + if (scsi_partsize(bdev, capacity, geom)) 359 + return 0; 360 + 366 361 total_capacity = capacity; 367 362 heads = 64; 368 363 sectors = 32;
+2 -11
drivers/scsi/megaraid.c
··· 2795 2795 sector_t capacity, int geom[]) 2796 2796 { 2797 2797 adapter_t *adapter; 2798 - unsigned char *bh; 2799 2798 int heads; 2800 2799 int sectors; 2801 2800 int cylinders; 2802 - int rval; 2803 2801 2804 2802 /* Get pointer to host config structure */ 2805 2803 adapter = (adapter_t *)sdev->host->hostdata; ··· 2824 2826 geom[2] = cylinders; 2825 2827 } 2826 2828 else { 2827 - bh = scsi_bios_ptable(bdev); 2828 - 2829 - if( bh ) { 2830 - rval = scsi_partsize(bh, capacity, 2831 - &geom[2], &geom[0], &geom[1]); 2832 - kfree(bh); 2833 - if( rval != -1 ) 2834 - return rval; 2835 - } 2829 + if (scsi_partsize(bdev, capacity, geom)) 2830 + return 0; 2836 2831 2837 2832 dev_info(&adapter->dev->dev, 2838 2833 "invalid partition on this disk on channel %d\n",
+3 -2
drivers/scsi/scsi_debug.c
··· 38 38 #include <linux/hrtimer.h> 39 39 #include <linux/uuid.h> 40 40 #include <linux/t10-pi.h> 41 + #include <linux/msdos_partition.h> 41 42 42 43 #include <net/checksum.h> 43 44 ··· 4147 4146 static void __init sdebug_build_parts(unsigned char *ramp, 4148 4147 unsigned long store_size) 4149 4148 { 4150 - struct partition *pp; 4149 + struct msdos_partition *pp; 4151 4150 int starts[SDEBUG_MAX_PARTS + 2]; 4152 4151 int sectors_per_part, num_sectors, k; 4153 4152 int heads_by_sects, start_sec, end_sec; ··· 4172 4171 4173 4172 ramp[510] = 0x55; /* magic partition markings */ 4174 4173 ramp[511] = 0xAA; 4175 - pp = (struct partition *)(ramp + 0x1be); 4174 + pp = (struct msdos_partition *)(ramp + 0x1be); 4176 4175 for (k = 0; starts[k + 1]; ++k, ++pp) { 4177 4176 start_sec = starts[k]; 4178 4177 end_sec = starts[k + 1] - 1;
+92 -94
drivers/scsi/scsicam.c
··· 17 17 #include <linux/genhd.h> 18 18 #include <linux/kernel.h> 19 19 #include <linux/blkdev.h> 20 + #include <linux/msdos_partition.h> 20 21 #include <asm/unaligned.h> 21 22 22 23 #include <scsi/scsicam.h> 23 - 24 - 25 - static int setsize(unsigned long capacity, unsigned int *cyls, unsigned int *hds, 26 - unsigned int *secs); 27 24 28 25 /** 29 26 * scsi_bios_ptable - Read PC partition table out of first sector of device. ··· 32 35 */ 33 36 unsigned char *scsi_bios_ptable(struct block_device *dev) 34 37 { 35 - unsigned char *res = kmalloc(66, GFP_KERNEL); 36 - if (res) { 37 - struct block_device *bdev = dev->bd_contains; 38 - Sector sect; 39 - void *data = read_dev_sector(bdev, 0, &sect); 40 - if (data) { 41 - memcpy(res, data + 0x1be, 66); 42 - put_dev_sector(sect); 43 - } else { 44 - kfree(res); 45 - res = NULL; 46 - } 47 - } 38 + struct address_space *mapping = dev->bd_contains->bd_inode->i_mapping; 39 + unsigned char *res = NULL; 40 + struct page *page; 41 + 42 + page = read_mapping_page(mapping, 0, NULL); 43 + if (IS_ERR(page)) 44 + return NULL; 45 + 46 + if (!PageError(page)) 47 + res = kmemdup(page_address(page) + 0x1be, 66, GFP_KERNEL); 48 + put_page(page); 48 49 return res; 49 50 } 50 51 EXPORT_SYMBOL(scsi_bios_ptable); 51 52 52 53 /** 53 - * scsicam_bios_param - Determine geometry of a disk in cylinders/heads/sectors. 54 - * @bdev: which device 55 - * @capacity: size of the disk in sectors 56 - * @ip: return value: ip[0]=heads, ip[1]=sectors, ip[2]=cylinders 57 - * 58 - * Description : determine the BIOS mapping/geometry used for a drive in a 59 - * SCSI-CAM system, storing the results in ip as required 60 - * by the HDIO_GETGEO ioctl(). 61 - * 62 - * Returns : -1 on failure, 0 on success. 63 - */ 64 - 65 - int scsicam_bios_param(struct block_device *bdev, sector_t capacity, int *ip) 66 - { 67 - unsigned char *p; 68 - u64 capacity64 = capacity; /* Suppress gcc warning */ 69 - int ret; 70 - 71 - p = scsi_bios_ptable(bdev); 72 - if (!p) 73 - return -1; 74 - 75 - /* try to infer mapping from partition table */ 76 - ret = scsi_partsize(p, (unsigned long)capacity, (unsigned int *)ip + 2, 77 - (unsigned int *)ip + 0, (unsigned int *)ip + 1); 78 - kfree(p); 79 - 80 - if (ret == -1 && capacity64 < (1ULL << 32)) { 81 - /* pick some standard mapping with at most 1024 cylinders, 82 - and at most 62 sectors per track - this works up to 83 - 7905 MB */ 84 - ret = setsize((unsigned long)capacity, (unsigned int *)ip + 2, 85 - (unsigned int *)ip + 0, (unsigned int *)ip + 1); 86 - } 87 - 88 - /* if something went wrong, then apparently we have to return 89 - a geometry with more than 1024 cylinders */ 90 - if (ret || ip[0] > 255 || ip[1] > 63) { 91 - if ((capacity >> 11) > 65534) { 92 - ip[0] = 255; 93 - ip[1] = 63; 94 - } else { 95 - ip[0] = 64; 96 - ip[1] = 32; 97 - } 98 - 99 - if (capacity > 65535*63*255) 100 - ip[2] = 65535; 101 - else 102 - ip[2] = (unsigned long)capacity / (ip[0] * ip[1]); 103 - } 104 - 105 - return 0; 106 - } 107 - EXPORT_SYMBOL(scsicam_bios_param); 108 - 109 - /** 110 54 * scsi_partsize - Parse cylinders/heads/sectors from PC partition table 111 - * @buf: partition table, see scsi_bios_ptable() 55 + * @bdev: block device to parse 112 56 * @capacity: size of the disk in sectors 113 - * @cyls: put cylinders here 114 - * @hds: put heads here 115 - * @secs: put sectors here 57 + * @geom: output in form of [hds, cylinders, sectors] 116 58 * 117 59 * Determine the BIOS mapping/geometry used to create the partition 118 - * table, storing the results in @cyls, @hds, and @secs 60 + * table, storing the results in @geom. 119 61 * 120 - * Returns: -1 on failure, 0 on success. 62 + * Returns: %false on failure, %true on success. 121 63 */ 122 - 123 - int scsi_partsize(unsigned char *buf, unsigned long capacity, 124 - unsigned int *cyls, unsigned int *hds, unsigned int *secs) 64 + bool scsi_partsize(struct block_device *bdev, sector_t capacity, int geom[3]) 125 65 { 126 - struct partition *p = (struct partition *)buf, *largest = NULL; 127 - int i, largest_cyl; 128 66 int cyl, ext_cyl, end_head, end_cyl, end_sector; 129 67 unsigned int logical_end, physical_end, ext_physical_end; 68 + struct msdos_partition *p, *largest = NULL; 69 + void *buf; 70 + int ret = false; 130 71 72 + buf = scsi_bios_ptable(bdev); 73 + if (!buf) 74 + return false; 131 75 132 76 if (*(unsigned short *) (buf + 64) == 0xAA55) { 133 - for (largest_cyl = -1, i = 0; i < 4; ++i, ++p) { 77 + int largest_cyl = -1, i; 78 + 79 + for (i = 0, p = buf; i < 4; i++, p++) { 134 80 if (!p->sys_ind) 135 81 continue; 136 82 #ifdef DEBUG ··· 93 153 end_sector = largest->end_sector & 0x3f; 94 154 95 155 if (end_head + 1 == 0 || end_sector == 0) 96 - return -1; 156 + goto out_free_buf; 97 157 98 158 #ifdef DEBUG 99 159 printk("scsicam_bios_param : end at h = %d, c = %d, s = %d\n", ··· 118 178 ,logical_end, physical_end, ext_physical_end, ext_cyl); 119 179 #endif 120 180 121 - if ((logical_end == physical_end) || 122 - (end_cyl == 1023 && ext_physical_end == logical_end)) { 123 - *secs = end_sector; 124 - *hds = end_head + 1; 125 - *cyls = capacity / ((end_head + 1) * end_sector); 126 - return 0; 181 + if (logical_end == physical_end || 182 + (end_cyl == 1023 && ext_physical_end == logical_end)) { 183 + geom[0] = end_head + 1; 184 + geom[1] = end_sector; 185 + geom[2] = (unsigned long)capacity / 186 + ((end_head + 1) * end_sector); 187 + ret = true; 188 + goto out_free_buf; 127 189 } 128 190 #ifdef DEBUG 129 191 printk("scsicam_bios_param : logical (%u) != physical (%u)\n", 130 192 logical_end, physical_end); 131 193 #endif 132 194 } 133 - return -1; 195 + 196 + out_free_buf: 197 + kfree(buf); 198 + return ret; 134 199 } 135 200 EXPORT_SYMBOL(scsi_partsize); 136 201 ··· 203 258 *hds = (unsigned int) heads; 204 259 return (rv); 205 260 } 261 + 262 + /** 263 + * scsicam_bios_param - Determine geometry of a disk in cylinders/heads/sectors. 264 + * @bdev: which device 265 + * @capacity: size of the disk in sectors 266 + * @ip: return value: ip[0]=heads, ip[1]=sectors, ip[2]=cylinders 267 + * 268 + * Description : determine the BIOS mapping/geometry used for a drive in a 269 + * SCSI-CAM system, storing the results in ip as required 270 + * by the HDIO_GETGEO ioctl(). 271 + * 272 + * Returns : -1 on failure, 0 on success. 273 + */ 274 + int scsicam_bios_param(struct block_device *bdev, sector_t capacity, int *ip) 275 + { 276 + u64 capacity64 = capacity; /* Suppress gcc warning */ 277 + int ret = 0; 278 + 279 + /* try to infer mapping from partition table */ 280 + if (scsi_partsize(bdev, capacity, ip)) 281 + return 0; 282 + 283 + if (capacity64 < (1ULL << 32)) { 284 + /* 285 + * Pick some standard mapping with at most 1024 cylinders, and 286 + * at most 62 sectors per track - this works up to 7905 MB. 287 + */ 288 + ret = setsize((unsigned long)capacity, (unsigned int *)ip + 2, 289 + (unsigned int *)ip + 0, (unsigned int *)ip + 1); 290 + } 291 + 292 + /* 293 + * If something went wrong, then apparently we have to return a geometry 294 + * with more than 1024 cylinders. 295 + */ 296 + if (ret || ip[0] > 255 || ip[1] > 63) { 297 + if ((capacity >> 11) > 65534) { 298 + ip[0] = 255; 299 + ip[1] = 63; 300 + } else { 301 + ip[0] = 64; 302 + ip[1] = 32; 303 + } 304 + 305 + if (capacity > 65535*63*255) 306 + ip[2] = 65535; 307 + else 308 + ip[2] = (unsigned long)capacity / (ip[0] * ip[1]); 309 + } 310 + 311 + return 0; 312 + } 313 + EXPORT_SYMBOL(scsicam_bios_param);
+2 -1
drivers/scsi/sd.c
··· 3189 3189 3190 3190 sdkp->first_scan = 0; 3191 3191 3192 - set_capacity(disk, logical_to_sectors(sdp, sdkp->capacity)); 3192 + set_capacity_revalidate_and_notify(disk, 3193 + logical_to_sectors(sdp, sdkp->capacity), false); 3193 3194 sd_config_write_same(sdkp); 3194 3195 kfree(buffer); 3195 3196
+16 -4
fs/block_dev.c
··· 1520 1520 if (ret) 1521 1521 return ret; 1522 1522 1523 - if (invalidate) 1524 - set_capacity(disk, 0); 1525 - else if (disk->fops->revalidate_disk) 1526 - disk->fops->revalidate_disk(disk); 1523 + /* 1524 + * Historically we only set the capacity to zero for devices that 1525 + * support partitions (independ of actually having partitions created). 1526 + * Doing that is rather inconsistent, but changing it broke legacy 1527 + * udisks polling for legacy ide-cdrom devices. Use the crude check 1528 + * below to get the sane behavior for most device while not breaking 1529 + * userspace for this particular setup. 1530 + */ 1531 + if (invalidate) { 1532 + if (disk_part_scan_enabled(disk) || 1533 + !(disk->flags & GENHD_FL_REMOVABLE)) 1534 + set_capacity(disk, 0); 1535 + } else { 1536 + if (disk->fops->revalidate_disk) 1537 + disk->fops->revalidate_disk(disk); 1538 + } 1527 1539 1528 1540 check_disk_size_change(disk, bdev, !invalidate); 1529 1541
-43
fs/buffer.c
··· 3019 3019 bio_put(bio); 3020 3020 } 3021 3021 3022 - /* 3023 - * This allows us to do IO even on the odd last sectors 3024 - * of a device, even if the block size is some multiple 3025 - * of the physical sector size. 3026 - * 3027 - * We'll just truncate the bio to the size of the device, 3028 - * and clear the end of the buffer head manually. 3029 - * 3030 - * Truly out-of-range accesses will turn into actual IO 3031 - * errors, this only handles the "we need to be able to 3032 - * do IO at the final sector" case. 3033 - */ 3034 - void guard_bio_eod(struct bio *bio) 3035 - { 3036 - sector_t maxsector; 3037 - struct hd_struct *part; 3038 - 3039 - rcu_read_lock(); 3040 - part = __disk_get_part(bio->bi_disk, bio->bi_partno); 3041 - if (part) 3042 - maxsector = part_nr_sects_read(part); 3043 - else 3044 - maxsector = get_capacity(bio->bi_disk); 3045 - rcu_read_unlock(); 3046 - 3047 - if (!maxsector) 3048 - return; 3049 - 3050 - /* 3051 - * If the *whole* IO is past the end of the device, 3052 - * let it through, and the IO layer will turn it into 3053 - * an EIO. 3054 - */ 3055 - if (unlikely(bio->bi_iter.bi_sector >= maxsector)) 3056 - return; 3057 - 3058 - maxsector -= bio->bi_iter.bi_sector; 3059 - if (likely((bio->bi_iter.bi_size >> 9) <= maxsector)) 3060 - return; 3061 - 3062 - bio_truncate(bio, maxsector << 9); 3063 - } 3064 - 3065 3022 static int submit_bh_wbc(int op, int op_flags, struct buffer_head *bh, 3066 3023 enum rw_hint write_hint, struct writeback_control *wbc) 3067 3024 {
+4 -4
fs/ext4/super.c
··· 43 43 #include <linux/uaccess.h> 44 44 #include <linux/iversion.h> 45 45 #include <linux/unicode.h> 46 - 46 + #include <linux/part_stat.h> 47 47 #include <linux/kthread.h> 48 48 #include <linux/freezer.h> 49 49 ··· 927 927 static struct block_device *ext4_blkdev_get(dev_t dev, struct super_block *sb) 928 928 { 929 929 struct block_device *bdev; 930 - char b[BDEVNAME_SIZE]; 931 930 932 931 bdev = blkdev_get_by_dev(dev, FMODE_READ|FMODE_WRITE|FMODE_EXCL, sb); 933 932 if (IS_ERR(bdev)) ··· 934 935 return bdev; 935 936 936 937 fail: 937 - ext4_msg(sb, KERN_ERR, "failed to open journal device %s: %ld", 938 - __bdevname(dev, b), PTR_ERR(bdev)); 938 + ext4_msg(sb, KERN_ERR, 939 + "failed to open journal device unknown-block(%u,%u) %ld", 940 + MAJOR(dev), MINOR(dev), PTR_ERR(bdev)); 939 941 return NULL; 940 942 } 941 943
+1
fs/ext4/sysfs.c
··· 13 13 #include <linux/seq_file.h> 14 14 #include <linux/slab.h> 15 15 #include <linux/proc_fs.h> 16 + #include <linux/part_stat.h> 16 17 17 18 #include "ext4.h" 18 19 #include "ext4_jbd2.h"
+1
fs/f2fs/f2fs.h
··· 22 22 #include <linux/bio.h> 23 23 #include <linux/blkdev.h> 24 24 #include <linux/quotaops.h> 25 + #include <linux/part_stat.h> 25 26 #include <crypto/hash.h> 26 27 27 28 #include <linux/fscrypt.h>
+1
fs/f2fs/super.c
··· 24 24 #include <linux/sysfs.h> 25 25 #include <linux/quota.h> 26 26 #include <linux/unicode.h> 27 + #include <linux/part_stat.h> 27 28 28 29 #include "f2fs.h" 29 30 #include "node.h"
-1
fs/internal.h
··· 38 38 /* 39 39 * buffer.c 40 40 */ 41 - extern void guard_bio_eod(struct bio *bio); 42 41 extern int __block_write_begin_int(struct page *page, loff_t pos, unsigned len, 43 42 get_block_t *get_block, struct iomap *iomap); 44 43
+2 -3
fs/reiserfs/journal.c
··· 2599 2599 int result; 2600 2600 dev_t jdev; 2601 2601 fmode_t blkdev_mode = FMODE_READ | FMODE_WRITE | FMODE_EXCL; 2602 - char b[BDEVNAME_SIZE]; 2603 2602 2604 2603 result = 0; 2605 2604 ··· 2620 2621 result = PTR_ERR(journal->j_dev_bd); 2621 2622 journal->j_dev_bd = NULL; 2622 2623 reiserfs_warning(super, "sh-458", 2623 - "cannot init journal device '%s': %i", 2624 - __bdevname(jdev, b), result); 2624 + "cannot init journal device unknown-block(%u,%u): %i", 2625 + MAJOR(jdev), MINOR(jdev), result); 2625 2626 return result; 2626 2627 } else if (jdev != super->s_dev) 2627 2628 set_blocksize(journal->j_dev_bd, super->s_blocksize);
+1 -14
include/linux/bio.h
··· 441 441 unsigned int len, unsigned int off); 442 442 int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter); 443 443 void bio_release_pages(struct bio *bio, bool mark_dirty); 444 - struct rq_map_data; 445 - extern struct bio *bio_map_user_iov(struct request_queue *, 446 - struct iov_iter *, gfp_t); 447 - extern void bio_unmap_user(struct bio *); 448 - extern struct bio *bio_map_kern(struct request_queue *, void *, unsigned int, 449 - gfp_t); 450 - extern struct bio *bio_copy_kern(struct request_queue *, void *, unsigned int, 451 - gfp_t, int); 452 444 extern void bio_set_pages_dirty(struct bio *bio); 453 445 extern void bio_check_pages_dirty(struct bio *bio); 454 446 ··· 455 463 extern void bio_copy_data(struct bio *dst, struct bio *src); 456 464 extern void bio_list_copy_data(struct bio *dst, struct bio *src); 457 465 extern void bio_free_pages(struct bio *bio); 458 - 459 - extern struct bio *bio_copy_user_iov(struct request_queue *, 460 - struct rq_map_data *, 461 - struct iov_iter *, 462 - gfp_t); 463 - extern int bio_uncopy_user(struct bio *); 464 466 void zero_fill_bio_iter(struct bio *bio, struct bvec_iter iter); 465 467 void bio_truncate(struct bio *bio, unsigned new_size); 468 + void guard_bio_eod(struct bio *bio); 466 469 467 470 static inline void zero_fill_bio(struct bio *bio) 468 471 {
+6 -1
include/linux/blk-mq.h
··· 162 162 struct dentry *sched_debugfs_dir; 163 163 #endif 164 164 165 - /** @hctx_list: List of all hardware queues. */ 165 + /** 166 + * @hctx_list: if this hctx is not in use, this is an entry in 167 + * q->unused_hctx_list. 168 + */ 166 169 struct list_head hctx_list; 167 170 168 171 /** ··· 412 409 << BLK_MQ_F_ALLOC_POLICY_START_BIT) 413 410 414 411 struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *); 412 + struct request_queue *blk_mq_init_queue_data(struct blk_mq_tag_set *set, 413 + void *queuedata); 415 414 struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, 416 415 struct request_queue *q, 417 416 bool elevator_init);
+2 -12
include/linux/blkdev.h
··· 1063 1063 * Access functions for manipulating queue properties 1064 1064 */ 1065 1065 extern void blk_cleanup_queue(struct request_queue *); 1066 - extern void blk_queue_make_request(struct request_queue *, make_request_fn *); 1067 1066 extern void blk_queue_bounce_limit(struct request_queue *, u64); 1068 1067 extern void blk_queue_max_hw_sectors(struct request_queue *, unsigned int); 1069 1068 extern void blk_queue_chunk_sectors(struct request_queue *, unsigned int); ··· 1139 1140 extern long nr_blockdev_pages(void); 1140 1141 1141 1142 bool __must_check blk_get_queue(struct request_queue *); 1142 - struct request_queue *blk_alloc_queue(gfp_t); 1143 - struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id); 1143 + struct request_queue *blk_alloc_queue(make_request_fn make_request, int node_id); 1144 1144 extern void blk_put_queue(struct request_queue *); 1145 1145 extern void blk_set_queue_dying(struct request_queue *); 1146 1146 ··· 1482 1484 return bdev->bd_block_size; 1483 1485 } 1484 1486 1485 - typedef struct {struct page *v;} Sector; 1486 - 1487 - unsigned char *read_dev_sector(struct block_device *, sector_t, Sector *); 1488 - 1489 - static inline void put_dev_sector(Sector p) 1490 - { 1491 - put_page(p.v); 1492 - } 1493 - 1494 1487 int kblockd_schedule_work(struct work_struct *work); 1495 1488 int kblockd_mod_delayed_work_on(int cpu, struct delayed_work *dwork, unsigned long delay); 1496 1489 ··· 1695 1706 void (*swap_slot_free_notify) (struct block_device *, unsigned long); 1696 1707 int (*report_zones)(struct gendisk *, sector_t sector, 1697 1708 unsigned int nr_zones, report_zones_cb cb, void *data); 1709 + char *(*devnode)(struct gendisk *disk, umode_t *mode); 1698 1710 struct module *owner; 1699 1711 const struct pr_ops *pr_ops; 1700 1712 };
-1
include/linux/fs.h
··· 2700 2700 2701 2701 #ifdef CONFIG_BLOCK 2702 2702 #define BLKDEV_MAJOR_MAX 512 2703 - extern const char *__bdevname(dev_t, char *buffer); 2704 2703 extern const char *bdevname(struct block_device *bdev, char *buffer); 2705 2704 extern struct block_device *lookup_bdev(const char *); 2706 2705 extern void blkdev_show(struct seq_file *,off_t);
+61 -462
include/linux/genhd.h
··· 27 27 #define part_to_dev(part) (&((part)->__dev)) 28 28 29 29 extern struct device_type part_type; 30 - extern struct kobject *block_depr; 31 30 extern struct class block_class; 32 - 33 - enum { 34 - /* These three have identical behaviour; use the second one if DOS FDISK gets 35 - confused about extended/logical partitions starting past cylinder 1023. */ 36 - DOS_EXTENDED_PARTITION = 5, 37 - LINUX_EXTENDED_PARTITION = 0x85, 38 - WIN98_EXTENDED_PARTITION = 0x0f, 39 - 40 - SUN_WHOLE_DISK = DOS_EXTENDED_PARTITION, 41 - 42 - LINUX_SWAP_PARTITION = 0x82, 43 - LINUX_DATA_PARTITION = 0x83, 44 - LINUX_LVM_PARTITION = 0x8e, 45 - LINUX_RAID_PARTITION = 0xfd, /* autodetect RAID partition */ 46 - 47 - SOLARIS_X86_PARTITION = LINUX_SWAP_PARTITION, 48 - NEW_SOLARIS_X86_PARTITION = 0xbf, 49 - 50 - DM6_AUX1PARTITION = 0x51, /* no DDO: use xlated geom */ 51 - DM6_AUX3PARTITION = 0x53, /* no DDO: use xlated geom */ 52 - DM6_PARTITION = 0x54, /* has DDO: use xlated geom & offset */ 53 - EZD_PARTITION = 0x55, /* EZ-DRIVE */ 54 - 55 - FREEBSD_PARTITION = 0xa5, /* FreeBSD Partition ID */ 56 - OPENBSD_PARTITION = 0xa6, /* OpenBSD Partition ID */ 57 - NETBSD_PARTITION = 0xa9, /* NetBSD Partition ID */ 58 - BSDI_PARTITION = 0xb7, /* BSDI Partition ID */ 59 - MINIX_PARTITION = 0x81, /* Minix Partition ID */ 60 - UNIXWARE_PARTITION = 0x63, /* Same as GNU_HURD and SCO Unix */ 61 - }; 62 31 63 32 #define DISK_MAX_PARTS 256 64 33 #define DISK_NAME_LEN 32 ··· 39 70 #include <linux/fs.h> 40 71 #include <linux/workqueue.h> 41 72 42 - struct partition { 43 - unsigned char boot_ind; /* 0x80 - active */ 44 - unsigned char head; /* starting head */ 45 - unsigned char sector; /* starting sector */ 46 - unsigned char cyl; /* starting cylinder */ 47 - unsigned char sys_ind; /* What partition type */ 48 - unsigned char end_head; /* end head */ 49 - unsigned char end_sector; /* end sector */ 50 - unsigned char end_cyl; /* end cylinder */ 51 - __le32 start_sect; /* starting sector counting from 0 */ 52 - __le32 nr_sects; /* nr of sectors in partition */ 53 - } __attribute__((packed)); 54 - 55 73 struct disk_stats { 56 74 u64 nsecs[NR_STAT_GROUPS]; 57 75 unsigned long sectors[NR_STAT_GROUPS]; 58 76 unsigned long ios[NR_STAT_GROUPS]; 59 77 unsigned long merges[NR_STAT_GROUPS]; 60 78 unsigned long io_ticks; 61 - unsigned long time_in_queue; 62 79 local_t in_flight[2]; 63 80 }; 64 81 ··· 88 133 struct rcu_work rcu_work; 89 134 }; 90 135 91 - #define GENHD_FL_REMOVABLE 1 92 - /* 2 is unused */ 93 - #define GENHD_FL_MEDIA_CHANGE_NOTIFY 4 94 - #define GENHD_FL_CD 8 95 - #define GENHD_FL_UP 16 96 - #define GENHD_FL_SUPPRESS_PARTITION_INFO 32 97 - #define GENHD_FL_EXT_DEVT 64 /* allow extended devt */ 98 - #define GENHD_FL_NATIVE_CAPACITY 128 99 - #define GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE 256 100 - #define GENHD_FL_NO_PART_SCAN 512 101 - #define GENHD_FL_HIDDEN 1024 136 + /** 137 + * DOC: genhd capability flags 138 + * 139 + * ``GENHD_FL_REMOVABLE`` (0x0001): indicates that the block device 140 + * gives access to removable media. 141 + * When set, the device remains present even when media is not 142 + * inserted. 143 + * Must not be set for devices which are removed entirely when the 144 + * media is removed. 145 + * 146 + * ``GENHD_FL_CD`` (0x0008): the block device is a CD-ROM-style 147 + * device. 148 + * Affects responses to the ``CDROM_GET_CAPABILITY`` ioctl. 149 + * 150 + * ``GENHD_FL_UP`` (0x0010): indicates that the block device is "up", 151 + * with a similar meaning to network interfaces. 152 + * 153 + * ``GENHD_FL_SUPPRESS_PARTITION_INFO`` (0x0020): don't include 154 + * partition information in ``/proc/partitions`` or in the output of 155 + * printk_all_partitions(). 156 + * Used for the null block device and some MMC devices. 157 + * 158 + * ``GENHD_FL_EXT_DEVT`` (0x0040): the driver supports extended 159 + * dynamic ``dev_t``, i.e. it wants extended device numbers 160 + * (``BLOCK_EXT_MAJOR``). 161 + * This affects the maximum number of partitions. 162 + * 163 + * ``GENHD_FL_NATIVE_CAPACITY`` (0x0080): based on information in the 164 + * partition table, the device's capacity has been extended to its 165 + * native capacity; i.e. the device has hidden capacity used by one 166 + * of the partitions (this is a flag used so that native capacity is 167 + * only ever unlocked once). 168 + * 169 + * ``GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE`` (0x0100): event polling is 170 + * blocked whenever a writer holds an exclusive lock. 171 + * 172 + * ``GENHD_FL_NO_PART_SCAN`` (0x0200): partition scanning is disabled. 173 + * Used for loop devices in their default settings and some MMC 174 + * devices. 175 + * 176 + * ``GENHD_FL_HIDDEN`` (0x0400): the block device is hidden; it 177 + * doesn't produce events, doesn't appear in sysfs, and doesn't have 178 + * an associated ``bdev``. 179 + * Implies ``GENHD_FL_SUPPRESS_PARTITION_INFO`` and 180 + * ``GENHD_FL_NO_PART_SCAN``. 181 + * Used for multipath devices. 182 + */ 183 + #define GENHD_FL_REMOVABLE 0x0001 184 + /* 2 is unused (used to be GENHD_FL_DRIVERFS) */ 185 + /* 4 is unused (used to be GENHD_FL_MEDIA_CHANGE_NOTIFY) */ 186 + #define GENHD_FL_CD 0x0008 187 + #define GENHD_FL_UP 0x0010 188 + #define GENHD_FL_SUPPRESS_PARTITION_INFO 0x0020 189 + #define GENHD_FL_EXT_DEVT 0x0040 190 + #define GENHD_FL_NATIVE_CAPACITY 0x0080 191 + #define GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE 0x0100 192 + #define GENHD_FL_NO_PART_SCAN 0x0200 193 + #define GENHD_FL_HIDDEN 0x0400 102 194 103 195 enum { 104 196 DISK_EVENT_MEDIA_CHANGE = 1 << 0, /* media changed */ ··· 191 189 * disks that can't be partitioned. */ 192 190 193 191 char disk_name[DISK_NAME_LEN]; /* name of major driver */ 194 - char *(*devnode)(struct gendisk *gd, umode_t *mode); 195 192 196 193 unsigned short events; /* supported events */ 197 194 unsigned short event_flags; /* flags related to event processing */ ··· 284 283 struct gendisk *disk, unsigned int flags); 285 284 extern struct hd_struct *disk_part_iter_next(struct disk_part_iter *piter); 286 285 extern void disk_part_iter_exit(struct disk_part_iter *piter); 287 - 288 - extern struct hd_struct *disk_map_sector_rcu(struct gendisk *disk, 289 - sector_t sector); 290 - bool disk_has_partitions(struct gendisk *disk); 291 - 292 - /* 293 - * Macros to operate on percpu disk statistics: 294 - * 295 - * {disk|part|all}_stat_{add|sub|inc|dec}() modify the stat counters 296 - * and should be called between disk_stat_lock() and 297 - * disk_stat_unlock(). 298 - * 299 - * part_stat_read() can be called at any time. 300 - * 301 - * part_stat_{add|set_all}() and {init|free}_part_stats are for 302 - * internal use only. 303 - */ 304 - #ifdef CONFIG_SMP 305 - #define part_stat_lock() ({ rcu_read_lock(); get_cpu(); }) 306 - #define part_stat_unlock() do { put_cpu(); rcu_read_unlock(); } while (0) 307 - 308 - #define part_stat_get_cpu(part, field, cpu) \ 309 - (per_cpu_ptr((part)->dkstats, (cpu))->field) 310 - 311 - #define part_stat_get(part, field) \ 312 - part_stat_get_cpu(part, field, smp_processor_id()) 313 - 314 - #define part_stat_read(part, field) \ 315 - ({ \ 316 - typeof((part)->dkstats->field) res = 0; \ 317 - unsigned int _cpu; \ 318 - for_each_possible_cpu(_cpu) \ 319 - res += per_cpu_ptr((part)->dkstats, _cpu)->field; \ 320 - res; \ 321 - }) 322 - 323 - static inline void part_stat_set_all(struct hd_struct *part, int value) 324 - { 325 - int i; 326 - 327 - for_each_possible_cpu(i) 328 - memset(per_cpu_ptr(part->dkstats, i), value, 329 - sizeof(struct disk_stats)); 330 - } 331 - 332 - static inline int init_part_stats(struct hd_struct *part) 333 - { 334 - part->dkstats = alloc_percpu(struct disk_stats); 335 - if (!part->dkstats) 336 - return 0; 337 - return 1; 338 - } 339 - 340 - static inline void free_part_stats(struct hd_struct *part) 341 - { 342 - free_percpu(part->dkstats); 343 - } 344 - 345 - #else /* !CONFIG_SMP */ 346 - #define part_stat_lock() ({ rcu_read_lock(); 0; }) 347 - #define part_stat_unlock() rcu_read_unlock() 348 - 349 - #define part_stat_get(part, field) ((part)->dkstats.field) 350 - #define part_stat_get_cpu(part, field, cpu) part_stat_get(part, field) 351 - #define part_stat_read(part, field) part_stat_get(part, field) 352 - 353 - static inline void part_stat_set_all(struct hd_struct *part, int value) 354 - { 355 - memset(&part->dkstats, value, sizeof(struct disk_stats)); 356 - } 357 - 358 - static inline int init_part_stats(struct hd_struct *part) 359 - { 360 - return 1; 361 - } 362 - 363 - static inline void free_part_stats(struct hd_struct *part) 364 - { 365 - } 366 - 367 - #endif /* CONFIG_SMP */ 368 - 369 - #define part_stat_read_msecs(part, which) \ 370 - div_u64(part_stat_read(part, nsecs[which]), NSEC_PER_MSEC) 371 - 372 - #define part_stat_read_accum(part, field) \ 373 - (part_stat_read(part, field[STAT_READ]) + \ 374 - part_stat_read(part, field[STAT_WRITE]) + \ 375 - part_stat_read(part, field[STAT_DISCARD])) 376 - 377 - #define __part_stat_add(part, field, addnd) \ 378 - (part_stat_get(part, field) += (addnd)) 379 - 380 - #define part_stat_add(part, field, addnd) do { \ 381 - __part_stat_add((part), field, addnd); \ 382 - if ((part)->partno) \ 383 - __part_stat_add(&part_to_disk((part))->part0, \ 384 - field, addnd); \ 385 - } while (0) 386 - 387 - #define part_stat_dec(gendiskp, field) \ 388 - part_stat_add(gendiskp, field, -1) 389 - #define part_stat_inc(gendiskp, field) \ 390 - part_stat_add(gendiskp, field, 1) 391 - #define part_stat_sub(gendiskp, field, subnd) \ 392 - part_stat_add(gendiskp, field, -subnd) 393 - 394 - #define part_stat_local_dec(gendiskp, field) \ 395 - local_dec(&(part_stat_get(gendiskp, field))) 396 - #define part_stat_local_inc(gendiskp, field) \ 397 - local_inc(&(part_stat_get(gendiskp, field))) 398 - #define part_stat_local_read(gendiskp, field) \ 399 - local_read(&(part_stat_get(gendiskp, field))) 400 - #define part_stat_local_read_cpu(gendiskp, field, cpu) \ 401 - local_read(&(part_stat_get_cpu(gendiskp, field, cpu))) 402 - 403 - unsigned int part_in_flight(struct request_queue *q, struct hd_struct *part); 404 - void part_in_flight_rw(struct request_queue *q, struct hd_struct *part, 405 - unsigned int inflight[2]); 406 - void part_dec_in_flight(struct request_queue *q, struct hd_struct *part, 407 - int rw); 408 - void part_inc_in_flight(struct request_queue *q, struct hd_struct *part, 409 - int rw); 410 - 411 - static inline struct partition_meta_info *alloc_part_info(struct gendisk *disk) 412 - { 413 - if (disk) 414 - return kzalloc_node(sizeof(struct partition_meta_info), 415 - GFP_KERNEL, disk->node_id); 416 - return kzalloc(sizeof(struct partition_meta_info), GFP_KERNEL); 417 - } 418 - 419 - static inline void free_part_info(struct hd_struct *part) 420 - { 421 - kfree(part->info); 422 - } 423 - 424 - void update_io_ticks(struct hd_struct *part, unsigned long now); 286 + extern bool disk_has_partitions(struct gendisk *disk); 425 287 426 288 /* block/genhd.c */ 427 289 extern void device_add_disk(struct device *parent, struct gendisk *disk, ··· 314 450 extern void disk_block_events(struct gendisk *disk); 315 451 extern void disk_unblock_events(struct gendisk *disk); 316 452 extern void disk_flush_events(struct gendisk *disk, unsigned int mask); 453 + extern void set_capacity_revalidate_and_notify(struct gendisk *disk, 454 + sector_t size, bool revalidate); 317 455 extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask); 318 456 319 457 /* drivers/char/random.c */ ··· 335 469 disk->part0.nr_sects = size; 336 470 } 337 471 338 - #ifdef CONFIG_SOLARIS_X86_PARTITION 339 - 340 - #define SOLARIS_X86_NUMSLICE 16 341 - #define SOLARIS_X86_VTOC_SANE (0x600DDEEEUL) 342 - 343 - struct solaris_x86_slice { 344 - __le16 s_tag; /* ID tag of partition */ 345 - __le16 s_flag; /* permission flags */ 346 - __le32 s_start; /* start sector no of partition */ 347 - __le32 s_size; /* # of blocks in partition */ 348 - }; 349 - 350 - struct solaris_x86_vtoc { 351 - unsigned int v_bootinfo[3]; /* info needed by mboot (unsupported) */ 352 - __le32 v_sanity; /* to verify vtoc sanity */ 353 - __le32 v_version; /* layout version */ 354 - char v_volume[8]; /* volume name */ 355 - __le16 v_sectorsz; /* sector size in bytes */ 356 - __le16 v_nparts; /* number of partitions */ 357 - unsigned int v_reserved[10]; /* free space */ 358 - struct solaris_x86_slice 359 - v_slice[SOLARIS_X86_NUMSLICE]; /* slice headers */ 360 - unsigned int timestamp[SOLARIS_X86_NUMSLICE]; /* timestamp (unsupported) */ 361 - char v_asciilabel[128]; /* for compatibility */ 362 - }; 363 - 364 - #endif /* CONFIG_SOLARIS_X86_PARTITION */ 365 - 366 - #ifdef CONFIG_BSD_DISKLABEL 367 - /* 368 - * BSD disklabel support by Yossi Gottlieb <yogo@math.tau.ac.il> 369 - * updated by Marc Espie <Marc.Espie@openbsd.org> 370 - */ 371 - 372 - /* check against BSD src/sys/sys/disklabel.h for consistency */ 373 - 374 - #define BSD_DISKMAGIC (0x82564557UL) /* The disk magic number */ 375 - #define BSD_MAXPARTITIONS 16 376 - #define OPENBSD_MAXPARTITIONS 16 377 - #define BSD_FS_UNUSED 0 /* disklabel unused partition entry ID */ 378 - struct bsd_disklabel { 379 - __le32 d_magic; /* the magic number */ 380 - __s16 d_type; /* drive type */ 381 - __s16 d_subtype; /* controller/d_type specific */ 382 - char d_typename[16]; /* type name, e.g. "eagle" */ 383 - char d_packname[16]; /* pack identifier */ 384 - __u32 d_secsize; /* # of bytes per sector */ 385 - __u32 d_nsectors; /* # of data sectors per track */ 386 - __u32 d_ntracks; /* # of tracks per cylinder */ 387 - __u32 d_ncylinders; /* # of data cylinders per unit */ 388 - __u32 d_secpercyl; /* # of data sectors per cylinder */ 389 - __u32 d_secperunit; /* # of data sectors per unit */ 390 - __u16 d_sparespertrack; /* # of spare sectors per track */ 391 - __u16 d_sparespercyl; /* # of spare sectors per cylinder */ 392 - __u32 d_acylinders; /* # of alt. cylinders per unit */ 393 - __u16 d_rpm; /* rotational speed */ 394 - __u16 d_interleave; /* hardware sector interleave */ 395 - __u16 d_trackskew; /* sector 0 skew, per track */ 396 - __u16 d_cylskew; /* sector 0 skew, per cylinder */ 397 - __u32 d_headswitch; /* head switch time, usec */ 398 - __u32 d_trkseek; /* track-to-track seek, usec */ 399 - __u32 d_flags; /* generic flags */ 400 - #define NDDATA 5 401 - __u32 d_drivedata[NDDATA]; /* drive-type specific information */ 402 - #define NSPARE 5 403 - __u32 d_spare[NSPARE]; /* reserved for future use */ 404 - __le32 d_magic2; /* the magic number (again) */ 405 - __le16 d_checksum; /* xor of data incl. partitions */ 406 - 407 - /* filesystem and partition information: */ 408 - __le16 d_npartitions; /* number of partitions in following */ 409 - __le32 d_bbsize; /* size of boot area at sn0, bytes */ 410 - __le32 d_sbsize; /* max size of fs superblock, bytes */ 411 - struct bsd_partition { /* the partition table */ 412 - __le32 p_size; /* number of sectors in partition */ 413 - __le32 p_offset; /* starting sector */ 414 - __le32 p_fsize; /* filesystem basic fragment size */ 415 - __u8 p_fstype; /* filesystem type, see below */ 416 - __u8 p_frag; /* filesystem fragments per block */ 417 - __le16 p_cpg; /* filesystem cylinders per group */ 418 - } d_partitions[BSD_MAXPARTITIONS]; /* actually may be more */ 419 - }; 420 - 421 - #endif /* CONFIG_BSD_DISKLABEL */ 422 - 423 - #ifdef CONFIG_UNIXWARE_DISKLABEL 424 - /* 425 - * Unixware slices support by Andrzej Krzysztofowicz <ankry@mif.pg.gda.pl> 426 - * and Krzysztof G. Baranowski <kgb@knm.org.pl> 427 - */ 428 - 429 - #define UNIXWARE_DISKMAGIC (0xCA5E600DUL) /* The disk magic number */ 430 - #define UNIXWARE_DISKMAGIC2 (0x600DDEEEUL) /* The slice table magic nr */ 431 - #define UNIXWARE_NUMSLICE 16 432 - #define UNIXWARE_FS_UNUSED 0 /* Unused slice entry ID */ 433 - 434 - struct unixware_slice { 435 - __le16 s_label; /* label */ 436 - __le16 s_flags; /* permission flags */ 437 - __le32 start_sect; /* starting sector */ 438 - __le32 nr_sects; /* number of sectors in slice */ 439 - }; 440 - 441 - struct unixware_disklabel { 442 - __le32 d_type; /* drive type */ 443 - __le32 d_magic; /* the magic number */ 444 - __le32 d_version; /* version number */ 445 - char d_serial[12]; /* serial number of the device */ 446 - __le32 d_ncylinders; /* # of data cylinders per device */ 447 - __le32 d_ntracks; /* # of tracks per cylinder */ 448 - __le32 d_nsectors; /* # of data sectors per track */ 449 - __le32 d_secsize; /* # of bytes per sector */ 450 - __le32 d_part_start; /* # of first sector of this partition */ 451 - __le32 d_unknown1[12]; /* ? */ 452 - __le32 d_alt_tbl; /* byte offset of alternate table */ 453 - __le32 d_alt_len; /* byte length of alternate table */ 454 - __le32 d_phys_cyl; /* # of physical cylinders per device */ 455 - __le32 d_phys_trk; /* # of physical tracks per cylinder */ 456 - __le32 d_phys_sec; /* # of physical sectors per track */ 457 - __le32 d_phys_bytes; /* # of physical bytes per sector */ 458 - __le32 d_unknown2; /* ? */ 459 - __le32 d_unknown3; /* ? */ 460 - __le32 d_pad[8]; /* pad */ 461 - 462 - struct unixware_vtoc { 463 - __le32 v_magic; /* the magic number */ 464 - __le32 v_version; /* version number */ 465 - char v_name[8]; /* volume name */ 466 - __le16 v_nslices; /* # of slices */ 467 - __le16 v_unknown1; /* ? */ 468 - __le32 v_reserved[10]; /* reserved */ 469 - struct unixware_slice 470 - v_slice[UNIXWARE_NUMSLICE]; /* slice headers */ 471 - } vtoc; 472 - 473 - }; /* 408 */ 474 - 475 - #endif /* CONFIG_UNIXWARE_DISKLABEL */ 476 - 477 - #ifdef CONFIG_MINIX_SUBPARTITION 478 - # define MINIX_NR_SUBPARTITIONS 4 479 - #endif /* CONFIG_MINIX_SUBPARTITION */ 480 - 481 - #define ADDPART_FLAG_NONE 0 482 - #define ADDPART_FLAG_RAID 1 483 - #define ADDPART_FLAG_WHOLEDISK 2 484 - 485 - extern int blk_alloc_devt(struct hd_struct *part, dev_t *devt); 486 - extern void blk_free_devt(dev_t devt); 487 - extern void blk_invalidate_devt(dev_t devt); 488 472 extern dev_t blk_lookup_devt(const char *name, int partno); 489 - extern char *disk_name (struct gendisk *hd, int partno, char *buf); 490 473 491 474 int bdev_disk_changed(struct block_device *bdev, bool invalidate); 492 475 int blk_add_partitions(struct gendisk *disk, struct block_device *bdev); 493 476 int blk_drop_partitions(struct gendisk *disk, struct block_device *bdev); 494 - extern int disk_expand_part_tbl(struct gendisk *disk, int target); 495 - extern struct hd_struct * __must_check add_partition(struct gendisk *disk, 496 - int partno, sector_t start, 497 - sector_t len, int flags, 498 - struct partition_meta_info 499 - *info); 500 - extern void __delete_partition(struct percpu_ref *); 501 - extern void delete_partition(struct gendisk *, int); 502 477 extern void printk_all_partitions(void); 503 478 504 479 extern struct gendisk *__alloc_disk_node(int minors, int node_id); ··· 352 645 int (*lock)(dev_t, void *), 353 646 void *data); 354 647 extern void blk_unregister_region(dev_t devt, unsigned long range); 355 - 356 - extern ssize_t part_size_show(struct device *dev, 357 - struct device_attribute *attr, char *buf); 358 - extern ssize_t part_stat_show(struct device *dev, 359 - struct device_attribute *attr, char *buf); 360 - extern ssize_t part_inflight_show(struct device *dev, 361 - struct device_attribute *attr, char *buf); 362 - #ifdef CONFIG_FAIL_MAKE_REQUEST 363 - extern ssize_t part_fail_show(struct device *dev, 364 - struct device_attribute *attr, char *buf); 365 - extern ssize_t part_fail_store(struct device *dev, 366 - struct device_attribute *attr, 367 - const char *buf, size_t count); 368 - #endif /* CONFIG_FAIL_MAKE_REQUEST */ 369 648 370 649 #define alloc_disk_node(minors, node_id) \ 371 650 ({ \ ··· 370 677 }) 371 678 372 679 #define alloc_disk(minors) alloc_disk_node(minors, NUMA_NO_NODE) 373 - 374 - static inline int hd_ref_init(struct hd_struct *part) 375 - { 376 - if (percpu_ref_init(&part->ref, __delete_partition, 0, 377 - GFP_KERNEL)) 378 - return -ENOMEM; 379 - return 0; 380 - } 381 - 382 - static inline void hd_struct_get(struct hd_struct *part) 383 - { 384 - percpu_ref_get(&part->ref); 385 - } 386 - 387 - static inline int hd_struct_try_get(struct hd_struct *part) 388 - { 389 - return percpu_ref_tryget_live(&part->ref); 390 - } 391 - 392 - static inline void hd_struct_put(struct hd_struct *part) 393 - { 394 - percpu_ref_put(&part->ref); 395 - } 396 - 397 - static inline void hd_struct_kill(struct hd_struct *part) 398 - { 399 - percpu_ref_kill(&part->ref); 400 - } 401 - 402 - static inline void hd_free_part(struct hd_struct *part) 403 - { 404 - free_part_stats(part); 405 - free_part_info(part); 406 - percpu_ref_exit(&part->ref); 407 - } 408 - 409 - /* 410 - * Any access of part->nr_sects which is not protected by partition 411 - * bd_mutex or gendisk bdev bd_mutex, should be done using this 412 - * accessor function. 413 - * 414 - * Code written along the lines of i_size_read() and i_size_write(). 415 - * CONFIG_PREEMPTION case optimizes the case of UP kernel with preemption 416 - * on. 417 - */ 418 - static inline sector_t part_nr_sects_read(struct hd_struct *part) 419 - { 420 - #if BITS_PER_LONG==32 && defined(CONFIG_SMP) 421 - sector_t nr_sects; 422 - unsigned seq; 423 - do { 424 - seq = read_seqcount_begin(&part->nr_sects_seq); 425 - nr_sects = part->nr_sects; 426 - } while (read_seqcount_retry(&part->nr_sects_seq, seq)); 427 - return nr_sects; 428 - #elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPTION) 429 - sector_t nr_sects; 430 - 431 - preempt_disable(); 432 - nr_sects = part->nr_sects; 433 - preempt_enable(); 434 - return nr_sects; 435 - #else 436 - return part->nr_sects; 437 - #endif 438 - } 439 - 440 - /* 441 - * Should be called with mutex lock held (typically bd_mutex) of partition 442 - * to provide mutual exlusion among writers otherwise seqcount might be 443 - * left in wrong state leaving the readers spinning infinitely. 444 - */ 445 - static inline void part_nr_sects_write(struct hd_struct *part, sector_t size) 446 - { 447 - #if BITS_PER_LONG==32 && defined(CONFIG_SMP) 448 - write_seqcount_begin(&part->nr_sects_seq); 449 - part->nr_sects = size; 450 - write_seqcount_end(&part->nr_sects_seq); 451 - #elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPTION) 452 - preempt_disable(); 453 - part->nr_sects = size; 454 - preempt_enable(); 455 - #else 456 - part->nr_sects = size; 457 - #endif 458 - } 459 - 460 - #if defined(CONFIG_BLK_DEV_INTEGRITY) 461 - extern void blk_integrity_add(struct gendisk *); 462 - extern void blk_integrity_del(struct gendisk *); 463 - #else /* CONFIG_BLK_DEV_INTEGRITY */ 464 - static inline void blk_integrity_add(struct gendisk *disk) { } 465 - static inline void blk_integrity_del(struct gendisk *disk) { } 466 - #endif /* CONFIG_BLK_DEV_INTEGRITY */ 467 680 468 681 #else /* CONFIG_BLOCK */ 469 682
+1
include/linux/iocontext.h
··· 8 8 9 9 enum { 10 10 ICQ_EXITED = 1 << 2, 11 + ICQ_DESTROYED = 1 << 3, 11 12 }; 12 13 13 14 /*
+50
include/linux/msdos_partition.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _LINUX_MSDOS_PARTITION_H 3 + #define _LINUX_MSDOS_PARTITION_H 4 + 5 + #define MSDOS_LABEL_MAGIC 0xAA55 6 + 7 + struct msdos_partition { 8 + u8 boot_ind; /* 0x80 - active */ 9 + u8 head; /* starting head */ 10 + u8 sector; /* starting sector */ 11 + u8 cyl; /* starting cylinder */ 12 + u8 sys_ind; /* What partition type */ 13 + u8 end_head; /* end head */ 14 + u8 end_sector; /* end sector */ 15 + u8 end_cyl; /* end cylinder */ 16 + __le32 start_sect; /* starting sector counting from 0 */ 17 + __le32 nr_sects; /* nr of sectors in partition */ 18 + } __packed; 19 + 20 + enum msdos_sys_ind { 21 + /* 22 + * These three have identical behaviour; use the second one if DOS FDISK 23 + * gets confused about extended/logical partitions starting past 24 + * cylinder 1023. 25 + */ 26 + DOS_EXTENDED_PARTITION = 5, 27 + LINUX_EXTENDED_PARTITION = 0x85, 28 + WIN98_EXTENDED_PARTITION = 0x0f, 29 + 30 + LINUX_DATA_PARTITION = 0x83, 31 + LINUX_LVM_PARTITION = 0x8e, 32 + LINUX_RAID_PARTITION = 0xfd, /* autodetect RAID partition */ 33 + 34 + SOLARIS_X86_PARTITION = 0x82, /* also Linux swap partitions */ 35 + NEW_SOLARIS_X86_PARTITION = 0xbf, 36 + 37 + DM6_AUX1PARTITION = 0x51, /* no DDO: use xlated geom */ 38 + DM6_AUX3PARTITION = 0x53, /* no DDO: use xlated geom */ 39 + DM6_PARTITION = 0x54, /* has DDO: use xlated geom & offset */ 40 + EZD_PARTITION = 0x55, /* EZ-DRIVE */ 41 + 42 + FREEBSD_PARTITION = 0xa5, /* FreeBSD Partition ID */ 43 + OPENBSD_PARTITION = 0xa6, /* OpenBSD Partition ID */ 44 + NETBSD_PARTITION = 0xa9, /* NetBSD Partition ID */ 45 + BSDI_PARTITION = 0xb7, /* BSDI Partition ID */ 46 + MINIX_PARTITION = 0x81, /* Minix Partition ID */ 47 + UNIXWARE_PARTITION = 0x63, /* Same as GNU_HURD and SCO Unix */ 48 + }; 49 + 50 + #endif /* LINUX_MSDOS_PARTITION_H */
+115
include/linux/part_stat.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _LINUX_PART_STAT_H 3 + #define _LINUX_PART_STAT_H 4 + 5 + #include <linux/genhd.h> 6 + 7 + /* 8 + * Macros to operate on percpu disk statistics: 9 + * 10 + * {disk|part|all}_stat_{add|sub|inc|dec}() modify the stat counters 11 + * and should be called between disk_stat_lock() and 12 + * disk_stat_unlock(). 13 + * 14 + * part_stat_read() can be called at any time. 15 + * 16 + * part_stat_{add|set_all}() and {init|free}_part_stats are for 17 + * internal use only. 18 + */ 19 + #ifdef CONFIG_SMP 20 + #define part_stat_lock() ({ rcu_read_lock(); get_cpu(); }) 21 + #define part_stat_unlock() do { put_cpu(); rcu_read_unlock(); } while (0) 22 + 23 + #define part_stat_get_cpu(part, field, cpu) \ 24 + (per_cpu_ptr((part)->dkstats, (cpu))->field) 25 + 26 + #define part_stat_get(part, field) \ 27 + part_stat_get_cpu(part, field, smp_processor_id()) 28 + 29 + #define part_stat_read(part, field) \ 30 + ({ \ 31 + typeof((part)->dkstats->field) res = 0; \ 32 + unsigned int _cpu; \ 33 + for_each_possible_cpu(_cpu) \ 34 + res += per_cpu_ptr((part)->dkstats, _cpu)->field; \ 35 + res; \ 36 + }) 37 + 38 + static inline void part_stat_set_all(struct hd_struct *part, int value) 39 + { 40 + int i; 41 + 42 + for_each_possible_cpu(i) 43 + memset(per_cpu_ptr(part->dkstats, i), value, 44 + sizeof(struct disk_stats)); 45 + } 46 + 47 + static inline int init_part_stats(struct hd_struct *part) 48 + { 49 + part->dkstats = alloc_percpu(struct disk_stats); 50 + if (!part->dkstats) 51 + return 0; 52 + return 1; 53 + } 54 + 55 + static inline void free_part_stats(struct hd_struct *part) 56 + { 57 + free_percpu(part->dkstats); 58 + } 59 + 60 + #else /* !CONFIG_SMP */ 61 + #define part_stat_lock() ({ rcu_read_lock(); 0; }) 62 + #define part_stat_unlock() rcu_read_unlock() 63 + 64 + #define part_stat_get(part, field) ((part)->dkstats.field) 65 + #define part_stat_get_cpu(part, field, cpu) part_stat_get(part, field) 66 + #define part_stat_read(part, field) part_stat_get(part, field) 67 + 68 + static inline void part_stat_set_all(struct hd_struct *part, int value) 69 + { 70 + memset(&part->dkstats, value, sizeof(struct disk_stats)); 71 + } 72 + 73 + static inline int init_part_stats(struct hd_struct *part) 74 + { 75 + return 1; 76 + } 77 + 78 + static inline void free_part_stats(struct hd_struct *part) 79 + { 80 + } 81 + 82 + #endif /* CONFIG_SMP */ 83 + 84 + #define part_stat_read_accum(part, field) \ 85 + (part_stat_read(part, field[STAT_READ]) + \ 86 + part_stat_read(part, field[STAT_WRITE]) + \ 87 + part_stat_read(part, field[STAT_DISCARD])) 88 + 89 + #define __part_stat_add(part, field, addnd) \ 90 + (part_stat_get(part, field) += (addnd)) 91 + 92 + #define part_stat_add(part, field, addnd) do { \ 93 + __part_stat_add((part), field, addnd); \ 94 + if ((part)->partno) \ 95 + __part_stat_add(&part_to_disk((part))->part0, \ 96 + field, addnd); \ 97 + } while (0) 98 + 99 + #define part_stat_dec(gendiskp, field) \ 100 + part_stat_add(gendiskp, field, -1) 101 + #define part_stat_inc(gendiskp, field) \ 102 + part_stat_add(gendiskp, field, 1) 103 + #define part_stat_sub(gendiskp, field, subnd) \ 104 + part_stat_add(gendiskp, field, -subnd) 105 + 106 + #define part_stat_local_dec(gendiskp, field) \ 107 + local_dec(&(part_stat_get(gendiskp, field))) 108 + #define part_stat_local_inc(gendiskp, field) \ 109 + local_inc(&(part_stat_get(gendiskp, field))) 110 + #define part_stat_local_read(gendiskp, field) \ 111 + local_read(&(part_stat_get(gendiskp, field))) 112 + #define part_stat_local_read_cpu(gendiskp, field, cpu) \ 113 + local_read(&(part_stat_get_cpu(gendiskp, field, cpu))) 114 + 115 + #endif /* _LINUX_PART_STAT_H */
+3
include/linux/raid/detect.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + 3 + void md_autodetect_dev(dev_t dev);
+3 -4
include/scsi/scsicam.h
··· 13 13 14 14 #ifndef SCSICAM_H 15 15 #define SCSICAM_H 16 - extern int scsicam_bios_param (struct block_device *bdev, sector_t capacity, int *ip); 17 - extern int scsi_partsize(unsigned char *buf, unsigned long capacity, 18 - unsigned int *cyls, unsigned int *hds, unsigned int *secs); 19 - extern unsigned char *scsi_bios_ptable(struct block_device *bdev); 16 + int scsicam_bios_param(struct block_device *bdev, sector_t capacity, int *ip); 17 + bool scsi_partsize(struct block_device *bdev, sector_t capacity, int geom[3]); 18 + unsigned char *scsi_bios_ptable(struct block_device *bdev); 20 19 #endif /* def SCSICAM_H */
+2 -10
init/do_mounts.c
··· 429 429 struct page *page = alloc_page(GFP_KERNEL); 430 430 char *fs_names = page_address(page); 431 431 char *p; 432 - #ifdef CONFIG_BLOCK 433 432 char b[BDEVNAME_SIZE]; 434 - #else 435 - const char *b = name; 436 - #endif 437 433 434 + scnprintf(b, BDEVNAME_SIZE, "unknown-block(%u,%u)", 435 + MAJOR(ROOT_DEV), MINOR(ROOT_DEV)); 438 436 get_fs_names(fs_names); 439 437 retry: 440 438 for (p = fs_names; *p; p += strlen(p)+1) { ··· 449 451 * and bad superblock on root device. 450 452 * and give them a list of the available devices 451 453 */ 452 - #ifdef CONFIG_BLOCK 453 - __bdevname(ROOT_DEV, b); 454 - #endif 455 454 printk("VFS: Cannot open root device \"%s\" or %s: error %d\n", 456 455 root_device_name, b, err); 457 456 printk("Please append a correct \"root=\" boot option; here are the available partitions:\n"); ··· 471 476 for (p = fs_names; *p; p += strlen(p)+1) 472 477 printk(" %s", p); 473 478 printk("\n"); 474 - #ifdef CONFIG_BLOCK 475 - __bdevname(ROOT_DEV, b); 476 - #endif 477 479 panic("VFS: Unable to mount root fs on %s", b); 478 480 out: 479 481 put_page(page);