Subject: Re: ipc errors/Linux Emulation NetBSD-3BETA using Oracle
To: , <christos@astron.com>
From: GNMJLR@terra.es <GNMJLR@terra.es>
List: tech-kern
Date: 11/09/2005 22:03:55
------=_Part_4620_16570874.1131570235363
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

I have resolved the outstanding problem, and I can create a Oracle=20
database
with Oracle version 9.2.0.4

Chuq, I have modified your patch=20
for change IPC_STAT and IPC_SHM
when it is used with IPC_64. They wait=20
to receive a diferent shmid_id structure, and
ipc_perms. I have called=20
them shmid64_id and ipc64_perms.

I receive a lot of:=20
194 oracle  =20
RET   ipc -1 errno -4 Interrupted system call
   194 oracle   PSIG =20
SIGALRM caught handler=3D0xbd784c70 mask=3D(33): code=3DSI_TIMER+

I have to=20
study if it is normal or not.


Can this patch be added to cvs, and=20
netbsd-3, before is it released?
It is not harmfull, because it doesn't=20
change the existing system calls.
I have created this patch against=20
netbsd-3, but I think that the afected
files are the same in HEAD.

I=20
will leave logs of ktrace, and other logs in: http://n0se.sharknet.nu=20
in a few minutes.




The output screen of the startup and creation of=20
the database:

-bash-2.05b$ sqlplus /nolog

SQL*Plus: Release 9.2.0.4.0=20
- Production on Wed Nov 9 22:27:11 2005

Copyright (c) 1982, 2002,=20
Oracle Corporation.  All rights reserved.

SQL> connect / as sysdba
Connected to an idle instance.
SQL> startup nomount
ORACLE instance=20
started.

Total System Global Area   42742804 bytes
Fixed=20
Size                   451604 bytes
Variable Size              41943040=20
bytes
Database Buffers             204800 bytes
Redo=20
Buffers                 143360 bytes
SQL> create database;

Database=20
created.

SQL> quit
Disconnected from Oracle9i Enterprise Edition=20
Release 9.2.0.4.0 - Production
With the Partitioning and Oracle Data=20
Mining options
JServer Release 9.2.0.4.0 - Production
-bash-2.05b$=20


Prueba el Nuevo Correo Terra; Seguro, R=C3=A1pido, Fiable.

------=_Part_4620_16570874.1131570235363
Content-Type: APPLICATION/OCTET-STREAM; name=diff.linux-shm.6
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=diff.linux-shm.6; size=11167

Index: src/sys/compat/linux/common/linux_ipc.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_ipc.c,v
retrieving revision 1.31
diff -u -r1.31 linux_ipc.c
--- compat/linux/common/linux_ipc.c	26 Feb 2005 23:10:19 -0000	1.31
+++ compat/linux/common/linux_ipc.c	9 Nov 2005 20:06:45 -0000
@@ -110,6 +110,20 @@
 }
 
 void
+linux_to_bsd_ipc64_perm(lpp, bpp)
+	struct linux_ipc64_perm *lpp;
+	struct ipc_perm *bpp;
+{
+	bpp->_key = lpp->l_key;
+	bpp->uid = lpp->l_uid;
+	bpp->gid = lpp->l_gid;
+	bpp->cuid = lpp->l_cuid;
+	bpp->cgid = lpp->l_cgid;
+	bpp->mode = lpp->l_mode;
+	bpp->_seq = lpp->l_seq;
+}
+
+void
 bsd_to_linux_ipc_perm(bpp, lpp)
 	struct ipc_perm *bpp;
 	struct linux_ipc_perm *lpp;
@@ -123,6 +137,21 @@
 	lpp->l_mode = bpp->mode;
 	lpp->l_seq = bpp->_seq;
 }
