From: Christoph Hellwig <hch@infradead.org>
To: Steven Dake <sdake@mvista.com>
Cc: linux-kernel@vger.kernel.org, greg@kroah.com,
alan@lxorquk.ukuu.org.uk, linux-scsi@vger.kernel.org
Subject: Re: [PATCH] Advanced TCA SCSI/FC disk hotswap driver for kernel 2.5.44
Date: Thu, 24 Oct 2002 01:42:04 +0100 [thread overview]
Message-ID: <20021024014204.A31345@infradead.org> (raw)
In-Reply-To: <3DB7304A.3030903@mvista.com>; from sdake@mvista.com on Wed, Oct 23, 2002 at 04:27:06PM -0700
On Wed, Oct 23, 2002 at 04:27:06PM -0700, Steven Dake wrote:
> lkml,
>
> Attached is an update of the Advanced TCA disk hotswap driver to provide
> disk hotswap
> support for the Linux Kernel 2.5.43. Hotswap targets include both SCSI
> and FibreChannel.
> Note this support is generic in that it will work in a typical PC system
> with SCSI or
> FibreChannel disks.
Thanks a lot for doing the work. There are still some issues to sort
out, but I guess we'll be able to finish getting it integrated into
the tree.
Btw, please Cc linux-scsi@vger.kernel.org for scsi-related patches.
> linux-2.5.44-scsi-hotswap/drivers/scsi/hosts.c
> --- linux-2.5.44-qla/drivers/scsi/hosts.c Fri Oct 18 21:01:09 2002
> +++ linux-2.5.44-scsi-hotswap/drivers/scsi/hosts.c Wed Oct 23
> 15:35:30 2002
> @@ -371,6 +371,7 @@
> scsi_hosts_registered++;
>
> spin_lock_init(&shost->default_lock);
> + spin_lock_init(&shost->host_queue_lock);
> scsi_assign_lock(shost, &shost->default_lock);
> atomic_set(&shost->host_active,0);
I think your mailer mangles the patch a bit, I'm pretty sure that
code uses one tab indentation. Please make sure that you use
that indentation in new code (if you editor gets it wrong all
the time just run the source through unexpand(1))
> int (* bios_param)(Disk *, struct block_device *, int []);
>
> +#ifdef CONFIG_SCSIFCHOTSWAP
> + /*
> + * Used to determine the id to send the inquiry command to during
> + * hot additions of FibreChannel targets
> + */
> + int (*get_scsi_info_from_wwn)(int mode, unsigned long long wwn, int
> *host, int *channel, int *lun, int *id);
> +#endif
Please make this method unconditional - even if we don't call it without
your option set, the drivers are cluttered up much less this way.
> @@ -0,0 +1,1334 @@
> +/*
> + * hotswap.c
> + *
> + * SCSI/FibreChannel Hotswap kernel implementaton
> + * + * Author: MontaVista Software, Inc.
Is this + * intentional or a cut & paste error? :)
> *buf)
> +{
> + buf->f_type = SCSI_HOTSWAP_MAGIC;
> + buf->f_bsize = PAGE_CACHE_SIZE;
> + buf->f_namelen = 255;
> + return (0);
> +}
Please take a look at fs/libfs.c. For most of your filesystem
methods you can just use the simple_* functions there.
> +static int scsi_hotswap_mkdir (struct inode *dir, struct dentry *dentry,
> + int mode)
> +{
> + return (scsi_hotswap_mknod (dir, dentry, mode | S_IFDIR, 0));
Small codingstyle issue, this should be:
return scsi_hotswap_mknod(dir, dentry, mode | S_IFDIR, 0);
Btw, have you read Documentation/CodingStyle in the kernel tree?
> +
> +static ssize_t default_read_file (struct file *file, char *buf, size_t
> count,
> + loff_t *ppos)
> +{
> + return (0);
> +}
> +
> +static ssize_t default_write_file (struct file *file, const char *buf,
> + size_t count, loff_t *ppos)
> +{
> + return (count);
> +}
If you don't need read/write just don't set those methods in
the operation vector - the kernel can cope with that.
> +
> +static loff_t default_file_lseek (struct file *file, loff_t offset, int
> orig)
> +{
> + loff_t retval = -EINVAL;
> +
> + switch(orig) {
> + case 0:
> + if (offset > 0) {
> + file->f_pos = offset;
> + retval = file->f_pos;
> + }
> + break;
> + case 1:
> + if ((offset + file->f_pos) > 0) {
> + file->f_pos += offset;
> + retval = file->f_pos;
> + }
> + break;
> + default:
> + break;
> + }
> +
> + return (retval);
> +}
This isn't different from default_llseek (except of missing locking),
just don't implement ->llseek, the VFS will take care of you.
> +
> +static int default_open (struct inode *inode, struct file *filp)
> +{
> + if (inode->u.generic_ip) {
> + filp->private_data = inode->u.generic_ip;
> + }
> + return (0);
> +}
You don't seem to actually use file->private_data. Unless I'm
wrong you don't have to implement ->open at all.
> +
> +static int default_sync_file (struct file *file, struct dentry *dentry,
> + int datasync)
> +{
> + return (0);
> +}
Again, no need to implement a noop ->fsync, VFS deals with it not beeing
implemented.
> +static struct file_operations default_file_operations = {
> + read: default_read_file,
> + write: default_write_file,
> + open: default_open,
> + llseek: default_file_lseek,
> + fsync: default_sync_file,
> + mmap: generic_file_mmap,
> +};
Please use C99 struct-initializers, i.e.
static struct file_operations default_file_operations = {
.mmap = generic_file_mmap,
};
> + * scsi_hotswap_insert_by_scsi_id file operations structure
> + */
> +static ssize_t scsi_hotswap_insert_by_scsi_id_read_file (struct file
> *file,
> + char *buf, size_t count, loff_t *offset);
> +static ssize_t scsi_hotswap_insert_by_scsi_id_write_file (struct file
> *file,
> + const char *buf, size_t count, loff_t *ppos);
Looks like this wants a bit nicer line-wrapping (or shorter function
names :))
<lots of file_operations snipped)
Mayb you can put a switch into ->read/->write instead of having
many different file operations?
> +/*
> + * Core file read/write operations interfaces
> + */
> +static char scsi_hotswap_insert_by_scsi_id_usage[] = {
> + "Usage: echo \"[host] [channel] [lun] [id]\" > insert_by_scsi_id\n"
> +};
I don't think the kernel should supply usage information.
> +/*
> + * Core Interface Implementation
> + * Note these are exported to the global symbol table for
> + * other subsystems to use such as a scsi processor or 1394
> + */
> +int scsi_hotswap_insert_by_scsi_id (unsigned int host, unsigned int
> channel,
> + unsigned int lun, unsigned int id)
> +{
> + struct Scsi_Host *scsi_host;
> + Scsi_Device *scsi_device;
> +
> + for (scsi_host = scsi_host_get_next (NULL); scsi_host;
> + scsi_host = scsi_host_get_next (scsi_host)) {
> + if (scsi_host->host_no == host) {
> + break;
> + }
> + }
> + if (scsi_host == 0) {
> + return (-ENXIO);
> + }
> +
> + spin_lock (&scsi_host->host_queue_lock);
> +
> + /*
> + * Determine if device already attached
> + */
> + for (scsi_device = scsi_host->host_queue; scsi_device; scsi_device
> = scsi_device->next) {
> + if ((scsi_device->channel == channel
> + && scsi_device->id == id
> + && scsi_device->lun == lun)) {
> + break;
> + }
> + }
> +
> + spin_unlock (&scsi_host->host_queue_lock);
> +
> + /*
> + * If scsi_device found in host queue, then device already attached
> + */
> + if (scsi_device) {
> + return (-EEXIST);
> + }
> +
> + scan_scsis(scsi_host, 1, channel, id, lun);
> +
> + return (0);
> +}
This seems to be largely copied from proc_scsi_gen_write(). What about
factoring out a common support function? (dito for many of the functions
below)
> diff -uNr linux-2.5.44-qla/drivers/scsi/qla2xxx/qla2x00.c
> linux-2.5.44-scsi-hotswap/drivers/scsi/qla2xxx/qla2x00.c
> --- linux-2.5.44-qla/drivers/scsi/qla2xxx/qla2x00.c Wed Oct 23
Doesn't seem to exist in my tree..
> diff -uNr linux-2.5.44-qla/include/linux/scsi_hotswap.h
> linux-2.5.44-scsi-hotswap/include/linux/scsi_hotswap.h
> --- linux-2.5.44-qla/include/linux/scsi_hotswap.h Wed Dec 31 17:00:00
> 1969
> +++ linux-2.5.44-scsi-hotswap/include/linux/scsi_hotswap.h Wed Oct 23
I think this one should go to include/scsi/ instead, that's where
the other scsi headers live.
next prev parent reply other threads:[~2002-10-24 0:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-23 23:27 [PATCH] Advanced TCA SCSI/FC disk hotswap driver for kernel 2.5.44 Steven Dake
2002-10-24 0:18 ` Greg KH
2002-10-24 0:26 ` Steven Dake
2002-10-24 0:30 ` Greg KH
2002-10-24 16:51 ` Patrick Mochel
2002-10-24 0:27 ` Greg KH
2002-10-24 0:42 ` Christoph Hellwig [this message]
2002-10-24 20:04 ` Steven Dake
[not found] ` <20021024042838.GA30891@codepoet.org>
2002-10-24 18:12 ` Steven Dake
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=20021024014204.A31345@infradead.org \
--to=hch@infradead.org \
--cc=alan@lxorquk.ukuu.org.uk \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=sdake@mvista.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;
as well as URLs for NNTP newsgroup(s).