firefly-linux-kernel-4.4.55.git
11 years agodrbd: Turn no-disk-drain into disk-drain={yes|no}
Andreas Gruenbacher [Wed, 4 May 2011 13:25:35 +0000 (15:25 +0200)]
drbd: Turn no-disk-drain into disk-drain={yes|no}

Change the --no-disk-drain drbdsetup command line option as well as
the no_disk_drain netlink packet.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Turn no-disk-flushes into disk-flushes={yes|no}
Andreas Gruenbacher [Wed, 4 May 2011 13:25:35 +0000 (15:25 +0200)]
drbd: Turn no-disk-flushes into disk-flushes={yes|no}

Change the --no-disk-flushes drbdsetup command line option as well as
the no_disk_flush netlink packet.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Convert boolean flags on netlink from NLA_FLAG to NLA_U8
Andreas Gruenbacher [Wed, 4 May 2011 14:06:51 +0000 (16:06 +0200)]
drbd: Convert boolean flags on netlink from NLA_FLAG to NLA_U8

Flags of type NLA_FLAG are either present or absent, but do not have a
value by themselves.  Use type NLA_U8 for our boolean flags instead, and
use the value to determine if the flag should be on or off.

On the drbdsetup command line, all those flags have an optional yes/no
argument which defaults to yes.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: RCU for rs_plan_s
Philipp Reisner [Tue, 3 May 2011 14:47:02 +0000 (16:47 +0200)]
drbd: RCU for rs_plan_s

This removes the issue with using peer_seq_lock out of different
contexts.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Enforce limits of disk_conf members; centralized these checks
Philipp Reisner [Wed, 4 May 2011 08:06:52 +0000 (10:06 +0200)]
drbd: Enforce limits of disk_conf members; centralized these checks

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Made the fifo object a self contained object (preparing for RCU)
Philipp Reisner [Tue, 3 May 2011 14:19:31 +0000 (16:19 +0200)]
drbd: Made the fifo object a self contained object (preparing for RCU)

* Moved rs_planed into it, named total
* When having a pointer to the object the values can
  be embedded into the fifo object.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: RCU for disk_conf
Philipp Reisner [Tue, 3 May 2011 13:00:55 +0000 (15:00 +0200)]
drbd: RCU for disk_conf

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Introduce __s32_field in the genetlink macro magic
Lars Ellenberg [Wed, 4 May 2011 08:33:52 +0000 (10:33 +0200)]
drbd: Introduce __s32_field in the genetlink macro magic

...and drop explicit typecasts (int)meta_dev_idx < 0.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Renamed (old|new)_conf into (old|new)_net_conf in receive_SyncParam
Philipp Reisner [Tue, 3 May 2011 12:58:00 +0000 (14:58 +0200)]
drbd: Renamed (old|new)_conf into (old|new)_net_conf in receive_SyncParam

Preparing RCU for disk_conf

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Split drbd_alter_sa() into drbd_sync_after_valid() and drbd_sync_after_changed()
Philipp Reisner [Tue, 3 May 2011 12:27:15 +0000 (14:27 +0200)]
drbd: Split drbd_alter_sa() into drbd_sync_after_valid() and drbd_sync_after_changed()

Preparing RCU for disk_conf

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: drbd_dew_dev_size() gets the user requests disk_size as argument
Philipp Reisner [Tue, 3 May 2011 11:27:43 +0000 (13:27 +0200)]
drbd: drbd_dew_dev_size() gets the user requests disk_size as argument

Preparing RCU for disk_conf

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Renamed the net_conf_update mutex to conf_update
Philipp Reisner [Tue, 3 May 2011 11:14:15 +0000 (13:14 +0200)]
drbd: Renamed the net_conf_update mutex to conf_update

