aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/drbd/drbd_main.c
diff options
context:
space:
mode:
authorPhilipp Reisner <philipp.reisner@linbit.com>2011-01-19 06:26:59 -0500
committerPhilipp Reisner <philipp.reisner@linbit.com>2011-08-29 05:27:02 -0400
commit2111438b30a509cfe8a1595d7fad304308ff2466 (patch)
tree3d5d1cec53f2966a45f2c66a1e2b7aa40f38e18b /drivers/block/drbd/drbd_main.c
parent9749f30f1a387070e6e8351f35aeb829eacc3ab6 (diff)
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>
Diffstat (limited to 'drivers/block/drbd/drbd_main.c')
-rw-r--r--drivers/block/drbd/drbd_main.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index 2902f6dd7bf1..a6ac0c81406b 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -132,6 +132,7 @@ module_param_string(usermode_helper, usermode_helper, sizeof(usermode_helper), 0
132 * as member "struct gendisk *vdisk;" 132 * as member "struct gendisk *vdisk;"
133 */ 133 */
134struct drbd_conf **minor_table; 134struct drbd_conf **minor_table;
135struct list_head drbd_tconns; /* list of struct drbd_tconn */
135 136
136struct kmem_cache *drbd_request_cache; 137struct kmem_cache *drbd_request_cache;
137struct kmem_cache *drbd_ee_cache; /* epoch entries */ 138struct kmem_cache *drbd_ee_cache; /* epoch entries */
@@ -3267,6 +3268,7 @@ static void drbd_delete_device(unsigned int minor)
3267 bdput(mdev->this_bdev); 3268 bdput(mdev->this_bdev);
3268 3269
3269 drbd_free_resources(mdev); 3270 drbd_free_resources(mdev);
3271 drbd_free_tconn(mdev->tconn);
3270 3272
3271 drbd_release_ee_lists(mdev); 3273 drbd_release_ee_lists(mdev);
3272 3274
@@ -3358,6 +3360,41 @@ out:
3358 return r; 3360 return r;
3359} 3361}
3360 3362
3363struct drbd_tconn *drbd_new_tconn(char *name)
3364{
3365 struct drbd_tconn *tconn;
3366
3367 tconn = kzalloc(sizeof(struct drbd_tconn), GFP_KERNEL);
3368 if (!tconn)
3369 return NULL;
3370
3371 tconn->name = kstrdup(name, GFP_KERNEL);
3372 if (!tconn->name)
3373 goto fail;
3374
3375 write_lock_irq(&global_state_lock);
3376 list_add(&tconn->all_tconn, &drbd_tconns);
3377 write_unlock_irq(&global_state_lock);
3378
3379 return tconn;
3380
3381fail:
3382 kfree(tconn->name);
3383 kfree(tconn);
3384
3385 return NULL;
3386}
3387
3388void drbd_free_tconn(struct drbd_tconn *tconn)
3389{
3390 write_lock_irq(&global_state_lock);
3391 list_del(&tconn->all_tconn);
3392 write_unlock_irq(&global_state_lock);
3393
3394 kfree(tconn->name);
3395 kfree(tconn);
3396}
3397
3361struct drbd_conf *drbd_new_device(unsigned int minor) 3398struct drbd_conf *drbd_new_device(unsigned int minor)
3362{ 3399{
3363 struct drbd_conf *mdev; 3400 struct drbd_conf *mdev;
@@ -3368,9 +3405,14 @@ struct drbd_conf *drbd_new_device(unsigned int minor)
3368 mdev = kzalloc(sizeof(struct drbd_conf), GFP_KERNEL); 3405 mdev = kzalloc(sizeof(struct drbd_conf), GFP_KERNEL);
3369 if (!mdev) 3406 if (!mdev)
3370 return NULL; 3407 return NULL;
3408 mdev->tconn = drbd_new_tconn("dummy");
3409 if (!mdev->tconn)
3410 goto out_no_tconn;
3411
3371 if (!zalloc_cpumask_var(&mdev->cpu_mask, GFP_KERNEL)) 3412 if (!zalloc_cpumask_var(&mdev->cpu_mask, GFP_KERNEL))
3372 goto out_no_cpumask; 3413 goto out_no_cpumask;
3373 3414
3415 mdev->tconn->volume0 = mdev;
3374 mdev->minor = minor; 3416 mdev->minor = minor;
3375 3417
3376 drbd_init_set_defaults(mdev); 3418 drbd_init_set_defaults(mdev);
@@ -3447,6 +3489,8 @@ out_no_disk:
3447out_no_q: 3489out_no_q:
3448 free_cpumask_var(mdev->cpu_mask); 3490 free_cpumask_var(mdev->cpu_mask);
3449out_no_cpumask: 3491out_no_cpumask:
3492 drbd_free_tconn(mdev->tconn);
3493out_no_tconn:
3450 kfree(mdev); 3494 kfree(mdev);
3451 return NULL; 3495 return NULL;
3452} 3496}
@@ -3526,6 +3570,7 @@ int __init drbd_init(void)
3526 } 3570 }
3527 3571
3528 rwlock_init(&global_state_lock); 3572 rwlock_init(&global_state_lock);
3573 INIT_LIST_HEAD(&drbd_tconns);
3529 3574
3530 printk(KERN_INFO "drbd: initialized. " 3575 printk(KERN_INFO "drbd: initialized. "
3531 "Version: " REL_VERSION " (api:%d/proto:%d-%d)\n", 3576 "Version: " REL_VERSION " (api:%d/proto:%d-%d)\n",