Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / fs / cifs / cifs_debug.c
index 5ed3145..f4124a3 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *   fs/cifs_debug.c
  *
- *   Copyright (C) International Business Machines  Corp., 2000,2003
+ *   Copyright (C) International Business Machines  Corp., 2000,2005
  *
  *   Modified by Steve French (sfrench@us.ibm.com)
  *
@@ -29,6 +29,7 @@
 #include "cifsglob.h"
 #include "cifsproto.h"
 #include "cifs_debug.h"
+#include "cifsfs.h"
 
 void
 cifs_dump_mem(char *label, void *data, int length)
@@ -57,7 +58,7 @@ cifs_dump_mem(char *label, void *data, int length)
 }
 
 #ifdef CONFIG_PROC_FS
-int
+static int
 cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
                     int count, int *eof, void *data)
 {
@@ -78,8 +79,11 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
                    "Display Internal CIFS Data Structures for Debugging\n"
                    "---------------------------------------------------\n");
        buf += length;
-
-       length = sprintf(buf, "Servers:\n");
+       length = sprintf(buf,"CIFS Version %s\n",CIFS_VERSION);
+       buf += length;
+       length = sprintf(buf,"Active VFS Requests: %d\n", GlobalTotalActiveXid);
+       buf += length;
+       length = sprintf(buf, "Servers:");
        buf += length;
 
        i = 0;
@@ -87,19 +91,35 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
        list_for_each(tmp, &GlobalSMBSessionList) {
                i++;
                ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList);
-               length =
-                   sprintf(buf,
-                           "\n%d) Name: %s  Domain: %s Mounts: %d ServerOS: %s  \n\tServerNOS: %s\tCapabilities: 0x%x\n\tSMB session status: %d\tTCP status: %d",
-                               i, ses->serverName, ses->serverDomain, atomic_read(&ses->inUse),
-                               ses->serverOS, ses->serverNOS, ses->capabilities,ses->status,ses->server->tcpStatus);
-               buf += length;
+               if((ses->serverDomain == NULL) || (ses->serverOS == NULL) ||
+                  (ses->serverNOS == NULL)) {
+                       buf += sprintf("\nentry for %s not fully displayed\n\t",
+                                       ses->serverName);
+                       
+               } else {
+                       length =
+                           sprintf(buf,
+                                   "\n%d) Name: %s  Domain: %s Mounts: %d OS: %s  \n\tNOS: %s\tCapability: 0x%x\n\tSMB session status: %d\t",
+                               i, ses->serverName, ses->serverDomain,
+                               atomic_read(&ses->inUse),
+                               ses->serverOS, ses->serverNOS,
+                               ses->capabilities,ses->status);
+                       buf += length;
+               }
                if(ses->server) {
-                       buf += sprintf(buf, "\n\tLocal Users To Server: %d SecMode: 0x%x Req Active: %d",
+                       buf += sprintf(buf, "TCP status: %d\n\tLocal Users To Server: %d SecMode: 0x%x Req On Wire: %d",
+                               ses->server->tcpStatus,
                                atomic_read(&ses->server->socketUseCount),
                                ses->server->secMode,
                                atomic_read(&ses->server->inFlight));
-                       
-                       length = sprintf(buf, "\nMIDs: \n");
+
+#ifdef CONFIG_CIFS_STATS2
+                       buf += sprintf(buf, " In Send: %d In MaxReq Wait: %d",
+                               atomic_read(&ses->server->inSend), 
+                               atomic_read(&ses->server->num_waiters));
+#endif
+
+                       length = sprintf(buf, "\nMIDs:\n");
                        buf += length;
 
                        spin_lock(&GlobalMid_Lock);
@@ -108,7 +128,12 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
                                        mid_q_entry,
                                        qhead);
                                if(mid_entry) {
-                                       length = sprintf(buf,"State: %d com: %d pid: %d tsk: %p mid %d\n",mid_entry->midState,mid_entry->command,mid_entry->pid,mid_entry->tsk,mid_entry->mid);
+                                       length = sprintf(buf,"State: %d com: %d pid: %d tsk: %p mid %d\n",
+                                               mid_entry->midState,
+                                               (int)mid_entry->command,
+                                               mid_entry->pid,
+                                               mid_entry->tsk,
+                                               mid_entry->mid);
                                        buf += length;
                                }
                        }
@@ -120,32 +145,34 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
        sprintf(buf, "\n");
        buf++;
 
-       length = sprintf(buf, "\nShares:\n");
+       length = sprintf(buf, "Shares:");
        buf += length;
 
        i = 0;
        read_lock(&GlobalSMBSeslock);
        list_for_each(tmp, &GlobalTreeConnectionList) {
+               __u32 dev_type;
                i++;
                tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
+               dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType);
                length =
                    sprintf(buf,
-                           "\n%d) %s Uses: %d Type: %s Characteristics: 0x%x Attributes: 0x%x\nPathComponentMax: %d Status: %d",
+                           "\n%d) %s Uses: %d Type: %s DevInfo: 0x%x Attributes: 0x%x\nPathComponentMax: %d Status: %d",
                            i, tcon->treeName,
                            atomic_read(&tcon->useCount),
                            tcon->nativeFileSystem,
-                           tcon->fsDevInfo.DeviceCharacteristics,
-                           tcon->fsAttrInfo.Attributes,
-                           tcon->fsAttrInfo.MaxPathNameComponentLength,tcon->tidStatus);
+                           le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics),
+                           le32_to_cpu(tcon->fsAttrInfo.Attributes),
+                           le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength),
+                           tcon->tidStatus);
                buf += length;        
-               if (tcon->fsDevInfo.DeviceType == FILE_DEVICE_DISK)
+               if (dev_type == FILE_DEVICE_DISK)
                        length = sprintf(buf, " type: DISK ");
-               else if (tcon->fsDevInfo.DeviceType == FILE_DEVICE_CD_ROM)
+               else if (dev_type == FILE_DEVICE_CD_ROM)
                        length = sprintf(buf, " type: CDROM ");
                else
                        length =
-                           sprintf(buf, " type: %d ",
-                                   tcon->fsDevInfo.DeviceType);
+                           sprintf(buf, " type: %d ", dev_type);
                buf += length;
                if(tcon->tidStatus == CifsNeedReconnect) {
                        buf += sprintf(buf, "\tDISCONNECTED ");
@@ -176,7 +203,54 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
 }
 
 #ifdef CONFIG_CIFS_STATS
-int
+
+static int
+cifs_stats_write(struct file *file, const char __user *buffer,
+               unsigned long count, void *data)
+{
+        char c;
+        int rc;
+       struct list_head *tmp;
+       struct cifsTconInfo *tcon;
+
+        rc = get_user(c, buffer);
+        if (rc)
+                return rc;
+
+        if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
+               read_lock(&GlobalSMBSeslock);
+#ifdef CONFIG_CIFS_STATS2
+               atomic_set(&totBufAllocCount, 0);
+               atomic_set(&totSmBufAllocCount, 0);
+#endif /* CONFIG_CIFS_STATS2 */
+               list_for_each(tmp, &GlobalTreeConnectionList) {
+                       tcon = list_entry(tmp, struct cifsTconInfo,
+                                       cifsConnectionList);
+                       atomic_set(&tcon->num_smbs_sent, 0);
+                       atomic_set(&tcon->num_writes, 0);
+                       atomic_set(&tcon->num_reads, 0);
+                       atomic_set(&tcon->num_oplock_brks, 0);
+                       atomic_set(&tcon->num_opens, 0);
+                       atomic_set(&tcon->num_closes, 0);
+                       atomic_set(&tcon->num_deletes, 0);
+                       atomic_set(&tcon->num_mkdirs, 0);
+                       atomic_set(&tcon->num_rmdirs, 0);
+                       atomic_set(&tcon->num_renames, 0);
+                       atomic_set(&tcon->num_t2renames, 0);
+                       atomic_set(&tcon->num_ffirst, 0);
+                       atomic_set(&tcon->num_fnext, 0);
+                       atomic_set(&tcon->num_fclose, 0);
+                       atomic_set(&tcon->num_hardlinks, 0);
+                       atomic_set(&tcon->num_symlinks, 0);
+                       atomic_set(&tcon->num_locks, 0);
+               }
+               read_unlock(&GlobalSMBSeslock);
+       }
+
+        return count;
+}
+
+static int
 cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
                  int count, int *eof, void *data)
 {
@@ -196,10 +270,24 @@ cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
        length += item_length;
        buf += item_length;      
        item_length = 
-               sprintf(buf,"SMB Request/Response Buffer: %d\n",
-                       bufAllocCount.counter);
+               sprintf(buf,"SMB Request/Response Buffer: %d Pool size: %d\n",
+                       bufAllocCount.counter,
+                       cifs_min_rcv + tcpSesAllocCount.counter);
        length += item_length;
-       buf += item_length;      
+       buf += item_length;
+       item_length = 
+               sprintf(buf,"SMB Small Req/Resp Buffer: %d Pool size: %d\n",
+                       smBufAllocCount.counter,cifs_min_small);
+       length += item_length;
+       buf += item_length;
+#ifdef CONFIG_CIFS_STATS2
+        item_length = sprintf(buf, "Total Large %d Small %d Allocations\n",
+                               atomic_read(&totBufAllocCount),
+                               atomic_read(&totSmBufAllocCount));
+       length += item_length;
+       buf += item_length;
+#endif /* CONFIG_CIFS_STATS2 */
+
        item_length = 
                sprintf(buf,"Operations (MIDs): %d\n",
                        midCount.counter);
@@ -229,35 +317,51 @@ cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
                        buf += sprintf(buf, "\tDISCONNECTED ");
                        length += 14;
                }
