diff options
author | Milan Broz <mbroz@redhat.com> | 2006-10-03 04:15:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-03 11:04:15 -0400 |
commit | 8757b7764f13e336f3c0eb1f634440d4ee4c3a67 (patch) | |
tree | c91b00ace6ee438a9e447bce311808a698e9d487 | |
parent | cc1092019ce3d9b3e85a285b41e852ff94a6b590 (diff) |
[PATCH] dm table: add target preresume
This patch adds a target preresume hook.
It is called before the targets are resumed and if it returns an error the
resume gets cancelled.
The crypt target will use this to indicate that it is unable to process I/O
because no encryption key has been supplied.
Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | drivers/md/dm-table.c | 17 | ||||
-rw-r--r-- | drivers/md/dm.c | 4 | ||||
-rw-r--r-- | drivers/md/dm.h | 2 | ||||
-rw-r--r-- | include/linux/device-mapper.h | 2 | ||||
-rw-r--r-- | include/linux/dm-ioctl.h | 4 |
5 files changed, 23 insertions, 6 deletions
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 75fe9493e6af..47412ae98fb9 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c | |||
@@ -939,9 +939,20 @@ void dm_table_postsuspend_targets(struct dm_table *t) | |||
939 | return suspend_targets(t, 1); | 939 | return suspend_targets(t, 1); |
940 | } | 940 | } |
941 | 941 | ||
942 | void dm_table_resume_targets(struct dm_table *t) | 942 | int dm_table_resume_targets(struct dm_table *t) |
943 | { | 943 | { |
944 | int i; | 944 | int i, r = 0; |
945 | |||
946 | for (i = 0; i < t->num_targets; i++) { | ||
947 | struct dm_target *ti = t->targets + i; | ||
948 | |||
949 | if (!ti->type->preresume) | ||
950 | continue; | ||
951 | |||
952 | r = ti->type->preresume(ti); | ||
953 | if (r) | ||
954 | return r; | ||
955 | } | ||
945 | 956 | ||
946 | for (i = 0; i < t->num_targets; i++) { | 957 | for (i = 0; i < t->num_targets; i++) { |
947 | struct dm_target *ti = t->targets + i; | 958 | struct dm_target *ti = t->targets + i; |
@@ -949,6 +960,8 @@ void dm_table_resume_targets(struct dm_table *t) | |||
949 | if (ti->type->resume) | 960 | if (ti->type->resume) |
950 | ti->type->resume(ti); | 961 | ti->type->resume(ti); |
951 | } | 962 | } |
963 | |||
964 | return 0; | ||
952 | } | 965 | } |
953 | 966 | ||
954 | int dm_table_any_congested(struct dm_table *t, int bdi_bits) | 967 | int dm_table_any_congested(struct dm_table *t, int bdi_bits) |
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 883860c3565b..aeb63a3ac330 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c | |||
@@ -1360,7 +1360,9 @@ int dm_resume(struct mapped_device *md) | |||
1360 | if (!map || !dm_table_get_size(map)) | 1360 | if (!map || !dm_table_get_size(map)) |
1361 | goto out; | 1361 | goto out; |
1362 | 1362 | ||
1363 | dm_table_resume_targets(map); | 1363 | r = dm_table_resume_targets(map); |
1364 | if (r) | ||
1365 | goto out; | ||
1364 | 1366 | ||
1365 | down_write(&md->io_lock); | 1367 | down_write(&md->io_lock); |
1366 | clear_bit(DMF_BLOCK_IO, &md->flags); | 1368 | clear_bit(DMF_BLOCK_IO, &md->flags); |
diff --git a/drivers/md/dm.h b/drivers/md/dm.h index fe701c4834fe..a48ec5e3c1f4 100644 --- a/drivers/md/dm.h +++ b/drivers/md/dm.h | |||
@@ -57,7 +57,7 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q); | |||
57 | struct list_head *dm_table_get_devices(struct dm_table *t); | 57 | struct list_head *dm_table_get_devices(struct dm_table *t); |
58 | void dm_table_presuspend_targets(struct dm_table *t); | 58 | void dm_table_presuspend_targets(struct dm_table *t); |
59 | void dm_table_postsuspend_targets(struct dm_table *t); | 59 | void dm_table_postsuspend_targets(struct dm_table *t); |
60 | void dm_table_resume_targets(struct dm_table *t); | 60 | int dm_table_resume_targets(struct dm_table *t); |
61 | int dm_table_any_congested(struct dm_table *t, int bdi_bits); | 61 | int dm_table_any_congested(struct dm_table *t, int bdi_bits); |
62 | void dm_table_unplug_all(struct dm_table *t); | 62 | void dm_table_unplug_all(struct dm_table *t); |
63 | int dm_table_flush_all(struct dm_table *t); | 63 | int dm_table_flush_all(struct dm_table *t); |
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index d44a99650af3..8cbc46b8e3db 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h | |||
@@ -57,6 +57,7 @@ typedef int (*dm_endio_fn) (struct dm_target *ti, | |||
57 | 57 | ||
58 | typedef void (*dm_presuspend_fn) (struct dm_target *ti); | 58 | typedef void (*dm_presuspend_fn) (struct dm_target *ti); |
59 | typedef void (*dm_postsuspend_fn) (struct dm_target *ti); | 59 | typedef void (*dm_postsuspend_fn) (struct dm_target *ti); |
60 | typedef int (*dm_preresume_fn) (struct dm_target *ti); | ||
60 | typedef void (*dm_resume_fn) (struct dm_target *ti); | 61 | typedef void (*dm_resume_fn) (struct dm_target *ti); |
61 | 62 | ||
62 | typedef int (*dm_status_fn) (struct dm_target *ti, status_type_t status_type, | 63 | typedef int (*dm_status_fn) (struct dm_target *ti, status_type_t status_type, |
@@ -92,6 +93,7 @@ struct target_type { | |||
92 | dm_endio_fn end_io; | 93 | dm_endio_fn end_io; |
93 | dm_presuspend_fn presuspend; | 94 | dm_presuspend_fn presuspend; |
94 | dm_postsuspend_fn postsuspend; | 95 | dm_postsuspend_fn postsuspend; |
96 | dm_preresume_fn preresume; | ||
95 | dm_resume_fn resume; | 97 | dm_resume_fn resume; |
96 | dm_status_fn status; | 98 | dm_status_fn status; |
97 | dm_message_fn message; | 99 | dm_message_fn message; |
diff --git a/include/linux/dm-ioctl.h b/include/linux/dm-ioctl.h index b349b768df35..f28b5c87aa6b 100644 --- a/include/linux/dm-ioctl.h +++ b/include/linux/dm-ioctl.h | |||
@@ -285,9 +285,9 @@ typedef char ioctl_struct[308]; | |||
285 | #define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl) | 285 | #define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl) |
286 | 286 | ||
287 | #define DM_VERSION_MAJOR 4 | 287 | #define DM_VERSION_MAJOR 4 |
288 | #define DM_VERSION_MINOR 8 | 288 | #define DM_VERSION_MINOR 9 |
289 | #define DM_VERSION_PATCHLEVEL 0 | 289 | #define DM_VERSION_PATCHLEVEL 0 |
290 | #define DM_VERSION_EXTRA "-ioctl (2006-06-24)" | 290 | #define DM_VERSION_EXTRA "-ioctl (2006-09-14)" |
291 | 291 | ||
292 | /* Status bits */ | 292 | /* Status bits */ |
293 | #define DM_READONLY_FLAG (1 << 0) /* In/Out */ | 293 | #define DM_READONLY_FLAG (1 << 0) /* In/Out */ |