Skip to content

Commit c709002

Browse files
committed
Merge branch 'pernet-all-async'
Kirill Tkhai says: ==================== Make pernet_operations always read locked All the pernet_operations are converted, and the last one is in this patchset (nfsd_net_ops acked by J. Bruce Fields). So, it's the time to kill pernet_operations::async field, and make setup_net() and cleanup_net() always require the rwsem only read locked. All further pernet_operations have to be developed to fit this rule. Some of previous patches added a comment to struct pernet_operations about that. Also, this patchset renames net_sem to pernet_ops_rwsem to make the target area of the rwsem is more clear visible, and adds more comments. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents cdcfeb0 + 8518e9b commit c709002

File tree

182 files changed

+38
-266
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

182 files changed

+38
-266
lines changed

drivers/infiniband/core/cma.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4554,7 +4554,6 @@ static struct pernet_operations cma_pernet_operations = {
45544554
.exit = cma_exit_net,
45554555
.id = &cma_pernet_id,
45564556
.size = sizeof(struct cma_pernet),
4557-
.async = true,
45584557
};
45594558

45604559
static int __init cma_init(void)

drivers/net/bonding/bond_main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4791,7 +4791,6 @@ static struct pernet_operations bond_net_ops = {
47914791
.exit = bond_net_exit,
47924792
.id = &bond_net_id,
47934793
.size = sizeof(struct bond_net),
4794-
.async = true,
47954794
};
47964795

47974796
static int __init bonding_init(void)

drivers/net/geneve.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1694,7 +1694,6 @@ static struct pernet_operations geneve_net_ops = {
16941694
.exit_batch = geneve_exit_batch_net,
16951695
.id = &geneve_net_id,
16961696
.size = sizeof(struct geneve_net),
1697-
.async = true,
16981697
};
16991698

17001699
static int __init geneve_init_module(void)

drivers/net/gtp.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1325,7 +1325,6 @@ static struct pernet_operations gtp_net_ops = {
13251325
.exit = gtp_net_exit,
13261326
.id = &gtp_net_id,
13271327
.size = sizeof(struct gtp_net),
1328-
.async = true,
13291328
};
13301329

13311330
static int __init gtp_init(void)

drivers/net/ipvlan/ipvlan_main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,6 @@ static struct pernet_operations ipvlan_net_ops = {
10401040
.id = &ipvlan_netid,
10411041
.size = sizeof(struct ipvlan_netns),
10421042
.exit = ipvlan_ns_exit,
1043-
.async = true,
10441043
};
10451044

10461045
static int __init ipvlan_init_module(void)

drivers/net/loopback.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,5 +230,4 @@ static __net_init int loopback_net_init(struct net *net)
230230
/* Registered in net/core/dev.c */
231231
struct pernet_operations __net_initdata loopback_net_ops = {
232232
.init = loopback_net_init,
233-
.async = true,
234233
};

drivers/net/ppp/ppp_generic.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,6 @@ static struct pernet_operations ppp_net_ops = {
970970
.exit = ppp_exit_net,
971971
.id = &ppp_net_id,
972972
.size = sizeof(struct ppp_net),
973-
.async = true,
974973
};
975974

976975
static int ppp_unit_register(struct ppp *ppp, int unit, bool ifname_is_set)

drivers/net/ppp/pppoe.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,6 @@ static struct pernet_operations pppoe_net_ops = {
11611161
.exit = pppoe_exit_net,
11621162
.id = &pppoe_net_id,
11631163
.size = sizeof(struct pppoe_net),
1164-
.async = true,
11651164
};
11661165

11671166
static int __init pppoe_init(void)

drivers/net/vrf.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1435,7 +1435,6 @@ static struct pernet_operations vrf_net_ops __net_initdata = {
14351435
.init = vrf_netns_init,
14361436
.id = &vrf_net_id,
14371437
.size = sizeof(bool),
1438-
.async = true,
14391438
};
14401439

14411440
static int __init vrf_init_module(void)

