autofs4: change log print macros to not insert newline
[linux-2.6-block.git] / fs / autofs4 / waitq.c
index 2ad05ab93db86efe0e4d0432b7ed8f1f37a0dd52..169ba871b86c1cb1fb1cb44a6f36060551117fa5 100644 (file)
@@ -1,15 +1,11 @@
-/* -*- c -*- --------------------------------------------------------------- *
- *
- * linux/fs/autofs/waitq.c
- *
- *  Copyright 1997-1998 Transmeta Corporation -- All Rights Reserved
- *  Copyright 2001-2006 Ian Kent <raven@themaw.net>
+/*
+ * Copyright 1997-1998 Transmeta Corporation -- All Rights Reserved
+ * Copyright 2001-2006 Ian Kent <raven@themaw.net>
  *
  * This file is part of the Linux kernel and is made available under
  * the terms of the GNU General Public License, version 2, or at your
  * option, any later version, incorporated herein by reference.
- *
- * ------------------------------------------------------------------------- */
+ */
 
 #include <linux/slab.h>
 #include <linux/time.h>
@@ -18,7 +14,8 @@
 #include "autofs_i.h"
 
 /* We make this a static variable rather than a part of the superblock; it
-   is better if we don't reassign numbers easily even across filesystems */
+ * is better if we don't reassign numbers easily even across filesystems
+ */
 static autofs_wqt_t autofs4_next_wait_queue = 1;
 
 /* These are the signals we allow interrupting a pending mount */
@@ -34,7 +31,7 @@ void autofs4_catatonic_mode(struct autofs_sb_info *sbi)
                return;
        }
 
-       DPRINTK("entering catatonic mode");
+       DPRINTK("entering catatonic mode\n");
 
        sbi->catatonic = 1;
        wq = sbi->queues;
@@ -69,17 +66,19 @@ static int autofs4_write(struct autofs_sb_info *sbi,
        set_fs(KERNEL_DS);
 
        mutex_lock(&sbi->pipe_mutex);
-       while (bytes &&
-              (wr = __vfs_write(file,data,bytes,&file->f_pos)) > 0) {
+       wr = __vfs_write(file, data, bytes, &file->f_pos);
+       while (bytes && wr) {
                data += wr;
                bytes -= wr;
+               wr = __vfs_write(file, data, bytes, &file->f_pos);
        }
        mutex_unlock(&sbi->pipe_mutex);
 
        set_fs(fs);
 
        /* Keep the currently executing process from receiving a
-          SIGPIPE unless it was already supposed to get one */
+        * SIGPIPE unless it was already supposed to get one
+        */
        if (wr == -EPIPE && !sigpipe) {
                spin_lock_irqsave(&current->sighand->siglock, flags);
                sigdelset(&current->pending.signal, SIGPIPE);
@@ -89,7 +88,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
 
        return (bytes > 0);
 }
-       
+
 static void autofs4_notify_daemon(struct autofs_sb_info *sbi,
                                 struct autofs_wait_queue *wq,
                                 int type)
@@ -102,10 +101,11 @@ static void autofs4_notify_daemon(struct autofs_sb_info *sbi,
        struct file *pipe = NULL;
        size_t pktsz;
 
-       DPRINTK("wait id = 0x%08lx, name = %.*s, type=%d",
-               (unsigned long) wq->wait_queue_token, wq->name.len, wq->name.name, type);
+       DPRINTK("wait id = 0x%08lx, name = %.*s, type=%d\n",
+               (unsigned long) 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 */
 
        pkt.hdr.proto_version = sbi->version;
        pkt.hdr.type = type;
@@ -126,7 +126,8 @@ static void autofs4_notify_daemon(struct autofs_sb_info *sbi,
        }
        case autofs_ptype_expire_multi:
        {
-               struct autofs_packet_expire_multi *ep = &pkt.v4_pkt.expire_multi;
+               struct autofs_packet_expire_multi *ep =
+                                       &pkt.v4_pkt.expire_multi;
 
                pktsz = sizeof(*ep);
 
@@ -163,7 +164,7 @@ static void autofs4_notify_daemon(struct autofs_sb_info *sbi,
                break;
        }
        default:
-               printk("autofs4_notify_daemon: bad type %d!\n", type);
+               AUTOFS_WARN("bad type %d!\n", type);
                mutex_unlock(&sbi->wq_mutex);
                return;
        }
@@ -231,7 +232,7 @@ autofs4_find_wait(struct autofs_sb_info *sbi, struct qstr *qstr)
                if (wq->name.hash == qstr->hash &&
                    wq->name.len == qstr->len &&
                    wq->name.name &&
-                        !memcmp(wq->name.name, qstr->name, qstr->len))
+                   !memcmp(wq->name.name, qstr->name, qstr->len))
                        break;
        }
        return wq;
@@ -248,7 +249,7 @@ autofs4_find_wait(struct autofs_sb_info *sbi, struct qstr *qstr)
 static int validate_request(struct autofs_wait_queue **wait,
                            struct autofs_sb_info *sbi,
                            struct qstr *qstr,
-                           struct dentry*dentry, enum autofs_notify notify)
+                           struct dentry *dentry, enum autofs_notify notify)
 {
        struct autofs_wait_queue *wq;
        struct autofs_info *ino;
@@ -322,8 +323,10 @@ static int validate_request(struct autofs_wait_queue **wait,
                 * continue on and create a new request.
                 */
                if (!IS_ROOT(dentry)) {
-                       if (dentry->d_inode && d_unhashed(dentry)) {
+                       if (d_unhashed(dentry) &&
+                           d_really_is_positive(dentry)) {
                                struct dentry *parent = dentry->d_parent;
+
                                new = d_lookup(parent, &dentry->d_name);
                                if (new)
                                        dentry = new;
@@ -340,8 +343,8 @@ static int validate_request(struct autofs_wait_queue **wait,
        return 1;
 }
 
-int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
-               enum autofs_notify notify)
+int autofs4_wait(struct autofs_sb_info *sbi,
+                struct dentry *dentry, enum autofs_notify notify)
 {
        struct autofs_wait_queue *wq;
        struct qstr qstr;
@@ -364,7 +367,7 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
        if (pid == 0 || tgid == 0)
                return -ENOENT;
 
-       if (!dentry->d_inode) {
+       if (d_really_is_negative(dentry)) {
                /*
                 * A wait for a negative dentry is invalid for certain
                 * cases. A direct or offset mount "always" has its mount
@@ -411,7 +414,7 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
 
        if (!wq) {
                /* Create a new wait queue */
-               wq = kmalloc(sizeof(struct autofs_wait_queue),GFP_KERNEL);
+               wq = kmalloc(sizeof(struct autofs_wait_queue), GFP_KERNEL);
                if (!wq) {
                        kfree(qstr.name);
                        mutex_unlock(&sbi->wq_mutex);
@@ -454,11 +457,13 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
                        (unsigned long) wq->wait_queue_token, wq->name.len,
                        wq->name.name, notify);
 
-               /* autofs4_notify_daemon() may block; it will unlock ->wq_mutex */
+               /*
+                * autofs4_notify_daemon() may block; it will unlock ->wq_mutex
+                */
                autofs4_notify_daemon(sbi, wq, type);
        } else {
                wq->wait_ctr++;
-               DPRINTK("existing wait id = 0x%08lx, name = %.*s, nfy=%d",
+               DPRINTK("existing wait id = 0x%08lx, name = %.*s, nfy=%d\n",
                        (unsigned long) wq->wait_queue_token, wq->name.len,
                        wq->name.name, notify);
                mutex_unlock(&sbi->wq_mutex);
@@ -471,12 +476,14 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
         */
        if (wq->name.name) {
                /* Block all but "shutdown" signals while waiting */
-               sigset_t oldset;
+               unsigned long shutdown_sigs_mask;
                unsigned long irqflags;
+               sigset_t oldset;
 
                spin_lock_irqsave(&current->sighand->siglock, irqflags);
                oldset = current->blocked;
-               siginitsetinv(&current->blocked, SHUTDOWN_SIGS & ~oldset.sig[0]);
+               shutdown_sigs_mask = SHUTDOWN_SIGS & ~oldset.sig[0];
+               siginitsetinv(&current->blocked, shutdown_sigs_mask);
                recalc_sigpending();
                spin_unlock_irqrestore(&current->sighand->siglock, irqflags);
 
@@ -487,7 +494,7 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
                recalc_sigpending();
                spin_unlock_irqrestore(&current->sighand->siglock, irqflags);
        } else {
-               DPRINTK("skipped sleeping");
+               DPRINTK("skipped sleeping\n");
        }
 
        status = wq->status;
@@ -562,4 +569,3 @@ int autofs4_wait_release(struct autofs_sb_info *sbi, autofs_wqt_t wait_queue_tok
 
        return 0;
 }
-