All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv1 0/2] xen/xenfs: fix /proc/xen/xenbus
@ 2016-05-16 17:44 David Vrabel
  2016-05-16 17:44 ` [PATCHv1 1/2] libfs: allow simple_fill_super() to add symlinks David Vrabel
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: David Vrabel @ 2016-05-16 17:44 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Boris Ostrovsky, David Vrabel

"Fix" /proc/xen/xenbus by making it a symlink to the working
/dev/xen/xenbus.  Do the same for /proc/xen/privcmd so it matches.

If there's agreement on this approach I'll resend to Cc the fs
maintainers.

David


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCHv1 1/2] libfs: allow simple_fill_super() to add symlinks
  2016-05-16 17:44 [PATCHv1 0/2] xen/xenfs: fix /proc/xen/xenbus David Vrabel
@ 2016-05-16 17:44 ` David Vrabel
  2016-05-16 17:44 ` [PATCHv1 2/2] xen/xenfs: replace xenbus and privcmd with symlinks David Vrabel
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: David Vrabel @ 2016-05-16 17:44 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Boris Ostrovsky, David Vrabel

simple_fill_super() will add symlinks if an entry has mode & S_IFLNK.
The target is provided in the new "link" field.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
---
 fs/libfs.c         | 23 ++++++++++++++++++++---
 include/linux/fs.h |  2 +-
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/fs/libfs.c b/fs/libfs.c
index f3fa82c..894e182 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -500,6 +500,8 @@ int simple_fill_super(struct super_block *s, unsigned long magic,
 	if (!root)
 		return -ENOMEM;
 	for (i = 0; !files->name || files->name[0]; i++, files++) {
+		char *link = NULL;
+
 		if (!files->name)
 			continue;
 
@@ -509,17 +511,32 @@ int simple_fill_super(struct super_block *s, unsigned long magic,
 				"with an index of 1!\n", __func__,
 				s->s_type->name);
 
+		if (files->mode & S_IFLNK) {
+			link = kstrdup(files->link, GFP_KERNEL);
+			if (!link)
+				goto out;
+		}
+
 		dentry = d_alloc_name(root, files->name);
-		if (!dentry)
+		if (!dentry) {
+			kfree(link);
 			goto out;
+		}
 		inode = new_inode(s);
 		if (!inode) {
 			dput(dentry);
+			kfree(link);
 			goto out;
 		}
-		inode->i_mode = S_IFREG | files->mode;
+		inode->i_mode = files->mode;
+		if (files->mode & S_IFLNK) {
+			inode->i_op = &simple_symlink_inode_operations;
+			inode->i_link = link;
+		} else {
+			inode->i_fop = files->ops;
+			inode->i_mode |= S_IFREG;
+		}
 		inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
-		inode->i_fop = files->ops;
 		inode->i_ino = i;
 		d_add(dentry, inode);
 	}
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 70e61b5..8a09998 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2897,7 +2897,7 @@ extern const struct file_operations simple_dir_operations;
 extern const struct inode_operations simple_dir_inode_operations;
 extern void make_empty_dir_inode(struct inode *inode);
 extern bool is_empty_dir_inode(struct inode *inode);
-struct tree_descr { char *name; const struct file_operations *ops; int mode; };
+struct tree_descr { char *name; const struct file_operations *ops; int mode; char *link; };
 struct dentry *d_alloc_name(struct dentry *, const char *);
 extern int simple_fill_super(struct super_block *, unsigned long, struct tree_descr *);
 extern int simple_pin_fs(struct file_system_type *, struct vfsmount **mount, int *count);
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCHv1 2/2] xen/xenfs: replace xenbus and privcmd with symlinks
  2016-05-16 17:44 [PATCHv1 0/2] xen/xenfs: fix /proc/xen/xenbus David Vrabel
  2016-05-16 17:44 ` [PATCHv1 1/2] libfs: allow simple_fill_super() to add symlinks David Vrabel
@ 2016-05-16 17:44 ` David Vrabel
  2016-05-16 18:36 ` [PATCHv1 0/2] xen/xenfs: fix /proc/xen/xenbus Boris Ostrovsky
  2016-05-16 22:23 ` Doug Goldstein
  3 siblings, 0 replies; 5+ messages in thread
From: David Vrabel @ 2016-05-16 17:44 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Boris Ostrovsky, David Vrabel

/proc/xen/xenbus does not work correctly.  A read blocked waiting for
a xenbus message will deadlock a write to the same file handle due to
the requirement for atomic file position updates on regular files.

/proc/xen/xenbus and /proc/xen/privcmd are supposed to be identical to
the character devices /dev/xen/xenbus and /dev/xen/privcmd so replace
the files with symlinks.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
---
 drivers/xen/xenfs/super.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/xen/xenfs/super.c b/drivers/xen/xenfs/super.c
index 8559a71..09c239e 100644
--- a/drivers/xen/xenfs/super.c
+++ b/drivers/xen/xenfs/super.c
@@ -45,16 +45,16 @@ static const struct file_operations capabilities_file_ops = {
 static int xenfs_fill_super(struct super_block *sb, void *data, int silent)
 {
 	static struct tree_descr xenfs_files[] = {
-		[2] = { "xenbus", &xen_xenbus_fops, S_IRUSR|S_IWUSR },
+		[2] = { "xenbus", NULL, S_IFLNK | S_IRWXUGO, "/dev/xen/xenbus" },
 		{ "capabilities", &capabilities_file_ops, S_IRUGO },
-		{ "privcmd", &xen_privcmd_fops, S_IRUSR|S_IWUSR },
+		{ "privcmd", NULL, S_IFLNK | S_IRWXUGO, "/dev/xen/privcmd" },
 		{""},
 	};
 
 	static struct tree_descr xenfs_init_files[] = {
-		[2] = { "xenbus", &xen_xenbus_fops, S_IRUSR|S_IWUSR },
+		[2] = { "xenbus", NULL, S_IFLNK | S_IRWXUGO, "/dev/xen/xenbus" },
 		{ "capabilities", &capabilities_file_ops, S_IRUGO },
-		{ "privcmd", &xen_privcmd_fops, S_IRUSR|S_IWUSR },
+		{ "privcmd", NULL, S_IFLNK | S_IRWXUGO, "/dev/xen/privcmd" },
 		{ "xsd_kva", &xsd_kva_file_ops, S_IRUSR|S_IWUSR},
 		{ "xsd_port", &xsd_port_file_ops, S_IRUSR|S_IWUSR},
 #ifdef CONFIG_XEN_SYMS
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCHv1 0/2] xen/xenfs: fix /proc/xen/xenbus
  2016-05-16 17:44 [PATCHv1 0/2] xen/xenfs: fix /proc/xen/xenbus David Vrabel
  2016-05-16 17:44 ` [PATCHv1 1/2] libfs: allow simple_fill_super() to add symlinks David Vrabel
  2016-05-16 17:44 ` [PATCHv1 2/2] xen/xenfs: replace xenbus and privcmd with symlinks David Vrabel
@ 2016-05-16 18:36 ` Boris Ostrovsky
  2016-05-16 22:23 ` Doug Goldstein
  3 siblings, 0 replies; 5+ messages in thread
From: Boris Ostrovsky @ 2016-05-16 18:36 UTC (permalink / raw)
  To: David Vrabel, xen-devel; +Cc: Juergen Gross

On 05/16/2016 01:44 PM, David Vrabel wrote:
> "Fix" /proc/xen/xenbus by making it a symlink to the working
> /dev/xen/xenbus.  Do the same for /proc/xen/privcmd so it matches.
>
> If there's agreement on this approach I'll resend to Cc the fs
> maintainers.

Looks good to me.

-boris


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCHv1 0/2] xen/xenfs: fix /proc/xen/xenbus
  2016-05-16 17:44 [PATCHv1 0/2] xen/xenfs: fix /proc/xen/xenbus David Vrabel
                   ` (2 preceding siblings ...)
  2016-05-16 18:36 ` [PATCHv1 0/2] xen/xenfs: fix /proc/xen/xenbus Boris Ostrovsky
@ 2016-05-16 22:23 ` Doug Goldstein
  3 siblings, 0 replies; 5+ messages in thread
From: Doug Goldstein @ 2016-05-16 22:23 UTC (permalink / raw)
  To: David Vrabel, xen-devel; +Cc: Juergen Gross, Boris Ostrovsky


[-- Attachment #1.1.1: Type: text/plain, Size: 451 bytes --]

On 5/16/16 12:44 PM, David Vrabel wrote:
> "Fix" /proc/xen/xenbus by making it a symlink to the working
> /dev/xen/xenbus.  Do the same for /proc/xen/privcmd so it matches.
> 
> If there's agreement on this approach I'll resend to Cc the fs
> maintainers.
> 
> David
> 

Looks good to me. Looks like the bits you're using were introduced in
4.2 which explains why I believed some more infra needed to be wired up.

-- 
Doug Goldstein


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 959 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-05-16 22:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-16 17:44 [PATCHv1 0/2] xen/xenfs: fix /proc/xen/xenbus David Vrabel
2016-05-16 17:44 ` [PATCHv1 1/2] libfs: allow simple_fill_super() to add symlinks David Vrabel
2016-05-16 17:44 ` [PATCHv1 2/2] xen/xenfs: replace xenbus and privcmd with symlinks David Vrabel
2016-05-16 18:36 ` [PATCHv1 0/2] xen/xenfs: fix /proc/xen/xenbus Boris Ostrovsky
2016-05-16 22:23 ` Doug Goldstein

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.