From: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
To: linux-kernel@vger.kernel.org
Cc: axboe@kernel.dk, tj@kernel.org, seiji.aguchi@hds.com,
vgoyal@redhat.com, majianpeng@gmail.com
Subject: [PATCH v2 2/2] elevator: acquire q->sysfs_lock in elevator_change()
Date: Fri, 30 Aug 2013 18:47:16 -0400 [thread overview]
Message-ID: <20130830224716.21812.99333.stgit@hds.com> (raw)
In-Reply-To: <20130830224707.21812.63516.stgit@hds.com>
Add locking of q->sysfs_lock into elevator_change() (an exported function)
to ensure it is held to protect q->elevator from elevator_init(), even if
elevator_change() is called from non-sysfs paths.
sysfs path (elv_iosched_store) uses __elevator_change(), non-locking
version, as the lock is already taken by elv_iosched_store().
Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
---
block/elevator.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/block/elevator.c b/block/elevator.c
index 02d4390..6d765f7 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -965,7 +965,7 @@ fail_init:
/*
* Switch this queue to the given IO scheduler.
*/
-int elevator_change(struct request_queue *q, const char *name)
+static int __elevator_change(struct request_queue *q, const char *name)
{
char elevator_name[ELV_NAME_MAX];
struct elevator_type *e;
@@ -987,6 +987,18 @@ int elevator_change(struct request_queue *q, const char *name)
return elevator_switch(q, e);
}
+
+int elevator_change(struct request_queue *q, const char *name)
+{
+ int ret;
+
+ /* Protect q->elevator from elevator_init() */
+ mutex_lock(&q->sysfs_lock);
+ ret = __elevator_change(q, name);
+ mutex_unlock(&q->sysfs_lock);
+
+ return ret;
+}
EXPORT_SYMBOL(elevator_change);
ssize_t elv_iosched_store(struct request_queue *q, const char *name,
@@ -997,7 +1009,7 @@ ssize_t elv_iosched_store(struct request_queue *q, const char *name,
if (!q->elevator)
return count;
- ret = elevator_change(q, name);
+ ret = __elevator_change(q, name);
if (!ret)
return count;
next prev parent reply other threads:[~2013-08-30 22:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-30 22:47 [PATCH v2 1/2] elevator: Fix a race in elevator switching and md device initialization Tomoki Sekiyama
2013-08-30 22:47 ` Tomoki Sekiyama [this message]
2013-09-22 17:00 ` [PATCH v2 2/2] elevator: acquire q->sysfs_lock in elevator_change() Tejun Heo
2013-09-06 15:01 ` [PATCH v2 1/2] elevator: Fix a race in elevator switching and md device initialization Tomoki Sekiyama
2013-09-22 17:04 ` Tejun Heo
2013-09-23 20:11 ` Tomoki Sekiyama
2013-09-23 20:14 ` Tejun Heo
2013-10-09 22:36 ` Tomoki Sekiyama
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130830224716.21812.99333.stgit@hds.com \
--to=tomoki.sekiyama@hds.com \
--cc=axboe@kernel.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=majianpeng@gmail.com \
--cc=seiji.aguchi@hds.com \
--cc=tj@kernel.org \
--cc=vgoyal@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.