From patchwork Fri Oct 28 15:52:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Vrabel X-Patchwork-Id: 9402195 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CC5F86022E for ; Fri, 28 Oct 2016 15:55:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE8112A86A for ; Fri, 28 Oct 2016 15:55:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2C722A86F; Fri, 28 Oct 2016 15:55:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4FE522A86A for ; Fri, 28 Oct 2016 15:55:05 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c09Sg-0005Fd-6L; Fri, 28 Oct 2016 15:52:54 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c09Se-0005Eu-NW for xen-devel@lists.xenproject.org; Fri, 28 Oct 2016 15:52:52 +0000 Received: from [85.158.139.211] by server-15.bemta-5.messagelabs.com id B2/2A-13537-35473185; Fri, 28 Oct 2016 15:52:51 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprDIsWRWlGSWpSXmKPExsXitHSDvW5QiXC Ewe4dchbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8a03SvZCt4qVdy7e5q9gfGObBcjJ4eEgL/E 2Wn/mEBsNgEdicdLZrCD2CJA9u+GsyxdjFwczAIPGCWe/HrF2MXIwSEs4Cbx80geSA2LgKpE2 7q3YL28QOF3r96wQMyUkzh//CcziM0p4C6x89UjRhBbCKjm3ovfrBC2isTHtatYIXoFJU7OfA LWyywgIXHwxQtmiDncErdPT2WewMg3C0nZLCRlCxiZVjGqF6cWlaUW6VrqJRVlpmeU5CZm5ug aGpjq5aYWFyemp+YkJhXrJefnbmIEhhQDEOxgXNvqfIhRkoNJSZT3Q7hwhBBfUn5KZUZicUZ8 UWlOavEhRhkODiUJ3rBioJxgUWp6akVaZg4wuGHSEhw8SiK8ESBp3uKCxNzizHSI1ClGXY43u 14+YBJiycvPS5US5y0BKRIAKcoozYMbAYu0S4yyUsK8jEBHCfEUpBblZpagyr9iFOdgVBLmnQ 8yhSczrwRu0yugI5iAjpieLgByREkiQkqqgbFl0xIttXVL8jzX+7LzP22uFlE6YLnZYsr1pkN XnevPG4spPL181rHMW3prkaPu3AhN6anrDUKuHRFVeMd6bZXJZIPT/x6uc19tMqUqP5XPmXN1 bFiTwXKbOxN1Ih7+Xfjcqj/z9qQ1n8T/L7nzwnbDyodcB7cab+X3d3z+KDh52aafP37u9zihx FKckWioxVxUnAgAl3g7Z68CAAA= X-Env-Sender: prvs=102855286=david.vrabel@citrix.com X-Msg-Ref: server-6.tower-206.messagelabs.com!1477669968!67182327!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.0.13; banners=-,-,- X-VirusChecked: Checked Received: (qmail 8202 invoked from network); 28 Oct 2016 15:52:50 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-6.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 28 Oct 2016 15:52:50 -0000 X-IronPort-AV: E=Sophos;i="5.31,410,1473120000"; d="scan'208";a="395209388" From: David Vrabel To: Alexander Viro Date: Fri, 28 Oct 2016 16:52:38 +0100 Message-ID: <1477669959-9486-3-git-send-email-david.vrabel@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1477669959-9486-1-git-send-email-david.vrabel@citrix.com> References: <1477669959-9486-1-git-send-email-david.vrabel@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: Juergen Gross , linux-kernel@vger.kernel.org, David Vrabel , linux-fsdevel@vger.kernel.org, xen-devel@lists.xenproject.org, Boris Ostrovsky Subject: [Xen-devel] [PATCHv4 2/3] xenfs: replace xenbus and privcmd with symlinks X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP /proc/xen/xenbus does not work correctly. A read blocked waiting for a xenstore message holds the mutex needed for atomic file position updates. This blocks any writes on the same file handle, which can deadlock if the write is needed to unblock the read. /proc/xen/xenbus is supposed to be identical to the character device /dev/xen/xenbus so replace the file with a symlink. Similarly, replace /proc/xen/privcmd with a symlink since it should be the same as /dev/xen/privcmd. Signed-off-by: David Vrabel --- v4: - Make xen_xenbus_fops and xen_privcmd_fops static. --- drivers/xen/privcmd.c | 5 +---- drivers/xen/privcmd.h | 3 --- drivers/xen/xenbus/xenbus_comms.h | 2 -- drivers/xen/xenbus/xenbus_dev_frontend.c | 3 +-- drivers/xen/xenfs/super.c | 10 ++++------ 5 files changed, 6 insertions(+), 17 deletions(-) delete mode 100644 drivers/xen/privcmd.h diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c index 702040f..12ece8d 100644 --- a/drivers/xen/privcmd.c +++ b/drivers/xen/privcmd.c @@ -37,8 +37,6 @@ #include #include -#include "privcmd.h" - MODULE_LICENSE("GPL"); #define PRIV_VMA_LOCKED ((void *)1) @@ -644,12 +642,11 @@ static int privcmd_vma_range_is_mapped( is_mapped_fn, NULL) != 0; } -const struct file_operations xen_privcmd_fops = { +const static struct file_operations xen_privcmd_fops = { .owner = THIS_MODULE, .unlocked_ioctl = privcmd_ioctl, .mmap = privcmd_mmap, }; -EXPORT_SYMBOL_GPL(xen_privcmd_fops); static struct miscdevice privcmd_dev = { .minor = MISC_DYNAMIC_MINOR, diff --git a/drivers/xen/privcmd.h b/drivers/xen/privcmd.h deleted file mode 100644 index 14facae..0000000 --- a/drivers/xen/privcmd.h +++ /dev/null @@ -1,3 +0,0 @@ -#include - -extern const struct file_operations xen_privcmd_fops; diff --git a/drivers/xen/xenbus/xenbus_comms.h b/drivers/xen/xenbus/xenbus_comms.h index e74f9c1..39efb85 100644 --- a/drivers/xen/xenbus/xenbus_comms.h +++ b/drivers/xen/xenbus/xenbus_comms.h @@ -47,6 +47,4 @@ extern struct xenstore_domain_interface *xen_store_interface; extern int xen_store_evtchn; extern enum xenstore_init xen_store_domain_type; -extern const struct file_operations xen_xenbus_fops; - #endif /* _XENBUS_COMMS_H */ diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c index c1010f01..a45e7f2 100644 --- a/drivers/xen/xenbus/xenbus_dev_frontend.c +++ b/drivers/xen/xenbus/xenbus_dev_frontend.c @@ -598,7 +598,7 @@ static unsigned int xenbus_file_poll(struct file *file, poll_table *wait) return 0; } -const struct file_operations xen_xenbus_fops = { +const static struct file_operations xen_xenbus_fops = { .read = xenbus_file_read, .write = xenbus_file_write, .open = xenbus_file_open, @@ -606,7 +606,6 @@ const struct file_operations xen_xenbus_fops = { .poll = xenbus_file_poll, .llseek = no_llseek, }; -EXPORT_SYMBOL_GPL(xen_xenbus_fops); static struct miscdevice xenbus_dev = { .minor = MISC_DYNAMIC_MINOR, diff --git a/drivers/xen/xenfs/super.c b/drivers/xen/xenfs/super.c index 8559a71..0f2e2cd 100644 --- a/drivers/xen/xenfs/super.c +++ b/drivers/xen/xenfs/super.c @@ -18,8 +18,6 @@ #include #include "xenfs.h" -#include "../privcmd.h" -#include "../xenbus/xenbus_comms.h" #include @@ -45,16 +43,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