From patchwork Fri Apr 12 21:05:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Verma, Vishal L" X-Patchwork-Id: 13628334 X-Patchwork-Delegate: patchwork-bot@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5108714EC53 for ; Fri, 12 Apr 2024 21:06:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712956003; cv=none; b=QwEnH4ZvmMXPTYkb304rF7quKOx3Lq3ho2/6gZGEyHexPcL4jzobE5W71gJ8nC7IXmOUrK0TFI5iPnLLxfC/fWn5cpKOeAmt1yc2R40w4OPwpUJk31KZR4VHGPjEgib3A9MuGX9XRDd7lp0CKsRWeaQV8Pcm3mPQTeLG7UhnoEA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712956003; c=relaxed/simple; bh=4OoKlgOE9tKbs4ksjOdP6+J+Tu5xTpeSXjhKP83Imbc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ulfnid6Pl7EDQsy39ppn+Hi7iKNXdEhx6ggIiZBUo9Jm71wUP3zPoMq4C/CCD8YmI4N+E1YnkcOth2iXg8szyo4Rw3zwtPQ8LMC9ZCkT4YfoDeLYYF58FdXEF/R/STHxIsjnyFfXir9s/lE1NcSxPL4po3WatIKW0p6QK2eoesE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=XctKZmpI; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="XctKZmpI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712956002; x=1744492002; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=4OoKlgOE9tKbs4ksjOdP6+J+Tu5xTpeSXjhKP83Imbc=; b=XctKZmpIfKI3qc5ymnsUo2eRFafd2LUZIei4OLgiVXa031OrOZPFUy77 lf0Z8Wyp0NpYHi0DUhuedBHlhsMoCWJuw9LOyyi8QiOUHo8ZC5eqC9b+A toiJwHuUSLiAZAOyzFIlVxWHo6KH9xESGQ1Hb+BwGB3NV8sgrpJF3mj81 J/mxv3Bv/+pWG2Ip/8Zl06cRs/VmHiPyDOtczz9yRZbOyn932rv4EGJj9 XRGG9ZN/Yqanv6IzBUjWuBLjdCp4Co5YeSP2ip8OY6+8MQYH797ZkmlYA MnnZ3c3p1uFYuECFsFbN/G/zeFZawTPgZtDL+HnSOBCFyNSJFnMWTH8jc w==; X-CSE-ConnectionGUID: 6igAPRYpSpuGRC/sxCWfWw== X-CSE-MsgGUID: m2aupxKeTjWCpA4wNj0I5g== X-IronPort-AV: E=McAfee;i="6600,9927,11042"; a="12211948" X-IronPort-AV: E=Sophos;i="6.07,197,1708416000"; d="scan'208";a="12211948" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2024 14:06:14 -0700 X-CSE-ConnectionGUID: o94hUSh4QzipNCfvniNrqg== X-CSE-MsgGUID: CASqLeUMSjKK+jZgOYGBdQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,197,1708416000"; d="scan'208";a="21909763" Received: from vverma7-desk1.amr.corp.intel.com (HELO [192.168.1.200]) ([10.213.183.147]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2024 14:06:12 -0700 From: Vishal Verma Date: Fri, 12 Apr 2024 15:05:39 -0600 Subject: [PATCH ndctl 1/2] daxctl/device.c: Handle special case of destroying daxX.0 Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240412-vv-daxctl-fixes-v1-1-6e808174e24f@intel.com> References: <20240412-vv-daxctl-fixes-v1-0-6e808174e24f@intel.com> In-Reply-To: <20240412-vv-daxctl-fixes-v1-0-6e808174e24f@intel.com> To: nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org Cc: Dan Williams , Alison Schofield , Dave Jiang , Ira Weiny , Vishal Verma X-Mailer: b4 0.14-dev-5ce50 X-Developer-Signature: v=1; a=openpgp-sha256; l=1450; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=4OoKlgOE9tKbs4ksjOdP6+J+Tu5xTpeSXjhKP83Imbc=; b=owGbwMvMwCXGf25diOft7jLG02pJDGmSi5yuHmfh9NGL/PJCYvozg5c9xrpXLgZx3PRvamOtb gvNCRPtKGVhEONikBVTZPm75yPjMbnt+TyBCY4wc1iZQIYwcHEKwEQUYxn+2XnHGNwP5pI708D7 ltHc6uL1Aytqm2XdMtoY5paun8JuxcjQ2Ru/b7eFMOthZvHU9TnTn4esqlotuVCu+szVG+ZdH+R 4AQ== X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF The kernel has special handling for destroying the 0th dax device under any given DAX region (daxX.0). It ensures the size is set to 0, but doesn't actually remove the device, instead it returns an EBUSY, indicating that this device cannot be removed. Add an expectation in daxctl's dev_destroy() helper to handle this case instead of returning the error - as far as the user is concerned, the size has been set to zero, and the destroy operation has been completed, even if the kernel indicated an EBUSY. Cc: Dan Williams Cc: Alison Schofield Reported-by: Ira Weiny Reported-by: Dave Jiang Signed-off-by: Vishal Verma Reviewed-by: Dan Williams Reviewed-by: Dave Jiang --- daxctl/device.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/daxctl/device.c b/daxctl/device.c index 83913430..83c61389 100644 --- a/daxctl/device.c +++ b/daxctl/device.c @@ -675,6 +675,13 @@ static int dev_destroy(struct daxctl_dev *dev) return rc; rc = daxctl_region_destroy_dev(daxctl_dev_get_region(dev), dev); + /* + * The kernel treats daxX.0 specially. It can't be deleted to ensure + * there is always a /sys/bus/dax/ present. If this happens, an + * EBUSY is returned. Expect it and don't treat it as an error. + */ + if (daxctl_dev_get_id(dev) == 0 && rc == -EBUSY) + return 0; if (rc < 0) return rc; From patchwork Fri Apr 12 21:05:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Verma, Vishal L" X-Patchwork-Id: 13628336 X-Patchwork-Delegate: patchwork-bot@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91DC214F122 for ; Fri, 12 Apr 2024 21:06:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712956011; cv=none; b=X/+P3NEjAFJve2MsPKgh44SxxlbuOOsZvE5+dOg38FzlK+6rpscAOW43KP3IEMxAK8qJp2D/g9jyUJ8t5ys0cAOOQ7d2nlGWOr/lgatywLKE2CZ/8fQJnaoZ/lCe8qiCTE+bONEE+pMRZhnD13cbWjcSOizPDwkC/Gnj4+CZeEQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712956011; c=relaxed/simple; bh=CSEdPdPYTjr5gHfBvjI2/VJYMO4SMTS2WFurQWRnuug=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sXU2TL0ricq0p8qgCf+MO0vyelhcSHLR4fpgaUNSrgRxCBw1NcXHQ7rClU0EY/kuuyIgcw+gp8IyXasQX7zuq2IVqDh68LKWBKRkwVPxd2ggFLyFg9LVvnY3UN5AKwkh/sYxn4yQ0M123p5RcSJgXthMEV3xSheMK0BTg3wcpvU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=TznaPaEg; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="TznaPaEg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712956009; x=1744492009; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=CSEdPdPYTjr5gHfBvjI2/VJYMO4SMTS2WFurQWRnuug=; b=TznaPaEgB6gcD9YdSgrNzjNkQKGJ3ea4x8aDZKl4UXxbDx7yvIuXvYIo gufUbZLnXtiN3ZHWxw7tdWNuVmhll6XlxtlsX81WSD3l1yqOYKZ/hD38r A8BB/NBHj8+sXs+Cmq2D5qhBbYZXyT/Ts87vu/xC8Y7J83wLAxtOVl+pE H27qwKN6DoAySj3YpJha641hIOWMUPs8tXd40Nx33C3XedRijg9l9SWGo ZGlwxmfZsiM+Y0XtOTAaip+ZBUfTzJjHdGikOxMZdiOPmJGJ3Nsv8gvQZ 84h86JlZU03KfQZP6QUPVlWsCxN+uSm4OSlns/5bk04P7+F4iOC+Ny015 g==; X-CSE-ConnectionGUID: K22F1k+wSF6hqc6LQ1O6WA== X-CSE-MsgGUID: 2u/d65tzTuSgIE8hPenD+g== X-IronPort-AV: E=McAfee;i="6600,9927,11042"; a="12211952" X-IronPort-AV: E=Sophos;i="6.07,197,1708416000"; d="scan'208";a="12211952" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2024 14:06:21 -0700 X-CSE-ConnectionGUID: +7qdXTwXRMOYzGYPZOPyEA== X-CSE-MsgGUID: ZtLyK7EISFG2CfvLsqMyjA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,197,1708416000"; d="scan'208";a="21909770" Received: from vverma7-desk1.amr.corp.intel.com (HELO [192.168.1.200]) ([10.213.183.147]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2024 14:06:12 -0700 From: Vishal Verma Date: Fri, 12 Apr 2024 15:05:40 -0600 Subject: [PATCH ndctl 2/2] daxctl/device.c: Fix error propagation in do_xaction_device() Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240412-vv-daxctl-fixes-v1-2-6e808174e24f@intel.com> References: <20240412-vv-daxctl-fixes-v1-0-6e808174e24f@intel.com> In-Reply-To: <20240412-vv-daxctl-fixes-v1-0-6e808174e24f@intel.com> To: nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org Cc: Dan Williams , Alison Schofield , Dave Jiang , Ira Weiny , Vishal Verma X-Mailer: b4 0.14-dev-5ce50 X-Developer-Signature: v=1; a=openpgp-sha256; l=1972; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=CSEdPdPYTjr5gHfBvjI2/VJYMO4SMTS2WFurQWRnuug=; b=owGbwMvMwCXGf25diOft7jLG02pJDGmSi5zmtUwysZc/7huavtrHtX/bgdnP1jzUdY6qfTB/1 0uP9B9LO0pZGMS4GGTFFFn+7vnIeExuez5PYIIjzBxWJpAhDFycAjCRrgCGf2btKvvX+H07tEB5 Y97M8ASBWRcMDl8+8V9xk4NM7nQLQSaG/5FOHAc+hH5mrb1Vczr9Zuj0k+xPcmv/pH3Z6lY64Vm tByMA X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF The loop through the provided list of devices in do_xaction_device() returns the status based on whatever the last device did. Since the order of processing devices, especially in cases like the 'all' keyword, can be effectively random, this can lead to the same command, and same effects, exiting with a different error code based on device ordering. This was noticed with flakiness in the daxctl-create.sh unit test. Its 'destroy-device all' command would either pass or fail based on the order it tried to destroy devices in. (Recall that until now, destroying a daxX.0 device would result in a failure). Make this slightly more consistent by saving a failed status in do_xaction_device if any iteration of the loop produces a failure. Return this saved status instead of returning the status of the last device processed. Cc: Dan Williams Cc: Alison Schofield Signed-off-by: Vishal Verma Reviewed-by: Dan Williams Reviewed-by: Dave Jiang --- daxctl/device.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/daxctl/device.c b/daxctl/device.c index 83c61389..14d62148 100644 --- a/daxctl/device.c +++ b/daxctl/device.c @@ -1012,7 +1012,7 @@ static int do_xaction_device(const char *device, enum device_action action, struct json_object *jdevs = NULL; struct daxctl_region *region; struct daxctl_dev *dev; - int rc = -ENXIO; + int rc = -ENXIO, saved_rc = 0; *processed = 0; @@ -1059,6 +1059,8 @@ static int do_xaction_device(const char *device, enum device_action action, rc = -EINVAL; break; } + if (rc) + saved_rc = rc; } } @@ -1070,7 +1072,7 @@ static int do_xaction_device(const char *device, enum device_action action, if (jdevs) util_display_json_array(stdout, jdevs, flags); - return rc; + return saved_rc; } int cmd_create_device(int argc, const char **argv, struct daxctl_ctx *ctx)