Skip to content

Commit acda472

Browse files
committed
Merge branch 'vfs-scale-working' of git://git.kernel.org/pub/scm/linux/kernel/git/npiggin/linux-npiggin
* 'vfs-scale-working' of git://git.kernel.org/pub/scm/linux/kernel/git/npiggin/linux-npiggin: kernel: fix hlist_bl again cgroups: Fix a lockdep warning at cgroup removal fs: namei fix ->put_link on wrong inode in do_filp_open
2 parents 822e521 + 32385c7 commit acda472

3 files changed

Lines changed: 21 additions & 20 deletions

File tree

‎fs/namei.c‎

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,8 @@ static void path_put_conditional(struct path *path, struct nameidata *nd)
779779
mntput(path->mnt);
780780
}
781781

782-
static inline void path_to_nameidata(struct path *path, struct nameidata *nd)
782+
static inline void path_to_nameidata(const struct path *path,
783+
struct nameidata *nd)
783784
{
784785
if (!(nd->flags & LOOKUP_RCU)) {
785786
dput(nd->path.dentry);
@@ -791,20 +792,20 @@ static inline void path_to_nameidata(struct path *path, struct nameidata *nd)
791792
}
792793

793794
static __always_inline int
794-
__do_follow_link(struct path *path, struct nameidata *nd, void **p)
795+
__do_follow_link(const struct path *link, struct nameidata *nd, void **p)
795796
{
796797
int error;
797-
struct dentry *dentry = path->dentry;
798+
struct dentry *dentry = link->dentry;
798799

799-
touch_atime(path->mnt, dentry);
800+
touch_atime(link->mnt, dentry);
800801
nd_set_link(nd, NULL);
801802

802-
if (path->mnt != nd->path.mnt) {
803-
path_to_nameidata(path, nd);
803+
if (link->mnt != nd->path.mnt) {
804+
path_to_nameidata(link, nd);
804805
nd->inode = nd->path.dentry->d_inode;
805806
dget(dentry);
806807
}
807-
mntget(path->mnt);
808+
mntget(link->mnt);
808809

809810
nd->last_type = LAST_BIND;
810811
*p = dentry->d_inode->i_op->follow_link(dentry, nd);
@@ -2348,11 +2349,12 @@ struct file *do_filp_open(int dfd, const char *pathname,
23482349
nd.flags = flags;
23492350
filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname);
23502351
while (unlikely(!filp)) { /* trailing symlink */
2351-
struct path holder;
2352+
struct path link = path;
2353+
struct inode *linki = link.dentry->d_inode;
23522354
void *cookie;
23532355
error = -ELOOP;
23542356
/* S_ISDIR part is a temporary automount kludge */
2355-
if (!(nd.flags & LOOKUP_FOLLOW) && !S_ISDIR(nd.inode->i_mode))
2357+
if (!(nd.flags & LOOKUP_FOLLOW) && !S_ISDIR(linki->i_mode))
23562358
goto exit_dput;
23572359
if (count++ == 32)
23582360
goto exit_dput;
@@ -2368,23 +2370,22 @@ struct file *do_filp_open(int dfd, const char *pathname,
23682370
* just set LAST_BIND.
23692371
*/
23702372
nd.flags |= LOOKUP_PARENT;
2371-
error = security_inode_follow_link(path.dentry, &nd);
2373+
error = security_inode_follow_link(link.dentry, &nd);
23722374
if (error)
23732375
goto exit_dput;
2374-
error = __do_follow_link(&path, &nd, &cookie);
2376+
error = __do_follow_link(&link, &nd, &cookie);
23752377
if (unlikely(error)) {
2376-
if (!IS_ERR(cookie) && nd.inode->i_op->put_link)
2377-
nd.inode->i_op->put_link(path.dentry, &nd, cookie);
2378+
if (!IS_ERR(cookie) && linki->i_op->put_link)
2379+
linki->i_op->put_link(link.dentry, &nd, cookie);
23782380
/* nd.path had been dropped */
2379-
nd.path = path;
2381+
nd.path = link;
23802382
goto out_path;
23812383
}
2382-
holder = path;
23832384
nd.flags &= ~LOOKUP_PARENT;
23842385
filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname);
2385-
if (nd.inode->i_op->put_link)
2386-
nd.inode->i_op->put_link(holder.dentry, &nd, cookie);
2387-
path_put(&holder);
2386+
if (linki->i_op->put_link)
2387+
linki->i_op->put_link(link.dentry, &nd, cookie);
2388+
path_put(&link);
23882389
}
23892390
out:
23902391
if (nd.root.mnt)

‎include/linux/list_bl.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* some fast and compact auxiliary data.
1717
*/
1818

19-
#if defined(CONFIG_SMP)
19+
#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
2020
#define LIST_BL_LOCKMASK 1UL
2121
#else
2222
#define LIST_BL_LOCKMASK 0UL

‎kernel/cgroup.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ static void cgroup_d_remove_dir(struct dentry *dentry)
916916

917917
parent = dentry->d_parent;
918918
spin_lock(&parent->d_lock);
919-
spin_lock(&dentry->d_lock);
919+
spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);
920920
list_del_init(&dentry->d_u.d_child);
921921
spin_unlock(&dentry->d_lock);
922922
spin_unlock(&parent->d_lock);

0 commit comments

Comments
 (0)