dm.c (9a1fb46448cac50e93115322ad28f417936f7852) | dm.c (53d5914f288b67ddc4d594d6a09568fe114bb909) |
---|---|
1/* 2 * Copyright (C) 2001, 2002 Sistina Software (UK) Limited. 3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. 4 * 5 * This file is released under the GPL. 6 */ 7 8#include "dm.h" --- 85 unchanged lines hidden (view full) --- 94#define DMF_FROZEN 2 95#define DMF_FREEING 3 96#define DMF_DELETING 4 97#define DMF_NOFLUSH_SUSPENDING 5 98 99/* 100 * Work processed by per-device workqueue. 101 */ | 1/* 2 * Copyright (C) 2001, 2002 Sistina Software (UK) Limited. 3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. 4 * 5 * This file is released under the GPL. 6 */ 7 8#include "dm.h" --- 85 unchanged lines hidden (view full) --- 94#define DMF_FROZEN 2 95#define DMF_FREEING 3 96#define DMF_DELETING 4 97#define DMF_NOFLUSH_SUSPENDING 5 98 99/* 100 * Work processed by per-device workqueue. 101 */ |
102struct dm_wq_req { 103 struct work_struct work; 104 struct mapped_device *md; 105}; 106 | |
107struct mapped_device { 108 struct rw_semaphore io_lock; 109 struct mutex suspend_lock; 110 spinlock_t pushback_lock; 111 rwlock_t map_lock; 112 atomic_t holders; 113 atomic_t open_count; 114 --- 5 unchanged lines hidden (view full) --- 120 121 void *interface_ptr; 122 123 /* 124 * A list of ios that arrived while we were suspended. 125 */ 126 atomic_t pending; 127 wait_queue_head_t wait; | 102struct mapped_device { 103 struct rw_semaphore io_lock; 104 struct mutex suspend_lock; 105 spinlock_t pushback_lock; 106 rwlock_t map_lock; 107 atomic_t holders; 108 atomic_t open_count; 109 --- 5 unchanged lines hidden (view full) --- 115 116 void *interface_ptr; 117 118 /* 119 * A list of ios that arrived while we were suspended. 120 */ 121 atomic_t pending; 122 wait_queue_head_t wait; |
123 struct work_struct work; |
|
128 struct bio_list deferred; 129 struct bio_list pushback; 130 131 /* 132 * Processing queue (flush/barriers) 133 */ 134 struct workqueue_struct *wq; 135 --- 929 unchanged lines hidden (view full) --- 1065 1066out: 1067 spin_unlock(&_minor_lock); 1068 return r; 1069} 1070 1071static struct block_device_operations dm_blk_dops; 1072 | 124 struct bio_list deferred; 125 struct bio_list pushback; 126 127 /* 128 * Processing queue (flush/barriers) 129 */ 130 struct workqueue_struct *wq; 131 --- 929 unchanged lines hidden (view full) --- 1061 1062out: 1063 spin_unlock(&_minor_lock); 1064 return r; 1065} 1066 1067static struct block_device_operations dm_blk_dops; 1068 |
1069static void dm_wq_work(struct work_struct *work); 1070 |
|
1073/* 1074 * Allocate and initialise a blank device with a given minor. 1075 */ 1076static struct mapped_device *alloc_dev(int minor) 1077{ 1078 int r; 1079 struct mapped_device *md = kzalloc(sizeof(*md), GFP_KERNEL); 1080 void *old_md; --- 50 unchanged lines hidden (view full) --- 1131 goto bad_no_bioset; 1132 1133 md->disk = alloc_disk(1); 1134 if (!md->disk) 1135 goto bad_disk; 1136 1137 atomic_set(&md->pending, 0); 1138 init_waitqueue_head(&md->wait); | 1071/* 1072 * Allocate and initialise a blank device with a given minor. 1073 */ 1074static struct mapped_device *alloc_dev(int minor) 1075{ 1076 int r; 1077 struct mapped_device *md = kzalloc(sizeof(*md), GFP_KERNEL); 1078 void *old_md; --- 50 unchanged lines hidden (view full) --- 1129 goto bad_no_bioset; 1130 1131 md->disk = alloc_disk(1); 1132 if (!md->disk) 1133 goto bad_disk; 1134 1135 atomic_set(&md->pending, 0); 1136 init_waitqueue_head(&md->wait); |
1137 INIT_WORK(&md->work, dm_wq_work); |
|
1139 init_waitqueue_head(&md->eventq); 1140 1141 md->disk->major = _major; 1142 md->disk->first_minor = minor; 1143 md->disk->fops = &dm_blk_dops; 1144 md->disk->queue = md->queue; 1145 md->disk->private_data = md; 1146 sprintf(md->disk->disk_name, "dm-%d", minor); --- 274 unchanged lines hidden (view full) --- 1421 clear_bit(DMF_NOFLUSH_SUSPENDING, &md->flags); 1422 bio_list_merge_head(&md->deferred, &md->pushback); 1423 bio_list_init(&md->pushback); 1424 spin_unlock_irqrestore(&md->pushback_lock, flags); 1425} 1426 1427static void dm_wq_work(struct work_struct *work) 1428{ | 1138 init_waitqueue_head(&md->eventq); 1139 1140 md->disk->major = _major; 1141 md->disk->first_minor = minor; 1142 md->disk->fops = &dm_blk_dops; 1143 md->disk->queue = md->queue; 1144 md->disk->private_data = md; 1145 sprintf(md->disk->disk_name, "dm-%d", minor); --- 274 unchanged lines hidden (view full) --- 1420 clear_bit(DMF_NOFLUSH_SUSPENDING, &md->flags); 1421 bio_list_merge_head(&md->deferred, &md->pushback); 1422 bio_list_init(&md->pushback); 1423 spin_unlock_irqrestore(&md->pushback_lock, flags); 1424} 1425 1426static void dm_wq_work(struct work_struct *work) 1427{ |
1429 struct dm_wq_req *req = container_of(work, struct dm_wq_req, work); 1430 struct mapped_device *md = req->md; | 1428 struct mapped_device *md = container_of(work, struct mapped_device, 1429 work); |
1431 1432 down_write(&md->io_lock); 1433 __flush_deferred_io(md); 1434 up_write(&md->io_lock); 1435} 1436 | 1430 1431 down_write(&md->io_lock); 1432 __flush_deferred_io(md); 1433 up_write(&md->io_lock); 1434} 1435 |
1437static void dm_wq_queue(struct mapped_device *md, struct dm_wq_req *req) 1438{ 1439 req->md = md; 1440 INIT_WORK(&req->work, dm_wq_work); 1441 queue_work(md->wq, &req->work); 1442} 1443 | |
1444static void dm_queue_flush(struct mapped_device *md) 1445{ | 1436static void dm_queue_flush(struct mapped_device *md) 1437{ |
1446 struct dm_wq_req req; 1447 1448 dm_wq_queue(md, &req); | 1438 queue_work(md->wq, &md->work); |
1449 flush_workqueue(md->wq); 1450} 1451 1452/* 1453 * Swap in a new table (destroying old one). 1454 */ 1455int dm_swap_table(struct mapped_device *md, struct dm_table *table) 1456{ --- 301 unchanged lines hidden --- | 1439 flush_workqueue(md->wq); 1440} 1441 1442/* 1443 * Swap in a new table (destroying old one). 1444 */ 1445int dm_swap_table(struct mapped_device *md, struct dm_table *table) 1446{ --- 301 unchanged lines hidden --- |