aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/file.c
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 /fs/cifs/file.c
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>
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r--fs/cifs/file.c39
1 files changed, 16 insertions, 23 deletions
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 }