aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2010-09-29 19:51:11 -0400
committerSteve French <sfrench@us.ibm.com>2010-10-06 12:12:49 -0400
commit13cfb7334eb6fd0fc06da5589aea1e947791f1d6 (patch)
tree56d884f6a5dbcf8b259247fdad55c9158bd4d865 /fs/cifs
parent7ffec372458d163492e56e663a1b3a2d7be0a0a2 (diff)
cifs: have cifsFileInfo hold a reference to a tlink rather than tcon pointer
cifsFileInfo needs a pointer to a tcon, but it doesn't currently hold a reference to it. Change it to keep a pointer to a tcon_link instead and hold a reference to it. That will keep the tcon from being freed until the file is closed. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r--fs/cifs/cifsfs.c3
-rw-r--r--fs/cifs/cifsglob.h9
-rw-r--r--fs/cifs/cifsproto.h2
-rw-r--r--fs/cifs/dir.c10
-rw-r--r--fs/cifs/file.c31
-rw-r--r--fs/cifs/inode.c12
-rw-r--r--fs/cifs/ioctl.c2
-rw-r--r--fs/cifs/link.c1
-rw-r--r--fs/cifs/readdir.c4
9 files changed, 41 insertions, 33 deletions
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 898d2a5cfad2..b2fd075dc2e6 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -595,7 +595,8 @@ static int cifs_setlease(struct file *file, long arg, struct file_lock **lease)
595 ((arg == F_WRLCK) && 595 ((arg == F_WRLCK) &&
596 (CIFS_I(inode)->clientCanCacheAll))) 596 (CIFS_I(inode)->clientCanCacheAll)))
597 return generic_setlease(file, arg, lease); 597 return generic_setlease(file, arg, lease);
598 else if (cfile->tcon->local_lease && !CIFS_I(inode)->clientCanCacheRead) 598 else if (tlink_tcon(cfile->tlink)->local_lease &&
599 !CIFS_I(inode)->clientCanCacheRead)
599 /* If the server claims to support oplock on this 600 /* If the server claims to support oplock on this
600 file, then we still need to check oplock even 601 file, then we still need to check oplock even
601 if the local_lease mount option is set, but there 602 if the local_lease mount option is set, but there
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index cdfd2db4e70d..d5324853203b 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -341,6 +341,12 @@ cifs_put_tlink(struct tcon_link *tlink)
341 return; 341 return;
342} 342}
343 343
344static inline struct tcon_link *
345cifs_get_tlink(struct tcon_link *tlink)
346{
347 return tlink;
348}
349
344/* This function is always expected to succeed */ 350/* This function is always expected to succeed */
345static inline struct cifsTconInfo * 351static inline struct cifsTconInfo *
346cifs_sb_master_tcon(struct cifs_sb_info *cifs_sb) 352cifs_sb_master_tcon(struct cifs_sb_info *cifs_sb)
@@ -389,7 +395,7 @@ struct cifsFileInfo {
389 struct file *pfile; /* needed for writepage */ 395 struct file *pfile; /* needed for writepage */
390 struct inode *pInode; /* needed for oplock break */ 396 struct inode *pInode; /* needed for oplock break */
391 struct vfsmount *mnt; 397 struct vfsmount *mnt;
392 struct cifsTconInfo *tcon; 398 struct tcon_link *tlink;
393 struct mutex lock_mutex; 399 struct mutex lock_mutex;
394 struct list_head llist; /* list of byte range locks we have. */ 400 struct list_head llist; /* list of byte range locks we have. */
395 bool closePend:1; /* file is marked to close */ 401 bool closePend:1; /* file is marked to close */
@@ -411,6 +417,7 @@ static inline void cifsFileInfo_get(struct cifsFileInfo *cifs_file)
411static inline void cifsFileInfo_put(struct cifsFileInfo *cifs_file) 417static inline void cifsFileInfo_put(struct cifsFileInfo *cifs_file)
412{ 418{
413 if (atomic_dec_and_test(&cifs_file->count)) { 419 if (atomic_dec_and_test(&cifs_file->count)) {
420 cifs_put_tlink(cifs_file->tlink);
414 iput(cifs_file->pInode); 421 iput(cifs_file->pInode);
415 kfree(cifs_file); 422 kfree(cifs_file);
416 } 423 }
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 610b2263c9f3..7294723d0625 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -107,7 +107,7 @@ extern struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time,
107 107
108extern struct cifsFileInfo *cifs_new_fileinfo(struct inode *newinode, 108extern struct cifsFileInfo *cifs_new_fileinfo(struct inode *newinode,
109 __u16 fileHandle, struct file *file, 109 __u16 fileHandle, struct file *file,
110 struct vfsmount *mnt, struct cifsTconInfo *tcon, 110 struct vfsmount *mnt, struct tcon_link *tlink,
111 unsigned int oflags, __u32 oplock); 111 unsigned int oflags, __u32 oplock);
112extern int cifs_posix_open(char *full_path, struct inode **pinode, 112extern int cifs_posix_open(char *full_path, struct inode **pinode,
113 struct super_block *sb, 113 struct super_block *sb,
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index bb3ea06ca6f4..5adf47f28fed 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -132,7 +132,7 @@ cifs_bp_rename_retry:
132 132
133struct cifsFileInfo * 133struct cifsFileInfo *
134cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle, struct file *file, 134cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle, struct file *file,
135 struct vfsmount *mnt, struct cifsTconInfo *tcon, 135 struct vfsmount *mnt, struct tcon_link *tlink,
136 unsigned int oflags, __u32 oplock) 136 unsigned int oflags, __u32 oplock)
137{ 137{
138 struct cifsFileInfo *pCifsFile; 138 struct cifsFileInfo *pCifsFile;
@@ -149,7 +149,7 @@ cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle, struct file *file,
149 pCifsFile->pfile = file; 149 pCifsFile->pfile = file;
150 pCifsFile->invalidHandle = false; 150 pCifsFile->invalidHandle = false;
151 pCifsFile->closePend = false; 151 pCifsFile->closePend = false;
152 pCifsFile->tcon = tcon; 152 pCifsFile->tlink = cifs_get_tlink(tlink);
153 mutex_init(&pCifsFile->fh_mutex); 153 mutex_init(&pCifsFile->fh_mutex);
154 mutex_init(&pCifsFile->lock_mutex); 154 mutex_init(&pCifsFile->lock_mutex);
155 INIT_LIST_HEAD(&pCifsFile->llist); 155 INIT_LIST_HEAD(&pCifsFile->llist);
@@ -157,7 +157,7 @@ cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle, struct file *file,
157 INIT_WORK(&pCifsFile->oplock_break, cifs_oplock_break); 157 INIT_WORK(&pCifsFile->oplock_break, cifs_oplock_break);
158 158
159 write_lock(&GlobalSMBSeslock); 159 write_lock(&GlobalSMBSeslock);
160 list_add(&pCifsFile->tlist, &tcon->openFileList); 160 list_add(&pCifsFile->tlist, &(tlink_tcon(tlink)->openFileList));
161 pCifsInode = CIFS_I(newinode); 161 pCifsInode = CIFS_I(newinode);
162 if (pCifsInode) { 162 if (pCifsInode) {
163 /* if readable file instance put first in list*/ 163 /* if readable file instance put first in list*/
@@ -483,7 +483,7 @@ cifs_create_set_dentry:
483 } 483 }
484 484
485 pfile_info = cifs_new_fileinfo(newinode, fileHandle, filp, 485 pfile_info = cifs_new_fileinfo(newinode, fileHandle, filp,
486 nd->path.mnt, tcon, oflags, 486 nd->path.mnt, tlink, oflags,
487 oplock); 487 oplock);
488 if (pfile_info == NULL) { 488 if (pfile_info == NULL) {
489 fput(filp); 489 fput(filp);
@@ -758,7 +758,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
758 } 758 }
759 759
760 cfile = cifs_new_fileinfo(newInode, fileHandle, filp, 760 cfile = cifs_new_fileinfo(newInode, fileHandle, filp,
761 nd->path.mnt, pTcon, 761 nd->path.mnt, tlink,
762 nd->intent.open.flags, 762 nd->intent.open.flags,
763 oplock); 763 oplock);
764 if (cfile == NULL) { 764 if (cfile == NULL) {
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 1e375abc5eb3..24332d437150 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -283,7 +283,7 @@ int cifs_open(struct inode *inode, struct file *file)
283 283
284 pCifsFile = cifs_new_fileinfo(inode, netfid, file, 284 pCifsFile = cifs_new_fileinfo(inode, netfid, file,
285 file->f_path.mnt, 285 file->f_path.mnt,
286 tcon, oflags, oplock); 286 tlink, oflags, oplock);
287 if (pCifsFile == NULL) { 287 if (pCifsFile == NULL) {
288 CIFSSMBClose(xid, tcon, netfid); 288 CIFSSMBClose(xid, tcon, netfid);
289 rc = -ENOMEM; 289 rc = -ENOMEM;
@@ -376,7 +376,7 @@ int cifs_open(struct inode *inode, struct file *file)
376 goto out; 376 goto out;
377 377
378 pCifsFile = cifs_new_fileinfo(inode, netfid, file, file->f_path.mnt, 378 pCifsFile = cifs_new_fileinfo(inode, netfid, file, file->f_path.mnt,
379 tcon, file->f_flags, oplock); 379 tlink, file->f_flags, oplock);
380 if (pCifsFile == NULL) { 380 if (pCifsFile == NULL) {
381 rc = -ENOMEM; 381 rc = -ENOMEM;
382 goto out; 382 goto out;
@@ -468,7 +468,7 @@ static int cifs_reopen_file(struct file *file, bool can_flush)
468 } 468 }
469 469
470 cifs_sb = CIFS_SB(inode->i_sb); 470 cifs_sb = CIFS_SB(inode->i_sb);
471 tcon = pCifsFile->tcon; 471 tcon = tlink_tcon(pCifsFile->tlink);
472 472
473/* can not grab rename sem here because various ops, including 473/* can not grab rename sem here because various ops, including
474 those that already have the rename sem can end up causing writepage 474 those that already have the rename sem can end up causing writepage
@@ -582,7 +582,7 @@ int cifs_close(struct inode *inode, struct file *file)
582 xid = GetXid(); 582 xid = GetXid();
583 583
584 cifs_sb = CIFS_SB(inode->i_sb); 584 cifs_sb = CIFS_SB(inode->i_sb);
585 pTcon = pSMBFile->tcon; 585 pTcon = tlink_tcon(pSMBFile->tlink);
586 if (pSMBFile) { 586 if (pSMBFile) {
587 struct cifsLockInfo *li, *tmp; 587 struct cifsLockInfo *li, *tmp;
588 write_lock(&GlobalSMBSeslock); 588 write_lock(&GlobalSMBSeslock);
@@ -660,7 +660,7 @@ int cifs_closedir(struct inode *inode, struct file *file)
660 xid = GetXid(); 660 xid = GetXid();
661 661
662 if (pCFileStruct) { 662 if (pCFileStruct) {
663 struct cifsTconInfo *pTcon = pCFileStruct->tcon; 663 struct cifsTconInfo *pTcon = tlink_tcon(pCFileStruct->tlink);
664 664
665 cFYI(1, "Freeing private data in close dir"); 665 cFYI(1, "Freeing private data in close dir");
666 write_lock(&GlobalSMBSeslock); 666 write_lock(&GlobalSMBSeslock);
@@ -684,6 +684,7 @@ int cifs_closedir(struct inode *inode, struct file *file)
684 else 684 else
685 cifs_buf_release(ptmp); 685 cifs_buf_release(ptmp);
686 } 686 }
687 cifs_put_tlink(pCFileStruct->tlink);
687 kfree(file->private_data); 688 kfree(file->private_data);
688 file->private_data = NULL; 689 file->private_data = NULL;
689 } 690 }
@@ -770,7 +771,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
770 cFYI(1, "Unknown type of lock"); 771 cFYI(1, "Unknown type of lock");
771 772
772 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 773 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
773 tcon = ((struct cifsFileInfo *)file->private_data)->tcon; 774 tcon = tlink_tcon(((struct cifsFileInfo *)file->private_data)->tlink);
774 775
775 if (file->private_data == NULL) { 776 if (file->private_data == NULL) {
776 rc = -EBADF; 777 rc = -EBADF;
@@ -970,7 +971,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
970 return -EBADF; 971 return -EBADF;
971 972
972 open_file = file->private_data; 973 open_file = file->private_data;
973 pTcon = open_file->tcon; 974 pTcon = tlink_tcon(open_file->tlink);
974 975
975 rc = generic_write_checks(file, poffset, &write_size, 0); 976 rc = generic_write_checks(file, poffset, &write_size, 0);
976 if (rc) 977 if (rc)
@@ -1071,7 +1072,7 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
1071 if (file->private_data == NULL) 1072 if (file->private_data == NULL)
1072 return -EBADF; 1073 return -EBADF;
1073 open_file = file->private_data; 1074 open_file = file->private_data;
1074 pTcon = open_file->tcon; 1075 pTcon = tlink_tcon(open_file->tlink);
1075 1076
1076 xid = GetXid(); 1077 xid = GetXid();
1077 1078
@@ -1393,7 +1394,7 @@ static int cifs_writepages(struct address_space *mapping,
1393 return generic_writepages(mapping, wbc); 1394 return generic_writepages(mapping, wbc);
1394 } 1395 }
1395 1396
1396 tcon = open_file->tcon; 1397 tcon = tlink_tcon(open_file->tlink);
1397 if (!experimEnabled && tcon->ses->server->secMode & 1398 if (!experimEnabled && tcon->ses->server->secMode &
1398 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) { 1399 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) {
1399 cifsFileInfo_put(open_file); 1400 cifsFileInfo_put(open_file);
@@ -1672,7 +1673,7 @@ int cifs_fsync(struct file *file, int datasync)
1672 if (rc == 0) { 1673 if (rc == 0) {
1673 rc = CIFS_I(inode)->write_behind_rc; 1674 rc = CIFS_I(inode)->write_behind_rc;
1674 CIFS_I(inode)->write_behind_rc = 0; 1675 CIFS_I(inode)->write_behind_rc = 0;
1675 tcon = smbfile->tcon; 1676 tcon = tlink_tcon(smbfile->tlink);
1676 if (!rc && tcon && smbfile && 1677 if (!rc && tcon && smbfile &&
1677 !(CIFS_SB(inode->i_sb)->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) 1678 !(CIFS_SB(inode->i_sb)->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC))
1678 rc = CIFSSMBFlush(xid, tcon, smbfile->netfid); 1679 rc = CIFSSMBFlush(xid, tcon, smbfile->netfid);
@@ -1764,7 +1765,7 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,
1764 return rc; 1765 return rc;
1765 } 1766 }
1766 open_file = file->private_data; 1767 open_file = file->private_data;
1767 pTcon = open_file->tcon; 1768 pTcon = tlink_tcon(open_file->tlink);
1768 1769
1769 if ((file->f_flags & O_ACCMODE) == O_WRONLY) 1770 if ((file->f_flags & O_ACCMODE) == O_WRONLY)
1770 cFYI(1, "attempting read on write only file instance"); 1771 cFYI(1, "attempting read on write only file instance");
@@ -1845,7 +1846,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
1845 return rc; 1846 return rc;
1846 } 1847 }
1847 open_file = file->private_data; 1848 open_file = file->private_data;
1848 pTcon = open_file->tcon; 1849 pTcon = tlink_tcon(open_file->tlink);
1849 1850
1850 if ((file->f_flags & O_ACCMODE) == O_WRONLY) 1851 if ((file->f_flags & O_ACCMODE) == O_WRONLY)
1851 cFYI(1, "attempting read on write only file instance"); 1852 cFYI(1, "attempting read on write only file instance");
@@ -1981,7 +1982,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
1981 } 1982 }
1982 open_file = file->private_data; 1983 open_file = file->private_data;
1983 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 1984 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
1984 pTcon = open_file->tcon; 1985 pTcon = tlink_tcon(open_file->tlink);
1985 1986
1986 /* 1987 /*
1987 * Reads as many pages as possible from fscache. Returns -ENOBUFS 1988 * Reads as many pages as possible from fscache. Returns -ENOBUFS
@@ -2345,8 +2346,8 @@ void cifs_oplock_break(struct work_struct *work)
2345 * disconnected since oplock already released by the server 2346 * disconnected since oplock already released by the server
2346 */ 2347 */
2347 if (!cfile->closePend && !cfile->oplock_break_cancelled) { 2348 if (!cfile->closePend && !cfile->oplock_break_cancelled) {
2348 rc = CIFSSMBLock(0, cfile->tcon, cfile->netfid, 0, 0, 0, 0, 2349 rc = CIFSSMBLock(0, tlink_tcon(cfile->tlink), cfile->netfid, 0,
2349 LOCKING_ANDX_OPLOCK_RELEASE, false); 2350 0, 0, 0, LOCKING_ANDX_OPLOCK_RELEASE, false);
2350 cFYI(1, "Oplock release rc = %d", rc); 2351 cFYI(1, "Oplock release rc = %d", rc);
2351 } 2352 }
2352 2353
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index aa229692aef1..a39a1c451733 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -289,7 +289,7 @@ int cifs_get_file_info_unix(struct file *filp)
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 cifsFileInfo *cfile = filp->private_data; 291 struct cifsFileInfo *cfile = filp->private_data;
292 struct cifsTconInfo *tcon = cfile->tcon; 292 struct cifsTconInfo *tcon = tlink_tcon(cfile->tlink);
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);
@@ -546,7 +546,7 @@ int cifs_get_file_info(struct file *filp)
546 struct inode *inode = filp->f_path.dentry->d_inode; 546 struct inode *inode = filp->f_path.dentry->d_inode;
547 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 547 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
548 struct cifsFileInfo *cfile = filp->private_data; 548 struct cifsFileInfo *cfile = filp->private_data;
549 struct cifsTconInfo *tcon = cfile->tcon; 549 struct cifsTconInfo *tcon = tlink_tcon(cfile->tlink);
550 550
551 xid = GetXid(); 551 xid = GetXid();
552 rc = CIFSSMBQFileInfo(xid, tcon, cfile->netfid, &find_data); 552 rc = CIFSSMBQFileInfo(xid, tcon, cfile->netfid, &find_data);
@@ -967,7 +967,7 @@ cifs_set_file_info(struct inode *inode, struct iattr *attrs, int xid,
967 if (open_file) { 967 if (open_file) {
968 netfid = open_file->netfid; 968 netfid = open_file->netfid;
969 netpid = open_file->pid; 969 netpid = open_file->pid;
970 pTcon = open_file->tcon; 970 pTcon = tlink_tcon(open_file->tlink);
971 goto set_via_filehandle; 971 goto set_via_filehandle;
972 } 972 }
973 973
@@ -1696,7 +1696,7 @@ int cifs_revalidate_file(struct file *filp)
1696 if (!cifs_inode_needs_reval(inode)) 1696 if (!cifs_inode_needs_reval(inode))
1697 goto check_inval; 1697 goto check_inval;
1698 1698
1699 if (cfile->tcon->unix_ext) 1699 if (tlink_tcon(cfile->tlink)->unix_ext)
1700 rc = cifs_get_file_info_unix(filp); 1700 rc = cifs_get_file_info_unix(filp);
1701 else 1701 else
1702 rc = cifs_get_file_info(filp); 1702 rc = cifs_get_file_info(filp);
@@ -1817,7 +1817,7 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs,
1817 if (open_file) { 1817 if (open_file) {
1818 __u16 nfid = open_file->netfid; 1818 __u16 nfid = open_file->netfid;
1819 __u32 npid = open_file->pid; 1819 __u32 npid = open_file->pid;
1820 pTcon = open_file->tcon; 1820 pTcon = tlink_tcon(open_file->tlink);
1821 rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size, nfid, 1821 rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size, nfid,
1822 npid, false); 1822 npid, false);
1823 cifsFileInfo_put(open_file); 1823 cifsFileInfo_put(open_file);
@@ -1982,7 +1982,7 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)
1982 if (open_file) { 1982 if (open_file) {
1983 u16 nfid = open_file->netfid; 1983 u16 nfid = open_file->netfid;
1984 u32 npid = open_file->pid; 1984 u32 npid = open_file->pid;
1985 pTcon = open_file->tcon; 1985 pTcon = tlink_tcon(open_file->tlink);
1986 rc = CIFSSMBUnixSetFileInfo(xid, pTcon, args, nfid, npid); 1986 rc = CIFSSMBUnixSetFileInfo(xid, pTcon, args, nfid, npid);
1987 cifsFileInfo_put(open_file); 1987 cifsFileInfo_put(open_file);
1988 } else { 1988 } else {
diff --git a/fs/cifs/ioctl.c b/fs/cifs/ioctl.c
index cc70a61a47d2..077bf756f342 100644
--- a/fs/cifs/ioctl.c
+++ b/fs/cifs/ioctl.c
@@ -38,7 +38,7 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
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; 40 struct cifsFileInfo *pSMBFile = filep->private_data;
41 struct cifsTconInfo *tcon = pSMBFile->tcon; 41 struct cifsTconInfo *tcon = tlink_tcon(pSMBFile->tlink);
42 __u64 ExtAttrBits = 0; 42 __u64 ExtAttrBits = 0;
43 __u64 ExtAttrMask = 0; 43 __u64 ExtAttrMask = 0;
44 __u64 caps = le64_to_cpu(tcon->fsUnixInfo.Capability); 44 __u64 caps = le64_to_cpu(tcon->fsUnixInfo.Capability);
diff --git a/fs/cifs/link.c b/fs/cifs/link.c
index b38fe6704ad2..85cdbf831e7b 100644
--- a/fs/cifs/link.c
+++ b/fs/cifs/link.c
@@ -346,7 +346,6 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode,
346 goto cifs_hl_exit; 346 goto cifs_hl_exit;
347 } 347 }
348 348
349/* if (cifs_sb_target->tcon->ses->capabilities & CAP_UNIX)*/
350 if (pTcon->unix_ext) 349 if (pTcon->unix_ext)
351 rc = CIFSUnixCreateHardLink(xid, pTcon, fromName, toName, 350 rc = CIFSUnixCreateHardLink(xid, pTcon, fromName, toName,
352 cifs_sb->local_nls, 351 cifs_sb->local_nls,
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 170047cf4522..1f0bd0f972d4 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -245,7 +245,7 @@ static int initiate_cifs_search(const int xid, struct file *file)
245 cifsFile = file->private_data; 245 cifsFile = file->private_data;
246 cifsFile->invalidHandle = true; 246 cifsFile->invalidHandle = true;
247 cifsFile->srch_inf.endOfSearch = false; 247 cifsFile->srch_inf.endOfSearch = false;
248 cifsFile->tcon = pTcon; 248 cifsFile->tlink = cifs_get_tlink(tlink);
249 249
250 full_path = build_path_from_dentry(file->f_path.dentry); 250 full_path = build_path_from_dentry(file->f_path.dentry);
251 if (full_path == NULL) { 251 if (full_path == NULL) {
@@ -838,7 +838,7 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
838 CIFSFindClose(xid, pTcon, cifsFile->netfid); 838 CIFSFindClose(xid, pTcon, cifsFile->netfid);
839 } */ 839 } */
840 840
841 pTcon = cifsFile->tcon; 841 pTcon = tlink_tcon(cifsFile->tlink);
842 rc = find_cifs_entry(xid, pTcon, file, 842 rc = find_cifs_entry(xid, pTcon, file,
843 &current_entry, &num_to_fill); 843 &current_entry, &num_to_fill);
844 if (rc) { 844 if (rc) {