Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Side by Side Diff: drivers/md/dm-table.c

Issue 2020011: CHROMIUM: add boot-to-device mapper support. (Closed) Base URL: ssh://git@gitrw.chromium.org//kernel.git
Patch Set: fix the onyl Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « drivers/md/dm-ioctl.c ('k') | include/linux/device-mapper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2001 Sistina Software (UK) Limited. 2 * Copyright (C) 2001 Sistina Software (UK) Limited.
3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. 3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
4 * 4 *
5 * This file is released under the GPL. 5 * This file is released under the GPL.
6 */ 6 */
7 7
8 #include "dm.h" 8 #include "dm.h"
9 9
10 #include <linux/module.h> 10 #include <linux/module.h>
11 #include <linux/vmalloc.h> 11 #include <linux/vmalloc.h>
12 #include <linux/blkdev.h> 12 #include <linux/blkdev.h>
13 #include <linux/namei.h> 13 #include <linux/namei.h>
14 #include <linux/mount.h>
14 #include <linux/ctype.h> 15 #include <linux/ctype.h>
15 #include <linux/slab.h> 16 #include <linux/slab.h>
16 #include <linux/interrupt.h> 17 #include <linux/interrupt.h>
17 #include <linux/mutex.h> 18 #include <linux/mutex.h>
18 #include <linux/delay.h> 19 #include <linux/delay.h>
19 #include <asm/atomic.h> 20 #include <asm/atomic.h>
20 21
21 #define DM_MSG_PREFIX "table" 22 #define DM_MSG_PREFIX "table"
22 23
23 #define MAX_DEPTH 16 24 #define MAX_DEPTH 16
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 indexes += (KEYS_PER_NODE * t->counts[i]); 895 indexes += (KEYS_PER_NODE * t->counts[i]);
895 setup_btree_index(i, t); 896 setup_btree_index(i, t);
896 } 897 }
897 898
898 return 0; 899 return 0;
899 } 900 }
900 901
901 /* 902 /*
902 * Builds the btree to index the map. 903 * Builds the btree to index the map.
903 */ 904 */
904 int dm_table_complete(struct dm_table *t) 905 int dm_table_build_index(struct dm_table *t)
905 { 906 {
906 int r = 0; 907 int r = 0;
907 unsigned int leaf_nodes; 908 unsigned int leaf_nodes;
908 909
909 /* how many indexes will the btree have ? */ 910 /* how many indexes will the btree have ? */
910 leaf_nodes = dm_div_up(t->num_targets, KEYS_PER_NODE); 911 leaf_nodes = dm_div_up(t->num_targets, KEYS_PER_NODE);
911 t->depth = 1 + int_log(leaf_nodes, CHILDREN_PER_NODE); 912 t->depth = 1 + int_log(leaf_nodes, CHILDREN_PER_NODE);
912 913
913 /* leaf layer has already been set up */ 914 /* leaf layer has already been set up */
914 t->counts[t->depth - 1] = leaf_nodes; 915 t->counts[t->depth - 1] = leaf_nodes;
915 t->index[t->depth - 1] = t->highs; 916 t->index[t->depth - 1] = t->highs;
916 917
917 if (t->depth >= 2) 918 if (t->depth >= 2)
918 r = setup_indexes(t); 919 r = setup_indexes(t);
919 920
920 return r; 921 return r;
921 } 922 }
922 923
924 /*
925 * Register the mapped device for blk_integrity support if
926 * the underlying devices support it.
927 */
928 static int dm_table_prealloc_integrity(struct dm_table *t,
929 struct mapped_device *md)
930 {
931 struct list_head *devices = dm_table_get_devices(t);
932 struct dm_dev_internal *dd;
933
934 list_for_each_entry(dd, devices, list)
935 if (bdev_get_integrity(dd->dm_dev.bdev))
936 return blk_integrity_register(dm_disk(md), NULL);
937
938 return 0;
939 }
940
941 /*
942 * Prepares the table for use by building the indices,
943 * setting the type, and allocating mempools.
944 */
945 int dm_table_complete(struct dm_table *t)
946 {
947 int r = 0;
948 r = dm_table_set_type(t);
949 if (r) {
950 DMERR("unable to set table type");
951 return r;
952 }
953
954 r = dm_table_build_index(t);
955 if (r) {
956 DMERR("unable to build btrees");
957 return r;
958 }
959
960 r = dm_table_prealloc_integrity(t, t->md);
961 if (r) {
962 DMERR("could not register integrity profile.");
963 return r;
964 }
965
966 r = dm_table_alloc_md_mempools(t);
967 if (r)
968 DMERR("unable to allocate mempools");
969 return r;
970 }
971
923 static DEFINE_MUTEX(_event_lock); 972 static DEFINE_MUTEX(_event_lock);
924 void dm_table_event_callback(struct dm_table *t, 973 void dm_table_event_callback(struct dm_table *t,
925 void (*fn)(void *), void *context) 974 void (*fn)(void *), void *context)
926 { 975 {
927 mutex_lock(&_event_lock); 976 mutex_lock(&_event_lock);
928 t->event_fn = fn; 977 t->event_fn = fn;
929 t->event_context = context; 978 t->event_context = context;
930 mutex_unlock(&_event_lock); 979 mutex_unlock(&_event_lock);
931 } 980 }
932 981
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 EXPORT_SYMBOL(dm_vcalloc); 1287 EXPORT_SYMBOL(dm_vcalloc);
1239 EXPORT_SYMBOL(dm_get_device); 1288 EXPORT_SYMBOL(dm_get_device);
1240 EXPORT_SYMBOL(dm_put_device); 1289 EXPORT_SYMBOL(dm_put_device);
1241 EXPORT_SYMBOL(dm_table_event); 1290 EXPORT_SYMBOL(dm_table_event);
1242 EXPORT_SYMBOL(dm_table_get_size); 1291 EXPORT_SYMBOL(dm_table_get_size);
1243 EXPORT_SYMBOL(dm_table_get_mode); 1292 EXPORT_SYMBOL(dm_table_get_mode);
1244 EXPORT_SYMBOL(dm_table_get_md); 1293 EXPORT_SYMBOL(dm_table_get_md);
1245 EXPORT_SYMBOL(dm_table_put); 1294 EXPORT_SYMBOL(dm_table_put);
1246 EXPORT_SYMBOL(dm_table_get); 1295 EXPORT_SYMBOL(dm_table_get);
1247 EXPORT_SYMBOL(dm_table_unplug_all); 1296 EXPORT_SYMBOL(dm_table_unplug_all);
OLDNEW
« no previous file with comments | « drivers/md/dm-ioctl.c ('k') | include/linux/device-mapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698