Skip to contentSkip to conversation

aoe [1/7]: zero packet data after skb allocation

PATCH New Ed L. Cashin 2 participants 11 messages Jan 3, 2006 – Jan 5, 2006

Subsystems (3)
lore
Share & tools
lore
#1 lore raw

PATCH 1/1 aoe [2/7]: support dynamic resizing of AoE devices

In reply to Ed L. Cashin

Allow the driver to recognize AoE devices that have changed size. Devices not in use are updated automatically, and devices that are in use are updated at user request.

Documentation/aoe/udev.txt +1 -0
Index: 2.6.15-rc7-aoe/Documentation/aoe/udev.txt
===================================================================
@@ -18,6 +18,7 @@
 SUBSYSTEM="aoe", KERNEL="discover",	NAME="etherd/%k", GROUP="disk", MODE="0220"
 SUBSYSTEM="aoe", KERNEL="err",		NAME="etherd/%k", GROUP="disk", MODE="0440"
 SUBSYSTEM="aoe", KERNEL="interfaces",	NAME="etherd/%k", GROUP="disk", MODE="0220"
+SUBSYSTEM="aoe", KERNEL="revalidate",	NAME="etherd/%k", GROUP="disk", MODE="0220"
 
 # aoe block devices     
 KERNEL="etherd*",       NAME="%k", GROUP="disk"
drivers/block/aoe/aoeblk.c +9 -13
Index: 2.6.15-rc7-aoe/drivers/block/aoe/aoeblk.c
===================================================================
@@ -22,7 +22,9 @@
 	return snprintf(page, PAGE_SIZE,
 			"%s%s\n",
 			(d->flags & DEVFL_UP) ? "up" : "down",
-			(d->flags & DEVFL_CLOSEWAIT) ? ",closewait" : "");
+			(d->flags & DEVFL_PAUSE) ? ",paused" : 
+			(d->nopen && !(d->flags & DEVFL_UP)) ? ",closewait" : "");
+	/* I'd rather see nopen exported so we can ditch closewait */
 }
 static ssize_t aoedisk_show_mac(struct gendisk * disk, char *page)
 {
@@ -107,8 +109,7 @@
 
 	spin_lock_irqsave(&d->lock, flags);
 
-	if (--d->nopen == 0 && (d->flags & DEVFL_CLOSEWAIT)) {
-		d->flags &= ~DEVFL_CLOSEWAIT;
+	if (--d->nopen == 0 && !(d->flags & DEVFL_UP)) {
 		spin_unlock_irqrestore(&d->lock, flags);
 		aoecmd_cfg(d->aoemajor, d->aoeminor);
 		return 0;
@@ -158,14 +159,14 @@
 	}
 
 	list_add_tail(&buf->bufs, &d->bufq);
-	aoecmd_work(d);
 
+	aoecmd_work(d);
 	sl = d->sendq_hd;
 	d->sendq_hd = d->sendq_tl = NULL;
 
 	spin_unlock_irqrestore(&d->lock, flags);
-
 	aoenet_xmit(sl);
+
 	return 0;
 }
 
@@ -217,7 +218,7 @@
 		printk(KERN_ERR "aoe: aoeblk_gdalloc: cannot allocate disk "
 			"structure for %ld.%ld\n", d->aoemajor, d->aoeminor);
 		spin_lock_irqsave(&d->lock, flags);
-		d->flags &= ~DEVFL_WORKON;
+		d->flags &= ~DEVFL_GDALLOC;
 		spin_unlock_irqrestore(&d->lock, flags);
 		return;
 	}
@@ -230,7 +231,7 @@
 			"for %ld.%ld\n", d->aoemajor, d->aoeminor);
 		put_disk(gd);
 		spin_lock_irqsave(&d->lock, flags);
-		d->flags &= ~DEVFL_WORKON;
+		d->flags &= ~DEVFL_GDALLOC;
 		spin_unlock_irqrestore(&d->lock, flags);
 		return;
 	}
@@ -247,18 +248,13 @@
 
 	gd->queue = &d->blkq;
 	d->gd = gd;
-	d->flags &= ~DEVFL_WORKON;
+	d->flags &= ~DEVFL_GDALLOC;
 	d->flags |= DEVFL_UP;
 
 	spin_unlock_irqrestore(&d->lock, flags);
 
 	add_disk(gd);
 	aoedisk_add_sysfs(d);
-	
-	printk(KERN_INFO "aoe: %012llx e%lu.%lu v%04x has %llu "
-		"sectors\n", (unsigned long long)mac_addr(d->addr),
-		d->aoemajor, d->aoeminor,
-		d->fw_ver, (long long)d->ssize);
 }
 
 void
drivers/block/aoe/aoedev.c +31 -18

84 lines not on this page · raw message

Documentation/aoe/mkdevs.sh +2 -0
Index: 2.6.15-rc7-aoe/Documentation/aoe/mkdevs.sh
===================================================================
@@ -27,6 +27,8 @@
 mknod -m 0200 $dir/discover c $MAJOR 3
 rm -f $dir/interfaces
 mknod -m 0200 $dir/interfaces c $MAJOR 4
+rm -f $dir/revalidate
+mknod -m 0200 $dir/revalidate c $MAJOR 5
 
 export n_partitions
 mkshelf=`echo $0 | sed 's!mkdevs!mkshelf!'`
drivers/block/aoe/aoecmd.c +91 -22

196 lines not on this page · raw message

drivers/block/aoe/aoe.h +8 -5
Index: 2.6.15-rc7-aoe/drivers/block/aoe/aoe.h
===================================================================
@@ -75,8 +75,9 @@
 	DEVFL_TKILL = (1<<1),	/* flag for timer to know when to kill self */
 	DEVFL_EXT = (1<<2),	/* device accepts lba48 commands */
 	DEVFL_CLOSEWAIT = (1<<3), /* device is waiting for all closes to revalidate */
-	DEVFL_WC_UPDATE = (1<<4), /* this device needs to update write cache status */
-	DEVFL_WORKON = (1<<4),
+	DEVFL_GDALLOC = (1<<4),	/* need to alloc gendisk */
+	DEVFL_PAUSE = (1<<5),
+	DEVFL_NEWSIZE = (1<<6),	/* need to update dev size in block layer */
 
 	BUFFL_FAIL = 1,
 };
@@ -152,16 +153,18 @@
 void aoechr_error(char *);
 
 void aoecmd_work(struct aoedev *d);
-void aoecmd_cfg(ushort, unsigned char);
+void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor);
+struct sk_buff *aoecmd_cfg_pkts(ushort, unsigned char, struct sk_buff **);
 void aoecmd_ata_rsp(struct sk_buff *);
 void aoecmd_cfg_rsp(struct sk_buff *);
+void aoecmd_sleepwork(void *vp);
 
 int aoedev_init(void);
 void aoedev_exit(void);
 struct aoedev *aoedev_by_aoeaddr(int maj, int min);
+struct aoedev *aoedev_by_sysminor_m(ulong sysminor, ulong bufcnt);
 void aoedev_downdev(struct aoedev *d);
-struct aoedev *aoedev_set(ulong, unsigned char *, struct net_device *, ulong);
-int aoedev_busy(void);
+int aoedev_isbusy(struct aoedev *d);
 
 int aoenet_init(void);
 void aoenet_exit(void);
drivers/block/aoe/aoechr.c +37 -0
Index: 2.6.15-rc7-aoe/drivers/block/aoe/aoechr.c
===================================================================
@@ -13,6 +13,7 @@
 	MINOR_ERR = 2,
 	MINOR_DISCOVER,
 	MINOR_INTERFACES,
+	MINOR_REVALIDATE,
 	MSGSZ = 2048,
 	NARGS = 10,
 	NMSG = 100,		/* message backlog to retain */
@@ -41,6 +42,7 @@
 	{ MINOR_ERR, "err" },
 	{ MINOR_DISCOVER, "discover" },
 	{ MINOR_INTERFACES, "interfaces" },
+	{ MINOR_REVALIDATE, "revalidate" },
 };
 
 static int
