Whamcloud - gitweb
LU-8900 snapshot: new config for MDT write barrier
[fs/lustre-release.git] / lustre / mgs / mgs_internal.h
index d3baacd..46979e9 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
@@ -27,7 +23,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2013, Intel Corporation.
+ * Copyright (c) 2011, 2016, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
  */
 struct mgs_nidtbl;
 struct mgs_nidtbl_target {
-        cfs_list_t              mnt_list;
-        struct mgs_nidtbl      *mnt_fs;
-        u64                     mnt_version;
-        int                     mnt_type; /* OST or MDT */
-        cfs_time_t              mnt_last_active;
-        struct mgs_target_info  mnt_mti;
+       struct list_head        mnt_list;
+       struct mgs_nidtbl      *mnt_fs;
+       u64                     mnt_version;
+       int                     mnt_type;       /* OST or MDT */
+       cfs_time_t              mnt_last_active;
+       struct mgs_target_info  mnt_mti;
 };
 
 enum {
@@ -78,30 +74,30 @@ struct fs_db;
  * maintain fs client nodes of mgs.
  */
 struct mgs_fsc {
-        struct fs_db      *mfc_fsdb;
+       struct fs_db            *mfc_fsdb;
         /**
          * Where the fs client comes from.
          */
-        struct obd_export *mfc_export;
+       struct obd_export       *mfc_export;
         /**
          * list of fs clients from the same export,
          * protected by mgs_export_data->med_lock
          */
-        cfs_list_t         mfc_export_list;
+       struct list_head        mfc_export_list;
         /**
          * list of fs clients in the same fsdb, protected by fsdb->fsdb_mutex
          */
-        cfs_list_t        mfc_fsdb_list;
-        unsigned          mfc_ir_capable:1;
+       struct list_head        mfc_fsdb_list;
+       unsigned                mfc_ir_capable:1;
 };
 
 struct mgs_nidtbl {
-        struct fs_db *mn_fsdb;
-        struct file  *mn_version_file;
-       struct mutex    mn_lock;
-        u64           mn_version;
-        int           mn_nr_targets;
-        cfs_list_t    mn_targets;
+       struct fs_db            *mn_fsdb;
+       struct file             *mn_version_file;
+       struct mutex             mn_lock;
+       u64                      mn_version;
+       int                      mn_nr_targets;
+       struct list_head         mn_targets;
 };
 
 struct mgs_tgt_srpc_conf {
@@ -121,23 +117,29 @@ struct mgs_tgt_srpc_conf {
 #define FSDB_REVOKING_PARAMS   (6)  /* DLM lock is being revoked */
 
 struct fs_db {
-        char              fsdb_name[9];
-        cfs_list_t        fsdb_list;           /* list of databases */
+       char              fsdb_name[20];
+       struct list_head  fsdb_list;            /* list of databases */
        struct mutex      fsdb_mutex;
-        void             *fsdb_ost_index_map;  /* bitmap of used indicies */
-        void             *fsdb_mdt_index_map;  /* bitmap of used indicies */
-        int               fsdb_mdt_count;
-        char             *fsdb_clilov;       /* COMPAT_146 client lov name */
-        char             *fsdb_clilmv;
-        unsigned long     fsdb_flags;
-        __u32             fsdb_gen;
+       union {
+               void     *fsdb_ost_index_map;   /* bitmap of used indicies */
+               void     *fsdb_barrier_map;     /* bitmap of barrier */
+       };
+       void             *fsdb_mdt_index_map;   /* bitmap of used indicies */
+       atomic_t          fsdb_ref;
+       int               fsdb_mdt_count;
+       char             *fsdb_clilov;  /* COMPAT_146 client lov name */
+       char             *fsdb_clilmv;
+       unsigned long     fsdb_flags;
+       __u32             fsdb_barrier_status;
+       __u32             fsdb_barrier_timeout;
+       time_t            fsdb_barrier_latest_create_time;
 
         /* in-memory copy of the srpc rules, guarded by fsdb_lock */
         struct sptlrpc_rule_set   fsdb_srpc_gen;
         struct mgs_tgt_srpc_conf *fsdb_srpc_tgt;
 
         /* list of fs clients, mgs_fsc. protected by mgs_mutex */
-        cfs_list_t           fsdb_clients;
+       struct list_head     fsdb_clients;
         int                  fsdb_nonir_clients;
         int                  fsdb_ir_state;
 
@@ -146,16 +148,19 @@ struct fs_db {
 
        /* async thread to notify clients */
        struct mgs_device    *fsdb_mgs;
-       wait_queue_head_t    fsdb_notify_waitq;
-       struct completion    fsdb_notify_comp;
-       cfs_time_t           fsdb_notify_start;
-       atomic_t         fsdb_notify_phase;
+       wait_queue_head_t     fsdb_notify_waitq;
+       struct completion     fsdb_notify_comp;
+       cfs_time_t            fsdb_notify_start;
+       atomic_t              fsdb_notify_phase;
        volatile unsigned int fsdb_notify_async:1,
-                             fsdb_notify_stop:1;
-        /* statistic data */
-        unsigned int         fsdb_notify_total;
-        unsigned int         fsdb_notify_max;
-        unsigned int         fsdb_notify_count;
+                             fsdb_notify_stop:1,
+                             fsdb_has_lproc_entry:1,
+                             fsdb_barrier_disabled:1;
+       /* statistic data */
+       unsigned int    fsdb_notify_total;
+       unsigned int    fsdb_notify_max;
+       unsigned int    fsdb_notify_count;
+       __u32           fsdb_gen;
 };
 
 struct mgs_device {
@@ -165,16 +170,18 @@ struct mgs_device {
        struct obd_export               *mgs_bottom_exp;
        struct dt_object                *mgs_configs_dir;
        struct dt_object                *mgs_nidtbl_dir;
-       cfs_list_t                       mgs_fs_db_list;
+       struct list_head                 mgs_fs_db_list;
        spinlock_t                       mgs_lock; /* covers mgs_fs_db_list */
-       cfs_proc_dir_entry_t            *mgs_proc_live;
-       cfs_proc_dir_entry_t            *mgs_proc_osd;
-       cfs_proc_dir_entry_t            *mgs_proc_fstype;
-       cfs_proc_dir_entry_t            *mgs_proc_mntdev;
+       struct proc_dir_entry           *mgs_proc_live;
+       struct proc_dir_entry           *mgs_proc_osd;
+       struct proc_dir_entry           *mgs_proc_fstype;
+       struct proc_dir_entry           *mgs_proc_mntdev;
        cfs_time_t                       mgs_start_time;
        struct obd_device               *mgs_obd;
        struct local_oid_storage        *mgs_los;
        struct mutex                     mgs_mutex;
+       struct mutex                     mgs_health_mutex;
+       struct rw_semaphore              mgs_barrier_rwsem;
        struct lu_target                 mgs_lut;
 };
 
@@ -188,19 +195,25 @@ struct mgs_object {
 
 int mgs_init_fsdb_list(struct mgs_device *mgs);
 int mgs_cleanup_fsdb_list(struct mgs_device *mgs);
-int mgs_find_or_make_fsdb(const struct lu_env *env, struct mgs_device *mgs, char *name,
-                          struct fs_db **dbh);
-struct fs_db *mgs_find_fsdb(struct mgs_device *mgs, char *fsname);
-int mgs_get_fsdb_srpc_from_llog(const struct lu_env *env, struct mgs_device *mgs, struct fs_db *fsdb);
-int mgs_check_index(const struct lu_env *env, struct mgs_device *mgs, struct mgs_target_info *mti);
-int mgs_check_failnid(const struct lu_env *env, struct mgs_device *mgs, struct mgs_target_info *mti);
-int mgs_write_log_target(const struct lu_env *env, struct mgs_device *mgs, struct mgs_target_info *mti,
-                        struct fs_db *fsdb);
-int mgs_replace_nids(const struct lu_env *env, struct mgs_device *mgs, char *devname, char *nids);
+int mgs__mgs_fsdb_setup(const struct lu_env *env, struct mgs_device *mgs);
+int mgs_params_fsdb_setup(const struct lu_env *env, struct mgs_device *mgs);
+int mgs_params_fsdb_cleanup(const struct lu_env *env, struct mgs_device *mgs);
+int mgs_find_or_make_fsdb(const struct lu_env *env, struct mgs_device *mgs,
+                         char *name, struct fs_db **dbh);
+struct fs_db *mgs_find_fsdb(struct mgs_device *mgs, const char *fsname);
+void mgs_put_fsdb(struct mgs_device *mgs, struct fs_db *fsdb);
+int mgs_get_fsdb_srpc_from_llog(const struct lu_env *env,
+                               struct mgs_device *mgs, struct fs_db *fsdb);
+int mgs_check_index(const struct lu_env *env, struct mgs_device *mgs,
+                   struct mgs_target_info *mti);
+int mgs_write_log_target(const struct lu_env *env, struct mgs_device *mgs,
+                        struct mgs_target_info *mti, struct fs_db *fsdb);
+int mgs_replace_nids(const struct lu_env *env, struct mgs_device *mgs,
+                    char *devname, char *nids);
 int mgs_erase_log(const struct lu_env *env, struct mgs_device *mgs,
                  char *name);
 int mgs_erase_logs(const struct lu_env *env, struct mgs_device *mgs,
-                  char *fsname);
+                  const char *fsname);
 int mgs_setparam(const struct lu_env *env, struct mgs_device *mgs,
                 struct lustre_cfg *lcfg, char *fsname);
 int mgs_list_logs(const struct lu_env *env, struct mgs_device *mgs,
@@ -210,7 +223,7 @@ int mgs_pool_cmd(const struct lu_env *env, struct mgs_device *mgs,
                 char *ostname);
 int mgs_nodemap_cmd(const struct lu_env *env, struct mgs_device *mgs,
                    enum lcfg_command_type cmd, const char *nodemap_name,
-                   const char *param);
+                   char *param);
 
 /* mgs_handler.c */
 int  mgs_get_lock(struct obd_device *obd, struct ldlm_res_id *res,
@@ -226,11 +239,11 @@ int mgs_ir_init_fs(const struct lu_env *env, struct mgs_device *mgs,
 void mgs_ir_fini_fs(struct mgs_device *mgs, struct fs_db *fsdb);
 void mgs_ir_notify_complete(struct fs_db *fsdb);
 int  mgs_get_ir_logs(struct ptlrpc_request *req);
-int  lprocfs_wr_ir_state(struct file *file, const char *buffer,
-                           unsigned long count, void *data);
+int  lprocfs_wr_ir_state(struct file *file, const char __user *buffer,
+                        size_t count, void *data);
 int  lprocfs_rd_ir_state(struct seq_file *seq, void *data);
 ssize_t
-lprocfs_ir_timeout_seq_write(struct file *file, const char *buffer,
+lprocfs_ir_timeout_seq_write(struct file *file, const char __user *buffer,
                             size_t count, loff_t *off);
 int  lprocfs_ir_timeout_seq_show(struct seq_file *seq, void *data);
 void mgs_fsc_cleanup(struct obd_export *exp);
@@ -245,7 +258,7 @@ int mgs_client_free(struct obd_export *exp);
 int mgs_fs_setup(const struct lu_env *env, struct mgs_device *m);
 int mgs_fs_cleanup(const struct lu_env *env, struct mgs_device *m);
 
-#ifdef LPROCFS
+#ifdef CONFIG_PROC_FS
 int lproc_mgs_setup(struct mgs_device *mgs, const char *osd_name);
 void lproc_mgs_cleanup(struct mgs_device *mgs);
 int lproc_mgs_add_live(struct mgs_device *mgs, struct fs_db *fsdb);
@@ -362,22 +375,18 @@ static inline struct dt_object* mgs_object_child(struct mgs_object *o)
                             struct dt_object, do_lu);
 }
 
-static inline struct dt_object *dt_object_child(struct dt_object *o)
-{
-       return container_of0(lu_object_next(&(o)->do_lu),
-                            struct dt_object, do_lu);
-}
 struct mgs_direntry {
-       cfs_list_t  list;
-       char       *name;
-       int         len;
+       struct list_head         mde_list;
+       char                    *mde_name;
+       int                      mde_len;
 };
 
 static inline void mgs_direntry_free(struct mgs_direntry *de)
 {
+       LASSERT(list_empty(&de->mde_list));
        if (de) {
-               LASSERT(de->len);
-               OBD_FREE(de->name, de->len);
+               LASSERT(de->mde_len);
+               OBD_FREE(de->mde_name, de->mde_len);
                OBD_FREE_PTR(de);
        }
 }
@@ -390,19 +399,20 @@ static inline struct mgs_direntry *mgs_direntry_alloc(int len)
        if (de == NULL)
                return NULL;
 
-       OBD_ALLOC(de->name, len);
-       if (de->name == NULL) {
+       OBD_ALLOC(de->mde_name, len);
+       if (de->mde_name == NULL) {
                OBD_FREE_PTR(de);
                return NULL;
        }
 
-       de->len = len;
+       de->mde_len = len;
+       INIT_LIST_HEAD(&de->mde_list);
 
        return de;
 }
 
 /* mgs_llog.c */
 int class_dentry_readdir(const struct lu_env *env, struct mgs_device *mgs,
-                        cfs_list_t *list);
+                        struct list_head *list);
 
 #endif /* _MGS_INTERNAL_H */