Skip to content

Commit

Permalink
CIFS: Move async write to ops struct
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org>
Signed-off-by: Steve French <smfrench@gmail.com>
  • Loading branch information
Pavel Shilovsky authored and Steve French committed Sep 25, 2012
1 parent 09a4707 commit c9de5c8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
3 changes: 3 additions & 0 deletions fs/cifs/cifsglob.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ struct cifs_fattr;
struct smb_vol;
struct cifs_fid;
struct cifs_readdata;
struct cifs_writedata;

struct smb_version_operations {
int (*send_cancel)(struct TCP_Server_Info *, void *,
Expand Down Expand Up @@ -283,6 +284,8 @@ struct smb_version_operations {
int (*flush)(const unsigned int, struct cifs_tcon *, struct cifs_fid *);
/* async read from the server */
int (*async_readv)(struct cifs_readdata *);
/* async write to the server */
int (*async_writev)(struct cifs_writedata *);
};

struct smb_version_values {
Expand Down
4 changes: 3 additions & 1 deletion fs/cifs/cifssmb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1926,14 +1926,16 @@ cifs_writev_requeue(struct cifs_writedata *wdata)
{
int i, rc;
struct inode *inode = wdata->cfile->dentry->d_inode;
struct TCP_Server_Info *server;

for (i = 0; i < wdata->nr_pages; i++) {
lock_page(wdata->pages[i]);
clear_page_dirty_for_io(wdata->pages[i]);
}

do {
rc = cifs_async_writev(wdata);
server = tlink_tcon(wdata->cfile->tlink)->ses->server;
rc = server->ops->async_writev(wdata);
} while (rc == -EAGAIN);

for (i = 0; i < wdata->nr_pages; i++) {
Expand Down
13 changes: 11 additions & 2 deletions fs/cifs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1754,6 +1754,7 @@ static int cifs_writepages(struct address_space *mapping,
bool done = false, scanned = false, range_whole = false;
pgoff_t end, index;
struct cifs_writedata *wdata;
struct TCP_Server_Info *server;
struct page *page;
int rc = 0;

Expand Down Expand Up @@ -1904,7 +1905,8 @@ static int cifs_writepages(struct address_space *mapping,
break;
}
wdata->pid = wdata->cfile->pid;
rc = cifs_async_writev(wdata);
server = tlink_tcon(wdata->cfile->tlink)->ses->server;
rc = server->ops->async_writev(wdata);
} while (wbc->sync_mode == WB_SYNC_ALL && rc == -EAGAIN);

for (i = 0; i < nr_pages; ++i)
Expand Down Expand Up @@ -2235,14 +2237,17 @@ static int
cifs_uncached_retry_writev(struct cifs_writedata *wdata)
{
int rc;
struct TCP_Server_Info *server;

server = tlink_tcon(wdata->cfile->tlink)->ses->server;

do {
if (wdata->cfile->invalidHandle) {
rc = cifs_reopen_file(wdata->cfile, false);
if (rc != 0)
continue;
}
rc = cifs_async_writev(wdata);
rc = server->ops->async_writev(wdata);
} while (rc == -EAGAIN);

return rc;
Expand Down Expand Up @@ -2277,6 +2282,10 @@ cifs_iovec_write(struct file *file, const struct iovec *iov,
cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
open_file = file->private_data;
tcon = tlink_tcon(open_file->tlink);

if (!tcon->ses->server->ops->async_writev)
return -ENOSYS;

offset = *poffset;

if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD)
Expand Down
1 change: 1 addition & 0 deletions fs/cifs/smb1ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,7 @@ struct smb_version_operations smb1_operations = {
.close = cifs_close_file,
.flush = cifs_flush_file,
.async_readv = cifs_async_readv,
.async_writev = cifs_async_writev,
};

struct smb_version_values smb1_values = {
Expand Down

0 comments on commit c9de5c8

Please sign in to comment.