aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/9p/fid.h15
-rw-r--r--fs/9p/v9fs.c57
-rw-r--r--fs/9p/v9fs.h85
-rw-r--r--fs/9p/vfs_addr.c2
-rw-r--r--fs/9p/vfs_dir.c2
-rw-r--r--fs/9p/vfs_file.c11
-rw-r--r--fs/9p/vfs_inode.c50
-rw-r--r--fs/9p/vfs_super.c35
-rw-r--r--fs/Kconfig.binfmt2
-rw-r--r--fs/afs/callback.c2
-rw-r--r--fs/afs/inode.c2
-rw-r--r--fs/afs/super.c2
-rw-r--r--fs/aio.c4
-rw-r--r--fs/befs/endian.h2
-rw-r--r--fs/binfmt_elf.c9
-rw-r--r--fs/binfmt_elf_fdpic.c2
-rw-r--r--fs/binfmt_flat.c8
-rw-r--r--fs/block_dev.c8
-rw-r--r--fs/cifs/AUTHORS1
-rw-r--r--fs/cifs/CHANGES10
-rw-r--r--fs/cifs/README5
-rw-r--r--fs/cifs/TODO15
-rw-r--r--fs/cifs/asn1.c14
-rw-r--r--fs/cifs/cifs_dfs_ref.c49
-rw-r--r--fs/cifs/cifs_fs_sb.h1
-rw-r--r--fs/cifs/cifs_spnego.c3
-rw-r--r--fs/cifs/cifsfs.c65
-rw-r--r--fs/cifs/cifsfs.h3
-rw-r--r--fs/cifs/cifsglob.h4
-rw-r--r--fs/cifs/cifspdu.h49
-rw-r--r--fs/cifs/cifsproto.h13
-rw-r--r--fs/cifs/cifssmb.c355
-rw-r--r--fs/cifs/connect.c152
-rw-r--r--fs/cifs/dir.c50
-rw-r--r--fs/cifs/dns_resolve.c9
-rw-r--r--fs/cifs/file.c13
-rw-r--r--fs/cifs/inode.c602
-rw-r--r--fs/cifs/ioctl.c4
-rw-r--r--fs/cifs/link.c43
-rw-r--r--fs/cifs/misc.c3
-rw-r--r--fs/cifs/netmisc.c6
-rw-r--r--fs/cifs/ntlmssp.h4
-rw-r--r--fs/cifs/readdir.c84
-rw-r--r--fs/compat.c4
-rw-r--r--fs/dlm/lowcomms.c27
-rw-r--r--fs/dlm/netlink.c2
-rw-r--r--fs/dlm/plock.c2
-rw-r--r--fs/dquot.c10
-rw-r--r--fs/ecryptfs/crypto.c2
-rw-r--r--fs/ecryptfs/ecryptfs_kernel.h2
-rw-r--r--fs/ecryptfs/inode.c13
-rw-r--r--fs/ecryptfs/miscdev.c28
-rw-r--r--fs/ecryptfs/read_write.c22
-rw-r--r--fs/exec.c15
-rw-r--r--fs/ext3/resize.c3
-rw-r--r--fs/ext3/xattr.c5
-rw-r--r--fs/ext4/balloc.c88
-rw-r--r--fs/ext4/mballoc.c80
-rw-r--r--fs/ext4/resize.c3
-rw-r--r--fs/ext4/super.c116
-rw-r--r--fs/ext4/xattr.c5
-rw-r--r--fs/fat/file.c44
-rw-r--r--fs/file.c152
-rw-r--r--fs/fuse/file.c2
-rw-r--r--fs/fuse/fuse_i.h3
-rw-r--r--fs/fuse/inode.c12
-rw-r--r--fs/gfs2/glops.c2
-rw-r--r--fs/gfs2/incore.h1
-rw-r--r--fs/gfs2/inode.c10
-rw-r--r--fs/gfs2/meta_io.c6
-rw-r--r--fs/gfs2/ops_fstype.c4
-rw-r--r--fs/gfs2/ops_super.c16
-rw-r--r--fs/gfs2/rgrp.c2
-rw-r--r--fs/hfsplus/inode.c2
-rw-r--r--fs/hppfs/Makefile5
-rw-r--r--fs/hppfs/hppfs.c (renamed from fs/hppfs/hppfs_kern.c)82
-rw-r--r--fs/jbd/commit.c2
-rw-r--r--fs/jbd2/commit.c3
-rw-r--r--fs/jbd2/journal.c4
-rw-r--r--fs/jbd2/recovery.c12
-rw-r--r--fs/libfs.c18
-rw-r--r--fs/namei.c12
-rw-r--r--fs/nfs/callback.c2
-rw-r--r--fs/nfs/callback_proc.c4
-rw-r--r--fs/nfs/callback_xdr.c40
-rw-r--r--fs/nfs/client.c8
-rw-r--r--fs/nfs/delegation.c4
-rw-r--r--fs/nfs/dir.c18
-rw-r--r--fs/nfs/file.c2
-rw-r--r--fs/nfs/inode.c14
-rw-r--r--fs/nfs/namespace.c11
-rw-r--r--fs/nfs/nfs3proc.c6
-rw-r--r--fs/nfs/nfs4_fs.h1
-rw-r--r--fs/nfs/nfs4namespace.c12
-rw-r--r--fs/nfs/nfs4proc.c38
-rw-r--r--fs/nfs/nfs4renewd.c10
-rw-r--r--fs/nfs/nfs4state.c8
-rw-r--r--fs/nfs/nfs4xdr.c100
-rw-r--r--fs/nfs/proc.c8
-rw-r--r--fs/nfs/read.c2
-rw-r--r--fs/nfs/super.c12
-rw-r--r--fs/nfs/write.c2
-rw-r--r--fs/nfsd/nfs4callback.c2
-rw-r--r--fs/ntfs/upcase.c5
-rw-r--r--fs/ocfs2/alloc.c4
-rw-r--r--fs/ocfs2/cluster/tcp.c28
-rw-r--r--fs/ocfs2/cluster/tcp.h12
-rw-r--r--fs/ocfs2/cluster/tcp_internal.h32
-rw-r--r--fs/ocfs2/dlm/dlmdebug.h12
-rw-r--r--fs/ocfs2/stack_user.c34
-rw-r--r--fs/proc/array.c3
-rw-r--r--fs/proc/base.c35
-rw-r--r--fs/proc/inode.c3
-rw-r--r--fs/proc/proc_misc.c8
-rw-r--r--fs/proc/task_mmu.c111
-rw-r--r--fs/splice.c17
-rw-r--r--fs/sysfs/dir.c6
-rw-r--r--fs/ufs/ufs.h1
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c24
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.h19
-rw-r--r--fs/xfs/linux-2.6/xfs_file.c17
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.h8
-rw-r--r--fs/xfs/xfs_inode.c9
-rw-r--r--fs/xfs/xfs_vnodeops.c112
-rw-r--r--fs/xfs/xfs_vnodeops.h3
125 files changed, 2062 insertions, 1421 deletions
diff --git a/fs/9p/fid.h b/fs/9p/fid.h
index 26e07df783b9..c3bbd6af996d 100644
--- a/fs/9p/fid.h
+++ b/fs/9p/fid.h
@@ -22,6 +22,21 @@
22 22
23#include <linux/list.h> 23#include <linux/list.h>
24 24
25/**
26 * struct v9fs_dentry - 9p private data stored in dentry d_fsdata
27 * @lock: protects the fidlist
28 * @fidlist: list of FIDs currently associated with this dentry
29 *
30 * This structure defines the 9p private data associated with
31 * a particular dentry. In particular, this private data is used
32 * to lookup which 9P FID handle should be used for a particular VFS
33 * operation. FID handles are associated with dentries instead of
34 * inodes in order to more closely map functionality to the Plan 9
35 * expected behavior for FID reclaimation and tracking.
36 *
37 * See Also: Mapping FIDs to Linux VFS model in
38 * Design and Implementation of the Linux 9P File System documentation
39 */
25struct v9fs_dentry { 40struct v9fs_dentry {
26 spinlock_t lock; /* protect fidlist */ 41 spinlock_t lock; /* protect fidlist */
27 struct list_head fidlist; 42 struct list_head fidlist;
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
index 9b0f0222e8bb..047c791427aa 100644
--- a/fs/9p/v9fs.c
+++ b/fs/9p/v9fs.c
@@ -71,19 +71,19 @@ static match_table_t tokens = {
71 71
72/** 72/**
73 * v9fs_parse_options - parse mount options into session structure 73 * v9fs_parse_options - parse mount options into session structure
74 * @options: options string passed from mount
75 * @v9ses: existing v9fs session information 74 * @v9ses: existing v9fs session information
76 * 75 *
76 * Return 0 upon success, -ERRNO upon failure.
77 */ 77 */
78 78
79static void v9fs_parse_options(struct v9fs_session_info *v9ses) 79static int v9fs_parse_options(struct v9fs_session_info *v9ses)
80{ 80{
81 char *options; 81 char *options;
82 substring_t args[MAX_OPT_ARGS]; 82 substring_t args[MAX_OPT_ARGS];
83 char *p; 83 char *p;
84 int option = 0; 84 int option = 0;
85 char *s, *e; 85 char *s, *e;
86 int ret; 86 int ret = 0;
87 87
88 /* setup defaults */ 88 /* setup defaults */
89 v9ses->afid = ~0; 89 v9ses->afid = ~0;
@@ -91,19 +91,26 @@ static void v9fs_parse_options(struct v9fs_session_info *v9ses)
91 v9ses->cache = 0; 91 v9ses->cache = 0;
92 92
93 if (!v9ses->options) 93 if (!v9ses->options)
94 return; 94 return 0;
95 95
96 options = kstrdup(v9ses->options, GFP_KERNEL); 96 options = kstrdup(v9ses->options, GFP_KERNEL);
97 if (!options) {
98 P9_DPRINTK(P9_DEBUG_ERROR,
99 "failed to allocate copy of option string\n");
100 return -ENOMEM;
101 }
102
97 while ((p = strsep(&options, ",")) != NULL) { 103 while ((p = strsep(&options, ",")) != NULL) {
98 int token; 104 int token;
99 if (!*p) 105 if (!*p)
100 continue; 106 continue;
101 token = match_token(p, tokens, args); 107 token = match_token(p, tokens, args);
102 if (token < Opt_uname) { 108 if (token < Opt_uname) {
103 ret = match_int(&args[0], &option); 109 int r = match_int(&args[0], &option);
104 if (ret < 0) { 110 if (r < 0) {
105 P9_DPRINTK(P9_DEBUG_ERROR, 111 P9_DPRINTK(P9_DEBUG_ERROR,
106 "integer field, but no integer?\n"); 112 "integer field, but no integer?\n");
113 ret = r;
107 continue; 114 continue;
108 } 115 }
109 } 116 }
@@ -125,10 +132,10 @@ static void v9fs_parse_options(struct v9fs_session_info *v9ses)
125 v9ses->afid = option; 132 v9ses->afid = option;
126 break; 133 break;
127 case Opt_uname: 134 case Opt_uname:
128 match_strcpy(v9ses->uname, &args[0]); 135 match_strlcpy(v9ses->uname, &args[0], PATH_MAX);
129 break; 136 break;
130 case Opt_remotename: 137 case Opt_remotename:
131 match_strcpy(v9ses->aname, &args[0]); 138 match_strlcpy(v9ses->aname, &args[0], PATH_MAX);
132 break; 139 break;
133 case Opt_nodevmap: 140 case Opt_nodevmap:
134 v9ses->nodev = 1; 141 v9ses->nodev = 1;
@@ -139,6 +146,13 @@ static void v9fs_parse_options(struct v9fs_session_info *v9ses)
139 146
140 case Opt_access: 147 case Opt_access:
141 s = match_strdup(&args[0]); 148 s = match_strdup(&args[0]);
149 if (!s) {
150 P9_DPRINTK(P9_DEBUG_ERROR,
151 "failed to allocate copy"
152 " of option argument\n");
153 ret = -ENOMEM;
154 break;
155 }
142 v9ses->flags &= ~V9FS_ACCESS_MASK; 156 v9ses->flags &= ~V9FS_ACCESS_MASK;
143 if (strcmp(s, "user") == 0) 157 if (strcmp(s, "user") == 0)
144 v9ses->flags |= V9FS_ACCESS_USER; 158 v9ses->flags |= V9FS_ACCESS_USER;
@@ -158,6 +172,7 @@ static void v9fs_parse_options(struct v9fs_session_info *v9ses)
158 } 172 }
159 } 173 }
160 kfree(options); 174 kfree(options);
175 return ret;
161} 176}
162 177
163/** 178/**
@@ -173,6 +188,7 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
173{ 188{
174 int retval = -EINVAL; 189 int retval = -EINVAL;
175 struct p9_fid *fid; 190 struct p9_fid *fid;
191 int rc;
176 192
177 v9ses->uname = __getname(); 193 v9ses->uname = __getname();
178 if (!v9ses->uname) 194 if (!v9ses->uname)
@@ -190,8 +206,21 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
190 v9ses->uid = ~0; 206 v9ses->uid = ~0;
191 v9ses->dfltuid = V9FS_DEFUID; 207 v9ses->dfltuid = V9FS_DEFUID;
192 v9ses->dfltgid = V9FS_DEFGID; 208 v9ses->dfltgid = V9FS_DEFGID;
193 v9ses->options = kstrdup(data, GFP_KERNEL); 209 if (data) {
194 v9fs_parse_options(v9ses); 210 v9ses->options = kstrdup(data, GFP_KERNEL);
211 if (!v9ses->options) {
212 P9_DPRINTK(P9_DEBUG_ERROR,
213 "failed to allocate copy of option string\n");
214 retval = -ENOMEM;
215 goto error;
216 }
217 }
218
219 rc = v9fs_parse_options(v9ses);
220 if (rc < 0) {
221 retval = rc;
222 goto error;
223 }
195 224
196 v9ses->clnt = p9_client_create(dev_name, v9ses->options); 225 v9ses->clnt = p9_client_create(dev_name, v9ses->options);
197 226
@@ -233,7 +262,6 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
233 return fid; 262 return fid;
234 263
235error: 264error:
236 v9fs_session_close(v9ses);
237 return ERR_PTR(retval); 265 return ERR_PTR(retval);
238} 266}
239 267
@@ -256,9 +284,12 @@ void v9fs_session_close(struct v9fs_session_info *v9ses)
256} 284}
257 285
258/** 286/**
259 * v9fs_session_cancel - mark transport as disconnected 287 * v9fs_session_cancel - terminate a session
260 * and cancel all pending requests. 288 * @v9ses: session to terminate
289 *
290 * mark transport as disconnected and cancel all pending requests.
261 */ 291 */
292
262void v9fs_session_cancel(struct v9fs_session_info *v9ses) { 293void v9fs_session_cancel(struct v9fs_session_info *v9ses) {
263 P9_DPRINTK(P9_DEBUG_ERROR, "cancel session %p\n", v9ses); 294 P9_DPRINTK(P9_DEBUG_ERROR, "cancel session %p\n", v9ses);
264 p9_client_disconnect(v9ses->clnt); 295 p9_client_disconnect(v9ses->clnt);
diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h
index 7d3a1018db52..a7d567192998 100644
--- a/fs/9p/v9fs.h
+++ b/fs/9p/v9fs.h
@@ -21,18 +21,69 @@
21 * 21 *
22 */ 22 */
23 23
24/* 24/**
25 * Session structure provides information for an opened session 25 * enum p9_session_flags - option flags for each 9P session
26 * 26 * @V9FS_EXTENDED: whether or not to use 9P2000.u extensions
27 */ 27 * @V9FS_ACCESS_SINGLE: only the mounting user can access the hierarchy
28 * @V9FS_ACCESS_USER: a new attach will be issued for every user (default)
29 * @V9FS_ACCESS_ANY: use a single attach for all users
30 * @V9FS_ACCESS_MASK: bit mask of different ACCESS options
31 *
32 * Session flags reflect options selected by users at mount time
33 */
34enum p9_session_flags {
35 V9FS_EXTENDED = 0x01,
36 V9FS_ACCESS_SINGLE = 0x02,
37 V9FS_ACCESS_USER = 0x04,
38 V9FS_ACCESS_ANY = 0x06,
39 V9FS_ACCESS_MASK = 0x06,
40};
41
42/* possible values of ->cache */
43/**
44 * enum p9_cache_modes - user specified cache preferences
45 * @CACHE_NONE: do not cache data, dentries, or directory contents (default)
46 * @CACHE_LOOSE: cache data, dentries, and directory contents w/no consistency
47 *
48 * eventually support loose, tight, time, session, default always none
49 */
50
51enum p9_cache_modes {
52 CACHE_NONE,
53 CACHE_LOOSE,
54};
55
56/**
57 * struct v9fs_session_info - per-instance session information
58 * @flags: session options of type &p9_session_flags
59 * @nodev: set to 1 to disable device mapping
60 * @debug: debug level
61 * @afid: authentication handle
62 * @cache: cache mode of type &p9_cache_modes
63 * @options: copy of options string given by user
64 * @uname: string user name to mount hierarchy as
65 * @aname: mount specifier for remote hierarchy
66 * @maxdata: maximum data to be sent/recvd per protocol message
67 * @dfltuid: default numeric userid to mount hierarchy as
68 * @dfltgid: default numeric groupid to mount hierarchy as
69 * @uid: if %V9FS_ACCESS_SINGLE, the numeric uid which mounted the hierarchy
70 * @clnt: reference to 9P network client instantiated for this session
71 * @debugfs_dir: reference to debugfs_dir which can be used for add'l debug
72 *
73 * This structure holds state for each session instance established during
74 * a sys_mount() .
75 *
76 * Bugs: there seems to be a lot of state which could be condensed and/or
77 * removed.
78 */
28 79
29struct v9fs_session_info { 80struct v9fs_session_info {
30 /* options */ 81 /* options */
31 unsigned char flags; /* session flags */ 82 unsigned char flags;
32 unsigned char nodev; /* set to 1 if no disable device mapping */ 83 unsigned char nodev;
33 unsigned short debug; /* debug level */ 84 unsigned short debug;
34 unsigned int afid; /* authentication fid */ 85 unsigned int afid;
35 unsigned int cache; /* cache mode */ 86 unsigned int cache;
36 87
37 char *options; /* copy of mount options */ 88 char *options; /* copy of mount options */
38 char *uname; /* user name to mount as */ 89 char *uname; /* user name to mount as */
@@ -45,22 +96,6 @@ struct v9fs_session_info {
45 struct dentry *debugfs_dir; 96 struct dentry *debugfs_dir;
46}; 97};
47 98
48/* session flags */
49enum {
50 V9FS_EXTENDED = 0x01, /* 9P2000.u */
51 V9FS_ACCESS_MASK = 0x06, /* access mask */
52 V9FS_ACCESS_SINGLE = 0x02, /* only one user can access the files */
53 V9FS_ACCESS_USER = 0x04, /* attache per user */
54 V9FS_ACCESS_ANY = 0x06, /* use the same attach for all users */
55};
56
57/* possible values of ->cache */
58/* eventually support loose, tight, time, session, default always none */
59enum {
60 CACHE_NONE, /* default */
61 CACHE_LOOSE, /* no consistency */
62};
63
64extern struct dentry *v9fs_debugfs_root; 99extern struct dentry *v9fs_debugfs_root;
65 100
66struct p9_fid *v9fs_session_init(struct v9fs_session_info *, const char *, 101struct p9_fid *v9fs_session_init(struct v9fs_session_info *, const char *,
diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
index 6248f0e727a3..97d3aed57983 100644
--- a/fs/9p/vfs_addr.c
+++ b/fs/9p/vfs_addr.c
@@ -43,7 +43,7 @@
43/** 43/**
44 * v9fs_vfs_readpage - read an entire page in from 9P 44 * v9fs_vfs_readpage - read an entire page in from 9P
45 * 45 *
46 * @file: file being read 46 * @filp: file being read
47 * @page: structure to page 47 * @page: structure to page
48 * 48 *
49 */ 49 */
diff --git a/fs/9p/vfs_dir.c b/fs/9p/vfs_dir.c
index 0924d4477da3..88e3787c6ea9 100644
--- a/fs/9p/vfs_dir.c
+++ b/fs/9p/vfs_dir.c
@@ -60,7 +60,7 @@ static inline int dt_type(struct p9_stat *mistat)
60 60
61/** 61/**
62 * v9fs_dir_readdir - read a directory 62 * v9fs_dir_readdir - read a directory
63 * @filep: opened file structure 63 * @filp: opened file structure
64 * @dirent: directory structure ??? 64 * @dirent: directory structure ???
65 * @filldir: function to populate directory structure ??? 65 * @filldir: function to populate directory structure ???
66 * 66 *
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index a616fff8906d..0d55affe37d4 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -90,10 +90,11 @@ int v9fs_file_open(struct inode *inode, struct file *file)
90 90
91/** 91/**
92 * v9fs_file_lock - lock a file (or directory) 92 * v9fs_file_lock - lock a file (or directory)
93 * @inode: inode to be opened 93 * @filp: file to be locked
94 * @file: file being opened 94 * @cmd: lock command
95 * @fl: file lock structure
95 * 96 *
96 * XXX - this looks like a local only lock, we should extend into 9P 97 * Bugs: this looks like a local only lock, we should extend into 9P
97 * by using open exclusive 98 * by using open exclusive
98 */ 99 */
99 100
@@ -118,7 +119,7 @@ static int v9fs_file_lock(struct file *filp, int cmd, struct file_lock *fl)
118 119
119/** 120/**
120 * v9fs_file_read - read from a file 121 * v9fs_file_read - read from a file
121 * @filep: file pointer to read 122 * @filp: file pointer to read
122 * @data: data buffer to read data into 123 * @data: data buffer to read data into
123 * @count: size of buffer 124 * @count: size of buffer
124 * @offset: offset at which to read data 125 * @offset: offset at which to read data
@@ -142,7 +143,7 @@ v9fs_file_read(struct file *filp, char __user * data, size_t count,
142 143
143/** 144/**
144 * v9fs_file_write - write to a file 145 * v9fs_file_write - write to a file
145 * @filep: file pointer to write 146 * @filp: file pointer to write
146 * @data: data buffer to write data from 147 * @data: data buffer to write data from
147 * @count: size of buffer 148 * @count: size of buffer
148 * @offset: offset at which to write data 149 * @offset: offset at which to write data
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 6a28842052ea..40fa807bd929 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -129,6 +129,12 @@ static int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode)
129 return res; 129 return res;
130} 130}
131 131
132/**
133 * v9fs_uflags2omode- convert posix open flags to plan 9 mode bits
134 * @uflags: flags to convert
135 *
136 */
137
132int v9fs_uflags2omode(int uflags) 138int v9fs_uflags2omode(int uflags)
133{ 139{
134 int ret; 140 int ret;
@@ -312,6 +318,14 @@ error:
312} 318}
313*/ 319*/
314 320
321/**
322 * v9fs_inode_from_fid - populate an inode by issuing a attribute request
323 * @v9ses: session information
324 * @fid: fid to issue attribute request for
325 * @sb: superblock on which to create inode
326 *
327 */
328
315static struct inode * 329static struct inode *
316v9fs_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid, 330v9fs_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid,
317 struct super_block *sb) 331 struct super_block *sb)
@@ -384,9 +398,12 @@ v9fs_open_created(struct inode *inode, struct file *file)
384 398
385/** 399/**
386 * v9fs_create - Create a file 400 * v9fs_create - Create a file
401 * @v9ses: session information
402 * @dir: directory that dentry is being created in
387 * @dentry: dentry that is being created 403 * @dentry: dentry that is being created
388 * @perm: create permissions 404 * @perm: create permissions
389 * @mode: open mode 405 * @mode: open mode
406 * @extension: 9p2000.u extension string to support devices, etc.
390 * 407 *
391 */ 408 */
392static struct p9_fid * 409static struct p9_fid *
@@ -461,7 +478,7 @@ error:
461 478
462/** 479/**
463 * v9fs_vfs_create - VFS hook to create files 480 * v9fs_vfs_create - VFS hook to create files
464 * @inode: directory inode that is being created 481 * @dir: directory inode that is being created
465 * @dentry: dentry that is being deleted 482 * @dentry: dentry that is being deleted
466 * @mode: create permissions 483 * @mode: create permissions
467 * @nd: path information 484 * @nd: path information
@@ -519,7 +536,7 @@ error:
519 536
520/** 537/**
521 * v9fs_vfs_mkdir - VFS mkdir hook to create a directory 538 * v9fs_vfs_mkdir - VFS mkdir hook to create a directory
522 * @inode: inode that is being unlinked 539 * @dir: inode that is being unlinked
523 * @dentry: dentry that is being unlinked 540 * @dentry: dentry that is being unlinked
524 * @mode: mode for new directory 541 * @mode: mode for new directory
525 * 542 *
@@ -703,9 +720,9 @@ done:
703 720
704/** 721/**
705 * v9fs_vfs_getattr - retrieve file metadata 722 * v9fs_vfs_getattr - retrieve file metadata
706 * @mnt - mount information 723 * @mnt: mount information
707 * @dentry - file to get attributes on 724 * @dentry: file to get attributes on
708 * @stat - metadata structure to populate 725 * @stat: metadata structure to populate
709 * 726 *
710 */ 727 */
711 728
@@ -928,7 +945,7 @@ done:
928/** 945/**
929 * v9fs_vfs_readlink - read a symlink's location 946 * v9fs_vfs_readlink - read a symlink's location
930 * @dentry: dentry for symlink 947 * @dentry: dentry for symlink
931 * @buf: buffer to load symlink location into 948 * @buffer: buffer to load symlink location into
932 * @buflen: length of buffer 949 * @buflen: length of buffer
933 * 950 *
934 */ 951 */
@@ -996,10 +1013,12 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
996 * v9fs_vfs_put_link - release a symlink path 1013 * v9fs_vfs_put_link - release a symlink path
997 * @dentry: dentry for symlink 1014 * @dentry: dentry for symlink
998 * @nd: nameidata 1015 * @nd: nameidata
1016 * @p: unused
999 * 1017 *
1000 */ 1018 */
1001 1019
1002static void v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p) 1020static void
1021v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
1003{ 1022{
1004 char *s = nd_get_link(nd); 1023 char *s = nd_get_link(nd);
1005 1024
@@ -1008,6 +1027,15 @@ static void v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void
1008 __putname(s); 1027 __putname(s);
1009} 1028}
1010 1029
1030/**
1031 * v9fs_vfs_mkspecial - create a special file
1032 * @dir: inode to create special file in
1033 * @dentry: dentry to create
1034 * @mode: mode to create special file
1035 * @extension: 9p2000.u format extension string representing special file
1036 *
1037 */
1038
1011static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry, 1039static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry,
1012 int mode, const char *extension) 1040 int mode, const char *extension)
1013{ 1041{
@@ -1037,7 +1065,7 @@ static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry,
1037 * @dentry: dentry for symlink 1065 * @dentry: dentry for symlink
1038 * @symname: symlink data 1066 * @symname: symlink data
1039 * 1067 *
1040 * See 9P2000.u RFC for more information 1068 * See Also: 9P2000.u RFC for more information
1041 * 1069 *
1042 */ 1070 */
1043 1071
@@ -1058,10 +1086,6 @@ v9fs_vfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
1058 * 1086 *
1059 */ 1087 */
1060 1088
1061/* XXX - lots of code dup'd from symlink and creates,
1062 * figure out a better reuse strategy
1063 */
1064
1065static int 1089static int
1066v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir, 1090v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir,
1067 struct dentry *dentry) 1091 struct dentry *dentry)
@@ -1098,7 +1122,7 @@ clunk_fid:
1098 * @dir: inode destination for new link 1122 * @dir: inode destination for new link
1099 * @dentry: dentry for file 1123 * @dentry: dentry for file
1100 * @mode: mode for creation 1124 * @mode: mode for creation
1101 * @dev_t: device associated with special file 1125 * @rdev: device associated with special file
1102 * 1126 *
1103 */ 1127 */
1104 1128
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
index a452ac67fc94..bf59c3960494 100644
--- a/fs/9p/vfs_super.c
+++ b/fs/9p/vfs_super.c
@@ -75,6 +75,7 @@ static int v9fs_set_super(struct super_block *s, void *data)
75 * v9fs_fill_super - populate superblock with info 75 * v9fs_fill_super - populate superblock with info
76 * @sb: superblock 76 * @sb: superblock
77 * @v9ses: session information 77 * @v9ses: session information
78 * @flags: flags propagated from v9fs_get_sb()
78 * 79 *
79 */ 80 */
80 81
@@ -127,29 +128,26 @@ static int v9fs_get_sb(struct file_system_type *fs_type, int flags,
127 fid = v9fs_session_init(v9ses, dev_name, data); 128 fid = v9fs_session_init(v9ses, dev_name, data);
128 if (IS_ERR(fid)) { 129 if (IS_ERR(fid)) {
129 retval = PTR_ERR(fid); 130 retval = PTR_ERR(fid);
130 fid = NULL; 131 goto close_session;
131 kfree(v9ses);
132 v9ses = NULL;
133 goto error;
134 } 132 }
135 133
136 st = p9_client_stat(fid); 134 st = p9_client_stat(fid);
137 if (IS_ERR(st)) { 135 if (IS_ERR(st)) {
138 retval = PTR_ERR(st); 136 retval = PTR_ERR(st);
139 goto error; 137 goto clunk_fid;
140 } 138 }
141 139
142 sb = sget(fs_type, NULL, v9fs_set_super, v9ses); 140 sb = sget(fs_type, NULL, v9fs_set_super, v9ses);
143 if (IS_ERR(sb)) { 141 if (IS_ERR(sb)) {
144 retval = PTR_ERR(sb); 142 retval = PTR_ERR(sb);
145 goto error; 143 goto free_stat;
146 } 144 }
147 v9fs_fill_super(sb, v9ses, flags); 145 v9fs_fill_super(sb, v9ses, flags);
148 146
149 inode = v9fs_get_inode(sb, S_IFDIR | mode); 147 inode = v9fs_get_inode(sb, S_IFDIR | mode);
150 if (IS_ERR(inode)) { 148 if (IS_ERR(inode)) {
151 retval = PTR_ERR(inode); 149 retval = PTR_ERR(inode);
152 goto error; 150 goto release_sb;
153 } 151 }
154 152
155 inode->i_uid = uid; 153 inode->i_uid = uid;
@@ -158,7 +156,7 @@ static int v9fs_get_sb(struct file_system_type *fs_type, int flags,
158 root = d_alloc_root(inode); 156 root = d_alloc_root(inode);
159 if (!root) { 157 if (!root) {
160 retval = -ENOMEM; 158 retval = -ENOMEM;
161 goto error; 159 goto release_sb;
162 } 160 }
163 161
164 sb->s_root = root; 162 sb->s_root = root;
@@ -169,21 +167,22 @@ static int v9fs_get_sb(struct file_system_type *fs_type, int flags,
169 167
170 return simple_set_mnt(mnt, sb); 168 return simple_set_mnt(mnt, sb);
171 169
172error: 170release_sb:
173 kfree(st);
174 if (fid)
175 p9_client_clunk(fid);
176
177 if (v9ses) {
178 v9fs_session_close(v9ses);
179 kfree(v9ses);
180 }
181
182 if (sb) { 171 if (sb) {
183 up_write(&sb->s_umount); 172 up_write(&sb->s_umount);
184 deactivate_super(sb); 173 deactivate_super(sb);
185 } 174 }
186 175
176free_stat:
177 kfree(st);
178
179clunk_fid:
180 p9_client_clunk(fid);
181
182close_session:
183 v9fs_session_close(v9ses);
184 kfree(v9ses);
185
187 return retval; 186 return retval;
188} 187}
189 188
diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
index 55e8ee1900a5..3263084eef9e 100644
--- a/fs/Kconfig.binfmt
+++ b/fs/Kconfig.binfmt
@@ -42,7 +42,7 @@ config BINFMT_ELF_FDPIC
42 42
43config BINFMT_FLAT 43config BINFMT_FLAT
44 bool "Kernel support for flat binaries" 44 bool "Kernel support for flat binaries"
45 depends on !MMU 45 depends on !MMU && (!FRV || BROKEN)
46 help 46 help
47 Support uClinux FLAT format binaries. 47 Support uClinux FLAT format binaries.
48 48
diff --git a/fs/afs/callback.c b/fs/afs/callback.c
index a78d5b236bb1..587ef5123cd8 100644
--- a/fs/afs/callback.c
+++ b/fs/afs/callback.c
@@ -8,7 +8,7 @@
8 * along with this program; if not, write to the Free Software 8 * along with this program; if not, write to the Free Software
9 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 9 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
10 * 10 *
11 * Authors: David Woodhouse <dwmw2@cambridge.redhat.com> 11 * Authors: David Woodhouse <dwmw2@infradead.org>
12 * David Howells <dhowells@redhat.com> 12 * David Howells <dhowells@redhat.com>
13 * 13 *
14 */ 14 */
diff --git a/fs/afs/inode.c b/fs/afs/inode.c
index 08db82e1343a..bb47217f6a18 100644
--- a/fs/afs/inode.c
+++ b/fs/afs/inode.c
@@ -8,7 +8,7 @@
8 * along with this program; if not, write to the Free Software 8 * along with this program; if not, write to the Free Software
9 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 9 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
10 * 10 *
11 * Authors: David Woodhouse <dwmw2@cambridge.redhat.com> 11 * Authors: David Woodhouse <dwmw2@infradead.org>
12 * David Howells <dhowells@redhat.com> 12 * David Howells <dhowells@redhat.com>
13 * 13 *
14 */ 14 */
diff --git a/fs/afs/super.c b/fs/afs/super.c
index 4b572b801d8d..7e3faeef6818 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -10,7 +10,7 @@
10 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 10 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
11 * 11 *
12 * Authors: David Howells <dhowells@redhat.com> 12 * Authors: David Howells <dhowells@redhat.com>
13 * David Woodhouse <dwmw2@redhat.com> 13 * David Woodhouse <dwmw2@infradead.org>
14 * 14 *
15 */ 15 */
16 16
diff --git a/fs/aio.c b/fs/aio.c
index b5253e77eb2f..0fb3117ddd93 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -591,10 +591,6 @@ static void use_mm(struct mm_struct *mm)
591 atomic_inc(&mm->mm_count); 591 atomic_inc(&mm->mm_count);
592 tsk->mm = mm; 592 tsk->mm = mm;
593 tsk->active_mm = mm; 593 tsk->active_mm = mm;
594 /*
595 * Note that on UML this *requires* PF_BORROWED_MM to be set, otherwise
596 * it won't work. Update it accordingly if you change it here
597 */
598 switch_mm(active_mm, mm, tsk); 594 switch_mm(active_mm, mm, tsk);
599 task_unlock(tsk); 595 task_unlock(tsk);
600 596
diff --git a/fs/befs/endian.h b/fs/befs/endian.h
index e254a20869f4..6cb84d896d05 100644
--- a/fs/befs/endian.h
+++ b/fs/befs/endian.h
@@ -9,7 +9,7 @@
9#ifndef LINUX_BEFS_ENDIAN 9#ifndef LINUX_BEFS_ENDIAN
10#define LINUX_BEFS_ENDIAN 10#define LINUX_BEFS_ENDIAN
11 11
12#include <linux/byteorder/generic.h> 12#include <asm/byteorder.h>
13 13
14static inline u64 14static inline u64
15fs64_to_cpu(const struct super_block *sb, fs64 n) 15fs64_to_cpu(const struct super_block *sb, fs64 n)
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index b25707fee2cc..0fa95b198e6e 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -256,7 +256,7 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
256 return -EFAULT; 256 return -EFAULT;
257 len = strnlen_user((void __user *)p, MAX_ARG_STRLEN); 257 len = strnlen_user((void __user *)p, MAX_ARG_STRLEN);
258 if (!len || len > MAX_ARG_STRLEN) 258 if (!len || len > MAX_ARG_STRLEN)
259 return 0; 259 return -EINVAL;
260 p += len; 260 p += len;
261 } 261 }
262 if (__put_user(0, argv)) 262 if (__put_user(0, argv))
@@ -268,7 +268,7 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
268 return -EFAULT; 268 return -EFAULT;
269 len = strnlen_user((void __user *)p, MAX_ARG_STRLEN); 269 len = strnlen_user((void __user *)p, MAX_ARG_STRLEN);
270 if (!len || len > MAX_ARG_STRLEN) 270 if (!len || len > MAX_ARG_STRLEN)
271 return 0; 271 return -EINVAL;
272 p += len; 272 p += len;
273 } 273 }
274 if (__put_user(0, envp)) 274 if (__put_user(0, envp))
@@ -1900,7 +1900,7 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, un
1900 /* alloc memory for large data structures: too large to be on stack */ 1900 /* alloc memory for large data structures: too large to be on stack */
1901 elf = kmalloc(sizeof(*elf), GFP_KERNEL); 1901 elf = kmalloc(sizeof(*elf), GFP_KERNEL);
1902 if (!elf) 1902 if (!elf)
1903 goto cleanup; 1903 goto out;
1904 1904
1905 segs = current->mm->map_count; 1905 segs = current->mm->map_count;
1906#ifdef ELF_CORE_EXTRA_PHDRS 1906#ifdef ELF_CORE_EXTRA_PHDRS
@@ -2034,8 +2034,9 @@ end_coredump:
2034 set_fs(fs); 2034 set_fs(fs);
2035 2035
2036cleanup: 2036cleanup:
2037 kfree(elf);
2038 free_note_info(&info); 2037 free_note_info(&info);
2038 kfree(elf);
2039out:
2039 return has_dumped; 2040 return has_dumped;
2040} 2041}
2041 2042
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index ddd35d873391..d051a32e6270 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -390,7 +390,7 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm,
390 } 390 }
391 391
392 /* expand the stack mapping to use up the entire allocation granule */ 392 /* expand the stack mapping to use up the entire allocation granule */
393 fullsize = ksize((char *) current->mm->start_brk); 393 fullsize = kobjsize((char *) current->mm->start_brk);
394 if (!IS_ERR_VALUE(do_mremap(current->mm->start_brk, stack_size, 394 if (!IS_ERR_VALUE(do_mremap(current->mm->start_brk, stack_size,
395 fullsize, 0, 0))) 395 fullsize, 0, 0)))
396 stack_size = fullsize; 396 stack_size = fullsize;
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
index 3b40d45a3a16..2cb1acda3a82 100644
--- a/fs/binfmt_flat.c
+++ b/fs/binfmt_flat.c
@@ -548,7 +548,7 @@ static int load_flat_file(struct linux_binprm * bprm,
548 PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, 0); 548 PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, 0);
549 /* Remap to use all availabe slack region space */ 549 /* Remap to use all availabe slack region space */
550 if (realdatastart && (realdatastart < (unsigned long)-4096)) { 550 if (realdatastart && (realdatastart < (unsigned long)-4096)) {
551 reallen = ksize((void *)realdatastart); 551 reallen = kobjsize((void *)realdatastart);
552 if (reallen > len) { 552 if (reallen > len) {
553 realdatastart = do_mremap(realdatastart, len, 553 realdatastart = do_mremap(realdatastart, len,
554 reallen, MREMAP_FIXED, realdatastart); 554 reallen, MREMAP_FIXED, realdatastart);
@@ -600,7 +600,7 @@ static int load_flat_file(struct linux_binprm * bprm,
600 PROT_READ | PROT_EXEC | PROT_WRITE, MAP_PRIVATE, 0); 600 PROT_READ | PROT_EXEC | PROT_WRITE, MAP_PRIVATE, 0);
601 /* Remap to use all availabe slack region space */ 601 /* Remap to use all availabe slack region space */
602 if (textpos && (textpos < (unsigned long) -4096)) { 602 if (textpos && (textpos < (unsigned long) -4096)) {
603 reallen = ksize((void *)textpos); 603 reallen = kobjsize((void *)textpos);
604 if (reallen > len) { 604 if (reallen > len) {
605 textpos = do_mremap(textpos, len, reallen, 605 textpos = do_mremap(textpos, len, reallen,
606 MREMAP_FIXED, textpos); 606 MREMAP_FIXED, textpos);
@@ -683,7 +683,7 @@ static int load_flat_file(struct linux_binprm * bprm,
683 */ 683 */
684 current->mm->start_brk = datapos + data_len + bss_len; 684 current->mm->start_brk = datapos + data_len + bss_len;
685 current->mm->brk = (current->mm->start_brk + 3) & ~3; 685 current->mm->brk = (current->mm->start_brk + 3) & ~3;
686 current->mm->context.end_brk = memp + ksize((void *) memp) - stack_len; 686 current->mm->context.end_brk = memp + kobjsize((void *) memp) - stack_len;
687 } 687 }
688 688
689 if (flags & FLAT_FLAG_KTRACE) 689 if (flags & FLAT_FLAG_KTRACE)
@@ -790,7 +790,7 @@ static int load_flat_file(struct linux_binprm * bprm,
790 790
791 /* zero the BSS, BRK and stack areas */ 791 /* zero the BSS, BRK and stack areas */
792 memset((void*)(datapos + data_len), 0, bss_len + 792 memset((void*)(datapos + data_len), 0, bss_len +
793 (memp + ksize((void *) memp) - stack_len - /* end brk */ 793 (memp + kobjsize((void *) memp) - stack_len - /* end brk */
794 libinfo->lib_list[id].start_brk) + /* start brk */ 794 libinfo->lib_list[id].start_brk) + /* start brk */
795 stack_len); 795 stack_len);
796 796
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 7d822fae7765..470c10ceb0fb 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -12,6 +12,7 @@
12#include <linux/kmod.h> 12#include <linux/kmod.h>
13#include <linux/major.h> 13#include <linux/major.h>
14#include <linux/smp_lock.h> 14#include <linux/smp_lock.h>
15#include <linux/device_cgroup.h>
15#include <linux/highmem.h> 16#include <linux/highmem.h>
16#include <linux/blkdev.h> 17#include <linux/blkdev.h>
17#include <linux/module.h> 18#include <linux/module.h>
@@ -928,9 +929,14 @@ static int do_open(struct block_device *bdev, struct file *file, int for_part)
928{ 929{
929 struct module *owner = NULL; 930 struct module *owner = NULL;
930 struct gendisk *disk; 931 struct gendisk *disk;
931 int ret = -ENXIO; 932 int ret;
932 int part; 933 int part;
933 934
935 ret = devcgroup_inode_permission(bdev->bd_inode, file->f_mode);
936 if (ret != 0)
937 return ret;
938
939 ret = -ENXIO;
934 file->f_mapping = bdev->bd_inode->i_mapping; 940 file->f_mapping = bdev->bd_inode->i_mapping;
935 lock_kernel(); 941 lock_kernel();
936 disk = get_gendisk(bdev->bd_dev, &part); 942 disk = get_gendisk(bdev->bd_dev, &part);
diff --git a/fs/cifs/AUTHORS b/fs/cifs/AUTHORS
index 8848e4dfa026..9c136d7803d9 100644
--- a/fs/cifs/AUTHORS
+++ b/fs/cifs/AUTHORS
@@ -36,6 +36,7 @@ Miklos Szeredi
36Kazeon team for various fixes especially for 2.4 version. 36Kazeon team for various fixes especially for 2.4 version.
37Asser Ferno (Change Notify support) 37Asser Ferno (Change Notify support)
38Shaggy (Dave Kleikamp) for inumerable small fs suggestions and some good cleanup 38Shaggy (Dave Kleikamp) for inumerable small fs suggestions and some good cleanup
39Igor Mammedov (DFS support)
39 40
40Test case and Bug Report contributors 41Test case and Bug Report contributors
41------------------------------------- 42-------------------------------------
diff --git a/fs/cifs/CHANGES b/fs/cifs/CHANGES
index 8355e918fddf..1f3465201fdf 100644
--- a/fs/cifs/CHANGES
+++ b/fs/cifs/CHANGES
@@ -1,5 +1,12 @@
1Version 1.53 1Version 1.53
2------------ 2------------
3DFS support added (Microsoft Distributed File System client support needed
4for referrals which enable a hierarchical name space among servers).
5Disable temporary caching of mode bits to servers which do not support
6storing of mode (e.g. Windows servers, when client mounts without cifsacl
7mount option) and add new "dynperm" mount option to enable temporary caching
8of mode (enable old behavior). Fix hang on mount caused when server crashes
9tcp session during negotiate protocol.
3 10
4Version 1.52 11Version 1.52
5------------ 12------------
@@ -12,7 +19,8 @@ Add ability to modify cifs acls for handling chmod (when mounted with
12cifsacl flag). Fix prefixpath path separator so we can handle mounts 19cifsacl flag). Fix prefixpath path separator so we can handle mounts
13with prefixpaths longer than one directory (one path component) when 20with prefixpaths longer than one directory (one path component) when
14mounted to Windows servers. Fix slow file open when cifsacl 21mounted to Windows servers. Fix slow file open when cifsacl
15enabled. 22enabled. Fix memory leak in FindNext when the SMB call returns -EBADF.
23
16 24
17Version 1.51 25Version 1.51
18------------ 26------------
diff --git a/fs/cifs/README b/fs/cifs/README
index 621aa1a85971..2bd6fe556f88 100644
--- a/fs/cifs/README
+++ b/fs/cifs/README
@@ -483,6 +483,11 @@ A partial list of the supported mount options follows:
483 sign Must use packet signing (helps avoid unwanted data modification 483 sign Must use packet signing (helps avoid unwanted data modification
484 by intermediate systems in the route). Note that signing 484 by intermediate systems in the route). Note that signing
485 does not work with lanman or plaintext authentication. 485 does not work with lanman or plaintext authentication.
486 seal Must seal (encrypt) all data on this mounted share before
487 sending on the network. Requires support for Unix Extensions.
488 Note that this differs from the sign mount option in that it
489 causes encryption of data sent over this mounted share but other
490 shares mounted to the same server are unaffected.
486 sec Security mode. Allowed values are: 491 sec Security mode. Allowed values are:
487 none attempt to connection as a null user (no name) 492 none attempt to connection as a null user (no name)
488 krb5 Use Kerberos version 5 authentication 493 krb5 Use Kerberos version 5 authentication
diff --git a/fs/cifs/TODO b/fs/cifs/TODO
index 92c9feac440f..5aff46c61e52 100644
--- a/fs/cifs/TODO
+++ b/fs/cifs/TODO
@@ -1,4 +1,4 @@
1Version 1.52 January 3, 2008 1Version 1.53 May 20, 2008
2 2
3A Partial List of Missing Features 3A Partial List of Missing Features
4================================== 4==================================
@@ -20,20 +20,21 @@ d) Cleanup now unneeded SessSetup code in
20fs/cifs/connect.c and add back in NTLMSSP code if any servers 20fs/cifs/connect.c and add back in NTLMSSP code if any servers
21need it 21need it
22 22
23e) ms-dfs and ms-dfs host name resolution cleanup 23e) fix NTLMv2 signing when two mounts with different users to same
24
25f) fix NTLMv2 signing when two mounts with different users to same
26server. 24server.
27 25
28g) Directory entry caching relies on a 1 second timer, rather than 26f) Directory entry caching relies on a 1 second timer, rather than
29using FindNotify or equivalent. - (started) 27using FindNotify or equivalent. - (started)
30 28
31h) quota support (needs minor kernel change since quota calls 29g) quota support (needs minor kernel change since quota calls
32to make it to network filesystems or deviceless filesystems) 30to make it to network filesystems or deviceless filesystems)
33 31
34i) investigate sync behavior (including syncpage) and check 32h) investigate sync behavior (including syncpage) and check
35for proper behavior of intr/nointr 33for proper behavior of intr/nointr
36 34
35i) improve support for very old servers (OS/2 and Win9x for example)
36Including support for changing the time remotely (utimes command).
37
37j) hook lower into the sockets api (as NFS/SunRPC does) to avoid the 38j) hook lower into the sockets api (as NFS/SunRPC does) to avoid the
38extra copy in/out of the socket buffers in some cases. 39extra copy in/out of the socket buffers in some cases.
39 40
diff --git a/fs/cifs/asn1.c b/fs/cifs/asn1.c
index cb52cbbe45ff..f58e41d3ba48 100644
--- a/fs/cifs/asn1.c
+++ b/fs/cifs/asn1.c
@@ -186,6 +186,11 @@ asn1_length_decode(struct asn1_ctx *ctx, unsigned int *def, unsigned int *len)
186 } 186 }
187 } 187 }
188 } 188 }
189
190 /* don't trust len bigger than ctx buffer */
191 if (*len > ctx->end - ctx->pointer)
192 return 0;
193
189 return 1; 194 return 1;
190} 195}
191 196
@@ -203,6 +208,10 @@ asn1_header_decode(struct asn1_ctx *ctx,
203 if (!asn1_length_decode(ctx, &def, &len)) 208 if (!asn1_length_decode(ctx, &def, &len))
204 return 0; 209 return 0;
205 210
211 /* primitive shall be definite, indefinite shall be constructed */
212 if (*con == ASN1_PRI && !def)
213 return 0;
214
206 if (def) 215 if (def)
207 *eoc = ctx->pointer + len; 216 *eoc = ctx->pointer + len;
208 else 217 else
@@ -389,6 +398,11 @@ asn1_oid_decode(struct asn1_ctx *ctx,
389 unsigned long *optr; 398 unsigned long *optr;
390 399
391 size = eoc - ctx->pointer + 1; 400 size = eoc - ctx->pointer + 1;
401
402 /* first subid actually encodes first two subids */
403 if (size < 2 || size > ULONG_MAX/sizeof(unsigned long))
404 return 0;
405
392 *oid = kmalloc(size * sizeof(unsigned long), GFP_ATOMIC); 406 *oid = kmalloc(size * sizeof(unsigned long), GFP_ATOMIC);
393 if (*oid == NULL) 407 if (*oid == NULL)
394 return 0; 408 return 0;
diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c
index f6fdecf6598c..d82374c9e329 100644
--- a/fs/cifs/cifs_dfs_ref.c
+++ b/fs/cifs/cifs_dfs_ref.c
@@ -219,53 +219,6 @@ static struct vfsmount *cifs_dfs_do_refmount(const struct vfsmount *mnt_parent,
219 219
220} 220}
221 221
222static char *build_full_dfs_path_from_dentry(struct dentry *dentry)
223{
224 char *full_path = NULL;
225 char *search_path;
226 char *tmp_path;
227 size_t l_max_len;
228 struct cifs_sb_info *cifs_sb;
229
230 if (dentry->d_inode == NULL)
231 return NULL;
232
233 cifs_sb = CIFS_SB(dentry->d_inode->i_sb);
234
235 if (cifs_sb->tcon == NULL)
236 return NULL;
237
238 search_path = build_path_from_dentry(dentry);
239 if (search_path == NULL)
240 return NULL;
241
242 if (cifs_sb->tcon->Flags & SMB_SHARE_IS_IN_DFS) {
243 int i;
244 /* we should use full path name for correct working with DFS */
245 l_max_len = strnlen(cifs_sb->tcon->treeName, MAX_TREE_SIZE+1) +
246 strnlen(search_path, MAX_PATHCONF) + 1;
247 tmp_path = kmalloc(l_max_len, GFP_KERNEL);
248 if (tmp_path == NULL) {
249 kfree(search_path);
250 return NULL;
251 }
252 strncpy(tmp_path, cifs_sb->tcon->treeName, l_max_len);
253 tmp_path[l_max_len-1] = 0;
254 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
255 for (i = 0; i < l_max_len; i++) {
256 if (tmp_path[i] == '\\')
257 tmp_path[i] = '/';
258 }
259 strncat(tmp_path, search_path, l_max_len - strlen(tmp_path));
260
261 full_path = tmp_path;
262 kfree(search_path);
263 } else {
264 full_path = search_path;
265 }
266 return full_path;
267}
268
269static int add_mount_helper(struct vfsmount *newmnt, struct nameidata *nd, 222static int add_mount_helper(struct vfsmount *newmnt, struct nameidata *nd,
270 struct list_head *mntlist) 223 struct list_head *mntlist)
271{ 224{
@@ -333,7 +286,7 @@ cifs_dfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd)
333 goto out_err; 286 goto out_err;
334 } 287 }
335 288
336 full_path = build_full_dfs_path_from_dentry(dentry); 289 full_path = build_path_from_dentry(dentry);
337 if (full_path == NULL) { 290 if (full_path == NULL) {
338 rc = -ENOMEM; 291 rc = -ENOMEM;
339 goto out_err; 292 goto out_err;
diff --git a/fs/cifs/cifs_fs_sb.h b/fs/cifs/cifs_fs_sb.h
index 8ad2330ba061..877c85409f1f 100644
--- a/fs/cifs/cifs_fs_sb.h
+++ b/fs/cifs/cifs_fs_sb.h
@@ -30,6 +30,7 @@
30#define CIFS_MOUNT_CIFS_ACL 0x200 /* send ACL requests to non-POSIX srv */ 30#define CIFS_MOUNT_CIFS_ACL 0x200 /* send ACL requests to non-POSIX srv */
31#define CIFS_MOUNT_OVERR_UID 0x400 /* override uid returned from server */ 31#define CIFS_MOUNT_OVERR_UID 0x400 /* override uid returned from server */
32#define CIFS_MOUNT_OVERR_GID 0x800 /* override gid returned from server */ 32#define CIFS_MOUNT_OVERR_GID 0x800 /* override gid returned from server */
33#define CIFS_MOUNT_DYNPERM 0x1000 /* allow in-memory only mode setting */
33 34
34struct cifs_sb_info { 35struct cifs_sb_info {
35 struct cifsTconInfo *tcon; /* primary mount */ 36 struct cifsTconInfo *tcon; /* primary mount */
diff --git a/fs/cifs/cifs_spnego.c b/fs/cifs/cifs_spnego.c
index 6653e29637a7..7013aaff6aed 100644
--- a/fs/cifs/cifs_spnego.c
+++ b/fs/cifs/cifs_spnego.c
@@ -119,6 +119,9 @@ cifs_get_spnego_key(struct cifsSesInfo *sesInfo)
119 dp = description + strlen(description); 119 dp = description + strlen(description);
120 sprintf(dp, ";uid=0x%x", sesInfo->linux_uid); 120 sprintf(dp, ";uid=0x%x", sesInfo->linux_uid);
121 121
122 dp = description + strlen(description);
123 sprintf(dp, ";user=%s", sesInfo->userName);
124
122 cFYI(1, ("key description = %s", description)); 125 cFYI(1, ("key description = %s", description));
123 spnego_key = request_key(&cifs_spnego_key_type, description, ""); 126 spnego_key = request_key(&cifs_spnego_key_type, description, "");
124 127
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 427a7c695896..86b4d5f405ae 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * fs/cifs/cifsfs.c 2 * fs/cifs/cifsfs.c
3 * 3 *
4 * Copyright (C) International Business Machines Corp., 2002,2007 4 * Copyright (C) International Business Machines Corp., 2002,2008
5 * Author(s): Steve French (sfrench@us.ibm.com) 5 * Author(s): Steve French (sfrench@us.ibm.com)
6 * 6 *
7 * Common Internet FileSystem (CIFS) client 7 * Common Internet FileSystem (CIFS) client
@@ -97,9 +97,6 @@ cifs_read_super(struct super_block *sb, void *data,
97{ 97{
98 struct inode *inode; 98 struct inode *inode;
99 struct cifs_sb_info *cifs_sb; 99 struct cifs_sb_info *cifs_sb;
100#ifdef CONFIG_CIFS_DFS_UPCALL
101 int len;
102#endif
103 int rc = 0; 100 int rc = 0;
104 101
105 /* BB should we make this contingent on mount parm? */ 102 /* BB should we make this contingent on mount parm? */
@@ -117,15 +114,17 @@ cifs_read_super(struct super_block *sb, void *data,
117 * complex operation (mount), and in case of fail 114 * complex operation (mount), and in case of fail
118 * just exit instead of doing mount and attempting 115 * just exit instead of doing mount and attempting
119 * undo it if this copy fails?*/ 116 * undo it if this copy fails?*/
120 len = strlen(data); 117 if (data) {
121 cifs_sb->mountdata = kzalloc(len + 1, GFP_KERNEL); 118 int len = strlen(data);
122 if (cifs_sb->mountdata == NULL) { 119 cifs_sb->mountdata = kzalloc(len + 1, GFP_KERNEL);
123 kfree(sb->s_fs_info); 120 if (cifs_sb->mountdata == NULL) {
124 sb->s_fs_info = NULL; 121 kfree(sb->s_fs_info);
125 return -ENOMEM; 122 sb->s_fs_info = NULL;
123 return -ENOMEM;
124 }
125 strncpy(cifs_sb->mountdata, data, len + 1);
126 cifs_sb->mountdata[len] = '\0';
126 } 127 }
127 strncpy(cifs_sb->mountdata, data, len + 1);
128 cifs_sb->mountdata[len] = '\0';
129#endif 128#endif
130 129
131 rc = cifs_mount(sb, cifs_sb, data, devname); 130 rc = cifs_mount(sb, cifs_sb, data, devname);
@@ -353,9 +352,41 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m)
353 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID) || 352 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID) ||
354 !(cifs_sb->tcon->unix_ext)) 353 !(cifs_sb->tcon->unix_ext))
355 seq_printf(s, ",gid=%d", cifs_sb->mnt_gid); 354 seq_printf(s, ",gid=%d", cifs_sb->mnt_gid);
355 if (!cifs_sb->tcon->unix_ext) {
356 seq_printf(s, ",file_mode=0%o,dir_mode=0%o",
357 cifs_sb->mnt_file_mode,
358 cifs_sb->mnt_dir_mode);
359 }
360 if (cifs_sb->tcon->seal)
361 seq_printf(s, ",seal");
362 if (cifs_sb->tcon->nocase)
363 seq_printf(s, ",nocase");
364 if (cifs_sb->tcon->retry)
365 seq_printf(s, ",hard");
356 } 366 }
357 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) 367 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
358 seq_printf(s, ",posixpaths"); 368 seq_printf(s, ",posixpaths");
369 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID)
370 seq_printf(s, ",setuids");
371 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)
372 seq_printf(s, ",serverino");
373 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO)
374 seq_printf(s, ",directio");
375 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
376 seq_printf(s, ",nouser_xattr");
377 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR)
378 seq_printf(s, ",mapchars");
379 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL)
380 seq_printf(s, ",sfu");
381 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
382 seq_printf(s, ",nobrl");
383 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL)
384 seq_printf(s, ",cifsacl");
385 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM)
386 seq_printf(s, ",dynperm");
387 if (m->mnt_sb->s_flags & MS_POSIXACL)
388 seq_printf(s, ",acl");
389
359 seq_printf(s, ",rsize=%d", cifs_sb->rsize); 390 seq_printf(s, ",rsize=%d", cifs_sb->rsize);
360 seq_printf(s, ",wsize=%d", cifs_sb->wsize); 391 seq_printf(s, ",wsize=%d", cifs_sb->wsize);
361 } 392 }
@@ -657,7 +688,7 @@ const struct file_operations cifs_file_ops = {
657 .splice_read = generic_file_splice_read, 688 .splice_read = generic_file_splice_read,
658 .llseek = cifs_llseek, 689 .llseek = cifs_llseek,
659#ifdef CONFIG_CIFS_POSIX 690#ifdef CONFIG_CIFS_POSIX
660 .ioctl = cifs_ioctl, 691 .unlocked_ioctl = cifs_ioctl,
661#endif /* CONFIG_CIFS_POSIX */ 692#endif /* CONFIG_CIFS_POSIX */
662 693
663#ifdef CONFIG_CIFS_EXPERIMENTAL 694#ifdef CONFIG_CIFS_EXPERIMENTAL
@@ -677,7 +708,7 @@ const struct file_operations cifs_file_direct_ops = {
677 .flush = cifs_flush, 708 .flush = cifs_flush,
678 .splice_read = generic_file_splice_read, 709 .splice_read = generic_file_splice_read,
679#ifdef CONFIG_CIFS_POSIX 710#ifdef CONFIG_CIFS_POSIX
680 .ioctl = cifs_ioctl, 711 .unlocked_ioctl = cifs_ioctl,
681#endif /* CONFIG_CIFS_POSIX */ 712#endif /* CONFIG_CIFS_POSIX */
682 .llseek = cifs_llseek, 713 .llseek = cifs_llseek,
683#ifdef CONFIG_CIFS_EXPERIMENTAL 714#ifdef CONFIG_CIFS_EXPERIMENTAL
@@ -697,7 +728,7 @@ const struct file_operations cifs_file_nobrl_ops = {
697 .splice_read = generic_file_splice_read, 728 .splice_read = generic_file_splice_read,
698 .llseek = cifs_llseek, 729 .llseek = cifs_llseek,
699#ifdef CONFIG_CIFS_POSIX 730#ifdef CONFIG_CIFS_POSIX
700 .ioctl = cifs_ioctl, 731 .unlocked_ioctl = cifs_ioctl,
701#endif /* CONFIG_CIFS_POSIX */ 732#endif /* CONFIG_CIFS_POSIX */
702 733
703#ifdef CONFIG_CIFS_EXPERIMENTAL 734#ifdef CONFIG_CIFS_EXPERIMENTAL
@@ -716,7 +747,7 @@ const struct file_operations cifs_file_direct_nobrl_ops = {
716 .flush = cifs_flush, 747 .flush = cifs_flush,
717 .splice_read = generic_file_splice_read, 748 .splice_read = generic_file_splice_read,
718#ifdef CONFIG_CIFS_POSIX 749#ifdef CONFIG_CIFS_POSIX
719 .ioctl = cifs_ioctl, 750 .unlocked_ioctl = cifs_ioctl,
720#endif /* CONFIG_CIFS_POSIX */ 751#endif /* CONFIG_CIFS_POSIX */
721 .llseek = cifs_llseek, 752 .llseek = cifs_llseek,
722#ifdef CONFIG_CIFS_EXPERIMENTAL 753#ifdef CONFIG_CIFS_EXPERIMENTAL
@@ -731,7 +762,7 @@ const struct file_operations cifs_dir_ops = {
731#ifdef CONFIG_CIFS_EXPERIMENTAL 762#ifdef CONFIG_CIFS_EXPERIMENTAL
732 .dir_notify = cifs_dir_notify, 763 .dir_notify = cifs_dir_notify,
733#endif /* CONFIG_CIFS_EXPERIMENTAL */ 764#endif /* CONFIG_CIFS_EXPERIMENTAL */
734 .ioctl = cifs_ioctl, 765 .unlocked_ioctl = cifs_ioctl,
735}; 766};
736 767
737static void 768static void
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
index cd1301a09b3b..25a6cbd15529 100644
--- a/fs/cifs/cifsfs.h
+++ b/fs/cifs/cifsfs.h
@@ -95,8 +95,7 @@ extern int cifs_setxattr(struct dentry *, const char *, const void *,
95 size_t, int); 95 size_t, int);
96extern ssize_t cifs_getxattr(struct dentry *, const char *, void *, size_t); 96extern ssize_t cifs_getxattr(struct dentry *, const char *, void *, size_t);
97extern ssize_t cifs_listxattr(struct dentry *, char *, size_t); 97extern ssize_t cifs_listxattr(struct dentry *, char *, size_t);
98extern int cifs_ioctl(struct inode *inode, struct file *filep, 98extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);
99 unsigned int command, unsigned long arg);
100 99
101#ifdef CONFIG_CIFS_EXPERIMENTAL 100#ifdef CONFIG_CIFS_EXPERIMENTAL
102extern const struct export_operations cifs_export_ops; 101extern const struct export_operations cifs_export_ops;
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index b7d9f698e63e..9cfcf326ead3 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -281,6 +281,7 @@ struct cifsTconInfo {
281 bool ipc:1; /* set if connection to IPC$ eg for RPC/PIPES */ 281 bool ipc:1; /* set if connection to IPC$ eg for RPC/PIPES */
282 bool retry:1; 282 bool retry:1;
283 bool nocase:1; 283 bool nocase:1;
284 bool seal:1; /* transport encryption for this mounted share */
284 bool unix_ext:1; /* if false disable Linux extensions to CIFS protocol 285 bool unix_ext:1; /* if false disable Linux extensions to CIFS protocol
285 for this mount even if server would support */ 286 for this mount even if server would support */
286 /* BB add field for back pointer to sb struct(s)? */ 287 /* BB add field for back pointer to sb struct(s)? */
@@ -332,7 +333,6 @@ struct cifsFileInfo {
332 bool messageMode:1; /* for pipes: message vs byte mode */ 333 bool messageMode:1; /* for pipes: message vs byte mode */
333 atomic_t wrtPending; /* handle in use - defer close */ 334 atomic_t wrtPending; /* handle in use - defer close */
334 struct semaphore fh_sem; /* prevents reopen race after dead ses*/ 335 struct semaphore fh_sem; /* prevents reopen race after dead ses*/
335 char *search_resume_name; /* BB removeme BB */
336 struct cifs_search_info srch_inf; 336 struct cifs_search_info srch_inf;
337}; 337};
338 338
@@ -625,7 +625,7 @@ GLOBAL_EXTERN atomic_t tcpSesAllocCount;
625GLOBAL_EXTERN atomic_t tcpSesReconnectCount; 625GLOBAL_EXTERN atomic_t tcpSesReconnectCount;
626GLOBAL_EXTERN atomic_t tconInfoReconnectCount; 626GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
627 627
628/* Various Debug counters to remove someday (BB) */ 628/* Various Debug counters */
629GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */ 629GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
630#ifdef CONFIG_CIFS_STATS2 630#ifdef CONFIG_CIFS_STATS2
631GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */ 631GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
diff --git a/fs/cifs/cifspdu.h b/fs/cifs/cifspdu.h
index a0d26b540d4e..0f327c224da3 100644
--- a/fs/cifs/cifspdu.h
+++ b/fs/cifs/cifspdu.h
@@ -79,6 +79,19 @@
79#define TRANS2_GET_DFS_REFERRAL 0x10 79#define TRANS2_GET_DFS_REFERRAL 0x10
80#define TRANS2_REPORT_DFS_INCOSISTENCY 0x11 80#define TRANS2_REPORT_DFS_INCOSISTENCY 0x11
81 81
82/* SMB Transact (Named Pipe) subcommand codes */
83#define TRANS_SET_NMPIPE_STATE 0x0001
84#define TRANS_RAW_READ_NMPIPE 0x0011
85#define TRANS_QUERY_NMPIPE_STATE 0x0021
86#define TRANS_QUERY_NMPIPE_INFO 0x0022
87#define TRANS_PEEK_NMPIPE 0x0023
88#define TRANS_TRANSACT_NMPIPE 0x0026
89#define TRANS_RAW_WRITE_NMPIPE 0x0031
90#define TRANS_READ_NMPIPE 0x0036
91#define TRANS_WRITE_NMPIPE 0x0037
92#define TRANS_WAIT_NMPIPE 0x0053
93#define TRANS_CALL_NMPIPE 0x0054
94
82/* NT Transact subcommand codes */ 95/* NT Transact subcommand codes */
83#define NT_TRANSACT_CREATE 0x01 96#define NT_TRANSACT_CREATE 0x01
84#define NT_TRANSACT_IOCTL 0x02 97#define NT_TRANSACT_IOCTL 0x02
@@ -328,18 +341,20 @@
328#define CREATE_COMPLETE_IF_OPLK 0x00000100 /* should be zero */ 341#define CREATE_COMPLETE_IF_OPLK 0x00000100 /* should be zero */
329#define CREATE_NO_EA_KNOWLEDGE 0x00000200 342#define CREATE_NO_EA_KNOWLEDGE 0x00000200
330#define CREATE_EIGHT_DOT_THREE 0x00000400 /* doc says this is obsolete 343#define CREATE_EIGHT_DOT_THREE 0x00000400 /* doc says this is obsolete
331 open for recovery flag - should 344 "open for recovery" flag - should
332 be zero */ 345 be zero in any case */
346#define CREATE_OPEN_FOR_RECOVERY 0x00000400
333#define CREATE_RANDOM_ACCESS 0x00000800 347#define CREATE_RANDOM_ACCESS 0x00000800
334#define CREATE_DELETE_ON_CLOSE 0x00001000 348#define CREATE_DELETE_ON_CLOSE 0x00001000
335#define CREATE_OPEN_BY_ID 0x00002000 349#define CREATE_OPEN_BY_ID 0x00002000
336#define CREATE_OPEN_BACKUP_INTN 0x00004000 350#define CREATE_OPEN_BACKUP_INTENT 0x00004000
337#define CREATE_NO_COMPRESSION 0x00008000 351#define CREATE_NO_COMPRESSION 0x00008000
338#define CREATE_RESERVE_OPFILTER 0x00100000 /* should be zero */ 352#define CREATE_RESERVE_OPFILTER 0x00100000 /* should be zero */
339#define OPEN_REPARSE_POINT 0x00200000 353#define OPEN_REPARSE_POINT 0x00200000
340#define OPEN_NO_RECALL 0x00400000 354#define OPEN_NO_RECALL 0x00400000
341#define OPEN_FREE_SPACE_QUERY 0x00800000 /* should be zero */ 355#define OPEN_FREE_SPACE_QUERY 0x00800000 /* should be zero */
342#define CREATE_OPTIONS_MASK 0x007FFFFF 356#define CREATE_OPTIONS_MASK 0x007FFFFF
357#define CREATE_OPTION_READONLY 0x10000000
343#define CREATE_OPTION_SPECIAL 0x20000000 /* system. NB not sent over wire */ 358#define CREATE_OPTION_SPECIAL 0x20000000 /* system. NB not sent over wire */
344 359
345/* ImpersonationLevel flags */ 360/* ImpersonationLevel flags */
@@ -721,7 +736,6 @@ typedef struct smb_com_tconx_rsp_ext {
721#define SMB_CSC_CACHE_AUTO_REINT 0x0004 736#define SMB_CSC_CACHE_AUTO_REINT 0x0004
722#define SMB_CSC_CACHE_VDO 0x0008 737#define SMB_CSC_CACHE_VDO 0x0008
723#define SMB_CSC_NO_CACHING 0x000C 738#define SMB_CSC_NO_CACHING 0x000C
724
725#define SMB_UNIQUE_FILE_NAME 0x0010 739#define SMB_UNIQUE_FILE_NAME 0x0010
726#define SMB_EXTENDED_SIGNATURES 0x0020 740#define SMB_EXTENDED_SIGNATURES 0x0020
727 741
@@ -805,7 +819,7 @@ typedef struct smb_com_findclose_req {
805#define ICOUNT_MASK 0x00FF 819#define ICOUNT_MASK 0x00FF
806#define PIPE_READ_MODE 0x0100 820#define PIPE_READ_MODE 0x0100
807#define NAMED_PIPE_TYPE 0x0400 821#define NAMED_PIPE_TYPE 0x0400
808#define PIPE_END_POINT 0x0800 822#define PIPE_END_POINT 0x4000
809#define BLOCKING_NAMED_PIPE 0x8000 823#define BLOCKING_NAMED_PIPE 0x8000
810 824
811typedef struct smb_com_open_req { /* also handles create */ 825typedef struct smb_com_open_req { /* also handles create */
@@ -1903,19 +1917,26 @@ typedef struct smb_com_transaction2_get_dfs_refer_req {
1903 char RequestFileName[1]; 1917 char RequestFileName[1];
1904} __attribute__((packed)) TRANSACTION2_GET_DFS_REFER_REQ; 1918} __attribute__((packed)) TRANSACTION2_GET_DFS_REFER_REQ;
1905 1919
1920#define DFS_VERSION cpu_to_le16(0x0003)
1921
1922/* DFS server target type */
1923#define DFS_TYPE_LINK 0x0000 /* also for sysvol targets */
1924#define DFS_TYPE_ROOT 0x0001
1925
1926/* Referral Entry Flags */
1927#define DFS_NAME_LIST_REF 0x0200
1928
1906typedef struct dfs_referral_level_3 { 1929typedef struct dfs_referral_level_3 {
1907 __le16 VersionNumber; 1930 __le16 VersionNumber;
1908 __le16 ReferralSize; 1931 __le16 Size;
1909 __le16 ServerType; /* 0x0001 = CIFS server */ 1932 __le16 ServerType; /* 0x0001 = root targets; 0x0000 = link targets */
1910 __le16 ReferralFlags; /* or proximity - not clear which since it is 1933 __le16 ReferralEntryFlags; /* 0x0200 bit set only for domain
1911 always set to zero - SNIA spec says 0x01 1934 or DC referral responce */
1912 means strip off PathConsumed chars before 1935 __le32 TimeToLive;
1913 submitting RequestFileName to remote node */
1914 __le16 TimeToLive;
1915 __le16 Proximity;
1916 __le16 DfsPathOffset; 1936 __le16 DfsPathOffset;
1917 __le16 DfsAlternatePathOffset; 1937 __le16 DfsAlternatePathOffset;
1918 __le16 NetworkAddressOffset; 1938 __le16 NetworkAddressOffset; /* offset of the link target */
1939 __le16 ServiceSiteGuid;
1919} __attribute__((packed)) REFERRAL3; 1940} __attribute__((packed)) REFERRAL3;
1920 1941
1921typedef struct smb_com_transaction_get_dfs_refer_rsp { 1942typedef struct smb_com_transaction_get_dfs_refer_rsp {
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index d481f6c5a2be..b9f5e935f821 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -93,7 +93,7 @@ extern struct timespec cnvrtDosUnixTm(__u16 date, __u16 time);
93 93
94extern int cifs_get_inode_info(struct inode **pinode, 94extern int cifs_get_inode_info(struct inode **pinode,
95 const unsigned char *search_path, 95 const unsigned char *search_path,
96 FILE_ALL_INFO * pfile_info, 96 FILE_ALL_INFO *pfile_info,
97 struct super_block *sb, int xid, const __u16 *pfid); 97 struct super_block *sb, int xid, const __u16 *pfid);
98extern int cifs_get_inode_info_unix(struct inode **pinode, 98extern int cifs_get_inode_info_unix(struct inode **pinode,
99 const unsigned char *search_path, 99 const unsigned char *search_path,
@@ -130,7 +130,7 @@ extern int CIFSFindClose(const int, struct cifsTconInfo *tcon,
130 130
131extern int CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon, 131extern int CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon,
132 const unsigned char *searchName, 132 const unsigned char *searchName,
133 FILE_ALL_INFO * findData, 133 FILE_ALL_INFO *findData,
134 int legacy /* whether to use old info level */, 134 int legacy /* whether to use old info level */,
135 const struct nls_table *nls_codepage, int remap); 135 const struct nls_table *nls_codepage, int remap);
136extern int SMBQueryInformation(const int xid, struct cifsTconInfo *tcon, 136extern int SMBQueryInformation(const int xid, struct cifsTconInfo *tcon,
@@ -141,18 +141,15 @@ extern int SMBQueryInformation(const int xid, struct cifsTconInfo *tcon,
141extern int CIFSSMBUnixQPathInfo(const int xid, 141extern int CIFSSMBUnixQPathInfo(const int xid,
142 struct cifsTconInfo *tcon, 142 struct cifsTconInfo *tcon,
143 const unsigned char *searchName, 143 const unsigned char *searchName,
144 FILE_UNIX_BASIC_INFO * pFindData, 144 FILE_UNIX_BASIC_INFO *pFindData,
145 const struct nls_table *nls_codepage, int remap); 145 const struct nls_table *nls_codepage, int remap);
146 146
147extern int CIFSGetDFSRefer(const int xid, struct cifsSesInfo *ses, 147extern int CIFSGetDFSRefer(const int xid, struct cifsSesInfo *ses,
148 const unsigned char *searchName, 148 const unsigned char *searchName,
149 unsigned char **targetUNCs, 149 struct dfs_info3_param **target_nodes,
150 unsigned int *number_of_UNC_in_array, 150 unsigned int *number_of_nodes_in_array,
151 const struct nls_table *nls_codepage, int remap); 151 const struct nls_table *nls_codepage, int remap);
152 152
153extern int connect_to_dfs_path(int xid, struct cifsSesInfo *pSesInfo,
154 const char *old_path,
155 const struct nls_table *nls_codepage, int remap);
156extern int get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, 153extern int get_dfs_path(int xid, struct cifsSesInfo *pSesInfo,
157 const char *old_path, 154 const char *old_path,
158 const struct nls_table *nls_codepage, 155 const struct nls_table *nls_codepage,
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index cfd9750852b3..4511b708f0f3 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -81,6 +81,40 @@ static struct {
81#endif /* CONFIG_CIFS_WEAK_PW_HASH */ 81#endif /* CONFIG_CIFS_WEAK_PW_HASH */
82#endif /* CIFS_POSIX */ 82#endif /* CIFS_POSIX */
83 83
84/* Allocates buffer into dst and copies smb string from src to it.
85 * caller is responsible for freeing dst if function returned 0.
86 * returns:
87 * on success - 0
88 * on failure - errno
89 */
90static int
91cifs_strncpy_to_host(char **dst, const char *src, const int maxlen,
92 const bool is_unicode, const struct nls_table *nls_codepage)
93{
94 int plen;
95
96 if (is_unicode) {
97 plen = UniStrnlen((wchar_t *)src, maxlen);
98 *dst = kmalloc(plen + 2, GFP_KERNEL);
99 if (!*dst)
100 goto cifs_strncpy_to_host_ErrExit;
101 cifs_strfromUCS_le(*dst, (__le16 *)src, plen, nls_codepage);
102 } else {
103 plen = strnlen(src, maxlen);
104 *dst = kmalloc(plen + 2, GFP_KERNEL);
105 if (!*dst)
106 goto cifs_strncpy_to_host_ErrExit;
107 strncpy(*dst, src, plen);
108 }
109 (*dst)[plen] = 0;
110 (*dst)[plen+1] = 0; /* harmless for ASCII case, needed for Unicode */
111 return 0;
112
113cifs_strncpy_to_host_ErrExit:
114 cERROR(1, ("Failed to allocate buffer for string\n"));
115 return -ENOMEM;
116}
117
84 118
85/* Mark as invalid, all open files on tree connections since they 119/* Mark as invalid, all open files on tree connections since they
86 were closed when session to server was lost */ 120 were closed when session to server was lost */
@@ -1166,6 +1200,20 @@ static __u16 convert_disposition(int disposition)
1166 return ofun; 1200 return ofun;
1167} 1201}
1168 1202
1203static int
1204access_flags_to_smbopen_mode(const int access_flags)
1205{
1206 int masked_flags = access_flags & (GENERIC_READ | GENERIC_WRITE);
1207
1208 if (masked_flags == GENERIC_READ)
1209 return SMBOPEN_READ;
1210 else if (masked_flags == GENERIC_WRITE)
1211 return SMBOPEN_WRITE;
1212
1213 /* just go for read/write */
1214 return SMBOPEN_READWRITE;
1215}
1216
1169int 1217int
1170SMBLegacyOpen(const int xid, struct cifsTconInfo *tcon, 1218SMBLegacyOpen(const int xid, struct cifsTconInfo *tcon,
1171 const char *fileName, const int openDisposition, 1219 const char *fileName, const int openDisposition,
@@ -1207,13 +1255,7 @@ OldOpenRetry:
1207 pSMB->OpenFlags = cpu_to_le16(REQ_BATCHOPLOCK); 1255 pSMB->OpenFlags = cpu_to_le16(REQ_BATCHOPLOCK);
1208 1256
1209 pSMB->OpenFlags |= cpu_to_le16(REQ_MORE_INFO); 1257 pSMB->OpenFlags |= cpu_to_le16(REQ_MORE_INFO);
1210 /* BB fixme add conversion for access_flags to bits 0 - 2 of mode */ 1258 pSMB->Mode = cpu_to_le16(access_flags_to_smbopen_mode(access_flags));
1211 /* 0 = read
1212 1 = write
1213 2 = rw
1214 3 = execute
1215 */
1216 pSMB->Mode = cpu_to_le16(2);
1217 pSMB->Mode |= cpu_to_le16(0x40); /* deny none */ 1259 pSMB->Mode |= cpu_to_le16(0x40); /* deny none */
1218 /* set file as system file if special file such 1260 /* set file as system file if special file such
1219 as fifo and server expecting SFU style and 1261 as fifo and server expecting SFU style and
@@ -1224,11 +1266,8 @@ OldOpenRetry:
1224 else /* BB FIXME BB */ 1266 else /* BB FIXME BB */
1225 pSMB->FileAttributes = cpu_to_le16(0/*ATTR_NORMAL*/); 1267 pSMB->FileAttributes = cpu_to_le16(0/*ATTR_NORMAL*/);
1226 1268
1227 /* if ((omode & S_IWUGO) == 0) 1269 if (create_options & CREATE_OPTION_READONLY)
1228 pSMB->FileAttributes |= cpu_to_le32(ATTR_READONLY);*/ 1270 pSMB->FileAttributes |= cpu_to_le16(ATTR_READONLY);
1229 /* Above line causes problems due to vfs splitting create into two
1230 pieces - need to set mode after file created not while it is
1231 being created */
1232 1271
1233 /* BB FIXME BB */ 1272 /* BB FIXME BB */
1234/* pSMB->CreateOptions = cpu_to_le32(create_options & 1273/* pSMB->CreateOptions = cpu_to_le32(create_options &
@@ -1250,7 +1289,7 @@ OldOpenRetry:
1250 } else { 1289 } else {
1251 /* BB verify if wct == 15 */ 1290 /* BB verify if wct == 15 */
1252 1291
1253/* *pOplock = pSMBr->OplockLevel; */ /* BB take from action field BB */ 1292/* *pOplock = pSMBr->OplockLevel; */ /* BB take from action field*/
1254 1293
1255 *netfid = pSMBr->Fid; /* cifs fid stays in le */ 1294 *netfid = pSMBr->Fid; /* cifs fid stays in le */
1256 /* Let caller know file was created so we can set the mode. */ 1295 /* Let caller know file was created so we can set the mode. */
@@ -1331,17 +1370,16 @@ openRetry:
1331 pSMB->FileAttributes = cpu_to_le32(ATTR_SYSTEM); 1370 pSMB->FileAttributes = cpu_to_le32(ATTR_SYSTEM);
1332 else 1371 else
1333 pSMB->FileAttributes = cpu_to_le32(ATTR_NORMAL); 1372 pSMB->FileAttributes = cpu_to_le32(ATTR_NORMAL);
1373
1334 /* XP does not handle ATTR_POSIX_SEMANTICS */ 1374 /* XP does not handle ATTR_POSIX_SEMANTICS */
1335 /* but it helps speed up case sensitive checks for other 1375 /* but it helps speed up case sensitive checks for other
1336 servers such as Samba */ 1376 servers such as Samba */
1337 if (tcon->ses->capabilities & CAP_UNIX) 1377 if (tcon->ses->capabilities & CAP_UNIX)
1338 pSMB->FileAttributes |= cpu_to_le32(ATTR_POSIX_SEMANTICS); 1378 pSMB->FileAttributes |= cpu_to_le32(ATTR_POSIX_SEMANTICS);
1339 1379
1340 /* if ((omode & S_IWUGO) == 0) 1380 if (create_options & CREATE_OPTION_READONLY)
1341 pSMB->FileAttributes |= cpu_to_le32(ATTR_READONLY);*/ 1381 pSMB->FileAttributes |= cpu_to_le32(ATTR_READONLY);
1342 /* Above line causes problems due to vfs splitting create into two 1382
1343 pieces - need to set mode after file created not while it is
1344 being created */
1345 pSMB->ShareAccess = cpu_to_le32(FILE_SHARE_ALL); 1383 pSMB->ShareAccess = cpu_to_le32(FILE_SHARE_ALL);
1346 pSMB->CreateDisposition = cpu_to_le32(openDisposition); 1384 pSMB->CreateDisposition = cpu_to_le32(openDisposition);
1347 pSMB->CreateOptions = cpu_to_le32(create_options & CREATE_OPTIONS_MASK); 1385 pSMB->CreateOptions = cpu_to_le32(create_options & CREATE_OPTIONS_MASK);
@@ -1690,7 +1728,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
1690{ 1728{
1691 int rc = 0; 1729 int rc = 0;
1692 LOCK_REQ *pSMB = NULL; 1730 LOCK_REQ *pSMB = NULL;
1693 LOCK_RSP *pSMBr = NULL; 1731/* LOCK_RSP *pSMBr = NULL; */ /* No response data other than rc to parse */
1694 int bytes_returned; 1732 int bytes_returned;
1695 int timeout = 0; 1733 int timeout = 0;
1696 __u16 count; 1734 __u16 count;
@@ -1701,8 +1739,6 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
1701 if (rc) 1739 if (rc)
1702 return rc; 1740 return rc;
1703 1741
1704 pSMBr = (LOCK_RSP *)pSMB; /* BB removeme BB */
1705
1706 if (lockType == LOCKING_ANDX_OPLOCK_RELEASE) { 1742 if (lockType == LOCKING_ANDX_OPLOCK_RELEASE) {
1707 timeout = CIFS_ASYNC_OP; /* no response expected */ 1743 timeout = CIFS_ASYNC_OP; /* no response expected */
1708 pSMB->Timeout = 0; 1744 pSMB->Timeout = 0;
@@ -1736,7 +1772,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
1736 1772
1737 if (waitFlag) { 1773 if (waitFlag) {
1738 rc = SendReceiveBlockingLock(xid, tcon, (struct smb_hdr *) pSMB, 1774 rc = SendReceiveBlockingLock(xid, tcon, (struct smb_hdr *) pSMB,
1739 (struct smb_hdr *) pSMBr, &bytes_returned); 1775 (struct smb_hdr *) pSMB, &bytes_returned);
1740 cifs_small_buf_release(pSMB); 1776 cifs_small_buf_release(pSMB);
1741 } else { 1777 } else {
1742 rc = SendReceiveNoRsp(xid, tcon->ses, (struct smb_hdr *)pSMB, 1778 rc = SendReceiveNoRsp(xid, tcon->ses, (struct smb_hdr *)pSMB,
@@ -1771,7 +1807,7 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
1771 cFYI(1, ("Posix Lock")); 1807 cFYI(1, ("Posix Lock"));
1772 1808
1773 if (pLockData == NULL) 1809 if (pLockData == NULL)
1774 return EINVAL; 1810 return -EINVAL;
1775 1811
1776 rc = small_smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB); 1812 rc = small_smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB);
1777 1813
@@ -1948,7 +1984,7 @@ renameRetry:
1948 /* protocol requires ASCII signature byte on Unicode string */ 1984 /* protocol requires ASCII signature byte on Unicode string */
1949 pSMB->OldFileName[name_len + 1] = 0x00; 1985 pSMB->OldFileName[name_len + 1] = 0x00;
1950 name_len2 = 1986 name_len2 =
1951 cifsConvertToUCS((__le16 *) &pSMB->OldFileName[name_len + 2], 1987 cifsConvertToUCS((__le16 *)&pSMB->OldFileName[name_len + 2],
1952 toName, PATH_MAX, nls_codepage, remap); 1988 toName, PATH_MAX, nls_codepage, remap);
1953 name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; 1989 name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ;
1954 name_len2 *= 2; /* convert to bytes */ 1990 name_len2 *= 2; /* convert to bytes */
@@ -2121,8 +2157,7 @@ copyRetry:
2121 cFYI(1, ("Send error in copy = %d with %d files copied", 2157 cFYI(1, ("Send error in copy = %d with %d files copied",
2122 rc, le16_to_cpu(pSMBr->CopyCount))); 2158 rc, le16_to_cpu(pSMBr->CopyCount)));
2123 } 2159 }
2124 if (pSMB) 2160 cifs_buf_release(pSMB);
2125 cifs_buf_release(pSMB);
2126 2161
2127 if (rc == -EAGAIN) 2162 if (rc == -EAGAIN)
2128 goto copyRetry; 2163 goto copyRetry;
@@ -2211,8 +2246,7 @@ createSymLinkRetry:
2211 if (rc) 2246 if (rc)
2212 cFYI(1, ("Send error in SetPathInfo create symlink = %d", rc)); 2247 cFYI(1, ("Send error in SetPathInfo create symlink = %d", rc));
2213 2248
2214 if (pSMB) 2249 cifs_buf_release(pSMB);
2215 cifs_buf_release(pSMB);
2216 2250
2217 if (rc == -EAGAIN) 2251 if (rc == -EAGAIN)
2218 goto createSymLinkRetry; 2252 goto createSymLinkRetry;
@@ -2929,7 +2963,8 @@ setAclRetry:
2929 } 2963 }
2930 params = 6 + name_len; 2964 params = 6 + name_len;
2931 pSMB->MaxParameterCount = cpu_to_le16(2); 2965 pSMB->MaxParameterCount = cpu_to_le16(2);
2932 pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB size from sess */ 2966 /* BB find max SMB size from sess */
2967 pSMB->MaxDataCount = cpu_to_le16(1000);
2933 pSMB->MaxSetupCount = 0; 2968 pSMB->MaxSetupCount = 0;
2934 pSMB->Reserved = 0; 2969 pSMB->Reserved = 0;
2935 pSMB->Flags = 0; 2970 pSMB->Flags = 0;
@@ -3326,7 +3361,8 @@ QPathInfoRetry:
3326 params = 2 /* level */ + 4 /* reserved */ + name_len /* includes NUL */; 3361 params = 2 /* level */ + 4 /* reserved */ + name_len /* includes NUL */;
3327 pSMB->TotalDataCount = 0; 3362 pSMB->TotalDataCount = 0;
3328 pSMB->MaxParameterCount = cpu_to_le16(2); 3363 pSMB->MaxParameterCount = cpu_to_le16(2);
3329 pSMB->MaxDataCount = cpu_to_le16(4000); /* BB find exact max SMB PDU from sess structure BB */ 3364 /* BB find exact max SMB PDU from sess structure BB */
3365 pSMB->MaxDataCount = cpu_to_le16(4000);
3330 pSMB->MaxSetupCount = 0; 3366 pSMB->MaxSetupCount = 0;
3331 pSMB->Reserved = 0; 3367 pSMB->Reserved = 0;
3332 pSMB->Flags = 0; 3368 pSMB->Flags = 0;
@@ -3392,7 +3428,7 @@ QPathInfoRetry:
3392int 3428int
3393CIFSSMBUnixQPathInfo(const int xid, struct cifsTconInfo *tcon, 3429CIFSSMBUnixQPathInfo(const int xid, struct cifsTconInfo *tcon,
3394 const unsigned char *searchName, 3430 const unsigned char *searchName,
3395 FILE_UNIX_BASIC_INFO * pFindData, 3431 FILE_UNIX_BASIC_INFO *pFindData,
3396 const struct nls_table *nls_codepage, int remap) 3432 const struct nls_table *nls_codepage, int remap)
3397{ 3433{
3398/* SMB_QUERY_FILE_UNIX_BASIC */ 3434/* SMB_QUERY_FILE_UNIX_BASIC */
@@ -3683,6 +3719,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
3683 if (rc) { 3719 if (rc) {
3684 if (rc == -EBADF) { 3720 if (rc == -EBADF) {
3685 psrch_inf->endOfSearch = true; 3721 psrch_inf->endOfSearch = true;
3722 cifs_buf_release(pSMB);
3686 rc = 0; /* search probably was closed at end of search*/ 3723 rc = 0; /* search probably was closed at end of search*/
3687 } else 3724 } else
3688 cFYI(1, ("FindNext returned = %d", rc)); 3725 cFYI(1, ("FindNext returned = %d", rc));
@@ -3860,25 +3897,112 @@ GetInodeNumOut:
3860 return rc; 3897 return rc;
3861} 3898}
3862 3899
3900/* parses DFS refferal V3 structure
3901 * caller is responsible for freeing target_nodes
3902 * returns:
3903 * on success - 0
3904 * on failure - errno
3905 */
3906static int
3907parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr,
3908 unsigned int *num_of_nodes,
3909 struct dfs_info3_param **target_nodes,
3910 const struct nls_table *nls_codepage)
3911{
3912 int i, rc = 0;
3913 char *data_end;
3914 bool is_unicode;
3915 struct dfs_referral_level_3 *ref;
3916
3917 is_unicode = pSMBr->hdr.Flags2 & SMBFLG2_UNICODE;
3918 *num_of_nodes = le16_to_cpu(pSMBr->NumberOfReferrals);
3919
3920 if (*num_of_nodes < 1) {
3921 cERROR(1, ("num_referrals: must be at least > 0,"
3922 "but we get num_referrals = %d\n", *num_of_nodes));
3923 rc = -EINVAL;
3924 goto parse_DFS_referrals_exit;
3925 }
3926
3927 ref = (struct dfs_referral_level_3 *) &(pSMBr->referrals);
3928 if (ref->VersionNumber != cpu_to_le16(3)) {
3929 cERROR(1, ("Referrals of V%d version are not supported,"
3930 "should be V3", le16_to_cpu(ref->VersionNumber)));
3931 rc = -EINVAL;
3932 goto parse_DFS_referrals_exit;
3933 }
3934
3935 /* get the upper boundary of the resp buffer */
3936 data_end = (char *)(&(pSMBr->PathConsumed)) +
3937 le16_to_cpu(pSMBr->t2.DataCount);
3938
3939 cFYI(1, ("num_referrals: %d dfs flags: 0x%x ... \n",
3940 *num_of_nodes,
3941 le16_to_cpu(pSMBr->DFSFlags)));
3942
3943 *target_nodes = kzalloc(sizeof(struct dfs_info3_param) *
3944 *num_of_nodes, GFP_KERNEL);
3945 if (*target_nodes == NULL) {
3946 cERROR(1, ("Failed to allocate buffer for target_nodes\n"));
3947 rc = -ENOMEM;
3948 goto parse_DFS_referrals_exit;
3949 }
3950
3951 /* collect neccessary data from referrals */
3952 for (i = 0; i < *num_of_nodes; i++) {
3953 char *temp;
3954 int max_len;
3955 struct dfs_info3_param *node = (*target_nodes)+i;
3956
3957 node->flags = le16_to_cpu(pSMBr->DFSFlags);
3958 node->path_consumed = le16_to_cpu(pSMBr->PathConsumed);
3959 node->server_type = le16_to_cpu(ref->ServerType);
3960 node->ref_flag = le16_to_cpu(ref->ReferralEntryFlags);
3961
3962 /* copy DfsPath */
3963 temp = (char *)ref + le16_to_cpu(ref->DfsPathOffset);
3964 max_len = data_end - temp;
3965 rc = cifs_strncpy_to_host(&(node->path_name), temp,
3966 max_len, is_unicode, nls_codepage);
3967 if (rc)
3968 goto parse_DFS_referrals_exit;
3969
3970 /* copy link target UNC */
3971 temp = (char *)ref + le16_to_cpu(ref->NetworkAddressOffset);
3972 max_len = data_end - temp;
3973 rc = cifs_strncpy_to_host(&(node->node_name), temp,
3974 max_len, is_unicode, nls_codepage);
3975 if (rc)
3976 goto parse_DFS_referrals_exit;
3977
3978 ref += le16_to_cpu(ref->Size);
3979 }
3980
3981parse_DFS_referrals_exit:
3982 if (rc) {
3983 free_dfs_info_array(*target_nodes, *num_of_nodes);
3984 *target_nodes = NULL;
3985 *num_of_nodes = 0;
3986 }
3987 return rc;
3988}
3989
3863int 3990int
3864CIFSGetDFSRefer(const int xid, struct cifsSesInfo *ses, 3991CIFSGetDFSRefer(const int xid, struct cifsSesInfo *ses,
3865 const unsigned char *searchName, 3992 const unsigned char *searchName,
3866 unsigned char **targetUNCs, 3993 struct dfs_info3_param **target_nodes,
3867 unsigned int *number_of_UNC_in_array, 3994 unsigned int *num_of_nodes,
3868 const struct nls_table *nls_codepage, int remap) 3995 const struct nls_table *nls_codepage, int remap)
3869{ 3996{
3870/* TRANS2_GET_DFS_REFERRAL */ 3997/* TRANS2_GET_DFS_REFERRAL */
3871 TRANSACTION2_GET_DFS_REFER_REQ *pSMB = NULL; 3998 TRANSACTION2_GET_DFS_REFER_REQ *pSMB = NULL;
3872 TRANSACTION2_GET_DFS_REFER_RSP *pSMBr = NULL; 3999 TRANSACTION2_GET_DFS_REFER_RSP *pSMBr = NULL;
3873 struct dfs_referral_level_3 *referrals = NULL;
3874 int rc = 0; 4000 int rc = 0;
3875 int bytes_returned; 4001 int bytes_returned;
3876 int name_len; 4002 int name_len;
3877 unsigned int i;
3878 char *temp;
3879 __u16 params, byte_count; 4003 __u16 params, byte_count;
3880 *number_of_UNC_in_array = 0; 4004 *num_of_nodes = 0;
3881 *targetUNCs = NULL; 4005 *target_nodes = NULL;
3882 4006
3883 cFYI(1, ("In GetDFSRefer the path %s", searchName)); 4007 cFYI(1, ("In GetDFSRefer the path %s", searchName));
3884 if (ses == NULL) 4008 if (ses == NULL)
@@ -3925,7 +4049,8 @@ getDFSRetry:
3925 pSMB->DataCount = 0; 4049 pSMB->DataCount = 0;
3926 pSMB->DataOffset = 0; 4050 pSMB->DataOffset = 0;
3927 pSMB->MaxParameterCount = 0; 4051 pSMB->MaxParameterCount = 0;
3928 pSMB->MaxDataCount = cpu_to_le16(4000); /* BB find exact max SMB PDU from sess structure BB */ 4052 /* BB find exact max SMB PDU from sess structure BB */
4053 pSMB->MaxDataCount = cpu_to_le16(4000);
3929 pSMB->MaxSetupCount = 0; 4054 pSMB->MaxSetupCount = 0;
3930 pSMB->Reserved = 0; 4055 pSMB->Reserved = 0;
3931 pSMB->Flags = 0; 4056 pSMB->Flags = 0;
@@ -3947,103 +4072,26 @@ getDFSRetry:
3947 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 4072 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
3948 if (rc) { 4073 if (rc) {
3949 cFYI(1, ("Send error in GetDFSRefer = %d", rc)); 4074 cFYI(1, ("Send error in GetDFSRefer = %d", rc));
3950 } else { /* decode response */ 4075 goto GetDFSRefExit;
3951/* BB Add logic to parse referrals here */ 4076 }
3952 rc = validate_t2((struct smb_t2_rsp *)pSMBr); 4077 rc = validate_t2((struct smb_t2_rsp *)pSMBr);
3953 4078
3954 /* BB Also check if enough total bytes returned? */ 4079 /* BB Also check if enough total bytes returned? */
3955 if (rc || (pSMBr->ByteCount < 17)) 4080 if (rc || (pSMBr->ByteCount < 17)) {
3956 rc = -EIO; /* bad smb */ 4081 rc = -EIO; /* bad smb */
3957 else { 4082 goto GetDFSRefExit;
3958 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); 4083 }
3959 __u16 data_count = le16_to_cpu(pSMBr->t2.DataCount);
3960 4084
3961 cFYI(1, 4085 cFYI(1, ("Decoding GetDFSRefer response BCC: %d Offset %d",
3962 ("Decoding GetDFSRefer response BCC: %d Offset %d", 4086 pSMBr->ByteCount,
3963 pSMBr->ByteCount, data_offset)); 4087 le16_to_cpu(pSMBr->t2.DataOffset)));
3964 referrals =
3965 (struct dfs_referral_level_3 *)
3966 (8 /* sizeof start of data block */ +
3967 data_offset +
3968 (char *) &pSMBr->hdr.Protocol);
3969 cFYI(1, ("num_referrals: %d dfs flags: 0x%x ... \n"
3970 "for referral one refer size: 0x%x srv "
3971 "type: 0x%x refer flags: 0x%x ttl: 0x%x",
3972 le16_to_cpu(pSMBr->NumberOfReferrals),
3973 le16_to_cpu(pSMBr->DFSFlags),
3974 le16_to_cpu(referrals->ReferralSize),
3975 le16_to_cpu(referrals->ServerType),
3976 le16_to_cpu(referrals->ReferralFlags),
3977 le16_to_cpu(referrals->TimeToLive)));
3978 /* BB This field is actually two bytes in from start of
3979 data block so we could do safety check that DataBlock
3980 begins at address of pSMBr->NumberOfReferrals */
3981 *number_of_UNC_in_array =
3982 le16_to_cpu(pSMBr->NumberOfReferrals);
3983
3984 /* BB Fix below so can return more than one referral */
3985 if (*number_of_UNC_in_array > 1)
3986 *number_of_UNC_in_array = 1;
3987
3988 /* get the length of the strings describing refs */
3989 name_len = 0;
3990 for (i = 0; i < *number_of_UNC_in_array; i++) {
3991 /* make sure that DfsPathOffset not past end */
3992 __u16 offset =
3993 le16_to_cpu(referrals->DfsPathOffset);
3994 if (offset > data_count) {
3995 /* if invalid referral, stop here and do
3996 not try to copy any more */
3997 *number_of_UNC_in_array = i;
3998 break;
3999 }
4000 temp = ((char *)referrals) + offset;
4001 4088
4002 if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) { 4089 /* parse returned result into more usable form */
4003 name_len += UniStrnlen((wchar_t *)temp, 4090 rc = parse_DFS_referrals(pSMBr, num_of_nodes,
4004 data_count); 4091 target_nodes, nls_codepage);
4005 } else {
4006 name_len += strnlen(temp, data_count);
4007 }
4008 referrals++;
4009 /* BB add check that referral pointer does
4010 not fall off end PDU */
4011 }
4012 /* BB add check for name_len bigger than bcc */
4013 *targetUNCs =
4014 kmalloc(name_len+1+(*number_of_UNC_in_array),
4015 GFP_KERNEL);
4016 if (*targetUNCs == NULL) {
4017 rc = -ENOMEM;
4018 goto GetDFSRefExit;
4019 }
4020 /* copy the ref strings */
4021 referrals = (struct dfs_referral_level_3 *)
4022 (8 /* sizeof data hdr */ + data_offset +
4023 (char *) &pSMBr->hdr.Protocol);
4024
4025 for (i = 0; i < *number_of_UNC_in_array; i++) {
4026 temp = ((char *)referrals) +
4027 le16_to_cpu(referrals->DfsPathOffset);
4028 if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) {
4029 cifs_strfromUCS_le(*targetUNCs,
4030 (__le16 *) temp,
4031 name_len,
4032 nls_codepage);
4033 } else {
4034 strncpy(*targetUNCs, temp, name_len);
4035 }
4036 /* BB update target_uncs pointers */
4037 referrals++;
4038 }
4039 temp = *targetUNCs;
4040 temp[name_len] = 0;
4041 }
4042 4092
4043 }
4044GetDFSRefExit: 4093GetDFSRefExit:
4045 if (pSMB) 4094 cifs_buf_release(pSMB);
4046 cifs_buf_release(pSMB);
4047 4095
4048 if (rc == -EAGAIN) 4096 if (rc == -EAGAIN)
4049 goto getDFSRetry; 4097 goto getDFSRetry;
@@ -4233,7 +4281,8 @@ QFSAttributeRetry:
4233 params = 2; /* level */ 4281 params = 2; /* level */
4234 pSMB->TotalDataCount = 0; 4282 pSMB->TotalDataCount = 0;
4235 pSMB->MaxParameterCount = cpu_to_le16(2); 4283 pSMB->MaxParameterCount = cpu_to_le16(2);
4236 pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find exact max SMB PDU from sess structure BB */ 4284 /* BB find exact max SMB PDU from sess structure BB */
4285 pSMB->MaxDataCount = cpu_to_le16(1000);
4237 pSMB->MaxSetupCount = 0; 4286 pSMB->MaxSetupCount = 0;
4238 pSMB->Reserved = 0; 4287 pSMB->Reserved = 0;
4239 pSMB->Flags = 0; 4288 pSMB->Flags = 0;
@@ -4302,7 +4351,8 @@ QFSDeviceRetry:
4302 params = 2; /* level */ 4351 params = 2; /* level */
4303 pSMB->TotalDataCount = 0; 4352 pSMB->TotalDataCount = 0;
4304 pSMB->MaxParameterCount = cpu_to_le16(2); 4353 pSMB->MaxParameterCount = cpu_to_le16(2);
4305 pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find exact max SMB PDU from sess structure BB */ 4354 /* BB find exact max SMB PDU from sess structure BB */
4355 pSMB->MaxDataCount = cpu_to_le16(1000);
4306 pSMB->MaxSetupCount = 0; 4356 pSMB->MaxSetupCount = 0;
4307 pSMB->Reserved = 0; 4357 pSMB->Reserved = 0;
4308 pSMB->Flags = 0; 4358 pSMB->Flags = 0;
@@ -4373,7 +4423,8 @@ QFSUnixRetry:
4373 pSMB->DataCount = 0; 4423 pSMB->DataCount = 0;
4374 pSMB->DataOffset = 0; 4424 pSMB->DataOffset = 0;
4375 pSMB->MaxParameterCount = cpu_to_le16(2); 4425 pSMB->MaxParameterCount = cpu_to_le16(2);
4376 pSMB->MaxDataCount = cpu_to_le16(100); /* BB find exact max SMB PDU from sess structure BB */ 4426 /* BB find exact max SMB PDU from sess structure BB */
4427 pSMB->MaxDataCount = cpu_to_le16(100);
4377 pSMB->MaxSetupCount = 0; 4428 pSMB->MaxSetupCount = 0;
4378 pSMB->Reserved = 0; 4429 pSMB->Reserved = 0;
4379 pSMB->Flags = 0; 4430 pSMB->Flags = 0;
@@ -4448,7 +4499,8 @@ SETFSUnixRetry:
4448 offset = param_offset + params; 4499 offset = param_offset + params;
4449 4500
4450 pSMB->MaxParameterCount = cpu_to_le16(4); 4501 pSMB->MaxParameterCount = cpu_to_le16(4);
4451 pSMB->MaxDataCount = cpu_to_le16(100); /* BB find exact max SMB PDU from sess structure BB */ 4502 /* BB find exact max SMB PDU from sess structure BB */
4503 pSMB->MaxDataCount = cpu_to_le16(100);
4452 pSMB->SetupCount = 1; 4504 pSMB->SetupCount = 1;
4453 pSMB->Reserved3 = 0; 4505 pSMB->Reserved3 = 0;
4454 pSMB->SubCommand = cpu_to_le16(TRANS2_SET_FS_INFORMATION); 4506 pSMB->SubCommand = cpu_to_le16(TRANS2_SET_FS_INFORMATION);
@@ -4516,7 +4568,8 @@ QFSPosixRetry:
4516 pSMB->DataCount = 0; 4568 pSMB->DataCount = 0;
4517 pSMB->DataOffset = 0; 4569 pSMB->DataOffset = 0;
4518 pSMB->MaxParameterCount = cpu_to_le16(2); 4570 pSMB->MaxParameterCount = cpu_to_le16(2);
4519 pSMB->MaxDataCount = cpu_to_le16(100); /* BB find exact max SMB PDU from sess structure BB */ 4571 /* BB find exact max SMB PDU from sess structure BB */
4572 pSMB->MaxDataCount = cpu_to_le16(100);
4520 pSMB->MaxSetupCount = 0; 4573 pSMB->MaxSetupCount = 0;
4521 pSMB->Reserved = 0; 4574 pSMB->Reserved = 0;
4522 pSMB->Flags = 0; 4575 pSMB->Flags = 0;
@@ -4706,7 +4759,8 @@ CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, __u64 size,
4706 4759
4707 count = sizeof(struct file_end_of_file_info); 4760 count = sizeof(struct file_end_of_file_info);
4708 pSMB->MaxParameterCount = cpu_to_le16(2); 4761 pSMB->MaxParameterCount = cpu_to_le16(2);
4709 pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB PDU from sess */ 4762 /* BB find exact max SMB PDU from sess structure BB */
4763 pSMB->MaxDataCount = cpu_to_le16(1000);
4710 pSMB->SetupCount = 1; 4764 pSMB->SetupCount = 1;
4711 pSMB->Reserved3 = 0; 4765 pSMB->Reserved3 = 0;
4712 pSMB->SubCommand = cpu_to_le16(TRANS2_SET_FILE_INFORMATION); 4766 pSMB->SubCommand = cpu_to_le16(TRANS2_SET_FILE_INFORMATION);
@@ -4793,7 +4847,8 @@ CIFSSMBSetFileTimes(const int xid, struct cifsTconInfo *tcon,
4793 4847
4794 count = sizeof(FILE_BASIC_INFO); 4848 count = sizeof(FILE_BASIC_INFO);
4795 pSMB->MaxParameterCount = cpu_to_le16(2); 4849 pSMB->MaxParameterCount = cpu_to_le16(2);
4796 pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB PDU from sess */ 4850 /* BB find max SMB PDU from sess */
4851 pSMB->MaxDataCount = cpu_to_le16(1000);
4797 pSMB->SetupCount = 1; 4852 pSMB->SetupCount = 1;
4798 pSMB->Reserved3 = 0; 4853 pSMB->Reserved3 = 0;
4799 pSMB->SubCommand = cpu_to_le16(TRANS2_SET_FILE_INFORMATION); 4854 pSMB->SubCommand = cpu_to_le16(TRANS2_SET_FILE_INFORMATION);
@@ -4860,7 +4915,8 @@ SetTimesRetry:
4860 params = 6 + name_len; 4915 params = 6 + name_len;
4861 count = sizeof(FILE_BASIC_INFO); 4916 count = sizeof(FILE_BASIC_INFO);
4862 pSMB->MaxParameterCount = cpu_to_le16(2); 4917 pSMB->MaxParameterCount = cpu_to_le16(2);
4863 pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find exact max SMB PDU from sess structure BB */ 4918 /* BB find max SMB PDU from sess structure BB */
4919 pSMB->MaxDataCount = cpu_to_le16(1000);
4864 pSMB->MaxSetupCount = 0; 4920 pSMB->MaxSetupCount = 0;
4865 pSMB->Reserved = 0; 4921 pSMB->Reserved = 0;
4866 pSMB->Flags = 0; 4922 pSMB->Flags = 0;
@@ -4990,7 +5046,8 @@ setPermsRetry:
4990 params = 6 + name_len; 5046 params = 6 + name_len;
4991 count = sizeof(FILE_UNIX_BASIC_INFO); 5047 count = sizeof(FILE_UNIX_BASIC_INFO);
4992 pSMB->MaxParameterCount = cpu_to_le16(2); 5048 pSMB->MaxParameterCount = cpu_to_le16(2);
4993 pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find exact max SMB PDU from sess structure BB */ 5049 /* BB find max SMB PDU from sess structure BB */
5050 pSMB->MaxDataCount = cpu_to_le16(1000);
4994 pSMB->MaxSetupCount = 0; 5051 pSMB->MaxSetupCount = 0;
4995 pSMB->Reserved = 0; 5052 pSMB->Reserved = 0;
4996 pSMB->Flags = 0; 5053 pSMB->Flags = 0;
@@ -5055,8 +5112,7 @@ setPermsRetry:
5055 if (rc) 5112 if (rc)
5056 cFYI(1, ("SetPathInfo (perms) returned %d", rc)); 5113 cFYI(1, ("SetPathInfo (perms) returned %d", rc));
5057 5114
5058 if (pSMB) 5115 cifs_buf_release(pSMB);
5059 cifs_buf_release(pSMB);
5060 if (rc == -EAGAIN) 5116 if (rc == -EAGAIN)
5061 goto setPermsRetry; 5117 goto setPermsRetry;
5062 return rc; 5118 return rc;
@@ -5173,7 +5229,8 @@ QAllEAsRetry:
5173 params = 2 /* level */ + 4 /* reserved */ + name_len /* includes NUL */; 5229 params = 2 /* level */ + 4 /* reserved */ + name_len /* includes NUL */;
5174 pSMB->TotalDataCount = 0; 5230 pSMB->TotalDataCount = 0;
5175 pSMB->MaxParameterCount = cpu_to_le16(2); 5231 pSMB->MaxParameterCount = cpu_to_le16(2);
5176 pSMB->MaxDataCount = cpu_to_le16(4000); /* BB find exact max SMB PDU from sess structure BB */ 5232 /* BB find exact max SMB PDU from sess structure BB */
5233 pSMB->MaxDataCount = cpu_to_le16(4000);
5177 pSMB->MaxSetupCount = 0; 5234 pSMB->MaxSetupCount = 0;
5178 pSMB->Reserved = 0; 5235 pSMB->Reserved = 0;
5179 pSMB->Flags = 0; 5236 pSMB->Flags = 0;
@@ -5277,8 +5334,7 @@ QAllEAsRetry:
5277 } 5334 }
5278 } 5335 }
5279 } 5336 }
5280 if (pSMB) 5337 cifs_buf_release(pSMB);
5281 cifs_buf_release(pSMB);
5282 if (rc == -EAGAIN) 5338 if (rc == -EAGAIN)
5283 goto QAllEAsRetry; 5339 goto QAllEAsRetry;
5284 5340
@@ -5321,7 +5377,8 @@ QEARetry:
5321 params = 2 /* level */ + 4 /* reserved */ + name_len /* includes NUL */; 5377 params = 2 /* level */ + 4 /* reserved */ + name_len /* includes NUL */;
5322 pSMB->TotalDataCount = 0; 5378 pSMB->TotalDataCount = 0;
5323 pSMB->MaxParameterCount = cpu_to_le16(2); 5379 pSMB->MaxParameterCount = cpu_to_le16(2);
5324 pSMB->MaxDataCount = cpu_to_le16(4000); /* BB find exact max SMB PDU from sess structure BB */ 5380 /* BB find exact max SMB PDU from sess structure BB */
5381 pSMB->MaxDataCount = cpu_to_le16(4000);
5325 pSMB->MaxSetupCount = 0; 5382 pSMB->MaxSetupCount = 0;
5326 pSMB->Reserved = 0; 5383 pSMB->Reserved = 0;
5327 pSMB->Flags = 0; 5384 pSMB->Flags = 0;
@@ -5426,8 +5483,7 @@ QEARetry:
5426 } 5483 }
5427 } 5484 }
5428 } 5485 }
5429 if (pSMB) 5486 cifs_buf_release(pSMB);
5430 cifs_buf_release(pSMB);
5431 if (rc == -EAGAIN) 5487 if (rc == -EAGAIN)
5432 goto QEARetry; 5488 goto QEARetry;
5433 5489
@@ -5479,7 +5535,8 @@ SetEARetry:
5479 5535
5480 count = sizeof(*parm_data) + ea_value_len + name_len; 5536 count = sizeof(*parm_data) + ea_value_len + name_len;
5481 pSMB->MaxParameterCount = cpu_to_le16(2); 5537 pSMB->MaxParameterCount = cpu_to_le16(2);
5482 pSMB->MaxDataCount = cpu_to_le16(1000); /* BB find max SMB size from sess */ 5538 /* BB find max SMB PDU from sess */
5539 pSMB->MaxDataCount = cpu_to_le16(1000);
5483 pSMB->MaxSetupCount = 0; 5540 pSMB->MaxSetupCount = 0;
5484 pSMB->Reserved = 0; 5541 pSMB->Reserved = 0;
5485 pSMB->Flags = 0; 5542 pSMB->Flags = 0;
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 791ca5c1a116..e8fa46c7cff2 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -60,7 +60,7 @@ struct smb_vol {
60 char *domainname; 60 char *domainname;
61 char *UNC; 61 char *UNC;
62 char *UNCip; 62 char *UNCip;
63 char *in6_addr; /* ipv6 address as human readable form of in6_addr */ 63 char *in6_addr; /* ipv6 address as human readable form of in6_addr */
64 char *iocharset; /* local code page for mapping to and from Unicode */ 64 char *iocharset; /* local code page for mapping to and from Unicode */
65 char source_rfc1001_name[16]; /* netbios name of client */ 65 char source_rfc1001_name[16]; /* netbios name of client */
66 char target_rfc1001_name[16]; /* netbios name of server for Win9x/ME */ 66 char target_rfc1001_name[16]; /* netbios name of server for Win9x/ME */
@@ -75,19 +75,21 @@ struct smb_vol {
75 bool setuids:1; 75 bool setuids:1;
76 bool override_uid:1; 76 bool override_uid:1;
77 bool override_gid:1; 77 bool override_gid:1;
78 bool dynperm:1;
78 bool noperm:1; 79 bool noperm:1;
79 bool no_psx_acl:1; /* set if posix acl support should be disabled */ 80 bool no_psx_acl:1; /* set if posix acl support should be disabled */
80 bool cifs_acl:1; 81 bool cifs_acl:1;
81 bool no_xattr:1; /* set if xattr (EA) support should be disabled*/ 82 bool no_xattr:1; /* set if xattr (EA) support should be disabled*/
82 bool server_ino:1; /* use inode numbers from server ie UniqueId */ 83 bool server_ino:1; /* use inode numbers from server ie UniqueId */
83 bool direct_io:1; 84 bool direct_io:1;
84 bool remap:1; /* set to remap seven reserved chars in filenames */ 85 bool remap:1; /* set to remap seven reserved chars in filenames */
85 bool posix_paths:1; /* unset to not ask for posix pathnames. */ 86 bool posix_paths:1; /* unset to not ask for posix pathnames. */
86 bool no_linux_ext:1; 87 bool no_linux_ext:1;
87 bool sfu_emul:1; 88 bool sfu_emul:1;
88 bool nullauth:1; /* attempt to authenticate with null user */ 89 bool nullauth:1; /* attempt to authenticate with null user */
89 unsigned nocase; /* request case insensitive filenames */ 90 bool nocase:1; /* request case insensitive filenames */
90 unsigned nobrl; /* disable sending byte range locks to srv */ 91 bool nobrl:1; /* disable sending byte range locks to srv */
92 bool seal:1; /* request transport encryption on share */
91 unsigned int rsize; 93 unsigned int rsize;
92 unsigned int wsize; 94 unsigned int wsize;
93 unsigned int sockopt; 95 unsigned int sockopt;
@@ -348,7 +350,6 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
348 int reconnect; 350 int reconnect;
349 351
350 current->flags |= PF_MEMALLOC; 352 current->flags |= PF_MEMALLOC;
351 server->tsk = current; /* save process info to wake at shutdown */
352 cFYI(1, ("Demultiplex PID: %d", task_pid_nr(current))); 353 cFYI(1, ("Demultiplex PID: %d", task_pid_nr(current)));
353 write_lock(&GlobalSMBSeslock); 354 write_lock(&GlobalSMBSeslock);
354 atomic_inc(&tcpSesAllocCount); 355 atomic_inc(&tcpSesAllocCount);
@@ -651,10 +652,21 @@ multi_t2_fnd:
651 652
652 spin_lock(&GlobalMid_Lock); 653 spin_lock(&GlobalMid_Lock);
653 server->tcpStatus = CifsExiting; 654 server->tcpStatus = CifsExiting;
654 server->tsk = NULL; 655 spin_unlock(&GlobalMid_Lock);
656 wake_up_all(&server->response_q);
657
658 /* don't exit until kthread_stop is called */
659 set_current_state(TASK_UNINTERRUPTIBLE);
660 while (!kthread_should_stop()) {
661 schedule();
662 set_current_state(TASK_UNINTERRUPTIBLE);
663 }
664 set_current_state(TASK_RUNNING);
665
655 /* check if we have blocked requests that need to free */ 666 /* check if we have blocked requests that need to free */
656 /* Note that cifs_max_pending is normally 50, but 667 /* Note that cifs_max_pending is normally 50, but
657 can be set at module install time to as little as two */ 668 can be set at module install time to as little as two */
669 spin_lock(&GlobalMid_Lock);
658 if (atomic_read(&server->inFlight) >= cifs_max_pending) 670 if (atomic_read(&server->inFlight) >= cifs_max_pending)
659 atomic_set(&server->inFlight, cifs_max_pending - 1); 671 atomic_set(&server->inFlight, cifs_max_pending - 1);
660 /* We do not want to set the max_pending too low or we 672 /* We do not want to set the max_pending too low or we
@@ -1237,6 +1249,10 @@ cifs_parse_mount_options(char *options, const char *devname,
1237 vol->setuids = 1; 1249 vol->setuids = 1;
1238 } else if (strnicmp(data, "nosetuids", 9) == 0) { 1250 } else if (strnicmp(data, "nosetuids", 9) == 0) {
1239 vol->setuids = 0; 1251 vol->setuids = 0;
1252 } else if (strnicmp(data, "dynperm", 7) == 0) {
1253 vol->dynperm = true;
1254 } else if (strnicmp(data, "nodynperm", 9) == 0) {
1255 vol->dynperm = false;
1240 } else if (strnicmp(data, "nohard", 6) == 0) { 1256 } else if (strnicmp(data, "nohard", 6) == 0) {
1241 vol->retry = 0; 1257 vol->retry = 0;
1242 } else if (strnicmp(data, "nosoft", 6) == 0) { 1258 } else if (strnicmp(data, "nosoft", 6) == 0) {
@@ -1259,8 +1275,12 @@ cifs_parse_mount_options(char *options, const char *devname,
1259 vol->no_psx_acl = 1; 1275 vol->no_psx_acl = 1;
1260 } else if (strnicmp(data, "sign", 4) == 0) { 1276 } else if (strnicmp(data, "sign", 4) == 0) {
1261 vol->secFlg |= CIFSSEC_MUST_SIGN; 1277 vol->secFlg |= CIFSSEC_MUST_SIGN;
1262/* } else if (strnicmp(data, "seal",4) == 0) { 1278 } else if (strnicmp(data, "seal", 4) == 0) {
1263 vol->secFlg |= CIFSSEC_MUST_SEAL; */ 1279 /* we do not do the following in secFlags because seal
1280 is a per tree connection (mount) not a per socket
1281 or per-smb connection option in the protocol */
1282 /* vol->secFlg |= CIFSSEC_MUST_SEAL; */
1283 vol->seal = 1;
1264 } else if (strnicmp(data, "direct", 6) == 0) { 1284 } else if (strnicmp(data, "direct", 6) == 0) {
1265 vol->direct_io = 1; 1285 vol->direct_io = 1;
1266 } else if (strnicmp(data, "forcedirectio", 13) == 0) { 1286 } else if (strnicmp(data, "forcedirectio", 13) == 0) {
@@ -1318,42 +1338,43 @@ cifs_parse_mount_options(char *options, const char *devname,
1318 1338
1319static struct cifsSesInfo * 1339static struct cifsSesInfo *
1320cifs_find_tcp_session(struct in_addr *target_ip_addr, 1340cifs_find_tcp_session(struct in_addr *target_ip_addr,
1321 struct in6_addr *target_ip6_addr, 1341 struct in6_addr *target_ip6_addr,
1322 char *userName, struct TCP_Server_Info **psrvTcp) 1342 char *userName, struct TCP_Server_Info **psrvTcp)
1323{ 1343{
1324 struct list_head *tmp; 1344 struct list_head *tmp;
1325 struct cifsSesInfo *ses; 1345 struct cifsSesInfo *ses;
1346
1326 *psrvTcp = NULL; 1347 *psrvTcp = NULL;
1327 read_lock(&GlobalSMBSeslock);
1328 1348
1349 read_lock(&GlobalSMBSeslock);
1329 list_for_each(tmp, &GlobalSMBSessionList) { 1350 list_for_each(tmp, &GlobalSMBSessionList) {
1330 ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); 1351 ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList);
1331 if (ses->server) { 1352 if (!ses->server)
1332 if ((target_ip_addr && 1353 continue;
1333 (ses->server->addr.sockAddr.sin_addr.s_addr 1354
1334 == target_ip_addr->s_addr)) || (target_ip6_addr 1355 if (target_ip_addr &&
1335 && memcmp(&ses->server->addr.sockAddr6.sin6_addr, 1356 ses->server->addr.sockAddr.sin_addr.s_addr != target_ip_addr->s_addr)
1336 target_ip6_addr, sizeof(*target_ip6_addr)))) { 1357 continue;
1337 /* BB lock server and tcp session and increment 1358 else if (target_ip6_addr &&
1338 use count here?? */ 1359 memcmp(&ses->server->addr.sockAddr6.sin6_addr,
1339 1360 target_ip6_addr, sizeof(*target_ip6_addr)))
1340 /* found a match on the TCP session */ 1361 continue;
1341 *psrvTcp = ses->server; 1362 /* BB lock server and tcp session; increment use count here?? */
1342 1363
1343 /* BB check if reconnection needed */ 1364 /* found a match on the TCP session */
1344 if (strncmp 1365 *psrvTcp = ses->server;
1345 (ses->userName, userName, 1366
1346 MAX_USERNAME_SIZE) == 0){ 1367 /* BB check if reconnection needed */
1347 read_unlock(&GlobalSMBSeslock); 1368 if (strncmp(ses->userName, userName, MAX_USERNAME_SIZE) == 0) {
1348 /* Found exact match on both TCP and 1369 read_unlock(&GlobalSMBSeslock);
1349 SMB sessions */ 1370 /* Found exact match on both TCP and
1350 return ses; 1371 SMB sessions */
1351 } 1372 return ses;
1352 }
1353 } 1373 }
1354 /* else tcp and smb sessions need reconnection */ 1374 /* else tcp and smb sessions need reconnection */
1355 } 1375 }
1356 read_unlock(&GlobalSMBSeslock); 1376 read_unlock(&GlobalSMBSeslock);
1377
1357 return NULL; 1378 return NULL;
1358} 1379}
1359 1380
@@ -1404,34 +1425,12 @@ find_unc(__be32 new_target_ip_addr, char *uncName, char *userName)
1404} 1425}
1405 1426
1406int 1427int
1407connect_to_dfs_path(int xid, struct cifsSesInfo *pSesInfo,
1408 const char *old_path, const struct nls_table *nls_codepage,
1409 int remap)
1410{
1411 struct dfs_info3_param *referrals = NULL;
1412 unsigned int num_referrals;
1413 int rc = 0;
1414
1415 rc = get_dfs_path(xid, pSesInfo, old_path, nls_codepage,
1416 &num_referrals, &referrals, remap);
1417
1418 /* BB Add in code to: if valid refrl, if not ip address contact
1419 the helper that resolves tcp names, mount to it, try to
1420 tcon to it unmount it if fail */
1421
1422 kfree(referrals);
1423
1424 return rc;
1425}
1426
1427int
1428get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, const char *old_path, 1428get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, const char *old_path,
1429 const struct nls_table *nls_codepage, unsigned int *pnum_referrals, 1429 const struct nls_table *nls_codepage, unsigned int *pnum_referrals,
1430 struct dfs_info3_param **preferrals, int remap) 1430 struct dfs_info3_param **preferrals, int remap)
1431{ 1431{
1432 char *temp_unc; 1432 char *temp_unc;
1433 int rc = 0; 1433 int rc = 0;
1434 unsigned char *targetUNCs;
1435 1434
1436 *pnum_referrals = 0; 1435 *pnum_referrals = 0;
1437 *preferrals = NULL; 1436 *preferrals = NULL;
@@ -1454,7 +1453,7 @@ get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, const char *old_path,
1454 kfree(temp_unc); 1453 kfree(temp_unc);
1455 } 1454 }
1456 if (rc == 0) 1455 if (rc == 0)
1457 rc = CIFSGetDFSRefer(xid, pSesInfo, old_path, &targetUNCs, 1456 rc = CIFSGetDFSRefer(xid, pSesInfo, old_path, preferrals,
1458 pnum_referrals, nls_codepage, remap); 1457 pnum_referrals, nls_codepage, remap);
1459 /* BB map targetUNCs to dfs_info3 structures, here or 1458 /* BB map targetUNCs to dfs_info3 structures, here or
1460 in CIFSGetDFSRefer BB */ 1459 in CIFSGetDFSRefer BB */
@@ -1805,7 +1804,7 @@ convert_delimiter(char *path, char delim)
1805 if (path == NULL) 1804 if (path == NULL)
1806 return; 1805 return;
1807 1806
1808 if (delim == '/') 1807 if (delim == '/')
1809 old_delim = '\\'; 1808 old_delim = '\\';
1810 else 1809 else
1811 old_delim = '/'; 1810 old_delim = '/';
@@ -2115,11 +2114,17 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2115 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_UID; 2114 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_UID;
2116 if (volume_info.override_gid) 2115 if (volume_info.override_gid)
2117 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_GID; 2116 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_GID;
2117 if (volume_info.dynperm)
2118 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DYNPERM;
2118 if (volume_info.direct_io) { 2119 if (volume_info.direct_io) {
2119 cFYI(1, ("mounting share using direct i/o")); 2120 cFYI(1, ("mounting share using direct i/o"));
2120 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DIRECT_IO; 2121 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DIRECT_IO;
2121 } 2122 }
2122 2123
2124 if ((volume_info.cifs_acl) && (volume_info.dynperm))
2125 cERROR(1, ("mount option dynperm ignored if cifsacl "
2126 "mount option supported"));
2127
2123 tcon = 2128 tcon =
2124 find_unc(sin_server.sin_addr.s_addr, volume_info.UNC, 2129 find_unc(sin_server.sin_addr.s_addr, volume_info.UNC,
2125 volume_info.username); 2130 volume_info.username);
@@ -2131,6 +2136,9 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2131 for the retry flag is used */ 2136 for the retry flag is used */
2132 tcon->retry = volume_info.retry; 2137 tcon->retry = volume_info.retry;
2133 tcon->nocase = volume_info.nocase; 2138 tcon->nocase = volume_info.nocase;
2139 if (tcon->seal != volume_info.seal)
2140 cERROR(1, ("transport encryption setting "
2141 "conflicts with existing tid"));
2134 } else { 2142 } else {
2135 tcon = tconInfoAlloc(); 2143 tcon = tconInfoAlloc();
2136 if (tcon == NULL) 2144 if (tcon == NULL)
@@ -2144,10 +2152,11 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2144 if ((strchr(volume_info.UNC + 3, '\\') == NULL) 2152 if ((strchr(volume_info.UNC + 3, '\\') == NULL)
2145 && (strchr(volume_info.UNC + 3, '/') == 2153 && (strchr(volume_info.UNC + 3, '/') ==
2146 NULL)) { 2154 NULL)) {
2147 rc = connect_to_dfs_path(xid, pSesInfo, 2155/* rc = connect_to_dfs_path(xid, pSesInfo,
2148 "", cifs_sb->local_nls, 2156 "", cifs_sb->local_nls,
2149 cifs_sb->mnt_cifs_flags & 2157 cifs_sb->mnt_cifs_flags &
2150 CIFS_MOUNT_MAP_SPECIAL_CHR); 2158 CIFS_MOUNT_MAP_SPECIAL_CHR);*/
2159 cFYI(1, ("DFS root not supported"));
2151 rc = -ENODEV; 2160 rc = -ENODEV;
2152 goto out; 2161 goto out;
2153 } else { 2162 } else {
@@ -2163,6 +2172,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2163 atomic_inc(&pSesInfo->inUse); 2172 atomic_inc(&pSesInfo->inUse);
2164 tcon->retry = volume_info.retry; 2173 tcon->retry = volume_info.retry;
2165 tcon->nocase = volume_info.nocase; 2174 tcon->nocase = volume_info.nocase;
2175 tcon->seal = volume_info.seal;
2166 } 2176 }
2167 } 2177 }
2168 } 2178 }
@@ -2186,15 +2196,12 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2186 srvTcp->tcpStatus = CifsExiting; 2196 srvTcp->tcpStatus = CifsExiting;
2187 spin_unlock(&GlobalMid_Lock); 2197 spin_unlock(&GlobalMid_Lock);
2188 if (srvTcp->tsk) { 2198 if (srvTcp->tsk) {
2189 struct task_struct *tsk;
2190 /* If we could verify that kthread_stop would 2199 /* If we could verify that kthread_stop would
2191 always wake up processes blocked in 2200 always wake up processes blocked in
2192 tcp in recv_mesg then we could remove the 2201 tcp in recv_mesg then we could remove the
2193 send_sig call */ 2202 send_sig call */
2194 force_sig(SIGKILL, srvTcp->tsk); 2203 force_sig(SIGKILL, srvTcp->tsk);
2195 tsk = srvTcp->tsk; 2204 kthread_stop(srvTcp->tsk);
2196 if (tsk)
2197 kthread_stop(tsk);
2198 } 2205 }
2199 } 2206 }
2200 /* If find_unc succeeded then rc == 0 so we can not end */ 2207 /* If find_unc succeeded then rc == 0 so we can not end */
@@ -2210,23 +2217,17 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2210 if ((temp_rc == -ESHUTDOWN) && 2217 if ((temp_rc == -ESHUTDOWN) &&
2211 (pSesInfo->server) && 2218 (pSesInfo->server) &&
2212 (pSesInfo->server->tsk)) { 2219 (pSesInfo->server->tsk)) {
2213 struct task_struct *tsk;
2214 force_sig(SIGKILL, 2220 force_sig(SIGKILL,
2215 pSesInfo->server->tsk); 2221 pSesInfo->server->tsk);
2216 tsk = pSesInfo->server->tsk; 2222 kthread_stop(pSesInfo->server->tsk);
2217 if (tsk)
2218 kthread_stop(tsk);
2219 } 2223 }
2220 } else { 2224 } else {
2221 cFYI(1, ("No session or bad tcon")); 2225 cFYI(1, ("No session or bad tcon"));
2222 if ((pSesInfo->server) && 2226 if ((pSesInfo->server) &&
2223 (pSesInfo->server->tsk)) { 2227 (pSesInfo->server->tsk)) {
2224 struct task_struct *tsk;
2225 force_sig(SIGKILL, 2228 force_sig(SIGKILL,
2226 pSesInfo->server->tsk); 2229 pSesInfo->server->tsk);
2227 tsk = pSesInfo->server->tsk; 2230 kthread_stop(pSesInfo->server->tsk);
2228 if (tsk)
2229 kthread_stop(tsk);
2230 } 2231 }
2231 } 2232 }
2232 sesInfoFree(pSesInfo); 2233 sesInfoFree(pSesInfo);
@@ -2313,9 +2314,10 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2313 user = ses->userName; 2314 user = ses->userName;
2314 domain = ses->domainName; 2315 domain = ses->domainName;
2315 smb_buffer = cifs_buf_get(); 2316 smb_buffer = cifs_buf_get();
2316 if (smb_buffer == NULL) { 2317
2318 if (smb_buffer == NULL)
2317 return -ENOMEM; 2319 return -ENOMEM;
2318 } 2320
2319 smb_buffer_response = smb_buffer; 2321 smb_buffer_response = smb_buffer;
2320 pSMBr = pSMB = (SESSION_SETUP_ANDX *) smb_buffer; 2322 pSMBr = pSMB = (SESSION_SETUP_ANDX *) smb_buffer;
2321 2323
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index 6ed775986be9..fb69c1fa85c9 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -49,18 +49,25 @@ build_path_from_dentry(struct dentry *direntry)
49 struct dentry *temp; 49 struct dentry *temp;
50 int namelen; 50 int namelen;
51 int pplen; 51 int pplen;
52 int dfsplen;
52 char *full_path; 53 char *full_path;
53 char dirsep; 54 char dirsep;
55 struct cifs_sb_info *cifs_sb;
54 56
55 if (direntry == NULL) 57 if (direntry == NULL)
56 return NULL; /* not much we can do if dentry is freed and 58 return NULL; /* not much we can do if dentry is freed and
57 we need to reopen the file after it was closed implicitly 59 we need to reopen the file after it was closed implicitly
58 when the server crashed */ 60 when the server crashed */
59 61
60 dirsep = CIFS_DIR_SEP(CIFS_SB(direntry->d_sb)); 62 cifs_sb = CIFS_SB(direntry->d_sb);
61 pplen = CIFS_SB(direntry->d_sb)->prepathlen; 63 dirsep = CIFS_DIR_SEP(cifs_sb);
64 pplen = cifs_sb->prepathlen;
65 if (cifs_sb->tcon && (cifs_sb->tcon->Flags & SMB_SHARE_IS_IN_DFS))
66 dfsplen = strnlen(cifs_sb->tcon->treeName, MAX_TREE_SIZE + 1);
67 else
68 dfsplen = 0;
62cifs_bp_rename_retry: 69cifs_bp_rename_retry:
63 namelen = pplen; 70 namelen = pplen + dfsplen;
64 for (temp = direntry; !IS_ROOT(temp);) { 71 for (temp = direntry; !IS_ROOT(temp);) {
65 namelen += (1 + temp->d_name.len); 72 namelen += (1 + temp->d_name.len);
66 temp = temp->d_parent; 73 temp = temp->d_parent;
@@ -91,7 +98,7 @@ cifs_bp_rename_retry:
91 return NULL; 98 return NULL;
92 } 99 }
93 } 100 }
94 if (namelen != pplen) { 101 if (namelen != pplen + dfsplen) {
95 cERROR(1, 102 cERROR(1,
96 ("did not end path lookup where expected namelen is %d", 103 ("did not end path lookup where expected namelen is %d",
97 namelen)); 104 namelen));
@@ -107,7 +114,18 @@ cifs_bp_rename_retry:
107 since the '\' is a valid posix character so we can not switch 114 since the '\' is a valid posix character so we can not switch
108 those safely to '/' if any are found in the middle of the prepath */ 115 those safely to '/' if any are found in the middle of the prepath */
109 /* BB test paths to Windows with '/' in the midst of prepath */ 116 /* BB test paths to Windows with '/' in the midst of prepath */
110 strncpy(full_path, CIFS_SB(direntry->d_sb)->prepath, pplen); 117
118 if (dfsplen) {
119 strncpy(full_path, cifs_sb->tcon->treeName, dfsplen);
120 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) {
121 int i;
122 for (i = 0; i < dfsplen; i++) {
123 if (full_path[i] == '\\')
124 full_path[i] = '/';
125 }
126 }
127 }
128 strncpy(full_path + dfsplen, CIFS_SB(direntry->d_sb)->prepath, pplen);
111 return full_path; 129 return full_path;
112} 130}
113 131
@@ -119,6 +137,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
119{ 137{
120 int rc = -ENOENT; 138 int rc = -ENOENT;
121 int xid; 139 int xid;
140 int create_options = CREATE_NOT_DIR;
122 int oplock = 0; 141 int oplock = 0;
123 int desiredAccess = GENERIC_READ | GENERIC_WRITE; 142 int desiredAccess = GENERIC_READ | GENERIC_WRITE;
124 __u16 fileHandle; 143 __u16 fileHandle;
@@ -176,9 +195,19 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
176 FreeXid(xid); 195 FreeXid(xid);
177 return -ENOMEM; 196 return -ENOMEM;
178 } 197 }
198
199 mode &= ~current->fs->umask;
200
201 /*
202 * if we're not using unix extensions, see if we need to set
203 * ATTR_READONLY on the create call
204 */
205 if (!pTcon->unix_ext && (mode & S_IWUGO) == 0)
206 create_options |= CREATE_OPTION_READONLY;
207
179 if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS) 208 if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS)
180 rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, 209 rc = CIFSSMBOpen(xid, pTcon, full_path, disposition,
181 desiredAccess, CREATE_NOT_DIR, 210 desiredAccess, create_options,
182 &fileHandle, &oplock, buf, cifs_sb->local_nls, 211 &fileHandle, &oplock, buf, cifs_sb->local_nls,
183 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 212 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
184 else 213 else
@@ -187,7 +216,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
187 if (rc == -EIO) { 216 if (rc == -EIO) {
188 /* old server, retry the open legacy style */ 217 /* old server, retry the open legacy style */
189 rc = SMBLegacyOpen(xid, pTcon, full_path, disposition, 218 rc = SMBLegacyOpen(xid, pTcon, full_path, disposition,
190 desiredAccess, CREATE_NOT_DIR, 219 desiredAccess, create_options,
191 &fileHandle, &oplock, buf, cifs_sb->local_nls, 220 &fileHandle, &oplock, buf, cifs_sb->local_nls,
192 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 221 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
193 } 222 }
@@ -197,7 +226,6 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
197 /* If Open reported that we actually created a file 226 /* If Open reported that we actually created a file
198 then we now have to set the mode if possible */ 227 then we now have to set the mode if possible */
199 if ((pTcon->unix_ext) && (oplock & CIFS_CREATE_ACTION)) { 228 if ((pTcon->unix_ext) && (oplock & CIFS_CREATE_ACTION)) {
200 mode &= ~current->fs->umask;
201 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { 229 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
202 CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, 230 CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode,
203 (__u64)current->fsuid, 231 (__u64)current->fsuid,
@@ -232,7 +260,9 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
232 buf, inode->i_sb, xid, 260 buf, inode->i_sb, xid,
233 &fileHandle); 261 &fileHandle);
234 if (newinode) { 262 if (newinode) {
235 newinode->i_mode = mode; 263 if (cifs_sb->mnt_cifs_flags &
264 CIFS_MOUNT_DYNPERM)
265 newinode->i_mode = mode;
236 if ((oplock & CIFS_CREATE_ACTION) && 266 if ((oplock & CIFS_CREATE_ACTION) &&
237 (cifs_sb->mnt_cifs_flags & 267 (cifs_sb->mnt_cifs_flags &
238 CIFS_MOUNT_SET_UID)) { 268 CIFS_MOUNT_SET_UID)) {
@@ -580,7 +610,7 @@ static int cifs_ci_compare(struct dentry *dentry, struct qstr *a,
580 * case take precedence. If a is not a negative dentry, this 610 * case take precedence. If a is not a negative dentry, this
581 * should have no side effects 611 * should have no side effects
582 */ 612 */
583 memcpy(a->name, b->name, a->len); 613 memcpy((void *)a->name, b->name, a->len);
584 return 0; 614 return 0;
585 } 615 }
586 return 1; 616 return 1;
diff --git a/fs/cifs/dns_resolve.c b/fs/cifs/dns_resolve.c
index 939e256f8497..f730ef35499e 100644
--- a/fs/cifs/dns_resolve.c
+++ b/fs/cifs/dns_resolve.c
@@ -134,10 +134,6 @@ dns_resolve_server_name_to_ip(const char *unc, char **ip_addr)
134 rkey = request_key(&key_type_dns_resolver, name, ""); 134 rkey = request_key(&key_type_dns_resolver, name, "");
135 if (!IS_ERR(rkey)) { 135 if (!IS_ERR(rkey)) {
136 data = rkey->payload.data; 136 data = rkey->payload.data;
137 cFYI(1, ("%s: resolved: %s to %s", __func__,
138 rkey->description,
139 *ip_addr
140 ));
141 } else { 137 } else {
142 cERROR(1, ("%s: unable to resolve: %s", __func__, name)); 138 cERROR(1, ("%s: unable to resolve: %s", __func__, name));
143 goto out; 139 goto out;
@@ -150,6 +146,11 @@ skip_upcall:
150 if (*ip_addr) { 146 if (*ip_addr) {
151 memcpy(*ip_addr, data, len); 147 memcpy(*ip_addr, data, len);
152 (*ip_addr)[len] = '\0'; 148 (*ip_addr)[len] = '\0';
149 if (!IS_ERR(rkey))
150 cFYI(1, ("%s: resolved: %s to %s", __func__,
151 name,
152 *ip_addr
153 ));
153 rc = 0; 154 rc = 0;
154 } else { 155 } else {
155 rc = -ENOMEM; 156 rc = -ENOMEM;
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 31a0a33b9d95..0aac824371a5 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -75,7 +75,11 @@ static inline int cifs_convert_flags(unsigned int flags)
75 return (GENERIC_READ | GENERIC_WRITE); 75 return (GENERIC_READ | GENERIC_WRITE);
76 } 76 }
77 77
78 return 0x20197; 78 return (READ_CONTROL | FILE_WRITE_ATTRIBUTES | FILE_READ_ATTRIBUTES |
79 FILE_WRITE_EA | FILE_APPEND_DATA | FILE_WRITE_DATA |
80 FILE_READ_DATA);
81
82
79} 83}
80 84
81static inline int cifs_get_disposition(unsigned int flags) 85static inline int cifs_get_disposition(unsigned int flags)
@@ -542,7 +546,6 @@ int cifs_close(struct inode *inode, struct file *file)
542 msleep(timeout); 546 msleep(timeout);
543 timeout *= 8; 547 timeout *= 8;
544 } 548 }
545 kfree(pSMBFile->search_resume_name);
546 kfree(file->private_data); 549 kfree(file->private_data);
547 file->private_data = NULL; 550 file->private_data = NULL;
548 } else 551 } else
@@ -601,12 +604,6 @@ int cifs_closedir(struct inode *inode, struct file *file)
601 else 604 else
602 cifs_buf_release(ptmp); 605 cifs_buf_release(ptmp);
603 } 606 }
604 ptmp = pCFileStruct->search_resume_name;
605 if (ptmp) {
606 cFYI(1, ("closedir free resume name"));
607 pCFileStruct->search_resume_name = NULL;
608 kfree(ptmp);
609 }
610 kfree(file->private_data); 607 kfree(file->private_data);
611 file->private_data = NULL; 608 file->private_data = NULL;
612 } 609 }
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 0d9d2e6d7af6..722be543ceec 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -161,118 +161,115 @@ static void cifs_unix_info_to_inode(struct inode *inode,
161 spin_unlock(&inode->i_lock); 161 spin_unlock(&inode->i_lock);
162} 162}
163 163
164static const unsigned char *cifs_get_search_path(struct cifs_sb_info *cifs_sb,
165 const char *search_path)
166{
167 int tree_len;
168 int path_len;
169 int i;
170 char *tmp_path;
171 struct cifsTconInfo *pTcon = cifs_sb->tcon;
172
173 if (!(pTcon->Flags & SMB_SHARE_IS_IN_DFS))
174 return search_path;
175
176 /* use full path name for working with DFS */
177 tree_len = strnlen(pTcon->treeName, MAX_TREE_SIZE + 1);
178 path_len = strnlen(search_path, MAX_PATHCONF);
179 164
180 tmp_path = kmalloc(tree_len+path_len+1, GFP_KERNEL); 165/*
181 if (tmp_path == NULL) 166 * Needed to setup inode data for the directory which is the
182 return search_path; 167 * junction to the new submount (ie to setup the fake directory
168 * which represents a DFS referral)
169 */
170static void fill_fake_finddataunix(FILE_UNIX_BASIC_INFO *pfnd_dat,
171 struct super_block *sb)
172{
173 struct inode *pinode = NULL;
174
175 memset(pfnd_dat, 0, sizeof(FILE_UNIX_BASIC_INFO));
176
177/* __le64 pfnd_dat->EndOfFile = cpu_to_le64(0);
178 __le64 pfnd_dat->NumOfBytes = cpu_to_le64(0);
179 __u64 UniqueId = 0; */
180 pfnd_dat->LastStatusChange =
181 cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME));
182 pfnd_dat->LastAccessTime =
183 cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME));
184 pfnd_dat->LastModificationTime =
185 cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME));
186 pfnd_dat->Type = cpu_to_le32(UNIX_DIR);
187 pfnd_dat->Permissions = cpu_to_le64(S_IXUGO | S_IRWXU);
188 pfnd_dat->Nlinks = cpu_to_le64(2);
189 if (sb->s_root)
190 pinode = sb->s_root->d_inode;
191 if (pinode == NULL)
192 return;
183 193
184 strncpy(tmp_path, pTcon->treeName, tree_len); 194 /* fill in default values for the remaining based on root
185 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) 195 inode since we can not query the server for this inode info */
186 for (i = 0; i < tree_len; i++) { 196 pfnd_dat->DevMajor = cpu_to_le64(MAJOR(pinode->i_rdev));
187 if (tmp_path[i] == '\\') 197 pfnd_dat->DevMinor = cpu_to_le64(MINOR(pinode->i_rdev));
188 tmp_path[i] = '/'; 198 pfnd_dat->Uid = cpu_to_le64(pinode->i_uid);
189 } 199 pfnd_dat->Gid = cpu_to_le64(pinode->i_gid);
190 strncpy(tmp_path+tree_len, search_path, path_len);
191 tmp_path[tree_len+path_len] = 0;
192 return tmp_path;
193} 200}
194 201
195int cifs_get_inode_info_unix(struct inode **pinode, 202int cifs_get_inode_info_unix(struct inode **pinode,
196 const unsigned char *search_path, struct super_block *sb, int xid) 203 const unsigned char *full_path, struct super_block *sb, int xid)
197{ 204{
198 int rc = 0; 205 int rc = 0;
199 FILE_UNIX_BASIC_INFO findData; 206 FILE_UNIX_BASIC_INFO find_data;
200 struct cifsTconInfo *pTcon; 207 struct cifsTconInfo *pTcon;
201 struct inode *inode; 208 struct inode *inode;
202 struct cifs_sb_info *cifs_sb = CIFS_SB(sb); 209 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
203 const unsigned char *full_path;
204 bool is_dfs_referral = false; 210 bool is_dfs_referral = false;
211 struct cifsInodeInfo *cifsInfo;
212 __u64 num_of_bytes;
213 __u64 end_of_file;
205 214
206 pTcon = cifs_sb->tcon; 215 pTcon = cifs_sb->tcon;
207 cFYI(1, ("Getting info on %s", search_path)); 216 cFYI(1, ("Getting info on %s", full_path));
208 217
209 full_path = cifs_get_search_path(cifs_sb, search_path);
210
211try_again_CIFSSMBUnixQPathInfo:
212 /* could have done a find first instead but this returns more info */ 218 /* could have done a find first instead but this returns more info */
213 rc = CIFSSMBUnixQPathInfo(xid, pTcon, full_path, &findData, 219 rc = CIFSSMBUnixQPathInfo(xid, pTcon, full_path, &find_data,
214 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & 220 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
215 CIFS_MOUNT_MAP_SPECIAL_CHR); 221 CIFS_MOUNT_MAP_SPECIAL_CHR);
216/* dump_mem("\nUnixQPathInfo return data", &findData,
217 sizeof(findData)); */
218 if (rc) { 222 if (rc) {
219 if (rc == -EREMOTE && !is_dfs_referral) { 223 if (rc == -EREMOTE && !is_dfs_referral) {
220 is_dfs_referral = true; 224 is_dfs_referral = true;
221 if (full_path != search_path) { 225 cFYI(DBG2, ("DFS ref"));
222 kfree(full_path); 226 /* for DFS, server does not give us real inode data */
223 full_path = search_path; 227 fill_fake_finddataunix(&find_data, sb);
224 } 228 rc = 0;
225 goto try_again_CIFSSMBUnixQPathInfo;
226 } 229 }
227 goto cgiiu_exit; 230 }
228 } else { 231 num_of_bytes = le64_to_cpu(find_data.NumOfBytes);
229 struct cifsInodeInfo *cifsInfo; 232 end_of_file = le64_to_cpu(find_data.EndOfFile);
230 __u64 num_of_bytes = le64_to_cpu(findData.NumOfBytes);
231 __u64 end_of_file = le64_to_cpu(findData.EndOfFile);
232 233
233 /* get new inode */ 234 /* get new inode */
235 if (*pinode == NULL) {
236 *pinode = new_inode(sb);
234 if (*pinode == NULL) { 237 if (*pinode == NULL) {
235 *pinode = new_inode(sb); 238 rc = -ENOMEM;
236 if (*pinode == NULL) { 239 goto cgiiu_exit;
237 rc = -ENOMEM;
238 goto cgiiu_exit;
239 }
240 /* Is an i_ino of zero legal? */
241 /* Are there sanity checks we can use to ensure that
242 the server is really filling in that field? */
243 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
244 (*pinode)->i_ino =
245 (unsigned long)findData.UniqueId;
246 } /* note ino incremented to unique num in new_inode */
247 if (sb->s_flags & MS_NOATIME)
248 (*pinode)->i_flags |= S_NOATIME | S_NOCMTIME;
249
250 insert_inode_hash(*pinode);
251 } 240 }
241 /* Is an i_ino of zero legal? */
242 /* note ino incremented to unique num in new_inode */
243 /* Are there sanity checks we can use to ensure that
244 the server is really filling in that field? */
245 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)
246 (*pinode)->i_ino = (unsigned long)find_data.UniqueId;
252 247
253 inode = *pinode; 248 if (sb->s_flags & MS_NOATIME)
254 cifsInfo = CIFS_I(inode); 249 (*pinode)->i_flags |= S_NOATIME | S_NOCMTIME;
255 250
256 cFYI(1, ("Old time %ld", cifsInfo->time)); 251 insert_inode_hash(*pinode);
257 cifsInfo->time = jiffies; 252 }
258 cFYI(1, ("New time %ld", cifsInfo->time));
259 /* this is ok to set on every inode revalidate */
260 atomic_set(&cifsInfo->inUse, 1);
261 253
262 cifs_unix_info_to_inode(inode, &findData, 0); 254 inode = *pinode;
255 cifsInfo = CIFS_I(inode);
263 256
257 cFYI(1, ("Old time %ld", cifsInfo->time));
258 cifsInfo->time = jiffies;
259 cFYI(1, ("New time %ld", cifsInfo->time));
260 /* this is ok to set on every inode revalidate */
261 atomic_set(&cifsInfo->inUse, 1);
264 262
265 if (num_of_bytes < end_of_file) 263 cifs_unix_info_to_inode(inode, &find_data, 0);
266 cFYI(1, ("allocation size less than end of file"));
267 cFYI(1, ("Size %ld and blocks %llu",
268 (unsigned long) inode->i_size,
269 (unsigned long long)inode->i_blocks));
270 264
271 cifs_set_ops(inode, is_dfs_referral); 265 if (num_of_bytes < end_of_file)
272 } 266 cFYI(1, ("allocation size less than end of file"));
267 cFYI(1, ("Size %ld and blocks %llu",
268 (unsigned long) inode->i_size,
269 (unsigned long long)inode->i_blocks));
270
271 cifs_set_ops(inode, is_dfs_referral);
273cgiiu_exit: 272cgiiu_exit:
274 if (full_path != search_path)
275 kfree(full_path);
276 return rc; 273 return rc;
277} 274}
278 275
@@ -379,21 +376,52 @@ static int get_sfu_mode(struct inode *inode,
379#endif 376#endif
380} 377}
381 378
379/*
380 * Needed to setup inode data for the directory which is the
381 * junction to the new submount (ie to setup the fake directory
382 * which represents a DFS referral)
383 */
384static void fill_fake_finddata(FILE_ALL_INFO *pfnd_dat,
385 struct super_block *sb)
386{
387 memset(pfnd_dat, 0, sizeof(FILE_ALL_INFO));
388
389/* __le64 pfnd_dat->AllocationSize = cpu_to_le64(0);
390 __le64 pfnd_dat->EndOfFile = cpu_to_le64(0);
391 __u8 pfnd_dat->DeletePending = 0;
392 __u8 pfnd_data->Directory = 0;
393 __le32 pfnd_dat->EASize = 0;
394 __u64 pfnd_dat->IndexNumber = 0;
395 __u64 pfnd_dat->IndexNumber1 = 0; */
396 pfnd_dat->CreationTime =
397 cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME));
398 pfnd_dat->LastAccessTime =
399 cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME));
400 pfnd_dat->LastWriteTime =
401 cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME));
402 pfnd_dat->ChangeTime =
403 cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME));
404 pfnd_dat->Attributes = cpu_to_le32(ATTR_DIRECTORY);
405 pfnd_dat->NumberOfLinks = cpu_to_le32(2);
406}
407
382int cifs_get_inode_info(struct inode **pinode, 408int cifs_get_inode_info(struct inode **pinode,
383 const unsigned char *search_path, FILE_ALL_INFO *pfindData, 409 const unsigned char *full_path, FILE_ALL_INFO *pfindData,
384 struct super_block *sb, int xid, const __u16 *pfid) 410 struct super_block *sb, int xid, const __u16 *pfid)
385{ 411{
386 int rc = 0; 412 int rc = 0;
413 __u32 attr;
414 struct cifsInodeInfo *cifsInfo;
387 struct cifsTconInfo *pTcon; 415 struct cifsTconInfo *pTcon;
388 struct inode *inode; 416 struct inode *inode;
389 struct cifs_sb_info *cifs_sb = CIFS_SB(sb); 417 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
390 const unsigned char *full_path = NULL;
391 char *buf = NULL; 418 char *buf = NULL;
392 bool adjustTZ = false; 419 bool adjustTZ = false;
393 bool is_dfs_referral = false; 420 bool is_dfs_referral = false;
421 umode_t default_mode;
394 422
395 pTcon = cifs_sb->tcon; 423 pTcon = cifs_sb->tcon;
396 cFYI(1, ("Getting info on %s", search_path)); 424 cFYI(1, ("Getting info on %s", full_path));
397 425
398 if ((pfindData == NULL) && (*pinode != NULL)) { 426 if ((pfindData == NULL) && (*pinode != NULL)) {
399 if (CIFS_I(*pinode)->clientCanCacheRead) { 427 if (CIFS_I(*pinode)->clientCanCacheRead) {
@@ -409,9 +437,6 @@ int cifs_get_inode_info(struct inode **pinode,
409 return -ENOMEM; 437 return -ENOMEM;
410 pfindData = (FILE_ALL_INFO *)buf; 438 pfindData = (FILE_ALL_INFO *)buf;
411 439
412 full_path = cifs_get_search_path(cifs_sb, search_path);
413
414try_again_CIFSSMBQPathInfo:
415 /* could do find first instead but this returns more info */ 440 /* could do find first instead but this returns more info */
416 rc = CIFSSMBQPathInfo(xid, pTcon, full_path, pfindData, 441 rc = CIFSSMBQPathInfo(xid, pTcon, full_path, pfindData,
417 0 /* not legacy */, 442 0 /* not legacy */,
@@ -429,178 +454,163 @@ try_again_CIFSSMBQPathInfo:
429 } 454 }
430 } 455 }
431 /* dump_mem("\nQPathInfo return data",&findData, sizeof(findData)); */ 456 /* dump_mem("\nQPathInfo return data",&findData, sizeof(findData)); */
432 if (rc) { 457 if (rc == -EREMOTE) {
433 if (rc == -EREMOTE && !is_dfs_referral) { 458 is_dfs_referral = true;
434 is_dfs_referral = true; 459 fill_fake_finddata(pfindData, sb);
435 if (full_path != search_path) { 460 rc = 0;
436 kfree(full_path); 461 } else if (rc)
437 full_path = search_path;
438 }
439 goto try_again_CIFSSMBQPathInfo;
440 }
441 goto cgii_exit; 462 goto cgii_exit;
442 } else {
443 struct cifsInodeInfo *cifsInfo;
444 __u32 attr = le32_to_cpu(pfindData->Attributes);
445
446 /* get new inode */
447 if (*pinode == NULL) {
448 *pinode = new_inode(sb);
449 if (*pinode == NULL) {
450 rc = -ENOMEM;
451 goto cgii_exit;
452 }
453 /* Is an i_ino of zero legal? Can we use that to check
454 if the server supports returning inode numbers? Are
455 there other sanity checks we can use to ensure that
456 the server is really filling in that field? */
457
458 /* We can not use the IndexNumber field by default from
459 Windows or Samba (in ALL_INFO buf) but we can request
460 it explicitly. It may not be unique presumably if
461 the server has multiple devices mounted under one
462 share */
463 463
464 /* There may be higher info levels that work but are 464 attr = le32_to_cpu(pfindData->Attributes);
465 there Windows server or network appliances for which
466 IndexNumber field is not guaranteed unique? */
467 465
468 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) { 466 /* get new inode */
469 int rc1 = 0; 467 if (*pinode == NULL) {
470 __u64 inode_num; 468 *pinode = new_inode(sb);
471 469 if (*pinode == NULL) {
472 rc1 = CIFSGetSrvInodeNumber(xid, pTcon, 470 rc = -ENOMEM;
473 search_path, &inode_num, 471 goto cgii_exit;
472 }
473 /* Is an i_ino of zero legal? Can we use that to check
474 if the server supports returning inode numbers? Are
475 there other sanity checks we can use to ensure that
476 the server is really filling in that field? */
477
478 /* We can not use the IndexNumber field by default from
479 Windows or Samba (in ALL_INFO buf) but we can request
480 it explicitly. It may not be unique presumably if
481 the server has multiple devices mounted under one share */
482
483 /* There may be higher info levels that work but are
484 there Windows server or network appliances for which
485 IndexNumber field is not guaranteed unique? */
486
487 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
488 int rc1 = 0;
489 __u64 inode_num;
490
491 rc1 = CIFSGetSrvInodeNumber(xid, pTcon,
492 full_path, &inode_num,
474 cifs_sb->local_nls, 493 cifs_sb->local_nls,
475 cifs_sb->mnt_cifs_flags & 494 cifs_sb->mnt_cifs_flags &
476 CIFS_MOUNT_MAP_SPECIAL_CHR); 495 CIFS_MOUNT_MAP_SPECIAL_CHR);
477 if (rc1) { 496 if (rc1) {
478 cFYI(1, ("GetSrvInodeNum rc %d", rc1)); 497 cFYI(1, ("GetSrvInodeNum rc %d", rc1));
479 /* BB EOPNOSUPP disable SERVER_INUM? */ 498 /* BB EOPNOSUPP disable SERVER_INUM? */
480 } else /* do we need cast or hash to ino? */ 499 } else /* do we need cast or hash to ino? */
481 (*pinode)->i_ino = inode_num; 500 (*pinode)->i_ino = inode_num;
482 } /* else ino incremented to unique num in new_inode*/ 501 } /* else ino incremented to unique num in new_inode*/
483 if (sb->s_flags & MS_NOATIME) 502 if (sb->s_flags & MS_NOATIME)
484 (*pinode)->i_flags |= S_NOATIME | S_NOCMTIME; 503 (*pinode)->i_flags |= S_NOATIME | S_NOCMTIME;
485 insert_inode_hash(*pinode); 504 insert_inode_hash(*pinode);
486 } 505 }
487 inode = *pinode; 506 inode = *pinode;
488 cifsInfo = CIFS_I(inode); 507 cifsInfo = CIFS_I(inode);
489 cifsInfo->cifsAttrs = attr; 508 cifsInfo->cifsAttrs = attr;
490 cFYI(1, ("Old time %ld", cifsInfo->time)); 509 cFYI(1, ("Old time %ld", cifsInfo->time));
491 cifsInfo->time = jiffies; 510 cifsInfo->time = jiffies;
492 cFYI(1, ("New time %ld", cifsInfo->time)); 511 cFYI(1, ("New time %ld", cifsInfo->time));
493 512
494 /* blksize needs to be multiple of two. So safer to default to 513 /* blksize needs to be multiple of two. So safer to default to
495 blksize and blkbits set in superblock so 2**blkbits and blksize 514 blksize and blkbits set in superblock so 2**blkbits and blksize
496 will match rather than setting to: 515 will match rather than setting to:
497 (pTcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) & 0xFFFFFE00;*/ 516 (pTcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) & 0xFFFFFE00;*/
498 517
499 /* Linux can not store file creation time so ignore it */ 518 /* Linux can not store file creation time so ignore it */
500 if (pfindData->LastAccessTime) 519 if (pfindData->LastAccessTime)
501 inode->i_atime = cifs_NTtimeToUnix 520 inode->i_atime = cifs_NTtimeToUnix
502 (le64_to_cpu(pfindData->LastAccessTime)); 521 (le64_to_cpu(pfindData->LastAccessTime));
503 else /* do not need to use current_fs_time - time not stored */ 522 else /* do not need to use current_fs_time - time not stored */
504 inode->i_atime = CURRENT_TIME; 523 inode->i_atime = CURRENT_TIME;
505 inode->i_mtime = 524 inode->i_mtime =
506 cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastWriteTime)); 525 cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastWriteTime));
507 inode->i_ctime = 526 inode->i_ctime =
508 cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime)); 527 cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime));
509 cFYI(0, ("Attributes came in as 0x%x", attr)); 528 cFYI(DBG2, ("Attributes came in as 0x%x", attr));
510 if (adjustTZ && (pTcon->ses) && (pTcon->ses->server)) { 529 if (adjustTZ && (pTcon->ses) && (pTcon->ses->server)) {
511 inode->i_ctime.tv_sec += pTcon->ses->server->timeAdj; 530 inode->i_ctime.tv_sec += pTcon->ses->server->timeAdj;
512 inode->i_mtime.tv_sec += pTcon->ses->server->timeAdj; 531 inode->i_mtime.tv_sec += pTcon->ses->server->timeAdj;
513 } 532 }
514 533
515 /* set default mode. will override for dirs below */ 534 /* get default inode mode */
516 if (atomic_read(&cifsInfo->inUse) == 0) 535 if (attr & ATTR_DIRECTORY)
517 /* new inode, can safely set these fields */ 536 default_mode = cifs_sb->mnt_dir_mode;
518 inode->i_mode = cifs_sb->mnt_file_mode; 537 else
519 else /* since we set the inode type below we need to mask off 538 default_mode = cifs_sb->mnt_file_mode;
520 to avoid strange results if type changes and both 539
521 get orred in */ 540 /* set permission bits */
541 if (atomic_read(&cifsInfo->inUse) == 0 ||
542 (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM) == 0)
543 inode->i_mode = default_mode;
544 else {
545 /* just reenable write bits if !ATTR_READONLY */
546 if ((inode->i_mode & S_IWUGO) == 0 &&
547 (attr & ATTR_READONLY) == 0)
548 inode->i_mode |= (S_IWUGO & default_mode);
522 inode->i_mode &= ~S_IFMT; 549 inode->i_mode &= ~S_IFMT;
523/* if (attr & ATTR_REPARSE) */ 550 }
524 /* We no longer handle these as symlinks because we could not 551 /* clear write bits if ATTR_READONLY is set */
525 follow them due to the absolute path with drive letter */ 552 if (attr & ATTR_READONLY)
526 if (attr & ATTR_DIRECTORY) { 553 inode->i_mode &= ~S_IWUGO;
527 /* override default perms since we do not do byte range locking 554
528 on dirs */ 555 /* set inode type */
529 inode->i_mode = cifs_sb->mnt_dir_mode; 556 if ((attr & ATTR_SYSTEM) &&
530 inode->i_mode |= S_IFDIR; 557 (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL)) {
531 } else if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) && 558 /* no need to fix endianness on 0 */
532 (cifsInfo->cifsAttrs & ATTR_SYSTEM) && 559 if (pfindData->EndOfFile == 0)
533 /* No need to le64 convert size of zero */
534 (pfindData->EndOfFile == 0)) {
535 inode->i_mode = cifs_sb->mnt_file_mode;
536 inode->i_mode |= S_IFIFO; 560 inode->i_mode |= S_IFIFO;
537/* BB Finish for SFU style symlinks and devices */ 561 else if (decode_sfu_inode(inode,
538 } else if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) && 562 le64_to_cpu(pfindData->EndOfFile),
539 (cifsInfo->cifsAttrs & ATTR_SYSTEM)) { 563 full_path, cifs_sb, xid))
540 if (decode_sfu_inode(inode, 564 cFYI(1, ("unknown SFU file type\n"));
541 le64_to_cpu(pfindData->EndOfFile), 565 } else {
542 search_path, 566 if (attr & ATTR_DIRECTORY)
543 cifs_sb, xid)) 567 inode->i_mode |= S_IFDIR;
544 cFYI(1, ("Unrecognized sfu inode type")); 568 else
545
546 cFYI(1, ("sfu mode 0%o", inode->i_mode));
547 } else {
548 inode->i_mode |= S_IFREG; 569 inode->i_mode |= S_IFREG;
549 /* treat the dos attribute of read-only as read-only 570 }
550 mode e.g. 555 */
551 if (cifsInfo->cifsAttrs & ATTR_READONLY)
552 inode->i_mode &= ~(S_IWUGO);
553 else if ((inode->i_mode & S_IWUGO) == 0)
554 /* the ATTR_READONLY flag may have been */
555 /* changed on server -- set any w bits */
556 /* allowed by mnt_file_mode */
557 inode->i_mode |= (S_IWUGO &
558 cifs_sb->mnt_file_mode);
559 /* BB add code here -
560 validate if device or weird share or device type? */
561 }
562 571
563 spin_lock(&inode->i_lock); 572 spin_lock(&inode->i_lock);
564 if (is_size_safe_to_change(cifsInfo, 573 if (is_size_safe_to_change(cifsInfo,
565 le64_to_cpu(pfindData->EndOfFile))) { 574 le64_to_cpu(pfindData->EndOfFile))) {
566 /* can not safely shrink the file size here if the 575 /* can not safely shrink the file size here if the
567 client is writing to it due to potential races */ 576 client is writing to it due to potential races */
568 i_size_write(inode, le64_to_cpu(pfindData->EndOfFile)); 577 i_size_write(inode, le64_to_cpu(pfindData->EndOfFile));
569 578
570 /* 512 bytes (2**9) is the fake blocksize that must be 579 /* 512 bytes (2**9) is the fake blocksize that must be
571 used for this calculation */ 580 used for this calculation */
572 inode->i_blocks = (512 - 1 + le64_to_cpu( 581 inode->i_blocks = (512 - 1 + le64_to_cpu(
573 pfindData->AllocationSize)) >> 9; 582 pfindData->AllocationSize)) >> 9;
574 } 583 }
575 spin_unlock(&inode->i_lock); 584 spin_unlock(&inode->i_lock);
576 585
577 inode->i_nlink = le32_to_cpu(pfindData->NumberOfLinks); 586 inode->i_nlink = le32_to_cpu(pfindData->NumberOfLinks);
578 587
579 /* BB fill in uid and gid here? with help from winbind? 588 /* BB fill in uid and gid here? with help from winbind?
580 or retrieve from NTFS stream extended attribute */ 589 or retrieve from NTFS stream extended attribute */
581#ifdef CONFIG_CIFS_EXPERIMENTAL 590#ifdef CONFIG_CIFS_EXPERIMENTAL
582 /* fill in 0777 bits from ACL */ 591 /* fill in 0777 bits from ACL */
583 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) { 592 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) {
584 cFYI(1, ("Getting mode bits from ACL")); 593 cFYI(1, ("Getting mode bits from ACL"));
585 acl_to_uid_mode(inode, search_path, pfid); 594 acl_to_uid_mode(inode, full_path, pfid);
586 } 595 }
587#endif 596#endif
588 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) { 597 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) {
589 /* fill in remaining high mode bits e.g. SUID, VTX */ 598 /* fill in remaining high mode bits e.g. SUID, VTX */
590 get_sfu_mode(inode, search_path, cifs_sb, xid); 599 get_sfu_mode(inode, full_path, cifs_sb, xid);
591 } else if (atomic_read(&cifsInfo->inUse) == 0) { 600 } else if (atomic_read(&cifsInfo->inUse) == 0) {
592 inode->i_uid = cifs_sb->mnt_uid; 601 inode->i_uid = cifs_sb->mnt_uid;
593 inode->i_gid = cifs_sb->mnt_gid; 602 inode->i_gid = cifs_sb->mnt_gid;
594 /* set so we do not keep refreshing these fields with 603 /* set so we do not keep refreshing these fields with
595 bad data after user has changed them in memory */ 604 bad data after user has changed them in memory */
596 atomic_set(&cifsInfo->inUse, 1); 605 atomic_set(&cifsInfo->inUse, 1);
597 }
598
599 cifs_set_ops(inode, is_dfs_referral);
600 } 606 }
607
608 cifs_set_ops(inode, is_dfs_referral);
609
610
611
612
601cgii_exit: 613cgii_exit:
602 if (full_path != search_path)
603 kfree(full_path);
604 kfree(buf); 614 kfree(buf);
605 return rc; 615 return rc;
606} 616}
@@ -974,8 +984,8 @@ mkdir_get_info:
974 * failed to get it from the server or was set bogus */ 984 * failed to get it from the server or was set bogus */
975 if ((direntry->d_inode) && (direntry->d_inode->i_nlink < 2)) 985 if ((direntry->d_inode) && (direntry->d_inode->i_nlink < 2))
976 direntry->d_inode->i_nlink = 2; 986 direntry->d_inode->i_nlink = 2;
987 mode &= ~current->fs->umask;
977 if (pTcon->unix_ext) { 988 if (pTcon->unix_ext) {
978 mode &= ~current->fs->umask;
979 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { 989 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
980 CIFSSMBUnixSetPerms(xid, pTcon, full_path, 990 CIFSSMBUnixSetPerms(xid, pTcon, full_path,
981 mode, 991 mode,
@@ -994,12 +1004,22 @@ mkdir_get_info:
994 CIFS_MOUNT_MAP_SPECIAL_CHR); 1004 CIFS_MOUNT_MAP_SPECIAL_CHR);
995 } 1005 }
996 } else { 1006 } else {
997 /* BB to be implemented via Windows secrty descriptors 1007 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) &&
998 eg CIFSSMBWinSetPerms(xid, pTcon, full_path, mode, 1008 (mode & S_IWUGO) == 0) {
999 -1, -1, local_nls); */ 1009 FILE_BASIC_INFO pInfo;
1010 memset(&pInfo, 0, sizeof(pInfo));
1011 pInfo.Attributes = cpu_to_le32(ATTR_READONLY);
1012 CIFSSMBSetTimes(xid, pTcon, full_path,
1013 &pInfo, cifs_sb->local_nls,
1014 cifs_sb->mnt_cifs_flags &
1015 CIFS_MOUNT_MAP_SPECIAL_CHR);
1016 }
1000 if (direntry->d_inode) { 1017 if (direntry->d_inode) {
1001 direntry->d_inode->i_mode = mode; 1018 if (cifs_sb->mnt_cifs_flags &
1002 direntry->d_inode->i_mode |= S_IFDIR; 1019 CIFS_MOUNT_DYNPERM)
1020 direntry->d_inode->i_mode =
1021 (mode | S_IFDIR);
1022
1003 if (cifs_sb->mnt_cifs_flags & 1023 if (cifs_sb->mnt_cifs_flags &
1004 CIFS_MOUNT_SET_UID) { 1024 CIFS_MOUNT_SET_UID) {
1005 direntry->d_inode->i_uid = 1025 direntry->d_inode->i_uid =
@@ -1408,18 +1428,19 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1408 __u64 uid = 0xFFFFFFFFFFFFFFFFULL; 1428 __u64 uid = 0xFFFFFFFFFFFFFFFFULL;
1409 __u64 gid = 0xFFFFFFFFFFFFFFFFULL; 1429 __u64 gid = 0xFFFFFFFFFFFFFFFFULL;
1410 struct cifsInodeInfo *cifsInode; 1430 struct cifsInodeInfo *cifsInode;
1431 struct inode *inode = direntry->d_inode;
1411 1432
1412 xid = GetXid(); 1433 xid = GetXid();
1413 1434
1414 cFYI(1, ("setattr on file %s attrs->iavalid 0x%x", 1435 cFYI(1, ("setattr on file %s attrs->iavalid 0x%x",
1415 direntry->d_name.name, attrs->ia_valid)); 1436 direntry->d_name.name, attrs->ia_valid));
1416 1437
1417 cifs_sb = CIFS_SB(direntry->d_inode->i_sb); 1438 cifs_sb = CIFS_SB(inode->i_sb);
1418 pTcon = cifs_sb->tcon; 1439 pTcon = cifs_sb->tcon;
1419 1440
1420 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) == 0) { 1441 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) == 0) {
1421 /* check if we have permission to change attrs */ 1442 /* check if we have permission to change attrs */
1422 rc = inode_change_ok(direntry->d_inode, attrs); 1443 rc = inode_change_ok(inode, attrs);
1423 if (rc < 0) { 1444 if (rc < 0) {
1424 FreeXid(xid); 1445 FreeXid(xid);
1425 return rc; 1446 return rc;
@@ -1432,7 +1453,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1432 FreeXid(xid); 1453 FreeXid(xid);
1433 return -ENOMEM; 1454 return -ENOMEM;
1434 } 1455 }
1435 cifsInode = CIFS_I(direntry->d_inode); 1456 cifsInode = CIFS_I(inode);
1436 1457
1437 if ((attrs->ia_valid & ATTR_MTIME) || (attrs->ia_valid & ATTR_SIZE)) { 1458 if ((attrs->ia_valid & ATTR_MTIME) || (attrs->ia_valid & ATTR_SIZE)) {
1438 /* 1459 /*
@@ -1443,9 +1464,9 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1443 will be truncated anyway? Also, should we error out here if 1464 will be truncated anyway? Also, should we error out here if
1444 the flush returns error? 1465 the flush returns error?
1445 */ 1466 */
1446 rc = filemap_write_and_wait(direntry->d_inode->i_mapping); 1467 rc = filemap_write_and_wait(inode->i_mapping);
1447 if (rc != 0) { 1468 if (rc != 0) {
1448 CIFS_I(direntry->d_inode)->write_behind_rc = rc; 1469 cifsInode->write_behind_rc = rc;
1449 rc = 0; 1470 rc = 0;
1450 } 1471 }
1451 } 1472 }
@@ -1494,8 +1515,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1494 int oplock = 0; 1515 int oplock = 0;
1495 1516
1496 rc = SMBLegacyOpen(xid, pTcon, full_path, 1517 rc = SMBLegacyOpen(xid, pTcon, full_path,
1497 FILE_OPEN, 1518 FILE_OPEN, GENERIC_WRITE,
1498 SYNCHRONIZE | FILE_WRITE_ATTRIBUTES,
1499 CREATE_NOT_DIR, &netfid, &oplock, 1519 CREATE_NOT_DIR, &netfid, &oplock,
1500 NULL, cifs_sb->local_nls, 1520 NULL, cifs_sb->local_nls,
1501 cifs_sb->mnt_cifs_flags & 1521 cifs_sb->mnt_cifs_flags &
@@ -1521,19 +1541,31 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1521 */ 1541 */
1522 1542
1523 if (rc == 0) { 1543 if (rc == 0) {
1524 rc = cifs_vmtruncate(direntry->d_inode, attrs->ia_size); 1544 rc = cifs_vmtruncate(inode, attrs->ia_size);
1525 cifs_truncate_page(direntry->d_inode->i_mapping, 1545 cifs_truncate_page(inode->i_mapping, inode->i_size);
1526 direntry->d_inode->i_size);
1527 } else 1546 } else
1528 goto cifs_setattr_exit; 1547 goto cifs_setattr_exit;
1529 } 1548 }
1530 if (attrs->ia_valid & ATTR_UID) { 1549
1531 cFYI(1, ("UID changed to %d", attrs->ia_uid)); 1550 /*
1532 uid = attrs->ia_uid; 1551 * Without unix extensions we can't send ownership changes to the
1533 } 1552 * server, so silently ignore them. This is consistent with how
1534 if (attrs->ia_valid & ATTR_GID) { 1553 * local DOS/Windows filesystems behave (VFAT, NTFS, etc). With
1535 cFYI(1, ("GID changed to %d", attrs->ia_gid)); 1554 * CIFSACL support + proper Windows to Unix idmapping, we may be
1536 gid = attrs->ia_gid; 1555 * able to support this in the future.
1556 */
1557 if (!pTcon->unix_ext &&
1558 !(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID)) {
1559 attrs->ia_valid &= ~(ATTR_UID | ATTR_GID);
1560 } else {
1561 if (attrs->ia_valid & ATTR_UID) {
1562 cFYI(1, ("UID changed to %d", attrs->ia_uid));
1563 uid = attrs->ia_uid;
1564 }
1565 if (attrs->ia_valid & ATTR_GID) {
1566 cFYI(1, ("GID changed to %d", attrs->ia_gid));
1567 gid = attrs->ia_gid;
1568 }
1537 } 1569 }
1538 1570
1539 time_buf.Attributes = 0; 1571 time_buf.Attributes = 0;
@@ -1543,7 +1575,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1543 attrs->ia_valid &= ~ATTR_MODE; 1575 attrs->ia_valid &= ~ATTR_MODE;
1544 1576
1545 if (attrs->ia_valid & ATTR_MODE) { 1577 if (attrs->ia_valid & ATTR_MODE) {
1546 cFYI(1, ("Mode changed to 0x%x", attrs->ia_mode)); 1578 cFYI(1, ("Mode changed to 0%o", attrs->ia_mode));
1547 mode = attrs->ia_mode; 1579 mode = attrs->ia_mode;
1548 } 1580 }
1549 1581
@@ -1557,19 +1589,19 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1557 rc = 0; 1589 rc = 0;
1558#ifdef CONFIG_CIFS_EXPERIMENTAL 1590#ifdef CONFIG_CIFS_EXPERIMENTAL
1559 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) 1591 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL)
1560 rc = mode_to_acl(direntry->d_inode, full_path, mode); 1592 rc = mode_to_acl(inode, full_path, mode);
1561 else if ((mode & S_IWUGO) == 0) { 1593 else
1562#else
1563 if ((mode & S_IWUGO) == 0) {
1564#endif 1594#endif
1565 /* not writeable */ 1595 if (((mode & S_IWUGO) == 0) &&
1566 if ((cifsInode->cifsAttrs & ATTR_READONLY) == 0) { 1596 (cifsInode->cifsAttrs & ATTR_READONLY) == 0) {
1567 set_dosattr = true; 1597 set_dosattr = true;
1568 time_buf.Attributes = 1598 time_buf.Attributes = cpu_to_le32(cifsInode->cifsAttrs |
1569 cpu_to_le32(cifsInode->cifsAttrs | 1599 ATTR_READONLY);
1570 ATTR_READONLY); 1600 /* fix up mode if we're not using dynperm */
1571 } 1601 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM) == 0)
1572 } else if (cifsInode->cifsAttrs & ATTR_READONLY) { 1602 attrs->ia_mode = inode->i_mode & ~S_IWUGO;
1603 } else if ((mode & S_IWUGO) &&
1604 (cifsInode->cifsAttrs & ATTR_READONLY)) {
1573 /* If file is readonly on server, we would 1605 /* If file is readonly on server, we would
1574 not be able to write to it - so if any write 1606 not be able to write to it - so if any write
1575 bit is enabled for user or group or other we 1607 bit is enabled for user or group or other we
@@ -1580,6 +1612,20 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1580 /* Windows ignores set to zero */ 1612 /* Windows ignores set to zero */
1581 if (time_buf.Attributes == 0) 1613 if (time_buf.Attributes == 0)
1582 time_buf.Attributes |= cpu_to_le32(ATTR_NORMAL); 1614 time_buf.Attributes |= cpu_to_le32(ATTR_NORMAL);
1615
1616 /* reset local inode permissions to normal */
1617 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM)) {
1618 attrs->ia_mode &= ~(S_IALLUGO);
1619 if (S_ISDIR(inode->i_mode))
1620 attrs->ia_mode |=
1621 cifs_sb->mnt_dir_mode;
1622 else
1623 attrs->ia_mode |=
1624 cifs_sb->mnt_file_mode;
1625 }
1626 } else if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM)) {
1627 /* ignore mode change - ATTR_READONLY hasn't changed */
1628 attrs->ia_valid &= ~ATTR_MODE;
1583 } 1629 }
1584 } 1630 }
1585 1631
@@ -1665,7 +1711,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1665 /* do not need local check to inode_check_ok since the server does 1711 /* do not need local check to inode_check_ok since the server does
1666 that */ 1712 that */
1667 if (!rc) 1713 if (!rc)
1668 rc = inode_setattr(direntry->d_inode, attrs); 1714 rc = inode_setattr(inode, attrs);
1669cifs_setattr_exit: 1715cifs_setattr_exit:
1670 kfree(full_path); 1716 kfree(full_path);
1671 FreeXid(xid); 1717 FreeXid(xid);
diff --git a/fs/cifs/ioctl.c b/fs/cifs/ioctl.c
index 5c792df13d62..0088a5b52564 100644
--- a/fs/cifs/ioctl.c
+++ b/fs/cifs/ioctl.c
@@ -30,9 +30,9 @@
30 30
31#define CIFS_IOC_CHECKUMOUNT _IO(0xCF, 2) 31#define CIFS_IOC_CHECKUMOUNT _IO(0xCF, 2)
32 32
33int cifs_ioctl(struct inode *inode, struct file *filep, 33long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
34 unsigned int command, unsigned long arg)
35{ 34{
35 struct inode *inode = filep->f_dentry->d_inode;
36 int rc = -ENOTTY; /* strange error - but the precedent */ 36 int rc = -ENOTTY; /* strange error - but the precedent */
37 int xid; 37 int xid;
38 struct cifs_sb_info *cifs_sb; 38 struct cifs_sb_info *cifs_sb;
diff --git a/fs/cifs/link.c b/fs/cifs/link.c
index 1c2c3ce5020b..63f644000ce5 100644
--- a/fs/cifs/link.c
+++ b/fs/cifs/link.c
@@ -234,7 +234,6 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen)
234 struct cifs_sb_info *cifs_sb; 234 struct cifs_sb_info *cifs_sb;
235 struct cifsTconInfo *pTcon; 235 struct cifsTconInfo *pTcon;
236 char *full_path = NULL; 236 char *full_path = NULL;
237 char *tmp_path = NULL;
238 char *tmpbuffer; 237 char *tmpbuffer;
239 int len; 238 int len;
240 __u16 fid; 239 __u16 fid;
@@ -295,45 +294,9 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen)
295 cFYI(1, ("Error closing junction point " 294 cFYI(1, ("Error closing junction point "
296 "(open for ioctl)")); 295 "(open for ioctl)"));
297 } 296 }
298 /* BB unwind this long, nested function, or remove BB */ 297 /* If it is a DFS junction earlier we would have gotten
299 if (rc == -EIO) { 298 PATH_NOT_COVERED returned from server so we do
300 /* Query if DFS Junction */ 299 not need to request the DFS info here */
301 unsigned int num_referrals = 0;
302 struct dfs_info3_param *refs = NULL;
303 tmp_path =
304 kmalloc(MAX_TREE_SIZE + MAX_PATHCONF + 1,
305 GFP_KERNEL);
306 if (tmp_path) {
307 strncpy(tmp_path, pTcon->treeName,
308 MAX_TREE_SIZE);
309 strncat(tmp_path, full_path,
310 MAX_PATHCONF);
311 rc = get_dfs_path(xid, pTcon->ses,
312 tmp_path,
313 cifs_sb->local_nls,
314 &num_referrals, &refs,
315 cifs_sb->mnt_cifs_flags &
316 CIFS_MOUNT_MAP_SPECIAL_CHR);
317 cFYI(1, ("Get DFS for %s rc = %d ",
318 tmp_path, rc));
319 if ((num_referrals == 0) && (rc == 0))
320 rc = -EACCES;
321 else {
322 cFYI(1, ("num referral: %d",
323 num_referrals));
324 if (refs && refs->path_name) {
325 strncpy(tmpbuffer,
326 refs->path_name,
327 len-1);
328 }
329 }
330 kfree(refs);
331 kfree(tmp_path);
332}
333 /* BB add code like else decode referrals
334 then memcpy to tmpbuffer and free referrals
335 string array BB */
336 }
337 } 300 }
338 } 301 }
339 /* BB Anything else to do to handle recursive links? */ 302 /* BB Anything else to do to handle recursive links? */
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index 1d69b8014e0b..4b17f8fe3157 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -519,8 +519,7 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
519 pnotify = (struct file_notify_information *) 519 pnotify = (struct file_notify_information *)
520 ((char *)&pSMBr->hdr.Protocol + data_offset); 520 ((char *)&pSMBr->hdr.Protocol + data_offset);
521 cFYI(1, ("dnotify on %s Action: 0x%x", 521 cFYI(1, ("dnotify on %s Action: 0x%x",
522 pnotify->FileName, 522 pnotify->FileName, pnotify->Action));
523 pnotify->Action)); /* BB removeme BB */
524 /* cifs_dump_mem("Rcvd notify Data: ",buf, 523 /* cifs_dump_mem("Rcvd notify Data: ",buf,
525 sizeof(struct smb_hdr)+60); */ 524 sizeof(struct smb_hdr)+60); */
526 return true; 525 return true;
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
index 00f4cff400b3..8703d68f5b20 100644
--- a/fs/cifs/netmisc.c
+++ b/fs/cifs/netmisc.c
@@ -141,11 +141,11 @@ cifs_inet_pton(const int address_family, const char *cp, void *dst)
141 int ret = 0; 141 int ret = 0;
142 142
143 /* calculate length by finding first slash or NULL */ 143 /* calculate length by finding first slash or NULL */
144 if (address_family == AF_INET) { 144 if (address_family == AF_INET)
145 ret = in4_pton(cp, -1 /* len */, dst, '\\', NULL); 145 ret = in4_pton(cp, -1 /* len */, dst, '\\', NULL);
146 } else if (address_family == AF_INET6) { 146 else if (address_family == AF_INET6)
147 ret = in6_pton(cp, -1 /* len */, dst , '\\', NULL); 147 ret = in6_pton(cp, -1 /* len */, dst , '\\', NULL);
148 } 148
149 cFYI(DBG2, ("address conversion returned %d for %s", ret, cp)); 149 cFYI(DBG2, ("address conversion returned %d for %s", ret, cp));
150 if (ret > 0) 150 if (ret > 0)
151 ret = 1; 151 ret = 1;
diff --git a/fs/cifs/ntlmssp.h b/fs/cifs/ntlmssp.h
index 7170a9b70f1e..c377d8065d99 100644
--- a/fs/cifs/ntlmssp.h
+++ b/fs/cifs/ntlmssp.h
@@ -64,7 +64,7 @@ typedef struct _SECURITY_BUFFER {
64} __attribute__((packed)) SECURITY_BUFFER; 64} __attribute__((packed)) SECURITY_BUFFER;
65 65
66typedef struct _NEGOTIATE_MESSAGE { 66typedef struct _NEGOTIATE_MESSAGE {
67 __u8 Signature[sizeof (NTLMSSP_SIGNATURE)]; 67 __u8 Signature[sizeof(NTLMSSP_SIGNATURE)];
68 __le32 MessageType; /* 1 */ 68 __le32 MessageType; /* 1 */
69 __le32 NegotiateFlags; 69 __le32 NegotiateFlags;
70 SECURITY_BUFFER DomainName; /* RFC 1001 style and ASCII */ 70 SECURITY_BUFFER DomainName; /* RFC 1001 style and ASCII */
@@ -74,7 +74,7 @@ typedef struct _NEGOTIATE_MESSAGE {
74} __attribute__((packed)) NEGOTIATE_MESSAGE, *PNEGOTIATE_MESSAGE; 74} __attribute__((packed)) NEGOTIATE_MESSAGE, *PNEGOTIATE_MESSAGE;
75 75
76typedef struct _CHALLENGE_MESSAGE { 76typedef struct _CHALLENGE_MESSAGE {
77 __u8 Signature[sizeof (NTLMSSP_SIGNATURE)]; 77 __u8 Signature[sizeof(NTLMSSP_SIGNATURE)];
78 __le32 MessageType; /* 2 */ 78 __le32 MessageType; /* 2 */
79 SECURITY_BUFFER TargetName; 79 SECURITY_BUFFER TargetName;
80 __le32 NegotiateFlags; 80 __le32 NegotiateFlags;
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 34ec32100c72..83f306954883 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -132,6 +132,7 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
132 __u32 attr; 132 __u32 attr;
133 __u64 allocation_size; 133 __u64 allocation_size;
134 __u64 end_of_file; 134 __u64 end_of_file;
135 umode_t default_mode;
135 136
136 /* save mtime and size */ 137 /* save mtime and size */
137 local_mtime = tmp_inode->i_mtime; 138 local_mtime = tmp_inode->i_mtime;
@@ -187,48 +188,54 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
187 if (atomic_read(&cifsInfo->inUse) == 0) { 188 if (atomic_read(&cifsInfo->inUse) == 0) {
188 tmp_inode->i_uid = cifs_sb->mnt_uid; 189 tmp_inode->i_uid = cifs_sb->mnt_uid;
189 tmp_inode->i_gid = cifs_sb->mnt_gid; 190 tmp_inode->i_gid = cifs_sb->mnt_gid;
190 /* set default mode. will override for dirs below */ 191 }
191 tmp_inode->i_mode = cifs_sb->mnt_file_mode; 192
192 } else { 193 if (attr & ATTR_DIRECTORY)
193 /* mask off the type bits since it gets set 194 default_mode = cifs_sb->mnt_dir_mode;
194 below and we do not want to get two type 195 else
195 bits set */ 196 default_mode = cifs_sb->mnt_file_mode;
197
198 /* set initial permissions */
199 if ((atomic_read(&cifsInfo->inUse) == 0) ||
200 (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM) == 0)
201 tmp_inode->i_mode = default_mode;
202 else {
203 /* just reenable write bits if !ATTR_READONLY */
204 if ((tmp_inode->i_mode & S_IWUGO) == 0 &&
205 (attr & ATTR_READONLY) == 0)
206 tmp_inode->i_mode |= (S_IWUGO & default_mode);
207
196 tmp_inode->i_mode &= ~S_IFMT; 208 tmp_inode->i_mode &= ~S_IFMT;
197 } 209 }
198 210
199 if (attr & ATTR_DIRECTORY) { 211 /* clear write bits if ATTR_READONLY is set */
200 *pobject_type = DT_DIR; 212 if (attr & ATTR_READONLY)
201 /* override default perms since we do not lock dirs */ 213 tmp_inode->i_mode &= ~S_IWUGO;
202 if (atomic_read(&cifsInfo->inUse) == 0) 214
203 tmp_inode->i_mode = cifs_sb->mnt_dir_mode; 215 /* set inode type */
204 tmp_inode->i_mode |= S_IFDIR; 216 if ((attr & ATTR_SYSTEM) &&
205 } else if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) && 217 (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL)) {
206 (attr & ATTR_SYSTEM)) {
207 if (end_of_file == 0) { 218 if (end_of_file == 0) {
208 *pobject_type = DT_FIFO;
209 tmp_inode->i_mode |= S_IFIFO; 219 tmp_inode->i_mode |= S_IFIFO;
220 *pobject_type = DT_FIFO;
210 } else { 221 } else {
211 /* rather than get the type here, we mark the 222 /*
212 inode as needing revalidate and get the real type 223 * trying to get the type can be slow, so just call
213 (blk vs chr vs. symlink) later ie in lookup */ 224 * this a regular file for now, and mark for reval
214 *pobject_type = DT_REG; 225 */
215 tmp_inode->i_mode |= S_IFREG; 226 tmp_inode->i_mode |= S_IFREG;
227 *pobject_type = DT_REG;
216 cifsInfo->time = 0; 228 cifsInfo->time = 0;
217 } 229 }
218/* we no longer mark these because we could not follow them */
219/* } else if (attr & ATTR_REPARSE) {
220 *pobject_type = DT_LNK;
221 tmp_inode->i_mode |= S_IFLNK; */
222 } else { 230 } else {
223 *pobject_type = DT_REG; 231 if (attr & ATTR_DIRECTORY) {
224 tmp_inode->i_mode |= S_IFREG; 232 tmp_inode->i_mode |= S_IFDIR;
225 if (attr & ATTR_READONLY) 233 *pobject_type = DT_DIR;
226 tmp_inode->i_mode &= ~(S_IWUGO); 234 } else {
227 else if ((tmp_inode->i_mode & S_IWUGO) == 0) 235 tmp_inode->i_mode |= S_IFREG;
228 /* the ATTR_READONLY flag may have been changed on */ 236 *pobject_type = DT_REG;
229 /* server -- set any w bits allowed by mnt_file_mode */ 237 }
230 tmp_inode->i_mode |= (S_IWUGO & cifs_sb->mnt_file_mode); 238 }
231 } /* could add code here - to validate if device or weird share type? */
232 239
233 /* can not fill in nlink here as in qpathinfo version and Unx search */ 240 /* can not fill in nlink here as in qpathinfo version and Unx search */
234 if (atomic_read(&cifsInfo->inUse) == 0) 241 if (atomic_read(&cifsInfo->inUse) == 0)
@@ -670,10 +677,11 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
670 (index_to_find < first_entry_in_buffer)) { 677 (index_to_find < first_entry_in_buffer)) {
671 /* close and restart search */ 678 /* close and restart search */
672 cFYI(1, ("search backing up - close and restart search")); 679 cFYI(1, ("search backing up - close and restart search"));
673 cifsFile->invalidHandle = true; 680 if (!cifsFile->srch_inf.endOfSearch &&
674 CIFSFindClose(xid, pTcon, cifsFile->netfid); 681 !cifsFile->invalidHandle) {
675 kfree(cifsFile->search_resume_name); 682 cifsFile->invalidHandle = true;
676 cifsFile->search_resume_name = NULL; 683 CIFSFindClose(xid, pTcon, cifsFile->netfid);
684 }
677 if (cifsFile->srch_inf.ntwrk_buf_start) { 685 if (cifsFile->srch_inf.ntwrk_buf_start) {
678 cFYI(1, ("freeing SMB ff cache buf on search rewind")); 686 cFYI(1, ("freeing SMB ff cache buf on search rewind"));
679 if (cifsFile->srch_inf.smallBuf) 687 if (cifsFile->srch_inf.smallBuf)
@@ -1040,9 +1048,7 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
1040 } /* else { 1048 } /* else {
1041 cifsFile->invalidHandle = true; 1049 cifsFile->invalidHandle = true;
1042 CIFSFindClose(xid, pTcon, cifsFile->netfid); 1050 CIFSFindClose(xid, pTcon, cifsFile->netfid);
1043 } 1051 } */
1044 kfree(cifsFile->search_resume_name);
1045 cifsFile->search_resume_name = NULL; */
1046 1052
1047 rc = find_cifs_entry(xid, pTcon, file, 1053 rc = find_cifs_entry(xid, pTcon, file,
1048 &current_entry, &num_to_fill); 1054 &current_entry, &num_to_fill);
diff --git a/fs/compat.c b/fs/compat.c
index 332a869d2c53..ed43e17a5dc6 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -1405,7 +1405,7 @@ int compat_do_execve(char * filename,
1405 /* execve success */ 1405 /* execve success */
1406 security_bprm_free(bprm); 1406 security_bprm_free(bprm);
1407 acct_update_integrals(current); 1407 acct_update_integrals(current);
1408 kfree(bprm); 1408 free_bprm(bprm);
1409 return retval; 1409 return retval;
1410 } 1410 }
1411 1411
@@ -1424,7 +1424,7 @@ out_file:
1424 } 1424 }
1425 1425
1426out_kfree: 1426out_kfree:
1427 kfree(bprm); 1427 free_bprm(bprm);
1428 1428
1429out_ret: 1429out_ret:
1430 return retval; 1430 return retval;
diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
index 7c1e5e5cccd8..637018c891ef 100644
--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms.c
@@ -50,6 +50,7 @@
50#include <linux/pagemap.h> 50#include <linux/pagemap.h>
51#include <linux/idr.h> 51#include <linux/idr.h>
52#include <linux/file.h> 52#include <linux/file.h>
53#include <linux/mutex.h>
53#include <linux/sctp.h> 54#include <linux/sctp.h>
54#include <net/sctp/user.h> 55#include <net/sctp/user.h>
55 56
@@ -138,7 +139,7 @@ static struct workqueue_struct *recv_workqueue;
138static struct workqueue_struct *send_workqueue; 139static struct workqueue_struct *send_workqueue;
139 140
140static DEFINE_IDR(connections_idr); 141static DEFINE_IDR(connections_idr);
141static DECLARE_MUTEX(connections_lock); 142static DEFINE_MUTEX(connections_lock);
142static int max_nodeid; 143static int max_nodeid;
143static struct kmem_cache *con_cache; 144static struct kmem_cache *con_cache;
144 145
@@ -205,9 +206,9 @@ static struct connection *nodeid2con(int nodeid, gfp_t allocation)
205{ 206{
206 struct connection *con; 207 struct connection *con;
207 208
208 down(&connections_lock); 209 mutex_lock(&connections_lock);
209 con = __nodeid2con(nodeid, allocation); 210 con = __nodeid2con(nodeid, allocation);
210 up(&connections_lock); 211 mutex_unlock(&connections_lock);
211 212
212 return con; 213 return con;
213} 214}
@@ -218,15 +219,15 @@ static struct connection *assoc2con(int assoc_id)
218 int i; 219 int i;
219 struct connection *con; 220 struct connection *con;
220 221
221 down(&connections_lock); 222 mutex_lock(&connections_lock);
222 for (i=0; i<=max_nodeid; i++) { 223 for (i=0; i<=max_nodeid; i++) {
223 con = __nodeid2con(i, 0); 224 con = __nodeid2con(i, 0);
224 if (con && con->sctp_assoc == assoc_id) { 225 if (con && con->sctp_assoc == assoc_id) {
225 up(&connections_lock); 226 mutex_unlock(&connections_lock);
226 return con; 227 return con;
227 } 228 }
228 } 229 }
229 up(&connections_lock); 230 mutex_unlock(&connections_lock);
230 return NULL; 231 return NULL;
231} 232}
232 233
@@ -381,7 +382,7 @@ static void sctp_init_failed(void)
381 int i; 382 int i;
382 struct connection *con; 383 struct connection *con;
383 384
384 down(&connections_lock); 385 mutex_lock(&connections_lock);
385 for (i=1; i<=max_nodeid; i++) { 386 for (i=1; i<=max_nodeid; i++) {
386 con = __nodeid2con(i, 0); 387 con = __nodeid2con(i, 0);
387 if (!con) 388 if (!con)
@@ -393,7 +394,7 @@ static void sctp_init_failed(void)
393 } 394 }
394 } 395 }
395 } 396 }
396 up(&connections_lock); 397 mutex_unlock(&connections_lock);
397} 398}
398 399
399/* Something happened to an association */ 400/* Something happened to an association */
@@ -930,7 +931,7 @@ out_err:
930 * errors we try again until the max number of retries is reached. 931 * errors we try again until the max number of retries is reached.
931 */ 932 */
932 if (result != -EHOSTUNREACH && result != -ENETUNREACH && 933 if (result != -EHOSTUNREACH && result != -ENETUNREACH &&
933 result != -ENETDOWN && result != EINVAL 934 result != -ENETDOWN && result != -EINVAL
934 && result != -EPROTONOSUPPORT) { 935 && result != -EPROTONOSUPPORT) {
935 lowcomms_connect_sock(con); 936 lowcomms_connect_sock(con);
936 result = 0; 937 result = 0;
@@ -1417,7 +1418,7 @@ void dlm_lowcomms_stop(void)
1417 /* Set all the flags to prevent any 1418 /* Set all the flags to prevent any
1418 socket activity. 1419 socket activity.
1419 */ 1420 */
1420 down(&connections_lock); 1421 mutex_lock(&connections_lock);
1421 for (i = 0; i <= max_nodeid; i++) { 1422 for (i = 0; i <= max_nodeid; i++) {
1422 con = __nodeid2con(i, 0); 1423 con = __nodeid2con(i, 0);
1423 if (con) { 1424 if (con) {
@@ -1426,11 +1427,11 @@ void dlm_lowcomms_stop(void)
1426 con->sock->sk->sk_user_data = NULL; 1427 con->sock->sk->sk_user_data = NULL;
1427 } 1428 }
1428 } 1429 }
1429 up(&connections_lock); 1430 mutex_unlock(&connections_lock);
1430 1431
1431 work_stop(); 1432 work_stop();
1432 1433
1433 down(&connections_lock); 1434 mutex_lock(&connections_lock);
1434 clean_writequeues(); 1435 clean_writequeues();
1435 1436
1436 for (i = 0; i <= max_nodeid; i++) { 1437 for (i = 0; i <= max_nodeid; i++) {
@@ -1443,7 +1444,7 @@ void dlm_lowcomms_stop(void)
1443 } 1444 }
1444 } 1445 }
1445 max_nodeid = 0; 1446 max_nodeid = 0;
1446 up(&connections_lock); 1447 mutex_unlock(&connections_lock);
1447 kmem_cache_destroy(con_cache); 1448 kmem_cache_destroy(con_cache);
1448 idr_init(&connections_idr); 1449 idr_init(&connections_idr);
1449} 1450}
diff --git a/fs/dlm/netlink.c b/fs/dlm/netlink.c
index 714593621f4f..18bda83cc892 100644
--- a/fs/dlm/netlink.c
+++ b/fs/dlm/netlink.c
@@ -95,7 +95,7 @@ int __init dlm_netlink_init(void)
95 return rv; 95 return rv;
96} 96}
97 97
98void __exit dlm_netlink_exit(void) 98void dlm_netlink_exit(void)
99{ 99{
100 genl_unregister_ops(&family, &dlm_nl_ops); 100 genl_unregister_ops(&family, &dlm_nl_ops);
101 genl_unregister_family(&family); 101 genl_unregister_family(&family);
diff --git a/fs/dlm/plock.c b/fs/dlm/plock.c
index d6d6e370f89c..78878c5781ca 100644
--- a/fs/dlm/plock.c
+++ b/fs/dlm/plock.c
@@ -379,7 +379,7 @@ static ssize_t dev_write(struct file *file, const char __user *u, size_t count,
379 struct plock_xop *xop; 379 struct plock_xop *xop;
380 xop = (struct plock_xop *)op; 380 xop = (struct plock_xop *)op;
381 if (xop->callback) 381 if (xop->callback)
382 count = dlm_plock_callback(op); 382 dlm_plock_callback(op);
383 else 383 else
384 wake_up(&recv_wq); 384 wake_up(&recv_wq);
385 } else 385 } else
diff --git a/fs/dquot.c b/fs/dquot.c
index dfba1623cccb..5ac77da19959 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -1491,6 +1491,16 @@ int vfs_quota_off(struct super_block *sb, int type, int remount)
1491 1491
1492 /* We need to serialize quota_off() for device */ 1492 /* We need to serialize quota_off() for device */
1493 mutex_lock(&dqopt->dqonoff_mutex); 1493 mutex_lock(&dqopt->dqonoff_mutex);
1494
1495 /*
1496 * Skip everything if there's nothing to do. We have to do this because
1497 * sometimes we are called when fill_super() failed and calling
1498 * sync_fs() in such cases does no good.
1499 */
1500 if (!sb_any_quota_enabled(sb) && !sb_any_quota_suspended(sb)) {
1501 mutex_unlock(&dqopt->dqonoff_mutex);
1502 return 0;
1503 }
1494 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1504 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
1495 toputinode[cnt] = NULL; 1505 toputinode[cnt] = NULL;
1496 if (type != -1 && cnt != type) 1506 if (type != -1 && cnt != type)
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index cd62d75b2cc0..e2832bc7869a 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -1906,9 +1906,9 @@ int ecryptfs_get_tfm_and_mutex_for_cipher_name(struct crypto_blkcipher **tfm,
1906 goto out; 1906 goto out;
1907 } 1907 }
1908 } 1908 }
1909 mutex_unlock(&key_tfm_list_mutex);
1910 (*tfm) = key_tfm->key_tfm; 1909 (*tfm) = key_tfm->key_tfm;
1911 (*tfm_mutex) = &key_tfm->key_tfm_mutex; 1910 (*tfm_mutex) = &key_tfm->key_tfm_mutex;
1912out: 1911out:
1912 mutex_unlock(&key_tfm_list_mutex);
1913 return rc; 1913 return rc;
1914} 1914}
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h
index 951ee33a022d..c15c25745e05 100644
--- a/fs/ecryptfs/ecryptfs_kernel.h
+++ b/fs/ecryptfs/ecryptfs_kernel.h
@@ -660,8 +660,6 @@ int ecryptfs_get_tfm_and_mutex_for_cipher_name(struct crypto_blkcipher **tfm,
660int ecryptfs_keyring_auth_tok_for_sig(struct key **auth_tok_key, 660int ecryptfs_keyring_auth_tok_for_sig(struct key **auth_tok_key,
661 struct ecryptfs_auth_tok **auth_tok, 661 struct ecryptfs_auth_tok **auth_tok,
662 char *sig); 662 char *sig);
663int ecryptfs_write_zeros(struct file *file, pgoff_t index, int start,
664 int num_zeros);
665int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data, 663int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data,
666 loff_t offset, size_t size); 664 loff_t offset, size_t size);
667int ecryptfs_write_lower_page_segment(struct inode *ecryptfs_inode, 665int ecryptfs_write_lower_page_segment(struct inode *ecryptfs_inode,
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 0a1397335a8e..c92cc1c00aae 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -37,17 +37,11 @@ static struct dentry *lock_parent(struct dentry *dentry)
37{ 37{
38 struct dentry *dir; 38 struct dentry *dir;
39 39
40 dir = dget(dentry->d_parent); 40 dir = dget_parent(dentry);
41 mutex_lock_nested(&(dir->d_inode->i_mutex), I_MUTEX_PARENT); 41 mutex_lock_nested(&(dir->d_inode->i_mutex), I_MUTEX_PARENT);
42 return dir; 42 return dir;
43} 43}
44 44
45static void unlock_parent(struct dentry *dentry)
46{
47 mutex_unlock(&(dentry->d_parent->d_inode->i_mutex));
48 dput(dentry->d_parent);
49}
50
51static void unlock_dir(struct dentry *dir) 45static void unlock_dir(struct dentry *dir)
52{ 46{
53 mutex_unlock(&dir->d_inode->i_mutex); 47 mutex_unlock(&dir->d_inode->i_mutex);
@@ -426,8 +420,9 @@ static int ecryptfs_unlink(struct inode *dir, struct dentry *dentry)
426 int rc = 0; 420 int rc = 0;
427 struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry); 421 struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
428 struct inode *lower_dir_inode = ecryptfs_inode_to_lower(dir); 422 struct inode *lower_dir_inode = ecryptfs_inode_to_lower(dir);
423 struct dentry *lower_dir_dentry;
429 424
430 lock_parent(lower_dentry); 425 lower_dir_dentry = lock_parent(lower_dentry);
431 rc = vfs_unlink(lower_dir_inode, lower_dentry); 426 rc = vfs_unlink(lower_dir_inode, lower_dentry);
432 if (rc) { 427 if (rc) {
433 printk(KERN_ERR "Error in vfs_unlink; rc = [%d]\n", rc); 428 printk(KERN_ERR "Error in vfs_unlink; rc = [%d]\n", rc);
@@ -439,7 +434,7 @@ static int ecryptfs_unlink(struct inode *dir, struct dentry *dentry)
439 dentry->d_inode->i_ctime = dir->i_ctime; 434 dentry->d_inode->i_ctime = dir->i_ctime;
440 d_drop(dentry); 435 d_drop(dentry);
441out_unlock: 436out_unlock:
442 unlock_parent(lower_dentry); 437 unlock_dir(lower_dir_dentry);
443 return rc; 438 return rc;
444} 439}
445 440
diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
index 788995efd1d3..50c994a249a5 100644
--- a/fs/ecryptfs/miscdev.c
+++ b/fs/ecryptfs/miscdev.c
@@ -243,7 +243,6 @@ ecryptfs_miscdev_read(struct file *file, char __user *buf, size_t count,
243 struct ecryptfs_daemon *daemon; 243 struct ecryptfs_daemon *daemon;
244 struct ecryptfs_msg_ctx *msg_ctx; 244 struct ecryptfs_msg_ctx *msg_ctx;
245 size_t packet_length_size; 245 size_t packet_length_size;
246 u32 counter_nbo;
247 char packet_length[3]; 246 char packet_length[3];
248 size_t i; 247 size_t i;
249 size_t total_length; 248 size_t total_length;
@@ -257,12 +256,14 @@ ecryptfs_miscdev_read(struct file *file, char __user *buf, size_t count,
257 mutex_lock(&daemon->mux); 256 mutex_lock(&daemon->mux);
258 if (daemon->flags & ECRYPTFS_DAEMON_ZOMBIE) { 257 if (daemon->flags & ECRYPTFS_DAEMON_ZOMBIE) {
259 rc = 0; 258 rc = 0;
259 mutex_unlock(&ecryptfs_daemon_hash_mux);
260 printk(KERN_WARNING "%s: Attempt to read from zombified " 260 printk(KERN_WARNING "%s: Attempt to read from zombified "
261 "daemon\n", __func__); 261 "daemon\n", __func__);
262 goto out_unlock_daemon; 262 goto out_unlock_daemon;
263 } 263 }
264 if (daemon->flags & ECRYPTFS_DAEMON_IN_READ) { 264 if (daemon->flags & ECRYPTFS_DAEMON_IN_READ) {
265 rc = 0; 265 rc = 0;
266 mutex_unlock(&ecryptfs_daemon_hash_mux);
266 goto out_unlock_daemon; 267 goto out_unlock_daemon;
267 } 268 }
268 /* This daemon will not go away so long as this flag is set */ 269 /* This daemon will not go away so long as this flag is set */
@@ -326,20 +327,18 @@ check_list:
326 "pending message\n", __func__, count, total_length); 327 "pending message\n", __func__, count, total_length);
327 goto out_unlock_msg_ctx; 328 goto out_unlock_msg_ctx;
328 } 329 }
329 i = 0; 330 rc = -EFAULT;
330 buf[i++] = msg_ctx->type; 331 if (put_user(msg_ctx->type, buf))
331 counter_nbo = cpu_to_be32(msg_ctx->counter); 332 goto out_unlock_msg_ctx;
332 memcpy(&buf[i], (char *)&counter_nbo, 4); 333 if (put_user(cpu_to_be32(msg_ctx->counter), (__be32 __user *)(buf + 1)))
333 i += 4; 334 goto out_unlock_msg_ctx;
335 i = 5;
334 if (msg_ctx->msg) { 336 if (msg_ctx->msg) {
335 memcpy(&buf[i], packet_length, packet_length_size); 337 if (copy_to_user(&buf[i], packet_length, packet_length_size))
338 goto out_unlock_msg_ctx;
336 i += packet_length_size; 339 i += packet_length_size;
337 rc = copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size); 340 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
338 if (rc) {
339 printk(KERN_ERR "%s: copy_to_user returned error "
340 "[%d]\n", __func__, rc);
341 goto out_unlock_msg_ctx; 341 goto out_unlock_msg_ctx;
342 }
343 i += msg_ctx->msg_size; 342 i += msg_ctx->msg_size;
344 } 343 }
345 rc = i; 344 rc = i;
@@ -450,7 +449,8 @@ static ssize_t
450ecryptfs_miscdev_write(struct file *file, const char __user *buf, 449ecryptfs_miscdev_write(struct file *file, const char __user *buf,
451 size_t count, loff_t *ppos) 450 size_t count, loff_t *ppos)
452{ 451{
453 u32 counter_nbo, seq; 452 __be32 counter_nbo;
453 u32 seq;
454 size_t packet_size, packet_size_length, i; 454 size_t packet_size, packet_size_length, i;
455 ssize_t sz = 0; 455 ssize_t sz = 0;
456 char *data; 456 char *data;
@@ -483,7 +483,7 @@ ecryptfs_miscdev_write(struct file *file, const char __user *buf,
483 count); 483 count);
484 goto out_free; 484 goto out_free;
485 } 485 }
486 memcpy((char *)&counter_nbo, &data[i], 4); 486 memcpy(&counter_nbo, &data[i], 4);
487 seq = be32_to_cpu(counter_nbo); 487 seq = be32_to_cpu(counter_nbo);
488 i += 4; 488 i += 4;
489 rc = ecryptfs_parse_packet_length(&data[i], &packet_size, 489 rc = ecryptfs_parse_packet_length(&data[i], &packet_size,
diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
index ebf55150be56..75c2ea9fee35 100644
--- a/fs/ecryptfs/read_write.c
+++ b/fs/ecryptfs/read_write.c
@@ -157,20 +157,6 @@ int ecryptfs_write(struct file *ecryptfs_file, char *data, loff_t offset,
157 ecryptfs_page_idx, rc); 157 ecryptfs_page_idx, rc);
158 goto out; 158 goto out;
159 } 159 }
160 if (start_offset_in_page) {
161 /* Read in the page from the lower
162 * into the eCryptfs inode page cache,
163 * decrypting */
164 rc = ecryptfs_decrypt_page(ecryptfs_page);
165 if (rc) {
166 printk(KERN_ERR "%s: Error decrypting "
167 "page; rc = [%d]\n",
168 __func__, rc);
169 ClearPageUptodate(ecryptfs_page);
170 page_cache_release(ecryptfs_page);
171 goto out;
172 }
173 }
174 ecryptfs_page_virt = kmap_atomic(ecryptfs_page, KM_USER0); 160 ecryptfs_page_virt = kmap_atomic(ecryptfs_page, KM_USER0);
175 161
176 /* 162 /*
@@ -349,14 +335,6 @@ int ecryptfs_read(char *data, loff_t offset, size_t size,
349 ecryptfs_page_idx, rc); 335 ecryptfs_page_idx, rc);
350 goto out; 336 goto out;
351 } 337 }
352 rc = ecryptfs_decrypt_page(ecryptfs_page);
353 if (rc) {
354 printk(KERN_ERR "%s: Error decrypting "
355 "page; rc = [%d]\n", __func__, rc);
356 ClearPageUptodate(ecryptfs_page);
357 page_cache_release(ecryptfs_page);
358 goto out;
359 }
360 ecryptfs_page_virt = kmap_atomic(ecryptfs_page, KM_USER0); 338 ecryptfs_page_virt = kmap_atomic(ecryptfs_page, KM_USER0);
361 memcpy((data + data_offset), 339 memcpy((data + data_offset),
362 ((char *)ecryptfs_page_virt + start_offset_in_page), 340 ((char *)ecryptfs_page_virt + start_offset_in_page),
diff --git a/fs/exec.c b/fs/exec.c
index aeaa9791d8be..9448f1b50b4a 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -736,7 +736,7 @@ static int exec_mmap(struct mm_struct *mm)
736 tsk->active_mm = mm; 736 tsk->active_mm = mm;
737 activate_mm(active_mm, mm); 737 activate_mm(active_mm, mm);
738 task_unlock(tsk); 738 task_unlock(tsk);
739 mm_update_next_owner(mm); 739 mm_update_next_owner(old_mm);
740 arch_pick_mmap_layout(mm); 740 arch_pick_mmap_layout(mm);
741 if (old_mm) { 741 if (old_mm) {
742 up_read(&old_mm->mmap_sem); 742 up_read(&old_mm->mmap_sem);
@@ -860,6 +860,7 @@ static int de_thread(struct task_struct *tsk)
860 860
861no_thread_group: 861no_thread_group:
862 exit_itimers(sig); 862 exit_itimers(sig);
863 flush_itimer_signals();
863 if (leader) 864 if (leader)
864 release_task(leader); 865 release_task(leader);
865 866
@@ -1251,6 +1252,12 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
1251 1252
1252EXPORT_SYMBOL(search_binary_handler); 1253EXPORT_SYMBOL(search_binary_handler);
1253 1254
1255void free_bprm(struct linux_binprm *bprm)
1256{
1257 free_arg_pages(bprm);
1258 kfree(bprm);
1259}
1260
1254/* 1261/*
1255 * sys_execve() executes a new program. 1262 * sys_execve() executes a new program.
1256 */ 1263 */
@@ -1320,17 +1327,15 @@ int do_execve(char * filename,
1320 retval = search_binary_handler(bprm,regs); 1327 retval = search_binary_handler(bprm,regs);
1321 if (retval >= 0) { 1328 if (retval >= 0) {
1322 /* execve success */ 1329 /* execve success */
1323 free_arg_pages(bprm);
1324 security_bprm_free(bprm); 1330 security_bprm_free(bprm);
1325 acct_update_integrals(current); 1331 acct_update_integrals(current);
1326 kfree(bprm); 1332 free_bprm(bprm);
1327 if (displaced) 1333 if (displaced)
1328 put_files_struct(displaced); 1334 put_files_struct(displaced);
1329 return retval; 1335 return retval;
1330 } 1336 }
1331 1337
1332out: 1338out:
1333 free_arg_pages(bprm);
1334 if (bprm->security) 1339 if (bprm->security)
1335 security_bprm_free(bprm); 1340 security_bprm_free(bprm);
1336 1341
@@ -1344,7 +1349,7 @@ out_file:
1344 fput(bprm->file); 1349 fput(bprm->file);
1345 } 1350 }
1346out_kfree: 1351out_kfree:
1347 kfree(bprm); 1352 free_bprm(bprm);
1348 1353
1349out_files: 1354out_files:
1350 if (displaced) 1355 if (displaced)
diff --git a/fs/ext3/resize.c b/fs/ext3/resize.c
index 28cfd0b40527..77278e947e94 100644
--- a/fs/ext3/resize.c
+++ b/fs/ext3/resize.c
@@ -580,7 +580,8 @@ static int reserve_backup_gdb(handle_t *handle, struct inode *inode,
580 } 580 }
581 581
582 blk = EXT3_SB(sb)->s_sbh->b_blocknr + 1 + EXT3_SB(sb)->s_gdb_count; 582 blk = EXT3_SB(sb)->s_sbh->b_blocknr + 1 + EXT3_SB(sb)->s_gdb_count;
583 data = (__le32 *)dind->b_data + EXT3_SB(sb)->s_gdb_count; 583 data = (__le32 *)dind->b_data + (EXT3_SB(sb)->s_gdb_count %
584 EXT3_ADDR_PER_BLOCK(sb));
584 end = (__le32 *)dind->b_data + EXT3_ADDR_PER_BLOCK(sb); 585 end = (__le32 *)dind->b_data + EXT3_ADDR_PER_BLOCK(sb);
585 586
586 /* Get each reserved primary GDT block and verify it holds backups */ 587 /* Get each reserved primary GDT block and verify it holds backups */
diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c
index d4a4f0e9ff69..175414ac2210 100644
--- a/fs/ext3/xattr.c
+++ b/fs/ext3/xattr.c
@@ -1000,6 +1000,11 @@ ext3_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
1000 i.value = NULL; 1000 i.value = NULL;
1001 error = ext3_xattr_block_set(handle, inode, &i, &bs); 1001 error = ext3_xattr_block_set(handle, inode, &i, &bs);
1002 } else if (error == -ENOSPC) { 1002 } else if (error == -ENOSPC) {
1003 if (EXT3_I(inode)->i_file_acl && !bs.s.base) {
1004 error = ext3_xattr_block_find(inode, &i, &bs);
1005 if (error)
1006 goto cleanup;
1007 }
1003 error = ext3_xattr_block_set(handle, inode, &i, &bs); 1008 error = ext3_xattr_block_set(handle, inode, &i, &bs);
1004 if (error) 1009 if (error)
1005 goto cleanup; 1010 goto cleanup;
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index da994374ec3b..9cc80b9cc8d8 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -43,6 +43,46 @@ void ext4_get_group_no_and_offset(struct super_block *sb, ext4_fsblk_t blocknr,
43 43
44} 44}
45 45
46static int ext4_block_in_group(struct super_block *sb, ext4_fsblk_t block,
47 ext4_group_t block_group)
48{
49 ext4_group_t actual_group;
50 ext4_get_group_no_and_offset(sb, block, &actual_group, 0);
51 if (actual_group == block_group)
52 return 1;
53 return 0;
54}
55
56static int ext4_group_used_meta_blocks(struct super_block *sb,
57 ext4_group_t block_group)
58{
59 ext4_fsblk_t tmp;
60 struct ext4_sb_info *sbi = EXT4_SB(sb);
61 /* block bitmap, inode bitmap, and inode table blocks */
62 int used_blocks = sbi->s_itb_per_group + 2;
63
64 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG)) {
65 struct ext4_group_desc *gdp;
66 struct buffer_head *bh;
67
68 gdp = ext4_get_group_desc(sb, block_group, &bh);
69 if (!ext4_block_in_group(sb, ext4_block_bitmap(sb, gdp),
70 block_group))
71 used_blocks--;
72
73 if (!ext4_block_in_group(sb, ext4_inode_bitmap(sb, gdp),
74 block_group))
75 used_blocks--;
76
77 tmp = ext4_inode_table(sb, gdp);
78 for (; tmp < ext4_inode_table(sb, gdp) +
79 sbi->s_itb_per_group; tmp++) {
80 if (!ext4_block_in_group(sb, tmp, block_group))
81 used_blocks -= 1;
82 }
83 }
84 return used_blocks;
85}
46/* Initializes an uninitialized block bitmap if given, and returns the 86/* Initializes an uninitialized block bitmap if given, and returns the
47 * number of blocks free in the group. */ 87 * number of blocks free in the group. */
48unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh, 88unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh,
@@ -105,20 +145,34 @@ unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh,
105 free_blocks = group_blocks - bit_max; 145 free_blocks = group_blocks - bit_max;
106 146
107 if (bh) { 147 if (bh) {
108 ext4_fsblk_t start; 148 ext4_fsblk_t start, tmp;
149 int flex_bg = 0;
109 150
110 for (bit = 0; bit < bit_max; bit++) 151 for (bit = 0; bit < bit_max; bit++)
111 ext4_set_bit(bit, bh->b_data); 152 ext4_set_bit(bit, bh->b_data);
112 153
113 start = ext4_group_first_block_no(sb, block_group); 154 start = ext4_group_first_block_no(sb, block_group);
114 155
115 /* Set bits for block and inode bitmaps, and inode table */ 156 if (EXT4_HAS_INCOMPAT_FEATURE(sb,
116 ext4_set_bit(ext4_block_bitmap(sb, gdp) - start, bh->b_data); 157 EXT4_FEATURE_INCOMPAT_FLEX_BG))
117 ext4_set_bit(ext4_inode_bitmap(sb, gdp) - start, bh->b_data); 158 flex_bg = 1;
118 for (bit = (ext4_inode_table(sb, gdp) - start),
119 bit_max = bit + sbi->s_itb_per_group; bit < bit_max; bit++)
120 ext4_set_bit(bit, bh->b_data);
121 159
160 /* Set bits for block and inode bitmaps, and inode table */
161 tmp = ext4_block_bitmap(sb, gdp);
162 if (!flex_bg || ext4_block_in_group(sb, tmp, block_group))
163 ext4_set_bit(tmp - start, bh->b_data);
164
165 tmp = ext4_inode_bitmap(sb, gdp);
166 if (!flex_bg || ext4_block_in_group(sb, tmp, block_group))
167 ext4_set_bit(tmp - start, bh->b_data);
168
169 tmp = ext4_inode_table(sb, gdp);
170 for (; tmp < ext4_inode_table(sb, gdp) +
171 sbi->s_itb_per_group; tmp++) {
172 if (!flex_bg ||
173 ext4_block_in_group(sb, tmp, block_group))
174 ext4_set_bit(tmp - start, bh->b_data);
175 }
122 /* 176 /*
123 * Also if the number of blocks within the group is 177 * Also if the number of blocks within the group is
124 * less than the blocksize * 8 ( which is the size 178 * less than the blocksize * 8 ( which is the size
@@ -126,8 +180,7 @@ unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh,
126 */ 180 */
127 mark_bitmap_end(group_blocks, sb->s_blocksize * 8, bh->b_data); 181 mark_bitmap_end(group_blocks, sb->s_blocksize * 8, bh->b_data);
128 } 182 }
129 183 return free_blocks - ext4_group_used_meta_blocks(sb, block_group);
130 return free_blocks - sbi->s_itb_per_group - 2;
131} 184}
132 185
133 186
@@ -287,11 +340,11 @@ read_block_bitmap(struct super_block *sb, ext4_group_t block_group)
287 (int)block_group, (unsigned long long)bitmap_blk); 340 (int)block_group, (unsigned long long)bitmap_blk);
288 return NULL; 341 return NULL;
289 } 342 }
290 if (!ext4_valid_block_bitmap(sb, desc, block_group, bh)) { 343 ext4_valid_block_bitmap(sb, desc, block_group, bh);
291 put_bh(bh); 344 /*
292 return NULL; 345 * file system mounted not to panic on error,
293 } 346 * continue with corrupt bitmap
294 347 */
295 return bh; 348 return bh;
296} 349}
297/* 350/*
@@ -1770,7 +1823,12 @@ allocated:
1770 "Allocating block in system zone - " 1823 "Allocating block in system zone - "
1771 "blocks from %llu, length %lu", 1824 "blocks from %llu, length %lu",
1772 ret_block, num); 1825 ret_block, num);
1773 goto out; 1826 /*
1827 * claim_block marked the blocks we allocated
1828 * as in use. So we may want to selectively
1829 * mark some of the blocks as free
1830 */
1831 goto retry_alloc;
1774 } 1832 }
1775 1833
1776 performed_allocation = 1; 1834 performed_allocation = 1;
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index fbec2ef93797..c9900aade150 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2639,8 +2639,7 @@ static int ext4_mb_init_per_dev_proc(struct super_block *sb)
2639 struct proc_dir_entry *proc; 2639 struct proc_dir_entry *proc;
2640 char devname[64]; 2640 char devname[64];
2641 2641
2642 snprintf(devname, sizeof(devname) - 1, "%s", 2642 bdevname(sb->s_bdev, devname);
2643 bdevname(sb->s_bdev, devname));
2644 sbi->s_mb_proc = proc_mkdir(devname, proc_root_ext4); 2643 sbi->s_mb_proc = proc_mkdir(devname, proc_root_ext4);
2645 2644
2646 MB_PROC_HANDLER(EXT4_MB_STATS_NAME, stats); 2645 MB_PROC_HANDLER(EXT4_MB_STATS_NAME, stats);
@@ -2674,8 +2673,7 @@ static int ext4_mb_destroy_per_dev_proc(struct super_block *sb)
2674 if (sbi->s_mb_proc == NULL) 2673 if (sbi->s_mb_proc == NULL)
2675 return -EINVAL; 2674 return -EINVAL;
2676 2675
2677 snprintf(devname, sizeof(devname) - 1, "%s", 2676 bdevname(sb->s_bdev, devname);
2678 bdevname(sb->s_bdev, devname));
2679 remove_proc_entry(EXT4_MB_GROUP_PREALLOC, sbi->s_mb_proc); 2677 remove_proc_entry(EXT4_MB_GROUP_PREALLOC, sbi->s_mb_proc);
2680 remove_proc_entry(EXT4_MB_STREAM_REQ, sbi->s_mb_proc); 2678 remove_proc_entry(EXT4_MB_STREAM_REQ, sbi->s_mb_proc);
2681 remove_proc_entry(EXT4_MB_ORDER2_REQ, sbi->s_mb_proc); 2679 remove_proc_entry(EXT4_MB_ORDER2_REQ, sbi->s_mb_proc);
@@ -2738,7 +2736,7 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac,
2738 struct ext4_sb_info *sbi; 2736 struct ext4_sb_info *sbi;
2739 struct super_block *sb; 2737 struct super_block *sb;
2740 ext4_fsblk_t block; 2738 ext4_fsblk_t block;
2741 int err; 2739 int err, len;
2742 2740
2743 BUG_ON(ac->ac_status != AC_STATUS_FOUND); 2741 BUG_ON(ac->ac_status != AC_STATUS_FOUND);
2744 BUG_ON(ac->ac_b_ex.fe_len <= 0); 2742 BUG_ON(ac->ac_b_ex.fe_len <= 0);
@@ -2747,8 +2745,6 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac,
2747 sbi = EXT4_SB(sb); 2745 sbi = EXT4_SB(sb);
2748 es = sbi->s_es; 2746 es = sbi->s_es;
2749 2747
2750 ext4_debug("using block group %lu(%d)\n", ac->ac_b_ex.fe_group,
2751 gdp->bg_free_blocks_count);
2752 2748
2753 err = -EIO; 2749 err = -EIO;
2754 bitmap_bh = read_block_bitmap(sb, ac->ac_b_ex.fe_group); 2750 bitmap_bh = read_block_bitmap(sb, ac->ac_b_ex.fe_group);
@@ -2764,6 +2760,9 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac,
2764 if (!gdp) 2760 if (!gdp)
2765 goto out_err; 2761 goto out_err;
2766 2762
2763 ext4_debug("using block group %lu(%d)\n", ac->ac_b_ex.fe_group,
2764 gdp->bg_free_blocks_count);
2765
2767 err = ext4_journal_get_write_access(handle, gdp_bh); 2766 err = ext4_journal_get_write_access(handle, gdp_bh);
2768 if (err) 2767 if (err)
2769 goto out_err; 2768 goto out_err;
@@ -2772,14 +2771,27 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac,
2772 + ac->ac_b_ex.fe_start 2771 + ac->ac_b_ex.fe_start
2773 + le32_to_cpu(es->s_first_data_block); 2772 + le32_to_cpu(es->s_first_data_block);
2774 2773
2775 if (block == ext4_block_bitmap(sb, gdp) || 2774 len = ac->ac_b_ex.fe_len;
2776 block == ext4_inode_bitmap(sb, gdp) || 2775 if (in_range(ext4_block_bitmap(sb, gdp), block, len) ||
2777 in_range(block, ext4_inode_table(sb, gdp), 2776 in_range(ext4_inode_bitmap(sb, gdp), block, len) ||
2778 EXT4_SB(sb)->s_itb_per_group)) { 2777 in_range(block, ext4_inode_table(sb, gdp),
2779 2778 EXT4_SB(sb)->s_itb_per_group) ||
2779 in_range(block + len - 1, ext4_inode_table(sb, gdp),
2780 EXT4_SB(sb)->s_itb_per_group)) {
2780 ext4_error(sb, __func__, 2781 ext4_error(sb, __func__,
2781 "Allocating block in system zone - block = %llu", 2782 "Allocating block in system zone - block = %llu",
2782 block); 2783 block);
2784 /* File system mounted not to panic on error
2785 * Fix the bitmap and repeat the block allocation
2786 * We leak some of the blocks here.
2787 */
2788 mb_set_bits(sb_bgl_lock(sbi, ac->ac_b_ex.fe_group),
2789 bitmap_bh->b_data, ac->ac_b_ex.fe_start,
2790 ac->ac_b_ex.fe_len);
2791 err = ext4_journal_dirty_metadata(handle, bitmap_bh);
2792 if (!err)
2793 err = -EAGAIN;
2794 goto out_err;
2783 } 2795 }
2784#ifdef AGGRESSIVE_CHECK 2796#ifdef AGGRESSIVE_CHECK
2785 { 2797 {
@@ -2882,12 +2894,11 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac,
2882 if (size < i_size_read(ac->ac_inode)) 2894 if (size < i_size_read(ac->ac_inode))
2883 size = i_size_read(ac->ac_inode); 2895 size = i_size_read(ac->ac_inode);
2884 2896
2885 /* max available blocks in a free group */ 2897 /* max size of free chunks */
2886 max = EXT4_BLOCKS_PER_GROUP(ac->ac_sb) - 1 - 1 - 2898 max = 2 << bsbits;
2887 EXT4_SB(ac->ac_sb)->s_itb_per_group;
2888 2899
2889#define NRL_CHECK_SIZE(req, size, max,bits) \ 2900#define NRL_CHECK_SIZE(req, size, max, chunk_size) \
2890 (req <= (size) || max <= ((size) >> bits)) 2901 (req <= (size) || max <= (chunk_size))
2891 2902
2892 /* first, try to predict filesize */ 2903 /* first, try to predict filesize */
2893 /* XXX: should this table be tunable? */ 2904 /* XXX: should this table be tunable? */
@@ -2906,16 +2917,16 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac,
2906 size = 512 * 1024; 2917 size = 512 * 1024;
2907 } else if (size <= 1024 * 1024) { 2918 } else if (size <= 1024 * 1024) {
2908 size = 1024 * 1024; 2919 size = 1024 * 1024;
2909 } else if (NRL_CHECK_SIZE(size, 4 * 1024 * 1024, max, bsbits)) { 2920 } else if (NRL_CHECK_SIZE(size, 4 * 1024 * 1024, max, 2 * 1024)) {
2910 start_off = ((loff_t)ac->ac_o_ex.fe_logical >> 2921 start_off = ((loff_t)ac->ac_o_ex.fe_logical >>
2911 (20 - bsbits)) << 20; 2922 (21 - bsbits)) << 21;
2912 size = 1024 * 1024; 2923 size = 2 * 1024 * 1024;
2913 } else if (NRL_CHECK_SIZE(size, 8 * 1024 * 1024, max, bsbits)) { 2924 } else if (NRL_CHECK_SIZE(size, 8 * 1024 * 1024, max, 4 * 1024)) {
2914 start_off = ((loff_t)ac->ac_o_ex.fe_logical >> 2925 start_off = ((loff_t)ac->ac_o_ex.fe_logical >>
2915 (22 - bsbits)) << 22; 2926 (22 - bsbits)) << 22;
2916 size = 4 * 1024 * 1024; 2927 size = 4 * 1024 * 1024;
2917 } else if (NRL_CHECK_SIZE(ac->ac_o_ex.fe_len, 2928 } else if (NRL_CHECK_SIZE(ac->ac_o_ex.fe_len,
2918 (8<<20)>>bsbits, max, bsbits)) { 2929 (8<<20)>>bsbits, max, 8 * 1024)) {
2919 start_off = ((loff_t)ac->ac_o_ex.fe_logical >> 2930 start_off = ((loff_t)ac->ac_o_ex.fe_logical >>
2920 (23 - bsbits)) << 23; 2931 (23 - bsbits)) << 23;
2921 size = 8 * 1024 * 1024; 2932 size = 8 * 1024 * 1024;
@@ -3084,8 +3095,7 @@ static void ext4_mb_use_inode_pa(struct ext4_allocation_context *ac,
3084static void ext4_mb_use_group_pa(struct ext4_allocation_context *ac, 3095static void ext4_mb_use_group_pa(struct ext4_allocation_context *ac,
3085 struct ext4_prealloc_space *pa) 3096 struct ext4_prealloc_space *pa)
3086{ 3097{
3087 unsigned len = ac->ac_o_ex.fe_len; 3098 unsigned int len = ac->ac_o_ex.fe_len;
3088
3089 ext4_get_group_no_and_offset(ac->ac_sb, pa->pa_pstart, 3099 ext4_get_group_no_and_offset(ac->ac_sb, pa->pa_pstart,
3090 &ac->ac_b_ex.fe_group, 3100 &ac->ac_b_ex.fe_group,
3091 &ac->ac_b_ex.fe_start); 3101 &ac->ac_b_ex.fe_start);
@@ -4035,7 +4045,6 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
4035 4045
4036 ac->ac_op = EXT4_MB_HISTORY_ALLOC; 4046 ac->ac_op = EXT4_MB_HISTORY_ALLOC;
4037 ext4_mb_normalize_request(ac, ar); 4047 ext4_mb_normalize_request(ac, ar);
4038
4039repeat: 4048repeat:
4040 /* allocate space in core */ 4049 /* allocate space in core */
4041 ext4_mb_regular_allocator(ac); 4050 ext4_mb_regular_allocator(ac);
@@ -4049,10 +4058,21 @@ repeat:
4049 } 4058 }
4050 4059
4051 if (likely(ac->ac_status == AC_STATUS_FOUND)) { 4060 if (likely(ac->ac_status == AC_STATUS_FOUND)) {
4052 ext4_mb_mark_diskspace_used(ac, handle); 4061 *errp = ext4_mb_mark_diskspace_used(ac, handle);
4053 *errp = 0; 4062 if (*errp == -EAGAIN) {
4054 block = ext4_grp_offs_to_block(sb, &ac->ac_b_ex); 4063 ac->ac_b_ex.fe_group = 0;
4055 ar->len = ac->ac_b_ex.fe_len; 4064 ac->ac_b_ex.fe_start = 0;
4065 ac->ac_b_ex.fe_len = 0;
4066 ac->ac_status = AC_STATUS_CONTINUE;
4067 goto repeat;
4068 } else if (*errp) {
4069 ac->ac_b_ex.fe_len = 0;
4070 ar->len = 0;
4071 ext4_mb_show_ac(ac);
4072 } else {
4073 block = ext4_grp_offs_to_block(sb, &ac->ac_b_ex);
4074 ar->len = ac->ac_b_ex.fe_len;
4075 }
4056 } else { 4076 } else {
4057 freed = ext4_mb_discard_preallocations(sb, ac->ac_o_ex.fe_len); 4077 freed = ext4_mb_discard_preallocations(sb, ac->ac_o_ex.fe_len);
4058 if (freed) 4078 if (freed)
@@ -4239,6 +4259,8 @@ do_more:
4239 ext4_error(sb, __func__, 4259 ext4_error(sb, __func__,
4240 "Freeing blocks in system zone - " 4260 "Freeing blocks in system zone - "
4241 "Block = %lu, count = %lu", block, count); 4261 "Block = %lu, count = %lu", block, count);
4262 /* err = 0. ext4_std_error should be a no op */
4263 goto error_return;
4242 } 4264 }
4243 4265
4244 BUFFER_TRACE(bitmap_bh, "getting write access"); 4266 BUFFER_TRACE(bitmap_bh, "getting write access");
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index 9f086a6a472b..9ecb92f68543 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -563,7 +563,8 @@ static int reserve_backup_gdb(handle_t *handle, struct inode *inode,
563 } 563 }
564 564
565 blk = EXT4_SB(sb)->s_sbh->b_blocknr + 1 + EXT4_SB(sb)->s_gdb_count; 565 blk = EXT4_SB(sb)->s_sbh->b_blocknr + 1 + EXT4_SB(sb)->s_gdb_count;
566 data = (__le32 *)dind->b_data + EXT4_SB(sb)->s_gdb_count; 566 data = (__le32 *)dind->b_data + (EXT4_SB(sb)->s_gdb_count %
567 EXT4_ADDR_PER_BLOCK(sb));
567 end = (__le32 *)dind->b_data + EXT4_ADDR_PER_BLOCK(sb); 568 end = (__le32 *)dind->b_data + EXT4_ADDR_PER_BLOCK(sb);
568 569
569 /* Get each reserved primary GDT block and verify it holds backups */ 570 /* Get each reserved primary GDT block and verify it holds backups */
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 52dd0679a4e2..cb96f127c366 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -671,6 +671,7 @@ static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs)
671 unsigned long def_mount_opts; 671 unsigned long def_mount_opts;
672 struct super_block *sb = vfs->mnt_sb; 672 struct super_block *sb = vfs->mnt_sb;
673 struct ext4_sb_info *sbi = EXT4_SB(sb); 673 struct ext4_sb_info *sbi = EXT4_SB(sb);
674 journal_t *journal = sbi->s_journal;
674 struct ext4_super_block *es = sbi->s_es; 675 struct ext4_super_block *es = sbi->s_es;
675 676
676 def_mount_opts = le32_to_cpu(es->s_default_mount_opts); 677 def_mount_opts = le32_to_cpu(es->s_default_mount_opts);
@@ -729,8 +730,15 @@ static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs)
729 seq_printf(seq, ",commit=%u", 730 seq_printf(seq, ",commit=%u",
730 (unsigned) (sbi->s_commit_interval / HZ)); 731 (unsigned) (sbi->s_commit_interval / HZ));
731 } 732 }
732 if (test_opt(sb, BARRIER)) 733 /*
733 seq_puts(seq, ",barrier=1"); 734 * We're changing the default of barrier mount option, so
735 * let's always display its mount state so it's clear what its
736 * status is.
737 */
738 seq_puts(seq, ",barrier=");
739 seq_puts(seq, test_opt(sb, BARRIER) ? "1" : "0");
740 if (test_opt(sb, JOURNAL_ASYNC_COMMIT))
741 seq_puts(seq, ",journal_async_commit");
734 if (test_opt(sb, NOBH)) 742 if (test_opt(sb, NOBH))
735 seq_puts(seq, ",nobh"); 743 seq_puts(seq, ",nobh");
736 if (!test_opt(sb, EXTENTS)) 744 if (!test_opt(sb, EXTENTS))
@@ -979,7 +987,7 @@ static int parse_options (char *options, struct super_block *sb,
979 int data_opt = 0; 987 int data_opt = 0;
980 int option; 988 int option;
981#ifdef CONFIG_QUOTA 989#ifdef CONFIG_QUOTA
982 int qtype; 990 int qtype, qfmt;
983 char *qname; 991 char *qname;
984#endif 992#endif
985 993
@@ -1162,9 +1170,11 @@ static int parse_options (char *options, struct super_block *sb,
1162 case Opt_grpjquota: 1170 case Opt_grpjquota:
1163 qtype = GRPQUOTA; 1171 qtype = GRPQUOTA;
1164set_qf_name: 1172set_qf_name:
1165 if (sb_any_quota_enabled(sb)) { 1173 if ((sb_any_quota_enabled(sb) ||
1174 sb_any_quota_suspended(sb)) &&
1175 !sbi->s_qf_names[qtype]) {
1166 printk(KERN_ERR 1176 printk(KERN_ERR
1167 "EXT4-fs: Cannot change journalled " 1177 "EXT4-fs: Cannot change journaled "
1168 "quota options when quota turned on.\n"); 1178 "quota options when quota turned on.\n");
1169 return 0; 1179 return 0;
1170 } 1180 }
@@ -1200,9 +1210,11 @@ set_qf_name:
1200 case Opt_offgrpjquota: 1210 case Opt_offgrpjquota:
1201 qtype = GRPQUOTA; 1211 qtype = GRPQUOTA;
1202clear_qf_name: 1212clear_qf_name:
1203 if (sb_any_quota_enabled(sb)) { 1213 if ((sb_any_quota_enabled(sb) ||
1214 sb_any_quota_suspended(sb)) &&
1215 sbi->s_qf_names[qtype]) {
1204 printk(KERN_ERR "EXT4-fs: Cannot change " 1216 printk(KERN_ERR "EXT4-fs: Cannot change "
1205 "journalled quota options when " 1217 "journaled quota options when "
1206 "quota turned on.\n"); 1218 "quota turned on.\n");
1207 return 0; 1219 return 0;
1208 } 1220 }
@@ -1213,10 +1225,20 @@ clear_qf_name:
1213 sbi->s_qf_names[qtype] = NULL; 1225 sbi->s_qf_names[qtype] = NULL;
1214 break; 1226 break;
1215 case Opt_jqfmt_vfsold: 1227 case Opt_jqfmt_vfsold:
1216 sbi->s_jquota_fmt = QFMT_VFS_OLD; 1228 qfmt = QFMT_VFS_OLD;
1217 break; 1229 goto set_qf_format;
1218 case Opt_jqfmt_vfsv0: 1230 case Opt_jqfmt_vfsv0:
1219 sbi->s_jquota_fmt = QFMT_VFS_V0; 1231 qfmt = QFMT_VFS_V0;
1232set_qf_format:
1233 if ((sb_any_quota_enabled(sb) ||
1234 sb_any_quota_suspended(sb)) &&
1235 sbi->s_jquota_fmt != qfmt) {
1236 printk(KERN_ERR "EXT4-fs: Cannot change "
1237 "journaled quota options when "
1238 "quota turned on.\n");
1239 return 0;
1240 }
1241 sbi->s_jquota_fmt = qfmt;
1220 break; 1242 break;
1221 case Opt_quota: 1243 case Opt_quota:
1222 case Opt_usrquota: 1244 case Opt_usrquota:
@@ -1241,6 +1263,9 @@ clear_qf_name:
1241 case Opt_quota: 1263 case Opt_quota:
1242 case Opt_usrquota: 1264 case Opt_usrquota:
1243 case Opt_grpquota: 1265 case Opt_grpquota:
1266 printk(KERN_ERR
1267 "EXT4-fs: quota options not supported.\n");
1268 break;
1244 case Opt_usrjquota: 1269 case Opt_usrjquota:
1245 case Opt_grpjquota: 1270 case Opt_grpjquota:
1246 case Opt_offusrjquota: 1271 case Opt_offusrjquota:
@@ -1248,7 +1273,7 @@ clear_qf_name:
1248 case Opt_jqfmt_vfsold: 1273 case Opt_jqfmt_vfsold:
1249 case Opt_jqfmt_vfsv0: 1274 case Opt_jqfmt_vfsv0:
1250 printk(KERN_ERR 1275 printk(KERN_ERR
1251 "EXT4-fs: journalled quota options not " 1276 "EXT4-fs: journaled quota options not "
1252 "supported.\n"); 1277 "supported.\n");
1253 break; 1278 break;
1254 case Opt_noquota: 1279 case Opt_noquota:
@@ -1333,14 +1358,14 @@ clear_qf_name:
1333 } 1358 }
1334 1359
1335 if (!sbi->s_jquota_fmt) { 1360 if (!sbi->s_jquota_fmt) {
1336 printk(KERN_ERR "EXT4-fs: journalled quota format " 1361 printk(KERN_ERR "EXT4-fs: journaled quota format "
1337 "not specified.\n"); 1362 "not specified.\n");
1338 return 0; 1363 return 0;
1339 } 1364 }
1340 } else { 1365 } else {
1341 if (sbi->s_jquota_fmt) { 1366 if (sbi->s_jquota_fmt) {
1342 printk(KERN_ERR "EXT4-fs: journalled quota format " 1367 printk(KERN_ERR "EXT4-fs: journaled quota format "
1343 "specified with no journalling " 1368 "specified with no journaling "
1344 "enabled.\n"); 1369 "enabled.\n");
1345 return 0; 1370 return 0;
1346 } 1371 }
@@ -1581,7 +1606,7 @@ static void ext4_orphan_cleanup (struct super_block * sb,
1581 int ret = ext4_quota_on_mount(sb, i); 1606 int ret = ext4_quota_on_mount(sb, i);
1582 if (ret < 0) 1607 if (ret < 0)
1583 printk(KERN_ERR 1608 printk(KERN_ERR
1584 "EXT4-fs: Cannot turn on journalled " 1609 "EXT4-fs: Cannot turn on journaled "
1585 "quota: error %d\n", ret); 1610 "quota: error %d\n", ret);
1586 } 1611 }
1587 } 1612 }
@@ -1890,6 +1915,7 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
1890 sbi->s_resgid = le16_to_cpu(es->s_def_resgid); 1915 sbi->s_resgid = le16_to_cpu(es->s_def_resgid);
1891 1916
1892 set_opt(sbi->s_mount_opt, RESERVATION); 1917 set_opt(sbi->s_mount_opt, RESERVATION);
1918 set_opt(sbi->s_mount_opt, BARRIER);
1893 1919
1894 /* 1920 /*
1895 * turn on extents feature by default in ext4 filesystem 1921 * turn on extents feature by default in ext4 filesystem
@@ -2172,6 +2198,29 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
2172 EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) { 2198 EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) {
2173 if (ext4_load_journal(sb, es, journal_devnum)) 2199 if (ext4_load_journal(sb, es, journal_devnum))
2174 goto failed_mount3; 2200 goto failed_mount3;
2201 if (!(sb->s_flags & MS_RDONLY) &&
2202 EXT4_SB(sb)->s_journal->j_failed_commit) {
2203 printk(KERN_CRIT "EXT4-fs error (device %s): "
2204 "ext4_fill_super: Journal transaction "
2205 "%u is corrupt\n", sb->s_id,
2206 EXT4_SB(sb)->s_journal->j_failed_commit);
2207 if (test_opt (sb, ERRORS_RO)) {
2208 printk (KERN_CRIT
2209 "Mounting filesystem read-only\n");
2210 sb->s_flags |= MS_RDONLY;
2211 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;
2212 es->s_state |= cpu_to_le16(EXT4_ERROR_FS);
2213 }
2214 if (test_opt(sb, ERRORS_PANIC)) {
2215 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;
2216 es->s_state |= cpu_to_le16(EXT4_ERROR_FS);
2217 ext4_commit_super(sb, es, 1);
2218 printk(KERN_CRIT
2219 "EXT4-fs (device %s): mount failed\n",
2220 sb->s_id);
2221 goto failed_mount4;
2222 }
2223 }
2175 } else if (journal_inum) { 2224 } else if (journal_inum) {
2176 if (ext4_create_journal(sb, es, journal_inum)) 2225 if (ext4_create_journal(sb, es, journal_inum))
2177 goto failed_mount3; 2226 goto failed_mount3;
@@ -3106,7 +3155,7 @@ static int ext4_release_dquot(struct dquot *dquot)
3106 3155
3107static int ext4_mark_dquot_dirty(struct dquot *dquot) 3156static int ext4_mark_dquot_dirty(struct dquot *dquot)
3108{ 3157{
3109 /* Are we journalling quotas? */ 3158 /* Are we journaling quotas? */
3110 if (EXT4_SB(dquot->dq_sb)->s_qf_names[USRQUOTA] || 3159 if (EXT4_SB(dquot->dq_sb)->s_qf_names[USRQUOTA] ||
3111 EXT4_SB(dquot->dq_sb)->s_qf_names[GRPQUOTA]) { 3160 EXT4_SB(dquot->dq_sb)->s_qf_names[GRPQUOTA]) {
3112 dquot_mark_dquot_dirty(dquot); 3161 dquot_mark_dquot_dirty(dquot);
@@ -3153,23 +3202,42 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id,
3153 3202
3154 if (!test_opt(sb, QUOTA)) 3203 if (!test_opt(sb, QUOTA))
3155 return -EINVAL; 3204 return -EINVAL;
3156 /* Not journalling quota? */ 3205 /* When remounting, no checks are needed and in fact, path is NULL */
3157 if ((!EXT4_SB(sb)->s_qf_names[USRQUOTA] && 3206 if (remount)
3158 !EXT4_SB(sb)->s_qf_names[GRPQUOTA]) || remount)
3159 return vfs_quota_on(sb, type, format_id, path, remount); 3207 return vfs_quota_on(sb, type, format_id, path, remount);
3208
3160 err = path_lookup(path, LOOKUP_FOLLOW, &nd); 3209 err = path_lookup(path, LOOKUP_FOLLOW, &nd);
3161 if (err) 3210 if (err)
3162 return err; 3211 return err;
3212
3163 /* Quotafile not on the same filesystem? */ 3213 /* Quotafile not on the same filesystem? */
3164 if (nd.path.mnt->mnt_sb != sb) { 3214 if (nd.path.mnt->mnt_sb != sb) {
3165 path_put(&nd.path); 3215 path_put(&nd.path);
3166 return -EXDEV; 3216 return -EXDEV;
3167 } 3217 }
3168 /* Quotafile not of fs root? */ 3218 /* Journaling quota? */
3169 if (nd.path.dentry->d_parent->d_inode != sb->s_root->d_inode) 3219 if (EXT4_SB(sb)->s_qf_names[type]) {
3170 printk(KERN_WARNING 3220 /* Quotafile not of fs root? */
3171 "EXT4-fs: Quota file not on filesystem root. " 3221 if (nd.path.dentry->d_parent->d_inode != sb->s_root->d_inode)
3172 "Journalled quota will not work.\n"); 3222 printk(KERN_WARNING
3223 "EXT4-fs: Quota file not on filesystem root. "
3224 "Journaled quota will not work.\n");
3225 }
3226
3227 /*
3228 * When we journal data on quota file, we have to flush journal to see
3229 * all updates to the file when we bypass pagecache...
3230 */
3231 if (ext4_should_journal_data(nd.path.dentry->d_inode)) {
3232 /*
3233 * We don't need to lock updates but journal_flush() could
3234 * otherwise be livelocked...
3235 */
3236 jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal);
3237 jbd2_journal_flush(EXT4_SB(sb)->s_journal);
3238 jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal);
3239 }
3240
3173 path_put(&nd.path); 3241 path_put(&nd.path);
3174 return vfs_quota_on(sb, type, format_id, path, remount); 3242 return vfs_quota_on(sb, type, format_id, path, remount);
3175} 3243}
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 3fbc2c6c3d0e..ff08633f398e 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -1009,6 +1009,11 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
1009 i.value = NULL; 1009 i.value = NULL;
1010 error = ext4_xattr_block_set(handle, inode, &i, &bs); 1010 error = ext4_xattr_block_set(handle, inode, &i, &bs);
1011 } else if (error == -ENOSPC) { 1011 } else if (error == -ENOSPC) {
1012 if (EXT4_I(inode)->i_file_acl && !bs.s.base) {
1013 error = ext4_xattr_block_find(inode, &i, &bs);
1014 if (error)
1015 goto cleanup;
1016 }
1012 error = ext4_xattr_block_set(handle, inode, &i, &bs); 1017 error = ext4_xattr_block_set(handle, inode, &i, &bs);
1013 if (error) 1018 if (error)
1014 goto cleanup; 1019 goto cleanup;
diff --git a/fs/fat/file.c b/fs/fat/file.c
index 27cc1164ec36..771326b8047e 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -257,26 +257,34 @@ int fat_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
257} 257}
258EXPORT_SYMBOL_GPL(fat_getattr); 258EXPORT_SYMBOL_GPL(fat_getattr);
259 259
260static int fat_check_mode(const struct msdos_sb_info *sbi, struct inode *inode, 260static int fat_sanitize_mode(const struct msdos_sb_info *sbi,
261 mode_t mode) 261 struct inode *inode, umode_t *mode_ptr)
262{ 262{
263 mode_t mask, req = mode & ~S_IFMT; 263 mode_t mask, perm;
264 264
265 if (S_ISREG(mode)) 265 /*
266 * Note, the basic check is already done by a caller of
267 * (attr->ia_mode & ~MSDOS_VALID_MODE)
268 */
269
270 if (S_ISREG(inode->i_mode))
266 mask = sbi->options.fs_fmask; 271 mask = sbi->options.fs_fmask;
267 else 272 else
268 mask = sbi->options.fs_dmask; 273 mask = sbi->options.fs_dmask;
269 274
275 perm = *mode_ptr & ~(S_IFMT | mask);
276
270 /* 277 /*
271 * Of the r and x bits, all (subject to umask) must be present. Of the 278 * Of the r and x bits, all (subject to umask) must be present. Of the
272 * w bits, either all (subject to umask) or none must be present. 279 * w bits, either all (subject to umask) or none must be present.
273 */ 280 */
274 req &= ~mask; 281 if ((perm & (S_IRUGO | S_IXUGO)) != (inode->i_mode & (S_IRUGO|S_IXUGO)))
275 if ((req & (S_IRUGO | S_IXUGO)) != (inode->i_mode & (S_IRUGO|S_IXUGO)))
276 return -EPERM; 282 return -EPERM;
277 if ((req & S_IWUGO) && ((req & S_IWUGO) != (S_IWUGO & ~mask))) 283 if ((perm & S_IWUGO) && ((perm & S_IWUGO) != (S_IWUGO & ~mask)))
278 return -EPERM; 284 return -EPERM;
279 285
286 *mode_ptr &= S_IFMT | perm;
287
280 return 0; 288 return 0;
281} 289}
282 290
@@ -299,7 +307,7 @@ int fat_setattr(struct dentry *dentry, struct iattr *attr)
299{ 307{
300 struct msdos_sb_info *sbi = MSDOS_SB(dentry->d_sb); 308 struct msdos_sb_info *sbi = MSDOS_SB(dentry->d_sb);
301 struct inode *inode = dentry->d_inode; 309 struct inode *inode = dentry->d_inode;
302 int mask, error = 0; 310 int error = 0;
303 unsigned int ia_valid; 311 unsigned int ia_valid;
304 312
305 lock_kernel(); 313 lock_kernel();
@@ -332,12 +340,13 @@ int fat_setattr(struct dentry *dentry, struct iattr *attr)
332 error = 0; 340 error = 0;
333 goto out; 341 goto out;
334 } 342 }
343
335 if (((attr->ia_valid & ATTR_UID) && 344 if (((attr->ia_valid & ATTR_UID) &&
336 (attr->ia_uid != sbi->options.fs_uid)) || 345 (attr->ia_uid != sbi->options.fs_uid)) ||
337 ((attr->ia_valid & ATTR_GID) && 346 ((attr->ia_valid & ATTR_GID) &&
338 (attr->ia_gid != sbi->options.fs_gid)) || 347 (attr->ia_gid != sbi->options.fs_gid)) ||
339 ((attr->ia_valid & ATTR_MODE) && 348 ((attr->ia_valid & ATTR_MODE) &&
340 fat_check_mode(sbi, inode, attr->ia_mode) < 0)) 349 (attr->ia_mode & ~MSDOS_VALID_MODE)))
341 error = -EPERM; 350 error = -EPERM;
342 351
343 if (error) { 352 if (error) {
@@ -346,15 +355,16 @@ int fat_setattr(struct dentry *dentry, struct iattr *attr)
346 goto out; 355 goto out;
347 } 356 }
348 357
349 error = inode_setattr(inode, attr); 358 /*
350 if (error) 359 * We don't return -EPERM here. Yes, strange, but this is too
351 goto out; 360 * old behavior.
361 */
362 if (attr->ia_valid & ATTR_MODE) {
363 if (fat_sanitize_mode(sbi, inode, &attr->ia_mode) < 0)
364 attr->ia_valid &= ~ATTR_MODE;
365 }
352 366
353 if (S_ISDIR(inode->i_mode)) 367 error = inode_setattr(inode, attr);
354 mask = sbi->options.fs_dmask;
355 else
356 mask = sbi->options.fs_fmask;
357 inode->i_mode &= S_IFMT | (S_IRWXUGO & ~mask);
358out: 368out:
359 unlock_kernel(); 369 unlock_kernel();
360 return error; 370 return error;
diff --git a/fs/file.c b/fs/file.c
index 4c6f0ea12c41..7b3887e054d0 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -26,6 +26,8 @@ struct fdtable_defer {
26}; 26};
27 27
28int sysctl_nr_open __read_mostly = 1024*1024; 28int sysctl_nr_open __read_mostly = 1024*1024;
29int sysctl_nr_open_min = BITS_PER_LONG;
30int sysctl_nr_open_max = 1024 * 1024; /* raised later */
29 31
30/* 32/*
31 * We use this list to defer free fdtables that have vmalloced 33 * We use this list to defer free fdtables that have vmalloced
@@ -119,8 +121,6 @@ static void copy_fdtable(struct fdtable *nfdt, struct fdtable *ofdt)
119 unsigned int cpy, set; 121 unsigned int cpy, set;
120 122
121 BUG_ON(nfdt->max_fds < ofdt->max_fds); 123 BUG_ON(nfdt->max_fds < ofdt->max_fds);
122 if (ofdt->max_fds == 0)
123 return;
124 124
125 cpy = ofdt->max_fds * sizeof(struct file *); 125 cpy = ofdt->max_fds * sizeof(struct file *);
126 set = (nfdt->max_fds - ofdt->max_fds) * sizeof(struct file *); 126 set = (nfdt->max_fds - ofdt->max_fds) * sizeof(struct file *);
@@ -261,6 +261,139 @@ int expand_files(struct files_struct *files, int nr)
261 return expand_fdtable(files, nr); 261 return expand_fdtable(files, nr);
262} 262}
263 263
264static int count_open_files(struct fdtable *fdt)
265{
266 int size = fdt->max_fds;
267 int i;
268
269 /* Find the last open fd */
270 for (i = size/(8*sizeof(long)); i > 0; ) {
271 if (fdt->open_fds->fds_bits[--i])
272 break;
273 }
274 i = (i+1) * 8 * sizeof(long);
275 return i;
276}
277
278/*
279 * Allocate a new files structure and copy contents from the
280 * passed in files structure.
281 * errorp will be valid only when the returned files_struct is NULL.
282 */
283struct files_struct *dup_fd(struct files_struct *oldf, int *errorp)
284{
285 struct files_struct *newf;
286 struct file **old_fds, **new_fds;
287 int open_files, size, i;
288 struct fdtable *old_fdt, *new_fdt;
289
290 *errorp = -ENOMEM;
291 newf = kmem_cache_alloc(files_cachep, GFP_KERNEL);
292 if (!newf)
293 goto out;
294
295 atomic_set(&newf->count, 1);
296
297 spin_lock_init(&newf->file_lock);
298 newf->next_fd = 0;
299 new_fdt = &newf->fdtab;
300 new_fdt->max_fds = NR_OPEN_DEFAULT;
301 new_fdt->close_on_exec = (fd_set *)&newf->close_on_exec_init;
302 new_fdt->open_fds = (fd_set *)&newf->open_fds_init;
303 new_fdt->fd = &newf->fd_array[0];
304 INIT_RCU_HEAD(&new_fdt->rcu);
305 new_fdt->next = NULL;
306
307 spin_lock(&oldf->file_lock);
308 old_fdt = files_fdtable(oldf);
309 open_files = count_open_files(old_fdt);
310
311 /*
312 * Check whether we need to allocate a larger fd array and fd set.
313 */
314 while (unlikely(open_files > new_fdt->max_fds)) {
315 spin_unlock(&oldf->file_lock);
316
317 if (new_fdt != &newf->fdtab) {
318 free_fdarr(new_fdt);
319 free_fdset(new_fdt);
320 kfree(new_fdt);
321 }
322
323 new_fdt = alloc_fdtable(open_files - 1);
324 if (!new_fdt) {
325 *errorp = -ENOMEM;
326 goto out_release;
327 }
328
329 /* beyond sysctl_nr_open; nothing to do */
330 if (unlikely(new_fdt->max_fds < open_files)) {
331 free_fdarr(new_fdt);
332 free_fdset(new_fdt);
333 kfree(new_fdt);
334 *errorp = -EMFILE;
335 goto out_release;
336 }
337
338 /*
339 * Reacquire the oldf lock and a pointer to its fd table
340 * who knows it may have a new bigger fd table. We need
341 * the latest pointer.
342 */
343 spin_lock(&oldf->file_lock);
344 old_fdt = files_fdtable(oldf);
345 open_files = count_open_files(old_fdt);
346 }
347
348 old_fds = old_fdt->fd;
349 new_fds = new_fdt->fd;
350
351 memcpy(new_fdt->open_fds->fds_bits,
352 old_fdt->open_fds->fds_bits, open_files/8);
353 memcpy(new_fdt->close_on_exec->fds_bits,
354 old_fdt->close_on_exec->fds_bits, open_files/8);
355
356 for (i = open_files; i != 0; i--) {
357 struct file *f = *old_fds++;
358 if (f) {
359 get_file(f);
360 } else {
361 /*
362 * The fd may be claimed in the fd bitmap but not yet
363 * instantiated in the files array if a sibling thread
364 * is partway through open(). So make sure that this
365 * fd is available to the new process.
366 */
367 FD_CLR(open_files - i, new_fdt->open_fds);
368 }
369 rcu_assign_pointer(*new_fds++, f);
370 }
371 spin_unlock(&oldf->file_lock);
372
373 /* compute the remainder to be cleared */
374 size = (new_fdt->max_fds - open_files) * sizeof(struct file *);
375
376 /* This is long word aligned thus could use a optimized version */
377 memset(new_fds, 0, size);
378
379 if (new_fdt->max_fds > open_files) {
380 int left = (new_fdt->max_fds-open_files)/8;
381 int start = open_files / (8 * sizeof(unsigned long));
382
383 memset(&new_fdt->open_fds->fds_bits[start], 0, left);
384 memset(&new_fdt->close_on_exec->fds_bits[start], 0, left);
385 }
386
387 rcu_assign_pointer(newf->fdt, new_fdt);
388
389 return newf;
390
391out_release:
392 kmem_cache_free(files_cachep, newf);
393out:
394 return NULL;
395}
396
264static void __devinit fdtable_defer_list_init(int cpu) 397static void __devinit fdtable_defer_list_init(int cpu)
265{ 398{
266 struct fdtable_defer *fddef = &per_cpu(fdtable_defer_list, cpu); 399 struct fdtable_defer *fddef = &per_cpu(fdtable_defer_list, cpu);
@@ -274,4 +407,19 @@ void __init files_defer_init(void)
274 int i; 407 int i;
275 for_each_possible_cpu(i) 408 for_each_possible_cpu(i)
276 fdtable_defer_list_init(i); 409 fdtable_defer_list_init(i);
410 sysctl_nr_open_max = min((size_t)INT_MAX, ~(size_t)0/sizeof(void *)) &
411 -BITS_PER_LONG;
277} 412}
413
414struct files_struct init_files = {
415 .count = ATOMIC_INIT(1),
416 .fdt = &init_files.fdtab,
417 .fdtab = {
418 .max_fds = NR_OPEN_DEFAULT,
419 .fd = &init_files.fd_array[0],
420 .close_on_exec = (fd_set *)&init_files.close_on_exec_init,
421 .open_fds = (fd_set *)&init_files.open_fds_init,
422 .rcu = RCU_HEAD_INIT,
423 },
424 .file_lock = __SPIN_LOCK_UNLOCKED(init_task.file_lock),
425};
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index f28cf8b46f80..8092f0d9fd1f 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -804,6 +804,8 @@ static ssize_t fuse_fill_write_pages(struct fuse_req *req,
804 if (offset == PAGE_CACHE_SIZE) 804 if (offset == PAGE_CACHE_SIZE)
805 offset = 0; 805 offset = 0;
806 806
807 if (!fc->big_writes)
808 break;
807 } while (iov_iter_count(ii) && count < fc->max_write && 809 } while (iov_iter_count(ii) && count < fc->max_write &&
808 req->num_pages < FUSE_MAX_PAGES_PER_REQ && offset == 0); 810 req->num_pages < FUSE_MAX_PAGES_PER_REQ && offset == 0);
809 811
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index dadffa21a206..bae948657c4f 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -404,6 +404,9 @@ struct fuse_conn {
404 /** Is bmap not implemented by fs? */ 404 /** Is bmap not implemented by fs? */
405 unsigned no_bmap : 1; 405 unsigned no_bmap : 1;
406 406
407 /** Do multi-page cached writes */
408 unsigned big_writes : 1;
409
407 /** The number of requests waiting for completion */ 410 /** The number of requests waiting for completion */
408 atomic_t num_waiting; 411 atomic_t num_waiting;
409 412
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 79b615873838..43e99513334a 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -488,7 +488,12 @@ static struct fuse_conn *new_conn(struct super_block *sb)
488 err = bdi_init(&fc->bdi); 488 err = bdi_init(&fc->bdi);
489 if (err) 489 if (err)
490 goto error_kfree; 490 goto error_kfree;
491 err = bdi_register_dev(&fc->bdi, fc->dev); 491 if (sb->s_bdev) {
492 err = bdi_register(&fc->bdi, NULL, "%u:%u-fuseblk",
493 MAJOR(fc->dev), MINOR(fc->dev));
494 } else {
495 err = bdi_register_dev(&fc->bdi, fc->dev);
496 }
492 if (err) 497 if (err)
493 goto error_bdi_destroy; 498 goto error_bdi_destroy;
494 /* 499 /*
@@ -576,6 +581,8 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
576 fc->no_lock = 1; 581 fc->no_lock = 1;
577 if (arg->flags & FUSE_ATOMIC_O_TRUNC) 582 if (arg->flags & FUSE_ATOMIC_O_TRUNC)
578 fc->atomic_o_trunc = 1; 583 fc->atomic_o_trunc = 1;
584 if (arg->flags & FUSE_BIG_WRITES)
585 fc->big_writes = 1;
579 } else { 586 } else {
580 ra_pages = fc->max_read / PAGE_CACHE_SIZE; 587 ra_pages = fc->max_read / PAGE_CACHE_SIZE;
581 fc->no_lock = 1; 588 fc->no_lock = 1;
@@ -599,7 +606,8 @@ static void fuse_send_init(struct fuse_conn *fc, struct fuse_req *req)
599 arg->major = FUSE_KERNEL_VERSION; 606 arg->major = FUSE_KERNEL_VERSION;
600 arg->minor = FUSE_KERNEL_MINOR_VERSION; 607 arg->minor = FUSE_KERNEL_MINOR_VERSION;
601 arg->max_readahead = fc->bdi.ra_pages * PAGE_CACHE_SIZE; 608 arg->max_readahead = fc->bdi.ra_pages * PAGE_CACHE_SIZE;
602 arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC; 609 arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC |
610 FUSE_BIG_WRITES;
603 req->in.h.opcode = FUSE_INIT; 611 req->in.h.opcode = FUSE_INIT;
604 req->in.numargs = 1; 612 req->in.numargs = 1;
605 req->in.args[0].size = sizeof(*arg); 613 req->in.args[0].size = sizeof(*arg);
diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
index d31badadef8f..07d84d16cda4 100644
--- a/fs/gfs2/glops.c
+++ b/fs/gfs2/glops.c
@@ -249,7 +249,7 @@ static int inode_go_lock(struct gfs2_holder *gh)
249 struct gfs2_inode *ip = gl->gl_object; 249 struct gfs2_inode *ip = gl->gl_object;
250 int error = 0; 250 int error = 0;
251 251
252 if (!ip) 252 if (!ip || (gh->gh_flags & GL_SKIP))
253 return 0; 253 return 0;
254 254
255 if (test_bit(GIF_INVALID, &ip->i_flags)) { 255 if (test_bit(GIF_INVALID, &ip->i_flags)) {
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index 9c2c0b90b22a..eabe5eac41da 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -236,6 +236,7 @@ enum {
236 GIF_INVALID = 0, 236 GIF_INVALID = 0,
237 GIF_QD_LOCKED = 1, 237 GIF_QD_LOCKED = 1,
238 GIF_SW_PAGED = 3, 238 GIF_SW_PAGED = 3,
239 GIF_USER = 4, /* user inode, not metadata addr space */
239}; 240};
240 241
241struct gfs2_dinode_host { 242struct gfs2_dinode_host {
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 3a9ef526c308..09453d057e41 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -47,8 +47,7 @@ static int iget_test(struct inode *inode, void *opaque)
47 struct gfs2_inode *ip = GFS2_I(inode); 47 struct gfs2_inode *ip = GFS2_I(inode);
48 u64 *no_addr = opaque; 48 u64 *no_addr = opaque;
49 49
50 if (ip->i_no_addr == *no_addr && 50 if (ip->i_no_addr == *no_addr && test_bit(GIF_USER, &ip->i_flags))
51 inode->i_private != NULL)
52 return 1; 51 return 1;
53 52
54 return 0; 53 return 0;
@@ -61,6 +60,7 @@ static int iget_set(struct inode *inode, void *opaque)
61 60
62 inode->i_ino = (unsigned long)*no_addr; 61 inode->i_ino = (unsigned long)*no_addr;
63 ip->i_no_addr = *no_addr; 62 ip->i_no_addr = *no_addr;
63 set_bit(GIF_USER, &ip->i_flags);
64 return 0; 64 return 0;
65} 65}
66 66
@@ -86,7 +86,7 @@ static int iget_skip_test(struct inode *inode, void *opaque)
86 struct gfs2_inode *ip = GFS2_I(inode); 86 struct gfs2_inode *ip = GFS2_I(inode);
87 struct gfs2_skip_data *data = opaque; 87 struct gfs2_skip_data *data = opaque;
88 88
89 if (ip->i_no_addr == data->no_addr && inode->i_private != NULL){ 89 if (ip->i_no_addr == data->no_addr && test_bit(GIF_USER, &ip->i_flags)){
90 if (inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE)){ 90 if (inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE)){
91 data->skipped = 1; 91 data->skipped = 1;
92 return 0; 92 return 0;
@@ -105,6 +105,7 @@ static int iget_skip_set(struct inode *inode, void *opaque)
105 return 1; 105 return 1;
106 inode->i_ino = (unsigned long)(data->no_addr); 106 inode->i_ino = (unsigned long)(data->no_addr);
107 ip->i_no_addr = data->no_addr; 107 ip->i_no_addr = data->no_addr;
108 set_bit(GIF_USER, &ip->i_flags);
108 return 0; 109 return 0;
109} 110}
110 111
@@ -166,7 +167,7 @@ void gfs2_set_iop(struct inode *inode)
166 * Returns: A VFS inode, or an error 167 * Returns: A VFS inode, or an error
167 */ 168 */
168 169
169struct inode *gfs2_inode_lookup(struct super_block *sb, 170struct inode *gfs2_inode_lookup(struct super_block *sb,
170 unsigned int type, 171 unsigned int type,
171 u64 no_addr, 172 u64 no_addr,
172 u64 no_formal_ino, int skip_freeing) 173 u64 no_formal_ino, int skip_freeing)
@@ -187,7 +188,6 @@ struct inode *gfs2_inode_lookup(struct super_block *sb,
187 188
188 if (inode->i_state & I_NEW) { 189 if (inode->i_state & I_NEW) {
189 struct gfs2_sbd *sdp = GFS2_SB(inode); 190 struct gfs2_sbd *sdp = GFS2_SB(inode);
190 inode->i_private = ip;
191 ip->i_no_formal_ino = no_formal_ino; 191 ip->i_no_formal_ino = no_formal_ino;
192 192
193 error = gfs2_glock_get(sdp, no_addr, &gfs2_inode_glops, CREATE, &ip->i_gl); 193 error = gfs2_glock_get(sdp, no_addr, &gfs2_inode_glops, CREATE, &ip->i_gl);
diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c
index 85aea27b4a86..78d75f892f82 100644
--- a/fs/gfs2/meta_io.c
+++ b/fs/gfs2/meta_io.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. 2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. 3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
4 * 4 *
5 * This copyrighted material is made available to anyone wishing to use, 5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions 6 * modify, copy, or redistribute it subject to the terms and conditions
@@ -69,13 +69,15 @@ static const struct address_space_operations aspace_aops = {
69struct inode *gfs2_aspace_get(struct gfs2_sbd *sdp) 69struct inode *gfs2_aspace_get(struct gfs2_sbd *sdp)
70{ 70{
71 struct inode *aspace; 71 struct inode *aspace;
72 struct gfs2_inode *ip;
72 73
73 aspace = new_inode(sdp->sd_vfs); 74 aspace = new_inode(sdp->sd_vfs);
74 if (aspace) { 75 if (aspace) {
75 mapping_set_gfp_mask(aspace->i_mapping, GFP_NOFS); 76 mapping_set_gfp_mask(aspace->i_mapping, GFP_NOFS);
76 aspace->i_mapping->a_ops = &aspace_aops; 77 aspace->i_mapping->a_ops = &aspace_aops;
77 aspace->i_size = ~0ULL; 78 aspace->i_size = ~0ULL;
78 aspace->i_private = NULL; 79 ip = GFS2_I(aspace);
80 clear_bit(GIF_USER, &ip->i_flags);
79 insert_inode_hash(aspace); 81 insert_inode_hash(aspace);
80 } 82 }
81 return aspace; 83 return aspace;
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index ef9c6c4f80f6..b2028c82e8d1 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -142,8 +142,8 @@ static int init_names(struct gfs2_sbd *sdp, int silent)
142 if (!table[0]) 142 if (!table[0])
143 table = sdp->sd_vfs->s_id; 143 table = sdp->sd_vfs->s_id;
144 144
145 snprintf(sdp->sd_proto_name, GFS2_FSNAME_LEN, "%s", proto); 145 strlcpy(sdp->sd_proto_name, proto, GFS2_FSNAME_LEN);
146 snprintf(sdp->sd_table_name, GFS2_FSNAME_LEN, "%s", table); 146 strlcpy(sdp->sd_table_name, table, GFS2_FSNAME_LEN);
147 147
148 table = sdp->sd_table_name; 148 table = sdp->sd_table_name;
149 while ((table = strchr(table, '/'))) 149 while ((table = strchr(table, '/')))
diff --git a/fs/gfs2/ops_super.c b/fs/gfs2/ops_super.c
index 2278c68b7e35..0b7cc920eb89 100644
--- a/fs/gfs2/ops_super.c
+++ b/fs/gfs2/ops_super.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. 2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. 3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
4 * 4 *
5 * This copyrighted material is made available to anyone wishing to use, 5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions 6 * modify, copy, or redistribute it subject to the terms and conditions
@@ -52,7 +52,7 @@ static int gfs2_write_inode(struct inode *inode, int sync)
52 struct gfs2_inode *ip = GFS2_I(inode); 52 struct gfs2_inode *ip = GFS2_I(inode);
53 53
54 /* Check this is a "normal" inode */ 54 /* Check this is a "normal" inode */
55 if (inode->i_private) { 55 if (test_bit(GIF_USER, &ip->i_flags)) {
56 if (current->flags & PF_MEMALLOC) 56 if (current->flags & PF_MEMALLOC)
57 return 0; 57 return 0;
58 if (sync) 58 if (sync)
@@ -297,8 +297,9 @@ static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data)
297 */ 297 */
298static void gfs2_drop_inode(struct inode *inode) 298static void gfs2_drop_inode(struct inode *inode)
299{ 299{
300 if (inode->i_private && inode->i_nlink) { 300 struct gfs2_inode *ip = GFS2_I(inode);
301 struct gfs2_inode *ip = GFS2_I(inode); 301
302 if (test_bit(GIF_USER, &ip->i_flags) && inode->i_nlink) {
302 struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl; 303 struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl;
303 if (gl && test_bit(GLF_DEMOTE, &gl->gl_flags)) 304 if (gl && test_bit(GLF_DEMOTE, &gl->gl_flags))
304 clear_nlink(inode); 305 clear_nlink(inode);
@@ -314,12 +315,13 @@ static void gfs2_drop_inode(struct inode *inode)
314 315
315static void gfs2_clear_inode(struct inode *inode) 316static void gfs2_clear_inode(struct inode *inode)
316{ 317{
318 struct gfs2_inode *ip = GFS2_I(inode);
319
317 /* This tells us its a "real" inode and not one which only 320 /* This tells us its a "real" inode and not one which only
318 * serves to contain an address space (see rgrp.c, meta_io.c) 321 * serves to contain an address space (see rgrp.c, meta_io.c)
319 * which therefore doesn't have its own glocks. 322 * which therefore doesn't have its own glocks.
320 */ 323 */
321 if (inode->i_private) { 324 if (test_bit(GIF_USER, &ip->i_flags)) {
322 struct gfs2_inode *ip = GFS2_I(inode);
323 ip->i_gl->gl_object = NULL; 325 ip->i_gl->gl_object = NULL;
324 gfs2_glock_schedule_for_reclaim(ip->i_gl); 326 gfs2_glock_schedule_for_reclaim(ip->i_gl);
325 gfs2_glock_put(ip->i_gl); 327 gfs2_glock_put(ip->i_gl);
@@ -419,7 +421,7 @@ static void gfs2_delete_inode(struct inode *inode)
419 struct gfs2_holder gh; 421 struct gfs2_holder gh;
420 int error; 422 int error;
421 423
422 if (!inode->i_private) 424 if (!test_bit(GIF_USER, &ip->i_flags))
423 goto out; 425 goto out;
424 426
425 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh); 427 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 7e8f0b1d6c6e..6387523a3153 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -1495,7 +1495,7 @@ u64 gfs2_alloc_block(struct gfs2_inode *ip, unsigned int *n)
1495 1495
1496 al->al_alloced += *n; 1496 al->al_alloced += *n;
1497 1497
1498 gfs2_statfs_change(sdp, 0, -*n, 0); 1498 gfs2_statfs_change(sdp, 0, -(s64)*n, 0);
1499 gfs2_quota_change(ip, *n, ip->i_inode.i_uid, ip->i_inode.i_gid); 1499 gfs2_quota_change(ip, *n, ip->i_inode.i_uid, ip->i_inode.i_gid);
1500 1500
1501 spin_lock(&sdp->sd_rindex_spin); 1501 spin_lock(&sdp->sd_rindex_spin);
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index d53b2af91c25..67e1c8b467c4 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -65,6 +65,8 @@ static int hfsplus_releasepage(struct page *page, gfp_t mask)
65 BUG(); 65 BUG();
66 return 0; 66 return 0;
67 } 67 }
68 if (!tree)
69 return 0;
68 if (tree->node_size >= PAGE_CACHE_SIZE) { 70 if (tree->node_size >= PAGE_CACHE_SIZE) {
69 nidx = page->index >> (tree->node_size_shift - PAGE_CACHE_SHIFT); 71 nidx = page->index >> (tree->node_size_shift - PAGE_CACHE_SHIFT);
70 spin_lock(&tree->hash_lock); 72 spin_lock(&tree->hash_lock);
diff --git a/fs/hppfs/Makefile b/fs/hppfs/Makefile
index 6890433f7595..3a982bd975d2 100644
--- a/fs/hppfs/Makefile
+++ b/fs/hppfs/Makefile
@@ -1,9 +1,6 @@
1# 1#
2# Copyright (C) 2002, 2003 Jeff Dike (jdike@karaya.com) 2# Copyright (C) 2002 - 2008 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3# Licensed under the GPL 3# Licensed under the GPL
4# 4#
5 5
6hppfs-objs := hppfs_kern.o
7
8obj-y =
9obj-$(CONFIG_HPPFS) += hppfs.o 6obj-$(CONFIG_HPPFS) += hppfs.o
diff --git a/fs/hppfs/hppfs_kern.c b/fs/hppfs/hppfs.c
index 8601d8ef3b55..65077aa90f0a 100644
--- a/fs/hppfs/hppfs_kern.c
+++ b/fs/hppfs/hppfs.c
@@ -33,7 +33,7 @@ struct hppfs_private {
33}; 33};
34 34
35struct hppfs_inode_info { 35struct hppfs_inode_info {
36 struct dentry *proc_dentry; 36 struct dentry *proc_dentry;
37 struct inode vfs_inode; 37 struct inode vfs_inode;
38}; 38};
39 39
@@ -52,7 +52,7 @@ static int is_pid(struct dentry *dentry)
52 int i; 52 int i;
53 53
54 sb = dentry->d_sb; 54 sb = dentry->d_sb;
55 if ((sb->s_op != &hppfs_sbops) || (dentry->d_parent != sb->s_root)) 55 if (dentry->d_parent != sb->s_root)
56 return 0; 56 return 0;
57 57
58 for (i = 0; i < dentry->d_name.len; i++) { 58 for (i = 0; i < dentry->d_name.len; i++) {
@@ -136,7 +136,7 @@ static int file_removed(struct dentry *dentry, const char *file)
136} 136}
137 137
138static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry, 138static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry,
139 struct nameidata *nd) 139 struct nameidata *nd)
140{ 140{
141 struct dentry *proc_dentry, *new, *parent; 141 struct dentry *proc_dentry, *new, *parent;
142 struct inode *inode; 142 struct inode *inode;
@@ -254,6 +254,8 @@ static ssize_t hppfs_read(struct file *file, char __user *buf, size_t count,
254 int err; 254 int err;
255 255
256 if (hppfs->contents != NULL) { 256 if (hppfs->contents != NULL) {
257 int rem;
258
257 if (*ppos >= hppfs->len) 259 if (*ppos >= hppfs->len)
258 return 0; 260 return 0;
259 261
@@ -267,8 +269,10 @@ static ssize_t hppfs_read(struct file *file, char __user *buf, size_t count,
267 269
268 if (off + count > hppfs->len) 270 if (off + count > hppfs->len)
269 count = hppfs->len - off; 271 count = hppfs->len - off;
270 copy_to_user(buf, &data->contents[off], count); 272 rem = copy_to_user(buf, &data->contents[off], count);
271 *ppos += count; 273 *ppos += count - rem;
274 if (rem > 0)
275 return -EFAULT;
272 } else if (hppfs->host_fd != -1) { 276 } else if (hppfs->host_fd != -1) {
273 err = os_seek_file(hppfs->host_fd, *ppos); 277 err = os_seek_file(hppfs->host_fd, *ppos);
274 if (err) { 278 if (err) {
@@ -285,21 +289,15 @@ static ssize_t hppfs_read(struct file *file, char __user *buf, size_t count,
285 return count; 289 return count;
286} 290}
287 291
288static ssize_t hppfs_write(struct file *file, const char __user *buf, size_t len, 292static ssize_t hppfs_write(struct file *file, const char __user *buf,
289 loff_t *ppos) 293 size_t len, loff_t *ppos)
290{ 294{
291 struct hppfs_private *data = file->private_data; 295 struct hppfs_private *data = file->private_data;
292 struct file *proc_file = data->proc_file; 296 struct file *proc_file = data->proc_file;
293 ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *); 297 ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *);
294 int err;
295 298
296 write = proc_file->f_path.dentry->d_inode->i_fop->write; 299 write = proc_file->f_path.dentry->d_inode->i_fop->write;
297 300 return (*write)(proc_file, buf, len, ppos);
298 proc_file->f_pos = file->f_pos;
299 err = (*write)(proc_file, buf, len, &proc_file->f_pos);
300 file->f_pos = proc_file->f_pos;
301
302 return err;
303} 301}
304 302
305static int open_host_sock(char *host_file, int *filter_out) 303static int open_host_sock(char *host_file, int *filter_out)
@@ -357,7 +355,7 @@ static struct hppfs_data *hppfs_get_data(int fd, int filter,
357 355
358 if (filter) { 356 if (filter) {
359 while ((n = read_proc(proc_file, data->contents, 357 while ((n = read_proc(proc_file, data->contents,
360 sizeof(data->contents), NULL, 0)) > 0) 358 sizeof(data->contents), NULL, 0)) > 0)
361 os_write_file(fd, data->contents, n); 359 os_write_file(fd, data->contents, n);
362 err = os_shutdown_socket(fd, 0, 1); 360 err = os_shutdown_socket(fd, 0, 1);
363 if (err) { 361 if (err) {
@@ -429,8 +427,8 @@ static int file_mode(int fmode)
429static int hppfs_open(struct inode *inode, struct file *file) 427static int hppfs_open(struct inode *inode, struct file *file)
430{ 428{
431 struct hppfs_private *data; 429 struct hppfs_private *data;
432 struct dentry *proc_dentry;
433 struct vfsmount *proc_mnt; 430 struct vfsmount *proc_mnt;
431 struct dentry *proc_dentry;
434 char *host_file; 432 char *host_file;
435 int err, fd, type, filter; 433 int err, fd, type, filter;
436 434
@@ -492,8 +490,8 @@ static int hppfs_open(struct inode *inode, struct file *file)
492static int hppfs_dir_open(struct inode *inode, struct file *file) 490static int hppfs_dir_open(struct inode *inode, struct file *file)
493{ 491{
494 struct hppfs_private *data; 492 struct hppfs_private *data;
495 struct dentry *proc_dentry;
496 struct vfsmount *proc_mnt; 493 struct vfsmount *proc_mnt;
494 struct dentry *proc_dentry;
497 int err; 495 int err;
498 496
499 err = -ENOMEM; 497 err = -ENOMEM;
@@ -620,6 +618,9 @@ static struct inode *hppfs_alloc_inode(struct super_block *sb)
620 618
621void hppfs_delete_inode(struct inode *ino) 619void hppfs_delete_inode(struct inode *ino)
622{ 620{
621 dput(HPPFS_I(ino)->proc_dentry);
622 mntput(ino->i_sb->s_fs_info);
623
623 clear_inode(ino); 624 clear_inode(ino);
624} 625}
625 626
@@ -628,69 +629,46 @@ static void hppfs_destroy_inode(struct inode *inode)
628 kfree(HPPFS_I(inode)); 629 kfree(HPPFS_I(inode));
629} 630}
630 631
631static void hppfs_put_super(struct super_block *sb)
632{
633 mntput(sb->s_fs_info);
634}
635
636static const struct super_operations hppfs_sbops = { 632static const struct super_operations hppfs_sbops = {
637 .alloc_inode = hppfs_alloc_inode, 633 .alloc_inode = hppfs_alloc_inode,
638 .destroy_inode = hppfs_destroy_inode, 634 .destroy_inode = hppfs_destroy_inode,
639 .delete_inode = hppfs_delete_inode, 635 .delete_inode = hppfs_delete_inode,
640 .statfs = hppfs_statfs, 636 .statfs = hppfs_statfs,
641 .put_super = hppfs_put_super,
642}; 637};
643 638
644static int hppfs_readlink(struct dentry *dentry, char __user *buffer, 639static int hppfs_readlink(struct dentry *dentry, char __user *buffer,
645 int buflen) 640 int buflen)
646{ 641{
647 struct file *proc_file;
648 struct dentry *proc_dentry; 642 struct dentry *proc_dentry;
649 struct vfsmount *proc_mnt;
650 int ret;
651 643
652 proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry; 644 proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry;
653 proc_mnt = dentry->d_sb->s_fs_info; 645 return proc_dentry->d_inode->i_op->readlink(proc_dentry, buffer,
654 646 buflen);
655 proc_file = dentry_open(dget(proc_dentry), mntget(proc_mnt), O_RDONLY);
656 if (IS_ERR(proc_file))
657 return PTR_ERR(proc_file);
658
659 ret = proc_dentry->d_inode->i_op->readlink(proc_dentry, buffer, buflen);
660
661 fput(proc_file);
662
663 return ret;
664} 647}
665 648
666static void* hppfs_follow_link(struct dentry *dentry, struct nameidata *nd) 649static void *hppfs_follow_link(struct dentry *dentry, struct nameidata *nd)
667{ 650{
668 struct file *proc_file;
669 struct dentry *proc_dentry; 651 struct dentry *proc_dentry;
670 struct vfsmount *proc_mnt;
671 void *ret;
672 652
673 proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry; 653 proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry;
674 proc_mnt = dentry->d_sb->s_fs_info;
675
676 proc_file = dentry_open(dget(proc_dentry), mntget(proc_mnt), O_RDONLY);
677 if (IS_ERR(proc_file))
678 return proc_file;
679
680 ret = proc_dentry->d_inode->i_op->follow_link(proc_dentry, nd);
681 654
682 fput(proc_file); 655 return proc_dentry->d_inode->i_op->follow_link(proc_dentry, nd);
656}
683 657
684 return ret; 658int hppfs_permission(struct inode *inode, int mask, struct nameidata *nd)
659{
660 return generic_permission(inode, mask, NULL);
685} 661}
686 662
687static const struct inode_operations hppfs_dir_iops = { 663static const struct inode_operations hppfs_dir_iops = {
688 .lookup = hppfs_lookup, 664 .lookup = hppfs_lookup,
665 .permission = hppfs_permission,
689}; 666};
690 667
691static const struct inode_operations hppfs_link_iops = { 668static const struct inode_operations hppfs_link_iops = {
692 .readlink = hppfs_readlink, 669 .readlink = hppfs_readlink,
693 .follow_link = hppfs_follow_link, 670 .follow_link = hppfs_follow_link,
671 .permission = hppfs_permission,
694}; 672};
695 673
696static struct inode *get_inode(struct super_block *sb, struct dentry *dentry) 674static struct inode *get_inode(struct super_block *sb, struct dentry *dentry)
@@ -712,7 +690,7 @@ static struct inode *get_inode(struct super_block *sb, struct dentry *dentry)
712 inode->i_fop = &hppfs_file_fops; 690 inode->i_fop = &hppfs_file_fops;
713 } 691 }
714 692
715 HPPFS_I(inode)->proc_dentry = dentry; 693 HPPFS_I(inode)->proc_dentry = dget(dentry);
716 694
717 inode->i_uid = proc_ino->i_uid; 695 inode->i_uid = proc_ino->i_uid;
718 inode->i_gid = proc_ino->i_gid; 696 inode->i_gid = proc_ino->i_gid;
@@ -725,7 +703,7 @@ static struct inode *get_inode(struct super_block *sb, struct dentry *dentry)
725 inode->i_size = proc_ino->i_size; 703 inode->i_size = proc_ino->i_size;
726 inode->i_blocks = proc_ino->i_blocks; 704 inode->i_blocks = proc_ino->i_blocks;
727 705
728 return 0; 706 return inode;
729} 707}
730 708
731static int hppfs_fill_super(struct super_block *sb, void *d, int silent) 709static int hppfs_fill_super(struct super_block *sb, void *d, int silent)
diff --git a/fs/jbd/commit.c b/fs/jbd/commit.c
index cd931ef1f000..5a8ca61498ca 100644
--- a/fs/jbd/commit.c
+++ b/fs/jbd/commit.c
@@ -470,7 +470,9 @@ void journal_commit_transaction(journal_t *journal)
470 * transaction! Now comes the tricky part: we need to write out 470 * transaction! Now comes the tricky part: we need to write out
471 * metadata. Loop over the transaction's entire buffer list: 471 * metadata. Loop over the transaction's entire buffer list:
472 */ 472 */
473 spin_lock(&journal->j_state_lock);
473 commit_transaction->t_state = T_COMMIT; 474 commit_transaction->t_state = T_COMMIT;
475 spin_unlock(&journal->j_state_lock);
474 476
475 J_ASSERT(commit_transaction->t_nr_buffers <= 477 J_ASSERT(commit_transaction->t_nr_buffers <=
476 commit_transaction->t_outstanding_credits); 478 commit_transaction->t_outstanding_credits);
diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
index e0139786f717..a2ed72f7ceee 100644
--- a/fs/jbd2/commit.c
+++ b/fs/jbd2/commit.c
@@ -168,6 +168,7 @@ static int journal_submit_commit_record(journal_t *journal,
168 spin_unlock(&journal->j_state_lock); 168 spin_unlock(&journal->j_state_lock);
169 169
170 /* And try again, without the barrier */ 170 /* And try again, without the barrier */
171 lock_buffer(bh);
171 set_buffer_uptodate(bh); 172 set_buffer_uptodate(bh);
172 set_buffer_dirty(bh); 173 set_buffer_dirty(bh);
173 ret = submit_bh(WRITE, bh); 174 ret = submit_bh(WRITE, bh);
@@ -560,7 +561,9 @@ void jbd2_journal_commit_transaction(journal_t *journal)
560 * transaction! Now comes the tricky part: we need to write out 561 * transaction! Now comes the tricky part: we need to write out
561 * metadata. Loop over the transaction's entire buffer list: 562 * metadata. Loop over the transaction's entire buffer list:
562 */ 563 */
564 spin_lock(&journal->j_state_lock);
563 commit_transaction->t_state = T_COMMIT; 565 commit_transaction->t_state = T_COMMIT;
566 spin_unlock(&journal->j_state_lock);
564 567
565 stats.u.run.rs_logging = jiffies; 568 stats.u.run.rs_logging = jiffies;
566 stats.u.run.rs_flushing = jbd2_time_diff(stats.u.run.rs_flushing, 569 stats.u.run.rs_flushing = jbd2_time_diff(stats.u.run.rs_flushing,
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 53632e3e8457..2e24567c4a79 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -901,7 +901,7 @@ static void jbd2_stats_proc_init(journal_t *journal)
901{ 901{
902 char name[BDEVNAME_SIZE]; 902 char name[BDEVNAME_SIZE];
903 903
904 snprintf(name, sizeof(name) - 1, "%s", bdevname(journal->j_dev, name)); 904 bdevname(journal->j_dev, name);
905 journal->j_proc_entry = proc_mkdir(name, proc_jbd2_stats); 905 journal->j_proc_entry = proc_mkdir(name, proc_jbd2_stats);
906 if (journal->j_proc_entry) { 906 if (journal->j_proc_entry) {
907 proc_create_data("history", S_IRUGO, journal->j_proc_entry, 907 proc_create_data("history", S_IRUGO, journal->j_proc_entry,
@@ -915,7 +915,7 @@ static void jbd2_stats_proc_exit(journal_t *journal)
915{ 915{
916 char name[BDEVNAME_SIZE]; 916 char name[BDEVNAME_SIZE];
917 917
918 snprintf(name, sizeof(name) - 1, "%s", bdevname(journal->j_dev, name)); 918 bdevname(journal->j_dev, name);
919 remove_proc_entry("info", journal->j_proc_entry); 919 remove_proc_entry("info", journal->j_proc_entry);
920 remove_proc_entry("history", journal->j_proc_entry); 920 remove_proc_entry("history", journal->j_proc_entry);
921 remove_proc_entry(name, proc_jbd2_stats); 921 remove_proc_entry(name, proc_jbd2_stats);
diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c
index 5d0405a9e7ca..058f50f65b76 100644
--- a/fs/jbd2/recovery.c
+++ b/fs/jbd2/recovery.c
@@ -344,6 +344,7 @@ static int calc_chksums(journal_t *journal, struct buffer_head *bh,
344 *crc32_sum = crc32_be(*crc32_sum, (void *)obh->b_data, 344 *crc32_sum = crc32_be(*crc32_sum, (void *)obh->b_data,
345 obh->b_size); 345 obh->b_size);
346 } 346 }
347 put_bh(obh);
347 } 348 }
348 return 0; 349 return 0;
349} 350}
@@ -610,9 +611,8 @@ static int do_one_pass(journal_t *journal,
610 chksum_err = chksum_seen = 0; 611 chksum_err = chksum_seen = 0;
611 612
612 if (info->end_transaction) { 613 if (info->end_transaction) {
613 printk(KERN_ERR "JBD: Transaction %u " 614 journal->j_failed_commit =
614 "found to be corrupt.\n", 615 info->end_transaction;
615 next_commit_ID - 1);
616 brelse(bh); 616 brelse(bh);
617 break; 617 break;
618 } 618 }
@@ -643,10 +643,8 @@ static int do_one_pass(journal_t *journal,
643 643
644 if (!JBD2_HAS_INCOMPAT_FEATURE(journal, 644 if (!JBD2_HAS_INCOMPAT_FEATURE(journal,
645 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT)){ 645 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT)){
646 printk(KERN_ERR 646 journal->j_failed_commit =
647 "JBD: Transaction %u " 647 next_commit_ID;
648 "found to be corrupt.\n",
649 next_commit_ID);
650 brelse(bh); 648 brelse(bh);
651 break; 649 break;
652 } 650 }
diff --git a/fs/libfs.c b/fs/libfs.c
index b004dfadd891..892d41cb3382 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -528,6 +528,23 @@ ssize_t simple_read_from_buffer(void __user *to, size_t count, loff_t *ppos,
528 return count; 528 return count;
529} 529}
530 530
531ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos,
532 const void *from, size_t available)
533{
534 loff_t pos = *ppos;
535
536 if (pos < 0)
537 return -EINVAL;
538 if (pos >= available)
539 return 0;
540 if (count > available - pos)
541 count = available - pos;
542 memcpy(to, from + pos, count);
543 *ppos = pos + count;
544
545 return count;
546}
547
531/* 548/*
532 * Transaction based IO. 549 * Transaction based IO.
533 * The file expects a single write which triggers the transaction, and then 550 * The file expects a single write which triggers the transaction, and then
@@ -800,6 +817,7 @@ EXPORT_SYMBOL(simple_statfs);
800EXPORT_SYMBOL(simple_sync_file); 817EXPORT_SYMBOL(simple_sync_file);
801EXPORT_SYMBOL(simple_unlink); 818EXPORT_SYMBOL(simple_unlink);
802EXPORT_SYMBOL(simple_read_from_buffer); 819EXPORT_SYMBOL(simple_read_from_buffer);
820EXPORT_SYMBOL(memory_read_from_buffer);
803EXPORT_SYMBOL(simple_transaction_get); 821EXPORT_SYMBOL(simple_transaction_get);
804EXPORT_SYMBOL(simple_transaction_read); 822EXPORT_SYMBOL(simple_transaction_read);
805EXPORT_SYMBOL(simple_transaction_release); 823EXPORT_SYMBOL(simple_transaction_release);
diff --git a/fs/namei.c b/fs/namei.c
index 32fd9655485b..c7e43536c49a 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2003,18 +2003,22 @@ struct dentry *lookup_create(struct nameidata *nd, int is_dir)
2003 if (IS_ERR(dentry)) 2003 if (IS_ERR(dentry))
2004 goto fail; 2004 goto fail;
2005 2005
2006 if (dentry->d_inode)
2007 goto eexist;
2006 /* 2008 /*
2007 * Special case - lookup gave negative, but... we had foo/bar/ 2009 * Special case - lookup gave negative, but... we had foo/bar/
2008 * From the vfs_mknod() POV we just have a negative dentry - 2010 * From the vfs_mknod() POV we just have a negative dentry -
2009 * all is fine. Let's be bastards - you had / on the end, you've 2011 * all is fine. Let's be bastards - you had / on the end, you've
2010 * been asking for (non-existent) directory. -ENOENT for you. 2012 * been asking for (non-existent) directory. -ENOENT for you.
2011 */ 2013 */
2012 if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode) 2014 if (unlikely(!is_dir && nd->last.name[nd->last.len])) {
2013 goto enoent; 2015 dput(dentry);
2016 dentry = ERR_PTR(-ENOENT);
2017 }
2014 return dentry; 2018 return dentry;
2015enoent: 2019eexist:
2016 dput(dentry); 2020 dput(dentry);
2017 dentry = ERR_PTR(-ENOENT); 2021 dentry = ERR_PTR(-EEXIST);
2018fail: 2022fail:
2019 return dentry; 2023 return dentry;
2020} 2024}
diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
index 5606ae3d72d3..c1e7c8300629 100644
--- a/fs/nfs/callback.c
+++ b/fs/nfs/callback.c
@@ -182,7 +182,7 @@ static int nfs_callback_authenticate(struct svc_rqst *rqstp)
182 if (clp == NULL) 182 if (clp == NULL)
183 return SVC_DROP; 183 return SVC_DROP;
184 184
185 dprintk("%s: %s NFSv4 callback!\n", __FUNCTION__, 185 dprintk("%s: %s NFSv4 callback!\n", __func__,
186 svc_print_addr(rqstp, buf, sizeof(buf))); 186 svc_print_addr(rqstp, buf, sizeof(buf)));
187 nfs_put_client(clp); 187 nfs_put_client(clp);
188 188
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index 15f7785048d3..f7e83e23cf9f 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -57,7 +57,7 @@ out_iput:
57out_putclient: 57out_putclient:
58 nfs_put_client(clp); 58 nfs_put_client(clp);
59out: 59out:
60 dprintk("%s: exit with status = %d\n", __FUNCTION__, ntohl(res->status)); 60 dprintk("%s: exit with status = %d\n", __func__, ntohl(res->status));
61 return res->status; 61 return res->status;
62} 62}
63 63
@@ -98,6 +98,6 @@ __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy)
98 nfs_put_client(prev); 98 nfs_put_client(prev);
99 } while (clp != NULL); 99 } while (clp != NULL);
100out: 100out:
101 dprintk("%s: exit with status = %d\n", __FUNCTION__, ntohl(res)); 101 dprintk("%s: exit with status = %d\n", __func__, ntohl(res));
102 return res; 102 return res;
103} 103}
diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
index 13619d24f023..dd0ef34b5845 100644
--- a/fs/nfs/callback_xdr.c
+++ b/fs/nfs/callback_xdr.c
@@ -141,7 +141,7 @@ static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound
141 /* We do not like overly long tags! */ 141 /* We do not like overly long tags! */
142 if (hdr->taglen > CB_OP_TAGLEN_MAXSZ - 12) { 142 if (hdr->taglen > CB_OP_TAGLEN_MAXSZ - 12) {
143 printk("NFSv4 CALLBACK %s: client sent tag of length %u\n", 143 printk("NFSv4 CALLBACK %s: client sent tag of length %u\n",
144 __FUNCTION__, hdr->taglen); 144 __func__, hdr->taglen);
145 return htonl(NFS4ERR_RESOURCE); 145 return htonl(NFS4ERR_RESOURCE);
146 } 146 }
147 p = read_buf(xdr, 12); 147 p = read_buf(xdr, 12);
@@ -151,7 +151,7 @@ static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound
151 /* Check minor version is zero. */ 151 /* Check minor version is zero. */
152 if (minor_version != 0) { 152 if (minor_version != 0) {
153 printk(KERN_WARNING "%s: NFSv4 server callback with illegal minor version %u!\n", 153 printk(KERN_WARNING "%s: NFSv4 server callback with illegal minor version %u!\n",
154 __FUNCTION__, minor_version); 154 __func__, minor_version);
155 return htonl(NFS4ERR_MINOR_VERS_MISMATCH); 155 return htonl(NFS4ERR_MINOR_VERS_MISMATCH);
156 } 156 }
157 hdr->callback_ident = ntohl(*p++); 157 hdr->callback_ident = ntohl(*p++);
@@ -179,7 +179,7 @@ static __be32 decode_getattr_args(struct svc_rqst *rqstp, struct xdr_stream *xdr
179 args->addr = svc_addr(rqstp); 179 args->addr = svc_addr(rqstp);
180 status = decode_bitmap(xdr, args->bitmap); 180 status = decode_bitmap(xdr, args->bitmap);
181out: 181out:
182 dprintk("%s: exit with status = %d\n", __FUNCTION__, ntohl(status)); 182 dprintk("%s: exit with status = %d\n", __func__, ntohl(status));
183 return status; 183 return status;
184} 184}
185 185
@@ -200,7 +200,7 @@ static __be32 decode_recall_args(struct svc_rqst *rqstp, struct xdr_stream *xdr,
200 args->truncate = ntohl(*p); 200 args->truncate = ntohl(*p);
201 status = decode_fh(xdr, &args->fh); 201 status = decode_fh(xdr, &args->fh);
202out: 202out:
203 dprintk("%s: exit with status = %d\n", __FUNCTION__, ntohl(status)); 203 dprintk("%s: exit with status = %d\n", __func__, ntohl(status));
204 return status; 204 return status;
205} 205}
206 206
@@ -349,7 +349,7 @@ static __be32 encode_getattr_res(struct svc_rqst *rqstp, struct xdr_stream *xdr,
349 status = encode_attr_mtime(xdr, res->bitmap, &res->mtime); 349 status = encode_attr_mtime(xdr, res->bitmap, &res->mtime);
350 *savep = htonl((unsigned int)((char *)xdr->p - (char *)(savep+1))); 350 *savep = htonl((unsigned int)((char *)xdr->p - (char *)(savep+1)));
351out: 351out:
352 dprintk("%s: exit with status = %d\n", __FUNCTION__, ntohl(status)); 352 dprintk("%s: exit with status = %d\n", __func__, ntohl(status));
353 return status; 353 return status;
354} 354}
355 355
@@ -363,7 +363,7 @@ static __be32 process_op(struct svc_rqst *rqstp,
363 long maxlen; 363 long maxlen;
364 __be32 res; 364 __be32 res;
365 365
366 dprintk("%s: start\n", __FUNCTION__); 366 dprintk("%s: start\n", __func__);
367 status = decode_op_hdr(xdr_in, &op_nr); 367 status = decode_op_hdr(xdr_in, &op_nr);
368 if (likely(status == 0)) { 368 if (likely(status == 0)) {
369 switch (op_nr) { 369 switch (op_nr) {
@@ -392,7 +392,7 @@ static __be32 process_op(struct svc_rqst *rqstp,
392 status = res; 392 status = res;
393 if (op->encode_res != NULL && status == 0) 393 if (op->encode_res != NULL && status == 0)
394 status = op->encode_res(rqstp, xdr_out, resp); 394 status = op->encode_res(rqstp, xdr_out, resp);
395 dprintk("%s: done, status = %d\n", __FUNCTION__, ntohl(status)); 395 dprintk("%s: done, status = %d\n", __func__, ntohl(status));
396 return status; 396 return status;
397} 397}
398 398
@@ -401,37 +401,37 @@ static __be32 process_op(struct svc_rqst *rqstp,
401 */ 401 */
402static __be32 nfs4_callback_compound(struct svc_rqst *rqstp, void *argp, void *resp) 402static __be32 nfs4_callback_compound(struct svc_rqst *rqstp, void *argp, void *resp)
403{ 403{
404 struct cb_compound_hdr_arg hdr_arg; 404 struct cb_compound_hdr_arg hdr_arg = { 0 };
405 struct cb_compound_hdr_res hdr_res; 405 struct cb_compound_hdr_res hdr_res = { NULL };
406 struct xdr_stream xdr_in, xdr_out; 406 struct xdr_stream xdr_in, xdr_out;
407 __be32 *p; 407 __be32 *p;
408 __be32 status; 408 __be32 status;
409 unsigned int nops = 1; 409 unsigned int nops = 0;
410 410
411 dprintk("%s: start\n", __FUNCTION__); 411 dprintk("%s: start\n", __func__);
412 412
413 xdr_init_decode(&xdr_in, &rqstp->rq_arg, rqstp->rq_arg.head[0].iov_base); 413 xdr_init_decode(&xdr_in, &rqstp->rq_arg, rqstp->rq_arg.head[0].iov_base);
414 414
415 p = (__be32*)((char *)rqstp->rq_res.head[0].iov_base + rqstp->rq_res.head[0].iov_len); 415 p = (__be32*)((char *)rqstp->rq_res.head[0].iov_base + rqstp->rq_res.head[0].iov_len);
416 xdr_init_encode(&xdr_out, &rqstp->rq_res, p); 416 xdr_init_encode(&xdr_out, &rqstp->rq_res, p);
417 417
418 decode_compound_hdr_arg(&xdr_in, &hdr_arg); 418 status = decode_compound_hdr_arg(&xdr_in, &hdr_arg);
419 if (status == __constant_htonl(NFS4ERR_RESOURCE))
420 return rpc_garbage_args;
421
419 hdr_res.taglen = hdr_arg.taglen; 422 hdr_res.taglen = hdr_arg.taglen;
420 hdr_res.tag = hdr_arg.tag; 423 hdr_res.tag = hdr_arg.tag;
421 hdr_res.nops = NULL; 424 if (encode_compound_hdr_res(&xdr_out, &hdr_res) != 0)
422 encode_compound_hdr_res(&xdr_out, &hdr_res); 425 return rpc_system_err;
423 426
424 for (;;) { 427 while (status == 0 && nops != hdr_arg.nops) {
425 status = process_op(rqstp, &xdr_in, argp, &xdr_out, resp); 428 status = process_op(rqstp, &xdr_in, argp, &xdr_out, resp);
426 if (status != 0)
427 break;
428 if (nops == hdr_arg.nops)
429 break;
430 nops++; 429 nops++;
431 } 430 }
431
432 *hdr_res.status = status; 432 *hdr_res.status = status;
433 *hdr_res.nops = htonl(nops); 433 *hdr_res.nops = htonl(nops);
434 dprintk("%s: done, status = %u\n", __FUNCTION__, ntohl(status)); 434 dprintk("%s: done, status = %u\n", __func__, ntohl(status));
435 return rpc_success; 435 return rpc_success;
436} 436}
437 437
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 89ac5bb0401c..f2a092ca69b5 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -488,7 +488,7 @@ static int nfs_create_rpc_client(struct nfs_client *clp,
488 clnt = rpc_create(&args); 488 clnt = rpc_create(&args);
489 if (IS_ERR(clnt)) { 489 if (IS_ERR(clnt)) {
490 dprintk("%s: cannot create RPC client. Error = %ld\n", 490 dprintk("%s: cannot create RPC client. Error = %ld\n",
491 __FUNCTION__, PTR_ERR(clnt)); 491 __func__, PTR_ERR(clnt));
492 return PTR_ERR(clnt); 492 return PTR_ERR(clnt);
493 } 493 }
494 494
@@ -576,7 +576,7 @@ static int nfs_init_server_rpcclient(struct nfs_server *server,
576 576
577 server->client = rpc_clone_client(clp->cl_rpcclient); 577 server->client = rpc_clone_client(clp->cl_rpcclient);
578 if (IS_ERR(server->client)) { 578 if (IS_ERR(server->client)) {
579 dprintk("%s: couldn't create rpc_client!\n", __FUNCTION__); 579 dprintk("%s: couldn't create rpc_client!\n", __func__);
580 return PTR_ERR(server->client); 580 return PTR_ERR(server->client);
581 } 581 }
582 582
@@ -590,7 +590,7 @@ static int nfs_init_server_rpcclient(struct nfs_server *server,
590 590
591 auth = rpcauth_create(pseudoflavour, server->client); 591 auth = rpcauth_create(pseudoflavour, server->client);
592 if (IS_ERR(auth)) { 592 if (IS_ERR(auth)) {
593 dprintk("%s: couldn't create credcache!\n", __FUNCTION__); 593 dprintk("%s: couldn't create credcache!\n", __func__);
594 return PTR_ERR(auth); 594 return PTR_ERR(auth);
595 } 595 }
596 } 596 }
@@ -985,7 +985,7 @@ static int nfs4_init_client(struct nfs_client *clp,
985 error = nfs_idmap_new(clp); 985 error = nfs_idmap_new(clp);
986 if (error < 0) { 986 if (error < 0) {
987 dprintk("%s: failed to create idmapper. Error = %d\n", 987 dprintk("%s: failed to create idmapper. Error = %d\n",
988 __FUNCTION__, error); 988 __func__, error);
989 goto error; 989 goto error;
990 } 990 }
991 __set_bit(NFS_CS_IDMAP, &clp->cl_res_state); 991 __set_bit(NFS_CS_IDMAP, &clp->cl_res_state);
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index 00a5e4405e16..cc563cfa6940 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -60,7 +60,7 @@ static int nfs_delegation_claim_locks(struct nfs_open_context *ctx, struct nfs4_
60 switch (status) { 60 switch (status) {
61 default: 61 default:
62 printk(KERN_ERR "%s: unhandled error %d.\n", 62 printk(KERN_ERR "%s: unhandled error %d.\n",
63 __FUNCTION__, status); 63 __func__, status);
64 case -NFS4ERR_EXPIRED: 64 case -NFS4ERR_EXPIRED:
65 /* kill_proc(fl->fl_pid, SIGLOST, 1); */ 65 /* kill_proc(fl->fl_pid, SIGLOST, 1); */
66 case -NFS4ERR_STALE_CLIENTID: 66 case -NFS4ERR_STALE_CLIENTID:
@@ -186,7 +186,7 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct
186 */ 186 */
187 dfprintk(FILE, "%s: server %s handed out " 187 dfprintk(FILE, "%s: server %s handed out "
188 "a duplicate delegation!\n", 188 "a duplicate delegation!\n",
189 __FUNCTION__, clp->cl_hostname); 189 __func__, clp->cl_hostname);
190 if (delegation->type <= nfsi->delegation->type) { 190 if (delegation->type <= nfsi->delegation->type) {
191 freeme = delegation; 191 freeme = delegation;
192 delegation = NULL; 192 delegation = NULL;
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index f288b3ecab4a..58d43daec084 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -180,7 +180,7 @@ int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page *page)
180 int error; 180 int error;
181 181
182 dfprintk(DIRCACHE, "NFS: %s: reading cookie %Lu into page %lu\n", 182 dfprintk(DIRCACHE, "NFS: %s: reading cookie %Lu into page %lu\n",
183 __FUNCTION__, (long long)desc->entry->cookie, 183 __func__, (long long)desc->entry->cookie,
184 page->index); 184 page->index);
185 185
186 again: 186 again:
@@ -256,7 +256,7 @@ int find_dirent(nfs_readdir_descriptor_t *desc)
256 256
257 while((status = dir_decode(desc)) == 0) { 257 while((status = dir_decode(desc)) == 0) {
258 dfprintk(DIRCACHE, "NFS: %s: examining cookie %Lu\n", 258 dfprintk(DIRCACHE, "NFS: %s: examining cookie %Lu\n",
259 __FUNCTION__, (unsigned long long)entry->cookie); 259 __func__, (unsigned long long)entry->cookie);
260 if (entry->prev_cookie == *desc->dir_cookie) 260 if (entry->prev_cookie == *desc->dir_cookie)
261 break; 261 break;
262 if (loop_count++ > 200) { 262 if (loop_count++ > 200) {
@@ -315,7 +315,7 @@ int find_dirent_page(nfs_readdir_descriptor_t *desc)
315 int status; 315 int status;
316 316
317 dfprintk(DIRCACHE, "NFS: %s: searching page %ld for target %Lu\n", 317 dfprintk(DIRCACHE, "NFS: %s: searching page %ld for target %Lu\n",
318 __FUNCTION__, desc->page_index, 318 __func__, desc->page_index,
319 (long long) *desc->dir_cookie); 319 (long long) *desc->dir_cookie);
320 320
321 /* If we find the page in the page_cache, we cannot be sure 321 /* If we find the page in the page_cache, we cannot be sure
@@ -339,7 +339,7 @@ int find_dirent_page(nfs_readdir_descriptor_t *desc)
339 if (status < 0) 339 if (status < 0)
340 dir_page_release(desc); 340 dir_page_release(desc);
341 out: 341 out:
342 dfprintk(DIRCACHE, "NFS: %s: returns %d\n", __FUNCTION__, status); 342 dfprintk(DIRCACHE, "NFS: %s: returns %d\n", __func__, status);
343 return status; 343 return status;
344} 344}
345 345
@@ -380,7 +380,7 @@ int readdir_search_pagecache(nfs_readdir_descriptor_t *desc)
380 } 380 }
381 } 381 }
382 382
383 dfprintk(DIRCACHE, "NFS: %s: returns %d\n", __FUNCTION__, res); 383 dfprintk(DIRCACHE, "NFS: %s: returns %d\n", __func__, res);
384 return res; 384 return res;
385} 385}
386 386
@@ -506,7 +506,7 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
506 desc->entry->eof = 0; 506 desc->entry->eof = 0;
507 out: 507 out:
508 dfprintk(DIRCACHE, "NFS: %s: returns %d\n", 508 dfprintk(DIRCACHE, "NFS: %s: returns %d\n",
509 __FUNCTION__, status); 509 __func__, status);
510 return status; 510 return status;
511 out_release: 511 out_release:
512 dir_page_release(desc); 512 dir_page_release(desc);
@@ -780,7 +780,7 @@ static int nfs_lookup_revalidate(struct dentry * dentry, struct nameidata *nd)
780 780
781 if (is_bad_inode(inode)) { 781 if (is_bad_inode(inode)) {
782 dfprintk(LOOKUPCACHE, "%s: %s/%s has dud inode\n", 782 dfprintk(LOOKUPCACHE, "%s: %s/%s has dud inode\n",
783 __FUNCTION__, dentry->d_parent->d_name.name, 783 __func__, dentry->d_parent->d_name.name,
784 dentry->d_name.name); 784 dentry->d_name.name);
785 goto out_bad; 785 goto out_bad;
786 } 786 }
@@ -808,7 +808,7 @@ static int nfs_lookup_revalidate(struct dentry * dentry, struct nameidata *nd)
808 unlock_kernel(); 808 unlock_kernel();
809 dput(parent); 809 dput(parent);
810 dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) is valid\n", 810 dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) is valid\n",
811 __FUNCTION__, dentry->d_parent->d_name.name, 811 __func__, dentry->d_parent->d_name.name,
812 dentry->d_name.name); 812 dentry->d_name.name);
813 return 1; 813 return 1;
814out_zap_parent: 814out_zap_parent:
@@ -827,7 +827,7 @@ out_zap_parent:
827 unlock_kernel(); 827 unlock_kernel();
828 dput(parent); 828 dput(parent);
829 dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) is invalid\n", 829 dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) is invalid\n",
830 __FUNCTION__, dentry->d_parent->d_name.name, 830 __func__, dentry->d_parent->d_name.name,
831 dentry->d_name.name); 831 dentry->d_name.name);
832 return 0; 832 return 0;
833} 833}
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 3536b01164f9..d84a3d8f32af 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -526,7 +526,7 @@ static int do_vfs_lock(struct file *file, struct file_lock *fl)
526 if (res < 0) 526 if (res < 0)
527 dprintk(KERN_WARNING "%s: VFS is out of sync with lock manager" 527 dprintk(KERN_WARNING "%s: VFS is out of sync with lock manager"
528 " - error %d!\n", 528 " - error %d!\n",
529 __FUNCTION__, res); 529 __func__, res);
530 return res; 530 return res;
531} 531}
532 532
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 5cb3345eb694..596c5d8e86f4 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -541,8 +541,7 @@ static void __put_nfs_open_context(struct nfs_open_context *ctx, int wait)
541 } 541 }
542 if (ctx->cred != NULL) 542 if (ctx->cred != NULL)
543 put_rpccred(ctx->cred); 543 put_rpccred(ctx->cred);
544 dput(ctx->path.dentry); 544 path_put(&ctx->path);
545 mntput(ctx->path.mnt);
546 kfree(ctx); 545 kfree(ctx);
547} 546}
548 547
@@ -707,6 +706,13 @@ int nfs_attribute_timeout(struct inode *inode)
707 706
708 if (nfs_have_delegation(inode, FMODE_READ)) 707 if (nfs_have_delegation(inode, FMODE_READ))
709 return 0; 708 return 0;
709 /*
710 * Special case: if the attribute timeout is set to 0, then always
711 * treat the cache as having expired (unless holding
712 * a delegation).
713 */
714 if (nfsi->attrtimeo == 0)
715 return 1;
710 return !time_in_range(jiffies, nfsi->read_cache_jiffies, nfsi->read_cache_jiffies + nfsi->attrtimeo); 716 return !time_in_range(jiffies, nfsi->read_cache_jiffies, nfsi->read_cache_jiffies + nfsi->attrtimeo);
711} 717}
712 718
@@ -995,7 +1001,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
995 unsigned long now = jiffies; 1001 unsigned long now = jiffies;
996 1002
997 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n", 1003 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
998 __FUNCTION__, inode->i_sb->s_id, inode->i_ino, 1004 __func__, inode->i_sb->s_id, inode->i_ino,
999 atomic_read(&inode->i_count), fattr->valid); 1005 atomic_read(&inode->i_count), fattr->valid);
1000 1006
1001 if (nfsi->fileid != fattr->fileid) 1007 if (nfsi->fileid != fattr->fileid)
@@ -1119,7 +1125,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
1119 * Big trouble! The inode has become a different object. 1125 * Big trouble! The inode has become a different object.
1120 */ 1126 */
1121 printk(KERN_DEBUG "%s: inode %ld mode changed, %07o to %07o\n", 1127 printk(KERN_DEBUG "%s: inode %ld mode changed, %07o to %07o\n",
1122 __FUNCTION__, inode->i_ino, inode->i_mode, fattr->mode); 1128 __func__, inode->i_ino, inode->i_mode, fattr->mode);
1123 out_err: 1129 out_err:
1124 /* 1130 /*
1125 * No need to worry about unhashing the dentry, as the 1131 * No need to worry about unhashing the dentry, as the
diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
index af4d0f1e402c..2f285ef76399 100644
--- a/fs/nfs/namespace.c
+++ b/fs/nfs/namespace.c
@@ -106,7 +106,7 @@ static void * nfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd)
106 dprintk("--> nfs_follow_mountpoint()\n"); 106 dprintk("--> nfs_follow_mountpoint()\n");
107 107
108 BUG_ON(IS_ROOT(dentry)); 108 BUG_ON(IS_ROOT(dentry));
109 dprintk("%s: enter\n", __FUNCTION__); 109 dprintk("%s: enter\n", __func__);
110 dput(nd->path.dentry); 110 dput(nd->path.dentry);
111 nd->path.dentry = dget(dentry); 111 nd->path.dentry = dget(dentry);
112 112
@@ -137,13 +137,12 @@ static void * nfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd)
137 goto out_follow; 137 goto out_follow;
138 goto out_err; 138 goto out_err;
139 } 139 }
140 mntput(nd->path.mnt); 140 path_put(&nd->path);
141 dput(nd->path.dentry);
142 nd->path.mnt = mnt; 141 nd->path.mnt = mnt;
143 nd->path.dentry = dget(mnt->mnt_root); 142 nd->path.dentry = dget(mnt->mnt_root);
144 schedule_delayed_work(&nfs_automount_task, nfs_mountpoint_expiry_timeout); 143 schedule_delayed_work(&nfs_automount_task, nfs_mountpoint_expiry_timeout);
145out: 144out:
146 dprintk("%s: done, returned %d\n", __FUNCTION__, err); 145 dprintk("%s: done, returned %d\n", __func__, err);
147 146
148 dprintk("<-- nfs_follow_mountpoint() = %d\n", err); 147 dprintk("<-- nfs_follow_mountpoint() = %d\n", err);
149 return ERR_PTR(err); 148 return ERR_PTR(err);
@@ -230,7 +229,7 @@ static struct vfsmount *nfs_do_submount(const struct vfsmount *mnt_parent,
230 229
231 dprintk("--> nfs_do_submount()\n"); 230 dprintk("--> nfs_do_submount()\n");
232 231
233 dprintk("%s: submounting on %s/%s\n", __FUNCTION__, 232 dprintk("%s: submounting on %s/%s\n", __func__,
234 dentry->d_parent->d_name.name, 233 dentry->d_parent->d_name.name,
235 dentry->d_name.name); 234 dentry->d_name.name);
236 if (page == NULL) 235 if (page == NULL)
@@ -243,7 +242,7 @@ static struct vfsmount *nfs_do_submount(const struct vfsmount *mnt_parent,
243free_page: 242free_page:
244 free_page((unsigned long)page); 243 free_page((unsigned long)page);
245out: 244out:
246 dprintk("%s: done\n", __FUNCTION__); 245 dprintk("%s: done\n", __func__);
247 246
248 dprintk("<-- nfs_do_submount() = %p\n", mnt); 247 dprintk("<-- nfs_do_submount() = %p\n", mnt);
249 return mnt; 248 return mnt;
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index 549dbce714a4..c3523ad03ed1 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -63,15 +63,15 @@ do_proc_get_root(struct rpc_clnt *client, struct nfs_fh *fhandle,
63 }; 63 };
64 int status; 64 int status;
65 65
66 dprintk("%s: call fsinfo\n", __FUNCTION__); 66 dprintk("%s: call fsinfo\n", __func__);
67 nfs_fattr_init(info->fattr); 67 nfs_fattr_init(info->fattr);
68 status = rpc_call_sync(client, &msg, 0); 68 status = rpc_call_sync(client, &msg, 0);
69 dprintk("%s: reply fsinfo: %d\n", __FUNCTION__, status); 69 dprintk("%s: reply fsinfo: %d\n", __func__, status);
70 if (!(info->fattr->valid & NFS_ATTR_FATTR)) { 70 if (!(info->fattr->valid & NFS_ATTR_FATTR)) {
71 msg.rpc_proc = &nfs3_procedures[NFS3PROC_GETATTR]; 71 msg.rpc_proc = &nfs3_procedures[NFS3PROC_GETATTR];
72 msg.rpc_resp = info->fattr; 72 msg.rpc_resp = info->fattr;
73 status = rpc_call_sync(client, &msg, 0); 73 status = rpc_call_sync(client, &msg, 0);
74 dprintk("%s: reply getattr: %d\n", __FUNCTION__, status); 74 dprintk("%s: reply getattr: %d\n", __func__, status);
75 } 75 }
76 return status; 76 return status;
77} 77}
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index bd1b9d663fb9..ea790645fda6 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -206,7 +206,6 @@ struct rpc_cred *nfs4_get_renew_cred(struct nfs_client *clp);
206 206
207extern struct nfs4_state_owner * nfs4_get_state_owner(struct nfs_server *, struct rpc_cred *); 207extern struct nfs4_state_owner * nfs4_get_state_owner(struct nfs_server *, struct rpc_cred *);
208extern void nfs4_put_state_owner(struct nfs4_state_owner *); 208extern void nfs4_put_state_owner(struct nfs4_state_owner *);
209extern void nfs4_drop_state_owner(struct nfs4_state_owner *);
210extern struct nfs4_state * nfs4_get_open_state(struct inode *, struct nfs4_state_owner *); 209extern struct nfs4_state * nfs4_get_open_state(struct inode *, struct nfs4_state_owner *);
211extern void nfs4_put_open_state(struct nfs4_state *); 210extern void nfs4_put_open_state(struct nfs4_state *);
212extern void nfs4_close_state(struct path *, struct nfs4_state *, mode_t); 211extern void nfs4_close_state(struct path *, struct nfs4_state *, mode_t);
diff --git a/fs/nfs/nfs4namespace.c b/fs/nfs/nfs4namespace.c
index 5f9ba41ed5bf..b112857301f7 100644
--- a/fs/nfs/nfs4namespace.c
+++ b/fs/nfs/nfs4namespace.c
@@ -86,7 +86,7 @@ static int nfs4_validate_fspath(const struct vfsmount *mnt_parent,
86 86
87 if (strncmp(path, fs_path, strlen(fs_path)) != 0) { 87 if (strncmp(path, fs_path, strlen(fs_path)) != 0) {
88 dprintk("%s: path %s does not begin with fsroot %s\n", 88 dprintk("%s: path %s does not begin with fsroot %s\n",
89 __FUNCTION__, path, fs_path); 89 __func__, path, fs_path);
90 return -ENOENT; 90 return -ENOENT;
91 } 91 }
92 92
@@ -134,7 +134,7 @@ static struct vfsmount *nfs_follow_referral(const struct vfsmount *mnt_parent,
134 if (locations == NULL || locations->nlocations <= 0) 134 if (locations == NULL || locations->nlocations <= 0)
135 goto out; 135 goto out;
136 136
137 dprintk("%s: referral at %s/%s\n", __FUNCTION__, 137 dprintk("%s: referral at %s/%s\n", __func__,
138 dentry->d_parent->d_name.name, dentry->d_name.name); 138 dentry->d_parent->d_name.name, dentry->d_name.name);
139 139
140 page = (char *) __get_free_page(GFP_USER); 140 page = (char *) __get_free_page(GFP_USER);
@@ -204,7 +204,7 @@ static struct vfsmount *nfs_follow_referral(const struct vfsmount *mnt_parent,
204out: 204out:
205 free_page((unsigned long) page); 205 free_page((unsigned long) page);
206 free_page((unsigned long) page2); 206 free_page((unsigned long) page2);
207 dprintk("%s: done\n", __FUNCTION__); 207 dprintk("%s: done\n", __func__);
208 return mnt; 208 return mnt;
209} 209}
210 210
@@ -223,7 +223,7 @@ struct vfsmount *nfs_do_refmount(const struct vfsmount *mnt_parent, struct dentr
223 int err; 223 int err;
224 224
225 /* BUG_ON(IS_ROOT(dentry)); */ 225 /* BUG_ON(IS_ROOT(dentry)); */
226 dprintk("%s: enter\n", __FUNCTION__); 226 dprintk("%s: enter\n", __func__);
227 227
228 page = alloc_page(GFP_KERNEL); 228 page = alloc_page(GFP_KERNEL);
229 if (page == NULL) 229 if (page == NULL)
@@ -238,7 +238,7 @@ struct vfsmount *nfs_do_refmount(const struct vfsmount *mnt_parent, struct dentr
238 238
239 parent = dget_parent(dentry); 239 parent = dget_parent(dentry);
240 dprintk("%s: getting locations for %s/%s\n", 240 dprintk("%s: getting locations for %s/%s\n",
241 __FUNCTION__, parent->d_name.name, dentry->d_name.name); 241 __func__, parent->d_name.name, dentry->d_name.name);
242 242
243 err = nfs4_proc_fs_locations(parent->d_inode, &dentry->d_name, fs_locations, page); 243 err = nfs4_proc_fs_locations(parent->d_inode, &dentry->d_name, fs_locations, page);
244 dput(parent); 244 dput(parent);
@@ -252,6 +252,6 @@ out_free:
252 __free_page(page); 252 __free_page(page);
253 kfree(fs_locations); 253 kfree(fs_locations);
254out: 254out:
255 dprintk("%s: done\n", __FUNCTION__); 255 dprintk("%s: done\n", __func__);
256 return mnt; 256 return mnt;
257} 257}
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index dbc09271af02..1293e0acd82b 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -73,7 +73,7 @@ int nfs4_map_errors(int err)
73{ 73{
74 if (err < -1000) { 74 if (err < -1000) {
75 dprintk("%s could not handle NFSv4 error %d\n", 75 dprintk("%s could not handle NFSv4 error %d\n",
76 __FUNCTION__, -err); 76 __func__, -err);
77 return -EIO; 77 return -EIO;
78 } 78 }
79 return err; 79 return err;
@@ -306,8 +306,7 @@ static void nfs4_opendata_free(struct kref *kref)
306 nfs4_put_open_state(p->state); 306 nfs4_put_open_state(p->state);
307 nfs4_put_state_owner(p->owner); 307 nfs4_put_state_owner(p->owner);
308 dput(p->dir); 308 dput(p->dir);
309 dput(p->path.dentry); 309 path_put(&p->path);
310 mntput(p->path.mnt);
311 kfree(p); 310 kfree(p);
312} 311}
313 312
@@ -1210,8 +1209,7 @@ static void nfs4_free_closedata(void *data)
1210 nfs4_put_open_state(calldata->state); 1209 nfs4_put_open_state(calldata->state);
1211 nfs_free_seqid(calldata->arg.seqid); 1210 nfs_free_seqid(calldata->arg.seqid);
1212 nfs4_put_state_owner(sp); 1211 nfs4_put_state_owner(sp);
1213 dput(calldata->path.dentry); 1212 path_put(&calldata->path);
1214 mntput(calldata->path.mnt);
1215 kfree(calldata); 1213 kfree(calldata);
1216} 1214}
1217 1215
@@ -1578,7 +1576,7 @@ static int nfs4_get_referral(struct inode *dir, const struct qstr *name, struct
1578 goto out; 1576 goto out;
1579 /* Make sure server returned a different fsid for the referral */ 1577 /* Make sure server returned a different fsid for the referral */
1580 if (nfs_fsid_equal(&NFS_SERVER(dir)->fsid, &locations->fattr.fsid)) { 1578 if (nfs_fsid_equal(&NFS_SERVER(dir)->fsid, &locations->fattr.fsid)) {
1581 dprintk("%s: server did not return a different fsid for a referral at %s\n", __FUNCTION__, name->name); 1579 dprintk("%s: server did not return a different fsid for a referral at %s\n", __func__, name->name);
1582 status = -EIO; 1580 status = -EIO;
1583 goto out; 1581 goto out;
1584 } 1582 }
@@ -2211,7 +2209,7 @@ static int _nfs4_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
2211 }; 2209 };
2212 int status; 2210 int status;
2213 2211
2214 dprintk("%s: dentry = %s/%s, cookie = %Lu\n", __FUNCTION__, 2212 dprintk("%s: dentry = %s/%s, cookie = %Lu\n", __func__,
2215 dentry->d_parent->d_name.name, 2213 dentry->d_parent->d_name.name,
2216 dentry->d_name.name, 2214 dentry->d_name.name,
2217 (unsigned long long)cookie); 2215 (unsigned long long)cookie);
@@ -2223,7 +2221,7 @@ static int _nfs4_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
2223 2221
2224 nfs_invalidate_atime(dir); 2222 nfs_invalidate_atime(dir);
2225 2223
2226 dprintk("%s: returns %d\n", __FUNCTION__, status); 2224 dprintk("%s: returns %d\n", __func__, status);
2227 return status; 2225 return status;
2228} 2226}
2229 2227
@@ -3342,7 +3340,7 @@ static void nfs4_lock_prepare(struct rpc_task *task, void *calldata)
3342 struct nfs4_lockdata *data = calldata; 3340 struct nfs4_lockdata *data = calldata;
3343 struct nfs4_state *state = data->lsp->ls_state; 3341 struct nfs4_state *state = data->lsp->ls_state;
3344 3342
3345 dprintk("%s: begin!\n", __FUNCTION__); 3343 dprintk("%s: begin!\n", __func__);
3346 if (nfs_wait_on_sequence(data->arg.lock_seqid, task) != 0) 3344 if (nfs_wait_on_sequence(data->arg.lock_seqid, task) != 0)
3347 return; 3345 return;
3348 /* Do we need to do an open_to_lock_owner? */ 3346 /* Do we need to do an open_to_lock_owner? */
@@ -3356,14 +3354,14 @@ static void nfs4_lock_prepare(struct rpc_task *task, void *calldata)
3356 data->arg.new_lock_owner = 0; 3354 data->arg.new_lock_owner = 0;
3357 data->timestamp = jiffies; 3355 data->timestamp = jiffies;
3358 rpc_call_start(task); 3356 rpc_call_start(task);
3359 dprintk("%s: done!, ret = %d\n", __FUNCTION__, data->rpc_status); 3357 dprintk("%s: done!, ret = %d\n", __func__, data->rpc_status);
3360} 3358}
3361 3359
3362static void nfs4_lock_done(struct rpc_task *task, void *calldata) 3360static void nfs4_lock_done(struct rpc_task *task, void *calldata)
3363{ 3361{
3364 struct nfs4_lockdata *data = calldata; 3362 struct nfs4_lockdata *data = calldata;
3365 3363
3366 dprintk("%s: begin!\n", __FUNCTION__); 3364 dprintk("%s: begin!\n", __func__);
3367 3365
3368 data->rpc_status = task->tk_status; 3366 data->rpc_status = task->tk_status;
3369 if (RPC_ASSASSINATED(task)) 3367 if (RPC_ASSASSINATED(task))
@@ -3381,14 +3379,14 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata)
3381 renew_lease(NFS_SERVER(data->ctx->path.dentry->d_inode), data->timestamp); 3379 renew_lease(NFS_SERVER(data->ctx->path.dentry->d_inode), data->timestamp);
3382 } 3380 }
3383out: 3381out:
3384 dprintk("%s: done, ret = %d!\n", __FUNCTION__, data->rpc_status); 3382 dprintk("%s: done, ret = %d!\n", __func__, data->rpc_status);
3385} 3383}
3386 3384
3387static void nfs4_lock_release(void *calldata) 3385static void nfs4_lock_release(void *calldata)
3388{ 3386{
3389 struct nfs4_lockdata *data = calldata; 3387 struct nfs4_lockdata *data = calldata;
3390 3388
3391 dprintk("%s: begin!\n", __FUNCTION__); 3389 dprintk("%s: begin!\n", __func__);
3392 nfs_free_seqid(data->arg.open_seqid); 3390 nfs_free_seqid(data->arg.open_seqid);
3393 if (data->cancelled != 0) { 3391 if (data->cancelled != 0) {
3394 struct rpc_task *task; 3392 struct rpc_task *task;
@@ -3396,13 +3394,13 @@ static void nfs4_lock_release(void *calldata)
3396 data->arg.lock_seqid); 3394 data->arg.lock_seqid);
3397 if (!IS_ERR(task)) 3395 if (!IS_ERR(task))
3398 rpc_put_task(task); 3396 rpc_put_task(task);
3399 dprintk("%s: cancelling lock!\n", __FUNCTION__); 3397 dprintk("%s: cancelling lock!\n", __func__);
3400 } else 3398 } else
3401 nfs_free_seqid(data->arg.lock_seqid); 3399 nfs_free_seqid(data->arg.lock_seqid);
3402 nfs4_put_lock_state(data->lsp); 3400 nfs4_put_lock_state(data->lsp);
3403 put_nfs_open_context(data->ctx); 3401 put_nfs_open_context(data->ctx);
3404 kfree(data); 3402 kfree(data);
3405 dprintk("%s: done!\n", __FUNCTION__); 3403 dprintk("%s: done!\n", __func__);
3406} 3404}
3407 3405
3408static const struct rpc_call_ops nfs4_lock_ops = { 3406static const struct rpc_call_ops nfs4_lock_ops = {
@@ -3428,7 +3426,7 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f
3428 }; 3426 };
3429 int ret; 3427 int ret;
3430 3428
3431 dprintk("%s: begin!\n", __FUNCTION__); 3429 dprintk("%s: begin!\n", __func__);
3432 data = nfs4_alloc_lockdata(fl, nfs_file_open_context(fl->fl_file), 3430 data = nfs4_alloc_lockdata(fl, nfs_file_open_context(fl->fl_file),
3433 fl->fl_u.nfs4_fl.owner); 3431 fl->fl_u.nfs4_fl.owner);
3434 if (data == NULL) 3432 if (data == NULL)
@@ -3451,7 +3449,7 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f
3451 } else 3449 } else
3452 data->cancelled = 1; 3450 data->cancelled = 1;
3453 rpc_put_task(task); 3451 rpc_put_task(task);
3454 dprintk("%s: done, ret = %d!\n", __FUNCTION__, ret); 3452 dprintk("%s: done, ret = %d!\n", __func__, ret);
3455 return ret; 3453 return ret;
3456} 3454}
3457 3455
@@ -3527,7 +3525,7 @@ static int _nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock
3527 /* Note: we always want to sleep here! */ 3525 /* Note: we always want to sleep here! */
3528 request->fl_flags = fl_flags | FL_SLEEP; 3526 request->fl_flags = fl_flags | FL_SLEEP;
3529 if (do_vfs_lock(request->fl_file, request) < 0) 3527 if (do_vfs_lock(request->fl_file, request) < 0)
3530 printk(KERN_WARNING "%s: VFS is out of sync with lock manager!\n", __FUNCTION__); 3528 printk(KERN_WARNING "%s: VFS is out of sync with lock manager!\n", __func__);
3531out_unlock: 3529out_unlock:
3532 up_read(&clp->cl_sem); 3530 up_read(&clp->cl_sem);
3533out: 3531out:
@@ -3665,12 +3663,12 @@ int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name,
3665 }; 3663 };
3666 int status; 3664 int status;
3667 3665
3668 dprintk("%s: start\n", __FUNCTION__); 3666 dprintk("%s: start\n", __func__);
3669 nfs_fattr_init(&fs_locations->fattr); 3667 nfs_fattr_init(&fs_locations->fattr);
3670 fs_locations->server = server; 3668 fs_locations->server = server;
3671 fs_locations->nlocations = 0; 3669 fs_locations->nlocations = 0;
3672 status = rpc_call_sync(server->client, &msg, 0); 3670 status = rpc_call_sync(server->client, &msg, 0);
3673 dprintk("%s: returned status = %d\n", __FUNCTION__, status); 3671 dprintk("%s: returned status = %d\n", __func__, status);
3674 return status; 3672 return status;
3675} 3673}
3676 3674
diff --git a/fs/nfs/nfs4renewd.c b/fs/nfs/nfs4renewd.c
index 5e2e4af1a0e6..3305acbbe2ae 100644
--- a/fs/nfs/nfs4renewd.c
+++ b/fs/nfs/nfs4renewd.c
@@ -66,7 +66,7 @@ nfs4_renew_state(struct work_struct *work)
66 unsigned long last, now; 66 unsigned long last, now;
67 67
68 down_read(&clp->cl_sem); 68 down_read(&clp->cl_sem);
69 dprintk("%s: start\n", __FUNCTION__); 69 dprintk("%s: start\n", __func__);
70 /* Are there any active superblocks? */ 70 /* Are there any active superblocks? */
71 if (list_empty(&clp->cl_superblocks)) 71 if (list_empty(&clp->cl_superblocks))
72 goto out; 72 goto out;
@@ -92,17 +92,17 @@ nfs4_renew_state(struct work_struct *work)
92 spin_lock(&clp->cl_lock); 92 spin_lock(&clp->cl_lock);
93 } else 93 } else
94 dprintk("%s: failed to call renewd. Reason: lease not expired \n", 94 dprintk("%s: failed to call renewd. Reason: lease not expired \n",
95 __FUNCTION__); 95 __func__);
96 if (timeout < 5 * HZ) /* safeguard */ 96 if (timeout < 5 * HZ) /* safeguard */
97 timeout = 5 * HZ; 97 timeout = 5 * HZ;
98 dprintk("%s: requeueing work. Lease period = %ld\n", 98 dprintk("%s: requeueing work. Lease period = %ld\n",
99 __FUNCTION__, (timeout + HZ - 1) / HZ); 99 __func__, (timeout + HZ - 1) / HZ);
100 cancel_delayed_work(&clp->cl_renewd); 100 cancel_delayed_work(&clp->cl_renewd);
101 schedule_delayed_work(&clp->cl_renewd, timeout); 101 schedule_delayed_work(&clp->cl_renewd, timeout);
102 spin_unlock(&clp->cl_lock); 102 spin_unlock(&clp->cl_lock);
103out: 103out:
104 up_read(&clp->cl_sem); 104 up_read(&clp->cl_sem);
105 dprintk("%s: done\n", __FUNCTION__); 105 dprintk("%s: done\n", __func__);
106} 106}
107 107
108/* Must be called with clp->cl_sem locked for writes */ 108/* Must be called with clp->cl_sem locked for writes */
@@ -117,7 +117,7 @@ nfs4_schedule_state_renewal(struct nfs_client *clp)
117 if (timeout < 5 * HZ) 117 if (timeout < 5 * HZ)
118 timeout = 5 * HZ; 118 timeout = 5 * HZ;
119 dprintk("%s: requeueing work. Lease period = %ld\n", 119 dprintk("%s: requeueing work. Lease period = %ld\n",
120 __FUNCTION__, (timeout + HZ - 1) / HZ); 120 __func__, (timeout + HZ - 1) / HZ);
121 cancel_delayed_work(&clp->cl_renewd); 121 cancel_delayed_work(&clp->cl_renewd);
122 schedule_delayed_work(&clp->cl_renewd, timeout); 122 schedule_delayed_work(&clp->cl_renewd, timeout);
123 set_bit(NFS_CS_RENEWD, &clp->cl_res_state); 123 set_bit(NFS_CS_RENEWD, &clp->cl_res_state);
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 46eb624e4f16..856a8934f610 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -282,7 +282,7 @@ nfs4_alloc_state_owner(void)
282 return sp; 282 return sp;
283} 283}
284 284
285void 285static void
286nfs4_drop_state_owner(struct nfs4_state_owner *sp) 286nfs4_drop_state_owner(struct nfs4_state_owner *sp)
287{ 287{
288 if (!RB_EMPTY_NODE(&sp->so_client_node)) { 288 if (!RB_EMPTY_NODE(&sp->so_client_node)) {
@@ -828,7 +828,7 @@ static int nfs4_reclaim_locks(struct nfs4_state_recovery_ops *ops, struct nfs4_s
828 switch (status) { 828 switch (status) {
829 default: 829 default:
830 printk(KERN_ERR "%s: unhandled error %d. Zeroing state\n", 830 printk(KERN_ERR "%s: unhandled error %d. Zeroing state\n",
831 __FUNCTION__, status); 831 __func__, status);
832 case -NFS4ERR_EXPIRED: 832 case -NFS4ERR_EXPIRED:
833 case -NFS4ERR_NO_GRACE: 833 case -NFS4ERR_NO_GRACE:
834 case -NFS4ERR_RECLAIM_BAD: 834 case -NFS4ERR_RECLAIM_BAD:
@@ -869,14 +869,14 @@ static int nfs4_reclaim_open_state(struct nfs4_state_recovery_ops *ops, struct n
869 list_for_each_entry(lock, &state->lock_states, ls_locks) { 869 list_for_each_entry(lock, &state->lock_states, ls_locks) {
870 if (!(lock->ls_flags & NFS_LOCK_INITIALIZED)) 870 if (!(lock->ls_flags & NFS_LOCK_INITIALIZED))
871 printk("%s: Lock reclaim failed!\n", 871 printk("%s: Lock reclaim failed!\n",
872 __FUNCTION__); 872 __func__);
873 } 873 }
874 continue; 874 continue;
875 } 875 }
876 switch (status) { 876 switch (status) {
877 default: 877 default:
878 printk(KERN_ERR "%s: unhandled error %d. Zeroing state\n", 878 printk(KERN_ERR "%s: unhandled error %d. Zeroing state\n",
879 __FUNCTION__, status); 879 __func__, status);
880 case -ENOENT: 880 case -ENOENT:
881 case -NFS4ERR_RECLAIM_BAD: 881 case -NFS4ERR_RECLAIM_BAD:
882 case -NFS4ERR_RECLAIM_CONFLICT: 882 case -NFS4ERR_RECLAIM_CONFLICT:
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 5a2d64927b35..b916297d2334 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -1831,7 +1831,7 @@ static int nfs4_xdr_enc_readdir(struct rpc_rqst *req, __be32 *p, const struct nf
1831 xdr_inline_pages(&req->rq_rcv_buf, replen, args->pages, 1831 xdr_inline_pages(&req->rq_rcv_buf, replen, args->pages,
1832 args->pgbase, args->count); 1832 args->pgbase, args->count);
1833 dprintk("%s: inlined page args = (%u, %p, %u, %u)\n", 1833 dprintk("%s: inlined page args = (%u, %p, %u, %u)\n",
1834 __FUNCTION__, replen, args->pages, 1834 __func__, replen, args->pages,
1835 args->pgbase, args->count); 1835 args->pgbase, args->count);
1836 1836
1837out: 1837out:
@@ -2192,9 +2192,9 @@ out:
2192 p = xdr_inline_decode(xdr, nbytes); \ 2192 p = xdr_inline_decode(xdr, nbytes); \
2193 if (unlikely(!p)) { \ 2193 if (unlikely(!p)) { \
2194 dprintk("nfs: %s: prematurely hit end of receive" \ 2194 dprintk("nfs: %s: prematurely hit end of receive" \
2195 " buffer\n", __FUNCTION__); \ 2195 " buffer\n", __func__); \
2196 dprintk("nfs: %s: xdr->p=%p, bytes=%u, xdr->end=%p\n", \ 2196 dprintk("nfs: %s: xdr->p=%p, bytes=%u, xdr->end=%p\n", \
2197 __FUNCTION__, xdr->p, nbytes, xdr->end); \ 2197 __func__, xdr->p, nbytes, xdr->end); \
2198 return -EIO; \ 2198 return -EIO; \
2199 } \ 2199 } \
2200} while (0) 2200} while (0)
@@ -2306,12 +2306,12 @@ static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *
2306 READ_BUF(4); 2306 READ_BUF(4);
2307 READ32(*type); 2307 READ32(*type);
2308 if (*type < NF4REG || *type > NF4NAMEDATTR) { 2308 if (*type < NF4REG || *type > NF4NAMEDATTR) {
2309 dprintk("%s: bad type %d\n", __FUNCTION__, *type); 2309 dprintk("%s: bad type %d\n", __func__, *type);
2310 return -EIO; 2310 return -EIO;
2311 } 2311 }
2312 bitmap[0] &= ~FATTR4_WORD0_TYPE; 2312 bitmap[0] &= ~FATTR4_WORD0_TYPE;
2313 } 2313 }
2314 dprintk("%s: type=0%o\n", __FUNCTION__, nfs_type2fmt[*type].nfs2type); 2314 dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type].nfs2type);
2315 return 0; 2315 return 0;
2316} 2316}
2317 2317
@@ -2327,7 +2327,7 @@ static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t
2327 READ64(*change); 2327 READ64(*change);
2328 bitmap[0] &= ~FATTR4_WORD0_CHANGE; 2328 bitmap[0] &= ~FATTR4_WORD0_CHANGE;
2329 } 2329 }
2330 dprintk("%s: change attribute=%Lu\n", __FUNCTION__, 2330 dprintk("%s: change attribute=%Lu\n", __func__,
2331 (unsigned long long)*change); 2331 (unsigned long long)*change);
2332 return 0; 2332 return 0;
2333} 2333}
@@ -2344,7 +2344,7 @@ static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *
2344 READ64(*size); 2344 READ64(*size);
2345 bitmap[0] &= ~FATTR4_WORD0_SIZE; 2345 bitmap[0] &= ~FATTR4_WORD0_SIZE;
2346 } 2346 }
2347 dprintk("%s: file size=%Lu\n", __FUNCTION__, (unsigned long long)*size); 2347 dprintk("%s: file size=%Lu\n", __func__, (unsigned long long)*size);
2348 return 0; 2348 return 0;
2349} 2349}
2350 2350
@@ -2360,7 +2360,7 @@ static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, ui
2360 READ32(*res); 2360 READ32(*res);
2361 bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT; 2361 bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT;
2362 } 2362 }
2363 dprintk("%s: link support=%s\n", __FUNCTION__, *res == 0 ? "false" : "true"); 2363 dprintk("%s: link support=%s\n", __func__, *res == 0 ? "false" : "true");
2364 return 0; 2364 return 0;
2365} 2365}
2366 2366
@@ -2376,7 +2376,7 @@ static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap,
2376 READ32(*res); 2376 READ32(*res);
2377 bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT; 2377 bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT;
2378 } 2378 }
2379 dprintk("%s: symlink support=%s\n", __FUNCTION__, *res == 0 ? "false" : "true"); 2379 dprintk("%s: symlink support=%s\n", __func__, *res == 0 ? "false" : "true");
2380 return 0; 2380 return 0;
2381} 2381}
2382 2382
@@ -2394,7 +2394,7 @@ static int decode_attr_fsid(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs
2394 READ64(fsid->minor); 2394 READ64(fsid->minor);
2395 bitmap[0] &= ~FATTR4_WORD0_FSID; 2395 bitmap[0] &= ~FATTR4_WORD0_FSID;
2396 } 2396 }
2397 dprintk("%s: fsid=(0x%Lx/0x%Lx)\n", __FUNCTION__, 2397 dprintk("%s: fsid=(0x%Lx/0x%Lx)\n", __func__,
2398 (unsigned long long)fsid->major, 2398 (unsigned long long)fsid->major,
2399 (unsigned long long)fsid->minor); 2399 (unsigned long long)fsid->minor);
2400 return 0; 2400 return 0;
@@ -2412,7 +2412,7 @@ static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint
2412 READ32(*res); 2412 READ32(*res);
2413 bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME; 2413 bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME;
2414 } 2414 }
2415 dprintk("%s: file size=%u\n", __FUNCTION__, (unsigned int)*res); 2415 dprintk("%s: file size=%u\n", __func__, (unsigned int)*res);
2416 return 0; 2416 return 0;
2417} 2417}
2418 2418
@@ -2428,7 +2428,7 @@ static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint
2428 READ32(*res); 2428 READ32(*res);
2429 bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT; 2429 bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT;
2430 } 2430 }
2431 dprintk("%s: ACLs supported=%u\n", __FUNCTION__, (unsigned int)*res); 2431 dprintk("%s: ACLs supported=%u\n", __func__, (unsigned int)*res);
2432 return 0; 2432 return 0;
2433} 2433}
2434 2434
@@ -2444,7 +2444,7 @@ static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t
2444 READ64(*fileid); 2444 READ64(*fileid);
2445 bitmap[0] &= ~FATTR4_WORD0_FILEID; 2445 bitmap[0] &= ~FATTR4_WORD0_FILEID;
2446 } 2446 }
2447 dprintk("%s: fileid=%Lu\n", __FUNCTION__, (unsigned long long)*fileid); 2447 dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid);
2448 return 0; 2448 return 0;
2449} 2449}
2450 2450
@@ -2460,7 +2460,7 @@ static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitma
2460 READ64(*fileid); 2460 READ64(*fileid);
2461 bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID; 2461 bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID;
2462 } 2462 }
2463 dprintk("%s: fileid=%Lu\n", __FUNCTION__, (unsigned long long)*fileid); 2463 dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid);
2464 return 0; 2464 return 0;
2465} 2465}
2466 2466
@@ -2477,7 +2477,7 @@ static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uin
2477 READ64(*res); 2477 READ64(*res);
2478 bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL; 2478 bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL;
2479 } 2479 }
2480 dprintk("%s: files avail=%Lu\n", __FUNCTION__, (unsigned long long)*res); 2480 dprintk("%s: files avail=%Lu\n", __func__, (unsigned long long)*res);
2481 return status; 2481 return status;
2482} 2482}
2483 2483
@@ -2494,7 +2494,7 @@ static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint
2494 READ64(*res); 2494 READ64(*res);
2495 bitmap[0] &= ~FATTR4_WORD0_FILES_FREE; 2495 bitmap[0] &= ~FATTR4_WORD0_FILES_FREE;
2496 } 2496 }
2497 dprintk("%s: files free=%Lu\n", __FUNCTION__, (unsigned long long)*res); 2497 dprintk("%s: files free=%Lu\n", __func__, (unsigned long long)*res);
2498 return status; 2498 return status;
2499} 2499}
2500 2500
@@ -2511,7 +2511,7 @@ static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uin
2511 READ64(*res); 2511 READ64(*res);
2512 bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL; 2512 bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL;
2513 } 2513 }
2514 dprintk("%s: files total=%Lu\n", __FUNCTION__, (unsigned long long)*res); 2514 dprintk("%s: files total=%Lu\n", __func__, (unsigned long long)*res);
2515 return status; 2515 return status;
2516} 2516}
2517 2517
@@ -2569,7 +2569,7 @@ static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, st
2569 status = 0; 2569 status = 0;
2570 if (unlikely(!(bitmap[0] & FATTR4_WORD0_FS_LOCATIONS))) 2570 if (unlikely(!(bitmap[0] & FATTR4_WORD0_FS_LOCATIONS)))
2571 goto out; 2571 goto out;
2572 dprintk("%s: fsroot ", __FUNCTION__); 2572 dprintk("%s: fsroot ", __func__);
2573 status = decode_pathname(xdr, &res->fs_path); 2573 status = decode_pathname(xdr, &res->fs_path);
2574 if (unlikely(status != 0)) 2574 if (unlikely(status != 0))
2575 goto out; 2575 goto out;
@@ -2586,7 +2586,7 @@ static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, st
2586 READ32(m); 2586 READ32(m);
2587 2587
2588 loc->nservers = 0; 2588 loc->nservers = 0;
2589 dprintk("%s: servers ", __FUNCTION__); 2589 dprintk("%s: servers ", __func__);
2590 while (loc->nservers < m) { 2590 while (loc->nservers < m) {
2591 struct nfs4_string *server = &loc->servers[loc->nservers]; 2591 struct nfs4_string *server = &loc->servers[loc->nservers];
2592 status = decode_opaque_inline(xdr, &server->len, &server->data); 2592 status = decode_opaque_inline(xdr, &server->len, &server->data);
@@ -2599,7 +2599,7 @@ static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, st
2599 unsigned int i; 2599 unsigned int i;
2600 dprintk("%s: using first %u of %u servers " 2600 dprintk("%s: using first %u of %u servers "
2601 "returned for location %u\n", 2601 "returned for location %u\n",
2602 __FUNCTION__, 2602 __func__,
2603 NFS4_FS_LOCATION_MAXSERVERS, 2603 NFS4_FS_LOCATION_MAXSERVERS,
2604 m, res->nlocations); 2604 m, res->nlocations);
2605 for (i = loc->nservers; i < m; i++) { 2605 for (i = loc->nservers; i < m; i++) {
@@ -2618,7 +2618,7 @@ static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, st
2618 res->nlocations++; 2618 res->nlocations++;
2619 } 2619 }
2620out: 2620out:
2621 dprintk("%s: fs_locations done, error = %d\n", __FUNCTION__, status); 2621 dprintk("%s: fs_locations done, error = %d\n", __func__, status);
2622 return status; 2622 return status;
2623out_eio: 2623out_eio:
2624 status = -EIO; 2624 status = -EIO;
@@ -2638,7 +2638,7 @@ static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uin
2638 READ64(*res); 2638 READ64(*res);
2639 bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE; 2639 bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE;
2640 } 2640 }
2641 dprintk("%s: maxfilesize=%Lu\n", __FUNCTION__, (unsigned long long)*res); 2641 dprintk("%s: maxfilesize=%Lu\n", __func__, (unsigned long long)*res);
2642 return status; 2642 return status;
2643} 2643}
2644 2644
@@ -2655,7 +2655,7 @@ static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_
2655 READ32(*maxlink); 2655 READ32(*maxlink);
2656 bitmap[0] &= ~FATTR4_WORD0_MAXLINK; 2656 bitmap[0] &= ~FATTR4_WORD0_MAXLINK;
2657 } 2657 }
2658 dprintk("%s: maxlink=%u\n", __FUNCTION__, *maxlink); 2658 dprintk("%s: maxlink=%u\n", __func__, *maxlink);
2659 return status; 2659 return status;
2660} 2660}
2661 2661
@@ -2672,7 +2672,7 @@ static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_
2672 READ32(*maxname); 2672 READ32(*maxname);
2673 bitmap[0] &= ~FATTR4_WORD0_MAXNAME; 2673 bitmap[0] &= ~FATTR4_WORD0_MAXNAME;
2674 } 2674 }
2675 dprintk("%s: maxname=%u\n", __FUNCTION__, *maxname); 2675 dprintk("%s: maxname=%u\n", __func__, *maxname);
2676 return status; 2676 return status;
2677} 2677}
2678 2678
@@ -2693,7 +2693,7 @@ static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_
2693 *res = (uint32_t)maxread; 2693 *res = (uint32_t)maxread;
2694 bitmap[0] &= ~FATTR4_WORD0_MAXREAD; 2694 bitmap[0] &= ~FATTR4_WORD0_MAXREAD;
2695 } 2695 }
2696 dprintk("%s: maxread=%lu\n", __FUNCTION__, (unsigned long)*res); 2696 dprintk("%s: maxread=%lu\n", __func__, (unsigned long)*res);
2697 return status; 2697 return status;
2698} 2698}
2699 2699
@@ -2714,7 +2714,7 @@ static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32
2714 *res = (uint32_t)maxwrite; 2714 *res = (uint32_t)maxwrite;
2715 bitmap[0] &= ~FATTR4_WORD0_MAXWRITE; 2715 bitmap[0] &= ~FATTR4_WORD0_MAXWRITE;
2716 } 2716 }
2717 dprintk("%s: maxwrite=%lu\n", __FUNCTION__, (unsigned long)*res); 2717 dprintk("%s: maxwrite=%lu\n", __func__, (unsigned long)*res);
2718 return status; 2718 return status;
2719} 2719}
2720 2720
@@ -2731,7 +2731,7 @@ static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *
2731 *mode &= ~S_IFMT; 2731 *mode &= ~S_IFMT;
2732 bitmap[1] &= ~FATTR4_WORD1_MODE; 2732 bitmap[1] &= ~FATTR4_WORD1_MODE;
2733 } 2733 }
2734 dprintk("%s: file mode=0%o\n", __FUNCTION__, (unsigned int)*mode); 2734 dprintk("%s: file mode=0%o\n", __func__, (unsigned int)*mode);
2735 return 0; 2735 return 0;
2736} 2736}
2737 2737
@@ -2747,7 +2747,7 @@ static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t
2747 READ32(*nlink); 2747 READ32(*nlink);
2748 bitmap[1] &= ~FATTR4_WORD1_NUMLINKS; 2748 bitmap[1] &= ~FATTR4_WORD1_NUMLINKS;
2749 } 2749 }
2750 dprintk("%s: nlink=%u\n", __FUNCTION__, (unsigned int)*nlink); 2750 dprintk("%s: nlink=%u\n", __func__, (unsigned int)*nlink);
2751 return 0; 2751 return 0;
2752} 2752}
2753 2753
@@ -2766,13 +2766,13 @@ static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, struct nf
2766 if (len < XDR_MAX_NETOBJ) { 2766 if (len < XDR_MAX_NETOBJ) {
2767 if (nfs_map_name_to_uid(clp, (char *)p, len, uid) != 0) 2767 if (nfs_map_name_to_uid(clp, (char *)p, len, uid) != 0)
2768 dprintk("%s: nfs_map_name_to_uid failed!\n", 2768 dprintk("%s: nfs_map_name_to_uid failed!\n",
2769 __FUNCTION__); 2769 __func__);
2770 } else 2770 } else
2771 dprintk("%s: name too long (%u)!\n", 2771 dprintk("%s: name too long (%u)!\n",
2772 __FUNCTION__, len); 2772 __func__, len);
2773 bitmap[1] &= ~FATTR4_WORD1_OWNER; 2773 bitmap[1] &= ~FATTR4_WORD1_OWNER;
2774 } 2774 }
2775 dprintk("%s: uid=%d\n", __FUNCTION__, (int)*uid); 2775 dprintk("%s: uid=%d\n", __func__, (int)*uid);
2776 return 0; 2776 return 0;
2777} 2777}
2778 2778
@@ -2791,13 +2791,13 @@ static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, struct nf
2791 if (len < XDR_MAX_NETOBJ) { 2791 if (len < XDR_MAX_NETOBJ) {
2792 if (nfs_map_group_to_gid(clp, (char *)p, len, gid) != 0) 2792 if (nfs_map_group_to_gid(clp, (char *)p, len, gid) != 0)
2793 dprintk("%s: nfs_map_group_to_gid failed!\n", 2793 dprintk("%s: nfs_map_group_to_gid failed!\n",
2794 __FUNCTION__); 2794 __func__);
2795 } else 2795 } else
2796 dprintk("%s: name too long (%u)!\n", 2796 dprintk("%s: name too long (%u)!\n",
2797 __FUNCTION__, len); 2797 __func__, len);
2798 bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP; 2798 bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP;
2799 } 2799 }
2800 dprintk("%s: gid=%d\n", __FUNCTION__, (int)*gid); 2800 dprintk("%s: gid=%d\n", __func__, (int)*gid);
2801 return 0; 2801 return 0;
2802} 2802}
2803 2803
@@ -2820,7 +2820,7 @@ static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rde
2820 *rdev = tmp; 2820 *rdev = tmp;
2821 bitmap[1] &= ~ FATTR4_WORD1_RAWDEV; 2821 bitmap[1] &= ~ FATTR4_WORD1_RAWDEV;
2822 } 2822 }
2823 dprintk("%s: rdev=(0x%x:0x%x)\n", __FUNCTION__, major, minor); 2823 dprintk("%s: rdev=(0x%x:0x%x)\n", __func__, major, minor);
2824 return 0; 2824 return 0;
2825} 2825}
2826 2826
@@ -2837,7 +2837,7 @@ static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uin
2837 READ64(*res); 2837 READ64(*res);
2838 bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL; 2838 bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL;
2839 } 2839 }
2840 dprintk("%s: space avail=%Lu\n", __FUNCTION__, (unsigned long long)*res); 2840 dprintk("%s: space avail=%Lu\n", __func__, (unsigned long long)*res);
2841 return status; 2841 return status;
2842} 2842}
2843 2843
@@ -2854,7 +2854,7 @@ static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint
2854 READ64(*res); 2854 READ64(*res);
2855 bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE; 2855 bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE;
2856 } 2856 }
2857 dprintk("%s: space free=%Lu\n", __FUNCTION__, (unsigned long long)*res); 2857 dprintk("%s: space free=%Lu\n", __func__, (unsigned long long)*res);
2858 return status; 2858 return status;
2859} 2859}
2860 2860
@@ -2871,7 +2871,7 @@ static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uin
2871 READ64(*res); 2871 READ64(*res);
2872 bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL; 2872 bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL;
2873 } 2873 }
2874 dprintk("%s: space total=%Lu\n", __FUNCTION__, (unsigned long long)*res); 2874 dprintk("%s: space total=%Lu\n", __func__, (unsigned long long)*res);
2875 return status; 2875 return status;
2876} 2876}
2877 2877
@@ -2887,7 +2887,7 @@ static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint
2887 READ64(*used); 2887 READ64(*used);
2888 bitmap[1] &= ~FATTR4_WORD1_SPACE_USED; 2888 bitmap[1] &= ~FATTR4_WORD1_SPACE_USED;
2889 } 2889 }
2890 dprintk("%s: space used=%Lu\n", __FUNCTION__, 2890 dprintk("%s: space used=%Lu\n", __func__,
2891 (unsigned long long)*used); 2891 (unsigned long long)*used);
2892 return 0; 2892 return 0;
2893} 2893}
@@ -2918,7 +2918,7 @@ static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, str
2918 status = decode_attr_time(xdr, time); 2918 status = decode_attr_time(xdr, time);
2919 bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS; 2919 bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS;
2920 } 2920 }
2921 dprintk("%s: atime=%ld\n", __FUNCTION__, (long)time->tv_sec); 2921 dprintk("%s: atime=%ld\n", __func__, (long)time->tv_sec);
2922 return status; 2922 return status;
2923} 2923}
2924 2924
@@ -2934,7 +2934,7 @@ static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, s
2934 status = decode_attr_time(xdr, time); 2934 status = decode_attr_time(xdr, time);
2935 bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA; 2935 bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA;
2936 } 2936 }
2937 dprintk("%s: ctime=%ld\n", __FUNCTION__, (long)time->tv_sec); 2937 dprintk("%s: ctime=%ld\n", __func__, (long)time->tv_sec);
2938 return status; 2938 return status;
2939} 2939}
2940 2940
@@ -2950,7 +2950,7 @@ static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, str
2950 status = decode_attr_time(xdr, time); 2950 status = decode_attr_time(xdr, time);
2951 bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY; 2951 bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY;
2952 } 2952 }
2953 dprintk("%s: mtime=%ld\n", __FUNCTION__, (long)time->tv_sec); 2953 dprintk("%s: mtime=%ld\n", __func__, (long)time->tv_sec);
2954 return status; 2954 return status;
2955} 2955}
2956 2956
@@ -2962,7 +2962,7 @@ static int verify_attr_len(struct xdr_stream *xdr, __be32 *savep, uint32_t attrl
2962 if (unlikely(attrwords != nwords)) { 2962 if (unlikely(attrwords != nwords)) {
2963 dprintk("%s: server returned incorrect attribute length: " 2963 dprintk("%s: server returned incorrect attribute length: "
2964 "%u %c %u\n", 2964 "%u %c %u\n",
2965 __FUNCTION__, 2965 __func__,
2966 attrwords << 2, 2966 attrwords << 2,
2967 (attrwords < nwords) ? '<' : '>', 2967 (attrwords < nwords) ? '<' : '>',
2968 nwords << 2); 2968 nwords << 2);
@@ -3067,7 +3067,7 @@ static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_re
3067 goto xdr_error; 3067 goto xdr_error;
3068 status = verify_attr_len(xdr, savep, attrlen); 3068 status = verify_attr_len(xdr, savep, attrlen);
3069xdr_error: 3069xdr_error:
3070 dprintk("%s: xdr returned %d!\n", __FUNCTION__, -status); 3070 dprintk("%s: xdr returned %d!\n", __func__, -status);
3071 return status; 3071 return status;
3072} 3072}
3073 3073
@@ -3100,7 +3100,7 @@ static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat)
3100 3100
3101 status = verify_attr_len(xdr, savep, attrlen); 3101 status = verify_attr_len(xdr, savep, attrlen);
3102xdr_error: 3102xdr_error:
3103 dprintk("%s: xdr returned %d!\n", __FUNCTION__, -status); 3103 dprintk("%s: xdr returned %d!\n", __func__, -status);
3104 return status; 3104 return status;
3105} 3105}
3106 3106
@@ -3125,7 +3125,7 @@ static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf
3125 3125
3126 status = verify_attr_len(xdr, savep, attrlen); 3126 status = verify_attr_len(xdr, savep, attrlen);
3127xdr_error: 3127xdr_error:
3128 dprintk("%s: xdr returned %d!\n", __FUNCTION__, -status); 3128 dprintk("%s: xdr returned %d!\n", __func__, -status);
3129 return status; 3129 return status;
3130} 3130}
3131 3131
@@ -3193,7 +3193,7 @@ static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, cons
3193 if ((status = verify_attr_len(xdr, savep, attrlen)) == 0) 3193 if ((status = verify_attr_len(xdr, savep, attrlen)) == 0)
3194 fattr->valid = NFS_ATTR_FATTR | NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4; 3194 fattr->valid = NFS_ATTR_FATTR | NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4;
3195xdr_error: 3195xdr_error:
3196 dprintk("%s: xdr returned %d\n", __FUNCTION__, -status); 3196 dprintk("%s: xdr returned %d\n", __func__, -status);
3197 return status; 3197 return status;
3198} 3198}
3199 3199
@@ -3226,7 +3226,7 @@ static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo)
3226 3226
3227 status = verify_attr_len(xdr, savep, attrlen); 3227 status = verify_attr_len(xdr, savep, attrlen);
3228xdr_error: 3228xdr_error:
3229 dprintk("%s: xdr returned %d!\n", __FUNCTION__, -status); 3229 dprintk("%s: xdr returned %d!\n", __func__, -status);
3230 return status; 3230 return status;
3231} 3231}
3232 3232
@@ -3418,7 +3418,7 @@ static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res)
3418 3418
3419 return decode_delegation(xdr, res); 3419 return decode_delegation(xdr, res);
3420xdr_error: 3420xdr_error:
3421 dprintk("%s: Bitmap too large! Length = %u\n", __FUNCTION__, bmlen); 3421 dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen);
3422 return -EIO; 3422 return -EIO;
3423} 3423}
3424 3424
@@ -3575,7 +3575,7 @@ short_pkt:
3575 * the call was successful, but incomplete. The caller can retry the 3575 * the call was successful, but incomplete. The caller can retry the
3576 * readdir starting at the last cookie. 3576 * readdir starting at the last cookie.
3577 */ 3577 */
3578 dprintk("%s: short packet at entry %d\n", __FUNCTION__, nr); 3578 dprintk("%s: short packet at entry %d\n", __func__, nr);
3579 entry[0] = entry[1] = 0; 3579 entry[0] = entry[1] = 0;
3580 if (nr) 3580 if (nr)
3581 goto out; 3581 goto out;
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c
index 5ccf7faee19c..03599bfe81cf 100644
--- a/fs/nfs/proc.c
+++ b/fs/nfs/proc.c
@@ -63,17 +63,17 @@ nfs_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
63 }; 63 };
64 int status; 64 int status;
65 65
66 dprintk("%s: call getattr\n", __FUNCTION__); 66 dprintk("%s: call getattr\n", __func__);
67 nfs_fattr_init(fattr); 67 nfs_fattr_init(fattr);
68 status = rpc_call_sync(server->nfs_client->cl_rpcclient, &msg, 0); 68 status = rpc_call_sync(server->nfs_client->cl_rpcclient, &msg, 0);
69 dprintk("%s: reply getattr: %d\n", __FUNCTION__, status); 69 dprintk("%s: reply getattr: %d\n", __func__, status);
70 if (status) 70 if (status)
71 return status; 71 return status;
72 dprintk("%s: call statfs\n", __FUNCTION__); 72 dprintk("%s: call statfs\n", __func__);
73 msg.rpc_proc = &nfs_procedures[NFSPROC_STATFS]; 73 msg.rpc_proc = &nfs_procedures[NFSPROC_STATFS];
74 msg.rpc_resp = &fsinfo; 74 msg.rpc_resp = &fsinfo;
75 status = rpc_call_sync(server->nfs_client->cl_rpcclient, &msg, 0); 75 status = rpc_call_sync(server->nfs_client->cl_rpcclient, &msg, 0);
76 dprintk("%s: reply statfs: %d\n", __FUNCTION__, status); 76 dprintk("%s: reply statfs: %d\n", __func__, status);
77 if (status) 77 if (status)
78 return status; 78 return status;
79 info->rtmax = NFS_MAXDATA; 79 info->rtmax = NFS_MAXDATA;
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 16f57e0af999..40d17987d0e8 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -329,7 +329,7 @@ int nfs_readpage_result(struct rpc_task *task, struct nfs_read_data *data)
329{ 329{
330 int status; 330 int status;
331 331
332 dprintk("NFS: %s: %5u, (status %d)\n", __FUNCTION__, task->tk_pid, 332 dprintk("NFS: %s: %5u, (status %d)\n", __func__, task->tk_pid,
333 task->tk_status); 333 task->tk_status);
334 334
335 status = NFS_PROTO(data->inode)->read_done(task, data); 335 status = NFS_PROTO(data->inode)->read_done(task, data);
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 7226a506f3ca..2a4a024a4e7b 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -405,7 +405,7 @@ static int nfs_statfs(struct dentry *dentry, struct kstatfs *buf)
405 return 0; 405 return 0;
406 406
407 out_err: 407 out_err:
408 dprintk("%s: statfs error = %d\n", __FUNCTION__, -error); 408 dprintk("%s: statfs error = %d\n", __func__, -error);
409 unlock_kernel(); 409 unlock_kernel();
410 return error; 410 return error;
411} 411}
@@ -2015,6 +2015,10 @@ static int nfs4_get_sb(struct file_system_type *fs_type,
2015 goto error_splat_super; 2015 goto error_splat_super;
2016 } 2016 }
2017 2017
2018 error = security_sb_set_mnt_opts(s, &data.lsm_opts);
2019 if (error)
2020 goto error_splat_root;
2021
2018 s->s_flags |= MS_ACTIVE; 2022 s->s_flags |= MS_ACTIVE;
2019 mnt->mnt_sb = s; 2023 mnt->mnt_sb = s;
2020 mnt->mnt_root = mntroot; 2024 mnt->mnt_root = mntroot;
@@ -2031,6 +2035,8 @@ out_free:
2031 nfs_free_server(server); 2035 nfs_free_server(server);
2032 goto out; 2036 goto out;
2033 2037
2038error_splat_root:
2039 dput(mntroot);
2034error_splat_super: 2040error_splat_super:
2035 up_write(&s->s_umount); 2041 up_write(&s->s_umount);
2036 deactivate_super(s); 2042 deactivate_super(s);
@@ -2114,6 +2120,8 @@ static int nfs4_xdev_get_sb(struct file_system_type *fs_type, int flags,
2114 mnt->mnt_sb = s; 2120 mnt->mnt_sb = s;
2115 mnt->mnt_root = mntroot; 2121 mnt->mnt_root = mntroot;
2116 2122
2123 security_sb_clone_mnt_opts(data->sb, s);
2124
2117 dprintk("<-- nfs4_xdev_get_sb() = 0\n"); 2125 dprintk("<-- nfs4_xdev_get_sb() = 0\n");
2118 return 0; 2126 return 0;
2119 2127
@@ -2197,6 +2205,8 @@ static int nfs4_referral_get_sb(struct file_system_type *fs_type, int flags,
2197 mnt->mnt_sb = s; 2205 mnt->mnt_sb = s;
2198 mnt->mnt_root = mntroot; 2206 mnt->mnt_root = mntroot;
2199 2207
2208 security_sb_clone_mnt_opts(data->sb, s);
2209
2200 dprintk("<-- nfs4_referral_get_sb() = 0\n"); 2210 dprintk("<-- nfs4_referral_get_sb() = 0\n");
2201 return 0; 2211 return 0;
2202 2212
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 1ade11d1ba07..6d8ace3e3259 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -415,7 +415,7 @@ nfs_dirty_request(struct nfs_page *req)
415 415
416 if (page == NULL || test_bit(PG_NEED_COMMIT, &req->wb_flags)) 416 if (page == NULL || test_bit(PG_NEED_COMMIT, &req->wb_flags))
417 return 0; 417 return 0;
418 return !PageWriteback(req->wb_page); 418 return !PageWriteback(page);
419} 419}
420 420
421#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4) 421#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
index 0b3ffa9840c2..4d4760e687c3 100644
--- a/fs/nfsd/nfs4callback.c
+++ b/fs/nfsd/nfs4callback.c
@@ -419,9 +419,9 @@ static int do_probe_callback(void *data)
419out_release_client: 419out_release_client:
420 rpc_shutdown_client(client); 420 rpc_shutdown_client(client);
421out_err: 421out_err:
422 put_nfs4_client(clp);
423 dprintk("NFSD: warning: no callback path to client %.*s\n", 422 dprintk("NFSD: warning: no callback path to client %.*s\n",
424 (int)clp->cl_name.len, clp->cl_name.data); 423 (int)clp->cl_name.len, clp->cl_name.data);
424 put_nfs4_client(clp);
425 return status; 425 return status;
426} 426}
427 427
diff --git a/fs/ntfs/upcase.c b/fs/ntfs/upcase.c
index 9101807dc81a..e2f72ca98037 100644
--- a/fs/ntfs/upcase.c
+++ b/fs/ntfs/upcase.c
@@ -77,11 +77,10 @@ ntfschar *generate_default_upcase(void)
77 uc[i] = cpu_to_le16(i); 77 uc[i] = cpu_to_le16(i);
78 for (r = 0; uc_run_table[r][0]; r++) 78 for (r = 0; uc_run_table[r][0]; r++)
79 for (i = uc_run_table[r][0]; i < uc_run_table[r][1]; i++) 79 for (i = uc_run_table[r][0]; i < uc_run_table[r][1]; i++)
80 uc[i] = cpu_to_le16(le16_to_cpu(uc[i]) + 80 le16_add_cpu(&uc[i], uc_run_table[r][2]);
81 uc_run_table[r][2]);
82 for (r = 0; uc_dup_table[r][0]; r++) 81 for (r = 0; uc_dup_table[r][0]; r++)
83 for (i = uc_dup_table[r][0]; i < uc_dup_table[r][1]; i += 2) 82 for (i = uc_dup_table[r][0]; i < uc_dup_table[r][1]; i += 2)
84 uc[i + 1] = cpu_to_le16(le16_to_cpu(uc[i + 1]) - 1); 83 le16_add_cpu(&uc[i + 1], -1);
85 for (r = 0; uc_word_table[r][0]; r++) 84 for (r = 0; uc_word_table[r][0]; r++)
86 uc[uc_word_table[r][0]] = cpu_to_le16(uc_word_table[r][1]); 85 uc[uc_word_table[r][0]] = cpu_to_le16(uc_word_table[r][1]);
87 return uc; 86 return uc;
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 41f84c92094f..10bfb466e068 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -2788,7 +2788,7 @@ static int ocfs2_merge_rec_right(struct inode *inode,
2788 BUG_ON(index >= le16_to_cpu(el->l_next_free_rec)); 2788 BUG_ON(index >= le16_to_cpu(el->l_next_free_rec));
2789 left_rec = &el->l_recs[index]; 2789 left_rec = &el->l_recs[index];
2790 2790
2791 if (index == le16_to_cpu(el->l_next_free_rec - 1) && 2791 if (index == le16_to_cpu(el->l_next_free_rec) - 1 &&
2792 le16_to_cpu(el->l_next_free_rec) == le16_to_cpu(el->l_count)) { 2792 le16_to_cpu(el->l_next_free_rec) == le16_to_cpu(el->l_count)) {
2793 /* we meet with a cross extent block merge. */ 2793 /* we meet with a cross extent block merge. */
2794 ret = ocfs2_get_right_path(inode, left_path, &right_path); 2794 ret = ocfs2_get_right_path(inode, left_path, &right_path);
@@ -2802,7 +2802,7 @@ static int ocfs2_merge_rec_right(struct inode *inode,
2802 BUG_ON(next_free <= 0); 2802 BUG_ON(next_free <= 0);
2803 right_rec = &right_el->l_recs[0]; 2803 right_rec = &right_el->l_recs[0];
2804 if (ocfs2_is_empty_extent(right_rec)) { 2804 if (ocfs2_is_empty_extent(right_rec)) {
2805 BUG_ON(le16_to_cpu(next_free) <= 1); 2805 BUG_ON(next_free <= 1);
2806 right_rec = &right_el->l_recs[1]; 2806 right_rec = &right_el->l_recs[1];
2807 } 2807 }
2808 2808
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c
index 1e44ad14881a..a27d61581bd6 100644
--- a/fs/ocfs2/cluster/tcp.c
+++ b/fs/ocfs2/cluster/tcp.c
@@ -142,53 +142,43 @@ static void o2net_idle_timer(unsigned long data);
142static void o2net_sc_postpone_idle(struct o2net_sock_container *sc); 142static void o2net_sc_postpone_idle(struct o2net_sock_container *sc);
143static void o2net_sc_reset_idle_timer(struct o2net_sock_container *sc); 143static void o2net_sc_reset_idle_timer(struct o2net_sock_container *sc);
144 144
145static void o2net_init_nst(struct o2net_send_tracking *nst, u32 msgtype,
146 u32 msgkey, struct task_struct *task, u8 node)
147{
148#ifdef CONFIG_DEBUG_FS 145#ifdef CONFIG_DEBUG_FS
146void o2net_init_nst(struct o2net_send_tracking *nst, u32 msgtype,
147 u32 msgkey, struct task_struct *task, u8 node)
148{
149 INIT_LIST_HEAD(&nst->st_net_debug_item); 149 INIT_LIST_HEAD(&nst->st_net_debug_item);
150 nst->st_task = task; 150 nst->st_task = task;
151 nst->st_msg_type = msgtype; 151 nst->st_msg_type = msgtype;
152 nst->st_msg_key = msgkey; 152 nst->st_msg_key = msgkey;
153 nst->st_node = node; 153 nst->st_node = node;
154#endif
155} 154}
156 155
157static void o2net_set_nst_sock_time(struct o2net_send_tracking *nst) 156void o2net_set_nst_sock_time(struct o2net_send_tracking *nst)
158{ 157{
159#ifdef CONFIG_DEBUG_FS
160 do_gettimeofday(&nst->st_sock_time); 158 do_gettimeofday(&nst->st_sock_time);
161#endif
162} 159}
163 160
164static void o2net_set_nst_send_time(struct o2net_send_tracking *nst) 161void o2net_set_nst_send_time(struct o2net_send_tracking *nst)
165{ 162{
166#ifdef CONFIG_DEBUG_FS
167 do_gettimeofday(&nst->st_send_time); 163 do_gettimeofday(&nst->st_send_time);
168#endif
169} 164}
170 165
171static void o2net_set_nst_status_time(struct o2net_send_tracking *nst) 166void o2net_set_nst_status_time(struct o2net_send_tracking *nst)
172{ 167{
173#ifdef CONFIG_DEBUG_FS
174 do_gettimeofday(&nst->st_status_time); 168 do_gettimeofday(&nst->st_status_time);
175#endif
176} 169}
177 170
178static void o2net_set_nst_sock_container(struct o2net_send_tracking *nst, 171void o2net_set_nst_sock_container(struct o2net_send_tracking *nst,
179 struct o2net_sock_container *sc) 172 struct o2net_sock_container *sc)
180{ 173{
181#ifdef CONFIG_DEBUG_FS
182 nst->st_sc = sc; 174 nst->st_sc = sc;
183#endif
184} 175}
185 176
186static void o2net_set_nst_msg_id(struct o2net_send_tracking *nst, u32 msg_id) 177void o2net_set_nst_msg_id(struct o2net_send_tracking *nst, u32 msg_id)
187{ 178{
188#ifdef CONFIG_DEBUG_FS
189 nst->st_id = msg_id; 179 nst->st_id = msg_id;
190#endif
191} 180}
181#endif /* CONFIG_DEBUG_FS */
192 182
193static inline int o2net_reconnect_delay(void) 183static inline int o2net_reconnect_delay(void)
194{ 184{
diff --git a/fs/ocfs2/cluster/tcp.h b/fs/ocfs2/cluster/tcp.h
index a705d5d19036..fd6179eb26d4 100644
--- a/fs/ocfs2/cluster/tcp.h
+++ b/fs/ocfs2/cluster/tcp.h
@@ -128,23 +128,23 @@ void o2net_debug_del_nst(struct o2net_send_tracking *nst);
128void o2net_debug_add_sc(struct o2net_sock_container *sc); 128void o2net_debug_add_sc(struct o2net_sock_container *sc);
129void o2net_debug_del_sc(struct o2net_sock_container *sc); 129void o2net_debug_del_sc(struct o2net_sock_container *sc);
130#else 130#else
131static int o2net_debugfs_init(void) 131static inline int o2net_debugfs_init(void)
132{ 132{
133 return 0; 133 return 0;
134} 134}
135static void o2net_debugfs_exit(void) 135static inline void o2net_debugfs_exit(void)
136{ 136{
137} 137}
138static void o2net_debug_add_nst(struct o2net_send_tracking *nst) 138static inline void o2net_debug_add_nst(struct o2net_send_tracking *nst)
139{ 139{
140} 140}
141static void o2net_debug_del_nst(struct o2net_send_tracking *nst) 141static inline void o2net_debug_del_nst(struct o2net_send_tracking *nst)
142{ 142{
143} 143}
144static void o2net_debug_add_sc(struct o2net_sock_container *sc) 144static inline void o2net_debug_add_sc(struct o2net_sock_container *sc)
145{ 145{
146} 146}
147static void o2net_debug_del_sc(struct o2net_sock_container *sc) 147static inline void o2net_debug_del_sc(struct o2net_sock_container *sc)
148{ 148{
149} 149}
150#endif /* CONFIG_DEBUG_FS */ 150#endif /* CONFIG_DEBUG_FS */
diff --git a/fs/ocfs2/cluster/tcp_internal.h b/fs/ocfs2/cluster/tcp_internal.h
index 8d58cfe410b1..18307ff81b77 100644
--- a/fs/ocfs2/cluster/tcp_internal.h
+++ b/fs/ocfs2/cluster/tcp_internal.h
@@ -224,10 +224,42 @@ struct o2net_send_tracking {
224 struct timeval st_send_time; 224 struct timeval st_send_time;
225 struct timeval st_status_time; 225 struct timeval st_status_time;
226}; 226};
227
228void o2net_init_nst(struct o2net_send_tracking *nst, u32 msgtype,
229 u32 msgkey, struct task_struct *task, u8 node);
230void o2net_set_nst_sock_time(struct o2net_send_tracking *nst);
231void o2net_set_nst_send_time(struct o2net_send_tracking *nst);
232void o2net_set_nst_status_time(struct o2net_send_tracking *nst);
233void o2net_set_nst_sock_container(struct o2net_send_tracking *nst,
234 struct o2net_sock_container *sc);
235void o2net_set_nst_msg_id(struct o2net_send_tracking *nst, u32 msg_id);
236
227#else 237#else
228struct o2net_send_tracking { 238struct o2net_send_tracking {
229 u32 dummy; 239 u32 dummy;
230}; 240};
241
242static inline void o2net_init_nst(struct o2net_send_tracking *nst, u32 msgtype,
243 u32 msgkey, struct task_struct *task, u8 node)
244{
245}
246static inline void o2net_set_nst_sock_time(struct o2net_send_tracking *nst)
247{
248}
249static inline void o2net_set_nst_send_time(struct o2net_send_tracking *nst)
250{
251}
252static inline void o2net_set_nst_status_time(struct o2net_send_tracking *nst)
253{
254}
255static inline void o2net_set_nst_sock_container(struct o2net_send_tracking *nst,
256 struct o2net_sock_container *sc)
257{
258}
259static inline void o2net_set_nst_msg_id(struct o2net_send_tracking *nst,
260 u32 msg_id)
261{
262}
231#endif /* CONFIG_DEBUG_FS */ 263#endif /* CONFIG_DEBUG_FS */
232 264
233#endif /* O2CLUSTER_TCP_INTERNAL_H */ 265#endif /* O2CLUSTER_TCP_INTERNAL_H */
diff --git a/fs/ocfs2/dlm/dlmdebug.h b/fs/ocfs2/dlm/dlmdebug.h
index d34a62a3a625..8c686d22f9c7 100644
--- a/fs/ocfs2/dlm/dlmdebug.h
+++ b/fs/ocfs2/dlm/dlmdebug.h
@@ -60,25 +60,25 @@ void dlm_destroy_debugfs_root(void);
60 60
61#else 61#else
62 62
63static int dlm_debug_init(struct dlm_ctxt *dlm) 63static inline int dlm_debug_init(struct dlm_ctxt *dlm)
64{ 64{
65 return 0; 65 return 0;
66} 66}
67static void dlm_debug_shutdown(struct dlm_ctxt *dlm) 67static inline void dlm_debug_shutdown(struct dlm_ctxt *dlm)
68{ 68{
69} 69}
70static int dlm_create_debugfs_subroot(struct dlm_ctxt *dlm) 70static inline int dlm_create_debugfs_subroot(struct dlm_ctxt *dlm)
71{ 71{
72 return 0; 72 return 0;
73} 73}
74static void dlm_destroy_debugfs_subroot(struct dlm_ctxt *dlm) 74static inline void dlm_destroy_debugfs_subroot(struct dlm_ctxt *dlm)
75{ 75{
76} 76}
77static int dlm_create_debugfs_root(void) 77static inline int dlm_create_debugfs_root(void)
78{ 78{
79 return 0; 79 return 0;
80} 80}
81static void dlm_destroy_debugfs_root(void) 81static inline void dlm_destroy_debugfs_root(void)
82{ 82{
83} 83}
84 84
diff --git a/fs/ocfs2/stack_user.c b/fs/ocfs2/stack_user.c
index b503772cd0ec..6b97d11f6bf8 100644
--- a/fs/ocfs2/stack_user.c
+++ b/fs/ocfs2/stack_user.c
@@ -61,7 +61,7 @@
61 * negotiated by the client. The client negotiates based on the maximum 61 * negotiated by the client. The client negotiates based on the maximum
62 * version advertised in /sys/fs/ocfs2/max_locking_protocol. The major 62 * version advertised in /sys/fs/ocfs2/max_locking_protocol. The major
63 * number from the "SETV" message must match 63 * number from the "SETV" message must match
64 * user_stack.sp_proto->lp_max_version.pv_major, and the minor number 64 * ocfs2_user_plugin.sp_proto->lp_max_version.pv_major, and the minor number
65 * must be less than or equal to ...->lp_max_version.pv_minor. 65 * must be less than or equal to ...->lp_max_version.pv_minor.
66 * 66 *
67 * Once this information has been set, mounts will be allowed. From this 67 * Once this information has been set, mounts will be allowed. From this
@@ -153,7 +153,7 @@ union ocfs2_control_message {
153 struct ocfs2_control_message_down u_down; 153 struct ocfs2_control_message_down u_down;
154}; 154};
155 155
156static struct ocfs2_stack_plugin user_stack; 156static struct ocfs2_stack_plugin ocfs2_user_plugin;
157 157
158static atomic_t ocfs2_control_opened; 158static atomic_t ocfs2_control_opened;
159static int ocfs2_control_this_node = -1; 159static int ocfs2_control_this_node = -1;
@@ -399,7 +399,7 @@ static int ocfs2_control_do_setversion_msg(struct file *file,
399 char *ptr = NULL; 399 char *ptr = NULL;
400 struct ocfs2_control_private *p = file->private_data; 400 struct ocfs2_control_private *p = file->private_data;
401 struct ocfs2_protocol_version *max = 401 struct ocfs2_protocol_version *max =
402 &user_stack.sp_proto->lp_max_version; 402 &ocfs2_user_plugin.sp_proto->lp_max_version;
403 403
404 if (ocfs2_control_get_handshake_state(file) != 404 if (ocfs2_control_get_handshake_state(file) !=
405 OCFS2_CONTROL_HANDSHAKE_PROTOCOL) 405 OCFS2_CONTROL_HANDSHAKE_PROTOCOL)
@@ -680,7 +680,7 @@ static void fsdlm_lock_ast_wrapper(void *astarg)
680 struct dlm_lksb *lksb = fsdlm_astarg_to_lksb(astarg); 680 struct dlm_lksb *lksb = fsdlm_astarg_to_lksb(astarg);
681 int status = lksb->sb_status; 681 int status = lksb->sb_status;
682 682
683 BUG_ON(user_stack.sp_proto == NULL); 683 BUG_ON(ocfs2_user_plugin.sp_proto == NULL);
684 684
685 /* 685 /*
686 * For now we're punting on the issue of other non-standard errors 686 * For now we're punting on the issue of other non-standard errors
@@ -693,16 +693,16 @@ static void fsdlm_lock_ast_wrapper(void *astarg)
693 */ 693 */
694 694
695 if (status == -DLM_EUNLOCK || status == -DLM_ECANCEL) 695 if (status == -DLM_EUNLOCK || status == -DLM_ECANCEL)
696 user_stack.sp_proto->lp_unlock_ast(astarg, 0); 696 ocfs2_user_plugin.sp_proto->lp_unlock_ast(astarg, 0);
697 else 697 else
698 user_stack.sp_proto->lp_lock_ast(astarg); 698 ocfs2_user_plugin.sp_proto->lp_lock_ast(astarg);
699} 699}
700 700
701static void fsdlm_blocking_ast_wrapper(void *astarg, int level) 701static void fsdlm_blocking_ast_wrapper(void *astarg, int level)
702{ 702{
703 BUG_ON(user_stack.sp_proto == NULL); 703 BUG_ON(ocfs2_user_plugin.sp_proto == NULL);
704 704
705 user_stack.sp_proto->lp_blocking_ast(astarg, level); 705 ocfs2_user_plugin.sp_proto->lp_blocking_ast(astarg, level);
706} 706}
707 707
708static int user_dlm_lock(struct ocfs2_cluster_connection *conn, 708static int user_dlm_lock(struct ocfs2_cluster_connection *conn,
@@ -838,7 +838,7 @@ static int user_cluster_this_node(unsigned int *this_node)
838 return 0; 838 return 0;
839} 839}
840 840
841static struct ocfs2_stack_operations user_stack_ops = { 841static struct ocfs2_stack_operations ocfs2_user_plugin_ops = {
842 .connect = user_cluster_connect, 842 .connect = user_cluster_connect,
843 .disconnect = user_cluster_disconnect, 843 .disconnect = user_cluster_disconnect,
844 .this_node = user_cluster_this_node, 844 .this_node = user_cluster_this_node,
@@ -849,20 +849,20 @@ static struct ocfs2_stack_operations user_stack_ops = {
849 .dump_lksb = user_dlm_dump_lksb, 849 .dump_lksb = user_dlm_dump_lksb,
850}; 850};
851 851
852static struct ocfs2_stack_plugin user_stack = { 852static struct ocfs2_stack_plugin ocfs2_user_plugin = {
853 .sp_name = "user", 853 .sp_name = "user",
854 .sp_ops = &user_stack_ops, 854 .sp_ops = &ocfs2_user_plugin_ops,
855 .sp_owner = THIS_MODULE, 855 .sp_owner = THIS_MODULE,
856}; 856};
857 857
858 858
859static int __init user_stack_init(void) 859static int __init ocfs2_user_plugin_init(void)
860{ 860{
861 int rc; 861 int rc;
862 862
863 rc = ocfs2_control_init(); 863 rc = ocfs2_control_init();
864 if (!rc) { 864 if (!rc) {
865 rc = ocfs2_stack_glue_register(&user_stack); 865 rc = ocfs2_stack_glue_register(&ocfs2_user_plugin);
866 if (rc) 866 if (rc)
867 ocfs2_control_exit(); 867 ocfs2_control_exit();
868 } 868 }
@@ -870,14 +870,14 @@ static int __init user_stack_init(void)
870 return rc; 870 return rc;
871} 871}
872 872
873static void __exit user_stack_exit(void) 873static void __exit ocfs2_user_plugin_exit(void)
874{ 874{
875 ocfs2_stack_glue_unregister(&user_stack); 875 ocfs2_stack_glue_unregister(&ocfs2_user_plugin);
876 ocfs2_control_exit(); 876 ocfs2_control_exit();
877} 877}
878 878
879MODULE_AUTHOR("Oracle"); 879MODULE_AUTHOR("Oracle");
880MODULE_DESCRIPTION("ocfs2 driver for userspace cluster stacks"); 880MODULE_DESCRIPTION("ocfs2 driver for userspace cluster stacks");
881MODULE_LICENSE("GPL"); 881MODULE_LICENSE("GPL");
882module_init(user_stack_init); 882module_init(ocfs2_user_plugin_init);
883module_exit(user_stack_exit); 883module_exit(ocfs2_user_plugin_exit);
diff --git a/fs/proc/array.c b/fs/proc/array.c
index dca997a93bff..797d775e0354 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -288,7 +288,7 @@ static void render_cap_t(struct seq_file *m, const char *header,
288 seq_printf(m, "%s", header); 288 seq_printf(m, "%s", header);
289 CAP_FOR_EACH_U32(__capi) { 289 CAP_FOR_EACH_U32(__capi) {
290 seq_printf(m, "%08x", 290 seq_printf(m, "%08x",
291 a->cap[(_LINUX_CAPABILITY_U32S-1) - __capi]); 291 a->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
292 } 292 }
293 seq_printf(m, "\n"); 293 seq_printf(m, "\n");
294} 294}
@@ -298,6 +298,7 @@ static inline void task_cap(struct seq_file *m, struct task_struct *p)
298 render_cap_t(m, "CapInh:\t", &p->cap_inheritable); 298 render_cap_t(m, "CapInh:\t", &p->cap_inheritable);
299 render_cap_t(m, "CapPrm:\t", &p->cap_permitted); 299 render_cap_t(m, "CapPrm:\t", &p->cap_permitted);
300 render_cap_t(m, "CapEff:\t", &p->cap_effective); 300 render_cap_t(m, "CapEff:\t", &p->cap_effective);
301 render_cap_t(m, "CapBnd:\t", &p->cap_bset);
301} 302}
302 303
303static inline void task_context_switch_counts(struct seq_file *m, 304static inline void task_context_switch_counts(struct seq_file *m,
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 808cbdc193d3..3b455371e7ff 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -127,6 +127,25 @@ struct pid_entry {
127 NULL, &proc_single_file_operations, \ 127 NULL, &proc_single_file_operations, \
128 { .proc_show = &proc_##OTYPE } ) 128 { .proc_show = &proc_##OTYPE } )
129 129
130/*
131 * Count the number of hardlinks for the pid_entry table, excluding the .
132 * and .. links.
133 */
134static unsigned int pid_entry_count_dirs(const struct pid_entry *entries,
135 unsigned int n)
136{
137 unsigned int i;
138 unsigned int count;
139
140 count = 0;
141 for (i = 0; i < n; ++i) {
142 if (S_ISDIR(entries[i].mode))
143 ++count;
144 }
145
146 return count;
147}
148
130int maps_protect; 149int maps_protect;
131EXPORT_SYMBOL(maps_protect); 150EXPORT_SYMBOL(maps_protect);
132 151
@@ -2441,7 +2460,7 @@ static const struct pid_entry tgid_base_stuff[] = {
2441 REG("oom_adj", S_IRUGO|S_IWUSR, oom_adjust), 2460 REG("oom_adj", S_IRUGO|S_IWUSR, oom_adjust),
2442#ifdef CONFIG_AUDITSYSCALL 2461#ifdef CONFIG_AUDITSYSCALL
2443 REG("loginuid", S_IWUSR|S_IRUGO, loginuid), 2462 REG("loginuid", S_IWUSR|S_IRUGO, loginuid),
2444 REG("sessionid", S_IRUSR, sessionid), 2463 REG("sessionid", S_IRUGO, sessionid),
2445#endif 2464#endif
2446#ifdef CONFIG_FAULT_INJECTION 2465#ifdef CONFIG_FAULT_INJECTION
2447 REG("make-it-fail", S_IRUGO|S_IWUSR, fault_inject), 2466 REG("make-it-fail", S_IRUGO|S_IWUSR, fault_inject),
@@ -2585,10 +2604,9 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
2585 inode->i_op = &proc_tgid_base_inode_operations; 2604 inode->i_op = &proc_tgid_base_inode_operations;
2586 inode->i_fop = &proc_tgid_base_operations; 2605 inode->i_fop = &proc_tgid_base_operations;
2587 inode->i_flags|=S_IMMUTABLE; 2606 inode->i_flags|=S_IMMUTABLE;
2588 inode->i_nlink = 5; 2607
2589#ifdef CONFIG_SECURITY 2608 inode->i_nlink = 2 + pid_entry_count_dirs(tgid_base_stuff,
2590 inode->i_nlink += 1; 2609 ARRAY_SIZE(tgid_base_stuff));
2591#endif
2592 2610
2593 dentry->d_op = &pid_dentry_operations; 2611 dentry->d_op = &pid_dentry_operations;
2594 2612
@@ -2816,10 +2834,9 @@ static struct dentry *proc_task_instantiate(struct inode *dir,
2816 inode->i_op = &proc_tid_base_inode_operations; 2834 inode->i_op = &proc_tid_base_inode_operations;
2817 inode->i_fop = &proc_tid_base_operations; 2835 inode->i_fop = &proc_tid_base_operations;
2818 inode->i_flags|=S_IMMUTABLE; 2836 inode->i_flags|=S_IMMUTABLE;
2819 inode->i_nlink = 4; 2837
2820#ifdef CONFIG_SECURITY 2838 inode->i_nlink = 2 + pid_entry_count_dirs(tid_base_stuff,
2821 inode->i_nlink += 1; 2839 ARRAY_SIZE(tid_base_stuff));
2822#endif
2823 2840
2824 dentry->d_op = &pid_dentry_operations; 2841 dentry->d_op = &pid_dentry_operations;
2825 2842
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 6f4e8dc97da1..b08d10017911 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -425,7 +425,8 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino,
425 } 425 }
426 } 426 }
427 unlock_new_inode(inode); 427 unlock_new_inode(inode);
428 } 428 } else
429 module_put(de->owner);
429 return inode; 430 return inode;
430 431
431out_ino: 432out_ino:
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index 74a323d2b850..7e277f2ad466 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -139,7 +139,7 @@ static int meminfo_read_proc(char *page, char **start, off_t off,
139#define K(x) ((x) << (PAGE_SHIFT - 10)) 139#define K(x) ((x) << (PAGE_SHIFT - 10))
140 si_meminfo(&i); 140 si_meminfo(&i);
141 si_swapinfo(&i); 141 si_swapinfo(&i);
142 committed = atomic_read(&vm_committed_space); 142 committed = atomic_long_read(&vm_committed_space);
143 allowed = ((totalram_pages - hugetlb_total_pages()) 143 allowed = ((totalram_pages - hugetlb_total_pages())
144 * sysctl_overcommit_ratio / 100) + total_swap_pages; 144 * sysctl_overcommit_ratio / 100) + total_swap_pages;
145 145
@@ -716,7 +716,7 @@ static ssize_t kpagecount_read(struct file *file, char __user *buf,
716 pfn = src / KPMSIZE; 716 pfn = src / KPMSIZE;
717 count = min_t(size_t, count, (max_pfn * KPMSIZE) - src); 717 count = min_t(size_t, count, (max_pfn * KPMSIZE) - src);
718 if (src & KPMMASK || count & KPMMASK) 718 if (src & KPMMASK || count & KPMMASK)
719 return -EIO; 719 return -EINVAL;
720 720
721 while (count > 0) { 721 while (count > 0) {
722 ppage = NULL; 722 ppage = NULL;
@@ -726,7 +726,7 @@ static ssize_t kpagecount_read(struct file *file, char __user *buf,
726 if (!ppage) 726 if (!ppage)
727 pcount = 0; 727 pcount = 0;
728 else 728 else
729 pcount = atomic_read(&ppage->_count); 729 pcount = page_mapcount(ppage);
730 730
731 if (put_user(pcount, out++)) { 731 if (put_user(pcount, out++)) {
732 ret = -EFAULT; 732 ret = -EFAULT;
@@ -782,7 +782,7 @@ static ssize_t kpageflags_read(struct file *file, char __user *buf,
782 pfn = src / KPMSIZE; 782 pfn = src / KPMSIZE;
783 count = min_t(unsigned long, count, (max_pfn * KPMSIZE) - src); 783 count = min_t(unsigned long, count, (max_pfn * KPMSIZE) - src);
784 if (src & KPMMASK || count & KPMMASK) 784 if (src & KPMMASK || count & KPMMASK)
785 return -EIO; 785 return -EINVAL;
786 786
787 while (count > 0) { 787 while (count > 0) {
788 ppage = NULL; 788 ppage = NULL;
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 88717c0f941b..ab8ccc9d14ff 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -315,9 +315,9 @@ struct mem_size_stats {
315}; 315};
316 316
317static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, 317static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
318 void *private) 318 struct mm_walk *walk)
319{ 319{
320 struct mem_size_stats *mss = private; 320 struct mem_size_stats *mss = walk->private;
321 struct vm_area_struct *vma = mss->vma; 321 struct vm_area_struct *vma = mss->vma;
322 pte_t *pte, ptent; 322 pte_t *pte, ptent;
323 spinlock_t *ptl; 323 spinlock_t *ptl;
@@ -365,19 +365,21 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
365 return 0; 365 return 0;
366} 366}
367 367
368static struct mm_walk smaps_walk = { .pmd_entry = smaps_pte_range };
369
370static int show_smap(struct seq_file *m, void *v) 368static int show_smap(struct seq_file *m, void *v)
371{ 369{
372 struct vm_area_struct *vma = v; 370 struct vm_area_struct *vma = v;
373 struct mem_size_stats mss; 371 struct mem_size_stats mss;
374 int ret; 372 int ret;
373 struct mm_walk smaps_walk = {
374 .pmd_entry = smaps_pte_range,
375 .mm = vma->vm_mm,
376 .private = &mss,
377 };
375 378
376 memset(&mss, 0, sizeof mss); 379 memset(&mss, 0, sizeof mss);
377 mss.vma = vma; 380 mss.vma = vma;
378 if (vma->vm_mm && !is_vm_hugetlb_page(vma)) 381 if (vma->vm_mm && !is_vm_hugetlb_page(vma))
379 walk_page_range(vma->vm_mm, vma->vm_start, vma->vm_end, 382 walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
380 &smaps_walk, &mss);
381 383
382 ret = show_map(m, v); 384 ret = show_map(m, v);
383 if (ret) 385 if (ret)
@@ -426,9 +428,9 @@ const struct file_operations proc_smaps_operations = {
426}; 428};
427 429
428static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr, 430static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr,
429 unsigned long end, void *private) 431 unsigned long end, struct mm_walk *walk)
430{ 432{
431 struct vm_area_struct *vma = private; 433 struct vm_area_struct *vma = walk->private;
432 pte_t *pte, ptent; 434 pte_t *pte, ptent;
433 spinlock_t *ptl; 435 spinlock_t *ptl;
434 struct page *page; 436 struct page *page;
@@ -452,8 +454,6 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr,
452 return 0; 454 return 0;
453} 455}
454 456
455static struct mm_walk clear_refs_walk = { .pmd_entry = clear_refs_pte_range };
456
457static ssize_t clear_refs_write(struct file *file, const char __user *buf, 457static ssize_t clear_refs_write(struct file *file, const char __user *buf,
458 size_t count, loff_t *ppos) 458 size_t count, loff_t *ppos)
459{ 459{
@@ -476,11 +476,17 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
476 return -ESRCH; 476 return -ESRCH;
477 mm = get_task_mm(task); 477 mm = get_task_mm(task);
478 if (mm) { 478 if (mm) {
479 static struct mm_walk clear_refs_walk;
480 memset(&clear_refs_walk, 0, sizeof(clear_refs_walk));
481 clear_refs_walk.pmd_entry = clear_refs_pte_range;
482 clear_refs_walk.mm = mm;
479 down_read(&mm->mmap_sem); 483 down_read(&mm->mmap_sem);
480 for (vma = mm->mmap; vma; vma = vma->vm_next) 484 for (vma = mm->mmap; vma; vma = vma->vm_next) {
485 clear_refs_walk.private = vma;
481 if (!is_vm_hugetlb_page(vma)) 486 if (!is_vm_hugetlb_page(vma))
482 walk_page_range(mm, vma->vm_start, vma->vm_end, 487 walk_page_range(vma->vm_start, vma->vm_end,
483 &clear_refs_walk, vma); 488 &clear_refs_walk);
489 }
484 flush_tlb_mm(mm); 490 flush_tlb_mm(mm);
485 up_read(&mm->mmap_sem); 491 up_read(&mm->mmap_sem);
486 mmput(mm); 492 mmput(mm);
@@ -496,7 +502,7 @@ const struct file_operations proc_clear_refs_operations = {
496}; 502};
497 503
498struct pagemapread { 504struct pagemapread {
499 char __user *out, *end; 505 u64 __user *out, *end;
500}; 506};
501 507
502#define PM_ENTRY_BYTES sizeof(u64) 508#define PM_ENTRY_BYTES sizeof(u64)
@@ -519,28 +525,18 @@ struct pagemapread {
519static int add_to_pagemap(unsigned long addr, u64 pfn, 525static int add_to_pagemap(unsigned long addr, u64 pfn,
520 struct pagemapread *pm) 526 struct pagemapread *pm)
521{ 527{
522 /*
523 * Make sure there's room in the buffer for an
524 * entire entry. Otherwise, only copy part of
525 * the pfn.
526 */
527 if (pm->out + PM_ENTRY_BYTES >= pm->end) {
528 if (copy_to_user(pm->out, &pfn, pm->end - pm->out))
529 return -EFAULT;
530 pm->out = pm->end;
531 return PM_END_OF_BUFFER;
532 }
533
534 if (put_user(pfn, pm->out)) 528 if (put_user(pfn, pm->out))
535 return -EFAULT; 529 return -EFAULT;
536 pm->out += PM_ENTRY_BYTES; 530 pm->out++;
531 if (pm->out >= pm->end)
532 return PM_END_OF_BUFFER;
537 return 0; 533 return 0;
538} 534}
539 535
540static int pagemap_pte_hole(unsigned long start, unsigned long end, 536static int pagemap_pte_hole(unsigned long start, unsigned long end,
541 void *private) 537 struct mm_walk *walk)
542{ 538{
543 struct pagemapread *pm = private; 539 struct pagemapread *pm = walk->private;
544 unsigned long addr; 540 unsigned long addr;
545 int err = 0; 541 int err = 0;
546 for (addr = start; addr < end; addr += PAGE_SIZE) { 542 for (addr = start; addr < end; addr += PAGE_SIZE) {
@@ -557,24 +553,45 @@ static u64 swap_pte_to_pagemap_entry(pte_t pte)
557 return swp_type(e) | (swp_offset(e) << MAX_SWAPFILES_SHIFT); 553 return swp_type(e) | (swp_offset(e) << MAX_SWAPFILES_SHIFT);
558} 554}
559 555
556static unsigned long pte_to_pagemap_entry(pte_t pte)
557{
558 unsigned long pme = 0;
559 if (is_swap_pte(pte))
560 pme = PM_PFRAME(swap_pte_to_pagemap_entry(pte))
561 | PM_PSHIFT(PAGE_SHIFT) | PM_SWAP;
562 else if (pte_present(pte))
563 pme = PM_PFRAME(pte_pfn(pte))
564 | PM_PSHIFT(PAGE_SHIFT) | PM_PRESENT;
565 return pme;
566}
567
560static int pagemap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, 568static int pagemap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
561 void *private) 569 struct mm_walk *walk)
562{ 570{
563 struct pagemapread *pm = private; 571 struct vm_area_struct *vma;
572 struct pagemapread *pm = walk->private;
564 pte_t *pte; 573 pte_t *pte;
565 int err = 0; 574 int err = 0;
566 575
576 /* find the first VMA at or above 'addr' */
577 vma = find_vma(walk->mm, addr);
567 for (; addr != end; addr += PAGE_SIZE) { 578 for (; addr != end; addr += PAGE_SIZE) {
568 u64 pfn = PM_NOT_PRESENT; 579 u64 pfn = PM_NOT_PRESENT;
569 pte = pte_offset_map(pmd, addr); 580
570 if (is_swap_pte(*pte)) 581 /* check to see if we've left 'vma' behind
571 pfn = PM_PFRAME(swap_pte_to_pagemap_entry(*pte)) 582 * and need a new, higher one */
572 | PM_PSHIFT(PAGE_SHIFT) | PM_SWAP; 583 if (vma && (addr >= vma->vm_end))
573 else if (pte_present(*pte)) 584 vma = find_vma(walk->mm, addr);
574 pfn = PM_PFRAME(pte_pfn(*pte)) 585
575 | PM_PSHIFT(PAGE_SHIFT) | PM_PRESENT; 586 /* check that 'vma' actually covers this address,
576 /* unmap so we're not in atomic when we copy to userspace */ 587 * and that it isn't a huge page vma */
577 pte_unmap(pte); 588 if (vma && (vma->vm_start <= addr) &&
589 !is_vm_hugetlb_page(vma)) {
590 pte = pte_offset_map(pmd, addr);
591 pfn = pte_to_pagemap_entry(*pte);
592 /* unmap before userspace copy */
593 pte_unmap(pte);
594 }
578 err = add_to_pagemap(addr, pfn, pm); 595 err = add_to_pagemap(addr, pfn, pm);
579 if (err) 596 if (err)
580 return err; 597 return err;
@@ -634,7 +651,7 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
634 651
635 ret = -EINVAL; 652 ret = -EINVAL;
636 /* file position must be aligned */ 653 /* file position must be aligned */
637 if (*ppos % PM_ENTRY_BYTES) 654 if ((*ppos % PM_ENTRY_BYTES) || (count % PM_ENTRY_BYTES))
638 goto out_task; 655 goto out_task;
639 656
640 ret = 0; 657 ret = 0;
@@ -664,8 +681,8 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
664 goto out_pages; 681 goto out_pages;
665 } 682 }
666 683
667 pm.out = buf; 684 pm.out = (u64 *)buf;
668 pm.end = buf + count; 685 pm.end = (u64 *)(buf + count);
669 686
670 if (!ptrace_may_attach(task)) { 687 if (!ptrace_may_attach(task)) {
671 ret = -EIO; 688 ret = -EIO;
@@ -685,14 +702,14 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
685 * user buffer is tracked in "pm", and the walk 702 * user buffer is tracked in "pm", and the walk
686 * will stop when we hit the end of the buffer. 703 * will stop when we hit the end of the buffer.
687 */ 704 */
688 ret = walk_page_range(mm, start_vaddr, end_vaddr, 705 ret = walk_page_range(start_vaddr, end_vaddr,
689 &pagemap_walk, &pm); 706 &pagemap_walk);
690 if (ret == PM_END_OF_BUFFER) 707 if (ret == PM_END_OF_BUFFER)
691 ret = 0; 708 ret = 0;
692 /* don't need mmap_sem for these, but this looks cleaner */ 709 /* don't need mmap_sem for these, but this looks cleaner */
693 *ppos += pm.out - buf; 710 *ppos += (char *)pm.out - buf;
694 if (!ret) 711 if (!ret)
695 ret = pm.out - buf; 712 ret = (char *)pm.out - buf;
696 } 713 }
697 714
698out_pages: 715out_pages:
diff --git a/fs/splice.c b/fs/splice.c
index 78150038b584..aa5f6f60b305 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -58,8 +58,8 @@ static int page_cache_pipe_buf_steal(struct pipe_inode_info *pipe,
58 */ 58 */
59 wait_on_page_writeback(page); 59 wait_on_page_writeback(page);
60 60
61 if (PagePrivate(page)) 61 if (PagePrivate(page) && !try_to_release_page(page, GFP_KERNEL))
62 try_to_release_page(page, GFP_KERNEL); 62 goto out_unlock;
63 63
64 /* 64 /*
65 * If we succeeded in removing the mapping, set LRU flag 65 * If we succeeded in removing the mapping, set LRU flag
@@ -75,6 +75,7 @@ static int page_cache_pipe_buf_steal(struct pipe_inode_info *pipe,
75 * Raced with truncate or failed to remove page from current 75 * Raced with truncate or failed to remove page from current
76 * address space, unlock and return failure. 76 * address space, unlock and return failure.
77 */ 77 */
78out_unlock:
78 unlock_page(page); 79 unlock_page(page);
79 return 1; 80 return 1;
80} 81}
@@ -983,7 +984,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
983 984
984 while (len) { 985 while (len) {
985 size_t read_len; 986 size_t read_len;
986 loff_t pos = sd->pos; 987 loff_t pos = sd->pos, prev_pos = pos;
987 988
988 ret = do_splice_to(in, &pos, pipe, len, flags); 989 ret = do_splice_to(in, &pos, pipe, len, flags);
989 if (unlikely(ret <= 0)) 990 if (unlikely(ret <= 0))
@@ -998,15 +999,19 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
998 * could get stuck data in the internal pipe: 999 * could get stuck data in the internal pipe:
999 */ 1000 */
1000 ret = actor(pipe, sd); 1001 ret = actor(pipe, sd);
1001 if (unlikely(ret <= 0)) 1002 if (unlikely(ret <= 0)) {
1003 sd->pos = prev_pos;
1002 goto out_release; 1004 goto out_release;
1005 }
1003 1006
1004 bytes += ret; 1007 bytes += ret;
1005 len -= ret; 1008 len -= ret;
1006 sd->pos = pos; 1009 sd->pos = pos;
1007 1010
1008 if (ret < read_len) 1011 if (ret < read_len) {
1012 sd->pos = prev_pos + ret;
1009 goto out_release; 1013 goto out_release;
1014 }
1010 } 1015 }
1011 1016
1012done: 1017done:
@@ -1072,7 +1077,7 @@ long do_splice_direct(struct file *in, loff_t *ppos, struct file *out,
1072 1077
1073 ret = splice_direct_to_actor(in, &sd, direct_splice_actor); 1078 ret = splice_direct_to_actor(in, &sd, direct_splice_actor);
1074 if (ret > 0) 1079 if (ret > 0)
1075 *ppos += ret; 1080 *ppos = sd.pos;
1076 1081
1077 return ret; 1082 return ret;
1078} 1083}
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index a1c3a1fab7f0..8c0e4b92574f 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -419,12 +419,8 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt,
419 */ 419 */
420int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd) 420int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd)
421{ 421{
422 if (sysfs_find_dirent(acxt->parent_sd, sd->s_name)) { 422 if (sysfs_find_dirent(acxt->parent_sd, sd->s_name))
423 printk(KERN_WARNING "sysfs: duplicate filename '%s' "
424 "can not be created\n", sd->s_name);
425 WARN_ON(1);
426 return -EEXIST; 423 return -EEXIST;
427 }
428 424
429 sd->s_parent = sysfs_get(acxt->parent_sd); 425 sd->s_parent = sysfs_get(acxt->parent_sd);
430 426
diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h
index 244a1aaa940e..11c035168ea6 100644
--- a/fs/ufs/ufs.h
+++ b/fs/ufs/ufs.h
@@ -107,7 +107,6 @@ extern struct inode * ufs_new_inode (struct inode *, int);
107 107
108/* inode.c */ 108/* inode.c */
109extern struct inode *ufs_iget(struct super_block *, unsigned long); 109extern struct inode *ufs_iget(struct super_block *, unsigned long);
110extern void ufs_put_inode (struct inode *);
111extern int ufs_write_inode (struct inode *, int); 110extern int ufs_write_inode (struct inode *, int);
112extern int ufs_sync_inode (struct inode *); 111extern int ufs_sync_inode (struct inode *);
113extern void ufs_delete_inode (struct inode *); 112extern void ufs_delete_inode (struct inode *);
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index 5105015a75ad..98e0e86093b4 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -387,6 +387,8 @@ _xfs_buf_lookup_pages(
387 if (unlikely(page == NULL)) { 387 if (unlikely(page == NULL)) {
388 if (flags & XBF_READ_AHEAD) { 388 if (flags & XBF_READ_AHEAD) {
389 bp->b_page_count = i; 389 bp->b_page_count = i;
390 for (i = 0; i < bp->b_page_count; i++)
391 unlock_page(bp->b_pages[i]);
390 return -ENOMEM; 392 return -ENOMEM;
391 } 393 }
392 394
@@ -416,17 +418,24 @@ _xfs_buf_lookup_pages(
416 ASSERT(!PagePrivate(page)); 418 ASSERT(!PagePrivate(page));
417 if (!PageUptodate(page)) { 419 if (!PageUptodate(page)) {
418 page_count--; 420 page_count--;
419 if (blocksize < PAGE_CACHE_SIZE && !PagePrivate(page)) { 421 if (blocksize >= PAGE_CACHE_SIZE) {
422 if (flags & XBF_READ)
423 bp->b_flags |= _XBF_PAGE_LOCKED;
424 } else if (!PagePrivate(page)) {
420 if (test_page_region(page, offset, nbytes)) 425 if (test_page_region(page, offset, nbytes))
421 page_count++; 426 page_count++;
422 } 427 }
423 } 428 }
424 429
425 unlock_page(page);
426 bp->b_pages[i] = page; 430 bp->b_pages[i] = page;
427 offset = 0; 431 offset = 0;
428 } 432 }
429 433
434 if (!(bp->b_flags & _XBF_PAGE_LOCKED)) {
435 for (i = 0; i < bp->b_page_count; i++)
436 unlock_page(bp->b_pages[i]);
437 }
438
430 if (page_count == bp->b_page_count) 439 if (page_count == bp->b_page_count)
431 bp->b_flags |= XBF_DONE; 440 bp->b_flags |= XBF_DONE;
432 441
@@ -746,6 +755,7 @@ xfs_buf_associate_memory(
746 bp->b_count_desired = len; 755 bp->b_count_desired = len;
747 bp->b_buffer_length = buflen; 756 bp->b_buffer_length = buflen;
748 bp->b_flags |= XBF_MAPPED; 757 bp->b_flags |= XBF_MAPPED;
758 bp->b_flags &= ~_XBF_PAGE_LOCKED;
749 759
750 return 0; 760 return 0;
751} 761}
@@ -1093,8 +1103,10 @@ _xfs_buf_ioend(
1093 xfs_buf_t *bp, 1103 xfs_buf_t *bp,
1094 int schedule) 1104 int schedule)
1095{ 1105{
1096 if (atomic_dec_and_test(&bp->b_io_remaining) == 1) 1106 if (atomic_dec_and_test(&bp->b_io_remaining) == 1) {
1107 bp->b_flags &= ~_XBF_PAGE_LOCKED;
1097 xfs_buf_ioend(bp, schedule); 1108 xfs_buf_ioend(bp, schedule);
1109 }
1098} 1110}
1099 1111
1100STATIC void 1112STATIC void
@@ -1125,6 +1137,9 @@ xfs_buf_bio_end_io(
1125 1137
1126 if (--bvec >= bio->bi_io_vec) 1138 if (--bvec >= bio->bi_io_vec)
1127 prefetchw(&bvec->bv_page->flags); 1139 prefetchw(&bvec->bv_page->flags);
1140
1141 if (bp->b_flags & _XBF_PAGE_LOCKED)
1142 unlock_page(page);
1128 } while (bvec >= bio->bi_io_vec); 1143 } while (bvec >= bio->bi_io_vec);
1129 1144
1130 _xfs_buf_ioend(bp, 1); 1145 _xfs_buf_ioend(bp, 1);
@@ -1163,7 +1178,8 @@ _xfs_buf_ioapply(
1163 * filesystem block size is not smaller than the page size. 1178 * filesystem block size is not smaller than the page size.
1164 */ 1179 */
1165 if ((bp->b_buffer_length < PAGE_CACHE_SIZE) && 1180 if ((bp->b_buffer_length < PAGE_CACHE_SIZE) &&
1166 (bp->b_flags & XBF_READ) && 1181 ((bp->b_flags & (XBF_READ|_XBF_PAGE_LOCKED)) ==
1182 (XBF_READ|_XBF_PAGE_LOCKED)) &&
1167 (blocksize >= PAGE_CACHE_SIZE)) { 1183 (blocksize >= PAGE_CACHE_SIZE)) {
1168 bio = bio_alloc(GFP_NOIO, 1); 1184 bio = bio_alloc(GFP_NOIO, 1);
1169 1185
diff --git a/fs/xfs/linux-2.6/xfs_buf.h b/fs/xfs/linux-2.6/xfs_buf.h
index 841d7883528d..f948ec7ba9a4 100644
--- a/fs/xfs/linux-2.6/xfs_buf.h
+++ b/fs/xfs/linux-2.6/xfs_buf.h
@@ -66,6 +66,25 @@ typedef enum {
66 _XBF_PAGES = (1 << 18), /* backed by refcounted pages */ 66 _XBF_PAGES = (1 << 18), /* backed by refcounted pages */
67 _XBF_RUN_QUEUES = (1 << 19),/* run block device task queue */ 67 _XBF_RUN_QUEUES = (1 << 19),/* run block device task queue */
68 _XBF_DELWRI_Q = (1 << 21), /* buffer on delwri queue */ 68 _XBF_DELWRI_Q = (1 << 21), /* buffer on delwri queue */
69
70 /*
71 * Special flag for supporting metadata blocks smaller than a FSB.
72 *
73 * In this case we can have multiple xfs_buf_t on a single page and
74 * need to lock out concurrent xfs_buf_t readers as they only
75 * serialise access to the buffer.
76 *
77 * If the FSB size >= PAGE_CACHE_SIZE case, we have no serialisation
78 * between reads of the page. Hence we can have one thread read the
79 * page and modify it, but then race with another thread that thinks
80 * the page is not up-to-date and hence reads it again.
81 *
82 * The result is that the first modifcation to the page is lost.
83 * This sort of AGF/AGI reading race can happen when unlinking inodes
84 * that require truncation and results in the AGI unlinked list
85 * modifications being lost.
86 */
87 _XBF_PAGE_LOCKED = (1 << 22),
69} xfs_buf_flags_t; 88} xfs_buf_flags_t;
70 89
71typedef enum { 90typedef enum {
diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/linux-2.6/xfs_file.c
index 65e78c13d4ae..5f60363b9343 100644
--- a/fs/xfs/linux-2.6/xfs_file.c
+++ b/fs/xfs/linux-2.6/xfs_file.c
@@ -184,19 +184,24 @@ xfs_file_release(
184 return -xfs_release(XFS_I(inode)); 184 return -xfs_release(XFS_I(inode));
185} 185}
186 186
187/*
188 * We ignore the datasync flag here because a datasync is effectively
189 * identical to an fsync. That is, datasync implies that we need to write
190 * only the metadata needed to be able to access the data that is written
191 * if we crash after the call completes. Hence if we are writing beyond
192 * EOF we have to log the inode size change as well, which makes it a
193 * full fsync. If we don't write beyond EOF, the inode core will be
194 * clean in memory and so we don't need to log the inode, just like
195 * fsync.
196 */
187STATIC int 197STATIC int
188xfs_file_fsync( 198xfs_file_fsync(
189 struct file *filp, 199 struct file *filp,
190 struct dentry *dentry, 200 struct dentry *dentry,
191 int datasync) 201 int datasync)
192{ 202{
193 int flags = FSYNC_WAIT;
194
195 if (datasync)
196 flags |= FSYNC_DATA;
197 xfs_iflags_clear(XFS_I(dentry->d_inode), XFS_ITRUNCATED); 203 xfs_iflags_clear(XFS_I(dentry->d_inode), XFS_ITRUNCATED);
198 return -xfs_fsync(XFS_I(dentry->d_inode), flags, 204 return -xfs_fsync(XFS_I(dentry->d_inode));
199 (xfs_off_t)0, (xfs_off_t)-1);
200} 205}
201 206
202/* 207/*
diff --git a/fs/xfs/linux-2.6/xfs_vnode.h b/fs/xfs/linux-2.6/xfs_vnode.h
index 9d73cb5c0fc7..25eb2a9e8d9b 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.h
+++ b/fs/xfs/linux-2.6/xfs_vnode.h
@@ -230,14 +230,6 @@ static inline void vn_atime_to_time_t(bhv_vnode_t *vp, time_t *tt)
230#define ATTR_NOSIZETOK 0x400 /* Don't get the SIZE token */ 230#define ATTR_NOSIZETOK 0x400 /* Don't get the SIZE token */
231 231
232/* 232/*
233 * Flags to vop_fsync/reclaim.
234 */
235#define FSYNC_NOWAIT 0 /* asynchronous flush */
236#define FSYNC_WAIT 0x1 /* synchronous fsync or forced reclaim */
237#define FSYNC_INVAL 0x2 /* flush and invalidate cached data */
238#define FSYNC_DATA 0x4 /* synchronous fsync of data only */
239
240/*
241 * Tracking vnode activity. 233 * Tracking vnode activity.
242 */ 234 */
243#if defined(XFS_INODE_TRACE) 235#if defined(XFS_INODE_TRACE)
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index cf0bb9c1d621..e569bf5d6cf0 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -2974,6 +2974,7 @@ xfs_iflush_cluster(
2974 xfs_mount_t *mp = ip->i_mount; 2974 xfs_mount_t *mp = ip->i_mount;
2975 xfs_perag_t *pag = xfs_get_perag(mp, ip->i_ino); 2975 xfs_perag_t *pag = xfs_get_perag(mp, ip->i_ino);
2976 unsigned long first_index, mask; 2976 unsigned long first_index, mask;
2977 unsigned long inodes_per_cluster;
2977 int ilist_size; 2978 int ilist_size;
2978 xfs_inode_t **ilist; 2979 xfs_inode_t **ilist;
2979 xfs_inode_t *iq; 2980 xfs_inode_t *iq;
@@ -2985,8 +2986,9 @@ xfs_iflush_cluster(
2985 ASSERT(pag->pagi_inodeok); 2986 ASSERT(pag->pagi_inodeok);
2986 ASSERT(pag->pag_ici_init); 2987 ASSERT(pag->pag_ici_init);
2987 2988
2988 ilist_size = XFS_INODE_CLUSTER_SIZE(mp) * sizeof(xfs_inode_t *); 2989 inodes_per_cluster = XFS_INODE_CLUSTER_SIZE(mp) >> mp->m_sb.sb_inodelog;
2989 ilist = kmem_alloc(ilist_size, KM_MAYFAIL); 2990 ilist_size = inodes_per_cluster * sizeof(xfs_inode_t *);
2991 ilist = kmem_alloc(ilist_size, KM_MAYFAIL|KM_NOFS);
2990 if (!ilist) 2992 if (!ilist)
2991 return 0; 2993 return 0;
2992 2994
@@ -2995,8 +2997,7 @@ xfs_iflush_cluster(
2995 read_lock(&pag->pag_ici_lock); 2997 read_lock(&pag->pag_ici_lock);
2996 /* really need a gang lookup range call here */ 2998 /* really need a gang lookup range call here */
2997 nr_found = radix_tree_gang_lookup(&pag->pag_ici_root, (void**)ilist, 2999 nr_found = radix_tree_gang_lookup(&pag->pag_ici_root, (void**)ilist,
2998 first_index, 3000 first_index, inodes_per_cluster);
2999 XFS_INODE_CLUSTER_SIZE(mp));
3000 if (nr_found == 0) 3001 if (nr_found == 0)
3001 goto out_free; 3002 goto out_free;
3002 3003
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index 70702a60b4bb..e475e3717eb3 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -856,18 +856,14 @@ xfs_readlink(
856/* 856/*
857 * xfs_fsync 857 * xfs_fsync
858 * 858 *
859 * This is called to sync the inode and its data out to disk. 859 * This is called to sync the inode and its data out to disk. We need to hold
860 * We need to hold the I/O lock while flushing the data, and 860 * the I/O lock while flushing the data, and the inode lock while flushing the
861 * the inode lock while flushing the inode. The inode lock CANNOT 861 * inode. The inode lock CANNOT be held while flushing the data, so acquire
862 * be held while flushing the data, so acquire after we're done 862 * after we're done with that.
863 * with that.
864 */ 863 */
865int 864int
866xfs_fsync( 865xfs_fsync(
867 xfs_inode_t *ip, 866 xfs_inode_t *ip)
868 int flag,
869 xfs_off_t start,
870 xfs_off_t stop)
871{ 867{
872 xfs_trans_t *tp; 868 xfs_trans_t *tp;
873 int error; 869 int error;
@@ -875,103 +871,79 @@ xfs_fsync(
875 871
876 xfs_itrace_entry(ip); 872 xfs_itrace_entry(ip);
877 873
878 ASSERT(start >= 0 && stop >= -1);
879
880 if (XFS_FORCED_SHUTDOWN(ip->i_mount)) 874 if (XFS_FORCED_SHUTDOWN(ip->i_mount))
881 return XFS_ERROR(EIO); 875 return XFS_ERROR(EIO);
882 876
883 if (flag & FSYNC_DATA) 877 /* capture size updates in I/O completion before writing the inode. */
884 filemap_fdatawait(vn_to_inode(XFS_ITOV(ip))->i_mapping); 878 error = filemap_fdatawait(vn_to_inode(XFS_ITOV(ip))->i_mapping);
879 if (error)
880 return XFS_ERROR(error);
885 881
886 /* 882 /*
887 * We always need to make sure that the required inode state 883 * We always need to make sure that the required inode state is safe on
888 * is safe on disk. The vnode might be clean but because 884 * disk. The vnode might be clean but we still might need to force the
889 * of committed transactions that haven't hit the disk yet. 885 * log because of committed transactions that haven't hit the disk yet.
890 * Likewise, there could be unflushed non-transactional 886 * Likewise, there could be unflushed non-transactional changes to the
891 * changes to the inode core that have to go to disk. 887 * inode core that have to go to disk and this requires us to issue
888 * a synchronous transaction to capture these changes correctly.
892 * 889 *
893 * The following code depends on one assumption: that 890 * This code relies on the assumption that if the update_* fields
894 * any transaction that changes an inode logs the core 891 * of the inode are clear and the inode is unpinned then it is clean
895 * because it has to change some field in the inode core 892 * and no action is required.
896 * (typically nextents or nblocks). That assumption
897 * implies that any transactions against an inode will
898 * catch any non-transactional updates. If inode-altering
899 * transactions exist that violate this assumption, the
900 * code breaks. Right now, it figures that if the involved
901 * update_* field is clear and the inode is unpinned, the
902 * inode is clean. Either it's been flushed or it's been
903 * committed and the commit has hit the disk unpinning the inode.
904 * (Note that xfs_inode_item_format() called at commit clears
905 * the update_* fields.)
906 */ 893 */
907 xfs_ilock(ip, XFS_ILOCK_SHARED); 894 xfs_ilock(ip, XFS_ILOCK_SHARED);
908 895
909 /* If we are flushing data then we care about update_size 896 if (!(ip->i_update_size || ip->i_update_core)) {
910 * being set, otherwise we care about update_core
911 */
912 if ((flag & FSYNC_DATA) ?
913 (ip->i_update_size == 0) :
914 (ip->i_update_core == 0)) {
915 /* 897 /*
916 * Timestamps/size haven't changed since last inode 898 * Timestamps/size haven't changed since last inode flush or
917 * flush or inode transaction commit. That means 899 * inode transaction commit. That means either nothing got
918 * either nothing got written or a transaction 900 * written or a transaction committed which caught the updates.
919 * committed which caught the updates. If the 901 * If the latter happened and the transaction hasn't hit the
920 * latter happened and the transaction hasn't 902 * disk yet, the inode will be still be pinned. If it is,
921 * hit the disk yet, the inode will be still 903 * force the log.
922 * be pinned. If it is, force the log.
923 */ 904 */
924 905
925 xfs_iunlock(ip, XFS_ILOCK_SHARED); 906 xfs_iunlock(ip, XFS_ILOCK_SHARED);
926 907
927 if (xfs_ipincount(ip)) { 908 if (xfs_ipincount(ip)) {
928 _xfs_log_force(ip->i_mount, (xfs_lsn_t)0, 909 error = _xfs_log_force(ip->i_mount, (xfs_lsn_t)0,
929 XFS_LOG_FORCE | 910 XFS_LOG_FORCE | XFS_LOG_SYNC,
930 ((flag & FSYNC_WAIT)
931 ? XFS_LOG_SYNC : 0),
932 &log_flushed); 911 &log_flushed);
933 } else { 912 } else {
934 /* 913 /*
935 * If the inode is not pinned and nothing 914 * If the inode is not pinned and nothing has changed
936 * has changed we don't need to flush the 915 * we don't need to flush the cache.
937 * cache.
938 */ 916 */
939 changed = 0; 917 changed = 0;
940 } 918 }
941 error = 0;
942 } else { 919 } else {
943 /* 920 /*
944 * Kick off a transaction to log the inode 921 * Kick off a transaction to log the inode core to get the
945 * core to get the updates. Make it 922 * updates. The sync transaction will also force the log.
946 * sync if FSYNC_WAIT is passed in (which
947 * is done by everybody but specfs). The
948 * sync transaction will also force the log.
949 */ 923 */
950 xfs_iunlock(ip, XFS_ILOCK_SHARED); 924 xfs_iunlock(ip, XFS_ILOCK_SHARED);
951 tp = xfs_trans_alloc(ip->i_mount, XFS_TRANS_FSYNC_TS); 925 tp = xfs_trans_alloc(ip->i_mount, XFS_TRANS_FSYNC_TS);
952 if ((error = xfs_trans_reserve(tp, 0, 926 error = xfs_trans_reserve(tp, 0,
953 XFS_FSYNC_TS_LOG_RES(ip->i_mount), 927 XFS_FSYNC_TS_LOG_RES(ip->i_mount), 0, 0, 0);
954 0, 0, 0))) { 928 if (error) {
955 xfs_trans_cancel(tp, 0); 929 xfs_trans_cancel(tp, 0);
956 return error; 930 return error;
957 } 931 }
958 xfs_ilock(ip, XFS_ILOCK_EXCL); 932 xfs_ilock(ip, XFS_ILOCK_EXCL);
959 933
960 /* 934 /*
961 * Note - it's possible that we might have pushed 935 * Note - it's possible that we might have pushed ourselves out
962 * ourselves out of the way during trans_reserve 936 * of the way during trans_reserve which would flush the inode.
963 * which would flush the inode. But there's no 937 * But there's no guarantee that the inode buffer has actually
964 * guarantee that the inode buffer has actually 938 * gone out yet (it's delwri). Plus the buffer could be pinned
965 * gone out yet (it's delwri). Plus the buffer 939 * anyway if it's part of an inode in another recent
966 * could be pinned anyway if it's part of an 940 * transaction. So we play it safe and fire off the
967 * inode in another recent transaction. So we 941 * transaction anyway.
968 * play it safe and fire off the transaction anyway.
969 */ 942 */
970 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); 943 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
971 xfs_trans_ihold(tp, ip); 944 xfs_trans_ihold(tp, ip);
972 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 945 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
973 if (flag & FSYNC_WAIT) 946 xfs_trans_set_sync(tp);
974 xfs_trans_set_sync(tp);
975 error = _xfs_trans_commit(tp, 0, &log_flushed); 947 error = _xfs_trans_commit(tp, 0, &log_flushed);
976 948
977 xfs_iunlock(ip, XFS_ILOCK_EXCL); 949 xfs_iunlock(ip, XFS_ILOCK_EXCL);
diff --git a/fs/xfs/xfs_vnodeops.h b/fs/xfs/xfs_vnodeops.h
index 8abe8f186e20..57335ba4ce53 100644
--- a/fs/xfs/xfs_vnodeops.h
+++ b/fs/xfs/xfs_vnodeops.h
@@ -18,8 +18,7 @@ int xfs_open(struct xfs_inode *ip);
18int xfs_setattr(struct xfs_inode *ip, struct bhv_vattr *vap, int flags, 18int xfs_setattr(struct xfs_inode *ip, struct bhv_vattr *vap, int flags,
19 struct cred *credp); 19 struct cred *credp);
20int xfs_readlink(struct xfs_inode *ip, char *link); 20int xfs_readlink(struct xfs_inode *ip, char *link);
21int xfs_fsync(struct xfs_inode *ip, int flag, xfs_off_t start, 21int xfs_fsync(struct xfs_inode *ip);
22 xfs_off_t stop);
23int xfs_release(struct xfs_inode *ip); 22int xfs_release(struct xfs_inode *ip);
24int xfs_inactive(struct xfs_inode *ip); 23int xfs_inactive(struct xfs_inode *ip);
25int xfs_lookup(struct xfs_inode *dp, struct xfs_name *name, 24int xfs_lookup(struct xfs_inode *dp, struct xfs_name *name,