Skip to content

Commit f7c2ca2

Browse files
committed
Merge tag 'block-6.15-20250417' of git://git.kernel.dk/linux
Pull block fixes from Jens Axboe: - MD pull via Yu: - fix raid10 missing discard IO accounting (Yu Kuai) - fix bitmap stats for bitmap file (Zheng Qixing) - fix oops while reading all member disks failed during check/repair (Meir Elisha) - NVMe pull via Christoph: - fix scan failure for non-ANA multipath controllers (Hannes Reinecke) - fix multipath sysfs links creation for some cases (Hannes Reinecke) - PCIe endpoint fixes (Damien Le Moal) - use NULL instead of 0 in the auth code (Damien Le Moal) - Various ublk fixes: - Slew of selftest additions - Improvements and fixes for IO cancelation - Tweak to Kconfig verbiage - Fix for page dirtying for blk integrity mapped pages - loop fixes: - buffered IO fix - uevent fixes - request priority inheritance fix - Various little fixes * tag 'block-6.15-20250417' of git://git.kernel.dk/linux: (38 commits) selftests: ublk: add generic_06 for covering fault inject ublk: simplify aborting ublk request ublk: remove __ublk_quiesce_dev() ublk: improve detection and handling of ublk server exit ublk: move device reset into ublk_ch_release() ublk: rely on ->canceling for dealing with ublk_nosrv_dev_should_queue_io ublk: add ublk_force_abort_dev() ublk: properly serialize all FETCH_REQs selftests: ublk: move creating UBLK_TMP into _prep_test() selftests: ublk: add test_stress_05.sh selftests: ublk: support user recovery selftests: ublk: support target specific command line selftests: ublk: increase max nr_queues and queue depth selftests: ublk: set queue pthread's cpu affinity selftests: ublk: setup ring with IORING_SETUP_SINGLE_ISSUER/IORING_SETUP_DEFER_TASKRUN selftests: ublk: add two stress tests for zero copy feature selftests: ublk: run stress tests in parallel selftests: ublk: make sure _add_ublk_dev can return in sub-shell selftests: ublk: cleanup backfile automatically selftests: ublk: add io_uring uapi header ...
2 parents b1011b2 + 81dd1fe commit f7c2ca2

36 files changed

+1325
-604
lines changed

block/bio-integrity.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,12 @@ struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio,
6666
}
6767
EXPORT_SYMBOL(bio_integrity_alloc);
6868

69-
static void bio_integrity_unpin_bvec(struct bio_vec *bv, int nr_vecs,
70-
bool dirty)
69+
static void bio_integrity_unpin_bvec(struct bio_vec *bv, int nr_vecs)
7170
{
7271
int i;
7372

74-
for (i = 0; i < nr_vecs; i++) {
75-
if (dirty && !PageCompound(bv[i].bv_page))
76-
set_page_dirty_lock(bv[i].bv_page);
73+
for (i = 0; i < nr_vecs; i++)
7774
unpin_user_page(bv[i].bv_page);
78-
}
7975
}
8076

8177
static void bio_integrity_uncopy_user(struct bio_integrity_payload *bip)
@@ -91,7 +87,7 @@ static void bio_integrity_uncopy_user(struct bio_integrity_payload *bip)
9187
ret = copy_to_iter(bvec_virt(bounce_bvec), bytes, &orig_iter);
9288
WARN_ON_ONCE(ret != bytes);
9389

94-
bio_integrity_unpin_bvec(orig_bvecs, orig_nr_vecs, true);
90+
bio_integrity_unpin_bvec(orig_bvecs, orig_nr_vecs);
9591
}
9692

9793
/**
@@ -111,8 +107,7 @@ void bio_integrity_unmap_user(struct bio *bio)
111107
return;
112108
}
113109

114-
bio_integrity_unpin_bvec(bip->bip_vec, bip->bip_max_vcnt,
115-
bio_data_dir(bio) == READ);
110+
bio_integrity_unpin_bvec(bip->bip_vec, bip->bip_max_vcnt);
116111
}
117112

118113
/**
@@ -198,7 +193,7 @@ static int bio_integrity_copy_user(struct bio *bio, struct bio_vec *bvec,
198193
}
199194

200195
if (write)
201-
bio_integrity_unpin_bvec(bvec, nr_vecs, false);
196+
bio_integrity_unpin_bvec(bvec, nr_vecs);
202197
else
203198
memcpy(&bip->bip_vec[1], bvec, nr_vecs * sizeof(*bvec));
204199

@@ -319,7 +314,7 @@ int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter)
319314
return 0;
320315

321316
release_pages:
322-
bio_integrity_unpin_bvec(bvec, nr_bvecs, false);
317+
bio_integrity_unpin_bvec(bvec, nr_bvecs);
323318
free_bvec:
324319
if (bvec != stack_vec)
325320
kfree(bvec);

block/blk-sysfs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,8 @@ int blk_register_queue(struct gendisk *disk)
909909
out_debugfs_remove:
910910
blk_debugfs_remove(disk);
911911
mutex_unlock(&q->sysfs_lock);
912+
if (queue_is_mq(q))
913+
blk_mq_sysfs_unregister(disk);
912914
out_put_queue_kobj:
913915
kobject_put(&disk->queue_kobj);
914916
return ret;

block/blk-throttle.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
12
#ifndef BLK_THROTTLE_H
23
#define BLK_THROTTLE_H
34

drivers/block/Kconfig

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -388,12 +388,6 @@ config BLK_DEV_UBLK
388388
definition isn't finalized yet, and might change according to future
389389
requirement, so mark is as experimental now.
390390

391-
Say Y if you want to get better performance because task_work_add()
392-
can be used in IO path for replacing io_uring cmd, which will become
393-
shared between IO tasks and ubq daemon, meantime task_work_add() can
394-
can handle batch more effectively, but task_work_add() isn't exported
395-
for module, so ublk has to be built to kernel.
396-
397391
config BLKDEV_UBLK_LEGACY_OPCODES
398392
bool "Support legacy command opcode"
399393
depends on BLK_DEV_UBLK

drivers/block/loop.c

Lines changed: 22 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -211,72 +211,6 @@ static void loop_set_size(struct loop_device *lo, loff_t size)
211211
kobject_uevent(&disk_to_dev(lo->lo_disk)->kobj, KOBJ_CHANGE);
212212
}
213213

214-
static int lo_write_bvec(struct file *file, struct bio_vec *bvec, loff_t *ppos)
215-
{
216-
struct iov_iter i;
217-
ssize_t bw;
218-
219-
iov_iter_bvec(&i, ITER_SOURCE, bvec, 1, bvec->bv_len);
220-
221-
bw = vfs_iter_write(file, &i, ppos, 0);
222-
223-
if (likely(bw == bvec->bv_len))
224-
return 0;
225-
226-
printk_ratelimited(KERN_ERR
227-
"loop: Write error at byte offset %llu, length %i.\n",
228-
(unsigned long long)*ppos, bvec->bv_len);
229-
if (bw >= 0)
230-
bw = -EIO;
231-
return bw;
232-
}
233-
234-
static int lo_write_simple(struct loop_device *lo, struct request *rq,
235-
loff_t pos)
236-
{
237-
struct bio_vec bvec;
238-
struct req_iterator iter;
239-
int ret = 0;
240-
241-
rq_for_each_segment(bvec, rq, iter) {
242-
ret = lo_write_bvec(lo->lo_backing_file, &bvec, &pos);
243-
if (ret < 0)
244-
break;
245-
cond_resched();
246-
}
247-
248-
return ret;
249-
}
250-
251-
static int lo_read_simple(struct loop_device *lo, struct request *rq,
252-
loff_t pos)
253-
{
254-
struct bio_vec bvec;
255-
struct req_iterator iter;
256-
struct iov_iter i;
257-
ssize_t len;
258-
259-
rq_for_each_segment(bvec, rq, iter) {
260-
iov_iter_bvec(&i, ITER_DEST, &bvec, 1, bvec.bv_len);
261-
len = vfs_iter_read(lo->lo_backing_file, &i, &pos, 0);
262-
if (len < 0)
263-
return len;
264-
265-
flush_dcache_page(bvec.bv_page);
266-
267-
if (len != bvec.bv_len) {
268-
struct bio *bio;
269-
270-
__rq_for_each_bio(bio, rq)
271-
zero_fill_bio(bio);
272-
break;
273-
}
274-
cond_resched();
275-
}
276-
277-
return 0;
278-
}
279-
280214
static void loop_clear_limits(struct loop_device *lo, int mode)
281215
{
282216
struct queue_limits lim = queue_limits_start_update(lo->lo_queue);
@@ -342,7 +276,7 @@ static void lo_complete_rq(struct request *rq)
342276
struct loop_cmd *cmd = blk_mq_rq_to_pdu(rq);
343277
blk_status_t ret = BLK_STS_OK;
344278

345-
if (!cmd->use_aio || cmd->ret < 0 || cmd->ret == blk_rq_bytes(rq) ||
279+
if (cmd->ret < 0 || cmd->ret == blk_rq_bytes(rq) ||
346280
req_op(rq) != REQ_OP_READ) {
347281
if (cmd->ret < 0)
348282
ret = errno_to_blk_status(cmd->ret);
@@ -358,14 +292,13 @@ static void lo_complete_rq(struct request *rq)
358292
cmd->ret = 0;
359293
blk_mq_requeue_request(rq, true);
360294
} else {
361-
if (cmd->use_aio) {
362-
struct bio *bio = rq->bio;
295+
struct bio *bio = rq->bio;
363296

364-
while (bio) {
365-
zero_fill_bio(bio);
366-
bio = bio->bi_next;
367-
}
297+
while (bio) {
298+
zero_fill_bio(bio);
299+
bio = bio->bi_next;
368300
}
301+
369302
ret = BLK_STS_IOERR;
370303
end_io:
371304
blk_mq_end_request(rq, ret);
@@ -445,9 +378,14 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
445378

446379
cmd->iocb.ki_pos = pos;
447380
cmd->iocb.ki_filp = file;
448-
cmd->iocb.ki_complete = lo_rw_aio_complete;
449-
cmd->iocb.ki_flags = IOCB_DIRECT;
450-
cmd->iocb.ki_ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0);
381+
cmd->iocb.ki_ioprio = req_get_ioprio(rq);
382+
if (cmd->use_aio) {
383+
cmd->iocb.ki_complete = lo_rw_aio_complete;
384+
cmd->iocb.ki_flags = IOCB_DIRECT;
385+
} else {
386+
cmd->iocb.ki_complete = NULL;
387+
cmd->iocb.ki_flags = 0;
388+
}
451389

452390
if (rw == ITER_SOURCE)
453391
ret = file->f_op->write_iter(&cmd->iocb, &iter);
@@ -458,23 +396,14 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
458396

459397
if (ret != -EIOCBQUEUED)
460398
lo_rw_aio_complete(&cmd->iocb, ret);
461-
return 0;
399+
return -EIOCBQUEUED;
462400
}
463401

464402
static int do_req_filebacked(struct loop_device *lo, struct request *rq)
465403
{
466404
struct loop_cmd *cmd = blk_mq_rq_to_pdu(rq);
467405
loff_t pos = ((loff_t) blk_rq_pos(rq) << 9) + lo->lo_offset;
468406

469-
/*
470-
* lo_write_simple and lo_read_simple should have been covered
471-
* by io submit style function like lo_rw_aio(), one blocker
472-
* is that lo_read_simple() need to call flush_dcache_page after
473-
* the page is written from kernel, and it isn't easy to handle
474-
* this in io submit style function which submits all segments
475-
* of the req at one time. And direct read IO doesn't need to
476-
* run flush_dcache_page().
477-
*/
478407
switch (req_op(rq)) {
479408
case REQ_OP_FLUSH:
480409
return lo_req_flush(lo, rq);
@@ -490,15 +419,9 @@ static int do_req_filebacked(struct loop_device *lo, struct request *rq)
490419
case REQ_OP_DISCARD:
491420
return lo_fallocate(lo, rq, pos, FALLOC_FL_PUNCH_HOLE);
492421
case REQ_OP_WRITE:
493-
if (cmd->use_aio)
494-
return lo_rw_aio(lo, cmd, pos, ITER_SOURCE);
495-
else
496-
return lo_write_simple(lo, rq, pos);
422+
return lo_rw_aio(lo, cmd, pos, ITER_SOURCE);
497423
case REQ_OP_READ:
498-
if (cmd->use_aio)
499-
return lo_rw_aio(lo, cmd, pos, ITER_DEST);
500-
else
501-
return lo_read_simple(lo, rq, pos);
424+
return lo_rw_aio(lo, cmd, pos, ITER_DEST);
502425
default:
503426
WARN_ON_ONCE(1);
504427
return -EIO;
@@ -662,19 +585,20 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
662585
* dependency.
663586
*/
664587
fput(old_file);
588+
dev_set_uevent_suppress(disk_to_dev(lo->lo_disk), 0);
665589
if (partscan)
666590
loop_reread_partitions(lo);
667591

668592
error = 0;
669593
done:
670-
/* enable and uncork uevent now that we are done */
671-
dev_set_uevent_suppress(disk_to_dev(lo->lo_disk), 0);
594+
kobject_uevent(&disk_to_dev(lo->lo_disk)->kobj, KOBJ_CHANGE);
672595
return error;
673596

674597
out_err:
675598
loop_global_unlock(lo, is_loop);
676599
out_putf:
677600
fput(file);
601+
dev_set_uevent_suppress(disk_to_dev(lo->lo_disk), 0);
678602
goto done;
679603
}
680604

