* [PATCH][linux 2.6.18] scsiback: free resources after error
@ 2014-07-04 4:41 jgross
2014-07-04 9:40 ` [PATCH v2][linux " Jan Beulich
0 siblings, 1 reply; 3+ messages in thread
From: jgross @ 2014-07-04 4:41 UTC (permalink / raw)
To: xen-devel, jbeulich; +Cc: Juergen Gross
From: Juergen Gross <jgross@suse.com>
In case of an error during preparing an I/O the already allocated resources
should all be freed again and the frontend request should be terminated
accordingly.
Signed-off-by: Juergen Gross <jgross@suse.com>
diff -r 19448506c371 drivers/xen/scsiback/common.h
--- a/drivers/xen/scsiback/common.h Wed Jul 02 15:09:18 2014 +0200
+++ b/drivers/xen/scsiback/common.h Fri Jul 04 06:38:14 2014 +0200
@@ -163,13 +163,13 @@ struct scsi_device *scsiback_do_translat
void scsiback_release_translation_entry(struct vscsibk_info *info);
-void scsiback_cmd_exec(pending_req_t *pending_req);
+int scsiback_cmd_exec(pending_req_t *pending_req);
void scsiback_do_resp_with_sense(char *sense_buffer, int32_t result,
uint32_t resid, pending_req_t *pending_req);
void scsiback_fast_flush_area(pending_req_t *req);
void scsiback_rsp_emulation(pending_req_t *pending_req);
-void scsiback_req_emulation_or_cmdexec(pending_req_t *pending_req);
+int scsiback_req_emulation_or_cmdexec(pending_req_t *pending_req);
void scsiback_emulation_init(void);
diff -r 19448506c371 drivers/xen/scsiback/emulate.c
--- a/drivers/xen/scsiback/emulate.c Wed Jul 02 15:09:18 2014 +0200
+++ b/drivers/xen/scsiback/emulate.c Fri Jul 04 06:38:14 2014 +0200
@@ -345,16 +345,19 @@ void scsiback_rsp_emulation(pending_req_
}
-void scsiback_req_emulation_or_cmdexec(pending_req_t *pending_req)
+int scsiback_req_emulation_or_cmdexec(pending_req_t *pending_req)
{
+ int err = 0;
+
if (__pre_do_emulation(pending_req, NULL)) {
- scsiback_cmd_exec(pending_req);
+ err = scsiback_cmd_exec(pending_req);
}
else {
scsiback_fast_flush_area(pending_req);
scsiback_do_resp_with_sense(pending_req->sense_buffer,
pending_req->rslt, pending_req->resid, pending_req);
}
+ return err;
}
diff -r 19448506c371 drivers/xen/scsiback/scsiback.c
--- a/drivers/xen/scsiback/scsiback.c Wed Jul 02 15:09:18 2014 +0200
+++ b/drivers/xen/scsiback/scsiback.c Fri Jul 04 06:38:14 2014 +0200
@@ -429,7 +429,7 @@ free_bios:
}
-void scsiback_cmd_exec(pending_req_t *pending_req)
+int scsiback_cmd_exec(pending_req_t *pending_req)
{
int cmd_len = (int)pending_req->cmd_len;
int data_dir = (int)pending_req->sc_data_direction;
@@ -437,6 +437,7 @@ void scsiback_cmd_exec(pending_req_t *pe
unsigned int timeout;
struct request *rq;
int write;
+ int err;
DPRINTK("%s\n",__FUNCTION__);
@@ -464,16 +465,18 @@ void scsiback_cmd_exec(pending_req_t *pe
if (nr_segments) {
- if (request_map_sg(rq, pending_req, nr_segments)) {
+ err = request_map_sg(rq, pending_req, nr_segments);
+ if (err) {
printk(KERN_ERR "scsiback: SG Request Map Error\n");
- return;
+ blk_put_request(rq);
+ return err;
}
}
scsiback_get(pending_req->info);
blk_execute_rq_nowait(rq->q, NULL, rq, 1, scsiback_cmd_done);
- return ;
+ return 0;
}
@@ -616,9 +619,15 @@ static int _scsiback_do_cmd_fn(struct vs
case VSCSIIF_ACT_SCSI_CDB:
/* The Host mode is through as for Emulation. */
if (info->feature == VSCSI_TYPE_HOST)
- scsiback_cmd_exec(pending_req);
+ err = scsiback_cmd_exec(pending_req);
else
- scsiback_req_emulation_or_cmdexec(pending_req);
+ err = scsiback_req_emulation_or_cmdexec(
+ pending_req);
+ if (err) {
+ scsiback_fast_flush_area(pending_req);
+ scsiback_do_resp_with_sense(NULL,
+ DRIVER_ERROR << 24, 0, pending_req);
+ }
break;
case VSCSIIF_ACT_SCSI_RESET:
scsiback_device_reset_exec(pending_req);
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2][linux 2.6.18] scsiback: free resources after error
2014-07-04 4:41 [PATCH][linux 2.6.18] scsiback: free resources after error jgross
@ 2014-07-04 9:40 ` Jan Beulich
2014-07-04 10:02 ` Juergen Gross
0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2014-07-04 9:40 UTC (permalink / raw)
To: xen-devel; +Cc: Juergen Gross
[-- Attachment #1: Type: text/plain, Size: 4433 bytes --]
From: Juergen Gross <jgross@suse.com>
In case of an error during preparing an I/O the already allocated resources
should all be freed again and the frontend request should be terminated
accordingly.
Signed-off-by: Juergen Gross <jgross@suse.com>
Some formatting adjustments to the changes above, and some more releasing
of resources (in the VSCSIIF_ACT_SCSI_RESET and default cases of the switch
in scsiback_do_cmd_fn()).
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/drivers/xen/scsiback/common.h
+++ b/drivers/xen/scsiback/common.h
@@ -163,13 +163,13 @@ struct scsi_device *scsiback_do_translat
void scsiback_release_translation_entry(struct vscsibk_info *info);
-void scsiback_cmd_exec(pending_req_t *pending_req);
+int scsiback_cmd_exec(pending_req_t *pending_req);
void scsiback_do_resp_with_sense(char *sense_buffer, int32_t result,
uint32_t resid, pending_req_t *pending_req);
void scsiback_fast_flush_area(pending_req_t *req);
void scsiback_rsp_emulation(pending_req_t *pending_req);
-void scsiback_req_emulation_or_cmdexec(pending_req_t *pending_req);
+int scsiback_req_emulation_or_cmdexec(pending_req_t *pending_req);
void scsiback_emulation_init(void);
--- a/drivers/xen/scsiback/emulate.c
+++ b/drivers/xen/scsiback/emulate.c
@@ -345,16 +345,16 @@ void scsiback_rsp_emulation(pending_req_
}
-void scsiback_req_emulation_or_cmdexec(pending_req_t *pending_req)
+int scsiback_req_emulation_or_cmdexec(pending_req_t *pending_req)
{
- if (__pre_do_emulation(pending_req, NULL)) {
- scsiback_cmd_exec(pending_req);
- }
- else {
- scsiback_fast_flush_area(pending_req);
- scsiback_do_resp_with_sense(pending_req->sense_buffer,
- pending_req->rslt, pending_req->resid, pending_req);
- }
+ if (__pre_do_emulation(pending_req, NULL))
+ return scsiback_cmd_exec(pending_req);
+
+ scsiback_fast_flush_area(pending_req);
+ scsiback_do_resp_with_sense(pending_req->sense_buffer,
+ pending_req->rslt, pending_req->resid,
+ pending_req);
+ return 0;
}
--- a/drivers/xen/scsiback/scsiback.c
+++ b/drivers/xen/scsiback/scsiback.c
@@ -429,14 +429,14 @@ free_bios:
}
-void scsiback_cmd_exec(pending_req_t *pending_req)
+int scsiback_cmd_exec(pending_req_t *pending_req)
{
int cmd_len = (int)pending_req->cmd_len;
int data_dir = (int)pending_req->sc_data_direction;
unsigned int nr_segments = (unsigned int)pending_req->nr_segments;
unsigned int timeout;
struct request *rq;
- int write;
+ int write, err;
DPRINTK("%s\n",__FUNCTION__);
@@ -463,17 +463,19 @@ void scsiback_cmd_exec(pending_req_t *pe
rq->end_io_data = pending_req;
if (nr_segments) {
-
- if (request_map_sg(rq, pending_req, nr_segments)) {
- printk(KERN_ERR "scsiback: SG Request Map Error\n");
- return;
+ err = request_map_sg(rq, pending_req, nr_segments);
+ if (err) {
+ printk(KERN_ERR "scsiback: SG Request Map error %d\n",
+ err);
+ blk_put_request(rq);
+ return err;
}
}
scsiback_get(pending_req->info);
blk_execute_rq_nowait(rq->q, NULL, rq, 1, scsiback_cmd_done);
- return ;
+ return 0;
}
@@ -615,17 +617,28 @@ static int scsiback_do_cmd_fn(struct vsc
switch (err ?: pending_req->act) {
case VSCSIIF_ACT_SCSI_CDB:
/* The Host mode is through as for Emulation. */
- if (info->feature == VSCSI_TYPE_HOST)
- scsiback_cmd_exec(pending_req);
- else
- scsiback_req_emulation_or_cmdexec(pending_req);
+ if (info->feature == VSCSI_TYPE_HOST ?
+ scsiback_cmd_exec(pending_req) :
+ scsiback_req_emulation_or_cmdexec(pending_req)) {
+ scsiback_fast_flush_area(pending_req);
+ scsiback_do_resp_with_sense(NULL,
+ DRIVER_ERROR << 24,
+ 0, pending_req);
+ }
break;
case VSCSIIF_ACT_SCSI_RESET:
+ /* Just for pointlessly specified segments: */
+ scsiback_fast_flush_area(pending_req);
scsiback_device_reset_exec(pending_req);
break;
default:
- if(!err && printk_ratelimit())
- printk(KERN_ERR "scsiback: invalid request\n");
+ if(!err) {
+ scsiback_fast_flush_area(pending_req);
+ if (printk_ratelimit())
+ printk(KERN_ERR
+ "scsiback: invalid request %#x\n",
+ pending_req->act);
+ }
scsiback_do_resp_with_sense(NULL, DRIVER_ERROR << 24,
0, pending_req);
break;
[-- Attachment #2: xen-scsiback-free-resources-after-error.patch --]
[-- Type: text/plain, Size: 4428 bytes --]
scsiback: free resources after error
In case of an error during preparing an I/O the already allocated resources
should all be freed again and the frontend request should be terminated
accordingly.
Signed-off-by: Juergen Gross <jgross@suse.com>
Some formatting adjustments to the changes above, and some more releasing
of resources (in the VSCSIIF_ACT_SCSI_RESET and default cases of the switch
in scsiback_do_cmd_fn()).
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/drivers/xen/scsiback/common.h
+++ b/drivers/xen/scsiback/common.h
@@ -163,13 +163,13 @@ struct scsi_device *scsiback_do_translat
void scsiback_release_translation_entry(struct vscsibk_info *info);
-void scsiback_cmd_exec(pending_req_t *pending_req);
+int scsiback_cmd_exec(pending_req_t *pending_req);
void scsiback_do_resp_with_sense(char *sense_buffer, int32_t result,
uint32_t resid, pending_req_t *pending_req);
void scsiback_fast_flush_area(pending_req_t *req);
void scsiback_rsp_emulation(pending_req_t *pending_req);
-void scsiback_req_emulation_or_cmdexec(pending_req_t *pending_req);
+int scsiback_req_emulation_or_cmdexec(pending_req_t *pending_req);
void scsiback_emulation_init(void);
--- a/drivers/xen/scsiback/emulate.c
+++ b/drivers/xen/scsiback/emulate.c
@@ -345,16 +345,16 @@ void scsiback_rsp_emulation(pending_req_
}
-void scsiback_req_emulation_or_cmdexec(pending_req_t *pending_req)
+int scsiback_req_emulation_or_cmdexec(pending_req_t *pending_req)
{
- if (__pre_do_emulation(pending_req, NULL)) {
- scsiback_cmd_exec(pending_req);
- }
- else {
- scsiback_fast_flush_area(pending_req);
- scsiback_do_resp_with_sense(pending_req->sense_buffer,
- pending_req->rslt, pending_req->resid, pending_req);
- }
+ if (__pre_do_emulation(pending_req, NULL))
+ return scsiback_cmd_exec(pending_req);
+
+ scsiback_fast_flush_area(pending_req);
+ scsiback_do_resp_with_sense(pending_req->sense_buffer,
+ pending_req->rslt, pending_req->resid,
+ pending_req);
+ return 0;
}
--- a/drivers/xen/scsiback/scsiback.c
+++ b/drivers/xen/scsiback/scsiback.c
@@ -429,14 +429,14 @@ free_bios:
}
-void scsiback_cmd_exec(pending_req_t *pending_req)
+int scsiback_cmd_exec(pending_req_t *pending_req)
{
int cmd_len = (int)pending_req->cmd_len;
int data_dir = (int)pending_req->sc_data_direction;
unsigned int nr_segments = (unsigned int)pending_req->nr_segments;
unsigned int timeout;
struct request *rq;
- int write;
+ int write, err;
DPRINTK("%s\n",__FUNCTION__);
@@ -463,17 +463,19 @@ void scsiback_cmd_exec(pending_req_t *pe
rq->end_io_data = pending_req;
if (nr_segments) {
-
- if (request_map_sg(rq, pending_req, nr_segments)) {
- printk(KERN_ERR "scsiback: SG Request Map Error\n");
- return;
+ err = request_map_sg(rq, pending_req, nr_segments);
+ if (err) {
+ printk(KERN_ERR "scsiback: SG Request Map error %d\n",
+ err);
+ blk_put_request(rq);
+ return err;
}
}
scsiback_get(pending_req->info);
blk_execute_rq_nowait(rq->q, NULL, rq, 1, scsiback_cmd_done);
- return ;
+ return 0;
}
@@ -615,17 +617,28 @@ static int scsiback_do_cmd_fn(struct vsc
switch (err ?: pending_req->act) {
case VSCSIIF_ACT_SCSI_CDB:
/* The Host mode is through as for Emulation. */
- if (info->feature == VSCSI_TYPE_HOST)
- scsiback_cmd_exec(pending_req);
- else
- scsiback_req_emulation_or_cmdexec(pending_req);
+ if (info->feature == VSCSI_TYPE_HOST ?
+ scsiback_cmd_exec(pending_req) :
+ scsiback_req_emulation_or_cmdexec(pending_req)) {
+ scsiback_fast_flush_area(pending_req);
+ scsiback_do_resp_with_sense(NULL,
+ DRIVER_ERROR << 24,
+ 0, pending_req);
+ }
break;
case VSCSIIF_ACT_SCSI_RESET:
+ /* Just for pointlessly specified segments: */
+ scsiback_fast_flush_area(pending_req);
scsiback_device_reset_exec(pending_req);
break;
default:
- if(!err && printk_ratelimit())
- printk(KERN_ERR "scsiback: invalid request\n");
+ if(!err) {
+ scsiback_fast_flush_area(pending_req);
+ if (printk_ratelimit())
+ printk(KERN_ERR
+ "scsiback: invalid request %#x\n",
+ pending_req->act);
+ }
scsiback_do_resp_with_sense(NULL, DRIVER_ERROR << 24,
0, pending_req);
break;
[-- Attachment #3: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2][linux 2.6.18] scsiback: free resources after error
2014-07-04 9:40 ` [PATCH v2][linux " Jan Beulich
@ 2014-07-04 10:02 ` Juergen Gross
0 siblings, 0 replies; 3+ messages in thread
From: Juergen Gross @ 2014-07-04 10:02 UTC (permalink / raw)
To: Jan Beulich, xen-devel
On 07/04/2014 11:40 AM, Jan Beulich wrote:
> From: Juergen Gross <jgross@suse.com>
>
> In case of an error during preparing an I/O the already allocated resources
> should all be freed again and the frontend request should be terminated
> accordingly.
>
> Signed-off-by: Juergen Gross <jgross@suse.com>
>
> Some formatting adjustments to the changes above, and some more releasing
> of resources (in the VSCSIIF_ACT_SCSI_RESET and default cases of the switch
> in scsiback_do_cmd_fn()).
For your additional changes:
Reviewed-by: Juergen Gross <jgross@suse.com>
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>
> --- a/drivers/xen/scsiback/common.h
> +++ b/drivers/xen/scsiback/common.h
> @@ -163,13 +163,13 @@ struct scsi_device *scsiback_do_translat
> void scsiback_release_translation_entry(struct vscsibk_info *info);
>
>
> -void scsiback_cmd_exec(pending_req_t *pending_req);
> +int scsiback_cmd_exec(pending_req_t *pending_req);
> void scsiback_do_resp_with_sense(char *sense_buffer, int32_t result,
> uint32_t resid, pending_req_t *pending_req);
> void scsiback_fast_flush_area(pending_req_t *req);
>
> void scsiback_rsp_emulation(pending_req_t *pending_req);
> -void scsiback_req_emulation_or_cmdexec(pending_req_t *pending_req);
> +int scsiback_req_emulation_or_cmdexec(pending_req_t *pending_req);
> void scsiback_emulation_init(void);
>
>
> --- a/drivers/xen/scsiback/emulate.c
> +++ b/drivers/xen/scsiback/emulate.c
> @@ -345,16 +345,16 @@ void scsiback_rsp_emulation(pending_req_
> }
>
>
> -void scsiback_req_emulation_or_cmdexec(pending_req_t *pending_req)
> +int scsiback_req_emulation_or_cmdexec(pending_req_t *pending_req)
> {
> - if (__pre_do_emulation(pending_req, NULL)) {
> - scsiback_cmd_exec(pending_req);
> - }
> - else {
> - scsiback_fast_flush_area(pending_req);
> - scsiback_do_resp_with_sense(pending_req->sense_buffer,
> - pending_req->rslt, pending_req->resid, pending_req);
> - }
> + if (__pre_do_emulation(pending_req, NULL))
> + return scsiback_cmd_exec(pending_req);
> +
> + scsiback_fast_flush_area(pending_req);
> + scsiback_do_resp_with_sense(pending_req->sense_buffer,
> + pending_req->rslt, pending_req->resid,
> + pending_req);
> + return 0;
> }
>
>
> --- a/drivers/xen/scsiback/scsiback.c
> +++ b/drivers/xen/scsiback/scsiback.c
> @@ -429,14 +429,14 @@ free_bios:
> }
>
>
> -void scsiback_cmd_exec(pending_req_t *pending_req)
> +int scsiback_cmd_exec(pending_req_t *pending_req)
> {
> int cmd_len = (int)pending_req->cmd_len;
> int data_dir = (int)pending_req->sc_data_direction;
> unsigned int nr_segments = (unsigned int)pending_req->nr_segments;
> unsigned int timeout;
> struct request *rq;
> - int write;
> + int write, err;
>
> DPRINTK("%s\n",__FUNCTION__);
>
> @@ -463,17 +463,19 @@ void scsiback_cmd_exec(pending_req_t *pe
> rq->end_io_data = pending_req;
>
> if (nr_segments) {
> -
> - if (request_map_sg(rq, pending_req, nr_segments)) {
> - printk(KERN_ERR "scsiback: SG Request Map Error\n");
> - return;
> + err = request_map_sg(rq, pending_req, nr_segments);
> + if (err) {
> + printk(KERN_ERR "scsiback: SG Request Map error %d\n",
> + err);
> + blk_put_request(rq);
> + return err;
> }
> }
>
> scsiback_get(pending_req->info);
> blk_execute_rq_nowait(rq->q, NULL, rq, 1, scsiback_cmd_done);
>
> - return ;
> + return 0;
> }
>
>
> @@ -615,17 +617,28 @@ static int scsiback_do_cmd_fn(struct vsc
> switch (err ?: pending_req->act) {
> case VSCSIIF_ACT_SCSI_CDB:
> /* The Host mode is through as for Emulation. */
> - if (info->feature == VSCSI_TYPE_HOST)
> - scsiback_cmd_exec(pending_req);
> - else
> - scsiback_req_emulation_or_cmdexec(pending_req);
> + if (info->feature == VSCSI_TYPE_HOST ?
> + scsiback_cmd_exec(pending_req) :
> + scsiback_req_emulation_or_cmdexec(pending_req)) {
> + scsiback_fast_flush_area(pending_req);
> + scsiback_do_resp_with_sense(NULL,
> + DRIVER_ERROR << 24,
> + 0, pending_req);
> + }
> break;
> case VSCSIIF_ACT_SCSI_RESET:
> + /* Just for pointlessly specified segments: */
> + scsiback_fast_flush_area(pending_req);
> scsiback_device_reset_exec(pending_req);
> break;
> default:
> - if(!err && printk_ratelimit())
> - printk(KERN_ERR "scsiback: invalid request\n");
> + if(!err) {
> + scsiback_fast_flush_area(pending_req);
> + if (printk_ratelimit())
> + printk(KERN_ERR
> + "scsiback: invalid request %#x\n",
> + pending_req->act);
> + }
> scsiback_do_resp_with_sense(NULL, DRIVER_ERROR << 24,
> 0, pending_req);
> break;
>
>
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-07-04 10:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-04 4:41 [PATCH][linux 2.6.18] scsiback: free resources after error jgross
2014-07-04 9:40 ` [PATCH v2][linux " Jan Beulich
2014-07-04 10:02 ` Juergen Gross
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.