Skip to content

Commit

Permalink
Merge git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6
Browse files Browse the repository at this point in the history
* git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6:
  [CIFS] cifs_prepare_write was incorrectly rereading page in some cases
  [CIFS] Fix set file size to zero when doing chmod to Samba 3.0.26pre
  [CIFS] Remove some unused functions/declarations
  [CIFS] New file for previous commit
  [CIFS] cifs export operations
  [CIFS] small piece missing from previous patch
  [CIFS] Fix locking problem around some cifs uses of i_size write
  • Loading branch information
Linus Torvalds committed Mar 7, 2007
2 parents 8328258 + 8a23626 commit 9f6632d
Show file tree
Hide file tree
Showing 15 changed files with 227 additions and 70 deletions.
7 changes: 7 additions & 0 deletions fs/cifs/CHANGES
@@ -1,3 +1,10 @@
Verison 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
on smp system corrupts sequence number. Do not reread unnecessarily partial page
(which we are about to overwrite anyway) when writing out file opened rw.

Version 1.47
------------
Fix oops in list_del during mount caused by unaligned string.
Expand Down
2 changes: 1 addition & 1 deletion fs/cifs/Makefile
Expand Up @@ -3,4 +3,4 @@
#
obj-$(CONFIG_CIFS) += cifs.o

cifs-objs := cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o inode.o link.o misc.o netmisc.o smbdes.o smbencrypt.o transport.o asn1.o md4.o md5.o cifs_unicode.o nterr.o xattr.o cifsencrypt.o fcntl.o readdir.o ioctl.o sess.o
cifs-objs := cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o inode.o link.o misc.o netmisc.o smbdes.o smbencrypt.o transport.o asn1.o md4.o md5.o cifs_unicode.o nterr.o xattr.o cifsencrypt.o fcntl.o readdir.o ioctl.o sess.o export.o
16 changes: 7 additions & 9 deletions fs/cifs/TODO
Expand Up @@ -18,7 +18,9 @@ better)

d) Kerberos/SPNEGO session setup support - (started)

e) NTLMv2 authentication (mostly implemented)
e) NTLMv2 authentication (mostly implemented - double check
that NTLMv2 signing works, also need to cleanup now unneeded SessSetup code in
fs/cifs/connect.c)

f) MD5-HMAC signing SMB PDUs when SPNEGO style SessionSetup
used (Kerberos or NTLMSSP). Signing alreadyimplemented for NTLM
Expand Down Expand Up @@ -88,11 +90,12 @@ 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) Add support for OS/2 (LANMAN 1.2 and LANMAN2.1 based SMB servers)
x) 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).

KNOWN BUGS (updated April 29, 2005)
KNOWN BUGS (updated February 26, 2007)
====================================
See http://bugzilla.samba.org - search on product "CifsVFS" for
current bug list.
Expand All @@ -107,19 +110,14 @@ but recognizes them
succeed but still return access denied (appears to be Windows
server not cifs client problem) and has not been reproduced recently.
NTFS partitions do not have this problem.
4) debug connectathon lock test case 10 which fails against
Samba (may be unmappable due to POSIX to Windows lock model
differences but worth investigating). Also debug Samba to
see why lock test case 7 takes longer to complete to Samba
than to Windows.

Misc testing to do
==================
1) check out max path names and max path name components against various server
types. Try nested symlinks (8 deep). Return max path name in stat -f information

2) Modify file portion of ltp so it can run against a mounted network
share and run it against cifs vfs.
share and run it against cifs vfs in automated fashion.

3) Additional performance testing and optimization using iozone and similar -
there are some easy changes that can be done to parallelize sequential writes,
Expand Down
16 changes: 12 additions & 4 deletions fs/cifs/cifsfs.c
@@ -1,7 +1,7 @@
/*
* fs/cifs/cifsfs.c
*
* Copyright (C) International Business Machines Corp., 2002,2004
* Copyright (C) International Business Machines Corp., 2002,2007
* Author(s): Steve French (sfrench@us.ibm.com)
*
* Common Internet FileSystem (CIFS) client
Expand Down Expand Up @@ -47,7 +47,11 @@

#ifdef CONFIG_CIFS_QUOTA
static struct quotactl_ops cifs_quotactl_ops;
#endif
#endif /* QUOTA */

#ifdef CONFIG_CIFS_EXPERIMENTAL
extern struct export_operations cifs_export_ops;
#endif /* EXPERIMENTAL */

int cifsFYI = 0;
int cifsERROR = 1;
Expand All @@ -62,8 +66,8 @@ unsigned int extended_security = CIFSSEC_DEF;
unsigned int sign_CIFS_PDUs = 1;
extern struct task_struct * oplockThread; /* remove sparse warning */
struct task_struct * oplockThread = NULL;
extern struct task_struct * dnotifyThread; /* remove sparse warning */
struct task_struct * dnotifyThread = NULL;
/* extern struct task_struct * dnotifyThread; remove sparse warning */
static struct task_struct * dnotifyThread = NULL;
static const struct super_operations cifs_super_ops;
unsigned int CIFSMaxBufSize = CIFS_MAX_MSGSIZE;
module_param(CIFSMaxBufSize, int, 0);
Expand Down Expand Up @@ -110,6 +114,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)
sb->s_export_op = &cifs_export_ops;
#endif /* EXPERIMENTAL */
/* 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
Expand Down
4 changes: 2 additions & 2 deletions fs/cifs/cifsfs.h
Expand Up @@ -38,8 +38,8 @@ extern const struct address_space_operations cifs_addr_ops_smallbuf;
/* Functions related to super block operations */
/* extern const struct super_operations cifs_super_ops;*/
extern void cifs_read_inode(struct inode *);
extern void cifs_delete_inode(struct inode *);
/* extern void cifs_write_inode(struct inode *); *//* BB not needed yet */
/*extern void cifs_delete_inode(struct inode *);*/ /* BB not needed yet */
/* extern void cifs_write_inode(struct inode *); */ /* BB not needed yet */

/* Functions related to inodes */
extern const struct inode_operations cifs_dir_inode_ops;
Expand Down
8 changes: 5 additions & 3 deletions fs/cifs/cifsglob.h
Expand Up @@ -525,15 +525,17 @@ require use of the stronger protocol */
*/
GLOBAL_EXTERN struct smbUidInfo *GlobalUidList[UID_HASH];

GLOBAL_EXTERN struct list_head GlobalServerList; /* BB not implemented yet */
/* GLOBAL_EXTERN struct list_head GlobalServerList; BB not implemented yet */
GLOBAL_EXTERN struct list_head GlobalSMBSessionList;
GLOBAL_EXTERN struct list_head GlobalTreeConnectionList;
GLOBAL_EXTERN rwlock_t GlobalSMBSeslock; /* protects list inserts on 3 above */

GLOBAL_EXTERN struct list_head GlobalOplock_Q;

GLOBAL_EXTERN struct list_head GlobalDnotifyReqList; /* Outstanding dir notify requests */
GLOBAL_EXTERN struct list_head GlobalDnotifyRsp_Q;/* DirNotify response queue */
/* Outstanding dir notify requests */
GLOBAL_EXTERN struct list_head GlobalDnotifyReqList;
/* DirNotify response queue */
GLOBAL_EXTERN struct list_head GlobalDnotifyRsp_Q;

/*
* Global transaction id (XID) information
Expand Down
3 changes: 3 additions & 0 deletions fs/cifs/cifspdu.h
Expand Up @@ -220,6 +220,9 @@
*/
#define CIFS_NO_HANDLE 0xFFFF

#define NO_CHANGE_64 0xFFFFFFFFFFFFFFFFULL
#define NO_CHANGE_32 0xFFFFFFFFUL

/* IPC$ in ASCII */
#define CIFS_IPC_RESOURCE "\x49\x50\x43\x24"

Expand Down
2 changes: 1 addition & 1 deletion fs/cifs/cifsproto.h
Expand Up @@ -43,7 +43,7 @@ extern void _FreeXid(unsigned int);
#define FreeXid(curr_xid) {_FreeXid(curr_xid); cFYI(1,("CIFS VFS: leaving %s (xid = %d) rc = %d",__FUNCTION__,curr_xid,(int)rc));}
extern char *build_path_from_dentry(struct dentry *);
extern char *build_wildcard_path_from_dentry(struct dentry *direntry);
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 *,
struct smb_hdr * /* input */ ,
struct smb_hdr * /* out */ ,
Expand Down
10 changes: 10 additions & 0 deletions fs/cifs/cifssmb.c
Expand Up @@ -4803,6 +4803,16 @@ CIFSSMBUnixSetPerms(const int xid, struct cifsTconInfo *tcon,
pSMB->InformationLevel = cpu_to_le16(SMB_SET_FILE_UNIX_BASIC);
pSMB->Reserved4 = 0;
pSMB->hdr.smb_buf_length += byte_count;
/* Samba server ignores set of file size to zero due to bugs in some
older clients, but we should be precise - we use SetFileSize to
set file size and do not want to truncate file size to zero
accidently as happened on one Samba server beta by putting
zero instead of -1 here */
data_offset->EndOfFile = NO_CHANGE_64;
data_offset->NumOfBytes = NO_CHANGE_64;
data_offset->LastStatusChange = NO_CHANGE_64;
data_offset->LastAccessTime = NO_CHANGE_64;
data_offset->LastModificationTime = NO_CHANGE_64;
data_offset->Uid = cpu_to_le64(uid);
data_offset->Gid = cpu_to_le64(gid);
/* better to leave device as zero when it is */
Expand Down
2 changes: 1 addition & 1 deletion fs/cifs/dir.c
Expand Up @@ -31,7 +31,7 @@
#include "cifs_debug.h"
#include "cifs_fs_sb.h"

void
static void
renew_parental_timestamps(struct dentry *direntry)
{
/* BB check if there is a way to get the kernel to do this or if we really need this */
Expand Down
52 changes: 52 additions & 0 deletions fs/cifs/export.c
@@ -0,0 +1,52 @@
/*
* fs/cifs/export.c
*
* Copyright (C) International Business Machines Corp., 2007
* Author(s): Steve French (sfrench@us.ibm.com)
*
* Common Internet FileSystem (CIFS) client
*
* Operations related to support for exporting files via NFSD
*
* 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
*/

/*
* See Documentation/filesystems/Exporting
* and examples in fs/exportfs
*/

#include <linux/fs.h>

#ifdef CONFIG_CIFS_EXPERIMENTAL

static struct dentry *cifs_get_parent(struct dentry *dentry)
{
/* BB need to add code here eventually to enable export via NFSD */
return ERR_PTR(-EACCES);
}

struct export_operations cifs_export_ops = {
.get_parent = cifs_get_parent,
/* Following five export operations are unneeded so far and can default */
/* .get_dentry =
.get_name =
.find_exported_dentry =
.decode_fh =
.encode_fs = */
};

#endif /* EXPERIMENTAL */

105 changes: 63 additions & 42 deletions fs/cifs/file.c
Expand Up @@ -879,18 +879,19 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
cifs_stats_bytes_written(pTcon, total_written);

/* since the write may have blocked check these pointers again */
if (file->f_path.dentry) {
if (file->f_path.dentry->d_inode) {
struct inode *inode = file->f_path.dentry->d_inode;
inode->i_ctime = inode->i_mtime =
current_fs_time(inode->i_sb);
if (total_written > 0) {
if (*poffset > file->f_path.dentry->d_inode->i_size)
i_size_write(file->f_path.dentry->d_inode,
if ((file->f_path.dentry) && (file->f_path.dentry->d_inode)) {
struct inode *inode = file->f_path.dentry->d_inode;
/* Do not update local mtime - server will set its actual value on write
* inode->i_ctime = inode->i_mtime =
* current_fs_time(inode->i_sb);*/
if (total_written > 0) {
spin_lock(&inode->i_lock);
if (*poffset > file->f_path.dentry->d_inode->i_size)
i_size_write(file->f_path.dentry->d_inode,
*poffset);
}
mark_inode_dirty_sync(file->f_path.dentry->d_inode);
spin_unlock(&inode->i_lock);
}
mark_inode_dirty_sync(file->f_path.dentry->d_inode);
}
FreeXid(xid);
return total_written;
Expand Down Expand Up @@ -1012,18 +1013,18 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
cifs_stats_bytes_written(pTcon, total_written);

/* since the write may have blocked check these pointers again */
if (file->f_path.dentry) {
if (file->f_path.dentry->d_inode) {
if ((file->f_path.dentry) && (file->f_path.dentry->d_inode)) {
/*BB We could make this contingent on superblock ATIME flag too */
/* file->f_path.dentry->d_inode->i_ctime =
file->f_path.dentry->d_inode->i_mtime = CURRENT_TIME;*/
if (total_written > 0) {
if (*poffset > file->f_path.dentry->d_inode->i_size)
i_size_write(file->f_path.dentry->d_inode,
*poffset);
}
mark_inode_dirty_sync(file->f_path.dentry->d_inode);
/* file->f_path.dentry->d_inode->i_ctime =
file->f_path.dentry->d_inode->i_mtime = CURRENT_TIME;*/
if (total_written > 0) {
spin_lock(&file->f_path.dentry->d_inode->i_lock);
if (*poffset > file->f_path.dentry->d_inode->i_size)
i_size_write(file->f_path.dentry->d_inode,
*poffset);
spin_unlock(&file->f_path.dentry->d_inode->i_lock);
}
mark_inode_dirty_sync(file->f_path.dentry->d_inode);
}
FreeXid(xid);
return total_written;
Expand Down Expand Up @@ -1400,6 +1401,7 @@ static int cifs_commit_write(struct file *file, struct page *page,
xid = GetXid();
cFYI(1, ("commit write for page %p up to position %lld for %d",
page, position, to));
spin_lock(&inode->i_lock);
if (position > inode->i_size) {
i_size_write(inode, position);
/* if (file->private_data == NULL) {
Expand Down Expand Up @@ -1429,6 +1431,7 @@ static int cifs_commit_write(struct file *file, struct page *page,
cFYI(1, (" SetEOF (commit write) rc = %d", rc));
} */
}
spin_unlock(&inode->i_lock);
if (!PageUptodate(page)) {
position = ((loff_t)page->index << PAGE_CACHE_SHIFT) + offset;
/* can not rely on (or let) writepage write this data */
Expand Down Expand Up @@ -1989,34 +1992,52 @@ static int cifs_prepare_write(struct file *file, struct page *page,
unsigned from, unsigned to)
{
int rc = 0;
loff_t offset = (loff_t)page->index << PAGE_CACHE_SHIFT;
loff_t i_size;
loff_t offset;

cFYI(1, ("prepare write for page %p from %d to %d",page,from,to));
if (!PageUptodate(page)) {
/* if (to - from != PAGE_CACHE_SIZE) {
void *kaddr = kmap_atomic(page, KM_USER0);
if (PageUptodate(page))
return 0;

/* If we are writing a full page it will be up to date,
no need to read from the server */
if ((to == PAGE_CACHE_SIZE) && (from == 0)) {
SetPageUptodate(page);
return 0;
}

offset = (loff_t)page->index << PAGE_CACHE_SHIFT;
i_size = i_size_read(page->mapping->host);

if ((offset >= i_size) ||
((from == 0) && (offset + to) >= i_size)) {
/*
* We don't need to read data beyond the end of the file.
* zero it, and set the page uptodate
*/
void *kaddr = kmap_atomic(page, KM_USER0);

if (from)
memset(kaddr, 0, from);
if (to < PAGE_CACHE_SIZE)
memset(kaddr + to, 0, PAGE_CACHE_SIZE - to);
flush_dcache_page(page);
kunmap_atomic(kaddr, KM_USER0);
} */
/* If we are writing a full page it will be up to date,
no need to read from the server */
if ((to == PAGE_CACHE_SIZE) && (from == 0))
SetPageUptodate(page);

flush_dcache_page(page);
kunmap_atomic(kaddr, KM_USER0);
SetPageUptodate(page);
} else if ((file->f_flags & O_ACCMODE) != O_WRONLY) {
/* might as well read a page, it is fast enough */
if ((file->f_flags & O_ACCMODE) != O_WRONLY) {
rc = cifs_readpage_worker(file, page, &offset);
} else {
/* should we try using another file handle if there is one -
how would we lock it to prevent close of that handle
racing with this read?
In any case this will be written out by commit_write */
}
rc = cifs_readpage_worker(file, page, &offset);
} else {
/* we could try using another file handle if there is one -
but how would we lock it to prevent close of that handle
racing with this read? In any case
this will be written out by commit_write so is fine */
}

/* BB should we pass any errors back?
e.g. if we do not have read access to the file */
/* we do not need to pass errors back
e.g. if we do not have read access to the file
because cifs_commit_write will do the right thing. -- shaggy */

return 0;
}

Expand Down

0 comments on commit 9f6632d

Please sign in to comment.