From: Amir Goldstein <amir73il@gmail.com>
To: Jan Kara <jack@suse.cz>
Cc: Al Viro <viro@zeniv.linux.org.uk>, linux-fsdevel@vger.kernel.org
Subject: [RFC][PATCH 3/4] fs: convert filesystems to use simple_remove() helper
Date: Wed, 15 May 2019 01:19:00 +0300 [thread overview]
Message-ID: <20190514221901.29125-4-amir73il@gmail.com> (raw)
In-Reply-To: <20190514221901.29125-1-amir73il@gmail.com>
Convert some filesystems to use the new simple_remove() helper.
This will allow them to generate fsnotify delete events after the
fsnotify_nameremove() hook is removed from d_delete().
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
arch/s390/hypfs/inode.c | 9 ++-------
drivers/infiniband/hw/qib/qib_fs.c | 3 +--
fs/debugfs/inode.c | 20 ++++----------------
fs/tracefs/inode.c | 23 ++++-------------------
net/sunrpc/rpc_pipe.c | 16 ++--------------
security/apparmor/apparmorfs.c | 6 +-----
6 files changed, 14 insertions(+), 63 deletions(-)
diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c
index ccad1398abd4..30a0ab967461 100644
--- a/arch/s390/hypfs/inode.c
+++ b/arch/s390/hypfs/inode.c
@@ -70,13 +70,8 @@ static void hypfs_remove(struct dentry *dentry)
parent = dentry->d_parent;
inode_lock(d_inode(parent));
- if (simple_positive(dentry)) {
- if (d_is_dir(dentry))
- simple_rmdir(d_inode(parent), dentry);
- else
- simple_unlink(d_inode(parent), dentry);
- }
- d_delete(dentry);
+ if (simple_positive(dentry))
+ simple_remove(d_inode(parent), dentry);
dput(dentry);
inode_unlock(d_inode(parent));
}
diff --git a/drivers/infiniband/hw/qib/qib_fs.c b/drivers/infiniband/hw/qib/qib_fs.c
index ceb42d948412..795938a2488b 100644
--- a/drivers/infiniband/hw/qib/qib_fs.c
+++ b/drivers/infiniband/hw/qib/qib_fs.c
@@ -491,8 +491,7 @@ static int remove_device_files(struct super_block *sb,
}
remove_file(dir, "flash");
inode_unlock(d_inode(dir));
- ret = simple_rmdir(d_inode(root), dir);
- d_delete(dir);
+ ret = simple_remove(d_inode(root), dir);
dput(dir);
bail:
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index acef14ad53db..bc96198df1d4 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -617,13 +617,10 @@ struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent,
}
EXPORT_SYMBOL_GPL(debugfs_create_symlink);
-static void __debugfs_remove_file(struct dentry *dentry, struct dentry *parent)
+static void __debugfs_file_removed(struct dentry *dentry)
{
struct debugfs_fsdata *fsd;
- simple_unlink(d_inode(parent), dentry);
- d_delete(dentry);
-
/*
* Paired with the closing smp_mb() implied by a successful
* cmpxchg() in debugfs_file_get(): either
@@ -643,18 +640,9 @@ static int __debugfs_remove(struct dentry *dentry, struct dentry *parent)
int ret = 0;
if (simple_positive(dentry)) {
- dget(dentry);
- if (!d_is_reg(dentry)) {
- if (d_is_dir(dentry))
- ret = simple_rmdir(d_inode(parent), dentry);
- else
- simple_unlink(d_inode(parent), dentry);
- if (!ret)
- d_delete(dentry);
- } else {
- __debugfs_remove_file(dentry, parent);
- }
- dput(dentry);
+ ret = simple_remove(d_inode(parent), dentry);
+ if (d_is_reg(dentry))
+ __debugfs_file_removed(dentry);
}
return ret;
}
diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
index 7098c49f3693..6ac31ea9ad5d 100644
--- a/fs/tracefs/inode.c
+++ b/fs/tracefs/inode.c
@@ -501,25 +501,10 @@ __init struct dentry *tracefs_create_instance_dir(const char *name,
static int __tracefs_remove(struct dentry *dentry, struct dentry *parent)
{
- int ret = 0;
-
- if (simple_positive(dentry)) {
- if (dentry->d_inode) {
- dget(dentry);
- switch (dentry->d_inode->i_mode & S_IFMT) {
- case S_IFDIR:
- ret = simple_rmdir(parent->d_inode, dentry);
- break;
- default:
- simple_unlink(parent->d_inode, dentry);
- break;
- }
- if (!ret)
- d_delete(dentry);
- dput(dentry);
- }
- }
- return ret;
+ if (simple_positive(dentry))
+ return simple_remove(d_inode(parent), dentry);
+
+ return 0;
}
/**
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 979d23646e33..5b1a59776b9a 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -593,24 +593,12 @@ static int __rpc_mkpipe_dentry(struct inode *dir, struct dentry *dentry,
static int __rpc_rmdir(struct inode *dir, struct dentry *dentry)
{
- int ret;
-
- dget(dentry);
- ret = simple_rmdir(dir, dentry);
- d_delete(dentry);
- dput(dentry);
- return ret;
+ return simple_remove(dir, dentry);
}
static int __rpc_unlink(struct inode *dir, struct dentry *dentry)
{
- int ret;
-
- dget(dentry);
- ret = simple_unlink(dir, dentry);
- d_delete(dentry);
- dput(dentry);
- return ret;
+ return simple_remove(dir, dentry);
}
static int __rpc_rmpipe(struct inode *dir, struct dentry *dentry)
diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
index 9ab5613fe07c..4a10acb4a6d3 100644
--- a/security/apparmor/apparmorfs.c
+++ b/security/apparmor/apparmorfs.c
@@ -351,11 +351,7 @@ static void aafs_remove(struct dentry *dentry)
dir = d_inode(dentry->d_parent);
inode_lock(dir);
if (simple_positive(dentry)) {
- if (d_is_dir(dentry))
- simple_rmdir(dir, dentry);
- else
- simple_unlink(dir, dentry);
- d_delete(dentry);
+ simple_remove(dir, dentry);
dput(dentry);
}
inode_unlock(dir);
--
2.17.1
next prev parent reply other threads:[~2019-05-14 22:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-14 22:18 [RFC][PATCH 0/4] Sort out fsnotify_nameremove() mess Amir Goldstein
2019-05-14 22:18 ` [RFC][PATCH 1/4] fs: create simple_remove() helper Amir Goldstein
2019-05-15 7:51 ` Jan Kara
2019-05-14 22:18 ` [RFC][PATCH 2/4] fsnotify: add empty fsnotify_remove() hook Amir Goldstein
2019-05-15 7:57 ` Jan Kara
2019-05-14 22:19 ` Amir Goldstein [this message]
2019-05-14 22:19 ` [RFC][PATCH 4/4] fsnotify: move fsnotify_nameremove() hook out of d_delete() Amir Goldstein
2019-05-15 8:24 ` Jan Kara
2019-05-15 10:56 ` Amir Goldstein
2019-05-15 11:45 ` Jan Kara
2019-05-15 8:36 ` [RFC][PATCH 0/4] Sort out fsnotify_nameremove() mess Jan Kara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190514221901.29125-4-amir73il@gmail.com \
--to=amir73il@gmail.com \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).