From patchwork Tue Jun 9 07:56:38 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gui Jianfeng X-Patchwork-Id: 28881 Received: from hormel.redhat.com (hormel1.redhat.com [209.132.177.33]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n597wgjk010448 for ; Tue, 9 Jun 2009 07:58:43 GMT Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id EF0B3618D0E; Tue, 9 Jun 2009 03:58:41 -0400 (EDT) Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id n597wceV027904 for ; Tue, 9 Jun 2009 03:58:38 -0400 Received: from mx1.redhat.com (mx1.redhat.com [172.16.48.31]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n597wZ0i028186; Tue, 9 Jun 2009 03:58:35 -0400 Received: from song.cn.fujitsu.com (cn.fujitsu.com [222.73.24.84] (may be forged)) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n597wLFt009219; Tue, 9 Jun 2009 03:58:22 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 1BE98170134; Tue, 9 Jun 2009 16:20:16 +0800 (CST) Received: from fnst.cn.fujitsu.com (localhost.localdomain [127.0.0.1]) by tang.cn.fujitsu.com (8.13.1/8.13.1) with ESMTP id n598AdDM019063; Tue, 9 Jun 2009 16:10:39 +0800 Received: from [127.0.0.1] (unknown [10.167.141.226]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id 47A2FD4016; Tue, 9 Jun 2009 15:58:04 +0800 (CST) Message-ID: <4A2E15B6.8030001@cn.fujitsu.com> Date: Tue, 09 Jun 2009 15:56:38 +0800 From: Gui Jianfeng User-Agent: Thunderbird 2.0.0.5 (Windows/20070716) MIME-Version: 1.0 To: Vivek Goyal References: <1241553525-28095-1-git-send-email-vgoyal@redhat.com> <1241553525-28095-9-git-send-email-vgoyal@redhat.com> In-Reply-To: <1241553525-28095-9-git-send-email-vgoyal@redhat.com> X-RedHat-Spam-Score: -0.738 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 X-Scanned-By: MIMEDefang 2.63 on 172.16.48.31 X-loop: dm-devel@redhat.com Cc: dhaval@linux.vnet.ibm.com, snitzer@redhat.com, dm-devel@redhat.com, dpshah@google.com, jens.axboe@oracle.com, agk@redhat.com, balbir@linux.vnet.ibm.com, paolo.valente@unimore.it, fernando@oss.ntt.co.jp, mikew@google.com, jmoyer@redhat.com, nauman@google.com, m-ikeda@ds.jp.nec.com, lizf@cn.fujitsu.com, fchecconi@gmail.com, s-uchida@ap.jp.nec.com, containers@lists.linux-foundation.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, righi.andrea@gmail.com Subject: [dm-devel] Re: [PATCH 08/18] io-controller: idle for sometime on sync queue before expiring it X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.5 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com Vivek Goyal wrote: ... > +ssize_t elv_fairness_store(struct request_queue *q, const char *name, > + size_t count) > +{ > + struct elv_fq_data *efqd; > + unsigned int data; > + unsigned long flags; > + > + char *p = (char *)name; > + > + data = simple_strtoul(p, &p, 10); > + > + if (data < 0) > + data = 0; > + else if (data > INT_MAX) > + data = INT_MAX; Hi Vivek, data might overflow on 64 bit systems. In addition, since "fairness" is nothing more than a switch, just let it be. Signed-off-by: Gui Jianfeng --- block/elevator-fq.c | 10 +++++----- block/elevator-fq.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/block/elevator-fq.c b/block/elevator-fq.c index 655162b..42d4279 100644 --- a/block/elevator-fq.c +++ b/block/elevator-fq.c @@ -2605,7 +2605,7 @@ static inline int is_root_group_ioq(struct request_queue *q, ssize_t elv_fairness_show(struct request_queue *q, char *name) { struct elv_fq_data *efqd; - unsigned int data; + unsigned long data; unsigned long flags; spin_lock_irqsave(q->queue_lock, flags); @@ -2619,17 +2619,17 @@ ssize_t elv_fairness_store(struct request_queue *q, const char *name, size_t count) { struct elv_fq_data *efqd; - unsigned int data; + unsigned long data; unsigned long flags; char *p = (char *)name; data = simple_strtoul(p, &p, 10); - if (data < 0) + if (!data) data = 0; - else if (data > INT_MAX) - data = INT_MAX; + else + data = 1; spin_lock_irqsave(q->queue_lock, flags); efqd = &q->elevator->efqd; diff --git a/block/elevator-fq.h b/block/elevator-fq.h index b2bb11a..4fe843a 100644 --- a/block/elevator-fq.h +++ b/block/elevator-fq.h @@ -359,7 +359,7 @@ struct elv_fq_data { * throughput and focus more on providing fairness for sync * queues. */ - int fairness; + unsigned long fairness; }; extern int elv_slice_idle;