All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Clements <paul.clements@steeleye.com>
To: Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org
Cc: david@dgreaves.com, Wouter Verhelst <w@uter.be>,
	Corey Minyard <cminyard@mvista.com>
Subject: [PATCH 1/2] NBD: set uninitialized devices to size 0
Date: Fri, 24 Aug 2007 13:06:39 -0400	[thread overview]
Message-ID: <46CF101F.4050603@steeleye.com> (raw)

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

This fixes errors with utilities (such as LVM's vgscan) that try to scan 
all devices. Previously this would generate read errors when 
uninitialized nbd devices were scanned:

# vgscan
   Reading all physical volumes.  This may take a while...
   /dev/nbd0: read failed after 0 of 1024 at 0: Input/output error
   /dev/nbd0: read failed after 0 of 1024 at 509804544: Input/output error
   /dev/nbd0: read failed after 0 of 2048 at 0: Input/output error
   /dev/nbd1: read failed after 0 of 1024 at 509804544: Input/output error
   /dev/nbd1: read failed after 0 of 2048 at 0: Input/output error


 From now on, uninitialized nbd devices will have size zero, which 
prevents these errors.

Patch applies and was tested against 2.6.23-rc2-mm2.

Thanks,
Paul

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


Signed-Off-By: Paul Clements <paul.clements@steeleye.com>

--- ./drivers/block/nbd.c.ERROR_RETURNS	2007-08-15 15:41:19.000000000 -0400
+++ ./drivers/block/nbd.c	2007-08-16 13:08:06.000000000 -0400
@@ -589,6 +589,9 @@ static int nbd_ioctl(struct inode *inode
 		printk(KERN_WARNING "%s: queue cleared\n", lo->disk->disk_name);
 		if (file)
 			fput(file);
+		lo->bytesize = 0;
+		inode->i_bdev->bd_inode->i_size = 0;
+		set_capacity(lo->disk, 0);
 		return lo->harderror;
 	case NBD_CLEAR_QUE:
 		/*
@@ -666,14 +669,14 @@ static int __init nbd_init(void)
 		mutex_init(&nbd_dev[i].tx_lock);
 		init_waitqueue_head(&nbd_dev[i].active_wq);
 		nbd_dev[i].blksize = 1024;
-		nbd_dev[i].bytesize = 0x7ffffc00ULL << 10; /* 2TB */
+		nbd_dev[i].bytesize = 0;
 		disk->major = NBD_MAJOR;
 		disk->first_minor = i;
 		disk->fops = &nbd_fops;
 		disk->private_data = &nbd_dev[i];
 		disk->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO;
 		sprintf(disk->disk_name, "nbd%d", i);
-		set_capacity(disk, 0x7ffffc00ULL << 1); /* 2 TB */
+		set_capacity(disk, 0);
 		add_disk(disk);
 	}
 

             reply	other threads:[~2007-08-24 17:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-24 17:06 Paul Clements [this message]
2007-08-24 17:40 ` [PATCH 2/2] NBD: allow hung network I/O to be cancelled Paul Clements
2007-08-24 18:13   ` Mike Snitzer
2007-08-24 19:09     ` Paul Clements
2007-08-24 23:48 ` [PATCH 1/2] NBD: set uninitialized devices to size 0 Andrew Morton
2007-08-29  2:54   ` Bill Davidsen

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=46CF101F.4050603@steeleye.com \
    --to=paul.clements@steeleye.com \
    --cc=akpm@linux-foundation.org \
    --cc=cminyard@mvista.com \
    --cc=david@dgreaves.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=w@uter.be \
    /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 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.