bus/vdev: fix wrong error log on secondary device scan

Message ID 20180827122732.5531-1-qi.z.zhang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series bus/vdev: fix wrong error log on secondary device scan |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Qi Zhang Aug. 27, 2018, 12:27 p.m. UTC
  When a secondary process handles VDEV_SCAN_ONE mp action, it is possible
the device is already be inserted. This happens when we have multiple
secondary processes which cause multiple broadcasts from primary during
bus->scan. So we don't need to log any error for -EEXIST.

Bugzilla ID: 84
Fixes: cdb068f031c6 ("bus/vdev: scan by multi-process channel")
Cc: stable@dpdk.org

Reported-by: Eads Gage <gage.eads@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
 drivers/bus/vdev/vdev.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Comments

Anatoly Burakov Aug. 27, 2018, 4:16 p.m. UTC | #1
On 27-Aug-18 1:27 PM, Qi Zhang wrote:
> When a secondary process handles VDEV_SCAN_ONE mp action, it is possible
> the device is already be inserted. This happens when we have multiple
> secondary processes which cause multiple broadcasts from primary during
> bus->scan. So we don't need to log any error for -EEXIST.
> 
> Bugzilla ID: 84
> Fixes: cdb068f031c6 ("bus/vdev: scan by multi-process channel")
> Cc: stable@dpdk.org
> 
> Reported-by: Eads Gage <gage.eads@intel.com>
> Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> ---
>   drivers/bus/vdev/vdev.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
> index 6139dd551..af9526fe6 100644
> --- a/drivers/bus/vdev/vdev.c
> +++ b/drivers/bus/vdev/vdev.c
> @@ -346,6 +346,7 @@ vdev_action(const struct rte_mp_msg *mp_msg, const void *peer)
>   	const struct vdev_param *in = (const struct vdev_param *)mp_msg->param;
>   	const char *devname;
>   	int num;
> +	int ret;
>   
>   	strlcpy(mp_resp.name, VDEV_MP_KEY, sizeof(mp_resp.name));
>   	mp_resp.len_param = sizeof(*ou);
> @@ -380,7 +381,10 @@ vdev_action(const struct rte_mp_msg *mp_msg, const void *peer)
>   		break;
>   	case VDEV_SCAN_ONE:
>   		VDEV_LOG(INFO, "receive vdev, %s", in->name);
> -		if (insert_vdev(in->name, NULL, NULL) < 0)
> +		ret = insert_vdev(in->name, NULL, NULL);
> +		if (ret == -EEXIST)
> +			VDEV_LOG(INFO, "device already exist, %s", in->name);

This is probably going to be printed a lot, and there's no real point in 
that. Maybe set log level to DEBUG instead?

> +		else if (ret < 0)
>   			VDEV_LOG(ERR, "failed to add vdev, %s", in->name);
>   		break;
>   	default:
>
  

Patch

diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index 6139dd551..af9526fe6 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -346,6 +346,7 @@  vdev_action(const struct rte_mp_msg *mp_msg, const void *peer)
 	const struct vdev_param *in = (const struct vdev_param *)mp_msg->param;
 	const char *devname;
 	int num;
+	int ret;
 
 	strlcpy(mp_resp.name, VDEV_MP_KEY, sizeof(mp_resp.name));
 	mp_resp.len_param = sizeof(*ou);
@@ -380,7 +381,10 @@  vdev_action(const struct rte_mp_msg *mp_msg, const void *peer)
 		break;
 	case VDEV_SCAN_ONE:
 		VDEV_LOG(INFO, "receive vdev, %s", in->name);
-		if (insert_vdev(in->name, NULL, NULL) < 0)
+		ret = insert_vdev(in->name, NULL, NULL);
+		if (ret == -EEXIST)
+			VDEV_LOG(INFO, "device already exist, %s", in->name);
+		else if (ret < 0)
 			VDEV_LOG(ERR, "failed to add vdev, %s", in->name);
 		break;
 	default: