Whamcloud - gitweb
LU-6271 osc: handle osc eviction correctly
[fs/lustre-release.git] / lustre / osc / osc_cl_internal.h
index 1518db4..65658f6 100644 (file)
@@ -77,8 +77,6 @@ struct osc_io {
        struct osc_extent *oi_trunc;
        /** write osc_lock for this IO, used by osc_extent_find(). */
        struct osc_lock   *oi_write_osclock;
-
-       struct obd_info    oi_info;
        struct obdo        oi_oa;
        struct osc_async_cbargs {
                bool              opc_rpc_sent;
@@ -103,12 +101,12 @@ struct osc_session {
 
 #define OTI_PVEC_SIZE 256
 struct osc_thread_info {
-        struct ldlm_res_id      oti_resname;
-        ldlm_policy_data_t      oti_policy;
-        struct cl_lock_descr    oti_descr;
-        struct cl_attr          oti_attr;
-        struct lustre_handle    oti_handle;
-        struct cl_page_list     oti_plist;
+       struct ldlm_res_id      oti_resname;
+       union ldlm_policy_data  oti_policy;
+       struct cl_lock_descr    oti_descr;
+       struct cl_attr          oti_attr;
+       struct lustre_handle    oti_handle;
+       struct cl_page_list     oti_plist;
        struct cl_io            oti_io;
        void                    *oti_pvec[OTI_PVEC_SIZE];
        /**
@@ -135,16 +133,6 @@ struct osc_object {
         /** Serialization object for osc_object::oo_debug_io. */
        struct mutex       oo_debug_mutex;
 #endif
-        /**
-         * List of pages in transfer.
-         */
-       struct list_head        oo_inflight[CRT_NR];
-        /**
-         * Lock, protecting ccc_object::cob_inflight, because a seat-belt is
-         * locked during take-off and landing.
-         */
-       spinlock_t              oo_seatbelt;
-
        /**
         * used by the osc to keep track of what objects to build into rpcs.
         * Protected by client_obd->cli_loi_list_lock.
@@ -184,6 +172,10 @@ struct osc_object {
        /* Protect osc_lock this osc_object has */
        spinlock_t              oo_ol_spin;
        struct list_head        oo_ol_list;
+
+       /** number of active IOs of this object */
+       atomic_t                oo_nr_ios;
+       wait_queue_head_t       oo_io_waitq;
 };
 
 static inline void osc_object_lock(struct osc_object *obj)
@@ -378,15 +370,6 @@ struct osc_page {
         */
        struct list_head        ops_lru;
        /**
-        * Linkage into a per-osc_object list of pages in flight. For
-        * debugging.
-        */
-       struct list_head        ops_inflight;
-       /**
-        * Thread that submitted this page for transfer. For debugging.
-        */
-       struct task_struct           *ops_submitter;
-       /**
         * Submit time - the time when the page is starting RPC. For debugging.
         */
        cfs_time_t            ops_submit_time;
@@ -418,17 +401,17 @@ struct lu_object *osc_object_alloc(const struct lu_env *env,
 int osc_page_init(const struct lu_env *env, struct cl_object *obj,
                  struct cl_page *page, pgoff_t ind);
 
-void osc_index2policy  (ldlm_policy_data_t *policy, const struct cl_object *obj,
-                        pgoff_t start, pgoff_t end);
-int  osc_lvb_print     (const struct lu_env *env, void *cookie,
-                        lu_printer_t p, const struct ost_lvb *lvb);
+void osc_index2policy(union ldlm_policy_data *policy,
+                     const struct cl_object *obj, pgoff_t start, pgoff_t end);
+int  osc_lvb_print(const struct lu_env *env, void *cookie,
+                  lu_printer_t p, const struct ost_lvb *lvb);
 
 void osc_lru_add_batch(struct client_obd *cli, struct list_head *list);
 void osc_page_submit(const struct lu_env *env, struct osc_page *opg,
                     enum cl_req_type crt, int brw_flags);
 int osc_cancel_async_page(const struct lu_env *env, struct osc_page *ops);
 int osc_set_async_flags(struct osc_object *obj, struct osc_page *opg,
-                       obd_flag async_flags);
+                       u32 async_flags);
 int osc_prep_async_page(struct osc_object *osc, struct osc_page *ops,
                        struct page *page, loff_t offset);
 int osc_queue_async_io(const struct lu_env *env, struct cl_io *io,
@@ -441,16 +424,15 @@ int osc_flush_async_page(const struct lu_env *env, struct cl_io *io,
                         struct osc_page *ops);
 int osc_queue_sync_pages(const struct lu_env *env, struct osc_object *obj,
                         struct list_head *list, int cmd, int brw_flags);
-int osc_cache_truncate_start(const struct lu_env *env, struct osc_io *oio,
-                            struct osc_object *obj, __u64 size);
-void osc_cache_truncate_end(const struct lu_env *env, struct osc_io *oio,
-                           struct osc_object *obj);
+int osc_cache_truncate_start(const struct lu_env *env, struct osc_object *obj,
+                            __u64 size, struct osc_extent **extp);
+void osc_cache_truncate_end(const struct lu_env *env, struct osc_extent *ext);
 int osc_cache_writeback_range(const struct lu_env *env, struct osc_object *obj,
                              pgoff_t start, pgoff_t end, int hp, int discard);
 int osc_cache_wait_range(const struct lu_env *env, struct osc_object *obj,
                         pgoff_t start, pgoff_t end);
 void osc_io_unplug(const struct lu_env *env, struct client_obd *cli,
-                  struct osc_object *osc, pdl_policy_t pol);
+                  struct osc_object *osc);
 int lru_queue_work(const struct lu_env *env, void *data);
 
 void osc_object_set_contended  (struct osc_object *obj);
@@ -520,26 +502,24 @@ static inline struct cl_object *osc2cl(const struct osc_object *obj)
        return (struct cl_object *)&obj->oo_cl;
 }
 
-static inline ldlm_mode_t osc_cl_lock2ldlm(enum cl_lock_mode mode)
+static inline enum ldlm_mode osc_cl_lock2ldlm(enum cl_lock_mode mode)
 {
-        LASSERT(mode == CLM_READ || mode == CLM_WRITE || mode == CLM_GROUP);
-        if (mode == CLM_READ)
-                return LCK_PR;
-        else if (mode == CLM_WRITE)
-                return LCK_PW;
-        else
-                return LCK_GROUP;
+       LASSERT(mode == CLM_READ || mode == CLM_WRITE || mode == CLM_GROUP);
+       if (mode == CLM_READ)
+               return LCK_PR;
+       if (mode == CLM_WRITE)
+               return LCK_PW;
+       return LCK_GROUP;
 }
 
-static inline enum cl_lock_mode osc_ldlm2cl_lock(ldlm_mode_t mode)
+static inline enum cl_lock_mode osc_ldlm2cl_lock(enum ldlm_mode mode)
 {
-        LASSERT(mode == LCK_PR || mode == LCK_PW || mode == LCK_GROUP);
-        if (mode == LCK_PR)
-                return CLM_READ;
-        else if (mode == LCK_PW)
-                return CLM_WRITE;
-        else
-                return CLM_GROUP;
+       LASSERT(mode == LCK_PR || mode == LCK_PW || mode == LCK_GROUP);
+       if (mode == LCK_PR)
+               return CLM_READ;
+       if (mode == LCK_PW)
+               return CLM_WRITE;
+       return CLM_GROUP;
 }
 
 static inline struct osc_page *cl2osc_page(const struct cl_page_slice *slice)
@@ -622,7 +602,7 @@ struct osc_extent {
        /** link list of osc_object's oo_{hp|urgent|locking}_exts. */
        struct list_head        oe_link;
        /** state of this extent */
-       unsigned int            oe_state;
+       enum osc_extent_state   oe_state;
        /** flags for this extent. */
        unsigned int            oe_intree:1,
        /** 0 is write, 1 is read */