|
|
@@ -44,6 +44,7 @@
|
|
|
#include <linux/string.h>
|
|
|
#include <linux/scatterlist.h>
|
|
|
#include "drbd_int.h"
|
|
|
+#include "drbd_protocol.h"
|
|
|
#include "drbd_req.h"
|
|
|
|
|
|
#include "drbd_vli.h"
|
|
|
@@ -61,11 +62,11 @@ enum finish_epoch {
|
|
|
FE_RECYCLED,
|
|
|
};
|
|
|
|
|
|
-static int drbd_do_features(struct drbd_tconn *tconn);
|
|
|
-static int drbd_do_auth(struct drbd_tconn *tconn);
|
|
|
-static int drbd_disconnected(struct drbd_conf *mdev);
|
|
|
+static int drbd_do_features(struct drbd_connection *connection);
|
|
|
+static int drbd_do_auth(struct drbd_connection *connection);
|
|
|
+static int drbd_disconnected(struct drbd_peer_device *);
|
|
|
|
|
|
-static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *, struct drbd_epoch *, enum epoch_event);
|
|
|
+static enum finish_epoch drbd_may_finish_epoch(struct drbd_connection *, struct drbd_epoch *, enum epoch_event);
|
|
|
static int e_end_block(struct drbd_work *, int);
|
|
|
|
|
|
|
|
|
@@ -150,7 +151,7 @@ static void page_chain_add(struct page **head,
|
|
|
*head = chain_first;
|
|
|
}
|
|
|
|
|
|
-static struct page *__drbd_alloc_pages(struct drbd_conf *mdev,
|
|
|
+static struct page *__drbd_alloc_pages(struct drbd_device *device,
|
|
|
unsigned int number)
|
|
|
{
|
|
|
struct page *page = NULL;
|
|
|
@@ -196,41 +197,39 @@ static struct page *__drbd_alloc_pages(struct drbd_conf *mdev,
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
-static void reclaim_finished_net_peer_reqs(struct drbd_conf *mdev,
|
|
|
+static void reclaim_finished_net_peer_reqs(struct drbd_device *device,
|
|
|
struct list_head *to_be_freed)
|
|
|
{
|
|
|
- struct drbd_peer_request *peer_req;
|
|
|
- struct list_head *le, *tle;
|
|
|
+ struct drbd_peer_request *peer_req, *tmp;
|
|
|
|
|
|
/* The EEs are always appended to the end of the list. Since
|
|
|
they are sent in order over the wire, they have to finish
|
|
|
in order. As soon as we see the first not finished we can
|
|
|
stop to examine the list... */
|
|
|
|
|
|
- list_for_each_safe(le, tle, &mdev->net_ee) {
|
|
|
- peer_req = list_entry(le, struct drbd_peer_request, w.list);
|
|
|
+ list_for_each_entry_safe(peer_req, tmp, &device->net_ee, w.list) {
|
|
|
if (drbd_peer_req_has_active_page(peer_req))
|
|
|
break;
|
|
|
- list_move(le, to_be_freed);
|
|
|
+ list_move(&peer_req->w.list, to_be_freed);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void drbd_kick_lo_and_reclaim_net(struct drbd_conf *mdev)
|
|
|
+static void drbd_kick_lo_and_reclaim_net(struct drbd_device *device)
|
|
|
{
|
|
|
LIST_HEAD(reclaimed);
|
|
|
struct drbd_peer_request *peer_req, *t;
|
|
|
|
|
|
- spin_lock_irq(&mdev->tconn->req_lock);
|
|
|
- reclaim_finished_net_peer_reqs(mdev, &reclaimed);
|
|
|
- spin_unlock_irq(&mdev->tconn->req_lock);
|
|
|
+ spin_lock_irq(&device->resource->req_lock);
|
|
|
+ reclaim_finished_net_peer_reqs(device, &reclaimed);
|
|
|
+ spin_unlock_irq(&device->resource->req_lock);
|
|
|
|
|
|
list_for_each_entry_safe(peer_req, t, &reclaimed, w.list)
|
|
|
- drbd_free_net_peer_req(mdev, peer_req);
|
|
|
+ drbd_free_net_peer_req(device, peer_req);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* drbd_alloc_pages() - Returns @number pages, retries forever (or until signalled)
|
|
|
- * @mdev: DRBD device.
|
|
|
+ * @device: DRBD device.
|
|
|
* @number: number of pages requested
|
|
|
* @retry: whether to retry, if not enough pages are available right now
|
|
|
*
|
|
|
@@ -240,9 +239,10 @@ static void drbd_kick_lo_and_reclaim_net(struct drbd_conf *mdev)
|
|
|
*
|
|
|
* Returns a page chain linked via page->private.
|
|
|
*/
|
|
|
-struct page *drbd_alloc_pages(struct drbd_conf *mdev, unsigned int number,
|
|
|
+struct page *drbd_alloc_pages(struct drbd_peer_device *peer_device, unsigned int number,
|
|
|
bool retry)
|
|
|
{
|
|
|
+ struct drbd_device *device = peer_device->device;
|
|
|
struct page *page = NULL;
|
|
|
struct net_conf *nc;
|
|
|
DEFINE_WAIT(wait);
|
|
|
@@ -251,20 +251,20 @@ struct page *drbd_alloc_pages(struct drbd_conf *mdev, unsigned int number,
|
|
|
/* Yes, we may run up to @number over max_buffers. If we
|
|
|
* follow it strictly, the admin will get it wrong anyways. */
|
|
|
rcu_read_lock();
|
|
|
- nc = rcu_dereference(mdev->tconn->net_conf);
|
|
|
+ nc = rcu_dereference(peer_device->connection->net_conf);
|
|
|
mxb = nc ? nc->max_buffers : 1000000;
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
- if (atomic_read(&mdev->pp_in_use) < mxb)
|
|
|
- page = __drbd_alloc_pages(mdev, number);
|
|
|
+ if (atomic_read(&device->pp_in_use) < mxb)
|
|
|
+ page = __drbd_alloc_pages(device, number);
|
|
|
|
|
|
while (page == NULL) {
|
|
|
prepare_to_wait(&drbd_pp_wait, &wait, TASK_INTERRUPTIBLE);
|
|
|
|
|
|
- drbd_kick_lo_and_reclaim_net(mdev);
|
|
|
+ drbd_kick_lo_and_reclaim_net(device);
|
|
|
|
|
|
- if (atomic_read(&mdev->pp_in_use) < mxb) {
|
|
|
- page = __drbd_alloc_pages(mdev, number);
|
|
|
+ if (atomic_read(&device->pp_in_use) < mxb) {
|
|
|
+ page = __drbd_alloc_pages(device, number);
|
|
|
if (page)
|
|
|
break;
|
|
|
}
|
|
|
@@ -273,7 +273,7 @@ struct page *drbd_alloc_pages(struct drbd_conf *mdev, unsigned int number,
|
|
|
break;
|
|
|
|
|
|
if (signal_pending(current)) {
|
|
|
- dev_warn(DEV, "drbd_alloc_pages interrupted!\n");
|
|
|
+ drbd_warn(device, "drbd_alloc_pages interrupted!\n");
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
@@ -282,17 +282,17 @@ struct page *drbd_alloc_pages(struct drbd_conf *mdev, unsigned int number,
|
|
|
finish_wait(&drbd_pp_wait, &wait);
|
|
|
|
|
|
if (page)
|
|
|
- atomic_add(number, &mdev->pp_in_use);
|
|
|
+ atomic_add(number, &device->pp_in_use);
|
|
|
return page;
|
|
|
}
|
|
|
|
|
|
/* Must not be used from irq, as that may deadlock: see drbd_alloc_pages.
|
|
|
- * Is also used from inside an other spin_lock_irq(&mdev->tconn->req_lock);
|
|
|
+ * Is also used from inside an other spin_lock_irq(&resource->req_lock);
|
|
|
* Either links the page chain back to the global pool,
|
|
|
* or returns all pages to the system. */
|
|
|
-static void drbd_free_pages(struct drbd_conf *mdev, struct page *page, int is_net)
|
|
|
+static void drbd_free_pages(struct drbd_device *device, struct page *page, int is_net)
|
|
|
{
|
|
|
- atomic_t *a = is_net ? &mdev->pp_in_use_by_net : &mdev->pp_in_use;
|
|
|
+ atomic_t *a = is_net ? &device->pp_in_use_by_net : &device->pp_in_use;
|
|
|
int i;
|
|
|
|
|
|
if (page == NULL)
|
|
|
@@ -310,7 +310,7 @@ static void drbd_free_pages(struct drbd_conf *mdev, struct page *page, int is_ne
|
|
|
}
|
|
|
i = atomic_sub_return(i, a);
|
|
|
if (i < 0)
|
|
|
- dev_warn(DEV, "ASSERTION FAILED: %s: %d < 0\n",
|
|
|
+ drbd_warn(device, "ASSERTION FAILED: %s: %d < 0\n",
|
|
|
is_net ? "pp_in_use_by_net" : "pp_in_use", i);
|
|
|
wake_up(&drbd_pp_wait);
|
|
|
}
|
|
|
@@ -330,25 +330,26 @@ You must not have the req_lock:
|
|
|
*/
|
|
|
|
|
|
struct drbd_peer_request *
|
|
|
-drbd_alloc_peer_req(struct drbd_conf *mdev, u64 id, sector_t sector,
|
|
|
+drbd_alloc_peer_req(struct drbd_peer_device *peer_device, u64 id, sector_t sector,
|
|
|
unsigned int data_size, gfp_t gfp_mask) __must_hold(local)
|
|
|
{
|
|
|
+ struct drbd_device *device = peer_device->device;
|
|
|
struct drbd_peer_request *peer_req;
|
|
|
struct page *page = NULL;
|
|
|
unsigned nr_pages = (data_size + PAGE_SIZE -1) >> PAGE_SHIFT;
|
|
|
|
|
|
- if (drbd_insert_fault(mdev, DRBD_FAULT_AL_EE))
|
|
|
+ if (drbd_insert_fault(device, DRBD_FAULT_AL_EE))
|
|
|
return NULL;
|
|
|
|
|
|
peer_req = mempool_alloc(drbd_ee_mempool, gfp_mask & ~__GFP_HIGHMEM);
|
|
|
if (!peer_req) {
|
|
|
if (!(gfp_mask & __GFP_NOWARN))
|
|
|
- dev_err(DEV, "%s: allocation failed\n", __func__);
|
|
|
+ drbd_err(device, "%s: allocation failed\n", __func__);
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
if (data_size) {
|
|
|
- page = drbd_alloc_pages(mdev, nr_pages, (gfp_mask & __GFP_WAIT));
|
|
|
+ page = drbd_alloc_pages(peer_device, nr_pages, (gfp_mask & __GFP_WAIT));
|
|
|
if (!page)
|
|
|
goto fail;
|
|
|
}
|
|
|
@@ -360,7 +361,7 @@ drbd_alloc_peer_req(struct drbd_conf *mdev, u64 id, sector_t sector,
|
|
|
peer_req->i.waiting = false;
|
|
|
|
|
|
peer_req->epoch = NULL;
|
|
|
- peer_req->w.mdev = mdev;
|
|
|
+ peer_req->peer_device = peer_device;
|
|
|
peer_req->pages = page;
|
|
|
atomic_set(&peer_req->pending_bios, 0);
|
|
|
peer_req->flags = 0;
|
|
|
@@ -377,30 +378,30 @@ drbd_alloc_peer_req(struct drbd_conf *mdev, u64 id, sector_t sector,
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
-void __drbd_free_peer_req(struct drbd_conf *mdev, struct drbd_peer_request *peer_req,
|
|
|
+void __drbd_free_peer_req(struct drbd_device *device, struct drbd_peer_request *peer_req,
|
|
|
int is_net)
|
|
|
{
|
|
|
if (peer_req->flags & EE_HAS_DIGEST)
|
|
|
kfree(peer_req->digest);
|
|
|
- drbd_free_pages(mdev, peer_req->pages, is_net);
|
|
|
- D_ASSERT(atomic_read(&peer_req->pending_bios) == 0);
|
|
|
- D_ASSERT(drbd_interval_empty(&peer_req->i));
|
|
|
+ drbd_free_pages(device, peer_req->pages, is_net);
|
|
|
+ D_ASSERT(device, atomic_read(&peer_req->pending_bios) == 0);
|
|
|
+ D_ASSERT(device, drbd_interval_empty(&peer_req->i));
|
|
|
mempool_free(peer_req, drbd_ee_mempool);
|
|
|
}
|
|
|
|
|
|
-int drbd_free_peer_reqs(struct drbd_conf *mdev, struct list_head *list)
|
|
|
+int drbd_free_peer_reqs(struct drbd_device *device, struct list_head *list)
|
|
|
{
|
|
|
LIST_HEAD(work_list);
|
|
|
struct drbd_peer_request *peer_req, *t;
|
|
|
int count = 0;
|
|
|
- int is_net = list == &mdev->net_ee;
|
|
|
+ int is_net = list == &device->net_ee;
|
|
|
|
|
|
- spin_lock_irq(&mdev->tconn->req_lock);
|
|
|
+ spin_lock_irq(&device->resource->req_lock);
|
|
|
list_splice_init(list, &work_list);
|
|
|
- spin_unlock_irq(&mdev->tconn->req_lock);
|
|
|
+ spin_unlock_irq(&device->resource->req_lock);
|
|
|
|
|
|
list_for_each_entry_safe(peer_req, t, &work_list, w.list) {
|
|
|
- __drbd_free_peer_req(mdev, peer_req, is_net);
|
|
|
+ __drbd_free_peer_req(device, peer_req, is_net);
|
|
|
count++;
|
|
|
}
|
|
|
return count;
|
|
|
@@ -409,20 +410,20 @@ int drbd_free_peer_reqs(struct drbd_conf *mdev, struct list_head *list)
|
|
|
/*
|
|
|
* See also comments in _req_mod(,BARRIER_ACKED) and receive_Barrier.
|
|
|
*/
|
|
|
-static int drbd_finish_peer_reqs(struct drbd_conf *mdev)
|
|
|
+static int drbd_finish_peer_reqs(struct drbd_device *device)
|
|
|
{
|
|
|
LIST_HEAD(work_list);
|
|
|
LIST_HEAD(reclaimed);
|
|
|
struct drbd_peer_request *peer_req, *t;
|
|
|
int err = 0;
|
|
|
|
|
|
- spin_lock_irq(&mdev->tconn->req_lock);
|
|
|
- reclaim_finished_net_peer_reqs(mdev, &reclaimed);
|
|
|
- list_splice_init(&mdev->done_ee, &work_list);
|
|
|
- spin_unlock_irq(&mdev->tconn->req_lock);
|
|
|
+ spin_lock_irq(&device->resource->req_lock);
|
|
|
+ reclaim_finished_net_peer_reqs(device, &reclaimed);
|
|
|
+ list_splice_init(&device->done_ee, &work_list);
|
|
|
+ spin_unlock_irq(&device->resource->req_lock);
|
|
|
|
|
|
list_for_each_entry_safe(peer_req, t, &reclaimed, w.list)
|
|
|
- drbd_free_net_peer_req(mdev, peer_req);
|
|
|
+ drbd_free_net_peer_req(device, peer_req);
|
|
|
|
|
|
/* possible callbacks here:
|
|
|
* e_end_block, and e_end_resync_block, e_send_superseded.
|
|
|
@@ -435,14 +436,14 @@ static int drbd_finish_peer_reqs(struct drbd_conf *mdev)
|
|
|
err2 = peer_req->w.cb(&peer_req->w, !!err);
|
|
|
if (!err)
|
|
|
err = err2;
|
|
|
- drbd_free_peer_req(mdev, peer_req);
|
|
|
+ drbd_free_peer_req(device, peer_req);
|
|
|
}
|
|
|
- wake_up(&mdev->ee_wait);
|
|
|
+ wake_up(&device->ee_wait);
|
|
|
|
|
|
return err;
|
|
|
}
|
|
|
|
|
|
-static void _drbd_wait_ee_list_empty(struct drbd_conf *mdev,
|
|
|
+static void _drbd_wait_ee_list_empty(struct drbd_device *device,
|
|
|
struct list_head *head)
|
|
|
{
|
|
|
DEFINE_WAIT(wait);
|
|
|
@@ -450,20 +451,20 @@ static void _drbd_wait_ee_list_empty(struct drbd_conf *mdev,
|
|
|
/* avoids spin_lock/unlock
|
|
|
* and calling prepare_to_wait in the fast path */
|
|
|
while (!list_empty(head)) {
|
|
|
- prepare_to_wait(&mdev->ee_wait, &wait, TASK_UNINTERRUPTIBLE);
|
|
|
- spin_unlock_irq(&mdev->tconn->req_lock);
|
|
|
+ prepare_to_wait(&device->ee_wait, &wait, TASK_UNINTERRUPTIBLE);
|
|
|
+ spin_unlock_irq(&device->resource->req_lock);
|
|
|
io_schedule();
|
|
|
- finish_wait(&mdev->ee_wait, &wait);
|
|
|
- spin_lock_irq(&mdev->tconn->req_lock);
|
|
|
+ finish_wait(&device->ee_wait, &wait);
|
|
|
+ spin_lock_irq(&device->resource->req_lock);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void drbd_wait_ee_list_empty(struct drbd_conf *mdev,
|
|
|
+static void drbd_wait_ee_list_empty(struct drbd_device *device,
|
|
|
struct list_head *head)
|
|
|
{
|
|
|
- spin_lock_irq(&mdev->tconn->req_lock);
|
|
|
- _drbd_wait_ee_list_empty(mdev, head);
|
|
|
- spin_unlock_irq(&mdev->tconn->req_lock);
|
|
|
+ spin_lock_irq(&device->resource->req_lock);
|
|
|
+ _drbd_wait_ee_list_empty(device, head);
|
|
|
+ spin_unlock_irq(&device->resource->req_lock);
|
|
|
}
|
|
|
|
|
|
static int drbd_recv_short(struct socket *sock, void *buf, size_t size, int flags)
|
|
|
@@ -488,44 +489,44 @@ static int drbd_recv_short(struct socket *sock, void *buf, size_t size, int flag
|
|
|
return rv;
|
|
|
}
|
|
|
|
|
|
-static int drbd_recv(struct drbd_tconn *tconn, void *buf, size_t size)
|
|
|
+static int drbd_recv(struct drbd_connection *connection, void *buf, size_t size)
|
|
|
{
|
|
|
int rv;
|
|
|
|
|
|
- rv = drbd_recv_short(tconn->data.socket, buf, size, 0);
|
|
|
+ rv = drbd_recv_short(connection->data.socket, buf, size, 0);
|
|
|
|
|
|
if (rv < 0) {
|
|
|
if (rv == -ECONNRESET)
|
|
|
- conn_info(tconn, "sock was reset by peer\n");
|
|
|
+ drbd_info(connection, "sock was reset by peer\n");
|
|
|
else if (rv != -ERESTARTSYS)
|
|
|
- conn_err(tconn, "sock_recvmsg returned %d\n", rv);
|
|
|
+ drbd_err(connection, "sock_recvmsg returned %d\n", rv);
|
|
|
} else if (rv == 0) {
|
|
|
- if (test_bit(DISCONNECT_SENT, &tconn->flags)) {
|
|
|
+ if (test_bit(DISCONNECT_SENT, &connection->flags)) {
|
|
|
long t;
|
|
|
rcu_read_lock();
|
|
|
- t = rcu_dereference(tconn->net_conf)->ping_timeo * HZ/10;
|
|
|
+ t = rcu_dereference(connection->net_conf)->ping_timeo * HZ/10;
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
- t = wait_event_timeout(tconn->ping_wait, tconn->cstate < C_WF_REPORT_PARAMS, t);
|
|
|
+ t = wait_event_timeout(connection->ping_wait, connection->cstate < C_WF_REPORT_PARAMS, t);
|
|
|
|
|
|
if (t)
|
|
|
goto out;
|
|
|
}
|
|
|
- conn_info(tconn, "sock was shut down by peer\n");
|
|
|
+ drbd_info(connection, "sock was shut down by peer\n");
|
|
|
}
|
|
|
|
|
|
if (rv != size)
|
|
|
- conn_request_state(tconn, NS(conn, C_BROKEN_PIPE), CS_HARD);
|
|
|
+ conn_request_state(connection, NS(conn, C_BROKEN_PIPE), CS_HARD);
|
|
|
|
|
|
out:
|
|
|
return rv;
|
|
|
}
|
|
|
|
|
|
-static int drbd_recv_all(struct drbd_tconn *tconn, void *buf, size_t size)
|
|
|
+static int drbd_recv_all(struct drbd_connection *connection, void *buf, size_t size)
|
|
|
{
|
|
|
int err;
|
|
|
|
|
|
- err = drbd_recv(tconn, buf, size);
|
|
|
+ err = drbd_recv(connection, buf, size);
|
|
|
if (err != size) {
|
|
|
if (err >= 0)
|
|
|
err = -EIO;
|
|
|
@@ -534,13 +535,13 @@ static int drbd_recv_all(struct drbd_tconn *tconn, void *buf, size_t size)
|
|
|
return err;
|
|
|
}
|
|
|
|
|
|
-static int drbd_recv_all_warn(struct drbd_tconn *tconn, void *buf, size_t size)
|
|
|
+static int drbd_recv_all_warn(struct drbd_connection *connection, void *buf, size_t size)
|
|
|
{
|
|
|
int err;
|
|
|
|
|
|
- err = drbd_recv_all(tconn, buf, size);
|
|
|
+ err = drbd_recv_all(connection, buf, size);
|
|
|
if (err && !signal_pending(current))
|
|
|
- conn_warn(tconn, "short read (expected size %d)\n", (int)size);
|
|
|
+ drbd_warn(connection, "short read (expected size %d)\n", (int)size);
|
|
|
return err;
|
|
|
}
|
|
|
|
|
|
@@ -563,7 +564,7 @@ static void drbd_setbufsize(struct socket *sock, unsigned int snd,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static struct socket *drbd_try_connect(struct drbd_tconn *tconn)
|
|
|
+static struct socket *drbd_try_connect(struct drbd_connection *connection)
|
|
|
{
|
|
|
const char *what;
|
|
|
struct socket *sock;
|
|
|
@@ -575,7 +576,7 @@ static struct socket *drbd_try_connect(struct drbd_tconn *tconn)
|
|
|
int disconnect_on_error = 1;
|
|
|
|
|
|
rcu_read_lock();
|
|
|
- nc = rcu_dereference(tconn->net_conf);
|
|
|
+ nc = rcu_dereference(connection->net_conf);
|
|
|
if (!nc) {
|
|
|
rcu_read_unlock();
|
|
|
return NULL;
|
|
|
@@ -585,16 +586,16 @@ static struct socket *drbd_try_connect(struct drbd_tconn *tconn)
|
|
|
connect_int = nc->connect_int;
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
- my_addr_len = min_t(int, tconn->my_addr_len, sizeof(src_in6));
|
|
|
- memcpy(&src_in6, &tconn->my_addr, my_addr_len);
|
|
|
+ my_addr_len = min_t(int, connection->my_addr_len, sizeof(src_in6));
|
|
|
+ memcpy(&src_in6, &connection->my_addr, my_addr_len);
|
|
|
|
|
|
- if (((struct sockaddr *)&tconn->my_addr)->sa_family == AF_INET6)
|
|
|
+ if (((struct sockaddr *)&connection->my_addr)->sa_family == AF_INET6)
|
|
|
src_in6.sin6_port = 0;
|
|
|
else
|
|
|
((struct sockaddr_in *)&src_in6)->sin_port = 0; /* AF_INET & AF_SCI */
|
|
|
|
|
|
- peer_addr_len = min_t(int, tconn->peer_addr_len, sizeof(src_in6));
|
|
|
- memcpy(&peer_in6, &tconn->peer_addr, peer_addr_len);
|
|
|
+ peer_addr_len = min_t(int, connection->peer_addr_len, sizeof(src_in6));
|
|
|
+ memcpy(&peer_in6, &connection->peer_addr, peer_addr_len);
|
|
|
|
|
|
what = "sock_create_kern";
|
|
|
err = sock_create_kern(((struct sockaddr *)&src_in6)->sa_family,
|
|
|
@@ -642,17 +643,17 @@ out:
|
|
|
disconnect_on_error = 0;
|
|
|
break;
|
|
|
default:
|
|
|
- conn_err(tconn, "%s failed, err = %d\n", what, err);
|
|
|
+ drbd_err(connection, "%s failed, err = %d\n", what, err);
|
|
|
}
|
|
|
if (disconnect_on_error)
|
|
|
- conn_request_state(tconn, NS(conn, C_DISCONNECTING), CS_HARD);
|
|
|
+ conn_request_state(connection, NS(conn, C_DISCONNECTING), CS_HARD);
|
|
|
}
|
|
|
|
|
|
return sock;
|
|
|
}
|
|
|
|
|
|
struct accept_wait_data {
|
|
|
- struct drbd_tconn *tconn;
|
|
|
+ struct drbd_connection *connection;
|
|
|
struct socket *s_listen;
|
|
|
struct completion door_bell;
|
|
|
void (*original_sk_state_change)(struct sock *sk);
|
|
|
@@ -670,7 +671,7 @@ static void drbd_incoming_connection(struct sock *sk)
|
|
|
state_change(sk);
|
|
|
}
|
|
|
|
|
|
-static int prepare_listen_socket(struct drbd_tconn *tconn, struct accept_wait_data *ad)
|
|
|
+static int prepare_listen_socket(struct drbd_connection *connection, struct accept_wait_data *ad)
|
|
|
{
|
|
|
int err, sndbuf_size, rcvbuf_size, my_addr_len;
|
|
|
struct sockaddr_in6 my_addr;
|
|
|
@@ -679,7 +680,7 @@ static int prepare_listen_socket(struct drbd_tconn *tconn, struct accept_wait_da
|
|
|
const char *what;
|
|
|
|
|
|
rcu_read_lock();
|
|
|
- nc = rcu_dereference(tconn->net_conf);
|
|
|
+ nc = rcu_dereference(connection->net_conf);
|
|
|
if (!nc) {
|
|
|
rcu_read_unlock();
|
|
|
return -EIO;
|
|
|
@@ -688,8 +689,8 @@ static int prepare_listen_socket(struct drbd_tconn *tconn, struct accept_wait_da
|
|
|
rcvbuf_size = nc->rcvbuf_size;
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
- my_addr_len = min_t(int, tconn->my_addr_len, sizeof(struct sockaddr_in6));
|
|
|
- memcpy(&my_addr, &tconn->my_addr, my_addr_len);
|
|
|
+ my_addr_len = min_t(int, connection->my_addr_len, sizeof(struct sockaddr_in6));
|
|
|
+ memcpy(&my_addr, &connection->my_addr, my_addr_len);
|
|
|
|
|
|
what = "sock_create_kern";
|
|
|
err = sock_create_kern(((struct sockaddr *)&my_addr)->sa_family,
|
|
|
@@ -725,8 +726,8 @@ out:
|
|
|
sock_release(s_listen);
|
|
|
if (err < 0) {
|
|
|
if (err != -EAGAIN && err != -EINTR && err != -ERESTARTSYS) {
|
|
|
- conn_err(tconn, "%s failed, err = %d\n", what, err);
|
|
|
- conn_request_state(tconn, NS(conn, C_DISCONNECTING), CS_HARD);
|
|
|
+ drbd_err(connection, "%s failed, err = %d\n", what, err);
|
|
|
+ conn_request_state(connection, NS(conn, C_DISCONNECTING), CS_HARD);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -741,14 +742,14 @@ static void unregister_state_change(struct sock *sk, struct accept_wait_data *ad
|
|
|
write_unlock_bh(&sk->sk_callback_lock);
|
|
|
}
|
|
|
|
|
|
-static struct socket *drbd_wait_for_connect(struct drbd_tconn *tconn, struct accept_wait_data *ad)
|
|
|
+static struct socket *drbd_wait_for_connect(struct drbd_connection *connection, struct accept_wait_data *ad)
|
|
|
{
|
|
|
int timeo, connect_int, err = 0;
|
|
|
struct socket *s_estab = NULL;
|
|
|
struct net_conf *nc;
|
|
|
|
|
|
rcu_read_lock();
|
|
|
- nc = rcu_dereference(tconn->net_conf);
|
|
|
+ nc = rcu_dereference(connection->net_conf);
|
|
|
if (!nc) {
|
|
|
rcu_read_unlock();
|
|
|
return NULL;
|
|
|
@@ -767,8 +768,8 @@ static struct socket *drbd_wait_for_connect(struct drbd_tconn *tconn, struct acc
|
|
|
err = kernel_accept(ad->s_listen, &s_estab, 0);
|
|
|
if (err < 0) {
|
|
|
if (err != -EAGAIN && err != -EINTR && err != -ERESTARTSYS) {
|
|
|
- conn_err(tconn, "accept failed, err = %d\n", err);
|
|
|
- conn_request_state(tconn, NS(conn, C_DISCONNECTING), CS_HARD);
|
|
|
+ drbd_err(connection, "accept failed, err = %d\n", err);
|
|
|
+ conn_request_state(connection, NS(conn, C_DISCONNECTING), CS_HARD);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -778,29 +779,29 @@ static struct socket *drbd_wait_for_connect(struct drbd_tconn *tconn, struct acc
|
|
|
return s_estab;
|
|
|
}
|
|
|
|
|
|
-static int decode_header(struct drbd_tconn *, void *, struct packet_info *);
|
|
|
+static int decode_header(struct drbd_connection *, void *, struct packet_info *);
|
|
|
|
|
|
-static int send_first_packet(struct drbd_tconn *tconn, struct drbd_socket *sock,
|
|
|
+static int send_first_packet(struct drbd_connection *connection, struct drbd_socket *sock,
|
|
|
enum drbd_packet cmd)
|
|
|
{
|
|
|
- if (!conn_prepare_command(tconn, sock))
|
|
|
+ if (!conn_prepare_command(connection, sock))
|
|
|
return -EIO;
|
|
|
- return conn_send_command(tconn, sock, cmd, 0, NULL, 0);
|
|
|
+ return conn_send_command(connection, sock, cmd, 0, NULL, 0);
|
|
|
}
|
|
|
|
|
|
-static int receive_first_packet(struct drbd_tconn *tconn, struct socket *sock)
|
|
|
+static int receive_first_packet(struct drbd_connection *connection, struct socket *sock)
|
|
|
{
|
|
|
- unsigned int header_size = drbd_header_size(tconn);
|
|
|
+ unsigned int header_size = drbd_header_size(connection);
|
|
|
struct packet_info pi;
|
|
|
int err;
|
|
|
|
|
|
- err = drbd_recv_short(sock, tconn->data.rbuf, header_size, 0);
|
|
|
+ err = drbd_recv_short(sock, connection->data.rbuf, header_size, 0);
|
|
|
if (err != header_size) {
|
|
|
if (err >= 0)
|
|
|
err = -EIO;
|
|
|
return err;
|
|
|
}
|
|
|
- err = decode_header(tconn, tconn->data.rbuf, &pi);
|
|
|
+ err = decode_header(connection, connection->data.rbuf, &pi);
|
|
|
if (err)
|
|
|
return err;
|
|
|
return pi.cmd;
|
|
|
@@ -830,28 +831,29 @@ static int drbd_socket_okay(struct socket **sock)
|
|
|
}
|
|
|
/* Gets called if a connection is established, or if a new minor gets created
|
|
|
in a connection */
|
|
|
-int drbd_connected(struct drbd_conf *mdev)
|
|
|
+int drbd_connected(struct drbd_peer_device *peer_device)
|
|
|
{
|
|
|
+ struct drbd_device *device = peer_device->device;
|
|
|
int err;
|
|
|
|
|
|
- atomic_set(&mdev->packet_seq, 0);
|
|
|
- mdev->peer_seq = 0;
|
|
|
+ atomic_set(&device->packet_seq, 0);
|
|
|
+ device->peer_seq = 0;
|
|
|
|
|
|
- mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
|
|
|
- &mdev->tconn->cstate_mutex :
|
|
|
- &mdev->own_state_mutex;
|
|
|
+ device->state_mutex = peer_device->connection->agreed_pro_version < 100 ?
|
|
|
+ &peer_device->connection->cstate_mutex :
|
|
|
+ &device->own_state_mutex;
|
|
|
|
|
|
- err = drbd_send_sync_param(mdev);
|
|
|
+ err = drbd_send_sync_param(peer_device);
|
|
|
if (!err)
|
|
|
- err = drbd_send_sizes(mdev, 0, 0);
|
|
|
+ err = drbd_send_sizes(peer_device, 0, 0);
|
|
|
if (!err)
|
|
|
- err = drbd_send_uuids(mdev);
|
|
|
+ err = drbd_send_uuids(peer_device);
|
|
|
if (!err)
|
|
|
- err = drbd_send_current_state(mdev);
|
|
|
- clear_bit(USE_DEGR_WFC_T, &mdev->flags);
|
|
|
- clear_bit(RESIZE_PENDING, &mdev->flags);
|
|
|
- atomic_set(&mdev->ap_in_flight, 0);
|
|
|
- mod_timer(&mdev->request_timer, jiffies + HZ); /* just start it here. */
|
|
|
+ err = drbd_send_current_state(peer_device);
|
|
|
+ clear_bit(USE_DEGR_WFC_T, &device->flags);
|
|
|
+ clear_bit(RESIZE_PENDING, &device->flags);
|
|
|
+ atomic_set(&device->ap_in_flight, 0);
|
|
|
+ mod_timer(&device->request_timer, jiffies + HZ); /* just start it here. */
|
|
|
return err;
|
|
|
}
|
|
|
|
|
|
@@ -863,59 +865,59 @@ int drbd_connected(struct drbd_conf *mdev)
|
|
|
* no point in trying again, please go standalone.
|
|
|
* -2 We do not have a network config...
|
|
|
*/
|
|
|
-static int conn_connect(struct drbd_tconn *tconn)
|
|
|
+static int conn_connect(struct drbd_connection *connection)
|
|
|
{
|
|
|
struct drbd_socket sock, msock;
|
|
|
- struct drbd_conf *mdev;
|
|
|
+ struct drbd_peer_device *peer_device;
|
|
|
struct net_conf *nc;
|
|
|
int vnr, timeout, h, ok;
|
|
|
bool discard_my_data;
|
|
|
enum drbd_state_rv rv;
|
|
|
struct accept_wait_data ad = {
|
|
|
- .tconn = tconn,
|
|
|
+ .connection = connection,
|
|
|
.door_bell = COMPLETION_INITIALIZER_ONSTACK(ad.door_bell),
|
|
|
};
|
|
|
|
|
|
- clear_bit(DISCONNECT_SENT, &tconn->flags);
|
|
|
- if (conn_request_state(tconn, NS(conn, C_WF_CONNECTION), CS_VERBOSE) < SS_SUCCESS)
|
|
|
+ clear_bit(DISCONNECT_SENT, &connection->flags);
|
|
|
+ if (conn_request_state(connection, NS(conn, C_WF_CONNECTION), CS_VERBOSE) < SS_SUCCESS)
|
|
|
return -2;
|
|
|
|
|
|
mutex_init(&sock.mutex);
|
|
|
- sock.sbuf = tconn->data.sbuf;
|
|
|
- sock.rbuf = tconn->data.rbuf;
|
|
|
+ sock.sbuf = connection->data.sbuf;
|
|
|
+ sock.rbuf = connection->data.rbuf;
|
|
|
sock.socket = NULL;
|
|
|
mutex_init(&msock.mutex);
|
|
|
- msock.sbuf = tconn->meta.sbuf;
|
|
|
- msock.rbuf = tconn->meta.rbuf;
|
|
|
+ msock.sbuf = connection->meta.sbuf;
|
|
|
+ msock.rbuf = connection->meta.rbuf;
|
|
|
msock.socket = NULL;
|
|
|
|
|
|
/* Assume that the peer only understands protocol 80 until we know better. */
|
|
|
- tconn->agreed_pro_version = 80;
|
|
|
+ connection->agreed_pro_version = 80;
|
|
|
|
|
|
- if (prepare_listen_socket(tconn, &ad))
|
|
|
+ if (prepare_listen_socket(connection, &ad))
|
|
|
return 0;
|
|
|
|
|
|
do {
|
|
|
struct socket *s;
|
|
|
|
|
|
- s = drbd_try_connect(tconn);
|
|
|
+ s = drbd_try_connect(connection);
|
|
|
if (s) {
|
|
|
if (!sock.socket) {
|
|
|
sock.socket = s;
|
|
|
- send_first_packet(tconn, &sock, P_INITIAL_DATA);
|
|
|
+ send_first_packet(connection, &sock, P_INITIAL_DATA);
|
|
|
} else if (!msock.socket) {
|
|
|
- clear_bit(RESOLVE_CONFLICTS, &tconn->flags);
|
|
|
+ clear_bit(RESOLVE_CONFLICTS, &connection->flags);
|
|
|
msock.socket = s;
|
|
|
- send_first_packet(tconn, &msock, P_INITIAL_META);
|
|
|
+ send_first_packet(connection, &msock, P_INITIAL_META);
|
|
|
} else {
|
|
|
- conn_err(tconn, "Logic error in conn_connect()\n");
|
|
|
+ drbd_err(connection, "Logic error in conn_connect()\n");
|
|
|
goto out_release_sockets;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (sock.socket && msock.socket) {
|
|
|
rcu_read_lock();
|
|
|
- nc = rcu_dereference(tconn->net_conf);
|
|
|
+ nc = rcu_dereference(connection->net_conf);
|
|
|
timeout = nc->ping_timeo * HZ / 10;
|
|
|
rcu_read_unlock();
|
|
|
schedule_timeout_interruptible(timeout);
|
|
|
@@ -926,15 +928,15 @@ static int conn_connect(struct drbd_tconn *tconn)
|
|
|
}
|
|
|
|
|
|
retry:
|
|
|
- s = drbd_wait_for_connect(tconn, &ad);
|
|
|
+ s = drbd_wait_for_connect(connection, &ad);
|
|
|
if (s) {
|
|
|
- int fp = receive_first_packet(tconn, s);
|
|
|
+ int fp = receive_first_packet(connection, s);
|
|
|
drbd_socket_okay(&sock.socket);
|
|
|
drbd_socket_okay(&msock.socket);
|
|
|
switch (fp) {
|
|
|
case P_INITIAL_DATA:
|
|
|
if (sock.socket) {
|
|
|
- conn_warn(tconn, "initial packet S crossed\n");
|
|
|
+ drbd_warn(connection, "initial packet S crossed\n");
|
|
|
sock_release(sock.socket);
|
|
|
sock.socket = s;
|
|
|
goto randomize;
|
|
|
@@ -942,9 +944,9 @@ retry:
|
|
|
sock.socket = s;
|
|
|
break;
|
|
|
case P_INITIAL_META:
|
|
|
- set_bit(RESOLVE_CONFLICTS, &tconn->flags);
|
|
|
+ set_bit(RESOLVE_CONFLICTS, &connection->flags);
|
|
|
if (msock.socket) {
|
|
|
- conn_warn(tconn, "initial packet M crossed\n");
|
|
|
+ drbd_warn(connection, "initial packet M crossed\n");
|
|
|
sock_release(msock.socket);
|
|
|
msock.socket = s;
|
|
|
goto randomize;
|
|
|
@@ -952,7 +954,7 @@ retry:
|
|
|
msock.socket = s;
|
|
|
break;
|
|
|
default:
|
|
|
- conn_warn(tconn, "Error receiving initial packet\n");
|
|
|
+ drbd_warn(connection, "Error receiving initial packet\n");
|
|
|
sock_release(s);
|
|
|
randomize:
|
|
|
if (prandom_u32() & 1)
|
|
|
@@ -960,12 +962,12 @@ randomize:
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (tconn->cstate <= C_DISCONNECTING)
|
|
|
+ if (connection->cstate <= C_DISCONNECTING)
|
|
|
goto out_release_sockets;
|
|
|
if (signal_pending(current)) {
|
|
|
flush_signals(current);
|
|
|
smp_rmb();
|
|
|
- if (get_t_state(&tconn->receiver) == EXITING)
|
|
|
+ if (get_t_state(&connection->receiver) == EXITING)
|
|
|
goto out_release_sockets;
|
|
|
}
|
|
|
|
|
|
@@ -986,12 +988,12 @@ randomize:
|
|
|
msock.socket->sk->sk_priority = TC_PRIO_INTERACTIVE;
|
|
|
|
|
|
/* NOT YET ...
|
|
|
- * sock.socket->sk->sk_sndtimeo = tconn->net_conf->timeout*HZ/10;
|
|
|
+ * sock.socket->sk->sk_sndtimeo = connection->net_conf->timeout*HZ/10;
|
|
|
* sock.socket->sk->sk_rcvtimeo = MAX_SCHEDULE_TIMEOUT;
|
|
|
* first set it to the P_CONNECTION_FEATURES timeout,
|
|
|
* which we set to 4x the configured ping_timeout. */
|
|
|
rcu_read_lock();
|
|
|
- nc = rcu_dereference(tconn->net_conf);
|
|
|
+ nc = rcu_dereference(connection->net_conf);
|
|
|
|
|
|
sock.socket->sk->sk_sndtimeo =
|
|
|
sock.socket->sk->sk_rcvtimeo = nc->ping_timeo*4*HZ/10;
|
|
|
@@ -1008,37 +1010,38 @@ randomize:
|
|
|
drbd_tcp_nodelay(sock.socket);
|
|
|
drbd_tcp_nodelay(msock.socket);
|
|
|
|
|
|
- tconn->data.socket = sock.socket;
|
|
|
- tconn->meta.socket = msock.socket;
|
|
|
- tconn->last_received = jiffies;
|
|
|
+ connection->data.socket = sock.socket;
|
|
|
+ connection->meta.socket = msock.socket;
|
|
|
+ connection->last_received = jiffies;
|
|
|
|
|
|
- h = drbd_do_features(tconn);
|
|
|
+ h = drbd_do_features(connection);
|
|
|
if (h <= 0)
|
|
|
return h;
|
|
|
|
|
|
- if (tconn->cram_hmac_tfm) {
|
|
|
- /* drbd_request_state(mdev, NS(conn, WFAuth)); */
|
|
|
- switch (drbd_do_auth(tconn)) {
|
|
|
+ if (connection->cram_hmac_tfm) {
|
|
|
+ /* drbd_request_state(device, NS(conn, WFAuth)); */
|
|
|
+ switch (drbd_do_auth(connection)) {
|
|
|
case -1:
|
|
|
- conn_err(tconn, "Authentication of peer failed\n");
|
|
|
+ drbd_err(connection, "Authentication of peer failed\n");
|
|
|
return -1;
|
|
|
case 0:
|
|
|
- conn_err(tconn, "Authentication of peer failed, trying again.\n");
|
|
|
+ drbd_err(connection, "Authentication of peer failed, trying again.\n");
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- tconn->data.socket->sk->sk_sndtimeo = timeout;
|
|
|
- tconn->data.socket->sk->sk_rcvtimeo = MAX_SCHEDULE_TIMEOUT;
|
|
|
+ connection->data.socket->sk->sk_sndtimeo = timeout;
|
|
|
+ connection->data.socket->sk->sk_rcvtimeo = MAX_SCHEDULE_TIMEOUT;
|
|
|
|
|
|
- if (drbd_send_protocol(tconn) == -EOPNOTSUPP)
|
|
|
+ if (drbd_send_protocol(connection) == -EOPNOTSUPP)
|
|
|
return -1;
|
|
|
|
|
|
- set_bit(STATE_SENT, &tconn->flags);
|
|
|
+ set_bit(STATE_SENT, &connection->flags);
|
|
|
|
|
|
rcu_read_lock();
|
|
|
- idr_for_each_entry(&tconn->volumes, mdev, vnr) {
|
|
|
- kref_get(&mdev->kref);
|
|
|
+ idr_for_each_entry(&connection->peer_devices, peer_device, vnr) {
|
|
|
+ struct drbd_device *device = peer_device->device;
|
|
|
+ kref_get(&device->kref);
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
/* Prevent a race between resync-handshake and
|
|
|
@@ -1048,35 +1051,35 @@ randomize:
|
|
|
* drbd_set_role() is finished, and any incoming drbd_set_role
|
|
|
* will see the STATE_SENT flag, and wait for it to be cleared.
|
|
|
*/
|
|
|
- mutex_lock(mdev->state_mutex);
|
|
|
- mutex_unlock(mdev->state_mutex);
|
|
|
+ mutex_lock(device->state_mutex);
|
|
|
+ mutex_unlock(device->state_mutex);
|
|
|
|
|
|
if (discard_my_data)
|
|
|
- set_bit(DISCARD_MY_DATA, &mdev->flags);
|
|
|
+ set_bit(DISCARD_MY_DATA, &device->flags);
|
|
|
else
|
|
|
- clear_bit(DISCARD_MY_DATA, &mdev->flags);
|
|
|
+ clear_bit(DISCARD_MY_DATA, &device->flags);
|
|
|
|
|
|
- drbd_connected(mdev);
|
|
|
- kref_put(&mdev->kref, &drbd_minor_destroy);
|
|
|
+ drbd_connected(peer_device);
|
|
|
+ kref_put(&device->kref, drbd_destroy_device);
|
|
|
rcu_read_lock();
|
|
|
}
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
- rv = conn_request_state(tconn, NS(conn, C_WF_REPORT_PARAMS), CS_VERBOSE);
|
|
|
- if (rv < SS_SUCCESS || tconn->cstate != C_WF_REPORT_PARAMS) {
|
|
|
- clear_bit(STATE_SENT, &tconn->flags);
|
|
|
+ rv = conn_request_state(connection, NS(conn, C_WF_REPORT_PARAMS), CS_VERBOSE);
|
|
|
+ if (rv < SS_SUCCESS || connection->cstate != C_WF_REPORT_PARAMS) {
|
|
|
+ clear_bit(STATE_SENT, &connection->flags);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- drbd_thread_start(&tconn->asender);
|
|
|
+ drbd_thread_start(&connection->asender);
|
|
|
|
|
|
- mutex_lock(&tconn->conf_update);
|
|
|
+ mutex_lock(&connection->resource->conf_update);
|
|
|
/* The discard_my_data flag is a single-shot modifier to the next
|
|
|
* connection attempt, the handshake of which is now well underway.
|
|
|
* No need for rcu style copying of the whole struct
|
|
|
* just to clear a single value. */
|
|
|
- tconn->net_conf->discard_my_data = 0;
|
|
|
- mutex_unlock(&tconn->conf_update);
|
|
|
+ connection->net_conf->discard_my_data = 0;
|
|
|
+ mutex_unlock(&connection->resource->conf_update);
|
|
|
|
|
|
return h;
|
|
|
|
|
|
@@ -1090,15 +1093,15 @@ out_release_sockets:
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
-static int decode_header(struct drbd_tconn *tconn, void *header, struct packet_info *pi)
|
|
|
+static int decode_header(struct drbd_connection *connection, void *header, struct packet_info *pi)
|
|
|
{
|
|
|
- unsigned int header_size = drbd_header_size(tconn);
|
|
|
+ unsigned int header_size = drbd_header_size(connection);
|
|
|
|
|
|
if (header_size == sizeof(struct p_header100) &&
|
|
|
*(__be32 *)header == cpu_to_be32(DRBD_MAGIC_100)) {
|
|
|
struct p_header100 *h = header;
|
|
|
if (h->pad != 0) {
|
|
|
- conn_err(tconn, "Header padding is not zero\n");
|
|
|
+ drbd_err(connection, "Header padding is not zero\n");
|
|
|
return -EINVAL;
|
|
|
}
|
|
|
pi->vnr = be16_to_cpu(h->volume);
|
|
|
@@ -1117,55 +1120,57 @@ static int decode_header(struct drbd_tconn *tconn, void *header, struct packet_i
|
|
|
pi->size = be16_to_cpu(h->length);
|
|
|
pi->vnr = 0;
|
|
|
} else {
|
|
|
- conn_err(tconn, "Wrong magic value 0x%08x in protocol version %d\n",
|
|
|
+ drbd_err(connection, "Wrong magic value 0x%08x in protocol version %d\n",
|
|
|
be32_to_cpu(*(__be32 *)header),
|
|
|
- tconn->agreed_pro_version);
|
|
|
+ connection->agreed_pro_version);
|
|
|
return -EINVAL;
|
|
|
}
|
|
|
pi->data = header + header_size;
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int drbd_recv_header(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int drbd_recv_header(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
- void *buffer = tconn->data.rbuf;
|
|
|
+ void *buffer = connection->data.rbuf;
|
|
|
int err;
|
|
|
|
|
|
- err = drbd_recv_all_warn(tconn, buffer, drbd_header_size(tconn));
|
|
|
+ err = drbd_recv_all_warn(connection, buffer, drbd_header_size(connection));
|
|
|
if (err)
|
|
|
return err;
|
|
|
|
|
|
- err = decode_header(tconn, buffer, pi);
|
|
|
- tconn->last_received = jiffies;
|
|
|
+ err = decode_header(connection, buffer, pi);
|
|
|
+ connection->last_received = jiffies;
|
|
|
|
|
|
return err;
|
|
|
}
|
|
|
|
|
|
-static void drbd_flush(struct drbd_tconn *tconn)
|
|
|
+static void drbd_flush(struct drbd_connection *connection)
|
|
|
{
|
|
|
int rv;
|
|
|
- struct drbd_conf *mdev;
|
|
|
+ struct drbd_peer_device *peer_device;
|
|
|
int vnr;
|
|
|
|
|
|
- if (tconn->write_ordering >= WO_bdev_flush) {
|
|
|
+ if (connection->write_ordering >= WO_bdev_flush) {
|
|
|
rcu_read_lock();
|
|
|
- idr_for_each_entry(&tconn->volumes, mdev, vnr) {
|
|
|
- if (!get_ldev(mdev))
|
|
|
+ idr_for_each_entry(&connection->peer_devices, peer_device, vnr) {
|
|
|
+ struct drbd_device *device = peer_device->device;
|
|
|
+
|
|
|
+ if (!get_ldev(device))
|
|
|
continue;
|
|
|
- kref_get(&mdev->kref);
|
|
|
+ kref_get(&device->kref);
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
- rv = blkdev_issue_flush(mdev->ldev->backing_bdev,
|
|
|
+ rv = blkdev_issue_flush(device->ldev->backing_bdev,
|
|
|
GFP_NOIO, NULL);
|
|
|
if (rv) {
|
|
|
- dev_info(DEV, "local disk flush failed with status %d\n", rv);
|
|
|
+ drbd_info(device, "local disk flush failed with status %d\n", rv);
|
|
|
/* would rather check on EOPNOTSUPP, but that is not reliable.
|
|
|
* don't try again for ANY return value != 0
|
|
|
* if (rv == -EOPNOTSUPP) */
|
|
|
- drbd_bump_write_ordering(tconn, WO_drain_io);
|
|
|
+ drbd_bump_write_ordering(connection, WO_drain_io);
|
|
|
}
|
|
|
- put_ldev(mdev);
|
|
|
- kref_put(&mdev->kref, &drbd_minor_destroy);
|
|
|
+ put_ldev(device);
|
|
|
+ kref_put(&device->kref, drbd_destroy_device);
|
|
|
|
|
|
rcu_read_lock();
|
|
|
if (rv)
|
|
|
@@ -1177,11 +1182,11 @@ static void drbd_flush(struct drbd_tconn *tconn)
|
|
|
|
|
|
/**
|
|
|
* drbd_may_finish_epoch() - Applies an epoch_event to the epoch's state, eventually finishes it.
|
|
|
- * @mdev: DRBD device.
|
|
|
+ * @device: DRBD device.
|
|
|
* @epoch: Epoch object.
|
|
|
* @ev: Epoch event.
|
|
|
*/
|
|
|
-static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
|
|
|
+static enum finish_epoch drbd_may_finish_epoch(struct drbd_connection *connection,
|
|
|
struct drbd_epoch *epoch,
|
|
|
enum epoch_event ev)
|
|
|
{
|
|
|
@@ -1189,7 +1194,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
|
|
|
struct drbd_epoch *next_epoch;
|
|
|
enum finish_epoch rv = FE_STILL_LIVE;
|
|
|
|
|
|
- spin_lock(&tconn->epoch_lock);
|
|
|
+ spin_lock(&connection->epoch_lock);
|
|
|
do {
|
|
|
next_epoch = NULL;
|
|
|
|
|
|
@@ -1211,22 +1216,22 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
|
|
|
atomic_read(&epoch->active) == 0 &&
|
|
|
(test_bit(DE_HAVE_BARRIER_NUMBER, &epoch->flags) || ev & EV_CLEANUP)) {
|
|
|
if (!(ev & EV_CLEANUP)) {
|
|
|
- spin_unlock(&tconn->epoch_lock);
|
|
|
- drbd_send_b_ack(epoch->tconn, epoch->barrier_nr, epoch_size);
|
|
|
- spin_lock(&tconn->epoch_lock);
|
|
|
+ spin_unlock(&connection->epoch_lock);
|
|
|
+ drbd_send_b_ack(epoch->connection, epoch->barrier_nr, epoch_size);
|
|
|
+ spin_lock(&connection->epoch_lock);
|
|
|
}
|
|
|
#if 0
|
|
|
/* FIXME: dec unacked on connection, once we have
|
|
|
* something to count pending connection packets in. */
|
|
|
if (test_bit(DE_HAVE_BARRIER_NUMBER, &epoch->flags))
|
|
|
- dec_unacked(epoch->tconn);
|
|
|
+ dec_unacked(epoch->connection);
|
|
|
#endif
|
|
|
|
|
|
- if (tconn->current_epoch != epoch) {
|
|
|
+ if (connection->current_epoch != epoch) {
|
|
|
next_epoch = list_entry(epoch->list.next, struct drbd_epoch, list);
|
|
|
list_del(&epoch->list);
|
|
|
ev = EV_BECAME_LAST | (ev & EV_CLEANUP);
|
|
|
- tconn->epochs--;
|
|
|
+ connection->epochs--;
|
|
|
kfree(epoch);
|
|
|
|
|
|
if (rv == FE_STILL_LIVE)
|
|
|
@@ -1246,20 +1251,20 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
|
|
|
epoch = next_epoch;
|
|
|
} while (1);
|
|
|
|
|
|
- spin_unlock(&tconn->epoch_lock);
|
|
|
+ spin_unlock(&connection->epoch_lock);
|
|
|
|
|
|
return rv;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* drbd_bump_write_ordering() - Fall back to an other write ordering method
|
|
|
- * @tconn: DRBD connection.
|
|
|
+ * @connection: DRBD connection.
|
|
|
* @wo: Write ordering method to try.
|
|
|
*/
|
|
|
-void drbd_bump_write_ordering(struct drbd_tconn *tconn, enum write_ordering_e wo)
|
|
|
+void drbd_bump_write_ordering(struct drbd_connection *connection, enum write_ordering_e wo)
|
|
|
{
|
|
|
struct disk_conf *dc;
|
|
|
- struct drbd_conf *mdev;
|
|
|
+ struct drbd_peer_device *peer_device;
|
|
|
enum write_ordering_e pwo;
|
|
|
int vnr;
|
|
|
static char *write_ordering_str[] = {
|
|
|
@@ -1268,29 +1273,31 @@ void drbd_bump_write_ordering(struct drbd_tconn *tconn, enum write_ordering_e wo
|
|
|
[WO_bdev_flush] = "flush",
|
|
|
};
|
|
|
|
|
|
- pwo = tconn->write_ordering;
|
|
|
+ pwo = connection->write_ordering;
|
|
|
wo = min(pwo, wo);
|
|
|
rcu_read_lock();
|
|
|
- idr_for_each_entry(&tconn->volumes, mdev, vnr) {
|
|
|
- if (!get_ldev_if_state(mdev, D_ATTACHING))
|
|
|
+ idr_for_each_entry(&connection->peer_devices, peer_device, vnr) {
|
|
|
+ struct drbd_device *device = peer_device->device;
|
|
|
+
|
|
|
+ if (!get_ldev_if_state(device, D_ATTACHING))
|
|
|
continue;
|
|
|
- dc = rcu_dereference(mdev->ldev->disk_conf);
|
|
|
+ dc = rcu_dereference(device->ldev->disk_conf);
|
|
|
|
|
|
if (wo == WO_bdev_flush && !dc->disk_flushes)
|
|
|
wo = WO_drain_io;
|
|
|
if (wo == WO_drain_io && !dc->disk_drain)
|
|
|
wo = WO_none;
|
|
|
- put_ldev(mdev);
|
|
|
+ put_ldev(device);
|
|
|
}
|
|
|
rcu_read_unlock();
|
|
|
- tconn->write_ordering = wo;
|
|
|
- if (pwo != tconn->write_ordering || wo == WO_bdev_flush)
|
|
|
- conn_info(tconn, "Method to ensure write ordering: %s\n", write_ordering_str[tconn->write_ordering]);
|
|
|
+ connection->write_ordering = wo;
|
|
|
+ if (pwo != connection->write_ordering || wo == WO_bdev_flush)
|
|
|
+ drbd_info(connection, "Method to ensure write ordering: %s\n", write_ordering_str[connection->write_ordering]);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* drbd_submit_peer_request()
|
|
|
- * @mdev: DRBD device.
|
|
|
+ * @device: DRBD device.
|
|
|
* @peer_req: peer request
|
|
|
* @rw: flag field, see bio->bi_rw
|
|
|
*
|
|
|
@@ -1305,7 +1312,7 @@ void drbd_bump_write_ordering(struct drbd_tconn *tconn, enum write_ordering_e wo
|
|
|
* on certain Xen deployments.
|
|
|
*/
|
|
|
/* TODO allocate from our own bio_set. */
|
|
|
-int drbd_submit_peer_request(struct drbd_conf *mdev,
|
|
|
+int drbd_submit_peer_request(struct drbd_device *device,
|
|
|
struct drbd_peer_request *peer_req,
|
|
|
const unsigned rw, const int fault_type)
|
|
|
{
|
|
|
@@ -1329,12 +1336,12 @@ int drbd_submit_peer_request(struct drbd_conf *mdev,
|
|
|
next_bio:
|
|
|
bio = bio_alloc(GFP_NOIO, nr_pages);
|
|
|
if (!bio) {
|
|
|
- dev_err(DEV, "submit_ee: Allocation of a bio failed\n");
|
|
|
+ drbd_err(device, "submit_ee: Allocation of a bio failed\n");
|
|
|
goto fail;
|
|
|
}
|
|
|
/* > peer_req->i.sector, unless this is the first bio */
|
|
|
bio->bi_iter.bi_sector = sector;
|
|
|
- bio->bi_bdev = mdev->ldev->backing_bdev;
|
|
|
+ bio->bi_bdev = device->ldev->backing_bdev;
|
|
|
bio->bi_rw = rw;
|
|
|
bio->bi_private = peer_req;
|
|
|
bio->bi_end_io = drbd_peer_request_endio;
|
|
|
@@ -1350,7 +1357,7 @@ next_bio:
|
|
|
* But in case it fails anyways,
|
|
|
* we deal with it, and complain (below). */
|
|
|
if (bio->bi_vcnt == 0) {
|
|
|
- dev_err(DEV,
|
|
|
+ drbd_err(device,
|
|
|
"bio_add_page failed for len=%u, "
|
|
|
"bi_vcnt=0 (bi_sector=%llu)\n",
|
|
|
len, (uint64_t)bio->bi_iter.bi_sector);
|
|
|
@@ -1363,8 +1370,8 @@ next_bio:
|
|
|
sector += len >> 9;
|
|
|
--nr_pages;
|
|
|
}
|
|
|
- D_ASSERT(page == NULL);
|
|
|
- D_ASSERT(ds == 0);
|
|
|
+ D_ASSERT(device, page == NULL);
|
|
|
+ D_ASSERT(device, ds == 0);
|
|
|
|
|
|
atomic_set(&peer_req->pending_bios, n_bios);
|
|
|
do {
|
|
|
@@ -1372,7 +1379,7 @@ next_bio:
|
|
|
bios = bios->bi_next;
|
|
|
bio->bi_next = NULL;
|
|
|
|
|
|
- drbd_generic_make_request(mdev, fault_type, bio);
|
|
|
+ drbd_generic_make_request(device, fault_type, bio);
|
|
|
} while (bios);
|
|
|
return 0;
|
|
|
|
|
|
@@ -1385,36 +1392,44 @@ fail:
|
|
|
return err;
|
|
|
}
|
|
|
|
|
|
-static void drbd_remove_epoch_entry_interval(struct drbd_conf *mdev,
|
|
|
+static void drbd_remove_epoch_entry_interval(struct drbd_device *device,
|
|
|
struct drbd_peer_request *peer_req)
|
|
|
{
|
|
|
struct drbd_interval *i = &peer_req->i;
|
|
|
|
|
|
- drbd_remove_interval(&mdev->write_requests, i);
|
|
|
+ drbd_remove_interval(&device->write_requests, i);
|
|
|
drbd_clear_interval(i);
|
|
|
|
|
|
/* Wake up any processes waiting for this peer request to complete. */
|
|
|
if (i->waiting)
|
|
|
- wake_up(&mdev->misc_wait);
|
|
|
+ wake_up(&device->misc_wait);
|
|
|
}
|
|
|
|
|
|
-void conn_wait_active_ee_empty(struct drbd_tconn *tconn)
|
|
|
+static void conn_wait_active_ee_empty(struct drbd_connection *connection)
|
|
|
{
|
|
|
- struct drbd_conf *mdev;
|
|
|
+ struct drbd_peer_device *peer_device;
|
|
|
int vnr;
|
|
|
|
|
|
rcu_read_lock();
|
|
|
- idr_for_each_entry(&tconn->volumes, mdev, vnr) {
|
|
|
- kref_get(&mdev->kref);
|
|
|
+ idr_for_each_entry(&connection->peer_devices, peer_device, vnr) {
|
|
|
+ struct drbd_device *device = peer_device->device;
|
|
|
+
|
|
|
+ kref_get(&device->kref);
|
|
|
rcu_read_unlock();
|
|
|
- drbd_wait_ee_list_empty(mdev, &mdev->active_ee);
|
|
|
- kref_put(&mdev->kref, &drbd_minor_destroy);
|
|
|
+ drbd_wait_ee_list_empty(device, &device->active_ee);
|
|
|
+ kref_put(&device->kref, drbd_destroy_device);
|
|
|
rcu_read_lock();
|
|
|
}
|
|
|
rcu_read_unlock();
|
|
|
}
|
|
|
|
|
|
-static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static struct drbd_peer_device *
|
|
|
+conn_peer_device(struct drbd_connection *connection, int volume_number)
|
|
|
+{
|
|
|
+ return idr_find(&connection->peer_devices, volume_number);
|
|
|
+}
|
|
|
+
|
|
|
+static int receive_Barrier(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
int rv;
|
|
|
struct p_barrier *p = pi->data;
|
|
|
@@ -1423,16 +1438,16 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
/* FIXME these are unacked on connection,
|
|
|
* not a specific (peer)device.
|
|
|
*/
|
|
|
- tconn->current_epoch->barrier_nr = p->barrier;
|
|
|
- tconn->current_epoch->tconn = tconn;
|
|
|
- rv = drbd_may_finish_epoch(tconn, tconn->current_epoch, EV_GOT_BARRIER_NR);
|
|
|
+ connection->current_epoch->barrier_nr = p->barrier;
|
|
|
+ connection->current_epoch->connection = connection;
|
|
|
+ rv = drbd_may_finish_epoch(connection, connection->current_epoch, EV_GOT_BARRIER_NR);
|
|
|
|
|
|
/* P_BARRIER_ACK may imply that the corresponding extent is dropped from
|
|
|
* the activity log, which means it would not be resynced in case the
|
|
|
* R_PRIMARY crashes now.
|
|
|
* Therefore we must send the barrier_ack after the barrier request was
|
|
|
* completed. */
|
|
|
- switch (tconn->write_ordering) {
|
|
|
+ switch (connection->write_ordering) {
|
|
|
case WO_none:
|
|
|
if (rv == FE_RECYCLED)
|
|
|
return 0;
|
|
|
@@ -1443,15 +1458,15 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
if (epoch)
|
|
|
break;
|
|
|
else
|
|
|
- conn_warn(tconn, "Allocation of an epoch failed, slowing down\n");
|
|
|
+ drbd_warn(connection, "Allocation of an epoch failed, slowing down\n");
|
|
|
/* Fall through */
|
|
|
|
|
|
case WO_bdev_flush:
|
|
|
case WO_drain_io:
|
|
|
- conn_wait_active_ee_empty(tconn);
|
|
|
- drbd_flush(tconn);
|
|
|
+ conn_wait_active_ee_empty(connection);
|
|
|
+ drbd_flush(connection);
|
|
|
|
|
|
- if (atomic_read(&tconn->current_epoch->epoch_size)) {
|
|
|
+ if (atomic_read(&connection->current_epoch->epoch_size)) {
|
|
|
epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
|
|
|
if (epoch)
|
|
|
break;
|
|
|
@@ -1459,7 +1474,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
|
|
|
return 0;
|
|
|
default:
|
|
|
- conn_err(tconn, "Strangeness in tconn->write_ordering %d\n", tconn->write_ordering);
|
|
|
+ drbd_err(connection, "Strangeness in connection->write_ordering %d\n", connection->write_ordering);
|
|
|
return -EIO;
|
|
|
}
|
|
|
|
|
|
@@ -1467,16 +1482,16 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
atomic_set(&epoch->epoch_size, 0);
|
|
|
atomic_set(&epoch->active, 0);
|
|
|
|
|
|
- spin_lock(&tconn->epoch_lock);
|
|
|
- if (atomic_read(&tconn->current_epoch->epoch_size)) {
|
|
|
- list_add(&epoch->list, &tconn->current_epoch->list);
|
|
|
- tconn->current_epoch = epoch;
|
|
|
- tconn->epochs++;
|
|
|
+ spin_lock(&connection->epoch_lock);
|
|
|
+ if (atomic_read(&connection->current_epoch->epoch_size)) {
|
|
|
+ list_add(&epoch->list, &connection->current_epoch->list);
|
|
|
+ connection->current_epoch = epoch;
|
|
|
+ connection->epochs++;
|
|
|
} else {
|
|
|
/* The current_epoch got recycled while we allocated this one... */
|
|
|
kfree(epoch);
|
|
|
}
|
|
|
- spin_unlock(&tconn->epoch_lock);
|
|
|
+ spin_unlock(&connection->epoch_lock);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -1484,25 +1499,26 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
/* used from receive_RSDataReply (recv_resync_read)
|
|
|
* and from receive_Data */
|
|
|
static struct drbd_peer_request *
|
|
|
-read_in_block(struct drbd_conf *mdev, u64 id, sector_t sector,
|
|
|
+read_in_block(struct drbd_peer_device *peer_device, u64 id, sector_t sector,
|
|
|
int data_size) __must_hold(local)
|
|
|
{
|
|
|
- const sector_t capacity = drbd_get_capacity(mdev->this_bdev);
|
|
|
+ struct drbd_device *device = peer_device->device;
|
|
|
+ const sector_t capacity = drbd_get_capacity(device->this_bdev);
|
|
|
struct drbd_peer_request *peer_req;
|
|
|
struct page *page;
|
|
|
int dgs, ds, err;
|
|
|
- void *dig_in = mdev->tconn->int_dig_in;
|
|
|
- void *dig_vv = mdev->tconn->int_dig_vv;
|
|
|
+ void *dig_in = peer_device->connection->int_dig_in;
|
|
|
+ void *dig_vv = peer_device->connection->int_dig_vv;
|
|
|
unsigned long *data;
|
|
|
|
|
|
dgs = 0;
|
|
|
- if (mdev->tconn->peer_integrity_tfm) {
|
|
|
- dgs = crypto_hash_digestsize(mdev->tconn->peer_integrity_tfm);
|
|
|
+ if (peer_device->connection->peer_integrity_tfm) {
|
|
|
+ dgs = crypto_hash_digestsize(peer_device->connection->peer_integrity_tfm);
|
|
|
/*
|
|
|
* FIXME: Receive the incoming digest into the receive buffer
|
|
|
* here, together with its struct p_data?
|
|
|
*/
|
|
|
- err = drbd_recv_all_warn(mdev->tconn, dig_in, dgs);
|
|
|
+ err = drbd_recv_all_warn(peer_device->connection, dig_in, dgs);
|
|
|
if (err)
|
|
|
return NULL;
|
|
|
data_size -= dgs;
|
|
|
@@ -1516,7 +1532,7 @@ read_in_block(struct drbd_conf *mdev, u64 id, sector_t sector,
|
|
|
/* even though we trust out peer,
|
|
|
* we sometimes have to double check. */
|
|
|
if (sector + (data_size>>9) > capacity) {
|
|
|
- dev_err(DEV, "request from peer beyond end of local disk: "
|
|
|
+ drbd_err(device, "request from peer beyond end of local disk: "
|
|
|
"capacity: %llus < sector: %llus + size: %u\n",
|
|
|
(unsigned long long)capacity,
|
|
|
(unsigned long long)sector, data_size);
|
|
|
@@ -1526,7 +1542,7 @@ read_in_block(struct drbd_conf *mdev, u64 id, sector_t sector,
|
|
|
/* GFP_NOIO, because we must not cause arbitrary write-out: in a DRBD
|
|
|
* "criss-cross" setup, that might cause write-out on some other DRBD,
|
|
|
* which in turn might block on the other node at this very place. */
|
|
|
- peer_req = drbd_alloc_peer_req(mdev, id, sector, data_size, GFP_NOIO);
|
|
|
+ peer_req = drbd_alloc_peer_req(peer_device, id, sector, data_size, GFP_NOIO);
|
|
|
if (!peer_req)
|
|
|
return NULL;
|
|
|
|
|
|
@@ -1538,36 +1554,36 @@ read_in_block(struct drbd_conf *mdev, u64 id, sector_t sector,
|
|
|
page_chain_for_each(page) {
|
|
|
unsigned len = min_t(int, ds, PAGE_SIZE);
|
|
|
data = kmap(page);
|
|
|
- err = drbd_recv_all_warn(mdev->tconn, data, len);
|
|
|
- if (drbd_insert_fault(mdev, DRBD_FAULT_RECEIVE)) {
|
|
|
- dev_err(DEV, "Fault injection: Corrupting data on receive\n");
|
|
|
+ err = drbd_recv_all_warn(peer_device->connection, data, len);
|
|
|
+ if (drbd_insert_fault(device, DRBD_FAULT_RECEIVE)) {
|
|
|
+ drbd_err(device, "Fault injection: Corrupting data on receive\n");
|
|
|
data[0] = data[0] ^ (unsigned long)-1;
|
|
|
}
|
|
|
kunmap(page);
|
|
|
if (err) {
|
|
|
- drbd_free_peer_req(mdev, peer_req);
|
|
|
+ drbd_free_peer_req(device, peer_req);
|
|
|
return NULL;
|
|
|
}
|
|
|
ds -= len;
|
|
|
}
|
|
|
|
|
|
if (dgs) {
|
|
|
- drbd_csum_ee(mdev, mdev->tconn->peer_integrity_tfm, peer_req, dig_vv);
|
|
|
+ drbd_csum_ee(peer_device->connection->peer_integrity_tfm, peer_req, dig_vv);
|
|
|
if (memcmp(dig_in, dig_vv, dgs)) {
|
|
|
- dev_err(DEV, "Digest integrity check FAILED: %llus +%u\n",
|
|
|
+ drbd_err(device, "Digest integrity check FAILED: %llus +%u\n",
|
|
|
(unsigned long long)sector, data_size);
|
|
|
- drbd_free_peer_req(mdev, peer_req);
|
|
|
+ drbd_free_peer_req(device, peer_req);
|
|
|
return NULL;
|
|
|
}
|
|
|
}
|
|
|
- mdev->recv_cnt += data_size>>9;
|
|
|
+ device->recv_cnt += data_size>>9;
|
|
|
return peer_req;
|
|
|
}
|
|
|
|
|
|
/* drbd_drain_block() just takes a data block
|
|
|
* out of the socket input buffer, and discards it.
|
|
|
*/
|
|
|
-static int drbd_drain_block(struct drbd_conf *mdev, int data_size)
|
|
|
+static int drbd_drain_block(struct drbd_peer_device *peer_device, int data_size)
|
|
|
{
|
|
|
struct page *page;
|
|
|
int err = 0;
|
|
|
@@ -1576,36 +1592,36 @@ static int drbd_drain_block(struct drbd_conf *mdev, int data_size)
|
|
|
if (!data_size)
|
|
|
return 0;
|
|
|
|
|
|
- page = drbd_alloc_pages(mdev, 1, 1);
|
|
|
+ page = drbd_alloc_pages(peer_device, 1, 1);
|
|
|
|
|
|
data = kmap(page);
|
|
|
while (data_size) {
|
|
|
unsigned int len = min_t(int, data_size, PAGE_SIZE);
|
|
|
|
|
|
- err = drbd_recv_all_warn(mdev->tconn, data, len);
|
|
|
+ err = drbd_recv_all_warn(peer_device->connection, data, len);
|
|
|
if (err)
|
|
|
break;
|
|
|
data_size -= len;
|
|
|
}
|
|
|
kunmap(page);
|
|
|
- drbd_free_pages(mdev, page, 0);
|
|
|
+ drbd_free_pages(peer_device->device, page, 0);
|
|
|
return err;
|
|
|
}
|
|
|
|
|
|
-static int recv_dless_read(struct drbd_conf *mdev, struct drbd_request *req,
|
|
|
+static int recv_dless_read(struct drbd_peer_device *peer_device, struct drbd_request *req,
|
|
|
sector_t sector, int data_size)
|
|
|
{
|
|
|
struct bio_vec bvec;
|
|
|
struct bvec_iter iter;
|
|
|
struct bio *bio;
|
|
|
int dgs, err, expect;
|
|
|
- void *dig_in = mdev->tconn->int_dig_in;
|
|
|
- void *dig_vv = mdev->tconn->int_dig_vv;
|
|
|
+ void *dig_in = peer_device->connection->int_dig_in;
|
|
|
+ void *dig_vv = peer_device->connection->int_dig_vv;
|
|
|
|
|
|
dgs = 0;
|
|
|
- if (mdev->tconn->peer_integrity_tfm) {
|
|
|
- dgs = crypto_hash_digestsize(mdev->tconn->peer_integrity_tfm);
|
|
|
- err = drbd_recv_all_warn(mdev->tconn, dig_in, dgs);
|
|
|
+ if (peer_device->connection->peer_integrity_tfm) {
|
|
|
+ dgs = crypto_hash_digestsize(peer_device->connection->peer_integrity_tfm);
|
|
|
+ err = drbd_recv_all_warn(peer_device->connection, dig_in, dgs);
|
|
|
if (err)
|
|
|
return err;
|
|
|
data_size -= dgs;
|
|
|
@@ -1613,15 +1629,15 @@ static int recv_dless_read(struct drbd_conf *mdev, struct drbd_request *req,
|
|
|
|
|
|
/* optimistically update recv_cnt. if receiving fails below,
|
|
|
* we disconnect anyways, and counters will be reset. */
|
|
|
- mdev->recv_cnt += data_size>>9;
|
|
|
+ peer_device->device->recv_cnt += data_size>>9;
|
|
|
|
|
|
bio = req->master_bio;
|
|
|
- D_ASSERT(sector == bio->bi_iter.bi_sector);
|
|
|
+ D_ASSERT(peer_device->device, sector == bio->bi_iter.bi_sector);
|
|
|
|
|
|
bio_for_each_segment(bvec, bio, iter) {
|
|
|
void *mapped = kmap(bvec.bv_page) + bvec.bv_offset;
|
|
|
expect = min_t(int, data_size, bvec.bv_len);
|
|
|
- err = drbd_recv_all_warn(mdev->tconn, mapped, expect);
|
|
|
+ err = drbd_recv_all_warn(peer_device->connection, mapped, expect);
|
|
|
kunmap(bvec.bv_page);
|
|
|
if (err)
|
|
|
return err;
|
|
|
@@ -1629,14 +1645,14 @@ static int recv_dless_read(struct drbd_conf *mdev, struct drbd_request *req,
|
|
|
}
|
|
|
|
|
|
if (dgs) {
|
|
|
- drbd_csum_bio(mdev, mdev->tconn->peer_integrity_tfm, bio, dig_vv);
|
|
|
+ drbd_csum_bio(peer_device->connection->peer_integrity_tfm, bio, dig_vv);
|
|
|
if (memcmp(dig_in, dig_vv, dgs)) {
|
|
|
- dev_err(DEV, "Digest integrity check FAILED. Broken NICs?\n");
|
|
|
+ drbd_err(peer_device, "Digest integrity check FAILED. Broken NICs?\n");
|
|
|
return -EINVAL;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- D_ASSERT(data_size == 0);
|
|
|
+ D_ASSERT(peer_device->device, data_size == 0);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
@@ -1648,64 +1664,67 @@ static int e_end_resync_block(struct drbd_work *w, int unused)
|
|
|
{
|
|
|
struct drbd_peer_request *peer_req =
|
|
|
container_of(w, struct drbd_peer_request, w);
|
|
|
- struct drbd_conf *mdev = w->mdev;
|
|
|
+ struct drbd_peer_device *peer_device = peer_req->peer_device;
|
|
|
+ struct drbd_device *device = peer_device->device;
|
|
|
sector_t sector = peer_req->i.sector;
|
|
|
int err;
|
|
|
|
|
|
- D_ASSERT(drbd_interval_empty(&peer_req->i));
|
|
|
+ D_ASSERT(device, drbd_interval_empty(&peer_req->i));
|
|
|
|
|
|
if (likely((peer_req->flags & EE_WAS_ERROR) == 0)) {
|
|
|
- drbd_set_in_sync(mdev, sector, peer_req->i.size);
|
|
|
- err = drbd_send_ack(mdev, P_RS_WRITE_ACK, peer_req);
|
|
|
+ drbd_set_in_sync(device, sector, peer_req->i.size);
|
|
|
+ err = drbd_send_ack(peer_device, P_RS_WRITE_ACK, peer_req);
|
|
|
} else {
|
|
|
/* Record failure to sync */
|
|
|
- drbd_rs_failed_io(mdev, sector, peer_req->i.size);
|
|
|
+ drbd_rs_failed_io(device, sector, peer_req->i.size);
|
|
|
|
|
|
- err = drbd_send_ack(mdev, P_NEG_ACK, peer_req);
|
|
|
+ err = drbd_send_ack(peer_device, P_NEG_ACK, peer_req);
|
|
|
}
|
|
|
- dec_unacked(mdev);
|
|
|
+ dec_unacked(device);
|
|
|
|
|
|
return err;
|
|
|
}
|
|
|
|
|
|
-static int recv_resync_read(struct drbd_conf *mdev, sector_t sector, int data_size) __releases(local)
|
|
|
+static int recv_resync_read(struct drbd_peer_device *peer_device, sector_t sector,
|
|
|
+ int data_size) __releases(local)
|
|
|
{
|
|
|
+ struct drbd_device *device = peer_device->device;
|
|
|
struct drbd_peer_request *peer_req;
|
|
|
|
|
|
- peer_req = read_in_block(mdev, ID_SYNCER, sector, data_size);
|
|
|
+ peer_req = read_in_block(peer_device, ID_SYNCER, sector, data_size);
|
|
|
if (!peer_req)
|
|
|
goto fail;
|
|
|
|
|
|
- dec_rs_pending(mdev);
|
|
|
+ dec_rs_pending(device);
|
|
|
|
|
|
- inc_unacked(mdev);
|
|
|
+ inc_unacked(device);
|
|
|
/* corresponding dec_unacked() in e_end_resync_block()
|
|
|
* respective _drbd_clear_done_ee */
|
|
|
|
|
|
peer_req->w.cb = e_end_resync_block;
|
|
|
|
|
|
- spin_lock_irq(&mdev->tconn->req_lock);
|
|
|
- list_add(&peer_req->w.list, &mdev->sync_ee);
|
|
|
- spin_unlock_irq(&mdev->tconn->req_lock);
|
|
|
+ spin_lock_irq(&device->resource->req_lock);
|
|
|
+ list_add(&peer_req->w.list, &device->sync_ee);
|
|
|
+ spin_unlock_irq(&device->resource->req_lock);
|
|
|
|
|
|
- atomic_add(data_size >> 9, &mdev->rs_sect_ev);
|
|
|
- if (drbd_submit_peer_request(mdev, peer_req, WRITE, DRBD_FAULT_RS_WR) == 0)
|
|
|
+ atomic_add(data_size >> 9, &device->rs_sect_ev);
|
|
|
+ if (drbd_submit_peer_request(device, peer_req, WRITE, DRBD_FAULT_RS_WR) == 0)
|
|
|
return 0;
|
|
|
|
|
|
/* don't care for the reason here */
|
|
|
- dev_err(DEV, "submit failed, triggering re-connect\n");
|
|
|
- spin_lock_irq(&mdev->tconn->req_lock);
|
|
|
+ drbd_err(device, "submit failed, triggering re-connect\n");
|
|
|
+ spin_lock_irq(&device->resource->req_lock);
|
|
|
list_del(&peer_req->w.list);
|
|
|
- spin_unlock_irq(&mdev->tconn->req_lock);
|
|
|
+ spin_unlock_irq(&device->resource->req_lock);
|
|
|
|
|
|
- drbd_free_peer_req(mdev, peer_req);
|
|
|
+ drbd_free_peer_req(device, peer_req);
|
|
|
fail:
|
|
|
- put_ldev(mdev);
|
|
|
+ put_ldev(device);
|
|
|
return -EIO;
|
|
|
}
|
|
|
|
|
|
static struct drbd_request *
|
|
|
-find_request(struct drbd_conf *mdev, struct rb_root *root, u64 id,
|
|
|
+find_request(struct drbd_device *device, struct rb_root *root, u64 id,
|
|
|
sector_t sector, bool missing_ok, const char *func)
|
|
|
{
|
|
|
struct drbd_request *req;
|
|
|
@@ -1715,36 +1734,38 @@ find_request(struct drbd_conf *mdev, struct rb_root *root, u64 id,
|
|
|
if (drbd_contains_interval(root, sector, &req->i) && req->i.local)
|
|
|
return req;
|
|
|
if (!missing_ok) {
|
|
|
- dev_err(DEV, "%s: failed to find request 0x%lx, sector %llus\n", func,
|
|
|
+ drbd_err(device, "%s: failed to find request 0x%lx, sector %llus\n", func,
|
|
|
(unsigned long)id, (unsigned long long)sector);
|
|
|
}
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
-static int receive_DataReply(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int receive_DataReply(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
- struct drbd_conf *mdev;
|
|
|
+ struct drbd_peer_device *peer_device;
|
|
|
+ struct drbd_device *device;
|
|
|
struct drbd_request *req;
|
|
|
sector_t sector;
|
|
|
int err;
|
|
|
struct p_data *p = pi->data;
|
|
|
|
|
|
- mdev = vnr_to_mdev(tconn, pi->vnr);
|
|
|
- if (!mdev)
|
|
|
+ peer_device = conn_peer_device(connection, pi->vnr);
|
|
|
+ if (!peer_device)
|
|
|
return -EIO;
|
|
|
+ device = peer_device->device;
|
|
|
|
|
|
sector = be64_to_cpu(p->sector);
|
|
|
|
|
|
- spin_lock_irq(&mdev->tconn->req_lock);
|
|
|
- req = find_request(mdev, &mdev->read_requests, p->block_id, sector, false, __func__);
|
|
|
- spin_unlock_irq(&mdev->tconn->req_lock);
|
|
|
+ spin_lock_irq(&device->resource->req_lock);
|
|
|
+ req = find_request(device, &device->read_requests, p->block_id, sector, false, __func__);
|
|
|
+ spin_unlock_irq(&device->resource->req_lock);
|
|
|
if (unlikely(!req))
|
|
|
return -EIO;
|
|
|
|
|
|
/* hlist_del(&req->collision) is done in _req_may_be_done, to avoid
|
|
|
* special casing it there for the various failure cases.
|
|
|
* still no race with drbd_fail_pending_reads */
|
|
|
- err = recv_dless_read(mdev, req, sector, pi->size);
|
|
|
+ err = recv_dless_read(peer_device, req, sector, pi->size);
|
|
|
if (!err)
|
|
|
req_mod(req, DATA_RECEIVED);
|
|
|
/* else: nothing. handled from drbd_disconnect...
|
|
|
@@ -1754,46 +1775,48 @@ static int receive_DataReply(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
return err;
|
|
|
}
|
|
|
|
|
|
-static int receive_RSDataReply(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int receive_RSDataReply(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
- struct drbd_conf *mdev;
|
|
|
+ struct drbd_peer_device *peer_device;
|
|
|
+ struct drbd_device *device;
|
|
|
sector_t sector;
|
|
|
int err;
|
|
|
struct p_data *p = pi->data;
|
|
|
|
|
|
- mdev = vnr_to_mdev(tconn, pi->vnr);
|
|
|
- if (!mdev)
|
|
|
+ peer_device = conn_peer_device(connection, pi->vnr);
|
|
|
+ if (!peer_device)
|
|
|
return -EIO;
|
|
|
+ device = peer_device->device;
|
|
|
|
|
|
sector = be64_to_cpu(p->sector);
|
|
|
- D_ASSERT(p->block_id == ID_SYNCER);
|
|
|
+ D_ASSERT(device, p->block_id == ID_SYNCER);
|
|
|
|
|
|
- if (get_ldev(mdev)) {
|
|
|
+ if (get_ldev(device)) {
|
|
|
/* data is submitted to disk within recv_resync_read.
|
|
|
* corresponding put_ldev done below on error,
|
|
|
* or in drbd_peer_request_endio. */
|
|
|
- err = recv_resync_read(mdev, sector, pi->size);
|
|
|
+ err = recv_resync_read(peer_device, sector, pi->size);
|
|
|
} else {
|
|
|
if (__ratelimit(&drbd_ratelimit_state))
|
|
|
- dev_err(DEV, "Can not write resync data to local disk.\n");
|
|
|
+ drbd_err(device, "Can not write resync data to local disk.\n");
|
|
|
|
|
|
- err = drbd_drain_block(mdev, pi->size);
|
|
|
+ err = drbd_drain_block(peer_device, pi->size);
|
|
|
|
|
|
- drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
|
|
|
+ drbd_send_ack_dp(peer_device, P_NEG_ACK, p, pi->size);
|
|
|
}
|
|
|
|
|
|
- atomic_add(pi->size >> 9, &mdev->rs_sect_in);
|
|
|
+ atomic_add(pi->size >> 9, &device->rs_sect_in);
|
|
|
|
|
|
return err;
|
|
|
}
|
|
|
|
|
|
-static void restart_conflicting_writes(struct drbd_conf *mdev,
|
|
|
+static void restart_conflicting_writes(struct drbd_device *device,
|
|
|
sector_t sector, int size)
|
|
|
{
|
|
|
struct drbd_interval *i;
|
|
|
struct drbd_request *req;
|
|
|
|
|
|
- drbd_for_each_overlap(i, &mdev->write_requests, sector, size) {
|
|
|
+ drbd_for_each_overlap(i, &device->write_requests, sector, size) {
|
|
|
if (!i->local)
|
|
|
continue;
|
|
|
req = container_of(i, struct drbd_request, i);
|
|
|
@@ -1813,52 +1836,53 @@ static int e_end_block(struct drbd_work *w, int cancel)
|
|
|
{
|
|
|
struct drbd_peer_request *peer_req =
|
|
|
container_of(w, struct drbd_peer_request, w);
|
|
|
- struct drbd_conf *mdev = w->mdev;
|
|
|
+ struct drbd_peer_device *peer_device = peer_req->peer_device;
|
|
|
+ struct drbd_device *device = peer_device->device;
|
|
|
sector_t sector = peer_req->i.sector;
|
|
|
int err = 0, pcmd;
|
|
|
|
|
|
if (peer_req->flags & EE_SEND_WRITE_ACK) {
|
|
|
if (likely((peer_req->flags & EE_WAS_ERROR) == 0)) {
|
|
|
- pcmd = (mdev->state.conn >= C_SYNC_SOURCE &&
|
|
|
- mdev->state.conn <= C_PAUSED_SYNC_T &&
|
|
|
+ pcmd = (device->state.conn >= C_SYNC_SOURCE &&
|
|
|
+ device->state.conn <= C_PAUSED_SYNC_T &&
|
|
|
peer_req->flags & EE_MAY_SET_IN_SYNC) ?
|
|
|
P_RS_WRITE_ACK : P_WRITE_ACK;
|
|
|
- err = drbd_send_ack(mdev, pcmd, peer_req);
|
|
|
+ err = drbd_send_ack(peer_device, pcmd, peer_req);
|
|
|
if (pcmd == P_RS_WRITE_ACK)
|
|
|
- drbd_set_in_sync(mdev, sector, peer_req->i.size);
|
|
|
+ drbd_set_in_sync(device, sector, peer_req->i.size);
|
|
|
} else {
|
|
|
- err = drbd_send_ack(mdev, P_NEG_ACK, peer_req);
|
|
|
+ err = drbd_send_ack(peer_device, P_NEG_ACK, peer_req);
|
|
|
/* we expect it to be marked out of sync anyways...
|
|
|
* maybe assert this? */
|
|
|
}
|
|
|
- dec_unacked(mdev);
|
|
|
+ dec_unacked(device);
|
|
|
}
|
|
|
/* we delete from the conflict detection hash _after_ we sent out the
|
|
|
* P_WRITE_ACK / P_NEG_ACK, to get the sequence number right. */
|
|
|
if (peer_req->flags & EE_IN_INTERVAL_TREE) {
|
|
|
- spin_lock_irq(&mdev->tconn->req_lock);
|
|
|
- D_ASSERT(!drbd_interval_empty(&peer_req->i));
|
|
|
- drbd_remove_epoch_entry_interval(mdev, peer_req);
|
|
|
+ spin_lock_irq(&device->resource->req_lock);
|
|
|
+ D_ASSERT(device, !drbd_interval_empty(&peer_req->i));
|
|
|
+ drbd_remove_epoch_entry_interval(device, peer_req);
|
|
|
if (peer_req->flags & EE_RESTART_REQUESTS)
|
|
|
- restart_conflicting_writes(mdev, sector, peer_req->i.size);
|
|
|
- spin_unlock_irq(&mdev->tconn->req_lock);
|
|
|
+ restart_conflicting_writes(device, sector, peer_req->i.size);
|
|
|
+ spin_unlock_irq(&device->resource->req_lock);
|
|
|
} else
|
|
|
- D_ASSERT(drbd_interval_empty(&peer_req->i));
|
|
|
+ D_ASSERT(device, drbd_interval_empty(&peer_req->i));
|
|
|
|
|
|
- drbd_may_finish_epoch(mdev->tconn, peer_req->epoch, EV_PUT + (cancel ? EV_CLEANUP : 0));
|
|
|
+ drbd_may_finish_epoch(first_peer_device(device)->connection, peer_req->epoch, EV_PUT + (cancel ? EV_CLEANUP : 0));
|
|
|
|
|
|
return err;
|
|
|
}
|
|
|
|
|
|
static int e_send_ack(struct drbd_work *w, enum drbd_packet ack)
|
|
|
{
|
|
|
- struct drbd_conf *mdev = w->mdev;
|
|
|
struct drbd_peer_request *peer_req =
|
|
|
container_of(w, struct drbd_peer_request, w);
|
|
|
+ struct drbd_peer_device *peer_device = peer_req->peer_device;
|
|
|
int err;
|
|
|
|
|
|
- err = drbd_send_ack(mdev, ack, peer_req);
|
|
|
- dec_unacked(mdev);
|
|
|
+ err = drbd_send_ack(peer_device, ack, peer_req);
|
|
|
+ dec_unacked(peer_device->device);
|
|
|
|
|
|
return err;
|
|
|
}
|
|
|
@@ -1870,9 +1894,11 @@ static int e_send_superseded(struct drbd_work *w, int unused)
|
|
|
|
|
|
static int e_send_retry_write(struct drbd_work *w, int unused)
|
|
|
{
|
|
|
- struct drbd_tconn *tconn = w->mdev->tconn;
|
|
|
+ struct drbd_peer_request *peer_req =
|
|
|
+ container_of(w, struct drbd_peer_request, w);
|
|
|
+ struct drbd_connection *connection = peer_req->peer_device->connection;
|
|
|
|
|
|
- return e_send_ack(w, tconn->agreed_pro_version >= 100 ?
|
|
|
+ return e_send_ack(w, connection->agreed_pro_version >= 100 ?
|
|
|
P_RETRY_WRITE : P_SUPERSEDED);
|
|
|
}
|
|
|
|
|
|
@@ -1891,18 +1917,19 @@ static u32 seq_max(u32 a, u32 b)
|
|
|
return seq_greater(a, b) ? a : b;
|
|
|
}
|
|
|
|
|
|
-static void update_peer_seq(struct drbd_conf *mdev, unsigned int peer_seq)
|
|
|
+static void update_peer_seq(struct drbd_peer_device *peer_device, unsigned int peer_seq)
|
|
|
{
|
|
|
+ struct drbd_device *device = peer_device->device;
|
|
|
unsigned int newest_peer_seq;
|
|
|
|
|
|
- if (test_bit(RESOLVE_CONFLICTS, &mdev->tconn->flags)) {
|
|
|
- spin_lock(&mdev->peer_seq_lock);
|
|
|
- newest_peer_seq = seq_max(mdev->peer_seq, peer_seq);
|
|
|
- mdev->peer_seq = newest_peer_seq;
|
|
|
- spin_unlock(&mdev->peer_seq_lock);
|
|
|
- /* wake up only if we actually changed mdev->peer_seq */
|
|
|
+ if (test_bit(RESOLVE_CONFLICTS, &peer_device->connection->flags)) {
|
|
|
+ spin_lock(&device->peer_seq_lock);
|
|
|
+ newest_peer_seq = seq_max(device->peer_seq, peer_seq);
|
|
|
+ device->peer_seq = newest_peer_seq;
|
|
|
+ spin_unlock(&device->peer_seq_lock);
|
|
|
+ /* wake up only if we actually changed device->peer_seq */
|
|
|
if (peer_seq == newest_peer_seq)
|
|
|
- wake_up(&mdev->seq_wait);
|
|
|
+ wake_up(&device->seq_wait);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1912,20 +1939,20 @@ static inline int overlaps(sector_t s1, int l1, sector_t s2, int l2)
|
|
|
}
|
|
|
|
|
|
/* maybe change sync_ee into interval trees as well? */
|
|
|
-static bool overlapping_resync_write(struct drbd_conf *mdev, struct drbd_peer_request *peer_req)
|
|
|
+static bool overlapping_resync_write(struct drbd_device *device, struct drbd_peer_request *peer_req)
|
|
|
{
|
|
|
struct drbd_peer_request *rs_req;
|
|
|
bool rv = 0;
|
|
|
|
|
|
- spin_lock_irq(&mdev->tconn->req_lock);
|
|
|
- list_for_each_entry(rs_req, &mdev->sync_ee, w.list) {
|
|
|
+ spin_lock_irq(&device->resource->req_lock);
|
|
|
+ list_for_each_entry(rs_req, &device->sync_ee, w.list) {
|
|
|
if (overlaps(peer_req->i.sector, peer_req->i.size,
|
|
|
rs_req->i.sector, rs_req->i.size)) {
|
|
|
rv = 1;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- spin_unlock_irq(&mdev->tconn->req_lock);
|
|
|
+ spin_unlock_irq(&device->resource->req_lock);
|
|
|
|
|
|
return rv;
|
|
|
}
|
|
|
@@ -1939,9 +1966,9 @@ static bool overlapping_resync_write(struct drbd_conf *mdev, struct drbd_peer_re
|
|
|
*
|
|
|
* Note: we don't care for Ack packets overtaking P_DATA packets.
|
|
|
*
|
|
|
- * In case packet_seq is larger than mdev->peer_seq number, there are
|
|
|
+ * In case packet_seq is larger than device->peer_seq number, there are
|
|
|
* outstanding packets on the msock. We wait for them to arrive.
|
|
|
- * In case we are the logically next packet, we update mdev->peer_seq
|
|
|
+ * In case we are the logically next packet, we update device->peer_seq
|
|
|
* ourselves. Correctly handles 32bit wrap around.
|
|
|
*
|
|
|
* Assume we have a 10 GBit connection, that is about 1<<30 byte per second,
|
|
|
@@ -1951,19 +1978,20 @@ static bool overlapping_resync_write(struct drbd_conf *mdev, struct drbd_peer_re
|
|
|
*
|
|
|
* returns 0 if we may process the packet,
|
|
|
* -ERESTARTSYS if we were interrupted (by disconnect signal). */
|
|
|
-static int wait_for_and_update_peer_seq(struct drbd_conf *mdev, const u32 peer_seq)
|
|
|
+static int wait_for_and_update_peer_seq(struct drbd_peer_device *peer_device, const u32 peer_seq)
|
|
|
{
|
|
|
+ struct drbd_device *device = peer_device->device;
|
|
|
DEFINE_WAIT(wait);
|
|
|
long timeout;
|
|
|
int ret = 0, tp;
|
|
|
|
|
|
- if (!test_bit(RESOLVE_CONFLICTS, &mdev->tconn->flags))
|
|
|
+ if (!test_bit(RESOLVE_CONFLICTS, &peer_device->connection->flags))
|
|
|
return 0;
|
|
|
|
|
|
- spin_lock(&mdev->peer_seq_lock);
|
|
|
+ spin_lock(&device->peer_seq_lock);
|
|
|
for (;;) {
|
|
|
- if (!seq_greater(peer_seq - 1, mdev->peer_seq)) {
|
|
|
- mdev->peer_seq = seq_max(mdev->peer_seq, peer_seq);
|
|
|
+ if (!seq_greater(peer_seq - 1, device->peer_seq)) {
|
|
|
+ device->peer_seq = seq_max(device->peer_seq, peer_seq);
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
@@ -1973,35 +2001,35 @@ static int wait_for_and_update_peer_seq(struct drbd_conf *mdev, const u32 peer_s
|
|
|
}
|
|
|
|
|
|
rcu_read_lock();
|
|
|
- tp = rcu_dereference(mdev->tconn->net_conf)->two_primaries;
|
|
|
+ tp = rcu_dereference(first_peer_device(device)->connection->net_conf)->two_primaries;
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
if (!tp)
|
|
|
break;
|
|
|
|
|
|
/* Only need to wait if two_primaries is enabled */
|
|
|
- prepare_to_wait(&mdev->seq_wait, &wait, TASK_INTERRUPTIBLE);
|
|
|
- spin_unlock(&mdev->peer_seq_lock);
|
|
|
+ prepare_to_wait(&device->seq_wait, &wait, TASK_INTERRUPTIBLE);
|
|
|
+ spin_unlock(&device->peer_seq_lock);
|
|
|
rcu_read_lock();
|
|
|
- timeout = rcu_dereference(mdev->tconn->net_conf)->ping_timeo*HZ/10;
|
|
|
+ timeout = rcu_dereference(peer_device->connection->net_conf)->ping_timeo*HZ/10;
|
|
|
rcu_read_unlock();
|
|
|
timeout = schedule_timeout(timeout);
|
|
|
- spin_lock(&mdev->peer_seq_lock);
|
|
|
+ spin_lock(&device->peer_seq_lock);
|
|
|
if (!timeout) {
|
|
|
ret = -ETIMEDOUT;
|
|
|
- dev_err(DEV, "Timed out waiting for missing ack packets; disconnecting\n");
|
|
|
+ drbd_err(device, "Timed out waiting for missing ack packets; disconnecting\n");
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- spin_unlock(&mdev->peer_seq_lock);
|
|
|
- finish_wait(&mdev->seq_wait, &wait);
|
|
|
+ spin_unlock(&device->peer_seq_lock);
|
|
|
+ finish_wait(&device->seq_wait, &wait);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
/* 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_conf *mdev, 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) |
|
|
|
@@ -2009,13 +2037,13 @@ static unsigned long wire_flags_to_bio(struct drbd_conf *mdev, u32 dpf)
|
|
|
(dpf & DP_DISCARD ? REQ_DISCARD : 0);
|
|
|
}
|
|
|
|
|
|
-static void fail_postponed_requests(struct drbd_conf *mdev, sector_t sector,
|
|
|
+static void fail_postponed_requests(struct drbd_device *device, sector_t sector,
|
|
|
unsigned int size)
|
|
|
{
|
|
|
struct drbd_interval *i;
|
|
|
|
|
|
repeat:
|
|
|
- drbd_for_each_overlap(i, &mdev->write_requests, sector, size) {
|
|
|
+ drbd_for_each_overlap(i, &device->write_requests, sector, size) {
|
|
|
struct drbd_request *req;
|
|
|
struct bio_and_error m;
|
|
|
|
|
|
@@ -2026,19 +2054,19 @@ static void fail_postponed_requests(struct drbd_conf *mdev, sector_t sector,
|
|
|
continue;
|
|
|
req->rq_state &= ~RQ_POSTPONED;
|
|
|
__req_mod(req, NEG_ACKED, &m);
|
|
|
- spin_unlock_irq(&mdev->tconn->req_lock);
|
|
|
+ spin_unlock_irq(&device->resource->req_lock);
|
|
|
if (m.bio)
|
|
|
- complete_master_bio(mdev, &m);
|
|
|
- spin_lock_irq(&mdev->tconn->req_lock);
|
|
|
+ complete_master_bio(device, &m);
|
|
|
+ spin_lock_irq(&device->resource->req_lock);
|
|
|
goto repeat;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static int handle_write_conflicts(struct drbd_conf *mdev,
|
|
|
+static int handle_write_conflicts(struct drbd_device *device,
|
|
|
struct drbd_peer_request *peer_req)
|
|
|
{
|
|
|
- struct drbd_tconn *tconn = mdev->tconn;
|
|
|
- bool resolve_conflicts = test_bit(RESOLVE_CONFLICTS, &tconn->flags);
|
|
|
+ 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;
|
|
|
struct drbd_interval *i;
|
|
|
@@ -2049,10 +2077,10 @@ static int handle_write_conflicts(struct drbd_conf *mdev,
|
|
|
* Inserting the peer request into the write_requests tree will prevent
|
|
|
* new conflicting local requests from being added.
|
|
|
*/
|
|
|
- drbd_insert_interval(&mdev->write_requests, &peer_req->i);
|
|
|
+ drbd_insert_interval(&device->write_requests, &peer_req->i);
|
|
|
|
|
|
repeat:
|
|
|
- drbd_for_each_overlap(i, &mdev->write_requests, sector, size) {
|
|
|
+ drbd_for_each_overlap(i, &device->write_requests, sector, size) {
|
|
|
if (i == &peer_req->i)
|
|
|
continue;
|
|
|
|
|
|
@@ -2062,7 +2090,7 @@ static int handle_write_conflicts(struct drbd_conf *mdev,
|
|
|
* should not happen in a two-node setup. Wait for the
|
|
|
* earlier peer request to complete.
|
|
|
*/
|
|
|
- err = drbd_wait_misc(mdev, i);
|
|
|
+ err = drbd_wait_misc(device, i);
|
|
|
if (err)
|
|
|
goto out;
|
|
|
goto repeat;
|
|
|
@@ -2080,18 +2108,18 @@ static int handle_write_conflicts(struct drbd_conf *mdev,
|
|
|
(i->size >> 9) >= sector + (size >> 9);
|
|
|
|
|
|
if (!equal)
|
|
|
- dev_alert(DEV, "Concurrent writes detected: "
|
|
|
+ drbd_alert(device, "Concurrent writes detected: "
|
|
|
"local=%llus +%u, remote=%llus +%u, "
|
|
|
"assuming %s came first\n",
|
|
|
(unsigned long long)i->sector, i->size,
|
|
|
(unsigned long long)sector, size,
|
|
|
superseded ? "local" : "remote");
|
|
|
|
|
|
- inc_unacked(mdev);
|
|
|
+ inc_unacked(device);
|
|
|
peer_req->w.cb = superseded ? e_send_superseded :
|
|
|
e_send_retry_write;
|
|
|
- list_add_tail(&peer_req->w.list, &mdev->done_ee);
|
|
|
- wake_asender(mdev->tconn);
|
|
|
+ list_add_tail(&peer_req->w.list, &device->done_ee);
|
|
|
+ wake_asender(connection);
|
|
|
|
|
|
err = -ENOENT;
|
|
|
goto out;
|
|
|
@@ -2100,7 +2128,7 @@ static int handle_write_conflicts(struct drbd_conf *mdev,
|
|
|
container_of(i, struct drbd_request, i);
|
|
|
|
|
|
if (!equal)
|
|
|
- dev_alert(DEV, "Concurrent writes detected: "
|
|
|
+ drbd_alert(device, "Concurrent writes detected: "
|
|
|
"local=%llus +%u, remote=%llus +%u\n",
|
|
|
(unsigned long long)i->sector, i->size,
|
|
|
(unsigned long long)sector, size);
|
|
|
@@ -2118,12 +2146,10 @@ static int handle_write_conflicts(struct drbd_conf *mdev,
|
|
|
* request to finish locally before submitting
|
|
|
* the conflicting peer request.
|
|
|
*/
|
|
|
- err = drbd_wait_misc(mdev, &req->i);
|
|
|
+ err = drbd_wait_misc(device, &req->i);
|
|
|
if (err) {
|
|
|
- _conn_request_state(mdev->tconn,
|
|
|
- NS(conn, C_TIMEOUT),
|
|
|
- CS_HARD);
|
|
|
- fail_postponed_requests(mdev, sector, size);
|
|
|
+ _conn_request_state(connection, NS(conn, C_TIMEOUT), CS_HARD);
|
|
|
+ fail_postponed_requests(device, sector, size);
|
|
|
goto out;
|
|
|
}
|
|
|
goto repeat;
|
|
|
@@ -2139,14 +2165,15 @@ static int handle_write_conflicts(struct drbd_conf *mdev,
|
|
|
|
|
|
out:
|
|
|
if (err)
|
|
|
- drbd_remove_epoch_entry_interval(mdev, peer_req);
|
|
|
+ drbd_remove_epoch_entry_interval(device, peer_req);
|
|
|
return err;
|
|
|
}
|
|
|
|
|
|
/* mirrored write */
|
|
|
-static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int receive_Data(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
- struct drbd_conf *mdev;
|
|
|
+ struct drbd_peer_device *peer_device;
|
|
|
+ struct drbd_device *device;
|
|
|
sector_t sector;
|
|
|
struct drbd_peer_request *peer_req;
|
|
|
struct p_data *p = pi->data;
|
|
|
@@ -2155,17 +2182,18 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
u32 dp_flags;
|
|
|
int err, tp;
|
|
|
|
|
|
- mdev = vnr_to_mdev(tconn, pi->vnr);
|
|
|
- if (!mdev)
|
|
|
+ peer_device = conn_peer_device(connection, pi->vnr);
|
|
|
+ if (!peer_device)
|
|
|
return -EIO;
|
|
|
+ device = peer_device->device;
|
|
|
|
|
|
- if (!get_ldev(mdev)) {
|
|
|
+ if (!get_ldev(device)) {
|
|
|
int err2;
|
|
|
|
|
|
- err = wait_for_and_update_peer_seq(mdev, peer_seq);
|
|
|
- drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
|
|
|
- atomic_inc(&tconn->current_epoch->epoch_size);
|
|
|
- err2 = drbd_drain_block(mdev, pi->size);
|
|
|
+ err = wait_for_and_update_peer_seq(peer_device, peer_seq);
|
|
|
+ drbd_send_ack_dp(peer_device, P_NEG_ACK, p, pi->size);
|
|
|
+ atomic_inc(&connection->current_epoch->epoch_size);
|
|
|
+ err2 = drbd_drain_block(peer_device, pi->size);
|
|
|
if (!err)
|
|
|
err = err2;
|
|
|
return err;
|
|
|
@@ -2178,61 +2206,61 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
*/
|
|
|
|
|
|
sector = be64_to_cpu(p->sector);
|
|
|
- peer_req = read_in_block(mdev, p->block_id, sector, pi->size);
|
|
|
+ peer_req = read_in_block(peer_device, p->block_id, sector, pi->size);
|
|
|
if (!peer_req) {
|
|
|
- put_ldev(mdev);
|
|
|
+ put_ldev(device);
|
|
|
return -EIO;
|
|
|
}
|
|
|
|
|
|
peer_req->w.cb = e_end_block;
|
|
|
|
|
|
dp_flags = be32_to_cpu(p->dp_flags);
|
|
|
- rw |= wire_flags_to_bio(mdev, dp_flags);
|
|
|
+ rw |= wire_flags_to_bio(dp_flags);
|
|
|
if (peer_req->pages == NULL) {
|
|
|
- D_ASSERT(peer_req->i.size == 0);
|
|
|
- D_ASSERT(dp_flags & DP_FLUSH);
|
|
|
+ D_ASSERT(device, peer_req->i.size == 0);
|
|
|
+ D_ASSERT(device, dp_flags & DP_FLUSH);
|
|
|
}
|
|
|
|
|
|
if (dp_flags & DP_MAY_SET_IN_SYNC)
|
|
|
peer_req->flags |= EE_MAY_SET_IN_SYNC;
|
|
|
|
|
|
- spin_lock(&tconn->epoch_lock);
|
|
|
- peer_req->epoch = tconn->current_epoch;
|
|
|
+ spin_lock(&connection->epoch_lock);
|
|
|
+ peer_req->epoch = connection->current_epoch;
|
|
|
atomic_inc(&peer_req->epoch->epoch_size);
|
|
|
atomic_inc(&peer_req->epoch->active);
|
|
|
- spin_unlock(&tconn->epoch_lock);
|
|
|
+ spin_unlock(&connection->epoch_lock);
|
|
|
|
|
|
rcu_read_lock();
|
|
|
- tp = rcu_dereference(mdev->tconn->net_conf)->two_primaries;
|
|
|
+ tp = rcu_dereference(peer_device->connection->net_conf)->two_primaries;
|
|
|
rcu_read_unlock();
|
|
|
if (tp) {
|
|
|
peer_req->flags |= EE_IN_INTERVAL_TREE;
|
|
|
- err = wait_for_and_update_peer_seq(mdev, peer_seq);
|
|
|
+ err = wait_for_and_update_peer_seq(peer_device, peer_seq);
|
|
|
if (err)
|
|
|
goto out_interrupted;
|
|
|
- spin_lock_irq(&mdev->tconn->req_lock);
|
|
|
- err = handle_write_conflicts(mdev, peer_req);
|
|
|
+ spin_lock_irq(&device->resource->req_lock);
|
|
|
+ err = handle_write_conflicts(device, peer_req);
|
|
|
if (err) {
|
|
|
- spin_unlock_irq(&mdev->tconn->req_lock);
|
|
|
+ spin_unlock_irq(&device->resource->req_lock);
|
|
|
if (err == -ENOENT) {
|
|
|
- put_ldev(mdev);
|
|
|
+ put_ldev(device);
|
|
|
return 0;
|
|
|
}
|
|
|
goto out_interrupted;
|
|
|
}
|
|
|
} else {
|
|
|
- update_peer_seq(mdev, peer_seq);
|
|
|
- spin_lock_irq(&mdev->tconn->req_lock);
|
|
|
+ update_peer_seq(peer_device, peer_seq);
|
|
|
+ spin_lock_irq(&device->resource->req_lock);
|
|
|
}
|
|
|
- list_add(&peer_req->w.list, &mdev->active_ee);
|
|
|
- spin_unlock_irq(&mdev->tconn->req_lock);
|
|
|
+ list_add(&peer_req->w.list, &device->active_ee);
|
|
|
+ spin_unlock_irq(&device->resource->req_lock);
|
|
|
|
|
|
- if (mdev->state.conn == C_SYNC_TARGET)
|
|
|
- wait_event(mdev->ee_wait, !overlapping_resync_write(mdev, peer_req));
|
|
|
+ if (device->state.conn == C_SYNC_TARGET)
|
|
|
+ wait_event(device->ee_wait, !overlapping_resync_write(device, peer_req));
|
|
|
|
|
|
- if (mdev->tconn->agreed_pro_version < 100) {
|
|
|
+ if (peer_device->connection->agreed_pro_version < 100) {
|
|
|
rcu_read_lock();
|
|
|
- switch (rcu_dereference(mdev->tconn->net_conf)->wire_protocol) {
|
|
|
+ switch (rcu_dereference(peer_device->connection->net_conf)->wire_protocol) {
|
|
|
case DRBD_PROT_C:
|
|
|
dp_flags |= DP_SEND_WRITE_ACK;
|
|
|
break;
|
|
|
@@ -2245,7 +2273,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
|
|
|
if (dp_flags & DP_SEND_WRITE_ACK) {
|
|
|
peer_req->flags |= EE_SEND_WRITE_ACK;
|
|
|
- inc_unacked(mdev);
|
|
|
+ inc_unacked(device);
|
|
|
/* corresponding dec_unacked() in e_end_block()
|
|
|
* respective _drbd_clear_done_ee */
|
|
|
}
|
|
|
@@ -2253,34 +2281,34 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
if (dp_flags & DP_SEND_RECEIVE_ACK) {
|
|
|
/* I really don't like it that the receiver thread
|
|
|
* sends on the msock, but anyways */
|
|
|
- drbd_send_ack(mdev, P_RECV_ACK, peer_req);
|
|
|
+ drbd_send_ack(first_peer_device(device), P_RECV_ACK, peer_req);
|
|
|
}
|
|
|
|
|
|
- if (mdev->state.pdsk < D_INCONSISTENT) {
|
|
|
+ if (device->state.pdsk < D_INCONSISTENT) {
|
|
|
/* In case we have the only disk of the cluster, */
|
|
|
- drbd_set_out_of_sync(mdev, peer_req->i.sector, peer_req->i.size);
|
|
|
+ drbd_set_out_of_sync(device, peer_req->i.sector, peer_req->i.size);
|
|
|
peer_req->flags |= EE_CALL_AL_COMPLETE_IO;
|
|
|
peer_req->flags &= ~EE_MAY_SET_IN_SYNC;
|
|
|
- drbd_al_begin_io(mdev, &peer_req->i, true);
|
|
|
+ drbd_al_begin_io(device, &peer_req->i, true);
|
|
|
}
|
|
|
|
|
|
- err = drbd_submit_peer_request(mdev, peer_req, rw, DRBD_FAULT_DT_WR);
|
|
|
+ err = drbd_submit_peer_request(device, peer_req, rw, DRBD_FAULT_DT_WR);
|
|
|
if (!err)
|
|
|
return 0;
|
|
|
|
|
|
/* don't care for the reason here */
|
|
|
- dev_err(DEV, "submit failed, triggering re-connect\n");
|
|
|
- spin_lock_irq(&mdev->tconn->req_lock);
|
|
|
+ drbd_err(device, "submit failed, triggering re-connect\n");
|
|
|
+ spin_lock_irq(&device->resource->req_lock);
|
|
|
list_del(&peer_req->w.list);
|
|
|
- drbd_remove_epoch_entry_interval(mdev, peer_req);
|
|
|
- spin_unlock_irq(&mdev->tconn->req_lock);
|
|
|
+ drbd_remove_epoch_entry_interval(device, peer_req);
|
|
|
+ spin_unlock_irq(&device->resource->req_lock);
|
|
|
if (peer_req->flags & EE_CALL_AL_COMPLETE_IO)
|
|
|
- drbd_al_complete_io(mdev, &peer_req->i);
|
|
|
+ drbd_al_complete_io(device, &peer_req->i);
|
|
|
|
|
|
out_interrupted:
|
|
|
- drbd_may_finish_epoch(tconn, peer_req->epoch, EV_PUT + EV_CLEANUP);
|
|
|
- put_ldev(mdev);
|
|
|
- drbd_free_peer_req(mdev, peer_req);
|
|
|
+ drbd_may_finish_epoch(connection, peer_req->epoch, EV_PUT + EV_CLEANUP);
|
|
|
+ put_ldev(device);
|
|
|
+ drbd_free_peer_req(device, peer_req);
|
|
|
return err;
|
|
|
}
|
|
|
|
|
|
@@ -2295,9 +2323,9 @@ out_interrupted:
|
|
|
* The current sync rate used here uses only the most recent two step marks,
|
|
|
* to have a short time average so we can react faster.
|
|
|
*/
|
|
|
-int drbd_rs_should_slow_down(struct drbd_conf *mdev, sector_t sector)
|
|
|
+int drbd_rs_should_slow_down(struct drbd_device *device, sector_t sector)
|
|
|
{
|
|
|
- struct gendisk *disk = mdev->ldev->backing_bdev->bd_contains->bd_disk;
|
|
|
+ struct gendisk *disk = device->ldev->backing_bdev->bd_contains->bd_disk;
|
|
|
unsigned long db, dt, dbdt;
|
|
|
struct lc_element *tmp;
|
|
|
int curr_events;
|
|
|
@@ -2305,48 +2333,48 @@ int drbd_rs_should_slow_down(struct drbd_conf *mdev, sector_t sector)
|
|
|
unsigned int c_min_rate;
|
|
|
|
|
|
rcu_read_lock();
|
|
|
- c_min_rate = rcu_dereference(mdev->ldev->disk_conf)->c_min_rate;
|
|
|
+ c_min_rate = rcu_dereference(device->ldev->disk_conf)->c_min_rate;
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
/* feature disabled? */
|
|
|
if (c_min_rate == 0)
|
|
|
return 0;
|
|
|
|
|
|
- spin_lock_irq(&mdev->al_lock);
|
|
|
- tmp = lc_find(mdev->resync, BM_SECT_TO_EXT(sector));
|
|
|
+ spin_lock_irq(&device->al_lock);
|
|
|
+ tmp = lc_find(device->resync, BM_SECT_TO_EXT(sector));
|
|
|
if (tmp) {
|
|
|
struct bm_extent *bm_ext = lc_entry(tmp, struct bm_extent, lce);
|
|
|
if (test_bit(BME_PRIORITY, &bm_ext->flags)) {
|
|
|
- spin_unlock_irq(&mdev->al_lock);
|
|
|
+ spin_unlock_irq(&device->al_lock);
|
|
|
return 0;
|
|
|
}
|
|
|
/* Do not slow down if app IO is already waiting for this extent */
|
|
|
}
|
|
|
- spin_unlock_irq(&mdev->al_lock);
|
|
|
+ spin_unlock_irq(&device->al_lock);
|
|
|
|
|
|
curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
|
|
|
(int)part_stat_read(&disk->part0, sectors[1]) -
|
|
|
- atomic_read(&mdev->rs_sect_ev);
|
|
|
+ atomic_read(&device->rs_sect_ev);
|
|
|
|
|
|
- if (!mdev->rs_last_events || curr_events - mdev->rs_last_events > 64) {
|
|
|
+ if (!device->rs_last_events || curr_events - device->rs_last_events > 64) {
|
|
|
unsigned long rs_left;
|
|
|
int i;
|
|
|
|
|
|
- mdev->rs_last_events = curr_events;
|
|
|
+ device->rs_last_events = curr_events;
|
|
|
|
|
|
/* sync speed average over the last 2*DRBD_SYNC_MARK_STEP,
|
|
|
* approx. */
|
|
|
- i = (mdev->rs_last_mark + DRBD_SYNC_MARKS-1) % DRBD_SYNC_MARKS;
|
|
|
+ i = (device->rs_last_mark + DRBD_SYNC_MARKS-1) % DRBD_SYNC_MARKS;
|
|
|
|
|
|
- if (mdev->state.conn == C_VERIFY_S || mdev->state.conn == C_VERIFY_T)
|
|
|
- rs_left = mdev->ov_left;
|
|
|
+ if (device->state.conn == C_VERIFY_S || device->state.conn == C_VERIFY_T)
|
|
|
+ rs_left = device->ov_left;
|
|
|
else
|
|
|
- rs_left = drbd_bm_total_weight(mdev) - mdev->rs_failed;
|
|
|
+ rs_left = drbd_bm_total_weight(device) - device->rs_failed;
|
|
|
|
|
|
- dt = ((long)jiffies - (long)mdev->rs_mark_time[i]) / HZ;
|
|
|
+ dt = ((long)jiffies - (long)device->rs_mark_time[i]) / HZ;
|
|
|
if (!dt)
|
|
|
dt++;
|
|
|
- db = mdev->rs_mark_left[i] - rs_left;
|
|
|
+ db = device->rs_mark_left[i] - rs_left;
|
|
|
dbdt = Bit2KB(db/dt);
|
|
|
|
|
|
if (dbdt > c_min_rate)
|
|
|
@@ -2356,9 +2384,10 @@ int drbd_rs_should_slow_down(struct drbd_conf *mdev, sector_t sector)
|
|
|
}
|
|
|
|
|
|
|
|
|
-static int receive_DataRequest(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int receive_DataRequest(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
- struct drbd_conf *mdev;
|
|
|
+ struct drbd_peer_device *peer_device;
|
|
|
+ struct drbd_device *device;
|
|
|
sector_t sector;
|
|
|
sector_t capacity;
|
|
|
struct drbd_peer_request *peer_req;
|
|
|
@@ -2367,58 +2396,59 @@ static int receive_DataRequest(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
unsigned int fault_type;
|
|
|
struct p_block_req *p = pi->data;
|
|
|
|
|
|
- mdev = vnr_to_mdev(tconn, pi->vnr);
|
|
|
- if (!mdev)
|
|
|
+ peer_device = conn_peer_device(connection, pi->vnr);
|
|
|
+ if (!peer_device)
|
|
|
return -EIO;
|
|
|
- capacity = drbd_get_capacity(mdev->this_bdev);
|
|
|
+ device = peer_device->device;
|
|
|
+ capacity = drbd_get_capacity(device->this_bdev);
|
|
|
|
|
|
sector = be64_to_cpu(p->sector);
|
|
|
size = be32_to_cpu(p->blksize);
|
|
|
|
|
|
if (size <= 0 || !IS_ALIGNED(size, 512) || size > DRBD_MAX_BIO_SIZE) {
|
|
|
- dev_err(DEV, "%s:%d: sector: %llus, size: %u\n", __FILE__, __LINE__,
|
|
|
+ drbd_err(device, "%s:%d: sector: %llus, size: %u\n", __FILE__, __LINE__,
|
|
|
(unsigned long long)sector, size);
|
|
|
return -EINVAL;
|
|
|
}
|
|
|
if (sector + (size>>9) > capacity) {
|
|
|
- dev_err(DEV, "%s:%d: sector: %llus, size: %u\n", __FILE__, __LINE__,
|
|
|
+ drbd_err(device, "%s:%d: sector: %llus, size: %u\n", __FILE__, __LINE__,
|
|
|
(unsigned long long)sector, size);
|
|
|
return -EINVAL;
|
|
|
}
|
|
|
|
|
|
- if (!get_ldev_if_state(mdev, D_UP_TO_DATE)) {
|
|
|
+ if (!get_ldev_if_state(device, D_UP_TO_DATE)) {
|
|
|
verb = 1;
|
|
|
switch (pi->cmd) {
|
|
|
case P_DATA_REQUEST:
|
|
|
- drbd_send_ack_rp(mdev, P_NEG_DREPLY, p);
|
|
|
+ drbd_send_ack_rp(peer_device, P_NEG_DREPLY, p);
|
|
|
break;
|
|
|
case P_RS_DATA_REQUEST:
|
|
|
case P_CSUM_RS_REQUEST:
|
|
|
case P_OV_REQUEST:
|
|
|
- drbd_send_ack_rp(mdev, P_NEG_RS_DREPLY , p);
|
|
|
+ drbd_send_ack_rp(peer_device, P_NEG_RS_DREPLY , p);
|
|
|
break;
|
|
|
case P_OV_REPLY:
|
|
|
verb = 0;
|
|
|
- dec_rs_pending(mdev);
|
|
|
- drbd_send_ack_ex(mdev, P_OV_RESULT, sector, size, ID_IN_SYNC);
|
|
|
+ dec_rs_pending(device);
|
|
|
+ drbd_send_ack_ex(peer_device, P_OV_RESULT, sector, size, ID_IN_SYNC);
|
|
|
break;
|
|
|
default:
|
|
|
BUG();
|
|
|
}
|
|
|
if (verb && __ratelimit(&drbd_ratelimit_state))
|
|
|
- dev_err(DEV, "Can not satisfy peer's read request, "
|
|
|
+ drbd_err(device, "Can not satisfy peer's read request, "
|
|
|
"no local data.\n");
|
|
|
|
|
|
/* drain possibly payload */
|
|
|
- return drbd_drain_block(mdev, pi->size);
|
|
|
+ return drbd_drain_block(peer_device, pi->size);
|
|
|
}
|
|
|
|
|
|
/* GFP_NOIO, because we must not cause arbitrary write-out: in a DRBD
|
|
|
* "criss-cross" setup, that might cause write-out on some other DRBD,
|
|
|
* which in turn might block on the other node at this very place. */
|
|
|
- peer_req = drbd_alloc_peer_req(mdev, p->block_id, sector, size, GFP_NOIO);
|
|
|
+ peer_req = drbd_alloc_peer_req(peer_device, p->block_id, sector, size, GFP_NOIO);
|
|
|
if (!peer_req) {
|
|
|
- put_ldev(mdev);
|
|
|
+ put_ldev(device);
|
|
|
return -ENOMEM;
|
|
|
}
|
|
|
|
|
|
@@ -2433,7 +2463,7 @@ static int receive_DataRequest(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
peer_req->w.cb = w_e_end_rsdata_req;
|
|
|
fault_type = DRBD_FAULT_RS_RD;
|
|
|
/* used in the sector offset progress display */
|
|
|
- mdev->bm_resync_fo = BM_SECT_TO_BIT(sector);
|
|
|
+ device->bm_resync_fo = BM_SECT_TO_BIT(sector);
|
|
|
break;
|
|
|
|
|
|
case P_OV_REPLY:
|
|
|
@@ -2449,19 +2479,19 @@ static int receive_DataRequest(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
peer_req->digest = di;
|
|
|
peer_req->flags |= EE_HAS_DIGEST;
|
|
|
|
|
|
- if (drbd_recv_all(mdev->tconn, di->digest, pi->size))
|
|
|
+ if (drbd_recv_all(peer_device->connection, di->digest, pi->size))
|
|
|
goto out_free_e;
|
|
|
|
|
|
if (pi->cmd == P_CSUM_RS_REQUEST) {
|
|
|
- D_ASSERT(mdev->tconn->agreed_pro_version >= 89);
|
|
|
+ D_ASSERT(device, peer_device->connection->agreed_pro_version >= 89);
|
|
|
peer_req->w.cb = w_e_end_csum_rs_req;
|
|
|
/* used in the sector offset progress display */
|
|
|
- mdev->bm_resync_fo = BM_SECT_TO_BIT(sector);
|
|
|
+ device->bm_resync_fo = BM_SECT_TO_BIT(sector);
|
|
|
} else if (pi->cmd == P_OV_REPLY) {
|
|
|
/* track progress, we may need to throttle */
|
|
|
- atomic_add(size >> 9, &mdev->rs_sect_in);
|
|
|
+ atomic_add(size >> 9, &device->rs_sect_in);
|
|
|
peer_req->w.cb = w_e_end_ov_reply;
|
|
|
- dec_rs_pending(mdev);
|
|
|
+ dec_rs_pending(device);
|
|
|
/* drbd_rs_begin_io done when we sent this request,
|
|
|
* but accounting still needs to be done. */
|
|
|
goto submit_for_resync;
|
|
|
@@ -2469,19 +2499,19 @@ static int receive_DataRequest(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
break;
|
|
|
|
|
|
case P_OV_REQUEST:
|
|
|
- if (mdev->ov_start_sector == ~(sector_t)0 &&
|
|
|
- mdev->tconn->agreed_pro_version >= 90) {
|
|
|
+ if (device->ov_start_sector == ~(sector_t)0 &&
|
|
|
+ peer_device->connection->agreed_pro_version >= 90) {
|
|
|
unsigned long now = jiffies;
|
|
|
int i;
|
|
|
- mdev->ov_start_sector = sector;
|
|
|
- mdev->ov_position = sector;
|
|
|
- mdev->ov_left = drbd_bm_bits(mdev) - BM_SECT_TO_BIT(sector);
|
|
|
- mdev->rs_total = mdev->ov_left;
|
|
|
+ device->ov_start_sector = sector;
|
|
|
+ device->ov_position = sector;
|
|
|
+ device->ov_left = drbd_bm_bits(device) - BM_SECT_TO_BIT(sector);
|
|
|
+ device->rs_total = device->ov_left;
|
|
|
for (i = 0; i < DRBD_SYNC_MARKS; i++) {
|
|
|
- mdev->rs_mark_left[i] = mdev->ov_left;
|
|
|
- mdev->rs_mark_time[i] = now;
|
|
|
+ device->rs_mark_left[i] = device->ov_left;
|
|
|
+ device->rs_mark_time[i] = now;
|
|
|
}
|
|
|
- dev_info(DEV, "Online Verify start sector: %llu\n",
|
|
|
+ drbd_info(device, "Online Verify start sector: %llu\n",
|
|
|
(unsigned long long)sector);
|
|
|
}
|
|
|
peer_req->w.cb = w_e_end_ov_req;
|
|
|
@@ -2514,57 +2544,61 @@ static int receive_DataRequest(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
* we would also throttle its application reads.
|
|
|
* In that case, throttling is done on the SyncTarget only.
|
|
|
*/
|
|
|
- if (mdev->state.peer != R_PRIMARY && drbd_rs_should_slow_down(mdev, sector))
|
|
|
+ if (device->state.peer != R_PRIMARY && drbd_rs_should_slow_down(device, sector))
|
|
|
schedule_timeout_uninterruptible(HZ/10);
|
|
|
- if (drbd_rs_begin_io(mdev, sector))
|
|
|
+ if (drbd_rs_begin_io(device, sector))
|
|
|
goto out_free_e;
|
|
|
|
|
|
submit_for_resync:
|
|
|
- atomic_add(size >> 9, &mdev->rs_sect_ev);
|
|
|
+ atomic_add(size >> 9, &device->rs_sect_ev);
|
|
|
|
|
|
submit:
|
|
|
- inc_unacked(mdev);
|
|
|
- spin_lock_irq(&mdev->tconn->req_lock);
|
|
|
- list_add_tail(&peer_req->w.list, &mdev->read_ee);
|
|
|
- spin_unlock_irq(&mdev->tconn->req_lock);
|
|
|
+ inc_unacked(device);
|
|
|
+ spin_lock_irq(&device->resource->req_lock);
|
|
|
+ list_add_tail(&peer_req->w.list, &device->read_ee);
|
|
|
+ spin_unlock_irq(&device->resource->req_lock);
|
|
|
|
|
|
- if (drbd_submit_peer_request(mdev, peer_req, READ, fault_type) == 0)
|
|
|
+ if (drbd_submit_peer_request(device, peer_req, READ, fault_type) == 0)
|
|
|
return 0;
|
|
|
|
|
|
/* don't care for the reason here */
|
|
|
- dev_err(DEV, "submit failed, triggering re-connect\n");
|
|
|
- spin_lock_irq(&mdev->tconn->req_lock);
|
|
|
+ drbd_err(device, "submit failed, triggering re-connect\n");
|
|
|
+ spin_lock_irq(&device->resource->req_lock);
|
|
|
list_del(&peer_req->w.list);
|
|
|
- spin_unlock_irq(&mdev->tconn->req_lock);
|
|
|
+ spin_unlock_irq(&device->resource->req_lock);
|
|
|
/* no drbd_rs_complete_io(), we are dropping the connection anyways */
|
|
|
|
|
|
out_free_e:
|
|
|
- put_ldev(mdev);
|
|
|
- drbd_free_peer_req(mdev, peer_req);
|
|
|
+ put_ldev(device);
|
|
|
+ drbd_free_peer_req(device, peer_req);
|
|
|
return -EIO;
|
|
|
}
|
|
|
|
|
|
-static int drbd_asb_recover_0p(struct drbd_conf *mdev) __must_hold(local)
|
|
|
+/**
|
|
|
+ * drbd_asb_recover_0p - Recover after split-brain with no remaining primaries
|
|
|
+ */
|
|
|
+static int drbd_asb_recover_0p(struct drbd_peer_device *peer_device) __must_hold(local)
|
|
|
{
|
|
|
+ struct drbd_device *device = peer_device->device;
|
|
|
int self, peer, rv = -100;
|
|
|
unsigned long ch_self, ch_peer;
|
|
|
enum drbd_after_sb_p after_sb_0p;
|
|
|
|
|
|
- self = mdev->ldev->md.uuid[UI_BITMAP] & 1;
|
|
|
- peer = mdev->p_uuid[UI_BITMAP] & 1;
|
|
|
+ self = device->ldev->md.uuid[UI_BITMAP] & 1;
|
|
|
+ peer = device->p_uuid[UI_BITMAP] & 1;
|
|
|
|
|
|
- ch_peer = mdev->p_uuid[UI_SIZE];
|
|
|
- ch_self = mdev->comm_bm_set;
|
|
|
+ ch_peer = device->p_uuid[UI_SIZE];
|
|
|
+ ch_self = device->comm_bm_set;
|
|
|
|
|
|
rcu_read_lock();
|
|
|
- after_sb_0p = rcu_dereference(mdev->tconn->net_conf)->after_sb_0p;
|
|
|
+ after_sb_0p = rcu_dereference(peer_device->connection->net_conf)->after_sb_0p;
|
|
|
rcu_read_unlock();
|
|
|
switch (after_sb_0p) {
|
|
|
case ASB_CONSENSUS:
|
|
|
case ASB_DISCARD_SECONDARY:
|
|
|
case ASB_CALL_HELPER:
|
|
|
case ASB_VIOLENTLY:
|
|
|
- dev_err(DEV, "Configuration error.\n");
|
|
|
+ drbd_err(device, "Configuration error.\n");
|
|
|
break;
|
|
|
case ASB_DISCONNECT:
|
|
|
break;
|
|
|
@@ -2588,11 +2622,11 @@ static int drbd_asb_recover_0p(struct drbd_conf *mdev) __must_hold(local)
|
|
|
break;
|
|
|
}
|
|
|
/* Else fall through to one of the other strategies... */
|
|
|
- dev_warn(DEV, "Discard younger/older primary did not find a decision\n"
|
|
|
+ drbd_warn(device, "Discard younger/older primary did not find a decision\n"
|
|
|
"Using discard-least-changes instead\n");
|
|
|
case ASB_DISCARD_ZERO_CHG:
|
|
|
if (ch_peer == 0 && ch_self == 0) {
|
|
|
- rv = test_bit(RESOLVE_CONFLICTS, &mdev->tconn->flags)
|
|
|
+ rv = test_bit(RESOLVE_CONFLICTS, &peer_device->connection->flags)
|
|
|
? -1 : 1;
|
|
|
break;
|
|
|
} else {
|
|
|
@@ -2608,7 +2642,7 @@ static int drbd_asb_recover_0p(struct drbd_conf *mdev) __must_hold(local)
|
|
|
rv = 1;
|
|
|
else /* ( ch_self == ch_peer ) */
|
|
|
/* Well, then use something else. */
|
|
|
- rv = test_bit(RESOLVE_CONFLICTS, &mdev->tconn->flags)
|
|
|
+ rv = test_bit(RESOLVE_CONFLICTS, &peer_device->connection->flags)
|
|
|
? -1 : 1;
|
|
|
break;
|
|
|
case ASB_DISCARD_LOCAL:
|
|
|
@@ -2621,13 +2655,17 @@ static int drbd_asb_recover_0p(struct drbd_conf *mdev) __must_hold(local)
|
|
|
return rv;
|
|
|
}
|
|
|
|
|
|
-static int drbd_asb_recover_1p(struct drbd_conf *mdev) __must_hold(local)
|
|
|
+/**
|
|
|
+ * drbd_asb_recover_1p - Recover after split-brain with one remaining primary
|
|
|
+ */
|
|
|
+static int drbd_asb_recover_1p(struct drbd_peer_device *peer_device) __must_hold(local)
|
|
|
{
|
|
|
+ struct drbd_device *device = peer_device->device;
|
|
|
int hg, rv = -100;
|
|
|
enum drbd_after_sb_p after_sb_1p;
|
|
|
|
|
|
rcu_read_lock();
|
|
|
- after_sb_1p = rcu_dereference(mdev->tconn->net_conf)->after_sb_1p;
|
|
|
+ after_sb_1p = rcu_dereference(peer_device->connection->net_conf)->after_sb_1p;
|
|
|
rcu_read_unlock();
|
|
|
switch (after_sb_1p) {
|
|
|
case ASB_DISCARD_YOUNGER_PRI:
|
|
|
@@ -2636,35 +2674,35 @@ static int drbd_asb_recover_1p(struct drbd_conf *mdev) __must_hold(local)
|
|
|
case ASB_DISCARD_LOCAL:
|
|
|
case ASB_DISCARD_REMOTE:
|
|
|
case ASB_DISCARD_ZERO_CHG:
|
|
|
- dev_err(DEV, "Configuration error.\n");
|
|
|
+ drbd_err(device, "Configuration error.\n");
|
|
|
break;
|
|
|
case ASB_DISCONNECT:
|
|
|
break;
|
|
|
case ASB_CONSENSUS:
|
|
|
- hg = drbd_asb_recover_0p(mdev);
|
|
|
- if (hg == -1 && mdev->state.role == R_SECONDARY)
|
|
|
+ hg = drbd_asb_recover_0p(peer_device);
|
|
|
+ if (hg == -1 && device->state.role == R_SECONDARY)
|
|
|
rv = hg;
|
|
|
- if (hg == 1 && mdev->state.role == R_PRIMARY)
|
|
|
+ if (hg == 1 && device->state.role == R_PRIMARY)
|
|
|
rv = hg;
|
|
|
break;
|
|
|
case ASB_VIOLENTLY:
|
|
|
- rv = drbd_asb_recover_0p(mdev);
|
|
|
+ rv = drbd_asb_recover_0p(peer_device);
|
|
|
break;
|
|
|
case ASB_DISCARD_SECONDARY:
|
|
|
- return mdev->state.role == R_PRIMARY ? 1 : -1;
|
|
|
+ return device->state.role == R_PRIMARY ? 1 : -1;
|
|
|
case ASB_CALL_HELPER:
|
|
|
- hg = drbd_asb_recover_0p(mdev);
|
|
|
- if (hg == -1 && mdev->state.role == R_PRIMARY) {
|
|
|
+ hg = drbd_asb_recover_0p(peer_device);
|
|
|
+ if (hg == -1 && device->state.role == R_PRIMARY) {
|
|
|
enum drbd_state_rv rv2;
|
|
|
|
|
|
/* drbd_change_state() does not sleep while in SS_IN_TRANSIENT_STATE,
|
|
|
* we might be here in C_WF_REPORT_PARAMS which is transient.
|
|
|
* we do not need to wait for the after state change work either. */
|
|
|
- rv2 = drbd_change_state(mdev, CS_VERBOSE, NS(role, R_SECONDARY));
|
|
|
+ rv2 = drbd_change_state(device, CS_VERBOSE, NS(role, R_SECONDARY));
|
|
|
if (rv2 != SS_SUCCESS) {
|
|
|
- drbd_khelper(mdev, "pri-lost-after-sb");
|
|
|
+ drbd_khelper(device, "pri-lost-after-sb");
|
|
|
} else {
|
|
|
- dev_warn(DEV, "Successfully gave up primary role.\n");
|
|
|
+ drbd_warn(device, "Successfully gave up primary role.\n");
|
|
|
rv = hg;
|
|
|
}
|
|
|
} else
|
|
|
@@ -2674,13 +2712,17 @@ static int drbd_asb_recover_1p(struct drbd_conf *mdev) __must_hold(local)
|
|
|
return rv;
|
|
|
}
|
|
|
|
|
|
-static int drbd_asb_recover_2p(struct drbd_conf *mdev) __must_hold(local)
|
|
|
+/**
|
|
|
+ * drbd_asb_recover_2p - Recover after split-brain with two remaining primaries
|
|
|
+ */
|
|
|
+static int drbd_asb_recover_2p(struct drbd_peer_device *peer_device) __must_hold(local)
|
|
|
{
|
|
|
+ struct drbd_device *device = peer_device->device;
|
|
|
int hg, rv = -100;
|
|
|
enum drbd_after_sb_p after_sb_2p;
|
|
|
|
|
|
rcu_read_lock();
|
|
|
- after_sb_2p = rcu_dereference(mdev->tconn->net_conf)->after_sb_2p;
|
|
|
+ after_sb_2p = rcu_dereference(peer_device->connection->net_conf)->after_sb_2p;
|
|
|
rcu_read_unlock();
|
|
|
switch (after_sb_2p) {
|
|
|
case ASB_DISCARD_YOUNGER_PRI:
|
|
|
@@ -2691,26 +2733,26 @@ static int drbd_asb_recover_2p(struct drbd_conf *mdev) __must_hold(local)
|
|
|
case ASB_CONSENSUS:
|
|
|
case ASB_DISCARD_SECONDARY:
|
|
|
case ASB_DISCARD_ZERO_CHG:
|
|
|
- dev_err(DEV, "Configuration error.\n");
|
|
|
+ drbd_err(device, "Configuration error.\n");
|
|
|
break;
|
|
|
case ASB_VIOLENTLY:
|
|
|
- rv = drbd_asb_recover_0p(mdev);
|
|
|
+ rv = drbd_asb_recover_0p(peer_device);
|
|
|
break;
|
|
|
case ASB_DISCONNECT:
|
|
|
break;
|
|
|
case ASB_CALL_HELPER:
|
|
|
- hg = drbd_asb_recover_0p(mdev);
|
|
|
+ hg = drbd_asb_recover_0p(peer_device);
|
|
|
if (hg == -1) {
|
|
|
enum drbd_state_rv rv2;
|
|
|
|
|
|
/* drbd_change_state() does not sleep while in SS_IN_TRANSIENT_STATE,
|
|
|
* we might be here in C_WF_REPORT_PARAMS which is transient.
|
|
|
* we do not need to wait for the after state change work either. */
|
|
|
- rv2 = drbd_change_state(mdev, CS_VERBOSE, NS(role, R_SECONDARY));
|
|
|
+ rv2 = drbd_change_state(device, CS_VERBOSE, NS(role, R_SECONDARY));
|
|
|
if (rv2 != SS_SUCCESS) {
|
|
|
- drbd_khelper(mdev, "pri-lost-after-sb");
|
|
|
+ drbd_khelper(device, "pri-lost-after-sb");
|
|
|
} else {
|
|
|
- dev_warn(DEV, "Successfully gave up primary role.\n");
|
|
|
+ drbd_warn(device, "Successfully gave up primary role.\n");
|
|
|
rv = hg;
|
|
|
}
|
|
|
} else
|
|
|
@@ -2720,14 +2762,14 @@ static int drbd_asb_recover_2p(struct drbd_conf *mdev) __must_hold(local)
|
|
|
return rv;
|
|
|
}
|
|
|
|
|
|
-static void drbd_uuid_dump(struct drbd_conf *mdev, char *text, u64 *uuid,
|
|
|
+static void drbd_uuid_dump(struct drbd_device *device, char *text, u64 *uuid,
|
|
|
u64 bits, u64 flags)
|
|
|
{
|
|
|
if (!uuid) {
|
|
|
- dev_info(DEV, "%s uuid info vanished while I was looking!\n", text);
|
|
|
+ drbd_info(device, "%s uuid info vanished while I was looking!\n", text);
|
|
|
return;
|
|
|
}
|
|
|
- dev_info(DEV, "%s %016llX:%016llX:%016llX:%016llX bits:%llu flags:%llX\n",
|
|
|
+ drbd_info(device, "%s %016llX:%016llX:%016llX:%016llX bits:%llu flags:%llX\n",
|
|
|
text,
|
|
|
(unsigned long long)uuid[UI_CURRENT],
|
|
|
(unsigned long long)uuid[UI_BITMAP],
|
|
|
@@ -2749,13 +2791,13 @@ static void drbd_uuid_dump(struct drbd_conf *mdev, char *text, u64 *uuid,
|
|
|
-1091 requires proto 91
|
|
|
-1096 requires proto 96
|
|
|
*/
|
|
|
-static int drbd_uuid_compare(struct drbd_conf *mdev, int *rule_nr) __must_hold(local)
|
|
|
+static int drbd_uuid_compare(struct drbd_device *device, int *rule_nr) __must_hold(local)
|
|
|
{
|
|
|
u64 self, peer;
|
|
|
int i, j;
|
|
|
|
|
|
- self = mdev->ldev->md.uuid[UI_CURRENT] & ~((u64)1);
|
|
|
- peer = mdev->p_uuid[UI_CURRENT] & ~((u64)1);
|
|
|
+ self = device->ldev->md.uuid[UI_CURRENT] & ~((u64)1);
|
|
|
+ peer = device->p_uuid[UI_CURRENT] & ~((u64)1);
|
|
|
|
|
|
*rule_nr = 10;
|
|
|
if (self == UUID_JUST_CREATED && peer == UUID_JUST_CREATED)
|
|
|
@@ -2774,46 +2816,46 @@ static int drbd_uuid_compare(struct drbd_conf *mdev, int *rule_nr) __must_hold(l
|
|
|
if (self == peer) {
|
|
|
int rct, dc; /* roles at crash time */
|
|
|
|
|
|
- if (mdev->p_uuid[UI_BITMAP] == (u64)0 && mdev->ldev->md.uuid[UI_BITMAP] != (u64)0) {
|
|
|
+ if (device->p_uuid[UI_BITMAP] == (u64)0 && device->ldev->md.uuid[UI_BITMAP] != (u64)0) {
|
|
|
|
|
|
- if (mdev->tconn->agreed_pro_version < 91)
|
|
|
+ if (first_peer_device(device)->connection->agreed_pro_version < 91)
|
|
|
return -1091;
|
|
|
|
|
|
- if ((mdev->ldev->md.uuid[UI_BITMAP] & ~((u64)1)) == (mdev->p_uuid[UI_HISTORY_START] & ~((u64)1)) &&
|
|
|
- (mdev->ldev->md.uuid[UI_HISTORY_START] & ~((u64)1)) == (mdev->p_uuid[UI_HISTORY_START + 1] & ~((u64)1))) {
|
|
|
- dev_info(DEV, "was SyncSource, missed the resync finished event, corrected myself:\n");
|
|
|
- drbd_uuid_move_history(mdev);
|
|
|
- mdev->ldev->md.uuid[UI_HISTORY_START] = mdev->ldev->md.uuid[UI_BITMAP];
|
|
|
- mdev->ldev->md.uuid[UI_BITMAP] = 0;
|
|
|
+ if ((device->ldev->md.uuid[UI_BITMAP] & ~((u64)1)) == (device->p_uuid[UI_HISTORY_START] & ~((u64)1)) &&
|
|
|
+ (device->ldev->md.uuid[UI_HISTORY_START] & ~((u64)1)) == (device->p_uuid[UI_HISTORY_START + 1] & ~((u64)1))) {
|
|
|
+ drbd_info(device, "was SyncSource, missed the resync finished event, corrected myself:\n");
|
|
|
+ drbd_uuid_move_history(device);
|
|
|
+ device->ldev->md.uuid[UI_HISTORY_START] = device->ldev->md.uuid[UI_BITMAP];
|
|
|
+ device->ldev->md.uuid[UI_BITMAP] = 0;
|
|
|
|
|
|
- drbd_uuid_dump(mdev, "self", mdev->ldev->md.uuid,
|
|
|
- mdev->state.disk >= D_NEGOTIATING ? drbd_bm_total_weight(mdev) : 0, 0);
|
|
|
+ drbd_uuid_dump(device, "self", device->ldev->md.uuid,
|
|
|
+ device->state.disk >= D_NEGOTIATING ? drbd_bm_total_weight(device) : 0, 0);
|
|
|
*rule_nr = 34;
|
|
|
} else {
|
|
|
- dev_info(DEV, "was SyncSource (peer failed to write sync_uuid)\n");
|
|
|
+ drbd_info(device, "was SyncSource (peer failed to write sync_uuid)\n");
|
|
|
*rule_nr = 36;
|
|
|
}
|
|
|
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
- if (mdev->ldev->md.uuid[UI_BITMAP] == (u64)0 && mdev->p_uuid[UI_BITMAP] != (u64)0) {
|
|
|
+ if (device->ldev->md.uuid[UI_BITMAP] == (u64)0 && device->p_uuid[UI_BITMAP] != (u64)0) {
|
|
|
|
|
|
- if (mdev->tconn->agreed_pro_version < 91)
|
|
|
+ if (first_peer_device(device)->connection->agreed_pro_version < 91)
|
|
|
return -1091;
|
|
|
|
|
|
- if ((mdev->ldev->md.uuid[UI_HISTORY_START] & ~((u64)1)) == (mdev->p_uuid[UI_BITMAP] & ~((u64)1)) &&
|
|
|
- (mdev->ldev->md.uuid[UI_HISTORY_START + 1] & ~((u64)1)) == (mdev->p_uuid[UI_HISTORY_START] & ~((u64)1))) {
|
|
|
- dev_info(DEV, "was SyncTarget, peer missed the resync finished event, corrected peer:\n");
|
|
|
+ if ((device->ldev->md.uuid[UI_HISTORY_START] & ~((u64)1)) == (device->p_uuid[UI_BITMAP] & ~((u64)1)) &&
|
|
|
+ (device->ldev->md.uuid[UI_HISTORY_START + 1] & ~((u64)1)) == (device->p_uuid[UI_HISTORY_START] & ~((u64)1))) {
|
|
|
+ drbd_info(device, "was SyncTarget, peer missed the resync finished event, corrected peer:\n");
|
|
|
|
|
|
- mdev->p_uuid[UI_HISTORY_START + 1] = mdev->p_uuid[UI_HISTORY_START];
|
|
|
- mdev->p_uuid[UI_HISTORY_START] = mdev->p_uuid[UI_BITMAP];
|
|
|
- mdev->p_uuid[UI_BITMAP] = 0UL;
|
|
|
+ device->p_uuid[UI_HISTORY_START + 1] = device->p_uuid[UI_HISTORY_START];
|
|
|
+ device->p_uuid[UI_HISTORY_START] = device->p_uuid[UI_BITMAP];
|
|
|
+ device->p_uuid[UI_BITMAP] = 0UL;
|
|
|
|
|
|
- drbd_uuid_dump(mdev, "peer", mdev->p_uuid, mdev->p_uuid[UI_SIZE], mdev->p_uuid[UI_FLAGS]);
|
|
|
+ drbd_uuid_dump(device, "peer", device->p_uuid, device->p_uuid[UI_SIZE], device->p_uuid[UI_FLAGS]);
|
|
|
*rule_nr = 35;
|
|
|
} else {
|
|
|
- dev_info(DEV, "was SyncTarget (failed to write sync_uuid)\n");
|
|
|
+ drbd_info(device, "was SyncTarget (failed to write sync_uuid)\n");
|
|
|
*rule_nr = 37;
|
|
|
}
|
|
|
|
|
|
@@ -2821,8 +2863,8 @@ static int drbd_uuid_compare(struct drbd_conf *mdev, int *rule_nr) __must_hold(l
|
|
|
}
|
|
|
|
|
|
/* Common power [off|failure] */
|
|
|
- rct = (test_bit(CRASHED_PRIMARY, &mdev->flags) ? 1 : 0) +
|
|
|
- (mdev->p_uuid[UI_FLAGS] & 2);
|
|
|
+ rct = (test_bit(CRASHED_PRIMARY, &device->flags) ? 1 : 0) +
|
|
|
+ (device->p_uuid[UI_FLAGS] & 2);
|
|
|
/* lowest bit is set when we were primary,
|
|
|
* next bit (weight 2) is set when peer was primary */
|
|
|
*rule_nr = 40;
|
|
|
@@ -2832,72 +2874,72 @@ static int drbd_uuid_compare(struct drbd_conf *mdev, int *rule_nr) __must_hold(l
|
|
|
case 1: /* self_pri && !peer_pri */ return 1;
|
|
|
case 2: /* !self_pri && peer_pri */ return -1;
|
|
|
case 3: /* self_pri && peer_pri */
|
|
|
- dc = test_bit(RESOLVE_CONFLICTS, &mdev->tconn->flags);
|
|
|
+ dc = test_bit(RESOLVE_CONFLICTS, &first_peer_device(device)->connection->flags);
|
|
|
return dc ? -1 : 1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
*rule_nr = 50;
|
|
|
- peer = mdev->p_uuid[UI_BITMAP] & ~((u64)1);
|
|
|
+ peer = device->p_uuid[UI_BITMAP] & ~((u64)1);
|
|
|
if (self == peer)
|
|
|
return -1;
|
|
|
|
|
|
*rule_nr = 51;
|
|
|
- peer = mdev->p_uuid[UI_HISTORY_START] & ~((u64)1);
|
|
|
+ peer = device->p_uuid[UI_HISTORY_START] & ~((u64)1);
|
|
|
if (self == peer) {
|
|
|
- if (mdev->tconn->agreed_pro_version < 96 ?
|
|
|
- (mdev->ldev->md.uuid[UI_HISTORY_START] & ~((u64)1)) ==
|
|
|
- (mdev->p_uuid[UI_HISTORY_START + 1] & ~((u64)1)) :
|
|
|
- peer + UUID_NEW_BM_OFFSET == (mdev->p_uuid[UI_BITMAP] & ~((u64)1))) {
|
|
|
+ if (first_peer_device(device)->connection->agreed_pro_version < 96 ?
|
|
|
+ (device->ldev->md.uuid[UI_HISTORY_START] & ~((u64)1)) ==
|
|
|
+ (device->p_uuid[UI_HISTORY_START + 1] & ~((u64)1)) :
|
|
|
+ peer + UUID_NEW_BM_OFFSET == (device->p_uuid[UI_BITMAP] & ~((u64)1))) {
|
|
|
/* The last P_SYNC_UUID did not get though. Undo the last start of
|
|
|
resync as sync source modifications of the peer's UUIDs. */
|
|
|
|
|
|
- if (mdev->tconn->agreed_pro_version < 91)
|
|
|
+ if (first_peer_device(device)->connection->agreed_pro_version < 91)
|
|
|
return -1091;
|
|
|
|
|
|
- mdev->p_uuid[UI_BITMAP] = mdev->p_uuid[UI_HISTORY_START];
|
|
|
- mdev->p_uuid[UI_HISTORY_START] = mdev->p_uuid[UI_HISTORY_START + 1];
|
|
|
+ device->p_uuid[UI_BITMAP] = device->p_uuid[UI_HISTORY_START];
|
|
|
+ device->p_uuid[UI_HISTORY_START] = device->p_uuid[UI_HISTORY_START + 1];
|
|
|
|
|
|
- dev_info(DEV, "Lost last syncUUID packet, corrected:\n");
|
|
|
- drbd_uuid_dump(mdev, "peer", mdev->p_uuid, mdev->p_uuid[UI_SIZE], mdev->p_uuid[UI_FLAGS]);
|
|
|
+ drbd_info(device, "Lost last syncUUID packet, corrected:\n");
|
|
|
+ drbd_uuid_dump(device, "peer", device->p_uuid, device->p_uuid[UI_SIZE], device->p_uuid[UI_FLAGS]);
|
|
|
|
|
|
return -1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
*rule_nr = 60;
|
|
|
- self = mdev->ldev->md.uuid[UI_CURRENT] & ~((u64)1);
|
|
|
+ self = device->ldev->md.uuid[UI_CURRENT] & ~((u64)1);
|
|
|
for (i = UI_HISTORY_START; i <= UI_HISTORY_END; i++) {
|
|
|
- peer = mdev->p_uuid[i] & ~((u64)1);
|
|
|
+ peer = device->p_uuid[i] & ~((u64)1);
|
|
|
if (self == peer)
|
|
|
return -2;
|
|
|
}
|
|
|
|
|
|
*rule_nr = 70;
|
|
|
- self = mdev->ldev->md.uuid[UI_BITMAP] & ~((u64)1);
|
|
|
- peer = mdev->p_uuid[UI_CURRENT] & ~((u64)1);
|
|
|
+ self = device->ldev->md.uuid[UI_BITMAP] & ~((u64)1);
|
|
|
+ peer = device->p_uuid[UI_CURRENT] & ~((u64)1);
|
|
|
if (self == peer)
|
|
|
return 1;
|
|
|
|
|
|
*rule_nr = 71;
|
|
|
- self = mdev->ldev->md.uuid[UI_HISTORY_START] & ~((u64)1);
|
|
|
+ self = device->ldev->md.uuid[UI_HISTORY_START] & ~((u64)1);
|
|
|
if (self == peer) {
|
|
|
- if (mdev->tconn->agreed_pro_version < 96 ?
|
|
|
- (mdev->ldev->md.uuid[UI_HISTORY_START + 1] & ~((u64)1)) ==
|
|
|
- (mdev->p_uuid[UI_HISTORY_START] & ~((u64)1)) :
|
|
|
- self + UUID_NEW_BM_OFFSET == (mdev->ldev->md.uuid[UI_BITMAP] & ~((u64)1))) {
|
|
|
+ if (first_peer_device(device)->connection->agreed_pro_version < 96 ?
|
|
|
+ (device->ldev->md.uuid[UI_HISTORY_START + 1] & ~((u64)1)) ==
|
|
|
+ (device->p_uuid[UI_HISTORY_START] & ~((u64)1)) :
|
|
|
+ self + UUID_NEW_BM_OFFSET == (device->ldev->md.uuid[UI_BITMAP] & ~((u64)1))) {
|
|
|
/* The last P_SYNC_UUID did not get though. Undo the last start of
|
|
|
resync as sync source modifications of our UUIDs. */
|
|
|
|
|
|
- if (mdev->tconn->agreed_pro_version < 91)
|
|
|
+ if (first_peer_device(device)->connection->agreed_pro_version < 91)
|
|
|
return -1091;
|
|
|
|
|
|
- __drbd_uuid_set(mdev, UI_BITMAP, mdev->ldev->md.uuid[UI_HISTORY_START]);
|
|
|
- __drbd_uuid_set(mdev, UI_HISTORY_START, mdev->ldev->md.uuid[UI_HISTORY_START + 1]);
|
|
|
+ __drbd_uuid_set(device, UI_BITMAP, device->ldev->md.uuid[UI_HISTORY_START]);
|
|
|
+ __drbd_uuid_set(device, UI_HISTORY_START, device->ldev->md.uuid[UI_HISTORY_START + 1]);
|
|
|
|
|
|
- dev_info(DEV, "Last syncUUID did not get through, corrected:\n");
|
|
|
- drbd_uuid_dump(mdev, "self", mdev->ldev->md.uuid,
|
|
|
- mdev->state.disk >= D_NEGOTIATING ? drbd_bm_total_weight(mdev) : 0, 0);
|
|
|
+ drbd_info(device, "Last syncUUID did not get through, corrected:\n");
|
|
|
+ drbd_uuid_dump(device, "self", device->ldev->md.uuid,
|
|
|
+ device->state.disk >= D_NEGOTIATING ? drbd_bm_total_weight(device) : 0, 0);
|
|
|
|
|
|
return 1;
|
|
|
}
|
|
|
@@ -2905,24 +2947,24 @@ static int drbd_uuid_compare(struct drbd_conf *mdev, int *rule_nr) __must_hold(l
|
|
|
|
|
|
|
|
|
*rule_nr = 80;
|
|
|
- peer = mdev->p_uuid[UI_CURRENT] & ~((u64)1);
|
|
|
+ peer = device->p_uuid[UI_CURRENT] & ~((u64)1);
|
|
|
for (i = UI_HISTORY_START; i <= UI_HISTORY_END; i++) {
|
|
|
- self = mdev->ldev->md.uuid[i] & ~((u64)1);
|
|
|
+ self = device->ldev->md.uuid[i] & ~((u64)1);
|
|
|
if (self == peer)
|
|
|
return 2;
|
|
|
}
|
|
|
|
|
|
*rule_nr = 90;
|
|
|
- self = mdev->ldev->md.uuid[UI_BITMAP] & ~((u64)1);
|
|
|
- peer = mdev->p_uuid[UI_BITMAP] & ~((u64)1);
|
|
|
+ self = device->ldev->md.uuid[UI_BITMAP] & ~((u64)1);
|
|
|
+ peer = device->p_uuid[UI_BITMAP] & ~((u64)1);
|
|
|
if (self == peer && self != ((u64)0))
|
|
|
return 100;
|
|
|
|
|
|
*rule_nr = 100;
|
|
|
for (i = UI_HISTORY_START; i <= UI_HISTORY_END; i++) {
|
|
|
- self = mdev->ldev->md.uuid[i] & ~((u64)1);
|
|
|
+ self = device->ldev->md.uuid[i] & ~((u64)1);
|
|
|
for (j = UI_HISTORY_START; j <= UI_HISTORY_END; j++) {
|
|
|
- peer = mdev->p_uuid[j] & ~((u64)1);
|
|
|
+ peer = device->p_uuid[j] & ~((u64)1);
|
|
|
if (self == peer)
|
|
|
return -100;
|
|
|
}
|
|
|
@@ -2934,36 +2976,38 @@ static int drbd_uuid_compare(struct drbd_conf *mdev, int *rule_nr) __must_hold(l
|
|
|
/* drbd_sync_handshake() returns the new conn state on success, or
|
|
|
CONN_MASK (-1) on failure.
|
|
|
*/
|
|
|
-static enum drbd_conns drbd_sync_handshake(struct drbd_conf *mdev, enum drbd_role peer_role,
|
|
|
+static enum drbd_conns drbd_sync_handshake(struct drbd_peer_device *peer_device,
|
|
|
+ enum drbd_role peer_role,
|
|
|
enum drbd_disk_state peer_disk) __must_hold(local)
|
|
|
{
|
|
|
+ struct drbd_device *device = peer_device->device;
|
|
|
enum drbd_conns rv = C_MASK;
|
|
|
enum drbd_disk_state mydisk;
|
|
|
struct net_conf *nc;
|
|
|
int hg, rule_nr, rr_conflict, tentative;
|
|
|
|
|
|
- mydisk = mdev->state.disk;
|
|
|
+ mydisk = device->state.disk;
|
|
|
if (mydisk == D_NEGOTIATING)
|
|
|
- mydisk = mdev->new_state_tmp.disk;
|
|
|
+ mydisk = device->new_state_tmp.disk;
|
|
|
|
|
|
- dev_info(DEV, "drbd_sync_handshake:\n");
|
|
|
+ drbd_info(device, "drbd_sync_handshake:\n");
|
|
|
|
|
|
- spin_lock_irq(&mdev->ldev->md.uuid_lock);
|
|
|
- drbd_uuid_dump(mdev, "self", mdev->ldev->md.uuid, mdev->comm_bm_set, 0);
|
|
|
- drbd_uuid_dump(mdev, "peer", mdev->p_uuid,
|
|
|
- mdev->p_uuid[UI_SIZE], mdev->p_uuid[UI_FLAGS]);
|
|
|
+ spin_lock_irq(&device->ldev->md.uuid_lock);
|
|
|
+ drbd_uuid_dump(device, "self", device->ldev->md.uuid, device->comm_bm_set, 0);
|
|
|
+ drbd_uuid_dump(device, "peer", device->p_uuid,
|
|
|
+ device->p_uuid[UI_SIZE], device->p_uuid[UI_FLAGS]);
|
|
|
|
|
|
- hg = drbd_uuid_compare(mdev, &rule_nr);
|
|
|
- spin_unlock_irq(&mdev->ldev->md.uuid_lock);
|
|
|
+ hg = drbd_uuid_compare(device, &rule_nr);
|
|
|
+ spin_unlock_irq(&device->ldev->md.uuid_lock);
|
|
|
|
|
|
- dev_info(DEV, "uuid_compare()=%d by rule %d\n", hg, rule_nr);
|
|
|
+ drbd_info(device, "uuid_compare()=%d by rule %d\n", hg, rule_nr);
|
|
|
|
|
|
if (hg == -1000) {
|
|
|
- dev_alert(DEV, "Unrelated data, aborting!\n");
|
|
|
+ drbd_alert(device, "Unrelated data, aborting!\n");
|
|
|
return C_MASK;
|
|
|
}
|
|
|
if (hg < -1000) {
|
|
|
- dev_alert(DEV, "To resolve this both sides have to support at least protocol %d\n", -hg - 1000);
|
|
|
+ drbd_alert(device, "To resolve this both sides have to support at least protocol %d\n", -hg - 1000);
|
|
|
return C_MASK;
|
|
|
}
|
|
|
|
|
|
@@ -2973,38 +3017,38 @@ static enum drbd_conns drbd_sync_handshake(struct drbd_conf *mdev, enum drbd_rol
|
|
|
hg = mydisk > D_INCONSISTENT ? 1 : -1;
|
|
|
if (f)
|
|
|
hg = hg*2;
|
|
|
- dev_info(DEV, "Becoming sync %s due to disk states.\n",
|
|
|
+ drbd_info(device, "Becoming sync %s due to disk states.\n",
|
|
|
hg > 0 ? "source" : "target");
|
|
|
}
|
|
|
|
|
|
if (abs(hg) == 100)
|
|
|
- drbd_khelper(mdev, "initial-split-brain");
|
|
|
+ drbd_khelper(device, "initial-split-brain");
|
|
|
|
|
|
rcu_read_lock();
|
|
|
- nc = rcu_dereference(mdev->tconn->net_conf);
|
|
|
+ nc = rcu_dereference(peer_device->connection->net_conf);
|
|
|
|
|
|
if (hg == 100 || (hg == -100 && nc->always_asbp)) {
|
|
|
- int pcount = (mdev->state.role == R_PRIMARY)
|
|
|
+ int pcount = (device->state.role == R_PRIMARY)
|
|
|
+ (peer_role == R_PRIMARY);
|
|
|
int forced = (hg == -100);
|
|
|
|
|
|
switch (pcount) {
|
|
|
case 0:
|
|
|
- hg = drbd_asb_recover_0p(mdev);
|
|
|
+ hg = drbd_asb_recover_0p(peer_device);
|
|
|
break;
|
|
|
case 1:
|
|
|
- hg = drbd_asb_recover_1p(mdev);
|
|
|
+ hg = drbd_asb_recover_1p(peer_device);
|
|
|
break;
|
|
|
case 2:
|
|
|
- hg = drbd_asb_recover_2p(mdev);
|
|
|
+ hg = drbd_asb_recover_2p(peer_device);
|
|
|
break;
|
|
|
}
|
|
|
if (abs(hg) < 100) {
|
|
|
- dev_warn(DEV, "Split-Brain detected, %d primaries, "
|
|
|
+ drbd_warn(device, "Split-Brain detected, %d primaries, "
|
|
|
"automatically solved. Sync from %s node\n",
|
|
|
pcount, (hg < 0) ? "peer" : "this");
|
|
|
if (forced) {
|
|
|
- dev_warn(DEV, "Doing a full sync, since"
|
|
|
+ drbd_warn(device, "Doing a full sync, since"
|
|
|
" UUIDs where ambiguous.\n");
|
|
|
hg = hg*2;
|
|
|
}
|
|
|
@@ -3012,13 +3056,13 @@ static enum drbd_conns drbd_sync_handshake(struct drbd_conf *mdev, enum drbd_rol
|
|
|
}
|
|
|
|
|
|
if (hg == -100) {
|
|
|
- if (test_bit(DISCARD_MY_DATA, &mdev->flags) && !(mdev->p_uuid[UI_FLAGS]&1))
|
|
|
+ if (test_bit(DISCARD_MY_DATA, &device->flags) && !(device->p_uuid[UI_FLAGS]&1))
|
|
|
hg = -1;
|
|
|
- if (!test_bit(DISCARD_MY_DATA, &mdev->flags) && (mdev->p_uuid[UI_FLAGS]&1))
|
|
|
+ if (!test_bit(DISCARD_MY_DATA, &device->flags) && (device->p_uuid[UI_FLAGS]&1))
|
|
|
hg = 1;
|
|
|
|
|
|
if (abs(hg) < 100)
|
|
|
- dev_warn(DEV, "Split-Brain detected, manually solved. "
|
|
|
+ drbd_warn(device, "Split-Brain detected, manually solved. "
|
|
|
"Sync from %s node\n",
|
|
|
(hg < 0) ? "peer" : "this");
|
|
|
}
|
|
|
@@ -3031,44 +3075,44 @@ static enum drbd_conns drbd_sync_handshake(struct drbd_conf *mdev, enum drbd_rol
|
|
|
* after an attempted attach on a diskless node.
|
|
|
* We just refuse to attach -- well, we drop the "connection"
|
|
|
* to that disk, in a way... */
|
|
|
- dev_alert(DEV, "Split-Brain detected but unresolved, dropping connection!\n");
|
|
|
- drbd_khelper(mdev, "split-brain");
|
|
|
+ drbd_alert(device, "Split-Brain detected but unresolved, dropping connection!\n");
|
|
|
+ drbd_khelper(device, "split-brain");
|
|
|
return C_MASK;
|
|
|
}
|
|
|
|
|
|
if (hg > 0 && mydisk <= D_INCONSISTENT) {
|
|
|
- dev_err(DEV, "I shall become SyncSource, but I am inconsistent!\n");
|
|
|
+ drbd_err(device, "I shall become SyncSource, but I am inconsistent!\n");
|
|
|
return C_MASK;
|
|
|
}
|
|
|
|
|
|
if (hg < 0 && /* by intention we do not use mydisk here. */
|
|
|
- mdev->state.role == R_PRIMARY && mdev->state.disk >= D_CONSISTENT) {
|
|
|
+ device->state.role == R_PRIMARY && device->state.disk >= D_CONSISTENT) {
|
|
|
switch (rr_conflict) {
|
|
|
case ASB_CALL_HELPER:
|
|
|
- drbd_khelper(mdev, "pri-lost");
|
|
|
+ drbd_khelper(device, "pri-lost");
|
|
|
/* fall through */
|
|
|
case ASB_DISCONNECT:
|
|
|
- dev_err(DEV, "I shall become SyncTarget, but I am primary!\n");
|
|
|
+ drbd_err(device, "I shall become SyncTarget, but I am primary!\n");
|
|
|
return C_MASK;
|
|
|
case ASB_VIOLENTLY:
|
|
|
- dev_warn(DEV, "Becoming SyncTarget, violating the stable-data"
|
|
|
+ drbd_warn(device, "Becoming SyncTarget, violating the stable-data"
|
|
|
"assumption\n");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (tentative || test_bit(CONN_DRY_RUN, &mdev->tconn->flags)) {
|
|
|
+ if (tentative || test_bit(CONN_DRY_RUN, &peer_device->connection->flags)) {
|
|
|
if (hg == 0)
|
|
|
- dev_info(DEV, "dry-run connect: No resync, would become Connected immediately.\n");
|
|
|
+ drbd_info(device, "dry-run connect: No resync, would become Connected immediately.\n");
|
|
|
else
|
|
|
- dev_info(DEV, "dry-run connect: Would become %s, doing a %s resync.",
|
|
|
+ drbd_info(device, "dry-run connect: Would become %s, doing a %s resync.",
|
|
|
drbd_conn_str(hg > 0 ? C_SYNC_SOURCE : C_SYNC_TARGET),
|
|
|
abs(hg) >= 2 ? "full" : "bit-map based");
|
|
|
return C_MASK;
|
|
|
}
|
|
|
|
|
|
if (abs(hg) >= 2) {
|
|
|
- dev_info(DEV, "Writing the whole bitmap, full sync required after drbd_sync_handshake.\n");
|
|
|
- if (drbd_bitmap_io(mdev, &drbd_bmio_set_n_write, "set_n_write from sync_handshake",
|
|
|
+ drbd_info(device, "Writing the whole bitmap, full sync required after drbd_sync_handshake.\n");
|
|
|
+ if (drbd_bitmap_io(device, &drbd_bmio_set_n_write, "set_n_write from sync_handshake",
|
|
|
BM_LOCKED_SET_ALLOWED))
|
|
|
return C_MASK;
|
|
|
}
|
|
|
@@ -3079,9 +3123,9 @@ static enum drbd_conns drbd_sync_handshake(struct drbd_conf *mdev, enum drbd_rol
|
|
|
rv = C_WF_BITMAP_T;
|
|
|
} else {
|
|
|
rv = C_CONNECTED;
|
|
|
- if (drbd_bm_total_weight(mdev)) {
|
|
|
- dev_info(DEV, "No resync, but %lu bits in bitmap!\n",
|
|
|
- drbd_bm_total_weight(mdev));
|
|
|
+ if (drbd_bm_total_weight(device)) {
|
|
|
+ drbd_info(device, "No resync, but %lu bits in bitmap!\n",
|
|
|
+ drbd_bm_total_weight(device));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -3102,7 +3146,7 @@ static enum drbd_after_sb_p convert_after_sb(enum drbd_after_sb_p peer)
|
|
|
return peer;
|
|
|
}
|
|
|
|
|
|
-static int receive_protocol(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int receive_protocol(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
struct p_protocol *p = pi->data;
|
|
|
enum drbd_after_sb_p p_after_sb_0p, p_after_sb_1p, p_after_sb_2p;
|
|
|
@@ -3120,58 +3164,58 @@ static int receive_protocol(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
cf = be32_to_cpu(p->conn_flags);
|
|
|
p_discard_my_data = cf & CF_DISCARD_MY_DATA;
|
|
|
|
|
|
- if (tconn->agreed_pro_version >= 87) {
|
|
|
+ if (connection->agreed_pro_version >= 87) {
|
|
|
int err;
|
|
|
|
|
|
if (pi->size > sizeof(integrity_alg))
|
|
|
return -EIO;
|
|
|
- err = drbd_recv_all(tconn, integrity_alg, pi->size);
|
|
|
+ err = drbd_recv_all(connection, integrity_alg, pi->size);
|
|
|
if (err)
|
|
|
return err;
|
|
|
integrity_alg[SHARED_SECRET_MAX - 1] = 0;
|
|
|
}
|
|
|
|
|
|
if (pi->cmd != P_PROTOCOL_UPDATE) {
|
|
|
- clear_bit(CONN_DRY_RUN, &tconn->flags);
|
|
|
+ clear_bit(CONN_DRY_RUN, &connection->flags);
|
|
|
|
|
|
if (cf & CF_DRY_RUN)
|
|
|
- set_bit(CONN_DRY_RUN, &tconn->flags);
|
|
|
+ set_bit(CONN_DRY_RUN, &connection->flags);
|
|
|
|
|
|
rcu_read_lock();
|
|
|
- nc = rcu_dereference(tconn->net_conf);
|
|
|
+ nc = rcu_dereference(connection->net_conf);
|
|
|
|
|
|
if (p_proto != nc->wire_protocol) {
|
|
|
- conn_err(tconn, "incompatible %s settings\n", "protocol");
|
|
|
+ drbd_err(connection, "incompatible %s settings\n", "protocol");
|
|
|
goto disconnect_rcu_unlock;
|
|
|
}
|
|
|
|
|
|
if (convert_after_sb(p_after_sb_0p) != nc->after_sb_0p) {
|
|
|
- conn_err(tconn, "incompatible %s settings\n", "after-sb-0pri");
|
|
|
+ drbd_err(connection, "incompatible %s settings\n", "after-sb-0pri");
|
|
|
goto disconnect_rcu_unlock;
|
|
|
}
|
|
|
|
|
|
if (convert_after_sb(p_after_sb_1p) != nc->after_sb_1p) {
|
|
|
- conn_err(tconn, "incompatible %s settings\n", "after-sb-1pri");
|
|
|
+ drbd_err(connection, "incompatible %s settings\n", "after-sb-1pri");
|
|
|
goto disconnect_rcu_unlock;
|
|
|
}
|
|
|
|
|
|
if (convert_after_sb(p_after_sb_2p) != nc->after_sb_2p) {
|
|
|
- conn_err(tconn, "incompatible %s settings\n", "after-sb-2pri");
|
|
|
+ drbd_err(connection, "incompatible %s settings\n", "after-sb-2pri");
|
|
|
goto disconnect_rcu_unlock;
|
|
|
}
|
|
|
|
|
|
if (p_discard_my_data && nc->discard_my_data) {
|
|
|
- conn_err(tconn, "incompatible %s settings\n", "discard-my-data");
|
|
|
+ drbd_err(connection, "incompatible %s settings\n", "discard-my-data");
|
|
|
goto disconnect_rcu_unlock;
|
|
|
}
|
|
|
|
|
|
if (p_two_primaries != nc->two_primaries) {
|
|
|
- conn_err(tconn, "incompatible %s settings\n", "allow-two-primaries");
|
|
|
+ drbd_err(connection, "incompatible %s settings\n", "allow-two-primaries");
|
|
|
goto disconnect_rcu_unlock;
|
|
|
}
|
|
|
|
|
|
if (strcmp(integrity_alg, nc->integrity_alg)) {
|
|
|
- conn_err(tconn, "incompatible %s settings\n", "data-integrity-alg");
|
|
|
+ drbd_err(connection, "incompatible %s settings\n", "data-integrity-alg");
|
|
|
goto disconnect_rcu_unlock;
|
|
|
}
|
|
|
|
|
|
@@ -3192,7 +3236,7 @@ static int receive_protocol(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
|
|
|
peer_integrity_tfm = crypto_alloc_hash(integrity_alg, 0, CRYPTO_ALG_ASYNC);
|
|
|
if (!peer_integrity_tfm) {
|
|
|
- conn_err(tconn, "peer data-integrity-alg %s not supported\n",
|
|
|
+ drbd_err(connection, "peer data-integrity-alg %s not supported\n",
|
|
|
integrity_alg);
|
|
|
goto disconnect;
|
|
|
}
|
|
|
@@ -3201,20 +3245,20 @@ static int receive_protocol(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
int_dig_in = kmalloc(hash_size, GFP_KERNEL);
|
|
|
int_dig_vv = kmalloc(hash_size, GFP_KERNEL);
|
|
|
if (!(int_dig_in && int_dig_vv)) {
|
|
|
- conn_err(tconn, "Allocation of buffers for data integrity checking failed\n");
|
|
|
+ drbd_err(connection, "Allocation of buffers for data integrity checking failed\n");
|
|
|
goto disconnect;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
new_net_conf = kmalloc(sizeof(struct net_conf), GFP_KERNEL);
|
|
|
if (!new_net_conf) {
|
|
|
- conn_err(tconn, "Allocation of new net_conf failed\n");
|
|
|
+ drbd_err(connection, "Allocation of new net_conf failed\n");
|
|
|
goto disconnect;
|
|
|
}
|
|
|
|
|
|
- mutex_lock(&tconn->data.mutex);
|
|
|
- mutex_lock(&tconn->conf_update);
|
|
|
- old_net_conf = tconn->net_conf;
|
|
|
+ mutex_lock(&connection->data.mutex);
|
|
|
+ mutex_lock(&connection->resource->conf_update);
|
|
|
+ old_net_conf = connection->net_conf;
|
|
|
*new_net_conf = *old_net_conf;
|
|
|
|
|
|
new_net_conf->wire_protocol = p_proto;
|
|
|
@@ -3223,19 +3267,19 @@ static int receive_protocol(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
new_net_conf->after_sb_2p = convert_after_sb(p_after_sb_2p);
|
|
|
new_net_conf->two_primaries = p_two_primaries;
|
|
|
|
|
|
- rcu_assign_pointer(tconn->net_conf, new_net_conf);
|
|
|
- mutex_unlock(&tconn->conf_update);
|
|
|
- mutex_unlock(&tconn->data.mutex);
|
|
|
+ rcu_assign_pointer(connection->net_conf, new_net_conf);
|
|
|
+ mutex_unlock(&connection->resource->conf_update);
|
|
|
+ mutex_unlock(&connection->data.mutex);
|
|
|
|
|
|
- crypto_free_hash(tconn->peer_integrity_tfm);
|
|
|
- kfree(tconn->int_dig_in);
|
|
|
- kfree(tconn->int_dig_vv);
|
|
|
- tconn->peer_integrity_tfm = peer_integrity_tfm;
|
|
|
- tconn->int_dig_in = int_dig_in;
|
|
|
- tconn->int_dig_vv = int_dig_vv;
|
|
|
+ crypto_free_hash(connection->peer_integrity_tfm);
|
|
|
+ kfree(connection->int_dig_in);
|
|
|
+ kfree(connection->int_dig_vv);
|
|
|
+ connection->peer_integrity_tfm = peer_integrity_tfm;
|
|
|
+ connection->int_dig_in = int_dig_in;
|
|
|
+ connection->int_dig_vv = int_dig_vv;
|
|
|
|
|
|
if (strcmp(old_net_conf->integrity_alg, integrity_alg))
|
|
|
- conn_info(tconn, "peer data-integrity-alg: %s\n",
|
|
|
+ drbd_info(connection, "peer data-integrity-alg: %s\n",
|
|
|
integrity_alg[0] ? integrity_alg : "(none)");
|
|
|
|
|
|
synchronize_rcu();
|
|
|
@@ -3248,7 +3292,7 @@ disconnect:
|
|
|
crypto_free_hash(peer_integrity_tfm);
|
|
|
kfree(int_dig_in);
|
|
|
kfree(int_dig_vv);
|
|
|
- conn_request_state(tconn, NS(conn, C_DISCONNECTING), CS_HARD);
|
|
|
+ conn_request_state(connection, NS(conn, C_DISCONNECTING), CS_HARD);
|
|
|
return -EIO;
|
|
|
}
|
|
|
|
|
|
@@ -3257,7 +3301,8 @@ disconnect:
|
|
|
* return: NULL (alg name was "")
|
|
|
* ERR_PTR(error) if something goes wrong
|
|
|
* or the crypto hash ptr, if it worked out ok. */
|
|
|
-struct crypto_hash *drbd_crypto_alloc_digest_safe(const struct drbd_conf *mdev,
|
|
|
+static
|
|
|
+struct crypto_hash *drbd_crypto_alloc_digest_safe(const struct drbd_device *device,
|
|
|
const char *alg, const char *name)
|
|
|
{
|
|
|
struct crypto_hash *tfm;
|
|
|
@@ -3267,21 +3312,21 @@ struct crypto_hash *drbd_crypto_alloc_digest_safe(const struct drbd_conf *mdev,
|
|
|
|
|
|
tfm = crypto_alloc_hash(alg, 0, CRYPTO_ALG_ASYNC);
|
|
|
if (IS_ERR(tfm)) {
|
|
|
- dev_err(DEV, "Can not allocate \"%s\" as %s (reason: %ld)\n",
|
|
|
+ drbd_err(device, "Can not allocate \"%s\" as %s (reason: %ld)\n",
|
|
|
alg, name, PTR_ERR(tfm));
|
|
|
return tfm;
|
|
|
}
|
|
|
return tfm;
|
|
|
}
|
|
|
|
|
|
-static int ignore_remaining_packet(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int ignore_remaining_packet(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
- void *buffer = tconn->data.rbuf;
|
|
|
+ void *buffer = connection->data.rbuf;
|
|
|
int size = pi->size;
|
|
|
|
|
|
while (size) {
|
|
|
int s = min_t(int, size, DRBD_SOCKET_BUFFER_SIZE);
|
|
|
- s = drbd_recv(tconn, buffer, s);
|
|
|
+ s = drbd_recv(connection, buffer, s);
|
|
|
if (s <= 0) {
|
|
|
if (s < 0)
|
|
|
return s;
|
|
|
@@ -3305,30 +3350,32 @@ static int ignore_remaining_packet(struct drbd_tconn *tconn, struct packet_info
|
|
|
*
|
|
|
* (We can also end up here if drbd is misconfigured.)
|
|
|
*/
|
|
|
-static int config_unknown_volume(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int config_unknown_volume(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
- conn_warn(tconn, "%s packet received for volume %u, which is not configured locally\n",
|
|
|
+ drbd_warn(connection, "%s packet received for volume %u, which is not configured locally\n",
|
|
|
cmdname(pi->cmd), pi->vnr);
|
|
|
- return ignore_remaining_packet(tconn, pi);
|
|
|
+ return ignore_remaining_packet(connection, pi);
|
|
|
}
|
|
|
|
|
|
-static int receive_SyncParam(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int receive_SyncParam(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
- struct drbd_conf *mdev;
|
|
|
+ struct drbd_peer_device *peer_device;
|
|
|
+ struct drbd_device *device;
|
|
|
struct p_rs_param_95 *p;
|
|
|
unsigned int header_size, data_size, exp_max_sz;
|
|
|
struct crypto_hash *verify_tfm = NULL;
|
|
|
struct crypto_hash *csums_tfm = NULL;
|
|
|
struct net_conf *old_net_conf, *new_net_conf = NULL;
|
|
|
struct disk_conf *old_disk_conf = NULL, *new_disk_conf = NULL;
|
|
|
- const int apv = tconn->agreed_pro_version;
|
|
|
+ const int apv = connection->agreed_pro_version;
|
|
|
struct fifo_buffer *old_plan = NULL, *new_plan = NULL;
|
|
|
int fifo_size = 0;
|
|
|
int err;
|
|
|
|
|
|
- mdev = vnr_to_mdev(tconn, pi->vnr);
|
|
|
- if (!mdev)
|
|
|
- return config_unknown_volume(tconn, pi);
|
|
|
+ peer_device = conn_peer_device(connection, pi->vnr);
|
|
|
+ if (!peer_device)
|
|
|
+ return config_unknown_volume(connection, pi);
|
|
|
+ device = peer_device->device;
|
|
|
|
|
|
exp_max_sz = apv <= 87 ? sizeof(struct p_rs_param)
|
|
|
: apv == 88 ? sizeof(struct p_rs_param)
|
|
|
@@ -3337,7 +3384,7 @@ static int receive_SyncParam(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
: /* apv >= 95 */ sizeof(struct p_rs_param_95);
|
|
|
|
|
|
if (pi->size > exp_max_sz) {
|
|
|
- dev_err(DEV, "SyncParam packet too long: received %u, expected <= %u bytes\n",
|
|
|
+ drbd_err(device, "SyncParam packet too long: received %u, expected <= %u bytes\n",
|
|
|
pi->size, exp_max_sz);
|
|
|
return -EIO;
|
|
|
}
|
|
|
@@ -3348,33 +3395,33 @@ static int receive_SyncParam(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
} else if (apv <= 94) {
|
|
|
header_size = sizeof(struct p_rs_param_89);
|
|
|
data_size = pi->size - header_size;
|
|
|
- D_ASSERT(data_size == 0);
|
|
|
+ D_ASSERT(device, data_size == 0);
|
|
|
} else {
|
|
|
header_size = sizeof(struct p_rs_param_95);
|
|
|
data_size = pi->size - header_size;
|
|
|
- D_ASSERT(data_size == 0);
|
|
|
+ D_ASSERT(device, data_size == 0);
|
|
|
}
|
|
|
|
|
|
/* initialize verify_alg and csums_alg */
|
|
|
p = pi->data;
|
|
|
memset(p->verify_alg, 0, 2 * SHARED_SECRET_MAX);
|
|
|
|
|
|
- err = drbd_recv_all(mdev->tconn, p, header_size);
|
|
|
+ err = drbd_recv_all(peer_device->connection, p, header_size);
|
|
|
if (err)
|
|
|
return err;
|
|
|
|
|
|
- mutex_lock(&mdev->tconn->conf_update);
|
|
|
- old_net_conf = mdev->tconn->net_conf;
|
|
|
- if (get_ldev(mdev)) {
|
|
|
+ mutex_lock(&connection->resource->conf_update);
|
|
|
+ old_net_conf = peer_device->connection->net_conf;
|
|
|
+ if (get_ldev(device)) {
|
|
|
new_disk_conf = kzalloc(sizeof(struct disk_conf), GFP_KERNEL);
|
|
|
if (!new_disk_conf) {
|
|
|
- put_ldev(mdev);
|
|
|
- mutex_unlock(&mdev->tconn->conf_update);
|
|
|
- dev_err(DEV, "Allocation of new disk_conf failed\n");
|
|
|
+ put_ldev(device);
|
|
|
+ mutex_unlock(&connection->resource->conf_update);
|
|
|
+ drbd_err(device, "Allocation of new disk_conf failed\n");
|
|
|
return -ENOMEM;
|
|
|
}
|
|
|
|
|
|
- old_disk_conf = mdev->ldev->disk_conf;
|
|
|
+ old_disk_conf = device->ldev->disk_conf;
|
|
|
*new_disk_conf = *old_disk_conf;
|
|
|
|
|
|
new_disk_conf->resync_rate = be32_to_cpu(p->resync_rate);
|
|
|
@@ -3383,37 +3430,37 @@ static int receive_SyncParam(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
if (apv >= 88) {
|
|
|
if (apv == 88) {
|
|
|
if (data_size > SHARED_SECRET_MAX || data_size == 0) {
|
|
|
- dev_err(DEV, "verify-alg of wrong size, "
|
|
|
+ drbd_err(device, "verify-alg of wrong size, "
|
|
|
"peer wants %u, accepting only up to %u byte\n",
|
|
|
data_size, SHARED_SECRET_MAX);
|
|
|
err = -EIO;
|
|
|
goto reconnect;
|
|
|
}
|
|
|
|
|
|
- err = drbd_recv_all(mdev->tconn, p->verify_alg, data_size);
|
|
|
+ err = drbd_recv_all(peer_device->connection, p->verify_alg, data_size);
|
|
|
if (err)
|
|
|
goto reconnect;
|
|
|
/* we expect NUL terminated string */
|
|
|
/* but just in case someone tries to be evil */
|
|
|
- D_ASSERT(p->verify_alg[data_size-1] == 0);
|
|
|
+ D_ASSERT(device, p->verify_alg[data_size-1] == 0);
|
|
|
p->verify_alg[data_size-1] = 0;
|
|
|
|
|
|
} else /* apv >= 89 */ {
|
|
|
/* we still expect NUL terminated strings */
|
|
|
/* but just in case someone tries to be evil */
|
|
|
- D_ASSERT(p->verify_alg[SHARED_SECRET_MAX-1] == 0);
|
|
|
- D_ASSERT(p->csums_alg[SHARED_SECRET_MAX-1] == 0);
|
|
|
+ D_ASSERT(device, p->verify_alg[SHARED_SECRET_MAX-1] == 0);
|
|
|
+ D_ASSERT(device, p->csums_alg[SHARED_SECRET_MAX-1] == 0);
|
|
|
p->verify_alg[SHARED_SECRET_MAX-1] = 0;
|
|
|
p->csums_alg[SHARED_SECRET_MAX-1] = 0;
|
|
|
}
|
|
|
|
|
|
if (strcmp(old_net_conf->verify_alg, p->verify_alg)) {
|
|
|
- if (mdev->state.conn == C_WF_REPORT_PARAMS) {
|
|
|
- dev_err(DEV, "Different verify-alg settings. me=\"%s\" peer=\"%s\"\n",
|
|
|
+ if (device->state.conn == C_WF_REPORT_PARAMS) {
|
|
|
+ drbd_err(device, "Different verify-alg settings. me=\"%s\" peer=\"%s\"\n",
|
|
|
old_net_conf->verify_alg, p->verify_alg);
|
|
|
goto disconnect;
|
|
|
}
|
|
|
- verify_tfm = drbd_crypto_alloc_digest_safe(mdev,
|
|
|
+ verify_tfm = drbd_crypto_alloc_digest_safe(device,
|
|
|
p->verify_alg, "verify-alg");
|
|
|
if (IS_ERR(verify_tfm)) {
|
|
|
verify_tfm = NULL;
|
|
|
@@ -3422,12 +3469,12 @@ static int receive_SyncParam(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
}
|
|
|
|
|
|
if (apv >= 89 && strcmp(old_net_conf->csums_alg, p->csums_alg)) {
|
|
|
- if (mdev->state.conn == C_WF_REPORT_PARAMS) {
|
|
|
- dev_err(DEV, "Different csums-alg settings. me=\"%s\" peer=\"%s\"\n",
|
|
|
+ if (device->state.conn == C_WF_REPORT_PARAMS) {
|
|
|
+ drbd_err(device, "Different csums-alg settings. me=\"%s\" peer=\"%s\"\n",
|
|
|
old_net_conf->csums_alg, p->csums_alg);
|
|
|
goto disconnect;
|
|
|
}
|
|
|
- csums_tfm = drbd_crypto_alloc_digest_safe(mdev,
|
|
|
+ csums_tfm = drbd_crypto_alloc_digest_safe(device,
|
|
|
p->csums_alg, "csums-alg");
|
|
|
if (IS_ERR(csums_tfm)) {
|
|
|
csums_tfm = NULL;
|
|
|
@@ -3442,11 +3489,11 @@ static int receive_SyncParam(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
new_disk_conf->c_max_rate = be32_to_cpu(p->c_max_rate);
|
|
|
|
|
|
fifo_size = (new_disk_conf->c_plan_ahead * 10 * SLEEP_TIME) / HZ;
|
|
|
- if (fifo_size != mdev->rs_plan_s->size) {
|
|
|
+ if (fifo_size != device->rs_plan_s->size) {
|
|
|
new_plan = fifo_alloc(fifo_size);
|
|
|
if (!new_plan) {
|
|
|
- dev_err(DEV, "kmalloc of fifo_buffer failed");
|
|
|
- put_ldev(mdev);
|
|
|
+ drbd_err(device, "kmalloc of fifo_buffer failed");
|
|
|
+ put_ldev(device);
|
|
|
goto disconnect;
|
|
|
}
|
|
|
}
|
|
|
@@ -3455,7 +3502,7 @@ static int receive_SyncParam(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
if (verify_tfm || csums_tfm) {
|
|
|
new_net_conf = kzalloc(sizeof(struct net_conf), GFP_KERNEL);
|
|
|
if (!new_net_conf) {
|
|
|
- dev_err(DEV, "Allocation of new net_conf failed\n");
|
|
|
+ drbd_err(device, "Allocation of new net_conf failed\n");
|
|
|
goto disconnect;
|
|
|
}
|
|
|
|
|
|
@@ -3464,32 +3511,32 @@ static int receive_SyncParam(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
if (verify_tfm) {
|
|
|
strcpy(new_net_conf->verify_alg, p->verify_alg);
|
|
|
new_net_conf->verify_alg_len = strlen(p->verify_alg) + 1;
|
|
|
- crypto_free_hash(mdev->tconn->verify_tfm);
|
|
|
- mdev->tconn->verify_tfm = verify_tfm;
|
|
|
- dev_info(DEV, "using verify-alg: \"%s\"\n", p->verify_alg);
|
|
|
+ crypto_free_hash(peer_device->connection->verify_tfm);
|
|
|
+ peer_device->connection->verify_tfm = verify_tfm;
|
|
|
+ drbd_info(device, "using verify-alg: \"%s\"\n", p->verify_alg);
|
|
|
}
|
|
|
if (csums_tfm) {
|
|
|
strcpy(new_net_conf->csums_alg, p->csums_alg);
|
|
|
new_net_conf->csums_alg_len = strlen(p->csums_alg) + 1;
|
|
|
- crypto_free_hash(mdev->tconn->csums_tfm);
|
|
|
- mdev->tconn->csums_tfm = csums_tfm;
|
|
|
- dev_info(DEV, "using csums-alg: \"%s\"\n", p->csums_alg);
|
|
|
+ crypto_free_hash(peer_device->connection->csums_tfm);
|
|
|
+ peer_device->connection->csums_tfm = csums_tfm;
|
|
|
+ drbd_info(device, "using csums-alg: \"%s\"\n", p->csums_alg);
|
|
|
}
|
|
|
- rcu_assign_pointer(tconn->net_conf, new_net_conf);
|
|
|
+ rcu_assign_pointer(connection->net_conf, new_net_conf);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (new_disk_conf) {
|
|
|
- rcu_assign_pointer(mdev->ldev->disk_conf, new_disk_conf);
|
|
|
- put_ldev(mdev);
|
|
|
+ rcu_assign_pointer(device->ldev->disk_conf, new_disk_conf);
|
|
|
+ put_ldev(device);
|
|
|
}
|
|
|
|
|
|
if (new_plan) {
|
|
|
- old_plan = mdev->rs_plan_s;
|
|
|
- rcu_assign_pointer(mdev->rs_plan_s, new_plan);
|
|
|
+ old_plan = device->rs_plan_s;
|
|
|
+ rcu_assign_pointer(device->rs_plan_s, new_plan);
|
|
|
}
|
|
|
|
|
|
- mutex_unlock(&mdev->tconn->conf_update);
|
|
|
+ mutex_unlock(&connection->resource->conf_update);
|
|
|
synchronize_rcu();
|
|
|
if (new_net_conf)
|
|
|
kfree(old_net_conf);
|
|
|
@@ -3500,30 +3547,30 @@ static int receive_SyncParam(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
|
|
|
reconnect:
|
|
|
if (new_disk_conf) {
|
|
|
- put_ldev(mdev);
|
|
|
+ put_ldev(device);
|
|
|
kfree(new_disk_conf);
|
|
|
}
|
|
|
- mutex_unlock(&mdev->tconn->conf_update);
|
|
|
+ mutex_unlock(&connection->resource->conf_update);
|
|
|
return -EIO;
|
|
|
|
|
|
disconnect:
|
|
|
kfree(new_plan);
|
|
|
if (new_disk_conf) {
|
|
|
- put_ldev(mdev);
|
|
|
+ put_ldev(device);
|
|
|
kfree(new_disk_conf);
|
|
|
}
|
|
|
- mutex_unlock(&mdev->tconn->conf_update);
|
|
|
+ mutex_unlock(&connection->resource->conf_update);
|
|
|
/* just for completeness: actually not needed,
|
|
|
* as this is not reached if csums_tfm was ok. */
|
|
|
crypto_free_hash(csums_tfm);
|
|
|
/* but free the verify_tfm again, if csums_tfm did not work out */
|
|
|
crypto_free_hash(verify_tfm);
|
|
|
- conn_request_state(mdev->tconn, NS(conn, C_DISCONNECTING), CS_HARD);
|
|
|
+ conn_request_state(peer_device->connection, NS(conn, C_DISCONNECTING), CS_HARD);
|
|
|
return -EIO;
|
|
|
}
|
|
|
|
|
|
/* warn if the arguments differ by more than 12.5% */
|
|
|
-static void warn_if_differ_considerably(struct drbd_conf *mdev,
|
|
|
+static void warn_if_differ_considerably(struct drbd_device *device,
|
|
|
const char *s, sector_t a, sector_t b)
|
|
|
{
|
|
|
sector_t d;
|
|
|
@@ -3531,54 +3578,56 @@ static void warn_if_differ_considerably(struct drbd_conf *mdev,
|
|
|
return;
|
|
|
d = (a > b) ? (a - b) : (b - a);
|
|
|
if (d > (a>>3) || d > (b>>3))
|
|
|
- dev_warn(DEV, "Considerable difference in %s: %llus vs. %llus\n", s,
|
|
|
+ drbd_warn(device, "Considerable difference in %s: %llus vs. %llus\n", s,
|
|
|
(unsigned long long)a, (unsigned long long)b);
|
|
|
}
|
|
|
|
|
|
-static int receive_sizes(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int receive_sizes(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
- struct drbd_conf *mdev;
|
|
|
+ struct drbd_peer_device *peer_device;
|
|
|
+ struct drbd_device *device;
|
|
|
struct p_sizes *p = pi->data;
|
|
|
enum determine_dev_size dd = DS_UNCHANGED;
|
|
|
sector_t p_size, p_usize, my_usize;
|
|
|
int ldsc = 0; /* local disk size changed */
|
|
|
enum dds_flags ddsf;
|
|
|
|
|
|
- mdev = vnr_to_mdev(tconn, pi->vnr);
|
|
|
- if (!mdev)
|
|
|
- return config_unknown_volume(tconn, pi);
|
|
|
+ peer_device = conn_peer_device(connection, pi->vnr);
|
|
|
+ if (!peer_device)
|
|
|
+ return config_unknown_volume(connection, pi);
|
|
|
+ device = peer_device->device;
|
|
|
|
|
|
p_size = be64_to_cpu(p->d_size);
|
|
|
p_usize = be64_to_cpu(p->u_size);
|
|
|
|
|
|
/* just store the peer's disk size for now.
|
|
|
* we still need to figure out whether we accept that. */
|
|
|
- mdev->p_size = p_size;
|
|
|
+ device->p_size = p_size;
|
|
|
|
|
|
- if (get_ldev(mdev)) {
|
|
|
+ if (get_ldev(device)) {
|
|
|
rcu_read_lock();
|
|
|
- my_usize = rcu_dereference(mdev->ldev->disk_conf)->disk_size;
|
|
|
+ my_usize = rcu_dereference(device->ldev->disk_conf)->disk_size;
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
- warn_if_differ_considerably(mdev, "lower level device sizes",
|
|
|
- p_size, drbd_get_max_capacity(mdev->ldev));
|
|
|
- warn_if_differ_considerably(mdev, "user requested size",
|
|
|
+ warn_if_differ_considerably(device, "lower level device sizes",
|
|
|
+ p_size, drbd_get_max_capacity(device->ldev));
|
|
|
+ warn_if_differ_considerably(device, "user requested size",
|
|
|
p_usize, my_usize);
|
|
|
|
|
|
/* if this is the first connect, or an otherwise expected
|
|
|
* param exchange, choose the minimum */
|
|
|
- if (mdev->state.conn == C_WF_REPORT_PARAMS)
|
|
|
+ if (device->state.conn == C_WF_REPORT_PARAMS)
|
|
|
p_usize = min_not_zero(my_usize, p_usize);
|
|
|
|
|
|
/* Never shrink a device with usable data during connect.
|
|
|
But allow online shrinking if we are connected. */
|
|
|
- if (drbd_new_dev_size(mdev, mdev->ldev, p_usize, 0) <
|
|
|
- drbd_get_capacity(mdev->this_bdev) &&
|
|
|
- mdev->state.disk >= D_OUTDATED &&
|
|
|
- mdev->state.conn < C_CONNECTED) {
|
|
|
- dev_err(DEV, "The peer's disk size is too small!\n");
|
|
|
- conn_request_state(mdev->tconn, NS(conn, C_DISCONNECTING), CS_HARD);
|
|
|
- put_ldev(mdev);
|
|
|
+ if (drbd_new_dev_size(device, device->ldev, p_usize, 0) <
|
|
|
+ drbd_get_capacity(device->this_bdev) &&
|
|
|
+ device->state.disk >= D_OUTDATED &&
|
|
|
+ device->state.conn < C_CONNECTED) {
|
|
|
+ drbd_err(device, "The peer's disk size is too small!\n");
|
|
|
+ conn_request_state(peer_device->connection, NS(conn, C_DISCONNECTING), CS_HARD);
|
|
|
+ put_ldev(device);
|
|
|
return -EIO;
|
|
|
}
|
|
|
|
|
|
@@ -3587,145 +3636,147 @@ static int receive_sizes(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
|
|
|
new_disk_conf = kzalloc(sizeof(struct disk_conf), GFP_KERNEL);
|
|
|
if (!new_disk_conf) {
|
|
|
- dev_err(DEV, "Allocation of new disk_conf failed\n");
|
|
|
- put_ldev(mdev);
|
|
|
+ drbd_err(device, "Allocation of new disk_conf failed\n");
|
|
|
+ put_ldev(device);
|
|
|
return -ENOMEM;
|
|
|
}
|
|
|
|
|
|
- mutex_lock(&mdev->tconn->conf_update);
|
|
|
- old_disk_conf = mdev->ldev->disk_conf;
|
|
|
+ mutex_lock(&connection->resource->conf_update);
|
|
|
+ old_disk_conf = device->ldev->disk_conf;
|
|
|
*new_disk_conf = *old_disk_conf;
|
|
|
new_disk_conf->disk_size = p_usize;
|
|
|
|
|
|
- rcu_assign_pointer(mdev->ldev->disk_conf, new_disk_conf);
|
|
|
- mutex_unlock(&mdev->tconn->conf_update);
|
|
|
+ rcu_assign_pointer(device->ldev->disk_conf, new_disk_conf);
|
|
|
+ mutex_unlock(&connection->resource->conf_update);
|
|
|
synchronize_rcu();
|
|
|
kfree(old_disk_conf);
|
|
|
|
|
|
- dev_info(DEV, "Peer sets u_size to %lu sectors\n",
|
|
|
+ drbd_info(device, "Peer sets u_size to %lu sectors\n",
|
|
|
(unsigned long)my_usize);
|
|
|
}
|
|
|
|
|
|
- put_ldev(mdev);
|
|
|
+ put_ldev(device);
|
|
|
}
|
|
|
|
|
|
ddsf = be16_to_cpu(p->dds_flags);
|
|
|
- if (get_ldev(mdev)) {
|
|
|
- dd = drbd_determine_dev_size(mdev, ddsf, NULL);
|
|
|
- put_ldev(mdev);
|
|
|
+ if (get_ldev(device)) {
|
|
|
+ dd = drbd_determine_dev_size(device, ddsf, NULL);
|
|
|
+ put_ldev(device);
|
|
|
if (dd == DS_ERROR)
|
|
|
return -EIO;
|
|
|
- drbd_md_sync(mdev);
|
|
|
+ drbd_md_sync(device);
|
|
|
} else {
|
|
|
/* I am diskless, need to accept the peer's size. */
|
|
|
- drbd_set_my_capacity(mdev, p_size);
|
|
|
+ drbd_set_my_capacity(device, p_size);
|
|
|
}
|
|
|
|
|
|
- mdev->peer_max_bio_size = be32_to_cpu(p->max_bio_size);
|
|
|
- drbd_reconsider_max_bio_size(mdev);
|
|
|
+ device->peer_max_bio_size = be32_to_cpu(p->max_bio_size);
|
|
|
+ drbd_reconsider_max_bio_size(device);
|
|
|
|
|
|
- if (get_ldev(mdev)) {
|
|
|
- if (mdev->ldev->known_size != drbd_get_capacity(mdev->ldev->backing_bdev)) {
|
|
|
- mdev->ldev->known_size = drbd_get_capacity(mdev->ldev->backing_bdev);
|
|
|
+ if (get_ldev(device)) {
|
|
|
+ if (device->ldev->known_size != drbd_get_capacity(device->ldev->backing_bdev)) {
|
|
|
+ device->ldev->known_size = drbd_get_capacity(device->ldev->backing_bdev);
|
|
|
ldsc = 1;
|
|
|
}
|
|
|
|
|
|
- put_ldev(mdev);
|
|
|
+ put_ldev(device);
|
|
|
}
|
|
|
|
|
|
- if (mdev->state.conn > C_WF_REPORT_PARAMS) {
|
|
|
+ if (device->state.conn > C_WF_REPORT_PARAMS) {
|
|
|
if (be64_to_cpu(p->c_size) !=
|
|
|
- drbd_get_capacity(mdev->this_bdev) || ldsc) {
|
|
|
+ drbd_get_capacity(device->this_bdev) || ldsc) {
|
|
|
/* we have different sizes, probably peer
|
|
|
* needs to know my new size... */
|
|
|
- drbd_send_sizes(mdev, 0, ddsf);
|
|
|
+ drbd_send_sizes(peer_device, 0, ddsf);
|
|
|
}
|
|
|
- if (test_and_clear_bit(RESIZE_PENDING, &mdev->flags) ||
|
|
|
- (dd == DS_GREW && mdev->state.conn == C_CONNECTED)) {
|
|
|
- if (mdev->state.pdsk >= D_INCONSISTENT &&
|
|
|
- mdev->state.disk >= D_INCONSISTENT) {
|
|
|
+ if (test_and_clear_bit(RESIZE_PENDING, &device->flags) ||
|
|
|
+ (dd == DS_GREW && device->state.conn == C_CONNECTED)) {
|
|
|
+ if (device->state.pdsk >= D_INCONSISTENT &&
|
|
|
+ device->state.disk >= D_INCONSISTENT) {
|
|
|
if (ddsf & DDSF_NO_RESYNC)
|
|
|
- dev_info(DEV, "Resync of new storage suppressed with --assume-clean\n");
|
|
|
+ drbd_info(device, "Resync of new storage suppressed with --assume-clean\n");
|
|
|
else
|
|
|
- resync_after_online_grow(mdev);
|
|
|
+ resync_after_online_grow(device);
|
|
|
} else
|
|
|
- set_bit(RESYNC_AFTER_NEG, &mdev->flags);
|
|
|
+ set_bit(RESYNC_AFTER_NEG, &device->flags);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int receive_uuids(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int receive_uuids(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
- struct drbd_conf *mdev;
|
|
|
+ struct drbd_peer_device *peer_device;
|
|
|
+ struct drbd_device *device;
|
|
|
struct p_uuids *p = pi->data;
|
|
|
u64 *p_uuid;
|
|
|
int i, updated_uuids = 0;
|
|
|
|
|
|
- mdev = vnr_to_mdev(tconn, pi->vnr);
|
|
|
- if (!mdev)
|
|
|
- return config_unknown_volume(tconn, pi);
|
|
|
+ peer_device = conn_peer_device(connection, pi->vnr);
|
|
|
+ if (!peer_device)
|
|
|
+ return config_unknown_volume(connection, pi);
|
|
|
+ device = peer_device->device;
|
|
|
|
|
|
p_uuid = kmalloc(sizeof(u64)*UI_EXTENDED_SIZE, GFP_NOIO);
|
|
|
if (!p_uuid) {
|
|
|
- dev_err(DEV, "kmalloc of p_uuid failed\n");
|
|
|
+ drbd_err(device, "kmalloc of p_uuid failed\n");
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
for (i = UI_CURRENT; i < UI_EXTENDED_SIZE; i++)
|
|
|
p_uuid[i] = be64_to_cpu(p->uuid[i]);
|
|
|
|
|
|
- kfree(mdev->p_uuid);
|
|
|
- mdev->p_uuid = p_uuid;
|
|
|
+ kfree(device->p_uuid);
|
|
|
+ device->p_uuid = p_uuid;
|
|
|
|
|
|
- if (mdev->state.conn < C_CONNECTED &&
|
|
|
- mdev->state.disk < D_INCONSISTENT &&
|
|
|
- mdev->state.role == R_PRIMARY &&
|
|
|
- (mdev->ed_uuid & ~((u64)1)) != (p_uuid[UI_CURRENT] & ~((u64)1))) {
|
|
|
- dev_err(DEV, "Can only connect to data with current UUID=%016llX\n",
|
|
|
- (unsigned long long)mdev->ed_uuid);
|
|
|
- conn_request_state(mdev->tconn, NS(conn, C_DISCONNECTING), CS_HARD);
|
|
|
+ if (device->state.conn < C_CONNECTED &&
|
|
|
+ device->state.disk < D_INCONSISTENT &&
|
|
|
+ device->state.role == R_PRIMARY &&
|
|
|
+ (device->ed_uuid & ~((u64)1)) != (p_uuid[UI_CURRENT] & ~((u64)1))) {
|
|
|
+ drbd_err(device, "Can only connect to data with current UUID=%016llX\n",
|
|
|
+ (unsigned long long)device->ed_uuid);
|
|
|
+ conn_request_state(peer_device->connection, NS(conn, C_DISCONNECTING), CS_HARD);
|
|
|
return -EIO;
|
|
|
}
|
|
|
|
|
|
- if (get_ldev(mdev)) {
|
|
|
+ if (get_ldev(device)) {
|
|
|
int skip_initial_sync =
|
|
|
- mdev->state.conn == C_CONNECTED &&
|
|
|
- mdev->tconn->agreed_pro_version >= 90 &&
|
|
|
- mdev->ldev->md.uuid[UI_CURRENT] == UUID_JUST_CREATED &&
|
|
|
+ device->state.conn == C_CONNECTED &&
|
|
|
+ peer_device->connection->agreed_pro_version >= 90 &&
|
|
|
+ device->ldev->md.uuid[UI_CURRENT] == UUID_JUST_CREATED &&
|
|
|
(p_uuid[UI_FLAGS] & 8);
|
|
|
if (skip_initial_sync) {
|
|
|
- dev_info(DEV, "Accepted new current UUID, preparing to skip initial sync\n");
|
|
|
- drbd_bitmap_io(mdev, &drbd_bmio_clear_n_write,
|
|
|
+ drbd_info(device, "Accepted new current UUID, preparing to skip initial sync\n");
|
|
|
+ drbd_bitmap_io(device, &drbd_bmio_clear_n_write,
|
|
|
"clear_n_write from receive_uuids",
|
|
|
BM_LOCKED_TEST_ALLOWED);
|
|
|
- _drbd_uuid_set(mdev, UI_CURRENT, p_uuid[UI_CURRENT]);
|
|
|
- _drbd_uuid_set(mdev, UI_BITMAP, 0);
|
|
|
- _drbd_set_state(_NS2(mdev, disk, D_UP_TO_DATE, pdsk, D_UP_TO_DATE),
|
|
|
+ _drbd_uuid_set(device, UI_CURRENT, p_uuid[UI_CURRENT]);
|
|
|
+ _drbd_uuid_set(device, UI_BITMAP, 0);
|
|
|
+ _drbd_set_state(_NS2(device, disk, D_UP_TO_DATE, pdsk, D_UP_TO_DATE),
|
|
|
CS_VERBOSE, NULL);
|
|
|
- drbd_md_sync(mdev);
|
|
|
+ drbd_md_sync(device);
|
|
|
updated_uuids = 1;
|
|
|
}
|
|
|
- put_ldev(mdev);
|
|
|
- } else if (mdev->state.disk < D_INCONSISTENT &&
|
|
|
- mdev->state.role == R_PRIMARY) {
|
|
|
+ put_ldev(device);
|
|
|
+ } else if (device->state.disk < D_INCONSISTENT &&
|
|
|
+ device->state.role == R_PRIMARY) {
|
|
|
/* I am a diskless primary, the peer just created a new current UUID
|
|
|
for me. */
|
|
|
- updated_uuids = drbd_set_ed_uuid(mdev, p_uuid[UI_CURRENT]);
|
|
|
+ updated_uuids = drbd_set_ed_uuid(device, p_uuid[UI_CURRENT]);
|
|
|
}
|
|
|
|
|
|
/* Before we test for the disk state, we should wait until an eventually
|
|
|
ongoing cluster wide state change is finished. That is important if
|
|
|
we are primary and are detaching from our disk. We need to see the
|
|
|
new disk state... */
|
|
|
- mutex_lock(mdev->state_mutex);
|
|
|
- mutex_unlock(mdev->state_mutex);
|
|
|
- if (mdev->state.conn >= C_CONNECTED && mdev->state.disk < D_INCONSISTENT)
|
|
|
- updated_uuids |= drbd_set_ed_uuid(mdev, p_uuid[UI_CURRENT]);
|
|
|
+ mutex_lock(device->state_mutex);
|
|
|
+ mutex_unlock(device->state_mutex);
|
|
|
+ if (device->state.conn >= C_CONNECTED && device->state.disk < D_INCONSISTENT)
|
|
|
+ updated_uuids |= drbd_set_ed_uuid(device, p_uuid[UI_CURRENT]);
|
|
|
|
|
|
if (updated_uuids)
|
|
|
- drbd_print_uuids(mdev, "receiver updated UUIDs to");
|
|
|
+ drbd_print_uuids(device, "receiver updated UUIDs to");
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -3761,38 +3812,40 @@ static union drbd_state convert_state(union drbd_state ps)
|
|
|
return ms;
|
|
|
}
|
|
|
|
|
|
-static int receive_req_state(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int receive_req_state(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
- struct drbd_conf *mdev;
|
|
|
+ struct drbd_peer_device *peer_device;
|
|
|
+ struct drbd_device *device;
|
|
|
struct p_req_state *p = pi->data;
|
|
|
union drbd_state mask, val;
|
|
|
enum drbd_state_rv rv;
|
|
|
|
|
|
- mdev = vnr_to_mdev(tconn, pi->vnr);
|
|
|
- if (!mdev)
|
|
|
+ peer_device = conn_peer_device(connection, pi->vnr);
|
|
|
+ if (!peer_device)
|
|
|
return -EIO;
|
|
|
+ device = peer_device->device;
|
|
|
|
|
|
mask.i = be32_to_cpu(p->mask);
|
|
|
val.i = be32_to_cpu(p->val);
|
|
|
|
|
|
- if (test_bit(RESOLVE_CONFLICTS, &mdev->tconn->flags) &&
|
|
|
- mutex_is_locked(mdev->state_mutex)) {
|
|
|
- drbd_send_sr_reply(mdev, SS_CONCURRENT_ST_CHG);
|
|
|
+ if (test_bit(RESOLVE_CONFLICTS, &peer_device->connection->flags) &&
|
|
|
+ mutex_is_locked(device->state_mutex)) {
|
|
|
+ drbd_send_sr_reply(peer_device, SS_CONCURRENT_ST_CHG);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
mask = convert_state(mask);
|
|
|
val = convert_state(val);
|
|
|
|
|
|
- rv = drbd_change_state(mdev, CS_VERBOSE, mask, val);
|
|
|
- drbd_send_sr_reply(mdev, rv);
|
|
|
+ rv = drbd_change_state(device, CS_VERBOSE, mask, val);
|
|
|
+ drbd_send_sr_reply(peer_device, rv);
|
|
|
|
|
|
- drbd_md_sync(mdev);
|
|
|
+ drbd_md_sync(device);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int receive_req_conn_state(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int receive_req_conn_state(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
struct p_req_state *p = pi->data;
|
|
|
union drbd_state mask, val;
|
|
|
@@ -3801,46 +3854,48 @@ static int receive_req_conn_state(struct drbd_tconn *tconn, struct packet_info *
|
|
|
mask.i = be32_to_cpu(p->mask);
|
|
|
val.i = be32_to_cpu(p->val);
|
|
|
|
|
|
- if (test_bit(RESOLVE_CONFLICTS, &tconn->flags) &&
|
|
|
- mutex_is_locked(&tconn->cstate_mutex)) {
|
|
|
- conn_send_sr_reply(tconn, SS_CONCURRENT_ST_CHG);
|
|
|
+ if (test_bit(RESOLVE_CONFLICTS, &connection->flags) &&
|
|
|
+ mutex_is_locked(&connection->cstate_mutex)) {
|
|
|
+ conn_send_sr_reply(connection, SS_CONCURRENT_ST_CHG);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
mask = convert_state(mask);
|
|
|
val = convert_state(val);
|
|
|
|
|
|
- rv = conn_request_state(tconn, mask, val, CS_VERBOSE | CS_LOCAL_ONLY | CS_IGN_OUTD_FAIL);
|
|
|
- conn_send_sr_reply(tconn, rv);
|
|
|
+ rv = conn_request_state(connection, mask, val, CS_VERBOSE | CS_LOCAL_ONLY | CS_IGN_OUTD_FAIL);
|
|
|
+ conn_send_sr_reply(connection, rv);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int receive_state(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int receive_state(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
- struct drbd_conf *mdev;
|
|
|
+ struct drbd_peer_device *peer_device;
|
|
|
+ struct drbd_device *device;
|
|
|
struct p_state *p = pi->data;
|
|
|
union drbd_state os, ns, peer_state;
|
|
|
enum drbd_disk_state real_peer_disk;
|
|
|
enum chg_state_flags cs_flags;
|
|
|
int rv;
|
|
|
|
|
|
- mdev = vnr_to_mdev(tconn, pi->vnr);
|
|
|
- if (!mdev)
|
|
|
- return config_unknown_volume(tconn, pi);
|
|
|
+ peer_device = conn_peer_device(connection, pi->vnr);
|
|
|
+ if (!peer_device)
|
|
|
+ return config_unknown_volume(connection, pi);
|
|
|
+ device = peer_device->device;
|
|
|
|
|
|
peer_state.i = be32_to_cpu(p->state);
|
|
|
|
|
|
real_peer_disk = peer_state.disk;
|
|
|
if (peer_state.disk == D_NEGOTIATING) {
|
|
|
- real_peer_disk = mdev->p_uuid[UI_FLAGS] & 4 ? D_INCONSISTENT : D_CONSISTENT;
|
|
|
- dev_info(DEV, "real peer disk state = %s\n", drbd_disk_str(real_peer_disk));
|
|
|
+ real_peer_disk = device->p_uuid[UI_FLAGS] & 4 ? D_INCONSISTENT : D_CONSISTENT;
|
|
|
+ drbd_info(device, "real peer disk state = %s\n", drbd_disk_str(real_peer_disk));
|
|
|
}
|
|
|
|
|
|
- spin_lock_irq(&mdev->tconn->req_lock);
|
|
|
+ spin_lock_irq(&device->resource->req_lock);
|
|
|
retry:
|
|
|
- os = ns = drbd_read_state(mdev);
|
|
|
- spin_unlock_irq(&mdev->tconn->req_lock);
|
|
|
+ os = ns = drbd_read_state(device);
|
|
|
+ spin_unlock_irq(&device->resource->req_lock);
|
|
|
|
|
|
/* If some other part of the code (asender thread, timeout)
|
|
|
* already decided to close the connection again,
|
|
|
@@ -3872,8 +3927,8 @@ static int receive_state(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
* Maybe we should finish it up, too? */
|
|
|
else if (os.conn >= C_SYNC_SOURCE &&
|
|
|
peer_state.conn == C_CONNECTED) {
|
|
|
- if (drbd_bm_total_weight(mdev) <= mdev->rs_failed)
|
|
|
- drbd_resync_finished(mdev);
|
|
|
+ if (drbd_bm_total_weight(device) <= device->rs_failed)
|
|
|
+ drbd_resync_finished(device);
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
@@ -3881,8 +3936,8 @@ static int receive_state(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
/* explicit verify finished notification, stop sector reached. */
|
|
|
if (os.conn == C_VERIFY_T && os.disk == D_UP_TO_DATE &&
|
|
|
peer_state.conn == C_CONNECTED && real_peer_disk == D_UP_TO_DATE) {
|
|
|
- ov_out_of_sync_print(mdev);
|
|
|
- drbd_resync_finished(mdev);
|
|
|
+ ov_out_of_sync_print(device);
|
|
|
+ drbd_resync_finished(device);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
@@ -3901,8 +3956,8 @@ static int receive_state(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
if (peer_state.conn == C_AHEAD)
|
|
|
ns.conn = C_BEHIND;
|
|
|
|
|
|
- if (mdev->p_uuid && peer_state.disk >= D_NEGOTIATING &&
|
|
|
- get_ldev_if_state(mdev, D_NEGOTIATING)) {
|
|
|
+ if (device->p_uuid && peer_state.disk >= D_NEGOTIATING &&
|
|
|
+ get_ldev_if_state(device, D_NEGOTIATING)) {
|
|
|
int cr; /* consider resync */
|
|
|
|
|
|
/* if we established a new connection */
|
|
|
@@ -3914,7 +3969,7 @@ static int receive_state(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
os.disk == D_NEGOTIATING));
|
|
|
/* if we have both been inconsistent, and the peer has been
|
|
|
* forced to be UpToDate with --overwrite-data */
|
|
|
- cr |= test_bit(CONSIDER_RESYNC, &mdev->flags);
|
|
|
+ cr |= test_bit(CONSIDER_RESYNC, &device->flags);
|
|
|
/* if we had been plain connected, and the admin requested to
|
|
|
* start a sync by "invalidate" or "invalidate-remote" */
|
|
|
cr |= (os.conn == C_CONNECTED &&
|
|
|
@@ -3922,55 +3977,55 @@ static int receive_state(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
peer_state.conn <= C_WF_BITMAP_T));
|
|
|
|
|
|
if (cr)
|
|
|
- ns.conn = drbd_sync_handshake(mdev, peer_state.role, real_peer_disk);
|
|
|
+ ns.conn = drbd_sync_handshake(peer_device, peer_state.role, real_peer_disk);
|
|
|
|
|
|
- put_ldev(mdev);
|
|
|
+ put_ldev(device);
|
|
|
if (ns.conn == C_MASK) {
|
|
|
ns.conn = C_CONNECTED;
|
|
|
- if (mdev->state.disk == D_NEGOTIATING) {
|
|
|
- drbd_force_state(mdev, NS(disk, D_FAILED));
|
|
|
+ if (device->state.disk == D_NEGOTIATING) {
|
|
|
+ drbd_force_state(device, NS(disk, D_FAILED));
|
|
|
} else if (peer_state.disk == D_NEGOTIATING) {
|
|
|
- dev_err(DEV, "Disk attach process on the peer node was aborted.\n");
|
|
|
+ drbd_err(device, "Disk attach process on the peer node was aborted.\n");
|
|
|
peer_state.disk = D_DISKLESS;
|
|
|
real_peer_disk = D_DISKLESS;
|
|
|
} else {
|
|
|
- if (test_and_clear_bit(CONN_DRY_RUN, &mdev->tconn->flags))
|
|
|
+ if (test_and_clear_bit(CONN_DRY_RUN, &peer_device->connection->flags))
|
|
|
return -EIO;
|
|
|
- D_ASSERT(os.conn == C_WF_REPORT_PARAMS);
|
|
|
- conn_request_state(mdev->tconn, NS(conn, C_DISCONNECTING), CS_HARD);
|
|
|
+ D_ASSERT(device, os.conn == C_WF_REPORT_PARAMS);
|
|
|
+ conn_request_state(peer_device->connection, NS(conn, C_DISCONNECTING), CS_HARD);
|
|
|
return -EIO;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- spin_lock_irq(&mdev->tconn->req_lock);
|
|
|
- if (os.i != drbd_read_state(mdev).i)
|
|
|
+ spin_lock_irq(&device->resource->req_lock);
|
|
|
+ if (os.i != drbd_read_state(device).i)
|
|
|
goto retry;
|
|
|
- clear_bit(CONSIDER_RESYNC, &mdev->flags);
|
|
|
+ clear_bit(CONSIDER_RESYNC, &device->flags);
|
|
|
ns.peer = peer_state.role;
|
|
|
ns.pdsk = real_peer_disk;
|
|
|
ns.peer_isp = (peer_state.aftr_isp | peer_state.user_isp);
|
|
|
if ((ns.conn == C_CONNECTED || ns.conn == C_WF_BITMAP_S) && ns.disk == D_NEGOTIATING)
|
|
|
- ns.disk = mdev->new_state_tmp.disk;
|
|
|
+ ns.disk = device->new_state_tmp.disk;
|
|
|
cs_flags = CS_VERBOSE + (os.conn < C_CONNECTED && ns.conn >= C_CONNECTED ? 0 : CS_HARD);
|
|
|
- if (ns.pdsk == D_CONSISTENT && drbd_suspended(mdev) && ns.conn == C_CONNECTED && os.conn < C_CONNECTED &&
|
|
|
- test_bit(NEW_CUR_UUID, &mdev->flags)) {
|
|
|
+ if (ns.pdsk == D_CONSISTENT && drbd_suspended(device) && ns.conn == C_CONNECTED && os.conn < C_CONNECTED &&
|
|
|
+ test_bit(NEW_CUR_UUID, &device->flags)) {
|
|
|
/* Do not allow tl_restart(RESEND) for a rebooted peer. We can only allow this
|
|
|
for temporal network outages! */
|
|
|
- spin_unlock_irq(&mdev->tconn->req_lock);
|
|
|
- dev_err(DEV, "Aborting Connect, can not thaw IO with an only Consistent peer\n");
|
|
|
- tl_clear(mdev->tconn);
|
|
|
- drbd_uuid_new_current(mdev);
|
|
|
- clear_bit(NEW_CUR_UUID, &mdev->flags);
|
|
|
- conn_request_state(mdev->tconn, NS2(conn, C_PROTOCOL_ERROR, susp, 0), CS_HARD);
|
|
|
+ spin_unlock_irq(&device->resource->req_lock);
|
|
|
+ drbd_err(device, "Aborting Connect, can not thaw IO with an only Consistent peer\n");
|
|
|
+ tl_clear(peer_device->connection);
|
|
|
+ drbd_uuid_new_current(device);
|
|
|
+ clear_bit(NEW_CUR_UUID, &device->flags);
|
|
|
+ conn_request_state(peer_device->connection, NS2(conn, C_PROTOCOL_ERROR, susp, 0), CS_HARD);
|
|
|
return -EIO;
|
|
|
}
|
|
|
- rv = _drbd_set_state(mdev, ns, cs_flags, NULL);
|
|
|
- ns = drbd_read_state(mdev);
|
|
|
- spin_unlock_irq(&mdev->tconn->req_lock);
|
|
|
+ rv = _drbd_set_state(device, ns, cs_flags, NULL);
|
|
|
+ ns = drbd_read_state(device);
|
|
|
+ spin_unlock_irq(&device->resource->req_lock);
|
|
|
|
|
|
if (rv < SS_SUCCESS) {
|
|
|
- conn_request_state(mdev->tconn, NS(conn, C_DISCONNECTING), CS_HARD);
|
|
|
+ conn_request_state(peer_device->connection, NS(conn, C_DISCONNECTING), CS_HARD);
|
|
|
return -EIO;
|
|
|
}
|
|
|
|
|
|
@@ -3980,47 +4035,49 @@ static int receive_state(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
/* we want resync, peer has not yet decided to sync... */
|
|
|
/* Nowadays only used when forcing a node into primary role and
|
|
|
setting its disk to UpToDate with that */
|
|
|
- drbd_send_uuids(mdev);
|
|
|
- drbd_send_current_state(mdev);
|
|
|
+ drbd_send_uuids(peer_device);
|
|
|
+ drbd_send_current_state(peer_device);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- clear_bit(DISCARD_MY_DATA, &mdev->flags);
|
|
|
+ clear_bit(DISCARD_MY_DATA, &device->flags);
|
|
|
|
|
|
- drbd_md_sync(mdev); /* update connected indicator, la_size_sect, ... */
|
|
|
+ drbd_md_sync(device); /* update connected indicator, la_size_sect, ... */
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int receive_sync_uuid(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int receive_sync_uuid(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
- struct drbd_conf *mdev;
|
|
|
+ struct drbd_peer_device *peer_device;
|
|
|
+ struct drbd_device *device;
|
|
|
struct p_rs_uuid *p = pi->data;
|
|
|
|
|
|
- mdev = vnr_to_mdev(tconn, pi->vnr);
|
|
|
- if (!mdev)
|
|
|
+ peer_device = conn_peer_device(connection, pi->vnr);
|
|
|
+ if (!peer_device)
|
|
|
return -EIO;
|
|
|
+ device = peer_device->device;
|
|
|
|
|
|
- wait_event(mdev->misc_wait,
|
|
|
- mdev->state.conn == C_WF_SYNC_UUID ||
|
|
|
- mdev->state.conn == C_BEHIND ||
|
|
|
- mdev->state.conn < C_CONNECTED ||
|
|
|
- mdev->state.disk < D_NEGOTIATING);
|
|
|
+ wait_event(device->misc_wait,
|
|
|
+ device->state.conn == C_WF_SYNC_UUID ||
|
|
|
+ device->state.conn == C_BEHIND ||
|
|
|
+ device->state.conn < C_CONNECTED ||
|
|
|
+ device->state.disk < D_NEGOTIATING);
|
|
|
|
|
|
- /* D_ASSERT( mdev->state.conn == C_WF_SYNC_UUID ); */
|
|
|
+ /* D_ASSERT(device, device->state.conn == C_WF_SYNC_UUID ); */
|
|
|
|
|
|
/* Here the _drbd_uuid_ functions are right, current should
|
|
|
_not_ be rotated into the history */
|
|
|
- if (get_ldev_if_state(mdev, D_NEGOTIATING)) {
|
|
|
- _drbd_uuid_set(mdev, UI_CURRENT, be64_to_cpu(p->uuid));
|
|
|
- _drbd_uuid_set(mdev, UI_BITMAP, 0UL);
|
|
|
+ if (get_ldev_if_state(device, D_NEGOTIATING)) {
|
|
|
+ _drbd_uuid_set(device, UI_CURRENT, be64_to_cpu(p->uuid));
|
|
|
+ _drbd_uuid_set(device, UI_BITMAP, 0UL);
|
|
|
|
|
|
- drbd_print_uuids(mdev, "updated sync uuid");
|
|
|
- drbd_start_resync(mdev, C_SYNC_TARGET);
|
|
|
+ drbd_print_uuids(device, "updated sync uuid");
|
|
|
+ drbd_start_resync(device, C_SYNC_TARGET);
|
|
|
|
|
|
- put_ldev(mdev);
|
|
|
+ put_ldev(device);
|
|
|
} else
|
|
|
- dev_err(DEV, "Ignoring SyncUUID packet!\n");
|
|
|
+ drbd_err(device, "Ignoring SyncUUID packet!\n");
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -4032,27 +4089,27 @@ static int receive_sync_uuid(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
* code upon failure.
|
|
|
*/
|
|
|
static int
|
|
|
-receive_bitmap_plain(struct drbd_conf *mdev, unsigned int size,
|
|
|
+receive_bitmap_plain(struct drbd_peer_device *peer_device, unsigned int size,
|
|
|
unsigned long *p, struct bm_xfer_ctx *c)
|
|
|
{
|
|
|
unsigned int data_size = DRBD_SOCKET_BUFFER_SIZE -
|
|
|
- drbd_header_size(mdev->tconn);
|
|
|
+ drbd_header_size(peer_device->connection);
|
|
|
unsigned int num_words = min_t(size_t, data_size / sizeof(*p),
|
|
|
c->bm_words - c->word_offset);
|
|
|
unsigned int want = num_words * sizeof(*p);
|
|
|
int err;
|
|
|
|
|
|
if (want != size) {
|
|
|
- dev_err(DEV, "%s:want (%u) != size (%u)\n", __func__, want, size);
|
|
|
+ drbd_err(peer_device, "%s:want (%u) != size (%u)\n", __func__, want, size);
|
|
|
return -EIO;
|
|
|
}
|
|
|
if (want == 0)
|
|
|
return 0;
|
|
|
- err = drbd_recv_all(mdev->tconn, p, want);
|
|
|
+ err = drbd_recv_all(peer_device->connection, p, want);
|
|
|
if (err)
|
|
|
return err;
|
|
|
|
|
|
- drbd_bm_merge_lel(mdev, c->word_offset, num_words, p);
|
|
|
+ drbd_bm_merge_lel(peer_device->device, c->word_offset, num_words, p);
|
|
|
|
|
|
c->word_offset += num_words;
|
|
|
c->bit_offset = c->word_offset * BITS_PER_LONG;
|
|
|
@@ -4084,7 +4141,7 @@ static int dcbp_get_pad_bits(struct p_compressed_bm *p)
|
|
|
* code upon failure.
|
|
|
*/
|
|
|
static int
|
|
|
-recv_bm_rle_bits(struct drbd_conf *mdev,
|
|
|
+recv_bm_rle_bits(struct drbd_peer_device *peer_device,
|
|
|
struct p_compressed_bm *p,
|
|
|
struct bm_xfer_ctx *c,
|
|
|
unsigned int len)
|
|
|
@@ -4113,14 +4170,14 @@ recv_bm_rle_bits(struct drbd_conf *mdev,
|
|
|
if (toggle) {
|
|
|
e = s + rl -1;
|
|
|
if (e >= c->bm_bits) {
|
|
|
- dev_err(DEV, "bitmap overflow (e:%lu) while decoding bm RLE packet\n", e);
|
|
|
+ drbd_err(peer_device, "bitmap overflow (e:%lu) while decoding bm RLE packet\n", e);
|
|
|
return -EIO;
|
|
|
}
|
|
|
- _drbd_bm_set_bits(mdev, s, e);
|
|
|
+ _drbd_bm_set_bits(peer_device->device, s, e);
|
|
|
}
|
|
|
|
|
|
if (have < bits) {
|
|
|
- dev_err(DEV, "bitmap decoding error: h:%d b:%d la:0x%08llx l:%u/%u\n",
|
|
|
+ drbd_err(peer_device, "bitmap decoding error: h:%d b:%d la:0x%08llx l:%u/%u\n",
|
|
|
have, bits, look_ahead,
|
|
|
(unsigned int)(bs.cur.b - p->code),
|
|
|
(unsigned int)bs.buf_len);
|
|
|
@@ -4153,28 +4210,28 @@ recv_bm_rle_bits(struct drbd_conf *mdev,
|
|
|
* code upon failure.
|
|
|
*/
|
|
|
static int
|
|
|
-decode_bitmap_c(struct drbd_conf *mdev,
|
|
|
+decode_bitmap_c(struct drbd_peer_device *peer_device,
|
|
|
struct p_compressed_bm *p,
|
|
|
struct bm_xfer_ctx *c,
|
|
|
unsigned int len)
|
|
|
{
|
|
|
if (dcbp_get_code(p) == RLE_VLI_Bits)
|
|
|
- return recv_bm_rle_bits(mdev, p, c, len - sizeof(*p));
|
|
|
+ return recv_bm_rle_bits(peer_device, p, c, len - sizeof(*p));
|
|
|
|
|
|
/* other variants had been implemented for evaluation,
|
|
|
* but have been dropped as this one turned out to be "best"
|
|
|
* during all our tests. */
|
|
|
|
|
|
- dev_err(DEV, "receive_bitmap_c: unknown encoding %u\n", p->encoding);
|
|
|
- conn_request_state(mdev->tconn, NS(conn, C_PROTOCOL_ERROR), CS_HARD);
|
|
|
+ drbd_err(peer_device, "receive_bitmap_c: unknown encoding %u\n", p->encoding);
|
|
|
+ conn_request_state(peer_device->connection, NS(conn, C_PROTOCOL_ERROR), CS_HARD);
|
|
|
return -EIO;
|
|
|
}
|
|
|
|
|
|
-void INFO_bm_xfer_stats(struct drbd_conf *mdev,
|
|
|
+void INFO_bm_xfer_stats(struct drbd_device *device,
|
|
|
const char *direction, struct bm_xfer_ctx *c)
|
|
|
{
|
|
|
/* what would it take to transfer it "plaintext" */
|
|
|
- unsigned int header_size = drbd_header_size(mdev->tconn);
|
|
|
+ unsigned int header_size = drbd_header_size(first_peer_device(device)->connection);
|
|
|
unsigned int data_size = DRBD_SOCKET_BUFFER_SIZE - header_size;
|
|
|
unsigned int plain =
|
|
|
header_size * (DIV_ROUND_UP(c->bm_words, data_size) + 1) +
|
|
|
@@ -4198,7 +4255,7 @@ void INFO_bm_xfer_stats(struct drbd_conf *mdev,
|
|
|
r = 1000;
|
|
|
|
|
|
r = 1000 - r;
|
|
|
- dev_info(DEV, "%s bitmap stats [Bytes(packets)]: plain %u(%u), RLE %u(%u), "
|
|
|
+ drbd_info(device, "%s bitmap stats [Bytes(packets)]: plain %u(%u), RLE %u(%u), "
|
|
|
"total %u; compression: %u.%u%%\n",
|
|
|
direction,
|
|
|
c->bytes[1], c->packets[1],
|
|
|
@@ -4214,129 +4271,133 @@ void INFO_bm_xfer_stats(struct drbd_conf *mdev,
|
|
|
in order to be agnostic to the 32 vs 64 bits issue.
|
|
|
|
|
|
returns 0 on failure, 1 if we successfully received it. */
|
|
|
-static int receive_bitmap(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int receive_bitmap(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
- struct drbd_conf *mdev;
|
|
|
+ struct drbd_peer_device *peer_device;
|
|
|
+ struct drbd_device *device;
|
|
|
struct bm_xfer_ctx c;
|
|
|
int err;
|
|
|
|
|
|
- mdev = vnr_to_mdev(tconn, pi->vnr);
|
|
|
- if (!mdev)
|
|
|
+ peer_device = conn_peer_device(connection, pi->vnr);
|
|
|
+ if (!peer_device)
|
|
|
return -EIO;
|
|
|
+ device = peer_device->device;
|
|
|
|
|
|
- drbd_bm_lock(mdev, "receive bitmap", BM_LOCKED_SET_ALLOWED);
|
|
|
+ drbd_bm_lock(device, "receive bitmap", BM_LOCKED_SET_ALLOWED);
|
|
|
/* you are supposed to send additional out-of-sync information
|
|
|
* if you actually set bits during this phase */
|
|
|
|
|
|
c = (struct bm_xfer_ctx) {
|
|
|
- .bm_bits = drbd_bm_bits(mdev),
|
|
|
- .bm_words = drbd_bm_words(mdev),
|
|
|
+ .bm_bits = drbd_bm_bits(device),
|
|
|
+ .bm_words = drbd_bm_words(device),
|
|
|
};
|
|
|
|
|
|
for(;;) {
|
|
|
if (pi->cmd == P_BITMAP)
|
|
|
- err = receive_bitmap_plain(mdev, pi->size, pi->data, &c);
|
|
|
+ err = receive_bitmap_plain(peer_device, pi->size, pi->data, &c);
|
|
|
else if (pi->cmd == P_COMPRESSED_BITMAP) {
|
|
|
/* MAYBE: sanity check that we speak proto >= 90,
|
|
|
* and the feature is enabled! */
|
|
|
struct p_compressed_bm *p = pi->data;
|
|
|
|
|
|
- if (pi->size > DRBD_SOCKET_BUFFER_SIZE - drbd_header_size(tconn)) {
|
|
|
- dev_err(DEV, "ReportCBitmap packet too large\n");
|
|
|
+ if (pi->size > DRBD_SOCKET_BUFFER_SIZE - drbd_header_size(connection)) {
|
|
|
+ drbd_err(device, "ReportCBitmap packet too large\n");
|
|
|
err = -EIO;
|
|
|
goto out;
|
|
|
}
|
|
|
if (pi->size <= sizeof(*p)) {
|
|
|
- dev_err(DEV, "ReportCBitmap packet too small (l:%u)\n", pi->size);
|
|
|
+ drbd_err(device, "ReportCBitmap packet too small (l:%u)\n", pi->size);
|
|
|
err = -EIO;
|
|
|
goto out;
|
|
|
}
|
|
|
- err = drbd_recv_all(mdev->tconn, p, pi->size);
|
|
|
+ err = drbd_recv_all(peer_device->connection, p, pi->size);
|
|
|
if (err)
|
|
|
goto out;
|
|
|
- err = decode_bitmap_c(mdev, p, &c, pi->size);
|
|
|
+ err = decode_bitmap_c(peer_device, p, &c, pi->size);
|
|
|
} else {
|
|
|
- dev_warn(DEV, "receive_bitmap: cmd neither ReportBitMap nor ReportCBitMap (is 0x%x)", pi->cmd);
|
|
|
+ drbd_warn(device, "receive_bitmap: cmd neither ReportBitMap nor ReportCBitMap (is 0x%x)", pi->cmd);
|
|
|
err = -EIO;
|
|
|
goto out;
|
|
|
}
|
|
|
|
|
|
c.packets[pi->cmd == P_BITMAP]++;
|
|
|
- c.bytes[pi->cmd == P_BITMAP] += drbd_header_size(tconn) + pi->size;
|
|
|
+ c.bytes[pi->cmd == P_BITMAP] += drbd_header_size(connection) + pi->size;
|
|
|
|
|
|
if (err <= 0) {
|
|
|
if (err < 0)
|
|
|
goto out;
|
|
|
break;
|
|
|
}
|
|
|
- err = drbd_recv_header(mdev->tconn, pi);
|
|
|
+ err = drbd_recv_header(peer_device->connection, pi);
|
|
|
if (err)
|
|
|
goto out;
|
|
|
}
|
|
|
|
|
|
- INFO_bm_xfer_stats(mdev, "receive", &c);
|
|
|
+ INFO_bm_xfer_stats(device, "receive", &c);
|
|
|
|
|
|
- if (mdev->state.conn == C_WF_BITMAP_T) {
|
|
|
+ if (device->state.conn == C_WF_BITMAP_T) {
|
|
|
enum drbd_state_rv rv;
|
|
|
|
|
|
- err = drbd_send_bitmap(mdev);
|
|
|
+ err = drbd_send_bitmap(device);
|
|
|
if (err)
|
|
|
goto out;
|
|
|
/* Omit CS_ORDERED with this state transition to avoid deadlocks. */
|
|
|
- rv = _drbd_request_state(mdev, NS(conn, C_WF_SYNC_UUID), CS_VERBOSE);
|
|
|
- D_ASSERT(rv == SS_SUCCESS);
|
|
|
- } else if (mdev->state.conn != C_WF_BITMAP_S) {
|
|
|
+ rv = _drbd_request_state(device, NS(conn, C_WF_SYNC_UUID), CS_VERBOSE);
|
|
|
+ D_ASSERT(device, rv == SS_SUCCESS);
|
|
|
+ } else if (device->state.conn != C_WF_BITMAP_S) {
|
|
|
/* admin may have requested C_DISCONNECTING,
|
|
|
* other threads may have noticed network errors */
|
|
|
- dev_info(DEV, "unexpected cstate (%s) in receive_bitmap\n",
|
|
|
- drbd_conn_str(mdev->state.conn));
|
|
|
+ drbd_info(device, "unexpected cstate (%s) in receive_bitmap\n",
|
|
|
+ drbd_conn_str(device->state.conn));
|
|
|
}
|
|
|
err = 0;
|
|
|
|
|
|
out:
|
|
|
- drbd_bm_unlock(mdev);
|
|
|
- if (!err && mdev->state.conn == C_WF_BITMAP_S)
|
|
|
- drbd_start_resync(mdev, C_SYNC_SOURCE);
|
|
|
+ drbd_bm_unlock(device);
|
|
|
+ if (!err && device->state.conn == C_WF_BITMAP_S)
|
|
|
+ drbd_start_resync(device, C_SYNC_SOURCE);
|
|
|
return err;
|
|
|
}
|
|
|
|
|
|
-static int receive_skip(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int receive_skip(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
- conn_warn(tconn, "skipping unknown optional packet type %d, l: %d!\n",
|
|
|
+ drbd_warn(connection, "skipping unknown optional packet type %d, l: %d!\n",
|
|
|
pi->cmd, pi->size);
|
|
|
|
|
|
- return ignore_remaining_packet(tconn, pi);
|
|
|
+ return ignore_remaining_packet(connection, pi);
|
|
|
}
|
|
|
|
|
|
-static int receive_UnplugRemote(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int receive_UnplugRemote(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
/* Make sure we've acked all the TCP data associated
|
|
|
* with the data requests being unplugged */
|
|
|
- drbd_tcp_quickack(tconn->data.socket);
|
|
|
+ drbd_tcp_quickack(connection->data.socket);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int receive_out_of_sync(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int receive_out_of_sync(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
- struct drbd_conf *mdev;
|
|
|
+ struct drbd_peer_device *peer_device;
|
|
|
+ struct drbd_device *device;
|
|
|
struct p_block_desc *p = pi->data;
|
|
|
|
|
|
- mdev = vnr_to_mdev(tconn, pi->vnr);
|
|
|
- if (!mdev)
|
|
|
+ peer_device = conn_peer_device(connection, pi->vnr);
|
|
|
+ if (!peer_device)
|
|
|
return -EIO;
|
|
|
+ device = peer_device->device;
|
|
|
|
|
|
- switch (mdev->state.conn) {
|
|
|
+ switch (device->state.conn) {
|
|
|
case C_WF_SYNC_UUID:
|
|
|
case C_WF_BITMAP_T:
|
|
|
case C_BEHIND:
|
|
|
break;
|
|
|
default:
|
|
|
- dev_err(DEV, "ASSERT FAILED cstate = %s, expected: WFSyncUUID|WFBitMapT|Behind\n",
|
|
|
- drbd_conn_str(mdev->state.conn));
|
|
|
+ drbd_err(device, "ASSERT FAILED cstate = %s, expected: WFSyncUUID|WFBitMapT|Behind\n",
|
|
|
+ drbd_conn_str(device->state.conn));
|
|
|
}
|
|
|
|
|
|
- drbd_set_out_of_sync(mdev, be64_to_cpu(p->sector), be32_to_cpu(p->blksize));
|
|
|
+ drbd_set_out_of_sync(device, be64_to_cpu(p->sector), be32_to_cpu(p->blksize));
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -4344,7 +4405,7 @@ static int receive_out_of_sync(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
struct data_cmd {
|
|
|
int expect_payload;
|
|
|
size_t pkt_size;
|
|
|
- int (*fn)(struct drbd_tconn *, struct packet_info *);
|
|
|
+ int (*fn)(struct drbd_connection *, struct packet_info *);
|
|
|
};
|
|
|
|
|
|
static struct data_cmd drbd_cmd_handler[] = {
|
|
|
@@ -4374,43 +4435,43 @@ static struct data_cmd drbd_cmd_handler[] = {
|
|
|
[P_PROTOCOL_UPDATE] = { 1, sizeof(struct p_protocol), receive_protocol },
|
|
|
};
|
|
|
|
|
|
-static void drbdd(struct drbd_tconn *tconn)
|
|
|
+static void drbdd(struct drbd_connection *connection)
|
|
|
{
|
|
|
struct packet_info pi;
|
|
|
size_t shs; /* sub header size */
|
|
|
int err;
|
|
|
|
|
|
- while (get_t_state(&tconn->receiver) == RUNNING) {
|
|
|
+ while (get_t_state(&connection->receiver) == RUNNING) {
|
|
|
struct data_cmd *cmd;
|
|
|
|
|
|
- drbd_thread_current_set_cpu(&tconn->receiver);
|
|
|
- if (drbd_recv_header(tconn, &pi))
|
|
|
+ drbd_thread_current_set_cpu(&connection->receiver);
|
|
|
+ if (drbd_recv_header(connection, &pi))
|
|
|
goto err_out;
|
|
|
|
|
|
cmd = &drbd_cmd_handler[pi.cmd];
|
|
|
if (unlikely(pi.cmd >= ARRAY_SIZE(drbd_cmd_handler) || !cmd->fn)) {
|
|
|
- conn_err(tconn, "Unexpected data packet %s (0x%04x)",
|
|
|
+ drbd_err(connection, "Unexpected data packet %s (0x%04x)",
|
|
|
cmdname(pi.cmd), pi.cmd);
|
|
|
goto err_out;
|
|
|
}
|
|
|
|
|
|
shs = cmd->pkt_size;
|
|
|
if (pi.size > shs && !cmd->expect_payload) {
|
|
|
- conn_err(tconn, "No payload expected %s l:%d\n",
|
|
|
+ drbd_err(connection, "No payload expected %s l:%d\n",
|
|
|
cmdname(pi.cmd), pi.size);
|
|
|
goto err_out;
|
|
|
}
|
|
|
|
|
|
if (shs) {
|
|
|
- err = drbd_recv_all_warn(tconn, pi.data, shs);
|
|
|
+ err = drbd_recv_all_warn(connection, pi.data, shs);
|
|
|
if (err)
|
|
|
goto err_out;
|
|
|
pi.size -= shs;
|
|
|
}
|
|
|
|
|
|
- err = cmd->fn(tconn, &pi);
|
|
|
+ err = cmd->fn(connection, &pi);
|
|
|
if (err) {
|
|
|
- conn_err(tconn, "error receiving %s, e: %d l: %d!\n",
|
|
|
+ drbd_err(connection, "error receiving %s, e: %d l: %d!\n",
|
|
|
cmdname(pi.cmd), err, pi.size);
|
|
|
goto err_out;
|
|
|
}
|
|
|
@@ -4418,27 +4479,16 @@ static void drbdd(struct drbd_tconn *tconn)
|
|
|
return;
|
|
|
|
|
|
err_out:
|
|
|
- conn_request_state(tconn, NS(conn, C_PROTOCOL_ERROR), CS_HARD);
|
|
|
-}
|
|
|
-
|
|
|
-void conn_flush_workqueue(struct drbd_tconn *tconn)
|
|
|
-{
|
|
|
- struct drbd_wq_barrier barr;
|
|
|
-
|
|
|
- barr.w.cb = w_prev_work_done;
|
|
|
- barr.w.tconn = tconn;
|
|
|
- init_completion(&barr.done);
|
|
|
- drbd_queue_work(&tconn->sender_work, &barr.w);
|
|
|
- wait_for_completion(&barr.done);
|
|
|
+ conn_request_state(connection, NS(conn, C_PROTOCOL_ERROR), CS_HARD);
|
|
|
}
|
|
|
|
|
|
-static void conn_disconnect(struct drbd_tconn *tconn)
|
|
|
+static void conn_disconnect(struct drbd_connection *connection)
|
|
|
{
|
|
|
- struct drbd_conf *mdev;
|
|
|
+ struct drbd_peer_device *peer_device;
|
|
|
enum drbd_conns oc;
|
|
|
int vnr;
|
|
|
|
|
|
- if (tconn->cstate == C_STANDALONE)
|
|
|
+ if (connection->cstate == C_STANDALONE)
|
|
|
return;
|
|
|
|
|
|
/* We are about to start the cleanup after connection loss.
|
|
|
@@ -4446,54 +4496,56 @@ static void conn_disconnect(struct drbd_tconn *tconn)
|
|
|
* Usually we should be in some network failure state already,
|
|
|
* but just in case we are not, we fix it up here.
|
|
|
*/
|
|
|
- conn_request_state(tconn, NS(conn, C_NETWORK_FAILURE), CS_HARD);
|
|
|
+ conn_request_state(connection, NS(conn, C_NETWORK_FAILURE), CS_HARD);
|
|
|
|
|
|
/* asender does not clean up anything. it must not interfere, either */
|
|
|
- drbd_thread_stop(&tconn->asender);
|
|
|
- drbd_free_sock(tconn);
|
|
|
+ drbd_thread_stop(&connection->asender);
|
|
|
+ drbd_free_sock(connection);
|
|
|
|
|
|
rcu_read_lock();
|
|
|
- idr_for_each_entry(&tconn->volumes, mdev, vnr) {
|
|
|
- kref_get(&mdev->kref);
|
|
|
+ idr_for_each_entry(&connection->peer_devices, peer_device, vnr) {
|
|
|
+ struct drbd_device *device = peer_device->device;
|
|
|
+ kref_get(&device->kref);
|
|
|
rcu_read_unlock();
|
|
|
- drbd_disconnected(mdev);
|
|
|
- kref_put(&mdev->kref, &drbd_minor_destroy);
|
|
|
+ drbd_disconnected(peer_device);
|
|
|
+ kref_put(&device->kref, drbd_destroy_device);
|
|
|
rcu_read_lock();
|
|
|
}
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
- if (!list_empty(&tconn->current_epoch->list))
|
|
|
- conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
|
|
|
+ if (!list_empty(&connection->current_epoch->list))
|
|
|
+ drbd_err(connection, "ASSERTION FAILED: connection->current_epoch->list not empty\n");
|
|
|
/* ok, no more ee's on the fly, it is safe to reset the epoch_size */
|
|
|
- atomic_set(&tconn->current_epoch->epoch_size, 0);
|
|
|
- tconn->send.seen_any_write_yet = false;
|
|
|
+ atomic_set(&connection->current_epoch->epoch_size, 0);
|
|
|
+ connection->send.seen_any_write_yet = false;
|
|
|
|
|
|
- conn_info(tconn, "Connection closed\n");
|
|
|
+ drbd_info(connection, "Connection closed\n");
|
|
|
|
|
|
- if (conn_highest_role(tconn) == R_PRIMARY && conn_highest_pdsk(tconn) >= D_UNKNOWN)
|
|
|
- conn_try_outdate_peer_async(tconn);
|
|
|
+ if (conn_highest_role(connection) == R_PRIMARY && conn_highest_pdsk(connection) >= D_UNKNOWN)
|
|
|
+ conn_try_outdate_peer_async(connection);
|
|
|
|
|
|
- spin_lock_irq(&tconn->req_lock);
|
|
|
- oc = tconn->cstate;
|
|
|
+ spin_lock_irq(&connection->resource->req_lock);
|
|
|
+ oc = connection->cstate;
|
|
|
if (oc >= C_UNCONNECTED)
|
|
|
- _conn_request_state(tconn, NS(conn, C_UNCONNECTED), CS_VERBOSE);
|
|
|
+ _conn_request_state(connection, NS(conn, C_UNCONNECTED), CS_VERBOSE);
|
|
|
|
|
|
- spin_unlock_irq(&tconn->req_lock);
|
|
|
+ spin_unlock_irq(&connection->resource->req_lock);
|
|
|
|
|
|
if (oc == C_DISCONNECTING)
|
|
|
- conn_request_state(tconn, NS(conn, C_STANDALONE), CS_VERBOSE | CS_HARD);
|
|
|
+ conn_request_state(connection, NS(conn, C_STANDALONE), CS_VERBOSE | CS_HARD);
|
|
|
}
|
|
|
|
|
|
-static int drbd_disconnected(struct drbd_conf *mdev)
|
|
|
+static int drbd_disconnected(struct drbd_peer_device *peer_device)
|
|
|
{
|
|
|
+ struct drbd_device *device = peer_device->device;
|
|
|
unsigned int i;
|
|
|
|
|
|
/* wait for current activity to cease. */
|
|
|
- spin_lock_irq(&mdev->tconn->req_lock);
|
|
|
- _drbd_wait_ee_list_empty(mdev, &mdev->active_ee);
|
|
|
- _drbd_wait_ee_list_empty(mdev, &mdev->sync_ee);
|
|
|
- _drbd_wait_ee_list_empty(mdev, &mdev->read_ee);
|
|
|
- spin_unlock_irq(&mdev->tconn->req_lock);
|
|
|
+ spin_lock_irq(&device->resource->req_lock);
|
|
|
+ _drbd_wait_ee_list_empty(device, &device->active_ee);
|
|
|
+ _drbd_wait_ee_list_empty(device, &device->sync_ee);
|
|
|
+ _drbd_wait_ee_list_empty(device, &device->read_ee);
|
|
|
+ spin_unlock_irq(&device->resource->req_lock);
|
|
|
|
|
|
/* We do not have data structures that would allow us to
|
|
|
* get the rs_pending_cnt down to 0 again.
|
|
|
@@ -4505,42 +4557,42 @@ static int drbd_disconnected(struct drbd_conf *mdev)
|
|
|
* resync_LRU. The resync_LRU tracks the whole operation including
|
|
|
* the disk-IO, while the rs_pending_cnt only tracks the blocks
|
|
|
* on the fly. */
|
|
|
- drbd_rs_cancel_all(mdev);
|
|
|
- mdev->rs_total = 0;
|
|
|
- mdev->rs_failed = 0;
|
|
|
- atomic_set(&mdev->rs_pending_cnt, 0);
|
|
|
- wake_up(&mdev->misc_wait);
|
|
|
+ drbd_rs_cancel_all(device);
|
|
|
+ device->rs_total = 0;
|
|
|
+ device->rs_failed = 0;
|
|
|
+ atomic_set(&device->rs_pending_cnt, 0);
|
|
|
+ wake_up(&device->misc_wait);
|
|
|
|
|
|
- del_timer_sync(&mdev->resync_timer);
|
|
|
- resync_timer_fn((unsigned long)mdev);
|
|
|
+ del_timer_sync(&device->resync_timer);
|
|
|
+ resync_timer_fn((unsigned long)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(mdev);
|
|
|
+ drbd_flush_workqueue(&peer_device->connection->sender_work);
|
|
|
|
|
|
- drbd_finish_peer_reqs(mdev);
|
|
|
+ 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(mdev);
|
|
|
+ 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(). */
|
|
|
- drbd_rs_cancel_all(mdev);
|
|
|
+ drbd_rs_cancel_all(device);
|
|
|
|
|
|
- kfree(mdev->p_uuid);
|
|
|
- mdev->p_uuid = NULL;
|
|
|
+ kfree(device->p_uuid);
|
|
|
+ device->p_uuid = NULL;
|
|
|
|
|
|
- if (!drbd_suspended(mdev))
|
|
|
- tl_clear(mdev->tconn);
|
|
|
+ if (!drbd_suspended(device))
|
|
|
+ tl_clear(peer_device->connection);
|
|
|
|
|
|
- drbd_md_sync(mdev);
|
|
|
+ drbd_md_sync(device);
|
|
|
|
|
|
/* serialize with bitmap writeout triggered by the state change,
|
|
|
* if any. */
|
|
|
- wait_event(mdev->misc_wait, !test_bit(BITMAP_IO, &mdev->flags));
|
|
|
+ wait_event(device->misc_wait, !test_bit(BITMAP_IO, &device->flags));
|
|
|
|
|
|
/* tcp_close and release of sendpage pages can be deferred. I don't
|
|
|
* want to use SO_LINGER, because apparently it can be deferred for
|
|
|
@@ -4549,20 +4601,20 @@ static int drbd_disconnected(struct drbd_conf *mdev)
|
|
|
* Actually we don't care for exactly when the network stack does its
|
|
|
* put_page(), but release our reference on these pages right here.
|
|
|
*/
|
|
|
- i = drbd_free_peer_reqs(mdev, &mdev->net_ee);
|
|
|
+ i = drbd_free_peer_reqs(device, &device->net_ee);
|
|
|
if (i)
|
|
|
- dev_info(DEV, "net_ee not empty, killed %u entries\n", i);
|
|
|
- i = atomic_read(&mdev->pp_in_use_by_net);
|
|
|
+ drbd_info(device, "net_ee not empty, killed %u entries\n", i);
|
|
|
+ i = atomic_read(&device->pp_in_use_by_net);
|
|
|
if (i)
|
|
|
- dev_info(DEV, "pp_in_use_by_net = %d, expected 0\n", i);
|
|
|
- i = atomic_read(&mdev->pp_in_use);
|
|
|
+ drbd_info(device, "pp_in_use_by_net = %d, expected 0\n", i);
|
|
|
+ i = atomic_read(&device->pp_in_use);
|
|
|
if (i)
|
|
|
- dev_info(DEV, "pp_in_use = %d, expected 0\n", i);
|
|
|
+ drbd_info(device, "pp_in_use = %d, expected 0\n", i);
|
|
|
|
|
|
- D_ASSERT(list_empty(&mdev->read_ee));
|
|
|
- D_ASSERT(list_empty(&mdev->active_ee));
|
|
|
- D_ASSERT(list_empty(&mdev->sync_ee));
|
|
|
- D_ASSERT(list_empty(&mdev->done_ee));
|
|
|
+ D_ASSERT(device, list_empty(&device->read_ee));
|
|
|
+ D_ASSERT(device, list_empty(&device->active_ee));
|
|
|
+ D_ASSERT(device, list_empty(&device->sync_ee));
|
|
|
+ D_ASSERT(device, list_empty(&device->done_ee));
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -4576,19 +4628,19 @@ static int drbd_disconnected(struct drbd_conf *mdev)
|
|
|
*
|
|
|
* for now, they are expected to be zero, but ignored.
|
|
|
*/
|
|
|
-static int drbd_send_features(struct drbd_tconn *tconn)
|
|
|
+static int drbd_send_features(struct drbd_connection *connection)
|
|
|
{
|
|
|
struct drbd_socket *sock;
|
|
|
struct p_connection_features *p;
|
|
|
|
|
|
- sock = &tconn->data;
|
|
|
- p = conn_prepare_command(tconn, sock);
|
|
|
+ sock = &connection->data;
|
|
|
+ p = conn_prepare_command(connection, sock);
|
|
|
if (!p)
|
|
|
return -EIO;
|
|
|
memset(p, 0, sizeof(*p));
|
|
|
p->protocol_min = cpu_to_be32(PRO_VERSION_MIN);
|
|
|
p->protocol_max = cpu_to_be32(PRO_VERSION_MAX);
|
|
|
- return conn_send_command(tconn, sock, P_CONNECTION_FEATURES, sizeof(*p), NULL, 0);
|
|
|
+ return conn_send_command(connection, sock, P_CONNECTION_FEATURES, sizeof(*p), NULL, 0);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
@@ -4598,36 +4650,36 @@ static int drbd_send_features(struct drbd_tconn *tconn)
|
|
|
* -1 peer talks different language,
|
|
|
* no point in trying again, please go standalone.
|
|
|
*/
|
|
|
-static int drbd_do_features(struct drbd_tconn *tconn)
|
|
|
+static int drbd_do_features(struct drbd_connection *connection)
|
|
|
{
|
|
|
- /* ASSERT current == tconn->receiver ... */
|
|
|
+ /* ASSERT current == connection->receiver ... */
|
|
|
struct p_connection_features *p;
|
|
|
const int expect = sizeof(struct p_connection_features);
|
|
|
struct packet_info pi;
|
|
|
int err;
|
|
|
|
|
|
- err = drbd_send_features(tconn);
|
|
|
+ err = drbd_send_features(connection);
|
|
|
if (err)
|
|
|
return 0;
|
|
|
|
|
|
- err = drbd_recv_header(tconn, &pi);
|
|
|
+ err = drbd_recv_header(connection, &pi);
|
|
|
if (err)
|
|
|
return 0;
|
|
|
|
|
|
if (pi.cmd != P_CONNECTION_FEATURES) {
|
|
|
- conn_err(tconn, "expected ConnectionFeatures packet, received: %s (0x%04x)\n",
|
|
|
+ drbd_err(connection, "expected ConnectionFeatures packet, received: %s (0x%04x)\n",
|
|
|
cmdname(pi.cmd), pi.cmd);
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
if (pi.size != expect) {
|
|
|
- conn_err(tconn, "expected ConnectionFeatures length: %u, received: %u\n",
|
|
|
+ drbd_err(connection, "expected ConnectionFeatures length: %u, received: %u\n",
|
|
|
expect, pi.size);
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
p = pi.data;
|
|
|
- err = drbd_recv_all_warn(tconn, p, expect);
|
|
|
+ err = drbd_recv_all_warn(connection, p, expect);
|
|
|
if (err)
|
|
|
return 0;
|
|
|
|
|
|
@@ -4640,15 +4692,15 @@ static int drbd_do_features(struct drbd_tconn *tconn)
|
|
|
PRO_VERSION_MIN > p->protocol_max)
|
|
|
goto incompat;
|
|
|
|
|
|
- tconn->agreed_pro_version = min_t(int, PRO_VERSION_MAX, p->protocol_max);
|
|
|
+ connection->agreed_pro_version = min_t(int, PRO_VERSION_MAX, p->protocol_max);
|
|
|
|
|
|
- conn_info(tconn, "Handshake successful: "
|
|
|
- "Agreed network protocol version %d\n", tconn->agreed_pro_version);
|
|
|
+ drbd_info(connection, "Handshake successful: "
|
|
|
+ "Agreed network protocol version %d\n", connection->agreed_pro_version);
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
incompat:
|
|
|
- conn_err(tconn, "incompatible DRBD dialects: "
|
|
|
+ drbd_err(connection, "incompatible DRBD dialects: "
|
|
|
"I support %d-%d, peer supports %d-%d\n",
|
|
|
PRO_VERSION_MIN, PRO_VERSION_MAX,
|
|
|
p->protocol_min, p->protocol_max);
|
|
|
@@ -4656,10 +4708,10 @@ static int drbd_do_features(struct drbd_tconn *tconn)
|
|
|
}
|
|
|
|
|
|
#if !defined(CONFIG_CRYPTO_HMAC) && !defined(CONFIG_CRYPTO_HMAC_MODULE)
|
|
|
-static int drbd_do_auth(struct drbd_tconn *tconn)
|
|
|
+static int drbd_do_auth(struct drbd_connection *connection)
|
|
|
{
|
|
|
- conn_err(tconn, "This kernel was build without CONFIG_CRYPTO_HMAC.\n");
|
|
|
- conn_err(tconn, "You need to disable 'cram-hmac-alg' in drbd.conf.\n");
|
|
|
+ drbd_err(connection, "This kernel was build without CONFIG_CRYPTO_HMAC.\n");
|
|
|
+ drbd_err(connection, "You need to disable 'cram-hmac-alg' in drbd.conf.\n");
|
|
|
return -1;
|
|
|
}
|
|
|
#else
|
|
|
@@ -4671,7 +4723,7 @@ static int drbd_do_auth(struct drbd_tconn *tconn)
|
|
|
-1 - auth failed, don't try again.
|
|
|
*/
|
|
|
|
|
|
-static int drbd_do_auth(struct drbd_tconn *tconn)
|
|
|
+static int drbd_do_auth(struct drbd_connection *connection)
|
|
|
{
|
|
|
struct drbd_socket *sock;
|
|
|
char my_challenge[CHALLENGE_LEN]; /* 64 Bytes... */
|
|
|
@@ -4690,69 +4742,69 @@ static int drbd_do_auth(struct drbd_tconn *tconn)
|
|
|
/* FIXME: Put the challenge/response into the preallocated socket buffer. */
|
|
|
|
|
|
rcu_read_lock();
|
|
|
- nc = rcu_dereference(tconn->net_conf);
|
|
|
+ nc = rcu_dereference(connection->net_conf);
|
|
|
key_len = strlen(nc->shared_secret);
|
|
|
memcpy(secret, nc->shared_secret, key_len);
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
- desc.tfm = tconn->cram_hmac_tfm;
|
|
|
+ desc.tfm = connection->cram_hmac_tfm;
|
|
|
desc.flags = 0;
|
|
|
|
|
|
- rv = crypto_hash_setkey(tconn->cram_hmac_tfm, (u8 *)secret, key_len);
|
|
|
+ rv = crypto_hash_setkey(connection->cram_hmac_tfm, (u8 *)secret, key_len);
|
|
|
if (rv) {
|
|
|
- conn_err(tconn, "crypto_hash_setkey() failed with %d\n", rv);
|
|
|
+ drbd_err(connection, "crypto_hash_setkey() failed with %d\n", rv);
|
|
|
rv = -1;
|
|
|
goto fail;
|
|
|
}
|
|
|
|
|
|
get_random_bytes(my_challenge, CHALLENGE_LEN);
|
|
|
|
|
|
- sock = &tconn->data;
|
|
|
- if (!conn_prepare_command(tconn, sock)) {
|
|
|
+ sock = &connection->data;
|
|
|
+ if (!conn_prepare_command(connection, sock)) {
|
|
|
rv = 0;
|
|
|
goto fail;
|
|
|
}
|
|
|
- rv = !conn_send_command(tconn, sock, P_AUTH_CHALLENGE, 0,
|
|
|
+ rv = !conn_send_command(connection, sock, P_AUTH_CHALLENGE, 0,
|
|
|
my_challenge, CHALLENGE_LEN);
|
|
|
if (!rv)
|
|
|
goto fail;
|
|
|
|
|
|
- err = drbd_recv_header(tconn, &pi);
|
|
|
+ err = drbd_recv_header(connection, &pi);
|
|
|
if (err) {
|
|
|
rv = 0;
|
|
|
goto fail;
|
|
|
}
|
|
|
|
|
|
if (pi.cmd != P_AUTH_CHALLENGE) {
|
|
|
- conn_err(tconn, "expected AuthChallenge packet, received: %s (0x%04x)\n",
|
|
|
+ drbd_err(connection, "expected AuthChallenge packet, received: %s (0x%04x)\n",
|
|
|
cmdname(pi.cmd), pi.cmd);
|
|
|
rv = 0;
|
|
|
goto fail;
|
|
|
}
|
|
|
|
|
|
if (pi.size > CHALLENGE_LEN * 2) {
|
|
|
- conn_err(tconn, "expected AuthChallenge payload too big.\n");
|
|
|
+ drbd_err(connection, "expected AuthChallenge payload too big.\n");
|
|
|
rv = -1;
|
|
|
goto fail;
|
|
|
}
|
|
|
|
|
|
peers_ch = kmalloc(pi.size, GFP_NOIO);
|
|
|
if (peers_ch == NULL) {
|
|
|
- conn_err(tconn, "kmalloc of peers_ch failed\n");
|
|
|
+ drbd_err(connection, "kmalloc of peers_ch failed\n");
|
|
|
rv = -1;
|
|
|
goto fail;
|
|
|
}
|
|
|
|
|
|
- err = drbd_recv_all_warn(tconn, peers_ch, pi.size);
|
|
|
+ err = drbd_recv_all_warn(connection, peers_ch, pi.size);
|
|
|
if (err) {
|
|
|
rv = 0;
|
|
|
goto fail;
|
|
|
}
|
|
|
|
|
|
- resp_size = crypto_hash_digestsize(tconn->cram_hmac_tfm);
|
|
|
+ resp_size = crypto_hash_digestsize(connection->cram_hmac_tfm);
|
|
|
response = kmalloc(resp_size, GFP_NOIO);
|
|
|
if (response == NULL) {
|
|
|
- conn_err(tconn, "kmalloc of response failed\n");
|
|
|
+ drbd_err(connection, "kmalloc of response failed\n");
|
|
|
rv = -1;
|
|
|
goto fail;
|
|
|
}
|
|
|
@@ -4762,40 +4814,40 @@ static int drbd_do_auth(struct drbd_tconn *tconn)
|
|
|
|
|
|
rv = crypto_hash_digest(&desc, &sg, sg.length, response);
|
|
|
if (rv) {
|
|
|
- conn_err(tconn, "crypto_hash_digest() failed with %d\n", rv);
|
|
|
+ drbd_err(connection, "crypto_hash_digest() failed with %d\n", rv);
|
|
|
rv = -1;
|
|
|
goto fail;
|
|
|
}
|
|
|
|
|
|
- if (!conn_prepare_command(tconn, sock)) {
|
|
|
+ if (!conn_prepare_command(connection, sock)) {
|
|
|
rv = 0;
|
|
|
goto fail;
|
|
|
}
|
|
|
- rv = !conn_send_command(tconn, sock, P_AUTH_RESPONSE, 0,
|
|
|
+ rv = !conn_send_command(connection, sock, P_AUTH_RESPONSE, 0,
|
|
|
response, resp_size);
|
|
|
if (!rv)
|
|
|
goto fail;
|
|
|
|
|
|
- err = drbd_recv_header(tconn, &pi);
|
|
|
+ err = drbd_recv_header(connection, &pi);
|
|
|
if (err) {
|
|
|
rv = 0;
|
|
|
goto fail;
|
|
|
}
|
|
|
|
|
|
if (pi.cmd != P_AUTH_RESPONSE) {
|
|
|
- conn_err(tconn, "expected AuthResponse packet, received: %s (0x%04x)\n",
|
|
|
+ drbd_err(connection, "expected AuthResponse packet, received: %s (0x%04x)\n",
|
|
|
cmdname(pi.cmd), pi.cmd);
|
|
|
rv = 0;
|
|
|
goto fail;
|
|
|
}
|
|
|
|
|
|
if (pi.size != resp_size) {
|
|
|
- conn_err(tconn, "expected AuthResponse payload of wrong size\n");
|
|
|
+ drbd_err(connection, "expected AuthResponse payload of wrong size\n");
|
|
|
rv = 0;
|
|
|
goto fail;
|
|
|
}
|
|
|
|
|
|
- err = drbd_recv_all_warn(tconn, response , resp_size);
|
|
|
+ err = drbd_recv_all_warn(connection, response , resp_size);
|
|
|
if (err) {
|
|
|
rv = 0;
|
|
|
goto fail;
|
|
|
@@ -4803,7 +4855,7 @@ static int drbd_do_auth(struct drbd_tconn *tconn)
|
|
|
|
|
|
right_response = kmalloc(resp_size, GFP_NOIO);
|
|
|
if (right_response == NULL) {
|
|
|
- conn_err(tconn, "kmalloc of right_response failed\n");
|
|
|
+ drbd_err(connection, "kmalloc of right_response failed\n");
|
|
|
rv = -1;
|
|
|
goto fail;
|
|
|
}
|
|
|
@@ -4812,7 +4864,7 @@ static int drbd_do_auth(struct drbd_tconn *tconn)
|
|
|
|
|
|
rv = crypto_hash_digest(&desc, &sg, sg.length, right_response);
|
|
|
if (rv) {
|
|
|
- conn_err(tconn, "crypto_hash_digest() failed with %d\n", rv);
|
|
|
+ drbd_err(connection, "crypto_hash_digest() failed with %d\n", rv);
|
|
|
rv = -1;
|
|
|
goto fail;
|
|
|
}
|
|
|
@@ -4820,7 +4872,7 @@ static int drbd_do_auth(struct drbd_tconn *tconn)
|
|
|
rv = !memcmp(response, right_response, resp_size);
|
|
|
|
|
|
if (rv)
|
|
|
- conn_info(tconn, "Peer authenticated using %d bytes HMAC\n",
|
|
|
+ drbd_info(connection, "Peer authenticated using %d bytes HMAC\n",
|
|
|
resp_size);
|
|
|
else
|
|
|
rv = -1;
|
|
|
@@ -4834,163 +4886,169 @@ static int drbd_do_auth(struct drbd_tconn *tconn)
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
-int drbdd_init(struct drbd_thread *thi)
|
|
|
+int drbd_receiver(struct drbd_thread *thi)
|
|
|
{
|
|
|
- struct drbd_tconn *tconn = thi->tconn;
|
|
|
+ struct drbd_connection *connection = thi->connection;
|
|
|
int h;
|
|
|
|
|
|
- conn_info(tconn, "receiver (re)started\n");
|
|
|
+ drbd_info(connection, "receiver (re)started\n");
|
|
|
|
|
|
do {
|
|
|
- h = conn_connect(tconn);
|
|
|
+ h = conn_connect(connection);
|
|
|
if (h == 0) {
|
|
|
- conn_disconnect(tconn);
|
|
|
+ conn_disconnect(connection);
|
|
|
schedule_timeout_interruptible(HZ);
|
|
|
}
|
|
|
if (h == -1) {
|
|
|
- conn_warn(tconn, "Discarding network configuration.\n");
|
|
|
- conn_request_state(tconn, NS(conn, C_DISCONNECTING), CS_HARD);
|
|
|
+ drbd_warn(connection, "Discarding network configuration.\n");
|
|
|
+ conn_request_state(connection, NS(conn, C_DISCONNECTING), CS_HARD);
|
|
|
}
|
|
|
} while (h == 0);
|
|
|
|
|
|
if (h > 0)
|
|
|
- drbdd(tconn);
|
|
|
+ drbdd(connection);
|
|
|
|
|
|
- conn_disconnect(tconn);
|
|
|
+ conn_disconnect(connection);
|
|
|
|
|
|
- conn_info(tconn, "receiver terminated\n");
|
|
|
+ drbd_info(connection, "receiver terminated\n");
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
/* ********* acknowledge sender ******** */
|
|
|
|
|
|
-static int got_conn_RqSReply(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int got_conn_RqSReply(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
struct p_req_state_reply *p = pi->data;
|
|
|
int retcode = be32_to_cpu(p->retcode);
|
|
|
|
|
|
if (retcode >= SS_SUCCESS) {
|
|
|
- set_bit(CONN_WD_ST_CHG_OKAY, &tconn->flags);
|
|
|
+ set_bit(CONN_WD_ST_CHG_OKAY, &connection->flags);
|
|
|
} else {
|
|
|
- set_bit(CONN_WD_ST_CHG_FAIL, &tconn->flags);
|
|
|
- conn_err(tconn, "Requested state change failed by peer: %s (%d)\n",
|
|
|
+ set_bit(CONN_WD_ST_CHG_FAIL, &connection->flags);
|
|
|
+ drbd_err(connection, "Requested state change failed by peer: %s (%d)\n",
|
|
|
drbd_set_st_err_str(retcode), retcode);
|
|
|
}
|
|
|
- wake_up(&tconn->ping_wait);
|
|
|
+ wake_up(&connection->ping_wait);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int got_RqSReply(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int got_RqSReply(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
- struct drbd_conf *mdev;
|
|
|
+ struct drbd_peer_device *peer_device;
|
|
|
+ struct drbd_device *device;
|
|
|
struct p_req_state_reply *p = pi->data;
|
|
|
int retcode = be32_to_cpu(p->retcode);
|
|
|
|
|
|
- mdev = vnr_to_mdev(tconn, pi->vnr);
|
|
|
- if (!mdev)
|
|
|
+ peer_device = conn_peer_device(connection, pi->vnr);
|
|
|
+ if (!peer_device)
|
|
|
return -EIO;
|
|
|
+ device = peer_device->device;
|
|
|
|
|
|
- if (test_bit(CONN_WD_ST_CHG_REQ, &tconn->flags)) {
|
|
|
- D_ASSERT(tconn->agreed_pro_version < 100);
|
|
|
- return got_conn_RqSReply(tconn, pi);
|
|
|
+ if (test_bit(CONN_WD_ST_CHG_REQ, &connection->flags)) {
|
|
|
+ D_ASSERT(device, connection->agreed_pro_version < 100);
|
|
|
+ return got_conn_RqSReply(connection, pi);
|
|
|
}
|
|
|
|
|
|
if (retcode >= SS_SUCCESS) {
|
|
|
- set_bit(CL_ST_CHG_SUCCESS, &mdev->flags);
|
|
|
+ set_bit(CL_ST_CHG_SUCCESS, &device->flags);
|
|
|
} else {
|
|
|
- set_bit(CL_ST_CHG_FAIL, &mdev->flags);
|
|
|
- dev_err(DEV, "Requested state change failed by peer: %s (%d)\n",
|
|
|
+ set_bit(CL_ST_CHG_FAIL, &device->flags);
|
|
|
+ drbd_err(device, "Requested state change failed by peer: %s (%d)\n",
|
|
|
drbd_set_st_err_str(retcode), retcode);
|
|
|
}
|
|
|
- wake_up(&mdev->state_wait);
|
|
|
+ wake_up(&device->state_wait);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int got_Ping(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int got_Ping(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
- return drbd_send_ping_ack(tconn);
|
|
|
+ return drbd_send_ping_ack(connection);
|
|
|
|
|
|
}
|
|
|
|
|
|
-static int got_PingAck(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int got_PingAck(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
/* restore idle timeout */
|
|
|
- tconn->meta.socket->sk->sk_rcvtimeo = tconn->net_conf->ping_int*HZ;
|
|
|
- if (!test_and_set_bit(GOT_PING_ACK, &tconn->flags))
|
|
|
- wake_up(&tconn->ping_wait);
|
|
|
+ connection->meta.socket->sk->sk_rcvtimeo = connection->net_conf->ping_int*HZ;
|
|
|
+ if (!test_and_set_bit(GOT_PING_ACK, &connection->flags))
|
|
|
+ wake_up(&connection->ping_wait);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int got_IsInSync(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int got_IsInSync(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
- struct drbd_conf *mdev;
|
|
|
+ struct drbd_peer_device *peer_device;
|
|
|
+ struct drbd_device *device;
|
|
|
struct p_block_ack *p = pi->data;
|
|
|
sector_t sector = be64_to_cpu(p->sector);
|
|
|
int blksize = be32_to_cpu(p->blksize);
|
|
|
|
|
|
- mdev = vnr_to_mdev(tconn, pi->vnr);
|
|
|
- if (!mdev)
|
|
|
+ peer_device = conn_peer_device(connection, pi->vnr);
|
|
|
+ if (!peer_device)
|
|
|
return -EIO;
|
|
|
+ device = peer_device->device;
|
|
|
|
|
|
- D_ASSERT(mdev->tconn->agreed_pro_version >= 89);
|
|
|
+ D_ASSERT(device, peer_device->connection->agreed_pro_version >= 89);
|
|
|
|
|
|
- update_peer_seq(mdev, be32_to_cpu(p->seq_num));
|
|
|
+ update_peer_seq(peer_device, be32_to_cpu(p->seq_num));
|
|
|
|
|
|
- if (get_ldev(mdev)) {
|
|
|
- drbd_rs_complete_io(mdev, sector);
|
|
|
- drbd_set_in_sync(mdev, sector, blksize);
|
|
|
+ if (get_ldev(device)) {
|
|
|
+ drbd_rs_complete_io(device, sector);
|
|
|
+ drbd_set_in_sync(device, sector, blksize);
|
|
|
/* rs_same_csums is supposed to count in units of BM_BLOCK_SIZE */
|
|
|
- mdev->rs_same_csum += (blksize >> BM_BLOCK_SHIFT);
|
|
|
- put_ldev(mdev);
|
|
|
+ device->rs_same_csum += (blksize >> BM_BLOCK_SHIFT);
|
|
|
+ put_ldev(device);
|
|
|
}
|
|
|
- dec_rs_pending(mdev);
|
|
|
- atomic_add(blksize >> 9, &mdev->rs_sect_in);
|
|
|
+ dec_rs_pending(device);
|
|
|
+ atomic_add(blksize >> 9, &device->rs_sect_in);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
static int
|
|
|
-validate_req_change_req_state(struct drbd_conf *mdev, u64 id, sector_t sector,
|
|
|
+validate_req_change_req_state(struct drbd_device *device, u64 id, sector_t sector,
|
|
|
struct rb_root *root, const char *func,
|
|
|
enum drbd_req_event what, bool missing_ok)
|
|
|
{
|
|
|
struct drbd_request *req;
|
|
|
struct bio_and_error m;
|
|
|
|
|
|
- spin_lock_irq(&mdev->tconn->req_lock);
|
|
|
- req = find_request(mdev, root, id, sector, missing_ok, func);
|
|
|
+ spin_lock_irq(&device->resource->req_lock);
|
|
|
+ req = find_request(device, root, id, sector, missing_ok, func);
|
|
|
if (unlikely(!req)) {
|
|
|
- spin_unlock_irq(&mdev->tconn->req_lock);
|
|
|
+ spin_unlock_irq(&device->resource->req_lock);
|
|
|
return -EIO;
|
|
|
}
|
|
|
__req_mod(req, what, &m);
|
|
|
- spin_unlock_irq(&mdev->tconn->req_lock);
|
|
|
+ spin_unlock_irq(&device->resource->req_lock);
|
|
|
|
|
|
if (m.bio)
|
|
|
- complete_master_bio(mdev, &m);
|
|
|
+ complete_master_bio(device, &m);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int got_BlockAck(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int got_BlockAck(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
- struct drbd_conf *mdev;
|
|
|
+ struct drbd_peer_device *peer_device;
|
|
|
+ struct drbd_device *device;
|
|
|
struct p_block_ack *p = pi->data;
|
|
|
sector_t sector = be64_to_cpu(p->sector);
|
|
|
int blksize = be32_to_cpu(p->blksize);
|
|
|
enum drbd_req_event what;
|
|
|
|
|
|
- mdev = vnr_to_mdev(tconn, pi->vnr);
|
|
|
- if (!mdev)
|
|
|
+ peer_device = conn_peer_device(connection, pi->vnr);
|
|
|
+ if (!peer_device)
|
|
|
return -EIO;
|
|
|
+ device = peer_device->device;
|
|
|
|
|
|
- update_peer_seq(mdev, be32_to_cpu(p->seq_num));
|
|
|
+ update_peer_seq(peer_device, be32_to_cpu(p->seq_num));
|
|
|
|
|
|
if (p->block_id == ID_SYNCER) {
|
|
|
- drbd_set_in_sync(mdev, sector, blksize);
|
|
|
- dec_rs_pending(mdev);
|
|
|
+ drbd_set_in_sync(device, sector, blksize);
|
|
|
+ dec_rs_pending(device);
|
|
|
return 0;
|
|
|
}
|
|
|
switch (pi->cmd) {
|
|
|
@@ -5013,33 +5071,35 @@ static int got_BlockAck(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
BUG();
|
|
|
}
|
|
|
|
|
|
- return validate_req_change_req_state(mdev, p->block_id, sector,
|
|
|
- &mdev->write_requests, __func__,
|
|
|
+ return validate_req_change_req_state(device, p->block_id, sector,
|
|
|
+ &device->write_requests, __func__,
|
|
|
what, false);
|
|
|
}
|
|
|
|
|
|
-static int got_NegAck(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int got_NegAck(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
- struct drbd_conf *mdev;
|
|
|
+ struct drbd_peer_device *peer_device;
|
|
|
+ struct drbd_device *device;
|
|
|
struct p_block_ack *p = pi->data;
|
|
|
sector_t sector = be64_to_cpu(p->sector);
|
|
|
int size = be32_to_cpu(p->blksize);
|
|
|
int err;
|
|
|
|
|
|
- mdev = vnr_to_mdev(tconn, pi->vnr);
|
|
|
- if (!mdev)
|
|
|
+ peer_device = conn_peer_device(connection, pi->vnr);
|
|
|
+ if (!peer_device)
|
|
|
return -EIO;
|
|
|
+ device = peer_device->device;
|
|
|
|
|
|
- update_peer_seq(mdev, be32_to_cpu(p->seq_num));
|
|
|
+ update_peer_seq(peer_device, be32_to_cpu(p->seq_num));
|
|
|
|
|
|
if (p->block_id == ID_SYNCER) {
|
|
|
- dec_rs_pending(mdev);
|
|
|
- drbd_rs_failed_io(mdev, sector, size);
|
|
|
+ dec_rs_pending(device);
|
|
|
+ drbd_rs_failed_io(device, sector, size);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- err = validate_req_change_req_state(mdev, p->block_id, sector,
|
|
|
- &mdev->write_requests, __func__,
|
|
|
+ err = validate_req_change_req_state(device, p->block_id, sector,
|
|
|
+ &device->write_requests, __func__,
|
|
|
NEG_ACKED, true);
|
|
|
if (err) {
|
|
|
/* Protocol A has no P_WRITE_ACKs, but has P_NEG_ACKs.
|
|
|
@@ -5047,80 +5107,86 @@ static int got_NegAck(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
request is no longer in the collision hash. */
|
|
|
/* In Protocol B we might already have got a P_RECV_ACK
|
|
|
but then get a P_NEG_ACK afterwards. */
|
|
|
- drbd_set_out_of_sync(mdev, sector, size);
|
|
|
+ drbd_set_out_of_sync(device, sector, size);
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int got_NegDReply(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int got_NegDReply(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
- struct drbd_conf *mdev;
|
|
|
+ struct drbd_peer_device *peer_device;
|
|
|
+ struct drbd_device *device;
|
|
|
struct p_block_ack *p = pi->data;
|
|
|
sector_t sector = be64_to_cpu(p->sector);
|
|
|
|
|
|
- mdev = vnr_to_mdev(tconn, pi->vnr);
|
|
|
- if (!mdev)
|
|
|
+ peer_device = conn_peer_device(connection, pi->vnr);
|
|
|
+ if (!peer_device)
|
|
|
return -EIO;
|
|
|
+ device = peer_device->device;
|
|
|
|
|
|
- update_peer_seq(mdev, be32_to_cpu(p->seq_num));
|
|
|
+ update_peer_seq(peer_device, be32_to_cpu(p->seq_num));
|
|
|
|
|
|
- dev_err(DEV, "Got NegDReply; Sector %llus, len %u.\n",
|
|
|
+ drbd_err(device, "Got NegDReply; Sector %llus, len %u.\n",
|
|
|
(unsigned long long)sector, be32_to_cpu(p->blksize));
|
|
|
|
|
|
- return validate_req_change_req_state(mdev, p->block_id, sector,
|
|
|
- &mdev->read_requests, __func__,
|
|
|
+ return validate_req_change_req_state(device, p->block_id, sector,
|
|
|
+ &device->read_requests, __func__,
|
|
|
NEG_ACKED, false);
|
|
|
}
|
|
|
|
|
|
-static int got_NegRSDReply(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int got_NegRSDReply(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
- struct drbd_conf *mdev;
|
|
|
+ struct drbd_peer_device *peer_device;
|
|
|
+ struct drbd_device *device;
|
|
|
sector_t sector;
|
|
|
int size;
|
|
|
struct p_block_ack *p = pi->data;
|
|
|
|
|
|
- mdev = vnr_to_mdev(tconn, pi->vnr);
|
|
|
- if (!mdev)
|
|
|
+ peer_device = conn_peer_device(connection, pi->vnr);
|
|
|
+ if (!peer_device)
|
|
|
return -EIO;
|
|
|
+ device = peer_device->device;
|
|
|
|
|
|
sector = be64_to_cpu(p->sector);
|
|
|
size = be32_to_cpu(p->blksize);
|
|
|
|
|
|
- update_peer_seq(mdev, be32_to_cpu(p->seq_num));
|
|
|
+ update_peer_seq(peer_device, be32_to_cpu(p->seq_num));
|
|
|
|
|
|
- dec_rs_pending(mdev);
|
|
|
+ dec_rs_pending(device);
|
|
|
|
|
|
- if (get_ldev_if_state(mdev, D_FAILED)) {
|
|
|
- drbd_rs_complete_io(mdev, sector);
|
|
|
+ if (get_ldev_if_state(device, D_FAILED)) {
|
|
|
+ drbd_rs_complete_io(device, sector);
|
|
|
switch (pi->cmd) {
|
|
|
case P_NEG_RS_DREPLY:
|
|
|
- drbd_rs_failed_io(mdev, sector, size);
|
|
|
+ drbd_rs_failed_io(device, sector, size);
|
|
|
case P_RS_CANCEL:
|
|
|
break;
|
|
|
default:
|
|
|
BUG();
|
|
|
}
|
|
|
- put_ldev(mdev);
|
|
|
+ put_ldev(device);
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int got_BarrierAck(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int got_BarrierAck(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
struct p_barrier_ack *p = pi->data;
|
|
|
- struct drbd_conf *mdev;
|
|
|
+ struct drbd_peer_device *peer_device;
|
|
|
int vnr;
|
|
|
|
|
|
- tl_release(tconn, p->barrier, be32_to_cpu(p->set_size));
|
|
|
+ tl_release(connection, p->barrier, be32_to_cpu(p->set_size));
|
|
|
|
|
|
rcu_read_lock();
|
|
|
- idr_for_each_entry(&tconn->volumes, mdev, vnr) {
|
|
|
- if (mdev->state.conn == C_AHEAD &&
|
|
|
- atomic_read(&mdev->ap_in_flight) == 0 &&
|
|
|
- !test_and_set_bit(AHEAD_TO_SYNC_SOURCE, &mdev->flags)) {
|
|
|
- mdev->start_resync_timer.expires = jiffies + HZ;
|
|
|
- add_timer(&mdev->start_resync_timer);
|
|
|
+ idr_for_each_entry(&connection->peer_devices, peer_device, vnr) {
|
|
|
+ struct drbd_device *device = peer_device->device;
|
|
|
+
|
|
|
+ if (device->state.conn == C_AHEAD &&
|
|
|
+ atomic_read(&device->ap_in_flight) == 0 &&
|
|
|
+ !test_and_set_bit(AHEAD_TO_SYNC_SOURCE, &device->flags)) {
|
|
|
+ device->start_resync_timer.expires = jiffies + HZ;
|
|
|
+ add_timer(&device->start_resync_timer);
|
|
|
}
|
|
|
}
|
|
|
rcu_read_unlock();
|
|
|
@@ -5128,90 +5194,94 @@ static int got_BarrierAck(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int got_OVResult(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int got_OVResult(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
- struct drbd_conf *mdev;
|
|
|
+ struct drbd_peer_device *peer_device;
|
|
|
+ struct drbd_device *device;
|
|
|
struct p_block_ack *p = pi->data;
|
|
|
- struct drbd_work *w;
|
|
|
+ struct drbd_device_work *dw;
|
|
|
sector_t sector;
|
|
|
int size;
|
|
|
|
|
|
- mdev = vnr_to_mdev(tconn, pi->vnr);
|
|
|
- if (!mdev)
|
|
|
+ peer_device = conn_peer_device(connection, pi->vnr);
|
|
|
+ if (!peer_device)
|
|
|
return -EIO;
|
|
|
+ device = peer_device->device;
|
|
|
|
|
|
sector = be64_to_cpu(p->sector);
|
|
|
size = be32_to_cpu(p->blksize);
|
|
|
|
|
|
- update_peer_seq(mdev, be32_to_cpu(p->seq_num));
|
|
|
+ update_peer_seq(peer_device, be32_to_cpu(p->seq_num));
|
|
|
|
|
|
if (be64_to_cpu(p->block_id) == ID_OUT_OF_SYNC)
|
|
|
- drbd_ov_out_of_sync_found(mdev, sector, size);
|
|
|
+ drbd_ov_out_of_sync_found(device, sector, size);
|
|
|
else
|
|
|
- ov_out_of_sync_print(mdev);
|
|
|
+ ov_out_of_sync_print(device);
|
|
|
|
|
|
- if (!get_ldev(mdev))
|
|
|
+ if (!get_ldev(device))
|
|
|
return 0;
|
|
|
|
|
|
- drbd_rs_complete_io(mdev, sector);
|
|
|
- dec_rs_pending(mdev);
|
|
|
+ drbd_rs_complete_io(device, sector);
|
|
|
+ dec_rs_pending(device);
|
|
|
|
|
|
- --mdev->ov_left;
|
|
|
+ --device->ov_left;
|
|
|
|
|
|
/* let's advance progress step marks only for every other megabyte */
|
|
|
- if ((mdev->ov_left & 0x200) == 0x200)
|
|
|
- drbd_advance_rs_marks(mdev, mdev->ov_left);
|
|
|
-
|
|
|
- if (mdev->ov_left == 0) {
|
|
|
- w = kmalloc(sizeof(*w), GFP_NOIO);
|
|
|
- if (w) {
|
|
|
- w->cb = w_ov_finished;
|
|
|
- w->mdev = mdev;
|
|
|
- drbd_queue_work(&mdev->tconn->sender_work, w);
|
|
|
+ if ((device->ov_left & 0x200) == 0x200)
|
|
|
+ drbd_advance_rs_marks(device, device->ov_left);
|
|
|
+
|
|
|
+ if (device->ov_left == 0) {
|
|
|
+ dw = kmalloc(sizeof(*dw), GFP_NOIO);
|
|
|
+ if (dw) {
|
|
|
+ dw->w.cb = w_ov_finished;
|
|
|
+ dw->device = device;
|
|
|
+ drbd_queue_work(&peer_device->connection->sender_work, &dw->w);
|
|
|
} else {
|
|
|
- dev_err(DEV, "kmalloc(w) failed.");
|
|
|
- ov_out_of_sync_print(mdev);
|
|
|
- drbd_resync_finished(mdev);
|
|
|
+ drbd_err(device, "kmalloc(dw) failed.");
|
|
|
+ ov_out_of_sync_print(device);
|
|
|
+ drbd_resync_finished(device);
|
|
|
}
|
|
|
}
|
|
|
- put_ldev(mdev);
|
|
|
+ put_ldev(device);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int got_skip(struct drbd_tconn *tconn, struct packet_info *pi)
|
|
|
+static int got_skip(struct drbd_connection *connection, struct packet_info *pi)
|
|
|
{
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
|
|
|
+static int connection_finish_peer_reqs(struct drbd_connection *connection)
|
|
|
{
|
|
|
- struct drbd_conf *mdev;
|
|
|
+ struct drbd_peer_device *peer_device;
|
|
|
int vnr, not_empty = 0;
|
|
|
|
|
|
do {
|
|
|
- clear_bit(SIGNAL_ASENDER, &tconn->flags);
|
|
|
+ clear_bit(SIGNAL_ASENDER, &connection->flags);
|
|
|
flush_signals(current);
|
|
|
|
|
|
rcu_read_lock();
|
|
|
- idr_for_each_entry(&tconn->volumes, mdev, vnr) {
|
|
|
- kref_get(&mdev->kref);
|
|
|
+ idr_for_each_entry(&connection->peer_devices, peer_device, vnr) {
|
|
|
+ struct drbd_device *device = peer_device->device;
|
|
|
+ kref_get(&device->kref);
|
|
|
rcu_read_unlock();
|
|
|
- if (drbd_finish_peer_reqs(mdev)) {
|
|
|
- kref_put(&mdev->kref, &drbd_minor_destroy);
|
|
|
+ if (drbd_finish_peer_reqs(device)) {
|
|
|
+ kref_put(&device->kref, drbd_destroy_device);
|
|
|
return 1;
|
|
|
}
|
|
|
- kref_put(&mdev->kref, &drbd_minor_destroy);
|
|
|
+ kref_put(&device->kref, drbd_destroy_device);
|
|
|
rcu_read_lock();
|
|
|
}
|
|
|
- set_bit(SIGNAL_ASENDER, &tconn->flags);
|
|
|
+ set_bit(SIGNAL_ASENDER, &connection->flags);
|
|
|
|
|
|
- spin_lock_irq(&tconn->req_lock);
|
|
|
- idr_for_each_entry(&tconn->volumes, mdev, vnr) {
|
|
|
- not_empty = !list_empty(&mdev->done_ee);
|
|
|
+ spin_lock_irq(&connection->resource->req_lock);
|
|
|
+ idr_for_each_entry(&connection->peer_devices, peer_device, vnr) {
|
|
|
+ struct drbd_device *device = peer_device->device;
|
|
|
+ not_empty = !list_empty(&device->done_ee);
|
|
|
if (not_empty)
|
|
|
break;
|
|
|
}
|
|
|
- spin_unlock_irq(&tconn->req_lock);
|
|
|
+ spin_unlock_irq(&connection->resource->req_lock);
|
|
|
rcu_read_unlock();
|
|
|
} while (not_empty);
|
|
|
|
|
|
@@ -5220,7 +5290,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
|
|
|
|
|
|
struct asender_cmd {
|
|
|
size_t pkt_size;
|
|
|
- int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
|
|
|
+ int (*fn)(struct drbd_connection *connection, struct packet_info *);
|
|
|
};
|
|
|
|
|
|
static struct asender_cmd asender_tbl[] = {
|
|
|
@@ -5245,13 +5315,13 @@ static struct asender_cmd asender_tbl[] = {
|
|
|
|
|
|
int drbd_asender(struct drbd_thread *thi)
|
|
|
{
|
|
|
- struct drbd_tconn *tconn = thi->tconn;
|
|
|
+ struct drbd_connection *connection = thi->connection;
|
|
|
struct asender_cmd *cmd = NULL;
|
|
|
struct packet_info pi;
|
|
|
int rv;
|
|
|
- void *buf = tconn->meta.rbuf;
|
|
|
+ void *buf = connection->meta.rbuf;
|
|
|
int received = 0;
|
|
|
- unsigned int header_size = drbd_header_size(tconn);
|
|
|
+ unsigned int header_size = drbd_header_size(connection);
|
|
|
int expect = header_size;
|
|
|
bool ping_timeout_active = false;
|
|
|
struct net_conf *nc;
|
|
|
@@ -5260,45 +5330,45 @@ int drbd_asender(struct drbd_thread *thi)
|
|
|
|
|
|
rv = sched_setscheduler(current, SCHED_RR, ¶m);
|
|
|
if (rv < 0)
|
|
|
- conn_err(tconn, "drbd_asender: ERROR set priority, ret=%d\n", rv);
|
|
|
+ drbd_err(connection, "drbd_asender: ERROR set priority, ret=%d\n", rv);
|
|
|
|
|
|
while (get_t_state(thi) == RUNNING) {
|
|
|
drbd_thread_current_set_cpu(thi);
|
|
|
|
|
|
rcu_read_lock();
|
|
|
- nc = rcu_dereference(tconn->net_conf);
|
|
|
+ nc = rcu_dereference(connection->net_conf);
|
|
|
ping_timeo = nc->ping_timeo;
|
|
|
tcp_cork = nc->tcp_cork;
|
|
|
ping_int = nc->ping_int;
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
- if (test_and_clear_bit(SEND_PING, &tconn->flags)) {
|
|
|
- if (drbd_send_ping(tconn)) {
|
|
|
- conn_err(tconn, "drbd_send_ping has failed\n");
|
|
|
+ if (test_and_clear_bit(SEND_PING, &connection->flags)) {
|
|
|
+ if (drbd_send_ping(connection)) {
|
|
|
+ drbd_err(connection, "drbd_send_ping has failed\n");
|
|
|
goto reconnect;
|
|
|
}
|
|
|
- tconn->meta.socket->sk->sk_rcvtimeo = ping_timeo * HZ / 10;
|
|
|
+ connection->meta.socket->sk->sk_rcvtimeo = ping_timeo * HZ / 10;
|
|
|
ping_timeout_active = true;
|
|
|
}
|
|
|
|
|
|
/* TODO: conditionally cork; it may hurt latency if we cork without
|
|
|
much to send */
|
|
|
if (tcp_cork)
|
|
|
- drbd_tcp_cork(tconn->meta.socket);
|
|
|
- if (tconn_finish_peer_reqs(tconn)) {
|
|
|
- conn_err(tconn, "tconn_finish_peer_reqs() failed\n");
|
|
|
+ drbd_tcp_cork(connection->meta.socket);
|
|
|
+ if (connection_finish_peer_reqs(connection)) {
|
|
|
+ drbd_err(connection, "connection_finish_peer_reqs() failed\n");
|
|
|
goto reconnect;
|
|
|
}
|
|
|
/* but unconditionally uncork unless disabled */
|
|
|
if (tcp_cork)
|
|
|
- drbd_tcp_uncork(tconn->meta.socket);
|
|
|
+ drbd_tcp_uncork(connection->meta.socket);
|
|
|
|
|
|
/* short circuit, recv_msg would return EINTR anyways. */
|
|
|
if (signal_pending(current))
|
|
|
continue;
|
|
|
|
|
|
- rv = drbd_recv_short(tconn->meta.socket, buf, expect-received, 0);
|
|
|
- clear_bit(SIGNAL_ASENDER, &tconn->flags);
|
|
|
+ rv = drbd_recv_short(connection->meta.socket, buf, expect-received, 0);
|
|
|
+ clear_bit(SIGNAL_ASENDER, &connection->flags);
|
|
|
|
|
|
flush_signals(current);
|
|
|
|
|
|
@@ -5316,51 +5386,51 @@ int drbd_asender(struct drbd_thread *thi)
|
|
|
received += rv;
|
|
|
buf += rv;
|
|
|
} else if (rv == 0) {
|
|
|
- if (test_bit(DISCONNECT_SENT, &tconn->flags)) {
|
|
|
+ if (test_bit(DISCONNECT_SENT, &connection->flags)) {
|
|
|
long t;
|
|
|
rcu_read_lock();
|
|
|
- t = rcu_dereference(tconn->net_conf)->ping_timeo * HZ/10;
|
|
|
+ t = rcu_dereference(connection->net_conf)->ping_timeo * HZ/10;
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
- t = wait_event_timeout(tconn->ping_wait,
|
|
|
- tconn->cstate < C_WF_REPORT_PARAMS,
|
|
|
+ t = wait_event_timeout(connection->ping_wait,
|
|
|
+ connection->cstate < C_WF_REPORT_PARAMS,
|
|
|
t);
|
|
|
if (t)
|
|
|
break;
|
|
|
}
|
|
|
- conn_err(tconn, "meta connection shut down by peer.\n");
|
|
|
+ drbd_err(connection, "meta connection shut down by peer.\n");
|
|
|
goto reconnect;
|
|
|
} else if (rv == -EAGAIN) {
|
|
|
/* If the data socket received something meanwhile,
|
|
|
* that is good enough: peer is still alive. */
|
|
|
- if (time_after(tconn->last_received,
|
|
|
- jiffies - tconn->meta.socket->sk->sk_rcvtimeo))
|
|
|
+ if (time_after(connection->last_received,
|
|
|
+ jiffies - connection->meta.socket->sk->sk_rcvtimeo))
|
|
|
continue;
|
|
|
if (ping_timeout_active) {
|
|
|
- conn_err(tconn, "PingAck did not arrive in time.\n");
|
|
|
+ drbd_err(connection, "PingAck did not arrive in time.\n");
|
|
|
goto reconnect;
|
|
|
}
|
|
|
- set_bit(SEND_PING, &tconn->flags);
|
|
|
+ set_bit(SEND_PING, &connection->flags);
|
|
|
continue;
|
|
|
} else if (rv == -EINTR) {
|
|
|
continue;
|
|
|
} else {
|
|
|
- conn_err(tconn, "sock_recvmsg returned %d\n", rv);
|
|
|
+ drbd_err(connection, "sock_recvmsg returned %d\n", rv);
|
|
|
goto reconnect;
|
|
|
}
|
|
|
|
|
|
if (received == expect && cmd == NULL) {
|
|
|
- if (decode_header(tconn, tconn->meta.rbuf, &pi))
|
|
|
+ if (decode_header(connection, connection->meta.rbuf, &pi))
|
|
|
goto reconnect;
|
|
|
cmd = &asender_tbl[pi.cmd];
|
|
|
if (pi.cmd >= ARRAY_SIZE(asender_tbl) || !cmd->fn) {
|
|
|
- conn_err(tconn, "Unexpected meta packet %s (0x%04x)\n",
|
|
|
+ drbd_err(connection, "Unexpected meta packet %s (0x%04x)\n",
|
|
|
cmdname(pi.cmd), pi.cmd);
|
|
|
goto disconnect;
|
|
|
}
|
|
|
expect = header_size + cmd->pkt_size;
|
|
|
if (pi.size != expect - header_size) {
|
|
|
- conn_err(tconn, "Wrong packet size on meta (c: %d, l: %d)\n",
|
|
|
+ drbd_err(connection, "Wrong packet size on meta (c: %d, l: %d)\n",
|
|
|
pi.cmd, pi.size);
|
|
|
goto reconnect;
|
|
|
}
|
|
|
@@ -5368,21 +5438,21 @@ int drbd_asender(struct drbd_thread *thi)
|
|
|
if (received == expect) {
|
|
|
bool err;
|
|
|
|
|
|
- err = cmd->fn(tconn, &pi);
|
|
|
+ err = cmd->fn(connection, &pi);
|
|
|
if (err) {
|
|
|
- conn_err(tconn, "%pf failed\n", cmd->fn);
|
|
|
+ drbd_err(connection, "%pf failed\n", cmd->fn);
|
|
|
goto reconnect;
|
|
|
}
|
|
|
|
|
|
- tconn->last_received = jiffies;
|
|
|
+ connection->last_received = jiffies;
|
|
|
|
|
|
if (cmd == &asender_tbl[P_PING_ACK]) {
|
|
|
/* restore idle timeout */
|
|
|
- tconn->meta.socket->sk->sk_rcvtimeo = ping_int * HZ;
|
|
|
+ connection->meta.socket->sk->sk_rcvtimeo = ping_int * HZ;
|
|
|
ping_timeout_active = false;
|
|
|
}
|
|
|
|
|
|
- buf = tconn->meta.rbuf;
|
|
|
+ buf = connection->meta.rbuf;
|
|
|
received = 0;
|
|
|
expect = header_size;
|
|
|
cmd = NULL;
|
|
|
@@ -5391,16 +5461,16 @@ int drbd_asender(struct drbd_thread *thi)
|
|
|
|
|
|
if (0) {
|
|
|
reconnect:
|
|
|
- conn_request_state(tconn, NS(conn, C_NETWORK_FAILURE), CS_HARD);
|
|
|
- conn_md_sync(tconn);
|
|
|
+ conn_request_state(connection, NS(conn, C_NETWORK_FAILURE), CS_HARD);
|
|
|
+ conn_md_sync(connection);
|
|
|
}
|
|
|
if (0) {
|
|
|
disconnect:
|
|
|
- conn_request_state(tconn, NS(conn, C_DISCONNECTING), CS_HARD);
|
|
|
+ conn_request_state(connection, NS(conn, C_DISCONNECTING), CS_HARD);
|
|
|
}
|
|
|
- clear_bit(SIGNAL_ASENDER, &tconn->flags);
|
|
|
+ clear_bit(SIGNAL_ASENDER, &connection->flags);
|
|
|
|
|
|
- conn_info(tconn, "asender terminated\n");
|
|
|
+ drbd_info(connection, "asender terminated\n");
|
|
|
|
|
|
return 0;
|
|
|
}
|