Skip to content

Commit

Permalink
Merge branch 'pernet-all-async'
Browse files Browse the repository at this point in the history
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 <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Mar 27, 2018
2 parents cdcfeb0 + 8518e9b commit c709002
Show file tree
Hide file tree
Showing 182 changed files with 38 additions and 266 deletions.
1 change: 0 additions & 1 deletion drivers/infiniband/core/cma.c
Original file line number Diff line number Diff line change
Expand Up @@ -4554,7 +4554,6 @@ static struct pernet_operations cma_pernet_operations = {
.exit = cma_exit_net,
.id = &cma_pernet_id,
.size = sizeof(struct cma_pernet),
.async = true,
};

static int __init cma_init(void)
Expand Down
1 change: 0 additions & 1 deletion drivers/net/bonding/bond_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4791,7 +4791,6 @@ static struct pernet_operations bond_net_ops = {
.exit = bond_net_exit,
.id = &bond_net_id,
.size = sizeof(struct bond_net),
.async = true,
};

static int __init bonding_init(void)
Expand Down
1 change: 0 additions & 1 deletion drivers/net/geneve.c
Original file line number Diff line number Diff line change
Expand Up @@ -1694,7 +1694,6 @@ static struct pernet_operations geneve_net_ops = {
.exit_batch = geneve_exit_batch_net,
.id = &geneve_net_id,
.size = sizeof(struct geneve_net),
.async = true,
};

static int __init geneve_init_module(void)
Expand Down
1 change: 0 additions & 1 deletion drivers/net/gtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,6 @@ static struct pernet_operations gtp_net_ops = {
.exit = gtp_net_exit,
.id = &gtp_net_id,
.size = sizeof(struct gtp_net),
.async = true,
};

static int __init gtp_init(void)
Expand Down
1 change: 0 additions & 1 deletion drivers/net/ipvlan/ipvlan_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,6 @@ static struct pernet_operations ipvlan_net_ops = {
.id = &ipvlan_netid,
.size = sizeof(struct ipvlan_netns),
.exit = ipvlan_ns_exit,
.async = true,
};

static int __init ipvlan_init_module(void)
Expand Down
1 change: 0 additions & 1 deletion drivers/net/loopback.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,5 +230,4 @@ static __net_init int loopback_net_init(struct net *net)
/* Registered in net/core/dev.c */
struct pernet_operations __net_initdata loopback_net_ops = {
.init = loopback_net_init,
.async = true,
};
1 change: 0 additions & 1 deletion drivers/net/ppp/ppp_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,6 @@ static struct pernet_operations ppp_net_ops = {
.exit = ppp_exit_net,
.id = &ppp_net_id,
.size = sizeof(struct ppp_net),
.async = true,
};

static int ppp_unit_register(struct ppp *ppp, int unit, bool ifname_is_set)
Expand Down
1 change: 0 additions & 1 deletion drivers/net/ppp/pppoe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,6 @@ static struct pernet_operations pppoe_net_ops = {
.exit = pppoe_exit_net,
.id = &pppoe_net_id,
.size = sizeof(struct pppoe_net),
.async = true,
};

static int __init pppoe_init(void)
Expand Down
1 change: 0 additions & 1 deletion drivers/net/vrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1435,7 +1435,6 @@ static struct pernet_operations vrf_net_ops __net_initdata = {
.init = vrf_netns_init,
.id = &vrf_net_id,
.size = sizeof(bool),
.async = true,
};

static int __init vrf_init_module(void)
Expand Down
1 change: 0 additions & 1 deletion drivers/net/vxlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -3752,7 +3752,6 @@ static struct pernet_operations vxlan_net_ops = {
.exit_batch = vxlan_exit_batch_net,
.id = &vxlan_net_id,
.size = sizeof(struct vxlan_net),
.async = true,
};

static int __init vxlan_init_module(void)
Expand Down
1 change: 0 additions & 1 deletion drivers/net/wireless/mac80211_hwsim.c
Original file line number Diff line number Diff line change
Expand Up @@ -3542,7 +3542,6 @@ static struct pernet_operations hwsim_net_ops = {
.exit = hwsim_exit_net,
.id = &hwsim_net_id,
.size = sizeof(struct hwsim_net),
.async = true,
};

static void hwsim_exit_netlink(void)
Expand Down
1 change: 0 additions & 1 deletion fs/lockd/svc.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,6 @@ static struct pernet_operations lockd_net_ops = {
.exit = lockd_exit_net,
.id = &lockd_net_id,
.size = sizeof(struct lockd_net),
.async = true,
};


Expand Down
1 change: 0 additions & 1 deletion fs/nfs/blocklayout/rpc_pipefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ static void nfs4blocklayout_net_exit(struct net *net)
static struct pernet_operations nfs4blocklayout_net_ops = {
.init = nfs4blocklayout_net_init,
.exit = nfs4blocklayout_net_exit,
.async = true,
};

