提交 0f3bc09e 编写于 作者: S Suresh Jayaraman 提交者: Steve French

cifs: Fix incorrect return code being printed in cFYI messages

FreeXid() along with freeing Xid does add a cifsFYI debug message that
prints rc (return code) as well. In some code paths where we set/return
error code after calling FreeXid(), incorrect error code is being
printed when cifsFYI is enabled.

This could be misleading in few cases. For eg.
In cifs_open() if cifs_fill_filedata() returns a valid pointer to
cifsFileInfo, FreeXid() prints rc=-13 whereas 0 is actually being
returned. Fix this by setting rc before calling FreeXid().

Basically convert

FreeXid(xid);			rc = -ERR;
return -ERR;		=>	FreeXid(xid);
				return rc;

[Note that Christoph would like to replace the GetXid/FreeXid
calls, which are primarily used for debugging.  This seems
like a good longer term goal, but although there is an
alternative tracing facility, there are no examples yet
available that I know of that we can use (yet) to
convert this cifs function entry/exit logging, and for
creating an identifier that we can use to correlate
all dmesg log entries for a particular vfs operation
(ie identify all log entries for a particular vfs
request to cifs: e.g. a particular close or read or write
or byte range lock call ... and just using the thread id
is harder).  Eventually when a replacement
for this is available (e.g. when NFS switches over and various
samples to look at in other file systems) we can remove the
GetXid/FreeXid macro but in the meantime multiple people
use this run time configurable logging all the time
for debugging, and Suresh's patch fixes a problem
which made it harder to notice some low
memory problems in the log so it is worthwhile
to fix this problem until a better logging
approach is able to be used]
Acked-by: NJeff Layton <jlayton@redhat.com>
Signed-off-by: NSuresh Jayaraman <sjayaraman@suse.de>
Signed-off-by: NSteve French <sfrench@us.ibm.com>
上级 f46c7234
...@@ -307,8 +307,9 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode, ...@@ -307,8 +307,9 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
full_path = build_path_from_dentry(direntry); full_path = build_path_from_dentry(direntry);
if (full_path == NULL) { if (full_path == NULL) {
rc = -ENOMEM;
FreeXid(xid); FreeXid(xid);
return -ENOMEM; return rc;
} }
if (oplockEnabled) if (oplockEnabled)
...@@ -540,8 +541,9 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, ...@@ -540,8 +541,9 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL); buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);
if (buf == NULL) { if (buf == NULL) {
kfree(full_path); kfree(full_path);
rc = -ENOMEM;
FreeXid(xid); FreeXid(xid);
return -ENOMEM; return rc;
} }
rc = CIFSSMBOpen(xid, pTcon, full_path, rc = CIFSSMBOpen(xid, pTcon, full_path,
......
...@@ -300,14 +300,16 @@ int cifs_open(struct inode *inode, struct file *file) ...@@ -300,14 +300,16 @@ int cifs_open(struct inode *inode, struct file *file)
pCifsInode = CIFS_I(file->f_path.dentry->d_inode); pCifsInode = CIFS_I(file->f_path.dentry->d_inode);
pCifsFile = cifs_fill_filedata(file); pCifsFile = cifs_fill_filedata(file);
if (pCifsFile) { if (pCifsFile) {
rc = 0;
FreeXid(xid); FreeXid(xid);
return 0; return rc;
} }
full_path = build_path_from_dentry(file->f_path.dentry); full_path = build_path_from_dentry(file->f_path.dentry);
if (full_path == NULL) { if (full_path == NULL) {
rc = -ENOMEM;
FreeXid(xid); FreeXid(xid);
return -ENOMEM; return rc;
} }
cFYI(1, ("inode = 0x%p file flags are 0x%x for %s", cFYI(1, ("inode = 0x%p file flags are 0x%x for %s",
...@@ -494,8 +496,9 @@ static int cifs_reopen_file(struct file *file, bool can_flush) ...@@ -494,8 +496,9 @@ static int cifs_reopen_file(struct file *file, bool can_flush)
mutex_unlock(&pCifsFile->fh_mutex); mutex_unlock(&pCifsFile->fh_mutex);
if (!pCifsFile->invalidHandle) { if (!pCifsFile->invalidHandle) {
mutex_lock(&pCifsFile->fh_mutex); mutex_lock(&pCifsFile->fh_mutex);
rc = 0;
FreeXid(xid); FreeXid(xid);
return 0; return rc;
} }
if (file->f_path.dentry == NULL) { if (file->f_path.dentry == NULL) {
...@@ -845,8 +848,9 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) ...@@ -845,8 +848,9 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
tcon = cifs_sb->tcon; tcon = cifs_sb->tcon;
if (file->private_data == NULL) { if (file->private_data == NULL) {
rc = -EBADF;
FreeXid(xid); FreeXid(xid);
return -EBADF; return rc;
} }
netfid = ((struct cifsFileInfo *)file->private_data)->netfid; netfid = ((struct cifsFileInfo *)file->private_data)->netfid;
...@@ -1805,8 +1809,9 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data, ...@@ -1805,8 +1809,9 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,
pTcon = cifs_sb->tcon; pTcon = cifs_sb->tcon;
if (file->private_data == NULL) { if (file->private_data == NULL) {
rc = -EBADF;
FreeXid(xid); FreeXid(xid);
return -EBADF; return rc;
} }
open_file = (struct cifsFileInfo *)file->private_data; open_file = (struct cifsFileInfo *)file->private_data;
...@@ -1885,8 +1890,9 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size, ...@@ -1885,8 +1890,9 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
pTcon = cifs_sb->tcon; pTcon = cifs_sb->tcon;
if (file->private_data == NULL) { if (file->private_data == NULL) {
rc = -EBADF;
FreeXid(xid); FreeXid(xid);
return -EBADF; return rc;
} }
open_file = (struct cifsFileInfo *)file->private_data; open_file = (struct cifsFileInfo *)file->private_data;
...@@ -2019,8 +2025,9 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, ...@@ -2019,8 +2025,9 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
xid = GetXid(); xid = GetXid();
if (file->private_data == NULL) { if (file->private_data == NULL) {
rc = -EBADF;
FreeXid(xid); FreeXid(xid);
return -EBADF; return rc;
} }
open_file = (struct cifsFileInfo *)file->private_data; open_file = (struct cifsFileInfo *)file->private_data;
cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
...@@ -2185,8 +2192,9 @@ static int cifs_readpage(struct file *file, struct page *page) ...@@ -2185,8 +2192,9 @@ static int cifs_readpage(struct file *file, struct page *page)
xid = GetXid(); xid = GetXid();
if (file->private_data == NULL) { if (file->private_data == NULL) {
rc = -EBADF;
FreeXid(xid); FreeXid(xid);
return -EBADF; return rc;
} }
cFYI(1, ("readpage %p at offset %d 0x%x\n", cFYI(1, ("readpage %p at offset %d 0x%x\n",
......
...@@ -988,8 +988,9 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -988,8 +988,9 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry)
* sb->s_vfs_rename_mutex here */ * sb->s_vfs_rename_mutex here */
full_path = build_path_from_dentry(dentry); full_path = build_path_from_dentry(dentry);
if (full_path == NULL) { if (full_path == NULL) {
rc = -ENOMEM;
FreeXid(xid); FreeXid(xid);
return -ENOMEM; return rc;
} }
if ((tcon->ses->capabilities & CAP_UNIX) && if ((tcon->ses->capabilities & CAP_UNIX) &&
...@@ -1118,8 +1119,9 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) ...@@ -1118,8 +1119,9 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
full_path = build_path_from_dentry(direntry); full_path = build_path_from_dentry(direntry);
if (full_path == NULL) { if (full_path == NULL) {
rc = -ENOMEM;
FreeXid(xid); FreeXid(xid);
return -ENOMEM; return rc;
} }
if ((pTcon->ses->capabilities & CAP_UNIX) && if ((pTcon->ses->capabilities & CAP_UNIX) &&
...@@ -1303,8 +1305,9 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry) ...@@ -1303,8 +1305,9 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry)
full_path = build_path_from_dentry(direntry); full_path = build_path_from_dentry(direntry);
if (full_path == NULL) { if (full_path == NULL) {
rc = -ENOMEM;
FreeXid(xid); FreeXid(xid);
return -ENOMEM; return rc;
} }
rc = CIFSSMBRmDir(xid, pTcon, full_path, cifs_sb->local_nls, rc = CIFSSMBRmDir(xid, pTcon, full_path, cifs_sb->local_nls,
...@@ -1508,8 +1511,9 @@ int cifs_revalidate(struct dentry *direntry) ...@@ -1508,8 +1511,9 @@ int cifs_revalidate(struct dentry *direntry)
since that would deadlock */ since that would deadlock */
full_path = build_path_from_dentry(direntry); full_path = build_path_from_dentry(direntry);
if (full_path == NULL) { if (full_path == NULL) {
rc = -ENOMEM;
FreeXid(xid); FreeXid(xid);
return -ENOMEM; return rc;
} }
cFYI(1, ("Revalidate: %s inode 0x%p count %d dentry: 0x%p d_time %ld " cFYI(1, ("Revalidate: %s inode 0x%p count %d dentry: 0x%p d_time %ld "
"jiffies %ld", full_path, direntry->d_inode, "jiffies %ld", full_path, direntry->d_inode,
...@@ -1911,8 +1915,9 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs) ...@@ -1911,8 +1915,9 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
full_path = build_path_from_dentry(direntry); full_path = build_path_from_dentry(direntry);
if (full_path == NULL) { if (full_path == NULL) {
rc = -ENOMEM;
FreeXid(xid); FreeXid(xid);
return -ENOMEM; return rc;
} }
/* /*
......
...@@ -172,8 +172,9 @@ cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname) ...@@ -172,8 +172,9 @@ cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname)
full_path = build_path_from_dentry(direntry); full_path = build_path_from_dentry(direntry);
if (full_path == NULL) { if (full_path == NULL) {
rc = -ENOMEM;
FreeXid(xid); FreeXid(xid);
return -ENOMEM; return rc;
} }
cFYI(1, ("Full path: %s", full_path)); cFYI(1, ("Full path: %s", full_path));
......
...@@ -64,8 +64,9 @@ int cifs_removexattr(struct dentry *direntry, const char *ea_name) ...@@ -64,8 +64,9 @@ int cifs_removexattr(struct dentry *direntry, const char *ea_name)
full_path = build_path_from_dentry(direntry); full_path = build_path_from_dentry(direntry);
if (full_path == NULL) { if (full_path == NULL) {
rc = -ENOMEM;
FreeXid(xid); FreeXid(xid);
return -ENOMEM; return rc;
} }
if (ea_name == NULL) { if (ea_name == NULL) {
cFYI(1, ("Null xattr names not supported")); cFYI(1, ("Null xattr names not supported"));
...@@ -118,8 +119,9 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name, ...@@ -118,8 +119,9 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name,
full_path = build_path_from_dentry(direntry); full_path = build_path_from_dentry(direntry);
if (full_path == NULL) { if (full_path == NULL) {
rc = -ENOMEM;
FreeXid(xid); FreeXid(xid);
return -ENOMEM; return rc;
} }
/* return dos attributes as pseudo xattr */ /* return dos attributes as pseudo xattr */
/* return alt name if available as pseudo attr */ /* return alt name if available as pseudo attr */
...@@ -225,8 +227,9 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name, ...@@ -225,8 +227,9 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name,
full_path = build_path_from_dentry(direntry); full_path = build_path_from_dentry(direntry);
if (full_path == NULL) { if (full_path == NULL) {
rc = -ENOMEM;
FreeXid(xid); FreeXid(xid);
return -ENOMEM; return rc;
} }
/* return dos attributes as pseudo xattr */ /* return dos attributes as pseudo xattr */
/* return alt name if available as pseudo attr */ /* return alt name if available as pseudo attr */
...@@ -351,8 +354,9 @@ ssize_t cifs_listxattr(struct dentry *direntry, char *data, size_t buf_size) ...@@ -351,8 +354,9 @@ ssize_t cifs_listxattr(struct dentry *direntry, char *data, size_t buf_size)
full_path = build_path_from_dentry(direntry); full_path = build_path_from_dentry(direntry);
if (full_path == NULL) { if (full_path == NULL) {
rc = -ENOMEM;
FreeXid(xid); FreeXid(xid);
return -ENOMEM; return rc;
} }
/* return dos attributes as pseudo xattr */ /* return dos attributes as pseudo xattr */
/* return alt name if available as pseudo attr */ /* return alt name if available as pseudo attr */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册