提交 a4544347 编写于 作者: S Steve French

CIFS: Reduce CONFIG_CIFS_STATS ifdefs

Make cifs_stats code conditional in the header files to avoid ifdefs in the
main code.
Signed-off-by: NDave Kleikamp <shaggy@austin.ibm.com>
Signed-off-by: NSteve French <sfrench@us.ibm.com>
上级 6b8edfe0
...@@ -339,6 +339,34 @@ static inline const char CIFS_DIR_SEP(const struct cifs_sb_info *cifs_sb) ...@@ -339,6 +339,34 @@ static inline const char CIFS_DIR_SEP(const struct cifs_sb_info *cifs_sb)
return '\\'; 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 */ /* one of these for every pending CIFS request to the server */
struct mid_q_entry { struct mid_q_entry {
struct list_head qhead; /* mids waiting on reply from this server */ struct list_head qhead; /* mids waiting on reply from this server */
......
...@@ -166,11 +166,9 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon, ...@@ -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); header_assemble((struct smb_hdr *) *request_buf, smb_command, tcon,wct);
#ifdef CONFIG_CIFS_STATS if(tcon != NULL)
if(tcon != NULL) { cifs_stats_inc(&tcon->num_smbs_sent);
atomic_inc(&tcon->num_smbs_sent);
}
#endif /* CONFIG_CIFS_STATS */
return rc; return rc;
} }
...@@ -269,11 +267,9 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon, ...@@ -269,11 +267,9 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
header_assemble((struct smb_hdr *) *request_buf, smb_command, tcon, header_assemble((struct smb_hdr *) *request_buf, smb_command, tcon,
wct /*wct */ ); wct /*wct */ );
#ifdef CONFIG_CIFS_STATS if(tcon != NULL)
if(tcon != NULL) { cifs_stats_inc(&tcon->num_smbs_sent);
atomic_inc(&tcon->num_smbs_sent);
}
#endif /* CONFIG_CIFS_STATS */
return rc; return rc;
} }
...@@ -584,9 +580,7 @@ CIFSSMBDelFile(const int xid, struct cifsTconInfo *tcon, const char *fileName, ...@@ -584,9 +580,7 @@ CIFSSMBDelFile(const int xid, struct cifsTconInfo *tcon, const char *fileName,
pSMB->ByteCount = cpu_to_le16(name_len + 1); pSMB->ByteCount = cpu_to_le16(name_len + 1);
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0); (struct smb_hdr *) pSMBr, &bytes_returned, 0);
#ifdef CONFIG_CIFS_STATS cifs_stats_inc(&tcon->num_deletes);
atomic_inc(&tcon->num_deletes);
#endif
if (rc) { if (rc) {
cFYI(1, ("Error in RMFile = %d", rc)); cFYI(1, ("Error in RMFile = %d", rc));
} }
...@@ -631,9 +625,7 @@ CIFSSMBRmDir(const int xid, struct cifsTconInfo *tcon, const char *dirName, ...@@ -631,9 +625,7 @@ CIFSSMBRmDir(const int xid, struct cifsTconInfo *tcon, const char *dirName,
pSMB->ByteCount = cpu_to_le16(name_len + 1); pSMB->ByteCount = cpu_to_le16(name_len + 1);
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0); (struct smb_hdr *) pSMBr, &bytes_returned, 0);
#ifdef CONFIG_CIFS_STATS cifs_stats_inc(&tcon->num_rmdirs);
atomic_inc(&tcon->num_rmdirs);
#endif
if (rc) { if (rc) {
cFYI(1, ("Error in RMDir = %d", rc)); cFYI(1, ("Error in RMDir = %d", rc));
} }
...@@ -677,9 +669,7 @@ CIFSSMBMkDir(const int xid, struct cifsTconInfo *tcon, ...@@ -677,9 +669,7 @@ CIFSSMBMkDir(const int xid, struct cifsTconInfo *tcon,
pSMB->ByteCount = cpu_to_le16(name_len + 1); pSMB->ByteCount = cpu_to_le16(name_len + 1);
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0); (struct smb_hdr *) pSMBr, &bytes_returned, 0);
#ifdef CONFIG_CIFS_STATS cifs_stats_inc(&tcon->num_mkdirs);
atomic_inc(&tcon->num_mkdirs);
#endif
if (rc) { if (rc) {
cFYI(1, ("Error in Mkdir = %d", rc)); cFYI(1, ("Error in Mkdir = %d", rc));
} }
...@@ -767,9 +757,7 @@ CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon, ...@@ -767,9 +757,7 @@ CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon,
/* long_op set to 1 to allow for oplock break timeouts */ /* long_op set to 1 to allow for oplock break timeouts */
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 1); (struct smb_hdr *) pSMBr, &bytes_returned, 1);
#ifdef CONFIG_CIFS_STATS cifs_stats_inc(&tcon->num_opens);
atomic_inc(&tcon->num_opens);
#endif
if (rc) { if (rc) {
cFYI(1, ("Error in Open = %d", rc)); cFYI(1, ("Error in Open = %d", rc));
} else { } else {
...@@ -833,9 +821,7 @@ CIFSSMBRead(const int xid, struct cifsTconInfo *tcon, ...@@ -833,9 +821,7 @@ CIFSSMBRead(const int xid, struct cifsTconInfo *tcon,
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0); (struct smb_hdr *) pSMBr, &bytes_returned, 0);
#ifdef CONFIG_CIFS_STATS cifs_stats_inc(&tcon->num_reads);
atomic_inc(&tcon->num_reads);
#endif
if (rc) { if (rc) {
cERROR(1, ("Send error in read = %d", rc)); cERROR(1, ("Send error in read = %d", rc));
} else { } else {
...@@ -938,9 +924,7 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon, ...@@ -938,9 +924,7 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, long_op); (struct smb_hdr *) pSMBr, &bytes_returned, long_op);
#ifdef CONFIG_CIFS_STATS cifs_stats_inc(&tcon->num_writes);
atomic_inc(&tcon->num_writes);
#endif
if (rc) { if (rc) {
cFYI(1, ("Send error in write = %d", rc)); cFYI(1, ("Send error in write = %d", rc));
*nbytes = 0; *nbytes = 0;
...@@ -1013,9 +997,7 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon, ...@@ -1013,9 +997,7 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
rc = SendReceive2(xid, tcon->ses, (struct smb_hdr *) pSMB, smb_hdr_len, rc = SendReceive2(xid, tcon->ses, (struct smb_hdr *) pSMB, smb_hdr_len,
buf, bytes_sent, &bytes_returned, long_op); buf, bytes_sent, &bytes_returned, long_op);
#ifdef CONFIG_CIFS_STATS cifs_stats_inc(&tcon->num_writes);
atomic_inc(&tcon->num_writes);
#endif
if (rc) { if (rc) {
cFYI(1, ("Send error in write = %d", rc)); cFYI(1, ("Send error in write = %d", rc));
*nbytes = 0; *nbytes = 0;
...@@ -1091,9 +1073,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon, ...@@ -1091,9 +1073,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, timeout); (struct smb_hdr *) pSMBr, &bytes_returned, timeout);
#ifdef CONFIG_CIFS_STATS cifs_stats_inc(&tcon->num_locks);
atomic_inc(&tcon->num_locks);
#endif
if (rc) { if (rc) {
cFYI(1, ("Send error in Lock = %d", rc)); cFYI(1, ("Send error in Lock = %d", rc));
} }
...@@ -1127,9 +1107,7 @@ CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, int smb_file_id) ...@@ -1127,9 +1107,7 @@ CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, int smb_file_id)
pSMB->ByteCount = 0; pSMB->ByteCount = 0;
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0); (struct smb_hdr *) pSMBr, &bytes_returned, 0);
#ifdef CONFIG_CIFS_STATS cifs_stats_inc(&tcon->num_closes);
atomic_inc(&tcon->num_closes);
#endif
if (rc) { if (rc) {
if(rc!=-EINTR) { if(rc!=-EINTR) {
/* EINTR is expected when user ctl-c to kill app */ /* EINTR is expected when user ctl-c to kill app */
...@@ -1202,9 +1180,7 @@ CIFSSMBRename(const int xid, struct cifsTconInfo *tcon, ...@@ -1202,9 +1180,7 @@ CIFSSMBRename(const int xid, struct cifsTconInfo *tcon,
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0); (struct smb_hdr *) pSMBr, &bytes_returned, 0);
#ifdef CONFIG_CIFS_STATS cifs_stats_inc(&tcon->num_renames);
atomic_inc(&tcon->num_renames);
#endif
if (rc) { if (rc) {
cFYI(1, ("Send error in rename = %d", rc)); cFYI(1, ("Send error in rename = %d", rc));
} }
...@@ -1283,9 +1259,7 @@ int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon, ...@@ -1283,9 +1259,7 @@ int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon,
pSMB->ByteCount = cpu_to_le16(byte_count); pSMB->ByteCount = cpu_to_le16(byte_count);
rc = SendReceive(xid, pTcon->ses, (struct smb_hdr *) pSMB, rc = SendReceive(xid, pTcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0); (struct smb_hdr *) pSMBr, &bytes_returned, 0);
#ifdef CONFIG_CIFS_STATS cifs_stats_inc(&pTcon->num_t2renames);
atomic_inc(&pTcon->num_t2renames);
#endif
if (rc) { if (rc) {
cFYI(1,("Send error in Rename (by file handle) = %d", rc)); cFYI(1,("Send error in Rename (by file handle) = %d", rc));
} }
...@@ -1443,9 +1417,7 @@ CIFSUnixCreateSymLink(const int xid, struct cifsTconInfo *tcon, ...@@ -1443,9 +1417,7 @@ CIFSUnixCreateSymLink(const int xid, struct cifsTconInfo *tcon,
pSMB->ByteCount = cpu_to_le16(byte_count); pSMB->ByteCount = cpu_to_le16(byte_count);
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0); (struct smb_hdr *) pSMBr, &bytes_returned, 0);
#ifdef CONFIG_CIFS_STATS cifs_stats_inc(&tcon->num_symlinks);
atomic_inc(&tcon->num_symlinks);
#endif
if (rc) { if (rc) {
cFYI(1, cFYI(1,
("Send error in SetPathInfo (create symlink) = %d", ("Send error in SetPathInfo (create symlink) = %d",
...@@ -1535,9 +1507,7 @@ CIFSUnixCreateHardLink(const int xid, struct cifsTconInfo *tcon, ...@@ -1535,9 +1507,7 @@ CIFSUnixCreateHardLink(const int xid, struct cifsTconInfo *tcon,
pSMB->ByteCount = cpu_to_le16(byte_count); pSMB->ByteCount = cpu_to_le16(byte_count);
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0); (struct smb_hdr *) pSMBr, &bytes_returned, 0);
#ifdef CONFIG_CIFS_STATS cifs_stats_inc(&tcon->num_hardlinks);
atomic_inc(&tcon->num_hardlinks);
#endif
if (rc) { if (rc) {
cFYI(1, ("Send error in SetPathInfo (hard link) = %d", rc)); cFYI(1, ("Send error in SetPathInfo (hard link) = %d", rc));
} }
...@@ -1608,9 +1578,7 @@ CIFSCreateHardLink(const int xid, struct cifsTconInfo *tcon, ...@@ -1608,9 +1578,7 @@ CIFSCreateHardLink(const int xid, struct cifsTconInfo *tcon,
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0); (struct smb_hdr *) pSMBr, &bytes_returned, 0);
#ifdef CONFIG_CIFS_STATS cifs_stats_inc(&tcon->num_hardlinks);
atomic_inc(&tcon->num_hardlinks);
#endif
if (rc) { if (rc) {
cFYI(1, ("Send error in hard link (NT rename) = %d", rc)); cFYI(1, ("Send error in hard link (NT rename) = %d", rc));
} }
...@@ -2490,9 +2458,7 @@ int CIFSFindSingle(const int xid, struct cifsTconInfo *tcon, ...@@ -2490,9 +2458,7 @@ int CIFSFindSingle(const int xid, struct cifsTconInfo *tcon,
if (rc) { if (rc) {
cFYI(1, ("Send error in FindFileDirInfo = %d", rc)); cFYI(1, ("Send error in FindFileDirInfo = %d", rc));
} else { /* decode response */ } else { /* decode response */
#ifdef CONFIG_CIFS_STATS cifs_stats_inc(&tcon->num_ffirst);
atomic_inc(&tcon->num_ffirst);
#endif
/* BB fill in */ /* BB fill in */
} }
...@@ -2592,9 +2558,7 @@ CIFSFindFirst(const int xid, struct cifsTconInfo *tcon, ...@@ -2592,9 +2558,7 @@ CIFSFindFirst(const int xid, struct cifsTconInfo *tcon,
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0); (struct smb_hdr *) pSMBr, &bytes_returned, 0);
#ifdef CONFIG_CIFS_STATS cifs_stats_inc(&tcon->num_ffirst);
atomic_inc(&tcon->num_ffirst);
#endif
if (rc) {/* BB add logic to retry regular search if Unix search rejected unexpectedly by server */ if (rc) {/* BB add logic to retry regular search if Unix search rejected unexpectedly by server */
/* BB Add code to handle unsupported level rc */ /* BB Add code to handle unsupported level rc */
...@@ -2716,9 +2680,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon, ...@@ -2716,9 +2680,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0); (struct smb_hdr *) pSMBr, &bytes_returned, 0);
#ifdef CONFIG_CIFS_STATS cifs_stats_inc(&tcon->num_fnext);
atomic_inc(&tcon->num_fnext);
#endif
if (rc) { if (rc) {
if (rc == -EBADF) { if (rc == -EBADF) {
psrch_inf->endOfSearch = TRUE; psrch_inf->endOfSearch = TRUE;
...@@ -2795,9 +2757,7 @@ CIFSFindClose(const int xid, struct cifsTconInfo *tcon, const __u16 searchHandle ...@@ -2795,9 +2757,7 @@ CIFSFindClose(const int xid, struct cifsTconInfo *tcon, const __u16 searchHandle
if (rc) { if (rc) {
cERROR(1, ("Send error in FindClose = %d", rc)); cERROR(1, ("Send error in FindClose = %d", rc));
} }
#ifdef CONFIG_CIFS_STATS cifs_stats_inc(&tcon->num_fclose);
atomic_inc(&tcon->num_fclose);
#endif
cifs_small_buf_release(pSMB); cifs_small_buf_release(pSMB);
/* Since session is dead, search handle closed on server already */ /* Since session is dead, search handle closed on server already */
......
...@@ -744,13 +744,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data, ...@@ -744,13 +744,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
15 seconds is plenty */ 15 seconds is plenty */
} }
#ifdef CONFIG_CIFS_STATS cifs_stats_bytes_written(pTcon, total_written);
if (total_written > 0) {
spin_lock(&pTcon->stat_lock);
pTcon->bytes_written += total_written;
spin_unlock(&pTcon->stat_lock);
}
#endif
/* since the write may have blocked check these pointers again */ /* since the write may have blocked check these pointers again */
if (file->f_dentry) { if (file->f_dentry) {
...@@ -878,13 +872,7 @@ static ssize_t cifs_write(struct file *file, const char *write_data, ...@@ -878,13 +872,7 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
15 seconds is plenty */ 15 seconds is plenty */
} }
#ifdef CONFIG_CIFS_STATS cifs_stats_bytes_written(pTcon, total_written);
if (total_written > 0) {
spin_lock(&pTcon->stat_lock);
pTcon->bytes_written += total_written;
spin_unlock(&pTcon->stat_lock);
}
#endif
/* since the write may have blocked check these pointers again */ /* since the write may have blocked check these pointers again */
if (file->f_dentry) { if (file->f_dentry) {
...@@ -1245,11 +1233,7 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data, ...@@ -1245,11 +1233,7 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,
return rc; return rc;
} }
} else { } else {
#ifdef CONFIG_CIFS_STATS cifs_stats_bytes_read(pTcon, bytes_read);
spin_lock(&pTcon->stat_lock);
pTcon->bytes_read += total_read;
spin_unlock(&pTcon->stat_lock);
#endif
*poffset += bytes_read; *poffset += bytes_read;
} }
} }
...@@ -1312,11 +1296,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size, ...@@ -1312,11 +1296,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
return rc; return rc;
} }
} else { } else {
#ifdef CONFIG_CIFS_STATS cifs_stats_bytes_read(pTcon, total_read);
spin_lock(&pTcon->stat_lock);
pTcon->bytes_read += total_read;
spin_unlock(&pTcon->stat_lock);
#endif
*poffset += bytes_read; *poffset += bytes_read;
} }
} }
...@@ -1488,11 +1468,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, ...@@ -1488,11 +1468,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
le16_to_cpu(pSMBr->DataOffset), &lru_pvec); le16_to_cpu(pSMBr->DataOffset), &lru_pvec);
i += bytes_read >> PAGE_CACHE_SHIFT; i += bytes_read >> PAGE_CACHE_SHIFT;
#ifdef CONFIG_CIFS_STATS cifs_stats_bytes_read(pTcon, bytes_read);
spin_lock(&pTcon->stat_lock);
pTcon->bytes_read += bytes_read;
spin_unlock(&pTcon->stat_lock);
#endif
if ((int)(bytes_read & PAGE_CACHE_MASK) != bytes_read) { if ((int)(bytes_read & PAGE_CACHE_MASK) != bytes_read) {
i++; /* account for partial page */ i++; /* account for partial page */
......
...@@ -520,9 +520,7 @@ is_valid_oplock_break(struct smb_hdr *buf) ...@@ -520,9 +520,7 @@ is_valid_oplock_break(struct smb_hdr *buf)
list_for_each(tmp, &GlobalTreeConnectionList) { list_for_each(tmp, &GlobalTreeConnectionList) {
tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
if (tcon->tid == buf->Tid) { if (tcon->tid == buf->Tid) {
#ifdef CONFIG_CIFS_STATS cifs_stats_inc(&tcon->num_oplock_brks);
atomic_inc(&tcon->num_oplock_brks);
#endif
list_for_each(tmp1,&tcon->openFileList){ list_for_each(tmp1,&tcon->openFileList){
netfile = list_entry(tmp1,struct cifsFileInfo, netfile = list_entry(tmp1,struct cifsFileInfo,
tlist); tlist);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册