Whamcloud - gitweb
LU-3285 osc: prepare OSC code to be used from MDC 96/22996/18
authorMikhal Pershin <mike.pershin@intel.com>
Fri, 4 Dec 2015 20:05:10 +0000 (23:05 +0300)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 19 Jul 2017 03:28:30 +0000 (03:28 +0000)
Move osc/osc_cl_include.h to include/lustre_osc.h
to be included from both OSC and MDC.

Change-Id: Ic04995d8793cd64b998463aee59c6bf30445b64b
Signed-off-by: Mikhal Pershin <mike.pershin@intel.com>
Reviewed-on: https://review.whamcloud.com/22996
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
13 files changed:
lustre/include/Makefile.am
lustre/include/lustre_osc.h [moved from lustre/osc/osc_cl_internal.h with 73% similarity]
lustre/osc/Makefile.in
lustre/osc/lproc_osc.c
lustre/osc/osc_cache.c
lustre/osc/osc_dev.c
lustre/osc/osc_internal.h
lustre/osc/osc_io.c
lustre/osc/osc_lock.c
lustre/osc/osc_object.c
lustre/osc/osc_page.c
lustre/osc/osc_quota.c
lustre/osc/osc_request.c

index 1a2fa30..e97ba30 100644 (file)
@@ -69,6 +69,7 @@ EXTRA_DIST = \
        lustre_mdc.h \
        lustre_mds.h \
        lustre_net.h \
+       lustre_osc.h \
        lustre_nodemap.h \
        lustre_nrs.h \
        lustre_nrs_crr.h \
similarity index 73%
rename from lustre/osc/osc_cl_internal.h
rename to lustre/include/lustre_osc.h
index f9b9faf..77ee34b 100644 (file)
  * Lustre is a trademark of Sun Microsystems, Inc.
  */
 /*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
+ * lustre/include/lustre_osc.h
+ *
+ * OSC layer structures and methods common for both OSC and MDC.
  *
- * Internal interfaces of OSC layer.
+ * This file contains OSC interfaces used by OSC and MDC. Most of them
+ * were just moved from lustre/osc/osc_cl_internal.h for Data-on-MDT
+ * purposes.
  *
  *   Author: Nikita Danilov <nikita.danilov@sun.com>
  *   Author: Jinshan Xiong <jinshan.xiong@whamcloud.com>
+ *   Author: Mikhail Pershin <mike.pershin@intel.com>
  */
 
-#ifndef OSC_CL_INTERNAL_H
-#define OSC_CL_INTERNAL_H
+#ifndef LUSTRE_OSC_H
+#define LUSTRE_OSC_H
 
 #include <libcfs/libcfs.h>
 #include <obd.h>
-/* osc_build_res_name() */
 #include <cl_object.h>
-#include "osc_internal.h"
 
 /** \defgroup osc osc
  *  @{
  */
 
+struct osc_quota_info {
+       /** linkage for quota hash table */
+       struct hlist_node oqi_hash;
+       __u32             oqi_id;
+};
+
+enum async_flags {
+       ASYNC_READY = 0x1, /* ap_make_ready will not be called before this
+                             page is added to an rpc */
+       ASYNC_URGENT = 0x2, /* page must be put into an RPC before return */
+       ASYNC_COUNT_STABLE = 0x4, /* ap_refresh_count will not be called
+                                    to give the caller a chance to update
+                                    or cancel the size of the io */
+       ASYNC_HP = 0x10,
+};
+
+struct osc_async_page {
+       int                     oap_magic;
+       unsigned short          oap_cmd;
+       unsigned short          oap_interrupted:1;
+
+       struct list_head        oap_pending_item;
+       struct list_head        oap_rpc_item;
+
+       loff_t                  oap_obj_off;
+       unsigned                oap_page_off;
+       enum async_flags        oap_async_flags;
+
+       struct brw_page         oap_brw_page;
+
+       struct ptlrpc_request   *oap_request;
+       struct client_obd       *oap_cli;
+       struct osc_object       *oap_obj;
+
+       spinlock_t               oap_lock;
+};
+
+#define oap_page       oap_brw_page.pg
+#define oap_count      oap_brw_page.count
+#define oap_brw_flags  oap_brw_page.flag
+
+static inline struct osc_async_page *brw_page2oap(struct brw_page *pga)
+{
+       return container_of(pga, struct osc_async_page, oap_brw_page);
+}
+
+struct osc_cache_waiter {
+       struct list_head        ocw_entry;
+       wait_queue_head_t       ocw_waitq;
+       struct osc_async_page   *ocw_oap;
+       int                     ocw_grant;
+       int                     ocw_rc;
+};
+
+struct osc_device {
+       struct cl_device        od_cl;
+       struct obd_export       *od_exp;
+
+       /* Write stats is actually protected by client_obd's lock. */
+       struct osc_stats {
+               uint64_t        os_lockless_writes;    /* by bytes */
+               uint64_t        os_lockless_reads;     /* by bytes */
+               uint64_t        os_lockless_truncates; /* by times */
+       } od_stats;
+
+       /* configuration item(s) */
+       int                     od_contention_time;
+       int                     od_lockless_truncate;
+};
+
 struct osc_extent;
 
 /**
@@ -78,8 +150,8 @@ struct osc_io {
        struct obdo        oi_oa;
        struct osc_async_cbargs {
                bool              opc_rpc_sent;
-               int               opc_rc;
-               struct completion       opc_sync;
+               int               opc_rc;
+               struct completion opc_sync;
        } oi_cbarg;
 };
 
@@ -87,7 +159,7 @@ struct osc_io {
  * State maintained by osc layer for the duration of a system call.
  */
 struct osc_session {
-        struct osc_io       os_io;
+       struct osc_io os_io;
 };
 
 #define OTI_PVEC_SIZE 256
@@ -111,20 +183,20 @@ struct osc_thread_info {
 };
 
 struct osc_object {
-        struct cl_object   oo_cl;
-        struct lov_oinfo  *oo_oinfo;
-        /**
-         * True if locking against this stripe got -EUSERS.
-         */
-        int                oo_contended;
-        cfs_time_t         oo_contention_time;
+       struct cl_object        oo_cl;
+       struct lov_oinfo        *oo_oinfo;
+       /**
+        * True if locking against this stripe got -EUSERS.
+        */
+       int                     oo_contended;
+       cfs_time_t              oo_contention_time;
 #ifdef CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK
-        /**
-         * IO context used for invariant checks in osc_lock_has_pages().
-         */
-        struct cl_io       oo_debug_io;
-        /** Serialization object for osc_object::oo_debug_io. */
-       struct mutex       oo_debug_mutex;
+       /**
+        * IO context used for invariant checks in osc_lock_has_pages().
+        */
+       struct cl_io            oo_debug_io;
+       /** Serialization object for osc_object::oo_debug_io. */
+       struct mutex            oo_debug_mutex;
 #endif
        /**
         * used by the osc to keep track of what objects to build into rpcs.
@@ -138,7 +210,7 @@ struct osc_object {
        /**
         * extent is a red black tree to manage (async) dirty pages.
         */
-       struct rb_root       oo_root;
+       struct rb_root          oo_root;
        /**
         * Manage write(dirty) extents.
         */
@@ -148,12 +220,12 @@ struct osc_object {
 
        struct list_head        oo_reading_exts;
 
-       atomic_t         oo_nr_reads;
-       atomic_t         oo_nr_writes;
+       atomic_t                oo_nr_reads;
+       atomic_t                oo_nr_writes;
 
        /** Protect extent tree. Will be used to protect
         * oo_{read|write}_pages soon. */
-       spinlock_t          oo_lock;
+       spinlock_t              oo_lock;
 
        /**
         * Radix tree for caching pages
@@ -169,6 +241,8 @@ struct osc_object {
        /** number of active IOs of this object */
        atomic_t                oo_nr_ios;
        wait_queue_head_t       oo_io_waitq;
+
+       bool                    oo_initialized;
 };
 
 static inline void osc_object_lock(struct osc_object *obj)
@@ -204,11 +278,11 @@ static inline int osc_object_is_locked(struct osc_object *obj)
  * Lock "micro-states" for osc layer.
  */
 enum osc_lock_state {
-        OLS_NEW,
-        OLS_ENQUEUED,
-        OLS_UPCALL_RECEIVED,
-        OLS_GRANTED,
-        OLS_CANCELLED
+       OLS_NEW,
+       OLS_ENQUEUED,
+       OLS_UPCALL_RECEIVED,
+       OLS_GRANTED,
+       OLS_CANCELLED
 };
 
 /**
@@ -271,53 +345,52 @@ struct osc_lock {
        /** DLM flags with which osc_lock::ols_lock was enqueued */
        __u64                   ols_flags;
        /** osc_lock::ols_lock handle */
-       struct lustre_handle     ols_handle;
+       struct lustre_handle    ols_handle;
        struct ldlm_enqueue_info ols_einfo;
-       enum osc_lock_state      ols_state;
+       enum osc_lock_state     ols_state;
        /** lock value block */
        struct ost_lvb          ols_lvb;
 
-        /**
-         * true, if ldlm_lock_addref() was called against
-         * osc_lock::ols_lock. This is used for sanity checking.
-         *
-         * \see osc_lock::ols_has_ref
-         */
-        unsigned                  ols_hold :1,
-        /**
-         * this is much like osc_lock::ols_hold, except that this bit is
-         * cleared _after_ reference in released in osc_lock_unuse(). This
-         * fine distinction is needed because:
-         *
-         *     - if ldlm lock still has a reference, osc_ast_data_get() needs
-         *       to return associated cl_lock (so that a flag is needed that is
-         *       cleared after ldlm_lock_decref() returned), and
-         *
-         *     - ldlm_lock_decref() can invoke blocking ast (for a
-         *       LDLM_FL_CBPENDING lock), and osc_lock functions like
-         *       osc_lock_cancel() called from there need to know whether to
-         *       release lock reference (so that a flag is needed that is
-         *       cleared before ldlm_lock_decref() is called).
-         */
-                                 ols_has_ref:1,
-        /**
-         * inherit the lockless attribute from top level cl_io.
-         * If true, osc_lock_enqueue is able to tolerate the -EUSERS error.
-         */
-                                 ols_locklessable:1,
-        /**
-         * if set, the osc_lock is a glimpse lock. For glimpse locks, we treat
-         * the EVAVAIL error as torerable, this will make upper logic happy
-         * to wait all glimpse locks to each OSTs to be completed.
-         * Glimpse lock converts to normal lock if the server lock is
-         * granted.
-         * Glimpse lock should be destroyed immediately after use.
-         */
-                                 ols_glimpse:1,
-        /**
-         * For async glimpse lock.
-         */
-                                 ols_agl:1;
+       /**
+        * true, if ldlm_lock_addref() was called against
+        * osc_lock::ols_lock. This is used for sanity checking.
+        *
+        * \see osc_lock::ols_has_ref
+        */
+       unsigned                ols_hold :1,
+       /**
+        * this is much like osc_lock::ols_hold, except that this bit is
+        * cleared _after_ reference in released in osc_lock_unuse(). This
+        * fine distinction is needed because:
+        *
+        *     - if ldlm lock still has a reference, osc_ast_data_get() needs
+        *       to return associated cl_lock (so that a flag is needed that is
+        *       cleared after ldlm_lock_decref() returned), and
+        *
+        *     - ldlm_lock_decref() can invoke blocking ast (for a
+        *       LDLM_FL_CBPENDING lock), and osc_lock functions like
+        *       osc_lock_cancel() called from there need to know whether to
+        *       release lock reference (so that a flag is needed that is
+        *       cleared before ldlm_lock_decref() is called).
+        */
+                               ols_has_ref:1,
+       /**
+        * inherit the lockless attribute from top level cl_io.
+        * If true, osc_lock_enqueue is able to tolerate the -EUSERS error.
+        */
+                               ols_locklessable:1,
+       /**
+        * if set, the osc_lock is a glimpse lock. For glimpse locks, we treat
+        * the EVAVAIL error as torerable, this will make upper logic happy
+        * to wait all glimpse locks to each OSTs to be completed.
+        * Glimpse lock converts to normal lock if the server lock is granted.
+        * Glimpse lock should be destroyed immediately after use.
+        */
+                               ols_glimpse:1,
+       /**
+        * For async glimpse lock.
+        */
+                               ols_agl:1;
 };
 
 
