2009-09-26 07:07:19 +08:00
|
|
|
/*
|
|
|
|
drbd_worker.c
|
|
|
|
|
|
|
|
This file is part of DRBD by Philipp Reisner and Lars Ellenberg.
|
|
|
|
|
|
|
|
Copyright (C) 2001-2008, LINBIT Information Technologies GmbH.
|
|
|
|
Copyright (C) 1999-2008, Philipp Reisner <philipp.reisner@linbit.com>.
|
|
|
|
Copyright (C) 2002-2008, Lars Ellenberg <lars.ellenberg@linbit.com>.
|
|
|
|
|
|
|
|
drbd is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
drbd is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with drbd; see the file COPYING. If not, write to
|
|
|
|
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
2011-07-28 21:27:51 +08:00
|
|
|
*/
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/drbd.h>
|
2017-02-03 02:15:33 +08:00
|
|
|
#include <linux/sched/signal.h>
|
2009-09-26 07:07:19 +08:00
|
|
|
#include <linux/wait.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/memcontrol.h>
|
|
|
|
#include <linux/mm_inline.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/random.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/scatterlist.h>
|
|
|
|
|
|
|
|
#include "drbd_int.h"
|
2011-05-30 17:47:37 +08:00
|
|
|
#include "drbd_protocol.h"
|
2009-09-26 07:07:19 +08:00
|
|
|
#include "drbd_req.h"
|
|
|
|
|
2011-08-25 22:59:58 +08:00
|
|
|
static int make_ov_request(struct drbd_device *, int);
|
|
|
|
static int make_resync_request(struct drbd_device *, int);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-01-26 00:33:38 +08:00
|
|
|
/* endio handlers:
|
2014-09-11 20:29:06 +08:00
|
|
|
* drbd_md_endio (defined here)
|
2011-02-17 23:46:59 +08:00
|
|
|
* drbd_request_endio (defined here)
|
|
|
|
* drbd_peer_request_endio (defined here)
|
2014-09-11 20:29:06 +08:00
|
|
|
* drbd_bm_endio (defined in drbd_bitmap.c)
|
2011-01-26 00:33:38 +08:00
|
|
|
*
|
2009-09-26 07:07:19 +08:00
|
|
|
* For all these callbacks, note the following:
|
|
|
|
* The callbacks will be called in irq context by the IDE drivers,
|
|
|
|
* and in Softirqs/Tasklets/BH context by the SCSI drivers.
|
|
|
|
* Try to get the locking right :)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* used for synchronous meta data and bitmap IO
|
|
|
|
* submitted by drbd_md_sync_page_io()
|
|
|
|
*/
|
2015-07-20 21:29:37 +08:00
|
|
|
void drbd_md_endio(struct bio *bio)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
2011-07-03 19:26:43 +08:00
|
|
|
struct drbd_device *device;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2014-04-02 05:53:30 +08:00
|
|
|
device = bio->bi_private;
|
2017-06-03 15:38:06 +08:00
|
|
|
device->md_io.error = blk_status_to_errno(bio->bi_status);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2017-08-29 16:20:39 +08:00
|
|
|
/* special case: drbd_md_read() during drbd_adm_attach() */
|
|
|
|
if (device->ldev)
|
|
|
|
put_ldev(device);
|
|
|
|
bio_put(bio);
|
|
|
|
|
2011-11-10 19:12:52 +08:00
|
|
|
/* We grabbed an extra reference in _drbd_md_sync_page_io() to be able
|
|
|
|
* to timeout on the lower level device, and eventually detach from it.
|
|
|
|
* If this io completion runs after that timeout expired, this
|
|
|
|
* drbd_md_put_buffer() may allow us to finally try and re-attach.
|
|
|
|
* During normal operation, this only puts that extra reference
|
|
|
|
* down to 1 again.
|
|
|
|
* Make sure we first drop the reference, and only then signal
|
|
|
|
* completion, or we may (in drbd_al_read_log()) cycle so fast into the
|
|
|
|
* next drbd_md_sync_page_io(), that we trigger the
|
2011-07-03 19:26:43 +08:00
|
|
|
* ASSERT(atomic_read(&device->md_io_in_use) == 1) there.
|
2011-11-10 19:12:52 +08:00
|
|
|
*/
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_md_put_buffer(device);
|
2014-04-02 05:53:30 +08:00
|
|
|
device->md_io.done = 1;
|
2011-07-03 19:26:43 +08:00
|
|
|
wake_up(&device->misc_wait);
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* reads on behalf of the partner,
|
|
|
|
* "submitted" by the receiver
|
|
|
|
*/
|
2013-12-19 17:36:10 +08:00
|
|
|
static void drbd_endio_read_sec_final(struct drbd_peer_request *peer_req) __releases(local)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
|
|
|
unsigned long flags = 0;
|
2011-09-13 16:39:41 +08:00
|
|
|
struct drbd_peer_device *peer_device = peer_req->peer_device;
|
|
|
|
struct drbd_device *device = peer_device->device;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-07-07 20:19:42 +08:00
|
|
|
spin_lock_irqsave(&device->resource->req_lock, flags);
|
2011-07-03 19:26:43 +08:00
|
|
|
device->read_cnt += peer_req->i.size >> 9;
|
2011-08-25 21:49:40 +08:00
|
|
|
list_del(&peer_req->w.list);
|
2011-07-03 19:26:43 +08:00
|
|
|
if (list_empty(&device->read_ee))
|
|
|
|
wake_up(&device->ee_wait);
|
2011-02-04 22:57:48 +08:00
|
|
|
if (test_bit(__EE_WAS_ERROR, &peer_req->flags))
|
2011-07-03 19:26:43 +08:00
|
|
|
__drbd_chk_io_error(device, DRBD_READ_ERROR);
|
2011-07-07 20:19:42 +08:00
|
|
|
spin_unlock_irqrestore(&device->resource->req_lock, flags);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-09-13 16:39:41 +08:00
|
|
|
drbd_queue_work(&peer_device->connection->sender_work, &peer_req->w);
|
2011-07-03 19:26:43 +08:00
|
|
|
put_ldev(device);
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* writes on behalf of the partner, or resync writes,
|
2010-05-14 23:10:48 +08:00
|
|
|
* "submitted" by the receiver, final stage. */
|
2014-04-29 00:43:23 +08:00
|
|
|
void drbd_endio_write_sec_final(struct drbd_peer_request *peer_req) __releases(local)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
|
|
|
unsigned long flags = 0;
|
2011-09-13 16:39:41 +08:00
|
|
|
struct drbd_peer_device *peer_device = peer_req->peer_device;
|
|
|
|
struct drbd_device *device = peer_device->device;
|
2015-03-16 23:08:29 +08:00
|
|
|
struct drbd_connection *connection = peer_device->connection;
|
2011-03-31 21:18:56 +08:00
|
|
|
struct drbd_interval i;
|
2009-09-26 07:07:19 +08:00
|
|
|
int do_wake;
|
2011-01-14 01:40:57 +08:00
|
|
|
u64 block_id;
|
2009-09-26 07:07:19 +08:00
|
|
|
int do_al_complete_io;
|
|
|
|
|
2011-02-04 22:57:48 +08:00
|
|
|
/* after we moved peer_req to done_ee,
|
2009-09-26 07:07:19 +08:00
|
|
|
* we may no longer access it,
|
|
|
|
* it may be freed/reused already!
|
|
|
|
* (as soon as we release the req_lock) */
|
2011-03-31 21:18:56 +08:00
|
|
|
i = peer_req->i;
|
2011-02-04 22:57:48 +08:00
|
|
|
do_al_complete_io = peer_req->flags & EE_CALL_AL_COMPLETE_IO;
|
|
|
|
block_id = peer_req->block_id;
|
2014-05-06 05:42:24 +08:00
|
|
|
peer_req->flags &= ~EE_CALL_AL_COMPLETE_IO;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
drbd: Send P_NEG_ACK upon write error in protocol != C
In protocol != C, we forgot to send the P_NEG_ACK for failing writes.
Once we no longer submit to local disk, because we already "detached",
due to the typical "on-io-error detach;" config setting,
we already send the neg acks right away.
Only those requests that have been submitted,
and have been error-completed by the local disk,
would forget to send the neg-ack,
and only in asynchronous replication (protocol != C).
Unless this happened during resync,
where we already always send acks, regardless of protocol.
The primary side needs the P_NEG_ACK in order to mark
the affected block(s) for resync in its out-of-sync bitmap.
If the blocks in question are not re-written again,
we may miss to resync them later, causing data inconsistencies.
This patch will always send the neg-acks, and also at least try to
persist the out-of-sync status on the local node already.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2017-08-29 16:20:35 +08:00
|
|
|
if (peer_req->flags & EE_WAS_ERROR) {
|
|
|
|
/* In protocol != C, we usually do not send write acks.
|
|
|
|
* In case of a write error, send the neg ack anyways. */
|
|
|
|
if (!__test_and_set_bit(__EE_SEND_WRITE_ACK, &peer_req->flags))
|
|
|
|
inc_unacked(device);
|
|
|
|
drbd_set_out_of_sync(device, peer_req->i.sector, peer_req->i.size);
|
|
|
|
}
|
|
|
|
|
2011-07-07 20:19:42 +08:00
|
|
|
spin_lock_irqsave(&device->resource->req_lock, flags);
|
2011-07-03 19:26:43 +08:00
|
|
|
device->writ_cnt += peer_req->i.size >> 9;
|
2011-08-25 21:49:40 +08:00
|
|
|
list_move_tail(&peer_req->w.list, &device->done_ee);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-01-21 22:59:23 +08:00
|
|
|
/*
|
2011-01-27 21:42:51 +08:00
|
|
|
* Do not remove from the write_requests tree here: we did not send the
|
2011-01-21 22:59:23 +08:00
|
|
|
* Ack yet and did not wake possibly waiting conflicting requests.
|
|
|
|
* Removed from the tree from "drbd_process_done_ee" within the
|
2011-07-28 21:27:51 +08:00
|
|
|
* appropriate dw.cb (e_end_block/e_end_resync_block) or from
|
2011-01-21 22:59:23 +08:00
|
|
|
* _drbd_clear_done_ee.
|
|
|
|
*/
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
do_wake = list_empty(block_id == ID_SYNCER ? &device->sync_ee : &device->active_ee);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2014-04-29 00:43:23 +08:00
|
|
|
/* FIXME do we want to detach for failed REQ_DISCARD?
|
|
|
|
* ((peer_req->flags & (EE_WAS_ERROR|EE_IS_TRIM)) == EE_WAS_ERROR) */
|
|
|
|
if (peer_req->flags & EE_WAS_ERROR)
|
2011-07-03 19:26:43 +08:00
|
|
|
__drbd_chk_io_error(device, DRBD_WRITE_ERROR);
|
2015-03-16 23:08:29 +08:00
|
|
|
|
|
|
|
if (connection->cstate >= C_WF_REPORT_PARAMS) {
|
|
|
|
kref_get(&device->kref); /* put is in drbd_send_acks_wf() */
|
|
|
|
if (!queue_work(connection->ack_sender, &peer_device->send_acks_work))
|
|
|
|
kref_put(&device->kref, drbd_destroy_device);
|
|
|
|
}
|
2011-07-07 20:19:42 +08:00
|
|
|
spin_unlock_irqrestore(&device->resource->req_lock, flags);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-01-14 01:40:57 +08:00
|
|
|
if (block_id == ID_SYNCER)
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_rs_complete_io(device, i.sector);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
if (do_wake)
|
2011-07-03 19:26:43 +08:00
|
|
|
wake_up(&device->ee_wait);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
if (do_al_complete_io)
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_al_complete_io(device, &i);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
put_ldev(device);
|
2010-05-14 23:10:48 +08:00
|
|
|
}
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2010-05-14 23:10:48 +08:00
|
|
|
/* writes on behalf of the partner, or resync writes,
|
|
|
|
* "submitted" by the receiver.
|
|
|
|
*/
|
2015-07-20 21:29:37 +08:00
|
|
|
void drbd_peer_request_endio(struct bio *bio)
|
2010-05-14 23:10:48 +08:00
|
|
|
{
|
2011-02-04 22:57:48 +08:00
|
|
|
struct drbd_peer_request *peer_req = bio->bi_private;
|
2011-08-25 21:49:40 +08:00
|
|
|
struct drbd_device *device = peer_req->peer_device->device;
|
2016-06-14 06:26:35 +08:00
|
|
|
bool is_write = bio_data_dir(bio) == WRITE;
|
2017-04-06 01:21:22 +08:00
|
|
|
bool is_discard = bio_op(bio) == REQ_OP_WRITE_ZEROES ||
|
|
|
|
bio_op(bio) == REQ_OP_DISCARD;
|
2010-05-14 23:10:48 +08:00
|
|
|
|
2017-06-03 15:38:06 +08:00
|
|
|
if (bio->bi_status && __ratelimit(&drbd_ratelimit_state))
|
2011-07-03 23:53:52 +08:00
|
|
|
drbd_warn(device, "%s: error=%d s=%llus\n",
|
2014-04-29 00:43:23 +08:00
|
|
|
is_write ? (is_discard ? "discard" : "write")
|
2017-06-03 15:38:06 +08:00
|
|
|
: "read", bio->bi_status,
|
2011-02-04 22:57:48 +08:00
|
|
|
(unsigned long long)peer_req->i.sector);
|
2010-05-14 23:10:48 +08:00
|
|
|
|
2017-06-03 15:38:06 +08:00
|
|
|
if (bio->bi_status)
|
2011-02-04 22:57:48 +08:00
|
|
|
set_bit(__EE_WAS_ERROR, &peer_req->flags);
|
2010-05-14 23:10:48 +08:00
|
|
|
|
|
|
|
bio_put(bio); /* no need for the bio anymore */
|
2011-02-04 22:57:48 +08:00
|
|
|
if (atomic_dec_and_test(&peer_req->pending_bios)) {
|
2010-05-14 23:10:48 +08:00
|
|
|
if (is_write)
|
2011-02-04 22:57:48 +08:00
|
|
|
drbd_endio_write_sec_final(peer_req);
|
2010-05-14 23:10:48 +08:00
|
|
|
else
|
2011-02-04 22:57:48 +08:00
|
|
|
drbd_endio_read_sec_final(peer_req);
|
2010-05-14 23:10:48 +08:00
|
|
|
}
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2017-08-29 16:20:36 +08:00
|
|
|
static void
|
|
|
|
drbd_panic_after_delayed_completion_of_aborted_request(struct drbd_device *device)
|
2015-02-19 20:48:59 +08:00
|
|
|
{
|
|
|
|
panic("drbd%u %s/%u potential random memory corruption caused by delayed completion of aborted local request\n",
|
|
|
|
device->minor, device->resource->name, device->vnr);
|
|
|
|
}
|
|
|
|
|
2009-09-26 07:07:19 +08:00
|
|
|
/* read, readA or write requests on R_PRIMARY coming from drbd_make_request
|
|
|
|
*/
|
2015-07-20 21:29:37 +08:00
|
|
|
void drbd_request_endio(struct bio *bio)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
2010-11-14 03:42:29 +08:00
|
|
|
unsigned long flags;
|
2009-09-26 07:07:19 +08:00
|
|
|
struct drbd_request *req = bio->bi_private;
|
2011-07-28 21:27:51 +08:00
|
|
|
struct drbd_device *device = req->device;
|
2010-11-14 03:42:29 +08:00
|
|
|
struct bio_and_error m;
|
2009-09-26 07:07:19 +08:00
|
|
|
enum drbd_req_event what;
|
drbd: panic on delayed completion of aborted requests
"aborting" requests, or force-detaching the disk, is intended for
completely blocked/hung local backing devices which do no longer
complete requests at all, not even do error completions. In this
situation, usually a hard-reset and failover is the only way out.
By "aborting", basically faking a local error-completion,
we allow for a more graceful swichover by cleanly migrating services.
Still the affected node has to be rebooted "soon".
By completing these requests, we allow the upper layers to re-use
the associated data pages.
If later the local backing device "recovers", and now DMAs some data
from disk into the original request pages, in the best case it will
just put random data into unused pages; but typically it will corrupt
meanwhile completely unrelated data, causing all sorts of damage.
Which means delayed successful completion,
especially for READ requests,
is a reason to panic().
We assume that a delayed *error* completion is OK,
though we still will complain noisily about it.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
2012-09-04 21:16:20 +08:00
|
|
|
|
|
|
|
/* If this request was aborted locally before,
|
|
|
|
* but now was completed "successfully",
|
|
|
|
* chances are that this caused arbitrary data corruption.
|
|
|
|
*
|
|
|
|
* "aborting" requests, or force-detaching the disk, is intended for
|
|
|
|
* completely blocked/hung local backing devices which do no longer
|
|
|
|
* complete requests at all, not even do error completions. In this
|
|
|
|
* situation, usually a hard-reset and failover is the only way out.
|
|
|
|
*
|
|
|
|
* By "aborting", basically faking a local error-completion,
|
|
|
|
* we allow for a more graceful swichover by cleanly migrating services.
|
|
|
|
* Still the affected node has to be rebooted "soon".
|
|
|
|
*
|
|
|
|
* By completing these requests, we allow the upper layers to re-use
|
|
|
|
* the associated data pages.
|
|
|
|
*
|
|
|
|
* If later the local backing device "recovers", and now DMAs some data
|
|
|
|
* from disk into the original request pages, in the best case it will
|
|
|
|
* just put random data into unused pages; but typically it will corrupt
|
|
|
|
* meanwhile completely unrelated data, causing all sorts of damage.
|
|
|
|
*
|
|
|
|
* Which means delayed successful completion,
|
|
|
|
* especially for READ requests,
|
|
|
|
* is a reason to panic().
|
|
|
|
*
|
|
|
|
* We assume that a delayed *error* completion is OK,
|
|
|
|
* though we still will complain noisily about it.
|
|
|
|
*/
|
|
|
|
if (unlikely(req->rq_state & RQ_LOCAL_ABORTED)) {
|
|
|
|
if (__ratelimit(&drbd_ratelimit_state))
|
2011-07-03 23:53:52 +08:00
|
|
|
drbd_emerg(device, "delayed completion of aborted local request; disk-timeout may be too aggressive\n");
|
drbd: panic on delayed completion of aborted requests
"aborting" requests, or force-detaching the disk, is intended for
completely blocked/hung local backing devices which do no longer
complete requests at all, not even do error completions. In this
situation, usually a hard-reset and failover is the only way out.
By "aborting", basically faking a local error-completion,
we allow for a more graceful swichover by cleanly migrating services.
Still the affected node has to be rebooted "soon".
By completing these requests, we allow the upper layers to re-use
the associated data pages.
If later the local backing device "recovers", and now DMAs some data
from disk into the original request pages, in the best case it will
just put random data into unused pages; but typically it will corrupt
meanwhile completely unrelated data, causing all sorts of damage.
Which means delayed successful completion,
especially for READ requests,
is a reason to panic().
We assume that a delayed *error* completion is OK,
though we still will complain noisily about it.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
2012-09-04 21:16:20 +08:00
|
|
|
|
2017-06-03 15:38:06 +08:00
|
|
|
if (!bio->bi_status)
|
2015-02-19 20:48:59 +08:00
|
|
|
drbd_panic_after_delayed_completion_of_aborted_request(device);
|
drbd: panic on delayed completion of aborted requests
"aborting" requests, or force-detaching the disk, is intended for
completely blocked/hung local backing devices which do no longer
complete requests at all, not even do error completions. In this
situation, usually a hard-reset and failover is the only way out.
By "aborting", basically faking a local error-completion,
we allow for a more graceful swichover by cleanly migrating services.
Still the affected node has to be rebooted "soon".
By completing these requests, we allow the upper layers to re-use
the associated data pages.
If later the local backing device "recovers", and now DMAs some data
from disk into the original request pages, in the best case it will
just put random data into unused pages; but typically it will corrupt
meanwhile completely unrelated data, causing all sorts of damage.
Which means delayed successful completion,
especially for READ requests,
is a reason to panic().
We assume that a delayed *error* completion is OK,
though we still will complain noisily about it.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
2012-09-04 21:16:20 +08:00
|
|
|
}
|
|
|
|
|
2009-09-26 07:07:19 +08:00
|
|
|
/* to avoid recursion in __req_mod */
|
2017-06-03 15:38:06 +08:00
|
|
|
if (unlikely(bio->bi_status)) {
|
2016-07-19 17:28:41 +08:00
|
|
|
switch (bio_op(bio)) {
|
2017-04-06 01:21:22 +08:00
|
|
|
case REQ_OP_WRITE_ZEROES:
|
2016-07-19 17:28:41 +08:00
|
|
|
case REQ_OP_DISCARD:
|
2017-06-03 15:38:06 +08:00
|
|
|
if (bio->bi_status == BLK_STS_NOTSUPP)
|
2016-07-19 17:28:41 +08:00
|
|
|
what = DISCARD_COMPLETED_NOTSUPP;
|
|
|
|
else
|
|
|
|
what = DISCARD_COMPLETED_WITH_ERROR;
|
|
|
|
break;
|
|
|
|
case REQ_OP_READ:
|
2016-08-06 05:35:16 +08:00
|
|
|
if (bio->bi_opf & REQ_RAHEAD)
|
2016-07-19 17:28:41 +08:00
|
|
|
what = READ_AHEAD_COMPLETED_WITH_ERROR;
|
|
|
|
else
|
|
|
|
what = READ_COMPLETED_WITH_ERROR;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
what = WRITE_COMPLETED_WITH_ERROR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
2011-01-25 22:37:43 +08:00
|
|
|
what = COMPLETED_OK;
|
2016-07-19 17:28:41 +08:00
|
|
|
}
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
bio_put(req->private_bio);
|
2017-06-03 15:38:06 +08:00
|
|
|
req->private_bio = ERR_PTR(blk_status_to_errno(bio->bi_status));
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2010-11-14 03:42:29 +08:00
|
|
|
/* not req_mod(), we need irqsave here! */
|
2011-07-07 20:19:42 +08:00
|
|
|
spin_lock_irqsave(&device->resource->req_lock, flags);
|
2010-11-14 03:42:29 +08:00
|
|
|
__req_mod(req, what, &m);
|
2011-07-07 20:19:42 +08:00
|
|
|
spin_unlock_irqrestore(&device->resource->req_lock, flags);
|
2011-07-03 19:26:43 +08:00
|
|
|
put_ldev(device);
|
2010-11-14 03:42:29 +08:00
|
|
|
|
|
|
|
if (m.bio)
|
2011-07-03 19:26:43 +08:00
|
|
|
complete_master_bio(device, &m);
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2016-01-24 21:19:21 +08:00
|
|
|
void drbd_csum_ee(struct crypto_ahash *tfm, struct drbd_peer_request *peer_req, void *digest)
|
2010-05-14 23:10:48 +08:00
|
|
|
{
|
2016-01-24 21:19:21 +08:00
|
|
|
AHASH_REQUEST_ON_STACK(req, tfm);
|
2010-05-14 23:10:48 +08:00
|
|
|
struct scatterlist sg;
|
2011-02-04 22:57:48 +08:00
|
|
|
struct page *page = peer_req->pages;
|
2010-05-14 23:10:48 +08:00
|
|
|
struct page *tmp;
|
|
|
|
unsigned len;
|
|
|
|
|
2016-01-24 21:19:21 +08:00
|
|
|
ahash_request_set_tfm(req, tfm);
|
|
|
|
ahash_request_set_callback(req, 0, NULL, NULL);
|
2010-05-14 23:10:48 +08:00
|
|
|
|
|
|
|
sg_init_table(&sg, 1);
|
2016-01-24 21:19:21 +08:00
|
|
|
crypto_ahash_init(req);
|
2010-05-14 23:10:48 +08:00
|
|
|
|
|
|
|
while ((tmp = page_chain_next(page))) {
|
|
|
|
/* all but the last page will be fully used */
|
|
|
|
sg_set_page(&sg, page, PAGE_SIZE, 0);
|
2016-01-24 21:19:21 +08:00
|
|
|
ahash_request_set_crypt(req, &sg, NULL, sg.length);
|
|
|
|
crypto_ahash_update(req);
|
2010-05-14 23:10:48 +08:00
|
|
|
page = tmp;
|
|
|
|
}
|
|
|
|
/* and now the last, possibly only partially used page */
|
2011-02-04 22:57:48 +08:00
|
|
|
len = peer_req->i.size & (PAGE_SIZE - 1);
|
2010-05-14 23:10:48 +08:00
|
|
|
sg_set_page(&sg, page, len ?: PAGE_SIZE, 0);
|
2016-01-24 21:19:21 +08:00
|
|
|
ahash_request_set_crypt(req, &sg, digest, sg.length);
|
|
|
|
crypto_ahash_finup(req);
|
|
|
|
ahash_request_zero(req);
|
2010-05-14 23:10:48 +08:00
|
|
|
}
|
|
|
|
|
2016-01-24 21:19:21 +08:00
|
|
|
void drbd_csum_bio(struct crypto_ahash *tfm, struct bio *bio, void *digest)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
2016-01-24 21:19:21 +08:00
|
|
|
AHASH_REQUEST_ON_STACK(req, tfm);
|
2009-09-26 07:07:19 +08:00
|
|
|
struct scatterlist sg;
|
2013-11-24 09:19:00 +08:00
|
|
|
struct bio_vec bvec;
|
|
|
|
struct bvec_iter iter;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2016-01-24 21:19:21 +08:00
|
|
|
ahash_request_set_tfm(req, tfm);
|
|
|
|
ahash_request_set_callback(req, 0, NULL, NULL);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
sg_init_table(&sg, 1);
|
2016-01-24 21:19:21 +08:00
|
|
|
crypto_ahash_init(req);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2013-11-24 09:19:00 +08:00
|
|
|
bio_for_each_segment(bvec, bio, iter) {
|
|
|
|
sg_set_page(&sg, bvec.bv_page, bvec.bv_len, bvec.bv_offset);
|
2016-01-24 21:19:21 +08:00
|
|
|
ahash_request_set_crypt(req, &sg, NULL, sg.length);
|
|
|
|
crypto_ahash_update(req);
|
2016-06-14 06:26:31 +08:00
|
|
|
/* REQ_OP_WRITE_SAME has only one segment,
|
|
|
|
* checksum the payload only once. */
|
|
|
|
if (bio_op(bio) == REQ_OP_WRITE_SAME)
|
|
|
|
break;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
2016-01-24 21:19:21 +08:00
|
|
|
ahash_request_set_crypt(req, NULL, digest, 0);
|
|
|
|
crypto_ahash_final(req);
|
|
|
|
ahash_request_zero(req);
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-02-22 21:02:31 +08:00
|
|
|
/* MAYBE merge common code with w_e_end_ov_req */
|
2011-03-16 22:31:39 +08:00
|
|
|
static int w_e_send_csum(struct drbd_work *w, int cancel)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
2011-08-25 21:49:40 +08:00
|
|
|
struct drbd_peer_request *peer_req = container_of(w, struct drbd_peer_request, w);
|
2011-09-13 16:39:41 +08:00
|
|
|
struct drbd_peer_device *peer_device = peer_req->peer_device;
|
|
|
|
struct drbd_device *device = peer_device->device;
|
2009-09-26 07:07:19 +08:00
|
|
|
int digest_size;
|
|
|
|
void *digest;
|
2011-03-16 22:31:39 +08:00
|
|
|
int err = 0;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-03-09 00:11:40 +08:00
|
|
|
if (unlikely(cancel))
|
|
|
|
goto out;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-02-22 21:02:31 +08:00
|
|
|
if (unlikely((peer_req->flags & EE_WAS_ERROR) != 0))
|
2011-03-09 00:11:40 +08:00
|
|
|
goto out;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2016-01-24 21:19:21 +08:00
|
|
|
digest_size = crypto_ahash_digestsize(peer_device->connection->csums_tfm);
|
2011-03-09 00:11:40 +08:00
|
|
|
digest = kmalloc(digest_size, GFP_NOIO);
|
|
|
|
if (digest) {
|
2011-02-04 22:57:48 +08:00
|
|
|
sector_t sector = peer_req->i.sector;
|
|
|
|
unsigned int size = peer_req->i.size;
|
2011-09-13 16:39:41 +08:00
|
|
|
drbd_csum_ee(peer_device->connection->csums_tfm, peer_req, digest);
|
2011-02-22 21:02:31 +08:00
|
|
|
/* Free peer_req and pages before send.
|
2011-03-09 00:11:40 +08:00
|
|
|
* In case we block on congestion, we could otherwise run into
|
|
|
|
* some distributed deadlock, if the other side blocks on
|
|
|
|
* congestion as well, because our receiver blocks in
|
2011-04-08 03:02:09 +08:00
|
|
|
* drbd_alloc_pages due to pp_in_use > max_buffers. */
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_free_peer_req(device, peer_req);
|
2011-02-04 22:57:48 +08:00
|
|
|
peer_req = NULL;
|
2011-07-03 19:26:43 +08:00
|
|
|
inc_rs_pending(device);
|
2011-09-13 16:39:41 +08:00
|
|
|
err = drbd_send_drequest_csum(peer_device, sector, size,
|
2011-03-16 08:37:21 +08:00
|
|
|
digest, digest_size,
|
|
|
|
P_CSUM_RS_REQUEST);
|
2011-03-09 00:11:40 +08:00
|
|
|
kfree(digest);
|
|
|
|
} else {
|
2011-07-03 23:53:52 +08:00
|
|
|
drbd_err(device, "kmalloc() of digest failed.\n");
|
2011-03-16 22:31:39 +08:00
|
|
|
err = -ENOMEM;
|
2011-03-09 00:11:40 +08:00
|
|
|
}
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-03-09 00:11:40 +08:00
|
|
|
out:
|
2011-02-04 22:57:48 +08:00
|
|
|
if (peer_req)
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_free_peer_req(device, peer_req);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-03-16 22:31:39 +08:00
|
|
|
if (unlikely(err))
|
2011-07-03 23:53:52 +08:00
|
|
|
drbd_err(device, "drbd_send_drequest(..., csum) failed\n");
|
2011-03-16 22:31:39 +08:00
|
|
|
return err;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#define GFP_TRY (__GFP_HIGHMEM | __GFP_NOWARN)
|
|
|
|
|
drbd: Pass a peer device to a number of fuctions
These functions actually operate on a peer device, or
need a peer device.
drbd_prepare_command(), drbd_send_command(), drbd_send_sync_param()
drbd_send_uuids(), drbd_gen_and_send_sync_uuid(), drbd_send_sizes()
drbd_send_state(), drbd_send_current_state(), and drbd_send_state_req()
drbd_send_sr_reply(), drbd_send_ack(), drbd_send_drequest(),
drbd_send_drequest_csum(), drbd_send_ov_request(), drbd_send_dblock()
drbd_send_block(), drbd_send_out_of_sync(), recv_dless_read()
drbd_drain_block(), receive_bitmap_plain(), recv_resync_read()
read_in_block(), read_for_csum(), drbd_alloc_pages(), drbd_alloc_peer_req()
need_peer_seq(), update_peer_seq(), wait_for_and_update_peer_seq()
drbd_sync_handshake(), drbd_asb_recover_{0,1,2}p(), drbd_connected()
drbd_disconnected(), decode_bitmap_c() and recv_bm_rle_bits()
Signed-off-by: Andreas Gruenbacher <agruen@linbit.com>
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
2011-08-09 06:47:13 +08:00
|
|
|
static int read_for_csum(struct drbd_peer_device *peer_device, sector_t sector, int size)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
drbd: Pass a peer device to a number of fuctions
These functions actually operate on a peer device, or
need a peer device.
drbd_prepare_command(), drbd_send_command(), drbd_send_sync_param()
drbd_send_uuids(), drbd_gen_and_send_sync_uuid(), drbd_send_sizes()
drbd_send_state(), drbd_send_current_state(), and drbd_send_state_req()
drbd_send_sr_reply(), drbd_send_ack(), drbd_send_drequest(),
drbd_send_drequest_csum(), drbd_send_ov_request(), drbd_send_dblock()
drbd_send_block(), drbd_send_out_of_sync(), recv_dless_read()
drbd_drain_block(), receive_bitmap_plain(), recv_resync_read()
read_in_block(), read_for_csum(), drbd_alloc_pages(), drbd_alloc_peer_req()
need_peer_seq(), update_peer_seq(), wait_for_and_update_peer_seq()
drbd_sync_handshake(), drbd_asb_recover_{0,1,2}p(), drbd_connected()
drbd_disconnected(), decode_bitmap_c() and recv_bm_rle_bits()
Signed-off-by: Andreas Gruenbacher <agruen@linbit.com>
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
2011-08-09 06:47:13 +08:00
|
|
|
struct drbd_device *device = peer_device->device;
|
2011-02-04 22:57:48 +08:00
|
|
|
struct drbd_peer_request *peer_req;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
if (!get_ldev(device))
|
2010-08-12 05:28:00 +08:00
|
|
|
return -EIO;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
/* GFP_TRY, because if there is no memory available right now, this may
|
|
|
|
* be rescheduled for later. It is "only" background resync, after all. */
|
drbd: Pass a peer device to a number of fuctions
These functions actually operate on a peer device, or
need a peer device.
drbd_prepare_command(), drbd_send_command(), drbd_send_sync_param()
drbd_send_uuids(), drbd_gen_and_send_sync_uuid(), drbd_send_sizes()
drbd_send_state(), drbd_send_current_state(), and drbd_send_state_req()
drbd_send_sr_reply(), drbd_send_ack(), drbd_send_drequest(),
drbd_send_drequest_csum(), drbd_send_ov_request(), drbd_send_dblock()
drbd_send_block(), drbd_send_out_of_sync(), recv_dless_read()
drbd_drain_block(), receive_bitmap_plain(), recv_resync_read()
read_in_block(), read_for_csum(), drbd_alloc_pages(), drbd_alloc_peer_req()
need_peer_seq(), update_peer_seq(), wait_for_and_update_peer_seq()
drbd_sync_handshake(), drbd_asb_recover_{0,1,2}p(), drbd_connected()
drbd_disconnected(), decode_bitmap_c() and recv_bm_rle_bits()
Signed-off-by: Andreas Gruenbacher <agruen@linbit.com>
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
2011-08-09 06:47:13 +08:00
|
|
|
peer_req = drbd_alloc_peer_req(peer_device, ID_SYNCER /* unused */, sector,
|
2016-06-14 06:26:31 +08:00
|
|
|
size, size, GFP_TRY);
|
2011-02-04 22:57:48 +08:00
|
|
|
if (!peer_req)
|
2010-08-12 05:28:00 +08:00
|
|
|
goto defer;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-08-25 21:49:40 +08:00
|
|
|
peer_req->w.cb = w_e_send_csum;
|
2011-07-07 20:19:42 +08:00
|
|
|
spin_lock_irq(&device->resource->req_lock);
|
2014-04-23 18:15:35 +08:00
|
|
|
list_add_tail(&peer_req->w.list, &device->read_ee);
|
2011-07-07 20:19:42 +08:00
|
|
|
spin_unlock_irq(&device->resource->req_lock);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
atomic_add(size >> 9, &device->rs_sect_ev);
|
2016-06-06 03:32:06 +08:00
|
|
|
if (drbd_submit_peer_request(device, peer_req, REQ_OP_READ, 0,
|
|
|
|
DRBD_FAULT_RS_RD) == 0)
|
2010-08-12 05:28:00 +08:00
|
|
|
return 0;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-01-24 21:47:09 +08:00
|
|
|
/* If it failed because of ENOMEM, retry should help. If it failed
|
|
|
|
* because bio_add_page failed (probably broken lower level driver),
|
|
|
|
* retry may or may not help.
|
|
|
|
* If it does not, you may need to force disconnect. */
|
2011-07-07 20:19:42 +08:00
|
|
|
spin_lock_irq(&device->resource->req_lock);
|
2011-08-25 21:49:40 +08:00
|
|
|
list_del(&peer_req->w.list);
|
2011-07-07 20:19:42 +08:00
|
|
|
spin_unlock_irq(&device->resource->req_lock);
|
2010-09-15 02:40:41 +08:00
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_free_peer_req(device, peer_req);
|
2010-08-12 05:28:00 +08:00
|
|
|
defer:
|
2011-07-03 19:26:43 +08:00
|
|
|
put_ldev(device);
|
2010-08-12 05:28:00 +08:00
|
|
|
return -EAGAIN;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-03-16 22:31:39 +08:00
|
|
|
int w_resync_timer(struct drbd_work *w, int cancel)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
2011-07-28 21:27:51 +08:00
|
|
|
struct drbd_device *device =
|
|
|
|
container_of(w, struct drbd_device, resync_work);
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
switch (device->state.conn) {
|
2010-09-01 21:47:15 +08:00
|
|
|
case C_VERIFY_S:
|
2011-08-25 22:59:58 +08:00
|
|
|
make_ov_request(device, cancel);
|
2010-09-01 21:47:15 +08:00
|
|
|
break;
|
|
|
|
case C_SYNC_TARGET:
|
2011-08-25 22:59:58 +08:00
|
|
|
make_resync_request(device, cancel);
|
2010-09-01 21:47:15 +08:00
|
|
|
break;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-03-16 22:31:39 +08:00
|
|
|
return 0;
|
2010-12-27 18:51:23 +08:00
|
|
|
}
|
|
|
|
|
2017-10-18 11:33:01 +08:00
|
|
|
void resync_timer_fn(struct timer_list *t)
|
2010-12-27 18:51:23 +08:00
|
|
|
{
|
2017-10-18 11:33:01 +08:00
|
|
|
struct drbd_device *device = from_timer(device, t, resync_timer);
|
2010-12-27 18:51:23 +08:00
|
|
|
|
2014-04-28 17:43:21 +08:00
|
|
|
drbd_queue_work_if_unqueued(
|
|
|
|
&first_peer_device(device)->connection->sender_work,
|
|
|
|
&device->resync_work);
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2010-07-06 17:14:00 +08:00
|
|
|
static void fifo_set(struct fifo_buffer *fb, int value)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < fb->size; i++)
|
2010-10-05 22:50:17 +08:00
|
|
|
fb->values[i] = value;
|
2010-07-06 17:14:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int fifo_push(struct fifo_buffer *fb, int value)
|
|
|
|
{
|
|
|
|
int ov;
|
|
|
|
|
|
|
|
ov = fb->values[fb->head_index];
|
|
|
|
fb->values[fb->head_index++] = value;
|
|
|
|
|
|
|
|
if (fb->head_index >= fb->size)
|
|
|
|
fb->head_index = 0;
|
|
|
|
|
|
|
|
return ov;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void fifo_add_val(struct fifo_buffer *fb, int value)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < fb->size; i++)
|
|
|
|
fb->values[i] += value;
|
|
|
|
}
|
|
|
|
|
2011-05-03 22:19:31 +08:00
|
|
|
struct fifo_buffer *fifo_alloc(int fifo_size)
|
|
|
|
{
|
|
|
|
struct fifo_buffer *fb;
|
|
|
|
|
2012-09-26 20:22:40 +08:00
|
|
|
fb = kzalloc(sizeof(struct fifo_buffer) + sizeof(int) * fifo_size, GFP_NOIO);
|
2011-05-03 22:19:31 +08:00
|
|
|
if (!fb)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
fb->head_index = 0;
|
|
|
|
fb->size = fifo_size;
|
|
|
|
fb->total = 0;
|
|
|
|
|
|
|
|
return fb;
|
|
|
|
}
|
|
|
|
|
2014-04-29 00:43:18 +08:00
|
|
|
static int drbd_rs_controller(struct drbd_device *device, unsigned int sect_in)
|
2010-07-06 17:14:00 +08:00
|
|
|
{
|
2011-05-03 21:00:55 +08:00
|
|
|
struct disk_conf *dc;
|
2014-04-22 22:37:16 +08:00
|
|
|
unsigned int want; /* The number of sectors we want in-flight */
|
2010-07-06 17:14:00 +08:00
|
|
|
int req_sect; /* Number of sectors to request in this turn */
|
2014-04-22 22:37:16 +08:00
|
|
|
int correction; /* Number of sectors more we need in-flight */
|
2010-07-06 17:14:00 +08:00
|
|
|
int cps; /* correction per invocation of drbd_rs_controller() */
|
|
|
|
int steps; /* Number of time steps to plan ahead */
|
|
|
|
int curr_corr;
|
|
|
|
int max_sect;
|
2011-05-03 22:47:02 +08:00
|
|
|
struct fifo_buffer *plan;
|
2010-07-06 17:14:00 +08:00
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
dc = rcu_dereference(device->ldev->disk_conf);
|
|
|
|
plan = rcu_dereference(device->rs_plan_s);
|
2010-07-06 17:14:00 +08:00
|
|
|
|
2011-05-03 22:47:02 +08:00
|
|
|
steps = plan->size; /* (dc->c_plan_ahead * 10 * SLEEP_TIME) / HZ; */
|
2010-07-06 17:14:00 +08:00
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
if (device->rs_in_flight + sect_in == 0) { /* At start of resync */
|
2011-05-03 21:00:55 +08:00
|
|
|
want = ((dc->resync_rate * 2 * SLEEP_TIME) / HZ) * steps;
|
2010-07-06 17:14:00 +08:00
|
|
|
} else { /* normal path */
|
2011-05-03 21:00:55 +08:00
|
|
|
want = dc->c_fill_target ? dc->c_fill_target :
|
|
|
|
sect_in * dc->c_delay_target * HZ / (SLEEP_TIME * 10);
|
2010-07-06 17:14:00 +08:00
|
|
|
}
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
correction = want - device->rs_in_flight - plan->total;
|
2010-07-06 17:14:00 +08:00
|
|
|
|
|
|
|
/* Plan ahead */
|
|
|
|
cps = correction / steps;
|
2011-05-03 22:47:02 +08:00
|
|
|
fifo_add_val(plan, cps);
|
|
|
|
plan->total += cps * steps;
|
2010-07-06 17:14:00 +08:00
|
|
|
|
|
|
|
/* What we do in this step */
|
2011-05-03 22:47:02 +08:00
|
|
|
curr_corr = fifo_push(plan, 0);
|
|
|
|
plan->total -= curr_corr;
|
2010-07-06 17:14:00 +08:00
|
|
|
|
|
|
|
req_sect = sect_in + curr_corr;
|
|
|
|
if (req_sect < 0)
|
|
|
|
req_sect = 0;
|
|
|
|
|
2011-05-03 21:00:55 +08:00
|
|
|
max_sect = (dc->c_max_rate * 2 * SLEEP_TIME) / HZ;
|
2010-07-06 17:14:00 +08:00
|
|
|
if (req_sect > max_sect)
|
|
|
|
req_sect = max_sect;
|
|
|
|
|
|
|
|
/*
|
2011-07-03 23:53:52 +08:00
|
|
|
drbd_warn(device, "si=%u if=%d wa=%u co=%d st=%d cps=%d pl=%d cc=%d rs=%d\n",
|
2011-07-03 19:26:43 +08:00
|
|
|
sect_in, device->rs_in_flight, want, correction,
|
|
|
|
steps, cps, device->rs_planed, curr_corr, req_sect);
|
2010-07-06 17:14:00 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
return req_sect;
|
|
|
|
}
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
static int drbd_rs_number_requests(struct drbd_device *device)
|
2010-11-05 17:04:07 +08:00
|
|
|
{
|
2014-04-29 00:43:18 +08:00
|
|
|
unsigned int sect_in; /* Number of sectors that came in since the last turn */
|
|
|
|
int number, mxb;
|
|
|
|
|
|
|
|
sect_in = atomic_xchg(&device->rs_sect_in, 0);
|
|
|
|
device->rs_in_flight -= sect_in;
|
2011-05-03 22:47:02 +08:00
|
|
|
|
|
|
|
rcu_read_lock();
|
2014-04-29 00:43:18 +08:00
|
|
|
mxb = drbd_get_max_buffers(device) / 2;
|
2011-07-03 19:26:43 +08:00
|
|
|
if (rcu_dereference(device->rs_plan_s)->size) {
|
2014-04-29 00:43:18 +08:00
|
|
|
number = drbd_rs_controller(device, sect_in) >> (BM_BLOCK_SHIFT - 9);
|
2011-07-03 19:26:43 +08:00
|
|
|
device->c_sync_rate = number * HZ * (BM_BLOCK_SIZE / 1024) / SLEEP_TIME;
|
2010-11-05 17:04:07 +08:00
|
|
|
} else {
|
2011-07-03 19:26:43 +08:00
|
|
|
device->c_sync_rate = rcu_dereference(device->ldev->disk_conf)->resync_rate;
|
|
|
|
number = SLEEP_TIME * device->c_sync_rate / ((BM_BLOCK_SIZE / 1024) * HZ);
|
2010-11-05 17:04:07 +08:00
|
|
|
}
|
2011-05-03 22:47:02 +08:00
|
|
|
rcu_read_unlock();
|
2010-11-05 17:04:07 +08:00
|
|
|
|
2014-04-29 00:43:18 +08:00
|
|
|
/* Don't have more than "max-buffers"/2 in-flight.
|
|
|
|
* Otherwise we may cause the remote site to stall on drbd_alloc_pages(),
|
|
|
|
* potentially causing a distributed deadlock on congestion during
|
|
|
|
* online-verify or (checksum-based) resync, if max-buffers,
|
|
|
|
* socket buffer sizes and resync rate settings are mis-configured. */
|
2014-04-22 22:37:16 +08:00
|
|
|
|
|
|
|
/* note that "number" is in units of "BM_BLOCK_SIZE" (which is 4k),
|
|
|
|
* mxb (as used here, and in drbd_alloc_pages on the peer) is
|
|
|
|
* "number of pages" (typically also 4k),
|
|
|
|
* but "rs_in_flight" is in "sectors" (512 Byte). */
|
|
|
|
if (mxb - device->rs_in_flight/8 < number)
|
|
|
|
number = mxb - device->rs_in_flight/8;
|
2014-04-29 00:43:18 +08:00
|
|
|
|
2010-11-05 17:04:07 +08:00
|
|
|
return number;
|
|
|
|
}
|
|
|
|
|
2013-11-22 19:40:58 +08:00
|
|
|
static int make_resync_request(struct drbd_device *const device, int cancel)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
2013-11-22 19:40:58 +08:00
|
|
|
struct drbd_peer_device *const peer_device = first_peer_device(device);
|
|
|
|
struct drbd_connection *const connection = peer_device ? peer_device->connection : NULL;
|
2009-09-26 07:07:19 +08:00
|
|
|
unsigned long bit;
|
|
|
|
sector_t sector;
|
2011-07-03 19:26:43 +08:00
|
|
|
const sector_t capacity = drbd_get_capacity(device->this_bdev);
|
2010-11-11 22:19:07 +08:00
|
|
|
int max_bio_size;
|
2010-11-05 17:04:07 +08:00
|
|
|
int number, rollback_i, size;
|
2014-01-31 21:55:12 +08:00
|
|
|
int align, requeue = 0;
|
2010-08-12 05:40:24 +08:00
|
|
|
int i = 0;
|
2016-06-14 06:26:15 +08:00
|
|
|
int discard_granularity = 0;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
if (unlikely(cancel))
|
2011-03-16 22:31:39 +08:00
|
|
|
return 0;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
if (device->rs_total == 0) {
|
2010-10-07 22:07:55 +08:00
|
|
|
/* empty resync? */
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_resync_finished(device);
|
2011-03-16 22:31:39 +08:00
|
|
|
return 0;
|
2010-10-07 22:07:55 +08:00
|
|
|
}
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
if (!get_ldev(device)) {
|
|
|
|
/* Since we only need to access device->rsync a
|
|
|
|
get_ldev_if_state(device,D_FAILED) would be sufficient, but
|
2009-09-26 07:07:19 +08:00
|
|
|
to continue resync with a broken disk makes no sense at
|
|
|
|
all */
|
2011-07-03 23:53:52 +08:00
|
|
|
drbd_err(device, "Disk broke down during resync!\n");
|
2011-03-16 22:31:39 +08:00
|
|
|
return 0;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2016-06-14 06:26:31 +08:00
|
|
|
if (connection->agreed_features & DRBD_FF_THIN_RESYNC) {
|
2016-06-14 06:26:15 +08:00
|
|
|
rcu_read_lock();
|
|
|
|
discard_granularity = rcu_dereference(device->ldev->disk_conf)->rs_discard_granularity;
|
|
|
|
rcu_read_unlock();
|
|
|
|
}
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
max_bio_size = queue_max_hw_sectors(device->rq_queue) << 9;
|
|
|
|
number = drbd_rs_number_requests(device);
|
2014-04-29 00:43:18 +08:00
|
|
|
if (number <= 0)
|
2010-08-12 05:40:24 +08:00
|
|
|
goto requeue;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
for (i = 0; i < number; i++) {
|
2014-01-31 21:55:12 +08:00
|
|
|
/* Stop generating RS requests when half of the send buffer is filled,
|
|
|
|
* but notify TCP that we'd like to have more space. */
|
2013-11-22 19:40:58 +08:00
|
|
|
mutex_lock(&connection->data.mutex);
|
|
|
|
if (connection->data.socket) {
|
2014-01-31 21:55:12 +08:00
|
|
|
struct sock *sk = connection->data.socket->sk;
|
|
|
|
int queued = sk->sk_wmem_queued;
|
|
|
|
int sndbuf = sk->sk_sndbuf;
|
|
|
|
if (queued > sndbuf / 2) {
|
|
|
|
requeue = 1;
|
|
|
|
if (sk->sk_socket)
|
|
|
|
set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
requeue = 1;
|
2013-11-22 19:40:58 +08:00
|
|
|
mutex_unlock(&connection->data.mutex);
|
2014-01-31 21:55:12 +08:00
|
|
|
if (requeue)
|
2009-09-26 07:07:19 +08:00
|
|
|
goto requeue;
|
|
|
|
|
|
|
|
next_sector:
|
|
|
|
size = BM_BLOCK_SIZE;
|
2011-07-03 19:26:43 +08:00
|
|
|
bit = drbd_bm_find_next(device, device->bm_resync_fo);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2010-12-14 22:13:04 +08:00
|
|
|
if (bit == DRBD_END_OF_BITMAP) {
|
2011-07-03 19:26:43 +08:00
|
|
|
device->bm_resync_fo = drbd_bm_bits(device);
|
|
|
|
put_ldev(device);
|
2011-03-16 22:31:39 +08:00
|
|
|
return 0;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
sector = BM_BIT_TO_SECT(bit);
|
|
|
|
|
2013-12-20 18:22:13 +08:00
|
|
|
if (drbd_try_rs_begin_io(device, sector)) {
|
2011-07-03 19:26:43 +08:00
|
|
|
device->bm_resync_fo = bit;
|
2009-09-26 07:07:19 +08:00
|
|
|
goto requeue;
|
|
|
|
}
|
2011-07-03 19:26:43 +08:00
|
|
|
device->bm_resync_fo = bit + 1;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
if (unlikely(drbd_bm_test_bit(device, bit) == 0)) {
|
|
|
|
drbd_rs_complete_io(device, sector);
|
2009-09-26 07:07:19 +08:00
|
|
|
goto next_sector;
|
|
|
|
}
|
|
|
|
|
2010-11-11 22:19:07 +08:00
|
|
|
#if DRBD_MAX_BIO_SIZE > BM_BLOCK_SIZE
|
2009-09-26 07:07:19 +08:00
|
|
|
/* try to find some adjacent bits.
|
|
|
|
* we stop if we have already the maximum req size.
|
|
|
|
*
|
|
|
|
* Additionally always align bigger requests, in order to
|
|
|
|
* be prepared for all stripe sizes of software RAIDs.
|
|
|
|
*/
|
|
|
|
align = 1;
|
2010-07-22 21:27:27 +08:00
|
|
|
rollback_i = i;
|
2014-04-29 00:43:17 +08:00
|
|
|
while (i < number) {
|
2010-11-11 22:19:07 +08:00
|
|
|
if (size + BM_BLOCK_SIZE > max_bio_size)
|
2009-09-26 07:07:19 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* Be always aligned */
|
|
|
|
if (sector & ((1<<(align+3))-1))
|
|
|
|
break;
|
|
|
|
|
2016-06-14 06:26:15 +08:00
|
|
|
if (discard_granularity && size == discard_granularity)
|
|
|
|
break;
|
|
|
|
|
2009-09-26 07:07:19 +08:00
|
|
|
/* do not cross extent boundaries */
|
|
|
|
if (((bit+1) & BM_BLOCKS_PER_BM_EXT_MASK) == 0)
|
|
|
|
break;
|
|
|
|
/* now, is it actually dirty, after all?
|
|
|
|
* caution, drbd_bm_test_bit is tri-state for some
|
|
|
|
* obscure reason; ( b == 0 ) would get the out-of-band
|
|
|
|
* only accidentally right because of the "oddly sized"
|
|
|
|
* adjustment below */
|
2011-07-03 19:26:43 +08:00
|
|
|
if (drbd_bm_test_bit(device, bit+1) != 1)
|
2009-09-26 07:07:19 +08:00
|
|
|
break;
|
|
|
|
bit++;
|
|
|
|
size += BM_BLOCK_SIZE;
|
|
|
|
if ((BM_BLOCK_SIZE << align) <= size)
|
|
|
|
align++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
/* if we merged some,
|
|
|
|
* reset the offset to start the next drbd_bm_find_next from */
|
|
|
|
if (size > BM_BLOCK_SIZE)
|
2011-07-03 19:26:43 +08:00
|
|
|
device->bm_resync_fo = bit + 1;
|
2009-09-26 07:07:19 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* adjust very last sectors, in case we are oddly sized */
|
|
|
|
if (sector + (size>>9) > capacity)
|
|
|
|
size = (capacity-sector)<<9;
|
2014-03-18 19:30:09 +08:00
|
|
|
|
|
|
|
if (device->use_csums) {
|
2013-11-22 19:40:58 +08:00
|
|
|
switch (read_for_csum(peer_device, sector, size)) {
|
2010-08-12 05:28:00 +08:00
|
|
|
case -EIO: /* Disk failure */
|
2011-07-03 19:26:43 +08:00
|
|
|
put_ldev(device);
|
2011-03-16 22:31:39 +08:00
|
|
|
return -EIO;
|
2010-08-12 05:28:00 +08:00
|
|
|
case -EAGAIN: /* allocation failed, or ldev busy */
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_rs_complete_io(device, sector);
|
|
|
|
device->bm_resync_fo = BM_SECT_TO_BIT(sector);
|
2010-07-22 21:27:27 +08:00
|
|
|
i = rollback_i;
|
2009-09-26 07:07:19 +08:00
|
|
|
goto requeue;
|
2010-08-12 05:28:00 +08:00
|
|
|
case 0:
|
|
|
|
/* everything ok */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BUG();
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
} else {
|
2011-03-16 22:31:39 +08:00
|
|
|
int err;
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
inc_rs_pending(device);
|
2016-06-14 06:26:15 +08:00
|
|
|
err = drbd_send_drequest(peer_device,
|
|
|
|
size == discard_granularity ? P_RS_THIN_REQ : P_RS_DATA_REQUEST,
|
2011-03-16 22:31:39 +08:00
|
|
|
sector, size, ID_SYNCER);
|
|
|
|
if (err) {
|
2011-07-03 23:53:52 +08:00
|
|
|
drbd_err(device, "drbd_send_drequest() failed, aborting...\n");
|
2011-07-03 19:26:43 +08:00
|
|
|
dec_rs_pending(device);
|
|
|
|
put_ldev(device);
|
2011-03-16 22:31:39 +08:00
|
|
|
return err;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
if (device->bm_resync_fo >= drbd_bm_bits(device)) {
|
2009-09-26 07:07:19 +08:00
|
|
|
/* last syncer _request_ was sent,
|
|
|
|
* but the P_RS_DATA_REPLY not yet received. sync will end (and
|
|
|
|
* next sync group will resume), as soon as we receive the last
|
|
|
|
* resync data block, and the last bit is cleared.
|
|
|
|
* until then resync "work" is "inactive" ...
|
|
|
|
*/
|
2011-07-03 19:26:43 +08:00
|
|
|
put_ldev(device);
|
2011-03-16 22:31:39 +08:00
|
|
|
return 0;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
requeue:
|
2011-07-03 19:26:43 +08:00
|
|
|
device->rs_in_flight += (i << (BM_BLOCK_SHIFT - 9));
|
|
|
|
mod_timer(&device->resync_timer, jiffies + SLEEP_TIME);
|
|
|
|
put_ldev(device);
|
2011-03-16 22:31:39 +08:00
|
|
|
return 0;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-08-25 22:59:58 +08:00
|
|
|
static int make_ov_request(struct drbd_device *device, int cancel)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
|
|
|
int number, i, size;
|
|
|
|
sector_t sector;
|
2011-07-03 19:26:43 +08:00
|
|
|
const sector_t capacity = drbd_get_capacity(device->this_bdev);
|
2012-07-26 20:09:49 +08:00
|
|
|
bool stop_sector_reached = false;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
if (unlikely(cancel))
|
|
|
|
return 1;
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
number = drbd_rs_number_requests(device);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
sector = device->ov_position;
|
2009-09-26 07:07:19 +08:00
|
|
|
for (i = 0; i < number; i++) {
|
2012-07-26 20:09:49 +08:00
|
|
|
if (sector >= capacity)
|
2009-09-26 07:07:19 +08:00
|
|
|
return 1;
|
2012-07-26 20:09:49 +08:00
|
|
|
|
|
|
|
/* We check for "finished" only in the reply path:
|
|
|
|
* w_e_end_ov_reply().
|
|
|
|
* We need to send at least one request out. */
|
|
|
|
stop_sector_reached = i > 0
|
2011-07-03 19:26:43 +08:00
|
|
|
&& verify_can_do_stop_sector(device)
|
|
|
|
&& sector >= device->ov_stop_sector;
|
2012-07-26 20:09:49 +08:00
|
|
|
if (stop_sector_reached)
|
|
|
|
break;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
size = BM_BLOCK_SIZE;
|
|
|
|
|
2013-12-20 18:22:13 +08:00
|
|
|
if (drbd_try_rs_begin_io(device, sector)) {
|
2011-07-03 19:26:43 +08:00
|
|
|
device->ov_position = sector;
|
2009-09-26 07:07:19 +08:00
|
|
|
goto requeue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sector + (size>>9) > capacity)
|
|
|
|
size = (capacity-sector)<<9;
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
inc_rs_pending(device);
|
drbd: Pass a peer device to a number of fuctions
These functions actually operate on a peer device, or
need a peer device.
drbd_prepare_command(), drbd_send_command(), drbd_send_sync_param()
drbd_send_uuids(), drbd_gen_and_send_sync_uuid(), drbd_send_sizes()
drbd_send_state(), drbd_send_current_state(), and drbd_send_state_req()
drbd_send_sr_reply(), drbd_send_ack(), drbd_send_drequest(),
drbd_send_drequest_csum(), drbd_send_ov_request(), drbd_send_dblock()
drbd_send_block(), drbd_send_out_of_sync(), recv_dless_read()
drbd_drain_block(), receive_bitmap_plain(), recv_resync_read()
read_in_block(), read_for_csum(), drbd_alloc_pages(), drbd_alloc_peer_req()
need_peer_seq(), update_peer_seq(), wait_for_and_update_peer_seq()
drbd_sync_handshake(), drbd_asb_recover_{0,1,2}p(), drbd_connected()
drbd_disconnected(), decode_bitmap_c() and recv_bm_rle_bits()
Signed-off-by: Andreas Gruenbacher <agruen@linbit.com>
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
2011-08-09 06:47:13 +08:00
|
|
|
if (drbd_send_ov_request(first_peer_device(device), sector, size)) {
|
2011-07-03 19:26:43 +08:00
|
|
|
dec_rs_pending(device);
|
2009-09-26 07:07:19 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
sector += BM_SECT_PER_BIT;
|
|
|
|
}
|
2011-07-03 19:26:43 +08:00
|
|
|
device->ov_position = sector;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
requeue:
|
2011-07-03 19:26:43 +08:00
|
|
|
device->rs_in_flight += (i << (BM_BLOCK_SHIFT - 9));
|
2012-07-26 20:09:49 +08:00
|
|
|
if (i == 0 || !stop_sector_reached)
|
2011-07-03 19:26:43 +08:00
|
|
|
mod_timer(&device->resync_timer, jiffies + SLEEP_TIME);
|
2009-09-26 07:07:19 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-03-16 22:31:39 +08:00
|
|
|
int w_ov_finished(struct drbd_work *w, int cancel)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
2011-07-28 21:27:51 +08:00
|
|
|
struct drbd_device_work *dw =
|
|
|
|
container_of(w, struct drbd_device_work, w);
|
|
|
|
struct drbd_device *device = dw->device;
|
|
|
|
kfree(dw);
|
2011-07-03 19:26:43 +08:00
|
|
|
ov_out_of_sync_print(device);
|
|
|
|
drbd_resync_finished(device);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-03-16 22:31:39 +08:00
|
|
|
return 0;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-03-16 22:31:39 +08:00
|
|
|
static int w_resync_finished(struct drbd_work *w, int cancel)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
2011-07-28 21:27:51 +08:00
|
|
|
struct drbd_device_work *dw =
|
|
|
|
container_of(w, struct drbd_device_work, w);
|
|
|
|
struct drbd_device *device = dw->device;
|
|
|
|
kfree(dw);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_resync_finished(device);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-03-16 22:31:39 +08:00
|
|
|
return 0;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
static void ping_peer(struct drbd_device *device)
|
2010-10-07 22:07:55 +08:00
|
|
|
{
|
2011-05-31 20:33:49 +08:00
|
|
|
struct drbd_connection *connection = first_peer_device(device)->connection;
|
2011-02-09 21:10:32 +08:00
|
|
|
|
2011-05-30 22:32:41 +08:00
|
|
|
clear_bit(GOT_PING_ACK, &connection->flags);
|
|
|
|
request_ping(connection);
|
|
|
|
wait_event(connection->ping_wait,
|
|
|
|
test_bit(GOT_PING_ACK, &connection->flags) || device->state.conn < C_CONNECTED);
|
2010-10-07 22:07:55 +08:00
|
|
|
}
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
int drbd_resync_finished(struct drbd_device *device)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
drbd: introduce unfence-peer handler
When resync is finished, we already call the "after-resync-target"
handler (on the former sync target, obviously), once per volume.
Paired with the before-resync-target handler, you can create snapshots,
before the resync causes the volumes to become inconsistent,
and discard those snapshots again, once they are no longer needed.
It was also overloaded to be paired with the "fence-peer" handler,
to "unfence" once the volumes are up-to-date and known good.
This has some disadvantages, though: we call "fence-peer" for the whole
connection (once for the group of volumes), but would call unfence as
side-effect of after-resync-target once for each volume.
Also, we fence on a (current, or about to become) Primary,
which will later become the sync-source.
Calling unfence only as a side effect of the after-resync-target
handler opens a race window, between a new fence on the Primary
(SyncTarget) and the unfence on the SyncTarget, which is difficult to
close without some kind of "cluster wide lock" in those handlers.
We would not need those handlers if we could still communicate.
Which makes trying to aquire a cluster wide lock from those handlers
seem like a very bad idea.
This introduces the "unfence-peer" handler, which will be called
per connection (once for the group of volumes), just like the fence
handler, only once all volumes are back in sync, and on the SyncSource.
Which is expected to be the node that previously called "fence", the
node that is currently allowed to be Primary, and thus the only node
that could trigger a new "fence" that could race with this unfence.
Which makes us not need any cluster wide synchronization here,
serializing two scripts running on the same node is trivial.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-06-14 06:26:25 +08:00
|
|
|
struct drbd_connection *connection = first_peer_device(device)->connection;
|
2009-09-26 07:07:19 +08:00
|
|
|
unsigned long db, dt, dbdt;
|
|
|
|
unsigned long n_oos;
|
|
|
|
union drbd_state os, ns;
|
2011-07-28 21:27:51 +08:00
|
|
|
struct drbd_device_work *dw;
|
2009-09-26 07:07:19 +08:00
|
|
|
char *khelper_cmd = NULL;
|
2010-11-05 16:56:33 +08:00
|
|
|
int verify_done = 0;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
/* Remove all elements from the resync LRU. Since future actions
|
|
|
|
* might set bits in the (main) bitmap, then the entries in the
|
|
|
|
* resync LRU would be wrong. */
|
2011-07-03 19:26:43 +08:00
|
|
|
if (drbd_rs_del_all(device)) {
|
2009-09-26 07:07:19 +08:00
|
|
|
/* In case this is not possible now, most probably because
|
|
|
|
* there are P_RS_DATA_REPLY Packets lingering on the worker's
|
|
|
|
* queue (or even the read operations for those packets
|
|
|
|
* is not finished by now). Retry in 100ms. */
|
|
|
|
|
2011-01-18 22:28:59 +08:00
|
|
|
schedule_timeout_interruptible(HZ / 10);
|
2011-07-28 21:27:51 +08:00
|
|
|
dw = kmalloc(sizeof(struct drbd_device_work), GFP_ATOMIC);
|
|
|
|
if (dw) {
|
|
|
|
dw->w.cb = w_resync_finished;
|
|
|
|
dw->device = device;
|
drbd: introduce unfence-peer handler
When resync is finished, we already call the "after-resync-target"
handler (on the former sync target, obviously), once per volume.
Paired with the before-resync-target handler, you can create snapshots,
before the resync causes the volumes to become inconsistent,
and discard those snapshots again, once they are no longer needed.
It was also overloaded to be paired with the "fence-peer" handler,
to "unfence" once the volumes are up-to-date and known good.
This has some disadvantages, though: we call "fence-peer" for the whole
connection (once for the group of volumes), but would call unfence as
side-effect of after-resync-target once for each volume.
Also, we fence on a (current, or about to become) Primary,
which will later become the sync-source.
Calling unfence only as a side effect of the after-resync-target
handler opens a race window, between a new fence on the Primary
(SyncTarget) and the unfence on the SyncTarget, which is difficult to
close without some kind of "cluster wide lock" in those handlers.
We would not need those handlers if we could still communicate.
Which makes trying to aquire a cluster wide lock from those handlers
seem like a very bad idea.
This introduces the "unfence-peer" handler, which will be called
per connection (once for the group of volumes), just like the fence
handler, only once all volumes are back in sync, and on the SyncSource.
Which is expected to be the node that previously called "fence", the
node that is currently allowed to be Primary, and thus the only node
that could trigger a new "fence" that could race with this unfence.
Which makes us not need any cluster wide synchronization here,
serializing two scripts running on the same node is trivial.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-06-14 06:26:25 +08:00
|
|
|
drbd_queue_work(&connection->sender_work, &dw->w);
|
2009-09-26 07:07:19 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2011-07-28 21:27:51 +08:00
|
|
|
drbd_err(device, "Warn failed to drbd_rs_del_all() and to kmalloc(dw).\n");
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
dt = (jiffies - device->rs_start - device->rs_paused) / HZ;
|
2009-09-26 07:07:19 +08:00
|
|
|
if (dt <= 0)
|
|
|
|
dt = 1;
|
2011-07-28 21:27:51 +08:00
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
db = device->rs_total;
|
2012-07-26 20:09:49 +08:00
|
|
|
/* adjust for verify start and stop sectors, respective reached position */
|
2011-07-03 19:26:43 +08:00
|
|
|
if (device->state.conn == C_VERIFY_S || device->state.conn == C_VERIFY_T)
|
|
|
|
db -= device->ov_left;
|
2012-07-26 20:09:49 +08:00
|
|
|
|
2009-09-26 07:07:19 +08:00
|
|
|
dbdt = Bit2KB(db/dt);
|
2011-07-03 19:26:43 +08:00
|
|
|
device->rs_paused /= HZ;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
if (!get_ldev(device))
|
2009-09-26 07:07:19 +08:00
|
|
|
goto out;
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
ping_peer(device);
|
2010-10-07 22:07:55 +08:00
|
|
|
|
2011-07-07 20:19:42 +08:00
|
|
|
spin_lock_irq(&device->resource->req_lock);
|
2011-07-03 19:26:43 +08:00
|
|
|
os = drbd_read_state(device);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2010-11-05 16:56:33 +08:00
|
|
|
verify_done = (os.conn == C_VERIFY_S || os.conn == C_VERIFY_T);
|
|
|
|
|
2009-09-26 07:07:19 +08:00
|
|
|
/* This protects us against multiple calls (that can happen in the presence
|
|
|
|
of application IO), and against connectivity loss just before we arrive here. */
|
|
|
|
if (os.conn <= C_CONNECTED)
|
|
|
|
goto out_unlock;
|
|
|
|
|
|
|
|
ns = os;
|
|
|
|
ns.conn = C_CONNECTED;
|
|
|
|
|
2011-07-03 23:53:52 +08:00
|
|
|
drbd_info(device, "%s done (total %lu sec; paused %lu sec; %lu K/sec)\n",
|
2012-07-26 20:09:49 +08:00
|
|
|
verify_done ? "Online verify" : "Resync",
|
2011-07-03 19:26:43 +08:00
|
|
|
dt + device->rs_paused, device->rs_paused, dbdt);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
n_oos = drbd_bm_total_weight(device);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
if (os.conn == C_VERIFY_S || os.conn == C_VERIFY_T) {
|
|
|
|
if (n_oos) {
|
2011-07-03 23:53:52 +08:00
|
|
|
drbd_alert(device, "Online verify found %lu %dk block out of sync!\n",
|
2009-09-26 07:07:19 +08:00
|
|
|
n_oos, Bit2KB(1));
|
|
|
|
khelper_cmd = "out-of-sync";
|
|
|
|
}
|
|
|
|
} else {
|
2011-06-27 22:23:33 +08:00
|
|
|
D_ASSERT(device, (n_oos - device->rs_failed) == 0);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
if (os.conn == C_SYNC_TARGET || os.conn == C_PAUSED_SYNC_T)
|
|
|
|
khelper_cmd = "after-resync-target";
|
|
|
|
|
2014-03-18 19:30:09 +08:00
|
|
|
if (device->use_csums && device->rs_total) {
|
2011-07-03 19:26:43 +08:00
|
|
|
const unsigned long s = device->rs_same_csum;
|
|
|
|
const unsigned long t = device->rs_total;
|
2009-09-26 07:07:19 +08:00
|
|
|
const int ratio =
|
|
|
|
(t == 0) ? 0 :
|
|
|
|
(t < 100000) ? ((s*100)/t) : (s/(t/100));
|
2011-07-03 23:53:52 +08:00
|
|
|
drbd_info(device, "%u %% had equal checksums, eliminated: %luK; "
|
2009-09-26 07:07:19 +08:00
|
|
|
"transferred %luK total %luK\n",
|
|
|
|
ratio,
|
2011-07-03 19:26:43 +08:00
|
|
|
Bit2KB(device->rs_same_csum),
|
|
|
|
Bit2KB(device->rs_total - device->rs_same_csum),
|
|
|
|
Bit2KB(device->rs_total));
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
if (device->rs_failed) {
|
2011-07-03 23:53:52 +08:00
|
|
|
drbd_info(device, " %lu failed blocks\n", device->rs_failed);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
if (os.conn == C_SYNC_TARGET || os.conn == C_PAUSED_SYNC_T) {
|
|
|
|
ns.disk = D_INCONSISTENT;
|
|
|
|
ns.pdsk = D_UP_TO_DATE;
|
|
|
|
} else {
|
|
|
|
ns.disk = D_UP_TO_DATE;
|
|
|
|
ns.pdsk = D_INCONSISTENT;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ns.disk = D_UP_TO_DATE;
|
|
|
|
ns.pdsk = D_UP_TO_DATE;
|
|
|
|
|
|
|
|
if (os.conn == C_SYNC_TARGET || os.conn == C_PAUSED_SYNC_T) {
|
2011-07-03 19:26:43 +08:00
|
|
|
if (device->p_uuid) {
|
2009-09-26 07:07:19 +08:00
|
|
|
int i;
|
|
|
|
for (i = UI_BITMAP ; i <= UI_HISTORY_END ; i++)
|
2011-07-03 19:26:43 +08:00
|
|
|
_drbd_uuid_set(device, i, device->p_uuid[i]);
|
|
|
|
drbd_uuid_set(device, UI_BITMAP, device->ldev->md.uuid[UI_CURRENT]);
|
|
|
|
_drbd_uuid_set(device, UI_CURRENT, device->p_uuid[UI_CURRENT]);
|
2009-09-26 07:07:19 +08:00
|
|
|
} else {
|
2011-07-03 23:53:52 +08:00
|
|
|
drbd_err(device, "device->p_uuid is NULL! BUG\n");
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-20 20:25:21 +08:00
|
|
|
if (!(os.conn == C_VERIFY_S || os.conn == C_VERIFY_T)) {
|
|
|
|
/* for verify runs, we don't update uuids here,
|
|
|
|
* so there would be nothing to report. */
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_uuid_set_bm(device, 0UL);
|
|
|
|
drbd_print_uuids(device, "updated UUIDs");
|
|
|
|
if (device->p_uuid) {
|
2011-01-20 20:25:21 +08:00
|
|
|
/* Now the two UUID sets are equal, update what we
|
|
|
|
* know of the peer. */
|
|
|
|
int i;
|
|
|
|
for (i = UI_CURRENT ; i <= UI_HISTORY_END ; i++)
|
2011-07-03 19:26:43 +08:00
|
|
|
device->p_uuid[i] = device->ldev->md.uuid[i];
|
2011-01-20 20:25:21 +08:00
|
|
|
}
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
_drbd_set_state(device, ns, CS_VERBOSE, NULL);
|
2009-09-26 07:07:19 +08:00
|
|
|
out_unlock:
|
2011-07-07 20:19:42 +08:00
|
|
|
spin_unlock_irq(&device->resource->req_lock);
|
drbd: introduce unfence-peer handler
When resync is finished, we already call the "after-resync-target"
handler (on the former sync target, obviously), once per volume.
Paired with the before-resync-target handler, you can create snapshots,
before the resync causes the volumes to become inconsistent,
and discard those snapshots again, once they are no longer needed.
It was also overloaded to be paired with the "fence-peer" handler,
to "unfence" once the volumes are up-to-date and known good.
This has some disadvantages, though: we call "fence-peer" for the whole
connection (once for the group of volumes), but would call unfence as
side-effect of after-resync-target once for each volume.
Also, we fence on a (current, or about to become) Primary,
which will later become the sync-source.
Calling unfence only as a side effect of the after-resync-target
handler opens a race window, between a new fence on the Primary
(SyncTarget) and the unfence on the SyncTarget, which is difficult to
close without some kind of "cluster wide lock" in those handlers.
We would not need those handlers if we could still communicate.
Which makes trying to aquire a cluster wide lock from those handlers
seem like a very bad idea.
This introduces the "unfence-peer" handler, which will be called
per connection (once for the group of volumes), just like the fence
handler, only once all volumes are back in sync, and on the SyncSource.
Which is expected to be the node that previously called "fence", the
node that is currently allowed to be Primary, and thus the only node
that could trigger a new "fence" that could race with this unfence.
Which makes us not need any cluster wide synchronization here,
serializing two scripts running on the same node is trivial.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-06-14 06:26:25 +08:00
|
|
|
|
|
|
|
/* If we have been sync source, and have an effective fencing-policy,
|
|
|
|
* once *all* volumes are back in sync, call "unfence". */
|
|
|
|
if (os.conn == C_SYNC_SOURCE) {
|
|
|
|
enum drbd_disk_state disk_state = D_MASK;
|
|
|
|
enum drbd_disk_state pdsk_state = D_MASK;
|
|
|
|
enum drbd_fencing_p fp = FP_DONT_CARE;
|
|
|
|
|
|
|
|
rcu_read_lock();
|
|
|
|
fp = rcu_dereference(device->ldev->disk_conf)->fencing;
|
|
|
|
if (fp != FP_DONT_CARE) {
|
|
|
|
struct drbd_peer_device *peer_device;
|
|
|
|
int vnr;
|
|
|
|
idr_for_each_entry(&connection->peer_devices, peer_device, vnr) {
|
|
|
|
struct drbd_device *device = peer_device->device;
|
|
|
|
disk_state = min_t(enum drbd_disk_state, disk_state, device->state.disk);
|
|
|
|
pdsk_state = min_t(enum drbd_disk_state, pdsk_state, device->state.pdsk);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rcu_read_unlock();
|
|
|
|
if (disk_state == D_UP_TO_DATE && pdsk_state == D_UP_TO_DATE)
|
|
|
|
conn_khelper(connection, "unfence-peer");
|
|
|
|
}
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
put_ldev(device);
|
2009-09-26 07:07:19 +08:00
|
|
|
out:
|
2011-07-03 19:26:43 +08:00
|
|
|
device->rs_total = 0;
|
|
|
|
device->rs_failed = 0;
|
|
|
|
device->rs_paused = 0;
|
2012-07-26 20:09:49 +08:00
|
|
|
|
|
|
|
/* reset start sector, if we reached end of device */
|
2011-07-03 19:26:43 +08:00
|
|
|
if (verify_done && device->ov_left == 0)
|
|
|
|
device->ov_start_sector = 0;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_md_sync(device);
|
2010-10-13 23:37:54 +08:00
|
|
|
|
2009-09-26 07:07:19 +08:00
|
|
|
if (khelper_cmd)
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_khelper(device, khelper_cmd);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* helper */
|
2011-07-03 19:26:43 +08:00
|
|
|
static void move_to_net_ee_or_free(struct drbd_device *device, struct drbd_peer_request *peer_req)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
2011-04-08 03:34:24 +08:00
|
|
|
if (drbd_peer_req_has_active_page(peer_req)) {
|
2009-09-26 07:07:19 +08:00
|
|
|
/* This might happen if sendpage() has not finished */
|
2011-02-04 22:57:48 +08:00
|
|
|
int i = (peer_req->i.size + PAGE_SIZE -1) >> PAGE_SHIFT;
|
2011-07-03 19:26:43 +08:00
|
|
|
atomic_add(i, &device->pp_in_use_by_net);
|
|
|
|
atomic_sub(i, &device->pp_in_use);
|
2011-07-07 20:19:42 +08:00
|
|
|
spin_lock_irq(&device->resource->req_lock);
|
2011-08-25 21:49:40 +08:00
|
|
|
list_add_tail(&peer_req->w.list, &device->net_ee);
|
2011-07-07 20:19:42 +08:00
|
|
|
spin_unlock_irq(&device->resource->req_lock);
|
2010-09-06 18:30:25 +08:00
|
|
|
wake_up(&drbd_pp_wait);
|
2009-09-26 07:07:19 +08:00
|
|
|
} else
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_free_peer_req(device, peer_req);
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* w_e_end_data_req() - Worker callback, to send a P_DATA_REPLY packet in response to a P_DATA_REQUEST
|
|
|
|
* @w: work object.
|
|
|
|
* @cancel: The connection will be closed anyways
|
|
|
|
*/
|
2011-03-16 22:31:39 +08:00
|
|
|
int w_e_end_data_req(struct drbd_work *w, int cancel)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
2011-08-25 21:49:40 +08:00
|
|
|
struct drbd_peer_request *peer_req = container_of(w, struct drbd_peer_request, w);
|
2011-09-13 16:39:41 +08:00
|
|
|
struct drbd_peer_device *peer_device = peer_req->peer_device;
|
|
|
|
struct drbd_device *device = peer_device->device;
|
2011-03-16 22:31:39 +08:00
|
|
|
int err;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
if (unlikely(cancel)) {
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_free_peer_req(device, peer_req);
|
|
|
|
dec_unacked(device);
|
2011-03-16 22:31:39 +08:00
|
|
|
return 0;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-02-04 22:57:48 +08:00
|
|
|
if (likely((peer_req->flags & EE_WAS_ERROR) == 0)) {
|
2011-09-13 16:39:41 +08:00
|
|
|
err = drbd_send_block(peer_device, P_DATA_REPLY, peer_req);
|
2009-09-26 07:07:19 +08:00
|
|
|
} else {
|
|
|
|
if (__ratelimit(&drbd_ratelimit_state))
|
2011-07-03 23:53:52 +08:00
|
|
|
drbd_err(device, "Sending NegDReply. sector=%llus.\n",
|
2011-02-04 22:57:48 +08:00
|
|
|
(unsigned long long)peer_req->i.sector);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-09-13 16:39:41 +08:00
|
|
|
err = drbd_send_ack(peer_device, P_NEG_DREPLY, peer_req);
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
dec_unacked(device);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
move_to_net_ee_or_free(device, peer_req);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-03-16 22:31:39 +08:00
|
|
|
if (unlikely(err))
|
2011-07-03 23:53:52 +08:00
|
|
|
drbd_err(device, "drbd_send_block() failed\n");
|
2011-03-16 22:31:39 +08:00
|
|
|
return err;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2016-06-14 06:26:13 +08:00
|
|
|
static bool all_zero(struct drbd_peer_request *peer_req)
|
|
|
|
{
|
|
|
|
struct page *page = peer_req->pages;
|
|
|
|
unsigned int len = peer_req->i.size;
|
|
|
|
|
|
|
|
page_chain_for_each(page) {
|
|
|
|
unsigned int l = min_t(unsigned int, len, PAGE_SIZE);
|
|
|
|
unsigned int i, words = l / sizeof(long);
|
|
|
|
unsigned long *d;
|
|
|
|
|
|
|
|
d = kmap_atomic(page);
|
|
|
|
for (i = 0; i < words; i++) {
|
|
|
|
if (d[i]) {
|
|
|
|
kunmap_atomic(d);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
kunmap_atomic(d);
|
|
|
|
len -= l;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-09-26 07:07:19 +08:00
|
|
|
/**
|
2011-08-17 18:43:25 +08:00
|
|
|
* w_e_end_rsdata_req() - Worker callback to send a P_RS_DATA_REPLY packet in response to a P_RS_DATA_REQUEST
|
2009-09-26 07:07:19 +08:00
|
|
|
* @w: work object.
|
|
|
|
* @cancel: The connection will be closed anyways
|
|
|
|
*/
|
2011-03-16 22:31:39 +08:00
|
|
|
int w_e_end_rsdata_req(struct drbd_work *w, int cancel)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
2011-08-25 21:49:40 +08:00
|
|
|
struct drbd_peer_request *peer_req = container_of(w, struct drbd_peer_request, w);
|
2011-09-13 16:39:41 +08:00
|
|
|
struct drbd_peer_device *peer_device = peer_req->peer_device;
|
|
|
|
struct drbd_device *device = peer_device->device;
|
2011-03-16 22:31:39 +08:00
|
|
|
int err;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
if (unlikely(cancel)) {
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_free_peer_req(device, peer_req);
|
|
|
|
dec_unacked(device);
|
2011-03-16 22:31:39 +08:00
|
|
|
return 0;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
if (get_ldev_if_state(device, D_FAILED)) {
|
|
|
|
drbd_rs_complete_io(device, peer_req->i.sector);
|
|
|
|
put_ldev(device);
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
if (device->state.conn == C_AHEAD) {
|
2011-09-13 16:39:41 +08:00
|
|
|
err = drbd_send_ack(peer_device, P_RS_CANCEL, peer_req);
|
2011-02-04 22:57:48 +08:00
|
|
|
} else if (likely((peer_req->flags & EE_WAS_ERROR) == 0)) {
|
2011-07-03 19:26:43 +08:00
|
|
|
if (likely(device->state.pdsk >= D_INCONSISTENT)) {
|
|
|
|
inc_rs_pending(device);
|
2016-06-14 06:26:13 +08:00
|
|
|
if (peer_req->flags & EE_RS_THIN_REQ && all_zero(peer_req))
|
|
|
|
err = drbd_send_rs_deallocated(peer_device, peer_req);
|
|
|
|
else
|
|
|
|
err = drbd_send_block(peer_device, P_RS_DATA_REPLY, peer_req);
|
2009-09-26 07:07:19 +08:00
|
|
|
} else {
|
|
|
|
if (__ratelimit(&drbd_ratelimit_state))
|
2011-07-03 23:53:52 +08:00
|
|
|
drbd_err(device, "Not sending RSDataReply, "
|
2009-09-26 07:07:19 +08:00
|
|
|
"partner DISKLESS!\n");
|
2011-03-16 22:31:39 +08:00
|
|
|
err = 0;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (__ratelimit(&drbd_ratelimit_state))
|
2011-07-03 23:53:52 +08:00
|
|
|
drbd_err(device, "Sending NegRSDReply. sector %llus.\n",
|
2011-02-04 22:57:48 +08:00
|
|
|
(unsigned long long)peer_req->i.sector);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-09-13 16:39:41 +08:00
|
|
|
err = drbd_send_ack(peer_device, P_NEG_RS_DREPLY, peer_req);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
/* update resync data with failure */
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_rs_failed_io(device, peer_req->i.sector, peer_req->i.size);
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
dec_unacked(device);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
move_to_net_ee_or_free(device, peer_req);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-03-16 22:31:39 +08:00
|
|
|
if (unlikely(err))
|
2011-07-03 23:53:52 +08:00
|
|
|
drbd_err(device, "drbd_send_block() failed\n");
|
2011-03-16 22:31:39 +08:00
|
|
|
return err;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-03-16 22:31:39 +08:00
|
|
|
int w_e_end_csum_rs_req(struct drbd_work *w, int cancel)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
2011-08-25 21:49:40 +08:00
|
|
|
struct drbd_peer_request *peer_req = container_of(w, struct drbd_peer_request, w);
|
2011-09-13 16:39:41 +08:00
|
|
|
struct drbd_peer_device *peer_device = peer_req->peer_device;
|
|
|
|
struct drbd_device *device = peer_device->device;
|
2009-09-26 07:07:19 +08:00
|
|
|
struct digest_info *di;
|
|
|
|
int digest_size;
|
|
|
|
void *digest = NULL;
|
2011-03-16 22:31:39 +08:00
|
|
|
int err, eq = 0;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
if (unlikely(cancel)) {
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_free_peer_req(device, peer_req);
|
|
|
|
dec_unacked(device);
|
2011-03-16 22:31:39 +08:00
|
|
|
return 0;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
if (get_ldev(device)) {
|
|
|
|
drbd_rs_complete_io(device, peer_req->i.sector);
|
|
|
|
put_ldev(device);
|
2010-09-05 07:13:24 +08:00
|
|
|
}
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-02-04 22:57:48 +08:00
|
|
|
di = peer_req->digest;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-02-04 22:57:48 +08:00
|
|
|
if (likely((peer_req->flags & EE_WAS_ERROR) == 0)) {
|
2009-09-26 07:07:19 +08:00
|
|
|
/* quick hack to try to avoid a race against reconfiguration.
|
|
|
|
* a real fix would be much more involved,
|
|
|
|
* introducing more locking mechanisms */
|
2011-09-13 16:39:41 +08:00
|
|
|
if (peer_device->connection->csums_tfm) {
|
2016-01-24 21:19:21 +08:00
|
|
|
digest_size = crypto_ahash_digestsize(peer_device->connection->csums_tfm);
|
2011-06-27 22:23:33 +08:00
|
|
|
D_ASSERT(device, digest_size == di->digest_size);
|
2009-09-26 07:07:19 +08:00
|
|
|
digest = kmalloc(digest_size, GFP_NOIO);
|
|
|
|
}
|
|
|
|
if (digest) {
|
2011-09-13 16:39:41 +08:00
|
|
|
drbd_csum_ee(peer_device->connection->csums_tfm, peer_req, digest);
|
2009-09-26 07:07:19 +08:00
|
|
|
eq = !memcmp(digest, di->digest, digest_size);
|
|
|
|
kfree(digest);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (eq) {
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_set_in_sync(device, peer_req->i.sector, peer_req->i.size);
|
2010-03-03 09:08:22 +08:00
|
|
|
/* rs_same_csums unit is BM_BLOCK_SIZE */
|
2011-07-03 19:26:43 +08:00
|
|
|
device->rs_same_csum += peer_req->i.size >> BM_BLOCK_SHIFT;
|
2011-09-13 16:39:41 +08:00
|
|
|
err = drbd_send_ack(peer_device, P_RS_IS_IN_SYNC, peer_req);
|
2009-09-26 07:07:19 +08:00
|
|
|
} else {
|
2011-07-03 19:26:43 +08:00
|
|
|
inc_rs_pending(device);
|
2011-02-04 22:57:48 +08:00
|
|
|
peer_req->block_id = ID_SYNCER; /* By setting block_id, digest pointer becomes invalid! */
|
|
|
|
peer_req->flags &= ~EE_HAS_DIGEST; /* This peer request no longer has a digest pointer */
|
2010-08-23 22:17:13 +08:00
|
|
|
kfree(di);
|
2011-09-13 16:39:41 +08:00
|
|
|
err = drbd_send_block(peer_device, P_RS_DATA_REPLY, peer_req);
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
} else {
|
2011-09-13 16:39:41 +08:00
|
|
|
err = drbd_send_ack(peer_device, P_NEG_RS_DREPLY, peer_req);
|
2009-09-26 07:07:19 +08:00
|
|
|
if (__ratelimit(&drbd_ratelimit_state))
|
2011-07-03 23:53:52 +08:00
|
|
|
drbd_err(device, "Sending NegDReply. I guess it gets messy.\n");
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
dec_unacked(device);
|
|
|
|
move_to_net_ee_or_free(device, peer_req);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-03-16 22:31:39 +08:00
|
|
|
if (unlikely(err))
|
2011-07-03 23:53:52 +08:00
|
|
|
drbd_err(device, "drbd_send_block/ack() failed\n");
|
2011-03-16 22:31:39 +08:00
|
|
|
return err;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-03-16 22:31:39 +08:00
|
|
|
int w_e_end_ov_req(struct drbd_work *w, int cancel)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
2011-08-25 21:49:40 +08:00
|
|
|
struct drbd_peer_request *peer_req = container_of(w, struct drbd_peer_request, w);
|
2011-09-13 16:39:41 +08:00
|
|
|
struct drbd_peer_device *peer_device = peer_req->peer_device;
|
|
|
|
struct drbd_device *device = peer_device->device;
|
2011-02-04 22:57:48 +08:00
|
|
|
sector_t sector = peer_req->i.sector;
|
|
|
|
unsigned int size = peer_req->i.size;
|
2009-09-26 07:07:19 +08:00
|
|
|
int digest_size;
|
|
|
|
void *digest;
|
2011-03-16 22:31:39 +08:00
|
|
|
int err = 0;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
if (unlikely(cancel))
|
|
|
|
goto out;
|
|
|
|
|
2016-01-24 21:19:21 +08:00
|
|
|
digest_size = crypto_ahash_digestsize(peer_device->connection->verify_tfm);
|
2009-09-26 07:07:19 +08:00
|
|
|
digest = kmalloc(digest_size, GFP_NOIO);
|
2011-03-01 22:52:35 +08:00
|
|
|
if (!digest) {
|
2011-03-16 22:31:39 +08:00
|
|
|
err = 1; /* terminate the connection in case the allocation failed */
|
2011-03-01 22:52:35 +08:00
|
|
|
goto out;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-02-04 22:57:48 +08:00
|
|
|
if (likely(!(peer_req->flags & EE_WAS_ERROR)))
|
2011-09-13 16:39:41 +08:00
|
|
|
drbd_csum_ee(peer_device->connection->verify_tfm, peer_req, digest);
|
2011-03-01 22:52:35 +08:00
|
|
|
else
|
|
|
|
memset(digest, 0, digest_size);
|
|
|
|
|
2011-03-09 00:11:40 +08:00
|
|
|
/* Free e and pages before send.
|
|
|
|
* In case we block on congestion, we could otherwise run into
|
|
|
|
* some distributed deadlock, if the other side blocks on
|
|
|
|
* congestion as well, because our receiver blocks in
|
2011-04-08 03:02:09 +08:00
|
|
|
* drbd_alloc_pages due to pp_in_use > max_buffers. */
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_free_peer_req(device, peer_req);
|
2011-02-04 22:57:48 +08:00
|
|
|
peer_req = NULL;
|
2011-07-03 19:26:43 +08:00
|
|
|
inc_rs_pending(device);
|
2011-09-13 16:39:41 +08:00
|
|
|
err = drbd_send_drequest_csum(peer_device, sector, size, digest, digest_size, P_OV_REPLY);
|
2011-03-16 22:31:39 +08:00
|
|
|
if (err)
|
2011-07-03 19:26:43 +08:00
|
|
|
dec_rs_pending(device);
|
2011-03-01 22:52:35 +08:00
|
|
|
kfree(digest);
|
|
|
|
|
2009-09-26 07:07:19 +08:00
|
|
|
out:
|
2011-02-04 22:57:48 +08:00
|
|
|
if (peer_req)
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_free_peer_req(device, peer_req);
|
|
|
|
dec_unacked(device);
|
2011-03-16 22:31:39 +08:00
|
|
|
return err;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
void drbd_ov_out_of_sync_found(struct drbd_device *device, sector_t sector, int size)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
2011-07-03 19:26:43 +08:00
|
|
|
if (device->ov_last_oos_start + device->ov_last_oos_size == sector) {
|
|
|
|
device->ov_last_oos_size += size>>9;
|
2009-09-26 07:07:19 +08:00
|
|
|
} else {
|
2011-07-03 19:26:43 +08:00
|
|
|
device->ov_last_oos_start = sector;
|
|
|
|
device->ov_last_oos_size = size>>9;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_set_out_of_sync(device, sector, size);
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-03-16 22:31:39 +08:00
|
|
|
int w_e_end_ov_reply(struct drbd_work *w, int cancel)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
2011-08-25 21:49:40 +08:00
|
|
|
struct drbd_peer_request *peer_req = container_of(w, struct drbd_peer_request, w);
|
2011-09-13 16:39:41 +08:00
|
|
|
struct drbd_peer_device *peer_device = peer_req->peer_device;
|
|
|
|
struct drbd_device *device = peer_device->device;
|
2009-09-26 07:07:19 +08:00
|
|
|
struct digest_info *di;
|
|
|
|
void *digest;
|
2011-02-04 22:57:48 +08:00
|
|
|
sector_t sector = peer_req->i.sector;
|
|
|
|
unsigned int size = peer_req->i.size;
|
2011-03-09 00:11:40 +08:00
|
|
|
int digest_size;
|
2011-03-16 22:31:39 +08:00
|
|
|
int err, eq = 0;
|
2012-07-26 20:09:49 +08:00
|
|
|
bool stop_sector_reached = false;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
if (unlikely(cancel)) {
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_free_peer_req(device, peer_req);
|
|
|
|
dec_unacked(device);
|
2011-03-16 22:31:39 +08:00
|
|
|
return 0;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* after "cancel", because after drbd_disconnect/drbd_rs_cancel_all
|
|
|
|
* the resync lru has been cleaned up already */
|
2011-07-03 19:26:43 +08:00
|
|
|
if (get_ldev(device)) {
|
|
|
|
drbd_rs_complete_io(device, peer_req->i.sector);
|
|
|
|
put_ldev(device);
|
2010-09-05 07:13:24 +08:00
|
|
|
}
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-02-04 22:57:48 +08:00
|
|
|
di = peer_req->digest;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-02-04 22:57:48 +08:00
|
|
|
if (likely((peer_req->flags & EE_WAS_ERROR) == 0)) {
|
2016-01-24 21:19:21 +08:00
|
|
|
digest_size = crypto_ahash_digestsize(peer_device->connection->verify_tfm);
|
2009-09-26 07:07:19 +08:00
|
|
|
digest = kmalloc(digest_size, GFP_NOIO);
|
|
|
|
if (digest) {
|
2011-09-13 16:39:41 +08:00
|
|
|
drbd_csum_ee(peer_device->connection->verify_tfm, peer_req, digest);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-06-27 22:23:33 +08:00
|
|
|
D_ASSERT(device, digest_size == di->digest_size);
|
2009-09-26 07:07:19 +08:00
|
|
|
eq = !memcmp(digest, di->digest, digest_size);
|
|
|
|
kfree(digest);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-22 21:02:31 +08:00
|
|
|
/* Free peer_req and pages before send.
|
|
|
|
* In case we block on congestion, we could otherwise run into
|
|
|
|
* some distributed deadlock, if the other side blocks on
|
|
|
|
* congestion as well, because our receiver blocks in
|
2011-04-08 03:02:09 +08:00
|
|
|
* drbd_alloc_pages due to pp_in_use > max_buffers. */
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_free_peer_req(device, peer_req);
|
2009-09-26 07:07:19 +08:00
|
|
|
if (!eq)
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_ov_out_of_sync_found(device, sector, size);
|
2009-09-26 07:07:19 +08:00
|
|
|
else
|
2011-07-03 19:26:43 +08:00
|
|
|
ov_out_of_sync_print(device);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-09-13 16:39:41 +08:00
|
|
|
err = drbd_send_ack_ex(peer_device, P_OV_RESULT, sector, size,
|
2011-03-16 08:31:39 +08:00
|
|
|
eq ? ID_IN_SYNC : ID_OUT_OF_SYNC);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
dec_unacked(device);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
--device->ov_left;
|
2010-11-05 16:48:01 +08:00
|
|
|
|
|
|
|
/* let's advance progress step marks only for every other megabyte */
|
2011-07-03 19:26:43 +08:00
|
|
|
if ((device->ov_left & 0x200) == 0x200)
|
|
|
|
drbd_advance_rs_marks(device, device->ov_left);
|
2010-11-05 16:48:01 +08:00
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
stop_sector_reached = verify_can_do_stop_sector(device) &&
|
|
|
|
(sector + (size>>9)) >= device->ov_stop_sector;
|
2012-07-26 20:09:49 +08:00
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
if (device->ov_left == 0 || stop_sector_reached) {
|
|
|
|
ov_out_of_sync_print(device);
|
|
|
|
drbd_resync_finished(device);
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-03-16 22:31:39 +08:00
|
|
|
return err;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-11-28 22:04:49 +08:00
|
|
|
/* FIXME
|
|
|
|
* We need to track the number of pending barrier acks,
|
|
|
|
* and to be able to wait for them.
|
|
|
|
* See also comment in drbd_adm_attach before drbd_suspend_io.
|
|
|
|
*/
|
2011-05-30 22:32:41 +08:00
|
|
|
static int drbd_send_barrier(struct drbd_connection *connection)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
2011-03-28 20:23:08 +08:00
|
|
|
struct p_barrier *p;
|
2011-11-28 22:04:49 +08:00
|
|
|
struct drbd_socket *sock;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-05-30 22:32:41 +08:00
|
|
|
sock = &connection->data;
|
|
|
|
p = conn_prepare_command(connection, sock);
|
2011-03-28 20:23:08 +08:00
|
|
|
if (!p)
|
|
|
|
return -EIO;
|
2011-05-30 22:32:41 +08:00
|
|
|
p->barrier = connection->send.current_epoch_nr;
|
2011-11-28 22:04:49 +08:00
|
|
|
p->pad = 0;
|
2011-05-30 22:32:41 +08:00
|
|
|
connection->send.current_epoch_writes = 0;
|
2015-02-19 20:54:11 +08:00
|
|
|
connection->send.last_sent_barrier_jif = jiffies;
|
2011-11-28 22:04:49 +08:00
|
|
|
|
2011-05-30 22:32:41 +08:00
|
|
|
return conn_send_command(connection, sock, P_BARRIER, sizeof(*p), NULL, 0);
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
drbd: introduce drbd_recv_header_maybe_unplug
Recently, drbd_recv_header() was changed to potentially
implicitly "unplug" the backend device(s), in case there
is currently nothing to receive.
Be more explicit about it: re-introduce the original drbd_recv_header(),
and introduce a new drbd_recv_header_maybe_unplug() for use by the
receiver "main loop".
Using explicit plugging via blk_start_plug(); blk_finish_plug();
really helps the io-scheduler of the backend with merging requests.
Wrap the receiver "main loop" with such a plug.
Also catch unplug events on the Primary,
and try to propagate.
This is performance relevant. Without this, if the receiving side does
not merge requests, number of IOPS on the peer can me significantly
higher than IOPS on the Primary, and can easily become the bottleneck.
Together, both changes should help to reduce the number of IOPS
as seen on the backend of the receiving side, by increasing
the chance of merging mergable requests, without trading latency
for more throughput.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2017-08-29 16:20:32 +08:00
|
|
|
static int pd_send_unplug_remote(struct drbd_peer_device *pd)
|
|
|
|
{
|
|
|
|
struct drbd_socket *sock = &pd->connection->data;
|
|
|
|
if (!drbd_prepare_command(pd, sock))
|
|
|
|
return -EIO;
|
|
|
|
return drbd_send_command(pd, sock, P_UNPLUG_REMOTE, 0, NULL, 0);
|
|
|
|
}
|
|
|
|
|
2011-03-16 22:31:39 +08:00
|
|
|
int w_send_write_hint(struct drbd_work *w, int cancel)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
2011-07-28 21:27:51 +08:00
|
|
|
struct drbd_device *device =
|
|
|
|
container_of(w, struct drbd_device, unplug_work);
|
2011-03-28 20:23:08 +08:00
|
|
|
|
2009-09-26 07:07:19 +08:00
|
|
|
if (cancel)
|
2011-03-16 22:31:39 +08:00
|
|
|
return 0;
|
drbd: introduce drbd_recv_header_maybe_unplug
Recently, drbd_recv_header() was changed to potentially
implicitly "unplug" the backend device(s), in case there
is currently nothing to receive.
Be more explicit about it: re-introduce the original drbd_recv_header(),
and introduce a new drbd_recv_header_maybe_unplug() for use by the
receiver "main loop".
Using explicit plugging via blk_start_plug(); blk_finish_plug();
really helps the io-scheduler of the backend with merging requests.
Wrap the receiver "main loop" with such a plug.
Also catch unplug events on the Primary,
and try to propagate.
This is performance relevant. Without this, if the receiving side does
not merge requests, number of IOPS on the peer can me significantly
higher than IOPS on the Primary, and can easily become the bottleneck.
Together, both changes should help to reduce the number of IOPS
as seen on the backend of the receiving side, by increasing
the chance of merging mergable requests, without trading latency
for more throughput.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2017-08-29 16:20:32 +08:00
|
|
|
return pd_send_unplug_remote(first_peer_device(device));
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-05-30 22:32:41 +08:00
|
|
|
static void re_init_if_first_write(struct drbd_connection *connection, unsigned int epoch)
|
2012-08-20 17:05:23 +08:00
|
|
|
{
|
2011-05-30 22:32:41 +08:00
|
|
|
if (!connection->send.seen_any_write_yet) {
|
|
|
|
connection->send.seen_any_write_yet = true;
|
|
|
|
connection->send.current_epoch_nr = epoch;
|
|
|
|
connection->send.current_epoch_writes = 0;
|
2015-02-19 20:54:11 +08:00
|
|
|
connection->send.last_sent_barrier_jif = jiffies;
|
2012-08-20 17:05:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-30 22:32:41 +08:00
|
|
|
static void maybe_send_barrier(struct drbd_connection *connection, unsigned int epoch)
|
2012-08-20 17:05:23 +08:00
|
|
|
{
|
|
|
|
/* re-init if first write on this connection */
|
2011-05-30 22:32:41 +08:00
|
|
|
if (!connection->send.seen_any_write_yet)
|
2012-08-20 17:05:23 +08:00
|
|
|
return;
|
2011-05-30 22:32:41 +08:00
|
|
|
if (connection->send.current_epoch_nr != epoch) {
|
|
|
|
if (connection->send.current_epoch_writes)
|
|
|
|
drbd_send_barrier(connection);
|
|
|
|
connection->send.current_epoch_nr = epoch;
|
2012-08-20 17:05:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-20 06:53:14 +08:00
|
|
|
int w_send_out_of_sync(struct drbd_work *w, int cancel)
|
2010-10-27 20:33:00 +08:00
|
|
|
{
|
|
|
|
struct drbd_request *req = container_of(w, struct drbd_request, w);
|
2011-07-28 21:27:51 +08:00
|
|
|
struct drbd_device *device = req->device;
|
2013-11-22 19:40:58 +08:00
|
|
|
struct drbd_peer_device *const peer_device = first_peer_device(device);
|
|
|
|
struct drbd_connection *const connection = peer_device->connection;
|
2011-03-16 22:31:39 +08:00
|
|
|
int err;
|
2010-10-27 20:33:00 +08:00
|
|
|
|
|
|
|
if (unlikely(cancel)) {
|
2011-01-25 22:37:43 +08:00
|
|
|
req_mod(req, SEND_CANCELED);
|
2011-03-16 22:31:39 +08:00
|
|
|
return 0;
|
2010-10-27 20:33:00 +08:00
|
|
|
}
|
2013-11-22 19:32:01 +08:00
|
|
|
req->pre_send_jif = jiffies;
|
2010-10-27 20:33:00 +08:00
|
|
|
|
2011-05-30 22:32:41 +08:00
|
|
|
/* this time, no connection->send.current_epoch_writes++;
|
2011-11-28 22:04:49 +08:00
|
|
|
* If it was sent, it was the closing barrier for the last
|
|
|
|
* replicated epoch, before we went into AHEAD mode.
|
|
|
|
* No more barriers will be sent, until we leave AHEAD mode again. */
|
2011-05-30 22:32:41 +08:00
|
|
|
maybe_send_barrier(connection, req->epoch);
|
2011-11-28 22:04:49 +08:00
|
|
|
|
2013-11-22 19:40:58 +08:00
|
|
|
err = drbd_send_out_of_sync(peer_device, req);
|
2011-01-25 22:37:43 +08:00
|
|
|
req_mod(req, OOS_HANDED_TO_NETWORK);
|
2010-10-27 20:33:00 +08:00
|
|
|
|
2011-03-16 22:31:39 +08:00
|
|
|
return err;
|
2010-10-27 20:33:00 +08:00
|
|
|
}
|
|
|
|
|
2009-09-26 07:07:19 +08:00
|
|
|
/**
|
|
|
|
* w_send_dblock() - Worker callback to send a P_DATA packet in order to mirror a write request
|
|
|
|
* @w: work object.
|
|
|
|
* @cancel: The connection will be closed anyways
|
|
|
|
*/
|
2011-03-16 22:31:39 +08:00
|
|
|
int w_send_dblock(struct drbd_work *w, int cancel)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
|
|
|
struct drbd_request *req = container_of(w, struct drbd_request, w);
|
2011-07-28 21:27:51 +08:00
|
|
|
struct drbd_device *device = req->device;
|
2013-11-22 19:40:58 +08:00
|
|
|
struct drbd_peer_device *const peer_device = first_peer_device(device);
|
|
|
|
struct drbd_connection *connection = peer_device->connection;
|
drbd: introduce drbd_recv_header_maybe_unplug
Recently, drbd_recv_header() was changed to potentially
implicitly "unplug" the backend device(s), in case there
is currently nothing to receive.
Be more explicit about it: re-introduce the original drbd_recv_header(),
and introduce a new drbd_recv_header_maybe_unplug() for use by the
receiver "main loop".
Using explicit plugging via blk_start_plug(); blk_finish_plug();
really helps the io-scheduler of the backend with merging requests.
Wrap the receiver "main loop" with such a plug.
Also catch unplug events on the Primary,
and try to propagate.
This is performance relevant. Without this, if the receiving side does
not merge requests, number of IOPS on the peer can me significantly
higher than IOPS on the Primary, and can easily become the bottleneck.
Together, both changes should help to reduce the number of IOPS
as seen on the backend of the receiving side, by increasing
the chance of merging mergable requests, without trading latency
for more throughput.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2017-08-29 16:20:32 +08:00
|
|
|
bool do_send_unplug = req->rq_state & RQ_UNPLUG;
|
2011-03-16 22:31:39 +08:00
|
|
|
int err;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
if (unlikely(cancel)) {
|
2011-01-25 22:37:43 +08:00
|
|
|
req_mod(req, SEND_CANCELED);
|
2011-03-16 22:31:39 +08:00
|
|
|
return 0;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
2013-11-22 19:32:01 +08:00
|
|
|
req->pre_send_jif = jiffies;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-05-30 22:32:41 +08:00
|
|
|
re_init_if_first_write(connection, req->epoch);
|
|
|
|
maybe_send_barrier(connection, req->epoch);
|
|
|
|
connection->send.current_epoch_writes++;
|
2011-11-28 22:04:49 +08:00
|
|
|
|
2013-11-22 19:40:58 +08:00
|
|
|
err = drbd_send_dblock(peer_device, req);
|
2011-03-16 22:31:39 +08:00
|
|
|
req_mod(req, err ? SEND_FAILED : HANDED_OVER_TO_NETWORK);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
drbd: introduce drbd_recv_header_maybe_unplug
Recently, drbd_recv_header() was changed to potentially
implicitly "unplug" the backend device(s), in case there
is currently nothing to receive.
Be more explicit about it: re-introduce the original drbd_recv_header(),
and introduce a new drbd_recv_header_maybe_unplug() for use by the
receiver "main loop".
Using explicit plugging via blk_start_plug(); blk_finish_plug();
really helps the io-scheduler of the backend with merging requests.
Wrap the receiver "main loop" with such a plug.
Also catch unplug events on the Primary,
and try to propagate.
This is performance relevant. Without this, if the receiving side does
not merge requests, number of IOPS on the peer can me significantly
higher than IOPS on the Primary, and can easily become the bottleneck.
Together, both changes should help to reduce the number of IOPS
as seen on the backend of the receiving side, by increasing
the chance of merging mergable requests, without trading latency
for more throughput.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2017-08-29 16:20:32 +08:00
|
|
|
if (do_send_unplug && !err)
|
|
|
|
pd_send_unplug_remote(peer_device);
|
|
|
|
|
2011-03-16 22:31:39 +08:00
|
|
|
return err;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* w_send_read_req() - Worker callback to send a read request (P_DATA_REQUEST) packet
|
|
|
|
* @w: work object.
|
|
|
|
* @cancel: The connection will be closed anyways
|
|
|
|
*/
|
2011-03-16 22:31:39 +08:00
|
|
|
int w_send_read_req(struct drbd_work *w, int cancel)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
|
|
|
struct drbd_request *req = container_of(w, struct drbd_request, w);
|
2011-07-28 21:27:51 +08:00
|
|
|
struct drbd_device *device = req->device;
|
2013-11-22 19:40:58 +08:00
|
|
|
struct drbd_peer_device *const peer_device = first_peer_device(device);
|
|
|
|
struct drbd_connection *connection = peer_device->connection;
|
drbd: introduce drbd_recv_header_maybe_unplug
Recently, drbd_recv_header() was changed to potentially
implicitly "unplug" the backend device(s), in case there
is currently nothing to receive.
Be more explicit about it: re-introduce the original drbd_recv_header(),
and introduce a new drbd_recv_header_maybe_unplug() for use by the
receiver "main loop".
Using explicit plugging via blk_start_plug(); blk_finish_plug();
really helps the io-scheduler of the backend with merging requests.
Wrap the receiver "main loop" with such a plug.
Also catch unplug events on the Primary,
and try to propagate.
This is performance relevant. Without this, if the receiving side does
not merge requests, number of IOPS on the peer can me significantly
higher than IOPS on the Primary, and can easily become the bottleneck.
Together, both changes should help to reduce the number of IOPS
as seen on the backend of the receiving side, by increasing
the chance of merging mergable requests, without trading latency
for more throughput.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2017-08-29 16:20:32 +08:00
|
|
|
bool do_send_unplug = req->rq_state & RQ_UNPLUG;
|
2011-03-16 22:31:39 +08:00
|
|
|
int err;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
if (unlikely(cancel)) {
|
2011-01-25 22:37:43 +08:00
|
|
|
req_mod(req, SEND_CANCELED);
|
2011-03-16 22:31:39 +08:00
|
|
|
return 0;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
2013-11-22 19:32:01 +08:00
|
|
|
req->pre_send_jif = jiffies;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-11-28 22:04:49 +08:00
|
|
|
/* Even read requests may close a write epoch,
|
|
|
|
* if there was any yet. */
|
2011-05-30 22:32:41 +08:00
|
|
|
maybe_send_barrier(connection, req->epoch);
|
2011-11-28 22:04:49 +08:00
|
|
|
|
2013-11-22 19:40:58 +08:00
|
|
|
err = drbd_send_drequest(peer_device, P_DATA_REQUEST, req->i.sector, req->i.size,
|
2011-03-16 08:34:24 +08:00
|
|
|
(unsigned long)req);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-03-16 22:31:39 +08:00
|
|
|
req_mod(req, err ? SEND_FAILED : HANDED_OVER_TO_NETWORK);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
drbd: introduce drbd_recv_header_maybe_unplug
Recently, drbd_recv_header() was changed to potentially
implicitly "unplug" the backend device(s), in case there
is currently nothing to receive.
Be more explicit about it: re-introduce the original drbd_recv_header(),
and introduce a new drbd_recv_header_maybe_unplug() for use by the
receiver "main loop".
Using explicit plugging via blk_start_plug(); blk_finish_plug();
really helps the io-scheduler of the backend with merging requests.
Wrap the receiver "main loop" with such a plug.
Also catch unplug events on the Primary,
and try to propagate.
This is performance relevant. Without this, if the receiving side does
not merge requests, number of IOPS on the peer can me significantly
higher than IOPS on the Primary, and can easily become the bottleneck.
Together, both changes should help to reduce the number of IOPS
as seen on the backend of the receiving side, by increasing
the chance of merging mergable requests, without trading latency
for more throughput.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2017-08-29 16:20:32 +08:00
|
|
|
if (do_send_unplug && !err)
|
|
|
|
pd_send_unplug_remote(peer_device);
|
|
|
|
|
2011-03-16 22:31:39 +08:00
|
|
|
return err;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-03-16 22:31:39 +08:00
|
|
|
int w_restart_disk_io(struct drbd_work *w, int cancel)
|
2010-05-31 16:14:17 +08:00
|
|
|
{
|
|
|
|
struct drbd_request *req = container_of(w, struct drbd_request, w);
|
2011-07-28 21:27:51 +08:00
|
|
|
struct drbd_device *device = req->device;
|
2010-05-31 16:14:17 +08:00
|
|
|
|
2010-08-31 18:00:50 +08:00
|
|
|
if (bio_data_dir(req->master_bio) == WRITE && req->rq_state & RQ_IN_ACT_LOG)
|
2014-02-11 18:15:36 +08:00
|
|
|
drbd_al_begin_io(device, &req->i);
|
2010-05-31 16:14:17 +08:00
|
|
|
|
|
|
|
drbd_req_make_private_bio(req, req->master_bio);
|
2017-08-24 01:10:32 +08:00
|
|
|
bio_set_dev(req->private_bio, device->ldev->backing_bdev);
|
2010-05-31 16:14:17 +08:00
|
|
|
generic_make_request(req->private_bio);
|
|
|
|
|
2011-03-16 22:31:39 +08:00
|
|
|
return 0;
|
2010-05-31 16:14:17 +08:00
|
|
|
}
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
static int _drbd_may_sync_now(struct drbd_device *device)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
2011-07-03 19:26:43 +08:00
|
|
|
struct drbd_device *odev = device;
|
2011-05-12 17:15:34 +08:00
|
|
|
int resync_after;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
while (1) {
|
2013-03-27 21:08:43 +08:00
|
|
|
if (!odev->ldev || odev->state.disk == D_DISKLESS)
|
2011-03-28 20:48:01 +08:00
|
|
|
return 1;
|
2011-05-03 21:00:55 +08:00
|
|
|
rcu_read_lock();
|
2011-05-12 17:15:34 +08:00
|
|
|
resync_after = rcu_dereference(odev->ldev->disk_conf)->resync_after;
|
2011-05-03 21:00:55 +08:00
|
|
|
rcu_read_unlock();
|
2011-05-12 17:15:34 +08:00
|
|
|
if (resync_after == -1)
|
2009-09-26 07:07:19 +08:00
|
|
|
return 1;
|
2011-07-03 19:26:43 +08:00
|
|
|
odev = minor_to_device(resync_after);
|
2013-03-27 21:08:43 +08:00
|
|
|
if (!odev)
|
2010-12-16 02:31:20 +08:00
|
|
|
return 1;
|
2009-09-26 07:07:19 +08:00
|
|
|
if ((odev->state.conn >= C_SYNC_SOURCE &&
|
|
|
|
odev->state.conn <= C_PAUSED_SYNC_T) ||
|
|
|
|
odev->state.aftr_isp || odev->state.peer_isp ||
|
|
|
|
odev->state.user_isp)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-08-15 00:33:30 +08:00
|
|
|
* drbd_pause_after() - Pause resync on all devices that may not resync now
|
2011-07-03 19:26:43 +08:00
|
|
|
* @device: DRBD device.
|
2009-09-26 07:07:19 +08:00
|
|
|
*
|
|
|
|
* Called from process context only (admin command and after_state_ch).
|
|
|
|
*/
|
2014-08-15 00:33:30 +08:00
|
|
|
static bool drbd_pause_after(struct drbd_device *device)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
2014-08-15 00:33:30 +08:00
|
|
|
bool changed = false;
|
2011-05-30 22:15:21 +08:00
|
|
|
struct drbd_device *odev;
|
2014-08-15 00:33:30 +08:00
|
|
|
int i;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-04-12 13:53:32 +08:00
|
|
|
rcu_read_lock();
|
2011-06-08 04:54:17 +08:00
|
|
|
idr_for_each_entry(&drbd_devices, odev, i) {
|
2009-09-26 07:07:19 +08:00
|
|
|
if (odev->state.conn == C_STANDALONE && odev->state.disk == D_DISKLESS)
|
|
|
|
continue;
|
2014-08-15 00:33:30 +08:00
|
|
|
if (!_drbd_may_sync_now(odev) &&
|
|
|
|
_drbd_set_state(_NS(odev, aftr_isp, 1),
|
|
|
|
CS_HARD, NULL) != SS_NOTHING_TO_DO)
|
|
|
|
changed = true;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
2011-04-12 13:53:32 +08:00
|
|
|
rcu_read_unlock();
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2014-08-15 00:33:30 +08:00
|
|
|
return changed;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-08-15 00:33:30 +08:00
|
|
|
* drbd_resume_next() - Resume resync on all devices that may resync now
|
2011-07-03 19:26:43 +08:00
|
|
|
* @device: DRBD device.
|
2009-09-26 07:07:19 +08:00
|
|
|
*
|
|
|
|
* Called from process context only (admin command and worker).
|
|
|
|
*/
|
2014-08-15 00:33:30 +08:00
|
|
|
static bool drbd_resume_next(struct drbd_device *device)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
2014-08-15 00:33:30 +08:00
|
|
|
bool changed = false;
|
2011-05-30 22:15:21 +08:00
|
|
|
struct drbd_device *odev;
|
2014-08-15 00:33:30 +08:00
|
|
|
int i;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-04-12 13:53:32 +08:00
|
|
|
rcu_read_lock();
|
2011-06-08 04:54:17 +08:00
|
|
|
idr_for_each_entry(&drbd_devices, odev, i) {
|
2009-09-26 07:07:19 +08:00
|
|
|
if (odev->state.conn == C_STANDALONE && odev->state.disk == D_DISKLESS)
|
|
|
|
continue;
|
|
|
|
if (odev->state.aftr_isp) {
|
2014-08-15 00:33:30 +08:00
|
|
|
if (_drbd_may_sync_now(odev) &&
|
|
|
|
_drbd_set_state(_NS(odev, aftr_isp, 0),
|
|
|
|
CS_HARD, NULL) != SS_NOTHING_TO_DO)
|
|
|
|
changed = true;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
}
|
2011-04-12 13:53:32 +08:00
|
|
|
rcu_read_unlock();
|
2014-08-15 00:33:30 +08:00
|
|
|
return changed;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
void resume_next_sg(struct drbd_device *device)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
2014-08-15 00:33:30 +08:00
|
|
|
lock_all_resources();
|
|
|
|
drbd_resume_next(device);
|
|
|
|
unlock_all_resources();
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
void suspend_other_sg(struct drbd_device *device)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
2014-08-15 00:33:30 +08:00
|
|
|
lock_all_resources();
|
|
|
|
drbd_pause_after(device);
|
|
|
|
unlock_all_resources();
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2014-08-15 00:33:30 +08:00
|
|
|
/* caller must lock_all_resources() */
|
2011-07-03 19:26:43 +08:00
|
|
|
enum drbd_ret_code drbd_resync_after_valid(struct drbd_device *device, int o_minor)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
2011-05-30 22:15:21 +08:00
|
|
|
struct drbd_device *odev;
|
2011-05-12 17:15:34 +08:00
|
|
|
int resync_after;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
if (o_minor == -1)
|
|
|
|
return NO_ERROR;
|
2013-03-27 21:08:43 +08:00
|
|
|
if (o_minor < -1 || o_minor > MINORMASK)
|
2011-05-12 17:15:34 +08:00
|
|
|
return ERR_RESYNC_AFTER;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
/* check for loops */
|
2011-07-03 19:26:43 +08:00
|
|
|
odev = minor_to_device(o_minor);
|
2009-09-26 07:07:19 +08:00
|
|
|
while (1) {
|
2011-07-03 19:26:43 +08:00
|
|
|
if (odev == device)
|
2011-05-12 17:15:34 +08:00
|
|
|
return ERR_RESYNC_AFTER_CYCLE;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2013-03-27 21:08:43 +08:00
|
|
|
/* You are free to depend on diskless, non-existing,
|
|
|
|
* or not yet/no longer existing minors.
|
|
|
|
* We only reject dependency loops.
|
|
|
|
* We cannot follow the dependency chain beyond a detached or
|
|
|
|
* missing minor.
|
|
|
|
*/
|
|
|
|
if (!odev || !odev->ldev || odev->state.disk == D_DISKLESS)
|
|
|
|
return NO_ERROR;
|
|
|
|
|
2011-05-03 21:00:55 +08:00
|
|
|
rcu_read_lock();
|
2011-05-12 17:15:34 +08:00
|
|
|
resync_after = rcu_dereference(odev->ldev->disk_conf)->resync_after;
|
2011-05-03 21:00:55 +08:00
|
|
|
rcu_read_unlock();
|
2009-09-26 07:07:19 +08:00
|
|
|
/* dependency chain ends here, no cycles. */
|
2011-05-12 17:15:34 +08:00
|
|
|
if (resync_after == -1)
|
2009-09-26 07:07:19 +08:00
|
|
|
return NO_ERROR;
|
|
|
|
|
|
|
|
/* follow the dependency chain */
|
2011-07-03 19:26:43 +08:00
|
|
|
odev = minor_to_device(resync_after);
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-15 00:33:30 +08:00
|
|
|
/* caller must lock_all_resources() */
|
2011-07-03 19:26:43 +08:00
|
|
|
void drbd_resync_after_changed(struct drbd_device *device)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
2014-08-15 00:33:30 +08:00
|
|
|
int changed;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-05-03 20:27:15 +08:00
|
|
|
do {
|
2014-08-15 00:33:30 +08:00
|
|
|
changed = drbd_pause_after(device);
|
|
|
|
changed |= drbd_resume_next(device);
|
|
|
|
} while (changed);
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
void drbd_rs_controller_reset(struct drbd_device *device)
|
2010-11-05 16:55:18 +08:00
|
|
|
{
|
2014-11-11 00:21:12 +08:00
|
|
|
struct gendisk *disk = device->ldev->backing_bdev->bd_contains->bd_disk;
|
2011-05-03 22:47:02 +08:00
|
|
|
struct fifo_buffer *plan;
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
atomic_set(&device->rs_sect_in, 0);
|
|
|
|
atomic_set(&device->rs_sect_ev, 0);
|
|
|
|
device->rs_in_flight = 0;
|
2014-11-11 00:21:12 +08:00
|
|
|
device->rs_last_events =
|
|
|
|
(int)part_stat_read(&disk->part0, sectors[0]) +
|
|
|
|
(int)part_stat_read(&disk->part0, sectors[1]);
|
2011-05-03 22:47:02 +08:00
|
|
|
|
|
|
|
/* Updating the RCU protected object in place is necessary since
|
|
|
|
this function gets called from atomic context.
|
|
|
|
It is valid since all other updates also lead to an completely
|
|
|
|
empty fifo */
|
|
|
|
rcu_read_lock();
|
2011-07-03 19:26:43 +08:00
|
|
|
plan = rcu_dereference(device->rs_plan_s);
|
2011-05-03 22:47:02 +08:00
|
|
|
plan->total = 0;
|
|
|
|
fifo_set(plan, 0);
|
|
|
|
rcu_read_unlock();
|
2010-11-05 16:55:18 +08:00
|
|
|
}
|
|
|
|
|
2017-10-18 11:33:01 +08:00
|
|
|
void start_resync_timer_fn(struct timer_list *t)
|
2011-02-07 18:33:59 +08:00
|
|
|
{
|
2017-10-18 11:33:01 +08:00
|
|
|
struct drbd_device *device = from_timer(device, t, start_resync_timer);
|
2014-02-11 16:47:58 +08:00
|
|
|
drbd_device_post_work(device, RS_START);
|
2011-02-07 18:33:59 +08:00
|
|
|
}
|
|
|
|
|
2014-02-11 16:47:58 +08:00
|
|
|
static void do_start_resync(struct drbd_device *device)
|
2011-02-07 18:33:59 +08:00
|
|
|
{
|
2011-07-03 19:26:43 +08:00
|
|
|
if (atomic_read(&device->unacked_cnt) || atomic_read(&device->rs_pending_cnt)) {
|
2014-02-11 16:47:58 +08:00
|
|
|
drbd_warn(device, "postponing start_resync ...\n");
|
2011-07-03 19:26:43 +08:00
|
|
|
device->start_resync_timer.expires = jiffies + HZ/10;
|
|
|
|
add_timer(&device->start_resync_timer);
|
2014-02-11 16:47:58 +08:00
|
|
|
return;
|
2011-02-07 18:33:59 +08:00
|
|
|
}
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_start_resync(device, C_SYNC_SOURCE);
|
|
|
|
clear_bit(AHEAD_TO_SYNC_SOURCE, &device->flags);
|
2011-02-07 18:33:59 +08:00
|
|
|
}
|
|
|
|
|
2014-03-18 19:30:09 +08:00
|
|
|
static bool use_checksum_based_resync(struct drbd_connection *connection, struct drbd_device *device)
|
|
|
|
{
|
|
|
|
bool csums_after_crash_only;
|
|
|
|
rcu_read_lock();
|
|
|
|
csums_after_crash_only = rcu_dereference(connection->net_conf)->csums_after_crash_only;
|
|
|
|
rcu_read_unlock();
|
|
|
|
return connection->agreed_pro_version >= 89 && /* supported? */
|
|
|
|
connection->csums_tfm && /* configured? */
|
2016-06-14 06:26:35 +08:00
|
|
|
(csums_after_crash_only == false /* use for each resync? */
|
2014-03-18 19:30:09 +08:00
|
|
|
|| test_bit(CRASHED_PRIMARY, &device->flags)); /* or only after Primary crash? */
|
|
|
|
}
|
|
|
|
|
2009-09-26 07:07:19 +08:00
|
|
|
/**
|
|
|
|
* drbd_start_resync() - Start the resync process
|
2011-07-03 19:26:43 +08:00
|
|
|
* @device: DRBD device.
|
2009-09-26 07:07:19 +08:00
|
|
|
* @side: Either C_SYNC_SOURCE or C_SYNC_TARGET
|
|
|
|
*
|
|
|
|
* This function might bring you directly into one of the
|
|
|
|
* C_PAUSED_SYNC_* states.
|
|
|
|
*/
|
2011-07-03 19:26:43 +08:00
|
|
|
void drbd_start_resync(struct drbd_device *device, enum drbd_conns side)
|
2009-09-26 07:07:19 +08:00
|
|
|
{
|
2013-11-22 19:40:58 +08:00
|
|
|
struct drbd_peer_device *peer_device = first_peer_device(device);
|
|
|
|
struct drbd_connection *connection = peer_device ? peer_device->connection : NULL;
|
2009-09-26 07:07:19 +08:00
|
|
|
union drbd_state ns;
|
|
|
|
int r;
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
if (device->state.conn >= C_SYNC_SOURCE && device->state.conn < C_AHEAD) {
|
2011-07-03 23:53:52 +08:00
|
|
|
drbd_err(device, "Resync already running!\n");
|
2009-09-26 07:07:19 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-08-29 16:20:47 +08:00
|
|
|
if (!connection) {
|
|
|
|
drbd_err(device, "No connection to peer, aborting!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
if (!test_bit(B_RS_H_DONE, &device->flags)) {
|
2011-02-06 00:34:11 +08:00
|
|
|
if (side == C_SYNC_TARGET) {
|
|
|
|
/* Since application IO was locked out during C_WF_BITMAP_T and
|
|
|
|
C_WF_SYNC_UUID we are still unmodified. Before going to C_SYNC_TARGET
|
|
|
|
we check that we might make the data inconsistent. */
|
2011-07-03 19:26:43 +08:00
|
|
|
r = drbd_khelper(device, "before-resync-target");
|
2011-02-06 00:34:11 +08:00
|
|
|
r = (r >> 8) & 0xff;
|
|
|
|
if (r > 0) {
|
2011-07-03 23:53:52 +08:00
|
|
|
drbd_info(device, "before-resync-target handler returned %d, "
|
2010-12-03 23:04:24 +08:00
|
|
|
"dropping connection.\n", r);
|
2013-11-22 19:40:58 +08:00
|
|
|
conn_request_state(connection, NS(conn, C_DISCONNECTING), CS_HARD);
|
2010-12-03 23:04:24 +08:00
|
|
|
return;
|
|
|
|
}
|
2011-02-06 00:34:11 +08:00
|
|
|
} else /* C_SYNC_SOURCE */ {
|
2011-07-03 19:26:43 +08:00
|
|
|
r = drbd_khelper(device, "before-resync-source");
|
2011-02-06 00:34:11 +08:00
|
|
|
r = (r >> 8) & 0xff;
|
|
|
|
if (r > 0) {
|
|
|
|
if (r == 3) {
|
2011-07-03 23:53:52 +08:00
|
|
|
drbd_info(device, "before-resync-source handler returned %d, "
|
2011-02-06 00:34:11 +08:00
|
|
|
"ignoring. Old userland tools?", r);
|
|
|
|
} else {
|
2011-07-03 23:53:52 +08:00
|
|
|
drbd_info(device, "before-resync-source handler returned %d, "
|
2011-02-06 00:34:11 +08:00
|
|
|
"dropping connection.\n", r);
|
2013-11-22 19:40:58 +08:00
|
|
|
conn_request_state(connection,
|
2011-05-31 20:33:49 +08:00
|
|
|
NS(conn, C_DISCONNECTING), CS_HARD);
|
2011-02-06 00:34:11 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2010-12-03 23:04:24 +08:00
|
|
|
}
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2013-11-22 19:40:58 +08:00
|
|
|
if (current == connection->worker.task) {
|
2011-02-12 02:43:55 +08:00
|
|
|
/* The worker should not sleep waiting for state_mutex,
|
2011-02-06 00:34:11 +08:00
|
|
|
that can take long */
|
2011-07-03 19:26:43 +08:00
|
|
|
if (!mutex_trylock(device->state_mutex)) {
|
|
|
|
set_bit(B_RS_H_DONE, &device->flags);
|
|
|
|
device->start_resync_timer.expires = jiffies + HZ/5;
|
|
|
|
add_timer(&device->start_resync_timer);
|
2011-02-06 00:34:11 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
2011-07-03 19:26:43 +08:00
|
|
|
mutex_lock(device->state_mutex);
|
2011-02-06 00:34:11 +08:00
|
|
|
}
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2014-08-15 00:33:30 +08:00
|
|
|
lock_all_resources();
|
|
|
|
clear_bit(B_RS_H_DONE, &device->flags);
|
2013-03-27 21:08:35 +08:00
|
|
|
/* Did some connection breakage or IO error race with us? */
|
2011-07-03 19:26:43 +08:00
|
|
|
if (device->state.conn < C_CONNECTED
|
|
|
|
|| !get_ldev_if_state(device, D_NEGOTIATING)) {
|
2014-08-15 00:33:30 +08:00
|
|
|
unlock_all_resources();
|
|
|
|
goto out;
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
ns = drbd_read_state(device);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
ns.aftr_isp = !_drbd_may_sync_now(device);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
ns.conn = side;
|
|
|
|
|
|
|
|
if (side == C_SYNC_TARGET)
|
|
|
|
ns.disk = D_INCONSISTENT;
|
|
|
|
else /* side == C_SYNC_SOURCE */
|
|
|
|
ns.pdsk = D_INCONSISTENT;
|
|
|
|
|
2014-08-15 00:33:30 +08:00
|
|
|
r = _drbd_set_state(device, ns, CS_VERBOSE, NULL);
|
2011-07-03 19:26:43 +08:00
|
|
|
ns = drbd_read_state(device);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
if (ns.conn < C_CONNECTED)
|
|
|
|
r = SS_UNKNOWN_ERROR;
|
|
|
|
|
|
|
|
if (r == SS_SUCCESS) {
|
2011-07-03 19:26:43 +08:00
|
|
|
unsigned long tw = drbd_bm_total_weight(device);
|
2010-08-12 03:21:50 +08:00
|
|
|
unsigned long now = jiffies;
|
|
|
|
int i;
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
device->rs_failed = 0;
|
|
|
|
device->rs_paused = 0;
|
|
|
|
device->rs_same_csum = 0;
|
|
|
|
device->rs_last_sect_ev = 0;
|
|
|
|
device->rs_total = tw;
|
|
|
|
device->rs_start = now;
|
2010-08-12 03:21:50 +08:00
|
|
|
for (i = 0; i < DRBD_SYNC_MARKS; i++) {
|
2011-07-03 19:26:43 +08:00
|
|
|
device->rs_mark_left[i] = tw;
|
|
|
|
device->rs_mark_time[i] = now;
|
2010-08-12 03:21:50 +08:00
|
|
|
}
|
2014-08-15 00:33:30 +08:00
|
|
|
drbd_pause_after(device);
|
drbd: fix resync finished detection
This fixes one recent regresion,
and one long existing bug.
The bug:
drbd_try_clear_on_disk_bm() assumed that all "count" bits have to be
accounted in the resync extent corresponding to the start sector.
Since we allow application requests to cross our "extent" boundaries,
this assumption is no longer true, resulting in possible misaccounting,
scary messages
("BAD! sector=12345s enr=6 rs_left=-7 rs_failed=0 count=58 cstate=..."),
and potentially, if the last bit to be cleared during resync would
reside in previously misaccounted resync extent, the resync would never
be recognized as finished, but would be "stalled" forever, even though
all blocks are in sync again and all bits have been cleared...
The regression was introduced by
drbd: get rid of atomic update on disk bitmap works
For an "empty" resync (rs_total == 0), we must not "finish" the
resync on the SyncSource before the SyncTarget knows all relevant
information (sync uuid). We need to wait for the full round-trip,
the SyncTarget will then explicitly notify us.
Also for normal, non-empty resyncs (rs_total > 0), the resync-finished
condition needs to be tested before the schedule() in wait_for_work, or
it is likely to be missed.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
2014-01-27 22:58:22 +08:00
|
|
|
/* Forget potentially stale cached per resync extent bit-counts.
|
|
|
|
* Open coded drbd_rs_cancel_all(device), we already have IRQs
|
|
|
|
* disabled, and know the disk state is ok. */
|
|
|
|
spin_lock(&device->al_lock);
|
|
|
|
lc_reset(device->resync);
|
|
|
|
device->resync_locked = 0;
|
|
|
|
device->resync_wenr = LC_FREE;
|
|
|
|
spin_unlock(&device->al_lock);
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
2014-08-15 00:33:30 +08:00
|
|
|
unlock_all_resources();
|
2010-12-18 04:14:23 +08:00
|
|
|
|
2009-09-26 07:07:19 +08:00
|
|
|
if (r == SS_SUCCESS) {
|
drbd: fix resync finished detection
This fixes one recent regresion,
and one long existing bug.
The bug:
drbd_try_clear_on_disk_bm() assumed that all "count" bits have to be
accounted in the resync extent corresponding to the start sector.
Since we allow application requests to cross our "extent" boundaries,
this assumption is no longer true, resulting in possible misaccounting,
scary messages
("BAD! sector=12345s enr=6 rs_left=-7 rs_failed=0 count=58 cstate=..."),
and potentially, if the last bit to be cleared during resync would
reside in previously misaccounted resync extent, the resync would never
be recognized as finished, but would be "stalled" forever, even though
all blocks are in sync again and all bits have been cleared...
The regression was introduced by
drbd: get rid of atomic update on disk bitmap works
For an "empty" resync (rs_total == 0), we must not "finish" the
resync on the SyncSource before the SyncTarget knows all relevant
information (sync uuid). We need to wait for the full round-trip,
the SyncTarget will then explicitly notify us.
Also for normal, non-empty resyncs (rs_total > 0), the resync-finished
condition needs to be tested before the schedule() in wait_for_work, or
it is likely to be missed.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
2014-01-27 22:58:22 +08:00
|
|
|
wake_up(&device->al_wait); /* for lc_reset() above */
|
2012-10-19 20:37:47 +08:00
|
|
|
/* reset rs_last_bcast when a resync or verify is started,
|
|
|
|
* to deal with potential jiffies wrap. */
|
2011-07-03 19:26:43 +08:00
|
|
|
device->rs_last_bcast = jiffies - HZ;
|
2012-10-19 20:37:47 +08:00
|
|
|
|
2011-07-03 23:53:52 +08:00
|
|
|
drbd_info(device, "Began resync as %s (will sync %lu KB [%lu bits set]).\n",
|
2009-09-26 07:07:19 +08:00
|
|
|
drbd_conn_str(ns.conn),
|
2011-07-03 19:26:43 +08:00
|
|
|
(unsigned long) device->rs_total << (BM_BLOCK_SHIFT-10),
|
|
|
|
(unsigned long) device->rs_total);
|
2014-03-18 19:30:09 +08:00
|
|
|
if (side == C_SYNC_TARGET) {
|
2011-07-03 19:26:43 +08:00
|
|
|
device->bm_resync_fo = 0;
|
2014-03-18 19:30:09 +08:00
|
|
|
device->use_csums = use_checksum_based_resync(connection, device);
|
|
|
|
} else {
|
2016-06-14 06:26:35 +08:00
|
|
|
device->use_csums = false;
|
2014-03-18 19:30:09 +08:00
|
|
|
}
|
2011-01-12 18:51:13 +08:00
|
|
|
|
|
|
|
/* Since protocol 96, we must serialize drbd_gen_and_send_sync_uuid
|
|
|
|
* with w_send_oos, or the sync target will get confused as to
|
|
|
|
* how much bits to resync. We cannot do that always, because for an
|
|
|
|
* empty resync and protocol < 95, we need to do it here, as we call
|
|
|
|
* drbd_resync_finished from here in that case.
|
|
|
|
* We drbd_gen_and_send_sync_uuid here for protocol < 96,
|
|
|
|
* and from after_state_ch otherwise. */
|
2013-11-22 19:40:58 +08:00
|
|
|
if (side == C_SYNC_SOURCE && connection->agreed_pro_version < 96)
|
|
|
|
drbd_gen_and_send_sync_uuid(peer_device);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2013-11-22 19:40:58 +08:00
|
|
|
if (connection->agreed_pro_version < 95 && device->rs_total == 0) {
|
2010-10-07 22:07:55 +08:00
|
|
|
/* This still has a race (about when exactly the peers
|
|
|
|
* detect connection loss) that can lead to a full sync
|
|
|
|
* on next handshake. In 8.3.9 we fixed this with explicit
|
|
|
|
* resync-finished notifications, but the fix
|
|
|
|
* introduces a protocol change. Sleeping for some
|
|
|
|
* time longer than the ping interval + timeout on the
|
|
|
|
* SyncSource, to give the SyncTarget the chance to
|
|
|
|
* detect connection loss, then waiting for a ping
|
|
|
|
* response (implicit in drbd_resync_finished) reduces
|
|
|
|
* the race considerably, but does not solve it. */
|
2011-04-19 23:10:19 +08:00
|
|
|
if (side == C_SYNC_SOURCE) {
|
|
|
|
struct net_conf *nc;
|
|
|
|
int timeo;
|
|
|
|
|
|
|
|
rcu_read_lock();
|
2013-11-22 19:40:58 +08:00
|
|
|
nc = rcu_dereference(connection->net_conf);
|
2011-04-19 23:10:19 +08:00
|
|
|
timeo = nc->ping_int * HZ + nc->ping_timeo * HZ / 9;
|
|
|
|
rcu_read_unlock();
|
|
|
|
schedule_timeout_interruptible(timeo);
|
|
|
|
}
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_resync_finished(device);
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_rs_controller_reset(device);
|
|
|
|
/* ns.conn may already be != device->state.conn,
|
2009-09-26 07:07:19 +08:00
|
|
|
* we may have been paused in between, or become paused until
|
|
|
|
* the timer triggers.
|
|
|
|
* No matter, that is handled in resync_timer_fn() */
|
|
|
|
if (ns.conn == C_SYNC_TARGET)
|
2011-07-03 19:26:43 +08:00
|
|
|
mod_timer(&device->resync_timer, jiffies);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_md_sync(device);
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
2011-07-03 19:26:43 +08:00
|
|
|
put_ldev(device);
|
2014-08-15 00:33:30 +08:00
|
|
|
out:
|
2011-07-03 19:26:43 +08:00
|
|
|
mutex_unlock(device->state_mutex);
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
|
2014-02-11 16:30:49 +08:00
|
|
|
static void update_on_disk_bitmap(struct drbd_device *device, bool resync_done)
|
2013-12-20 18:39:48 +08:00
|
|
|
{
|
|
|
|
struct sib_info sib = { .sib_reason = SIB_SYNC_PROGRESS, };
|
|
|
|
device->rs_last_bcast = jiffies;
|
|
|
|
|
|
|
|
if (!get_ldev(device))
|
|
|
|
return;
|
|
|
|
|
|
|
|
drbd_bm_write_lazy(device, 0);
|
drbd: fix resync finished detection
This fixes one recent regresion,
and one long existing bug.
The bug:
drbd_try_clear_on_disk_bm() assumed that all "count" bits have to be
accounted in the resync extent corresponding to the start sector.
Since we allow application requests to cross our "extent" boundaries,
this assumption is no longer true, resulting in possible misaccounting,
scary messages
("BAD! sector=12345s enr=6 rs_left=-7 rs_failed=0 count=58 cstate=..."),
and potentially, if the last bit to be cleared during resync would
reside in previously misaccounted resync extent, the resync would never
be recognized as finished, but would be "stalled" forever, even though
all blocks are in sync again and all bits have been cleared...
The regression was introduced by
drbd: get rid of atomic update on disk bitmap works
For an "empty" resync (rs_total == 0), we must not "finish" the
resync on the SyncSource before the SyncTarget knows all relevant
information (sync uuid). We need to wait for the full round-trip,
the SyncTarget will then explicitly notify us.
Also for normal, non-empty resyncs (rs_total > 0), the resync-finished
condition needs to be tested before the schedule() in wait_for_work, or
it is likely to be missed.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
2014-01-27 22:58:22 +08:00
|
|
|
if (resync_done && is_sync_state(device->state.conn))
|
2013-12-20 18:39:48 +08:00
|
|
|
drbd_resync_finished(device);
|
drbd: fix resync finished detection
This fixes one recent regresion,
and one long existing bug.
The bug:
drbd_try_clear_on_disk_bm() assumed that all "count" bits have to be
accounted in the resync extent corresponding to the start sector.
Since we allow application requests to cross our "extent" boundaries,
this assumption is no longer true, resulting in possible misaccounting,
scary messages
("BAD! sector=12345s enr=6 rs_left=-7 rs_failed=0 count=58 cstate=..."),
and potentially, if the last bit to be cleared during resync would
reside in previously misaccounted resync extent, the resync would never
be recognized as finished, but would be "stalled" forever, even though
all blocks are in sync again and all bits have been cleared...
The regression was introduced by
drbd: get rid of atomic update on disk bitmap works
For an "empty" resync (rs_total == 0), we must not "finish" the
resync on the SyncSource before the SyncTarget knows all relevant
information (sync uuid). We need to wait for the full round-trip,
the SyncTarget will then explicitly notify us.
Also for normal, non-empty resyncs (rs_total > 0), the resync-finished
condition needs to be tested before the schedule() in wait_for_work, or
it is likely to be missed.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
2014-01-27 22:58:22 +08:00
|
|
|
|
2013-12-20 18:39:48 +08:00
|
|
|
drbd_bcast_event(device, &sib);
|
|
|
|
/* update timestamp, in case it took a while to write out stuff */
|
|
|
|
device->rs_last_bcast = jiffies;
|
|
|
|
put_ldev(device);
|
|
|
|
}
|
|
|
|
|
2014-02-11 16:30:49 +08:00
|
|
|
static void drbd_ldev_destroy(struct drbd_device *device)
|
|
|
|
{
|
|
|
|
lc_destroy(device->resync);
|
|
|
|
device->resync = NULL;
|
|
|
|
lc_destroy(device->act_log);
|
|
|
|
device->act_log = NULL;
|
2014-09-11 20:29:09 +08:00
|
|
|
|
|
|
|
__acquire(local);
|
2015-03-27 03:53:55 +08:00
|
|
|
drbd_backing_dev_free(device, device->ldev);
|
2014-09-11 20:29:09 +08:00
|
|
|
device->ldev = NULL;
|
|
|
|
__release(local);
|
|
|
|
|
2014-02-11 16:30:49 +08:00
|
|
|
clear_bit(GOING_DISKLESS, &device->flags);
|
|
|
|
wake_up(&device->misc_wait);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void go_diskless(struct drbd_device *device)
|
|
|
|
{
|
|
|
|
D_ASSERT(device, device->state.disk == D_FAILED);
|
|
|
|
/* we cannot assert local_cnt == 0 here, as get_ldev_if_state will
|
|
|
|
* inc/dec it frequently. Once we are D_DISKLESS, no one will touch
|
|
|
|
* the protected members anymore, though, so once put_ldev reaches zero
|
|
|
|
* again, it will be safe to free them. */
|
|
|
|
|
|
|
|
/* Try to write changed bitmap pages, read errors may have just
|
|
|
|
* set some bits outside the area covered by the activity log.
|
|
|
|
*
|
|
|
|
* If we have an IO error during the bitmap writeout,
|
|
|
|
* we will want a full sync next time, just in case.
|
|
|
|
* (Do we want a specific meta data flag for this?)
|
|
|
|
*
|
|
|
|
* If that does not make it to stable storage either,
|
|
|
|
* we cannot do anything about that anymore.
|
|
|
|
*
|
|
|
|
* We still need to check if both bitmap and ldev are present, we may
|
|
|
|
* end up here after a failed attach, before ldev was even assigned.
|
|
|
|
*/
|
|
|
|
if (device->bitmap && device->ldev) {
|
|
|
|
/* An interrupted resync or similar is allowed to recounts bits
|
|
|
|
* while we detach.
|
|
|
|
* Any modifications would not be expected anymore, though.
|
|
|
|
*/
|
|
|
|
if (drbd_bitmap_io_from_worker(device, drbd_bm_write,
|
|
|
|
"detach", BM_LOCKED_TEST_ALLOWED)) {
|
|
|
|
if (test_bit(WAS_READ_ERROR, &device->flags)) {
|
|
|
|
drbd_md_set_flag(device, MDF_FULL_SYNC);
|
|
|
|
drbd_md_sync(device);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
drbd_force_state(device, NS(disk, D_DISKLESS));
|
|
|
|
}
|
|
|
|
|
2014-02-11 16:47:58 +08:00
|
|
|
static int do_md_sync(struct drbd_device *device)
|
|
|
|
{
|
|
|
|
drbd_warn(device, "md_sync_timer expired! Worker calls drbd_md_sync().\n");
|
|
|
|
drbd_md_sync(device);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-05-06 21:02:05 +08:00
|
|
|
/* only called from drbd_worker thread, no locking */
|
|
|
|
void __update_timing_details(
|
|
|
|
struct drbd_thread_timing_details *tdp,
|
|
|
|
unsigned int *cb_nr,
|
|
|
|
void *cb,
|
|
|
|
const char *fn, const unsigned int line)
|
|
|
|
{
|
|
|
|
unsigned int i = *cb_nr % DRBD_THREAD_DETAILS_HIST;
|
|
|
|
struct drbd_thread_timing_details *td = tdp + i;
|
|
|
|
|
|
|
|
td->start_jif = jiffies;
|
|
|
|
td->cb_addr = cb;
|
|
|
|
td->caller_fn = fn;
|
|
|
|
td->line = line;
|
|
|
|
td->cb_nr = *cb_nr;
|
|
|
|
|
|
|
|
i = (i+1) % DRBD_THREAD_DETAILS_HIST;
|
|
|
|
td = tdp + i;
|
|
|
|
memset(td, 0, sizeof(*td));
|
|
|
|
|
|
|
|
++(*cb_nr);
|
|
|
|
}
|
|
|
|
|
2014-02-11 16:30:49 +08:00
|
|
|
static void do_device_work(struct drbd_device *device, const unsigned long todo)
|
|
|
|
{
|
2014-09-11 20:29:10 +08:00
|
|
|
if (test_bit(MD_SYNC, &todo))
|
2014-02-11 16:47:58 +08:00
|
|
|
do_md_sync(device);
|
2014-09-11 20:29:10 +08:00
|
|
|
if (test_bit(RS_DONE, &todo) ||
|
|
|
|
test_bit(RS_PROGRESS, &todo))
|
|
|
|
update_on_disk_bitmap(device, test_bit(RS_DONE, &todo));
|
|
|
|
if (test_bit(GO_DISKLESS, &todo))
|
2014-02-11 16:30:49 +08:00
|
|
|
go_diskless(device);
|
2014-09-11 20:29:10 +08:00
|
|
|
if (test_bit(DESTROY_DISK, &todo))
|
2014-02-11 16:30:49 +08:00
|
|
|
drbd_ldev_destroy(device);
|
2014-09-11 20:29:10 +08:00
|
|
|
if (test_bit(RS_START, &todo))
|
2014-02-11 16:47:58 +08:00
|
|
|
do_start_resync(device);
|
2014-02-11 16:30:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#define DRBD_DEVICE_WORK_MASK \
|
|
|
|
((1UL << GO_DISKLESS) \
|
|
|
|
|(1UL << DESTROY_DISK) \
|
2014-02-11 16:47:58 +08:00
|
|
|
|(1UL << MD_SYNC) \
|
|
|
|
|(1UL << RS_START) \
|
2014-02-11 16:30:49 +08:00
|
|
|
|(1UL << RS_PROGRESS) \
|
|
|
|
|(1UL << RS_DONE) \
|
|
|
|
)
|
|
|
|
|
|
|
|
static unsigned long get_work_bits(unsigned long *flags)
|
|
|
|
{
|
|
|
|
unsigned long old, new;
|
|
|
|
do {
|
|
|
|
old = *flags;
|
|
|
|
new = old & ~DRBD_DEVICE_WORK_MASK;
|
|
|
|
} while (cmpxchg(flags, old, new) != old);
|
|
|
|
return old & DRBD_DEVICE_WORK_MASK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void do_unqueued_work(struct drbd_connection *connection)
|
2013-12-20 18:39:48 +08:00
|
|
|
{
|
|
|
|
struct drbd_peer_device *peer_device;
|
|
|
|
int vnr;
|
|
|
|
|
|
|
|
rcu_read_lock();
|
|
|
|
idr_for_each_entry(&connection->peer_devices, peer_device, vnr) {
|
|
|
|
struct drbd_device *device = peer_device->device;
|
2014-02-11 16:30:49 +08:00
|
|
|
unsigned long todo = get_work_bits(&device->flags);
|
|
|
|
if (!todo)
|
2013-12-20 18:39:48 +08:00
|
|
|
continue;
|
drbd: fix resync finished detection
This fixes one recent regresion,
and one long existing bug.
The bug:
drbd_try_clear_on_disk_bm() assumed that all "count" bits have to be
accounted in the resync extent corresponding to the start sector.
Since we allow application requests to cross our "extent" boundaries,
this assumption is no longer true, resulting in possible misaccounting,
scary messages
("BAD! sector=12345s enr=6 rs_left=-7 rs_failed=0 count=58 cstate=..."),
and potentially, if the last bit to be cleared during resync would
reside in previously misaccounted resync extent, the resync would never
be recognized as finished, but would be "stalled" forever, even though
all blocks are in sync again and all bits have been cleared...
The regression was introduced by
drbd: get rid of atomic update on disk bitmap works
For an "empty" resync (rs_total == 0), we must not "finish" the
resync on the SyncSource before the SyncTarget knows all relevant
information (sync uuid). We need to wait for the full round-trip,
the SyncTarget will then explicitly notify us.
Also for normal, non-empty resyncs (rs_total > 0), the resync-finished
condition needs to be tested before the schedule() in wait_for_work, or
it is likely to be missed.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
2014-01-27 22:58:22 +08:00
|
|
|
|
2013-12-20 18:39:48 +08:00
|
|
|
kref_get(&device->kref);
|
|
|
|
rcu_read_unlock();
|
2014-02-11 16:30:49 +08:00
|
|
|
do_device_work(device, todo);
|
2013-12-20 18:39:48 +08:00
|
|
|
kref_put(&device->kref, drbd_destroy_device);
|
|
|
|
rcu_read_lock();
|
|
|
|
}
|
|
|
|
rcu_read_unlock();
|
|
|
|
}
|
|
|
|
|
2013-12-19 17:36:10 +08:00
|
|
|
static bool dequeue_work_batch(struct drbd_work_queue *queue, struct list_head *work_list)
|
2011-10-19 17:50:57 +08:00
|
|
|
{
|
|
|
|
spin_lock_irq(&queue->q_lock);
|
2014-04-28 17:43:21 +08:00
|
|
|
list_splice_tail_init(&queue->q, work_list);
|
2011-10-19 17:50:57 +08:00
|
|
|
spin_unlock_irq(&queue->q_lock);
|
|
|
|
return !list_empty(work_list);
|
|
|
|
}
|
|
|
|
|
2011-05-30 22:32:41 +08:00
|
|
|
static void wait_for_work(struct drbd_connection *connection, struct list_head *work_list)
|
2011-11-28 22:04:49 +08:00
|
|
|
{
|
|
|
|
DEFINE_WAIT(wait);
|
|
|
|
struct net_conf *nc;
|
|
|
|
int uncork, cork;
|
|
|
|
|
2014-09-11 20:29:11 +08:00
|
|
|
dequeue_work_batch(&connection->sender_work, work_list);
|
2011-11-28 22:04:49 +08:00
|
|
|
if (!list_empty(work_list))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Still nothing to do?
|
|
|
|
* Maybe we still need to close the current epoch,
|
|
|
|
* even if no new requests are queued yet.
|
|
|
|
*
|
|
|
|
* Also, poke TCP, just in case.
|
|
|
|
* Then wait for new work (or signal). */
|
|
|
|
rcu_read_lock();
|
|
|
|
nc = rcu_dereference(connection->net_conf);
|
|
|
|
uncork = nc ? nc->tcp_cork : 0;
|
|
|
|
rcu_read_unlock();
|
|
|
|
if (uncork) {
|
|
|
|
mutex_lock(&connection->data.mutex);
|
|
|
|
if (connection->data.socket)
|
|
|
|
drbd_tcp_uncork(connection->data.socket);
|
|
|
|
mutex_unlock(&connection->data.mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
int send_barrier;
|
|
|
|
prepare_to_wait(&connection->sender_work.q_wait, &wait, TASK_INTERRUPTIBLE);
|
2011-07-07 20:19:42 +08:00
|
|
|
spin_lock_irq(&connection->resource->req_lock);
|
2011-11-28 22:04:49 +08:00
|
|
|
spin_lock(&connection->sender_work.q_lock); /* FIXME get rid of this one? */
|
2012-08-22 17:47:14 +08:00
|
|
|
if (!list_empty(&connection->sender_work.q))
|
2014-02-11 18:15:36 +08:00
|
|
|
list_splice_tail_init(&connection->sender_work.q, work_list);
|
2011-11-28 22:04:49 +08:00
|
|
|
spin_unlock(&connection->sender_work.q_lock); /* FIXME get rid of this one? */
|
|
|
|
if (!list_empty(work_list) || signal_pending(current)) {
|
2011-07-07 20:19:42 +08:00
|
|
|
spin_unlock_irq(&connection->resource->req_lock);
|
2011-11-28 22:04:49 +08:00
|
|
|
break;
|
|
|
|
}
|
drbd: always implicitly close last epoch when idle
Once our sender thread needs to wait_for_work(),
and actually needs to schedule(), just before we do that,
we already check if it is useful to implicitly close the last epoch.
The condition was too strict: only implicitly close the epoch,
if there have been no new (write) requests at all.
The assumption was that if there were new requests, they would
always be communicated one way or another, and would send necessary
epoch separating barriers explicitly.
This is not always true, e.g. when becoming diskless,
or while explicitly starting a full resync.
The last communicated epoch could stay open for a long time,
locking down corresponding activity log extents.
It is safe to always implicitly send that last barrier, as soon as we
determin that there cannot be more requests in the last communicated
epoch, even if there have been (uncommunicated) new requests in new
epochs meanwhile.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
2014-04-29 00:43:29 +08:00
|
|
|
|
|
|
|
/* We found nothing new to do, no to-be-communicated request,
|
|
|
|
* no other work item. We may still need to close the last
|
|
|
|
* epoch. Next incoming request epoch will be connection ->
|
|
|
|
* current transfer log epoch number. If that is different
|
|
|
|
* from the epoch of the last request we communicated, it is
|
|
|
|
* safe to send the epoch separating barrier now.
|
|
|
|
*/
|
|
|
|
send_barrier =
|
|
|
|
atomic_read(&connection->current_tle_nr) !=
|
|
|
|
connection->send.current_epoch_nr;
|
2011-07-07 20:19:42 +08:00
|
|
|
spin_unlock_irq(&connection->resource->req_lock);
|
drbd: always implicitly close last epoch when idle
Once our sender thread needs to wait_for_work(),
and actually needs to schedule(), just before we do that,
we already check if it is useful to implicitly close the last epoch.
The condition was too strict: only implicitly close the epoch,
if there have been no new (write) requests at all.
The assumption was that if there were new requests, they would
always be communicated one way or another, and would send necessary
epoch separating barriers explicitly.
This is not always true, e.g. when becoming diskless,
or while explicitly starting a full resync.
The last communicated epoch could stay open for a long time,
locking down corresponding activity log extents.
It is safe to always implicitly send that last barrier, as soon as we
determin that there cannot be more requests in the last communicated
epoch, even if there have been (uncommunicated) new requests in new
epochs meanwhile.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
2014-04-29 00:43:29 +08:00
|
|
|
|
|
|
|
if (send_barrier)
|
|
|
|
maybe_send_barrier(connection,
|
|
|
|
connection->send.current_epoch_nr + 1);
|
drbd: fix resync finished detection
This fixes one recent regresion,
and one long existing bug.
The bug:
drbd_try_clear_on_disk_bm() assumed that all "count" bits have to be
accounted in the resync extent corresponding to the start sector.
Since we allow application requests to cross our "extent" boundaries,
this assumption is no longer true, resulting in possible misaccounting,
scary messages
("BAD! sector=12345s enr=6 rs_left=-7 rs_failed=0 count=58 cstate=..."),
and potentially, if the last bit to be cleared during resync would
reside in previously misaccounted resync extent, the resync would never
be recognized as finished, but would be "stalled" forever, even though
all blocks are in sync again and all bits have been cleared...
The regression was introduced by
drbd: get rid of atomic update on disk bitmap works
For an "empty" resync (rs_total == 0), we must not "finish" the
resync on the SyncSource before the SyncTarget knows all relevant
information (sync uuid). We need to wait for the full round-trip,
the SyncTarget will then explicitly notify us.
Also for normal, non-empty resyncs (rs_total > 0), the resync-finished
condition needs to be tested before the schedule() in wait_for_work, or
it is likely to be missed.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
2014-01-27 22:58:22 +08:00
|
|
|
|
2014-02-11 16:30:49 +08:00
|
|
|
if (test_bit(DEVICE_WORK_PENDING, &connection->flags))
|
drbd: fix resync finished detection
This fixes one recent regresion,
and one long existing bug.
The bug:
drbd_try_clear_on_disk_bm() assumed that all "count" bits have to be
accounted in the resync extent corresponding to the start sector.
Since we allow application requests to cross our "extent" boundaries,
this assumption is no longer true, resulting in possible misaccounting,
scary messages
("BAD! sector=12345s enr=6 rs_left=-7 rs_failed=0 count=58 cstate=..."),
and potentially, if the last bit to be cleared during resync would
reside in previously misaccounted resync extent, the resync would never
be recognized as finished, but would be "stalled" forever, even though
all blocks are in sync again and all bits have been cleared...
The regression was introduced by
drbd: get rid of atomic update on disk bitmap works
For an "empty" resync (rs_total == 0), we must not "finish" the
resync on the SyncSource before the SyncTarget knows all relevant
information (sync uuid). We need to wait for the full round-trip,
the SyncTarget will then explicitly notify us.
Also for normal, non-empty resyncs (rs_total > 0), the resync-finished
condition needs to be tested before the schedule() in wait_for_work, or
it is likely to be missed.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
2014-01-27 22:58:22 +08:00
|
|
|
break;
|
|
|
|
|
2013-12-28 00:17:25 +08:00
|
|
|
/* drbd_send() may have called flush_signals() */
|
|
|
|
if (get_t_state(&connection->worker) != RUNNING)
|
|
|
|
break;
|
drbd: fix resync finished detection
This fixes one recent regresion,
and one long existing bug.
The bug:
drbd_try_clear_on_disk_bm() assumed that all "count" bits have to be
accounted in the resync extent corresponding to the start sector.
Since we allow application requests to cross our "extent" boundaries,
this assumption is no longer true, resulting in possible misaccounting,
scary messages
("BAD! sector=12345s enr=6 rs_left=-7 rs_failed=0 count=58 cstate=..."),
and potentially, if the last bit to be cleared during resync would
reside in previously misaccounted resync extent, the resync would never
be recognized as finished, but would be "stalled" forever, even though
all blocks are in sync again and all bits have been cleared...
The regression was introduced by
drbd: get rid of atomic update on disk bitmap works
For an "empty" resync (rs_total == 0), we must not "finish" the
resync on the SyncSource before the SyncTarget knows all relevant
information (sync uuid). We need to wait for the full round-trip,
the SyncTarget will then explicitly notify us.
Also for normal, non-empty resyncs (rs_total > 0), the resync-finished
condition needs to be tested before the schedule() in wait_for_work, or
it is likely to be missed.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
2014-01-27 22:58:22 +08:00
|
|
|
|
2011-11-28 22:04:49 +08:00
|
|
|
schedule();
|
|
|
|
/* may be woken up for other things but new work, too,
|
|
|
|
* e.g. if the current epoch got closed.
|
|
|
|
* In which case we send the barrier above. */
|
|
|
|
}
|
|
|
|
finish_wait(&connection->sender_work.q_wait, &wait);
|
|
|
|
|
|
|
|
/* someone may have changed the config while we have been waiting above. */
|
|
|
|
rcu_read_lock();
|
|
|
|
nc = rcu_dereference(connection->net_conf);
|
|
|
|
cork = nc ? nc->tcp_cork : 0;
|
|
|
|
rcu_read_unlock();
|
|
|
|
mutex_lock(&connection->data.mutex);
|
|
|
|
if (connection->data.socket) {
|
|
|
|
if (cork)
|
|
|
|
drbd_tcp_cork(connection->data.socket);
|
|
|
|
else if (!uncork)
|
|
|
|
drbd_tcp_uncork(connection->data.socket);
|
|
|
|
}
|
|
|
|
mutex_unlock(&connection->data.mutex);
|
|
|
|
}
|
|
|
|
|
2009-09-26 07:07:19 +08:00
|
|
|
int drbd_worker(struct drbd_thread *thi)
|
|
|
|
{
|
2011-05-30 22:32:41 +08:00
|
|
|
struct drbd_connection *connection = thi->connection;
|
2011-08-27 05:50:08 +08:00
|
|
|
struct drbd_work *w = NULL;
|
2011-06-21 23:23:59 +08:00
|
|
|
struct drbd_peer_device *peer_device;
|
2009-09-26 07:07:19 +08:00
|
|
|
LIST_HEAD(work_list);
|
2011-10-19 17:50:57 +08:00
|
|
|
int vnr;
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-01-25 22:43:39 +08:00
|
|
|
while (get_t_state(thi) == RUNNING) {
|
2011-02-08 19:46:30 +08:00
|
|
|
drbd_thread_current_set_cpu(thi);
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2014-05-06 21:02:05 +08:00
|
|
|
if (list_empty(&work_list)) {
|
|
|
|
update_worker_timing_details(connection, wait_for_work);
|
2011-05-30 22:32:41 +08:00
|
|
|
wait_for_work(connection, &work_list);
|
2014-05-06 21:02:05 +08:00
|
|
|
}
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2014-05-06 21:02:05 +08:00
|
|
|
if (test_and_clear_bit(DEVICE_WORK_PENDING, &connection->flags)) {
|
|
|
|
update_worker_timing_details(connection, do_unqueued_work);
|
2014-02-11 16:30:49 +08:00
|
|
|
do_unqueued_work(connection);
|
2014-05-06 21:02:05 +08:00
|
|
|
}
|
drbd: fix resync finished detection
This fixes one recent regresion,
and one long existing bug.
The bug:
drbd_try_clear_on_disk_bm() assumed that all "count" bits have to be
accounted in the resync extent corresponding to the start sector.
Since we allow application requests to cross our "extent" boundaries,
this assumption is no longer true, resulting in possible misaccounting,
scary messages
("BAD! sector=12345s enr=6 rs_left=-7 rs_failed=0 count=58 cstate=..."),
and potentially, if the last bit to be cleared during resync would
reside in previously misaccounted resync extent, the resync would never
be recognized as finished, but would be "stalled" forever, even though
all blocks are in sync again and all bits have been cleared...
The regression was introduced by
drbd: get rid of atomic update on disk bitmap works
For an "empty" resync (rs_total == 0), we must not "finish" the
resync on the SyncSource before the SyncTarget knows all relevant
information (sync uuid). We need to wait for the full round-trip,
the SyncTarget will then explicitly notify us.
Also for normal, non-empty resyncs (rs_total > 0), the resync-finished
condition needs to be tested before the schedule() in wait_for_work, or
it is likely to be missed.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
2014-01-27 22:58:22 +08:00
|
|
|
|
2011-10-19 17:50:57 +08:00
|
|
|
if (signal_pending(current)) {
|
2009-09-26 07:07:19 +08:00
|
|
|
flush_signals(current);
|
2011-02-09 17:09:07 +08:00
|
|
|
if (get_t_state(thi) == RUNNING) {
|
2011-07-06 17:01:44 +08:00
|
|
|
drbd_warn(connection, "Worker got an unexpected signal\n");
|
2009-09-26 07:07:19 +08:00
|
|
|
continue;
|
2011-02-09 17:09:07 +08:00
|
|
|
}
|
2009-09-26 07:07:19 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-01-25 22:43:39 +08:00
|
|
|
if (get_t_state(thi) != RUNNING)
|
2009-09-26 07:07:19 +08:00
|
|
|
break;
|
|
|
|
|
2014-09-11 20:29:12 +08:00
|
|
|
if (!list_empty(&work_list)) {
|
2011-08-27 05:50:08 +08:00
|
|
|
w = list_first_entry(&work_list, struct drbd_work, list);
|
|
|
|
list_del_init(&w->list);
|
2014-05-06 21:02:05 +08:00
|
|
|
update_worker_timing_details(connection, w->cb);
|
2011-08-27 05:50:08 +08:00
|
|
|
if (w->cb(w, connection->cstate < C_WF_REPORT_PARAMS) == 0)
|
2011-10-19 17:50:57 +08:00
|
|
|
continue;
|
2011-05-30 22:32:41 +08:00
|
|
|
if (connection->cstate >= C_WF_REPORT_PARAMS)
|
|
|
|
conn_request_state(connection, NS(conn, C_NETWORK_FAILURE), CS_HARD);
|
2009-09-26 07:07:19 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-19 17:50:57 +08:00
|
|
|
do {
|
2014-05-06 21:02:05 +08:00
|
|
|
if (test_and_clear_bit(DEVICE_WORK_PENDING, &connection->flags)) {
|
|
|
|
update_worker_timing_details(connection, do_unqueued_work);
|
2014-02-11 16:30:49 +08:00
|
|
|
do_unqueued_work(connection);
|
2014-05-06 21:02:05 +08:00
|
|
|
}
|
2014-09-11 20:29:12 +08:00
|
|
|
if (!list_empty(&work_list)) {
|
2011-08-27 05:50:08 +08:00
|
|
|
w = list_first_entry(&work_list, struct drbd_work, list);
|
|
|
|
list_del_init(&w->list);
|
2014-05-06 21:02:05 +08:00
|
|
|
update_worker_timing_details(connection, w->cb);
|
2011-08-27 05:50:08 +08:00
|
|
|
w->cb(w, 1);
|
2014-09-11 20:29:12 +08:00
|
|
|
} else
|
|
|
|
dequeue_work_batch(&connection->sender_work, &work_list);
|
2014-02-11 16:30:49 +08:00
|
|
|
} while (!list_empty(&work_list) || test_bit(DEVICE_WORK_PENDING, &connection->flags));
|
2009-09-26 07:07:19 +08:00
|
|
|
|
2011-05-05 22:13:10 +08:00
|
|
|
rcu_read_lock();
|
2011-06-21 23:23:59 +08:00
|
|
|
idr_for_each_entry(&connection->peer_devices, peer_device, vnr) {
|
|
|
|
struct drbd_device *device = peer_device->device;
|
2011-06-27 22:23:33 +08:00
|
|
|
D_ASSERT(device, device->state.disk == D_DISKLESS && device->state.conn == C_STANDALONE);
|
2011-07-03 19:26:43 +08:00
|
|
|
kref_get(&device->kref);
|
2011-05-05 22:13:10 +08:00
|
|
|
rcu_read_unlock();
|
2011-07-03 19:26:43 +08:00
|
|
|
drbd_device_cleanup(device);
|
2011-06-08 04:54:17 +08:00
|
|
|
kref_put(&device->kref, drbd_destroy_device);
|
2011-05-05 22:13:10 +08:00
|
|
|
rcu_read_lock();
|
2011-02-18 21:23:11 +08:00
|
|
|
}
|
2011-05-05 22:13:10 +08:00
|
|
|
rcu_read_unlock();
|
2009-09-26 07:07:19 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|