mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeff Garzik <jgarzik@pobox.com>
To: Ed Cashin <ecashin@coraid.com>
Cc: Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/8] aoe: provide ATA identify device content to user on request
Date: Thu, 08 Nov 2012 19:40:48 -0500	[thread overview]
Message-ID: <509C5110.5090809@pobox.com> (raw)
In-Reply-To: <9a089f76a8e21e64c89556d155833bcb286e48be.1352316179.git.ecashin@coraid.com>

On 11/08/2012 11:32 AM, Ed Cashin wrote:
> This patch makes the aoe driver follow expected behavior when
> the user uses ioctl to get the ATA device identify information.
>
> 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 */

This duplicates ata_id_string() and/or ata_id_c_string(), does it not?




  reply	other threads:[~2012-11-09  0:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2012-11-09  2:10     ` Ed Cashin
2012-11-08 16:34 ` [PATCH 3/8] aoe: improve network congestion handling Ed Cashin, Ed Cashin
2012-11-08 16:42 ` [PATCH 4/8] aoe: err device: include MAC addresses for unexpected responses Ed Cashin, Ed Cashin
2012-11-08 16:44 ` [PATCH 5/8] aoe: manipulate aoedev network stats under lock Ed Cashin, Ed Cashin
2012-11-08 16:46 ` [PATCH 6/8] aoe: use high-resolution RTTs with fallback to low-res Ed Cashin, Ed Cashin
2012-11-08 16:48 ` [PATCH 7/8] aoe: commands in retransmit queue use new destination on failure Ed Cashin, Ed Cashin
2012-11-08 16:50 ` [PATCH 8/8] aoe: update driver-internal version to 64+ Ed Cashin, Ed Cashin
2012-11-08 19:26 ` [PATCH 1/8] aoe: avoid running request handler on plugged queue Andrew Morton
2012-11-08 19:32   ` Ed Cashin
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:19 ` [PATCH 2/8] aoe: provide ATA identify device content to user on request Ed Cashin, 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=509C5110.5090809@pobox.com \
    --to=jgarzik@pobox.com \
    --cc=akpm@linux-foundation.org \
    --cc=ecashin@coraid.com \
    --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®