• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/src/linux/linux-2.6/drivers/md/

Lines Matching refs:md

37 	struct mapped_device *md;
64 * Bits for the md->flags field.
225 struct mapped_device *md;
229 md = inode->i_bdev->bd_disk->private_data;
230 if (!md)
233 if (test_bit(DMF_FREEING, &md->flags) ||
234 test_bit(DMF_DELETING, &md->flags)) {
235 md = NULL;
239 dm_get(md);
240 atomic_inc(&md->open_count);
245 return md ? 0 : -ENXIO;
250 struct mapped_device *md;
252 md = inode->i_bdev->bd_disk->private_data;
253 atomic_dec(&md->open_count);
254 dm_put(md);
258 int dm_open_count(struct mapped_device *md)
260 return atomic_read(&md->open_count);
266 int dm_lock_for_deletion(struct mapped_device *md)
272 if (dm_open_count(md))
275 set_bit(DMF_DELETING, &md->flags);
284 struct mapped_device *md = bdev->bd_disk->private_data;
286 return dm_get_geometry(md, geo);
292 struct mapped_device *md;
300 md = inode->i_bdev->bd_disk->private_data;
302 map = dm_get_table(md);
313 if (dm_suspended(md)) {
328 static inline struct dm_io *alloc_io(struct mapped_device *md)
330 return mempool_alloc(md->io_pool, GFP_NOIO);
333 static inline void free_io(struct mapped_device *md, struct dm_io *io)
335 mempool_free(io, md->io_pool);
338 static inline struct target_io *alloc_tio(struct mapped_device *md)
340 return mempool_alloc(md->tio_pool, GFP_NOIO);
343 static inline void free_tio(struct mapped_device *md, struct target_io *tio)
345 mempool_free(tio, md->tio_pool);
350 struct mapped_device *md = io->md;
355 disk_round_stats(dm_disk(md));
357 dm_disk(md)->in_flight = atomic_inc_return(&md->pending);
362 struct mapped_device *md = io->md;
369 disk_round_stats(dm_disk(md));
371 dm_disk(md)->in_flight = pending = atomic_dec_return(&md->pending);
373 disk_stat_add(dm_disk(md), ticks[rw], duration);
381 static int queue_io(struct mapped_device *md, struct bio *bio)
383 down_write(&md->io_lock);
385 if (!test_bit(DMF_BLOCK_IO, &md->flags)) {
386 up_write(&md->io_lock);
390 bio_list_add(&md->deferred, bio);
392 up_write(&md->io_lock);
398 * function to access the md->map field, and make sure they call
401 struct dm_table *dm_get_table(struct mapped_device *md)
405 read_lock(&md->map_lock);
406 t = md->map;
409 read_unlock(&md->map_lock);
417 int dm_get_geometry(struct mapped_device *md, struct hd_geometry *geo)
419 *geo = md->geometry;
427 int dm_set_geometry(struct mapped_device *md, struct hd_geometry *geo)
436 md->geometry = *geo;
450 static int __noflush_suspending(struct mapped_device *md)
452 return test_bit(DMF_NOFLUSH_SUSPENDING, &md->flags);
464 if (error && !(io->error > 0 && __noflush_suspending(io->md)))
474 spin_lock_irqsave(&io->md->pushback_lock, flags);
475 if (__noflush_suspending(io->md))
476 bio_list_add(&io->md->pushback, io->bio);
480 spin_unlock_irqrestore(&io->md->pushback_lock, flags);
485 wake_up(&io->md->wait);
488 blk_add_trace_bio(io->md->queue, io->bio,
494 free_io(io->md, io);
502 struct mapped_device *md = tio->io->md;
531 * Store md for cleanup instead of tio which is about to get freed.
533 bio->bi_private = md->bs;
536 free_tio(md, tio);
540 static sector_t max_io_len(struct mapped_device *md,
565 struct mapped_device *md;
593 md = tio->io->md;
598 clone->bi_private = md->bs;
600 free_tio(md, tio);
608 struct mapped_device *md;
674 sector_t len = 0, max = max_io_len(ci->md, ci->sector, ti);
680 tio = alloc_tio(ci->md);
692 ci->md->bs);
716 ci->md->bs);
734 max = max_io_len(ci->md, ci->sector, ti);
736 tio = alloc_tio(ci->md);
746 ci->md->bs);
762 static void __split_bio(struct mapped_device *md, struct bio *bio)
766 ci.map = dm_get_table(md);
772 ci.md = md;
774 ci.io = alloc_io(md);
778 ci.io->md = md;
803 struct mapped_device *md = q->queuedata;
805 down_read(&md->io_lock);
807 disk_stat_inc(dm_disk(md), ios[rw]);
808 disk_stat_add(dm_disk(md), sectors[rw], bio_sectors(bio));
814 while (test_bit(DMF_BLOCK_IO, &md->flags)) {
815 up_read(&md->io_lock);
822 r = queue_io(md, bio);
834 down_read(&md->io_lock);
837 __split_bio(md, bio);
838 up_read(&md->io_lock);
845 struct mapped_device *md = q->queuedata;
846 struct dm_table *map = dm_get_table(md);
859 struct mapped_device *md = q->queuedata;
860 struct dm_table *map = dm_get_table(md);
871 struct mapped_device *md = (struct mapped_device *) congested_data;
872 struct dm_table *map = dm_get_table(md);
874 if (!map || test_bit(DMF_BLOCK_IO, &md->flags))
898 static int specific_minor(struct mapped_device *md, int minor)
931 static int next_free_minor(struct mapped_device *md, int *minor)
967 struct mapped_device *md = kmalloc(sizeof(*md), GFP_KERNEL);
970 if (!md) {
980 r = next_free_minor(md, &minor);
982 r = specific_minor(md, minor);
986 memset(md, 0, sizeof(*md));
987 init_rwsem(&md->io_lock);
988 init_MUTEX(&md->suspend_lock);
989 spin_lock_init(&md->pushback_lock);
990 rwlock_init(&md->map_lock);
991 atomic_set(&md->holders, 1);
992 atomic_set(&md->open_count, 0);
993 atomic_set(&md->event_nr, 0);
995 md->queue = blk_alloc_queue(GFP_KERNEL);
996 if (!md->queue)
999 md->queue->queuedata = md;
1000 md->queue->backing_dev_info.congested_fn = dm_any_congested;
1001 md->queue->backing_dev_info.congested_data = md;
1002 blk_queue_make_request(md->queue, dm_request);
1003 blk_queue_bounce_limit(md->queue, BLK_BOUNCE_ANY);
1004 md->queue->unplug_fn = dm_unplug_all;
1005 md->queue->issue_flush_fn = dm_flush_all;
1007 md->io_pool = mempool_create_slab_pool(MIN_IOS, _io_cache);
1008 if (!md->io_pool)
1011 md->tio_pool = mempool_create_slab_pool(MIN_IOS, _tio_cache);
1012 if (!md->tio_pool)
1015 md->bs = bioset_create(16, 16);
1016 if (!md->bs)
1019 md->disk = alloc_disk(1);
1020 if (!md->disk)
1023 atomic_set(&md->pending, 0);
1024 init_waitqueue_head(&md->wait);
1025 init_waitqueue_head(&md->eventq);
1027 md->disk->major = _major;
1028 md->disk->first_minor = minor;
1029 md->disk->fops = &dm_blk_dops;
1030 md->disk->queue = md->queue;
1031 md->disk->private_data = md;
1032 sprintf(md->disk->disk_name, "dm-%d", minor);
1033 add_disk(md->disk);
1034 format_dev_t(md->name, MKDEV(_major, minor));
1038 old_md = idr_replace(&_minor_idr, md, minor);
1043 return md;
1046 bioset_free(md->bs);
1048 mempool_destroy(md->tio_pool);
1050 mempool_destroy(md->io_pool);
1052 blk_cleanup_queue(md->queue);
1058 kfree(md);
1062 static void free_dev(struct mapped_device *md)
1064 int minor = md->disk->first_minor;
1066 if (md->suspended_bdev) {
1067 thaw_bdev(md->suspended_bdev, NULL);
1068 bdput(md->suspended_bdev);
1070 mempool_destroy(md->tio_pool);
1071 mempool_destroy(md->io_pool);
1072 bioset_free(md->bs);
1073 del_gendisk(md->disk);
1077 md->disk->private_data = NULL;
1080 put_disk(md->disk);
1081 blk_cleanup_queue(md->queue);
1083 kfree(md);
1091 struct mapped_device *md = (struct mapped_device *) context;
1093 atomic_inc(&md->event_nr);
1094 wake_up(&md->eventq);
1097 static void __set_size(struct mapped_device *md, sector_t size)
1099 set_capacity(md->disk, size);
1101 mutex_lock(&md->suspended_bdev->bd_inode->i_mutex);
1102 i_size_write(md->suspended_bdev->bd_inode, (loff_t)size << SECTOR_SHIFT);
1103 mutex_unlock(&md->suspended_bdev->bd_inode->i_mutex);
1106 static int __bind(struct mapped_device *md, struct dm_table *t)
1108 request_queue_t *q = md->queue;
1116 if (size != get_capacity(md->disk))
1117 memset(&md->geometry, 0, sizeof(md->geometry));
1119 if (md->suspended_bdev)
1120 __set_size(md, size);
1125 dm_table_event_callback(t, event_callback, md);
1127 write_lock(&md->map_lock);
1128 md->map = t;
1130 write_unlock(&md->map_lock);
1135 static void __unbind(struct mapped_device *md)
1137 struct dm_table *map = md->map;
1143 write_lock(&md->map_lock);
1144 md->map = NULL;
1145 write_unlock(&md->map_lock);
1154 struct mapped_device *md;
1156 md = alloc_dev(minor);
1157 if (!md)
1160 *result = md;
1166 struct mapped_device *md;
1174 md = idr_find(&_minor_idr, minor);
1175 if (md && (md == MINOR_ALLOCED ||
1176 (dm_disk(md)->first_minor != minor) ||
1177 test_bit(DMF_FREEING, &md->flags))) {
1178 md = NULL;
1185 return md;
1190 struct mapped_device *md = dm_find_md(dev);
1192 if (md)
1193 dm_get(md);
1195 return md;
1198 void *dm_get_mdptr(struct mapped_device *md)
1200 return md->interface_ptr;
1203 void dm_set_mdptr(struct mapped_device *md, void *ptr)
1205 md->interface_ptr = ptr;
1208 void dm_get(struct mapped_device *md)
1210 atomic_inc(&md->holders);
1213 const char *dm_device_name(struct mapped_device *md)
1215 return md->name;
1219 void dm_put(struct mapped_device *md)
1223 BUG_ON(test_bit(DMF_FREEING, &md->flags));
1225 if (atomic_dec_and_lock(&md->holders, &_minor_lock)) {
1226 map = dm_get_table(md);
1227 idr_replace(&_minor_idr, MINOR_ALLOCED, dm_disk(md)->first_minor);
1228 set_bit(DMF_FREEING, &md->flags);
1230 if (!dm_suspended(md)) {
1234 __unbind(md);
1236 free_dev(md);
1244 static void __flush_deferred_io(struct mapped_device *md, struct bio *c)
1251 __split_bio(md, c);
1259 int dm_swap_table(struct mapped_device *md, struct dm_table *table)
1263 down(&md->suspend_lock);
1266 if (!dm_suspended(md))
1270 if (!md->suspended_bdev)
1271 if (get_capacity(md->disk) != dm_table_get_size(table))
1274 __unbind(md);
1275 r = __bind(md, table);
1278 up(&md->suspend_lock);
1286 static int lock_fs(struct mapped_device *md)
1290 WARN_ON(md->frozen_sb);
1292 md->frozen_sb = freeze_bdev(md->suspended_bdev);
1293 if (IS_ERR(md->frozen_sb)) {
1294 r = PTR_ERR(md->frozen_sb);
1295 md->frozen_sb = NULL;
1299 set_bit(DMF_FROZEN, &md->flags);
1307 static void unlock_fs(struct mapped_device *md)
1309 if (!test_bit(DMF_FROZEN, &md->flags))
1312 thaw_bdev(md->suspended_bdev, md->frozen_sb);
1313 md->frozen_sb = NULL;
1314 clear_bit(DMF_FROZEN, &md->flags);
1324 int dm_suspend(struct mapped_device *md, unsigned suspend_flags)
1334 down(&md->suspend_lock);
1336 if (dm_suspended(md))
1339 map = dm_get_table(md);
1346 set_bit(DMF_NOFLUSH_SUSPENDING, &md->flags);
1353 md->suspended_bdev = bdget_disk(md->disk, 0);
1354 if (!md->suspended_bdev) {
1366 r = lock_fs(md);
1374 down_write(&md->io_lock);
1375 set_bit(DMF_BLOCK_IO, &md->flags);
1377 add_wait_queue(&md->wait, &wait);
1378 up_write(&md->io_lock);
1391 if (!atomic_read(&md->pending) || signal_pending(current))
1398 down_write(&md->io_lock);
1399 remove_wait_queue(&md->wait, &wait);
1402 spin_lock_irqsave(&md->pushback_lock, flags);
1403 clear_bit(DMF_NOFLUSH_SUSPENDING, &md->flags);
1404 bio_list_merge_head(&md->deferred, &md->pushback);
1405 bio_list_init(&md->pushback);
1406 spin_unlock_irqrestore(&md->pushback_lock, flags);
1411 if (atomic_read(&md->pending)) {
1412 clear_bit(DMF_BLOCK_IO, &md->flags);
1413 def = bio_list_get(&md->deferred);
1414 __flush_deferred_io(md, def);
1415 up_write(&md->io_lock);
1416 unlock_fs(md);
1419 up_write(&md->io_lock);
1423 set_bit(DMF_SUSPENDED, &md->flags);
1433 down_write(&md->io_lock);
1435 spin_lock_irqsave(&md->pushback_lock, flags);
1436 clear_bit(DMF_NOFLUSH_SUSPENDING, &md->flags);
1437 bio_list_merge_head(&md->deferred, &md->pushback);
1438 bio_list_init(&md->pushback);
1439 spin_unlock_irqrestore(&md->pushback_lock, flags);
1441 def = bio_list_get(&md->deferred);
1442 __flush_deferred_io(md, def);
1443 up_write(&md->io_lock);
1447 if (r && md->suspended_bdev) {
1448 bdput(md->suspended_bdev);
1449 md->suspended_bdev = NULL;
1455 up(&md->suspend_lock);
1459 int dm_resume(struct mapped_device *md)
1465 down(&md->suspend_lock);
1466 if (!dm_suspended(md))
1469 map = dm_get_table(md);
1477 down_write(&md->io_lock);
1478 clear_bit(DMF_BLOCK_IO, &md->flags);
1480 def = bio_list_get(&md->deferred);
1481 __flush_deferred_io(md, def);
1482 up_write(&md->io_lock);
1484 unlock_fs(md);
1486 if (md->suspended_bdev) {
1487 bdput(md->suspended_bdev);
1488 md->suspended_bdev = NULL;
1491 clear_bit(DMF_SUSPENDED, &md->flags);
1495 kobject_uevent(&md->disk->kobj, KOBJ_CHANGE);
1501 up(&md->suspend_lock);
1509 uint32_t dm_get_event_nr(struct mapped_device *md)
1511 return atomic_read(&md->event_nr);
1514 int dm_wait_event(struct mapped_device *md, int event_nr)
1516 return wait_event_interruptible(md->eventq,
1517 (event_nr != atomic_read(&md->event_nr)));
1522 * count on 'md'.
1524 struct gendisk *dm_disk(struct mapped_device *md)
1526 return md->disk;
1529 int dm_suspended(struct mapped_device *md)
1531 return test_bit(DMF_SUSPENDED, &md->flags);
1536 struct mapped_device *md = dm_table_get_md(ti->table);
1537 int r = __noflush_suspending(md);
1539 dm_put(md);