Whamcloud - gitweb
LU-3963 obdclass: convert to linux list api
[fs/lustre-release.git] / lustre / obdclass / idmap.c
index 146b40e..df6c57b 100644 (file)
@@ -168,10 +168,10 @@ int lustre_in_group_p(struct lu_ucred *mu, gid_t grp)
 EXPORT_SYMBOL(lustre_in_group_p);
 
 struct lustre_idmap_entry {
 EXPORT_SYMBOL(lustre_in_group_p);
 
 struct lustre_idmap_entry {
-        cfs_list_t       lie_rmt_uid_hash; /* hashed as lie_rmt_uid; */
-        cfs_list_t       lie_lcl_uid_hash; /* hashed as lie_lcl_uid; */
-        cfs_list_t       lie_rmt_gid_hash; /* hashed as lie_rmt_gid; */
-        cfs_list_t       lie_lcl_gid_hash; /* hashed as lie_lcl_gid; */
+       struct list_head       lie_rmt_uid_hash; /* hashed as lie_rmt_uid; */
+       struct list_head       lie_lcl_uid_hash; /* hashed as lie_lcl_uid; */
+       struct list_head       lie_rmt_gid_hash; /* hashed as lie_rmt_gid; */
+       struct list_head       lie_lcl_gid_hash; /* hashed as lie_lcl_gid; */
         uid_t            lie_rmt_uid;      /* remote uid */
         uid_t            lie_lcl_uid;      /* local uid */
         gid_t            lie_rmt_gid;      /* remote gid */
         uid_t            lie_rmt_uid;      /* remote uid */
         uid_t            lie_lcl_uid;      /* local uid */
         gid_t            lie_rmt_gid;      /* remote gid */
@@ -193,10 +193,10 @@ struct lustre_idmap_entry *idmap_entry_alloc(uid_t rmt_uid, uid_t lcl_uid,
         if (e == NULL)
                 return NULL;
 
         if (e == NULL)
                 return NULL;
 
-        CFS_INIT_LIST_HEAD(&e->lie_rmt_uid_hash);
-        CFS_INIT_LIST_HEAD(&e->lie_lcl_uid_hash);
-        CFS_INIT_LIST_HEAD(&e->lie_rmt_gid_hash);
-        CFS_INIT_LIST_HEAD(&e->lie_lcl_gid_hash);
+       INIT_LIST_HEAD(&e->lie_rmt_uid_hash);
+       INIT_LIST_HEAD(&e->lie_lcl_uid_hash);
+       INIT_LIST_HEAD(&e->lie_rmt_gid_hash);
+       INIT_LIST_HEAD(&e->lie_lcl_gid_hash);
         e->lie_rmt_uid = rmt_uid;
         e->lie_lcl_uid = lcl_uid;
         e->lie_rmt_gid = rmt_gid;
         e->lie_rmt_uid = rmt_uid;
         e->lie_lcl_uid = lcl_uid;
         e->lie_rmt_gid = rmt_gid;
@@ -207,15 +207,11 @@ struct lustre_idmap_entry *idmap_entry_alloc(uid_t rmt_uid, uid_t lcl_uid,
 
 static void idmap_entry_free(struct lustre_idmap_entry *e)
 {
 
 static void idmap_entry_free(struct lustre_idmap_entry *e)
 {
-        if (!cfs_list_empty(&e->lie_rmt_uid_hash))
-                cfs_list_del(&e->lie_rmt_uid_hash);
-        if (!cfs_list_empty(&e->lie_lcl_uid_hash))
-                cfs_list_del(&e->lie_lcl_uid_hash);
-        if (!cfs_list_empty(&e->lie_rmt_gid_hash))
-                cfs_list_del(&e->lie_rmt_gid_hash);
-        if (!cfs_list_empty(&e->lie_lcl_gid_hash))
-                cfs_list_del(&e->lie_lcl_gid_hash);
-        OBD_FREE_PTR(e);
+       list_del(&e->lie_rmt_uid_hash);
+       list_del(&e->lie_lcl_uid_hash);
+       list_del(&e->lie_rmt_gid_hash);
+       list_del(&e->lie_lcl_gid_hash);
+       OBD_FREE_PTR(e);
 }
 
 /*
 }
 
 /*
@@ -229,11 +225,11 @@ struct lustre_idmap_entry *idmap_search_entry(struct lustre_idmap_table *t,
                                               uid_t rmt_uid, uid_t lcl_uid,
                                               gid_t rmt_gid, gid_t lcl_gid)
 {
                                               uid_t rmt_uid, uid_t lcl_uid,
                                               gid_t rmt_gid, gid_t lcl_gid)
 {
-        cfs_list_t *head;
+       struct list_head *head;
         struct lustre_idmap_entry *e;
 
         head = &t->lit_idmaps[RMT_UIDMAP_IDX][lustre_idmap_hashfunc(rmt_uid)];
         struct lustre_idmap_entry *e;
 
         head = &t->lit_idmaps[RMT_UIDMAP_IDX][lustre_idmap_hashfunc(rmt_uid)];
-        cfs_list_for_each_entry(e, head, lie_rmt_uid_hash)
+       list_for_each_entry(e, head, lie_rmt_uid_hash)
                 if (e->lie_rmt_uid == rmt_uid) {
                         if (e->lie_lcl_uid == lcl_uid) {
                                 if (e->lie_rmt_gid == rmt_gid &&
                 if (e->lie_rmt_uid == rmt_uid) {
                         if (e->lie_lcl_uid == lcl_uid) {
                                 if (e->lie_rmt_gid == rmt_gid &&
@@ -250,7 +246,7 @@ struct lustre_idmap_entry *idmap_search_entry(struct lustre_idmap_table *t,
                 }
 
         head = &t->lit_idmaps[RMT_GIDMAP_IDX][lustre_idmap_hashfunc(rmt_gid)];
                 }
 
         head = &t->lit_idmaps[RMT_GIDMAP_IDX][lustre_idmap_hashfunc(rmt_gid)];
-        cfs_list_for_each_entry(e, head, lie_rmt_gid_hash)
+       list_for_each_entry(e, head, lie_rmt_gid_hash)
                 if (e->lie_rmt_gid == rmt_gid) {
                         if (e->lie_lcl_gid == lcl_gid) {
                                 if (unlikely(e->lie_rmt_uid == rmt_uid &&
                 if (e->lie_rmt_gid == rmt_gid) {
                         if (e->lie_lcl_gid == lcl_gid) {
                                 if (unlikely(e->lie_rmt_uid == rmt_uid &&
@@ -270,36 +266,36 @@ struct lustre_idmap_entry *idmap_search_entry(struct lustre_idmap_table *t,
         return NULL;
 }
 
         return NULL;
 }
 
-static __u32 idmap_lookup_uid(cfs_list_t *hash, int reverse,
+static __u32 idmap_lookup_uid(struct list_head *hash, int reverse,
                               __u32 uid)
 {
                               __u32 uid)
 {
-        cfs_list_t *head = &hash[lustre_idmap_hashfunc(uid)];
-        struct lustre_idmap_entry *e;
+       struct list_head *head = &hash[lustre_idmap_hashfunc(uid)];
+       struct lustre_idmap_entry *e;
 
 
-        if (!reverse) {
-                cfs_list_for_each_entry(e, head, lie_rmt_uid_hash)
-                        if (e->lie_rmt_uid == uid)
-                                return e->lie_lcl_uid;
-        } else {
-                cfs_list_for_each_entry(e, head, lie_lcl_uid_hash)
-                        if (e->lie_lcl_uid == uid)
-                                return e->lie_rmt_uid;
-        }
+       if (!reverse) {
+               list_for_each_entry(e, head, lie_rmt_uid_hash)
+                       if (e->lie_rmt_uid == uid)
+                               return e->lie_lcl_uid;
+       } else {
+               list_for_each_entry(e, head, lie_lcl_uid_hash)
+                       if (e->lie_lcl_uid == uid)
+                               return e->lie_rmt_uid;
+       }
 
 
-        return CFS_IDMAP_NOTFOUND;
+       return CFS_IDMAP_NOTFOUND;
 }
 
 }
 
-static __u32 idmap_lookup_gid(cfs_list_t *hash, int reverse, __u32 gid)
+static __u32 idmap_lookup_gid(struct list_head *hash, int reverse, __u32 gid)
 {
 {
-        cfs_list_t *head = &hash[lustre_idmap_hashfunc(gid)];
+       struct list_head *head = &hash[lustre_idmap_hashfunc(gid)];
         struct lustre_idmap_entry *e;
 
         if (!reverse) {
         struct lustre_idmap_entry *e;
 
         if (!reverse) {
-                cfs_list_for_each_entry(e, head, lie_rmt_gid_hash)
+               list_for_each_entry(e, head, lie_rmt_gid_hash)
                         if (e->lie_rmt_gid == gid)
                                 return e->lie_lcl_gid;
         } else {
                         if (e->lie_rmt_gid == gid)
                                 return e->lie_lcl_gid;
         } else {
-                cfs_list_for_each_entry(e, head, lie_lcl_gid_hash)
+               list_for_each_entry(e, head, lie_lcl_gid_hash)
                         if (e->lie_lcl_gid == gid)
                                 return e->lie_rmt_gid;
         }
                         if (e->lie_lcl_gid == gid)
                                 return e->lie_rmt_gid;
         }
@@ -324,32 +320,32 @@ int lustre_idmap_add(struct lustre_idmap_table *t,
                        return -ENOMEM;
 
                spin_lock(&t->lit_lock);
                        return -ENOMEM;
 
                spin_lock(&t->lit_lock);
-                e1 = idmap_search_entry(t, ruid, luid, rgid, lgid);
-                if (e1 == NULL) {
-                        cfs_list_add_tail(&e0->lie_rmt_uid_hash,
-                                          &t->lit_idmaps[RMT_UIDMAP_IDX]
-                                          [lustre_idmap_hashfunc(ruid)]);
-                        cfs_list_add_tail(&e0->lie_lcl_uid_hash,
-                                          &t->lit_idmaps[LCL_UIDMAP_IDX]
-                                          [lustre_idmap_hashfunc(luid)]);
-                        cfs_list_add_tail(&e0->lie_rmt_gid_hash,
-                                          &t->lit_idmaps[RMT_GIDMAP_IDX]
-                                          [lustre_idmap_hashfunc(rgid)]);
-                        cfs_list_add_tail(&e0->lie_lcl_gid_hash,
-                                          &t->lit_idmaps[LCL_GIDMAP_IDX]
-                                          [lustre_idmap_hashfunc(lgid)]);
-                }
+               e1 = idmap_search_entry(t, ruid, luid, rgid, lgid);
+               if (e1 == NULL) {
+                       list_add_tail(&e0->lie_rmt_uid_hash,
+                                     &t->lit_idmaps[RMT_UIDMAP_IDX]
+                                     [lustre_idmap_hashfunc(ruid)]);
+                       list_add_tail(&e0->lie_lcl_uid_hash,
+                                     &t->lit_idmaps[LCL_UIDMAP_IDX]
+                                     [lustre_idmap_hashfunc(luid)]);
+                       list_add_tail(&e0->lie_rmt_gid_hash,
+                                     &t->lit_idmaps[RMT_GIDMAP_IDX]
+                                     [lustre_idmap_hashfunc(rgid)]);
+                       list_add_tail(&e0->lie_lcl_gid_hash,
+                                     &t->lit_idmaps[LCL_GIDMAP_IDX]
+                                     [lustre_idmap_hashfunc(lgid)]);
+               }
                spin_unlock(&t->lit_lock);
                spin_unlock(&t->lit_lock);
-                if (e1 != NULL) {
-                        idmap_entry_free(e0);
-                        if (IS_ERR(e1))
-                                return PTR_ERR(e1);
-                }
-        } else if (IS_ERR(e0)) {
-                return PTR_ERR(e0);
-        }
+               if (e1 != NULL) {
+                       idmap_entry_free(e0);
+                       if (IS_ERR(e1))
+                               return PTR_ERR(e1);
+               }
+       } else if (IS_ERR(e0)) {
+               return PTR_ERR(e0);
+       }
 
 
-        return 0;
+       return 0;
 }
 EXPORT_SYMBOL(lustre_idmap_add);
 
 }
 EXPORT_SYMBOL(lustre_idmap_add);
 
@@ -378,7 +374,7 @@ int lustre_idmap_lookup_uid(struct lu_ucred *mu,
                            struct lustre_idmap_table *t,
                            int reverse, uid_t uid)
 {
                            struct lustre_idmap_table *t,
                            int reverse, uid_t uid)
 {
-       cfs_list_t *hash;
+       struct list_head *hash;
 
        if (mu && (mu->uc_valid == UCRED_OLD || mu->uc_valid == UCRED_NEW)) {
                if (!reverse) {
 
        if (mu && (mu->uc_valid == UCRED_OLD || mu->uc_valid == UCRED_NEW)) {
                if (!reverse) {
@@ -410,7 +406,7 @@ EXPORT_SYMBOL(lustre_idmap_lookup_uid);
 int lustre_idmap_lookup_gid(struct lu_ucred *mu, struct lustre_idmap_table *t,
                            int reverse, gid_t gid)
 {
 int lustre_idmap_lookup_gid(struct lu_ucred *mu, struct lustre_idmap_table *t,
                            int reverse, gid_t gid)
 {
-       cfs_list_t *hash;
+       struct list_head *hash;
 
        if (mu && (mu->uc_valid == UCRED_OLD || mu->uc_valid == UCRED_NEW)) {
                if (!reverse) {
 
        if (mu && (mu->uc_valid == UCRED_OLD || mu->uc_valid == UCRED_NEW)) {
                if (!reverse) {
@@ -451,7 +447,7 @@ struct lustre_idmap_table *lustre_idmap_init(void)
        spin_lock_init(&t->lit_lock);
        for (i = 0; i < ARRAY_SIZE(t->lit_idmaps); i++)
                for (j = 0; j < ARRAY_SIZE(t->lit_idmaps[i]); j++)
        spin_lock_init(&t->lit_lock);
        for (i = 0; i < ARRAY_SIZE(t->lit_idmaps); i++)
                for (j = 0; j < ARRAY_SIZE(t->lit_idmaps[i]); j++)
-                       CFS_INIT_LIST_HEAD(&t->lit_idmaps[i][j]);
+                       INIT_LIST_HEAD(&t->lit_idmaps[i][j]);
 
        return t;
 }
 
        return t;
 }
@@ -459,7 +455,7 @@ EXPORT_SYMBOL(lustre_idmap_init);
 
 void lustre_idmap_fini(struct lustre_idmap_table *t)
 {
 
 void lustre_idmap_fini(struct lustre_idmap_table *t)
 {
-        cfs_list_t *list;
+       struct list_head *list;
         struct lustre_idmap_entry *e;
         int i;
         LASSERT(t);
         struct lustre_idmap_entry *e;
         int i;
         LASSERT(t);
@@ -467,10 +463,10 @@ void lustre_idmap_fini(struct lustre_idmap_table *t)
         list = t->lit_idmaps[RMT_UIDMAP_IDX];
        spin_lock(&t->lit_lock);
        for (i = 0; i < CFS_IDMAP_HASHSIZE; i++)
         list = t->lit_idmaps[RMT_UIDMAP_IDX];
        spin_lock(&t->lit_lock);
        for (i = 0; i < CFS_IDMAP_HASHSIZE; i++)
-               while (!cfs_list_empty(&list[i])) {
-                       e = cfs_list_entry(list[i].next,
-                                          struct lustre_idmap_entry,
-                                          lie_rmt_uid_hash);
+               while (!list_empty(&list[i])) {
+                       e = list_entry(list[i].next,
+                                      struct lustre_idmap_entry,
+                                      lie_rmt_uid_hash);
                        idmap_entry_free(e);
                }
        spin_unlock(&t->lit_lock);
                        idmap_entry_free(e);
                }
        spin_unlock(&t->lit_lock);