Commit b7405e16 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 typo in cifs readme from previous commit
  [CIFS] Make sec=none force an anonymous mount
  [CIFS] Change semaphore to mutex for cifs lock_sem
  [CIFS] Fix oops in reset_cifs_unix_caps on reconnect
  [CIFS] UID/GID override on CIFS mounts to Samba
  [CIFS] prefixpath mounts to servers supporting posix paths used wrong slash
  [CIFS] Update cifs version to 1.49
  [CIFS] Replace kmalloc/memset combination with kzalloc
  [CIFS]  Add IPv6 support
  [CIFS] New CIFS POSIX mkdir performance improvement (part 2)
  [CIFS] New CIFS POSIX mkdir performance improvement
  [CIFS] Add write perm for usr to file on windows should remove r/o dos attr
  [CIFS] Remove unnecessary parm to cifs_reopen_file
  [CIFS] Switch cifsd to kthread_run from kernel_thread
  [CIFS] Remove unnecessary checks
parents ea62ccd0 0ec54aa8
Verison 1.48
Version 1.49
------------
IPv6 support. Enable ipv6 addresses to be passed on mount (put the ipv6
address after the "ip=" mount option, at least until mount.cifs is fixed to
handle DNS host to ipv6 name translation). Accept override of uid or gid
on mount even when Unix Extensions are negotiated (it used to be ignored
when Unix Extensions were ignored). This allows users to override the
default uid and gid for files when they are certain that the uids or
gids on the server do not match those of the client. Make "sec=none"
mount override username (so that null user connection is attempted)
to match what documentation said.
Version 1.48
------------
Fix mtime bouncing around from local idea of last write times to remote time.
Fix hang (in i_size_read) when simultaneous size update of same remote file
......@@ -9,7 +21,13 @@ from read-only back to read-write, reflect this change in default file mode
(we had been leaving a file's mode read-only until the inode were reloaded).
Allow setting of attribute back to ATTR_NORMAL (removing readonly dos attribute
when archive dos attribute not set and we are changing mode back to writeable
on server which does not support the Unix Extensions).
on server which does not support the Unix Extensions). Remove read only dos
attribute on chmod when adding any write permission (ie on any of
user/group/other (not all of user/group/other ie 0222) when
mounted to windows. Add support for POSIX MkDir (slight performance
enhancement and eliminates the network race between the mkdir and set
path info of the mode).
Version 1.47
------------
......
......@@ -257,13 +257,19 @@ A partial list of the supported mount options follows:
mount.
domain Set the SMB/CIFS workgroup name prepended to the
username during CIFS session establishment
uid If CIFS Unix extensions are not supported by the server
this overrides the default uid for inodes. For mounts to
servers which do support the CIFS Unix extensions, such
as a properly configured Samba server, the server provides
the uid, gid and mode. For servers which do not support
the Unix extensions, the default uid (and gid) returned on
lookup of existing files is the uid (gid) of the person
uid Set the default uid for inodes. For mounts to servers
which do support the CIFS Unix extensions, such as a
properly configured Samba server, the server provides
the uid, gid and mode so this parameter should not be
specified unless the server and clients uid and gid
numbering differ. If the server and client are in the
same domain (e.g. running winbind or nss_ldap) and
the server supports the Unix Extensions then the uid
and gid can be retrieved from the server (and uid
and gid would not have to be specifed on the mount.
For servers which do not support the CIFS Unix
extensions, the default uid (and gid) returned on lookup
of existing files will be the uid (gid) of the person
who executed the mount (root, except when mount.cifs
is configured setuid for user mounts) unless the "uid="
(gid) mount option is specified. For the uid (gid) of newly
......@@ -281,8 +287,7 @@ A partial list of the supported mount options follows:
the client. Note that the mount.cifs helper must be
at version 1.10 or higher to support specifying the uid
(or gid) in non-numberic form.
gid If CIFS Unix extensions are not supported by the server
this overrides the default gid for inodes.
gid Set the default gid for inodes (similar to above).
file_mode If CIFS Unix extensions are not supported by the server
this overrides the default mode for file inodes.
dir_mode If CIFS Unix extensions are not supported by the server
......@@ -467,7 +472,7 @@ including:
-V print mount.cifs version
-? display simple usage information
With recent 2.6 kernel versions of modutils, the version of the cifs kernel
With most 2.6 kernel versions of modutils, the version of the cifs kernel
module can be displayed via modinfo.
Misc /proc/fs/cifs Flags and Debug Info
......@@ -516,8 +521,22 @@ SecurityFlags Flags which control security negotiation and
must use plaintext passwords 0x20020
(reserved for future packet encryption) 0x00040
cifsFYI If set to one, additional debug information is
logged to the system error log. (default 0)
cifsFYI If set to non-zero value, additional debug information
will be logged to the system error log. This field
contains three flags controlling different classes of
debugging entries. The maximum value it can be set
to is 7 which enables all debugging points (default 0).
Some debugging statements are not compiled into the
cifs kernel unless CONFIG_CIFS_DEBUG2 is enabled in the
kernel configuration. cifsFYI may be set to one or
nore of the following flags (7 sets them all):
log cifs informational messages 0x01
log return codes from cifs entry points 0x02
log slow responses (ie which take longer than 1 second)
CONFIG_CIFS_STATS2 must be enabled in .config 0x04
traceSMB If set to one, debug information is logged to the
system error log with the start of smb requests
and responses (default 0)
......
Version 1.39 November 30, 2005
Version 1.49 April 26, 2007
A Partial List of Missing Features
==================================
......@@ -18,7 +18,7 @@ better)
d) Kerberos/SPNEGO session setup support - (started)
e) NTLMv2 authentication (mostly implemented - double check
e) More testing of NTLMv2 authentication (mostly implemented - double check
that NTLMv2 signing works, also need to cleanup now unneeded SessSetup code in
fs/cifs/connect.c)
......@@ -27,55 +27,44 @@ used (Kerberos or NTLMSSP). Signing alreadyimplemented for NTLM
and raw NTLMSSP already. This is important when enabling
extended security and mounting to Windows 2003 Servers
f) Directory entry caching relies on a 1 second timer, rather than
g) Directory entry caching relies on a 1 second timer, rather than
using FindNotify or equivalent. - (started)
g) A few byte range testcases fail due to POSIX vs. Windows/CIFS
style byte range lock differences. Save byte range locks so
reconnect can replay them.
h) Support unlock all (unlock 0,MAX_OFFSET)
by unlocking all known byte range locks that we locked on the file.
i) quota support (needs minor kernel change since quota calls
h) quota support (needs minor kernel change since quota calls
to make it to network filesystems or deviceless filesystems)
j) investigate sync behavior (including syncpage) and check
i) investigate sync behavior (including syncpage) and check
for proper behavior of intr/nointr
k) hook lower into the sockets api (as NFS/SunRPC does) to avoid the
j) hook lower into the sockets api (as NFS/SunRPC does) to avoid the
extra copy in/out of the socket buffers in some cases.
l) finish support for IPv6. This is mostly complete but
needs a simple conversion of ipv6 to sin6_addr from the
address in string representation.
m) Better optimize open (and pathbased setfilesize) to reduce the
k) Better optimize open (and pathbased setfilesize) to reduce the
oplock breaks coming from windows srv. Piggyback identical file
opens on top of each other by incrementing reference count rather
than resending (helps reduce server resource utilization and avoid
spurious oplock breaks).
o) Improve performance of readpages by sending more than one read
l) Improve performance of readpages by sending more than one read
at a time when 8 pages or more are requested. In conjuntion
add support for async_cifs_readpages.
p) Add support for storing symlink info to Windows servers
m) Add support for storing symlink info to Windows servers
in the Extended Attribute format their SFU clients would recognize.
q) Finish fcntl D_NOTIFY support so kde and gnome file list windows
n) Finish fcntl D_NOTIFY support so kde and gnome file list windows
will autorefresh (partially complete by Asser). Needs minor kernel
vfs change to support removing D_NOTIFY on a file.
r) Add GUI tool to configure /proc/fs/cifs settings and for display of
o) Add GUI tool to configure /proc/fs/cifs settings and for display of
the CIFS statistics (started)
s) implement support for security and trusted categories of xattrs
p) implement support for security and trusted categories of xattrs
(requires minor protocol extension) to enable better support for SELINUX
t) Implement O_DIRECT flag on open (already supported on mount)
q) Implement O_DIRECT flag on open (already supported on mount)
u) Create UID mapping facility so server UIDs can be mapped on a per
r) Create UID mapping facility so server UIDs can be mapped on a per
mount or a per server basis to client UIDs or nobody if no mapping
exists. This is helpful when Unix extensions are negotiated to
allow better permission checking when UIDs differ on the server
......@@ -83,19 +72,26 @@ and client. Add new protocol request to the CIFS protocol
standard for asking the server for the corresponding name of a
particular uid.
v) Add support for CIFS Unix and also the newer POSIX extensions to the
s) Add support for CIFS Unix and also the newer POSIX extensions to the
server side for Samba 4.
w) Finish up the dos time conversion routines needed to return old server
time to the client (default time, of now or time 0 is used now for these
very old servers)
x) In support for OS/2 (LANMAN 1.2 and LANMAN2.1 based SMB servers)
t) In support for OS/2 (LANMAN 1.2 and LANMAN2.1 based SMB servers)
need to add ability to set time to server (utimes command)
y) Finish testing of Windows 9x/Windows ME server support (started).
u) DOS attrs - returned as pseudo-xattr in Samba format (check VFAT and NTFS for this too)
v) mount check for unmatched uids
w) Add mount option for Linux extension disable per mount, and partial
disable per mount (uid off, symlink/fifo/mknod on but what about posix acls?)
KNOWN BUGS (updated February 26, 2007)
x) Fix Samba 3 server to handle Linux kernel aio so dbench with lots of
processes can proceed better in parallel (on the server)
y) Fix Samba 3 to handle reads/writes over 127K (and remove the cifs mount
restriction of wsize max being 127K)
KNOWN BUGS (updated April 24, 2007)
====================================
See http://bugzilla.samba.org - search on product "CifsVFS" for
current bug list.
......@@ -127,10 +123,3 @@ negotiated size) and send larger write sizes to modern servers.
4) More exhaustively test against less common servers. More testing
against Windows 9x, Windows ME servers.
DOS attrs - returned as pseudo-xattr in Samba format (check VFAT and NTFS for this too)
mount check for unmatched uids - and uid override
Add mount option for Linux extension disable per mount, and partial disable per mount (uid off, symlink/fifo/mknod on but what about posix acls?)
Free threads at umount --force that are stuck on the sesSem
......@@ -22,12 +22,14 @@
#define CIFS_MOUNT_SET_UID 2 /* set current->euid in create etc. */
#define CIFS_MOUNT_SERVER_INUM 4 /* inode numbers from uniqueid from server */
#define CIFS_MOUNT_DIRECT_IO 8 /* do not write nor read through page cache */
#define CIFS_MOUNT_NO_XATTR 0x10 /* if set - disable xattr support */
#define CIFS_MOUNT_MAP_SPECIAL_CHR 0x20 /* remap illegal chars in filenames */
#define CIFS_MOUNT_POSIX_PATHS 0x40 /* Negotiate posix pathnames if possible. */
#define CIFS_MOUNT_UNX_EMUL 0x80 /* Network compat with SFUnix emulation */
#define CIFS_MOUNT_NO_BRL 0x100 /* No sending byte range locks to srv */
#define CIFS_MOUNT_CIFS_ACL 0x200 /* send ACL requests to non-POSIX srv */
#define CIFS_MOUNT_NO_XATTR 0x10 /* if set - disable xattr support */
#define CIFS_MOUNT_MAP_SPECIAL_CHR 0x20 /* remap illegal chars in filenames */
#define CIFS_MOUNT_POSIX_PATHS 0x40 /* Negotiate posix pathnames if possible*/
#define CIFS_MOUNT_UNX_EMUL 0x80 /* Network compat with SFUnix emulation */
#define CIFS_MOUNT_NO_BRL 0x100 /* No sending byte range locks to srv */
#define CIFS_MOUNT_CIFS_ACL 0x200 /* send ACL requests to non-POSIX srv */
#define CIFS_MOUNT_OVERR_UID 0x400 /* override uid returned from server */
#define CIFS_MOUNT_OVERR_GID 0x800 /* override gid returned from server */
struct cifs_sb_info {
struct cifsTconInfo *tcon; /* primary mount */
......
......@@ -74,8 +74,8 @@ cifs_strtoUCS(__le16 * to, const char *from, int len,
charlen = codepage->char2uni(from, len, &wchar_to[i]);
if (charlen < 1) {
cERROR(1,
("cifs_strtoUCS: char2uni returned %d",
charlen));
("strtoUCS: char2uni of %d returned %d",
(int)*from, charlen));
/* A question mark */
to[i] = cpu_to_le16(0x003f);
charlen = 1;
......
......@@ -100,7 +100,7 @@ cifs_read_super(struct super_block *sb, void *data,
sb->s_flags |= MS_NODIRATIME | MS_NOATIME;
sb->s_fs_info = kzalloc(sizeof(struct cifs_sb_info),GFP_KERNEL);
cifs_sb = CIFS_SB(sb);
if(cifs_sb == NULL)
if (cifs_sb == NULL)
return -ENOMEM;
rc = cifs_mount(sb, cifs_sb, data, devname);
......@@ -115,10 +115,10 @@ cifs_read_super(struct super_block *sb, void *data,
sb->s_magic = CIFS_MAGIC_NUMBER;
sb->s_op = &cifs_super_ops;
#ifdef CONFIG_CIFS_EXPERIMENTAL
if(experimEnabled != 0)
if (experimEnabled != 0)
sb->s_export_op = &cifs_export_ops;
#endif /* EXPERIMENTAL */
/* if(cifs_sb->tcon->ses->server->maxBuf > MAX_CIFS_HDR_SIZE + 512)
/* if (cifs_sb->tcon->ses->server->maxBuf > MAX_CIFS_HDR_SIZE + 512)
sb->s_blocksize = cifs_sb->tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE; */
#ifdef CONFIG_CIFS_QUOTA
sb->s_qcop = &cifs_quotactl_ops;
......@@ -147,8 +147,8 @@ cifs_read_super(struct super_block *sb, void *data,
iput(inode);
out_mount_failed:
if(cifs_sb) {
if(cifs_sb->local_nls)
if (cifs_sb) {
if (cifs_sb->local_nls)
unload_nls(cifs_sb->local_nls);
kfree(cifs_sb);
}
......@@ -163,7 +163,7 @@ cifs_put_super(struct super_block *sb)
cFYI(1, ("In cifs_put_super"));
cifs_sb = CIFS_SB(sb);
if(cifs_sb == NULL) {
if (cifs_sb == NULL) {
cFYI(1,("Empty cifs superblock info passed to unmount"));
return;
}
......@@ -208,14 +208,14 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
/* Only need to call the old QFSInfo if failed
on newer one */
if(rc)
if(pTcon->ses->capabilities & CAP_NT_SMBS)
if (rc)
if (pTcon->ses->capabilities & CAP_NT_SMBS)
rc = CIFSSMBQFSInfo(xid, pTcon, buf); /* not supported by OS2 */
/* Some old Windows servers also do not support level 103, retry with
older level one if old server failed the previous call or we
bypassed it because we detected that this was an older LANMAN sess */
if(rc)
if (rc)
rc = SMBOldQFSInfo(xid, pTcon, buf);
/*
int f_type;
......@@ -301,11 +301,19 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m)
if (cifs_sb->tcon->ses->userName)
seq_printf(s, ",username=%s",
cifs_sb->tcon->ses->userName);
if(cifs_sb->tcon->ses->domainName)
if (cifs_sb->tcon->ses->domainName)
seq_printf(s, ",domain=%s",
cifs_sb->tcon->ses->domainName);
}
}
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
seq_printf(s, ",posixpaths");
if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) ||
!(cifs_sb->tcon->ses->capabilities & CAP_UNIX))
seq_printf(s, ",uid=%d", cifs_sb->mnt_uid);
if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID) ||
!(cifs_sb->tcon->ses->capabilities & CAP_UNIX))
seq_printf(s, ",gid=%d", cifs_sb->mnt_gid);
seq_printf(s, ",rsize=%d",cifs_sb->rsize);
seq_printf(s, ",wsize=%d",cifs_sb->wsize);
}
......@@ -321,14 +329,14 @@ int cifs_xquota_set(struct super_block * sb, int quota_type, qid_t qid,
struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
struct cifsTconInfo *pTcon;
if(cifs_sb)
if (cifs_sb)
pTcon = cifs_sb->tcon;
else
return -EIO;
xid = GetXid();
if(pTcon) {
if (pTcon) {
cFYI(1,("set type: 0x%x id: %d",quota_type,qid));
} else {
return -EIO;
......@@ -346,13 +354,13 @@ int cifs_xquota_get(struct super_block * sb, int quota_type, qid_t qid,
struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
struct cifsTconInfo *pTcon;
if(cifs_sb)
if (cifs_sb)
pTcon = cifs_sb->tcon;
else
return -EIO;
xid = GetXid();
if(pTcon) {
if (pTcon) {
cFYI(1,("set type: 0x%x id: %d",quota_type,qid));
} else {
rc = -EIO;
......@@ -369,13 +377,13 @@ int cifs_xstate_set(struct super_block * sb, unsigned int flags, int operation)
struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
struct cifsTconInfo *pTcon;
if(cifs_sb)
if (cifs_sb)
pTcon = cifs_sb->tcon;
else
return -EIO;
xid = GetXid();
if(pTcon) {
if (pTcon) {
cFYI(1,("flags: 0x%x operation: 0x%x",flags,operation));
} else {
rc = -EIO;
......@@ -392,13 +400,13 @@ int cifs_xstate_get(struct super_block * sb, struct fs_quota_stat *qstats)
struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
struct cifsTconInfo *pTcon;
if(cifs_sb) {
if (cifs_sb) {
pTcon = cifs_sb->tcon;
} else {
return -EIO;
}
xid = GetXid();
if(pTcon) {
if (pTcon) {
cFYI(1,("pqstats %p",qstats));
} else {
rc = -EIO;
......@@ -424,11 +432,11 @@ static void cifs_umount_begin(struct vfsmount * vfsmnt, int flags)
if (!(flags & MNT_FORCE))
return;
cifs_sb = CIFS_SB(vfsmnt->mnt_sb);
if(cifs_sb == NULL)
if (cifs_sb == NULL)
return;
tcon = cifs_sb->tcon;
if(tcon == NULL)
if (tcon == NULL)
return;
down(&tcon->tconSem);
if (atomic_read(&tcon->useCount) == 1)
......@@ -437,7 +445,7 @@ static void cifs_umount_begin(struct vfsmount * vfsmnt, int flags)
/* cancel_brl_requests(tcon); */ /* BB mark all brl mids as exiting */
/* cancel_notify_requests(tcon); */
if(tcon->ses && tcon->ses->server)
if (tcon->ses && tcon->ses->server)
{
cFYI(1,("wake up tasks now - umount begin not complete"));
wake_up_all(&tcon->ses->server->request_q);
......@@ -529,8 +537,7 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int origin)
/* some applications poll for the file length in this strange
way so we must seek to end on non-oplocked files by
setting the revalidate time to zero */
if(file->f_path.dentry->d_inode)
CIFS_I(file->f_path.dentry->d_inode)->time = 0;
CIFS_I(file->f_path.dentry->d_inode)->time = 0;
retval = cifs_revalidate(file->f_path.dentry);
if (retval < 0)
......@@ -724,7 +731,7 @@ cifs_destroy_inodecache(void)
static int
cifs_init_request_bufs(void)
{
if(CIFSMaxBufSize < 8192) {
if (CIFSMaxBufSize < 8192) {
/* Buffer size can not be smaller than 2 * PATH_MAX since maximum
Unicode path name has to fit in any SMB/CIFS path based frames */
CIFSMaxBufSize = 8192;
......@@ -741,7 +748,7 @@ cifs_init_request_bufs(void)
if (cifs_req_cachep == NULL)
return -ENOMEM;
if(cifs_min_rcv < 1)
if (cifs_min_rcv < 1)
cifs_min_rcv = 1;
else if (cifs_min_rcv > 64) {
cifs_min_rcv = 64;
......@@ -751,7 +758,7 @@ cifs_init_request_bufs(void)
cifs_req_poolp = mempool_create_slab_pool(cifs_min_rcv,
cifs_req_cachep);
if(cifs_req_poolp == NULL) {
if (cifs_req_poolp == NULL) {
kmem_cache_destroy(cifs_req_cachep);
return -ENOMEM;
}
......@@ -772,7 +779,7 @@ cifs_init_request_bufs(void)
return -ENOMEM;
}
if(cifs_min_small < 2)
if (cifs_min_small < 2)
cifs_min_small = 2;
else if (cifs_min_small > 256) {
cifs_min_small = 256;
......@@ -782,7 +789,7 @@ cifs_init_request_bufs(void)
cifs_sm_req_poolp = mempool_create_slab_pool(cifs_min_small,
cifs_sm_req_cachep);
if(cifs_sm_req_poolp == NULL) {
if (cifs_sm_req_poolp == NULL) {
mempool_destroy(cifs_req_poolp);
kmem_cache_destroy(cifs_req_cachep);
kmem_cache_destroy(cifs_sm_req_cachep);
......@@ -812,7 +819,7 @@ cifs_init_mids(void)
/* 3 is a reasonable minimum number of simultaneous operations */
cifs_mid_poolp = mempool_create_slab_pool(3, cifs_mid_cachep);
if(cifs_mid_poolp == NULL) {
if (cifs_mid_poolp == NULL) {
kmem_cache_destroy(cifs_mid_cachep);
return -ENOMEM;
}
......@@ -850,14 +857,14 @@ static int cifs_oplock_thread(void * dummyarg)
continue;
spin_lock(&GlobalMid_Lock);
if(list_empty(&GlobalOplock_Q)) {
if (list_empty(&GlobalOplock_Q)) {
spin_unlock(&GlobalMid_Lock);
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(39*HZ);
} else {
oplock_item = list_entry(GlobalOplock_Q.next,
struct oplock_q_entry, qhead);
if(oplock_item) {
if (oplock_item) {
cFYI(1,("found oplock item to write out"));
pTcon = oplock_item->tcon;
inode = oplock_item->pinode;
......@@ -871,7 +878,7 @@ static int cifs_oplock_thread(void * dummyarg)
/* mutex_lock(&inode->i_mutex);*/
if (S_ISREG(inode->i_mode)) {
rc = filemap_fdatawrite(inode->i_mapping);
if(CIFS_I(inode)->clientCanCacheRead == 0) {
if (CIFS_I(inode)->clientCanCacheRead == 0) {
filemap_fdatawait(inode->i_mapping);
invalidate_remote_inode(inode);
}
......@@ -888,7 +895,7 @@ static int cifs_oplock_thread(void * dummyarg)
not bother sending an oplock release if session
to server still is disconnected since oplock
already released by the server in that case */
if(pTcon->tidStatus != CifsNeedReconnect) {
if (pTcon->tidStatus != CifsNeedReconnect) {
rc = CIFSSMBLock(0, pTcon, netfid,
0 /* len */ , 0 /* offset */, 0,
0, LOCKING_ANDX_OPLOCK_RELEASE,
......@@ -922,7 +929,7 @@ static int cifs_dnotify_thread(void * dummyarg)
list_for_each(tmp, &GlobalSMBSessionList) {
ses = list_entry(tmp, struct cifsSesInfo,
cifsSessionList);
if(ses && ses->server &&
if (ses && ses->server &&
atomic_read(&ses->server->inFlight))
wake_up_all(&ses->server->response_q);
}
......@@ -971,10 +978,10 @@ init_cifs(void)
rwlock_init(&GlobalSMBSeslock);
spin_lock_init(&GlobalMid_Lock);
if(cifs_max_pending < 2) {
if (cifs_max_pending < 2) {
cifs_max_pending = 2;
cFYI(1,("cifs_max_pending set to min of 2"));
} else if(cifs_max_pending > 256) {
} else if (cifs_max_pending > 256) {
cifs_max_pending = 256;
cFYI(1,("cifs_max_pending set to max of 256"));
}
......
......@@ -100,5 +100,5 @@ extern ssize_t cifs_getxattr(struct dentry *, const char *, void *, size_t);
extern ssize_t cifs_listxattr(struct dentry *, char *, size_t);
extern int cifs_ioctl (struct inode * inode, struct file * filep,
unsigned int command, unsigned long arg);
#define CIFS_VERSION "1.48"
#define CIFS_VERSION "1.49"
#endif /* _CIFSFS_H */
......@@ -311,7 +311,7 @@ struct cifsFileInfo {
/* lock scope id (0 if none) */
struct file * pfile; /* needed for writepage */
struct inode * pInode; /* needed for oplock break */
struct semaphore lock_sem;
struct mutex lock_mutex;
struct list_head llist; /* list of byte range locks we have. */
unsigned closePend:1; /* file is marked to close */
unsigned invalidHandle:1; /* file closed via session abend */
......
......@@ -1388,7 +1388,7 @@ struct smb_t2_rsp {
#define SMB_SET_POSIX_LOCK 0x208
#define SMB_POSIX_OPEN 0x209
#define SMB_POSIX_UNLINK 0x20a
#define SMB_SET_FILE_UNIX_INFO2
#define SMB_SET_FILE_UNIX_INFO2 0x20b
#define SMB_SET_FILE_BASIC_INFO2 0x3ec
#define SMB_SET_FILE_RENAME_INFORMATION 0x3f2 /* BB check if qpathinfo too */
#define SMB_FILE_ALL_INFO2 0x3fa
......@@ -2109,22 +2109,40 @@ struct cifs_posix_acl { /* access conrol list (ACL) */
/* end of POSIX ACL definitions */
/* POSIX Open Flags */
#define SMB_O_RDONLY 0x1
#define SMB_O_WRONLY 0x2
#define SMB_O_RDWR 0x4
#define SMB_O_CREAT 0x10
#define SMB_O_EXCL 0x20
#define SMB_O_TRUNC 0x40
#define SMB_O_APPEND 0x80
#define SMB_O_SYNC 0x100
#define SMB_O_DIRECTORY 0x200
#define SMB_O_NOFOLLOW 0x400
#define SMB_O_DIRECT 0x800
typedef struct {
__u32 OpenFlags; /* same as NT CreateX */
__u32 PosixOpenFlags;
__u32 Mode;
__u16 Level; /* reply level requested (see QPathInfo levels) */
__u16 Pad; /* reserved - MBZ */
__le32 OpenFlags; /* same as NT CreateX */
__le32 PosixOpenFlags;
__le64 Permissions;
__le16 Level; /* reply level requested (see QPathInfo levels) */
} __attribute__((packed)) OPEN_PSX_REQ; /* level 0x209 SetPathInfo data */
typedef struct {
/* reply varies based on requested level */
__le16 OplockFlags;
__u16 Fid;
__le32 CreateAction;
__le16 ReturnedLevel;
__le16 Pad;
/* struct following varies based on requested level */
} __attribute__((packed)) OPEN_PSX_RSP; /* level 0x209 SetPathInfo data */
struct file_internal_info {
__u64 UniqueId; /* inode number */
} __attribute__((packed)); /* level 0x3ee */
struct file_mode_info {
__le32 Mode;
} __attribute__((packed)); /* level 0x3f8 */
......
/*
* fs/cifs/cifsproto.h
*
* Copyright (c) International Business Machines Corp., 2002,2006
* Copyright (c) International Business Machines Corp., 2002,2007
* Author(s): Steve French (sfrench@us.ibm.com)
*
* This library is free software; you can redistribute it and/or modify
......@@ -244,6 +244,11 @@ extern int SMBLegacyOpen(const int xid, struct cifsTconInfo *tcon,
const int access_flags, const int omode,
__u16 * netfid, int *pOplock, FILE_ALL_INFO *,
const struct nls_table *nls_codepage, int remap);
extern int CIFSPOSIXCreate(const int xid, struct cifsTconInfo *tcon,
u32 posix_flags, __u64 mode, __u16 * netfid,
FILE_UNIX_BASIC_INFO *pRetData,
__u32 *pOplock, const char *name,
const struct nls_table *nls_codepage, int remap);
extern int CIFSSMBClose(const int xid, struct cifsTconInfo *tcon,
const int smb_file_id);
......
/*
* fs/cifs/cifssmb.c
*
* Copyright (C) International Business Machines Corp., 2002,2006
* Copyright (C) International Business Machines Corp., 2002,2007
* Author(s): Steve French (sfrench@us.ibm.com)
*
* Contains the routines for constructing the SMB PDUs themselves
......@@ -24,8 +24,8 @@
/* SMB/CIFS PDU handling routines here - except for leftovers in connect.c */
/* These are mostly routines that operate on a pathname, or on a tree id */
/* (mounted volume), but there are eight handle based routines which must be */
/* treated slightly different for reconnection purposes since we never want */
/* to reuse a stale file handle and the caller knows the file handle */
/* treated slightly differently for reconnection purposes since we never */
/* want to reuse a stale file handle and only the caller knows the file info */
#include <linux/fs.h>
#include <linux/kernel.h>
......@@ -913,6 +913,130 @@ CIFSSMBMkDir(const int xid, struct cifsTconInfo *tcon,
return rc;
}
int
CIFSPOSIXCreate(const int xid, struct cifsTconInfo *tcon, __u32 posix_flags,
__u64 mode, __u16 * netfid, FILE_UNIX_BASIC_INFO *pRetData,
__u32 *pOplock, const char *name,
const struct nls_table *nls_codepage, int remap)
{
TRANSACTION2_SPI_REQ *pSMB = NULL;
TRANSACTION2_SPI_RSP *pSMBr = NULL;
int name_len;
int rc = 0;
int bytes_returned = 0;
char *data_offset;
__u16 params, param_offset, offset, byte_count, count;
OPEN_PSX_REQ * pdata;
OPEN_PSX_RSP * psx_rsp;
cFYI(1, ("In POSIX Create"));
PsxCreat:
rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,
(void **) &pSMBr);
if (rc)
return rc;
if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
name_len =
cifsConvertToUCS((__le16 *) pSMB->FileName, name,
PATH_MAX, nls_codepage, remap);
name_len++; /* trailing null */
name_len *= 2;
} else { /* BB improve the check for buffer overruns BB */
name_len = strnlen(name, PATH_MAX);
name_len++; /* trailing null */
strncpy(pSMB->FileName, name, name_len);
}
params = 6 + name_len;
count = sizeof(OPEN_PSX_REQ);
pSMB->MaxParameterCount = cpu_to_le16(2);
pSMB->MaxDataCount = cpu_to_le16(1000); /* large enough */
pSMB->MaxSetupCount = 0;
pSMB->Reserved = 0;
pSMB->Flags = 0;
pSMB->Timeout = 0;
pSMB->Reserved2 = 0;
param_offset = offsetof(struct smb_com_transaction2_spi_req,
InformationLevel) - 4;
offset = param_offset + params;
data_offset = (char *) (&pSMB->hdr.Protocol) + offset;
pdata = (OPEN_PSX_REQ *)(((char *)&pSMB->hdr.Protocol) + offset);
pdata->Level = SMB_QUERY_FILE_UNIX_BASIC;
pdata->Permissions = cpu_to_le64(mode);
pdata->PosixOpenFlags = cpu_to_le32(posix_flags);
pdata->OpenFlags = cpu_to_le32(*pOplock);
pSMB->ParameterOffset = cpu_to_le16(param_offset);
pSMB->DataOffset = cpu_to_le16(offset);
pSMB->SetupCount = 1;
pSMB->Reserved3 = 0;
pSMB->SubCommand = cpu_to_le16(TRANS2_SET_PATH_INFORMATION);
byte_count = 3 /* pad */ + params + count;
pSMB->DataCount = cpu_to_le16(count);
pSMB->ParameterCount = cpu_to_le16(params);
pSMB->TotalDataCount = pSMB->DataCount;
pSMB->TotalParameterCount = pSMB->ParameterCount;
pSMB->InformationLevel = cpu_to_le16(SMB_POSIX_OPEN);
pSMB->Reserved4 = 0;
pSMB->hdr.smb_buf_length += byte_count;
pSMB->ByteCount = cpu_to_le16(byte_count);
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, &bytes_returned, 0);
if (rc) {
cFYI(1, ("Posix create returned %d", rc));
goto psx_create_err;
}
cFYI(1,("copying inode info"));
rc = validate_t2((struct smb_t2_rsp *)pSMBr);
if (rc || (pSMBr->ByteCount < sizeof(OPEN_PSX_RSP))) {
rc = -EIO; /* bad smb */
goto psx_create_err;
}
/* copy return information to pRetData */
psx_rsp = (OPEN_PSX_RSP *)((char *) &pSMBr->hdr.Protocol
+ le16_to_cpu(pSMBr->t2.DataOffset));
*pOplock = le16_to_cpu(psx_rsp->OplockFlags);
if(netfid)
*netfid = psx_rsp->Fid; /* cifs fid stays in le */
/* Let caller know file was created so we can set the mode. */
/* Do we care about the CreateAction in any other cases? */
if(cpu_to_le32(FILE_CREATE) == psx_rsp->CreateAction)
*pOplock |= CIFS_CREATE_ACTION;
/* check to make sure response data is there */
if(psx_rsp->ReturnedLevel != SMB_QUERY_FILE_UNIX_BASIC) {
pRetData->Type = -1; /* unknown */
#ifdef CONFIG_CIFS_DEBUG2
cFYI(1,("unknown type"));
#endif
} else {
if(pSMBr->ByteCount < sizeof(OPEN_PSX_RSP)
+ sizeof(FILE_UNIX_BASIC_INFO)) {
cERROR(1,("Open response data too small"));
pRetData->Type = -1;
goto psx_create_err;
}
memcpy((char *) pRetData,
(char *)psx_rsp + sizeof(OPEN_PSX_RSP),
sizeof (FILE_UNIX_BASIC_INFO));
}
psx_create_err:
cifs_buf_release(pSMB);
cifs_stats_inc(&tcon->num_mkdirs);
if (rc == -EAGAIN)
goto PsxCreat;
return rc;
}
static __u16 convert_disposition(int disposition)
{
__u16 ofun = 0;
......
This diff is collapsed.
......@@ -274,7 +274,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
pCifsFile->invalidHandle = FALSE;
pCifsFile->closePend = FALSE;
init_MUTEX(&pCifsFile->fh_sem);
init_MUTEX(&pCifsFile->lock_sem);
mutex_init(&pCifsFile->lock_mutex);
INIT_LIST_HEAD(&pCifsFile->llist);
atomic_set(&pCifsFile->wrtPending,0);
......
......@@ -48,7 +48,7 @@ static inline struct cifsFileInfo *cifs_init_private(
private_data->netfid = netfid;
private_data->pid = current->tgid;
init_MUTEX(&private_data->fh_sem);
init_MUTEX(&private_data->lock_sem);
mutex_init(&private_data->lock_mutex);
INIT_LIST_HEAD(&private_data->llist);
private_data->pfile = file; /* needed for writepage */
private_data->pInode = inode;
......@@ -338,8 +338,7 @@ static int cifs_relock_file(struct cifsFileInfo *cifsFile)
return rc;
}
static int cifs_reopen_file(struct inode *inode, struct file *file,
int can_flush)
static int cifs_reopen_file(struct file *file, int can_flush)
{
int rc = -EACCES;
int xid, oplock;
......@@ -347,13 +346,12 @@ static int cifs_reopen_file(struct inode *inode, struct file *file,
struct cifsTconInfo *pTcon;
struct cifsFileInfo *pCifsFile;
struct cifsInodeInfo *pCifsInode;
struct inode * inode;
char *full_path = NULL;
int desiredAccess;
int disposition = FILE_OPEN;
__u16 netfid;
if (inode == NULL)
return -EBADF;
if (file->private_data) {
pCifsFile = (struct cifsFileInfo *)file->private_data;
} else
......@@ -368,25 +366,37 @@ static int cifs_reopen_file(struct inode *inode, struct file *file,
}
if (file->f_path.dentry == NULL) {
up(&pCifsFile->fh_sem);
cFYI(1, ("failed file reopen, no valid name if dentry freed"));
FreeXid(xid);
return -EBADF;
cERROR(1, ("no valid name if dentry freed"));
dump_stack();
rc = -EBADF;
goto reopen_error_exit;
}
inode = file->f_path.dentry->d_inode;
if(inode == NULL) {
cERROR(1, ("inode not valid"));
dump_stack();
rc = -EBADF;
goto reopen_error_exit;
}
cifs_sb = CIFS_SB(inode->i_sb);
pTcon = cifs_sb->tcon;
/* can not grab rename sem here because various ops, including
those that already have the rename sem can end up causing writepage
to get called and if the server was down that means we end up here,
and we can never tell if the caller already has the rename_sem */
full_path = build_path_from_dentry(file->f_path.dentry);
if (full_path == NULL) {
rc = -ENOMEM;
reopen_error_exit:
up(&pCifsFile->fh_sem);
FreeXid(xid);
return -ENOMEM;
return rc;
}
cFYI(1, (" inode = 0x%p file flags are 0x%x for %s",
cFYI(1, ("inode = 0x%p file flags 0x%x for %s",
inode, file->f_flags,full_path));
desiredAccess = cifs_convert_flags(file->f_flags);
......@@ -401,13 +411,6 @@ static int cifs_reopen_file(struct inode *inode, struct file *file,
and server version of file size can be stale. If we knew for sure
that inode was not dirty locally we could do this */
/* buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);
if (buf == 0) {
up(&pCifsFile->fh_sem);
kfree(full_path);
FreeXid(xid);
return -ENOMEM;
} */
rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, desiredAccess,
CREATE_NOT_DIR, &netfid, &oplock, NULL,
cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
......@@ -508,12 +511,12 @@ int cifs_close(struct inode *inode, struct file *file)
/* Delete any outstanding lock records.
We'll lose them when the file is closed anyway. */
down(&pSMBFile->lock_sem);
mutex_lock(&pSMBFile->lock_mutex);
list_for_each_entry_safe(li, tmp, &pSMBFile->llist, llist) {
list_del(&li->llist);
kfree(li);
}
up(&pSMBFile->lock_sem);
mutex_unlock(&pSMBFile->lock_mutex);
write_lock(&GlobalSMBSeslock);
list_del(&pSMBFile->flist);
......@@ -598,9 +601,9 @@ static int store_file_lock(struct cifsFileInfo *fid, __u64 len,
li->offset = offset;
li->length = len;
li->type = lockType;
down(&fid->lock_sem);
mutex_lock(&fid->lock_mutex);
list_add(&li->llist, &fid->llist);
up(&fid->lock_sem);
mutex_unlock(&fid->lock_mutex);
return 0;
}
......@@ -757,7 +760,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
struct cifsLockInfo *li, *tmp;
rc = 0;
down(&fid->lock_sem);
mutex_lock(&fid->lock_mutex);
list_for_each_entry_safe(li, tmp, &fid->llist, llist) {
if (pfLock->fl_start <= li->offset &&
length >= li->length) {
......@@ -771,7 +774,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
kfree(li);
}
}
up(&fid->lock_sem);
mutex_unlock(&fid->lock_mutex);
}
}
......@@ -792,12 +795,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
int xid, long_op;
struct cifsFileInfo *open_file;
if (file->f_path.dentry == NULL)
return -EBADF;
cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
if (cifs_sb == NULL)
return -EBADF;
pTcon = cifs_sb->tcon;
......@@ -807,14 +805,9 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
if (file->private_data == NULL)
return -EBADF;
else
open_file = (struct cifsFileInfo *) file->private_data;
open_file = (struct cifsFileInfo *) file->private_data;
xid = GetXid();
if (file->f_path.dentry->d_inode == NULL) {
FreeXid(xid);
return -EBADF;
}
if (*poffset > file->f_path.dentry->d_inode->i_size)
long_op = 2; /* writes past end of file can take a long time */
......@@ -841,17 +834,11 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
return -EBADF;
}
if (open_file->invalidHandle) {
if ((file->f_path.dentry == NULL) ||
(file->f_path.dentry->d_inode == NULL)) {
FreeXid(xid);
return total_written;
}
/* we could deadlock if we called
filemap_fdatawait from here so tell
reopen_file not to flush data to server
now */
rc = cifs_reopen_file(file->f_path.dentry->d_inode,
file, FALSE);
rc = cifs_reopen_file(file, FALSE);
if (rc != 0)
break;
}
......@@ -908,12 +895,7 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
int xid, long_op;
struct cifsFileInfo *open_file;
if (file->f_path.dentry == NULL)
return -EBADF;
cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
if (cifs_sb == NULL)
return -EBADF;
pTcon = cifs_sb->tcon;
......@@ -922,14 +904,9 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
if (file->private_data == NULL)
return -EBADF;
else
open_file = (struct cifsFileInfo *)file->private_data;
open_file = (struct cifsFileInfo *)file->private_data;
xid = GetXid();
if (file->f_path.dentry->d_inode == NULL) {
FreeXid(xid);
return -EBADF;
}
if (*poffset > file->f_path.dentry->d_inode->i_size)
long_op = 2; /* writes past end of file can take a long time */
......@@ -957,17 +934,11 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
return -EBADF;
}
if (open_file->invalidHandle) {
if ((file->f_path.dentry == NULL) ||
(file->f_path.dentry->d_inode == NULL)) {
FreeXid(xid);
return total_written;
}
/* we could deadlock if we called
filemap_fdatawait from here so tell
reopen_file not to flush data to
server now */
rc = cifs_reopen_file(file->f_path.dentry->d_inode,
file, FALSE);
rc = cifs_reopen_file(file, FALSE);
if (rc != 0)
break;
}
......@@ -1056,8 +1027,7 @@ struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode)
read_unlock(&GlobalSMBSeslock);
if((open_file->invalidHandle) &&
(!open_file->closePend) /* BB fixme -since the second clause can not be true remove it BB */) {
rc = cifs_reopen_file(&cifs_inode->vfs_inode,
open_file->pfile, FALSE);
rc = cifs_reopen_file(open_file->pfile, FALSE);
/* if it fails, try another handle - might be */
/* dangerous to hold up writepages with retry */
if(rc) {
......@@ -1404,32 +1374,6 @@ static int cifs_commit_write(struct file *file, struct page *page,
spin_lock(&inode->i_lock);
if (position > inode->i_size) {
i_size_write(inode, position);
/* if (file->private_data == NULL) {
rc = -EBADF;
} else {
open_file = (struct cifsFileInfo *)file->private_data;
cifs_sb = CIFS_SB(inode->i_sb);
rc = -EAGAIN;
while (rc == -EAGAIN) {
if ((open_file->invalidHandle) &&
(!open_file->closePend)) {
rc = cifs_reopen_file(
file->f_path.dentry->d_inode, file);
if (rc != 0)
break;
}
if (!open_file->closePend) {
rc = CIFSSMBSetFileSize(xid,
cifs_sb->tcon, position,
open_file->netfid,
open_file->pid, FALSE);
} else {
rc = -EBADF;
break;
}
}
cFYI(1, (" SetEOF (commit write) rc = %d", rc));
} */
}
spin_unlock(&inode->i_lock);
if (!PageUptodate(page)) {
......@@ -1573,8 +1517,7 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,
int buf_type = CIFS_NO_BUFFER;
if ((open_file->invalidHandle) &&
(!open_file->closePend)) {
rc = cifs_reopen_file(file->f_path.dentry->d_inode,
file, TRUE);
rc = cifs_reopen_file(file, TRUE);
if (rc != 0)
break;
}
......@@ -1660,8 +1603,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
while (rc == -EAGAIN) {
if ((open_file->invalidHandle) &&
(!open_file->closePend)) {
rc = cifs_reopen_file(file->f_path.dentry->d_inode,
file, TRUE);
rc = cifs_reopen_file(file, TRUE);
if (rc != 0)
break;
}
......@@ -1817,8 +1759,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
while (rc == -EAGAIN) {
if ((open_file->invalidHandle) &&
(!open_file->closePend)) {
rc = cifs_reopen_file(file->f_path.dentry->d_inode,
file, TRUE);
rc = cifs_reopen_file(file, TRUE);
if (rc != 0)
break;
}
......
This diff is collapsed.
......@@ -30,6 +30,9 @@
#include <linux/fs.h>
#include <asm/div64.h>
#include <asm/byteorder.h>
#ifdef CONFIG_CIFS_EXPERIMENTAL
#include <linux/inet.h>
#endif
#include "cifsfs.h"
#include "cifspdu.h"
#include "cifsglob.h"
......@@ -129,11 +132,27 @@ static const struct smb_to_posix_error mapping_table_ERRHRD[] = {
/* Convert string containing dotted ip address to binary form */
/* returns 0 if invalid address */
/* BB add address family, change rc to status flag and return union or for ipv6 */
/* will need parent to call something like inet_pton to convert ipv6 address BB */
int
cifs_inet_pton(int address_family, char *cp,void *dst)
{
#ifdef CONFIG_CIFS_EXPERIMENTAL
int ret = 0;
/* calculate length by finding first slash or NULL */
/* BB Should we convert '/' slash to '\' here since it seems already done
before this */
if( address_family == AF_INET ){
ret = in4_pton(cp, -1 /* len */, dst , '\\', NULL);
} else if( address_family == AF_INET6 ){
ret = in6_pton(cp, -1 /* len */, dst , '\\', NULL);
}
#ifdef CONFIG_CIFS_DEBUG2
cFYI(1,("address conversion returned %d for %s", ret, cp));
#endif
if (ret > 0)
ret = 1;
return ret;
#else
int value;
int digit;
int i;
......@@ -192,6 +211,7 @@ cifs_inet_pton(int address_family, char *cp,void *dst)
*((__be32 *)dst) = *((__be32 *) bytes) | htonl(value);
return 1; /* success */
#endif /* EXPERIMENTAL */
}
/*****************************************************************************
......
This diff is collapsed.
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