@@ -62,6 +64,39 @@
 	return 0;
 }
 
+static int
+revalidate(const char __user *str, size_t size)
+{
+	int major, minor, n;
+	ulong flags;
+	struct aoedev *d;
+	char buf[16];
+
+	if (size >= sizeof buf)
+		return -EINVAL;
+	buf[sizeof buf - 1] = '\0';
+	if (copy_from_user(buf, str, size))
+		return -EFAULT;
+
+	/* should be e%d.%d format */
+	n = sscanf(buf, "e%d.%d", &major, &minor);
+	if (n != 2) {
+		printk(KERN_ERR "aoe: %s: invalid device specification\n",
+			__FUNCTION__);
+		return -EINVAL;
+	}
+	d = aoedev_by_aoeaddr(major, minor);
+	if (!d)
+		return -EINVAL;
+
+	spin_lock_irqsave(&d->lock, flags);
+	d->flags |= DEVFL_PAUSE;
+	spin_unlock_irqrestore(&d->lock, flags);
+	aoecmd_cfg(major, minor);
+
+	return 0;
+}
+
 void
 aoechr_error(char *msg)
 {
@@ -114,6 +149,8 @@
 	case MINOR_INTERFACES:
 		ret = interfaces(buf, cnt);
 		break;
+	case MINOR_REVALIDATE:
+		ret = revalidate(buf, cnt);
 	}
 	if (ret == 0)
 		ret = cnt;
Signature · 1 line
  Ed L. Cashin <[email protected]>
#0 lore raw

PATCH 1/1 aoe [1/7]: zero packet data after skb allocation

Zero the data in new socket buffers to prevent leaking information.

drivers/block/aoe/aoecmd.c +1 -0
Index: 2.6.15-rc7-aoe/drivers/block/aoe/aoecmd.c
===================================================================
@@ -28,6 +28,7 @@
 		skb->protocol = __constant_htons(ETH_P_AOE);
 		skb->priority = 0;
 		skb_put(skb, len);
+		memset(skb->head, 0, len);
 		skb->next = skb->prev = NULL;
 
 		/* tell the network layer not to perform IP checksums
Signature · 1 line
  Ed L. Cashin <[email protected]>
#2 lore raw

PATCH 1/1 aoe [3/7]: increase allowed outstanding packets

Increase the number of AoE packets per device that can be outstanding at one time, increasing performance.

drivers/block/aoe/aoecmd.c +1 -1
Index: 2.6.15-rc7-aoe/drivers/block/aoe/aoecmd.c
===================================================================
@@ -655,7 +655,7 @@
 	ulong flags, sysminor, aoemajor;
 	u16 bufcnt;
 	struct sk_buff *sl;
-	enum { MAXFRAMES = 8 };
+	enum { MAXFRAMES = 16 };
 
 	h = (struct aoe_hdr *) skb->mac.raw;
 	ch = (struct aoe_cfghdr *) (h+1);
Signature · 1 line
  Ed L. Cashin <[email protected]>
#3 lore raw

PATCH 1/1 aoe [7/7]: update driver version number

In reply to Ed L. Cashin

Update aoe driver version number.

drivers/block/aoe/aoe.h +1 -1
Index: 2.6.15-rc7-aoe/drivers/block/aoe/aoe.h
===================================================================
@@ -1,5 +1,5 @@
 /* Copyright (c) 2004 Coraid, Inc.  See COPYING for GPL terms. */
-#define VERSION "14"
+#define VERSION "18"
 #define AOE_MAJOR 152
 #define DEVICE_NAME "aoe"
 
Signature · 1 line
  Ed L. Cashin <[email protected]>
#4 lore raw

PATCH 1/1 aoe [6/7]: update device information on last close

In reply to Ed L. Cashin

Instead of making the user wait or do it manually, refresh device information on its last close by issuing a config query to the device.

drivers/block/aoe/aoeblk.c +1 -1
Index: 2.6.15-rc7-aoe/drivers/block/aoe/aoeblk.c
===================================================================
@@ -109,7 +109,7 @@
 
 	spin_lock_irqsave(&d->lock, flags);
 
