mirror of
https://github.com/torvalds/linux.git
synced 2026-05-29 17:43:52 +02:00
fuse_ctl: use simple_recursive_removal()
easier that way - no need to keep that array of dentry references, etc. Reviewed-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
7b7a8ca43f
commit
fcaac5b427
|
|
@ -11,6 +11,7 @@
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/fs_context.h>
|
#include <linux/fs_context.h>
|
||||||
|
#include <linux/namei.h>
|
||||||
|
|
||||||
#define FUSE_CTL_SUPER_MAGIC 0x65735543
|
#define FUSE_CTL_SUPER_MAGIC 0x65735543
|
||||||
|
|
||||||
|
|
@ -212,7 +213,6 @@ static struct dentry *fuse_ctl_add_dentry(struct dentry *parent,
|
||||||
struct dentry *dentry;
|
struct dentry *dentry;
|
||||||
struct inode *inode;
|
struct inode *inode;
|
||||||
|
|
||||||
BUG_ON(fc->ctl_ndents >= FUSE_CTL_NUM_DENTRIES);
|
|
||||||
dentry = d_alloc_name(parent, name);
|
dentry = d_alloc_name(parent, name);
|
||||||
if (!dentry)
|
if (!dentry)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -236,8 +236,6 @@ static struct dentry *fuse_ctl_add_dentry(struct dentry *parent,
|
||||||
inode->i_private = fc;
|
inode->i_private = fc;
|
||||||
d_add(dentry, inode);
|
d_add(dentry, inode);
|
||||||
|
|
||||||
fc->ctl_dentry[fc->ctl_ndents++] = dentry;
|
|
||||||
|
|
||||||
return dentry;
|
return dentry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -280,27 +278,29 @@ int fuse_ctl_add_conn(struct fuse_conn *fc)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void remove_one(struct dentry *dentry)
|
||||||
|
{
|
||||||
|
d_inode(dentry)->i_private = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Remove a connection from the control filesystem (if it exists).
|
* Remove a connection from the control filesystem (if it exists).
|
||||||
* Caller must hold fuse_mutex
|
* Caller must hold fuse_mutex
|
||||||
*/
|
*/
|
||||||
void fuse_ctl_remove_conn(struct fuse_conn *fc)
|
void fuse_ctl_remove_conn(struct fuse_conn *fc)
|
||||||
{
|
{
|
||||||
int i;
|
struct dentry *dentry;
|
||||||
|
char name[32];
|
||||||
|
|
||||||
if (!fuse_control_sb || fc->no_control)
|
if (!fuse_control_sb || fc->no_control)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = fc->ctl_ndents - 1; i >= 0; i--) {
|
sprintf(name, "%u", fc->dev);
|
||||||
struct dentry *dentry = fc->ctl_dentry[i];
|
dentry = lookup_noperm_positive_unlocked(&QSTR(name), fuse_control_sb->s_root);
|
||||||
d_inode(dentry)->i_private = NULL;
|
if (!IS_ERR(dentry)) {
|
||||||
if (!i) {
|
simple_recursive_removal(dentry, remove_one);
|
||||||
/* Get rid of submounts: */
|
dput(dentry); // paired with lookup_noperm_positive_unlocked()
|
||||||
d_invalidate(dentry);
|
|
||||||
}
|
|
||||||
dput(dentry);
|
|
||||||
}
|
}
|
||||||
drop_nlink(d_inode(fuse_control_sb->s_root));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fuse_ctl_fill_super(struct super_block *sb, struct fs_context *fsc)
|
static int fuse_ctl_fill_super(struct super_block *sb, struct fs_context *fsc)
|
||||||
|
|
@ -346,12 +346,8 @@ static int fuse_ctl_init_fs_context(struct fs_context *fsc)
|
||||||
|
|
||||||
static void fuse_ctl_kill_sb(struct super_block *sb)
|
static void fuse_ctl_kill_sb(struct super_block *sb)
|
||||||
{
|
{
|
||||||
struct fuse_conn *fc;
|
|
||||||
|
|
||||||
mutex_lock(&fuse_mutex);
|
mutex_lock(&fuse_mutex);
|
||||||
fuse_control_sb = NULL;
|
fuse_control_sb = NULL;
|
||||||
list_for_each_entry(fc, &fuse_conn_list, entry)
|
|
||||||
fc->ctl_ndents = 0;
|
|
||||||
mutex_unlock(&fuse_mutex);
|
mutex_unlock(&fuse_mutex);
|
||||||
|
|
||||||
kill_litter_super(sb);
|
kill_litter_super(sb);
|
||||||
|
|
|
||||||
|
|
@ -913,12 +913,6 @@ struct fuse_conn {
|
||||||
/** Device ID from the root super block */
|
/** Device ID from the root super block */
|
||||||
dev_t dev;
|
dev_t dev;
|
||||||
|
|
||||||
/** Dentries in the control filesystem */
|
|
||||||
struct dentry *ctl_dentry[FUSE_CTL_NUM_DENTRIES];
|
|
||||||
|
|
||||||
/** number of dentries used in the above array */
|
|
||||||
int ctl_ndents;
|
|
||||||
|
|
||||||
/** Key for lock owner ID scrambling */
|
/** Key for lock owner ID scrambling */
|
||||||
u32 scramble_key[4];
|
u32 scramble_key[4];
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user