All of lore.kernel.org
 help / color / mirror / Atom feed
From: Douglas Gilbert <dgilbert@interlog.com>
To: linux-scsi@vger.kernel.org
Cc: martin.petersen@oracle.com, jejb@linux.vnet.ibm.com,
	hare@suse.de, dan.carpenter@oracle.com, colin.king@canonical.com
Subject: [PATCH v2 6/6] sg: remove debugging remnants
Date: Wed, 17 Mar 2021 11:27:58 -0400	[thread overview]
Message-ID: <20210317152758.51689-7-dgilbert@interlog.com> (raw)
In-Reply-To: <20210317152758.51689-1-dgilbert@interlog.com>

Remove check whether the sg_request object's xarray mark indicates
that it is 'free' (it shouldn't be in sg_common_write() ). This was
added as part of scattergun debugging to find a problem that was
fixed elsewhere. The associated SG_LOG message has never been seen
in testing.

Likewise the SG_FRQ_BLK_PUT_REQ bit in the sg_request::frq_bm
bitmask was part of debugging.

Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>
---
 drivers/scsi/sg.c | 42 ++++++++++++------------------------------
 1 file changed, 12 insertions(+), 30 deletions(-)

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index f59ddf809f21..f36a6a262774 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -115,10 +115,9 @@ enum sg_rq_state {	/* N.B. sg_rq_state_arr assumes SG_RS_AWAIT_RCV==2 */
 #define SG_FRQ_NO_US_XFER	3	/* no user space transfer of data */
 #define SG_FRQ_DEACT_ORPHAN	6	/* not keeping orphan so de-activate */
 #define SG_FRQ_RECEIVING	7	/* guard against multiple receivers */
-#define SG_FRQ_BLK_PUT_REQ	8	/* set when blk_put_request() called */
-#define SG_FRQ_FOR_MMAP		9	/* request needs PAGE_SIZE elements */
-#define SG_FRQ_COUNT_ACTIVE	10	/* sfp->submitted + waiting active */
-#define SG_FRQ_ISSUED		11	/* blk_execute_rq_nowait() finished */
+#define SG_FRQ_FOR_MMAP		8	/* request needs PAGE_SIZE elements */
+#define SG_FRQ_COUNT_ACTIVE	9	/* sfp->submitted + waiting active */
+#define SG_FRQ_ISSUED		10	/* blk_execute_rq_nowait() finished */
 
 /* Bit positions (flags) for sg_fd::ffd_bm bitmask follow */
 #define SG_FFD_FORCE_PACKID	0	/* receive only given pack_id/tag */
@@ -1118,15 +1117,6 @@ sg_common_write(struct sg_comm_wr_t *cwrp)
 		goto err_out;
  	}
 
-	if (unlikely(test_bit(SG_FRQ_BLK_PUT_REQ, srp->frq_bm) || !srp->rqq)) {
-		res = -EIDRM;	/* this failure unexpected but observed */
-		goto err_out;
-	}
-	if (xa_get_mark(&fp->srp_arr, srp->rq_idx, SG_XA_RQ_FREE)) {
-		SG_LOG(1, fp, "%s: ahhh, request erased!!!\n", __func__);
-		res = -ENODEV;
-		goto err_out;
-	}
 	srp->rqq->timeout = cwrp->timeout;
 	sg_execute_cmd(fp, srp);
 	return srp;
@@ -2562,10 +2552,6 @@ sg_rq_end_io(struct request *rq, blk_status_t status)
 	struct sg_fd *sfp;
 
 	/* Expect 0 --> 1 transition, otherwise processed elsewhere */
-	if (unlikely(test_and_set_bit(SG_FRQ_BLK_PUT_REQ, srp->frq_bm))) {
-		pr_info("%s: srp=%pK already completed\n", __func__, srp);
-		return;
-	}
 	sfp = srp->parentfp;
 	sdp = sfp->parentdp;
 
@@ -3181,11 +3167,8 @@ sg_start_req(struct sg_request *srp, struct sg_comm_wr_t *cwrp, int dxfer_dir)
 	}
 fini:
 	if (unlikely(res)) {		/* failure, free up resources */
-		if (likely(!test_and_set_bit(SG_FRQ_BLK_PUT_REQ,
-					     srp->frq_bm))) {
-			WRITE_ONCE(srp->rqq, NULL);
-			blk_put_request(rq);
-		}
+		WRITE_ONCE(srp->rqq, NULL);
+		blk_put_request(rq);
 	} else {
 		srp->bio = rq->bio;
 	}
@@ -3206,6 +3189,7 @@ sg_finish_scsi_blk_rq(struct sg_request *srp)
 {
 	int ret;
 	struct sg_fd *sfp = srp->parentfp;
+	struct request *rqq = READ_ONCE(srp->rqq);
 
 	SG_LOG(4, sfp, "%s: srp=0x%pK%s\n", __func__, srp,
 	       (srp->parentfp->rsv_srp == srp) ? " rsv" : "");
@@ -3217,15 +3201,13 @@ sg_finish_scsi_blk_rq(struct sg_request *srp)
 		atomic_dec(&sfp->waiting);
 	}
 
-	/* Expect blk_put_request(rq) already called in sg_rq_end_io() */
-	if (unlikely(!test_and_set_bit(SG_FRQ_BLK_PUT_REQ, srp->frq_bm))) {
-		struct request *rq = READ_ONCE(srp->rqq);
-
+	/* Expect blk_put_request(rqq) already called in sg_rq_end_io() */
+	if (unlikely(rqq)) {
 		WRITE_ONCE(srp->rqq, NULL);
-		if (rq) {       /* blk_get_request() may have failed */
-			if (scsi_req(rq))
-				scsi_req_free_cmd(scsi_req(rq));
-			blk_put_request(rq);
+		if (rqq) {       /* blk_get_request() may have failed */
+			if (scsi_req(rqq))
+				scsi_req_free_cmd(scsi_req(rqq));
+			blk_put_request(rqq);
 		}
 	}
 	if (srp->bio) {
-- 
2.25.1


      parent reply	other threads:[~2021-03-17 15:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-17 15:27 [PATCH v2 0/6] sg: fixes for 5.13/scsi-staging Douglas Gilbert
2021-03-17 15:27 ` [PATCH v2 1/6] sg: sg_rq_map_kern: fix uninitialized Douglas Gilbert
2021-03-17 15:27 ` [PATCH v2 2/6] sg: sg_remove_sfp_usercontext: remove NULL check Douglas Gilbert
2021-03-17 15:27 ` [PATCH v2 3/6] sg: sg_rq_end_io: set SG_FRQ_ISSUED Douglas Gilbert
2021-03-17 15:27 ` [PATCH v2 4/6] sg: fix double free of long scsi commands Douglas Gilbert
2021-03-17 15:27 ` [PATCH v2 5/6] sg: tighten handling of struct request objects Douglas Gilbert
2021-03-17 15:27 ` Douglas Gilbert [this message]

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=20210317152758.51689-7-dgilbert@interlog.com \
    --to=dgilbert@interlog.com \
    --cc=colin.king@canonical.com \
    --cc=dan.carpenter@oracle.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.