Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 208213
b: refs/heads/master
c: e2e1a14
h: refs/heads/master
i:
  208211: 62897fc
v: v3
  • Loading branch information
Jens Axboe committed Aug 7, 2010
1 parent b060e73 commit f2d97ee
Show file tree
Hide file tree
Showing 4 changed files with 35 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: 841fdffdd382722d33579a6aa1487e8a4e526dbd
refs/heads/master: e2e1a148bc45855816ae6b4692ce29d0020fa22e
3 changes: 2 additions & 1 deletion trunk/block/blk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2111,7 +2111,8 @@ static bool blk_update_bidi_request(struct request *rq, int error,
blk_update_request(rq->next_rq, error, bidi_bytes))
return true;

add_disk_randomness(rq->rq_disk);
if (blk_queue_add_random(rq->q))
add_disk_randomness(rq->rq_disk);

return false;
}
Expand Down
28 changes: 28 additions & 0 deletions trunk/block/blk-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,27 @@ queue_rq_affinity_store(struct request_queue *q, const char *page, size_t count)
return ret;
}

static ssize_t queue_random_show(struct request_queue *q, char *page)
{
return queue_var_show(blk_queue_add_random(q), page);
}

static ssize_t queue_random_store(struct request_queue *q, const char *page,
size_t count)
{
unsigned long val;
ssize_t ret = queue_var_store(&val, page, count);

spin_lock_irq(q->queue_lock);
if (val)
queue_flag_set(QUEUE_FLAG_ADD_RANDOM, q);
else
queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, q);
spin_unlock_irq(q->queue_lock);

return ret;
}

static ssize_t queue_iostats_show(struct request_queue *q, char *page)
{
return queue_var_show(blk_queue_io_stat(q), page);
Expand Down Expand Up @@ -374,6 +395,12 @@ static struct queue_sysfs_entry queue_iostats_entry = {
.store = queue_iostats_store,
};

static struct queue_sysfs_entry queue_random_entry = {
.attr = {.name = "add_random", .mode = S_IRUGO | S_IWUSR },
.show = queue_random_show,
.store = queue_random_store,
};

static struct attribute *default_attrs[] = {
&queue_requests_entry.attr,
&queue_ra_entry.attr,
Expand All @@ -394,6 +421,7 @@ static struct attribute *default_attrs[] = {
&queue_nomerges_entry.attr,
&queue_rq_affinity_entry.attr,
&queue_iostats_entry.attr,
&queue_random_entry.attr,
NULL,
};

Expand Down
5 changes: 4 additions & 1 deletion trunk/include/linux/blkdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -467,11 +467,13 @@ struct request_queue
#define QUEUE_FLAG_IO_STAT 15 /* do IO stats */
#define QUEUE_FLAG_DISCARD 16 /* supports DISCARD */
#define QUEUE_FLAG_NOXMERGES 17 /* No extended merges */
#define QUEUE_FLAG_ADD_RANDOM 18 /* Contributes to random pool */

#define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \
(1 << QUEUE_FLAG_CLUSTER) | \
(1 << QUEUE_FLAG_STACKABLE) | \
(1 << QUEUE_FLAG_SAME_COMP))
(1 << QUEUE_FLAG_SAME_COMP) | \
(1 << QUEUE_FLAG_ADD_RANDOM))

static inline int queue_is_locked(struct request_queue *q)
{
Expand Down Expand Up @@ -596,6 +598,7 @@ enum {
test_bit(QUEUE_FLAG_NOXMERGES, &(q)->queue_flags)
#define blk_queue_nonrot(q) test_bit(QUEUE_FLAG_NONROT, &(q)->queue_flags)
#define blk_queue_io_stat(q) test_bit(QUEUE_FLAG_IO_STAT, &(q)->queue_flags)
#define blk_queue_add_random(q) test_bit(QUEUE_FLAG_ADD_RANDOM, &(q)->queue_flags)
#define blk_queue_flushing(q) ((q)->ordseq)
#define blk_queue_stackable(q) \
test_bit(QUEUE_FLAG_STACKABLE, &(q)->queue_flags)
Expand Down

0 comments on commit f2d97ee

Please sign in to comment.