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

Commit 223f1af6 authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Greg Kroah-Hartman
Browse files

dm snapshot: introduce account_start_copy() and account_end_copy()



[ Upstream commit a2f83e8b0c82c9500421a26c49eb198b25fcdea3 ]

This simple refactoring moves code for modifying the semaphore cow_count
into separate functions to prepare for changes that will extend these
methods to provide for a more sophisticated mechanism for COW
throttling.

Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Reviewed-by: default avatarNikos Tsironis <ntsironis@arrikto.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 0ca37291
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -1399,6 +1399,16 @@ static void snapshot_dtr(struct dm_target *ti)
	kfree(s);
}

static void account_start_copy(struct dm_snapshot *s)
{
	down(&s->cow_count);
}

static void account_end_copy(struct dm_snapshot *s)
{
	up(&s->cow_count);
}

/*
 * Flush a list of buffers.
 */
@@ -1594,7 +1604,7 @@ static void copy_callback(int read_err, unsigned long write_err, void *context)
		rb_link_node(&pe->out_of_order_node, parent, p);
		rb_insert_color(&pe->out_of_order_node, &s->out_of_order_tree);
	}
	up(&s->cow_count);
	account_end_copy(s);
}

/*
@@ -1618,7 +1628,7 @@ static void start_copy(struct dm_snap_pending_exception *pe)
	dest.count = src.count;

	/* Hand over to kcopyd */
	down(&s->cow_count);
	account_start_copy(s);
	dm_kcopyd_copy(s->kcopyd_client, &src, 1, &dest, 0, copy_callback, pe);
}

@@ -1638,7 +1648,7 @@ static void start_full_bio(struct dm_snap_pending_exception *pe,
	pe->full_bio = bio;
	pe->full_bio_end_io = bio->bi_end_io;

	down(&s->cow_count);
	account_start_copy(s);
	callback_data = dm_kcopyd_prepare_callback(s->kcopyd_client,
						   copy_callback, pe);