#define div_floor(A, B) ((A)/(B))
extern struct ratelimit_state drbd_ratelimit_state;
-extern struct idr minors; /* RCU, updates: genl_lock() */
+extern struct idr drbd_devices; /* RCU, updates: genl_lock() */
extern struct list_head drbd_connections; /* RCU, updates: genl_lock() */
extern const char *cmdname(enum drbd_packet cmd);
static inline struct drbd_device *minor_to_device(unsigned int minor)
{
- return (struct drbd_device *)idr_find(&minors, minor);
+ return (struct drbd_device *)idr_find(&drbd_devices, minor);
}
static inline struct drbd_peer_device *first_peer_device(struct drbd_device *device)
extern int conn_lowest_minor(struct drbd_connection *connection);
enum drbd_ret_code drbd_create_minor(struct drbd_connection *connection, unsigned int minor, int vnr);
-extern void drbd_minor_destroy(struct kref *kref);
+extern void drbd_destroy_device(struct kref *kref);
extern int set_resource_options(struct drbd_connection *connection, struct res_opts *res_opts);
extern struct drbd_connection *conn_create(const char *name, struct res_opts *res_opts);
-extern void conn_destroy(struct kref *kref);
+extern void drbd_destroy_connection(struct kref *kref);
struct drbd_connection *conn_get_by_name(const char *name);
extern struct drbd_connection *conn_get_by_addrs(void *my_addr, int my_addr_len,
void *peer_addr, int peer_addr_len);
/* in 2.6.x, our device mapping and config info contains our virtual gendisks
* as member "struct gendisk *vdisk;"
*/
-struct idr minors;
+struct idr drbd_devices;
struct list_head drbd_connections; /* list of struct drbd_connection */
struct kmem_cache *drbd_request_cache;
/* Release mod reference taken when thread was started */
- kref_put(&connection->kref, &conn_destroy);
+ kref_put(&connection->kref, drbd_destroy_connection);
module_put(THIS_MODULE);
return retval;
}
if (IS_ERR(nt)) {
conn_err(connection, "Couldn't start thread\n");
- kref_put(&connection->kref, &conn_destroy);
+ kref_put(&connection->kref, drbd_destroy_connection);
module_put(THIS_MODULE);
return false;
}
}
/* caution. no locking. */
-void drbd_minor_destroy(struct kref *kref)
+void drbd_destroy_device(struct kref *kref)
{
struct drbd_device *device = container_of(kref, struct drbd_device, kref);
struct drbd_connection *connection = first_peer_device(device)->connection;
kfree(first_peer_device(device));
kfree(device);
- kref_put(&connection->kref, &conn_destroy);
+ kref_put(&connection->kref, drbd_destroy_connection);
}
/* One global retry thread, if we need to push back some bio and have it
drbd_genl_unregister();
- idr_for_each_entry(&minors, device, i) {
- idr_remove(&minors, device_to_minor(device));
+ idr_for_each_entry(&drbd_devices, device, i) {
+ idr_remove(&drbd_devices, device_to_minor(device));
idr_remove(&first_peer_device(device)->connection->volumes, device->vnr);
destroy_workqueue(device->submit.wq);
del_gendisk(device->vdisk);
/* synchronize_rcu(); No other threads running at this point */
- kref_put(&device->kref, &drbd_minor_destroy);
+ kref_put(&device->kref, drbd_destroy_device);
}
/* not _rcu since, no other updater anymore. Genl already unregistered */
list_for_each_entry_safe(connection, tmp, &drbd_connections, connections) {
list_del(&connection->connections); /* not _rcu no proc, not other threads */
/* synchronize_rcu(); */
- kref_put(&connection->kref, &conn_destroy);
+ kref_put(&connection->kref, drbd_destroy_connection);
}
drbd_destroy_mempools();
unregister_blkdev(DRBD_MAJOR, "drbd");
- idr_destroy(&minors);
+ idr_destroy(&drbd_devices);
printk(KERN_INFO "drbd: module cleanup done.\n");
}
return NULL;
}
-void conn_destroy(struct kref *kref)
+void drbd_destroy_connection(struct kref *kref)
{
struct drbd_connection *connection = container_of(kref, struct drbd_connection, kref);
device->read_requests = RB_ROOT;
device->write_requests = RB_ROOT;
- minor_got = idr_alloc(&minors, device, minor, minor + 1, GFP_KERNEL);
+ minor_got = idr_alloc(&drbd_devices, device, minor, minor + 1, GFP_KERNEL);
if (minor_got < 0) {
if (minor_got == -ENOSPC) {
err = ERR_MINOR_EXISTS;
out_idr_remove_vol:
idr_remove(&connection->volumes, vnr_got);
out_idr_remove_minor:
- idr_remove(&minors, minor_got);
+ idr_remove(&drbd_devices, minor_got);
synchronize_rcu();
out_no_minor_idr:
drbd_bm_cleanup(device);
out_no_disk:
blk_cleanup_queue(q);
out_no_q:
- kref_put(&connection->kref, &conn_destroy);
+ kref_put(&connection->kref, drbd_destroy_connection);
out_no_peer_device:
kfree(device);
return err;
init_waitqueue_head(&drbd_pp_wait);
drbd_proc = NULL; /* play safe for drbd_cleanup */
- idr_init(&minors);
+ idr_init(&drbd_devices);
rwlock_init(&global_state_lock);
INIT_LIST_HEAD(&drbd_connections);
kref_get(&device->kref);
rcu_read_unlock();
drbd_md_sync(device);
- kref_put(&device->kref, &drbd_minor_destroy);
+ kref_put(&device->kref, drbd_destroy_device);
rcu_read_lock();
}
rcu_read_unlock();
// int drbd_adm_create_resource(struct sk_buff *skb, struct genl_info *info);
// int drbd_adm_delete_resource(struct sk_buff *skb, struct genl_info *info);
-int drbd_adm_add_minor(struct sk_buff *skb, struct genl_info *info);
-int drbd_adm_delete_minor(struct sk_buff *skb, struct genl_info *info);
+int drbd_adm_new_minor(struct sk_buff *skb, struct genl_info *info);
+int drbd_adm_del_minor(struct sk_buff *skb, struct genl_info *info);
int drbd_adm_new_resource(struct sk_buff *skb, struct genl_info *info);
int drbd_adm_del_resource(struct sk_buff *skb, struct genl_info *info);
static int drbd_adm_finish(struct genl_info *info, int retcode)
{
if (adm_ctx.connection) {
- kref_put(&adm_ctx.connection->kref, &conn_destroy);
+ kref_put(&adm_ctx.connection->kref, drbd_destroy_connection);
adm_ctx.connection = NULL;
}
conn_try_outdate_peer(connection);
- kref_put(&connection->kref, &conn_destroy);
+ kref_put(&connection->kref, drbd_destroy_connection);
return 0;
}
opa = kthread_run(_try_outdate_peer_async, connection, "drbd_async_h");
if (IS_ERR(opa)) {
conn_err(connection, "out of mem, failed to invoke fence-peer helper\n");
- kref_put(&connection->kref, &conn_destroy);
+ kref_put(&connection->kref, drbd_destroy_connection);
}
}
* on each iteration.
*/
- /* synchronize with conn_create()/conn_destroy() */
+ /* synchronize with conn_create()/drbd_destroy_connection() */
rcu_read_lock();
/* revalidate iterator position */
list_for_each_entry_rcu(tmp, &drbd_connections, connections) {
if (!connection)
return -ENODEV;
- kref_put(&connection->kref, &conn_destroy); /* get_one_status() (re)validates connection by itself */
+ kref_put(&connection->kref, drbd_destroy_connection); /* get_one_status() (re)validates connection by itself */
/* prime iterators, and set "filter" mode mark:
* only dump this connection. */
return 0;
}
-int drbd_adm_add_minor(struct sk_buff *skb, struct genl_info *info)
+int drbd_adm_new_minor(struct sk_buff *skb, struct genl_info *info)
{
struct drbd_genlmsghdr *dh = info->userhdr;
enum drbd_ret_code retcode;
return 0;
}
-static enum drbd_ret_code adm_delete_minor(struct drbd_device *device)
+static enum drbd_ret_code adm_del_minor(struct drbd_device *device)
{
if (device->state.disk == D_DISKLESS &&
/* no need to be device->state.conn == C_STANDALONE &&
_drbd_request_state(device, NS(conn, C_WF_REPORT_PARAMS),
CS_VERBOSE + CS_WAIT_COMPLETE);
idr_remove(&first_peer_device(device)->connection->volumes, device->vnr);
- idr_remove(&minors, device_to_minor(device));
+ idr_remove(&drbd_devices, device_to_minor(device));
destroy_workqueue(device->submit.wq);
del_gendisk(device->vdisk);
synchronize_rcu();
- kref_put(&device->kref, &drbd_minor_destroy);
+ kref_put(&device->kref, drbd_destroy_device);
return NO_ERROR;
} else
return ERR_MINOR_CONFIGURED;
}
-int drbd_adm_delete_minor(struct sk_buff *skb, struct genl_info *info)
+int drbd_adm_del_minor(struct sk_buff *skb, struct genl_info *info)
{
enum drbd_ret_code retcode;
if (retcode != NO_ERROR)
goto out;
- retcode = adm_delete_minor(adm_ctx.device);
+ retcode = adm_del_minor(adm_ctx.device);
out:
drbd_adm_finish(info, retcode);
return 0;
/* delete volumes */
idr_for_each_entry(&adm_ctx.connection->volumes, device, i) {
- retcode = adm_delete_minor(device);
+ retcode = adm_del_minor(device);
if (retcode != NO_ERROR) {
/* "can not happen" */
drbd_msg_put_info("failed to delete volume");
if (conn_lowest_minor(adm_ctx.connection) < 0) {
list_del_rcu(&adm_ctx.connection->connections);
synchronize_rcu();
- kref_put(&adm_ctx.connection->kref, &conn_destroy);
+ kref_put(&adm_ctx.connection->kref, drbd_destroy_connection);
retcode = NO_ERROR;
} else {
if (conn_lowest_minor(adm_ctx.connection) < 0) {
list_del_rcu(&adm_ctx.connection->connections);
synchronize_rcu();
- kref_put(&adm_ctx.connection->kref, &conn_destroy);
+ kref_put(&adm_ctx.connection->kref, drbd_destroy_connection);
retcode = NO_ERROR;
} else {
*/
rcu_read_lock();
- idr_for_each_entry(&minors, device, i) {
+ idr_for_each_entry(&drbd_devices, device, i) {
if (prev_i != i - 1)
seq_printf(seq, "\n");
prev_i = i;
clear_bit(DISCARD_MY_DATA, &device->flags);
drbd_connected(device);
- kref_put(&device->kref, &drbd_minor_destroy);
+ kref_put(&device->kref, drbd_destroy_device);
rcu_read_lock();
}
rcu_read_unlock();
drbd_bump_write_ordering(connection, WO_drain_io);
}
put_ldev(device);
- kref_put(&device->kref, &drbd_minor_destroy);
+ kref_put(&device->kref, drbd_destroy_device);
rcu_read_lock();
if (rv)
kref_get(&device->kref);
rcu_read_unlock();
drbd_wait_ee_list_empty(device, &device->active_ee);
- kref_put(&device->kref, &drbd_minor_destroy);
+ kref_put(&device->kref, drbd_destroy_device);
rcu_read_lock();
}
rcu_read_unlock();
kref_get(&device->kref);
rcu_read_unlock();
drbd_disconnected(device);
- kref_put(&device->kref, &drbd_minor_destroy);
+ kref_put(&device->kref, &drbd_destroy_device);
rcu_read_lock();
}
rcu_read_unlock();
kref_get(&device->kref);
rcu_read_unlock();
if (drbd_finish_peer_reqs(device)) {
- kref_put(&device->kref, &drbd_minor_destroy);
+ kref_put(&device->kref, drbd_destroy_device);
return 1;
}
- kref_put(&device->kref, &drbd_minor_destroy);
+ kref_put(&device->kref, drbd_destroy_device);
rcu_read_lock();
}
set_bit(SIGNAL_ASENDER, &connection->flags);
spin_unlock_irq(&connection->req_lock);
}
}
- kref_put(&connection->kref, &conn_destroy);
+ kref_put(&connection->kref, drbd_destroy_connection);
conn_md_sync(connection);
int i, rv = 0;
rcu_read_lock();
- idr_for_each_entry(&minors, odev, i) {
+ idr_for_each_entry(&drbd_devices, odev, i) {
if (odev->state.conn == C_STANDALONE && odev->state.disk == D_DISKLESS)
continue;
if (!_drbd_may_sync_now(odev))
int i, rv = 0;
rcu_read_lock();
- idr_for_each_entry(&minors, odev, i) {
+ idr_for_each_entry(&drbd_devices, odev, i) {
if (odev->state.conn == C_STANDALONE && odev->state.disk == D_DISKLESS)
continue;
if (odev->state.aftr_isp) {
kref_get(&device->kref);
rcu_read_unlock();
drbd_device_cleanup(device);
- kref_put(&device->kref, &drbd_minor_destroy);
+ kref_put(&device->kref, drbd_destroy_device);
rcu_read_lock();
}
rcu_read_unlock();
)
/* add DRBD minor devices as volumes to resources */
-GENL_op(DRBD_ADM_NEW_MINOR, 5, GENL_doit(drbd_adm_add_minor),
+GENL_op(DRBD_ADM_NEW_MINOR, 5, GENL_doit(drbd_adm_new_minor),
GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
-GENL_op(DRBD_ADM_DEL_MINOR, 6, GENL_doit(drbd_adm_delete_minor),
+GENL_op(DRBD_ADM_DEL_MINOR, 6, GENL_doit(drbd_adm_del_minor),
GENL_tla_expected(DRBD_NLA_CFG_CONTEXT, DRBD_F_REQUIRED))
/* add or delete resources */