Commit 2111438b authored by Philipp Reisner's avatar Philipp Reisner

drbd: Minimal struct drbd_tconn

Starting to dissolve the network connection from the actual
block devices.
Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent 9749f30f
...@@ -94,6 +94,7 @@ extern char usermode_helper[]; ...@@ -94,6 +94,7 @@ extern char usermode_helper[];
#define UUID_NEW_BM_OFFSET ((u64)0x0001000000000000ULL) #define UUID_NEW_BM_OFFSET ((u64)0x0001000000000000ULL)
struct drbd_conf; struct drbd_conf;
struct drbd_tconn;
/* to shorten dev_warn(DEV, "msg"); and relatives statements */ /* to shorten dev_warn(DEV, "msg"); and relatives statements */
...@@ -960,7 +961,18 @@ struct fifo_buffer { ...@@ -960,7 +961,18 @@ struct fifo_buffer {
unsigned int size; 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_conf {
struct drbd_tconn *tconn;
int vnr; /* volume number within the connection */
/* things that are stored as / read from meta data on disk */ /* things that are stored as / read from meta data on disk */
unsigned long flags; unsigned long flags;
...@@ -1496,6 +1508,9 @@ extern rwlock_t global_state_lock; ...@@ -1496,6 +1508,9 @@ extern rwlock_t global_state_lock;
extern struct drbd_conf *drbd_new_device(unsigned int minor); extern struct drbd_conf *drbd_new_device(unsigned int minor);
extern void drbd_free_mdev(struct drbd_conf *mdev); 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; extern int proc_details;
/* drbd_req */ /* drbd_req */
......
...@@ -132,6 +132,7 @@ module_param_string(usermode_helper, usermode_helper, sizeof(usermode_helper), 0 ...@@ -132,6 +132,7 @@ module_param_string(usermode_helper, usermode_helper, sizeof(usermode_helper), 0
* as member "struct gendisk *vdisk;" * as member "struct gendisk *vdisk;"
*/ */
struct drbd_conf **minor_table; 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_request_cache;
struct kmem_cache *drbd_ee_cache; /* epoch entries */ struct kmem_cache *drbd_ee_cache; /* epoch entries */
...@@ -3267,6 +3268,7 @@ static void drbd_delete_device(unsigned int minor) ...@@ -3267,6 +3268,7 @@ static void drbd_delete_device(unsigned int minor)
bdput(mdev->this_bdev); bdput(mdev->this_bdev);
drbd_free_resources(mdev); drbd_free_resources(mdev);
drbd_free_tconn(mdev->tconn);
drbd_release_ee_lists(mdev); drbd_release_ee_lists(mdev);
...@@ -3358,6 +3360,41 @@ static int drbd_congested(void *congested_data, int bdi_bits) ...@@ -3358,6 +3360,41 @@ static int drbd_congested(void *congested_data, int bdi_bits)
return r; 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 *drbd_new_device(unsigned int minor)
{ {
struct drbd_conf *mdev; struct drbd_conf *mdev;
...@@ -3368,9 +3405,14 @@ struct drbd_conf *drbd_new_device(unsigned int minor) ...@@ -3368,9 +3405,14 @@ struct drbd_conf *drbd_new_device(unsigned int minor)
mdev = kzalloc(sizeof(struct drbd_conf), GFP_KERNEL); mdev = kzalloc(sizeof(struct drbd_conf), GFP_KERNEL);
if (!mdev) if (!mdev)
return NULL; return NULL;
mdev->tconn = drbd_new_tconn("dummy");
if (!mdev->tconn)
goto out_no_tconn;
if (!zalloc_cpumask_var(&mdev->cpu_mask, GFP_KERNEL)) if (!zalloc_cpumask_var(&mdev->cpu_mask, GFP_KERNEL))
goto out_no_cpumask; goto out_no_cpumask;
mdev->tconn->volume0 = mdev;
mdev->minor = minor; mdev->minor = minor;
drbd_init_set_defaults(mdev); drbd_init_set_defaults(mdev);
...@@ -3447,6 +3489,8 @@ struct drbd_conf *drbd_new_device(unsigned int minor) ...@@ -3447,6 +3489,8 @@ struct drbd_conf *drbd_new_device(unsigned int minor)
out_no_q: out_no_q:
free_cpumask_var(mdev->cpu_mask); free_cpumask_var(mdev->cpu_mask);
out_no_cpumask: out_no_cpumask:
drbd_free_tconn(mdev->tconn);
out_no_tconn:
kfree(mdev); kfree(mdev);
return NULL; return NULL;
} }
...@@ -3526,6 +3570,7 @@ int __init drbd_init(void) ...@@ -3526,6 +3570,7 @@ int __init drbd_init(void)
} }
rwlock_init(&global_state_lock); rwlock_init(&global_state_lock);
INIT_LIST_HEAD(&drbd_tconns);
printk(KERN_INFO "drbd: initialized. " printk(KERN_INFO "drbd: initialized. "
"Version: " REL_VERSION " (api:%d/proto:%d-%d)\n", "Version: " REL_VERSION " (api:%d/proto:%d-%d)\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment