From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com [209.85.217.169]) by dpdk.org (Postfix) with ESMTP id D1074C346 for ; Thu, 16 Apr 2015 13:48:38 +0200 (CEST) Received: by lbbzk7 with SMTP id zk7so56517776lbb.0 for ; Thu, 16 Apr 2015 04:48:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mirantis.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dvdfr3KyANWFYRZQ0EfCmUrG01urPtVXnO2v/pN9GHA=; b=I9DapjIH4u3nqZ8esZZY4zEvmvU+b1ggIeE6YWPxGBgGFc5IIDJZB7zQzIRlIKBjPp SAfpWZIPq5NJc22ZSzC+L2yejaQ2AhTITPFdrET6F0irrEOnlsfguchQDM5W+wS/6qNG vmbTT58f5b3nYlMnrPqWfwL1ixX9Vq35F+DZQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dvdfr3KyANWFYRZQ0EfCmUrG01urPtVXnO2v/pN9GHA=; b=CdIL5IsLWVp2CzJ5L7RROK8c8L+MiU6YKOpx6ZoNxwLjOQ9c8w9RWxQNX38iRGWzKT gxuhkTyjLo9FOVl4jCDyLcRvZbH7BhaU5du9gcgLTjEALL/uFxz1MO9yK3fCNmkJ6DWi f/wBdoJN2wDBv7EtRZEVofzi+/4PVFctZNKDrxSkV/YfSusUq9/oYpP/vgtVhroR3/5A SFpIqpDAsRahEAJtXSdOpcXugdraK0XJ06J72maVpz+5KifbUk3dlUqAS1mlfG0iYLDR kCK2jYx/ZVFe3c33TxuqjfH9q0PA0QSHzErwDoELXbAdwzkTDWssjiflUjCeE/PzKzqr XyPw== X-Gm-Message-State: ALoCoQlC8skwG+tMA98pWxzrmODXEPfpzMthEgGYS/ljHGobI4CqfMtIloc1KnrjNoUX/ZAxw28y X-Received: by 10.152.178.197 with SMTP id da5mr28889856lac.56.1429184918629; Thu, 16 Apr 2015 04:48:38 -0700 (PDT) Received: from pboldin-pc.kha.mirantis.net ([194.213.110.67]) by mx.google.com with ESMTPSA id oy3sm1636510lbb.1.2015.04.16.04.48.37 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Apr 2015 04:48:38 -0700 (PDT) From: Pavel Boldin To: dev@dpdk.org Date: Thu, 16 Apr 2015 14:48:29 +0300 Message-Id: <1429184910-30186-5-git-send-email-pboldin@mirantis.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1429184910-30186-1-git-send-email-pboldin@mirantis.com> References: <1427994080-10163-1-git-send-email-pboldin@mirantis.com> <1429184910-30186-1-git-send-email-pboldin@mirantis.com> Subject: [dpdk-dev] [PATCH v5 4/5] vhost: eventfd_link: replace copy-pasted sys_close X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Apr 2015 11:48:39 -0000 Replace copy-pasted `fget_from_files' -> `filp_close' with a `sys_close' call. Signed-off-by: Pavel Boldin --- lib/librte_vhost/eventfd_link/eventfd_link.c | 49 +++++++--------------------- 1 file changed, 12 insertions(+), 37 deletions(-) diff --git a/lib/librte_vhost/eventfd_link/eventfd_link.c b/lib/librte_vhost/eventfd_link/eventfd_link.c index 0a06594..9bc52a3 100644 --- a/lib/librte_vhost/eventfd_link/eventfd_link.c +++ b/lib/librte_vhost/eventfd_link/eventfd_link.c @@ -88,9 +88,8 @@ eventfd_link_ioctl_copy(unsigned long arg) { void __user *argp = (void __user *) arg; struct task_struct *task_target = NULL; - struct file *file; - struct files_struct *files; - struct fdtable *fdt; + struct file *target_file; + struct files_struct *target_files; struct eventfd_copy eventfd_copy; long ret = -EFAULT; @@ -109,51 +108,27 @@ eventfd_link_ioctl_copy(unsigned long arg) goto out; } - ret = -ESTALE; - files = get_files_struct(current); - if (files == NULL) { - pr_info("Failed to get current files struct\n"); - goto out_task; - } - - ret = -EBADF; - file = fget_from_files(files, eventfd_copy.source_fd); - - if (file == NULL) { - pr_info("Failed to get fd %d from source\n", - eventfd_copy.source_fd); - put_files_struct(files); + /* Closing the source_fd */ + ret = sys_close(eventfd_copy.source_fd); + if (ret) goto out_task; - } - - /* - * Release the existing eventfd in the source process - */ - spin_lock(&files->file_lock); - fput(file); - filp_close(file, files); - fdt = files_fdtable(files); - fdt->fd[eventfd_copy.source_fd] = NULL; - spin_unlock(&files->file_lock); - - put_files_struct(files); + ret = -ESTALE; /* * Find the file struct associated with the target fd. */ - ret = -ESTALE; - files = get_files_struct(task_target); - if (files == NULL) { + target_files = get_files_struct(task_target); + if (target_files == NULL) { pr_info("Failed to get target files struct\n"); goto out_task; } ret = -EBADF; - file = fget_from_files(files, eventfd_copy.target_fd); - put_files_struct(files); + target_file = fget_from_files(target_files, eventfd_copy.target_fd); + put_files_struct(target_files); - if (file == NULL) { + if (target_file == NULL) { pr_info("Failed to get fd %d from target\n", eventfd_copy.target_fd); goto out_task; @@ -164,7 +139,7 @@ eventfd_link_ioctl_copy(unsigned long arg) * file desciptor of the source process, */ - fd_install(eventfd_copy.source_fd, file); + fd_install(eventfd_copy.source_fd, target_file); ret = 0; out_task: -- 1.9.1