Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 12031
b: refs/heads/master
c: a454434
h: refs/heads/master
i:
  12029: 42c7baa
  12027: 1fe93e7
  12023: 782df02
  12015: ce9a34c
  11999: 0b015c0
  11967: 44a80c5
  11903: 06145c4
  11775: 5a178a5
v: v3
  • Loading branch information
Steve French committed Aug 24, 2005
1 parent a115361 commit f85e109
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 97 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6b8edfe0f918e7585acb3bd63f62ff56e32dd3d2
refs/heads/master: a45443475835ab4d1c753159812aca21b5c333a3
28 changes: 28 additions & 0 deletions trunk/fs/cifs/cifsglob.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,34 @@ static inline const char CIFS_DIR_SEP(const struct cifs_sb_info *cifs_sb)
return '\\';
}

#ifdef CONFIG_CIFS_STATS
#define cifs_stats_inc atomic_inc

static inline void cifs_stats_bytes_written(struct cifsTconInfo *tcon,
unsigned int bytes)
{
if (bytes) {
spin_lock(&tcon->stat_lock);
tcon->bytes_written += bytes;
spin_unlock(&tcon->stat_lock);
}
}

static inline void cifs_stats_bytes_read(struct cifsTconInfo *tcon,
unsigned int bytes)
{
spin_lock(&tcon->stat_lock);
tcon->bytes_read += bytes;
spin_unlock(&tcon->stat_lock);
}
#else

#define cifs_stats_inc(field) do {} while(0)
#define cifs_stats_bytes_written(tcon, bytes) do {} while(0)
#define cifs_stats_bytes_read(tcon, bytes) do {} while(0)

#endif

/* one of these for every pending CIFS request to the server */
struct mid_q_entry {
struct list_head qhead; /* mids waiting on reply from this server */
Expand Down
88 changes: 24 additions & 64 deletions trunk/fs/cifs/cifssmb.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,9 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,

header_assemble((struct smb_hdr *) *request_buf, smb_command, tcon,wct);

#ifdef CONFIG_CIFS_STATS
if(tcon != NULL) {
atomic_inc(&tcon->num_smbs_sent);
}
#endif /* CONFIG_CIFS_STATS */
if(tcon != NULL)
cifs_stats_inc(&tcon->num_smbs_sent);

return rc;
}

Expand Down Expand Up @@ -269,11 +267,9 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
header_assemble((struct smb_hdr *) *request_buf, smb_command, tcon,
wct /*wct */ );

#ifdef CONFIG_CIFS_STATS
if(tcon != NULL) {
atomic_inc(&tcon->num_smbs_sent);
}
#endif /* CONFIG_CIFS_STATS */
if(tcon != NULL)
cifs_stats_inc(&tcon->num_smbs_sent);

return rc;
}

Expand Down Expand Up @@ -584,9 +580,7 @@ CIFSSMBDelFile(const int xid, struct cifsTconInfo *tcon, const char *fileName,
pSMB->ByteCount = cpu_to_le16(name_len + 1);
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0);
#ifdef CONFIG_CIFS_STATS
atomic_inc(&tcon->num_deletes);
#endif
cifs_stats_inc(&tcon->num_deletes);
if (rc) {
cFYI(1, ("Error in RMFile = %d", rc));
}
Expand Down Expand Up @@ -631,9 +625,7 @@ CIFSSMBRmDir(const int xid, struct cifsTconInfo *tcon, const char *dirName,
pSMB->ByteCount = cpu_to_le16(name_len + 1);
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0);
#ifdef CONFIG_CIFS_STATS
atomic_inc(&tcon->num_rmdirs);
#endif
cifs_stats_inc(&tcon->num_rmdirs);
if (rc) {
cFYI(1, ("Error in RMDir = %d", rc));
}
Expand Down Expand Up @@ -677,9 +669,7 @@ CIFSSMBMkDir(const int xid, struct cifsTconInfo *tcon,
pSMB->ByteCount = cpu_to_le16(name_len + 1);
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0);
#ifdef CONFIG_CIFS_STATS
atomic_inc(&tcon->num_mkdirs);
#endif
cifs_stats_inc(&tcon->num_mkdirs);
if (rc) {
cFYI(1, ("Error in Mkdir = %d", rc));
}
Expand Down Expand Up @@ -767,9 +757,7 @@ CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon,
/* long_op set to 1 to allow for oplock break timeouts */
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 1);
#ifdef CONFIG_CIFS_STATS
atomic_inc(&tcon->num_opens);
#endif
cifs_stats_inc(&tcon->num_opens);
if (rc) {
cFYI(1, ("Error in Open = %d", rc));
} else {
Expand Down Expand Up @@ -833,9 +821,7 @@ CIFSSMBRead(const int xid, struct cifsTconInfo *tcon,

rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0);
#ifdef CONFIG_CIFS_STATS
atomic_inc(&tcon->num_reads);
#endif
cifs_stats_inc(&tcon->num_reads);
if (rc) {
cERROR(1, ("Send error in read = %d", rc));
} else {
Expand Down Expand Up @@ -938,9 +924,7 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,

rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, long_op);
#ifdef CONFIG_CIFS_STATS
atomic_inc(&tcon->num_writes);
#endif
cifs_stats_inc(&tcon->num_writes);
if (rc) {
cFYI(1, ("Send error in write = %d", rc));
*nbytes = 0;
Expand Down Expand Up @@ -1013,9 +997,7 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,

rc = SendReceive2(xid, tcon->ses, (struct smb_hdr *) pSMB, smb_hdr_len,
buf, bytes_sent, &bytes_returned, long_op);
#ifdef CONFIG_CIFS_STATS
atomic_inc(&tcon->num_writes);
#endif
cifs_stats_inc(&tcon->num_writes);
if (rc) {
cFYI(1, ("Send error in write = %d", rc));
*nbytes = 0;
Expand Down Expand Up @@ -1091,9 +1073,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,

rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, timeout);
#ifdef CONFIG_CIFS_STATS
atomic_inc(&tcon->num_locks);
#endif
cifs_stats_inc(&tcon->num_locks);
if (rc) {
cFYI(1, ("Send error in Lock = %d", rc));
}
Expand Down Expand Up @@ -1127,9 +1107,7 @@ CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, int smb_file_id)
pSMB->ByteCount = 0;
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0);
#ifdef CONFIG_CIFS_STATS
atomic_inc(&tcon->num_closes);
#endif
cifs_stats_inc(&tcon->num_closes);
if (rc) {
if(rc!=-EINTR) {
/* EINTR is expected when user ctl-c to kill app */
Expand Down Expand Up @@ -1202,9 +1180,7 @@ CIFSSMBRename(const int xid, struct cifsTconInfo *tcon,

rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0);
#ifdef CONFIG_CIFS_STATS
atomic_inc(&tcon->num_renames);
#endif
cifs_stats_inc(&tcon->num_renames);
if (rc) {
cFYI(1, ("Send error in rename = %d", rc));
}
Expand Down Expand Up @@ -1283,9 +1259,7 @@ int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon,
pSMB->ByteCount = cpu_to_le16(byte_count);
rc = SendReceive(xid, pTcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0);
#ifdef CONFIG_CIFS_STATS
atomic_inc(&pTcon->num_t2renames);
#endif
cifs_stats_inc(&pTcon->num_t2renames);
if (rc) {
cFYI(1,("Send error in Rename (by file handle) = %d", rc));
}
Expand Down Expand Up @@ -1443,9 +1417,7 @@ CIFSUnixCreateSymLink(const int xid, struct cifsTconInfo *tcon,
pSMB->ByteCount = cpu_to_le16(byte_count);
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0);
#ifdef CONFIG_CIFS_STATS
atomic_inc(&tcon->num_symlinks);
#endif
cifs_stats_inc(&tcon->num_symlinks);
if (rc) {
cFYI(1,
("Send error in SetPathInfo (create symlink) = %d",
Expand Down Expand Up @@ -1535,9 +1507,7 @@ CIFSUnixCreateHardLink(const int xid, struct cifsTconInfo *tcon,
pSMB->ByteCount = cpu_to_le16(byte_count);
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0);
#ifdef CONFIG_CIFS_STATS
atomic_inc(&tcon->num_hardlinks);
#endif
cifs_stats_inc(&tcon->num_hardlinks);
if (rc) {
cFYI(1, ("Send error in SetPathInfo (hard link) = %d", rc));
}
Expand Down Expand Up @@ -1608,9 +1578,7 @@ CIFSCreateHardLink(const int xid, struct cifsTconInfo *tcon,

rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0);
#ifdef CONFIG_CIFS_STATS
atomic_inc(&tcon->num_hardlinks);
#endif
cifs_stats_inc(&tcon->num_hardlinks);
if (rc) {
cFYI(1, ("Send error in hard link (NT rename) = %d", rc));
}
Expand Down Expand Up @@ -2490,9 +2458,7 @@ int CIFSFindSingle(const int xid, struct cifsTconInfo *tcon,
if (rc) {
cFYI(1, ("Send error in FindFileDirInfo = %d", rc));
} else { /* decode response */
#ifdef CONFIG_CIFS_STATS
atomic_inc(&tcon->num_ffirst);
#endif
cifs_stats_inc(&tcon->num_ffirst);
/* BB fill in */
}

Expand Down Expand Up @@ -2592,9 +2558,7 @@ CIFSFindFirst(const int xid, struct cifsTconInfo *tcon,

rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0);
#ifdef CONFIG_CIFS_STATS
atomic_inc(&tcon->num_ffirst);
#endif
cifs_stats_inc(&tcon->num_ffirst);

if (rc) {/* BB add logic to retry regular search if Unix search rejected unexpectedly by server */
/* BB Add code to handle unsupported level rc */
Expand Down Expand Up @@ -2716,9 +2680,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,

rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0);
#ifdef CONFIG_CIFS_STATS
atomic_inc(&tcon->num_fnext);
#endif
cifs_stats_inc(&tcon->num_fnext);
if (rc) {
if (rc == -EBADF) {
psrch_inf->endOfSearch = TRUE;
Expand Down Expand Up @@ -2795,9 +2757,7 @@ CIFSFindClose(const int xid, struct cifsTconInfo *tcon, const __u16 searchHandle
if (rc) {
cERROR(1, ("Send error in FindClose = %d", rc));
}
#ifdef CONFIG_CIFS_STATS
atomic_inc(&tcon->num_fclose);
#endif
cifs_stats_inc(&tcon->num_fclose);
cifs_small_buf_release(pSMB);

/* Since session is dead, search handle closed on server already */
Expand Down
34 changes: 5 additions & 29 deletions trunk/fs/cifs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,13 +744,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
15 seconds is plenty */
}

#ifdef CONFIG_CIFS_STATS
if (total_written > 0) {
spin_lock(&pTcon->stat_lock);
pTcon->bytes_written += total_written;
spin_unlock(&pTcon->stat_lock);
}
#endif
cifs_stats_bytes_written(pTcon, total_written);

/* since the write may have blocked check these pointers again */
if (file->f_dentry) {
Expand Down Expand Up @@ -878,13 +872,7 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
15 seconds is plenty */
}

#ifdef CONFIG_CIFS_STATS
if (total_written > 0) {
spin_lock(&pTcon->stat_lock);
pTcon->bytes_written += total_written;
spin_unlock(&pTcon->stat_lock);
}
#endif
cifs_stats_bytes_written(pTcon, total_written);

/* since the write may have blocked check these pointers again */
if (file->f_dentry) {
Expand Down Expand Up @@ -1245,11 +1233,7 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,
return rc;
}
} else {
#ifdef CONFIG_CIFS_STATS
spin_lock(&pTcon->stat_lock);
pTcon->bytes_read += total_read;
spin_unlock(&pTcon->stat_lock);
#endif
cifs_stats_bytes_read(pTcon, bytes_read);
*poffset += bytes_read;
}
}
Expand Down Expand Up @@ -1312,11 +1296,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
return rc;
}
} else {
#ifdef CONFIG_CIFS_STATS
spin_lock(&pTcon->stat_lock);
pTcon->bytes_read += total_read;
spin_unlock(&pTcon->stat_lock);
#endif
cifs_stats_bytes_read(pTcon, total_read);
*poffset += bytes_read;
}
}
Expand Down Expand Up @@ -1488,11 +1468,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
le16_to_cpu(pSMBr->DataOffset), &lru_pvec);

i += bytes_read >> PAGE_CACHE_SHIFT;
#ifdef CONFIG_CIFS_STATS
spin_lock(&pTcon->stat_lock);
pTcon->bytes_read += bytes_read;
spin_unlock(&pTcon->stat_lock);
#endif
cifs_stats_bytes_read(pTcon, bytes_read);
if ((int)(bytes_read & PAGE_CACHE_MASK) != bytes_read) {
i++; /* account for partial page */

Expand Down
4 changes: 1 addition & 3 deletions trunk/fs/cifs/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,9 +520,7 @@ is_valid_oplock_break(struct smb_hdr *buf)
list_for_each(tmp, &GlobalTreeConnectionList) {
tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
if (tcon->tid == buf->Tid) {
#ifdef CONFIG_CIFS_STATS
atomic_inc(&tcon->num_oplock_brks);
#endif
cifs_stats_inc(&tcon->num_oplock_brks);
list_for_each(tmp1,&tcon->openFileList){
netfile = list_entry(tmp1,struct cifsFileInfo,
tlist);
Expand Down

0 comments on commit f85e109

Please sign in to comment.