Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.dk/linux-2.6-block
Browse files Browse the repository at this point in the history
* 'for-linus' of git://git.kernel.dk/linux-2.6-block:
  elevator: fix oops on early call to elevator_change()
  • Loading branch information
torvalds committed Oct 7, 2010
2 parents 74de82e + 430c62f commit c8d86d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
12 changes: 8 additions & 4 deletions block/elevator.c
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,7 @@ int elv_register_queue(struct request_queue *q)
}
}
kobject_uevent(&e->kobj, KOBJ_ADD);
e->registered = 1;
}
return error;
}
Expand All @@ -947,6 +948,7 @@ static void __elv_unregister_queue(struct elevator_queue *e)
{
kobject_uevent(&e->kobj, KOBJ_REMOVE);
kobject_del(&e->kobj);
e->registered = 0;
}

void elv_unregister_queue(struct request_queue *q)
Expand Down Expand Up @@ -1042,11 +1044,13 @@ static int elevator_switch(struct request_queue *q, struct elevator_type *new_e)

spin_unlock_irq(q->queue_lock);

__elv_unregister_queue(old_elevator);
if (old_elevator->registered) {
__elv_unregister_queue(old_elevator);

err = elv_register_queue(q);
if (err)
goto fail_register;
err = elv_register_queue(q);
if (err)
goto fail_register;
}

/*
* finally exit old elevator and turn off BYPASS.
Expand Down
1 change: 1 addition & 0 deletions include/linux/elevator.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ struct elevator_queue
struct elevator_type *elevator_type;
struct mutex sysfs_lock;
struct hlist_head *hash;
unsigned int registered:1;
};

/*
Expand Down

0 comments on commit c8d86d8

Please sign in to comment.