aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/cifs/cifsglob.h4
-rw-r--r--fs/cifs/cifsproto.h3
-rw-r--r--fs/cifs/cifssmb.c6
-rw-r--r--fs/cifs/file.c36
-rw-r--r--fs/cifs/smb1ops.c11
5 files changed, 38 insertions, 22 deletions
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 5b1751d81901..48c7c83a7a99 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -291,6 +291,10 @@ struct smb_version_operations {
291 int (*sync_read)(const unsigned int, struct cifsFileInfo *, 291 int (*sync_read)(const unsigned int, struct cifsFileInfo *,
292 struct cifs_io_parms *, unsigned int *, char **, 292 struct cifs_io_parms *, unsigned int *, char **,
293 int *); 293 int *);
294 /* sync write to the server */
295 int (*sync_write)(const unsigned int, struct cifsFileInfo *,
296 struct cifs_io_parms *, unsigned int *, struct kvec *,
297 unsigned long);
294}; 298};
295 299
296struct smb_version_values { 300struct smb_version_values {
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 8b320c7b582c..f20d0c8ee7ce 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -369,8 +369,7 @@ extern int CIFSSMBWrite(const unsigned int xid, struct cifs_io_parms *io_parms,
369 unsigned int *nbytes, const char *buf, 369 unsigned int *nbytes, const char *buf,
370 const char __user *ubuf, const int long_op); 370 const char __user *ubuf, const int long_op);
371extern int CIFSSMBWrite2(const unsigned int xid, struct cifs_io_parms *io_parms, 371extern int CIFSSMBWrite2(const unsigned int xid, struct cifs_io_parms *io_parms,
372 unsigned int *nbytes, struct kvec *iov, const int nvec, 372 unsigned int *nbytes, struct kvec *iov, const int nvec);
373 const int long_op);
374extern int CIFSGetSrvInodeNumber(const unsigned int xid, struct cifs_tcon *tcon, 373extern int CIFSGetSrvInodeNumber(const unsigned int xid, struct cifs_tcon *tcon,
375 const char *search_name, __u64 *inode_number, 374 const char *search_name, __u64 *inode_number,
376 const struct nls_table *nls_codepage, 375 const struct nls_table *nls_codepage,
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index f27b13ea08b8..733119dad493 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -2123,8 +2123,7 @@ async_writev_out:
2123 2123
2124int 2124int
2125CIFSSMBWrite2(const unsigned int xid, struct cifs_io_parms *io_parms, 2125CIFSSMBWrite2(const unsigned int xid, struct cifs_io_parms *io_parms,
2126 unsigned int *nbytes, struct kvec *iov, int n_vec, 2126 unsigned int *nbytes, struct kvec *iov, int n_vec)
2127 const int long_op)
2128{ 2127{
2129 int rc = -EACCES; 2128 int rc = -EACCES;
2130 WRITE_REQ *pSMB = NULL; 2129 WRITE_REQ *pSMB = NULL;
@@ -2195,8 +2194,7 @@ CIFSSMBWrite2(const unsigned int xid, struct cifs_io_parms *io_parms,
2195 iov[0].iov_len = smb_hdr_len + 8; 2194 iov[0].iov_len = smb_hdr_len + 8;
2196 2195
2197 2196
2198 rc = SendReceive2(xid, tcon->ses, iov, n_vec + 1, &resp_buf_type, 2197 rc = SendReceive2(xid, tcon->ses, iov, n_vec + 1, &resp_buf_type, 0);
2199 long_op);
2200 cifs_stats_inc(&tcon->stats.cifs_stats.num_writes); 2198 cifs_stats_inc(&tcon->stats.cifs_stats.num_writes);
2201 if (rc) { 2199 if (rc) {
2202 cFYI(1, "Send error Write2 = %d", rc); 2200 cFYI(1, "Send error Write2 = %d", rc);
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index fae03c52f314..39fff77e38d4 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -1477,15 +1477,16 @@ cifs_update_eof(struct cifsInodeInfo *cifsi, loff_t offset,
1477 cifsi->server_eof = end_of_write; 1477 cifsi->server_eof = end_of_write;
1478} 1478}
1479 1479
1480static ssize_t cifs_write(struct cifsFileInfo *open_file, __u32 pid, 1480static ssize_t
1481 const char *write_data, size_t write_size, 1481cifs_write(struct cifsFileInfo *open_file, __u32 pid, const char *write_data,
1482 loff_t *poffset) 1482 size_t write_size, loff_t *offset)
1483{ 1483{
1484 int rc = 0; 1484 int rc = 0;
1485 unsigned int bytes_written = 0; 1485 unsigned int bytes_written = 0;
1486 unsigned int total_written; 1486 unsigned int total_written;
1487 struct cifs_sb_info *cifs_sb; 1487 struct cifs_sb_info *cifs_sb;
1488 struct cifs_tcon *pTcon; 1488 struct cifs_tcon *tcon;
1489 struct TCP_Server_Info *server;
1489 unsigned int xid; 1490 unsigned int xid;
1490 struct dentry *dentry = open_file->dentry; 1491 struct dentry *dentry = open_file->dentry;
1491 struct cifsInodeInfo *cifsi = CIFS_I(dentry->d_inode); 1492 struct cifsInodeInfo *cifsi = CIFS_I(dentry->d_inode);
@@ -1494,9 +1495,13 @@ static ssize_t cifs_write(struct cifsFileInfo *open_file, __u32 pid,
1494 cifs_sb = CIFS_SB(dentry->d_sb); 1495 cifs_sb = CIFS_SB(dentry->d_sb);
1495 1496
1496 cFYI(1, "write %zd bytes to offset %lld of %s", write_size, 1497 cFYI(1, "write %zd bytes to offset %lld of %s", write_size,
1497 *poffset, dentry->d_name.name); 1498 *offset, dentry->d_name.name);
1499
1500 tcon = tlink_tcon(open_file->tlink);
1501 server = tcon->ses->server;
1498 1502
1499 pTcon = tlink_tcon(open_file->tlink); 1503 if (!server->ops->sync_write)
1504 return -ENOSYS;
1500 1505
1501 xid = get_xid(); 1506 xid = get_xid();
1502 1507
@@ -1522,13 +1527,12 @@ static ssize_t cifs_write(struct cifsFileInfo *open_file, __u32 pid,
1522 /* iov[0] is reserved for smb header */ 1527 /* iov[0] is reserved for smb header */
1523 iov[1].iov_base = (char *)write_data + total_written; 1528 iov[1].iov_base = (char *)write_data + total_written;
1524 iov[1].iov_len = len; 1529 iov[1].iov_len = len;
1525 io_parms.netfid = open_file->fid.netfid;
1526 io_parms.pid = pid; 1530 io_parms.pid = pid;
1527 io_parms.tcon = pTcon; 1531 io_parms.tcon = tcon;
1528 io_parms.offset = *poffset; 1532 io_parms.offset = *offset;
1529 io_parms.length = len; 1533 io_parms.length = len;
1530 rc = CIFSSMBWrite2(xid, &io_parms, &bytes_written, iov, 1534 rc = server->ops->sync_write(xid, open_file, &io_parms,
1531 1, 0); 1535 &bytes_written, iov, 1);
1532 } 1536 }
1533 if (rc || (bytes_written == 0)) { 1537 if (rc || (bytes_written == 0)) {
1534 if (total_written) 1538 if (total_written)
@@ -1539,18 +1543,18 @@ static ssize_t cifs_write(struct cifsFileInfo *open_file, __u32 pid,
1539 } 1543 }
1540 } else { 1544 } else {
1541 spin_lock(&dentry->d_inode->i_lock); 1545 spin_lock(&dentry->d_inode->i_lock);
1542 cifs_update_eof(cifsi, *poffset, bytes_written); 1546 cifs_update_eof(cifsi, *offset, bytes_written);
1543 spin_unlock(&dentry->d_inode->i_lock); 1547 spin_unlock(&dentry->d_inode->i_lock);
1544 *poffset += bytes_written; 1548 *offset += bytes_written;
1545 } 1549 }
1546 } 1550 }
1547 1551
1548 cifs_stats_bytes_written(pTcon, total_written); 1552 cifs_stats_bytes_written(tcon, total_written);
1549 1553
1550 if (total_written > 0) { 1554 if (total_written > 0) {
1551 spin_lock(&dentry->d_inode->i_lock); 1555 spin_lock(&dentry->d_inode->i_lock);
1552 if (*poffset > dentry->d_inode->i_size) 1556 if (*offset > dentry->d_inode->i_size)
1553 i_size_write(dentry->d_inode, *poffset); 1557 i_size_write(dentry->d_inode, *offset);
1554 spin_unlock(&dentry->d_inode->i_lock); 1558 spin_unlock(&dentry->d_inode->i_lock);
1555 } 1559 }
1556 mark_inode_dirty_sync(dentry->d_inode); 1560 mark_inode_dirty_sync(dentry->d_inode);
diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
index cea958ee8b7a..aa55c2fbf793 100644
--- a/fs/cifs/smb1ops.c
+++ b/fs/cifs/smb1ops.c
@@ -748,6 +748,16 @@ cifs_sync_read(const unsigned int xid, struct cifsFileInfo *cfile,
748 return CIFSSMBRead(xid, parms, bytes_read, buf, buf_type); 748 return CIFSSMBRead(xid, parms, bytes_read, buf, buf_type);
749} 749}
750 750
751static int
752cifs_sync_write(const unsigned int xid, struct cifsFileInfo *cfile,
753 struct cifs_io_parms *parms, unsigned int *written,
754 struct kvec *iov, unsigned long nr_segs)
755{
756
757 parms->netfid = cfile->fid.netfid;
758 return CIFSSMBWrite2(xid, parms, written, iov, nr_segs);
759}
760
751struct smb_version_operations smb1_operations = { 761struct smb_version_operations smb1_operations = {
752 .send_cancel = send_nt_cancel, 762 .send_cancel = send_nt_cancel,
753 .compare_fids = cifs_compare_fids, 763 .compare_fids = cifs_compare_fids,
@@ -797,6 +807,7 @@ struct smb_version_operations smb1_operations = {
797 .async_readv = cifs_async_readv, 807 .async_readv = cifs_async_readv,
798 .async_writev = cifs_async_writev, 808 .async_writev = cifs_async_writev,
799 .sync_read = cifs_sync_read, 809 .sync_read = cifs_sync_read,
810 .sync_write = cifs_sync_write,
800}; 811};
801 812
802struct smb_version_values smb1_values = { 813struct smb_version_values smb1_values = {