drivers/net/vxlan.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3752,7 +3752,6 @@ static struct pernet_operations vxlan_net_ops = {
37523752
.exit_batch = vxlan_exit_batch_net,
37533753
.id = &vxlan_net_id,
37543754
.size = sizeof(struct vxlan_net),
3755-
.async = true,
37563755
};
37573756

37583757
static int __init vxlan_init_module(void)

drivers/net/wireless/mac80211_hwsim.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3542,7 +3542,6 @@ static struct pernet_operations hwsim_net_ops = {
35423542
.exit = hwsim_exit_net,
35433543
.id = &hwsim_net_id,
35443544
.size = sizeof(struct hwsim_net),
3545-
.async = true,
35463545
};
35473546

35483547
static void hwsim_exit_netlink(void)

fs/lockd/svc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,6 @@ static struct pernet_operations lockd_net_ops = {
709709
.exit = lockd_exit_net,
710710
.id = &lockd_net_id,
711711
.size = sizeof(struct lockd_net),
712-
.async = true,
713712
};
714713

715714

fs/nfs/blocklayout/rpc_pipefs.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ static void nfs4blocklayout_net_exit(struct net *net)
261261
static struct pernet_operations nfs4blocklayout_net_ops = {
262262
.init = nfs4blocklayout_net_init,
263263
.exit = nfs4blocklayout_net_exit,
264-
.async = true,
265264
};
266265

267266
int __init bl_init_pipefs(void)

fs/nfs/dns_resolve.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@ static void nfs4_dns_net_exit(struct net *net)
410410
static struct pernet_operations nfs4_dns_resolver_ops = {
411411
.init = nfs4_dns_net_init,
412412
.exit = nfs4_dns_net_exit,
413-
.async = true,
414413
};
415414

