Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 273799
b: refs/heads/master
c: bc16a4f
h: refs/heads/master
i:
  273797: 1a1c52c
  273795: 6dc5ae7
  273791: 5ff68f3
v: v3
  • Loading branch information
Tejun Heo authored and Jens Axboe committed Oct 19, 2011
1 parent ec1d1cc commit 853aac9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 42 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: e3c78ca524d230bc145e902625e88c392a58ddf3
refs/heads/master: bc16a4f933bc5ed50826b20561e4c3515061998b
8 changes: 2 additions & 6 deletions trunk/block/blk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1515,12 +1515,8 @@ generic_make_request_checks(struct bio *bio)
goto end_io;
}

if (blk_throtl_bio(q, &bio))
goto end_io;

/* if bio = NULL, bio has been throttled and will be submitted later. */
if (!bio)
return false;
if (blk_throtl_bio(q, bio))
return false; /* throttled, will be resubmitted later */

trace_block_bio_queue(q, bio);
return true;
Expand Down
49 changes: 17 additions & 32 deletions trunk/block/blk-throttle.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,6 @@ throtl_grp *throtl_find_tg(struct throtl_data *td, struct blkio_cgroup *blkcg)
return tg;
}

/*
* This function returns with queue lock unlocked in case of error, like
* request queue is no more
*/
static struct throtl_grp * throtl_get_tg(struct throtl_data *td)
{
struct throtl_grp *tg = NULL, *__tg = NULL;
Expand All @@ -330,20 +326,16 @@ static struct throtl_grp * throtl_get_tg(struct throtl_data *td)
spin_unlock_irq(q->queue_lock);

tg = throtl_alloc_tg(td);
/*
* We might have slept in group allocation. Make sure queue is not
* dead
*/
if (unlikely(test_bit(QUEUE_FLAG_DEAD, &q->queue_flags))) {
if (tg)
kfree(tg);

return ERR_PTR(-ENODEV);
}

/* Group allocated and queue is still alive. take the lock */
spin_lock_irq(q->queue_lock);

/* Make sure @q is still alive */
if (unlikely(test_bit(QUEUE_FLAG_DEAD, &q->queue_flags))) {
kfree(tg);
return NULL;
}

/*
* Initialize the new group. After sleeping, read the blkcg again.
*/
Expand Down Expand Up @@ -1118,17 +1110,17 @@ static struct blkio_policy_type blkio_policy_throtl = {
.plid = BLKIO_POLICY_THROTL,
};

int blk_throtl_bio(struct request_queue *q, struct bio **biop)
bool blk_throtl_bio(struct request_queue *q, struct bio *bio)
{
struct throtl_data *td = q->td;
struct throtl_grp *tg;
struct bio *bio = *biop;
bool rw = bio_data_dir(bio), update_disptime = true;
struct blkio_cgroup *blkcg;
bool throttled = false;

if (bio->bi_rw & REQ_THROTTLED) {
bio->bi_rw &= ~REQ_THROTTLED;
return 0;
goto out;
}

/*
Expand All @@ -1147,7 +1139,7 @@ int blk_throtl_bio(struct request_queue *q, struct bio **biop)
blkiocg_update_dispatch_stats(&tg->blkg, bio->bi_size,
rw, rw_is_sync(bio->bi_rw));
rcu_read_unlock();
return 0;
goto out;
}
}
rcu_read_unlock();
Expand All @@ -1156,18 +1148,10 @@ int blk_throtl_bio(struct request_queue *q, struct bio **biop)
* Either group has not been allocated yet or it is not an unlimited
* IO group
*/

spin_lock_irq(q->queue_lock);
tg = throtl_get_tg(td);

if (IS_ERR(tg)) {
if (PTR_ERR(tg) == -ENODEV) {
/*
* Queue is gone. No queue lock held here.
*/
return -ENODEV;
}
}
if (unlikely(!tg))
goto out_unlock;

if (tg->nr_queued[rw]) {
/*
Expand Down Expand Up @@ -1195,7 +1179,7 @@ int blk_throtl_bio(struct request_queue *q, struct bio **biop)
* So keep on trimming slice even if bio is not queued.
*/
throtl_trim_slice(td, tg, rw);
goto out;
goto out_unlock;
}

queue_bio:
Expand All @@ -1207,16 +1191,17 @@ int blk_throtl_bio(struct request_queue *q, struct bio **biop)
tg->nr_queued[READ], tg->nr_queued[WRITE]);

throtl_add_bio_tg(q->td, tg, bio);
*biop = NULL;
throttled = true;

if (update_disptime) {
tg_update_disptime(td, tg);
throtl_schedule_next_dispatch(td);
}

out:
out_unlock:
spin_unlock_irq(q->queue_lock);
return 0;
out:
return throttled;
}

int blk_throtl_init(struct request_queue *q)
Expand Down
6 changes: 3 additions & 3 deletions trunk/block/blk.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,13 @@ static inline int blk_do_io_stat(struct request *rq)
}

#ifdef CONFIG_BLK_DEV_THROTTLING
extern int blk_throtl_bio(struct request_queue *q, struct bio **bio);
extern bool blk_throtl_bio(struct request_queue *q, struct bio *bio);
extern int blk_throtl_init(struct request_queue *q);
extern void blk_throtl_exit(struct request_queue *q);
#else /* CONFIG_BLK_DEV_THROTTLING */
static inline int blk_throtl_bio(struct request_queue *q, struct bio **bio)
static inline bool blk_throtl_bio(struct request_queue *q, struct bio *bio)
{
return 0;
return false;
}
static inline int blk_throtl_init(struct request_queue *q) { return 0; }
static inline void blk_throtl_exit(struct request_queue *q) { }
Expand Down

0 comments on commit 853aac9

Please sign in to comment.