Skip to content

Commit 3d3dfeb

Browse files
committed
Merge tag 'for-6.6/block-2023-08-28' of git://git.kernel.dk/linux
Pull block updates from Jens Axboe: "Pretty quiet round for this release. This contains: - Add support for zoned storage to ublk (Andreas, Ming) - Series improving performance for drivers that mark themselves as needing a blocking context for issue (Bart) - Cleanup the flush logic (Chengming) - sed opal keyring support (Greg) - Fixes and improvements to the integrity support (Jinyoung) - Add some exports for bcachefs that we can hopefully delete again in the future (Kent) - deadline throttling fix (Zhiguo) - Series allowing building the kernel without buffer_head support (Christoph) - Sanitize the bio page adding flow (Christoph) - Write back cache fixes (Christoph) - MD updates via Song: - Fix perf regression for raid0 large sequential writes (Jan) - Fix split bio iostat for raid0 (David) - Various raid1 fixes (Heinz, Xueshi) - raid6test build fixes (WANG) - Deprecate bitmap file support (Christoph) - Fix deadlock with md sync thread (Yu) - Refactor md io accounting (Yu) - Various non-urgent fixes (Li, Yu, Jack) - Various fixes and cleanups (Arnd, Azeem, Chengming, Damien, Li, Ming, Nitesh, Ruan, Tejun, Thomas, Xu)" * tag 'for-6.6/block-2023-08-28' of git://git.kernel.dk/linux: (113 commits) block: use strscpy() to instead of strncpy() block: sed-opal: keyring support for SED keys block: sed-opal: Implement IOC_OPAL_REVERT_LSP block: sed-opal: Implement IOC_OPAL_DISCOVERY blk-mq: prealloc tags when increase tagset nr_hw_queues blk-mq: delete redundant tagset map update when fallback blk-mq: fix tags leak when shrink nr_hw_queues ublk: zoned: support REQ_OP_ZONE_RESET_ALL md: raid0: account for split bio in iostat accounting md/raid0: Fix performance regression for large sequential writes md/raid0: Factor out helper for mapping and submitting a bio md raid1: allow writebehind to work on any leg device set WriteMostly md/raid1: hold the barrier until handle_read_error() finishes md/raid1: free the r1bio before waiting for blocked rdev md/raid1: call free_r1bio() before allow_barrier() in raid_end_bio_io() blk-cgroup: Fix NULL deref caused by blkg_policy_data being installed before init drivers/rnbd: restore sysfs interface to rnbd-client md/raid5-cache: fix null-ptr-deref for r5l_flush_stripe_to_raid() raid6: test: only check for Altivec if building on powerpc hosts raid6: test: make sure all intermediate and artifact files are .gitignored ...
2 parents c1b7fcf + 146afeb commit 3d3dfeb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+1683
-844
lines changed

block/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
menuconfig BLOCK
66
bool "Enable the block layer" if EXPERT
77
default y
8+
select FS_IOMAP
89
select SBITMAP
910
help
1011
Provide block layer support for the kernel.
@@ -183,6 +184,8 @@ config BLK_DEBUG_FS_ZONED
183184

184185
config BLK_SED_OPAL
185186
bool "Logic for interfacing with Opal enabled SEDs"
187+
depends on KEYS
188+
select PSERIES_PLPKS if PPC_PSERIES
186189
help
187190
Builds Logic for interfacing with Opal enabled controllers.
188191
Enabling this option enables users to setup/unlock/lock

block/bio-integrity.c

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -123,20 +123,38 @@ void bio_integrity_free(struct bio *bio)
123123
int bio_integrity_add_page(struct bio *bio, struct page *page,
124124
unsigned int len, unsigned int offset)
125125
{
126+
struct request_queue *q = bdev_get_queue(bio->bi_bdev);
126127
struct bio_integrity_payload *bip = bio_integrity(bio);
127128

128-
if (bip->bip_vcnt >= bip->bip_max_vcnt) {
129-
printk(KERN_ERR "%s: bip_vec full\n", __func__);
129+
if (((bip->bip_iter.bi_size + len) >> SECTOR_SHIFT) >
130+
queue_max_hw_sectors(q))
130131
return 0;
131-
}
132132

133-
if (bip->bip_vcnt &&
134-
bvec_gap_to_prev(&bdev_get_queue(bio->bi_bdev)->limits,
135-
&bip->bip_vec[bip->bip_vcnt - 1], offset))
136-
return 0;
133+
if (bip->bip_vcnt > 0) {
134+
struct bio_vec *bv = &bip->bip_vec[bip->bip_vcnt - 1];
135+
bool same_page = false;
136+
137+
if (bvec_try_merge_hw_page(q, bv, page, len, offset,
138+
&same_page)) {
139+
bip->bip_iter.bi_size += len;
140+
return len;
141+
}
142+
143+
if (bip->bip_vcnt >=
144+
min(bip->bip_max_vcnt, queue_max_integrity_segments(q)))
145+
return 0;
146+
147+
/*
148+
* If the queue doesn't support SG gaps and adding this segment
149+
* would create a gap, disallow it.
150+
*/
151+
if (bvec_gap_to_prev(&q->limits, bv, offset))
152+
return 0;
153+
}
137154

138155
bvec_set_page(&bip->bip_vec[bip->bip_vcnt], page, len, offset);
139156
bip->bip_vcnt++;
157+
bip->bip_iter.bi_size += len;
140158

141159
return len;
142160
}
@@ -199,8 +217,6 @@ bool bio_integrity_prep(struct bio *bio)
199217
unsigned long start, end;
200218
unsigned int len, nr_pages;
201219
unsigned int bytes, offset, i;
202-
unsigned int intervals;
203-
blk_status_t status;
204220

205221
if (!bi)
206222
return true;
@@ -224,12 +240,10 @@ bool bio_integrity_prep(struct bio *bio)
224240
!(bi->flags & BLK_INTEGRITY_GENERATE))
225241
return true;
226242
}
227-
intervals = bio_integrity_intervals(bi, bio_sectors(bio));
228243

229244
/* Allocate kernel buffer for protection data */
230-
len = intervals * bi->tuple_size;
245+
len = bio_integrity_bytes(bi, bio_sectors(bio));
231246
buf = kmalloc(len, GFP_NOIO);
232-
status = BLK_STS_RESOURCE;
233247
if (unlikely(buf == NULL)) {
234248
printk(KERN_ERR "could not allocate integrity buffer\n");
235249
goto err_end_io;
@@ -244,41 +258,29 @@ bool bio_integrity_prep(struct bio *bio)
244258
if (IS_ERR(bip)) {
245259
printk(KERN_ERR "could not allocate data integrity bioset\n");
246260
kfree(buf);
247-
status = BLK_STS_RESOURCE;
248261
goto err_end_io;
249262
}
250263

251264
bip->bip_flags |= BIP_BLOCK_INTEGRITY;
252-
bip->bip_iter.bi_size = len;
253265
bip_set_seed(bip, bio->bi_iter.bi_sector);
254266

255267
if (bi->flags & BLK_INTEGRITY_IP_CHECKSUM)
256268
bip->bip_flags |= BIP_IP_CHECKSUM;
257269

258270
/* Map it */
259271
offset = offset_in_page(buf);
260-
for (i = 0 ; i < nr_pages ; i++) {
261-
int ret;
272+
for (i = 0; i < nr_pages && len > 0; i++) {
262273
bytes = PAGE_SIZE - offset;
263274

264-
if (len <= 0)
265-
break;
266-
267275
if (bytes > len)
268276
bytes = len;
269277

270-
ret = bio_integrity_add_page(bio, virt_to_page(buf),
271-
bytes, offset);
272-
273-
if (ret == 0) {
278+
if (bio_integrity_add_page(bio, virt_to_page(buf),
279+
bytes, offset) < bytes) {
274280
printk(KERN_ERR "could not attach integrity payload\n");
275-
status = BLK_STS_RESOURCE;
276281
goto err_end_io;
277282
}
278283

279-
if (ret < bytes)
280-
break;
281-
282284
buf += bytes;
283285
len -= bytes;
284286
offset = 0;
@@ -294,10 +296,9 @@ bool bio_integrity_prep(struct bio *bio)
294296
return true;
295297

296298
err_end_io:
297-
bio->bi_status = status;
299+
bio->bi_status = BLK_STS_RESOURCE;
298300
bio_endio(bio);
299301
return false;
300-
301302
}
302303
EXPORT_SYMBOL(bio_integrity_prep);
303304

0 commit comments

Comments
 (0)