+
+void
+bsd_to_linux_ipc64_perm(bpp, lpp)
+	struct ipc_perm *bpp;
+	struct linux_ipc64_perm *lpp;
+{
+	lpp->l_key = bpp->_key;
+	lpp->l_uid = bpp->uid;
+	lpp->l_gid = bpp->gid;
+	lpp->l_cuid = bpp->cuid;
+	lpp->l_cgid = bpp->cgid;
+	lpp->l_mode = bpp->mode;
+	lpp->l_seq = bpp->_seq;
+}
+
 #endif
 
 #ifdef SYSVSEM
@@ -353,6 +382,7 @@
 #endif /* SYSVMSG */
 
 #ifdef SYSVSHM
+extern int shm_nused;
 /*
  * shmget(2). Just make sure the Linux-compatible shmat() semantics
  * is enabled for the segment, so that shmat() succeeds even when
@@ -430,6 +460,23 @@
 }
 
 void
+linux_to_bsd_shmid64_ds(lsp, bsp)
+	struct linux_shmid64_ds *lsp;
+	struct shmid_ds *bsp;
+{
+
+	linux_to_bsd_ipc64_perm(&lsp->l_shm_perm, &bsp->shm_perm);
+	bsp->shm_segsz = lsp->l_shm_segsz;
+	bsp->shm_lpid = lsp->l_shm_lpid;
+	bsp->shm_cpid = lsp->l_shm_cpid;
+	bsp->shm_nattch = lsp->l_shm_nattch;
+	bsp->shm_atime = lsp->l_shm_atime;
+	bsp->shm_dtime = lsp->l_shm_dtime;
+	bsp->shm_ctime = lsp->l_shm_ctime;
+	bsp->_shm_internal = (void*)lsp->l___unused5;	/* XXX Oh well. */
+}
+
+void
 bsd_to_linux_shmid_ds(bsp, lsp)
 	struct shmid_ds *bsp;
 	struct linux_shmid_ds *lsp;
@@ -446,9 +493,24 @@
 	lsp->l_private2 = bsp->_shm_internal;	/* XXX */
 }
 
