File 0027-LU-15220-lustre-use-fallthrough-pseudo-keyword-for-s.patch of Package lustre_2_12

From e85b316ff9110c9c37625e2c27e343da12d31609 Mon Sep 17 00:00:00 2001
From: Jian Yu <yujian@whamcloud.com>
Date: Sat, 22 Jan 2022 18:21:04 -0800
Subject: [PATCH 27/35] LU-15220 lustre: use 'fallthrough' pseudo keyword for
 switch

'/* fallthrough */' hits implicit-fallthrough error with GCC 11.

This patch replaces the existing '/* fallthrough */' comments and
its variants with the 'fallthrough' pseudo keyword, which was added
by Linux kernel commit v5.4-rc2-141-g294f69e662d1.

Test-Parameters: trivial
Change-Id: Icace4c9953950f86d3c48068d8c6bba7dd1160a6
Signed-off-by: Jian Yu <yujian@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/46269
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Peter Jones <pjones@whamcloud.com>
---
 lustre/include/lustre_compat.h   |  4 ++++
 lustre/ldlm/ldlm_request.c       |  2 +-
 lustre/lfsck/lfsck_layout.c      |  4 ++--
 lustre/lfsck/lfsck_namespace.c   |  6 +++---
 lustre/llite/file.c              |  4 ++--
 lustre/llite/namei.c             |  6 +++---
 lustre/lod/lod_object.c          |  2 +-
 lustre/lod/lod_qos.c             |  6 +++---
 lustre/lov/lov_object.c          |  1 +
 lustre/mdt/mdt_coordinator.c     |  2 +-
 lustre/mdt/mdt_handler.c         |  5 +++--
 lustre/mgs/mgs_barrier.c         |  4 ++--
 lustre/mgs/mgs_llog.c            |  2 +-
 lustre/obdclass/lprocfs_status.c |  8 ++++----
 lustre/obdecho/echo_client.c     | 12 ++++++------
 lustre/osc/osc_cache.c           |  2 +-
 lustre/osd-zfs/osd_object.c      |  1 +
 lustre/ptlrpc/gss/gss_keyring.c  |  8 ++++----
 lustre/ptlrpc/gss/sec_gss.c      |  2 +-
 lustre/ptlrpc/lproc_ptlrpc.c     | 11 ++++++-----
 lustre/ptlrpc/pack_generic.c     |  8 ++++----
 lustre/quota/qmt_handler.c       |  4 ++--
 22 files changed, 56 insertions(+), 48 deletions(-)

diff --git a/lustre/include/lustre_compat.h b/lustre/include/lustre_compat.h
index 336c6ab12a6d..70c8cae1505d 100644
--- a/lustre/include/lustre_compat.h
+++ b/lustre/include/lustre_compat.h
@@ -847,6 +847,10 @@ static inline int ll_vfs_removexattr(struct dentry *dentry, struct inode *inode,
 #endif
 }
 
+#ifndef fallthrough
+#define fallthrough do {} while (0)  /* fallthrough */
+#endif
+
 #ifndef HAVE_USER_NAMESPACE_ARG
 #define posix_acl_update_mode(ns, inode, mode, acl) \
 	posix_acl_update_mode(inode, mode, acl)
diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c
index 6f7b7bb8a744..a206133b0192 100644
--- a/lustre/ldlm/ldlm_request.c
+++ b/lustre/ldlm/ldlm_request.c
@@ -1539,7 +1539,7 @@ ldlm_cancel_no_wait_policy(struct ldlm_namespace *ns, struct ldlm_lock *lock,
 		case LDLM_IBITS:
 			if (ns->ns_cancel != NULL && ns->ns_cancel(lock) != 0)
 				break;
-			/* fallthrough */
+			fallthrough;
 		default:
 			result = LDLM_POLICY_SKIP_LOCK;
 			break;
diff --git a/lustre/lfsck/lfsck_layout.c b/lustre/lfsck/lfsck_layout.c
index 76ec6c7c6d7e..f7ad14138edb 100644
--- a/lustre/lfsck/lfsck_layout.c
+++ b/lustre/lfsck/lfsck_layout.c
@@ -6878,7 +6878,7 @@ int lfsck_layout_setup(const struct lu_env *env, struct lfsck_instance *lfsck)
 	default:
 		CERROR("%s: unknown lfsck_layout status %d\n",
 		       lfsck_lfsck2name(lfsck), lo->ll_status);
-		/* fall through */
+		fallthrough;
 	case LS_SCANNING_PHASE1:
 	case LS_SCANNING_PHASE2:
 		/* No need to store the status to disk right now.
@@ -6887,7 +6887,7 @@ int lfsck_layout_setup(const struct lu_env *env, struct lfsck_instance *lfsck)
 		lo->ll_status = LS_CRASHED;
 		if (!lfsck->li_master)
 			lo->ll_flags |= LF_INCOMPLETE;
-		/* fall through */
+		fallthrough;
 	case LS_PAUSED:
 	case LS_CRASHED:
 	case LS_CO_FAILED:
diff --git a/lustre/lfsck/lfsck_namespace.c b/lustre/lfsck/lfsck_namespace.c
index a7103ac96706..cff18a13c8b0 100644
--- a/lustre/lfsck/lfsck_namespace.c
+++ b/lustre/lfsck/lfsck_namespace.c
@@ -3619,7 +3619,7 @@ static int lfsck_namespace_double_scan_one(const struct lu_env *env,
 
 			repaired = true;
 
-			/* fall through */
+			fallthrough;
 		}
 
 		parent = lfsck_object_find_bottom(env, lfsck, pfid);
@@ -6910,14 +6910,14 @@ int lfsck_namespace_setup(const struct lu_env *env,
 	default:
 		CERROR("%s: unknown lfsck_namespace status %d\n",
 		       lfsck_lfsck2name(lfsck), ns->ln_status);
-		/* fall through */
+		fallthrough;
 	case LS_SCANNING_PHASE1:
 	case LS_SCANNING_PHASE2:
 		/* No need to store the status to disk right now.
 		 * If the system crashed before the status stored,
 		 * it will be loaded back when next time. */
 		ns->ln_status = LS_CRASHED;
-		/* fall through */
+		fallthrough;
 	case LS_PAUSED:
 	case LS_CRASHED:
 		spin_lock(&lfsck->li_lock);
diff --git a/lustre/llite/file.c b/lustre/llite/file.c
index 80b9c7772f1f..8442c7ffe7d9 100644
--- a/lustre/llite/file.c
+++ b/lustre/llite/file.c
@@ -157,7 +157,7 @@ static int ll_close_inode_openhandle(struct inode *inode,
 		op_data->op_attr_blocks += ((struct inode *)data)->i_blocks;
 		op_data->op_attr.ia_valid |= ATTR_SIZE;
 		op_data->op_xvalid |= OP_XVALID_BLOCKS;
-		/* fallthrough */
+		fallthrough;
 	case MDS_CLOSE_LAYOUT_SPLIT:
 	case MDS_CLOSE_LAYOUT_SWAP: {
 		struct split_param *sp = data;
@@ -2942,7 +2942,7 @@ static int ll_ladvise_sanity(struct inode *inode,
 			       ladvise_names[advice], rc);
 			GOTO(out, rc);
 		}
-		/* fallthrough */
+		fallthrough;
 	case LU_LADVISE_WILLREAD:
 	case LU_LADVISE_DONTNEED:
 	default:
diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c
index 47ae228d0736..f060597a953f 100644
--- a/lustre/llite/namei.c
+++ b/lustre/llite/namei.c
@@ -410,13 +410,13 @@ int ll_md_need_convert(struct ldlm_lock *lock)
 	switch (lock->l_req_mode) {
 	case LCK_PR:
 		mode = LCK_PR;
-		/* fallthrough */
+		fallthrough;
 	case LCK_PW:
 		mode |= LCK_CR;
 		break;
 	case LCK_CW:
 		mode = LCK_CW;
-		/* fallthrough */
+		fallthrough;
 	case LCK_CR:
 		mode |= LCK_CR;
 		break;
@@ -1403,7 +1403,7 @@ static int ll_mknod(struct user_namespace *mnt_userns, struct inode *dir,
 	switch (mode & S_IFMT) {
 	case 0:
 		mode |= S_IFREG;
-		/* fallthrough */
+		fallthrough;
 	case S_IFREG:
 	case S_IFCHR:
 	case S_IFBLK:
diff --git a/lustre/lod/lod_object.c b/lustre/lod/lod_object.c
index ada0d40758e3..8870809aef16 100644
--- a/lustre/lod/lod_object.c
+++ b/lustre/lod/lod_object.c
@@ -3646,7 +3646,7 @@ static int lod_xattr_set_lov_on_dir(const struct lu_env *env,
 		v3 = buf->lb_buf;
 		if (v3->lmm_pool_name[0] != '\0')
 			pool_name = v3->lmm_pool_name;
-		/* fall through */
+		fallthrough;
 	case LOV_USER_MAGIC_V1:
 		/* if { size, offset, count } = { 0, -1, 0 } and no pool
 		 * (i.e. all default values specified) then delete default
diff --git a/lustre/lod/lod_qos.c b/lustre/lod/lod_qos.c
index ebb36c0e55b9..b92ef0e86d2a 100644
--- a/lustre/lod/lod_qos.c
+++ b/lustre/lod/lod_qos.c
@@ -1995,13 +1995,13 @@ int lod_qos_parse_config(const struct lu_env *env, struct lod_object *lo,
 	case __swab32(LOV_USER_MAGIC_V1):
 		lustre_swab_lov_user_md_v1(v1);
 		magic = v1->lmm_magic;
-		/* fall through */
+		fall through;
 	case LOV_USER_MAGIC_V1:
 		break;
 	case __swab32(LOV_USER_MAGIC_V3):
 		lustre_swab_lov_user_md_v3(v3);
 		magic = v3->lmm_magic;
-		/* fall through */
+		fall through;
 	case LOV_USER_MAGIC_V3:
 		break;
 	case __swab32(LOV_USER_MAGIC_SPECIFIC):
@@ -2009,7 +2009,7 @@ int lod_qos_parse_config(const struct lu_env *env, struct lod_object *lo,
 		lustre_swab_lov_user_md_objects(v3->lmm_objects,
 						v3->lmm_stripe_count);
 		magic = v3->lmm_magic;
-		/* fall through */
+		fall through;
 	case LOV_USER_MAGIC_SPECIFIC:
 		break;
 	case __swab32(LOV_USER_MAGIC_COMP_V1):
diff --git a/lustre/lov/lov_object.c b/lustre/lov/lov_object.c
index f9f3522806a4..590a2009a87e 100644
--- a/lustre/lov/lov_object.c
+++ b/lustre/lov/lov_object.c
@@ -2164,6 +2164,7 @@ int lov_read_and_clear_async_rc(struct cl_object *clob)
 				}
 			}
 		}
+		fallthrough;
 		case LLT_RELEASED:
 		case LLT_EMPTY:
 			break;
diff --git a/lustre/mdt/mdt_coordinator.c b/lustre/mdt/mdt_coordinator.c
index 808b38d216d9..c50c38b7e5ef 100644
--- a/lustre/mdt/mdt_coordinator.c
+++ b/lustre/mdt/mdt_coordinator.c
@@ -293,7 +293,7 @@ static int mdt_cdt_waiting_cb(const struct lu_env *env,
 		break;
 	case HSMA_RESTORE:
 		hsd->hsd_one_restore = true;
-		/* Intentional fallthrough */
+		fallthrough;
 	default:
 		cdt_agent_record_hash_add(cdt, hai->hai_cookie,
 					  llh->lgh_hdr->llh_cat_idx,
diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c
index 24cee1e96f66..6cd20bda48d1 100644
--- a/lustre/mdt/mdt_handler.c
+++ b/lustre/mdt/mdt_handler.c
@@ -2732,14 +2732,14 @@ static int mdt_quotactl(struct tgt_session_info *tsi)
 	case LUSTRE_Q_SETDEFAULT:
 		if (!nodemap_can_setquota(nodemap))
 			GOTO(out_nodemap, rc = -EPERM);
-		/* fallthrough */
+		fallthrough;
 	case Q_GETINFO:
 	case Q_GETQUOTA:
 	case LUSTRE_Q_GETDEFAULT:
 		if (qmt == NULL)
 			GOTO(out_nodemap, rc = -EOPNOTSUPP);
 		/* slave quotactl */
-		/* fallthrough */
+		fallthrough;
 	case Q_GETOINFO:
 	case Q_GETOQUOTA:
 		break;
@@ -4323,6 +4323,7 @@ static int mdt_intent_opc(enum ldlm_intent_flags it_opc,
 		break;
 	case IT_GETATTR:
 		check_mdt_object = true;
+		fallthrough;
 	case IT_LOOKUP:
 		it_format = &RQF_LDLM_INTENT_GETATTR;
 		it_handler = &mdt_intent_getattr;
diff --git a/lustre/mgs/mgs_barrier.c b/lustre/mgs/mgs_barrier.c
index 7ea09157670b..490f48a41c1a 100644
--- a/lustre/mgs/mgs_barrier.c
+++ b/lustre/mgs/mgs_barrier.c
@@ -358,7 +358,7 @@ static int mgs_barrier_freeze(const struct lu_env *env,
 			rc = -EALREADY;
 			break;
 		}
-		/* fallthrough */
+		fallthrough;
 	case BS_INIT:
 	case BS_THAWED:
 	case BS_EXPIRED:
@@ -684,7 +684,7 @@ static int mgs_barrier_rescan(const struct lu_env *env,
 			rc = -EBUSY;
 			break;
 		}
-		/* fallthrough */
+		fallthrough;
 	case BS_INIT:
 	case BS_THAWED:
 	case BS_EXPIRED:
diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c
index 95e34f35acf0..bb07175d2e8c 100644
--- a/lustre/mgs/mgs_llog.c
+++ b/lustre/mgs/mgs_llog.c
@@ -4713,7 +4713,7 @@ static int mgs_lcfg_fork_handler(const struct lu_env *env,
 			} /* else case fall through */
 		} /* else case fall through */
 	}
-	/* fallthrough */
+		fallthrough;
 	default: {
 		for (i = 1; i < cnt; i++) {
 			o_buflen = o_lcfg->lcfg_buflens[i];
diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c
index 5f1b2799b2f5..02a1ca87337d 100644
--- a/lustre/obdclass/lprocfs_status.c
+++ b/lustre/obdclass/lprocfs_status.c
@@ -1808,19 +1808,19 @@ static int get_mult(char unit, __u64 *mult)
 	case 'p':
 	case 'P':
 		units <<= 10;
-		/* fallthrough */
+		fallthrough;
 	case 't':
 	case 'T':
 		units <<= 10;
-		/* fallthrough */
+		fallthrough;
 	case 'g':
 	case 'G':
 		units <<= 10;
-		/* fallthrough */
+		fallthrough;
 	case 'm':
 	case 'M':
 		units <<= 10;
-		/* fallthrough */
+		fallthrough;
 	case 'k':
 	case 'K':
 		units <<= 10;
diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c
index 78cd38aa86d7..f9e141bac778 100644
--- a/lustre/obdecho/echo_client.c
+++ b/lustre/obdecho/echo_client.c
@@ -977,17 +977,17 @@ out:
                         CERROR("Cleanup obd device %s error(%d)\n",
                                obd->obd_name, rc2);
         }
-	/* fallthrough */
+	fallthrough;
 
 	case 3:
 		echo_site_fini(env, ed);
-		/* fallthrough */
+		fallthrough;
 	case 2:
 		cl_device_fini(&ed->ed_cl);
-		/* fallthrough */
+		fallthrough;
 	case 1:
 		OBD_FREE_PTR(ed);
-		/* fallthrough */
+		fallthrough;
 	case 0:
 	default:
 		break;
@@ -2717,7 +2717,7 @@ static int echo_client_brw_ioctl(const struct lu_env *env, int rw,
 
         switch (test_mode) {
         case 1:
-                /* fall through */
+                fallthrough;
         case 2:
 		rc = echo_client_kbrw(ed, rw, oa, eco, data->ioc_offset,
 				      data->ioc_count, async);
@@ -2903,7 +2903,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                         GOTO (out, rc = -EPERM);
 
                 rw = OBD_BRW_WRITE;
-                /* fall through */
+                fallthrough;
         case OBD_IOC_BRW_READ:
 		rc = echo_client_brw_ioctl(env, rw, exp, data);
                 GOTO(out, rc);
diff --git a/lustre/osc/osc_cache.c b/lustre/osc/osc_cache.c
index 5652e74222be..4bae208d145f 100644
--- a/lustre/osc/osc_cache.c
+++ b/lustre/osc/osc_cache.c
@@ -216,7 +216,7 @@ static int osc_extent_sanity_check0(struct osc_extent *ext,
 			GOTO(out, rc = 60);
 		if (ext->oe_fsync_wait && !ext->oe_urgent && !ext->oe_hp)
 			GOTO(out, rc = 65);
-		/* fallthrough */
+		fallthrough;
 	default:
 		if (atomic_read(&ext->oe_users) > 0)
 			GOTO(out, rc = 70);
diff --git a/lustre/osd-zfs/osd_object.c b/lustre/osd-zfs/osd_object.c
index 3b7ac6801ad4..6b1da069cbd7 100644
--- a/lustre/osd-zfs/osd_object.c
+++ b/lustre/osd-zfs/osd_object.c
@@ -1489,6 +1489,7 @@ static int osd_declare_create(const struct lu_env *env, struct dt_object *dt,
 	switch (dof->dof_type) {
 		case DFT_DIR:
 			dt->do_index_ops = &osd_dir_ops;
+			fallthrough;
 		case DFT_INDEX:
 			/* for zap create */
 			dmu_tx_hold_zap(oh->ot_tx, DMU_NEW_OBJECT, FALSE, NULL);
diff --git a/lustre/ptlrpc/gss/gss_keyring.c b/lustre/ptlrpc/gss/gss_keyring.c
index 15bf99427489..845269c8acec 100644
--- a/lustre/ptlrpc/gss/gss_keyring.c
+++ b/lustre/ptlrpc/gss/gss_keyring.c
@@ -690,24 +690,24 @@ static void request_key_unlink(struct key *key)
 				break;
 		}
 #endif
-		/* fall through */
+		fallthrough;
 	case KEY_REQKEY_DEFL_THREAD_KEYRING:
 		ring = key_get(cred->thread_keyring);
 		if (ring)
 			break;
-		/* fallthrough */
+		fallthrough;
 	case KEY_REQKEY_DEFL_PROCESS_KEYRING:
 		ring = key_get(cred->process_keyring);
 		if (ring)
 			break;
-		/* fallthrough */
+		fallthrough;
 	case KEY_REQKEY_DEFL_SESSION_KEYRING:
 		rcu_read_lock();
 		ring = key_get(rcu_dereference(cred->session_keyring));
 		rcu_read_unlock();
 		if (ring)
 			break;
-		/* fallthrough */
+		fallthrough;
 	case KEY_REQKEY_DEFL_USER_SESSION_KEYRING:
 		ring = get_user_session_keyring(cred);
 		break;
diff --git a/lustre/ptlrpc/gss/sec_gss.c b/lustre/ptlrpc/gss/sec_gss.c
index 845bfbca44d5..17e8f0a258c6 100644
--- a/lustre/ptlrpc/gss/sec_gss.c
+++ b/lustre/ptlrpc/gss/sec_gss.c
@@ -534,7 +534,7 @@ int gss_check_seq_num(struct gss_svc_seq_data *ssd, __u32 seq_num, int set)
                 switch (rc) {
                 case -1:
                         gss_stat_oos_record_svc(1, 1);
-                        /* fall through */
+			fallthrough;
                 case 0:
                         goto exit;
                 }
diff --git a/lustre/ptlrpc/lproc_ptlrpc.c b/lustre/ptlrpc/lproc_ptlrpc.c
index d673128ba16f..51196e45f528 100644
--- a/lustre/ptlrpc/lproc_ptlrpc.c
+++ b/lustre/ptlrpc/lproc_ptlrpc.c
@@ -1013,11 +1013,12 @@ void target_print_req(void *seq_file, struct ptlrpc_request *req)
                 break;
         case RQ_PHASE_INTERPRET:
                 /* being handled, so basic msg swabbed, and opc is valid
-                 * but racing with mds_handle() */
-        case RQ_PHASE_COMPLETE:
-                /* been handled by mds_handle() reply state possibly still
-                 * volatile */
-                seq_printf(sf, "opc %d\n", lustre_msg_get_opc(req->rq_reqmsg));
+		 * but racing with mds_handle().
+		 */
+		fallthrough;
+	case RQ_PHASE_COMPLETE:
+		/* been handled by mds_handle(), reply state may be volatile */
+		seq_printf(sf, "opc %d\n", lustre_msg_get_opc(req->rq_reqmsg));
                 break;
         default:
                 DEBUG_REQ(D_ERROR, req, "bad phase %d", req->rq_phase);
diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c
index 5e2d384435fb..81d7ba581223 100644
--- a/lustre/ptlrpc/pack_generic.c
+++ b/lustre/ptlrpc/pack_generic.c
@@ -856,7 +856,7 @@ __u32 lustre_msg_get_flags(struct lustre_msg *msg)
 
 		CERROR("invalid msg %p: no ptlrpc body!\n", msg);
 	}
-	/* fallthrough */
+	fallthrough;
 	default:
 		/* flags might be printed in debug code while message
 		 * uninitialized */
@@ -920,7 +920,7 @@ __u32 lustre_msg_get_op_flags(struct lustre_msg *msg)
 
 		CERROR("invalid msg %p: no ptlrpc body!\n", msg);
 	}
-	/* fallthrough */
+	fallthrough;
 	default:
 		return 0;
 	}
@@ -1125,7 +1125,7 @@ int lustre_msg_get_status(struct lustre_msg *msg)
 			return pb->pb_status;
 		CERROR("invalid msg %p: no ptlrpc body!\n", msg);
 	}
-	/* fallthrough */
+	fallthrough;
 	default:
 		/* status might be printed in debug code while message
 		* uninitialized */
@@ -2185,7 +2185,7 @@ void lustre_swab_lmv_user_md(struct lmv_user_md *lum)
 	switch (lum->lum_magic) {
 	case LMV_USER_MAGIC_SPECIFIC:
 		count = lum->lum_stripe_count;
-		/* fallthrough */
+		fallthrough;
 	case __swab32(LMV_USER_MAGIC_SPECIFIC):
 		lustre_swab_lmv_user_md_objects(lum->lum_objects, count);
 		break;
diff --git a/lustre/quota/qmt_handler.c b/lustre/quota/qmt_handler.c
index d5dfbc85570c..c93f69d0a014 100644
--- a/lustre/quota/qmt_handler.c
+++ b/lustre/quota/qmt_handler.c
@@ -351,7 +351,7 @@ static int qmt_quotactl(const struct lu_env *env, struct lu_device *ld,
 
 	case LUSTRE_Q_GETDEFAULT:
 		is_default = true;
-		/* fallthrough */
+		fallthrough;
 
 	case Q_GETQUOTA: /* consult quota limit */
 		/* extract quota ID from quotactl request */
@@ -382,7 +382,7 @@ static int qmt_quotactl(const struct lu_env *env, struct lu_device *ld,
 
 	case LUSTRE_Q_SETDEFAULT:
 		is_default = true;
-		/* fallthrough */
+		fallthrough;
 
 	case Q_SETQUOTA: /* change quota limits */
 		/* extract quota ID from quotactl request */
-- 
2.41.0

openSUSE Build Service is sponsored by