public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Mike Christie <michaelc@cs.wisc.edu>
To: Chris Wright <chrisw@sous-sol.org>
Cc: Jean Delvare <jdelvare@suse.de>,
	linux-scsi@vger.kernel.org,
	James Bottomley <James.Bottomley@hansenpartnership.com>
Subject: Re: [PATCH 7/7] libiscsi: fix iscsi pool error path
Date: Thu, 02 Apr 2009 11:05:16 -0500	[thread overview]
Message-ID: <49D4E23C.2010201@cs.wisc.edu> (raw)
In-Reply-To: <20090402152715.GF18394@sequoia.sous-sol.org>

[-- Attachment #1: Type: text/plain, Size: 1171 bytes --]

Chris Wright wrote:
> * Mike Christie (michaelc@cs.wisc.edu) wrote:
>>>> -	if (q->queue == ERR_PTR(-ENOMEM))
>>>> +	if (IS_ERR(q->queue)) {
>>> This indeed solves the problem I had underlined before, but
>>> introduces a new one. Right now the only error returned by kfifo_init
>>> is -ENOMEM. This may however change in the future, and then the
>>> above code would silently convert the other error code to -ENOMEM.
>>> This might make it difficult to trace errors.
>> What do you mean by converting other errors codes to -ENOMEM?
> 
> Jean means the goto label...it will jump to essentially return -ENOMEM.
> 

Ah, ok, I can agree with passing up errors in general. I did the 
attached patch to propogate the error code upwards. It does not really 
make much difference now. The iscsi pool init caller just checks for 
error or no error and does not even print out the error. It will not 
make tracing errors easier or more difficult. To be useful, we would 
have to propgate the error higher to userspace so the user can see it. I 
do not think I have time to get that in the current feature window, so 
that would have to wait unless you have patches I can test now.

[-- Attachment #2: libiscsi-propogate-pool-error.patch --]
[-- Type: text/plain, Size: 1460 bytes --]

libiscsi: propogate errors from kfifo_init to iscsi_pool_init callers

Don't convert kfifo_init's error code to -ENOMEM when passing the
error to the iscsi_pool_init caller.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 6896283..cf86d59 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -1984,6 +1984,7 @@ int
 iscsi_pool_init(struct iscsi_pool *q, int max, void ***items, int item_size)
 {
 	int i, num_arrays = 1;
+	int rc = -ENOMEM;
 
 	memset(q, 0, sizeof(*q));
 
@@ -1995,20 +1996,21 @@ iscsi_pool_init(struct iscsi_pool *q, int max, void ***items, int item_size)
 		num_arrays++;
 	q->pool = kzalloc(num_arrays * max * sizeof(void*), GFP_KERNEL);
 	if (q->pool == NULL)
-		return -ENOMEM;
+		return rc;
 
 	q->queue = kfifo_init((void*)q->pool, max * sizeof(void*),
 			      GFP_KERNEL, NULL);
 	if (IS_ERR(q->queue)) {
 		q->queue = NULL;
-		goto enomem;
+		rc = PTR_ERR(q->queue);		
+		goto fail;
 	}
 
 	for (i = 0; i < max; i++) {
 		q->pool[i] = kzalloc(item_size, GFP_KERNEL);
 		if (q->pool[i] == NULL) {
 			q->max = i;
-			goto enomem;
+			goto fail;
 		}
 		__kfifo_put(q->queue, (void*)&q->pool[i], sizeof(void*));
 	}
@@ -2020,9 +2022,9 @@ iscsi_pool_init(struct iscsi_pool *q, int max, void ***items, int item_size)
 
 	return 0;
 
-enomem:
+fail:
 	iscsi_pool_free(q);
-	return -ENOMEM;
+	return rc;
 }
 EXPORT_SYMBOL_GPL(iscsi_pool_init);
 

  reply	other threads:[~2009-04-02 16:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-01 18:11 iscsi bugfixes and cleanups michaelc
2009-04-01 18:11 ` [PATCH 1/7] cxgb3i - subscribe to error notification from cxgb3 driver michaelc
2009-04-01 18:11   ` [PATCH 2/7] cxgb3i - re-initialize ddp settings after chip reset michaelc
2009-04-01 18:11     ` [PATCH 3/7] cxgb3i - re-read ddp settings information " michaelc
2009-04-01 18:11       ` [PATCH 4/7] cxgb3i - close all tcp connections upon " michaelc
2009-04-01 18:11         ` [PATCH 5/7] cxgb3i -- merge cxgb3i_ddp into cxgb3i module michaelc
2009-04-01 18:11           ` [PATCH 6/7] cxgb3i: call ddp release function directly michaelc
2009-04-01 18:11             ` [PATCH 7/7] libiscsi: fix iscsi pool error path michaelc
2009-04-02 14:02               ` Jean Delvare
2009-04-02 15:15                 ` Mike Christie
2009-04-02 15:27                   ` Chris Wright
2009-04-02 16:05                     ` Mike Christie [this message]
2009-04-02 17:26                       ` Chris Wright

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=49D4E23C.2010201@cs.wisc.edu \
    --to=michaelc@cs.wisc.edu \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=chrisw@sous-sol.org \
    --cc=jdelvare@suse.de \
    --cc=linux-scsi@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox