CTC++ Coverage Report - Execution Profile    #852/1532

Files Summary | Functions Summary | Execution Profile | Index | No Index
First | Previous | Next | Last


File: fs/cifs/cifs_debug.c
Instrumentation mode: function-decision-multicondition
TER: 4 % ( 12/337)

Start/ End/    
True False - Line Source

  1 /*
  2  *   fs/cifs_debug.c
  3  *
  4  *   Copyright (C) International Business Machines  Corp., 2000,2005
  5  *
  6  *   Modified by Steve French (sfrench@us.ibm.com)
  7  *
  8  *   This program is free software;  you can redistribute it and/or modify
  9  *   it under the terms of the GNU General Public License as published by
  10  *   the Free Software Foundation; either version 2 of the License, or 
  11  *   (at your option) any later version.
  12  * 
  13  *   This program is distributed in the hope that it will be useful,
  14  *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
  15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
  16  *   the GNU General Public License for more details.
  17  *
  18  *   You should have received a copy of the GNU General Public License
  19  *   along with this program;  if not, write to the Free Software 
  20  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21  */
  22 #include <linux/fs.h>
  23 #include <linux/string.h>
  24 #include <linux/ctype.h>
  25 #include <linux/module.h>
  26 #include <linux/proc_fs.h>
  27 #include <asm/uaccess.h>
  28 #include "cifspdu.h"
  29 #include "cifsglob.h"
  30 #include "cifsproto.h"
  31 #include "cifs_debug.h"
  32 #include "cifsfs.h"
  33 
  34 void
 
- 35 cifs_dump_mem(char *label, void *data, int length)
  36 {
  37    int i, j;
  38    int *intptr = data;
  39    char *charptr = data;
  40    char buf[10], line[80];
  41 
  42    printk(KERN_DEBUG "%s: dump of %d bytes of data at 0x%p\n\n", 
  43       label, length, data);
- 44    for (i = 0; i < length; i += 16) {
  45       line[0] = 0;
- 46       for (j = 0; (j < 4) && (i + j * 4 < length); j++) {
 - 46     (T) && (T)
 - 46     (T) && (F)
 - 46     (F) && (_)
  47          sprintf(buf, " %08x", intptr[i / 4 + j]);
  48          strcat(line, buf);
  49       }
  50       buf[0] = ' ';
  51       buf[2] = 0;
- 52       for (j = 0; (j < 16) && (i + j < length); j++) {
 - 52     (T) && (T)
 - 52     (T) && (F)
 - 52     (F) && (_)
    53          buf[1] = isprint(charptr[i + j]) ? charptr[i + j] : '.';
- 53     ternary-?: ( ( ( _ctype [ ( int ) ( unsign..
  54          strcat(line, buf);
  55       }
  56       printk(KERN_DEBUG "%s\n", line);
  57    }
  58 }
  59 
  60 #ifdef CONFIG_PROC_FS
  61 static int
 
- 62 cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
  63            int count, int *eof, void *data)
  64 {
  65    struct list_head *tmp;
  66    struct list_head *tmp1;
  67    struct mid_q_entry * mid_entry;
  68    struct cifsSesInfo *ses;
  69    struct cifsTconInfo *tcon;
  70    int i;
  71    int length = 0;
  72    char * original_buf = buf;
  73 
  74    *beginBuffer = buf + offset;
  75 
  76    
  77    length =
  78        sprintf(buf,
  79           "Display Internal CIFS Data Structures for Debugging\n"
  80           "---------------------------------------------------\n");
  81    buf += length;
  82    length = sprintf(buf,"CIFS Version %s\n",CIFS_VERSION);
  83    buf += length;
  84    length = sprintf(buf,"Active VFS Requests: %d\n", GlobalTotalActiveXid);
  85    buf += length;
  86    length = sprintf(buf, "Servers:");
  87    buf += length;
  88 
  89    i = 0;
    90    read_lock(&GlobalSMBSeslock);
    90   do
- 90   do-while (0)
- 90 do-while (0)
- 91    list_for_each(tmp, &GlobalSMBSessionList) {
  92       i++;
  93       ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList);
  94       if((ses->serverDomain == NULL) || (ses->serverOS == NULL) ||
- 95          (ses->serverNOS == NULL)) {
 - 95     (T) || (_) || (_)
 - 95     (F) || (T) || (_)
 - 95     (F) || (F) || (T)
 - 95     (F) || (F) || (F)
  96          buf += sprintf("\nentry for %s not fully displayed\n\t",
  97                ses->serverName);
  98          
    99       } else {
  100          length =
  101              sprintf(buf,
  102                 "\n%d) Name: %s  Domain: %s Mounts: %d OS: %s  \n\tNOS: %s\tCapability: 0x%x\n\tSMB session status: %d\t",
  103             i, ses->serverName, ses->serverDomain,
  104             atomic_read(&ses->inUse),
  105             ses->serverOS, ses->serverNOS,
  106             ses->capabilities,ses->status);
  107          buf += length;
  108       }
- 109       if(ses->server) {
  110          buf += sprintf(buf, "TCP status: %d\n\tLocal Users To Server: %d SecMode: 0x%x Req On Wire: %d",
  111             ses->server->tcpStatus,
  112             atomic_read(&ses->server->socketUseCount),
  113             ses->server->secMode,
  114             atomic_read(&ses->server->inFlight));
  115 
  116 #ifdef CONFIG_CIFS_STATS2
  117          buf += sprintf(buf, " In Send: %d In MaxReq Wait: %d",
  118             atomic_read(&ses->server->inSend), 
  119             atomic_read(&ses->server->num_waiters));
  120 #endif
  121 
  122          length = sprintf(buf, "\nMIDs:\n");
  123          buf += length;
  124 
    125          spin_lock(&GlobalMid_Lock);
    125       do
- 125       do-while (0)
- 125     do-while (0)
- 126          list_for_each(tmp1, &ses->server->pending_mid_q) {
  127             mid_entry = list_entry(tmp1, struct
  128                mid_q_entry,
  129                qhead);
- 130             if(mid_entry) {
  131                length = sprintf(buf,"State: %d com: %d pid: %d tsk: %p mid %d\n",
  132                   mid_entry->midState,
  133                   (int)mid_entry->command,
  134                   mid_entry->pid,
  135                   mid_entry->tsk,
  136                   mid_entry->mid);
  137                buf += length;
  138             }
  139          }
    140          spin_unlock(&GlobalMid_Lock); 
    140       do
- 140       do-while (0)
- 140     do-while (0)
  141       }
  142 
  143    }
    144    read_unlock(&GlobalSMBSeslock);
    144   do
- 144   do-while (0)
- 144 do-while (0)
  145    sprintf(buf, "\n");
  146    buf++;
  147 
  148    length = sprintf(buf, "Shares:");
  149    buf += length;
  150 
  151    i = 0;
    152    read_lock(&GlobalSMBSeslock);
    152   do
- 152   do-while (0)
- 152 do-while (0)
- 153    list_for_each(tmp, &GlobalTreeConnectionList) {
  154       __u32 dev_type;
  155       i++;
  156       tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
  157       dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType);
  158       length =
  159           sprintf(buf,
  160              "\n%d) %s Uses: %d Type: %s DevInfo: 0x%x Attributes: 0x%x\nPathComponentMax: %d Status: %d",
  161              i, tcon->treeName,
  162              atomic_read(&tcon->useCount),
  163              tcon->nativeFileSystem,
  164              le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics),
  165              le32_to_cpu(tcon->fsAttrInfo.Attributes),
  166              le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength),
  167              tcon->tidStatus);
  168       buf += length;        
- 169       if (dev_type == FILE_DEVICE_DISK)
  170          length = sprintf(buf, " type: DISK ");
- 171       else if (dev_type == FILE_DEVICE_CD_ROM)
  172          length = sprintf(buf, " type: CDROM ");
    173       else
  174          length =
  175              sprintf(buf, " type: %d ", dev_type);
  176       buf += length;
- 177       if(tcon->tidStatus == CifsNeedReconnect) {
  178          buf += sprintf(buf, "\tDISCONNECTED ");
  179          length += 14;
  180       }
  181    }
    182    read_unlock(&GlobalSMBSeslock);
    182   do
- 182   do-while (0)
- 182 do-while (0)
  183 
  184    length = sprintf(buf, "\n");
  185    buf += length;
  186 
  187    /* BB add code to dump additional info such as TCP session info now */
  188    /* Now calculate total size of returned data */
  189    length = buf - original_buf;
  190 
- 191    if(offset + count >= length)
  192       *eof = 1;
- 193    if(length < offset) {
  194       *eof = 1;
 - 195       return 0;
    196    } else {
  197       length = length - offset;
  198    }
- 199    if (length > count)
  200       length = count;
  201 
 - 202    return length;
  203 }
  204 
  205 #ifdef CONFIG_CIFS_STATS
  206 
  207 static int
  208 cifs_stats_write(struct file *file, const char __user *buffer,
  209                unsigned long count, void *data)
  210 {
  211         char c;
  212         int rc;
  213    struct list_head *tmp;
  214    struct cifsTconInfo *tcon;
  215 
  216         rc = get_user(c, buffer);
  217         if (rc)
  218                 return rc;
  219 
  220         if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
  221       read_lock(&GlobalSMBSeslock);
  222 #ifdef CONFIG_CIFS_STATS2
  223       atomic_set(&totBufAllocCount, 0);
  224       atomic_set(&totSmBufAllocCount, 0);
  225 #endif /* CONFIG_CIFS_STATS2 */
  226       list_for_each(tmp, &GlobalTreeConnectionList) {
  227          tcon = list_entry(tmp, struct cifsTconInfo,
  228                cifsConnectionList);
  229          atomic_set(&tcon->num_smbs_sent, 0);
  230          atomic_set(&tcon->num_writes, 0);
  231          atomic_set(&tcon->num_reads, 0);
  232          atomic_set(&tcon->num_oplock_brks, 0);
  233          atomic_set(&tcon->num_opens, 0);
  234          atomic_set(&tcon->num_closes, 0);
  235          atomic_set(&tcon->num_deletes, 0);
  236          atomic_set(&tcon->num_mkdirs, 0);
  237          atomic_set(&tcon->num_rmdirs, 0);
  238          atomic_set(&tcon->num_renames, 0);
  239          atomic_set(&tcon->num_t2renames, 0);
  240          atomic_set(&tcon->num_ffirst, 0);
  241          atomic_set(&tcon->num_fnext, 0);
  242          atomic_set(&tcon->num_fclose, 0);
  243          atomic_set(&tcon->num_hardlinks, 0);
  244          atomic_set(&tcon->num_symlinks, 0);
  245          atomic_set(&tcon->num_locks, 0);
  246       }
  247       read_unlock(&GlobalSMBSeslock);
  248    }
  249 
  250         return count;
  251 }
  252 
  253 static int
  254 cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
  255         int count, int *eof, void *data)
  256 {
  257    int item_length,i,length;
  258    struct list_head *tmp;
  259    struct cifsTconInfo *tcon;
  260 
  261    *beginBuffer = buf + offset;
  262 
  263    length = sprintf(buf,
  264          "Resources in use\nCIFS Session: %d\n",
  265          sesInfoAllocCount.counter);
  266    buf += length;
  267    item_length = 
  268       sprintf(buf,"Share (unique mount targets): %d\n",
  269          tconInfoAllocCount.counter);
  270    length += item_length;
  271    buf += item_length;      
  272    item_length = 
  273       sprintf(buf,"SMB Request/Response Buffer: %d Pool size: %d\n",
  274          bufAllocCount.counter,
  275          cifs_min_rcv + tcpSesAllocCount.counter);
  276    length += item_length;
  277    buf += item_length;
  278    item_length = 
  279       sprintf(buf,"SMB Small Req/Resp Buffer: %d Pool size: %d\n",
  280          smBufAllocCount.counter,cifs_min_small);
  281    length += item_length;
  282    buf += item_length;
  283 #ifdef CONFIG_CIFS_STATS2
  284         item_length = sprintf(buf, "Total Large %d Small %d Allocations\n",
  285             atomic_read(&totBufAllocCount),
  286                       atomic_read(&totSmBufAllocCount));
  287    length += item_length;
  288    buf += item_length;
  289 #endif /* CONFIG_CIFS_STATS2 */
  290 
  291    item_length = 
  292       sprintf(buf,"Operations (MIDs): %d\n",
  293          midCount.counter);
  294    length += item_length;
  295    buf += item_length;
  296    item_length = sprintf(buf,
  297       "\n%d session %d share reconnects\n",
  298       tcpSesReconnectCount.counter,tconInfoReconnectCount.counter);
  299    length += item_length;
  300    buf += item_length;
  301 
  302    item_length = sprintf(buf,
  303       "Total vfs operations: %d maximum at one time: %d\n",
  304       GlobalCurrentXid,GlobalMaxActiveXid);
  305    length += item_length;
  306    buf += item_length;
  307 
  308    i = 0;
  309    read_lock(&GlobalSMBSeslock);
  310    list_for_each(tmp, &GlobalTreeConnectionList) {
  311       i++;
  312       tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
  313       item_length = sprintf(buf,"\n%d) %s",i, tcon->treeName);
  314       buf += item_length;
  315       length += item_length;
  316       if(tcon->tidStatus == CifsNeedReconnect) {
  317          buf += sprintf(buf, "\tDISCONNECTED ");
  318          length += 14;
  319       }
  320       item_length = sprintf(buf, "\nSMBs: %d Oplock Breaks: %d",
  321          atomic_read(&tcon->num_smbs_sent),
  322          atomic_read(&tcon->num_oplock_brks));
  323       buf += item_length;
  324       length += item_length;
  325       item_length = sprintf(buf, "\nReads:  %d Bytes: %lld",
  326          atomic_read(&tcon->num_reads),
  327          (long long)(tcon->bytes_read));
  328       buf += item_length;
  329       length += item_length;
  330       item_length = sprintf(buf, "\nWrites: %d Bytes: %lld",
  331          atomic_read(&tcon->num_writes),
  332          (long long)(tcon->bytes_written));
  333                 buf += item_length;
  334                 length += item_length;
  335                 item_length = sprintf(buf, 
  336          "\nLocks: %d HardLinks: %d Symlinks: %d",
  337                         atomic_read(&tcon->num_locks),
  338          atomic_read(&tcon->num_hardlinks),
  339          atomic_read(&tcon->num_symlinks));
  340                 buf += item_length;
  341                 length += item_length;
  342 
  343       item_length = sprintf(buf, "\nOpens: %d Closes: %d Deletes: %d",
  344          atomic_read(&tcon->num_opens),
  345          atomic_read(&tcon->num_closes),
  346          atomic_read(&tcon->num_deletes));
  347       buf += item_length;
  348       length += item_length;
  349       item_length = sprintf(buf, "\nMkdirs: %d Rmdirs: %d",
  350          atomic_read(&tcon->num_mkdirs),
  351          atomic_read(&tcon->num_rmdirs));
  352       buf += item_length;
  353       length += item_length;
  354       item_length = sprintf(buf, "\nRenames: %d T2 Renames %d",
  355          atomic_read(&tcon->num_renames),
  356          atomic_read(&tcon->num_t2renames));
  357       buf += item_length;
  358       length += item_length;
  359       item_length = sprintf(buf, "\nFindFirst: %d FNext %d FClose %d",
  360          atomic_read(&tcon->num_ffirst),
  361          atomic_read(&tcon->num_fnext),
  362          atomic_read(&tcon->num_fclose));
  363       buf += item_length;
  364       length += item_length;
  365    }
  366    read_unlock(&GlobalSMBSeslock);
  367 
  368    buf += sprintf(buf,"\n");
  369    length++;
  370 
  371    if(offset + count >= length)
  372       *eof = 1;
  373    if(length < offset) {
  374       *eof = 1;
  375       return 0;
  376    } else {
  377       length = length - offset;
  378    }
  379    if (length > count)
  380       length = count;
  381       
  382    return length;
  383 }
  384 #endif
  385 
  386 static struct proc_dir_entry *proc_fs_cifs;
  387 read_proc_t cifs_txanchor_read;
  388 static read_proc_t cifsFYI_read;
  389 static write_proc_t cifsFYI_write;
  390 static read_proc_t oplockEnabled_read;
  391 static write_proc_t oplockEnabled_write;
  392 static read_proc_t lookupFlag_read;
  393 static write_proc_t lookupFlag_write;
  394 static read_proc_t traceSMB_read;
  395 static write_proc_t traceSMB_write;
  396 static read_proc_t multiuser_mount_read;
  397 static write_proc_t multiuser_mount_write;
  398 static read_proc_t extended_security_read;
  399 static write_proc_t extended_security_write;
  400 static read_proc_t ntlmv2_enabled_read;
  401 static write_proc_t ntlmv2_enabled_write;
  402 static read_proc_t packet_signing_enabled_read;
  403 static write_proc_t packet_signing_enabled_write;
  404 static read_proc_t experimEnabled_read;
  405 static write_proc_t experimEnabled_write;
  406 static read_proc_t linuxExtensionsEnabled_read;
  407 static write_proc_t linuxExtensionsEnabled_write;
  408 
  409 void
 
  410 cifs_proc_init(void)
  411 {
  412    struct proc_dir_entry *pde;
  413 
  414    proc_fs_cifs = proc_mkdir("cifs", proc_root_fs);
- 415    if (proc_fs_cifs == NULL)
 - 416       return;
  417 
  418    proc_fs_cifs->owner = THIS_MODULE;
  419    create_proc_read_entry("DebugData", 0, proc_fs_cifs,
  420             cifs_debug_data_read, NULL);
  421 
  422 #ifdef CONFIG_CIFS_STATS
  423    pde = create_proc_read_entry("Stats", 0, proc_fs_cifs,
  424             cifs_stats_read, NULL);
  425    if (pde)
  426       pde->write_proc = cifs_stats_write;
  427 #endif
  428    pde = create_proc_read_entry("cifsFYI", 0, proc_fs_cifs,
  429             cifsFYI_read, NULL);
- 430    if (pde)
  431       pde->write_proc = cifsFYI_write;
  432 
  433    pde =
  434        create_proc_read_entry("traceSMB", 0, proc_fs_cifs,
  435             traceSMB_read, NULL);
- 436    if (pde)
  437       pde->write_proc = traceSMB_write;
  438 
  439    pde = create_proc_read_entry("OplockEnabled", 0, proc_fs_cifs,
  440             oplockEnabled_read, NULL);
- 441    if (pde)
  442       pde->write_proc = oplockEnabled_write;
  443 
  444    pde = create_proc_read_entry("Experimental", 0, proc_fs_cifs,
  445             experimEnabled_read, NULL);
- 446    if (pde)
  447       pde->write_proc = experimEnabled_write;
  448 
  449    pde = create_proc_read_entry("LinuxExtensionsEnabled", 0, proc_fs_cifs,
  450             linuxExtensionsEnabled_read, NULL);
- 451    if (pde)
  452       pde->write_proc = linuxExtensionsEnabled_write;
  453 
  454    pde =
  455        create_proc_read_entry("MultiuserMount", 0, proc_fs_cifs,
  456             multiuser_mount_read, NULL);
- 457    if (pde)
  458       pde->write_proc = multiuser_mount_write;
  459 
  460    pde =
  461        create_proc_read_entry("ExtendedSecurity", 0, proc_fs_cifs,
  462             extended_security_read, NULL);
- 463    if (pde)
  464       pde->write_proc = extended_security_write;
  465 
  466    pde =
  467    create_proc_read_entry("LookupCacheEnabled", 0, proc_fs_cifs,
  468             lookupFlag_read, NULL);
- 469    if (pde)
  470       pde->write_proc = lookupFlag_write;
  471 
  472    pde =
  473        create_proc_read_entry("NTLMV2Enabled", 0, proc_fs_cifs,
  474             ntlmv2_enabled_read, NULL);
- 475    if (pde)
  476       pde->write_proc = ntlmv2_enabled_write;
  477 
  478    pde =
  479        create_proc_read_entry("PacketSigningEnabled", 0, proc_fs_cifs,
  480             packet_signing_enabled_read, NULL);
- 481    if (pde)
  482       pde->write_proc = packet_signing_enabled_write;
  483 }
  484 
  485 void
 
- 486 cifs_proc_clean(void)
  487 {
- 488    if (proc_fs_cifs == NULL)
 - 489       return;
  490 
  491    remove_proc_entry("DebugData", proc_fs_cifs);
  492    remove_proc_entry("cifsFYI", proc_fs_cifs);
  493    remove_proc_entry("traceSMB", proc_fs_cifs);
  494 #ifdef CONFIG_CIFS_STATS
  495    remove_proc_entry("Stats", proc_fs_cifs);
  496 #endif
  497    remove_proc_entry("MultiuserMount", proc_fs_cifs);
  498    remove_proc_entry("OplockEnabled", proc_fs_cifs);
  499    remove_proc_entry("NTLMV2Enabled",proc_fs_cifs);
  500    remove_proc_entry("ExtendedSecurity",proc_fs_cifs);
  501    remove_proc_entry("PacketSigningEnabled",proc_fs_cifs);
  502    remove_proc_entry("LinuxExtensionsEnabled",proc_fs_cifs);
  503    remove_proc_entry("Experimental",proc_fs_cifs);
  504    remove_proc_entry("LookupCacheEnabled",proc_fs_cifs);
  505    remove_proc_entry("cifs", proc_root_fs);
  506 }
  507 
  508 static int
 
- 509 cifsFYI_read(char *page, char **start, off_t off, int count,
  510         int *eof, void *data)
  511 {
  512    int len;
  513 
  514    len = sprintf(page, "%d\n", cifsFYI);
  515 
  516    len -= off;
  517    *start = page + off;
  518 
- 519    if (len > count)
  520       len = count;
    521    else
  522       *eof = 1;
  523 
- 524    if (len < 0)
  525       len = 0;