Skip to content

Commit

Permalink
block: change ->make_request_fn() and users to return a queue cookie
Browse files Browse the repository at this point in the history
No functional changes in this patch, but it prepares us for returning
a more useful cookie related to the IO that was queued up.

Signed-off-by: Jens Axboe <[email protected]>
Acked-by: Christoph Hellwig <[email protected]>
Acked-by: Keith Busch <[email protected]>
  • Loading branch information
axboe committed Nov 7, 2015
1 parent 8e483ed commit dece163
Show file tree
Hide file tree
Showing 28 changed files with 127 additions and 71 deletions.
3 changes: 2 additions & 1 deletion arch/m68k/emu/nfblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct nfhd_device {
struct gendisk *disk;
};

static void nfhd_make_request(struct request_queue *queue, struct bio *bio)
static blk_qc_t nfhd_make_request(struct request_queue *queue, struct bio *bio)
{
struct nfhd_device *dev = queue->queuedata;
struct bio_vec bvec;
Expand All @@ -77,6 +77,7 @@ static void nfhd_make_request(struct request_queue *queue, struct bio *bio)
sec += len;
}
bio_endio(bio);
return BLK_QC_T_NONE;
}

static int nfhd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
Expand Down
5 changes: 3 additions & 2 deletions arch/powerpc/sysdev/axonram.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ axon_ram_irq_handler(int irq, void *dev)
* axon_ram_make_request - make_request() method for block device
* @queue, @bio: see blk_queue_make_request()
*/
static void
static blk_qc_t
axon_ram_make_request(struct request_queue *queue, struct bio *bio)
{
struct axon_ram_bank *bank = bio->bi_bdev->bd_disk->private_data;
Expand All @@ -120,7 +120,7 @@ axon_ram_make_request(struct request_queue *queue, struct bio *bio)
bio_for_each_segment(vec, bio, iter) {
if (unlikely(phys_mem + vec.bv_len > phys_end)) {
bio_io_error(bio);
return;
return BLK_QC_T_NONE;
}

user_mem = page_address(vec.bv_page) + vec.bv_offset;
Expand All @@ -133,6 +133,7 @@ axon_ram_make_request(struct request_queue *queue, struct bio *bio)
transfered += vec.bv_len;
}
bio_endio(bio);
return BLK_QC_T_NONE;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion arch/xtensa/platforms/iss/simdisk.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static void simdisk_transfer(struct simdisk *dev, unsigned long sector,
spin_unlock(&dev->lock);
}

static void simdisk_make_request(struct request_queue *q, struct bio *bio)
static blk_qc_t simdisk_make_request(struct request_queue *q, struct bio *bio)
{
struct simdisk *dev = q->queuedata;
struct bio_vec bvec;
Expand All @@ -119,6 +119,7 @@ static void simdisk_make_request(struct request_queue *q, struct bio *bio)
}

bio_endio(bio);
return BLK_QC_T_NONE;
}

static int simdisk_open(struct block_device *bdev, fmode_t mode)
Expand Down
26 changes: 16 additions & 10 deletions block/blk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ blk_init_queue_node(request_fn_proc *rfn, spinlock_t *lock, int node_id)
}
EXPORT_SYMBOL(blk_init_queue_node);

static void blk_queue_bio(struct request_queue *q, struct bio *bio);
static blk_qc_t blk_queue_bio(struct request_queue *q, struct bio *bio);

struct request_queue *
blk_init_allocated_queue(struct request_queue *q, request_fn_proc *rfn,
Expand Down Expand Up @@ -1678,7 +1678,7 @@ void init_request_from_bio(struct request *req, struct bio *bio)
blk_rq_bio_prep(req->q, req, bio);
}

