diff options
| author | Johannes Thumshirn <jthumshirn@suse.de> | 2016-11-17 04:31:23 -0500 |
|---|---|---|
| committer | Martin K. Petersen <martin.petersen@oracle.com> | 2016-11-17 20:15:26 -0500 |
| commit | fb6f7c8d8a19e5543d5b4d44c58e2c4e5a82bb12 (patch) | |
| tree | 7c7626dfd808b37d35d06c31c603f434ee252782 | |
| parent | 06548160dfecd1983ffd9d6795242a5cda095da5 (diff) | |
block: add bsg_job_put() and bsg_job_get()
Add bsg_job_put() and bsg_job_get() so don't need to export
bsg_destroy_job() any more.
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
| -rw-r--r-- | block/bsg-lib.c | 17 | ||||
| -rw-r--r-- | drivers/scsi/scsi_transport_fc.c | 4 | ||||
| -rw-r--r-- | include/linux/bsg-lib.h | 3 |
3 files changed, 18 insertions, 6 deletions
diff --git a/block/bsg-lib.c b/block/bsg-lib.c index 6661f823db4c..803ec40ebd6d 100644 --- a/block/bsg-lib.c +++ b/block/bsg-lib.c | |||
| @@ -32,7 +32,7 @@ | |||
| 32 | * bsg_destroy_job - routine to teardown/delete a bsg job | 32 | * bsg_destroy_job - routine to teardown/delete a bsg job |
| 33 | * @job: bsg_job that is to be torn down | 33 | * @job: bsg_job that is to be torn down |
| 34 | */ | 34 | */ |
| 35 | void bsg_destroy_job(struct kref *kref) | 35 | static void bsg_destroy_job(struct kref *kref) |
| 36 | { | 36 | { |
| 37 | struct bsg_job *job = container_of(kref, struct bsg_job, kref); | 37 | struct bsg_job *job = container_of(kref, struct bsg_job, kref); |
| 38 | struct request *rq = job->req; | 38 | struct request *rq = job->req; |
| @@ -45,7 +45,18 @@ void bsg_destroy_job(struct kref *kref) | |||
| 45 | kfree(job->reply_payload.sg_list); | 45 | kfree(job->reply_payload.sg_list); |
| 46 | kfree(job); | 46 | kfree(job); |
| 47 | } | 47 | } |
| 48 | EXPORT_SYMBOL_GPL(bsg_destroy_job); | 48 | |
| 49 | void bsg_job_put(struct bsg_job *job) | ||
| 50 | { | ||
| 51 | kref_put(&job->kref, bsg_destroy_job); | ||
| 52 | } | ||
| 53 | EXPORT_SYMBOL_GPL(bsg_job_put); | ||
| 54 | |||
| 55 | int bsg_job_get(struct bsg_job *job) | ||
| 56 | { | ||
| 57 | return kref_get_unless_zero(&job->kref); | ||
| 58 | } | ||
| 59 | EXPORT_SYMBOL_GPL(bsg_job_get); | ||
| 49 | 60 | ||
| 50 | /** | 61 | /** |
| 51 | * bsg_job_done - completion routine for bsg requests | 62 | * bsg_job_done - completion routine for bsg requests |
| @@ -89,7 +100,7 @@ void bsg_softirq_done(struct request *rq) | |||
| 89 | { | 100 | { |
| 90 | struct bsg_job *job = rq->special; | 101 | struct bsg_job *job = rq->special; |
| 91 | 102 | ||
| 92 | kref_put(&job->kref, bsg_destroy_job); | 103 | bsg_job_put(job); |
| 93 | } | 104 | } |
| 94 | EXPORT_SYMBOL_GPL(bsg_softirq_done); | 105 | EXPORT_SYMBOL_GPL(bsg_softirq_done); |
| 95 | 106 | ||
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c index ee1e812bad4c..23e1eed932b5 100644 --- a/drivers/scsi/scsi_transport_fc.c +++ b/drivers/scsi/scsi_transport_fc.c | |||
| @@ -3571,13 +3571,13 @@ fc_bsg_job_timeout(struct request *req) | |||
| 3571 | if (rport && rport->port_state == FC_PORTSTATE_BLOCKED) | 3571 | if (rport && rport->port_state == FC_PORTSTATE_BLOCKED) |
| 3572 | return BLK_EH_RESET_TIMER; | 3572 | return BLK_EH_RESET_TIMER; |
| 3573 | 3573 | ||
| 3574 | inflight = kref_get_unless_zero(&job->kref); | 3574 | inflight = bsg_job_get(job); |
| 3575 | 3575 | ||
| 3576 | if (inflight && i->f->bsg_timeout) { | 3576 | if (inflight && i->f->bsg_timeout) { |
| 3577 | /* call LLDD to abort the i/o as it has timed out */ | 3577 | /* call LLDD to abort the i/o as it has timed out */ |
| 3578 | err = i->f->bsg_timeout(job); | 3578 | err = i->f->bsg_timeout(job); |
| 3579 | if (err == -EAGAIN) { | 3579 | if (err == -EAGAIN) { |
| 3580 | kref_put(&job->kref, bsg_destroy_job); | 3580 | bsg_job_put(job); |
| 3581 | return BLK_EH_RESET_TIMER; | 3581 | return BLK_EH_RESET_TIMER; |
| 3582 | } else if (err) | 3582 | } else if (err) |
| 3583 | printk(KERN_ERR "ERROR: FC BSG request timeout - LLD " | 3583 | printk(KERN_ERR "ERROR: FC BSG request timeout - LLD " |
diff --git a/include/linux/bsg-lib.h b/include/linux/bsg-lib.h index 09f304437cd6..b708db91618f 100644 --- a/include/linux/bsg-lib.h +++ b/include/linux/bsg-lib.h | |||
| @@ -69,7 +69,8 @@ void bsg_job_done(struct bsg_job *job, int result, | |||
| 69 | int bsg_setup_queue(struct device *dev, struct request_queue *q, char *name, | 69 | int bsg_setup_queue(struct device *dev, struct request_queue *q, char *name, |
| 70 | bsg_job_fn *job_fn, int dd_job_size); | 70 | bsg_job_fn *job_fn, int dd_job_size); |
| 71 | void bsg_request_fn(struct request_queue *q); | 71 | void bsg_request_fn(struct request_queue *q); |
| 72 | void bsg_destroy_job(struct kref *kref); | ||
| 73 | void bsg_softirq_done(struct request *rq); | 72 | void bsg_softirq_done(struct request *rq); |
| 73 | void bsg_job_put(struct bsg_job *job); | ||
| 74 | int __must_check bsg_job_get(struct bsg_job *job); | ||
| 74 | 75 | ||
| 75 | #endif | 76 | #endif |
