aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r--fs/cifs/file.c79
1 files changed, 48 insertions, 31 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 14a1c72ced92..77c990f0cb98 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -127,8 +127,7 @@ static inline int cifs_open_inode_helper(struct inode *inode, struct file *file,
127 if (file->f_dentry->d_inode->i_mapping) { 127 if (file->f_dentry->d_inode->i_mapping) {
128 /* BB no need to lock inode until after invalidate 128 /* BB no need to lock inode until after invalidate
129 since namei code should already have it locked? */ 129 since namei code should already have it locked? */
130 filemap_fdatawrite(file->f_dentry->d_inode->i_mapping); 130 filemap_write_and_wait(file->f_dentry->d_inode->i_mapping);
131 filemap_fdatawait(file->f_dentry->d_inode->i_mapping);
132 } 131 }
133 cFYI(1, ("invalidating remote inode since open detected it " 132 cFYI(1, ("invalidating remote inode since open detected it "
134 "changed")); 133 "changed"));
@@ -419,8 +418,7 @@ static int cifs_reopen_file(struct inode *inode, struct file *file,
419 pCifsInode = CIFS_I(inode); 418 pCifsInode = CIFS_I(inode);
420 if (pCifsInode) { 419 if (pCifsInode) {
421 if (can_flush) { 420 if (can_flush) {
422 filemap_fdatawrite(inode->i_mapping); 421 filemap_write_and_wait(inode->i_mapping);
423 filemap_fdatawait(inode->i_mapping);
424 /* temporarily disable caching while we 422 /* temporarily disable caching while we
425 go to server to get inode info */ 423 go to server to get inode info */
426 pCifsInode->clientCanCacheAll = FALSE; 424 pCifsInode->clientCanCacheAll = FALSE;
@@ -555,13 +553,13 @@ int cifs_closedir(struct inode *inode, struct file *file)
555 } 553 }
556 ptmp = pCFileStruct->srch_inf.ntwrk_buf_start; 554 ptmp = pCFileStruct->srch_inf.ntwrk_buf_start;
557 if (ptmp) { 555 if (ptmp) {
558 /* BB removeme BB */ cFYI(1, ("freeing smb buf in srch struct in closedir")); 556 cFYI(1, ("closedir free smb buf in srch struct"));
559 pCFileStruct->srch_inf.ntwrk_buf_start = NULL; 557 pCFileStruct->srch_inf.ntwrk_buf_start = NULL;
560 cifs_buf_release(ptmp); 558 cifs_buf_release(ptmp);
561 } 559 }
562 ptmp = pCFileStruct->search_resume_name; 560 ptmp = pCFileStruct->search_resume_name;
563 if (ptmp) { 561 if (ptmp) {
564 /* BB removeme BB */ cFYI(1, ("freeing resume name in closedir")); 562 cFYI(1, ("closedir free resume name"));
565 pCFileStruct->search_resume_name = NULL; 563 pCFileStruct->search_resume_name = NULL;
566 kfree(ptmp); 564 kfree(ptmp);
567 } 565 }
@@ -870,10 +868,9 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
870 if (rc != 0) 868 if (rc != 0)
871 break; 869 break;
872 } 870 }
873#ifdef CONFIG_CIFS_EXPERIMENTAL
874 /* BB FIXME We can not sign across two buffers yet */ 871 /* BB FIXME We can not sign across two buffers yet */
875 if((experimEnabled) && ((pTcon->ses->server->secMode & 872 if((pTcon->ses->server->secMode &
876 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) == 0)) { 873 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) == 0) {
877 struct kvec iov[2]; 874 struct kvec iov[2];
878 unsigned int len; 875 unsigned int len;
879 876
@@ -889,7 +886,6 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
889 iov, 1, long_op); 886 iov, 1, long_op);
890 } else 887 } else
891 /* BB FIXME fixup indentation of line below */ 888 /* BB FIXME fixup indentation of line below */
892#endif
893 rc = CIFSSMBWrite(xid, pTcon, 889 rc = CIFSSMBWrite(xid, pTcon,
894 open_file->netfid, 890 open_file->netfid,
895 min_t(const int, cifs_sb->wsize, 891 min_t(const int, cifs_sb->wsize,
@@ -1026,7 +1022,6 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
1026 return rc; 1022 return rc;
1027} 1023}
1028 1024
1029#ifdef CONFIG_CIFS_EXPERIMENTAL
1030static int cifs_writepages(struct address_space *mapping, 1025static int cifs_writepages(struct address_space *mapping,
1031 struct writeback_control *wbc) 1026 struct writeback_control *wbc)
1032{ 1027{
@@ -1229,7 +1224,6 @@ retry:
1229 1224
1230 return rc; 1225 return rc;
1231} 1226}
1232#endif
1233 1227
1234static int cifs_writepage(struct page* page, struct writeback_control *wbc) 1228static int cifs_writepage(struct page* page, struct writeback_control *wbc)
1235{ 1229{
@@ -1428,6 +1422,7 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,
1428 rc = -EAGAIN; 1422 rc = -EAGAIN;
1429 smb_read_data = NULL; 1423 smb_read_data = NULL;
1430 while (rc == -EAGAIN) { 1424 while (rc == -EAGAIN) {
1425 int buf_type = CIFS_NO_BUFFER;
1431 if ((open_file->invalidHandle) && 1426 if ((open_file->invalidHandle) &&
1432 (!open_file->closePend)) { 1427 (!open_file->closePend)) {
1433 rc = cifs_reopen_file(file->f_dentry->d_inode, 1428 rc = cifs_reopen_file(file->f_dentry->d_inode,
@@ -1436,20 +1431,22 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,
1436 break; 1431 break;
1437 } 1432 }
1438 rc = CIFSSMBRead(xid, pTcon, 1433 rc = CIFSSMBRead(xid, pTcon,
1439 open_file->netfid, 1434 open_file->netfid,
1440 current_read_size, *poffset, 1435 current_read_size, *poffset,
1441 &bytes_read, &smb_read_data); 1436 &bytes_read, &smb_read_data,
1437 &buf_type);
1442 pSMBr = (struct smb_com_read_rsp *)smb_read_data; 1438 pSMBr = (struct smb_com_read_rsp *)smb_read_data;
1443 if (copy_to_user(current_offset, 1439 if (copy_to_user(current_offset,
1444 smb_read_data + 4 /* RFC1001 hdr */ 1440 smb_read_data + 4 /* RFC1001 hdr */
1445 + le16_to_cpu(pSMBr->DataOffset), 1441 + le16_to_cpu(pSMBr->DataOffset),
1446 bytes_read)) { 1442 bytes_read)) {
1447 rc = -EFAULT; 1443 rc = -EFAULT;
1448 FreeXid(xid); 1444 }
1449 return rc;
1450 }
1451 if (smb_read_data) { 1445 if (smb_read_data) {
1452 cifs_buf_release(smb_read_data); 1446 if(buf_type == CIFS_SMALL_BUFFER)
1447 cifs_small_buf_release(smb_read_data);
1448 else if(buf_type == CIFS_LARGE_BUFFER)
1449 cifs_buf_release(smb_read_data);
1453 smb_read_data = NULL; 1450 smb_read_data = NULL;
1454 } 1451 }
1455 } 1452 }
@@ -1482,6 +1479,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
1482 int xid; 1479 int xid;
1483 char *current_offset; 1480 char *current_offset;
1484 struct cifsFileInfo *open_file; 1481 struct cifsFileInfo *open_file;
1482 int buf_type = CIFS_NO_BUFFER;
1485 1483
1486 xid = GetXid(); 1484 xid = GetXid();
1487 cifs_sb = CIFS_SB(file->f_dentry->d_sb); 1485 cifs_sb = CIFS_SB(file->f_dentry->d_sb);
@@ -1518,9 +1516,10 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
1518 break; 1516 break;
1519 } 1517 }
1520 rc = CIFSSMBRead(xid, pTcon, 1518 rc = CIFSSMBRead(xid, pTcon,
1521 open_file->netfid, 1519 open_file->netfid,
1522 current_read_size, *poffset, 1520 current_read_size, *poffset,
1523 &bytes_read, &current_offset); 1521 &bytes_read, &current_offset,
1522 &buf_type);
1524 } 1523 }
1525 if (rc || (bytes_read == 0)) { 1524 if (rc || (bytes_read == 0)) {
1526 if (total_read) { 1525 if (total_read) {
@@ -1618,6 +1617,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
1618 struct smb_com_read_rsp *pSMBr; 1617 struct smb_com_read_rsp *pSMBr;
1619 struct pagevec lru_pvec; 1618 struct pagevec lru_pvec;
1620 struct cifsFileInfo *open_file; 1619 struct cifsFileInfo *open_file;
1620 int buf_type = CIFS_NO_BUFFER;
1621 1621
1622 xid = GetXid(); 1622 xid = GetXid();
1623 if (file->private_data == NULL) { 1623 if (file->private_data == NULL) {
@@ -1674,14 +1674,17 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
1674 } 1674 }
1675 1675
1676 rc = CIFSSMBRead(xid, pTcon, 1676 rc = CIFSSMBRead(xid, pTcon,
1677 open_file->netfid, 1677 open_file->netfid,
1678 read_size, offset, 1678 read_size, offset,
1679 &bytes_read, &smb_read_data); 1679 &bytes_read, &smb_read_data,
1680 1680 &buf_type);
1681 /* BB more RC checks ? */ 1681 /* BB more RC checks ? */
1682 if (rc== -EAGAIN) { 1682 if (rc== -EAGAIN) {
1683 if (smb_read_data) { 1683 if (smb_read_data) {
1684 cifs_buf_release(smb_read_data); 1684 if(buf_type == CIFS_SMALL_BUFFER)
1685 cifs_small_buf_release(smb_read_data);
1686 else if(buf_type == CIFS_LARGE_BUFFER)
1687 cifs_buf_release(smb_read_data);
1685 smb_read_data = NULL; 1688 smb_read_data = NULL;
1686 } 1689 }
1687 } 1690 }
@@ -1738,7 +1741,10 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
1738 break; 1741 break;
1739 } 1742 }
1740 if (smb_read_data) { 1743 if (smb_read_data) {
1741 cifs_buf_release(smb_read_data); 1744 if(buf_type == CIFS_SMALL_BUFFER)
1745 cifs_small_buf_release(smb_read_data);
1746 else if(buf_type == CIFS_LARGE_BUFFER)
1747 cifs_buf_release(smb_read_data);
1742 smb_read_data = NULL; 1748 smb_read_data = NULL;
1743 } 1749 }
1744 bytes_read = 0; 1750 bytes_read = 0;
@@ -1748,7 +1754,10 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
1748 1754
1749/* need to free smb_read_data buf before exit */ 1755/* need to free smb_read_data buf before exit */
1750 if (smb_read_data) { 1756 if (smb_read_data) {
1751 cifs_buf_release(smb_read_data); 1757 if(buf_type == CIFS_SMALL_BUFFER)
1758 cifs_small_buf_release(smb_read_data);
1759 else if(buf_type == CIFS_LARGE_BUFFER)
1760 cifs_buf_release(smb_read_data);
1752 smb_read_data = NULL; 1761 smb_read_data = NULL;
1753 } 1762 }
1754 1763
@@ -1827,10 +1836,20 @@ int is_size_safe_to_change(struct cifsInodeInfo *cifsInode)
1827 open_file = find_writable_file(cifsInode); 1836 open_file = find_writable_file(cifsInode);
1828 1837
1829 if(open_file) { 1838 if(open_file) {
1839 struct cifs_sb_info *cifs_sb;
1840
1830 /* there is not actually a write pending so let 1841 /* there is not actually a write pending so let
1831 this handle go free and allow it to 1842 this handle go free and allow it to
1832 be closable if needed */ 1843 be closable if needed */
1833 atomic_dec(&open_file->wrtPending); 1844 atomic_dec(&open_file->wrtPending);
1845
1846 cifs_sb = CIFS_SB(cifsInode->vfs_inode.i_sb);
1847 if ( cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO ) {
1848 /* since no page cache to corrupt on directio
1849 we can change size safely */
1850 return 1;
1851 }
1852
1834 return 0; 1853 return 0;
1835 } else 1854 } else
1836 return 1; 1855 return 1;
@@ -1875,9 +1894,7 @@ struct address_space_operations cifs_addr_ops = {
1875 .readpage = cifs_readpage, 1894 .readpage = cifs_readpage,
1876 .readpages = cifs_readpages, 1895 .readpages = cifs_readpages,
1877 .writepage = cifs_writepage, 1896 .writepage = cifs_writepage,
1878#ifdef CONFIG_CIFS_EXPERIMENTAL
1879 .writepages = cifs_writepages, 1897 .writepages = cifs_writepages,
1880#endif
1881 .prepare_write = cifs_prepare_write, 1898 .prepare_write = cifs_prepare_write,
1882 .commit_write = cifs_commit_write, 1899 .commit_write = cifs_commit_write,
1883 .set_page_dirty = __set_page_dirty_nobuffers, 1900 .set_page_dirty = __set_page_dirty_nobuffers,