static void blk_queue_bio(struct request_queue *q, struct bio *bio)
static blk_qc_t blk_queue_bio(struct request_queue *q, struct bio *bio)
{
const bool sync = !!(bio->bi_rw & REQ_SYNC);
struct blk_plug *plug;
Expand All @@ -1698,7 +1698,7 @@ static void blk_queue_bio(struct request_queue *q, struct bio *bio)
if (bio_integrity_enabled(bio) && bio_integrity_prep(bio)) {
bio->bi_error = -EIO;
bio_endio(bio);
return;
return BLK_QC_T_NONE;
}

if (bio->bi_rw & (REQ_FLUSH | REQ_FUA)) {
Expand All @@ -1713,7 +1713,7 @@ static void blk_queue_bio(struct request_queue *q, struct bio *bio)
*/
if (!blk_queue_nomerges(q)) {
if (blk_attempt_plug_merge(q, bio, &request_count, NULL))
return;
return BLK_QC_T_NONE;
} else
request_count = blk_plug_queued_count(q);

Expand Down Expand Up @@ -1791,6 +1791,8 @@ static void blk_queue_bio(struct request_queue *q, struct bio *bio)
out_unlock:
spin_unlock_irq(q->queue_lock);
}

return BLK_QC_T_NONE;
}

/*
Expand Down Expand Up @@ -1996,12 +1998,13 @@ generic_make_request_checks(struct bio *bio)
* a lower device by calling into generic_make_request recursively, which
* means the bio should NOT be touched after the call to ->make_request_fn.
*/
void generic_make_request(struct bio *bio)
blk_qc_t generic_make_request(struct bio *bio)
{
struct bio_list bio_list_on_stack;
blk_qc_t ret = BLK_QC_T_NONE;

if (!generic_make_request_checks(bio))
return;
goto out;

/*
* We only want one ->make_request_fn to be active at a time, else
Expand All @@ -2015,7 +2018,7 @@ void generic_make_request(struct bio *bio)
*/
if (current->bio_list) {
bio_list_add(current->bio_list, bio);
return;
goto out;
}

/* following loop may be a bit non-obvious, and so deserves some
Expand All @@ -2040,7 +2043,7 @@ void generic_make_request(struct bio *bio)

if (likely(blk_queue_enter(q, __GFP_WAIT) == 0)) {

q->make_request_fn(q, bio);
ret = q->make_request_fn(q, bio);

blk_queue_exit(q);

Expand All @@ -2053,6 +2056,9 @@ void generic_make_request(struct bio *bio)
}
} while (bio);
current->bio_list = NULL; /* deactivate */

out:
return ret;
}
EXPORT_SYMBOL(generic_make_request);

Expand All @@ -2066,7 +2072,7 @@ EXPORT_SYMBOL(generic_make_request);
* interfaces; @bio must be presetup and ready for I/O.
*
*/
void submit_bio(int rw, struct bio *bio)
blk_qc_t submit_bio(int rw, struct bio *bio)
{
bio->bi_rw |= rw;

Expand Down Expand Up @@ -2100,7 +2106,7 @@ void submit_bio(int rw, struct bio *bio)
}
}

generic_make_request(bio);
return generic_make_request(bio);
}
EXPORT_SYMBOL(submit_bio);

Expand Down
26 changes: 14 additions & 12 deletions block/blk-mq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,7 @@ static int blk_mq_direct_issue_request(struct request *rq)
* but will attempt to bypass the hctx queueing if we can go straight to
* hardware for SYNC IO.
*/
static void blk_mq_make_request(struct request_queue *q, struct bio *bio)
static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)
{
const int is_sync = rw_is_sync(bio->bi_rw);
const int is_flush_fua = bio->bi_rw & (REQ_FLUSH | REQ_FUA);
Expand All @@ -1249,21 +1249,21 @@ static void blk_mq_make_request(struct request_queue *q, struct bio *bio)

if (bio_integrity_enabled(bio) && bio_integrity_prep(bio)) {
bio_io_error(bio);
return;
return BLK_QC_T_NONE;
}

blk_queue_split(q, &bio, q->bio_split);

if (!is_flush_fua && !blk_queue_nomerges(q)) {
if (blk_attempt_plug_merge(q, bio, &request_count,
&same_queue_rq))
return;
return BLK_QC_T_NONE;
} else
request_count = blk_plug_queued_count(q);

rq = blk_mq_map_request(q, bio, &data);
if (unlikely(!rq))
return;
return BLK_QC_T_NONE;

if (unlikely(is_flush_fua)) {
blk_mq_bio_to_request(rq, bio);
Expand Down Expand Up @@ -1302,11 +1302,11 @@ static void blk_mq_make_request(struct request_queue *q, struct bio *bio)
old_rq = rq;
blk_mq_put_ctx(data.ctx);
if (!old_rq)
return;
return BLK_QC_T_NONE;
if (!blk_mq_direct_issue_request(old_rq))
return;
return BLK_QC_T_NONE;
blk_mq_insert_request(old_rq, false, true, true);
return;
return BLK_QC_T_NONE;
}

if (!blk_mq_merge_queue_io(data.hctx, data.ctx, rq, bio)) {
Expand All @@ -1320,13 +1320,14 @@ static void blk_mq_make_request(struct request_queue *q, struct bio *bio)
blk_mq_run_hw_queue(data.hctx, !is_sync || is_flush_fua);
}
blk_mq_put_ctx(data.ctx);
return BLK_QC_T_NONE;
}