Preparing to use the same mutex for disk_conf updates

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Removed dead code
Philipp Reisner [Mon, 2 May 2011 09:24:04 +0000 (11:24 +0200)]
drbd: Removed dead code

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Generate the drbd_set_*_defaults() functions from drbd_genl.h
Andreas Gruenbacher [Tue, 3 May 2011 12:56:09 +0000 (14:56 +0200)]
drbd: Generate the drbd_set_*_defaults() functions from drbd_genl.h

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Remove left-over unused define
Andreas Gruenbacher [Tue, 3 May 2011 10:27:11 +0000 (12:27 +0200)]
drbd: Remove left-over unused define

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: fix schedule in atomic
Lars Ellenberg [Mon, 2 May 2011 09:51:31 +0000 (11:51 +0200)]
drbd: fix schedule in atomic

An administrative detach used to request a state change directly to D_DISKLESS,
first suspending IO to avoid the last put_ldev() occuring from an endio handler,
potentially in irq context.

This is not enough on the receiving side (typically secondary), we may miss
some peer_req on the way to local disk, which then may do the last put_ldev()
from their drbd_peer_request_endio().

This patch makes the detach always go through the intermediate D_FAILED state.
We may consider to rename it D_DETACHING.

Alternative approach would be to create yet an other work item to be scheduled
on the worker, do the destructor work from there, and get the timing right.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: fix thread stop deadlock
Lars Ellenberg [Mon, 2 May 2011 09:47:18 +0000 (11:47 +0200)]
drbd: fix thread stop deadlock

There are races where the receiver may be exiting,
but still need the worker to process some stuff.

Do not wait for the receiver to die from an exiting worker.
The receiver must already be dead in case the worker decides to exit.
If the receiver was still alive, it may still want to queue work, and do
drbd_flush_workqueue() from it's disconnect cleanup code,
which would no longer be processed by an exiting worker.

This also would deadlock,
if the worker was to synchornously wait for the receiver to die.

Do not implicitly stop the worker.
The worker will only be stopped from configuration context, from
conn_reconfig_done(), drbd_adm_down() or drbd_adm_delete_connection(),
after making sure the receiver is already stopped.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: fix race when forcefully disconnecting
Lars Ellenberg [Mon, 2 May 2011 08:45:05 +0000 (10:45 +0200)]
drbd: fix race when forcefully disconnecting

If a forced disconnect hits a restarting receiver right after it passed
its final "if (C_DISCONNECTING)" test in drbdd_init(), but before it was
actually restarted by drbd_thread_setup, we could be left with a
connection stuck in C_DISCONNECTING, never reaching C_STANDALONE,
which would be necessary to take it down or reconfigure it.

Move the last cleanup into w_after_conn_state_ch(), and do an additional
state change request in conn_try_disconnect(), just in case.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Allow to change data-integrity-alg on the fly
Andreas Gruenbacher [Thu, 28 Apr 2011 19:47:21 +0000 (21:47 +0200)]
drbd: Allow to change data-integrity-alg on the fly

The main purpose of this is to allow to turn data integrity checking on
and off on demand without causing interruptions.

Implemented by allocating tconn->peer_integrity_tfm only when receiving
a P_PROTOCOL message.  l accesses to tconn->peer_integrity_tf happen in
worker context, and no further synchronization is necessary.

On the sender side, tconn->integrity_tfm is modified under
tconn->data.mutex, and a P_PROTOCOL message is sent whenever.  All
accesses to tconn->integrity_tfm already happen under this mutex.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Introduce a "lockless" variant of drbd_send_protocoll()
Andreas Gruenbacher [Fri, 29 Apr 2011 11:19:58 +0000 (13:19 +0200)]
drbd: Introduce a "lockless" variant of drbd_send_protocoll()

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Remove obsolete drbd_crypto_is_hash()
Andreas Gruenbacher [Fri, 29 Apr 2011 08:20:08 +0000 (10:20 +0200)]
drbd: Remove obsolete drbd_crypto_is_hash()

