Whamcloud - gitweb
LU-14291 lustre: limit header scope for server only handling 96/43096/12
authorJames Simmons <jsimmons@infradead.org>
Sat, 8 May 2021 16:15:33 +0000 (12:15 -0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 19 May 2021 02:03:50 +0000 (02:03 +0000)
The lustre headers have server only function declarations and
inline functions. Only include them if HAVE_SERVER_SUPPORT is
set. This gets us closer to building OpenSFS modules against
a Linux kernel with a native Lustre client. Move a few things
from UAPI headers that are used only by kernel space to kernel
only headers where they belong.

For mdc_changlog.c a debug message access a field that is
available the server which is never the case. Since its
nonsense we can remove the report of this field

Change-Id: I6e2d3bebc121aef97fe69344d496e230f62b28ad
Signed-off-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/43096
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Neil Brown <neilb@suse.de>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
12 files changed:
lustre/include/llog_swab.h
lustre/include/lprocfs_status.h
lustre/include/lu_object.h
lustre/include/lustre_fid.h
lustre/include/lustre_lmv.h
lustre/include/lustre_swab.h
lustre/include/obd.h
lustre/include/obd_support.h
lustre/include/uapi/linux/lustre/lustre_idl.h
lustre/include/uapi/linux/lustre/lustre_user.h
lustre/mdc/mdc_changelog.c
lustre/ptlrpc/lproc_ptlrpc.c

index 6fe62bc..cf48167 100644 (file)
@@ -60,7 +60,9 @@ void lustre_swab_llogd_conn_body(struct llogd_conn_body *d);
 void lustre_swab_llog_rec(struct llog_rec_hdr *rec);
 void lustre_swab_llog_id(struct llog_logid *lid);
 void lustre_swab_lu_seq_range(struct lu_seq_range *range);
+#ifdef HAVE_SERVER_SUPPORT
 void lustre_swab_update_ops(struct update_ops *uops, unsigned int op_count);
+#endif
 void lustre_swab_lustre_cfg(struct lustre_cfg *lcfg);
 void lustre_swab_cfg_marker(struct cfg_marker *marker,
                            int swab, int size);
index d0ab7e1..2b04a14 100644 (file)
@@ -318,6 +318,7 @@ static inline int opcode_offset(__u32 opc) {
                         OPC_RANGE(LDLM) +
                         OPC_RANGE(MDS) +
                         OPC_RANGE(OST));
+#ifdef HAVE_SERVER_SUPPORT
        } else if (opc < OUT_UPDATE_LAST_OPC) {
                /* update opcode */
                return (opc - OUT_UPDATE_FIRST_OPC +
@@ -345,25 +346,31 @@ static inline int opcode_offset(__u32 opc) {
                        OPC_RANGE(LDLM) +
                        OPC_RANGE(MDS) +
                        OPC_RANGE(OST));
+#endif /* HAVE_SERVER_SUPPORT */
        } else {
                /* Unknown Opcode */
                return -1;
        }
 }
 
+#define LUSTRE_MAX_OPCODES_CLIENT (OPC_RANGE(OST)  + \
+                                  OPC_RANGE(MDS)  + \
+                                  OPC_RANGE(LDLM) + \
+                                  OPC_RANGE(MGS)  + \
+                                  OPC_RANGE(OBD)  + \
+                                  OPC_RANGE(LLOG) + \
+                                  OPC_RANGE(SEC)  + \
+                                  OPC_RANGE(SEQ)  + \
+                                  OPC_RANGE(SEC)  + \
+                                  OPC_RANGE(FLD))
 
-#define LUSTRE_MAX_OPCODES (OPC_RANGE(OST)  + \
-                            OPC_RANGE(MDS)  + \
-                            OPC_RANGE(LDLM) + \
-                            OPC_RANGE(MGS)  + \
-                            OPC_RANGE(OBD)  + \
-                            OPC_RANGE(LLOG) + \
-                            OPC_RANGE(SEC)  + \
-                            OPC_RANGE(SEQ)  + \
-                            OPC_RANGE(SEC)  + \
-                           OPC_RANGE(FLD)  + \
+#ifdef HAVE_SERVER_SUPPORT
+#define LUSTRE_MAX_OPCODES (LUSTRE_MAX_OPCODES_CLIENT + \
                            OPC_RANGE(OUT_UPDATE) + \
                            OPC_RANGE(LFSCK))
+#else
+#define LUSTRE_MAX_OPCODES LUSTRE_MAX_OPCODES_CLIENT
+#endif
 
 #define EXTRA_MAX_OPCODES ((PTLRPC_LAST_CNTR - PTLRPC_FIRST_CNTR)  + \
                             OPC_RANGE(EXTRA))
index 884d79e..6969b71 100644 (file)
@@ -1588,6 +1588,12 @@ struct lu_tgt_qos {
 };
 
 /* target descriptor */
+#define LOV_QOS_DEF_THRESHOLD_RR_PCT   17
+#define LMV_QOS_DEF_THRESHOLD_RR_PCT   5
+
+#define LOV_QOS_DEF_PRIO_FREE          90
+#define LMV_QOS_DEF_PRIO_FREE          90
+
 struct lu_tgt_desc {
        union {
                struct dt_device        *ltd_tgt;
index fccb5ff..e82b847 100644 (file)
@@ -306,6 +306,13 @@ static inline int fid_is_name_llog(const struct lu_fid *fid)
        return fid_seq(fid) == FID_SEQ_LLOG_NAME;
 }
 
+static inline int fid_seq_in_fldb(u64 seq)
+{
+       return fid_seq_is_igif(seq) || fid_seq_is_norm(seq) ||
+              fid_seq_is_root(seq) || fid_seq_is_dot(seq);
+}
+
+#ifdef HAVE_SERVER_SUPPORT
 static inline int fid_is_namespace_visible(const struct lu_fid *fid)
 {
        const __u64 seq = fid_seq(fid);
@@ -317,12 +324,6 @@ static inline int fid_is_namespace_visible(const struct lu_fid *fid)
               fid_is_root(fid) || fid_seq_is_dot(seq);
 }
 
-static inline int fid_seq_in_fldb(__u64 seq)
-{
-       return fid_seq_is_igif(seq) || fid_seq_is_norm(seq) ||
-              fid_seq_is_root(seq) || fid_seq_is_dot(seq);
-}
-
 static inline void ost_layout_cpu_to_le(struct ost_layout *dst,
                                        const struct ost_layout *src)
 {
@@ -374,6 +375,7 @@ static inline void filter_fid_le_to_cpu(struct filter_fid *dst,
 
        /* XXX: Add more if filter_fid is enlarged in the future. */
 }
+#endif /* HAVE_SERVER_SUPPORT */
 
 static inline void lu_last_id_fid(struct lu_fid *fid, __u64 seq, __u32 ost_idx)
 {
index 811da36..6f302b3 100644 (file)
@@ -116,16 +116,20 @@ lsm_md_eq(const struct lmv_stripe_md *lsm1, const struct lmv_stripe_md *lsm2)
 
 static inline void lsm_md_dump(int mask, const struct lmv_stripe_md *lsm)
 {
+       bool valid_hash = lmv_dir_bad_hash(lsm);
        int i;
 
        /* If lsm_md_magic == LMV_MAGIC_FOREIGN pool_name may not be a null
         * terminated string so only print LOV_MAXPOOLNAME bytes.
         */
        CDEBUG(mask,
-              "magic %#x stripe count %d master mdt %d hash type %#x max inherit %hhu version %d migrate offset %d migrate hash %#x pool %.*s\n",
+              "magic %#x stripe count %d master mdt %d hash type %s:%#x max inherit %hhu version %d migrate offset %d migrate hash %#x pool %.*s\n",
               lsm->lsm_md_magic, lsm->lsm_md_stripe_count,
-              lsm->lsm_md_master_mdt_index, lsm->lsm_md_hash_type,
-              lsm->lsm_md_max_inherit, lsm->lsm_md_layout_version,
+              lsm->lsm_md_master_mdt_index,
+              valid_hash ? "invalid hash" :
+                           mdt_hash_name[lsm->lsm_md_hash_type & (LMV_HASH_TYPE_MAX - 1)],
+              lsm->lsm_md_hash_type, lsm->lsm_md_max_inherit,
+              lsm->lsm_md_layout_version,
               lsm->lsm_md_migrate_offset, lsm->lsm_md_migrate_hash,
               LOV_MAXPOOLNAME, lsm->lsm_md_pool_name);
 
@@ -403,6 +407,17 @@ static inline bool lmv_user_magic_supported(__u32 lum_magic)
               lum_magic == LMV_MAGIC_FOREIGN;
 }
 
+#define LMV_DEBUG(mask, lmv, msg)                                      \
+       CDEBUG(mask,                                                    \
+              "%s LMV: magic=%#x count=%u index=%u hash=%s:%#x version=%u migrate offset=%u migrate hash=%s:%u.\n",\
+              msg, (lmv)->lmv_magic, (lmv)->lmv_stripe_count,          \
+              (lmv)->lmv_master_mdt_index,                             \
+              mdt_hash_name[(lmv)->lmv_hash_type & (LMV_HASH_TYPE_MAX - 1)],\
+              (lmv)->lmv_hash_type, (lmv)->lmv_layout_version,         \
+              (lmv)->lmv_migrate_offset,                               \
+              mdt_hash_name[(lmv)->lmv_migrate_hash & (LMV_HASH_TYPE_MAX - 1)],\
+              (lmv)->lmv_migrate_hash)
+
 /* master LMV is sane */
 static inline bool lmv_is_sane(const struct lmv_mds_md_v1 *lmv)
 {
index 7db43f6..2e9d9f5 100644 (file)
 
 #include <uapi/linux/lustre/lustre_idl.h>
 
+#ifdef HAVE_SERVER_SUPPORT
 void lustre_swab_orphan_ent(struct lu_orphan_ent *ent);
 void lustre_swab_orphan_ent_v2(struct lu_orphan_ent_v2 *ent);
 void lustre_swab_orphan_ent_v3(struct lu_orphan_ent_v3 *ent);
+void lustre_swab_gl_lquota_desc(struct ldlm_gl_lquota_desc *desc);
+void lustre_swab_gl_barrier_desc(struct ldlm_gl_barrier_desc *desc);
+void lustre_swab_object_update(struct object_update *ou);
+int lustre_swab_object_update_request(struct object_update_request *our,
+                                     __u32 len);
+void lustre_swab_out_update_header(struct out_update_header *ouh);
+void lustre_swab_out_update_buffer(struct out_update_buffer *oub);
+void lustre_swab_object_update_result(struct object_update_result *our);
+int lustre_swab_object_update_reply(struct object_update_reply *our, __u32 len);
+#endif /* HAVE_SERVER_SUPPORT */
 void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
 void lustre_swab_connect(struct obd_connect_data *ocd);
 void lustre_swab_hsm_user_state(struct hsm_user_state *hus);
@@ -76,8 +87,6 @@ void lustre_swab_lmv_mds_md(union lmv_mds_md *lmm);
 void lustre_swab_lov_desc(struct lov_desc *ld);
 void lustre_swab_ldlm_res_id(struct ldlm_res_id *id);
 void lustre_swab_ldlm_policy_data(union ldlm_wire_policy_data *d);
-void lustre_swab_gl_lquota_desc(struct ldlm_gl_lquota_desc *);
-void lustre_swab_gl_barrier_desc(struct ldlm_gl_barrier_desc *);
 void lustre_swab_ldlm_intent(struct ldlm_intent *i);
 void lustre_swab_ldlm_resource_desc(struct ldlm_resource_desc *r);
 void lustre_swab_ldlm_lock_desc(struct ldlm_lock_desc *l);
@@ -111,13 +120,6 @@ void lustre_swab_hsm_progress_kernel(struct hsm_progress_kernel *hpk);
 void lustre_swab_hsm_user_state(struct hsm_user_state *hus);
 void lustre_swab_hsm_user_item(struct hsm_user_item *hui);
 void lustre_swab_hsm_request(struct hsm_request *hr);
-void lustre_swab_object_update(struct object_update *ou);
-int lustre_swab_object_update_request(struct object_update_request *our,
-                                     __u32 len);
-void lustre_swab_out_update_header(struct out_update_header *ouh);
-void lustre_swab_out_update_buffer(struct out_update_buffer *oub);
-void lustre_swab_object_update_result(struct object_update_result *our);
-int lustre_swab_object_update_reply(struct object_update_reply *our, __u32 len);
 void lustre_swab_swap_layouts(struct mdc_swap_layouts *msl);
 void lustre_swab_close_data(struct close_data *data);
 void lustre_swab_close_data_resync_done(struct close_data_resync_done *resync);
index ed93ccf..49ab370 100644 (file)
@@ -45,6 +45,7 @@
 #ifdef HAVE_SERVER_SUPPORT
 # include <lu_target.h>
 # include <obd_target.h>
+# include <lustre_quota.h>
 #endif
 #include <lu_ref.h>
 #include <lustre_export.h>
@@ -53,7 +54,6 @@
 #include <lustre_handles.h>
 #include <lustre_intent.h>
 #include <lvfs.h>
-#include <lustre_quota.h>
 
 #define MAX_OBD_DEVICES 8192
 
index 9dde5f7..4b15d6a 100644 (file)
@@ -973,6 +973,7 @@ do {                                                                          \
 #define KEY_IS(str) \
         (keylen >= (sizeof(str)-1) && memcmp(key, str, (sizeof(str)-1)) == 0)
 
+#ifdef HAVE_SERVER_SUPPORT
 /* LUSTRE_LMA_FL_MASKS defines which flags will be stored in LMA */
 
 static inline int lma_to_lustre_flags(__u32 lma_flags)
@@ -986,6 +987,7 @@ static inline int lustre_to_lma_flags(__u32 la_flags)
        return (((la_flags & LUSTRE_ORPHAN_FL) ? LMAI_ORPHAN : 0) |
                ((la_flags & LUSTRE_ENCRYPT_FL) ? LMAI_ENCRYPT : 0));
 }
+#endif /* HAVE_SERVER_SUPPORT */
 
 /* Convert wire LUSTRE_*_FL to corresponding client local VFS S_* values
  * for the client inode i_flags.  The LUSTRE_*_FL are the Lustre wire
index ff7765f..b0f22cb 100644 (file)
@@ -2214,14 +2214,6 @@ struct lmv_mds_md_v1 {
        struct lu_fid lmv_stripe_fids[0];       /* FIDs for each stripe */
 };
 
-#define LMV_DEBUG(mask, lmv, msg)                                      \
-       CDEBUG(mask,                                                    \
-              "%s LMV: magic=%#x count=%u index=%u hash=%#x version=%u migrate offset=%u migrate hash=%u.\n",  \
-              msg, (lmv)->lmv_magic, (lmv)->lmv_stripe_count,          \
-              (lmv)->lmv_master_mdt_index, (lmv)->lmv_hash_type,       \
-              (lmv)->lmv_layout_version, (lmv)->lmv_migrate_offset,    \
-              (lmv)->lmv_migrate_hash)
-
 /* stripe count before directory split */
 #define lmv_split_offset       lmv_migrate_offset
 /* stripe count after directory merge */
index 308a526..9297f0d 100644 (file)
@@ -718,12 +718,6 @@ struct fsxattr {
 #define LOV_OFFSET_DEFAULT      ((__u16)-1)
 #define LMV_OFFSET_DEFAULT      ((__u32)-1)
 
-#define LOV_QOS_DEF_THRESHOLD_RR_PCT   17
-#define LMV_QOS_DEF_THRESHOLD_RR_PCT    5
-
-#define LOV_QOS_DEF_PRIO_FREE          90
-#define LMV_QOS_DEF_PRIO_FREE          90
-
 static inline bool lov_pattern_supported(__u32 pattern)
 {
        return (pattern & ~LOV_PATTERN_F_RELEASED) == LOV_PATTERN_RAID0 ||
index 8a3f723..459f4f0 100644 (file)
@@ -222,10 +222,9 @@ static int chlg_read_cat_process_cb(const struct lu_env *env,
 
        if (rec->cr_hdr.lrh_type != CHANGELOG_REC) {
                rc = -EINVAL;
-               CERROR("%s: not a changelog rec %x/%d in llog "DFID" rc = %d\n",
+               CERROR("%s: not a changelog rec %x/%d in llog : rc = %d\n",
                       crs->crs_obd->obd_name, rec->cr_hdr.lrh_type,
-                      rec->cr.cr_type,
-                      PFID(lu_object_fid(&llh->lgh_obj->do_lu)), rc);
+                      rec->cr.cr_type, rc);
                RETURN(rc);
        }
 
index 2e3c008..50d5660 100644 (file)
@@ -132,9 +132,11 @@ static struct ll_rpc_opcode {
        { SEC_CTX_FINI,     "sec_ctx_fini" },
        { FLD_QUERY,        "fld_query" },
        { FLD_READ,         "fld_read" },
+#ifdef HAVE_SERVER_SUPPORT
        { OUT_UPDATE,       "out_update" },
        { LFSCK_NOTIFY,     "lfsck_notify" },
        { LFSCK_QUERY,      "lfsck_query" },
+#endif
 };
 
 static struct ll_eopcode {