diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2013-03-01 17:45:49 -0500 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2013-03-01 17:45:49 -0500 |
commit | df5d2e9089c7d5b8c46f767e4278610ea3e815b9 (patch) | |
tree | 5285aa8b0c794da419133a209437b32a11aa8a8d /include | |
parent | a26062416ef8add48f16fbadded2b5f6fb84d024 (diff) |
dm kcopyd: introduce configurable throttling
This patch allows the administrator to reduce the rate at which kcopyd
issues I/O.
Each module that uses kcopyd acquires a throttle parameter that can be
set in /sys/module/*/parameters.
We maintain a history of kcopyd usage by each module in the variables
io_period and total_period in struct dm_kcopyd_throttle. The actual
kcopyd activity is calculated as a percentage of time equal to
"(100 * io_period / total_period)". This is compared with the user-defined
throttle percentage threshold and if it is exceeded, we sleep.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/dm-kcopyd.h | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/include/linux/dm-kcopyd.h b/include/linux/dm-kcopyd.h index 47d9d376e4e7..f486d636b82e 100644 --- a/include/linux/dm-kcopyd.h +++ b/include/linux/dm-kcopyd.h | |||
@@ -21,11 +21,34 @@ | |||
21 | 21 | ||
22 | #define DM_KCOPYD_IGNORE_ERROR 1 | 22 | #define DM_KCOPYD_IGNORE_ERROR 1 |
23 | 23 | ||
24 | struct dm_kcopyd_throttle { | ||
25 | unsigned throttle; | ||
26 | unsigned num_io_jobs; | ||
27 | unsigned io_period; | ||
28 | unsigned total_period; | ||
29 | unsigned last_jiffies; | ||
30 | }; | ||
31 | |||
32 | /* | ||
33 | * kcopyd clients that want to support throttling must pass an initialised | ||
34 | * dm_kcopyd_throttle struct into dm_kcopyd_client_create(). | ||
35 | * Two or more clients may share the same instance of this struct between | ||
36 | * them if they wish to be throttled as a group. | ||
37 | * | ||
38 | * This macro also creates a corresponding module parameter to configure | ||
39 | * the amount of throttling. | ||
40 | */ | ||
41 | #define DECLARE_DM_KCOPYD_THROTTLE_WITH_MODULE_PARM(name, description) \ | ||
42 | static struct dm_kcopyd_throttle dm_kcopyd_throttle = { 100, 0, 0, 0, 0 }; \ | ||
43 | module_param_named(name, dm_kcopyd_throttle.throttle, uint, 0644); \ | ||
44 | MODULE_PARM_DESC(name, description) | ||
45 | |||
24 | /* | 46 | /* |
25 | * To use kcopyd you must first create a dm_kcopyd_client object. | 47 | * To use kcopyd you must first create a dm_kcopyd_client object. |
48 | * throttle can be NULL if you don't want any throttling. | ||
26 | */ | 49 | */ |
27 | struct dm_kcopyd_client; | 50 | struct dm_kcopyd_client; |
28 | struct dm_kcopyd_client *dm_kcopyd_client_create(void); | 51 | struct dm_kcopyd_client *dm_kcopyd_client_create(struct dm_kcopyd_throttle *throttle); |
29 | void dm_kcopyd_client_destroy(struct dm_kcopyd_client *kc); | 52 | void dm_kcopyd_client_destroy(struct dm_kcopyd_client *kc); |
30 | 53 | ||
31 | /* | 54 | /* |