drbd: Minimal struct drbd_tconn

Starting to dissolve the network connection from the actual
block devices.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
This commit is contained in:
Philipp Reisner 2011-01-19 12:26:59 +01:00
parent 9749f30f1a
commit 2111438b30
2 changed files with 60 additions and 0 deletions

View File

@ -94,6 +94,7 @@ extern char usermode_helper[];
#define UUID_NEW_BM_OFFSET ((u64)0x0001000000000000ULL)
struct drbd_conf;
struct drbd_tconn;
/* to shorten dev_warn(DEV, "msg"); and relatives statements */
@ -960,7 +961,18 @@ struct fifo_buffer {
unsigned int size;
};
struct drbd_tconn { /* is a resource from the config file */
char *name; /* Resource name */
struct list_head all_tconn; /* List of all drbd_tconn, prot by global_state_lock */
struct drbd_conf *volume0; /* TODO: Remove me again */
struct net_conf *net_conf; /* protected by get_net_conf() and put_net_conf() */
};
struct drbd_conf {
struct drbd_tconn *tconn;
int vnr; /* volume number within the connection */
/* things that are stored as / read from meta data on disk */
unsigned long flags;
@ -1496,6 +1508,9 @@ extern rwlock_t global_state_lock;
extern struct drbd_conf *drbd_new_device(unsigned int minor);
extern void drbd_free_mdev(struct drbd_conf *mdev);
struct drbd_tconn *drbd_new_tconn(char *name);
extern void drbd_free_tconn(struct drbd_tconn *tconn);
extern int proc_details;
/* drbd_req */

View File

@ -132,6 +132,7 @@ module_param_string(usermode_helper, usermode_helper, sizeof(usermode_helper), 0
* as member "struct gendisk *vdisk;"
*/
struct drbd_conf **minor_table;
struct list_head drbd_tconns; /* list of struct drbd_tconn */
struct kmem_cache *drbd_request_cache;
struct kmem_cache *drbd_ee_cache; /* epoch entries */
@ -3267,6 +3268,7 @@ static void drbd_delete_device(unsigned int minor)
bdput(mdev->this_bdev);
drbd_free_resources(mdev);
drbd_free_tconn(mdev->tconn);
drbd_release_ee_lists(mdev);
@ -3358,6 +3360,41 @@ out:
return r;
}
struct drbd_tconn *drbd_new_tconn(char *name)
{
struct drbd_tconn *tconn;
tconn = kzalloc(sizeof(struct drbd_tconn), GFP_KERNEL);
if (!tconn)
return NULL;
tconn->name = kstrdup(name, GFP_KERNEL);
if (!tconn->name)
goto fail;
write_lock_irq(&global_state_lock);
list_add(&tconn->all_tconn, &drbd_tconns);
write_unlock_irq(&global_state_lock);
return tconn;
fail:
kfree(tconn->name);
kfree(tconn);
return NULL;
}
void drbd_free_tconn(struct drbd_tconn *tconn)
{
write_lock_irq(&global_state_lock);
list_del(&tconn->all_tconn);
write_unlock_irq(&global_state_lock);
kfree(tconn->name);
kfree(tconn);
}
struct drbd_conf *drbd_new_device(unsigned int minor)
{
struct drbd_conf *mdev;
@ -3368,9 +3405,14 @@ struct drbd_conf *drbd_new_device(unsigned int minor)
mdev = kzalloc(sizeof(struct drbd_conf), GFP_KERNEL);
if (!mdev)
return NULL;
mdev->tconn = drbd_new_tconn("dummy");
if (!mdev->tconn)
goto out_no_tconn;
if (!zalloc_cpumask_var(&mdev->cpu_mask, GFP_KERNEL))
goto out_no_cpumask;
mdev->tconn->volume0 = mdev;
mdev->minor = minor;
drbd_init_set_defaults(mdev);
@ -3447,6 +3489,8 @@ out_no_disk:
out_no_q:
free_cpumask_var(mdev->cpu_mask);
out_no_cpumask:
drbd_free_tconn(mdev->tconn);
out_no_tconn:
kfree(mdev);
return NULL;
}
@ -3526,6 +3570,7 @@ int __init drbd_init(void)
}
rwlock_init(&global_state_lock);
INIT_LIST_HEAD(&drbd_tconns);
printk(KERN_INFO "drbd: initialized. "
"Version: " REL_VERSION " (api:%d/proto:%d-%d)\n",