diff options
author | Pavel Shilovsky <pshilovsky@samba.org> | 2012-09-18 19:20:30 -0400 |
---|---|---|
committer | Steve French <smfrench@gmail.com> | 2012-09-24 22:46:28 -0400 |
commit | ba9ad7257ae50b8aa72a3f44da839830e065363c (patch) | |
tree | 95d7aafe1a24ef0d046bee15833854bd397882b9 /fs/cifs/file.c | |
parent | d8e050398d23ef7c019c96200b80d73f4e5cec0c (diff) |
CIFS: Move writepage to ops struct
Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org>
Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r-- | fs/cifs/file.c | 36 |
1 files changed, 20 insertions, 16 deletions
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 | ||
1480 | static ssize_t cifs_write(struct cifsFileInfo *open_file, __u32 pid, | 1480 | static ssize_t |
1481 | const char *write_data, size_t write_size, | 1481 | cifs_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); |