Skip to content

Commit 6568edb

Browse files
committed
Merge branch 'for-7.1/block' into for-next
* for-7.1/block: (111 commits) bcache: fix cached_dev.sb_bio use-after-free and crash block: use sysfs_emit in sysfs show functions blk-crypto: fix name of the bio completion callback bio: fix kmemleak false positives from percpu bio alloc cache blk-iocost: fix busy_level reset when no IOs complete blk-cgroup: fix disk reference leak in blkcg_maybe_throttle_current() zloop: add max_open_zones option block: fix zones_cond memory leak on zone revalidation error paths loop: fix partition scan race between udev and loop_reread_partitions() sed-opal: Add STACK_RESET command nvme-loop: do not cancel I/O and admin tagset during ctrl reset/shutdown nvme: add WQ_PERCPU to alloc_workqueue users nvmet-fc: add WQ_PERCPU to alloc_workqueue users nvmet: replace use of system_wq with system_percpu_wq nvme-auth: Don't propose NVME_AUTH_DHGROUP_NULL with SC_C nvme: Add the DHCHAP maximum HD IDs nvme-pci: add NVME_QUIRK_DISABLE_WRITE_ZEROES for Kingston OM3SGP4 nvme: respect NVME_QUIRK_DISABLE_WRITE_ZEROES when wzsl is set nvmet: report NPDGL and NPDAL nvmet: use NVME_NS_FEAT_OPTPERF_SHIFT ...
2 parents b595ad7 + fec114a commit 6568edb

100 files changed

Lines changed: 3707 additions & 2807 deletions

Some content is hidden

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

Documentation/ABI/stable/sysfs-block

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,21 @@ Description:
886886
zone commands, they will be treated as regular block devices and
887887
zoned will report "none".
888888

889+
What: /sys/block/<disk>/queue/zoned_qd1_writes
890+
Date: January 2026
891+
Contact: Damien Le Moal <dlemoal@kernel.org>
892+
Description:
893+
[RW] zoned_qd1_writes indicates if write operations to a zoned
894+
block device are being handled using a single issuer context (a
895+
kernel thread) operating at a maximum queue depth of 1. This
896+
attribute is visible only for zoned block devices. The default
897+
value for zoned block devices that are not rotational devices
898+
(e.g. ZNS SSDs or zoned UFS devices) is 0. For rotational zoned
899+
block devices (e.g. SMR HDDs) the default value is 1. Since
900+
this default may not be appropriate for some devices, e.g.
901+
remotely connected devices over high latency networks, the user
902+
can disable this feature by setting this attribute to 0.
903+
889904

890905
What: /sys/block/<disk>/hidden
891906
Date: March 2023
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
What: /sys/devices/virtual/nvme-fabrics/ctl/.../tls_configured_key
2+
Date: November 2025
3+
KernelVersion: 6.19
4+
Contact: Linux NVMe mailing list <linux-nvme@lists.infradead.org>
5+
Description:
6+
The file is avaliable when using a secure concatanation
7+
connection to a NVMe target. Reading the file will return
8+
the serial of the currently negotiated key.
9+
10+
Writing 0 to the file will trigger a PSK reauthentication
11+
(REPLACETLSPSK) with the target. After a reauthentication
12+
the value returned by tls_configured_key will be the new
13+
serial.

Documentation/admin-guide/blockdev/zoned_loop.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ The options available for the add command can be listed by reading the
6262
/dev/zloop-control device::
6363

6464
$ cat /dev/zloop-control
65-
add id=%d,capacity_mb=%u,zone_size_mb=%u,zone_capacity_mb=%u,conv_zones=%u,base_dir=%s,nr_queues=%u,queue_depth=%u,buffered_io
65+
add id=%d,capacity_mb=%u,zone_size_mb=%u,zone_capacity_mb=%u,conv_zones=%u,max_open_zones=%u,base_dir=%s,nr_queues=%u,queue_depth=%u,buffered_io,zone_append=%u,ordered_zone_append,discard_write_cache
6666
remove id=%d
6767

6868
In more details, the options that can be used with the "add" command are as
@@ -80,6 +80,9 @@ zone_capacity_mb Device zone capacity (must always be equal to or lower
8080
conv_zones Total number of conventioanl zones starting from
8181
sector 0
8282
Default: 8
83+
max_open_zones Maximum number of open sequential write required zones
84+
(0 for no limit).
85+
Default: 0
8386
base_dir Path to the base directory where to create the directory
8487
containing the zone files of the device.
8588
Default=/var/local/zloop.
@@ -104,6 +107,11 @@ ordered_zone_append Enable zloop mitigation of zone append reordering.
104107
(extents), as when enabled, this can significantly reduce
105108
the number of data extents needed to for a file data
106109
mapping.
110+
discard_write_cache Discard all data that was not explicitly persisted using a
111+
flush operation when the device is removed by truncating
112+
each zone file to the size recorded during the last flush
113+
operation. This simulates power fail events where
114+
uncommitted data is lost.
107115
=================== =========================================================
108116

109117
3) Deleting a Zoned Device

