Whamcloud - gitweb
LU-3285 lfs: add parameter for Data-on-MDT file
[fs/lustre-release.git] / lustre / osc / osc_object.c
index 454311c..77f6b03 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
  */
@@ -40,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.
  *
  */
-
-static int osc_object_init(const struct lu_env *env, struct lu_object *obj,
-                           const struct lu_object_conf *conf)
+int osc_object_init(const struct lu_env *env, struct lu_object *obj,
+                   const struct lu_object_conf *conf)
 {
         struct osc_object           *osc   = lu2osc(obj);
         const struct cl_object_conf *cconf = lu2cl_conf(conf);
 
-        osc->oo_oinfo = cconf->u.coc_oinfo;
+       osc->oo_oinfo = cconf->u.coc_oinfo;
 #ifdef CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK
        mutex_init(&osc->oo_debug_mutex);
 #endif
@@ -88,7 +67,7 @@ static int osc_object_init(const struct lu_env *env, struct lu_object *obj,
        osc->oo_root.rb_node = NULL;
        INIT_LIST_HEAD(&osc->oo_hp_exts);
        INIT_LIST_HEAD(&osc->oo_urgent_exts);
-       INIT_LIST_HEAD(&osc->oo_rpc_exts);
+       INIT_LIST_HEAD(&osc->oo_full_exts);
        INIT_LIST_HEAD(&osc->oo_reading_exts);
        atomic_set(&osc->oo_nr_reads, 0);
        atomic_set(&osc->oo_nr_writes, 0);
@@ -104,8 +83,9 @@ static int osc_object_init(const struct lu_env *env, struct lu_object *obj,
 
        return 0;
 }
+EXPORT_SYMBOL(osc_object_init);
 
-static void osc_object_free(const struct lu_env *env, struct lu_object *obj)
+void osc_object_free(const struct lu_env *env, struct lu_object *obj)
 {
        struct osc_object *osc = lu2osc(obj);
 
@@ -117,7 +97,7 @@ static void osc_object_free(const struct lu_env *env, struct lu_object *obj)
        LASSERT(osc->oo_root.rb_node == NULL);
        LASSERT(list_empty(&osc->oo_hp_exts));
        LASSERT(list_empty(&osc->oo_urgent_exts));
-       LASSERT(list_empty(&osc->oo_rpc_exts));
+       LASSERT(list_empty(&osc->oo_full_exts));
        LASSERT(list_empty(&osc->oo_reading_exts));
        LASSERT(atomic_read(&osc->oo_nr_reads) == 0);
        LASSERT(atomic_read(&osc->oo_nr_writes) == 0);
@@ -127,22 +107,24 @@ static void osc_object_free(const struct lu_env *env, struct lu_object *obj)
        lu_object_fini(obj);
        OBD_SLAB_FREE_PTR(osc, osc_object_kmem);
 }
+EXPORT_SYMBOL(osc_object_free);
 
 int osc_lvb_print(const struct lu_env *env, void *cookie,
-                  lu_printer_t p, const struct ost_lvb *lvb)
+                 lu_printer_t p, const struct ost_lvb *lvb)
 {
        return (*p)(env, cookie, "size: %llu mtime: %llu atime: %llu "
                    "ctime: %llu blocks: %llu",
                     lvb->lvb_size, lvb->lvb_mtime, lvb->lvb_atime,
                     lvb->lvb_ctime, lvb->lvb_blocks);
 }
+EXPORT_SYMBOL(osc_lvb_print);
 
-static int osc_object_print(const struct lu_env *env, void *cookie,
-                            lu_printer_t p, const struct lu_object *obj)
+int osc_object_print(const struct lu_env *env, void *cookie,
+                    lu_printer_t p, const struct lu_object *obj)
 {
-       struct osc_object   *osc   = lu2osc(obj);
-       struct lov_oinfo    *oinfo = osc->oo_oinfo;
-       struct osc_async_rc *ar    = &oinfo->loi_ar;
+       struct osc_object *osc = lu2osc(obj);
+       struct lov_oinfo *oinfo = osc->oo_oinfo;
+       struct osc_async_rc *ar = &oinfo->loi_ar;
 
        (*p)(env, cookie, "id: "DOSTID" "
             "idx: %d gen: %d kms_valid: %u kms %llu "
@@ -153,20 +135,22 @@ static int osc_object_print(const struct lu_env *env, void *cookie,
        osc_lvb_print(env, cookie, p, &oinfo->loi_lvb);
        return 0;
 }
+EXPORT_SYMBOL(osc_object_print);
 
 
-static int osc_attr_get(const struct lu_env *env, struct cl_object *obj,
-                        struct cl_attr *attr)
+int osc_attr_get(const struct lu_env *env, struct cl_object *obj,
+                struct cl_attr *attr)
 {
-        struct lov_oinfo *oinfo = cl2osc(obj)->oo_oinfo;
+       struct lov_oinfo *oinfo = cl2osc(obj)->oo_oinfo;
 
-        cl_lvb2attr(attr, &oinfo->loi_lvb);
-        attr->cat_kms = oinfo->loi_kms_valid ? oinfo->loi_kms : 0;
-        return 0;
+       cl_lvb2attr(attr, &oinfo->loi_lvb);
+       attr->cat_kms = oinfo->loi_kms_valid ? oinfo->loi_kms : 0;
+       return 0;
 }
+EXPORT_SYMBOL(osc_attr_get);
 
-static int osc_attr_update(const struct lu_env *env, struct cl_object *obj,
-                          const struct cl_attr *attr, unsigned valid)
+int osc_attr_update(const struct lu_env *env, struct cl_object *obj,
+                   const struct cl_attr *attr, unsigned valid)
 {
        struct lov_oinfo *oinfo = cl2osc(obj)->oo_oinfo;
        struct ost_lvb   *lvb   = &oinfo->loi_lvb;
@@ -188,17 +172,18 @@ static int osc_attr_update(const struct lu_env *env, struct cl_object *obj,
        }
        return 0;
 }
+EXPORT_SYMBOL(osc_attr_update);
 
-static int osc_object_glimpse(const struct lu_env *env,
-                              const struct cl_object *obj, struct ost_lvb *lvb)
+int osc_object_glimpse(const struct lu_env *env, const struct cl_object *obj,
+                      struct ost_lvb *lvb)
 {
-        struct lov_oinfo *oinfo = cl2osc(obj)->oo_oinfo;
+       struct lov_oinfo *oinfo = cl2osc(obj)->oo_oinfo;
 
-        ENTRY;
-        lvb->lvb_size   = oinfo->loi_kms;
-        lvb->lvb_blocks = oinfo->loi_lvb.lvb_blocks;
-        RETURN(0);
+       lvb->lvb_size = oinfo->loi_kms;
+       lvb->lvb_blocks = oinfo->loi_lvb.lvb_blocks;
+       return 0;
 }
+EXPORT_SYMBOL(osc_object_glimpse);
 
 static int osc_object_ast_clear(struct ldlm_lock *lock, void *data)
 {
@@ -241,15 +226,15 @@ static int osc_object_fiemap(const struct lu_env *env, struct cl_object *obj,
        if (!(fmkey->lfik_fiemap.fm_flags & FIEMAP_FLAG_SYNC))
                goto skip_locking;
 
-       policy.l_extent.start = fmkey->lfik_fiemap.fm_start & PAGE_CACHE_MASK;
+       policy.l_extent.start = fmkey->lfik_fiemap.fm_start & PAGE_MASK;
 
        if (OBD_OBJECT_EOF - fmkey->lfik_fiemap.fm_length <=
-           fmkey->lfik_fiemap.fm_start + PAGE_CACHE_SIZE - 1)
+           fmkey->lfik_fiemap.fm_start + PAGE_SIZE - 1)
                policy.l_extent.end = OBD_OBJECT_EOF;
        else
                policy.l_extent.end = (fmkey->lfik_fiemap.fm_start +
                                       fmkey->lfik_fiemap.fm_length +
-                                      PAGE_CACHE_SIZE - 1) & PAGE_CACHE_MASK;
+                                      PAGE_SIZE - 1) & PAGE_MASK;
 
        ostid_build_res_name(&fmkey->lfik_oa.o_oi, &resid);
        mode = ldlm_lock_match(exp->exp_obd->obd_namespace,
@@ -379,7 +364,14 @@ static void osc_req_attr_set(const struct lu_env *env, struct cl_object *obj,
                oa->o_valid |= OBD_MD_FLGROUP;
        }
        if (flags & OBD_MD_FLID) {
-               ostid_set_id(&oa->o_oi, ostid_id(&oinfo->loi_oi));
+               int rc;
+
+               rc = ostid_set_id(&oa->o_oi, ostid_id(&oinfo->loi_oi));
+               if (rc) {
+                       CERROR("Bad %llu to set " DOSTID " : rc %d\n",
+                              (unsigned long long)ostid_id(&oinfo->loi_oi),
+                              POSTID(&oa->o_oi), rc);
+               }
                oa->o_valid |= OBD_MD_FLID;
        }
        if (flags & OBD_MD_FLHANDLE) {
@@ -468,7 +460,7 @@ int osc_object_invalidate(const struct lu_env *env, struct osc_object *osc)
        osc_cache_truncate_start(env, osc, 0, NULL);
 
        /* Discard all caching pages */
-       osc_lock_discard_pages(env, osc, 0, CL_PAGE_EOF, CLM_WRITE);
+       osc_lock_discard_pages(env, osc, 0, CL_PAGE_EOF, true);
 
        /* Clear ast data of dlm lock. Do this after discarding all pages */
        osc_object_prune(env, osc2cl(osc));