Whamcloud - gitweb
LU-5092 nodemap: save nodemaps to targets for caching
[fs/lustre-release.git] / lustre / ofd / ofd_internal.h
index 5316264..e2955d2 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2013, Intel Corporation.
+ * Copyright (c) 2012, 2015, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -42,7 +42,6 @@
 #include <dt_object.h>
 #include <md_object.h>
 #include <lustre_fid.h>
-#include <lustre_capa.h>
 
 #define OFD_INIT_OBJID 0
 #define OFD_PRECREATE_BATCH_DEFAULT (OBJ_SUBDIR_COUNT * 4)
@@ -125,6 +124,7 @@ struct ofd_device {
        /* last_rcvd file */
        struct lu_target         ofd_lut;
        struct dt_object        *ofd_health_check_file;
+       struct local_oid_storage *ofd_los;
 
        int                      ofd_subdir_count;
        __u64                    ofd_inconsistency_self_detected;
@@ -142,7 +142,8 @@ struct ofd_device {
        struct obd_statfs        ofd_osfs;
        __u64                    ofd_osfs_age;
        int                      ofd_blockbits;
-       /* writes which might be be accounted twice in ofd_osfs.os_bavail */
+       /* writes between prep & commit which might be accounted twice in
+        * ofd_osfs.os_bavail */
        u64                      ofd_osfs_unstable;
 
        /* counters used during statfs update, protected by ofd_osfs_lock.
@@ -161,14 +162,12 @@ struct ofd_device {
        u64                      ofd_tot_granted;
        /* grant used by I/Os in progress (between prepare and commit) */
        u64                      ofd_tot_pending;
-       /* free space threshold over which we stop granting space to clients
-        * ofd_grant_ratio is stored as a fixed-point fraction using
-        * OFD_GRANT_RATIO_SHIFT of the remaining free space, not in percentage
-        * values */
-       int                      ofd_grant_ratio;
        /* number of clients using grants */
        int                      ofd_tot_granted_clients;
 
+       /* preferred BRW size, decided by storage type and capability */
+       __u32                    ofd_brw_size;
+
        /* ofd mod data: ofd_device wide values */
        int                      ofd_fmd_max_num; /* per ofd ofd_mod_data */
        cfs_duration_t           ofd_fmd_max_age; /* time to fmd expiry */
@@ -183,7 +182,8 @@ struct ofd_device {
                                 /* Protected by ofd_lastid_rwsem. */
                                 ofd_lastid_rebuilding:1,
                                 ofd_record_fid_accessed:1,
-                                ofd_lfsck_verify_pfid:1;
+                                ofd_lfsck_verify_pfid:1,
+                                ofd_skip_lfsck:1;
        struct seq_server_site   ofd_seq_site;
        /* the limit of SOFT_SYNC RPCs that will trigger a soft sync */
        unsigned int             ofd_soft_sync_limit;
@@ -253,13 +253,6 @@ static inline struct ofd_device *ofd_obj2dev(const struct ofd_object *fo)
        return ofd_dev(fo->ofo_obj.do_lu.lo_dev);
 }
 
-static inline struct lustre_capa *ofd_object_capa(const struct lu_env *env,
-                                                 const struct ofd_object *obj)
-{
-       /* TODO: see mdd_object_capa() */
-       return BYPASS_CAPA;
-}
-
 static inline void ofd_read_lock(const struct lu_env *env,
                                 struct ofd_object *fo)
 {
@@ -327,23 +320,20 @@ struct ofd_thread_info {
        /* Space used by the I/O, used by grant code */
        unsigned long                    fti_used;
        struct ost_lvb                   fti_lvb;
-       struct lfsck_request             fti_lr;
+       union {
+               struct lfsck_request     fti_lr;
+               struct obd_connect_data  fti_ocd;
+       };
 };
 
 extern void target_recovery_fini(struct obd_device *obd);
 extern void target_recovery_init(struct lu_target *lut, svc_handler_t handler);
 
-/* ofd_capa.c */
-int ofd_update_capa_key(struct ofd_device *ofd, struct lustre_capa_key *key);
-int ofd_auth_capa(struct obd_export *exp, const struct lu_fid *fid,
-                 u64 seq, struct lustre_capa *capa, __u64 opc);
-void ofd_free_capa_keys(struct ofd_device *ofd);
-
 /* ofd_dev.c */
 extern struct lu_context_key ofd_thread_key;
 int ofd_postrecov(const struct lu_env *env, struct ofd_device *ofd);
 int ofd_fiemap_get(const struct lu_env *env, struct ofd_device *ofd,
-                  struct lu_fid *fid, struct ll_user_fiemap *fiemap);
+                  struct lu_fid *fid, struct fiemap *fiemap);
 
 /* ofd_obd.c */
 extern struct obd_ops ofd_obd_ops;
@@ -382,13 +372,11 @@ int ofd_verify_ff(const struct lu_env *env, struct ofd_object *fo,
 int ofd_preprw(const struct lu_env *env,int cmd, struct obd_export *exp,
               struct obdo *oa, int objcount, struct obd_ioobj *obj,
               struct niobuf_remote *rnb, int *nr_local,
-              struct niobuf_local *lnb, struct obd_trans_info *oti,
-              struct lustre_capa *capa);
+              struct niobuf_local *lnb);
 int ofd_commitrw(const struct lu_env *env, int cmd, struct obd_export *exp,
                 struct obdo *oa, int objcount, struct obd_ioobj *obj,
                 struct niobuf_remote *rnb, int npages,
-                struct niobuf_local *lnb, struct obd_trans_info *oti,
-                int old_rc);
+                struct niobuf_local *lnb, int old_rc);
 
 /* ofd_trans.c */
 struct thandle *ofd_trans_create(const struct lu_env *env,
@@ -402,8 +390,8 @@ int ofd_txn_stop_cb(const struct lu_env *env, struct thandle *txn,
                    void *cookie);
 
 /* lproc_ofd.c */
-#ifdef LPROCFS
-extern struct lprocfs_seq_vars lprocfs_ofd_obd_vars[];
+#ifdef CONFIG_PROC_FS
+extern struct lprocfs_vars lprocfs_ofd_obd_vars[];
 void ofd_stats_counter_init(struct lprocfs_stats *stats);
 #else
 static inline void ofd_stats_counter_init(struct lprocfs_stats *stats) {}
@@ -445,17 +433,6 @@ struct ofd_object *ofd_object_find_exists(const struct lu_env *env,
 }
 
 /* ofd_grants.c */
-#define OFD_GRANT_RATIO_SHIFT 8
-static inline u64 ofd_grant_reserved(struct ofd_device *ofd, u64 bavail)
-{
-       return (bavail * ofd->ofd_grant_ratio) >> OFD_GRANT_RATIO_SHIFT;
-}
-
-static inline int ofd_grant_ratio_conv(int percentage)
-{
-       return (percentage << OFD_GRANT_RATIO_SHIFT) / 100;
-}
-
 static inline int ofd_grant_param_supp(struct obd_export *exp)
 {
        return !!(exp_connect_flags(exp) & OBD_CONNECT_GRANT_PARAM);
@@ -465,16 +442,6 @@ static inline int ofd_grant_param_supp(struct obd_export *exp)
  * That's 4KB=2^12 which is the biggest block size known to work whatever
  * the client's page size is. */
 #define COMPAT_BSIZE_SHIFT 12
-static inline int ofd_grant_compat(struct obd_export *exp,
-                                  struct ofd_device *ofd)
-{
-       /* Clients which don't support OBD_CONNECT_GRANT_PARAM cannot handle
-        * a block size > page size and consume PAGE_CACHE_SIZE of grant when
-        * dirtying a page regardless of the block size */
-       return !!(ofd_obd(ofd)->obd_self_export != exp &&
-                 ofd->ofd_blockbits > COMPAT_BSIZE_SHIFT &&
-                 !ofd_grant_param_supp(exp));
-}
 
 static inline int ofd_grant_prohibit(struct obd_export *exp,
                                     struct ofd_device *ofd)
@@ -483,20 +450,24 @@ static inline int ofd_grant_prohibit(struct obd_export *exp,
         * clients not supporting OBD_CONNECT_GRANT_PARAM.
         * Otherwise, space granted to such a client is inflated since it
         * consumes PAGE_CACHE_SIZE of grant space per block */
-       return !!(ofd_grant_compat(exp, ofd) && ofd->ofd_grant_compat_disable);
+       return !!(ofd_obd(ofd)->obd_self_export != exp &&
+                 !ofd_grant_param_supp(exp) && ofd->ofd_grant_compat_disable);
 }
 
 void ofd_grant_sanity_check(struct obd_device *obd, const char *func);
-long ofd_grant_connect(const struct lu_env *env, struct obd_export *exp,
-                      u64 want, bool new_conn);
+void ofd_grant_connect(const struct lu_env *env, struct obd_export *exp,
+                      struct obd_connect_data *data, bool new_conn);
 void ofd_grant_discard(struct obd_export *exp);
 void ofd_grant_prepare_read(const struct lu_env *env, struct obd_export *exp,
                            struct obdo *oa);
 void ofd_grant_prepare_write(const struct lu_env *env, struct obd_export *exp,
                             struct obdo *oa, struct niobuf_remote *rnb,
                             int niocount);
-void ofd_grant_commit(const struct lu_env *env, struct obd_export *exp, int rc);
-int ofd_grant_create(const struct lu_env *env, struct obd_export *exp, int *nr);
+void ofd_grant_commit(struct obd_export *exp, unsigned long grant_used, int rc);
+int ofd_grant_commit_cb_add(struct thandle *th, struct obd_export *exp,
+                           unsigned long grant);
+long ofd_grant_create(const struct lu_env *env, struct obd_export *exp,
+                     int *nr);
 
 /* ofd_fmd.c */
 int ofd_fmd_init(void);
@@ -525,7 +496,7 @@ extern struct ldlm_valblock_ops ofd_lvbo;
 
 /* ofd_dlm.c */
 int ofd_intent_policy(struct ldlm_namespace *ns, struct ldlm_lock **lockp,
-                     void *req_cookie, ldlm_mode_t mode, __u64 flags,
+                     void *req_cookie, enum ldlm_mode mode, __u64 flags,
                      void *data);
 
 static inline struct ofd_thread_info *ofd_info(const struct lu_env *env)
@@ -578,20 +549,6 @@ static inline struct ofd_thread_info *tsi2ofd_info(struct tgt_session_info *tsi)
        return info;
 }
 
-static inline void ofd_oti2info(struct ofd_thread_info *info,
-                               struct obd_trans_info *oti)
-{
-       info->fti_xid = oti->oti_xid;
-       info->fti_pre_version = oti->oti_pre_version;
-}
-
-static inline void ofd_info2oti(struct ofd_thread_info *info,
-                                struct obd_trans_info *oti)
-{
-       oti->oti_xid = info->fti_xid;
-       oti->oti_pre_version = info->fti_pre_version;
-}
-
 /* sync on lock cancel is useless when we force a journal flush,
  * and if we enable async journal commit, we should also turn on
  * sync on lock cancel if it is not enabled already. */