diff options
author | Philipp Reisner <philipp.reisner@linbit.com> | 2010-08-25 05:58:05 -0400 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2010-10-14 12:38:32 -0400 |
commit | 76d2e7eca8e7675c6d7a6592f9e747b121cc8a87 (patch) | |
tree | 0fef8428c57574046bdd650c4040c9c3d299aba5 /drivers/block | |
parent | 1090c056c5eb6d5335cceb381683e77ac24c71ab (diff) |
drbd: Adding support for BIO/Request flags: REQ_FUA, REQ_FLUSH and REQ_DISCARD
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/drbd/drbd_int.h | 8 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_main.c | 28 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_receiver.c | 20 |
3 files changed, 34 insertions, 22 deletions
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h index f9b75fc30569..79b877db9a39 100644 --- a/drivers/block/drbd/drbd_int.h +++ b/drivers/block/drbd/drbd_int.h | |||
@@ -374,9 +374,13 @@ union p_header { | |||
374 | */ | 374 | */ |
375 | 375 | ||
376 | /* these defines must not be changed without changing the protocol version */ | 376 | /* these defines must not be changed without changing the protocol version */ |
377 | #define DP_HARDBARRIER 1 | 377 | #define DP_HARDBARRIER 1 /* depricated */ |
378 | #define DP_RW_SYNC 2 | 378 | #define DP_RW_SYNC 2 /* equals REQ_SYNC */ |
379 | #define DP_MAY_SET_IN_SYNC 4 | 379 | #define DP_MAY_SET_IN_SYNC 4 |
380 | #define DP_UNPLUG 8 /* equals REQ_UNPLUG */ | ||
381 | #define DP_FUA 16 /* equals REQ_FUA */ | ||
382 | #define DP_FLUSH 32 /* equals REQ_FLUSH */ | ||
383 | #define DP_DISCARD 64 /* equals REQ_DISCARD */ | ||
380 | 384 | ||
381 | struct p_data { | 385 | struct p_data { |
382 | union p_header head; | 386 | union p_header head; |
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index ab1244e0045c..1827cf073c2e 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c | |||
@@ -2426,6 +2426,18 @@ static int _drbd_send_zc_ee(struct drbd_conf *mdev, struct drbd_epoch_entry *e) | |||
2426 | return 1; | 2426 | return 1; |
2427 | } | 2427 | } |
2428 | 2428 | ||
2429 | static u32 bio_flags_to_wire(struct drbd_conf *mdev, unsigned long bi_rw) | ||
2430 | { | ||
2431 | if (mdev->agreed_pro_version >= 95) | ||
2432 | return (bi_rw & REQ_SYNC ? DP_RW_SYNC : 0) | | ||
2433 | (bi_rw & REQ_UNPLUG ? DP_UNPLUG : 0) | | ||
2434 | (bi_rw & REQ_FUA ? DP_FUA : 0) | | ||
2435 | (bi_rw & REQ_FLUSH ? DP_FLUSH : 0) | | ||
2436 | (bi_rw & REQ_DISCARD ? DP_DISCARD : 0); | ||
2437 | else | ||
2438 | return bi_rw & (REQ_SYNC | REQ_UNPLUG) ? DP_RW_SYNC : 0; | ||
2439 | } | ||
2440 | |||
2429 | /* Used to send write requests | 2441 | /* Used to send write requests |
2430 | * R_PRIMARY -> Peer (P_DATA) | 2442 | * R_PRIMARY -> Peer (P_DATA) |
2431 | */ | 2443 | */ |
@@ -2459,21 +2471,9 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req) | |||
2459 | p.block_id = (unsigned long)req; | 2471 | p.block_id = (unsigned long)req; |
2460 | p.seq_num = cpu_to_be32(req->seq_num = | 2472 | p.seq_num = cpu_to_be32(req->seq_num = |
2461 | atomic_add_return(1, &mdev->packet_seq)); | 2473 | atomic_add_return(1, &mdev->packet_seq)); |
2462 | dp_flags = 0; | ||
2463 | 2474 | ||
2464 | /* NOTE: no need to check if barriers supported here as we would | 2475 | dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw); |
2465 | * not pass the test in make_request_common in that case | 2476 | |
2466 | */ | ||
2467 | if (req->master_bio->bi_rw & REQ_HARDBARRIER) { | ||
2468 | dev_err(DEV, "ASSERT FAILED would have set DP_HARDBARRIER\n"); | ||
2469 | /* dp_flags |= DP_HARDBARRIER; */ | ||
2470 | } | ||
2471 | if (req->master_bio->bi_rw & REQ_SYNC) | ||
2472 | dp_flags |= DP_RW_SYNC; | ||
2473 | /* for now handle SYNCIO and UNPLUG | ||
2474 | * as if they still were one and the same flag */ | ||
2475 | if (req->master_bio->bi_rw & REQ_UNPLUG) | ||
2476 | dp_flags |= DP_RW_SYNC; | ||
2477 | if (mdev->state.conn >= C_SYNC_SOURCE && | 2477 | if (mdev->state.conn >= C_SYNC_SOURCE && |
2478 | mdev->state.conn <= C_PAUSED_SYNC_T) | 2478 | mdev->state.conn <= C_PAUSED_SYNC_T) |
2479 | dp_flags |= DP_MAY_SET_IN_SYNC; | 2479 | dp_flags |= DP_MAY_SET_IN_SYNC; |
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c index 885471ded2fb..e96fbb04ea4d 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c | |||
@@ -1753,6 +1753,18 @@ static int drbd_wait_peer_seq(struct drbd_conf *mdev, const u32 packet_seq) | |||
1753 | return ret; | 1753 | return ret; |
1754 | } | 1754 | } |
1755 | 1755 | ||
1756 | static unsigned long write_flags_to_bio(struct drbd_conf *mdev, u32 dpf) | ||
1757 | { | ||
1758 | if (mdev->agreed_pro_version >= 95) | ||
1759 | return (dpf & DP_RW_SYNC ? REQ_SYNC : 0) | | ||
1760 | (dpf & DP_UNPLUG ? REQ_UNPLUG : 0) | | ||
1761 | (dpf & DP_FUA ? REQ_FUA : 0) | | ||
1762 | (dpf & DP_FLUSH ? REQ_FUA : 0) | | ||
1763 | (dpf & DP_DISCARD ? REQ_DISCARD : 0); | ||
1764 | else | ||
1765 | return dpf & DP_RW_SYNC ? (REQ_SYNC | REQ_UNPLUG) : 0; | ||
1766 | } | ||
1767 | |||
1756 | /* mirrored write */ | 1768 | /* mirrored write */ |
1757 | static int receive_Data(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int data_size) | 1769 | static int receive_Data(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int data_size) |
1758 | { | 1770 | { |
@@ -1818,12 +1830,8 @@ static int receive_Data(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned | |||
1818 | spin_unlock(&mdev->epoch_lock); | 1830 | spin_unlock(&mdev->epoch_lock); |
1819 | 1831 | ||
1820 | dp_flags = be32_to_cpu(p->dp_flags); | 1832 | dp_flags = be32_to_cpu(p->dp_flags); |
1821 | if (dp_flags & DP_HARDBARRIER) { | 1833 | rw |= write_flags_to_bio(mdev, dp_flags); |
1822 | dev_err(DEV, "ASSERT FAILED would have submitted barrier request\n"); | 1834 | |
1823 | /* rw |= REQ_HARDBARRIER; */ | ||
1824 | } | ||
1825 | if (dp_flags & DP_RW_SYNC) | ||
1826 | rw |= REQ_SYNC | REQ_UNPLUG; | ||
1827 | if (dp_flags & DP_MAY_SET_IN_SYNC) | 1835 | if (dp_flags & DP_MAY_SET_IN_SYNC) |
1828 | e->flags |= EE_MAY_SET_IN_SYNC; | 1836 | e->flags |= EE_MAY_SET_IN_SYNC; |
1829 | 1837 | ||