-               item_length = sprintf(buf,"\nSMBs: %d Oplock Breaks: %d",
+               item_length = sprintf(buf, "\nSMBs: %d Oplock Breaks: %d",
                        atomic_read(&tcon->num_smbs_sent),
                        atomic_read(&tcon->num_oplock_brks));
                buf += item_length;
                length += item_length;
-               item_length = sprintf(buf,"\nReads: %d Bytes %lld",
+               item_length = sprintf(buf, "\nReads:  %d Bytes: %lld",
                        atomic_read(&tcon->num_reads),
                        (long long)(tcon->bytes_read));
                buf += item_length;
                length += item_length;
-               item_length = sprintf(buf,"\nWrites: %d Bytes: %lld",
+               item_length = sprintf(buf, "\nWrites: %d Bytes: %lld",
                        atomic_read(&tcon->num_writes),
                        (long long)(tcon->bytes_written));
+                buf += item_length;
+                length += item_length;
+                item_length = sprintf(buf, 
+                       "\nLocks: %d HardLinks: %d Symlinks: %d",
+                        atomic_read(&tcon->num_locks),
+                       atomic_read(&tcon->num_hardlinks),
+                       atomic_read(&tcon->num_symlinks));
+                buf += item_length;
+                length += item_length;
+
+               item_length = sprintf(buf, "\nOpens: %d Closes: %d Deletes: %d",
+                       atomic_read(&tcon->num_opens),
+                       atomic_read(&tcon->num_closes),
+                       atomic_read(&tcon->num_deletes));
                buf += item_length;
                length += item_length;
-               item_length = sprintf(buf,
-                       "\nOpens: %d Deletes: %d\nMkdirs: %d Rmdirs: %d",
-                       atomic_read(&tcon->num_opens),
-                       atomic_read(&tcon->num_deletes),
+               item_length = sprintf(buf, "\nMkdirs: %d Rmdirs: %d",
                        atomic_read(&tcon->num_mkdirs),
                        atomic_read(&tcon->num_rmdirs));
                buf += item_length;
                length += item_length;
-               item_length = sprintf(buf,
-                       "\nRenames: %d T2 Renames %d",
+               item_length = sprintf(buf, "\nRenames: %d T2 Renames %d",
                        atomic_read(&tcon->num_renames),
                        atomic_read(&tcon->num_t2renames));
                buf += item_length;
                length += item_length;
+               item_length = sprintf(buf, "\nFindFirst: %d FNext %d FClose %d",
+                       atomic_read(&tcon->num_ffirst),
+                       atomic_read(&tcon->num_fnext),
+                       atomic_read(&tcon->num_fclose));
+               buf += item_length;
+               length += item_length;
        }
        read_unlock(&GlobalSMBSeslock);
 
@@ -279,7 +383,7 @@ cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
 }
 #endif
 
-struct proc_dir_entry *proc_fs_cifs;
+static struct proc_dir_entry *proc_fs_cifs;
 read_proc_t cifs_txanchor_read;
 static read_proc_t cifsFYI_read;
 static write_proc_t cifsFYI_write;
@@ -297,8 +401,8 @@ static read_proc_t ntlmv2_enabled_read;
 static write_proc_t ntlmv2_enabled_write;
 static read_proc_t packet_signing_enabled_read;
 static write_proc_t packet_signing_enabled_write;
-static read_proc_t quotaEnabled_read;
-static write_proc_t quotaEnabled_write;
+static read_proc_t experimEnabled_read;
+static write_proc_t experimEnabled_write;
 static read_proc_t linuxExtensionsEnabled_read;
 static write_proc_t linuxExtensionsEnabled_write;
 
@@ -316,8 +420,10 @@ cifs_proc_init(void)
                                cifs_debug_data_read, NULL);
 
 #ifdef CONFIG_CIFS_STATS
-       create_proc_read_entry("Stats", 0, proc_fs_cifs,
+       pde = create_proc_read_entry("Stats", 0, proc_fs_cifs,
                                cifs_stats_read, NULL);
+       if (pde)
+               pde->write_proc = cifs_stats_write;
 #endif
        pde = create_proc_read_entry("cifsFYI", 0, proc_fs_cifs,
                                cifsFYI_read, NULL);
@@ -335,10 +441,10 @@ cifs_proc_init(void)
        if (pde)
                pde->write_proc = oplockEnabled_write;
 
-       pde = create_proc_read_entry("QuotaEnabled", 0, proc_fs_cifs,
-                               quotaEnabled_read, NULL);
+       pde = create_proc_read_entry("Experimental", 0, proc_fs_cifs,
+                               experimEnabled_read, NULL);
        if (pde)
-               pde->write_proc = quotaEnabled_write;
+               pde->write_proc = experimEnabled_write;
 
        pde = create_proc_read_entry("LinuxExtensionsEnabled", 0, proc_fs_cifs,
                                linuxExtensionsEnabled_read, NULL);
@@ -394,7 +500,7 @@ cifs_proc_clean(void)
        remove_proc_entry("ExtendedSecurity",proc_fs_cifs);
        remove_proc_entry("PacketSigningEnabled",proc_fs_cifs);
        remove_proc_entry("LinuxExtensionsEnabled",proc_fs_cifs);
-       remove_proc_entry("QuotaEnabled",proc_fs_cifs);
+       remove_proc_entry("Experimental",proc_fs_cifs);
        remove_proc_entry("LookupCacheEnabled",proc_fs_cifs);
        remove_proc_entry("cifs", proc_root_fs);
 }
@@ -434,6 +540,8 @@ cifsFYI_write(struct file *file, const char __user *buffer,
                cifsFYI = 0;
        else if (c == '1' || c == 'y' || c == 'Y')
                cifsFYI = 1;
+       else if((c > '1') && (c <= '9'))
+               cifsFYI = (int) (c - '0'); /* see cifs_debug.h for meanings */
 
        return count;
 }
@@ -478,14 +586,13 @@ oplockEnabled_write(struct file *file, const char __user *buffer,
 }
 
 static int
-quotaEnabled_read(char *page, char **start, off_t off,
+experimEnabled_read(char *page, char **start, off_t off,
                    int count, int *eof, void *data)
 {
         int len;
 
-        len = sprintf(page, "%d\n", quotaEnabled);
-/* could also check if quotas are enabled in kernel
-       as a whole first */
+        len = sprintf(page, "%d\n", experimEnabled);
+
         len -= off;
         *start = page + off;
 
@@ -500,21 +607,23 @@ quotaEnabled_read(char *page, char **start, off_t off,
         return len;
 }
 static int
-quotaEnabled_write(struct file *file, const char __user *buffer,
+experimEnabled_write(struct file *file, const char __user *buffer,
                     unsigned long count, void *data)
 {
-        char c;
-        int rc;
+       char c;
+       int rc;
 
-        rc = get_user(c, buffer);
-        if (rc)
-                return rc;
-        if (c == '0' || c == 'n' || c == 'N')
-                quotaEnabled = 0;
-        else if (c == '1' || c == 'y' || c == 'Y')
-                quotaEnabled = 1;
+       rc = get_user(c, buffer);
+       if (rc)
+               return rc;
+       if (c == '0' || c == 'n' || c == 'N')
+               experimEnabled = 0;
+       else if (c == '1' || c == 'y' || c == 'Y')
+               experimEnabled = 1;
+       else if (c == '2')
+               experimEnabled = 2;
 
-        return count;
+       return count;
 }
 
 static int
@@ -524,8 +633,6 @@ linuxExtensionsEnabled_read(char *page, char **start, off_t off,
         int len;
 
         len = sprintf(page, "%d\n", linuxExtEnabled);
-/* could also check if quotas are enabled in kernel
-       as a whole first */
         len -= off;
         *start = page + off;