Whamcloud - gitweb
LU-1303 osp: land precreate code
[fs/lustre-release.git] / lustre / osp / osp_internal.h
index e572552..541ed00 100644 (file)
@@ -53,8 +53,12 @@ struct osp_device {
        struct obd_export               *opd_storage_exp;
        struct dt_device                *opd_storage;
        struct dt_object                *opd_last_used_file;
        struct obd_export               *opd_storage_exp;
        struct dt_device                *opd_storage;
        struct dt_object                *opd_last_used_file;
-       /* protected by opd_pre_lock */
+
+       /* stored persistently in LE format, updated directly to/from disk
+        * and required le64_to_cpu() conversion before use.
+        * Protected by opd_pre_lock */
        volatile obd_id                  opd_last_used_id;
        volatile obd_id                  opd_last_used_id;
+
        obd_id                           opd_gap_start;
        int                              opd_gap_count;
        /* connection to OST */
        obd_id                           opd_gap_start;
        int                              opd_gap_count;
        /* connection to OST */
@@ -76,6 +80,41 @@ struct osp_device {
         * reported via ->ldo_recovery_complete() */
        int                              opd_recovery_completed;
 
         * reported via ->ldo_recovery_complete() */
        int                              opd_recovery_completed;
 
+       /*
+        * Precreation pool
+        */
+       cfs_spinlock_t                   opd_pre_lock;
+       /* next id to assign in creation */
+       __u64                            opd_pre_next;
+       /* last created id OST reported, next-created - available id's */
+       __u64                            opd_pre_last_created;
+       /* how many ids are reserved in declare, we shouldn't block in create */
+       __u64                            opd_pre_reserved;
+       /* dedicate precreate thread */
+       struct ptlrpc_thread             opd_pre_thread;
+       /* thread waits for signals about pool going empty */
+       cfs_waitq_t                      opd_pre_waitq;
+       /* consumers (who needs new ids) wait here */
+       cfs_waitq_t                      opd_pre_user_waitq;
+       /* current precreation status: working, failed, stopping? */
+       int                              opd_pre_status;
+       /* how many to precreate next time */
+       int                              opd_pre_grow_count;
+       int                              opd_pre_min_grow_count;
+       int                              opd_pre_max_grow_count;
+       /* whether to grow precreation window next time or not */
+       int                              opd_pre_grow_slow;
+
+       /*
+        * statfs related fields: OSP maintains it on its own
+        */
+       struct obd_statfs                opd_statfs;
+       cfs_time_t                       opd_statfs_fresh_till;
+       cfs_timer_t                      opd_statfs_timer;
+       int                              opd_statfs_update_in_progress;
+       /* how often to update statfs data */
+       int                              opd_statfs_maxage;
+
        cfs_proc_dir_entry_t            *opd_symlink;
 };
 
        cfs_proc_dir_entry_t            *opd_symlink;
 };
 
@@ -94,6 +133,7 @@ struct osp_thread_info {
        struct lu_buf            osi_lb;
        struct lu_fid            osi_fid;
        struct lu_attr           osi_attr;
        struct lu_buf            osi_lb;
        struct lu_fid            osi_fid;
        struct lu_attr           osi_attr;
+       struct ost_id            osi_oi;
        obd_id                   osi_id;
        loff_t                   osi_off;
 };
        obd_id                   osi_id;
        loff_t                   osi_off;
 };
@@ -190,6 +230,15 @@ static inline struct dt_object *osp_object_child(struct osp_object *o)
 /* osp_dev.c */
 void osp_update_last_id(struct osp_device *d, obd_id objid);
 
 /* osp_dev.c */
 void osp_update_last_id(struct osp_device *d, obd_id objid);
 
+/* osp_precreate.c */
+int osp_init_precreate(struct osp_device *d);
+int osp_precreate_reserve(const struct lu_env *env, struct osp_device *d);
+__u64 osp_precreate_get_id(struct osp_device *d);
+void osp_precreate_fini(struct osp_device *d);
+int osp_object_truncate(const struct lu_env *env, struct dt_object *dt, __u64);
+void osp_pre_update_status(struct osp_device *d, int rc);
+void osp_statfs_need_now(struct osp_device *d);
+
 /* lproc_osp.c */
 void lprocfs_osp_init_vars(struct lprocfs_static_vars *lvars);
 
 /* lproc_osp.c */
 void lprocfs_osp_init_vars(struct lprocfs_static_vars *lvars);