Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755759AbZDWJKb (ORCPT ); Thu, 23 Apr 2009 05:10:31 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752757AbZDWJKV (ORCPT ); Thu, 23 Apr 2009 05:10:21 -0400 Received: from ti-out-0910.google.com ([209.85.142.185]:54269 "EHLO ti-out-0910.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752590AbZDWJKS (ORCPT ); Thu, 23 Apr 2009 05:10:18 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=HhuydT/GaoeiBBJAfD6KkupCz+BW951mY8LFDlvuHm13NTd4LKrDyuXj/Yb6KoPaJ/ U5WTyOGntNJ+BHwiUIrBjtHikgMso0u5hL1gLSjEJQj9QSMTel3oqp6/vlSLS9KIJHQ5 IoZM93RQ6HVk7a0boFjHcMCryYg95hKdefirY= MIME-Version: 1.0 Date: Thu, 23 Apr 2009 18:10:14 +0900 Message-ID: <2891419e0904230210w40482535ma3fc25c1e429969d@mail.gmail.com> Subject: [PATCH] range-bw: Another I/O scheduling policy of dm-ioband supporting the predicable I/O bandwidth (range bandwidth) From: Dong-Jae Kang To: Ryo Tsuruta , Andrea Righi , Paul Menage , Balbir Singh , Gui Jianfeng , KAMEZAWA Hiroyuki , agk@sourceware.org, akpm@linux-foundation.org, axboe@kernel.dk, Carl Henrik Lunde , dave@linux.vnet.ibm.com, Divyesh Shah , eric.rannaud@gmail.com, fernando@oss.ntt.co.jp, Hirokazu Takahashi , Li Zefan , matt@bluehost.com, dradford@bluehost.com, ngupta@google.com, randy.dunlap@oracle.com, roberto@unbit.it, Satoshi UCHIDA , subrata@linux.vnet.ibm.com, yoshikawa.takuya@oss.ntt.co.jp, Nauman Rafique , fchecconi@gmail.com, paolo.valente@unimore.it, containers@lists.linux-foundation.org, linux-kernel@vger.kernel.org, corsetproject@googlegroups.com Content-Type: multipart/mixed; boundary=001485f339387c95940468353f22 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 56643 Lines: 1277 --001485f339387c95940468353f22 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Hi, all range-bw was implemented as another I/O scheduling policy of dm-ioband to support predicable I/O bandwidth between minimum and maximum bandwidth defined by administrator. So, basic advantages and defects are same with dm-ioband. Here, minimum I/O bandwidth should be guaranteed for stable performance or reliability of specific process groups and I/O bandwidth over maximum should be throttled to protect the limited I/O resource from over-provisioning in unnecessary usage or to reserve the I/O bandwidth for another use. Recently, as many contributors have discussed about similar issues through the container ML, administrator of several business site requires the predicable and consistent I/O bandwidth regardless of system specification (especially disk) and he/she wants the method to limit I/O bandwidth used by less important service or process group such like io-throttle by Andrea , at the same time. I think the proportional I/O bandwidth is also important such like weight/io-weight policy in dm-ioband. So, range-bw was implemented to include the two concepts, guaranteeing of minimum bandwidth and limitation of maximum bandwidth according to the importance or priority of specific process groups. range-bw is based on newest version of dm-ioband, bio-cgroup V7(4 patch files), dm-ioband-V1.10.3(1 patch file) and these can be referred in http://people.valinux.co.jp/~ryov/dm-ioband/ http://people.valinux.co.jp/~ryov/bio-cgroup/ and the below range-bw patch file(dm-ioband-rangebw-1.10.3.patch) including Ryo=92s patch set is also referred in: http://www.corsetproject.net/browser/corset_source_code/resource_controller= s/disk_controller/Range-BW-for-dmioband-V1.10.3 You have to apply this(dm-ioband-rangebw-1.10.3.patch) patch file after applying dm-ioband and bio-cgroup patches. The released range-bw may have some problems and improper code although I try to test heavily. It is first release ^^ And it is required to reduce the overhead of I/O scheduling and to optimize the source code. Any comments or advices is welcome Ryo Tsuruta, Can you check this patch file ? for convenience, patch file is attached in this mail. USAGE Example ------------------------------------------------- The basic usage is same with dm-ioband by Ryo Tsuruta. So, it is helpful to refer the usage of dm-ioband. # mount the cgroup for range-bw mount -t cgroup -o bio none /root/cgroup/bio # create the 3 groups mkdir /root/cgroup/bio/bgroup1 mkdir /root/cgroup/bio/bgroup2 mkdir /root/cgroup/bio/bgroup3 # create the ioband device ( name : ioband1 ) echo "0 $(blockdev --getsize /dev/sdb2) ioband /dev/sdb2 1 0 0 none range-bw 0 :0" | dmsetup create ioband1 # init ioband device ( type and policy ) dmsetup message ioband1 0 type cgroup dmsetup message ioband1 0 policy range-bw # attach the groups to the ioband device dmsetup message ioband1 0 attach 2 dmsetup message ioband1 0 attach 3 dmsetup message ioband1 0 attach 4 # allocate the values ( min-bw and max-bw ) : XXX Kbytes # range : about 3~5Mbytes dmsetup message ioband1 0 min-bw 2:3000 dmsetup message ioband1 0 max-bw 2:5000 # range : about 7~10Mbytes dmsetup message ioband1 0 min-bw 3:7000 dmsetup message ioband1 0 max-bw 3:10000 # range : about 15~20Mbytes dmsetup message ioband1 0 min-bw 4:15000 dmsetup message ioband1 0 max-bw 4:20000 This patch file is for range-bw policy in dm-ioband.--------------------------------------------------------------- diff -urN linux-2.6.30-rc1-orig/drivers/md/dm-ioband-ctl.c linux-2.6.30-rc1/drivers/md/dm-ioband-ctl.c --- linux-2.6.30-rc1-orig/drivers/md/dm-ioband-ctl.c 2009-04-20 18:16:00.000000000 +0900 +++ linux-2.6.30-rc1/drivers/md/dm-ioband-ctl.c 2009-04-21 13:00:41.000000000 +0900 @@ -789,6 +789,17 @@ } /* + * Check the overflow of maximum bandwidth limit + */ +static int is_no_io_mode(struct ioband_group * gp) +{ + if(gp->c_io_mode =3D=3D NO_IO_MODE) + return 1; + + return 0; +} + +/* * Start to control the bandwidth once the number of uncompleted BIOs * exceeds the value of "io_throttle". */ @@ -799,9 +810,24 @@ struct ioband_device *dp =3D gp->c_banddev; unsigned long flags; int direct; + unsigned long now, time_step; spin_lock_irqsave(&dp->g_lock, flags); + gp =3D ioband_group_get(gp, bio); + + /* + * This part is for controlling the max bandwidth of range-bw poli= cy + */ + if(is_no_io_mode(gp)){=09 + now =3D jiffies; + if(time_after(dp->g_next_time_period, now)){ + time_step =3D dp->g_next_time_period - now; + range_bw_timer_register(gp->c_timer, (time_step + TIME_COMPENSATOR), (unsigned long)gp); + wait_event_lock_irq(gp->c_max_bw_over_waitq, !is_no_io_mode(gp), dp->g_lock, do_nothing()); + } + } + /* * The device is suspended while some of the ioband device * configurations are being changed. @@ -811,7 +837,6 @@ !is_device_suspended(dp), dp->g_lock, do_nothing()); - gp =3D ioband_group_get(gp, bio); prevent_burst_bios(gp, bio); if (should_pushback_bio(gp)) { spin_unlock_irqrestore(&dp->g_lock, flags); diff -urN linux-2.6.30-rc1-orig/drivers/md/dm-ioband.h linux-2.6.30-rc1/drivers/md/dm-ioband.h --- linux-2.6.30-rc1-orig/drivers/md/dm-ioband.h 2009-04-20 18:16:00.000000000 +0900 +++ linux-2.6.30-rc1/drivers/md/dm-ioband.h 2009-04-20 18:12:50.000000000 += 0900 @@ -8,6 +8,10 @@ #include #include +#include +#include +#include +#include #define DM_MSG_PREFIX "ioband" @@ -16,6 +20,12 @@ #define IOBAND_NAME_MAX 31 #define IOBAND_ID_ANY (-1) +#define MAX_BW_OVER 1 +#define MAX_BW_UNDER 0 +#define NO_IO_MODE 4 + +#define TIME_COMPENSATOR 10 + struct ioband_group; struct ioband_device { @@ -74,6 +84,16 @@ int g_token_left; /* left-over tokens from the previous epoch */ int g_token_extra; + + /* members for range-bw policy */ + int g_min_bw_total; + unsigned long g_next_time_period; + int g_time_period_expired; + struct ioband_group * g_running_gp; + int g_total_min_bw_token; + int g_consumed_min_bw_token; + int g_io_mode; + }; struct ioband_group_stat { @@ -110,8 +130,31 @@ /* rfu */ /* struct bio_list c_ordered_tag_bios; */ + + /* members for range-bw policy */ + wait_queue_head_t c_max_bw_over_waitq; + spinlock_t c_lock; + struct timer_list * c_timer; + int timer_set; + int c_min_bw; + int c_max_bw; + int c_time_slice_expired; + int c_min_bw_token; + int c_max_bw_token; + int c_consumed_min_bw_token; + int c_is_over_max_bw; + int c_io_mode; + unsigned long c_time_slice; + unsigned long c_time_slice_start; + unsigned long c_time_slice_end; + int c_wait_p_count; + }; +extern void range_bw_timeover(unsigned long gp); +extern void range_bw_timer_register(struct timer_list * ptimer, unsigned long timeover, unsigned long gp); +extern int policy_range_bw_init(struct ioband_device *dp, int argc, char **argv); + #define IOBAND_URGENT 1 #define DEV_BIO_BLOCKED 1 diff -urN linux-2.6.30-rc1-orig/drivers/md/dm-ioband-policy.c linux-2.6.30-rc1/drivers/md/dm-ioband-policy.c --- linux-2.6.30-rc1-orig/drivers/md/dm-ioband-policy.c 2009-04-20 18:16:00.000000000 +0900 +++ linux-2.6.30-rc1/drivers/md/dm-ioband-policy.c 2009-04-20 16:12:55.000000000 +0900 @@ -453,5 +453,6 @@ {"default", policy_default_init}, {"weight", policy_weight_init}, {"weight-iosize", w2_policy_weight_init}, + {"range-bw", policy_range_bw_init}, {NULL, policy_default_init} }; diff -urN linux-2.6.30-rc1-orig/drivers/md/dm-ioband-rangebw.c linux-2.6.30-rc1/drivers/md/dm-ioband-rangebw.c --- linux-2.6.30-rc1-orig/drivers/md/dm-ioband-rangebw.c 1970-01-01 09:00:00.000000000 +0900 +++ linux-2.6.30-rc1/drivers/md/dm-ioband-rangebw.c 2009-04-20 16:00:09.000000000 +0900 @@ -0,0 +1,562 @@ +/* + * dm-ioband-rangebw.c + * + * This is a I/O control policy to support the Range Bandwidth in Disk I/O= . + * And this policy is for dm-ioband controller by Ryo Tsuruta, Hirokazu Takahashi + * + * Copyright (C) 2008 - 2011 Electronics and Telecommunications Research Institute(ETRI) + * + * This program is free software. you can redistribute it and/or modify + * it under the terms of the GNU General Public License(GPL) as published = by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * Contact Information: + * Dong-Jae, Kang , Chei-Yol,Kim , + * Sung-In,Jung + */ + +#include +#include +#include +#include "dm.h" +#include "dm-bio-list.h" +#include "dm-ioband.h" + +/* + * Functions for Range Bandwidth(range-bw) policy based on the time slice and token. + */ +#define DEFAULT_BUCKET 2 +#define DEFAULT_TOKENPOOL 2048 + +#define DEFAULT_MIN_BW 0 +#define TIME_SLICE_EXPIRED 1 +#define TIME_SLICE_NOT_EXPIRED 0 + +#define MINBW_IO_MODE 0 +#define LEFTOVER_IO_MODE 1 +#define RANGE_IO_MODE 2 +#define DEFAULT_IO_MODE 3 +#define NO_IO_MODE 4 + +#define MINBW_PRIO_BASE 10 +#define OVER_IO_RATE 4 + +static const int time_slice_base =3D HZ / 10; +static const int leftover_time_slice_base =3D HZ / 25; +static const int range_time_slice_base =3D HZ / 50; + +/* + * g_restart_bios function for range-bw policy + */ +static int range_bw_restart_bios(struct ioband_device *dp) +{ + return 1; +} + +/* + * Allocate the time slice when IO mode is MINBW_IO_MODE, RANGE_IO_MODE or LEFTOVER_IO_MODE + */ +static int set_time_slice(struct ioband_group * gp) +{ + struct ioband_device *dp =3D gp->c_banddev; + int dp_io_mode, gp_io_mode; + unsigned long now =3D jiffies; + + dp_io_mode =3D dp->g_io_mode; + gp_io_mode =3D gp->c_io_mode; + + gp->c_time_slice_start =3D now; + + if(dp_io_mode =3D=3D LEFTOVER_IO_MODE){ + gp->c_time_slice_end =3D now + leftover_time_slice_base; + return 0; + } + + if(gp_io_mode =3D=3D MINBW_IO_MODE) + gp->c_time_slice_end =3D now + gp->c_time_slice; + else if(gp_io_mode =3D=3D RANGE_IO_MODE) + gp->c_time_slice_end =3D now + range_time_slice_base; + else // gp_io_mode =3D=3D DEFAULT_IO_MODE + gp->c_time_slice_end =3D now + time_slice_base; + + gp->c_time_slice_expired =3D TIME_SLICE_NOT_EXPIRED; + + return 0; +} + +/* + * Calculate the priority of given ioband_group + */ +static int range_bw_priority(struct ioband_group * gp) +{ + struct ioband_device *dp =3D gp->c_banddev; + int prio =3D 0; + + if(dp->g_io_mode =3D=3D LEFTOVER_IO_MODE){ + prio =3D random32() % MINBW_PRIO_BASE; + if(prio =3D=3D 0) + prio =3D 1; + }else if(gp->c_io_mode =3D=3D MINBW_IO_MODE){ + prio =3D (gp->c_min_bw_token - gp->c_consumed_min_bw_token) * MINBW_PRIO= _BASE; + }else if(gp->c_io_mode =3D=3D DEFAULT_IO_MODE){ + prio =3D MINBW_PRIO_BASE; + }else if(gp->c_io_mode =3D=3D RANGE_IO_MODE){ + prio =3D MINBW_PRIO_BASE / 2; + }else{ + prio =3D 0; + } + + return prio; +} + +/* + * Check whether this group has right to issue an I/O in range-bw policy m= ode. + * Return 0 if it doesn't have right, otherwise return the non-zero value= . + */ +static int has_right_to_issue(struct ioband_group *gp) +{ + struct ioband_device *dp =3D gp->c_banddev; + int prio; + + if(gp->c_prio_blocked > 0 || gp->c_blocked - gp->c_prio_blocked > 0){ + prio =3D range_bw_priority(gp); + if(prio <=3D 0) + return 1; + return prio; + } + + if(gp =3D=3D dp->g_running_gp){ + + if(gp->c_time_slice_expired =3D=3D TIME_SLICE_EXPIRED){ + + gp->c_time_slice_expired =3D TIME_SLICE_NOT_EXPIRED; + gp->c_time_slice_end =3D 0; + + return 0; + } + + if(gp->c_time_slice_end =3D=3D 0) + set_time_slice(gp); + + return range_bw_priority(gp); + + } + + dp->g_running_gp =3D gp; + set_time_slice(gp); + + return range_bw_priority(gp); +} + +/* + * Reset all variables related with range-bw token and time slice + */ +static int reset_range_bw_token(struct ioband_group * gp, unsigned long no= w) +{ + struct ioband_device *dp =3D gp->c_banddev; + struct ioband_group *p; + + list_for_each_entry(p, &dp->g_groups, c_list){ + p->c_consumed_min_bw_token =3D 0; + p->c_is_over_max_bw =3D MAX_BW_UNDER; + if(p->c_io_mode !=3D DEFAULT_IO_MODE) + p->c_io_mode =3D MINBW_IO_MODE; + } + + dp->g_consumed_min_bw_token =3D 0; + + dp->g_next_time_period =3D now + HZ; + dp->g_time_period_expired =3D TIME_SLICE_NOT_EXPIRED; + dp->g_io_mode =3D MINBW_IO_MODE; + + list_for_each_entry(p, &dp->g_groups, c_list){ + if(waitqueue_active(&p->c_max_bw_over_waitq)) + wake_up_all(&p->c_max_bw_over_waitq); + } + return 0; +} + +/* + * Use tokens(Increase the number of consumed token) to issue an I/O for guranteeing the range-bw. + * and check the expiration of local and global time slice, and overflow of max bw + */ +static int range_bw_consume_token(struct ioband_group *gp, int count, int = flag) +{ + struct ioband_device *dp =3D gp->c_banddev; + struct ioband_group *p; + unsigned long now =3D jiffies; + int io_mode; + + dp->g_current =3D gp; + + if(dp->g_next_time_period =3D=3D 0){ + dp->g_next_time_period =3D now + HZ; + dp->g_time_period_expired =3D TIME_SLICE_NOT_EXPIRED; + } + + if(time_after(now, dp->g_next_time_period)){ + reset_range_bw_token(gp, now); + }else{ + gp->c_consumed_min_bw_token +=3D count; + dp->g_consumed_min_bw_token +=3D count; + + if(gp->c_max_bw > 0 && gp->c_consumed_min_bw_token >=3D gp->c_max_bw_token){ + gp->c_is_over_max_bw =3D MAX_BW_OVER; + gp->c_io_mode =3D NO_IO_MODE; + return R_YIELD; + } + + if(gp->c_io_mode !=3D RANGE_IO_MODE && gp->c_min_bw_token <=3D gp->c_consumed_min_bw_token){ + gp->c_io_mode =3D RANGE_IO_MODE; + + if(dp->g_total_min_bw_token <=3D dp->g_consumed_min_bw_token){ + list_for_each_entry(p, &dp->g_groups, c_li= st){ + if(p->c_io_mode =3D=3D RANGE_IO_MODE || p->c_io_mode =3D=3D DEFAULT_IO_MODE){ + io_mode =3D 1; + }else{ + io_mode =3D 0; + break; + } + } + + if(io_mode && dp->g_io_mode =3D=3D MINBW_I= O_MODE) + dp->g_io_mode =3D LEFTOVER_IO_MODE= ; + } + } + } + + if(gp->c_time_slice_end !=3D 0 && time_after(now, gp->c_time_slice= _end)){ + gp->c_time_slice_expired =3D TIME_SLICE_EXPIRED; + return R_YIELD; + } + + return R_OK; +} + +/* + * Check if this group is able to receive a new bio. + * in range bw policy, we only check that ioband device should be blocked + */ +static int range_bw_queue_full(struct ioband_group *gp) +{ +=09 + return (gp->c_blocked >=3D gp->c_limit); +} + +/* + * Convert the bw valuse to the number of bw token + * bw : Kbyte unit bandwidth + * token_base : the number of tokens used for one 1Kbyte-size IO + * -- Attention : Currently, We support the 512byte or 1Kbyte per 1 token + */ +static int convert_bw_to_token(int bw, int token_unit) +{ + int token; + int token_base; + + token_base =3D (1 << token_unit) / 4; // token_base is 1 or 2 + token =3D bw * token_base; +=09 + return token; +} + + +/* + * Allocate the time slice for MINBW_IO_MODE to each group + */ +static void range_bw_time_slice_init(struct ioband_group * gp) +{ + struct ioband_device * dp =3D gp->c_banddev; + struct ioband_group * p; + + list_for_each_entry(p, &dp->g_groups, c_list){ + if(p->c_min_bw =3D=3D 0) + p->c_time_slice =3D time_slice_base; + else + p->c_time_slice =3D time_slice_base + ((time_slice_base * p->c_min_bw) / dp->g_min_bw_total); + } +} + + +/* + * Allocate the min_bw and min_bw_token to the given group + */ +static void set_min_bw(struct ioband_group *gp, int new) +{ + struct ioband_device *dp =3D gp->c_banddev; + struct ioband_group * p; + int token_unit; + + dp->g_min_bw_total +=3D (new - gp->c_min_bw); + gp->c_min_bw =3D new; + + if(new) + gp->c_io_mode =3D MINBW_IO_MODE; + else + gp->c_io_mode =3D DEFAULT_IO_MODE; +=09 + range_bw_time_slice_init(gp); + + token_unit =3D dp->g_token_unit; + gp->c_min_bw_token =3D convert_bw_to_token(gp->c_min_bw, token_unit); + dp->g_total_min_bw_token =3D convert_bw_to_token(dp->g_min_bw_total, token_unit); + + if (dp->g_min_bw_total =3D=3D 0) { + list_for_each_entry(p, &dp->g_groups, c_list) + p->c_limit =3D 1; + } else { + list_for_each_entry(p, &dp->g_groups, c_list) { + p->c_limit =3D (dp->g_io_limit[0] + dp->g_io_limit= [1]) * + p->c_min_bw / dp->g_min_bw_total / + OVER_IO_RATE + 1; + } + } + + return; +} + +/* + * Allocate the max_bw and max_bw_token to the pointed group + */ +static void set_max_bw(struct ioband_group *gp, int new) +{ + struct ioband_device *dp =3D gp->c_banddev; + int token_unit;=09 + + token_unit =3D dp->g_token_unit; + + gp->c_max_bw =3D new; + gp->c_max_bw_token =3D convert_bw_to_token(new, token_unit); + + return; + +} + +static void init_range_bw_token_bucket(struct ioband_device *dp, int val) +{ + dp->g_token_bucket =3D ((dp->g_io_limit[0] + dp->g_io_limit[1]) * + DEFAULT_BUCKET) << dp->g_token_unit; + if (!val) + val =3D DEFAULT_TOKENPOOL << dp->g_token_unit; + if (val < dp->g_token_bucket) + val =3D dp->g_token_bucket; + dp->g_carryover =3D val/dp->g_token_bucket; + dp->g_token_left =3D 0; +} + +static int policy_range_bw_param(struct ioband_group *gp, char *cmd, char *value) +{ + long val; + int r =3D 0, err; + + err =3D strict_strtol(value, 0, &val); + + if (!strcmp(cmd, "min-bw")) { + if (!err && 0 <=3D val && val <=3D (INT_MAX / 2)) + set_min_bw(gp, val); + else + r =3D -EINVAL; + } else if (!strcmp(cmd, "max-bw")) { + if ((!err && 0 <=3D val && val <=3D (INT_MAX / 2) && gp->c_min_bw <=3D val) || val =3D=3D 0) + set_max_bw(gp, val); + else + r =3D -EINVAL; + } else { + r =3D -EINVAL; + } + + return r; +} + +static int policy_range_bw_ctr(struct ioband_group *gp, char *arg) +{ + int ret; + + if (!arg) + arg =3D __stringify(DEFAULT_MIN_BW); + + init_waitqueue_head(&gp->c_max_bw_over_waitq); + spin_lock_init(&gp->c_lock);=09 + + gp->c_min_bw =3D 0; + gp->c_max_bw =3D 0; + gp->c_io_mode =3D DEFAULT_IO_MODE; + gp->c_time_slice_expired =3D TIME_SLICE_NOT_EXPIRED; + gp->c_min_bw_token =3D 0; + gp->c_max_bw_token =3D 0; + gp->c_consumed_min_bw_token =3D 0; + gp->c_is_over_max_bw =3D MAX_BW_UNDER; + gp->c_time_slice_start =3D 0; + gp->c_time_slice_end =3D 0; + gp->c_wait_p_count =3D 0;// + + gp->c_time_slice =3D time_slice_base; + + gp->c_timer =3D kmalloc(sizeof(struct timer_list), GFP_KERNEL); + if(gp->c_timer =3D=3D NULL) return -EINVAL; // return value may be not appropriate !!! + memset(gp->c_timer, 0, sizeof(struct timer_list)); + gp->timer_set =3D 0; +=09 + ret =3D policy_range_bw_param(gp, "min-bw", arg); + + return ret; +} + +static void policy_range_bw_dtr(struct ioband_group *gp) +{ + struct ioband_device *dp =3D gp->c_banddev; + + set_min_bw(gp, 0); + gp->c_time_slice =3D 0; + set_max_bw(gp, 0); + + dp->g_running_gp =3D NULL; + + if(gp->c_timer !=3D NULL){ + del_timer(gp->c_timer); + kfree(gp->c_timer); + } +} + +static void policy_range_bw_show(struct ioband_group *gp, int *szp, + char *result, unsigned int maxlen) +{ + struct ioband_group *p; + struct ioband_device *dp =3D gp->c_banddev; + struct rb_node *node; + int sz =3D *szp; /* used in DMEMIT() */ + + DMEMIT(" %d :%d", dp->g_token_bucket * dp->g_carryover, gp->c_min_bw); + + for (node =3D rb_first(&gp->c_group_root); node; node =3D rb_next(node)) = { + p =3D rb_entry(node, struct ioband_group, c_group_node); + DMEMIT(" %d:%d:%d", p->c_id, p->c_min_bw, p->c_max_bw); + } + *szp =3D sz; +} + +static int range_bw_prepare_token(struct ioband_group *gp, struct bio *bio, int flag) +{ + struct ioband_device *dp =3D gp->c_banddev; + int unit; + int bio_count; + int token_count =3D 0; + + unit =3D (1 << dp->g_token_unit); + bio_count =3D bio_sectors(bio); + + if(unit =3D=3D 8) // 1 token is used for 512 bytes + token_count =3D bio_count; + else if(unit =3D=3D 4) // 1 token is used for 1024 bytes + token_count =3D bio_count / 2; + else if(unit =3D=3D 2) // 1 token is used for 2048 bytes + token_count =3D bio_count / 4; + else if(unit =3D=3D 1) // 1 token is used for 4096 bytes + token_count =3D bio_count / 8; + + return range_bw_consume_token(gp, token_count, flag); +} + +void range_bw_timer_register(struct timer_list * ptimer, unsigned long timeover, unsigned long gp) +{ + struct ioband_group * group =3D (struct ioband_group *)gp; + + if(group->timer_set =3D=3D 0){ + init_timer(ptimer); + ptimer->expires =3D get_jiffies_64() + timeover; + ptimer->data =3D gp; + ptimer->function =3D range_bw_timeover; + add_timer(ptimer); + group->timer_set =3D 1; + } +} + +/* + * Timer Handler function to protect the all processes's hanging in lower min-bw configuration + */ +void range_bw_timeover(unsigned long gp) +{ + struct ioband_group * group =3D (struct ioband_group *)gp; + + if(group->c_is_over_max_bw =3D=3D MAX_BW_OVER){ + group->c_is_over_max_bw =3D MAX_BW_UNDER; + } + + if(group->c_io_mode =3D=3D NO_IO_MODE){ + group->c_io_mode =3D MINBW_IO_MODE; + } + + if(waitqueue_active(&group->c_max_bw_over_waitq)) + wake_up_all(&group->c_max_bw_over_waitq); +=09 + group->timer_set =3D 0; +} + +/* + * + * g_can_submit : To determine whether a given group has the right to + * submit BIOs. The larger the return value the higher th= e + * priority to submit. Zero means it has no right. + * g_prepare_bio : Called right before submitting each BIO. + * g_restart_bios : Called if this ioband device has some BIOs blocked but= none + * of them can be submitted now. This method has to + * reinitialize the data to restart to submit BIOs and re= turn + * 0 or 1. + * The return value 0 means that it has become able to su= bmit + * them now so that this ioband device will continue its = work. + * The return value 1 means that it is still unable to su= bmit + * them so that this device will stop its work. And this + * policy module has to reactivate the device when it get= s + * to be able to submit BIOs. + * g_hold_bio : To hold a given BIO until it is submitted. + * The default function is used when this method is undef= ined. + * g_pop_bio : To select and get the best BIO to submit. + * g_group_ctr : To initalize the policy own members of struct ioband_g= roup. + * g_group_dtr : Called when struct ioband_group is removed. + * g_set_param : To update the policy own date. + * The parameters can be passed through "dmsetup message" + * command. + * g_should_block : Called every time this ioband device receive a BIO. + * Return 1 if a given group can't receive any more BIOs, + * otherwise return 0. + * g_show : Show the configuration. + */ + +int policy_range_bw_init(struct ioband_device *dp, + int argc, char **argv) +{ + long val; + int r =3D 0; + + if (argc < 1) + val =3D 0; + else { + r =3D strict_strtol(argv[0], 0, &val); + if (r || val < 0) + return -EINVAL; + } +=09 + dp->g_can_submit =3D has_right_to_issue; + dp->g_prepare_bio =3D range_bw_prepare_token; + dp->g_restart_bios =3D range_bw_restart_bios; + dp->g_group_ctr =3D policy_range_bw_ctr; + dp->g_group_dtr =3D policy_range_bw_dtr; + dp->g_set_param =3D policy_range_bw_param; + dp->g_should_block =3D range_bw_queue_full; + dp->g_show =3D policy_range_bw_show; + + dp->g_min_bw_total =3D 0; + dp->g_running_gp =3D NULL; + dp->g_total_min_bw_token =3D 0; + dp->g_io_mode =3D MINBW_IO_MODE; + dp->g_consumed_min_bw_token =3D 0; + dp->g_current =3D NULL; + dp->g_next_time_period =3D 0; + dp->g_time_period_expired =3D TIME_SLICE_NOT_EXPIRED; + + dp->g_token_unit =3D PAGE_SHIFT - 9; + init_range_bw_token_bucket(dp, val); + + return 0; +} diff -urN linux-2.6.30-rc1-orig/drivers/md/Makefile linux-2.6.30-rc1/drivers/md/Makefile --- linux-2.6.30-rc1-orig/drivers/md/Makefile 2009-04-20 18:16:00.000000000 +0900 +++ linux-2.6.30-rc1/drivers/md/Makefile 2009-04-20 16:42:47.000000000 +090= 0 @@ -8,7 +8,7 @@ dm-snapshot-y +=3D dm-snap.o dm-exception-store.o dm-snap-transient.o \ dm-snap-persistent.o dm-mirror-y +=3D dm-raid1.o -dm-ioband-y +=3D dm-ioband-ctl.o dm-ioband-policy.o dm-ioband-type.o +dm-ioband-y +=3D dm-ioband-ctl.o dm-ioband-policy.o dm-ioband-type.o dm-ioband-rangebw.o md-mod-y +=3D md.o bitmap.o raid456-y +=3D raid5.o raid6_pq-y +=3D raid6algos.o raid6recov.o raid6tables.o \ --=20 Best Regards, Dong-Jae Kang --001485f339387c95940468353f22 Content-Type: application/octet-stream; name="dm-ioband-rangebw-1.10.3.patch" Content-Disposition: attachment; filename="dm-ioband-rangebw-1.10.3.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_ftv8ezeo0 ZGlmZiAtdXJOIGxpbnV4LTIuNi4zMC1yYzEtb3JpZy9kcml2ZXJzL21kL2RtLWlvYmFuZC1jdGwu YyBsaW51eC0yLjYuMzAtcmMxL2RyaXZlcnMvbWQvZG0taW9iYW5kLWN0bC5jCi0tLSBsaW51eC0y LjYuMzAtcmMxLW9yaWcvZHJpdmVycy9tZC9kbS1pb2JhbmQtY3RsLmMJMjAwOS0wNC0yMCAxODox NjowMC4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gICAgIG5vdyA9IGppZmZpZXM7 CisgICAgICAgICAgICAgICAgaWYodGltZV9hZnRlcihkcC0+Z19uZXh0X3RpbWVfcGVyaW9kLCBu b3cpKXsKKyAgICAgICAgICAgICAgICAgICAgICAgIHRpbWVfc3RlcCA9IGRwLT5nX25leHRfdGlt ZV9wZXJpb2QgLSBub3c7CisgICAgICAgICAgICAgICAgICAgICAgICByYW5nZV9id190aW1lcl9y ZWdpc3RlcihncC0+Y190aW1lciwgKHRpbWVfc3RlcCArIFRJTUVfQ09NUEVOU0FUT1IpLCAodW5z aWduZWQgbG9uZylncCk7CisgICAgICAgICAgICAgICAgICAgICAgICB3YWl0X2V2ZW50X2xvY2tf aXJxKGdwLT5jX21heF9id19vdmVyX3dhaXRxLCAhaXNfbm9faW9fbW9kZShncCksIGRwLT5nX2xv Y2ssIGRvX25vdGhpbmcoKSk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICB9CisKIAkvKgog CSAqIFRoZSBkZXZpY2UgaXMgc3VzcGVuZGVkIHdoaWxlIHNvbWUgb2YgdGhlIGlvYmFuZCBkZXZp Y2UKIAkgKiBjb25maWd1cmF0aW9ucyBhcmUgYmVpbmcgY2hhbmdlZC4KQEAgLTgxMSw3ICs4Mzcs NiBAQAogCQkJCSAgICAhaXNfZGV2aWNlX3N1c3BlbmRlZChkcCksIGRwLT5nX2xvY2ssCiAJCQkJ ICAgIGRvX25vdGhpbmcoKSk7CiAKLQlncCA9IGlvYmFuZF9ncm91cF9nZXQoZ3AsIGJpbyk7CiAJ cHJldmVudF9idXJzdF9iaW9zKGdwLCBiaW8pOwogCWlmIChzaG91bGRfcHVzaGJhY2tfYmlvKGdw KSkgewogCQlzcGluX3VubG9ja19pcnFyZXN0b3JlKCZkcC0+Z19sb2NrLCBmbGFncyk7CmRpZmYg LXVyTiBsaW51eC0yLjYuMzAtcmMxLW9yaWcvZHJpdmVycy9tZC9kbS1pb2JhbmQuaCBsaW51eC0y LjYuMzAtcmMxL2RyaXZlcnM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vbGljeSAqLworICAgICAgICBpbnQgICAgIGdf bWluX2J3X3RvdGFsOworICAgICAgICB1bnNpZ25lZCBsb25nICAgZ19uZXh0X3RpbWVfcGVyaW9k OworICAgICAgICBpbnQgICAgIGdfdGltZV9wZXJpb2RfZXhwaXJlZDsKKyAgICAgICAgc3RydWN0 IGlvYmFuZF9ncm91cCAqIGdfcnVubmluZ19ncDsKKyAgICAgICAgaW50ICAgICBnX3RvdGFsX21p bl9id190b2tlbjsKKyAgICAgICAgaW50ICAgICBnX2NvbnN1bWVkX21pbl9id190b2tlbjsKKyAg ICAgICAgaW50ICAgICBnX2lvX21vZGU7CisKIH07CiAKIHN0cnVjdCBpb2JhbmRfZ3JvdXBfc3Rh dCB7CkBAIC0xMTAsOCArMTMwLDMxIEBACiAKIAkvKiByZnUgKi8KIAkvKiBzdHJ1Y3QgYmlvX2xp c3QJY19vcmRlcmVkX3RhZ19iaW9zOyAqLworCisgICAgICAgIC8qIG1lbWJlcnMgZm9yIHJhbmdl LWJ3IHBvbGljeSAqLworICAgICAgICB3YWl0X3F1ZXVlX2hlYWRfdCAgICAgICBjX21heF9id19v dmVyX3dhaXRxOworICAgICAgICBzcGlubG9ja190ICAgICAgY19sb2NrOworICAgICAgICBzdHJ1 Y3QgdGltZXJfbGlzdCAqIGNfdGltZXI7CisgICAgICAgIGludCAgICAgdGltZXJfc2V0OworICAg ICAgICBpbnQgICAgIGNfbWluX2J3OworICAgICAgICBpbnQgICAgIGNfbWF4X2J3OworICAgICAg ICBpbnQgICAgIGNfdGltZV9zbGljZV9leHBpcmVkOworICAgICAgICBpbnQgICAgIGNfbWluX2J3 X3Rva2VuOworICAgICAgICBpbnQgICAgIGNfbWF4X2J3X3Rva2VuOworICAgICAgICBpbnQgICAg IGNfY29uc3VtZWRfbWluX2J3X3Rva2VuOworICAgICAgICBpbnQgICAgIGNfaXNfb3Zlcl9tYXhf Ync7CisgICAgICAgIGludCAgICAgY19pb19tb2RlOworICAgICAgICB1bnNpZ25lZC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ZTsKKworICAgICAgICBncC0+Y190aW1lX3NsaWNlX3N0YXJ0ID0gbm93OworCisgICAgICAg IGlmKGRwX2lvX21vZGUgPT0gTEVGVE9WRVJfSU9fTU9ERSl7CisgICAgICAgICAgICAgICAgZ3At PmNfdGltZV9zbGljZV9lbmQgPSBub3cgKyBsZWZ0b3Zlcl90aW1lX3NsaWNlX2Jhc2U7CisgICAg ICAgICAgICAgICAgcmV0dXJuIDA7CisgICAgICAgIH0KKworICAgICAgICBpZihncF9pb19tb2Rl ID09IE1JTkJXX0lPX01PREUpCisgICAgICAgICAgICAgICAgZ3AtPmNfdGltZV9zbGljZV9lbmQg PSBub3cgKyBncC0+Y190aW1lX3NsaWNlOworICAgICAgICBlbHNlIGlmKGdwX2lvX21vZGUgPT0g UkFOR0VfSU9fTU9ERSkKKyAgICAgICAgICAgICAgICBncC0+Y190aW1lX3NsaWNlX2VuZCA9IG5v dyArIHJhbmdlX3RpbWVfc2xpY2VfYmFzZTsKKyAgICAgICAgZWxzZSAvLyBncF9pb19tb2RlID09 IERFRkFVTFRfSU9fTU9ERQorICAgICAgICAgICAgICAgIGdwLT5jX3RpbWVfc2xpY2VfZW5kID0g bm93ICsgdGltZV9zbGljZV9iYXNlOworCisgICAgICAgIGdwLT5jX3RpbWVfc2xpY2VfZXhwaXJl ZCA9IFRJTUVfU0xJQ0VfTk9UX0VYUElSRUQ7CisKKyAgICAgICAgcmV0dXJuIDA7Cit9CisKKy8q CisgKiBDYWxjdWxhdGUgdGhlIHByaW9yaXR5IG9mIGdpdmVuIGlvYmFuZF9ncm91cCAKKyAqLwor c3RhdGljIGludCByYW5nZV9id19wcmlvcml0eShzdHJ1Y3QgaW9iYW5kX2dyb3VwICogZ3ApCit7 CisJc3RydWN0IGlvYmFuZF9kZXZpY2UgKmRwID0gZ3AtPmNfYmFuZGRldjsKKwlpbnQgcHJpbyA9 IDA7CisKKwlpZihkcC0+Z19pb19tb2RlID09IExFRlRPVkVSX0lPX01PREUpeworCQlwcmlv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sKKwl9CisKKwlpZihncCA9PSBkcC0+Z19ydW5uaW5nX2dwKXsKKwor CQlpZihncC0+Y190aW1lX3NsaWNlX2V4cGlyZWQgPT0gVElNRV9TTElDRV9FWFBJUkVEKXsKKwor CQkJZ3AtPmNfdGltZV9zbGljZV9leHBpcmVkID0gVElNRV9TTElDRV9OT1RfRVhQSVJFRDsKKwkJ CWdwLT5jX3RpbWVfc2xpY2VfZW5kID0gMDsKKworCQkJcmV0dXJuIDA7CisJCX0KKyAKKwkJaWYo Z3AtPmNfdGltZV9zbGljZV9lbmQgPT0gMCkKKwkJCXNldF90aW1lX3NsaWNlKGdwKTsKKworCQly ZXR1cm4gcmFuZ2VfYndfcHJpb3JpdHkoZ3ApOworCisJfQorCisJZHAtPmdfcnVubmluZ19ncCA9 IGdwOworCXNldF90aW1lX3NsaWNlKGdwKTsKKworCXJldHVybiByYW5nZV9id19wcmlvcml0eShn cCk7Cit9CisKKy8qCisgKiBSZXNldCBhbGwgdmFyaWFibGVzIHJlbGF0ZWQgd2l0aCByYW5nZS1i dyB0b2tlbiBhbmQgdGltZSBzbGljZSAKKyAqLworc3RhdGljIGludCByZXNldF9yYW5nZV9id190 b2tlbihzdHJ1Y3QgaW9iYW5kX2dyb3VwICogZ3AsIHVuc2lnbmVkIGxvbmcgbm93KQoreworICAg ICAgICBzdHJ1Y3QgaW9iYW5kX2RldmljZSAqZHAgPSBncC0+Y19iYW5kZGV2OworICAgICAgICBz dHJ1Y3QgaW9iYW5kX2dyb3VwICpwOworCisgICAgICAgIGxpc3RfZm9yX2VhY2hfZW50cnkocCwg JmRwLT5nX2dyb3VwcywgY19saXN0KXsKKyAgICAgICAgICAgICAgICBwLT5jX2NvbnN1bWVkX21p bl9id190b2tlbiA9IDA7CisgICAgICAgICAgICAgICAgcC0+Y19pc19vdmVyX21heF9idyA9IE1B WF9CV19VTkRFUjsKKwkJaWYocC0+Y19pb19tb2RlICE9IERFRkFVTFRfSU9fTU9ERSkKKwkJCXAt PmNfaW9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AgIGludCBpb19tb2RlOworCisg ICAgICAgIGRwLT5nX2N1cnJlbnQgPSBncDsKKworICAgICAgICBpZihkcC0+Z19uZXh0X3RpbWVf cGVyaW9kID09IDApeworICAgICAgICAgICAgICAgIGRwLT5nX25leHRfdGltZV9wZXJpb2QgPSBu b3cgKyBIWjsKKyAgICAgICAgICAgICAgICBkcC0+Z190aW1lX3BlcmlvZF9leHBpcmVkID0gVElN RV9TTElDRV9OT1RfRVhQSVJFRDsKKyAgICAgICAgfQorIAorICAgICAgICBpZih0aW1lX2FmdGVy KG5vdywgZHAtPmdfbmV4dF90aW1lX3BlcmlvZCkpeworICAgICAgICAgICAgICAgIHJlc2V0X3Jh bmdlX2J3X3Rva2VuKGdwLCBub3cpOworICAgICAgICB9ZWxzZXsKKyAgICAgICAgICAgICAgICBn cC0+Y19jb25zdW1lZF9taW5fYndfdG9rZW4gKz0gY291bnQ7CisgICAgICAgICAgICAgICAgZHAt PmdfY29uc3VtZWRfbWluX2J3X3Rva2VuICs9IGNvdW50OworCisgICAgICAgICAgICAgICAgaWYo Z3AtPmNfbWF4X2J3ID4gMCAmJiBncC0+Y19jb25zdW1lZF9taW5fYndfdG9rZW4gPj0gZ3AtPmNf bWF4X2J3X3Rva2VuKXsKKyAgICAgICAgICAgICAgICAgICAgICAgIGdwLT5jX2lzX292ZXJfbWF4 X2J3ID0gTUFYX0JXX09WRVI7CisJCQlncC0+Y19pb19tb2RlID0gTk9fSU9fTU9ERTsKKwkJCXJl dHVybiBSX1lJRUxEOworICAgICAgICAgICAgICAgIH0KKworICAgICAgICAgICAgICAgIGlmKGdw LT5jX2lvX21vZGUgIT0gUkFOR0VfSU9fTU9ERSAmJiBncC0+Y19taW5fYndfdG9rZW4gPD0gZ3At PmNfY29uc3VtZWRfbWluX2J3X3Rva2VuKXsKKyAgICAgICAgICAgICAgICAgICAgICAgIGdwLT5j X2lvX21vZGUgPSBSQU5HRV9JT19NT0RFOworCisgICAgICAgICAgICAgICAgICAgICAgICBpZihk cC0+Z190b3RhbF9taW5fYndfdG9rZW4gPD0gZHAtPmdfY29uc3VtZWRfbWluX2J3X3Rva2VuKXsK KyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGlzdF9mb3JfZWFjaF9lbnRyeShwLCAm ZHAtPmdfZ3JvdXBzLCBjX2xpc3QpeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgIGlmKHAtPmNfaW9fbW9kZSA9PSBSQU5HRV9JT19NT0RFIHx8IHAtPmNfaW9fbW9kZSA9 PSBERUZBVUxUX0lPX01PREUpeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgaW9fbW9kZSA9IDE7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgfWVsc2V7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICBpb19tb2RlID0gMDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQorCisgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgIGlmKGlvX21vZGUgJiYgZHAtPmdfaW9fbW9kZSA9PSBNSU5CV19J T19NT0RFKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRwLT5nX2lv X21vZGUgPSBMRUZUT1ZFUl9JT19NT0RFOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAg ICAgICAgICAgICAgIH0KKyAgICAgICAgfQorCisgICAgICAgIGlmKGdwLT5jX3RpbWVfc2xpY2Vf ZW5kICE9IDAgJiYgdGltZV9hZnRlcihub3csIGdwLT5jX3RpbWVfc2xpY2VfZW5kKSl7CisgICAg ICAgICAgICAgICAgZ3AtPmNfdGltZV9zbGljZV9leHBpcmVkID0gVElNRV9TTElDRV9FWFBJUkVE OworCQlyZXR1cm4gUl9ZSUVMRDsKKyAgICAgICAgfQorCisgICAgICAgIHJldHVybiBSX09LOwor fQorCisvKgorICogQ2hlY2sgaWYgdGhpcyBncm91cCBpcyBhYmxlIHRvIHJlY2VpdmUgYSBuZXcg YmlvLgorICogaW4gcmFuZ2UgYncgcG9saWN5LCB3ZSBvbmx5IGNoZWNrIHRoYXQgaW9iYW5kIGRl dmljZSBzaG91bGQgYmUgYmxvY2tlZAorICovCitzdGF0aWMgaW50IHJhbmdlX2J3X3F1ZXVlX2Z1 bGwoc3RydWN0IGlvYmFuZF9ncm91cCAqZ3ApCit7CisJCisJcmV0dXJuIChncC0+Y19ibG9ja2Vk ID49IGdwLT5jX2xpbWl0KTsKK30KKworLyoKKyAqIENvbnZlcnQgdGhlIGJ3IHZhbHVzZSB0byB0 aGUgbnVtYmVyIG9mIGJ3IHRva2VuCisgKiBidyA6IEtieXRlIHVuaXQgYmFuZHdpZHRoCisgKiB0 b2tlbl9iYXNlIDogdGhlIG51bWJlciBvZiB0b2tlbnMgdXNlZCBmb3Igb25lIDFLYnl0ZS1zaXpl IElPCisgKiAtLSBBdHRlbnRpb24gOiBDdXJyZW50bHksIFdlIHN1cHBvcnQgdGhlIDUxMmJ5dGUg b3IgMUtieXRlIHBlciAxIHRva2VuCisgKi8KK3N0YXRpYyBpbnQgY29udmVydF9id190b190b2tl bihpbnQgYncsIGludCB0b2tlbl91bml0KQoreworCWludAl0b2tlbjsKKwlpbnQJdG9rZW5fYmFz ZTsgCisKKwl0b2tlbl9iYXNlID0gKDEgPDwgdG9rZW5fdW5pdCkgLyA0OyAvLyB0b2tlbl9iYXNl IGlzIDEgb3IgMgorCXRva2VuID0gYncgKiB0b2tlbl9iYXNlOworCQorCXJldHVybiB0b2tlbjsK K30KKworCisvKgorICogQWxsb2NhdGUgdGhlIHRpbWUgc2xpY2UgZm9yIE1JTkJXX0lPX01PREUg dG8gZWFjaCBncm91cCAKKyAqLworc3RhdGljI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ap OworCisJdG9rZW5fdW5pdCA9IGRwLT5nX3Rva2VuX3VuaXQ7CisJZ3AtPmNfbWluX2J3X3Rva2Vu ID0gY29udmVydF9id190b190b2tlbihncC0+Y19taW5fYncsIHRva2VuX3VuaXQpOworCWRwLT5n X3RvdGFsX21pbl9id190b2tlbiA9IGNvbnZlcnRfYndfdG9fdG9rZW4oZHAtPmdfbWluX2J3X3Rv dGFsLCB0b2tlbl91bml0KTsKKworICAgICAgICBpZiAoZHAtPmdfbWluX2J3X3RvdGFsID09IDAp IHsKKyAgICAgICAgICAgICAgICBsaXN0X2Zvcl9lYWNoX2VudHJ5KHAsICZkcC0+Z19ncm91cHMs IGNfbGlzdCkKKyAgICAgICAgICAgICAgICAgICAgICAgIHAtPmNfbGltaXQgPSAxOworICAgICAg ICB9IGVsc2UgeworICAgICAgICAgICAgICAgIGxpc3RfZm9yX2VhY2hfZW50cnkocCwgJmRwLT5n X2dyb3VwcywgY19saXN0KSB7CisgICAgICAgICAgICAgICAgICAgICAgICBwLT5jX2xpbWl0ID0g KGRwLT5nX2lvX2xpbWl0WzBdICsgZHAtPmdfaW9fbGltaXRbMV0pICoKKyAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgcC0+Y19taW5fYncgLyBkcC0+Z19taW5fYndfdG90YWwgLworICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICBPVkVSX0lPX1JBVEUgKyAxOworICAgICAgICAg ICAgICAgIH0KKyAgICAgICAgfQorCisJcmV0dXJuOworfQorCisvKgorICogQWxsb2NhdGUgdGhl IG1heF9idyBhbmQgbWF4X2J3X3Rva2VuIHRvIHRoZSBwb2ludGVkIGdyb3VwCisgKi8KK3N0YXRp YyB2b2lkIHNldF9tYXhfYncoc3RydWN0IGlvYmFuZF9ncm91cCAqZ3AsIGludCBuZXcpCit7CisJ c3RydWN0IGlvYmFuZF9kZXZpY2UgKmRwID0gZ3AtPmNfYmFuZGRldjsKKwlpbnQJdG9rZW5fdW5p dDsJCisKKwl0b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wLXBlcnNp c3RlbnQubwogZG0tbWlycm9yLXkJKz0gZG0tcmFpZDEubwotZG0taW9iYW5kLXkJKz0gZG0taW9i YW5kLWN0bC5vIGRtLWlvYmFuZC1wb2xpY3kubyBkbS1pb2JhbmQtdHlwZS5vCitkbS1pb2JhbmQt eQkrPSBkbS1pb2JhbmQtY3RsLm8gZG0taW9iYW5kLXBvbGljeS5vIGRtLWlvYmFuZC10eXBlLm8g ZG0taW9iYW5kLXJhbmdlYncubwogbWQtbW9kLXkJKz0gbWQubyBiaXRtYXAubwogcmFpZDQ1Ni15 CSs9IHJhaWQ1Lm8KIHJhaWQ2X3BxLXkJKz0gcmFpZDZhbGdvcy5vIHJhaWQ2cmVjb3YubyByYWlk NnRhYmxlcy5vIFwK --001485f339387c95940468353f22-- -- 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/