From 98af592f5bf863137ae2872ed03720f02fbc82c3 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 14 Dec 2014 02:59:17 -0500 Subject: btrfs: filp_open() returns ERR_PTR() on failure, not NULL... Signed-off-by: Al Viro diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 0144790..50c5a87 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1485,7 +1485,7 @@ static void update_dev_time(char *path_name) struct file *filp; filp = filp_open(path_name, O_RDWR, 0); - if (!filp) + if (IS_ERR(filp)) return; file_update_time(filp); filp_close(filp, NULL); -- cgit v0.10.2 From 1ad581ebf31688155db50665005af73e0184e427 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 11 Dec 2014 22:40:27 -0500 Subject: lustre: get rid of playing with ->fs * removed several pieces of dead code in lustre_compat25.h * don't open-code current_umask() (and BTW, 0755 & (S_IRWXUGO | S_ISVTX) is better spelled as 0755) * fix broken attempt to get the pathname by dentry - abusing d_path() for that is simply wrong. Signed-off-by: Al Viro diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h index 8156b4c..3925db1 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h @@ -42,28 +42,6 @@ #include "lustre_patchless_compat.h" -# define LOCK_FS_STRUCT(fs) spin_lock(&(fs)->lock) -# define UNLOCK_FS_STRUCT(fs) spin_unlock(&(fs)->lock) - -static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt, - struct dentry *dentry) -{ - struct path path; - struct path old_pwd; - - path.mnt = mnt; - path.dentry = dentry; - LOCK_FS_STRUCT(fs); - old_pwd = fs->pwd; - path_get(&path); - fs->pwd = path; - UNLOCK_FS_STRUCT(fs); - - if (old_pwd.dentry) - path_put(&old_pwd); -} - - /* * set ATTR_BLOCKS to a high value to avoid any risk of collision with other * ATTR_* attributes (see bug 13828) @@ -110,8 +88,6 @@ static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt, #define cfs_bio_io_error(a, b) bio_io_error((a)) #define cfs_bio_endio(a, b, c) bio_endio((a), (c)) -#define cfs_fs_pwd(fs) ((fs)->pwd.dentry) -#define cfs_fs_mnt(fs) ((fs)->pwd.mnt) #define cfs_path_put(nd) path_put(&(nd)->path) diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 407718a..1ac7a70 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -661,7 +661,7 @@ int ll_dir_setdirstripe(struct inode *dir, struct lmv_user_md *lump, int mode; int err; - mode = (0755 & (S_IRWXUGO|S_ISVTX) & ~current->fs->umask) | S_IFDIR; + mode = (0755 & ~current_umask()) | S_IFDIR; op_data = ll_prep_md_op_data(NULL, dir, NULL, filename, strlen(filename), mode, LUSTRE_OPC_MKDIR, lump); diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 6e423aa..a3367bf 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -2372,21 +2372,6 @@ char *ll_get_fsname(struct super_block *sb, char *buf, int buflen) return buf; } -static char *ll_d_path(struct dentry *dentry, char *buf, int bufsize) -{ - char *path = NULL; - - struct path p; - - p.dentry = dentry; - p.mnt = current->fs->root.mnt; - path_get(&p); - path = d_path(&p, buf, bufsize); - path_put(&p); - - return path; -} - void ll_dirty_page_discard_warn(struct page *page, int ioret) { char *buf, *path = NULL; @@ -2398,7 +2383,7 @@ void ll_dirty_page_discard_warn(struct page *page, int ioret) if (buf != NULL) { dentry = d_find_alias(page->mapping->host); if (dentry != NULL) - path = ll_d_path(dentry, buf, PAGE_SIZE); + path = dentry_path_raw(dentry, buf, PAGE_SIZE); } CDEBUG(D_WARNING, -- cgit v0.10.2 From b1bc6d7f163234cad4f34e3f5dffde44b96369eb Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 17 Dec 2014 04:37:27 -0500 Subject: move_extent_per_page(): get rid of unused w_flags ... and comparing get_fs() with KERNEL_DS used only to initialize that Signed-off-by: Al Viro diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c index 503ea15..370420b 100644 --- a/fs/ext4/move_extent.c +++ b/fs/ext4/move_extent.c @@ -267,7 +267,6 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode, handle_t *handle; ext4_lblk_t orig_blk_offset, donor_blk_offset; unsigned long blocksize = orig_inode->i_sb->s_blocksize; - unsigned int w_flags = 0; unsigned int tmp_data_size, data_size, replaced_size; int err2, jblocks, retries = 0; int replaced_count = 0; @@ -288,9 +287,6 @@ again: return 0; } - if (segment_eq(get_fs(), KERNEL_DS)) - w_flags |= AOP_FLAG_UNINTERRUPTIBLE; - orig_blk_offset = orig_page_offset * blocks_per_page + data_offset_in_page; -- cgit v0.10.2 From 777eda2c5b84d6f3543f4aecbf4cd1f29b222a81 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 17 Dec 2014 04:46:46 -0500 Subject: new helper: iter_is_iovec() Signed-off-by: Al Viro diff --git a/include/linux/uio.h b/include/linux/uio.h index a41e252..1c5e453 100644 --- a/include/linux/uio.h +++ b/include/linux/uio.h @@ -101,6 +101,11 @@ static inline size_t iov_iter_count(struct iov_iter *i) return i->count; } +static inline bool iter_is_iovec(struct iov_iter *i) +{ + return !(i->type & (ITER_BVEC | ITER_KVEC)); +} + /* * Cap the iov_iter by given limit; note that the second argument is * *not* the new size - it's upper limit for such. Passing it a value diff --git a/mm/filemap.c b/mm/filemap.c index e8905bc..bd8543c 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2464,7 +2464,7 @@ ssize_t generic_perform_write(struct file *file, /* * Copies from kernel address space cannot fail (NFSD is a big user). */ - if (segment_eq(get_fs(), KERNEL_DS)) + if (!iter_is_iovec(i)) flags |= AOP_FLAG_UNINTERRUPTIBLE; do { diff --git a/mm/shmem.c b/mm/shmem.c index 185836b..73ba1df 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1536,7 +1536,7 @@ static ssize_t shmem_file_read_iter(struct kiocb *iocb, struct iov_iter *to) * holes of a sparse file, we actually need to allocate those pages, * and even mark them dirty, so it cannot exceed the max_blocks limit. */ - if (segment_eq(get_fs(), KERNEL_DS)) + if (!iter_is_iovec(to)) sgp = SGP_DIRTY; index = *ppos >> PAGE_CACHE_SHIFT; -- cgit v0.10.2 From 50062175ffc844b8ff9664024c6416a37ad63c77 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 15 May 2014 05:06:42 -0400 Subject: vm_area_operations: kill ->migrate() the only instance this method has ever grown was one in kernfs - one that call ->migrate() of another vm_ops if it exists. Signed-off-by: Al Viro diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c index 697390e..ddc9f96 100644 --- a/fs/kernfs/file.c +++ b/fs/kernfs/file.c @@ -448,27 +448,6 @@ static struct mempolicy *kernfs_vma_get_policy(struct vm_area_struct *vma, return pol; } -static int kernfs_vma_migrate(struct vm_area_struct *vma, - const nodemask_t *from, const nodemask_t *to, - unsigned long flags) -{ - struct file *file = vma->vm_file; - struct kernfs_open_file *of = kernfs_of(file); - int ret; - - if (!of->vm_ops) - return 0; - - if (!kernfs_get_active(of->kn)) - return 0; - - ret = 0; - if (of->vm_ops->migrate) - ret = of->vm_ops->migrate(vma, from, to, flags); - - kernfs_put_active(of->kn); - return ret; -} #endif static const struct vm_operations_struct kernfs_vm_ops = { @@ -479,7 +458,6 @@ static const struct vm_operations_struct kernfs_vm_ops = { #ifdef CONFIG_NUMA .set_policy = kernfs_vma_set_policy, .get_policy = kernfs_vma_get_policy, - .migrate = kernfs_vma_migrate, #endif }; diff --git a/include/linux/migrate.h b/include/linux/migrate.h index 01aad3e..fab9b32 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -36,9 +36,6 @@ extern int migrate_pages(struct list_head *l, new_page_t new, free_page_t free, extern int migrate_prep(void); extern int migrate_prep_local(void); -extern int migrate_vmas(struct mm_struct *mm, - const nodemask_t *from, const nodemask_t *to, - unsigned long flags); extern void migrate_page_copy(struct page *newpage, struct page *page); extern int migrate_huge_page_move_mapping(struct address_space *mapping, struct page *newpage, struct page *page); @@ -57,13 +54,6 @@ static inline int migrate_pages(struct list_head *l, new_page_t new, static inline int migrate_prep(void) { return -ENOSYS; } static inline int migrate_prep_local(void) { return -ENOSYS; } -static inline int migrate_vmas(struct mm_struct *mm, - const nodemask_t *from, const nodemask_t *to, - unsigned long flags) -{ - return -ENOSYS; -} - static inline void migrate_page_copy(struct page *newpage, struct page *page) {} diff --git a/include/linux/mm.h b/include/linux/mm.h index c0a67b8..f80d019 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -286,8 +286,6 @@ struct vm_operations_struct { */ struct mempolicy *(*get_policy)(struct vm_area_struct *vma, unsigned long addr); - int (*migrate)(struct vm_area_struct *vma, const nodemask_t *from, - const nodemask_t *to, unsigned long flags); #endif /* called by sys_remap_file_pages() to populate non-linear mapping */ int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr, diff --git a/mm/mempolicy.c b/mm/mempolicy.c index e58725a..c1b273f 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1047,10 +1047,6 @@ int do_migrate_pages(struct mm_struct *mm, const nodemask_t *from, down_read(&mm->mmap_sem); - err = migrate_vmas(mm, from, to, flags); - if (err) - goto out; - /* * Find a 'source' bit set in 'tmp' whose corresponding 'dest' * bit in 'to' is not also set in 'tmp'. Clear the found 'source' @@ -1130,7 +1126,6 @@ int do_migrate_pages(struct mm_struct *mm, const nodemask_t *from, if (err < 0) break; } -out: up_read(&mm->mmap_sem); if (err < 0) return err; diff --git a/mm/migrate.c b/mm/migrate.c index b1d0212..344cdf6 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1536,27 +1536,6 @@ out: return err; } -/* - * Call migration functions in the vma_ops that may prepare - * memory in a vm for migration. migration functions may perform - * the migration for vmas that do not have an underlying page struct. - */ -int migrate_vmas(struct mm_struct *mm, const nodemask_t *to, - const nodemask_t *from, unsigned long flags) -{ - struct vm_area_struct *vma; - int err = 0; - - for (vma = mm->mmap; vma && !err; vma = vma->vm_next) { - if (vma->vm_ops && vma->vm_ops->migrate) { - err = vma->vm_ops->migrate(vma, to, from, flags); - if (err) - break; - } - } - return err; -} - #ifdef CONFIG_NUMA_BALANCING /* * Returns true if this is a safe migration target node for misplaced NUMA -- cgit v0.10.2 From 7d65cf10e3d7747033b83fa18c5f3d2a498f66bc Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 17 Dec 2014 05:29:16 -0500 Subject: unfuck binfmt_misc.c (broken by commit e6084d4) scanarg(s, del) never returns s; the empty field results in s + 1. Restore the correct checks, and move NUL-termination into scanarg(), while we are at it. Incidentally, mixing "coding style cleanups" (for small values of cleanup) with functional changes is a Bad Idea(tm)... Signed-off-by: Al Viro diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c index c04ef1d..97aff28 100644 --- a/fs/binfmt_misc.c +++ b/fs/binfmt_misc.c @@ -254,6 +254,7 @@ static char *scanarg(char *s, char del) return NULL; } } + s[-1] ='\0'; return s; } @@ -378,8 +379,7 @@ static Node *create_entry(const char __user *buffer, size_t count) p = scanarg(p, del); if (!p) goto einval; - p[-1] = '\0'; - if (p == e->magic) + if (!e->magic[0]) goto einval; if (USE_DEBUG) print_hex_dump_bytes( @@ -391,8 +391,7 @@ static Node *create_entry(const char __user *buffer, size_t count) p = scanarg(p, del); if (!p) goto einval; - p[-1] = '\0'; - if (p == e->mask) { + if (!e->mask[0]) { e->mask = NULL; pr_debug("register: mask[raw]: none\n"); } else if (USE_DEBUG) -- cgit v0.10.2 From 10975933da3d65f8833d4ce98dcc2ecc63a695d6 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Thu, 20 Nov 2014 16:08:59 +0100 Subject: init: fix read-write root mount If mount flags don't have MS_RDONLY, iso9660 returns EACCES without actually checking if it's an iso image. This tricks mount_block_root() into retrying with MS_RDONLY. This results in a read-only root despite the "rw" boot parameter if the actual filesystem was checked after iso9660. I believe the behavior of iso9660 is okay, while that of mount_block_root() is not. It should rather try all types without MS_RDONLY and only then retry with MS_RDONLY. This change also makes the code more robust against the case when EACCES is returned despite MS_RDONLY, which would've resulted in a lockup. Signed-off-by: Miklos Szeredi Signed-off-by: Al Viro diff --git a/init/do_mounts.c b/init/do_mounts.c index 9b3565c..eb41008 100644 --- a/init/do_mounts.c +++ b/init/do_mounts.c @@ -395,8 +395,6 @@ retry: case 0: goto out; case -EACCES: - flags |= MS_RDONLY; - goto retry; case -EINVAL: continue; } @@ -419,6 +417,10 @@ retry: #endif panic("VFS: Unable to mount root fs on %s", b); } + if (!(flags & MS_RDONLY)) { + flags |= MS_RDONLY; + goto retry; + } printk("List of all partitions:\n"); printk_all_partitions(); -- cgit v0.10.2 From 9ad4dc4f7318080e2e4e0cd23623211a20d33861 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Wed, 17 Oct 2012 20:29:36 +0400 Subject: vfs: cleanup show_mountinfo Starting with commit v3.2-rc4-1-g02125a8, seq_path_root() no longer changes the value of its "struct path *root" argument. Starting with commit v3.2-rc7-104-g8c9379e, the "struct path *root" argument of seq_path_root() is const. As result, the temporary variable "root" in show_mountinfo() that holds a copy of struct path root is no longer needed. Signed-off-by: Dmitry V. Levin Signed-off-by: Al Viro diff --git a/fs/proc_namespace.c b/fs/proc_namespace.c index 73ca174..789e8d1 100644 --- a/fs/proc_namespace.c +++ b/fs/proc_namespace.c @@ -125,7 +125,6 @@ static int show_mountinfo(struct seq_file *m, struct vfsmount *mnt) struct mount *r = real_mount(mnt); struct super_block *sb = mnt->mnt_sb; struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt }; - struct path root = p->root; int err = 0; seq_printf(m, "%i %i %u:%u ", r->mnt_id, r->mnt_parent->mnt_id, @@ -139,7 +138,7 @@ static int show_mountinfo(struct seq_file *m, struct vfsmount *mnt) seq_putc(m, ' '); /* mountpoints outside of chroot jail will give SEQ_SKIP on this */ - err = seq_path_root(m, &mnt_path, &root, " \t\n\\"); + err = seq_path_root(m, &mnt_path, &p->root, " \t\n\\"); if (err) goto out; -- cgit v0.10.2 From 9d4d65748a5ca26ea8650e50ba521295549bf4e3 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Tue, 16 Dec 2014 06:59:37 +0300 Subject: vfs: make mounts and mountstats honor root dir like mountinfo does As we already show mountpoints relative to the root directory, thanks to the change made back in 2000, change show_vfsmnt() and show_vfsstat() to skip out-of-root mountpoints the same way as show_mountinfo() does. Signed-off-by: Dmitry V. Levin Signed-off-by: Al Viro diff --git a/fs/proc_namespace.c b/fs/proc_namespace.c index 789e8d1..0f96f71 100644 --- a/fs/proc_namespace.c +++ b/fs/proc_namespace.c @@ -91,6 +91,7 @@ static void show_type(struct seq_file *m, struct super_block *sb) static int show_vfsmnt(struct seq_file *m, struct vfsmount *mnt) { + struct proc_mounts *p = proc_mounts(m); struct mount *r = real_mount(mnt); int err = 0; struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt }; @@ -104,7 +105,10 @@ static int show_vfsmnt(struct seq_file *m, struct vfsmount *mnt) mangle(m, r->mnt_devname ? r->mnt_devname : "none"); } seq_putc(m, ' '); - seq_path(m, &mnt_path, " \t\n\\"); + /* mountpoints outside of chroot jail will give SEQ_SKIP on this */ + err = seq_path_root(m, &mnt_path, &p->root, " \t\n\\"); + if (err) + goto out; seq_putc(m, ' '); show_type(m, sb); seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw"); @@ -181,6 +185,7 @@ out: static int show_vfsstat(struct seq_file *m, struct vfsmount *mnt) { + struct proc_mounts *p = proc_mounts(m); struct mount *r = real_mount(mnt); struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt }; struct super_block *sb = mnt_path.dentry->d_sb; @@ -200,7 +205,10 @@ static int show_vfsstat(struct seq_file *m, struct vfsmount *mnt) /* mount point */ seq_puts(m, " mounted on "); - seq_path(m, &mnt_path, " \t\n\\"); + /* mountpoints outside of chroot jail will give SEQ_SKIP on this */ + err = seq_path_root(m, &mnt_path, &p->root, " \t\n\\"); + if (err) + goto out; seq_putc(m, ' '); /* file system type */ @@ -215,6 +223,7 @@ static int show_vfsstat(struct seq_file *m, struct vfsmount *mnt) } seq_putc(m, '\n'); +out: return err; } -- cgit v0.10.2 From e3bb504efd919f7bacd24cb14038953899b909e1 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 19 Dec 2014 07:11:56 -0500 Subject: [regression] chunk lost from bd9b51 Reported-by: Pavel Emelyanov Acked-by: Pavel Emelyanov Signed-off-by: Al Viro diff --git a/net/socket.c b/net/socket.c index 70bbde6..a2c33a4 100644 --- a/net/socket.c +++ b/net/socket.c @@ -372,7 +372,6 @@ struct file *sock_alloc_file(struct socket *sock, int flags, const char *dname) path.mnt = mntget(sock_mnt); d_instantiate(path.dentry, SOCK_INODE(sock)); - SOCK_INODE(sock)->i_fop = &socket_file_ops; file = alloc_file(&path, FMODE_READ | FMODE_WRITE, &socket_file_ops); -- cgit v0.10.2