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: 13628338 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 A787C14EC53 for ; Fri, 12 Apr 2024 21:06:48 +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=1712956010; cv=none; b=K4DRozQqwf4jkA3CzZFNU+PKtofL4Fgd0Ddubw1yedHOlS/F3IYCDewIgZ/u+WiZEJsIjGzD0KXqZQGsoIXSzX3z11F9wjGeh7w32NwbexGZ/AykMhwsUzjp+fu8Tsh53M0Lpl+RSAYO2Ob2O6E0kyQ22PRifcWadf9Za6v9fc8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712956010; c=relaxed/simple; bh=4OoKlgOE9tKbs4ksjOdP6+J+Tu5xTpeSXjhKP83Imbc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=m6nJt0GufPYl4LUsidntdPOrezk+n7JGjbgDFR1MNga7u/hD61wbI5ASqsDBm8bukkTxRs6d9zASmqATjI3pOWjBOG/62eWNrmus1zSg7mpJrvku8g+AfovPDpeKdMj3/6keDvalJs6ROrcuuYLrVDxuhcXzH7F+DzLcsEsrvoA= 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=j3lVAIFx; 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="j3lVAIFx" 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=4OoKlgOE9tKbs4ksjOdP6+J+Tu5xTpeSXjhKP83Imbc=; b=j3lVAIFxkwlKYF/dsPmGWD/9lOA1tE6Pc2Y9C3IMlQM/UBgnZ+FfaTGm 5SxV+Tw7iVhpiHj9S35yYbr1o4IowNuJmtHbSAnQ3f3UylJn5u8d98TUT BAoYavzPyNBtG8kxGs1dKa5Z/ZXWOhPfwJnjyCAwLM9yGcx6ujnkqfLGw KEAMM7P4gsGLgV7P661tpt5ThaXbSFm9w4G+Meh2M95b6iAeVxOLYZ/Cg Fx/Jw4ZIVlo53wPzqn9bEmGEg2rMU5L62Os421Csz1/paQ4K62R0WYg/z 57WEduBXutMcyrBq0Y+uFuZujfCUoByhsWa8Y/HAL6RD/AfbJODq9Gg+Q g==; X-CSE-ConnectionGUID: EOCBsmKfSnqFDMCy7bo2RQ== X-CSE-MsgGUID: Vk3fD2tNRhil+yR8nupN6Q== X-IronPort-AV: E=McAfee;i="6600,9927,11042"; a="12211947" X-IronPort-AV: E=Sophos;i="6.07,197,1708416000"; d="scan'208";a="12211947" 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: linux-cxl@vger.kernel.org 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: 13628337 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 5061814BF9B 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=1712956004; cv=none; b=Ku8wbsQh6FNwFTpXQrlhTbEFsU6LKHXf1B/18jIlnVneY7keXSy/uEu2wghEqyb2uD3qmRkZCFD29Z2lHMpZJKw7S9I1cLDnDDVC2FZzMaBzvWODPFY4+Ztt7K8BJTTsr/vcbsdi/Hbm+5EF6R0UjLX5VozQvrn5tFjGohQouPs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712956004; c=relaxed/simple; bh=CSEdPdPYTjr5gHfBvjI2/VJYMO4SMTS2WFurQWRnuug=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WXSp0ONGbLKO7lyfT7/Qve10Xig7tcx5RkEUM8No0FRoIedlbSOJuX8Om4AiD+PMSAG+vDkUqn9ZeVUASHvfyPAtJjHlxGOoBdmUAbQQVKPl0VLMux4P1phNtU2BEZxSuEXSEs5M4/LDKH5/S5IVUZdHSkWoWuh2KxjRGrLbr1c= 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=SDnQBlC+; 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="SDnQBlC+" 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=CSEdPdPYTjr5gHfBvjI2/VJYMO4SMTS2WFurQWRnuug=; b=SDnQBlC+mBE067tC925ZeDGFgjjoQze64ul979apiInH6WlTjZgVQ/Nd 38yjWX0JJp3uzny5tVXQiyeOTWpU5ZN4xkR4I6z+upzRLxFwHQS/mONP3 edGYvWk87daYjsRNqnxD45XFs2MlILOcv6Ww5FyShL2h7hSrBEE4oBcd/ b8Cq2Fi9LrvITxgbvPYj6KgEicVK/wK5h5v3UHE1rpFgmWE8W5yPfYeWF GmDYOGYJYAtguPfNZLZk7JE+pppmRao2+lmpw7E59VbggURbQQGuBw96h 80PQOb9TYFWT6vtwMt+S90yGpKptHmMZB+q9cB/toxOdWVuikooTtxAuO w==; X-CSE-ConnectionGUID: 9WG7GVSTRZqiXgAR5mZdmg== X-CSE-MsgGUID: ZAJtOPZvQ7+6ZyrohKTHjQ== X-IronPort-AV: E=McAfee;i="6600,9927,11042"; a="12211951" X-IronPort-AV: E=Sophos;i="6.07,197,1708416000"; d="scan'208";a="12211951" 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: linux-cxl@vger.kernel.org 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)