Whamcloud - gitweb
b=16098
[fs/lustre-release.git] / lustre / mdd / mdd_internal.h
index 8e2f8d3..88bc287 100644 (file)
@@ -1,27 +1,41 @@
 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
- *  mdd/mdd_internel.c
  *
- *  Copyright (C) 2006 Cluster File Systems, Inc.
- *   Author: Wang Di <wangdi@clusterfs.com>
+ * GPL HEADER START
  *
- *   This file is part of the Lustre file system, http://www.lustre.org
- *   Lustre is a trademark of Cluster File Systems, Inc.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
- *   You may have signed or agreed to another license before downloading
- *   this software.  If so, you are bound by the terms and conditions
- *   of that agreement, and the following does not apply to you.  See the
- *   LICENSE file included with this distribution for more information.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
  *
- *   If you did not agree to a different license, then this copy of Lustre
- *   is open source software; you can redistribute it and/or modify it
- *   under the terms of version 2 of the GNU General Public License as
- *   published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
  *
- *   In either case, Lustre is distributed in the hope that it will be
- *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   license text for more details.
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see [sun.com URL with a
+ * copy of GPLv2].
+ *
+ * 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.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lustre/mdd/mdd_internal.h
+ *
+ * Author: Wang Di <wangdi@clusterfs.com>
  */
 
 #ifndef _MDD_INTERNAL_H
@@ -30,6 +44,7 @@
 #include <asm/semaphore.h>
 
 #include <linux/lustre_acl.h>
+#include <lustre_eacl.h>
 #include <obd.h>
 #include <md_object.h>
 #include <dt_object.h>
@@ -69,6 +84,7 @@ struct mdd_device {
         cfs_proc_dir_entry_t            *mdd_proc_entry;
         struct lprocfs_stats            *mdd_stats;
         struct mdd_txn_op_descr          mdd_tod[MDD_TXN_LAST_OP];
+        unsigned long                    mdd_atime_diff;
 };
 
 enum mod_flags {
@@ -76,7 +92,8 @@ enum mod_flags {
         DEAD_OBJ   = 1 << 0,
         APPEND_OBJ = 1 << 1,
         IMMUTE_OBJ = 1 << 2,
-        ORPHAN_OBJ = 1 << 3
+        ORPHAN_OBJ = 1 << 3,
+        MNLINK_OBJ = 1 << 4
 };
 
 #define LUSTRE_APPEND_FL LDISKFS_APPEND_FL
@@ -141,7 +158,7 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd,
                    struct mdd_object *parent, struct mdd_object *child,
                    struct lov_mds_md **lmm, int *lmm_size,
                    const struct md_op_spec *spec, struct lu_attr *la);
-void mdd_lov_objid_update(const struct lu_env *env, struct mdd_device *mdd);
+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);
@@ -151,9 +168,16 @@ int mdd_get_md_locked(const struct lu_env *env, struct mdd_object *obj,
                       void *md, int *md_size, const char *name);
 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, struct mdd_object *o,
-                          const struct lu_attr *attr, struct thandle *handle,
-                          const int needacl);
+int mdd_attr_set_internal(const struct lu_env *env,
+                          struct mdd_object *obj,
+                          struct lu_attr *attr,
+                          struct thandle *handle,
+                          int needacl);
+int mdd_attr_check_set_internal(const struct lu_env *env,
+                                struct mdd_object *obj,
+                                struct lu_attr *attr,
+                                struct thandle *handle,
+                                int needacl);
 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,
@@ -164,10 +188,11 @@ int mdd_attr_get_internal_locked(const struct lu_env *env,
 int mdd_object_create_internal(const struct lu_env *env, struct mdd_object *p,
                                struct mdd_object *c, struct md_attr *ma,
                                struct thandle *handle);
-int mdd_attr_set_internal_locked(const struct lu_env *env,
-                                 struct mdd_object *o,
-                                 const struct lu_attr *attr,
-                                 struct thandle *handle, const int needacl);
+int mdd_attr_check_set_internal_locked(const struct lu_env *env,
+                                       struct mdd_object *obj,
+                                       struct lu_attr *attr,
+                                       struct thandle *handle,
+                                       int needacl);
 int mdd_lmm_get_locked(const struct lu_env *env, struct mdd_object *mdd_obj,
                        struct md_attr *ma);
 /* mdd_lock.c */
@@ -189,6 +214,10 @@ 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 */
+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,
+                   struct thandle *handle, int is_dot);
 int mdd_may_create(const struct lu_env *env, struct mdd_object *pobj,
                    struct mdd_object *cobj, int check_perm, int check_nlink);
 int mdd_may_unlink(const struct lu_env *env, struct mdd_object *pobj,
@@ -236,6 +265,8 @@ int orph_index_init(const struct lu_env *env, struct mdd_device *mdd);
 void orph_index_fini(const struct lu_env *env, struct mdd_device *mdd);
 int mdd_txn_init_credits(const struct lu_env *env, struct mdd_device *mdd);
 
+/* mdd_lproc.c */
+void lprocfs_mdd_init_vars(struct lprocfs_static_vars *lvars);
 int mdd_procfs_init(struct mdd_device *mdd, const char *name);
 int mdd_procfs_fini(struct mdd_device *mdd);
 void mdd_lprocfs_time_start(const struct lu_env *env);
@@ -286,6 +317,7 @@ extern 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);
+
 /* mdd_permission.c */
 #define mdd_cap_t(x) (x)
 
@@ -301,7 +333,6 @@ static inline int mdd_capable(struct md_ucred *uc, int cap)
         return 0;
 }
 
-int mdd_in_group_p(struct md_ucred *uc, gid_t grp);
 int mdd_acl_def_get(const struct lu_env *env, struct mdd_object *mdd_obj,
                     struct md_attr *ma);
 int mdd_acl_chmod(const struct lu_env *env, struct mdd_object *o, __u32 mode,
@@ -415,6 +446,11 @@ static inline int mdd_is_append(struct mdd_object *obj)
         return obj->mod_flags & APPEND_OBJ;
 }
 
+static inline int mdd_is_mnlink(struct mdd_object *obj)
+{
+        return obj->mod_flags & MNLINK_OBJ;
+}
+
 static inline int mdd_object_exists(struct mdd_object *obj)
 {
         return lu_object_exists(mdd2lu_obj(obj));
@@ -456,6 +492,8 @@ static inline void mdd_set_capainfo(const struct lu_env *env, int offset,
         ci->mc_capa[offset] = capa;
 }
 
+#define MAX_ATIME_DIFF 60
+
 enum {
         LPROC_MDD_NR
 };
@@ -565,11 +603,11 @@ int mdo_create_obj(const struct lu_env *env, struct mdd_object *o,
 static inline struct obd_capa *mdo_capa_get(const struct lu_env *env,
                                             struct mdd_object *obj, 
                                             struct lustre_capa *old,
-                                            __u32 uid, __u64 opc)
+                                            __u64 opc)
 {
         struct dt_object *next = mdd_object_child(obj);
         LASSERT(mdd_object_exists(obj));
-        return next->do_ops->do_capa_get(env, next, old, uid, opc);
+        return next->do_ops->do_capa_get(env, next, old, opc);
 }
 
 #endif