summaryrefslogtreecommitdiff
path: root/fs/smb/client/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/smb/client/file.c')
-rw-r--r--fs/smb/client/file.c97
1 files changed, 38 insertions, 59 deletions
diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index 1ff1fce50198..30b3abcfc904 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -73,7 +73,7 @@ retry:
}
}
- rc = server->ops->wait_mtu_credits(server, wsize, &wdata->subreq.max_len,
+ rc = smb2_wait_mtu_credits(server, wsize, &wdata->subreq.max_len,
&wdata->credits);
if (rc < 0) {
subreq->error = rc;
@@ -120,7 +120,7 @@ static void cifs_issue_write(struct netfs_io_subrequest *subreq)
if (wdata->req->cfile->invalidHandle)
goto fail;
- wdata->server->ops->async_writev(wdata);
+ smb2_async_writev(wdata);
out:
return;
@@ -167,7 +167,7 @@ static bool cifs_clamp_length(struct netfs_io_subrequest *subreq)
cifs_sb->ctx);
- rc = server->ops->wait_mtu_credits(server, cifs_sb->ctx->rsize,
+ rc = smb2_wait_mtu_credits(server, cifs_sb->ctx->rsize,
&rsize, &rdata->credits);
if (rc) {
subreq->error = rc;
@@ -224,7 +224,7 @@ static void cifs_req_issue_read(struct netfs_io_subrequest *subreq)
size_t rsize = umin(subreq->len - subreq->transferred,
cifs_sb->ctx->rsize);
- rc = server->ops->wait_mtu_credits(server, rsize, &rdata->actual_len,
+ rc = smb2_wait_mtu_credits(server, rsize, &rdata->actual_len,
&rdata->credits);
if (rc)
goto out;
@@ -249,7 +249,7 @@ static void cifs_req_issue_read(struct netfs_io_subrequest *subreq)
if (subreq->rreq->origin != NETFS_DIO_READ)
__set_bit(NETFS_SREQ_CLEAR_TAIL, &subreq->flags);
- rc = rdata->server->ops->async_readv(rdata);
+ rc = smb2_async_readv(rdata);
out:
if (rc)
netfs_subreq_terminated(subreq, rc, false);
@@ -469,9 +469,6 @@ static int cifs_nt_open(const char *full_path, struct inode *inode, struct cifs_
struct cifs_open_parms oparms;
int rdwr_for_fscache = 0;
- if (!server->ops->open)
- return -ENOSYS;
-
/* If we're caching, we need to be able to fill in around partial writes. */
if (cifs_fscache_enabled(inode) && (f_flags & O_ACCMODE) == O_WRONLY)
rdwr_for_fscache = 1;
@@ -524,7 +521,7 @@ retry_open:
.fid = fid,
};
- rc = server->ops->open(xid, &oparms, oplock, buf);
+ rc = smb2_open_file(xid, &oparms, oplock, buf);
if (rc) {
if (rc == -EACCES && rdwr_for_fscache == 1) {
desired_access = cifs_convert_flags(f_flags, 0);
@@ -545,7 +542,7 @@ retry_open:
xid, fid);
if (rc) {
- server->ops->close(xid, tcon, fid);
+ smb2_close_file(xid, tcon, fid);
if (rc == -ESTALE)
rc = -EOPENSTALE;
}
@@ -651,7 +648,7 @@ struct cifsFileInfo *cifs_new_fileinfo(struct cifs_fid *fid, struct file *file,
list_del(&fid->pending_open->olist);
fid->purge_cache = false;
- server->ops->set_fid(cfile, fid, oplock);
+ smb2_set_fid(cfile, fid, oplock);
list_add(&cfile->tlist, &tcon->openFileList);
atomic_inc(&tcon->num_local_opens);
@@ -732,8 +729,8 @@ void serverclose_work(struct work_struct *work)
do {
if (server->ops->close_getattr)
rc = server->ops->close_getattr(0, tcon, cifs_file);
- else if (server->ops->close)
- rc = server->ops->close(0, tcon, &cifs_file->fid);
+ else
+ rc = smb2_close_file(0, tcon, &cifs_file->fid);
if (rc == -EBUSY || rc == -EAGAIN) {
retries++;
@@ -806,8 +803,7 @@ void _cifsFileInfo_put(struct cifsFileInfo *cifs_file,
}
spin_unlock(&cifs_file->file_info_lock);
- if (server->ops->get_lease_key)
- server->ops->get_lease_key(inode, &fid);
+ smb2_get_lease_key(inode, &fid);
/* store open in pending opens to make sure we don't miss lease break */
cifs_add_pending_open_locked(&fid, cifs_file->tlink, &open);
@@ -844,8 +840,8 @@ void _cifsFileInfo_put(struct cifsFileInfo *cifs_file,
xid = get_xid();
if (server->ops->close_getattr)
rc = server->ops->close_getattr(xid, tcon, cifs_file);
- else if (server->ops->close)
- rc = server->ops->close(xid, tcon, &cifs_file->fid);
+ else
+ rc = smb2_close_file(xid, tcon, &cifs_file->fid);
_free_xid(xid);
if (rc == -EBUSY || rc == -EAGAIN) {
@@ -943,14 +939,11 @@ int cifs_open(struct inode *inode, struct file *file)
oplock = 0;
- if (server->ops->get_lease_key)
- server->ops->get_lease_key(inode, &fid);
-
+ smb2_get_lease_key(inode, &fid);
cifs_add_pending_open(&fid, tlink, &open);
if (!posix_open_ok) {
- if (server->ops->get_lease_key)
- server->ops->get_lease_key(inode, &fid);
+ smb2_get_lease_key(inode, &fid);
rc = cifs_nt_open(full_path, inode, cifs_sb, tcon, file->f_flags, &oplock, &fid,
xid, &data);
@@ -962,8 +955,7 @@ int cifs_open(struct inode *inode, struct file *file)
cfile = cifs_new_fileinfo(&fid, file, tlink, oplock, data.symlink_target);
if (cfile == NULL) {
- if (server->ops->close)
- server->ops->close(xid, tcon, &fid);
+ smb2_close_file(xid, tcon, &fid);
cifs_del_pending_open(&open);
rc = -ENOMEM;
goto out;
@@ -1006,7 +998,7 @@ cifs_relock_file(struct cifsFileInfo *cfile)
return rc;
}
- rc = tcon->ses->server->ops->push_mand_locks(cfile);
+ rc = smb2_push_mandatory_locks(cfile);
up_read(&cinode->lock_sem);
return rc;
@@ -1081,9 +1073,7 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
if (cfile->f_flags & O_DIRECT)
create_options |= CREATE_NO_BUFFER;
- if (server->ops->get_lease_key)
- server->ops->get_lease_key(inode, &cfile->fid);
-
+ smb2_get_lease_key(inode, &cfile->fid);
retry_open:
oparms = (struct cifs_open_parms) {
.tcon = tcon,
@@ -1103,10 +1093,10 @@ retry_open:
* version of file size can be stale. If we knew for sure that inode was
* not dirty locally we could do this.
*/
- rc = server->ops->open(xid, &oparms, &oplock, NULL);
+ rc = smb2_open_file(xid, &oparms, &oplock, NULL);
if (rc == -ENOENT && oparms.reconnect == false) {
/* durable handle timeout is expired - open the file again */
- rc = server->ops->open(xid, &oparms, &oplock, NULL);
+ rc = smb2_open_file(xid, &oparms, &oplock, NULL);
/* indicate that we need to relock the file */
oparms.reconnect = true;
}
@@ -1162,7 +1152,7 @@ retry_open:
oplock = 0;
}
- server->ops->set_fid(cfile, &cfile->fid, oplock);
+ smb2_set_fid(cfile, &cfile->fid, oplock);
if (oparms.reconnect)
cifs_relock_file(cfile);
@@ -1299,13 +1289,10 @@ int cifs_closedir(struct inode *inode, struct file *file)
cifs_dbg(FYI, "Freeing private data in close dir\n");
spin_lock(&cfile->file_info_lock);
- if (server->ops->dir_needs_close(cfile)) {
+ if (smb2_dir_needs_close(cfile)) {
cfile->invalidHandle = true;
spin_unlock(&cfile->file_info_lock);
- if (server->ops->close_dir)
- rc = server->ops->close_dir(xid, tcon, &cfile->fid);
- else
- rc = -ENOSYS;
+ rc = smb2_close_dir(xid, tcon, &cfile->fid);
cifs_dbg(FYI, "Closing uncompleted readdir with rc %d\n", rc);
/* not much we can do if it fails anyway, ignore rc */
rc = 0;
@@ -1377,19 +1364,19 @@ cifs_find_fid_lock_conflict(struct cifs_fid_locks *fdlocks, __u64 offset,
offset >= li->offset + li->length)
continue;
if (rw_check != CIFS_LOCK_OP && current->tgid == li->pid &&
- server->ops->compare_fids(cfile, cur_cfile)) {
+ smb2_compare_fids(cfile, cur_cfile)) {
/* shared lock prevents write op through the same fid */
if (!(li->type & server->vals->shared_lock_type) ||
rw_check != CIFS_WRITE_OP)
continue;
}
if ((type & server->vals->shared_lock_type) &&
- ((server->ops->compare_fids(cfile, cur_cfile) &&
+ ((smb2_compare_fids(cfile, cur_cfile) &&
current->tgid == li->pid) || type == li->type))
continue;
if (rw_check == CIFS_LOCK_OP &&
(flags & FL_OFDLCK) && (li->flags & FL_OFDLCK) &&
- server->ops->compare_fids(cfile, cur_cfile))
+ smb2_compare_fids(cfile, cur_cfile))
continue;
if (conf_lock)
*conf_lock = li;
@@ -1539,7 +1526,7 @@ cifs_push_locks(struct cifsFileInfo *cfile)
return rc;
}
- rc = tcon->ses->server->ops->push_mand_locks(cfile);
+ rc = smb2_push_mandatory_locks(cfile);
cinode->can_cache_brlcks = false;
up_write(&cinode->lock_sem);
@@ -1609,10 +1596,10 @@ cifs_getlk(struct file *file, struct file_lock *flock, __u32 type,
return rc;
/* BB we could chain these into one lock request BB */
- rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length, type,
+ rc = smb2_mand_lock(xid, cfile, flock->fl_start, length, type,
1, 0, false);
if (rc == 0) {
- rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length,
+ rc = smb2_mand_lock(xid, cfile, flock->fl_start, length,
type, 0, 1, false);
flock->c.flc_type = F_UNLCK;
if (rc != 0)
@@ -1628,11 +1615,11 @@ cifs_getlk(struct file *file, struct file_lock *flock, __u32 type,
type &= ~server->vals->exclusive_lock_type;
- rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length,
+ rc = smb2_mand_lock(xid, cfile, flock->fl_start, length,
type | server->vals->shared_lock_type,
1, 0, false);
if (rc == 0) {
- rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length,
+ rc = smb2_mand_lock(xid, cfile, flock->fl_start, length,
type | server->vals->shared_lock_type, 0, 1, false);
flock->c.flc_type = F_RDLCK;
if (rc != 0)
@@ -1707,7 +1694,7 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
CIFS_I(inode)->oplock = 0;
}
- rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length,
+ rc = smb2_mand_lock(xid, cfile, flock->fl_start, length,
type, 1, 0, wait_flag);
if (rc) {
kfree(lock);
@@ -1716,7 +1703,7 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
cifs_lock_add(cfile, lock);
} else if (unlock)
- rc = server->ops->mand_unlock_range(cfile, flock, xid);
+ rc = smb2_unlock_range(cfile, flock, xid);
out:
if ((flock->c.flc_flags & FL_POSIX) || (flock->c.flc_flags & FL_FLOCK)) {
@@ -2102,20 +2089,16 @@ int cifs_strict_fsync(struct file *file, loff_t start, loff_t end,
tcon = tlink_tcon(smbfile->tlink);
if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) {
server = tcon->ses->server;
- if (server->ops->flush == NULL) {
- rc = -ENOSYS;
- goto strict_fsync_exit;
- }
if ((OPEN_FMODE(smbfile->f_flags) & FMODE_WRITE) == 0) {
smbfile = find_writable_file(CIFS_I(inode), FIND_WR_ANY);
if (smbfile) {
- rc = server->ops->flush(xid, tcon, &smbfile->fid);
+ rc = smb2_flush_file(xid, tcon, &smbfile->fid);
cifsFileInfo_put(smbfile);
} else
cifs_dbg(FYI, "ignore fsync for file not open for write\n");
} else
- rc = server->ops->flush(xid, tcon, &smbfile->fid);
+ rc = smb2_flush_file(xid, tcon, &smbfile->fid);
}
strict_fsync_exit:
@@ -2150,20 +2133,16 @@ int cifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
tcon = tlink_tcon(smbfile->tlink);
if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) {
server = tcon->ses->server;
- if (server->ops->flush == NULL) {
- rc = -ENOSYS;
- goto fsync_exit;
- }
if ((OPEN_FMODE(smbfile->f_flags) & FMODE_WRITE) == 0) {
smbfile = find_writable_file(CIFS_I(inode), FIND_WR_ANY);
if (smbfile) {
- rc = server->ops->flush(xid, tcon, &smbfile->fid);
+ rc = smb2_flush_file(xid, tcon, &smbfile->fid);
cifsFileInfo_put(smbfile);
} else
cifs_dbg(FYI, "ignore fsync for file not open for write\n");
} else
- rc = server->ops->flush(xid, tcon, &smbfile->fid);
+ rc = smb2_flush_file(xid, tcon, &smbfile->fid);
}
fsync_exit:
@@ -2572,7 +2551,7 @@ oplock_break_ack:
/* check list empty since can race with kill_sb calling tree disconnect */
if (!oplock_break_cancelled && !list_empty(&cinode->openFileList)) {
spin_unlock(&cinode->open_file_lock);
- rc = server->ops->oplock_response(tcon, persistent_fid,
+ rc = smb2_oplock_response(tcon, persistent_fid,
volatile_fid, net_fid, cinode);
cifs_dbg(FYI, "Oplock release rc = %d\n", rc);
} else