aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/cifs/cifsglob.h28
-rw-r--r--fs/cifs/cifssmb.c88
-rw-r--r--fs/cifs/file.c34
-rw-r--r--fs/cifs/misc.c4
4 files changed, 58 insertions, 96 deletions
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index f143975627e0..9a3c85bdd77e 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -339,6 +339,34 @@ static inline const char CIFS_DIR_SEP(const struct cifs_sb_info *cifs_sb)
339 return '\\'; 339 return '\\';
340} 340}
341 341
342#ifdef CONFIG_CIFS_STATS
343#define cifs_stats_inc atomic_inc
344
345static inline void cifs_stats_bytes_written(struct cifsTconInfo *tcon,
346 unsigned int bytes)
347{
348 if (bytes) {
349 spin_lock(&tcon->stat_lock);
350 tcon->bytes_written += bytes;
351 spin_unlock(&tcon->stat_lock);
352 }
353}
354
355static inline void cifs_stats_bytes_read(struct cifsTconInfo *tcon,
356 unsigned int bytes)
357{
358 spin_lock(&tcon->stat_lock);
359 tcon->bytes_read += bytes;
360 spin_unlock(&tcon->stat_lock);
361}
362#else
363
364#define cifs_stats_inc(field) do {} while(0)
365#define cifs_stats_bytes_written(tcon, bytes) do {} while(0)
366#define cifs_stats_bytes_read(tcon, bytes) do {} while(0)
367
368#endif
369
342/* one of these for every pending CIFS request to the server */ 370/* one of these for every pending CIFS request to the server */
343struct mid_q_entry { 371struct mid_q_entry {
344 struct list_head qhead; /* mids waiting on reply from this server */ 372 struct list_head qhead; /* mids waiting on reply from this server */
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 811ab3dffafa..698cdcebca04 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -166,11 +166,9 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
166 166
167 header_assemble((struct smb_hdr *) *request_buf, smb_command, tcon,wct); 167 header_assemble((struct smb_hdr *) *request_buf, smb_command, tcon,wct);
168 168
169#ifdef CONFIG_CIFS_STATS 169 if(tcon != NULL)
170 if(tcon != NULL) { 170 cifs_stats_inc(&tcon->num_smbs_sent);
171 atomic_inc(&tcon->num_smbs_sent); 171
172 }
173#endif /* CONFIG_CIFS_STATS */
174 return rc; 172 return rc;
175} 173}
176 174
@@ -269,11 +267,9 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
269 header_assemble((struct smb_hdr *) *request_buf, smb_command, tcon, 267 header_assemble((struct smb_hdr *) *request_buf, smb_command, tcon,
270 wct /*wct */ ); 268 wct /*wct */ );
271 269
272#ifdef CONFIG_CIFS_STATS 270 if(tcon != NULL)
273 if(tcon != NULL) { 271 cifs_stats_inc(&tcon->num_smbs_sent);
274 atomic_inc(&tcon->num_smbs_sent); 272
275 }
276#endif /* CONFIG_CIFS_STATS */
277 return rc; 273 return rc;
278} 274}
279 275
@@ -584,9 +580,7 @@ DelFileRetry:
584 pSMB->ByteCount = cpu_to_le16(name_len + 1); 580 pSMB->ByteCount = cpu_to_le16(name_len + 1);
585 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 581 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
586 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 582 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
587#ifdef CONFIG_CIFS_STATS 583 cifs_stats_inc(&tcon->num_deletes);
588 atomic_inc(&tcon->num_deletes);
589#endif
590 if (rc) { 584 if (rc) {
591 cFYI(1, ("Error in RMFile = %d", rc)); 585 cFYI(1, ("Error in RMFile = %d", rc));
592 } 586 }
@@ -631,9 +625,7 @@ RmDirRetry:
631 pSMB->ByteCount = cpu_to_le16(name_len + 1); 625 pSMB->ByteCount = cpu_to_le16(name_len + 1);
632 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 626 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
633 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 627 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
634#ifdef CONFIG_CIFS_STATS 628 cifs_stats_inc(&tcon->num_rmdirs);
635 atomic_inc(&tcon->num_rmdirs);
636#endif
637 if (rc) { 629 if (rc) {
638 cFYI(1, ("Error in RMDir = %d", rc)); 630 cFYI(1, ("Error in RMDir = %d", rc));
639 } 631 }
@@ -677,9 +669,7 @@ MkDirRetry:
677 pSMB->ByteCount = cpu_to_le16(name_len + 1); 669 pSMB->ByteCount = cpu_to_le16(name_len + 1);
678 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 670 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
679 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 671 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
680#ifdef CONFIG_CIFS_STATS 672 cifs_stats_inc(&tcon->num_mkdirs);
681 atomic_inc(&tcon->num_mkdirs);
682#endif
683 if (rc) { 673 if (rc) {
684 cFYI(1, ("Error in Mkdir = %d", rc)); 674 cFYI(1, ("Error in Mkdir = %d", rc));
685 } 675 }
@@ -767,9 +757,7 @@ openRetry:
767 /* long_op set to 1 to allow for oplock break timeouts */ 757 /* long_op set to 1 to allow for oplock break timeouts */
768 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 758 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
769 (struct smb_hdr *) pSMBr, &bytes_returned, 1); 759 (struct smb_hdr *) pSMBr, &bytes_returned, 1);
770#ifdef CONFIG_CIFS_STATS 760 cifs_stats_inc(&tcon->num_opens);
771 atomic_inc(&tcon->num_opens);
772#endif
773 if (rc) { 761 if (rc) {
774 cFYI(1, ("Error in Open = %d", rc)); 762 cFYI(1, ("Error in Open = %d", rc));
775 } else { 763 } else {
@@ -833,9 +821,7 @@ CIFSSMBRead(const int xid, struct cifsTconInfo *tcon,
833 821
834 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 822 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
835 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 823 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
836#ifdef CONFIG_CIFS_STATS 824 cifs_stats_inc(&tcon->num_reads);
837 atomic_inc(&tcon->num_reads);
838#endif
839 if (rc) { 825 if (rc) {
840 cERROR(1, ("Send error in read = %d", rc)); 826 cERROR(1, ("Send error in read = %d", rc));
841 } else { 827 } else {
@@ -938,9 +924,7 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
938 924
939 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 925 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
940 (struct smb_hdr *) pSMBr, &bytes_returned, long_op); 926 (struct smb_hdr *) pSMBr, &bytes_returned, long_op);
941#ifdef CONFIG_CIFS_STATS 927 cifs_stats_inc(&tcon->num_writes);
942 atomic_inc(&tcon->num_writes);
943#endif
944 if (rc) { 928 if (rc) {
945 cFYI(1, ("Send error in write = %d", rc)); 929 cFYI(1, ("Send error in write = %d", rc));
946 *nbytes = 0; 930 *nbytes = 0;
@@ -1013,9 +997,7 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
1013 997
1014 rc = SendReceive2(xid, tcon->ses, (struct smb_hdr *) pSMB, smb_hdr_len, 998 rc = SendReceive2(xid, tcon->ses, (struct smb_hdr *) pSMB, smb_hdr_len,
1015 buf, bytes_sent, &bytes_returned, long_op); 999 buf, bytes_sent, &bytes_returned, long_op);
1016#ifdef CONFIG_CIFS_STATS 1000 cifs_stats_inc(&tcon->num_writes);
1017 atomic_inc(&tcon->num_writes);
1018#endif
1019 if (rc) { 1001 if (rc) {
1020 cFYI(1, ("Send error in write = %d", rc)); 1002 cFYI(1, ("Send error in write = %d", rc));
1021 *nbytes = 0; 1003 *nbytes = 0;
@@ -1091,9 +1073,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
1091 1073
1092 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 1074 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
1093 (struct smb_hdr *) pSMBr, &bytes_returned, timeout); 1075 (struct smb_hdr *) pSMBr, &bytes_returned, timeout);
1094#ifdef CONFIG_CIFS_STATS 1076 cifs_stats_inc(&tcon->num_locks);
1095 atomic_inc(&tcon->num_locks);
1096#endif
1097 if (rc) { 1077 if (rc) {
1098 cFYI(1, ("Send error in Lock = %d", rc)); 1078 cFYI(1, ("Send error in Lock = %d", rc));
1099 } 1079 }
@@ -1127,9 +1107,7 @@ CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, int smb_file_id)
1127 pSMB->ByteCount = 0; 1107 pSMB->ByteCount = 0;
1128 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 1108 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
1129 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 1109 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
1130#ifdef CONFIG_CIFS_STATS 1110 cifs_stats_inc(&tcon->num_closes);
1131 atomic_inc(&tcon->num_closes);
1132#endif
1133 if (rc) { 1111 if (rc) {
1134 if(rc!=-EINTR) { 1112 if(rc!=-EINTR) {
1135 /* EINTR is expected when user ctl-c to kill app */ 1113 /* EINTR is expected when user ctl-c to kill app */
@@ -1202,9 +1180,7 @@ renameRetry:
1202 1180
1203 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 1181 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
1204 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 1182 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
1205#ifdef CONFIG_CIFS_STATS 1183 cifs_stats_inc(&tcon->num_renames);
1206 atomic_inc(&tcon->num_renames);
1207#endif
1208 if (rc) { 1184 if (rc) {
1209 cFYI(1, ("Send error in rename = %d", rc)); 1185 cFYI(1, ("Send error in rename = %d", rc));
1210 } 1186 }
@@ -1283,9 +1259,7 @@ int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon,
1283 pSMB->ByteCount = cpu_to_le16(byte_count); 1259 pSMB->ByteCount = cpu_to_le16(byte_count);
1284 rc = SendReceive(xid, pTcon->ses, (struct smb_hdr *) pSMB, 1260 rc = SendReceive(xid, pTcon->ses, (struct smb_hdr *) pSMB,
1285 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 1261 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
1286#ifdef CONFIG_CIFS_STATS 1262 cifs_stats_inc(&pTcon->num_t2renames);
1287 atomic_inc(&pTcon->num_t2renames);
1288#endif
1289 if (rc) { 1263 if (rc) {
1290 cFYI(1,("Send error in Rename (by file handle) = %d", rc)); 1264 cFYI(1,("Send error in Rename (by file handle) = %d", rc));
1291 } 1265 }
@@ -1443,9 +1417,7 @@ createSymLinkRetry:
1443 pSMB->ByteCount = cpu_to_le16(byte_count); 1417 pSMB->ByteCount = cpu_to_le16(byte_count);
1444 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 1418 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
1445 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 1419 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
1446#ifdef CONFIG_CIFS_STATS 1420 cifs_stats_inc(&tcon->num_symlinks);
1447 atomic_inc(&tcon->num_symlinks);
1448#endif
1449 if (rc) { 1421 if (rc) {
1450 cFYI(1, 1422 cFYI(1,
1451 ("Send error in SetPathInfo (create symlink) = %d", 1423 ("Send error in SetPathInfo (create symlink) = %d",
@@ -1535,9 +1507,7 @@ createHardLinkRetry:
1535 pSMB->ByteCount = cpu_to_le16(byte_count); 1507 pSMB->ByteCount = cpu_to_le16(byte_count);
1536 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 1508 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
1537 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 1509 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
1538#ifdef CONFIG_CIFS_STATS 1510 cifs_stats_inc(&tcon->num_hardlinks);
1539 atomic_inc(&tcon->num_hardlinks);
1540#endif
1541 if (rc) { 1511 if (rc) {
1542 cFYI(1, ("Send error in SetPathInfo (hard link) = %d", rc)); 1512 cFYI(1, ("Send error in SetPathInfo (hard link) = %d", rc));
1543 } 1513 }
@@ -1608,9 +1578,7 @@ winCreateHardLinkRetry:
1608 1578
1609 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 1579 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
1610 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 1580 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
1611#ifdef CONFIG_CIFS_STATS 1581 cifs_stats_inc(&tcon->num_hardlinks);
1612 atomic_inc(&tcon->num_hardlinks);
1613#endif
1614 if (rc) { 1582 if (rc) {
1615 cFYI(1, ("Send error in hard link (NT rename) = %d", rc)); 1583 cFYI(1, ("Send error in hard link (NT rename) = %d", rc));
1616 } 1584 }
@@ -2490,9 +2458,7 @@ findUniqueRetry:
2490 if (rc) { 2458 if (rc) {
2491 cFYI(1, ("Send error in FindFileDirInfo = %d", rc)); 2459 cFYI(1, ("Send error in FindFileDirInfo = %d", rc));
2492 } else { /* decode response */ 2460 } else { /* decode response */
2493#ifdef CONFIG_CIFS_STATS 2461 cifs_stats_inc(&tcon->num_ffirst);
2494 atomic_inc(&tcon->num_ffirst);
2495#endif
2496 /* BB fill in */ 2462 /* BB fill in */
2497 } 2463 }
2498 2464
@@ -2592,9 +2558,7 @@ findFirstRetry:
2592 2558
2593 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 2559 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
2594 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 2560 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
2595#ifdef CONFIG_CIFS_STATS 2561 cifs_stats_inc(&tcon->num_ffirst);
2596 atomic_inc(&tcon->num_ffirst);
2597#endif
2598 2562
2599 if (rc) {/* BB add logic to retry regular search if Unix search rejected unexpectedly by server */ 2563 if (rc) {/* BB add logic to retry regular search if Unix search rejected unexpectedly by server */
2600 /* BB Add code to handle unsupported level rc */ 2564 /* BB Add code to handle unsupported level rc */
@@ -2716,9 +2680,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
2716 2680
2717 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 2681 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
2718 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 2682 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
2719#ifdef CONFIG_CIFS_STATS 2683 cifs_stats_inc(&tcon->num_fnext);
2720 atomic_inc(&tcon->num_fnext);
2721#endif
2722 if (rc) { 2684 if (rc) {
2723 if (rc == -EBADF) { 2685 if (rc == -EBADF) {
2724 psrch_inf->endOfSearch = TRUE; 2686 psrch_inf->endOfSearch = TRUE;
@@ -2795,9 +2757,7 @@ CIFSFindClose(const int xid, struct cifsTconInfo *tcon, const __u16 searchHandle
2795 if (rc) { 2757 if (rc) {
2796 cERROR(1, ("Send error in FindClose = %d", rc)); 2758 cERROR(1, ("Send error in FindClose = %d", rc));
2797 } 2759 }
2798#ifdef CONFIG_CIFS_STATS 2760 cifs_stats_inc(&tcon->num_fclose);
2799 atomic_inc(&tcon->num_fclose);
2800#endif
2801 cifs_small_buf_release(pSMB); 2761 cifs_small_buf_release(pSMB);
2802 2762
2803 /* Since session is dead, search handle closed on server already */ 2763 /* Since session is dead, search handle closed on server already */
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index b054df2dee1e..5857d12611e6 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -744,13 +744,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
744 15 seconds is plenty */ 744 15 seconds is plenty */
745 } 745 }
746 746
747#ifdef CONFIG_CIFS_STATS 747 cifs_stats_bytes_written(pTcon, total_written);
748 if (total_written > 0) {
749 spin_lock(&pTcon->stat_lock);
750 pTcon->bytes_written += total_written;
751 spin_unlock(&pTcon->stat_lock);
752 }
753#endif
754 748
755 /* since the write may have blocked check these pointers again */ 749 /* since the write may have blocked check these pointers again */
756 if (file->f_dentry) { 750 if (file->f_dentry) {
@@ -878,13 +872,7 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
878 15 seconds is plenty */ 872 15 seconds is plenty */
879 } 873 }
880 874
881#ifdef CONFIG_CIFS_STATS 875 cifs_stats_bytes_written(pTcon, total_written);
882 if (total_written > 0) {
883 spin_lock(&pTcon->stat_lock);
884 pTcon->bytes_written += total_written;
885 spin_unlock(&pTcon->stat_lock);
886 }
887#endif
888 876
889 /* since the write may have blocked check these pointers again */ 877 /* since the write may have blocked check these pointers again */
890 if (file->f_dentry) { 878 if (file->f_dentry) {
@@ -1245,11 +1233,7 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,
1245 return rc; 1233 return rc;
1246 } 1234 }
1247 } else { 1235 } else {
1248#ifdef CONFIG_CIFS_STATS 1236 cifs_stats_bytes_read(pTcon, bytes_read);
1249 spin_lock(&pTcon->stat_lock);
1250 pTcon->bytes_read += total_read;
1251 spin_unlock(&pTcon->stat_lock);
1252#endif
1253 *poffset += bytes_read; 1237 *poffset += bytes_read;
1254 } 1238 }
1255 } 1239 }
@@ -1312,11 +1296,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
1312 return rc; 1296 return rc;
1313 } 1297 }
1314 } else { 1298 } else {
1315#ifdef CONFIG_CIFS_STATS 1299 cifs_stats_bytes_read(pTcon, total_read);
1316 spin_lock(&pTcon->stat_lock);
1317 pTcon->bytes_read += total_read;
1318 spin_unlock(&pTcon->stat_lock);
1319#endif
1320 *poffset += bytes_read; 1300 *poffset += bytes_read;
1321 } 1301 }
1322 } 1302 }
@@ -1488,11 +1468,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
1488 le16_to_cpu(pSMBr->DataOffset), &lru_pvec); 1468 le16_to_cpu(pSMBr->DataOffset), &lru_pvec);
1489 1469
1490 i += bytes_read >> PAGE_CACHE_SHIFT; 1470 i += bytes_read >> PAGE_CACHE_SHIFT;
1491#ifdef CONFIG_CIFS_STATS 1471 cifs_stats_bytes_read(pTcon, bytes_read);
1492 spin_lock(&pTcon->stat_lock);
1493 pTcon->bytes_read += bytes_read;
1494 spin_unlock(&pTcon->stat_lock);
1495#endif
1496 if ((int)(bytes_read & PAGE_CACHE_MASK) != bytes_read) { 1472 if ((int)(bytes_read & PAGE_CACHE_MASK) != bytes_read) {
1497 i++; /* account for partial page */ 1473 i++; /* account for partial page */
1498 1474
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index 40d50b77bfe7..fafbdbfa63a1 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -520,9 +520,7 @@ is_valid_oplock_break(struct smb_hdr *buf)
520 list_for_each(tmp, &GlobalTreeConnectionList) { 520 list_for_each(tmp, &GlobalTreeConnectionList) {
521 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); 521 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
522 if (tcon->tid == buf->Tid) { 522 if (tcon->tid == buf->Tid) {
523#ifdef CONFIG_CIFS_STATS 523 cifs_stats_inc(&tcon->num_oplock_brks);
524 atomic_inc(&tcon->num_oplock_brks);
525#endif
526 list_for_each(tmp1,&tcon->openFileList){ 524 list_for_each(tmp1,&tcon->openFileList){
527 netfile = list_entry(tmp1,struct cifsFileInfo, 525 netfile = list_entry(tmp1,struct cifsFileInfo,
528 tlist); 526 tlist);