diff options
author | Lars Ellenberg <lars.ellenberg@linbit.com> | 2012-08-07 00:42:09 -0400 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2012-11-09 08:05:47 -0500 |
commit | 99b4d8fe6d12dcb49126df7153961fbc4de05f2a (patch) | |
tree | 6e9f8f96b8264f7d1ce801d32526ec47b99de051 /drivers/block/drbd | |
parent | 8a0bab2a6dd05ee35777370be892daba01750712 (diff) |
drbd: only start a new epoch, if the current epoch contains writes
Almost all code paths calling start_new_tl_epoch() guarded it with
if (... current_tle_writes > 0 ... ).
Just move that inside start_new_tl_epoch().
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 | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c index 6e8d09763510..0c1b6327e207 100644 --- a/drivers/block/drbd/drbd_req.c +++ b/drivers/block/drbd/drbd_req.c | |||
@@ -162,6 +162,10 @@ static void wake_all_senders(struct drbd_tconn *tconn) { | |||
162 | /* must hold resource->req_lock */ | 162 | /* must hold resource->req_lock */ |
163 | static void start_new_tl_epoch(struct drbd_tconn *tconn) | 163 | static void start_new_tl_epoch(struct drbd_tconn *tconn) |
164 | { | 164 | { |
165 | /* no point closing an epoch, if it is empty, anyways. */ | ||
166 | if (tconn->current_tle_writes == 0) | ||
167 | return; | ||
168 | |||
165 | tconn->current_tle_writes = 0; | 169 | tconn->current_tle_writes = 0; |
166 | atomic_inc(&tconn->current_tle_nr); | 170 | atomic_inc(&tconn->current_tle_nr); |
167 | wake_all_senders(tconn); | 171 | wake_all_senders(tconn); |
@@ -861,9 +865,8 @@ static void maybe_pull_ahead(struct drbd_conf *mdev) | |||
861 | } | 865 | } |
862 | 866 | ||
863 | if (congested) { | 867 | if (congested) { |
864 | if (mdev->tconn->current_tle_writes) | 868 | /* start a new epoch for non-mirrored writes */ |
865 | /* start a new epoch for non-mirrored writes */ | 869 | start_new_tl_epoch(mdev->tconn); |
866 | start_new_tl_epoch(mdev->tconn); | ||
867 | 870 | ||
868 | if (on_congestion == OC_PULL_AHEAD) | 871 | if (on_congestion == OC_PULL_AHEAD) |
869 | _drbd_set_state(_NS(mdev, conn, C_AHEAD), 0, NULL); | 872 | _drbd_set_state(_NS(mdev, conn, C_AHEAD), 0, NULL); |
@@ -950,7 +953,7 @@ static int drbd_process_write_request(struct drbd_request *req) | |||
950 | if (unlikely(req->i.size == 0)) { | 953 | if (unlikely(req->i.size == 0)) { |
951 | /* The only size==0 bios we expect are empty flushes. */ | 954 | /* The only size==0 bios we expect are empty flushes. */ |
952 | D_ASSERT(req->master_bio->bi_rw & REQ_FLUSH); | 955 | D_ASSERT(req->master_bio->bi_rw & REQ_FLUSH); |
953 | if (remote && mdev->tconn->current_tle_writes) | 956 | if (remote) |
954 | start_new_tl_epoch(mdev->tconn); | 957 | start_new_tl_epoch(mdev->tconn); |
955 | return 0; | 958 | return 0; |
956 | } | 959 | } |
@@ -1066,13 +1069,15 @@ void __drbd_make_request(struct drbd_conf *mdev, struct bio *bio, unsigned long | |||
1066 | 1069 | ||
1067 | /* which transfer log epoch does this belong to? */ | 1070 | /* which transfer log epoch does this belong to? */ |
1068 | req->epoch = atomic_read(&mdev->tconn->current_tle_nr); | 1071 | req->epoch = atomic_read(&mdev->tconn->current_tle_nr); |
1069 | if (rw == WRITE) | ||
1070 | mdev->tconn->current_tle_writes++; | ||
1071 | 1072 | ||
1072 | /* no point in adding empty flushes to the transfer log, | 1073 | /* no point in adding empty flushes to the transfer log, |
1073 | * they are mapped to drbd barriers already. */ | 1074 | * they are mapped to drbd barriers already. */ |
1074 | if (likely(req->i.size!=0)) | 1075 | if (likely(req->i.size!=0)) { |
1076 | if (rw == WRITE) | ||
1077 | mdev->tconn->current_tle_writes++; | ||
1078 | |||
1075 | list_add_tail(&req->tl_requests, &mdev->tconn->transfer_log); | 1079 | list_add_tail(&req->tl_requests, &mdev->tconn->transfer_log); |
1080 | } | ||
1076 | 1081 | ||
1077 | if (rw == WRITE) { | 1082 | if (rw == WRITE) { |
1078 | if (!drbd_process_write_request(req)) | 1083 | if (!drbd_process_write_request(req)) |