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

Commit 0ddf9644 authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Alasdair G Kergon
Browse files

dm ioctl: fill in device parameters in more ioctls



Move parameter filling from find_device to __find_device_hash_cell.

This patch causes ioctls using __find_device_hash_cell
(DM_DEV_REMOVE_CMD, DM_DEV_SUSPEND_CMD - resume, DM_TABLE_CLEAR_CMD)
to return device parameters, bringing them into line with the other
ioctls.

Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
parent a3998799
Loading
Loading
Loading
Loading
+36 −27
Original line number Original line Diff line number Diff line
@@ -719,36 +719,33 @@ static int dev_create(struct dm_ioctl *param, size_t param_size)
static struct hash_cell *__find_device_hash_cell(struct dm_ioctl *param)
static struct hash_cell *__find_device_hash_cell(struct dm_ioctl *param)
{
{
	struct mapped_device *md;
	struct mapped_device *md;
	void *mdptr = NULL;
	struct hash_cell *hc = NULL;


	if (*param->uuid)
	if (*param->uuid) {
		return __get_uuid_cell(param->uuid);
		hc = __get_uuid_cell(param->uuid);
		if (!hc)
			return NULL;
		goto fill_params;
	}


	if (*param->name)
	if (*param->name) {
		return __get_name_cell(param->name);
		hc = __get_name_cell(param->name);
		if (!hc)
			return NULL;
		goto fill_params;
	}


	md = dm_get_md(huge_decode_dev(param->dev));
	md = dm_get_md(huge_decode_dev(param->dev));
	if (!md)
	if (!md)
		goto out;
		return NULL;


	mdptr = dm_get_mdptr(md);
	hc = dm_get_mdptr(md);
	if (!mdptr)
	if (!hc) {
		dm_put(md);
		dm_put(md);

		return NULL;
out:
	return mdptr;
	}
	}


static struct mapped_device *find_device(struct dm_ioctl *param)
fill_params:
{
	struct hash_cell *hc;
	struct mapped_device *md = NULL;

	down_read(&_hash_lock);
	hc = __find_device_hash_cell(param);
	if (hc) {
		md = hc->md;

	/*
	/*
	 * Sneakily write in both the name and the uuid
	 * Sneakily write in both the name and the uuid
	 * while we have the cell.
	 * while we have the cell.
@@ -763,7 +760,19 @@ static struct mapped_device *find_device(struct dm_ioctl *param)
		param->flags |= DM_INACTIVE_PRESENT_FLAG;
		param->flags |= DM_INACTIVE_PRESENT_FLAG;
	else
	else
		param->flags &= ~DM_INACTIVE_PRESENT_FLAG;
		param->flags &= ~DM_INACTIVE_PRESENT_FLAG;

	return hc;
}
}

static struct mapped_device *find_device(struct dm_ioctl *param)
{
	struct hash_cell *hc;
	struct mapped_device *md = NULL;

	down_read(&_hash_lock);
	hc = __find_device_hash_cell(param);
	if (hc)
		md = hc->md;
	up_read(&_hash_lock);
	up_read(&_hash_lock);


	return md;
	return md;
+2 −2
Original line number Original line Diff line number Diff line
@@ -267,9 +267,9 @@ enum {
#define DM_DEV_SET_GEOMETRY	_IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)
#define DM_DEV_SET_GEOMETRY	_IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)


#define DM_VERSION_MAJOR	4
#define DM_VERSION_MAJOR	4
#define DM_VERSION_MINOR	20
#define DM_VERSION_MINOR	21
#define DM_VERSION_PATCHLEVEL	0
#define DM_VERSION_PATCHLEVEL	0
#define DM_VERSION_EXTRA	"-ioctl (2011-02-02)"
#define DM_VERSION_EXTRA	"-ioctl (2011-07-06)"


/* Status bits */
/* Status bits */
#define DM_READONLY_FLAG	(1 << 0) /* In/Out */
#define DM_READONLY_FLAG	(1 << 0) /* In/Out */