The autofs_wait_queue already contains all of the fields of the
struct qstr, so change it into a qstr.
This patch, from Jeff Moyer, has been modified a liitle by myself.
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Ian Kent <raven@themaw.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
struct autofs_wait_queue *next;
autofs_wqt_t wait_queue_token;
/* We use the following to see what we are waiting for */
struct autofs_wait_queue *next;
autofs_wqt_t wait_queue_token;
/* We use the following to see what we are waiting for */
- unsigned int hash;
- unsigned int len;
- char *name;
u32 dev;
u64 ino;
uid_t uid;
u32 dev;
u64 ino;
uid_t uid;
while (wq) {
nwq = wq->next;
wq->status = -ENOENT; /* Magic is gone - report failure */
while (wq) {
nwq = wq->next;
wq->status = -ENOENT; /* Magic is gone - report failure */
- kfree(wq->name);
- wq->name = NULL;
+ if (wq->name.name) {
+ kfree(wq->name.name);
+ wq->name.name = NULL;
+ }
wake_up_interruptible(&wq->queue);
wq = nwq;
}
wake_up_interruptible(&wq->queue);
wq = nwq;
}
size_t pktsz;
DPRINTK("wait id = 0x%08lx, name = %.*s, type=%d",
size_t pktsz;
DPRINTK("wait id = 0x%08lx, name = %.*s, type=%d",
- wq->wait_queue_token, wq->len, wq->name, type);
+ wq->wait_queue_token, wq->name.len, wq->name.name, type);
memset(&pkt,0,sizeof pkt); /* For security reasons */
memset(&pkt,0,sizeof pkt); /* For security reasons */
pktsz = sizeof(*mp);
mp->wait_queue_token = wq->wait_queue_token;
pktsz = sizeof(*mp);
mp->wait_queue_token = wq->wait_queue_token;
- mp->len = wq->len;
- memcpy(mp->name, wq->name, wq->len);
- mp->name[wq->len] = '\0';
+ mp->len = wq->name.len;
+ memcpy(mp->name, wq->name.name, wq->name.len);
+ mp->name[wq->name.len] = '\0';
break;
}
case autofs_ptype_expire_multi:
break;
}
case autofs_ptype_expire_multi:
pktsz = sizeof(*ep);
ep->wait_queue_token = wq->wait_queue_token;
pktsz = sizeof(*ep);
ep->wait_queue_token = wq->wait_queue_token;
- ep->len = wq->len;
- memcpy(ep->name, wq->name, wq->len);
- ep->name[wq->len] = '\0';
+ ep->len = wq->name.len;
+ memcpy(ep->name, wq->name.name, wq->name.len);
+ ep->name[wq->name.len] = '\0';
pktsz = sizeof(*packet);
packet->wait_queue_token = wq->wait_queue_token;
pktsz = sizeof(*packet);
packet->wait_queue_token = wq->wait_queue_token;
- packet->len = wq->len;
- memcpy(packet->name, wq->name, wq->len);
- packet->name[wq->len] = '\0';
+ packet->len = wq->name.len;
+ memcpy(packet->name, wq->name.name, wq->name.len);
+ packet->name[wq->name.len] = '\0';
packet->dev = wq->dev;
packet->ino = wq->ino;
packet->uid = wq->uid;
packet->dev = wq->dev;
packet->ino = wq->ino;
packet->uid = wq->uid;
}
static struct autofs_wait_queue *
}
static struct autofs_wait_queue *
-autofs4_find_wait(struct autofs_sb_info *sbi,
- char *name, unsigned int hash, unsigned int len)
+autofs4_find_wait(struct autofs_sb_info *sbi, struct qstr *qstr)
{
struct autofs_wait_queue *wq;
for (wq = sbi->queues; wq; wq = wq->next) {
{
struct autofs_wait_queue *wq;
for (wq = sbi->queues; wq; wq = wq->next) {
- if (wq->hash == hash &&
- wq->len == len &&
- wq->name && !memcmp(wq->name, name, len))
+ if (wq->name.hash == qstr->hash &&
+ wq->name.len == qstr->len &&
+ wq->name.name &&
+ !memcmp(wq->name.name, qstr->name, qstr->len))
{
struct autofs_info *ino;
struct autofs_wait_queue *wq;
{
struct autofs_info *ino;
struct autofs_wait_queue *wq;
- unsigned int len = 0;
- unsigned int hash = 0;
int status, type;
/* In catatonic mode, we don't wait for nobody */
int status, type;
/* In catatonic mode, we don't wait for nobody */
/* If this is a direct mount request create a dummy name */
if (IS_ROOT(dentry) && (sbi->type & AUTOFS_TYPE_DIRECT))
/* If this is a direct mount request create a dummy name */
if (IS_ROOT(dentry) && (sbi->type & AUTOFS_TYPE_DIRECT))
- len = sprintf(name, "%p", dentry);
+ qstr.len = sprintf(name, "%p", dentry);
- len = autofs4_getpath(sbi, dentry, &name);
- if (!len) {
+ qstr.len = autofs4_getpath(sbi, dentry, &name);
+ if (!qstr.len) {
kfree(name);
return -ENOENT;
}
}
kfree(name);
return -ENOENT;
}
}
- hash = full_name_hash(name, len);
+ qstr.name = name;
+ qstr.hash = full_name_hash(name, qstr.len);
if (mutex_lock_interruptible(&sbi->wq_mutex)) {
if (mutex_lock_interruptible(&sbi->wq_mutex)) {
- wq = autofs4_find_wait(sbi, name, hash, len);
+ wq = autofs4_find_wait(sbi, &qstr);
ino = autofs4_dentry_ino(dentry);
if (!wq && ino && notify == NFY_NONE) {
/*
ino = autofs4_dentry_ino(dentry);
if (!wq && ino && notify == NFY_NONE) {
/*
mutex_unlock(&sbi->wq_mutex);
schedule_timeout_interruptible(HZ/10);
if (mutex_lock_interruptible(&sbi->wq_mutex)) {
mutex_unlock(&sbi->wq_mutex);
schedule_timeout_interruptible(HZ/10);
if (mutex_lock_interruptible(&sbi->wq_mutex)) {
- wq = autofs4_find_wait(sbi, name, hash, len);
+ wq = autofs4_find_wait(sbi, &qstr);
* return status of the wait.
*/
if (!wq) {
* return status of the wait.
*/
if (!wq) {
mutex_unlock(&sbi->wq_mutex);
return 0;
}
mutex_unlock(&sbi->wq_mutex);
return 0;
}
/* Create a new wait queue */
wq = kmalloc(sizeof(struct autofs_wait_queue),GFP_KERNEL);
if (!wq) {
/* Create a new wait queue */
wq = kmalloc(sizeof(struct autofs_wait_queue),GFP_KERNEL);
if (!wq) {
mutex_unlock(&sbi->wq_mutex);
return -ENOMEM;
}
mutex_unlock(&sbi->wq_mutex);
return -ENOMEM;
}
wq->next = sbi->queues;
sbi->queues = wq;
init_waitqueue_head(&wq->queue);
wq->next = sbi->queues;
sbi->queues = wq;
init_waitqueue_head(&wq->queue);
- wq->hash = hash;
- wq->name = name;
- wq->len = len;
+ memcpy(&wq->name, &qstr, sizeof(struct qstr));
wq->dev = autofs4_get_dev(sbi);
wq->ino = autofs4_get_ino(sbi);
wq->uid = current->uid;
wq->dev = autofs4_get_dev(sbi);
wq->ino = autofs4_get_ino(sbi);
wq->uid = current->uid;
}
DPRINTK("new wait id = 0x%08lx, name = %.*s, nfy=%d\n",
}
DPRINTK("new wait id = 0x%08lx, name = %.*s, nfy=%d\n",
- (unsigned long) wq->wait_queue_token, wq->len, wq->name, notify);
+ (unsigned long) wq->wait_queue_token, wq->name.len,
+ wq->name.name, notify);
/* autofs4_notify_daemon() may block */
autofs4_notify_daemon(sbi, wq, type);
} else {
atomic_inc(&wq->wait_ctr);
mutex_unlock(&sbi->wq_mutex);
/* autofs4_notify_daemon() may block */
autofs4_notify_daemon(sbi, wq, type);
} else {
atomic_inc(&wq->wait_ctr);
mutex_unlock(&sbi->wq_mutex);
DPRINTK("existing wait id = 0x%08lx, name = %.*s, nfy=%d",
DPRINTK("existing wait id = 0x%08lx, name = %.*s, nfy=%d",
- (unsigned long) wq->wait_queue_token, wq->len, wq->name, notify);
+ (unsigned long) wq->wait_queue_token, wq->name.len,
+ wq->name.name, notify);
}
/* wq->name is NULL if and only if the lock is already released */
}
/* wq->name is NULL if and only if the lock is already released */
if (sbi->catatonic) {
/* We might have slept, so check again for catatonic mode */
wq->status = -ENOENT;
if (sbi->catatonic) {
/* We might have slept, so check again for catatonic mode */
wq->status = -ENOENT;
- kfree(wq->name);
- wq->name = NULL;
+ if (wq->name.name) {
+ kfree(wq->name.name);
+ wq->name.name = NULL;
+ }
/* Block all but "shutdown" signals while waiting */
sigset_t oldset;
unsigned long irqflags;
/* Block all but "shutdown" signals while waiting */
sigset_t oldset;
unsigned long irqflags;
recalc_sigpending();
spin_unlock_irqrestore(¤t->sighand->siglock, irqflags);
recalc_sigpending();
spin_unlock_irqrestore(¤t->sighand->siglock, irqflags);
- wait_event_interruptible(wq->queue, wq->name == NULL);
+ wait_event_interruptible(wq->queue, wq->name.name == NULL);
spin_lock_irqsave(¤t->sighand->siglock, irqflags);
current->blocked = oldset;
spin_lock_irqsave(¤t->sighand->siglock, irqflags);
current->blocked = oldset;
*wql = wq->next; /* Unlink from chain */
mutex_unlock(&sbi->wq_mutex);
*wql = wq->next; /* Unlink from chain */
mutex_unlock(&sbi->wq_mutex);
- kfree(wq->name);
- wq->name = NULL; /* Do not wait on this queue */
+ kfree(wq->name.name);
+ wq->name.name = NULL; /* Do not wait on this queue */