Skip to content

Commit

Permalink
Drop 'size' argument from bio_endio and bi_end_io
Browse files Browse the repository at this point in the history
As bi_end_io is only called once when the reqeust is complete,
the 'size' argument is now redundant.  Remove it.

Now there is no need for bio_endio to subtract the size completed
from bi_size.  So don't do that either.

While we are at it, change bi_end_io to return void.

Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
  • Loading branch information
neilbrown authored and Jens Axboe committed Oct 10, 2007
1 parent 5bb23a6 commit 6712ecf
Show file tree
Hide file tree
Showing 45 changed files with 132 additions and 328 deletions.
10 changes: 5 additions & 5 deletions block/ll_rw_blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ static void req_bio_endio(struct request *rq, struct bio *bio,
bio->bi_size -= nbytes;
bio->bi_sector += (nbytes >> 9);
if (bio->bi_size == 0)
bio_endio(bio, bio->bi_size, error);
bio_endio(bio, error);
} else {

/*
Expand Down Expand Up @@ -2401,7 +2401,7 @@ static int __blk_rq_map_user(struct request_queue *q, struct request *rq,
return bio->bi_size;

/* if it was boucned we must call the end io function */
bio_endio(bio, bio->bi_size, 0);
bio_endio(bio, 0);
__blk_rq_unmap_user(orig_bio);
bio_put(bio);
return ret;
Expand Down Expand Up @@ -2510,7 +2510,7 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
return PTR_ERR(bio);

if (bio->bi_size != len) {
bio_endio(bio, bio->bi_size, 0);
bio_endio(bio, 0);
bio_unmap_user(bio);
return -EINVAL;
}
Expand Down Expand Up @@ -3040,7 +3040,7 @@ static int __make_request(struct request_queue *q, struct bio *bio)
return 0;

end_io:
bio_endio(bio, nr_sectors << 9, err);
bio_endio(bio, err);
return 0;
}

Expand Down Expand Up @@ -3187,7 +3187,7 @@ static inline void __generic_make_request(struct bio *bio)
bdevname(bio->bi_bdev, b),
(long long) bio->bi_sector);
end_io:
bio_endio(bio, bio->bi_size, -EIO);
bio_endio(bio, -EIO);
break;
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/block/aoe/aoeblk.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ aoeblk_make_request(struct request_queue *q, struct bio *bio)
buf = mempool_alloc(d->bufpool, GFP_NOIO);
if (buf == NULL) {
printk(KERN_INFO "aoe: buf allocation failure\n");
bio_endio(bio, bio->bi_size, -ENOMEM);
bio_endio(bio, -ENOMEM);
return 0;
}
memset(buf, 0, sizeof(*buf));
Expand All @@ -159,7 +159,7 @@ aoeblk_make_request(struct request_queue *q, struct bio *bio)
d->aoemajor, d->aoeminor);
spin_unlock_irqrestore(&d->lock, flags);
mempool_free(buf, d->bufpool);
bio_endio(bio, bio->bi_size, -ENXIO);
bio_endio(bio, -ENXIO);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/block/aoe/aoecmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ aoecmd_ata_rsp(struct sk_buff *skb)
disk_stat_add(disk, sectors[rw], n_sect);
disk_stat_add(disk, io_ticks, duration);
n = (buf->flags & BUFFL_FAIL) ? -EIO : 0;
bio_endio(buf->bio, buf->bio->bi_size, n);
bio_endio(buf->bio, n);
mempool_free(buf, d->bufpool);
}
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/block/aoe/aoedev.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ aoedev_downdev(struct aoedev *d)
bio = buf->bio;
if (--buf->nframesout == 0) {
mempool_free(buf, d->bufpool);
bio_endio(bio, bio->bi_size, -EIO);
bio_endio(bio, -EIO);
}
skb_shinfo(f->skb)->nr_frags = f->skb->data_len = 0;
}
Expand All @@ -130,7 +130,7 @@ aoedev_downdev(struct aoedev *d)
list_del(d->bufq.next);
bio = buf->bio;
mempool_free(buf, d->bufpool);
bio_endio(bio, bio->bi_size, -EIO);
bio_endio(bio, -EIO);
}

if (d->gd)
Expand Down
2 changes: 1 addition & 1 deletion drivers/block/cciss.c
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,7 @@ static inline void complete_buffers(struct bio *bio, int status)
int nr_sectors = bio_sectors(bio);

bio->bi_next = NULL;
bio_endio(bio, nr_sectors << 9, status ? 0 : -EIO);
bio_endio(bio, status ? 0 : -EIO);
bio = xbh;
}
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/block/cpqarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ static inline void complete_buffers(struct bio *bio, int ok)
xbh = bio->bi_next;
bio->bi_next = NULL;

bio_endio(bio, nr_sectors << 9, ok ? 0 : -EIO);
bio_endio(bio, ok ? 0 : -EIO);

