Skip to content

Commit 83a8965

Browse files
committed
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull SCSI fix from James Bottomley: "Fix to zone block devices to make the maximum segment count match what the block layer is capable of" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: sd_zbc: block: Respect bio vector limits for REPORT ZONES buffer
2 parents 6462c24 + e8007fa commit 83a8965

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

block/bio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ struct bio *bio_kmalloc(unsigned short nr_vecs, gfp_t gfp_mask)
611611
{
612612
struct bio *bio;
613613

614-
if (nr_vecs > UIO_MAXIOV)
614+
if (nr_vecs > BIO_MAX_INLINE_VECS)
615615
return NULL;
616616
return kmalloc(struct_size(bio, bi_inline_vecs, nr_vecs), gfp_mask);
617617
}

drivers/scsi/sd_zbc.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ static void *sd_zbc_alloc_report_buffer(struct scsi_disk *sdkp,
169169
unsigned int nr_zones, size_t *buflen)
170170
{
171171
struct request_queue *q = sdkp->disk->queue;
172+
unsigned int max_segments;
172173
size_t bufsize;
173174
void *buf;
174175

@@ -180,12 +181,15 @@ static void *sd_zbc_alloc_report_buffer(struct scsi_disk *sdkp,
180181
* Furthermore, since the report zone command cannot be split, make
181182
* sure that the allocated buffer can always be mapped by limiting the
182183
* number of pages allocated to the HBA max segments limit.
184+
* Since max segments can be larger than the max inline bio vectors,
185+
* further limit the allocated buffer to BIO_MAX_INLINE_VECS.
183186
*/
184187
nr_zones = min(nr_zones, sdkp->zone_info.nr_zones);
185188
bufsize = roundup((nr_zones + 1) * 64, SECTOR_SIZE);
186189
bufsize = min_t(size_t, bufsize,
187190
queue_max_hw_sectors(q) << SECTOR_SHIFT);
188-
bufsize = min_t(size_t, bufsize, queue_max_segments(q) << PAGE_SHIFT);
191+
max_segments = min(BIO_MAX_INLINE_VECS, queue_max_segments(q));
192+
bufsize = min_t(size_t, bufsize, max_segments << PAGE_SHIFT);
189193

190194
while (bufsize >= SECTOR_SIZE) {
191195
buf = kvzalloc(bufsize, GFP_KERNEL | __GFP_NORETRY);

include/linux/bio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/uio.h>
1212

1313
#define BIO_MAX_VECS 256U
14+
#define BIO_MAX_INLINE_VECS UIO_MAXIOV
1415

1516
struct queue_limits;
1617

0 commit comments

Comments
 (0)