Skip to content

Commit

Permalink
block: get rid of elevator_t typedef
Browse files Browse the repository at this point in the history
Just use struct elevator_queue everywhere instead.

Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Jens Axboe committed Dec 29, 2008
1 parent abf137d commit b374d18
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 44 deletions.
8 changes: 4 additions & 4 deletions block/as-iosched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ static int as_may_queue(struct request_queue *q, int rw)
return ret;
}

static void as_exit_queue(elevator_t *e)
static void as_exit_queue(struct elevator_queue *e)
{
struct as_data *ad = e->elevator_data;

Expand Down Expand Up @@ -1409,7 +1409,7 @@ as_var_store(unsigned long *var, const char *page, size_t count)
return count;
}

static ssize_t est_time_show(elevator_t *e, char *page)
static ssize_t est_time_show(struct elevator_queue *e, char *page)
{
struct as_data *ad = e->elevator_data;
int pos = 0;
Expand All @@ -1427,7 +1427,7 @@ static ssize_t est_time_show(elevator_t *e, char *page)
}

#define SHOW_FUNCTION(__FUNC, __VAR) \
static ssize_t __FUNC(elevator_t *e, char *page) \
static ssize_t __FUNC(struct elevator_queue *e, char *page) \
{ \
struct as_data *ad = e->elevator_data; \
return as_var_show(jiffies_to_msecs((__VAR)), (page)); \
Expand All @@ -1440,7 +1440,7 @@ SHOW_FUNCTION(as_write_batch_expire_show, ad->batch_expire[REQ_ASYNC]);
#undef SHOW_FUNCTION

#define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX) \
static ssize_t __FUNC(elevator_t *e, const char *page, size_t count) \
static ssize_t __FUNC(struct elevator_queue *e, const char *page, size_t count) \
{ \
struct as_data *ad = e->elevator_data; \
int ret = as_var_store(__PTR, (page), count); \
Expand Down
6 changes: 3 additions & 3 deletions block/cfq-iosched.c
Original file line number Diff line number Diff line change
Expand Up @@ -2178,7 +2178,7 @@ static void cfq_put_async_queues(struct cfq_data *cfqd)
cfq_put_queue(cfqd->async_idle_cfqq);
}

static void cfq_exit_queue(elevator_t *e)
static void cfq_exit_queue(struct elevator_queue *e)
{
struct cfq_data *cfqd = e->elevator_data;
struct request_queue *q = cfqd->queue;
Expand Down Expand Up @@ -2288,7 +2288,7 @@ cfq_var_store(unsigned int *var, const char *page, size_t count)
}

#define SHOW_FUNCTION(__FUNC, __VAR, __CONV) \
static ssize_t __FUNC(elevator_t *e, char *page) \
static ssize_t __FUNC(struct elevator_queue *e, char *page) \
{ \
struct cfq_data *cfqd = e->elevator_data; \
unsigned int __data = __VAR; \
Expand All @@ -2308,7 +2308,7 @@ SHOW_FUNCTION(cfq_slice_async_rq_show, cfqd->cfq_slice_async_rq, 0);
#undef SHOW_FUNCTION

#define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX, __CONV) \
static ssize_t __FUNC(elevator_t *e, const char *page, size_t count) \
static ssize_t __FUNC(struct elevator_queue *e, const char *page, size_t count) \
{ \
struct cfq_data *cfqd = e->elevator_data; \
unsigned int __data; \
Expand Down
6 changes: 3 additions & 3 deletions block/deadline-iosched.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ static int deadline_queue_empty(struct request_queue *q)
&& list_empty(&dd->fifo_list[READ]);
}

static void deadline_exit_queue(elevator_t *e)
static void deadline_exit_queue(struct elevator_queue *e)
{
struct deadline_data *dd = e->elevator_data;

Expand Down Expand Up @@ -387,7 +387,7 @@ deadline_var_store(int *var, const char *page, size_t count)
}

#define SHOW_FUNCTION(__FUNC, __VAR, __CONV) \
static ssize_t __FUNC(elevator_t *e, char *page) \
static ssize_t __FUNC(struct elevator_queue *e, char *page) \
{ \
struct deadline_data *dd = e->elevator_data; \
int __data = __VAR; \
Expand All @@ -403,7 +403,7 @@ SHOW_FUNCTION(deadline_fifo_batch_show, dd->fifo_batch, 0);
#undef SHOW_FUNCTION

#define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX, __CONV) \
static ssize_t __FUNC(elevator_t *e, const char *page, size_t count) \
static ssize_t __FUNC(struct elevator_queue *e, const char *page, size_t count) \
{ \
struct deadline_data *dd = e->elevator_data; \
int __data; \
Expand Down
55 changes: 29 additions & 26 deletions block/elevator.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ DEFINE_TRACE(block_rq_issue);
static int elv_iosched_allow_merge(struct request *rq, struct bio *bio)
{
struct request_queue *q = rq->q;
elevator_t *e = q->elevator;
struct elevator_queue *e = q->elevator;

if (e->ops->elevator_allow_merge_fn)
return e->ops->elevator_allow_merge_fn(q, rq, bio);
Expand Down Expand Up @@ -208,13 +208,13 @@ __setup("elevator=", elevator_setup);

static struct kobj_type elv_ktype;

static elevator_t *elevator_alloc(struct request_queue *q,
static struct elevator_queue *elevator_alloc(struct request_queue *q,
struct elevator_type *e)
{
elevator_t *eq;
struct elevator_queue *eq;
int i;

eq = kmalloc_node(sizeof(elevator_t), GFP_KERNEL | __GFP_ZERO, q->node);
eq = kmalloc_node(sizeof(*eq), GFP_KERNEL | __GFP_ZERO, q->node);
if (unlikely(!eq))
goto err;

Expand All @@ -240,8 +240,9 @@ static elevator_t *elevator_alloc(struct request_queue *q,

static void elevator_release(struct kobject *kobj)
{
elevator_t *e = container_of(kobj, elevator_t, kobj);
struct elevator_queue *e;

e = container_of(kobj, struct elevator_queue, kobj);
elevator_put(e->elevator_type);
kfree(e->hash);
kfree(e);
Expand Down Expand Up @@ -297,7 +298,7 @@ int elevator_init(struct request_queue *q, char *name)
}
EXPORT_SYMBOL(elevator_init);

void elevator_exit(elevator_t *e)
void elevator_exit(struct elevator_queue *e)
{
mutex_lock(&e->sysfs_lock);
if (e->ops->elevator_exit_fn)
Expand All @@ -311,15 +312,15 @@ EXPORT_SYMBOL(elevator_exit);

static void elv_activate_rq(struct request_queue *q, struct request *rq)
{
elevator_t *e = q->elevator;
struct elevator_queue *e = q->elevator;

if (e->ops->elevator_activate_req_fn)
e->ops->elevator_activate_req_fn(q, rq);
}

static void elv_deactivate_rq(struct request_queue *q, struct request *rq)
{
elevator_t *e = q->elevator;
struct elevator_queue *e = q->elevator;

if (e->ops->elevator_deactivate_req_fn)
e->ops->elevator_deactivate_req_fn(q, rq);
Expand All @@ -338,7 +339,7 @@ static void elv_rqhash_del(struct request_queue *q, struct request *rq)

static void elv_rqhash_add(struct request_queue *q, struct request *rq)
{
elevator_t *e = q->elevator;
struct elevator_queue *e = q->elevator;

BUG_ON(ELV_ON_HASH(rq));
hlist_add_head(&rq->hash, &e->hash[ELV_HASH_FN(rq_hash_key(rq))]);
Expand All @@ -352,7 +353,7 @@ static void elv_rqhash_reposition(struct request_queue *q, struct request *rq)

static struct request *elv_rqhash_find(struct request_queue *q, sector_t offset)
{
elevator_t *e = q->elevator;
struct elevator_queue *e = q->elevator;
struct hlist_head *hash_list = &e->hash[ELV_HASH_FN(offset)];
struct hlist_node *entry, *next;
struct request *rq;
Expand Down Expand Up @@ -494,7 +495,7 @@ EXPORT_SYMBOL(elv_dispatch_add_tail);

int elv_merge(struct request_queue *q, struct request **req, struct bio *bio)
{
elevator_t *e = q->elevator;
struct elevator_queue *e = q->elevator;
struct request *__rq;
int ret;

Expand Down Expand Up @@ -529,7 +530,7 @@ int elv_merge(struct request_queue *q, struct request **req, struct bio *bio)

void elv_merged_request(struct request_queue *q, struct request *rq, int type)
{
elevator_t *e = q->elevator;
struct elevator_queue *e = q->elevator;

if (e->ops->elevator_merged_fn)
e->ops->elevator_merged_fn(q, rq, type);
Expand All @@ -543,7 +544,7 @@ void elv_merged_request(struct request_queue *q, struct request *rq, int type)
void elv_merge_requests(struct request_queue *q, struct request *rq,
struct request *next)
{
elevator_t *e = q->elevator;
struct elevator_queue *e = q->elevator;

if (e->ops->elevator_merge_req_fn)
e->ops->elevator_merge_req_fn(q, rq, next);
Expand Down Expand Up @@ -846,7 +847,7 @@ void elv_dequeue_request(struct request_queue *q, struct request *rq)

int elv_queue_empty(struct request_queue *q)
{
elevator_t *e = q->elevator;
struct elevator_queue *e = q->elevator;

if (!list_empty(&q->queue_head))
return 0;
Expand All @@ -860,7 +861,7 @@ EXPORT_SYMBOL(elv_queue_empty);

struct request *elv_latter_request(struct request_queue *q, struct request *rq)
{
elevator_t *e = q->elevator;
struct elevator_queue *e = q->elevator;

if (e->ops->elevator_latter_req_fn)
return e->ops->elevator_latter_req_fn(q, rq);
Expand All @@ -869,7 +870,7 @@ struct request *elv_latter_request(struct request_queue *q, struct request *rq)

struct request *elv_former_request(struct request_queue *q, struct request *rq)
{
elevator_t *e = q->elevator;
struct elevator_queue *e = q->elevator;

if (e->ops->elevator_former_req_fn)
return e->ops->elevator_former_req_fn(q, rq);
Expand All @@ -878,7 +879,7 @@ struct request *elv_former_request(struct request_queue *q, struct request *rq)

int elv_set_request(struct request_queue *q, struct request *rq, gfp_t gfp_mask)
{
elevator_t *e = q->elevator;
struct elevator_queue *e = q->elevator;

if (e->ops->elevator_set_req_fn)
return e->ops->elevator_set_req_fn(q, rq, gfp_mask);
Expand All @@ -889,15 +890,15 @@ int elv_set_request(struct request_queue *q, struct request *rq, gfp_t gfp_mask)

void elv_put_request(struct request_queue *q, struct request *rq)
{
elevator_t *e = q->elevator;
struct elevator_queue *e = q->elevator;

if (e->ops->elevator_put_req_fn)
e->ops->elevator_put_req_fn(rq);
}

int elv_may_queue(struct request_queue *q, int rw)
{
elevator_t *e = q->elevator;
struct elevator_queue *e = q->elevator;

if (e->ops->elevator_may_queue_fn)
return e->ops->elevator_may_queue_fn(q, rw);
Expand All @@ -920,7 +921,7 @@ EXPORT_SYMBOL(elv_abort_queue);

void elv_completed_request(struct request_queue *q, struct request *rq)
{
elevator_t *e = q->elevator;
struct elevator_queue *e = q->elevator;

/*
* request is released from the driver, io must be done
Expand Down Expand Up @@ -955,13 +956,14 @@ void elv_completed_request(struct request_queue *q, struct request *rq)
static ssize_t
elv_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
{
elevator_t *e = container_of(kobj, elevator_t, kobj);
struct elv_fs_entry *entry = to_elv(attr);
struct elevator_queue *e;
ssize_t error;

if (!entry->show)
return -EIO;

e = container_of(kobj, struct elevator_queue, kobj);
mutex_lock(&e->sysfs_lock);
error = e->ops ? entry->show(e, page) : -ENOENT;
mutex_unlock(&e->sysfs_lock);
Expand All @@ -972,13 +974,14 @@ static ssize_t
elv_attr_store(struct kobject *kobj, struct attribute *attr,
const char *page, size_t length)
{
elevator_t *e = container_of(kobj, elevator_t, kobj);
struct elv_fs_entry *entry = to_elv(attr);
struct elevator_queue *e;
ssize_t error;

if (!entry->store)
return -EIO;

e = container_of(kobj, struct elevator_queue, kobj);
mutex_lock(&e->sysfs_lock);
error = e->ops ? entry->store(e, page, length) : -ENOENT;
mutex_unlock(&e->sysfs_lock);
Expand All @@ -997,7 +1000,7 @@ static struct kobj_type elv_ktype = {

int elv_register_queue(struct request_queue *q)
{
elevator_t *e = q->elevator;
struct elevator_queue *e = q->elevator;
int error;

error = kobject_add(&e->kobj, &q->kobj, "%s", "iosched");
Expand All @@ -1015,7 +1018,7 @@ int elv_register_queue(struct request_queue *q)
return error;
}

static void __elv_unregister_queue(elevator_t *e)
static void __elv_unregister_queue(struct elevator_queue *e)
{
kobject_uevent(&e->kobj, KOBJ_REMOVE);
kobject_del(&e->kobj);
Expand Down Expand Up @@ -1078,7 +1081,7 @@ EXPORT_SYMBOL_GPL(elv_unregister);
*/
static int elevator_switch(struct request_queue *q, struct elevator_type *new_e)
{
elevator_t *old_elevator, *e;
struct elevator_queue *old_elevator, *e;
void *data;

/*
Expand Down Expand Up @@ -1184,7 +1187,7 @@ ssize_t elv_iosched_store(struct request_queue *q, const char *name,

ssize_t elv_iosched_show(struct request_queue *q, char *name)
{
elevator_t *e = q->elevator;
struct elevator_queue *e = q->elevator;
struct elevator_type *elv = e->elevator_type;
struct elevator_type *__e;
int len = 0;
Expand Down
2 changes: 1 addition & 1 deletion block/noop-iosched.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static void *noop_init_queue(struct request_queue *q)
return nd;
}

static void noop_exit_queue(elevator_t *e)
static void noop_exit_queue(struct elevator_queue *e)
{
struct noop_data *nd = e->elevator_data;

Expand Down
2 changes: 1 addition & 1 deletion drivers/block/nbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ static int __init nbd_init(void)

for (i = 0; i < nbds_max; i++) {
struct gendisk *disk = alloc_disk(1 << part_shift);
elevator_t *old_e;
struct elevator_queue *old_e;
if (!disk)
goto out;
nbd_dev[i].disk = disk;
Expand Down
3 changes: 1 addition & 2 deletions include/linux/blkdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ struct scsi_ioctl_command;

struct request_queue;
struct elevator_queue;
typedef struct elevator_queue elevator_t;
struct request_pm_state;
struct blk_trace;
struct request;
Expand Down Expand Up @@ -313,7 +312,7 @@ struct request_queue
*/
struct list_head queue_head;
struct request *last_merge;
elevator_t *elevator;
struct elevator_queue *elevator;

/*
* the queue request freelist, one for reads and one for writes
Expand Down
8 changes: 4 additions & 4 deletions include/linux/elevator.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ typedef void (elevator_activate_req_fn) (struct request_queue *, struct request
typedef void (elevator_deactivate_req_fn) (struct request_queue *, struct request *);

typedef void *(elevator_init_fn) (struct request_queue *);
typedef void (elevator_exit_fn) (elevator_t *);
typedef void (elevator_exit_fn) (struct elevator_queue *);

struct elevator_ops
{
Expand Down Expand Up @@ -62,8 +62,8 @@ struct elevator_ops

struct elv_fs_entry {
struct attribute attr;
ssize_t (*show)(elevator_t *, char *);
ssize_t (*store)(elevator_t *, const char *, size_t);
ssize_t (*show)(struct elevator_queue *, char *);
ssize_t (*store)(struct elevator_queue *, const char *, size_t);
};

/*
Expand Down Expand Up @@ -130,7 +130,7 @@ extern ssize_t elv_iosched_show(struct request_queue *, char *);
extern ssize_t elv_iosched_store(struct request_queue *, const char *, size_t);

extern int elevator_init(struct request_queue *, char *);
extern void elevator_exit(elevator_t *);
extern void elevator_exit(struct elevator_queue *);
extern int elv_rq_merge_ok(struct request *, struct bio *);

/*
Expand Down

0 comments on commit b374d18

Please sign in to comment.