int __init bl_init_pipefs(void)
Expand Down
1 change: 0 additions & 1 deletion fs/nfs/dns_resolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,6 @@ static void nfs4_dns_net_exit(struct net *net)
static struct pernet_operations nfs4_dns_resolver_ops = {
.init = nfs4_dns_net_init,
.exit = nfs4_dns_net_exit,
.async = true,
};

static int rpc_pipefs_event(struct notifier_block *nb, unsigned long event,
Expand Down
1 change: 0 additions & 1 deletion fs/nfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -2122,7 +2122,6 @@ static struct pernet_operations nfs_net_ops = {
.exit = nfs_net_exit,
.id = &nfs_net_id,
.size = sizeof(struct nfs_net),
.async = true,
};

/*
Expand Down
1 change: 0 additions & 1 deletion fs/nfs_common/grace.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ static struct pernet_operations grace_net_ops = {
.exit = grace_exit_net,
.id = &grace_net_id,
.size = sizeof(struct list_head),
.async = true,
};

static int __init
Expand Down
1 change: 0 additions & 1 deletion fs/proc/proc_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ static __net_exit void proc_net_ns_exit(struct net *net)
static struct pernet_operations __net_initdata proc_net_ns_ops = {
.init = proc_net_ns_init,
.exit = proc_net_ns_exit,
.async = true,
};

int __init proc_net_init(void)
Expand Down
2 changes: 1 addition & 1 deletion include/linux/rtnetlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extern int rtnl_is_locked(void);
extern int rtnl_lock_killable(void);

extern wait_queue_head_t netdev_unregistering_wq;
extern struct rw_semaphore net_sem;
extern struct rw_semaphore pernet_ops_rwsem;

#ifdef CONFIG_PROVE_LOCKING
extern bool lockdep_rtnl_is_held(void);
Expand Down
22 changes: 11 additions & 11 deletions include/net/net_namespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ struct net {

struct list_head list; /* list of network namespaces */
struct list_head exit_list; /* To linked to call pernet exit
* methods on dead net (net_sem
* read locked), or to unregister
* pernet ops (net_sem wr locked).
* methods on dead net (
* pernet_ops_rwsem read locked),
* or to unregister pernet ops
* (pernet_ops_rwsem write locked).
*/
struct llist_node cleanup_list; /* namespaces on death row */

Expand Down Expand Up @@ -95,8 +96,9 @@ struct net {
/* core fib_rules */
struct list_head rules_ops;

struct list_head fib_notifier_ops; /* protected by net_sem */

struct list_head fib_notifier_ops; /* Populated by
* register_pernet_subsys()
*/
struct net_device *loopback_dev; /* The loopback */
struct netns_core core;
struct netns_mib mib;
Expand Down Expand Up @@ -321,6 +323,10 @@ struct pernet_operations {
* have to keep in mind all other pernet_operations and
* to introduce a locking, if they share common resources.
*
* The only time they are called with exclusive lock is
* from register_pernet_subsys(), unregister_pernet_subsys()
* register_pernet_device() and unregister_pernet_device().
*
* Exit methods using blocking RCU primitives, such as
* synchronize_rcu(), should be implemented via exit_batch.
* Then, destruction of a group of net requires single
Expand All @@ -333,12 +339,6 @@ struct pernet_operations {
void (*exit_batch)(struct list_head *net_exit_list);
unsigned int *id;
size_t size;
/*
* Indicates above methods are allowed to be executed in parallel
* with methods of any other pernet_operations, i.e. they are not
* need write locked net_sem.
*/
bool async;
};

/*
Expand Down
1 change: 0 additions & 1 deletion kernel/audit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1526,7 +1526,6 @@ static struct pernet_operations audit_net_ops __net_initdata = {
.exit = audit_net_exit,
.id = &audit_net_id,
.size = sizeof(struct audit_net),
.async = true,
};

/* Initialize audit support at boot time. */
Expand Down
1 change: 0 additions & 1 deletion lib/kobject_uevent.c
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,6 @@ static void uevent_net_exit(struct net *net)
static struct pernet_operations uevent_net_ops = {
.init = uevent_net_init,
.exit = uevent_net_exit,
.async = true,
};

static int __init kobject_uevent_init(void)
Expand Down
1 change: 0 additions & 1 deletion net/8021q/vlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,6 @@ static struct pernet_operations vlan_net_ops = {
.exit = vlan_exit_net,
.id = &vlan_net_id,
.size = sizeof(struct vlan_net),
.async = true,
};

static int __init vlan_proto_init(void)
Expand Down
1 change: 0 additions & 1 deletion net/bridge/br.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ static void __net_exit br_net_exit(struct net *net)

static struct pernet_operations br_net_ops = {
.exit = br_net_exit,
.async = true,
};

static const struct stp_proto br_stp_proto = {
Expand Down
1 change: 0 additions & 1 deletion net/bridge/br_netfilter_hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,6 @@ static struct pernet_operations brnf_net_ops __read_mostly = {
.exit = brnf_exit_net,
.id = &brnf_net_id,
.size = sizeof(struct brnf_net),
.async = true,
};

static struct notifier_block brnf_notifier __read_mostly = {
Expand Down
1 change: 0 additions & 1 deletion net/bridge/netfilter/ebtable_broute.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ static void __net_exit broute_net_exit(struct net *net)
static struct pernet_operations broute_net_ops = {
.init = broute_net_init,
.exit = broute_net_exit,
.async = true,
};

static int __init ebtable_broute_init(void)
Expand Down
1 change: 0 additions & 1 deletion net/bridge/netfilter/ebtable_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ static void __net_exit frame_filter_net_exit(struct net *net)
static struct pernet_operations frame_filter_net_ops = {
.init = frame_filter_net_init,
.exit = frame_filter_net_exit,
.async = true,
};

static int __init ebtable_filter_init(void)
Expand Down
1 change: 0 additions & 1 deletion net/bridge/netfilter/ebtable_nat.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ static void __net_exit frame_nat_net_exit(struct net *net)
static struct pernet_operations frame_nat_net_ops = {
.init = frame_nat_net_init,
.exit = frame_nat_net_exit,
.async = true,
};

static int __init ebtable_nat_init(void)
Expand Down
1 change: 0 additions & 1 deletion net/bridge/netfilter/nf_log_bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ static void __net_exit nf_log_bridge_net_exit(struct net *net)
static struct pernet_operations nf_log_bridge_net_ops = {
.init = nf_log_bridge_net_init,
.exit = nf_log_bridge_net_exit,
.async = true,
};

static int __init nf_log_bridge_init(void)
Expand Down
1 change: 0 additions & 1 deletion net/caif/caif_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,6 @@ static struct pernet_operations caif_net_ops = {
.exit = caif_exit_net,
.id = &caif_net_id,
.size = sizeof(struct caif_net),
.async = true,
};

/* Initialize Caif devices list */
Expand Down
1 change: 0 additions & 1 deletion net/can/af_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,6 @@ static struct notifier_block can_netdev_notifier __read_mostly = {
static struct pernet_operations can_pernet_ops __read_mostly = {
.init = can_pernet_init,
.exit = can_pernet_exit,
.async = true,
};

static __init int can_init(void)
Expand Down
1 change: 0 additions & 1 deletion net/can/bcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1717,7 +1717,6 @@ static void canbcm_pernet_exit(struct net *net)
static struct pernet_operations canbcm_pernet_ops __read_mostly = {
.init = canbcm_pernet_init,
.exit = canbcm_pernet_exit,
.async = true,
};

static int __init bcm_module_init(void)
Expand Down
1 change: 0 additions & 1 deletion net/can/gw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,6 @@ static void __net_exit cangw_pernet_exit(struct net *net)
static struct pernet_operations cangw_pernet_ops = {
.init = cangw_pernet_init,
.exit = cangw_pernet_exit,
.async = true,
};

static __init int cgw_module_init(void)
Expand Down
2 changes: 0 additions & 2 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -8883,7 +8883,6 @@ static void __net_exit netdev_exit(struct net *net)
static struct pernet_operations __net_initdata netdev_net_ops = {
.init = netdev_init,
.exit = netdev_exit,
.async = true,
};

static void __net_exit default_device_exit(struct net *net)
Expand Down Expand Up @@ -8984,7 +8983,6 @@ static void __net_exit default_device_exit_batch(struct list_head *net_list)
static struct pernet_operations __net_initdata default_device_ops = {
.exit = default_device_exit,
.exit_batch = default_device_exit_batch,
.async = true,
};

/*
Expand Down
1 change: 0 additions & 1 deletion net/core/fib_notifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ static void __net_exit fib_notifier_net_exit(struct net *net)
static struct pernet_operations fib_notifier_net_ops = {
.init = fib_notifier_net_init,
.exit = fib_notifier_net_exit,
.async = true,
};

static int __init fib_notifier_init(void)
Expand Down
1 change: 0 additions & 1 deletion net/core/fib_rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,6 @@ static void __net_exit fib_rules_net_exit(struct net *net)
static struct pernet_operations fib_rules_net_ops = {
.init = fib_rules_net_init,
.exit = fib_rules_net_exit,
.async = true,
};

static int __init fib_rules_init(void)
Expand Down
2 changes: 0 additions & 2 deletions net/core/net-procfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@ static void __net_exit dev_proc_net_exit(struct net *net)
static struct pernet_operations __net_initdata dev_proc_ops = {
.init = dev_proc_net_init,
.exit = dev_proc_net_exit,
.async = true,
};

static int dev_mc_seq_show(struct seq_file *seq, void *v)
Expand Down Expand Up @@ -406,7 +405,6 @@ static void __net_exit dev_mc_net_exit(struct net *net)
static struct pernet_operations __net_initdata dev_mc_net_ops = {
.init = dev_mc_net_init,
.exit = dev_mc_net_exit,
.async = true,
};

int __init dev_proc_init(void)
Expand Down
Loading

0 comments on commit c709002

Please sign in to comment.