bring driver version number to 47
Subsystems (3)
PATCH 1/13 bring driver version number to 47
These patches were made against kernel 2.6.24-rc5-mm1 kernel. They were submitted earlier and have been modified to incorporate feedback from the kernel development community. I am resending them after resolving conflicts with patches already in the mm tree.
The eleventh patch in the old series was obsoleted by a patch in the 2.6.24-rc5-mm1 tree, gregkh-driver-block-device.patch, and has been omitted. The last patch in this series is new but straightforward.
--- drivers/block/aoe/aoe.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/block/aoe/aoe.h +1 -1
@@ -1,5 +1,5 @@/* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */ -#define VERSION "32" +#define VERSION "47"#define AOE_MAJOR 152#define DEVICE_NAME "aoe"
Signature · 1 line
1.5.3.4
PATCH 2/13 handle multiple network paths to AoE device
A remote AoE device is something can process ATA commands and is identified by an AoE shelf number and an AoE slot number. Such a device might have more than one network interface, and it might be reachable by more than one local network interface. This patch tracks the available network paths available to each AoE device, allowing them to be used more efficiently.
Andrew Morton asked about the call to msleep_interruptible in the revalidate function. Yes, if a signal is pending, then msleep_interruptible will not return 0. That means we will not loop but will call aoenet_xmit with a NULL skb, which is a noop. If the system is too low on memory or the aoe driver is too low on frames, then the user can hit control-C to interrupt the attempt to do a revalidate. I have added a comment to the code summarizing that.
Andrew Morton asked whether the allocation performed inside addtgt could use a more relaxed allocation like GFP_KERNEL, but addtgt is called when the aoedev lock has been locked with spin_lock_irqsave. It would be nice to allocate the memory under fewer restrictions, but targets are only added when the device is being discovered, and if the target can't be added right now, we can try again in a minute when then next AoE config query broadcast goes out.
Andrew Morton pointed out that the "too many targets" message could be printed for failing GFP_ATOMIC allocations. The last patch in this series makes the messages more specific.
--- drivers/block/aoe/aoe.h | 57 +++-- drivers/block/aoe/aoeblk.c | 62 ++++- drivers/block/aoe/aoechr.c | 17 +- drivers/block/aoe/aoecmd.c | 675 ++++++++++++++++++++++++++++++-------------- drivers/block/aoe/aoedev.c | 168 +++++------ drivers/block/aoe/aoenet.c | 9 +- 6 files changed, 653 insertions(+), 335 deletions(-)
drivers/block/aoe/aoe.h +40 -17
@@ -76,10 +76,8 @@ enum {DEVFL_EXT = (1 <<2 ),/* device accepts lba48 commands */ DEVFL_CLOSEWAIT = (1 <<3 ),/* device is waiting for all closes to revalidate */ DEVFL_GDALLOC = (1 <<4 ),/* need to alloc gendisk */ -DEVFL_PAUSE = (1 <<5 ), +DEVFL_KICKME = (1 <<5 ),/* slow polling network card catch */ DEVFL_NEWSIZE = (1 <<6 ),/* need to update dev size in block layer */ -DEVFL_MAXBCNT = (1 <<7 ),/* d->maxbcnt is not changeable */ -DEVFL_KICKME = (1 <<8 ), BUFFL_FAIL = 1, };
@@ -88,17 +86,24 @@ enum {DEFAULTBCNT =2 *512 ,/* 2 sectors */ NPERSHELF =16 ,/* number of slots per shelf address */ FREETAG =-1 , - MIN_BUFS = 8, +MIN_BUFS =16 , +NTARGETS =8 , +NAOEIFS =8 , + +TIMERTICK =HZ /10 , +MINTIMER =HZ >>2 , +MAXTIMER =HZ <<1 , + HELPWAIT = 20, };struct buf {struct list_head bufs; -ulong start_time;/* for disk stats */ +ulong stime;/* for disk stats */ ulong flags;ulong nframesout; -char *bufaddr;ulong resid;ulong bv_resid; +ulong bv_off;sector_t sector;struct bio *bio;struct bio_vec *bv;
@@ -114,19 +119,37 @@ struct frame {struct sk_buff *skb; }; +struct aoeif { +struct net_device *nd; +unsigned char lost; +unsigned char lostjumbo; +ushort maxbcnt; +}; + +struct aoetgt { +unsigned char addr[6 ]; +ushort nframes; +struct frame *frames; +struct aoeif ifs[NAOEIFS ]; +struct aoeif *ifp;/* current aoeif in use */ +ushort nout; +ushort maxout; +u16 lasttag;/* last tag sent */ +u16 useme; +ulong lastwadj;/* last window adjustment */ +int wpkts, rpkts; +}; +struct aoedev {struct aoedev *next; -unsigned char addr[6 ];/* remote mac addr */ -ushort flags;ulong sysminor;ulong aoemajor; -ulong aoeminor; +u16 aoeminor; +u16 flags;u16 nopen;/* (bd_openers isn't available without sleeping) */ -u16 lasttag;/* last tag sent */ u16 rttavg;/* round trip average of requests/responses */ u16 mintimer;u16 fw_ver;/* version of blade's firmware */ -u16 maxbcnt;struct work_struct work;/* disk create work struct */ struct gendisk *gd;struct request_queue blkq;
@@ -134,15 +157,14 @@ struct aoedev {sector_t ssize;struct timer_list timer;spinlock_t lock; -struct net_device *ifp;/* interface ed is attached to */ struct sk_buff *sendq_hd;/* packets needing to be sent, list head */ struct sk_buff *sendq_tl;mempool_t *bufpool;/* for deadlock-free Buf allocation */ struct list_head bufq;/* queue of bios to work on */ struct buf *inprocess;/* the one we're currently working on */ -ushort lostjumbo; -ushort nframes;/* number of frames below */ -struct frame *frames; +struct aoetgt *targets[NTARGETS ]; +struct aoetgt **tgt;/* target in use when working */ +struct aoetgt **htgt;/* target needing rexmit assistance */ };
@@ -160,12 +182,13 @@ void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor);void aoecmd_ata_rsp (struct sk_buff *);void aoecmd_cfg_rsp (struct sk_buff *);void aoecmd_sleepwork (struct work_struct *); -struct sk_buff *new_skb (ulong ); +void aoecmd_cleanslate (struct aoedev *); +struct sk_buff *aoecmd_ata_id (struct aoedev *);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); +struct aoedev *aoedev_by_sysminor_m (ulong sysminor);void aoedev_downdev (struct aoedev *d);int aoedev_isbusy (struct aoedev *d);
drivers/block/aoe/aoeblk.c +55 -7
107 lines not on this page · raw message
drivers/block/aoe/aoechr.c +13 -4
@@ -6,6 +6,7 @@#include <linux/hdreg.h> #include <linux/blkdev.h> +#include <linux/delay.h> #include "aoe.h" enum {
@@ -68,6 +69,7 @@ revalidate(const char __user *str, size_t size)int major, minor, n;ulong flags;struct aoedev *d; +struct sk_buff *skb;char buf[16 ];if (size >=sizeof buf)
@@ -85,13 +87,20 @@ revalidate(const char __user *str, size_t size) d =aoedev_by_aoeaddr (major, minor);if (!d)return -EINVAL ; -spin_lock_irqsave (&d->lock, flags); - d->flags &= ~DEVFL_MAXBCNT ; - d->flags |=DEVFL_PAUSE ; +aoecmd_cleanslate (d); +loop: + skb =aoecmd_ata_id (d);spin_unlock_irqrestore (&d->lock, flags); +/* try again if we are able to sleep a bit, +* otherwise give up this revalidation +*/ +if (!skb && !msleep_interruptible (200 )) { +spin_lock_irqsave (&d->lock, flags); + goto loop; + } +aoenet_xmit (skb);aoecmd_cfg (major, minor); -return 0 ; }
drivers/block/aoe/aoecmd.c +460 -215
978 lines not on this page · raw message
drivers/block/aoe/aoedev.c +79 -89
221 lines not on this page · raw message
drivers/block/aoe/aoenet.c +6 -3
@@ -137,9 +137,12 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt,if (n >NECODES ) n =0 ;if (net_ratelimit ()) -printk (KERN_ERR "aoe: error packet from %d.%d; ecode=%d '%s'\n" , -be16_to_cpu (get_unaligned (&h->major)), h->minor, - h->err, aoe_errlist[n]); +printk (KERN_ERR +"%s%d.%d@%s; ecode=%d '%s'\n" , +"aoe: error packet from " , +be16_to_cpu (get_unaligned (&h->major)), + h->minor, skb->dev->name, + h->err, aoe_errlist[n]); goto exit; }
Signature · 1 line
1.5.3.4
PATCH 3/13 mac_addr: avoid 64-bit arch compiler warnings
In reply to Ed L. CashinBy returning unsigned long long, mac_addr does not generate compiler warnings on 64-bit architectures.
--- drivers/block/aoe/aoe.h | 2 +- drivers/block/aoe/aoeblk.c | 3 +-- drivers/block/aoe/aoecmd.c | 10 +++++----- drivers/block/aoe/aoenet.c | 4 ++-- 4 files changed, 9 insertions(+), 10 deletions(-)
drivers/block/aoe/aoe.h +1 -1
@@ -198,4 +198,4 @@ void aoenet_xmit(struct sk_buff *);int is_aoe_netif (struct net_device *ifp);int set_aoe_iflist (const char __user *str,size_t size); -u64 mac_addr (char addr[6 ]); +unsigned long long mac_addr (char addr[6 ]);
drivers/block/aoe/aoeblk.c +1 -2
@@ -37,8 +37,7 @@ static ssize_t aoedisk_show_mac(struct device *dev,if (t ==NULL )return snprintf (page,PAGE_SIZE ,"none\n" ); -return snprintf (page,PAGE_SIZE ,"%012llx\n" , - (unsigned long long )mac_addr (t->addr)); +return snprintf (page,PAGE_SIZE ,"%012llx\n" ,mac_addr (t->addr)); }static ssize_t aoedisk_show_netif (struct device *dev,struct device_attribute *attr,char *page)
drivers/block/aoe/aoecmd.c +5 -5
@@ -309,7 +309,8 @@ resend(struct aoedev *d, struct aoetgt *t, struct frame *f)"%15s e%ld.%d oldtag=%08x@%08lx newtag=%08x " "s=%012llx d=%012llx nout=%d\n" ,"retransmit" , d->aoemajor, d->aoeminor, f->tag, jiffies, n, - mac_addr(h->src), mac_addr(h->dst), t->nout); +mac_addr (h->src), + mac_addr(h->dst), t->nout);aoechr_error (buf); f->tag = n;
@@ -633,7 +634,7 @@ ataid_complete(struct aoedev *d, struct aoetgt *t, unsigned char *id)if (d->ssize != ssize)printk (KERN_INFO "aoe: %012llx e%lu.%lu v%04x has %llu sectors\n" , - (unsigned long long )mac_addr (t->addr), +mac_addr (t->addr), d->aoemajor, d->aoeminor, d->fw_ver, (long long )ssize); d->ssize = ssize;
@@ -727,8 +728,7 @@ aoecmd_ata_rsp(struct sk_buff *skb) t =gettgt (d, hin->src);if (t ==NULL ) {printk (KERN_INFO "aoe: can't find target e%ld.%d:%012llx\n" , - d->aoemajor, d->aoeminor, - (unsigned long long )mac_addr (hin->src)); + d->aoemajor, d->aoeminor,mac_addr (hin->src));spin_unlock_irqrestore (&d->lock, flags);return ; }
@@ -1003,7 +1003,7 @@ aoecmd_cfg_rsp(struct sk_buff *skb)"aoe: e%ld.%d: setting %d%s%s:%012llx\n" , d->aoemajor, d->aoeminor, n," byte data frames on " , ifp->nd->name, - (unsigned long long) mac_addr(t->addr)); + mac_addr(t->addr)); ifp->maxbcnt = n; } }
drivers/block/aoe/aoenet.c +2 -2
@@ -83,7 +83,7 @@ set_aoe_iflist(const char __user *user_str, size_t size)return 0 ; } -u64 +unsigned long long mac_addr (char addr[6 ]) {__be64 n =0 ;
@@ -91,7 +91,7 @@ mac_addr(char addr[6])memcpy (p +2 , addr,6 );/* (sizeof addr != 6) */ -return __be64_to_cpu (n); +return (unsigned long long )__be64_to_cpu (n); }void
Signature · 1 line
1.5.3.4
PATCH 4/13 clean up udev configuration example
In reply to Ed L. CashinThis patch adds a known default location for the udev configuration file and uses the more recent "==" syntax for SUBSYSTEM and KERNEL.
--- Documentation/aoe/udev-install.sh | 5 ++++- Documentation/aoe/udev.txt | 15 ++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-)
Documentation/aoe/udev-install.sh +4 -1
@@ -23,7 +23,10 @@ fi # /etc/udev/rules.d # rules_d="`sed -n '/^udev_rules=/{ s!udev_rules=!!; s!\"!!g; p; }' $conf`" -if test -z "$rules_d" || test ! -d "$rules_d"; then +if test -z "$rules_d" ; then + rules_d=/etc/udev/rules.d +fi +if test ! -d "$rules_d"; then echo "$me Error: cannot find udev rules directory" 1>&2 exit 1 fi
Documentation/aoe/udev.txt +8 -7
@@ -1,6 +1,7 @@ # These rules tell udev what device nodes to create for aoe support. -# They may be installed along the following lines (adjusted to what -# you see on your system). +# They may be installed along the following lines. Check the section +# 8 udev manpage to see whether your udev supports SUBSYSTEM, and +# whether it uses one or two equal signs for SUBSYSTEM and KERNEL. # # ecashin@makki ~$ su # Password:
@@ -15,10 +16,10 @@ # # aoe char devices -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" +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" +KERNEL=="etherd*", NAME="%k", GROUP="disk"
Signature · 1 line
1.5.3.4
PATCH 5/13 eliminate goto and improve readability
In reply to Ed L. CashinAdam Richter suggested eliminating this goto.
--- drivers/block/aoe/aoechr.c | 69 +++++++++++++++++++++---------------------- 1 files changed, 34 insertions(+), 35 deletions(-)
drivers/block/aoe/aoechr.c +34 -35
@@ -194,52 +194,51 @@ aoechr_read(struct file *filp, char __user *buf, size_t cnt, loff_t *off)ulong flags; n = (unsigned long ) filp->private_data; -switch (n) { -case MINOR_ERR : -spin_lock_irqsave (&emsgs_lock, flags); -loop: - em = emsgs + emsgs_head_idx; -if ((em->flags &EMFL_VALID ) ==0 ) { -if (filp->f_flags &O_NDELAY ) { -spin_unlock_irqrestore (&emsgs_lock, flags); -return -EAGAIN ; - } - nblocked_emsgs_readers++; +if (n !=MINOR_ERR ) +return -EFAULT ; + +spin_lock_irqsave (&emsgs_lock, flags); +for (;;) { + em = emsgs + emsgs_head_idx; +if ((em->flags &EMFL_VALID ) !=0 ) +break ; +if (filp->f_flags &O_NDELAY ) {spin_unlock_irqrestore (&emsgs_lock, flags); +return -EAGAIN ; + } + nblocked_emsgs_readers++; + +spin_unlock_irqrestore (&emsgs_lock, flags); - n =down_interruptible (&emsgs_sema); + n =down_interruptible (&emsgs_sema); -spin_lock_irqsave (&emsgs_lock, flags); +spin_lock_irqsave (&emsgs_lock, flags); - nblocked_emsgs_readers--; + nblocked_emsgs_readers--; -if (n) { -spin_unlock_irqrestore (&emsgs_lock, flags); -return -ERESTARTSYS ; - } - goto loop; - } -if (em->len > cnt) { +if (n) {spin_unlock_irqrestore (&emsgs_lock, flags); -return -EAGAIN ; +return -ERESTARTSYS ; } - mp = em->msg; - len = em->len; - em->msg =NULL ; - em->flags &= ~EMFL_VALID ; + } +if (em->len > cnt) { +spin_unlock_irqrestore (&emsgs_lock, flags); +return -EAGAIN ; + } + mp = em->msg; + len = em->len; + em->msg =NULL ; + em->flags &= ~EMFL_VALID ; - emsgs_head_idx++; - emsgs_head_idx %=ARRAY_SIZE (emsgs); + emsgs_head_idx++; + emsgs_head_idx %=ARRAY_SIZE (emsgs); -spin_unlock_irqrestore (&emsgs_lock, flags); +spin_unlock_irqrestore (&emsgs_lock, flags); - n =copy_to_user (buf, mp, len); -kfree (mp); -return n ==0 ? len : -EFAULT ; -default : -return -EFAULT ; - } + n =copy_to_user (buf, mp, len); +kfree (mp); +return n ==0 ? len : -EFAULT ; }static const struct file_operations aoe_fops = {
Signature · 1 line
1.5.3.4
PATCH 6/13 user can ask driver to forget previously detected devices
In reply to Ed L. CashinWhen an AoE device is detected, the kernel is informed, and a new block device is created. If the device is unused, the block device corresponding to remote device that is no longer available may be removed from the system by telling the aoe driver to "flush" its list of devices.
Without this patch, software like GPFS and LVM may attempt to read from AoE devices that were discovered earlier but are no longer present, blocking until the I/O attempt times out.
--- Documentation/aoe/mkdevs.sh | 2 + Documentation/aoe/udev.txt | 1 + drivers/block/aoe/aoe.h | 1 + drivers/block/aoe/aoechr.c | 5 ++ drivers/block/aoe/aoedev.c | 87 +++++++++++++++++++++++++++++++++--------- 5 files changed, 77 insertions(+), 19 deletions(-)
Documentation/aoe/mkdevs.sh +2 -0
@@ -29,6 +29,8 @@ rm -f $dir/interfaces mknod -m 0200 $dir/interfaces c $MAJOR 4 rm -f $dir/revalidate mknod -m 0200 $dir/revalidate c $MAJOR 5 +rm -f $dir/flush +mknod -m 0200 $dir/flush c $MAJOR 6 export n_partitions mkshelf=`echo $0 | sed 's!mkdevs!mkshelf!'`
Documentation/aoe/udev.txt +1 -0
@@ -20,6 +20,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" +SUBSYSTEM=="aoe", KERNEL=="flush", NAME="etherd/%k", GROUP="disk", MODE="0220" # aoe block devices KERNEL=="etherd*", NAME="%k", GROUP="disk"
drivers/block/aoe/aoe.h +1 -0
@@ -191,6 +191,7 @@ struct aoedev *aoedev_by_aoeaddr(int maj, int min);struct aoedev *aoedev_by_sysminor_m (ulong sysminor);void aoedev_downdev (struct aoedev *d);int aoedev_isbusy (struct aoedev *d); +int aoedev_flush (const char __user *str,size_t size);int aoenet_init (void );void aoenet_exit (void );
drivers/block/aoe/aoechr.c +5 -0
@@ -15,6 +15,7 @@ enum {MINOR_DISCOVER ,MINOR_INTERFACES ,MINOR_REVALIDATE , +MINOR_FLUSH ,MSGSZ =2048 , NMSG = 100, /* message backlog to retain */ };
@@ -43,6 +44,7 @@ static struct aoe_chardev chardevs[] = { { MINOR_DISCOVER, "discover" }, { MINOR_INTERFACES, "interfaces" }, { MINOR_REVALIDATE, "revalidate" }, + { MINOR_FLUSH, "flush" }, }; static int
@@ -158,6 +160,9 @@ aoechr_write(struct file *filp, const char __user *buf, size_t cnt, loff_t *offpbreak ;case MINOR_REVALIDATE : ret =revalidate (buf, cnt); +break ; +case MINOR_FLUSH : + ret =aoedev_flush (buf, cnt); }if (ret ==0 ) ret = cnt;
drivers/block/aoe/aoedev.c +68 -19
105 lines not on this page · raw message
Signature · 1 line
1.5.3.4
PATCH 7/13 dynamically allocate a capped number of skbs when necessary
In reply to Ed L. CashinWhat this Patch Does
Even before this recent series of 12 patches to 2.6.22-rc4, the aoe driver was reusing a small set of skbs that were allocated once and were only used for outbound AoE commands.
The network layer cannot be allowed to put_page on the data that is still associated with a bio we haven't returned to the block layer, so the aoe driver (even before the patch under discussion) is still the owner of skbs that have been handed to the network layer for transmission. We need to keep track of these skbs so that we can free them, but by tracking them, we can also easily re-use them.
The new patch was a response to the behavior of certain network drivers. We cannot reuse an skb that the network driver still has in its transmit ring. Network drivers can defer transmit ring cleanup and then use the state in the skb to determine how many data segments to clean up in its transmit ring. The tg3 driver is one driver that behaves in this way.
When the network driver defers cleanup of its transmit ring, the aoe driver can find itself in a situation where it would like to send an AoE command, and the AoE target is ready for more work, but the network driver still has all of the pre-allocated skbs. In that case, the new patch just calls alloc_skb, as you'd expect.
We don't want to get carried away, though. We try not to do excessive allocation in the write path, so we cap the number of skbs we dynamically allocate.
Probably calling it a "dynamic pool" is misleading. We were already trying to use a small fixed-size set of pre-allocated skbs before this patch, and this patch just provides a little headroom (with a ceiling, though) to accomodate network drivers that hang onto skbs, by allocating when needed. The d->skbpool_hd list of allocated skbs is necessary so that we can free them later.
We didn't notice the need for this headroom until AoE targets got fast enough.
Alternatives
If the network layer never did a put_page on the pages in the bio's we get from the block layer, then it would be possible for us to hand skbs to the network layer and forget about them, allowing the network layer to free skbs itself (and thereby calling our own skb->destructor callback function if we needed that). In that case we could get rid of the pre-allocated skbs and also the d->skbpool_hd, instead just calling alloc_skb every time we wanted to transmit a packet. The slab allocator would effectively maintain the list of skbs.
Besides a loss of CPU cache locality, the main concern with that approach the danger that it would increase the likelihood of deadlock when VM is trying to free pages by writing dirty data from the page cache through the aoe driver out to persistent storage on an AoE device. Right now we have a situation where we have pre-allocation that corresponds to how much we use, which seems ideal.
Of course, there's still the separate issue of receiving the packets that tell us that a write has successfully completed on the AoE target. When memory is low and VM is using AoE to flush dirty data to free up pages, it would be perfect if there were a way for us to register a fast callback that could recognize write command completion responses. But I don't think the current problems with the receive side of the situation are a justification for exacerbating the problem on the transmit side.
--- drivers/block/aoe/aoe.h | 5 ++ drivers/block/aoe/aoecmd.c | 117 +++++++++++++++++++++++++++++++------------- drivers/block/aoe/aoedev.c | 52 +++++++++++++++++--- 3 files changed, 133 insertions(+), 41 deletions(-)
drivers/block/aoe/aoe.h +5 -0
@@ -89,6 +89,7 @@ enum {MIN_BUFS =16 ,NTARGETS =8 ,NAOEIFS =8 , +NSKBPOOLMAX =128 ,TIMERTICK =HZ /10 , MINTIMER = HZ >> 2,
@@ -138,6 +139,7 @@ struct aoetgt {u16 useme;ulong lastwadj;/* last window adjustment */ int wpkts, rpkts; +int dataref; };struct aoedev {
@@ -159,6 +161,9 @@ struct aoedev {spinlock_t lock;struct sk_buff *sendq_hd;/* packets needing to be sent, list head */ struct sk_buff *sendq_tl; +struct sk_buff *skbpool_hd; +struct sk_buff *skbpool_tl; +int nskbpool;mempool_t *bufpool;/* for deadlock-free Buf allocation */ struct list_head bufq;/* queue of bios to work on */ struct buf *inprocess;/* the one we're currently working on */
drivers/block/aoe/aoecmd.c +83 -34
161 lines not on this page · raw message
drivers/block/aoe/aoedev.c +45 -7
87 lines not on this page · raw message
Signature · 1 line
1.5.3.4
PATCH 8/13 only install new AoE device once
In reply to Ed L. CashinAn aoe driver user who had about 70 AoE targets found that he was hitting a BUG in sysfs_create_file because the aoe driver was trying to tell the kernel about an AoE device more than once. Each AoE device was reachable by several local network interfaces, and multiple ATA device indentify responses were returning from that single device.
This patch eliminates a race condition so that aoe always informs the block layer of a new AoE device once in the presence of multiple incoming ATA device identify responses.
--- drivers/block/aoe/aoecmd.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/block/aoe/aoecmd.c +2 -0
@@ -698,6 +698,8 @@ ataid_complete(struct aoedev *d, struct aoetgt *t, unsigned char *id) d->fw_ver, (long long)ssize); d->ssize = ssize; d->geo.start =0 ; +if (d->flags & (DEVFL_GDALLOC |DEVFL_NEWSIZE )) +return ;if (d->gd !=NULL ) { d->gd->capacity = ssize; d->flags |=DEVFL_NEWSIZE ;
Signature · 1 line
1.5.3.4
PATCH 9/13 remove race between use and initialization of locks
In reply to Ed L. CashinAlexey Dobriyan noticed a race in the initialization of the dynamic locks in ...
Message-ID: <[email protected]>
Andrew Morton commented that these locks should be initialized at compile time, so this patch does that.
--- drivers/block/aoe/aoechr.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/block/aoe/aoechr.c +2 -4
@@ -35,8 +35,8 @@ struct ErrMsg {static struct ErrMsg emsgs[NMSG ];static int emsgs_head_idx, emsgs_tail_idx; -static struct semaphore emsgs_sema; -static spinlock_t emsgs_lock; +static __DECLARE_SEMAPHORE_GENERIC(emsgs_sema, 0); +static DEFINE_SPINLOCK (emsgs_lock);static int nblocked_emsgs_readers;static struct class *aoe_class;static struct aoe_chardev chardevs[] = {
@@ -264,8 +264,6 @@ aoechr_init(void)printk (KERN_ERR "aoe: can't register char device\n" );return n; } -sema_init (&emsgs_sema,0 ); -spin_lock_init (&emsgs_lock); aoe_class =class_create (THIS_MODULE ,"aoe" );if (IS_ERR (aoe_class)) {unregister_chrdev (AOE_MAJOR ,"aoechr" );
Signature · 1 line
1.5.3.4
Re: [PATCH 09/13] remove race between use and initialization of locks
Quoted 18 lines · On Thu, 20 Dec 2007 17:15:57 -0500 "Ed L. Cashin" <[email protected]> wrote:
Alexey Dobriyan noticed a race in the initialization of the dynamic locks in ...
Message-ID: <[email protected]>
Andrew Morton commented that these locks should be initialized at compile time, so this patch does that.
Signed-off-by Ed L. Cashin <[email protected]>--- drivers/block/aoe/aoechr.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)drivers/block/aoe/aoechr.c +0
-0
drivers/block/aoe/aoechr.c struct ErrMsg { · line 38
Quoted 6 lines
drivers/block/aoe/aoechr.c +1
-2@@ -35,8 +35,8 @@ struct ErrMsg {static struct ErrMsg emsgs[NMSG ];static int emsgs_head_idx, emsgs_tail_idx; -static struct semaphore emsgs_sema; -static spinlock_t emsgs_lock; +static __DECLARE_SEMAPHORE_GENERIC(emsgs_sema, 0);
That's not very attractive. This would be the only user of __DECLARE_SEMAPHORE_GENERIC() in the tree. It seems that all architectures (apart from uml) do implement this (although I didn't verify that they all offer the same interface for it). But still...
And no, we don't appear to have a proper interface to statically declare a locked semaphore. Nor do we appear to have one for mutexes(!).
drivers/block/aoe/aoechr.c aoechr_init(void) · line 269
Quoted 13 lines
drivers/block/aoe/aoechr.c +1
-2+static DEFINE_SPINLOCK (emsgs_lock);static int nblocked_emsgs_readers;static struct class *aoe_class;static struct aoe_chardev chardevs[] = {@@ -264,8 +264,6 @@ aoechr_init(void)printk (KERN_ERR "aoe: can't register char device\n" );return n; } -sema_init (&emsgs_sema,0 ); -spin_lock_init (&emsgs_lock); aoe_class =class_create (THIS_MODULE ,"aoe" );if (IS_ERR (aoe_class)) {unregister_chrdev (AOE_MAJOR ,"aoechr" );
I think it would be better to go back to initialising emsgs_lock at runtime rather than fattening the exported semaphore API like this.
emssgs_sema is a weird-looking thing. There really should be some comments in there because it is unobvious what the code is attempting to do.
What is the code attempting to do?
It appears to me that nblocked_emsgs_readers gets incorrectly decremented if the down_interruptible() got interrupted, btw.
Re: [PATCH 09/13] remove race between use and initialization of locks
Quoted 1 line · Andrew Morton
On Thu, 20 Dec 2007 17:15:57 -0500 "Ed L. Cashin" <[email protected]> wrote:
...
Quoted 1 line
Quoted 1 line
+static
__DECLARE_SEMAPHORE_GENERIC(emsgs_sema, 0);
...
Quoted 8 lines
drivers/block/aoe/aoechr.c aoechr_init(void) · line 269
Quoted 5 lines
drivers/block/aoe/aoechr.c +0
-2-sema_init (&emsgs_sema,0 ); -spin_lock_init (&emsgs_lock); aoe_class =class_create (THIS_MODULE ,"aoe" );if (IS_ERR (aoe_class)) {unregister_chrdev (AOE_MAJOR ,"aoechr" );I think it would be better to go back to initialising
emsgs_lockat runtime rather than fattening the exported semaphore API like this.
I don't think there is anything wrong with having a complete set of initialization routines for a semaphore, but it's certainly easy enough to go back to Alexey Dobriyan's original suggestion, which was to simply move the initialization calls before register_chardev.
I will follow this email with a patch that does that.
Quoted 4 lines
emssgs_semais a weird-looking thing. There really should be some comments in there because it is unobvious what the code is attempting to do.What is the code attempting to do?
There is a ring buffer of error messages. Userland processes can read these error messages by reading /dev/etherd/err, blocking if there are no error messages to read yet.
The emsgs_sema semaphore is used to manage the reader(s) waiting for error messages. When there are sleepers waiting, "up" is used to wake one up when a new error message is produced. A reader gets a single message, not just some text with a mixture of different errors.
If I do,
cat /dev/etherd/err > /my/log/file
... then I can hit control-c or send a SIGTERM to stop it.
Quoted 2 lines
It appears to me that
nblocked_emsgs_readersgets incorrectly decremented if thedown_interruptible()got interrupted, btw.
The counter will be incremented again if the process goes back to sleep waiting for an error message, but the process might be getting killed. The counter is really just for sleeping readers.
Signature · 1 line
Ed L Cashin <[email protected]>
PATCH 1/1 aoe: initialize locking structures before registering char devices
In reply to Andrew MortonThis patch was made against 2.6.24-rc6-mm1.
In March 2007, Alexey Dobriyan suggested this change, which eliminates a race after register_chardev has been called but the locking primitives protecting the error messages ring buffer have not yet been initialized.
The initialization could happen at compile time, but that would leave aoe as the only user of __DECLARE_SEMAPHORE_GENERIC.
--- drivers/block/aoe/aoechr.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/block/aoe/aoechr.c +2 -2
@@ -259,13 +259,13 @@ aoechr_init(void) {int n, i; +sema_init (&emsgs_sema,0 ); +spin_lock_init (&emsgs_lock); n =register_chrdev (AOE_MAJOR ,"aoechr" , &aoe_fops);if (n <0 ) {printk (KERN_ERR "aoe: can't register char device\n" );return n; } -sema_init (&emsgs_sema,0 ); -spin_lock_init (&emsgs_lock); aoe_class =class_create (THIS_MODULE ,"aoe" );if (IS_ERR (aoe_class)) {unregister_chrdev (AOE_MAJOR ,"aoechr" );
Signature · 1 line
1.5.3.4
PATCH 1/1 aoe: document the behavior of /dev/etherd/err
In reply to Andrew Morton--- drivers/block/aoe/aoechr.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/block/aoe/aoechr.c +4 -0
@@ -33,6 +33,10 @@ struct ErrMsg {char *msg; }; +/* A ring buffer of error messages, to be read through +* "/dev/etherd/err". When no messages are present, +* readers will block waiting for messages to appear. +*/ static struct ErrMsg emsgs[NMSG ];static int emsgs_head_idx, emsgs_tail_idx;static struct semaphore emsgs_sema;
Signature · 1 line
1.5.3.4
PATCH 10/13 add module parameter for users who need more outstanding I/O
In reply to Ed L. CashinAn AoE target provides an estimate of the number of outstanding commands that the AoE initiator can send before getting a response. The aoe_maxout parameter provides a way to set an even lower limit. It will not allow a user to use more outstanding commands than the target permits. If a user discovers a problem with a large setting, this parameter provides a way for us to work with them to debug the problem. We expect to improve the dynamic window sizing algorithm and drop this parameter. For the time being, it is a debugging aid.
--- drivers/block/aoe/aoecmd.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)
drivers/block/aoe/aoecmd.c +7 -3
@@ -18,6 +18,11 @@ static int aoe_deadsecs = 60 * 3;module_param (aoe_deadsecs, int,0644 );MODULE_PARM_DESC (aoe_deadsecs,"After aoe_deadsecs seconds, give up and fail dev." ); +static int aoe_maxout =16 ; +module_param (aoe_maxout, int,0644 ); +MODULE_PARM_DESC (aoe_maxout, +"Only aoe_maxout outstanding packets for every MAC on eX.Y." ); +static struct sk_buff *new_skb (ulong len) {
@@ -984,7 +989,6 @@ aoecmd_cfg_rsp(struct sk_buff *skb)struct aoeif *ifp;ulong flags, sysminor, aoemajor;struct sk_buff *sl; -enum {MAXFRAMES =16 };u16 n; h = (struct aoe_hdr *)skb_mac_header (skb);
@@ -1009,8 +1013,8 @@ aoecmd_cfg_rsp(struct sk_buff *skb) } n =be16_to_cpu (ch->bufcnt); -if (n >MAXFRAMES )/* keep it reasonable */ - n =MAXFRAMES ; +if (n > aoe_maxout)/* keep it reasonable */ + n = aoe_maxout; d =aoedev_by_sysminor_m (sysminor);if (d ==NULL ) {
Signature · 1 line
1.5.3.4
PATCH 11/13 the aoeminor doesn't need a long format
In reply to Ed L. CashinThe aoedev aoeminor member doesn't need a long format.
--- drivers/block/aoe/aoeblk.c | 7 ++++--- drivers/block/aoe/aoecmd.c | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-)
drivers/block/aoe/aoeblk.c +4 -3
@@ -202,7 +202,7 @@ aoeblk_make_request(struct request_queue *q, struct bio *bio)spin_lock_irqsave (&d->lock, flags);if ((d->flags &DEVFL_UP ) ==0 ) { -printk (KERN_INFO "aoe: device %ld.%ld is not up\n" , +printk (KERN_INFO "aoe: device %ld.%d is not up\n" , d->aoemajor, d->aoeminor);spin_unlock_irqrestore (&d->lock, flags);mempool_free (buf, d->bufpool);
@@ -255,14 +255,15 @@ aoeblk_gdalloc(void *vp) gd =alloc_disk (AOE_PARTITIONS );if (gd ==NULL ) { -printk (KERN_ERR "aoe: cannot allocate disk structure for %ld.%ld\n" , +printk (KERN_ERR +"aoe: cannot allocate disk structure for %ld.%d\n" , d->aoemajor, d->aoeminor); goto err; } d->bufpool =mempool_create_slab_pool (MIN_BUFS , buf_pool_cache);if (d->bufpool ==NULL ) { -printk (KERN_ERR "aoe: cannot allocate bufpool for %ld.%ld\n" , +printk (KERN_ERR "aoe: cannot allocate bufpool for %ld.%d\n" , d->aoemajor, d->aoeminor); goto err_disk; }
drivers/block/aoe/aoecmd.c +3 -2
@@ -697,7 +697,8 @@ ataid_complete(struct aoedev *d, struct aoetgt *t, unsigned char *id) }if (d->ssize != ssize) -printk (KERN_INFO "aoe: %012llx e%lu.%lu v%04x has %llu sectors\n" , +printk (KERN_INFO +"aoe: %012llx e%ld.%d v%04x has %llu sectors\n" ,mac_addr (t->addr), d->aoemajor, d->aoeminor, d->fw_ver, (long long )ssize);
@@ -822,7 +823,7 @@ aoecmd_ata_rsp(struct sk_buff *skb)if (ahin->cmdstat &0xa9 ) {/* these bits cleared on success */ printk (KERN_ERR -"aoe: ata error cmd=%2.2Xh stat=%2.2Xh from e%ld.%ld\n" , +"aoe: ata error cmd=%2.2Xh stat=%2.2Xh from e%ld.%d\n" , ahout->cmdstat, ahin->cmdstat, d->aoemajor, d->aoeminor);if (buf)
Signature · 1 line
1.5.3.4
PATCH 12/13 make error messages more specific
In reply to Ed L. CashinAndrew Morton pointed out that the "too many targets" message in patch 2 could be printed for failing GFP_ATOMIC allocations. This patch makes the messages more specific.
--- drivers/block/aoe/aoecmd.c | 15 +++++++-------- 1 files changed, 7 insertions(+), 8 deletions(-)
drivers/block/aoe/aoecmd.c +7 -8
@@ -957,15 +957,17 @@ addtgt(struct aoedev *d, char *addr, ulong nframes)for (; tt < te && *tt; tt++) ; -if (tt == te) +if (tt == te) { +printk (KERN_INFO +"aoe: device addtgt failure; too many targets\n" );return NULL ; - + } t =kcalloc (1 ,sizeof *t,GFP_ATOMIC ); -if (!t) -return NULL ; f =kcalloc (nframes,sizeof *f,GFP_ATOMIC ); -if (!f) { +if (!t || !f) { +kfree (f);kfree (t); +printk (KERN_INFO "aoe: cannot allocate memory to add target\n" );return NULL ; }
@@ -1029,9 +1031,6 @@ aoecmd_cfg_rsp(struct sk_buff *skb)if (!t) { t =addtgt (d, h->src, n);if (!t) { -printk (KERN_INFO -"aoe: device addtgt failure; " -"too many targets?\n" );spin_unlock_irqrestore (&d->lock, flags);return ; }
Signature · 1 line
1.5.3.4
PATCH 13/13 update copyright date
In reply to Ed L. CashinUpdate the year in the copyright notices.
--- drivers/block/aoe/aoe.h | 2 +- drivers/block/aoe/aoeblk.c | 2 +- drivers/block/aoe/aoechr.c | 2 +- drivers/block/aoe/aoecmd.c | 2 +- drivers/block/aoe/aoedev.c | 2 +- drivers/block/aoe/aoemain.c | 2 +- drivers/block/aoe/aoenet.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-)
drivers/block/aoe/aoe.h +1 -1
@@ -1,4 +1,4 @@ -/* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */ +/* Copyright (c) 2007 Coraid, Inc. See COPYING for GPL terms. */ #define VERSION "47"#define AOE_MAJOR 152#define DEVICE_NAME "aoe"
drivers/block/aoe/aoeblk.c +1 -1
@@ -1,4 +1,4 @@ -/* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */ +/* Copyright (c) 2007 Coraid, Inc. See COPYING for GPL terms. */ /* * aoeblk.c * block device routines
drivers/block/aoe/aoechr.c +1 -1
@@ -1,4 +1,4 @@ -/* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */ +/* Copyright (c) 2007 Coraid, Inc. See COPYING for GPL terms. */ /* * aoechr.c * AoE character device driver
drivers/block/aoe/aoecmd.c +1 -1
@@ -1,4 +1,4 @@ -/* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */ +/* Copyright (c) 2007 Coraid, Inc. See COPYING for GPL terms. */ /* * aoecmd.c * Filesystem request handling methods
drivers/block/aoe/aoedev.c +1 -1
@@ -1,4 +1,4 @@ -/* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */ +/* Copyright (c) 2007 Coraid, Inc. See COPYING for GPL terms. */ /* * aoedev.c * AoE device utility functions; maintains device list.
drivers/block/aoe/aoemain.c +1 -1
@@ -1,4 +1,4 @@ -/* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */ +/* Copyright (c) 2007 Coraid, Inc. See COPYING for GPL terms. */ /* * aoemain.c * Module initialization routines, discover timer
drivers/block/aoe/aoenet.c +1 -1
@@ -1,4 +1,4 @@ -/* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */ +/* Copyright (c) 2007 Coraid, Inc. See COPYING for GPL terms. */ /* * aoenet.c * Ethernet portion of AoE driver
Signature · 1 line
1.5.3.4
Re: [PATCH 13/13] update copyright date
Quoted 1 line · On Thu, 20 Dec 2007 17:16:01 -0500 "Ed L. Cashin" <[email protected]> wrote:
Subject: [PATCH 13/13] update copyright date
Please put an identfier for the subsytem in patch titles. In this case,
Subject: [PATCH 13/13] aoe: update copyright date
would suit.
I dropped aoe-remove-race-between-use-and-initialization-of-locks.patch, queued the rest and added the below, thanks.
aoe: statically initialise devlist_lock
From: Andrew Morton <[email protected]>
I guess aoedev_init() can go away now.
---
drivers/block/aoe/aoedev.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/block/aoe/aoedev.c renamed from drivers/block/aoe/aoedev.c~aoe-statically-initialise-devlist_lock +1 -3
@@ -16,7 +16,7 @@ static void freetgt(struct aoedev *d, ststatic void skbpoolfree (struct aoedev *d);static struct aoedev *devlist; -static spinlock_t devlist_lock; +static DEFINE_SPINLOCK (devlist_lock);int aoedev_isbusy (struct aoedev *d)
@@ -291,7 +291,5 @@ aoedev_exit(void)int __init aoedev_init (void ) { -spin_lock_init (&devlist_lock);return 0 ; } -
_