Commit a689b938 authored by Linus Torvalds's avatar Linus Torvalds

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
parents ef1a4a77 b2b50d57
What: /sys/kernel/debug/pktcdvd/pktcdvd[0-7]
Date: Oct. 2006
KernelVersion: 2.6.20
Contact: Thomas Maier <balagi@justmail.de>
Description:
The pktcdvd module (packet writing driver) creates
these files in debugfs:
/sys/kernel/debug/pktcdvd/pktcdvd[0-7]/
==== ====== ====================================
info 0444 Lots of driver statistics and infos.
==== ====== ====================================
Example::
cat /sys/kernel/debug/pktcdvd/pktcdvd0/info
sysfs interface
---------------
The pktcdvd module (packet writing driver) creates the following files in the
sysfs: (<devid> is in the format major:minor)
What: /sys/class/pktcdvd/add
What: /sys/class/pktcdvd/remove
What: /sys/class/pktcdvd/device_map
Date: Oct. 2006
KernelVersion: 2.6.20
Contact: Thomas Maier <balagi@justmail.de>
Description:
========== ==============================================
add (WO) Write a block device id (major:minor) to
create a new pktcdvd device and map it to the
block device.
remove (WO) Write the pktcdvd device id (major:minor)
to remove the pktcdvd device.
device_map (RO) Shows the device mapping in format:
pktcdvd[0-7] <pktdevid> <blkdevid>
========== ==============================================
What: /sys/class/pktcdvd/pktcdvd[0-7]/dev
What: /sys/class/pktcdvd/pktcdvd[0-7]/uevent
Date: Oct. 2006
KernelVersion: 2.6.20
Contact: Thomas Maier <balagi@justmail.de>
Description:
dev: (RO) Device id
uevent: (WO) To send a uevent
What: /sys/class/pktcdvd/pktcdvd[0-7]/stat/packets_started
What: /sys/class/pktcdvd/pktcdvd[0-7]/stat/packets_finished
What: /sys/class/pktcdvd/pktcdvd[0-7]/stat/kb_written
What: /sys/class/pktcdvd/pktcdvd[0-7]/stat/kb_read
What: /sys/class/pktcdvd/pktcdvd[0-7]/stat/kb_read_gather
What: /sys/class/pktcdvd/pktcdvd[0-7]/stat/reset
Date: Oct. 2006
KernelVersion: 2.6.20
Contact: Thomas Maier <balagi@justmail.de>
Description:
packets_started: (RO) Number of started packets.
packets_finished: (RO) Number of finished packets.
kb_written: (RO) kBytes written.
kb_read: (RO) kBytes read.
kb_read_gather: (RO) kBytes read to fill write packets.
reset: (WO) Write any value to it to reset
pktcdvd device statistic values, like
bytes read/written.
What: /sys/class/pktcdvd/pktcdvd[0-7]/write_queue/size
What: /sys/class/pktcdvd/pktcdvd[0-7]/write_queue/congestion_off
What: /sys/class/pktcdvd/pktcdvd[0-7]/write_queue/congestion_on
Date: Oct. 2006
KernelVersion: 2.6.20
Contact: Thomas Maier <balagi@justmail.de>
Description:
============== ================================================
size (RO) Contains the size of the bio write queue.
congestion_off (RW) If bio write queue size is below this mark,
accept new bio requests from the block layer.
congestion_on (RW) If bio write queue size is higher as this
mark, do no longer accept bio write requests
from the block layer and wait till the pktcdvd
device has processed enough bio's so that bio
write queue size is below congestion off mark.
A value of <= 0 disables congestion control.
============== ================================================
Example:
--------
To use the pktcdvd sysfs interface directly, you can do::
# create a new pktcdvd device mapped to /dev/hdc
echo "22:0" >/sys/class/pktcdvd/add
cat /sys/class/pktcdvd/device_map
# assuming device pktcdvd0 was created, look at stat's
cat /sys/class/pktcdvd/pktcdvd0/stat/kb_written
# print the device id of the mapped block device
fgrep pktcdvd0 /sys/class/pktcdvd/device_map
# remove device, using pktcdvd0 device id 253:0
echo "253:0" >/sys/class/pktcdvd/remove
...@@ -16610,6 +16610,13 @@ S: Supported ...@@ -16610,6 +16610,13 @@ S: Supported
F: Documentation/devicetree/bindings/input/pine64,pinephone-keyboard.yaml F: Documentation/devicetree/bindings/input/pine64,pinephone-keyboard.yaml
F: drivers/input/keyboard/pinephone-keyboard.c F: drivers/input/keyboard/pinephone-keyboard.c
PKTCDVD DRIVER
M: linux-block@vger.kernel.org
S: Orphan
F: drivers/block/pktcdvd.c
F: include/linux/pktcdvd.h
F: include/uapi/linux/pktcdvd.h
PLANTOWER PMS7003 AIR POLLUTION SENSOR DRIVER PLANTOWER PMS7003 AIR POLLUTION SENSOR DRIVER
M: Tomasz Duszynski <tduszyns@gmail.com> M: Tomasz Duszynski <tduszyns@gmail.com>
S: Maintained S: Maintained
......
...@@ -6,7 +6,6 @@ menuconfig BLOCK ...@@ -6,7 +6,6 @@ menuconfig BLOCK
bool "Enable the block layer" if EXPERT bool "Enable the block layer" if EXPERT
default y default y
select SBITMAP select SBITMAP
select SRCU
help help
Provide block layer support for the kernel. Provide block layer support for the kernel.
......
...@@ -1401,6 +1401,27 @@ void __bio_advance(struct bio *bio, unsigned bytes) ...@@ -1401,6 +1401,27 @@ void __bio_advance(struct bio *bio, unsigned bytes)
} }
EXPORT_SYMBOL(__bio_advance); EXPORT_SYMBOL(__bio_advance);
void bio_copy_data_iter(struct bio *dst, struct bvec_iter *dst_iter,
struct bio *src, struct bvec_iter *src_iter)
{
while (src_iter->bi_size && dst_iter->bi_size) {
struct bio_vec src_bv = bio_iter_iovec(src, *src_iter);
struct bio_vec dst_bv = bio_iter_iovec(dst, *dst_iter);
unsigned int bytes = min(src_bv.bv_len, dst_bv.bv_len);
void *src_buf = bvec_kmap_local(&src_bv);
void *dst_buf = bvec_kmap_local(&dst_bv);
memcpy(dst_buf, src_buf, bytes);
kunmap_local(dst_buf);
kunmap_local(src_buf);
bio_advance_iter_single(src, src_iter, bytes);
bio_advance_iter_single(dst, dst_iter, bytes);
}
}
EXPORT_SYMBOL(bio_copy_data_iter);
/** /**
* bio_copy_data - copy contents of data buffers from one bio to another * bio_copy_data - copy contents of data buffers from one bio to another
* @src: source bio * @src: source bio
...@@ -1414,21 +1435,7 @@ void bio_copy_data(struct bio *dst, struct bio *src) ...@@ -1414,21 +1435,7 @@ void bio_copy_data(struct bio *dst, struct bio *src)
struct bvec_iter src_iter = src->bi_iter; struct bvec_iter src_iter = src->bi_iter;
struct bvec_iter dst_iter = dst->bi_iter; struct bvec_iter dst_iter = dst->bi_iter;
while (src_iter.bi_size && dst_iter.bi_size) { bio_copy_data_iter(dst, &dst_iter, src, &src_iter);
struct bio_vec src_bv = bio_iter_iovec(src, src_iter);
struct bio_vec dst_bv = bio_iter_iovec(dst, dst_iter);
unsigned int bytes = min(src_bv.bv_len, dst_bv.bv_len);
void *src_buf = bvec_kmap_local(&src_bv);
void *dst_buf = bvec_kmap_local(&dst_bv);
memcpy(dst_buf, src_buf, bytes);
kunmap_local(dst_buf);
kunmap_local(src_buf);
bio_advance_iter_single(src, &src_iter, bytes);
bio_advance_iter_single(dst, &dst_iter, bytes);
}
} }
EXPORT_SYMBOL(bio_copy_data); EXPORT_SYMBOL(bio_copy_data);
......
...@@ -309,6 +309,16 @@ static struct bio *bio_split_rw(struct bio *bio, const struct queue_limits *lim, ...@@ -309,6 +309,16 @@ static struct bio *bio_split_rw(struct bio *bio, const struct queue_limits *lim,
*segs = nsegs; *segs = nsegs;
return NULL; return NULL;
split: split:
/*
* We can't sanely support splitting for a REQ_NOWAIT bio. End it
* with EAGAIN if splitting is required and return an error pointer.
*/
if (bio->bi_opf & REQ_NOWAIT) {
bio->bi_status = BLK_STS_AGAIN;
bio_endio(bio);
return ERR_PTR(-EAGAIN);
}
*segs = nsegs; *segs = nsegs;
/* /*
...@@ -358,11 +368,13 @@ struct bio *__bio_split_to_limits(struct bio *bio, ...@@ -358,11 +368,13 @@ struct bio *__bio_split_to_limits(struct bio *bio,
default: default:
split = bio_split_rw(bio, lim, nr_segs, bs, split = bio_split_rw(bio, lim, nr_segs, bs,
get_max_io_size(bio, lim) << SECTOR_SHIFT); get_max_io_size(bio, lim) << SECTOR_SHIFT);
if (IS_ERR(split))
return NULL;
break; break;
} }
if (split) { if (split) {
/* there isn't chance to merge the splitted bio */ /* there isn't chance to merge the split bio */
split->bi_opf |= REQ_NOMERGE; split->bi_opf |= REQ_NOMERGE;
blkcg_bio_issue_init(split); blkcg_bio_issue_init(split);
......
...@@ -2951,8 +2951,11 @@ void blk_mq_submit_bio(struct bio *bio) ...@@ -2951,8 +2951,11 @@ void blk_mq_submit_bio(struct bio *bio)
blk_status_t ret; blk_status_t ret;
bio = blk_queue_bounce(bio, q); bio = blk_queue_bounce(bio, q);
if (bio_may_exceed_limits(bio, &q->limits)) if (bio_may_exceed_limits(bio, &q->limits)) {
bio = __bio_split_to_limits(bio, &q->limits, &nr_segs); bio = __bio_split_to_limits(bio, &q->limits, &nr_segs);
if (!bio)
return;
}
if (!bio_integrity_prep(bio)) if (!bio_integrity_prep(bio))
return; return;
......
...@@ -1201,10 +1201,21 @@ struct class block_class = { ...@@ -1201,10 +1201,21 @@ struct class block_class = {
.dev_uevent = block_uevent, .dev_uevent = block_uevent,
}; };
static char *block_devnode(struct device *dev, umode_t *mode,
kuid_t *uid, kgid_t *gid)
{
struct gendisk *disk = dev_to_disk(dev);
if (disk->fops->devnode)
return disk->fops->devnode(disk, mode);
return NULL;
}
const struct device_type disk_type = { const struct device_type disk_type = {
.name = "disk", .name = "disk",
.groups = disk_attr_groups, .groups = disk_attr_groups,
.release = disk_release, .release = disk_release,
.devnode = block_devnode,
}; };
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
......
...@@ -285,6 +285,49 @@ config BLK_DEV_RAM_SIZE ...@@ -285,6 +285,49 @@ config BLK_DEV_RAM_SIZE
The default value is 4096 kilobytes. Only change this if you know The default value is 4096 kilobytes. Only change this if you know
what you are doing. what you are doing.
config CDROM_PKTCDVD
tristate "Packet writing on CD/DVD media (DEPRECATED)"
depends on !UML
depends on SCSI
select CDROM
help
Note: This driver is deprecated and will be removed from the
kernel in the near future!
If you have a CDROM/DVD drive that supports packet writing, say
Y to include support. It should work with any MMC/Mt Fuji
compliant ATAPI or SCSI drive, which is just about any newer
DVD/CD writer.
Currently only writing to CD-RW, DVD-RW, DVD+RW and DVDRAM discs
is possible.
DVD-RW disks must be in restricted overwrite mode.
See the file <file:Documentation/cdrom/packet-writing.rst>
for further information on the use of this driver.
To compile this driver as a module, choose M here: the
module will be called pktcdvd.
config CDROM_PKTCDVD_BUFFERS
int "Free buffers for data gathering"
depends on CDROM_PKTCDVD
default "8"
help
This controls the maximum number of active concurrent packets. More
concurrent packets can increase write performance, but also require
more memory. Each concurrent packet will require approximately 64Kb
of non-swappable kernel memory, memory which will be allocated when
a disc is opened for writing.
config CDROM_PKTCDVD_WCACHE
bool "Enable write caching"
depends on CDROM_PKTCDVD
help
If enabled, write caching will be set for the CD-R/W device. For now
this option is dangerous unless the CD-RW media is known good, as we
don't do deferred write error handling yet.
config ATA_OVER_ETH config ATA_OVER_ETH
tristate "ATA over Ethernet support" tristate "ATA over Ethernet support"
depends on NET depends on NET
......
...@@ -20,6 +20,7 @@ obj-$(CONFIG_AMIGA_Z2RAM) += z2ram.o ...@@ -20,6 +20,7 @@ obj-$(CONFIG_AMIGA_Z2RAM) += z2ram.o
obj-$(CONFIG_N64CART) += n64cart.o obj-$(CONFIG_N64CART) += n64cart.o
obj-$(CONFIG_BLK_DEV_RAM) += brd.o obj-$(CONFIG_BLK_DEV_RAM) += brd.o
obj-$(CONFIG_BLK_DEV_LOOP) += loop.o obj-$(CONFIG_BLK_DEV_LOOP) += loop.o
obj-$(CONFIG_CDROM_PKTCDVD) += pktcdvd.o
obj-$(CONFIG_SUNVDC) += sunvdc.o obj-$(CONFIG_SUNVDC) += sunvdc.o
obj-$(CONFIG_BLK_DEV_NBD) += nbd.o obj-$(CONFIG_BLK_DEV_NBD) += nbd.o
......
...@@ -1607,6 +1607,8 @@ void drbd_submit_bio(struct bio *bio) ...@@ -1607,6 +1607,8 @@ void drbd_submit_bio(struct bio *bio)
struct drbd_device *device = bio->bi_bdev->bd_disk->private_data; struct drbd_device *device = bio->bi_bdev->bd_disk->private_data;
bio = bio_split_to_limits(bio); bio = bio_split_to_limits(bio);
if (!bio)
return;
/* /*
* what we "blindly" assume: * what we "blindly" assume:
......
This diff is collapsed.
...@@ -587,6 +587,8 @@ static void ps3vram_submit_bio(struct bio *bio) ...@@ -587,6 +587,8 @@ static void ps3vram_submit_bio(struct bio *bio)
dev_dbg(&dev->core, "%s\n", __func__); dev_dbg(&dev->core, "%s\n", __func__);
bio = bio_split_to_limits(bio); bio = bio_split_to_limits(bio);
if (!bio)
return;
spin_lock_irq(&priv->lock); spin_lock_irq(&priv->lock);
busy = !bio_list_empty(&priv->list); busy = !bio_list_empty(&priv->list);
......
...@@ -1992,6 +1992,9 @@ static int ublk_ctrl_uring_cmd(struct io_uring_cmd *cmd, ...@@ -1992,6 +1992,9 @@ static int ublk_ctrl_uring_cmd(struct io_uring_cmd *cmd,
struct ublksrv_ctrl_cmd *header = (struct ublksrv_ctrl_cmd *)cmd->cmd; struct ublksrv_ctrl_cmd *header = (struct ublksrv_ctrl_cmd *)cmd->cmd;
int ret = -EINVAL; int ret = -EINVAL;
if (issue_flags & IO_URING_F_NONBLOCK)
return -EAGAIN;
ublk_ctrl_cmd_dump(cmd); ublk_ctrl_cmd_dump(cmd);
if (!(issue_flags & IO_URING_F_SQE128)) if (!(issue_flags & IO_URING_F_SQE128))
......
...@@ -1742,6 +1742,8 @@ static void dm_split_and_process_bio(struct mapped_device *md, ...@@ -1742,6 +1742,8 @@ static void dm_split_and_process_bio(struct mapped_device *md,
* otherwise associated queue_limits won't be imposed. * otherwise associated queue_limits won't be imposed.
*/ */
bio = bio_split_to_limits(bio); bio = bio_split_to_limits(bio);
if (!bio)
return;
} }
init_clone_info(&ci, md, map, bio, is_abnormal); init_clone_info(&ci, md, map, bio, is_abnormal);
......
...@@ -455,6 +455,8 @@ static void md_submit_bio(struct bio *bio) ...@@ -455,6 +455,8 @@ static void md_submit_bio(struct bio *bio)
} }
bio = bio_split_to_limits(bio); bio = bio_split_to_limits(bio);
if (!bio)
return;
if (mddev->ro == MD_RDONLY && unlikely(rw == WRITE)) { if (mddev->ro == MD_RDONLY && unlikely(rw == WRITE)) {
if (bio_sectors(bio) != 0) if (bio_sectors(bio) != 0)
......
...@@ -376,6 +376,8 @@ static void nvme_ns_head_submit_bio(struct bio *bio) ...@@ -376,6 +376,8 @@ static void nvme_ns_head_submit_bio(struct bio *bio)
* pool from the original queue to allocate the bvecs from. * pool from the original queue to allocate the bvecs from.
*/ */
bio = bio_split_to_limits(bio); bio = bio_split_to_limits(bio);
if (!bio)
return;
srcu_idx = srcu_read_lock(&head->srcu); srcu_idx = srcu_read_lock(&head->srcu);
ns = nvme_find_path(head); ns = nvme_find_path(head);
......
...@@ -865,6 +865,8 @@ dcssblk_submit_bio(struct bio *bio) ...@@ -865,6 +865,8 @@ dcssblk_submit_bio(struct bio *bio)
unsigned long bytes_done; unsigned long bytes_done;
bio = bio_split_to_limits(bio); bio = bio_split_to_limits(bio);
if (!bio)
return;
bytes_done = 0; bytes_done = 0;
dev_info = bio->bi_bdev->bd_disk->private_data; dev_info = bio->bi_bdev->bd_disk->private_data;
......
...@@ -475,6 +475,8 @@ void __bio_release_pages(struct bio *bio, bool mark_dirty); ...@@ -475,6 +475,8 @@ void __bio_release_pages(struct bio *bio, bool mark_dirty);
extern void bio_set_pages_dirty(struct bio *bio); extern void bio_set_pages_dirty(struct bio *bio);
extern void bio_check_pages_dirty(struct bio *bio); extern void bio_check_pages_dirty(struct bio *bio);
extern void bio_copy_data_iter(struct bio *dst, struct bvec_iter *dst_iter,
struct bio *src, struct bvec_iter *src_iter);
extern void bio_copy_data(struct bio *dst, struct bio *src); extern void bio_copy_data(struct bio *dst, struct bio *src);
extern void bio_free_pages(struct bio *bio); extern void bio_free_pages(struct bio *bio);
void guard_bio_eod(struct bio *bio); void guard_bio_eod(struct bio *bio);
......
...@@ -1395,6 +1395,7 @@ struct block_device_operations { ...@@ -1395,6 +1395,7 @@ struct block_device_operations {
void (*swap_slot_free_notify) (struct block_device *, unsigned long); void (*swap_slot_free_notify) (struct block_device *, unsigned long);
int (*report_zones)(struct gendisk *, sector_t sector, int (*report_zones)(struct gendisk *, sector_t sector,
unsigned int nr_zones, report_zones_cb cb, void *data); unsigned int nr_zones, report_zones_cb cb, void *data);
char *(*devnode)(struct gendisk *disk, umode_t *mode);
/* returns the length of the identifier or a negative errno: */ /* returns the length of the identifier or a negative errno: */
int (*get_unique_id)(struct gendisk *disk, u8 id[16], int (*get_unique_id)(struct gendisk *disk, u8 id[16],
enum blk_unique_id id_type); enum blk_unique_id id_type);
......
/*
* Copyright (C) 2000 Jens Axboe <axboe@suse.de>
* Copyright (C) 2001-2004 Peter Osterlund <petero2@telia.com>
*
* May be copied or modified under the terms of the GNU General Public
* License. See linux/COPYING for more information.
*
* Packet writing layer for ATAPI and SCSI CD-R, CD-RW, DVD-R, and
* DVD-RW devices.
*
*/
#ifndef __PKTCDVD_H
#define __PKTCDVD_H
#include <linux/blkdev.h>
#include <linux/completion.h>
#include <linux/cdrom.h>
#include <linux/kobject.h>
#include <linux/sysfs.h>
#include <linux/mempool.h>
#include <uapi/linux/pktcdvd.h>
/* default bio write queue congestion marks */
#define PKT_WRITE_CONGESTION_ON 10000
#define PKT_WRITE_CONGESTION_OFF 9000
struct packet_settings
{
__u32 size; /* packet size in (512 byte) sectors */
__u8 fp; /* fixed packets */
__u8 link_loss; /* the rest is specified
* as per Mt Fuji */
__u8 write_type;
__u8 track_mode;
__u8 block_mode;
};
/*
* Very crude stats for now
*/
struct packet_stats
{
unsigned long pkt_started;
unsigned long pkt_ended;
unsigned long secs_w;
unsigned long secs_rg;
unsigned long secs_r;
};
struct packet_cdrw
{
struct list_head pkt_free_list;
struct list_head pkt_active_list;
spinlock_t active_list_lock; /* Serialize access to pkt_active_list */
struct task_struct *thread;
atomic_t pending_bios;
};
/*
* Switch to high speed reading after reading this many kilobytes
* with no interspersed writes.
*/
#define HI_SPEED_SWITCH 512
struct packet_iosched
{
atomic_t attention; /* Set to non-zero when queue processing is needed */
int writing; /* Non-zero when writing, zero when reading */
spinlock_t lock; /* Protecting read/write queue manipulations */
struct bio_list read_queue;
struct bio_list write_queue;
sector_t last_write; /* The sector where the last write ended */
int successive_reads;
};
/*
* 32 buffers of 2048 bytes
*/
#if (PAGE_SIZE % CD_FRAMESIZE) != 0
#error "PAGE_SIZE must be a multiple of CD_FRAMESIZE"
#endif
#define PACKET_MAX_SIZE 128
#define FRAMES_PER_PAGE (PAGE_SIZE / CD_FRAMESIZE)
#define PACKET_MAX_SECTORS (PACKET_MAX_SIZE * CD_FRAMESIZE >> 9)
enum packet_data_state {
PACKET_IDLE_STATE, /* Not used at the moment */
PACKET_WAITING_STATE, /* Waiting for more bios to arrive, so */
/* we don't have to do as much */
/* data gathering */
PACKET_READ_WAIT_STATE, /* Waiting for reads to fill in holes */
PACKET_WRITE_WAIT_STATE, /* Waiting for the write to complete */
PACKET_RECOVERY_STATE, /* Recover after read/write errors */
PACKET_FINISHED_STATE, /* After write has finished */
PACKET_NUM_STATES /* Number of possible states */
};
/*
* Information needed for writing a single packet
*/
struct pktcdvd_device;
struct packet_data
{
struct list_head list;
spinlock_t lock; /* Lock protecting state transitions and */
/* orig_bios list */
struct bio_list orig_bios; /* Original bios passed to pkt_make_request */
/* that will be handled by this packet */
int write_size; /* Total size of all bios in the orig_bios */
/* list, measured in number of frames */
struct bio *w_bio; /* The bio we will send to the real CD */
/* device once we have all data for the */
/* packet we are going to write */
sector_t sector; /* First sector in this packet */
int frames; /* Number of frames in this packet */
enum packet_data_state state; /* Current state */
atomic_t run_sm; /* Incremented whenever the state */
/* machine needs to be run */
long sleep_time; /* Set this to non-zero to make the state */
/* machine run after this many jiffies. */
atomic_t io_wait; /* Number of pending IO operations */
atomic_t io_errors; /* Number of read/write errors during IO */
struct bio *r_bios[PACKET_MAX_SIZE]; /* bios to use during data gathering */
struct page *pages[PACKET_MAX_SIZE / FRAMES_PER_PAGE];
int cache_valid; /* If non-zero, the data for the zone defined */
/* by the sector variable is completely cached */
/* in the pages[] vector. */
int id; /* ID number for debugging */
struct pktcdvd_device *pd;
};
struct pkt_rb_node {
struct rb_node rb_node;
struct bio *bio;
};
struct packet_stacked_data
{
struct bio *bio; /* Original read request bio */
struct pktcdvd_device *pd;
};
#define PSD_POOL_SIZE 64
struct pktcdvd_device
{
struct block_device *bdev; /* dev attached */
dev_t pkt_dev; /* our dev */
char name[20];
struct packet_settings settings;
struct packet_stats stats;
int refcnt; /* Open count */
int write_speed; /* current write speed, kB/s */
int read_speed; /* current read speed, kB/s */
unsigned long offset; /* start offset */
__u8 mode_offset; /* 0 / 8 */
__u8 type;
unsigned long flags;
__u16 mmc3_profile;
__u32 nwa; /* next writable address */
__u32 lra; /* last recorded address */
struct packet_cdrw cdrw;
wait_queue_head_t wqueue;
spinlock_t lock; /* Serialize access to bio_queue */
struct rb_root bio_queue; /* Work queue of bios we need to handle */
int bio_queue_size; /* Number of nodes in bio_queue */
bool congested; /* Someone is waiting for bio_queue_size
* to drop. */
sector_t current_sector; /* Keep track of where the elevator is */
atomic_t scan_queue; /* Set to non-zero when pkt_handle_queue */
/* needs to be run. */
mempool_t rb_pool; /* mempool for pkt_rb_node allocations */
struct packet_iosched iosched;
struct gendisk *disk;
int write_congestion_off;
int write_congestion_on;
struct device *dev; /* sysfs pktcdvd[0-7] dev */
struct dentry *dfs_d_root; /* debugfs: devname directory */
struct dentry *dfs_f_info; /* debugfs: info file */
};
#endif /* __PKTCDVD_H */
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/*
* Copyright (C) 2000 Jens Axboe <axboe@suse.de>
* Copyright (C) 2001-2004 Peter Osterlund <petero2@telia.com>
*
* May be copied or modified under the terms of the GNU General Public
* License. See linux/COPYING for more information.
*
* Packet writing layer for ATAPI and SCSI CD-R, CD-RW, DVD-R, and
* DVD-RW devices.
*
*/
#ifndef _UAPI__PKTCDVD_H
#define _UAPI__PKTCDVD_H
#include <linux/types.h>
/*
* 1 for normal debug messages, 2 is very verbose. 0 to turn it off.
*/
#define PACKET_DEBUG 1
#define MAX_WRITERS 8
#define PKT_RB_POOL_SIZE 512
/*
* How long we should hold a non-full packet before starting data gathering.
*/
#define PACKET_WAIT_TIME (HZ * 5 / 1000)
/*
* use drive write caching -- we need deferred error handling to be
* able to successfully recover with this option (drive will return good
* status as soon as the cdb is validated).
*/
#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
#define USE_WCACHING 1
#else
#define USE_WCACHING 0
#endif
/*
* No user-servicable parts beyond this point ->
*/
/*
* device types
*/
#define PACKET_CDR 1
#define PACKET_CDRW 2
#define PACKET_DVDR 3
#define PACKET_DVDRW 4
/*
* flags
*/
#define PACKET_WRITABLE 1 /* pd is writable */
#define PACKET_NWA_VALID 2 /* next writable address valid */
#define PACKET_LRA_VALID 3 /* last recorded address valid */
#define PACKET_MERGE_SEGS 4 /* perform segment merging to keep */
/* underlying cdrom device happy */
/*
* Disc status -- from READ_DISC_INFO
*/
#define PACKET_DISC_EMPTY 0
#define PACKET_DISC_INCOMPLETE 1
#define PACKET_DISC_COMPLETE 2
#define PACKET_DISC_OTHER 3
/*
* write type, and corresponding data block type
*/
#define PACKET_MODE1 1
#define PACKET_MODE2 2
#define PACKET_BLOCK_MODE1 8
#define PACKET_BLOCK_MODE2 10
/*
* Last session/border status
*/
#define PACKET_SESSION_EMPTY 0
#define PACKET_SESSION_INCOMPLETE 1
#define PACKET_SESSION_RESERVED 2
#define PACKET_SESSION_COMPLETE 3
#define PACKET_MCN "4a656e734178626f65323030300000"
#undef PACKET_USE_LS
#define PKT_CTRL_CMD_SETUP 0
#define PKT_CTRL_CMD_TEARDOWN 1
#define PKT_CTRL_CMD_STATUS 2
struct pkt_ctrl_command {
__u32 command; /* in: Setup, teardown, status */
__u32 dev_index; /* in/out: Device index */
__u32 dev; /* in/out: Device nr for cdrw device */
__u32 pkt_dev; /* in/out: Device nr for packet device */
__u32 num_devices; /* out: Largest device index + 1 */
__u32 padding; /* Not used */
};
/*
* packet ioctls
*/
#define PACKET_IOCTL_MAGIC ('X')
#define PACKET_CTRL_CMD _IOWR(PACKET_IOCTL_MAGIC, 1, struct pkt_ctrl_command)
#endif /* _UAPI__PKTCDVD_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment