]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/cifs/connect.c
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
[linux-2.6-omap-h63xx.git] / fs / cifs / connect.c
index 1126f7ab4606083635546ba8f485b7ae7940615b..e9f9248cb3feff13deeeb4d5eeae1d2a65f79ebe 100644 (file)
@@ -90,7 +90,10 @@ struct smb_vol {
        bool nocase:1;     /* request case insensitive filenames */
        bool nobrl:1;      /* disable sending byte range locks to srv */
        bool seal:1;       /* request transport encryption on share */
-       bool nodfs:1;
+       bool nodfs:1;      /* Do not request DFS, even if available */
+       bool local_lease:1; /* check leases only on local system, not remote */
+       bool noblocksnd:1;
+       bool noautotune:1;
        unsigned int rsize;
        unsigned int wsize;
        unsigned int sockopt;
@@ -101,9 +104,11 @@ struct smb_vol {
 static int ipv4_connect(struct sockaddr_in *psin_server,
                        struct socket **csocket,
                        char *netb_name,
-                       char *server_netb_name);
+                       char *server_netb_name,
+                       bool noblocksnd,
+                       bool nosndbuf); /* ipv6 never set sndbuf size */
 static int ipv6_connect(struct sockaddr_in6 *psin_server,
-                       struct socket **csocket);
+                       struct socket **csocket, bool noblocksnd);
 
 
        /*
@@ -190,12 +195,13 @@ cifs_reconnect(struct TCP_Server_Info *server)
                try_to_freeze();
                if (server->protocolType == IPV6) {
                        rc = ipv6_connect(&server->addr.sockAddr6,
-                                         &server->ssocket);
+                                         &server->ssocket, server->noautotune);
                } else {
                        rc = ipv4_connect(&server->addr.sockAddr,
                                        &server->ssocket,
                                        server->workstation_RFC1001_name,
-                                       server->server_RFC1001_name);
+                                       server->server_RFC1001_name,
+                                       server->noblocksnd, server->noautotune);
                }
                if (rc) {
                        cFYI(1, ("reconnect error %d", rc));
@@ -749,6 +755,7 @@ multi_t2_fnd:
        write_unlock(&GlobalSMBSeslock);
 
        kfree(server->hostname);
+       task_to_wake = xchg(&server->tsk, NULL);
        kfree(server);
 
        length = atomic_dec_return(&tcpSesAllocCount);
@@ -756,6 +763,16 @@ multi_t2_fnd:
                mempool_resize(cifs_req_poolp, length + cifs_min_rcv,
                                GFP_KERNEL);
 
+       /* if server->tsk was NULL then wait for a signal before exiting */
+       if (!task_to_wake) {
+               set_current_state(TASK_INTERRUPTIBLE);
+               while (!signal_pending(current)) {
+                       schedule();
+                       set_current_state(TASK_INTERRUPTIBLE);
+               }
+               set_current_state(TASK_RUNNING);
+       }
+
        return 0;
 }
 
@@ -1180,6 +1197,10 @@ cifs_parse_mount_options(char *options, const char *devname,
                        /* ignore */
                } else if (strnicmp(data, "rw", 2) == 0) {
                        vol->rw = true;
+               } else if (strnicmp(data, "noblocksend", 11) == 0) {
+                       vol->noblocksnd = 1;
+               } else if (strnicmp(data, "noautotune", 10) == 0) {
+                       vol->noautotune = 1;
                } else if ((strnicmp(data, "suid", 4) == 0) ||
                                   (strnicmp(data, "nosuid", 6) == 0) ||
                                   (strnicmp(data, "exec", 4) == 0) ||
@@ -1264,6 +1285,10 @@ cifs_parse_mount_options(char *options, const char *devname,
                        vol->no_psx_acl = 0;
                } else if (strnicmp(data, "noacl", 5) == 0) {
                        vol->no_psx_acl = 1;
+#ifdef CONFIG_CIFS_EXPERIMENTAL
+               } else if (strnicmp(data, "locallease", 6) == 0) {
+                       vol->local_lease = 1;
+#endif
                } else if (strnicmp(data, "sign", 4) == 0) {
                        vol->secFlg |= CIFSSEC_MUST_SIGN;
                } else if (strnicmp(data, "seal", 4) == 0) {
@@ -1502,7 +1527,8 @@ static void rfc1002mangle(char *target, char *source, unsigned int length)
 
 static int
 ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket,
-            char *netbios_name, char *target_name)
+            char *netbios_name, char *target_name,
+            bool noblocksnd, bool noautotune)
 {
        int rc = 0;
        int connected = 0;
@@ -1574,11 +1600,16 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket,
                 (*csocket)->sk->sk_sndbuf,
                 (*csocket)->sk->sk_rcvbuf, (*csocket)->sk->sk_rcvtimeo));
        (*csocket)->sk->sk_rcvtimeo = 7 * HZ;
+       if (!noblocksnd)
+               (*csocket)->sk->sk_sndtimeo = 3 * HZ;
+
        /* make the bufsizes depend on wsize/rsize and max requests */
-       if ((*csocket)->sk->sk_sndbuf < (200 * 1024))
-               (*csocket)->sk->sk_sndbuf = 200 * 1024;
-       if ((*csocket)->sk->sk_rcvbuf < (140 * 1024))
-               (*csocket)->sk->sk_rcvbuf = 140 * 1024;
+       if (noautotune) {
+               if ((*csocket)->sk->sk_sndbuf < (200 * 1024))
+                       (*csocket)->sk->sk_sndbuf = 200 * 1024;
+               if ((*csocket)->sk->sk_rcvbuf < (140 * 1024))
+                       (*csocket)->sk->sk_rcvbuf = 140 * 1024;
+       }
 
        /* send RFC1001 sessinit */
        if (psin_server->sin_port == htons(RFC1001_PORT)) {
@@ -1615,7 +1646,7 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket,
                        /* sizeof RFC1002_SESSION_REQUEST with no scope */
                        smb_buf->smb_buf_length = 0x81000044;
                        rc = smb_send(*csocket, smb_buf, 0x44,
-                               (struct sockaddr *)psin_server);
+                               (struct sockaddr *)psin_server, noblocksnd);
                        kfree(ses_init_buf);
                        msleep(1); /* RFC1001 layer in at least one server
                                      requires very short break before negprot
@@ -1635,7 +1666,8 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket,
 }
 
 static int
-ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket)
+ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket,
+            bool noblocksnd)
 {
        int rc = 0;
        int connected = 0;
@@ -1704,6 +1736,9 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket)
                the default. sock_setsockopt not used because it expects
                user space buffer */
        (*csocket)->sk->sk_rcvtimeo = 7 * HZ;
+       if (!noblocksnd)
+               (*csocket)->sk->sk_sndtimeo = 3 * HZ;
+
 
        return rc;
 }
@@ -1841,6 +1876,16 @@ convert_delimiter(char *path, char delim)
        }
 }
 
+static void
+kill_cifsd(struct TCP_Server_Info *server)
+{
+       struct task_struct *task;
+
+       task = xchg(&server->tsk, NULL);
+       if (task)
+               force_sig(SIGKILL, task);
+}
+
 int
 cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
           char *mount_data, const char *devname)
@@ -1957,11 +2002,14 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
                        cFYI(1, ("attempting ipv6 connect"));
                        /* BB should we allow ipv6 on port 139? */
                        /* other OS never observed in Wild doing 139 with v6 */
-                       rc = ipv6_connect(&sin_server6, &csocket);
+                       rc = ipv6_connect(&sin_server6, &csocket,
+                                       volume_info.noblocksnd);
                } else
                        rc = ipv4_connect(&sin_server, &csocket,
                                  volume_info.source_rfc1001_name,
-                                 volume_info.target_rfc1001_name);
+                                 volume_info.target_rfc1001_name,
+                                 volume_info.noblocksnd,
+                                 volume_info.noautotune);
                if (rc < 0) {
                        cERROR(1, ("Error connecting to IPv4 socket. "
                                   "Aborting operation"));
@@ -1976,6 +2024,8 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
                        sock_release(csocket);
                        goto out;
                } else {
+                       srvTcp->noblocksnd = volume_info.noblocksnd;
+                       srvTcp->noautotune = volume_info.noautotune;
                        memcpy(&srvTcp->addr.sockAddr, &sin_server,
                                sizeof(struct sockaddr_in));
                        atomic_set(&srvTcp->inFlight, 0);
@@ -2162,6 +2212,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
                           for the retry flag is used */
                        tcon->retry = volume_info.retry;
                        tcon->nocase = volume_info.nocase;
+                       tcon->local_lease = volume_info.local_lease;
                        if (tcon->seal != volume_info.seal)
                                cERROR(1, ("transport encryption setting "
                                           "conflicts with existing tid"));
@@ -2227,7 +2278,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
                        spin_lock(&GlobalMid_Lock);
                        srvTcp->tcpStatus = CifsExiting;
                        spin_unlock(&GlobalMid_Lock);
-                       force_sig(SIGKILL, srvTcp->tsk);
+                       kill_cifsd(srvTcp);
                }
                 /* If find_unc succeeded then rc == 0 so we can not end */
                if (tcon)  /* up accidently freeing someone elses tcon struct */
@@ -2240,19 +2291,15 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
                                        temp_rc = CIFSSMBLogoff(xid, pSesInfo);
                                        /* if the socketUseCount is now zero */
                                        if ((temp_rc == -ESHUTDOWN) &&
-                                           (pSesInfo->server) &&
-                                           (pSesInfo->server->tsk))
-                                               force_sig(SIGKILL,
-                                                       pSesInfo->server->tsk);
+                                           (pSesInfo->server))
+                                               kill_cifsd(pSesInfo->server);
                                } else {
                                        cFYI(1, ("No session or bad tcon"));
-                                       if ((pSesInfo->server) &&
-                                           (pSesInfo->server->tsk)) {
+                                       if (pSesInfo->server) {
                                                spin_lock(&GlobalMid_Lock);
                                                srvTcp->tcpStatus = CifsExiting;
                                                spin_unlock(&GlobalMid_Lock);
-                                               force_sig(SIGKILL,
-                                                       pSesInfo->server->tsk);
+                                               kill_cifsd(pSesInfo->server);
                                        }
                                }
                                sesInfoFree(pSesInfo);
@@ -3539,7 +3586,6 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb)
        int rc = 0;
        int xid;
        struct cifsSesInfo *ses = NULL;
-       struct task_struct *cifsd_task;
        char *tmp;
 
        xid = GetXid();
@@ -3555,7 +3601,6 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb)
                tconInfoFree(cifs_sb->tcon);
                if ((ses) && (ses->server)) {
                        /* save off task so we do not refer to ses later */
-                       cifsd_task = ses->server->tsk;
                        cFYI(1, ("About to do SMBLogoff "));
                        rc = CIFSSMBLogoff(xid, ses);
                        if (rc == -EBUSY) {
@@ -3563,8 +3608,8 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb)
                                return 0;
                        } else if (rc == -ESHUTDOWN) {
                                cFYI(1, ("Waking up socket by sending signal"));
-                               if (cifsd_task)
-                                       force_sig(SIGKILL, cifsd_task);
+                               if (ses->server)
+                                       kill_cifsd(ses->server);
                                rc = 0;
                        } /* else - we have an smb session
                                left on this socket do not kill cifsd */