summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnzo Matsumiya <ematsumiya@suse.de>2024-11-13 17:31:03 -0300
committerEnzo Matsumiya <ematsumiya@suse.de>2024-11-14 15:54:44 -0300
commitd3e3f6a0581323822d06a3d33bacda0955a2d7e1 (patch)
tree1c1f27c7426df30115ae2eae8d0a94bdf5b10a60
parentc449f3a65bd502fa27d7b0d59eefb6b0d2ce41f2 (diff)
downloadlinux-d3e3f6a0581323822d06a3d33bacda0955a2d7e1.tar.gz
linux-d3e3f6a0581323822d06a3d33bacda0955a2d7e1.tar.bz2
linux-d3e3f6a0581323822d06a3d33bacda0955a2d7e1.zip
smb: client: replace function pointers with smb{2,3}_* functions
Continuation of previous commit. Signed-off-by: Enzo Matsumiya <ematsumiya@suse.de>
-rw-r--r--fs/smb/client/cifs_debug.c7
-rw-r--r--fs/smb/client/cifsacl.c6
-rw-r--r--fs/smb/client/cifsfs.c1
-rw-r--r--fs/smb/client/cifsglob.h249
-rw-r--r--fs/smb/client/connect.c2
-rw-r--r--fs/smb/client/dfs.c1
-rw-r--r--fs/smb/client/dir.c7
-rw-r--r--fs/smb/client/file.c18
-rw-r--r--fs/smb/client/inode.c134
-rw-r--r--fs/smb/client/ioctl.c45
-rw-r--r--fs/smb/client/link.c27
-rw-r--r--fs/smb/client/misc.c7
-rw-r--r--fs/smb/client/readdir.c40
-rw-r--r--fs/smb/client/smb2inode.c6
-rw-r--r--fs/smb/client/smb2ops.c275
-rw-r--r--fs/smb/client/smb2pdu.c16
-rw-r--r--fs/smb/client/smb2proto.h203
-rw-r--r--fs/smb/client/smb2transport.c3
-rw-r--r--fs/smb/client/trace.h2
-rw-r--r--fs/smb/client/transport.c26
-rw-r--r--fs/smb/client/xattr.c18
21 files changed, 423 insertions, 670 deletions
diff --git a/fs/smb/client/cifs_debug.c b/fs/smb/client/cifs_debug.c
index f78e197327b5..e58291e4a83f 100644
--- a/fs/smb/client/cifs_debug.c
+++ b/fs/smb/client/cifs_debug.c
@@ -26,6 +26,7 @@
#include "smbdirect.h"
#endif
#include "cifs_swn.h"
+#include "smb2proto.h"
void
cifs_dump_mem(char *label, void *data, int length)
@@ -44,10 +45,8 @@ static void cifs_dump_detail(void *buf, struct TCP_Server_Info *server)
smb->Command, smb->Status, smb->Flags, smb->MessageId, smb->Id.SyncId.ProcessId,
smb->StructureSize);
- if (!smb2_check_message(buf, server->total_read, server)) {
- cifs_dbg(VFS, "smb buf %p len %u\n", smb,
- smb2_calc_smb_size(smb));
- }
+ if (!smb2_check_message(buf, server->total_read, server))
+ cifs_dbg(VFS, "smb buf %p len %u\n", smb, smb2_calc_size(smb));
#endif /* CONFIG_CIFS_DEBUG2 */
}
diff --git a/fs/smb/client/cifsacl.c b/fs/smb/client/cifsacl.c
index 114dd27ee918..467fa46bb435 100644
--- a/fs/smb/client/cifsacl.c
+++ b/fs/smb/client/cifsacl.c
@@ -25,6 +25,7 @@
#include "fs_context.h"
#include "cifs_fs_sb.h"
#include "cifs_unicode.h"
+#include "smb2proto.h"
/* security id for everyone/world system group */
static const struct cifs_sid sid_everyone = {
@@ -1510,12 +1511,9 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode,
cifs_dbg(NOISY, "build_sec_desc rc: %d\n", rc);
- if (ops->set_acl == NULL)
- rc = -EOPNOTSUPP;
-
if (!rc) {
/* Set the security descriptor */
- rc = ops->set_acl(pnntsd, nsecdesclen, inode, path, aclflag);
+ rc = set_smb2_acl(pnntsd, nsecdesclen, inode, path, aclflag);
cifs_dbg(NOISY, "set_cifs_acl rc: %d\n", rc);
}
cifs_put_tlink(tlink);
diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c
index c6f517099eea..990bb7d4caab 100644
--- a/fs/smb/client/cifsfs.c
+++ b/fs/smb/client/cifsfs.c
@@ -49,6 +49,7 @@
#endif
#include "fs_context.h"
#include "cached_dir.h"
+#include "smb2proto.h"
/*
* DOS dates from 1980/1/1 through 2107/12/31
diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h
index ef81676664a5..6a01b01ef8de 100644
--- a/fs/smb/client/cifsglob.h
+++ b/fs/smb/client/cifsglob.h
@@ -274,224 +274,6 @@ struct cifsInodeInfo;
struct cifs_open_parms;
struct cifs_credits;
-/* TODO: find a suitable place for these functions */
-extern struct mid_q_entry * smb2_find_mid(struct TCP_Server_Info *, char *);
-extern void smb2_dump_detail(void *buf, struct TCP_Server_Info *ptcp_info);
-extern void clear_stats(struct cifs_tcon *);
-extern void smb2_print_stats(struct seq_file *m, struct cifs_tcon *);
-extern bool smb2_is_valid_oplock_break(char *, struct TCP_Server_Info *);
-extern int smb2_handle_cancelled_mid(struct mid_q_entry *, struct TCP_Server_Info *);
-extern bool smb2_need_neg(struct TCP_Server_Info *);
-extern int smb2_negotiate(const unsigned int xid,
- struct cifs_ses *ses,
- struct TCP_Server_Info *server);
-extern int SMB2_sess_setup(const unsigned int, struct cifs_ses *,
- struct TCP_Server_Info *server,
- const struct nls_table *);
-extern int SMB2_logoff(const unsigned int, struct cifs_ses *);
-/* connect to a server share */
-extern int SMB2_tcon(const unsigned int, struct cifs_ses *, const char *,
- struct cifs_tcon *, const struct nls_table *);
-/* close tree connection */
-extern int SMB2_tdis(const unsigned int, struct cifs_tcon *);
-
-
-extern int smb2_get_dfs_refer(const unsigned int, struct cifs_ses *,
- const char *, struct dfs_info3_param **,
- unsigned int *, const struct nls_table *, int);
-/* check if a path is accessible or not */
-extern int smb2_is_path_accessible(const unsigned int, struct cifs_tcon *,
- struct cifs_sb_info *, const char *);
-/* query path data from the server */
-extern int smb2_query_path_info(const unsigned int xid,
- struct cifs_tcon *tcon,
- struct cifs_sb_info *cifs_sb,
- const char *full_path,
- struct cifs_open_info_data *data);
-/* query reparse point to determine which type of special file */
-extern int smb2_query_reparse_point(const unsigned int xid,
- struct cifs_tcon *tcon,
- struct cifs_sb_info *cifs_sb,
- const char *full_path,
- u32 *tag, struct kvec *rsp,
- int *rsp_buftype);
-/* get server index number */
-extern int smb2_get_srv_inum(const unsigned int xid, struct cifs_tcon *tcon,
- struct cifs_sb_info *cifs_sb, const char *full_path, u64 *uniqueid,
- struct cifs_open_info_data *data);
-/* query file data from the server */
-extern int smb2_query_file_info(const unsigned int xid, struct cifs_tcon *tcon,
- struct cifsFileInfo *cfile, struct cifs_open_info_data *data);
-/* set size by path */
-extern int smb2_set_path_size(const unsigned int, struct cifs_tcon *,
- const char *, __u64, struct cifs_sb_info *, bool,
- struct dentry *);
-/* set size by file handle */
-extern int smb2_set_file_size(const unsigned int, struct cifs_tcon *,
- struct cifsFileInfo *, __u64, bool);
-/* set attributes */
-int smb2_set_file_info(struct inode *, const char *, FILE_BASIC_INFO *,
- const unsigned int);
-extern int smb2_set_compression(const unsigned int, struct cifs_tcon *,
- struct cifsFileInfo *);
-/* check if we can send an echo or nor */
-extern bool smb2_can_echo(struct TCP_Server_Info *);
-/* send echo request */
-extern int SMB2_echo(struct TCP_Server_Info *);
-extern int smb2_mkdir(const unsigned int xid, struct inode *inode, umode_t mode,
- struct cifs_tcon *tcon, const char *name,
- struct cifs_sb_info *sb);
-/* set info on created directory */
-extern void smb2_mkdir_setinfo(struct inode *, const char *,
- struct cifs_sb_info *, struct cifs_tcon *,
- const unsigned int);
-/* remove directory */
-extern int smb2_rmdir(const unsigned int, struct cifs_tcon *, const char *,
- struct cifs_sb_info *);
-/* unlink file */
-extern int smb2_unlink(const unsigned int, struct cifs_tcon *, const char *,
- struct cifs_sb_info *, struct dentry *);
-/* send rename request */
-extern int smb2_rename_path(const unsigned int xid,
- struct cifs_tcon *tcon,
- struct dentry *source_dentry,
- const char *from_name, const char *to_name,
- struct cifs_sb_info *cifs_sb);
-extern int smb2_create_hardlink(const unsigned int xid,
- struct cifs_tcon *tcon,
- struct dentry *source_dentry,
- const char *from_name, const char *to_name,
- struct cifs_sb_info *cifs_sb);
-/* open a file for non-posix mounts */
-extern int smb2_open(const unsigned int xid, struct cifs_open_parms *oparms, __u32 *oplock,
- void *buf);
-/* set fid protocol-specific info */
-extern void smb2_set_fid(struct cifsFileInfo *, struct cifs_fid *, __u32);
-/* close a file */
-extern int smb2_close(const unsigned int, struct cifs_tcon *,
- struct cifs_fid *);
-/* send a flush request to the server */
-extern int smb2_flush_file(const unsigned int, struct cifs_tcon *, struct cifs_fid *);
-/* async read from the server */
-extern int smb2_async_readv(struct cifs_io_subrequest *);
-/* async write to the server */
-extern void smb2_async_writev(struct cifs_io_subrequest *);
-/* sync read from the server */
-extern int smb2_sync_read(const unsigned int, struct cifs_fid *,
- struct cifs_io_parms *, unsigned int *, char **,
- int *);
-/* sync write to the server */
-extern int smb2_sync_write(const unsigned int, struct cifs_fid *,
- struct cifs_io_parms *, unsigned int *, struct kvec *,
- unsigned long);
-/* open dir, start readdir */
-extern int smb2_query_dir_first(const unsigned int, struct cifs_tcon *,
- const char *, struct cifs_sb_info *,
- struct cifs_fid *, __u16,
- struct cifs_search_info *);
-/* continue readdir */
-extern int smb2_query_dir_next(const unsigned int, struct cifs_tcon *,
- struct cifs_fid *,
- __u16, struct cifs_search_info *srch_inf);
-/* close dir */
-extern int smb2_close_dir(const unsigned int, struct cifs_tcon *,
- struct cifs_fid *);
-/* calculate a size of SMB message */
-extern unsigned int smb2_calc_size(void *buf);
-/* check for STATUS_PENDING and process the response if yes */
-extern bool smb2_is_status_pending(char *buf, struct TCP_Server_Info *server);
-/* check for STATUS_NETWORK_SESSION_EXPIRED */
-extern bool smb2_is_session_expired(char *);
-/* send oplock break response */
-extern int smb2_oplock_response(struct cifs_tcon *tcon, __u64 persistent_fid, __u64 volatile_fid,
- __u16 net_fid, struct cifsInodeInfo *cifs_inode);
-/* send mandatory brlock to the server */
-extern int smb2_mand_lock(const unsigned int, struct cifsFileInfo *, __u64,
- __u64, __u32, int, int, bool);
-/* unlock range of mandatory locks */
-extern int smb2_unlock_range(struct cifsFileInfo *, struct file_lock *,
- const unsigned int);
-
-/* push brlocks from the cache to the server */
-extern int smb2_push_mandatory_locks(struct cifsFileInfo *);
-/* get lease key of the inode */
-extern void smb2_get_lease_key(struct inode *, struct cifs_fid *);
-/* set lease key of the inode */
-extern void smb2_set_lease_key(struct inode *, struct cifs_fid *);
-/* generate new lease key */
-extern void smb2_new_lease_key(struct cifs_fid *);
-extern int smb3_enum_snapshots(const unsigned int xid, struct cifs_tcon *tcon,
- struct cifsFileInfo *src_file, void __user *);
-extern int smb3_notify(const unsigned int xid, struct file *pfile,
- void __user *pbuf, bool return_changes);
-extern int smb3_query_mf_symlink(unsigned int, struct cifs_tcon *,
- struct cifs_sb_info *, const unsigned char *,
- char *, unsigned int *);
-extern int smb3_create_mf_symlink(unsigned int, struct cifs_tcon *,
- struct cifs_sb_info *, const unsigned char *,
- char *, unsigned int *);
-/* if we can do cache read operations */
-extern bool smb21_is_read_op(__u32);
-extern ssize_t copychunk_range)(const unsigned int,
- struct cifsFileInfo *src_file,
- struct cifsFileInfo *target_file,
- u64 src_off, u64 len, u64 dest_off);
-extern ssize_t smb2_query_eas(const unsigned int, struct cifs_tcon *,
- const unsigned char *, const unsigned char *, char *,
- size_t, struct cifs_sb_info *);
-extern int smb2_set_ea(const unsigned int, struct cifs_tcon *, const char *,
- const char *, const void *, const __u16,
- const struct nls_table *, struct cifs_sb_info *);
-extern struct cifs_ntsd * get_smb2_acl(struct cifs_sb_info *, struct inode *,
- const char *, u32 *, u32);
-extern struct cifs_ntsd * get_smb2_acl_by_fid(struct cifs_sb_info *,
- const struct cifs_fid *, u32 *, u32);
-extern int set_smb2_acl(struct cifs_ntsd *, __u32, struct inode *, const char *,
- int);
- /* writepages retry size */
-extern unsigned int smb2_wp_retry_size(struct inode *);
- /* check if we need to issue closedir */
-extern bool smb2_dir_needs_close(struct cifsFileInfo *);
-extern enum securityEnum smb2_select_sectype(struct TCP_Server_Info *,
- enum securityEnum);
-extern int smb2_next_header(struct TCP_Server_Info *server, char *buf,
- unsigned int *noff);
-/* ioctl passthrough for query_info */
-extern int smb2_ioctl_query_info(const unsigned int xid,
- struct cifs_tcon *tcon,
- struct cifs_sb_info *cifs_sb,
- __le16 *path, int is_dir,
- unsigned long p);
-/* make unix special files (block, char, fifo, socket) */
-extern int smb2_make_node(unsigned int xid,
- struct inode *inode,
- struct dentry *dentry,
- struct cifs_tcon *tcon,
- const char *full_path,
- umode_t mode,
- dev_t device_number);
-/* version specific fiemap implementation */
-extern int smb3_fiemap(struct cifs_tcon *tcon, struct cifsFileInfo *,
- struct fiemap_extent_info *, u64, u64);
-/* version specific llseek implementation */
-extern loff_t smb3_llseek(struct file *, struct cifs_tcon *, loff_t, int);
-
-/* Check for STATUS_IO_TIMEOUT */
-extern bool smb2_is_status_io_timeout(char *buf);
-
-/* Check for STATUS_NETWORK_NAME_DELETED */
-extern bool smb2_is_network_name_deleted(char *buf, struct TCP_Server_Info *srv);
-
-extern int smb2_parse_reparse_point(struct cifs_sb_info *cifs_sb,
- struct kvec *rsp_iov,
- struct cifs_open_info_data *data);
-extern int smb2_create_reparse_symlink(const unsigned int xid,
- struct inode *inode,
- struct dentry *dentry,
- struct cifs_tcon *tcon,
- const char *full_path,
- const char *symname);
-
struct smb_version_operations {
/* find mid corresponding to the response message */
void (*dump_share_caps)(struct seq_file *, struct cifs_tcon *);
@@ -817,12 +599,9 @@ has_credits(struct TCP_Server_Info *server, int *credits, int num_credits)
return num >= num_credits;
}
-static inline void
-add_credits(struct TCP_Server_Info *server, struct cifs_credits *credits,
- const int optype)
-{
- smb2_add_credits(server, credits, optype);
-}
+extern void
+smb2_add_credits(struct TCP_Server_Info *server,
+ struct cifs_credits *credits, const int optype);
static inline void
add_credits_and_wake_if(struct TCP_Server_Info *server,
@@ -835,11 +614,15 @@ add_credits_and_wake_if(struct TCP_Server_Info *server,
}
}
-static inline int
-adjust_credits(struct TCP_Server_Info *server, struct cifs_io_subrequest *subreq,
- unsigned int /* enum smb3_rw_credits_trace */ trace)
+static __u64
+smb2_get_next_mid(struct TCP_Server_Info *server)
{
- return smb2_adjust_credits(server, subreq, trace) : 0;
+ __u64 mid;
+ /* for SMB2 we need the current value */
+ spin_lock(&server->mid_lock);
+ mid = server->CurrentMid++;
+ spin_unlock(&server->mid_lock);
+ return mid;
}
static inline __le64
@@ -859,13 +642,21 @@ get_next_mid(struct TCP_Server_Info *server)
return cpu_to_le16(mid);
}
+static inline void smb2_revert_current_mid(struct TCP_Server_Info *server, const unsigned int val)
+{
+ spin_lock(&server->mid_lock);
+ if (server->CurrentMid >= val)
+ server->CurrentMid -= val;
+ spin_unlock(&server->mid_lock);
+}
+
static inline void
revert_current_mid_from_hdr(struct TCP_Server_Info *server,
const struct smb2_hdr *shdr)
{
unsigned int num = le16_to_cpu(shdr->CreditCharge);
- return smb2_revert_current_mid(server, num > 0 ? num : 1);
+ smb2_revert_current_mid(server, num > 0 ? num : 1);
}
/*
diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c
index 7dc9ea6cceb7..ed6812b888a5 100644
--- a/fs/smb/client/connect.c
+++ b/fs/smb/client/connect.c
@@ -2008,7 +2008,7 @@ void __cifs_put_smb_ses(struct cifs_ses *ses)
cifs_chan_clear_need_reconnect(ses, server);
spin_unlock(&ses->chan_lock);
- do_logoff = ses->ses_status == SES_GOOD && SMB2_logoff;
+ do_logoff = (ses->ses_status == SES_GOOD);
ses->ses_status = SES_EXITING;
tcon = ses->tcon_ipc;
ses->tcon_ipc = NULL;
diff --git a/fs/smb/client/dfs.c b/fs/smb/client/dfs.c
index 4c9d5e0441bf..f4da19617ee2 100644
--- a/fs/smb/client/dfs.c
+++ b/fs/smb/client/dfs.c
@@ -3,6 +3,7 @@
* Copyright (c) 2022 Paulo Alcantara <palcantara@suse.de>
*/
+#include "smb2proto.h"
#include "cifsproto.h"
#include "cifs_debug.h"
#include "dns_resolve.h"
diff --git a/fs/smb/client/dir.c b/fs/smb/client/dir.c
index 01bb87eaf1f2..cd6e4c0a92b7 100644
--- a/fs/smb/client/dir.c
+++ b/fs/smb/client/dir.c
@@ -23,6 +23,7 @@
#include "fs_context.h"
#include "cifs_ioctl.h"
#include "fscache.h"
+#include "smb2proto.h"
static void
renew_parental_timestamps(struct dentry *direntry)
@@ -186,7 +187,6 @@ static int cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned
void *page = alloc_dentry_path();
struct inode *newinode = NULL;
int disposition;
- struct TCP_Server_Info *server = tcon->ses->server;
struct cifs_open_parms oparms;
int rdwr_for_fscache = 0;
@@ -499,10 +499,7 @@ int cifs_mknod(struct mnt_idmap *idmap, struct inode *inode,
trace_smb3_mknod_enter(xid, tcon->ses->Suid, tcon->tid, full_path);
- rc = smb2_make_node(xid, inode, direntry, tcon,
- full_path, mode,
- device_number);
-
+ rc = smb2_make_node(xid, inode, direntry, tcon, full_path, mode, device_number);
mknod_out:
if (rc)
trace_smb3_mknod_err(xid, tcon->ses->Suid, tcon->tid, rc);
diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index 30b3abcfc904..23e75de833bc 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -112,7 +112,7 @@ static void cifs_issue_write(struct netfs_io_subrequest *subreq)
}
wdata->actual_len = wdata->subreq.len;
- rc = adjust_credits(wdata->server, wdata, cifs_trace_rw_credits_issue_write_adjust);
+ rc = smb2_adjust_credits(wdata->server, wdata, cifs_trace_rw_credits_issue_write_adjust);
if (rc)
goto fail;
@@ -465,7 +465,6 @@ static int cifs_nt_open(const char *full_path, struct inode *inode, struct cifs_
int desired_access;
int disposition;
int create_options = CREATE_NOT_DIR;
- struct TCP_Server_Info *server = tcon->ses->server;
struct cifs_open_parms oparms;
int rdwr_for_fscache = 0;
@@ -587,7 +586,6 @@ struct cifsFileInfo *cifs_new_fileinfo(struct cifs_fid *fid, struct file *file,
struct cifsFileInfo *cfile;
struct cifs_fid_locks *fdlocks;
struct cifs_tcon *tcon = tlink_tcon(tlink);
- struct TCP_Server_Info *server = tcon->ses->server;
cfile = kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL);
if (cfile == NULL)
@@ -633,7 +631,7 @@ struct cifsFileInfo *cifs_new_fileinfo(struct cifs_fid *fid, struct file *file,
* If the server returned a read oplock and we have mandatory brlocks,
* set oplock level to None.
*/
- if (server->ops->is_read_op(oplock) && cifs_has_mand_locks(cinode)) {
+ if (smb21_is_read_op(oplock) && cifs_has_mand_locks(cinode)) {
cifs_dbg(FYI, "Reset oplock val from read to None due to mand locks\n");
oplock = 0;
}
@@ -781,7 +779,6 @@ void _cifsFileInfo_put(struct cifsFileInfo *cifs_file,
{
struct inode *inode = d_inode(cifs_file->dentry);
struct cifs_tcon *tcon = tlink_tcon(cifs_file->tlink);
- struct TCP_Server_Info *server = tcon->ses->server;
struct cifsInodeInfo *cifsi = CIFS_I(inode);
struct super_block *sb = inode->i_sb;
struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
@@ -988,7 +985,6 @@ static int
cifs_relock_file(struct cifsFileInfo *cfile)
{
struct cifsInodeInfo *cinode = CIFS_I(d_inode(cfile->dentry));
- struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
int rc = 0;
down_read_nested(&cinode->lock_sem, SINGLE_DEPTH_NESTING);
@@ -998,8 +994,7 @@ cifs_relock_file(struct cifsFileInfo *cfile)
return rc;
}
- rc = smb2_push_mandatory_locks(cfile);
-
+ rc = smb2_push_mandatory_locks(cfile);
up_read(&cinode->lock_sem);
return rc;
}
@@ -1147,7 +1142,7 @@ retry_open:
* If the server returned a read oplock and we have mandatory brlocks,
* set oplock level to None.
*/
- if (server->ops->is_read_op(oplock) && cifs_has_mand_locks(cinode)) {
+ if (smb21_is_read_op(oplock) && cifs_has_mand_locks(cinode)) {
cifs_dbg(FYI, "Reset oplock val from read to None due to mand locks\n");
oplock = 0;
}
@@ -1516,7 +1511,6 @@ static int
cifs_push_locks(struct cifsFileInfo *cfile)
{
struct cifsInodeInfo *cinode = CIFS_I(d_inode(cfile->dentry));
- struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
int rc = 0;
/* we are going to update can_cache_brlcks here - need a write access */
@@ -1659,8 +1653,6 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
int rc = 0;
__u64 length = cifs_flock_len(flock);
struct cifsFileInfo *cfile = (struct cifsFileInfo *)file->private_data;
- struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
- struct TCP_Server_Info *server = tcon->ses->server;
struct inode *inode = d_inode(cfile->dentry);
if (lock) {
@@ -2101,7 +2093,6 @@ int cifs_strict_fsync(struct file *file, loff_t start, loff_t end,
rc = smb2_flush_file(xid, tcon, &smbfile->fid);
}
-strict_fsync_exit:
free_xid(xid);
return rc;
}
@@ -2145,7 +2136,6 @@ int cifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
rc = smb2_flush_file(xid, tcon, &smbfile->fid);
}
-fsync_exit:
free_xid(xid);
return rc;
}
diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
index 8ce5adbb1588..234835e70bb1 100644
--- a/fs/smb/client/inode.c
+++ b/fs/smb/client/inode.c
@@ -546,14 +546,7 @@ static int cifs_sfu_mode(struct cifs_fattr *fattr, const unsigned char *path,
return PTR_ERR(tlink);
tcon = tlink_tcon(tlink);
- if (tcon->ses->server->ops->query_all_EAs == NULL) {
- cifs_put_tlink(tlink);
- return -EOPNOTSUPP;
- }
-
- rc = smb2_query_eas(xid, tcon, path,
- "SETFILEBITS", ea_value, 4 /* size of buf */,
- cifs_sb);
+ rc = smb2_query_eas(xid, tcon, path, "SETFILEBITS", ea_value, 4 /* size of buf */, cifs_sb);
cifs_put_tlink(tlink);
if (rc < 0)
return (int)rc;
@@ -723,16 +716,10 @@ cifs_get_file_info(struct file *filp)
struct inode *inode = file_inode(filp);
struct cifsFileInfo *cfile = filp->private_data;
struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
- struct TCP_Server_Info *server = tcon->ses->server;
struct dentry *dentry = filp->f_path.dentry;
void *page = alloc_dentry_path();
const unsigned char *path;
- if (!server->ops->query_file_info) {
- free_dentry_path(page);
- return -ENOSYS;
- }
-
xid = get_xid();
rc = smb2_query_file_info(xid, tcon, cfile, &data);
switch (rc) {
@@ -802,7 +789,6 @@ static void cifs_set_fattr_ino(int xid, struct cifs_tcon *tcon, struct super_blo
struct cifs_open_info_data *data, struct cifs_fattr *fattr)
{
struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
- struct TCP_Server_Info *server = tcon->ses->server;
int rc;
if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) {
@@ -859,21 +845,18 @@ static int reparse_info_to_fattr(struct cifs_open_info_data *data,
const char *full_path,
struct cifs_fattr *fattr)
{
- struct TCP_Server_Info *server = tcon->ses->server;
struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
struct kvec rsp_iov, *iov = NULL;
int rsp_buftype = CIFS_NO_BUFFER;
u32 tag = data->reparse.tag;
int rc = 0;
- if (!tag && server->ops->query_reparse_point) {
- rc = smb2_query_reparse_point(xid, tcon, cifs_sb,
- full_path, &tag,
- &rsp_iov, &rsp_buftype);
+ if (!tag) {
+ rc = smb2_query_reparse_point(xid, tcon, cifs_sb, full_path, &tag, &rsp_iov,
+ &rsp_buftype);
if (!rc)
iov = &rsp_iov;
- } else if (data->reparse.io.buftype != CIFS_NO_BUFFER &&
- data->reparse.io.iov.iov_base) {
+ } else if (data->reparse.io.buftype != CIFS_NO_BUFFER && data->reparse.io.iov.iov_base) {
iov = &data->reparse.io.iov;
}
@@ -902,12 +885,10 @@ static int reparse_info_to_fattr(struct cifs_open_info_data *data,
goto out;
default:
/* Check for cached reparse point data */
- if (data->symlink_target || data->reparse.buf) {
+ if (data->symlink_target || data->reparse.buf)
rc = 0;
- } else if (iov && server->ops->parse_reparse_point) {
- rc = smb2_parse_reparse_point(cifs_sb,
- iov, data);
- }
+ else if (iov)
+ rc = smb2_parse_reparse_point(cifs_sb, iov, data);
break;
}
@@ -1360,17 +1341,11 @@ cifs_set_file_info(struct inode *inode, struct iattr *attrs, unsigned int xid,
const char *full_path, __u32 dosattr)
{
bool set_time = false;
- struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
- struct TCP_Server_Info *server;
FILE_BASIC_INFO info_buf;
if (attrs == NULL)
return -EINVAL;
- server = cifs_sb_master_tcon(cifs_sb)->ses->server;
- if (!server->ops->set_file_info)
- return -ENOSYS;
-
info_buf.Pad = 0;
if (attrs->ia_valid & ATTR_ATIME) {
@@ -1470,14 +1445,7 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry)
cifs_close_deferred_file_under_dentry(tcon, full_path);
retry_std_delete:
- if (!server->ops->unlink) {
- rc = -ENOSYS;
- goto psx_del_no_retry;
- }
-
rc = smb2_unlink(xid, tcon, full_path, cifs_sb, dentry);
-
-psx_del_no_retry:
if (!rc) {
if (inode) {
cifs_mark_open_handles_for_deleted_file(inode, full_path);
@@ -1572,22 +1540,18 @@ cifs_mkdir_qinfo(struct inode *parent, struct dentry *dentry, umode_t mode,
if (parent->i_mode & S_ISGID)
mode |= S_ISGID;
- {
- struct TCP_Server_Info *server = tcon->ses->server;
- if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) &&
- (mode & S_IWUGO) == 0 && server->ops->mkdir_setinfo)
- smb2_mkdir_setinfo(inode, full_path, cifs_sb,
- tcon, xid);
- if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM)
- inode->i_mode = (mode | S_IFDIR);
-
- if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
- inode->i_uid = current_fsuid();
- if (inode->i_mode & S_ISGID)
- inode->i_gid = parent->i_gid;
- else
- inode->i_gid = current_fsgid();
- }
+ if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) && (mode & S_IWUGO) == 0)
+ smb2_mkdir_setinfo(inode, full_path, cifs_sb, tcon, xid);
+
+ if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM)
+ inode->i_mode = (mode | S_IFDIR);
+
+ if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
+ inode->i_uid = current_fsuid();
+ if (inode->i_mode & S_ISGID)
+ inode->i_gid = parent->i_gid;
+ else
+ inode->i_gid = current_fsgid();
}
d_instantiate(dentry, inode);
return 0;
@@ -1635,12 +1599,6 @@ int cifs_mkdir(struct mnt_idmap *idmap, struct inode *inode,
goto mkdir_out;
}
-
- if (!server->ops->mkdir) {
- rc = -ENOSYS;
- goto mkdir_out;
- }
-
/* BB add setting the equivalent of mode via CreateX w/ACLs */
rc = smb2_mkdir(xid, inode, mode, tcon, full_path, cifs_sb);
if (rc) {
@@ -1700,12 +1658,6 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry)
tcon = tlink_tcon(tlink);
server = tcon->ses->server;
- if (!server->ops->rmdir) {
- rc = -ENOSYS;
- cifs_put_tlink(tlink);
- goto rmdir_exit;
- }
-
if (tcon->nodelete) {
rc = -EACCES;
cifs_put_tlink(tlink);
@@ -1759,12 +1711,8 @@ cifs_do_rename(const unsigned int xid, struct dentry *from_dentry,
tcon = tlink_tcon(tlink);
server = tcon->ses->server;
- if (!server->ops->rename)
- return -ENOSYS;
-
/* try path-based rename first */
- rc = smb2_rename_path(xid, tcon, from_dentry,
- from_path, to_path, cifs_sb);
+ rc = smb2_rename_path(xid, tcon, from_dentry, from_path, to_path, cifs_sb);
/*
* Don't bother with rename by filehandle unless file is busy and
@@ -2156,7 +2104,6 @@ int cifs_fiemap(struct inode *inode, struct fiemap_extent_info *fei, u64 start,
struct cifsInodeInfo *cifs_i = CIFS_I(inode);
struct cifs_sb_info *cifs_sb = CIFS_SB(cifs_i->netfs.inode.i_sb);
struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
- struct TCP_Server_Info *server = tcon->ses->server;
struct cifsFileInfo *cfile;
int rc;
@@ -2180,14 +2127,9 @@ int cifs_fiemap(struct inode *inode, struct fiemap_extent_info *fei, u64 start,
if (cfile == NULL)
return -EINVAL;
- if (server->ops->fiemap) {
- rc = smb3_fiemap(tcon, cfile, fei, start, len);
- cifsFileInfo_put(cfile);
- return rc;
- }
-
+ rc = smb3_fiemap(tcon, cfile, fei, start, len);
cifsFileInfo_put(cfile);
- return -EOPNOTSUPP;
+ return rc;
}
int cifs_truncate_page(struct address_space *mapping, loff_t from)
@@ -2245,11 +2187,7 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs,
if (open_file) {
tcon = tlink_tcon(open_file->tlink);
server = tcon->ses->server;
- if (server->ops->set_file_size)
- rc = smb2_set_file_size(xid, tcon, open_file,
- attrs->ia_size, false);
- else
- rc = -ENOSYS;
+ rc = smb2_set_file_size(xid, tcon, open_file, attrs->ia_size, false);
cifsFileInfo_put(open_file);
cifs_dbg(FYI, "SetFSize for attrs rc = %d\n", rc);
} else
@@ -2271,11 +2209,7 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs,
* valid, writeable file handle for it was found or because there was
* an error setting it by handle.
*/
- if (server->ops->set_path_size)
- rc = smb2_set_path_size(xid, tcon, full_path,
- attrs->ia_size, cifs_sb, false, dentry);
- else
- rc = -ENOSYS;
+ rc = smb2_set_path_size(xid, tcon, full_path, attrs->ia_size, cifs_sb, false, dentry);
cifs_dbg(FYI, "SetEOF by path (setattrs) rc = %d\n", rc);
if (tlink)
@@ -2403,8 +2337,7 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
goto cifs_setattr_exit;
}
}
- } else
- if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID))
+ } else if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID))
attrs->ia_valid &= ~(ATTR_UID | ATTR_GID);
/* skip mode change if it's just for clearing setuid/setgid */
@@ -2430,18 +2363,13 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
*/
if (mode != attrs->ia_mode)
attrs->ia_mode = mode;
- } else
- if (((mode & S_IWUGO) == 0) &&
- (cifsInode->cifsAttrs & ATTR_READONLY) == 0) {
-
+ } else if (((mode & S_IWUGO) == 0) && (cifsInode->cifsAttrs & ATTR_READONLY) == 0) {
dosattr = cifsInode->cifsAttrs | ATTR_READONLY;
/* fix up mode if we're not using dynperm */
if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM) == 0)
attrs->ia_mode = inode->i_mode & ~S_IWUGO;
- } else if ((mode & S_IWUGO) &&
- (cifsInode->cifsAttrs & ATTR_READONLY)) {
-
+ } else if ((mode & S_IWUGO) && (cifsInode->cifsAttrs & ATTR_READONLY)) {
dosattr = cifsInode->cifsAttrs & ~ATTR_READONLY;
/* Attributes of 0 are ignored */
if (dosattr == 0)
@@ -2451,11 +2379,9 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM)) {
attrs->ia_mode