summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorLars Ellenberg <lars.ellenberg@linbit.com>2011-11-17 11:49:46 +0100
committerPhilipp Reisner <philipp.reisner@linbit.com>2012-11-08 16:58:33 +0100
commitb379c41ed78e83c4443fca4dbfbc358c19e4f24c (patch)
tree4e5a3d472c67835406e4c511ada0277b97798c26 /drivers
parent9d05e7c4e7069180370ce9c2c121fd6f7810c5a3 (diff)
drbd: transfer log epoch numbers are now per resource
cherry-picked from drbd 9 devel branch. In preparation of multiple connections, the "barrier number" or "epoch number" needs to be tracked per-resource, not per connection. The sequence number space will not be reset anymore. Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/block/drbd/drbd_int.h1
-rw-r--r--drivers/block/drbd/drbd_main.c9
-rw-r--r--drivers/block/drbd/drbd_req.c4
3 files changed, 6 insertions, 8 deletions
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index 5b1789af6cdf..d7ca76ce00cb 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -864,6 +864,7 @@ struct drbd_tconn { /* is a resource from the config file */
spinlock_t epoch_lock;
unsigned int epochs;
enum write_ordering_e write_ordering;
+ atomic_t current_tle_nr; /* transfer log epoch number */
unsigned long last_reconnect_jif;
struct drbd_thread receiver;
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index 843d0af68f96..bfe6975ef94c 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -208,7 +208,7 @@ static int tl_init(struct drbd_tconn *tconn)
INIT_LIST_HEAD(&b->requests);
INIT_LIST_HEAD(&b->w.list);
b->next = NULL;
- b->br_number = 4711;
+ b->br_number = atomic_inc_return(&tconn->current_tle_nr);
b->n_writes = 0;
b->w.cb = NULL; /* if this is != NULL, we need to dec_ap_pending in tl_clear */
@@ -241,16 +241,13 @@ static void tl_cleanup(struct drbd_tconn *tconn)
*/
void _tl_add_barrier(struct drbd_tconn *tconn, struct drbd_tl_epoch *new)
{
- struct drbd_tl_epoch *newest_before;
-
INIT_LIST_HEAD(&new->requests);
INIT_LIST_HEAD(&new->w.list);
new->w.cb = NULL; /* if this is != NULL, we need to dec_ap_pending in tl_clear */
new->next = NULL;
new->n_writes = 0;
- newest_before = tconn->newest_tle;
- new->br_number = newest_before->br_number+1;
+ new->br_number = atomic_inc_return(&tconn->current_tle_nr);
if (tconn->newest_tle != new) {
tconn->newest_tle->next = new;
tconn->newest_tle = new;
@@ -406,7 +403,7 @@ void _tl_restart(struct drbd_tconn *tconn, enum drbd_req_event what)
list_splice(&carry_reads, &b->requests);
INIT_LIST_HEAD(&b->w.list);
b->w.cb = NULL;
- b->br_number = net_random();
+ b->br_number = atomic_inc_return(&tconn->current_tle_nr);
b->n_writes = 0;
*pn = b;
diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c
index 34e791dfaf81..a131174b6677 100644
--- a/drivers/block/drbd/drbd_req.c
+++ b/drivers/block/drbd/drbd_req.c
@@ -187,7 +187,7 @@ static void _about_to_complete_local_write(struct drbd_conf *mdev,
*/
if (mdev->state.conn >= C_CONNECTED &&
(s & RQ_NET_SENT) != 0 &&
- req->epoch == mdev->tconn->newest_tle->br_number)
+ req->epoch == atomic_read(&mdev->tconn->current_tle_nr))
queue_barrier(mdev);
}
@@ -518,7 +518,7 @@ int __req_mod(struct drbd_request *req, enum drbd_req_event what,
* just after it grabs the req_lock */
D_ASSERT(test_bit(CREATE_BARRIER, &mdev->tconn->flags) == 0);
- req->epoch = mdev->tconn->newest_tle->br_number;
+ req->epoch = atomic_read(&mdev->tconn->current_tle_nr);
/* increment size of current epoch */
mdev->tconn->newest_tle->n_writes++;