Documentation/block/inline-encryption.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ blk-crypto-fallback completes the original bio. If the original bio is too
153153
large, multiple bounce bios may be required; see the code for details.
154154

155155
For decryption, blk-crypto-fallback "wraps" the bio's completion callback
156-
(``bi_complete``) and private data (``bi_private``) with its own, unsets the
156+
(``bi_end_io``) and private data (``bi_private``) with its own, unsets the
157157
bio's encryption context, then submits the bio. If the read completes
158158
successfully, blk-crypto-fallback restores the bio's original completion
159159
callback and private data, then decrypts the bio's data in-place using the

block/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ bfq-y := bfq-iosched.o bfq-wf2q.o bfq-cgroup.o
2626
obj-$(CONFIG_IOSCHED_BFQ) += bfq.o
2727

2828
obj-$(CONFIG_BLK_DEV_INTEGRITY) += bio-integrity.o blk-integrity.o t10-pi.o \
29-
bio-integrity-auto.o
29+
bio-integrity-auto.o bio-integrity-fs.o
3030
obj-$(CONFIG_BLK_DEV_ZONED) += blk-zoned.o
3131
obj-$(CONFIG_BLK_WBT) += blk-wbt.o
3232
obj-$(CONFIG_BLK_DEBUG_FS) += blk-mq-debugfs.o

block/bio-integrity-auto.c

Lines changed: 11 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static void bio_integrity_verify_fn(struct work_struct *work)
3939
container_of(work, struct bio_integrity_data, work);
4040
struct bio *bio = bid->bio;
4141

42-
blk_integrity_verify_iter(bio, &bid->saved_bio_iter);
42+
bio->bi_status = bio_integrity_verify(bio, &bid->saved_bio_iter);
4343
bio_integrity_finish(bid);
4444
bio_endio(bio);
4545
}
@@ -50,11 +50,6 @@ static bool bip_should_check(struct bio_integrity_payload *bip)
5050
return bip->bip_flags & BIP_CHECK_FLAGS;
5151
}
5252