We allocate hash transformations with crypto_alloc_hash() which will
only return hash algorithms.  It is not necessary to reconfirm that we
actually got a hash algorithm.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Rename integrity_r_tfm -> peer_integrity_tfm
Andreas Gruenbacher [Wed, 27 Apr 2011 19:00:12 +0000 (21:00 +0200)]
drbd: Rename integrity_r_tfm -> peer_integrity_tfm

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Rename integrity_w_tfm -> integrity_tfm
Andreas Gruenbacher [Wed, 27 Apr 2011 18:59:18 +0000 (20:59 +0200)]
drbd: Rename integrity_w_tfm -> integrity_tfm

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Wrong use of RCU in receive_protocol()
Andreas Gruenbacher [Thu, 28 Apr 2011 13:24:18 +0000 (15:24 +0200)]
drbd: Wrong use of RCU in receive_protocol()

It is not enough to grab net_conf->integrity_alg under rcu_read_lock()
and access it outside of it; the entire net_conf object may be gone by
then.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: fix copy/paste error in comment
Lars Ellenberg [Thu, 28 Apr 2011 05:58:24 +0000 (07:58 +0200)]
drbd: fix copy/paste error in comment

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: rename variable sc to res_opts
Lars Ellenberg [Wed, 27 Apr 2011 19:17:33 +0000 (21:17 +0200)]
drbd: rename variable sc to res_opts

sc was short for syncer conf, which does not exist anymore anyways.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: rename variable ndc to new_disk_conf
Lars Ellenberg [Wed, 27 Apr 2011 19:14:57 +0000 (21:14 +0200)]
drbd: rename variable ndc to new_disk_conf

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: on reconfiguration requests, mind the SET_DEFAULTS flag
Lars Ellenberg [Wed, 27 Apr 2011 19:09:55 +0000 (21:09 +0200)]
drbd: on reconfiguration requests, mind the SET_DEFAULTS flag

The DRBD_GENL_F_SET_DEFAULTS flag was ignored
for drbd_adm_disk_opts() and drbd_adm_net_opts().

Factor out drbd_set_*_defaults() helper functions,
and call them appropriately.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Consider all crypto options in connect and in net-options
Philipp Reisner [Wed, 27 Apr 2011 09:27:47 +0000 (11:27 +0200)]
drbd: Consider all crypto options in connect and in net-options

So for this was simply not considered after the options have been
re-arranged.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: fix various disconnecting races
Lars Ellenberg [Wed, 27 Apr 2011 08:25:28 +0000 (10:25 +0200)]
drbd: fix various disconnecting races

If an admin requests disconnect at a time when the state handling
already disconnects/reconnects, there have been some races.

Make sure to always really stop the network threads before
returning success for disconnect. Do not pretend successfull
forced disconnect, if the state handling returned an error.

Return success from drbd_adm_down() only after all threads are finished.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: remove useless kobject_uevent from drbd_adm_connect
Lars Ellenberg [Tue, 26 Apr 2011 14:22:25 +0000 (16:22 +0200)]
drbd: remove useless kobject_uevent from drbd_adm_connect

Calling kobject_uevent, which may sleep, from within rcu_read_lock()
protected regions is not possible.
This particular kobject_uevent also is also wrong. It was supposed to
trigger a udev run, just in case something relevant to udev symlink
magic has changed, when adjusting runtime re-configurable settings while
we still had the "syncer conf".  It was improperly placed in connect
when we dropped the "syncer conf".  The right thing to do is probably to
call "udevadm trigger" directly in those cases where drbdadm thinks
there was a need to trigger extra udev runs.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Removed the OBJECT_DYING and the CONFIG_PENDING bits
Philipp Reisner [Sun, 24 Apr 2011 09:09:55 +0000 (11:09 +0200)]
drbd: Removed the OBJECT_DYING and the CONFIG_PENDING bits

superseded by refcounting

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Take a reference on tconn when finding a tconn by name
Philipp Reisner [Sun, 24 Apr 2011 08:53:19 +0000 (10:53 +0200)]
drbd: Take a reference on tconn when finding a tconn by name

Rule #3 of kref.txt

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Basic refcounting for drbd_tconn
Philipp Reisner [Fri, 22 Apr 2011 13:23:32 +0000 (15:23 +0200)]
drbd: Basic refcounting for drbd_tconn

