diff options
author | Lars Ellenberg <lars.ellenberg@linbit.com> | 2012-08-02 20:19:09 -0400 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2012-11-09 08:05:46 -0500 |
commit | 519b6d3eac823e4ceec10484bc06f239047cebbf (patch) | |
tree | e3aeff3d85e0b75cf474bd717fd184c4b50e4cf4 /drivers/block/drbd | |
parent | 80c6eed49d5da3ba97cff4dc316ff051486cd1fc (diff) |
drbd: fix drbd wire compatibility for empty flushes
DRBD has a concept of request epochs or reorder-domains,
which are separated on the wire by P_BARRIER packets.
Older DRBD is not able to handle zero-sized requests at all,
so we need to map empty flushes to these drbd barriers.
These are the equivalent of empty flushes, and
by default trigger flushes on the receiving side anyways
(unless not supported or explicitly disabled),
so there is no need to handle this differently in newer drbd either.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers/block/drbd')
-rw-r--r-- | drivers/block/drbd/drbd_req.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c index 8323449fbbab..a9111b68fe2d 100644 --- a/drivers/block/drbd/drbd_req.c +++ b/drivers/block/drbd/drbd_req.c | |||
@@ -935,6 +935,20 @@ static int drbd_process_write_request(struct drbd_request *req) | |||
935 | send_oos = drbd_should_send_out_of_sync(mdev->state); | 935 | send_oos = drbd_should_send_out_of_sync(mdev->state); |
936 | rcu_read_unlock(); | 936 | rcu_read_unlock(); |
937 | 937 | ||
938 | /* Need to replicate writes. Unless it is an empty flush, | ||
939 | * which is better mapped to a DRBD P_BARRIER packet, | ||
940 | * also for drbd wire protocol compatibility reasons. | ||
941 | * If this was a flush, just start a new epoch. | ||
942 | * Unless the current epoch was empty anyways, or we are not currently | ||
943 | * replicating, in which case there is no point. */ | ||
944 | if (unlikely(req->i.size == 0)) { | ||
945 | /* The only size==0 bios we expect are empty flushes. */ | ||
946 | D_ASSERT(req->master_bio->bi_rw & REQ_FLUSH); | ||
947 | if (remote && mdev->tconn->current_tle_writes) | ||
948 | start_new_tl_epoch(mdev->tconn); | ||
949 | return 0; | ||
950 | } | ||
951 | |||
938 | if (!remote && !send_oos) | 952 | if (!remote && !send_oos) |
939 | return 0; | 953 | return 0; |
940 | 954 | ||
@@ -1004,8 +1018,10 @@ void __drbd_make_request(struct drbd_conf *mdev, struct bio *bio, unsigned long | |||
1004 | * extent. This waits for any resync activity in the corresponding | 1018 | * extent. This waits for any resync activity in the corresponding |
1005 | * resync extent to finish, and, if necessary, pulls in the target | 1019 | * resync extent to finish, and, if necessary, pulls in the target |
1006 | * extent into the activity log, which involves further disk io because | 1020 | * extent into the activity log, which involves further disk io because |
1007 | * of transactional on-disk meta data updates. */ | 1021 | * of transactional on-disk meta data updates. |
1008 | if (rw == WRITE && req->private_bio | 1022 | * Empty flushes don't need to go into the activity log, they can only |
1023 | * flush data for pending writes which are already in there. */ | ||
1024 | if (rw == WRITE && req->private_bio && req->i.size | ||
1009 | && !test_bit(AL_SUSPENDED, &mdev->flags)) { | 1025 | && !test_bit(AL_SUSPENDED, &mdev->flags)) { |
1010 | req->rq_state |= RQ_IN_ACT_LOG; | 1026 | req->rq_state |= RQ_IN_ACT_LOG; |
1011 | drbd_al_begin_io(mdev, &req->i); | 1027 | drbd_al_begin_io(mdev, &req->i); |
@@ -1047,7 +1063,10 @@ void __drbd_make_request(struct drbd_conf *mdev, struct bio *bio, unsigned long | |||
1047 | if (rw == WRITE) | 1063 | if (rw == WRITE) |
1048 | mdev->tconn->current_tle_writes++; | 1064 | mdev->tconn->current_tle_writes++; |
1049 | 1065 | ||
1050 | list_add_tail(&req->tl_requests, &mdev->tconn->transfer_log); | 1066 | /* no point in adding empty flushes to the transfer log, |
1067 | * they are mapped to drbd barriers already. */ | ||
1068 | if (likely(req->i.size!=0)) | ||
1069 | list_add_tail(&req->tl_requests, &mdev->tconn->transfer_log); | ||
1051 | 1070 | ||
1052 | if (rw == WRITE) { | 1071 | if (rw == WRITE) { |
1053 | if (!drbd_process_write_request(req)) | 1072 | if (!drbd_process_write_request(req)) |