+void
+bsd_to_linux_shmid64_ds(bsp, lsp)
+	struct shmid_ds *bsp;
+	struct linux_shmid64_ds *lsp;
+{
+	bsd_to_linux_ipc64_perm(&bsp->shm_perm, &lsp->l_shm_perm);
+	lsp->l_shm_segsz = bsp->shm_segsz;
+	lsp->l_shm_lpid = bsp->shm_lpid;
+	lsp->l_shm_cpid = bsp->shm_cpid;
+	lsp->l_shm_nattch = bsp->shm_nattch;
+	lsp->l_shm_atime = bsp->shm_atime;
+	lsp->l_shm_dtime = bsp->shm_dtime;
+	lsp->l_shm_ctime = bsp->shm_ctime;
+	lsp->l___unused5 = (u_long)bsp->_shm_internal;	/* XXX */
+}
+
 /*
- * shmctl. Not implemented (for now): IPC_INFO, SHM_INFO, SHM_STAT
- * SHM_LOCK and SHM_UNLOCK are passed on, but currently not implemented
+ * shmctl.SHM_LOCK and SHM_UNLOCK are passed on, but currently not implemented
  * by NetBSD itself.
  *
  * The usual structure conversion and massaging is done.
@@ -469,11 +531,16 @@
 	struct sys___shmctl13_args nua;
 	struct shmid_ds *bsp, bs;
 	struct linux_shmid_ds ls;
-	int error;
+	struct linux_shmid64_ds ls64;
+	struct linux_shminfo64 lsi64;
+	struct linux_shm_info lsi;
+	int error, i, cmd;
 
 	SCARG(&nua, shmid) = SCARG(uap, shmid);
-	switch (SCARG(uap, cmd)) {
+	cmd = SCARG(uap, cmd);
+	switch (cmd) {
 	case LINUX_IPC_STAT:
+	case LINUX_SHM_STAT:
 		sg = stackgap_init(p, 0);
 		bsp = stackgap_alloc(p, &sg, sizeof(struct shmid_ds));
 		SCARG(&nua, cmd) = IPC_STAT;
@@ -483,7 +550,29 @@
 		if ((error = copyin(SCARG(&nua, buf), &bs, sizeof bs)))
 			return error;
 		bsd_to_linux_shmid_ds(&bs, &ls);
+		if (cmd == LINUX_SHM_STAT) {
+			retval[0] = IXSEQ_TO_IPCID(bs.shm_perm._key,
+						   bs.shm_perm);
+		}
 		return copyout(&ls, SCARG(uap, buf), sizeof ls);
+
+	case LINUX_IPC_STAT|LINUX_IPC_64:
+	case LINUX_SHM_STAT|LINUX_IPC_64:
+		sg = stackgap_init(p,0);
+		bsp = stackgap_alloc(p, &sg, sizeof(struct linux_shmid64_ds));
+		SCARG(&nua, cmd) = IPC_STAT;
+		SCARG(&nua, buf) = bsp;
+		if ((error = sys___shmctl13(l, &nua, retval)))
+			return error;
+		if ((error = copyin(SCARG(&nua, buf), &bs, sizeof bs)))
+			return error;
+		bsd_to_linux_shmid64_ds(&bs, &ls64);
+		if (cmd == (LINUX_SHM_STAT|LINUX_IPC_64)) {
+			retval[0] = IXSEQ_TO_IPCID(bs.shm_perm._key,
+						   bs.shm_perm);
+		}
+		return copyout(&ls64, SCARG(uap, buf), sizeof ls64);
+
 	case LINUX_IPC_SET:
 		if ((error = copyin(SCARG(uap, buf), &ls, sizeof ls)))
 			return error;
@@ -495,22 +584,47 @@
 		SCARG(&nua, cmd) = IPC_SET;
 		SCARG(&nua, buf) = bsp;
 		break;
+
 	case LINUX_IPC_RMID:
 		SCARG(&nua, cmd) = IPC_RMID;
 		SCARG(&nua, buf) = NULL;
 		break;
+
 	case LINUX_SHM_LOCK:
 		SCARG(&nua, cmd) = SHM_LOCK;
 		SCARG(&nua, buf) = NULL;
 		break;
+
 	case LINUX_SHM_UNLOCK:
 		SCARG(&nua, cmd) = SHM_UNLOCK;
 		SCARG(&nua, buf) = NULL;
 		break;
+
 	case LINUX_IPC_INFO:
-	case LINUX_SHM_STAT:
+		memset(&lsi64, 0, sizeof lsi64);
+		lsi64.l_shmmax = shminfo.shmmax;
+		lsi64.l_shmmin = shminfo.shmmin;
+		lsi64.l_shmmni = shminfo.shmmni;
+		lsi64.l_shmseg = shminfo.shmseg;
+		lsi64.l_shmall = shminfo.shmall;
+		return copyout(&lsi64, SCARG(uap, buf), sizeof lsi64);
+
 	case LINUX_SHM_INFO:
+		memset(&lsi, 0, sizeof lsi);
+		lsi.l_used_ids = shm_nused;
+		for (i = 0; i < shminfo.shmmni; i++) {
+			if (shmsegs[i].shm_perm.mode & 0x800) {
+				lsi.l_shm_tot += shmsegs[i].shm_segsz;
+			}
+		}
+		lsi.l_shm_rss = 0;
+		lsi.l_shm_swp = 0;
+		lsi.l_swap_attempts = 0;
+		lsi.l_swap_successes = 0;
+		return copyout(&lsi, SCARG(uap, buf), sizeof lsi);
+
 	default:
+		printf("linux_sys_shmctl cmd %d\n", SCARG(uap, cmd));
 		return EINVAL;
 	}
 	return sys___shmctl13(l, &nua, retval);
Index: src/sys/compat/linux/common/linux_ipc.h
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_ipc.h,v
retrieving revision 1.6
diff -u -r1.6 linux_ipc.h
--- compat/linux/common/linux_ipc.h	30 May 2001 11:37:27 -0000	1.6
+++ compat/linux/common/linux_ipc.h	9 Nov 2005 20:06:45 -0000
@@ -67,18 +67,38 @@
 	ushort		l_seq;
 };
 
+struct linux_ipc64_perm {
+	linux_key_t	l_key;
+	uint		l_uid;
+	uint		l_gid;
+	uint		l_cuid;
+	uint		l_cgid;
+	ushort		l_mode;
+	ushort		l___pad1;
+	ushort		l_seq;
+	ushort		l___pad2;
+	ulong		l___unused1;
+	ulong		l___unused2;
+};
+
 #define LINUX_IPC_RMID	0
 #define LINUX_IPC_SET	1
 #define LINUX_IPC_STAT	2
 #define LINUX_IPC_INFO	3
 
+#define LINUX_IPC_64	0x100
+
 #if defined (SYSVSEM) || defined(SYSVSHM) || defined(SYSVMSG)
 #ifdef _KERNEL
 __BEGIN_DECLS
 void linux_to_bsd_ipc_perm __P((struct linux_ipc_perm *,
 				       struct ipc_perm *));
+void linux_to_bsd_ipc64_perm __P((struct linux_ipc64_perm *,
+				       struct ipc_perm *));
 void bsd_to_linux_ipc_perm __P((struct ipc_perm *,
 				       struct linux_ipc_perm *));
+void bsd_to_linux_ipc64_perm __P((struct ipc_perm *,
+				       struct linux_ipc64_perm *));
 __END_DECLS
 #endif	/* !_KERNEL */
 #endif	/* !SYSVSEM, !SYSVSHM, !SYSVMSG */
