Whamcloud - gitweb
b=24037 Changes of 2.6.32 kernel.
[fs/lustre-release.git] / lustre / mdd / mdd_internal.h
index c5a0e64..d436a3e 100644 (file)
@@ -26,7 +26,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  */
 /*
@@ -41,8 +41,6 @@
 #ifndef _MDD_INTERNAL_H
 #define _MDD_INTERNAL_H
 
-#include <asm/semaphore.h>
-
 #include <lustre_acl.h>
 #include <lustre_eacl.h>
 #include <obd.h>
@@ -62,11 +60,15 @@ extern quota_interface_t *mds_quota_interface_ref;
 
 static inline void mdd_quota_wrapper(struct lu_attr *la, unsigned int *qids)
 {
-        qids[0] = la->la_uid;
-        qids[1] = la->la_gid;
+        qids[USRQUOTA] = la->la_uid;
+        qids[GRPQUOTA] = la->la_gid;
 }
 #endif
 
+/* PDO lock is unnecessary for current MDT stack because operations
+ * are already protected by ldlm lock */
+#define MDD_DISABLE_PDO_LOCK    1
+
 enum mdd_txn_op {
         MDD_TXN_OBJECT_DESTROY_OP = 0,
         MDD_TXN_OBJECT_CREATE_OP,
@@ -102,12 +104,18 @@ struct mdd_txn_op_descr {
 #define CLM_PURGE 0x40000
 
 struct mdd_changelog {
-        spinlock_t                       mc_lock;    /* for index */
-        cfs_waitq_t                      mc_waitq;
+        cfs_spinlock_t                   mc_lock;    /* for index */
         int                              mc_flags;
         int                              mc_mask;
         __u64                            mc_index;
         __u64                            mc_starttime;
+        cfs_spinlock_t                   mc_user_lock;
+        int                              mc_lastuser;
+};
+
+/** Objects in .lustre dir */
+struct mdd_dot_lustre_objs {
+        struct mdd_object *mdd_obf;
 };
 
 struct mdd_device {
@@ -123,6 +131,9 @@ struct mdd_device {
         struct mdd_txn_op_descr          mdd_tod[MDD_TXN_LAST_OP];
         struct mdd_changelog             mdd_cl;
         unsigned long                    mdd_atime_diff;
+        struct mdd_object               *mdd_dot_lustre;
+        struct mdd_dot_lustre_objs       mdd_dot_lustre_objs;
+        unsigned int                     mdd_sync_permission;
 };
 
 enum mod_flags {
@@ -175,7 +186,6 @@ struct mdd_thread_info {
         struct lu_name            mti_name;
         struct obdo               mti_oa;
         char                      mti_xattr_buf[LUSTRE_POSIX_ACL_MAX_SIZE];
-        struct lu_fid_pack        mti_pack;
         struct dt_allocation_hint mti_hint;
         struct lov_mds_md        *mti_max_lmm;
         int                       mti_max_lmm_size;
@@ -218,10 +228,16 @@ void mdd_lov_objid_update(struct mdd_device *mdd, struct lov_mds_md *lmm);
 void mdd_lov_create_finish(const struct lu_env *env, struct mdd_device *mdd,
                            struct lov_mds_md *lmm, int lmm_size,
                            const struct md_op_spec *spec);
+int mdd_file_lock(const struct lu_env *env, struct md_object *obj,
+                  struct lov_mds_md *lmm, struct ldlm_extent *extent,
+                  struct lustre_handle *lockh);
+int mdd_file_unlock(const struct lu_env *env, struct md_object *obj,
+                    struct lov_mds_md *lmm, struct lustre_handle *lockh);
 int mdd_get_md(const struct lu_env *env, struct mdd_object *obj,
                void *md, int *md_size, const char *name);
 int mdd_get_md_locked(const struct lu_env *env, struct mdd_object *obj,
                       void *md, int *md_size, const char *name);
+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_set_internal(const struct lu_env *env,
@@ -238,6 +254,8 @@ int mdd_object_kill(const struct lu_env *env, struct mdd_object *obj,
                     struct md_attr *ma);
 int mdd_iattr_get(const struct lu_env *env, struct mdd_object *mdd_obj,
                   struct md_attr *ma);
+int mdd_attr_get_internal(const struct lu_env *env, struct mdd_object *mdd_obj,
+                          struct md_attr *ma);
 int mdd_attr_get_internal_locked(const struct lu_env *env,
                                  struct mdd_object *mdd_obj,
                                  struct md_attr *ma);
@@ -260,6 +278,7 @@ void mdd_read_lock(const struct lu_env *env, struct mdd_object *obj,
                    enum mdd_object_role role);
 void mdd_write_unlock(const struct lu_env *env, struct mdd_object *obj);
 void mdd_read_unlock(const struct lu_env *env, struct mdd_object *obj);
+int mdd_write_locked(const struct lu_env *env, struct mdd_object *obj);
 
 void mdd_pdlock_init(struct mdd_object *obj);
 unsigned long mdd_name2hash(const char *name);
@@ -276,6 +295,8 @@ void mdd_pdo_write_unlock(const struct lu_env *env, struct mdd_object *obj,
 void mdd_pdo_read_unlock(const struct lu_env *env, struct mdd_object *obj,
                          struct dynlock_handle *dlh);
 /* mdd_dir.c */
+int mdd_is_subdir(const struct lu_env *env, struct md_object *mo,
+                  const struct lu_fid *fid, struct lu_fid *sfid);
 void __mdd_ref_add(const struct lu_env *env, struct mdd_object *obj,
                    struct thandle *handle);
 void __mdd_ref_del(const struct lu_env *env, struct mdd_object *obj,
@@ -361,7 +382,11 @@ extern const struct lu_device_operations mdd_lu_ops;
 struct mdd_object *mdd_object_find(const struct lu_env *env,
                                    struct mdd_device *d,
                                    const struct lu_fid *f);
-
+int mdd_get_default_md(struct mdd_object *mdd_obj, struct lov_mds_md *lmm);
+int mdd_readpage(const struct lu_env *env, struct md_object *obj,
+                 const struct lu_rdpg *rdpg);
+int mdd_changelog(const struct lu_env *env, enum changelog_rec_type type,
+                  int flags, struct md_object *obj);
 /* mdd_quota.c*/
 #ifdef HAVE_QUOTA_SUPPORT
 int mdd_quota_notify(const struct lu_env *env, struct md_device *m);
@@ -370,7 +395,7 @@ int mdd_quota_setup(const struct lu_env *env, struct md_device *m,
 int mdd_quota_cleanup(const struct lu_env *env, struct md_device *m);
 int mdd_quota_recovery(const struct lu_env *env, struct md_device *m);
 int mdd_quota_check(const struct lu_env *env, struct md_device *m,
-                    struct obd_export *exp, __u32 type);
+                    __u32 type);
 int mdd_quota_on(const struct lu_env *env, struct md_device *m,
                  __u32 type);
 int mdd_quota_off(const struct lu_env *env, struct md_device *m,
@@ -434,6 +459,7 @@ int mdd_changelog_llog_write(struct mdd_device         *mdd,
                              struct thandle            *handle);
 int mdd_changelog_llog_cancel(struct mdd_device *mdd, long long endrec);
 int mdd_changelog_write_header(struct mdd_device *mdd, int markerflags);
+int mdd_changelog_on(struct mdd_device *mdd, int on);
 
 /* mdd_permission.c */
 #define mdd_cap_t(x) (x)
@@ -528,16 +554,7 @@ static inline const struct lu_fid *mdo2fid(const struct mdd_object *obj)
         return lu_object_fid(&obj->mod_obj.mo_lu);
 }
 
-static inline const struct dt_rec *__mdd_fid_rec(const struct lu_env *env,
-                                                 const struct lu_fid *fid)
-{
-        struct lu_fid_pack *pack = &mdd_env_info(env)->mti_pack;
-
-        fid_pack(pack, fid, &mdd_env_info(env)->mti_fid2);
-        return (const struct dt_rec *)pack;
-}
-
-static inline umode_t mdd_object_type(const struct mdd_object *obj)
+static inline cfs_umode_t mdd_object_type(const struct mdd_object *obj)
 {
         return lu_object_attr(&obj->mod_obj.mo_lu);
 }
@@ -638,6 +655,15 @@ static inline int mdd_permission_internal_locked(const struct lu_env *env,
         return __mdd_permission_internal(env, obj, la, mask, role);
 }
 
+static inline int mdo_data_get(const struct lu_env *env,
+                               struct mdd_object *obj,
+                               void **data)
+{
+        struct dt_object *next = mdd_object_child(obj);
+        next->do_ops->do_data_get(env, next, data);
+        return 0;
+}
+
 /* mdd inline func for calling osd_dt_object ops */
 static inline int mdo_attr_get(const struct lu_env *env, struct mdd_object *obj,
                                struct lu_attr *la, struct lustre_capa *capa)