dm.c (1134e5ae79bab61c05657ca35a6297cf87202e35) dm.c (3ac51e741a46af7a20f55e79d3e3aeaa93c6c544)
1/*
2 * Copyright (C) 2001, 2002 Sistina Software (UK) Limited.
3 * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
4 *
5 * This file is released under the GPL.
6 */
7
8#include "dm.h"
9#include "dm-bio-list.h"
10
11#include <linux/init.h>
12#include <linux/module.h>
13#include <linux/moduleparam.h>
14#include <linux/blkpg.h>
15#include <linux/bio.h>
16#include <linux/buffer_head.h>
17#include <linux/mempool.h>
18#include <linux/slab.h>
19#include <linux/idr.h>
1/*
2 * Copyright (C) 2001, 2002 Sistina Software (UK) Limited.
3 * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
4 *
5 * This file is released under the GPL.
6 */
7
8#include "dm.h"
9#include "dm-bio-list.h"
10
11#include <linux/init.h>
12#include <linux/module.h>
13#include <linux/moduleparam.h>
14#include <linux/blkpg.h>
15#include <linux/bio.h>
16#include <linux/buffer_head.h>
17#include <linux/mempool.h>
18#include <linux/slab.h>
19#include <linux/idr.h>
20#include <linux/hdreg.h>
20#include <linux/blktrace_api.h>
21
22static const char *_name = DM_NAME;
23
24static unsigned int major = 0;
25static unsigned int _major = 0;
26
27/*

--- 69 unchanged lines hidden (view full) ---

97 atomic_t event_nr;
98 wait_queue_head_t eventq;
99
100 /*
101 * freeze/thaw support require holding onto a super block
102 */
103 struct super_block *frozen_sb;
104 struct block_device *suspended_bdev;
21#include <linux/blktrace_api.h>
22
23static const char *_name = DM_NAME;
24
25static unsigned int major = 0;
26static unsigned int _major = 0;
27
28/*

--- 69 unchanged lines hidden (view full) ---

98 atomic_t event_nr;
99 wait_queue_head_t eventq;
100
101 /*
102 * freeze/thaw support require holding onto a super block
103 */
104 struct super_block *frozen_sb;
105 struct block_device *suspended_bdev;
106
107 /* forced geometry settings */
108 struct hd_geometry geometry;
105};
106
107#define MIN_IOS 256
108static kmem_cache_t *_io_cache;
109static kmem_cache_t *_tio_cache;
110
111static struct bio_set *dm_set;
112

--- 109 unchanged lines hidden (view full) ---

222{
223 struct mapped_device *md;
224
225 md = inode->i_bdev->bd_disk->private_data;
226 dm_put(md);
227 return 0;
228}
229
109};
110
111#define MIN_IOS 256
112static kmem_cache_t *_io_cache;
113static kmem_cache_t *_tio_cache;
114
115static struct bio_set *dm_set;
116

--- 109 unchanged lines hidden (view full) ---

226{
227 struct mapped_device *md;
228
229 md = inode->i_bdev->bd_disk->private_data;
230 dm_put(md);
231 return 0;
232}
233
234static int dm_blk_getgeo(struct block_device *bdev, struct hd_geometry *geo)
235{
236 struct mapped_device *md = bdev->bd_disk->private_data;
237
238 return dm_get_geometry(md, geo);
239}
240
230static inline struct dm_io *alloc_io(struct mapped_device *md)
231{
232 return mempool_alloc(md->io_pool, GFP_NOIO);
233}
234
235static inline void free_io(struct mapped_device *md, struct dm_io *io)
236{
237 mempool_free(io, md->io_pool);

--- 70 unchanged lines hidden (view full) ---

308 t = md->map;
309 if (t)
310 dm_table_get(t);
311 read_unlock(&md->map_lock);
312
313 return t;
314}
315
241static inline struct dm_io *alloc_io(struct mapped_device *md)
242{
243 return mempool_alloc(md->io_pool, GFP_NOIO);
244}
245
246static inline void free_io(struct mapped_device *md, struct dm_io *io)
247{
248 mempool_free(io, md->io_pool);

--- 70 unchanged lines hidden (view full) ---

319 t = md->map;
320 if (t)
321 dm_table_get(t);
322 read_unlock(&md->map_lock);
323
324 return t;
325}
326
327/*
328 * Get the geometry associated with a dm device
329 */
330int dm_get_geometry(struct mapped_device *md, struct hd_geometry *geo)
331{
332 *geo = md->geometry;
333
334 return 0;
335}
336
337/*
338 * Set the geometry of a device.
339 */
340int dm_set_geometry(struct mapped_device *md, struct hd_geometry *geo)
341{
342 sector_t sz = (sector_t)geo->cylinders * geo->heads * geo->sectors;
343
344 if (geo->start > sz) {
345 DMWARN("Start sector is beyond the geometry limits.");
346 return -EINVAL;
347 }
348
349 md->geometry = *geo;
350
351 return 0;
352}
353
316/*-----------------------------------------------------------------
317 * CRUD START:
318 * A more elegant soln is in the works that uses the queue
319 * merge fn, unfortunately there are a couple of changes to
320 * the block layer that I want to make for this. So in the
321 * interests of getting something for people to use I give
322 * you this clearly demarcated crap.
323 *---------------------------------------------------------------*/

