gfs2: Switch to list_{first,last}_entry
authorAndreas Gruenbacher <agruenba@redhat.com>
Mon, 3 Feb 2020 18:22:45 +0000 (19:22 +0100)
committerBob Peterson <rpeterso@redhat.com>
Fri, 27 Mar 2020 19:08:04 +0000 (14:08 -0500)
Replace open-coded versions of list_first_entry and list_last_entry with those
functions.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
fs/gfs2/bmap.c
fs/gfs2/glock.c
fs/gfs2/log.c
fs/gfs2/lops.c
fs/gfs2/quota.c
fs/gfs2/recovery.c
fs/gfs2/super.c

index 08f6fbb3655e2f5e54f02378b0398d2e0701445a..2fe4457e1d01c8f212c68134bf2c0640a5433c1e 100644 (file)
@@ -2223,7 +2223,7 @@ void gfs2_free_journal_extents(struct gfs2_jdesc *jd)
        struct gfs2_journal_extent *jext;
 
        while(!list_empty(&jd->extent_list)) {
-               jext = list_entry(jd->extent_list.next, struct gfs2_journal_extent, list);
+               jext = list_first_entry(&jd->extent_list, struct gfs2_journal_extent, list);
                list_del(&jext->list);
                kfree(jext);
        }
@@ -2244,7 +2244,7 @@ static int gfs2_add_jextent(struct gfs2_jdesc *jd, u64 lblock, u64 dblock, u64 b
        struct gfs2_journal_extent *jext;
 
        if (!list_empty(&jd->extent_list)) {
-               jext = list_entry(jd->extent_list.prev, struct gfs2_journal_extent, list);
+               jext = list_last_entry(&jd->extent_list, struct gfs2_journal_extent, list);
                if ((jext->dblock + jext->blocks) == dblock) {
                        jext->blocks += blocks;
                        return 0;
index 0bfa58e5a64effc1bebbc9dcaefb25d8e928df39..29f9b6684b7480083f0057b9074dc02cb7eb4d7b 100644 (file)
@@ -308,7 +308,7 @@ void gfs2_glock_put(struct gfs2_glock *gl)
 
 static inline int may_grant(const struct gfs2_glock *gl, const struct gfs2_holder *gh)
 {
-       const struct gfs2_holder *gh_head = list_entry(gl->gl_holders.next, const struct gfs2_holder, gh_list);
+       const struct gfs2_holder *gh_head = list_first_entry(&gl->gl_holders, const struct gfs2_holder, gh_list);
        if ((gh->gh_state == LM_ST_EXCLUSIVE ||
             gh_head->gh_state == LM_ST_EXCLUSIVE) && gh != gh_head)
                return 0;
@@ -690,7 +690,7 @@ static inline struct gfs2_holder *find_first_holder(const struct gfs2_glock *gl)
        struct gfs2_holder *gh;
 
        if (!list_empty(&gl->gl_holders)) {
-               gh = list_entry(gl->gl_holders.next, struct gfs2_holder, gh_list);
+               gh = list_first_entry(&gl->gl_holders, struct gfs2_holder, gh_list);
                if (test_bit(HIF_HOLDER, &gh->gh_iflags))
                        return gh;
        }
@@ -1240,7 +1240,7 @@ fail:
        }
        list_add_tail(&gh->gh_list, insert_pt);
 do_cancel:
-       gh = list_entry(gl->gl_holders.next, struct gfs2_holder, gh_list);
+       gh = list_first_entry(&gl->gl_holders, struct gfs2_holder, gh_list);
        if (!(gh->gh_flags & LM_FLAG_PRIORITY)) {
                spin_unlock(&gl->gl_lockref.lock);
                if (sdp->sd_lockstruct.ls_ops->lm_cancel)
@@ -1642,7 +1642,7 @@ __acquires(&lru_lock)
        list_sort(NULL, list, glock_cmp);
 
        while(!list_empty(list)) {
-               gl = list_entry(list->next, struct gfs2_glock, gl_lru);
+               gl = list_first_entry(list, struct gfs2_glock, gl_lru);
                list_del_init(&gl->gl_lru);
                if (!spin_trylock(&gl->gl_lockref.lock)) {
 add_back_to_lru:
@@ -1683,7 +1683,7 @@ static long gfs2_scan_glock_lru(int nr)
 
        spin_lock(&lru_lock);
        while ((nr-- >= 0) && !list_empty(&lru_list)) {
-               gl = list_entry(lru_list.next, struct gfs2_glock, gl_lru);
+               gl = list_first_entry(&lru_list, struct gfs2_glock, gl_lru);
 
                /* Test for being demotable */
                if (!test_bit(GLF_LOCK, &gl->gl_flags)) {
index 87f3e892be3e8fa46d8c0b7f19d3ecc3de37fb9f..8729f5f3a98c50ac2dbe7f262aa977e9b34c237f 100644 (file)
@@ -518,7 +518,7 @@ static unsigned int current_tail(struct gfs2_sbd *sdp)
        if (list_empty(&sdp->sd_ail1_list)) {
                tail = sdp->sd_log_head;
        } else {
-               tr = list_entry(sdp->sd_ail1_list.prev, struct gfs2_trans,
+               tr = list_last_entry(&sdp->sd_ail1_list, struct gfs2_trans,
                                tr_list);
                tail = tr->tr_first;
        }
@@ -580,7 +580,7 @@ static void gfs2_ordered_write(struct gfs2_sbd *sdp)
        spin_lock(&sdp->sd_ordered_lock);
        list_sort(NULL, &sdp->sd_log_ordered, &ip_cmp);
        while (!list_empty(&sdp->sd_log_ordered)) {
-               ip = list_entry(sdp->sd_log_ordered.next, struct gfs2_inode, i_ordered);
+               ip = list_first_entry(&sdp->sd_log_ordered, struct gfs2_inode, i_ordered);
                if (ip->i_inode.i_mapping->nrpages == 0) {
                        test_and_clear_bit(GIF_ORDERED, &ip->i_flags);
                        list_del(&ip->i_ordered);
@@ -601,7 +601,7 @@ static void gfs2_ordered_wait(struct gfs2_sbd *sdp)
 
        spin_lock(&sdp->sd_ordered_lock);
        while (!list_empty(&sdp->sd_log_ordered)) {
-               ip = list_entry(sdp->sd_log_ordered.next, struct gfs2_inode, i_ordered);
+               ip = list_first_entry(&sdp->sd_log_ordered, struct gfs2_inode, i_ordered);
                list_del(&ip->i_ordered);
                WARN_ON(!test_and_clear_bit(GIF_ORDERED, &ip->i_flags));
                if (ip->i_inode.i_mapping->nrpages == 0)
index 7307e5e721d1055828587111cf63b515f7a88b42..5ea96757afc48ee8f65bbcdfbfe4e83ffe7399b2 100644 (file)
@@ -734,7 +734,7 @@ static void buf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
 
        head = &tr->tr_buf;
        while (!list_empty(head)) {
-               bd = list_entry(head->next, struct gfs2_bufdata, bd_list);
+               bd = list_first_entry(head, struct gfs2_bufdata, bd_list);
                list_del_init(&bd->bd_list);
                gfs2_unpin(sdp, bd->bd_bh, tr);
        }
@@ -904,7 +904,7 @@ static void revoke_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
        struct gfs2_glock *gl;
 
        while (!list_empty(head)) {
-               bd = list_entry(head->next, struct gfs2_bufdata, bd_list);
+               bd = list_first_entry(head, struct gfs2_bufdata, bd_list);
                list_del_init(&bd->bd_list);
                gl = bd->bd_gl;
                gfs2_glock_remove_revoke(gl);
@@ -1083,7 +1083,7 @@ static void databuf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
 
        head = &tr->tr_databuf;
        while (!list_empty(head)) {
-               bd = list_entry(head->next, struct gfs2_bufdata, bd_list);
+               bd = list_first_entry(head, struct gfs2_bufdata, bd_list);
                list_del_init(&bd->bd_list);
                gfs2_unpin(sdp, bd->bd_bh, tr);
        }
index 43ffe59970985abe1c28ac1523cf65142115ca32..8290f60f9877e13d819f3bf397c4c9868f205505 100644 (file)
@@ -115,7 +115,7 @@ static void gfs2_qd_dispose(struct list_head *list)
        struct gfs2_sbd *sdp;
 
        while (!list_empty(list)) {
-               qd = list_entry(list->next, struct gfs2_quota_data, qd_lru);
+               qd = list_first_entry(list, struct gfs2_quota_data, qd_lru);
                sdp = qd->qd_gl->gl_name.ln_sbd;
 
                list_del(&qd->qd_lru);
@@ -1441,7 +1441,7 @@ void gfs2_quota_cleanup(struct gfs2_sbd *sdp)
 
        spin_lock(&qd_lock);
        while (!list_empty(head)) {
-               qd = list_entry(head->prev, struct gfs2_quota_data, qd_list);
+               qd = list_last_entry(head, struct gfs2_quota_data, qd_list);
 
                list_del(&qd->qd_list);
 
@@ -1504,7 +1504,7 @@ static void quotad_check_trunc_list(struct gfs2_sbd *sdp)
                ip = NULL;
                spin_lock(&sdp->sd_trunc_lock);
                if (!list_empty(&sdp->sd_trunc_list)) {
-                       ip = list_entry(sdp->sd_trunc_list.next,
+                       ip = list_first_entry(&sdp->sd_trunc_list,
                                        struct gfs2_inode, i_trunc_list);
                        list_del_init(&ip->i_trunc_list);
                }
index 21fc44b3186361f2901b5d9d1c3aa9376fd031e7..34dfdb211439ea5cbd7bb49e99383d506203ae77 100644 (file)
@@ -111,7 +111,7 @@ void gfs2_revoke_clean(struct gfs2_jdesc *jd)
        struct gfs2_revoke_replay *rr;
 
        while (!list_empty(head)) {
-               rr = list_entry(head->next, struct gfs2_revoke_replay, rr_list);
+               rr = list_first_entry(head, struct gfs2_revoke_replay, rr_list);
                list_del(&rr->rr_list);
                kfree(rr);
        }
index d664b01759468546f2d84264e7d36890564d6545..a6bf8f1e083e6fc898132c69319ece215ccdd966 100644 (file)
@@ -63,7 +63,7 @@ void gfs2_jindex_free(struct gfs2_sbd *sdp)
 
        sdp->sd_jdesc = NULL;
        while (!list_empty(&list)) {
-               jd = list_entry(list.next, struct gfs2_jdesc, jd_list);
+               jd = list_first_entry(&list, struct gfs2_jdesc, jd_list);
                gfs2_free_journal_extents(jd);
                list_del(&jd->jd_list);
                iput(jd->jd_inode);
@@ -452,7 +452,7 @@ static int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp)
 
 out:
        while (!list_empty(&list)) {
-               lfcc = list_entry(list.next, struct lfcc, list);
+               lfcc = list_first_entry(&list, struct lfcc, list);
                list_del(&lfcc->list);
                gfs2_glock_dq_uninit(&lfcc->gh);
                kfree(lfcc);