References hold by:
 * Each (running) drbd thread has a reference on tconn
 * Each mdev has a referenc on tconn
 * Beeing in the all_tconn list counts for one reference
 * Each after_conn_state_chg_work has a reference to tconn

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Eliminated drbd_free_resoruces() it is superseeded by conn_free_crypto()
Philipp Reisner [Fri, 22 Apr 2011 13:20:23 +0000 (15:20 +0200)]
drbd: Eliminated drbd_free_resoruces() it is superseeded by conn_free_crypto()

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: move comment about stopping the receiver thread to where it belongs
Lars Ellenberg [Sun, 24 Apr 2011 18:52:20 +0000 (20:52 +0200)]
drbd: move comment about stopping the receiver thread to where it belongs

When the last volume of a replication group is unconfigured,
the worker thread exits. To not interfere with cleanup
of other threads, before the the last cleanups run,
we need to make sure the receiver has already exited.

The commend explaining that clearly belongs above
drbd_thread_stop(&tconn->receiver), not in the cleanup loop below.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: cmdname() enum to string convertion was missing a few constants
Lars Ellenberg [Sat, 23 Apr 2011 22:01:16 +0000 (00:01 +0200)]
drbd: cmdname() enum to string convertion was missing a few constants

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: fix setsockopt for user mode linux
Lars Ellenberg [Sat, 23 Apr 2011 12:45:14 +0000 (14:45 +0200)]
drbd: fix setsockopt for user mode linux

We use our own copy of kernel_setsockopt, and did not mess around with
get_fs/set_fs, since we thought we knew we would always be KERNEL_DS
anyways. Apparently not so for at least user mode linux, so put the
set_fs(KERNEL_DS) in there.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: allow status dump request all volumes of a specific resource
Lars Ellenberg [Mon, 18 Apr 2011 07:43:25 +0000 (09:43 +0200)]
drbd: allow status dump request all volumes of a specific resource

We had drbd_adm_get_status (one single volume),
and drbd_adm_get_status_all (dump of all volumes of all resources).

This enhances the latter to be able to dump all volumes
of just one specific resource.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Considering that the two_primaries config flag can change
Philipp Reisner [Thu, 21 Apr 2011 09:36:49 +0000 (11:36 +0200)]
drbd: Considering that the two_primaries config flag can change

Now since it is possible to change the two_primaries config
flag while the connection is up, make sure we treat a peer_req
in a consistent way if the config flag changes while the peer_req
is under IO.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Proper locking for updates to net_conf under RCU
Philipp Reisner [Wed, 20 Apr 2011 15:47:29 +0000 (17:47 +0200)]
drbd: Proper locking for updates to net_conf under RCU

Removing the get_net_conf()/put_net_conf() functions

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: rcu_read_lock() and rcu_dereference() for tconn->net_conf
Philipp Reisner [Tue, 19 Apr 2011 15:10:19 +0000 (17:10 +0200)]
drbd: rcu_read_lock() and rcu_dereference() for tconn->net_conf

Removing the get_net_conf()/put_net_conf() calls

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Allow online change of replication protocol only with agreed_pv >= 100
Philipp Reisner [Thu, 14 Apr 2011 01:16:10 +0000 (18:16 -0700)]
drbd: Allow online change of replication protocol only with agreed_pv >= 100

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Check consistency of net options when the get changed online
Philipp Reisner [Thu, 14 Apr 2011 01:00:59 +0000 (18:00 -0700)]
drbd: Check consistency of net options when the get changed online

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Runtime changeable wire protocol
Philipp Reisner [Wed, 13 Apr 2011 23:24:47 +0000 (16:24 -0700)]
drbd: Runtime changeable wire protocol

The wire protocol is no longer a property that is negotiated
between the two peers. It is now expressed with two bits
(DP_SEND_WRITE_ACK and DP_SEND_RECEIVE_ACK) in each data
packet. Therefore the primary node is free to change the
wire protocol at any time without disconnect/reconnect.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: protect all idr accesses that might sleep with drbd_cfg_rwsem
Philipp Reisner [Wed, 13 Apr 2011 21:46:05 +0000 (14:46 -0700)]
drbd: protect all idr accesses that might sleep with drbd_cfg_rwsem

