mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-02 22:56:42 +07:00
01b8b07a5d
sem_exit_ns(), msg_exit_ns() and shm_exit_ns() are all called when an ipc_namespace is released to free all ipcs of each type. But in fact, they do the same thing: they loop around all ipcs to free them individually by calling a specific routine. This patch proposes to consolidate this by introducing a common function, free_ipcs(), that do the job. The specific routine to call on each individual ipcs is passed as parameter. For this, these ipc-specific 'free' routines are reworked to take a generic 'struct ipc_perm' as parameter. Signed-off-by: Pierre Peiffer <pierre.peiffer@bull.net> Cc: Cedric Le Goater <clg@fr.ibm.com> Cc: Pavel Emelyanov <xemul@openvz.org> Cc: Nadia Derbey <Nadia.Derbey@bull.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
82 lines
1.5 KiB
C
82 lines
1.5 KiB
C
#ifndef __IPC_NAMESPACE_H__
|
|
#define __IPC_NAMESPACE_H__
|
|
|
|
#include <linux/err.h>
|
|
#include <linux/idr.h>
|
|
#include <linux/rwsem.h>
|
|
|
|
struct ipc_ids {
|
|
int in_use;
|
|
unsigned short seq;
|
|
unsigned short seq_max;
|
|
struct rw_semaphore rw_mutex;
|
|
struct idr ipcs_idr;
|
|
};
|
|
|
|
struct ipc_namespace {
|
|
struct kref kref;
|
|
struct ipc_ids ids[3];
|
|
|
|
int sem_ctls[4];
|
|
int used_sems;
|
|
|
|
int msg_ctlmax;
|
|
int msg_ctlmnb;
|
|
int msg_ctlmni;
|
|
atomic_t msg_bytes;
|
|
atomic_t msg_hdrs;
|
|
|
|
size_t shm_ctlmax;
|
|
size_t shm_ctlall;
|
|
int shm_ctlmni;
|
|
int shm_tot;
|
|
};
|
|
|
|
extern struct ipc_namespace init_ipc_ns;
|
|
|
|
#ifdef CONFIG_SYSVIPC
|
|
#define INIT_IPC_NS(ns) .ns = &init_ipc_ns,
|
|
#else
|
|
#define INIT_IPC_NS(ns)
|
|
#endif
|
|
|
|
#if defined(CONFIG_SYSVIPC) && defined(CONFIG_IPC_NS)
|
|
extern void free_ipc_ns(struct kref *kref);
|
|
extern struct ipc_namespace *copy_ipcs(unsigned long flags,
|
|
struct ipc_namespace *ns);
|
|
extern void free_ipcs(struct ipc_namespace *ns, struct ipc_ids *ids,
|
|
void (*free)(struct ipc_namespace *,
|
|
struct kern_ipc_perm *));
|
|
|
|
static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
|
|
{
|
|
if (ns)
|
|
kref_get(&ns->kref);
|
|
return ns;
|
|
}
|
|
|
|
static inline void put_ipc_ns(struct ipc_namespace *ns)
|
|
{
|
|
kref_put(&ns->kref, free_ipc_ns);
|
|
}
|
|
#else
|
|
static inline struct ipc_namespace *copy_ipcs(unsigned long flags,
|
|
struct ipc_namespace *ns)
|
|
{
|
|
if (flags & CLONE_NEWIPC)
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
return ns;
|
|
}
|
|
|
|
static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
|
|
{
|
|
return ns;
|
|
}
|
|
|
|
static inline void put_ipc_ns(struct ipc_namespace *ns)
|
|
{
|
|
}
|
|
#endif
|
|
#endif
|