f40a945
                                                                                                                                                                                                                                                               
f40a945
Delivered-To: jwboyer@gmail.com
f40a945
Received: by 10.76.168.104 with SMTP id zv8csp55623oab;
f40a945
        Fri, 30 Aug 2013 15:51:42 -0700 (PDT)
f40a945
X-Received: by 10.67.30.70 with SMTP id kc6mr13149193pad.32.1377903101609;
f40a945
        Fri, 30 Aug 2013 15:51:41 -0700 (PDT)
f40a945
Return-Path: <linux-kernel-owner@vger.kernel.org>
f40a945
Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67])
f40a945
        by mx.google.com with ESMTP id gg2si304840pac.217.1969.12.31.16.00.00;
f40a945
        Fri, 30 Aug 2013 15:51:41 -0700 (PDT)
f40a945
Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67;
f40a945
Authentication-Results: mx.google.com;
f40a945
       spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mail=linux-kernel-owner@vger.kernel.org;
f40a945
       dkim=neutral (bad format) header.i=@hds.com
f40a945
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
f40a945
	id S1756106Ab3H3WrX (ORCPT <rfc822;georgezhim@gmail.com>
f40a945
	+ 99 others); Fri, 30 Aug 2013 18:47:23 -0400
f40a945
Received: from usindpps04.hds.com ([207.126.252.17]:35640 "EHLO
f40a945
	usindpps04.hds.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
f40a945
	with ESMTP id S1752650Ab3H3WrW (ORCPT
f40a945
	<rfc822;linux-kernel@vger.kernel.org>);
f40a945
	Fri, 30 Aug 2013 18:47:22 -0400
f40a945
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/simple; d=hds.com; h=subject : to : from : cc
f40a945
 : date : message-id : in-reply-to : references : mime-version :
f40a945
 content-type : content-transfer-encoding; s=mail1;
f40a945
 bh=xbQuWVaSJrPfWG5E7bXFAbOFjf/sBaRZsPmpVgy0CYk=;
f40a945
 b=NW/A8Imu32MXoBi5FLrQ0FsK66RTWMQo1bFRtgQplVEQQIAXyf1XhCaAZyTkTplc0iEx
f40a945
 ovyGZHvLbmGL6w3I3pxkCFz1BPJCqoZtvQITir/WvfzyadYOK1cz+vuBUQSCmfkacvS/
f40a945
 w37h1jLAjsvWXkl0GY7pxB9HJMXdeLnhhuWxtNU8m8rKZ7t3LSByMeQi5/3OTkNojDEe
f40a945
 70cKeZXCPQ/UIDJAF4cpSVXia5FwoJISjXvQIrvqkYhFelzq3OHMcC482PdpqNB475h3
f40a945
 yHHJ83HFOLRulUQdOG5ZVTB9qRg0zxRx/oedeXwzturFke68noRRa4f4izQ8sCwsWOCI Dw== 
f40a945
Received: from usindmail01.hds.com (usindmail03 [207.126.252.22])
f40a945
	by usindpps04.hds.com (8.14.5/8.14.5) with ESMTP id r7UMlHIc025543;
f40a945
	Fri, 30 Aug 2013 18:47:17 -0400
f40a945
Received: from hds.com (usindnetf5d-vlan47float.corp.hds.com [10.74.73.11])
f40a945
	by usindmail01.hds.com (8.14.1/8.14.1) with ESMTP id r7UMlGiC058545;
f40a945
	Fri, 30 Aug 2013 18:47:17 -0400 (EDT)
f40a945
Subject: [PATCH v2 2/2] elevator: acquire q->sysfs_lock in elevator_change()
f40a945
To:	linux-kernel@vger.kernel.org
f40a945
From:	Tomoki Sekiyama <tomoki.sekiyama@hds.com>
f40a945
Cc:	axboe@kernel.dk, tj@kernel.org, seiji.aguchi@hds.com,
f40a945
	vgoyal@redhat.com, majianpeng@gmail.com
f40a945
Date:	Fri, 30 Aug 2013 18:47:16 -0400
f40a945
Message-ID: <20130830224716.21812.99333.stgit@hds.com>
f40a945
In-Reply-To: <20130830224707.21812.63516.stgit@hds.com>
f40a945
References: <20130830224707.21812.63516.stgit@hds.com>
f40a945
User-Agent: StGit/0.16
f40a945
MIME-Version: 1.0
f40a945
Content-Type: text/plain; charset="utf-8"
f40a945
Content-Transfer-Encoding: 7bit
f40a945
X-Proofpoint-SPF-Result: pass
f40a945
X-Proofpoint-SPF-Record: v=spf1 mx ip4:207.126.244.0/26 ip4:207.126.252.0/25 include:mktomail.com
f40a945
 include:cloud.hds.com ~all
f40a945
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.10.8794,1.0.431,0.0.0000
f40a945
 definitions=2013-08-30_09:2013-08-30,2013-08-30,1970-01-01 signatures=0
f40a945
X-Proofpoint-Spam-Details: rule=notspam policy=outbound_policy score=0 spamscore=0 suspectscore=1
f40a945
 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx
f40a945
 scancount=1 engine=7.0.1-1305240000 definitions=main-1308300162
f40a945
Sender:	linux-kernel-owner@vger.kernel.org
f40a945
Precedence: bulk
f40a945
List-ID: <linux-kernel.vger.kernel.org>
f40a945
X-Mailing-List:	linux-kernel@vger.kernel.org
f40a945
f40a945
Add locking of q->sysfs_lock into elevator_change() (an exported function)
f40a945
to ensure it is held to protect q->elevator from elevator_init(), even if
f40a945
elevator_change() is called from non-sysfs paths.
f40a945
sysfs path (elv_iosched_store) uses __elevator_change(), non-locking
f40a945
version, as the lock is already taken by elv_iosched_store().
f40a945
f40a945
Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
f40a945
---
f40a945
 block/elevator.c |   16 ++++++++++++++--
f40a945
 1 file changed, 14 insertions(+), 2 deletions(-)
f40a945
f40a945
diff --git a/block/elevator.c b/block/elevator.c
f40a945
index 02d4390..6d765f7 100644
f40a945
--- a/block/elevator.c
f40a945
+++ b/block/elevator.c
f40a945
@@ -965,7 +965,7 @@ fail_init:
f40a945
 /*
f40a945
  * Switch this queue to the given IO scheduler.
f40a945
  */
f40a945
-int elevator_change(struct request_queue *q, const char *name)
f40a945
+static int __elevator_change(struct request_queue *q, const char *name)
f40a945
 {
f40a945
 	char elevator_name[ELV_NAME_MAX];
f40a945
 	struct elevator_type *e;
f40a945
@@ -987,6 +987,18 @@ int elevator_change(struct request_queue *q, const char *name)
f40a945
 
f40a945
 	return elevator_switch(q, e);
f40a945
 }
f40a945
+
f40a945
+int elevator_change(struct request_queue *q, const char *name)
f40a945
+{
f40a945
+	int ret;
f40a945
+
f40a945
+	/* Protect q->elevator from elevator_init() */
f40a945
+	mutex_lock(&q->sysfs_lock);
f40a945
+	ret = __elevator_change(q, name);
f40a945
+	mutex_unlock(&q->sysfs_lock);
f40a945
+
f40a945
+	return ret;
f40a945
+}
f40a945
 EXPORT_SYMBOL(elevator_change);
f40a945
 
f40a945
 ssize_t elv_iosched_store(struct request_queue *q, const char *name,
f40a945
@@ -997,7 +1009,7 @@ ssize_t elv_iosched_store(struct request_queue *q, const char *name,
f40a945
 	if (!q->elevator)
f40a945
 		return count;
f40a945
 
f40a945
-	ret = elevator_change(q, name);
f40a945
+	ret = __elevator_change(q, name);
f40a945
 	if (!ret)
f40a945
 		return count;
f40a945
 
f40a945
f40a945
--
f40a945
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
f40a945
the body of a message to majordomo@vger.kernel.org
f40a945
More majordomo info at  http://vger.kernel.org/majordomo-info.html
f40a945
Please read the FAQ at  http://www.tux.org/lkml/