DRBD code reorganization
Subsystems (2)
Philipp Reisner
maintainercover DRBD code reorganization
Hi,
we are preparing DRBD for the ability to have multiple connections, in other words the ability to mirror a single block device to multiple peers concurrently.
This patch set is the second half of a preparation step. With part 1 it introduces a new in memory object (struct drbd_resource), and renames the current in memory objects for clarity.
This patch set does not introduce any new functionality.
Andreas Gruenbacher (27):
drbd: Rename net_conf variables old_conf -> old_net_conf and new_conf
-> new_net_conf
drbd: Iterate over all connections
drbd: drbd_adm_prepare(): Only set adm_ctx.connection when a
connection is requested
drbd: Move conf_mutex from connection to resource
drbd: Move susp, susp_nod, susp_fen from connection to resource
drbd: Define the size of res_opts->cpu_mask in a single place
drbd: Move cpu_mask from connection to resource
drbd: Rename drbdd_init() -> drbd_receiver()
drbd: Function prototype cleanups
drbd: drbd_csum_bio(), drbd_csum_ee(): Remove unused device argument
drbd: Replace vnr_to_mdev() with conn_peer_device()
drbd: Pass a peer device to a number of fuctions
drbd: Kill drbd_task_to_thread_name()
drbd: Remove useless assertion
drbd: Move string function prototypes from linux/drbd.h to
drbd_string.h
drbd: Rename w_prev_work_done -> w_complete
drbd: Create a dedicated struct drbd_device_work
drbd: Turn conn_flush_workqueue() into drbd_flush_workqueue()
drbd: struct after_conn_state_chg_work: Use drbd_work instead of
drbd_device_work
drbd: struct drbd_peer_request: Use drbd_work instead of
drbd_device_work
drbd: Make w_make_resync_request() static
drbd: Turn w_make_ov_request and make_resync_request into "normal"
functions
drbd: In the worker thread, process drbd_work instead of
drbd_device_work items
drbd: Get rid of first_peer_device() in handle_write_conflicts()
drbd: Remove unused parameter of wire_flags_to_bio()
drbd: Use the right peer device
drbd: Add drbd_thread->resource and make drbd_thread->connection
optional
drivers/block/drbd/drbd_actlog.c | 16 +- drivers/block/drbd/drbd_bitmap.c | 16 +- drivers/block/drbd/drbd_int.h | 148 ++++----- drivers/block/drbd/drbd_main.c | 558 ++++++++++++++++++--------------- drivers/block/drbd/drbd_nl.c | 260 +++++++-------- drivers/block/drbd/drbd_receiver.c | 608 ++++++++++++++++++++---------------- drivers/block/drbd/drbd_req.c | 59 ++-- drivers/block/drbd/drbd_req.h | 8 +- drivers/block/drbd/drbd_state.c | 116 +++---- drivers/block/drbd/drbd_strings.c | 1 + drivers/block/drbd/drbd_strings.h | 9 + drivers/block/drbd/drbd_worker.c | 216 ++++++------- include/linux/drbd.h | 8 +- include/linux/drbd_genl.h | 2 +- 14 files changed, 1074 insertions(+), 951 deletions(-) create mode 100644 drivers/block/drbd/drbd_strings.h
Signature · 1 line
1.7.9.5
Philipp Reisner
maintainerPATCH 1/27 drbd: Rename net_conf variables old_conf -> old_net_conf and new_conf -> new_net_conf
From: Andreas Gruenbacher <[email protected]>
--- drivers/block/drbd/drbd_nl.c | 92 +++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 46 deletions(-)
drivers/block/drbd/drbd_nl.c +46 -46
@@ -1921,29 +1921,29 @@ static bool conn_ov_running(struct drbd_connection *connection) }static enum drbd_ret_code -_check_net_options (struct drbd_connection *connection,struct net_conf *old_conf,struct net_conf *new_conf) +_check_net_options (struct drbd_connection *connection,struct net_conf *old_net_conf,struct net_conf *new_net_conf) {struct drbd_peer_device *peer_device;int i; -if (old_conf && connection->cstate ==C_WF_REPORT_PARAMS && connection->agreed_pro_version <100 ) { -if (new_conf->wire_protocol != old_conf->wire_protocol) +if (old_net_conf && connection->cstate ==C_WF_REPORT_PARAMS && connection->agreed_pro_version <100 ) { +if (new_net_conf->wire_protocol != old_net_conf->wire_protocol)return ERR_NEED_APV_100 ; -if (new_conf->two_primaries != old_conf->two_primaries) +if (new_net_conf->two_primaries != old_net_conf->two_primaries)return ERR_NEED_APV_100 ; -if (strcmp (new_conf->integrity_alg, old_conf->integrity_alg)) +if (strcmp (new_net_conf->integrity_alg, old_net_conf->integrity_alg))return ERR_NEED_APV_100 ; } -if (!new_conf->two_primaries && +if (!new_net_conf->two_primaries &&conn_highest_role (connection) ==R_PRIMARY &&conn_highest_peer (connection) ==R_PRIMARY )return ERR_NEED_ALLOW_TWO_PRI ; -if (new_conf->two_primaries && - (new_conf->wire_protocol !=DRBD_PROT_C )) +if (new_net_conf->two_primaries && + (new_net_conf->wire_protocol !=DRBD_PROT_C ))return ERR_NOT_PROTO_C ;idr_for_each_entry (&connection->peer_devices, peer_device, i) {
@@ -1951,28 +1951,28 @@ _check_net_options(struct drbd_connection *connection, struct net_conf *old_confif (get_ldev (device)) {enum drbd_fencing_p fp =rcu_dereference (device->ldev->disk_conf)->fencing;put_ldev (device); -if (new_conf->wire_protocol ==DRBD_PROT_A && fp ==FP_STONITH ) +if (new_net_conf->wire_protocol ==DRBD_PROT_A && fp ==FP_STONITH )return ERR_STONITH_AND_PROT_A ; } -if (device->state.role ==R_PRIMARY && new_conf->discard_my_data) +if (device->state.role ==R_PRIMARY && new_net_conf->discard_my_data)return ERR_DISCARD_IMPOSSIBLE ; } -if (new_conf->on_congestion !=OC_BLOCK && new_conf->wire_protocol !=DRBD_PROT_A ) +if (new_net_conf->on_congestion !=OC_BLOCK && new_net_conf->wire_protocol !=DRBD_PROT_A )return ERR_CONG_NOT_PROTO_A ;return NO_ERROR ; }static enum drbd_ret_code -check_net_options (struct drbd_connection *connection,struct net_conf *new_conf) +check_net_options (struct drbd_connection *connection,struct net_conf *new_net_conf) {static enum drbd_ret_code rv;struct drbd_peer_device *peer_device;int i;rcu_read_lock (); - rv =_check_net_options (connection,rcu_dereference (connection->net_conf), new_conf); + rv =_check_net_options (connection,rcu_dereference (connection->net_conf), new_net_conf);rcu_read_unlock ();/* connection->volumes protected by genl_lock() here */
@@ -2010,26 +2010,26 @@ alloc_hash(struct crypto_hash **tfm, char *tfm_name, int err_alg) }static enum drbd_ret_code -alloc_crypto (struct crypto *crypto,struct net_conf *new_conf) +alloc_crypto (struct crypto *crypto,struct net_conf *new_net_conf) {char hmac_name[CRYPTO_MAX_ALG_NAME ];enum drbd_ret_code rv; - rv =alloc_hash (&crypto->csums_tfm, new_conf->csums_alg, + rv =alloc_hash (&crypto->csums_tfm, new_net_conf->csums_alg,ERR_CSUMS_ALG );if (rv !=NO_ERROR )return rv; - rv =alloc_hash (&crypto->verify_tfm, new_conf->verify_alg, + rv =alloc_hash (&crypto->verify_tfm, new_net_conf->verify_alg,ERR_VERIFY_ALG );if (rv !=NO_ERROR )return rv; - rv =alloc_hash (&crypto->integrity_tfm, new_conf->integrity_alg, + rv =alloc_hash (&crypto->integrity_tfm, new_net_conf->integrity_alg,ERR_INTEGRITY_ALG );if (rv !=NO_ERROR )return rv; -if (new_conf->cram_hmac_alg[0 ] !=0 ) { +if (new_net_conf->cram_hmac_alg[0 ] !=0 ) {snprintf (hmac_name,CRYPTO_MAX_ALG_NAME ,"hmac(%s)" , - new_conf->cram_hmac_alg); + new_net_conf->cram_hmac_alg); rv =alloc_hash (&crypto->cram_hmac_tfm, hmac_name,ERR_AUTH_ALG );
@@ -2050,7 +2050,7 @@ int drbd_adm_net_opts(struct sk_buff *skb, struct genl_info *info) {enum drbd_ret_code retcode;struct drbd_connection *connection; -struct net_conf *old_conf, *new_conf =NULL ; +struct net_conf *old_net_conf, *new_net_conf =NULL ;int err;int ovr;/* online verify running */ int rsr;/* re-sync running */
@@ -2064,8 +2064,8 @@ int drbd_adm_net_opts(struct sk_buff *skb, struct genl_info *info) connection = adm_ctx.connection; - new_conf =kzalloc (sizeof (struct net_conf ),GFP_KERNEL ); -if (!new_conf) { + new_net_conf =kzalloc (sizeof (struct net_conf ),GFP_KERNEL ); +if (!new_net_conf) { retcode =ERR_NOMEM ; goto out; }
@@ -2074,48 +2074,48 @@ int drbd_adm_net_opts(struct sk_buff *skb, struct genl_info *info)mutex_lock (&connection->data.mutex);mutex_lock (&connection->conf_update); - old_conf = connection->net_conf; + old_net_conf = connection->net_conf; -if (!old_conf) { +if (!old_net_conf) {drbd_msg_put_info ("net conf missing, try connect" ); retcode =ERR_INVALID_REQUEST ; goto fail; } - *new_conf = *old_conf; + *new_net_conf = *old_net_conf;if (should_set_defaults (info)) -set_net_conf_defaults (new_conf); +set_net_conf_defaults (new_net_conf); - err =net_conf_from_attrs_for_change (new_conf, info); + err =net_conf_from_attrs_for_change (new_net_conf, info);if (err && err != -ENOMSG ) { retcode =ERR_MANDATORY_TAG ;drbd_msg_put_info (from_attrs_err_to_txt (err)); goto fail; } - retcode =check_net_options (connection, new_conf); + retcode =check_net_options (connection, new_net_conf);if (retcode !=NO_ERROR ) goto fail;/* re-sync running */ rsr =conn_resync_running (connection); -if (rsr &&strcmp (new_conf->csums_alg, old_conf->csums_alg)) { +if (rsr &&strcmp (new_net_conf->csums_alg, old_net_conf->csums_alg)) { retcode =ERR_CSUMS_RESYNC_RUNNING ; goto fail; }/* online verify running */ ovr =conn_ov_running (connection); -if (ovr &&strcmp (new_conf->verify_alg, old_conf->verify_alg)) { +if (ovr &&strcmp (new_net_conf->verify_alg, old_net_conf->verify_alg)) { retcode =ERR_VERIFY_RUNNING ; goto fail; } - retcode =alloc_crypto (&crypto, new_conf); + retcode =alloc_crypto (&crypto, new_net_conf);if (retcode !=NO_ERROR ) goto fail; -rcu_assign_pointer (connection->net_conf, new_conf); +rcu_assign_pointer (connection->net_conf, new_net_conf);if (!rsr) {crypto_free_hash (connection->csums_tfm);
@@ -2140,7 +2140,7 @@ int drbd_adm_net_opts(struct sk_buff *skb, struct genl_info *info)mutex_unlock (&connection->conf_update);mutex_unlock (&connection->data.mutex);synchronize_rcu (); -kfree (old_conf); +kfree (old_net_conf);if (connection->cstate >=C_WF_REPORT_PARAMS )drbd_send_sync_param (minor_to_device (conn_lowest_minor (connection)));
@@ -2151,7 +2151,7 @@ int drbd_adm_net_opts(struct sk_buff *skb, struct genl_info *info)mutex_unlock (&connection->conf_update);mutex_unlock (&connection->data.mutex);free_crypto (&crypto); -kfree (new_conf); +kfree (new_net_conf); done:conn_reconfig_done (connection); out:
@@ -2162,7 +2162,7 @@ int drbd_adm_net_opts(struct sk_buff *skb, struct genl_info *info)int drbd_adm_connect (struct sk_buff *skb,struct genl_info *info) {struct drbd_peer_device *peer_device; -struct net_conf *old_conf, *new_conf =NULL ; +struct net_conf *old_net_conf, *new_net_conf =NULL ;struct crypto crypto = { };struct drbd_resource *resource;struct drbd_connection *connection;
@@ -2212,41 +2212,41 @@ int drbd_adm_connect(struct sk_buff *skb, struct genl_info *info) }/* allocation not in the IO path, drbdsetup / netlink process context */ - new_conf =kzalloc (sizeof (*new_conf),GFP_KERNEL ); -if (!new_conf) { + new_net_conf =kzalloc (sizeof (*new_net_conf),GFP_KERNEL ); +if (!new_net_conf) { retcode =ERR_NOMEM ; goto fail; } -set_net_conf_defaults (new_conf); +set_net_conf_defaults (new_net_conf); - err =net_conf_from_attrs (new_conf, info); + err =net_conf_from_attrs (new_net_conf, info);if (err && err != -ENOMSG ) { retcode =ERR_MANDATORY_TAG ;drbd_msg_put_info (from_attrs_err_to_txt (err)); goto fail; } - retcode =check_net_options (connection, new_conf); + retcode =check_net_options (connection, new_net_conf);if (retcode !=NO_ERROR ) goto fail; - retcode =alloc_crypto (&crypto, new_conf); + retcode =alloc_crypto (&crypto, new_net_conf);if (retcode !=NO_ERROR ) goto fail; - ((char *)new_conf->shared_secret)[SHARED_SECRET_MAX -1 ] =0 ; + ((char *)new_net_conf->shared_secret)[SHARED_SECRET_MAX -1 ] =0 ;conn_flush_workqueue (connection);mutex_lock (&connection->conf_update); - old_conf = connection->net_conf; -if (old_conf) { + old_net_conf = connection->net_conf; +if (old_net_conf) { retcode =ERR_NET_CONFIGURED ;mutex_unlock (&connection->conf_update); goto fail; } -rcu_assign_pointer (connection->net_conf, new_conf); +rcu_assign_pointer (connection->net_conf, new_net_conf);conn_free_crypto (connection); connection->cram_hmac_tfm = crypto.cram_hmac_tfm;
@@ -2277,7 +2277,7 @@ int drbd_adm_connect(struct sk_buff *skb, struct genl_info *info) fail:free_crypto (&crypto); -kfree (new_conf); +kfree (new_net_conf);conn_reconfig_done (connection); out:
Signature · 1 line
1.7.9.5
Philipp Reisner
maintainerPATCH 2/27 drbd: Iterate over all connections
In reply to Philipp ReisnerFrom: Andreas Gruenbacher <[email protected]>
in drbd_adm_down(), drbd_create_device() and drbd_set_role()
--- drivers/block/drbd/drbd_main.c | 55 +++++++++++++++++++------------- drivers/block/drbd/drbd_nl.c | 68 ++++++++++++++++++++++------------------ 2 files changed, 70 insertions(+), 53 deletions(-)
drivers/block/drbd/drbd_main.c +33 -22
@@ -2663,9 +2663,9 @@ int init_submitter(struct drbd_device *device)enum drbd_ret_code drbd_create_device (struct drbd_resource *resource,unsigned int minor,int vnr) { -struct drbd_connection *connection =first_connection (resource); +struct drbd_connection *connection;struct drbd_device *device; -struct drbd_peer_device *peer_device; +struct drbd_peer_device *peer_device, *tmp_peer_device;struct gendisk *disk;struct request_queue *q;int id;
@@ -2681,18 +2681,8 @@ enum drbd_ret_code drbd_create_device(struct drbd_resource *resource, unsigned ireturn ERR_NOMEM ;kref_init (&device->kref); - peer_device =kzalloc (sizeof (struct drbd_peer_device ),GFP_KERNEL ); -if (!peer_device) - goto out_no_peer_device; - -INIT_LIST_HEAD (&device->peer_devices); -list_add (&peer_device->peer_devices, &device->peer_devices);kref_get (&resource->kref); device->resource = resource; -kref_get (&connection->kref); - peer_device->connection = connection; - peer_device->device = device; - device->minor = minor; device->vnr = vnr;
@@ -2763,15 +2753,27 @@ enum drbd_ret_code drbd_create_device(struct drbd_resource *resource, unsigned i }kref_get (&device->kref); - id =idr_alloc (&connection->peer_devices, peer_device, vnr, vnr +1 ,GFP_KERNEL ); -if (id <0 ) { -if (id == -ENOSPC ) { - err =ERR_INVALID_REQUEST ; -drbd_msg_put_info ("requested volume exists already" ); +INIT_LIST_HEAD (&device->peer_devices); +for_each_connection (connection, resource) { + peer_device =kzalloc (sizeof (struct drbd_peer_device ),GFP_KERNEL ); +if (!peer_device) + goto out_idr_remove_from_resource; + peer_device->connection = connection; + peer_device->device = device; + +list_add (&peer_device->peer_devices, &device->peer_devices); +kref_get (&device->kref); + + id =idr_alloc (&connection->peer_devices, peer_device, vnr, vnr +1 ,GFP_KERNEL ); +if (id <0 ) { +if (id == -ENOSPC ) { + err =ERR_INVALID_REQUEST ; +drbd_msg_put_info ("requested volume exists already" ); + } + goto out_idr_remove_from_resource; } - goto out_idr_remove_from_resource; +kref_get (&connection->kref); } -kref_get (&device->kref);if (init_submitter (device)) { err =ERR_NOMEM ;
@@ -2782,7 +2784,7 @@ enum drbd_ret_code drbd_create_device(struct drbd_resource *resource, unsigned iadd_disk (disk);/* inherit the connection state */ - device->state.conn = connection->cstate; + device->state.conn =first_connection (resource)->cstate;if (device->state.conn ==C_WF_REPORT_PARAMS )drbd_connected (device);
@@ -2791,6 +2793,17 @@ enum drbd_ret_code drbd_create_device(struct drbd_resource *resource, unsigned i out_idr_remove_vol:idr_remove (&connection->peer_devices, vnr); out_idr_remove_from_resource: +for_each_connection (connection, resource) { + peer_device =idr_find (&connection->peer_devices, vnr); +if (peer_device) { +idr_remove (&connection->peer_devices, vnr); +kref_put (&connection->kref, drbd_destroy_connection); + } + } +for_each_peer_device_safe (peer_device, tmp_peer_device, device) { +list_del (&peer_device->peer_devices); +kfree (peer_device); + }idr_remove (&resource->devices, vnr); out_idr_remove_minor:idr_remove (&drbd_devices, minor);
@@ -2804,9 +2817,7 @@ out_no_io_page: out_no_disk:blk_cleanup_queue (q); out_no_q: -kref_put (&connection->kref, drbd_destroy_connection);kref_put (&resource->kref, drbd_destroy_resource); -out_no_peer_device:kfree (device);return err; }
drivers/block/drbd/drbd_nl.c +37 -31
111 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Philipp Reisner
maintainerPATCH 3/27 drbd: drbd_adm_prepare(): Only set adm_ctx.connection when a connection is requested
In reply to Philipp ReisnerFrom: Andreas Gruenbacher <[email protected]>
Also change drbd_adm_connect() to expect a resource after it requested one.
--- drivers/block/drbd/drbd_nl.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/block/drbd/drbd_nl.c +2 -6
@@ -216,10 +216,6 @@ static int drbd_adm_prepare(struct sk_buff *skb, struct genl_info *info, adm_ctx.device =minor_to_device (d_in->minor);if (adm_ctx.resource_name) { adm_ctx.resource =drbd_find_resource (adm_ctx.resource_name); -if (adm_ctx.resource) { - adm_ctx.connection =first_connection (adm_ctx.resource); -kref_get (&adm_ctx.connection->kref); - } }if (!adm_ctx.device && (flags &DRBD_ADM_NEED_MINOR )) {
@@ -234,7 +230,7 @@ static int drbd_adm_prepare(struct sk_buff *skb, struct genl_info *info, }if (flags &DRBD_ADM_NEED_CONNECTION ) { -if (adm_ctx.connection && !(flags &DRBD_ADM_NEED_RESOURCE )) { +if (adm_ctx.resource) {drbd_msg_put_info ("no resource name expected" );return ERR_INVALID_REQUEST ; }
@@ -2211,7 +2207,7 @@ int drbd_adm_connect(struct sk_buff *skb, struct genl_info *info) } } - connection = adm_ctx.connection; + connection =first_connection (adm_ctx.resource);conn_reconfig_start (connection);if (connection->cstate >C_STANDALONE ) {
Signature · 1 line
1.7.9.5
Philipp Reisner
maintainerPATCH 4/27 drbd: Move conf_mutex from connection to resource
In reply to Philipp ReisnerFrom: Andreas Gruenbacher <[email protected]>
--- drivers/block/drbd/drbd_int.h | 15 +++-- drivers/block/drbd/drbd_main.c | 36 +++++------ drivers/block/drbd/drbd_nl.c | 50 ++++++++-------- drivers/block/drbd/drbd_receiver.c | 116 ++++++++++++++++++------------------ drivers/block/drbd/drbd_req.c | 18 +++--- drivers/block/drbd/drbd_req.h | 4 +- drivers/block/drbd/drbd_state.c | 48 +++++++-------- drivers/block/drbd/drbd_worker.c | 34 +++++------ 8 files changed, 160 insertions(+), 161 deletions(-)
drivers/block/drbd/drbd_int.h +7 -8
@@ -513,7 +513,7 @@ struct drbd_backing_dev {struct block_device *backing_bdev;struct block_device *md_bdev;struct drbd_md md; -struct disk_conf *disk_conf;/* RCU, for updates: first_peer_device(device)->connection->conf_update */ +struct disk_conf *disk_conf;/* RCU, for updates: resource->conf_update */ sector_t known_size;/* last known size of that backing device */ };
@@ -573,6 +573,8 @@ struct drbd_resource {struct list_head connections;struct list_head resources;struct res_opts res_opts; +struct mutex conf_update;/* mutex for ready-copy-update of net_conf and disk_conf */ +spinlock_t req_lock; };struct drbd_connection {
@@ -589,7 +591,6 @@ struct drbd_connection {unsigned long flags;struct net_conf *net_conf;/* content protected by rcu */ -struct mutex conf_update;/* mutex for ready-copy-update of net_conf and disk_conf */ wait_queue_head_t ping_wait;/* Woken upon reception of a ping, and a state change */ struct sockaddr_storage my_addr;
@@ -603,8 +604,6 @@ struct drbd_connection {unsigned long last_received;/* in jiffies, either socket */ unsigned int ko_count; -spinlock_t req_lock; -struct list_head transfer_log;/* all requests not yet fully processed */ struct crypto_hash *cram_hmac_tfm;
@@ -1590,9 +1589,9 @@ static inline void drbd_chk_io_error_(struct drbd_device *device, {if (error) {unsigned long flags; -spin_lock_irqsave (&first_peer_device (device)->connection->req_lock, flags); +spin_lock_irqsave (&device->resource->req_lock, flags);__drbd_chk_io_error_ (device, forcedetach, where); -spin_unlock_irqrestore (&first_peer_device (device)->connection->req_lock, flags); +spin_unlock_irqrestore (&device->resource->req_lock, flags); } }
@@ -2064,11 +2063,11 @@ static inline bool inc_ap_bio_cond(struct drbd_device *device) {bool rv = false; -spin_lock_irq (&first_peer_device (device)->connection->req_lock); +spin_lock_irq (&device->resource->req_lock); rv =may_inc_ap_bio (device);if (rv)atomic_inc (&device->ap_bio_cnt); -spin_unlock_irq (&first_peer_device (device)->connection->req_lock); +spin_unlock_irq (&device->resource->req_lock);return rv; }
drivers/block/drbd/drbd_main.c +18 -18
@@ -200,7 +200,7 @@ void tl_release(struct drbd_connection *connection, unsigned int barrier_nr,int expect_epoch =0 ;int expect_size =0 ; -spin_lock_irq (&connection->req_lock); +spin_lock_irq (&connection->resource->req_lock);/* find oldest not yet barrier-acked write request, * count writes in its epoch. */
@@ -257,12 +257,12 @@ void tl_release(struct drbd_connection *connection, unsigned int barrier_nr,break ;_req_mod (req,BARRIER_ACKED ); } -spin_unlock_irq (&connection->req_lock); +spin_unlock_irq (&connection->resource->req_lock);return ; bail: -spin_unlock_irq (&connection->req_lock); +spin_unlock_irq (&connection->resource->req_lock);conn_request_state (connection,NS (conn,C_PROTOCOL_ERROR ),CS_HARD ); }
@@ -286,9 +286,9 @@ void _tl_restart(struct drbd_connection *connection, enum drbd_req_event what)void tl_restart (struct drbd_connection *connection,enum drbd_req_event what) { -spin_lock_irq (&connection->req_lock); +spin_lock_irq (&connection->resource->req_lock);_tl_restart (connection, what); -spin_unlock_irq (&connection->req_lock); +spin_unlock_irq (&connection->resource->req_lock); }/**
@@ -313,7 +313,7 @@ void tl_abort_disk_io(struct drbd_device *device)struct drbd_connection *connection =first_peer_device (device)->connection;struct drbd_request *req, *r; -spin_lock_irq (&connection->req_lock); +spin_lock_irq (&connection->resource->req_lock);list_for_each_entry_safe (req, r, &connection->transfer_log, tl_requests) {if (!(req->rq_state &RQ_LOCAL_PENDING ))continue ;
@@ -321,7 +321,7 @@ void tl_abort_disk_io(struct drbd_device *device)continue ;_req_mod (req,ABORT_DISK_IO ); } -spin_unlock_irq (&connection->req_lock); +spin_unlock_irq (&connection->resource->req_lock); }static int drbd_thread_setup (void *arg)
@@ -1838,7 +1838,7 @@ static int drbd_open(struct block_device *bdev, fmode_t mode)int rv =0 ;mutex_lock (&drbd_main_mutex); -spin_lock_irqsave (&first_peer_device (device)->connection->req_lock, flags); +spin_lock_irqsave (&device->resource->req_lock, flags);/* to have a stable device->state.role * and no race with updating open_cnt */
@@ -1851,7 +1851,7 @@ static int drbd_open(struct block_device *bdev, fmode_t mode)if (!rv) device->open_cnt++; -spin_unlock_irqrestore (&first_peer_device (device)->connection->req_lock, flags); +spin_unlock_irqrestore (&device->resource->req_lock, flags);mutex_unlock (&drbd_main_mutex);return rv;
@@ -2548,6 +2548,8 @@ struct drbd_resource *drbd_create_resource(const char *name)idr_init (&resource->devices);INIT_LIST_HEAD (&resource->connections);list_add_tail_rcu (&resource->resources, &drbd_resources); +mutex_init (&resource->conf_update); +spin_lock_init (&resource->req_lock);return resource; }
@@ -2590,8 +2592,6 @@ struct drbd_connection *conn_create(const char *name, struct res_opts *res_opts) connection->cstate =C_STANDALONE ;mutex_init (&connection->cstate_mutex); -spin_lock_init (&connection->req_lock); -mutex_init (&connection->conf_update);init_waitqueue_head (&connection->ping_wait);idr_init (&connection->peer_devices);
@@ -2722,7 +2722,7 @@ enum drbd_ret_code drbd_create_device(struct drbd_resource *resource, unsigned iblk_queue_max_hw_sectors (q,DRBD_MAX_BIO_SIZE_SAFE >>8 );blk_queue_bounce_limit (q,BLK_BOUNCE_ANY );blk_queue_merge_bvec (q, drbd_merge_bvec); - q->queue_lock = &connection->req_lock; + q->queue_lock = &resource->req_lock; device->md_io_page =alloc_page (GFP_KERNEL );if (!device->md_io_page)
@@ -3283,14 +3283,14 @@ int drbd_md_read(struct drbd_device *device, struct drbd_backing_dev *bdev) rv =NO_ERROR ; -spin_lock_irq (&first_peer_device (device)->connection->req_lock); +spin_lock_irq (&device->resource->req_lock);if (device->state.conn <C_CONNECTED ) {unsigned int peer; peer =be32_to_cpu (buffer->la_peer_max_bio_size); peer =max (peer,DRBD_MAX_BIO_SIZE_SAFE ); device->peer_max_bio_size = peer; } -spin_unlock_irq (&first_peer_device (device)->connection->req_lock); +spin_unlock_irq (&device->resource->req_lock); err:drbd_md_put_buffer (device);
@@ -3579,13 +3579,13 @@ void drbd_queue_bitmap_io(struct drbd_device *device, device->bm_io_work.why = why; device->bm_io_work.flags = flags; -spin_lock_irq (&first_peer_device (device)->connection->req_lock); +spin_lock_irq (&device->resource->req_lock);set_bit (BITMAP_IO , &device->flags);if (atomic_read (&device->ap_bio_cnt) ==0 ) {if (!test_and_set_bit (BITMAP_IO_QUEUED , &device->flags))drbd_queue_work (&first_peer_device (device)->connection->sender_work, &device->bm_io_work.w); } -spin_unlock_irq (&first_peer_device (device)->connection->req_lock); +spin_unlock_irq (&device->resource->req_lock); }/**
@@ -3753,10 +3753,10 @@ int drbd_wait_misc(struct drbd_device *device, struct drbd_interval *i)/* Indicate to wake up device->misc_wait on progress. */ i->waiting = true;prepare_to_wait (&device->misc_wait, &wait,TASK_INTERRUPTIBLE ); -spin_unlock_irq (&first_peer_device (device)->connection->req_lock); +spin_unlock_irq (&device->resource->req_lock); timeout =schedule_timeout (timeout);finish_wait (&device->misc_wait, &wait); -spin_lock_irq (&first_peer_device (device)->connection->req_lock); +spin_lock_irq (&device->resource->req_lock);if (!timeout || device->state.conn <C_CONNECTED )return -ETIMEDOUT ;if (signal_pending (current))
drivers/block/drbd/drbd_nl.c +25 -25
175 lines not on this page · raw message
drivers/block/drbd/drbd_receiver.c +58 -58
379 lines not on this page · raw message
drivers/block/drbd/drbd_req.c +9 -9
@@ -851,9 +851,9 @@ static void complete_conflicting_writes(struct drbd_request *req)break ;/* Indicate to wake up device->misc_wait on progress. */ i->waiting = true; -spin_unlock_irq (&first_peer_device (device)->connection->req_lock); +spin_unlock_irq (&device->resource->req_lock);schedule (); -spin_lock_irq (&first_peer_device (device)->connection->req_lock); +spin_lock_irq (&device->resource->req_lock); }finish_wait (&device->misc_wait, &wait); }
@@ -1078,7 +1078,7 @@ static void drbd_send_and_submit(struct drbd_device *device, struct drbd_requeststruct bio_and_error m = {NULL , };bool no_remote = false; -spin_lock_irq (&first_peer_device (device)->connection->req_lock); +spin_lock_irq (&device->resource->req_lock);if (rw ==WRITE ) {/* This may temporarily give up the req_lock, * but will re-aquire it before it returns here.
@@ -1140,9 +1140,9 @@ static void drbd_send_and_submit(struct drbd_device *device, struct drbd_request/* needs to be marked within the same spinlock */ _req_mod (req,TO_BE_SUBMITTED );/* but we need to give up the spinlock to submit */ -spin_unlock_irq (&first_peer_device (device)->connection->req_lock); +spin_unlock_irq (&device->resource->req_lock);drbd_submit_req_private_bio (req); -spin_lock_irq (&first_peer_device (device)->connection->req_lock); +spin_lock_irq (&device->resource->req_lock); }else if (no_remote) { nodata:if (__ratelimit (&drbd_ratelimit_state))
@@ -1155,7 +1155,7 @@ nodata: out:if (drbd_req_put_completion_ref (req, &m,1 ))kref_put (&req->kref, drbd_req_destroy); -spin_unlock_irq (&first_peer_device (device)->connection->req_lock); +spin_unlock_irq (&device->resource->req_lock);if (m.bio)complete_master_bio (device, &m);
@@ -1360,10 +1360,10 @@ void request_timer_fn(unsigned long data) now = jiffies; -spin_lock_irq (&connection->req_lock); +spin_lock_irq (&device->resource->req_lock); req =find_oldest_request (connection);if (!req) { -spin_unlock_irq (&connection->req_lock); +spin_unlock_irq (&device->resource->req_lock);mod_timer (&device->request_timer, now + et);return ; }
@@ -1397,6 +1397,6 @@ void request_timer_fn(unsigned long data)__drbd_chk_io_error (device,DRBD_FORCE_DETACH ); } nt = (time_after (now, req->start_time + et) ? now : req->start_time) + et; -spin_unlock_irq (&connection->req_lock); +spin_unlock_irq (&connection->resource->req_lock);mod_timer (&device->request_timer, nt); }
drivers/block/drbd/drbd_req.h +2 -2
@@ -318,9 +318,9 @@ static inline int req_mod(struct drbd_request *req,struct bio_and_error m;int rv; -spin_lock_irqsave (&first_peer_device (device)->connection->req_lock, flags); +spin_lock_irqsave (&device->resource->req_lock, flags); rv =__req_mod (req, what, &m); -spin_unlock_irqrestore (&first_peer_device (device)->connection->req_lock, flags); +spin_unlock_irqrestore (&device->resource->req_lock, flags);if (m.bio)complete_master_bio (device, &m);
drivers/block/drbd/drbd_state.c +24 -24
170 lines not on this page · raw message
drivers/block/drbd/drbd_worker.c +17 -17
@@ -102,14 +102,14 @@ void drbd_endio_read_sec_final(struct drbd_peer_request *peer_req) __releases(lounsigned long flags =0 ;struct drbd_device *device = peer_req->w.device; -spin_lock_irqsave (&first_peer_device (device)->connection->req_lock, flags); +spin_lock_irqsave (&device->resource->req_lock, flags); device->read_cnt += peer_req->i.size >>9 ;list_del (&peer_req->w.list);if (list_empty (&device->read_ee))wake_up (&device->ee_wait);if (test_bit (__EE_WAS_ERROR, &peer_req->flags))__drbd_chk_io_error (device,DRBD_READ_ERROR ); -spin_unlock_irqrestore (&first_peer_device (device)->connection->req_lock, flags); +spin_unlock_irqrestore (&device->resource->req_lock, flags);drbd_queue_work (&first_peer_device (device)->connection->sender_work, &peer_req->w);put_ldev (device);
@@ -134,7 +134,7 @@ static void drbd_endio_write_sec_final(struct drbd_peer_request *peer_req) __rel do_al_complete_io = peer_req->flags &EE_CALL_AL_COMPLETE_IO ; block_id = peer_req->block_id; -spin_lock_irqsave (&first_peer_device (device)->connection->req_lock, flags); +spin_lock_irqsave (&device->resource->req_lock, flags); device->writ_cnt += peer_req->i.size >>9 ;list_move_tail (&peer_req->w.list, &device->done_ee);
@@ -150,7 +150,7 @@ static void drbd_endio_write_sec_final(struct drbd_peer_request *peer_req) __relif (test_bit (__EE_WAS_ERROR, &peer_req->flags))__drbd_chk_io_error (device,DRBD_WRITE_ERROR ); -spin_unlock_irqrestore (&first_peer_device (device)->connection->req_lock, flags); +spin_unlock_irqrestore (&device->resource->req_lock, flags);if (block_id ==ID_SYNCER )drbd_rs_complete_io (device, i.sector);
@@ -273,9 +273,9 @@ void drbd_request_endio(struct bio *bio, int error) req->private_bio =ERR_PTR (error);/* not req_mod(), we need irqsave here! */ -spin_lock_irqsave (&first_peer_device (device)->connection->req_lock, flags); +spin_lock_irqsave (&device->resource->req_lock, flags);__req_mod (req, what, &m); -spin_unlock_irqrestore (&first_peer_device (device)->connection->req_lock, flags); +spin_unlock_irqrestore (&device->resource->req_lock, flags);put_ldev (device);if (m.bio)
@@ -397,9 +397,9 @@ static int read_for_csum(struct drbd_device *device, sector_t sector, int size) goto defer; peer_req->w.cb = w_e_send_csum; -spin_lock_irq (&first_peer_device (device)->connection->req_lock); +spin_lock_irq (&device->resource->req_lock);list_add (&peer_req->w.list, &device->read_ee); -spin_unlock_irq (&first_peer_device (device)->connection->req_lock); +spin_unlock_irq (&device->resource->req_lock);atomic_add (size >>9 , &device->rs_sect_ev);if (drbd_submit_peer_request (device, peer_req,READ ,DRBD_FAULT_RS_RD ) ==0 )
@@ -409,9 +409,9 @@ static int read_for_csum(struct drbd_device *device, sector_t sector, int size)* because bio_add_page failed (probably broken lower level driver), * retry may or may not help. * If it does not, you may need to force disconnect. */ -spin_lock_irq (&first_peer_device (device)->connection->req_lock); +spin_lock_irq (&device->resource->req_lock);list_del (&peer_req->w.list); -spin_unlock_irq (&first_peer_device (device)->connection->req_lock); +spin_unlock_irq (&device->resource->req_lock);drbd_free_peer_req (device, peer_req); defer:
@@ -855,7 +855,7 @@ int drbd_resync_finished(struct drbd_device *device)ping_peer (device); -spin_lock_irq (&first_peer_device (device)->connection->req_lock); +spin_lock_irq (&device->resource->req_lock); os =drbd_read_state (device); verify_done = (os.conn ==C_VERIFY_S || os.conn ==C_VERIFY_T );
@@ -944,7 +944,7 @@ int drbd_resync_finished(struct drbd_device *device)_drbd_set_state (device, ns,CS_VERBOSE ,NULL ); out_unlock: -spin_unlock_irq (&first_peer_device (device)->connection->req_lock); +spin_unlock_irq (&device->resource->req_lock);put_ldev (device); out: device->rs_total =0 ;
@@ -971,9 +971,9 @@ static void move_to_net_ee_or_free(struct drbd_device *device, struct drbd_peer_int i = (peer_req->i.size +PAGE_SIZE -1 ) >>PAGE_SHIFT ;atomic_add (i, &device->pp_in_use_by_net);atomic_sub (i, &device->pp_in_use); -spin_lock_irq (&first_peer_device (device)->connection->req_lock); +spin_lock_irq (&device->resource->req_lock);list_add_tail (&peer_req->w.list, &device->net_ee); -spin_unlock_irq (&first_peer_device (device)->connection->req_lock); +spin_unlock_irq (&device->resource->req_lock);wake_up (&drbd_pp_wait); }else drbd_free_peer_req (device, peer_req);
@@ -1847,7 +1847,7 @@ void wait_for_work(struct drbd_connection *connection, struct list_head *work_lifor (;;) {int send_barrier;prepare_to_wait (&connection->sender_work.q_wait, &wait,TASK_INTERRUPTIBLE ); -spin_lock_irq (&connection->req_lock); +spin_lock_irq (&connection->resource->req_lock);spin_lock (&connection->sender_work.q_lock);/* FIXME get rid of this one? */ /* dequeue single item only, * we still use drbd_queue_work_front() in some places */
@@ -1855,11 +1855,11 @@ void wait_for_work(struct drbd_connection *connection, struct list_head *work_lilist_move (connection->sender_work.q.next, work_list);spin_unlock (&connection->sender_work.q_lock);/* FIXME get rid of this one? */ if (!list_empty (work_list) ||signal_pending (current)) { -spin_unlock_irq (&connection->req_lock); +spin_unlock_irq (&connection->resource->req_lock);break ; } send_barrier =need_to_send_barrier (connection); -spin_unlock_irq (&connection->req_lock); +spin_unlock_irq (&connection->resource->req_lock);if (send_barrier) {drbd_send_barrier (connection); connection->send.current_epoch_nr++;
Signature · 1 line
1.7.9.5
Philipp Reisner
maintainerPATCH 5/27 drbd: Move susp, susp_nod, susp_fen from connection to resource
In reply to Philipp ReisnerFrom: Andreas Gruenbacher <[email protected]>
--- drivers/block/drbd/drbd_int.h | 18 ++++++++++-------- drivers/block/drbd/drbd_main.c | 2 +- drivers/block/drbd/drbd_nl.c | 3 +-- drivers/block/drbd/drbd_state.c | 17 +++++++++-------- 4 files changed, 21 insertions(+), 19 deletions(-)
drivers/block/drbd/drbd_int.h +10 -8
@@ -575,6 +575,10 @@ struct drbd_resource {struct res_opts res_opts;struct mutex conf_update;/* mutex for ready-copy-update of net_conf and disk_conf */ spinlock_t req_lock; + + unsigned susp:1; /* IO suspended by user */ + unsigned susp_nod:1; /* IO suspended because no data */ + unsigned susp_fen:1; /* IO suspended because fence peer handler runs */ };struct drbd_connection {
@@ -583,9 +587,6 @@ struct drbd_connection {struct kref kref;struct idr peer_devices;/* volume number to peer device mapping */ enum drbd_conns cstate;/* Only C_STANDALONE to C_WF_REPORT_PARAMS */ - unsigned susp:1; /* IO suspended by user */ - unsigned susp_nod:1; /* IO suspended because no data */ - unsigned susp_fen:1; /* IO suspended because fence peer handler runs */struct mutex cstate_mutex;/* Protects graceful disconnects */ unsigned int connect_cnt;/* Inc each time a connection is established */
@@ -1502,12 +1503,13 @@ _drbd_set_state(struct drbd_device *device, union drbd_state ns,static inline union drbd_state drbd_read_state (struct drbd_device *device) { +struct drbd_resource *resource = device->resource;union drbd_state rv; rv.i = device->state.i; - rv.susp =first_peer_device (device)->connection->susp; - rv.susp_nod =first_peer_device (device)->connection->susp_nod; - rv.susp_fen =first_peer_device (device)->connection->susp_fen; + rv.susp = resource->susp; + rv.susp_nod = resource->susp_nod; + rv.susp_fen = resource->susp_fen;return rv; }
@@ -2028,9 +2030,9 @@ static inline int drbd_state_is_stable(struct drbd_device *device)static inline int drbd_suspended (struct drbd_device *device) { -struct drbd_connection *connection =first_peer_device (device)->connection; +struct drbd_resource *resource = device->resource; -return connection->susp || connection->susp_fen || connection->susp_nod; +return resource->susp || resource->susp_fen || resource->susp_nod; }static inline bool may_inc_ap_bio (struct drbd_device *device)
drivers/block/drbd/drbd_main.c +1 -1
@@ -2536,7 +2536,7 @@ struct drbd_resource *drbd_create_resource(const char *name) {struct drbd_resource *resource; - resource =kmalloc (sizeof (struct drbd_resource ),GFP_KERNEL ); + resource =kzalloc (sizeof (struct drbd_resource ),GFP_KERNEL );if (!resource)return NULL ; resource->name =kstrdup (name,GFP_KERNEL );
drivers/block/drbd/drbd_nl.c +1 -2
@@ -1665,8 +1665,7 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info)clear_bit (CRASHED_PRIMARY , &device->flags);if (drbd_md_test_flag (device->ldev,MDF_PRIMARY_IND ) && - !(device->state.role ==R_PRIMARY && -first_peer_device (device)->connection->susp_nod)) + !(device->state.role ==R_PRIMARY && device->resource->susp_nod))set_bit (CRASHED_PRIMARY , &device->flags); device->send_cnt =0 ;
drivers/block/drbd/drbd_state.c +9 -8
@@ -1011,9 +1011,9 @@ __drbd_set_state(struct drbd_device *device, union drbd_state ns, did_remote =drbd_should_do_remote (device->state); device->state.i = ns.i; should_do_remote =drbd_should_do_remote (device->state); -first_peer_device (device)->connection->susp = ns.susp; -first_peer_device (device)->connection->susp_nod = ns.susp_nod; -first_peer_device (device)->connection->susp_fen = ns.susp_fen; + device->resource->susp = ns.susp; + device->resource->susp_nod = ns.susp_nod; + device->resource->susp_fen = ns.susp_fen;/* put replicated vs not-replicated requests in seperate epochs */ if (did_remote != should_do_remote)
@@ -1222,6 +1222,7 @@ int drbd_bitmap_io_from_worker(struct drbd_device *device,static void after_state_ch (struct drbd_device *device,union drbd_state os,union drbd_state ns,enum chg_state_flags flags) { +struct drbd_resource *resource = device->resource;struct sib_info sib; sib.sib_reason =SIB_STATE_CHANGE ;
@@ -1256,7 +1257,7 @@ static void after_state_ch(struct drbd_device *device, union drbd_state os, conn_lowest_disk(connection) > D_NEGOTIATING) what =RESTART_FROZEN_DISK_IO ; -if (connection->susp_nod && what !=NOTHING ) { +if (resource->susp_nod && what !=NOTHING ) {_tl_restart (connection, what); _conn_request_state(connection, (union drbd_state) { { .susp_nod = 1 } },
@@ -1270,7 +1271,7 @@ static void after_state_ch(struct drbd_device *device, union drbd_state os,struct drbd_connection *connection =first_peer_device (device)->connection;spin_lock_irq (&device->resource->req_lock); -if (connection->susp_fen &&conn_lowest_conn (connection) >=C_CONNECTED ) { +if (resource->susp_fen &&conn_lowest_conn (connection) >=C_CONNECTED ) {/* case2: The connection was established again: */ struct drbd_peer_device *peer_device;int vnr;
@@ -1753,9 +1754,9 @@ conn_set_state(struct drbd_connection *connection, union drbd_state mask, union } }; } - ns_min.susp = ns_max.susp = connection->susp; - ns_min.susp_nod = ns_max.susp_nod = connection->susp_nod; - ns_min.susp_fen = ns_max.susp_fen = connection->susp_fen; + ns_min.susp = ns_max.susp = connection->resource->susp; + ns_min.susp_nod = ns_max.susp_nod = connection->resource->susp_nod; + ns_min.susp_fen = ns_max.susp_fen = connection->resource->susp_fen; *pns_min = ns_min; *pns_max = ns_max;
Signature · 1 line
1.7.9.5
Philipp Reisner
maintainerPATCH 6/27 drbd: Define the size of res_opts->cpu_mask in a single place
In reply to Philipp ReisnerFrom: Andreas Gruenbacher <[email protected]>
--- drivers/block/drbd/drbd_main.c | 3 +-- include/linux/drbd.h | 2 ++ include/linux/drbd_genl.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-)
drivers/block/drbd/drbd_main.c +1 -2
@@ -2505,8 +2505,7 @@ int set_resource_options(struct drbd_resource *resource, struct res_opts *res_op/* silently ignore cpu mask on UP kernel */ if (nr_cpu_ids >1 && res_opts->cpu_mask[0 ] !=0 ) { -/* FIXME: Get rid of constant 32 here */ - err =bitmap_parse (res_opts->cpu_mask,32 , + err =bitmap_parse (res_opts->cpu_mask,DRBD_CPU_MASK_SIZE ,cpumask_bits (new_cpu_mask), nr_cpu_ids);if (err) {drbd_warn (resource,"bitmap_parse() failed with %d\n" , err);
include/linux/drbd.h +2 -0
@@ -382,4 +382,6 @@ enum drbd_timeout_flag {#define DRBD_MD_INDEX_FLEX_EXT -2#define DRBD_MD_INDEX_FLEX_INT -3 +#define DRBD_CPU_MASK_SIZE 32 +#endif
include/linux/drbd_genl.h +1 -1
@@ -135,7 +135,7 @@ GENL_struct(DRBD_NLA_DISK_CONF, 3, disk_conf, )GENL_struct (DRBD_NLA_RESOURCE_OPTS ,4 , res_opts, - __str_field_def(1, DRBD_GENLA_F_MANDATORY, cpu_mask, 32) + __str_field_def(1, DRBD_GENLA_F_MANDATORY, cpu_mask, DRBD_CPU_MASK_SIZE)__u32_field_def (2 ,DRBD_GENLA_F_MANDATORY , on_no_data,DRBD_ON_NO_DATA_DEF ) )
Signature · 1 line
1.7.9.5
Philipp Reisner
maintainerPATCH 7/27 drbd: Move cpu_mask from connection to resource
In reply to Philipp ReisnerFrom: Andreas Gruenbacher <[email protected]>
Also fix drbd_calc_cpu_mask() to spread resources equally over all online cpus independent of device minor numbers.
--- drivers/block/drbd/drbd_int.h | 5 ++- drivers/block/drbd/drbd_main.c | 74 ++++++++++++++++++++++++---------------- 2 files changed, 47 insertions(+), 32 deletions(-)
drivers/block/drbd/drbd_int.h +2 -3
@@ -579,6 +579,8 @@ struct drbd_resource { unsigned susp:1; /* IO suspended by user */ unsigned susp_nod:1; /* IO suspended because no data */ unsigned susp_fen:1; /* IO suspended because fence peer handler runs */ + +cpumask_var_t cpu_mask; };struct drbd_connection {
@@ -627,7 +629,6 @@ struct drbd_connection {struct drbd_thread receiver;struct drbd_thread worker;struct drbd_thread asender; -cpumask_var_t cpu_mask;/* sender side */ struct drbd_work_queue sender_work;
@@ -875,10 +876,8 @@ extern void _drbd_thread_stop(struct drbd_thread *thi, int restart, int wait);extern char *drbd_task_to_thread_name (struct drbd_connection *connection,struct task_struct *task);#ifdef CONFIG_SMP extern void drbd_thread_current_set_cpu (struct drbd_thread *thi); -extern void drbd_calc_cpu_mask (struct drbd_connection *connection);#else #define drbd_thread_current_set_cpu (A ) ({}) -#define drbd_calc_cpu_mask (A ) ({})#endif extern void tl_release (struct drbd_connection *,unsigned int barrier_nr,unsigned int set_size);
drivers/block/drbd/drbd_main.c +45 -29
138 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Philipp Reisner
maintainerPATCH 8/27 drbd: Rename drbdd_init() -> drbd_receiver()
In reply to Philipp ReisnerFrom: Andreas Gruenbacher <[email protected]>
--- drivers/block/drbd/drbd_main.c | 4 ++-- drivers/block/drbd/drbd_nl.c | 2 +- drivers/block/drbd/drbd_receiver.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/block/drbd/drbd_main.c +2 -2
@@ -58,7 +58,7 @@#include "drbd_vli.h" static DEFINE_MUTEX (drbd_main_mutex); -int drbdd_init (struct drbd_thread *); +int drbd_receiver (struct drbd_thread *);int drbd_worker (struct drbd_thread *);int drbd_asender (struct drbd_thread *);
@@ -2616,7 +2616,7 @@ struct drbd_connection *conn_create(const char *name, struct res_opts *res_opts)mutex_init (&connection->data.mutex);mutex_init (&connection->meta.mutex); -drbd_thread_init (connection, &connection->receiver, drbdd_init,"receiver" ); +drbd_thread_init (connection, &connection->receiver, drbd_receiver,"receiver" );drbd_thread_init (connection, &connection->worker, drbd_worker,"worker" );drbd_thread_init (connection, &connection->asender, drbd_asender,"asender" );
drivers/block/drbd/drbd_nl.c +1 -1
@@ -2332,7 +2332,7 @@ static enum drbd_state_rv conn_try_disconnect(struct drbd_connection *connection/* Race breaker. This additional state change request may be * necessary, if this was a forced disconnect during a receiver * restart. We may have "killed" the receiver thread just -* after drbdd_init() returned. Typically, we should be +* after drbd_receiver() returned. Typically, we should be * C_STANDALONE already, now, and this becomes a no-op. */ rv2 = conn_request_state(connection, NS(conn, C_STANDALONE),
drivers/block/drbd/drbd_receiver.c +1 -1
@@ -4843,7 +4843,7 @@ static int drbd_do_auth(struct drbd_connection *connection) }#endif -int drbdd_init (struct drbd_thread *thi) +int drbd_receiver (struct drbd_thread *thi) {struct drbd_connection *connection = thi->connection;int h;
Signature · 1 line
1.7.9.5
Philipp Reisner
maintainerPATCH 9/27 drbd: Function prototype cleanups
In reply to Philipp ReisnerFrom: Andreas Gruenbacher <[email protected]>
--- drivers/block/drbd/drbd_int.h | 2 ++ drivers/block/drbd/drbd_main.c | 5 ----- 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/block/drbd/drbd_int.h +2 -0
@@ -1340,6 +1340,8 @@ extern void resync_timer_fn(unsigned long data);extern void start_resync_timer_fn (unsigned long data);/* drbd_receiver.c */ +extern int drbd_receiver (struct drbd_thread *thi); +extern int drbd_asender (struct drbd_thread *thi);extern int drbd_rs_should_slow_down (struct drbd_device *device,sector_t sector); extern int drbd_submit_peer_request(struct drbd_device *, struct drbd_peer_request *, const unsigned,
drivers/block/drbd/drbd_main.c +0 -5
@@ -58,11 +58,6 @@#include "drbd_vli.h" static DEFINE_MUTEX (drbd_main_mutex); -int drbd_receiver (struct drbd_thread *); -int drbd_worker (struct drbd_thread *); -int drbd_asender (struct drbd_thread *); - -int drbd_init (void );static int drbd_open (struct block_device *bdev,fmode_t mode);static void drbd_release (struct gendisk *gd,fmode_t mode);static int w_md_sync (struct drbd_work *w,int unused);
Signature · 1 line
1.7.9.5
Philipp Reisner
maintainerPATCH 10/27 drbd: drbd_csum_bio(), drbd_csum_ee(): Remove unused device argument
In reply to Philipp ReisnerFrom: Andreas Gruenbacher <[email protected]>
--- drivers/block/drbd/drbd_int.h | 5 ++--- drivers/block/drbd/drbd_main.c | 6 +++--- drivers/block/drbd/drbd_receiver.c | 4 ++-- drivers/block/drbd/drbd_worker.c | 13 ++++++------- 4 files changed, 13 insertions(+), 15 deletions(-)
drivers/block/drbd/drbd_int.h +2 -3
@@ -1315,9 +1315,8 @@ static inline void ov_out_of_sync_print(struct drbd_device *device) } -extern void drbd_csum_bio (struct drbd_device *,struct crypto_hash *,struct bio *,void *); -extern void drbd_csum_ee (struct drbd_device *,struct crypto_hash *, -struct drbd_peer_request *,void *); +extern void drbd_csum_bio (struct crypto_hash *,struct bio *,void *); +extern void drbd_csum_ee (struct crypto_hash *,struct drbd_peer_request *,void *);/* worker callbacks */ extern int w_e_end_data_req (struct drbd_work *,int );extern int w_e_end_rsdata_req (struct drbd_work *,int );
drivers/block/drbd/drbd_main.c +3 -3
@@ -1646,7 +1646,7 @@ int drbd_send_dblock(struct drbd_device *device, struct drbd_request *req) } p->dp_flags =cpu_to_be32 (dp_flags);if (dgs) -drbd_csum_bio (device,first_peer_device (device)->connection->integrity_tfm, req->master_bio, p +1 ); +drbd_csum_bio (first_peer_device (device)->connection->integrity_tfm, req->master_bio, p +1 ); err =__send_command (first_peer_device (device)->connection, device->vnr, sock,P_DATA ,sizeof (*p) + dgs,NULL , req->i.size);if (!err) {/* For protocol A, we have to memcpy the payload into
@@ -1670,7 +1670,7 @@ int drbd_send_dblock(struct drbd_device *device, struct drbd_request *req)/* 64 byte, 512 bit, is the largest digest size * currently supported in kernel crypto. */ unsigned char digest[64 ]; -drbd_csum_bio (device,first_peer_device (device)->connection->integrity_tfm, req->master_bio, digest); +drbd_csum_bio (first_peer_device (device)->connection->integrity_tfm, req->master_bio, digest);if (memcmp (p +1 , digest, dgs)) { drbd_warn(device, "Digest mismatch, buffer modified by upper layers during write: %llus +%u\n",
@@ -1710,7 +1710,7 @@ int drbd_send_block(struct drbd_device *device, enum drbd_packet cmd, p->seq_num =0 ;/* unused */ p->dp_flags =0 ;if (dgs) -drbd_csum_ee (device,first_peer_device (device)->connection->integrity_tfm, peer_req, p +1 ); +drbd_csum_ee (first_peer_device (device)->connection->integrity_tfm, peer_req, p +1 ); err =__send_command (first_peer_device (device)->connection, device->vnr, sock, cmd,sizeof (*p) + dgs,NULL , peer_req->i.size);if (!err) err =_drbd_send_zc_ee (device, peer_req);
drivers/block/drbd/drbd_receiver.c +2 -2
@@ -1560,7 +1560,7 @@ read_in_block(struct drbd_device *device, u64 id, sector_t sector, }if (dgs) { -drbd_csum_ee (device,first_peer_device (device)->connection->peer_integrity_tfm, peer_req, dig_vv); +drbd_csum_ee (first_peer_device (device)->connection->peer_integrity_tfm, peer_req, dig_vv);if (memcmp (dig_in, dig_vv, dgs)) {drbd_err (device,"Digest integrity check FAILED: %llus +%u\n" , (unsigned long long )sector, data_size);
@@ -1637,7 +1637,7 @@ static int recv_dless_read(struct drbd_device *device, struct drbd_request *req, }if (dgs) { -drbd_csum_bio (device,first_peer_device (device)->connection->peer_integrity_tfm, bio, dig_vv); +drbd_csum_bio (first_peer_device (device)->connection->peer_integrity_tfm, bio, dig_vv);if (memcmp (dig_in, dig_vv, dgs)) {drbd_err (device,"Digest integrity check FAILED. Broken NICs?\n" );return -EINVAL ;
drivers/block/drbd/drbd_worker.c +6 -7
@@ -282,8 +282,7 @@ void drbd_request_endio(struct bio *bio, int error)complete_master_bio (device, &m); } -void drbd_csum_ee (struct drbd_device *device,struct crypto_hash *tfm, -struct drbd_peer_request *peer_req,void *digest) +void drbd_csum_ee (struct crypto_hash *tfm,struct drbd_peer_request *peer_req,void *digest) {struct hash_desc desc;struct scatterlist sg;
@@ -310,7 +309,7 @@ void drbd_csum_ee(struct drbd_device *device, struct crypto_hash *tfm,crypto_hash_final (&desc, digest); } -void drbd_csum_bio (struct drbd_device *device,struct crypto_hash *tfm,struct bio *bio,void *digest) +void drbd_csum_bio (struct crypto_hash *tfm,struct bio *bio,void *digest) {struct hash_desc desc;struct scatterlist sg;
@@ -350,7 +349,7 @@ static int w_e_send_csum(struct drbd_work *w, int cancel)if (digest) {sector_t sector = peer_req->i.sector;unsigned int size = peer_req->i.size; -drbd_csum_ee (device,first_peer_device (device)->connection->csums_tfm, peer_req, digest); +drbd_csum_ee (first_peer_device (device)->connection->csums_tfm, peer_req, digest);/* Free peer_req and pages before send. * In case we block on congestion, we could otherwise run into * some distributed deadlock, if the other side blocks on
@@ -1103,7 +1102,7 @@ int w_e_end_csum_rs_req(struct drbd_work *w, int cancel) digest =kmalloc (digest_size,GFP_NOIO ); }if (digest) { -drbd_csum_ee (device,first_peer_device (device)->connection->csums_tfm, peer_req, digest); +drbd_csum_ee (first_peer_device (device)->connection->csums_tfm, peer_req, digest); eq = !memcmp (digest, di->digest, digest_size);kfree (digest); }
@@ -1155,7 +1154,7 @@ int w_e_end_ov_req(struct drbd_work *w, int cancel) }if (likely (!(peer_req->flags &EE_WAS_ERROR ))) -drbd_csum_ee (device,first_peer_device (device)->connection->verify_tfm, peer_req, digest); +drbd_csum_ee (first_peer_device (device)->connection->verify_tfm, peer_req, digest);else memset (digest,0 , digest_size);
@@ -1221,7 +1220,7 @@ int w_e_end_ov_reply(struct drbd_work *w, int cancel) digest_size =crypto_hash_digestsize (first_peer_device (device)->connection->verify_tfm); digest =kmalloc (digest_size,GFP_NOIO );if (digest) { -drbd_csum_ee (device,first_peer_device (device)->connection->verify_tfm, peer_req, digest); +drbd_csum_ee (first_peer_device (device)->connection->verify_tfm, peer_req, digest);D_ASSERT (device, digest_size == di->digest_size); eq = !memcmp (digest, di->digest, digest_size);
Signature · 1 line
1.7.9.5
Philipp Reisner
maintainerPATCH 11/27 drbd: Replace vnr_to_mdev() with conn_peer_device()
In reply to Philipp ReisnerFrom: Andreas Gruenbacher <[email protected]>
The new function returns a peer device, which allows us to eliminate a few instances of first_peer_device().
--- drivers/block/drbd/drbd_int.h | 8 -- drivers/block/drbd/drbd_receiver.c | 174 ++++++++++++++++++++++-------------- 2 files changed, 109 insertions(+), 73 deletions(-)
drivers/block/drbd/drbd_int.h +0 -8
@@ -851,14 +851,6 @@ static inline unsigned int device_to_minor(struct drbd_device *device)return device->minor; } -static inline struct drbd_device *vnr_to_device (struct drbd_connection *connection,int vnr) -{ -struct drbd_peer_device *peer_device; - - peer_device =idr_find (&connection->peer_devices, vnr); -return peer_device ? peer_device->device :NULL ; -} -/* * function declarations *************************/
drivers/block/drbd/drbd_receiver.c +109 -65
534 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Philipp Reisner
maintainerPATCH 13/27 drbd: Kill drbd_task_to_thread_name()
In reply to Philipp ReisnerFrom: Andreas Gruenbacher <[email protected]>
--- drivers/block/drbd/drbd_bitmap.c | 16 ++++++++-------- drivers/block/drbd/drbd_int.h | 3 +-- drivers/block/drbd/drbd_main.c | 20 ++------------------ 3 files changed, 11 insertions(+), 28 deletions(-)
drivers/block/drbd/drbd_bitmap.c +8 -8
@@ -118,10 +118,10 @@ static void __bm_print_lock_info(struct drbd_device *device, const char *func)struct drbd_bitmap *b = device->bitmap;if (!__ratelimit (&drbd_ratelimit_state))return ; -drbd_err (device,"FIXME %s in %s, bitmap locked for '%s' by %s\n" , -drbd_task_to_thread_name (first_peer_device (device)->connection, current), - func, b->bm_why ?:"?" , -drbd_task_to_thread_name (first_peer_device (device)->connection, b->bm_task)); +drbd_err (device,"FIXME %s[%d] in %s, bitmap locked for '%s' by %s[%d]\n" , + current->comm,task_pid_nr (current), + func, b->bm_why ?:"?" , + b->bm_task->comm,task_pid_nr (b->bm_task)); }void drbd_bm_lock (struct drbd_device *device,char *why,enum bm_flag flags)
@@ -137,10 +137,10 @@ void drbd_bm_lock(struct drbd_device *device, char *why, enum bm_flag flags) trylock_failed = !mutex_trylock (&b->bm_change);if (trylock_failed) { -drbd_warn (device,"%s going to '%s' but bitmap already locked for '%s' by %s\n" , -drbd_task_to_thread_name (first_peer_device (device)->connection, current), - why, b->bm_why ?:"?" , -drbd_task_to_thread_name (first_peer_device (device)->connection, b->bm_task)); +drbd_warn (device,"%s[%d] going to '%s' but bitmap already locked for '%s' by %s[%d]\n" , + current->comm,task_pid_nr (current), + why, b->bm_why ?:"?" , + b->bm_task->comm,task_pid_nr (b->bm_task));mutex_lock (&b->bm_change); }if (BM_LOCKED_MASK & b->bm_flags)
drivers/block/drbd/drbd_int.h +1 -2
@@ -263,7 +263,7 @@ struct drbd_thread {int (*function) (struct drbd_thread *);struct drbd_connection *connection;int reset_cpu_mask; -char name[9 ]; +const char *name; };static inline enum drbd_thread_state get_t_state (struct drbd_thread *thi)
@@ -865,7 +865,6 @@ enum dds_flags {extern void drbd_init_set_defaults (struct drbd_device *device);extern int drbd_thread_start (struct drbd_thread *thi);extern void _drbd_thread_stop (struct drbd_thread *thi,int restart,int wait); -extern char *drbd_task_to_thread_name (struct drbd_connection *connection,struct task_struct *task);#ifdef CONFIG_SMP extern void drbd_thread_current_set_cpu (struct drbd_thread *thi);#else
drivers/block/drbd/drbd_main.c +2 -18
@@ -368,14 +368,14 @@ restart: }static void drbd_thread_init (struct drbd_connection *connection,struct drbd_thread *thi, -int (*func) (struct drbd_thread *),char *name) +int (*func) (struct drbd_thread *),const char *name) {spin_lock_init (&thi->t_lock); thi->task =NULL ; thi->t_state =NONE ; thi->function = func; thi->connection = connection; -strncpy (thi->name, name,ARRAY_SIZE (thi->name)); + thi->name = name; }int drbd_thread_start (struct drbd_thread *thi)
@@ -475,22 +475,6 @@ void _drbd_thread_stop(struct drbd_thread *thi, int restart, int wait)wait_for_completion (&thi->stop); } -static struct drbd_thread *drbd_task_to_thread (struct drbd_connection *connection,struct task_struct *task) -{ -struct drbd_thread *thi = - task == connection->receiver.task ? &connection->receiver : - task == connection->asender.task ? &connection->asender : - task == connection->worker.task ? &connection->worker :NULL ; - -return thi; -} - -char *drbd_task_to_thread_name (struct drbd_connection *connection,struct task_struct *task) -{ -struct drbd_thread *thi =drbd_task_to_thread (connection, task); -return thi ? thi->name : task->comm; -} -int conn_lowest_minor (struct drbd_connection *connection) {struct drbd_peer_device *peer_device;
Signature · 1 line
1.7.9.5
Philipp Reisner
maintainerPATCH 12/27 drbd: Pass a peer device to a number of fuctions
In reply to Philipp ReisnerFrom: Andreas Gruenbacher <[email protected]>
These functions actually operate on a peer device, or need a peer device.
drbd_prepare_command(), drbd_send_command(), drbd_send_sync_param() drbd_send_uuids(), drbd_gen_and_send_sync_uuid(), drbd_send_sizes() drbd_send_state(), drbd_send_current_state(), and drbd_send_state_req() drbd_send_sr_reply(), drbd_send_ack(), drbd_send_drequest(), drbd_send_drequest_csum(), drbd_send_ov_request(), drbd_send_dblock() drbd_send_block(), drbd_send_out_of_sync(), recv_dless_read() drbd_drain_block(), receive_bitmap_plain(), recv_resync_read() read_in_block(), read_for_csum(), drbd_alloc_pages(), drbd_alloc_peer_req() need_peer_seq(), update_peer_seq(), wait_for_and_update_peer_seq() drbd_sync_handshake(), drbd_asb_recover_{0,1,2}p(), drbd_connected() drbd_disconnected(), decode_bitmap_c() and recv_bm_rle_bits()
--- drivers/block/drbd/drbd_int.h | 48 +++---- drivers/block/drbd/drbd_main.c | 260 ++++++++++++++++++------------------ drivers/block/drbd/drbd_nl.c | 27 ++-- drivers/block/drbd/drbd_receiver.c | 253 +++++++++++++++++++---------------- drivers/block/drbd/drbd_state.c | 34 ++--- drivers/block/drbd/drbd_worker.c | 45 ++++--- 6 files changed, 353 insertions(+), 314 deletions(-)
drivers/block/drbd/drbd_int.h +24 -24
@@ -882,36 +882,36 @@ extern int drbd_send_all(struct drbd_connection *, struct socket *, void *, sizeextern int __drbd_send_protocol (struct drbd_connection *connection,enum drbd_packet cmd);extern int drbd_send_protocol (struct drbd_connection *connection); -extern int drbd_send_uuids (struct drbd_device *device); -extern int drbd_send_uuids_skip_initial_sync (struct drbd_device *device); -extern void drbd_gen_and_send_sync_uuid (struct drbd_device *device); -extern int drbd_send_sizes (struct drbd_device *device,int trigger_reply,enum dds_flags flags); -extern int drbd_send_state (struct drbd_device *device,union drbd_state s); -extern int drbd_send_current_state (struct drbd_device *device); -extern int drbd_send_sync_param (struct drbd_device *device); +extern int drbd_send_uuids (struct drbd_peer_device *); +extern int drbd_send_uuids_skip_initial_sync (struct drbd_peer_device *); +extern void drbd_gen_and_send_sync_uuid (struct drbd_peer_device *); +extern int drbd_send_sizes (struct drbd_peer_device *,int trigger_reply,enum dds_flags flags); +extern int drbd_send_state (struct drbd_peer_device *,union drbd_state s); +extern int drbd_send_current_state (struct drbd_peer_device *); +extern int drbd_send_sync_param (struct drbd_peer_device *);extern void drbd_send_b_ack (struct drbd_connection *connection,u32 barrier_nr,u32 set_size); -extern int drbd_send_ack (struct drbd_device *,enum drbd_packet , +extern int drbd_send_ack (struct drbd_peer_device *,enum drbd_packet ,struct drbd_peer_request *); -extern void drbd_send_ack_rp (struct drbd_device *device,enum drbd_packet cmd, +extern void drbd_send_ack_rp (struct drbd_peer_device *,enum drbd_packet ,struct p_block_req *rp); -extern void drbd_send_ack_dp (struct drbd_device *device,enum drbd_packet cmd, +extern void drbd_send_ack_dp (struct drbd_peer_device *,enum drbd_packet ,struct p_data *dp,int data_size); -extern int drbd_send_ack_ex (struct drbd_device *device,enum drbd_packet cmd, +extern int drbd_send_ack_ex (struct drbd_peer_device *,enum drbd_packet ,sector_t sector,int blksize,u64 block_id); -extern int drbd_send_out_of_sync (struct drbd_device *,struct drbd_request *); -extern int drbd_send_block (struct drbd_device *,enum drbd_packet , +extern int drbd_send_out_of_sync (struct drbd_peer_device *,struct drbd_request *); +extern int drbd_send_block (struct drbd_peer_device *,enum drbd_packet ,struct drbd_peer_request *); -extern int drbd_send_dblock (struct drbd_device *device,struct drbd_request *req); -extern int drbd_send_drequest (struct drbd_device *device,int cmd, +extern int drbd_send_dblock (struct drbd_peer_device *,struct drbd_request *req); +extern int drbd_send_drequest (struct drbd_peer_device *,int cmd,sector_t sector,int size,u64 block_id); -extern int drbd_send_drequest_csum (struct drbd_device *device,sector_t sector, +extern int drbd_send_drequest_csum (struct drbd_peer_device *,sector_t sector,int size,void *digest,int digest_size,enum drbd_packet cmd); -extern int drbd_send_ov_request (struct drbd_device *device,sector_t sector,int size); +extern int drbd_send_ov_request (struct drbd_peer_device *,sector_t sector,int size);extern int drbd_send_bitmap (struct drbd_device *device); -extern void drbd_send_sr_reply (struct drbd_device *device,enum drbd_state_rv retcode); +extern void drbd_send_sr_reply (struct drbd_peer_device *,enum drbd_state_rv retcode);extern void conn_send_sr_reply (struct drbd_connection *connection,enum drbd_state_rv retcode);extern void drbd_free_bc (struct drbd_backing_dev *ldev);extern void drbd_device_cleanup (struct drbd_device *device);
@@ -1338,18 +1338,18 @@ extern int drbd_submit_peer_request(struct drbd_device *, struct drbd_peer_request *, const unsigned, const int);extern int drbd_free_peer_reqs (struct drbd_device *,struct list_head *); -extern struct drbd_peer_request *drbd_alloc_peer_req (struct drbd_device *,u64 , +extern struct drbd_peer_request *drbd_alloc_peer_req (struct drbd_peer_device *,u64 ,sector_t ,unsigned int ,gfp_t )__must_hold (local);extern void __drbd_free_peer_req (struct drbd_device *,struct drbd_peer_request *,int );#define drbd_free_peer_req (m,e) __drbd_free_peer_req(m, e, 0)#define drbd_free_net_peer_req (m,e) __drbd_free_peer_req(m, e, 1) -extern struct page *drbd_alloc_pages (struct drbd_device *,unsigned int ,bool ); +extern struct page *drbd_alloc_pages (struct drbd_peer_device *,unsigned int ,bool );extern void drbd_set_recv_tcq (struct drbd_device *device,int tcq_enabled);extern void _drbd_clear_done_ee (struct drbd_device *device,struct list_head *to_be_freed);extern void conn_flush_workqueue (struct drbd_connection *connection); -extern int drbd_connected (struct drbd_device *device); +extern int drbd_connected (struct drbd_peer_device *);static inline void drbd_flush_workqueue (struct drbd_device *device) {conn_flush_workqueue (first_peer_device (device)->connection);
@@ -1721,17 +1721,17 @@ static inline void request_ping(struct drbd_connection *connection) }extern void *conn_prepare_command (struct drbd_connection *,struct drbd_socket *); -extern void *drbd_prepare_command (struct drbd_device *,struct drbd_socket *); +extern void *drbd_prepare_command (struct drbd_peer_device *,struct drbd_socket *);extern int conn_send_command (struct drbd_connection *,struct drbd_socket *,enum drbd_packet ,unsigned int ,void *,unsigned int ); -extern int drbd_send_command (struct drbd_device *,struct drbd_socket *, +extern int drbd_send_command (struct drbd_peer_device *,struct drbd_socket *,enum drbd_packet ,unsigned int ,void *,unsigned int );extern int drbd_send_ping (struct drbd_connection *connection);extern int drbd_send_ping_ack (struct drbd_connection *connection); -extern int drbd_send_state_req (struct drbd_device *,union drbd_state ,union drbd_state ); +extern int drbd_send_state_req (struct drbd_peer_device *,union drbd_state ,union drbd_state );extern int conn_send_state_req (struct drbd_connection *,union drbd_state ,union drbd_state );static inline void drbd_thread_stop (struct drbd_thread *thi)
drivers/block/drbd/drbd_main.c +133 -127
682 lines not on this page · raw message
drivers/block/drbd/drbd_nl.c +18 -9
@@ -678,8 +678,8 @@ drbd_set_role(struct drbd_device *device, enum drbd_role new_role, int force)if (device->state.conn >=C_WF_REPORT_PARAMS ) {/* if this was forced, we should consider sync */ if (forced) -drbd_send_uuids (device); -drbd_send_current_state (device); +drbd_send_uuids (first_peer_device (device)); +drbd_send_current_state (first_peer_device (device)); }drbd_md_sync (device);
@@ -1364,8 +1364,12 @@ int drbd_adm_disk_opts(struct sk_buff *skb, struct genl_info *info)drbd_md_sync (device); -if (device->state.conn >=C_CONNECTED ) -drbd_send_sync_param (device); +if (device->state.conn >=C_CONNECTED ) { +struct drbd_peer_device *peer_device; + +for_each_peer_device (peer_device, device) +drbd_send_sync_param (peer_device); + }synchronize_rcu ();kfree (old_disk_conf);
@@ -2145,8 +2149,13 @@ int drbd_adm_net_opts(struct sk_buff *skb, struct genl_info *info)synchronize_rcu ();kfree (old_net_conf); -if (connection->cstate >=C_WF_REPORT_PARAMS ) -drbd_send_sync_param (minor_to_device (conn_lowest_minor (connection))); +if (connection->cstate >=C_WF_REPORT_PARAMS ) { +struct drbd_peer_device *peer_device; +int vnr; + +idr_for_each_entry (&connection->peer_devices, peer_device, vnr) +drbd_send_sync_param (peer_device); + } goto done;
@@ -2514,8 +2523,8 @@ int drbd_adm_resize(struct sk_buff *skb, struct genl_info *info)if (dd ==DS_GREW )set_bit (RESIZE_PENDING , &device->flags); -drbd_send_uuids (device); -drbd_send_sizes (device,1 , ddsf); +drbd_send_uuids (first_peer_device (device)); +drbd_send_sizes (first_peer_device (device),1 , ddsf); } fail:
@@ -3244,7 +3253,7 @@ int drbd_adm_new_c_uuid(struct sk_buff *skb, struct genl_info *info) retcode =ERR_IO_MD_DISK ; }if (skip_initial_sync) { -drbd_send_uuids_skip_initial_sync (device); +drbd_send_uuids_skip_initial_sync (first_peer_device (device));_drbd_uuid_set (device,UI_BITMAP ,0 );drbd_print_uuids (device,"cleared bitmap UUID" );spin_lock_irq (&device->resource->req_lock);
drivers/block/drbd/drbd_receiver.c +138 -115
791 lines not on this page · raw message
drivers/block/drbd/drbd_state.c +17 -17
@@ -354,7 +354,7 @@ drbd_req_state(struct drbd_device *device, union drbd_state mask, goto abort; } -if (drbd_send_state_req (device, mask, val)) { +if (drbd_send_state_req (first_peer_device (device), mask, val)) { rv =SS_CW_FAILED_BY_PEER ;if (f &CS_VERBOSE )print_st_err (device, os, ns, rv);
@@ -1296,7 +1296,7 @@ static void after_state_ch(struct drbd_device *device, union drbd_state os,if ((os.conn !=C_SYNC_SOURCE && os.conn !=C_PAUSED_SYNC_S ) && (ns.conn ==C_SYNC_SOURCE || ns.conn ==C_PAUSED_SYNC_S ) &&first_peer_device (device)->connection->agreed_pro_version >=96 &&get_ldev (device)) { -drbd_gen_and_send_sync_uuid (device); +drbd_gen_and_send_sync_uuid (first_peer_device (device));put_ldev (device); }
@@ -1310,8 +1310,8 @@ static void after_state_ch(struct drbd_device *device, union drbd_state os,atomic_set (&device->rs_pending_cnt,0 );drbd_rs_cancel_all (device); -drbd_send_uuids (device); -drbd_send_state (device, ns); +drbd_send_uuids (first_peer_device (device)); +drbd_send_state (first_peer_device (device), ns); }/* No point in queuing send_bitmap if we don't have a connection * anymore, so check also the _current_ state, not only the new state
@@ -1336,7 +1336,7 @@ static void after_state_ch(struct drbd_device *device, union drbd_state os,set_bit (NEW_CUR_UUID , &device->flags); }else {drbd_uuid_new_current (device); -drbd_send_uuids (device); +drbd_send_uuids (first_peer_device (device)); } }put_ldev (device);
@@ -1347,7 +1347,7 @@ static void after_state_ch(struct drbd_device *device, union drbd_state os,if (os.peer ==R_SECONDARY && ns.peer ==R_PRIMARY && device->ldev->md.uuid[UI_BITMAP ] ==0 && ns.disk >=D_UP_TO_DATE ) {drbd_uuid_new_current (device); -drbd_send_uuids (device); +drbd_send_uuids (first_peer_device (device)); }/* D_DISKLESS Peer becomes secondary */ if (os.peer ==R_PRIMARY && ns.peer ==R_SECONDARY )
@@ -1374,16 +1374,16 @@ static void after_state_ch(struct drbd_device *device, union drbd_state os,/* Last part of the attaching process ... */ if (ns.conn >=C_CONNECTED && os.disk ==D_ATTACHING && ns.disk ==D_NEGOTIATING ) { -drbd_send_sizes (device,0 ,0 );/* to start sync... */ -drbd_send_uuids (device); -drbd_send_state (device, ns); +drbd_send_sizes (first_peer_device (device),0 ,0 );/* to start sync... */ +drbd_send_uuids (first_peer_device (device)); +drbd_send_state (first_peer_device (device), ns); }/* We want to pause/continue resync, tell peer. */ if (ns.conn >=C_CONNECTED && ((os.aftr_isp != ns.aftr_isp) || (os.user_isp != ns.user_isp))) -drbd_send_state (device, ns); +drbd_send_state (first_peer_device (device), ns);/* In case one of the isp bits got set, suspend other devices. */ if ((!os.aftr_isp && !os.peer_isp && !os.user_isp) &&
@@ -1393,10 +1393,10 @@ static void after_state_ch(struct drbd_device *device, union drbd_state os,/* Make sure the peer gets informed about eventual state changes (ISP bits) while we were in WFReportParams. */ if (os.conn ==C_WF_REPORT_PARAMS && ns.conn >=C_CONNECTED ) -drbd_send_state (device, ns); +drbd_send_state (first_peer_device (device), ns);if (os.conn !=C_AHEAD && ns.conn ==C_AHEAD ) -drbd_send_state (device, ns); +drbd_send_state (first_peer_device (device), ns);/* We are in the progress to start a full sync... */ if ((os.conn != C_STARTING_SYNC_T && ns.conn == C_STARTING_SYNC_T) ||
@@ -1450,7 +1450,7 @@ static void after_state_ch(struct drbd_device *device, union drbd_state os, drbd_disk_str(device->state.disk));if (ns.conn >=C_CONNECTED ) -drbd_send_state (device, ns); +drbd_send_state (first_peer_device (device), ns);drbd_rs_cancel_all (device);
@@ -1474,7 +1474,7 @@ static void after_state_ch(struct drbd_device *device, union drbd_state os, drbd_disk_str(device->state.disk));if (ns.conn >=C_CONNECTED ) -drbd_send_state (device, ns); +drbd_send_state (first_peer_device (device), ns);/* corresponding get_ldev in __drbd_set_state * this may finally trigger drbd_ldev_destroy. */ put_ldev (device);
@@ -1482,7 +1482,7 @@ static void after_state_ch(struct drbd_device *device, union drbd_state os,/* Notify peer that I had a local IO error, and did not detached.. */ if (os.disk ==D_UP_TO_DATE && ns.disk ==D_INCONSISTENT && ns.conn >=C_CONNECTED ) -drbd_send_state (device, ns); +drbd_send_state (first_peer_device (device), ns);/* Disks got bigger while they were detached */ if (ns.disk > D_NEGOTIATING && ns.pdsk > D_NEGOTIATING &&
@@ -1500,14 +1500,14 @@ static void after_state_ch(struct drbd_device *device, union drbd_state os,/* sync target done with resync. Explicitly notify peer, even though * it should (at least for non-empty resyncs) already know itself. */ if (os.disk <D_UP_TO_DATE && os.conn >=C_SYNC_SOURCE && ns.conn ==C_CONNECTED ) -drbd_send_state (device, ns); +drbd_send_state (first_peer_device (device), ns);/* Verify finished, or reached stop sector. Peer did not know about * the stop sector, and we may even have changed the stop sector during * verify to interrupt/stop early. Send the new state. */ if (os.conn ==C_VERIFY_S && ns.conn ==C_CONNECTED &&verify_can_do_stop_sector (device)) -drbd_send_state (device, ns); +drbd_send_state (first_peer_device (device), ns);/* This triggers bitmap writeout of potentially still unwritten pages * if the resync finished cleanly, or aborted because of peer disk
drivers/block/drbd/drbd_worker.c +23 -22
164 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Philipp Reisner
maintainerPATCH 14/27 drbd: Remove useless assertion
In reply to Philipp ReisnerFrom: Andreas Gruenbacher <[email protected]>
--- drivers/block/drbd/drbd_state.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/block/drbd/drbd_state.c +1 -3
@@ -1165,10 +1165,8 @@ static int w_after_state_ch(struct drbd_work *w, int unused)struct drbd_device *device = w->device;after_state_ch (device, ascw->os, ascw->ns, ascw->flags); -if (ascw->flags &CS_WAIT_COMPLETE ) { -D_ASSERT (device, ascw->done !=NULL ); +if (ascw->flags &CS_WAIT_COMPLETE )complete (ascw->done); - }kfree (ascw);return 0 ;
Signature · 1 line
1.7.9.5
Philipp Reisner
maintainerPATCH 15/27 drbd: Move string function prototypes from linux/drbd.h to drbd_string.h
In reply to Philipp ReisnerFrom: Andreas Gruenbacher <[email protected]>
--- drivers/block/drbd/drbd_int.h | 1 + drivers/block/drbd/drbd_strings.c | 1 + drivers/block/drbd/drbd_strings.h | 9 +++++++++ include/linux/drbd.h | 6 ------ 4 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 drivers/block/drbd/drbd_strings.h
drivers/block/drbd/drbd_int.h +1 -0
@@ -45,6 +45,7 @@#include <linux/prefetch.h> #include <linux/drbd_genl_api.h> #include <linux/drbd.h> +#include "drbd_strings.h" #include "drbd_state.h" #include "drbd_protocol.h"
drivers/block/drbd/drbd_strings.c +1 -0
@@ -24,6 +24,7 @@*/ #include <linux/drbd.h> +#include "drbd_strings.h" static const char *drbd_conn_s_names[] = { [C_STANDALONE ] ="StandAlone" ,
drivers/block/drbd/drbd_strings.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef __DRBD_STRINGS_H +#define __DRBD_STRINGS_H + +extern const char *drbd_conn_str (enum drbd_conns ); +extern const char *drbd_role_str (enum drbd_role ); +extern const char *drbd_disk_str (enum drbd_disk_state ); +extern const char *drbd_set_st_err_str (enum drbd_state_rv ); + +#endif /* __DRBD_STRINGS_H */
include/linux/drbd.h +0 -6
@@ -327,12 +327,6 @@ enum drbd_state_rv { SS_AFTER_LAST_ERROR = -22, /* Keep this at bottom */ }; -/* from drbd_strings.c */ -extern const char *drbd_conn_str (enum drbd_conns ); -extern const char *drbd_role_str (enum drbd_role ); -extern const char *drbd_disk_str (enum drbd_disk_state ); -extern const char *drbd_set_st_err_str (enum drbd_state_rv ); -#define SHARED_SECRET_MAX 64#define MDF_CONSISTENT (1 << 0)
Signature · 1 line
1.7.9.5
Philipp Reisner
maintainerPATCH 16/27 drbd: Rename w_prev_work_done -> w_complete
In reply to Philipp ReisnerFrom: Andreas Gruenbacher <[email protected]>
Also move it to drbd_receiver.c and make it static.
--- drivers/block/drbd/drbd_int.h | 1 - drivers/block/drbd/drbd_receiver.c | 10 +++++++++- drivers/block/drbd/drbd_worker.c | 8 -------- 3 files changed, 9 insertions(+), 10 deletions(-)
drivers/block/drbd/drbd_int.h +0 -1
@@ -1321,7 +1321,6 @@ extern int w_send_write_hint(struct drbd_work *, int);extern int w_make_resync_request (struct drbd_work *,int );extern int w_send_dblock (struct drbd_work *,int );extern int w_send_read_req (struct drbd_work *,int ); -extern int w_prev_work_done (struct drbd_work *,int );extern int w_e_reissue (struct drbd_work *,int );extern int w_restart_disk_io (struct drbd_work *,int );extern int w_send_out_of_sync (struct drbd_work *,int );
drivers/block/drbd/drbd_receiver.c +9 -1
@@ -4481,11 +4481,19 @@ static void drbdd(struct drbd_connection *connection)conn_request_state (connection,NS (conn,C_PROTOCOL_ERROR ),CS_HARD ); } +static int w_complete (struct drbd_work *w,int cancel) +{ + struct drbd_wq_barrier *b = container_of(w, struct drbd_wq_barrier, w); + +complete (&b->done); +return 0 ; +} +void conn_flush_workqueue (struct drbd_connection *connection) {struct drbd_wq_barrier barr; - barr.w.cb = w_prev_work_done; + barr.w.cb = w_complete; barr.w.connection = connection;init_completion (&barr.done);drbd_queue_work (&connection->sender_work, &barr.w);
drivers/block/drbd/drbd_worker.c +0 -8
@@ -1262,14 +1262,6 @@ int w_e_end_ov_reply(struct drbd_work *w, int cancel)return err; } -int w_prev_work_done (struct drbd_work *w,int cancel) -{ - struct drbd_wq_barrier *b = container_of(w, struct drbd_wq_barrier, w); - -complete (&b->done); -return 0 ; -} -/* FIXME * We need to track the number of pending barrier acks, * and to be able to wait for them.
Signature · 1 line
1.7.9.5
Philipp Reisner
maintainerPATCH 17/27 drbd: Create a dedicated struct drbd_device_work
In reply to Philipp ReisnerFrom: Andreas Gruenbacher <[email protected]>
drbd_device_work is a work item that has a reference to a device, while drbd_work is a more generic work item that does not carry a reference to a device.
All callbacks get a pointer to a drbd_work instance, those callbacks that expect a drbd_device_work use the container_of macro to get it.
--- drivers/block/drbd/drbd_actlog.c | 16 +++-- drivers/block/drbd/drbd_int.h | 29 ++++---- drivers/block/drbd/drbd_main.c | 32 ++++----- drivers/block/drbd/drbd_receiver.c | 84 +++++++++++----------- drivers/block/drbd/drbd_req.c | 41 ++++++----- drivers/block/drbd/drbd_req.h | 4 +- drivers/block/drbd/drbd_state.c | 21 +++--- drivers/block/drbd/drbd_worker.c | 134 ++++++++++++++++++++---------------- 8 files changed, 197 insertions(+), 164 deletions(-)
drivers/block/drbd/drbd_actlog.c +10 -6
@@ -95,11 +95,13 @@ struct __packed al_transaction_on_disk {struct update_odbm_work {struct drbd_work w; +struct drbd_device *device;unsigned int enr; };struct update_al_work {struct drbd_work w; +struct drbd_device *device;struct completion event;int err; };
@@ -593,7 +595,7 @@ _al_write_transaction(struct drbd_device *device)static int w_al_write_transaction (struct drbd_work *w,int unused) { struct update_al_work *aw = container_of(w, struct update_al_work, w); -struct drbd_device *device = w->device; +struct drbd_device *device = aw->device;int err; err =_al_write_transaction (device);
@@ -612,8 +614,9 @@ static int al_write_transaction(struct drbd_device *device, bool delegate)struct update_al_work al_work;init_completion (&al_work.event); al_work.w.cb = w_al_write_transaction; - al_work.w.device = device; -drbd_queue_work_front (&first_peer_device (device)->connection->sender_work, &al_work.w); + al_work.device = device; +drbd_queue_work_front (&first_peer_device (device)->connection->sender_work, + &al_work.w);wait_for_completion (&al_work.event);return al_work.err; }else
@@ -683,7 +686,7 @@ int drbd_initialize_al(struct drbd_device *device, void *buffer)static int w_update_odbm (struct drbd_work *w,int unused) { struct update_odbm_work *udw = container_of(w, struct update_odbm_work, w); -struct drbd_device *device = w->device; +struct drbd_device *device = udw->device;struct sib_info sib = { .sib_reason =SIB_SYNC_PROGRESS , };if (!get_ldev (device)) {
@@ -794,8 +797,9 @@ static void drbd_try_clear_on_disk_bm(struct drbd_device *device, sector_t sectoif (udw) { udw->enr = ext->lce.lc_number; udw->w.cb = w_update_odbm; - udw->w.device = device; -drbd_queue_work_front (&first_peer_device (device)->connection->sender_work, &udw->w); + udw->device = device; +drbd_queue_work_front (&first_peer_device (device)->connection->sender_work, + &udw->w); }else {drbd_warn (device,"Could not kmalloc an udw\n" ); }
drivers/block/drbd/drbd_int.h +17 -12
@@ -280,10 +280,11 @@ static inline enum drbd_thread_state get_t_state(struct drbd_thread *thi)struct drbd_work {struct list_head list;int (*cb)(struct drbd_work *,int cancel); -union { -struct drbd_device *device; -struct drbd_connection *connection; - }; +}; + +struct drbd_device_work { +struct drbd_work w; +struct drbd_device *device; };#include "drbd_interval.h"
@@ -292,6 +293,7 @@ extern int drbd_wait_misc(struct drbd_device *, struct drbd_interval *);struct drbd_request {struct drbd_work w; +struct drbd_device *device;/* if local IO is not allowed, will be NULL. * if local IO _is_ allowed, holds the locally submitted bio clone,
@@ -355,7 +357,7 @@ struct digest_info { };struct drbd_peer_request { -struct drbd_work w; +struct drbd_device_work dw;struct drbd_epoch *epoch;/* for writes */ struct page *pages;atomic_t pending_bios;
@@ -681,11 +683,11 @@ struct drbd_device {struct gendisk *vdisk;unsigned long last_reattach_jif; -struct drbd_work resync_work, - unplug_work, - go_diskless, - md_sync_work, - start_resync_work; +struct drbd_work resync_work; +struct drbd_work unplug_work; +struct drbd_work go_diskless; +struct drbd_work md_sync_work; +struct drbd_work start_resync_work;struct timer_list resync_timer;struct timer_list md_sync_timer;struct timer_list start_resync_timer;
@@ -1860,7 +1862,8 @@ static inline void put_ldev(struct drbd_device *device)if (device->state.disk ==D_FAILED ) {/* all application IO references gone. */ if (!test_and_set_bit (GO_DISKLESS , &device->flags)) -drbd_queue_work (&first_peer_device (device)->connection->sender_work, &device->go_diskless); +drbd_queue_work (&first_peer_device (device)->connection->sender_work, + &device->go_diskless); }wake_up (&device->misc_wait); }
@@ -2087,7 +2090,9 @@ static inline void dec_ap_bio(struct drbd_device *device)if (ap_bio ==0 &&test_bit (BITMAP_IO , &device->flags)) {if (!test_and_set_bit (BITMAP_IO_QUEUED , &device->flags)) -drbd_queue_work (&first_peer_device (device)->connection->sender_work, &device->bm_io_work.w); +drbd_queue_work (&first_peer_device (device)-> + connection->sender_work, + &device->bm_io_work.w); }/* this currently does wake_up for every dec_ap_bio!
drivers/block/drbd/drbd_main.c +15 -17
@@ -312,7 +312,7 @@ void tl_abort_disk_io(struct drbd_device *device)list_for_each_entry_safe (req, r, &connection->transfer_log, tl_requests) {if (!(req->rq_state &RQ_LOCAL_PENDING ))continue ; -if (req->w.device != device) +if (req->device != device)continue ;_req_mod (req,ABORT_DISK_IO ); }
@@ -1917,13 +1917,6 @@ void drbd_init_set_defaults(struct drbd_device *device) device->bm_io_work.w.cb = w_bitmap_io; device->start_resync_work.cb = w_start_resync; - device->resync_work.device = device; - device->unplug_work.device = device; - device->go_diskless.device = device; - device->md_sync_work.device = device; - device->bm_io_work.w.device = device; - device->start_resync_work.device = device; -init_timer (&device->resync_timer);init_timer (&device->md_sync_timer);init_timer (&device->start_resync_timer);
@@ -2222,12 +2215,12 @@ static void do_retry(struct work_struct *ws)spin_unlock_irq (&retry->lock);list_for_each_entry_safe (req, tmp, &writes, tl_requests) { -struct drbd_device *device = req->w.device; +struct drbd_device *device = req->device;struct bio *bio = req->master_bio;unsigned long start_time = req->start_time;bool expected; - expected = + expected =expect (atomic_read (&req->completion_ref) ==0 ) &&expect (req->rq_state &RQ_POSTPONED ) && expect((req->rq_state & RQ_LOCAL_PENDING) == 0 ||
@@ -2273,7 +2266,7 @@ void drbd_restart_request(struct drbd_request *req)/* Drop the extra reference that would otherwise * have been dropped by complete_master_bio. * do_retry() needs to grab a new one. */ -dec_ap_bio (req->w.device); +dec_ap_bio (req->device);queue_work (retry.wq, &retry.worker); }
@@ -3468,8 +3461,9 @@ int drbd_bmio_clear_n_write(struct drbd_device *device)static int w_bitmap_io (struct drbd_work *w,int unused) { - struct bm_io_work *work = container_of(w, struct bm_io_work, w); -struct drbd_device *device = w->device; +struct drbd_device *device = + container_of(w, struct drbd_device, bm_io_work.w); +struct bm_io_work *work = &device->bm_io_work;int rv = -EIO ;D_ASSERT (device,atomic_read (&device->ap_bio_cnt) ==0 );
@@ -3509,7 +3503,8 @@ void drbd_ldev_destroy(struct drbd_device *device)static int w_go_diskless (struct drbd_work *w,int unused) { -struct drbd_device *device = w->device; +struct drbd_device *device = + container_of(w, struct drbd_device, go_diskless);D_ASSERT (device, device->state.disk ==D_FAILED );/* we cannot assert local_cnt == 0 here, as get_ldev_if_state will
@@ -3583,7 +3578,8 @@ void drbd_queue_bitmap_io(struct drbd_device *device,set_bit (BITMAP_IO , &device->flags);if (atomic_read (&device->ap_bio_cnt) ==0 ) {if (!test_and_set_bit (BITMAP_IO_QUEUED , &device->flags)) -drbd_queue_work (&first_peer_device (device)->connection->sender_work, &device->bm_io_work.w); +drbd_queue_work (&first_peer_device (device)->connection->sender_work, + &device->bm_io_work.w); }spin_unlock_irq (&device->resource->req_lock); }
@@ -3643,12 +3639,14 @@ static void md_sync_timer_fn(unsigned long data)/* must not double-queue! */ if (list_empty (&device->md_sync_work.list)) -drbd_queue_work_front (&first_peer_device (device)->connection->sender_work, &device->md_sync_work); +drbd_queue_work_front (&first_peer_device (device)->connection->sender_work, + &device->md_sync_work); }static int w_md_sync (struct drbd_work *w,int unused) { -struct drbd_device *device = w->device; +struct drbd_device *device = + container_of(w, struct drbd_device, md_sync_work);drbd_warn (device,"md_sync_timer expired! Worker calls drbd_md_sync().\n" );#ifdef DEBUG
drivers/block/drbd/drbd_receiver.c +43 -41
260 lines not on this page · raw message
drivers/block/drbd/drbd_req.c +23 -18
147 lines not on this page · raw message
drivers/block/drbd/drbd_req.h +2 -2
@@ -294,7 +294,7 @@ extern void drbd_restart_request(struct drbd_request *req);* outside the spinlock, e.g. when walking some list on cleanup. */ static inline int _req_mod (struct drbd_request *req,enum drbd_req_event what) { -struct drbd_device *device = req->w.device; +struct drbd_device *device = req->device;struct bio_and_error m;int rv;
@@ -314,7 +314,7 @@ static inline int req_mod(struct drbd_request *req, enum drbd_req_event what) {unsigned long flags; -struct drbd_device *device = req->w.device; +struct drbd_device *device = req->device;struct bio_and_error m;int rv;
drivers/block/drbd/drbd_state.c +12 -9
@@ -35,6 +35,7 @@ extern void tl_abort_disk_io(struct drbd_device *device);struct after_state_chg_work {struct drbd_work w; +struct drbd_device *device;union drbd_state os;union drbd_state ns;enum chg_state_flags flags;
@@ -1148,9 +1149,10 @@ __drbd_set_state(struct drbd_device *device, union drbd_state ns, ascw->ns = ns; ascw->flags = flags; ascw->w.cb = w_after_state_ch; - ascw->w.device = device; + ascw->device = device; ascw->done = done; -drbd_queue_work (&first_peer_device (device)->connection->sender_work, &ascw->w); +drbd_queue_work (&first_peer_device (device)->connection->sender_work, + &ascw->w); }else {drbd_err (device,"Could not kmalloc an ascw\n" ); }
@@ -1162,7 +1164,7 @@ static int w_after_state_ch(struct drbd_work *w, int unused) {struct after_state_chg_work *ascw = container_of(w, struct after_state_chg_work, w); -struct drbd_device *device = w->device; +struct drbd_device *device = ascw->device;after_state_ch (device, ascw->os, ascw->ns, ascw->flags);if (ascw->flags &CS_WAIT_COMPLETE )
@@ -1531,18 +1533,19 @@ static void after_state_ch(struct drbd_device *device, union drbd_state os, }struct after_conn_state_chg_work { -struct drbd_work w; +struct drbd_device_work dw;enum drbd_conns oc;union drbd_state ns_min;union drbd_state ns_max;/* new, max state, over all devices */ enum chg_state_flags flags; +struct drbd_connection *connection; };static int w_after_conn_state_ch (struct drbd_work *w,int unused) {struct after_conn_state_chg_work *acscw = - container_of(w, struct after_conn_state_chg_work, w); -struct drbd_connection *connection = w->connection; + container_of(w, struct after_conn_state_chg_work, dw.w); +struct drbd_connection *connection = acscw->connection;enum drbd_conns oc = acscw->oc;union drbd_state ns_max = acscw->ns_max;struct drbd_peer_device *peer_device;
@@ -1843,10 +1846,10 @@ _conn_request_state(struct drbd_connection *connection, union drbd_state mask, u acscw->ns_min = ns_min; acscw->ns_max = ns_max; acscw->flags = flags; - acscw->w.cb = w_after_conn_state_ch; + acscw->dw.w.cb = w_after_conn_state_ch;kref_get (&connection->kref); - acscw->w.connection = connection; -drbd_queue_work (&connection->sender_work, &acscw->w); + acscw->connection = connection; +drbd_queue_work (&connection->sender_work, &acscw->dw.w); }else {drbd_err (connection,"Could not kmalloc an acscw\n" ); }
drivers/block/drbd/drbd_worker.c +75 -59
375 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Philipp Reisner
maintainerPATCH 18/27 drbd: Turn conn_flush_workqueue() into drbd_flush_workqueue()
In reply to Philipp ReisnerFrom: Andreas Gruenbacher <[email protected]>
The new function can flush any work queue, not just the work queue of the data socket of a connection.
--- drivers/block/drbd/drbd_int.h | 12 ++---------- drivers/block/drbd/drbd_main.c | 24 ++++++++++++++++++++++++ drivers/block/drbd/drbd_nl.c | 10 +++++----- drivers/block/drbd/drbd_receiver.c | 22 ++-------------------- 4 files changed, 33 insertions(+), 35 deletions(-)
drivers/block/drbd/drbd_int.h +2 -10
@@ -346,11 +346,6 @@ enum epoch_event { EV_CLEANUP = 32, /* used as flag */ }; -struct drbd_wq_barrier { -struct drbd_work w; -struct completion done; -}; -struct digest_info {int digest_size;void *digest;
@@ -1349,12 +1344,7 @@ extern void __drbd_free_peer_req(struct drbd_device *, struct drbd_peer_requestextern struct page *drbd_alloc_pages (struct drbd_peer_device *,unsigned int ,bool );extern void drbd_set_recv_tcq (struct drbd_device *device,int tcq_enabled);extern void _drbd_clear_done_ee (struct drbd_device *device,struct list_head *to_be_freed); -extern void conn_flush_workqueue (struct drbd_connection *connection);extern int drbd_connected (struct drbd_peer_device *); -static inline void drbd_flush_workqueue (struct drbd_device *device) -{ -conn_flush_workqueue (first_peer_device (device)->connection); -}/* Yes, there is kernel_setsockopt, but only since 2.6.18. * So we have our own copy of it here. */
@@ -1709,6 +1699,8 @@ drbd_queue_work(struct drbd_work_queue *q, struct drbd_work *w)wake_up (&q->q_wait); } +extern void drbd_flush_workqueue (struct drbd_work_queue *work_queue); +static inline void wake_asender (struct drbd_connection *connection) {if (test_bit (SIGNAL_ASENDER , &connection->flags))
drivers/block/drbd/drbd_main.c +24 -0
@@ -2397,6 +2397,30 @@ static void drbd_init_workqueue(struct drbd_work_queue* wq)init_waitqueue_head (&wq->q_wait); } +struct completion_work { +struct drbd_work w; +struct completion done; +}; + +static int w_complete (struct drbd_work *w,int cancel) +{ +struct completion_work *completion_work = + container_of(w, struct completion_work, w); + +complete (&completion_work->done); +return 0 ; +} + +void drbd_flush_workqueue (struct drbd_work_queue *work_queue) +{ +struct completion_work completion_work; + + completion_work.w.cb = w_complete; +init_completion (&completion_work.done); +drbd_queue_work (work_queue, &completion_work.w); +wait_for_completion (&completion_work.done); +} +struct drbd_resource *drbd_find_resource (const char *name) {struct drbd_resource *resource;
drivers/block/drbd/drbd_nl.c +5 -5
@@ -1181,7 +1181,7 @@ void drbd_reconsider_max_bio_size(struct drbd_device *device)static void conn_reconfig_start (struct drbd_connection *connection) {drbd_thread_start (&connection->worker); -conn_flush_workqueue (connection); +drbd_flush_workqueue (&connection->sender_work); }/* if still unconfigured, stops worker again. */
@@ -1600,7 +1600,7 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info)*/ wait_event (device->misc_wait, !atomic_read (&device->ap_pending_cnt) ||drbd_suspended (device));/* and for any other previously queued work */ -drbd_flush_workqueue (device); +drbd_flush_workqueue (&first_peer_device (device)->connection->sender_work); rv =_drbd_request_state (device,NS (disk,D_ATTACHING ),CS_VERBOSE ); retcode = rv;/* FIXME: Type mismatch. */
@@ -2249,7 +2249,7 @@ int drbd_adm_connect(struct sk_buff *skb, struct genl_info *info) ((char *)new_net_conf->shared_secret)[SHARED_SECRET_MAX -1 ] =0 ; -conn_flush_workqueue (connection); +drbd_flush_workqueue (&connection->sender_work);mutex_lock (&adm_ctx.resource->conf_update); old_net_conf = connection->net_conf;
@@ -2589,7 +2589,7 @@ int drbd_adm_invalidate(struct sk_buff *skb, struct genl_info *info)* Also wait for it's after_state_ch(). */ drbd_suspend_io (device);wait_event (device->misc_wait, !test_bit (BITMAP_IO , &device->flags)); -drbd_flush_workqueue (device); +drbd_flush_workqueue (&first_peer_device (device)->connection->sender_work);/* If we happen to be C_STANDALONE R_SECONDARY, just change to * D_INCONSISTENT, and set all bits in the bitmap. Otherwise,
@@ -2655,7 +2655,7 @@ int drbd_adm_invalidate_peer(struct sk_buff *skb, struct genl_info *info)* Also wait for it's after_state_ch(). */ drbd_suspend_io (device);wait_event (device->misc_wait, !test_bit (BITMAP_IO , &device->flags)); -drbd_flush_workqueue (device); +drbd_flush_workqueue (&first_peer_device (device)->connection->sender_work);/* If we happen to be C_STANDALONE R_PRIMARY, just set all bits * in the bitmap. Otherwise, try to start a resync handshake
drivers/block/drbd/drbd_receiver.c +2 -20
@@ -4484,24 +4484,6 @@ static void drbdd(struct drbd_connection *connection)conn_request_state (connection,NS (conn,C_PROTOCOL_ERROR ),CS_HARD ); } -static int w_complete (struct drbd_work *w,int cancel) -{ - struct drbd_wq_barrier *b = container_of(w, struct drbd_wq_barrier, w); - -complete (&b->done); -return 0 ; -} - -void conn_flush_workqueue (struct drbd_connection *connection) -{ -struct drbd_wq_barrier barr; - - barr.w.cb = w_complete; -init_completion (&barr.done); -drbd_queue_work (&connection->sender_work, &barr.w); -wait_for_completion (&barr.done); -} -static void conn_disconnect (struct drbd_connection *connection) {struct drbd_peer_device *peer_device;
@@ -4589,14 +4571,14 @@ static int drbd_disconnected(struct drbd_peer_device *peer_device)/* wait for all w_e_end_data_req, w_e_end_rsdata_req, w_send_barrier, * w_make_resync_request etc. which may still be on the worker queue * to be "canceled" */ -drbd_flush_workqueue (device); +drbd_flush_workqueue (&peer_device->connection->sender_work);drbd_finish_peer_reqs (device);/* This second workqueue flush is necessary, since drbd_finish_peer_reqs() might have issued a work again. The one before drbd_finish_peer_reqs() is necessary to reclain net_ee in drbd_finish_peer_reqs(). */ -drbd_flush_workqueue (device); +drbd_flush_workqueue (&peer_device->connection->sender_work);/* need to do it again, drbd_finish_peer_reqs() may have populated it * again via drbd_try_clear_on_disk_bm(). */
Signature · 1 line
1.7.9.5
Philipp Reisner
maintainerPATCH 19/27 drbd: struct after_conn_state_chg_work: Use drbd_work instead of drbd_device_work
In reply to Philipp ReisnerFrom: Andreas Gruenbacher <[email protected]>
--- drivers/block/drbd/drbd_state.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/block/drbd/drbd_state.c +4 -4
@@ -1533,7 +1533,7 @@ static void after_state_ch(struct drbd_device *device, union drbd_state os, }struct after_conn_state_chg_work { -struct drbd_device_work dw; +struct drbd_work w;enum drbd_conns oc;union drbd_state ns_min;union drbd_state ns_max;/* new, max state, over all devices */
@@ -1544,7 +1544,7 @@ struct after_conn_state_chg_work {static int w_after_conn_state_ch (struct drbd_work *w,int unused) {struct after_conn_state_chg_work *acscw = - container_of(w, struct after_conn_state_chg_work, dw.w); + container_of(w, struct after_conn_state_chg_work, w);struct drbd_connection *connection = acscw->connection;enum drbd_conns oc = acscw->oc;union drbd_state ns_max = acscw->ns_max;
@@ -1846,10 +1846,10 @@ _conn_request_state(struct drbd_connection *connection, union drbd_state mask, u acscw->ns_min = ns_min; acscw->ns_max = ns_max; acscw->flags = flags; - acscw->dw.w.cb = w_after_conn_state_ch; + acscw->w.cb = w_after_conn_state_ch;kref_get (&connection->kref); acscw->connection = connection; -drbd_queue_work (&connection->sender_work, &acscw->dw.w); +drbd_queue_work (&connection->sender_work, &acscw->w); }else {drbd_err (connection,"Could not kmalloc an acscw\n" ); }
Signature · 1 line
1.7.9.5
Philipp Reisner
maintainerPATCH 20/27 drbd: struct drbd_peer_request: Use drbd_work instead of drbd_device_work
In reply to Philipp ReisnerFrom: Andreas Gruenbacher <[email protected]>
--- drivers/block/drbd/drbd_int.h | 3 +- drivers/block/drbd/drbd_receiver.c | 91 ++++++++++++++++++------------------ drivers/block/drbd/drbd_worker.c | 50 +++++++++----------- 3 files changed, 69 insertions(+), 75 deletions(-)
drivers/block/drbd/drbd_int.h +2 -1
@@ -352,7 +352,8 @@ struct digest_info { };struct drbd_peer_request { -struct drbd_device_work dw; +struct drbd_work w; +struct drbd_peer_device *peer_device;struct drbd_epoch *epoch;/* for writes */ struct page *pages;atomic_t pending_bios;
drivers/block/drbd/drbd_receiver.c +45 -46
277 lines not on this page · raw message
drivers/block/drbd/drbd_worker.c +22 -28
138 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Philipp Reisner
maintainerPATCH 21/27 drbd: Make w_make_resync_request() static
In reply to Philipp ReisnerFrom: Andreas Gruenbacher <[email protected]>
--- drivers/block/drbd/drbd_int.h | 1 - drivers/block/drbd/drbd_worker.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/block/drbd/drbd_int.h +0 -1
@@ -1316,7 +1316,6 @@ extern int w_e_end_ov_req(struct drbd_work *, int);extern int w_ov_finished (struct drbd_work *,int );extern int w_resync_timer (struct drbd_work *,int );extern int w_send_write_hint (struct drbd_work *,int ); -extern int w_make_resync_request (struct drbd_work *,int );extern int w_send_dblock (struct drbd_work *,int );extern int w_send_read_req (struct drbd_work *,int );extern int w_e_reissue (struct drbd_work *,int );
drivers/block/drbd/drbd_worker.c +2 -2
@@ -40,7 +40,7 @@#include "drbd_req.h" static int w_make_ov_request (struct drbd_work *,int ); - +static int w_make_resync_request (struct drbd_work *,int );/* endio handlers: * drbd_md_io_complete (defined here)
@@ -565,7 +565,7 @@ static int drbd_rs_number_requests(struct drbd_device *device)return number; } -int w_make_resync_request (struct drbd_work *w,int cancel) +static int w_make_resync_request (struct drbd_work *w,int cancel) {struct drbd_device_work *dw =device_work (w);struct drbd_device *device = dw->device;
Signature · 1 line
1.7.9.5
Philipp Reisner
maintainerPATCH 22/27 drbd: Turn w_make_ov_request and make_resync_request into "normal" functions
In reply to Philipp ReisnerFrom: Andreas Gruenbacher <[email protected]>
These functions are not used as drbd_work callbacks.
--- drivers/block/drbd/drbd_worker.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/block/drbd/drbd_worker.c +6 -9
@@ -39,8 +39,8 @@#include "drbd_protocol.h" #include "drbd_req.h" -static int w_make_ov_request (struct drbd_work *,int ); -static int w_make_resync_request (struct drbd_work *,int ); +static int make_ov_request (struct drbd_device *,int ); +static int make_resync_request (struct drbd_device *,int );/* endio handlers: * drbd_md_io_complete (defined here)
@@ -427,10 +427,10 @@ int w_resync_timer(struct drbd_work *w, int cancel)switch (device->state.conn) {case C_VERIFY_S : -w_make_ov_request (w, cancel); +make_ov_request (device, cancel);break ;case C_SYNC_TARGET : -w_make_resync_request (w, cancel); +make_resync_request (device, cancel);break ; }
@@ -565,10 +565,8 @@ static int drbd_rs_number_requests(struct drbd_device *device)return number; } -static int w_make_resync_request (struct drbd_work *w,int cancel) +static int make_resync_request (struct drbd_device *device,int cancel) { -struct drbd_device_work *dw =device_work (w); -struct drbd_device *device = dw->device;unsigned long bit;sector_t sector;const sector_t capacity =drbd_get_capacity (device->this_bdev);
@@ -730,9 +728,8 @@ next_sector:return 0 ; } -static int w_make_ov_request (struct drbd_work *w,int cancel) +static int make_ov_request (struct drbd_device *device,int cancel) { -struct drbd_device *device =device_work (w)->device;int number, i, size;sector_t sector;const sector_t capacity =drbd_get_capacity (device->this_bdev);
Signature · 1 line
1.7.9.5
Philipp Reisner
maintainerPATCH 23/27 drbd: In the worker thread, process drbd_work instead of drbd_device_work items
In reply to Philipp ReisnerFrom: Andreas Gruenbacher <[email protected]>
--- drivers/block/drbd/drbd_worker.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/block/drbd/drbd_worker.c +7 -7
@@ -1888,7 +1888,7 @@ void wait_for_work(struct drbd_connection *connection, struct list_head *work_liint drbd_worker (struct drbd_thread *thi) {struct drbd_connection *connection = thi->connection; -struct drbd_device_work *dw =NULL ; +struct drbd_work *w =NULL ;struct drbd_peer_device *peer_device;LIST_HEAD (work_list);int vnr;
@@ -1914,9 +1914,9 @@ int drbd_worker(struct drbd_thread *thi)break ;while (!list_empty (&work_list)) { - dw = list_first_entry(&work_list, struct drbd_device_work, w.list); -list_del_init (&dw->w.list); -if (dw->w.cb (&dw->w, connection->cstate <C_WF_REPORT_PARAMS ) ==0 ) + w = list_first_entry(&work_list, struct drbd_work, list); +list_del_init (&w->list); +if (w->cb (w, connection->cstate <C_WF_REPORT_PARAMS ) ==0 )continue ;if (connection->cstate >=C_WF_REPORT_PARAMS )conn_request_state (connection,NS (conn,C_NETWORK_FAILURE ),CS_HARD );
@@ -1925,9 +1925,9 @@ int drbd_worker(struct drbd_thread *thi)do {while (!list_empty (&work_list)) { - dw = list_first_entry(&work_list, struct drbd_device_work, w.list); -list_del_init (&dw->w.list); - dw->w.cb (&dw->w,1 ); + w = list_first_entry(&work_list, struct drbd_work, list); +list_del_init (&w->list); + w->cb (w,1 ); }dequeue_work_batch (&connection->sender_work, &work_list); }while (!list_empty (&work_list));
Signature · 1 line
1.7.9.5
Philipp Reisner
maintainerPATCH 24/27 drbd: Get rid of first_peer_device() in handle_write_conflicts()
In reply to Philipp ReisnerFrom: Andreas Gruenbacher <[email protected]>
--- drivers/block/drbd/drbd_receiver.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/block/drbd/drbd_receiver.c +3 -5
@@ -2065,7 +2065,7 @@ static void fail_postponed_requests(struct drbd_device *device, sector_t sector,static int handle_write_conflicts (struct drbd_device *device,struct drbd_peer_request *peer_req) { -struct drbd_connection *connection =first_peer_device (device)->connection; +struct drbd_connection *connection = peer_req->peer_device->connection;bool resolve_conflicts =test_bit (RESOLVE_CONFLICTS , &connection->flags);sector_t sector = peer_req->i.sector;const unsigned int size = peer_req->i.size;
@@ -2119,7 +2119,7 @@ static int handle_write_conflicts(struct drbd_device *device, peer_req->w.cb = superseded ? e_send_superseded : e_send_retry_write;list_add_tail (&peer_req->w.list, &device->done_ee); -wake_asender (first_peer_device (device)->connection); +wake_asender (connection); err = -ENOENT ; goto out;
@@ -2148,9 +2148,7 @@ static int handle_write_conflicts(struct drbd_device *device,*/ err =drbd_wait_misc (device, &req->i);if (err) { -_conn_request_state (first_peer_device (device)->connection, -NS (conn,C_TIMEOUT ), -CS_HARD ); +_conn_request_state (connection,NS (conn,C_TIMEOUT ),CS_HARD );fail_postponed_requests (device, sector, size); goto out; }
Signature · 1 line
1.7.9.5
Philipp Reisner
maintainerPATCH 25/27 drbd: Remove unused parameter of wire_flags_to_bio()
In reply to Philipp ReisnerFrom: Andreas Gruenbacher <[email protected]>
--- drivers/block/drbd/drbd_receiver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/drbd/drbd_receiver.c +2 -2
@@ -2029,7 +2029,7 @@ static int wait_for_and_update_peer_seq(struct drbd_peer_device *peer_device, co/* see also bio_flags_to_wire() * DRBD_REQ_*, because we need to semantically map the flags to data packet * flags and back. We may replicate to other kernel versions. */ -static unsigned long wire_flags_to_bio (struct drbd_device *device,u32 dpf) +static unsigned long wire_flags_to_bio (u32 dpf) {return (dpf &DP_RW_SYNC ?REQ_SYNC :0 ) | (dpf & DP_FUA ? REQ_FUA : 0) |
@@ -2215,7 +2215,7 @@ static int receive_Data(struct drbd_connection *connection, struct packet_info * peer_req->w.cb = e_end_block; dp_flags =be32_to_cpu (p->dp_flags); - rw |=wire_flags_to_bio (device, dp_flags); + rw |=wire_flags_to_bio (dp_flags);if (peer_req->pages ==NULL ) {D_ASSERT (device, peer_req->i.size ==0 );D_ASSERT (device, dp_flags &DP_FLUSH );
Signature · 1 line
1.7.9.5
Philipp Reisner
maintainerPATCH 26/27 drbd: Use the right peer device
In reply to Philipp ReisnerFrom: Andreas Gruenbacher <[email protected]>
in w_e_ (peer request) callbacks and in peer request I/O completion handlers
--- drivers/block/drbd/drbd_worker.c | 69 +++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 31 deletions(-)
drivers/block/drbd/drbd_worker.c +38 -31
@@ -100,7 +100,8 @@ void drbd_md_io_complete(struct bio *bio, int error)void drbd_endio_read_sec_final (struct drbd_peer_request *peer_req)__releases (local) {unsigned long flags =0 ; -struct drbd_device *device = peer_req->peer_device->device; +struct drbd_peer_device *peer_device = peer_req->peer_device; +struct drbd_device *device = peer_device->device;spin_lock_irqsave (&device->resource->req_lock, flags); device->read_cnt += peer_req->i.size >>9 ;
@@ -111,8 +112,7 @@ void drbd_endio_read_sec_final(struct drbd_peer_request *peer_req) __releases(lo__drbd_chk_io_error (device,DRBD_READ_ERROR );spin_unlock_irqrestore (&device->resource->req_lock, flags); -drbd_queue_work (&first_peer_device (device)->connection->sender_work, - &peer_req->w); +drbd_queue_work (&peer_device->connection->sender_work, &peer_req->w);put_ldev (device); }
@@ -121,7 +121,8 @@ void drbd_endio_read_sec_final(struct drbd_peer_request *peer_req) __releases(lostatic void drbd_endio_write_sec_final (struct drbd_peer_request *peer_req)__releases (local) {unsigned long flags =0 ; -struct drbd_device *device = peer_req->peer_device->device; +struct drbd_peer_device *peer_device = peer_req->peer_device; +struct drbd_device *device = peer_device->device;struct drbd_interval i;int do_wake;u64 block_id;
@@ -162,7 +163,7 @@ static void drbd_endio_write_sec_final(struct drbd_peer_request *peer_req) __relif (do_al_complete_io)drbd_al_complete_io (device, &i); -wake_asender (first_peer_device (device)->connection); +wake_asender (peer_device->connection);put_ldev (device); }
@@ -334,7 +335,8 @@ void drbd_csum_bio(struct crypto_hash *tfm, struct bio *bio, void *digest)static int w_e_send_csum (struct drbd_work *w,int cancel) { struct drbd_peer_request *peer_req = container_of(w, struct drbd_peer_request, w); -struct drbd_device *device = peer_req->peer_device->device; +struct drbd_peer_device *peer_device = peer_req->peer_device; +struct drbd_device *device = peer_device->device;int digest_size;void *digest;int err =0 ;
@@ -345,12 +347,12 @@ static int w_e_send_csum(struct drbd_work *w, int cancel)if (unlikely ((peer_req->flags &EE_WAS_ERROR ) !=0 )) goto out; - digest_size =crypto_hash_digestsize (first_peer_device (device)->connection->csums_tfm); + digest_size =crypto_hash_digestsize (peer_device->connection->csums_tfm); digest =kmalloc (digest_size,GFP_NOIO );if (digest) {sector_t sector = peer_req->i.sector;unsigned int size = peer_req->i.size; -drbd_csum_ee (first_peer_device (device)->connection->csums_tfm, peer_req, digest); +drbd_csum_ee (peer_device->connection->csums_tfm, peer_req, digest);/* Free peer_req and pages before send. * In case we block on congestion, we could otherwise run into * some distributed deadlock, if the other side blocks on
@@ -359,7 +361,7 @@ static int w_e_send_csum(struct drbd_work *w, int cancel)drbd_free_peer_req (device, peer_req); peer_req =NULL ;inc_rs_pending (device); - err =drbd_send_drequest_csum (first_peer_device (device), sector, size, + err =drbd_send_drequest_csum (peer_device, sector, size, digest, digest_size,P_CSUM_RS_REQUEST );kfree (digest);
@@ -995,7 +997,8 @@ static void move_to_net_ee_or_free(struct drbd_device *device, struct drbd_peer_int w_e_end_data_req (struct drbd_work *w,int cancel) { struct drbd_peer_request *peer_req = container_of(w, struct drbd_peer_request, w); -struct drbd_device *device = peer_req->peer_device->device; +struct drbd_peer_device *peer_device = peer_req->peer_device; +struct drbd_device *device = peer_device->device;int err;if (unlikely (cancel)) {
@@ -1005,13 +1008,13 @@ int w_e_end_data_req(struct drbd_work *w, int cancel) }if (likely ((peer_req->flags &EE_WAS_ERROR ) ==0 )) { - err =drbd_send_block (first_peer_device (device),P_DATA_REPLY , peer_req); + err =drbd_send_block (peer_device,P_DATA_REPLY , peer_req); }else {if (__ratelimit (&drbd_ratelimit_state))drbd_err (device,"Sending NegDReply. sector=%llus.\n" , (unsigned long long )peer_req->i.sector); - err =drbd_send_ack (first_peer_device (device),P_NEG_DREPLY , peer_req); + err =drbd_send_ack (peer_device,P_NEG_DREPLY , peer_req); }dec_unacked (device);
@@ -1031,7 +1034,8 @@ int w_e_end_data_req(struct drbd_work *w, int cancel)int w_e_end_rsdata_req (struct drbd_work *w,int cancel) { struct drbd_peer_request *peer_req = container_of(w, struct drbd_peer_request, w); -struct drbd_device *device = peer_req->peer_device->device; +struct drbd_peer_device *peer_device = peer_req->peer_device; +struct drbd_device *device = peer_device->device;int err;if (unlikely (cancel)) {
@@ -1046,11 +1050,11 @@ int w_e_end_rsdata_req(struct drbd_work *w, int cancel) }if (device->state.conn ==C_AHEAD ) { - err =drbd_send_ack (first_peer_device (device),P_RS_CANCEL , peer_req); + err =drbd_send_ack (peer_device,P_RS_CANCEL , peer_req); }else if (likely ((peer_req->flags &EE_WAS_ERROR ) ==0 )) {if (likely (device->state.pdsk >=D_INCONSISTENT )) {inc_rs_pending (device); - err =drbd_send_block (first_peer_device (device),P_RS_DATA_REPLY , peer_req); + err =drbd_send_block (peer_device,P_RS_DATA_REPLY , peer_req); }else {if (__ratelimit (&drbd_ratelimit_state)) drbd_err(device, "Not sending RSDataReply, "
@@ -1062,7 +1066,7 @@ int w_e_end_rsdata_req(struct drbd_work *w, int cancel)drbd_err (device,"Sending NegRSDReply. sector %llus.\n" , (unsigned long long )peer_req->i.sector); - err =drbd_send_ack (first_peer_device (device),P_NEG_RS_DREPLY , peer_req); + err =drbd_send_ack (peer_device,P_NEG_RS_DREPLY , peer_req);/* update resync data with failure */ drbd_rs_failed_io (device, peer_req->i.sector, peer_req->i.size);
@@ -1080,7 +1084,8 @@ int w_e_end_rsdata_req(struct drbd_work *w, int cancel)int w_e_end_csum_rs_req (struct drbd_work *w,int cancel) { struct drbd_peer_request *peer_req = container_of(w, struct drbd_peer_request, w); -struct drbd_device *device = peer_req->peer_device->device; +struct drbd_peer_device *peer_device = peer_req->peer_device; +struct drbd_device *device = peer_device->device;struct digest_info *di;int digest_size;void *digest =NULL ;
@@ -1103,13 +1108,13 @@ int w_e_end_csum_rs_req(struct drbd_work *w, int cancel)/* quick hack to try to avoid a race against reconfiguration. * a real fix would be much more involved, * introducing more locking mechanisms */ -if (first_peer_device (device)->connection->csums_tfm) { - digest_size =crypto_hash_digestsize (first_peer_device (device)->connection->csums_tfm); +if (peer_device->connection->csums_tfm) { + digest_size =crypto_hash_digestsize (peer_device->connection->csums_tfm);D_ASSERT (device, digest_size == di->digest_size); digest =kmalloc (digest_size,GFP_NOIO ); }if (digest) { -drbd_csum_ee (first_peer_device (device)->connection->csums_tfm, peer_req, digest); +drbd_csum_ee (peer_device->connection->csums_tfm, peer_req, digest); eq = !memcmp (digest, di->digest, digest_size);kfree (digest); }
@@ -1118,16 +1123,16 @@ int w_e_end_csum_rs_req(struct drbd_work *w, int cancel)drbd_set_in_sync (device, peer_req->i.sector, peer_req->i.size);/* rs_same_csums unit is BM_BLOCK_SIZE */ device->rs_same_csum += peer_req->i.size >>BM_BLOCK_SHIFT ; - err =drbd_send_ack (first_peer_device (device),P_RS_IS_IN_SYNC , peer_req); + err =drbd_send_ack (peer_device,P_RS_IS_IN_SYNC , peer_req); }else {inc_rs_pending (device); peer_req->block_id =ID_SYNCER ;/* By setting block_id, digest pointer becomes invalid! */ peer_req->flags &= ~EE_HAS_DIGEST ;/* This peer request no longer has a digest pointer */ kfree (di); - err =drbd_send_block (first_peer_device (device),P_RS_DATA_REPLY , peer_req); + err =drbd_send_block (peer_device,P_RS_DATA_REPLY , peer_req); } }else { - err =drbd_send_ack (first_peer_device (device),P_NEG_RS_DREPLY , peer_req); + err =drbd_send_ack (peer_device,P_NEG_RS_DREPLY , peer_req);if (__ratelimit (&drbd_ratelimit_state))drbd_err (device,"Sending NegDReply. I guess it gets messy.\n" ); }
@@ -1143,7 +1148,8 @@ int w_e_end_csum_rs_req(struct drbd_work *w, int cancel)int w_e_end_ov_req (struct drbd_work *w,int cancel) { struct drbd_peer_request *peer_req = container_of(w, struct drbd_peer_request, w); -struct drbd_device *device = peer_req->peer_device->device; +struct drbd_peer_device *peer_device = peer_req->peer_device; +struct drbd_device *device = peer_device->device;sector_t sector = peer_req->i.sector;unsigned int size = peer_req->i.size;int digest_size;
@@ -1153,7 +1159,7 @@ int w_e_end_ov_req(struct drbd_work *w, int cancel)if (unlikely (cancel)) goto out; - digest_size =crypto_hash_digestsize (first_peer_device (device)->connection->verify_tfm); + digest_size =crypto_hash_digestsize (peer_device->connection->verify_tfm); digest =kmalloc (digest_size,GFP_NOIO );if (!digest) { err =1 ;/* terminate the connection in case the allocation failed */
@@ -1161,7 +1167,7 @@ int w_e_end_ov_req(struct drbd_work *w, int cancel) }if (likely (!(peer_req->flags &EE_WAS_ERROR ))) -drbd_csum_ee (first_peer_device (device)->connection->verify_tfm, peer_req, digest); +drbd_csum_ee (peer_device->connection->verify_tfm, peer_req, digest);else memset (digest,0 , digest_size);
@@ -1173,7 +1179,7 @@ int w_e_end_ov_req(struct drbd_work *w, int cancel)drbd_free_peer_req (device, peer_req); peer_req =NULL ;inc_rs_pending (device); - err =drbd_send_drequest_csum (first_peer_device (device), sector, size, digest, digest_size,P_OV_REPLY ); + err =drbd_send_drequest_csum (peer_device, sector, size, digest, digest_size,P_OV_REPLY );if (err)dec_rs_pending (device);kfree (digest);
@@ -1199,7 +1205,8 @@ void drbd_ov_out_of_sync_found(struct drbd_device *device, sector_t sector, intint w_e_end_ov_reply (struct drbd_work *w,int cancel) { struct drbd_peer_request *peer_req = container_of(w, struct drbd_peer_request, w); -struct drbd_device *device = peer_req->peer_device->device; +struct drbd_peer_device *peer_device = peer_req->peer_device; +struct drbd_device *device = peer_device->device;struct digest_info *di;void *digest;sector_t sector = peer_req->i.sector;
@@ -1224,10 +1231,10 @@ int w_e_end_ov_reply(struct drbd_work *w, int cancel) di = peer_req->digest;if (likely ((peer_req->flags &EE_WAS_ERROR ) ==0 )) { - digest_size =crypto_hash_digestsize (first_peer_device (device)->connection->verify_tfm); + digest_size =crypto_hash_digestsize (peer_device->connection->verify_tfm); digest =kmalloc (digest_size,GFP_NOIO );if (digest) { -drbd_csum_ee (first_peer_device (device)->connection->verify_tfm, peer_req, digest); +drbd_csum_ee (peer_device->connection->verify_tfm, peer_req, digest);D_ASSERT (device, digest_size == di->digest_size); eq = !memcmp (digest, di->digest, digest_size);
@@ -1246,7 +1253,7 @@ int w_e_end_ov_reply(struct drbd_work *w, int cancel)else ov_out_of_sync_print (device); - err =drbd_send_ack_ex (first_peer_device (device),P_OV_RESULT , sector, size, + err =drbd_send_ack_ex (peer_device,P_OV_RESULT , sector, size, eq ?ID_IN_SYNC :ID_OUT_OF_SYNC );dec_unacked (device);
Signature · 1 line
1.7.9.5
Philipp Reisner
maintainerPATCH 27/27 drbd: Add drbd_thread->resource and make drbd_thread->connection optional
In reply to Philipp ReisnerFrom: Andreas Gruenbacher <[email protected]>
In the drbd_thread "infrastructure" functions, only use the resource instead of the connection. Make the connection field of drbd_thread optional. This will allow to introduce threads which are not associated with a connection.
--- drivers/block/drbd/drbd_int.h | 1 + drivers/block/drbd/drbd_main.c | 49 ++++++++++++++++++++++++---------------- 2 files changed, 31 insertions(+), 19 deletions(-)
drivers/block/drbd/drbd_int.h +1 -0
@@ -262,6 +262,7 @@ struct drbd_thread {struct completion stop;enum drbd_thread_state t_state;int (*function) (struct drbd_thread *); +struct drbd_resource *resource;struct drbd_connection *connection;int reset_cpu_mask;const char *name;
drivers/block/drbd/drbd_main.c +30 -19
136 lines not on this page · raw message
Signature · 1 line
1.7.9.5