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

Side by Side Diff: drivers/md/dm-ioctl.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 | « Documentation/kernel-parameters.txt ('k') | drivers/md/dm-table.c » ('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, 2002 Sistina Software (UK) Limited. 2 * Copyright (C) 2001, 2002 Sistina Software (UK) Limited.
3 * Copyright (C) 2004 - 2006 Red Hat, Inc. All rights reserved. 3 * Copyright (C) 2004 - 2006 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>
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 (sector_t) spec->length, 1054 (sector_t) spec->length,
1055 target_params); 1055 target_params);
1056 if (r) { 1056 if (r) {
1057 DMWARN("error adding target to table"); 1057 DMWARN("error adding target to table");
1058 return r; 1058 return r;
1059 } 1059 }
1060 1060
1061 next = spec->next; 1061 next = spec->next;
1062 } 1062 }
1063 1063
1064 r = dm_table_set_type(table);
1065 if (r) {
1066 DMWARN("unable to set table type");
1067 return r;
1068 }
1069
1070 return dm_table_complete(table); 1064 return dm_table_complete(table);
1071 } 1065 }
1072 1066
1073 static int table_prealloc_integrity(struct dm_table *t,
1074 struct mapped_device *md)
1075 {
1076 struct list_head *devices = dm_table_get_devices(t);
1077 struct dm_dev_internal *dd;
1078
1079 list_for_each_entry(dd, devices, list)
1080 if (bdev_get_integrity(dd->dm_dev.bdev))
1081 return blk_integrity_register(dm_disk(md), NULL);
1082
1083 return 0;
1084 }
1085
1086 static int table_load(struct dm_ioctl *param, size_t param_size) 1067 static int table_load(struct dm_ioctl *param, size_t param_size)
1087 { 1068 {
1088 int r; 1069 int r;
1089 struct hash_cell *hc; 1070 struct hash_cell *hc;
1090 struct dm_table *t; 1071 struct dm_table *t;
1091 struct mapped_device *md; 1072 struct mapped_device *md;
1092 1073
1093 md = find_device(param); 1074 md = find_device(param);
1094 if (!md) 1075 if (!md)
1095 return -ENXIO; 1076 return -ENXIO;
1096 1077
1097 r = dm_table_create(&t, get_mode(param), param->target_count, md); 1078 r = dm_table_create(&t, get_mode(param), param->target_count, md);
1098 if (r) 1079 if (r)
1099 goto out; 1080 goto out;
1100 1081
1101 r = populate_table(t, param, param_size); 1082 r = populate_table(t, param, param_size);
1102 if (r) { 1083 if (r) {
1103 dm_table_destroy(t); 1084 dm_table_destroy(t);
1104 goto out; 1085 goto out;
1105 } 1086 }
1106 1087
1107 r = table_prealloc_integrity(t, md);
1108 if (r) {
1109 DMERR("%s: could not register integrity profile.",
1110 dm_device_name(md));
1111 dm_table_destroy(t);
1112 goto out;
1113 }
1114
1115 r = dm_table_alloc_md_mempools(t);
1116 if (r) {
1117 DMWARN("unable to allocate mempools for this table");
1118 dm_table_destroy(t);
1119 goto out;
1120 }
1121
1122 down_write(&_hash_lock); 1088 down_write(&_hash_lock);
1123 hc = dm_get_mdptr(md); 1089 hc = dm_get_mdptr(md);
1124 if (!hc || hc->md != md) { 1090 if (!hc || hc->md != md) {
1125 DMWARN("device has been removed from the dev hash table."); 1091 DMWARN("device has been removed from the dev hash table.");
1126 dm_table_destroy(t); 1092 dm_table_destroy(t);
1127 up_write(&_hash_lock); 1093 up_write(&_hash_lock);
1128 r = -ENXIO; 1094 r = -ENXIO;
1129 goto out; 1095 goto out;
1130 } 1096 }
1131 1097
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1572 } 1538 }
1573 1539
1574 void dm_interface_exit(void) 1540 void dm_interface_exit(void)
1575 { 1541 {
1576 if (misc_deregister(&_dm_misc) < 0) 1542 if (misc_deregister(&_dm_misc) < 0)
1577 DMERR("misc_deregister failed for control device"); 1543 DMERR("misc_deregister failed for control device");
1578 1544
1579 dm_hash_exit(); 1545 dm_hash_exit();
1580 } 1546 }
1581 1547
1548
1549 /**
1550 * dm_ioctl_export - Permanently export a mapped device via the ioctl interface
1551 * @md: Pointer to mapped_device
1552 * @name: Buffer (size DM_NAME_LEN) for name
1553 * @uuid: Buffer (size DM_UUID_LEN) for uuid or NULL if not desired
1554 */
1555 int dm_ioctl_export(struct mapped_device *md, const char *name,
1556 const char *uuid)
1557 {
1558 int r = 0;
1559 struct hash_cell *hc;
1560
1561 if (!md) {
1562 r = -ENXIO;
1563 goto out;
1564 }
1565
1566 /* The name and uuid can only be set once. */
1567 mutex_lock(&dm_hash_cells_mutex);
1568 hc = dm_get_mdptr(md);
1569 mutex_unlock(&dm_hash_cells_mutex);
1570 if (hc) {
1571 DMERR("%s: already exported", dm_device_name(md));
1572 r = -ENXIO;
1573 goto out;
1574 }
1575
1576 r = dm_hash_insert(name, uuid, md);
1577 if (r) {
1578 DMERR("%s: could not bind to '%s'", dm_device_name(md), name);
1579 goto out;
1580 }
1581
1582 /* Let udev know we've changed. */
1583 dm_kobject_uevent(md, KOBJ_CHANGE, dm_get_event_nr(md));
1584 out:
1585 return r;
1586 }
1582 /** 1587 /**
1583 * dm_copy_name_and_uuid - Copy mapped device name & uuid into supplied buffers 1588 * dm_copy_name_and_uuid - Copy mapped device name & uuid into supplied buffers
1584 * @md: Pointer to mapped_device 1589 * @md: Pointer to mapped_device
1585 * @name: Buffer (size DM_NAME_LEN) for name 1590 * @name: Buffer (size DM_NAME_LEN) for name
1586 * @uuid: Buffer (size DM_UUID_LEN) for uuid or empty string if uuid not defined 1591 * @uuid: Buffer (size DM_UUID_LEN) for uuid or empty string if uuid not defined
1587 */ 1592 */
1588 int dm_copy_name_and_uuid(struct mapped_device *md, char *name, char *uuid) 1593 int dm_copy_name_and_uuid(struct mapped_device *md, char *name, char *uuid)
1589 { 1594 {
1590 int r = 0; 1595 int r = 0;
1591 struct hash_cell *hc; 1596 struct hash_cell *hc;
(...skipping 11 matching lines...) Expand all
1603 if (name) 1608 if (name)
1604 strcpy(name, hc->name); 1609 strcpy(name, hc->name);
1605 if (uuid) 1610 if (uuid)
1606 strcpy(uuid, hc->uuid ? : ""); 1611 strcpy(uuid, hc->uuid ? : "");
1607 1612
1608 out: 1613 out:
1609 mutex_unlock(&dm_hash_cells_mutex); 1614 mutex_unlock(&dm_hash_cells_mutex);
1610 1615
1611 return r; 1616 return r;
1612 } 1617 }
OLDNEW
« no previous file with comments | « Documentation/kernel-parameters.txt ('k') | drivers/md/dm-table.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698