From patchwork Tue Jun 9 08:45:14 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gui Jianfeng X-Patchwork-Id: 28890 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 n598lBLk014017 for ; Tue, 9 Jun 2009 08:47:12 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 D1E89618D51; Tue, 9 Jun 2009 04:47:08 -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 n598l4KP001790 for ; Tue, 9 Jun 2009 04:47:04 -0400 Received: from mx3.redhat.com (mx3.redhat.com [172.16.48.32]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n598l2xw026430; Tue, 9 Jun 2009 04:47:02 -0400 Received: from song.cn.fujitsu.com (cn.fujitsu.com [222.73.24.84] (may be forged)) by mx3.redhat.com (8.13.8/8.13.8) with ESMTP id n598km09015043; Tue, 9 Jun 2009 04:46:48 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 26F6C1700BD; Tue, 9 Jun 2009 17:08:50 +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 n598xDS3021425; Tue, 9 Jun 2009 16:59:13 +0800 Received: from [127.0.0.1] (unknown [10.167.141.226]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id A8531D4038; Tue, 9 Jun 2009 16:46:39 +0800 (CST) Message-ID: <4A2E211A.3030303@cn.fujitsu.com> Date: Tue, 09 Jun 2009 16:45:14 +0800 From: Gui Jianfeng User-Agent: Thunderbird 2.0.0.5 (Windows/20070716) MIME-Version: 1.0 To: Vivek Goyal References: <1244513342-11758-1-git-send-email-vgoyal@redhat.com> <1244513342-11758-3-git-send-email-vgoyal@redhat.com> In-Reply-To: <1244513342-11758-3-git-send-email-vgoyal@redhat.com> X-RedHat-Spam-Score: -0.723 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 X-Scanned-By: MIMEDefang 2.63 on 172.16.48.32 X-loop: dm-devel@redhat.com Cc: dhaval@linux.vnet.ibm.com, snitzer@redhat.com, peterz@infradead.org, 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, akpm@linux-foundation.org, jbaron@redhat.com, linux-kernel@vger.kernel.org, s-uchida@ap.jp.nec.com, righi.andrea@gmail.com, containers@lists.linux-foundation.org Subject: [dm-devel] Re: [PATCH 02/19] io-controller: Common flat fair queuing code in elevaotor layer 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_slice_idle_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) Hi Vivek, data can never be less than zero. Same problems also exist for other sysfs entry. Signed-off-by: Gui Jianfeng --- block/elevator-fq.c | 40 +++++++++++++--------------------------- block/elevator-fq.h | 6 +++--- 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/block/elevator-fq.c b/block/elevator-fq.c index 42d4279..8027f4c 100644 --- a/block/elevator-fq.c +++ b/block/elevator-fq.c @@ -2643,32 +2643,27 @@ ssize_t elv_fairness_store(struct request_queue *q, const char *name, ssize_t elv_slice_idle_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); efqd = &q->elevator->efqd; data = jiffies_to_msecs(efqd->elv_slice_idle); spin_unlock_irqrestore(q->queue_lock, flags); - return sprintf(name, "%d\n", data); + return sprintf(name, "%lu\n", data); } ssize_t elv_slice_idle_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) - data = 0; - else if (data > INT_MAX) - data = INT_MAX; - data = msecs_to_jiffies(data); spin_lock_irqsave(q->queue_lock, flags); @@ -2683,32 +2678,27 @@ ssize_t elv_slice_idle_store(struct request_queue *q, const char *name, ssize_t elv_async_slice_idle_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); efqd = &q->elevator->efqd; data = jiffies_to_msecs(efqd->elv_async_slice_idle); spin_unlock_irqrestore(q->queue_lock, flags); - return sprintf(name, "%d\n", data); + return sprintf(name, "%lu\n", data); } ssize_t elv_async_slice_idle_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) - data = 0; - else if (data > INT_MAX) - data = INT_MAX; - data = msecs_to_jiffies(data); spin_lock_irqsave(q->queue_lock, flags); @@ -2730,24 +2720,22 @@ ssize_t elv_slice_sync_show(struct request_queue *q, char *name) efqd = &q->elevator->efqd; data = efqd->elv_slice[1]; spin_unlock_irqrestore(q->queue_lock, flags); - return sprintf(name, "%d\n", data); + return sprintf(name, "%lu\n", data); } ssize_t elv_slice_sync_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) - data = 0; /* 100ms is the limit for now*/ - else if (data > 100) + if (data > 100) data = 100; spin_lock_irqsave(q->queue_lock, flags); @@ -2762,31 +2750,29 @@ ssize_t elv_slice_sync_store(struct request_queue *q, const char *name, ssize_t elv_slice_async_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); efqd = &q->elevator->efqd; data = efqd->elv_slice[0]; spin_unlock_irqrestore(q->queue_lock, flags); - return sprintf(name, "%d\n", data); + return sprintf(name, "%lu\n", data); } ssize_t elv_slice_async_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) - data = 0; /* 100ms is the limit for now*/ - else if (data > 100) + if (data > 100) data = 100; spin_lock_irqsave(q->queue_lock, flags); diff --git a/block/elevator-fq.h b/block/elevator-fq.h index 4fe843a..46e4dbc 100644 --- a/block/elevator-fq.h +++ b/block/elevator-fq.h @@ -338,13 +338,13 @@ struct elv_fq_data { * have any notion of anticipation/idling. As of now, these are the * users of this functionality. */ - unsigned int elv_slice_idle; + unsigned long elv_slice_idle; /* idle slice for async queue */ - unsigned int elv_async_slice_idle; + unsigned long elv_async_slice_idle; struct timer_list idle_slice_timer; struct work_struct unplug_work; - unsigned int elv_slice[2]; + unsigned long elv_slice[2]; /* Fields for keeping track of average disk rate */ unsigned long rate_sectors; /* number of sectors finished */