Whamcloud - gitweb
LU-1187 mdt: unlink remote directory
[fs/lustre-release.git] / lustre / include / md_object.h
index 2048cc6..d1554ea 100644 (file)
@@ -200,12 +200,12 @@ struct md_op_spec {
         /** Create flag from client: such as MDS_OPEN_CREAT, and others. */
         __u64      sp_cr_flags;
 
-                    /** don't create lov objects or llog cookie - this replay */
+       /** don't create lov objects or llog cookie - this replay */
        unsigned int no_create:1,
-                    /** Should mdd do lookup sanity check or not. */
-                    sp_cr_lookup:1;
+                    sp_cr_lookup:1, /* do lookup sanity check or not. */
+                    sp_rm_entry:1;  /* only remove name entry */
 
-        /** Current lock mode for parent dir where create is performing. */
+       /** Current lock mode for parent dir where create is performing. */
         mdl_mode_t sp_cr_mode;
 
         /** to create directory */
@@ -285,6 +285,10 @@ struct md_object_operations {
         int (*moo_file_unlock)(const struct lu_env *env, struct md_object *obj,
                                struct lov_mds_md *lmm,
                                struct lustre_handle *lockh);
+       int (*moo_object_lock)(const struct lu_env *env, struct md_object *obj,
+                              struct lustre_handle *lh,
+                              struct ldlm_enqueue_info *einfo,
+                              void *policy);
 };
 
 /**
@@ -713,6 +717,16 @@ static inline int mo_file_unlock(const struct lu_env *env, struct md_object *m,
         return m->mo_ops->moo_file_unlock(env, m, lmm, lockh);
 }
 
+static inline int mo_object_lock(const struct lu_env *env,
+                                struct md_object *m,
+                                struct lustre_handle *lh,
+                                struct ldlm_enqueue_info *einfo,
+                                void *policy)
+{
+       LASSERT(m->mo_ops->moo_object_lock);
+       return m->mo_ops->moo_object_lock(env, m, lh, einfo, policy);
+}
+
 static inline int mdo_lookup(const struct lu_env *env,
                              struct md_object *p,
                              const struct lu_name *lname,
@@ -792,8 +806,8 @@ static inline int mdo_unlink(const struct lu_env *env,
                              const struct lu_name *lname,
                              struct md_attr *ma)
 {
-        LASSERT(c->mo_dir_ops->mdo_unlink);
-        return c->mo_dir_ops->mdo_unlink(env, p, c, lname, ma);
+       LASSERT(p->mo_dir_ops->mdo_unlink);
+       return p->mo_dir_ops->mdo_unlink(env, p, c, lname, ma);
 }
 
 static inline int mdo_lum_lmm_cmp(const struct lu_env *env,
@@ -903,5 +917,20 @@ int llo_local_objects_setup(const struct lu_env *env,
 int lustre_buf2som(void *buf, int rc, struct md_som_data *msd);
 int lustre_buf2hsm(void *buf, int rc, struct md_hsm *mh);
 void lustre_hsm2buf(void *buf, struct md_hsm *mh);
+
+#define md_cap_t(x) (x)
+
+#define MD_CAP_TO_MASK(x) (1 << (x))
+
+#define md_cap_raised(c, flag) (md_cap_t(c) & MD_CAP_TO_MASK(flag))
+
+/* capable() is copied from linux kernel! */
+static inline int md_capable(struct lu_ucred *uc, cfs_cap_t cap)
+{
+       if (md_cap_raised(uc->uc_cap, cap))
+               return 1;
+       return 0;
+}
+
 /** @} md */
 #endif /* _LINUX_MD_OBJECT_H */