Skip to contentSkip to conversation

fs: dlm: use __func__ for function name

PATCH Superseded Alexander Aring 1 participant 3 messages Jul 20, 2022 Distributed lock manager (DLM)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Alexander Aring

author maintainer
#0 lore raw

PATCH 1/2 fs: dlm: use __func__ for function name

There are several times of using hard-coded function names inside the format string. When changing code checkpatch will drop a warning about this. This patch prepares to not dropping a checkpatch warning when introduce the same log message for a different loglevel by using __func__ instead of a hard-coded function name.

---
 fs/dlm/lock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/dlm/lock.c +2 -2
index c23413da40f5..d8de4003ec6a 100644
@@ -2901,7 +2901,7 @@ static int validate_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
 	rv = 0;
  out:
 	if (rv)
-		log_debug(ls, "validate_lock_args %d %x %x %x %d %d %s",
+		log_debug(ls, "%s %d %x %x %x %d %d %s", __func__,
 			  rv, lkb->lkb_id, lkb->lkb_flags, args->flags,
 			  lkb->lkb_status, lkb->lkb_wait_type,
 			  lkb->lkb_resource->res_name);
@@ -3038,7 +3038,7 @@ static int validate_unlock_args(struct dlm_lkb *lkb, struct dlm_args *args)
 	rv = 0;
  out:
 	if (rv)
-		log_debug(ls, "validate_unlock_args %d %x %x %x %x %d %s", rv,
+		log_debug(ls, "%s %d %x %x %x %x %d %s", __func__, rv,
 			  lkb->lkb_id, lkb->lkb_flags, lkb->lkb_exflags,
 			  args->flags, lkb->lkb_wait_type,
 			  lkb->lkb_resource->res_name);
Signature · 1 line
2.31.1
author maintainer
#1 lore raw

PATCH 2/2 fs: dlm: handle -EINVAL as log_error()

If the user generates a -EINVAL it's probably because the user using DLM wrong. To give the user notice about that wrong behaviour we should always print -EINVAL errors on the proper loglevel. In case of other errors like -EBUSY it will be still printed on debug loglevel as the current API handles it as "retry again".

---
 fs/dlm/lock.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)
fs/dlm/lock.c +22 -2
index d8de4003ec6a..7d5f94867e45 100644
@@ -2900,11 +2900,21 @@ static int validate_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
 #endif
 	rv = 0;
  out:
-	if (rv)
+	switch (rv) {
+	case -EINVAL:
+		log_error(ls, "%s %d %x %x %x %d %d %s", __func__,
+			  rv, lkb->lkb_id, lkb->lkb_flags, args->flags,
+			  lkb->lkb_status, lkb->lkb_wait_type,
+			  lkb->lkb_resource->res_name);
+		break;
+	default:
 		log_debug(ls, "%s %d %x %x %x %d %d %s", __func__,
 			  rv, lkb->lkb_id, lkb->lkb_flags, args->flags,
 			  lkb->lkb_status, lkb->lkb_wait_type,
 			  lkb->lkb_resource->res_name);
+		break;
+	}
+
 	return rv;
 }
 
@@ -3037,11 +3047,21 @@ static int validate_unlock_args(struct dlm_lkb *lkb, struct dlm_args *args)
 	lkb->lkb_astparam = args->astparam;
 	rv = 0;
  out:
-	if (rv)
+	switch (rv) {
+	case -EINVAL:
+		log_error(ls, "%s %d %x %x %x %x %d %s", __func__, rv,
+			  lkb->lkb_id, lkb->lkb_flags, lkb->lkb_exflags,
+			  args->flags, lkb->lkb_wait_type,
+			  lkb->lkb_resource->res_name);
+		break;
+	default:
 		log_debug(ls, "%s %d %x %x %x %x %d %s", __func__, rv,
 			  lkb->lkb_id, lkb->lkb_flags, lkb->lkb_exflags,
 			  args->flags, lkb->lkb_wait_type,
 			  lkb->lkb_resource->res_name);
+		break;
+	}
+
 	return rv;
 }
 
Signature · 1 line
2.31.1
author maintainer
#2 lore raw

PATCH 2/2 fs: dlm: handle -EINVAL as log_error()

Hi,

Quoted 49 lines · Alexander Aring

If the user generates a -EINVAL it's probably because the user using DLM wrong. To give the user notice about that wrong behaviour we should always print -EINVAL errors on the proper loglevel. In case of other errors like -EBUSY it will be still printed on debug loglevel as the current API handles it as "retry again".

---
 fs/dlm/lock.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)
fs/dlm/lock.c +16 -2
index d8de4003ec6a..7d5f94867e45 100644
@@ -2900,11 +2900,21 @@ static int validate_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
 #endif
        rv = 0;
  out:
-       if (rv)
+       switch (rv) {
+       case -EINVAL:
+               log_error(ls, "%s %d %x %x %x %d %d %s", __func__,
+                         rv, lkb->lkb_id, lkb->lkb_flags, args->flags,
+                         lkb->lkb_status, lkb->lkb_wait_type,
+                         lkb->lkb_resource->res_name);
+               break;
+       default:
                log_debug(ls, "%s %d %x %x %x %d %d %s", __func__,
                          rv, lkb->lkb_id, lkb->lkb_flags, args->flags,
                          lkb->lkb_status, lkb->lkb_wait_type,
                          lkb->lkb_resource->res_name);
+               break;
+       }
+
        return rv;
 }
 
@@ -3037,11 +3047,21 @@ static int validate_unlock_args(struct dlm_lkb *lkb, struct dlm_args *args)
        lkb->lkb_astparam = args->astparam;
        rv = 0;
  out:
-       if (rv)
+       switch (rv) {
+       case -EINVAL:
+               log_error(ls, "%s %d %x %x %x %x %d %s", __func__, rv,
+                         lkb->lkb_id, lkb->lkb_flags, lkb->lkb_exflags,
+                         args->flags, lkb->lkb_wait_type,

fs/dlm/lock.c static int validate_unlock_args(struct dlm_lkb *lkb, struct dlm_args *args) · line 3064

Quoted 10 lines
fs/dlm/lock.c +6 -0
+                         lkb->lkb_resource->res_name);
+               break;
+       default:
                log_debug(ls, "%s %d %x %x %x %x %d %s", __func__, rv,
                          lkb->lkb_id, lkb->lkb_flags, lkb->lkb_exflags,
                          args->flags, lkb->lkb_wait_type,
                          lkb->lkb_resource->res_name);
+               break;
+       }
+

there need to be a case 0: which does nothing of course... will send a v2.

- Alex