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.

block: reject invalid operation in submit_bio_noacct

submit_bio_noacct allows completely invalid operations, or operations
that are not supported in the bio path. Extent the existing switch
statement to rejcect all invalid types.

Move the code point for REQ_OP_ZONE_APPEND so that it's not right in the
middle of the zone management operations and the switch statement can
follow the numerical order of the operations.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20231221070538.1112446-1-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
1c042f8d 8aabc11c

+25 -9
+21 -5
block/blk-core.c
··· 764 764 bio_clear_polled(bio); 765 765 766 766 switch (bio_op(bio)) { 767 + case REQ_OP_READ: 768 + case REQ_OP_WRITE: 769 + break; 770 + case REQ_OP_FLUSH: 771 + /* 772 + * REQ_OP_FLUSH can't be submitted through bios, it is only 773 + * synthetized in struct request by the flush state machine. 774 + */ 775 + goto not_supported; 767 776 case REQ_OP_DISCARD: 768 777 if (!bdev_max_discard_sectors(bdev)) 769 778 goto not_supported; ··· 786 777 if (status != BLK_STS_OK) 787 778 goto end_io; 788 779 break; 780 + case REQ_OP_WRITE_ZEROES: 781 + if (!q->limits.max_write_zeroes_sectors) 782 + goto not_supported; 783 + break; 789 784 case REQ_OP_ZONE_RESET: 790 785 case REQ_OP_ZONE_OPEN: 791 786 case REQ_OP_ZONE_CLOSE: ··· 801 788 if (!bdev_is_zoned(bio->bi_bdev) || !blk_queue_zone_resetall(q)) 802 789 goto not_supported; 803 790 break; 804 - case REQ_OP_WRITE_ZEROES: 805 - if (!q->limits.max_write_zeroes_sectors) 806 - goto not_supported; 807 - break; 791 + case REQ_OP_DRV_IN: 792 + case REQ_OP_DRV_OUT: 793 + /* 794 + * Driver private operations are only used with passthrough 795 + * requests. 796 + */ 797 + fallthrough; 808 798 default: 809 - break; 799 + goto not_supported; 810 800 } 811 801 812 802 if (blk_throtl_bio(bio))
+4 -4
include/linux/blk_types.h
··· 378 378 REQ_OP_DISCARD = (__force blk_opf_t)3, 379 379 /* securely erase sectors */ 380 380 REQ_OP_SECURE_ERASE = (__force blk_opf_t)5, 381 + /* write data at the current zone write pointer */ 382 + REQ_OP_ZONE_APPEND = (__force blk_opf_t)7, 381 383 /* write the zero filled sector many times */ 382 384 REQ_OP_WRITE_ZEROES = (__force blk_opf_t)9, 383 385 /* Open a zone */ ··· 388 386 REQ_OP_ZONE_CLOSE = (__force blk_opf_t)11, 389 387 /* Transition a zone to full */ 390 388 REQ_OP_ZONE_FINISH = (__force blk_opf_t)12, 391 - /* write data at the current zone write pointer */ 392 - REQ_OP_ZONE_APPEND = (__force blk_opf_t)13, 393 389 /* reset a zone write pointer */ 394 - REQ_OP_ZONE_RESET = (__force blk_opf_t)15, 390 + REQ_OP_ZONE_RESET = (__force blk_opf_t)13, 395 391 /* reset all the zone present on the device */ 396 - REQ_OP_ZONE_RESET_ALL = (__force blk_opf_t)17, 392 + REQ_OP_ZONE_RESET_ALL = (__force blk_opf_t)15, 397 393 398 394 /* Driver private requests */ 399 395 REQ_OP_DRV_IN = (__force blk_opf_t)34,