All of lore.kernel.org
 help / color / mirror / Atom feed
From: Douglas Gilbert <dgilbert@interlog.com>
To: Hannes Reinecke <hare@suse.de>, linux-scsi@vger.kernel.org
Cc: martin.petersen@oracle.com, jejb@linux.vnet.ibm.com
Subject: Re: [PATCH v7 10/38] sg: improve naming
Date: Fri, 28 Feb 2020 11:25:00 -0500	[thread overview]
Message-ID: <25ae54e4-b2ab-97bf-05c0-323df9610218@interlog.com> (raw)
In-Reply-To: <11e41b41-8569-173a-3ce0-a6013e57f7da@suse.de>

On 2020-02-28 3:27 a.m., Hannes Reinecke wrote:
> On 2/27/20 5:58 PM, Douglas Gilbert wrote:
>> Remove use of typedef sg_io_hdr_t and replace with struct
>> sg_io_hdr. Change some names on driver wide structure fields
>> and comment them. Rename sg_alloc() to sg_add_device_helper()
>> to reflect its current role.
>>
>> Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>
>> ---
>>   drivers/scsi/sg.c | 240 ++++++++++++++++++++++++----------------------
>>   1 file changed, 127 insertions(+), 113 deletions(-)
>>
>> diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
>> index 246c630d3523..eb3b333ea30b 100644
>> --- a/drivers/scsi/sg.c
>> +++ b/drivers/scsi/sg.c
>> @@ -92,7 +92,7 @@ static int sg_allow_dio = SG_ALLOW_DIO_DEF;
>>   static int scatter_elem_sz = SG_SCATTER_SZ;
>>   static int scatter_elem_sz_prev = SG_SCATTER_SZ;
>> -#define SG_SECTOR_SZ 512
>> +#define SG_DEF_SECTOR_SZ 512
>>   static int sg_add_device(struct device *, struct class_interface *);
>>   static void sg_remove_device(struct device *, struct class_interface *);
>> @@ -105,12 +105,13 @@ static struct class_interface sg_interface = {
>>       .remove_dev     = sg_remove_device,
>>   };
>> -struct sg_scatter_hold { /* holding area for scsi scatter gather info */
>> -    u16 k_use_sg; /* Count of kernel scatter-gather pieces */
>> +struct sg_scatter_hold {     /* holding area for scsi scatter gather info */
>> +    struct page **pages;    /* num_sgat element array of struct page* */
>> +    int buflen;        /* capacity in bytes (dlen<=buflen) */
>> +    int dlen;        /* current valid data length of this req */
>> +    u16 page_order;        /* byte_len = (page_size*(2**page_order)) */
>> +    u16 num_sgat;        /* actual number of scatter-gather segments */
>>       unsigned int sglist_len; /* size of malloc'd scatter-gather list ++ */
>> -    unsigned int bufflen;    /* Size of (aggregate) data buffer */
>> -    struct page **pages;
>> -    int page_order;
>>       char dio_in_use;    /* 0->indirect IO (or mmap), 1->dio */
>>       u8 cmd_opcode;        /* first byte of command */
>>   };
> While you're at it, it might be worthwhile to exchange the order of the last two 
> fields.
> Having a 'char' before the 'u8' guarantees either a misaligned structure or 
> implicit padding by the compiler, neither of which is a good thing.

dio_in_use became part of a bitfield and is now gone. I find keeping the
opcode (first byte of the opcode) around very useful for debugging. As for
alignment, we could keep the first 4 bytes of the cdb instead :-)
struct sg_scatter_hold is embedded in struct sg_request so unless there
is another 3 bytes of u8s to put beside cmd_opcode, then there is going
to be padding somewhere.