/*
* Single hardware queue variant. This will attempt to use any per-process
* plug for merging and IO deferral.
*/
static void blk_sq_make_request(struct request_queue *q, struct bio *bio)
static blk_qc_t blk_sq_make_request(struct request_queue *q, struct bio *bio)
{
const int is_sync = rw_is_sync(bio->bi_rw);
const int is_flush_fua = bio->bi_rw & (REQ_FLUSH | REQ_FUA);
Expand All @@ -1339,18 +1340,18 @@ static void blk_sq_make_request(struct request_queue *q, struct bio *bio)

if (bio_integrity_enabled(bio) && bio_integrity_prep(bio)) {
bio_io_error(bio);
return;
return BLK_QC_T_NONE;
}

blk_queue_split(q, &bio, q->bio_split);

if (!is_flush_fua && !blk_queue_nomerges(q) &&
blk_attempt_plug_merge(q, bio, &request_count, NULL))
return;
return BLK_QC_T_NONE;

rq = blk_mq_map_request(q, bio, &data);
if (unlikely(!rq))
return;
return BLK_QC_T_NONE;

if (unlikely(is_flush_fua)) {
blk_mq_bio_to_request(rq, bio);
Expand All @@ -1374,7 +1375,7 @@ static void blk_sq_make_request(struct request_queue *q, struct bio *bio)
}
list_add_tail(&rq->queuelist, &plug->mq_list);
blk_mq_put_ctx(data.ctx);
return;
return BLK_QC_T_NONE;
}

if (!blk_mq_merge_queue_io(data.hctx, data.ctx, rq, bio)) {
Expand All @@ -1389,6 +1390,7 @@ static void blk_sq_make_request(struct request_queue *q, struct bio *bio)
}

blk_mq_put_ctx(data.ctx);
return BLK_QC_T_NONE;
}

/*
Expand Down
5 changes: 3 additions & 2 deletions drivers/block/brd.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ static int brd_do_bvec(struct brd_device *brd, struct page *page,
return err;
}

static void brd_make_request(struct request_queue *q, struct bio *bio)
static blk_qc_t brd_make_request(struct request_queue *q, struct bio *bio)
{
struct block_device *bdev = bio->bi_bdev;
struct brd_device *brd = bdev->bd_disk->private_data;
Expand Down Expand Up @@ -358,9 +358,10 @@ static void brd_make_request(struct request_queue *q, struct bio *bio)

out:
bio_endio(bio);
return;
return BLK_QC_T_NONE;
io_error:
bio_io_error(bio);
return BLK_QC_T_NONE;
}

static int brd_rw_page(struct block_device *bdev, sector_t sector,
Expand Down
2 changes: 1 addition & 1 deletion drivers/block/drbd/drbd_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,7 @@ extern int proc_details;
/* drbd_req */
extern void do_submit(struct work_struct *ws);
extern void __drbd_make_request(struct drbd_device *, struct bio *, unsigned long);
extern void drbd_make_request(struct request_queue *q, struct bio *bio);
extern blk_qc_t drbd_make_request(struct request_queue *q, struct bio *bio);
extern int drbd_read_remote(struct drbd_device *device, struct drbd_request *req);
extern int is_valid_ar_handle(struct drbd_request *, sector_t);

Expand Down
3 changes: 2 additions & 1 deletion drivers/block/drbd/drbd_req.c
Original file line number Diff line number Diff line change
Expand Up @@ -1494,7 +1494,7 @@ void do_submit(struct work_struct *ws)
}
}

void drbd_make_request(struct request_queue *q, struct bio *bio)
blk_qc_t drbd_make_request(struct request_queue *q, struct bio *bio)
{
struct drbd_device *device = (struct drbd_device *) q->queuedata;
unsigned long start_jif;
Expand All @@ -1510,6 +1510,7 @@ void drbd_make_request(struct request_queue *q, struct bio *bio)

inc_ap_bio(device);
__drbd_make_request(device, bio, start_jif);
return BLK_QC_T_NONE;
}

void request_timer_fn(unsigned long data)
Expand Down
3 changes: 2 additions & 1 deletion drivers/block/null_blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ static struct nullb_queue *nullb_to_queue(struct nullb *nullb)
return &nullb->queues[index];
}

static void null_queue_bio(struct request_queue *q, struct bio *bio)
static blk_qc_t null_queue_bio(struct request_queue *q, struct bio *bio)
{
struct nullb *nullb = q->queuedata;
struct nullb_queue *nq = nullb_to_queue(nullb);
Expand All @@ -331,6 +331,7 @@ static void null_queue_bio(struct request_queue *q, struct bio *bio)
cmd->bio = bio;

null_handle_cmd(cmd);
return BLK_QC_T_NONE;
}

static int null_rq_prep_fn(struct request_queue *q, struct request *req)
Expand Down
9 changes: 4 additions & 5 deletions drivers/block/pktcdvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2441,7 +2441,7 @@ static void pkt_make_request_write(struct request_queue *q, struct bio *bio)
}
}

static void pkt_make_request(struct request_queue *q, struct bio *bio)
static blk_qc_t pkt_make_request(struct request_queue *q, struct bio *bio)
{
struct pktcdvd_device *pd;
char b[BDEVNAME_SIZE];
Expand All @@ -2467,7 +2467,7 @@ static void pkt_make_request(struct request_queue *q, struct bio *bio)
*/
if (bio_data_dir(bio) == READ) {
pkt_make_request_read(pd, bio);
return;
return BLK_QC_T_NONE;
}

if (!test_bit(PACKET_WRITABLE, &pd->flags)) {
Expand Down Expand Up @@ -2499,13 +2499,12 @@ static void pkt_make_request(struct request_queue *q, struct bio *bio)
pkt_make_request_write(q, split);
} while (split != bio);

return;
return BLK_QC_T_NONE;
end_io:
bio_io_error(bio);
return BLK_QC_T_NONE;
}



static void pkt_init_queue(struct pktcdvd_device *pd)
{
struct request_queue *q = pd->disk->queue;
Expand Down
6 changes: 4 additions & 2 deletions drivers/block/ps3vram.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ static struct bio *ps3vram_do_bio(struct ps3_system_bus_device *dev,
return next;
}

static void ps3vram_make_request(struct request_queue *q, struct bio *bio)
static blk_qc_t ps3vram_make_request(struct request_queue *q, struct bio *bio)
{
struct ps3_system_bus_device *dev = q->queuedata;
struct ps3vram_priv *priv = ps3_system_bus_get_drvdata(dev);
Expand All @@ -614,11 +614,13 @@ static void ps3vram_make_request(struct request_queue *q, struct bio *bio)
spin_unlock_irq(&priv->lock);

if (busy)
return;
return BLK_QC_T_NONE;

do {
bio = ps3vram_do_bio(dev, bio);
} while (bio);

return BLK_QC_T_NONE;
}

static int ps3vram_probe(struct ps3_system_bus_device *dev)
Expand Down
Loading

0 comments on commit dece163

Please sign in to comment.