From c438fba7f068b0713d96dce1f0183ec6da7ab000 Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Mon, 27 Apr 2020 13:39:36 +1000 Subject: [PATCH] LU-6142 lustre: use BIT() macro where appropriate in include When accessing a bit in a bitmap/mask/flags-word it can be more readable to use BIT(num) rather than "1 << num". This patch makes that change to various places in lustre/include. Test-Parameters: trivial Signed-off-by: Mr NeilBrown Change-Id: I6a242fa843ff26320b299b8a532b6bb4388f0233 Reviewed-on: https://review.whamcloud.com/38376 Tested-by: jenkins Reviewed-by: Olaf Faaland-LLNL Tested-by: Maloo Reviewed-by: Gian-Carlo DeFazio Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- lustre/include/cl_object.h | 18 +++--- lustre/include/dt_object.h | 26 ++++---- lustre/include/lu_object.h | 132 ++++++++++++++++++++-------------------- lustre/include/lu_target.h | 8 +-- lustre/include/lustre_dlm.h | 4 +- lustre/include/lustre_net.h | 64 +++++++++---------- lustre/include/lustre_nrs.h | 10 +-- lustre/include/lustre_nrs_orr.h | 8 +-- lustre/include/lustre_osc.h | 4 +- lustre/include/lustre_quota.h | 14 ++--- lustre/include/lustre_sec.h | 12 ++-- lustre/include/md_object.h | 32 +++++----- lustre/include/obd.h | 22 +++---- 13 files changed, 177 insertions(+), 177 deletions(-) diff --git a/lustre/include/cl_object.h b/lustre/include/cl_object.h index fb93a94..e66584c 100644 --- a/lustre/include/cl_object.h +++ b/lustre/include/cl_object.h @@ -179,15 +179,15 @@ struct cl_attr { * Fields in cl_attr that are being set. */ enum cl_attr_valid { - CAT_SIZE = 1 << 0, - CAT_KMS = 1 << 1, - CAT_MTIME = 1 << 3, - CAT_ATIME = 1 << 4, - CAT_CTIME = 1 << 5, - CAT_BLOCKS = 1 << 6, - CAT_UID = 1 << 7, - CAT_GID = 1 << 8, - CAT_PROJID = 1 << 9 + CAT_SIZE = BIT(0), + CAT_KMS = BIT(1), + CAT_MTIME = BIT(3), + CAT_ATIME = BIT(4), + CAT_CTIME = BIT(5), + CAT_BLOCKS = BIT(6), + CAT_UID = BIT(7), + CAT_GID = BIT(8), + CAT_PROJID = BIT(9), }; /** diff --git a/lustre/include/dt_object.h b/lustre/include/dt_object.h index ab9a7c0..d9cc933 100644 --- a/lustre/include/dt_object.h +++ b/lustre/include/dt_object.h @@ -332,19 +332,19 @@ struct dt_index_features { }; enum dt_index_flags { - /** index supports variable sized keys */ - DT_IND_VARKEY = 1 << 0, - /** index supports variable sized records */ - DT_IND_VARREC = 1 << 1, - /** index can be modified */ - DT_IND_UPDATE = 1 << 2, - /** index supports records with non-unique (duplicate) keys */ - DT_IND_NONUNQ = 1 << 3, - /** - * index support fixed-size keys sorted with natural numerical way - * and is able to return left-side value if no exact value found - */ - DT_IND_RANGE = 1 << 4, + /** index supports variable sized keys */ + DT_IND_VARKEY = BIT(0), + /** index supports variable sized records */ + DT_IND_VARREC = BIT(1), + /** index can be modified */ + DT_IND_UPDATE = BIT(2), + /** index supports records with non-unique (duplicate) keys */ + DT_IND_NONUNQ = BIT(3), + /** + * index support fixed-size keys sorted with natural numerical way + * and is able to return left-side value if no exact value found + */ + DT_IND_RANGE = BIT(4), }; /* for dt_read_lock() and dt_write_lock() object lock rule */ diff --git a/lustre/include/lu_object.h b/lustre/include/lu_object.h index 0a9ed50..781b9b4 100644 --- a/lustre/include/lu_object.h +++ b/lustre/include/lu_object.h @@ -321,12 +321,12 @@ struct lu_device_type_operations; * device types. */ enum lu_device_tag { - /** this is meta-data device */ - LU_DEVICE_MD = (1 << 0), - /** this is data device */ - LU_DEVICE_DT = (1 << 1), - /** data device in the client stack */ - LU_DEVICE_CL = (1 << 2) + /** this is meta-data device */ + LU_DEVICE_MD = BIT(0), + /** this is data device */ + LU_DEVICE_DT = BIT(1), + /** data device in the client stack */ + LU_DEVICE_CL = BIT(2) }; /** @@ -508,9 +508,9 @@ enum lu_object_header_flags { }; enum lu_object_header_attr { - LOHA_EXISTS = 1 << 0, - LOHA_REMOTE = 1 << 1, - LOHA_HAS_AGENT_ENTRY = 1 << 2, + LOHA_EXISTS = BIT(0), + LOHA_REMOTE = BIT(1), + LOHA_HAS_AGENT_ENTRY = BIT(2), /** * UNIX file type is stored in S_IFMT bits. */ @@ -931,10 +931,10 @@ struct lu_rdpg { }; enum lu_xattr_flags { - LU_XATTR_REPLACE = (1 << 0), - LU_XATTR_CREATE = (1 << 1), - LU_XATTR_MERGE = (1 << 2), - LU_XATTR_SPLIT = (1 << 3), + LU_XATTR_REPLACE = BIT(0), + LU_XATTR_CREATE = BIT(1), + LU_XATTR_MERGE = BIT(2), + LU_XATTR_SPLIT = BIT(3), }; /** @} helpers */ @@ -1017,62 +1017,62 @@ struct lu_context { */ enum lu_context_tag { - /** - * Thread on md server - */ - LCT_MD_THREAD = 1 << 0, - /** - * Thread on dt server - */ - LCT_DT_THREAD = 1 << 1, - /** - * Thread on client - */ - LCT_CL_THREAD = 1 << 3, - /** - * A per-request session on a server, and a per-system-call session on - * a client. - */ - LCT_SESSION = 1 << 4, - /** - * A per-request data on OSP device - */ - LCT_OSP_THREAD = 1 << 5, - /** - * MGS device thread - */ - LCT_MG_THREAD = 1 << 6, - /** - * Context for local operations - */ - LCT_LOCAL = 1 << 7, + /** + * Thread on md server + */ + LCT_MD_THREAD = BIT(0), + /** + * Thread on dt server + */ + LCT_DT_THREAD = BIT(1), + /** + * Thread on client + */ + LCT_CL_THREAD = BIT(3), + /** + * A per-request session on a server, and a per-system-call session on + * a client. + */ + LCT_SESSION = BIT(4), + /** + * A per-request data on OSP device + */ + LCT_OSP_THREAD = BIT(5), + /** + * MGS device thread + */ + LCT_MG_THREAD = BIT(6), + /** + * Context for local operations + */ + LCT_LOCAL = BIT(7), /** * session for server thread **/ - LCT_SERVER_SESSION = 1 << 8, - /** - * Set when at least one of keys, having values in this context has - * non-NULL lu_context_key::lct_exit() method. This is used to - * optimize lu_context_exit() call. - */ - LCT_HAS_EXIT = 1 << 28, - /** - * Don't add references for modules creating key values in that context. - * This is only for contexts used internally by lu_object framework. - */ - LCT_NOREF = 1 << 29, - /** - * Key is being prepared for retiring, don't create new values for it. - */ - LCT_QUIESCENT = 1 << 30, - /** - * Context should be remembered. - */ - LCT_REMEMBER = 1 << 31, - /** - * Contexts usable in cache shrinker thread. - */ - LCT_SHRINKER = LCT_MD_THREAD|LCT_DT_THREAD|LCT_CL_THREAD|LCT_NOREF + LCT_SERVER_SESSION = BIT(8), + /** + * Set when at least one of keys, having values in this context has + * non-NULL lu_context_key::lct_exit() method. This is used to + * optimize lu_context_exit() call. + */ + LCT_HAS_EXIT = BIT(28), + /** + * Don't add references for modules creating key values in that context. + * This is only for contexts used internally by lu_object framework. + */ + LCT_NOREF = BIT(29), + /** + * Key is being prepared for retiring, don't create new values for it. + */ + LCT_QUIESCENT = BIT(30), + /** + * Context should be remembered. + */ + LCT_REMEMBER = BIT(31), + /** + * Contexts usable in cache shrinker thread. + */ + LCT_SHRINKER = LCT_MD_THREAD|LCT_DT_THREAD|LCT_CL_THREAD|LCT_NOREF, }; /** diff --git a/lustre/include/lu_target.h b/lustre/include/lu_target.h index 013432a..e16e5bc 100644 --- a/lustre/include/lu_target.h +++ b/lustre/include/lu_target.h @@ -338,21 +338,21 @@ enum tgt_handler_flags { * struct *_body is passed in the incoming message, and object * identified by this fid exists on disk. */ - HAS_BODY = (1 << 0), + HAS_BODY = BIT(0), /* * struct ldlm_request is passed in the incoming message. */ - HAS_KEY = (1 << 1), + HAS_KEY = BIT(1), /* * this request has fixed reply format, so that reply message can be * packed by generic code. */ - HAS_REPLY = (1 << 2), + HAS_REPLY = BIT(2), /* * this request will modify something, so check whether the file system * is readonly or not, then return -EROFS to client asap if necessary. */ - IS_MUTABLE = (1 << 3) + IS_MUTABLE = BIT(3) }; struct tgt_handler { diff --git a/lustre/include/lustre_dlm.h b/lustre/include/lustre_dlm.h index a1bda70..8cefd83 100644 --- a/lustre/include/lustre_dlm.h +++ b/lustre/include/lustre_dlm.h @@ -308,8 +308,8 @@ struct ldlm_valblock_ops { * Greedy means release cached locks aggressively */ enum ldlm_appetite { - LDLM_NAMESPACE_GREEDY = 1 << 0, - LDLM_NAMESPACE_MODEST = 1 << 1 + LDLM_NAMESPACE_GREEDY = BIT(0), + LDLM_NAMESPACE_MODEST = BIT(1), }; /** diff --git a/lustre/include/lustre_net.h b/lustre/include/lustre_net.h index b77a794..c2d9f07 100644 --- a/lustre/include/lustre_net.h +++ b/lustre/include/lustre_net.h @@ -553,8 +553,8 @@ struct ptlrpc_client { /** state flags of requests */ /* XXX only ones left are those used by the bulk descs as well! */ -#define PTL_RPC_FL_INTR (1 << 0) /* reply wait was interrupted by user */ -#define PTL_RPC_FL_TIMEOUT (1 << 7) /* request timed out waiting for reply */ +#define PTL_RPC_FL_INTR BIT(0) /* reply wait was interrupted by user */ +#define PTL_RPC_FL_TIMEOUT BIT(7) /* request timed out waiting for reply */ #define REQ_MAX_ACK_LOCKS 8 @@ -1193,7 +1193,7 @@ static inline bool ptlrpc_nrs_req_can_move(struct ptlrpc_request *req) static inline bool lustre_req_swabbed(struct ptlrpc_request *req, size_t index) { LASSERT(index < sizeof(req->rq_req_swab_mask) * 8); - return req->rq_req_swab_mask & (1 << index); + return req->rq_req_swab_mask & BIT(index); } /** @@ -1202,7 +1202,7 @@ static inline bool lustre_req_swabbed(struct ptlrpc_request *req, size_t index) static inline bool lustre_rep_swabbed(struct ptlrpc_request *req, size_t index) { LASSERT(index < sizeof(req->rq_rep_swab_mask) * 8); - return req->rq_rep_swab_mask & (1 << index); + return req->rq_rep_swab_mask & BIT(index); } /** @@ -1227,9 +1227,9 @@ static inline bool ptlrpc_rep_need_swab(struct ptlrpc_request *req) static inline void lustre_set_req_swabbed(struct ptlrpc_request *req, size_t index) { - LASSERT(index < sizeof(req->rq_req_swab_mask) * 8); - LASSERT((req->rq_req_swab_mask & (1 << index)) == 0); - req->rq_req_swab_mask |= 1 << index; + LASSERT(index < sizeof(req->rq_req_swab_mask) * 8); + LASSERT((req->rq_req_swab_mask & BIT(index)) == 0); + req->rq_req_swab_mask |= BIT(index); } /** @@ -1238,9 +1238,9 @@ static inline void lustre_set_req_swabbed(struct ptlrpc_request *req, static inline void lustre_set_rep_swabbed(struct ptlrpc_request *req, size_t index) { - LASSERT(index < sizeof(req->rq_rep_swab_mask) * 8); - LASSERT((req->rq_rep_swab_mask & (1 << index)) == 0); - req->rq_rep_swab_mask |= 1 << index; + LASSERT(index < sizeof(req->rq_rep_swab_mask) * 8); + LASSERT((req->rq_rep_swab_mask & BIT(index)) == 0); + req->rq_rep_swab_mask |= BIT(index); } /** @@ -1464,10 +1464,10 @@ struct ptlrpc_bulk_desc { enum { SVC_INIT = 0, - SVC_STOPPED = 1 << 0, - SVC_STOPPING = 1 << 1, - SVC_STARTING = 1 << 2, - SVC_RUNNING = 1 << 3, + SVC_STOPPED = BIT(0), + SVC_STOPPING = BIT(1), + SVC_STARTING = BIT(2), + SVC_RUNNING = BIT(3), }; #define PTLRPC_THR_NAME_LEN 32 @@ -1885,24 +1885,24 @@ struct ptlrpcd_ctl { /* Bits for pc_flags */ enum ptlrpcd_ctl_flags { - /** - * Ptlrpc thread start flag. - */ - LIOD_START = 1 << 0, - /** - * Ptlrpc thread stop flag. - */ - LIOD_STOP = 1 << 1, - /** - * Ptlrpc thread force flag (only stop force so far). - * This will cause aborting any inflight rpcs handled - * by thread if LIOD_STOP is specified. - */ - LIOD_FORCE = 1 << 2, - /** - * This is a recovery ptlrpc thread. - */ - LIOD_RECOVERY = 1 << 3, + /** + * Ptlrpc thread start flag. + */ + LIOD_START = BIT(0), + /** + * Ptlrpc thread stop flag. + */ + LIOD_STOP = BIT(1), + /** + * Ptlrpc thread force flag (only stop force so far). + * This will cause aborting any inflight rpcs handled + * by thread if LIOD_STOP is specified. + */ + LIOD_FORCE = BIT(2), + /** + * This is a recovery ptlrpc thread. + */ + LIOD_RECOVERY = BIT(3), }; /** diff --git a/lustre/include/lustre_nrs.h b/lustre/include/lustre_nrs.h index 6397cf2..bafbc7e 100644 --- a/lustre/include/lustre_nrs.h +++ b/lustre/include/lustre_nrs.h @@ -269,16 +269,16 @@ enum nrs_policy_flags { * service. The flag cannot be used on policies that use * \e PTLRPC_NRS_FL_REG_EXTERN */ - PTLRPC_NRS_FL_FALLBACK = (1 << 0), + PTLRPC_NRS_FL_FALLBACK = BIT(0), /** * Start policy immediately after registering. */ - PTLRPC_NRS_FL_REG_START = (1 << 1), + PTLRPC_NRS_FL_REG_START = BIT(1), /** * This is a policy registering from a module different to the one NRS * core ships in (currently ptlrpc). */ - PTLRPC_NRS_FL_REG_EXTERN = (1 << 2), + PTLRPC_NRS_FL_REG_EXTERN = BIT(2), }; /** @@ -289,8 +289,8 @@ enum nrs_policy_flags { * in a service. */ enum ptlrpc_nrs_queue_type { - PTLRPC_NRS_QUEUE_REG = (1 << 0), - PTLRPC_NRS_QUEUE_HP = (1 << 1), + PTLRPC_NRS_QUEUE_REG = BIT(0), + PTLRPC_NRS_QUEUE_HP = BIT(1), PTLRPC_NRS_QUEUE_BOTH = (PTLRPC_NRS_QUEUE_REG | PTLRPC_NRS_QUEUE_HP) }; diff --git a/lustre/include/lustre_nrs_orr.h b/lustre/include/lustre_nrs_orr.h index d9789b2..3698a80 100644 --- a/lustre/include/lustre_nrs_orr.h +++ b/lustre/include/lustre_nrs_orr.h @@ -64,13 +64,13 @@ struct nrs_orr_req_range { * RPC types supported by the ORR/TRR policies */ enum nrs_orr_supp { - NOS_OST_READ = (1 << 0), - NOS_OST_WRITE = (1 << 1), - NOS_OST_RW = (NOS_OST_READ | NOS_OST_WRITE), + NOS_OST_READ = BIT(0), + NOS_OST_WRITE = BIT(1), + NOS_OST_RW = (NOS_OST_READ | NOS_OST_WRITE), /** * Default value for policies. */ - NOS_DFLT = NOS_OST_READ + NOS_DFLT = NOS_OST_READ }; /** diff --git a/lustre/include/lustre_osc.h b/lustre/include/lustre_osc.h index cd7561c..656b60a 100644 --- a/lustre/include/lustre_osc.h +++ b/lustre/include/lustre_osc.h @@ -221,11 +221,11 @@ enum osc_dap_flags { * Just check if the desired lock exists, it won't hold reference * count on lock. */ - OSC_DAP_FL_TEST_LOCK = 1 << 0, + OSC_DAP_FL_TEST_LOCK = BIT(0), /** * Return the lock even if it is being canceled. */ - OSC_DAP_FL_CANCELING = 1 << 1 + OSC_DAP_FL_CANCELING = BIT(1), }; /* diff --git a/lustre/include/lustre_quota.h b/lustre/include/lustre_quota.h index f63874c..59406ee 100644 --- a/lustre/include/lustre_quota.h +++ b/lustre/include/lustre_quota.h @@ -62,9 +62,9 @@ union lquota_rec { /* flags for inode/block quota accounting */ enum osd_qid_declare_flags { - OSD_QID_INODE = 1 << 0, - OSD_QID_BLK = 1 << 1, - OSD_QID_FORCE = 1 << 2, + OSD_QID_INODE = BIT(0), + OSD_QID_BLK = BIT(1), + OSD_QID_FORCE = BIT(2), }; /* Index features supported by the global index objects @@ -178,10 +178,10 @@ struct qsd_instance; /* flags for quota local enforcement */ enum osd_quota_local_flags { - QUOTA_FL_OVER_USRQUOTA = 1 << 0, - QUOTA_FL_OVER_GRPQUOTA = 1 << 1, - QUOTA_FL_SYNC = 1 << 2, - QUOTA_FL_OVER_PRJQUOTA = 1 << 3, + QUOTA_FL_OVER_USRQUOTA = BIT(0), + QUOTA_FL_OVER_GRPQUOTA = BIT(1), + QUOTA_FL_SYNC = BIT(2), + QUOTA_FL_OVER_PRJQUOTA = BIT(3), }; struct qsd_instance *qsd_init(const struct lu_env *, char *, struct dt_device *, diff --git a/lustre/include/lustre_sec.h b/lustre/include/lustre_sec.h index 14010d5..68d64ee 100644 --- a/lustre/include/lustre_sec.h +++ b/lustre/include/lustre_sec.h @@ -532,12 +532,12 @@ struct ptlrpc_ctx_ops { #define PTLRPC_CTX_CACHED_BIT (8) /* in ctx cache (hash etc.) */ #define PTLRPC_CTX_ETERNAL_BIT (9) /* always valid */ -#define PTLRPC_CTX_NEW (1 << PTLRPC_CTX_NEW_BIT) -#define PTLRPC_CTX_UPTODATE (1 << PTLRPC_CTX_UPTODATE_BIT) -#define PTLRPC_CTX_DEAD (1 << PTLRPC_CTX_DEAD_BIT) -#define PTLRPC_CTX_ERROR (1 << PTLRPC_CTX_ERROR_BIT) -#define PTLRPC_CTX_CACHED (1 << PTLRPC_CTX_CACHED_BIT) -#define PTLRPC_CTX_ETERNAL (1 << PTLRPC_CTX_ETERNAL_BIT) +#define PTLRPC_CTX_NEW BIT(PTLRPC_CTX_NEW_BIT) +#define PTLRPC_CTX_UPTODATE BIT(PTLRPC_CTX_UPTODATE_BIT) +#define PTLRPC_CTX_DEAD BIT(PTLRPC_CTX_DEAD_BIT) +#define PTLRPC_CTX_ERROR BIT(PTLRPC_CTX_ERROR_BIT) +#define PTLRPC_CTX_CACHED BIT(PTLRPC_CTX_CACHED_BIT) +#define PTLRPC_CTX_ETERNAL BIT(PTLRPC_CTX_ETERNAL_BIT) #define PTLRPC_CTX_STATUS_MASK (PTLRPC_CTX_NEW_BIT | \ PTLRPC_CTX_UPTODATE | \ diff --git a/lustre/include/md_object.h b/lustre/include/md_object.h index c6b02c7..a54af3e 100644 --- a/lustre/include/md_object.h +++ b/lustre/include/md_object.h @@ -65,17 +65,17 @@ struct obd_export; /** metadata attributes */ enum ma_valid { - MA_INODE = 1 << 0, - MA_LOV = 1 << 1, - MA_FLAGS = 1 << 2, - MA_LMV = 1 << 3, - MA_ACL_DEF = 1 << 4, - MA_LOV_DEF = 1 << 5, - MA_HSM = 1 << 6, - MA_PFID = 1 << 7, - MA_LMV_DEF = 1 << 8, - MA_SOM = 1 << 9, - MA_FORCE_LOG = 1 << 10, /* forced close logged in mdt_mfd_close */ + MA_INODE = BIT(0), + MA_LOV = BIT(1), + MA_FLAGS = BIT(2), + MA_LMV = BIT(3), + MA_ACL_DEF = BIT(4), + MA_LOV_DEF = BIT(5), + MA_HSM = BIT(6), + MA_PFID = BIT(7), + MA_LMV_DEF = BIT(8), + MA_SOM = BIT(9), + MA_FORCE_LOG = BIT(10), /* forced close logged in mdt_mfd_close */ }; typedef enum { @@ -91,13 +91,13 @@ typedef enum { } mdl_mode_t; typedef enum { - MDT_NUL_LOCK = 0, - MDT_REG_LOCK = (1 << 0), - MDT_PDO_LOCK = (1 << 1) + MDT_NUL_LOCK = 0, + MDT_REG_LOCK = BIT(0), + MDT_PDO_LOCK = BIT(1), } mdl_type_t; /* lfs rgetfacl permission check */ -#define MAY_RGETFACL (1 << 14) +#define MAY_RGETFACL BIT(14) /* memory structure for hsm attributes * for fields description see the on disk structure hsm_attrs @@ -725,7 +725,7 @@ void lu_ucred_global_fini(void); #define md_cap_t(x) (x) -#define MD_CAP_TO_MASK(x) (1 << (x)) +#define MD_CAP_TO_MASK(x) BIT(x) #define md_cap_raised(c, flag) (md_cap_t(c) & MD_CAP_TO_MASK(flag)) diff --git a/lustre/include/obd.h b/lustre/include/obd.h index e1a6379..9da2f12 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -816,20 +816,20 @@ static inline int it_to_lock_mode(struct lookup_intent *it) } enum md_op_flags { - MF_MDC_CANCEL_FID1 = 1 << 0, - MF_MDC_CANCEL_FID2 = 1 << 1, - MF_MDC_CANCEL_FID3 = 1 << 2, - MF_MDC_CANCEL_FID4 = 1 << 3, - MF_GET_MDT_IDX = 1 << 4, + MF_MDC_CANCEL_FID1 = BIT(0), + MF_MDC_CANCEL_FID2 = BIT(1), + MF_MDC_CANCEL_FID3 = BIT(2), + MF_MDC_CANCEL_FID4 = BIT(3), + MF_GET_MDT_IDX = BIT(4), }; enum md_cli_flags { - CLI_SET_MEA = 1 << 0, - CLI_RM_ENTRY = 1 << 1, - CLI_HASH64 = 1 << 2, - CLI_API32 = 1 << 3, - CLI_MIGRATE = 1 << 4, - CLI_DIRTY_DATA = 1 << 5, + CLI_SET_MEA = BIT(0), + CLI_RM_ENTRY = BIT(1), + CLI_HASH64 = BIT(2), + CLI_API32 = BIT(3), + CLI_MIGRATE = BIT(4), + CLI_DIRTY_DATA = BIT(5), }; enum md_op_code { -- 1.8.3.1