416415
static int rpc_pipefs_event(struct notifier_block *nb, unsigned long event,

fs/nfs/inode.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2122,7 +2122,6 @@ static struct pernet_operations nfs_net_ops = {
21222122
.exit = nfs_net_exit,
21232123
.id = &nfs_net_id,
21242124
.size = sizeof(struct nfs_net),
2125-
.async = true,
21262125
};
21272126

21282127
/*

fs/nfs_common/grace.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ static struct pernet_operations grace_net_ops = {
118118
.exit = grace_exit_net,
119119
.id = &grace_net_id,
120120
.size = sizeof(struct list_head),
121-
.async = true,
122121
};
123122

124123
static int __init

fs/proc/proc_net.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ static __net_exit void proc_net_ns_exit(struct net *net)
237237
static struct pernet_operations __net_initdata proc_net_ns_ops = {
238238
.init = proc_net_ns_init,
239239
.exit = proc_net_ns_exit,
240-
.async = true,
241240
};
242241

243242
int __init proc_net_init(void)

include/linux/rtnetlink.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extern int rtnl_is_locked(void);
3636
extern int rtnl_lock_killable(void);
3737

3838
extern wait_queue_head_t netdev_unregistering_wq;
39-
extern struct rw_semaphore net_sem;
39+
extern struct rw_semaphore pernet_ops_rwsem;
4040

4141
#ifdef CONFIG_PROVE_LOCKING
4242
extern bool lockdep_rtnl_is_held(void);

include/net/net_namespace.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ struct net {
6060

6161
struct list_head list; /* list of network namespaces */
6262
struct list_head exit_list; /* To linked to call pernet exit
63-
* methods on dead net (net_sem
64-
* read locked), or to unregister
65-
* pernet ops (net_sem wr locked).
63+
* methods on dead net (
64+
* pernet_ops_rwsem read locked),
65+
* or to unregister pernet ops
66+
* (pernet_ops_rwsem write locked).
6667
*/
6768
struct llist_node cleanup_list; /* namespaces on death row */
6869

@@ -95,8 +96,9 @@ struct net {
9596
/* core fib_rules */
9697
struct list_head rules_ops;
9798

98-
struct list_head fib_notifier_ops; /* protected by net_sem */
99-
99+
struct list_head fib_notifier_ops; /* Populated by
100+
* register_pernet_subsys()
101+
*/
100102
struct net_device *loopback_dev; /* The loopback */
101103
struct netns_core core;
102104
struct netns_mib mib;
@@ -321,6 +323,10 @@ struct pernet_operations {
321323
* have to keep in mind all other pernet_operations and
322324
* to introduce a locking, if they share common resources.
323325
*
326+
* The only time they are called with exclusive lock is
327+
* from register_pernet_subsys(), unregister_pernet_subsys()
328+
* register_pernet_device() and unregister_pernet_device().
329+
*
324330
* Exit methods using blocking RCU primitives, such as
325331
* synchronize_rcu(), should be implemented via exit_batch.
326332
* Then, destruction of a group of net requires single
@@ -333,12 +339,6 @@ struct pernet_operations {
333339
void (*exit_batch)(struct list_head *net_exit_list);
334340
unsigned int *id;
335341
size_t size;
336-
/*
337-
* Indicates above methods are allowed to be executed in parallel
338-
* with methods of any other pernet_operations, i.e. they are not
339-
* need write locked net_sem.
340-
*/
341-
bool async;
342342
};
343343

344344
/*

kernel/audit.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,6 @@ static struct pernet_operations audit_net_ops __net_initdata = {
15261526
.exit = audit_net_exit,
15271527
.id = &audit_net_id,
15281528
.size = sizeof(struct audit_net),
1529-
.async = true,
15301529
};
15311530

15321531
/* Initialize audit support at boot time. */

lib/kobject_uevent.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,6 @@ static void uevent_net_exit(struct net *net)
724724
static struct pernet_operations uevent_net_ops = {
725725
.init = uevent_net_init,
726726
.exit = uevent_net_exit,
727-
.async = true,
728727
};
729728

730729
static int __init kobject_uevent_init(void)

net/8021q/vlan.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,6 @@ static struct pernet_operations vlan_net_ops = {
729729
.exit = vlan_exit_net,
730730
.id = &vlan_net_id,
731731
.size = sizeof(struct vlan_net),
732-
.async = true,
733732
};
734733

735734
static int __init vlan_proto_init(void)

net/bridge/br.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ static void __net_exit br_net_exit(struct net *net)
188188

189189
static struct pernet_operations br_net_ops = {
190190
.exit = br_net_exit,
191-
.async = true,
192191
};
193192

194193
static const struct stp_proto br_stp_proto = {

net/bridge/br_netfilter_hooks.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,6 @@ static struct pernet_operations brnf_net_ops __read_mostly = {
969969
.exit = brnf_exit_net,
970970
.id = &brnf_net_id,
971971
.size = sizeof(struct brnf_net),
972-
.async = true,
973972
};
974973

975974
static struct notifier_block brnf_notifier __read_mostly = {

net/bridge/netfilter/ebtable_broute.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ static void __net_exit broute_net_exit(struct net *net)
7777
static struct pernet_operations broute_net_ops = {
7878
.init = broute_net_init,
7979
.exit = broute_net_exit,
80-
.async = true,
8180
};
8281

8382
static int __init ebtable_broute_init(void)

net/bridge/netfilter/ebtable_filter.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ static void __net_exit frame_filter_net_exit(struct net *net)
105105
static struct pernet_operations frame_filter_net_ops = {
106106
.init = frame_filter_net_init,
107107
.exit = frame_filter_net_exit,
108-
.async = true,
109108
};
110109

111110
static int __init ebtable_filter_init(void)

net/bridge/netfilter/ebtable_nat.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ static void __net_exit frame_nat_net_exit(struct net *net)
105105
static struct pernet_operations frame_nat_net_ops = {
106106
.init = frame_nat_net_init,
107107
.exit = frame_nat_net_exit,
108-
.async = true,
109108
};
110109

111110
static int __init ebtable_nat_init(void)

net/bridge/netfilter/nf_log_bridge.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ static void __net_exit nf_log_bridge_net_exit(struct net *net)
4848
static struct pernet_operations nf_log_bridge_net_ops = {
4949
.init = nf_log_bridge_net_init,
5050
.exit = nf_log_bridge_net_exit,
51-
.async = true,
5251
};
5352

5453
static int __init nf_log_bridge_init(void)

net/caif/caif_dev.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,6 @@ static struct pernet_operations caif_net_ops = {
544544
.exit = caif_exit_net,
545545
.id = &caif_net_id,
546546
.size = sizeof(struct caif_net),
547-
.async = true,
548547
};
549548

550549
/* Initialize Caif devices list */

net/can/af_can.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,6 @@ static struct notifier_block can_netdev_notifier __read_mostly = {
954954
static struct pernet_operations can_pernet_ops __read_mostly = {
955955
.init = can_pernet_init,
956956
.exit = can_pernet_exit,
957-
.async = true,
958957
};
959958

960959
static __init int can_init(void)

net/can/bcm.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1717,7 +1717,6 @@ static void canbcm_pernet_exit(struct net *net)
17171717
static struct pernet_operations canbcm_pernet_ops __read_mostly = {
17181718
.init = canbcm_pernet_init,
17191719
.exit = canbcm_pernet_exit,
1720-
.async = true,
17211720
};
17221721

17231722
static int __init bcm_module_init(void)

net/can/gw.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,6 @@ static void __net_exit cangw_pernet_exit(struct net *net)
10101010
static struct pernet_operations cangw_pernet_ops = {
10111011
.init = cangw_pernet_init,
10121012
.exit = cangw_pernet_exit,
1013-
.async = true,
10141013
};
10151014

10161015
static __init int cgw_module_init(void)

net/core/dev.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8883,7 +8883,6 @@ static void __net_exit netdev_exit(struct net *net)
88838883
static struct pernet_operations __net_initdata netdev_net_ops = {
88848884
.init = netdev_init,
88858885
.exit = netdev_exit,
8886-
.async = true,
88878886
};
88888887

88898888
static void __net_exit default_device_exit(struct net *net)
@@ -8984,7 +8983,6 @@ static void __net_exit default_device_exit_batch(struct list_head *net_list)
89848983
static struct pernet_operations __net_initdata default_device_ops = {
89858984
.exit = default_device_exit,
89868985
.exit_batch = default_device_exit_batch,
8987-
.async = true,
89888986
};
89898987

89908988
/*

net/core/fib_notifier.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ static void __net_exit fib_notifier_net_exit(struct net *net)
171171
static struct pernet_operations fib_notifier_net_ops = {
172172
.init = fib_notifier_net_init,
173173
.exit = fib_notifier_net_exit,
174-
.async = true,
175174
};
176175

177176
static int __init fib_notifier_init(void)

net/core/fib_rules.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,6 @@ static void __net_exit fib_rules_net_exit(struct net *net)
11301130
static struct pernet_operations fib_rules_net_ops = {
11311131
.init = fib_rules_net_init,
11321132
.exit = fib_rules_net_exit,
1133-
.async = true,
11341133
};
11351134

11361135
static int __init fib_rules_init(void)

net/core/net-procfs.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,6 @@ static void __net_exit dev_proc_net_exit(struct net *net)
349349
static struct pernet_operations __net_initdata dev_proc_ops = {
350350
.init = dev_proc_net_init,
351351
.exit = dev_proc_net_exit,
352-
.async = true,
353352
};
354353

355354
static int dev_mc_seq_show(struct seq_file *seq, void *v)
@@ -406,7 +405,6 @@ static void __net_exit dev_mc_net_exit(struct net *net)
406405
static struct pernet_operations __net_initdata dev_mc_net_ops = {
407406
.init = dev_mc_net_init,
408407
.exit = dev_mc_net_exit,
409-
.async = true,
410408
};
411409

412410
int __init dev_proc_init(void)

0 commit comments

Comments
 (0)