• Home
  • Raw
  • Download

Lines Matching refs:ns

49 	struct ipc_namespace *ns;  member
59 #define shm_ids(ns) ((ns)->ids[IPC_SHM_IDS]) argument
67 static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
72 void shm_init_ns(struct ipc_namespace *ns) in shm_init_ns() argument
74 ns->shm_ctlmax = SHMMAX; in shm_init_ns()
75 ns->shm_ctlall = SHMALL; in shm_init_ns()
76 ns->shm_ctlmni = SHMMNI; in shm_init_ns()
77 ns->shm_rmid_forced = 0; in shm_init_ns()
78 ns->shm_tot = 0; in shm_init_ns()
79 ipc_init_ids(&shm_ids(ns)); in shm_init_ns()
86 static void do_shm_rmid(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp) in do_shm_rmid() argument
97 shm_destroy(ns, shp); in do_shm_rmid()
101 void shm_exit_ns(struct ipc_namespace *ns) in shm_exit_ns() argument
103 free_ipcs(ns, &shm_ids(ns), do_shm_rmid); in shm_exit_ns()
104 idr_destroy(&ns->ids[IPC_SHM_IDS].ipcs_idr); in shm_exit_ns()
131 static inline struct shmid_kernel *shm_lock(struct ipc_namespace *ns, int id) in shm_lock() argument
133 struct kern_ipc_perm *ipcp = ipc_lock(&shm_ids(ns), id); in shm_lock()
147 static inline struct shmid_kernel *shm_lock_check(struct ipc_namespace *ns, in shm_lock_check() argument
150 struct kern_ipc_perm *ipcp = ipc_lock_check(&shm_ids(ns), id); in shm_lock_check()
167 static inline void shm_rmid(struct ipc_namespace *ns, struct shmid_kernel *s) in shm_rmid() argument
169 ipc_rmid(&shm_ids(ns), &s->shm_perm); in shm_rmid()
180 shp = shm_lock(sfd->ns, sfd->id); in shm_open()
197 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp) in shm_destroy() argument
199 ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT; in shm_destroy()
200 shm_rmid(ns, shp); in shm_destroy()
221 static bool shm_may_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp) in shm_may_destroy() argument
224 (ns->shm_rmid_forced || in shm_may_destroy()
239 struct ipc_namespace *ns = sfd->ns; in shm_close() local
241 down_write(&shm_ids(ns).rw_mutex); in shm_close()
243 shp = shm_lock(ns, sfd->id); in shm_close()
248 if (shm_may_destroy(ns, shp)) in shm_close()
249 shm_destroy(ns, shp); in shm_close()
252 up_write(&shm_ids(ns).rw_mutex); in shm_close()
258 struct ipc_namespace *ns = data; in shm_try_destroy_current() local
276 if (!ns->shm_rmid_forced) in shm_try_destroy_current()
279 if (shm_may_destroy(ns, shp)) { in shm_try_destroy_current()
281 shm_destroy(ns, shp); in shm_try_destroy_current()
289 struct ipc_namespace *ns = data; in shm_try_destroy_orphaned() local
302 if (shm_may_destroy(ns, shp)) { in shm_try_destroy_orphaned()
304 shm_destroy(ns, shp); in shm_try_destroy_orphaned()
309 void shm_destroy_orphaned(struct ipc_namespace *ns) in shm_destroy_orphaned() argument
311 down_write(&shm_ids(ns).rw_mutex); in shm_destroy_orphaned()
312 if (shm_ids(ns).in_use) in shm_destroy_orphaned()
313 idr_for_each(&shm_ids(ns).ipcs_idr, &shm_try_destroy_orphaned, ns); in shm_destroy_orphaned()
314 up_write(&shm_ids(ns).rw_mutex); in shm_destroy_orphaned()
320 struct ipc_namespace *ns = task->nsproxy->ipc_ns; in exit_shm() local
322 if (shm_ids(ns).in_use == 0) in exit_shm()
326 down_write(&shm_ids(ns).rw_mutex); in exit_shm()
327 if (shm_ids(ns).in_use) in exit_shm()
328 idr_for_each(&shm_ids(ns).ipcs_idr, &shm_try_destroy_current, ns); in exit_shm()
329 up_write(&shm_ids(ns).rw_mutex); in exit_shm()
389 put_ipc_ns(sfd->ns); in shm_release()
466 static int newseg(struct ipc_namespace *ns, struct ipc_params *params) in newseg() argument
479 if (size < SHMMIN || size > ns->shm_ctlmax) in newseg()
482 if (ns->shm_tot + numpages > ns->shm_ctlall) in newseg()
541 id = ipc_addid(&shm_ids(ns), &shp->shm_perm, ns->shm_ctlmni); in newseg()
553 ns->shm_tot += numpages; in newseg()
595 struct ipc_namespace *ns; in SYSCALL_DEFINE3() local
599 ns = current->nsproxy->ipc_ns; in SYSCALL_DEFINE3()
609 return ipcget(ns, &shm_ids(ns), &shm_ops, &shm_params); in SYSCALL_DEFINE3()
721 static void shm_get_stat(struct ipc_namespace *ns, unsigned long *rss, in shm_get_stat() argument
730 in_use = shm_ids(ns).in_use; in shm_get_stat()
736 ipc = idr_find(&shm_ids(ns).ipcs_idr, next_id); in shm_get_stat()
752 static int shmctl_down(struct ipc_namespace *ns, int shmid, int cmd, in shmctl_down() argument
765 ipcp = ipcctl_pre_down(ns, &shm_ids(ns), shmid, cmd, in shmctl_down()
777 do_shm_rmid(ns, ipcp); in shmctl_down()
791 up_write(&shm_ids(ns).rw_mutex); in shmctl_down()
799 struct ipc_namespace *ns; in SYSCALL_DEFINE3() local
807 ns = current->nsproxy->ipc_ns; in SYSCALL_DEFINE3()
819 shminfo.shmmni = shminfo.shmseg = ns->shm_ctlmni; in SYSCALL_DEFINE3()
820 shminfo.shmmax = ns->shm_ctlmax; in SYSCALL_DEFINE3()
821 shminfo.shmall = ns->shm_ctlall; in SYSCALL_DEFINE3()
827 down_read(&shm_ids(ns).rw_mutex); in SYSCALL_DEFINE3()
828 err = ipc_get_maxid(&shm_ids(ns)); in SYSCALL_DEFINE3()
829 up_read(&shm_ids(ns).rw_mutex); in SYSCALL_DEFINE3()
844 down_read(&shm_ids(ns).rw_mutex); in SYSCALL_DEFINE3()
845 shm_info.used_ids = shm_ids(ns).in_use; in SYSCALL_DEFINE3()
846 shm_get_stat (ns, &shm_info.shm_rss, &shm_info.shm_swp); in SYSCALL_DEFINE3()
847 shm_info.shm_tot = ns->shm_tot; in SYSCALL_DEFINE3()
850 err = ipc_get_maxid(&shm_ids(ns)); in SYSCALL_DEFINE3()
851 up_read(&shm_ids(ns).rw_mutex); in SYSCALL_DEFINE3()
867 shp = shm_lock(ns, shmid); in SYSCALL_DEFINE3()
874 shp = shm_lock_check(ns, shmid); in SYSCALL_DEFINE3()
882 if (ipcperms(ns, &shp->shm_perm, S_IRUGO)) in SYSCALL_DEFINE3()
908 shp = shm_lock_check(ns, shmid); in SYSCALL_DEFINE3()
916 if (!ns_capable(ns->user_ns, CAP_IPC_LOCK)) { in SYSCALL_DEFINE3()
958 err = shmctl_down(ns, shmid, cmd, buf, version); in SYSCALL_DEFINE3()
988 struct ipc_namespace *ns; in do_shmat() local
1033 ns = current->nsproxy->ipc_ns; in do_shmat()
1034 shp = shm_lock_check(ns, shmid); in do_shmat()
1041 if (ipcperms(ns, &shp->shm_perm, acc_mode)) in do_shmat()
1070 sfd->ns = get_ipc_ns(ns); in do_shmat()
1106 down_write(&shm_ids(ns).rw_mutex); in do_shmat()
1107 shp = shm_lock(ns, shmid); in do_shmat()
1110 if (shm_may_destroy(ns, shp)) in do_shmat()
1111 shm_destroy(ns, shp); in do_shmat()
1114 up_write(&shm_ids(ns).rw_mutex); in do_shmat()