Whamcloud - gitweb
LU-4563 Fix unsafe userspace access in many proc files
[fs/lustre-release.git] / lustre / mgs / mgs_internal.h
index 00aae38..457fbbb 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2012, Intel Corporation.
+ * Copyright (c) 2011, 2013, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -40,6 +40,7 @@
 #include <libcfs/libcfs.h>
 #include <lustre_log.h>
 #include <lustre_export.h>
+#include <lustre_nodemap.h>
 #include <dt_object.h>
 
 #define MGSSELF_NAME    "_mgs"
@@ -117,6 +118,7 @@ struct mgs_tgt_srpc_conf {
 #define FSDB_MGS_SELF           (3)  /* for '_mgs', used by sptlrpc */
 #define FSDB_OSCNAME18          (4)  /* old 1.8 style OSC naming */
 #define FSDB_UDESC              (5)  /* sptlrpc user desc, will be obsolete */
+#define FSDB_REVOKING_PARAMS   (6)  /* DLM lock is being revoked */
 
 struct fs_db {
         char              fsdb_name[9];
@@ -142,13 +144,13 @@ struct fs_db {
         /* Target NIDs Table */
         struct mgs_nidtbl    fsdb_nidtbl;
 
-        /* async thread to notify clients */
-       struct mgs_device   *fsdb_mgs;
-        cfs_waitq_t          fsdb_notify_waitq;
-       struct completion       fsdb_notify_comp;
-        cfs_time_t           fsdb_notify_start;
-        cfs_atomic_t         fsdb_notify_phase;
-        volatile int         fsdb_notify_async:1,
+       /* 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;
+       volatile unsigned int fsdb_notify_async:1,
                              fsdb_notify_stop:1;
         /* statistic data */
         unsigned int         fsdb_notify_total;
@@ -173,6 +175,7 @@ struct mgs_device {
        struct obd_device               *mgs_obd;
        struct local_oid_storage        *mgs_los;
        struct mutex                     mgs_mutex;
+       struct lu_target                 mgs_lut;
 };
 
 /* this is a top object */
@@ -205,6 +208,9 @@ int mgs_list_logs(const struct lu_env *env, struct mgs_device *mgs,
 int mgs_pool_cmd(const struct lu_env *env, struct mgs_device *mgs,
                 enum lcfg_command_type cmd, char *poolname, char *fsname,
                 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);
 
 /* mgs_handler.c */
 int  mgs_get_lock(struct obd_device *obd, struct ldlm_res_id *res,
@@ -221,12 +227,12 @@ 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);
+                        size_t count, void *data);
 int  lprocfs_rd_ir_state(struct seq_file *seq, void *data);
-int  lprocfs_wr_ir_timeout(struct file *file, const char *buffer,
-                           unsigned long count, void *data);
-int  lprocfs_rd_ir_timeout(char *page, char **start, off_t off, int count,
-                           int *eof, void *data);
+ssize_t
+lprocfs_ir_timeout_seq_write(struct file *file, const char *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);
 void mgs_fsc_cleanup_by_fsdb(struct fs_db *fsdb);
 int  mgs_fsc_attach(const struct lu_env *env, struct obd_export *exp,
@@ -239,26 +245,20 @@ 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);
 
-#define strsuf(buf, suffix) (strcmp((buf)+strlen(buf)-strlen(suffix), (suffix)))
 #ifdef LPROCFS
-int lproc_mgs_setup(struct mgs_device *mgs, char *osd_name);
+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);
 int lproc_mgs_del_live(struct mgs_device *mgs, struct fs_db *fsdb);
-void lprocfs_mgs_init_vars(struct lprocfs_static_vars *lvars);
 #else
-static inline int lproc_mgs_setup(struct mgs_device *mgs)
-{return 0;}
-static inline int lproc_mgs_cleanup(struct mgs_device *mgs)
+static inline int lproc_mgs_setup(struct mgs_device *mgs, const char *osd_name)
 {return 0;}
+static inline void lproc_mgs_cleanup(struct mgs_device *mgs)
+{}
 static inline int lproc_mgs_add_live(struct mgs_device *mgs, struct fs_db *fsdb)
 {return 0;}
 static inline int lproc_mgs_del_live(struct mgs_device *mgs, struct fs_db *fsdb)
 {return 0;}
-static void lprocfs_mgs_init_vars(struct lprocfs_static_vars *lvars)
-{
-        memset(lvars, 0, sizeof(*lvars));
-}
 #endif
 
 /* mgs/lproc_mgs.c */
@@ -291,9 +291,16 @@ extern struct lu_context_key mgs_thread_key;
 
 static inline struct mgs_thread_info *mgs_env_info(const struct lu_env *env)
 {
-       struct mgs_thread_info *info;
+       struct mgs_thread_info  *info;
+       int                     rc;
 
        info = lu_context_key_get(&env->le_ctx, &mgs_thread_key);
+       if (info == NULL) {
+               rc = lu_env_refill((struct lu_env *)env);
+               if (rc != 0)
+                       return ERR_PTR(rc);
+               info = lu_context_key_get(&env->le_ctx, &mgs_thread_key);
+       }
        LASSERT(info != NULL);
        return info;
 }