Re: 4.15.14 crash with iscsi target and dvd

2018-04-14 Thread Wakko Warner
Ming Lei wrote:
> On Thu, Apr 12, 2018 at 09:43:02PM -0400, Wakko Warner wrote:
> > Ming Lei wrote:
> > > On Tue, Apr 10, 2018 at 08:45:25PM -0400, Wakko Warner wrote:
> > > > Sorry for the delay.  I reverted my change, added this one.  I didn't
> > > > reboot, I just unloaded and loaded this one.
> > > > Note: /dev/sr1 as seen from the initiator is /dev/sr0 (physical disc) 
> > > > on the
> > > > target.
> > > > 
> > > > Doesn't crash, however on the initiator I see this:
> > > > [9273849.70] ISO 9660 Extensions: RRIP_1991A
> > > > [9273863.359718] scsi_io_completion: 13 callbacks suppressed
> > > > [9273863.359788] sr 26:0:0:0: [sr1] tag#1 UNKNOWN(0x2003) Result: 
> > > > hostbyte=0x00 driverbyte=0x08
> > > > [9273863.359909] sr 26:0:0:0: [sr1] tag#1 Sense Key : 0x2 [current] 
> > > > [9273863.359974] sr 26:0:0:0: [sr1] tag#1 ASC=0x8 ASCQ=0x0 
> > > > [9273863.360036] sr 26:0:0:0: [sr1] tag#1 CDB: opcode=0x28 28 00 00 22 
> > > > f6 96 00 00 80 00
> > > > [9273863.360116] blk_update_request: 13 callbacks suppressed
> > > > [9273863.360177] blk_update_request: I/O error, dev sr1, sector 9165400
> > > > [9273875.864648] sr 26:0:0:0: [sr1] tag#1 UNKNOWN(0x2003) Result: 
> > > > hostbyte=0x00 driverbyte=0x08
> > > > [9273875.864738] sr 26:0:0:0: [sr1] tag#1 Sense Key : 0x2 [current] 
> > > > [9273875.864801] sr 26:0:0:0: [sr1] tag#1 ASC=0x8 ASCQ=0x0 
> > > > [9273875.864890] sr 26:0:0:0: [sr1] tag#1 CDB: opcode=0x28 28 00 00 22 
> > > > f7 16 00 00 80 00
> > > > [9273875.864971] blk_update_request: I/O error, dev sr1, sector 9165912
> > > > 
> > > > To cause this, I mounted the dvd as seen in the first line and ran this
> > > > command: find /cdrom2 -type f | xargs -tn1 cat > /dev/null
> > > > I did some various tests.  Each test was done after umount and mount to
> > > > clear the cache.
> > > > cat  > /dev/null causes the message.
> > > > dd if= of=/dev/null bs=2048 doesn't
> > > > using bs=4096 doesn't
> > > > using bs=64k doesn't
> > > > using bs=128k does
> > > > cat uses a blocksize of 128k.
> > > > 
> > > > The following was done without being mounted.
> > > > ddrescue -f -f /dev/sr1 /dev/null 
> > > > doesn't cause the message
> > > > dd if=/dev/sr1 of=/dev/null bs=128k
> > > > doesn't cause the message
> > > > using bs=256k causes the message once:
> > > > [9275916.857409] sr 27:0:0:0: [sr1] tag#0 UNKNOWN(0x2003) Result: 
> > > > hostbyte=0x00 driverbyte=0x08
> > > > [9275916.857482] sr 27:0:0:0: [sr1] tag#0 Sense Key : 0x2 [current] 
> > > > [9275916.857520] sr 27:0:0:0: [sr1] tag#0 ASC=0x8 ASCQ=0x0 
> > > > [9275916.857556] sr 27:0:0:0: [sr1] tag#0 CDB: opcode=0x28 28 00 00 00 
> > > > 00 00 00 00 80 00
> > > > [9275916.857614] blk_update_request: I/O error, dev sr1, sector 0
> > > > 
> > > > If I access the disc from the target natively either by mounting and
> > > > accessing files or working with the device directly (ie dd) no errors 
> > > > are
> > > > logged on the target.
> > > 
> > > OK, thanks for your test.
> > > 
> > > Could you test the following patch and see if there is still the failure
> > > message?
> > > 
> > > diff --git a/drivers/target/target_core_pscsi.c 
> > > b/drivers/target/target_core_pscsi.c
> > > index 0d99b242e82e..6137287b52fb 100644
> > > --- a/drivers/target/target_core_pscsi.c
> > > +++ b/drivers/target/target_core_pscsi.c
> > > @@ -913,9 +913,11 @@ pscsi_map_sg(struct se_cmd *cmd, struct scatterlist 
> > > *sgl, u32 sgl_nents,
> > >  
> > >   rc = bio_add_pc_page(pdv->pdv_sd->request_queue,
> > >   bio, page, bytes, off);
> > > + if (rc != bytes)
> > > + goto fail;
> > >   pr_debug("PSCSI: bio->bi_vcnt: %d nr_vecs: %d\n",
> > >   bio_segments(bio), nr_vecs);
> > > - if (rc != bytes) {
> > > + if (/*rc != bytes*/0) {
> > >   pr_debug("PSCSI: Reached bio->bi_vcnt max:"
> > >   " %d i: %d bio: %p, allocating another"
> > >   " bio\n", bio->bi_vcnt, i, bio);
> > 
> > Target doesn't crash but the errors on the initiator are still there.
> 
> OK, then this error log isn't related with my commit, because the patch
> I sent to you in last email is to revert my commit simply.
> 
> But the following patch is one correct fix for your crash.
> 
> https://marc.info/?l=linux-kernel=152331690727052=2

Ok, that'll be the one I used.  Do you know when it'll go upstream?

-- 
 Microsoft has beaten Volkswagen's world record.  Volkswagen only created 22
 million bugs.


Re: [PATCH] scsi: Change return type to vm_fault_t

2018-04-14 Thread Douglas Gilbert

On 2018-04-14 02:47 PM, Souptick Joarder wrote:

Use new return type vm_fault_t for fault handler
in struct vm_operations_struct.

Signed-off-by: Souptick Joarder 
Reviewed-by: Matthew Wilcox 


Acked-by: Douglas Gilbert 


---
  drivers/scsi/sg.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index c198b963..c2b7d34 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1192,7 +1192,7 @@ static long sg_compat_ioctl(struct file *filp, unsigned 
int cmd_in, unsigned lon
return fasync_helper(fd, filp, mode, >async_qp);
  }

-static int
+static vm_fault_t
  sg_vma_fault(struct vm_fault *vmf)
  {
struct vm_area_struct *vma = vmf->vma;
--
1.9.1






[PATCH] target: Change return type to vm_fault_t

2018-04-14 Thread Souptick Joarder
Use new return type vm_fault_t for fault handler
in struct vm_operations_struct.

Signed-off-by: Souptick Joarder 
Reviewed-by: Matthew Wilcox 
---
 drivers/target/target_core_user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/target/target_core_user.c 
b/drivers/target/target_core_user.c
index 4ad89ea..d6af292 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -1382,7 +1382,7 @@ static struct page *tcmu_try_get_block_page(struct 
tcmu_dev *udev, uint32_t dbi)
return page;
 }

-static int tcmu_vma_fault(struct vm_fault *vmf)
+static vm_fault_t tcmu_vma_fault(struct vm_fault *vmf)
 {
struct tcmu_dev *udev = vmf->vma->vm_private_data;
struct uio_info *info = >uio_info;
--
1.9.1



[PATCH] scsi: Change return type to vm_fault_t

2018-04-14 Thread Souptick Joarder
Use new return type vm_fault_t for fault handler
in struct vm_operations_struct.

Signed-off-by: Souptick Joarder 
Reviewed-by: Matthew Wilcox 
---
 drivers/scsi/sg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index c198b963..c2b7d34 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1192,7 +1192,7 @@ static long sg_compat_ioctl(struct file *filp, unsigned 
int cmd_in, unsigned lon
return fasync_helper(fd, filp, mode, >async_qp);
 }

-static int
+static vm_fault_t
 sg_vma_fault(struct vm_fault *vmf)
 {
struct vm_area_struct *vma = vmf->vma;
--
1.9.1



[PATCH v3 3/4] target: target_core_user.[ch]: convert comments into DOC:

2018-04-14 Thread Randy Dunlap
From: Randy Dunlap 

Make documentation on target-supported userspace-I/O design be
usable by kernel-doc by using "DOC:". This is used in the driver-api
Documentation chapter.

Signed-off-by: Randy Dunlap 
To: "Nicholas A. Bellinger" 
Cc: linux-scsi@vger.kernel.org
Cc: target-de...@vger.kernel.org
Cc: linux-...@vger.kernel.org
Cc: "James E.J. Bottomley" 
Cc: "Martin K. Petersen" 
Cc: Jonathan Corbet 
---
 drivers/target/target_core_user.c |8 ++--
 include/uapi/linux/target_core_user.h |   11 ++-
 2 files changed, 12 insertions(+), 7 deletions(-)

--- linux-next-20180413.orig/drivers/target/target_core_user.c
+++ linux-next-20180413/drivers/target/target_core_user.c
@@ -42,7 +42,11 @@
 
 #include 
 
-/*
+/**
+ * DOC: Userspace I/O
+ * Userspace I/O
+ * -
+ *
  * Define a shared-memory interface for LIO to pass SCSI commands and
  * data to userspace for processing. This is to allow backends that
  * are too complex for in-kernel support to be possible.
@@ -53,7 +57,7 @@
  * See the .h file for how the ring is laid out. Note that while the
  * command ring is defined, the particulars of the data area are
  * not. Offset values in the command entry point to other locations
- * internal to the mmap()ed area. There is separate space outside the
+ * internal to the mmap-ed area. There is separate space outside the
  * command ring for data buffers. This leaves maximum flexibility for
  * moving buffer allocations, or even page flipping or other
  * allocation techniques, without altering the command ring layout.
--- linux-next-20180413.orig/include/uapi/linux/target_core_user.h
+++ linux-next-20180413/include/uapi/linux/target_core_user.h
@@ -9,21 +9,22 @@
 
 #define TCMU_VERSION "2.0"
 
-/*
+/**
+ * DOC: Ring Design
  * Ring Design
  * ---
  *
  * The mmaped area is divided into three parts:
- * 1) The mailbox (struct tcmu_mailbox, below)
- * 2) The command ring
- * 3) Everything beyond the command ring (data)
+ * 1) The mailbox (struct tcmu_mailbox, below);
+ * 2) The command ring;
+ * 3) Everything beyond the command ring (data).
  *
  * The mailbox tells userspace the offset of the command ring from the
  * start of the shared memory region, and how big the command ring is.
  *
  * The kernel passes SCSI commands to userspace by putting a struct
  * tcmu_cmd_entry in the ring, updating mailbox->cmd_head, and poking
- * userspace via uio's interrupt mechanism.
+ * userspace via UIO's interrupt mechanism.
  *
  * tcmu_cmd_entry contains a header. If the header type is PAD,
  * userspace should skip hdr->length bytes (mod cmdr_size) to find the


[PATCH v3 4/4] target: add driver-api document

2018-04-14 Thread Randy Dunlap
From: Randy Dunlap 

Add a driver-api document for target/iSCSI interfaces.

Signed-off-by: Randy Dunlap 
To: "Nicholas A. Bellinger" 
Cc: linux-scsi@vger.kernel.org
Cc: target-de...@vger.kernel.org
Cc: linux-...@vger.kernel.org
Cc: "James E.J. Bottomley" 
Cc: "Martin K. Petersen" 
Cc: Jonathan Corbet 
---
 Documentation/driver-api/index.rst  |1 
 Documentation/driver-api/scsi.rst   |2 
 Documentation/driver-api/target.rst |   64 ++
 3 files changed, 66 insertions(+), 1 deletion(-)

--- linux-next-20180413.orig/Documentation/driver-api/index.rst
+++ linux-next-20180413/Documentation/driver-api/index.rst
@@ -34,6 +34,7 @@ available subsections can be seen below.
edac
scsi
libata
+   target
mtdnand
miscellaneous
w1
--- linux-next-20180413.orig/Documentation/driver-api/scsi.rst
+++ linux-next-20180413/Documentation/driver-api/scsi.rst
@@ -334,5 +334,5 @@ todo
 
 
 Parallel (fast/wide/ultra) SCSI, USB, SATA, SAS, Fibre Channel,
-FireWire, ATAPI devices, Infiniband, I2O, iSCSI, Parallel ports,
+FireWire, ATAPI devices, Infiniband, I2O, Parallel ports,
 netlink...
--- /dev/null
+++ linux-next-20180413/Documentation/driver-api/target.rst
@@ -0,0 +1,64 @@
+=
+target and iSCSI Interfaces Guide
+=
+
+Introduction and Overview
+=
+
+TBD
+
+Target core device interfaces
+=
+
+.. kernel-doc:: drivers/target/target_core_device.c
+:export:
+
+Target core transport interfaces
+
+
+.. kernel-doc:: drivers/target/target_core_transport.c
+:export:
+
+Target-supported userspace I/O
+==
+
+.. kernel-doc:: drivers/target/target_core_user.c
+:doc: Userspace I/O
+
+.. kernel-doc:: include/uapi/linux/target_core_user.h
+:doc: Ring Design
+
+iSCSI helper functions
+==
+
+.. kernel-doc:: drivers/scsi/libiscsi.c
+   :export:
+
+
+iSCSI boot information
+==
+
+.. kernel-doc:: drivers/scsi/iscsi_boot_sysfs.c
+   :export:
+
+
+iSCSI transport class
+=
+
+The file drivers/scsi/scsi_transport_iscsi.c defines transport
+attributes for the iSCSI class, which sends SCSI packets over TCP/IP
+connections.
+
+.. kernel-doc:: drivers/scsi/scsi_transport_iscsi.c
+   :export:
+
+
+iSCSI TCP interfaces
+
+
+.. kernel-doc:: drivers/scsi/iscsi_tcp.c
+   :internal:
+
+.. kernel-doc:: drivers/scsi/libiscsi_tcp.c
+   :export:
+


target: clean up kernel-doc and add driver-api document

2018-04-14 Thread Randy Dunlap
From: Randy Dunlap 

This patch series fixes kernel-doc warnings in drivers/target/ and
its header files, then adds a Documentation driver-api chapter for
target driver interfaces.


[PATCH v3 1/4] target: target_core_transport.c: fix kernel-doc warnings
[PATCH v3 2/4] target: target_core_transport.c: enable+fix kernel-doc
[PATCH v3 3/4] target: target_core_user.[ch]: convert comments into DOC:
[PATCH v3 4/4] target: add driver-api document


 Documentation/driver-api/index.rst |1 
 Documentation/driver-api/scsi.rst  |2 
 Documentation/driver-api/target.rst|   64 +++
 drivers/target/target_core_transport.c |   19 +++---
 drivers/target/target_core_user.c  |8 ++
 include/uapi/linux/target_core_user.h  |   11 ++-
 6 files changed, 89 insertions(+), 16 deletions(-)


[PATCH v3 2/4] target: target_core_transport.c: enable+fix kernel-doc

2018-04-14 Thread Randy Dunlap
From: Randy Dunlap 

For exported functions that already have near-kernel-doc notation,
fix them to begin with "/**" and make a few corrections so that they
don't have any kernel-doc warnings.

Signed-off-by: Randy Dunlap 
To: "Nicholas A. Bellinger" 
Cc: linux-scsi@vger.kernel.org
Cc: target-de...@vger.kernel.org
Cc: linux-...@vger.kernel.org
Cc: "James E.J. Bottomley" 
Cc: "Martin K. Petersen" 
Cc: Jonathan Corbet 
---
 drivers/target/target_core_transport.c |   17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

--- linux-next-20180413.orig/drivers/target/target_core_transport.c
+++ linux-next-20180413/drivers/target/target_core_transport.c
@@ -1431,7 +1431,7 @@ transport_generic_map_mem_to_cmd(struct
return 0;
 }
 
-/*
+/**
  * target_submit_cmd_map_sgls - lookup unpacked lun and submit uninitialized
  *  se_cmd + use pre-allocated SGL memory.
  *
@@ -1441,7 +1441,7 @@ transport_generic_map_mem_to_cmd(struct
  * @sense: pointer to SCSI sense buffer
  * @unpacked_lun: unpacked LUN to reference for struct se_lun
  * @data_length: fabric expected data transfer length
- * @task_addr: SAM task attribute
+ * @task_attr: SAM task attribute
  * @data_dir: DMA data direction
  * @flags: flags for command submission from target_sc_flags_tables
  * @sgl: struct scatterlist memory for unidirectional mapping
@@ -1578,7 +1578,7 @@ int target_submit_cmd_map_sgls(struct se
 }
 EXPORT_SYMBOL(target_submit_cmd_map_sgls);
 
-/*
+/**
  * target_submit_cmd - lookup unpacked lun and submit uninitialized se_cmd
  *
  * @se_cmd: command descriptor to submit
@@ -1587,7 +1587,7 @@ EXPORT_SYMBOL(target_submit_cmd_map_sgls
  * @sense: pointer to SCSI sense buffer
  * @unpacked_lun: unpacked LUN to reference for struct se_lun
  * @data_length: fabric expected data transfer length
- * @task_addr: SAM task attribute
+ * @task_attr: SAM task attribute
  * @data_dir: DMA data direction
  * @flags: flags for command submission from target_sc_flags_tables
  *
@@ -2606,7 +2606,8 @@ int transport_generic_free_cmd(struct se
 }
 EXPORT_SYMBOL(transport_generic_free_cmd);
 
-/* target_get_sess_cmd - Add command to active ->sess_cmd_list
+/**
+ * target_get_sess_cmd - Add command to active ->sess_cmd_list
  * @se_cmd:command descriptor to add
  * @ack_kref:  Signal that fabric will perform an ack target_put_sess_cmd()
  */
@@ -2800,7 +2801,8 @@ void target_show_cmd(const char *pfx, st
 }
 EXPORT_SYMBOL(target_show_cmd);
 
-/* target_sess_cmd_list_set_waiting - Flag all commands in
+/**
+ * target_sess_cmd_list_set_waiting - Flag all commands in
  * sess_cmd_list to complete cmd_wait_comp.  Set
  * sess_tearing_down so no more commands are queued.
  * @se_sess:   session to flag
@@ -2835,7 +2837,8 @@ void target_sess_cmd_list_set_waiting(st
 }
 EXPORT_SYMBOL(target_sess_cmd_list_set_waiting);
 
-/* target_wait_for_sess_cmds - Wait for outstanding descriptors
+/**
+ * target_wait_for_sess_cmds - Wait for outstanding descriptors
  * @se_sess:session to wait for active I/O
  */
 void target_wait_for_sess_cmds(struct se_session *se_sess)


[PATCH v3 1/4] target: target_core_transport.c: fix kernel-doc warnings

2018-04-14 Thread Randy Dunlap
From: Randy Dunlap 

Correct a function parameter's name to eliminate kernel-doc warnings
in drivers/target/target_core_transport.c.

Fixes these kernel-doc warnings: (tested by adding these files to a new
target.rst documentation file)

../drivers/target/target_core_transport.c:1671: warning: No description found 
for parameter 'fabric_tmr_ptr'
../drivers/target/target_core_transport.c:1671: warning: Excess function 
parameter 'fabric_context' description in 'target_submit_tmr'

Signed-off-by: Randy Dunlap 
To: "Nicholas A. Bellinger" 
Cc: linux-scsi@vger.kernel.org
Cc: target-de...@vger.kernel.org
Cc: linux-...@vger.kernel.org
Cc: "James E.J. Bottomley" 
Cc: "Martin K. Petersen" 
Cc: Jonathan Corbet 
---
 drivers/target/target_core_transport.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- linux-next-20180413.orig/drivers/target/target_core_transport.c
+++ linux-next-20180413/drivers/target/target_core_transport.c
@@ -1654,7 +1654,7 @@ static bool target_lookup_lun_from_tag(s
  * @se_sess: associated se_sess for endpoint
  * @sense: pointer to SCSI sense buffer
  * @unpacked_lun: unpacked LUN to reference for struct se_lun
- * @fabric_context: fabric context for TMR req
+ * @fabric_tmr_ptr: fabric context for TMR req
  * @tm_type: Type of TM request
  * @gfp: gfp type for caller
  * @tag: referenced task tag for TMR_ABORT_TASK


Re: target documentation patches?

2018-04-14 Thread Randy Dunlap
On 02/22/2018 04:38 PM, Randy Dunlap wrote:
> Hi Nicholas,
> 
> I posted several patches for target documentation cleanups and adding
> a chapter to the driver-api chapter back in December.
> 
> Do I need to repost those?  Do you want someone else to merge them, even
> though several of them are in drivers/target/ ?


[no response in 7 weeks]
[adding linux-doc list]


I have a new 4-patch series for target kernel-doc fixes and adding
Documentation/driver-api/target.rst.  However, I am wondering who will
merge the series.

I'll post the series to target-devel, linux-scsi, and linux-doc.
Hopefully one of the maintainers there will apply them.


thanks,
-- 
~Randy