Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 1 | /* |
| 2 | drbd_req.h |
| 3 | |
| 4 | This file is part of DRBD by Philipp Reisner and Lars Ellenberg. |
| 5 | |
| 6 | Copyright (C) 2006-2008, LINBIT Information Technologies GmbH. |
| 7 | Copyright (C) 2006-2008, Lars Ellenberg <lars.ellenberg@linbit.com>. |
| 8 | Copyright (C) 2006-2008, Philipp Reisner <philipp.reisner@linbit.com>. |
| 9 | |
| 10 | DRBD is free software; you can redistribute it and/or modify |
| 11 | it under the terms of the GNU General Public License as published by |
| 12 | the Free Software Foundation; either version 2, or (at your option) |
| 13 | any later version. |
| 14 | |
| 15 | DRBD is distributed in the hope that it will be useful, |
| 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | GNU General Public License for more details. |
| 19 | |
| 20 | You should have received a copy of the GNU General Public License |
| 21 | along with drbd; see the file COPYING. If not, write to |
| 22 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
| 23 | */ |
| 24 | |
| 25 | #ifndef _DRBD_REQ_H |
| 26 | #define _DRBD_REQ_H |
| 27 | |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 28 | #include <linux/module.h> |
| 29 | |
| 30 | #include <linux/slab.h> |
| 31 | #include <linux/drbd.h> |
| 32 | #include "drbd_int.h" |
| 33 | #include "drbd_wrappers.h" |
| 34 | |
| 35 | /* The request callbacks will be called in irq context by the IDE drivers, |
| 36 | and in Softirqs/Tasklets/BH context by the SCSI drivers, |
| 37 | and by the receiver and worker in kernel-thread context. |
| 38 | Try to get the locking right :) */ |
| 39 | |
| 40 | /* |
| 41 | * Objects of type struct drbd_request do only exist on a R_PRIMARY node, and are |
| 42 | * associated with IO requests originating from the block layer above us. |
| 43 | * |
| 44 | * There are quite a few things that may happen to a drbd request |
| 45 | * during its lifetime. |
| 46 | * |
| 47 | * It will be created. |
| 48 | * It will be marked with the intention to be |
| 49 | * submitted to local disk and/or |
| 50 | * send via the network. |
| 51 | * |
| 52 | * It has to be placed on the transfer log and other housekeeping lists, |
| 53 | * In case we have a network connection. |
| 54 | * |
| 55 | * It may be identified as a concurrent (write) request |
| 56 | * and be handled accordingly. |
| 57 | * |
| 58 | * It may me handed over to the local disk subsystem. |
| 59 | * It may be completed by the local disk subsystem, |
Daniel Mack | 3ad2f3f | 2010-02-03 08:01:28 +0800 | [diff] [blame] | 60 | * either successfully or with io-error. |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 61 | * In case it is a READ request, and it failed locally, |
| 62 | * it may be retried remotely. |
| 63 | * |
| 64 | * It may be queued for sending. |
| 65 | * It may be handed over to the network stack, |
| 66 | * which may fail. |
| 67 | * It may be acknowledged by the "peer" according to the wire_protocol in use. |
| 68 | * this may be a negative ack. |
| 69 | * It may receive a faked ack when the network connection is lost and the |
| 70 | * transfer log is cleaned up. |
| 71 | * Sending may be canceled due to network connection loss. |
| 72 | * When it finally has outlived its time, |
| 73 | * corresponding dirty bits in the resync-bitmap may be cleared or set, |
| 74 | * it will be destroyed, |
| 75 | * and completion will be signalled to the originator, |
| 76 | * with or without "success". |
| 77 | */ |
| 78 | |
| 79 | enum drbd_req_event { |
Andreas Gruenbacher | 8554df1 | 2011-01-25 15:37:43 +0100 | [diff] [blame] | 80 | CREATED, |
| 81 | TO_BE_SENT, |
| 82 | TO_BE_SUBMITTED, |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 83 | |
| 84 | /* XXX yes, now I am inconsistent... |
Philipp Reisner | 73a01a1 | 2010-10-27 14:33:00 +0200 | [diff] [blame] | 85 | * these are not "events" but "actions" |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 86 | * oh, well... */ |
Andreas Gruenbacher | 8554df1 | 2011-01-25 15:37:43 +0100 | [diff] [blame] | 87 | QUEUE_FOR_NET_WRITE, |
| 88 | QUEUE_FOR_NET_READ, |
| 89 | QUEUE_FOR_SEND_OOS, |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 90 | |
Lars Ellenberg | 7074e4a | 2013-03-27 14:08:41 +0100 | [diff] [blame] | 91 | /* An empty flush is queued as P_BARRIER, |
| 92 | * which will cause it to complete "successfully", |
| 93 | * even if the local disk flush failed. |
| 94 | * |
| 95 | * Just like "real" requests, empty flushes (blkdev_issue_flush()) will |
| 96 | * only see an error if neither local nor remote data is reachable. */ |
| 97 | QUEUE_AS_DRBD_BARRIER, |
| 98 | |
Andreas Gruenbacher | 8554df1 | 2011-01-25 15:37:43 +0100 | [diff] [blame] | 99 | SEND_CANCELED, |
| 100 | SEND_FAILED, |
| 101 | HANDED_OVER_TO_NETWORK, |
| 102 | OOS_HANDED_TO_NETWORK, |
| 103 | CONNECTION_LOST_WHILE_PENDING, |
| 104 | READ_RETRY_REMOTE_CANCELED, |
| 105 | RECV_ACKED_BY_PEER, |
| 106 | WRITE_ACKED_BY_PEER, |
| 107 | WRITE_ACKED_BY_PEER_AND_SIS, /* and set_in_sync */ |
Lars Ellenberg | d4dabbe | 2012-08-01 12:33:51 +0200 | [diff] [blame] | 108 | CONFLICT_RESOLVED, |
Andreas Gruenbacher | 7be8da0 | 2011-02-22 02:15:32 +0100 | [diff] [blame] | 109 | POSTPONE_WRITE, |
Andreas Gruenbacher | 8554df1 | 2011-01-25 15:37:43 +0100 | [diff] [blame] | 110 | NEG_ACKED, |
| 111 | BARRIER_ACKED, /* in protocol A and B */ |
| 112 | DATA_RECEIVED, /* (remote read) */ |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 113 | |
Andreas Gruenbacher | 8554df1 | 2011-01-25 15:37:43 +0100 | [diff] [blame] | 114 | READ_COMPLETED_WITH_ERROR, |
| 115 | READ_AHEAD_COMPLETED_WITH_ERROR, |
| 116 | WRITE_COMPLETED_WITH_ERROR, |
Philipp Reisner | cdfda63 | 2011-07-05 15:38:59 +0200 | [diff] [blame] | 117 | ABORT_DISK_IO, |
Andreas Gruenbacher | 8554df1 | 2011-01-25 15:37:43 +0100 | [diff] [blame] | 118 | COMPLETED_OK, |
| 119 | RESEND, |
| 120 | FAIL_FROZEN_DISK_IO, |
| 121 | RESTART_FROZEN_DISK_IO, |
| 122 | NOTHING, |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 123 | }; |
| 124 | |
| 125 | /* encoding of request states for now. we don't actually need that many bits. |
| 126 | * we don't need to do atomic bit operations either, since most of the time we |
| 127 | * need to look at the connection state and/or manipulate some lists at the |
| 128 | * same time, so we should hold the request lock anyways. |
| 129 | */ |
| 130 | enum drbd_req_state_bits { |
Philipp Reisner | cdfda63 | 2011-07-05 15:38:59 +0200 | [diff] [blame] | 131 | /* 3210 |
| 132 | * 0000: no local possible |
| 133 | * 0001: to be submitted |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 134 | * UNUSED, we could map: 011: submitted, completion still pending |
Philipp Reisner | cdfda63 | 2011-07-05 15:38:59 +0200 | [diff] [blame] | 135 | * 0110: completed ok |
| 136 | * 0010: completed with error |
| 137 | * 1001: Aborted (before completion) |
| 138 | * 1x10: Aborted and completed -> free |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 139 | */ |
| 140 | __RQ_LOCAL_PENDING, |
| 141 | __RQ_LOCAL_COMPLETED, |
| 142 | __RQ_LOCAL_OK, |
Philipp Reisner | cdfda63 | 2011-07-05 15:38:59 +0200 | [diff] [blame] | 143 | __RQ_LOCAL_ABORTED, |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 144 | |
Philipp Reisner | cdfda63 | 2011-07-05 15:38:59 +0200 | [diff] [blame] | 145 | /* 87654 |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 146 | * 00000: no network possible |
| 147 | * 00001: to be send |
| 148 | * 00011: to be send, on worker queue |
| 149 | * 00101: sent, expecting recv_ack (B) or write_ack (C) |
| 150 | * 11101: sent, |
| 151 | * recv_ack (B) or implicit "ack" (A), |
| 152 | * still waiting for the barrier ack. |
| 153 | * master_bio may already be completed and invalidated. |
Andreas Gruenbacher | 8554df1 | 2011-01-25 15:37:43 +0100 | [diff] [blame] | 154 | * 11100: write acked (C), |
| 155 | * data received (for remote read, any protocol) |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 156 | * or finally the barrier ack has arrived (B,A)... |
| 157 | * request can be freed |
| 158 | * 01100: neg-acked (write, protocol C) |
| 159 | * or neg-d-acked (read, any protocol) |
| 160 | * or killed from the transfer log |
| 161 | * during cleanup after connection loss |
| 162 | * request can be freed |
| 163 | * 01000: canceled or send failed... |
| 164 | * request can be freed |
| 165 | */ |
| 166 | |
| 167 | /* if "SENT" is not set, yet, this can still fail or be canceled. |
| 168 | * if "SENT" is set already, we still wait for an Ack packet. |
| 169 | * when cleared, the master_bio may be completed. |
| 170 | * in (B,A) the request object may still linger on the transaction log |
| 171 | * until the corresponding barrier ack comes in */ |
| 172 | __RQ_NET_PENDING, |
| 173 | |
| 174 | /* If it is QUEUED, and it is a WRITE, it is also registered in the |
| 175 | * transfer log. Currently we need this flag to avoid conflicts between |
| 176 | * worker canceling the request and tl_clear_barrier killing it from |
| 177 | * transfer log. We should restructure the code so this conflict does |
| 178 | * no longer occur. */ |
| 179 | __RQ_NET_QUEUED, |
| 180 | |
| 181 | /* well, actually only "handed over to the network stack". |
| 182 | * |
| 183 | * TODO can potentially be dropped because of the similar meaning |
| 184 | * of RQ_NET_SENT and ~RQ_NET_QUEUED. |
| 185 | * however it is not exactly the same. before we drop it |
| 186 | * we must ensure that we can tell a request with network part |
| 187 | * from a request without, regardless of what happens to it. */ |
| 188 | __RQ_NET_SENT, |
| 189 | |
| 190 | /* when set, the request may be freed (if RQ_NET_QUEUED is clear). |
| 191 | * basically this means the corresponding P_BARRIER_ACK was received */ |
| 192 | __RQ_NET_DONE, |
| 193 | |
| 194 | /* whether or not we know (C) or pretend (B,A) that the write |
| 195 | * was successfully written on the peer. |
| 196 | */ |
| 197 | __RQ_NET_OK, |
| 198 | |
| 199 | /* peer called drbd_set_in_sync() for this write */ |
| 200 | __RQ_NET_SIS, |
| 201 | |
| 202 | /* keep this last, its for the RQ_NET_MASK */ |
| 203 | __RQ_NET_MAX, |
Philipp Reisner | 288f422 | 2010-05-27 15:07:43 +0200 | [diff] [blame] | 204 | |
| 205 | /* Set when this is a write, clear for a read */ |
| 206 | __RQ_WRITE, |
Philipp Reisner | 0778286 | 2010-08-31 12:00:50 +0200 | [diff] [blame] | 207 | |
| 208 | /* Should call drbd_al_complete_io() for this request... */ |
| 209 | __RQ_IN_ACT_LOG, |
Andreas Gruenbacher | 7be8da0 | 2011-02-22 02:15:32 +0100 | [diff] [blame] | 210 | |
| 211 | /* The peer has sent a retry ACK */ |
| 212 | __RQ_POSTPONED, |
Philipp Reisner | 303d144 | 2011-04-13 16:24:47 -0700 | [diff] [blame] | 213 | |
Lars Ellenberg | a0d856d | 2012-01-24 17:19:42 +0100 | [diff] [blame] | 214 | /* would have been completed, |
| 215 | * but was not, because of drbd_suspended() */ |
| 216 | __RQ_COMPLETION_SUSP, |
| 217 | |
Philipp Reisner | 303d144 | 2011-04-13 16:24:47 -0700 | [diff] [blame] | 218 | /* We expect a receive ACK (wire proto B) */ |
| 219 | __RQ_EXP_RECEIVE_ACK, |
| 220 | |
| 221 | /* We expect a write ACK (wite proto C) */ |
| 222 | __RQ_EXP_WRITE_ACK, |
Lars Ellenberg | a0d856d | 2012-01-24 17:19:42 +0100 | [diff] [blame] | 223 | |
| 224 | /* waiting for a barrier ack, did an extra kref_get */ |
| 225 | __RQ_EXP_BARR_ACK, |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 226 | }; |
| 227 | |
| 228 | #define RQ_LOCAL_PENDING (1UL << __RQ_LOCAL_PENDING) |
| 229 | #define RQ_LOCAL_COMPLETED (1UL << __RQ_LOCAL_COMPLETED) |
| 230 | #define RQ_LOCAL_OK (1UL << __RQ_LOCAL_OK) |
Philipp Reisner | cdfda63 | 2011-07-05 15:38:59 +0200 | [diff] [blame] | 231 | #define RQ_LOCAL_ABORTED (1UL << __RQ_LOCAL_ABORTED) |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 232 | |
Philipp Reisner | cdfda63 | 2011-07-05 15:38:59 +0200 | [diff] [blame] | 233 | #define RQ_LOCAL_MASK ((RQ_LOCAL_ABORTED << 1)-1) |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 234 | |
| 235 | #define RQ_NET_PENDING (1UL << __RQ_NET_PENDING) |
| 236 | #define RQ_NET_QUEUED (1UL << __RQ_NET_QUEUED) |
| 237 | #define RQ_NET_SENT (1UL << __RQ_NET_SENT) |
| 238 | #define RQ_NET_DONE (1UL << __RQ_NET_DONE) |
| 239 | #define RQ_NET_OK (1UL << __RQ_NET_OK) |
| 240 | #define RQ_NET_SIS (1UL << __RQ_NET_SIS) |
| 241 | |
| 242 | /* 0x1f8 */ |
| 243 | #define RQ_NET_MASK (((1UL << __RQ_NET_MAX)-1) & ~RQ_LOCAL_MASK) |
| 244 | |
Philipp Reisner | 288f422 | 2010-05-27 15:07:43 +0200 | [diff] [blame] | 245 | #define RQ_WRITE (1UL << __RQ_WRITE) |
Philipp Reisner | 0778286 | 2010-08-31 12:00:50 +0200 | [diff] [blame] | 246 | #define RQ_IN_ACT_LOG (1UL << __RQ_IN_ACT_LOG) |
Andreas Gruenbacher | 7be8da0 | 2011-02-22 02:15:32 +0100 | [diff] [blame] | 247 | #define RQ_POSTPONED (1UL << __RQ_POSTPONED) |
Lars Ellenberg | a0d856d | 2012-01-24 17:19:42 +0100 | [diff] [blame] | 248 | #define RQ_COMPLETION_SUSP (1UL << __RQ_COMPLETION_SUSP) |
Philipp Reisner | 303d144 | 2011-04-13 16:24:47 -0700 | [diff] [blame] | 249 | #define RQ_EXP_RECEIVE_ACK (1UL << __RQ_EXP_RECEIVE_ACK) |
| 250 | #define RQ_EXP_WRITE_ACK (1UL << __RQ_EXP_WRITE_ACK) |
Lars Ellenberg | a0d856d | 2012-01-24 17:19:42 +0100 | [diff] [blame] | 251 | #define RQ_EXP_BARR_ACK (1UL << __RQ_EXP_BARR_ACK) |
Philipp Reisner | 288f422 | 2010-05-27 15:07:43 +0200 | [diff] [blame] | 252 | |
Philipp Reisner | 11b58e7 | 2010-05-12 17:08:26 +0200 | [diff] [blame] | 253 | /* For waking up the frozen transfer log mod_req() has to return if the request |
| 254 | should be counted in the epoch object*/ |
Andreas Gruenbacher | f497609 | 2011-07-17 23:06:12 +0200 | [diff] [blame] | 255 | #define MR_WRITE 1 |
| 256 | #define MR_READ 2 |
Philipp Reisner | 11b58e7 | 2010-05-12 17:08:26 +0200 | [diff] [blame] | 257 | |
Philipp Reisner | 5ba8230 | 2010-06-10 13:30:36 +0200 | [diff] [blame] | 258 | static inline void drbd_req_make_private_bio(struct drbd_request *req, struct bio *bio_src) |
| 259 | { |
| 260 | struct bio *bio; |
| 261 | bio = bio_clone(bio_src, GFP_NOIO); /* XXX cannot fail?? */ |
| 262 | |
| 263 | req->private_bio = bio; |
| 264 | |
| 265 | bio->bi_private = req; |
Andreas Gruenbacher | fcefa62 | 2011-02-17 16:46:59 +0100 | [diff] [blame] | 266 | bio->bi_end_io = drbd_request_endio; |
Philipp Reisner | 5ba8230 | 2010-06-10 13:30:36 +0200 | [diff] [blame] | 267 | bio->bi_next = NULL; |
| 268 | } |
| 269 | |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 270 | /* Short lived temporary struct on the stack. |
| 271 | * We could squirrel the error to be returned into |
| 272 | * bio->bi_size, or similar. But that would be too ugly. */ |
| 273 | struct bio_and_error { |
| 274 | struct bio *bio; |
| 275 | int error; |
| 276 | }; |
| 277 | |
Lars Ellenberg | 2681f7f | 2013-01-21 15:43:41 +0100 | [diff] [blame] | 278 | extern void start_new_tl_epoch(struct drbd_tconn *tconn); |
Lars Ellenberg | 9a278a7 | 2012-07-24 10:12:36 +0200 | [diff] [blame] | 279 | extern void drbd_req_destroy(struct kref *kref); |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 280 | extern void _req_may_be_done(struct drbd_request *req, |
| 281 | struct bio_and_error *m); |
Philipp Reisner | 2a80699 | 2010-06-09 14:07:43 +0200 | [diff] [blame] | 282 | extern int __req_mod(struct drbd_request *req, enum drbd_req_event what, |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 283 | struct bio_and_error *m); |
| 284 | extern void complete_master_bio(struct drbd_conf *mdev, |
| 285 | struct bio_and_error *m); |
Philipp Reisner | 7fde2be | 2011-03-01 11:08:28 +0100 | [diff] [blame] | 286 | extern void request_timer_fn(unsigned long data); |
Philipp Reisner | 2f5cdd0 | 2011-02-21 14:29:27 +0100 | [diff] [blame] | 287 | extern void tl_restart(struct drbd_tconn *tconn, enum drbd_req_event what); |
| 288 | extern void _tl_restart(struct drbd_tconn *tconn, enum drbd_req_event what); |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 289 | |
Lars Ellenberg | 2312f0b3 | 2011-11-24 10:36:25 +0100 | [diff] [blame] | 290 | /* this is in drbd_main.c */ |
Lars Ellenberg | 9d05e7c | 2012-07-17 10:05:04 +0200 | [diff] [blame] | 291 | extern void drbd_restart_request(struct drbd_request *req); |
Lars Ellenberg | 2312f0b3 | 2011-11-24 10:36:25 +0100 | [diff] [blame] | 292 | |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 293 | /* use this if you don't want to deal with calling complete_master_bio() |
| 294 | * outside the spinlock, e.g. when walking some list on cleanup. */ |
Philipp Reisner | 2a80699 | 2010-06-09 14:07:43 +0200 | [diff] [blame] | 295 | static inline int _req_mod(struct drbd_request *req, enum drbd_req_event what) |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 296 | { |
Philipp Reisner | a21e929 | 2011-02-08 15:08:49 +0100 | [diff] [blame] | 297 | struct drbd_conf *mdev = req->w.mdev; |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 298 | struct bio_and_error m; |
Philipp Reisner | 2a80699 | 2010-06-09 14:07:43 +0200 | [diff] [blame] | 299 | int rv; |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 300 | |
| 301 | /* __req_mod possibly frees req, do not touch req after that! */ |
Philipp Reisner | 2a80699 | 2010-06-09 14:07:43 +0200 | [diff] [blame] | 302 | rv = __req_mod(req, what, &m); |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 303 | if (m.bio) |
| 304 | complete_master_bio(mdev, &m); |
Philipp Reisner | 2a80699 | 2010-06-09 14:07:43 +0200 | [diff] [blame] | 305 | |
| 306 | return rv; |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 307 | } |
| 308 | |
Philipp Reisner | 759fbdf | 2010-10-26 16:02:27 +0200 | [diff] [blame] | 309 | /* completion of master bio is outside of our spinlock. |
| 310 | * We still may or may not be inside some irqs disabled section |
| 311 | * of the lower level driver completion callback, so we need to |
| 312 | * spin_lock_irqsave here. */ |
Philipp Reisner | 2a80699 | 2010-06-09 14:07:43 +0200 | [diff] [blame] | 313 | static inline int req_mod(struct drbd_request *req, |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 314 | enum drbd_req_event what) |
| 315 | { |
Philipp Reisner | 759fbdf | 2010-10-26 16:02:27 +0200 | [diff] [blame] | 316 | unsigned long flags; |
Philipp Reisner | a21e929 | 2011-02-08 15:08:49 +0100 | [diff] [blame] | 317 | struct drbd_conf *mdev = req->w.mdev; |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 318 | struct bio_and_error m; |
Philipp Reisner | 2a80699 | 2010-06-09 14:07:43 +0200 | [diff] [blame] | 319 | int rv; |
| 320 | |
Philipp Reisner | 87eeee4 | 2011-01-19 14:16:30 +0100 | [diff] [blame] | 321 | spin_lock_irqsave(&mdev->tconn->req_lock, flags); |
Philipp Reisner | 2a80699 | 2010-06-09 14:07:43 +0200 | [diff] [blame] | 322 | rv = __req_mod(req, what, &m); |
Philipp Reisner | 87eeee4 | 2011-01-19 14:16:30 +0100 | [diff] [blame] | 323 | spin_unlock_irqrestore(&mdev->tconn->req_lock, flags); |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 324 | |
| 325 | if (m.bio) |
| 326 | complete_master_bio(mdev, &m); |
Philipp Reisner | 2a80699 | 2010-06-09 14:07:43 +0200 | [diff] [blame] | 327 | |
| 328 | return rv; |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 329 | } |
Philipp Reisner | 6a35c45 | 2011-01-17 20:27:30 +0100 | [diff] [blame] | 330 | |
Philipp Reisner | da9fbc2 | 2011-03-29 10:52:01 +0200 | [diff] [blame] | 331 | static inline bool drbd_should_do_remote(union drbd_dev_state s) |
Philipp Reisner | 6a35c45 | 2011-01-17 20:27:30 +0100 | [diff] [blame] | 332 | { |
| 333 | return s.pdsk == D_UP_TO_DATE || |
| 334 | (s.pdsk >= D_INCONSISTENT && |
| 335 | s.conn >= C_WF_BITMAP_T && |
| 336 | s.conn < C_AHEAD); |
| 337 | /* Before proto 96 that was >= CONNECTED instead of >= C_WF_BITMAP_T. |
| 338 | That is equivalent since before 96 IO was frozen in the C_WF_BITMAP* |
| 339 | states. */ |
| 340 | } |
Philipp Reisner | da9fbc2 | 2011-03-29 10:52:01 +0200 | [diff] [blame] | 341 | static inline bool drbd_should_send_out_of_sync(union drbd_dev_state s) |
Philipp Reisner | 6a35c45 | 2011-01-17 20:27:30 +0100 | [diff] [blame] | 342 | { |
| 343 | return s.conn == C_AHEAD || s.conn == C_WF_BITMAP_S; |
| 344 | /* pdsk = D_INCONSISTENT as a consequence. Protocol 96 check not necessary |
| 345 | since we enter state C_AHEAD only if proto >= 96 */ |
| 346 | } |
| 347 | |
Philipp Reisner | b411b36 | 2009-09-25 16:07:19 -0700 | [diff] [blame] | 348 | #endif |