aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-01-12 20:11:47 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-01-12 20:11:47 -0500
commit33caf82acf4dc420bf0f0136b886f7b27ecf90c5 (patch)
treeb24b0b5c8f257ae7db3b8df939821a0856869895 /fs
parentca9706a282943899981e83604f2ed13e88ce4239 (diff)
parentbbddca8e8fac07ece3938e03526b5d00fa791a4c (diff)
Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull misc vfs updates from Al Viro: "All kinds of stuff. That probably should've been 5 or 6 separate branches, but by the time I'd realized how large and mixed that bag had become it had been too close to -final to play with rebasing. Some fs/namei.c cleanups there, memdup_user_nul() introduction and switching open-coded instances, burying long-dead code, whack-a-mole of various kinds, several new helpers for ->llseek(), assorted cleanups and fixes from various people, etc. One piece probably deserves special mention - Neil's lookup_one_len_unlocked(). Similar to lookup_one_len(), but gets called without ->i_mutex and tries to avoid ever taking it. That, of course, means that it's not useful for any directory modifications, but things like getting inode attributes in nfds readdirplus are fine with that. I really should've asked for moratorium on lookup-related changes this cycle, but since I hadn't done that early enough... I *am* asking for that for the coming cycle, though - I'm going to try and get conversion of i_mutex to rwsem with ->lookup() done under lock taken shared. There will be a patch closer to the end of the window, along the lines of the one Linus had posted last May - mechanical conversion of ->i_mutex accesses to inode_lock()/inode_unlock()/inode_trylock()/ inode_is_locked()/inode_lock_nested(). To quote Linus back then: ----- | This is an automated patch using | | sed 's/mutex_lock(&\(.*\)->i_mutex)/inode_lock(\1)/' | sed 's/mutex_unlock(&\(.*\)->i_mutex)/inode_unlock(\1)/' | sed 's/mutex_lock_nested(&\(.*\)->i_mutex,[ ]*I_MUTEX_\([A-Z0-9_]*\))/inode_lock_nested(\1, I_MUTEX_\2)/' | sed 's/mutex_is_locked(&\(.*\)->i_mutex)/inode_is_locked(\1)/' | sed 's/mutex_trylock(&\(.*\)->i_mutex)/inode_trylock(\1)/' | | with a very few manual fixups ----- I'm going to send that once the ->i_mutex-affecting stuff in -next gets mostly merged (or when Linus says he's about to stop taking merges)" * 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (63 commits) nfsd: don't hold i_mutex over userspace upcalls fs:affs:Replace time_t with time64_t fs/9p: use fscache mutex rather than spinlock proc: add a reschedule point in proc_readfd_common() logfs: constify logfs_block_ops structures fcntl: allow to set O_DIRECT flag on pipe fs: __generic_file_splice_read retry lookup on AOP_TRUNCATED_PAGE fs: xattr: Use kvfree() [s390] page_to_phys() always returns a multiple of PAGE_SIZE nbd: use ->compat_ioctl() fs: use block_device name vsprintf helper lib/vsprintf: add %*pg format specifier fs: use gendisk->disk_name where possible poll: plug an unused argument to do_poll amdkfd: don't open-code memdup_user() cdrom: don't open-code memdup_user() rsxx: don't open-code memdup_user() mtip32xx: don't open-code memdup_user() [um] mconsole: don't open-code memdup_user_nul() [um] hostaudio: don't open-code memdup_user() ...
Diffstat (limited to 'fs')
-rw-r--r--fs/9p/cache.c8
-rw-r--r--fs/9p/v9fs.h2
-rw-r--r--fs/9p/vfs_inode.c2
-rw-r--r--fs/adfs/adfs.h6
-rw-r--r--fs/adfs/dir.c6
-rw-r--r--fs/adfs/dir_f.c2
-rw-r--r--fs/adfs/dir_fplus.c2
-rw-r--r--fs/affs/affs.h2
-rw-r--r--fs/affs/amigaffs.c13
-rw-r--r--fs/affs/super.c2
-rw-r--r--fs/afs/proc.c25
-rw-r--r--fs/bad_inode.c2
-rw-r--r--fs/block_dev.c12
-rw-r--r--fs/btrfs/super.c4
-rw-r--r--fs/buffer.c21
-rw-r--r--fs/cachefiles/daemon.c12
-rw-r--r--fs/compat.c21
-rw-r--r--fs/compat_ioctl.c11
-rw-r--r--fs/coredump.c8
-rw-r--r--fs/dcache.c14
-rw-r--r--fs/dlm/user.c11
-rw-r--r--fs/ecryptfs/inode.c4
-rw-r--r--fs/exec.c4
-rw-r--r--fs/ext2/xattr.c6
-rw-r--r--fs/ext4/page-io.c5
-rw-r--r--fs/ext4/xattr.c6
-rw-r--r--fs/f2fs/debug.c6
-rw-r--r--fs/f2fs/f2fs.h6
-rw-r--r--fs/fcntl.c3
-rw-r--r--fs/file.c6
-rw-r--r--fs/gfs2/ops_fstype.c4
-rw-r--r--fs/hfs/mdb.c4
-rw-r--r--fs/hpfs/map.c2
-rw-r--r--fs/internal.h2
-rw-r--r--fs/jbd2/transaction.c6
-rw-r--r--fs/jfs/jfs_logmgr.c9
-rw-r--r--fs/logfs/logfs.h4
-rw-r--r--fs/logfs/readwrite.c4
-rw-r--r--fs/logfs/segment.c2
-rw-r--r--fs/minix/itree_v1.c9
-rw-r--r--fs/minix/itree_v2.c9
-rw-r--r--fs/namei.c200
-rw-r--r--fs/namespace.c39
-rw-r--r--fs/nfsd/nfs3xdr.c2
-rw-r--r--fs/nfsd/nfs4xdr.c8
-rw-r--r--fs/nfsd/vfs.c23
-rw-r--r--fs/nilfs2/super.c6
-rw-r--r--fs/open.c5
-rw-r--r--fs/proc/base.c17
-rw-r--r--fs/proc/fd.c1
-rw-r--r--fs/proc_namespace.c27
-rw-r--r--fs/read_write.c39
-rw-r--r--fs/reiserfs/journal.c24
-rw-r--r--fs/reiserfs/prints.c9
-rw-r--r--fs/reiserfs/procfs.c5
-rw-r--r--fs/select.c6
-rw-r--r--fs/splice.c8
-rw-r--r--fs/squashfs/super.c7
-rw-r--r--fs/super.c4
-rw-r--r--fs/xattr.c38
-rw-r--r--fs/xfs/xfs_buf.c8
61 files changed, 379 insertions, 384 deletions
diff --git a/fs/9p/cache.c b/fs/9p/cache.c
index a69260f27555..103ca5e1267b 100644
--- a/fs/9p/cache.c
+++ b/fs/9p/cache.c
@@ -243,14 +243,14 @@ void v9fs_cache_inode_set_cookie(struct inode *inode, struct file *filp)
243 if (!v9inode->fscache) 243 if (!v9inode->fscache)
244 return; 244 return;
245 245
246 spin_lock(&v9inode->fscache_lock); 246 mutex_lock(&v9inode->fscache_lock);
247 247
248 if ((filp->f_flags & O_ACCMODE) != O_RDONLY) 248 if ((filp->f_flags & O_ACCMODE) != O_RDONLY)
249 v9fs_cache_inode_flush_cookie(inode); 249 v9fs_cache_inode_flush_cookie(inode);
250 else 250 else
251 v9fs_cache_inode_get_cookie(inode); 251 v9fs_cache_inode_get_cookie(inode);
252 252
253 spin_unlock(&v9inode->fscache_lock); 253 mutex_unlock(&v9inode->fscache_lock);
254} 254}
255 255
256void v9fs_cache_inode_reset_cookie(struct inode *inode) 256void v9fs_cache_inode_reset_cookie(struct inode *inode)
@@ -264,7 +264,7 @@ void v9fs_cache_inode_reset_cookie(struct inode *inode)
264 264
265 old = v9inode->fscache; 265 old = v9inode->fscache;
266 266
267 spin_lock(&v9inode->fscache_lock); 267 mutex_lock(&v9inode->fscache_lock);
268 fscache_relinquish_cookie(v9inode->fscache, 1); 268 fscache_relinquish_cookie(v9inode->fscache, 1);
269 269
270 v9ses = v9fs_inode2v9ses(inode); 270 v9ses = v9fs_inode2v9ses(inode);
@@ -274,7 +274,7 @@ void v9fs_cache_inode_reset_cookie(struct inode *inode)
274 p9_debug(P9_DEBUG_FSC, "inode %p revalidating cookie old %p new %p\n", 274 p9_debug(P9_DEBUG_FSC, "inode %p revalidating cookie old %p new %p\n",
275 inode, old, v9inode->fscache); 275 inode, old, v9inode->fscache);
276 276
277 spin_unlock(&v9inode->fscache_lock); 277 mutex_unlock(&v9inode->fscache_lock);
278} 278}
279 279
280int __v9fs_fscache_release_page(struct page *page, gfp_t gfp) 280int __v9fs_fscache_release_page(struct page *page, gfp_t gfp)
diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h
index 0923f2cf3c80..6877050384a1 100644
--- a/fs/9p/v9fs.h
+++ b/fs/9p/v9fs.h
@@ -123,7 +123,7 @@ struct v9fs_session_info {
123 123
124struct v9fs_inode { 124struct v9fs_inode {
125#ifdef CONFIG_9P_FSCACHE 125#ifdef CONFIG_9P_FSCACHE
126 spinlock_t fscache_lock; 126 struct mutex fscache_lock;
127 struct fscache_cookie *fscache; 127 struct fscache_cookie *fscache;
128#endif 128#endif
129 struct p9_qid qid; 129 struct p9_qid qid;
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index c7cc7c30f0c8..3a08b3e6ff1d 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -244,7 +244,7 @@ struct inode *v9fs_alloc_inode(struct super_block *sb)
244 return NULL; 244 return NULL;
245#ifdef CONFIG_9P_FSCACHE 245#ifdef CONFIG_9P_FSCACHE
246 v9inode->fscache = NULL; 246 v9inode->fscache = NULL;
247 spin_lock_init(&v9inode->fscache_lock); 247 mutex_init(&v9inode->fscache_lock);
248#endif 248#endif
249 v9inode->writeback_fid = NULL; 249 v9inode->writeback_fid = NULL;
250 v9inode->cache_validity = 0; 250 v9inode->cache_validity = 0;
diff --git a/fs/adfs/adfs.h b/fs/adfs/adfs.h
index 24575d9d882d..ea4aba56f29d 100644
--- a/fs/adfs/adfs.h
+++ b/fs/adfs/adfs.h
@@ -45,7 +45,7 @@ struct adfs_dir_ops;
45struct adfs_sb_info { 45struct adfs_sb_info {
46 union { struct { 46 union { struct {
47 struct adfs_discmap *s_map; /* bh list containing map */ 47 struct adfs_discmap *s_map; /* bh list containing map */
48 struct adfs_dir_ops *s_dir; /* directory operations */ 48 const struct adfs_dir_ops *s_dir; /* directory operations */
49 }; 49 };
50 struct rcu_head rcu; /* used only at shutdown time */ 50 struct rcu_head rcu; /* used only at shutdown time */
51 }; 51 };
@@ -168,8 +168,8 @@ void __adfs_error(struct super_block *sb, const char *function,
168extern const struct inode_operations adfs_dir_inode_operations; 168extern const struct inode_operations adfs_dir_inode_operations;
169extern const struct file_operations adfs_dir_operations; 169extern const struct file_operations adfs_dir_operations;
170extern const struct dentry_operations adfs_dentry_operations; 170extern const struct dentry_operations adfs_dentry_operations;
171extern struct adfs_dir_ops adfs_f_dir_ops; 171extern const struct adfs_dir_ops adfs_f_dir_ops;
172extern struct adfs_dir_ops adfs_fplus_dir_ops; 172extern const struct adfs_dir_ops adfs_fplus_dir_ops;
173 173
174extern int adfs_dir_update(struct super_block *sb, struct object_info *obj, 174extern int adfs_dir_update(struct super_block *sb, struct object_info *obj,
175 int wait); 175 int wait);
diff --git a/fs/adfs/dir.c b/fs/adfs/dir.c
index 51c279a29845..fd4cf2c48e48 100644
--- a/fs/adfs/dir.c
+++ b/fs/adfs/dir.c
@@ -21,7 +21,7 @@ adfs_readdir(struct file *file, struct dir_context *ctx)
21{ 21{
22 struct inode *inode = file_inode(file); 22 struct inode *inode = file_inode(file);
23 struct super_block *sb = inode->i_sb; 23 struct super_block *sb = inode->i_sb;
24 struct adfs_dir_ops *ops = ADFS_SB(sb)->s_dir; 24 const struct adfs_dir_ops *ops = ADFS_SB(sb)->s_dir;
25 struct object_info obj; 25 struct object_info obj;
26 struct adfs_dir dir; 26 struct adfs_dir dir;
27 int ret = 0; 27 int ret = 0;
@@ -69,7 +69,7 @@ adfs_dir_update(struct super_block *sb, struct object_info *obj, int wait)
69{ 69{
70 int ret = -EINVAL; 70 int ret = -EINVAL;
71#ifdef CONFIG_ADFS_FS_RW 71#ifdef CONFIG_ADFS_FS_RW
72 struct adfs_dir_ops *ops = ADFS_SB(sb)->s_dir; 72 const struct adfs_dir_ops *ops = ADFS_SB(sb)->s_dir;
73 struct adfs_dir dir; 73 struct adfs_dir dir;
74 74
75 printk(KERN_INFO "adfs_dir_update: object %06X in dir %06X\n", 75 printk(KERN_INFO "adfs_dir_update: object %06X in dir %06X\n",
@@ -129,7 +129,7 @@ static int
129adfs_dir_lookup_byname(struct inode *inode, struct qstr *name, struct object_info *obj) 129adfs_dir_lookup_byname(struct inode *inode, struct qstr *name, struct object_info *obj)
130{ 130{
131 struct super_block *sb = inode->i_sb; 131 struct super_block *sb = inode->i_sb;
132 struct adfs_dir_ops *ops = ADFS_SB(sb)->s_dir; 132 const struct adfs_dir_ops *ops = ADFS_SB(sb)->s_dir;
133 struct adfs_dir dir; 133 struct adfs_dir dir;
134 int ret; 134 int ret;
135 135
diff --git a/fs/adfs/dir_f.c b/fs/adfs/dir_f.c
index 4bbe853ee50a..0fbfd0b04ae0 100644
--- a/fs/adfs/dir_f.c
+++ b/fs/adfs/dir_f.c
@@ -476,7 +476,7 @@ adfs_f_free(struct adfs_dir *dir)
476 dir->sb = NULL; 476 dir->sb = NULL;
477} 477}
478 478
479struct adfs_dir_ops adfs_f_dir_ops = { 479const struct adfs_dir_ops adfs_f_dir_ops = {
480 .read = adfs_f_read, 480 .read = adfs_f_read,
481 .setpos = adfs_f_setpos, 481 .setpos = adfs_f_setpos,
482 .getnext = adfs_f_getnext, 482 .getnext = adfs_f_getnext,
diff --git a/fs/adfs/dir_fplus.c b/fs/adfs/dir_fplus.c
index 82d14cdf70f9..c92cfb638c18 100644
--- a/fs/adfs/dir_fplus.c
+++ b/fs/adfs/dir_fplus.c
@@ -256,7 +256,7 @@ adfs_fplus_free(struct adfs_dir *dir)
256 dir->sb = NULL; 256 dir->sb = NULL;
257} 257}
258 258
259struct adfs_dir_ops adfs_fplus_dir_ops = { 259const struct adfs_dir_ops adfs_fplus_dir_ops = {
260 .read = adfs_fplus_read, 260 .read = adfs_fplus_read,
261 .setpos = adfs_fplus_setpos, 261 .setpos = adfs_fplus_setpos,
262 .getnext = adfs_fplus_getnext, 262 .getnext = adfs_fplus_getnext,
diff --git a/fs/affs/affs.h b/fs/affs/affs.h
index c69a87eaf57d..cc2b2efc9211 100644
--- a/fs/affs/affs.h
+++ b/fs/affs/affs.h
@@ -138,7 +138,7 @@ extern int affs_remove_hash(struct inode *dir, struct buffer_head *rem_bh);
138extern int affs_remove_header(struct dentry *dentry); 138extern int affs_remove_header(struct dentry *dentry);
139extern u32 affs_checksum_block(struct super_block *sb, struct buffer_head *bh); 139extern u32 affs_checksum_block(struct super_block *sb, struct buffer_head *bh);
140extern void affs_fix_checksum(struct super_block *sb, struct buffer_head *bh); 140extern void affs_fix_checksum(struct super_block *sb, struct buffer_head *bh);
141extern void secs_to_datestamp(time_t secs, struct affs_date *ds); 141extern void secs_to_datestamp(time64_t secs, struct affs_date *ds);
142extern umode_t prot_to_mode(u32 prot); 142extern umode_t prot_to_mode(u32 prot);
143extern void mode_to_prot(struct inode *inode); 143extern void mode_to_prot(struct inode *inode);
144__printf(3, 4) 144__printf(3, 4)
diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
index 5fa92bc790ef..d6c7a51c93e4 100644
--- a/fs/affs/amigaffs.c
+++ b/fs/affs/amigaffs.c
@@ -8,6 +8,7 @@
8 * Please send bug reports to: hjw@zvw.de 8 * Please send bug reports to: hjw@zvw.de
9 */ 9 */
10 10
11#include <linux/math64.h>
11#include "affs.h" 12#include "affs.h"
12 13
13/* 14/*
@@ -366,22 +367,22 @@ affs_fix_checksum(struct super_block *sb, struct buffer_head *bh)
366} 367}
367 368
368void 369void
369secs_to_datestamp(time_t secs, struct affs_date *ds) 370secs_to_datestamp(time64_t secs, struct affs_date *ds)
370{ 371{
371 u32 days; 372 u32 days;
372 u32 minute; 373 u32 minute;
374 s32 rem;
373 375
374 secs -= sys_tz.tz_minuteswest * 60 + ((8 * 365 + 2) * 24 * 60 * 60); 376 secs -= sys_tz.tz_minuteswest * 60 + ((8 * 365 + 2) * 24 * 60 * 60);
375 if (secs < 0) 377 if (secs < 0)
376 secs = 0; 378 secs = 0;
377 days = secs / 86400; 379 days = div_s64_rem(secs, 86400, &rem);
378 secs -= days * 86400; 380 minute = rem / 60;
379 minute = secs / 60; 381 rem -= minute * 60;
380 secs -= minute * 60;
381 382
382 ds->days = cpu_to_be32(days); 383 ds->days = cpu_to_be32(days);
383 ds->mins = cpu_to_be32(minute); 384 ds->mins = cpu_to_be32(minute);
384 ds->ticks = cpu_to_be32(secs * 50); 385 ds->ticks = cpu_to_be32(rem * 50);
385} 386}
386 387
387umode_t 388umode_t
diff --git a/fs/affs/super.c b/fs/affs/super.c
index 5b50c4ca43a7..8836df5f1e11 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -32,7 +32,7 @@ affs_commit_super(struct super_block *sb, int wait)
32 struct affs_root_tail *tail = AFFS_ROOT_TAIL(sb, bh); 32 struct affs_root_tail *tail = AFFS_ROOT_TAIL(sb, bh);
33 33
34 lock_buffer(bh); 34 lock_buffer(bh);
35 secs_to_datestamp(get_seconds(), &tail->disk_change); 35 secs_to_datestamp(ktime_get_real_seconds(), &tail->disk_change);
36 affs_fix_checksum(sb, bh); 36 affs_fix_checksum(sb, bh);
37 unlock_buffer(bh); 37 unlock_buffer(bh);
38 38
diff --git a/fs/afs/proc.c b/fs/afs/proc.c
index 24a905b076fd..2853b4095344 100644
--- a/fs/afs/proc.c
+++ b/fs/afs/proc.c
@@ -230,14 +230,9 @@ static ssize_t afs_proc_cells_write(struct file *file, const char __user *buf,
230 if (size <= 1 || size >= PAGE_SIZE) 230 if (size <= 1 || size >= PAGE_SIZE)
231 return -EINVAL; 231 return -EINVAL;
232 232
233 kbuf = kmalloc(size + 1, GFP_KERNEL); 233 kbuf = memdup_user_nul(buf, size);
234 if (!kbuf) 234 if (IS_ERR(kbuf))
235 return -ENOMEM; 235 return PTR_ERR(kbuf);
236
237 ret = -EFAULT;
238 if (copy_from_user(kbuf, buf, size) != 0)
239 goto done;
240 kbuf[size] = 0;
241 236
242 /* trim to first NL */ 237 /* trim to first NL */
243 name = memchr(kbuf, '\n', size); 238 name = memchr(kbuf, '\n', size);
@@ -315,15 +310,9 @@ static ssize_t afs_proc_rootcell_write(struct file *file,
315 if (size <= 1 || size >= PAGE_SIZE) 310 if (size <= 1 || size >= PAGE_SIZE)
316 return -EINVAL; 311 return -EINVAL;
317 312
318 ret = -ENOMEM; 313 kbuf = memdup_user_nul(buf, size);
319 kbuf = kmalloc(size + 1, GFP_KERNEL); 314 if (IS_ERR(kbuf))
320 if (!kbuf) 315 return PTR_ERR(kbuf);
321 goto nomem;
322
323 ret = -EFAULT;
324 if (copy_from_user(kbuf, buf, size) != 0)
325 goto infault;
326 kbuf[size] = 0;
327 316
328 /* trim to first NL */ 317 /* trim to first NL */
329 s = memchr(kbuf, '\n', size); 318 s = memchr(kbuf, '\n', size);
@@ -337,9 +326,7 @@ static ssize_t afs_proc_rootcell_write(struct file *file,
337 if (ret >= 0) 326 if (ret >= 0)
338 ret = size; /* consume everything, always */ 327 ret = size; /* consume everything, always */
339 328
340infault:
341 kfree(kbuf); 329 kfree(kbuf);
342nomem:
343 _leave(" = %d", ret); 330 _leave(" = %d", ret);
344 return ret; 331 return ret;
345} 332}
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index 861b1e1c4777..103f5d7c3083 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -192,7 +192,7 @@ EXPORT_SYMBOL(make_bad_inode);
192 * Returns true if the inode in question has been marked as bad. 192 * Returns true if the inode in question has been marked as bad.
193 */ 193 */
194 194
195int is_bad_inode(struct inode *inode) 195bool is_bad_inode(struct inode *inode)
196{ 196{
197 return (inode->i_op == &bad_inode_ops); 197 return (inode->i_op == &bad_inode_ops);
198} 198}
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 44d4a1e9244e..01b8e0d4b4ff 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1042,12 +1042,9 @@ EXPORT_SYMBOL_GPL(bd_unlink_disk_holder);
1042static void flush_disk(struct block_device *bdev, bool kill_dirty) 1042static void flush_disk(struct block_device *bdev, bool kill_dirty)
1043{ 1043{
1044 if (__invalidate_device(bdev, kill_dirty)) { 1044 if (__invalidate_device(bdev, kill_dirty)) {
1045 char name[BDEVNAME_SIZE] = "";
1046
1047 if (bdev->bd_disk)
1048 disk_name(bdev->bd_disk, 0, name);
1049 printk(KERN_WARNING "VFS: busy inodes on changed media or " 1045 printk(KERN_WARNING "VFS: busy inodes on changed media or "
1050 "resized disk %s\n", name); 1046 "resized disk %s\n",
1047 bdev->bd_disk ? bdev->bd_disk->disk_name : "");
1051 } 1048 }
1052 1049
1053 if (!bdev->bd_disk) 1050 if (!bdev->bd_disk)
@@ -1071,12 +1068,9 @@ void check_disk_size_change(struct gendisk *disk, struct block_device *bdev)
1071 disk_size = (loff_t)get_capacity(disk) << 9; 1068 disk_size = (loff_t)get_capacity(disk) << 9;
1072 bdev_size = i_size_read(bdev->bd_inode); 1069 bdev_size = i_size_read(bdev->bd_inode);
1073 if (disk_size != bdev_size) { 1070 if (disk_size != bdev_size) {
1074 char name[BDEVNAME_SIZE];
1075
1076 disk_name(disk, 0, name);
1077 printk(KERN_INFO 1071 printk(KERN_INFO
1078 "%s: detected capacity change from %lld to %lld\n", 1072 "%s: detected capacity change from %lld to %lld\n",
1079 name, bdev_size, disk_size); 1073 disk->disk_name, bdev_size, disk_size);
1080 i_size_write(bdev->bd_inode, disk_size); 1074 i_size_write(bdev->bd_inode, disk_size);
1081 flush_disk(bdev, false); 1075 flush_disk(bdev, false);
1082 } 1076 }
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 24154e422945..a0434c179ea9 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1514,9 +1514,7 @@ static struct dentry *btrfs_mount(struct file_system_type *fs_type, int flags,
1514 if ((flags ^ s->s_flags) & MS_RDONLY) 1514 if ((flags ^ s->s_flags) & MS_RDONLY)
1515 error = -EBUSY; 1515 error = -EBUSY;
1516 } else { 1516 } else {
1517 char b[BDEVNAME_SIZE]; 1517 snprintf(s->s_id, sizeof(s->s_id), "%pg", bdev);
1518
1519 strlcpy(s->s_id, bdevname(bdev, b), sizeof(s->s_id));
1520 btrfs_sb(s)->bdev_holder = fs_type; 1518 btrfs_sb(s)->bdev_holder = fs_type;
1521 error = btrfs_fill_super(s, fs_devices, data, 1519 error = btrfs_fill_super(s, fs_devices, data,
1522 flags & MS_SILENT ? 1 : 0); 1520 flags & MS_SILENT ? 1 : 0);
diff --git a/fs/buffer.c b/fs/buffer.c
index 4f4cd959da7c..e1632abb4ca9 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -134,13 +134,10 @@ __clear_page_buffers(struct page *page)
134 134
135static void buffer_io_error(struct buffer_head *bh, char *msg) 135static void buffer_io_error(struct buffer_head *bh, char *msg)
136{ 136{
137 char b[BDEVNAME_SIZE];
138
139 if (!test_bit(BH_Quiet, &bh->b_state)) 137 if (!test_bit(BH_Quiet, &bh->b_state))
140 printk_ratelimited(KERN_ERR 138 printk_ratelimited(KERN_ERR
141 "Buffer I/O error on dev %s, logical block %llu%s\n", 139 "Buffer I/O error on dev %pg, logical block %llu%s\n",
142 bdevname(bh->b_bdev, b), 140 bh->b_bdev, (unsigned long long)bh->b_blocknr, msg);
143 (unsigned long long)bh->b_blocknr, msg);
144} 141}
145 142
146/* 143/*
@@ -237,15 +234,13 @@ __find_get_block_slow(struct block_device *bdev, sector_t block)
237 * elsewhere, don't buffer_error if we had some unmapped buffers 234 * elsewhere, don't buffer_error if we had some unmapped buffers
238 */ 235 */
239 if (all_mapped) { 236 if (all_mapped) {
240 char b[BDEVNAME_SIZE];
241
242 printk("__find_get_block_slow() failed. " 237 printk("__find_get_block_slow() failed. "
243 "block=%llu, b_blocknr=%llu\n", 238 "block=%llu, b_blocknr=%llu\n",
244 (unsigned long long)block, 239 (unsigned long long)block,
245 (unsigned long long)bh->b_blocknr); 240 (unsigned long long)bh->b_blocknr);
246 printk("b_state=0x%08lx, b_size=%zu\n", 241 printk("b_state=0x%08lx, b_size=%zu\n",
247 bh->b_state, bh->b_size); 242 bh->b_state, bh->b_size);
248 printk("device %s blocksize: %d\n", bdevname(bdev, b), 243 printk("device %pg blocksize: %d\n", bdev,
249 1 << bd_inode->i_blkbits); 244 1 << bd_inode->i_blkbits);
250 } 245 }
251out_unlock: 246out_unlock:
@@ -531,10 +526,8 @@ repeat:
531 526
532static void do_thaw_one(struct super_block *sb, void *unused) 527static void do_thaw_one(struct super_block *sb, void *unused)
533{ 528{
534 char b[BDEVNAME_SIZE];
535 while (sb->s_bdev && !thaw_bdev(sb->s_bdev, sb)) 529 while (sb->s_bdev && !thaw_bdev(sb->s_bdev, sb))
536 printk(KERN_WARNING "Emergency Thaw on %s\n", 530 printk(KERN_WARNING "Emergency Thaw on %pg\n", sb->s_bdev);
537 bdevname(sb->s_bdev, b));
538} 531}
539 532
540static void do_thaw_all(struct work_struct *work) 533static void do_thaw_all(struct work_struct *work)
@@ -1074,12 +1067,10 @@ grow_buffers(struct block_device *bdev, sector_t block, int size, gfp_t gfp)
1074 * pagecache index. (this comparison is done using sector_t types). 1067 * pagecache index. (this comparison is done using sector_t types).
1075 */ 1068 */
1076 if (unlikely(index != block >> sizebits)) { 1069 if (unlikely(index != block >> sizebits)) {
1077 char b[BDEVNAME_SIZE];
1078
1079 printk(KERN_ERR "%s: requested out-of-range block %llu for " 1070 printk(KERN_ERR "%s: requested out-of-range block %llu for "
1080 "device %s\n", 1071 "device %pg\n",
1081 __func__, (unsigned long long)block, 1072 __func__, (unsigned long long)block,
1082 bdevname(bdev, b)); 1073 bdev);
1083 return -EIO; 1074 return -EIO;
1084 } 1075 }
1085 1076
diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
index f601def05bdf..452e98dd7560 100644
--- a/fs/cachefiles/daemon.c
+++ b/fs/cachefiles/daemon.c
@@ -226,15 +226,9 @@ static ssize_t cachefiles_daemon_write(struct file *file,
226 return -EOPNOTSUPP; 226 return -EOPNOTSUPP;
227 227
228 /* drag the command string into the kernel so we can parse it */ 228 /* drag the command string into the kernel so we can parse it */
229 data = kmalloc(datalen + 1, GFP_KERNEL); 229 data = memdup_user_nul(_data, datalen);
230 if (!data) 230 if (IS_ERR(data))
231 return -ENOMEM; 231 return PTR_ERR(data);
232
233 ret = -EFAULT;
234 if (copy_from_user(data, _data, datalen) != 0)
235 goto error;
236
237 data[datalen] = '\0';
238 232
239 ret = -EINVAL; 233 ret = -EINVAL;
240 if (memchr(data, '\0', datalen)) 234 if (memchr(data, '\0', datalen))
diff --git a/fs/compat.c b/fs/compat.c
index 6fd272d455e4..a71936a3f4cb 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -792,7 +792,7 @@ COMPAT_SYSCALL_DEFINE5(mount, const char __user *, dev_name,
792 const void __user *, data) 792 const void __user *, data)
793{ 793{
794 char *kernel_type; 794 char *kernel_type;
795 unsigned long data_page; 795 void *options;
796 char *kernel_dev; 796 char *kernel_dev;
797 int retval; 797 int retval;
798 798
@@ -806,26 +806,25 @@ COMPAT_SYSCALL_DEFINE5(mount, const char __user *, dev_name,
806 if (IS_ERR(kernel_dev)) 806 if (IS_ERR(kernel_dev))
807 goto out1; 807 goto out1;
808 808
809 retval = copy_mount_options(data, &data_page); 809 options = copy_mount_options(data);
810 if (retval < 0) 810 retval = PTR_ERR(options);
811 if (IS_ERR(options))
811 goto out2; 812 goto out2;
812 813
813 retval = -EINVAL; 814 if (kernel_type && options) {
814
815 if (kernel_type && data_page) {
816 if (!strcmp(kernel_type, NCPFS_NAME)) { 815 if (!strcmp(kernel_type, NCPFS_NAME)) {
817 do_ncp_super_data_conv((void *)data_page); 816 do_ncp_super_data_conv(options);
818 } else if (!strcmp(kernel_type, NFS4_NAME)) { 817 } else if (!strcmp(kernel_type, NFS4_NAME)) {
819 if (do_nfs4_super_data_conv((void *) data_page)) 818 retval = -EINVAL;
819 if (do_nfs4_super_data_conv(options))
820 goto out3; 820 goto out3;
821 } 821 }
822 } 822 }
823 823
824 retval = do_mount(kernel_dev, dir_name, kernel_type, 824 retval = do_mount(kernel_dev, dir_name, kernel_type, flags, options);
825 flags, (void*)data_page);
826 825
827 out3: 826 out3:
828 free_page(data_page); 827 kfree(options);
829 out2: 828 out2:
830 kfree(kernel_dev); 829 kfree(kernel_dev);
831 out1: 830 out1:
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 647ee0b03dc0..a5b8eb69a8f4 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -1305,12 +1305,6 @@ COMPATIBLE_IOCTL(PCIIOC_CONTROLLER)
1305COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO) 1305COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO)
1306COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_MEM) 1306COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_MEM)
1307COMPATIBLE_IOCTL(PCIIOC_WRITE_COMBINE) 1307COMPATIBLE_IOCTL(PCIIOC_WRITE_COMBINE)
1308/* NBD */
1309COMPATIBLE_IOCTL(NBD_DO_IT)
1310COMPATIBLE_IOCTL(NBD_CLEAR_SOCK)
1311COMPATIBLE_IOCTL(NBD_CLEAR_QUE)
1312COMPATIBLE_IOCTL(NBD_PRINT_DEBUG)
1313COMPATIBLE_IOCTL(NBD_DISCONNECT)
1314/* i2c */ 1308/* i2c */
1315COMPATIBLE_IOCTL(I2C_SLAVE) 1309COMPATIBLE_IOCTL(I2C_SLAVE)
1316COMPATIBLE_IOCTL(I2C_SLAVE_FORCE) 1310COMPATIBLE_IOCTL(I2C_SLAVE_FORCE)
@@ -1529,11 +1523,6 @@ static long do_ioctl_trans(unsigned int cmd,
1529 case KDSKBMETA: 1523 case KDSKBMETA:
1530 case KDSKBLED: 1524 case KDSKBLED:
1531 case KDSETLED: 1525 case KDSETLED:
1532 /* NBD */
1533 case NBD_SET_SOCK:
1534 case NBD_SET_BLKSIZE:
1535 case NBD_SET_SIZE:
1536 case NBD_SET_SIZE_BLOCKS:
1537 return vfs_ioctl(file, cmd, arg); 1526 return vfs_ioctl(file, cmd, arg);
1538 } 1527 }
1539 1528
diff --git a/fs/coredump.c b/fs/coredump.c
index 1777331eee76..b3c153ca435d 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -32,6 +32,7 @@
32#include <linux/pipe_fs_i.h> 32#include <linux/pipe_fs_i.h>
33#include <linux/oom.h> 33#include <linux/oom.h>
34#include <linux/compat.h> 34#include <linux/compat.h>
35#include <linux/timekeeping.h>
35 36
36#include <asm/uaccess.h> 37#include <asm/uaccess.h>
37#include <asm/mmu_context.h> 38#include <asm/mmu_context.h>
@@ -232,9 +233,10 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
232 break; 233 break;
233 /* UNIX time of coredump */ 234 /* UNIX time of coredump */
234 case 't': { 235 case 't': {
235 struct timeval tv; 236 time64_t time;
236 do_gettimeofday(&tv); 237
237 err = cn_printf(cn, "%lu", tv.tv_sec); 238 time = ktime_get_real_seconds();
239 err = cn_printf(cn, "%lld", time);
238 break; 240 break;
239 } 241 }
240 /* hostname */ 242 /* hostname */
diff --git a/fs/dcache.c b/fs/dcache.c
index d27f0909d9f6..8d38cd07b207 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -3303,18 +3303,18 @@ out:
3303 * @new_dentry: new dentry 3303 * @new_dentry: new dentry
3304 * @old_dentry: old dentry 3304 * @old_dentry: old dentry
3305 * 3305 *
3306 * Returns 1 if new_dentry is a subdirectory of the parent (at any depth). 3306 * Returns true if new_dentry is a subdirectory of the parent (at any depth).
3307 * Returns 0 otherwise. 3307 * Returns false otherwise.
3308 * Caller must ensure that "new_dentry" is pinned before calling is_subdir() 3308 * Caller must ensure that "new_dentry" is pinned before calling is_subdir()
3309 */ 3309 */
3310 3310
3311int is_subdir(struct dentry *new_dentry, struct dentry *old_dentry) 3311bool is_subdir(struct dentry *new_dentry, struct dentry *old_dentry)
3312{ 3312{
3313 int result; 3313 bool result;
3314 unsigned seq; 3314 unsigned seq;
3315 3315
3316 if (new_dentry == old_dentry) 3316 if (new_dentry == old_dentry)
3317 return 1; 3317 return true;
3318 3318
3319 do { 3319 do {
3320 /* for restarting inner loop in case of seq retry */ 3320 /* for restarting inner loop in case of seq retry */
@@ -3325,9 +3325,9 @@ int is_subdir(struct dentry *new_dentry, struct dentry *old_dentry)
3325 */ 3325 */
3326 rcu_read_lock(); 3326 rcu_read_lock();
3327 if (d_ancestor(old_dentry, new_dentry)) 3327 if (d_ancestor(old_dentry, new_dentry))
3328 result = 1; 3328 result = true;
3329 else 3329 else
3330 result = 0; 3330 result = false;
3331 rcu_read_unlock(); 3331 rcu_read_unlock();
3332 } while (read_seqretry(&rename_lock, seq)); 3332 } while (read_seqretry(&rename_lock, seq));
3333 3333
diff --git a/fs/dlm/user.c b/fs/dlm/user.c
index 173b3873a4f4..1925d6d222b8 100644
--- a/fs/dlm/user.c
+++ b/fs/dlm/user.c
@@ -515,14 +515,9 @@ static ssize_t device_write(struct file *file, const char __user *buf,
515 if (count > sizeof(struct dlm_write_request) + DLM_RESNAME_MAXLEN) 515 if (count > sizeof(struct dlm_write_request) + DLM_RESNAME_MAXLEN)
516 return -EINVAL; 516 return -EINVAL;
517 517
518 kbuf = kzalloc(count + 1, GFP_NOFS); 518 kbuf = memdup_user_nul(buf, count);
519 if (!kbuf) 519 if (!IS_ERR(kbuf))
520 return -ENOMEM; 520 return PTR_ERR(kbuf);
521
522 if (copy_from_user(kbuf, buf, count)) {
523 error = -EFAULT;
524 goto out_free;
525 }
526 521
527 if (check_version(kbuf)) { 522 if (check_version(kbuf)) {
528 error = -EBADE; 523 error = -EBADE;
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index a4dddc61594c..040aa879d634 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -282,9 +282,7 @@ ecryptfs_create(struct inode *directory_inode, struct dentry *ecryptfs_dentry,
282 if (rc) { 282 if (rc) {
283 ecryptfs_do_unlink(directory_inode, ecryptfs_dentry, 283 ecryptfs_do_unlink(directory_inode, ecryptfs_dentry,
284 ecryptfs_inode); 284 ecryptfs_inode);
285 make_bad_inode(ecryptfs_inode); 285 iget_failed(ecryptfs_inode);
286 unlock_new_inode(ecryptfs_inode);
287 iput(ecryptfs_inode);
288 goto out; 286 goto out;
289 } 287 }
290 unlock_new_inode(ecryptfs_inode); 288 unlock_new_inode(ecryptfs_inode);
diff --git a/fs/exec.c b/fs/exec.c
index b06623a9347f..828ec5f07de0 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -119,7 +119,7 @@ SYSCALL_DEFINE1(uselib, const char __user *, library)
119 int error = PTR_ERR(tmp); 119 int error = PTR_ERR(tmp);
120 static const struct open_flags uselib_flags = { 120 static const struct open_flags uselib_flags = {
121 .open_flag = O_LARGEFILE | O_RDONLY | __FMODE_EXEC, 121 .open_flag = O_LARGEFILE | O_RDONLY | __FMODE_EXEC,
122 .acc_mode = MAY_READ | MAY_EXEC | MAY_OPEN, 122 .acc_mode = MAY_READ | MAY_EXEC,
123 .intent = LOOKUP_OPEN, 123 .intent = LOOKUP_OPEN,
124 .lookup_flags = LOOKUP_FOLLOW, 124 .lookup_flags = LOOKUP_FOLLOW,
125 }; 125 };
@@ -763,7 +763,7 @@ static struct file *do_open_execat(int fd, struct filename *name, int flags)
763 int err; 763 int err;
764 struct open_flags open_exec_flags = { 764 struct open_flags open_exec_flags = {
765 .open_flag = O_LARGEFILE | O_RDONLY | __FMODE_EXEC, 765 .open_flag = O_LARGEFILE | O_RDONLY | __FMODE_EXEC,
766 .acc_mode = MAY_EXEC | MAY_OPEN, 766 .acc_mode = MAY_EXEC,
767 .intent = LOOKUP_OPEN, 767 .intent = LOOKUP_OPEN,
768 .lookup_flags = LOOKUP_FOLLOW, 768 .lookup_flags = LOOKUP_FOLLOW,
769 }; 769 };
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
index cd95d14f9cc2..f57a7aba32eb 100644
--- a/fs/ext2/xattr.c
+++ b/fs/ext2/xattr.c
@@ -77,10 +77,8 @@
77 printk("\n"); \ 77 printk("\n"); \
78 } while (0) 78 } while (0)
79# define ea_bdebug(bh, f...) do { \ 79# define ea_bdebug(bh, f...) do { \
80 char b[BDEVNAME_SIZE]; \ 80 printk(KERN_DEBUG "block %pg:%lu: ", \
81 printk(KERN_DEBUG "block %s:%lu: ", \ 81 bh->b_bdev, (unsigned long) bh->b_blocknr); \
82 bdevname(bh->b_bdev, b), \
83 (unsigned long) bh->b_blocknr); \
84 printk(f); \ 82 printk(f); \
85 printk("\n"); \ 83 printk("\n"); \
86 } while (0) 84 } while (0)
diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index 17fbe3882b8e..090b3498638e 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -52,9 +52,8 @@ void ext4_exit_pageio(void)
52 */ 52 */
53static void buffer_io_error(struct buffer_head *bh) 53static void buffer_io_error(struct buffer_head *bh)
54{ 54{
55 char b[BDEVNAME_SIZE]; 55 printk_ratelimited(KERN_ERR "Buffer I/O error on device %pg, logical block %llu\n",
56 printk_ratelimited(KERN_ERR "Buffer I/O error on device %s, logical block %llu\n", 56 bh->b_bdev,
57 bdevname(bh->b_bdev, b),
58 (unsigned long long)bh->b_blocknr); 57 (unsigned long long)bh->b_blocknr);
59} 58}
60 59
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index e9b9afdd1d96..a95151e875bd 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -68,10 +68,8 @@
68 printk("\n"); \ 68 printk("\n"); \
69 } while (0) 69 } while (0)
70# define ea_bdebug(bh, f...) do { \ 70# define ea_bdebug(bh, f...) do { \
71 char b[BDEVNAME_SIZE]; \ 71 printk(KERN_DEBUG "block %pg:%lu: ", \
72 printk(KERN_DEBUG "block %s:%lu: ", \ 72 bh->b_bdev, (unsigned long) bh->b_blocknr); \
73 bdevname(bh->b_bdev, b), \
74 (unsigned long) bh->b_blocknr); \
75 printk(f); \ 73 printk(f); \
76 printk("\n"); \ 74 printk("\n"); \
77 } while (0) 75 } while (0)
diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c
index 478e5d54154f..ad1b18a7705b 100644
--- a/fs/f2fs/debug.c
+++ b/fs/f2fs/debug.c
@@ -211,12 +211,10 @@ static int stat_show(struct seq_file *s, void *v)
211 211
212 mutex_lock(&f2fs_stat_mutex); 212 mutex_lock(&f2fs_stat_mutex);
213 list_for_each_entry(si, &f2fs_stat_list, stat_list) { 213 list_for_each_entry(si, &f2fs_stat_list, stat_list) {
214 char devname[BDEVNAME_SIZE];
215
216 update_general_status(si->sbi); 214 update_general_status(si->sbi);
217 215
218 seq_printf(s, "\n=====[ partition info(%s). #%d ]=====\n", 216 seq_printf(s, "\n=====[ partition info(%pg). #%d ]=====\n",
219 bdevname(si->sbi->sb->s_bdev, devname), i++); 217 si->sbi->sb->s_bdev, i++);
220 seq_printf(s, "[SB: 1] [CP: 2] [SIT: %d] [NAT: %d] ", 218 seq_printf(s, "[SB: 1] [CP: 2] [SIT: %d] [NAT: %d] ",
221 si->sit_area_segs, si->nat_area_segs); 219 si->sit_area_segs, si->nat_area_segs);
222 seq_printf(s, "[SSA: %d] [MAIN: %d", 220 seq_printf(s, "[SSA: %d] [MAIN: %d",
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 9db5500d63d9..ec6067c33a3f 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1602,13 +1602,11 @@ static inline bool is_dot_dotdot(const struct qstr *str)
1602 1602
1603static inline bool f2fs_may_extent_tree(struct inode *inode) 1603static inline bool f2fs_may_extent_tree(struct inode *inode)
1604{ 1604{
1605 mode_t mode = inode->i_mode;
1606
1607 if (!test_opt(F2FS_I_SB(inode), EXTENT_CACHE) || 1605 if (!test_opt(F2FS_I_SB(inode), EXTENT_CACHE) ||
1608 is_inode_flag_set(F2FS_I(inode), FI_NO_EXTENT)) 1606 is_inode_flag_set(F2FS_I(inode), FI_NO_EXTENT))
1609 return false; 1607 return false;
1610 1608
1611 return S_ISREG(mode); 1609 return S_ISREG(inode->i_mode);
1612} 1610}
1613 1611
1614static inline void *f2fs_kvmalloc(size_t size, gfp_t flags) 1612static inline void *f2fs_kvmalloc(size_t size, gfp_t flags)
@@ -2121,7 +2119,7 @@ static inline int f2fs_sb_has_crypto(struct super_block *sb)
2121static inline bool f2fs_may_encrypt(struct inode *inode) 2119static inline bool f2fs_may_encrypt(struct inode *inode)
2122{ 2120{
2123#ifdef CONFIG_F2FS_FS_ENCRYPTION 2121#ifdef CONFIG_F2FS_FS_ENCRYPTION
2124 mode_t mode = inode->i_mode; 2122 umode_t mode = inode->i_mode;
2125 2123
2126 return (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)); 2124 return (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode));
2127#else 2125#else
diff --git a/fs/fcntl.c b/fs/fcntl.c
index ee85cd4e136a..350a2c8cfd28 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -51,7 +51,8 @@ static int setfl(int fd, struct file * filp, unsigned long arg)
51 if (arg & O_NDELAY) 51 if (arg & O_NDELAY)
52 arg |= O_NONBLOCK; 52 arg |= O_NONBLOCK;
53 53
54 if (arg & O_DIRECT) { 54 /* Pipe packetized mode is controlled by O_DIRECT flag */
55 if (!S_ISFIFO(filp->f_inode->i_mode) && (arg & O_DIRECT)) {
55 if (!filp->f_mapping || !filp->f_mapping->a_ops || 56 if (!filp->f_mapping || !filp->f_mapping->a_ops ||
56 !filp->f_mapping->a_ops->direct_IO) 57 !filp->f_mapping->a_ops->direct_IO)
57 return -EINVAL; 58 return -EINVAL;
diff --git a/fs/file.c b/fs/file.c
index 39f8f15921da..1aed0add16a2 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -25,9 +25,9 @@
25 25
26int sysctl_nr_open __read_mostly = 1024*1024; 26int sysctl_nr_open __read_mostly = 1024*1024;
27int sysctl_nr_open_min = BITS_PER_LONG; 27int sysctl_nr_open_min = BITS_PER_LONG;
28/* our max() is unusable in constant expressions ;-/ */ 28/* our min() is unusable in constant expressions ;-/ */
29#define __const_max(x, y) ((x) < (y) ? (x) : (y)) 29#define __const_min(x, y) ((x) < (y) ? (x) : (y))
30int sysctl_nr_open_max = __const_max(INT_MAX, ~(size_t)0/sizeof(void *)) & 30int sysctl_nr_open_max = __const_min(INT_MAX, ~(size_t)0/sizeof(void *)) &
31 -BITS_PER_LONG; 31 -BITS_PER_LONG;
32 32
33static void *alloc_fdmem(size_t size) 33static void *alloc_fdmem(size_t size)
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index baab99b69d8a..001c66641243 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -1315,9 +1315,7 @@ static struct dentry *gfs2_mount(struct file_system_type *fs_type, int flags,
1315 if ((flags ^ s->s_flags) & MS_RDONLY) 1315 if ((flags ^ s->s_flags) & MS_RDONLY)
1316 goto error_super; 1316 goto error_super;
1317 } else { 1317 } else {
1318 char b[BDEVNAME_SIZE]; 1318 snprintf(s->s_id, sizeof(s->s_id), "%pg", bdev);
1319
1320 strlcpy(s->s_id, bdevname(bdev, b), sizeof(s->s_id));
1321 sb_set_blocksize(s, block_size(bdev)); 1319 sb_set_blocksize(s, block_size(bdev));
1322 error = fill_super(s, &args, flags & MS_SILENT ? 1 : 0); 1320 error = fill_super(s, &args, flags & MS_SILENT ? 1 : 0);
1323 if (error) 1321 if (error)
diff --git a/fs/hfs/mdb.c b/fs/hfs/mdb.c
index aa3f0d6d043c..a3ec3ae7d347 100644
--- a/fs/hfs/mdb.c
+++ b/fs/hfs/mdb.c
@@ -166,7 +166,7 @@ int hfs_mdb_get(struct super_block *sb)
166 pr_warn("continuing without an alternate MDB\n"); 166 pr_warn("continuing without an alternate MDB\n");
167 } 167 }
168 168
169 HFS_SB(sb)->bitmap = (__be32 *)__get_free_pages(GFP_KERNEL, PAGE_SIZE < 8192 ? 1 : 0); 169 HFS_SB(sb)->bitmap = kmalloc(8192, GFP_KERNEL);
170 if (!HFS_SB(sb)->bitmap) 170 if (!HFS_SB(sb)->bitmap)
171 goto out; 171 goto out;
172 172
@@ -360,7 +360,7 @@ void hfs_mdb_put(struct super_block *sb)
360 unload_nls(HFS_SB(sb)->nls_io); 360 unload_nls(HFS_SB(sb)->nls_io);
361 unload_nls(HFS_SB(sb)->nls_disk); 361 unload_nls(HFS_SB(sb)->nls_disk);
362 362
363 free_pages((unsigned long)HFS_SB(sb)->bitmap, PAGE_SIZE < 8192 ? 1 : 0); 363 kfree(HFS_SB(sb)->bitmap);
364 kfree(HFS_SB(sb)); 364 kfree(HFS_SB(sb));
365 sb->s_fs_info = NULL; 365 sb->s_fs_info = NULL;
366} 366}
diff --git a/fs/hpfs/map.c b/fs/hpfs/map.c
index a69bbc1e87f8..a136929189f0 100644
--- a/fs/hpfs/map.c
+++ b/fs/hpfs/map.c
@@ -133,7 +133,7 @@ __le32 *hpfs_load_bitmap_directory(struct super_block *s, secno bmp)
133void hpfs_load_hotfix_map(struct super_block *s, struct hpfs_spare_block *spareblock) 133void hpfs_load_hotfix_map(struct super_block *s, struct hpfs_spare_block *spareblock)
134{ 134{
135 struct quad_buffer_head qbh; 135 struct quad_buffer_head qbh;
136 u32 *directory; 136 __le32 *directory;
137 u32 n_hotfixes, n_used_hotfixes; 137 u32 n_hotfixes, n_used_hotfixes;
138 unsigned i; 138 unsigned i;
139 139
diff --git a/fs/internal.h b/fs/internal.h
index e38c08ca437d..b71deeecea17 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -55,7 +55,7 @@ extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
55/* 55/*
56 * namespace.c 56 * namespace.c
57 */ 57 */
58extern int copy_mount_options(const void __user *, unsigned long *); 58extern void *copy_mount_options(const void __user *);
59extern char *copy_mount_string(const void __user *); 59extern char *copy_mount_string(const void __user *);
60 60
61extern struct vfsmount *lookup_mnt(struct path *); 61extern struct vfsmount *lookup_mnt(struct path *);
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index ca181e81c765..081dff087fc0 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -764,13 +764,11 @@ void jbd2_journal_unlock_updates (journal_t *journal)
764 764
765static void warn_dirty_buffer(struct buffer_head *bh) 765static void warn_dirty_buffer(struct buffer_head *bh)
766{ 766{
767 char b[BDEVNAME_SIZE];
768
769 printk(KERN_WARNING 767 printk(KERN_WARNING
770 "JBD2: Spotted dirty metadata buffer (dev = %s, blocknr = %llu). " 768 "JBD2: Spotted dirty metadata buffer (dev = %pg, blocknr = %llu). "
771 "There's a risk of filesystem corruption in case of system " 769 "There's a risk of filesystem corruption in case of system "
772 "crash.\n", 770 "crash.\n",
773 bdevname(bh->b_bdev, b), (unsigned long long)bh->b_blocknr); 771 bh->b_bdev, (unsigned long long)bh->b_blocknr);
774} 772}
775 773
776/* Call t_frozen trigger and copy buffer data into jh->b_frozen_data. */ 774/* Call t_frozen trigger and copy buffer data into jh->b_frozen_data. */
diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c
index a69bdf2a1085..a270cb7ff4e0 100644
--- a/fs/jfs/jfs_logmgr.c
+++ b/fs/jfs/jfs_logmgr.c
@@ -1835,17 +1835,16 @@ static int lbmLogInit(struct jfs_log * log)
1835 for (i = 0; i < LOGPAGES;) { 1835 for (i = 0; i < LOGPAGES;) {
1836 char *buffer; 1836 char *buffer;
1837 uint offset; 1837 uint offset;
1838 struct page *page; 1838 struct page *page = alloc_page(GFP_KERNEL | __GFP_ZERO);
1839 1839
1840 buffer = (char *) get_zeroed_page(GFP_KERNEL); 1840 if (!page)
1841 if (buffer == NULL)
1842 goto error; 1841 goto error;
1843 page = virt_to_page(buffer); 1842 buffer = page_address(page);
1844 for (offset = 0; offset < PAGE_SIZE; offset += LOGPSIZE) { 1843 for (offset = 0; offset < PAGE_SIZE; offset += LOGPSIZE) {
1845 lbuf = kmalloc(sizeof(struct lbuf), GFP_KERNEL); 1844 lbuf = kmalloc(sizeof(struct lbuf), GFP_KERNEL);
1846 if (lbuf == NULL) { 1845 if (lbuf == NULL) {
1847 if (offset == 0) 1846 if (offset == 0)
1848 free_page((unsigned long) buffer); 1847 __free_page(page);
1849 goto error; 1848 goto error;
1850 } 1849 }
1851 if (offset) /* we already have one reference */ 1850 if (offset) /* we already have one reference */
diff --git a/fs/logfs/logfs.h b/fs/logfs/logfs.h
index 209a26d84c38..39d91f86cd35 100644
--- a/fs/logfs/logfs.h
+++ b/fs/logfs/logfs.h
@@ -302,7 +302,7 @@ struct logfs_block {
302 struct inode *inode; 302 struct inode *inode;
303 struct logfs_transaction *ta; 303 struct logfs_transaction *ta;
304 unsigned long alias_map[LOGFS_BLOCK_FACTOR / BITS_PER_LONG]; 304 unsigned long alias_map[LOGFS_BLOCK_FACTOR / BITS_PER_LONG];
305 struct logfs_block_ops *ops; 305 const struct logfs_block_ops *ops;
306 int full; 306 int full;
307 int partial; 307 int partial;
308 int reserved_bytes; 308 int reserved_bytes;
@@ -578,7 +578,7 @@ int logfs_exist_block(struct inode *inode, u64 bix);
578int get_page_reserve(struct inode *inode, struct page *page); 578int get_page_reserve(struct inode *inode, struct page *page);
579void logfs_get_wblocks(struct super_block *sb, struct page *page, int lock); 579void logfs_get_wblocks(struct super_block *sb, struct page *page, int lock);
580void logfs_put_wblocks(struct super_block *sb, struct page *page, int lock); 580void logfs_put_wblocks(struct super_block *sb, struct page *page, int lock);
581extern struct logfs_block_ops indirect_block_ops; 581extern const struct logfs_block_ops indirect_block_ops;
582 582
583/* segment.c */ 583/* segment.c */
584int logfs_erase_segment(struct super_block *sb, u32 ofs, int ensure_erase); 584int logfs_erase_segment(struct super_block *sb, u32 ofs, int ensure_erase);
diff --git a/fs/logfs/readwrite.c b/fs/logfs/readwrite.c
index 380d86e1ab45..20973c9e52f8 100644
--- a/fs/logfs/readwrite.c
+++ b/fs/logfs/readwrite.c
@@ -569,13 +569,13 @@ static void indirect_free_block(struct super_block *sb,
569} 569}
570 570
571 571
572static struct logfs_block_ops inode_block_ops = { 572static const struct logfs_block_ops inode_block_ops = {
573 .write_block = inode_write_block, 573 .write_block = inode_write_block,
574 .free_block = inode_free_block, 574 .free_block = inode_free_block,
575 .write_alias = inode_write_alias, 575 .write_alias = inode_write_alias,
576}; 576};
577 577
578struct logfs_block_ops indirect_block_ops = { 578const struct logfs_block_ops indirect_block_ops = {
579 .write_block = indirect_write_block, 579 .write_block = indirect_write_block,
580 .free_block = indirect_free_block, 580 .free_block = indirect_free_block,
581 .write_alias = indirect_write_alias, 581 .write_alias = indirect_write_alias,
diff --git a/fs/logfs/segment.c b/fs/logfs/segment.c
index 6de0fbfc6c00..d270e4b2ab6b 100644
--- a/fs/logfs/segment.c
+++ b/fs/logfs/segment.c
@@ -197,7 +197,7 @@ static int btree_write_alias(struct super_block *sb, struct logfs_block *block,
197 return 0; 197 return 0;
198} 198}
199 199
200static struct logfs_block_ops btree_block_ops = { 200static const struct logfs_block_ops btree_block_ops = {
201 .write_block = btree_write_block, 201 .write_block = btree_write_block,
202 .free_block = __free_block, 202 .free_block = __free_block,
203 .write_alias = btree_write_alias, 203 .write_alias = btree_write_alias,
diff --git a/fs/minix/itree_v1.c b/fs/minix/itree_v1.c
index 282e15ad8cd8..46ca39d6c735 100644
--- a/fs/minix/itree_v1.c
+++ b/fs/minix/itree_v1.c
@@ -24,16 +24,15 @@ static inline block_t *i_data(struct inode *inode)
24static int block_to_path(struct inode * inode, long block, int offsets[DEPTH]) 24static int block_to_path(struct inode * inode, long block, int offsets[DEPTH])
25{ 25{
26 int n = 0; 26 int n = 0;
27 char b[BDEVNAME_SIZE];
28 27
29 if (block < 0) { 28 if (block < 0) {
30 printk("MINIX-fs: block_to_path: block %ld < 0 on dev %s\n", 29 printk("MINIX-fs: block_to_path: block %ld < 0 on dev %pg\n",
31 block, bdevname(inode->i_sb->s_bdev, b)); 30 block, inode->i_sb->s_bdev);
32 } else if (block >= (minix_sb(inode->i_sb)->s_max_size/BLOCK_SIZE)) { 31 } else if (block >= (minix_sb(inode->i_sb)->s_max_size/BLOCK_SIZE)) {
33 if (printk_ratelimit()) 32 if (printk_ratelimit())
34 printk("MINIX-fs: block_to_path: " 33 printk("MINIX-fs: block_to_path: "
35 "block %ld too big on dev %s\n", 34 "block %ld too big on dev %pg\n",
36 block, bdevname(inode->i_sb->s_bdev, b)); 35 block, inode->i_sb->s_bdev);
37 } else if (block < 7) { 36 } else if (block < 7) {
38 offsets[n++] = block; 37 offsets[n++] = block;
39 } else if ((block -= 7) < 512) { 38 } else if ((block -= 7) < 512) {
diff --git a/fs/minix/itree_v2.c b/fs/minix/itree_v2.c
index 78e2d93e5c83..1ee101352586 100644
--- a/fs/minix/itree_v2.c
+++ b/fs/minix/itree_v2.c
@@ -26,18 +26,17 @@ static inline block_t *i_data(struct inode *inode)
26static int block_to_path(struct inode * inode, long block, int offsets[DEPTH]) 26static int block_to_path(struct inode * inode, long block, int offsets[DEPTH])
27{ 27{
28 int n = 0; 28 int n = 0;
29 char b[BDEVNAME_SIZE];
30 struct super_block *sb = inode->i_sb; 29 struct super_block *sb = inode->i_sb;
31 30
32 if (block < 0) { 31 if (block < 0) {
33 printk("MINIX-fs: block_to_path: block %ld < 0 on dev %s\n", 32 printk("MINIX-fs: block_to_path: block %ld < 0 on dev %pg\n",
34 block, bdevname(sb->s_bdev, b)); 33 block, sb->s_bdev);
35 } else if ((u64)block * (u64)sb->s_blocksize >= 34 } else if ((u64)block * (u64)sb->s_blocksize >=
36 minix_sb(sb)->s_max_size) { 35 minix_sb(sb)->s_max_size) {
37 if (printk_ratelimit()) 36 if (printk_ratelimit())
38 printk("MINIX-fs: block_to_path: " 37 printk("MINIX-fs: block_to_path: "
39 "block %ld too big on dev %s\n", 38 "block %ld too big on dev %pg\n",
40 block, bdevname(sb->s_bdev, b)); 39 block, sb->s_bdev);
41 } else if (block < DIRCOUNT) { 40 } else if (block < DIRCOUNT) {
42 offsets[n++] = block; 41 offsets[n++] = block;
43 } else if ((block -= DIRCOUNT) < INDIRCOUNT(sb)) { 42 } else if ((block -= DIRCOUNT) < INDIRCOUNT(sb)) {
diff --git a/fs/namei.c b/fs/namei.c
index 3c909aebef70..bceefd5588a2 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -534,10 +534,8 @@ static void restore_nameidata(void)
534 current->nameidata = old; 534 current->nameidata = old;
535 if (old) 535 if (old)
536 old->total_link_count = now->total_link_count; 536 old->total_link_count = now->total_link_count;
537 if (now->stack != now->internal) { 537 if (now->stack != now->internal)
538 kfree(now->stack); 538 kfree(now->stack);
539 now->stack = now->internal;
540 }
541} 539}
542 540
543static int __nd_alloc_stack(struct nameidata *nd) 541static int __nd_alloc_stack(struct nameidata *nd)
@@ -654,7 +652,7 @@ static bool legitimize_links(struct nameidata *nd)
654 * Path walking has 2 modes, rcu-walk and ref-walk (see 652 * Path walking has 2 modes, rcu-walk and ref-walk (see
655 * Documentation/filesystems/path-lookup.txt). In situations when we can't 653 * Documentation/filesystems/path-lookup.txt). In situations when we can't
656 * continue in RCU mode, we attempt to drop out of rcu-walk mode and grab 654 * continue in RCU mode, we attempt to drop out of rcu-walk mode and grab
657 * normal reference counts on dentries and vfsmounts to transition to rcu-walk 655 * normal reference counts on dentries and vfsmounts to transition to ref-walk
658 * mode. Refcounts are grabbed at the last known good point before rcu-walk 656 * mode. Refcounts are grabbed at the last known good point before rcu-walk
659 * got stuck, so ref-walk may continue from there. If this is not successful 657 * got stuck, so ref-walk may continue from there. If this is not successful
660 * (eg. a seqcount has changed), then failure is returned and it's up to caller 658 * (eg. a seqcount has changed), then failure is returned and it's up to caller
@@ -804,19 +802,19 @@ static int complete_walk(struct nameidata *nd)
804 802
805static void set_root(struct nameidata *nd) 803static void set_root(struct nameidata *nd)
806{ 804{
807 get_fs_root(current->fs, &nd->root);
808}
809
810static void set_root_rcu(struct nameidata *nd)
811{
812 struct fs_struct *fs = current->fs; 805 struct fs_struct *fs = current->fs;
813 unsigned seq;
814 806
815 do { 807 if (nd->flags & LOOKUP_RCU) {
816 seq = read_seqcount_begin(&fs->seq); 808 unsigned seq;
817 nd->root = fs->root; 809
818 nd->root_seq = __read_seqcount_begin(&nd->root.dentry->d_seq); 810 do {
819 } while (read_seqcount_retry(&fs->seq, seq)); 811 seq = read_seqcount_begin(&fs->seq);
812 nd->root = fs->root;
813 nd->root_seq = __read_seqcount_begin(&nd->root.dentry->d_seq);
814 } while (read_seqcount_retry(&fs->seq, seq));
815 } else {
816 get_fs_root(fs, &nd->root);
817 }
820} 818}
821 819
822static void path_put_conditional(struct path *path, struct nameidata *nd) 820static void path_put_conditional(struct path *path, struct nameidata *nd)
@@ -838,6 +836,26 @@ static inline void path_to_nameidata(const struct path *path,
838 nd->path.dentry = path->dentry; 836 nd->path.dentry = path->dentry;
839} 837}
840 838
839static int nd_jump_root(struct nameidata *nd)
840{
841 if (nd->flags & LOOKUP_RCU) {
842 struct dentry *d;
843 nd->path = nd->root;
844 d = nd->path.dentry;
845 nd->inode = d->d_inode;
846 nd->seq = nd->root_seq;
847 if (unlikely(read_seqcount_retry(&d->d_seq, nd->seq)))
848 return -ECHILD;
849 } else {
850 path_put(&nd->path);
851 nd->path = nd->root;
852 path_get(&nd->path);
853 nd->inode = nd->path.dentry->d_inode;
854 }
855 nd->flags |= LOOKUP_JUMPED;
856 return 0;
857}
858
841/* 859/*
842 * Helper to directly jump to a known parsed path from ->get_link, 860 * Helper to directly jump to a known parsed path from ->get_link,
843 * caller must have taken a reference to path beforehand. 861 * caller must have taken a reference to path beforehand.
@@ -1016,25 +1034,10 @@ const char *get_link(struct nameidata *nd)
1016 return res; 1034 return res;
1017 } 1035 }
1018 if (*res == '/') { 1036 if (*res == '/') {
1019 if (nd->flags & LOOKUP_RCU) { 1037 if (!nd->root.mnt)
1020 struct dentry *d; 1038 set_root(nd);
1021 if (!nd->root.mnt) 1039 if (unlikely(nd_jump_root(nd)))
1022 set_root_rcu(nd); 1040 return ERR_PTR(-ECHILD);
1023 nd->path = nd->root;
1024 d = nd->path.dentry;
1025 nd->inode = d->d_inode;
1026 nd->seq = nd->root_seq;
1027 if (unlikely(read_seqcount_retry(&d->d_seq, nd->seq)))
1028 return ERR_PTR(-ECHILD);
1029 } else {
1030 if (!nd->root.mnt)
1031 set_root(nd);
1032 path_put(&nd->path);
1033 nd->path = nd->root;
1034 path_get(&nd->root);
1035 nd->inode = nd->path.dentry->d_inode;
1036 }
1037 nd->flags |= LOOKUP_JUMPED;
1038 while (unlikely(*++res == '/')) 1041 while (unlikely(*++res == '/'))
1039 ; 1042 ;
1040 } 1043 }
@@ -1295,8 +1298,6 @@ static bool __follow_mount_rcu(struct nameidata *nd, struct path *path,
1295static int follow_dotdot_rcu(struct nameidata *nd) 1298static int follow_dotdot_rcu(struct nameidata *nd)
1296{ 1299{
1297 struct inode *inode = nd->inode; 1300 struct inode *inode = nd->inode;
1298 if (!nd->root.mnt)
1299 set_root_rcu(nd);
1300 1301
1301 while (1) { 1302 while (1) {
1302 if (path_equal(&nd->path, &nd->root)) 1303 if (path_equal(&nd->path, &nd->root))
@@ -1416,9 +1417,6 @@ static void follow_mount(struct path *path)
1416 1417
1417static int follow_dotdot(struct nameidata *nd) 1418static int follow_dotdot(struct nameidata *nd)
1418{ 1419{
1419 if (!nd->root.mnt)
1420 set_root(nd);
1421
1422 while(1) { 1420 while(1) {
1423 struct dentry *old = nd->path.dentry; 1421 struct dentry *old = nd->path.dentry;
1424 1422
@@ -1656,6 +1654,8 @@ static inline int may_lookup(struct nameidata *nd)
1656static inline int handle_dots(struct nameidata *nd, int type) 1654static inline int handle_dots(struct nameidata *nd, int type)
1657{ 1655{
1658 if (type == LAST_DOTDOT) { 1656 if (type == LAST_DOTDOT) {
1657 if (!nd->root.mnt)
1658 set_root(nd);
1659 if (nd->flags & LOOKUP_RCU) { 1659 if (nd->flags & LOOKUP_RCU) {
1660 return follow_dotdot_rcu(nd); 1660 return follow_dotdot_rcu(nd);
1661 } else 1661 } else
@@ -2021,18 +2021,19 @@ static const char *path_init(struct nameidata *nd, unsigned flags)
2021 } 2021 }
2022 2022
2023 nd->root.mnt = NULL; 2023 nd->root.mnt = NULL;
2024 nd->path.mnt = NULL;
2025 nd->path.dentry = NULL;
2024 2026
2025 nd->m_seq = read_seqbegin(&mount_lock); 2027 nd->m_seq = read_seqbegin(&mount_lock);
2026 if (*s == '/') { 2028 if (*s == '/') {
2027 if (flags & LOOKUP_RCU) { 2029 if (flags & LOOKUP_RCU)
2028 rcu_read_lock(); 2030 rcu_read_lock();
2029 set_root_rcu(nd); 2031 set_root(nd);
2030 nd->seq = nd->root_seq; 2032 if (likely(!nd_jump_root(nd)))
2031 } else { 2033 return s;
2032 set_root(nd); 2034 nd->root.mnt = NULL;
2033 path_get(&nd->root); 2035 rcu_read_unlock();
2034 } 2036 return ERR_PTR(-ECHILD);
2035 nd->path = nd->root;
2036 } else if (nd->dfd == AT_FDCWD) { 2037 } else if (nd->dfd == AT_FDCWD) {
2037 if (flags & LOOKUP_RCU) { 2038 if (flags & LOOKUP_RCU) {
2038 struct fs_struct *fs = current->fs; 2039 struct fs_struct *fs = current->fs;
@@ -2043,11 +2044,14 @@ static const char *path_init(struct nameidata *nd, unsigned flags)
2043 do { 2044 do {
2044 seq = read_seqcount_begin(&fs->seq); 2045 seq = read_seqcount_begin(&fs->seq);
2045 nd->path = fs->pwd; 2046 nd->path = fs->pwd;
2047 nd->inode = nd->path.dentry->d_inode;
2046 nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq); 2048 nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq);
2047 } while (read_seqcount_retry(&fs->seq, seq)); 2049 } while (read_seqcount_retry(&fs->seq, seq));
2048 } else { 2050 } else {
2049 get_fs_pwd(current->fs, &nd->path); 2051 get_fs_pwd(current->fs, &nd->path);
2052 nd->inode = nd->path.dentry->d_inode;
2050 } 2053 }
2054 return s;
2051 } else { 2055 } else {
2052 /* Caller must check execute permissions on the starting path component */ 2056 /* Caller must check execute permissions on the starting path component */
2053 struct fd f = fdget_raw(nd->dfd); 2057 struct fd f = fdget_raw(nd->dfd);
@@ -2077,16 +2081,6 @@ static const char *path_init(struct nameidata *nd, unsigned flags)
2077 fdput(f); 2081 fdput(f);
2078 return s; 2082 return s;
2079 } 2083 }
2080
2081 nd->inode = nd->path.dentry->d_inode;
2082 if (!(flags & LOOKUP_RCU))
2083 return s;
2084 if (likely(!read_seqcount_retry(&nd->path.dentry->d_seq, nd->seq)))
2085 return s;
2086 if (!(nd->flags & LOOKUP_ROOT))
2087 nd->root.mnt = NULL;
2088 rcu_read_unlock();
2089 return ERR_PTR(-ECHILD);
2090} 2084}
2091 2085
2092static const char *trailing_symlink(struct nameidata *nd) 2086static const char *trailing_symlink(struct nameidata *nd)
@@ -2279,6 +2273,8 @@ EXPORT_SYMBOL(vfs_path_lookup);
2279 * 2273 *
2280 * Note that this routine is purely a helper for filesystem usage and should 2274 * Note that this routine is purely a helper for filesystem usage and should
2281 * not be called by generic code. 2275 * not be called by generic code.
2276 *
2277 * The caller must hold base->i_mutex.
2282 */ 2278 */
2283struct dentry *lookup_one_len(const char *name, struct dentry *base, int len) 2279struct dentry *lookup_one_len(const char *name, struct dentry *base, int len)
2284{ 2280{
@@ -2322,6 +2318,75 @@ struct dentry *lookup_one_len(const char *name, struct dentry *base, int len)
2322} 2318}
2323EXPORT_SYMBOL(lookup_one_len); 2319EXPORT_SYMBOL(lookup_one_len);
2324 2320
2321/**
2322 * lookup_one_len_unlocked - filesystem helper to lookup single pathname component
2323 * @name: pathname component to lookup
2324 * @base: base directory to lookup from
2325 * @len: maximum length @len should be interpreted to
2326 *
2327 * Note that this routine is purely a helper for filesystem usage and should
2328 * not be called by generic code.
2329 *
2330 * Unlike lookup_one_len, it should be called without the parent
2331 * i_mutex held, and will take the i_mutex itself if necessary.
2332 */
2333struct dentry *lookup_one_len_unlocked(const char *name,
2334 struct dentry *base, int len)
2335{
2336 struct qstr this;
2337 unsigned int c;
2338 int err;
2339 struct dentry *ret;
2340
2341 this.name = name;
2342 this.len = len;
2343 this.hash = full_name_hash(name, len);
2344 if (!len)
2345 return ERR_PTR(-EACCES);
2346
2347 if (unlikely(name[0] == '.')) {
2348 if (len < 2 || (len == 2 && name[1] == '.'))
2349 return ERR_PTR(-EACCES);
2350 }
2351
2352 while (len--) {
2353 c = *(const unsigned char *)name++;
2354 if (c == '/' || c == '\0')
2355 return ERR_PTR(-EACCES);
2356 }
2357 /*
2358 * See if the low-level filesystem might want
2359 * to use its own hash..
2360 */
2361 if (base->d_flags & DCACHE_OP_HASH) {
2362 int err = base->d_op->d_hash(base, &this);
2363 if (err < 0)
2364 return ERR_PTR(err);
2365 }
2366
2367 err = inode_permission(base->d_inode, MAY_EXEC);
2368 if (err)
2369 return ERR_PTR(err);
2370
2371 /*
2372 * __d_lookup() is used to try to get a quick answer and avoid the
2373 * mutex. A false-negative does no harm.
2374 */
2375 ret = __d_lookup(base, &this);
2376 if (ret && unlikely(ret->d_flags & DCACHE_OP_REVALIDATE)) {
2377 dput(ret);
2378 ret = NULL;
2379 }
2380 if (ret)
2381 return ret;
2382
2383 mutex_lock(&base->d_inode->i_mutex);
2384 ret = __lookup_hash(&this, base, 0);
2385 mutex_unlock(&base->d_inode->i_mutex);
2386 return ret;
2387}
2388EXPORT_SYMBOL(lookup_one_len_unlocked);
2389
2325int user_path_at_empty(int dfd, const char __user *name, unsigned flags, 2390int user_path_at_empty(int dfd, const char __user *name, unsigned flags,
2326 struct path *path, int *empty) 2391 struct path *path, int *empty)
2327{ 2392{
@@ -2670,10 +2735,6 @@ static int may_open(struct path *path, int acc_mode, int flag)
2670 struct inode *inode = dentry->d_inode; 2735 struct inode *inode = dentry->d_inode;
2671 int error; 2736 int error;
2672 2737
2673 /* O_PATH? */
2674 if (!acc_mode)
2675 return 0;
2676
2677 if (!inode) 2738 if (!inode)
2678 return -ENOENT; 2739 return -ENOENT;
2679 2740
@@ -2695,7 +2756,7 @@ static int may_open(struct path *path, int acc_mode, int flag)
2695 break; 2756 break;
2696 } 2757 }
2697 2758
2698 error = inode_permission(inode, acc_mode); 2759 error = inode_permission(inode, MAY_OPEN | acc_mode);
2699 if (error) 2760 if (error)
2700 return error; 2761 return error;
2701 2762
@@ -2887,7 +2948,7 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry,
2887 if (*opened & FILE_CREATED) { 2948 if (*opened & FILE_CREATED) {
2888 WARN_ON(!(open_flag & O_CREAT)); 2949 WARN_ON(!(open_flag & O_CREAT));
2889 fsnotify_create(dir, dentry); 2950 fsnotify_create(dir, dentry);
2890 acc_mode = MAY_OPEN; 2951 acc_mode = 0;
2891 } 2952 }
2892 error = may_open(&file->f_path, acc_mode, open_flag); 2953 error = may_open(&file->f_path, acc_mode, open_flag);
2893 if (error) 2954 if (error)
@@ -3100,7 +3161,7 @@ retry_lookup:
3100 /* Don't check for write permission, don't truncate */ 3161 /* Don't check for write permission, don't truncate */
3101 open_flag &= ~O_TRUNC; 3162 open_flag &= ~O_TRUNC;
3102 will_truncate = false; 3163 will_truncate = false;
3103 acc_mode = MAY_OPEN; 3164 acc_mode = 0;
3104 path_to_nameidata(&path, nd); 3165 path_to_nameidata(&path, nd);
3105 goto finish_open_created; 3166 goto finish_open_created;
3106 } 3167 }
@@ -3184,10 +3245,11 @@ finish_open:
3184 got_write = true; 3245 got_write = true;
3185 } 3246 }
3186finish_open_created: 3247finish_open_created:
3187 error = may_open(&nd->path, acc_mode, open_flag); 3248 if (likely(!(open_flag & O_PATH))) {
3188 if (error) 3249 error = may_open(&nd->path, acc_mode, open_flag);
3189 goto out; 3250 if (error)
3190 3251 goto out;
3252 }
3191 BUG_ON(*opened & FILE_OPENED); /* once it's opened, it's opened */ 3253 BUG_ON(*opened & FILE_OPENED); /* once it's opened, it's opened */
3192 error = vfs_open(&nd->path, file, current_cred()); 3254 error = vfs_open(&nd->path, file, current_cred());
3193 if (!error) { 3255 if (!error) {
@@ -3274,7 +3336,7 @@ static int do_tmpfile(struct nameidata *nd, unsigned flags,
3274 goto out2; 3336 goto out2;
3275 audit_inode(nd->name, child, 0); 3337 audit_inode(nd->name, child, 0);
3276 /* Don't check for other permissions, the inode was just created */ 3338 /* Don't check for other permissions, the inode was just created */
3277 error = may_open(&path, MAY_OPEN, op->open_flag); 3339 error = may_open(&path, 0, op->open_flag);
3278 if (error) 3340 if (error)
3279 goto out2; 3341 goto out2;
3280 file->f_path.mnt = path.mnt; 3342 file->f_path.mnt = path.mnt;
diff --git a/fs/namespace.c b/fs/namespace.c
index 4d2c8f64b7bf..a830e1463704 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2609,18 +2609,18 @@ static long exact_copy_from_user(void *to, const void __user * from,
2609 return n; 2609 return n;
2610} 2610}
2611 2611
2612int copy_mount_options(const void __user * data, unsigned long *where) 2612void *copy_mount_options(const void __user * data)
2613{ 2613{
2614 int i; 2614 int i;
2615 unsigned long page;
2616 unsigned long size; 2615 unsigned long size;
2616 char *copy;
2617 2617
2618 *where = 0;
2619 if (!data) 2618 if (!data)
2620 return 0; 2619 return NULL;
2621 2620
2622 if (!(page = __get_free_page(GFP_KERNEL))) 2621 copy = kmalloc(PAGE_SIZE, GFP_KERNEL);
2623 return -ENOMEM; 2622 if (!copy)
2623 return ERR_PTR(-ENOMEM);
2624 2624
2625 /* We only care that *some* data at the address the user 2625 /* We only care that *some* data at the address the user
2626 * gave us is valid. Just in case, we'll zero 2626 * gave us is valid. Just in case, we'll zero
@@ -2631,15 +2631,14 @@ int copy_mount_options(const void __user * data, unsigned long *where)
2631 if (size > PAGE_SIZE) 2631 if (size > PAGE_SIZE)
2632 size = PAGE_SIZE; 2632 size = PAGE_SIZE;
2633 2633
2634 i = size - exact_copy_from_user((void *)page, data, size); 2634 i = size - exact_copy_from_user(copy, data, size);
2635 if (!i) { 2635 if (!i) {
2636 free_page(page); 2636 kfree(copy);
2637 return -EFAULT; 2637 return ERR_PTR(-EFAULT);
2638 } 2638 }
2639 if (i != PAGE_SIZE) 2639 if (i != PAGE_SIZE)
2640 memset((char *)page + i, 0, PAGE_SIZE - i); 2640 memset(copy + i, 0, PAGE_SIZE - i);
2641 *where = page; 2641 return copy;
2642 return 0;
2643} 2642}
2644 2643
2645char *copy_mount_string(const void __user *data) 2644char *copy_mount_string(const void __user *data)
@@ -2906,7 +2905,7 @@ SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
2906 int ret; 2905 int ret;
2907 char *kernel_type; 2906 char *kernel_type;
2908 char *kernel_dev; 2907 char *kernel_dev;
2909 unsigned long data_page; 2908 void *options;
2910 2909
2911 kernel_type = copy_mount_string(type); 2910 kernel_type = copy_mount_string(type);
2912 ret = PTR_ERR(kernel_type); 2911 ret = PTR_ERR(kernel_type);
@@ -2918,14 +2917,14 @@ SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
2918 if (IS_ERR(kernel_dev)) 2917 if (IS_ERR(kernel_dev))
2919 goto out_dev; 2918 goto out_dev;
2920 2919
2921 ret = copy_mount_options(data, &data_page); 2920 options = copy_mount_options(data);
2922 if (ret < 0) 2921 ret = PTR_ERR(options);
2922 if (IS_ERR(options))
2923 goto out_data; 2923 goto out_data;
2924 2924
2925 ret = do_mount(kernel_dev, dir_name, kernel_type, flags, 2925 ret = do_mount(kernel_dev, dir_name, kernel_type, flags, options);
2926 (void *) data_page);
2927 2926
2928 free_page(data_page); 2927 kfree(options);
2929out_data: 2928out_data:
2930 kfree(kernel_dev); 2929 kfree(kernel_dev);
2931out_dev: 2930out_dev:
@@ -2949,9 +2948,9 @@ bool is_path_reachable(struct mount *mnt, struct dentry *dentry,
2949 return &mnt->mnt == root->mnt && is_subdir(dentry, root->dentry); 2948 return &mnt->mnt == root->mnt && is_subdir(dentry, root->dentry);
2950} 2949}
2951 2950
2952int path_is_under(struct path *path1, struct path *path2) 2951bool path_is_under(struct path *path1, struct path *path2)
2953{ 2952{
2954 int res; 2953 bool res;
2955 read_seqlock_excl(&mount_lock); 2954 read_seqlock_excl(&mount_lock);
2956 res = is_path_reachable(real_mount(path1->mnt), path1->dentry, path2); 2955 res = is_path_reachable(real_mount(path1->mnt), path1->dentry, path2);
2957 read_sequnlock_excl(&mount_lock); 2956 read_sequnlock_excl(&mount_lock);
diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c
index 00575d776d91..2246454dec76 100644
--- a/fs/nfsd/nfs3xdr.c
+++ b/fs/nfsd/nfs3xdr.c
@@ -823,7 +823,7 @@ compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp,
823 } else 823 } else
824 dchild = dget(dparent); 824 dchild = dget(dparent);
825 } else 825 } else
826 dchild = lookup_one_len(name, dparent, namlen); 826 dchild = lookup_one_len_unlocked(name, dparent, namlen);
827 if (IS_ERR(dchild)) 827 if (IS_ERR(dchild))
828 return rv; 828 return rv;
829 if (d_mountpoint(dchild)) 829 if (d_mountpoint(dchild))
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 924416f91fdd..d6ef0955a979 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -2858,14 +2858,14 @@ nfsd4_encode_dirent_fattr(struct xdr_stream *xdr, struct nfsd4_readdir *cd,
2858 __be32 nfserr; 2858 __be32 nfserr;
2859 int ignore_crossmnt = 0; 2859 int ignore_crossmnt = 0;
2860 2860
2861 dentry = lookup_one_len(name, cd->rd_fhp->fh_dentry, namlen); 2861 dentry = lookup_one_len_unlocked(name, cd->rd_fhp->fh_dentry, namlen);
2862 if (IS_ERR(dentry)) 2862 if (IS_ERR(dentry))
2863 return nfserrno(PTR_ERR(dentry)); 2863 return nfserrno(PTR_ERR(dentry));
2864 if (d_really_is_negative(dentry)) { 2864 if (d_really_is_negative(dentry)) {
2865 /* 2865 /*
2866 * nfsd_buffered_readdir drops the i_mutex between 2866 * we're not holding the i_mutex here, so there's
2867 * readdir and calling this callback, leaving a window 2867 * a window where this directory entry could have gone
2868 * where this directory entry could have gone away. 2868 * away.
2869 */ 2869 */
2870 dput(dentry); 2870 dput(dentry);
2871 return nfserr_noent; 2871 return nfserr_noent;
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 5411bf09b810..d41c149fae75 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -218,10 +218,16 @@ nfsd_lookup_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp,
218 host_err = PTR_ERR(dentry); 218 host_err = PTR_ERR(dentry);
219 if (IS_ERR(dentry)) 219 if (IS_ERR(dentry))
220 goto out_nfserr; 220 goto out_nfserr;
221 /*
222 * check if we have crossed a mount point ...
223 */
224 if (nfsd_mountpoint(dentry, exp)) { 221 if (nfsd_mountpoint(dentry, exp)) {
222 /*
223 * We don't need the i_mutex after all. It's
224 * still possible we could open this (regular
225 * files can be mountpoints too), but the
226 * i_mutex is just there to prevent renames of
227 * something that we might be about to delegate,
228 * and a mountpoint won't be renamed:
229 */
230 fh_unlock(fhp);
225 if ((host_err = nfsd_cross_mnt(rqstp, &dentry, &exp))) { 231 if ((host_err = nfsd_cross_mnt(rqstp, &dentry, &exp))) {
226 dput(dentry); 232 dput(dentry);
227 goto out_nfserr; 233 goto out_nfserr;
@@ -1817,7 +1823,6 @@ static __be32 nfsd_buffered_readdir(struct file *file, nfsd_filldir_t func,
1817 offset = *offsetp; 1823 offset = *offsetp;
1818 1824
1819 while (1) { 1825 while (1) {
1820 struct inode *dir_inode = file_inode(file);
1821 unsigned int reclen; 1826 unsigned int reclen;
1822 1827
1823 cdp->err = nfserr_eof; /* will be cleared on successful read */ 1828 cdp->err = nfserr_eof; /* will be cleared on successful read */
@@ -1836,15 +1841,6 @@ static __be32 nfsd_buffered_readdir(struct file *file, nfsd_filldir_t func,
1836 if (!size) 1841 if (!size)
1837 break; 1842 break;
1838 1843
1839 /*
1840 * Various filldir functions may end up calling back into
1841 * lookup_one_len() and the file system's ->lookup() method.
1842 * These expect i_mutex to be held, as it would within readdir.
1843 */
1844 host_err = mutex_lock_killable(&dir_inode->i_mutex);
1845 if (host_err)
1846 break;
1847
1848 de = (struct buffered_dirent *)buf.dirent; 1844 de = (struct buffered_dirent *)buf.dirent;
1849 while (size > 0) { 1845 while (size > 0) {
1850 offset = de->offset; 1846 offset = de->offset;
@@ -1861,7 +1857,6 @@ static __be32 nfsd_buffered_readdir(struct file *file, nfsd_filldir_t func,
1861 size -= reclen; 1857 size -= reclen;
1862 de = (struct buffered_dirent *)((char *)de + reclen); 1858 de = (struct buffered_dirent *)((char *)de + reclen);
1863 } 1859 }
1864 mutex_unlock(&dir_inode->i_mutex);
1865 if (size > 0) /* We bailed out early */ 1860 if (size > 0) /* We bailed out early */
1866 break; 1861 break;
1867 1862
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 354013ea22ec..c7343844e6b6 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -1316,13 +1316,11 @@ nilfs_mount(struct file_system_type *fs_type, int flags,
1316 } 1316 }
1317 1317
1318 if (!s->s_root) { 1318 if (!s->s_root) {
1319 char b[BDEVNAME_SIZE]; 1319 s_new = true;
1320
1321 s_new = true;
1322 1320
1323 /* New superblock instance created */ 1321 /* New superblock instance created */
1324 s->s_mode = mode; 1322 s->s_mode = mode;
1325 strlcpy(s->s_id, bdevname(sd.bdev, b), sizeof(s->s_id)); 1323 snprintf(s->s_id, sizeof(s->s_id), "%pg", sd.bdev);
1326 sb_set_blocksize(s, block_size(sd.bdev)); 1324 sb_set_blocksize(s, block_size(sd.bdev));
1327 1325
1328 err = nilfs_fill_super(s, data, flags & MS_SILENT ? 1 : 0); 1326 err = nilfs_fill_super(s, data, flags & MS_SILENT ? 1 : 0);
diff --git a/fs/open.c b/fs/open.c
index b6f1e96a7c0b..b25b1542c530 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -887,7 +887,7 @@ EXPORT_SYMBOL(dentry_open);
887static inline int build_open_flags(int flags, umode_t mode, struct open_flags *op) 887static inline int build_open_flags(int flags, umode_t mode, struct open_flags *op)
888{ 888{
889 int lookup_flags = 0; 889 int lookup_flags = 0;
890 int acc_mode; 890 int acc_mode = ACC_MODE(flags);
891 891
892 if (flags & (O_CREAT | __O_TMPFILE)) 892 if (flags & (O_CREAT | __O_TMPFILE))
893 op->mode = (mode & S_IALLUGO) | S_IFREG; 893 op->mode = (mode & S_IALLUGO) | S_IFREG;
@@ -909,7 +909,6 @@ static inline int build_open_flags(int flags, umode_t mode, struct open_flags *o
909 if (flags & __O_TMPFILE) { 909 if (flags & __O_TMPFILE) {
910 if ((flags & O_TMPFILE_MASK) != O_TMPFILE) 910 if ((flags & O_TMPFILE_MASK) != O_TMPFILE)
911 return -EINVAL; 911 return -EINVAL;
912 acc_mode = MAY_OPEN | ACC_MODE(flags);
913 if (!(acc_mode & MAY_WRITE)) 912 if (!(acc_mode & MAY_WRITE))
914 return -EINVAL; 913 return -EINVAL;
915 } else if (flags & O_PATH) { 914 } else if (flags & O_PATH) {
@@ -919,8 +918,6 @@ static inline int build_open_flags(int flags, umode_t mode, struct open_flags *o
919 */ 918 */
920 flags &= O_DIRECTORY | O_NOFOLLOW | O_PATH; 919 flags &= O_DIRECTORY | O_NOFOLLOW | O_PATH;
921 acc_mode = 0; 920 acc_mode = 0;
922 } else {
923 acc_mode = MAY_OPEN | ACC_MODE(flags);
924 } 921 }
925 922
926 op->open_flag = flags; 923 op->open_flag = flags;
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 55e01f88eac9..2cf5d7e37375 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -2365,7 +2365,7 @@ static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf,
2365 size_t count, loff_t *ppos) 2365 size_t count, loff_t *ppos)
2366{ 2366{
2367 struct inode * inode = file_inode(file); 2367 struct inode * inode = file_inode(file);
2368 char *page; 2368 void *page;
2369 ssize_t length; 2369 ssize_t length;
2370 struct task_struct *task = get_proc_task(inode); 2370 struct task_struct *task = get_proc_task(inode);
2371 2371
@@ -2380,14 +2380,11 @@ static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf,
2380 if (*ppos != 0) 2380 if (*ppos != 0)
2381 goto out; 2381 goto out;
2382 2382
2383 length = -ENOMEM; 2383 page = memdup_user(buf, count);
2384 page = (char*)__get_free_page(GFP_TEMPORARY); 2384 if (IS_ERR(page)) {
2385 if (!page) 2385 length = PTR_ERR(page);
2386 goto out; 2386 goto out;
2387 2387 }
2388 length = -EFAULT;
2389 if (copy_from_user(page, buf, count))
2390 goto out_free;
2391 2388
2392 /* Guard against adverse ptrace interaction */ 2389 /* Guard against adverse ptrace interaction */
2393 length = mutex_lock_interruptible(&task->signal->cred_guard_mutex); 2390 length = mutex_lock_interruptible(&task->signal->cred_guard_mutex);
@@ -2396,10 +2393,10 @@ static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf,
2396 2393
2397 length = security_setprocattr(task, 2394 length = security_setprocattr(task,
2398 (char*)file->f_path.dentry->d_name.name, 2395 (char*)file->f_path.dentry->d_name.name,
2399 (void*)page, count); 2396 page, count);
2400 mutex_unlock(&task->signal->cred_guard_mutex); 2397 mutex_unlock(&task->signal->cred_guard_mutex);
2401out_free: 2398out_free:
2402 free_page((unsigned long) page); 2399 kfree(page);
2403out: 2400out:
2404 put_task_struct(task); 2401 put_task_struct(task);
2405out_no_task: 2402out_no_task:
diff --git a/fs/proc/fd.c b/fs/proc/fd.c
index 3c2a915c695a..56afa5ef08f2 100644
--- a/fs/proc/fd.c
+++ b/fs/proc/fd.c
@@ -258,6 +258,7 @@ static int proc_readfd_common(struct file *file, struct dir_context *ctx,
258 name, len, instantiate, p, 258 name, len, instantiate, p,
259 (void *)(unsigned long)fd)) 259 (void *)(unsigned long)fd))
260 goto out_fd_loop; 260 goto out_fd_loop;
261 cond_resched();
261 rcu_read_lock(); 262 rcu_read_lock();
262 } 263 }
263 rcu_read_unlock(); 264 rcu_read_unlock();
diff --git a/fs/proc_namespace.c b/fs/proc_namespace.c
index 8ebd9a334085..2256e7e23e67 100644
--- a/fs/proc_namespace.c
+++ b/fs/proc_namespace.c
@@ -95,9 +95,9 @@ static int show_vfsmnt(struct seq_file *m, struct vfsmount *mnt)
95{ 95{
96 struct proc_mounts *p = m->private; 96 struct proc_mounts *p = m->private;
97 struct mount *r = real_mount(mnt); 97 struct mount *r = real_mount(mnt);
98 int err = 0;
99 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt }; 98 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
100 struct super_block *sb = mnt_path.dentry->d_sb; 99 struct super_block *sb = mnt_path.dentry->d_sb;
100 int err;
101 101
102 if (sb->s_op->show_devname) { 102 if (sb->s_op->show_devname) {
103 err = sb->s_op->show_devname(m, mnt_path.dentry); 103 err = sb->s_op->show_devname(m, mnt_path.dentry);
@@ -131,16 +131,17 @@ static int show_mountinfo(struct seq_file *m, struct vfsmount *mnt)
131 struct mount *r = real_mount(mnt); 131 struct mount *r = real_mount(mnt);
132 struct super_block *sb = mnt->mnt_sb; 132 struct super_block *sb = mnt->mnt_sb;
133 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt }; 133 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
134 int err = 0; 134 int err;
135 135
136 seq_printf(m, "%i %i %u:%u ", r->mnt_id, r->mnt_parent->mnt_id, 136 seq_printf(m, "%i %i %u:%u ", r->mnt_id, r->mnt_parent->mnt_id,
137 MAJOR(sb->s_dev), MINOR(sb->s_dev)); 137 MAJOR(sb->s_dev), MINOR(sb->s_dev));
138 if (sb->s_op->show_path) 138 if (sb->s_op->show_path) {
139 err = sb->s_op->show_path(m, mnt->mnt_root); 139 err = sb->s_op->show_path(m, mnt->mnt_root);
140 else 140 if (err)
141 goto out;
142 } else {
141 seq_dentry(m, mnt->mnt_root, " \t\n\\"); 143 seq_dentry(m, mnt->mnt_root, " \t\n\\");
142 if (err) 144 }
143 goto out;
144 seq_putc(m, ' '); 145 seq_putc(m, ' ');
145 146
146 /* mountpoints outside of chroot jail will give SEQ_SKIP on this */ 147 /* mountpoints outside of chroot jail will give SEQ_SKIP on this */
@@ -168,12 +169,13 @@ static int show_mountinfo(struct seq_file *m, struct vfsmount *mnt)
168 seq_puts(m, " - "); 169 seq_puts(m, " - ");
169 show_type(m, sb); 170 show_type(m, sb);
170 seq_putc(m, ' '); 171 seq_putc(m, ' ');
171 if (sb->s_op->show_devname) 172 if (sb->s_op->show_devname) {
172 err = sb->s_op->show_devname(m, mnt->mnt_root); 173 err = sb->s_op->show_devname(m, mnt->mnt_root);
173 else 174 if (err)
175 goto out;
176 } else {
174 mangle(m, r->mnt_devname ? r->mnt_devname : "none"); 177 mangle(m, r->mnt_devname ? r->mnt_devname : "none");
175 if (err) 178 }
176 goto out;
177 seq_puts(m, sb->s_flags & MS_RDONLY ? " ro" : " rw"); 179 seq_puts(m, sb->s_flags & MS_RDONLY ? " ro" : " rw");
178 err = show_sb_opts(m, sb); 180 err = show_sb_opts(m, sb);
179 if (err) 181 if (err)
@@ -191,7 +193,7 @@ static int show_vfsstat(struct seq_file *m, struct vfsmount *mnt)
191 struct mount *r = real_mount(mnt); 193 struct mount *r = real_mount(mnt);
192 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt }; 194 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
193 struct super_block *sb = mnt_path.dentry->d_sb; 195 struct super_block *sb = mnt_path.dentry->d_sb;
194 int err = 0; 196 int err;
195 197
196 /* device */ 198 /* device */
197 if (sb->s_op->show_devname) { 199 if (sb->s_op->show_devname) {
@@ -220,8 +222,7 @@ static int show_vfsstat(struct seq_file *m, struct vfsmount *mnt)
220 /* optional statistics */ 222 /* optional statistics */
221 if (sb->s_op->show_stats) { 223 if (sb->s_op->show_stats) {
222 seq_putc(m, ' '); 224 seq_putc(m, ' ');
223 if (!err) 225 err = sb->s_op->show_stats(m, mnt_path.dentry);
224 err = sb->s_op->show_stats(m, mnt_path.dentry);
225 } 226 }
226 227
227 seq_putc(m, '\n'); 228 seq_putc(m, '\n');
diff --git a/fs/read_write.c b/fs/read_write.c
index 2116e74a83d3..06b07d5a08fe 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -172,6 +172,45 @@ loff_t fixed_size_llseek(struct file *file, loff_t offset, int whence, loff_t si
172EXPORT_SYMBOL(fixed_size_llseek); 172EXPORT_SYMBOL(fixed_size_llseek);
173 173
174/** 174/**
175 * no_seek_end_llseek - llseek implementation for fixed-sized devices
176 * @file: file structure to seek on
177 * @offset: file offset to seek to
178 * @whence: type of seek
179 *
180 */
181loff_t no_seek_end_llseek(struct file *file, loff_t offset, int whence)
182{
183 switch (whence) {
184 case SEEK_SET: case SEEK_CUR:
185 return generic_file_llseek_size(file, offset, whence,
186 ~0ULL, 0);
187 default:
188 return -EINVAL;
189 }
190}
191EXPORT_SYMBOL(no_seek_end_llseek);
192
193/**
194 * no_seek_end_llseek_size - llseek implementation for fixed-sized devices
195 * @file: file structure to seek on
196 * @offset: file offset to seek to
197 * @whence: type of seek
198 * @size: maximal offset allowed
199 *
200 */
201loff_t no_seek_end_llseek_size(struct file *file, loff_t offset, int whence, loff_t size)
202{
203 switch (whence) {
204 case SEEK_SET: case SEEK_CUR:
205 return generic_file_llseek_size(file, offset, whence,
206 size, 0);
207 default:
208 return -EINVAL;
209 }
210}
211EXPORT_SYMBOL(no_seek_end_llseek_size);
212
213/**
175 * noop_llseek - No Operation Performed llseek implementation 214 * noop_llseek - No Operation Performed llseek implementation
176 * @file: file structure to seek on 215 * @file: file structure to seek on
177 * @offset: file offset to seek to 216 * @offset: file offset to seek to
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index 9d6486d416a3..44c2bdced1c8 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -618,12 +618,10 @@ static void release_buffer_page(struct buffer_head *bh)
618 618
619static void reiserfs_end_buffer_io_sync(struct buffer_head *bh, int uptodate) 619static void reiserfs_end_buffer_io_sync(struct buffer_head *bh, int uptodate)
620{ 620{
621 char b[BDEVNAME_SIZE];
622
623 if (buffer_journaled(bh)) { 621 if (buffer_journaled(bh)) {
624 reiserfs_warning(NULL, "clm-2084", 622 reiserfs_warning(NULL, "clm-2084",
625 "pinned buffer %lu:%s sent to disk", 623 "pinned buffer %lu:%pg sent to disk",
626 bh->b_blocknr, bdevname(bh->b_bdev, b)); 624 bh->b_blocknr, bh->b_bdev);
627 } 625 }
628 if (uptodate) 626 if (uptodate)
629 set_buffer_uptodate(bh); 627 set_buffer_uptodate(bh);
@@ -2387,11 +2385,10 @@ static int journal_read(struct super_block *sb)
2387 int replay_count = 0; 2385 int replay_count = 0;
2388 int continue_replay = 1; 2386 int continue_replay = 1;
2389 int ret; 2387 int ret;
2390 char b[BDEVNAME_SIZE];
2391 2388
2392 cur_dblock = SB_ONDISK_JOURNAL_1st_BLOCK(sb); 2389 cur_dblock = SB_ONDISK_JOURNAL_1st_BLOCK(sb);
2393 reiserfs_info(sb, "checking transaction log (%s)\n", 2390 reiserfs_info(sb, "checking transaction log (%pg)\n",
2394 bdevname(journal->j_dev_bd, b)); 2391 journal->j_dev_bd);
2395 start = get_seconds(); 2392 start = get_seconds();
2396 2393
2397 /* 2394 /*
@@ -2651,8 +2648,8 @@ static int journal_init_dev(struct super_block *super,
2651 2648
2652 set_blocksize(journal->j_dev_bd, super->s_blocksize); 2649 set_blocksize(journal->j_dev_bd, super->s_blocksize);
2653 reiserfs_info(super, 2650 reiserfs_info(super,
2654 "journal_init_dev: journal device: %s\n", 2651 "journal_init_dev: journal device: %pg\n",
2655 bdevname(journal->j_dev_bd, b)); 2652 journal->j_dev_bd);
2656 return 0; 2653 return 0;
2657} 2654}
2658 2655
@@ -2724,7 +2721,6 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
2724 struct reiserfs_journal_header *jh; 2721 struct reiserfs_journal_header *jh;
2725 struct reiserfs_journal *journal; 2722 struct reiserfs_journal *journal;
2726 struct reiserfs_journal_list *jl; 2723 struct reiserfs_journal_list *jl;
2727 char b[BDEVNAME_SIZE];
2728 int ret; 2724 int ret;
2729 2725
2730 journal = SB_JOURNAL(sb) = vzalloc(sizeof(struct reiserfs_journal)); 2726 journal = SB_JOURNAL(sb) = vzalloc(sizeof(struct reiserfs_journal));
@@ -2794,10 +2790,10 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
2794 && (le32_to_cpu(jh->jh_journal.jp_journal_magic) != 2790 && (le32_to_cpu(jh->jh_journal.jp_journal_magic) !=
2795 sb_jp_journal_magic(rs))) { 2791 sb_jp_journal_magic(rs))) {
2796 reiserfs_warning(sb, "sh-460", 2792 reiserfs_warning(sb, "sh-460",
2797 "journal header magic %x (device %s) does " 2793 "journal header magic %x (device %pg) does "
2798 "not match to magic found in super block %x", 2794 "not match to magic found in super block %x",
2799 jh->jh_journal.jp_journal_magic, 2795 jh->jh_journal.jp_journal_magic,
2800 bdevname(journal->j_dev_bd, b), 2796 journal->j_dev_bd,
2801 sb_jp_journal_magic(rs)); 2797 sb_jp_journal_magic(rs));
2802 brelse(bhjh); 2798 brelse(bhjh);
2803 goto free_and_return; 2799 goto free_and_return;
@@ -2818,10 +2814,10 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
2818 journal->j_max_trans_age = commit_max_age; 2814 journal->j_max_trans_age = commit_max_age;
2819 } 2815 }
2820 2816
2821 reiserfs_info(sb, "journal params: device %s, size %u, " 2817 reiserfs_info(sb, "journal params: device %pg, size %u, "
2822 "journal first block %u, max trans len %u, max batch %u, " 2818 "journal first block %u, max trans len %u, max batch %u, "
2823 "max commit age %u, max trans age %u\n", 2819 "max commit age %u, max trans age %u\n",
2824 bdevname(journal->j_dev_bd, b), 2820 journal->j_dev_bd,
2825 SB_ONDISK_JOURNAL_SIZE(sb), 2821 SB_ONDISK_JOURNAL_SIZE(sb),
2826 SB_ONDISK_JOURNAL_1st_BLOCK(sb), 2822 SB_ONDISK_JOURNAL_1st_BLOCK(sb),
2827 journal->j_trans_max, 2823 journal->j_trans_max,
diff --git a/fs/reiserfs/prints.c b/fs/reiserfs/prints.c
index ae1dc841db3a..4f3f928076f3 100644
--- a/fs/reiserfs/prints.c
+++ b/fs/reiserfs/prints.c
@@ -139,11 +139,9 @@ static void sprintf_block_head(char *buf, struct buffer_head *bh)
139 139
140static void sprintf_buffer_head(char *buf, struct buffer_head *bh) 140static void sprintf_buffer_head(char *buf, struct buffer_head *bh)
141{ 141{
142 char b[BDEVNAME_SIZE];
143
144 sprintf(buf, 142 sprintf(buf,
145 "dev %s, size %zd, blocknr %llu, count %d, state 0x%lx, page %p, (%s, %s, %s)", 143 "dev %pg, size %zd, blocknr %llu, count %d, state 0x%lx, page %p, (%s, %s, %s)",
146 bdevname(bh->b_bdev, b), bh->b_size, 144 bh->b_bdev, bh->b_size,
147 (unsigned long long)bh->b_blocknr, atomic_read(&(bh->b_count)), 145 (unsigned long long)bh->b_blocknr, atomic_read(&(bh->b_count)),
148 bh->b_state, bh->b_page, 146 bh->b_state, bh->b_page,
149 buffer_uptodate(bh) ? "UPTODATE" : "!UPTODATE", 147 buffer_uptodate(bh) ? "UPTODATE" : "!UPTODATE",
@@ -530,7 +528,6 @@ static int print_super_block(struct buffer_head *bh)
530 (struct reiserfs_super_block *)(bh->b_data); 528 (struct reiserfs_super_block *)(bh->b_data);
531 int skipped, data_blocks; 529 int skipped, data_blocks;
532 char *version; 530 char *version;
533 char b[BDEVNAME_SIZE];
534 531
535 if (is_reiserfs_3_5(rs)) { 532 if (is_reiserfs_3_5(rs)) {
536 version = "3.5"; 533 version = "3.5";
@@ -543,7 +540,7 @@ static int print_super_block(struct buffer_head *bh)
543 return 1; 540 return 1;
544 } 541 }
545 542
546 printk("%s\'s super block is in block %llu\n", bdevname(bh->b_bdev, b), 543 printk("%pg\'s super block is in block %llu\n", bh->b_bdev,
547 (unsigned long long)bh->b_blocknr); 544 (unsigned long long)bh->b_blocknr);
548 printk("Reiserfs version %s\n", version); 545 printk("Reiserfs version %s\n", version);
549 printk("Block count %u\n", sb_block_count(rs)); 546 printk("Block count %u\n", sb_block_count(rs));
diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
index 621b9f381fe1..fe999157dd97 100644
--- a/fs/reiserfs/procfs.c
+++ b/fs/reiserfs/procfs.c
@@ -303,11 +303,10 @@ static int show_journal(struct seq_file *m, void *unused)
303 struct reiserfs_sb_info *r = REISERFS_SB(sb); 303 struct reiserfs_sb_info *r = REISERFS_SB(sb);
304 struct reiserfs_super_block *rs = r->s_rs; 304 struct reiserfs_super_block *rs = r->s_rs;
305 struct journal_params *jp = &rs->s_v1.s_journal; 305 struct journal_params *jp = &rs->s_v1.s_journal;
306 char b[BDEVNAME_SIZE];
307 306
308 seq_printf(m, /* on-disk fields */ 307 seq_printf(m, /* on-disk fields */
309 "jp_journal_1st_block: \t%i\n" 308 "jp_journal_1st_block: \t%i\n"
310 "jp_journal_dev: \t%s[%x]\n" 309 "jp_journal_dev: \t%pg[%x]\n"
311 "jp_journal_size: \t%i\n" 310 "jp_journal_size: \t%i\n"
312 "jp_journal_trans_max: \t%i\n" 311 "jp_journal_trans_max: \t%i\n"
313 "jp_journal_magic: \t%i\n" 312 "jp_journal_magic: \t%i\n"
@@ -348,7 +347,7 @@ static int show_journal(struct seq_file *m, void *unused)
348 "prepare: \t%12lu\n" 347 "prepare: \t%12lu\n"
349 "prepare_retry: \t%12lu\n", 348 "prepare_retry: \t%12lu\n",
350 DJP(jp_journal_1st_block), 349 DJP(jp_journal_1st_block),
351 bdevname(SB_JOURNAL(sb)->j_dev_bd, b), 350 SB_JOURNAL(sb)->j_dev_bd,
352 DJP(jp_journal_dev), 351 DJP(jp_journal_dev),
353 DJP(jp_journal_size), 352 DJP(jp_journal_size),
354 DJP(jp_journal_trans_max), 353 DJP(jp_journal_trans_max),
diff --git a/fs/select.c b/fs/select.c
index 015547330e88..79d0d4953cad 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -778,8 +778,8 @@ static inline unsigned int do_pollfd(struct pollfd *pollfd, poll_table *pwait,
778 return mask; 778 return mask;
779} 779}
780 780
781static int do_poll(unsigned int nfds, struct poll_list *list, 781static int do_poll(struct poll_list *list, struct poll_wqueues *wait,
782 struct poll_wqueues *wait, struct timespec *end_time) 782 struct timespec *end_time)
783{ 783{
784 poll_table* pt = &wait->pt; 784 poll_table* pt = &wait->pt;
785 ktime_t expire, *to = NULL; 785 ktime_t expire, *to = NULL;
@@ -908,7 +908,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
908 } 908 }
909 909
910 poll_initwait(&table); 910 poll_initwait(&table);
911 fdcount = do_poll(nfds, head, &table, end_time); 911 fdcount = do_poll(head, &table, end_time);
912 poll_freewait(&table); 912 poll_freewait(&table);
913 913
914 for (walk = head; walk; walk = walk->next) { 914 for (walk = head; walk; walk = walk->next) {
diff --git a/fs/splice.c b/fs/splice.c
index 4cf700d50b40..82bc0d64fc38 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -415,6 +415,7 @@ __generic_file_splice_read(struct file *in, loff_t *ppos,
415 */ 415 */
416 if (!page->mapping) { 416 if (!page->mapping) {
417 unlock_page(page); 417 unlock_page(page);
418retry_lookup:
418 page = find_or_create_page(mapping, index, 419 page = find_or_create_page(mapping, index,
419 mapping_gfp_mask(mapping)); 420 mapping_gfp_mask(mapping));
420 421
@@ -439,13 +440,10 @@ __generic_file_splice_read(struct file *in, loff_t *ppos,
439 error = mapping->a_ops->readpage(in, page); 440 error = mapping->a_ops->readpage(in, page);
440 if (unlikely(error)) { 441 if (unlikely(error)) {
441 /* 442 /*
442 * We really should re-lookup the page here, 443 * Re-lookup the page
443 * but it complicates things a lot. Instead
444 * lets just do what we already stored, and
445 * we'll get it the next time we are called.
446 */ 444 */
447 if (error == AOP_TRUNCATED_PAGE) 445 if (error == AOP_TRUNCATED_PAGE)
448 error = 0; 446 goto retry_lookup;
449 447
450 break; 448 break;
451 } 449 }
diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c
index 5056babe00df..dded920cbc8f 100644
--- a/fs/squashfs/super.c
+++ b/fs/squashfs/super.c
@@ -80,7 +80,6 @@ static int squashfs_fill_super(struct super_block *sb, void *data, int silent)
80{ 80{
81 struct squashfs_sb_info *msblk; 81 struct squashfs_sb_info *msblk;
82 struct squashfs_super_block *sblk = NULL; 82 struct squashfs_super_block *sblk = NULL;
83 char b[BDEVNAME_SIZE];
84 struct inode *root; 83 struct inode *root;
85 long long root_inode; 84 long long root_inode;
86 unsigned short flags; 85 unsigned short flags;
@@ -124,8 +123,8 @@ static int squashfs_fill_super(struct super_block *sb, void *data, int silent)
124 sb->s_magic = le32_to_cpu(sblk->s_magic); 123 sb->s_magic = le32_to_cpu(sblk->s_magic);
125 if (sb->s_magic != SQUASHFS_MAGIC) { 124 if (sb->s_magic != SQUASHFS_MAGIC) {
126 if (!silent) 125 if (!silent)
127 ERROR("Can't find a SQUASHFS superblock on %s\n", 126 ERROR("Can't find a SQUASHFS superblock on %pg\n",
128 bdevname(sb->s_bdev, b)); 127 sb->s_bdev);
129 goto failed_mount; 128 goto failed_mount;
130 } 129 }
131 130
@@ -178,7 +177,7 @@ static int squashfs_fill_super(struct super_block *sb, void *data, int silent)
178 msblk->inodes = le32_to_cpu(sblk->inodes); 177 msblk->inodes = le32_to_cpu(sblk->inodes);
179 flags = le16_to_cpu(sblk->flags); 178 flags = le16_to_cpu(sblk->flags);
180 179
181 TRACE("Found valid superblock on %s\n", bdevname(sb->s_bdev, b)); 180 TRACE("Found valid superblock on %pg\n", sb->s_bdev);
182 TRACE("Inodes are %scompressed\n", SQUASHFS_UNCOMPRESSED_INODES(flags) 181 TRACE("Inodes are %scompressed\n", SQUASHFS_UNCOMPRESSED_INODES(flags)
183 ? "un" : ""); 182 ? "un" : "");
184 TRACE("Data is %scompressed\n", SQUASHFS_UNCOMPRESSED_DATA(flags) 183 TRACE("Data is %scompressed\n", SQUASHFS_UNCOMPRESSED_DATA(flags)
diff --git a/fs/super.c b/fs/super.c
index 954aeb80e202..cc658a20a29e 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1012,10 +1012,8 @@ struct dentry *mount_bdev(struct file_system_type *fs_type,
1012 blkdev_put(bdev, mode); 1012 blkdev_put(bdev, mode);
1013 down_write(&s->s_umount); 1013 down_write(&s->s_umount);
1014 } else { 1014 } else {
1015 char b[BDEVNAME_SIZE];
1016
1017 s->s_mode = mode; 1015 s->s_mode = mode;
1018 strlcpy(s->s_id, bdevname(bdev, b), sizeof(s->s_id)); 1016 snprintf(s->s_id, sizeof(s->s_id), "%pg", bdev);
1019 sb_set_blocksize(s, block_size(bdev)); 1017 sb_set_blocksize(s, block_size(bdev));
1020 error = fill_super(s, data, flags & MS_SILENT ? 1 : 0); 1018 error = fill_super(s, data, flags & MS_SILENT ? 1 : 0);
1021 if (error) { 1019 if (error) {
diff --git a/fs/xattr.c b/fs/xattr.c
index d7f5037a17b5..d5dd6c8b82a7 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -305,7 +305,6 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
305{ 305{
306 int error; 306 int error;
307 void *kvalue = NULL; 307 void *kvalue = NULL;
308 void *vvalue = NULL; /* If non-NULL, we used vmalloc() */
309 char kname[XATTR_NAME_MAX + 1]; 308 char kname[XATTR_NAME_MAX + 1];
310 309
311 if (flags & ~(XATTR_CREATE|XATTR_REPLACE)) 310 if (flags & ~(XATTR_CREATE|XATTR_REPLACE))
@@ -322,10 +321,9 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
322 return -E2BIG; 321 return -E2BIG;
323 kvalue = kmalloc(size, GFP_KERNEL | __GFP_NOWARN); 322 kvalue = kmalloc(size, GFP_KERNEL | __GFP_NOWARN);
324 if (!kvalue) { 323 if (!kvalue) {
325 vvalue = vmalloc(size); 324 kvalue = vmalloc(size);
326 if (!vvalue) 325 if (!kvalue)
327 return -ENOMEM; 326 return -ENOMEM;
328 kvalue = vvalue;
329 } 327 }
330 if (copy_from_user(kvalue, value, size)) { 328 if (copy_from_user(kvalue, value, size)) {
331 error = -EFAULT; 329 error = -EFAULT;
@@ -338,10 +336,8 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
338 336
339 error = vfs_setxattr(d, kname, kvalue, size, flags); 337 error = vfs_setxattr(d, kname, kvalue, size, flags);
340out: 338out:
341 if (vvalue) 339 kvfree(kvalue);
342 vfree(vvalue); 340
343 else
344 kfree(kvalue);
345 return error; 341 return error;
346} 342}
347 343
@@ -409,7 +405,6 @@ getxattr(struct dentry *d, const char __user *name, void __user *value,
409{ 405{
410 ssize_t error; 406 ssize_t error;
411 void *kvalue = NULL; 407 void *kvalue = NULL;
412 void *vvalue = NULL;
413 char kname[XATTR_NAME_MAX + 1]; 408 char kname[XATTR_NAME_MAX + 1];
414 409
415 error = strncpy_from_user(kname, name, sizeof(kname)); 410 error = strncpy_from_user(kname, name, sizeof(kname));
@@ -423,10 +418,9 @@ getxattr(struct dentry *d, const char __user *name, void __user *value,
423 size = XATTR_SIZE_MAX; 418 size = XATTR_SIZE_MAX;
424 kvalue = kzalloc(size, GFP_KERNEL | __GFP_NOWARN); 419 kvalue = kzalloc(size, GFP_KERNEL | __GFP_NOWARN);
425 if (!kvalue) { 420 if (!kvalue) {
426 vvalue = vmalloc(size); 421 kvalue = vmalloc(size);
427 if (!vvalue) 422 if (!kvalue)
428 return -ENOMEM; 423 return -ENOMEM;
429 kvalue = vvalue;
430 } 424 }
431 } 425 }
432 426
@@ -442,10 +436,9 @@ getxattr(struct dentry *d, const char __user *name, void __user *value,
442 than XATTR_SIZE_MAX bytes. Not possible. */ 436 than XATTR_SIZE_MAX bytes. Not possible. */
443 error = -E2BIG; 437 error = -E2BIG;
444 } 438 }
445 if (vvalue) 439
446 vfree(vvalue); 440 kvfree(kvalue);
447 else 441
448 kfree(kvalue);
449 return error; 442 return error;
450} 443}
451 444
@@ -502,17 +495,15 @@ listxattr(struct dentry *d, char __user *list, size_t size)
502{ 495{
503 ssize_t error; 496 ssize_t error;
504 char *klist = NULL; 497 char *klist = NULL;
505 char *vlist = NULL; /* If non-NULL, we used vmalloc() */
506 498
507 if (size) { 499 if (size) {
508 if (size > XATTR_LIST_MAX) 500 if (size > XATTR_LIST_MAX)
509 size = XATTR_LIST_MAX; 501 size = XATTR_LIST_MAX;
510 klist = kmalloc(size, __GFP_NOWARN | GFP_KERNEL); 502 klist = kmalloc(size, __GFP_NOWARN | GFP_KERNEL);
511 if (!klist) { 503 if (!klist) {
512 vlist = vmalloc(size); 504 klist = vmalloc(size);
513 if (!vlist) 505 if (!klist)
514 return -ENOMEM; 506 return -ENOMEM;
515 klist = vlist;
516 } 507 }
517 } 508 }
518 509
@@ -525,10 +516,9 @@ listxattr(struct dentry *d, char __user *list, size_t size)
525 than XATTR_LIST_MAX bytes. Not possible. */ 516 than XATTR_LIST_MAX bytes. Not possible. */
526 error = -E2BIG; 517 error = -E2BIG;
527 } 518 }
528 if (vlist) 519
529 vfree(vlist); 520 kvfree(klist);
530 else 521
531 kfree(klist);
532 return error; 522 return error;
533} 523}
534 524
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 3243cdf97f33..ace91e7c713e 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -1632,13 +1632,9 @@ xfs_setsize_buftarg(
1632 btp->bt_meta_sectormask = sectorsize - 1; 1632 btp->bt_meta_sectormask = sectorsize - 1;
1633 1633
1634 if (set_blocksize(btp->bt_bdev, sectorsize)) { 1634 if (set_blocksize(btp->bt_bdev, sectorsize)) {
1635 char name[BDEVNAME_SIZE];
1636
1637 bdevname(btp->bt_bdev, name);
1638
1639 xfs_warn(btp->bt_mount, 1635 xfs_warn(btp->bt_mount,
1640 "Cannot set_blocksize to %u on device %s", 1636 "Cannot set_blocksize to %u on device %pg",
1641 sectorsize, name); 1637 sectorsize, btp->bt_bdev);
1642 return -EINVAL; 1638 return -EINVAL;
1643 } 1639 }
1644 1640