Whamcloud - gitweb
LU-1518 mdd: Fixup mdd_{obf,dot_lustre}_obj_ops.
[fs/lustre-release.git] / lustre / mdd / mdd_internal.h
index 72e497c..d2ab7b8 100644 (file)
@@ -1,6 +1,4 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
  * GPL HEADER START
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -29,8 +27,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011 Whamcloud, Inc.
- *
+ * Copyright (c) 2011, 2012, Whamcloud, Inc.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -105,7 +102,7 @@ struct mdd_device {
         struct obd_device               *mdd_obd_dev;
         struct lu_fid                    mdd_root_fid;
         struct dt_device_param           mdd_dt_conf;
-        struct dt_object                *mdd_orphans;
+        struct dt_object                *mdd_orphans; /* PENDING directory */
         struct dt_object                *mdd_capa;
         struct dt_txn_callback           mdd_txn_cb;
         cfs_proc_dir_entry_t            *mdd_proc_entry;
@@ -176,6 +173,7 @@ extern const char orph_index_name[];
 
 extern const struct dt_index_features orph_index_features;
 
+struct lov_mds_md *mdd_max_lmm_buffer(const struct lu_env *env, int size);
 struct lov_mds_md *mdd_max_lmm_get(const struct lu_env *env,
                                    struct mdd_device *mdd);
 
@@ -221,6 +219,10 @@ int mdd_get_md_locked(const struct lu_env *env, struct mdd_object *obj,
 int mdd_data_get(const struct lu_env *env, struct mdd_object *obj, void **data);
 int mdd_la_get(const struct lu_env *env, struct mdd_object *obj,
                struct lu_attr *la, struct lustre_capa *capa);
+int mdd_attr_get(const struct lu_env *env, struct md_object *obj,
+                 struct md_attr *ma);
+int mdd_attr_set(const struct lu_env *env, struct md_object *obj,
+                 const struct md_attr *ma);
 int mdd_attr_set_internal(const struct lu_env *env,
                           struct mdd_object *obj,
                           struct lu_attr *attr,
@@ -319,6 +321,11 @@ int mdd_get_cookie_size(const struct lu_env *env, struct mdd_device *mdd,
 int mdd_lov_setattr_async(const struct lu_env *env, struct mdd_object *obj,
                           struct lov_mds_md *lmm, int lmm_size,
                           struct llog_cookie *logcookies);
+int mdd_lovobj_unlink(const struct lu_env *env, struct mdd_device *mdd,
+                      struct mdd_object *obj, struct lu_attr *la,
+                      struct lov_mds_md *lmm, int lmm_size,
+                      struct llog_cookie *logcookies,
+                      int log_unlink);
 
 struct mdd_thread_info *mdd_env_info(const struct lu_env *env);
 
@@ -613,6 +620,11 @@ static inline void mdd_set_capainfo(const struct lu_env *env, int offset,
         ci->mc_capa[offset] = capa;
 }
 
+static inline const char *mdd_obj_dev_name(const struct mdd_object *obj)
+{
+        return lu_dev_name(obj->mod_obj.mo_lu.lo_dev);
+}
+
 #define MAX_ATIME_DIFF 60
 
 enum {
@@ -667,7 +679,11 @@ static inline int mdo_attr_set(const struct lu_env *env,
                                struct lustre_capa *capa)
 {
         struct dt_object *next = mdd_object_child(obj);
-        LASSERT(mdd_object_exists(obj));
+        if (mdd_object_exists(obj) == 0) {
+                CERROR("%s: object "DFID" not found: rc = -2\n",
+                       mdd_obj_dev_name(obj), PFID(mdd_object_fid(obj)));
+                return -ENOENT;
+        }
         return next->do_ops->do_attr_set(env, next, la, handle, capa);
 }
 
@@ -695,7 +711,11 @@ static inline int mdo_xattr_set(const struct lu_env *env,struct mdd_object *obj,
                                 struct lustre_capa *capa)
 {
         struct dt_object *next = mdd_object_child(obj);
-        LASSERT(mdd_object_exists(obj));
+        if (mdd_object_exists(obj) == 0) {
+                CERROR("%s: object "DFID" not found: rc = -2\n",
+                       mdd_obj_dev_name(obj), PFID(mdd_object_fid(obj)));
+                return -ENOENT;
+        }
         return next->do_ops->do_xattr_set(env, next, buf, name, fl, handle,
                                           capa);
 }
@@ -714,7 +734,11 @@ static inline int mdo_xattr_del(const struct lu_env *env,struct mdd_object *obj,
                                 struct lustre_capa *capa)
 {
         struct dt_object *next = mdd_object_child(obj);
-        LASSERT(mdd_object_exists(obj));
+        if (mdd_object_exists(obj) == 0) {
+                CERROR("%s: object "DFID" not found: rc = -2\n",
+                       mdd_obj_dev_name(obj), PFID(mdd_object_fid(obj)));
+                return -ENOENT;
+        }
         return next->do_ops->do_xattr_del(env, next, name, handle, capa);
 }
 
@@ -723,7 +747,11 @@ int mdo_xattr_list(const struct lu_env *env, struct mdd_object *obj,
                    struct lu_buf *buf, struct lustre_capa *capa)
 {
         struct dt_object *next = mdd_object_child(obj);
-        LASSERT(mdd_object_exists(obj));
+        if (mdd_object_exists(obj) == 0) {
+                CERROR("%s: object "DFID" not found: rc = -2\n",
+                       mdd_obj_dev_name(obj), PFID(mdd_object_fid(obj)));
+                return -ENOENT;
+        }
         return next->do_ops->do_xattr_list(env, next, buf, capa);
 }
 
@@ -784,7 +812,11 @@ static inline int mdo_ref_add(const struct lu_env *env, struct mdd_object *obj,
                               struct thandle *handle)
 {
         struct dt_object *next = mdd_object_child(obj);
-        LASSERT(mdd_object_exists(obj));
+        if (mdd_object_exists(obj) == 0) {
+                CERROR("%s: object "DFID" not found: rc = -2\n",
+                       mdd_obj_dev_name(obj), PFID(mdd_object_fid(obj)));
+                return -ENOENT;
+        }
         return next->do_ops->do_ref_add(env, next, handle);
 }
 
@@ -800,7 +832,11 @@ static inline int mdo_ref_del(const struct lu_env *env, struct mdd_object *obj,
                               struct thandle *handle)
 {
         struct dt_object *next = mdd_object_child(obj);
-        LASSERT(mdd_object_exists(obj));
+        if (mdd_object_exists(obj) == 0) {
+                CERROR("%s: object "DFID" not found: rc = -2\n",
+                       mdd_obj_dev_name(obj), PFID(mdd_object_fid(obj)));
+                return -ENOENT;
+        }
         return next->do_ops->do_ref_del(env, next, handle);
 }
 
@@ -849,7 +885,11 @@ static inline struct obd_capa *mdo_capa_get(const struct lu_env *env,
                                             __u64 opc)
 {
         struct dt_object *next = mdd_object_child(obj);
-        LASSERT(mdd_object_exists(obj));
+        if (mdd_object_exists(obj) == 0) {
+                CERROR("%s: object "DFID" not found: rc = -2\n",
+                       mdd_obj_dev_name(obj), PFID(mdd_object_fid(obj)));
+                return ERR_PTR(-ENOENT);
+        }
         return next->do_ops->do_capa_get(env, next, old, opc);
 }