* [PATCH 2/8] fs/namespace.c: remove unused macro MNT_WRITER_UNDERFLOW_LIMIT
2012-09-27 12:51 ` [PATCH 1/8] fs/namespace.c: introduce helper function path_unmounted() Yan Hong
@ 2012-09-27 12:51 ` Yan Hong
2012-09-27 12:51 ` [PATCH 3/8] fs/namespace.c: trivial code clean Yan Hong
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Yan Hong @ 2012-09-27 12:51 UTC (permalink / raw)
To: viro; +Cc: linux-fsdevel, linux-kernel
Its users have gone.
Signed-off-by: Yan Hong <clouds.yan@gmail.com>
---
fs/namespace.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/fs/namespace.c b/fs/namespace.c
index 3fdc239..dd969f8 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -59,7 +59,6 @@ static inline unsigned long hash(struct vfsmount *mnt, struct dentry *dentry)
return tmp & (HASH_SIZE - 1);
}
-#define MNT_WRITER_UNDERFLOW_LIMIT -(1<<16)
/*
* allocation is serialized by namespace_sem, but we need the spinlock to
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/8] fs/namespace.c: trivial code clean
2012-09-27 12:51 ` [PATCH 1/8] fs/namespace.c: introduce helper function path_unmounted() Yan Hong
2012-09-27 12:51 ` [PATCH 2/8] fs/namespace.c: remove unused macro MNT_WRITER_UNDERFLOW_LIMIT Yan Hong
@ 2012-09-27 12:51 ` Yan Hong
2012-09-27 12:51 ` [PATCH 4/8] fs/namespace.c: check permission early in sys_[u]mount Yan Hong
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Yan Hong @ 2012-09-27 12:51 UTC (permalink / raw)
To: viro; +Cc: linux-fsdevel, linux-kernel
Signed-off-by: Yan Hong <clouds.yan@gmail.com>
---
fs/namespace.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/namespace.c b/fs/namespace.c
index dd969f8..bbe9014 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -763,7 +763,7 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void
mnt->mnt.mnt_root = root;
mnt->mnt.mnt_sb = root->d_sb;
- mnt->mnt_mountpoint = mnt->mnt.mnt_root;
+ mnt->mnt_mountpoint = root;
mnt->mnt_parent = mnt;
br_write_lock(&vfsmount_lock);
list_add_tail(&mnt->mnt_instance, &root->d_sb->s_mounts);
@@ -798,7 +798,7 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root,
atomic_inc(&sb->s_active);
mnt->mnt.mnt_sb = sb;
mnt->mnt.mnt_root = dget(root);
- mnt->mnt_mountpoint = mnt->mnt.mnt_root;
+ mnt->mnt_mountpoint = root;
mnt->mnt_parent = mnt;
br_write_lock(&vfsmount_lock);
list_add_tail(&mnt->mnt_instance, &sb->s_mounts);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/8] fs/namespace.c: check permission early in sys_[u]mount
2012-09-27 12:51 ` [PATCH 1/8] fs/namespace.c: introduce helper function path_unmounted() Yan Hong
2012-09-27 12:51 ` [PATCH 2/8] fs/namespace.c: remove unused macro MNT_WRITER_UNDERFLOW_LIMIT Yan Hong
2012-09-27 12:51 ` [PATCH 3/8] fs/namespace.c: trivial code clean Yan Hong
@ 2012-09-27 12:51 ` Yan Hong
2012-09-27 12:51 ` [PATCH 5/8] fs/namei.c: introduce macro AT_FDINV Yan Hong
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Yan Hong @ 2012-09-27 12:51 UTC (permalink / raw)
To: viro; +Cc: linux-fsdevel, linux-kernel
We have several branches in sys_mount, each of them will check
CAP_SYS_ADMIN capability seperately. Do this check at the beginning
of sys_mount.
Also check permission as early as possible in sys_umount.
Signed-off-by: Yan Hong <clouds.yan@gmail.com>
---
fs/namespace.c | 26 +++++++-------------------
1 file changed, 7 insertions(+), 19 deletions(-)
diff --git a/fs/namespace.c b/fs/namespace.c
index bbe9014..ca2b6e9 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1256,6 +1256,9 @@ SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
if (flags & ~(MNT_FORCE | MNT_DETACH | MNT_EXPIRE | UMOUNT_NOFOLLOW))
return -EINVAL;
+ if (!capable(CAP_SYS_ADMIN))
+ return -EPERM;
+
if (!(flags & UMOUNT_NOFOLLOW))
lookup_flags |= LOOKUP_FOLLOW;
@@ -1269,10 +1272,6 @@ SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
if (!check_mnt(mnt))
goto dput_and_out;
- retval = -EPERM;
- if (!capable(CAP_SYS_ADMIN))
- goto dput_and_out;
-
retval = do_umount(mnt, flags);
dput_and_out:
/* we mustn't call path_put() as that would clear mnt_expiry_mark */
@@ -1296,9 +1295,7 @@ SYSCALL_DEFINE1(oldumount, char __user *, name)
static int mount_is_safe(struct path *path)
{
- if (capable(CAP_SYS_ADMIN))
- return 0;
- return -EPERM;
+ return 0;
#ifdef notyet
if (S_ISLNK(path->dentry->d_inode->i_mode))
return -EPERM;
@@ -1614,9 +1611,6 @@ static int do_change_type(struct path *path, int flag)
int type;
int err = 0;
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
-
if (path_unmounted(path))
return -EINVAL;
@@ -1725,9 +1719,6 @@ static int do_remount(struct path *path, int flags, int mnt_flags,
struct super_block *sb = path->mnt->mnt_sb;
struct mount *mnt = real_mount(path->mnt);
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
-
if (!check_mnt(mnt))
return -EINVAL;
@@ -1774,8 +1765,6 @@ static int do_move_mount(struct path *path, char *old_name)
struct mount *p;
struct mount *old;
int err = 0;
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
if (!old_name || !*old_name)
return -EINVAL;
err = kern_path(old_name, LOOKUP_FOLLOW, &old_path);
@@ -1924,10 +1913,6 @@ static int do_new_mount(struct path *path, char *type, int flags,
if (!type)
return -EINVAL;
- /* we need capabilities... */
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
-
mnt = do_kern_mount(type, flags, name, data);
if (IS_ERR(mnt))
return PTR_ERR(mnt);
@@ -2410,6 +2395,9 @@ SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
char *kernel_dev;
unsigned long data_page;
+ if (!capable(CAP_SYS_ADMIN))
+ return -EPERM;
+
ret = copy_mount_string(type, &kernel_type);
if (ret < 0)
goto out_type;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/8] fs/namei.c: introduce macro AT_FDINV
2012-09-27 12:51 ` [PATCH 1/8] fs/namespace.c: introduce helper function path_unmounted() Yan Hong
` (2 preceding siblings ...)
2012-09-27 12:51 ` [PATCH 4/8] fs/namespace.c: check permission early in sys_[u]mount Yan Hong
@ 2012-09-27 12:51 ` Yan Hong
2012-09-27 12:51 ` [PATCH 6/8] fs/inode.c: call alloc_inode() in new_inode() directly Yan Hong
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Yan Hong @ 2012-09-27 12:51 UTC (permalink / raw)
To: viro; +Cc: linux-fsdevel, linux-kernel
File descriptor is irrelevent when LOOKUP_ROOT is set.
Introduce AT_FDINV to avoid using hard coded value or reusing
existing macro.
Signed-off-by: Yan Hong <clouds.yan@gmail.com>
---
fs/namei.c | 11 ++++++-----
include/linux/fcntl.h | 2 ++
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/fs/namei.c b/fs/namei.c
index c5b85b3..5ffd97d 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2034,8 +2034,8 @@ int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt,
nd.root.dentry = dentry;
nd.root.mnt = mnt;
BUG_ON(flags & LOOKUP_PARENT);
- /* the first argument of do_path_lookup() is ignored with LOOKUP_ROOT */
- err = do_path_lookup(AT_FDCWD, name, flags | LOOKUP_ROOT, &nd);
+
+ err = do_path_lookup(AT_FDINV, name, flags | LOOKUP_ROOT, &nd);
if (!err)
*path = nd.path;
return err;
@@ -2969,11 +2969,12 @@ struct file *do_file_open_root(struct dentry *dentry, struct vfsmount *mnt,
if (dentry->d_inode->i_op->follow_link && op->intent & LOOKUP_OPEN)
return ERR_PTR(-ELOOP);
- file = path_openat(-1, name, &nd, op, flags | LOOKUP_RCU);
+ file = path_openat(AT_FDINV, name, &nd, op, flags | LOOKUP_RCU);
if (unlikely(file == ERR_PTR(-ECHILD)))
- file = path_openat(-1, name, &nd, op, flags);
+ file = path_openat(AT_FDINV, name, &nd, op, flags);
if (unlikely(file == ERR_PTR(-ESTALE)))
- file = path_openat(-1, name, &nd, op, flags | LOOKUP_REVAL);
+ file = path_openat(AT_FDINV, name, &nd, op,
+ flags | LOOKUP_REVAL);
return file;
}
diff --git a/include/linux/fcntl.h b/include/linux/fcntl.h
index f550f89..abd94fe 100644
--- a/include/linux/fcntl.h
+++ b/include/linux/fcntl.h
@@ -41,6 +41,8 @@
#define AT_FDCWD -100 /* Special value used to indicate
openat should use the current
working directory. */
+#define AT_FDINV -200 /* Special value used when LOOKUP_ROOT
+ is set. */
#define AT_SYMLINK_NOFOLLOW 0x100 /* Do not follow symbolic links. */
#define AT_REMOVEDIR 0x200 /* Remove directory instead of
unlinking file. */
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 6/8] fs/inode.c: call alloc_inode() in new_inode() directly
2012-09-27 12:51 ` [PATCH 1/8] fs/namespace.c: introduce helper function path_unmounted() Yan Hong
` (3 preceding siblings ...)
2012-09-27 12:51 ` [PATCH 5/8] fs/namei.c: introduce macro AT_FDINV Yan Hong
@ 2012-09-27 12:51 ` Yan Hong
2012-09-27 12:51 ` [PATCH 7/8] fs/inode.c: remove outstanding spin lock prefetch Yan Hong
2012-09-27 12:51 ` [PATCH 8/8] vfs: misc comment clean Yan Hong
6 siblings, 0 replies; 8+ messages in thread
From: Yan Hong @ 2012-09-27 12:51 UTC (permalink / raw)
To: viro; +Cc: linux-fsdevel, linux-kernel
This saves us a list head initialization.
Signed-off-by: Yan Hong <clouds.yan@gmail.com>
---
fs/inode.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/inode.c b/fs/inode.c
index ac8d904..3a2cd41 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -921,9 +921,11 @@ struct inode *new_inode(struct super_block *sb)
spin_lock_prefetch(&inode_sb_list_lock);
- inode = new_inode_pseudo(sb);
- if (inode)
+ inode = alloc_inode(sb);
+ if (inode) {
+ inode->i_state = 0;
inode_sb_list_add(inode);
+ }
return inode;
}
EXPORT_SYMBOL(new_inode);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 7/8] fs/inode.c: remove outstanding spin lock prefetch
2012-09-27 12:51 ` [PATCH 1/8] fs/namespace.c: introduce helper function path_unmounted() Yan Hong
` (4 preceding siblings ...)
2012-09-27 12:51 ` [PATCH 6/8] fs/inode.c: call alloc_inode() in new_inode() directly Yan Hong
@ 2012-09-27 12:51 ` Yan Hong
2012-09-27 12:51 ` [PATCH 8/8] vfs: misc comment clean Yan Hong
6 siblings, 0 replies; 8+ messages in thread
From: Yan Hong @ 2012-09-27 12:51 UTC (permalink / raw)
To: viro; +Cc: linux-fsdevel, linux-kernel
Do we have particular reason to do this here?
Signed-off-by: Yan Hong <clouds.yan@gmail.com>
---
fs/inode.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/fs/inode.c b/fs/inode.c
index 3a2cd41..e89d30c 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -14,7 +14,6 @@
#include <linux/fsnotify.h>
#include <linux/mount.h>
#include <linux/posix_acl.h>
-#include <linux/prefetch.h>
#include <linux/buffer_head.h> /* for inode_has_buffers */
#include <linux/ratelimit.h>
#include "internal.h"
@@ -919,8 +918,6 @@ struct inode *new_inode(struct super_block *sb)
{
struct inode *inode;
- spin_lock_prefetch(&inode_sb_list_lock);
-
inode = alloc_inode(sb);
if (inode) {
inode->i_state = 0;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 8/8] vfs: misc comment clean
2012-09-27 12:51 ` [PATCH 1/8] fs/namespace.c: introduce helper function path_unmounted() Yan Hong
` (5 preceding siblings ...)
2012-09-27 12:51 ` [PATCH 7/8] fs/inode.c: remove outstanding spin lock prefetch Yan Hong
@ 2012-09-27 12:51 ` Yan Hong
6 siblings, 0 replies; 8+ messages in thread
From: Yan Hong @ 2012-09-27 12:51 UTC (permalink / raw)
To: viro; +Cc: linux-fsdevel, linux-kernel
Mostly fix comments which reference inexist locks or parameters.
Signed-off-by: Yan Hong <clouds.yan@gmail.com>
---
fs/dcache.c | 12 ++++--------
fs/inode.c | 4 ++--
fs/namei.c | 2 +-
fs/namespace.c | 9 +++------
4 files changed, 10 insertions(+), 17 deletions(-)
diff --git a/fs/dcache.c b/fs/dcache.c
index 8086636..2d97518 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -44,8 +44,6 @@
* Usage:
* dcache->d_inode->i_lock protects:
* - i_dentry, d_alias, d_inode of aliases
- * dcache_hash_bucket lock protects:
- * - the dcache hash table
* s_anon bl list spinlock protects:
* - the s_anon list (see __d_drop)
* dcache_lru_lock protects:
@@ -64,7 +62,6 @@
* dentry->d_inode->i_lock
* dentry->d_lock
* dcache_lru_lock
- * dcache_hash_bucket lock
* s_anon lock
*
* If there is an ancestor relationship:
@@ -145,10 +142,9 @@ int proc_nr_dentry(ctl_table *table, int write, void __user *buffer,
#include <asm/word-at-a-time.h>
/*
- * NOTE! 'cs' and 'scount' come from a dentry, so it has a
- * aligned allocation for this particular component. We don't
- * strictly need the load_unaligned_zeropad() safety, but it
- * doesn't hurt either.
+ * NOTE! 'cs' comes from a dentry, so it has an aligned allocation
+ * for this particular component. We don't strictly need the
+ * load_unaligned_zeropad() safety, but it doesn't hurt either.
*
* In contrast, 'ct' and 'tcount' can be from a pathname, and do
* need the careful unaligned handling.
@@ -304,7 +300,7 @@ static void dentry_unlink_inode(struct dentry * dentry)
}
/*
- * dentry_lru_(add|del|prune|move_tail) must be called with d_lock held.
+ * dentry_lru_(add|del|prune|move_list) must be called with d_lock held.
*/
static void dentry_lru_add(struct dentry *dentry)
{
diff --git a/fs/inode.c b/fs/inode.c
index e89d30c..46d4f16 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -676,7 +676,7 @@ static int can_unuse(struct inode *inode)
* Walk the superblock inode LRU for freeable inodes and attempt to free them.
* This is called from the superblock shrinker function with a number of inodes
* to trim from the LRU. Inodes to be freed are moved to a temporary list and
- * then are freed outside inode_lock by dispose_list().
+ * then are freed outside s_inode_lru_lock by dispose_list().
*
* Any inodes which are pinned purely because of attached pagecache have their
* pagecache removed. If the inode has metadata buffers attached to
@@ -777,7 +777,7 @@ void prune_icache_sb(struct super_block *sb, int nr_to_scan)
static void __wait_on_freeing_inode(struct inode *inode);
/*
- * Called with the inode lock held.
+ * Called with the inode_hash_lock held.
*/
static struct inode *find_inode(struct super_block *sb,
struct hlist_head *head,
diff --git a/fs/namei.c b/fs/namei.c
index 5ffd97d..7b1f714 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -421,7 +421,7 @@ EXPORT_SYMBOL(path_put);
* Path walking has 2 modes, rcu-walk and ref-walk (see
* Documentation/filesystems/path-lookup.txt). In situations when we can't
* continue in RCU mode, we attempt to drop out of rcu-walk mode and grab
- * normal reference counts on dentries and vfsmounts to transition to rcu-walk
+ * normal reference counts on dentries and vfsmounts to transition to ref-walk
* mode. Refcounts are grabbed at the last known good point before rcu-walk
* got stuck, so ref-walk may continue from there. If this is not successful
* (eg. a seqcount has changed), then failure is returned and it's up to caller
diff --git a/fs/namespace.c b/fs/namespace.c
index ca2b6e9..b7477ee 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1239,9 +1239,6 @@ static inline bool path_unmounted(struct path *path)
}
/*
- * Now umount can handle mount points as well as block devices.
- * This is important for filesystems which use unnamed block devices.
- *
* We now support a flag for forced unmount like the other 'big iron'
* unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
*/
@@ -1431,9 +1428,9 @@ static int invent_group_ids(struct mount *mnt, bool recurse)
}
/*
- * @source_mnt : mount tree to be attached
- * @nd : place the mount tree @source_mnt is attached
- * @parent_nd : if non-null, detach the source_mnt from its parent and
+ * @source_mnt : mount tree to be attached
+ * @path : place the mount tree @source_mnt is attached
+ * @parent_path : if non-null, detach the @source_mnt from its parent and
* store the parent mount and mountpoint dentry.
* (done when source_mnt is moved)
*
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread