From: Ed Cashin <ecashin@coraid.com>
From: Ed Cashin <ecashin@coraid.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, ecashin@coraid.com
Subject: [PATCH 2/8] aoe: provide ATA identify device content to user on request
Date: Thu, 8 Nov 2012 19:19:16 -0500 [thread overview]
Message-ID: <fe2ec651bfe9d006a81e75c6205a82a4d0e7dda7.1352410985.git.ecashin@coraid.com> (raw)
In-Reply-To: <cover.1352410985.git.ecashin@coraid.com>
This patch makes the aoe driver follow expected behavior when the
user uses ioctl to get the ATA device identify information,
allowing access to model, serial number, etc.
Signed-off-by: Ed Cashin <ecashin@coraid.com>
---
drivers/block/aoe/aoe.h | 1 +
drivers/block/aoe/aoeblk.c | 30 ++++++++++++++++++++++++++++++
drivers/block/aoe/aoecmd.c | 16 ++++++++++++++++
3 files changed, 47 insertions(+), 0 deletions(-)
diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h
index 536942b..f6e0c03 100644
--- a/drivers/block/aoe/aoe.h
+++ b/drivers/block/aoe/aoe.h
@@ -169,6 +169,7 @@ struct aoedev {
struct aoetgt *htgt; /* target needing rexmit assistance */
ulong ntargets;
ulong kicked;
+ char ident[512];
};
/* kthread tracking */
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
index 56736cd..7ba0fcf 100644
--- a/drivers/block/aoe/aoeblk.c
+++ b/drivers/block/aoe/aoeblk.c
@@ -17,6 +17,7 @@
#include <linux/mutex.h>
#include <linux/export.h>
#include <linux/moduleparam.h>
+#include <scsi/sg.h>
#include "aoe.h"
static DEFINE_MUTEX(aoeblk_mutex);
@@ -212,9 +213,38 @@ aoeblk_getgeo(struct block_device *bdev, struct hd_geometry *geo)
return 0;
}
+static int
+aoeblk_ioctl(struct block_device *bdev, fmode_t mode, uint cmd, ulong arg)
+{
+ struct aoedev *d;
+
+ if (!arg)
+ return -EINVAL;
+
+ d = bdev->bd_disk->private_data;
+ if ((d->flags & DEVFL_UP) == 0) {
+ pr_err("aoe: disk not up\n");
+ return -ENODEV;
+ }
+
+ if (cmd == HDIO_GET_IDENTITY) {
+ if (!copy_to_user((void __user *) arg, &d->ident,
+ sizeof(d->ident)))
+ return 0;
+ return -EFAULT;
+ }
+
+ /* udev calls scsi_id, which uses SG_IO, resulting in noise */
+ if (cmd != SG_IO)
+ pr_info("aoe: unknown ioctl 0x%x\n", cmd);
+
+ return -ENOTTY;
+}
+
static const struct block_device_operations aoe_bdops = {
.open = aoeblk_open,
.release = aoeblk_release,
+ .ioctl = aoeblk_ioctl,
.getgeo = aoeblk_getgeo,
.owner = THIS_MODULE,
};
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index 3ce01f6..c4ff70b 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -799,6 +799,17 @@ aoecmd_sleepwork(struct work_struct *work)
}
static void
+ata_ident_fixstring(u16 *id, int ns)
+{
+ u16 s;
+
+ while (ns-- > 0) {
+ s = *id;
+ *id++ = s >> 8 | s << 8;
+ }
+}
+
+static void
ataid_complete(struct aoedev *d, struct aoetgt *t, unsigned char *id)
{
u64 ssize;
@@ -833,6 +844,11 @@ ataid_complete(struct aoedev *d, struct aoetgt *t, unsigned char *id)
d->geo.sectors = get_unaligned_le16(&id[56 << 1]);
}
+ ata_ident_fixstring((u16 *) &id[10<<1], 10); /* serial */
+ ata_ident_fixstring((u16 *) &id[23<<1], 4); /* firmware */
+ ata_ident_fixstring((u16 *) &id[27<<1], 20); /* model */
+ memcpy(d->ident, id, sizeof(d->ident));
+
if (d->ssize != ssize)
printk(KERN_INFO
"aoe: %pm e%ld.%d v%04x has %llu sectors\n",
--
1.7.1
next prev parent reply other threads:[~2012-11-09 0:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-09 0:14 [PATCH 0/8] aoe: improved network congestion handling from v60 to v64+ Ed Cashin, Ed Cashin
2012-11-09 0:17 ` [PATCH 1/8] aoe: avoid running request handler on plugged queue Ed Cashin, Ed Cashin
2012-11-09 7:31 ` Jens Axboe
2012-11-09 0:19 ` Ed Cashin, Ed Cashin [this message]
2012-11-09 0:21 ` [PATCH 3/8] aoe: improve network congestion handling Ed Cashin, Ed Cashin
2012-11-09 0:23 ` [PATCH 4/8] aoe: err device: include MAC addresses for unexpected responses Ed Cashin, Ed Cashin
2012-11-09 0:25 ` [PATCH 5/8] aoe: manipulate aoedev network stats under lock Ed Cashin, Ed Cashin
2012-11-09 0:27 ` [PATCH 6/8] aoe: use high-resolution RTTs with fallback to low-res Ed Cashin, Ed Cashin
2012-11-09 0:29 ` [PATCH 7/8] aoe: commands in retransmit queue use new destination on failure Ed Cashin, Ed Cashin
2012-11-09 0:31 ` [PATCH 8/8] aoe: update driver-internal version to 64+ Ed Cashin, Ed Cashin
-- strict thread matches above, loose matches on Subject: below --
2012-11-08 16:29 [PATCH 1/8] aoe: avoid running request handler on plugged queue Ed Cashin, Ed Cashin
2012-11-08 16:32 ` [PATCH 2/8] aoe: provide ATA identify device content to user on request Ed Cashin, Ed Cashin
2012-11-09 0:40 ` Jeff Garzik
2012-11-09 2:10 ` Ed Cashin
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=fe2ec651bfe9d006a81e75c6205a82a4d0e7dda7.1352410985.git.ecashin@coraid.com \
--to=ecashin@coraid.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®