Skip to content

Commit a689b93

Browse files
committed
Merge tag 'block-2023-01-06' of git://git.kernel.dk/linux
Pull block fixes from Jens Axboe: "The big change here is obviously the revert of the pktcdvd driver removal. Outside of that, just minor tweaks. In detail: - Re-instate the pktcdvd driver, which necessitates adding back bio_copy_data_iter() and the fops->devnode() hook for now (me) - Fix for splitting of a bio marked as NOWAIT, causing either nowait reads or writes to error with EAGAIN even if parts of the IO completed (me) - Fix for ublk, punting management commands to io-wq as they can all easily block for extended periods of time (Ming) - Removal of SRCU dependency for the block layer (Paul)" * tag 'block-2023-01-06' of git://git.kernel.dk/linux: block: Remove "select SRCU" Revert "pktcdvd: remove driver." Revert "block: remove devnode callback from struct block_device_operations" Revert "block: bio_copy_data_iter" ublk: honor IO_URING_F_NONBLOCK for handling control command block: don't allow splitting of a REQ_NOWAIT bio block: handle bio_split_to_limits() NULL return
2 parents ef1a4a7 + b2b50d5 commit a689b93

File tree

22 files changed

+3487
-18
lines changed

22 files changed

+3487
-18
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
What: /sys/kernel/debug/pktcdvd/pktcdvd[0-7]
2+
Date: Oct. 2006
3+
KernelVersion: 2.6.20
4+
Contact: Thomas Maier <[email protected]>
5+
Description:
6+
7+
The pktcdvd module (packet writing driver) creates
8+
these files in debugfs:
9+
10+
/sys/kernel/debug/pktcdvd/pktcdvd[0-7]/
11+
12+
==== ====== ====================================
13+
info 0444 Lots of driver statistics and infos.
14+
==== ====== ====================================
15+
16+
Example::
17+
18+
cat /sys/kernel/debug/pktcdvd/pktcdvd0/info
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
sysfs interface
2+
---------------
3+
The pktcdvd module (packet writing driver) creates the following files in the
4+
sysfs: (<devid> is in the format major:minor)
5+
6+
What: /sys/class/pktcdvd/add
7+
What: /sys/class/pktcdvd/remove
8+
What: /sys/class/pktcdvd/device_map
9+
Date: Oct. 2006
10+
KernelVersion: 2.6.20
11+
Contact: Thomas Maier <[email protected]>
12+
Description:
13+
14+
========== ==============================================
15+
add (WO) Write a block device id (major:minor) to
16+
create a new pktcdvd device and map it to the
17+
block device.
18+
19+
remove (WO) Write the pktcdvd device id (major:minor)
20+
to remove the pktcdvd device.
21+
22+
device_map (RO) Shows the device mapping in format:
23+
pktcdvd[0-7] <pktdevid> <blkdevid>
24+
========== ==============================================
25+
26+
27+
What: /sys/class/pktcdvd/pktcdvd[0-7]/dev
28+
What: /sys/class/pktcdvd/pktcdvd[0-7]/uevent
29+
Date: Oct. 2006
30+
KernelVersion: 2.6.20
31+
Contact: Thomas Maier <[email protected]>
32+
Description:
33+
dev: (RO) Device id
34+
35+
uevent: (WO) To send a uevent
36+
37+
38+
What: /sys/class/pktcdvd/pktcdvd[0-7]/stat/packets_started
39+
What: /sys/class/pktcdvd/pktcdvd[0-7]/stat/packets_finished
40+
What: /sys/class/pktcdvd/pktcdvd[0-7]/stat/kb_written
41+
What: /sys/class/pktcdvd/pktcdvd[0-7]/stat/kb_read
42+
What: /sys/class/pktcdvd/pktcdvd[0-7]/stat/kb_read_gather
43+
What: /sys/class/pktcdvd/pktcdvd[0-7]/stat/reset
44+
Date: Oct. 2006
45+
KernelVersion: 2.6.20
46+
Contact: Thomas Maier <[email protected]>
47+
Description:
48+
packets_started: (RO) Number of started packets.
49+
50+
packets_finished: (RO) Number of finished packets.
51+
52+
kb_written: (RO) kBytes written.
53+
54+
kb_read: (RO) kBytes read.
55+
56+
kb_read_gather: (RO) kBytes read to fill write packets.
57+
58+
reset: (WO) Write any value to it to reset
59+
pktcdvd device statistic values, like
60+
bytes read/written.
61+
62+
63+
What: /sys/class/pktcdvd/pktcdvd[0-7]/write_queue/size
64+
What: /sys/class/pktcdvd/pktcdvd[0-7]/write_queue/congestion_off
65+
What: /sys/class/pktcdvd/pktcdvd[0-7]/write_queue/congestion_on
66+
Date: Oct. 2006
67+
KernelVersion: 2.6.20
68+
Contact: Thomas Maier <[email protected]>
69+
Description:
70+
============== ================================================
71+
size (RO) Contains the size of the bio write queue.
72+
73+
congestion_off (RW) If bio write queue size is below this mark,
74+
accept new bio requests from the block layer.
75+
76+
congestion_on (RW) If bio write queue size is higher as this
77+
mark, do no longer accept bio write requests
78+
from the block layer and wait till the pktcdvd
79+
device has processed enough bio's so that bio
80+
write queue size is below congestion off mark.
81+
A value of <= 0 disables congestion control.
82+
============== ================================================
83+
84+
85+
Example:
86+
--------
87+
To use the pktcdvd sysfs interface directly, you can do::
88+
89+
# create a new pktcdvd device mapped to /dev/hdc
90+
echo "22:0" >/sys/class/pktcdvd/add
91+
cat /sys/class/pktcdvd/device_map
92+
# assuming device pktcdvd0 was created, look at stat's
93+
cat /sys/class/pktcdvd/pktcdvd0/stat/kb_written
94+
# print the device id of the mapped block device
95+
fgrep pktcdvd0 /sys/class/pktcdvd/device_map
96+
# remove device, using pktcdvd0 device id 253:0
97+
echo "253:0" >/sys/class/pktcdvd/remove

MAINTAINERS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16610,6 +16610,13 @@ S: Supported
1661016610
F: Documentation/devicetree/bindings/input/pine64,pinephone-keyboard.yaml
1661116611
F: drivers/input/keyboard/pinephone-keyboard.c
1661216612

16613+
PKTCDVD DRIVER
16614+
16615+
S: Orphan
16616+
F: drivers/block/pktcdvd.c
16617+
F: include/linux/pktcdvd.h
16618+
F: include/uapi/linux/pktcdvd.h
16619+
1661316620
PLANTOWER PMS7003 AIR POLLUTION SENSOR DRIVER
1661416621
M: Tomasz Duszynski <[email protected]>
1661516622
S: Maintained

block/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ menuconfig BLOCK
66
bool "Enable the block layer" if EXPERT
77
default y
88
select SBITMAP
9-
select SRCU
109
help
1110
Provide block layer support for the kernel.
1211

block/bio.c

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,27 @@ void __bio_advance(struct bio *bio, unsigned bytes)
14011401
}
14021402
EXPORT_SYMBOL(__bio_advance);
14031403

1404+
void bio_copy_data_iter(struct bio *dst, struct bvec_iter *dst_iter,
1405+
struct bio *src, struct bvec_iter *src_iter)
1406+
{
1407+
while (src_iter->bi_size && dst_iter->bi_size) {
1408+
struct bio_vec src_bv = bio_iter_iovec(src, *src_iter);
1409+
struct bio_vec dst_bv = bio_iter_iovec(dst, *dst_iter);
1410+
unsigned int bytes = min(src_bv.bv_len, dst_bv.bv_len);
1411+
void *src_buf = bvec_kmap_local(&src_bv);
1412+
void *dst_buf = bvec_kmap_local(&dst_bv);
1413+
1414+
memcpy(dst_buf, src_buf, bytes);
1415+
1416+
kunmap_local(dst_buf);
1417+
kunmap_local(src_buf);
1418+
1419+
bio_advance_iter_single(src, src_iter, bytes);
1420+
bio_advance_iter_single(dst, dst_iter, bytes);
1421+
}
1422+
}
1423+
EXPORT_SYMBOL(bio_copy_data_iter);
1424+
14041425
/**
14051426
* bio_copy_data - copy contents of data buffers from one bio to another
14061427
* @src: source bio
@@ -1414,21 +1435,7 @@ void bio_copy_data(struct bio *dst, struct bio *src)
14141435
struct bvec_iter src_iter = src->bi_iter;
14151436
struct bvec_iter dst_iter = dst->bi_iter;
14161437

1417-
while (src_iter.bi_size && dst_iter.bi_size) {
1418-
struct bio_vec src_bv = bio_iter_iovec(src, src_iter);
1419-
struct bio_vec dst_bv = bio_iter_iovec(dst, dst_iter);
1420-
unsigned int bytes = min(src_bv.bv_len, dst_bv.bv_len);
1421-
void *src_buf = bvec_kmap_local(&src_bv);
1422-
void *dst_buf = bvec_kmap_local(&dst_bv);
1423-
1424-
memcpy(dst_buf, src_buf, bytes);
1425-
1426-
kunmap_local(dst_buf);
1427-
kunmap_local(src_buf);
1428-
1429-
bio_advance_iter_single(src, &src_iter, bytes);
1430-
bio_advance_iter_single(dst, &dst_iter, bytes);
1431-
}
1438+
bio_copy_data_iter(dst, &dst_iter, src, &src_iter);
14321439
}
14331440
EXPORT_SYMBOL(bio_copy_data);
14341441

block/blk-merge.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,16 @@ static struct bio *bio_split_rw(struct bio *bio, const struct queue_limits *lim,
309309
*segs = nsegs;
310310
return NULL;
311311
split:
312+
/*
313+
* We can't sanely support splitting for a REQ_NOWAIT bio. End it
314+
* with EAGAIN if splitting is required and return an error pointer.
315+
*/
316+
if (bio->bi_opf & REQ_NOWAIT) {
317+
bio->bi_status = BLK_STS_AGAIN;
318+
bio_endio(bio);
319+
return ERR_PTR(-EAGAIN);
320+
}
321+
312322
*segs = nsegs;
313323

314324
/*
@@ -358,11 +368,13 @@ struct bio *__bio_split_to_limits(struct bio *bio,
358368
default:
359369
split = bio_split_rw(bio, lim, nr_segs, bs,
360370
get_max_io_size(bio, lim) << SECTOR_SHIFT);
371+
if (IS_ERR(split))
372+
return NULL;
361373
break;
362374
}
363375

364376
if (split) {
365-
/* there isn't chance to merge the splitted bio */
377+
/* there isn't chance to merge the split bio */
366378
split->bi_opf |= REQ_NOMERGE;
367379

368380
blkcg_bio_issue_init(split);

block/blk-mq.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2951,8 +2951,11 @@ void blk_mq_submit_bio(struct bio *bio)
29512951
blk_status_t ret;
29522952

29532953
bio = blk_queue_bounce(bio, q);
2954-
if (bio_may_exceed_limits(bio, &q->limits))
2954+
if (bio_may_exceed_limits(bio, &q->limits)) {
29552955
bio = __bio_split_to_limits(bio, &q->limits, &nr_segs);
2956+
if (!bio)
2957+
return;
2958+
}
29562959

29572960
if (!bio_integrity_prep(bio))
29582961
return;

block/genhd.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,10 +1201,21 @@ struct class block_class = {
12011201
.dev_uevent = block_uevent,
12021202
};
12031203

1204+
static char *block_devnode(struct device *dev, umode_t *mode,
1205+
kuid_t *uid, kgid_t *gid)
1206+
{
1207+
struct gendisk *disk = dev_to_disk(dev);
1208+
1209+
if (disk->fops->devnode)
1210+
return disk->fops->devnode(disk, mode);
1211+
return NULL;
1212+
}
1213+
12041214
const struct device_type disk_type = {
12051215
.name = "disk",
12061216
.groups = disk_attr_groups,
12071217
.release = disk_release,
1218+
.devnode = block_devnode,
12081219
};
12091220

12101221
#ifdef CONFIG_PROC_FS

drivers/block/Kconfig

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,49 @@ config BLK_DEV_RAM_SIZE
285285
The default value is 4096 kilobytes. Only change this if you know
286286
what you are doing.
287287

288+
config CDROM_PKTCDVD
289+
tristate "Packet writing on CD/DVD media (DEPRECATED)"
290+
depends on !UML
291+
depends on SCSI
292+
select CDROM
293+
help
294+
Note: This driver is deprecated and will be removed from the
295+
kernel in the near future!
296+
297+
If you have a CDROM/DVD drive that supports packet writing, say
298+
Y to include support. It should work with any MMC/Mt Fuji
299+
compliant ATAPI or SCSI drive, which is just about any newer
300+
DVD/CD writer.
301+
302+
Currently only writing to CD-RW, DVD-RW, DVD+RW and DVDRAM discs
303+
is possible.
304+
DVD-RW disks must be in restricted overwrite mode.
305+
306+
See the file <file:Documentation/cdrom/packet-writing.rst>
307+
for further information on the use of this driver.
308+
309+
To compile this driver as a module, choose M here: the
310+
module will be called pktcdvd.
311+
312+
config CDROM_PKTCDVD_BUFFERS
313+
int "Free buffers for data gathering"
314+
depends on CDROM_PKTCDVD
315+
default "8"
316+
help
317+
This controls the maximum number of active concurrent packets. More
318+
concurrent packets can increase write performance, but also require
319+
more memory. Each concurrent packet will require approximately 64Kb
320+
of non-swappable kernel memory, memory which will be allocated when
321+
a disc is opened for writing.
322+
323+
config CDROM_PKTCDVD_WCACHE
324+
bool "Enable write caching"
325+
depends on CDROM_PKTCDVD
326+
help
327+
If enabled, write caching will be set for the CD-R/W device. For now
328+
this option is dangerous unless the CD-RW media is known good, as we
329+
don't do deferred write error handling yet.
330+
288331
config ATA_OVER_ETH
289332
tristate "ATA over Ethernet support"
290333
depends on NET

drivers/block/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ obj-$(CONFIG_AMIGA_Z2RAM) += z2ram.o
2020
obj-$(CONFIG_N64CART) += n64cart.o
2121
obj-$(CONFIG_BLK_DEV_RAM) += brd.o
2222
obj-$(CONFIG_BLK_DEV_LOOP) += loop.o
23+
obj-$(CONFIG_CDROM_PKTCDVD) += pktcdvd.o
2324
obj-$(CONFIG_SUNVDC) += sunvdc.o
2425

2526
obj-$(CONFIG_BLK_DEV_NBD) += nbd.o

0 commit comments

Comments
 (0)