Index: src/sys/compat/linux/common/linux_shm.h
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_shm.h,v
retrieving revision 1.6
diff -u -r1.6 linux_shm.h
--- compat/linux/common/linux_shm.h	28 Sep 2004 19:05:19 -0000	1.6
+++ compat/linux/common/linux_shm.h	9 Nov 2005 20:06:45 -0000
@@ -58,6 +58,43 @@
 	void			*l_private3;
 };
 
+struct linux_shmid64_ds {
+	struct linux_ipc64_perm	l_shm_perm;
+	uint			l_shm_segsz;
+	linux_time_t		l_shm_atime;
+	u_long			l____unused1;
+	linux_time_t		l_shm_dtime;
+	u_long			l____unused2;
+	linux_time_t		l_shm_ctime;
+	u_long			l____unused3;
+	int			l_shm_cpid;
+	int			l_shm_lpid;
+	u_long			l_shm_nattch;
+	u_long			l___unused4;
+	u_long			l___unused5;
+};
+
+struct linux_shminfo64 {
+	u_long			l_shmmax;
+	u_long			l_shmmin;
+	u_long			l_shmmni;
+	u_long			l_shmseg;
+	u_long			l_shmall;
+	u_long			l___unused1;
+	u_long			l___unused2;
+	u_long			l___unused3;
+	u_long			l___unused4;
+};
+
+struct linux_shm_info {
+	int			l_used_ids;
+	u_long			l_shm_tot;
+	u_long			l_shm_rss;
+	u_long			l_shm_swp;
+	u_long			l_swap_attempts;
+	u_long			l_swap_successes;
+};
+
 #define LINUX_SHM_RDONLY	0x1000
 #define LINUX_SHM_RND		0x2000
 #define LINUX_SHM_REMAP		0x4000
@@ -90,8 +127,12 @@
 int linux_sys_shmctl __P((struct lwp *, void *, register_t *));
 void linux_to_bsd_shmid_ds __P((struct linux_shmid_ds *,
     struct shmid_ds *));
+void linux_to_bsd_shmid64_ds __P((struct linux_shmid64_ds *,
+    struct shmid_ds *));
 void bsd_to_linux_shmid_ds __P((struct shmid_ds *,
     struct linux_shmid_ds *));
+void bsd_to_linux_shmid64_ds __P((struct shmid_ds *,
+    struct linux_shmid64_ds *));
 __END_DECLS
 #endif	/* !_KERNEL */
 #endif	/* !SYSVSHM */
