Whamcloud - gitweb
LU-2739 mdt: Deny non-DNE client to access remote directory
[fs/lustre-release.git] / lustre / mdt / mdt_internal.h
index 37d7bc5..664940c 100644 (file)
@@ -119,17 +119,17 @@ struct mdt_device {
        struct obd_export         *mdt_bottom_exp;
         /** target device */
         struct lu_target           mdt_lut;
-        /*
-         * Options bit-fields.
-         */
-        struct {
-                signed int         mo_user_xattr :1,
-                                   mo_acl        :1,
-                                   mo_compat_resname:1,
-                                   mo_mds_capa   :1,
-                                   mo_oss_capa   :1,
-                                   mo_cos        :1;
-        } mdt_opts;
+       /*
+        * Options bit-fields.
+        */
+       struct {
+               unsigned int       mo_user_xattr:1,
+                                  mo_acl:1,
+                                  mo_compat_resname:1,
+                                  mo_mds_capa:1,
+                                  mo_oss_capa:1,
+                                  mo_cos:1;
+       } mdt_opts;
         /* mdt state flags */
         unsigned long              mdt_state;
         /* lock to protect IOepoch */
@@ -159,8 +159,9 @@ struct mdt_device {
         cfs_timer_t                mdt_ck_timer;
         struct ptlrpc_thread       mdt_ck_thread;
         struct lustre_capa_key     mdt_capa_keys[2];
-        unsigned int               mdt_capa_conf:1,
-                                   mdt_som_conf:1;
+       unsigned int               mdt_capa_conf:1,
+                                  mdt_som_conf:1,
+                                  mdt_enable_remote_dir:1;
 
        /* statfs optimization: we cache a bit  */
        struct obd_statfs          mdt_osfs;
@@ -237,6 +238,10 @@ struct mdt_lock_handle {
         struct lustre_handle    mlh_pdo_lh;
         ldlm_mode_t             mlh_pdo_mode;
         unsigned int            mlh_pdo_hash;
+
+       /* Remote regular lock */
+       struct lustre_handle    mlh_rreg_lh;
+       ldlm_mode_t          mlh_rreg_mode;
 };
 
 enum {
@@ -313,6 +318,9 @@ struct tx_arg {
                        struct lu_buf   buf;
                        loff_t          pos;
                } write;
+               struct {
+                       struct ost_body     *body;
+               } destroy;
        } u;
 };
 
@@ -556,8 +564,8 @@ static inline int req_is_replay(struct ptlrpc_request *req)
 
 static inline __u64 mdt_conn_flags(struct mdt_thread_info *info)
 {
-        LASSERT(info->mti_exp);
-        return info->mti_exp->exp_connect_flags;
+       LASSERT(info->mti_exp);
+       return exp_connect_flags(info->mti_exp);
 }
 
 static inline void mdt_object_get(const struct lu_env *env,
@@ -581,6 +589,11 @@ static inline int mdt_object_exists(const struct mdt_object *o)
         return lu_object_exists(&o->mot_obj.mo_lu);
 }
 
+static inline int mdt_object_remote(const struct mdt_object *o)
+{
+       return lu_object_remote(&o->mot_obj.mo_lu);
+}
+
 static inline const struct lu_fid *mdt_object_fid(const struct mdt_object *o)
 {
         return lu_object_fid(&o->mot_obj.mo_lu);
@@ -607,6 +620,13 @@ static inline void mdt_export_evict(struct obd_export *exp)
         class_export_put(exp);
 }
 
+/* Here we use LVB_TYPE to check dne client, because it is
+ * also landed on 2.4. */
+static inline int mdt_is_dne_client(struct obd_export *exp)
+{
+       return !!(exp_connect_flags(exp) & OBD_CONNECT_LVB_TYPE);
+}
+
 int mdt_get_disposition(struct ldlm_reply *rep, int flag);
 void mdt_set_disposition(struct mdt_thread_info *info,
                         struct ldlm_reply *rep, int flag);
@@ -656,6 +676,9 @@ void mdt_object_unlock_put(struct mdt_thread_info *,
 
 void mdt_client_compatibility(struct mdt_thread_info *info);
 
+int mdt_remote_object_lock(struct mdt_thread_info *mti,
+                          struct mdt_object *o, struct lustre_handle *lh,
+                          ldlm_mode_t mode, __u64 ibits);
 int mdt_close_unpack(struct mdt_thread_info *info);
 int mdt_reint_unpack(struct mdt_thread_info *info, __u32 op);
 int mdt_reint_rec(struct mdt_thread_info *, struct mdt_lock_handle *);
@@ -782,6 +805,7 @@ extern struct mdt_opc_slice mdt_fld_handlers[];
 int mdt_quotacheck(struct mdt_thread_info *info);
 int mdt_quotactl(struct mdt_thread_info *info);
 int mdt_quota_dqacq(struct mdt_thread_info *info);
+int mdt_swap_layouts(struct mdt_thread_info *info);
 
 extern struct lprocfs_vars lprocfs_mds_module_vars[];
 extern struct lprocfs_vars lprocfs_mds_obd_vars[];
@@ -995,7 +1019,7 @@ void mdt_stats_counter_init(struct lprocfs_stats *stats);
 void lprocfs_mdt_init_vars(struct lprocfs_static_vars *lvars);
 void lprocfs_mds_init_vars(struct lprocfs_static_vars *lvars);
 int mdt_procfs_init(struct mdt_device *mdt, const char *name);
-int mdt_procfs_fini(struct mdt_device *mdt);
+void mdt_procfs_fini(struct mdt_device *mdt);
 void mdt_rename_counter_tally(struct mdt_thread_info *info,
                              struct mdt_device *mdt,
                              struct ptlrpc_request *req,
@@ -1008,20 +1032,20 @@ void mdt_ck_timer_callback(unsigned long castmeharder);
 int mdt_capa_keys_init(const struct lu_env *env, struct mdt_device *mdt);
 
 static inline void mdt_set_capainfo(struct mdt_thread_info *info, int offset,
-                                    const struct lu_fid *fid,
-                                    struct lustre_capa *capa)
+                                   const struct lu_fid *fid,
+                                   struct lustre_capa *capa)
 {
-        struct md_capainfo *ci;
+       struct md_capainfo *ci;
 
        LASSERT(offset >= 0 && offset < MD_CAPAINFO_MAX);
-        if (!info->mti_mdt->mdt_opts.mo_mds_capa ||
-            !(info->mti_exp->exp_connect_flags & OBD_CONNECT_MDS_CAPA))
-                return;
-
-        ci = md_capainfo(info->mti_env);
-        LASSERT(ci);
-        ci->mc_fid[offset]  = *fid;
-        ci->mc_capa[offset] = capa;
+       if (!info->mti_mdt->mdt_opts.mo_mds_capa ||
+           !(exp_connect_flags(info->mti_exp) & OBD_CONNECT_MDS_CAPA))
+               return;
+
+       ci = md_capainfo(info->mti_env);
+       LASSERT(ci);
+       ci->mc_fid[offset]  = *fid;
+       ci->mc_capa[offset] = capa;
 }
 
 static inline void mdt_dump_capainfo(struct mdt_thread_info *info)