Commit 3a9f462f authored by Steve French's avatar Steve French

[CIFS] Remove unnecessary parm to cifs_reopen_file

Also expand debug entry to show which character on a failed Unicode
mapping.
Acked-by: default avatarShaggy <shaggy@us.ibm.com>
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent aaf737ad
...@@ -74,8 +74,8 @@ cifs_strtoUCS(__le16 * to, const char *from, int len, ...@@ -74,8 +74,8 @@ cifs_strtoUCS(__le16 * to, const char *from, int len,
charlen = codepage->char2uni(from, len, &wchar_to[i]); charlen = codepage->char2uni(from, len, &wchar_to[i]);
if (charlen < 1) { if (charlen < 1) {
cERROR(1, cERROR(1,
("cifs_strtoUCS: char2uni returned %d", ("strtoUCS: char2uni of %d returned %d",
charlen)); (int)*from, charlen));
/* A question mark */ /* A question mark */
to[i] = cpu_to_le16(0x003f); to[i] = cpu_to_le16(0x003f);
charlen = 1; charlen = 1;
......
...@@ -338,8 +338,7 @@ static int cifs_relock_file(struct cifsFileInfo *cifsFile) ...@@ -338,8 +338,7 @@ static int cifs_relock_file(struct cifsFileInfo *cifsFile)
return rc; return rc;
} }
static int cifs_reopen_file(struct inode *inode, struct file *file, static int cifs_reopen_file(struct file *file, int can_flush)
int can_flush)
{ {
int rc = -EACCES; int rc = -EACCES;
int xid, oplock; int xid, oplock;
...@@ -347,13 +346,12 @@ static int cifs_reopen_file(struct inode *inode, struct file *file, ...@@ -347,13 +346,12 @@ static int cifs_reopen_file(struct inode *inode, struct file *file,
struct cifsTconInfo *pTcon; struct cifsTconInfo *pTcon;
struct cifsFileInfo *pCifsFile; struct cifsFileInfo *pCifsFile;
struct cifsInodeInfo *pCifsInode; struct cifsInodeInfo *pCifsInode;
struct inode * inode;
char *full_path = NULL; char *full_path = NULL;
int desiredAccess; int desiredAccess;
int disposition = FILE_OPEN; int disposition = FILE_OPEN;
__u16 netfid; __u16 netfid;
if (inode == NULL)
return -EBADF;
if (file->private_data) { if (file->private_data) {
pCifsFile = (struct cifsFileInfo *)file->private_data; pCifsFile = (struct cifsFileInfo *)file->private_data;
} else } else
...@@ -368,25 +366,37 @@ static int cifs_reopen_file(struct inode *inode, struct file *file, ...@@ -368,25 +366,37 @@ static int cifs_reopen_file(struct inode *inode, struct file *file,
} }
if (file->f_path.dentry == NULL) { if (file->f_path.dentry == NULL) {
up(&pCifsFile->fh_sem); cERROR(1, ("no valid name if dentry freed"));
cFYI(1, ("failed file reopen, no valid name if dentry freed")); dump_stack();
FreeXid(xid); rc = -EBADF;
return -EBADF; goto reopen_error_exit;
}
inode = file->f_path.dentry->d_inode;
if(inode == NULL) {
cERROR(1, ("inode not valid"));
dump_stack();
rc = -EBADF;
goto reopen_error_exit;
} }
cifs_sb = CIFS_SB(inode->i_sb); cifs_sb = CIFS_SB(inode->i_sb);
pTcon = cifs_sb->tcon; pTcon = cifs_sb->tcon;
/* can not grab rename sem here because various ops, including /* can not grab rename sem here because various ops, including
those that already have the rename sem can end up causing writepage those that already have the rename sem can end up causing writepage
to get called and if the server was down that means we end up here, to get called and if the server was down that means we end up here,
and we can never tell if the caller already has the rename_sem */ and we can never tell if the caller already has the rename_sem */
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;
reopen_error_exit:
up(&pCifsFile->fh_sem); up(&pCifsFile->fh_sem);
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 0x%x for %s",
inode, file->f_flags,full_path)); inode, file->f_flags,full_path));
desiredAccess = cifs_convert_flags(file->f_flags); desiredAccess = cifs_convert_flags(file->f_flags);
...@@ -401,13 +411,6 @@ static int cifs_reopen_file(struct inode *inode, struct file *file, ...@@ -401,13 +411,6 @@ static int cifs_reopen_file(struct inode *inode, struct file *file,
and server version of file size can be stale. If we knew for sure and server version of file size can be stale. If we knew for sure
that inode was not dirty locally we could do this */ that inode was not dirty locally we could do this */
/* buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);
if (buf == 0) {
up(&pCifsFile->fh_sem);
kfree(full_path);
FreeXid(xid);
return -ENOMEM;
} */
rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, desiredAccess, rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, desiredAccess,
CREATE_NOT_DIR, &netfid, &oplock, NULL, CREATE_NOT_DIR, &netfid, &oplock, NULL,
cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
...@@ -831,17 +834,11 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data, ...@@ -831,17 +834,11 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
return -EBADF; return -EBADF;
} }
if (open_file->invalidHandle) { if (open_file->invalidHandle) {
if ((file->f_path.dentry == NULL) ||
(file->f_path.dentry->d_inode == NULL)) {
FreeXid(xid);
return total_written;
}
/* we could deadlock if we called /* we could deadlock if we called
filemap_fdatawait from here so tell filemap_fdatawait from here so tell
reopen_file not to flush data to server reopen_file not to flush data to server
now */ now */
rc = cifs_reopen_file(file->f_path.dentry->d_inode, rc = cifs_reopen_file(file, FALSE);
file, FALSE);
if (rc != 0) if (rc != 0)
break; break;
} }
...@@ -941,8 +938,7 @@ static ssize_t cifs_write(struct file *file, const char *write_data, ...@@ -941,8 +938,7 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
filemap_fdatawait from here so tell filemap_fdatawait from here so tell
reopen_file not to flush data to reopen_file not to flush data to
server now */ server now */
rc = cifs_reopen_file(file->f_path.dentry->d_inode, rc = cifs_reopen_file(file, FALSE);
file, FALSE);
if (rc != 0) if (rc != 0)
break; break;
} }
...@@ -1031,8 +1027,7 @@ struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode) ...@@ -1031,8 +1027,7 @@ struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode)
read_unlock(&GlobalSMBSeslock); read_unlock(&GlobalSMBSeslock);
if((open_file->invalidHandle) && if((open_file->invalidHandle) &&
(!open_file->closePend) /* BB fixme -since the second clause can not be true remove it BB */) { (!open_file->closePend) /* BB fixme -since the second clause can not be true remove it BB */) {
rc = cifs_reopen_file(&cifs_inode->vfs_inode, rc = cifs_reopen_file(open_file->pfile, FALSE);
open_file->pfile, FALSE);
/* if it fails, try another handle - might be */ /* if it fails, try another handle - might be */
/* dangerous to hold up writepages with retry */ /* dangerous to hold up writepages with retry */
if(rc) { if(rc) {
...@@ -1379,32 +1374,6 @@ static int cifs_commit_write(struct file *file, struct page *page, ...@@ -1379,32 +1374,6 @@ static int cifs_commit_write(struct file *file, struct page *page,
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
if (position > inode->i_size) { if (position > inode->i_size) {
i_size_write(inode, position); i_size_write(inode, position);
/* if (file->private_data == NULL) {
rc = -EBADF;
} else {
open_file = (struct cifsFileInfo *)file->private_data;
cifs_sb = CIFS_SB(inode->i_sb);
rc = -EAGAIN;
while (rc == -EAGAIN) {
if ((open_file->invalidHandle) &&
(!open_file->closePend)) {
rc = cifs_reopen_file(
file->f_path.dentry->d_inode, file);
if (rc != 0)
break;
}
if (!open_file->closePend) {
rc = CIFSSMBSetFileSize(xid,
cifs_sb->tcon, position,
open_file->netfid,
open_file->pid, FALSE);
} else {
rc = -EBADF;
break;
}
}
cFYI(1, (" SetEOF (commit write) rc = %d", rc));
} */
} }
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
if (!PageUptodate(page)) { if (!PageUptodate(page)) {
...@@ -1548,8 +1517,7 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data, ...@@ -1548,8 +1517,7 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,
int buf_type = CIFS_NO_BUFFER; int buf_type = CIFS_NO_BUFFER;
if ((open_file->invalidHandle) && if ((open_file->invalidHandle) &&
(!open_file->closePend)) { (!open_file->closePend)) {
rc = cifs_reopen_file(file->f_path.dentry->d_inode, rc = cifs_reopen_file(file, TRUE);
file, TRUE);
if (rc != 0) if (rc != 0)
break; break;
} }
...@@ -1635,8 +1603,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size, ...@@ -1635,8 +1603,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
while (rc == -EAGAIN) { while (rc == -EAGAIN) {
if ((open_file->invalidHandle) && if ((open_file->invalidHandle) &&
(!open_file->closePend)) { (!open_file->closePend)) {
rc = cifs_reopen_file(file->f_path.dentry->d_inode, rc = cifs_reopen_file(file, TRUE);
file, TRUE);
if (rc != 0) if (rc != 0)
break; break;
} }
...@@ -1792,8 +1759,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, ...@@ -1792,8 +1759,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
while (rc == -EAGAIN) { while (rc == -EAGAIN) {
if ((open_file->invalidHandle) && if ((open_file->invalidHandle) &&
(!open_file->closePend)) { (!open_file->closePend)) {
rc = cifs_reopen_file(file->f_path.dentry->d_inode, rc = cifs_reopen_file(file, TRUE);
file, TRUE);
if (rc != 0) if (rc != 0)
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment