Pull block fixes from Jens Axboe: - Fix autoloading of drivers from stat*(2) - Fix losing read-ahead setting one suspend/resume, when a device is re-probed. - Fix race between setting the block size and page cache updates. Includes a helper that a coming XFS fix will use as well. - ublk cancelation fixes. - ublk selftest additions and fixes. - NVMe pull via Christoph: - fix an out-of-bounds access in nvmet_enable_port (Richard Weinberger) * tag 'block-6.15-20250424' of git://git.kernel.dk/linux: ublk: fix race between io_uring_cmd_complete_in_task and ublk_cancel_cmd ublk: call ublk_dispatch_req() for handling UBLK_U_IO_NEED_GET_DATA block: don't autoload drivers on blk-cgroup configuration block: don't autoload drivers on stat block: remove the backing_inode variable in bdev_statx block: move blkdev_{get,put} _no_open prototypes out of blkdev.h block: never reduce ra_pages in blk_apply_bdi_limits selftests: ublk: common: fix _get_disk_dev_t for pre-9.0 coreutils selftests: ublk: remove useless 'delay_us' from 'struct dev_ctx' selftests: ublk: fix recover test block: hoist block size validation code to a separate function block: fix race between set_blocksize and read paths nvmet: fix out-of-bounds access in nvmet_enable_port
Unified · Split
| @@ -152,27 +152,65 @@ static void set_init_blocksize(struct block_device *bdev) · 151 unmodified lines | ||
| 152 | 152 | get_order(bsize)); |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | −int set_blocksize(struct file *file, int size) | |
| 155 | +/** | |
| 156 | + * bdev_validate_blocksize - check that this block size is acceptable | |
| 157 | + * @bdev: blockdevice to check | |
| 158 | + * @block_size: block size to check | |
| 159 | + * | |
| 160 | + * For block device users that do not use buffer heads or the block device | |
| 161 | + * page cache, make sure that this block size can be used with the device. | |
| 162 | + * | |
| 163 | + * Return: On success zero is returned, negative error code on failure. | |
| 164 | + */ | |
| 165 | +int bdev_validate_blocksize(struct block_device *bdev, int block_size) | |
| 156 | 166 | { |
| 157 | − struct inode *inode = file->f_mapping->host; | |
| 158 | − struct block_device *bdev = I_BDEV(inode); | |
| 159 | − | |
| 160 | − if (blk_validate_block_size(size)) | |
| 167 | + if (blk_validate_block_size(block_size)) | |
| 161 | 168 | return -EINVAL; |
| 162 | 169 | |
| 163 | 170 | /* Size cannot be smaller than the size supported by the device */ |
| 164 | − if (size < bdev_logical_block_size(bdev)) | |
| 171 | + if (block_size < bdev_logical_block_size(bdev)) | |
| 165 | 172 | return -EINVAL; |
| 166 | 173 | |
| 174 | + return 0; | |
| 175 | +} | |
| 176 | +EXPORT_SYMBOL_GPL(bdev_validate_blocksize); | |
| 177 | + | |
| 178 | +int set_blocksize(struct file *file, int size) | |
| 179 | +{ | |
| 180 | + struct inode *inode = file->f_mapping->host; | |
| 181 | + struct block_device *bdev = I_BDEV(inode); | |
| 182 | + int ret; | |
| 183 | + | |
| 184 | + ret = bdev_validate_blocksize(bdev, size); | |
| 185 | + if (ret) | |
| 186 | + return ret; | |
| 187 | + | |
| 167 | 188 | if (!file->private_data) |
| 168 | 189 | return -EINVAL; |
| 169 | 190 | |
| 170 | 191 | /* Don't change the size if it is same as current */ |
| 171 | 192 | if (inode->i_blkbits != blksize_bits(size)) { |
| 193 | + /* | |
| 194 | + * Flush and truncate the pagecache before we reconfigure the | |
| 195 | + * mapping geometry because folio sizes are variable now. If a | |
| 196 | + * reader has already allocated a folio whose size is smaller | |
| 197 | + * than the new min_order but invokes readahead after the new | |
| 198 | + * min_order becomes visible, readahead will think there are | |
| 199 | + * "zero" blocks per folio and crash. Take the inode and | |
| 200 | + * invalidation locks to avoid racing with | |
| 201 | + * read/write/fallocate. | |
| 202 | + */ | |
| 203 | + inode_lock(inode); | |
| 204 | + filemap_invalidate_lock(inode->i_mapping); | |
| 205 | + | |
| 172 | 206 | sync_blockdev(bdev); |
| 207 | + kill_bdev(bdev); | |
| 208 | + | |
| 173 | 209 | inode->i_blkbits = blksize_bits(size); |
| 174 | 210 | mapping_set_folio_min_order(inode->i_mapping, get_order(size)); |
| 175 | 211 | kill_bdev(bdev); |
| 212 | + filemap_invalidate_unlock(inode->i_mapping); | |
| 213 | + inode_unlock(inode); | |
| 176 | 214 | } |
| 177 | 215 | return 0; |
| 178 | 216 | } |
| @@ -777,13 +815,13 @@ static void blkdev_put_part(struct block_device *part) · 598 unmodified lines | ||
| 777 | 815 | blkdev_put_whole(whole); |
| 778 | 816 | } |
| 779 | 817 | |
| 780 | −struct block_device *blkdev_get_no_open(dev_t dev) | |
| 818 | +struct block_device *blkdev_get_no_open(dev_t dev, bool autoload) | |
| 781 | 819 | { |
| 782 | 820 | struct block_device *bdev; |
| 783 | 821 | struct inode *inode; |
| 784 | 822 | |
| 785 | 823 | inode = ilookup(blockdev_superblock, dev); |
| 786 | − if (!inode && IS_ENABLED(CONFIG_BLOCK_LEGACY_AUTOLOAD)) { | |
| 824 | + if (!inode && autoload && IS_ENABLED(CONFIG_BLOCK_LEGACY_AUTOLOAD)) { | |
| 787 | 825 | blk_request_module(dev); |
| 788 | 826 | inode = ilookup(blockdev_superblock, dev); |
| 789 | 827 | if (inode) |
| @@ -1005,7 +1043,7 @@ struct file *bdev_file_open_by_dev(dev_t dev, blk_mode_t mode, void *holder, · 215 unmodified lines | ||
| 1005 | 1043 | if (ret) |
| 1006 | 1044 | return ERR_PTR(ret); |
| 1007 | 1045 | |
| 1008 | − bdev = blkdev_get_no_open(dev); | |
| 1046 | + bdev = blkdev_get_no_open(dev, true); | |
| 1009 | 1047 | if (!bdev) |
| 1010 | 1048 | return ERR_PTR(-ENXIO); |
| 1011 | 1049 | |
| @@ -1274,18 +1312,15 @@ void sync_bdevs(bool wait) · 262 unmodified lines | ||
| 1274 | 1312 | */ |
| 1275 | 1313 | void bdev_statx(const struct path *path, struct kstat *stat, u32 request_mask) |
| 1276 | 1314 | { |
| 1277 | − struct inode *backing_inode; | |
| 1278 | 1315 | struct block_device *bdev; |
| 1279 | 1316 | |
| 1280 | − backing_inode = d_backing_inode(path->dentry); | |
| 1281 | − | |
| 1282 | 1317 | /* |
| 1283 | − * Note that backing_inode is the inode of a block device node file, | |
| 1284 | − * not the block device's internal inode. Therefore it is *not* valid | |
| 1285 | − * to use I_BDEV() here; the block device has to be looked up by i_rdev | |
| 1318 | + * Note that d_backing_inode() returns the block device node inode, not | |
| 1319 | + * the block device's internal inode. Therefore it is *not* valid to | |
| 1320 | + * use I_BDEV() here; the block device has to be looked up by i_rdev | |
| 1286 | 1321 | * instead. |
| 1287 | 1322 | */ |
| 1288 | − bdev = blkdev_get_no_open(backing_inode->i_rdev); | |
| 1323 | + bdev = blkdev_get_no_open(d_backing_inode(path->dentry)->i_rdev, false); | |
| 1289 | 1324 | if (!bdev) |
| 1290 | 1325 | return; |
| 1291 | 1326 | |
| @@ -797,7 +797,7 @@ int blkg_conf_open_bdev(struct blkg_conf_ctx *ctx) · 796 unmodified lines | ||
| 797 | 797 | return -EINVAL; |
| 798 | 798 | input = skip_spaces(input); |
| 799 | 799 | |
| 800 | − bdev = blkdev_get_no_open(MKDEV(major, minor)); | |
| 800 | + bdev = blkdev_get_no_open(MKDEV(major, minor), false); | |
| 801 | 801 | if (!bdev) |
| 802 | 802 | return -ENODEV; |
| 803 | 803 | if (bdev_is_partition(bdev)) { |
| @@ -61,8 +61,14 @@ void blk_apply_bdi_limits(struct backing_dev_info *bdi, · 60 unmodified lines | ||
| 61 | 61 | /* |
| 62 | 62 | * For read-ahead of large files to be effective, we need to read ahead |
| 63 | 63 | * at least twice the optimal I/O size. |
| 64 | + * | |
| 65 | + * There is no hardware limitation for the read-ahead size and the user | |
| 66 | + * might have increased the read-ahead size through sysfs, so don't ever | |
| 67 | + * decrease it. | |
| 64 | 68 | */ |
| 65 | − bdi->ra_pages = max(lim->io_opt * 2 / PAGE_SIZE, VM_READAHEAD_PAGES); | |
| 69 | + bdi->ra_pages = max3(bdi->ra_pages, | |
| 70 | + lim->io_opt * 2 / PAGE_SIZE, | |
| 71 | + VM_READAHEAD_PAGES); | |
| 66 | 72 | bdi->io_pages = lim->max_sectors >> PAGE_SECTORS_SHIFT; |
| 67 | 73 | } |
| 68 | 74 | |
| @@ -343,6 +343,7 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, blk_mode_t mode, · 342 unmodified lines | ||
| 343 | 343 | op = REQ_OP_ZONE_RESET; |
| 344 | 344 | |
| 345 | 345 | /* Invalidate the page cache, including dirty pages. */ |
| 346 | + inode_lock(bdev->bd_mapping->host); | |
| 346 | 347 | filemap_invalidate_lock(bdev->bd_mapping); |
| 347 | 348 | ret = blkdev_truncate_zone_range(bdev, mode, &zrange); |
| 348 | 349 | if (ret) |
| @@ -364,8 +365,10 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, blk_mode_t mode, · 15 unmodified lines | ||
| 364 | 365 | ret = blkdev_zone_mgmt(bdev, op, zrange.sector, zrange.nr_sectors); |
| 365 | 366 | |
| 366 | 367 | fail: |
| 367 | − if (cmd == BLKRESETZONE) | |
| 368 | + if (cmd == BLKRESETZONE) { | |
| 368 | 369 | filemap_invalidate_unlock(bdev->bd_mapping); |
| 370 | + inode_unlock(bdev->bd_mapping->host); | |
| 371 | + } | |
| 369 | 372 | |
| 370 | 373 | return ret; |
| 371 | 374 | } |
| @@ -94,6 +94,9 @@ static inline void blk_wait_io(struct completion *done) · 93 unmodified lines | ||
| 94 | 94 | wait_for_completion_io(done); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | +struct block_device *blkdev_get_no_open(dev_t dev, bool autoload); | |
| 98 | +void blkdev_put_no_open(struct block_device *bdev); | |
| 99 | + | |
| 97 | 100 | #define BIO_INLINE_VECS 4 |
| 98 | 101 | struct bio_vec *bvec_alloc(mempool_t *pool, unsigned short *nr_vecs, |
| 99 | 102 | gfp_t gfp_mask); |
| @@ -642,7 +642,7 @@ static int blkdev_open(struct inode *inode, struct file *filp) · 641 unmodified lines | ||
| 642 | 642 | if (ret) |
| 643 | 643 | return ret; |
| 644 | 644 | |
| 645 | − bdev = blkdev_get_no_open(inode->i_rdev); | |
| 645 | + bdev = blkdev_get_no_open(inode->i_rdev, true); | |
| 646 | 646 | if (!bdev) |
| 647 | 647 | return -ENXIO; |
| 648 | 648 | |
| @@ -746,7 +746,14 @@ static ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from) · 97 unmodified lines | ||
| 746 | 746 | ret = direct_write_fallback(iocb, from, ret, |
| 747 | 747 | blkdev_buffered_write(iocb, from)); |
| 748 | 748 | } else { |
| 749 | + /* | |
| 750 | + * Take i_rwsem and invalidate_lock to avoid racing with | |
| 751 | + * set_blocksize changing i_blkbits/folio order and punching | |
| 752 | + * out the pagecache. | |
| 753 | + */ | |
| 754 | + inode_lock_shared(bd_inode); | |
| 749 | 755 | ret = blkdev_buffered_write(iocb, from); |
| 756 | + inode_unlock_shared(bd_inode); | |
| 750 | 757 | } |
| 751 | 758 | |
| 752 | 759 | if (ret > 0) |
| @@ -757,6 +764,7 @@ static ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from) · 4 unmodified lines | ||
| 757 | 764 | |
| 758 | 765 | static ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to) |
| 759 | 766 | { |
| 767 | + struct inode *bd_inode = bdev_file_inode(iocb->ki_filp); | |
| 760 | 768 | struct block_device *bdev = I_BDEV(iocb->ki_filp->f_mapping->host); |
| 761 | 769 | loff_t size = bdev_nr_bytes(bdev); |
| 762 | 770 | loff_t pos = iocb->ki_pos; |
| @@ -793,7 +801,13 @@ static ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to) · 30 unmodified lines | ||
| 793 | 801 | goto reexpand; |
| 794 | 802 | } |
| 795 | 803 | |
| 804 | + /* | |
| 805 | + * Take i_rwsem and invalidate_lock to avoid racing with set_blocksize | |
| 806 | + * changing i_blkbits/folio order and punching out the pagecache. | |
| 807 | + */ | |
| 808 | + inode_lock_shared(bd_inode); | |
| 796 | 809 | ret = filemap_read(iocb, to, ret); |
| 810 | + inode_unlock_shared(bd_inode); | |
| 797 | 811 | |
| 798 | 812 | reexpand: |
| 799 | 813 | if (unlikely(shorted)) |
| @@ -836,6 +850,7 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start, · 36 unmodified lines | ||
| 836 | 850 | if ((start | len) & (bdev_logical_block_size(bdev) - 1)) |
| 837 | 851 | return -EINVAL; |
| 838 | 852 | |
| 853 | + inode_lock(inode); | |
| 839 | 854 | filemap_invalidate_lock(inode->i_mapping); |
| 840 | 855 | |
| 841 | 856 | /* |
| @@ -868,6 +883,7 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start, · 26 unmodified lines | ||
| 868 | 883 | |
| 869 | 884 | fail: |
| 870 | 885 | filemap_invalidate_unlock(inode->i_mapping); |
| 886 | + inode_unlock(inode); | |
| 871 | 887 | return error; |
| 872 | 888 | } |
| 873 | 889 | |
| @@ -142,6 +142,7 @@ static int blk_ioctl_discard(struct block_device *bdev, blk_mode_t mode, · 141 unmodified lines | ||
| 142 | 142 | if (err) |
| 143 | 143 | return err; |
| 144 | 144 | |
| 145 | + inode_lock(bdev->bd_mapping->host); | |
| 145 | 146 | filemap_invalidate_lock(bdev->bd_mapping); |
| 146 | 147 | err = truncate_bdev_range(bdev, mode, start, start + len - 1); |
| 147 | 148 | if (err) |
| @@ -174,6 +175,7 @@ out_unplug: · 26 unmodified lines | ||
| 174 | 175 | blk_finish_plug(&plug); |
| 175 | 176 | fail: |
| 176 | 177 | filemap_invalidate_unlock(bdev->bd_mapping); |
| 178 | + inode_unlock(bdev->bd_mapping->host); | |
| 177 | 179 | return err; |
| 178 | 180 | } |
| 179 | 181 | |
| @@ -199,12 +201,14 @@ static int blk_ioctl_secure_erase(struct block_device *bdev, blk_mode_t mode, · 19 unmodified lines | ||
| 199 | 201 | end > bdev_nr_bytes(bdev)) |
| 200 | 202 | return -EINVAL; |
| 201 | 203 | |
| 204 | + inode_lock(bdev->bd_mapping->host); | |
| 202 | 205 | filemap_invalidate_lock(bdev->bd_mapping); |
| 203 | 206 | err = truncate_bdev_range(bdev, mode, start, end - 1); |
| 204 | 207 | if (!err) |
| 205 | 208 | err = blkdev_issue_secure_erase(bdev, start >> 9, len >> 9, |
| 206 | 209 | GFP_KERNEL); |
| 207 | 210 | filemap_invalidate_unlock(bdev->bd_mapping); |
| 211 | + inode_unlock(bdev->bd_mapping->host); | |
| 208 | 212 | return err; |
| 209 | 213 | } |
| 210 | 214 | |
| @@ -236,6 +240,7 @@ static int blk_ioctl_zeroout(struct block_device *bdev, blk_mode_t mode, · 25 unmodified lines | ||
| 236 | 240 | return -EINVAL; |
| 237 | 241 | |
| 238 | 242 | /* Invalidate the page cache, including dirty pages */ |
| 243 | + inode_lock(bdev->bd_mapping->host); | |
| 239 | 244 | filemap_invalidate_lock(bdev->bd_mapping); |
| 240 | 245 | err = truncate_bdev_range(bdev, mode, start, end); |
| 241 | 246 | if (err) |
| @@ -246,6 +251,7 @@ static int blk_ioctl_zeroout(struct block_device *bdev, blk_mode_t mode, · 4 unmodified lines | ||
| 246 | 251 | |
| 247 | 252 | fail: |
| 248 | 253 | filemap_invalidate_unlock(bdev->bd_mapping); |
| 254 | + inode_unlock(bdev->bd_mapping->host); | |
| 249 | 255 | return err; |
| 250 | 256 | } |
| 251 | 257 | |
| @@ -1683,14 +1683,31 @@ static void ublk_start_cancel(struct ublk_queue *ubq) · 1682 unmodified lines | ||
| 1683 | 1683 | ublk_put_disk(disk); |
| 1684 | 1684 | } |
| 1685 | 1685 | |
| 1686 | −static void ublk_cancel_cmd(struct ublk_queue *ubq, struct ublk_io *io, | |
| 1686 | +static void ublk_cancel_cmd(struct ublk_queue *ubq, unsigned tag, | |
| 1687 | 1687 | unsigned int issue_flags) |
| 1688 | 1688 | { |
| 1689 | + struct ublk_io *io = &ubq->ios[tag]; | |
| 1690 | + struct ublk_device *ub = ubq->dev; | |
| 1691 | + struct request *req; | |
| 1689 | 1692 | bool done; |
| 1690 | 1693 | |
| 1691 | 1694 | if (!(io->flags & UBLK_IO_FLAG_ACTIVE)) |
| 1692 | 1695 | return; |
| 1693 | 1696 | |
| 1697 | + /* | |
| 1698 | + * Don't try to cancel this command if the request is started for | |
| 1699 | + * avoiding race between io_uring_cmd_done() and | |
| 1700 | + * io_uring_cmd_complete_in_task(). | |
| 1701 | + * | |
| 1702 | + * Either the started request will be aborted via __ublk_abort_rq(), | |
| 1703 | + * then this uring_cmd is canceled next time, or it will be done in | |
| 1704 | + * task work function ublk_dispatch_req() because io_uring guarantees | |
| 1705 | + * that ublk_dispatch_req() is always called | |
| 1706 | + */ | |
| 1707 | + req = blk_mq_tag_to_rq(ub->tag_set.tags[ubq->q_id], tag); | |
| 1708 | + if (req && blk_mq_request_started(req)) | |
| 1709 | + return; | |
| 1710 | + | |
| 1694 | 1711 | spin_lock(&ubq->cancel_lock); |
| 1695 | 1712 | done = !!(io->flags & UBLK_IO_FLAG_CANCELED); |
| 1696 | 1713 | if (!done) |
| @@ -1722,7 +1739,6 @@ static void ublk_uring_cmd_cancel_fn(struct io_uring_cmd *cmd, · 25 unmodified lines | ||
| 1722 | 1739 | struct ublk_uring_cmd_pdu *pdu = ublk_get_uring_cmd_pdu(cmd); |
| 1723 | 1740 | struct ublk_queue *ubq = pdu->ubq; |
| 1724 | 1741 | struct task_struct *task; |
| 1725 | − struct ublk_io *io; | |
| 1726 | 1742 | |
| 1727 | 1743 | if (WARN_ON_ONCE(!ubq)) |
| 1728 | 1744 | return; |
| @@ -1737,9 +1753,8 @@ static void ublk_uring_cmd_cancel_fn(struct io_uring_cmd *cmd, · 8 unmodified lines | ||
| 1737 | 1753 | if (!ubq->canceling) |
| 1738 | 1754 | ublk_start_cancel(ubq); |
| 1739 | 1755 | |
| 1740 | − io = &ubq->ios[pdu->tag]; | |
| 1741 | − WARN_ON_ONCE(io->cmd != cmd); | |
| 1742 | − ublk_cancel_cmd(ubq, io, issue_flags); | |
| 1756 | + WARN_ON_ONCE(ubq->ios[pdu->tag].cmd != cmd); | |
| 1757 | + ublk_cancel_cmd(ubq, pdu->tag, issue_flags); | |
| 1743 | 1758 | } |
| 1744 | 1759 | |
| 1745 | 1760 | static inline bool ublk_queue_ready(struct ublk_queue *ubq) |
| @@ -1752,7 +1767,7 @@ static void ublk_cancel_queue(struct ublk_queue *ubq) · 6 unmodified lines | ||
| 1752 | 1767 | int i; |
| 1753 | 1768 | |
| 1754 | 1769 | for (i = 0; i < ubq->q_depth; i++) |
| 1755 | − ublk_cancel_cmd(ubq, &ubq->ios[i], IO_URING_F_UNLOCKED); | |
| 1770 | + ublk_cancel_cmd(ubq, i, IO_URING_F_UNLOCKED); | |
| 1756 | 1771 | } |
| 1757 | 1772 | |
| 1758 | 1773 | /* Cancel all pending commands, must be called after del_gendisk() returns */ |
| @@ -1886,15 +1901,6 @@ static void ublk_mark_io_ready(struct ublk_device *ub, struct ublk_queue *ubq) · 127 unmodified lines | ||
| 1886 | 1901 | } |
| 1887 | 1902 | } |
| 1888 | 1903 | |
| 1889 | −static void ublk_handle_need_get_data(struct ublk_device *ub, int q_id, | |
| 1890 | − int tag) | |
| 1891 | −{ | |
| 1892 | − struct ublk_queue *ubq = ublk_get_queue(ub, q_id); | |
| 1893 | − struct request *req = blk_mq_tag_to_rq(ub->tag_set.tags[q_id], tag); | |
| 1894 | − | |
| 1895 | − ublk_queue_cmd(ubq, req); | |
| 1896 | −} | |
| 1897 | − | |
| 1898 | 1904 | static inline int ublk_check_cmd_op(u32 cmd_op) |
| 1899 | 1905 | { |
| 1900 | 1906 | u32 ioc_type = _IOC_TYPE(cmd_op); |
| @@ -2103,8 +2109,9 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd, · 202 unmodified lines | ||
| 2103 | 2109 | if (!(io->flags & UBLK_IO_FLAG_OWNED_BY_SRV)) |
| 2104 | 2110 | goto out; |
| 2105 | 2111 | ublk_fill_io_cmd(io, cmd, ub_cmd->addr); |
| 2106 | − ublk_handle_need_get_data(ub, ub_cmd->q_id, ub_cmd->tag); | |
| 2107 | − break; | |
| 2112 | + req = blk_mq_tag_to_rq(ub->tag_set.tags[ub_cmd->q_id], tag); | |
| 2113 | + ublk_dispatch_req(ubq, req, issue_flags); | |
| 2114 | + return -EIOCBQUEUED; | |
| 2108 | 2115 | default: |
| 2109 | 2116 | goto out; |
| 2110 | 2117 | } |
| @@ -324,6 +324,9 @@ int nvmet_enable_port(struct nvmet_port *port) · 323 unmodified lines | ||
| 324 | 324 | |
| 325 | 325 | lockdep_assert_held(&nvmet_config_sem); |
| 326 | 326 | |
| 327 | + if (port->disc_addr.trtype == NVMF_TRTYPE_MAX) | |
| 328 | + return -EINVAL; | |
| 329 | + | |
| 327 | 330 | ops = nvmet_transports[port->disc_addr.trtype]; |
| 328 | 331 | if (!ops) { |
| 329 | 332 | up_write(&nvmet_config_sem); |
| @@ -1637,6 +1637,7 @@ static inline void bio_end_io_acct(struct bio *bio, unsigned long start_time) · 1636 unmodified lines | ||
| 1637 | 1637 | return bio_end_io_acct_remapped(bio, start_time, bio->bi_bdev); |
| 1638 | 1638 | } |
| 1639 | 1639 | |
| 1640 | +int bdev_validate_blocksize(struct block_device *bdev, int block_size); | |
| 1640 | 1641 | int set_blocksize(struct file *file, int size); |
| 1641 | 1642 | |
| 1642 | 1643 | int lookup_bdev(const char *pathname, dev_t *dev); |
| @@ -1693,10 +1694,6 @@ int bd_prepare_to_claim(struct block_device *bdev, void *holder, · 50 unmodified lines | ||
| 1693 | 1694 | const struct blk_holder_ops *hops); |
| 1694 | 1695 | void bd_abort_claiming(struct block_device *bdev, void *holder); |
| 1695 | 1696 | |
| 1696 | −/* just for blk-cgroup, don't use elsewhere */ | |
| 1697 | −struct block_device *blkdev_get_no_open(dev_t dev); | |
| 1698 | −void blkdev_put_no_open(struct block_device *bdev); | |
| 1699 | − | |
| 1700 | 1697 | struct block_device *I_BDEV(struct inode *inode); |
| 1701 | 1698 | struct block_device *file_bdev(struct file *bdev_file); |
| 1702 | 1699 | bool disk_live(struct gendisk *disk); |
| @@ -1354,6 +1354,7 @@ int main(int argc, char *argv[]) · 1353 unmodified lines | ||
| 1354 | 1354 | value = strtol(optarg, NULL, 10); |
| 1355 | 1355 | if (value) |
| 1356 | 1356 | ctx.flags |= UBLK_F_NEED_GET_DATA; |
| 1357 | + break; | |
| 1357 | 1358 | case 0: |
| 1358 | 1359 | if (!strcmp(longopts[option_idx].name, "debug_mask")) |
| 1359 | 1360 | ublk_dbg_mask = strtol(optarg, NULL, 16); |
| @@ -86,9 +86,6 @@ struct dev_ctx { · 85 unmodified lines | ||
| 86 | 86 | unsigned int fg:1; |
| 87 | 87 | unsigned int recovery:1; |
| 88 | 88 | |
| 89 | − /* fault_inject */ | |
| 90 | − long long delay_us; | |
| 91 | − | |
| 92 | 89 | int _evtfd; |
| 93 | 90 | int _shmid; |
| 94 | 91 | |
| @@ -17,8 +17,8 @@ _get_disk_dev_t() { · 16 unmodified lines | ||
| 17 | 17 | local minor |
| 18 | 18 | |
| 19 | 19 | dev=/dev/ublkb"${dev_id}" |
| 20 | − major=$(stat -c '%Hr' "$dev") | |
| 21 | − minor=$(stat -c '%Lr' "$dev") | |
| 20 | + major="0x"$(stat -c '%t' "$dev") | |
| 21 | + minor="0x"$(stat -c '%T' "$dev") | |
| 22 | 22 | |
| 23 | 23 | echo $(( (major & 0xfff) << 20 | (minor & 0xfffff) )) |
| 24 | 24 | } |
| @@ -3,7 +3,7 @@ · 2 unmodified lines | ||
| 3 | 3 | |
| 4 | 4 | . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh |
| 5 | 5 | |
| 6 | −TID="generic_04" | |
| 6 | +TID="generic_05" | |
| 7 | 7 | ERR_CODE=0 |
| 8 | 8 | |
| 9 | 9 | ublk_run_recover_test() |