Commit 442a9ffa authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-next' of git://git.samba.org/sfrench/cifs-2.6

Pull CIFS updates from Steve French.

* 'for-next' of git://git.samba.org/sfrench/cifs-2.6: (29 commits)
  cifs: fix oops while traversing open file list (try #4)
  cifs: Fix comment as d_alloc_root() is replaced by d_make_root()
  CIFS: Introduce SMB2 mounts as vers=2.1
  CIFS: Introduce SMB2 Kconfig option
  CIFS: Move add/set_credits and get_credits_field to ops structure
  CIFS: Move protocol specific demultiplex thread calls to ops struct
  CIFS: Move protocol specific part from cifs_readv_receive to ops struct
  CIFS: Move header_size/max_header_size to ops structure
  CIFS: Move protocol specific part from SendReceive2 to ops struct
  cifs: Include backup intent search flags during searches {try #2)
  CIFS: Separate protocol specific part from setlk
  CIFS: Separate protocol specific part from getlk
  CIFS: Separate protocol specific lock type handling
  CIFS: Convert lock type to 32 bit variable
  CIFS: Move locks to cifsFileInfo structure
  cifs: convert send_nt_cancel into a version specific op
  cifs: add a smb_version_operations/values structures and a smb_version enum
  cifs: remove the vers= and version= synonyms for ver=
  cifs: add warning about change in default cache semantics in 3.7
  cifs: display cache= option in /proc/mounts
  ...
parents 4b781474 2c0c2a08
...@@ -158,3 +158,23 @@ config CIFS_NFSD_EXPORT ...@@ -158,3 +158,23 @@ config CIFS_NFSD_EXPORT
depends on CIFS && EXPERIMENTAL && BROKEN depends on CIFS && EXPERIMENTAL && BROKEN
help help
Allows NFS server to export a CIFS mounted share (nfsd over cifs) Allows NFS server to export a CIFS mounted share (nfsd over cifs)
config CIFS_SMB2
bool "SMB2 network file system support (EXPERIMENTAL)"
depends on EXPERIMENTAL && INET && BROKEN
select NLS
select KEYS
select FSCACHE
select DNS_RESOLVER
help
This enables experimental support for the SMB2 (Server Message Block
version 2) protocol. The SMB2 protocol is the successor to the
popular CIFS and SMB network file sharing protocols. SMB2 is the
native file sharing mechanism for recent versions of Windows
operating systems (since Vista). SMB2 enablement will eventually
allow users better performance, security and features, than would be
possible with cifs. Note that smb2 mount options also are simpler
(compared to cifs) due to protocol improvements.
Unless you are a developer or tester, say N.
...@@ -6,7 +6,7 @@ obj-$(CONFIG_CIFS) += cifs.o ...@@ -6,7 +6,7 @@ obj-$(CONFIG_CIFS) += cifs.o
cifs-y := cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o inode.o \ cifs-y := cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o inode.o \
link.o misc.o netmisc.o smbencrypt.o transport.o asn1.o \ link.o misc.o netmisc.o smbencrypt.o transport.o asn1.o \
cifs_unicode.o nterr.o xattr.o cifsencrypt.o \ cifs_unicode.o nterr.o xattr.o cifsencrypt.o \
readdir.o ioctl.o sess.o export.o readdir.o ioctl.o sess.o export.o smb1ops.o
cifs-$(CONFIG_CIFS_ACL) += cifsacl.o cifs-$(CONFIG_CIFS_ACL) += cifsacl.o
...@@ -15,3 +15,5 @@ cifs-$(CONFIG_CIFS_UPCALL) += cifs_spnego.o ...@@ -15,3 +15,5 @@ cifs-$(CONFIG_CIFS_UPCALL) += cifs_spnego.o
cifs-$(CONFIG_CIFS_DFS_UPCALL) += dns_resolve.o cifs_dfs_ref.o cifs-$(CONFIG_CIFS_DFS_UPCALL) += dns_resolve.o cifs_dfs_ref.o
cifs-$(CONFIG_CIFS_FSCACHE) += fscache.o cache.o cifs-$(CONFIG_CIFS_FSCACHE) += fscache.o cache.o
cifs-$(CONFIG_CIFS_SMB2) += smb2ops.o
...@@ -608,11 +608,6 @@ Stats Lists summary resource usage information as well as per ...@@ -608,11 +608,6 @@ Stats Lists summary resource usage information as well as per
in the kernel configuration. in the kernel configuration.
Configuration pseudo-files: Configuration pseudo-files:
MultiuserMount If set to one, more than one CIFS session to
the same server ip address can be established
if more than one uid accesses the same mount
point and if the uids user/password mapping
information is available. (default is 0)
PacketSigningEnabled If set to one, cifs packet signing is enabled PacketSigningEnabled If set to one, cifs packet signing is enabled
and will be used if the server requires and will be used if the server requires
it. If set to two, cifs packet signing is it. If set to two, cifs packet signing is
......
...@@ -57,19 +57,21 @@ cifs_dump_mem(char *label, void *data, int length) ...@@ -57,19 +57,21 @@ cifs_dump_mem(char *label, void *data, int length)
} }
} }
#ifdef CONFIG_CIFS_DEBUG2
void cifs_dump_detail(void *buf) void cifs_dump_detail(void *buf)
{ {
#ifdef CONFIG_CIFS_DEBUG2
struct smb_hdr *smb = (struct smb_hdr *)buf; struct smb_hdr *smb = (struct smb_hdr *)buf;
cERROR(1, "Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d", cERROR(1, "Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d",
smb->Command, smb->Status.CifsError, smb->Command, smb->Status.CifsError,
smb->Flags, smb->Flags2, smb->Mid, smb->Pid); smb->Flags, smb->Flags2, smb->Mid, smb->Pid);
cERROR(1, "smb buf %p len %d", smb, smbCalcSize(smb)); cERROR(1, "smb buf %p len %d", smb, smbCalcSize(smb));
#endif /* CONFIG_CIFS_DEBUG2 */
} }
void cifs_dump_mids(struct TCP_Server_Info *server) void cifs_dump_mids(struct TCP_Server_Info *server)
{ {
#ifdef CONFIG_CIFS_DEBUG2
struct list_head *tmp; struct list_head *tmp;
struct mid_q_entry *mid_entry; struct mid_q_entry *mid_entry;
...@@ -102,8 +104,8 @@ void cifs_dump_mids(struct TCP_Server_Info *server) ...@@ -102,8 +104,8 @@ void cifs_dump_mids(struct TCP_Server_Info *server)
} }
} }
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
}
#endif /* CONFIG_CIFS_DEBUG2 */ #endif /* CONFIG_CIFS_DEBUG2 */
}
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
static int cifs_debug_data_proc_show(struct seq_file *m, void *v) static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
...@@ -420,7 +422,6 @@ static struct proc_dir_entry *proc_fs_cifs; ...@@ -420,7 +422,6 @@ static struct proc_dir_entry *proc_fs_cifs;
static const struct file_operations cifsFYI_proc_fops; static const struct file_operations cifsFYI_proc_fops;
static const struct file_operations cifs_lookup_cache_proc_fops; static const struct file_operations cifs_lookup_cache_proc_fops;
static const struct file_operations traceSMB_proc_fops; static const struct file_operations traceSMB_proc_fops;
static const struct file_operations cifs_multiuser_mount_proc_fops;
static const struct file_operations cifs_security_flags_proc_fops; static const struct file_operations cifs_security_flags_proc_fops;
static const struct file_operations cifs_linux_ext_proc_fops; static const struct file_operations cifs_linux_ext_proc_fops;
...@@ -440,8 +441,6 @@ cifs_proc_init(void) ...@@ -440,8 +441,6 @@ cifs_proc_init(void)
proc_create("traceSMB", 0, proc_fs_cifs, &traceSMB_proc_fops); proc_create("traceSMB", 0, proc_fs_cifs, &traceSMB_proc_fops);
proc_create("LinuxExtensionsEnabled", 0, proc_fs_cifs, proc_create("LinuxExtensionsEnabled", 0, proc_fs_cifs,
&cifs_linux_ext_proc_fops); &cifs_linux_ext_proc_fops);
proc_create("MultiuserMount", 0, proc_fs_cifs,
&cifs_multiuser_mount_proc_fops);
proc_create("SecurityFlags", 0, proc_fs_cifs, proc_create("SecurityFlags", 0, proc_fs_cifs,
&cifs_security_flags_proc_fops); &cifs_security_flags_proc_fops);
proc_create("LookupCacheEnabled", 0, proc_fs_cifs, proc_create("LookupCacheEnabled", 0, proc_fs_cifs,
...@@ -460,7 +459,6 @@ cifs_proc_clean(void) ...@@ -460,7 +459,6 @@ cifs_proc_clean(void)
#ifdef CONFIG_CIFS_STATS #ifdef CONFIG_CIFS_STATS
remove_proc_entry("Stats", proc_fs_cifs); remove_proc_entry("Stats", proc_fs_cifs);
#endif #endif
remove_proc_entry("MultiuserMount", proc_fs_cifs);
remove_proc_entry("SecurityFlags", proc_fs_cifs); remove_proc_entry("SecurityFlags", proc_fs_cifs);
remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs); remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs);
remove_proc_entry("LookupCacheEnabled", proc_fs_cifs); remove_proc_entry("LookupCacheEnabled", proc_fs_cifs);
...@@ -617,52 +615,6 @@ static const struct file_operations traceSMB_proc_fops = { ...@@ -617,52 +615,6 @@ static const struct file_operations traceSMB_proc_fops = {
.write = traceSMB_proc_write, .write = traceSMB_proc_write,
}; };
static int cifs_multiuser_mount_proc_show(struct seq_file *m, void *v)
{
seq_printf(m, "%d\n", multiuser_mount);
return 0;
}
static int cifs_multiuser_mount_proc_open(struct inode *inode, struct file *fh)
{
return single_open(fh, cifs_multiuser_mount_proc_show, NULL);
}
static ssize_t cifs_multiuser_mount_proc_write(struct file *file,
const char __user *buffer, size_t count, loff_t *ppos)
{
char c;
int rc;
static bool warned;
rc = get_user(c, buffer);
if (rc)
return rc;
if (c == '0' || c == 'n' || c == 'N')
multiuser_mount = 0;
else if (c == '1' || c == 'y' || c == 'Y') {
multiuser_mount = 1;
if (!warned) {
warned = true;
printk(KERN_WARNING "CIFS VFS: The legacy multiuser "
"mount code is scheduled to be deprecated in "
"3.5. Please switch to using the multiuser "
"mount option.");
}
}
return count;
}
static const struct file_operations cifs_multiuser_mount_proc_fops = {
.owner = THIS_MODULE,
.open = cifs_multiuser_mount_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.write = cifs_multiuser_mount_proc_write,
};
static int cifs_security_flags_proc_show(struct seq_file *m, void *v) static int cifs_security_flags_proc_show(struct seq_file *m, void *v)
{ {
seq_printf(m, "0x%x\n", global_secflags); seq_printf(m, "0x%x\n", global_secflags);
......
...@@ -24,10 +24,10 @@ ...@@ -24,10 +24,10 @@
#define _H_CIFS_DEBUG #define _H_CIFS_DEBUG
void cifs_dump_mem(char *label, void *data, int length); void cifs_dump_mem(char *label, void *data, int length);
#ifdef CONFIG_CIFS_DEBUG2
#define DBG2 2
void cifs_dump_detail(void *); void cifs_dump_detail(void *);
void cifs_dump_mids(struct TCP_Server_Info *); void cifs_dump_mids(struct TCP_Server_Info *);
#ifdef CONFIG_CIFS_DEBUG2
#define DBG2 2
#else #else
#define DBG2 0 #define DBG2 0
#endif #endif
......
...@@ -56,7 +56,6 @@ int traceSMB = 0; ...@@ -56,7 +56,6 @@ int traceSMB = 0;
bool enable_oplocks = true; bool enable_oplocks = true;
unsigned int linuxExtEnabled = 1; unsigned int linuxExtEnabled = 1;
unsigned int lookupCacheEnabled = 1; unsigned int lookupCacheEnabled = 1;
unsigned int multiuser_mount = 0;
unsigned int global_secflags = CIFSSEC_DEF; unsigned int global_secflags = CIFSSEC_DEF;
/* unsigned int ntlmv2_support = 0; */ /* unsigned int ntlmv2_support = 0; */
unsigned int sign_CIFS_PDUs = 1; unsigned int sign_CIFS_PDUs = 1;
...@@ -125,7 +124,7 @@ cifs_read_super(struct super_block *sb) ...@@ -125,7 +124,7 @@ cifs_read_super(struct super_block *sb)
goto out_no_root; goto out_no_root;
} }
/* do that *after* d_alloc_root() - we want NULL ->d_op for root here */ /* do that *after* d_make_root() - we want NULL ->d_op for root here */
if (cifs_sb_master_tcon(cifs_sb)->nocase) if (cifs_sb_master_tcon(cifs_sb)->nocase)
sb->s_d_op = &cifs_ci_dentry_ops; sb->s_d_op = &cifs_ci_dentry_ops;
else else
...@@ -329,6 +328,19 @@ cifs_show_security(struct seq_file *s, struct TCP_Server_Info *server) ...@@ -329,6 +328,19 @@ cifs_show_security(struct seq_file *s, struct TCP_Server_Info *server)
seq_printf(s, "i"); seq_printf(s, "i");
} }
static void
cifs_show_cache_flavor(struct seq_file *s, struct cifs_sb_info *cifs_sb)
{
seq_printf(s, ",cache=");
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO)
seq_printf(s, "strict");
else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO)
seq_printf(s, "none");
else
seq_printf(s, "loose");
}
/* /*
* cifs_show_options() is for displaying mount options in /proc/mounts. * cifs_show_options() is for displaying mount options in /proc/mounts.
* Not all settable options are displayed but most of the important * Not all settable options are displayed but most of the important
...@@ -342,7 +354,9 @@ cifs_show_options(struct seq_file *s, struct dentry *root) ...@@ -342,7 +354,9 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
struct sockaddr *srcaddr; struct sockaddr *srcaddr;
srcaddr = (struct sockaddr *)&tcon->ses->server->srcaddr; srcaddr = (struct sockaddr *)&tcon->ses->server->srcaddr;
seq_printf(s, ",vers=%s", tcon->ses->server->vals->version_string);
cifs_show_security(s, tcon->ses->server); cifs_show_security(s, tcon->ses->server);
cifs_show_cache_flavor(s, cifs_sb);
seq_printf(s, ",unc=%s", tcon->treeName); seq_printf(s, ",unc=%s", tcon->treeName);
...@@ -408,8 +422,6 @@ cifs_show_options(struct seq_file *s, struct dentry *root) ...@@ -408,8 +422,6 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
seq_printf(s, ",rwpidforward"); seq_printf(s, ",rwpidforward");
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL)
seq_printf(s, ",forcemand"); seq_printf(s, ",forcemand");
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO)
seq_printf(s, ",directio");
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
seq_printf(s, ",nouser_xattr"); seq_printf(s, ",nouser_xattr");
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR)
...@@ -432,8 +444,6 @@ cifs_show_options(struct seq_file *s, struct dentry *root) ...@@ -432,8 +444,6 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
seq_printf(s, ",nostrictsync"); seq_printf(s, ",nostrictsync");
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM)
seq_printf(s, ",noperm"); seq_printf(s, ",noperm");
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO)
seq_printf(s, ",strictcache");
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPUID) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPUID)
seq_printf(s, ",backupuid=%u", cifs_sb->mnt_backupuid); seq_printf(s, ",backupuid=%u", cifs_sb->mnt_backupuid);
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPGID) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPGID)
...@@ -945,7 +955,6 @@ cifs_init_once(void *inode) ...@@ -945,7 +955,6 @@ cifs_init_once(void *inode)
struct cifsInodeInfo *cifsi = inode; struct cifsInodeInfo *cifsi = inode;
inode_init_once(&cifsi->vfs_inode); inode_init_once(&cifsi->vfs_inode);
INIT_LIST_HEAD(&cifsi->llist);
mutex_init(&cifsi->lock_mutex); mutex_init(&cifsi->lock_mutex);
} }
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#define CIFS_MIN_RCV_POOL 4 #define CIFS_MIN_RCV_POOL 4
#define MAX_REOPEN_ATT 5 /* these many maximum attempts to reopen a file */
/* /*
* default attribute cache timeout (jiffies) * default attribute cache timeout (jiffies)
*/ */
...@@ -150,6 +151,57 @@ struct cifs_cred { ...@@ -150,6 +151,57 @@ struct cifs_cred {
***************************************************************** *****************************************************************
*/ */
enum smb_version {
Smb_1 = 1,
Smb_21,
};
struct mid_q_entry;
struct TCP_Server_Info;
struct cifsFileInfo;
struct cifs_ses;
struct smb_version_operations {
int (*send_cancel)(struct TCP_Server_Info *, void *,
struct mid_q_entry *);
bool (*compare_fids)(struct cifsFileInfo *, struct cifsFileInfo *);
/* setup request: allocate mid, sign message */
int (*setup_request)(struct cifs_ses *, struct kvec *, unsigned int,
struct mid_q_entry **);
/* check response: verify signature, map error */
int (*check_receive)(struct mid_q_entry *, struct TCP_Server_Info *,
bool);
void (*add_credits)(struct TCP_Server_Info *, const unsigned int);
void (*set_credits)(struct TCP_Server_Info *, const int);
int * (*get_credits_field)(struct TCP_Server_Info *);
/* data offset from read response message */
unsigned int (*read_data_offset)(char *);
/* data length from read response message */
unsigned int (*read_data_length)(char *);
/* map smb to linux error */
int (*map_error)(char *, bool);
/* find mid corresponding to the response message */
struct mid_q_entry * (*find_mid)(struct TCP_Server_Info *, char *);
void (*dump_detail)(void *);
/* verify the message */
int (*check_message)(char *, unsigned int);
bool (*is_oplock_break)(char *, struct TCP_Server_Info *);
};
struct smb_version_values {
char *version_string;
__u32 large_lock_type;
__u32 exclusive_lock_type;
__u32 shared_lock_type;
__u32 unlock_lock_type;
size_t header_size;
size_t max_header_size;
size_t read_rsp_size;
};
#define HEADER_SIZE(server) (server->vals->header_size)
#define MAX_HEADER_SIZE(server) (server->vals->max_header_size)
struct smb_vol { struct smb_vol {
char *username; char *username;
char *password; char *password;
...@@ -205,6 +257,8 @@ struct smb_vol { ...@@ -205,6 +257,8 @@ struct smb_vol {
bool sockopt_tcp_nodelay:1; bool sockopt_tcp_nodelay:1;
unsigned short int port; unsigned short int port;
unsigned long actimeo; /* attribute cache timeout (jiffies) */ unsigned long actimeo; /* attribute cache timeout (jiffies) */
struct smb_version_operations *ops;
struct smb_version_values *vals;
char *prepath; char *prepath;
struct sockaddr_storage srcaddr; /* allow binding to a local IP */ struct sockaddr_storage srcaddr; /* allow binding to a local IP */
struct nls_table *local_nls; struct nls_table *local_nls;
...@@ -242,6 +296,8 @@ struct TCP_Server_Info { ...@@ -242,6 +296,8 @@ struct TCP_Server_Info {
int srv_count; /* reference counter */ int srv_count; /* reference counter */
/* 15 character server name + 0x20 16th byte indicating type = srv */ /* 15 character server name + 0x20 16th byte indicating type = srv */
char server_RFC1001_name[RFC1001_NAME_LEN_WITH_NULL]; char server_RFC1001_name[RFC1001_NAME_LEN_WITH_NULL];
struct smb_version_operations *ops;
struct smb_version_values *vals;
enum statusEnum tcpStatus; /* what we think the status is */ enum statusEnum tcpStatus; /* what we think the status is */
char *hostname; /* hostname portion of UNC string */ char *hostname; /* hostname portion of UNC string */
struct socket *ssocket; struct socket *ssocket;
...@@ -321,16 +377,6 @@ in_flight(struct TCP_Server_Info *server) ...@@ -321,16 +377,6 @@ in_flight(struct TCP_Server_Info *server)
return num; return num;
} }
static inline int*
get_credits_field(struct TCP_Server_Info *server)
{
/*
* This will change to switch statement when we reserve slots for echos
* and oplock breaks.
*/
return &server->credits;
}
static inline bool static inline bool
has_credits(struct TCP_Server_Info *server, int *credits) has_credits(struct TCP_Server_Info *server, int *credits)
{ {
...@@ -341,16 +387,16 @@ has_credits(struct TCP_Server_Info *server, int *credits) ...@@ -341,16 +387,16 @@ has_credits(struct TCP_Server_Info *server, int *credits)
return num > 0; return num > 0;
} }
static inline size_t static inline void
header_size(void) add_credits(struct TCP_Server_Info *server, const unsigned int add)
{ {
return sizeof(struct smb_hdr); server->ops->add_credits(server, add);
} }
static inline size_t static inline void
max_header_size(void) set_credits(struct TCP_Server_Info *server, const int val)
{ {
return MAX_CIFS_HDR_SIZE; server->ops->set_credits(server, val);
} }
/* /*
...@@ -547,8 +593,7 @@ struct cifsLockInfo { ...@@ -547,8 +593,7 @@ struct cifsLockInfo {
__u64 offset; __u64 offset;
__u64 length; __u64 length;
__u32 pid; __u32 pid;
__u8 type; __u32 type;
__u16 netfid;
}; };
/* /*
...@@ -573,6 +618,10 @@ struct cifs_search_info { ...@@ -573,6 +618,10 @@ struct cifs_search_info {
struct cifsFileInfo { struct cifsFileInfo {
struct list_head tlist; /* pointer to next fid owned by tcon */ struct list_head tlist; /* pointer to next fid owned by tcon */
struct list_head flist; /* next fid (file instance) for this inode */ struct list_head flist; /* next fid (file instance) for this inode */
struct list_head llist; /*
* brlocks held by this fid, protected by
* lock_mutex from cifsInodeInfo structure
*/
unsigned int uid; /* allows finding which FileInfo structure */ unsigned int uid; /* allows finding which FileInfo structure */
__u32 pid; /* process id who opened file */ __u32 pid; /* process id who opened file */
__u16 netfid; /* file id from remote */ __u16 netfid; /* file id from remote */
...@@ -615,9 +664,12 @@ void cifsFileInfo_put(struct cifsFileInfo *cifs_file); ...@@ -615,9 +664,12 @@ void cifsFileInfo_put(struct cifsFileInfo *cifs_file);
*/ */
struct cifsInodeInfo { struct cifsInodeInfo {
struct list_head llist; /* brlocks for this inode */
bool can_cache_brlcks; bool can_cache_brlcks;
struct mutex lock_mutex; /* protect two fields above */ struct mutex lock_mutex; /*
* protect the field above and llist
* from every cifsFileInfo structure
* from openFileList
*/
/* BB add in lists for dirty pages i.e. write caching info for oplock */ /* BB add in lists for dirty pages i.e. write caching info for oplock */
struct list_head openFileList; struct list_head openFileList;
__u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */ __u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */
...@@ -703,7 +755,6 @@ static inline void cifs_stats_bytes_read(struct cifs_tcon *tcon, ...@@ -703,7 +755,6 @@ static inline void cifs_stats_bytes_read(struct cifs_tcon *tcon,
#endif #endif
struct mid_q_entry;
/* /*
* This is the prototype for the mid receive function. This function is for * This is the prototype for the mid receive function. This function is for
...@@ -1042,12 +1093,7 @@ GLOBAL_EXTERN atomic_t smBufAllocCount; ...@@ -1042,12 +1093,7 @@ GLOBAL_EXTERN atomic_t smBufAllocCount;
GLOBAL_EXTERN atomic_t midCount; GLOBAL_EXTERN atomic_t midCount;
/* Misc globals */ /* Misc globals */
GLOBAL_EXTERN unsigned int multiuser_mount; /* if enabled allows new sessions GLOBAL_EXTERN bool enable_oplocks; /* enable or disable oplocks */
to be established on existing mount if we
have the uid/password or Kerberos credential
or equivalent for current user */
/* enable or disable oplocks */
GLOBAL_EXTERN bool enable_oplocks;
GLOBAL_EXTERN unsigned int lookupCacheEnabled; GLOBAL_EXTERN unsigned int lookupCacheEnabled;
GLOBAL_EXTERN unsigned int global_secflags; /* if on, session setup sent GLOBAL_EXTERN unsigned int global_secflags; /* if on, session setup sent
with more secure ntlmssp2 challenge/resp */ with more secure ntlmssp2 challenge/resp */
...@@ -1074,4 +1120,11 @@ void cifs_oplock_break(struct work_struct *work); ...@@ -1074,4 +1120,11 @@ void cifs_oplock_break(struct work_struct *work);
extern const struct slow_work_ops cifs_oplock_break_ops; extern const struct slow_work_ops cifs_oplock_break_ops;
extern struct workqueue_struct *cifsiod_wq; extern struct workqueue_struct *cifsiod_wq;
/* Operations for different SMB versions */
#define SMB1_VERSION_STRING "1.0"
extern struct smb_version_operations smb1_operations;
extern struct smb_version_values smb1_values;
#define SMB21_VERSION_STRING "2.1"
extern struct smb_version_operations smb21_operations;
extern struct smb_version_values smb21_values;
#endif /* _CIFS_GLOB_H */ #endif /* _CIFS_GLOB_H */
...@@ -78,6 +78,8 @@ extern int SendReceive(const unsigned int /* xid */ , struct cifs_ses *, ...@@ -78,6 +78,8 @@ extern int SendReceive(const unsigned int /* xid */ , struct cifs_ses *,
int * /* bytes returned */ , const int long_op); int * /* bytes returned */ , const int long_op);
extern int SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses, extern int SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses,
char *in_buf, int flags); char *in_buf, int flags);
extern int cifs_setup_request(struct cifs_ses *, struct kvec *, unsigned int,
struct mid_q_entry **);
extern int cifs_check_receive(struct mid_q_entry *mid, extern int cifs_check_receive(struct mid_q_entry *mid,
struct TCP_Server_Info *server, bool log_error); struct TCP_Server_Info *server, bool log_error);
extern int SendReceive2(const unsigned int /* xid */ , struct cifs_ses *, extern int SendReceive2(const unsigned int /* xid */ , struct cifs_ses *,
...@@ -88,9 +90,6 @@ extern int SendReceiveBlockingLock(const unsigned int xid, ...@@ -88,9 +90,6 @@ extern int SendReceiveBlockingLock(const unsigned int xid,
struct smb_hdr *in_buf , struct smb_hdr *in_buf ,
struct smb_hdr *out_buf, struct smb_hdr *out_buf,
int *bytes_returned); int *bytes_returned);
extern void cifs_add_credits(struct TCP_Server_Info *server,
const unsigned int add);
extern void cifs_set_credits(struct TCP_Server_Info *server, const int val);
extern int checkSMB(char *buf, unsigned int length); extern int checkSMB(char *buf, unsigned int length);
extern bool is_valid_oplock_break(char *, struct TCP_Server_Info *); extern bool is_valid_oplock_break(char *, struct TCP_Server_Info *);
extern bool backup_cred(struct cifs_sb_info *); extern bool backup_cred(struct cifs_sb_info *);
...@@ -192,11 +191,13 @@ extern int CIFSTCon(unsigned int xid, struct cifs_ses *ses, ...@@ -192,11 +191,13 @@ extern int CIFSTCon(unsigned int xid, struct cifs_ses *ses,
extern int CIFSFindFirst(const int xid, struct cifs_tcon *tcon, extern int CIFSFindFirst(const int xid, struct cifs_tcon *tcon,
const char *searchName, const struct nls_table *nls_codepage, const char *searchName, const struct nls_table *nls_codepage,
__u16 *searchHandle, struct cifs_search_info *psrch_inf, __u16 *searchHandle, __u16 search_flags,
struct cifs_search_info *psrch_inf,
int map, const char dirsep); int map, const char dirsep);
extern int CIFSFindNext(const int xid, struct cifs_tcon *tcon, extern int CIFSFindNext(const int xid, struct cifs_tcon *tcon,
__u16 searchHandle, struct cifs_search_info *psrch_inf); __u16 searchHandle, __u16 search_flags,
struct cifs_search_info *psrch_inf);
extern int CIFSFindClose(const int, struct cifs_tcon *tcon, extern int CIFSFindClose(const int, struct cifs_tcon *tcon,
const __u16 search_handle); const __u16 search_handle);
...@@ -464,6 +465,9 @@ extern int SMBencrypt(unsigned char *passwd, const unsigned char *c8, ...@@ -464,6 +465,9 @@ extern int SMBencrypt(unsigned char *passwd, const unsigned char *c8,
/* asynchronous read support */ /* asynchronous read support */
struct cifs_readdata { struct cifs_readdata {
struct kref refcount;
struct list_head list;
struct completion done;
struct cifsFileInfo *cfile; struct cifsFileInfo *cfile;
struct address_space *mapping; struct address_space *mapping;
__u64 offset; __u64 offset;
...@@ -472,12 +476,13 @@ struct cifs_readdata { ...@@ -472,12 +476,13 @@ struct cifs_readdata {
int result; int result;
struct list_head pages; struct list_head pages;
struct work_struct work; struct work_struct work;
int (*marshal_iov) (struct cifs_readdata *rdata,
unsigned int remaining);
unsigned int nr_iov; unsigned int nr_iov;
struct kvec iov[1]; struct kvec iov[1];
}; };
struct cifs_readdata *cifs_readdata_alloc(unsigned int nr_pages); void cifs_readdata_release(struct kref *refcount);
void cifs_readdata_free(struct cifs_readdata *rdata);
int cifs_async_readv(struct cifs_readdata *rdata); int cifs_async_readv(struct cifs_readdata *rdata);
/* asynchronous write support */ /* asynchronous write support */
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -51,7 +51,15 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg) ...@@ -51,7 +51,15 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
cifs_sb = CIFS_SB(inode->i_sb); cifs_sb = CIFS_SB(inode->i_sb);
switch (command) { switch (command) {
static bool warned = false;
case CIFS_IOC_CHECKUMOUNT: case CIFS_IOC_CHECKUMOUNT:
if (!warned) {
warned = true;
cERROR(1, "the CIFS_IOC_CHECKMOUNT ioctl will "
"be deprecated in 3.7. Please "
"migrate away from the use of "
"umount.cifs");
}
cFYI(1, "User unmount attempted"); cFYI(1, "User unmount attempted");
if (cifs_sb->mnt_uid == current_uid()) if (cifs_sb->mnt_uid == current_uid())
rc = 0; rc = 0;
......
...@@ -306,8 +306,6 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ , ...@@ -306,8 +306,6 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
const struct cifs_tcon *treeCon, int word_count const struct cifs_tcon *treeCon, int word_count
/* length of fixed section (word count) in two byte units */) /* length of fixed section (word count) in two byte units */)
{ {
struct list_head *temp_item;
struct cifs_ses *ses;
char *temp = (char *) buffer; char *temp = (char *) buffer;
memset(temp, 0, 256); /* bigger than MAX_CIFS_HDR_SIZE */ memset(temp, 0, 256); /* bigger than MAX_CIFS_HDR_SIZE */
...@@ -337,51 +335,6 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ , ...@@ -337,51 +335,6 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
/* Uid is not converted */ /* Uid is not converted */
buffer->Uid = treeCon->ses->Suid; buffer->Uid = treeCon->ses->Suid;
buffer->Mid = GetNextMid(treeCon->ses->server); buffer->Mid = GetNextMid(treeCon->ses->server);
if (multiuser_mount != 0) {
/* For the multiuser case, there are few obvious technically */
/* possible mechanisms to match the local linux user (uid) */
/* to a valid remote smb user (smb_uid): */
/* 1) Query Winbind (or other local pam/nss daemon */
/* for userid/password/logon_domain or credential */
/* 2) Query Winbind for uid to sid to username mapping */
/* and see if we have a matching password for existing*/
/* session for that user perhas getting password by */
/* adding a new pam_cifs module that stores passwords */
/* so that the cifs vfs can get at that for all logged*/
/* on users */
/* 3) (Which is the mechanism we have chosen) */
/* Search through sessions to the same server for a */
/* a match on the uid that was passed in on mount */
/* with the current processes uid (or euid?) and use */
/* that smb uid. If no existing smb session for */
/* that uid found, use the default smb session ie */
/* the smb session for the volume mounted which is */
/* the same as would be used if the multiuser mount */
/* flag were disabled. */
/* BB Add support for establishing new tCon and SMB Session */
/* with userid/password pairs found on the smb session */
/* for other target tcp/ip addresses BB */
if (current_fsuid() != treeCon->ses->linux_uid) {
cFYI(1, "Multiuser mode and UID "
"did not match tcon uid");
spin_lock(&cifs_tcp_ses_lock);
list_for_each(temp_item, &treeCon->ses->server->smb_ses_list) {
ses = list_entry(temp_item, struct cifs_ses, smb_ses_list);
if (ses->linux_uid == current_fsuid()) {
if (ses->server == treeCon->ses->server) {
cFYI(1, "found matching uid substitute right smb_uid");
buffer->Uid = ses->Suid;
break;
} else {
/* BB eventually call cifs_setup_session here */
cFYI(1, "local UID found but no smb sess with this server exists");
}
}
}
spin_unlock(&cifs_tcp_ses_lock);
}
}
} }
if (treeCon->Flags & SMB_SHARE_IS_IN_DFS) if (treeCon->Flags & SMB_SHARE_IS_IN_DFS)
buffer->Flags2 |= SMBFLG2_DFS; buffer->Flags2 |= SMBFLG2_DFS;
...@@ -700,22 +653,3 @@ backup_cred(struct cifs_sb_info *cifs_sb) ...@@ -700,22 +653,3 @@ backup_cred(struct cifs_sb_info *cifs_sb)
return false; return false;
} }
void
cifs_add_credits(struct TCP_Server_Info *server, const unsigned int add)
{
spin_lock(&server->req_lock);
server->credits += add;
server->in_flight--;
spin_unlock(&server->req_lock);
wake_up(&server->request_q);
}
void
cifs_set_credits(struct TCP_Server_Info *server, const int val)
{
spin_lock(&server->req_lock);
server->credits = val;
server->oplocks = val > 1 ? enable_oplocks : false;
spin_unlock(&server->req_lock);
}
...@@ -219,6 +219,7 @@ int get_symlink_reparse_path(char *full_path, struct cifs_sb_info *cifs_sb, ...@@ -219,6 +219,7 @@ int get_symlink_reparse_path(char *full_path, struct cifs_sb_info *cifs_sb,
static int initiate_cifs_search(const int xid, struct file *file) static int initiate_cifs_search(const int xid, struct file *file)
{ {
__u16 search_flags;
int rc = 0; int rc = 0;
char *full_path = NULL; char *full_path = NULL;
struct cifsFileInfo *cifsFile; struct cifsFileInfo *cifsFile;
...@@ -270,8 +271,12 @@ static int initiate_cifs_search(const int xid, struct file *file) ...@@ -270,8 +271,12 @@ static int initiate_cifs_search(const int xid, struct file *file)
cifsFile->srch_inf.info_level = SMB_FIND_FILE_DIRECTORY_INFO; cifsFile->srch_inf.info_level = SMB_FIND_FILE_DIRECTORY_INFO;
} }
search_flags = CIFS_SEARCH_CLOSE_AT_END | CIFS_SEARCH_RETURN_RESUME;
if (backup_cred(cifs_sb))
search_flags |= CIFS_SEARCH_BACKUP_SEARCH;
rc = CIFSFindFirst(xid, pTcon, full_path, cifs_sb->local_nls, rc = CIFSFindFirst(xid, pTcon, full_path, cifs_sb->local_nls,
&cifsFile->netfid, &cifsFile->srch_inf, &cifsFile->netfid, search_flags, &cifsFile->srch_inf,
cifs_sb->mnt_cifs_flags & cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR, CIFS_DIR_SEP(cifs_sb)); CIFS_MOUNT_MAP_SPECIAL_CHR, CIFS_DIR_SEP(cifs_sb));
if (rc == 0) if (rc == 0)
...@@ -502,11 +507,13 @@ static int cifs_save_resume_key(const char *current_entry, ...@@ -502,11 +507,13 @@ static int cifs_save_resume_key(const char *current_entry,
static int find_cifs_entry(const int xid, struct cifs_tcon *pTcon, static int find_cifs_entry(const int xid, struct cifs_tcon *pTcon,
struct file *file, char **ppCurrentEntry, int *num_to_ret) struct file *file, char **ppCurrentEntry, int *num_to_ret)
{ {
__u16 search_flags;
int rc = 0; int rc = 0;
int pos_in_buf = 0; int pos_in_buf = 0;
loff_t first_entry_in_buffer; loff_t first_entry_in_buffer;
loff_t index_to_find = file->f_pos; loff_t index_to_find = file->f_pos;
struct cifsFileInfo *cifsFile = file->private_data; struct cifsFileInfo *cifsFile = file->private_data;
struct cifs_sb_info *cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
/* check if index in the buffer */ /* check if index in the buffer */
if ((cifsFile == NULL) || (ppCurrentEntry == NULL) || if ((cifsFile == NULL) || (ppCurrentEntry == NULL) ||
...@@ -560,10 +567,14 @@ static int find_cifs_entry(const int xid, struct cifs_tcon *pTcon, ...@@ -560,10 +567,14 @@ static int find_cifs_entry(const int xid, struct cifs_tcon *pTcon,
cifsFile); cifsFile);
} }
search_flags = CIFS_SEARCH_CLOSE_AT_END | CIFS_SEARCH_RETURN_RESUME;
if (backup_cred(cifs_sb))
search_flags |= CIFS_SEARCH_BACKUP_SEARCH;
while ((index_to_find >= cifsFile->srch_inf.index_of_last_entry) && while ((index_to_find >= cifsFile->srch_inf.index_of_last_entry) &&
(rc == 0) && !cifsFile->srch_inf.endOfSearch) { (rc == 0) && !cifsFile->srch_inf.endOfSearch) {
cFYI(1, "calling findnext2"); cFYI(1, "calling findnext2");
rc = CIFSFindNext(xid, pTcon, cifsFile->netfid, rc = CIFSFindNext(xid, pTcon, cifsFile->netfid, search_flags,
&cifsFile->srch_inf); &cifsFile->srch_inf);
/* FindFirst/Next set last_entry to NULL on malformed reply */ /* FindFirst/Next set last_entry to NULL on malformed reply */
if (cifsFile->srch_inf.last_entry) if (cifsFile->srch_inf.last_entry)
......
/*
* SMB1 (CIFS) version specific operations
*
* Copyright (c) 2012, Jeff Layton <jlayton@redhat.com>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License v2 as published
* by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "cifsglob.h"
#include "cifsproto.h"
#include "cifs_debug.h"
#include "cifspdu.h"
/*
* An NT cancel request header looks just like the original request except:
*
* The Command is SMB_COM_NT_CANCEL
* The WordCount is zeroed out
* The ByteCount is zeroed out
*
* This function mangles an existing request buffer into a
* SMB_COM_NT_CANCEL request and then sends it.
*/
static int
send_nt_cancel(struct TCP_Server_Info *server, void *buf,
struct mid_q_entry *mid)
{
int rc = 0;
struct smb_hdr *in_buf = (struct smb_hdr *)buf;
/* -4 for RFC1001 length and +2 for BCC field */
in_buf->smb_buf_length = cpu_to_be32(sizeof(struct smb_hdr) - 4 + 2);
in_buf->Command = SMB_COM_NT_CANCEL;
in_buf->WordCount = 0;
put_bcc(0, in_buf);
mutex_lock(&server->srv_mutex);
rc = cifs_sign_smb(in_buf, server, &mid->sequence_number);
if (rc) {
mutex_unlock(&server->srv_mutex);
return rc;
}
rc = smb_send(server, in_buf, be32_to_cpu(in_buf->smb_buf_length));
mutex_unlock(&server->srv_mutex);
cFYI(1, "issued NT_CANCEL for mid %u, rc = %d",
in_buf->Mid, rc);
return rc;
}
static bool
cifs_compare_fids(struct cifsFileInfo *ob1, struct cifsFileInfo *ob2)
{
return ob1->netfid == ob2->netfid;
}
static unsigned int
cifs_read_data_offset(char *buf)
{
READ_RSP *rsp = (READ_RSP *)buf;
return le16_to_cpu(rsp->DataOffset);
}
static unsigned int
cifs_read_data_length(char *buf)
{
READ_RSP *rsp = (READ_RSP *)buf;
return (le16_to_cpu(rsp->DataLengthHigh) << 16) +
le16_to_cpu(rsp->DataLength);
}
static struct mid_q_entry *
cifs_find_mid(struct TCP_Server_Info *server, char *buffer)
{
struct smb_hdr *buf = (struct smb_hdr *)buffer;
struct mid_q_entry *mid;
spin_lock(&GlobalMid_Lock);
list_for_each_entry(mid, &server->pending_mid_q, qhead) {
if (mid->mid == buf->Mid &&
mid->mid_state == MID_REQUEST_SUBMITTED &&
le16_to_cpu(mid->command) == buf->Command) {
spin_unlock(&GlobalMid_Lock);
return mid;
}
}
spin_unlock(&GlobalMid_Lock);
return NULL;
}
static void
cifs_add_credits(struct TCP_Server_Info *server, const unsigned int add)
{
spin_lock(&server->req_lock);
server->credits += add;
server->in_flight--;
spin_unlock(&server->req_lock);
wake_up(&server->request_q);
}
static void
cifs_set_credits(struct TCP_Server_Info *server, const int val)
{
spin_lock(&server->req_lock);
server->credits = val;
server->oplocks = val > 1 ? enable_oplocks : false;
spin_unlock(&server->req_lock);
}
static int *
cifs_get_credits_field(struct TCP_Server_Info *server)
{
return &server->credits;
}
struct smb_version_operations smb1_operations = {
.send_cancel = send_nt_cancel,
.compare_fids = cifs_compare_fids,
.setup_request = cifs_setup_request,
.check_receive = cifs_check_receive,
.add_credits = cifs_add_credits,
.set_credits = cifs_set_credits,
.get_credits_field = cifs_get_credits_field,
.read_data_offset = cifs_read_data_offset,
.read_data_length = cifs_read_data_length,
.map_error = map_smb_to_linux_error,
.find_mid = cifs_find_mid,
.check_message = checkSMB,
.dump_detail = cifs_dump_detail,
.is_oplock_break = is_valid_oplock_break,
};
struct smb_version_values smb1_values = {
.version_string = SMB1_VERSION_STRING,
.large_lock_type = LOCKING_ANDX_LARGE_FILES,
.exclusive_lock_type = 0,
.shared_lock_type = LOCKING_ANDX_SHARED_LOCK,
.unlock_lock_type = 0,
.header_size = sizeof(struct smb_hdr),
.max_header_size = MAX_CIFS_HDR_SIZE,
.read_rsp_size = sizeof(READ_RSP),
};
/*
* SMB2 version specific operations
*
* Copyright (c) 2012, Jeff Layton <jlayton@redhat.com>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License v2 as published
* by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "cifsglob.h"
struct smb_version_operations smb21_operations = {
};
struct smb_version_values smb21_values = {
.version_string = SMB21_VERSION_STRING,
};
...@@ -304,7 +304,8 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int optype, ...@@ -304,7 +304,8 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int optype,
static int static int
wait_for_free_request(struct TCP_Server_Info *server, const int optype) wait_for_free_request(struct TCP_Server_Info *server, const int optype)
{ {
return wait_for_free_credits(server, optype, get_credits_field(server)); return wait_for_free_credits(server, optype,
server->ops->get_credits_field(server));
} }
static int allocate_mid(struct cifs_ses *ses, struct smb_hdr *in_buf, static int allocate_mid(struct cifs_ses *ses, struct smb_hdr *in_buf,
...@@ -396,7 +397,7 @@ cifs_call_async(struct TCP_Server_Info *server, struct kvec *iov, ...@@ -396,7 +397,7 @@ cifs_call_async(struct TCP_Server_Info *server, struct kvec *iov,
rc = cifs_setup_async_request(server, iov, nvec, &mid); rc = cifs_setup_async_request(server, iov, nvec, &mid);
if (rc) { if (rc) {
mutex_unlock(&server->srv_mutex); mutex_unlock(&server->srv_mutex);
cifs_add_credits(server, 1); add_credits(server, 1);
wake_up(&server->request_q); wake_up(&server->request_q);
return rc; return rc;
} }
...@@ -418,7 +419,7 @@ cifs_call_async(struct TCP_Server_Info *server, struct kvec *iov, ...@@ -418,7 +419,7 @@ cifs_call_async(struct TCP_Server_Info *server, struct kvec *iov,
return rc; return rc;
out_err: out_err:
delete_mid(mid); delete_mid(mid);
cifs_add_credits(server, 1); add_credits(server, 1);
wake_up(&server->request_q); wake_up(&server->request_q);
return rc; return rc;
} }
...@@ -483,41 +484,11 @@ cifs_sync_mid_result(struct mid_q_entry *mid, struct TCP_Server_Info *server) ...@@ -483,41 +484,11 @@ cifs_sync_mid_result(struct mid_q_entry *mid, struct TCP_Server_Info *server)
return rc; return rc;
} }
/* static inline int
* An NT cancel request header looks just like the original request except: send_cancel(struct TCP_Server_Info *server, void *buf, struct mid_q_entry *mid)
*
* The Command is SMB_COM_NT_CANCEL
* The WordCount is zeroed out
* The ByteCount is zeroed out
*
* This function mangles an existing request buffer into a
* SMB_COM_NT_CANCEL request and then sends it.
*/
static int
send_nt_cancel(struct TCP_Server_Info *server, struct smb_hdr *in_buf,
struct mid_q_entry *mid)
{ {
int rc = 0; return server->ops->send_cancel ?
server->ops->send_cancel(server, buf, mid) : 0;
/* -4 for RFC1001 length and +2 for BCC field */
in_buf->smb_buf_length = cpu_to_be32(sizeof(struct smb_hdr) - 4 + 2);
in_buf->Command = SMB_COM_NT_CANCEL;
in_buf->WordCount = 0;
put_bcc(0, in_buf);
mutex_lock(&server->srv_mutex);
rc = cifs_sign_smb(in_buf, server, &mid->sequence_number);
if (rc) {
mutex_unlock(&server->srv_mutex);
return rc;
}
rc = smb_send(server, in_buf, be32_to_cpu(in_buf->smb_buf_length));
mutex_unlock(&server->srv_mutex);
cFYI(1, "issued NT_CANCEL for mid %u, rc = %d",
in_buf->Mid, rc);
return rc;
} }
int int
...@@ -544,7 +515,7 @@ cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server, ...@@ -544,7 +515,7 @@ cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
return map_smb_to_linux_error(mid->resp_buf, log_error); return map_smb_to_linux_error(mid->resp_buf, log_error);
} }
static int int
cifs_setup_request(struct cifs_ses *ses, struct kvec *iov, cifs_setup_request(struct cifs_ses *ses, struct kvec *iov,
unsigned int nvec, struct mid_q_entry **ret_mid) unsigned int nvec, struct mid_q_entry **ret_mid)
{ {
...@@ -607,12 +578,12 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses, ...@@ -607,12 +578,12 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses,
mutex_lock(&ses->server->srv_mutex); mutex_lock(&ses->server->srv_mutex);
rc = cifs_setup_request(ses, iov, n_vec, &midQ); rc = ses->server->ops->setup_request(ses, iov, n_vec, &midQ);
if (rc) { if (rc) {
mutex_unlock(&ses->server->srv_mutex); mutex_unlock(&ses->server->srv_mutex);
cifs_small_buf_release(buf); cifs_small_buf_release(buf);
/* Update # of requests on wire to server */ /* Update # of requests on wire to server */
cifs_add_credits(ses->server, 1); add_credits(ses->server, 1);
return rc; return rc;
} }
...@@ -636,13 +607,13 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses, ...@@ -636,13 +607,13 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses,
rc = wait_for_response(ses->server, midQ); rc = wait_for_response(ses->server, midQ);
if (rc != 0) { if (rc != 0) {
send_nt_cancel(ses->server, (struct smb_hdr *)buf, midQ); send_cancel(ses->server, buf, midQ);
spin_lock(&GlobalMid_Lock); spin_lock(&GlobalMid_Lock);
if (midQ->mid_state == MID_REQUEST_SUBMITTED) { if (midQ->mid_state == MID_REQUEST_SUBMITTED) {
midQ->callback = DeleteMidQEntry; midQ->callback = DeleteMidQEntry;
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
cifs_small_buf_release(buf); cifs_small_buf_release(buf);
cifs_add_credits(ses->server, 1); add_credits(ses->server, 1);
return rc; return rc;
} }
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
...@@ -652,7 +623,7 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses, ...@@ -652,7 +623,7 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses,
rc = cifs_sync_mid_result(midQ, ses->server); rc = cifs_sync_mid_result(midQ, ses->server);
if (rc != 0) { if (rc != 0) {
cifs_add_credits(ses->server, 1); add_credits(ses->server, 1);
return rc; return rc;
} }
...@@ -670,14 +641,15 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses, ...@@ -670,14 +641,15 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses,
else else
*pRespBufType = CIFS_SMALL_BUFFER; *pRespBufType = CIFS_SMALL_BUFFER;
rc = cifs_check_receive(midQ, ses->server, flags & CIFS_LOG_ERROR); rc = ses->server->ops->check_receive(midQ, ses->server,
flags & CIFS_LOG_ERROR);
/* mark it so buf will not be freed by delete_mid */ /* mark it so buf will not be freed by delete_mid */
if ((flags & CIFS_NO_RESP) == 0) if ((flags & CIFS_NO_RESP) == 0)
midQ->resp_buf = NULL; midQ->resp_buf = NULL;
out: out:
delete_mid(midQ); delete_mid(midQ);
cifs_add_credits(ses->server, 1); add_credits(ses->server, 1);
return rc; return rc;
} }
...@@ -727,7 +699,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, ...@@ -727,7 +699,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
if (rc) { if (rc) {
mutex_unlock(&ses->server->srv_mutex); mutex_unlock(&ses->server->srv_mutex);
/* Update # of requests on wire to server */ /* Update # of requests on wire to server */
cifs_add_credits(ses->server, 1); add_credits(ses->server, 1);
return rc; return rc;
} }
...@@ -753,13 +725,13 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, ...@@ -753,13 +725,13 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
rc = wait_for_response(ses->server, midQ); rc = wait_for_response(ses->server, midQ);
if (rc != 0) { if (rc != 0) {
send_nt_cancel(ses->server, in_buf, midQ); send_cancel(ses->server, in_buf, midQ);
spin_lock(&GlobalMid_Lock); spin_lock(&GlobalMid_Lock);
if (midQ->mid_state == MID_REQUEST_SUBMITTED) { if (midQ->mid_state == MID_REQUEST_SUBMITTED) {
/* no longer considered to be "in-flight" */ /* no longer considered to be "in-flight" */
midQ->callback = DeleteMidQEntry; midQ->callback = DeleteMidQEntry;
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
cifs_add_credits(ses->server, 1); add_credits(ses->server, 1);
return rc; return rc;
} }
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
...@@ -767,7 +739,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, ...@@ -767,7 +739,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
rc = cifs_sync_mid_result(midQ, ses->server); rc = cifs_sync_mid_result(midQ, ses->server);
if (rc != 0) { if (rc != 0) {
cifs_add_credits(ses->server, 1); add_credits(ses->server, 1);
return rc; return rc;
} }
...@@ -783,7 +755,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, ...@@ -783,7 +755,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
rc = cifs_check_receive(midQ, ses->server, 0); rc = cifs_check_receive(midQ, ses->server, 0);
out: out:
delete_mid(midQ); delete_mid(midQ);
cifs_add_credits(ses->server, 1); add_credits(ses->server, 1);
return rc; return rc;
} }
...@@ -898,7 +870,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -898,7 +870,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
if (in_buf->Command == SMB_COM_TRANSACTION2) { if (in_buf->Command == SMB_COM_TRANSACTION2) {
/* POSIX lock. We send a NT_CANCEL SMB to cause the /* POSIX lock. We send a NT_CANCEL SMB to cause the
blocking lock to return. */ blocking lock to return. */
rc = send_nt_cancel(ses->server, in_buf, midQ); rc = send_cancel(ses->server, in_buf, midQ);
if (rc) { if (rc) {
delete_mid(midQ); delete_mid(midQ);
return rc; return rc;
...@@ -919,7 +891,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -919,7 +891,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
rc = wait_for_response(ses->server, midQ); rc = wait_for_response(ses->server, midQ);
if (rc) { if (rc) {
send_nt_cancel(ses->server, in_buf, midQ); send_cancel(ses->server, in_buf, midQ);
spin_lock(&GlobalMid_Lock); spin_lock(&GlobalMid_Lock);
if (midQ->mid_state == MID_REQUEST_SUBMITTED) { if (midQ->mid_state == MID_REQUEST_SUBMITTED) {
/* no longer considered to be "in-flight" */ /* no longer considered to be "in-flight" */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment