]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: use list_for_each_entry macro when possible
authorSage Weil <sage@newdream.net>
Tue, 30 Jun 2009 20:26:30 +0000 (13:26 -0700)
committerSage Weil <sage@newdream.net>
Tue, 30 Jun 2009 21:20:45 +0000 (14:20 -0700)
src/kernel/addr.c
src/kernel/caps.c
src/kernel/debugfs.c
src/kernel/mds_client.c
src/kernel/messenger.c
src/kernel/snap.c

index e5842fa6f0935f47cf16a8af8595dbd07bd47cdd..fb066e291eaf346e3f16d7a5a5e59057cefb97fd 100644 (file)
@@ -328,11 +328,9 @@ static struct ceph_snap_context *__get_oldest_context(struct inode *inode,
 {
        struct ceph_inode_info *ci = ceph_inode(inode);
        struct ceph_snap_context *snapc = NULL;
-       struct list_head *p;
        struct ceph_cap_snap *capsnap = NULL;
 
-       list_for_each(p, &ci->i_cap_snaps) {
-               capsnap = list_entry(p, struct ceph_cap_snap, ci_item);
+       list_for_each_entry(capsnap, &ci->i_cap_snaps, ci_item) {
                dout(20, " cap_snap %p snapc %p has %d dirty pages\n", capsnap,
                     capsnap->context, capsnap->dirty_pages);
                if (capsnap->dirty_pages) {
index df69adb214557c14fd0b916d33c36edaa46601c9..6a25cd298c33b6d9092e9ec7f5646908543cfab6 100644 (file)
@@ -1039,7 +1039,6 @@ void __ceph_flush_snaps(struct ceph_inode_info *ci,
 {
        struct inode *inode = &ci->vfs_inode;
        int mds;
-       struct list_head *p;
        struct ceph_cap_snap *capsnap;
        u32 mseq;
        struct ceph_mds_client *mdsc = &ceph_inode_to_client(inode)->mdsc;
@@ -1054,9 +1053,7 @@ void __ceph_flush_snaps(struct ceph_inode_info *ci,
 
        dout(10, "__flush_snaps %p\n", inode);
 retry:
-       list_for_each(p, &ci->i_cap_snaps) {
-               capsnap = list_entry(p, struct ceph_cap_snap, ci_item);
-
+       list_for_each_entry(capsnap, &ci->i_cap_snaps, ci_item) {
                /* avoid an infiniute loop after retry */
                if (capsnap->follows < next_follows)
                        continue;
@@ -1741,7 +1738,6 @@ void ceph_put_wrbuffer_cap_refs(struct ceph_inode_info *ci, int nr,
        int last = 0;
        int last_snap = 0;
        int found = 0;
-       struct list_head *p;
        struct ceph_cap_snap *capsnap = NULL;
 
        spin_lock(&inode->i_lock);
@@ -1760,8 +1756,7 @@ void ceph_put_wrbuffer_cap_refs(struct ceph_inode_info *ci, int nr,
                     ci->i_wrbuffer_ref, ci->i_wrbuffer_ref_head,
                     last ? " LAST" : "");
        } else {
-               list_for_each(p, &ci->i_cap_snaps) {
-                       capsnap = list_entry(p, struct ceph_cap_snap, ci_item);
+               list_for_each_entry(capsnap, &ci->i_cap_snaps, ci_item) {
                        if (capsnap->context == snapc) {
                                found = 1;
                                capsnap->dirty_pages -= nr;
@@ -2064,7 +2059,6 @@ static void handle_cap_flushsnap_ack(struct inode *inode,
 {
        struct ceph_inode_info *ci = ceph_inode(inode);
        u64 follows = le64_to_cpu(m->snap_follows);
-       struct list_head *p;
        struct ceph_cap_snap *capsnap;
        int drop = 0;
 
@@ -2072,8 +2066,7 @@ static void handle_cap_flushsnap_ack(struct inode *inode,
             inode, ci, session->s_mds, follows);
 
        spin_lock(&inode->i_lock);
-       list_for_each(p, &ci->i_cap_snaps) {
-               capsnap = list_entry(p, struct ceph_cap_snap, ci_item);
+       list_for_each_entry(capsnap, &ci->i_cap_snaps, ci_item) {
                if (capsnap->follows == follows) {
                        WARN_ON(capsnap->dirty_pages || capsnap->writing);
                        dout(10, " removing cap_snap %p follows %lld\n",
index 658135ac987c680ff5039c7af0c4a08e3175e150..bf399e78fd3d3eeb265b285a780ec89c2e2c86b9 100644 (file)
@@ -401,16 +401,13 @@ static int dentry_lru_show(struct seq_file *s, void *ptr)
 {
        struct ceph_client *client = s->private;
        struct ceph_mds_client *mdsc = &client->mdsc;
-       struct list_head *p;
        struct ceph_dentry_info *di;
 
        spin_lock(&mdsc->dentry_lru_lock);
-       list_for_each(p, &mdsc->dentry_lru) {
-               struct dentry *dentry;
-               di = list_entry(p, struct ceph_dentry_info, lru);
-               dentry = di->dentry;
+       list_for_each_entry(di, &mdsc->dentry_lru, lru) {
+               struct dentry *dentry = di->dentry;
                seq_printf(s, "%p %p\t%.*s\n",
-                       di, dentry, dentry->d_name.len, dentry->d_name.name);
+                          di, dentry, dentry->d_name.len, dentry->d_name.name);
        }
        spin_unlock(&mdsc->dentry_lru_lock);
 
index 8cb0a3ca37122717408e645111390c038f5096bd..8bbc755b77ba7f9fec191fd38328805fc88237ee 100644 (file)
@@ -630,16 +630,13 @@ static int iterate_session_caps(struct ceph_mds_session *session,
                                 int (*cb)(struct inode *, struct ceph_cap *,
                                            void *), void *arg)
 {
-       struct list_head *p;
-       struct ceph_cap *cap;
+       struct ceph_cap *cap, *ncap;
        struct inode *inode;
-       struct list_head *n;
        int ret;
 
        dout(10, "iterate_session_caps %p mds%d\n", session, session->s_mds);
        spin_lock(&session->s_cap_lock);
-       list_for_each_safe(p, n, &session->s_caps) {
-               cap = list_entry(p, struct ceph_cap, session_caps);
+       list_for_each_entry_safe(cap, ncap, &session->s_caps, session_caps) {
                inode = igrab(&cap->ci->vfs_inode);
                if (!inode)
                        continue;
@@ -1376,11 +1373,9 @@ finish:
 static void __wake_requests(struct ceph_mds_client *mdsc,
                            struct list_head *head)
 {
-       struct list_head *p, *n;
+       struct ceph_mds_request *req, *nreq;
 
-       list_for_each_safe(p, n, head) {
-               struct ceph_mds_request *req =
-                       list_entry(p, struct ceph_mds_request, r_wait);
+       list_for_each_entry_safe(req, nreq, head, r_wait) {
                list_del_init(&req->r_wait);
                __do_request(mdsc, req);
        }
@@ -1816,15 +1811,13 @@ bad:
 static void replay_unsafe_requests(struct ceph_mds_client *mdsc,
                                   struct ceph_mds_session *session)
 {
-       struct list_head *p, *n;
-       struct ceph_mds_request *req;
+       struct ceph_mds_request *req, *nreq;
        int err;
 
        dout(10, "replay_unsafe_requests mds%d\n", session->s_mds);
 
        mutex_lock(&mdsc->mutex);
-       list_for_each_safe(p, n, &session->s_unsafe) {
-               req = list_entry(p, struct ceph_mds_request, r_unsafe_item);
+       list_for_each_entry_safe(req, nreq, &session->s_unsafe, r_unsafe_item) {
                err = __prepare_send_request(mdsc, req, session->s_mds);
                if (!err) {
                        ceph_msg_get(req->r_request);
index 6de1a8abce3eb17186c2bd1a3d48621d76b36c0d..238632aa3fdedd3e87d337935a035f62c5dcfff4 100644 (file)
@@ -384,7 +384,7 @@ static struct ceph_connection *__get_connection(struct ceph_messenger *msgr,
                                                struct ceph_entity_addr *addr)
 {
        struct ceph_connection *con = NULL;
-       struct list_head *head, *p;
+       struct list_head *head;
        unsigned long key = hash_addr(addr);
 
        head = radix_tree_lookup(&msgr->con_tree, key);
@@ -393,11 +393,9 @@ static struct ceph_connection *__get_connection(struct ceph_messenger *msgr,
        con = list_entry(head, struct ceph_connection, list_bucket);
        if (memcmp(&con->peer_addr, addr, sizeof(addr)) == 0)
                goto yes;
-       list_for_each(p, head) {
-               con = list_entry(p, struct ceph_connection, list_bucket);
+       list_for_each_entry(con, head, list_bucket)
                if (memcmp(&con->peer_addr, addr, sizeof(addr)) == 0)
                        goto yes;
-       }
        return NULL;
 
 yes:
index 8944fe5c6a097ae0b56df24577bb1a9e95d0cd74..170edac6dfc3dae5a9b8ed2e8f5f260f796f15ec 100644 (file)
@@ -359,16 +359,13 @@ fail:
  */
 static void rebuild_snap_realms(struct ceph_snap_realm *realm)
 {
-       struct list_head *p;
        struct ceph_snap_realm *child;
 
        dout(10, "rebuild_snap_realms %llx %p\n", realm->ino, realm);
        build_snap_context(realm);
 
-       list_for_each(p, &realm->children) {
-               child = list_entry(p, struct ceph_snap_realm, child_item);
+       list_for_each_entry(child, &realm->children, child_item)
                rebuild_snap_realms(child);
-       }
 }
 
 
@@ -565,14 +562,12 @@ more:
                 * ...unless it's a snap deletion!
                 */
                if (!deletion) {
-                       struct list_head *pi;
-                       struct inode *inode;
+                       struct ceph_inode_info *ci;
+
                        spin_lock(&realm->inodes_with_caps_lock);
-                       list_for_each(pi, &realm->inodes_with_caps) {
-                               struct ceph_inode_info *ci =
-                                       list_entry(pi, struct ceph_inode_info,
-                                                  i_snap_realm_item);
-                               inode = igrab(&ci->vfs_inode);
+                       list_for_each_entry(ci, &realm->inodes_with_caps,
+                                           i_snap_realm_item) {
+                               struct inode *inode = igrab(&ci->vfs_inode);
                                spin_unlock(&realm->inodes_with_caps_lock);
                                if (inode) {
                                        ceph_queue_cap_snap(ci,