With this commit the locking for all accesses to IDRs is complete:

 * Non sleeping read accesses are protected by RCU
 * sleeping read accesses are protocted by a read lock on drbd_cfg_rwsem
 * accesses that add anything are protected by a write lock
 * accesses that remove an object are protoected by a write lock
   and a call to synchronize_rcu() after it is removed from the IDR
   and before the object is actually free()ed.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Converted drbd_cfg_mutex into drbd_cfg_rwsem
Philipp Reisner [Wed, 13 Apr 2011 21:21:29 +0000 (14:21 -0700)]
drbd: Converted drbd_cfg_mutex into drbd_cfg_rwsem

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: rcu_read_[un]lock() for all idr accesses that do not sleep
Philipp Reisner [Tue, 12 Apr 2011 05:53:32 +0000 (22:53 -0700)]
drbd: rcu_read_[un]lock() for all idr accesses that do not sleep

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Inlined drbd_free_mdev(); it got called only from one place
Philipp Reisner [Tue, 12 Apr 2011 04:24:24 +0000 (21:24 -0700)]
drbd: Inlined drbd_free_mdev(); it got called only from one place

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: drbd_delete_device() takes a struct drbd_conf * now
Philipp Reisner [Tue, 12 Apr 2011 04:10:11 +0000 (21:10 -0700)]
drbd: drbd_delete_device() takes a struct drbd_conf * now

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Rename drbd_pp_free() to drbd_free_pages()
Andreas Gruenbacher [Thu, 7 Apr 2011 19:02:59 +0000 (21:02 +0200)]
drbd: Rename drbd_pp_free() to drbd_free_pages()

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Rename drbd_pp_alloc() to drbd_alloc_pages() and make it non-static
Andreas Gruenbacher [Thu, 7 Apr 2011 19:02:09 +0000 (21:02 +0200)]
drbd: Rename drbd_pp_alloc() to drbd_alloc_pages() and make it non-static

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Rename drbd_pp_first_pages_or_try_alloc() to __drbd_alloc_pages()
Andreas Gruenbacher [Thu, 7 Apr 2011 19:08:50 +0000 (21:08 +0200)]
drbd: Rename drbd_pp_first_pages_or_try_alloc() to __drbd_alloc_pages()

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Make drbd_wait_ee_list_empty() and _drbd_wait_ee_list_empty() static
Andreas Gruenbacher [Wed, 6 Apr 2011 22:06:56 +0000 (00:06 +0200)]
drbd: Make drbd_wait_ee_list_empty() and _drbd_wait_ee_list_empty() static

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Rename drbd_{ ee -> peer_req }_has_active_page
Andreas Gruenbacher [Thu, 7 Apr 2011 19:34:24 +0000 (21:34 +0200)]
drbd: Rename drbd_{ ee -> peer_req }_has_active_page

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Rename reclaim_net_ee(), drbd_process_done_ee(), drbd_process_done_ee(), tconn_...
Andreas Gruenbacher [Wed, 6 Apr 2011 15:56:48 +0000 (17:56 +0200)]
drbd: Rename reclaim_net_ee(), drbd_process_done_ee(), drbd_process_done_ee(), tconn_process_done_ee() to *_peer_reqs

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Rename drbd_release_ee() to drbd_free_peer_reqs()
Andreas Gruenbacher [Wed, 6 Apr 2011 15:14:02 +0000 (17:14 +0200)]
drbd: Rename drbd_release_ee() to drbd_free_peer_reqs()

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Rename drbd_free_ee() and variants to *_peer_req()
Andreas Gruenbacher [Wed, 6 Apr 2011 14:16:56 +0000 (16:16 +0200)]
drbd: Rename drbd_free_ee() and variants to *_peer_req()

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Rename drbd_alloc_ee() to drbd_alloc_peer_req()
Andreas Gruenbacher [Wed, 6 Apr 2011 14:09:15 +0000 (16:09 +0200)]
drbd: Rename drbd_alloc_ee() to drbd_alloc_peer_req()

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: drbd_init_ee() no longer exists
Andreas Gruenbacher [Wed, 6 Apr 2011 15:18:29 +0000 (17:18 +0200)]
drbd: drbd_init_ee() no longer exists

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Make all asynchronous command handlers return 0 upon success and an error code...
Andreas Gruenbacher [Mon, 4 Apr 2011 13:30:24 +0000 (15:30 +0200)]
drbd: Make all asynchronous command handlers return 0 upon success and an error code otherwise

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: validate_req_change_req_state(): Return 0 upon success and an error code otherwise
Andreas Gruenbacher [Mon, 4 Apr 2011 11:09:15 +0000 (13:09 +0200)]
drbd: validate_req_change_req_state(): Return 0 upon success and an error code otherwise

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Removed outdated comments and code that envisioned VNRs in header 95
Andreas Gruenbacher [Tue, 22 Mar 2011 12:17:47 +0000 (13:17 +0100)]
drbd: Removed outdated comments and code that envisioned VNRs in header 95

