Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 179687
b: refs/heads/master
c: 2d1ee87
h: refs/heads/master
i:
  179685: 49a456f
  179683: b48386a
  179679: 59fcaf2
v: v3
  • Loading branch information
Julia Lawall authored and Philipp Reisner committed Jan 4, 2010
1 parent 2384009 commit ea919a6
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 58 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: 23978161f90e5a3200ad6ac9b0d534911e4cbb28
refs/heads/master: 2d1ee87d8763b38668f6f11bb53abb689a49a43e
5 changes: 5 additions & 0 deletions trunk/block/blk-ioc.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ int put_io_context(struct io_context *ioc)

if (atomic_long_dec_and_test(&ioc->refcount)) {
rcu_read_lock();
if (ioc->aic && ioc->aic->dtor)
ioc->aic->dtor(ioc->aic);
cfq_dtor(ioc);
rcu_read_unlock();

Expand Down Expand Up @@ -74,6 +76,8 @@ void exit_io_context(struct task_struct *task)
task_unlock(task);

if (atomic_dec_and_test(&ioc->nr_tasks)) {
if (ioc->aic && ioc->aic->exit)
ioc->aic->exit(ioc->aic);
cfq_exit(ioc);

}
Expand All @@ -93,6 +97,7 @@ struct io_context *alloc_io_context(gfp_t gfp_flags, int node)
ret->ioprio = 0;
ret->last_waited = jiffies; /* doesn't matter... */
ret->nr_batch_requests = 0; /* because this is 0 */
ret->aic = NULL;
INIT_RADIX_TREE(&ret->radix_root, GFP_ATOMIC | __GFP_HIGH);
INIT_HLIST_HEAD(&ret->cic_list);
ret->ioc_data = NULL;
Expand Down
39 changes: 4 additions & 35 deletions trunk/block/blk-settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
sector_t offset)
{
sector_t alignment;
unsigned int top, bottom, ret = 0;
unsigned int top, bottom;

t->max_sectors = min_not_zero(t->max_sectors, b->max_sectors);
t->max_hw_sectors = min_not_zero(t->max_hw_sectors, b->max_hw_sectors);
Expand All @@ -546,8 +546,6 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
t->max_segment_size = min_not_zero(t->max_segment_size,
b->max_segment_size);

t->misaligned |= b->misaligned;

alignment = queue_limit_alignment_offset(b, offset);

/* Bottom device has different alignment. Check that it is
Expand All @@ -560,10 +558,8 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
bottom = max(b->physical_block_size, b->io_min) + alignment;

/* Verify that top and bottom intervals line up */
if (max(top, bottom) & (min(top, bottom) - 1)) {
if (max(top, bottom) & (min(top, bottom) - 1))
t->misaligned = 1;
ret = -1;
}
}

t->logical_block_size = max(t->logical_block_size,
Expand All @@ -582,32 +578,27 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
if (t->physical_block_size & (t->logical_block_size - 1)) {
t->physical_block_size = t->logical_block_size;
t->misaligned = 1;
ret = -1;
}

/* Minimum I/O a multiple of the physical block size? */
if (t->io_min & (t->physical_block_size - 1)) {
t->io_min = t->physical_block_size;
t->misaligned = 1;
ret = -1;
}

/* Optimal I/O a multiple of the physical block size? */
if (t->io_opt & (t->physical_block_size - 1)) {
t->io_opt = 0;
t->misaligned = 1;
ret = -1;
}

/* Find lowest common alignment_offset */
t->alignment_offset = lcm(t->alignment_offset, alignment)
& (max(t->physical_block_size, t->io_min) - 1);

/* Verify that new alignment_offset is on a logical block boundary */
if (t->alignment_offset & (t->logical_block_size - 1)) {
if (t->alignment_offset & (t->logical_block_size - 1))
t->misaligned = 1;
ret = -1;
}

/* Discard alignment and granularity */
if (b->discard_granularity) {
Expand Down Expand Up @@ -635,32 +626,10 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
(t->discard_granularity - 1);
}

return ret;
return t->misaligned ? -1 : 0;
}
EXPORT_SYMBOL(blk_stack_limits);

/**
* bdev_stack_limits - adjust queue limits for stacked drivers
* @t: the stacking driver limits (top device)
* @bdev: the component block_device (bottom)
* @start: first data sector within component device
*
* Description:
* Merges queue limits for a top device and a block_device. Returns
* 0 if alignment didn't change. Returns -1 if adding the bottom
* device caused misalignment.
*/
int bdev_stack_limits(struct queue_limits *t, struct block_device *bdev,
sector_t start)
{
struct request_queue *bq = bdev_get_queue(bdev);

start += get_start_sect(bdev);

return blk_stack_limits(t, &bq->limits, start << 9);
}
EXPORT_SYMBOL(bdev_stack_limits);

/**
* disk_stack_limits - adjust queue limits for stacked drivers
* @disk: MD/DM gendisk (top)
Expand Down
6 changes: 0 additions & 6 deletions trunk/block/cfq-iosched.c
Original file line number Diff line number Diff line change
Expand Up @@ -3076,12 +3076,6 @@ cfq_should_preempt(struct cfq_data *cfqd, struct cfq_queue *new_cfqq,
if (cfq_class_idle(cfqq))
return true;

/*
* Don't allow a non-RT request to preempt an ongoing RT cfqq timeslice.
*/
if (cfq_class_rt(cfqq) && !cfq_class_rt(new_cfqq))
return false;

/*
* if the new request is sync, but the currently running queue is
* not, let the sync request have priority.
Expand Down
2 changes: 1 addition & 1 deletion trunk/block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ static ssize_t disk_discard_alignment_show(struct device *dev,
{
struct gendisk *disk = dev_to_disk(dev);

return sprintf(buf, "%d\n", queue_discard_alignment(disk->queue));
return sprintf(buf, "%u\n", queue_discard_alignment(disk->queue));
}

static DEVICE_ATTR(range, S_IRUGO, disk_range_show, NULL);
Expand Down
20 changes: 15 additions & 5 deletions trunk/drivers/md/dm-table.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,15 +503,16 @@ int dm_set_device_limits(struct dm_target *ti, struct dm_dev *dev,
return 0;
}

if (bdev_stack_limits(limits, bdev, start) < 0)
DMWARN("%s: adding target device %s caused an alignment inconsistency: "
if (blk_stack_limits(limits, &q->limits, start << 9) < 0)
DMWARN("%s: target device %s is misaligned: "
"physical_block_size=%u, logical_block_size=%u, "
"alignment_offset=%u, start=%llu",
dm_device_name(ti->table->md), bdevname(bdev, b),
q->limits.physical_block_size,
q->limits.logical_block_size,
q->limits.alignment_offset,
(unsigned long long) start << SECTOR_SHIFT);
(unsigned long long) start << 9);


/*
* Check if merge fn is supported.
Expand Down Expand Up @@ -1025,9 +1026,9 @@ int dm_calculate_queue_limits(struct dm_table *table,
* for the table.
*/
if (blk_stack_limits(limits, &ti_limits, 0) < 0)
DMWARN("%s: adding target device "
DMWARN("%s: target device "
"(start sect %llu len %llu) "
"caused an alignment inconsistency",
"is misaligned",
dm_device_name(table->md),
(unsigned long long) ti->begin,
(unsigned long long) ti->len);
Expand Down Expand Up @@ -1078,6 +1079,15 @@ static void dm_table_set_integrity(struct dm_table *t)
void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
struct queue_limits *limits)
{
/*
* Each target device in the table has a data area that should normally
* be aligned such that the DM device's alignment_offset is 0.
* FIXME: Propagate alignment_offsets up the stack and warn of
* sub-optimal or inconsistent settings.
*/
limits->alignment_offset = 0;
limits->misaligned = 0;

/*
* Copy table's limits to the DM device's request_queue
*/
Expand Down
9 changes: 2 additions & 7 deletions trunk/include/linux/blkdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -938,8 +938,6 @@ extern void blk_queue_io_opt(struct request_queue *q, unsigned int opt);
extern void blk_set_default_limits(struct queue_limits *lim);
extern int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
sector_t offset);
extern int bdev_stack_limits(struct queue_limits *t, struct block_device *bdev,
sector_t offset);
extern void disk_stack_limits(struct gendisk *disk, struct block_device *bdev,
sector_t offset);
extern void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b);
Expand Down Expand Up @@ -1150,11 +1148,8 @@ static inline int queue_discard_alignment(struct request_queue *q)
static inline int queue_sector_discard_alignment(struct request_queue *q,
sector_t sector)
{
struct queue_limits *lim = &q->limits;
unsigned int alignment = (sector << 9) & (lim->discard_granularity - 1);

return (lim->discard_granularity + lim->discard_alignment - alignment)
& (lim->discard_granularity - 1);
return ((sector << 9) - q->limits.discard_alignment)
& (q->limits.discard_granularity - 1);
}

static inline unsigned int queue_discard_zeroes_data(struct request_queue *q)
Expand Down
6 changes: 3 additions & 3 deletions trunk/include/linux/genhd.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,9 @@ extern struct hd_struct *disk_map_sector_rcu(struct gendisk *disk,
#define part_stat_read(part, field) \
({ \
typeof((part)->dkstats->field) res = 0; \
unsigned int _cpu; \
for_each_possible_cpu(_cpu) \
res += per_cpu_ptr((part)->dkstats, _cpu)->field; \
int i; \
for_each_possible_cpu(i) \
res += per_cpu_ptr((part)->dkstats, i)->field; \
res; \
})

Expand Down
27 changes: 27 additions & 0 deletions trunk/include/linux/iocontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,32 @@
#include <linux/radix-tree.h>
#include <linux/rcupdate.h>

/*
* This is the per-process anticipatory I/O scheduler state.
*/
struct as_io_context {
spinlock_t lock;

void (*dtor)(struct as_io_context *aic); /* destructor */
void (*exit)(struct as_io_context *aic); /* called on task exit */

unsigned long state;
atomic_t nr_queued; /* queued reads & sync writes */
atomic_t nr_dispatched; /* number of requests gone to the drivers */

/* IO History tracking */
/* Thinktime */
unsigned long last_end_request;
unsigned long ttime_total;
unsigned long ttime_samples;
unsigned long ttime_mean;
/* Layout pattern */
unsigned int seek_samples;
sector_t last_request_pos;
u64 seek_total;
sector_t seek_mean;
};

struct cfq_queue;
struct cfq_io_context {
void *key;
Expand Down Expand Up @@ -52,6 +78,7 @@ struct io_context {
unsigned long last_waited; /* Time last woken after wait for request */
int nr_batch_requests; /* Number of requests left in the batch */

struct as_io_context *aic;
struct radix_tree_root radix_root;
struct hlist_head cic_list;
void *ioc_data;
Expand Down

0 comments on commit ea919a6

Please sign in to comment.