Commit 39f15003 authored by Linus Torvalds's avatar Linus Torvalds

Merge git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6:
  [CIFS] Fix memory overwrite when saving nativeFileSystem field during mount
  [CIFS]  Rename compose_mount_options to cifs_compose_mount_options.
  [CIFS] work around bug in Samba server handling for posix open
  [CIFS] Use posix open on file open when server supports it
  cifs: fix buffer format byte on NT Rename/hardlink
  [CIFS] Add definitions for remoteably fsctl calls
  [CIFS] add extra null attr check
  [CIFS] fix build error
  [CIFS] reopen file via newer posix open protocol operation if available
  [CIFS] Add new nostrictsync cifs mount option to avoid slow SMB flush
  [CIFS] DFS no longer experimental
  [CIFS] Send SMB flush in cifs_fsync
parents 7676b8fd b363b330
...@@ -6,7 +6,16 @@ the server to treat subsequent connections, especially those that ...@@ -6,7 +6,16 @@ the server to treat subsequent connections, especially those that
are authenticated as guest, as reconnections, invalidating the earlier are authenticated as guest, as reconnections, invalidating the earlier
user's smb session. This fix allows cifs to mount multiple times to the user's smb session. This fix allows cifs to mount multiple times to the
same server with different userids without risking invalidating earlier same server with different userids without risking invalidating earlier
established security contexts. established security contexts. fsync now sends SMB Flush operation
to better ensure that we wait for server to write all of the data to
server disk (not just write it over the network). Add new mount
parameter to allow user to disable sending the (slow) SMB flush on
fsync if desired (fsync still flushes all cached write data to the server).
Posix file open support added (turned off after one attempt if server
fails to support it properly, as with Samba server versions prior to 3.3.2)
Fix "redzone overwritten" bug in cifs_put_tcon (CIFSTcon may allocate too
little memory for the "nativeFileSystem" field returned by the server
during mount).
Version 1.56 Version 1.56
------------ ------------
......
...@@ -118,6 +118,18 @@ config CIFS_DEBUG2 ...@@ -118,6 +118,18 @@ config CIFS_DEBUG2
option can be turned off unless you are debugging option can be turned off unless you are debugging
cifs problems. If unsure, say N. cifs problems. If unsure, say N.
config CIFS_DFS_UPCALL
bool "DFS feature support"
depends on CIFS && KEYS
help
Distributed File System (DFS) support is used to access shares
transparently in an enterprise name space, even if the share
moves to a different server. This feature also enables
an upcall mechanism for CIFS which contacts userspace helper
utilities to provide server name resolution (host names to
IP addresses) which is needed for implicit mounts of DFS junction
points. If unsure, say N.
config CIFS_EXPERIMENTAL config CIFS_EXPERIMENTAL
bool "CIFS Experimental Features (EXPERIMENTAL)" bool "CIFS Experimental Features (EXPERIMENTAL)"
depends on CIFS && EXPERIMENTAL depends on CIFS && EXPERIMENTAL
...@@ -131,12 +143,3 @@ config CIFS_EXPERIMENTAL ...@@ -131,12 +143,3 @@ config CIFS_EXPERIMENTAL
(which is disabled by default). See the file fs/cifs/README (which is disabled by default). See the file fs/cifs/README
for more details. If unsure, say N. for more details. If unsure, say N.
config CIFS_DFS_UPCALL
bool "DFS feature support (EXPERIMENTAL)"
depends on CIFS_EXPERIMENTAL
depends on KEYS
help
Enables an upcall mechanism for CIFS which contacts userspace
helper utilities to provide server name resolution (host names to
IP addresses) which is needed for implicit mounts of DFS junction
points. If unsure, say N.
...@@ -472,6 +472,19 @@ A partial list of the supported mount options follows: ...@@ -472,6 +472,19 @@ A partial list of the supported mount options follows:
even if the cifs server would support posix advisory locks. even if the cifs server would support posix advisory locks.
"forcemand" is accepted as a shorter form of this mount "forcemand" is accepted as a shorter form of this mount
option. option.
nostrictsync If this mount option is set, when an application does an
fsync call then the cifs client does not send an SMB Flush
to the server (to force the server to write all dirty data
for this file immediately to disk), although cifs still sends
all dirty (cached) file data to the server and waits for the
server to respond to the write. Since SMB Flush can be
very slow, and some servers may be reliable enough (to risk
delaying slightly flushing the data to disk on the server),
turning on this option may be useful to improve performance for
applications that fsync too much, at a small risk of server
crash. If this mount option is not set, by default cifs will
send an SMB flush request (and wait for a response) on every
fsync call.
nodfs Disable DFS (global name space support) even if the nodfs Disable DFS (global name space support) even if the
server claims to support it. This can help work around server claims to support it. This can help work around
a problem with parsing of DFS paths with Samba server a problem with parsing of DFS paths with Samba server
...@@ -692,13 +705,14 @@ require this helper. Note that NTLMv2 security (which does not require the ...@@ -692,13 +705,14 @@ require this helper. Note that NTLMv2 security (which does not require the
cifs.upcall helper program), instead of using Kerberos, is sufficient for cifs.upcall helper program), instead of using Kerberos, is sufficient for
some use cases. some use cases.
Enabling DFS support (used to access shares transparently in an MS-DFS DFS support allows transparent redirection to shares in an MS-DFS name space.
global name space) requires that CONFIG_CIFS_EXPERIMENTAL be enabled. In In addition, DFS support for target shares which are specified as UNC
addition, DFS support for target shares which are specified as UNC
names which begin with host names (rather than IP addresses) requires names which begin with host names (rather than IP addresses) requires
a user space helper (such as cifs.upcall) to be present in order to a user space helper (such as cifs.upcall) to be present in order to
translate host names to ip address, and the user space helper must also translate host names to ip address, and the user space helper must also
be configured in the file /etc/request-key.conf be configured in the file /etc/request-key.conf. Samba, Windows servers and
many NAS appliances support DFS as a way of constructing a global name
space to ease network configuration and improve reliability.
To use cifs Kerberos and DFS support, the Linux keyutils package should be To use cifs Kerberos and DFS support, the Linux keyutils package should be
installed and something like the following lines should be added to the installed and something like the following lines should be added to the
......
...@@ -340,6 +340,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v) ...@@ -340,6 +340,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
seq_printf(m, "\nWrites: %d Bytes: %lld", seq_printf(m, "\nWrites: %d Bytes: %lld",
atomic_read(&tcon->num_writes), atomic_read(&tcon->num_writes),
(long long)(tcon->bytes_written)); (long long)(tcon->bytes_written));
seq_printf(m, "\nFlushes: %d",
atomic_read(&tcon->num_flushes));
seq_printf(m, "\nLocks: %d HardLinks: %d " seq_printf(m, "\nLocks: %d HardLinks: %d "
"Symlinks: %d", "Symlinks: %d",
atomic_read(&tcon->num_locks), atomic_read(&tcon->num_locks),
......
...@@ -104,9 +104,9 @@ static char *cifs_get_share_name(const char *node_name) ...@@ -104,9 +104,9 @@ static char *cifs_get_share_name(const char *node_name)
/** /**
* compose_mount_options - creates mount options for refferral * cifs_compose_mount_options - creates mount options for refferral
* @sb_mountdata: parent/root DFS mount options (template) * @sb_mountdata: parent/root DFS mount options (template)
* @dentry: point where we are going to mount * @fullpath: full path in UNC format
* @ref: server's referral * @ref: server's referral
* @devname: pointer for saving device name * @devname: pointer for saving device name
* *
...@@ -116,8 +116,8 @@ static char *cifs_get_share_name(const char *node_name) ...@@ -116,8 +116,8 @@ static char *cifs_get_share_name(const char *node_name)
* Returns: pointer to new mount options or ERR_PTR. * Returns: pointer to new mount options or ERR_PTR.
* Caller is responcible for freeing retunrned value if it is not error. * Caller is responcible for freeing retunrned value if it is not error.
*/ */
static char *compose_mount_options(const char *sb_mountdata, char *cifs_compose_mount_options(const char *sb_mountdata,
struct dentry *dentry, const char *fullpath,
const struct dfs_info3_param *ref, const struct dfs_info3_param *ref,
char **devname) char **devname)
{ {
...@@ -128,7 +128,6 @@ static char *compose_mount_options(const char *sb_mountdata, ...@@ -128,7 +128,6 @@ static char *compose_mount_options(const char *sb_mountdata,
char *srvIP = NULL; char *srvIP = NULL;
char sep = ','; char sep = ',';
int off, noff; int off, noff;
char *fullpath;
if (sb_mountdata == NULL) if (sb_mountdata == NULL)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
...@@ -202,17 +201,6 @@ static char *compose_mount_options(const char *sb_mountdata, ...@@ -202,17 +201,6 @@ static char *compose_mount_options(const char *sb_mountdata,
goto compose_mount_options_err; goto compose_mount_options_err;
} }
/*
* this function gives us a path with a double backslash prefix. We
* require a single backslash for DFS. Temporarily increment fullpath
* to put it in the proper form and decrement before freeing it.
*/
fullpath = build_path_from_dentry(dentry);
if (!fullpath) {
rc = -ENOMEM;
goto compose_mount_options_err;
}
++fullpath;
tkn_e = strchr(tkn_e + 1, '\\'); tkn_e = strchr(tkn_e + 1, '\\');
if (tkn_e || (strlen(fullpath) - ref->path_consumed)) { if (tkn_e || (strlen(fullpath) - ref->path_consumed)) {
strncat(mountdata, &sep, 1); strncat(mountdata, &sep, 1);
...@@ -221,8 +209,6 @@ static char *compose_mount_options(const char *sb_mountdata, ...@@ -221,8 +209,6 @@ static char *compose_mount_options(const char *sb_mountdata,
strcat(mountdata, tkn_e + 1); strcat(mountdata, tkn_e + 1);
strcat(mountdata, fullpath + ref->path_consumed); strcat(mountdata, fullpath + ref->path_consumed);
} }
--fullpath;
kfree(fullpath);
/*cFYI(1,("%s: parent mountdata: %s", __func__,sb_mountdata));*/ /*cFYI(1,("%s: parent mountdata: %s", __func__,sb_mountdata));*/
/*cFYI(1, ("%s: submount mountdata: %s", __func__, mountdata ));*/ /*cFYI(1, ("%s: submount mountdata: %s", __func__, mountdata ));*/
...@@ -245,10 +231,20 @@ static struct vfsmount *cifs_dfs_do_refmount(const struct vfsmount *mnt_parent, ...@@ -245,10 +231,20 @@ static struct vfsmount *cifs_dfs_do_refmount(const struct vfsmount *mnt_parent,
struct vfsmount *mnt; struct vfsmount *mnt;
char *mountdata; char *mountdata;
char *devname = NULL; char *devname = NULL;
char *fullpath;
cifs_sb = CIFS_SB(dentry->d_inode->i_sb); cifs_sb = CIFS_SB(dentry->d_inode->i_sb);
mountdata = compose_mount_options(cifs_sb->mountdata, /*
dentry, ref, &devname); * this function gives us a path with a double backslash prefix. We
* require a single backslash for DFS.
*/
fullpath = build_path_from_dentry(dentry);
if (!fullpath)
return ERR_PTR(-ENOMEM);
mountdata = cifs_compose_mount_options(cifs_sb->mountdata,
fullpath + 1, ref, &devname);
kfree(fullpath);
if (IS_ERR(mountdata)) if (IS_ERR(mountdata))
return (struct vfsmount *)mountdata; return (struct vfsmount *)mountdata;
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#define CIFS_MOUNT_OVERR_GID 0x800 /* override gid returned from server */ #define CIFS_MOUNT_OVERR_GID 0x800 /* override gid returned from server */
#define CIFS_MOUNT_DYNPERM 0x1000 /* allow in-memory only mode setting */ #define CIFS_MOUNT_DYNPERM 0x1000 /* allow in-memory only mode setting */
#define CIFS_MOUNT_NOPOSIXBRL 0x2000 /* mandatory not posix byte range lock */ #define CIFS_MOUNT_NOPOSIXBRL 0x2000 /* mandatory not posix byte range lock */
#define CIFS_MOUNT_NOSSYNC 0x4000 /* don't do slow SMBflush on every sync*/
struct cifs_sb_info { struct cifs_sb_info {
struct cifsTconInfo *tcon; /* primary mount */ struct cifsTconInfo *tcon; /* primary mount */
......
...@@ -254,6 +254,7 @@ struct cifsTconInfo { ...@@ -254,6 +254,7 @@ struct cifsTconInfo {
atomic_t num_smbs_sent; atomic_t num_smbs_sent;
atomic_t num_writes; atomic_t num_writes;
atomic_t num_reads; atomic_t num_reads;
atomic_t num_flushes;
atomic_t num_oplock_brks; atomic_t num_oplock_brks;
atomic_t num_opens; atomic_t num_opens;
atomic_t num_closes; atomic_t num_closes;
...@@ -298,6 +299,7 @@ struct cifsTconInfo { ...@@ -298,6 +299,7 @@ struct cifsTconInfo {
bool unix_ext:1; /* if false disable Linux extensions to CIFS protocol bool unix_ext:1; /* if false disable Linux extensions to CIFS protocol
for this mount even if server would support */ for this mount even if server would support */
bool local_lease:1; /* check leases (only) on local system not remote */ bool local_lease:1; /* check leases (only) on local system not remote */
bool broken_posix_open; /* e.g. Samba server versions < 3.3.2, 3.2.9 */
bool need_reconnect:1; /* connection reset, tid now invalid */ bool need_reconnect:1; /* connection reset, tid now invalid */
/* BB add field for back pointer to sb struct(s)? */ /* BB add field for back pointer to sb struct(s)? */
}; };
......
/* /*
* fs/cifs/cifspdu.h * fs/cifs/cifspdu.h
* *
* Copyright (c) International Business Machines Corp., 2002,2008 * Copyright (c) International Business Machines Corp., 2002,2009
* Author(s): Steve French (sfrench@us.ibm.com) * Author(s): Steve French (sfrench@us.ibm.com)
* *
* This library is free software; you can redistribute it and/or modify * This library is free software; you can redistribute it and/or modify
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#define _CIFSPDU_H #define _CIFSPDU_H
#include <net/sock.h> #include <net/sock.h>
#include "smbfsctl.h"
#ifdef CONFIG_CIFS_WEAK_PW_HASH #ifdef CONFIG_CIFS_WEAK_PW_HASH
#define LANMAN_PROT 0 #define LANMAN_PROT 0
...@@ -34,15 +35,15 @@ ...@@ -34,15 +35,15 @@
#define POSIX_PROT (CIFS_PROT+1) #define POSIX_PROT (CIFS_PROT+1)
#define BAD_PROT 0xFFFF #define BAD_PROT 0xFFFF
/* SMB command codes */ /* SMB command codes:
/* * Note some commands have minimal (wct=0,bcc=0), or uninteresting, responses
* Some commands have minimal (wct=0,bcc=0), or uninteresting, responses
* (ie which include no useful data other than the SMB error code itself). * (ie which include no useful data other than the SMB error code itself).
* Knowing this helps avoid response buffer allocations and copy in some cases * This can allow us to avoid response buffer allocations and copy in some cases
*/ */
#define SMB_COM_CREATE_DIRECTORY 0x00 /* trivial response */ #define SMB_COM_CREATE_DIRECTORY 0x00 /* trivial response */
#define SMB_COM_DELETE_DIRECTORY 0x01 /* trivial response */ #define SMB_COM_DELETE_DIRECTORY 0x01 /* trivial response */
#define SMB_COM_CLOSE 0x04 /* triv req/rsp, timestamp ignored */ #define SMB_COM_CLOSE 0x04 /* triv req/rsp, timestamp ignored */
#define SMB_COM_FLUSH 0x05 /* triv req/rsp */
#define SMB_COM_DELETE 0x06 /* trivial response */ #define SMB_COM_DELETE 0x06 /* trivial response */
#define SMB_COM_RENAME 0x07 /* trivial response */ #define SMB_COM_RENAME 0x07 /* trivial response */
#define SMB_COM_QUERY_INFORMATION 0x08 /* aka getattr */ #define SMB_COM_QUERY_INFORMATION 0x08 /* aka getattr */
...@@ -790,6 +791,12 @@ typedef struct smb_com_close_rsp { ...@@ -790,6 +791,12 @@ typedef struct smb_com_close_rsp {
__u16 ByteCount; /* bct = 0 */ __u16 ByteCount; /* bct = 0 */
} __attribute__((packed)) CLOSE_RSP; } __attribute__((packed)) CLOSE_RSP;
typedef struct smb_com_flush_req {
struct smb_hdr hdr; /* wct = 1 */
__u16 FileID;
__u16 ByteCount; /* 0 */
} __attribute__((packed)) FLUSH_REQ;
typedef struct smb_com_findclose_req { typedef struct smb_com_findclose_req {
struct smb_hdr hdr; /* wct = 1 */ struct smb_hdr hdr; /* wct = 1 */
__u16 FileID; __u16 FileID;
...@@ -1924,19 +1931,19 @@ typedef struct smb_com_transaction2_get_dfs_refer_req { ...@@ -1924,19 +1931,19 @@ typedef struct smb_com_transaction2_get_dfs_refer_req {
#define DFS_TYPE_ROOT 0x0001 #define DFS_TYPE_ROOT 0x0001
/* Referral Entry Flags */ /* Referral Entry Flags */
#define DFS_NAME_LIST_REF 0x0200 #define DFS_NAME_LIST_REF 0x0200 /* set for domain or DC referral responses */
#define DFS_TARGET_SET_BOUNDARY 0x0400 /* only valid with version 4 dfs req */
typedef struct dfs_referral_level_3 { typedef struct dfs_referral_level_3 { /* version 4 is same, + one flag bit */
__le16 VersionNumber; __le16 VersionNumber; /* must be 3 or 4 */
__le16 Size; __le16 Size;
__le16 ServerType; /* 0x0001 = root targets; 0x0000 = link targets */ __le16 ServerType; /* 0x0001 = root targets; 0x0000 = link targets */
__le16 ReferralEntryFlags; /* 0x0200 bit set only for domain __le16 ReferralEntryFlags;
or DC referral responce */
__le32 TimeToLive; __le32 TimeToLive;
__le16 DfsPathOffset; __le16 DfsPathOffset;
__le16 DfsAlternatePathOffset; __le16 DfsAlternatePathOffset;
__le16 NetworkAddressOffset; /* offset of the link target */ __le16 NetworkAddressOffset; /* offset of the link target */
__le16 ServiceSiteGuid; __u8 ServiceSiteGuid[16]; /* MBZ, ignored */
} __attribute__((packed)) REFERRAL3; } __attribute__((packed)) REFERRAL3;
typedef struct smb_com_transaction_get_dfs_refer_rsp { typedef struct smb_com_transaction_get_dfs_refer_rsp {
...@@ -1946,48 +1953,15 @@ typedef struct smb_com_transaction_get_dfs_refer_rsp { ...@@ -1946,48 +1953,15 @@ typedef struct smb_com_transaction_get_dfs_refer_rsp {
__u8 Pad; __u8 Pad;
__le16 PathConsumed; __le16 PathConsumed;
__le16 NumberOfReferrals; __le16 NumberOfReferrals;
__le16 DFSFlags; __le32 DFSFlags;
__u16 Pad2;
REFERRAL3 referrals[1]; /* array of level 3 dfs_referral structures */ REFERRAL3 referrals[1]; /* array of level 3 dfs_referral structures */
/* followed by the strings pointed to by the referral structures */ /* followed by the strings pointed to by the referral structures */
} __attribute__((packed)) TRANSACTION2_GET_DFS_REFER_RSP; } __attribute__((packed)) TRANSACTION2_GET_DFS_REFER_RSP;
/* DFS Flags */ /* DFS Flags */
#define DFSREF_REFERRAL_SERVER 0x0001 #define DFSREF_REFERRAL_SERVER 0x00000001 /* all targets are DFS roots */
#define DFSREF_STORAGE_SERVER 0x0002 #define DFSREF_STORAGE_SERVER 0x00000002 /* no further ref requests needed */
#define DFSREF_TARGET_FAILBACK 0x00000004 /* only for DFS referral version 4 */
/* IOCTL information */
/*
* List of ioctl function codes that look to be of interest to remote clients
* like this one. Need to do some experimentation to make sure they all work
* remotely. Some of the following, such as the encryption/compression ones
* would be invoked from tools via a specialized hook into the VFS rather
* than via the standard vfs entry points
*/
#define FSCTL_REQUEST_OPLOCK_LEVEL_1 0x00090000
#define FSCTL_REQUEST_OPLOCK_LEVEL_2 0x00090004
#define FSCTL_REQUEST_BATCH_OPLOCK 0x00090008
#define FSCTL_LOCK_VOLUME 0x00090018
#define FSCTL_UNLOCK_VOLUME 0x0009001C
#define FSCTL_GET_COMPRESSION 0x0009003C
#define FSCTL_SET_COMPRESSION 0x0009C040
#define FSCTL_REQUEST_FILTER_OPLOCK 0x0009008C
#define FSCTL_FILESYS_GET_STATISTICS 0x00090090
#define FSCTL_SET_REPARSE_POINT 0x000900A4
#define FSCTL_GET_REPARSE_POINT 0x000900A8
#define FSCTL_DELETE_REPARSE_POINT 0x000900AC
#define FSCTL_SET_SPARSE 0x000900C4
#define FSCTL_SET_ZERO_DATA 0x000900C8
#define FSCTL_SET_ENCRYPTION 0x000900D7
#define FSCTL_ENCRYPTION_FSCTL_IO 0x000900DB
#define FSCTL_WRITE_RAW_ENCRYPTED 0x000900DF
#define FSCTL_READ_RAW_ENCRYPTED 0x000900E3
#define FSCTL_SIS_COPYFILE 0x00090100
#define FSCTL_SIS_LINK_FILES 0x0009C104
#define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003
#define IO_REPARSE_TAG_HSM 0xC0000004
#define IO_REPARSE_TAG_SIS 0x80000007
/* /*
************************************************************************ ************************************************************************
...@@ -2508,8 +2482,6 @@ struct data_blob { ...@@ -2508,8 +2482,6 @@ struct data_blob {
6) Use nanosecond timestamps throughout all time fields if 6) Use nanosecond timestamps throughout all time fields if
corresponding attribute flag is set corresponding attribute flag is set
7) sendfile - handle based copy 7) sendfile - handle based copy
8) Direct i/o
9) Misc fcntls?
what about fixing 64 bit alignment what about fixing 64 bit alignment
...@@ -2628,7 +2600,5 @@ typedef struct file_chattr_info { ...@@ -2628,7 +2600,5 @@ typedef struct file_chattr_info {
__le64 mode; /* list of actual attribute bits on this inode */ __le64 mode; /* list of actual attribute bits on this inode */
} __attribute__((packed)) FILE_CHATTR_INFO; /* ext attributes } __attribute__((packed)) FILE_CHATTR_INFO; /* ext attributes
(chattr, chflags) level 0x206 */ (chattr, chflags) level 0x206 */
#endif /* POSIX */
#endif
#endif /* _CIFSPDU_H */ #endif /* _CIFSPDU_H */
...@@ -44,6 +44,9 @@ extern void _FreeXid(unsigned int); ...@@ -44,6 +44,9 @@ extern void _FreeXid(unsigned int);
extern char *build_path_from_dentry(struct dentry *); extern char *build_path_from_dentry(struct dentry *);
extern char *cifs_build_path_to_root(struct cifs_sb_info *cifs_sb); extern char *cifs_build_path_to_root(struct cifs_sb_info *cifs_sb);
extern char *build_wildcard_path_from_dentry(struct dentry *direntry); extern char *build_wildcard_path_from_dentry(struct dentry *direntry);
extern char *cifs_compose_mount_options(const char *sb_mountdata,
const char *fullpath, const struct dfs_info3_param *ref,
char **devname);
/* extern void renew_parental_timestamps(struct dentry *direntry);*/ /* extern void renew_parental_timestamps(struct dentry *direntry);*/
extern int SendReceive(const unsigned int /* xid */ , struct cifsSesInfo *, extern int SendReceive(const unsigned int /* xid */ , struct cifsSesInfo *,
struct smb_hdr * /* input */ , struct smb_hdr * /* input */ ,
...@@ -92,6 +95,9 @@ extern u64 cifs_UnixTimeToNT(struct timespec); ...@@ -92,6 +95,9 @@ extern u64 cifs_UnixTimeToNT(struct timespec);
extern __le64 cnvrtDosCifsTm(__u16 date, __u16 time); extern __le64 cnvrtDosCifsTm(__u16 date, __u16 time);
extern struct timespec cnvrtDosUnixTm(__u16 date, __u16 time); extern struct timespec cnvrtDosUnixTm(__u16 date, __u16 time);
extern int cifs_posix_open(char *full_path, struct inode **pinode,
struct super_block *sb, int mode, int oflags,
int *poplock, __u16 *pnetfid, int xid);
extern void posix_fill_in_inode(struct inode *tmp_inode, extern void posix_fill_in_inode(struct inode *tmp_inode,
FILE_UNIX_BASIC_INFO *pData, int isNewInode); FILE_UNIX_BASIC_INFO *pData, int isNewInode);
extern struct inode *cifs_new_inode(struct super_block *sb, __u64 *inum); extern struct inode *cifs_new_inode(struct super_block *sb, __u64 *inum);
...@@ -281,6 +287,9 @@ extern int CIFSPOSIXCreate(const int xid, struct cifsTconInfo *tcon, ...@@ -281,6 +287,9 @@ extern int CIFSPOSIXCreate(const int xid, struct cifsTconInfo *tcon,
extern int CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, extern int CIFSSMBClose(const int xid, struct cifsTconInfo *tcon,
const int smb_file_id); const int smb_file_id);
extern int CIFSSMBFlush(const int xid, struct cifsTconInfo *tcon,
const int smb_file_id);
extern int CIFSSMBRead(const int xid, struct cifsTconInfo *tcon, extern int CIFSSMBRead(const int xid, struct cifsTconInfo *tcon,
const int netfid, unsigned int count, const int netfid, unsigned int count,
const __u64 lseek, unsigned int *nbytes, char **buf, const __u64 lseek, unsigned int *nbytes, char **buf,
......
...@@ -1933,6 +1933,27 @@ CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, int smb_file_id) ...@@ -1933,6 +1933,27 @@ CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, int smb_file_id)
return rc; return rc;
} }
int
CIFSSMBFlush(const int xid, struct cifsTconInfo *tcon, int smb_file_id)
{
int rc = 0;
FLUSH_REQ *pSMB = NULL;
cFYI(1, ("In CIFSSMBFlush"));
rc = small_smb_init(SMB_COM_FLUSH, 1, tcon, (void **) &pSMB);
if (rc)
return rc;
pSMB->FileID = (__u16) smb_file_id;
pSMB->ByteCount = 0;
rc = SendReceiveNoRsp(xid, tcon->ses, (struct smb_hdr *) pSMB, 0);
cifs_stats_inc(&tcon->num_flushes);
if (rc)
cERROR(1, ("Send error in Flush = %d", rc));
return rc;
}
int int
CIFSSMBRename(const int xid, struct cifsTconInfo *tcon, CIFSSMBRename(const int xid, struct cifsTconInfo *tcon,
const char *fromName, const char *toName, const char *fromName, const char *toName,
...@@ -2356,8 +2377,10 @@ CIFSCreateHardLink(const int xid, struct cifsTconInfo *tcon, ...@@ -2356,8 +2377,10 @@ CIFSCreateHardLink(const int xid, struct cifsTconInfo *tcon,
PATH_MAX, nls_codepage, remap); PATH_MAX, nls_codepage, remap);
name_len++; /* trailing null */ name_len++; /* trailing null */
name_len *= 2; name_len *= 2;
pSMB->OldFileName[name_len] = 0; /* pad */
pSMB->OldFileName[name_len + 1] = 0x04; /* protocol specifies ASCII buffer format (0x04) for unicode */
pSMB->OldFileName[name_len] = 0x04;
pSMB->OldFileName[name_len + 1] = 0x00; /* pad */
name_len2 = name_len2 =
cifsConvertToUCS((__le16 *)&pSMB->OldFileName[name_len + 2], cifsConvertToUCS((__le16 *)&pSMB->OldFileName[name_len + 2],
toName, PATH_MAX, nls_codepage, remap); toName, PATH_MAX, nls_codepage, remap);
......
...@@ -95,6 +95,7 @@ struct smb_vol { ...@@ -95,6 +95,7 @@ struct smb_vol {
bool local_lease:1; /* check leases only on local system, not remote */ bool local_lease:1; /* check leases only on local system, not remote */
bool noblocksnd:1; bool noblocksnd:1;
bool noautotune:1; bool noautotune:1;
bool nostrictsync:1; /* do not force expensive SMBflush on every sync */
unsigned int rsize; unsigned int rsize;
unsigned int wsize; unsigned int wsize;
unsigned int sockopt; unsigned int sockopt;
...@@ -1274,6 +1275,10 @@ cifs_parse_mount_options(char *options, const char *devname, ...@@ -1274,6 +1275,10 @@ cifs_parse_mount_options(char *options, const char *devname,
vol->intr = 0; vol->intr = 0;
} else if (strnicmp(data, "intr", 4) == 0) { } else if (strnicmp(data, "intr", 4) == 0) {
vol->intr = 1; vol->intr = 1;
} else if (strnicmp(data, "nostrictsync", 12) == 0) {
vol->nostrictsync = 1;
} else if (strnicmp(data, "strictsync", 10) == 0) {
vol->nostrictsync = 0;
} else if (strnicmp(data, "serverino", 7) == 0) { } else if (strnicmp(data, "serverino", 7) == 0) {
vol->server_ino = 1; vol->server_ino = 1;
} else if (strnicmp(data, "noserverino", 9) == 0) { } else if (strnicmp(data, "noserverino", 9) == 0) {
...@@ -2160,6 +2165,8 @@ static void setup_cifs_sb(struct smb_vol *pvolume_info, ...@@ -2160,6 +2165,8 @@ static void setup_cifs_sb(struct smb_vol *pvolume_info,
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_UNX_EMUL; cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_UNX_EMUL;
if (pvolume_info->nobrl) if (pvolume_info->nobrl)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_BRL; cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_BRL;
if (pvolume_info->nostrictsync)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NOSSYNC;
if (pvolume_info->mand_lock) if (pvolume_info->mand_lock)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NOPOSIXBRL; cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NOPOSIXBRL;
if (pvolume_info->cifs_acl) if (pvolume_info->cifs_acl)
...@@ -3667,7 +3674,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, ...@@ -3667,7 +3674,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
BCC(smb_buffer_response)) { BCC(smb_buffer_response)) {
kfree(tcon->nativeFileSystem); kfree(tcon->nativeFileSystem);
tcon->nativeFileSystem = tcon->nativeFileSystem =
kzalloc(length + 2, GFP_KERNEL); kzalloc(2*(length + 1), GFP_KERNEL);
if (tcon->nativeFileSystem) if (tcon->nativeFileSystem)
cifs_strfromUCS_le( cifs_strfromUCS_le(
tcon->nativeFileSystem, tcon->nativeFileSystem,
......
...@@ -129,7 +129,7 @@ build_path_from_dentry(struct dentry *direntry) ...@@ -129,7 +129,7 @@ build_path_from_dentry(struct dentry *direntry)
return full_path; return full_path;
} }
static int cifs_posix_open(char *full_path, struct inode **pinode, int cifs_posix_open(char *full_path, struct inode **pinode,
struct super_block *sb, int mode, int oflags, struct super_block *sb, int mode, int oflags,
int *poplock, __u16 *pnetfid, int xid) int *poplock, __u16 *pnetfid, int xid)
{ {
...@@ -187,7 +187,9 @@ static int cifs_posix_open(char *full_path, struct inode **pinode, ...@@ -187,7 +187,9 @@ static int cifs_posix_open(char *full_path, struct inode **pinode,
if (!pinode) if (!pinode)
goto posix_open_ret; /* caller does not need info */ goto posix_open_ret; /* caller does not need info */
if (*pinode == NULL)
*pinode = cifs_new_inode(sb, &presp_data->UniqueId); *pinode = cifs_new_inode(sb, &presp_data->UniqueId);
/* else an inode was passed in. Update its info, don't create one */
/* We do not need to close the file if new_inode fails since /* We do not need to close the file if new_inode fails since
the caller will retry qpathinfo as long as inode is null */ the caller will retry qpathinfo as long as inode is null */
......
This diff is collapsed.
...@@ -763,6 +763,9 @@ cifs_set_file_info(struct inode *inode, struct iattr *attrs, int xid, ...@@ -763,6 +763,9 @@ cifs_set_file_info(struct inode *inode, struct iattr *attrs, int xid,
struct cifsTconInfo *pTcon = cifs_sb->tcon; struct cifsTconInfo *pTcon = cifs_sb->tcon;
FILE_BASIC_INFO info_buf; FILE_BASIC_INFO info_buf;
if (attrs == NULL)
return -EINVAL;
if (attrs->ia_valid & ATTR_ATIME) { if (attrs->ia_valid & ATTR_ATIME) {
set_time = true; set_time = true;
info_buf.LastAccessTime = info_buf.LastAccessTime =
......
/*
* fs/cifs/smbfsctl.h: SMB, CIFS, SMB2 FSCTL definitions
*
* Copyright (c) International Business Machines Corp., 2002,2009
* Author(s): Steve French (sfrench@us.ibm.com)
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* 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
*/
/* IOCTL information */
/*
* List of ioctl/fsctl function codes that are or could be useful in the
* future to remote clients like cifs or SMB2 client. There is probably
* a slightly larger set of fsctls that NTFS local filesystem could handle,
* including the seven below that we do not have struct definitions for.
* Even with protocol definitions for most of these now available, we still
* need to do some experimentation to identify which are practical to do
* remotely. Some of the following, such as the encryption/compression ones
* could be invoked from tools via a specialized hook into the VFS rather
* than via the standard vfs entry points
*/
#define FSCTL_REQUEST_OPLOCK_LEVEL_1 0x00090000
#define FSCTL_REQUEST_OPLOCK_LEVEL_2 0x00090004
#define FSCTL_REQUEST_BATCH_OPLOCK 0x00090008
#define FSCTL_LOCK_VOLUME 0x00090018
#define FSCTL_UNLOCK_VOLUME 0x0009001C
#define FSCTL_IS_PATHNAME_VALID 0x0009002C /* BB add struct */
#define FSCTL_GET_COMPRESSION 0x0009003C /* BB add struct */
#define FSCTL_SET_COMPRESSION 0x0009C040 /* BB add struct */
#define FSCTL_QUERY_FAT_BPB 0x00090058 /* BB add struct */
/* Verify the next FSCTL number, we had it as 0x00090090 before */
#define FSCTL_FILESYSTEM_GET_STATS 0x00090060 /* BB add struct */
#define FSCTL_GET_NTFS_VOLUME_DATA 0x00090064 /* BB add struct */
#define FSCTL_GET_RETRIEVAL_POINTERS 0x00090073 /* BB add struct */
#define FSCTL_IS_VOLUME_DIRTY 0x00090078 /* BB add struct */
#define FSCTL_ALLOW_EXTENDED_DASD_IO 0x00090083 /* BB add struct */
#define FSCTL_REQUEST_FILTER_OPLOCK 0x0009008C
#define FSCTL_FIND_FILES_BY_SID 0x0009008F /* BB add struct */
#define FSCTL_SET_OBJECT_ID 0x00090098 /* BB add struct */
#define FSCTL_GET_OBJECT_ID 0x0009009C /* BB add struct */
#define FSCTL_DELETE_OBJECT_ID 0x000900A0 /* BB add struct */
#define FSCTL_SET_REPARSE_POINT 0x000900A4 /* BB add struct */
#define FSCTL_GET_REPARSE_POINT 0x000900A8 /* BB add struct */
#define FSCTL_DELETE_REPARSE_POINT 0x000900AC /* BB add struct */
#define FSCTL_SET_OBJECT_ID_EXTENDED 0x000900BC /* BB add struct */
#define FSCTL_CREATE_OR_GET_OBJECT_ID 0x000900C0 /* BB add struct */
#define FSCTL_SET_SPARSE 0x000900C4 /* BB add struct */
#define FSCTL_SET_ZERO_DATA 0x000900C8 /* BB add struct */
#define FSCTL_SET_ENCRYPTION 0x000900D7 /* BB add struct */
#define FSCTL_ENCRYPTION_FSCTL_IO 0x000900DB /* BB add struct */
#define FSCTL_WRITE_RAW_ENCRYPTED 0x000900DF /* BB add struct */
#define FSCTL_READ_RAW_ENCRYPTED 0x000900E3 /* BB add struct */
#define FSCTL_READ_FILE_USN_DATA 0x000900EB /* BB add struct */
#define FSCTL_WRITE_USN_CLOSE_RECORD 0x000900EF /* BB add struct */
#define FSCTL_SIS_COPYFILE 0x00090100 /* BB add struct */
#define FSCTL_RECALL_FILE 0x00090117 /* BB add struct */
#define FSCTL_QUERY_SPARING_INFO 0x00090138 /* BB add struct */
#define FSCTL_SET_ZERO_ON_DEALLOC 0x00090194 /* BB add struct */
#define FSCTL_SET_SHORT_NAME_BEHAVIOR 0x000901B4 /* BB add struct */
#define FSCTL_QUERY_ALLOCATED_RANGES 0x000940CF /* BB add struct */
#define FSCTL_SET_DEFECT_MANAGEMENT 0x00098134 /* BB add struct */
#define FSCTL_SIS_LINK_FILES 0x0009C104
#define FSCTL_PIPE_PEEK 0x0011400C /* BB add struct */
#define FSCTL_PIPE_TRANSCEIVE 0x0011C017 /* BB add struct */
/* strange that the number for this op is not sequential with previous op */
#define FSCTL_PIPE_WAIT 0x00110018 /* BB add struct */
#define FSCTL_LMR_GET_LINK_TRACK_INF 0x001400E8 /* BB add struct */
#define FSCTL_LMR_SET_LINK_TRACK_INF 0x001400EC /* BB add struct */
#define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003
#define IO_REPARSE_TAG_HSM 0xC0000004
#define IO_REPARSE_TAG_SIS 0x80000007
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