Skip to content

Commit 6d88542

Browse files
committed
Merge tag 'block-6.16-20250606' of git://git.kernel.dk/linux
Pull more block updates from Jens Axboe: - NVMe pull request via Christoph: - TCP error handling fix (Shin'ichiro Kawasaki) - TCP I/O stall handling fixes (Hannes Reinecke) - fix command limits status code (Keith Busch) - support vectored buffers also for passthrough (Pavel Begunkov) - spelling fixes (Yi Zhang) - MD pull request via Yu: - fix REQ_RAHEAD and REQ_NOWAIT IO err handling for raid1/10 - fix max_write_behind setting for dm-raid - some minor cleanups - Integrity data direction fix and cleanup - bcache NULL pointer fix - Fix for loop missing write start/end handling - Decouple hardware queues and IO threads in ublk - Slew of ublk selftests additions and updates * tag 'block-6.16-20250606' of git://git.kernel.dk/linux: (29 commits) nvme: spelling fixes nvme-tcp: fix I/O stalls on congested sockets nvme-tcp: sanitize request list handling nvme-tcp: remove tag set when second admin queue config fails nvme: enable vectored registered bufs for passthrough cmds nvme: fix implicit bool to flags conversion nvme: fix command limits status code selftests: ublk: kublk: improve behavior on init failure block: flip iter directions in blk_rq_integrity_map_user() block: drop direction param from bio_integrity_copy_user() selftests: ublk: cover PER_IO_DAEMON in more stress tests Documentation: ublk: document UBLK_F_PER_IO_DAEMON selftests: ublk: add stress test for per io daemons selftests: ublk: add functional test for per io daemons selftests: ublk: kublk: decouple ublk_queues from ublk server threads selftests: ublk: kublk: move per-thread data out of ublk_queue selftests: ublk: kublk: lift queue initialization out of thread selftests: ublk: kublk: tie sqe allocation to io instead of queue selftests: ublk: kublk: plumb q_id in io_uring user_data ublk: have a per-io daemon instead of a per-queue daemon ...
2 parents 794a549 + 6f65947 commit 6d88542

Some content is hidden

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

48 files changed

+693
-378
lines changed

Documentation/block/ublk.rst

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,15 @@ managing and controlling ublk devices with help of several control commands:
115115

116116
- ``UBLK_CMD_START_DEV``
117117

118-
After the server prepares userspace resources (such as creating per-queue
119-
pthread & io_uring for handling ublk IO), this command is sent to the
118+
After the server prepares userspace resources (such as creating I/O handler
119+
threads & io_uring for handling ublk IO), this command is sent to the
120120
driver for allocating & exposing ``/dev/ublkb*``. Parameters set via
121121
``UBLK_CMD_SET_PARAMS`` are applied for creating the device.
122122

123123
- ``UBLK_CMD_STOP_DEV``
124124

125125
Halt IO on ``/dev/ublkb*`` and remove the device. When this command returns,
126-
ublk server will release resources (such as destroying per-queue pthread &
126+
ublk server will release resources (such as destroying I/O handler threads &
127127
io_uring).
128128

129129
- ``UBLK_CMD_DEL_DEV``
@@ -208,15 +208,15 @@ managing and controlling ublk devices with help of several control commands:
208208
modify how I/O is handled while the ublk server is dying/dead (this is called
209209
the ``nosrv`` case in the driver code).
210210

211-
With just ``UBLK_F_USER_RECOVERY`` set, after one ubq_daemon(ublk server's io
212-
handler) is dying, ublk does not delete ``/dev/ublkb*`` during the whole
211+
With just ``UBLK_F_USER_RECOVERY`` set, after the ublk server exits,
212+
ublk does not delete ``/dev/ublkb*`` during the whole
213213
recovery stage and ublk device ID is kept. It is ublk server's
214214
responsibility to recover the device context by its own knowledge.
215215
Requests which have not been issued to userspace are requeued. Requests
216216
which have been issued to userspace are aborted.
217217

218-
With ``UBLK_F_USER_RECOVERY_REISSUE`` additionally set, after one ubq_daemon
219-
(ublk server's io handler) is dying, contrary to ``UBLK_F_USER_RECOVERY``,
218+
With ``UBLK_F_USER_RECOVERY_REISSUE`` additionally set, after the ublk server
219+
exits, contrary to ``UBLK_F_USER_RECOVERY``,
220220
requests which have been issued to userspace are requeued and will be
221221
re-issued to the new process after handling ``UBLK_CMD_END_USER_RECOVERY``.
222222
``UBLK_F_USER_RECOVERY_REISSUE`` is designed for backends who tolerate
@@ -241,10 +241,11 @@ can be controlled/accessed just inside this container.
241241
Data plane
242242
----------
243243

244-
ublk server needs to create per-queue IO pthread & io_uring for handling IO
245-
commands via io_uring passthrough. The per-queue IO pthread
246-
focuses on IO handling and shouldn't handle any control & management
247-
tasks.
244+
The ublk server should create dedicated threads for handling I/O. Each
245+
thread should have its own io_uring through which it is notified of new
246+
I/O, and through which it can complete I/O. These dedicated threads
247+
should focus on IO handling and shouldn't handle any control &
248+
management tasks.
248249

249250
The's IO is assigned by a unique tag, which is 1:1 mapping with IO
250251
request of ``/dev/ublkb*``.
@@ -265,6 +266,18 @@ with specified IO tag in the command data:
265266
destined to ``/dev/ublkb*``. This command is sent only once from the server
266267
IO pthread for ublk driver to setup IO forward environment.
267268

269+
Once a thread issues this command against a given (qid,tag) pair, the thread
270+
registers itself as that I/O's daemon. In the future, only that I/O's daemon
271+
is allowed to issue commands against the I/O. If any other thread attempts
272+
to issue a command against a (qid,tag) pair for which the thread is not the
273+
daemon, the command will fail. Daemons can be reset only be going through
274+
recovery.
275+
276+
The ability for every (qid,tag) pair to have its own independent daemon task
277+
is indicated by the ``UBLK_F_PER_IO_DAEMON`` feature. If this feature is not
278+
supported by the driver, daemons must be per-queue instead - i.e. all I/Os
279+
associated to a single qid must be handled by the same task.
280+
268281
- ``UBLK_IO_COMMIT_AND_FETCH_REQ``
269282

270283
When an IO request is destined to ``/dev/ublkb*``, the driver stores

block/bio-integrity.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,9 @@ int bio_integrity_add_page(struct bio *bio, struct page *page,
154154
EXPORT_SYMBOL(bio_integrity_add_page);
155155

156156
static int bio_integrity_copy_user(struct bio *bio, struct bio_vec *bvec,
157-
int nr_vecs, unsigned int len,
158-
unsigned int direction)
157+
int nr_vecs, unsigned int len)
159158
{
160-
bool write = direction == ITER_SOURCE;
159+
bool write = op_is_write(bio_op(bio));
161160
struct bio_integrity_payload *bip;
162161
struct iov_iter iter;
163162
void *buf;
@@ -168,7 +167,7 @@ static int bio_integrity_copy_user(struct bio *bio, struct bio_vec *bvec,
168167
return -ENOMEM;
169168

170169
if (write) {
171-
iov_iter_bvec(&iter, direction, bvec, nr_vecs, len);
170+
iov_iter_bvec(&iter, ITER_SOURCE, bvec, nr_vecs, len);
172171
if (!copy_from_iter_full(buf, len, &iter)) {
173172
ret = -EFAULT;
174173
goto free_buf;
@@ -264,7 +263,7 @@ int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter)
264263
struct page *stack_pages[UIO_FASTIOV], **pages = stack_pages;
265264
struct bio_vec stack_vec[UIO_FASTIOV], *bvec = stack_vec;
266265
size_t offset, bytes = iter->count;
267-
unsigned int direction, nr_bvecs;
266+
unsigned int nr_bvecs;
268267
int ret, nr_vecs;
269268
bool copy;
270269

@@ -273,11 +272,6 @@ int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter)
273272
if (bytes >> SECTOR_SHIFT > queue_max_hw_sectors(q))
274273
return -E2BIG;
275274

276-
if (bio_data_dir(bio) == READ)
277-
direction = ITER_DEST;
278-
else
279-
direction = ITER_SOURCE;
280-
281275
nr_vecs = iov_iter_npages(iter, BIO_MAX_VECS + 1);
282276
if (nr_vecs > BIO_MAX_VECS)
283277
return -E2BIG;
@@ -300,8 +294,7 @@ int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter)
300294
copy = true;
301295

302296
if (copy)
303-
ret = bio_integrity_copy_user(bio, bvec, nr_bvecs, bytes,
304-
direction);
297+
ret = bio_integrity_copy_user(bio, bvec, nr_bvecs, bytes);
305298
else
306299
ret = bio_integrity_init_user(bio, bvec, nr_bvecs, bytes);
307300
if (ret)

block/blk-integrity.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,8 @@ int blk_rq_integrity_map_user(struct request *rq, void __user *ubuf,
117117
{
118118
int ret;
119119
struct iov_iter iter;
120-
unsigned int direction;
121120

122-
if (op_is_write(req_op(rq)))
123-
direction = ITER_DEST;
124-
else
125-
direction = ITER_SOURCE;
126-
iov_iter_ubuf(&iter, direction, ubuf, bytes);
121+
iov_iter_ubuf(&iter, rq_data_dir(rq), ubuf, bytes);
127122
ret = bio_integrity_map_user(rq->bio, &iter);
128123
if (ret)
129124
return ret;

drivers/block/loop.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,14 @@ static void lo_complete_rq(struct request *rq)
308308
static void lo_rw_aio_do_completion(struct loop_cmd *cmd)
309309
{
310310
struct request *rq = blk_mq_rq_from_pdu(cmd);
311+
struct loop_device *lo = rq->q->queuedata;
311312

312313
if (!atomic_dec_and_test(&cmd->ref))
313314
return;
314315
kfree(cmd->bvec);
315316
cmd->bvec = NULL;
317+
if (req_op(rq) == REQ_OP_WRITE)
318+
file_end_write(lo->lo_backing_file);
316319
if (likely(!blk_should_fake_timeout(rq->q)))
317320
blk_mq_complete_request(rq);
318321
}
@@ -387,9 +390,10 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
387390
cmd->iocb.ki_flags = 0;
388391
}
389392

390-
if (rw == ITER_SOURCE)
393+
if (rw == ITER_SOURCE) {
394+
file_start_write(lo->lo_backing_file);
391395
ret = file->f_op->write_iter(&cmd->iocb, &iter);
392-
else
396+
} else
393397
ret = file->f_op->read_iter(&cmd->iocb, &iter);
394398

395399
lo_rw_aio_do_completion(cmd);

0 commit comments

Comments
 (0)