#define UUID_NEW_BM_OFFSET ((u64)0x0001000000000000ULL)
struct drbd_conf;
+struct drbd_tconn;
/* to shorten dev_warn(DEV, "msg"); and relatives statements */
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;
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 */
* 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 */
bdput(mdev->this_bdev);
drbd_free_resources(mdev);
+ drbd_free_tconn(mdev->tconn);
drbd_release_ee_lists(mdev);
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;
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);
out_no_q:
free_cpumask_var(mdev->cpu_mask);
out_no_cpumask:
+ drbd_free_tconn(mdev->tconn);
+out_no_tconn:
kfree(mdev);
return NULL;
}
}
rwlock_init(&global_state_lock);
+ INIT_LIST_HEAD(&drbd_tconns);
printk(KERN_INFO "drbd: initialized. "
"Version: " REL_VERSION " (api:%d/proto:%d-%d)\n",