@@ -348,11 +421,11 @@ struct osc_page {
        /**
         * in LRU?
         */
-                             ops_in_lru:1,
+                               ops_in_lru:1,
        /**
         * Set if the page must be transferred with OBD_BRW_SRVLOCK.
         */
-                             ops_srvlock:1;
+                               ops_srvlock:1;
        /**
         * lru page list. See osc_lru_{del|use}() in osc_page.c for usage.
         */
@@ -360,7 +433,7 @@ struct osc_page {
        /**
         * Submit time - the time when the page is starting RPC. For debugging.
         */
-       cfs_time_t            ops_submit_time;
+       cfs_time_t              ops_submit_time;
 };
 
 extern struct kmem_cache *osc_lock_kmem;
@@ -368,26 +441,17 @@ extern struct kmem_cache *osc_object_kmem;
 extern struct kmem_cache *osc_thread_kmem;
 extern struct kmem_cache *osc_session_kmem;
 extern struct kmem_cache *osc_extent_kmem;
+extern struct kmem_cache *osc_quota_kmem;
 
-extern struct lu_device_type osc_device_type;
 extern struct lu_context_key osc_key;
 extern struct lu_context_key osc_session_key;
 
 #define OSC_FLAGS (ASYNC_URGENT|ASYNC_READY)
 
-int osc_lock_init(const struct lu_env *env,
-                  struct cl_object *obj, struct cl_lock *lock,
-                  const struct cl_io *io);
-int osc_io_init  (const struct lu_env *env,
-                  struct cl_object *obj, struct cl_io *io);
-struct lu_object *osc_object_alloc(const struct lu_env *env,
-                                   const struct lu_object_header *hdr,
-                                   struct lu_device *dev);
 int osc_page_init(const struct lu_env *env, struct cl_object *obj,
                  struct cl_page *page, pgoff_t ind);
-
-void osc_index2policy(union ldlm_policy_data *policy,
-                     const struct cl_object *obj, pgoff_t start, pgoff_t end);
+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);
 
@@ -420,55 +484,47 @@ void osc_io_unplug(const struct lu_env *env, struct client_obd *cli,
                   struct osc_object *osc);
 int lru_queue_work(const struct lu_env *env, void *data);
 
-void osc_object_set_contended  (struct osc_object *obj);
+void osc_object_set_contended(struct osc_object *obj);
 void osc_object_clear_contended(struct osc_object *obj);
-int  osc_object_is_contended   (struct osc_object *obj);
-
-int  osc_lock_is_lockless      (const struct osc_lock *olck);
+int osc_object_is_contended(struct osc_object *obj);
+int osc_lock_is_lockless(const struct osc_lock *olck);
 
 /*****************************************************************************
  *
- * Accessors.
+ * Accessors and type conversions.
  *
  */
-
 static inline struct osc_thread_info *osc_env_info(const struct lu_env *env)
 {
-        struct osc_thread_info *info;
+       struct osc_thread_info *info;
 
-        info = lu_context_key_get(&env->le_ctx, &osc_key);
-        LASSERT(info != NULL);
-        return info;
+       info = lu_context_key_get(&env->le_ctx, &osc_key);
+       LASSERT(info != NULL);
+       return info;
 }
 
 static inline struct osc_session *osc_env_session(const struct lu_env *env)
 {
-        struct osc_session *ses;
+       struct osc_session *ses;
 
-        ses = lu_context_key_get(env->le_ses, &osc_session_key);
-        LASSERT(ses != NULL);
-        return ses;
+       ses = lu_context_key_get(env->le_ses, &osc_session_key);
+       LASSERT(ses != NULL);
+       return ses;
 }
 
 static inline struct osc_io *osc_env_io(const struct lu_env *env)
 {
-        return &osc_env_session(env)->os_io;
-}
-
-static inline int osc_is_object(const struct lu_object *obj)
-{
-        return obj->lo_dev->ld_type == &osc_device_type;
+       return &osc_env_session(env)->os_io;
 }
 
 static inline struct osc_device *lu2osc_dev(const struct lu_device *d)
 {
-        LINVRNT(d->ld_type == &osc_device_type);
-        return container_of0(d, struct osc_device, od_cl.cd_lu_dev);
+       return container_of0(d, struct osc_device, od_cl.cd_lu_dev);
 }
 
 static inline struct obd_export *osc_export(const struct osc_object *obj)
 {
-        return lu2osc_dev(obj->oo_cl.co_lu.lo_dev)->od_exp;
+       return lu2osc_dev(obj->oo_cl.co_lu.lo_dev)->od_exp;
 }
 
 static inline struct client_obd *osc_cli(const struct osc_object *obj)
@@ -478,8 +534,7 @@ static inline struct client_obd *osc_cli(const struct osc_object *obj)
 
 static inline struct osc_object *cl2osc(const struct cl_object *obj)
 {
-        LINVRNT(osc_is_object(&obj->co_lu));
-        return container_of0(obj, struct osc_object, oo_cl);
+       return container_of0(obj, struct osc_object, oo_cl);
 }
 
 static inline struct cl_object *osc2cl(const struct osc_object *obj)
