kernel/elevator-acquire-q-sysfs_lo...

123 lines
5.6 KiB
Diff

Bugzilla: 902012
Upstream-status: 3.13
Delivered-To: jwboyer@gmail.com
Received: by 10.76.168.104 with SMTP id zv8csp55623oab;
Fri, 30 Aug 2013 15:51:42 -0700 (PDT)
X-Received: by 10.67.30.70 with SMTP id kc6mr13149193pad.32.1377903101609;
Fri, 30 Aug 2013 15:51:41 -0700 (PDT)
Return-Path: <linux-kernel-owner@vger.kernel.org>
Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67])
by mx.google.com with ESMTP id gg2si304840pac.217.1969.12.31.16.00.00;
Fri, 30 Aug 2013 15:51:41 -0700 (PDT)
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;
Authentication-Results: mx.google.com;
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;
dkim=neutral (bad format) header.i=@hds.com
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S1756106Ab3H3WrX (ORCPT <rfc822;georgezhim@gmail.com>
+ 99 others); Fri, 30 Aug 2013 18:47:23 -0400
Received: from usindpps04.hds.com ([207.126.252.17]:35640 "EHLO
usindpps04.hds.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S1752650Ab3H3WrW (ORCPT
<rfc822;linux-kernel@vger.kernel.org>);
Fri, 30 Aug 2013 18:47:22 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hds.com; h=subject : to : from : cc
: date : message-id : in-reply-to : references : mime-version :
content-type : content-transfer-encoding; s=mail1;
bh=xbQuWVaSJrPfWG5E7bXFAbOFjf/sBaRZsPmpVgy0CYk=;
b=NW/A8Imu32MXoBi5FLrQ0FsK66RTWMQo1bFRtgQplVEQQIAXyf1XhCaAZyTkTplc0iEx
ovyGZHvLbmGL6w3I3pxkCFz1BPJCqoZtvQITir/WvfzyadYOK1cz+vuBUQSCmfkacvS/
w37h1jLAjsvWXkl0GY7pxB9HJMXdeLnhhuWxtNU8m8rKZ7t3LSByMeQi5/3OTkNojDEe
70cKeZXCPQ/UIDJAF4cpSVXia5FwoJISjXvQIrvqkYhFelzq3OHMcC482PdpqNB475h3
yHHJ83HFOLRulUQdOG5ZVTB9qRg0zxRx/oedeXwzturFke68noRRa4f4izQ8sCwsWOCI Dw==
Received: from usindmail01.hds.com (usindmail03 [207.126.252.22])
by usindpps04.hds.com (8.14.5/8.14.5) with ESMTP id r7UMlHIc025543;
Fri, 30 Aug 2013 18:47:17 -0400
Received: from hds.com (usindnetf5d-vlan47float.corp.hds.com [10.74.73.11])
by usindmail01.hds.com (8.14.1/8.14.1) with ESMTP id r7UMlGiC058545;
Fri, 30 Aug 2013 18:47:17 -0400 (EDT)
Subject: [PATCH v2 2/2] elevator: acquire q->sysfs_lock in elevator_change()
To: linux-kernel@vger.kernel.org
From: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
Cc: axboe@kernel.dk, tj@kernel.org, seiji.aguchi@hds.com,
vgoyal@redhat.com, majianpeng@gmail.com
Date: Fri, 30 Aug 2013 18:47:16 -0400
Message-ID: <20130830224716.21812.99333.stgit@hds.com>
In-Reply-To: <20130830224707.21812.63516.stgit@hds.com>
References: <20130830224707.21812.63516.stgit@hds.com>
User-Agent: StGit/0.16
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
X-Proofpoint-SPF-Result: pass
X-Proofpoint-SPF-Record: v=spf1 mx ip4:207.126.244.0/26 ip4:207.126.252.0/25 include:mktomail.com
include:cloud.hds.com ~all
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.10.8794,1.0.431,0.0.0000
definitions=2013-08-30_09:2013-08-30,2013-08-30,1970-01-01 signatures=0
X-Proofpoint-Spam-Details: rule=notspam policy=outbound_policy score=0 spamscore=0 suspectscore=1
phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx
scancount=1 engine=7.0.1-1305240000 definitions=main-1308300162
Sender: linux-kernel-owner@vger.kernel.org
Precedence: bulk
List-ID: <linux-kernel.vger.kernel.org>
X-Mailing-List: linux-kernel@vger.kernel.org
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;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/