Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 19329
b: refs/heads/master
c: 3eaf840
h: refs/heads/master
i:
  19327: c004561
v: v3
  • Loading branch information
Jun'ichi "Nick" Nomura authored and Linus Torvalds committed Feb 1, 2006
1 parent a78d1ef commit e1e9454
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 12f03a49cf0ab5e8511911142d28699499a572c4
refs/heads/master: 3eaf840e0b0046f56602c524c7ba58a82f5526c5
2 changes: 2 additions & 0 deletions trunk/block/ll_rw_blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -2579,6 +2579,8 @@ void disk_round_stats(struct gendisk *disk)
disk->stamp = now;
}

EXPORT_SYMBOL_GPL(disk_round_stats);

/*
* queue lock must be held
*/
Expand Down
35 changes: 33 additions & 2 deletions trunk/drivers/md/dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct dm_io {
int error;
struct bio *bio;
atomic_t io_count;
unsigned long start_time;
};

/*
Expand Down Expand Up @@ -244,6 +245,36 @@ static inline void free_tio(struct mapped_device *md, struct target_io *tio)
mempool_free(tio, md->tio_pool);
}

static void start_io_acct(struct dm_io *io)
{
struct mapped_device *md = io->md;

io->start_time = jiffies;

preempt_disable();
disk_round_stats(dm_disk(md));
preempt_enable();
dm_disk(md)->in_flight = atomic_inc_return(&md->pending);
}

static int end_io_acct(struct dm_io *io)
{
struct mapped_device *md = io->md;
struct bio *bio = io->bio;
unsigned long duration = jiffies - io->start_time;
int pending;
int rw = bio_data_dir(bio);

preempt_disable();
disk_round_stats(dm_disk(md));
preempt_enable();
dm_disk(md)->in_flight = pending = atomic_dec_return(&md->pending);

disk_stat_add(dm_disk(md), ticks[rw], duration);

return !pending;
}

/*
* Add the bio to the list of deferred io.
*/
Expand Down Expand Up @@ -299,7 +330,7 @@ static void dec_pending(struct dm_io *io, int error)
io->error = error;

if (atomic_dec_and_test(&io->io_count)) {
if (atomic_dec_and_test(&io->md->pending))
if (end_io_acct(io))
/* nudge anyone waiting on suspend queue */
wake_up(&io->md->wait);

Expand Down Expand Up @@ -554,7 +585,7 @@ static void __split_bio(struct mapped_device *md, struct bio *bio)
ci.sector_count = bio_sectors(bio);
ci.idx = bio->bi_idx;

atomic_inc(&md->pending);
start_io_acct(ci.io);
while (ci.sector_count)
__clone_and_map(&ci);

Expand Down

0 comments on commit e1e9454

Please sign in to comment.