@@ -1129,8 +1053,8 @@ static int loop_configure(struct loop_device *lo, blk_mode_t mode,
11291053
if (partscan)
11301054
clear_bit(GD_SUPPRESS_PART_SCAN, &lo->lo_disk->state);
11311055

1132-
/* enable and uncork uevent now that we are done */
11331056
dev_set_uevent_suppress(disk_to_dev(lo->lo_disk), 0);
1057+
kobject_uevent(&disk_to_dev(lo->lo_disk)->kobj, KOBJ_CHANGE);
11341058

11351059
loop_global_unlock(lo, is_loop);
11361060
if (partscan)
@@ -1921,7 +1845,6 @@ static void loop_handle_cmd(struct loop_cmd *cmd)
19211845
struct loop_device *lo = rq->q->queuedata;
19221846
int ret = 0;
19231847
struct mem_cgroup *old_memcg = NULL;
1924-
const bool use_aio = cmd->use_aio;
19251848

19261849
if (write && (lo->lo_flags & LO_FLAGS_READ_ONLY)) {
19271850
ret = -EIO;
@@ -1951,7 +1874,7 @@ static void loop_handle_cmd(struct loop_cmd *cmd)
19511874
}
19521875
failed:
19531876
/* complete non-aio request */
1954-
if (!use_aio || ret) {
1877+
if (ret != -EIOCBQUEUED) {
19551878
if (ret == -EOPNOTSUPP)
19561879
cmd->ret = ret;
19571880
else

0 commit comments

Comments
 (0)