53-
static bool bi_offload_capable(struct blk_integrity *bi)
54-
{
55-
return bi->metadata_size == bi->pi_tuple_size;
56-
}
57-
5853
/**
5954
* __bio_integrity_endio - Integrity I/O completion function
6055
* @bio: Protected bio
@@ -84,83 +79,30 @@ bool __bio_integrity_endio(struct bio *bio)
8479
/**
8580
* bio_integrity_prep - Prepare bio for integrity I/O
8681
* @bio: bio to prepare
82+
* @action: preparation action needed (BI_ACT_*)
8783
*
88-
* Checks if the bio already has an integrity payload attached. If it does, the
89-
* payload has been generated by another kernel subsystem, and we just pass it
90-
* through.
91-
* Otherwise allocates integrity payload and for writes the integrity metadata
92-
* will be generated. For reads, the completion handler will verify the
93-
* metadata.
84+
* Allocate the integrity payload. For writes, generate the integrity metadata
85+
* and for reads, setup the completion handler to verify the metadata.
86+
*
87+
* This is used for bios that do not have user integrity payloads attached.
9488
*/
95-
bool bio_integrity_prep(struct bio *bio)
89+
void bio_integrity_prep(struct bio *bio, unsigned int action)
9690
{
97-
struct blk_integrity *bi = blk_get_integrity(bio->bi_bdev->bd_disk);
9891
struct bio_integrity_data *bid;
99-
bool set_flags = true;
100-
gfp_t gfp = GFP_NOIO;
101-
102-
if (!bi)
103-
return true;
104-
105-
if (!bio_sectors(bio))
106-
return true;
107-
108-
/* Already protected? */
109-
if (bio_integrity(bio))
110-
return true;
111-
112-
switch (bio_op(bio)) {
113-
case REQ_OP_READ:
114-
if (bi->flags & BLK_INTEGRITY_NOVERIFY) {
115-
if (bi_offload_capable(bi))
116-
return true;
117-
set_flags = false;
118-
}
119-
break;
120-
case REQ_OP_WRITE:
121-
/*
122-
* Zero the memory allocated to not leak uninitialized kernel
123-
* memory to disk for non-integrity metadata where nothing else
124-
* initializes the memory.
125-
*/
126-
if (bi->flags & BLK_INTEGRITY_NOGENERATE) {
127-
if (bi_offload_capable(bi))
128-
return true;
129-
set_flags = false;
130-
gfp |= __GFP_ZERO;
131-
} else if (bi->metadata_size > bi->pi_tuple_size)
132-
gfp |= __GFP_ZERO;
133-
break;
134-
default:
135-
return true;
136-
}
137-
138-
if (WARN_ON_ONCE(bio_has_crypt_ctx(bio)))
139-
return true;
14092

14193
bid = mempool_alloc(&bid_pool, GFP_NOIO);
14294
bio_integrity_init(bio, &bid->bip, &bid->bvec, 1);
14395
bid->bio = bio;
14496
bid->bip.bip_flags |= BIP_BLOCK_INTEGRITY;
145-
bio_integrity_alloc_buf(bio, gfp & __GFP_ZERO);
146-
147-
bip_set_seed(&bid->bip, bio->bi_iter.bi_sector);
148-
149-
if (set_flags) {
150-
if (bi->csum_type == BLK_INTEGRITY_CSUM_IP)
151-
bid->bip.bip_flags |= BIP_IP_CHECKSUM;
152-
if (bi->csum_type)
153-
bid->bip.bip_flags |= BIP_CHECK_GUARD;
154-
if (bi->flags & BLK_INTEGRITY_REF_TAG)
155-
bid->bip.bip_flags |= BIP_CHECK_REFTAG;
156-
}
97+
bio_integrity_alloc_buf(bio, action & BI_ACT_ZERO);
98+
if (action & BI_ACT_CHECK)
99+
bio_integrity_setup_default(bio);
157100

158101
/* Auto-generate integrity metadata if this is a write */
159102
if (bio_data_dir(bio) == WRITE && bip_should_check(&bid->bip))
160-
blk_integrity_generate(bio);
103+
bio_integrity_generate(bio);
161104
else
162105
bid->saved_bio_iter = bio->bi_iter;
163-
return true;
164106
}
165107
EXPORT_SYMBOL(bio_integrity_prep);
166108

block/bio-integrity-fs.c

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright (c) 2025 Christoph Hellwig.
4+
*/
5+
#include <linux/blk-integrity.h>
6+
#include <linux/bio-integrity.h>
7+
#include "blk.h"
8+
9+
struct fs_bio_integrity_buf {
10+
struct bio_integrity_payload bip;
11+
struct bio_vec bvec;
12+
};
13+
14+
static struct kmem_cache *fs_bio_integrity_cache;
15+
static mempool_t fs_bio_integrity_pool;
16+
17+
unsigned int fs_bio_integrity_alloc(struct bio *bio)
18+
{
19+
struct fs_bio_integrity_buf *iib;
20+
unsigned int action;
21+
22+
action = bio_integrity_action(bio);
23+
if (!action)
24+
return 0;
25+
26+
iib = mempool_alloc(&fs_bio_integrity_pool, GFP_NOIO);
27+
bio_integrity_init(bio, &iib->bip, &iib->bvec, 1);
28+
29+
bio_integrity_alloc_buf(bio, action & BI_ACT_ZERO);
30+
if (action & BI_ACT_CHECK)
31+
bio_integrity_setup_default(bio);
32+
return action;
33+
}
34+
35+
void fs_bio_integrity_free(struct bio *bio)
36+
{
37+
struct bio_integrity_payload *bip = bio_integrity(bio);
38+
39+
bio_integrity_free_buf(bip);
40+
mempool_free(container_of(bip, struct fs_bio_integrity_buf, bip),
41+
&fs_bio_integrity_pool);
42+
43+
bio->bi_integrity = NULL;
44+
bio->bi_opf &= ~REQ_INTEGRITY;
45+
}
46+
47+
void fs_bio_integrity_generate(struct bio *bio)
48+
{
49+
if (fs_bio_integrity_alloc(bio))
50+
bio_integrity_generate(bio);
51+
}
52+
EXPORT_SYMBOL_GPL(fs_bio_integrity_generate);
53+
54+
int fs_bio_integrity_verify(struct bio *bio, sector_t sector, unsigned int size)
55+
{
56+
struct blk_integrity *bi = blk_get_integrity(bio->bi_bdev->bd_disk);
57+
struct bio_integrity_payload *bip = bio_integrity(bio);
58+
59+
/*
60+
* Reinitialize bip->bip_iter.
61+
*
62+
* This is for use in the submitter after the driver is done with the
63+
* bio. Requires the submitter to remember the sector and the size.
64+
*/
65+
memset(&bip->bip_iter, 0, sizeof(bip->bip_iter));
66+
bip->bip_iter.bi_sector = sector;
67+
bip->bip_iter.bi_size = bio_integrity_bytes(bi, size >> SECTOR_SHIFT);
68+
return blk_status_to_errno(bio_integrity_verify(bio, &bip->bip_iter));
69+
}
70+
71+
static int __init fs_bio_integrity_init(void)
72+
{
73+
fs_bio_integrity_cache = kmem_cache_create("fs_bio_integrity",
74+
sizeof(struct fs_bio_integrity_buf), 0,
75+
SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL);
76+
if (mempool_init_slab_pool(&fs_bio_integrity_pool, BIO_POOL_SIZE,
77+
fs_bio_integrity_cache))
78+
panic("fs_bio_integrity: can't create pool\n");
79+
return 0;
80+
}
81+
fs_initcall(fs_bio_integrity_init);