--- 577 unchanged lines hidden (view full) ---

901}
902
903static int __bind(struct mapped_device *md, struct dm_table *t)
904{
905 request_queue_t *q = md->queue;
906 sector_t size;
907
908 size = dm_table_get_size(t);
354/*-----------------------------------------------------------------
355 * CRUD START:
356 * A more elegant soln is in the works that uses the queue
357 * merge fn, unfortunately there are a couple of changes to
358 * the block layer that I want to make for this. So in the
359 * interests of getting something for people to use I give
360 * you this clearly demarcated crap.
361 *---------------------------------------------------------------*/

--- 577 unchanged lines hidden (view full) ---

939}
940
941static int __bind(struct mapped_device *md, struct dm_table *t)
942{
943 request_queue_t *q = md->queue;
944 sector_t size;
945
946 size = dm_table_get_size(t);
947
948 /*
949 * Wipe any geometry if the size of the table changed.
950 */
951 if (size != get_capacity(md->disk))
952 memset(&md->geometry, 0, sizeof(md->geometry));
953
909 __set_size(md, size);
910 if (size == 0)
911 return 0;
912
913 dm_table_get(t);
914 dm_table_event_callback(t, event_callback, md);
915
916 write_lock(&md->map_lock);

--- 339 unchanged lines hidden (view full) ---

1256int dm_suspended(struct mapped_device *md)
1257{
1258 return test_bit(DMF_SUSPENDED, &md->flags);
1259}
1260
1261static struct block_device_operations dm_blk_dops = {
1262 .open = dm_blk_open,
1263 .release = dm_blk_close,
954 __set_size(md, size);
955 if (size == 0)
956 return 0;
957
958 dm_table_get(t);
959 dm_table_event_callback(t, event_callback, md);
960
961 write_lock(&md->map_lock);

--- 339 unchanged lines hidden (view full) ---

1301int dm_suspended(struct mapped_device *md)
1302{
1303 return test_bit(DMF_SUSPENDED, &md->flags);
1304}
1305
1306static struct block_device_operations dm_blk_dops = {
1307 .open = dm_blk_open,
1308 .release = dm_blk_close,
1309 .getgeo = dm_blk_getgeo,
1264 .owner = THIS_MODULE
1265};
1266
1267EXPORT_SYMBOL(dm_get_mapinfo);
1268
1269/*
1270 * module hooks
1271 */
1272module_init(dm_init);
1273module_exit(dm_exit);
1274
1275module_param(major, uint, 0);
1276MODULE_PARM_DESC(major, "The major number of the device mapper");
1277MODULE_DESCRIPTION(DM_NAME " driver");
1278MODULE_AUTHOR("Joe Thornber <dm-devel@redhat.com>");
1279MODULE_LICENSE("GPL");
1310 .owner = THIS_MODULE
1311};
1312
1313EXPORT_SYMBOL(dm_get_mapinfo);
1314
1315/*
1316 * module hooks
1317 */
1318module_init(dm_init);
1319module_exit(dm_exit);
1320
1321module_param(major, uint, 0);
1322MODULE_PARM_DESC(major, "The major number of the device mapper");
1323MODULE_DESCRIPTION(DM_NAME " driver");
1324MODULE_AUTHOR("Joe Thornber <dm-devel@redhat.com>");
1325MODULE_LICENSE("GPL");