@@ -487,6 +542,36 @@ static inline struct cl_object *osc2cl(const struct osc_object *obj)
        return (struct cl_object *)&obj->oo_cl;
 }
 
+static inline struct osc_device *obd2osc_dev(const struct obd_device *d)
+{
+       return container_of0(d->obd_lu_dev, struct osc_device,
+                            od_cl.cd_lu_dev);
+}
+
+static inline struct lu_device *osc2lu_dev(struct osc_device *osc)
+{
+       return &osc->od_cl.cd_lu_dev;
+}
+
+static inline struct lu_object *osc2lu(struct osc_object *osc)
+{
+       return &osc->oo_cl.co_lu;
+}
+
+static inline struct osc_object *lu2osc(const struct lu_object *obj)
+{
+       return container_of0(obj, struct osc_object, oo_cl.co_lu);
+}
+
+static inline struct osc_io *cl2osc_io(const struct lu_env *env,
+                                      const struct cl_io_slice *slice)
+{
+       struct osc_io *oio = container_of0(slice, struct osc_io, oi_cl);
+
+       LINVRNT(oio == osc_env_io(env));
+       return oio;
+}
+
 static inline enum ldlm_mode osc_cl_lock2ldlm(enum cl_lock_mode mode)
 {
        LASSERT(mode == CLM_READ || mode == CLM_WRITE || mode == CLM_GROUP);
@@ -509,8 +594,7 @@ static inline enum cl_lock_mode osc_ldlm2cl_lock(enum ldlm_mode mode)
 
 static inline struct osc_page *cl2osc_page(const struct cl_page_slice *slice)
 {
-        LINVRNT(osc_is_object(&slice->cpl_obj->co_lu));
-        return container_of0(slice, struct osc_page, ops_cl);
+       return container_of0(slice, struct osc_page, ops_cl);
 }
 
 static inline struct osc_page *oap2osc(struct osc_async_page *oap)
@@ -545,18 +629,12 @@ osc_cl_page_osc(struct cl_page *page, struct osc_object *osc)
 
 static inline struct osc_lock *cl2osc_lock(const struct cl_lock_slice *slice)
 {
-        LINVRNT(osc_is_object(&slice->cls_obj->co_lu));
-        return container_of0(slice, struct osc_lock, ols_cl);
-}
-
-static inline struct osc_lock *osc_lock_at(const struct cl_lock *lock)
-{
-        return cl2osc_lock(cl_lock_at(lock, &osc_device_type));
+       return container_of0(slice, struct osc_lock, ols_cl);
 }
 
 static inline int osc_io_srvlock(struct osc_io *oio)
 {
-        return (oio->oi_lockless && !oio->oi_cl.cis_io->ci_no_srvlock);
+       return (oio->oi_lockless && !oio->oi_cl.cis_io->ci_no_srvlock);
 }
 
 enum osc_extent_state {
@@ -672,4 +750,4 @@ int osc_page_gang_lookup(const struct lu_env *env, struct cl_io *io,
                         osc_page_gang_cbt cb, void *cbdata);
 /** @} osc */
 
-#endif /* OSC_CL_INTERNAL_H */
+#endif /* LUSTRE_OSC_H */
index b1128bc..5f967e5 100644 (file)
@@ -1,6 +1,6 @@
 MODULES := osc
 osc-objs := osc_request.o lproc_osc.o osc_dev.o osc_object.o osc_page.o osc_lock.o osc_io.o osc_quota.o osc_cache.o
 
-EXTRA_DIST = $(osc-objs:%.o=%.c) osc_internal.h osc_cl_internal.h
+EXTRA_DIST = $(osc-objs:%.o=%.c) osc_internal.h
 
 @INCLUDE_RULES@
index c7c3f0c..3d90088 100644 (file)
@@ -37,6 +37,8 @@
 #include <obd_class.h>
 #include <lprocfs_status.h>
 #include <linux/seq_file.h>
+#include <lustre_osc.h>
+
 #include "osc_internal.h"
 
 #ifdef CONFIG_PROC_FS
index 43c4b6f..fad98b4 100644 (file)
@@ -37,7 +37,8 @@
 
 #define DEBUG_SUBSYSTEM S_OSC
 
-#include "osc_cl_internal.h"
+#include <lustre_osc.h>
+
 #include "osc_internal.h"
 
 static int extent_debug; /* set it to be true for more debug */
index c06a5de..b95bdac 100644 (file)
 
 /* class_name2obd() */
 #include <obd_class.h>
+#include <lustre_osc.h>
 
-#include "osc_cl_internal.h"
+#include "osc_internal.h"
 
-/** \addtogroup osc 
- * @{ 
+/** \addtogroup osc
+ * @{
  */
 
 struct kmem_cache *osc_lock_kmem;
@@ -90,17 +91,6 @@ struct lu_kmem_descr osc_caches[] = {
 
 /*****************************************************************************
  *
- * Type conversions.
- *
- */
-
-static struct lu_device *osc2lu_dev(struct osc_device *osc)
-{
-        return &osc->od_cl.cd_lu_dev;
-}
-
-/*****************************************************************************
- *
  * Osc device and device type functions.
  *
  */
index 2476626..60965c7 100644 (file)
 
 #define OAP_MAGIC 8675309
 
+#include <lustre_osc.h>
+
 extern atomic_t osc_pool_req_count;
 extern unsigned int osc_reqpool_maxreqcount;
 extern struct ptlrpc_request_pool *osc_rq_pool;
 
-struct lu_env;
-
-enum async_flags {
-        ASYNC_READY = 0x1, /* ap_make_ready will not be called before this
-                              page is added to an rpc */
-        ASYNC_URGENT = 0x2, /* page must be put into an RPC before return */
-        ASYNC_COUNT_STABLE = 0x4, /* ap_refresh_count will not be called
-                                     to give the caller a chance to update
-                                     or cancel the size of the io */
-        ASYNC_HP = 0x10,
-};
-
-struct osc_async_page {
-        int                     oap_magic;
-        unsigned short          oap_cmd;
-        unsigned short          oap_interrupted:1;
-
-       struct list_head        oap_pending_item;
-       struct list_head        oap_rpc_item;
-
-       loff_t                  oap_obj_off;
-        unsigned                oap_page_off;
-        enum async_flags        oap_async_flags;
-
-        struct brw_page         oap_brw_page;
-
-        struct ptlrpc_request   *oap_request;
-        struct client_obd       *oap_cli;
-       struct osc_object       *oap_obj;
-
-       spinlock_t               oap_lock;
-};
-
-#define oap_page        oap_brw_page.pg
-#define oap_count       oap_brw_page.count
-#define oap_brw_flags   oap_brw_page.flag
-
-static inline struct osc_async_page *brw_page2oap(struct brw_page *pga)
-{
-       return (struct osc_async_page *)container_of(pga, struct osc_async_page,
-                                                    oap_brw_page);
-}
-
-struct osc_cache_waiter {
-       struct list_head        ocw_entry;
-       wait_queue_head_t       ocw_waitq;
-       struct osc_async_page  *ocw_oap;
-       int                     ocw_grant;
-       int                     ocw_rc;
-};
-
 void osc_wake_cache_waiters(struct client_obd *cli);
 int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes);
 void osc_update_next_shrink(struct client_obd *cli);
 
-/*
- * cl integration.
- */
-#include <cl_object.h>
-
 extern struct ptlrpc_request_set *PTLRPCD_SET;
 
 typedef int (*osc_enqueue_upcall_f)(void *cookie, struct lustre_handle *lockh,
@@ -153,6 +99,24 @@ static inline int lproc_osc_attach_seqstat(struct obd_device *dev) {return 0;}
 
 extern struct lu_device_type osc_device_type;
 
+static inline int osc_is_object(const struct lu_object *obj)
+{
+       return obj->lo_dev->ld_type == &osc_device_type;
+}
+
+static inline struct osc_lock *osc_lock_at(const struct cl_lock *lock)
+{
+       return cl2osc_lock(cl_lock_at(lock, &osc_device_type));
+}
+
+int osc_lock_init(const struct lu_env *env, struct cl_object *obj,
+                 struct cl_lock *lock, const struct cl_io *io);
+int osc_io_init(const struct lu_env *env, struct cl_object *obj,
+               struct cl_io *io);
+struct lu_object *osc_object_alloc(const struct lu_env *env,
+                                  const struct lu_object_header *hdr,
+                                  struct lu_device *dev);
+
 static inline int osc_recoverable_error(int rc)
 {
         return (rc == -EIO || rc == -EROFS || rc == -ENOMEM ||
@@ -174,34 +138,6 @@ static inline char *cli_name(struct client_obd *cli)
         ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
 #endif
 
-struct osc_device {
-        struct cl_device    od_cl;
-        struct obd_export  *od_exp;
-
-        /* Write stats is actually protected by client_obd's lock. */
-        struct osc_stats {
-                uint64_t     os_lockless_writes;          /* by bytes */
-                uint64_t     os_lockless_reads;           /* by bytes */
-                uint64_t     os_lockless_truncates;       /* by times */
-        } od_stats;
-
-        /* configuration item(s) */
-        int                 od_contention_time;
-        int                 od_lockless_truncate;
-};
-
-static inline struct osc_device *obd2osc_dev(const struct obd_device *d)
-{
-        return container_of0(d->obd_lu_dev, struct osc_device, od_cl.cd_lu_dev);
-}
-
-extern struct kmem_cache *osc_quota_kmem;
-struct osc_quota_info {
-       /** linkage for quota hash table */
-       struct hlist_node oqi_hash;
-       u32               oqi_id;
-};
-
 struct osc_async_args {
        struct obd_info *aa_oi;
 };
index 0501ba5..b196fc8 100644 (file)
 #define DEBUG_SUBSYSTEM S_OSC
 
 #include <lustre_obdo.h>
+#include <lustre_osc.h>
 
-#include "osc_cl_internal.h"
+#include "osc_internal.h"
 
-/** \addtogroup osc 
- *  @{ 
+/** \addtogroup osc
+ *  @{
  */
 
 /*****************************************************************************
  *
- * Type conversions.
- *
- */
-
-static struct osc_io *cl2osc_io(const struct lu_env *env,
-                                const struct cl_io_slice *slice)
-{
-        struct osc_io *oio = container_of0(slice, struct osc_io, oi_cl);
-        LINVRNT(oio == osc_env_io(env));
-        return oio;
-}
-
-/*****************************************************************************
- *
  * io operations.
  *
  */
index fda349b..8c65878 100644 (file)
@@ -40,8 +40,9 @@
 #include <libcfs/libcfs.h>
 /* fid_build_reg_res_name() */
 #include <lustre_fid.h>
+#include <lustre_osc.h>
 
-#include "osc_cl_internal.h"
+#include "osc_internal.h"
 
 /** \addtogroup osc
  *  @{
index 7c486dd..7d32893 100644 (file)
@@ -36,8 +36,9 @@
  */
 
 #define DEBUG_SUBSYSTEM S_OSC
+#include <lustre_osc.h>
 
-#include "osc_cl_internal.h"
+#include "osc_internal.h"
 
 /** \addtogroup osc
  *  @{
 
 /*****************************************************************************
  *
- * Type conversions.
- *
- */
-
-static struct lu_object *osc2lu(struct osc_object *osc)
-{
-        return &osc->oo_cl.co_lu;
-}
-
-static struct osc_object *lu2osc(const struct lu_object *obj)
-{
-        LINVRNT(osc_is_object(obj));
-        return container_of0(obj, struct osc_object, oo_cl.co_lu);
-}
-
-/*****************************************************************************
- *
  * Object operations.
  *
  */
index 949d370..c0aa4be 100644 (file)
@@ -36,8 +36,9 @@
  */
 
 #define DEBUG_SUBSYSTEM S_OSC
+#include <lustre_osc.h>
 
-#include "osc_cl_internal.h"
+#include "osc_internal.h"
 
 static void osc_lru_del(struct client_obd *cli, struct osc_page *opg);
 static void osc_lru_use(struct client_obd *cli, struct osc_page *opg);
index 7dcbbd7..1c7748c 100644 (file)
@@ -29,6 +29,8 @@
  */
 
 #include <obd.h>
+#include <lustre_osc.h>
+
 #include "osc_internal.h"
 
 static inline struct osc_quota_info *osc_oqi_alloc(u32 id)
index 6038107..3e03092 100644 (file)
@@ -48,8 +48,8 @@
 #include <obd.h>
 #include <obd_cksum.h>
 #include <obd_class.h>
+#include <lustre_osc.h>
 
-#include "osc_cl_internal.h"
 #include "osc_internal.h"
 
 atomic_t osc_pool_req_count;