bio = xbh;
}
Expand Down
6 changes: 1 addition & 5 deletions drivers/block/floppy.c
Original file line number Diff line number Diff line change
Expand Up @@ -3810,14 +3810,10 @@ static int check_floppy_change(struct gendisk *disk)
* a disk in the drive, and whether that disk is writable.
*/

static int floppy_rb0_complete(struct bio *bio, unsigned int bytes_done,
static void floppy_rb0_complete(struct bio *bio,
int err)
{
if (bio->bi_size)
return 1;

complete((struct completion *)bio->bi_private);
return 0;
}

static int __floppy_read_block_0(struct block_device *bdev)
Expand Down
4 changes: 2 additions & 2 deletions drivers/block/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ static int loop_make_request(struct request_queue *q, struct bio *old_bio)

out:
spin_unlock_irq(&lo->lo_lock);
bio_io_error(old_bio, old_bio->bi_size);
bio_io_error(old_bio);
return 0;
}

Expand Down Expand Up @@ -580,7 +580,7 @@ static inline void loop_handle_bio(struct loop_device *lo, struct bio *bio)
bio_put(bio);
} else {
int ret = do_bio_filebacked(lo, bio);
bio_endio(bio, bio->bi_size, ret);
bio_endio(bio, ret);
}
}

Expand Down
25 changes: 6 additions & 19 deletions drivers/block/pktcdvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1058,15 +1058,12 @@ static void pkt_make_local_copy(struct packet_data *pkt, struct bio_vec *bvec)
}
}

static int pkt_end_io_read(struct bio *bio, unsigned int bytes_done, int err)
static void pkt_end_io_read(struct bio *bio, int err)
{
struct packet_data *pkt = bio->bi_private;
struct pktcdvd_device *pd = pkt->pd;
BUG_ON(!pd);

if (bio->bi_size)
return 1;

VPRINTK("pkt_end_io_read: bio=%p sec0=%llx sec=%llx err=%d\n", bio,
(unsigned long long)pkt->sector, (unsigned long long)bio->bi_sector, err);

Expand All @@ -1077,19 +1074,14 @@ static int pkt_end_io_read(struct bio *bio, unsigned int bytes_done, int err)
wake_up(&pd->wqueue);
}
pkt_bio_finished(pd);

return 0;
}

static int pkt_end_io_packet_write(struct bio *bio, unsigned int bytes_done, int err)
static void pkt_end_io_packet_write(struct bio *bio, int err)
{
struct packet_data *pkt = bio->bi_private;
struct pktcdvd_device *pd = pkt->pd;
BUG_ON(!pd);

if (bio->bi_size)
return 1;

VPRINTK("pkt_end_io_packet_write: id=%d, err=%d\n", pkt->id, err);

pd->stats.pkt_ended++;
Expand All @@ -1098,7 +1090,6 @@ static int pkt_end_io_packet_write(struct bio *bio, unsigned int bytes_done, int
atomic_dec(&pkt->io_wait);
atomic_inc(&pkt->run_sm);
wake_up(&pd->wqueue);
return 0;
}

/*
Expand Down Expand Up @@ -1470,7 +1461,7 @@ static void pkt_finish_packet(struct packet_data *pkt, int uptodate)
while (bio) {
next = bio->bi_next;
bio->bi_next = NULL;
bio_endio(bio, bio->bi_size, uptodate ? 0 : -EIO);
bio_endio(bio, uptodate ? 0 : -EIO);
bio = next;
}
pkt->orig_bios = pkt->orig_bios_tail = NULL;
Expand Down Expand Up @@ -2462,19 +2453,15 @@ static int pkt_close(struct inode *inode, struct file *file)
}


static int pkt_end_io_read_cloned(struct bio *bio, unsigned int bytes_done, int err)
static void pkt_end_io_read_cloned(struct bio *bio, int err)
{
struct packet_stacked_data *psd = bio->bi_private;
struct pktcdvd_device *pd = psd->pd;

if (bio->bi_size)
return 1;

bio_put(bio);
bio_endio(psd->bio, psd->bio->bi_size, err);
bio_endio(psd->bio, err);
mempool_free(psd, psd_pool);
pkt_bio_finished(pd);
return 0;
}

static int pkt_make_request(struct request_queue *q, struct bio *bio)
Expand Down Expand Up @@ -2620,7 +2607,7 @@ static int pkt_make_request(struct request_queue *q, struct bio *bio)
}
return 0;
end_io:
bio_io_error(bio, bio->bi_size);
bio_io_error(bio);
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/block/rd.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,10 @@ static int rd_make_request(struct request_queue *q, struct bio *bio)
if (ret)
goto fail;

bio_endio(bio, bio->bi_size, 0);
bio_endio(bio, 0);
return 0;
fail:
bio_io_error(bio, bio->bi_size);
bio_io_error(bio);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/block/umem.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ static void process_page(unsigned long data)

return_bio = bio->bi_next;
bio->bi_next = NULL;
bio_endio(bio, bio->bi_size, 0);
bio_endio(bio, 0);
}
}

Expand Down
21 changes: 7 additions & 14 deletions drivers/md/dm-crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ static void dec_pending(struct dm_crypt_io *io, int error)
if (!atomic_dec_and_test(&io->pending))
return;

bio_endio(io->base_bio, io->base_bio->bi_size, io->error);
bio_endio(io->base_bio, io->error);

mempool_free(io, cc->io_pool);
}
Expand All @@ -509,25 +509,19 @@ static void kcryptd_queue_io(struct dm_crypt_io *io)
queue_work(_kcryptd_workqueue, &io->work);
}

static int crypt_endio(struct bio *clone, unsigned int done, int error)
static void crypt_endio(struct bio *clone, int error)
{
struct dm_crypt_io *io = clone->bi_private;
struct crypt_config *cc = io->target->private;
unsigned read_io = bio_data_dir(clone) == READ;

/*
* free the processed pages, even if
* it's only a partially completed write
* free the processed pages
*/
if (!read_io)
crypt_free_buffer_pages(cc, clone, done);

/* keep going - not finished yet */
if (unlikely(clone->bi_size))
return 1;

if (!read_io)
if (!read_io) {
crypt_free_buffer_pages(cc, clone, clone->bi_size);
goto out;
}

if (unlikely(!bio_flagged(clone, BIO_UPTODATE))) {
error = -EIO;
Expand All @@ -537,12 +531,11 @@ static int crypt_endio(struct bio *clone, unsigned int done, int error)
bio_put(clone);
io->post_process = 1;
kcryptd_queue_io(io);
return 0;
return;

out:
bio_put(clone);
dec_pending(io, error);
return error;
}

static void clone_init(struct dm_crypt_io *io, struct bio *clone)
Expand Down
5 changes: 1 addition & 4 deletions drivers/md/dm-emc.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,10 @@ static inline void free_bio(struct bio *bio)
bio_put(bio);
}