Since have now header 100, that has space for 16 bit volume numbers,
the high byte of the length in header 95 is no longer reserved for
8 bit volume numbers.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Introduce protocol version 100 headers
Andreas Gruenbacher [Wed, 30 Mar 2011 14:00:17 +0000 (16:00 +0200)]
drbd: Introduce protocol version 100 headers

The 8 byte header finally becomes too small. With the protocol 100 header we
have 16 bit for the volume number, proper 32 bit for the data length, and
32 bit for further extensions in the future.

Previous versions of drbd are using version 80 headers for all packets
short enough for protocol 80.  They support both header versions in
worker context, but only version 80 headers in asynchronous context.
For backwards compatibility, continue to use version 80 headers for
short packets before protocol version 100.

From protocol version 100 on, use the same header version for all
packets.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Remove headers from on-the-wire data structures (struct p_*)
Andreas Gruenbacher [Wed, 30 Mar 2011 10:54:42 +0000 (12:54 +0200)]
drbd: Remove headers from on-the-wire data structures (struct p_*)

Prepare the introduction of the protocol 100 headers. The actual protocol
header is removed for the packet declarations. I.e. allow us to use the
packets with different headers.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Remove some fixed header size assumptions
Andreas Gruenbacher [Wed, 30 Mar 2011 09:53:51 +0000 (11:53 +0200)]
drbd: Remove some fixed header size assumptions

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Remove now-unused int_dig_out buffer
Andreas Gruenbacher [Wed, 30 Mar 2011 23:15:34 +0000 (01:15 +0200)]
drbd: Remove now-unused int_dig_out buffer

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Replace and remove old primitives
Andreas Gruenbacher [Mon, 28 Mar 2011 12:23:08 +0000 (14:23 +0200)]
drbd: Replace and remove old primitives

Centralize sock->mutex locking and unlocking in [drbd|conn]_prepare_command()
and [drbd|conn]_send_comman().

Therefore all *_send_* functions are touched to use these primitives instead
of drbd_get_data_sock()/drbd_put_data_sock() and former helper functions.

