aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2010-09-20 19:01:31 -0400
committerSteve French <sfrench@us.ibm.com>2010-09-29 15:04:32 -0400
commitba00ba64cf0895e4c2ac507e56306363dc125a90 (patch)
tree8edcd34f27aa623535fc5d640aa75c6dbb0d7a65
parentd3bf5221d3274b5015ad18a55060b074cca8d2f0 (diff)
cifs: make various routines use the cifsFileInfo->tcon pointer
...where it's available and appropriate. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
-rw-r--r--fs/cifs/cifsfs.c4
-rw-r--r--fs/cifs/file.c39
-rw-r--r--fs/cifs/inode.c22
-rw-r--r--fs/cifs/ioctl.c17
-rw-r--r--fs/cifs/readdir.c19
5 files changed, 45 insertions, 56 deletions
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index eeb8c67a3f29..7193494efc03 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -589,6 +589,7 @@ static int cifs_setlease(struct file *file, long arg, struct file_lock **lease)
589 /* note that this is called by vfs setlease with the BKL held 589 /* note that this is called by vfs setlease with the BKL held
590 although I doubt that BKL is needed here in cifs */ 590 although I doubt that BKL is needed here in cifs */
591 struct inode *inode = file->f_path.dentry->d_inode; 591 struct inode *inode = file->f_path.dentry->d_inode;
592 struct cifsFileInfo *cfile = file->private_data;
592 593
593 if (!(S_ISREG(inode->i_mode))) 594 if (!(S_ISREG(inode->i_mode)))
594 return -EINVAL; 595 return -EINVAL;
@@ -599,8 +600,7 @@ static int cifs_setlease(struct file *file, long arg, struct file_lock **lease)
599 ((arg == F_WRLCK) && 600 ((arg == F_WRLCK) &&
600 (CIFS_I(inode)->clientCanCacheAll))) 601 (CIFS_I(inode)->clientCanCacheAll)))
601 return generic_setlease(file, arg, lease); 602 return generic_setlease(file, arg, lease);
602 else if (CIFS_SB(inode->i_sb)->tcon->local_lease && 603 else if (cfile->tcon->local_lease && !CIFS_I(inode)->clientCanCacheRead)
603 !CIFS_I(inode)->clientCanCacheRead)
604 /* If the server claims to support oplock on this 604 /* If the server claims to support oplock on this
605 file, then we still need to check oplock even 605 file, then we still need to check oplock even
606 if the local_lease mount option is set, but there 606 if the local_lease mount option is set, but there
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 60061b9c2f67..84979fc77862 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -461,7 +461,7 @@ static int cifs_reopen_file(struct file *file, bool can_flush)
461 } 461 }
462 462
463 cifs_sb = CIFS_SB(inode->i_sb); 463 cifs_sb = CIFS_SB(inode->i_sb);
464 tcon = cifs_sb->tcon; 464 tcon = pCifsFile->tcon;
465 465
466/* can not grab rename sem here because various ops, including 466/* can not grab rename sem here because various ops, including
467 those that already have the rename sem can end up causing writepage 467 those that already have the rename sem can end up causing writepage
@@ -575,7 +575,7 @@ int cifs_close(struct inode *inode, struct file *file)
575 xid = GetXid(); 575 xid = GetXid();
576 576
577 cifs_sb = CIFS_SB(inode->i_sb); 577 cifs_sb = CIFS_SB(inode->i_sb);
578 pTcon = cifs_sb->tcon; 578 pTcon = pSMBFile->tcon;
579 if (pSMBFile) { 579 if (pSMBFile) {
580 struct cifsLockInfo *li, *tmp; 580 struct cifsLockInfo *li, *tmp;
581 write_lock(&GlobalSMBSeslock); 581 write_lock(&GlobalSMBSeslock);
@@ -653,11 +653,7 @@ int cifs_closedir(struct inode *inode, struct file *file)
653 xid = GetXid(); 653 xid = GetXid();
654 654
655 if (pCFileStruct) { 655 if (pCFileStruct) {
656 struct cifsTconInfo *pTcon; 656 struct cifsTconInfo *pTcon = pCFileStruct->tcon;
657 struct cifs_sb_info *cifs_sb =
658 CIFS_SB(file->f_path.dentry->d_sb);
659
660 pTcon = cifs_sb->tcon;
661 657
662 cFYI(1, "Freeing private data in close dir"); 658 cFYI(1, "Freeing private data in close dir");
663 write_lock(&GlobalSMBSeslock); 659 write_lock(&GlobalSMBSeslock);
@@ -767,7 +763,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
767 cFYI(1, "Unknown type of lock"); 763 cFYI(1, "Unknown type of lock");
768 764
769 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 765 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
770 tcon = cifs_sb->tcon; 766 tcon = ((struct cifsFileInfo *)file->private_data)->tcon;
771 767
772 if (file->private_data == NULL) { 768 if (file->private_data == NULL) {
773 rc = -EBADF; 769 rc = -EBADF;
@@ -960,14 +956,14 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
960 956
961 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 957 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
962 958
963 pTcon = cifs_sb->tcon;
964
965 /* cFYI(1, " write %d bytes to offset %lld of %s", write_size, 959 /* cFYI(1, " write %d bytes to offset %lld of %s", write_size,
966 *poffset, file->f_path.dentry->d_name.name); */ 960 *poffset, file->f_path.dentry->d_name.name); */
967 961
968 if (file->private_data == NULL) 962 if (file->private_data == NULL)
969 return -EBADF; 963 return -EBADF;
964
970 open_file = file->private_data; 965 open_file = file->private_data;
966 pTcon = open_file->tcon;
971 967
972 rc = generic_write_checks(file, poffset, &write_size, 0); 968 rc = generic_write_checks(file, poffset, &write_size, 0);
973 if (rc) 969 if (rc)
@@ -1062,14 +1058,13 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
1062 1058
1063 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 1059 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
1064 1060
1065 pTcon = cifs_sb->tcon;
1066
1067 cFYI(1, "write %zd bytes to offset %lld of %s", write_size, 1061 cFYI(1, "write %zd bytes to offset %lld of %s", write_size,
1068 *poffset, file->f_path.dentry->d_name.name); 1062 *poffset, file->f_path.dentry->d_name.name);
1069 1063
1070 if (file->private_data == NULL) 1064 if (file->private_data == NULL)
1071 return -EBADF; 1065 return -EBADF;
1072 open_file = file->private_data; 1066 open_file = file->private_data;
1067 pTcon = open_file->tcon;
1073 1068
1074 xid = GetXid(); 1069 xid = GetXid();
1075 1070
@@ -1284,7 +1279,6 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
1284 int rc = -EFAULT; 1279 int rc = -EFAULT;
1285 int bytes_written = 0; 1280 int bytes_written = 0;
1286 struct cifs_sb_info *cifs_sb; 1281 struct cifs_sb_info *cifs_sb;
1287 struct cifsTconInfo *pTcon;
1288 struct inode *inode; 1282 struct inode *inode;
1289 struct cifsFileInfo *open_file; 1283 struct cifsFileInfo *open_file;
1290 1284
@@ -1293,7 +1287,6 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
1293 1287
1294 inode = page->mapping->host; 1288 inode = page->mapping->host;
1295 cifs_sb = CIFS_SB(inode->i_sb); 1289 cifs_sb = CIFS_SB(inode->i_sb);
1296 pTcon = cifs_sb->tcon;
1297 1290
1298 offset += (loff_t)from; 1291 offset += (loff_t)from;
1299 write_data = kmap(page); 1292 write_data = kmap(page);
@@ -1352,6 +1345,7 @@ static int cifs_writepages(struct address_space *mapping,
1352 int nr_pages; 1345 int nr_pages;
1353 __u64 offset = 0; 1346 __u64 offset = 0;
1354 struct cifsFileInfo *open_file; 1347 struct cifsFileInfo *open_file;
1348 struct cifsTconInfo *tcon;
1355 struct cifsInodeInfo *cifsi = CIFS_I(mapping->host); 1349 struct cifsInodeInfo *cifsi = CIFS_I(mapping->host);
1356 struct page *page; 1350 struct page *page;
1357 struct pagevec pvec; 1351 struct pagevec pvec;
@@ -1501,8 +1495,9 @@ retry:
1501 cERROR(1, "No writable handles for inode"); 1495 cERROR(1, "No writable handles for inode");
1502 rc = -EBADF; 1496 rc = -EBADF;
1503 } else { 1497 } else {
1498 tcon = open_file->tcon;
1504 long_op = cifs_write_timeout(cifsi, offset); 1499 long_op = cifs_write_timeout(cifsi, offset);
1505 rc = CIFSSMBWrite2(xid, cifs_sb->tcon, 1500 rc = CIFSSMBWrite2(xid, tcon,
1506 open_file->netfid, 1501 open_file->netfid,
1507 bytes_to_write, offset, 1502 bytes_to_write, offset,
1508 &bytes_written, iov, n_iov, 1503 &bytes_written, iov, n_iov,
@@ -1520,8 +1515,7 @@ retry:
1520 else 1515 else
1521 set_bit(AS_EIO, &mapping->flags); 1516 set_bit(AS_EIO, &mapping->flags);
1522 } else { 1517 } else {
1523 cifs_stats_bytes_written(cifs_sb->tcon, 1518 cifs_stats_bytes_written(tcon, bytes_written);
1524 bytes_written);
1525 } 1519 }
1526 } 1520 }
1527 for (i = 0; i < n_iov; i++) { 1521 for (i = 0; i < n_iov; i++) {
@@ -1665,7 +1659,7 @@ int cifs_fsync(struct file *file, int datasync)
1665 if (rc == 0) { 1659 if (rc == 0) {
1666 rc = CIFS_I(inode)->write_behind_rc; 1660 rc = CIFS_I(inode)->write_behind_rc;
1667 CIFS_I(inode)->write_behind_rc = 0; 1661 CIFS_I(inode)->write_behind_rc = 0;
1668 tcon = CIFS_SB(inode->i_sb)->tcon; 1662 tcon = smbfile->tcon;
1669 if (!rc && tcon && smbfile && 1663 if (!rc && tcon && smbfile &&
1670 !(CIFS_SB(inode->i_sb)->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) 1664 !(CIFS_SB(inode->i_sb)->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC))
1671 rc = CIFSSMBFlush(xid, tcon, smbfile->netfid); 1665 rc = CIFSSMBFlush(xid, tcon, smbfile->netfid);
@@ -1750,7 +1744,6 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,
1750 1744
1751 xid = GetXid(); 1745 xid = GetXid();
1752 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 1746 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
1753 pTcon = cifs_sb->tcon;
1754 1747
1755 if (file->private_data == NULL) { 1748 if (file->private_data == NULL) {
1756 rc = -EBADF; 1749 rc = -EBADF;
@@ -1758,6 +1751,7 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,
1758 return rc; 1751 return rc;
1759 } 1752 }
1760 open_file = file->private_data; 1753 open_file = file->private_data;
1754 pTcon = open_file->tcon;
1761 1755
1762 if ((file->f_flags & O_ACCMODE) == O_WRONLY) 1756 if ((file->f_flags & O_ACCMODE) == O_WRONLY)
1763 cFYI(1, "attempting read on write only file instance"); 1757 cFYI(1, "attempting read on write only file instance");
@@ -1831,7 +1825,6 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
1831 1825
1832 xid = GetXid(); 1826 xid = GetXid();
1833 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 1827 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
1834 pTcon = cifs_sb->tcon;
1835 1828
1836 if (file->private_data == NULL) { 1829 if (file->private_data == NULL) {
1837 rc = -EBADF; 1830 rc = -EBADF;
@@ -1839,6 +1832,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
1839 return rc; 1832 return rc;
1840 } 1833 }
1841 open_file = file->private_data; 1834 open_file = file->private_data;
1835 pTcon = open_file->tcon;
1842 1836
1843 if ((file->f_flags & O_ACCMODE) == O_WRONLY) 1837 if ((file->f_flags & O_ACCMODE) == O_WRONLY)
1844 cFYI(1, "attempting read on write only file instance"); 1838 cFYI(1, "attempting read on write only file instance");
@@ -1974,7 +1968,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
1974 } 1968 }
1975 open_file = file->private_data; 1969 open_file = file->private_data;
1976 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 1970 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
1977 pTcon = cifs_sb->tcon; 1971 pTcon = open_file->tcon;
1978 1972
1979 /* 1973 /*
1980 * Reads as many pages as possible from fscache. Returns -ENOBUFS 1974 * Reads as many pages as possible from fscache. Returns -ENOBUFS
@@ -2312,7 +2306,6 @@ void cifs_oplock_break(struct work_struct *work)
2312 oplock_break); 2306 oplock_break);
2313 struct inode *inode = cfile->pInode; 2307 struct inode *inode = cfile->pInode;
2314 struct cifsInodeInfo *cinode = CIFS_I(inode); 2308 struct cifsInodeInfo *cinode = CIFS_I(inode);
2315 struct cifs_sb_info *cifs_sb = CIFS_SB(cfile->mnt->mnt_sb);
2316 int rc, waitrc = 0; 2309 int rc, waitrc = 0;
2317 2310
2318 if (inode && S_ISREG(inode->i_mode)) { 2311 if (inode && S_ISREG(inode->i_mode)) {
@@ -2339,7 +2332,7 @@ void cifs_oplock_break(struct work_struct *work)
2339 * disconnected since oplock already released by the server 2332 * disconnected since oplock already released by the server
2340 */ 2333 */
2341 if (!cfile->closePend && !cfile->oplock_break_cancelled) { 2334 if (!cfile->closePend && !cfile->oplock_break_cancelled) {
2342 rc = CIFSSMBLock(0, cifs_sb->tcon, cfile->netfid, 0, 0, 0, 0, 2335 rc = CIFSSMBLock(0, cfile->tcon, cfile->netfid, 0, 0, 0, 0,
2343 LOCKING_ANDX_OPLOCK_RELEASE, false); 2336 LOCKING_ANDX_OPLOCK_RELEASE, false);
2344 cFYI(1, "Oplock release rc = %d", rc); 2337 cFYI(1, "Oplock release rc = %d", rc);
2345 } 2338 }
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 016975b8e6dd..0fa145596fcf 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -288,8 +288,8 @@ int cifs_get_file_info_unix(struct file *filp)
288 struct cifs_fattr fattr; 288 struct cifs_fattr fattr;
289 struct inode *inode = filp->f_path.dentry->d_inode; 289 struct inode *inode = filp->f_path.dentry->d_inode;
290 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 290 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
291 struct cifsTconInfo *tcon = cifs_sb->tcon;
292 struct cifsFileInfo *cfile = filp->private_data; 291 struct cifsFileInfo *cfile = filp->private_data;
292 struct cifsTconInfo *tcon = cfile->tcon;
293 293
294 xid = GetXid(); 294 xid = GetXid();
295 rc = CIFSSMBUnixQFileInfo(xid, tcon, cfile->netfid, &find_data); 295 rc = CIFSSMBUnixQFileInfo(xid, tcon, cfile->netfid, &find_data);
@@ -522,8 +522,8 @@ int cifs_get_file_info(struct file *filp)
522 struct cifs_fattr fattr; 522 struct cifs_fattr fattr;
523 struct inode *inode = filp->f_path.dentry->d_inode; 523 struct inode *inode = filp->f_path.dentry->d_inode;
524 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 524 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
525 struct cifsTconInfo *tcon = cifs_sb->tcon;
526 struct cifsFileInfo *cfile = filp->private_data; 525 struct cifsFileInfo *cfile = filp->private_data;
526 struct cifsTconInfo *tcon = cfile->tcon;
527 527
528 xid = GetXid(); 528 xid = GetXid();
529 rc = CIFSSMBQFileInfo(xid, tcon, cfile->netfid, &find_data); 529 rc = CIFSSMBQFileInfo(xid, tcon, cfile->netfid, &find_data);
@@ -891,7 +891,7 @@ cifs_set_file_info(struct inode *inode, struct iattr *attrs, int xid,
891 struct cifsFileInfo *open_file; 891 struct cifsFileInfo *open_file;
892 struct cifsInodeInfo *cifsInode = CIFS_I(inode); 892 struct cifsInodeInfo *cifsInode = CIFS_I(inode);
893 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 893 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
894 struct cifsTconInfo *pTcon = cifs_sb->tcon; 894 struct cifsTconInfo *pTcon;
895 FILE_BASIC_INFO info_buf; 895 FILE_BASIC_INFO info_buf;
896 896
897 if (attrs == NULL) 897 if (attrs == NULL)
@@ -934,9 +934,12 @@ cifs_set_file_info(struct inode *inode, struct iattr *attrs, int xid,
934 if (open_file) { 934 if (open_file) {
935 netfid = open_file->netfid; 935 netfid = open_file->netfid;
936 netpid = open_file->pid; 936 netpid = open_file->pid;
937 pTcon = open_file->tcon;
937 goto set_via_filehandle; 938 goto set_via_filehandle;
938 } 939 }
939 940
941 pTcon = cifs_sb->tcon;
942
940 /* 943 /*
941 * NT4 apparently returns success on this call, but it doesn't 944 * NT4 apparently returns success on this call, but it doesn't
942 * really work. 945 * really work.
@@ -1611,11 +1614,12 @@ int cifs_revalidate_file(struct file *filp)
1611{ 1614{
1612 int rc = 0; 1615 int rc = 0;
1613 struct inode *inode = filp->f_path.dentry->d_inode; 1616 struct inode *inode = filp->f_path.dentry->d_inode;
1617 struct cifsFileInfo *cfile = (struct cifsFileInfo *) filp->private_data;
1614 1618
1615 if (!cifs_inode_needs_reval(inode)) 1619 if (!cifs_inode_needs_reval(inode))
1616 goto check_inval; 1620 goto check_inval;
1617 1621
1618 if (CIFS_SB(inode->i_sb)->tcon->unix_ext) 1622 if (cfile->tcon->unix_ext)
1619 rc = cifs_get_file_info_unix(filp); 1623 rc = cifs_get_file_info_unix(filp);
1620 else 1624 else
1621 rc = cifs_get_file_info(filp); 1625 rc = cifs_get_file_info(filp);
@@ -1720,7 +1724,7 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs,
1720 struct cifsFileInfo *open_file; 1724 struct cifsFileInfo *open_file;
1721 struct cifsInodeInfo *cifsInode = CIFS_I(inode); 1725 struct cifsInodeInfo *cifsInode = CIFS_I(inode);
1722 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 1726 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
1723 struct cifsTconInfo *pTcon = cifs_sb->tcon; 1727 struct cifsTconInfo *pTcon = NULL;
1724 1728
1725 /* 1729 /*
1726 * To avoid spurious oplock breaks from server, in the case of 1730 * To avoid spurious oplock breaks from server, in the case of
@@ -1735,6 +1739,7 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs,
1735 if (open_file) { 1739 if (open_file) {
1736 __u16 nfid = open_file->netfid; 1740 __u16 nfid = open_file->netfid;
1737 __u32 npid = open_file->pid; 1741 __u32 npid = open_file->pid;
1742 pTcon = open_file->tcon;
1738 rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size, nfid, 1743 rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size, nfid,
1739 npid, false); 1744 npid, false);
1740 cifsFileInfo_put(open_file); 1745 cifsFileInfo_put(open_file);
@@ -1749,6 +1754,9 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs,
1749 rc = -EINVAL; 1754 rc = -EINVAL;
1750 1755
1751 if (rc != 0) { 1756 if (rc != 0) {
1757 if (pTcon == NULL)
1758 pTcon = cifs_sb->tcon;
1759
1752 /* Set file size by pathname rather than by handle 1760 /* Set file size by pathname rather than by handle
1753 either because no valid, writeable file handle for 1761 either because no valid, writeable file handle for
1754 it was found or because there was an error setting 1762 it was found or because there was an error setting
@@ -1798,7 +1806,7 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)
1798 struct inode *inode = direntry->d_inode; 1806 struct inode *inode = direntry->d_inode;
1799 struct cifsInodeInfo *cifsInode = CIFS_I(inode); 1807 struct cifsInodeInfo *cifsInode = CIFS_I(inode);
1800 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 1808 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
1801 struct cifsTconInfo *pTcon = cifs_sb->tcon; 1809 struct cifsTconInfo *pTcon;
1802 struct cifs_unix_set_info_args *args = NULL; 1810 struct cifs_unix_set_info_args *args = NULL;
1803 struct cifsFileInfo *open_file; 1811 struct cifsFileInfo *open_file;
1804 1812
@@ -1889,9 +1897,11 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)
1889 if (open_file) { 1897 if (open_file) {
1890 u16 nfid = open_file->netfid; 1898 u16 nfid = open_file->netfid;
1891 u32 npid = open_file->pid; 1899 u32 npid = open_file->pid;
1900 pTcon = open_file->tcon;
1892 rc = CIFSSMBUnixSetFileInfo(xid, pTcon, args, nfid, npid); 1901 rc = CIFSSMBUnixSetFileInfo(xid, pTcon, args, nfid, npid);
1893 cifsFileInfo_put(open_file); 1902 cifsFileInfo_put(open_file);
1894 } else { 1903 } else {
1904 pTcon = cifs_sb->tcon;
1895 rc = CIFSSMBUnixSetPathInfo(xid, pTcon, full_path, args, 1905 rc = CIFSSMBUnixSetPathInfo(xid, pTcon, full_path, args,
1896 cifs_sb->local_nls, 1906 cifs_sb->local_nls,
1897 cifs_sb->mnt_cifs_flags & 1907 cifs_sb->mnt_cifs_flags &
diff --git a/fs/cifs/ioctl.c b/fs/cifs/ioctl.c
index 9d38a71c8e14..cc70a61a47d2 100644
--- a/fs/cifs/ioctl.c
+++ b/fs/cifs/ioctl.c
@@ -37,11 +37,11 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
37 int xid; 37 int xid;
38 struct cifs_sb_info *cifs_sb; 38 struct cifs_sb_info *cifs_sb;
39#ifdef CONFIG_CIFS_POSIX 39#ifdef CONFIG_CIFS_POSIX
40 struct cifsFileInfo *pSMBFile = filep->private_data;
41 struct cifsTconInfo *tcon = pSMBFile->tcon;
40 __u64 ExtAttrBits = 0; 42 __u64 ExtAttrBits = 0;
41 __u64 ExtAttrMask = 0; 43 __u64 ExtAttrMask = 0;
42 __u64 caps; 44 __u64 caps = le64_to_cpu(tcon->fsUnixInfo.Capability);
43 struct cifsTconInfo *tcon;
44 struct cifsFileInfo *pSMBFile = filep->private_data;
45#endif /* CONFIG_CIFS_POSIX */ 45#endif /* CONFIG_CIFS_POSIX */
46 46
47 xid = GetXid(); 47 xid = GetXid();
@@ -50,17 +50,6 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
50 50
51 cifs_sb = CIFS_SB(inode->i_sb); 51 cifs_sb = CIFS_SB(inode->i_sb);
52 52
53#ifdef CONFIG_CIFS_POSIX
54 tcon = cifs_sb->tcon;
55 if (tcon)
56 caps = le64_to_cpu(tcon->fsUnixInfo.Capability);
57 else {
58 rc = -EIO;
59 FreeXid(xid);
60 return -EIO;
61 }
62#endif /* CONFIG_CIFS_POSIX */
63
64 switch (command) { 53 switch (command) {
65 case CIFS_IOC_CHECKUMOUNT: 54 case CIFS_IOC_CHECKUMOUNT:
66 cFYI(1, "User unmount attempted"); 55 cFYI(1, "User unmount attempted");
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 6a8b417babab..d7784a95134f 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -228,22 +228,21 @@ static int initiate_cifs_search(const int xid, struct file *file)
228 struct cifs_sb_info *cifs_sb; 228 struct cifs_sb_info *cifs_sb;
229 struct cifsTconInfo *pTcon; 229 struct cifsTconInfo *pTcon;
230 230
231 if (file->private_data == NULL) { 231 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
232 if (cifs_sb == NULL)
233 return -EINVAL;
234
235 if (file->private_data == NULL)
232 file->private_data = 236 file->private_data =
233 kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL); 237 kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL);
234 }
235 238
236 if (file->private_data == NULL) 239 if (file->private_data == NULL)
237 return -ENOMEM; 240 return -ENOMEM;
238 cifsFile = file->private_data; 241 cifsFile = file->private_data;
239 cifsFile->invalidHandle = true; 242 cifsFile->invalidHandle = true;
240 cifsFile->srch_inf.endOfSearch = false; 243 cifsFile->srch_inf.endOfSearch = false;
241 244 cifsFile->tcon = cifs_sb->tcon;
242 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 245 pTcon = cifsFile->tcon;
243 if (cifs_sb == NULL)
244 return -EINVAL;
245
246 pTcon = cifs_sb->tcon;
247 if (pTcon == NULL) 246 if (pTcon == NULL)
248 return -EINVAL; 247 return -EINVAL;
249 248
@@ -786,9 +785,6 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
786 xid = GetXid(); 785 xid = GetXid();
787 786
788 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 787 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
789 pTcon = cifs_sb->tcon;
790 if (pTcon == NULL)
791 return -EINVAL;
792 788
793 switch ((int) file->f_pos) { 789 switch ((int) file->f_pos) {
794 case 0: 790 case 0:
@@ -838,6 +834,7 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
838 CIFSFindClose(xid, pTcon, cifsFile->netfid); 834 CIFSFindClose(xid, pTcon, cifsFile->netfid);
839 } */ 835 } */
840 836
837 pTcon = cifsFile->tcon;
841 rc = find_cifs_entry(xid, pTcon, file, 838 rc = find_cifs_entry(xid, pTcon, file,
842 &current_entry, &num_to_fill); 839 &current_entry, &num_to_fill);
843 if (rc) { 840 if (rc) {