public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Paul Clements <Paul.Clements@SteelEye.com>
To: akpm@osdl.org
Cc: Jens Axboe <axboe@suse.de>, Dave Jones <davej@redhat.com>,
	Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: nbd oops on unload. [PATCH x2]
Date: Wed, 18 Feb 2004 17:03:51 -0500	[thread overview]
Message-ID: <4033E147.D30E8383@SteelEye.com> (raw)
In-Reply-To: 4033A33F.FF279C05@SteelEye.com

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

Paul Clements wrote:

> Dave Jones wrote:
> > modprobe nbd ; rmmod nbd  was enough to reproduce this one..
> > (2.6.3rc4)

> Ahh, cleanup was being done in the wrong order.
> 
> Patch coming shortly...

Here it is, as well as another to fix some return codes (so nbd-client
can exit with the proper error code, rather than 0, when an error
occurs).

Tested against 2.6.3-rc2. Please apply.

Thanks,
Paul

[-- Attachment #2: nbd_cleanup_fix_2_6_3.diff --]
[-- Type: text/x-patch, Size: 691 bytes --]

--- 2_6_3_rc2/drivers/block/nbd.c.ERROR_RETURN_FIXES	Wed Feb 18 12:32:42 2004
+++ 2_6_3_rc2/drivers/block/nbd.c	Wed Feb 18 12:44:50 2004
@@ -751,8 +751,7 @@ static int __init nbd_init(void)
 	return 0;
 out:
 	while (i--) {
-		if (nbd_dev[i].disk->queue)
-			blk_cleanup_queue(nbd_dev[i].disk->queue);
+		blk_cleanup_queue(nbd_dev[i].disk->queue);
 		put_disk(nbd_dev[i].disk);
 	}
 	return err;
@@ -764,9 +763,8 @@ static void __exit nbd_cleanup(void)
 	for (i = 0; i < MAX_NBD; i++) {
 		struct gendisk *disk = nbd_dev[i].disk;
 		if (disk) {
-			if (disk->queue)
-				blk_cleanup_queue(disk->queue);
 			del_gendisk(disk);
+			blk_cleanup_queue(disk->queue);
 			put_disk(disk);
 		}
 	}

[-- Attachment #3: nbd_error_return_fixes_2_6_3.diff --]
[-- Type: text/x-patch, Size: 2186 bytes --]

--- 2_6_3_rc2/drivers/block/nbd.c.PRISTINE	Tue Feb 17 13:46:40 2004
+++ 2_6_3_rc2/drivers/block/nbd.c	Wed Feb 18 12:29:15 2004
@@ -221,6 +221,8 @@ static int sock_xmit(struct socket *sock
 			printk(KERN_ERR "nbd: %s - sock=%p at buf=%p, size=%d returned %d.\n",
 			       send? "send": "receive", sock, buf, size, result);
 #endif
+			if (result == 0)
+				result = -EPIPE; /* short read */
 			break;
 		}
 		size -= result;
@@ -309,7 +311,7 @@ void nbd_send_req(struct nbd_device *lo,
 	up(&lo->tx_lock);
 	return;
 
-      error_out:
+error_out:
 	up(&lo->tx_lock);
 	req->errors++;
 }
@@ -358,23 +360,22 @@ struct request *nbd_read_stat(struct nbd
 	if (result <= 0) {
 		printk(KERN_ERR "%s: Receive control failed (result %d)\n",
 				lo->disk->disk_name, result);
-		lo->harderror = result;
-		return NULL;
+		goto harderror;
 	}
 	req = nbd_find_request(lo, reply.handle);
 	if (req == NULL) {
 		printk(KERN_ERR "%s: Unexpected reply (%p)\n",
 				lo->disk->disk_name, reply.handle);
-		lo->harderror = result;
-		return NULL;
+		result = -EBADR;
+		goto harderror;
 	}
 
 	if (ntohl(reply.magic) != NBD_REPLY_MAGIC) {
 		printk(KERN_ERR "%s: Wrong magic (0x%lx)\n",
 				lo->disk->disk_name,
 				(unsigned long)ntohl(reply.magic));
-		lo->harderror = result;
-		return NULL;
+		result = -EPROTO;
+		goto harderror;
 	}
 	if (ntohl(reply.error)) {
 		printk(KERN_ERR "%s: Other side returned error (%d)\n",
@@ -396,8 +397,7 @@ struct request *nbd_read_stat(struct nbd
 					printk(KERN_ERR "%s: Receive data failed (result %d)\n",
 							lo->disk->disk_name,
 							result);
-					lo->harderror = result;
-					return NULL;
+					goto harderror;
 				}
 				dprintk(DBG_RX, "%s: request %p: got %d bytes data\n",
 					lo->disk->disk_name, req, bvec->bv_len);
@@ -405,6 +405,9 @@ struct request *nbd_read_stat(struct nbd
 		}
 	}
 	return req;
+harderror:
+	lo->harderror = result;
+	return NULL;
 }
 
 void nbd_do_it(struct nbd_device *lo)
@@ -416,8 +419,6 @@ void nbd_do_it(struct nbd_device *lo)
 #endif
 	while ((req = nbd_read_stat(lo)) != NULL)
 		nbd_end_request(req);
-	printk(KERN_NOTICE "%s: req should never be null\n",
-			lo->disk->disk_name);
 	return;
 }
 

      reply	other threads:[~2004-02-18 22:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-17 22:47 nbd oops on unload Dave Jones
2004-02-18  6:00 ` Paul Clements
2004-02-18  7:17   ` Jens Axboe
2004-02-18 17:39     ` Paul Clements
2004-02-18 22:03       ` Paul Clements [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=4033E147.D30E8383@SteelEye.com \
    --to=paul.clements@steeleye.com \
    --cc=akpm@osdl.org \
    --cc=axboe@suse.de \
    --cc=davej@redhat.com \
    --cc=linux-kernel@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