Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4877077imm; Fri, 18 May 2018 12:12:33 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrGFt1rQYqhbU5qtUCucHq/8e99EOAc2YYKqBG1jH7/hzG48Arz6Oj5WBgoa9lMylXryKxu X-Received: by 2002:a17:902:321:: with SMTP id 30-v6mr10653079pld.122.1526670753437; Fri, 18 May 2018 12:12:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526670753; cv=none; d=google.com; s=arc-20160816; b=hcfKvTje+5m/sBqY8WHnX2UrWBC8zlgKssksFAAGADRvjBOJBFX432oK+WWAj9ZNIC HpHXUWX2ViEogVLTRRtVLiuxG+1SfEnq/PVVBvHS/U2HzPZ+KIHszVPnHMcsu+5lXNvQ 295KmjJkzF8pgVT9Xn5V5WAmuChTSjZUEXZv2eQzqLscjv8Oyb7KwalRIoGeVRoqeOre U9/S4qzXxyUuWqsuUWsjACcDnbpj2U2atKCFZyAggeMLV/mL3xd/h2VcNbJy+FmjhNZT d211XFh6Fxcmr/laR4u3/1EBVt6qLm0/q4JNMtOB059kg6dvohIq1dYdpJdrjVbFo7tM HmGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:arc-authentication-results; bh=U1+pUFC5yqSy43J8EknPYXLtyazt+WAH8MpumnekVuA=; b=LQXWQqDsjnJRL/IDB4w97Z1oBCOrRpO8cd+mm1Y9AE1ax/e39K1j5j5TiCKfAm0LNO zCp3W6izliINYOZzWkqsHO1lzvbKGujrQZJskVP79FW5KNN+hY0OSkqVPsdQsABT7Hmx MhQjH2pr+OTRHnDFwd3jmcvskyaVWqYU3NN+YUOxg7YfyEZIOrTwLZ4DZP9L9jzjxfoF K6GHKKW9wirRuGA5ry6fCDgDvkuQUqkOyFF0wckK0SrQgX/xCGRISb5bM/87e9YZjDKS WB4MMpIE9d4POwRr+I3A/CmqlHtx9hWUZLA+45lL5R/iVwCj1cEAu2dFkCOaaKyehwdL /9bQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s186-v6si1786421pgc.602.2018.05.18.12.12.17; Fri, 18 May 2018 12:12:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752210AbeERTKm (ORCPT + 99 others); Fri, 18 May 2018 15:10:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49958 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751606AbeERTKi (ORCPT ); Fri, 18 May 2018 15:10:38 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9F721316C441; Fri, 18 May 2018 19:10:38 +0000 (UTC) Received: from gimli.home (ovpn-116-135.phx2.redhat.com [10.3.116.135]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A40760181; Fri, 18 May 2018 19:10:35 +0000 (UTC) Subject: [PATCH v4 2/2] vfio/mdev: Re-order sysfs attribute creation From: Alex Williamson To: kwankhede@nvidia.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, alex.williamson@redhat.com, cohuck@redhat.com, pasic@linux.ibm.com Date: Fri, 18 May 2018 13:10:35 -0600 Message-ID: <20180518191035.3187.77957.stgit@gimli.home> In-Reply-To: <20180518190145.3187.7620.stgit@gimli.home> References: <20180518190145.3187.7620.stgit@gimli.home> User-Agent: StGit/0.18-102-gdf9f MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 18 May 2018 19:10:38 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There exists a gap at the end of mdev_device_create() where the device is visible to userspace, but we're not yet ready to handle removal, as triggered through the 'remove' attribute. We handle this properly in mdev_device_remove() with an -EAGAIN return, but we can marginally reduce this gap by adding this attribute as a final step of our sysfs setup. Signed-off-by: Alex Williamson --- drivers/vfio/mdev/mdev_sysfs.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/vfio/mdev/mdev_sysfs.c b/drivers/vfio/mdev/mdev_sysfs.c index 802df210929b..249472f05509 100644 --- a/drivers/vfio/mdev/mdev_sysfs.c +++ b/drivers/vfio/mdev/mdev_sysfs.c @@ -257,24 +257,24 @@ int mdev_create_sysfs_files(struct device *dev, struct mdev_type *type) { int ret; - ret = sysfs_create_files(&dev->kobj, mdev_device_attrs); - if (ret) - return ret; - ret = sysfs_create_link(type->devices_kobj, &dev->kobj, dev_name(dev)); if (ret) - goto device_link_failed; + return ret; ret = sysfs_create_link(&dev->kobj, &type->kobj, "mdev_type"); if (ret) goto type_link_failed; + ret = sysfs_create_files(&dev->kobj, mdev_device_attrs); + if (ret) + goto create_files_failed; + return ret; +create_files_failed: + sysfs_remove_link(&dev->kobj, "mdev_type"); type_link_failed: sysfs_remove_link(type->devices_kobj, dev_name(dev)); -device_link_failed: - sysfs_remove_files(&dev->kobj, mdev_device_attrs); return ret; }