>> @@ -122,20 +123,20 @@ struct sg_request {    /* SG_MAX_QUEUE requests 
>> outstanding per file */
>>       struct list_head entry;    /* list entry */
>>       struct sg_fd *parentfp;    /* NULL -> not in use */
>>       struct sg_scatter_hold data;    /* hold buffer, perhaps scatter list */
>> -    sg_io_hdr_t header;    /* scsi command+info, see <scsi/sg.h> */
>> +    struct sg_io_hdr header;  /* scsi command+info, see <scsi/sg.h> */
>>       u8 sense_b[SCSI_SENSE_BUFFERSIZE];
>>       char res_used;        /* 1 -> using reserve buffer, 0 -> not ... */
>>       char orphan;        /* 1 -> drop on sight, 0 -> normal */
>>       char sg_io_owned;    /* 1 -> packet belongs to SG_IO */
>>       /* done protected by rq_list_lock */
>>       char done;        /* 0->before bh, 1->before read, 2->read */
> 
> And here a bitfield might be a good idea, as otherwise you might run into 
> alignment / padding issues again ...

They are indeed put in a bitfield in a later patch. Another reviewer has
complained that I tend to "sneak" small changes in that have little to
do with the title of the patch (guilty). Hard to keep everyone happy.

Doug Gilbert

  reply	other threads:[~2020-02-28 16:25 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-27 16:58 [PATCH v7 00/38] sg: add v4 interface Douglas Gilbert
2020-02-27 16:58 ` [PATCH v7 01/38] sg: move functions around Douglas Gilbert
2020-02-27 16:58 ` [PATCH v7 02/38] sg: remove typedefs, type+formatting cleanup Douglas Gilbert
2020-02-27 16:58 ` [PATCH v7 03/38] sg: sg_log and is_enabled Douglas Gilbert
2020-02-27 16:58 ` [PATCH v7 04/38] sg: rework sg_poll(), minor changes Douglas Gilbert
2020-02-27 16:58 ` [PATCH v7 05/38] sg: bitops in sg_device Douglas Gilbert
2020-02-27 16:58 ` [PATCH v7 06/38] sg: make open count an atomic Douglas Gilbert
2020-02-27 16:58 ` [PATCH v7 07/38] sg: move header to uapi section Douglas Gilbert
2020-02-27 16:58 ` [PATCH v7 08/38] sg: speed sg_poll and sg_get_num_waiting Douglas Gilbert
2020-02-27 16:58 ` [PATCH v7 09/38] sg: sg_allow_if_err_recovery and renames Douglas Gilbert
2020-02-27 16:58 ` [PATCH v7 10/38] sg: improve naming Douglas Gilbert
2020-02-28  8:27   ` Hannes Reinecke
2020-02-28 16:25     ` Douglas Gilbert [this message]
2020-02-28 16:37       ` Hannes Reinecke
2020-02-27 16:58 ` [PATCH v7 11/38] sg: change rwlock to spinlock Douglas Gilbert
2020-02-28  8:31   ` Hannes Reinecke
2020-02-28 16:25     ` Douglas Gilbert
2020-02-28 16:38       ` Hannes Reinecke
2020-02-27 16:58 ` [PATCH v7 12/38] sg: ioctl handling Douglas Gilbert
2020-02-28  8:33   ` Hannes Reinecke
2020-02-27 16:58 ` [PATCH v7 13/38] sg: split sg_read Douglas Gilbert
2020-02-28  8:35   ` Hannes Reinecke
2020-02-27 16:58 ` [PATCH v7 14/38] sg: sg_common_write add structure for arguments Douglas Gilbert
2020-02-28  8:36   ` Hannes Reinecke
2020-02-27 16:58 ` [PATCH v7 15/38] sg: rework sg_vma_fault Douglas Gilbert
2020-02-28  8:37   ` Hannes Reinecke
2020-02-27 16:58 ` [PATCH v7 16/38] sg: rework sg_mmap Douglas Gilbert
2020-02-28  8:38   ` Hannes Reinecke
2020-02-27 16:58 ` [PATCH v7 17/38] sg: replace sg_allow_access Douglas Gilbert
2020-02-28  8:40   ` Hannes Reinecke
2020-02-27 16:58 ` [PATCH v7 18/38] sg: rework scatter gather handling Douglas Gilbert
2020-02-28  8:41   ` Hannes Reinecke
2020-02-27 16:58 ` [PATCH v7 19/38] sg: introduce request state machine Douglas Gilbert
2020-02-27 16:58 ` [PATCH v7 20/38] sg: sg_find_srp_by_id Douglas Gilbert
2020-02-28  8:45   ` Hannes Reinecke
2020-02-27 16:58 ` [PATCH v7 21/38] sg: sg_fill_request_element Douglas Gilbert
2020-02-27 16:58 ` [PATCH v7 22/38] sg: printk change %p to %pK Douglas Gilbert
2020-02-28  8:46   ` Hannes Reinecke
2020-02-27 16:58 ` [PATCH v7 23/38] sg: xarray for fds in device Douglas Gilbert
2020-02-28  8:47   ` Hannes Reinecke
2020-02-27 16:58 ` [PATCH v7 24/38] sg: xarray for reqs in fd Douglas Gilbert
2020-02-28  9:00   ` Hannes Reinecke
2020-02-28 18:55     ` Douglas Gilbert
2020-02-29  1:18       ` Douglas Gilbert
2020-02-27 16:58 ` [PATCH v7 25/38] sg: replace rq array with lists Douglas Gilbert
2020-02-28  9:02   ` Hannes Reinecke
2020-02-27 16:58 ` [PATCH v7 26/38] sg: sense buffer rework Douglas Gilbert
2020-02-28  9:04   ` Hannes Reinecke
2020-02-27 16:58 ` [PATCH v7 27/38] sg: add sg v4 interface support Douglas Gilbert
2020-02-28  9:08   ` Hannes Reinecke
2020-02-28 20:20     ` Douglas Gilbert
2020-02-27 16:58 ` [PATCH v7 28/38] sg: rework debug info Douglas Gilbert
2020-02-28  9:14   ` Hannes Reinecke
2020-02-27 16:58 ` [PATCH v7 29/38] sg: add 8 byte SCSI LUN to sg_scsi_id Douglas Gilbert
2020-02-28  9:15   ` Hannes Reinecke
2020-02-28 23:27   ` kbuild test robot
2020-02-28 23:27     ` kbuild test robot
2020-02-27 16:58 ` [PATCH v7 30/38] sg: expand sg_comm_wr_t Douglas Gilbert
2020-02-27 16:58 ` [PATCH v7 31/38] sg: add sg_iosubmit_v3 and sg_ioreceive_v3 ioctls Douglas Gilbert
2020-02-28  9:16   ` Hannes Reinecke
2020-02-27 16:58 ` [PATCH v7 32/38] sg: add some __must_hold macros Douglas Gilbert
2020-02-28  9:16   ` Hannes Reinecke
2020-02-27 16:58 ` [PATCH v7 33/38] sg: move procfs objects to avoid forward decls Douglas Gilbert
2020-02-28  9:17   ` Hannes Reinecke
2020-02-27 16:58 ` [PATCH v7 34/38] sg: protect multiple receivers Douglas Gilbert
2020-02-28  9:18   ` Hannes Reinecke
2020-02-27 16:58 ` [PATCH v7 35/38] sg: first debugfs support Douglas Gilbert
2020-02-28  9:18   ` Hannes Reinecke
2020-02-27 16:59 ` [PATCH v7 36/38] sg: rework mmap support Douglas Gilbert
2020-02-28  9:20   ` Hannes Reinecke
2020-02-27 16:59 ` [PATCH v7 37/38] sg: warn v3 write system call users Douglas Gilbert
2020-02-28  9:20   ` Hannes Reinecke
2020-02-27 16:59 ` [PATCH v7 38/38] sg: bump version to 4.0.08 Douglas Gilbert
2020-02-28  9:21   ` Hannes Reinecke

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=25ae54e4-b2ab-97bf-05c0-323df9610218@interlog.com \
    --to=dgilbert@interlog.com \
    --cc=hare@suse.de \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.