mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
Merge branch 'akpm' (Andrew's patch-bomb)
Merge misc patches from Andrew Morton: "Incoming: - lots of misc stuff - backlight tree updates - lib/ updates - Oleg's percpu-rwsem changes - checkpatch - rtc - aoe - more checkpoint/restart support I still have a pile of MM stuff pending - Pekka should be merging later today after which that is good to go. A number of other things are twiddling thumbs awaiting maintainer merges." * emailed patches from Andrew Morton <[email protected]>: (180 commits) scatterlist: don't BUG when we can trivially return a proper error. docs: update documentation about /proc/<pid>/fdinfo/<fd> fanotify output fs, fanotify: add @mflags field to fanotify output docs: add documentation about /proc/<pid>/fdinfo/<fd> output fs, notify: add procfs fdinfo helper fs, exportfs: add exportfs_encode_inode_fh() helper fs, exportfs: escape nil dereference if no s_export_op present fs, epoll: add procfs fdinfo helper fs, eventfd: add procfs fdinfo helper procfs: add ability to plug in auxiliary fdinfo providers tools/testing/selftests/kcmp/kcmp_test.c: print reason for failure in kcmp_test breakpoint selftests: print failure status instead of cause make error kcmp selftests: print fail status instead of cause make error kcmp selftests: make run_tests fix mem-hotplug selftests: print failure status instead of cause make error cpu-hotplug selftests: print failure status instead of cause make error mqueue selftests: print failure status instead of cause make error vm selftests: print failure status instead of cause make error ubifs: use prandom_bytes mtd: nandsim: use prandom_bytes ...
This commit is contained in:
commit
848b81415c
185 changed files with 3447 additions and 1339 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/* Copyright (c) 2012 Coraid, Inc. See COPYING for GPL terms. */
|
||||
#define VERSION "50"
|
||||
#define VERSION "81"
|
||||
#define AOE_MAJOR 152
|
||||
#define DEVICE_NAME "aoe"
|
||||
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
#define AOE_PARTITIONS (16)
|
||||
#endif
|
||||
|
||||
#define WHITESPACE " \t\v\f\n"
|
||||
#define WHITESPACE " \t\v\f\n,"
|
||||
|
||||
enum {
|
||||
AOECMD_ATA,
|
||||
|
|
@ -73,21 +73,29 @@ enum {
|
|||
DEVFL_TKILL = (1<<1), /* flag for timer to know when to kill self */
|
||||
DEVFL_EXT = (1<<2), /* device accepts lba48 commands */
|
||||
DEVFL_GDALLOC = (1<<3), /* need to alloc gendisk */
|
||||
DEVFL_KICKME = (1<<4), /* slow polling network card catch */
|
||||
DEVFL_NEWSIZE = (1<<5), /* need to update dev size in block layer */
|
||||
DEVFL_GD_NOW = (1<<4), /* allocating gendisk */
|
||||
DEVFL_KICKME = (1<<5), /* slow polling network card catch */
|
||||
DEVFL_NEWSIZE = (1<<6), /* need to update dev size in block layer */
|
||||
DEVFL_FREEING = (1<<7), /* set when device is being cleaned up */
|
||||
DEVFL_FREED = (1<<8), /* device has been cleaned up */
|
||||
};
|
||||
|
||||
enum {
|
||||
DEFAULTBCNT = 2 * 512, /* 2 sectors */
|
||||
MIN_BUFS = 16,
|
||||
NTARGETS = 8,
|
||||
NTARGETS = 4,
|
||||
NAOEIFS = 8,
|
||||
NSKBPOOLMAX = 256,
|
||||
NFACTIVE = 61,
|
||||
|
||||
TIMERTICK = HZ / 10,
|
||||
MINTIMER = HZ >> 2,
|
||||
MAXTIMER = HZ << 1,
|
||||
RTTSCALE = 8,
|
||||
RTTDSCALE = 3,
|
||||
RTTAVG_INIT = USEC_PER_SEC / 4 << RTTSCALE,
|
||||
RTTDEV_INIT = RTTAVG_INIT / 4,
|
||||
|
||||
HARD_SCORN_SECS = 10, /* try another remote port after this */
|
||||
MAX_TAINT = 1000, /* cap on aoetgt taint */
|
||||
};
|
||||
|
||||
struct buf {
|
||||
|
|
@ -100,10 +108,17 @@ struct buf {
|
|||
struct request *rq;
|
||||
};
|
||||
|
||||
enum frame_flags {
|
||||
FFL_PROBE = 1,
|
||||
};
|
||||
|
||||
struct frame {
|
||||
struct list_head head;
|
||||
u32 tag;
|
||||
struct timeval sent; /* high-res time packet was sent */
|
||||
u32 sent_jiffs; /* low-res jiffies-based sent time */
|
||||
ulong waited;
|
||||
ulong waited_total;
|
||||
struct aoetgt *t; /* parent target I belong to */
|
||||
sector_t lba;
|
||||
struct sk_buff *skb; /* command skb freed on module exit */
|
||||
|
|
@ -112,6 +127,7 @@ struct frame {
|
|||
struct bio_vec *bv;
|
||||
ulong bcnt;
|
||||
ulong bv_off;
|
||||
char flags;
|
||||
};
|
||||
|
||||
struct aoeif {
|
||||
|
|
@ -122,28 +138,31 @@ struct aoeif {
|
|||
|
||||
struct aoetgt {
|
||||
unsigned char addr[6];
|
||||
ushort nframes;
|
||||
ushort nframes; /* cap on frames to use */
|
||||
struct aoedev *d; /* parent device I belong to */
|
||||
struct list_head ffree; /* list of free frames */
|
||||
struct aoeif ifs[NAOEIFS];
|
||||
struct aoeif *ifp; /* current aoeif in use */
|
||||
ushort nout;
|
||||
ushort maxout;
|
||||
ulong falloc;
|
||||
ulong lastwadj; /* last window adjustment */
|
||||
ushort nout; /* number of AoE commands outstanding */
|
||||
ushort maxout; /* current value for max outstanding */
|
||||
ushort next_cwnd; /* incr maxout after decrementing to zero */
|
||||
ushort ssthresh; /* slow start threshold */
|
||||
ulong falloc; /* number of allocated frames */
|
||||
int taint; /* how much we want to avoid this aoetgt */
|
||||
int minbcnt;
|
||||
int wpkts, rpkts;
|
||||
char nout_probes;
|
||||
};
|
||||
|
||||
struct aoedev {
|
||||
struct aoedev *next;
|
||||
ulong sysminor;
|
||||
ulong aoemajor;
|
||||
u32 rttavg; /* scaled AoE round trip time average */
|
||||
u32 rttdev; /* scaled round trip time mean deviation */
|
||||
u16 aoeminor;
|
||||
u16 flags;
|
||||
u16 nopen; /* (bd_openers isn't available without sleeping) */
|
||||
u16 rttavg; /* round trip average of requests/responses */
|
||||
u16 mintimer;
|
||||
u16 fw_ver; /* version of blade's firmware */
|
||||
u16 lasttag; /* last tag sent */
|
||||
u16 useme;
|
||||
|
|
@ -151,7 +170,7 @@ struct aoedev {
|
|||
struct work_struct work;/* disk create work struct */
|
||||
struct gendisk *gd;
|
||||
struct request_queue *blkq;
|
||||
struct hd_geometry geo;
|
||||
struct hd_geometry geo;
|
||||
sector_t ssize;
|
||||
struct timer_list timer;
|
||||
spinlock_t lock;
|
||||
|
|
@ -164,11 +183,12 @@ struct aoedev {
|
|||
} ip;
|
||||
ulong maxbcnt;
|
||||
struct list_head factive[NFACTIVE]; /* hash of active frames */
|
||||
struct aoetgt *targets[NTARGETS];
|
||||
struct list_head rexmitq; /* deferred retransmissions */
|
||||
struct aoetgt **targets;
|
||||
ulong ntargets; /* number of allocated aoetgt pointers */
|
||||
struct aoetgt **tgt; /* target in use when working */
|
||||
struct aoetgt *htgt; /* target needing rexmit assistance */
|
||||
ulong ntargets;
|
||||
ulong kicked;
|
||||
char ident[512];
|
||||
};
|
||||
|
||||
/* kthread tracking */
|
||||
|
|
@ -195,6 +215,7 @@ void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor);
|
|||
struct sk_buff *aoecmd_ata_rsp(struct sk_buff *);
|
||||
void aoecmd_cfg_rsp(struct sk_buff *);
|
||||
void aoecmd_sleepwork(struct work_struct *);
|
||||
void aoecmd_wreset(struct aoetgt *t);
|
||||
void aoecmd_cleanslate(struct aoedev *);
|
||||
void aoecmd_exit(void);
|
||||
int aoecmd_init(void);
|
||||
|
|
|
|||
|
|
@ -16,11 +16,19 @@
|
|||
#include <linux/netdevice.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/export.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <scsi/sg.h>
|
||||
#include "aoe.h"
|
||||
|
||||
static DEFINE_MUTEX(aoeblk_mutex);
|
||||
static struct kmem_cache *buf_pool_cache;
|
||||
|
||||
/* GPFS needs a larger value than the default. */
|
||||
static int aoe_maxsectors;
|
||||
module_param(aoe_maxsectors, int, 0644);
|
||||
MODULE_PARM_DESC(aoe_maxsectors,
|
||||
"When nonzero, set the maximum number of sectors per I/O request");
|
||||
|
||||
static ssize_t aoedisk_show_state(struct device *dev,
|
||||
struct device_attribute *attr, char *page)
|
||||
{
|
||||
|
|
@ -59,7 +67,7 @@ static ssize_t aoedisk_show_netif(struct device *dev,
|
|||
nd = nds;
|
||||
ne = nd + ARRAY_SIZE(nds);
|
||||
t = d->targets;
|
||||
te = t + NTARGETS;
|
||||
te = t + d->ntargets;
|
||||
for (; t < te && *t; t++) {
|
||||
ifp = (*t)->ifs;
|
||||
e = ifp + NAOEIFS;
|
||||
|
|
@ -91,6 +99,14 @@ static ssize_t aoedisk_show_fwver(struct device *dev,
|
|||
|
||||
return snprintf(page, PAGE_SIZE, "0x%04x\n", (unsigned int) d->fw_ver);
|
||||
}
|
||||
static ssize_t aoedisk_show_payload(struct device *dev,
|
||||
struct device_attribute *attr, char *page)
|
||||
{
|
||||
struct gendisk *disk = dev_to_disk(dev);
|
||||
struct aoedev *d = disk->private_data;
|
||||
|
||||
return snprintf(page, PAGE_SIZE, "%lu\n", d->maxbcnt);
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(state, S_IRUGO, aoedisk_show_state, NULL);
|
||||
static DEVICE_ATTR(mac, S_IRUGO, aoedisk_show_mac, NULL);
|
||||
|
|
@ -99,12 +115,14 @@ static struct device_attribute dev_attr_firmware_version = {
|
|||
.attr = { .name = "firmware-version", .mode = S_IRUGO },
|
||||
.show = aoedisk_show_fwver,
|
||||
};
|
||||
static DEVICE_ATTR(payload, S_IRUGO, aoedisk_show_payload, NULL);
|
||||
|
||||
static struct attribute *aoe_attrs[] = {
|
||||
&dev_attr_state.attr,
|
||||
&dev_attr_mac.attr,
|
||||
&dev_attr_netif.attr,
|
||||
&dev_attr_firmware_version.attr,
|
||||
&dev_attr_payload.attr,
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
|
@ -129,9 +147,18 @@ aoeblk_open(struct block_device *bdev, fmode_t mode)
|
|||
struct aoedev *d = bdev->bd_disk->private_data;
|
||||
ulong flags;
|
||||
|
||||
if (!virt_addr_valid(d)) {
|
||||
pr_crit("aoe: invalid device pointer in %s\n",
|
||||
__func__);
|
||||
WARN_ON(1);
|
||||
return -ENODEV;
|
||||
}
|
||||
if (!(d->flags & DEVFL_UP) || d->flags & DEVFL_TKILL)
|
||||
return -ENODEV;
|
||||
|
||||
mutex_lock(&aoeblk_mutex);
|
||||
spin_lock_irqsave(&d->lock, flags);
|
||||
if (d->flags & DEVFL_UP) {
|
||||
if (d->flags & DEVFL_UP && !(d->flags & DEVFL_TKILL)) {
|
||||
d->nopen++;
|
||||
spin_unlock_irqrestore(&d->lock, flags);
|
||||
mutex_unlock(&aoeblk_mutex);
|
||||
|
|
@ -195,9 +222,38 @@ aoeblk_getgeo(struct block_device *bdev, struct hd_geometry *geo)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
aoeblk_ioctl(struct block_device *bdev, fmode_t mode, uint cmd, ulong arg)
|
||||
{
|
||||
struct aoedev *d;
|
||||
|
||||
if (!arg)
|
||||
return -EINVAL;
|
||||
|
||||
d = bdev->bd_disk->private_data;
|
||||
if ((d->flags & DEVFL_UP) == 0) {
|
||||
pr_err("aoe: disk not up\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
if (cmd == HDIO_GET_IDENTITY) {
|
||||
if (!copy_to_user((void __user *) arg, &d->ident,
|
||||
sizeof(d->ident)))
|
||||
return 0;
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
/* udev calls scsi_id, which uses SG_IO, resulting in noise */
|
||||
if (cmd != SG_IO)
|
||||
pr_info("aoe: unknown ioctl 0x%x\n", cmd);
|
||||
|
||||
return -ENOTTY;
|
||||
}
|
||||
|
||||
static const struct block_device_operations aoe_bdops = {
|
||||
.open = aoeblk_open,
|
||||
.release = aoeblk_release,
|
||||
.ioctl = aoeblk_ioctl,
|
||||
.getgeo = aoeblk_getgeo,
|
||||
.owner = THIS_MODULE,
|
||||
};
|
||||
|
|
@ -212,6 +268,18 @@ aoeblk_gdalloc(void *vp)
|
|||
struct request_queue *q;
|
||||
enum { KB = 1024, MB = KB * KB, READ_AHEAD = 2 * MB, };
|
||||
ulong flags;
|
||||
int late = 0;
|
||||
|
||||
spin_lock_irqsave(&d->lock, flags);
|
||||
if (d->flags & DEVFL_GDALLOC
|
||||
&& !(d->flags & DEVFL_TKILL)
|
||||
&& !(d->flags & DEVFL_GD_NOW))
|
||||
d->flags |= DEVFL_GD_NOW;
|
||||
else
|
||||
late = 1;
|
||||
spin_unlock_irqrestore(&d->lock, flags);
|
||||
if (late)
|
||||
return;
|
||||
|
||||
gd = alloc_disk(AOE_PARTITIONS);
|
||||
if (gd == NULL) {
|
||||
|
|
@ -231,23 +299,24 @@ aoeblk_gdalloc(void *vp)
|
|||
if (q == NULL) {
|
||||
pr_err("aoe: cannot allocate block queue for %ld.%d\n",
|
||||
d->aoemajor, d->aoeminor);
|
||||
mempool_destroy(mp);
|
||||
goto err_disk;
|
||||
goto err_mempool;
|
||||
}
|
||||
|
||||
d->blkq = blk_alloc_queue(GFP_KERNEL);
|
||||
if (!d->blkq)
|
||||
goto err_mempool;
|
||||
d->blkq->backing_dev_info.name = "aoe";
|
||||
if (bdi_init(&d->blkq->backing_dev_info))
|
||||
goto err_blkq;
|
||||
spin_lock_irqsave(&d->lock, flags);
|
||||
blk_queue_max_hw_sectors(d->blkq, BLK_DEF_MAX_SECTORS);
|
||||
WARN_ON(!(d->flags & DEVFL_GD_NOW));
|
||||
WARN_ON(!(d->flags & DEVFL_GDALLOC));
|
||||
WARN_ON(d->flags & DEVFL_TKILL);
|
||||
WARN_ON(d->gd);
|
||||
WARN_ON(d->flags & DEVFL_UP);
|
||||
blk_queue_max_hw_sectors(q, BLK_DEF_MAX_SECTORS);
|
||||
q->backing_dev_info.name = "aoe";
|
||||
q->backing_dev_info.ra_pages = READ_AHEAD / PAGE_CACHE_SIZE;
|
||||
d->bufpool = mp;
|
||||
d->blkq = gd->queue = q;
|
||||
q->queuedata = d;
|
||||
d->gd = gd;
|
||||
if (aoe_maxsectors)
|
||||
blk_queue_max_hw_sectors(q, aoe_maxsectors);
|
||||
gd->major = AOE_MAJOR;
|
||||
gd->first_minor = d->sysminor;
|
||||
gd->fops = &aoe_bdops;
|
||||
|
|
@ -263,18 +332,21 @@ aoeblk_gdalloc(void *vp)
|
|||
|
||||
add_disk(gd);
|
||||
aoedisk_add_sysfs(d);
|
||||
|
||||
spin_lock_irqsave(&d->lock, flags);
|
||||
WARN_ON(!(d->flags & DEVFL_GD_NOW));
|
||||
d->flags &= ~DEVFL_GD_NOW;
|
||||
spin_unlock_irqrestore(&d->lock, flags);
|
||||
return;
|
||||
|
||||
err_blkq:
|
||||
blk_cleanup_queue(d->blkq);
|
||||
d->blkq = NULL;
|
||||
err_mempool:
|
||||
mempool_destroy(d->bufpool);
|
||||
mempool_destroy(mp);
|
||||
err_disk:
|
||||
put_disk(gd);
|
||||
err:
|
||||
spin_lock_irqsave(&d->lock, flags);
|
||||
d->flags &= ~DEVFL_GDALLOC;
|
||||
d->flags &= ~DEVFL_GD_NOW;
|
||||
schedule_work(&d->work);
|
||||
spin_unlock_irqrestore(&d->lock, flags);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,11 @@ struct ErrMsg {
|
|||
};
|
||||
|
||||
static DEFINE_MUTEX(aoechr_mutex);
|
||||
|
||||
/* 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 completion emsgs_comp;
|
||||
|
|
@ -282,7 +287,7 @@ aoechr_init(void)
|
|||
int n, i;
|
||||
|
||||
n = register_chrdev(AOE_MAJOR, "aoechr", &aoe_fops);
|
||||
if (n < 0) {
|
||||
if (n < 0) {
|
||||
printk(KERN_ERR "aoe: can't register char device\n");
|
||||
return n;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -15,7 +15,6 @@
|
|||
#include "aoe.h"
|
||||
|
||||
static void dummy_timer(ulong);
|
||||
static void aoedev_freedev(struct aoedev *);
|
||||
static void freetgt(struct aoedev *d, struct aoetgt *t);
|
||||
static void skbpoolfree(struct aoedev *d);
|
||||
|
||||
|
|
@ -69,25 +68,34 @@ minor_get_static(ulong *sysminor, ulong aoemaj, int aoemin)
|
|||
NPERSHELF = 16,
|
||||
};
|
||||
|
||||
if (aoemin >= NPERSHELF) {
|
||||
pr_err("aoe: %s %d slots per shelf\n",
|
||||
"static minor device numbers support only",
|
||||
NPERSHELF);
|
||||
error = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
n = aoemaj * NPERSHELF + aoemin;
|
||||
if (aoemin >= NPERSHELF || n >= N_DEVS) {
|
||||
if (n >= N_DEVS) {
|
||||
pr_err("aoe: %s with e%ld.%d\n",
|
||||
"cannot use static minor device numbers",
|
||||
aoemaj, aoemin);
|
||||
error = -1;
|
||||
} else {
|
||||
spin_lock_irqsave(&used_minors_lock, flags);
|
||||
if (test_bit(n, used_minors)) {
|
||||
pr_err("aoe: %s %lu\n",
|
||||
"existing device already has static minor number",
|
||||
n);
|
||||
error = -1;
|
||||
} else
|
||||
set_bit(n, used_minors);
|
||||
spin_unlock_irqrestore(&used_minors_lock, flags);
|
||||
goto out;
|
||||
}
|
||||
|
||||
*sysminor = n;
|
||||
spin_lock_irqsave(&used_minors_lock, flags);
|
||||
if (test_bit(n, used_minors)) {
|
||||
pr_err("aoe: %s %lu\n",
|
||||
"existing device already has static minor number",
|
||||
n);
|
||||
error = -1;
|
||||
} else
|
||||
set_bit(n, used_minors);
|
||||
spin_unlock_irqrestore(&used_minors_lock, flags);
|
||||
*sysminor = n * AOE_PARTITIONS;
|
||||
out:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
|
@ -170,41 +178,50 @@ aoe_failip(struct aoedev *d)
|
|||
aoe_end_request(d, rq, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
downdev_frame(struct list_head *pos)
|
||||
{
|
||||
struct frame *f;
|
||||
|
||||
f = list_entry(pos, struct frame, head);
|
||||
list_del(pos);
|
||||
if (f->buf) {
|
||||
f->buf->nframesout--;
|
||||
aoe_failbuf(f->t->d, f->buf);
|
||||
}
|
||||
aoe_freetframe(f);
|
||||
}
|
||||
|
||||
void
|
||||
aoedev_downdev(struct aoedev *d)
|
||||
{
|
||||
struct aoetgt *t, **tt, **te;
|
||||
struct frame *f;
|
||||
struct list_head *head, *pos, *nx;
|
||||
struct request *rq;
|
||||
int i;
|
||||
|
||||
d->flags &= ~DEVFL_UP;
|
||||
|
||||
/* clean out active buffers */
|
||||
/* clean out active and to-be-retransmitted buffers */
|
||||
for (i = 0; i < NFACTIVE; i++) {
|
||||
head = &d->factive[i];
|
||||
list_for_each_safe(pos, nx, head) {
|
||||
f = list_entry(pos, struct frame, head);
|
||||
list_del(pos);
|
||||
if (f->buf) {
|
||||
f->buf->nframesout--;
|
||||
aoe_failbuf(d, f->buf);
|
||||
}
|
||||
aoe_freetframe(f);
|
||||
}
|
||||
list_for_each_safe(pos, nx, head)
|
||||
downdev_frame(pos);
|
||||
}
|
||||
head = &d->rexmitq;
|
||||
list_for_each_safe(pos, nx, head)
|
||||
downdev_frame(pos);
|
||||
|
||||
/* reset window dressings */
|
||||
tt = d->targets;
|
||||
te = tt + NTARGETS;
|
||||
te = tt + d->ntargets;
|
||||
for (; tt < te && (t = *tt); tt++) {
|
||||
t->maxout = t->nframes;
|
||||
aoecmd_wreset(t);
|
||||
t->nout = 0;
|
||||
}
|
||||
|
||||
/* clean out the in-process request (if any) */
|
||||
aoe_failip(d);
|
||||
d->htgt = NULL;
|
||||
|
||||
/* fast fail all pending I/O */
|
||||
if (d->blkq) {
|
||||
|
|
@ -218,12 +235,48 @@ aoedev_downdev(struct aoedev *d)
|
|||
set_capacity(d->gd, 0);
|
||||
}
|
||||
|
||||
/* return whether the user asked for this particular
|
||||
* device to be flushed
|
||||
*/
|
||||
static int
|
||||
user_req(char *s, size_t slen, struct aoedev *d)
|
||||
{
|
||||
char *p;
|
||||
size_t lim;
|
||||
|
||||
if (!d->gd)
|
||||
return 0;
|
||||
p = strrchr(d->gd->disk_name, '/');
|
||||
if (!p)
|
||||
p = d->gd->disk_name;
|
||||
else
|
||||
p += 1;
|
||||
lim = sizeof(d->gd->disk_name);
|
||||
lim -= p - d->gd->disk_name;
|
||||
if (slen < lim)
|
||||
lim = slen;
|
||||
|
||||
return !strncmp(s, p, lim);
|
||||
}
|
||||
|
||||
static void
|
||||
aoedev_freedev(struct aoedev *d)
|
||||
freedev(struct aoedev *d)
|
||||
{
|
||||
struct aoetgt **t, **e;
|
||||
int freeing = 0;
|
||||
unsigned long flags;
|
||||
|
||||
cancel_work_sync(&d->work);
|
||||
spin_lock_irqsave(&d->lock, flags);
|
||||
if (d->flags & DEVFL_TKILL
|
||||
&& !(d->flags & DEVFL_FREEING)) {
|
||||
d->flags |= DEVFL_FREEING;
|
||||
freeing = 1;
|
||||
}
|
||||
spin_unlock_irqrestore(&d->lock, flags);
|
||||
if (!freeing)
|
||||
return;
|
||||
|
||||
del_timer_sync(&d->timer);
|
||||
if (d->gd) {
|
||||
aoedisk_rm_sysfs(d);
|
||||
del_gendisk(d->gd);
|
||||
|
|
@ -231,61 +284,113 @@ aoedev_freedev(struct aoedev *d)
|
|||
blk_cleanup_queue(d->blkq);
|
||||
}
|
||||
t = d->targets;
|
||||
e = t + NTARGETS;
|
||||
e = t + d->ntargets;
|
||||
for (; t < e && *t; t++)
|
||||
freetgt(d, *t);
|
||||
if (d->bufpool)
|
||||
mempool_destroy(d->bufpool);
|
||||
skbpoolfree(d);
|
||||
minor_free(d->sysminor);
|
||||
kfree(d);
|
||||
|
||||
spin_lock_irqsave(&d->lock, flags);
|
||||
d->flags |= DEVFL_FREED;
|
||||
spin_unlock_irqrestore(&d->lock, flags);
|
||||
}
|
||||
|
||||
int
|
||||
aoedev_flush(const char __user *str, size_t cnt)
|
||||
enum flush_parms {
|
||||
NOT_EXITING = 0,
|
||||
EXITING = 1,
|
||||
};
|
||||
|
||||
static int
|
||||
flush(const char __user *str, size_t cnt, int exiting)
|
||||
{
|
||||
ulong flags;
|
||||
struct aoedev *d, **dd;
|
||||
struct aoedev *rmd = NULL;
|
||||
char buf[16];
|
||||
int all = 0;
|
||||
int specified = 0; /* flush a specific device */
|
||||
unsigned int skipflags;
|
||||
|
||||
if (cnt >= 3) {
|
||||
skipflags = DEVFL_GDALLOC | DEVFL_NEWSIZE | DEVFL_TKILL;
|
||||
|
||||
if (!exiting && cnt >= 3) {
|
||||
if (cnt > sizeof buf)
|
||||
cnt = sizeof buf;
|
||||
if (copy_from_user(buf, str, cnt))
|
||||
return -EFAULT;
|
||||
all = !strncmp(buf, "all", 3);
|
||||
if (!all)
|
||||
specified = 1;
|
||||
}
|
||||
|
||||
flush_scheduled_work();
|
||||
/* pass one: without sleeping, do aoedev_downdev */
|
||||
spin_lock_irqsave(&devlist_lock, flags);
|
||||
dd = &devlist;
|
||||
while ((d = *dd)) {
|
||||
for (d = devlist; d; d = d->next) {
|
||||
spin_lock(&d->lock);
|
||||
if ((!all && (d->flags & DEVFL_UP))
|
||||
|| (d->flags & (DEVFL_GDALLOC|DEVFL_NEWSIZE))
|
||||
if (exiting) {
|
||||
/* unconditionally take each device down */
|
||||
} else if (specified) {
|
||||
if (!user_req(buf, cnt, d))
|
||||
goto cont;
|
||||
} else if ((!all && (d->flags & DEVFL_UP))
|
||||
|| d->flags & skipflags
|
||||
|| d->nopen
|
||||
|| d->ref) {
|
||||
spin_unlock(&d->lock);
|
||||
dd = &d->next;
|
||||
continue;
|
||||
}
|
||||
*dd = d->next;
|
||||
|| d->ref)
|
||||
goto cont;
|
||||
|
||||
aoedev_downdev(d);
|
||||
d->flags |= DEVFL_TKILL;
|
||||
cont:
|
||||
spin_unlock(&d->lock);
|
||||
d->next = rmd;
|
||||
rmd = d;
|
||||
}
|
||||
spin_unlock_irqrestore(&devlist_lock, flags);
|
||||
while ((d = rmd)) {
|
||||
rmd = d->next;
|
||||
del_timer_sync(&d->timer);
|
||||
aoedev_freedev(d); /* must be able to sleep */
|
||||
|
||||
/* pass two: call freedev, which might sleep,
|
||||
* for aoedevs marked with DEVFL_TKILL
|
||||
*/
|
||||
restart:
|
||||
spin_lock_irqsave(&devlist_lock, flags);
|
||||
for (d = devlist; d; d = d->next) {
|
||||
spin_lock(&d->lock);
|
||||
if (d->flags & DEVFL_TKILL
|
||||
&& !(d->flags & DEVFL_FREEING)) {
|
||||
spin_unlock(&d->lock);
|
||||
spin_unlock_irqrestore(&devlist_lock, flags);
|
||||
freedev(d);
|
||||
goto restart;
|
||||
}
|
||||
spin_unlock(&d->lock);
|
||||
}
|
||||
|
||||
/* pass three: remove aoedevs marked with DEVFL_FREED */
|
||||
for (dd = &devlist, d = *dd; d; d = *dd) {
|
||||
struct aoedev *doomed = NULL;
|
||||
|
||||
spin_lock(&d->lock);
|
||||
if (d->flags & DEVFL_FREED) {
|
||||
*dd = d->next;
|
||||
doomed = d;
|
||||
} else {
|
||||
dd = &d->next;
|
||||
}
|
||||
spin_unlock(&d->lock);
|
||||
if (doomed)
|
||||
kfree(doomed->targets);
|
||||
kfree(doomed);
|
||||
}
|
||||
spin_unlock_irqrestore(&devlist_lock, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
aoedev_flush(const char __user *str, size_t cnt)
|
||||
{
|
||||
return flush(str, cnt, NOT_EXITING);
|
||||
}
|
||||
|
||||
/* This has been confirmed to occur once with Tms=3*1000 due to the
|
||||
* driver changing link and not processing its transmit ring. The
|
||||
* problem is hard enough to solve by returning an error that I'm
|
||||
|
|
@ -332,13 +437,20 @@ aoedev_by_aoeaddr(ulong maj, int min, int do_alloc)
|
|||
struct aoedev *d;
|
||||
int i;
|
||||
ulong flags;
|
||||
ulong sysminor;
|
||||
ulong sysminor = 0;
|
||||
|
||||
spin_lock_irqsave(&devlist_lock, flags);
|
||||
|
||||
for (d=devlist; d; d=d->next)
|
||||
if (d->aoemajor == maj && d->aoeminor == min) {
|
||||
spin_lock(&d->lock);
|
||||
if (d->flags & DEVFL_TKILL) {
|
||||
spin_unlock(&d->lock);
|
||||
d = NULL;
|
||||
goto out;
|
||||
}
|
||||
d->ref++;
|
||||
spin_unlock(&d->lock);
|
||||
break;
|
||||
}
|
||||
if (d || !do_alloc || minor_get(&sysminor, maj, min) < 0)
|
||||
|
|
@ -346,6 +458,13 @@ aoedev_by_aoeaddr(ulong maj, int min, int do_alloc)
|
|||
d = kcalloc(1, sizeof *d, GFP_ATOMIC);
|
||||
if (!d)
|
||||
goto out;
|
||||
d->targets = kcalloc(NTARGETS, sizeof(*d->targets), GFP_ATOMIC);
|
||||
if (!d->targets) {
|
||||
kfree(d);
|
||||
d = NULL;
|
||||
goto out;
|
||||
}
|
||||
d->ntargets = NTARGETS;
|
||||
INIT_WORK(&d->work, aoecmd_sleepwork);
|
||||
spin_lock_init(&d->lock);
|
||||
skb_queue_head_init(&d->skbpool);
|
||||
|
|
@ -359,10 +478,12 @@ aoedev_by_aoeaddr(ulong maj, int min, int do_alloc)
|
|||
d->ref = 1;
|
||||
for (i = 0; i < NFACTIVE; i++)
|
||||
INIT_LIST_HEAD(&d->factive[i]);
|
||||
INIT_LIST_HEAD(&d->rexmitq);
|
||||
d->sysminor = sysminor;
|
||||
d->aoemajor = maj;
|
||||
d->aoeminor = min;
|
||||
d->mintimer = MINTIMER;
|
||||
d->rttavg = RTTAVG_INIT;
|
||||
d->rttdev = RTTDEV_INIT;
|
||||
d->next = devlist;
|
||||
devlist = d;
|
||||
out:
|
||||
|
|
@ -396,21 +517,9 @@ freetgt(struct aoedev *d, struct aoetgt *t)
|
|||
void
|
||||
aoedev_exit(void)
|
||||
{
|
||||
struct aoedev *d;
|
||||
ulong flags;
|
||||
|
||||
flush_scheduled_work();
|
||||
aoe_flush_iocq();
|
||||
while ((d = devlist)) {
|
||||
devlist = d->next;
|
||||
|
||||
spin_lock_irqsave(&d->lock, flags);
|
||||
aoedev_downdev(d);
|
||||
d->flags |= DEVFL_TKILL;
|
||||
spin_unlock_irqrestore(&d->lock, flags);
|
||||
|
||||
del_timer_sync(&d->timer);
|
||||
aoedev_freedev(d);
|
||||
}
|
||||
flush(NULL, 0, EXITING);
|
||||
}
|
||||
|
||||
int __init
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ aoe_init(void)
|
|||
aoechr_exit();
|
||||
chr_fail:
|
||||
aoedev_exit();
|
||||
|
||||
|
||||
printk(KERN_INFO "aoe: initialisation failure.\n");
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ enum {
|
|||
|
||||
static char aoe_iflist[IFLISTSZ];
|
||||
module_param_string(aoe_iflist, aoe_iflist, IFLISTSZ, 0600);
|
||||
MODULE_PARM_DESC(aoe_iflist, "aoe_iflist=\"dev1 [dev2 ...]\"");
|
||||
MODULE_PARM_DESC(aoe_iflist, "aoe_iflist=dev1[,dev2...]");
|
||||
|
||||
static wait_queue_head_t txwq;
|
||||
static struct ktstate kts;
|
||||
|
|
@ -52,13 +52,18 @@ static struct sk_buff_head skbtxq;
|
|||
|
||||
/* enters with txlock held */
|
||||
static int
|
||||
tx(void)
|
||||
tx(void) __must_hold(&txlock)
|
||||
{
|
||||
struct sk_buff *skb;
|
||||
struct net_device *ifp;
|
||||
|
||||
while ((skb = skb_dequeue(&skbtxq))) {
|
||||
spin_unlock_irq(&txlock);
|
||||
dev_queue_xmit(skb);
|
||||
ifp = skb->dev;
|
||||
if (dev_queue_xmit(skb) == NET_XMIT_DROP && net_ratelimit())
|
||||
pr_warn("aoe: packet could not be sent on %s. %s\n",
|
||||
ifp ? ifp->name : "netif",
|
||||
"consider increasing tx_queue_len");
|
||||
spin_lock_irq(&txlock);
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -119,8 +124,8 @@ aoenet_xmit(struct sk_buff_head *queue)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (1) len doesn't include the header by default. I want this.
|
||||
/*
|
||||
* (1) len doesn't include the header by default. I want this.
|
||||
*/
|
||||
static int
|
||||
aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt, struct net_device *orig_dev)
|
||||
|
|
|
|||
Loading…
Reference in a new issue