-	if (--d->nopen == 0 && !(d->flags & DEVFL_UP)) {
+	if (--d->nopen == 0) {
 		spin_unlock_irqrestore(&d->lock, flags);
 		aoecmd_cfg(d->aoemajor, d->aoeminor);
 		return 0;
Signature · 1 line
  Ed L. Cashin <[email protected]>
#5 lore raw

PATCH 1/1 aoe [5/7]: allow network interface migration on packet retransmit

In reply to Ed L. Cashin

Retransmit to the current network interface for an AoE device.

drivers/block/aoe/aoecmd.c +2 -0
Index: 2.6.15-rc7-aoe/drivers/block/aoe/aoecmd.c
===================================================================
@@ -239,6 +239,8 @@
 	h = (struct aoe_hdr *) f->data;
 	f->tag = n;
 	h->tag = cpu_to_be32(n);
+	memcpy(h->dst, d->addr, sizeof h->dst);
+	memcpy(h->src, d->ifp->dev_addr, sizeof h->src);
 
 	skb = skb_prepare(d, f);
 	if (skb) {
Signature · 1 line
  Ed L. Cashin <[email protected]>
#6 lore raw

PATCH 1/1 aoe [4/7]: use less confusing driver name

In reply to Ed L. Cashin

Users were confused by the driver being called "aoe-2.6-$version". This form looks less like a Linux kernel version number.

drivers/block/aoe/aoemain.c +1 -1
Index: 2.6.15-rc7-aoe/drivers/block/aoe/aoemain.c
===================================================================
@@ -89,7 +89,7 @@
 	}
 
 	printk(KERN_INFO
-	       "aoe: aoe_init: AoE v2.6-%s initialised.\n",
+	       "aoe: aoe_init: aoe6-%s initialised.\n",
 	       VERSION);
 	discover_timer(TINIT);
 	return 0;
Signature · 1 line
  Ed L. Cashin <[email protected]>
#7 lore raw

Re: [PATCH 2.6.15-rc7] aoe [4/7]: use less confusing driver name

2006/1/4, Ed L. Cashin <[email protected]>:

Quoted 10 lines

Users were confused by the driver being called "aoe-2.6-$version". This form looks less like a Linux kernel version number.

Index: 2.6.15-rc7-aoe/drivers/block/aoe/aoemain.c
===================================================================

drivers/block/aoe/aoemain.c 2006-01-02 13:35:14.000000000 -0500 line 93

Quoted 6 lines
drivers/block/aoe/aoemain.c 2006-01-02 13:35:14.000000000 -0500 renamed from drivers/block/aoe/aoemain.c 2006-01-02 13:35:13.000000000 -0500 +1 -1
@@ -89,7 +89,7 @@
        }
 
        printk(KERN_INFO
-              "aoe: aoe_init: AoE v2.6-%s initialised.\n",
+              "aoe: aoe_init: aoe6-%s initialised.\n",
               VERSION);

Better simply be `AoE v%s'?

drivers/block/aoe/aoemain.c 2006-01-02 13:35:14.000000000 -0500 line 95

Quoted 4 lines
drivers/block/aoe/aoemain.c 2006-01-02 13:35:14.000000000 -0500 renamed from drivers/block/aoe/aoemain.c 2006-01-02 13:35:13.000000000 -0500 +0 -0
        discover_timer(TINIT);
        return 0;

--
Coywolf Qi Hunt

#8 lore raw

Re: [PATCH 2.6.15-rc7] aoe [4/7]: use less confusing driver name

Quoted 13 lines · Coywolf Qi Hunt

2006/1/4, Ed L. Cashin <[email protected]>:

Quoted 12 lines

Users were confused by the driver being called "aoe-2.6-$version". This form looks less like a Linux kernel version number.

Index: 2.6.15-rc7-aoe/drivers/block/aoe/aoemain.c
===================================================================

drivers/block/aoe/aoemain.c 2006-01-02 13:35:14.000000000 -0500 renamed from drivers/block/aoe/aoemain.c 2006-01-02 13:35:13.000000000 -0500 +0 -0
@@ -89,7 +89,7 @@
        }
 
Quoted 6 lines

drivers/block/aoe/aoemain.c 2006-01-02 13:35:14.000000000 -0500 line 93

Quoted 4 lines
drivers/block/aoe/aoemain.c 2006-01-02 13:35:14.000000000 -0500 renamed from drivers/block/aoe/aoemain.c 2006-01-02 13:35:13.000000000 -0500 +1 -1
        printk(KERN_INFO
-              "aoe: aoe_init: AoE v2.6-%s initialised.\n",
+              "aoe: aoe_init: aoe6-%s initialised.\n",
               VERSION);

Better simply be `AoE v%s'?

That would be nice, but there's a driver for the 2.4 linux kernel that has an independent version number, so the "6" distinguishes the 2.6 aoe driver from the 2.4 aoe driver.

Signature · 1 line
  Ed L Cashin <[email protected]>
#9 lore raw

Re: [PATCH 2.6.15-rc7] aoe [4/7]: use less confusing driver name

2006/1/5, Ed L Cashin <[email protected]>:

Quoted 22 lines
Quoted 13 lines · Coywolf Qi Hunt

2006/1/4, Ed L. Cashin <[email protected]>:

Quoted 12 lines

Users were confused by the driver being called "aoe-2.6-$version". This form looks less like a Linux kernel version number.

Index: 2.6.15-rc7-aoe/drivers/block/aoe/aoemain.c
===================================================================

drivers/block/aoe/aoemain.c 2006-01-02 13:35:14.000000000 -0500 renamed from drivers/block/aoe/aoemain.c 2006-01-02 13:35:13.000000000 -0500 +0 -0
@@ -89,7 +89,7 @@
        }
 
Quoted 6 lines

drivers/block/aoe/aoemain.c 2006-01-02 13:35:14.000000000 -0500 line 93

Quoted 4 lines
drivers/block/aoe/aoemain.c 2006-01-02 13:35:14.000000000 -0500 renamed from drivers/block/aoe/aoemain.c 2006-01-02 13:35:13.000000000 -0500 +1 -1
        printk(KERN_INFO
-              "aoe: aoe_init: AoE v2.6-%s initialised.\n",
+              "aoe: aoe_init: aoe6-%s initialised.\n",
               VERSION);

Better simply be `AoE v%s'?

Quoted 3 lines

That would be nice, but there's a driver for the 2.4 linux kernel that has an independent version number, so the "6" distinguishes the 2.6 aoe driver from the 2.4 aoe driver.

But 2.4 and 2.6 driver never meet each other, right?

Quoted 5 lines

--
Ed L Cashin <[email protected]>

--
Coywolf Qi Hunt

#10 lore raw

Re: [PATCH 2.6.15-rc7] aoe [4/7]: use less confusing driver name

Coywolf Qi Hunt <[email protected]> writes:

[Ed writes]
...

Quoted 1 line
Quoted 1 line

Coywolf Qi Hunt <[email protected]> writes:

...

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Better simply be `AoE v%s'?

That would be nice, but there's a driver for the 2.4 linux kernel that has an independent version number, so the "6" distinguishes the 2.6 aoe driver from the 2.4 aoe driver.

But 2.4 and 2.6 driver never meet each other, right?

Yes, after thinking it over more, I agree. Here's a new version of this patch.

Users were confused by the driver being called "aoe-2.6-$version". This form looks less like a Linux kernel version number.

drivers/block/aoe/aoemain.c +1 -1
Index: 2.6.15-rc7-aoe/drivers/block/aoe/aoemain.c
===================================================================
@@ -89,7 +89,7 @@
 	}
 
 	printk(KERN_INFO
-	       "aoe: aoe_init: AoE v2.6-%s initialised.\n",
+	       "aoe: aoe_init: AoE v%s initialised.\n",
 	       VERSION);
 	discover_timer(TINIT);
 	return 0;
Signature · 1 line
  Ed L Cashin <[email protected]>