aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/9p/vfs_inode.c2
-rw-r--r--fs/9p/vfs_inode_dotl.c4
-rw-r--r--fs/Makefile2
-rw-r--r--fs/affs/amigaffs.c2
-rw-r--r--fs/affs/inode.c4
-rw-r--r--fs/affs/namei.c40
-rw-r--r--fs/afs/dir.c80
-rw-r--r--fs/afs/inode.c4
-rw-r--r--fs/afs/mntpt.c22
-rw-r--r--fs/afs/write.c9
-rw-r--r--fs/autofs4/expire.c42
-rw-r--r--fs/autofs4/root.c25
-rw-r--r--fs/befs/linuxvfs.c16
-rw-r--r--fs/binfmt_aout.c8
-rw-r--r--fs/block_dev.c3
-rw-r--r--fs/btrfs/ctree.c14
-rw-r--r--fs/btrfs/ctree.h2
-rw-r--r--fs/btrfs/disk-io.c43
-rw-r--r--fs/btrfs/extent-tree.c18
-rw-r--r--fs/btrfs/file-item.c2
-rw-r--r--fs/btrfs/inode.c2
-rw-r--r--fs/btrfs/ioctl.c2
-rw-r--r--fs/btrfs/locking.c24
-rw-r--r--fs/btrfs/locking.h2
-rw-r--r--fs/btrfs/super.c1
-rw-r--r--fs/btrfs/tree-log.c2
-rw-r--r--fs/buffer.c38
-rw-r--r--fs/cachefiles/namei.c21
-rw-r--r--fs/cachefiles/xattr.c15
-rw-r--r--fs/ceph/caps.c2
-rw-r--r--fs/ceph/debugfs.c14
-rw-r--r--fs/ceph/dir.c56
-rw-r--r--fs/ceph/file.c6
-rw-r--r--fs/ceph/inode.c18
-rw-r--r--fs/cifs/cifsfs.c3
-rw-r--r--fs/cifs/cifsglob.h6
-rw-r--r--fs/cifs/file.c12
-rw-r--r--fs/cifs/inode.c2
-rw-r--r--fs/cifs/readdir.c10
-rw-r--r--fs/coda/cache.c2
-rw-r--r--fs/coda/coda_linux.c6
-rw-r--r--fs/coda/coda_linux.h1
-rw-r--r--fs/coda/dir.c12
-rw-r--r--fs/compat.c21
-rw-r--r--fs/configfs/dir.c2
-rw-r--r--fs/dcache.c272
-rw-r--r--fs/debugfs/file.c15
-rw-r--r--fs/debugfs/inode.c2
-rw-r--r--fs/dlm/debug_fs.c263
-rw-r--r--fs/ecryptfs/crypto.c2
-rw-r--r--fs/ecryptfs/file.c6
-rw-r--r--fs/ecryptfs/mmap.c2
-rw-r--r--fs/efivarfs/file.c4
-rw-r--r--fs/eventfd.c9
-rw-r--r--fs/eventpoll.c13
-rw-r--r--fs/exportfs/expfs.c7
-rw-r--r--fs/ext3/super.c7
-rw-r--r--fs/ext4/extents.c9
-rw-r--r--fs/ext4/file.c2
-rw-r--r--fs/ext4/ialloc.c4
-rw-r--r--fs/ext4/inode.c7
-rw-r--r--fs/ext4/namei.c28
-rw-r--r--fs/ext4/resize.c2
-rw-r--r--fs/ext4/super.c17
-rw-r--r--fs/fat/dir.c5
-rw-r--r--fs/fuse/dir.c4
-rw-r--r--fs/fuse/file.c2
-rw-r--r--fs/gfs2/export.c8
-rw-r--r--fs/gfs2/inode.c26
-rw-r--r--fs/hppfs/hppfs.c5
-rw-r--r--fs/isofs/inode.c64
-rw-r--r--fs/isofs/namei.c22
-rw-r--r--fs/jbd/revoke.c7
-rw-r--r--fs/jbd2/revoke.c10
-rw-r--r--fs/jfs/namei.c18
-rw-r--r--fs/kernfs/dir.c2
-rw-r--r--fs/libfs.c12
-rw-r--r--fs/lockd/svcsubs.c2
-rw-r--r--fs/namei.c5
-rw-r--r--fs/ncpfs/dir.c12
-rw-r--r--fs/ncpfs/file.c14
-rw-r--r--fs/ncpfs/mmap.c4
-rw-r--r--fs/ncpfs/ncplib_kernel.h4
-rw-r--r--fs/nfs/blocklayout/blocklayout.c2
-rw-r--r--fs/nfs/blocklayout/rpc_pipefs.c16
-rw-r--r--fs/nfs/delegation.c25
-rw-r--r--fs/nfs/delegation.h1
-rw-r--r--fs/nfs/dir.c7
-rw-r--r--fs/nfs/direct.c1
-rw-r--r--fs/nfs/filelayout/filelayout.c3
-rw-r--r--fs/nfs/getroot.c4
-rw-r--r--fs/nfs/inode.c2
-rw-r--r--fs/nfs/netns.h1
-rw-r--r--fs/nfs/nfs4proc.c95
-rw-r--r--fs/nfs/write.c2
-rw-r--r--fs/nfsd/nfs4proc.c7
-rw-r--r--fs/nfsd/nfs4recover.c7
-rw-r--r--fs/nfsd/nfs4xdr.c2
-rw-r--r--fs/nfsd/nfsctl.c37
-rw-r--r--fs/nfsd/vfs.c16
-rw-r--r--fs/nfsd/vfs.h4
-rw-r--r--fs/notify/fdinfo.c78
-rw-r--r--fs/notify/fdinfo.h4
-rw-r--r--fs/notify/fsnotify.c40
-rw-r--r--fs/notify/fsnotify.h4
-rw-r--r--fs/notify/inode_mark.c25
-rw-r--r--fs/notify/mark.c36
-rw-r--r--fs/notify/vfsmount_mark.c8
-rw-r--r--fs/ntfs/namei.c4
-rw-r--r--fs/ocfs2/cluster/tcp.c2
-rw-r--r--fs/ocfs2/dcache.c20
-rw-r--r--fs/ocfs2/dir.c8
-rw-r--r--fs/ocfs2/dlmfs/dlmfs.c4
-rw-r--r--fs/ocfs2/dlmglue.c3
-rw-r--r--fs/ocfs2/journal.c8
-rw-r--r--fs/ocfs2/namei.c2
-rw-r--r--fs/open.c4
-rw-r--r--fs/overlayfs/Kconfig2
-rw-r--r--fs/overlayfs/Makefile4
-rw-r--r--fs/overlayfs/dir.c31
-rw-r--r--fs/overlayfs/inode.c27
-rw-r--r--fs/overlayfs/readdir.c64
-rw-r--r--fs/overlayfs/super.c61
-rw-r--r--fs/proc/base.c4
-rw-r--r--fs/proc/fd.c3
-rw-r--r--fs/quota/dquot.c2
-rw-r--r--fs/readdir.c21
-rw-r--r--fs/reiserfs/xattr.c21
-rw-r--r--fs/seq_file.c15
-rw-r--r--fs/signalfd.c4
-rw-r--r--fs/sync.c2
-rw-r--r--fs/timerfd.c27
-rw-r--r--fs/xattr.c16
-rw-r--r--fs/xfs/xfs_bmap_util.c72
-rw-r--r--fs/xfs/xfs_itable.c250
-rw-r--r--fs/xfs/xfs_itable.h16
136 files changed, 1226 insertions, 1417 deletions
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 296482fc77a9..9ee5343d4884 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -832,7 +832,7 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
832 * moved b under k and client parallely did a lookup for 832 * moved b under k and client parallely did a lookup for
833 * k/b. 833 * k/b.
834 */ 834 */
835 res = d_materialise_unique(dentry, inode); 835 res = d_splice_alias(inode, dentry);
836 if (!res) 836 if (!res)
837 v9fs_fid_add(dentry, fid); 837 v9fs_fid_add(dentry, fid);
838 else if (!IS_ERR(res)) 838 else if (!IS_ERR(res))
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index 02b64f4e576a..6054c16b8fae 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -826,8 +826,8 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, umode_t omode,
826 struct dentry *dir_dentry; 826 struct dentry *dir_dentry;
827 struct posix_acl *dacl = NULL, *pacl = NULL; 827 struct posix_acl *dacl = NULL, *pacl = NULL;
828 828
829 p9_debug(P9_DEBUG_VFS, " %lu,%s mode: %hx MAJOR: %u MINOR: %u\n", 829 p9_debug(P9_DEBUG_VFS, " %lu,%pd mode: %hx MAJOR: %u MINOR: %u\n",
830 dir->i_ino, dentry->d_name.name, omode, 830 dir->i_ino, dentry, omode,
831 MAJOR(rdev), MINOR(rdev)); 831 MAJOR(rdev), MINOR(rdev));
832 832
833 if (!new_valid_dev(rdev)) 833 if (!new_valid_dev(rdev))
diff --git a/fs/Makefile b/fs/Makefile
index 34393376eaa2..bedff48e8fdc 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -104,7 +104,7 @@ obj-$(CONFIG_QNX6FS_FS) += qnx6/
104obj-$(CONFIG_AUTOFS4_FS) += autofs4/ 104obj-$(CONFIG_AUTOFS4_FS) += autofs4/
105obj-$(CONFIG_ADFS_FS) += adfs/ 105obj-$(CONFIG_ADFS_FS) += adfs/
106obj-$(CONFIG_FUSE_FS) += fuse/ 106obj-$(CONFIG_FUSE_FS) += fuse/
107obj-$(CONFIG_OVERLAYFS_FS) += overlayfs/ 107obj-$(CONFIG_OVERLAY_FS) += overlayfs/
108obj-$(CONFIG_UDF_FS) += udf/ 108obj-$(CONFIG_UDF_FS) += udf/
109obj-$(CONFIG_SUN_OPENPROMFS) += openpromfs/ 109obj-$(CONFIG_SUN_OPENPROMFS) += openpromfs/
110obj-$(CONFIG_OMFS_FS) += omfs/ 110obj-$(CONFIG_OMFS_FS) += omfs/
diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
index abc853968fed..937ce8754b24 100644
--- a/fs/affs/amigaffs.c
+++ b/fs/affs/amigaffs.c
@@ -125,7 +125,7 @@ affs_fix_dcache(struct inode *inode, u32 entry_ino)
125{ 125{
126 struct dentry *dentry; 126 struct dentry *dentry;
127 spin_lock(&inode->i_lock); 127 spin_lock(&inode->i_lock);
128 hlist_for_each_entry(dentry, &inode->i_dentry, d_alias) { 128 hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) {
129 if (entry_ino == (u32)(long)dentry->d_fsdata) { 129 if (entry_ino == (u32)(long)dentry->d_fsdata) {
130 dentry->d_fsdata = (void *)inode->i_ino; 130 dentry->d_fsdata = (void *)inode->i_ino;
131 break; 131 break;
diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index e217c511459b..d0609a282e1d 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -348,9 +348,9 @@ affs_add_entry(struct inode *dir, struct inode *inode, struct dentry *dentry, s3
348 u32 block = 0; 348 u32 block = 0;
349 int retval; 349 int retval;
350 350
351 pr_debug("%s(dir=%u, inode=%u, \"%*s\", type=%d)\n", 351 pr_debug("%s(dir=%u, inode=%u, \"%pd\", type=%d)\n",
352 __func__, (u32)dir->i_ino, 352 __func__, (u32)dir->i_ino,
353 (u32)inode->i_ino, (int)dentry->d_name.len, dentry->d_name.name, type); 353 (u32)inode->i_ino, dentry, type);
354 354
355 retval = -EIO; 355 retval = -EIO;
356 bh = affs_bread(sb, inode->i_ino); 356 bh = affs_bread(sb, inode->i_ino);
diff --git a/fs/affs/namei.c b/fs/affs/namei.c
index 035bd31556fc..bbc38530e924 100644
--- a/fs/affs/namei.c
+++ b/fs/affs/namei.c
@@ -190,8 +190,7 @@ affs_find_entry(struct inode *dir, struct dentry *dentry)
190 toupper_t toupper = affs_get_toupper(sb); 190 toupper_t toupper = affs_get_toupper(sb);
191 u32 key; 191 u32 key;
192 192
193 pr_debug("%s(\"%.*s\")\n", 193 pr_debug("%s(\"%pd\")\n", __func__, dentry);
194 __func__, (int)dentry->d_name.len, dentry->d_name.name);
195 194
196 bh = affs_bread(sb, dir->i_ino); 195 bh = affs_bread(sb, dir->i_ino);
197 if (!bh) 196 if (!bh)
@@ -219,8 +218,7 @@ affs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
219 struct buffer_head *bh; 218 struct buffer_head *bh;
220 struct inode *inode = NULL; 219 struct inode *inode = NULL;
221 220
222 pr_debug("%s(\"%.*s\")\n", 221 pr_debug("%s(\"%pd\")\n", __func__, dentry);
223 __func__, (int)dentry->d_name.len, dentry->d_name.name);
224 222
225 affs_lock_dir(dir); 223 affs_lock_dir(dir);
226 bh = affs_find_entry(dir, dentry); 224 bh = affs_find_entry(dir, dentry);
@@ -250,9 +248,9 @@ affs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
250int 248int
251affs_unlink(struct inode *dir, struct dentry *dentry) 249affs_unlink(struct inode *dir, struct dentry *dentry)
252{ 250{
253 pr_debug("%s(dir=%d, %lu \"%.*s\")\n", 251 pr_debug("%s(dir=%d, %lu \"%pd\")\n",
254 __func__, (u32)dir->i_ino, dentry->d_inode->i_ino, 252 __func__, (u32)dir->i_ino, dentry->d_inode->i_ino,
255 (int)dentry->d_name.len, dentry->d_name.name); 253 dentry);
256 254
257 return affs_remove_header(dentry); 255 return affs_remove_header(dentry);
258} 256}
@@ -264,9 +262,8 @@ affs_create(struct inode *dir, struct dentry *dentry, umode_t mode, bool excl)
264 struct inode *inode; 262 struct inode *inode;
265 int error; 263 int error;
266 264
267 pr_debug("%s(%lu,\"%.*s\",0%ho)\n", 265 pr_debug("%s(%lu,\"%pd\",0%ho)\n",
268 __func__, dir->i_ino, (int)dentry->d_name.len, 266 __func__, dir->i_ino, dentry, mode);
269 dentry->d_name.name,mode);
270 267
271 inode = affs_new_inode(dir); 268 inode = affs_new_inode(dir);
272 if (!inode) 269 if (!inode)
@@ -294,9 +291,8 @@ affs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
294 struct inode *inode; 291 struct inode *inode;
295 int error; 292 int error;
296 293
297 pr_debug("%s(%lu,\"%.*s\",0%ho)\n", 294 pr_debug("%s(%lu,\"%pd\",0%ho)\n",
298 __func__, dir->i_ino, (int)dentry->d_name.len, 295 __func__, dir->i_ino, dentry, mode);
299 dentry->d_name.name, mode);
300 296
301 inode = affs_new_inode(dir); 297 inode = affs_new_inode(dir);
302 if (!inode) 298 if (!inode)
@@ -321,9 +317,9 @@ affs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
321int 317int
322affs_rmdir(struct inode *dir, struct dentry *dentry) 318affs_rmdir(struct inode *dir, struct dentry *dentry)
323{ 319{
324 pr_debug("%s(dir=%u, %lu \"%.*s\")\n", 320 pr_debug("%s(dir=%u, %lu \"%pd\")\n",
325 __func__, (u32)dir->i_ino, dentry->d_inode->i_ino, 321 __func__, (u32)dir->i_ino, dentry->d_inode->i_ino,
326 (int)dentry->d_name.len, dentry->d_name.name); 322 dentry);
327 323
328 return affs_remove_header(dentry); 324 return affs_remove_header(dentry);
329} 325}
@@ -338,9 +334,8 @@ affs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
338 int i, maxlen, error; 334 int i, maxlen, error;
339 char c, lc; 335 char c, lc;
340 336
341 pr_debug("%s(%lu,\"%.*s\" -> \"%s\")\n", 337 pr_debug("%s(%lu,\"%pd\" -> \"%s\")\n",
342 __func__, dir->i_ino, (int)dentry->d_name.len, 338 __func__, dir->i_ino, dentry, symname);
343 dentry->d_name.name, symname);
344 339
345 maxlen = AFFS_SB(sb)->s_hashsize * sizeof(u32) - 1; 340 maxlen = AFFS_SB(sb)->s_hashsize * sizeof(u32) - 1;
346 inode = affs_new_inode(dir); 341 inode = affs_new_inode(dir);
@@ -409,9 +404,9 @@ affs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
409{ 404{
410 struct inode *inode = old_dentry->d_inode; 405 struct inode *inode = old_dentry->d_inode;
411 406
412 pr_debug("%s(%u, %u, \"%.*s\")\n", 407 pr_debug("%s(%u, %u, \"%pd\")\n",
413 __func__, (u32)inode->i_ino, (u32)dir->i_ino, 408 __func__, (u32)inode->i_ino, (u32)dir->i_ino,
414 (int)dentry->d_name.len,dentry->d_name.name); 409 dentry);
415 410
416 return affs_add_entry(dir, inode, dentry, ST_LINKFILE); 411 return affs_add_entry(dir, inode, dentry, ST_LINKFILE);
417} 412}
@@ -424,10 +419,9 @@ affs_rename(struct inode *old_dir, struct dentry *old_dentry,
424 struct buffer_head *bh = NULL; 419 struct buffer_head *bh = NULL;
425 int retval; 420 int retval;
426 421
427 pr_debug("%s(old=%u,\"%*s\" to new=%u,\"%*s\")\n", 422 pr_debug("%s(old=%u,\"%pd\" to new=%u,\"%pd\")\n",
428 __func__, (u32)old_dir->i_ino, (int)old_dentry->d_name.len, 423 __func__, (u32)old_dir->i_ino, old_dentry,
429 old_dentry->d_name.name, (u32)new_dir->i_ino, 424 (u32)new_dir->i_ino, new_dentry);
430 (int)new_dentry->d_name.len, new_dentry->d_name.name);
431 425
432 retval = affs_check_name(new_dentry->d_name.name, 426 retval = affs_check_name(new_dentry->d_name.name,
433 new_dentry->d_name.len, 427 new_dentry->d_name.len,
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index a1645b88fe8a..4ec35e9130e1 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -26,7 +26,7 @@ static int afs_readdir(struct file *file, struct dir_context *ctx);
26static int afs_d_revalidate(struct dentry *dentry, unsigned int flags); 26static int afs_d_revalidate(struct dentry *dentry, unsigned int flags);
27static int afs_d_delete(const struct dentry *dentry); 27static int afs_d_delete(const struct dentry *dentry);
28static void afs_d_release(struct dentry *dentry); 28static void afs_d_release(struct dentry *dentry);
29static int afs_lookup_filldir(void *_cookie, const char *name, int nlen, 29static int afs_lookup_filldir(struct dir_context *ctx, const char *name, int nlen,
30 loff_t fpos, u64 ino, unsigned dtype); 30 loff_t fpos, u64 ino, unsigned dtype);
31static int afs_create(struct inode *dir, struct dentry *dentry, umode_t mode, 31static int afs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
32 bool excl); 32 bool excl);
@@ -391,10 +391,11 @@ static int afs_readdir(struct file *file, struct dir_context *ctx)
391 * - if afs_dir_iterate_block() spots this function, it'll pass the FID 391 * - if afs_dir_iterate_block() spots this function, it'll pass the FID
392 * uniquifier through dtype 392 * uniquifier through dtype
393 */ 393 */
394static int afs_lookup_filldir(void *_cookie, const char *name, int nlen, 394static int afs_lookup_filldir(struct dir_context *ctx, const char *name,
395 loff_t fpos, u64 ino, unsigned dtype) 395 int nlen, loff_t fpos, u64 ino, unsigned dtype)
396{ 396{
397 struct afs_lookup_cookie *cookie = _cookie; 397 struct afs_lookup_cookie *cookie =
398 container_of(ctx, struct afs_lookup_cookie, ctx);
398 399
399 _enter("{%s,%u},%s,%u,,%llu,%u", 400 _enter("{%s,%u},%s,%u,,%llu,%u",
400 cookie->name.name, cookie->name.len, name, nlen, 401 cookie->name.name, cookie->name.len, name, nlen,
@@ -433,7 +434,7 @@ static int afs_do_lookup(struct inode *dir, struct dentry *dentry,
433 }; 434 };
434 int ret; 435 int ret;
435 436
436 _enter("{%lu},%p{%s},", dir->i_ino, dentry, dentry->d_name.name); 437 _enter("{%lu},%p{%pd},", dir->i_ino, dentry, dentry);
437 438
438 /* search the directory */ 439 /* search the directory */
439 ret = afs_dir_iterate(dir, &cookie.ctx, key); 440 ret = afs_dir_iterate(dir, &cookie.ctx, key);
@@ -465,8 +466,8 @@ static struct inode *afs_try_auto_mntpt(
465 struct afs_vnode *vnode = AFS_FS_I(dir); 466 struct afs_vnode *vnode = AFS_FS_I(dir);
466 struct inode *inode; 467 struct inode *inode;
467 468
468 _enter("%d, %p{%s}, {%x:%u}, %p", 469 _enter("%d, %p{%pd}, {%x:%u}, %p",
469 ret, dentry, devname, vnode->fid.vid, vnode->fid.vnode, key); 470 ret, dentry, dentry, vnode->fid.vid, vnode->fid.vnode, key);
470 471
471 if (ret != -ENOENT || 472 if (ret != -ENOENT ||
472 !test_bit(AFS_VNODE_AUTOCELL, &vnode->flags)) 473 !test_bit(AFS_VNODE_AUTOCELL, &vnode->flags))
@@ -501,8 +502,8 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
501 502
502 vnode = AFS_FS_I(dir); 503 vnode = AFS_FS_I(dir);
503 504
504 _enter("{%x:%u},%p{%s},", 505 _enter("{%x:%u},%p{%pd},",
505 vnode->fid.vid, vnode->fid.vnode, dentry, dentry->d_name.name); 506 vnode->fid.vid, vnode->fid.vnode, dentry, dentry);
506 507
507 ASSERTCMP(dentry->d_inode, ==, NULL); 508 ASSERTCMP(dentry->d_inode, ==, NULL);
508 509
@@ -588,11 +589,11 @@ static int afs_d_revalidate(struct dentry *dentry, unsigned int flags)
588 vnode = AFS_FS_I(dentry->d_inode); 589 vnode = AFS_FS_I(dentry->d_inode);
589 590
590 if (dentry->d_inode) 591 if (dentry->d_inode)
591 _enter("{v={%x:%u} n=%s fl=%lx},", 592 _enter("{v={%x:%u} n=%pd fl=%lx},",
592 vnode->fid.vid, vnode->fid.vnode, dentry->d_name.name, 593 vnode->fid.vid, vnode->fid.vnode, dentry,
593 vnode->flags); 594 vnode->flags);
594 else 595 else
595 _enter("{neg n=%s}", dentry->d_name.name); 596 _enter("{neg n=%pd}", dentry);
596 597
597 key = afs_request_key(AFS_FS_S(dentry->d_sb)->volume->cell); 598 key = afs_request_key(AFS_FS_S(dentry->d_sb)->volume->cell);
598 if (IS_ERR(key)) 599 if (IS_ERR(key))
@@ -607,7 +608,7 @@ static int afs_d_revalidate(struct dentry *dentry, unsigned int flags)
607 afs_validate(dir, key); 608 afs_validate(dir, key);
608 609
609 if (test_bit(AFS_VNODE_DELETED, &dir->flags)) { 610 if (test_bit(AFS_VNODE_DELETED, &dir->flags)) {
610 _debug("%s: parent dir deleted", dentry->d_name.name); 611 _debug("%pd: parent dir deleted", dentry);
611 goto out_bad; 612 goto out_bad;
612 } 613 }
613 614
@@ -625,16 +626,16 @@ static int afs_d_revalidate(struct dentry *dentry, unsigned int flags)
625 if (!dentry->d_inode) 626 if (!dentry->d_inode)
626 goto out_bad; 627 goto out_bad;
627 if (is_bad_inode(dentry->d_inode)) { 628 if (is_bad_inode(dentry->d_inode)) {
628 printk("kAFS: afs_d_revalidate: %s/%s has bad inode\n", 629 printk("kAFS: afs_d_revalidate: %pd2 has bad inode\n",
629 parent->d_name.name, dentry->d_name.name); 630 dentry);
630 goto out_bad; 631 goto out_bad;
631 } 632 }
632 633
633 /* if the vnode ID has changed, then the dirent points to a 634 /* if the vnode ID has changed, then the dirent points to a
634 * different file */ 635 * different file */
635 if (fid.vnode != vnode->fid.vnode) { 636 if (fid.vnode != vnode->fid.vnode) {
636 _debug("%s: dirent changed [%u != %u]", 637 _debug("%pd: dirent changed [%u != %u]",
637 dentry->d_name.name, fid.vnode, 638 dentry, fid.vnode,
638 vnode->fid.vnode); 639 vnode->fid.vnode);
639 goto not_found; 640 goto not_found;
640 } 641 }
@@ -643,8 +644,8 @@ static int afs_d_revalidate(struct dentry *dentry, unsigned int flags)
643 * been deleted and replaced, and the original vnode ID has 644 * been deleted and replaced, and the original vnode ID has
644 * been reused */ 645 * been reused */
645 if (fid.unique != vnode->fid.unique) { 646 if (fid.unique != vnode->fid.unique) {
646 _debug("%s: file deleted (uq %u -> %u I:%u)", 647 _debug("%pd: file deleted (uq %u -> %u I:%u)",
647 dentry->d_name.name, fid.unique, 648 dentry, fid.unique,
648 vnode->fid.unique, 649 vnode->fid.unique,
649 dentry->d_inode->i_generation); 650 dentry->d_inode->i_generation);
650 spin_lock(&vnode->lock); 651 spin_lock(&vnode->lock);
@@ -656,14 +657,14 @@ static int afs_d_revalidate(struct dentry *dentry, unsigned int flags)
656 657
657 case -ENOENT: 658 case -ENOENT:
658 /* the filename is unknown */ 659 /* the filename is unknown */
659 _debug("%s: dirent not found", dentry->d_name.name); 660 _debug("%pd: dirent not found", dentry);
660 if (dentry->d_inode) 661 if (dentry->d_inode)
661 goto not_found; 662 goto not_found;
662 goto out_valid; 663 goto out_valid;
663 664
664 default: 665 default:
665 _debug("failed to iterate dir %s: %d", 666 _debug("failed to iterate dir %pd: %d",
666 parent->d_name.name, ret); 667 parent, ret);
667 goto out_bad; 668 goto out_bad;
668 } 669 }
669 670
@@ -681,8 +682,7 @@ not_found:
681 spin_unlock(&dentry->d_lock); 682 spin_unlock(&dentry->d_lock);
682 683
683out_bad: 684out_bad:
684 _debug("dropping dentry %s/%s", 685 _debug("dropping dentry %pd2", dentry);
685 parent->d_name.name, dentry->d_name.name);
686 dput(parent); 686 dput(parent);
687 key_put(key); 687 key_put(key);
688 688
@@ -698,7 +698,7 @@ out_bad:
698 */ 698 */
699static int afs_d_delete(const struct dentry *dentry) 699static int afs_d_delete(const struct dentry *dentry)
700{ 700{
701 _enter("%s", dentry->d_name.name); 701 _enter("%pd", dentry);
702 702
703 if (dentry->d_flags & DCACHE_NFSFS_RENAMED) 703 if (dentry->d_flags & DCACHE_NFSFS_RENAMED)
704 goto zap; 704 goto zap;
@@ -721,7 +721,7 @@ zap:
721 */ 721 */
722static void afs_d_release(struct dentry *dentry) 722static void afs_d_release(struct dentry *dentry)
723{ 723{
724 _enter("%s", dentry->d_name.name); 724 _enter("%pd", dentry);
725} 725}
726 726
727/* 727/*
@@ -740,8 +740,8 @@ static int afs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
740 740
741 dvnode = AFS_FS_I(dir); 741 dvnode = AFS_FS_I(dir);
742 742
743 _enter("{%x:%u},{%s},%ho", 743 _enter("{%x:%u},{%pd},%ho",
744 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name, mode); 744 dvnode->fid.vid, dvnode->fid.vnode, dentry, mode);
745 745
746 key = afs_request_key(dvnode->volume->cell); 746 key = afs_request_key(dvnode->volume->cell);
747 if (IS_ERR(key)) { 747 if (IS_ERR(key)) {
@@ -801,8 +801,8 @@ static int afs_rmdir(struct inode *dir, struct dentry *dentry)
801 801
802 dvnode = AFS_FS_I(dir); 802 dvnode = AFS_FS_I(dir);
803 803
804 _enter("{%x:%u},{%s}", 804 _enter("{%x:%u},{%pd}",
805 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name); 805 dvnode->fid.vid, dvnode->fid.vnode, dentry);
806 806
807 key = afs_request_key(dvnode->volume->cell); 807 key = afs_request_key(dvnode->volume->cell);
808 if (IS_ERR(key)) { 808 if (IS_ERR(key)) {
@@ -843,8 +843,8 @@ static int afs_unlink(struct inode *dir, struct dentry *dentry)
843 843
844 dvnode = AFS_FS_I(dir); 844 dvnode = AFS_FS_I(dir);
845 845
846 _enter("{%x:%u},{%s}", 846 _enter("{%x:%u},{%pd}",
847 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name); 847 dvnode->fid.vid, dvnode->fid.vnode, dentry);
848 848
849 ret = -ENAMETOOLONG; 849 ret = -ENAMETOOLONG;
850 if (dentry->d_name.len >= AFSNAMEMAX) 850 if (dentry->d_name.len >= AFSNAMEMAX)
@@ -917,8 +917,8 @@ static int afs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
917 917
918 dvnode = AFS_FS_I(dir); 918 dvnode = AFS_FS_I(dir);
919 919
920 _enter("{%x:%u},{%s},%ho,", 920 _enter("{%x:%u},{%pd},%ho,",
921 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name, mode); 921 dvnode->fid.vid, dvnode->fid.vnode, dentry, mode);
922 922
923 key = afs_request_key(dvnode->volume->cell); 923 key = afs_request_key(dvnode->volume->cell);
924 if (IS_ERR(key)) { 924 if (IS_ERR(key)) {
@@ -980,10 +980,10 @@ static int afs_link(struct dentry *from, struct inode *dir,
980 vnode = AFS_FS_I(from->d_inode); 980 vnode = AFS_FS_I(from->d_inode);
981 dvnode = AFS_FS_I(dir); 981 dvnode = AFS_FS_I(dir);
982 982
983 _enter("{%x:%u},{%x:%u},{%s}", 983 _enter("{%x:%u},{%x:%u},{%pd}",
984 vnode->fid.vid, vnode->fid.vnode, 984 vnode->fid.vid, vnode->fid.vnode,
985 dvnode->fid.vid, dvnode->fid.vnode, 985 dvnode->fid.vid, dvnode->fid.vnode,
986 dentry->d_name.name); 986 dentry);
987 987
988 key = afs_request_key(dvnode->volume->cell); 988 key = afs_request_key(dvnode->volume->cell);
989 if (IS_ERR(key)) { 989 if (IS_ERR(key)) {
@@ -1025,8 +1025,8 @@ static int afs_symlink(struct inode *dir, struct dentry *dentry,
1025 1025
1026 dvnode = AFS_FS_I(dir); 1026 dvnode = AFS_FS_I(dir);
1027 1027
1028 _enter("{%x:%u},{%s},%s", 1028 _enter("{%x:%u},{%pd},%s",
1029 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name, 1029 dvnode->fid.vid, dvnode->fid.vnode, dentry,
1030 content); 1030 content);
1031 1031
1032 ret = -EINVAL; 1032 ret = -EINVAL;
@@ -1093,11 +1093,11 @@ static int afs_rename(struct inode *old_dir, struct dentry *old_dentry,
1093 orig_dvnode = AFS_FS_I(old_dir); 1093 orig_dvnode = AFS_FS_I(old_dir);
1094 new_dvnode = AFS_FS_I(new_dir); 1094 new_dvnode = AFS_FS_I(new_dir);
1095 1095
1096 _enter("{%x:%u},{%x:%u},{%x:%u},{%s}", 1096 _enter("{%x:%u},{%x:%u},{%x:%u},{%pd}",
1097 orig_dvnode->fid.vid, orig_dvnode->fid.vnode, 1097 orig_dvnode->fid.vid, orig_dvnode->fid.vnode,
1098 vnode->fid.vid, vnode->fid.vnode, 1098 vnode->fid.vid, vnode->fid.vnode,
1099 new_dvnode->fid.vid, new_dvnode->fid.vnode, 1099 new_dvnode->fid.vid, new_dvnode->fid.vnode,
1100 new_dentry->d_name.name); 1100 new_dentry);
1101 1101
1102 key = afs_request_key(orig_dvnode->volume->cell); 1102 key = afs_request_key(orig_dvnode->volume->cell);
1103 if (IS_ERR(key)) { 1103 if (IS_ERR(key)) {
diff --git a/fs/afs/inode.c b/fs/afs/inode.c
index 294671288449..8a1d38ef0fc2 100644
--- a/fs/afs/inode.c
+++ b/fs/afs/inode.c
@@ -462,8 +462,8 @@ int afs_setattr(struct dentry *dentry, struct iattr *attr)
462 struct key *key; 462 struct key *key;
463 int ret; 463 int ret;
464 464
465 _enter("{%x:%u},{n=%s},%x", 465 _enter("{%x:%u},{n=%pd},%x",
466 vnode->fid.vid, vnode->fid.vnode, dentry->d_name.name, 466 vnode->fid.vid, vnode->fid.vnode, dentry,
467 attr->ia_valid); 467 attr->ia_valid);
468 468
469 if (!(attr->ia_valid & (ATTR_SIZE | ATTR_MODE | ATTR_UID | ATTR_GID | 469 if (!(attr->ia_valid & (ATTR_SIZE | ATTR_MODE | ATTR_UID | ATTR_GID |
diff --git a/fs/afs/mntpt.c b/fs/afs/mntpt.c
index 9682c33d5daf..938c5ab06d5a 100644
--- a/fs/afs/mntpt.c
+++ b/fs/afs/mntpt.c
@@ -106,14 +106,7 @@ static struct dentry *afs_mntpt_lookup(struct inode *dir,
106 struct dentry *dentry, 106 struct dentry *dentry,
107 unsigned int flags) 107 unsigned int flags)
108{ 108{
109 _enter("%p,%p{%p{%s},%s}", 109 _enter("%p,%p{%pd2}", dir, dentry, dentry);
110 dir,
111 dentry,
112 dentry->d_parent,
113 dentry->d_parent ?
114 dentry->d_parent->d_name.name : (const unsigned char *) "",
115 dentry->d_name.name);
116
117 return ERR_PTR(-EREMOTE); 110 return ERR_PTR(-EREMOTE);
118} 111}
119 112
@@ -122,14 +115,7 @@ static struct dentry *afs_mntpt_lookup(struct inode *dir,
122 */ 115 */
123static int afs_mntpt_open(struct inode *inode, struct file *file) 116static int afs_mntpt_open(struct inode *inode, struct file *file)
124{ 117{
125 _enter("%p,%p{%p{%s},%s}", 118 _enter("%p,%p{%pD2}", inode, file, file);
126 inode, file,
127 file->f_path.dentry->d_parent,
128 file->f_path.dentry->d_parent ?
129 file->f_path.dentry->d_parent->d_name.name :
130 (const unsigned char *) "",
131 file->f_path.dentry->d_name.name);
132
133 return -EREMOTE; 119 return -EREMOTE;
134} 120}
135 121
@@ -146,7 +132,7 @@ static struct vfsmount *afs_mntpt_do_automount(struct dentry *mntpt)
146 bool rwpath = false; 132 bool rwpath = false;
147 int ret; 133 int ret;
148 134
149 _enter("{%s}", mntpt->d_name.name); 135 _enter("{%pd}", mntpt);
150 136
151 BUG_ON(!mntpt->d_inode); 137 BUG_ON(!mntpt->d_inode);
152 138
@@ -242,7 +228,7 @@ struct vfsmount *afs_d_automount(struct path *path)
242{ 228{
243 struct vfsmount *newmnt; 229 struct vfsmount *newmnt;
244 230
245 _enter("{%s}", path->dentry->d_name.name); 231 _enter("{%pd}", path->dentry);
246 232
247 newmnt = afs_mntpt_do_automount(path->dentry); 233 newmnt = afs_mntpt_do_automount(path->dentry);
248 if (IS_ERR(newmnt)) 234 if (IS_ERR(newmnt))
diff --git a/fs/afs/write.c b/fs/afs/write.c
index ab6adfd52516..c13cb08964ed 100644
--- a/fs/afs/write.c
+++ b/fs/afs/write.c
@@ -682,14 +682,13 @@ int afs_writeback_all(struct afs_vnode *vnode)
682 */ 682 */
683int afs_fsync(struct file *file, loff_t start, loff_t end, int datasync) 683int afs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
684{ 684{
685 struct dentry *dentry = file->f_path.dentry; 685 struct inode *inode = file_inode(file);
686 struct inode *inode = file->f_mapping->host;
687 struct afs_writeback *wb, *xwb; 686 struct afs_writeback *wb, *xwb;
688 struct afs_vnode *vnode = AFS_FS_I(dentry->d_inode); 687 struct afs_vnode *vnode = AFS_FS_I(inode);
689 int ret; 688 int ret;
690 689
691 _enter("{%x:%u},{n=%s},%d", 690 _enter("{%x:%u},{n=%pD},%d",
692 vnode->fid.vid, vnode->fid.vnode, dentry->d_name.name, 691 vnode->fid.vid, vnode->fid.vnode, file,
693 datasync); 692 datasync);
694 693
695 ret = filemap_write_and_wait_range(inode->i_mapping, start, end); 694 ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c
index 683a5b9ce22a..bfdbaba9c2ba 100644
--- a/fs/autofs4/expire.c
+++ b/fs/autofs4/expire.c
@@ -41,8 +41,7 @@ static int autofs4_mount_busy(struct vfsmount *mnt, struct dentry *dentry)
41 struct path path = {.mnt = mnt, .dentry = dentry}; 41 struct path path = {.mnt = mnt, .dentry = dentry};
42 int status = 1; 42 int status = 1;
43 43
44 DPRINTK("dentry %p %.*s", 44 DPRINTK("dentry %p %pd", dentry, dentry);
45 dentry, (int)dentry->d_name.len, dentry->d_name.name);
46 45
47 path_get(&path); 46 path_get(&path);
48 47
@@ -85,7 +84,7 @@ static struct dentry *get_next_positive_subdir(struct dentry *prev,
85 spin_lock(&root->d_lock); 84 spin_lock(&root->d_lock);
86 85
87 if (prev) 86 if (prev)
88 next = prev->d_u.d_child.next; 87 next = prev->d_child.next;
89 else { 88 else {
90 prev = dget_dlock(root); 89 prev = dget_dlock(root);
91 next = prev->d_subdirs.next; 90 next = prev->d_subdirs.next;
@@ -99,13 +98,13 @@ cont:
99 return NULL; 98 return NULL;
100 } 99 }
101 100
102 q = list_entry(next, struct dentry, d_u.d_child); 101 q = list_entry(next, struct dentry, d_child);
103 102
104 spin_lock_nested(&q->d_lock, DENTRY_D_LOCK_NESTED); 103 spin_lock_nested(&q->d_lock, DENTRY_D_LOCK_NESTED);
105 /* Already gone or negative dentry (under construction) - try next */ 104 /* Already gone or negative dentry (under construction) - try next */
106 if (!d_count(q) || !simple_positive(q)) { 105 if (!d_count(q) || !simple_positive(q)) {
107 spin_unlock(&q->d_lock); 106 spin_unlock(&q->d_lock);
108 next = q->d_u.d_child.next; 107 next = q->d_child.next;
109 goto cont; 108 goto cont;
110 } 109 }
111 dget_dlock(q); 110 dget_dlock(q);
@@ -155,13 +154,13 @@ again:
155 goto relock; 154 goto relock;
156 } 155 }
157 spin_unlock(&p->d_lock); 156 spin_unlock(&p->d_lock);
158 next = p->d_u.d_child.next; 157 next = p->d_child.next;
159 p = parent; 158 p = parent;
160 if (next != &parent->d_subdirs) 159 if (next != &parent->d_subdirs)
161 break; 160 break;
162 } 161 }
163 } 162 }
164 ret = list_entry(next, struct dentry, d_u.d_child); 163 ret = list_entry(next, struct dentry, d_child);
165 164
166 spin_lock_nested(&ret->d_lock, DENTRY_D_LOCK_NESTED); 165 spin_lock_nested(&ret->d_lock, DENTRY_D_LOCK_NESTED);
167 /* Negative dentry - try next */ 166 /* Negative dentry - try next */
@@ -192,8 +191,7 @@ static int autofs4_direct_busy(struct vfsmount *mnt,
192 unsigned long timeout, 191 unsigned long timeout,
193 int do_now) 192 int do_now)
194{ 193{
195 DPRINTK("top %p %.*s", 194 DPRINTK("top %p %pd", top, top);
196 top, (int) top->d_name.len, top->d_name.name);
197 195
198 /* If it's busy update the expiry counters */ 196 /* If it's busy update the expiry counters */
199 if (!may_umount_tree(mnt)) { 197 if (!may_umount_tree(mnt)) {
@@ -221,8 +219,7 @@ static int autofs4_tree_busy(struct vfsmount *mnt,
221 struct autofs_info *top_ino = autofs4_dentry_ino(top); 219 struct autofs_info *top_ino = autofs4_dentry_ino(top);
222 struct dentry *p; 220 struct dentry *p;
223 221
224 DPRINTK("top %p %.*s", 222 DPRINTK("top %p %pd", top, top);
225 top, (int)top->d_name.len, top->d_name.name);
226 223
227 /* Negative dentry - give up */ 224 /* Negative dentry - give up */
228 if (!simple_positive(top)) 225 if (!simple_positive(top))
@@ -230,8 +227,7 @@ static int autofs4_tree_busy(struct vfsmount *mnt,
230 227
231 p = NULL; 228 p = NULL;
232 while ((p = get_next_positive_dentry(p, top))) { 229 while ((p = get_next_positive_dentry(p, top))) {
233 DPRINTK("dentry %p %.*s", 230 DPRINTK("dentry %p %pd", p, p);
234 p, (int) p->d_name.len, p->d_name.name);
235 231
236 /* 232 /*
237 * Is someone visiting anywhere in the subtree ? 233 * Is someone visiting anywhere in the subtree ?
@@ -277,13 +273,11 @@ static struct dentry *autofs4_check_leaves(struct vfsmount *mnt,
277{ 273{
278 struct dentry *p; 274 struct dentry *p;
279 275
280 DPRINTK("parent %p %.*s", 276 DPRINTK("parent %p %pd", parent, parent);
281 parent, (int)parent->d_name.len, parent->d_name.name);
282 277
283 p = NULL; 278 p = NULL;
284 while ((p = get_next_positive_dentry(p, parent))) { 279 while ((p = get_next_positive_dentry(p, parent))) {
285 DPRINTK("dentry %p %.*s", 280 DPRINTK("dentry %p %pd", p, p);
286 p, (int) p->d_name.len, p->d_name.name);
287 281
288 if (d_mountpoint(p)) { 282 if (d_mountpoint(p)) {
289 /* Can we umount this guy */ 283 /* Can we umount this guy */
@@ -368,8 +362,7 @@ static struct dentry *should_expire(struct dentry *dentry,
368 * offset (autofs-5.0+). 362 * offset (autofs-5.0+).
369 */ 363 */
370 if (d_mountpoint(dentry)) { 364 if (d_mountpoint(dentry)) {
371 DPRINTK("checking mountpoint %p %.*s", 365 DPRINTK("checking mountpoint %p %pd", dentry, dentry);
372 dentry, (int)dentry->d_name.len, dentry->d_name.name);
373 366
374 /* Can we umount this guy */ 367 /* Can we umount this guy */
375 if (autofs4_mount_busy(mnt, dentry)) 368 if (autofs4_mount_busy(mnt, dentry))
@@ -382,8 +375,7 @@ static struct dentry *should_expire(struct dentry *dentry,
382 } 375 }
383 376
384 if (dentry->d_inode && S_ISLNK(dentry->d_inode->i_mode)) { 377 if (dentry->d_inode && S_ISLNK(dentry->d_inode->i_mode)) {
385 DPRINTK("checking symlink %p %.*s", 378 DPRINTK("checking symlink %p %pd", dentry, dentry);
386 dentry, (int)dentry->d_name.len, dentry->d_name.name);
387 /* 379 /*
388 * A symlink can't be "busy" in the usual sense so 380 * A symlink can't be "busy" in the usual sense so
389 * just check last used for expire timeout. 381 * just check last used for expire timeout.
@@ -479,8 +471,7 @@ struct dentry *autofs4_expire_indirect(struct super_block *sb,
479 return NULL; 471 return NULL;
480 472
481found: 473found:
482 DPRINTK("returning %p %.*s", 474 DPRINTK("returning %p %pd", expired, expired);
483 expired, (int)expired->d_name.len, expired->d_name.name);
484 ino->flags |= AUTOFS_INF_EXPIRING; 475 ino->flags |= AUTOFS_INF_EXPIRING;
485 smp_mb(); 476 smp_mb();
486 ino->flags &= ~AUTOFS_INF_NO_RCU; 477 ino->flags &= ~AUTOFS_INF_NO_RCU;
@@ -489,7 +480,7 @@ found:
489 spin_lock(&sbi->lookup_lock); 480 spin_lock(&sbi->lookup_lock);
490 spin_lock(&expired->d_parent->d_lock); 481 spin_lock(&expired->d_parent->d_lock);
491 spin_lock_nested(&expired->d_lock, DENTRY_D_LOCK_NESTED); 482 spin_lock_nested(&expired->d_lock, DENTRY_D_LOCK_NESTED);
492 list_move(&expired->d_parent->d_subdirs, &expired->d_u.d_child); 483 list_move(&expired->d_parent->d_subdirs, &expired->d_child);
493 spin_unlock(&expired->d_lock); 484 spin_unlock(&expired->d_lock);
494 spin_unlock(&expired->d_parent->d_lock); 485 spin_unlock(&expired->d_parent->d_lock);
495 spin_unlock(&sbi->lookup_lock); 486 spin_unlock(&sbi->lookup_lock);
@@ -512,8 +503,7 @@ int autofs4_expire_wait(struct dentry *dentry, int rcu_walk)
512 if (ino->flags & AUTOFS_INF_EXPIRING) { 503 if (ino->flags & AUTOFS_INF_EXPIRING) {
513 spin_unlock(&sbi->fs_lock); 504 spin_unlock(&sbi->fs_lock);
514 505
515 DPRINTK("waiting for expire %p name=%.*s", 506 DPRINTK("waiting for expire %p name=%pd", dentry, dentry);
516 dentry, dentry->d_name.len, dentry->d_name.name);
517 507
518 status = autofs4_wait(sbi, dentry, NFY_NONE); 508 status = autofs4_wait(sbi, dentry, NFY_NONE);
519 wait_for_completion(&ino->expire_complete); 509 wait_for_completion(&ino->expire_complete);
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index d76d083f2f06..dbb5b7212ce1 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -108,8 +108,7 @@ static int autofs4_dir_open(struct inode *inode, struct file *file)
108 struct dentry *dentry = file->f_path.dentry; 108 struct dentry *dentry = file->f_path.dentry;
109 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); 109 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
110 110
111 DPRINTK("file=%p dentry=%p %.*s", 111 DPRINTK("file=%p dentry=%p %pD", file, dentry, dentry);
112 file, dentry, dentry->d_name.len, dentry->d_name.name);
113 112
114 if (autofs4_oz_mode(sbi)) 113 if (autofs4_oz_mode(sbi))
115 goto out; 114 goto out;
@@ -279,8 +278,7 @@ static int autofs4_mount_wait(struct dentry *dentry, bool rcu_walk)
279 if (ino->flags & AUTOFS_INF_PENDING) { 278 if (ino->flags & AUTOFS_INF_PENDING) {
280 if (rcu_walk) 279 if (rcu_walk)
281 return -ECHILD; 280 return -ECHILD;
282 DPRINTK("waiting for mount name=%.*s", 281 DPRINTK("waiting for mount name=%pd", dentry);
283 dentry->d_name.len, dentry->d_name.name);
284 status = autofs4_wait(sbi, dentry, NFY_MOUNT); 282 status = autofs4_wait(sbi, dentry, NFY_MOUNT);
285 DPRINTK("mount wait done status=%d", status); 283 DPRINTK("mount wait done status=%d", status);
286 } 284 }
@@ -340,8 +338,7 @@ static struct vfsmount *autofs4_d_automount(struct path *path)
340 struct autofs_info *ino = autofs4_dentry_ino(dentry); 338 struct autofs_info *ino = autofs4_dentry_ino(dentry);
341 int status; 339 int status;
342 340
343 DPRINTK("dentry=%p %.*s", 341 DPRINTK("dentry=%p %pd", dentry, dentry);
344 dentry, dentry->d_name.len, dentry->d_name.name);
345 342
346 /* The daemon never triggers a mount. */ 343 /* The daemon never triggers a mount. */
347 if (autofs4_oz_mode(sbi)) 344 if (autofs4_oz_mode(sbi))
@@ -428,8 +425,7 @@ static int autofs4_d_manage(struct dentry *dentry, bool rcu_walk)
428 struct autofs_info *ino = autofs4_dentry_ino(dentry); 425 struct autofs_info *ino = autofs4_dentry_ino(dentry);
429 int status; 426 int status;
430 427
431 DPRINTK("dentry=%p %.*s", 428 DPRINTK("dentry=%p %pd", dentry, dentry);
432 dentry, dentry->d_name.len, dentry->d_name.name);
433 429
434 /* The daemon never waits. */ 430 /* The daemon never waits. */
435 if (autofs4_oz_mode(sbi)) { 431 if (autofs4_oz_mode(sbi)) {
@@ -504,7 +500,7 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, u
504 struct autofs_info *ino; 500 struct autofs_info *ino;
505 struct dentry *active; 501 struct dentry *active;
506 502
507 DPRINTK("name = %.*s", dentry->d_name.len, dentry->d_name.name); 503 DPRINTK("name = %pd", dentry);
508 504
509 /* File name too long to exist */ 505 /* File name too long to exist */
510 if (dentry->d_name.len > NAME_MAX) 506 if (dentry->d_name.len > NAME_MAX)
@@ -558,8 +554,7 @@ static int autofs4_dir_symlink(struct inode *dir,
558 size_t size = strlen(symname); 554 size_t size = strlen(symname);
559 char *cp; 555 char *cp;
560 556
561 DPRINTK("%s <- %.*s", symname, 557 DPRINTK("%s <- %pd", symname, dentry);
562 dentry->d_name.len, dentry->d_name.name);
563 558
564 if (!autofs4_oz_mode(sbi)) 559 if (!autofs4_oz_mode(sbi))
565 return -EACCES; 560 return -EACCES;
@@ -687,7 +682,7 @@ static void autofs_clear_leaf_automount_flags(struct dentry *dentry)
687 /* only consider parents below dentrys in the root */ 682 /* only consider parents below dentrys in the root */
688 if (IS_ROOT(parent->d_parent)) 683 if (IS_ROOT(parent->d_parent))
689 return; 684 return;
690 d_child = &dentry->d_u.d_child; 685 d_child = &dentry->d_child;
691 /* Set parent managed if it's becoming empty */ 686 /* Set parent managed if it's becoming empty */
692 if (d_child->next == &parent->d_subdirs && 687 if (d_child->next == &parent->d_subdirs &&
693 d_child->prev == &parent->d_subdirs) 688 d_child->prev == &parent->d_subdirs)
@@ -701,8 +696,7 @@ static int autofs4_dir_rmdir(struct inode *dir, struct dentry *dentry)
701 struct autofs_info *ino = autofs4_dentry_ino(dentry); 696 struct autofs_info *ino = autofs4_dentry_ino(dentry);
702 struct autofs_info *p_ino; 697 struct autofs_info *p_ino;
703 698
704 DPRINTK("dentry %p, removing %.*s", 699 DPRINTK("dentry %p, removing %pd", dentry, dentry);
705 dentry, dentry->d_name.len, dentry->d_name.name);
706 700
707 if (!autofs4_oz_mode(sbi)) 701 if (!autofs4_oz_mode(sbi))
708 return -EACCES; 702 return -EACCES;
@@ -744,8 +738,7 @@ static int autofs4_dir_mkdir(struct inode *dir, struct dentry *dentry, umode_t m
744 if (!autofs4_oz_mode(sbi)) 738 if (!autofs4_oz_mode(sbi))
745 return -EACCES; 739 return -EACCES;
746 740
747 DPRINTK("dentry %p, creating %.*s", 741 DPRINTK("dentry %p, creating %pd", dentry, dentry);
748 dentry, dentry->d_name.len, dentry->d_name.name);
749 742
750 BUG_ON(!ino); 743 BUG_ON(!ino);
751 744
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index 4cf61ec6b7a8..b94d1cc9cd30 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -172,8 +172,8 @@ befs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
172 char *utfname; 172 char *utfname;
173 const char *name = dentry->d_name.name; 173 const char *name = dentry->d_name.name;
174 174
175 befs_debug(sb, "---> %s name %s inode %ld", __func__, 175 befs_debug(sb, "---> %s name %pd inode %ld", __func__,
176 dentry->d_name.name, dir->i_ino); 176 dentry, dir->i_ino);
177 177
178 /* Convert to UTF-8 */ 178 /* Convert to UTF-8 */
179 if (BEFS_SB(sb)->nls) { 179 if (BEFS_SB(sb)->nls) {
@@ -191,8 +191,7 @@ befs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
191 } 191 }
192 192
193 if (ret == BEFS_BT_NOT_FOUND) { 193 if (ret == BEFS_BT_NOT_FOUND) {
194 befs_debug(sb, "<--- %s %s not found", __func__, 194 befs_debug(sb, "<--- %s %pd not found", __func__, dentry);
195 dentry->d_name.name);
196 return ERR_PTR(-ENOENT); 195 return ERR_PTR(-ENOENT);
197 196
198 } else if (ret != BEFS_OK || offset == 0) { 197 } else if (ret != BEFS_OK || offset == 0) {
@@ -222,10 +221,9 @@ befs_readdir(struct file *file, struct dir_context *ctx)
222 size_t keysize; 221 size_t keysize;
223 unsigned char d_type; 222 unsigned char d_type;
224 char keybuf[BEFS_NAME_LEN + 1]; 223 char keybuf[BEFS_NAME_LEN + 1];
225 const char *dirname = file->f_path.dentry->d_name.name;
226 224
227 befs_debug(sb, "---> %s name %s, inode %ld, ctx->pos %lld", 225 befs_debug(sb, "---> %s name %pD, inode %ld, ctx->pos %lld",
228 __func__, dirname, inode->i_ino, ctx->pos); 226 __func__, file, inode->i_ino, ctx->pos);
229 227
230more: 228more:
231 result = befs_btree_read(sb, ds, ctx->pos, BEFS_NAME_LEN + 1, 229 result = befs_btree_read(sb, ds, ctx->pos, BEFS_NAME_LEN + 1,
@@ -233,8 +231,8 @@ more:
233 231
234 if (result == BEFS_ERR) { 232 if (result == BEFS_ERR) {
235 befs_debug(sb, "<--- %s ERROR", __func__); 233 befs_debug(sb, "<--- %s ERROR", __func__);
236 befs_error(sb, "IO error reading %s (inode %lu)", 234 befs_error(sb, "IO error reading %pD (inode %lu)",
237 dirname, inode->i_ino); 235 file, inode->i_ino);
238 return -EIO; 236 return -EIO;
239 237
240 } else if (result == BEFS_BT_END) { 238 } else if (result == BEFS_BT_END) {
diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
index 929dec08c348..4c556680fa74 100644
--- a/fs/binfmt_aout.c
+++ b/fs/binfmt_aout.c
@@ -292,8 +292,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
292 if ((fd_offset & ~PAGE_MASK) != 0 && printk_ratelimit()) 292 if ((fd_offset & ~PAGE_MASK) != 0 && printk_ratelimit())
293 { 293 {
294 printk(KERN_WARNING 294 printk(KERN_WARNING
295 "fd_offset is not page aligned. Please convert program: %s\n", 295 "fd_offset is not page aligned. Please convert program: %pD\n",
296 bprm->file->f_path.dentry->d_name.name); 296 bprm->file);
297 } 297 }
298 298
299 if (!bprm->file->f_op->mmap||((fd_offset & ~PAGE_MASK) != 0)) { 299 if (!bprm->file->f_op->mmap||((fd_offset & ~PAGE_MASK) != 0)) {
@@ -375,8 +375,8 @@ static int load_aout_library(struct file *file)
375 if (printk_ratelimit()) 375 if (printk_ratelimit())
376 { 376 {
377 printk(KERN_WARNING 377 printk(KERN_WARNING
378 "N_TXTOFF is not page aligned. Please convert library: %s\n", 378 "N_TXTOFF is not page aligned. Please convert library: %pD\n",
379 file->f_path.dentry->d_name.name); 379 file);
380 } 380 }
381 vm_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss); 381 vm_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss);
382 382
diff --git a/fs/block_dev.c b/fs/block_dev.c
index cc9d4114cda0..1d9c9f3754f8 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1585,7 +1585,7 @@ ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from)
1585} 1585}
1586EXPORT_SYMBOL_GPL(blkdev_write_iter); 1586EXPORT_SYMBOL_GPL(blkdev_write_iter);
1587 1587
1588static ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to) 1588ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to)
1589{ 1589{
1590 struct file *file = iocb->ki_filp; 1590 struct file *file = iocb->ki_filp;
1591 struct inode *bd_inode = file->f_mapping->host; 1591 struct inode *bd_inode = file->f_mapping->host;
@@ -1599,6 +1599,7 @@ static ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to)
1599 iov_iter_truncate(to, size); 1599 iov_iter_truncate(to, size);
1600 return generic_file_read_iter(iocb, to); 1600 return generic_file_read_iter(iocb, to);
1601} 1601}
1602EXPORT_SYMBOL_GPL(blkdev_read_iter);
1602 1603
1603/* 1604/*
1604 * Try to release a page associated with block device when the system 1605 * Try to release a page associated with block device when the system
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 19bc6162fb8e..150822ee0a0b 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -80,13 +80,6 @@ noinline void btrfs_clear_path_blocking(struct btrfs_path *p,
80{ 80{
81 int i; 81 int i;
82 82
83#ifdef CONFIG_DEBUG_LOCK_ALLOC
84 /* lockdep really cares that we take all of these spinlocks
85 * in the right order. If any of the locks in the path are not
86 * currently blocking, it is going to complain. So, make really
87 * really sure by forcing the path to blocking before we clear
88 * the path blocking.
89 */
90 if (held) { 83 if (held) {
91 btrfs_set_lock_blocking_rw(held, held_rw); 84 btrfs_set_lock_blocking_rw(held, held_rw);
92 if (held_rw == BTRFS_WRITE_LOCK) 85 if (held_rw == BTRFS_WRITE_LOCK)
@@ -95,7 +88,6 @@ noinline void btrfs_clear_path_blocking(struct btrfs_path *p,
95 held_rw = BTRFS_READ_LOCK_BLOCKING; 88 held_rw = BTRFS_READ_LOCK_BLOCKING;
96 } 89 }
97 btrfs_set_path_blocking(p); 90 btrfs_set_path_blocking(p);
98#endif
99 91
100 for (i = BTRFS_MAX_LEVEL - 1; i >= 0; i--) { 92 for (i = BTRFS_MAX_LEVEL - 1; i >= 0; i--) {
101 if (p->nodes[i] && p->locks[i]) { 93 if (p->nodes[i] && p->locks[i]) {
@@ -107,10 +99,8 @@ noinline void btrfs_clear_path_blocking(struct btrfs_path *p,
107 } 99 }
108 } 100 }
109 101
110#ifdef CONFIG_DEBUG_LOCK_ALLOC
111 if (held) 102 if (held)
112 btrfs_clear_lock_blocking_rw(held, held_rw); 103 btrfs_clear_lock_blocking_rw(held, held_rw);
113#endif
114} 104}
115 105
116/* this also releases the path */ 106/* this also releases the path */
@@ -2893,7 +2883,7 @@ cow_done:
2893 } 2883 }
2894 p->locks[level] = BTRFS_WRITE_LOCK; 2884 p->locks[level] = BTRFS_WRITE_LOCK;
2895 } else { 2885 } else {
2896 err = btrfs_try_tree_read_lock(b); 2886 err = btrfs_tree_read_lock_atomic(b);
2897 if (!err) { 2887 if (!err) {
2898 btrfs_set_path_blocking(p); 2888 btrfs_set_path_blocking(p);
2899 btrfs_tree_read_lock(b); 2889 btrfs_tree_read_lock(b);
@@ -3025,7 +3015,7 @@ again:
3025 } 3015 }
3026 3016
3027 level = btrfs_header_level(b); 3017 level = btrfs_header_level(b);
3028 err = btrfs_try_tree_read_lock(b); 3018 err = btrfs_tree_read_lock_atomic(b);
3029 if (!err) { 3019 if (!err) {
3030 btrfs_set_path_blocking(p); 3020 btrfs_set_path_blocking(p);
3031 btrfs_tree_read_lock(b); 3021 btrfs_tree_read_lock(b);
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index d557264ee974..fe69edda11fb 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3276,7 +3276,7 @@ int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
3276 struct btrfs_root *root, unsigned long count); 3276 struct btrfs_root *root, unsigned long count);
3277int btrfs_async_run_delayed_refs(struct btrfs_root *root, 3277int btrfs_async_run_delayed_refs(struct btrfs_root *root,
3278 unsigned long count, int wait); 3278 unsigned long count, int wait);
3279int btrfs_lookup_extent(struct btrfs_root *root, u64 start, u64 len); 3279int btrfs_lookup_data_extent(struct btrfs_root *root, u64 start, u64 len);
3280int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans, 3280int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
3281 struct btrfs_root *root, u64 bytenr, 3281 struct btrfs_root *root, u64 bytenr,
3282 u64 offset, int metadata, u64 *refs, u64 *flags); 3282 u64 offset, int metadata, u64 *refs, u64 *flags);
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 1ad0f47ac850..1bf9f897065d 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3817,19 +3817,19 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info,
3817 struct btrfs_super_block *sb = fs_info->super_copy; 3817 struct btrfs_super_block *sb = fs_info->super_copy;
3818 int ret = 0; 3818 int ret = 0;
3819 3819
3820 if (sb->root_level > BTRFS_MAX_LEVEL) { 3820 if (btrfs_super_root_level(sb) >= BTRFS_MAX_LEVEL) {
3821 printk(KERN_ERR "BTRFS: tree_root level too big: %d > %d\n", 3821 printk(KERN_ERR "BTRFS: tree_root level too big: %d >= %d\n",
3822 sb->root_level, BTRFS_MAX_LEVEL); 3822 btrfs_super_root_level(sb), BTRFS_MAX_LEVEL);
3823 ret = -EINVAL; 3823 ret = -EINVAL;
3824 } 3824 }
3825 if (sb->chunk_root_level > BTRFS_MAX_LEVEL) { 3825 if (btrfs_super_chunk_root_level(sb) >= BTRFS_MAX_LEVEL) {
3826 printk(KERN_ERR "BTRFS: chunk_root level too big: %d > %d\n", 3826 printk(KERN_ERR "BTRFS: chunk_root level too big: %d >= %d\n",
3827 sb->chunk_root_level, BTRFS_MAX_LEVEL); 3827 btrfs_super_chunk_root_level(sb), BTRFS_MAX_LEVEL);
3828 ret = -EINVAL; 3828 ret = -EINVAL;
3829 } 3829 }
3830 if (sb->log_root_level > BTRFS_MAX_LEVEL) { 3830 if (btrfs_super_log_root_level(sb) >= BTRFS_MAX_LEVEL) {
3831 printk(KERN_ERR "BTRFS: log_root level too big: %d > %d\n", 3831 printk(KERN_ERR "BTRFS: log_root level too big: %d >= %d\n",
3832 sb->log_root_level, BTRFS_MAX_LEVEL); 3832 btrfs_super_log_root_level(sb), BTRFS_MAX_LEVEL);
3833 ret = -EINVAL; 3833 ret = -EINVAL;
3834 } 3834 }
3835 3835
@@ -3837,15 +3837,15 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info,
3837 * The common minimum, we don't know if we can trust the nodesize/sectorsize 3837 * The common minimum, we don't know if we can trust the nodesize/sectorsize
3838 * items yet, they'll be verified later. Issue just a warning. 3838 * items yet, they'll be verified later. Issue just a warning.
3839 */ 3839 */
3840 if (!IS_ALIGNED(sb->root, 4096)) 3840 if (!IS_ALIGNED(btrfs_super_root(sb), 4096))
3841 printk(KERN_WARNING "BTRFS: tree_root block unaligned: %llu\n", 3841 printk(KERN_WARNING "BTRFS: tree_root block unaligned: %llu\n",
3842 sb->root); 3842 sb->root);
3843 if (!IS_ALIGNED(sb->chunk_root, 4096)) 3843 if (!IS_ALIGNED(btrfs_super_chunk_root(sb), 4096))
3844 printk(KERN_WARNING "BTRFS: tree_root block unaligned: %llu\n", 3844 printk(KERN_WARNING "BTRFS: tree_root block unaligned: %llu\n",
3845 sb->chunk_root); 3845 sb->chunk_root);
3846 if (!IS_ALIGNED(sb->log_root, 4096)) 3846 if (!IS_ALIGNED(btrfs_super_log_root(sb), 4096))
3847 printk(KERN_WARNING "BTRFS: tree_root block unaligned: %llu\n", 3847 printk(KERN_WARNING "BTRFS: tree_root block unaligned: %llu\n",
3848 sb->log_root); 3848 btrfs_super_log_root(sb));
3849 3849
3850 if (memcmp(fs_info->fsid, sb->dev_item.fsid, BTRFS_UUID_SIZE) != 0) { 3850 if (memcmp(fs_info->fsid, sb->dev_item.fsid, BTRFS_UUID_SIZE) != 0) {
3851 printk(KERN_ERR "BTRFS: dev_item UUID does not match fsid: %pU != %pU\n", 3851 printk(KERN_ERR "BTRFS: dev_item UUID does not match fsid: %pU != %pU\n",
@@ -3857,13 +3857,13 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info,
3857 * Hint to catch really bogus numbers, bitflips or so, more exact checks are 3857 * Hint to catch really bogus numbers, bitflips or so, more exact checks are
3858 * done later 3858 * done later
3859 */ 3859 */
3860 if (sb->num_devices > (1UL << 31)) 3860 if (btrfs_super_num_devices(sb) > (1UL << 31))
3861 printk(KERN_WARNING "BTRFS: suspicious number of devices: %llu\n", 3861 printk(KERN_WARNING "BTRFS: suspicious number of devices: %llu\n",
3862 sb->num_devices); 3862 btrfs_super_num_devices(sb));
3863 3863
3864 if (sb->bytenr != BTRFS_SUPER_INFO_OFFSET) { 3864 if (btrfs_super_bytenr(sb) != BTRFS_SUPER_INFO_OFFSET) {
3865 printk(KERN_ERR "BTRFS: super offset mismatch %llu != %u\n", 3865 printk(KERN_ERR "BTRFS: super offset mismatch %llu != %u\n",
3866 sb->bytenr, BTRFS_SUPER_INFO_OFFSET); 3866 btrfs_super_bytenr(sb), BTRFS_SUPER_INFO_OFFSET);
3867 ret = -EINVAL; 3867 ret = -EINVAL;
3868 } 3868 }
3869 3869
@@ -3871,14 +3871,15 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info,
3871 * The generation is a global counter, we'll trust it more than the others 3871 * The generation is a global counter, we'll trust it more than the others
3872 * but it's still possible that it's the one that's wrong. 3872 * but it's still possible that it's the one that's wrong.
3873 */ 3873 */
3874 if (sb->generation < sb->chunk_root_generation) 3874 if (btrfs_super_generation(sb) < btrfs_super_chunk_root_generation(sb))
3875 printk(KERN_WARNING 3875 printk(KERN_WARNING
3876 "BTRFS: suspicious: generation < chunk_root_generation: %llu < %llu\n", 3876 "BTRFS: suspicious: generation < chunk_root_generation: %llu < %llu\n",
3877 sb->generation, sb->chunk_root_generation); 3877 btrfs_super_generation(sb), btrfs_super_chunk_root_generation(sb));
3878 if (sb->generation < sb->cache_generation && sb->cache_generation != (u64)-1) 3878 if (btrfs_super_generation(sb) < btrfs_super_cache_generation(sb)
3879 && btrfs_super_cache_generation(sb) != (u64)-1)
3879 printk(KERN_WARNING 3880 printk(KERN_WARNING
3880 "BTRFS: suspicious: generation < cache_generation: %llu < %llu\n", 3881 "BTRFS: suspicious: generation < cache_generation: %llu < %llu\n",
3881 sb->generation, sb->cache_generation); 3882 btrfs_super_generation(sb), btrfs_super_cache_generation(sb));
3882 3883
3883 return ret; 3884 return ret;
3884} 3885}
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index d56589571012..47c1ba141082 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -710,8 +710,8 @@ void btrfs_clear_space_info_full(struct btrfs_fs_info *info)
710 rcu_read_unlock(); 710 rcu_read_unlock();
711} 711}
712 712
713/* simple helper to search for an existing extent at a given offset */ 713/* simple helper to search for an existing data extent at a given offset */
714int btrfs_lookup_extent(struct btrfs_root *root, u64 start, u64 len) 714int btrfs_lookup_data_extent(struct btrfs_root *root, u64 start, u64 len)
715{ 715{
716 int ret; 716 int ret;
717 struct btrfs_key key; 717 struct btrfs_key key;
@@ -726,12 +726,6 @@ int btrfs_lookup_extent(struct btrfs_root *root, u64 start, u64 len)
726 key.type = BTRFS_EXTENT_ITEM_KEY; 726 key.type = BTRFS_EXTENT_ITEM_KEY;
727 ret = btrfs_search_slot(NULL, root->fs_info->extent_root, &key, path, 727 ret = btrfs_search_slot(NULL, root->fs_info->extent_root, &key, path,
728 0, 0); 728 0, 0);
729 if (ret > 0) {
730 btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]);
731 if (key.objectid == start &&
732 key.type == BTRFS_METADATA_ITEM_KEY)
733 ret = 0;
734 }
735 btrfs_free_path(path); 729 btrfs_free_path(path);
736 return ret; 730 return ret;
737} 731}
@@ -786,7 +780,6 @@ search_again:
786 else 780 else
787 key.type = BTRFS_EXTENT_ITEM_KEY; 781 key.type = BTRFS_EXTENT_ITEM_KEY;
788 782
789again:
790 ret = btrfs_search_slot(trans, root->fs_info->extent_root, 783 ret = btrfs_search_slot(trans, root->fs_info->extent_root,
791 &key, path, 0, 0); 784 &key, path, 0, 0);
792 if (ret < 0) 785 if (ret < 0)
@@ -802,13 +795,6 @@ again:
802 key.offset == root->nodesize) 795 key.offset == root->nodesize)
803 ret = 0; 796 ret = 0;
804 } 797 }
805 if (ret) {
806 key.objectid = bytenr;
807 key.type = BTRFS_EXTENT_ITEM_KEY;
808 key.offset = root->nodesize;
809 btrfs_release_path(path);
810 goto again;
811 }
812 } 798 }
813 799
814 if (ret == 0) { 800 if (ret == 0) {
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
index 783a94355efd..84a2d1868271 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
@@ -413,7 +413,7 @@ int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end,
413 ret = 0; 413 ret = 0;
414fail: 414fail:
415 while (ret < 0 && !list_empty(&tmplist)) { 415 while (ret < 0 && !list_empty(&tmplist)) {
416 sums = list_entry(&tmplist, struct btrfs_ordered_sum, list); 416 sums = list_entry(tmplist.next, struct btrfs_ordered_sum, list);
417 list_del(&sums->list); 417 list_del(&sums->list);
418 kfree(sums); 418 kfree(sums);
419 } 419 }
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index d23362f4464e..ff0dcc016b71 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -5303,7 +5303,7 @@ static struct dentry *btrfs_lookup(struct inode *dir, struct dentry *dentry,
5303 return ERR_CAST(inode); 5303 return ERR_CAST(inode);
5304 } 5304 }
5305 5305
5306 return d_materialise_unique(dentry, inode); 5306 return d_splice_alias(inode, dentry);
5307} 5307}
5308 5308
5309unsigned char btrfs_filetype_table[] = { 5309unsigned char btrfs_filetype_table[] = {
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 4399f0c3a4ce..080fe66c0349 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -5296,7 +5296,7 @@ long btrfs_ioctl(struct file *file, unsigned int
5296 ret = btrfs_start_delalloc_roots(root->fs_info, 0, -1); 5296 ret = btrfs_start_delalloc_roots(root->fs_info, 0, -1);
5297 if (ret) 5297 if (ret)
5298 return ret; 5298 return ret;
5299 ret = btrfs_sync_fs(file->f_dentry->d_sb, 1); 5299 ret = btrfs_sync_fs(file_inode(file)->i_sb, 1);
5300 /* 5300 /*
5301 * The transaction thread may want to do more work, 5301 * The transaction thread may want to do more work,
5302 * namely it pokes the cleaner ktread that will start 5302 * namely it pokes the cleaner ktread that will start
diff --git a/fs/btrfs/locking.c b/fs/btrfs/locking.c
index 5665d2149249..f8229ef1b46d 100644
--- a/fs/btrfs/locking.c
+++ b/fs/btrfs/locking.c
@@ -128,6 +128,26 @@ again:
128} 128}
129 129
130/* 130/*
131 * take a spinning read lock.
132 * returns 1 if we get the read lock and 0 if we don't
133 * this won't wait for blocking writers
134 */
135int btrfs_tree_read_lock_atomic(struct extent_buffer *eb)
136{
137 if (atomic_read(&eb->blocking_writers))
138 return 0;
139
140 read_lock(&eb->lock);
141 if (atomic_read(&eb->blocking_writers)) {
142 read_unlock(&eb->lock);
143 return 0;
144 }
145 atomic_inc(&eb->read_locks);
146 atomic_inc(&eb->spinning_readers);
147 return 1;
148}
149
150/*
131 * returns 1 if we get the read lock and 0 if we don't 151 * returns 1 if we get the read lock and 0 if we don't
132 * this won't wait for blocking writers 152 * this won't wait for blocking writers
133 */ 153 */
@@ -158,9 +178,7 @@ int btrfs_try_tree_write_lock(struct extent_buffer *eb)
158 atomic_read(&eb->blocking_readers)) 178 atomic_read(&eb->blocking_readers))
159 return 0; 179 return 0;
160 180
161 if (!write_trylock(&eb->lock)) 181 write_lock(&eb->lock);
162 return 0;
163
164 if (atomic_read(&eb->blocking_writers) || 182 if (atomic_read(&eb->blocking_writers) ||
165 atomic_read(&eb->blocking_readers)) { 183 atomic_read(&eb->blocking_readers)) {
166 write_unlock(&eb->lock); 184 write_unlock(&eb->lock);
diff --git a/fs/btrfs/locking.h b/fs/btrfs/locking.h
index b81e0e9a4894..c44a9d5f5362 100644
--- a/fs/btrfs/locking.h
+++ b/fs/btrfs/locking.h
@@ -35,6 +35,8 @@ void btrfs_clear_lock_blocking_rw(struct extent_buffer *eb, int rw);
35void btrfs_assert_tree_locked(struct extent_buffer *eb); 35void btrfs_assert_tree_locked(struct extent_buffer *eb);
36int btrfs_try_tree_read_lock(struct extent_buffer *eb); 36int btrfs_try_tree_read_lock(struct extent_buffer *eb);
37int btrfs_try_tree_write_lock(struct extent_buffer *eb); 37int btrfs_try_tree_write_lock(struct extent_buffer *eb);
38int btrfs_tree_read_lock_atomic(struct extent_buffer *eb);
39
38 40
39static inline void btrfs_tree_unlock_rw(struct extent_buffer *eb, int rw) 41static inline void btrfs_tree_unlock_rw(struct extent_buffer *eb, int rw)
40{ 42{
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index a2b97ef10317..54bd91ece35b 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -2151,6 +2151,7 @@ static void __exit exit_btrfs_fs(void)
2151 extent_map_exit(); 2151 extent_map_exit();
2152 extent_io_exit(); 2152 extent_io_exit();
2153 btrfs_interface_exit(); 2153 btrfs_interface_exit();
2154 btrfs_end_io_wq_exit();
2154 unregister_filesystem(&btrfs_fs_type); 2155 unregister_filesystem(&btrfs_fs_type);
2155 btrfs_exit_sysfs(); 2156 btrfs_exit_sysfs();
2156 btrfs_cleanup_fs_uuids(); 2157 btrfs_cleanup_fs_uuids();
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 1475979e5718..286213cec861 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -672,7 +672,7 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans,
672 * is this extent already allocated in the extent 672 * is this extent already allocated in the extent
673 * allocation tree? If so, just add a reference 673 * allocation tree? If so, just add a reference
674 */ 674 */
675 ret = btrfs_lookup_extent(root, ins.objectid, 675 ret = btrfs_lookup_data_extent(root, ins.objectid,
676 ins.offset); 676 ins.offset);
677 if (ret == 0) { 677 if (ret == 0) {
678 ret = btrfs_inc_extent_ref(trans, root, 678 ret = btrfs_inc_extent_ref(trans, root,
diff --git a/fs/buffer.c b/fs/buffer.c
index 6c48f20eddd4..20805db2c987 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -128,21 +128,15 @@ __clear_page_buffers(struct page *page)
128 page_cache_release(page); 128 page_cache_release(page);
129} 129}
130 130
131 131static void buffer_io_error(struct buffer_head *bh, char *msg)
132static int quiet_error(struct buffer_head *bh)
133{
134 if (!test_bit(BH_Quiet, &bh->b_state) && printk_ratelimit())
135 return 0;
136 return 1;
137}
138
139
140static void buffer_io_error(struct buffer_head *bh)
141{ 132{
142 char b[BDEVNAME_SIZE]; 133 char b[BDEVNAME_SIZE];
143 printk(KERN_ERR "Buffer I/O error on device %s, logical block %Lu\n", 134
135 if (!test_bit(BH_Quiet, &bh->b_state))
136 printk_ratelimited(KERN_ERR
137 "Buffer I/O error on dev %s, logical block %llu%s\n",
144 bdevname(bh->b_bdev, b), 138 bdevname(bh->b_bdev, b),
145 (unsigned long long)bh->b_blocknr); 139 (unsigned long long)bh->b_blocknr, msg);
146} 140}
147 141
148/* 142/*
@@ -177,17 +171,10 @@ EXPORT_SYMBOL(end_buffer_read_sync);
177 171
178void end_buffer_write_sync(struct buffer_head *bh, int uptodate) 172void end_buffer_write_sync(struct buffer_head *bh, int uptodate)
179{ 173{
180 char b[BDEVNAME_SIZE];
181
182 if (uptodate) { 174 if (uptodate) {
183 set_buffer_uptodate(bh); 175 set_buffer_uptodate(bh);
184 } else { 176 } else {
185 if (!quiet_error(bh)) { 177 buffer_io_error(bh, ", lost sync page write");
186 buffer_io_error(bh);
187 printk(KERN_WARNING "lost page write due to "
188 "I/O error on %s\n",
189 bdevname(bh->b_bdev, b));
190 }
191 set_buffer_write_io_error(bh); 178 set_buffer_write_io_error(bh);
192 clear_buffer_uptodate(bh); 179 clear_buffer_uptodate(bh);
193 } 180 }
@@ -304,8 +291,7 @@ static void end_buffer_async_read(struct buffer_head *bh, int uptodate)
304 set_buffer_uptodate(bh); 291 set_buffer_uptodate(bh);
305 } else { 292 } else {
306 clear_buffer_uptodate(bh); 293 clear_buffer_uptodate(bh);
307 if (!quiet_error(bh)) 294 buffer_io_error(bh, ", async page read");
308 buffer_io_error(bh);
309 SetPageError(page); 295 SetPageError(page);
310 } 296 }
311 297
@@ -353,7 +339,6 @@ still_busy:
353 */ 339 */
354void end_buffer_async_write(struct buffer_head *bh, int uptodate) 340void end_buffer_async_write(struct buffer_head *bh, int uptodate)
355{ 341{
356 char b[BDEVNAME_SIZE];
357 unsigned long flags; 342 unsigned long flags;
358 struct buffer_head *first; 343 struct buffer_head *first;
359 struct buffer_head *tmp; 344 struct buffer_head *tmp;
@@ -365,12 +350,7 @@ void end_buffer_async_write(struct buffer_head *bh, int uptodate)
365 if (uptodate) { 350 if (uptodate) {
366 set_buffer_uptodate(bh); 351 set_buffer_uptodate(bh);
367 } else { 352 } else {
368 if (!quiet_error(bh)) { 353 buffer_io_error(bh, ", lost async page write");
369 buffer_io_error(bh);
370 printk(KERN_WARNING "lost page write due to "
371 "I/O error on %s\n",
372 bdevname(bh->b_bdev, b));
373 }
374 set_bit(AS_EIO, &page->mapping->flags); 354 set_bit(AS_EIO, &page->mapping->flags);
375 set_buffer_write_io_error(bh); 355 set_buffer_write_io_error(bh);
376 clear_buffer_uptodate(bh); 356 clear_buffer_uptodate(bh);
diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
index e12f189d539b..7f8e83f9d74e 100644
--- a/fs/cachefiles/namei.c
+++ b/fs/cachefiles/namei.c
@@ -102,8 +102,7 @@ static void cachefiles_mark_object_buried(struct cachefiles_cache *cache,
102 struct cachefiles_object *object; 102 struct cachefiles_object *object;
103 struct rb_node *p; 103 struct rb_node *p;
104 104
105 _enter(",'%*.*s'", 105 _enter(",'%pd'", dentry);
106 dentry->d_name.len, dentry->d_name.len, dentry->d_name.name);
107 106
108 write_lock(&cache->active_lock); 107 write_lock(&cache->active_lock);
109 108
@@ -273,9 +272,7 @@ static int cachefiles_bury_object(struct cachefiles_cache *cache,
273 char nbuffer[8 + 8 + 1]; 272 char nbuffer[8 + 8 + 1];
274 int ret; 273 int ret;
275 274
276 _enter(",'%*.*s','%*.*s'", 275 _enter(",'%pd','%pd'", dir, rep);
277 dir->d_name.len, dir->d_name.len, dir->d_name.name,
278 rep->d_name.len, rep->d_name.len, rep->d_name.name);
279 276
280 _debug("remove %p from %p", rep, dir); 277 _debug("remove %p from %p", rep, dir);
281 278
@@ -597,8 +594,7 @@ lookup_again:
597 /* if we've found that the terminal object exists, then we need to 594 /* if we've found that the terminal object exists, then we need to
598 * check its attributes and delete it if it's out of date */ 595 * check its attributes and delete it if it's out of date */
599 if (!object->new) { 596 if (!object->new) {
600 _debug("validate '%*.*s'", 597 _debug("validate '%pd'", next);
601 next->d_name.len, next->d_name.len, next->d_name.name);
602 598
603 ret = cachefiles_check_object_xattr(object, auxdata); 599 ret = cachefiles_check_object_xattr(object, auxdata);
604 if (ret == -ESTALE) { 600 if (ret == -ESTALE) {
@@ -827,8 +823,8 @@ static struct dentry *cachefiles_check_active(struct cachefiles_cache *cache,
827 unsigned long start; 823 unsigned long start;
828 int ret; 824 int ret;
829 825
830 //_enter(",%*.*s/,%s", 826 //_enter(",%pd/,%s",
831 // dir->d_name.len, dir->d_name.len, dir->d_name.name, filename); 827 // dir, filename);
832 828
833 /* look up the victim */ 829 /* look up the victim */
834 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT); 830 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
@@ -910,8 +906,7 @@ int cachefiles_cull(struct cachefiles_cache *cache, struct dentry *dir,
910 struct dentry *victim; 906 struct dentry *victim;
911 int ret; 907 int ret;
912 908
913 _enter(",%*.*s/,%s", 909 _enter(",%pd/,%s", dir, filename);
914 dir->d_name.len, dir->d_name.len, dir->d_name.name, filename);
915 910
916 victim = cachefiles_check_active(cache, dir, filename); 911 victim = cachefiles_check_active(cache, dir, filename);
917 if (IS_ERR(victim)) 912 if (IS_ERR(victim))
@@ -969,8 +964,8 @@ int cachefiles_check_in_use(struct cachefiles_cache *cache, struct dentry *dir,
969{ 964{
970 struct dentry *victim; 965 struct dentry *victim;
971 966
972 //_enter(",%*.*s/,%s", 967 //_enter(",%pd/,%s",
973 // dir->d_name.len, dir->d_name.len, dir->d_name.name, filename); 968 // dir, filename);
974 969
975 victim = cachefiles_check_active(cache, dir, filename); 970 victim = cachefiles_check_active(cache, dir, filename);
976 if (IS_ERR(victim)) 971 if (IS_ERR(victim))
diff --git a/fs/cachefiles/xattr.c b/fs/cachefiles/xattr.c
index acbc1f094fb1..a8a68745e11d 100644
--- a/fs/cachefiles/xattr.c
+++ b/fs/cachefiles/xattr.c
@@ -51,9 +51,8 @@ int cachefiles_check_object_type(struct cachefiles_object *object)
51 } 51 }
52 52
53 if (ret != -EEXIST) { 53 if (ret != -EEXIST) {
54 pr_err("Can't set xattr on %*.*s [%lu] (err %d)\n", 54 pr_err("Can't set xattr on %pd [%lu] (err %d)\n",
55 dentry->d_name.len, dentry->d_name.len, 55 dentry, dentry->d_inode->i_ino,
56 dentry->d_name.name, dentry->d_inode->i_ino,
57 -ret); 56 -ret);
58 goto error; 57 goto error;
59 } 58 }
@@ -64,9 +63,8 @@ int cachefiles_check_object_type(struct cachefiles_object *object)
64 if (ret == -ERANGE) 63 if (ret == -ERANGE)
65 goto bad_type_length; 64 goto bad_type_length;
66 65
67 pr_err("Can't read xattr on %*.*s [%lu] (err %d)\n", 66 pr_err("Can't read xattr on %pd [%lu] (err %d)\n",
68 dentry->d_name.len, dentry->d_name.len, 67 dentry, dentry->d_inode->i_ino,
69 dentry->d_name.name, dentry->d_inode->i_ino,
70 -ret); 68 -ret);
71 goto error; 69 goto error;
72 } 70 }
@@ -92,9 +90,8 @@ bad_type_length:
92 90
93bad_type: 91bad_type:
94 xtype[2] = 0; 92 xtype[2] = 0;
95 pr_err("Cache object %*.*s [%lu] type %s not %s\n", 93 pr_err("Cache object %pd [%lu] type %s not %s\n",
96 dentry->d_name.len, dentry->d_name.len, 94 dentry, dentry->d_inode->i_ino,
97 dentry->d_name.name, dentry->d_inode->i_ino,
98 xtype, type); 95 xtype, type);
99 ret = -EIO; 96 ret = -EIO;
100 goto error; 97 goto error;
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 659f2ea9e6f7..cefca661464b 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -2638,7 +2638,7 @@ static void handle_cap_flush_ack(struct inode *inode, u64 flush_tid,
2638 2638
2639 for (i = 0; i < CEPH_CAP_BITS; i++) 2639 for (i = 0; i < CEPH_CAP_BITS; i++)
2640 if ((dirty & (1 << i)) && 2640 if ((dirty & (1 << i)) &&
2641 flush_tid == ci->i_cap_flush_tid[i]) 2641 (u16)flush_tid == ci->i_cap_flush_tid[i])
2642 cleaned |= 1 << i; 2642 cleaned |= 1 << i;
2643 2643
2644 dout("handle_cap_flush_ack inode %p mds%d seq %d on %s cleaned %s," 2644 dout("handle_cap_flush_ack inode %p mds%d seq %d on %s cleaned %s,"
diff --git a/fs/ceph/debugfs.c b/fs/ceph/debugfs.c
index 5d5a4c8c8496..1b2355109b9f 100644
--- a/fs/ceph/debugfs.c
+++ b/fs/ceph/debugfs.c
@@ -83,10 +83,9 @@ static int mdsc_show(struct seq_file *s, void *p)
83 if (IS_ERR(path)) 83 if (IS_ERR(path))
84 path = NULL; 84 path = NULL;
85 spin_lock(&req->r_dentry->d_lock); 85 spin_lock(&req->r_dentry->d_lock);
86 seq_printf(s, " #%llx/%.*s (%s)", 86 seq_printf(s, " #%llx/%pd (%s)",
87 ceph_ino(req->r_dentry->d_parent->d_inode), 87 ceph_ino(req->r_dentry->d_parent->d_inode),
88 req->r_dentry->d_name.len, 88 req->r_dentry,
89 req->r_dentry->d_name.name,
90 path ? path : ""); 89 path ? path : "");
91 spin_unlock(&req->r_dentry->d_lock); 90 spin_unlock(&req->r_dentry->d_lock);
92 kfree(path); 91 kfree(path);
@@ -103,11 +102,10 @@ static int mdsc_show(struct seq_file *s, void *p)
103 if (IS_ERR(path)) 102 if (IS_ERR(path))
104 path = NULL; 103 path = NULL;
105 spin_lock(&req->r_old_dentry->d_lock); 104 spin_lock(&req->r_old_dentry->d_lock);
106 seq_printf(s, " #%llx/%.*s (%s)", 105 seq_printf(s, " #%llx/%pd (%s)",
107 req->r_old_dentry_dir ? 106 req->r_old_dentry_dir ?
108 ceph_ino(req->r_old_dentry_dir) : 0, 107 ceph_ino(req->r_old_dentry_dir) : 0,
109 req->r_old_dentry->d_name.len, 108 req->r_old_dentry,
110 req->r_old_dentry->d_name.name,
111 path ? path : ""); 109 path ? path : "");
112 spin_unlock(&req->r_old_dentry->d_lock); 110 spin_unlock(&req->r_old_dentry->d_lock);
113 kfree(path); 111 kfree(path);
@@ -150,8 +148,8 @@ static int dentry_lru_show(struct seq_file *s, void *ptr)
150 spin_lock(&mdsc->dentry_lru_lock); 148 spin_lock(&mdsc->dentry_lru_lock);
151 list_for_each_entry(di, &mdsc->dentry_lru, lru) { 149 list_for_each_entry(di, &mdsc->dentry_lru, lru) {
152 struct dentry *dentry = di->dentry; 150 struct dentry *dentry = di->dentry;
153 seq_printf(s, "%p %p\t%.*s\n", 151 seq_printf(s, "%p %p\t%pd\n",
154 di, dentry, dentry->d_name.len, dentry->d_name.name); 152 di, dentry, dentry);
155 } 153 }
156 spin_unlock(&mdsc->dentry_lru_lock); 154 spin_unlock(&mdsc->dentry_lru_lock);
157 155
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index e6d63f8f98c0..681a8537b64f 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -111,7 +111,7 @@ static int fpos_cmp(loff_t l, loff_t r)
111/* 111/*
112 * When possible, we try to satisfy a readdir by peeking at the 112 * When possible, we try to satisfy a readdir by peeking at the
113 * dcache. We make this work by carefully ordering dentries on 113 * dcache. We make this work by carefully ordering dentries on
114 * d_u.d_child when we initially get results back from the MDS, and 114 * d_child when we initially get results back from the MDS, and
115 * falling back to a "normal" sync readdir if any dentries in the dir 115 * falling back to a "normal" sync readdir if any dentries in the dir
116 * are dropped. 116 * are dropped.
117 * 117 *
@@ -123,7 +123,7 @@ static int __dcache_readdir(struct file *file, struct dir_context *ctx,
123 u32 shared_gen) 123 u32 shared_gen)
124{ 124{
125 struct ceph_file_info *fi = file->private_data; 125 struct ceph_file_info *fi = file->private_data;
126 struct dentry *parent = file->f_dentry; 126 struct dentry *parent = file->f_path.dentry;
127 struct inode *dir = parent->d_inode; 127 struct inode *dir = parent->d_inode;
128 struct list_head *p; 128 struct list_head *p;
129 struct dentry *dentry, *last; 129 struct dentry *dentry, *last;
@@ -147,11 +147,11 @@ static int __dcache_readdir(struct file *file, struct dir_context *ctx,
147 p = parent->d_subdirs.prev; 147 p = parent->d_subdirs.prev;
148 dout(" initial p %p/%p\n", p->prev, p->next); 148 dout(" initial p %p/%p\n", p->prev, p->next);
149 } else { 149 } else {
150 p = last->d_u.d_child.prev; 150 p = last->d_child.prev;
151 } 151 }
152 152
153more: 153more:
154 dentry = list_entry(p, struct dentry, d_u.d_child); 154 dentry = list_entry(p, struct dentry, d_child);
155 di = ceph_dentry(dentry); 155 di = ceph_dentry(dentry);
156 while (1) { 156 while (1) {
157 dout(" p %p/%p %s d_subdirs %p/%p\n", p->prev, p->next, 157 dout(" p %p/%p %s d_subdirs %p/%p\n", p->prev, p->next,
@@ -168,13 +168,13 @@ more:
168 ceph_ino(dentry->d_inode) != CEPH_INO_CEPH && 168 ceph_ino(dentry->d_inode) != CEPH_INO_CEPH &&
169 fpos_cmp(ctx->pos, di->offset) <= 0) 169 fpos_cmp(ctx->pos, di->offset) <= 0)
170 break; 170 break;
171 dout(" skipping %p %.*s at %llu (%llu)%s%s\n", dentry, 171 dout(" skipping %p %pd at %llu (%llu)%s%s\n", dentry,
172 dentry->d_name.len, dentry->d_name.name, di->offset, 172 dentry, di->offset,
173 ctx->pos, d_unhashed(dentry) ? " unhashed" : "", 173 ctx->pos, d_unhashed(dentry) ? " unhashed" : "",
174 !dentry->d_inode ? " null" : ""); 174 !dentry->d_inode ? " null" : "");
175 spin_unlock(&dentry->d_lock); 175 spin_unlock(&dentry->d_lock);
176 p = p->prev; 176 p = p->prev;
177 dentry = list_entry(p, struct dentry, d_u.d_child); 177 dentry = list_entry(p, struct dentry, d_child);
178 di = ceph_dentry(dentry); 178 di = ceph_dentry(dentry);
179 } 179 }
180 180
@@ -190,8 +190,8 @@ more:
190 goto out; 190 goto out;
191 } 191 }
192 192
193 dout(" %llu (%llu) dentry %p %.*s %p\n", di->offset, ctx->pos, 193 dout(" %llu (%llu) dentry %p %pd %p\n", di->offset, ctx->pos,
194 dentry, dentry->d_name.len, dentry->d_name.name, dentry->d_inode); 194 dentry, dentry, dentry->d_inode);
195 if (!dir_emit(ctx, dentry->d_name.name, 195 if (!dir_emit(ctx, dentry->d_name.name,
196 dentry->d_name.len, 196 dentry->d_name.len,
197 ceph_translate_ino(dentry->d_sb, dentry->d_inode->i_ino), 197 ceph_translate_ino(dentry->d_sb, dentry->d_inode->i_ino),
@@ -274,7 +274,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
274 off = 1; 274 off = 1;
275 } 275 }
276 if (ctx->pos == 1) { 276 if (ctx->pos == 1) {
277 ino_t ino = parent_ino(file->f_dentry); 277 ino_t ino = parent_ino(file->f_path.dentry);
278 dout("readdir off 1 -> '..'\n"); 278 dout("readdir off 1 -> '..'\n");
279 if (!dir_emit(ctx, "..", 2, 279 if (!dir_emit(ctx, "..", 2,
280 ceph_translate_ino(inode->i_sb, ino), 280 ceph_translate_ino(inode->i_sb, ino),
@@ -337,7 +337,7 @@ more:
337 } 337 }
338 req->r_inode = inode; 338 req->r_inode = inode;
339 ihold(inode); 339 ihold(inode);
340 req->r_dentry = dget(file->f_dentry); 340 req->r_dentry = dget(file->f_path.dentry);
341 /* hints to request -> mds selection code */ 341 /* hints to request -> mds selection code */
342 req->r_direct_mode = USE_AUTH_MDS; 342 req->r_direct_mode = USE_AUTH_MDS;
343 req->r_direct_hash = ceph_frag_value(frag); 343 req->r_direct_hash = ceph_frag_value(frag);
@@ -538,8 +538,8 @@ int ceph_handle_snapdir(struct ceph_mds_request *req,
538 strcmp(dentry->d_name.name, 538 strcmp(dentry->d_name.name,
539 fsc->mount_options->snapdir_name) == 0) { 539 fsc->mount_options->snapdir_name) == 0) {
540 struct inode *inode = ceph_get_snapdir(parent); 540 struct inode *inode = ceph_get_snapdir(parent);
541 dout("ENOENT on snapdir %p '%.*s', linking to snapdir %p\n", 541 dout("ENOENT on snapdir %p '%pd', linking to snapdir %p\n",
542 dentry, dentry->d_name.len, dentry->d_name.name, inode); 542 dentry, dentry, inode);
543 BUG_ON(!d_unhashed(dentry)); 543 BUG_ON(!d_unhashed(dentry));
544 d_add(dentry, inode); 544 d_add(dentry, inode);
545 err = 0; 545 err = 0;
@@ -603,8 +603,8 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
603 int op; 603 int op;
604 int err; 604 int err;
605 605
606 dout("lookup %p dentry %p '%.*s'\n", 606 dout("lookup %p dentry %p '%pd'\n",
607 dir, dentry, dentry->d_name.len, dentry->d_name.name); 607 dir, dentry, dentry);
608 608
609 if (dentry->d_name.len > NAME_MAX) 609 if (dentry->d_name.len > NAME_MAX)
610 return ERR_PTR(-ENAMETOOLONG); 610 return ERR_PTR(-ENAMETOOLONG);
@@ -774,8 +774,8 @@ static int ceph_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
774 if (ceph_snap(dir) == CEPH_SNAPDIR) { 774 if (ceph_snap(dir) == CEPH_SNAPDIR) {
775 /* mkdir .snap/foo is a MKSNAP */ 775 /* mkdir .snap/foo is a MKSNAP */
776 op = CEPH_MDS_OP_MKSNAP; 776 op = CEPH_MDS_OP_MKSNAP;
777 dout("mksnap dir %p snap '%.*s' dn %p\n", dir, 777 dout("mksnap dir %p snap '%pd' dn %p\n", dir,
778 dentry->d_name.len, dentry->d_name.name, dentry); 778 dentry, dentry);
779 } else if (ceph_snap(dir) == CEPH_NOSNAP) { 779 } else if (ceph_snap(dir) == CEPH_NOSNAP) {
780 dout("mkdir dir %p dn %p mode 0%ho\n", dir, dentry, mode); 780 dout("mkdir dir %p dn %p mode 0%ho\n", dir, dentry, mode);
781 op = CEPH_MDS_OP_MKDIR; 781 op = CEPH_MDS_OP_MKDIR;
@@ -888,8 +888,7 @@ static int ceph_unlink(struct inode *dir, struct dentry *dentry)
888 888
889 if (ceph_snap(dir) == CEPH_SNAPDIR) { 889 if (ceph_snap(dir) == CEPH_SNAPDIR) {
890 /* rmdir .snap/foo is RMSNAP */ 890 /* rmdir .snap/foo is RMSNAP */
891 dout("rmsnap dir %p '%.*s' dn %p\n", dir, dentry->d_name.len, 891 dout("rmsnap dir %p '%pd' dn %p\n", dir, dentry, dentry);
892 dentry->d_name.name, dentry);
893 op = CEPH_MDS_OP_RMSNAP; 892 op = CEPH_MDS_OP_RMSNAP;
894 } else if (ceph_snap(dir) == CEPH_NOSNAP) { 893 } else if (ceph_snap(dir) == CEPH_NOSNAP) {
895 dout("unlink/rmdir dir %p dn %p inode %p\n", 894 dout("unlink/rmdir dir %p dn %p inode %p\n",
@@ -1063,16 +1062,15 @@ static int ceph_d_revalidate(struct dentry *dentry, unsigned int flags)
1063 if (flags & LOOKUP_RCU) 1062 if (flags & LOOKUP_RCU)
1064 return -ECHILD; 1063 return -ECHILD;
1065 1064
1066 dout("d_revalidate %p '%.*s' inode %p offset %lld\n", dentry, 1065 dout("d_revalidate %p '%pd' inode %p offset %lld\n", dentry,
1067 dentry->d_name.len, dentry->d_name.name, dentry->d_inode, 1066 dentry, dentry->d_inode, ceph_dentry(dentry)->offset);
1068 ceph_dentry(dentry)->offset);
1069 1067
1070 dir = ceph_get_dentry_parent_inode(dentry); 1068 dir = ceph_get_dentry_parent_inode(dentry);
1071 1069
1072 /* always trust cached snapped dentries, snapdir dentry */ 1070 /* always trust cached snapped dentries, snapdir dentry */
1073 if (ceph_snap(dir) != CEPH_NOSNAP) { 1071 if (ceph_snap(dir) != CEPH_NOSNAP) {
1074 dout("d_revalidate %p '%.*s' inode %p is SNAPPED\n", dentry, 1072 dout("d_revalidate %p '%pd' inode %p is SNAPPED\n", dentry,
1075 dentry->d_name.len, dentry->d_name.name, dentry->d_inode); 1073 dentry, dentry->d_inode);
1076 valid = 1; 1074 valid = 1;
1077 } else if (dentry->d_inode && 1075 } else if (dentry->d_inode &&
1078 ceph_snap(dentry->d_inode) == CEPH_SNAPDIR) { 1076 ceph_snap(dentry->d_inode) == CEPH_SNAPDIR) {
@@ -1265,8 +1263,7 @@ void ceph_dentry_lru_add(struct dentry *dn)
1265 struct ceph_dentry_info *di = ceph_dentry(dn); 1263 struct ceph_dentry_info *di = ceph_dentry(dn);
1266 struct ceph_mds_client *mdsc; 1264 struct ceph_mds_client *mdsc;
1267 1265
1268 dout("dentry_lru_add %p %p '%.*s'\n", di, dn, 1266 dout("dentry_lru_add %p %p '%pd'\n", di, dn, dn);
1269 dn->d_name.len, dn->d_name.name);
1270 mdsc = ceph_sb_to_client(dn->d_sb)->mdsc; 1267 mdsc = ceph_sb_to_client(dn->d_sb)->mdsc;
1271 spin_lock(&mdsc->dentry_lru_lock); 1268 spin_lock(&mdsc->dentry_lru_lock);
1272 list_add_tail(&di->lru, &mdsc->dentry_lru); 1269 list_add_tail(&di->lru, &mdsc->dentry_lru);
@@ -1279,8 +1276,8 @@ void ceph_dentry_lru_touch(struct dentry *dn)
1279 struct ceph_dentry_info *di = ceph_dentry(dn); 1276 struct ceph_dentry_info *di = ceph_dentry(dn);
1280 struct ceph_mds_client *mdsc; 1277 struct ceph_mds_client *mdsc;
1281 1278
1282 dout("dentry_lru_touch %p %p '%.*s' (offset %lld)\n", di, dn, 1279 dout("dentry_lru_touch %p %p '%pd' (offset %lld)\n", di, dn, dn,
1283 dn->d_name.len, dn->d_name.name, di->offset); 1280 di->offset);
1284 mdsc = ceph_sb_to_client(dn->d_sb)->mdsc; 1281 mdsc = ceph_sb_to_client(dn->d_sb)->mdsc;
1285 spin_lock(&mdsc->dentry_lru_lock); 1282 spin_lock(&mdsc->dentry_lru_lock);
1286 list_move_tail(&di->lru, &mdsc->dentry_lru); 1283 list_move_tail(&di->lru, &mdsc->dentry_lru);
@@ -1292,8 +1289,7 @@ void ceph_dentry_lru_del(struct dentry *dn)
1292 struct ceph_dentry_info *di = ceph_dentry(dn); 1289 struct ceph_dentry_info *di = ceph_dentry(dn);
1293 struct ceph_mds_client *mdsc; 1290 struct ceph_mds_client *mdsc;
1294 1291
1295 dout("dentry_lru_del %p %p '%.*s'\n", di, dn, 1292 dout("dentry_lru_del %p %p '%pd'\n", di, dn, dn);
1296 dn->d_name.len, dn->d_name.name);
1297 mdsc = ceph_sb_to_client(dn->d_sb)->mdsc; 1293 mdsc = ceph_sb_to_client(dn->d_sb)->mdsc;
1298 spin_lock(&mdsc->dentry_lru_lock); 1294 spin_lock(&mdsc->dentry_lru_lock);
1299 list_del_init(&di->lru); 1295 list_del_init(&di->lru);
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index d7e0da8366e6..9f8e3572040e 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -211,7 +211,7 @@ int ceph_open(struct inode *inode, struct file *file)
211 211
212 req->r_num_caps = 1; 212 req->r_num_caps = 1;
213 if (flags & O_CREAT) 213 if (flags & O_CREAT)
214 parent_inode = ceph_get_dentry_parent_inode(file->f_dentry); 214 parent_inode = ceph_get_dentry_parent_inode(file->f_path.dentry);
215 err = ceph_mdsc_do_request(mdsc, parent_inode, req); 215 err = ceph_mdsc_do_request(mdsc, parent_inode, req);
216 iput(parent_inode); 216 iput(parent_inode);
217 if (!err) 217 if (!err)
@@ -238,8 +238,8 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
238 struct ceph_acls_info acls = {}; 238 struct ceph_acls_info acls = {};
239 int err; 239 int err;
240 240
241 dout("atomic_open %p dentry %p '%.*s' %s flags %d mode 0%o\n", 241 dout("atomic_open %p dentry %p '%pd' %s flags %d mode 0%o\n",
242 dir, dentry, dentry->d_name.len, dentry->d_name.name, 242 dir, dentry, dentry,
243 d_unhashed(dentry) ? "unhashed" : "hashed", flags, mode); 243 d_unhashed(dentry) ? "unhashed" : "hashed", flags, mode);
244 244
245 if (dentry->d_name.len > NAME_MAX) 245 if (dentry->d_name.len > NAME_MAX)
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 7b6139004401..a5593d51d035 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -967,7 +967,7 @@ static struct dentry *splice_dentry(struct dentry *dn, struct inode *in,
967 /* dn must be unhashed */ 967 /* dn must be unhashed */
968 if (!d_unhashed(dn)) 968 if (!d_unhashed(dn))
969 d_drop(dn); 969 d_drop(dn);
970 realdn = d_materialise_unique(dn, in); 970 realdn = d_splice_alias(in, dn);
971 if (IS_ERR(realdn)) { 971 if (IS_ERR(realdn)) {
972 pr_err("splice_dentry error %ld %p inode %p ino %llx.%llx\n", 972 pr_err("splice_dentry error %ld %p inode %p ino %llx.%llx\n",
973 PTR_ERR(realdn), dn, in, ceph_vinop(in)); 973 PTR_ERR(realdn), dn, in, ceph_vinop(in));
@@ -1186,20 +1186,18 @@ retry_lookup:
1186 struct inode *olddir = req->r_old_dentry_dir; 1186 struct inode *olddir = req->r_old_dentry_dir;
1187 BUG_ON(!olddir); 1187 BUG_ON(!olddir);
1188 1188
1189 dout(" src %p '%.*s' dst %p '%.*s'\n", 1189 dout(" src %p '%pd' dst %p '%pd'\n",
1190 req->r_old_dentry, 1190 req->r_old_dentry,
1191 req->r_old_dentry->d_name.len, 1191 req->r_old_dentry,
1192 req->r_old_dentry->d_name.name, 1192 dn, dn);
1193 dn, dn->d_name.len, dn->d_name.name);
1194 dout("fill_trace doing d_move %p -> %p\n", 1193 dout("fill_trace doing d_move %p -> %p\n",
1195 req->r_old_dentry, dn); 1194 req->r_old_dentry, dn);
1196 1195
1197 d_move(req->r_old_dentry, dn); 1196 d_move(req->r_old_dentry, dn);
1198 dout(" src %p '%.*s' dst %p '%.*s'\n", 1197 dout(" src %p '%pd' dst %p '%pd'\n",
1198 req->r_old_dentry,
1199 req->r_old_dentry, 1199 req->r_old_dentry,
1200 req->r_old_dentry->d_name.len, 1200 dn, dn);
1201 req->r_old_dentry->d_name.name,
1202 dn, dn->d_name.len, dn->d_name.name);
1203 1201
1204 /* ensure target dentry is invalidated, despite 1202 /* ensure target dentry is invalidated, despite
1205 rehashing bug in vfs_rename_dir */ 1203 rehashing bug in vfs_rename_dir */
@@ -1399,7 +1397,7 @@ retry_lookup:
1399 /* reorder parent's d_subdirs */ 1397 /* reorder parent's d_subdirs */
1400 spin_lock(&parent->d_lock); 1398 spin_lock(&parent->d_lock);
1401 spin_lock_nested(&dn->d_lock, DENTRY_D_LOCK_NESTED); 1399 spin_lock_nested(&dn->d_lock, DENTRY_D_LOCK_NESTED);
1402 list_move(&dn->d_u.d_child, &parent->d_subdirs); 1400 list_move(&dn->d_child, &parent->d_subdirs);
1403 spin_unlock(&dn->d_lock); 1401 spin_unlock(&dn->d_lock);
1404 spin_unlock(&parent->d_lock); 1402 spin_unlock(&parent->d_lock);
1405 } 1403 }
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 9d7996e8e793..d72fe37f5420 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -209,8 +209,7 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
209 209
210static long cifs_fallocate(struct file *file, int mode, loff_t off, loff_t len) 210static long cifs_fallocate(struct file *file, int mode, loff_t off, loff_t len)
211{ 211{
212 struct super_block *sb = file->f_path.dentry->d_sb; 212 struct cifs_sb_info *cifs_sb = CIFS_FILE_SB(file);
213 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
214 struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); 213 struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
215 struct TCP_Server_Info *server = tcon->ses->server; 214 struct TCP_Server_Info *server = tcon->ses->server;
216 215
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 02a33e529904..6e139111fdb2 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -1168,6 +1168,12 @@ CIFS_SB(struct super_block *sb)
1168 return sb->s_fs_info; 1168 return sb->s_fs_info;
1169} 1169}
1170 1170
1171static inline struct cifs_sb_info *
1172CIFS_FILE_SB(struct file *file)
1173{
1174 return CIFS_SB(file_inode(file)->i_sb);
1175}
1176
1171static inline char CIFS_DIR_SEP(const struct cifs_sb_info *cifs_sb) 1177static inline char CIFS_DIR_SEP(const struct cifs_sb_info *cifs_sb)
1172{ 1178{
1173 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) 1179 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 3e4d00a06c44..d535e168a9d3 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -1586,7 +1586,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *flock)
1586 cifs_read_flock(flock, &type, &lock, &unlock, &wait_flag, 1586 cifs_read_flock(flock, &type, &lock, &unlock, &wait_flag,
1587 tcon->ses->server); 1587 tcon->ses->server);
1588 1588
1589 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 1589 cifs_sb = CIFS_FILE_SB(file);
1590 netfid = cfile->fid.netfid; 1590 netfid = cfile->fid.netfid;
1591 cinode = CIFS_I(file_inode(file)); 1591 cinode = CIFS_I(file_inode(file));
1592 1592
@@ -2305,7 +2305,7 @@ int cifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
2305 struct cifs_tcon *tcon; 2305 struct cifs_tcon *tcon;
2306 struct TCP_Server_Info *server; 2306 struct TCP_Server_Info *server;
2307 struct cifsFileInfo *smbfile = file->private_data; 2307 struct cifsFileInfo *smbfile = file->private_data;
2308 struct cifs_sb_info *cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 2308 struct cifs_sb_info *cifs_sb = CIFS_FILE_SB(file);
2309 struct inode *inode = file->f_mapping->host; 2309 struct inode *inode = file->f_mapping->host;
2310 2310
2311 rc = filemap_write_and_wait_range(inode->i_mapping, start, end); 2311 rc = filemap_write_and_wait_range(inode->i_mapping, start, end);
@@ -2585,7 +2585,7 @@ cifs_iovec_write(struct file *file, struct iov_iter *from, loff_t *poffset)
2585 iov_iter_truncate(from, len); 2585 iov_iter_truncate(from, len);
2586 2586
2587 INIT_LIST_HEAD(&wdata_list); 2587 INIT_LIST_HEAD(&wdata_list);
2588 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 2588 cifs_sb = CIFS_FILE_SB(file);
2589 open_file = file->private_data; 2589 open_file = file->private_data;
2590 tcon = tlink_tcon(open_file->tlink); 2590 tcon = tlink_tcon(open_file->tlink);
2591 2591
@@ -3010,7 +3010,7 @@ ssize_t cifs_user_readv(struct kiocb *iocb, struct iov_iter *to)
3010 return 0; 3010 return 0;
3011 3011
3012 INIT_LIST_HEAD(&rdata_list); 3012 INIT_LIST_HEAD(&rdata_list);
3013 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 3013 cifs_sb = CIFS_FILE_SB(file);
3014 open_file = file->private_data; 3014 open_file = file->private_data;
3015 tcon = tlink_tcon(open_file->tlink); 3015 tcon = tlink_tcon(open_file->tlink);
3016 3016
@@ -3155,7 +3155,7 @@ cifs_read(struct file *file, char *read_data, size_t read_size, loff_t *offset)
3155 __u32 pid; 3155 __u32 pid;
3156 3156
3157 xid = get_xid(); 3157 xid = get_xid();
3158 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 3158 cifs_sb = CIFS_FILE_SB(file);
3159 3159
3160 /* FIXME: set up handlers for larger reads and/or convert to async */ 3160 /* FIXME: set up handlers for larger reads and/or convert to async */
3161 rsize = min_t(unsigned int, cifs_sb->rsize, CIFSMaxBufSize); 3161 rsize = min_t(unsigned int, cifs_sb->rsize, CIFSMaxBufSize);
@@ -3462,7 +3462,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
3462 int rc; 3462 int rc;
3463 struct list_head tmplist; 3463 struct list_head tmplist;
3464 struct cifsFileInfo *open_file = file->private_data; 3464 struct cifsFileInfo *open_file = file->private_data;
3465 struct cifs_sb_info *cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 3465 struct cifs_sb_info *cifs_sb = CIFS_FILE_SB(file);
3466 struct TCP_Server_Info *server; 3466 struct TCP_Server_Info *server;
3467 pid_t pid; 3467 pid_t pid;
3468 3468
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 197cb503d528..0c3ce464cae4 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -895,7 +895,7 @@ inode_has_hashed_dentries(struct inode *inode)
895 struct dentry *dentry; 895 struct dentry *dentry;
896 896
897 spin_lock(&inode->i_lock); 897 spin_lock(&inode->i_lock);
898 hlist_for_each_entry(dentry, &inode->i_dentry, d_alias) { 898 hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) {
899 if (!d_unhashed(dentry) || IS_ROOT(dentry)) { 899 if (!d_unhashed(dentry) || IS_ROOT(dentry)) {
900 spin_unlock(&inode->i_lock); 900 spin_unlock(&inode->i_lock);
901 return true; 901 return true;
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 8fd2a95860ba..d116ca8ce4c0 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -123,7 +123,7 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *name,
123 if (!inode) 123 if (!inode)
124 goto out; 124 goto out;
125 125
126 alias = d_materialise_unique(dentry, inode); 126 alias = d_splice_alias(inode, dentry);
127 if (alias && !IS_ERR(alias)) 127 if (alias && !IS_ERR(alias))
128 dput(alias); 128 dput(alias);
129out: 129out:
@@ -261,7 +261,7 @@ initiate_cifs_search(const unsigned int xid, struct file *file)
261 int rc = 0; 261 int rc = 0;
262 char *full_path = NULL; 262 char *full_path = NULL;
263 struct cifsFileInfo *cifsFile; 263 struct cifsFileInfo *cifsFile;
264 struct cifs_sb_info *cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 264 struct cifs_sb_info *cifs_sb = CIFS_FILE_SB(file);
265 struct tcon_link *tlink = NULL; 265 struct tcon_link *tlink = NULL;
266 struct cifs_tcon *tcon; 266 struct cifs_tcon *tcon;
267 struct TCP_Server_Info *server; 267 struct TCP_Server_Info *server;
@@ -561,7 +561,7 @@ find_cifs_entry(const unsigned int xid, struct cifs_tcon *tcon, loff_t pos,
561 loff_t first_entry_in_buffer; 561 loff_t first_entry_in_buffer;
562 loff_t index_to_find = pos; 562 loff_t index_to_find = pos;
563 struct cifsFileInfo *cfile = file->private_data; 563 struct cifsFileInfo *cfile = file->private_data;
564 struct cifs_sb_info *cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 564 struct cifs_sb_info *cifs_sb = CIFS_FILE_SB(file);
565 struct TCP_Server_Info *server = tcon->ses->server; 565 struct TCP_Server_Info *server = tcon->ses->server;
566 /* check if index in the buffer */ 566 /* check if index in the buffer */
567 567
@@ -679,7 +679,7 @@ static int cifs_filldir(char *find_entry, struct file *file,
679 char *scratch_buf, unsigned int max_len) 679 char *scratch_buf, unsigned int max_len)
680{ 680{
681 struct cifsFileInfo *file_info = file->private_data; 681 struct cifsFileInfo *file_info = file->private_data;
682 struct super_block *sb = file->f_path.dentry->d_sb; 682 struct super_block *sb = file_inode(file)->i_sb;
683 struct cifs_sb_info *cifs_sb = CIFS_SB(sb); 683 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
684 struct cifs_dirent de = { NULL, }; 684 struct cifs_dirent de = { NULL, };
685 struct cifs_fattr fattr; 685 struct cifs_fattr fattr;
@@ -753,7 +753,7 @@ static int cifs_filldir(char *find_entry, struct file *file,
753 */ 753 */
754 fattr.cf_flags |= CIFS_FATTR_NEED_REVAL; 754 fattr.cf_flags |= CIFS_FATTR_NEED_REVAL;
755 755
756 cifs_prime_dcache(file->f_dentry, &name, &fattr); 756 cifs_prime_dcache(file->f_path.dentry, &name, &fattr);
757 757
758 ino = cifs_uniqueid_to_ino_t(fattr.cf_uniqueid); 758 ino = cifs_uniqueid_to_ino_t(fattr.cf_uniqueid);
759 return !dir_emit(ctx, name.name, name.len, ino, fattr.cf_dtype); 759 return !dir_emit(ctx, name.name, name.len, ino, fattr.cf_dtype);
diff --git a/fs/coda/cache.c b/fs/coda/cache.c
index 278f8fdeb9ef..46ee6f238985 100644
--- a/fs/coda/cache.c
+++ b/fs/coda/cache.c
@@ -92,7 +92,7 @@ static void coda_flag_children(struct dentry *parent, int flag)
92 struct dentry *de; 92 struct dentry *de;
93 93
94 spin_lock(&parent->d_lock); 94 spin_lock(&parent->d_lock);
95 list_for_each_entry(de, &parent->d_subdirs, d_u.d_child) { 95 list_for_each_entry(de, &parent->d_subdirs, d_child) {
96 /* don't know what to do with negative dentries */ 96 /* don't know what to do with negative dentries */
97 if (de->d_inode ) 97 if (de->d_inode )
98 coda_flag_inode(de->d_inode, flag); 98 coda_flag_inode(de->d_inode, flag);
diff --git a/fs/coda/coda_linux.c b/fs/coda/coda_linux.c
index 1326d38960db..f1714cfb589c 100644
--- a/fs/coda/coda_linux.c
+++ b/fs/coda/coda_linux.c
@@ -40,12 +40,6 @@ int coda_iscontrol(const char *name, size_t length)
40 (strncmp(name, CODA_CONTROL, CODA_CONTROLLEN) == 0)); 40 (strncmp(name, CODA_CONTROL, CODA_CONTROLLEN) == 0));
41} 41}
42 42
43/* recognize /coda inode */
44int coda_isroot(struct inode *i)
45{
46 return ( i->i_sb->s_root->d_inode == i );
47}
48
49unsigned short coda_flags_to_cflags(unsigned short flags) 43unsigned short coda_flags_to_cflags(unsigned short flags)
50{ 44{
51 unsigned short coda_flags = 0; 45 unsigned short coda_flags = 0;
diff --git a/fs/coda/coda_linux.h b/fs/coda/coda_linux.h
index d42b725b1d21..d6f7a76a1f5b 100644
--- a/fs/coda/coda_linux.h
+++ b/fs/coda/coda_linux.h
@@ -52,7 +52,6 @@ int coda_setattr(struct dentry *, struct iattr *);
52 52
53/* this file: heloers */ 53/* this file: heloers */
54char *coda_f2s(struct CodaFid *f); 54char *coda_f2s(struct CodaFid *f);
55int coda_isroot(struct inode *i);
56int coda_iscontrol(const char *name, size_t length); 55int coda_iscontrol(const char *name, size_t length);
57 56
58void coda_vattr_to_iattr(struct inode *, struct coda_vattr *); 57void coda_vattr_to_iattr(struct inode *, struct coda_vattr *);
diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index 9c3dedc000d1..7ff025966e4f 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -107,7 +107,7 @@ static struct dentry *coda_lookup(struct inode *dir, struct dentry *entry, unsig
107 } 107 }
108 108
109 /* control object, create inode on the fly */ 109 /* control object, create inode on the fly */
110 if (coda_isroot(dir) && coda_iscontrol(name, length)) { 110 if (is_root_inode(dir) && coda_iscontrol(name, length)) {
111 inode = coda_cnode_makectl(sb); 111 inode = coda_cnode_makectl(sb);
112 type = CODA_NOCACHE; 112 type = CODA_NOCACHE;
113 } else { 113 } else {
@@ -195,7 +195,7 @@ static int coda_create(struct inode *dir, struct dentry *de, umode_t mode, bool
195 struct CodaFid newfid; 195 struct CodaFid newfid;
196 struct coda_vattr attrs; 196 struct coda_vattr attrs;
197 197
198 if (coda_isroot(dir) && coda_iscontrol(name, length)) 198 if (is_root_inode(dir) && coda_iscontrol(name, length))
199 return -EPERM; 199 return -EPERM;
200 200
201 error = venus_create(dir->i_sb, coda_i2f(dir), name, length, 201 error = venus_create(dir->i_sb, coda_i2f(dir), name, length,
@@ -227,7 +227,7 @@ static int coda_mkdir(struct inode *dir, struct dentry *de, umode_t mode)
227 int error; 227 int error;
228 struct CodaFid newfid; 228 struct CodaFid newfid;
229 229
230 if (coda_isroot(dir) && coda_iscontrol(name, len)) 230 if (is_root_inode(dir) && coda_iscontrol(name, len))
231 return -EPERM; 231 return -EPERM;
232 232
233 attrs.va_mode = mode; 233 attrs.va_mode = mode;
@@ -261,7 +261,7 @@ static int coda_link(struct dentry *source_de, struct inode *dir_inode,
261 int len = de->d_name.len; 261 int len = de->d_name.len;
262 int error; 262 int error;
263 263
264 if (coda_isroot(dir_inode) && coda_iscontrol(name, len)) 264 if (is_root_inode(dir_inode) && coda_iscontrol(name, len))
265 return -EPERM; 265 return -EPERM;
266 266
267 error = venus_link(dir_inode->i_sb, coda_i2f(inode), 267 error = venus_link(dir_inode->i_sb, coda_i2f(inode),
@@ -287,7 +287,7 @@ static int coda_symlink(struct inode *dir_inode, struct dentry *de,
287 int symlen; 287 int symlen;
288 int error; 288 int error;
289 289
290 if (coda_isroot(dir_inode) && coda_iscontrol(name, len)) 290 if (is_root_inode(dir_inode) && coda_iscontrol(name, len))
291 return -EPERM; 291 return -EPERM;
292 292
293 symlen = strlen(symname); 293 symlen = strlen(symname);
@@ -507,7 +507,7 @@ static int coda_dentry_revalidate(struct dentry *de, unsigned int flags)
507 return -ECHILD; 507 return -ECHILD;
508 508
509 inode = de->d_inode; 509 inode = de->d_inode;
510 if (!inode || coda_isroot(inode)) 510 if (!inode || is_root_inode(inode))
511 goto out; 511 goto out;
512 if (is_bad_inode(inode)) 512 if (is_bad_inode(inode))
513 goto bad; 513 goto bad;
diff --git a/fs/compat.c b/fs/compat.c
index b13df99f3534..6fd272d455e4 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -847,10 +847,12 @@ struct compat_readdir_callback {
847 int result; 847 int result;
848}; 848};
849 849
850static int compat_fillonedir(void *__buf, const char *name, int namlen, 850static int compat_fillonedir(struct dir_context *ctx, const char *name,
851 loff_t offset, u64 ino, unsigned int d_type) 851 int namlen, loff_t offset, u64 ino,
852 unsigned int d_type)
852{ 853{
853 struct compat_readdir_callback *buf = __buf; 854 struct compat_readdir_callback *buf =
855 container_of(ctx, struct compat_readdir_callback, ctx);
854 struct compat_old_linux_dirent __user *dirent; 856 struct compat_old_linux_dirent __user *dirent;
855 compat_ulong_t d_ino; 857 compat_ulong_t d_ino;
856 858
@@ -915,11 +917,12 @@ struct compat_getdents_callback {
915 int error; 917 int error;
916}; 918};
917 919
918static int compat_filldir(void *__buf, const char *name, int namlen, 920static int compat_filldir(struct dir_context *ctx, const char *name, int namlen,
919 loff_t offset, u64 ino, unsigned int d_type) 921 loff_t offset, u64 ino, unsigned int d_type)
920{ 922{
921 struct compat_linux_dirent __user * dirent; 923 struct compat_linux_dirent __user * dirent;
922 struct compat_getdents_callback *buf = __buf; 924 struct compat_getdents_callback *buf =
925 container_of(ctx, struct compat_getdents_callback, ctx);
923 compat_ulong_t d_ino; 926 compat_ulong_t d_ino;
924 int reclen = ALIGN(offsetof(struct compat_linux_dirent, d_name) + 927 int reclen = ALIGN(offsetof(struct compat_linux_dirent, d_name) +
925 namlen + 2, sizeof(compat_long_t)); 928 namlen + 2, sizeof(compat_long_t));
@@ -1001,11 +1004,13 @@ struct compat_getdents_callback64 {
1001 int error; 1004 int error;
1002}; 1005};
1003 1006
1004static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t offset, 1007static int compat_filldir64(struct dir_context *ctx, const char *name,
1005 u64 ino, unsigned int d_type) 1008 int namlen, loff_t offset, u64 ino,
1009 unsigned int d_type)
1006{ 1010{
1007 struct linux_dirent64 __user *dirent; 1011 struct linux_dirent64 __user *dirent;
1008 struct compat_getdents_callback64 *buf = __buf; 1012 struct compat_getdents_callback64 *buf =
1013 container_of(ctx, struct compat_getdents_callback64, ctx);
1009 int reclen = ALIGN(offsetof(struct linux_dirent64, d_name) + namlen + 1, 1014 int reclen = ALIGN(offsetof(struct linux_dirent64, d_name) + namlen + 1,
1010 sizeof(u64)); 1015 sizeof(u64));
1011 u64 off; 1016 u64 off;
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index 668dcabc5695..c9c298bd3058 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -386,7 +386,7 @@ static void remove_dir(struct dentry * d)
386 if (d->d_inode) 386 if (d->d_inode)
387 simple_rmdir(parent->d_inode,d); 387 simple_rmdir(parent->d_inode,d);
388 388
389 pr_debug(" o %s removing done (%d)\n",d->d_name.name, d_count(d)); 389 pr_debug(" o %pd removing done (%d)\n", d, d_count(d));
390 390
391 dput(parent); 391 dput(parent);
392} 392}
diff --git a/fs/dcache.c b/fs/dcache.c
index 3ffef7f4e5cd..e368d4f412f9 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -44,7 +44,7 @@
44/* 44/*
45 * Usage: 45 * Usage:
46 * dcache->d_inode->i_lock protects: 46 * dcache->d_inode->i_lock protects:
47 * - i_dentry, d_alias, d_inode of aliases 47 * - i_dentry, d_u.d_alias, d_inode of aliases
48 * dcache_hash_bucket lock protects: 48 * dcache_hash_bucket lock protects:
49 * - the dcache hash table 49 * - the dcache hash table
50 * s_anon bl list spinlock protects: 50 * s_anon bl list spinlock protects:
@@ -59,7 +59,7 @@
59 * - d_unhashed() 59 * - d_unhashed()
60 * - d_parent and d_subdirs 60 * - d_parent and d_subdirs
61 * - childrens' d_child and d_parent 61 * - childrens' d_child and d_parent
62 * - d_alias, d_inode 62 * - d_u.d_alias, d_inode
63 * 63 *
64 * Ordering: 64 * Ordering:
65 * dentry->d_inode->i_lock 65 * dentry->d_inode->i_lock
@@ -252,14 +252,12 @@ static void __d_free(struct rcu_head *head)
252{ 252{
253 struct dentry *dentry = container_of(head, struct dentry, d_u.d_rcu); 253 struct dentry *dentry = container_of(head, struct dentry, d_u.d_rcu);
254 254
255 WARN_ON(!hlist_unhashed(&dentry->d_alias));
256 kmem_cache_free(dentry_cache, dentry); 255 kmem_cache_free(dentry_cache, dentry);
257} 256}
258 257
259static void __d_free_external(struct rcu_head *head) 258static void __d_free_external(struct rcu_head *head)
260{ 259{
261 struct dentry *dentry = container_of(head, struct dentry, d_u.d_rcu); 260 struct dentry *dentry = container_of(head, struct dentry, d_u.d_rcu);
262 WARN_ON(!hlist_unhashed(&dentry->d_alias));
263 kfree(external_name(dentry)); 261 kfree(external_name(dentry));
264 kmem_cache_free(dentry_cache, dentry); 262 kmem_cache_free(dentry_cache, dentry);
265} 263}
@@ -271,6 +269,7 @@ static inline int dname_external(const struct dentry *dentry)
271 269
272static void dentry_free(struct dentry *dentry) 270static void dentry_free(struct dentry *dentry)
273{ 271{
272 WARN_ON(!hlist_unhashed(&dentry->d_u.d_alias));
274 if (unlikely(dname_external(dentry))) { 273 if (unlikely(dname_external(dentry))) {
275 struct external_name *p = external_name(dentry); 274 struct external_name *p = external_name(dentry);
276 if (likely(atomic_dec_and_test(&p->u.count))) { 275 if (likely(atomic_dec_and_test(&p->u.count))) {
@@ -311,7 +310,7 @@ static void dentry_iput(struct dentry * dentry)
311 struct inode *inode = dentry->d_inode; 310 struct inode *inode = dentry->d_inode;
312 if (inode) { 311 if (inode) {
313 dentry->d_inode = NULL; 312 dentry->d_inode = NULL;
314 hlist_del_init(&dentry->d_alias); 313 hlist_del_init(&dentry->d_u.d_alias);
315 spin_unlock(&dentry->d_lock); 314 spin_unlock(&dentry->d_lock);
316 spin_unlock(&inode->i_lock); 315 spin_unlock(&inode->i_lock);
317 if (!inode->i_nlink) 316 if (!inode->i_nlink)
@@ -336,7 +335,7 @@ static void dentry_unlink_inode(struct dentry * dentry)
336 struct inode *inode = dentry->d_inode; 335 struct inode *inode = dentry->d_inode;
337 __d_clear_type(dentry); 336 __d_clear_type(dentry);
338 dentry->d_inode = NULL; 337 dentry->d_inode = NULL;
339 hlist_del_init(&dentry->d_alias); 338 hlist_del_init(&dentry->d_u.d_alias);
340 dentry_rcuwalk_barrier(dentry); 339 dentry_rcuwalk_barrier(dentry);
341 spin_unlock(&dentry->d_lock); 340 spin_unlock(&dentry->d_lock);
342 spin_unlock(&inode->i_lock); 341 spin_unlock(&inode->i_lock);
@@ -496,7 +495,7 @@ static void __dentry_kill(struct dentry *dentry)
496 } 495 }
497 /* if it was on the hash then remove it */ 496 /* if it was on the hash then remove it */
498 __d_drop(dentry); 497 __d_drop(dentry);
499 list_del(&dentry->d_u.d_child); 498 __list_del_entry(&dentry->d_child);
500 /* 499 /*
501 * Inform d_walk() that we are no longer attached to the 500 * Inform d_walk() that we are no longer attached to the
502 * dentry tree 501 * dentry tree
@@ -722,7 +721,7 @@ static struct dentry *__d_find_alias(struct inode *inode)
722 721
723again: 722again:
724 discon_alias = NULL; 723 discon_alias = NULL;
725 hlist_for_each_entry(alias, &inode->i_dentry, d_alias) { 724 hlist_for_each_entry(alias, &inode->i_dentry, d_u.d_alias) {
726 spin_lock(&alias->d_lock); 725 spin_lock(&alias->d_lock);
727 if (S_ISDIR(inode->i_mode) || !d_unhashed(alias)) { 726 if (S_ISDIR(inode->i_mode) || !d_unhashed(alias)) {
728 if (IS_ROOT(alias) && 727 if (IS_ROOT(alias) &&
@@ -772,12 +771,13 @@ void d_prune_aliases(struct inode *inode)
772 struct dentry *dentry; 771 struct dentry *dentry;
773restart: 772restart:
774 spin_lock(&inode->i_lock); 773 spin_lock(&inode->i_lock);
775 hlist_for_each_entry(dentry, &inode->i_dentry, d_alias) { 774 hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) {
776 spin_lock(&dentry->d_lock); 775 spin_lock(&dentry->d_lock);
777 if (!dentry->d_lockref.count) { 776 if (!dentry->d_lockref.count) {
778 struct dentry *parent = lock_parent(dentry); 777 struct dentry *parent = lock_parent(dentry);
779 if (likely(!dentry->d_lockref.count)) { 778 if (likely(!dentry->d_lockref.count)) {
780 __dentry_kill(dentry); 779 __dentry_kill(dentry);
780 dput(parent);
781 goto restart; 781 goto restart;
782 } 782 }
783 if (parent) 783 if (parent)
@@ -1050,7 +1050,7 @@ repeat:
1050resume: 1050resume:
1051 while (next != &this_parent->d_subdirs) { 1051 while (next != &this_parent->d_subdirs) {
1052 struct list_head *tmp = next; 1052 struct list_head *tmp = next;
1053 struct dentry *dentry = list_entry(tmp, struct dentry, d_u.d_child); 1053 struct dentry *dentry = list_entry(tmp, struct dentry, d_child);
1054 next = tmp->next; 1054 next = tmp->next;
1055 1055
1056 spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED); 1056 spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);
@@ -1082,33 +1082,31 @@ resume:
1082 /* 1082 /*
1083 * All done at this level ... ascend and resume the search. 1083 * All done at this level ... ascend and resume the search.
1084 */ 1084 */
1085 rcu_read_lock();
1086ascend:
1085 if (this_parent != parent) { 1087 if (this_parent != parent) {
1086 struct dentry *child = this_parent; 1088 struct dentry *child = this_parent;
1087 this_parent = child->d_parent; 1089 this_parent = child->d_parent;
1088 1090
1089 rcu_read_lock();
1090 spin_unlock(&child->d_lock); 1091 spin_unlock(&child->d_lock);
1091 spin_lock(&this_parent->d_lock); 1092 spin_lock(&this_parent->d_lock);
1092 1093
1093 /* 1094 /* might go back up the wrong parent if we have had a rename. */
1094 * might go back up the wrong parent if we have had a rename 1095 if (need_seqretry(&rename_lock, seq))
1095 * or deletion
1096 */
1097 if (this_parent != child->d_parent ||
1098 (child->d_flags & DCACHE_DENTRY_KILLED) ||
1099 need_seqretry(&rename_lock, seq)) {
1100 spin_unlock(&this_parent->d_lock);
1101 rcu_read_unlock();
1102 goto rename_retry; 1096 goto rename_retry;
1097 next = child->d_child.next;
1098 while (unlikely(child->d_flags & DCACHE_DENTRY_KILLED)) {
1099 if (next == &this_parent->d_subdirs)
1100 goto ascend;
1101 child = list_entry(next, struct dentry, d_child);
1102 next = next->next;
1103 } 1103 }
1104 rcu_read_unlock(); 1104 rcu_read_unlock();
1105 next = child->d_u.d_child.next;
1106 goto resume; 1105 goto resume;
1107 } 1106 }
1108 if (need_seqretry(&rename_lock, seq)) { 1107 if (need_seqretry(&rename_lock, seq))
1109 spin_unlock(&this_parent->d_lock);
1110 goto rename_retry; 1108 goto rename_retry;
1111 } 1109 rcu_read_unlock();
1112 if (finish) 1110 if (finish)
1113 finish(data); 1111 finish(data);
1114 1112
@@ -1118,6 +1116,9 @@ out_unlock:
1118 return; 1116 return;
1119 1117
1120rename_retry: 1118rename_retry:
1119 spin_unlock(&this_parent->d_lock);
1120 rcu_read_unlock();
1121 BUG_ON(seq & 1);
1121 if (!retry) 1122 if (!retry)
1122 return; 1123 return;
1123 seq = 1; 1124 seq = 1;
@@ -1454,8 +1455,8 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
1454 INIT_HLIST_BL_NODE(&dentry->d_hash); 1455 INIT_HLIST_BL_NODE(&dentry->d_hash);
1455 INIT_LIST_HEAD(&dentry->d_lru); 1456 INIT_LIST_HEAD(&dentry->d_lru);
1456 INIT_LIST_HEAD(&dentry->d_subdirs); 1457 INIT_LIST_HEAD(&dentry->d_subdirs);
1457 INIT_HLIST_NODE(&dentry->d_alias); 1458 INIT_HLIST_NODE(&dentry->d_u.d_alias);
1458 INIT_LIST_HEAD(&dentry->d_u.d_child); 1459 INIT_LIST_HEAD(&dentry->d_child);
1459 d_set_d_op(dentry, dentry->d_sb->s_d_op); 1460 d_set_d_op(dentry, dentry->d_sb->s_d_op);
1460 1461
1461 this_cpu_inc(nr_dentry); 1462 this_cpu_inc(nr_dentry);
@@ -1485,7 +1486,7 @@ struct dentry *d_alloc(struct dentry * parent, const struct qstr *name)
1485 */ 1486 */
1486 __dget_dlock(parent); 1487 __dget_dlock(parent);
1487 dentry->d_parent = parent; 1488 dentry->d_parent = parent;
1488 list_add(&dentry->d_u.d_child, &parent->d_subdirs); 1489 list_add(&dentry->d_child, &parent->d_subdirs);
1489 spin_unlock(&parent->d_lock); 1490 spin_unlock(&parent->d_lock);
1490 1491
1491 return dentry; 1492 return dentry;
@@ -1578,7 +1579,7 @@ static void __d_instantiate(struct dentry *dentry, struct inode *inode)
1578 spin_lock(&dentry->d_lock); 1579 spin_lock(&dentry->d_lock);
1579 __d_set_type(dentry, add_flags); 1580 __d_set_type(dentry, add_flags);
1580 if (inode) 1581 if (inode)
1581 hlist_add_head(&dentry->d_alias, &inode->i_dentry); 1582 hlist_add_head(&dentry->d_u.d_alias, &inode->i_dentry);
1582 dentry->d_inode = inode; 1583 dentry->d_inode = inode;
1583 dentry_rcuwalk_barrier(dentry); 1584 dentry_rcuwalk_barrier(dentry);
1584 spin_unlock(&dentry->d_lock); 1585 spin_unlock(&dentry->d_lock);
@@ -1602,7 +1603,7 @@ static void __d_instantiate(struct dentry *dentry, struct inode *inode)
1602 1603
1603void d_instantiate(struct dentry *entry, struct inode * inode) 1604void d_instantiate(struct dentry *entry, struct inode * inode)
1604{ 1605{
1605 BUG_ON(!hlist_unhashed(&entry->d_alias)); 1606 BUG_ON(!hlist_unhashed(&entry->d_u.d_alias));
1606 if (inode) 1607 if (inode)
1607 spin_lock(&inode->i_lock); 1608 spin_lock(&inode->i_lock);
1608 __d_instantiate(entry, inode); 1609 __d_instantiate(entry, inode);
@@ -1641,7 +1642,7 @@ static struct dentry *__d_instantiate_unique(struct dentry *entry,
1641 return NULL; 1642 return NULL;
1642 } 1643 }
1643 1644
1644 hlist_for_each_entry(alias, &inode->i_dentry, d_alias) { 1645 hlist_for_each_entry(alias, &inode->i_dentry, d_u.d_alias) {
1645 /* 1646 /*
1646 * Don't need alias->d_lock here, because aliases with 1647 * Don't need alias->d_lock here, because aliases with
1647 * d_parent == entry->d_parent are not subject to name or 1648 * d_parent == entry->d_parent are not subject to name or
@@ -1667,7 +1668,7 @@ struct dentry *d_instantiate_unique(struct dentry *entry, struct inode *inode)
1667{ 1668{
1668 struct dentry *result; 1669 struct dentry *result;
1669 1670
1670 BUG_ON(!hlist_unhashed(&entry->d_alias)); 1671 BUG_ON(!hlist_unhashed(&entry->d_u.d_alias));
1671 1672
1672 if (inode) 1673 if (inode)
1673 spin_lock(&inode->i_lock); 1674 spin_lock(&inode->i_lock);
@@ -1698,7 +1699,7 @@ EXPORT_SYMBOL(d_instantiate_unique);
1698 */ 1699 */
1699int d_instantiate_no_diralias(struct dentry *entry, struct inode *inode) 1700int d_instantiate_no_diralias(struct dentry *entry, struct inode *inode)
1700{ 1701{
1701 BUG_ON(!hlist_unhashed(&entry->d_alias)); 1702 BUG_ON(!hlist_unhashed(&entry->d_u.d_alias));
1702 1703
1703 spin_lock(&inode->i_lock); 1704 spin_lock(&inode->i_lock);
1704 if (S_ISDIR(inode->i_mode) && !hlist_empty(&inode->i_dentry)) { 1705 if (S_ISDIR(inode->i_mode) && !hlist_empty(&inode->i_dentry)) {
@@ -1737,7 +1738,7 @@ static struct dentry * __d_find_any_alias(struct inode *inode)
1737 1738
1738 if (hlist_empty(&inode->i_dentry)) 1739 if (hlist_empty(&inode->i_dentry))
1739 return NULL; 1740 return NULL;
1740 alias = hlist_entry(inode->i_dentry.first, struct dentry, d_alias); 1741 alias = hlist_entry(inode->i_dentry.first, struct dentry, d_u.d_alias);
1741 __dget(alias); 1742 __dget(alias);
1742 return alias; 1743 return alias;
1743} 1744}
@@ -1799,7 +1800,7 @@ static struct dentry *__d_obtain_alias(struct inode *inode, int disconnected)
1799 spin_lock(&tmp->d_lock); 1800 spin_lock(&tmp->d_lock);
1800 tmp->d_inode = inode; 1801 tmp->d_inode = inode;
1801 tmp->d_flags |= add_flags; 1802 tmp->d_flags |= add_flags;
1802 hlist_add_head(&tmp->d_alias, &inode->i_dentry); 1803 hlist_add_head(&tmp->d_u.d_alias, &inode->i_dentry);
1803 hlist_bl_lock(&tmp->d_sb->s_anon); 1804 hlist_bl_lock(&tmp->d_sb->s_anon);
1804 hlist_bl_add_head(&tmp->d_hash, &tmp->d_sb->s_anon); 1805 hlist_bl_add_head(&tmp->d_hash, &tmp->d_sb->s_anon);
1805 hlist_bl_unlock(&tmp->d_sb->s_anon); 1806 hlist_bl_unlock(&tmp->d_sb->s_anon);
@@ -1888,51 +1889,19 @@ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode,
1888 * if not go ahead and create it now. 1889 * if not go ahead and create it now.
1889 */ 1890 */
1890 found = d_hash_and_lookup(dentry->d_parent, name); 1891 found = d_hash_and_lookup(dentry->d_parent, name);
1891 if (unlikely(IS_ERR(found)))
1892 goto err_out;
1893 if (!found) { 1892 if (!found) {
1894 new = d_alloc(dentry->d_parent, name); 1893 new = d_alloc(dentry->d_parent, name);
1895 if (!new) { 1894 if (!new) {
1896 found = ERR_PTR(-ENOMEM); 1895 found = ERR_PTR(-ENOMEM);
1897 goto err_out; 1896 } else {
1898 } 1897 found = d_splice_alias(inode, new);
1899 1898 if (found) {
1900 found = d_splice_alias(inode, new); 1899 dput(new);
1901 if (found) { 1900 return found;
1902 dput(new); 1901 }
1903 return found; 1902 return new;
1904 }
1905 return new;
1906 }
1907
1908 /*
1909 * If a matching dentry exists, and it's not negative use it.
1910 *
1911 * Decrement the reference count to balance the iget() done
1912 * earlier on.
1913 */
1914 if (found->d_inode) {
1915 if (unlikely(found->d_inode != inode)) {
1916 /* This can't happen because bad inodes are unhashed. */
1917 BUG_ON(!is_bad_inode(inode));
1918 BUG_ON(!is_bad_inode(found->d_inode));
1919 } 1903 }
1920 iput(inode);
1921 return found;
1922 } 1904 }
1923
1924 /*
1925 * Negative dentry: instantiate it unless the inode is a directory and
1926 * already has a dentry.
1927 */
1928 new = d_splice_alias(inode, found);
1929 if (new) {
1930 dput(found);
1931 found = new;
1932 }
1933 return found;
1934
1935err_out:
1936 iput(inode); 1905 iput(inode);
1937 return found; 1906 return found;
1938} 1907}
@@ -2234,7 +2203,7 @@ int d_validate(struct dentry *dentry, struct dentry *dparent)
2234 struct dentry *child; 2203 struct dentry *child;
2235 2204
2236 spin_lock(&dparent->d_lock); 2205 spin_lock(&dparent->d_lock);
2237 list_for_each_entry(child, &dparent->d_subdirs, d_u.d_child) { 2206 list_for_each_entry(child, &dparent->d_subdirs, d_child) {
2238 if (dentry == child) { 2207 if (dentry == child) {
2239 spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED); 2208 spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);
2240 __dget_dlock(dentry); 2209 __dget_dlock(dentry);
@@ -2392,6 +2361,8 @@ static void swap_names(struct dentry *dentry, struct dentry *target)
2392 */ 2361 */
2393 unsigned int i; 2362 unsigned int i;
2394 BUILD_BUG_ON(!IS_ALIGNED(DNAME_INLINE_LEN, sizeof(long))); 2363 BUILD_BUG_ON(!IS_ALIGNED(DNAME_INLINE_LEN, sizeof(long)));
2364 kmemcheck_mark_initialized(dentry->d_iname, DNAME_INLINE_LEN);
2365 kmemcheck_mark_initialized(target->d_iname, DNAME_INLINE_LEN);
2395 for (i = 0; i < DNAME_INLINE_LEN / sizeof(long); i++) { 2366 for (i = 0; i < DNAME_INLINE_LEN / sizeof(long); i++) {
2396 swap(((long *) &dentry->d_iname)[i], 2367 swap(((long *) &dentry->d_iname)[i],
2397 ((long *) &target->d_iname)[i]); 2368 ((long *) &target->d_iname)[i]);
@@ -2525,13 +2496,13 @@ static void __d_move(struct dentry *dentry, struct dentry *target,
2525 /* splicing a tree */ 2496 /* splicing a tree */
2526 dentry->d_parent = target->d_parent; 2497 dentry->d_parent = target->d_parent;
2527 target->d_parent = target; 2498 target->d_parent = target;
2528 list_del_init(&target->d_u.d_child); 2499 list_del_init(&target->d_child);
2529 list_move(&dentry->d_u.d_child, &dentry->d_parent->d_subdirs); 2500 list_move(&dentry->d_child, &dentry->d_parent->d_subdirs);
2530 } else { 2501 } else {
2531 /* swapping two dentries */ 2502 /* swapping two dentries */
2532 swap(dentry->d_parent, target->d_parent); 2503 swap(dentry->d_parent, target->d_parent);
2533 list_move(&target->d_u.d_child, &target->d_parent->d_subdirs); 2504 list_move(&target->d_child, &target->d_parent->d_subdirs);
2534 list_move(&dentry->d_u.d_child, &dentry->d_parent->d_subdirs); 2505 list_move(&dentry->d_child, &dentry->d_parent->d_subdirs);
2535 if (exchange) 2506 if (exchange)
2536 fsnotify_d_move(target); 2507 fsnotify_d_move(target);
2537 fsnotify_d_move(dentry); 2508 fsnotify_d_move(dentry);
@@ -2607,11 +2578,11 @@ struct dentry *d_ancestor(struct dentry *p1, struct dentry *p2)
2607 * Note: If ever the locking in lock_rename() changes, then please 2578 * Note: If ever the locking in lock_rename() changes, then please
2608 * remember to update this too... 2579 * remember to update this too...
2609 */ 2580 */
2610static struct dentry *__d_unalias(struct inode *inode, 2581static int __d_unalias(struct inode *inode,
2611 struct dentry *dentry, struct dentry *alias) 2582 struct dentry *dentry, struct dentry *alias)
2612{ 2583{
2613 struct mutex *m1 = NULL, *m2 = NULL; 2584 struct mutex *m1 = NULL, *m2 = NULL;
2614 struct dentry *ret = ERR_PTR(-EBUSY); 2585 int ret = -EBUSY;
2615 2586
2616 /* If alias and dentry share a parent, then no extra locks required */ 2587 /* If alias and dentry share a parent, then no extra locks required */
2617 if (alias->d_parent == dentry->d_parent) 2588 if (alias->d_parent == dentry->d_parent)
@@ -2626,7 +2597,7 @@ static struct dentry *__d_unalias(struct inode *inode,
2626 m2 = &alias->d_parent->d_inode->i_mutex; 2597 m2 = &alias->d_parent->d_inode->i_mutex;
2627out_unalias: 2598out_unalias:
2628 __d_move(alias, dentry, false); 2599 __d_move(alias, dentry, false);
2629 ret = alias; 2600 ret = 0;
2630out_err: 2601out_err:
2631 spin_unlock(&inode->i_lock); 2602 spin_unlock(&inode->i_lock);
2632 if (m2) 2603 if (m2)
@@ -2661,130 +2632,57 @@ out_err:
2661 */ 2632 */
2662struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry) 2633struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry)
2663{ 2634{
2664 struct dentry *new = NULL;
2665
2666 if (IS_ERR(inode)) 2635 if (IS_ERR(inode))
2667 return ERR_CAST(inode); 2636 return ERR_CAST(inode);
2668 2637
2669 if (inode && S_ISDIR(inode->i_mode)) {
2670 spin_lock(&inode->i_lock);
2671 new = __d_find_any_alias(inode);
2672 if (new) {
2673 if (!IS_ROOT(new)) {
2674 spin_unlock(&inode->i_lock);
2675 dput(new);
2676 iput(inode);
2677 return ERR_PTR(-EIO);
2678 }
2679 if (d_ancestor(new, dentry)) {
2680 spin_unlock(&inode->i_lock);
2681 dput(new);
2682 iput(inode);
2683 return ERR_PTR(-EIO);
2684 }
2685 write_seqlock(&rename_lock);
2686 __d_move(new, dentry, false);
2687 write_sequnlock(&rename_lock);
2688 spin_unlock(&inode->i_lock);
2689 security_d_instantiate(new, inode);
2690 iput(inode);
2691 } else {
2692 /* already taking inode->i_lock, so d_add() by hand */
2693 __d_instantiate(dentry, inode);
2694 spin_unlock(&inode->i_lock);
2695 security_d_instantiate(dentry, inode);
2696 d_rehash(dentry);
2697 }
2698 } else {
2699 d_instantiate(dentry, inode);
2700 if (d_unhashed(dentry))
2701 d_rehash(dentry);
2702 }
2703 return new;
2704}
2705EXPORT_SYMBOL(d_splice_alias);
2706
2707/**
2708 * d_materialise_unique - introduce an inode into the tree
2709 * @dentry: candidate dentry
2710 * @inode: inode to bind to the dentry, to which aliases may be attached
2711 *
2712 * Introduces an dentry into the tree, substituting an extant disconnected
2713 * root directory alias in its place if there is one. Caller must hold the
2714 * i_mutex of the parent directory.
2715 */
2716struct dentry *d_materialise_unique(struct dentry *dentry, struct inode *inode)
2717{
2718 struct dentry *actual;
2719
2720 BUG_ON(!d_unhashed(dentry)); 2638 BUG_ON(!d_unhashed(dentry));
2721 2639
2722 if (!inode) { 2640 if (!inode) {
2723 actual = dentry;
2724 __d_instantiate(dentry, NULL); 2641 __d_instantiate(dentry, NULL);
2725 d_rehash(actual); 2642 goto out;
2726 goto out_nolock;
2727 } 2643 }
2728
2729 spin_lock(&inode->i_lock); 2644 spin_lock(&inode->i_lock);
2730
2731 if (S_ISDIR(inode->i_mode)) { 2645 if (S_ISDIR(inode->i_mode)) {
2732 struct dentry *alias; 2646 struct dentry *new = __d_find_any_alias(inode);
2733 2647 if (unlikely(new)) {
2734 /* Does an aliased dentry already exist? */
2735 alias = __d_find_alias(inode);
2736 if (alias) {
2737 actual = alias;
2738 write_seqlock(&rename_lock); 2648 write_seqlock(&rename_lock);
2739 2649 if (unlikely(d_ancestor(new, dentry))) {
2740 if (d_ancestor(alias, dentry)) { 2650 write_sequnlock(&rename_lock);
2741 /* Check for loops */
2742 actual = ERR_PTR(-ELOOP);
2743 spin_unlock(&inode->i_lock); 2651 spin_unlock(&inode->i_lock);
2744 } else if (IS_ROOT(alias)) { 2652 dput(new);
2745 /* Is this an anonymous mountpoint that we 2653 new = ERR_PTR(-ELOOP);
2746 * could splice into our tree? */ 2654 pr_warn_ratelimited(
2747 __d_move(alias, dentry, false); 2655 "VFS: Lookup of '%s' in %s %s"
2656 " would have caused loop\n",
2657 dentry->d_name.name,
2658 inode->i_sb->s_type->name,
2659 inode->i_sb->s_id);
2660 } else if (!IS_ROOT(new)) {
2661 int err = __d_unalias(inode, dentry, new);
2748 write_sequnlock(&rename_lock); 2662 write_sequnlock(&rename_lock);
2749 goto found; 2663 if (err) {
2664 dput(new);
2665 new = ERR_PTR(err);
2666 }
2750 } else { 2667 } else {
2751 /* Nope, but we must(!) avoid directory 2668 __d_move(new, dentry, false);
2752 * aliasing. This drops inode->i_lock */ 2669 write_sequnlock(&rename_lock);
2753 actual = __d_unalias(inode, dentry, alias); 2670 spin_unlock(&inode->i_lock);
2754 } 2671 security_d_instantiate(new, inode);
2755 write_sequnlock(&rename_lock);
2756 if (IS_ERR(actual)) {
2757 if (PTR_ERR(actual) == -ELOOP)
2758 pr_warn_ratelimited(
2759 "VFS: Lookup of '%s' in %s %s"
2760 " would have caused loop\n",
2761 dentry->d_name.name,
2762 inode->i_sb->s_type->name,
2763 inode->i_sb->s_id);
2764 dput(alias);
2765 } 2672 }
2766 goto out_nolock; 2673 iput(inode);
2674 return new;
2767 } 2675 }
2768 } 2676 }
2769 2677 /* already taking inode->i_lock, so d_add() by hand */
2770 /* Add a unique reference */ 2678 __d_instantiate(dentry, inode);
2771 actual = __d_instantiate_unique(dentry, inode);
2772 if (!actual)
2773 actual = dentry;
2774
2775 d_rehash(actual);
2776found:
2777 spin_unlock(&inode->i_lock); 2679 spin_unlock(&inode->i_lock);
2778out_nolock: 2680out:
2779 if (actual == dentry) { 2681 security_d_instantiate(dentry, inode);
2780 security_d_instantiate(dentry, inode); 2682 d_rehash(dentry);
2781 return NULL; 2683 return NULL;
2782 }
2783
2784 iput(inode);
2785 return actual;
2786} 2684}
2787EXPORT_SYMBOL_GPL(d_materialise_unique); 2685EXPORT_SYMBOL(d_splice_alias);
2788 2686
2789static int prepend(char **buffer, int *buflen, const char *str, int namelen) 2687static int prepend(char **buffer, int *buflen, const char *str, int namelen)
2790{ 2688{
@@ -3320,7 +3218,7 @@ void d_tmpfile(struct dentry *dentry, struct inode *inode)
3320{ 3218{
3321 inode_dec_link_count(inode); 3219 inode_dec_link_count(inode);
3322 BUG_ON(dentry->d_name.name != dentry->d_iname || 3220 BUG_ON(dentry->d_name.name != dentry->d_iname ||
3323 !hlist_unhashed(&dentry->d_alias) || 3221 !hlist_unhashed(&dentry->d_u.d_alias) ||
3324 !d_unlinked(dentry)); 3222 !d_unlinked(dentry));
3325 spin_lock(&dentry->d_parent->d_lock); 3223 spin_lock(&dentry->d_parent->d_lock);
3326 spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED); 3224 spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index 76c08c2beb2f..8e0f2f410189 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -692,18 +692,19 @@ EXPORT_SYMBOL_GPL(debugfs_create_u32_array);
692 * because some peripherals have several blocks of identical registers, 692 * because some peripherals have several blocks of identical registers,
693 * for example configuration of dma channels 693 * for example configuration of dma channels
694 */ 694 */
695int debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs, 695void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs,
696 int nregs, void __iomem *base, char *prefix) 696 int nregs, void __iomem *base, char *prefix)
697{ 697{
698 int i, ret = 0; 698 int i;
699 699
700 for (i = 0; i < nregs; i++, regs++) { 700 for (i = 0; i < nregs; i++, regs++) {
701 if (prefix) 701 if (prefix)
702 ret += seq_printf(s, "%s", prefix); 702 seq_printf(s, "%s", prefix);
703 ret += seq_printf(s, "%s = 0x%08x\n", regs->name, 703 seq_printf(s, "%s = 0x%08x\n", regs->name,
704 readl(base + regs->offset)); 704 readl(base + regs->offset));
705 if (seq_has_overflowed(s))
706 break;
705 } 707 }
706 return ret;
707} 708}
708EXPORT_SYMBOL_GPL(debugfs_print_regs32); 709EXPORT_SYMBOL_GPL(debugfs_print_regs32);
709 710
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 1e3b99d3db0d..05f2960ed7c3 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -553,7 +553,7 @@ void debugfs_remove_recursive(struct dentry *dentry)
553 * use the d_u.d_child as the rcu head and corrupt this list. 553 * use the d_u.d_child as the rcu head and corrupt this list.
554 */ 554 */
555 spin_lock(&parent->d_lock); 555 spin_lock(&parent->d_lock);
556 list_for_each_entry(child, &parent->d_subdirs, d_u.d_child) { 556 list_for_each_entry(child, &parent->d_subdirs, d_child) {
557 if (!debugfs_positive(child)) 557 if (!debugfs_positive(child))
558 continue; 558 continue;
559 559
diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c
index 1323c568e362..eea64912c9c0 100644
--- a/fs/dlm/debug_fs.c
+++ b/fs/dlm/debug_fs.c
@@ -48,8 +48,8 @@ static char *print_lockmode(int mode)
48 } 48 }
49} 49}
50 50
51static int print_format1_lock(struct seq_file *s, struct dlm_lkb *lkb, 51static void print_format1_lock(struct seq_file *s, struct dlm_lkb *lkb,
52 struct dlm_rsb *res) 52 struct dlm_rsb *res)
53{ 53{
54 seq_printf(s, "%08x %s", lkb->lkb_id, print_lockmode(lkb->lkb_grmode)); 54 seq_printf(s, "%08x %s", lkb->lkb_id, print_lockmode(lkb->lkb_grmode));
55 55
@@ -68,21 +68,17 @@ static int print_format1_lock(struct seq_file *s, struct dlm_lkb *lkb,
68 if (lkb->lkb_wait_type) 68 if (lkb->lkb_wait_type)
69 seq_printf(s, " wait_type: %d", lkb->lkb_wait_type); 69 seq_printf(s, " wait_type: %d", lkb->lkb_wait_type);
70 70
71 return seq_puts(s, "\n"); 71 seq_puts(s, "\n");
72} 72}
73 73
74static int print_format1(struct dlm_rsb *res, struct seq_file *s) 74static void print_format1(struct dlm_rsb *res, struct seq_file *s)
75{ 75{
76 struct dlm_lkb *lkb; 76 struct dlm_lkb *lkb;
77 int i, lvblen = res->res_ls->ls_lvblen, recover_list, root_list; 77 int i, lvblen = res->res_ls->ls_lvblen, recover_list, root_list;
78 int rv;
79 78
80 lock_rsb(res); 79 lock_rsb(res);
81 80
82 rv = seq_printf(s, "\nResource %p Name (len=%d) \"", 81 seq_printf(s, "\nResource %p Name (len=%d) \"", res, res->res_length);
83 res, res->res_length);
84 if (rv)
85 goto out;
86 82
87 for (i = 0; i < res->res_length; i++) { 83 for (i = 0; i < res->res_length; i++) {
88 if (isprint(res->res_name[i])) 84 if (isprint(res->res_name[i]))
@@ -92,17 +88,16 @@ static int print_format1(struct dlm_rsb *res, struct seq_file *s)
92 } 88 }
93 89
94 if (res->res_nodeid > 0) 90 if (res->res_nodeid > 0)
95 rv = seq_printf(s, "\"\nLocal Copy, Master is node %d\n", 91 seq_printf(s, "\"\nLocal Copy, Master is node %d\n",
96 res->res_nodeid); 92 res->res_nodeid);
97 else if (res->res_nodeid == 0) 93 else if (res->res_nodeid == 0)
98 rv = seq_puts(s, "\"\nMaster Copy\n"); 94 seq_puts(s, "\"\nMaster Copy\n");
99 else if (res->res_nodeid == -1) 95 else if (res->res_nodeid == -1)
100 rv = seq_printf(s, "\"\nLooking up master (lkid %x)\n", 96 seq_printf(s, "\"\nLooking up master (lkid %x)\n",
101 res->res_first_lkid); 97 res->res_first_lkid);
102 else 98 else
103 rv = seq_printf(s, "\"\nInvalid master %d\n", 99 seq_printf(s, "\"\nInvalid master %d\n", res->res_nodeid);
104 res->res_nodeid); 100 if (seq_has_overflowed(s))
105 if (rv)
106 goto out; 101 goto out;
107 102
108 /* Print the LVB: */ 103 /* Print the LVB: */
@@ -116,8 +111,8 @@ static int print_format1(struct dlm_rsb *res, struct seq_file *s)
116 } 111 }
117 if (rsb_flag(res, RSB_VALNOTVALID)) 112 if (rsb_flag(res, RSB_VALNOTVALID))
118 seq_puts(s, " (INVALID)"); 113 seq_puts(s, " (INVALID)");
119 rv = seq_puts(s, "\n"); 114 seq_puts(s, "\n");
120 if (rv) 115 if (seq_has_overflowed(s))
121 goto out; 116 goto out;
122 } 117 }
123 118
@@ -125,32 +120,30 @@ static int print_format1(struct dlm_rsb *res, struct seq_file *s)
125 recover_list = !list_empty(&res->res_recover_list); 120 recover_list = !list_empty(&res->res_recover_list);
126 121
127 if (root_list || recover_list) { 122 if (root_list || recover_list) {
128 rv = seq_printf(s, "Recovery: root %d recover %d flags %lx " 123 seq_printf(s, "Recovery: root %d recover %d flags %lx count %d\n",
129 "count %d\n", root_list, recover_list, 124 root_list, recover_list,
130 res->res_flags, res->res_recover_locks_count); 125 res->res_flags, res->res_recover_locks_count);
131 if (rv)
132 goto out;
133 } 126 }
134 127
135 /* Print the locks attached to this resource */ 128 /* Print the locks attached to this resource */
136 seq_puts(s, "Granted Queue\n"); 129 seq_puts(s, "Granted Queue\n");
137 list_for_each_entry(lkb, &res->res_grantqueue, lkb_statequeue) { 130 list_for_each_entry(lkb, &res->res_grantqueue, lkb_statequeue) {
138 rv = print_format1_lock(s, lkb, res); 131 print_format1_lock(s, lkb, res);
139 if (rv) 132 if (seq_has_overflowed(s))
140 goto out; 133 goto out;
141 } 134 }
142 135
143 seq_puts(s, "Conversion Queue\n"); 136 seq_puts(s, "Conversion Queue\n");
144 list_for_each_entry(lkb, &res->res_convertqueue, lkb_statequeue) { 137 list_for_each_entry(lkb, &res->res_convertqueue, lkb_statequeue) {
145 rv = print_format1_lock(s, lkb, res); 138 print_format1_lock(s, lkb, res);
146 if (rv) 139 if (seq_has_overflowed(s))
147 goto out; 140 goto out;
148 } 141 }
149 142
150 seq_puts(s, "Waiting Queue\n"); 143 seq_puts(s, "Waiting Queue\n");
151 list_for_each_entry(lkb, &res->res_waitqueue, lkb_statequeue) { 144 list_for_each_entry(lkb, &res->res_waitqueue, lkb_statequeue) {
152 rv = print_format1_lock(s, lkb, res); 145 print_format1_lock(s, lkb, res);
153 if (rv) 146 if (seq_has_overflowed(s))
154 goto out; 147 goto out;
155 } 148 }
156 149
@@ -159,23 +152,23 @@ static int print_format1(struct dlm_rsb *res, struct seq_file *s)
159 152
160 seq_puts(s, "Lookup Queue\n"); 153 seq_puts(s, "Lookup Queue\n");
161 list_for_each_entry(lkb, &res->res_lookup, lkb_rsb_lookup) { 154 list_for_each_entry(lkb, &res->res_lookup, lkb_rsb_lookup) {
162 rv = seq_printf(s, "%08x %s", lkb->lkb_id, 155 seq_printf(s, "%08x %s",
163 print_lockmode(lkb->lkb_rqmode)); 156 lkb->lkb_id, print_lockmode(lkb->lkb_rqmode));
164 if (lkb->lkb_wait_type) 157 if (lkb->lkb_wait_type)
165 seq_printf(s, " wait_type: %d", lkb->lkb_wait_type); 158 seq_printf(s, " wait_type: %d", lkb->lkb_wait_type);
166 rv = seq_puts(s, "\n"); 159 seq_puts(s, "\n");
160 if (seq_has_overflowed(s))
161 goto out;
167 } 162 }
168 out: 163 out:
169 unlock_rsb(res); 164 unlock_rsb(res);
170 return rv;
171} 165}
172 166
173static int print_format2_lock(struct seq_file *s, struct dlm_lkb *lkb, 167static void print_format2_lock(struct seq_file *s, struct dlm_lkb *lkb,
174 struct dlm_rsb *r) 168 struct dlm_rsb *r)
175{ 169{
176 u64 xid = 0; 170 u64 xid = 0;
177 u64 us; 171 u64 us;
178 int rv;
179 172
180 if (lkb->lkb_flags & DLM_IFL_USER) { 173 if (lkb->lkb_flags & DLM_IFL_USER) {
181 if (lkb->lkb_ua) 174 if (lkb->lkb_ua)
@@ -188,103 +181,97 @@ static int print_format2_lock(struct seq_file *s, struct dlm_lkb *lkb,
188 /* id nodeid remid pid xid exflags flags sts grmode rqmode time_us 181 /* id nodeid remid pid xid exflags flags sts grmode rqmode time_us
189 r_nodeid r_len r_name */ 182 r_nodeid r_len r_name */
190 183
191 rv = seq_printf(s, "%x %d %x %u %llu %x %x %d %d %d %llu %u %d \"%s\"\n", 184 seq_printf(s, "%x %d %x %u %llu %x %x %d %d %d %llu %u %d \"%s\"\n",
192 lkb->lkb_id, 185 lkb->lkb_id,
193 lkb->lkb_nodeid, 186 lkb->lkb_nodeid,
194 lkb->lkb_remid, 187 lkb->lkb_remid,
195 lkb->lkb_ownpid, 188 lkb->lkb_ownpid,
196 (unsigned long long)xid, 189 (unsigned long long)xid,
197 lkb->lkb_exflags, 190 lkb->lkb_exflags,
198 lkb->lkb_flags, 191 lkb->lkb_flags,
199 lkb->lkb_status, 192 lkb->lkb_status,
200 lkb->lkb_grmode, 193 lkb->lkb_grmode,
201 lkb->lkb_rqmode, 194 lkb->lkb_rqmode,
202 (unsigned long long)us, 195 (unsigned long long)us,
203 r->res_nodeid, 196 r->res_nodeid,
204 r->res_length, 197 r->res_length,
205 r->res_name); 198 r->res_name);
206 return rv;
207} 199}
208 200
209static int print_format2(struct dlm_rsb *r, struct seq_file *s) 201static void print_format2(struct dlm_rsb *r, struct seq_file *s)
210{ 202{
211 struct dlm_lkb *lkb; 203 struct dlm_lkb *lkb;
212 int rv = 0;
213 204
214 lock_rsb(r); 205 lock_rsb(r);
215 206
216 list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) { 207 list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) {
217 rv = print_format2_lock(s, lkb, r); 208 print_format2_lock(s, lkb, r);
218 if (rv) 209 if (seq_has_overflowed(s))
219 goto out; 210 goto out;
220 } 211 }
221 212
222 list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) { 213 list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) {
223 rv = print_format2_lock(s, lkb, r); 214 print_format2_lock(s, lkb, r);
224 if (rv) 215 if (seq_has_overflowed(s))
225 goto out; 216 goto out;
226 } 217 }
227 218
228 list_for_each_entry(lkb, &r->res_waitqueue, lkb_statequeue) { 219 list_for_each_entry(lkb, &r->res_waitqueue, lkb_statequeue) {
229 rv = print_format2_lock(s, lkb, r); 220 print_format2_lock(s, lkb, r);
230 if (rv) 221 if (seq_has_overflowed(s))
231 goto out; 222 goto out;
232 } 223 }
233 out: 224 out:
234 unlock_rsb(r); 225 unlock_rsb(r);
235 return rv;
236} 226}
237 227
238static int print_format3_lock(struct seq_file *s, struct dlm_lkb *lkb, 228static void print_format3_lock(struct seq_file *s, struct dlm_lkb *lkb,
239 int rsb_lookup) 229 int rsb_lookup)
240{ 230{
241 u64 xid = 0; 231 u64 xid = 0;
242 int rv;
243 232
244 if (lkb->lkb_flags & DLM_IFL_USER) { 233 if (lkb->lkb_flags & DLM_IFL_USER) {
245 if (lkb->lkb_ua) 234 if (lkb->lkb_ua)
246 xid = lkb->lkb_ua->xid; 235 xid = lkb->lkb_ua->xid;
247 } 236 }
248 237
249 rv = seq_printf(s, "lkb %x %d %x %u %llu %x %x %d %d %d %d %d %d %u %llu %llu\n", 238 seq_printf(s, "lkb %x %d %x %u %llu %x %x %d %d %d %d %d %d %u %llu %llu\n",
250 lkb->lkb_id, 239 lkb->lkb_id,
251 lkb->lkb_nodeid, 240 lkb->lkb_nodeid,
252 lkb->lkb_remid, 241 lkb->lkb_remid,
253 lkb->lkb_ownpid, 242 lkb->lkb_ownpid,
254 (unsigned long long)xid, 243 (unsigned long long)xid,
255 lkb->lkb_exflags, 244 lkb->lkb_exflags,
256 lkb->lkb_flags, 245 lkb->lkb_flags,
257 lkb->lkb_status, 246 lkb->lkb_status,
258 lkb->lkb_grmode, 247 lkb->lkb_grmode,
259 lkb->lkb_rqmode, 248 lkb->lkb_rqmode,
260 lkb->lkb_last_bast.mode, 249 lkb->lkb_last_bast.mode,
261 rsb_lookup, 250 rsb_lookup,
262 lkb->lkb_wait_type, 251 lkb->lkb_wait_type,
263 lkb->lkb_lvbseq, 252 lkb->lkb_lvbseq,
264 (unsigned long long)ktime_to_ns(lkb->lkb_timestamp), 253 (unsigned long long)ktime_to_ns(lkb->lkb_timestamp),
265 (unsigned long long)ktime_to_ns(lkb->lkb_last_bast_time)); 254 (unsigned long long)ktime_to_ns(lkb->lkb_last_bast_time));
266 return rv;
267} 255}
268 256
269static int print_format3(struct dlm_rsb *r, struct seq_file *s) 257static void print_format3(struct dlm_rsb *r, struct seq_file *s)
270{ 258{
271 struct dlm_lkb *lkb; 259 struct dlm_lkb *lkb;
272 int i, lvblen = r->res_ls->ls_lvblen; 260 int i, lvblen = r->res_ls->ls_lvblen;
273 int print_name = 1; 261 int print_name = 1;
274 int rv;
275 262
276 lock_rsb(r); 263 lock_rsb(r);
277 264
278 rv = seq_printf(s, "rsb %p %d %x %lx %d %d %u %d ", 265 seq_printf(s, "rsb %p %d %x %lx %d %d %u %d ",
279 r, 266 r,
280 r->res_nodeid, 267 r->res_nodeid,
281 r->res_first_lkid, 268 r->res_first_lkid,
282 r->res_flags, 269 r->res_flags,
283 !list_empty(&r->res_root_list), 270 !list_empty(&r->res_root_list),
284 !list_empty(&r->res_recover_list), 271 !list_empty(&r->res_recover_list),
285 r->res_recover_locks_count, 272 r->res_recover_locks_count,
286 r->res_length); 273 r->res_length);
287 if (rv) 274 if (seq_has_overflowed(s))
288 goto out; 275 goto out;
289 276
290 for (i = 0; i < r->res_length; i++) { 277 for (i = 0; i < r->res_length; i++) {
@@ -292,7 +279,7 @@ static int print_format3(struct dlm_rsb *r, struct seq_file *s)
292 print_name = 0; 279 print_name = 0;
293 } 280 }
294 281
295 seq_printf(s, "%s", print_name ? "str " : "hex"); 282 seq_puts(s, print_name ? "str " : "hex");
296 283
297 for (i = 0; i < r->res_length; i++) { 284 for (i = 0; i < r->res_length; i++) {
298 if (print_name) 285 if (print_name)
@@ -300,8 +287,8 @@ static int print_format3(struct dlm_rsb *r, struct seq_file *s)
300 else 287 else
301 seq_printf(s, " %02x", (unsigned char)r->res_name[i]); 288 seq_printf(s, " %02x", (unsigned char)r->res_name[i]);
302 } 289 }
303 rv = seq_puts(s, "\n"); 290 seq_puts(s, "\n");
304 if (rv) 291 if (seq_has_overflowed(s))
305 goto out; 292 goto out;
306 293
307 if (!r->res_lvbptr) 294 if (!r->res_lvbptr)
@@ -311,65 +298,62 @@ static int print_format3(struct dlm_rsb *r, struct seq_file *s)
311 298
312 for (i = 0; i < lvblen; i++) 299 for (i = 0; i < lvblen; i++)
313 seq_printf(s, " %02x", (unsigned char)r->res_lvbptr[i]); 300 seq_printf(s, " %02x", (unsigned char)r->res_lvbptr[i]);
314 rv = seq_puts(s, "\n"); 301 seq_puts(s, "\n");
315 if (rv) 302 if (seq_has_overflowed(s))
316 goto out; 303 goto out;
317 304
318 do_locks: 305 do_locks:
319 list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) { 306 list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) {
320 rv = print_format3_lock(s, lkb, 0); 307 print_format3_lock(s, lkb, 0);
321 if (rv) 308 if (seq_has_overflowed(s))
322 goto out; 309 goto out;
323 } 310 }
324 311
325 list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) { 312 list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) {
326 rv = print_format3_lock(s, lkb, 0); 313 print_format3_lock(s, lkb, 0);
327 if (rv) 314 if (seq_has_overflowed(s))
328 goto out; 315 goto out;
329 } 316 }
330 317
331 list_for_each_entry(lkb, &r->res_waitqueue, lkb_statequeue) { 318 list_for_each_entry(lkb, &r->res_waitqueue, lkb_statequeue) {
332 rv = print_format3_lock(s, lkb, 0); 319 print_format3_lock(s, lkb, 0);
333 if (rv) 320 if (seq_has_overflowed(s))
334 goto out; 321 goto out;
335 } 322 }
336 323
337 list_for_each_entry(lkb, &r->res_lookup, lkb_rsb_lookup) { 324 list_for_each_entry(lkb, &r->res_lookup, lkb_rsb_lookup) {
338 rv = print_format3_lock(s, lkb, 1); 325 print_format3_lock(s, lkb, 1);
339 if (rv) 326 if (seq_has_overflowed(s))
340 goto out; 327 goto out;
341 } 328 }
342 out: 329 out:
343 unlock_rsb(r); 330 unlock_rsb(r);
344 return rv;
345} 331}
346 332
347static int print_format4(struct dlm_rsb *r, struct seq_file *s) 333static void print_format4(struct dlm_rsb *r, struct seq_file *s)
348{ 334{
349 int our_nodeid = dlm_our_nodeid(); 335 int our_nodeid = dlm_our_nodeid();
350 int print_name = 1; 336 int print_name = 1;
351 int i, rv; 337 int i;
352 338
353 lock_rsb(r); 339 lock_rsb(r);
354 340
355 rv = seq_printf(s, "rsb %p %d %d %d %d %lu %lx %d ", 341 seq_printf(s, "rsb %p %d %d %d %d %lu %lx %d ",
356 r, 342 r,
357 r->res_nodeid, 343 r->res_nodeid,
358 r->res_master_nodeid, 344 r->res_master_nodeid,
359 r->res_dir_nodeid, 345 r->res_dir_nodeid,
360 our_nodeid, 346 our_nodeid,
361 r->res_toss_time, 347 r->res_toss_time,
362 r->res_flags, 348 r->res_flags,
363 r->res_length); 349 r->res_length);
364 if (rv)
365 goto out;
366 350
367 for (i = 0; i < r->res_length; i++) { 351 for (i = 0; i < r->res_length; i++) {
368 if (!isascii(r->res_name[i]) || !isprint(r->res_name[i])) 352 if (!isascii(r->res_name[i]) || !isprint(r->res_name[i]))
369 print_name = 0; 353 print_name = 0;
370 } 354 }
371 355
372 seq_printf(s, "%s", print_name ? "str " : "hex"); 356 seq_puts(s, print_name ? "str " : "hex");
373 357
374 for (i = 0; i < r->res_length; i++) { 358 for (i = 0; i < r->res_length; i++) {
375 if (print_name) 359 if (print_name)
@@ -377,10 +361,9 @@ static int print_format4(struct dlm_rsb *r, struct seq_file *s)
377 else 361 else
378 seq_printf(s, " %02x", (unsigned char)r->res_name[i]); 362 seq_printf(s, " %02x", (unsigned char)r->res_name[i]);
379 } 363 }
380 rv = seq_puts(s, "\n"); 364 seq_puts(s, "\n");
381 out: 365
382 unlock_rsb(r); 366 unlock_rsb(r);
383 return rv;
384} 367}
385 368
386struct rsbtbl_iter { 369struct rsbtbl_iter {
@@ -390,47 +373,45 @@ struct rsbtbl_iter {
390 int header; 373 int header;
391}; 374};
392 375
393/* seq_printf returns -1 if the buffer is full, and 0 otherwise. 376/*
394 If the buffer is full, seq_printf can be called again, but it 377 * If the buffer is full, seq_printf can be called again, but it
395 does nothing and just returns -1. So, the these printing routines 378 * does nothing. So, the these printing routines periodically check
396 periodically check the return value to avoid wasting too much time 379 * seq_has_overflowed to avoid wasting too much time trying to print to
397 trying to print to a full buffer. */ 380 * a full buffer.
381 */
398 382
399static int table_seq_show(struct seq_file *seq, void *iter_ptr) 383static int table_seq_show(struct seq_file *seq, void *iter_ptr)
400{ 384{
401 struct rsbtbl_iter *ri = iter_ptr; 385 struct rsbtbl_iter *ri = iter_ptr;
402 int rv = 0;
403 386
404 switch (ri->format) { 387 switch (ri->format) {
405 case 1: 388 case 1:
406 rv = print_format1(ri->rsb, seq); 389 print_format1(ri->rsb, seq);
407 break; 390 break;
408 case 2: 391 case 2:
409 if (ri->header) { 392 if (ri->header) {
410 seq_printf(seq, "id nodeid remid pid xid exflags " 393 seq_puts(seq, "id nodeid remid pid xid exflags flags sts grmode rqmode time_ms r_nodeid r_len r_name\n");
411 "flags sts grmode rqmode time_ms "
412 "r_nodeid r_len r_name\n");
413 ri->header = 0; 394 ri->header = 0;
414 } 395 }
415 rv = print_format2(ri->rsb, seq); 396 print_format2(ri->rsb, seq);
416 break; 397 break;
417 case 3: 398 case 3:
418 if (ri->header) { 399 if (ri->header) {
419 seq_printf(seq, "version rsb 1.1 lvb 1.1 lkb 1.1\n"); 400 seq_puts(seq, "version rsb 1.1 lvb 1.1 lkb 1.1\n");
420 ri->header = 0; 401 ri->header = 0;
421 } 402 }
422 rv = print_format3(ri->rsb, seq); 403 print_format3(ri->rsb, seq);
423 break; 404 break;
424 case 4: 405 case 4:
425 if (ri->header) { 406 if (ri->header) {
426 seq_printf(seq, "version 4 rsb 2\n"); 407 seq_puts(seq, "version 4 rsb 2\n");
427 ri->header = 0; 408 ri->header = 0;
428 } 409 }
429 rv = print_format4(ri->rsb, seq); 410 print_format4(ri->rsb, seq);
430 break; 411 break;
431 } 412 }
432 413
433 return rv; 414 return 0;
434} 415}
435 416
436static const struct seq_operations format1_seq_ops; 417static const struct seq_operations format1_seq_ops;
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 2f6735dbf1a9..c2d6604667b0 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -1373,7 +1373,7 @@ out:
1373int ecryptfs_read_xattr_region(char *page_virt, struct inode *ecryptfs_inode) 1373int ecryptfs_read_xattr_region(char *page_virt, struct inode *ecryptfs_inode)
1374{ 1374{
1375 struct dentry *lower_dentry = 1375 struct dentry *lower_dentry =
1376 ecryptfs_inode_to_private(ecryptfs_inode)->lower_file->f_dentry; 1376 ecryptfs_inode_to_private(ecryptfs_inode)->lower_file->f_path.dentry;
1377 ssize_t size; 1377 ssize_t size;
1378 int rc = 0; 1378 int rc = 0;
1379 1379
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index f5bce9096555..80154ec4f8c2 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -75,11 +75,11 @@ struct ecryptfs_getdents_callback {
75 75
76/* Inspired by generic filldir in fs/readdir.c */ 76/* Inspired by generic filldir in fs/readdir.c */
77static int 77static int
78ecryptfs_filldir(void *dirent, const char *lower_name, int lower_namelen, 78ecryptfs_filldir(struct dir_context *ctx, const char *lower_name,
79 loff_t offset, u64 ino, unsigned int d_type) 79 int lower_namelen, loff_t offset, u64 ino, unsigned int d_type)
80{ 80{
81 struct ecryptfs_getdents_callback *buf = 81 struct ecryptfs_getdents_callback *buf =
82 (struct ecryptfs_getdents_callback *)dirent; 82 container_of(ctx, struct ecryptfs_getdents_callback, ctx);
83 size_t name_size; 83 size_t name_size;
84 char *name; 84 char *name;
85 int rc; 85 int rc;
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
index 564a1fa34b99..4626976794e7 100644
--- a/fs/ecryptfs/mmap.c
+++ b/fs/ecryptfs/mmap.c
@@ -419,7 +419,7 @@ static int ecryptfs_write_inode_size_to_xattr(struct inode *ecryptfs_inode)
419 ssize_t size; 419 ssize_t size;
420 void *xattr_virt; 420 void *xattr_virt;
421 struct dentry *lower_dentry = 421 struct dentry *lower_dentry =
422 ecryptfs_inode_to_private(ecryptfs_inode)->lower_file->f_dentry; 422 ecryptfs_inode_to_private(ecryptfs_inode)->lower_file->f_path.dentry;
423 struct inode *lower_inode = lower_dentry->d_inode; 423 struct inode *lower_inode = lower_dentry->d_inode;
424 int rc; 424 int rc;
425 425
diff --git a/fs/efivarfs/file.c b/fs/efivarfs/file.c
index cdb2971192a5..90001da9abfd 100644
--- a/fs/efivarfs/file.c
+++ b/fs/efivarfs/file.c
@@ -47,8 +47,8 @@ static ssize_t efivarfs_file_write(struct file *file,
47 47
48 if (bytes == -ENOENT) { 48 if (bytes == -ENOENT) {
49 drop_nlink(inode); 49 drop_nlink(inode);
50 d_delete(file->f_dentry); 50 d_delete(file->f_path.dentry);
51 dput(file->f_dentry); 51 dput(file->f_path.dentry);
52 } else { 52 } else {
53 mutex_lock(&inode->i_mutex); 53 mutex_lock(&inode->i_mutex);
54 i_size_write(inode, datasize + sizeof(attributes)); 54 i_size_write(inode, datasize + sizeof(attributes));
diff --git a/fs/eventfd.c b/fs/eventfd.c
index d6a88e7812f3..4b0a226024fa 100644
--- a/fs/eventfd.c
+++ b/fs/eventfd.c
@@ -287,17 +287,14 @@ static ssize_t eventfd_write(struct file *file, const char __user *buf, size_t c
287} 287}
288 288
289#ifdef CONFIG_PROC_FS 289#ifdef CONFIG_PROC_FS
290static int eventfd_show_fdinfo(struct seq_file *m, struct file *f) 290static void eventfd_show_fdinfo(struct seq_file *m, struct file *f)
291{ 291{
292 struct eventfd_ctx *ctx = f->private_data; 292 struct eventfd_ctx *ctx = f->private_data;
293 int ret;
294 293
295 spin_lock_irq(&ctx->wqh.lock); 294 spin_lock_irq(&ctx->wqh.lock);
296 ret = seq_printf(m, "eventfd-count: %16llx\n", 295 seq_printf(m, "eventfd-count: %16llx\n",
297 (unsigned long long)ctx->count); 296 (unsigned long long)ctx->count);
298 spin_unlock_irq(&ctx->wqh.lock); 297 spin_unlock_irq(&ctx->wqh.lock);
299
300 return ret;
301} 298}
302#endif 299#endif
303 300
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 7bcfff900f05..d77f94491352 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -870,25 +870,22 @@ static unsigned int ep_eventpoll_poll(struct file *file, poll_table *wait)
870} 870}
871 871
872#ifdef CONFIG_PROC_FS 872#ifdef CONFIG_PROC_FS
873static int ep_show_fdinfo(struct seq_file *m, struct file *f) 873static void ep_show_fdinfo(struct seq_file *m, struct file *f)
874{ 874{
875 struct eventpoll *ep = f->private_data; 875 struct eventpoll *ep = f->private_data;
876 struct rb_node *rbp; 876 struct rb_node *rbp;
877 int ret = 0;
878 877
879 mutex_lock(&ep->mtx); 878 mutex_lock(&ep->mtx);
880 for (rbp = rb_first(&ep->rbr); rbp; rbp = rb_next(rbp)) { 879 for (rbp = rb_first(&ep->rbr); rbp; rbp = rb_next(rbp)) {
881 struct epitem *epi = rb_entry(rbp, struct epitem, rbn); 880 struct epitem *epi = rb_entry(rbp, struct epitem, rbn);
882 881
883 ret = seq_printf(m, "tfd: %8d events: %8x data: %16llx\n", 882 seq_printf(m, "tfd: %8d events: %8x data: %16llx\n",
884 epi->ffd.fd, epi->event.events, 883 epi->ffd.fd, epi->event.events,
885 (long long)epi->event.data); 884 (long long)epi->event.data);
886 if (ret) 885 if (seq_has_overflowed(m))
887 break; 886 break;
888 } 887 }
889 mutex_unlock(&ep->mtx); 888 mutex_unlock(&ep->mtx);
890
891 return ret;
892} 889}
893#endif 890#endif
894 891
diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c
index b01fbfb51f43..fdfd206c737a 100644
--- a/fs/exportfs/expfs.c
+++ b/fs/exportfs/expfs.c
@@ -50,7 +50,7 @@ find_acceptable_alias(struct dentry *result,
50 50
51 inode = result->d_inode; 51 inode = result->d_inode;
52 spin_lock(&inode->i_lock); 52 spin_lock(&inode->i_lock);
53 hlist_for_each_entry(dentry, &inode->i_dentry, d_alias) { 53 hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) {
54 dget(dentry); 54 dget(dentry);
55 spin_unlock(&inode->i_lock); 55 spin_unlock(&inode->i_lock);
56 if (toput) 56 if (toput)
@@ -241,10 +241,11 @@ struct getdents_callback {
241 * A rather strange filldir function to capture 241 * A rather strange filldir function to capture
242 * the name matching the specified inode number. 242 * the name matching the specified inode number.
243 */ 243 */
244static int filldir_one(void * __buf, const char * name, int len, 244static int filldir_one(struct dir_context *ctx, const char *name, int len,
245 loff_t pos, u64 ino, unsigned int d_type) 245 loff_t pos, u64 ino, unsigned int d_type)
246{ 246{
247 struct getdents_callback *buf = __buf; 247 struct getdents_callback *buf =
248 container_of(ctx, struct getdents_callback, ctx);
248 int result = 0; 249 int result = 0;
249 250
250 buf->sequence++; 251 buf->sequence++;
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 7015db0bafd1..eb742d0e67ff 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -1354,13 +1354,6 @@ set_qf_format:
1354 "not specified."); 1354 "not specified.");
1355 return 0; 1355 return 0;
1356 } 1356 }
1357 } else {
1358 if (sbi->s_jquota_fmt) {
1359 ext3_msg(sb, KERN_ERR, "error: journaled quota format "
1360 "specified with no journaling "
1361 "enabled.");
1362 return 0;
1363 }
1364 } 1357 }
1365#endif 1358#endif
1366 return 1; 1359 return 1;
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 37043d0b2be8..0b16fb4c06d3 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3603,11 +3603,10 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,
3603 } 3603 }
3604 } 3604 }
3605 3605
3606 allocated = ext4_split_extent(handle, inode, ppath, 3606 err = ext4_split_extent(handle, inode, ppath, &split_map, split_flag,
3607 &split_map, split_flag, flags); 3607 flags);
3608 if (allocated < 0) 3608 if (err > 0)
3609 err = allocated; 3609 err = 0;
3610
3611out: 3610out:
3612 /* If we have gotten a failure, don't zero out status tree */ 3611 /* If we have gotten a failure, don't zero out status tree */
3613 if (!err) 3612 if (!err)
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index aca7b24a4432..8131be8c0af3 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -137,10 +137,10 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
137 iov_iter_truncate(from, sbi->s_bitmap_maxbytes - pos); 137 iov_iter_truncate(from, sbi->s_bitmap_maxbytes - pos);
138 } 138 }
139 139
140 iocb->private = &overwrite;
140 if (o_direct) { 141 if (o_direct) {
141 blk_start_plug(&plug); 142 blk_start_plug(&plug);
142 143
143 iocb->private = &overwrite;
144 144
145 /* check whether we do a DIO overwrite or not */ 145 /* check whether we do a DIO overwrite or not */
146 if (ext4_should_dioread_nolock(inode) && !aio_mutex && 146 if (ext4_should_dioread_nolock(inode) && !aio_mutex &&
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 8012a5daf401..ac644c31ca67 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -887,6 +887,10 @@ got:
887 struct buffer_head *block_bitmap_bh; 887 struct buffer_head *block_bitmap_bh;
888 888
889 block_bitmap_bh = ext4_read_block_bitmap(sb, group); 889 block_bitmap_bh = ext4_read_block_bitmap(sb, group);
890 if (!block_bitmap_bh) {
891 err = -EIO;
892 goto out;
893 }
890 BUFFER_TRACE(block_bitmap_bh, "get block bitmap access"); 894 BUFFER_TRACE(block_bitmap_bh, "get block bitmap access");
891 err = ext4_journal_get_write_access(handle, block_bitmap_bh); 895 err = ext4_journal_get_write_access(handle, block_bitmap_bh);
892 if (err) { 896 if (err) {
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index e9777f93cf05..3356ab5395f4 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4959,7 +4959,12 @@ int ext4_change_inode_journal_flag(struct inode *inode, int val)
4959 if (val) 4959 if (val)
4960 ext4_set_inode_flag(inode, EXT4_INODE_JOURNAL_DATA); 4960 ext4_set_inode_flag(inode, EXT4_INODE_JOURNAL_DATA);
4961 else { 4961 else {
4962 jbd2_journal_flush(journal); 4962 err = jbd2_journal_flush(journal);
4963 if (err < 0) {
4964 jbd2_journal_unlock_updates(journal);
4965 ext4_inode_resume_unlocked_dio(inode);
4966 return err;
4967 }
4963 ext4_clear_inode_flag(inode, EXT4_INODE_JOURNAL_DATA); 4968 ext4_clear_inode_flag(inode, EXT4_INODE_JOURNAL_DATA);
4964 } 4969 }
4965 ext4_set_aops(inode); 4970 ext4_set_aops(inode);
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 123798c5ac31..426211882f72 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -1816,31 +1816,39 @@ static int make_indexed_dir(handle_t *handle, struct dentry *dentry,
1816 hinfo.hash_version += EXT4_SB(dir->i_sb)->s_hash_unsigned; 1816 hinfo.hash_version += EXT4_SB(dir->i_sb)->s_hash_unsigned;
1817 hinfo.seed = EXT4_SB(dir->i_sb)->s_hash_seed; 1817 hinfo.seed = EXT4_SB(dir->i_sb)->s_hash_seed;
1818 ext4fs_dirhash(name, namelen, &hinfo); 1818 ext4fs_dirhash(name, namelen, &hinfo);
1819 memset(frames, 0, sizeof(frames));
1819 frame = frames; 1820 frame = frames;
1820 frame->entries = entries; 1821 frame->entries = entries;
1821 frame->at = entries; 1822 frame->at = entries;
1822 frame->bh = bh; 1823 frame->bh = bh;
1823 bh = bh2; 1824 bh = bh2;
1824 1825
1825 ext4_handle_dirty_dx_node(handle, dir, frame->bh); 1826 retval = ext4_handle_dirty_dx_node(handle, dir, frame->bh);
1826 ext4_handle_dirty_dirent_node(handle, dir, bh); 1827 if (retval)
1828 goto out_frames;
1829 retval = ext4_handle_dirty_dirent_node(handle, dir, bh);
1830 if (retval)
1831 goto out_frames;
1827 1832
1828 de = do_split(handle,dir, &bh, frame, &hinfo); 1833 de = do_split(handle,dir, &bh, frame, &hinfo);
1829 if (IS_ERR(de)) { 1834 if (IS_ERR(de)) {
1830 /* 1835 retval = PTR_ERR(de);
1831 * Even if the block split failed, we have to properly write 1836 goto out_frames;
1832 * out all the changes we did so far. Otherwise we can end up
1833 * with corrupted filesystem.
1834 */
1835 ext4_mark_inode_dirty(handle, dir);
1836 dx_release(frames);
1837 return PTR_ERR(de);
1838 } 1837 }
1839 dx_release(frames); 1838 dx_release(frames);
1840 1839
1841 retval = add_dirent_to_buf(handle, dentry, inode, de, bh); 1840 retval = add_dirent_to_buf(handle, dentry, inode, de, bh);
1842 brelse(bh); 1841 brelse(bh);
1843 return retval; 1842 return retval;
1843out_frames:
1844 /*
1845 * Even if the block split failed, we have to properly write
1846 * out all the changes we did so far. Otherwise we can end up
1847 * with corrupted filesystem.
1848 */
1849 ext4_mark_inode_dirty(handle, dir);
1850 dx_release(frames);
1851 return retval;
1844} 1852}
1845 1853
1846/* 1854/*
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index f298c60f907d..ca4588388fc3 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -1081,7 +1081,7 @@ static void update_backups(struct super_block *sb, int blk_off, char *data,
1081 break; 1081 break;
1082 1082
1083 if (meta_bg == 0) 1083 if (meta_bg == 0)
1084 backup_block = group * bpg + blk_off; 1084 backup_block = ((ext4_fsblk_t)group) * bpg + blk_off;
1085 else 1085 else
1086 backup_block = (ext4_group_first_block_no(sb, group) + 1086 backup_block = (ext4_group_first_block_no(sb, group) +
1087 ext4_bg_has_super(sb, group)); 1087 ext4_bg_has_super(sb, group));
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 1eda6ab0ef9d..2c9e6864abd9 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3526,6 +3526,10 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3526#ifdef CONFIG_EXT4_FS_POSIX_ACL 3526#ifdef CONFIG_EXT4_FS_POSIX_ACL
3527 set_opt(sb, POSIX_ACL); 3527 set_opt(sb, POSIX_ACL);
3528#endif 3528#endif
3529 /* don't forget to enable journal_csum when metadata_csum is enabled. */
3530 if (ext4_has_metadata_csum(sb))
3531 set_opt(sb, JOURNAL_CHECKSUM);
3532
3529 if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_DATA) 3533 if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_DATA)
3530 set_opt(sb, JOURNAL_DATA); 3534 set_opt(sb, JOURNAL_DATA);
3531 else if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_ORDERED) 3535 else if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_ORDERED)
@@ -3943,7 +3947,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3943 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_MMP) && 3947 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_MMP) &&
3944 !(sb->s_flags & MS_RDONLY)) 3948 !(sb->s_flags & MS_RDONLY))
3945 if (ext4_multi_mount_protect(sb, le64_to_cpu(es->s_mmp_block))) 3949 if (ext4_multi_mount_protect(sb, le64_to_cpu(es->s_mmp_block)))
3946 goto failed_mount3; 3950 goto failed_mount3a;
3947 3951
3948 /* 3952 /*
3949 * The first inode we look at is the journal inode. Don't try 3953 * The first inode we look at is the journal inode. Don't try
@@ -3952,7 +3956,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3952 if (!test_opt(sb, NOLOAD) && 3956 if (!test_opt(sb, NOLOAD) &&
3953 EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) { 3957 EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) {
3954 if (ext4_load_journal(sb, es, journal_devnum)) 3958 if (ext4_load_journal(sb, es, journal_devnum))
3955 goto failed_mount3; 3959 goto failed_mount3a;
3956 } else if (test_opt(sb, NOLOAD) && !(sb->s_flags & MS_RDONLY) && 3960 } else if (test_opt(sb, NOLOAD) && !(sb->s_flags & MS_RDONLY) &&
3957 EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) { 3961 EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) {
3958 ext4_msg(sb, KERN_ERR, "required journal recovery " 3962 ext4_msg(sb, KERN_ERR, "required journal recovery "
@@ -4240,6 +4244,7 @@ failed_mount_wq:
4240 jbd2_journal_destroy(sbi->s_journal); 4244 jbd2_journal_destroy(sbi->s_journal);
4241 sbi->s_journal = NULL; 4245 sbi->s_journal = NULL;
4242 } 4246 }
4247failed_mount3a:
4243 ext4_es_unregister_shrinker(sbi); 4248 ext4_es_unregister_shrinker(sbi);
4244failed_mount3: 4249failed_mount3:
4245 del_timer_sync(&sbi->s_err_report); 4250 del_timer_sync(&sbi->s_err_report);
@@ -4841,6 +4846,14 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
4841 goto restore_opts; 4846 goto restore_opts;
4842 } 4847 }
4843 4848
4849 if ((old_opts.s_mount_opt & EXT4_MOUNT_JOURNAL_CHECKSUM) ^
4850 test_opt(sb, JOURNAL_CHECKSUM)) {
4851 ext4_msg(sb, KERN_ERR, "changing journal_checksum "
4852 "during remount not supported");
4853 err = -EINVAL;
4854 goto restore_opts;
4855 }
4856
4844 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) { 4857 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) {
4845 if (test_opt2(sb, EXPLICIT_DELALLOC)) { 4858 if (test_opt2(sb, EXPLICIT_DELALLOC)) {
4846 ext4_msg(sb, KERN_ERR, "can't mount with " 4859 ext4_msg(sb, KERN_ERR, "can't mount with "
diff --git a/fs/fat/dir.c b/fs/fat/dir.c
index 3963ede84eb0..c5d6bb939d19 100644
--- a/fs/fat/dir.c
+++ b/fs/fat/dir.c
@@ -702,10 +702,11 @@ static int fat_readdir(struct file *file, struct dir_context *ctx)
702} 702}
703 703
704#define FAT_IOCTL_FILLDIR_FUNC(func, dirent_type) \ 704#define FAT_IOCTL_FILLDIR_FUNC(func, dirent_type) \
705static int func(void *__buf, const char *name, int name_len, \ 705static int func(struct dir_context *ctx, const char *name, int name_len, \
706 loff_t offset, u64 ino, unsigned int d_type) \ 706 loff_t offset, u64 ino, unsigned int d_type) \
707{ \ 707{ \
708 struct fat_ioctl_filldir_callback *buf = __buf; \ 708 struct fat_ioctl_filldir_callback *buf = \
709 container_of(ctx, struct fat_ioctl_filldir_callback, ctx); \
709 struct dirent_type __user *d1 = buf->dirent; \ 710 struct dirent_type __user *d1 = buf->dirent; \
710 struct dirent_type __user *d2 = d1 + 1; \ 711 struct dirent_type __user *d2 = d1 + 1; \
711 \ 712 \
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index dbab798f5caf..df562cc87763 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -372,7 +372,7 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
372 if (inode && get_node_id(inode) == FUSE_ROOT_ID) 372 if (inode && get_node_id(inode) == FUSE_ROOT_ID)
373 goto out_iput; 373 goto out_iput;
374 374
375 newent = d_materialise_unique(entry, inode); 375 newent = d_splice_alias(inode, entry);
376 err = PTR_ERR(newent); 376 err = PTR_ERR(newent);
377 if (IS_ERR(newent)) 377 if (IS_ERR(newent))
378 goto out_err; 378 goto out_err;
@@ -1320,7 +1320,7 @@ static int fuse_direntplus_link(struct file *file,
1320 if (!inode) 1320 if (!inode)
1321 goto out; 1321 goto out;
1322 1322
1323 alias = d_materialise_unique(dentry, inode); 1323 alias = d_splice_alias(inode, dentry);
1324 err = PTR_ERR(alias); 1324 err = PTR_ERR(alias);
1325 if (IS_ERR(alias)) 1325 if (IS_ERR(alias))
1326 goto out; 1326 goto out;
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index caa8d95b24e8..bf50259012ab 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1988,7 +1988,7 @@ static int fuse_write_begin(struct file *file, struct address_space *mapping,
1988 struct page **pagep, void **fsdata) 1988 struct page **pagep, void **fsdata)
1989{ 1989{
1990 pgoff_t index = pos >> PAGE_CACHE_SHIFT; 1990 pgoff_t index = pos >> PAGE_CACHE_SHIFT;
1991 struct fuse_conn *fc = get_fuse_conn(file->f_dentry->d_inode); 1991 struct fuse_conn *fc = get_fuse_conn(file_inode(file));
1992 struct page *page; 1992 struct page *page;
1993 loff_t fsize; 1993 loff_t fsize;
1994 int err = -ENOMEM; 1994 int err = -ENOMEM;
diff --git a/fs/gfs2/export.c b/fs/gfs2/export.c
index 8b9b3775e2e7..c41d255b6a7b 100644
--- a/fs/gfs2/export.c
+++ b/fs/gfs2/export.c
@@ -69,10 +69,12 @@ struct get_name_filldir {
69 char *name; 69 char *name;
70}; 70};
71 71
72static int get_name_filldir(void *opaque, const char *name, int length, 72static int get_name_filldir(struct dir_context *ctx, const char *name,
73 loff_t offset, u64 inum, unsigned int type) 73 int length, loff_t offset, u64 inum,
74 unsigned int type)
74{ 75{
75 struct get_name_filldir *gnfd = opaque; 76 struct get_name_filldir *gnfd =
77 container_of(ctx, struct get_name_filldir, ctx);
76 78
77 if (inum != gnfd->inum.no_addr) 79 if (inum != gnfd->inum.no_addr)
78 return 0; 80 return 0;
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index c4ed823d150e..6e2917433170 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -596,7 +596,6 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
596 struct gfs2_inode *dip = GFS2_I(dir), *ip; 596 struct gfs2_inode *dip = GFS2_I(dir), *ip;
597 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); 597 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
598 struct gfs2_glock *io_gl; 598 struct gfs2_glock *io_gl;
599 struct dentry *d;
600 int error, free_vfs_inode = 0; 599 int error, free_vfs_inode = 0;
601 u32 aflags = 0; 600 u32 aflags = 0;
602 unsigned blocks = 1; 601 unsigned blocks = 1;
@@ -624,22 +623,18 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
624 inode = gfs2_dir_search(dir, &dentry->d_name, !S_ISREG(mode) || excl); 623 inode = gfs2_dir_search(dir, &dentry->d_name, !S_ISREG(mode) || excl);
625 error = PTR_ERR(inode); 624 error = PTR_ERR(inode);
626 if (!IS_ERR(inode)) { 625 if (!IS_ERR(inode)) {
627 d = d_splice_alias(inode, dentry); 626 if (S_ISDIR(inode->i_mode)) {
628 error = PTR_ERR(d); 627 iput(inode);
629 if (IS_ERR(d)) { 628 inode = ERR_PTR(-EISDIR);
630 inode = ERR_CAST(d);
631 goto fail_gunlock; 629 goto fail_gunlock;
632 } 630 }
631 d_instantiate(dentry, inode);
633 error = 0; 632 error = 0;
634 if (file) { 633 if (file) {
635 if (S_ISREG(inode->i_mode)) { 634 if (S_ISREG(inode->i_mode))
636 WARN_ON(d != NULL);
637 error = finish_open(file, dentry, gfs2_open_common, opened); 635 error = finish_open(file, dentry, gfs2_open_common, opened);
638 } else { 636 else
639 error = finish_no_open(file, d); 637 error = finish_no_open(file, NULL);
640 }
641 } else {
642 dput(d);
643 } 638 }
644 gfs2_glock_dq_uninit(ghs); 639 gfs2_glock_dq_uninit(ghs);
645 return error; 640 return error;
@@ -1254,11 +1249,8 @@ static int gfs2_atomic_open(struct inode *dir, struct dentry *dentry,
1254 if (d != NULL) 1249 if (d != NULL)
1255 dentry = d; 1250 dentry = d;
1256 if (dentry->d_inode) { 1251 if (dentry->d_inode) {
1257 if (!(*opened & FILE_OPENED)) { 1252 if (!(*opened & FILE_OPENED))
1258 if (d == NULL) 1253 return finish_no_open(file, d);
1259 dget(dentry);
1260 return finish_no_open(file, dentry);
1261 }
1262 dput(d); 1254 dput(d);
1263 return 0; 1255 return 0;
1264 } 1256 }
diff --git a/fs/hppfs/hppfs.c b/fs/hppfs/hppfs.c
index 4338ff32959d..5f2755117ce7 100644
--- a/fs/hppfs/hppfs.c
+++ b/fs/hppfs/hppfs.c
@@ -548,10 +548,11 @@ struct hppfs_dirent {
548 struct dentry *dentry; 548 struct dentry *dentry;
549}; 549};
550 550
551static int hppfs_filldir(void *d, const char *name, int size, 551static int hppfs_filldir(struct dir_context *ctx, const char *name, int size,
552 loff_t offset, u64 inode, unsigned int type) 552 loff_t offset, u64 inode, unsigned int type)
553{ 553{
554 struct hppfs_dirent *dirent = d; 554 struct hppfs_dirent *dirent =
555 container_of(ctx, struct hppfs_dirent, ctx);
555 556
556 if (file_removed(dirent->dentry, name)) 557 if (file_removed(dirent->dentry, name))
557 return 0; 558 return 0;
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index 881b3bd0143f..d67a16f2a45d 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -29,13 +29,9 @@
29#define BEQUIET 29#define BEQUIET
30 30
31static int isofs_hashi(const struct dentry *parent, struct qstr *qstr); 31static int isofs_hashi(const struct dentry *parent, struct qstr *qstr);
32static int isofs_hash(const struct dentry *parent, struct qstr *qstr);
33static int isofs_dentry_cmpi(const struct dentry *parent, 32static int isofs_dentry_cmpi(const struct dentry *parent,
34 const struct dentry *dentry, 33 const struct dentry *dentry,
35 unsigned int len, const char *str, const struct qstr *name); 34 unsigned int len, const char *str, const struct qstr *name);
36static int isofs_dentry_cmp(const struct dentry *parent,
37 const struct dentry *dentry,
38 unsigned int len, const char *str, const struct qstr *name);
39 35
40#ifdef CONFIG_JOLIET 36#ifdef CONFIG_JOLIET
41static int isofs_hashi_ms(const struct dentry *parent, struct qstr *qstr); 37static int isofs_hashi_ms(const struct dentry *parent, struct qstr *qstr);
@@ -135,10 +131,6 @@ static const struct super_operations isofs_sops = {
135 131
136static const struct dentry_operations isofs_dentry_ops[] = { 132static const struct dentry_operations isofs_dentry_ops[] = {
137 { 133 {
138 .d_hash = isofs_hash,
139 .d_compare = isofs_dentry_cmp,
140 },
141 {
142 .d_hash = isofs_hashi, 134 .d_hash = isofs_hashi,
143 .d_compare = isofs_dentry_cmpi, 135 .d_compare = isofs_dentry_cmpi,
144 }, 136 },
@@ -182,27 +174,6 @@ struct iso9660_options{
182 * Compute the hash for the isofs name corresponding to the dentry. 174 * Compute the hash for the isofs name corresponding to the dentry.
183 */ 175 */
184static int 176static int
185isofs_hash_common(struct qstr *qstr, int ms)
186{
187 const char *name;
188 int len;
189
190 len = qstr->len;
191 name = qstr->name;
192 if (ms) {
193 while (len && name[len-1] == '.')
194 len--;
195 }
196
197 qstr->hash = full_name_hash(name, len);
198
199 return 0;
200}
201
202/*
203 * Compute the hash for the isofs name corresponding to the dentry.
204 */
205static int
206isofs_hashi_common(struct qstr *qstr, int ms) 177isofs_hashi_common(struct qstr *qstr, int ms)
207{ 178{
208 const char *name; 179 const char *name;
@@ -258,32 +229,40 @@ static int isofs_dentry_cmp_common(
258} 229}
259 230
260static int 231static int
261isofs_hash(const struct dentry *dentry, struct qstr *qstr)
262{
263 return isofs_hash_common(qstr, 0);
264}
265
266static int
267isofs_hashi(const struct dentry *dentry, struct qstr *qstr) 232isofs_hashi(const struct dentry *dentry, struct qstr *qstr)
268{ 233{
269 return isofs_hashi_common(qstr, 0); 234 return isofs_hashi_common(qstr, 0);
270} 235}
271 236
272static int 237static int
273isofs_dentry_cmp(const struct dentry *parent, const struct dentry *dentry, 238isofs_dentry_cmpi(const struct dentry *parent, const struct dentry *dentry,
274 unsigned int len, const char *str, const struct qstr *name) 239 unsigned int len, const char *str, const struct qstr *name)
275{ 240{
276 return isofs_dentry_cmp_common(len, str, name, 0, 0); 241 return isofs_dentry_cmp_common(len, str, name, 0, 1);
277} 242}
278 243
244#ifdef CONFIG_JOLIET
245/*
246 * Compute the hash for the isofs name corresponding to the dentry.
247 */
279static int 248static int
280isofs_dentry_cmpi(const struct dentry *parent, const struct dentry *dentry, 249isofs_hash_common(struct qstr *qstr, int ms)
281 unsigned int len, const char *str, const struct qstr *name)
282{ 250{
283 return isofs_dentry_cmp_common(len, str, name, 0, 1); 251 const char *name;
252 int len;
253
254 len = qstr->len;
255 name = qstr->name;
256 if (ms) {
257 while (len && name[len-1] == '.')
258 len--;
259 }
260
261 qstr->hash = full_name_hash(name, len);
262
263 return 0;
284} 264}
285 265
286#ifdef CONFIG_JOLIET
287static int 266static int
288isofs_hash_ms(const struct dentry *dentry, struct qstr *qstr) 267isofs_hash_ms(const struct dentry *dentry, struct qstr *qstr)
289{ 268{
@@ -930,7 +909,8 @@ root_found:
930 if (opt.check == 'r') 909 if (opt.check == 'r')
931 table++; 910 table++;
932 911
933 s->s_d_op = &isofs_dentry_ops[table]; 912 if (table)
913 s->s_d_op = &isofs_dentry_ops[table - 1];
934 914
935 /* get the root dentry */ 915 /* get the root dentry */
936 s->s_root = d_make_root(inode); 916 s->s_root = d_make_root(inode);
diff --git a/fs/isofs/namei.c b/fs/isofs/namei.c
index 95295640d9c8..7b543e6b6526 100644
--- a/fs/isofs/namei.c
+++ b/fs/isofs/namei.c
@@ -18,25 +18,10 @@ static int
18isofs_cmp(struct dentry *dentry, const char *compare, int dlen) 18isofs_cmp(struct dentry *dentry, const char *compare, int dlen)
19{ 19{
20 struct qstr qstr; 20 struct qstr qstr;
21
22 if (!compare)
23 return 1;
24
25 /* check special "." and ".." files */
26 if (dlen == 1) {
27 /* "." */
28 if (compare[0] == 0) {
29 if (!dentry->d_name.len)
30 return 0;
31 compare = ".";
32 } else if (compare[0] == 1) {
33 compare = "..";
34 dlen = 2;
35 }
36 }
37
38 qstr.name = compare; 21 qstr.name = compare;
39 qstr.len = dlen; 22 qstr.len = dlen;
23 if (likely(!dentry->d_op))
24 return dentry->d_name.len != dlen || memcmp(dentry->d_name.name, compare, dlen);
40 return dentry->d_op->d_compare(NULL, NULL, dentry->d_name.len, dentry->d_name.name, &qstr); 25 return dentry->d_op->d_compare(NULL, NULL, dentry->d_name.len, dentry->d_name.name, &qstr);
41} 26}
42 27
@@ -146,7 +131,8 @@ isofs_find_entry(struct inode *dir, struct dentry *dentry,
146 (!(de->flags[-sbi->s_high_sierra] & 1))) && 131 (!(de->flags[-sbi->s_high_sierra] & 1))) &&
147 (sbi->s_showassoc || 132 (sbi->s_showassoc ||
148 (!(de->flags[-sbi->s_high_sierra] & 4)))) { 133 (!(de->flags[-sbi->s_high_sierra] & 4)))) {
149 match = (isofs_cmp(dentry, dpnt, dlen) == 0); 134 if (dpnt && (dlen > 1 || dpnt[0] > 1))
135 match = (isofs_cmp(dentry, dpnt, dlen) == 0);
150 } 136 }
151 if (match) { 137 if (match) {
152 isofs_normalize_block_and_offset(de, 138 isofs_normalize_block_and_offset(de,
diff --git a/fs/jbd/revoke.c b/fs/jbd/revoke.c
index 8898bbd2b61e..dcead636c33b 100644
--- a/fs/jbd/revoke.c
+++ b/fs/jbd/revoke.c
@@ -93,6 +93,7 @@
93#include <linux/bio.h> 93#include <linux/bio.h>
94#endif 94#endif
95#include <linux/log2.h> 95#include <linux/log2.h>
96#include <linux/hash.h>
96 97
97static struct kmem_cache *revoke_record_cache; 98static struct kmem_cache *revoke_record_cache;
98static struct kmem_cache *revoke_table_cache; 99static struct kmem_cache *revoke_table_cache;
@@ -129,15 +130,11 @@ static void flush_descriptor(journal_t *, struct journal_head *, int, int);
129 130
130/* Utility functions to maintain the revoke table */ 131/* Utility functions to maintain the revoke table */
131 132
132/* Borrowed from buffer.c: this is a tried and tested block hash function */
133static inline int hash(journal_t *journal, unsigned int block) 133static inline int hash(journal_t *journal, unsigned int block)
134{ 134{
135 struct jbd_revoke_table_s *table = journal->j_revoke; 135 struct jbd_revoke_table_s *table = journal->j_revoke;
136 int hash_shift = table->hash_shift;
137 136
138 return ((block << (hash_shift - 6)) ^ 137 return hash_32(block, table->hash_shift);
139 (block >> 13) ^
140 (block << (hash_shift - 12))) & (table->hash_size - 1);
141} 138}
142 139
143static int insert_revoke_hash(journal_t *journal, unsigned int blocknr, 140static int insert_revoke_hash(journal_t *journal, unsigned int blocknr,
diff --git a/fs/jbd2/revoke.c b/fs/jbd2/revoke.c
index d5e95a175c92..c6cbaef2bda1 100644
--- a/fs/jbd2/revoke.c
+++ b/fs/jbd2/revoke.c
@@ -92,6 +92,7 @@
92#include <linux/init.h> 92#include <linux/init.h>
93#include <linux/bio.h> 93#include <linux/bio.h>
94#include <linux/log2.h> 94#include <linux/log2.h>
95#include <linux/hash.h>
95#endif 96#endif
96 97
97static struct kmem_cache *jbd2_revoke_record_cache; 98static struct kmem_cache *jbd2_revoke_record_cache;
@@ -130,16 +131,9 @@ static void flush_descriptor(journal_t *, struct buffer_head *, int, int);
130 131
131/* Utility functions to maintain the revoke table */ 132/* Utility functions to maintain the revoke table */
132 133
133/* Borrowed from buffer.c: this is a tried and tested block hash function */
134static inline int hash(journal_t *journal, unsigned long long block) 134static inline int hash(journal_t *journal, unsigned long long block)
135{ 135{
136 struct jbd2_revoke_table_s *table = journal->j_revoke; 136 return hash_64(block, journal->j_revoke->hash_shift);
137 int hash_shift = table->hash_shift;
138 int hash = (int)block ^ (int)((block >> 31) >> 1);
139
140 return ((hash << (hash_shift - 6)) ^
141 (hash >> 13) ^
142 (hash << (hash_shift - 12))) & (table->hash_size - 1);
143} 137}
144 138
145static int insert_revoke_hash(journal_t *journal, unsigned long long blocknr, 139static int insert_revoke_hash(journal_t *journal, unsigned long long blocknr,
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
index d59c7defb1ef..38fdc533f4ec 100644
--- a/fs/jfs/namei.c
+++ b/fs/jfs/namei.c
@@ -84,7 +84,7 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, umode_t mode,
84 struct inode *iplist[2]; 84 struct inode *iplist[2];
85 struct tblock *tblk; 85 struct tblock *tblk;
86 86
87 jfs_info("jfs_create: dip:0x%p name:%s", dip, dentry->d_name.name); 87 jfs_info("jfs_create: dip:0x%p name:%pd", dip, dentry);
88 88
89 dquot_initialize(dip); 89 dquot_initialize(dip);
90 90
@@ -216,7 +216,7 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, umode_t mode)
216 struct inode *iplist[2]; 216 struct inode *iplist[2];
217 struct tblock *tblk; 217 struct tblock *tblk;
218 218
219 jfs_info("jfs_mkdir: dip:0x%p name:%s", dip, dentry->d_name.name); 219 jfs_info("jfs_mkdir: dip:0x%p name:%pd", dip, dentry);
220 220
221 dquot_initialize(dip); 221 dquot_initialize(dip);
222 222
@@ -352,7 +352,7 @@ static int jfs_rmdir(struct inode *dip, struct dentry *dentry)
352 struct inode *iplist[2]; 352 struct inode *iplist[2];
353 struct tblock *tblk; 353 struct tblock *tblk;
354 354
355 jfs_info("jfs_rmdir: dip:0x%p name:%s", dip, dentry->d_name.name); 355 jfs_info("jfs_rmdir: dip:0x%p name:%pd", dip, dentry);
356 356
357 /* Init inode for quota operations. */ 357 /* Init inode for quota operations. */
358 dquot_initialize(dip); 358 dquot_initialize(dip);
@@ -480,7 +480,7 @@ static int jfs_unlink(struct inode *dip, struct dentry *dentry)
480 s64 new_size = 0; 480 s64 new_size = 0;
481 int commit_flag; 481 int commit_flag;
482 482
483 jfs_info("jfs_unlink: dip:0x%p name:%s", dip, dentry->d_name.name); 483 jfs_info("jfs_unlink: dip:0x%p name:%pd", dip, dentry);
484 484
485 /* Init inode for quota operations. */ 485 /* Init inode for quota operations. */
486 dquot_initialize(dip); 486 dquot_initialize(dip);
@@ -797,8 +797,7 @@ static int jfs_link(struct dentry *old_dentry,
797 struct btstack btstack; 797 struct btstack btstack;
798 struct inode *iplist[2]; 798 struct inode *iplist[2];
799 799
800 jfs_info("jfs_link: %s %s", old_dentry->d_name.name, 800 jfs_info("jfs_link: %pd %pd", old_dentry, dentry);
801 dentry->d_name.name);
802 801
803 dquot_initialize(dir); 802 dquot_initialize(dir);
804 803
@@ -1082,8 +1081,7 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1082 int commit_flag; 1081 int commit_flag;
1083 1082
1084 1083
1085 jfs_info("jfs_rename: %s %s", old_dentry->d_name.name, 1084 jfs_info("jfs_rename: %pd %pd", old_dentry, new_dentry);
1086 new_dentry->d_name.name);
1087 1085
1088 dquot_initialize(old_dir); 1086 dquot_initialize(old_dir);
1089 dquot_initialize(new_dir); 1087 dquot_initialize(new_dir);
@@ -1355,7 +1353,7 @@ static int jfs_mknod(struct inode *dir, struct dentry *dentry,
1355 if (!new_valid_dev(rdev)) 1353 if (!new_valid_dev(rdev))
1356 return -EINVAL; 1354 return -EINVAL;
1357 1355
1358 jfs_info("jfs_mknod: %s", dentry->d_name.name); 1356 jfs_info("jfs_mknod: %pd", dentry);
1359 1357
1360 dquot_initialize(dir); 1358 dquot_initialize(dir);
1361 1359
@@ -1444,7 +1442,7 @@ static struct dentry *jfs_lookup(struct inode *dip, struct dentry *dentry, unsig
1444 struct component_name key; 1442 struct component_name key;
1445 int rc; 1443 int rc;
1446 1444
1447 jfs_info("jfs_lookup: name = %s", dentry->d_name.name); 1445 jfs_info("jfs_lookup: name = %pd", dentry);
1448 1446
1449 if ((rc = get_UCSname(&key, dentry))) 1447 if ((rc = get_UCSname(&key, dentry)))
1450 return ERR_PTR(rc); 1448 return ERR_PTR(rc);
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index 1c771931bb60..37989f02a226 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -807,7 +807,7 @@ static struct dentry *kernfs_iop_lookup(struct inode *dir,
807 } 807 }
808 808
809 /* instantiate and hash dentry */ 809 /* instantiate and hash dentry */
810 ret = d_materialise_unique(dentry, inode); 810 ret = d_splice_alias(inode, dentry);
811 out_unlock: 811 out_unlock:
812 mutex_unlock(&kernfs_mutex); 812 mutex_unlock(&kernfs_mutex);
813 return ret; 813 return ret;
diff --git a/fs/libfs.c b/fs/libfs.c
index 171d2846f2a3..005843ce5dbd 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -114,18 +114,18 @@ loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence)
114 114
115 spin_lock(&dentry->d_lock); 115 spin_lock(&dentry->d_lock);
116 /* d_lock not required for cursor */ 116 /* d_lock not required for cursor */
117 list_del(&cursor->d_u.d_child); 117 list_del(&cursor->d_child);
118 p = dentry->d_subdirs.next; 118 p = dentry->d_subdirs.next;
119 while (n && p != &dentry->d_subdirs) { 119 while (n && p != &dentry->d_subdirs) {
120 struct dentry *next; 120 struct dentry *next;
121 next = list_entry(p, struct dentry, d_u.d_child); 121 next = list_entry(p, struct dentry, d_child);
122 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED); 122 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
123 if (simple_positive(next)) 123 if (simple_positive(next))
124 n--; 124 n--;
125 spin_unlock(&next->d_lock); 125 spin_unlock(&next->d_lock);
126 p = p->next; 126 p = p->next;
127 } 127 }
128 list_add_tail(&cursor->d_u.d_child, p); 128 list_add_tail(&cursor->d_child, p);
129 spin_unlock(&dentry->d_lock); 129 spin_unlock(&dentry->d_lock);
130 } 130 }
131 } 131 }
@@ -150,7 +150,7 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
150{ 150{
151 struct dentry *dentry = file->f_path.dentry; 151 struct dentry *dentry = file->f_path.dentry;
152 struct dentry *cursor = file->private_data; 152 struct dentry *cursor = file->private_data;
153 struct list_head *p, *q = &cursor->d_u.d_child; 153 struct list_head *p, *q = &cursor->d_child;
154 154
155 if (!dir_emit_dots(file, ctx)) 155 if (!dir_emit_dots(file, ctx))
156 return 0; 156 return 0;
@@ -159,7 +159,7 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
159 list_move(q, &dentry->d_subdirs); 159 list_move(q, &dentry->d_subdirs);
160 160
161 for (p = q->next; p != &dentry->d_subdirs; p = p->next) { 161 for (p = q->next; p != &dentry->d_subdirs; p = p->next) {
162 struct dentry *next = list_entry(p, struct dentry, d_u.d_child); 162 struct dentry *next = list_entry(p, struct dentry, d_child);
163 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED); 163 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
164 if (!simple_positive(next)) { 164 if (!simple_positive(next)) {
165 spin_unlock(&next->d_lock); 165 spin_unlock(&next->d_lock);
@@ -287,7 +287,7 @@ int simple_empty(struct dentry *dentry)
287 int ret = 0; 287 int ret = 0;
288 288
289 spin_lock(&dentry->d_lock); 289 spin_lock(&dentry->d_lock);
290 list_for_each_entry(child, &dentry->d_subdirs, d_u.d_child) { 290 list_for_each_entry(child, &dentry->d_subdirs, d_child) {
291 spin_lock_nested(&child->d_lock, DENTRY_D_LOCK_NESTED); 291 spin_lock_nested(&child->d_lock, DENTRY_D_LOCK_NESTED);
292 if (simple_positive(child)) { 292 if (simple_positive(child)) {
293 spin_unlock(&child->d_lock); 293 spin_unlock(&child->d_lock);
diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c
index b6f3b84b6e99..d12ff4e2dbe7 100644
--- a/fs/lockd/svcsubs.c
+++ b/fs/lockd/svcsubs.c
@@ -408,7 +408,7 @@ nlmsvc_match_sb(void *datap, struct nlm_file *file)
408{ 408{
409 struct super_block *sb = datap; 409 struct super_block *sb = datap;
410 410
411 return sb == file->f_file->f_path.dentry->d_sb; 411 return sb == file_inode(file->f_file)->i_sb;
412} 412}
413 413
414/** 414/**
diff --git a/fs/namei.c b/fs/namei.c
index 42df664e95e5..db5fe86319e6 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2497,7 +2497,7 @@ struct dentry *lock_rename(struct dentry *p1, struct dentry *p2)
2497 } 2497 }
2498 2498
2499 mutex_lock_nested(&p1->d_inode->i_mutex, I_MUTEX_PARENT); 2499 mutex_lock_nested(&p1->d_inode->i_mutex, I_MUTEX_PARENT);
2500 mutex_lock_nested(&p2->d_inode->i_mutex, I_MUTEX_CHILD); 2500 mutex_lock_nested(&p2->d_inode->i_mutex, I_MUTEX_PARENT2);
2501 return NULL; 2501 return NULL;
2502} 2502}
2503EXPORT_SYMBOL(lock_rename); 2503EXPORT_SYMBOL(lock_rename);
@@ -3154,7 +3154,8 @@ static int do_tmpfile(int dfd, struct filename *pathname,
3154 if (error) 3154 if (error)
3155 goto out2; 3155 goto out2;
3156 audit_inode(pathname, nd->path.dentry, 0); 3156 audit_inode(pathname, nd->path.dentry, 0);
3157 error = may_open(&nd->path, op->acc_mode, op->open_flag); 3157 /* Don't check for other permissions, the inode was just created */
3158 error = may_open(&nd->path, MAY_OPEN, op->open_flag);
3158 if (error) 3159 if (error)
3159 goto out2; 3160 goto out2;
3160 file->f_path.mnt = nd->path.mnt; 3161 file->f_path.mnt = nd->path.mnt;
diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c
index 7cb751dfbeef..008960101520 100644
--- a/fs/ncpfs/dir.c
+++ b/fs/ncpfs/dir.c
@@ -198,8 +198,8 @@ ncp_single_volume(struct ncp_server *server)
198 198
199static inline int ncp_is_server_root(struct inode *inode) 199static inline int ncp_is_server_root(struct inode *inode)
200{ 200{
201 return (!ncp_single_volume(NCP_SERVER(inode)) && 201 return !ncp_single_volume(NCP_SERVER(inode)) &&
202 inode == inode->i_sb->s_root->d_inode); 202 is_root_inode(inode);
203} 203}
204 204
205 205
@@ -403,7 +403,7 @@ ncp_dget_fpos(struct dentry *dentry, struct dentry *parent, unsigned long fpos)
403 403
404 /* If a pointer is invalid, we search the dentry. */ 404 /* If a pointer is invalid, we search the dentry. */
405 spin_lock(&parent->d_lock); 405 spin_lock(&parent->d_lock);
406 list_for_each_entry(dent, &parent->d_subdirs, d_u.d_child) { 406 list_for_each_entry(dent, &parent->d_subdirs, d_child) {
407 if ((unsigned long)dent->d_fsdata == fpos) { 407 if ((unsigned long)dent->d_fsdata == fpos) {
408 if (dent->d_inode) 408 if (dent->d_inode)
409 dget(dent); 409 dget(dent);
@@ -685,8 +685,7 @@ static void
685ncp_read_volume_list(struct file *file, struct dir_context *ctx, 685ncp_read_volume_list(struct file *file, struct dir_context *ctx,
686 struct ncp_cache_control *ctl) 686 struct ncp_cache_control *ctl)
687{ 687{
688 struct dentry *dentry = file->f_path.dentry; 688 struct inode *inode = file_inode(file);
689 struct inode *inode = dentry->d_inode;
690 struct ncp_server *server = NCP_SERVER(inode); 689 struct ncp_server *server = NCP_SERVER(inode);
691 struct ncp_volume_info info; 690 struct ncp_volume_info info;
692 struct ncp_entry_info entry; 691 struct ncp_entry_info entry;
@@ -721,8 +720,7 @@ static void
721ncp_do_readdir(struct file *file, struct dir_context *ctx, 720ncp_do_readdir(struct file *file, struct dir_context *ctx,
722 struct ncp_cache_control *ctl) 721 struct ncp_cache_control *ctl)
723{ 722{
724 struct dentry *dentry = file->f_path.dentry; 723 struct inode *dir = file_inode(file);
725 struct inode *dir = dentry->d_inode;
726 struct ncp_server *server = NCP_SERVER(dir); 724 struct ncp_server *server = NCP_SERVER(dir);
727 struct nw_search_sequence seq; 725 struct nw_search_sequence seq;
728 struct ncp_entry_info entry; 726 struct ncp_entry_info entry;
diff --git a/fs/ncpfs/file.c b/fs/ncpfs/file.c
index 77640a8bfb87..1dd7007f974d 100644
--- a/fs/ncpfs/file.c
+++ b/fs/ncpfs/file.c
@@ -100,8 +100,7 @@ out:
100static ssize_t 100static ssize_t
101ncp_file_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) 101ncp_file_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
102{ 102{
103 struct dentry *dentry = file->f_path.dentry; 103 struct inode *inode = file_inode(file);
104 struct inode *inode = dentry->d_inode;
105 size_t already_read = 0; 104 size_t already_read = 0;
106 off_t pos; 105 off_t pos;
107 size_t bufsize; 106 size_t bufsize;
@@ -109,7 +108,7 @@ ncp_file_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
109 void* freepage; 108 void* freepage;
110 size_t freelen; 109 size_t freelen;
111 110
112 ncp_dbg(1, "enter %pd2\n", dentry); 111 ncp_dbg(1, "enter %pD2\n", file);
113 112
114 pos = *ppos; 113 pos = *ppos;
115 114
@@ -167,7 +166,7 @@ ncp_file_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
167 166
168 file_accessed(file); 167 file_accessed(file);
169 168
170 ncp_dbg(1, "exit %pd2\n", dentry); 169 ncp_dbg(1, "exit %pD2\n", file);
171outrel: 170outrel:
172 ncp_inode_close(inode); 171 ncp_inode_close(inode);
173 return already_read ? already_read : error; 172 return already_read ? already_read : error;
@@ -176,15 +175,14 @@ outrel:
176static ssize_t 175static ssize_t
177ncp_file_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) 176ncp_file_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
178{ 177{
179 struct dentry *dentry = file->f_path.dentry; 178 struct inode *inode = file_inode(file);
180 struct inode *inode = dentry->d_inode;
181 size_t already_written = 0; 179 size_t already_written = 0;
182 off_t pos; 180 off_t pos;
183 size_t bufsize; 181 size_t bufsize;
184 int errno; 182 int errno;
185 void* bouncebuffer; 183 void* bouncebuffer;
186 184
187 ncp_dbg(1, "enter %pd2\n", dentry); 185 ncp_dbg(1, "enter %pD2\n", file);
188 if ((ssize_t) count < 0) 186 if ((ssize_t) count < 0)
189 return -EINVAL; 187 return -EINVAL;
190 pos = *ppos; 188 pos = *ppos;
@@ -263,7 +261,7 @@ ncp_file_write(struct file *file, const char __user *buf, size_t count, loff_t *
263 i_size_write(inode, pos); 261 i_size_write(inode, pos);
264 mutex_unlock(&inode->i_mutex); 262 mutex_unlock(&inode->i_mutex);
265 } 263 }
266 ncp_dbg(1, "exit %pd2\n", dentry); 264 ncp_dbg(1, "exit %pD2\n", file);
267outrel: 265outrel:
268 ncp_inode_close(inode); 266 ncp_inode_close(inode);
269 return already_written ? already_written : errno; 267 return already_written ? already_written : errno;
diff --git a/fs/ncpfs/mmap.c b/fs/ncpfs/mmap.c
index b359d12eb359..33b873b259a8 100644
--- a/fs/ncpfs/mmap.c
+++ b/fs/ncpfs/mmap.c
@@ -30,9 +30,7 @@
30static int ncp_file_mmap_fault(struct vm_area_struct *area, 30static int ncp_file_mmap_fault(struct vm_area_struct *area,
31 struct vm_fault *vmf) 31 struct vm_fault *vmf)
32{ 32{
33 struct file *file = area->vm_file; 33 struct inode *inode = file_inode(area->vm_file);
34 struct dentry *dentry = file->f_path.dentry;
35 struct inode *inode = dentry->d_inode;
36 char *pg_addr; 34 char *pg_addr;
37 unsigned int already_read; 35 unsigned int already_read;
38 unsigned int count; 36 unsigned int count;
diff --git a/fs/ncpfs/ncplib_kernel.h b/fs/ncpfs/ncplib_kernel.h
index 52cb19d66ecb..b785f74bfe3c 100644
--- a/fs/ncpfs/ncplib_kernel.h
+++ b/fs/ncpfs/ncplib_kernel.h
@@ -191,7 +191,7 @@ ncp_renew_dentries(struct dentry *parent)
191 struct dentry *dentry; 191 struct dentry *dentry;
192 192
193 spin_lock(&parent->d_lock); 193 spin_lock(&parent->d_lock);
194 list_for_each_entry(dentry, &parent->d_subdirs, d_u.d_child) { 194 list_for_each_entry(dentry, &parent->d_subdirs, d_child) {
195 if (dentry->d_fsdata == NULL) 195 if (dentry->d_fsdata == NULL)
196 ncp_age_dentry(server, dentry); 196 ncp_age_dentry(server, dentry);
197 else 197 else
@@ -207,7 +207,7 @@ ncp_invalidate_dircache_entries(struct dentry *parent)
207 struct dentry *dentry; 207 struct dentry *dentry;
208 208
209 spin_lock(&parent->d_lock); 209 spin_lock(&parent->d_lock);
210 list_for_each_entry(dentry, &parent->d_subdirs, d_u.d_child) { 210 list_for_each_entry(dentry, &parent->d_subdirs, d_child) {
211 dentry->d_fsdata = NULL; 211 dentry->d_fsdata = NULL;
212 ncp_age_dentry(server, dentry); 212 ncp_age_dentry(server, dentry);
213 } 213 }
diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c
index 5228f201d3d5..4f46f7a05289 100644
--- a/fs/nfs/blocklayout/blocklayout.c
+++ b/fs/nfs/blocklayout/blocklayout.c
@@ -378,7 +378,7 @@ bl_write_pagelist(struct nfs_pgio_header *header, int sync)
378 loff_t offset = header->args.offset; 378 loff_t offset = header->args.offset;
379 size_t count = header->args.count; 379 size_t count = header->args.count;
380 struct page **pages = header->args.pages; 380 struct page **pages = header->args.pages;
381 int pg_index = pg_index = header->args.pgbase >> PAGE_CACHE_SHIFT; 381 int pg_index = header->args.pgbase >> PAGE_CACHE_SHIFT;
382 unsigned int pg_len; 382 unsigned int pg_len;
383 struct blk_plug plug; 383 struct blk_plug plug;
384 int i; 384 int i;
diff --git a/fs/nfs/blocklayout/rpc_pipefs.c b/fs/nfs/blocklayout/rpc_pipefs.c
index e966c023b1b7..dbe5839cdeba 100644
--- a/fs/nfs/blocklayout/rpc_pipefs.c
+++ b/fs/nfs/blocklayout/rpc_pipefs.c
@@ -65,17 +65,18 @@ bl_resolve_deviceid(struct nfs_server *server, struct pnfs_block_volume *b,
65 65
66 dprintk("%s CREATING PIPEFS MESSAGE\n", __func__); 66 dprintk("%s CREATING PIPEFS MESSAGE\n", __func__);
67 67
68 mutex_lock(&nn->bl_mutex);
68 bl_pipe_msg.bl_wq = &nn->bl_wq; 69 bl_pipe_msg.bl_wq = &nn->bl_wq;
69 70
70 b->simple.len += 4; /* single volume */ 71 b->simple.len += 4; /* single volume */
71 if (b->simple.len > PAGE_SIZE) 72 if (b->simple.len > PAGE_SIZE)
72 return -EIO; 73 goto out_unlock;
73 74
74 memset(msg, 0, sizeof(*msg)); 75 memset(msg, 0, sizeof(*msg));
75 msg->len = sizeof(*bl_msg) + b->simple.len; 76 msg->len = sizeof(*bl_msg) + b->simple.len;
76 msg->data = kzalloc(msg->len, gfp_mask); 77 msg->data = kzalloc(msg->len, gfp_mask);
77 if (!msg->data) 78 if (!msg->data)
78 goto out; 79 goto out_free_data;
79 80
80 bl_msg = msg->data; 81 bl_msg = msg->data;
81 bl_msg->type = BL_DEVICE_MOUNT, 82 bl_msg->type = BL_DEVICE_MOUNT,
@@ -87,7 +88,7 @@ bl_resolve_deviceid(struct nfs_server *server, struct pnfs_block_volume *b,
87 rc = rpc_queue_upcall(nn->bl_device_pipe, msg); 88 rc = rpc_queue_upcall(nn->bl_device_pipe, msg);
88 if (rc < 0) { 89 if (rc < 0) {
89 remove_wait_queue(&nn->bl_wq, &wq); 90 remove_wait_queue(&nn->bl_wq, &wq);
90 goto out; 91 goto out_free_data;
91 } 92 }
92 93
93 set_current_state(TASK_UNINTERRUPTIBLE); 94 set_current_state(TASK_UNINTERRUPTIBLE);
@@ -97,19 +98,21 @@ bl_resolve_deviceid(struct nfs_server *server, struct pnfs_block_volume *b,
97 if (reply->status != BL_DEVICE_REQUEST_PROC) { 98 if (reply->status != BL_DEVICE_REQUEST_PROC) {
98 printk(KERN_WARNING "%s failed to decode device: %d\n", 99 printk(KERN_WARNING "%s failed to decode device: %d\n",
99 __func__, reply->status); 100 __func__, reply->status);
100 goto out; 101 goto out_free_data;
101 } 102 }
102 103
103 dev = MKDEV(reply->major, reply->minor); 104 dev = MKDEV(reply->major, reply->minor);
104out: 105out_free_data:
105 kfree(msg->data); 106 kfree(msg->data);
107out_unlock:
108 mutex_unlock(&nn->bl_mutex);
106 return dev; 109 return dev;
107} 110}
108 111
109static ssize_t bl_pipe_downcall(struct file *filp, const char __user *src, 112static ssize_t bl_pipe_downcall(struct file *filp, const char __user *src,
110 size_t mlen) 113 size_t mlen)
111{ 114{
112 struct nfs_net *nn = net_generic(filp->f_dentry->d_sb->s_fs_info, 115 struct nfs_net *nn = net_generic(file_inode(filp)->i_sb->s_fs_info,
113 nfs_net_id); 116 nfs_net_id);
114 117
115 if (mlen != sizeof (struct bl_dev_msg)) 118 if (mlen != sizeof (struct bl_dev_msg))
@@ -232,6 +235,7 @@ static int nfs4blocklayout_net_init(struct net *net)
232 struct nfs_net *nn = net_generic(net, nfs_net_id); 235 struct nfs_net *nn = net_generic(net, nfs_net_id);
233 struct dentry *dentry; 236 struct dentry *dentry;
234 237
238 mutex_init(&nn->bl_mutex);
235 init_waitqueue_head(&nn->bl_wq); 239 init_waitqueue_head(&nn->bl_wq);
236 nn->bl_device_pipe = rpc_mkpipe_data(&bl_upcall_ops, 0); 240 nn->bl_device_pipe = rpc_mkpipe_data(&bl_upcall_ops, 0);
237 if (IS_ERR(nn->bl_device_pipe)) 241 if (IS_ERR(nn->bl_device_pipe))
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index 5853f53db732..7f3f60641344 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -125,6 +125,8 @@ again:
125 continue; 125 continue;
126 if (!test_bit(NFS_DELEGATED_STATE, &state->flags)) 126 if (!test_bit(NFS_DELEGATED_STATE, &state->flags))
127 continue; 127 continue;
128 if (!nfs4_valid_open_stateid(state))
129 continue;
128 if (!nfs4_stateid_match(&state->stateid, stateid)) 130 if (!nfs4_stateid_match(&state->stateid, stateid))
129 continue; 131 continue;
130 get_nfs_open_context(ctx); 132 get_nfs_open_context(ctx);
@@ -193,7 +195,11 @@ static int nfs_do_return_delegation(struct inode *inode, struct nfs_delegation *
193{ 195{
194 int res = 0; 196 int res = 0;
195 197
196 res = nfs4_proc_delegreturn(inode, delegation->cred, &delegation->stateid, issync); 198 if (!test_bit(NFS_DELEGATION_REVOKED, &delegation->flags))
199 res = nfs4_proc_delegreturn(inode,
200 delegation->cred,
201 &delegation->stateid,
202 issync);
197 nfs_free_delegation(delegation); 203 nfs_free_delegation(delegation);
198 return res; 204 return res;
199} 205}
@@ -380,11 +386,13 @@ static int nfs_end_delegation_return(struct inode *inode, struct nfs_delegation
380{ 386{
381 struct nfs_client *clp = NFS_SERVER(inode)->nfs_client; 387 struct nfs_client *clp = NFS_SERVER(inode)->nfs_client;
382 struct nfs_inode *nfsi = NFS_I(inode); 388 struct nfs_inode *nfsi = NFS_I(inode);
383 int err; 389 int err = 0;
384 390
385 if (delegation == NULL) 391 if (delegation == NULL)
386 return 0; 392 return 0;
387 do { 393 do {
394 if (test_bit(NFS_DELEGATION_REVOKED, &delegation->flags))
395 break;
388 err = nfs_delegation_claim_opens(inode, &delegation->stateid); 396 err = nfs_delegation_claim_opens(inode, &delegation->stateid);
389 if (!issync || err != -EAGAIN) 397 if (!issync || err != -EAGAIN)
390 break; 398 break;
@@ -605,10 +613,23 @@ static void nfs_client_mark_return_unused_delegation_types(struct nfs_client *cl
605 rcu_read_unlock(); 613 rcu_read_unlock();
606} 614}
607 615
616static void nfs_revoke_delegation(struct inode *inode)
617{
618 struct nfs_delegation *delegation;
619 rcu_read_lock();
620 delegation = rcu_dereference(NFS_I(inode)->delegation);
621 if (delegation != NULL) {
622 set_bit(NFS_DELEGATION_REVOKED, &delegation->flags);
623 nfs_mark_return_delegation(NFS_SERVER(inode), delegation);
624 }
625 rcu_read_unlock();
626}
627
608void nfs_remove_bad_delegation(struct inode *inode) 628void nfs_remove_bad_delegation(struct inode *inode)
609{ 629{
610 struct nfs_delegation *delegation; 630 struct nfs_delegation *delegation;
611 631
632 nfs_revoke_delegation(inode);
612 delegation = nfs_inode_detach_delegation(inode); 633 delegation = nfs_inode_detach_delegation(inode);
613 if (delegation) { 634 if (delegation) {
614 nfs_inode_find_state_and_recover(inode, &delegation->stateid); 635 nfs_inode_find_state_and_recover(inode, &delegation->stateid);
diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h
index 5c1cce39297f..e3c20a3ccc93 100644
--- a/fs/nfs/delegation.h
+++ b/fs/nfs/delegation.h
@@ -31,6 +31,7 @@ enum {
31 NFS_DELEGATION_RETURN_IF_CLOSED, 31 NFS_DELEGATION_RETURN_IF_CLOSED,
32 NFS_DELEGATION_REFERENCED, 32 NFS_DELEGATION_REFERENCED,
33 NFS_DELEGATION_RETURNING, 33 NFS_DELEGATION_RETURNING,
34 NFS_DELEGATION_REVOKED,
34}; 35};
35 36
36int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res); 37int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res);
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 06e8cfcbb670..9b0c55cb2a2e 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -133,7 +133,7 @@ out:
133static int 133static int
134nfs_closedir(struct inode *inode, struct file *filp) 134nfs_closedir(struct inode *inode, struct file *filp)
135{ 135{
136 put_nfs_open_dir_context(filp->f_path.dentry->d_inode, filp->private_data); 136 put_nfs_open_dir_context(file_inode(filp), filp->private_data);
137 return 0; 137 return 0;
138} 138}
139 139
@@ -499,7 +499,7 @@ void nfs_prime_dcache(struct dentry *parent, struct nfs_entry *entry)
499 if (IS_ERR(inode)) 499 if (IS_ERR(inode))
500 goto out; 500 goto out;
501 501
502 alias = d_materialise_unique(dentry, inode); 502 alias = d_splice_alias(inode, dentry);
503 if (IS_ERR(alias)) 503 if (IS_ERR(alias))
504 goto out; 504 goto out;
505 else if (alias) { 505 else if (alias) {
@@ -1393,7 +1393,7 @@ struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned in
1393 nfs_advise_use_readdirplus(dir); 1393 nfs_advise_use_readdirplus(dir);
1394 1394
1395no_entry: 1395no_entry:
1396 res = d_materialise_unique(dentry, inode); 1396 res = d_splice_alias(inode, dentry);
1397 if (res != NULL) { 1397 if (res != NULL) {
1398 if (IS_ERR(res)) 1398 if (IS_ERR(res))
1399 goto out_unblock_sillyrename; 1399 goto out_unblock_sillyrename;
@@ -1527,6 +1527,7 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
1527 case -ENOENT: 1527 case -ENOENT:
1528 d_drop(dentry); 1528 d_drop(dentry);
1529 d_add(dentry, NULL); 1529 d_add(dentry, NULL);
1530 nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
1530 break; 1531 break;
1531 case -EISDIR: 1532 case -EISDIR:
1532 case -ENOTDIR: 1533 case -ENOTDIR:
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 20cffc830468..10bf07280f4a 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -266,6 +266,7 @@ static void nfs_direct_req_free(struct kref *kref)
266{ 266{
267 struct nfs_direct_req *dreq = container_of(kref, struct nfs_direct_req, kref); 267 struct nfs_direct_req *dreq = container_of(kref, struct nfs_direct_req, kref);
268 268
269 nfs_free_pnfs_ds_cinfo(&dreq->ds_cinfo);
269 if (dreq->l_ctx != NULL) 270 if (dreq->l_ctx != NULL)
270 nfs_put_lock_context(dreq->l_ctx); 271 nfs_put_lock_context(dreq->l_ctx);
271 if (dreq->ctx != NULL) 272 if (dreq->ctx != NULL)
diff --git a/fs/nfs/filelayout/filelayout.c b/fs/nfs/filelayout/filelayout.c
index 46fab1cb455a..7afb52f6a25a 100644
--- a/fs/nfs/filelayout/filelayout.c
+++ b/fs/nfs/filelayout/filelayout.c
@@ -145,9 +145,6 @@ static int filelayout_async_handle_error(struct rpc_task *task,
145 case -NFS4ERR_DELEG_REVOKED: 145 case -NFS4ERR_DELEG_REVOKED:
146 case -NFS4ERR_ADMIN_REVOKED: 146 case -NFS4ERR_ADMIN_REVOKED:
147 case -NFS4ERR_BAD_STATEID: 147 case -NFS4ERR_BAD_STATEID:
148 if (state == NULL)
149 break;
150 nfs_remove_bad_delegation(state->inode);
151 case -NFS4ERR_OPENMODE: 148 case -NFS4ERR_OPENMODE:
152 if (state == NULL) 149 if (state == NULL)
153 break; 150 break;
diff --git a/fs/nfs/getroot.c b/fs/nfs/getroot.c
index 880618a8b048..9ac3846cb59e 100644
--- a/fs/nfs/getroot.c
+++ b/fs/nfs/getroot.c
@@ -51,14 +51,14 @@ static int nfs_superblock_set_dummy_root(struct super_block *sb, struct inode *i
51 /* 51 /*
52 * Ensure that this dentry is invisible to d_find_alias(). 52 * Ensure that this dentry is invisible to d_find_alias().
53 * Otherwise, it may be spliced into the tree by 53 * Otherwise, it may be spliced into the tree by
54 * d_materialise_unique if a parent directory from the same 54 * d_splice_alias if a parent directory from the same
55 * filesystem gets mounted at a later time. 55 * filesystem gets mounted at a later time.
56 * This again causes shrink_dcache_for_umount_subtree() to 56 * This again causes shrink_dcache_for_umount_subtree() to
57 * Oops, since the test for IS_ROOT() will fail. 57 * Oops, since the test for IS_ROOT() will fail.
58 */ 58 */
59 spin_lock(&sb->s_root->d_inode->i_lock); 59 spin_lock(&sb->s_root->d_inode->i_lock);
60 spin_lock(&sb->s_root->d_lock); 60 spin_lock(&sb->s_root->d_lock);
61 hlist_del_init(&sb->s_root->d_alias); 61 hlist_del_init(&sb->s_root->d_u.d_alias);
62 spin_unlock(&sb->s_root->d_lock); 62 spin_unlock(&sb->s_root->d_lock);
63 spin_unlock(&sb->s_root->d_inode->i_lock); 63 spin_unlock(&sb->s_root->d_inode->i_lock);
64 } 64 }
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 6388a59f2add..00689a8a85e4 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -626,7 +626,7 @@ int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
626{ 626{
627 struct inode *inode = dentry->d_inode; 627 struct inode *inode = dentry->d_inode;
628 int need_atime = NFS_I(inode)->cache_validity & NFS_INO_INVALID_ATIME; 628 int need_atime = NFS_I(inode)->cache_validity & NFS_INO_INVALID_ATIME;
629 int err; 629 int err = 0;
630 630
631 trace_nfs_getattr_enter(inode); 631 trace_nfs_getattr_enter(inode);
632 /* Flush out writes to the server in order to update c/mtime. */ 632 /* Flush out writes to the server in order to update c/mtime. */
diff --git a/fs/nfs/netns.h b/fs/nfs/netns.h
index ef221fb8a183..f0e06e4acbef 100644
--- a/fs/nfs/netns.h
+++ b/fs/nfs/netns.h
@@ -19,6 +19,7 @@ struct nfs_net {
19 struct rpc_pipe *bl_device_pipe; 19 struct rpc_pipe *bl_device_pipe;
20 struct bl_dev_msg bl_mount_reply; 20 struct bl_dev_msg bl_mount_reply;
21 wait_queue_head_t bl_wq; 21 wait_queue_head_t bl_wq;
22 struct mutex bl_mutex;
22 struct list_head nfs_client_list; 23 struct list_head nfs_client_list;
23 struct list_head nfs_volume_list; 24 struct list_head nfs_volume_list;
24#if IS_ENABLED(CONFIG_NFS_V4) 25#if IS_ENABLED(CONFIG_NFS_V4)
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 405bd95c1f58..69dc20a743f9 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -370,11 +370,6 @@ static int nfs4_handle_exception(struct nfs_server *server, int errorcode, struc
370 case -NFS4ERR_DELEG_REVOKED: 370 case -NFS4ERR_DELEG_REVOKED:
371 case -NFS4ERR_ADMIN_REVOKED: 371 case -NFS4ERR_ADMIN_REVOKED:
372 case -NFS4ERR_BAD_STATEID: 372 case -NFS4ERR_BAD_STATEID:
373 if (inode != NULL && nfs4_have_delegation(inode, FMODE_READ)) {
374 nfs_remove_bad_delegation(inode);
375 exception->retry = 1;
376 break;
377 }
378 if (state == NULL) 373 if (state == NULL)
379 break; 374 break;
380 ret = nfs4_schedule_stateid_recovery(server, state); 375 ret = nfs4_schedule_stateid_recovery(server, state);
@@ -1654,7 +1649,7 @@ static int nfs4_handle_delegation_recall_error(struct nfs_server *server, struct
1654 nfs_inode_find_state_and_recover(state->inode, 1649 nfs_inode_find_state_and_recover(state->inode,
1655 stateid); 1650 stateid);
1656 nfs4_schedule_stateid_recovery(server, state); 1651 nfs4_schedule_stateid_recovery(server, state);
1657 return 0; 1652 return -EAGAIN;
1658 case -NFS4ERR_DELAY: 1653 case -NFS4ERR_DELAY:
1659 case -NFS4ERR_GRACE: 1654 case -NFS4ERR_GRACE:
1660 set_bit(NFS_DELEGATED_STATE, &state->flags); 1655 set_bit(NFS_DELEGATED_STATE, &state->flags);
@@ -2109,46 +2104,60 @@ static int nfs4_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *sta
2109 return ret; 2104 return ret;
2110} 2105}
2111 2106
2107static void nfs_finish_clear_delegation_stateid(struct nfs4_state *state)
2108{
2109 nfs_remove_bad_delegation(state->inode);
2110 write_seqlock(&state->seqlock);
2111 nfs4_stateid_copy(&state->stateid, &state->open_stateid);
2112 write_sequnlock(&state->seqlock);
2113 clear_bit(NFS_DELEGATED_STATE, &state->flags);
2114}
2115
2116static void nfs40_clear_delegation_stateid(struct nfs4_state *state)
2117{
2118 if (rcu_access_pointer(NFS_I(state->inode)->delegation) != NULL)
2119 nfs_finish_clear_delegation_stateid(state);
2120}
2121
2122static int nfs40_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *state)
2123{
2124 /* NFSv4.0 doesn't allow for delegation recovery on open expire */
2125 nfs40_clear_delegation_stateid(state);
2126 return nfs4_open_expired(sp, state);
2127}
2128
2112#if defined(CONFIG_NFS_V4_1) 2129#if defined(CONFIG_NFS_V4_1)
2113static void nfs41_clear_delegation_stateid(struct nfs4_state *state) 2130static void nfs41_check_delegation_stateid(struct nfs4_state *state)
2114{ 2131{
2115 struct nfs_server *server = NFS_SERVER(state->inode); 2132 struct nfs_server *server = NFS_SERVER(state->inode);
2116 nfs4_stateid *stateid = &state->stateid; 2133 nfs4_stateid stateid;
2117 struct nfs_delegation *delegation; 2134 struct nfs_delegation *delegation;
2118 struct rpc_cred *cred = NULL; 2135 struct rpc_cred *cred;
2119 int status = -NFS4ERR_BAD_STATEID; 2136 int status;
2120
2121 /* If a state reset has been done, test_stateid is unneeded */
2122 if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0)
2123 return;
2124 2137
2125 /* Get the delegation credential for use by test/free_stateid */ 2138 /* Get the delegation credential for use by test/free_stateid */
2126 rcu_read_lock(); 2139 rcu_read_lock();
2127 delegation = rcu_dereference(NFS_I(state->inode)->delegation); 2140 delegation = rcu_dereference(NFS_I(state->inode)->delegation);
2128 if (delegation != NULL && 2141 if (delegation == NULL) {
2129 nfs4_stateid_match(&delegation->stateid, stateid)) {
2130 cred = get_rpccred(delegation->cred);
2131 rcu_read_unlock();
2132 status = nfs41_test_stateid(server, stateid, cred);
2133 trace_nfs4_test_delegation_stateid(state, NULL, status);
2134 } else
2135 rcu_read_unlock(); 2142 rcu_read_unlock();
2143 return;
2144 }
2145
2146 nfs4_stateid_copy(&stateid, &delegation->stateid);
2147 cred = get_rpccred(delegation->cred);
2148 rcu_read_unlock();
2149 status = nfs41_test_stateid(server, &stateid, cred);
2150 trace_nfs4_test_delegation_stateid(state, NULL, status);
2136 2151
2137 if (status != NFS_OK) { 2152 if (status != NFS_OK) {
2138 /* Free the stateid unless the server explicitly 2153 /* Free the stateid unless the server explicitly
2139 * informs us the stateid is unrecognized. */ 2154 * informs us the stateid is unrecognized. */
2140 if (status != -NFS4ERR_BAD_STATEID) 2155 if (status != -NFS4ERR_BAD_STATEID)
2141 nfs41_free_stateid(server, stateid, cred); 2156 nfs41_free_stateid(server, &stateid, cred);
2142 nfs_remove_bad_delegation(state->inode); 2157 nfs_finish_clear_delegation_stateid(state);
2143
2144 write_seqlock(&state->seqlock);
2145 nfs4_stateid_copy(&state->stateid, &state->open_stateid);
2146 write_sequnlock(&state->seqlock);
2147 clear_bit(NFS_DELEGATED_STATE, &state->flags);
2148 } 2158 }
2149 2159
2150 if (cred != NULL) 2160 put_rpccred(cred);
2151 put_rpccred(cred);
2152} 2161}
2153 2162
2154/** 2163/**
@@ -2192,7 +2201,7 @@ static int nfs41_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *st
2192{ 2201{
2193 int status; 2202 int status;
2194 2203
2195 nfs41_clear_delegation_stateid(state); 2204 nfs41_check_delegation_stateid(state);
2196 status = nfs41_check_open_stateid(state); 2205 status = nfs41_check_open_stateid(state);
2197 if (status != NFS_OK) 2206 if (status != NFS_OK)
2198 status = nfs4_open_expired(sp, state); 2207 status = nfs4_open_expired(sp, state);
@@ -2231,19 +2240,8 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
2231 seq = raw_seqcount_begin(&sp->so_reclaim_seqcount); 2240 seq = raw_seqcount_begin(&sp->so_reclaim_seqcount);
2232 2241
2233 ret = _nfs4_proc_open(opendata); 2242 ret = _nfs4_proc_open(opendata);
2234 if (ret != 0) { 2243 if (ret != 0)
2235 if (ret == -ENOENT) {
2236 dentry = opendata->dentry;
2237 if (dentry->d_inode)
2238 d_delete(dentry);
2239 else if (d_unhashed(dentry))
2240 d_add(dentry, NULL);
2241
2242 nfs_set_verifier(dentry,
2243 nfs_save_change_attribute(opendata->dir->d_inode));
2244 }
2245 goto out; 2244 goto out;
2246 }
2247 2245
2248 state = nfs4_opendata_to_nfs4_state(opendata); 2246 state = nfs4_opendata_to_nfs4_state(opendata);
2249 ret = PTR_ERR(state); 2247 ret = PTR_ERR(state);
@@ -4841,9 +4839,6 @@ nfs4_async_handle_error(struct rpc_task *task, const struct nfs_server *server,
4841 case -NFS4ERR_DELEG_REVOKED: 4839 case -NFS4ERR_DELEG_REVOKED:
4842 case -NFS4ERR_ADMIN_REVOKED: 4840 case -NFS4ERR_ADMIN_REVOKED:
4843 case -NFS4ERR_BAD_STATEID: 4841 case -NFS4ERR_BAD_STATEID:
4844 if (state == NULL)
4845 break;
4846 nfs_remove_bad_delegation(state->inode);
4847 case -NFS4ERR_OPENMODE: 4842 case -NFS4ERR_OPENMODE:
4848 if (state == NULL) 4843 if (state == NULL)
4849 break; 4844 break;
@@ -8341,7 +8336,7 @@ static const struct nfs4_state_recovery_ops nfs41_reboot_recovery_ops = {
8341static const struct nfs4_state_recovery_ops nfs40_nograce_recovery_ops = { 8336static const struct nfs4_state_recovery_ops nfs40_nograce_recovery_ops = {
8342 .owner_flag_bit = NFS_OWNER_RECLAIM_NOGRACE, 8337 .owner_flag_bit = NFS_OWNER_RECLAIM_NOGRACE,
8343 .state_flag_bit = NFS_STATE_RECLAIM_NOGRACE, 8338 .state_flag_bit = NFS_STATE_RECLAIM_NOGRACE,
8344 .recover_open = nfs4_open_expired, 8339 .recover_open = nfs40_open_expired,
8345 .recover_lock = nfs4_lock_expired, 8340 .recover_lock = nfs4_lock_expired,
8346 .establish_clid = nfs4_init_clientid, 8341 .establish_clid = nfs4_init_clientid,
8347}; 8342};
@@ -8408,8 +8403,7 @@ static const struct nfs4_minor_version_ops nfs_v4_1_minor_ops = {
8408 | NFS_CAP_CHANGE_ATTR 8403 | NFS_CAP_CHANGE_ATTR
8409 | NFS_CAP_POSIX_LOCK 8404 | NFS_CAP_POSIX_LOCK
8410 | NFS_CAP_STATEID_NFSV41 8405 | NFS_CAP_STATEID_NFSV41
8411 | NFS_CAP_ATOMIC_OPEN_V1 8406 | NFS_CAP_ATOMIC_OPEN_V1,
8412 | NFS_CAP_SEEK,
8413 .init_client = nfs41_init_client, 8407 .init_client = nfs41_init_client,
8414 .shutdown_client = nfs41_shutdown_client, 8408 .shutdown_client = nfs41_shutdown_client,
8415 .match_stateid = nfs41_match_stateid, 8409 .match_stateid = nfs41_match_stateid,
@@ -8431,7 +8425,8 @@ static const struct nfs4_minor_version_ops nfs_v4_2_minor_ops = {
8431 | NFS_CAP_CHANGE_ATTR 8425 | NFS_CAP_CHANGE_ATTR
8432 | NFS_CAP_POSIX_LOCK 8426 | NFS_CAP_POSIX_LOCK
8433 | NFS_CAP_STATEID_NFSV41 8427 | NFS_CAP_STATEID_NFSV41
8434 | NFS_CAP_ATOMIC_OPEN_V1, 8428 | NFS_CAP_ATOMIC_OPEN_V1
8429 | NFS_CAP_SEEK,
8435 .init_client = nfs41_init_client, 8430 .init_client = nfs41_init_client,
8436 .shutdown_client = nfs41_shutdown_client, 8431 .shutdown_client = nfs41_shutdown_client,
8437 .match_stateid = nfs41_match_stateid, 8432 .match_stateid = nfs41_match_stateid,
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 12493846a2d3..f83b02dc9166 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -715,8 +715,6 @@ static void nfs_inode_remove_request(struct nfs_page *req)
715 715
716 if (test_and_clear_bit(PG_INODE_REF, &req->wb_flags)) 716 if (test_and_clear_bit(PG_INODE_REF, &req->wb_flags))
717 nfs_release_request(req); 717 nfs_release_request(req);
718 else
719 WARN_ON_ONCE(1);
720} 718}
721 719
722static void 720static void
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index cdeb3cfd6f32..0beb023f25ac 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -1272,7 +1272,8 @@ static bool need_wrongsec_check(struct svc_rqst *rqstp)
1272 */ 1272 */
1273 if (argp->opcnt == resp->opcnt) 1273 if (argp->opcnt == resp->opcnt)
1274 return false; 1274 return false;
1275 1275 if (next->opnum == OP_ILLEGAL)
1276 return false;
1276 nextd = OPDESC(next); 1277 nextd = OPDESC(next);
1277 /* 1278 /*
1278 * Rest of 2.6.3.1.1: certain operations will return WRONGSEC 1279 * Rest of 2.6.3.1.1: certain operations will return WRONGSEC
@@ -1589,7 +1590,8 @@ static inline u32 nfsd4_rename_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op
1589static inline u32 nfsd4_sequence_rsize(struct svc_rqst *rqstp, 1590static inline u32 nfsd4_sequence_rsize(struct svc_rqst *rqstp,
1590 struct nfsd4_op *op) 1591 struct nfsd4_op *op)
1591{ 1592{
1592 return NFS4_MAX_SESSIONID_LEN + 20; 1593 return (op_encode_hdr_size
1594 + XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5) * sizeof(__be32);
1593} 1595}
1594 1596
1595static inline u32 nfsd4_setattr_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 1597static inline u32 nfsd4_setattr_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
@@ -1893,6 +1895,7 @@ static struct nfsd4_operation nfsd4_ops[] = {
1893 .op_func = (nfsd4op_func)nfsd4_sequence, 1895 .op_func = (nfsd4op_func)nfsd4_sequence,
1894 .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_AS_FIRST_OP, 1896 .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_AS_FIRST_OP,
1895 .op_name = "OP_SEQUENCE", 1897 .op_name = "OP_SEQUENCE",
1898 .op_rsize_bop = (nfsd4op_rsize)nfsd4_sequence_rsize,
1896 }, 1899 },
1897 [OP_DESTROY_CLIENTID] = { 1900 [OP_DESTROY_CLIENTID] = {
1898 .op_func = (nfsd4op_func)nfsd4_destroy_clientid, 1901 .op_func = (nfsd4op_func)nfsd4_destroy_clientid,
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
index a25490ae6c62..cc6a76072009 100644
--- a/fs/nfsd/nfs4recover.c
+++ b/fs/nfsd/nfs4recover.c
@@ -245,10 +245,11 @@ struct nfs4_dir_ctx {
245}; 245};
246 246
247static int 247static int
248nfsd4_build_namelist(void *arg, const char *name, int namlen, 248nfsd4_build_namelist(struct dir_context *__ctx, const char *name, int namlen,
249 loff_t offset, u64 ino, unsigned int d_type) 249 loff_t offset, u64 ino, unsigned int d_type)
250{ 250{
251 struct nfs4_dir_ctx *ctx = arg; 251 struct nfs4_dir_ctx *ctx =
252 container_of(__ctx, struct nfs4_dir_ctx, ctx);
252 struct name_list *entry; 253 struct name_list *entry;
253 254
254 if (namlen != HEXDIR_LEN - 1) 255 if (namlen != HEXDIR_LEN - 1)
@@ -704,7 +705,7 @@ cld_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
704 struct cld_upcall *tmp, *cup; 705 struct cld_upcall *tmp, *cup;
705 struct cld_msg __user *cmsg = (struct cld_msg __user *)src; 706 struct cld_msg __user *cmsg = (struct cld_msg __user *)src;
706 uint32_t xid; 707 uint32_t xid;
707 struct nfsd_net *nn = net_generic(filp->f_dentry->d_sb->s_fs_info, 708 struct nfsd_net *nn = net_generic(file_inode(filp)->i_sb->s_fs_info,
708 nfsd_net_id); 709 nfsd_net_id);
709 struct cld_net *cn = nn->cld_net; 710 struct cld_net *cn = nn->cld_net;
710 711
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index eeea7a90eb87..b1eed4dd2eab 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -1886,7 +1886,7 @@ static __be32 nfsd4_encode_path(struct xdr_stream *xdr,
1886 goto out_free; 1886 goto out_free;
1887 } 1887 }
1888 p = xdr_encode_opaque(p, dentry->d_name.name, len); 1888 p = xdr_encode_opaque(p, dentry->d_name.name, len);
1889 dprintk("/%s", dentry->d_name.name); 1889 dprintk("/%pd", dentry);
1890 spin_unlock(&dentry->d_lock); 1890 spin_unlock(&dentry->d_lock);
1891 dput(dentry); 1891 dput(dentry);
1892 ncomponents--; 1892 ncomponents--;
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index ca73ca79a0ee..9506ea565610 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -231,6 +231,10 @@ static struct file_operations reply_cache_stats_operations = {
231 * payload - write methods 231 * payload - write methods
232 */ 232 */
233 233
234static inline struct net *netns(struct file *file)
235{
236 return file_inode(file)->i_sb->s_fs_info;
237}
234 238
235/** 239/**
236 * write_unlock_ip - Release all locks used by a client 240 * write_unlock_ip - Release all locks used by a client
@@ -252,7 +256,7 @@ static ssize_t write_unlock_ip(struct file *file, char *buf, size_t size)
252 struct sockaddr *sap = (struct sockaddr *)&address; 256 struct sockaddr *sap = (struct sockaddr *)&address;
253 size_t salen = sizeof(address); 257 size_t salen = sizeof(address);
254 char *fo_path; 258 char *fo_path;
255 struct net *net = file->f_dentry->d_sb->s_fs_info; 259 struct net *net = netns(file);
256 260
257 /* sanity check */ 261 /* sanity check */
258 if (size == 0) 262 if (size == 0)
@@ -350,7 +354,6 @@ static ssize_t write_filehandle(struct file *file, char *buf, size_t size)
350 int len; 354 int len;
351 struct auth_domain *dom; 355 struct auth_domain *dom;
352 struct knfsd_fh fh; 356 struct knfsd_fh fh;
353 struct net *net = file->f_dentry->d_sb->s_fs_info;
354 357
355 if (size == 0) 358 if (size == 0)
356 return -EINVAL; 359 return -EINVAL;
@@ -385,7 +388,7 @@ static ssize_t write_filehandle(struct file *file, char *buf, size_t size)
385 if (!dom) 388 if (!dom)
386 return -ENOMEM; 389 return -ENOMEM;
387 390
388 len = exp_rootfh(net, dom, path, &fh, maxsize); 391 len = exp_rootfh(netns(file), dom, path, &fh, maxsize);
389 auth_domain_put(dom); 392 auth_domain_put(dom);
390 if (len) 393 if (len)
391 return len; 394 return len;
@@ -429,7 +432,7 @@ static ssize_t write_threads(struct file *file, char *buf, size_t size)
429{ 432{
430 char *mesg = buf; 433 char *mesg = buf;
431 int rv; 434 int rv;
432 struct net *net = file->f_dentry->d_sb->s_fs_info; 435 struct net *net = netns(file);
433 436
434 if (size > 0) { 437 if (size > 0) {
435 int newthreads; 438 int newthreads;
@@ -480,7 +483,7 @@ static ssize_t write_pool_threads(struct file *file, char *buf, size_t size)
480 int len; 483 int len;
481 int npools; 484 int npools;
482 int *nthreads; 485 int *nthreads;
483 struct net *net = file->f_dentry->d_sb->s_fs_info; 486 struct net *net = netns(file);
484 487
485 mutex_lock(&nfsd_mutex); 488 mutex_lock(&nfsd_mutex);
486 npools = nfsd_nrpools(net); 489 npools = nfsd_nrpools(net);
@@ -543,8 +546,7 @@ static ssize_t __write_versions(struct file *file, char *buf, size_t size)
543 unsigned minor; 546 unsigned minor;
544 ssize_t tlen = 0; 547 ssize_t tlen = 0;
545 char *sep; 548 char *sep;
546 struct net *net = file->f_dentry->d_sb->s_fs_info; 549 struct nfsd_net *nn = net_generic(netns(file), nfsd_net_id);
547 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
548 550
549 if (size>0) { 551 if (size>0) {
550 if (nn->nfsd_serv) 552 if (nn->nfsd_serv)
@@ -830,10 +832,9 @@ static ssize_t __write_ports(struct file *file, char *buf, size_t size,
830static ssize_t write_ports(struct file *file, char *buf, size_t size) 832static ssize_t write_ports(struct file *file, char *buf, size_t size)
831{ 833{
832 ssize_t rv; 834 ssize_t rv;
833 struct net *net = file->f_dentry->d_sb->s_fs_info;
834 835
835 mutex_lock(&nfsd_mutex); 836 mutex_lock(&nfsd_mutex);
836 rv = __write_ports(file, buf, size, net); 837 rv = __write_ports(file, buf, size, netns(file));
837 mutex_unlock(&nfsd_mutex); 838 mutex_unlock(&nfsd_mutex);
838 return rv; 839 return rv;
839} 840}
@@ -865,8 +866,7 @@ int nfsd_max_blksize;
865static ssize_t write_maxblksize(struct file *file, char *buf, size_t size) 866static ssize_t write_maxblksize(struct file *file, char *buf, size_t size)
866{ 867{
867 char *mesg = buf; 868 char *mesg = buf;
868 struct net *net = file->f_dentry->d_sb->s_fs_info; 869 struct nfsd_net *nn = net_generic(netns(file), nfsd_net_id);
869 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
870 870
871 if (size > 0) { 871 if (size > 0) {
872 int bsize; 872 int bsize;
@@ -915,8 +915,7 @@ static ssize_t write_maxblksize(struct file *file, char *buf, size_t size)
915static ssize_t write_maxconn(struct file *file, char *buf, size_t size) 915static ssize_t write_maxconn(struct file *file, char *buf, size_t size)
916{ 916{
917 char *mesg = buf; 917 char *mesg = buf;
918 struct net *net = file->f_dentry->d_sb->s_fs_info; 918 struct nfsd_net *nn = net_generic(netns(file), nfsd_net_id);
919 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
920 unsigned int maxconn = nn->max_connections; 919 unsigned int maxconn = nn->max_connections;
921 920
922 if (size > 0) { 921 if (size > 0) {
@@ -997,8 +996,7 @@ static ssize_t nfsd4_write_time(struct file *file, char *buf, size_t size,
997 */ 996 */
998static ssize_t write_leasetime(struct file *file, char *buf, size_t size) 997static ssize_t write_leasetime(struct file *file, char *buf, size_t size)
999{ 998{
1000 struct net *net = file->f_dentry->d_sb->s_fs_info; 999 struct nfsd_net *nn = net_generic(netns(file), nfsd_net_id);
1001 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
1002 return nfsd4_write_time(file, buf, size, &nn->nfsd4_lease, nn); 1000 return nfsd4_write_time(file, buf, size, &nn->nfsd4_lease, nn);
1003} 1001}
1004 1002
@@ -1014,8 +1012,7 @@ static ssize_t write_leasetime(struct file *file, char *buf, size_t size)
1014 */ 1012 */
1015static ssize_t write_gracetime(struct file *file, char *buf, size_t size) 1013static ssize_t write_gracetime(struct file *file, char *buf, size_t size)
1016{ 1014{
1017 struct net *net = file->f_dentry->d_sb->s_fs_info; 1015 struct nfsd_net *nn = net_generic(netns(file), nfsd_net_id);
1018 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
1019 return nfsd4_write_time(file, buf, size, &nn->nfsd4_grace, nn); 1016 return nfsd4_write_time(file, buf, size, &nn->nfsd4_grace, nn);
1020} 1017}
1021 1018
@@ -1071,8 +1068,7 @@ static ssize_t __write_recoverydir(struct file *file, char *buf, size_t size,
1071static ssize_t write_recoverydir(struct file *file, char *buf, size_t size) 1068static ssize_t write_recoverydir(struct file *file, char *buf, size_t size)
1072{ 1069{
1073 ssize_t rv; 1070 ssize_t rv;
1074 struct net *net = file->f_dentry->d_sb->s_fs_info; 1071 struct nfsd_net *nn = net_generic(netns(file), nfsd_net_id);
1075 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
1076 1072
1077 mutex_lock(&nfsd_mutex); 1073 mutex_lock(&nfsd_mutex);
1078 rv = __write_recoverydir(file, buf, size, nn); 1074 rv = __write_recoverydir(file, buf, size, nn);
@@ -1102,8 +1098,7 @@ static ssize_t write_recoverydir(struct file *file, char *buf, size_t size)
1102 */ 1098 */
1103static ssize_t write_v4_end_grace(struct file *file, char *buf, size_t size) 1099static ssize_t write_v4_end_grace(struct file *file, char *buf, size_t size)
1104{ 1100{
1105 struct net *net = file->f_dentry->d_sb->s_fs_info; 1101 struct nfsd_net *nn = net_generic(netns(file), nfsd_net_id);
1106 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
1107 1102
1108 if (size > 0) { 1103 if (size > 0) {
1109 switch(buf[0]) { 1104 switch(buf[0]) {
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 989129e2d6ea..0a82e3c033ee 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -930,7 +930,6 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
930 unsigned long *cnt, int *stablep) 930 unsigned long *cnt, int *stablep)
931{ 931{
932 struct svc_export *exp; 932 struct svc_export *exp;
933 struct dentry *dentry;
934 struct inode *inode; 933 struct inode *inode;
935 mm_segment_t oldfs; 934 mm_segment_t oldfs;
936 __be32 err = 0; 935 __be32 err = 0;
@@ -949,8 +948,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
949 */ 948 */
950 current->flags |= PF_LESS_THROTTLE; 949 current->flags |= PF_LESS_THROTTLE;
951 950
952 dentry = file->f_path.dentry; 951 inode = file_inode(file);
953 inode = dentry->d_inode;
954 exp = fhp->fh_export; 952 exp = fhp->fh_export;
955 953
956 use_wgather = (rqstp->rq_vers == 2) && EX_WGATHER(exp); 954 use_wgather = (rqstp->rq_vers == 2) && EX_WGATHER(exp);
@@ -1819,10 +1817,12 @@ struct readdir_data {
1819 int full; 1817 int full;
1820}; 1818};
1821 1819
1822static int nfsd_buffered_filldir(void *__buf, const char *name, int namlen, 1820static int nfsd_buffered_filldir(struct dir_context *ctx, const char *name,
1823 loff_t offset, u64 ino, unsigned int d_type) 1821 int namlen, loff_t offset, u64 ino,
1822 unsigned int d_type)
1824{ 1823{
1825 struct readdir_data *buf = __buf; 1824 struct readdir_data *buf =
1825 container_of(ctx, struct readdir_data, ctx);
1826 struct buffered_dirent *de = (void *)(buf->dirent + buf->used); 1826 struct buffered_dirent *de = (void *)(buf->dirent + buf->used);
1827 unsigned int reclen; 1827 unsigned int reclen;
1828 1828
@@ -1842,7 +1842,7 @@ static int nfsd_buffered_filldir(void *__buf, const char *name, int namlen,
1842 return 0; 1842 return 0;
1843} 1843}
1844 1844
1845static __be32 nfsd_buffered_readdir(struct file *file, filldir_t func, 1845static __be32 nfsd_buffered_readdir(struct file *file, nfsd_filldir_t func,
1846 struct readdir_cd *cdp, loff_t *offsetp) 1846 struct readdir_cd *cdp, loff_t *offsetp)
1847{ 1847{
1848 struct buffered_dirent *de; 1848 struct buffered_dirent *de;
@@ -1926,7 +1926,7 @@ static __be32 nfsd_buffered_readdir(struct file *file, filldir_t func,
1926 */ 1926 */
1927__be32 1927__be32
1928nfsd_readdir(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t *offsetp, 1928nfsd_readdir(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t *offsetp,
1929 struct readdir_cd *cdp, filldir_t func) 1929 struct readdir_cd *cdp, nfsd_filldir_t func)
1930{ 1930{
1931 __be32 err; 1931 __be32 err;
1932 struct file *file; 1932 struct file *file;
diff --git a/fs/nfsd/vfs.h b/fs/nfsd/vfs.h
index c2ff3f14e5f6..b1796d6ee538 100644
--- a/fs/nfsd/vfs.h
+++ b/fs/nfsd/vfs.h
@@ -36,7 +36,7 @@
36/* 36/*
37 * Callback function for readdir 37 * Callback function for readdir
38 */ 38 */
39typedef int (*nfsd_dirop_t)(struct inode *, struct dentry *, int, int); 39typedef int (*nfsd_filldir_t)(void *, const char *, int, loff_t, u64, unsigned);
40 40
41/* nfsd/vfs.c */ 41/* nfsd/vfs.c */
42int nfsd_racache_init(int); 42int nfsd_racache_init(int);
@@ -95,7 +95,7 @@ __be32 nfsd_rename(struct svc_rqst *,
95__be32 nfsd_unlink(struct svc_rqst *, struct svc_fh *, int type, 95__be32 nfsd_unlink(struct svc_rqst *, struct svc_fh *, int type,
96 char *name, int len); 96 char *name, int len);
97__be32 nfsd_readdir(struct svc_rqst *, struct svc_fh *, 97__be32 nfsd_readdir(struct svc_rqst *, struct svc_fh *,
98 loff_t *, struct readdir_cd *, filldir_t); 98 loff_t *, struct readdir_cd *, nfsd_filldir_t);
99__be32 nfsd_statfs(struct svc_rqst *, struct svc_fh *, 99__be32 nfsd_statfs(struct svc_rqst *, struct svc_fh *,
100 struct kstatfs *, int access); 100 struct kstatfs *, int access);
101 101
diff --git a/fs/notify/fdinfo.c b/fs/notify/fdinfo.c
index 9d7e2b9659cb..6ffd220eb14d 100644
--- a/fs/notify/fdinfo.c
+++ b/fs/notify/fdinfo.c
@@ -20,25 +20,24 @@
20 20
21#if defined(CONFIG_INOTIFY_USER) || defined(CONFIG_FANOTIFY) 21#if defined(CONFIG_INOTIFY_USER) || defined(CONFIG_FANOTIFY)
22 22
23static int show_fdinfo(struct seq_file *m, struct file *f, 23static void show_fdinfo(struct seq_file *m, struct file *f,
24 int (*show)(struct seq_file *m, struct fsnotify_mark *mark)) 24 void (*show)(struct seq_file *m,
25 struct fsnotify_mark *mark))
25{ 26{
26 struct fsnotify_group *group = f->private_data; 27 struct fsnotify_group *group = f->private_data;
27 struct fsnotify_mark *mark; 28 struct fsnotify_mark *mark;
28 int ret = 0;
29 29
30 mutex_lock(&group->mark_mutex); 30 mutex_lock(&group->mark_mutex);
31 list_for_each_entry(mark, &group->marks_list, g_list) { 31 list_for_each_entry(mark, &group->marks_list, g_list) {
32 ret = show(m, mark); 32 show(m, mark);
33 if (ret) 33 if (seq_has_overflowed(m))
34 break; 34 break;
35 } 35 }
36 mutex_unlock(&group->mark_mutex); 36 mutex_unlock(&group->mark_mutex);
37 return ret;
38} 37}
39 38
40#if defined(CONFIG_EXPORTFS) 39#if defined(CONFIG_EXPORTFS)
41static int show_mark_fhandle(struct seq_file *m, struct inode *inode) 40static void show_mark_fhandle(struct seq_file *m, struct inode *inode)
42{ 41{
43 struct { 42 struct {
44 struct file_handle handle; 43 struct file_handle handle;
@@ -52,71 +51,62 @@ static int show_mark_fhandle(struct seq_file *m, struct inode *inode)
52 ret = exportfs_encode_inode_fh(inode, (struct fid *)f.handle.f_handle, &size, 0); 51 ret = exportfs_encode_inode_fh(inode, (struct fid *)f.handle.f_handle, &size, 0);
53 if ((ret == FILEID_INVALID) || (ret < 0)) { 52 if ((ret == FILEID_INVALID) || (ret < 0)) {
54 WARN_ONCE(1, "Can't encode file handler for inotify: %d\n", ret); 53 WARN_ONCE(1, "Can't encode file handler for inotify: %d\n", ret);
55 return 0; 54 return;
56 } 55 }
57 56
58 f.handle.handle_type = ret; 57 f.handle.handle_type = ret;
59 f.handle.handle_bytes = size * sizeof(u32); 58 f.handle.handle_bytes = size * sizeof(u32);
60 59
61 ret = seq_printf(m, "fhandle-bytes:%x fhandle-type:%x f_handle:", 60 seq_printf(m, "fhandle-bytes:%x fhandle-type:%x f_handle:",
62 f.handle.handle_bytes, f.handle.handle_type); 61 f.handle.handle_bytes, f.handle.handle_type);
63 62
64 for (i = 0; i < f.handle.handle_bytes; i++) 63 for (i = 0; i < f.handle.handle_bytes; i++)
65 ret |= seq_printf(m, "%02x", (int)f.handle.f_handle[i]); 64 seq_printf(m, "%02x", (int)f.handle.f_handle[i]);
66
67 return ret;
68} 65}
69#else 66#else
70static int show_mark_fhandle(struct seq_file *m, struct inode *inode) 67static void show_mark_fhandle(struct seq_file *m, struct inode *inode)
71{ 68{
72 return 0;
73} 69}
74#endif 70#endif
75 71
76#ifdef CONFIG_INOTIFY_USER 72#ifdef CONFIG_INOTIFY_USER
77 73
78static int inotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark) 74static void inotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
79{ 75{
80 struct inotify_inode_mark *inode_mark; 76 struct inotify_inode_mark *inode_mark;
81 struct inode *inode; 77 struct inode *inode;
82 int ret = 0;
83 78
84 if (!(mark->flags & (FSNOTIFY_MARK_FLAG_ALIVE | FSNOTIFY_MARK_FLAG_INODE))) 79 if (!(mark->flags & (FSNOTIFY_MARK_FLAG_ALIVE | FSNOTIFY_MARK_FLAG_INODE)))
85 return 0; 80 return;
86 81
87 inode_mark = container_of(mark, struct inotify_inode_mark, fsn_mark); 82 inode_mark = container_of(mark, struct inotify_inode_mark, fsn_mark);
88 inode = igrab(mark->i.inode); 83 inode = igrab(mark->i.inode);
89 if (inode) { 84 if (inode) {
90 ret = seq_printf(m, "inotify wd:%x ino:%lx sdev:%x " 85 seq_printf(m, "inotify wd:%x ino:%lx sdev:%x mask:%x ignored_mask:%x ",
91 "mask:%x ignored_mask:%x ", 86 inode_mark->wd, inode->i_ino, inode->i_sb->s_dev,
92 inode_mark->wd, inode->i_ino, 87 mark->mask, mark->ignored_mask);
93 inode->i_sb->s_dev, 88 show_mark_fhandle(m, inode);
94 mark->mask, mark->ignored_mask); 89 seq_putc(m, '\n');
95 ret |= show_mark_fhandle(m, inode);
96 ret |= seq_putc(m, '\n');
97 iput(inode); 90 iput(inode);
98 } 91 }
99
100 return ret;
101} 92}
102 93
103int inotify_show_fdinfo(struct seq_file *m, struct file *f) 94void inotify_show_fdinfo(struct seq_file *m, struct file *f)
104{ 95{
105 return show_fdinfo(m, f, inotify_fdinfo); 96 show_fdinfo(m, f, inotify_fdinfo);
106} 97}
107 98
108#endif /* CONFIG_INOTIFY_USER */ 99#endif /* CONFIG_INOTIFY_USER */
109 100
110#ifdef CONFIG_FANOTIFY 101#ifdef CONFIG_FANOTIFY
111 102
112static int fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark) 103static void fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
113{ 104{
114 unsigned int mflags = 0; 105 unsigned int mflags = 0;
115 struct inode *inode; 106 struct inode *inode;
116 int ret = 0;
117 107
118 if (!(mark->flags & FSNOTIFY_MARK_FLAG_ALIVE)) 108 if (!(mark->flags & FSNOTIFY_MARK_FLAG_ALIVE))
119 return 0; 109 return;
120 110
121 if (mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY) 111 if (mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY)
122 mflags |= FAN_MARK_IGNORED_SURV_MODIFY; 112 mflags |= FAN_MARK_IGNORED_SURV_MODIFY;
@@ -124,26 +114,22 @@ static int fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
124 if (mark->flags & FSNOTIFY_MARK_FLAG_INODE) { 114 if (mark->flags & FSNOTIFY_MARK_FLAG_INODE) {
125 inode = igrab(mark->i.inode); 115 inode = igrab(mark->i.inode);
126 if (!inode) 116 if (!inode)
127 goto out; 117 return;
128 ret = seq_printf(m, "fanotify ino:%lx sdev:%x " 118 seq_printf(m, "fanotify ino:%lx sdev:%x mflags:%x mask:%x ignored_mask:%x ",
129 "mflags:%x mask:%x ignored_mask:%x ", 119 inode->i_ino, inode->i_sb->s_dev,
130 inode->i_ino, inode->i_sb->s_dev, 120 mflags, mark->mask, mark->ignored_mask);
131 mflags, mark->mask, mark->ignored_mask); 121 show_mark_fhandle(m, inode);
132 ret |= show_mark_fhandle(m, inode); 122 seq_putc(m, '\n');
133 ret |= seq_putc(m, '\n');
134 iput(inode); 123 iput(inode);
135 } else if (mark->flags & FSNOTIFY_MARK_FLAG_VFSMOUNT) { 124 } else if (mark->flags & FSNOTIFY_MARK_FLAG_VFSMOUNT) {
136 struct mount *mnt = real_mount(mark->m.mnt); 125 struct mount *mnt = real_mount(mark->m.mnt);
137 126
138 ret = seq_printf(m, "fanotify mnt_id:%x mflags:%x mask:%x " 127 seq_printf(m, "fanotify mnt_id:%x mflags:%x mask:%x ignored_mask:%x\n",
139 "ignored_mask:%x\n", mnt->mnt_id, mflags, 128 mnt->mnt_id, mflags, mark->mask, mark->ignored_mask);
140 mark->mask, mark->ignored_mask);
141 } 129 }
142out:
143 return ret;
144} 130}
145 131
146int fanotify_show_fdinfo(struct seq_file *m, struct file *f) 132void fanotify_show_fdinfo(struct seq_file *m, struct file *f)
147{ 133{
148 struct fsnotify_group *group = f->private_data; 134 struct fsnotify_group *group = f->private_data;
149 unsigned int flags = 0; 135 unsigned int flags = 0;
@@ -169,7 +155,7 @@ int fanotify_show_fdinfo(struct seq_file *m, struct file *f)
169 seq_printf(m, "fanotify flags:%x event-flags:%x\n", 155 seq_printf(m, "fanotify flags:%x event-flags:%x\n",
170 flags, group->fanotify_data.f_flags); 156 flags, group->fanotify_data.f_flags);
171 157
172 return show_fdinfo(m, f, fanotify_fdinfo); 158 show_fdinfo(m, f, fanotify_fdinfo);
173} 159}
174 160
175#endif /* CONFIG_FANOTIFY */ 161#endif /* CONFIG_FANOTIFY */
diff --git a/fs/notify/fdinfo.h b/fs/notify/fdinfo.h
index 556afda990e9..9664c4904d6b 100644
--- a/fs/notify/fdinfo.h
+++ b/fs/notify/fdinfo.h
@@ -10,11 +10,11 @@ struct file;
10#ifdef CONFIG_PROC_FS 10#ifdef CONFIG_PROC_FS
11 11
12#ifdef CONFIG_INOTIFY_USER 12#ifdef CONFIG_INOTIFY_USER
13extern int inotify_show_fdinfo(struct seq_file *m, struct file *f); 13void inotify_show_fdinfo(struct seq_file *m, struct file *f);
14#endif 14#endif
15 15
16#ifdef CONFIG_FANOTIFY 16#ifdef CONFIG_FANOTIFY
17extern int fanotify_show_fdinfo(struct seq_file *m, struct file *f); 17void fanotify_show_fdinfo(struct seq_file *m, struct file *f);
18#endif 18#endif
19 19
20#else /* CONFIG_PROC_FS */ 20#else /* CONFIG_PROC_FS */
diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
index 9d3e9c50066a..41e39102743a 100644
--- a/fs/notify/fsnotify.c
+++ b/fs/notify/fsnotify.c
@@ -63,14 +63,14 @@ void __fsnotify_update_child_dentry_flags(struct inode *inode)
63 spin_lock(&inode->i_lock); 63 spin_lock(&inode->i_lock);
64 /* run all of the dentries associated with this inode. Since this is a 64 /* run all of the dentries associated with this inode. Since this is a
65 * directory, there damn well better only be one item on this list */ 65 * directory, there damn well better only be one item on this list */
66 hlist_for_each_entry(alias, &inode->i_dentry, d_alias) { 66 hlist_for_each_entry(alias, &inode->i_dentry, d_u.d_alias) {
67 struct dentry *child; 67 struct dentry *child;
68 68
69 /* run all of the children of the original inode and fix their 69 /* run all of the children of the original inode and fix their
70 * d_flags to indicate parental interest (their parent is the 70 * d_flags to indicate parental interest (their parent is the
71 * original inode) */ 71 * original inode) */
72 spin_lock(&alias->d_lock); 72 spin_lock(&alias->d_lock);
73 list_for_each_entry(child, &alias->d_subdirs, d_u.d_child) { 73 list_for_each_entry(child, &alias->d_subdirs, d_child) {
74 if (!child->d_inode) 74 if (!child->d_inode)
75 continue; 75 continue;
76 76
@@ -229,8 +229,16 @@ int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is,
229 &fsnotify_mark_srcu); 229 &fsnotify_mark_srcu);
230 } 230 }
231 231
232 /*
233 * We need to merge inode & vfsmount mark lists so that inode mark
234 * ignore masks are properly reflected for mount mark notifications.
235 * That's why this traversal is so complicated...
236 */
232 while (inode_node || vfsmount_node) { 237 while (inode_node || vfsmount_node) {
233 inode_group = vfsmount_group = NULL; 238 inode_group = NULL;
239 inode_mark = NULL;
240 vfsmount_group = NULL;
241 vfsmount_mark = NULL;
234 242
235 if (inode_node) { 243 if (inode_node) {
236 inode_mark = hlist_entry(srcu_dereference(inode_node, &fsnotify_mark_srcu), 244 inode_mark = hlist_entry(srcu_dereference(inode_node, &fsnotify_mark_srcu),
@@ -244,21 +252,19 @@ int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is,
244 vfsmount_group = vfsmount_mark->group; 252 vfsmount_group = vfsmount_mark->group;
245 } 253 }
246 254
247 if (inode_group > vfsmount_group) { 255 if (inode_group && vfsmount_group) {
248 /* handle inode */ 256 int cmp = fsnotify_compare_groups(inode_group,
249 ret = send_to_group(to_tell, inode_mark, NULL, mask, 257 vfsmount_group);
250 data, data_is, cookie, file_name); 258 if (cmp > 0) {
251 /* we didn't use the vfsmount_mark */ 259 inode_group = NULL;
252 vfsmount_group = NULL; 260 inode_mark = NULL;
253 } else if (vfsmount_group > inode_group) { 261 } else if (cmp < 0) {
254 ret = send_to_group(to_tell, NULL, vfsmount_mark, mask, 262 vfsmount_group = NULL;
255 data, data_is, cookie, file_name); 263 vfsmount_mark = NULL;
256 inode_group = NULL; 264 }
257 } else {
258 ret = send_to_group(to_tell, inode_mark, vfsmount_mark,
259 mask, data, data_is, cookie,
260 file_name);
261 } 265 }
266 ret = send_to_group(to_tell, inode_mark, vfsmount_mark, mask,
267 data, data_is, cookie, file_name);
262 268
263 if (ret && (mask & ALL_FSNOTIFY_PERM_EVENTS)) 269 if (ret && (mask & ALL_FSNOTIFY_PERM_EVENTS))
264 goto out; 270 goto out;
diff --git a/fs/notify/fsnotify.h b/fs/notify/fsnotify.h
index 9c0898c4cfe1..3b68b0ae0a97 100644
--- a/fs/notify/fsnotify.h
+++ b/fs/notify/fsnotify.h
@@ -12,6 +12,10 @@ extern void fsnotify_flush_notify(struct fsnotify_group *group);
12/* protects reads of inode and vfsmount marks list */ 12/* protects reads of inode and vfsmount marks list */
13extern struct srcu_struct fsnotify_mark_srcu; 13extern struct srcu_struct fsnotify_mark_srcu;
14 14
15/* compare two groups for sorting of marks lists */
16extern int fsnotify_compare_groups(struct fsnotify_group *a,
17 struct fsnotify_group *b);
18
15extern void fsnotify_set_inode_mark_mask_locked(struct fsnotify_mark *fsn_mark, 19extern void fsnotify_set_inode_mark_mask_locked(struct fsnotify_mark *fsn_mark,
16 __u32 mask); 20 __u32 mask);
17/* add a mark to an inode */ 21/* add a mark to an inode */
diff --git a/fs/notify/inode_mark.c b/fs/notify/inode_mark.c
index 9ce062218de9..dfbf5447eea4 100644
--- a/fs/notify/inode_mark.c
+++ b/fs/notify/inode_mark.c
@@ -194,6 +194,7 @@ int fsnotify_add_inode_mark(struct fsnotify_mark *mark,
194{ 194{
195 struct fsnotify_mark *lmark, *last = NULL; 195 struct fsnotify_mark *lmark, *last = NULL;
196 int ret = 0; 196 int ret = 0;
197 int cmp;
197 198
198 mark->flags |= FSNOTIFY_MARK_FLAG_INODE; 199 mark->flags |= FSNOTIFY_MARK_FLAG_INODE;
199 200
@@ -219,11 +220,8 @@ int fsnotify_add_inode_mark(struct fsnotify_mark *mark,
219 goto out; 220 goto out;
220 } 221 }
221 222
222 if (mark->group->priority < lmark->group->priority) 223 cmp = fsnotify_compare_groups(lmark->group, mark->group);
223 continue; 224 if (cmp < 0)
224
225 if ((mark->group->priority == lmark->group->priority) &&
226 (mark->group < lmark->group))
227 continue; 225 continue;
228 226
229 hlist_add_before_rcu(&mark->i.i_list, &lmark->i.i_list); 227 hlist_add_before_rcu(&mark->i.i_list, &lmark->i.i_list);
@@ -288,20 +286,25 @@ void fsnotify_unmount_inodes(struct list_head *list)
288 spin_unlock(&inode->i_lock); 286 spin_unlock(&inode->i_lock);
289 287
290 /* In case the dropping of a reference would nuke next_i. */ 288 /* In case the dropping of a reference would nuke next_i. */
291 if ((&next_i->i_sb_list != list) && 289 while (&next_i->i_sb_list != list) {
292 atomic_read(&next_i->i_count)) {
293 spin_lock(&next_i->i_lock); 290 spin_lock(&next_i->i_lock);
294 if (!(next_i->i_state & (I_FREEING | I_WILL_FREE))) { 291 if (!(next_i->i_state & (I_FREEING | I_WILL_FREE)) &&
292 atomic_read(&next_i->i_count)) {
295 __iget(next_i); 293 __iget(next_i);
296 need_iput = next_i; 294 need_iput = next_i;
295 spin_unlock(&next_i->i_lock);
296 break;
297 } 297 }
298 spin_unlock(&next_i->i_lock); 298 spin_unlock(&next_i->i_lock);
299 next_i = list_entry(next_i->i_sb_list.next,
300 struct inode, i_sb_list);
299 } 301 }
300 302
301 /* 303 /*
302 * We can safely drop inode_sb_list_lock here because we hold 304 * We can safely drop inode_sb_list_lock here because either
303 * references on both inode and next_i. Also no new inodes 305 * we actually hold references on both inode and next_i or
304 * will be added since the umount has begun. 306 * end of list. Also no new inodes will be added since the
307 * umount has begun.
305 */ 308 */
306 spin_unlock(&inode_sb_list_lock); 309 spin_unlock(&inode_sb_list_lock);
307 310
diff --git a/fs/notify/mark.c b/fs/notify/mark.c
index d90deaa08e78..34c38fabf514 100644
--- a/fs/notify/mark.c
+++ b/fs/notify/mark.c
@@ -210,6 +210,42 @@ void fsnotify_set_mark_ignored_mask_locked(struct fsnotify_mark *mark, __u32 mas
210} 210}
211 211
212/* 212/*
213 * Sorting function for lists of fsnotify marks.
214 *
215 * Fanotify supports different notification classes (reflected as priority of
216 * notification group). Events shall be passed to notification groups in
217 * decreasing priority order. To achieve this marks in notification lists for
218 * inodes and vfsmounts are sorted so that priorities of corresponding groups
219 * are descending.
220 *
221 * Furthermore correct handling of the ignore mask requires processing inode
222 * and vfsmount marks of each group together. Using the group address as
223 * further sort criterion provides a unique sorting order and thus we can
224 * merge inode and vfsmount lists of marks in linear time and find groups
225 * present in both lists.
226 *
227 * A return value of 1 signifies that b has priority over a.
228 * A return value of 0 signifies that the two marks have to be handled together.
229 * A return value of -1 signifies that a has priority over b.
230 */
231int fsnotify_compare_groups(struct fsnotify_group *a, struct fsnotify_group *b)
232{
233 if (a == b)
234 return 0;
235 if (!a)
236 return 1;
237 if (!b)
238 return -1;
239 if (a->priority < b->priority)
240 return 1;
241 if (a->priority > b->priority)
242 return -1;
243 if (a < b)
244 return 1;
245 return -1;
246}
247
248/*
213 * Attach an initialized mark to a given group and fs object. 249 * Attach an initialized mark to a given group and fs object.
214 * These marks may be used for the fsnotify backend to determine which 250 * These marks may be used for the fsnotify backend to determine which
215 * event types should be delivered to which group. 251 * event types should be delivered to which group.
diff --git a/fs/notify/vfsmount_mark.c b/fs/notify/vfsmount_mark.c
index ac851e8376b1..faefa72a11eb 100644
--- a/fs/notify/vfsmount_mark.c
+++ b/fs/notify/vfsmount_mark.c
@@ -153,6 +153,7 @@ int fsnotify_add_vfsmount_mark(struct fsnotify_mark *mark,
153 struct mount *m = real_mount(mnt); 153 struct mount *m = real_mount(mnt);
154 struct fsnotify_mark *lmark, *last = NULL; 154 struct fsnotify_mark *lmark, *last = NULL;
155 int ret = 0; 155 int ret = 0;
156 int cmp;
156 157
157 mark->flags |= FSNOTIFY_MARK_FLAG_VFSMOUNT; 158 mark->flags |= FSNOTIFY_MARK_FLAG_VFSMOUNT;
158 159
@@ -178,11 +179,8 @@ int fsnotify_add_vfsmount_mark(struct fsnotify_mark *mark,
178 goto out; 179 goto out;
179 } 180 }
180 181
181 if (mark->group->priority < lmark->group->priority) 182 cmp = fsnotify_compare_groups(lmark->group, mark->group);
182 continue; 183 if (cmp < 0)
183
184 if ((mark->group->priority == lmark->group->priority) &&
185 (mark->group < lmark->group))
186 continue; 184 continue;
187 185
188 hlist_add_before_rcu(&mark->m.m_list, &lmark->m.m_list); 186 hlist_add_before_rcu(&mark->m.m_list, &lmark->m.m_list);
diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c
index 436f36037e09..b3973c2fd190 100644
--- a/fs/ntfs/namei.c
+++ b/fs/ntfs/namei.c
@@ -111,8 +111,8 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent,
111 unsigned long dent_ino; 111 unsigned long dent_ino;
112 int uname_len; 112 int uname_len;
113 113
114 ntfs_debug("Looking up %s in directory inode 0x%lx.", 114 ntfs_debug("Looking up %pd in directory inode 0x%lx.",
115 dent->d_name.name, dir_ino->i_ino); 115 dent, dir_ino->i_ino);
116 /* Convert the name of the dentry to Unicode. */ 116 /* Convert the name of the dentry to Unicode. */
117 uname_len = ntfs_nlstoucs(vol, dent->d_name.name, dent->d_name.len, 117 uname_len = ntfs_nlstoucs(vol, dent->d_name.name, dent->d_name.len,
118 &uname); 118 &uname);
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c
index 97de0fbd9f78..a96044004064 100644
--- a/fs/ocfs2/cluster/tcp.c
+++ b/fs/ocfs2/cluster/tcp.c
@@ -925,7 +925,7 @@ static int o2net_send_tcp_msg(struct socket *sock, struct kvec *vec,
925 size_t veclen, size_t total) 925 size_t veclen, size_t total)
926{ 926{
927 int ret; 927 int ret;
928 struct msghdr msg; 928 struct msghdr msg = {.msg_flags = 0,};
929 929
930 if (sock == NULL) { 930 if (sock == NULL) {
931 ret = -EINVAL; 931 ret = -EINVAL;
diff --git a/fs/ocfs2/dcache.c b/fs/ocfs2/dcache.c
index e2e05a106beb..4fda7a5f3088 100644
--- a/fs/ocfs2/dcache.c
+++ b/fs/ocfs2/dcache.c
@@ -172,7 +172,7 @@ struct dentry *ocfs2_find_local_alias(struct inode *inode,
172 struct dentry *dentry; 172 struct dentry *dentry;
173 173
174 spin_lock(&inode->i_lock); 174 spin_lock(&inode->i_lock);
175 hlist_for_each_entry(dentry, &inode->i_dentry, d_alias) { 175 hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) {
176 spin_lock(&dentry->d_lock); 176 spin_lock(&dentry->d_lock);
177 if (ocfs2_match_dentry(dentry, parent_blkno, skip_unhashed)) { 177 if (ocfs2_match_dentry(dentry, parent_blkno, skip_unhashed)) {
178 trace_ocfs2_find_local_alias(dentry->d_name.len, 178 trace_ocfs2_find_local_alias(dentry->d_name.len,
@@ -251,8 +251,8 @@ int ocfs2_dentry_attach_lock(struct dentry *dentry,
251 251
252 if (dl) { 252 if (dl) {
253 mlog_bug_on_msg(dl->dl_parent_blkno != parent_blkno, 253 mlog_bug_on_msg(dl->dl_parent_blkno != parent_blkno,
254 " \"%.*s\": old parent: %llu, new: %llu\n", 254 " \"%pd\": old parent: %llu, new: %llu\n",
255 dentry->d_name.len, dentry->d_name.name, 255 dentry,
256 (unsigned long long)parent_blkno, 256 (unsigned long long)parent_blkno,
257 (unsigned long long)dl->dl_parent_blkno); 257 (unsigned long long)dl->dl_parent_blkno);
258 return 0; 258 return 0;
@@ -277,8 +277,8 @@ int ocfs2_dentry_attach_lock(struct dentry *dentry,
277 (unsigned long long)OCFS2_I(inode)->ip_blkno); 277 (unsigned long long)OCFS2_I(inode)->ip_blkno);
278 278
279 mlog_bug_on_msg(dl->dl_parent_blkno != parent_blkno, 279 mlog_bug_on_msg(dl->dl_parent_blkno != parent_blkno,
280 " \"%.*s\": old parent: %llu, new: %llu\n", 280 " \"%pd\": old parent: %llu, new: %llu\n",
281 dentry->d_name.len, dentry->d_name.name, 281 dentry,
282 (unsigned long long)parent_blkno, 282 (unsigned long long)parent_blkno,
283 (unsigned long long)dl->dl_parent_blkno); 283 (unsigned long long)dl->dl_parent_blkno);
284 284
@@ -406,17 +406,15 @@ static void ocfs2_dentry_iput(struct dentry *dentry, struct inode *inode)
406 if (inode) 406 if (inode)
407 ino = (unsigned long long)OCFS2_I(inode)->ip_blkno; 407 ino = (unsigned long long)OCFS2_I(inode)->ip_blkno;
408 mlog(ML_ERROR, "Dentry is missing cluster lock. " 408 mlog(ML_ERROR, "Dentry is missing cluster lock. "
409 "inode: %llu, d_flags: 0x%x, d_name: %.*s\n", 409 "inode: %llu, d_flags: 0x%x, d_name: %pd\n",
410 ino, dentry->d_flags, dentry->d_name.len, 410 ino, dentry->d_flags, dentry);
411 dentry->d_name.name);
412 } 411 }
413 412
414 goto out; 413 goto out;
415 } 414 }
416 415
417 mlog_bug_on_msg(dl->dl_count == 0, "dentry: %.*s, count: %u\n", 416 mlog_bug_on_msg(dl->dl_count == 0, "dentry: %pd, count: %u\n",
418 dentry->d_name.len, dentry->d_name.name, 417 dentry, dl->dl_count);
419 dl->dl_count);
420 418
421 ocfs2_dentry_lock_put(OCFS2_SB(dentry->d_sb), dl); 419 ocfs2_dentry_lock_put(OCFS2_SB(dentry->d_sb), dl);
422 420
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 0717662b4aef..c43d9b4a1ec0 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -2073,10 +2073,12 @@ struct ocfs2_empty_dir_priv {
2073 unsigned seen_other; 2073 unsigned seen_other;
2074 unsigned dx_dir; 2074 unsigned dx_dir;
2075}; 2075};
2076static int ocfs2_empty_dir_filldir(void *priv, const char *name, int name_len, 2076static int ocfs2_empty_dir_filldir(struct dir_context *ctx, const char *name,
2077 loff_t pos, u64 ino, unsigned type) 2077 int name_len, loff_t pos, u64 ino,
2078 unsigned type)
2078{ 2079{
2079 struct ocfs2_empty_dir_priv *p = priv; 2080 struct ocfs2_empty_dir_priv *p =
2081 container_of(ctx, struct ocfs2_empty_dir_priv, ctx);
2080 2082
2081 /* 2083 /*
2082 * Check the positions of "." and ".." records to be sure 2084 * Check the positions of "." and ".." records to be sure
diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c
index 09b7d9dac71d..57c40e34f56f 100644
--- a/fs/ocfs2/dlmfs/dlmfs.c
+++ b/fs/ocfs2/dlmfs/dlmfs.c
@@ -565,8 +565,8 @@ static int dlmfs_unlink(struct inode *dir,
565 * to acquire a lock, this basically destroys our lockres. */ 565 * to acquire a lock, this basically destroys our lockres. */
566 status = user_dlm_destroy_lock(&DLMFS_I(inode)->ip_lockres); 566 status = user_dlm_destroy_lock(&DLMFS_I(inode)->ip_lockres);
567 if (status < 0) { 567 if (status < 0) {
568 mlog(ML_ERROR, "unlink %.*s, error %d from destroy\n", 568 mlog(ML_ERROR, "unlink %pd, error %d from destroy\n",
569 dentry->d_name.len, dentry->d_name.name, status); 569 dentry, status);
570 goto bail; 570 goto bail;
571 } 571 }
572 status = simple_unlink(dir, dentry); 572 status = simple_unlink(dir, dentry);
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 21262f2b1654..37297c14f9a3 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -3725,8 +3725,7 @@ static int ocfs2_dentry_convert_worker(struct ocfs2_lock_res *lockres,
3725 break; 3725 break;
3726 spin_unlock(&dentry_attach_lock); 3726 spin_unlock(&dentry_attach_lock);
3727 3727
3728 mlog(0, "d_delete(%.*s);\n", dentry->d_name.len, 3728 mlog(0, "d_delete(%pd);\n", dentry);
3729 dentry->d_name.name);
3730 3729
3731 /* 3730 /*
3732 * The following dcache calls may do an 3731 * The following dcache calls may do an
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index 4b0c68849b36..4f502382180f 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -1982,10 +1982,12 @@ struct ocfs2_orphan_filldir_priv {
1982 struct ocfs2_super *osb; 1982 struct ocfs2_super *osb;
1983}; 1983};
1984 1984
1985static int ocfs2_orphan_filldir(void *priv, const char *name, int name_len, 1985static int ocfs2_orphan_filldir(struct dir_context *ctx, const char *name,
1986 loff_t pos, u64 ino, unsigned type) 1986 int name_len, loff_t pos, u64 ino,
1987 unsigned type)
1987{ 1988{
1988 struct ocfs2_orphan_filldir_priv *p = priv; 1989 struct ocfs2_orphan_filldir_priv *p =
1990 container_of(ctx, struct ocfs2_orphan_filldir_priv, ctx);
1989 struct inode *iter; 1991 struct inode *iter;
1990 1992
1991 if (name_len == 1 && !strncmp(".", name, 1)) 1993 if (name_len == 1 && !strncmp(".", name, 1))
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 8add6f1030d7..b931e04e3388 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -158,7 +158,7 @@ bail_add:
158 * NOTE: This dentry already has ->d_op set from 158 * NOTE: This dentry already has ->d_op set from
159 * ocfs2_get_parent() and ocfs2_get_dentry() 159 * ocfs2_get_parent() and ocfs2_get_dentry()
160 */ 160 */
161 if (ret) 161 if (!IS_ERR_OR_NULL(ret))
162 dentry = ret; 162 dentry = ret;
163 163
164 status = ocfs2_dentry_attach_lock(dentry, inode, 164 status = ocfs2_dentry_attach_lock(dentry, inode,
diff --git a/fs/open.c b/fs/open.c
index de92c13b58be..b1bf3d542d5d 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -516,7 +516,7 @@ SYSCALL_DEFINE2(fchmod, unsigned int, fd, umode_t, mode)
516 int err = -EBADF; 516 int err = -EBADF;
517 517
518 if (f.file) { 518 if (f.file) {
519 audit_inode(NULL, f.file->f_path.dentry, 0); 519 audit_file(f.file);
520 err = chmod_common(&f.file->f_path, mode); 520 err = chmod_common(&f.file->f_path, mode);
521 fdput(f); 521 fdput(f);
522 } 522 }
@@ -642,7 +642,7 @@ SYSCALL_DEFINE3(fchown, unsigned int, fd, uid_t, user, gid_t, group)
642 error = mnt_want_write_file(f.file); 642 error = mnt_want_write_file(f.file);
643 if (error) 643 if (error)
644 goto out_fput; 644 goto out_fput;
645 audit_inode(NULL, f.file->f_path.dentry, 0); 645 audit_file(f.file);
646 error = chown_common(&f.file->f_path, user, group); 646 error = chown_common(&f.file->f_path, user, group);
647 mnt_drop_write_file(f.file); 647 mnt_drop_write_file(f.file);
648out_fput: 648out_fput:
diff --git a/fs/overlayfs/Kconfig b/fs/overlayfs/Kconfig
index e60125976873..34355818a2e0 100644
--- a/fs/overlayfs/Kconfig
+++ b/fs/overlayfs/Kconfig
@@ -1,4 +1,4 @@
1config OVERLAYFS_FS 1config OVERLAY_FS
2 tristate "Overlay filesystem support" 2 tristate "Overlay filesystem support"
3 help 3 help
4 An overlay filesystem combines two filesystems - an 'upper' filesystem 4 An overlay filesystem combines two filesystems - an 'upper' filesystem
diff --git a/fs/overlayfs/Makefile b/fs/overlayfs/Makefile
index 8f91889480d0..900daed3e91d 100644
--- a/fs/overlayfs/Makefile
+++ b/fs/overlayfs/Makefile
@@ -2,6 +2,6 @@
2# Makefile for the overlay filesystem. 2# Makefile for the overlay filesystem.
3# 3#
4 4
5obj-$(CONFIG_OVERLAYFS_FS) += overlayfs.o 5obj-$(CONFIG_OVERLAY_FS) += overlay.o
6 6
7overlayfs-objs := super.o inode.o dir.o readdir.o copy_up.o 7overlay-objs := super.o inode.o dir.o readdir.o copy_up.o
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 15cd91ad9940..8ffc4b980f1b 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -284,8 +284,7 @@ out:
284 return ERR_PTR(err); 284 return ERR_PTR(err);
285} 285}
286 286
287static struct dentry *ovl_check_empty_and_clear(struct dentry *dentry, 287static struct dentry *ovl_check_empty_and_clear(struct dentry *dentry)
288 enum ovl_path_type type)
289{ 288{
290 int err; 289 int err;
291 struct dentry *ret = NULL; 290 struct dentry *ret = NULL;
@@ -294,8 +293,17 @@ static struct dentry *ovl_check_empty_and_clear(struct dentry *dentry,
294 err = ovl_check_empty_dir(dentry, &list); 293 err = ovl_check_empty_dir(dentry, &list);
295 if (err) 294 if (err)
296 ret = ERR_PTR(err); 295 ret = ERR_PTR(err);
297 else if (type == OVL_PATH_MERGE) 296 else {
298 ret = ovl_clear_empty(dentry, &list); 297 /*
298 * If no upperdentry then skip clearing whiteouts.
299 *
300 * Can race with copy-up, since we don't hold the upperdir
301 * mutex. Doesn't matter, since copy-up can't create a
302 * non-empty directory from an empty one.
303 */
304 if (ovl_dentry_upper(dentry))
305 ret = ovl_clear_empty(dentry, &list);
306 }
299 307
300 ovl_cache_free(&list); 308 ovl_cache_free(&list);
301 309
@@ -487,8 +495,7 @@ out:
487 return err; 495 return err;
488} 496}
489 497
490static int ovl_remove_and_whiteout(struct dentry *dentry, 498static int ovl_remove_and_whiteout(struct dentry *dentry, bool is_dir)
491 enum ovl_path_type type, bool is_dir)
492{ 499{
493 struct dentry *workdir = ovl_workdir(dentry); 500 struct dentry *workdir = ovl_workdir(dentry);
494 struct inode *wdir = workdir->d_inode; 501 struct inode *wdir = workdir->d_inode;
@@ -500,7 +507,7 @@ static int ovl_remove_and_whiteout(struct dentry *dentry,
500 int err; 507 int err;
501 508
502 if (is_dir) { 509 if (is_dir) {
503 opaquedir = ovl_check_empty_and_clear(dentry, type); 510 opaquedir = ovl_check_empty_and_clear(dentry);
504 err = PTR_ERR(opaquedir); 511 err = PTR_ERR(opaquedir);
505 if (IS_ERR(opaquedir)) 512 if (IS_ERR(opaquedir))
506 goto out; 513 goto out;
@@ -515,9 +522,10 @@ static int ovl_remove_and_whiteout(struct dentry *dentry,
515 if (IS_ERR(whiteout)) 522 if (IS_ERR(whiteout))
516 goto out_unlock; 523 goto out_unlock;
517 524
518 if (type == OVL_PATH_LOWER) { 525 upper = ovl_dentry_upper(dentry);
526 if (!upper) {
519 upper = lookup_one_len(dentry->d_name.name, upperdir, 527 upper = lookup_one_len(dentry->d_name.name, upperdir,
520 dentry->d_name.len); 528 dentry->d_name.len);
521 err = PTR_ERR(upper); 529 err = PTR_ERR(upper);
522 if (IS_ERR(upper)) 530 if (IS_ERR(upper))
523 goto kill_whiteout; 531 goto kill_whiteout;
@@ -529,7 +537,6 @@ static int ovl_remove_and_whiteout(struct dentry *dentry,
529 } else { 537 } else {
530 int flags = 0; 538 int flags = 0;
531 539
532 upper = ovl_dentry_upper(dentry);
533 if (opaquedir) 540 if (opaquedir)
534 upper = opaquedir; 541 upper = opaquedir;
535 err = -ESTALE; 542 err = -ESTALE;
@@ -648,7 +655,7 @@ static int ovl_do_remove(struct dentry *dentry, bool is_dir)
648 cap_raise(override_cred->cap_effective, CAP_CHOWN); 655 cap_raise(override_cred->cap_effective, CAP_CHOWN);
649 old_cred = override_creds(override_cred); 656 old_cred = override_creds(override_cred);
650 657
651 err = ovl_remove_and_whiteout(dentry, type, is_dir); 658 err = ovl_remove_and_whiteout(dentry, is_dir);
652 659
653 revert_creds(old_cred); 660 revert_creds(old_cred);
654 put_cred(override_cred); 661 put_cred(override_cred);
@@ -781,7 +788,7 @@ static int ovl_rename2(struct inode *olddir, struct dentry *old,
781 } 788 }
782 789
783 if (overwrite && (new_type == OVL_PATH_LOWER || new_type == OVL_PATH_MERGE) && new_is_dir) { 790 if (overwrite && (new_type == OVL_PATH_LOWER || new_type == OVL_PATH_MERGE) && new_is_dir) {
784 opaquedir = ovl_check_empty_and_clear(new, new_type); 791 opaquedir = ovl_check_empty_and_clear(new);
785 err = PTR_ERR(opaquedir); 792 err = PTR_ERR(opaquedir);
786 if (IS_ERR(opaquedir)) { 793 if (IS_ERR(opaquedir)) {
787 opaquedir = NULL; 794 opaquedir = NULL;
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index af2d18c9fcee..07d74b24913b 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -235,26 +235,36 @@ out:
235 return err; 235 return err;
236} 236}
237 237
238static bool ovl_need_xattr_filter(struct dentry *dentry,
239 enum ovl_path_type type)
240{
241 return type == OVL_PATH_UPPER && S_ISDIR(dentry->d_inode->i_mode);
242}
243
238ssize_t ovl_getxattr(struct dentry *dentry, const char *name, 244ssize_t ovl_getxattr(struct dentry *dentry, const char *name,
239 void *value, size_t size) 245 void *value, size_t size)
240{ 246{
241 if (ovl_path_type(dentry->d_parent) == OVL_PATH_MERGE && 247 struct path realpath;
242 ovl_is_private_xattr(name)) 248 enum ovl_path_type type = ovl_path_real(dentry, &realpath);
249
250 if (ovl_need_xattr_filter(dentry, type) && ovl_is_private_xattr(name))
243 return -ENODATA; 251 return -ENODATA;
244 252
245 return vfs_getxattr(ovl_dentry_real(dentry), name, value, size); 253 return vfs_getxattr(realpath.dentry, name, value, size);
246} 254}
247 255
248ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size) 256ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size)
249{ 257{
258 struct path realpath;
259 enum ovl_path_type type = ovl_path_real(dentry, &realpath);
250 ssize_t res; 260 ssize_t res;
251 int off; 261 int off;
252 262
253 res = vfs_listxattr(ovl_dentry_real(dentry), list, size); 263 res = vfs_listxattr(realpath.dentry, list, size);
254 if (res <= 0 || size == 0) 264 if (res <= 0 || size == 0)
255 return res; 265 return res;
256 266
257 if (ovl_path_type(dentry->d_parent) != OVL_PATH_MERGE) 267 if (!ovl_need_xattr_filter(dentry, type))
258 return res; 268 return res;
259 269
260 /* filter out private xattrs */ 270 /* filter out private xattrs */
@@ -279,17 +289,16 @@ int ovl_removexattr(struct dentry *dentry, const char *name)
279{ 289{
280 int err; 290 int err;
281 struct path realpath; 291 struct path realpath;
282 enum ovl_path_type type; 292 enum ovl_path_type type = ovl_path_real(dentry, &realpath);
283 293
284 err = ovl_want_write(dentry); 294 err = ovl_want_write(dentry);
285 if (err) 295 if (err)
286 goto out; 296 goto out;
287 297
288 if (ovl_path_type(dentry->d_parent) == OVL_PATH_MERGE && 298 err = -ENODATA;
289 ovl_is_private_xattr(name)) 299 if (ovl_need_xattr_filter(dentry, type) && ovl_is_private_xattr(name))
290 goto out_drop_write; 300 goto out_drop_write;
291 301
292 type = ovl_path_real(dentry, &realpath);
293 if (type == OVL_PATH_LOWER) { 302 if (type == OVL_PATH_LOWER) {
294 err = vfs_getxattr(realpath.dentry, name, NULL, 0); 303 err = vfs_getxattr(realpath.dentry, name, NULL, 0);
295 if (err < 0) 304 if (err < 0)
diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
index 910553f37aca..c0205990a9f5 100644
--- a/fs/overlayfs/readdir.c
+++ b/fs/overlayfs/readdir.c
@@ -21,9 +21,10 @@ struct ovl_cache_entry {
21 unsigned int len; 21 unsigned int len;
22 unsigned int type; 22 unsigned int type;
23 u64 ino; 23 u64 ino;
24 bool is_whiteout;
25 struct list_head l_node; 24 struct list_head l_node;
26 struct rb_node node; 25 struct rb_node node;
26 bool is_whiteout;
27 bool is_cursor;
27 char name[]; 28 char name[];
28}; 29};
29 30
@@ -92,6 +93,7 @@ static struct ovl_cache_entry *ovl_cache_entry_new(const char *name, int len,
92 p->type = d_type; 93 p->type = d_type;
93 p->ino = ino; 94 p->ino = ino;
94 p->is_whiteout = false; 95 p->is_whiteout = false;
96 p->is_cursor = false;
95 } 97 }
96 98
97 return p; 99 return p;
@@ -166,7 +168,7 @@ static void ovl_cache_put(struct ovl_dir_file *od, struct dentry *dentry)
166{ 168{
167 struct ovl_dir_cache *cache = od->cache; 169 struct ovl_dir_cache *cache = od->cache;
168 170
169 list_del(&od->cursor.l_node); 171 list_del_init(&od->cursor.l_node);
170 WARN_ON(cache->refcount <= 0); 172 WARN_ON(cache->refcount <= 0);
171 cache->refcount--; 173 cache->refcount--;
172 if (!cache->refcount) { 174 if (!cache->refcount) {
@@ -178,10 +180,12 @@ static void ovl_cache_put(struct ovl_dir_file *od, struct dentry *dentry)
178 } 180 }
179} 181}
180 182
181static int ovl_fill_merge(void *buf, const char *name, int namelen, 183static int ovl_fill_merge(struct dir_context *ctx, const char *name,
182 loff_t offset, u64 ino, unsigned int d_type) 184 int namelen, loff_t offset, u64 ino,
185 unsigned int d_type)
183{ 186{
184 struct ovl_readdir_data *rdd = buf; 187 struct ovl_readdir_data *rdd =
188 container_of(ctx, struct ovl_readdir_data, ctx);
185 189
186 rdd->count++; 190 rdd->count++;
187 if (!rdd->is_merge) 191 if (!rdd->is_merge)
@@ -251,7 +255,7 @@ static int ovl_dir_mark_whiteouts(struct dentry *dir,
251 255
252 mutex_lock(&dir->d_inode->i_mutex); 256 mutex_lock(&dir->d_inode->i_mutex);
253 list_for_each_entry(p, rdd->list, l_node) { 257 list_for_each_entry(p, rdd->list, l_node) {
254 if (!p->name) 258 if (p->is_cursor)
255 continue; 259 continue;
256 260
257 if (p->type != DT_CHR) 261 if (p->type != DT_CHR)
@@ -272,11 +276,11 @@ static int ovl_dir_mark_whiteouts(struct dentry *dir,
272 return 0; 276 return 0;
273} 277}
274 278
275static inline int ovl_dir_read_merged(struct path *upperpath, 279static int ovl_dir_read_merged(struct dentry *dentry, struct list_head *list)
276 struct path *lowerpath,
277 struct list_head *list)
278{ 280{
279 int err; 281 int err;
282 struct path lowerpath;
283 struct path upperpath;
280 struct ovl_readdir_data rdd = { 284 struct ovl_readdir_data rdd = {
281 .ctx.actor = ovl_fill_merge, 285 .ctx.actor = ovl_fill_merge,
282 .list = list, 286 .list = list,
@@ -284,30 +288,32 @@ static inline int ovl_dir_read_merged(struct path *upperpath,
284 .is_merge = false, 288 .is_merge = false,
285 }; 289 };
286 290
287 if (upperpath->dentry) { 291 ovl_path_lower(dentry, &lowerpath);
288 err = ovl_dir_read(upperpath, &rdd); 292 ovl_path_upper(dentry, &upperpath);
293
294 if (upperpath.dentry) {
295 err = ovl_dir_read(&upperpath, &rdd);
289 if (err) 296 if (err)
290 goto out; 297 goto out;
291 298
292 if (lowerpath->dentry) { 299 if (lowerpath.dentry) {
293 err = ovl_dir_mark_whiteouts(upperpath->dentry, &rdd); 300 err = ovl_dir_mark_whiteouts(upperpath.dentry, &rdd);
294 if (err) 301 if (err)
295 goto out; 302 goto out;
296 } 303 }
297 } 304 }
298 if (lowerpath->dentry) { 305 if (lowerpath.dentry) {
299 /* 306 /*
300 * Insert lowerpath entries before upperpath ones, this allows 307 * Insert lowerpath entries before upperpath ones, this allows
301 * offsets to be reasonably constant 308 * offsets to be reasonably constant
302 */ 309 */
303 list_add(&rdd.middle, rdd.list); 310 list_add(&rdd.middle, rdd.list);
304 rdd.is_merge = true; 311 rdd.is_merge = true;
305 err = ovl_dir_read(lowerpath, &rdd); 312 err = ovl_dir_read(&lowerpath, &rdd);
306 list_del(&rdd.middle); 313 list_del(&rdd.middle);
307 } 314 }
308out: 315out:
309 return err; 316 return err;
310
311} 317}
312 318
313static void ovl_seek_cursor(struct ovl_dir_file *od, loff_t pos) 319static void ovl_seek_cursor(struct ovl_dir_file *od, loff_t pos)
@@ -316,7 +322,7 @@ static void ovl_seek_cursor(struct ovl_dir_file *od, loff_t pos)
316 loff_t off = 0; 322 loff_t off = 0;
317 323
318 list_for_each_entry(p, &od->cache->entries, l_node) { 324 list_for_each_entry(p, &od->cache->entries, l_node) {
319 if (!p->name) 325 if (p->is_cursor)
320 continue; 326 continue;
321 if (off >= pos) 327 if (off >= pos)
322 break; 328 break;
@@ -328,8 +334,6 @@ static void ovl_seek_cursor(struct ovl_dir_file *od, loff_t pos)
328static struct ovl_dir_cache *ovl_cache_get(struct dentry *dentry) 334static struct ovl_dir_cache *ovl_cache_get(struct dentry *dentry)
329{ 335{
330 int res; 336 int res;
331 struct path lowerpath;
332 struct path upperpath;
333 struct ovl_dir_cache *cache; 337 struct ovl_dir_cache *cache;
334 338
335 cache = ovl_dir_cache(dentry); 339 cache = ovl_dir_cache(dentry);
@@ -346,10 +350,7 @@ static struct ovl_dir_cache *ovl_cache_get(struct dentry *dentry)
346 cache->refcount = 1; 350 cache->refcount = 1;
347 INIT_LIST_HEAD(&cache->entries); 351 INIT_LIST_HEAD(&cache->entries);
348 352
349 ovl_path_lower(dentry, &lowerpath); 353 res = ovl_dir_read_merged(dentry, &cache->entries);
350 ovl_path_upper(dentry, &upperpath);
351
352 res = ovl_dir_read_merged(&upperpath, &lowerpath, &cache->entries);
353 if (res) { 354 if (res) {
354 ovl_cache_free(&cache->entries); 355 ovl_cache_free(&cache->entries);
355 kfree(cache); 356 kfree(cache);
@@ -389,7 +390,7 @@ static int ovl_iterate(struct file *file, struct dir_context *ctx)
389 390
390 p = list_entry(od->cursor.l_node.next, struct ovl_cache_entry, l_node); 391 p = list_entry(od->cursor.l_node.next, struct ovl_cache_entry, l_node);
391 /* Skip cursors */ 392 /* Skip cursors */
392 if (p->name) { 393 if (!p->is_cursor) {
393 if (!p->is_whiteout) { 394 if (!p->is_whiteout) {
394 if (!dir_emit(ctx, p->name, p->len, p->ino, p->type)) 395 if (!dir_emit(ctx, p->name, p->len, p->ino, p->type))
395 break; 396 break;
@@ -451,15 +452,16 @@ static int ovl_dir_fsync(struct file *file, loff_t start, loff_t end,
451 /* 452 /*
452 * Need to check if we started out being a lower dir, but got copied up 453 * Need to check if we started out being a lower dir, but got copied up
453 */ 454 */
454 if (!od->is_upper && ovl_path_type(dentry) == OVL_PATH_MERGE) { 455 if (!od->is_upper && ovl_path_type(dentry) != OVL_PATH_LOWER) {
455 struct inode *inode = file_inode(file); 456 struct inode *inode = file_inode(file);
456 457
457 realfile = od->upperfile; 458 realfile = lockless_dereference(od->upperfile);
458 if (!realfile) { 459 if (!realfile) {
459 struct path upperpath; 460 struct path upperpath;
460 461
461 ovl_path_upper(dentry, &upperpath); 462 ovl_path_upper(dentry, &upperpath);
462 realfile = ovl_path_open(&upperpath, O_RDONLY); 463 realfile = ovl_path_open(&upperpath, O_RDONLY);
464 smp_mb__before_spinlock();
463 mutex_lock(&inode->i_mutex); 465 mutex_lock(&inode->i_mutex);
464 if (!od->upperfile) { 466 if (!od->upperfile) {
465 if (IS_ERR(realfile)) { 467 if (IS_ERR(realfile)) {
@@ -518,6 +520,7 @@ static int ovl_dir_open(struct inode *inode, struct file *file)
518 od->realfile = realfile; 520 od->realfile = realfile;
519 od->is_real = (type != OVL_PATH_MERGE); 521 od->is_real = (type != OVL_PATH_MERGE);
520 od->is_upper = (type != OVL_PATH_LOWER); 522 od->is_upper = (type != OVL_PATH_LOWER);
523 od->cursor.is_cursor = true;
521 file->private_data = od; 524 file->private_data = od;
522 525
523 return 0; 526 return 0;
@@ -535,14 +538,9 @@ const struct file_operations ovl_dir_operations = {
535int ovl_check_empty_dir(struct dentry *dentry, struct list_head *list) 538int ovl_check_empty_dir(struct dentry *dentry, struct list_head *list)
536{ 539{
537 int err; 540 int err;
538 struct path lowerpath;
539 struct path upperpath;
540 struct ovl_cache_entry *p; 541 struct ovl_cache_entry *p;
541 542
542 ovl_path_upper(dentry, &upperpath); 543 err = ovl_dir_read_merged(dentry, list);
543 ovl_path_lower(dentry, &lowerpath);
544
545 err = ovl_dir_read_merged(&upperpath, &lowerpath, list);
546 if (err) 544 if (err)
547 return err; 545 return err;
548 546
@@ -569,7 +567,7 @@ void ovl_cleanup_whiteouts(struct dentry *upper, struct list_head *list)
569{ 567{
570 struct ovl_cache_entry *p; 568 struct ovl_cache_entry *p;
571 569
572 mutex_lock_nested(&upper->d_inode->i_mutex, I_MUTEX_PARENT); 570 mutex_lock_nested(&upper->d_inode->i_mutex, I_MUTEX_CHILD);
573 list_for_each_entry(p, list, l_node) { 571 list_for_each_entry(p, list, l_node) {
574 struct dentry *dentry; 572 struct dentry *dentry;
575 573
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 08b704cebfc4..f16d318b71f8 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -24,7 +24,7 @@ MODULE_AUTHOR("Miklos Szeredi <miklos@szeredi.hu>");
24MODULE_DESCRIPTION("Overlay filesystem"); 24MODULE_DESCRIPTION("Overlay filesystem");
25MODULE_LICENSE("GPL"); 25MODULE_LICENSE("GPL");
26 26
27#define OVERLAYFS_SUPER_MAGIC 0x794c764f 27#define OVERLAYFS_SUPER_MAGIC 0x794c7630
28 28
29struct ovl_config { 29struct ovl_config {
30 char *lowerdir; 30 char *lowerdir;
@@ -84,12 +84,7 @@ enum ovl_path_type ovl_path_type(struct dentry *dentry)
84 84
85static struct dentry *ovl_upperdentry_dereference(struct ovl_entry *oe) 85static struct dentry *ovl_upperdentry_dereference(struct ovl_entry *oe)
86{ 86{
87 struct dentry *upperdentry = ACCESS_ONCE(oe->__upperdentry); 87 return lockless_dereference(oe->__upperdentry);
88 /*
89 * Make sure to order reads to upperdentry wrt ovl_dentry_update()
90 */
91 smp_read_barrier_depends();
92 return upperdentry;
93} 88}
94 89
95void ovl_path_upper(struct dentry *dentry, struct path *path) 90void ovl_path_upper(struct dentry *dentry, struct path *path)
@@ -462,11 +457,34 @@ static const match_table_t ovl_tokens = {
462 {OPT_ERR, NULL} 457 {OPT_ERR, NULL}
463}; 458};
464 459
460static char *ovl_next_opt(char **s)
461{
462 char *sbegin = *s;
463 char *p;
464
465 if (sbegin == NULL)
466 return NULL;
467
468 for (p = sbegin; *p; p++) {
469 if (*p == '\\') {
470 p++;
471 if (!*p)
472 break;
473 } else if (*p == ',') {
474 *p = '\0';
475 *s = p + 1;
476 return sbegin;
477 }
478 }
479 *s = NULL;
480 return sbegin;
481}
482
465static int ovl_parse_opt(char *opt, struct ovl_config *config) 483static int ovl_parse_opt(char *opt, struct ovl_config *config)
466{ 484{
467 char *p; 485 char *p;
468 486
469 while ((p = strsep(&opt, ",")) != NULL) { 487 while ((p = ovl_next_opt(&opt)) != NULL) {
470 int token; 488 int token;
471 substring_t args[MAX_OPT_ARGS]; 489 substring_t args[MAX_OPT_ARGS];
472 490
@@ -554,15 +572,34 @@ out_dput:
554 goto out_unlock; 572 goto out_unlock;
555} 573}
556 574
575static void ovl_unescape(char *s)
576{
577 char *d = s;
578
579 for (;; s++, d++) {
580 if (*s == '\\')
581 s++;
582 *d = *s;
583 if (!*s)
584 break;
585 }
586}
587
557static int ovl_mount_dir(const char *name, struct path *path) 588static int ovl_mount_dir(const char *name, struct path *path)
558{ 589{
559 int err; 590 int err;
591 char *tmp = kstrdup(name, GFP_KERNEL);
592
593 if (!tmp)
594 return -ENOMEM;
560 595
561 err = kern_path(name, LOOKUP_FOLLOW, path); 596 ovl_unescape(tmp);
597 err = kern_path(tmp, LOOKUP_FOLLOW, path);
562 if (err) { 598 if (err) {
563 pr_err("overlayfs: failed to resolve '%s': %i\n", name, err); 599 pr_err("overlayfs: failed to resolve '%s': %i\n", tmp, err);
564 err = -EINVAL; 600 err = -EINVAL;
565 } 601 }
602 kfree(tmp);
566 return err; 603 return err;
567} 604}
568 605
@@ -776,11 +813,11 @@ static struct dentry *ovl_mount(struct file_system_type *fs_type, int flags,
776 813
777static struct file_system_type ovl_fs_type = { 814static struct file_system_type ovl_fs_type = {
778 .owner = THIS_MODULE, 815 .owner = THIS_MODULE,
779 .name = "overlayfs", 816 .name = "overlay",
780 .mount = ovl_mount, 817 .mount = ovl_mount,
781 .kill_sb = kill_anon_super, 818 .kill_sb = kill_anon_super,
782}; 819};
783MODULE_ALIAS_FS("overlayfs"); 820MODULE_ALIAS_FS("overlay");
784 821
785static int __init ovl_init(void) 822static int __init ovl_init(void)
786{ 823{
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 772efa45a452..64891f3e41bd 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -2789,7 +2789,7 @@ retry:
2789int proc_pid_readdir(struct file *file, struct dir_context *ctx) 2789int proc_pid_readdir(struct file *file, struct dir_context *ctx)
2790{ 2790{
2791 struct tgid_iter iter; 2791 struct tgid_iter iter;
2792 struct pid_namespace *ns = file->f_dentry->d_sb->s_fs_info; 2792 struct pid_namespace *ns = file_inode(file)->i_sb->s_fs_info;
2793 loff_t pos = ctx->pos; 2793 loff_t pos = ctx->pos;
2794 2794
2795 if (pos >= PID_MAX_LIMIT + TGID_OFFSET) 2795 if (pos >= PID_MAX_LIMIT + TGID_OFFSET)
@@ -3095,7 +3095,7 @@ static int proc_task_readdir(struct file *file, struct dir_context *ctx)
3095 /* f_version caches the tgid value that the last readdir call couldn't 3095 /* f_version caches the tgid value that the last readdir call couldn't
3096 * return. lseek aka telldir automagically resets f_version to 0. 3096 * return. lseek aka telldir automagically resets f_version to 0.
3097 */ 3097 */
3098 ns = file->f_dentry->d_sb->s_fs_info; 3098 ns = inode->i_sb->s_fs_info;
3099 tid = (int)file->f_version; 3099 tid = (int)file->f_version;
3100 file->f_version = 0; 3100 file->f_version = 0;
3101 for (task = first_tid(proc_pid(inode), tid, ctx->pos - 2, ns); 3101 for (task = first_tid(proc_pid(inode), tid, ctx->pos - 2, ns);
diff --git a/fs/proc/fd.c b/fs/proc/fd.c
index e11d7c590bb0..8e5ad83b629a 100644
--- a/fs/proc/fd.c
+++ b/fs/proc/fd.c
@@ -53,7 +53,8 @@ static int seq_show(struct seq_file *m, void *v)
53 (long long)file->f_pos, f_flags, 53 (long long)file->f_pos, f_flags,
54 real_mount(file->f_path.mnt)->mnt_id); 54 real_mount(file->f_path.mnt)->mnt_id);
55 if (file->f_op->show_fdinfo) 55 if (file->f_op->show_fdinfo)
56 ret = file->f_op->show_fdinfo(m, file); 56 file->f_op->show_fdinfo(m, file);
57 ret = seq_has_overflowed(m);
57 fput(file); 58 fput(file);
58 } 59 }
59 60
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 8b663b2d9562..6b4527216a7f 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -634,7 +634,7 @@ int dquot_writeback_dquots(struct super_block *sb, int type)
634 dqstats_inc(DQST_LOOKUPS); 634 dqstats_inc(DQST_LOOKUPS);
635 err = sb->dq_op->write_dquot(dquot); 635 err = sb->dq_op->write_dquot(dquot);
636 if (!ret && err) 636 if (!ret && err)
637 err = ret; 637 ret = err;
638 dqput(dquot); 638 dqput(dquot);
639 spin_lock(&dq_list_lock); 639 spin_lock(&dq_list_lock);
640 } 640 }
diff --git a/fs/readdir.c b/fs/readdir.c
index 33fd92208cb7..ced679179cac 100644
--- a/fs/readdir.c
+++ b/fs/readdir.c
@@ -74,10 +74,11 @@ struct readdir_callback {
74 int result; 74 int result;
75}; 75};
76 76
77static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset, 77static int fillonedir(struct dir_context *ctx, const char *name, int namlen,
78 u64 ino, unsigned int d_type) 78 loff_t offset, u64 ino, unsigned int d_type)
79{ 79{
80 struct readdir_callback *buf = (struct readdir_callback *) __buf; 80 struct readdir_callback *buf =
81 container_of(ctx, struct readdir_callback, ctx);
81 struct old_linux_dirent __user * dirent; 82 struct old_linux_dirent __user * dirent;
82 unsigned long d_ino; 83 unsigned long d_ino;
83 84
@@ -148,11 +149,12 @@ struct getdents_callback {
148 int error; 149 int error;
149}; 150};
150 151
151static int filldir(void * __buf, const char * name, int namlen, loff_t offset, 152static int filldir(struct dir_context *ctx, const char *name, int namlen,
152 u64 ino, unsigned int d_type) 153 loff_t offset, u64 ino, unsigned int d_type)
153{ 154{
154 struct linux_dirent __user * dirent; 155 struct linux_dirent __user * dirent;
155 struct getdents_callback * buf = (struct getdents_callback *) __buf; 156 struct getdents_callback *buf =
157 container_of(ctx, struct getdents_callback, ctx);
156 unsigned long d_ino; 158 unsigned long d_ino;
157 int reclen = ALIGN(offsetof(struct linux_dirent, d_name) + namlen + 2, 159 int reclen = ALIGN(offsetof(struct linux_dirent, d_name) + namlen + 2,
158 sizeof(long)); 160 sizeof(long));
@@ -232,11 +234,12 @@ struct getdents_callback64 {
232 int error; 234 int error;
233}; 235};
234 236
235static int filldir64(void * __buf, const char * name, int namlen, loff_t offset, 237static int filldir64(struct dir_context *ctx, const char *name, int namlen,
236 u64 ino, unsigned int d_type) 238 loff_t offset, u64 ino, unsigned int d_type)
237{ 239{
238 struct linux_dirent64 __user *dirent; 240 struct linux_dirent64 __user *dirent;
239 struct getdents_callback64 * buf = (struct getdents_callback64 *) __buf; 241 struct getdents_callback64 *buf =
242 container_of(ctx, struct getdents_callback64, ctx);
240 int reclen = ALIGN(offsetof(struct linux_dirent64, d_name) + namlen + 1, 243 int reclen = ALIGN(offsetof(struct linux_dirent64, d_name) + namlen + 1,
241 sizeof(u64)); 244 sizeof(u64));
242 245
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index 7c36898af402..04b06146bae2 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -188,10 +188,11 @@ struct reiserfs_dentry_buf {
188}; 188};
189 189
190static int 190static int
191fill_with_dentries(void *buf, const char *name, int namelen, loff_t offset, 191fill_with_dentries(struct dir_context *ctx, const char *name, int namelen,
192 u64 ino, unsigned int d_type) 192 loff_t offset, u64 ino, unsigned int d_type)
193{ 193{
194 struct reiserfs_dentry_buf *dbuf = buf; 194 struct reiserfs_dentry_buf *dbuf =
195 container_of(ctx, struct reiserfs_dentry_buf, ctx);
195 struct dentry *dentry; 196 struct dentry *dentry;
196 197
197 WARN_ON_ONCE(!mutex_is_locked(&dbuf->xadir->d_inode->i_mutex)); 198 WARN_ON_ONCE(!mutex_is_locked(&dbuf->xadir->d_inode->i_mutex));
@@ -209,9 +210,9 @@ fill_with_dentries(void *buf, const char *name, int namelen, loff_t offset,
209 } else if (!dentry->d_inode) { 210 } else if (!dentry->d_inode) {
210 /* A directory entry exists, but no file? */ 211 /* A directory entry exists, but no file? */
211 reiserfs_error(dentry->d_sb, "xattr-20003", 212 reiserfs_error(dentry->d_sb, "xattr-20003",
212 "Corrupted directory: xattr %s listed but " 213 "Corrupted directory: xattr %pd listed but "
213 "not found for file %s.\n", 214 "not found for file %pd.\n",
214 dentry->d_name.name, dbuf->xadir->d_name.name); 215 dentry, dbuf->xadir);
215 dput(dentry); 216 dput(dentry);
216 return -EIO; 217 return -EIO;
217 } 218 }
@@ -824,10 +825,12 @@ struct listxattr_buf {
824 struct dentry *dentry; 825 struct dentry *dentry;
825}; 826};
826 827
827static int listxattr_filler(void *buf, const char *name, int namelen, 828static int listxattr_filler(struct dir_context *ctx, const char *name,
828 loff_t offset, u64 ino, unsigned int d_type) 829 int namelen, loff_t offset, u64 ino,
830 unsigned int d_type)
829{ 831{
830 struct listxattr_buf *b = (struct listxattr_buf *)buf; 832 struct listxattr_buf *b =
833 container_of(ctx, struct listxattr_buf, ctx);
831 size_t size; 834 size_t size;
832 835
833 if (name[0] != '.' || 836 if (name[0] != '.' ||
diff --git a/fs/seq_file.c b/fs/seq_file.c
index 3857b720cb1b..353948ba1c5b 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -16,17 +16,6 @@
16#include <asm/uaccess.h> 16#include <asm/uaccess.h>
17#include <asm/page.h> 17#include <asm/page.h>
18 18
19
20/*
21 * seq_files have a buffer which can may overflow. When this happens a larger
22 * buffer is reallocated and all the data will be printed again.
23 * The overflow state is true when m->count == m->size.
24 */
25static bool seq_overflow(struct seq_file *m)
26{
27 return m->count == m->size;
28}
29
30static void seq_set_overflow(struct seq_file *m) 19static void seq_set_overflow(struct seq_file *m)
31{ 20{
32 m->count = m->size; 21 m->count = m->size;
@@ -124,7 +113,7 @@ static int traverse(struct seq_file *m, loff_t offset)
124 error = 0; 113 error = 0;
125 m->count = 0; 114 m->count = 0;
126 } 115 }
127 if (seq_overflow(m)) 116 if (seq_has_overflowed(m))
128 goto Eoverflow; 117 goto Eoverflow;
129 if (pos + m->count > offset) { 118 if (pos + m->count > offset) {
130 m->from = offset - pos; 119 m->from = offset - pos;
@@ -267,7 +256,7 @@ Fill:
267 break; 256 break;
268 } 257 }
269 err = m->op->show(m, p); 258 err = m->op->show(m, p);
270 if (seq_overflow(m) || err) { 259 if (seq_has_overflowed(m) || err) {
271 m->count = offs; 260 m->count = offs;
272 if (likely(err <= 0)) 261 if (likely(err <= 0))
273 break; 262 break;
diff --git a/fs/signalfd.c b/fs/signalfd.c
index 424b7b65321f..7e412ad74836 100644
--- a/fs/signalfd.c
+++ b/fs/signalfd.c
@@ -230,7 +230,7 @@ static ssize_t signalfd_read(struct file *file, char __user *buf, size_t count,
230} 230}
231 231
232#ifdef CONFIG_PROC_FS 232#ifdef CONFIG_PROC_FS
233static int signalfd_show_fdinfo(struct seq_file *m, struct file *f) 233static void signalfd_show_fdinfo(struct seq_file *m, struct file *f)
234{ 234{
235 struct signalfd_ctx *ctx = f->private_data; 235 struct signalfd_ctx *ctx = f->private_data;
236 sigset_t sigmask; 236 sigset_t sigmask;
@@ -238,8 +238,6 @@ static int signalfd_show_fdinfo(struct seq_file *m, struct file *f)
238 sigmask = ctx->sigmask; 238 sigmask = ctx->sigmask;
239 signotset(&sigmask); 239 signotset(&sigmask);
240 render_sigset_t(m, "sigmask:\t", &sigmask); 240 render_sigset_t(m, "sigmask:\t", &sigmask);
241
242 return 0;
243} 241}
244#endif 242#endif
245 243
diff --git a/fs/sync.c b/fs/sync.c
index bdc729d80e5e..01d9f18a70b5 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -154,7 +154,7 @@ SYSCALL_DEFINE1(syncfs, int, fd)
154 154
155 if (!f.file) 155 if (!f.file)
156 return -EBADF; 156 return -EBADF;
157 sb = f.file->f_dentry->d_sb; 157 sb = f.file->f_path.dentry->d_sb;
158 158
159 down_read(&sb->s_umount); 159 down_read(&sb->s_umount);
160 ret = sync_filesystem(sb); 160 ret = sync_filesystem(sb);
diff --git a/fs/timerfd.c b/fs/timerfd.c
index b46ffa94372a..b94fa6c3c6eb 100644
--- a/fs/timerfd.c
+++ b/fs/timerfd.c
@@ -288,7 +288,7 @@ static ssize_t timerfd_read(struct file *file, char __user *buf, size_t count,
288} 288}
289 289
290#ifdef CONFIG_PROC_FS 290#ifdef CONFIG_PROC_FS
291static int timerfd_show(struct seq_file *m, struct file *file) 291static void timerfd_show(struct seq_file *m, struct file *file)
292{ 292{
293 struct timerfd_ctx *ctx = file->private_data; 293 struct timerfd_ctx *ctx = file->private_data;
294 struct itimerspec t; 294 struct itimerspec t;
@@ -298,18 +298,19 @@ static int timerfd_show(struct seq_file *m, struct file *file)
298 t.it_interval = ktime_to_timespec(ctx->tintv); 298 t.it_interval = ktime_to_timespec(ctx->tintv);
299 spin_unlock_irq(&ctx->wqh.lock); 299 spin_unlock_irq(&ctx->wqh.lock);
300 300
301 return seq_printf(m, 301 seq_printf(m,
302 "clockid: %d\n" 302 "clockid: %d\n"
303 "ticks: %llu\n" 303 "ticks: %llu\n"
304 "settime flags: 0%o\n" 304 "settime flags: 0%o\n"
305 "it_value: (%llu, %llu)\n" 305 "it_value: (%llu, %llu)\n"
306 "it_interval: (%llu, %llu)\n", 306 "it_interval: (%llu, %llu)\n",
307 ctx->clockid, (unsigned long long)ctx->ticks, 307 ctx->clockid,
308 ctx->settime_flags, 308 (unsigned long long)ctx->ticks,
309 (unsigned long long)t.it_value.tv_sec, 309 ctx->settime_flags,
310 (unsigned long long)t.it_value.tv_nsec, 310 (unsigned long long)t.it_value.tv_sec,
311 (unsigned long long)t.it_interval.tv_sec, 311 (unsigned long long)t.it_value.tv_nsec,
312 (unsigned long long)t.it_interval.tv_nsec); 312 (unsigned long long)t.it_interval.tv_sec,
313 (unsigned long long)t.it_interval.tv_nsec);
313} 314}
314#else 315#else
315#define timerfd_show NULL 316#define timerfd_show NULL
diff --git a/fs/xattr.c b/fs/xattr.c
index 64e83efb742d..4ef698549e31 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -405,16 +405,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
405 const void __user *,value, size_t, size, int, flags) 405 const void __user *,value, size_t, size, int, flags)
406{ 406{
407 struct fd f = fdget(fd); 407 struct fd f = fdget(fd);
408 struct dentry *dentry;
409 int error = -EBADF; 408 int error = -EBADF;
410 409
411 if (!f.file) 410 if (!f.file)
412 return error; 411 return error;
413 dentry = f.file->f_path.dentry; 412 audit_file(f.file);
414 audit_inode(NULL, dentry, 0);
415 error = mnt_want_write_file(f.file); 413 error = mnt_want_write_file(f.file);
416 if (!error) { 414 if (!error) {
417 error = setxattr(dentry, name, value, size, flags); 415 error = setxattr(f.file->f_path.dentry, name, value, size, flags);
418 mnt_drop_write_file(f.file); 416 mnt_drop_write_file(f.file);
419 } 417 }
420 fdput(f); 418 fdput(f);
@@ -509,7 +507,7 @@ SYSCALL_DEFINE4(fgetxattr, int, fd, const char __user *, name,
509 507
510 if (!f.file) 508 if (!f.file)
511 return error; 509 return error;
512 audit_inode(NULL, f.file->f_path.dentry, 0); 510 audit_file(f.file);
513 error = getxattr(f.file->f_path.dentry, name, value, size); 511 error = getxattr(f.file->f_path.dentry, name, value, size);
514 fdput(f); 512 fdput(f);
515 return error; 513 return error;
@@ -590,7 +588,7 @@ SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size)
590 588
591 if (!f.file) 589 if (!f.file)
592 return error; 590 return error;
593 audit_inode(NULL, f.file->f_path.dentry, 0); 591 audit_file(f.file);
594 error = listxattr(f.file->f_path.dentry, list, size); 592 error = listxattr(f.file->f_path.dentry, list, size);
595 fdput(f); 593 fdput(f);
596 return error; 594 return error;
@@ -651,16 +649,14 @@ SYSCALL_DEFINE2(lremovexattr, const char __user *, pathname,
651SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name) 649SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name)
652{ 650{
653 struct fd f = fdget(fd); 651 struct fd f = fdget(fd);
654 struct dentry *dentry;
655 int error = -EBADF; 652 int error = -EBADF;
656 653
657 if (!f.file) 654 if (!f.file)
658 return error; 655 return error;
659 dentry = f.file->f_path.dentry; 656 audit_file(f.file);
660 audit_inode(NULL, dentry, 0);
661 error = mnt_want_write_file(f.file); 657 error = mnt_want_write_file(f.file);
662 if (!error) { 658 if (!error) {
663 error = removexattr(dentry, name); 659 error = removexattr(f.file->f_path.dentry, name);
664 mnt_drop_write_file(f.file); 660 mnt_drop_write_file(f.file);
665 } 661 }
666 fdput(f); 662 fdput(f);
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index 92e8f99a5857..281002689d64 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -1338,7 +1338,10 @@ xfs_free_file_space(
1338 goto out; 1338 goto out;
1339} 1339}
1340 1340
1341 1341/*
1342 * Preallocate and zero a range of a file. This mechanism has the allocation
1343 * semantics of fallocate and in addition converts data in the range to zeroes.
1344 */
1342int 1345int
1343xfs_zero_file_space( 1346xfs_zero_file_space(
1344 struct xfs_inode *ip, 1347 struct xfs_inode *ip,
@@ -1346,65 +1349,30 @@ xfs_zero_file_space(
1346 xfs_off_t len) 1349 xfs_off_t len)
1347{ 1350{
1348 struct xfs_mount *mp = ip->i_mount; 1351 struct xfs_mount *mp = ip->i_mount;
1349 uint granularity; 1352 uint blksize;
1350 xfs_off_t start_boundary;
1351 xfs_off_t end_boundary;
1352 int error; 1353 int error;
1353 1354
1354 trace_xfs_zero_file_space(ip); 1355 trace_xfs_zero_file_space(ip);
1355 1356
1356 granularity = max_t(uint, 1 << mp->m_sb.sb_blocklog, PAGE_CACHE_SIZE); 1357 blksize = 1 << mp->m_sb.sb_blocklog;
1357 1358
1358 /* 1359 /*
1359 * Round the range of extents we are going to convert inwards. If the 1360 * Punch a hole and prealloc the range. We use hole punch rather than
1360 * offset is aligned, then it doesn't get changed so we zero from the 1361 * unwritten extent conversion for two reasons:
1361 * start of the block offset points to. 1362 *
1363 * 1.) Hole punch handles partial block zeroing for us.
1364 *
1365 * 2.) If prealloc returns ENOSPC, the file range is still zero-valued
1366 * by virtue of the hole punch.
1362 */ 1367 */
1363 start_boundary = round_up(offset, granularity); 1368 error = xfs_free_file_space(ip, offset, len);
1364 end_boundary = round_down(offset + len, granularity); 1369 if (error)
1365 1370 goto out;
1366 ASSERT(start_boundary >= offset);
1367 ASSERT(end_boundary <= offset + len);
1368
1369 if (start_boundary < end_boundary - 1) {
1370 /*
1371 * Writeback the range to ensure any inode size updates due to
1372 * appending writes make it to disk (otherwise we could just
1373 * punch out the delalloc blocks).
1374 */
1375 error = filemap_write_and_wait_range(VFS_I(ip)->i_mapping,
1376 start_boundary, end_boundary - 1);
1377 if (error)
1378 goto out;
1379 truncate_pagecache_range(VFS_I(ip), start_boundary,
1380 end_boundary - 1);
1381
1382 /* convert the blocks */
1383 error = xfs_alloc_file_space(ip, start_boundary,
1384 end_boundary - start_boundary - 1,
1385 XFS_BMAPI_PREALLOC | XFS_BMAPI_CONVERT);
1386 if (error)
1387 goto out;
1388
1389 /* We've handled the interior of the range, now for the edges */
1390 if (start_boundary != offset) {
1391 error = xfs_iozero(ip, offset, start_boundary - offset);
1392 if (error)
1393 goto out;
1394 }
1395
1396 if (end_boundary != offset + len)
1397 error = xfs_iozero(ip, end_boundary,
1398 offset + len - end_boundary);
1399
1400 } else {
1401 /*
1402 * It's either a sub-granularity range or the range spanned lies
1403 * partially across two adjacent blocks.
1404 */
1405 error = xfs_iozero(ip, offset, len);
1406 }
1407 1371
1372 error = xfs_alloc_file_space(ip, round_down(offset, blksize),
1373 round_up(offset + len, blksize) -
1374 round_down(offset, blksize),
1375 XFS_BMAPI_PREALLOC);
1408out: 1376out:
1409 return error; 1377 return error;
1410 1378
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index f1deb961a296..894924a5129b 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -236,8 +236,10 @@ xfs_bulkstat_grab_ichunk(
236 XFS_WANT_CORRUPTED_RETURN(stat == 1); 236 XFS_WANT_CORRUPTED_RETURN(stat == 1);
237 237
238 /* Check if the record contains the inode in request */ 238 /* Check if the record contains the inode in request */
239 if (irec->ir_startino + XFS_INODES_PER_CHUNK <= agino) 239 if (irec->ir_startino + XFS_INODES_PER_CHUNK <= agino) {
240 return -EINVAL; 240 *icount = 0;
241 return 0;
242 }
241 243
242 idx = agino - irec->ir_startino + 1; 244 idx = agino - irec->ir_startino + 1;
243 if (idx < XFS_INODES_PER_CHUNK && 245 if (idx < XFS_INODES_PER_CHUNK &&
@@ -262,75 +264,76 @@ xfs_bulkstat_grab_ichunk(
262 264
263#define XFS_BULKSTAT_UBLEFT(ubleft) ((ubleft) >= statstruct_size) 265#define XFS_BULKSTAT_UBLEFT(ubleft) ((ubleft) >= statstruct_size)
264 266
267struct xfs_bulkstat_agichunk {
268 char __user **ac_ubuffer;/* pointer into user's buffer */
269 int ac_ubleft; /* bytes left in user's buffer */
270 int ac_ubelem; /* spaces used in user's buffer */
271};
272
265/* 273/*
266 * Process inodes in chunk with a pointer to a formatter function 274 * Process inodes in chunk with a pointer to a formatter function
267 * that will iget the inode and fill in the appropriate structure. 275 * that will iget the inode and fill in the appropriate structure.
268 */ 276 */
269int 277static int
270xfs_bulkstat_ag_ichunk( 278xfs_bulkstat_ag_ichunk(
271 struct xfs_mount *mp, 279 struct xfs_mount *mp,
272 xfs_agnumber_t agno, 280 xfs_agnumber_t agno,
273 struct xfs_inobt_rec_incore *irbp, 281 struct xfs_inobt_rec_incore *irbp,
274 bulkstat_one_pf formatter, 282 bulkstat_one_pf formatter,
275 size_t statstruct_size, 283 size_t statstruct_size,
276 struct xfs_bulkstat_agichunk *acp) 284 struct xfs_bulkstat_agichunk *acp,
285 xfs_agino_t *last_agino)
277{ 286{
278 xfs_ino_t lastino = acp->ac_lastino;
279 char __user **ubufp = acp->ac_ubuffer; 287 char __user **ubufp = acp->ac_ubuffer;
280 int ubleft = acp->ac_ubleft; 288 int chunkidx;
281 int ubelem = acp->ac_ubelem;
282 int chunkidx, clustidx;
283 int error = 0; 289 int error = 0;
284 xfs_agino_t agino; 290 xfs_agino_t agino = irbp->ir_startino;
285 291
286 for (agino = irbp->ir_startino, chunkidx = clustidx = 0; 292 for (chunkidx = 0; chunkidx < XFS_INODES_PER_CHUNK;
287 XFS_BULKSTAT_UBLEFT(ubleft) && 293 chunkidx++, agino++) {
288 irbp->ir_freecount < XFS_INODES_PER_CHUNK; 294 int fmterror;
289 chunkidx++, clustidx++, agino++) {
290 int fmterror; /* bulkstat formatter result */
291 int ubused; 295 int ubused;
292 xfs_ino_t ino = XFS_AGINO_TO_INO(mp, agno, agino);
293 296
294 ASSERT(chunkidx < XFS_INODES_PER_CHUNK); 297 /* inode won't fit in buffer, we are done */
298 if (acp->ac_ubleft < statstruct_size)
299 break;
295 300
296 /* Skip if this inode is free */ 301 /* Skip if this inode is free */
297 if (XFS_INOBT_MASK(chunkidx) & irbp->ir_free) { 302 if (XFS_INOBT_MASK(chunkidx) & irbp->ir_free)
298 lastino = ino;
299 continue; 303 continue;
300 }
301
302 /*
303 * Count used inodes as free so we can tell when the
304 * chunk is used up.
305 */
306 irbp->ir_freecount++;
307 304
308 /* Get the inode and fill in a single buffer */ 305 /* Get the inode and fill in a single buffer */
309 ubused = statstruct_size; 306 ubused = statstruct_size;
310 error = formatter(mp, ino, *ubufp, ubleft, &ubused, &fmterror); 307 error = formatter(mp, XFS_AGINO_TO_INO(mp, agno, agino),
311 if (fmterror == BULKSTAT_RV_NOTHING) { 308 *ubufp, acp->ac_ubleft, &ubused, &fmterror);
312 if (error && error != -ENOENT && error != -EINVAL) { 309
313 ubleft = 0; 310 if (fmterror == BULKSTAT_RV_GIVEUP ||
314 break; 311 (error && error != -ENOENT && error != -EINVAL)) {
315 } 312 acp->ac_ubleft = 0;
316 lastino = ino;
317 continue;
318 }
319 if (fmterror == BULKSTAT_RV_GIVEUP) {
320 ubleft = 0;
321 ASSERT(error); 313 ASSERT(error);
322 break; 314 break;
323 } 315 }
324 if (*ubufp) 316
325 *ubufp += ubused; 317 /* be careful not to leak error if at end of chunk */
326 ubleft -= ubused; 318 if (fmterror == BULKSTAT_RV_NOTHING || error) {
327 ubelem++; 319 error = 0;
328 lastino = ino; 320 continue;
321 }
322
323 *ubufp += ubused;
324 acp->ac_ubleft -= ubused;
325 acp->ac_ubelem++;
329 } 326 }
330 327
331 acp->ac_lastino = lastino; 328 /*
332 acp->ac_ubleft = ubleft; 329 * Post-update *last_agino. At this point, agino will always point one
333 acp->ac_ubelem = ubelem; 330 * inode past the last inode we processed successfully. Hence we
331 * substract that inode when setting the *last_agino cursor so that we
332 * return the correct cookie to userspace. On the next bulkstat call,
333 * the inode under the lastino cookie will be skipped as we have already
334 * processed it here.
335 */
336 *last_agino = agino - 1;
334 337
335 return error; 338 return error;
336} 339}
@@ -353,45 +356,33 @@ xfs_bulkstat(
353 xfs_agino_t agino; /* inode # in allocation group */ 356 xfs_agino_t agino; /* inode # in allocation group */
354 xfs_agnumber_t agno; /* allocation group number */ 357 xfs_agnumber_t agno; /* allocation group number */
355 xfs_btree_cur_t *cur; /* btree cursor for ialloc btree */ 358 xfs_btree_cur_t *cur; /* btree cursor for ialloc btree */
356 int end_of_ag; /* set if we've seen the ag end */
357 int error; /* error code */
358 int fmterror;/* bulkstat formatter result */
359 int i; /* loop index */
360 int icount; /* count of inodes good in irbuf */
361 size_t irbsize; /* size of irec buffer in bytes */ 359 size_t irbsize; /* size of irec buffer in bytes */
362 xfs_ino_t ino; /* inode number (filesystem) */
363 xfs_inobt_rec_incore_t *irbp; /* current irec buffer pointer */
364 xfs_inobt_rec_incore_t *irbuf; /* start of irec buffer */ 360 xfs_inobt_rec_incore_t *irbuf; /* start of irec buffer */
365 xfs_inobt_rec_incore_t *irbufend; /* end of good irec buffer entries */
366 xfs_ino_t lastino; /* last inode number returned */
367 int nirbuf; /* size of irbuf */ 361 int nirbuf; /* size of irbuf */
368 int rval; /* return value error code */
369 int tmp; /* result value from btree calls */
370 int ubcount; /* size of user's buffer */ 362 int ubcount; /* size of user's buffer */
371 int ubleft; /* bytes left in user's buffer */ 363 struct xfs_bulkstat_agichunk ac;
372 char __user *ubufp; /* pointer into user's buffer */ 364 int error = 0;
373 int ubelem; /* spaces used in user's buffer */
374 365
375 /* 366 /*
376 * Get the last inode value, see if there's nothing to do. 367 * Get the last inode value, see if there's nothing to do.
377 */ 368 */
378 ino = (xfs_ino_t)*lastinop; 369 agno = XFS_INO_TO_AGNO(mp, *lastinop);
379 lastino = ino; 370 agino = XFS_INO_TO_AGINO(mp, *lastinop);
380 agno = XFS_INO_TO_AGNO(mp, ino);
381 agino = XFS_INO_TO_AGINO(mp, ino);
382 if (agno >= mp->m_sb.sb_agcount || 371 if (agno >= mp->m_sb.sb_agcount ||
383 ino != XFS_AGINO_TO_INO(mp, agno, agino)) { 372 *lastinop != XFS_AGINO_TO_INO(mp, agno, agino)) {
384 *done = 1; 373 *done = 1;
385 *ubcountp = 0; 374 *ubcountp = 0;
386 return 0; 375 return 0;
387 } 376 }
388 377
389 ubcount = *ubcountp; /* statstruct's */ 378 ubcount = *ubcountp; /* statstruct's */
390 ubleft = ubcount * statstruct_size; /* bytes */ 379 ac.ac_ubuffer = &ubuffer;
391 *ubcountp = ubelem = 0; 380 ac.ac_ubleft = ubcount * statstruct_size; /* bytes */;
381 ac.ac_ubelem = 0;
382
383 *ubcountp = 0;
392 *done = 0; 384 *done = 0;
393 fmterror = 0; 385
394 ubufp = ubuffer;
395 irbuf = kmem_zalloc_greedy(&irbsize, PAGE_SIZE, PAGE_SIZE * 4); 386 irbuf = kmem_zalloc_greedy(&irbsize, PAGE_SIZE, PAGE_SIZE * 4);
396 if (!irbuf) 387 if (!irbuf)
397 return -ENOMEM; 388 return -ENOMEM;
@@ -402,9 +393,13 @@ xfs_bulkstat(
402 * Loop over the allocation groups, starting from the last 393 * Loop over the allocation groups, starting from the last
403 * inode returned; 0 means start of the allocation group. 394 * inode returned; 0 means start of the allocation group.
404 */ 395 */
405 rval = 0; 396 while (agno < mp->m_sb.sb_agcount) {
406 while (XFS_BULKSTAT_UBLEFT(ubleft) && agno < mp->m_sb.sb_agcount) { 397 struct xfs_inobt_rec_incore *irbp = irbuf;
407 cond_resched(); 398 struct xfs_inobt_rec_incore *irbufend = irbuf + nirbuf;
399 bool end_of_ag = false;
400 int icount = 0;
401 int stat;
402
408 error = xfs_ialloc_read_agi(mp, NULL, agno, &agbp); 403 error = xfs_ialloc_read_agi(mp, NULL, agno, &agbp);
409 if (error) 404 if (error)
410 break; 405 break;
@@ -414,10 +409,6 @@ xfs_bulkstat(
414 */ 409 */
415 cur = xfs_inobt_init_cursor(mp, NULL, agbp, agno, 410 cur = xfs_inobt_init_cursor(mp, NULL, agbp, agno,
416 XFS_BTNUM_INO); 411 XFS_BTNUM_INO);
417 irbp = irbuf;
418 irbufend = irbuf + nirbuf;
419 end_of_ag = 0;
420 icount = 0;
421 if (agino > 0) { 412 if (agino > 0) {
422 /* 413 /*
423 * In the middle of an allocation group, we need to get 414 * In the middle of an allocation group, we need to get
@@ -427,22 +418,23 @@ xfs_bulkstat(
427 418
428 error = xfs_bulkstat_grab_ichunk(cur, agino, &icount, &r); 419 error = xfs_bulkstat_grab_ichunk(cur, agino, &icount, &r);
429 if (error) 420 if (error)
430 break; 421 goto del_cursor;
431 if (icount) { 422 if (icount) {
432 irbp->ir_startino = r.ir_startino; 423 irbp->ir_startino = r.ir_startino;
433 irbp->ir_freecount = r.ir_freecount; 424 irbp->ir_freecount = r.ir_freecount;
434 irbp->ir_free = r.ir_free; 425 irbp->ir_free = r.ir_free;
435 irbp++; 426 irbp++;
436 agino = r.ir_startino + XFS_INODES_PER_CHUNK;
437 } 427 }
438 /* Increment to the next record */ 428 /* Increment to the next record */
439 error = xfs_btree_increment(cur, 0, &tmp); 429 error = xfs_btree_increment(cur, 0, &stat);
440 } else { 430 } else {
441 /* Start of ag. Lookup the first inode chunk */ 431 /* Start of ag. Lookup the first inode chunk */
442 error = xfs_inobt_lookup(cur, 0, XFS_LOOKUP_GE, &tmp); 432 error = xfs_inobt_lookup(cur, 0, XFS_LOOKUP_GE, &stat);
433 }
434 if (error || stat == 0) {
435 end_of_ag = true;
436 goto del_cursor;
443 } 437 }
444 if (error)
445 break;
446 438
447 /* 439 /*
448 * Loop through inode btree records in this ag, 440 * Loop through inode btree records in this ag,
@@ -451,10 +443,10 @@ xfs_bulkstat(
451 while (irbp < irbufend && icount < ubcount) { 443 while (irbp < irbufend && icount < ubcount) {
452 struct xfs_inobt_rec_incore r; 444 struct xfs_inobt_rec_incore r;
453 445
454 error = xfs_inobt_get_rec(cur, &r, &i); 446 error = xfs_inobt_get_rec(cur, &r, &stat);
455 if (error || i == 0) { 447 if (error || stat == 0) {
456 end_of_ag = 1; 448 end_of_ag = true;
457 break; 449 goto del_cursor;
458 } 450 }
459 451
460 /* 452 /*
@@ -469,77 +461,79 @@ xfs_bulkstat(
469 irbp++; 461 irbp++;
470 icount += XFS_INODES_PER_CHUNK - r.ir_freecount; 462 icount += XFS_INODES_PER_CHUNK - r.ir_freecount;
471 } 463 }
472 /* 464 error = xfs_btree_increment(cur, 0, &stat);
473 * Set agino to after this chunk and bump the cursor. 465 if (error || stat == 0) {
474 */ 466 end_of_ag = true;
475 agino = r.ir_startino + XFS_INODES_PER_CHUNK; 467 goto del_cursor;
476 error = xfs_btree_increment(cur, 0, &tmp); 468 }
477 cond_resched(); 469 cond_resched();
478 } 470 }
471
479 /* 472 /*
480 * Drop the btree buffers and the agi buffer. 473 * Drop the btree buffers and the agi buffer as we can't hold any
481 * We can't hold any of the locks these represent 474 * of the locks these represent when calling iget. If there is a
482 * when calling iget. 475 * pending error, then we are done.
483 */ 476 */
477del_cursor:
484 xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR); 478 xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
485 xfs_buf_relse(agbp); 479 xfs_buf_relse(agbp);
480 if (error)
481 break;
486 /* 482 /*
487 * Now format all the good inodes into the user's buffer. 483 * Now format all the good inodes into the user's buffer. The
484 * call to xfs_bulkstat_ag_ichunk() sets up the agino pointer
485 * for the next loop iteration.
488 */ 486 */
489 irbufend = irbp; 487 irbufend = irbp;
490 for (irbp = irbuf; 488 for (irbp = irbuf;
491 irbp < irbufend && XFS_BULKSTAT_UBLEFT(ubleft); irbp++) { 489 irbp < irbufend && ac.ac_ubleft >= statstruct_size;
492 struct xfs_bulkstat_agichunk ac; 490 irbp++) {
493
494 ac.ac_lastino = lastino;
495 ac.ac_ubuffer = &ubuffer;
496 ac.ac_ubleft = ubleft;
497 ac.ac_ubelem = ubelem;
498 error = xfs_bulkstat_ag_ichunk(mp, agno, irbp, 491 error = xfs_bulkstat_ag_ichunk(mp, agno, irbp,
499 formatter, statstruct_size, &ac); 492 formatter, statstruct_size, &ac,
493 &agino);
500 if (error) 494 if (error)
501 rval = error; 495 break;
502
503 lastino = ac.ac_lastino;
504 ubleft = ac.ac_ubleft;
505 ubelem = ac.ac_ubelem;
506 496
507 cond_resched(); 497 cond_resched();
508 } 498 }
499
509 /* 500 /*
510 * Set up for the next loop iteration. 501 * If we've run out of space or had a formatting error, we
502 * are now done
511 */ 503 */
512 if (XFS_BULKSTAT_UBLEFT(ubleft)) { 504 if (ac.ac_ubleft < statstruct_size || error)
513 if (end_of_ag) {
514 agno++;
515 agino = 0;
516 } else
517 agino = XFS_INO_TO_AGINO(mp, lastino);
518 } else
519 break; 505 break;
506
507 if (end_of_ag) {
508 agno++;
509 agino = 0;
510 }
520 } 511 }
521 /* 512 /*
522 * Done, we're either out of filesystem or space to put the data. 513 * Done, we're either out of filesystem or space to put the data.
523 */ 514 */
524 kmem_free(irbuf); 515 kmem_free(irbuf);
525 *ubcountp = ubelem; 516 *ubcountp = ac.ac_ubelem;
517
526 /* 518 /*
527 * Found some inodes, return them now and return the error next time. 519 * We found some inodes, so clear the error status and return them.
520 * The lastino pointer will point directly at the inode that triggered
521 * any error that occurred, so on the next call the error will be
522 * triggered again and propagated to userspace as there will be no
523 * formatted inodes in the buffer.
528 */ 524 */
529 if (ubelem) 525 if (ac.ac_ubelem)
530 rval = 0; 526 error = 0;
531 if (agno >= mp->m_sb.sb_agcount) { 527
532 /* 528 /*
533 * If we ran out of filesystem, mark lastino as off 529 * If we ran out of filesystem, lastino will point off the end of
534 * the end of the filesystem, so the next call 530 * the filesystem so the next call will return immediately.
535 * will return immediately. 531 */
536 */ 532 *lastinop = XFS_AGINO_TO_INO(mp, agno, agino);
537 *lastinop = (xfs_ino_t)XFS_AGINO_TO_INO(mp, agno, 0); 533 if (agno >= mp->m_sb.sb_agcount)
538 *done = 1; 534 *done = 1;
539 } else
540 *lastinop = (xfs_ino_t)lastino;
541 535
542 return rval; 536 return error;
543} 537}
544 538
545int 539int
diff --git a/fs/xfs/xfs_itable.h b/fs/xfs/xfs_itable.h
index aaed08022eb9..6ea8b3912fa4 100644
--- a/fs/xfs/xfs_itable.h
+++ b/fs/xfs/xfs_itable.h
@@ -30,22 +30,6 @@ typedef int (*bulkstat_one_pf)(struct xfs_mount *mp,
30 int *ubused, 30 int *ubused,
31 int *stat); 31 int *stat);
32 32
33struct xfs_bulkstat_agichunk {
34 xfs_ino_t ac_lastino; /* last inode returned */
35 char __user **ac_ubuffer;/* pointer into user's buffer */
36 int ac_ubleft; /* bytes left in user's buffer */
37 int ac_ubelem; /* spaces used in user's buffer */
38};
39
40int
41xfs_bulkstat_ag_ichunk(
42 struct xfs_mount *mp,
43 xfs_agnumber_t agno,
44 struct xfs_inobt_rec_incore *irbp,
45 bulkstat_one_pf formatter,
46 size_t statstruct_size,
47 struct xfs_bulkstat_agichunk *acp);
48
49/* 33/*
50 * Values for stat return value. 34 * Values for stat return value.
51 */ 35 */