Linux Device Mapper development
 help / color / mirror / Atom feed
From: Andy Grover <agrover@redhat.com>
To: dm-devel@redhat.com
Subject: [PATCH 3/3] dm: Allow associated fd to be used for TABLE_STATUS
Date: Mon,  9 Jan 2017 10:20:40 -0800	[thread overview]
Message-ID: <20170109182040.31337-4-agrover@redhat.com> (raw)
In-Reply-To: <20170109182040.31337-1-agrover@redhat.com>

Allows TABLE_STATUS to be used without specifying the dm device in the
ioctl, if it has previously been associated with a device.

Signed-off-by: Andy Grover <agrover@redhat.com>
---
 drivers/md/dm-ioctl.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index c5fc53c..c4c47a6 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -1504,13 +1504,19 @@ static int table_deps(struct file *filp, struct dm_ioctl *param, size_t param_si
  */
 static int table_status(struct file *filp, struct dm_ioctl *param, size_t param_size)
 {
+	struct dm_file *priv = filp->private_data;
 	struct mapped_device *md;
 	struct dm_table *table;
 	int srcu_idx;
 
-	md = find_device(param);
-	if (!md)
-		return -ENXIO;
+	if (priv && priv->md) {
+		md = priv->md;
+		dm_get(md);
+	} else {
+		md = find_device(param);
+		if (!md)
+			return -ENXIO;
+	}
 
 	__dev_status(md, param);
 
@@ -1868,12 +1874,6 @@ static int ctl_ioctl(struct file *file, uint command, struct dm_ioctl __user *us
 	if (cmd == DM_VERSION_CMD)
 		return 0;
 
-	/*
-	 * Cannot use files that have been associated for most ioctls.
-	 * See dev_assoc_set().
-	 */
-	if (file->private_data)
-		return -EINVAL;
 
 	fn = lookup_ioctl(cmd, &ioctl_flags);
 	if (!fn) {
@@ -1882,6 +1882,13 @@ static int ctl_ioctl(struct file *file, uint command, struct dm_ioctl __user *us
 	}
 
 	/*
+	 * Cannot use files that have been associated for ioctls other than
+	 * VERSION and TABLE_STATUS.
+	 */
+	if (file->private_data && cmd != DM_TABLE_STATUS_CMD)
+		return -EINVAL;
+
+	/*
 	 * Copy the parameters into kernel space.
 	 */
 	r = copy_params(user, &param_kernel, ioctl_flags, &param, &param_flags);
-- 
2.9.3

      parent reply	other threads:[~2017-01-09 18:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-09 18:20 [PATCH 0/3] poll() for DM events Andy Grover
2017-01-09 18:20 ` [PATCH 1/3] dm: Change ioctl handlers to take struct file* Andy Grover
2017-01-09 18:20 ` [PATCH 2/3] dm: Add support to poll for dm events Andy Grover
2017-01-10  2:10   ` Andy Grover
2017-01-09 18:20 ` Andy Grover [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170109182040.31337-4-agrover@redhat.com \
    --to=agrover@redhat.com \
    --cc=dm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox