Whamcloud - gitweb
LU-1267 lfsck: framework (1) for MDT-OST consistency
[fs/lustre-release.git] / lustre / include / lustre_capa.h
index abc1033..b83cd6f 100644 (file)
@@ -80,11 +80,11 @@ struct target_capa {
 };
 
 struct obd_capa {
-        cfs_list_t                c_list;       /* link to capa_list */
+       cfs_list_t              c_list;         /* link to capa_list */
 
-        struct lustre_capa        c_capa;       /* capa */
-        cfs_atomic_t              c_refc;       /* ref count */
-        cfs_time_t                c_expiry;     /* jiffies */
+       struct lustre_capa      c_capa;         /* capa */
+       atomic_t                c_refc;         /* ref count */
+       cfs_time_t              c_expiry;       /* jiffies */
        spinlock_t              c_lock; /* protect capa content */
        int                     c_site;
 
@@ -179,7 +179,7 @@ typedef int (* renew_capa_cb_t)(struct obd_capa *, struct lustre_capa *);
 extern cfs_list_t capa_list[];
 extern spinlock_t capa_lock;
 extern int capa_count[];
-extern cfs_mem_cache_t *capa_cachep;
+extern struct kmem_cache *capa_cachep;
 
 cfs_hlist_head_t *init_capa_hash(void);
 void cleanup_capa_hash(cfs_hlist_head_t *hash);
@@ -205,10 +205,10 @@ static inline struct obd_capa *alloc_capa(int site)
         if (unlikely(!ocapa))
                 return ERR_PTR(-ENOMEM);
 
-        CFS_INIT_LIST_HEAD(&ocapa->c_list);
-        cfs_atomic_set(&ocapa->c_refc, 1);
+       CFS_INIT_LIST_HEAD(&ocapa->c_list);
+       atomic_set(&ocapa->c_refc, 1);
        spin_lock_init(&ocapa->c_lock);
-        ocapa->c_site = site;
+       ocapa->c_site = site;
         if (ocapa->c_site == CAPA_SITE_CLIENT)
                 CFS_INIT_LIST_HEAD(&ocapa->u.cli.lli_list);
         else
@@ -222,29 +222,29 @@ static inline struct obd_capa *alloc_capa(int site)
 
 static inline struct obd_capa *capa_get(struct obd_capa *ocapa)
 {
-        if (!ocapa)
-                return NULL;
+       if (!ocapa)
+               return NULL;
 
-        cfs_atomic_inc(&ocapa->c_refc);
-        return ocapa;
+       atomic_inc(&ocapa->c_refc);
+       return ocapa;
 }
 
 static inline void capa_put(struct obd_capa *ocapa)
 {
-        if (!ocapa)
-                return;
+       if (!ocapa)
+               return;
 
-        if (cfs_atomic_read(&ocapa->c_refc) == 0) {
-                DEBUG_CAPA(D_ERROR, &ocapa->c_capa, "refc is 0 for");
-                LBUG();
-        }
+       if (atomic_read(&ocapa->c_refc) == 0) {
+               DEBUG_CAPA(D_ERROR, &ocapa->c_capa, "refc is 0 for");
+               LBUG();
+       }
 
-        if (cfs_atomic_dec_and_test(&ocapa->c_refc)) {
-                LASSERT(cfs_list_empty(&ocapa->c_list));
-                if (ocapa->c_site == CAPA_SITE_CLIENT) {
-                        LASSERT(cfs_list_empty(&ocapa->u.cli.lli_list));
-                } else {
-                        cfs_hlist_node_t *hnode;
+       if (atomic_dec_and_test(&ocapa->c_refc)) {
+               LASSERT(cfs_list_empty(&ocapa->c_list));
+               if (ocapa->c_site == CAPA_SITE_CLIENT) {
+                       LASSERT(cfs_list_empty(&ocapa->u.cli.lli_list));
+               } else {
+                       cfs_hlist_node_t *hnode;
 
                         hnode = &ocapa->u.tgt.c_hash;
                         LASSERT(!hnode->next && !hnode->pprev);
@@ -298,14 +298,31 @@ struct filter_capa_key {
         struct lustre_capa_key  k_key;
 };
 
-enum {
-        LC_ID_NONE      = 0,
-        LC_ID_PLAIN     = 1,
-        LC_ID_CONVERT   = 2
+enum lc_auth_id {
+       LC_ID_NONE      = 0,
+       LC_ID_PLAIN     = 1,
+       LC_ID_CONVERT   = 2
 };
 
 #define BYPASS_CAPA (struct lustre_capa *)ERR_PTR(-ENOENT)
 
+enum {
+       LU_CAPAINFO_MAX = 5
+};
+
+/** there are at most 5 FIDs in one operation, see rename,
+ *  NOTE the last one is a temporary one used for is_subdir() */
+struct lu_capainfo {
+       enum lc_auth_id          lci_auth;
+       __u32                    lci_padding;
+       struct lu_fid            lci_fid[LU_CAPAINFO_MAX];
+       struct lustre_capa      *lci_capa[LU_CAPAINFO_MAX];
+};
+
+int  lu_capainfo_init(void);
+void lu_capainfo_fini(void);
+struct lu_capainfo *lu_capainfo_get(const struct lu_env *env);
+
 /** @} capa */
 
 #endif /* __LINUX_CAPA_H_ */