hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/net/sunrpc/rpc_pipe.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * net/sunrpc/rpc_pipe.c
34 *
....@@ -13,6 +14,7 @@
1314 #include <linux/string.h>
1415 #include <linux/pagemap.h>
1516 #include <linux/mount.h>
17
+#include <linux/fs_context.h>
1618 #include <linux/namei.h>
1719 #include <linux/fsnotify.h>
1820 #include <linux/kernel.h>
....@@ -49,7 +51,7 @@
4951
5052 int rpc_pipefs_notifier_register(struct notifier_block *nb)
5153 {
52
- return blocking_notifier_chain_cond_register(&rpc_pipefs_notifier_list, nb);
54
+ return blocking_notifier_chain_register(&rpc_pipefs_notifier_list, nb);
5355 }
5456 EXPORT_SYMBOL_GPL(rpc_pipefs_notifier_register);
5557
....@@ -202,16 +204,9 @@
202204 }
203205
204206 static void
205
-rpc_i_callback(struct rcu_head *head)
207
+rpc_free_inode(struct inode *inode)
206208 {
207
- struct inode *inode = container_of(head, struct inode, i_rcu);
208209 kmem_cache_free(rpc_inode_cachep, RPC_I(inode));
209
-}
210
-
211
-static void
212
-rpc_destroy_inode(struct inode *inode)
213
-{
214
- call_rcu(&inode->i_rcu, rpc_i_callback);
215210 }
216211
217212 static int
....@@ -483,6 +478,7 @@
483478 inode->i_fop = &simple_dir_operations;
484479 inode->i_op = &simple_dir_inode_operations;
485480 inc_nlink(inode);
481
+ break;
486482 default:
487483 break;
488484 }
....@@ -604,7 +600,9 @@
604600
605601 dget(dentry);
606602 ret = simple_rmdir(dir, dentry);
607
- d_delete(dentry);
603
+ d_drop(dentry);
604
+ if (!ret)
605
+ fsnotify_rmdir(dir, dentry);
608606 dput(dentry);
609607 return ret;
610608 }
....@@ -615,7 +613,9 @@
615613
616614 dget(dentry);
617615 ret = simple_unlink(dir, dentry);
618
- d_delete(dentry);
616
+ d_drop(dentry);
617
+ if (!ret)
618
+ fsnotify_unlink(dir, dentry);
619619 dput(dentry);
620620 return ret;
621621 }
....@@ -1123,7 +1123,7 @@
11231123 */
11241124 static const struct super_operations s_ops = {
11251125 .alloc_inode = rpc_alloc_inode,
1126
- .destroy_inode = rpc_destroy_inode,
1126
+ .free_inode = rpc_free_inode,
11271127 .statfs = simple_statfs,
11281128 };
11291129
....@@ -1266,7 +1266,7 @@
12661266 * that this file will be there and have a certain format.
12671267 */
12681268 static int
1269
-rpc_show_dummy_info(struct seq_file *m, void *v)
1269
+rpc_dummy_info_show(struct seq_file *m, void *v)
12701270 {
12711271 seq_printf(m, "RPC server: %s\n", utsname()->nodename);
12721272 seq_printf(m, "service: foo (1) version 0\n");
....@@ -1275,25 +1275,12 @@
12751275 seq_printf(m, "port: 0\n");
12761276 return 0;
12771277 }
1278
-
1279
-static int
1280
-rpc_dummy_info_open(struct inode *inode, struct file *file)
1281
-{
1282
- return single_open(file, rpc_show_dummy_info, NULL);
1283
-}
1284
-
1285
-static const struct file_operations rpc_dummy_info_operations = {
1286
- .owner = THIS_MODULE,
1287
- .open = rpc_dummy_info_open,
1288
- .read = seq_read,
1289
- .llseek = seq_lseek,
1290
- .release = single_release,
1291
-};
1278
+DEFINE_SHOW_ATTRIBUTE(rpc_dummy_info);
12921279
12931280 static const struct rpc_filelist gssd_dummy_info_file[] = {
12941281 [0] = {
12951282 .name = "info",
1296
- .i_fop = &rpc_dummy_info_operations,
1283
+ .i_fop = &rpc_dummy_info_fops,
12971284 .mode = S_IFREG | 0400,
12981285 },
12991286 };
....@@ -1368,11 +1355,11 @@
13681355 }
13691356
13701357 static int
1371
-rpc_fill_super(struct super_block *sb, void *data, int silent)
1358
+rpc_fill_super(struct super_block *sb, struct fs_context *fc)
13721359 {
13731360 struct inode *inode;
13741361 struct dentry *root, *gssd_dentry;
1375
- struct net *net = get_net(sb->s_fs_info);
1362
+ struct net *net = sb->s_fs_info;
13761363 struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
13771364 int err;
13781365
....@@ -1429,12 +1416,28 @@
14291416 }
14301417 EXPORT_SYMBOL_GPL(gssd_running);
14311418
1432
-static struct dentry *
1433
-rpc_mount(struct file_system_type *fs_type,
1434
- int flags, const char *dev_name, void *data)
1419
+static int rpc_fs_get_tree(struct fs_context *fc)
14351420 {
1436
- struct net *net = current->nsproxy->net_ns;
1437
- return mount_ns(fs_type, flags, data, net, net->user_ns, rpc_fill_super);
1421
+ return get_tree_keyed(fc, rpc_fill_super, get_net(fc->net_ns));
1422
+}
1423
+
1424
+static void rpc_fs_free_fc(struct fs_context *fc)
1425
+{
1426
+ if (fc->s_fs_info)
1427
+ put_net(fc->s_fs_info);
1428
+}
1429
+
1430
+static const struct fs_context_operations rpc_fs_context_ops = {
1431
+ .free = rpc_fs_free_fc,
1432
+ .get_tree = rpc_fs_get_tree,
1433
+};
1434
+
1435
+static int rpc_init_fs_context(struct fs_context *fc)
1436
+{
1437
+ put_user_ns(fc->user_ns);
1438
+ fc->user_ns = get_user_ns(fc->net_ns->user_ns);
1439
+ fc->ops = &rpc_fs_context_ops;
1440
+ return 0;
14381441 }
14391442
14401443 static void rpc_kill_sb(struct super_block *sb)
....@@ -1462,7 +1465,7 @@
14621465 static struct file_system_type rpc_pipe_fs_type = {
14631466 .owner = THIS_MODULE,
14641467 .name = "rpc_pipefs",
1465
- .mount = rpc_mount,
1468
+ .init_fs_context = rpc_init_fs_context,
14661469 .kill_sb = rpc_kill_sb,
14671470 };
14681471 MODULE_ALIAS_FS("rpc_pipefs");
....@@ -1508,6 +1511,6 @@
15081511 void unregister_rpc_pipefs(void)
15091512 {
15101513 rpc_clients_notifier_unregister();
1511
- kmem_cache_destroy(rpc_inode_cachep);
15121514 unregister_filesystem(&rpc_pipe_fs_type);
1515
+ kmem_cache_destroy(rpc_inode_cachep);
15131516 }