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

Configure Feed

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

Merge tag 'block-6.6-2023-09-08' of git://git.kernel.dk/linux

Pull block fixes from Jens Axboe:

- Fix null_blk polled IO timeout handling (Chengming)

- Regression fix for swapped arguments in drbd bvec_set_page()
(Christoph)

- String length handling fix for s390 dasd (Heiko)

- Fixes for blk-throttle accounting (Yu)

- Fix page pinning issue for same page segments (Christoph)

- Remove redundant file_remove_privs() call (Christoph)

- Fix a regression in partition handling for devices not supporting
partitions (Li)

* tag 'block-6.6-2023-09-08' of git://git.kernel.dk/linux:
drbd: swap bvec_set_page len and offset
block: fix pin count management when merging same-page segments
null_blk: fix poll request timeout handling
s390/dasd: fix string length handling
block: don't add or resize partition on the disk with GENHD_FL_NO_PART
block: remove the call to file_remove_privs in blkdev_write_iter
blk-throttle: consider 'carryover_ios/bytes' in throtl_trim_slice()
blk-throttle: use calculate_io/bytes_allowed() for throtl_trim_slice()
blk-throttle: fix wrong comparation while 'carryover_ios/bytes' is negative
blk-throttle: print signed value 'carryover_bytes/ios' for user

+95 -90
+3 -4
block/blk-map.c
··· 315 315 n = bytes; 316 316 317 317 if (!bio_add_hw_page(rq->q, bio, page, n, offs, 318 - max_sectors, &same_page)) { 319 - if (same_page) 320 - bio_release_page(bio, page); 318 + max_sectors, &same_page)) 321 319 break; 322 - } 323 320 321 + if (same_page) 322 + bio_release_page(bio, page); 324 323 bytes -= n; 325 324 offs = 0; 326 325 }
+67 -67
block/blk-throttle.c
··· 697 697 return true; 698 698 } 699 699 700 - /* Trim the used slices and adjust slice start accordingly */ 701 - static inline void throtl_trim_slice(struct throtl_grp *tg, bool rw) 702 - { 703 - unsigned long nr_slices, time_elapsed, io_trim; 704 - u64 bytes_trim, tmp; 705 - 706 - BUG_ON(time_before(tg->slice_end[rw], tg->slice_start[rw])); 707 - 708 - /* 709 - * If bps are unlimited (-1), then time slice don't get 710 - * renewed. Don't try to trim the slice if slice is used. A new 711 - * slice will start when appropriate. 712 - */ 713 - if (throtl_slice_used(tg, rw)) 714 - return; 715 - 716 - /* 717 - * A bio has been dispatched. Also adjust slice_end. It might happen 718 - * that initially cgroup limit was very low resulting in high 719 - * slice_end, but later limit was bumped up and bio was dispatched 720 - * sooner, then we need to reduce slice_end. A high bogus slice_end 721 - * is bad because it does not allow new slice to start. 722 - */ 723 - 724 - throtl_set_slice_end(tg, rw, jiffies + tg->td->throtl_slice); 725 - 726 - time_elapsed = jiffies - tg->slice_start[rw]; 727 - 728 - nr_slices = time_elapsed / tg->td->throtl_slice; 729 - 730 - if (!nr_slices) 731 - return; 732 - tmp = tg_bps_limit(tg, rw) * tg->td->throtl_slice * nr_slices; 733 - do_div(tmp, HZ); 734 - bytes_trim = tmp; 735 - 736 - io_trim = (tg_iops_limit(tg, rw) * tg->td->throtl_slice * nr_slices) / 737 - HZ; 738 - 739 - if (!bytes_trim && !io_trim) 740 - return; 741 - 742 - if (tg->bytes_disp[rw] >= bytes_trim) 743 - tg->bytes_disp[rw] -= bytes_trim; 744 - else 745 - tg->bytes_disp[rw] = 0; 746 - 747 - if (tg->io_disp[rw] >= io_trim) 748 - tg->io_disp[rw] -= io_trim; 749 - else 750 - tg->io_disp[rw] = 0; 751 - 752 - tg->slice_start[rw] += nr_slices * tg->td->throtl_slice; 753 - 754 - throtl_log(&tg->service_queue, 755 - "[%c] trim slice nr=%lu bytes=%llu io=%lu start=%lu end=%lu jiffies=%lu", 756 - rw == READ ? 'R' : 'W', nr_slices, bytes_trim, io_trim, 757 - tg->slice_start[rw], tg->slice_end[rw], jiffies); 758 - } 759 - 760 700 static unsigned int calculate_io_allowed(u32 iops_limit, 761 701 unsigned long jiffy_elapsed) 762 702 { ··· 724 784 static u64 calculate_bytes_allowed(u64 bps_limit, unsigned long jiffy_elapsed) 725 785 { 726 786 return mul_u64_u64_div_u64(bps_limit, (u64)jiffy_elapsed, (u64)HZ); 787 + } 788 + 789 + /* Trim the used slices and adjust slice start accordingly */ 790 + static inline void throtl_trim_slice(struct throtl_grp *tg, bool rw) 791 + { 792 + unsigned long time_elapsed; 793 + long long bytes_trim; 794 + int io_trim; 795 + 796 + BUG_ON(time_before(tg->slice_end[rw], tg->slice_start[rw])); 797 + 798 + /* 799 + * If bps are unlimited (-1), then time slice don't get 800 + * renewed. Don't try to trim the slice if slice is used. A new 801 + * slice will start when appropriate. 802 + */ 803 + if (throtl_slice_used(tg, rw)) 804 + return; 805 + 806 + /* 807 + * A bio has been dispatched. Also adjust slice_end. It might happen 808 + * that initially cgroup limit was very low resulting in high 809 + * slice_end, but later limit was bumped up and bio was dispatched 810 + * sooner, then we need to reduce slice_end. A high bogus slice_end 811 + * is bad because it does not allow new slice to start. 812 + */ 813 + 814 + throtl_set_slice_end(tg, rw, jiffies + tg->td->throtl_slice); 815 + 816 + time_elapsed = rounddown(jiffies - tg->slice_start[rw], 817 + tg->td->throtl_slice); 818 + if (!time_elapsed) 819 + return; 820 + 821 + bytes_trim = calculate_bytes_allowed(tg_bps_limit(tg, rw), 822 + time_elapsed) + 823 + tg->carryover_bytes[rw]; 824 + io_trim = calculate_io_allowed(tg_iops_limit(tg, rw), time_elapsed) + 825 + tg->carryover_ios[rw]; 826 + if (bytes_trim <= 0 && io_trim <= 0) 827 + return; 828 + 829 + tg->carryover_bytes[rw] = 0; 830 + if ((long long)tg->bytes_disp[rw] >= bytes_trim) 831 + tg->bytes_disp[rw] -= bytes_trim; 832 + else 833 + tg->bytes_disp[rw] = 0; 834 + 835 + tg->carryover_ios[rw] = 0; 836 + if ((int)tg->io_disp[rw] >= io_trim) 837 + tg->io_disp[rw] -= io_trim; 838 + else 839 + tg->io_disp[rw] = 0; 840 + 841 + tg->slice_start[rw] += time_elapsed; 842 + 843 + throtl_log(&tg->service_queue, 844 + "[%c] trim slice nr=%lu bytes=%lld io=%d start=%lu end=%lu jiffies=%lu", 845 + rw == READ ? 'R' : 'W', time_elapsed / tg->td->throtl_slice, 846 + bytes_trim, io_trim, tg->slice_start[rw], tg->slice_end[rw], 847 + jiffies); 727 848 } 728 849 729 850 static void __tg_update_carryover(struct throtl_grp *tg, bool rw) ··· 817 816 __tg_update_carryover(tg, WRITE); 818 817 819 818 /* see comments in struct throtl_grp for meaning of these fields. */ 820 - throtl_log(&tg->service_queue, "%s: %llu %llu %u %u\n", __func__, 819 + throtl_log(&tg->service_queue, "%s: %lld %lld %d %d\n", __func__, 821 820 tg->carryover_bytes[READ], tg->carryover_bytes[WRITE], 822 821 tg->carryover_ios[READ], tg->carryover_ios[WRITE]); 823 822 } ··· 826 825 u32 iops_limit) 827 826 { 828 827 bool rw = bio_data_dir(bio); 829 - unsigned int io_allowed; 828 + int io_allowed; 830 829 unsigned long jiffy_elapsed, jiffy_wait, jiffy_elapsed_rnd; 831 830 832 831 if (iops_limit == UINT_MAX) { ··· 839 838 jiffy_elapsed_rnd = roundup(jiffy_elapsed + 1, tg->td->throtl_slice); 840 839 io_allowed = calculate_io_allowed(iops_limit, jiffy_elapsed_rnd) + 841 840 tg->carryover_ios[rw]; 842 - if (tg->io_disp[rw] + 1 <= io_allowed) { 841 + if (io_allowed > 0 && tg->io_disp[rw] + 1 <= io_allowed) 843 842 return 0; 844 - } 845 843 846 844 /* Calc approx time to dispatch */ 847 845 jiffy_wait = jiffy_elapsed_rnd - jiffy_elapsed; ··· 851 851 u64 bps_limit) 852 852 { 853 853 bool rw = bio_data_dir(bio); 854 - u64 bytes_allowed, extra_bytes; 854 + long long bytes_allowed; 855 + u64 extra_bytes; 855 856 unsigned long jiffy_elapsed, jiffy_wait, jiffy_elapsed_rnd; 856 857 unsigned int bio_size = throtl_bio_data_size(bio); 857 858 ··· 870 869 jiffy_elapsed_rnd = roundup(jiffy_elapsed_rnd, tg->td->throtl_slice); 871 870 bytes_allowed = calculate_bytes_allowed(bps_limit, jiffy_elapsed_rnd) + 872 871 tg->carryover_bytes[rw]; 873 - if (tg->bytes_disp[rw] + bio_size <= bytes_allowed) { 872 + if (bytes_allowed > 0 && tg->bytes_disp[rw] + bio_size <= bytes_allowed) 874 873 return 0; 875 - } 876 874 877 875 /* Calc approx time to dispatch */ 878 876 extra_bytes = tg->bytes_disp[rw] + bio_size - bytes_allowed;
+2 -2
block/blk-throttle.h
··· 127 127 * bytes/ios are waited already in previous configuration, and they will 128 128 * be used to calculate wait time under new configuration. 129 129 */ 130 - uint64_t carryover_bytes[2]; 131 - unsigned int carryover_ios[2]; 130 + long long carryover_bytes[2]; 131 + int carryover_ios[2]; 132 132 133 133 unsigned long last_check_time; 134 134
-4
block/fops.c
··· 671 671 iov_iter_truncate(from, size); 672 672 } 673 673 674 - ret = file_remove_privs(file); 675 - if (ret) 676 - return ret; 677 - 678 674 ret = file_update_time(file); 679 675 if (ret) 680 676 return ret;
+2
block/ioctl.c
··· 20 20 struct blkpg_partition p; 21 21 long long start, length; 22 22 23 + if (disk->flags & GENHD_FL_NO_PART) 24 + return -EINVAL; 23 25 if (!capable(CAP_SYS_ADMIN)) 24 26 return -EACCES; 25 27 if (copy_from_user(&p, upart, sizeof(struct blkpg_partition)))
+1 -1
drivers/block/drbd/drbd_main.c
··· 1557 1557 do { 1558 1558 int sent; 1559 1559 1560 - bvec_set_page(&bvec, page, offset, len); 1560 + bvec_set_page(&bvec, page, len, offset); 1561 1561 iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, len); 1562 1562 1563 1563 sent = sock_sendmsg(socket, &msg);
+10 -2
drivers/block/null_blk/main.c
··· 1643 1643 struct nullb_queue *nq = hctx->driver_data; 1644 1644 LIST_HEAD(list); 1645 1645 int nr = 0; 1646 + struct request *rq; 1646 1647 1647 1648 spin_lock(&nq->poll_lock); 1648 1649 list_splice_init(&nq->poll_list, &list); 1650 + list_for_each_entry(rq, &list, queuelist) 1651 + blk_mq_set_request_complete(rq); 1649 1652 spin_unlock(&nq->poll_lock); 1650 1653 1651 1654 while (!list_empty(&list)) { ··· 1674 1671 struct blk_mq_hw_ctx *hctx = rq->mq_hctx; 1675 1672 struct nullb_cmd *cmd = blk_mq_rq_to_pdu(rq); 1676 1673 1677 - pr_info("rq %p timed out\n", rq); 1678 - 1679 1674 if (hctx->type == HCTX_TYPE_POLL) { 1680 1675 struct nullb_queue *nq = hctx->driver_data; 1681 1676 1682 1677 spin_lock(&nq->poll_lock); 1678 + /* The request may have completed meanwhile. */ 1679 + if (blk_mq_request_completed(rq)) { 1680 + spin_unlock(&nq->poll_lock); 1681 + return BLK_EH_DONE; 1682 + } 1683 1683 list_del_init(&rq->queuelist); 1684 1684 spin_unlock(&nq->poll_lock); 1685 1685 } 1686 + 1687 + pr_info("rq %p timed out\n", rq); 1686 1688 1687 1689 /* 1688 1690 * If the device is marked as blocking (i.e. memory backed or zoned
+1 -5
drivers/s390/block/dasd_devmap.c
··· 1378 1378 1379 1379 static DEVICE_ATTR(vendor, 0444, dasd_vendor_show, NULL); 1380 1380 1381 - #define UID_STRLEN ( /* vendor */ 3 + 1 + /* serial */ 14 + 1 +\ 1382 - /* SSID */ 4 + 1 + /* unit addr */ 2 + 1 +\ 1383 - /* vduit */ 32 + 1) 1384 - 1385 1381 static ssize_t 1386 1382 dasd_uid_show(struct device *dev, struct device_attribute *attr, char *buf) 1387 1383 { 1384 + char uid_string[DASD_UID_STRLEN]; 1388 1385 struct dasd_device *device; 1389 1386 struct dasd_uid uid; 1390 - char uid_string[UID_STRLEN]; 1391 1387 char ua_string[3]; 1392 1388 1393 1389 device = dasd_device_from_cdev(to_ccwdev(dev));
+5 -5
drivers/s390/block/dasd_eckd.c
··· 1079 1079 1080 1080 create_uid(conf, &uid); 1081 1081 if (strlen(uid.vduit) > 0) 1082 - snprintf(print_uid, sizeof(*print_uid), 1082 + snprintf(print_uid, DASD_UID_STRLEN, 1083 1083 "%s.%s.%04x.%02x.%s", 1084 1084 uid.vendor, uid.serial, uid.ssid, 1085 1085 uid.real_unit_addr, uid.vduit); 1086 1086 else 1087 - snprintf(print_uid, sizeof(*print_uid), 1087 + snprintf(print_uid, DASD_UID_STRLEN, 1088 1088 "%s.%s.%04x.%02x", 1089 1089 uid.vendor, uid.serial, uid.ssid, 1090 1090 uid.real_unit_addr); ··· 1093 1093 static int dasd_eckd_check_cabling(struct dasd_device *device, 1094 1094 void *conf_data, __u8 lpm) 1095 1095 { 1096 + char print_path_uid[DASD_UID_STRLEN], print_device_uid[DASD_UID_STRLEN]; 1096 1097 struct dasd_eckd_private *private = device->private; 1097 - char print_path_uid[60], print_device_uid[60]; 1098 1098 struct dasd_conf path_conf; 1099 1099 1100 1100 path_conf.data = conf_data; ··· 1293 1293 __u8 path_rcd_buf[DASD_ECKD_RCD_DATA_SIZE]; 1294 1294 __u8 lpm, opm, npm, ppm, epm, hpfpm, cablepm; 1295 1295 struct dasd_conf_data *conf_data; 1296 + char print_uid[DASD_UID_STRLEN]; 1296 1297 struct dasd_conf path_conf; 1297 1298 unsigned long flags; 1298 - char print_uid[60]; 1299 1299 int rc, pos; 1300 1300 1301 1301 opm = 0; ··· 5855 5855 static int dasd_eckd_reload_device(struct dasd_device *device) 5856 5856 { 5857 5857 struct dasd_eckd_private *private = device->private; 5858 + char print_uid[DASD_UID_STRLEN]; 5858 5859 int rc, old_base; 5859 - char print_uid[60]; 5860 5860 struct dasd_uid uid; 5861 5861 unsigned long flags; 5862 5862
+4
drivers/s390/block/dasd_int.h
··· 259 259 char vduit[33]; 260 260 }; 261 261 262 + #define DASD_UID_STRLEN ( /* vendor */ 3 + 1 + /* serial */ 14 + 1 + \ 263 + /* SSID */ 4 + 1 + /* unit addr */ 2 + 1 + \ 264 + /* vduit */ 32 + 1) 265 + 262 266 /* 263 267 * PPRC Status data 264 268 */