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@xxxxxxxxxxxx> --- 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