block/bio-integrity.c

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
#include <linux/blk-integrity.h>
10+
#include <linux/t10-pi.h>
1011
#include "blk.h"
1112

1213
struct bio_integrity_alloc {
@@ -16,6 +17,53 @@ struct bio_integrity_alloc {
1617

1718
static mempool_t integrity_buf_pool;
1819

20+
static bool bi_offload_capable(struct blk_integrity *bi)
21+
{
22+
return bi->metadata_size == bi->pi_tuple_size;
23+
}
24+
25+
unsigned int __bio_integrity_action(struct bio *bio)
26+
{
27+
struct blk_integrity *bi = blk_get_integrity(bio->bi_bdev->bd_disk);
28+
29+
if (WARN_ON_ONCE(bio_has_crypt_ctx(bio)))
30+
return 0;
31+
32+
switch (bio_op(bio)) {
33+
case REQ_OP_READ:
34+
if (bi->flags & BLK_INTEGRITY_NOVERIFY) {
35+
if (bi_offload_capable(bi))
36+
return 0;
37+
return BI_ACT_BUFFER;
38+
}
39+
return BI_ACT_BUFFER | BI_ACT_CHECK;
40+
case REQ_OP_WRITE:
41+
/*
42+
* Flush masquerading as write?
43+
*/
44+
if (!bio_sectors(bio))
45+
return 0;
46+
47+
/*
48+
* Zero the memory allocated to not leak uninitialized kernel
49+
* memory to disk for non-integrity metadata where nothing else
50+
* initializes the memory.
51+
*/
52+
if (bi->flags & BLK_INTEGRITY_NOGENERATE) {
53+
if (bi_offload_capable(bi))
54+
return 0;
55+
return BI_ACT_BUFFER | BI_ACT_ZERO;
56+
}
57+
58+
if (bi->metadata_size > bi->pi_tuple_size)
59+
return BI_ACT_BUFFER | BI_ACT_CHECK | BI_ACT_ZERO;
60+
return BI_ACT_BUFFER | BI_ACT_CHECK;
61+
default:
62+
return 0;
63+
}
64+
}
65+
EXPORT_SYMBOL_GPL(__bio_integrity_action);
66+
1967
void bio_integrity_alloc_buf(struct bio *bio, bool zero_buffer)
2068
{
2169
struct blk_integrity *bi = blk_get_integrity(bio->bi_bdev->bd_disk);
@@ -53,6 +101,22 @@ void bio_integrity_free_buf(struct bio_integrity_payload *bip)
53101
kfree(bvec_virt(bv));
54102
}
55103

104+
void bio_integrity_setup_default(struct bio *bio)
105+
{
106+
struct blk_integrity *bi = blk_get_integrity(bio->bi_bdev->bd_disk);
107+
struct bio_integrity_payload *bip = bio_integrity(bio);
108+
109+
bip_set_seed(bip, bio->bi_iter.bi_sector);
110+
111+
if (bi->csum_type) {
112+
bip->bip_flags |= BIP_CHECK_GUARD;
113+
if (bi->csum_type == BLK_INTEGRITY_CSUM_IP)
114+
bip->bip_flags |= BIP_IP_CHECKSUM;
115+
}
116+
if (bi->flags & BLK_INTEGRITY_REF_TAG)
117+
bip->bip_flags |= BIP_CHECK_REFTAG;
118+
}
119+
56120
/**
57121
* bio_integrity_free - Free bio integrity payload
58122
* @bio: bio containing bip to be freed

0 commit comments

Comments
 (0)