That change makes the *_send_* functions more standardized.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Introduce drbd_header_size()
Andreas Gruenbacher [Wed, 30 Mar 2011 09:38:49 +0000 (11:38 +0200)]
drbd: Introduce drbd_header_size()

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Introduce new primitives for sending commands
Andreas Gruenbacher [Tue, 29 Mar 2011 14:55:40 +0000 (16:55 +0200)]
drbd: Introduce new primitives for sending commands

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: drbd_send_ping(), drbd_send_ping(): Return 0 upon success and an error code...
Andreas Gruenbacher [Fri, 1 Apr 2011 10:49:42 +0000 (12:49 +0200)]
drbd: drbd_send_ping(), drbd_send_ping(): Return 0 upon success and an error code otherwise

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Use tconn in request_timer_fn()
Philipp Reisner [Tue, 1 Mar 2011 10:08:28 +0000 (11:08 +0100)]
drbd: Use tconn in request_timer_fn()

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Improved logging of state changes
Philipp Reisner [Tue, 29 Mar 2011 13:20:27 +0000 (15:20 +0200)]
drbd: Improved logging of state changes

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Implemented IO thawing for multiple volumes
Philipp Reisner [Tue, 29 Mar 2011 16:16:11 +0000 (18:16 +0200)]
drbd: Implemented IO thawing for multiple volumes

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Implemented conn_lowest_disk()
Philipp Reisner [Tue, 29 Mar 2011 16:15:49 +0000 (18:15 +0200)]
drbd: Implemented conn_lowest_disk()

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Implemented conn_lowest_conn()
Philipp Reisner [Tue, 29 Mar 2011 12:21:03 +0000 (14:21 +0200)]
drbd: Implemented conn_lowest_conn()

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Calculate and provide ns_min to the w_after_conn_state_ch() work
Philipp Reisner [Tue, 29 Mar 2011 12:01:02 +0000 (14:01 +0200)]
drbd: Calculate and provide ns_min to the w_after_conn_state_ch() work

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Renamed nms to ns_max
Philipp Reisner [Tue, 29 Mar 2011 11:20:58 +0000 (13:20 +0200)]
drbd: Renamed nms to ns_max

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Introduced a new type union drbd_dev_state
Philipp Reisner [Tue, 29 Mar 2011 08:52:01 +0000 (10:52 +0200)]
drbd: Introduced a new type union drbd_dev_state

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Moved susp, susp_nod and susp_fen to the connection object
Philipp Reisner [Mon, 28 Mar 2011 14:18:39 +0000 (16:18 +0200)]
drbd: Moved susp, susp_nod and susp_fen to the connection object

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Renamed id_susp(union drbd_state s) to drbd_suspended(struct drbd_conf *)
Philipp Reisner [Mon, 28 Mar 2011 14:48:11 +0000 (16:48 +0200)]
drbd: Renamed id_susp(union drbd_state s) to drbd_suspended(struct drbd_conf *)

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Introduced drbd_read_state()
Philipp Reisner [Mon, 28 Mar 2011 13:40:12 +0000 (15:40 +0200)]
drbd: Introduced drbd_read_state()

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: improvements to activate/deactivate multiple activity log extents
Lars Ellenberg [Fri, 1 Apr 2011 08:38:30 +0000 (10:38 +0200)]
drbd: improvements to activate/deactivate multiple activity log extents

Recent commit drbd: get rid of bio_split, allow bios of "arbitrary" size
had a reference count leak: it only deactivated the first of several
activity log extents for intervals crossing extent boundaries.

This commit generalizes on bios spanning multiple activity log extents
in drbd_al_begin_io, and adds the necessary loop around lc_put in
drbd_al_complete_io as well.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: get rid of bio_split, allow bios of "arbitrary" size
Lars Ellenberg [Thu, 31 Mar 2011 14:36:43 +0000 (16:36 +0200)]
drbd: get rid of bio_split, allow bios of "arbitrary" size

Where "arbitrary" size is currently 1 MiB, which is the BIO_MAX_SIZE
for architectures with 4k PAGE_CACHE_SIZE (most).

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: prepare to activate two activity log extents at once
Lars Ellenberg [Thu, 31 Mar 2011 14:00:51 +0000 (16:00 +0200)]
drbd: prepare to activate two activity log extents at once

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: preparation commit, pass drbd_interval to drbd_al_begin/complete_io
Lars Ellenberg [Thu, 31 Mar 2011 13:18:56 +0000 (15:18 +0200)]
drbd: preparation commit, pass drbd_interval to drbd_al_begin/complete_io

We want to avoid bio_split for bios crossing activity log boundaries.
So we may need to activate two activity log extents "atomically".
drbd_al_begin_io() needs to know more than just the start sector.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: introduce the "initialized" activity log transaction type
Lars Ellenberg [Thu, 31 Mar 2011 10:06:48 +0000 (12:06 +0200)]
drbd: introduce the "initialized" activity log transaction type

