[PATCH v2 4/8] sg: expand request states

2018-10-20 Thread Douglas Gilbert
Introduce the new sg_rq_state enumerations for tracking the lifetime of a sg_request. SG_RQ_DATA_THRESHOLD is a default value that if the data length of a request exceeds then, after that request is completed, the data buffer will be freed up as the sg_request object is placed on the free list.

[PATCH v2 6/8] sg: complete locking changes on ioctl+debug

2018-10-20 Thread Douglas Gilbert
Complete the locking and structure changes of ioctl and debug ('cat /proc/scsi/sg/debug') handling. Signed-off-by: Douglas Gilbert --- This was the code that was "#if 0'-ed out 2 patches ago. It also shuts checkpatch.pl up as it doesn't like that technique but offers no viable substitute.

[PATCH v2 0/8] sg: major cleanup, remove max_queue limit

2018-10-20 Thread Douglas Gilbert
The intention is to add two new ioctls as proposed by Linus Torvalds: SG_IOSUBMIT and SG_IORECEIVE to replace the write()/read() async interface. But first, clean up the driver and remove the SG_MAX_QUEUE limit of no more than 16 queued commands on a file descriptor at a time. A free list has

[PATCH v2 2/8] sg: introduce sg_log macro

2018-10-20 Thread Douglas Gilbert
Introduce the SG_LOG macro to replace long-winded 'SCSI_LOG_TIMEOUT(3, sg_printk ...' debug messages. Use __func__ wherever appropriate to make the debug messages more portable. Signed-off-by: Douglas Gilbert --- drivers/scsi/sg.c | 162 +- 1 file

[PATCH v2 3/8] sg: split header, expand and correct descriptions

2018-10-20 Thread Douglas Gilbert
Split scsi/sg.h into a smaller scsi/sg.h which includes a new header: uapi/scsi/sg.h . Overall expand the twin header files with new functionality in this patchset and functionality to be added in the next patchset to implement SG_IOSUBMIT and friends. Adjust format to modern kernel conventions.

[PATCH v2 7/8] sg: rework ioctl handling

2018-10-20 Thread Douglas Gilbert
Rework ioctl handling, report clearly to the log which ioctl has been invoked. Add a new "IOWR" ioctl: SG_SET_GET_EXTENDED which permits several integer and boolean values to be "_SET_" (i.e. passed into the driver, potentially changing its actions) and/or read from the driver (the "_GET_" part)

[PATCH v2 8/8] sg: user controls for q_at_head, read_value

2018-10-20 Thread Douglas Gilbert
= 30901;/* 2 digits for each component */ #ifdef CONFIG_SCSI_PROC_FS #include -static char *sg_version_date = "20181019"; +static char *sg_version_date = "20181020"; static int sg_proc_init(void); #endif @@ -95,6 +95,10 @@ enum sg_rq_state { #define SG_DEF_TIME_

[PATCH v2 5/8] sg: add free list, rework locking

2018-10-20 Thread Douglas Gilbert
Remove fixed 16 sg_request object array and replace with an active rq_list plus a request free list. Add finer grained spin lock to sg_request and do a major rework on locking. sg_request objects now are only de-allocated when the owning file descriptor is closed. This simplifies locking issues.

[PATCH v2 1/8] sg: types and naming cleanup

2018-10-20 Thread Douglas Gilbert
Remove typedefs and use better type names like bool and u8 where appropriate. Rename some variables and functions for clarity. Adjust formatting (e.g. function definitions) to be more consistent across the driver. Signed-off-by: Douglas Gilbert --- The intention is to move to sg_version_num

Re: [PATCH 3/3] scsi: myrs: prevent negatives in disable_enclosure_messages_store()

2018-10-20 Thread Dan Carpenter
On Fri, Oct 19, 2018 at 12:19:09PM +0300, Dan Carpenter wrote: > We only want the value to be zero or one. > > It's not a big deal, but say we passed set value to INT_MIN, then > disable_enclosure_messages_show() would return that 12 bytes of "buf" > are initialized but actually only 3 are. I