s390: Hypervisor File System
Subsystems (3)
Hi all,
[email protected] wrote on 04/21/2006 04:42:28 PM:
Quoted 4 lines
Hi Michael,
I have included some review comments below.
Here the updated version of my patch!
Michael
----
arch/s390/Kconfig | 7 arch/s390/Makefile | 2 arch/s390/hypfs/Makefile | 7 arch/s390/hypfs/hypfs.h | 32 ++ arch/s390/hypfs/hypfs_diag.c | 628 +++++++++++++++++++++++++++++++++++++++++++ arch/s390/hypfs/hypfs_diag.h | 16 + arch/s390/hypfs/inode.c | 467 +++++++++++++++++++++++++++++++ include/linux/string.h | 3 lib/string.c | 22 + 9 files changed, 1183 insertions(+), 1 deletion(-)
arch/s390/Kconfig +7 -0
@@ -442,6 +442,13 @@ config NO_IDLE_HZ_INIT The HZ timer is switched off in idle by default. That means the HZ timer is already disabled at boot time. +config HYPFS_FS + bool "zseries hypervisor file system support" + default y + help + This is a virtual file system intended to provide accounting + information in a zSeries hypervisor environment. + config KEXEC bool "kexec system call (EXPERIMENTAL)" depends on EXPERIMENTAL
arch/s390/Makefile +1 -1
@@ -77,7 +77,7 @@ LDFLAGS_vmlinux := -e start head-y := arch/$(ARCH)/kernel/head.o arch/$(ARCH)/kernel/init_task.o core-y += arch/$(ARCH)/mm/ arch/$(ARCH)/kernel/ arch/$(ARCH)/crypto/ \ - arch/$(ARCH)/appldata/ + arch/$(ARCH)/appldata/ arch/$(ARCH)/hypfs/ libs-y += arch/$(ARCH)/lib/ drivers-y += drivers/s390/ drivers-$(CONFIG_MATHEMU) += arch/$(ARCH)/math-emu/
arch/s390/hypfs/Makefile +7 -0
@@ -0,0 +1,7 @@ +# +# Makefile for the linux hypfs filesystem routines. +# + +obj-$(CONFIG_HYPFS_FS) += hypfs.o + +hypfs-objs := inode.o hypfs_diag.o
arch/s390/hypfs/hypfs.h +32 -0
@@ -0,0 +1,32 @@ +/* +* fs/hypfs/hypfs.h +* Hypervisor filesystem for Linux on zSeries. +* +* Copyright (C) IBM Corp. 2006 +* Author(s): Michael Holzheu <[email protected]> +*/ + +#ifndef _HYPFS_H_ +#define _HYPFS_H_ + +#include <linux/fs.h> +#include <linux/types.h> + +#define REG_FILE_MODE 0440 +#define UPDATE_FILE_MODE 0660 +#define DIR_MODE 0550 + +extern struct dentry *hypfs_mkdir (struct super_block *sb,struct dentry *parent, +const char *name); + +extern struct dentry *hypfs_create_u64 (struct super_block *sb, +struct dentry *dir,const char *name, +__u64 value); + +extern struct dentry *hypfs_create_str (struct super_block *sb, +struct dentry *dir,const char *name, +char *string); + +extern struct super_block *hypfs_sblk; + +#endif /* _HYPFS_H_ */
arch/s390/hypfs/hypfs_diag.c +628 -0
628 lines not on this page · raw message
arch/s390/hypfs/hypfs_diag.h +16 -0
@@ -0,0 +1,16 @@ +/* +* fs/hypfs/hypfs_diag.h +* Hypervisor filesystem for Linux on zSeries. +* +* Copyright (C) IBM Corp. 2006 +* Author(s): Michael Holzheu <[email protected]> +*/ + +#ifndef _HYPFS_DIAG_H_ +#define _HYPFS_DIAG_H_ + +extern int diag_init (void ); +extern void diag_exit (void ); +extern int diag_create_files (struct super_block *sb,struct dentry *root); + +#endif /* _HYPFS_DIAG_H_ */
arch/s390/hypfs/inode.c +467 -0
467 lines not on this page · raw message
include/linux/string.h +3 -0
@@ -59,6 +59,9 @@ extern char * strnchr(const char *, size#ifndef __HAVE_ARCH_STRRCHRextern char *strrchr (const char *,int );#endif +#ifndef __HAVE_ARCH_STRRTRIM +extern void strrtrim (char *,const char *); +#endif #ifndef __HAVE_ARCH_STRSTRextern char *strstr (const char *,const char *);#endif
lib/string.c +22 -0
@@ -284,6 +284,28 @@ char *strrchr(const char *s, int c)EXPORT_SYMBOL (strrchr);#endif +#ifndef __HAVE_ARCH_STRRTRIM +/** +* strrtrim - Remove trailing characters specified in @reject +* @s: The string to be searched +* @reject: The string of letters to avoid +*/ +void strrtrim (char *s,const char *reject) +{ +char *p; +const char *r; + +for (p = s +strlen (s) -1 ; s <= p; p--) { +for (r = reject; (*r !='\0' ) && (*p != *r); r++) +/* nothing */ ; +if (*r =='\0' ) +break ; + } + *(p +1 ) ='\0' ; +} +EXPORT_SYMBOL (strrtrim); +#endif +#ifndef __HAVE_ARCH_STRNCHR/** * strnchr - Find a character in a length limited string
lib/string.c char *strrchr(const char *s, int c) · line 293
Quoted 7 lines · Michael Holzheu
lib/string.c +7
-0+#ifndef __HAVE_ARCH_STRRTRIM +/** +* strrtrim - Remove trailing characters specified in @reject +* @s: The string to be searched +* @reject: The string of letters to avoid +*/ +void strrtrim (char *s,const char *reject)
I think this should return s to be consistent with other string API functions.
lib/string.c char *strrchr(const char *s, int c) · line 296
Quoted 3 lines
lib/string.c +3
-0+{ +char *p; +const char *r;
You need to exit here if strlen(s) is zero.
lib/string.c char *strrchr(const char *s, int c) · line 300
Quoted 4 lines
lib/string.c +4
-0+ +for (p = s +strlen (s) -1 ; s <= p; p--) { +for (r = reject; (*r !='\0' ) && (*p != *r); r++) +/* nothing */ ;
Please use strchr for the above.
lib/string.c char *strrchr(const char *s, int c) · line 302
Quoted 2 lines
lib/string.c +2
-0+if (*r =='\0' ) +break ;
What are you testing here?
Quoted 5 lines
lib/string.c +5
-0+ } + *(p +1 ) ='\0' ; +} +EXPORT_SYMBOL (strrtrim); +#endif
Quoted 7 lines · Michael Holzheu
Quoted 7 lines
(quoted diff) +7
-0+#ifndef __HAVE_ARCH_STRRTRIM +/** + * strrtrim - Remove trailing characters specified in @reject + * @s: The string to be searched + * @reject: The string of letters to avoid + */ +void strrtrim(char *s, const char *reject)
Quoted 2 lines · Pekka Enberg
I think this should return s to be consistent with other string API functions.
Hmm, thinking about this, I think a better API would be to not have that reject parameter at all. Would something like this be accetable for your use?
Pekka
include/linux/string.h +3 -0
@@ -56,6 +56,9 @@ #endif#ifndef __HAVE_ARCH_STRRCHRextern char *strrchr (const char *,int );#endif +#ifndef __HAVE_ARCH_STRSTRIP +extern char *strstrip (char *); +#endif #ifndef __HAVE_ARCH_STRSTRextern char *strstr (const char *,const char *);#endif
lib/string.c +32 -0
@@ -301,6 +301,38 @@ char *strnchr(const char *s, size_t counEXPORT_SYMBOL (strnchr);#endif +#ifndef __HAVE_ARCH_STRSTRIP +/** +* strstrip - Removes leading and trailing whitespace from @s. +* @s: The string to be stripped. +* +* Note that the first trailing whitespace is replaced with a %NUL-terminator +* in the given string @s. Returns a pointer to the first non-whitespace +* character in @s. +*/ +char *strstrip (char *s) +{ +size_t size; +char *end; + + size =strlen (s); + +if (!size) +return s; + + end = s + size -1 ; +while (end != s &&isspace (*end)) + end--; + *(end +1 ) ='\0' ; + +while (*s &&isspace (*s)) + s++; + +return s; +} +EXPORT_SYMBOL (strstrip); +#endif +#ifndef __HAVE_ARCH_STRLEN/** * strlen - Find the length of a string
Quoted 4 lines · Pekka Enberg
+#ifndef
__HAVE_ARCH_STRSTRIP
+extern char *strstrip(char *);
+#endif
Do we really need this gunk? It's not as if strstrip() is so super performance-sensitive that anyone would go and write a hand-tuned assembly version?
Quoted 3 lines · Pekka Enberg
Quoted 3 lines
+#ifndef
__HAVE_ARCH_STRSTRIP
+extern char *strstrip(char *);
+#endif
Quoted 3 lines · Andrew Morton
Do we really need this gunk? It's not as if
strstrip()is so super performance-sensitive that anyone would go and write a hand-tuned assembly version?
I guess not. I added it for consistency, but whatever makes you happy Andrew :)
Pekka
include/linux/string.h +1 -0
@@ -56,6 +56,7 @@ #endif#ifndef __HAVE_ARCH_STRRCHRextern char *strrchr (const char *,int );#endif +extern char *strstrip (char *);#ifndef __HAVE_ARCH_STRSTRextern char *strstr (const char *,const char *);#endif
lib/string.c +30 -0
@@ -301,6 +301,36 @@ char *strnchr(const char *s, size_t counEXPORT_SYMBOL (strnchr);#endif +/** +* strstrip - Removes leading and trailing whitespace from @s. +* @s: The string to be stripped. +* +* Note that the first trailing whitespace is replaced with a %NUL-terminator +* in the given string @s. Returns a pointer to the first non-whitespace +* character in @s. +*/ +char *strstrip (char *s) +{ +size_t size; +char *end; + + size =strlen (s); + +if (!size) +return s; + + end = s + size -1 ; +while (end != s &&isspace (*end)) + end--; + *(end +1 ) ='\0' ; + +while (*s &&isspace (*s)) + s++; + +return s; +} +EXPORT_SYMBOL (strstrip); +#ifndef __HAVE_ARCH_STRLEN/** * strlen - Find the length of a string
Quoted 4 lines · Pekka Enberg
Hmm, thinking about this, I think a better API would be to not have that reject parameter at all. Would something like this be accetable for your use?
[...]
lib/string.c char *strnchr(const char *s, size_t coun · line 329
Quoted 2 lines
lib/string.c +2
-0+while (*s &&isspace (*s)) + s++;
Just checking. This does remove a newline, right?
Jörn
Signature · 3 lines
When in doubt, punt. When somebody actually complains, go back and fix it... The 90% solution is a good thing. -- Rob Landley
Quoted 3 lines · Pekka Enberg
Quoted 3 lines
Hmm, thinking about this, I think a better API would be to not have that reject parameter at all. Would something like this be accetable for your use?
Quoted 6 lines · Jörn Engel
[...]
lib/string.c char *strnchr(const char *s, size_t coun · line 329
Quoted 2 lines
lib/string.c +2
-0+while (*s &&isspace (*s)) + s++;Just checking. This does remove a newline, right?
Yes, it does.
Pekka
Pekka Enberg <[email protected]> wrote on 04/25/2006 09:32:16 AM:
Quoted 10 lines · Michael Holzheu
Quoted 7 lines
Review
Quoted 7 lines
(quoted diff) +7
-0+#ifndef __HAVE_ARCH_STRRTRIM +/** + * strrtrim - Remove trailing characters specified in @reject + * @s: The string to be searched + * @reject: The string of letters to avoid + */ +void strrtrim(char *s, const char *reject)On Tue, 2006-04-25 at 09:58 +0300, Pekka Enberg wrote:
Quoted 6 lines
Quoted 2 lines
I think this should return s to be consistent with other string API functions.
Hmm, thinking about this, I think a better API would be to not have that reject parameter at all. Would something like this be accetable for your use?
Yes, strtrip() will work for us! If Andrew takes it, I will use it in my patch!
Thanks
Michael
arch/s390/hypfs/hypfs_diag.c line 492
Quoted 5 lines · Michael Holzheu
arch/s390/hypfs/hypfs_diag.c +5
-0+static int hypfs_create_cpu_files (struct super_block *sb, +struct dentry *cpus_dir,void *cpu_info) +{ +struct dentry *cpu_dir; +char buffer[TMP_SIZE ];
Holy cow! That's 1 KB allocated on the stack! Please use kmalloc() instead.
arch/s390/hypfs/hypfs_diag.c line 553
Quoted 5 lines
arch/s390/hypfs/hypfs_diag.c +5
-0+static int hypfs_create_phys_cpu_files (struct super_block *sb, +struct dentry *cpus_dir,void *cpu_info) +{ +struct dentry *cpu_dir; +char buffer[TMP_SIZE ];
Ditto.
arch/s390/hypfs/inode.c line 162
Quoted 11 lines
arch/s390/hypfs/inode.c +11
-0+static ssize_t hypfs_aio_write (struct kiocb *iocb,const char __user *buf, +size_t count,loff_t pos) +{ +int rc; + +mutex_lock (&hypfs_lock); +if (last_update_time ==get_seconds ()) { + rc = -EBUSY ; + goto out; + } +hypfs_delete_tree (hypfs_sblk->s_root);
To state what I said earlier: the use of a global hypfs_sblk is problematic because now we can only have the filesystem mounted once. So I would really like to see some other way of updating. How do you feel about the s_ops->fs_remount thing?
Pekka
Quoted 5 lines · Pekka Enberg
To state what I said earlier: the use of a global
hypfs_sblkis problematic because now we can only have the filesystem mounted once. So I would really like to see some other way of updating. How do you feel about thes_ops->fs_remountthing?
It sounds as if part of hypfs is a global resource. Maybe the code could be split between a global get-and-store-data part and a per-filesystem representation part?
Jörn
Signature · 2 lines
Invincibility is in oneself, vulnerability is in the opponent. -- Sun Tzu
Hi Pekka,
Pekka Enberg <[email protected]> wrote on 04/25/2006 04:33:01 PM:
Quoted 9 lines · Michael Holzheu
arch/s390/hypfs/hypfs_diag.c line 492
Quoted 5 lines
arch/s390/hypfs/hypfs_diag.c +5
-0+static int hypfs_create_cpu_files (struct super_block *sb, +struct dentry *cpus_dir,void *cpu_info) +{ +struct dentry *cpu_dir; +char buffer[TMP_SIZE ];Holy cow! That's 1 KB allocated on the stack! Please use
kmalloc()instead.
Thanks! We also have found that already! Shame on me ...
Quoted 1 line
Quoted 1 line
+static
ssize_thypfs_aio_write(struct kiocb *iocb, const char__user
*buf,
Quoted 7 lines
Quoted 7 lines
arch/s390/hypfs/inode.c +7
-0+ size_t count, loff_t pos) +{ + int rc; + +mutex_lock (&hypfs_lock); +if (last_update_time ==get_seconds ()) { + rc = -EBUSY ;
Quoted 9 lines
arch/s390/hypfs/inode.c line 162
Quoted 3 lines
arch/s390/hypfs/inode.c +3
-0+ goto out; + } +hypfs_delete_tree (hypfs_sblk->s_root);To state what I said earlier: the use of a global
hypfs_sblkis problematic because now we can only have the filesystem mounted once. So I would really like to see some other way of updating. How do you feel about thes_ops->fs_remountthing?
I will eliminate the global variable anyway, since I can get the superblock also from the inode:
+static ssize_t hypfs_aio_write(struct kiocb *iocb, const char __user *buf,
+ size_t count, loff_t pos)
+{
+ int rc;
+ struct super_block *sb;
+
+ mutex_lock(&hypfs_lock);
+ sb = iocb->ki_filp->f_dentry->d_inode->i_sb;
+ if (last_update_time == get_seconds()) {
+ rc = -EBUSY;
+ goto out;
+ }
+ hypfs_delete_tree(sb->s_root);
+ rc = diag_create_files(sb, sb->s_root);
+ if (rc) {
+ printk(KERN_ERR "hypfs: Update failed\n");
+ hypfs_delete_tree(sb->s_root);
+ goto out;
+ }
+ hypfs_update_update();
+ rc = count;+ out:
+ mutex_unlock(&hypfs_lock);
+ return rc;
+}
Hmmm... sure, you could use remount to trigger the update. One advantage of remount is that we do not need the hypfs_lock, right. But having the hypfs lock needs only three lines of code and therefore this is not really a strong argument in my eyes.
I think one disadvantage of the remount mechanism is that it is not as intuitive as the update attribute. If you have an update file, it is clear that writing to that file triggers an update. That a remount triggers an update seems to be less intuitive for me.
But the bigger disadvantage is that only root (or any user if you specify 'user' in /etc/fstab) can trigger the update with remount. We want to allow also other users to trigger the update and read the attributes. The current implementation for that is to specify uid and gid as mount option to define the owner of the files. For example you can run a user space program with uid xxx and specify uid=xxx as mount option to allow the program to update and read the data.
Michael