So we can initialize a clean on disk activity log area,
without the module complaining with loud assert messages
because of checksum or magic value mismatches.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Change how the "handshake" packets are called
Andreas Gruenbacher [Mon, 28 Mar 2011 15:05:50 +0000 (17:05 +0200)]
drbd: Change how the "handshake" packets are called

Packets of type P_HAND_SHAKE define which protocol versions and features
a node supports.  For clarity, call those packets P_CONNECTION_FEATURES
instead.

(This does not determine the features that a specific drbd device
supports, such as drbd protocol A, B, C.)

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Change how the initial packets are called
Andreas Gruenbacher [Mon, 28 Mar 2011 14:44:40 +0000 (16:44 +0200)]
drbd: Change how the initial packets are called

The first packets exchanged when a connection is established are
referred to as P_HAND_SHAKE_S and P_HAND_SHAKE_M in the code, followed
by P_HAND_SHAKE packets.  To avoid confusion between these two unrelated
things, call the initial packets P_INITIAL_DATA and P_INITIAL_META.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: _conn_send_cmd(), _drbd_send_cmd(): Pass a struct drbd_socket instead of a...
Andreas Gruenbacher [Mon, 21 Mar 2011 23:49:36 +0000 (00:49 +0100)]
drbd: _conn_send_cmd(), _drbd_send_cmd(): Pass a struct drbd_socket instead of a plain socket

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: drbd_connect(): Initialize struct drbd_socket before sending anything
Andreas Gruenbacher [Mon, 28 Mar 2011 14:33:12 +0000 (16:33 +0200)]
drbd: drbd_connect(): Initialize struct drbd_socket before sending anything

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Map from (connection, volume number) to device in the asender handlers
Andreas Gruenbacher [Fri, 25 Mar 2011 14:37:43 +0000 (15:37 +0100)]
drbd: Map from (connection, volume number) to device in the asender handlers

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Pass struct packet_info down to the asender receive functions
Andreas Gruenbacher [Fri, 25 Mar 2011 14:16:26 +0000 (15:16 +0100)]
drbd: Pass struct packet_info down to the asender receive functions

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Do not segfault if a sync dependency reaches a diskless device
Philipp Reisner [Mon, 28 Mar 2011 12:48:01 +0000 (14:48 +0200)]
drbd: Do not segfault if a sync dependency reaches a diskless device

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Allow to disconnect if one volume is diskless
Philipp Reisner [Mon, 28 Mar 2011 10:55:03 +0000 (12:55 +0200)]
drbd: Allow to disconnect if one volume is diskless

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Print common state changes of all volumes as connection state changes
Philipp Reisner [Fri, 25 Mar 2011 14:11:30 +0000 (15:11 +0100)]
drbd: Print common state changes of all volumes as connection state changes

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Fixed logging of old connection state
Philipp Reisner [Fri, 25 Mar 2011 13:31:11 +0000 (14:31 +0100)]
drbd: Fixed logging of old connection state

During a disconnect the oc variable in _conn_request_state()
could become outdated. Determin the common old state after
sleeping.
While at it, I implemented that for all parts of the state

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Use the idr_for_each_entry() iterator instead of idr_for_each()
Philipp Reisner [Fri, 25 Mar 2011 11:02:20 +0000 (12:02 +0100)]
drbd: Use the idr_for_each_entry() iterator instead of idr_for_each()

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Map from (connection, volume number) to device in the receive handlers
Andreas Gruenbacher [Fri, 25 Mar 2011 01:43:51 +0000 (02:43 +0100)]
drbd: Map from (connection, volume number) to device in the receive handlers

The receive handlers do not all handle unknown volume numbers the same
way.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
11 years agodrbd: Pass struct packet_info down to the receive functions
Andreas Gruenbacher [Thu, 24 Mar 2011 23:57:38 +0000 (00:57 +0100)]
drbd: Pass struct packet_info down to the receive functions

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>