Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 99b4d8fe authored by Lars Ellenberg's avatar Lars Ellenberg Committed by Philipp Reisner
Browse files

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: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent 8a0bab2a
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -162,6 +162,10 @@ static void wake_all_senders(struct drbd_tconn *tconn) {
/* must hold resource->req_lock */
static void start_new_tl_epoch(struct drbd_tconn *tconn)
{
	/* no point closing an epoch, if it is empty, anyways. */
	if (tconn->current_tle_writes == 0)
		return;

	tconn->current_tle_writes = 0;
	atomic_inc(&tconn->current_tle_nr);
	wake_all_senders(tconn);
@@ -861,7 +865,6 @@ static void maybe_pull_ahead(struct drbd_conf *mdev)
	}

	if (congested) {
		if (mdev->tconn->current_tle_writes)
		/* start a new epoch for non-mirrored writes */
		start_new_tl_epoch(mdev->tconn);

@@ -950,7 +953,7 @@ static int drbd_process_write_request(struct drbd_request *req)
	if (unlikely(req->i.size == 0)) {
		/* The only size==0 bios we expect are empty flushes. */
		D_ASSERT(req->master_bio->bi_rw & REQ_FLUSH);
		if (remote && mdev->tconn->current_tle_writes)
		if (remote)
			start_new_tl_epoch(mdev->tconn);
		return 0;
	}
@@ -1066,13 +1069,15 @@ void __drbd_make_request(struct drbd_conf *mdev, struct bio *bio, unsigned long

	/* which transfer log epoch does this belong to? */
	req->epoch = atomic_read(&mdev->tconn->current_tle_nr);
	if (rw == WRITE)
		mdev->tconn->current_tle_writes++;

	/* no point in adding empty flushes to the transfer log,
	 * they are mapped to drbd barriers already. */
	if (likely(req->i.size!=0))
	if (likely(req->i.size!=0)) {
		if (rw == WRITE)
			mdev->tconn->current_tle_writes++;

		list_add_tail(&req->tl_requests, &mdev->tconn->transfer_log);
	}

	if (rw == WRITE) {
		if (!drbd_process_write_request(req))