Skip to content

Commit

Permalink
cifs: Fix incorrect return code being printed in cFYI messages
Browse files Browse the repository at this point in the history
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: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
Signed-off-by: Steve French <sfrench@us.ibm.com>
  • Loading branch information
Suresh Jayaraman authored and Steve French committed Jun 25, 2009
1 parent f46c723 commit 0f3bc09
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 20 deletions.
6 changes: 4 additions & 2 deletions fs/cifs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,9 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,

full_path = build_path_from_dentry(direntry);
if (full_path == NULL) {
rc = -ENOMEM;
FreeXid(xid);
return -ENOMEM;
return rc;
}

if (oplockEnabled)
Expand Down Expand Up @@ -540,8 +541,9 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);
if (buf == NULL) {
kfree(full_path);
rc = -ENOMEM;
FreeXid(xid);
return -ENOMEM;
return rc;
}

rc = CIFSSMBOpen(xid, pTcon, full_path,
Expand Down
24 changes: 16 additions & 8 deletions fs/cifs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,14 +300,16 @@ int cifs_open(struct inode *inode, struct file *file)
pCifsInode = CIFS_I(file->f_path.dentry->d_inode);
pCifsFile = cifs_fill_filedata(file);
if (pCifsFile) {
rc = 0;
FreeXid(xid);
return 0;
return rc;
}

full_path = build_path_from_dentry(file->f_path.dentry);
if (full_path == NULL) {
rc = -ENOMEM;
FreeXid(xid);
return -ENOMEM;
return rc;
}

cFYI(1, ("inode = 0x%p file flags are 0x%x for %s",
Expand Down Expand Up @@ -494,8 +496,9 @@ static int cifs_reopen_file(struct file *file, bool can_flush)
mutex_unlock(&pCifsFile->fh_mutex);
if (!pCifsFile->invalidHandle) {
mutex_lock(&pCifsFile->fh_mutex);
rc = 0;
FreeXid(xid);
return 0;
return rc;
}

if (file->f_path.dentry == NULL) {
Expand Down Expand Up @@ -845,8 +848,9 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
tcon = cifs_sb->tcon;

if (file->private_data == NULL) {
rc = -EBADF;
FreeXid(xid);
return -EBADF;
return rc;
}
netfid = ((struct cifsFileInfo *)file->private_data)->netfid;

Expand Down Expand Up @@ -1805,8 +1809,9 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,
pTcon = cifs_sb->tcon;

if (file->private_data == NULL) {
rc = -EBADF;
FreeXid(xid);
return -EBADF;
return rc;
}
open_file = (struct cifsFileInfo *)file->private_data;

Expand Down Expand Up @@ -1885,8 +1890,9 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
pTcon = cifs_sb->tcon;

if (file->private_data == NULL) {
rc = -EBADF;
FreeXid(xid);
return -EBADF;
return rc;
}
open_file = (struct cifsFileInfo *)file->private_data;

Expand Down Expand Up @@ -2019,8 +2025,9 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,

xid = GetXid();
if (file->private_data == NULL) {
rc = -EBADF;
FreeXid(xid);
return -EBADF;
return rc;
}
open_file = (struct cifsFileInfo *)file->private_data;
cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
Expand Down Expand Up @@ -2185,8 +2192,9 @@ static int cifs_readpage(struct file *file, struct page *page)
xid = GetXid();

if (file->private_data == NULL) {
rc = -EBADF;
FreeXid(xid);
return -EBADF;
return rc;
}

cFYI(1, ("readpage %p at offset %d 0x%x\n",
Expand Down
15 changes: 10 additions & 5 deletions fs/cifs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -988,8 +988,9 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry)
* sb->s_vfs_rename_mutex here */
full_path = build_path_from_dentry(dentry);
if (full_path == NULL) {
rc = -ENOMEM;
FreeXid(xid);
return -ENOMEM;
return rc;
}

if ((tcon->ses->capabilities & CAP_UNIX) &&
Expand Down Expand Up @@ -1118,8 +1119,9 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)

full_path = build_path_from_dentry(direntry);
if (full_path == NULL) {
rc = -ENOMEM;
FreeXid(xid);
return -ENOMEM;
return rc;
}

if ((pTcon->ses->capabilities & CAP_UNIX) &&
Expand Down Expand Up @@ -1303,8 +1305,9 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry)

full_path = build_path_from_dentry(direntry);
if (full_path == NULL) {
rc = -ENOMEM;
FreeXid(xid);
return -ENOMEM;
return rc;
}

rc = CIFSSMBRmDir(xid, pTcon, full_path, cifs_sb->local_nls,
Expand Down Expand Up @@ -1508,8 +1511,9 @@ int cifs_revalidate(struct dentry *direntry)
since that would deadlock */
full_path = build_path_from_dentry(direntry);
if (full_path == NULL) {
rc = -ENOMEM;
FreeXid(xid);
return -ENOMEM;
return rc;
}
cFYI(1, ("Revalidate: %s inode 0x%p count %d dentry: 0x%p d_time %ld "
"jiffies %ld", full_path, direntry->d_inode,
Expand Down Expand Up @@ -1911,8 +1915,9 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)

full_path = build_path_from_dentry(direntry);
if (full_path == NULL) {
rc = -ENOMEM;
FreeXid(xid);
return -ENOMEM;
return rc;
}

/*
Expand Down
3 changes: 2 additions & 1 deletion fs/cifs/link.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname)
full_path = build_path_from_dentry(direntry);

if (full_path == NULL) {
rc = -ENOMEM;
FreeXid(xid);
return -ENOMEM;
return rc;
}

cFYI(1, ("Full path: %s", full_path));
Expand Down
12 changes: 8 additions & 4 deletions fs/cifs/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ int cifs_removexattr(struct dentry *direntry, const char *ea_name)

full_path = build_path_from_dentry(direntry);
if (full_path == NULL) {
rc = -ENOMEM;
FreeXid(xid);
return -ENOMEM;
return rc;
}
if (ea_name == NULL) {
cFYI(1, ("Null xattr names not supported"));
Expand Down Expand Up @@ -118,8 +119,9 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name,

full_path = build_path_from_dentry(direntry);
if (full_path == NULL) {
rc = -ENOMEM;
FreeXid(xid);
return -ENOMEM;
return rc;
}
/* return dos attributes as pseudo xattr */
/* return alt name if available as pseudo attr */
Expand Down Expand Up @@ -225,8 +227,9 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name,

full_path = build_path_from_dentry(direntry);
if (full_path == NULL) {
rc = -ENOMEM;
FreeXid(xid);
return -ENOMEM;
return rc;
}
/* return dos attributes as pseudo xattr */
/* return alt name if available as pseudo attr */
Expand Down Expand Up @@ -351,8 +354,9 @@ ssize_t cifs_listxattr(struct dentry *direntry, char *data, size_t buf_size)

full_path = build_path_from_dentry(direntry);
if (full_path == NULL) {
rc = -ENOMEM;
FreeXid(xid);
return -ENOMEM;
return rc;
}
/* return dos attributes as pseudo xattr */
/* return alt name if available as pseudo attr */
Expand Down

0 comments on commit 0f3bc09

Please sign in to comment.