Skip to contentSkip to conversation

shm fs v2 against 2.3.41

PATCH In review Christoph Rohland 3 participants 4 messages Jan 30, 2000 – Feb 2, 2000

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 shm fs v2 against 2.3.41

Hi Folks,

Here is my newest version of shm over a filesystem:

Changes to the previous versio:

- It does not try to autodetect the path any more. Per default it expects to be mounted at /var/shm. If you mount it somewhere else, put the new path into /proc/sys/kernel/shmpath
- No more /proc/sys/kernel/{shmall,shmmni}. Use mount options nr_blocks and nr_pages. You can change these parameters with remount.
- You can set the initial mode of the directory with mount option 'mode'.
- It frees all objects on umount.

I tested the shm fs heavily on 2.3.40+some patches to make smp and page_cache stable. It survived one day swap test.

Greetings
Christoph

Documentation/Changes +4 -0
diff -uNr 2.3.41/Documentation/Changes make41/Documentation/Changes
@@ -72,6 +72,10 @@
 General Information
 ===================
 
+   To use System V shared memory, you have to mount the shm filesystem
+somewhere and put the mountpoint into /proc/sys/kernel/shmpath.
+Default is /var/shm.
+
    <CTRL><ALT><DEL> now performs a cold reboot instead of a warm reboot
 for increased hardware compatibility.  If you want a warm reboot and
 know it works on your hardware, add a "reboot=warm" command line option
fs/namei.c +1 -1
diff -uNr 2.3.41/fs/namei.c make41/fs/namei.c
@@ -989,7 +989,7 @@
 	return error;
 }
 
-static inline int do_unlink(const char * name)
+int do_unlink(const char * name)
 {
 	int error;
 	struct dentry *dir;
include/linux/fs.h +1 -0
diff -uNr 2.3.41/include/linux/fs.h make41/include/linux/fs.h
@@ -880,6 +880,7 @@
 extern struct dentry * open_namei(const char *, int, int);
 extern struct dentry * do_mknod(const char *, int, dev_t);
 extern int do_pipe(int *);
+extern int do_unlink(const char * name);
 
 /* fs/dcache.c -- generic fs support functions */
 extern int is_subdir(struct dentry *, struct dentry *);
include/linux/sysctl.h +2 -1
diff -uNr 2.3.41/include/linux/sysctl.h make41/include/linux/sysctl.h
@@ -110,7 +110,8 @@
  	KERN_SPARC_STOP_A=44,	/* int: Sparc Stop-A enable */
  	KERN_SHMMNI=45,		/* int: shm array identifiers */
 	KERN_OVERFLOWUID=46,	/* int: overflow UID */
-	KERN_OVERFLOWGID=47	/* int: overflow GID */
+	KERN_OVERFLOWGID=47,	/* int: overflow GID */
+	KERN_SHMPATH=48,        /* string: path to shm fs */
 };
 
 
ipc/shm.c +629 -301

1,229 lines not on this page · raw message

ipc/util.c +0 -3
diff -uNr 2.3.41/ipc/util.c make41/ipc/util.c
@@ -40,9 +40,6 @@
 	if(size > IPCMNI)
 		size = IPCMNI;
 	ids->size = size;
-	if(size == 0)
-		return;
-
 	ids->in_use = 0;
 	ids->max_id = -1;
 	ids->seq = 0;
kernel/sysctl.c +3 -6
diff -uNr 2.3.41/kernel/sysctl.c make41/kernel/sysctl.c
@@ -55,8 +55,7 @@
 #endif
 #ifdef CONFIG_SYSVIPC
 extern size_t shm_ctlmax;
-extern int shm_ctlall;
-extern int shm_ctlmni;
+extern char shm_path[];
 extern int msg_ctlmax;
 extern int msg_ctlmnb;
 extern int msg_ctlmni;
@@ -225,12 +224,10 @@
 	{KERN_RTSIGMAX, "rtsig-max", &max_queued_signals, sizeof(int),
 	 0644, NULL, &proc_dointvec},
 #ifdef CONFIG_SYSVIPC
+	{KERN_SHMPATH, "shmpath", &shm_path, 256,
+	 0644, NULL, &proc_dostring, &sysctl_string },
 	{KERN_SHMMAX, "shmmax", &shm_ctlmax, sizeof (size_t),
 	 0644, NULL, &proc_doulongvec_minmax},
-	{KERN_SHMALL, "shmall", &shm_ctlall, sizeof (int),
-	 0644, NULL, &proc_dointvec},
-	{KERN_SHMMNI, "shmmni", &shm_ctlmni, sizeof (int),
-	 0644, NULL, &proc_dointvec},
 	{KERN_MSGMAX, "msgmax", &msg_ctlmax, sizeof (int),
 	 0644, NULL, &proc_dointvec},
 	{KERN_MSGMNI, "msgmni", &msg_ctlmni, sizeof (int),
#1 lore raw

Calling shmget( key, size, shmflg ) with size = 0, I got an error EINVAL. The below patch fix it, please apply into 2.3.41+shmfs14 patch.

---------------------

ipc/shm.c Tue Feb 1 18:57:52 2000 renamed from ipc/shm.c Tue Feb 1 18:49:02 2000 +1 -1
@@ -660,7 +660,7 @@
                return -EINVAL;
        }
 
-       if (size < SHMMIN)
+       if ((size != 0) && (size < SHMMIN))
                return -EINVAL;
 
        down(&shm_ids.sem);

---------------------

And now I have a question:
I guess almost all users have no shmpath (default: /var/shm), and they maybe make a dir and have to mount it. IMHO, it is better to change that sysv shared memory works samely, whenever shmfs is not mounted. Is it feasible, or only my mistaken ?

From: Christoph Rohland <[email protected]>
Subject: [PATCH] shm fs v2 against 2.3.41

Quoted 14 lines

Hi Folks,

Here is my newest version of shm over a filesystem:

Changes to the previous versio:

- It does not try to autodetect the path any more. Per default it expects to be mounted at /var/shm. If you mount it somewhere else, put the new path into /proc/sys/kernel/shmpath
- No more /proc/sys/kernel/{shmall,shmmni}. Use mount options nr_blocks and nr_pages. You can change these parameters with remount.
- You can set the initial mode of the directory with mount option 'mode'.
- It frees all objects on umount.

Quoted 2 lines

I tested the shm fs heavily on 2.3.40+some patches to make smp and page_cache stable. It survived one day swap test.

Regards,
-- GOTO Masanori
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/

#2 lore raw
Quoted 8 lines · GOTO Masanori

Calling shmget( key, size, shmflg ) with size = 0, I got an error EINVAL. The below patch fix it, please apply into 2.3.41+shmfs14 patch.

---------------------

ipc/shm.c Tue Feb 1 18:57:52 2000

Quoted 9 lines
ipc/shm.c Tue Feb 1 18:57:52 2000 renamed from ipc/shm.c Tue Feb 1 18:49:02 2000 +1 -2
@@ -660,7 +660,7 @@
                return -EINVAL;
        }
 
-       if (size < SHMMIN)
+       if ((size != 0) && (size < SHMMIN))
                return -EINVAL;
 
        down(&shm_ids.sem);
---------------------

Yes, I stumbled over that yesterday evening also. I will put out a new patch soon.

Quoted 6 lines

And now I have a question:
I guess almost all users have no shmpath (default: /var/shm), and they maybe make a dir and have to mount it. IMHO, it is better to change that sysv shared memory works samely, whenever shmfs is not mounted. Is it feasible, or only my mistaken ?

This was my first attempt, but all the gurus opposed to that since this needed some hacks to the VFS layer.

Since shmat, etc rely on the VFS functions, we have to mount the fs to use these functions.

Greetings
Christoph
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/

#3 lore raw
In reply to GOTO Masanori

Hi,

Quoted 5 lines · GOTO Masanori

I guess almost all users have no shmpath (default: /var/shm), and they maybe make a dir and have to mount it. IMHO, it is better to change that sysv shared memory works samely, whenever shmfs is not mounted. Is it feasible, or only my mistaken ?

Even tools as fundamental as "ps" don't work until /proc is mounted, so I don't see anything wrong with requiring shmfs to be mounted for sysV shared memory to work correctly.

--Stephen
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/