Index: src/sys/kern/sysv_sem.c
===================================================================
RCS file: /cvsroot/src/sys/kern/sysv_sem.c,v
retrieving revision 1.55.10.1
diff -u -r1.55.10.1 sysv_sem.c
--- kern/sysv_sem.c	5 Nov 2005 00:47:00 -0000	1.55.10.1
+++ kern/sysv_sem.c	9 Nov 2005 20:06:51 -0000
@@ -590,7 +590,7 @@
 	int i, eval;
 	int do_wakeup, do_undos;
 
-	SEM_PRINTF(("call to semop(%d, %p, %zd)\n", semid, sops, nsops));
+	SEM_PRINTF(("call to semop(%d, %p, %zd)\n", semid, SCARG(uap,sops), nsops));
 
 	semid = IPCID_TO_IX(semid);	/* Convert back to zero origin */
 	if (semid < 0 || semid >= seminfo.semmni)
Index: src/sys/kern/sysv_shm.c
===================================================================
RCS file: /cvsroot/src/sys/kern/sysv_shm.c,v
retrieving revision 1.82.10.1
diff -u -r1.82.10.1 sysv_shm.c
--- kern/sysv_shm.c	18 Sep 2005 20:09:50 -0000	1.82.10.1
+++ kern/sysv_shm.c	9 Nov 2005 20:06:52 -0000
@@ -110,7 +110,7 @@
 #define	SHMSEG_WANTED		0x1000
 #define	SHMSEG_RMLINGER		0x2000
 
-static int	shm_last_free, shm_nused, shm_committed;
+int shm_nused;
 struct	shmid_ds *shmsegs;
 
 struct shmmap_entry {
@@ -119,6 +119,8 @@
 	int shmid;
 };
 
+static int	shm_last_free, shm_committed;
+
 static POOL_INIT(shmmap_entry_pool, sizeof(struct shmmap_entry), 0, 0, 0,
     "shmmp", &pool_allocator_nointr);
 
@@ -179,6 +181,11 @@
 	struct uvm_object *uobj = shmseg->_shm_internal;
 	size_t size = (shmseg->shm_segsz + PGOFSET) & ~PGOFSET;
 
+#ifdef SHMDEBUG
+	printf("shm freeing key 0x%lx seq 0x%x\n",
+	       shmseg->shm_perm._key, shmseg->shm_perm._seq);
+#endif
+
 	(*uobj->pgops->pgo_detach)(uobj);
 	shmseg->_shm_internal = NULL;
 	shm_committed -= btoc(size);
@@ -375,7 +382,7 @@
 	shmmap_se->shmid = SCARG(uap, shmid);
 	shmmap_s = shmmap_getprivate(p);
 #ifdef SHMDEBUG
-	printf("shmat: vm %p: add %d @%lx\n", p->p_vmspace, shmid, attach_va);
+	printf("shmat: vm %p: add %d @%lx\n", p->p_vmspace, shmmap_se->shmid, attach_va);
 #endif
 	SLIST_INSERT_HEAD(&shmmap_s->entries, shmmap_se, next);
 	shmmap_s->nitems++;
@@ -596,8 +603,13 @@
 	if (SCARG(uap, shmflg) & _SHM_RMLINGER)
 		mode |= SHMSEG_RMLINGER;
 
+#ifdef SHMDEBUG
+	printf("shmget: key 0x%lx size 0x%x shmflg 0x%x mode 0x%x\n",
+        	SCARG(uap, key), SCARG(uap, size), SCARG(uap, shmflg), mode);
+#endif
+
 	if (SCARG(uap, key) != IPC_PRIVATE) {
-	again:
+again:
 		segnum = shm_find_segment_by_key(SCARG(uap, key));
 		if (segnum >= 0) {
 			error = shmget_existing(p, uap, mode, segnum, retval);

------=_Part_4620_16570874.1131570235363--