提交 f9c6e234 编写于 作者: P Pavel Shilovsky 提交者: Steve French

CIFS: Move readpage code to ops struct

Signed-off-by: NPavel Shilovsky <pshilovsky@samba.org>
Signed-off-by: NSteve French <smfrench@gmail.com>
上级 33319141
...@@ -174,6 +174,7 @@ struct smb_vol; ...@@ -174,6 +174,7 @@ struct smb_vol;
struct cifs_fid; struct cifs_fid;
struct cifs_readdata; struct cifs_readdata;
struct cifs_writedata; struct cifs_writedata;
struct cifs_io_parms;
struct smb_version_operations { struct smb_version_operations {
int (*send_cancel)(struct TCP_Server_Info *, void *, int (*send_cancel)(struct TCP_Server_Info *, void *,
...@@ -286,6 +287,10 @@ struct smb_version_operations { ...@@ -286,6 +287,10 @@ struct smb_version_operations {
int (*async_readv)(struct cifs_readdata *); int (*async_readv)(struct cifs_readdata *);
/* async write to the server */ /* async write to the server */
int (*async_writev)(struct cifs_writedata *); int (*async_writev)(struct cifs_writedata *);
/* sync read from the server */
int (*sync_read)(const unsigned int, struct cifsFileInfo *,
struct cifs_io_parms *, unsigned int *, char **,
int *);
}; };
struct smb_version_values { struct smb_version_values {
......
...@@ -2782,8 +2782,8 @@ ssize_t cifs_strict_readv(struct kiocb *iocb, const struct iovec *iov, ...@@ -2782,8 +2782,8 @@ ssize_t cifs_strict_readv(struct kiocb *iocb, const struct iovec *iov,
return cifs_user_readv(iocb, iov, nr_segs, pos); return cifs_user_readv(iocb, iov, nr_segs, pos);
} }
static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size, static ssize_t
loff_t *poffset) cifs_read(struct file *file, char *read_data, size_t read_size, loff_t *offset)
{ {
int rc = -EACCES; int rc = -EACCES;
unsigned int bytes_read = 0; unsigned int bytes_read = 0;
...@@ -2792,8 +2792,9 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size, ...@@ -2792,8 +2792,9 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
unsigned int rsize; unsigned int rsize;
struct cifs_sb_info *cifs_sb; struct cifs_sb_info *cifs_sb;
struct cifs_tcon *tcon; struct cifs_tcon *tcon;
struct TCP_Server_Info *server;
unsigned int xid; unsigned int xid;
char *current_offset; char *cur_offset;
struct cifsFileInfo *open_file; struct cifsFileInfo *open_file;
struct cifs_io_parms io_parms; struct cifs_io_parms io_parms;
int buf_type = CIFS_NO_BUFFER; int buf_type = CIFS_NO_BUFFER;
...@@ -2812,6 +2813,12 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size, ...@@ -2812,6 +2813,12 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
} }
open_file = file->private_data; open_file = file->private_data;
tcon = tlink_tcon(open_file->tlink); tcon = tlink_tcon(open_file->tlink);
server = tcon->ses->server;
if (!server->ops->sync_read) {
free_xid(xid);
return -ENOSYS;
}
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD)
pid = open_file->pid; pid = open_file->pid;
...@@ -2821,9 +2828,8 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size, ...@@ -2821,9 +2828,8 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
if ((file->f_flags & O_ACCMODE) == O_WRONLY) if ((file->f_flags & O_ACCMODE) == O_WRONLY)
cFYI(1, "attempting read on write only file instance"); cFYI(1, "attempting read on write only file instance");
for (total_read = 0, current_offset = read_data; for (total_read = 0, cur_offset = read_data; read_size > total_read;
read_size > total_read; total_read += bytes_read, cur_offset += bytes_read) {
total_read += bytes_read, current_offset += bytes_read) {
current_read_size = min_t(uint, read_size - total_read, rsize); current_read_size = min_t(uint, read_size - total_read, rsize);
/* /*
* For windows me and 9x we do not want to request more than it * For windows me and 9x we do not want to request more than it
...@@ -2841,13 +2847,13 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size, ...@@ -2841,13 +2847,13 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
if (rc != 0) if (rc != 0)
break; break;
} }
io_parms.netfid = open_file->fid.netfid;
io_parms.pid = pid; io_parms.pid = pid;
io_parms.tcon = tcon; io_parms.tcon = tcon;
io_parms.offset = *poffset; io_parms.offset = *offset;
io_parms.length = current_read_size; io_parms.length = current_read_size;
rc = CIFSSMBRead(xid, &io_parms, &bytes_read, rc = server->ops->sync_read(xid, open_file, &io_parms,
&current_offset, &buf_type); &bytes_read, &cur_offset,
&buf_type);
} }
if (rc || (bytes_read == 0)) { if (rc || (bytes_read == 0)) {
if (total_read) { if (total_read) {
...@@ -2858,7 +2864,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size, ...@@ -2858,7 +2864,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
} }
} else { } else {
cifs_stats_bytes_read(tcon, total_read); cifs_stats_bytes_read(tcon, total_read);
*poffset += bytes_read; *offset += bytes_read;
} }
} }
free_xid(xid); free_xid(xid);
......
...@@ -739,6 +739,15 @@ cifs_flush_file(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -739,6 +739,15 @@ cifs_flush_file(const unsigned int xid, struct cifs_tcon *tcon,
return CIFSSMBFlush(xid, tcon, fid->netfid); return CIFSSMBFlush(xid, tcon, fid->netfid);
} }
static int
cifs_sync_read(const unsigned int xid, struct cifsFileInfo *cfile,
struct cifs_io_parms *parms, unsigned int *bytes_read,
char **buf, int *buf_type)
{
parms->netfid = cfile->fid.netfid;
return CIFSSMBRead(xid, parms, bytes_read, buf, buf_type);
}
struct smb_version_operations smb1_operations = { struct smb_version_operations smb1_operations = {
.send_cancel = send_nt_cancel, .send_cancel = send_nt_cancel,
.compare_fids = cifs_compare_fids, .compare_fids = cifs_compare_fids,
...@@ -787,6 +796,7 @@ struct smb_version_operations smb1_operations = { ...@@ -787,6 +796,7 @@ struct smb_version_operations smb1_operations = {
.flush = cifs_flush_file, .flush = cifs_flush_file,
.async_readv = cifs_async_readv, .async_readv = cifs_async_readv,
.async_writev = cifs_async_writev, .async_writev = cifs_async_writev,
.sync_read = cifs_sync_read,
}; };
struct smb_version_values smb1_values = { struct smb_version_values smb1_values = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册