static int emc_endio(struct bio *bio, unsigned int bytes_done, int error)
static void emc_endio(struct bio *bio, int error)
{
struct dm_path *path = bio->bi_private;

if (bio->bi_size)
return 1;

/* We also need to look at the sense keys here whether or not to
* switch to the next PG etc.
*
Expand Down
8 changes: 1 addition & 7 deletions drivers/md/dm-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,11 @@ static void dec_count(struct io *io, unsigned int region, int error)
}
}

static int endio(struct bio *bio, unsigned int done, int error)
static void endio(struct bio *bio, int error)
{
struct io *io;
unsigned region;

/* keep going until we've finished */
if (bio->bi_size)
return 1;

if (error && bio_data_dir(bio) == READ)
zero_fill_bio(bio);

Expand All @@ -146,8 +142,6 @@ static int endio(struct bio *bio, unsigned int done, int error)
bio_put(bio);

dec_count(io, region, error);

return 0;
}

/*-----------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions drivers/md/dm-mpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,11 @@ static void dispatch_queued_ios(struct multipath *m)

r = map_io(m, bio, mpio, 1);
if (r < 0)
bio_endio(bio, bio->bi_size, r);
bio_endio(bio, r);
else if (r == DM_MAPIO_REMAPPED)
generic_make_request(bio);
else if (r == DM_MAPIO_REQUEUE)
bio_endio(bio, bio->bi_size, -EIO);
bio_endio(bio, -EIO);

bio = next;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/md/dm-raid1.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ static void write_callback(unsigned long error, void *context)
break;
}
}
bio_endio(bio, bio->bi_size, 0);
bio_endio(bio, 0);
}

static void do_write(struct mirror_set *ms, struct bio *bio)
Expand Down Expand Up @@ -900,7 +900,7 @@ static void do_writes(struct mirror_set *ms, struct bio_list *writes)
*/
if (unlikely(ms->log_failure))
while ((bio = bio_list_pop(&sync)))
bio_endio(bio, bio->bi_size, -EIO);
bio_endio(bio, -EIO);
else while ((bio = bio_list_pop(&sync)))
do_write(ms, bio);

Expand Down
2 changes: 1 addition & 1 deletion drivers/md/dm-snap.c
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ static void error_bios(struct bio *bio)
while (bio) {
n = bio->bi_next;
bio->bi_next = NULL;
bio_io_error(bio, bio->bi_size);
bio_io_error(bio);
bio = n;
}
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/md/dm-zero.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static int zero_map(struct dm_target *ti, struct bio *bio,
break;
}

bio_endio(bio, bio->bi_size, 0);
bio_endio(bio, 0);

/* accepted bio, don't make new request */
return DM_MAPIO_SUBMITTED;
Expand Down
Loading

0 comments on commit 6712ecf

Please sign in to comment.