Skip to content

Commit 969183b

Browse files
Andreas GruenbacherAstralBob
authored andcommitted
gfs2: Switch to list_{first,last}_entry
Replace open-coded versions of list_first_entry and list_last_entry with those functions. Signed-off-by: Andreas Gruenbacher <[email protected]> Signed-off-by: Bob Peterson <[email protected]>
1 parent 40e7e86 commit 969183b

File tree

7 files changed

+19
-19
lines changed

7 files changed

+19
-19
lines changed

fs/gfs2/bmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2223,7 +2223,7 @@ void gfs2_free_journal_extents(struct gfs2_jdesc *jd)
22232223
struct gfs2_journal_extent *jext;
22242224

22252225
while(!list_empty(&jd->extent_list)) {
2226-
jext = list_entry(jd->extent_list.next, struct gfs2_journal_extent, list);
2226+
jext = list_first_entry(&jd->extent_list, struct gfs2_journal_extent, list);
22272227
list_del(&jext->list);
22282228
kfree(jext);
22292229
}
@@ -2244,7 +2244,7 @@ static int gfs2_add_jextent(struct gfs2_jdesc *jd, u64 lblock, u64 dblock, u64 b
22442244
struct gfs2_journal_extent *jext;
22452245

22462246
if (!list_empty(&jd->extent_list)) {
2247-
jext = list_entry(jd->extent_list.prev, struct gfs2_journal_extent, list);
2247+
jext = list_last_entry(&jd->extent_list, struct gfs2_journal_extent, list);
22482248
if ((jext->dblock + jext->blocks) == dblock) {
22492249
jext->blocks += blocks;
22502250
return 0;

fs/gfs2/glock.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ void gfs2_glock_put(struct gfs2_glock *gl)
308308

309309
static inline int may_grant(const struct gfs2_glock *gl, const struct gfs2_holder *gh)
310310
{
311-
const struct gfs2_holder *gh_head = list_entry(gl->gl_holders.next, const struct gfs2_holder, gh_list);
311+
const struct gfs2_holder *gh_head = list_first_entry(&gl->gl_holders, const struct gfs2_holder, gh_list);
312312
if ((gh->gh_state == LM_ST_EXCLUSIVE ||
313313
gh_head->gh_state == LM_ST_EXCLUSIVE) && gh != gh_head)
314314
return 0;
@@ -690,7 +690,7 @@ static inline struct gfs2_holder *find_first_holder(const struct gfs2_glock *gl)
690690
struct gfs2_holder *gh;
691691

692692
if (!list_empty(&gl->gl_holders)) {
693-
gh = list_entry(gl->gl_holders.next, struct gfs2_holder, gh_list);
693+
gh = list_first_entry(&gl->gl_holders, struct gfs2_holder, gh_list);
694694
if (test_bit(HIF_HOLDER, &gh->gh_iflags))
695695
return gh;
696696
}
@@ -1240,7 +1240,7 @@ __acquires(&gl->gl_lockref.lock)
12401240
}
12411241
list_add_tail(&gh->gh_list, insert_pt);
12421242
do_cancel:
1243-
gh = list_entry(gl->gl_holders.next, struct gfs2_holder, gh_list);
1243+
gh = list_first_entry(&gl->gl_holders, struct gfs2_holder, gh_list);
12441244
if (!(gh->gh_flags & LM_FLAG_PRIORITY)) {
12451245
spin_unlock(&gl->gl_lockref.lock);
12461246
if (sdp->sd_lockstruct.ls_ops->lm_cancel)
@@ -1642,7 +1642,7 @@ __acquires(&lru_lock)
16421642
list_sort(NULL, list, glock_cmp);
16431643

16441644
while(!list_empty(list)) {
1645-
gl = list_entry(list->next, struct gfs2_glock, gl_lru);
1645+
gl = list_first_entry(list, struct gfs2_glock, gl_lru);
16461646
list_del_init(&gl->gl_lru);
16471647
if (!spin_trylock(&gl->gl_lockref.lock)) {
16481648
add_back_to_lru:
@@ -1683,7 +1683,7 @@ static long gfs2_scan_glock_lru(int nr)
16831683

16841684
spin_lock(&lru_lock);
16851685
while ((nr-- >= 0) && !list_empty(&lru_list)) {
1686-
gl = list_entry(lru_list.next, struct gfs2_glock, gl_lru);
1686+
gl = list_first_entry(&lru_list, struct gfs2_glock, gl_lru);
16871687

16881688
/* Test for being demotable */
16891689
if (!test_bit(GLF_LOCK, &gl->gl_flags)) {

fs/gfs2/log.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ static unsigned int current_tail(struct gfs2_sbd *sdp)
518518
if (list_empty(&sdp->sd_ail1_list)) {
519519
tail = sdp->sd_log_head;
520520
} else {
521-
tr = list_entry(sdp->sd_ail1_list.prev, struct gfs2_trans,
521+
tr = list_last_entry(&sdp->sd_ail1_list, struct gfs2_trans,
522522
tr_list);
523523
tail = tr->tr_first;
524524
}
@@ -580,7 +580,7 @@ static void gfs2_ordered_write(struct gfs2_sbd *sdp)
580580
spin_lock(&sdp->sd_ordered_lock);
581581
list_sort(NULL, &sdp->sd_log_ordered, &ip_cmp);
582582
while (!list_empty(&sdp->sd_log_ordered)) {
583-
ip = list_entry(sdp->sd_log_ordered.next, struct gfs2_inode, i_ordered);
583+
ip = list_first_entry(&sdp->sd_log_ordered, struct gfs2_inode, i_ordered);
584584
if (ip->i_inode.i_mapping->nrpages == 0) {
585585
test_and_clear_bit(GIF_ORDERED, &ip->i_flags);
586586
list_del(&ip->i_ordered);
@@ -601,7 +601,7 @@ static void gfs2_ordered_wait(struct gfs2_sbd *sdp)
601601

602602
spin_lock(&sdp->sd_ordered_lock);
603603
while (!list_empty(&sdp->sd_log_ordered)) {
604-
ip = list_entry(sdp->sd_log_ordered.next, struct gfs2_inode, i_ordered);
604+
ip = list_first_entry(&sdp->sd_log_ordered, struct gfs2_inode, i_ordered);
605605
list_del(&ip->i_ordered);
606606
WARN_ON(!test_and_clear_bit(GIF_ORDERED, &ip->i_flags));
607607
if (ip->i_inode.i_mapping->nrpages == 0)

fs/gfs2/lops.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ static void buf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
734734

735735
head = &tr->tr_buf;
736736
while (!list_empty(head)) {
737-
bd = list_entry(head->next, struct gfs2_bufdata, bd_list);
737+
bd = list_first_entry(head, struct gfs2_bufdata, bd_list);
738738
list_del_init(&bd->bd_list);
739739
gfs2_unpin(sdp, bd->bd_bh, tr);
740740
}
@@ -904,7 +904,7 @@ static void revoke_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
904904
struct gfs2_glock *gl;
905905

906906
while (!list_empty(head)) {
907-
bd = list_entry(head->next, struct gfs2_bufdata, bd_list);
907+
bd = list_first_entry(head, struct gfs2_bufdata, bd_list);
908908
list_del_init(&bd->bd_list);
909909
gl = bd->bd_gl;
910910
gfs2_glock_remove_revoke(gl);
@@ -1083,7 +1083,7 @@ static void databuf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
10831083

10841084
head = &tr->tr_databuf;
10851085
while (!list_empty(head)) {
1086-
bd = list_entry(head->next, struct gfs2_bufdata, bd_list);
1086+
bd = list_first_entry(head, struct gfs2_bufdata, bd_list);
10871087
list_del_init(&bd->bd_list);
10881088
gfs2_unpin(sdp, bd->bd_bh, tr);
10891089
}

fs/gfs2/quota.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static void gfs2_qd_dispose(struct list_head *list)
115115
struct gfs2_sbd *sdp;
116116

117117
while (!list_empty(list)) {
118-
qd = list_entry(list->next, struct gfs2_quota_data, qd_lru);
118+
qd = list_first_entry(list, struct gfs2_quota_data, qd_lru);
119119
sdp = qd->qd_gl->gl_name.ln_sbd;
120120

121121
list_del(&qd->qd_lru);
@@ -1441,7 +1441,7 @@ void gfs2_quota_cleanup(struct gfs2_sbd *sdp)
14411441

14421442
spin_lock(&qd_lock);
14431443
while (!list_empty(head)) {
1444-
qd = list_entry(head->prev, struct gfs2_quota_data, qd_list);
1444+
qd = list_last_entry(head, struct gfs2_quota_data, qd_list);
14451445

14461446
list_del(&qd->qd_list);
14471447

@@ -1504,7 +1504,7 @@ static void quotad_check_trunc_list(struct gfs2_sbd *sdp)
15041504
ip = NULL;
15051505
spin_lock(&sdp->sd_trunc_lock);
15061506
if (!list_empty(&sdp->sd_trunc_list)) {
1507-
ip = list_entry(sdp->sd_trunc_list.next,
1507+
ip = list_first_entry(&sdp->sd_trunc_list,
15081508
struct gfs2_inode, i_trunc_list);
15091509
list_del_init(&ip->i_trunc_list);
15101510
}

fs/gfs2/recovery.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void gfs2_revoke_clean(struct gfs2_jdesc *jd)
111111
struct gfs2_revoke_replay *rr;
112112

113113
while (!list_empty(head)) {
114-
rr = list_entry(head->next, struct gfs2_revoke_replay, rr_list);
114+
rr = list_first_entry(head, struct gfs2_revoke_replay, rr_list);
115115
list_del(&rr->rr_list);
116116
kfree(rr);
117117
}

fs/gfs2/super.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void gfs2_jindex_free(struct gfs2_sbd *sdp)
6363

6464
sdp->sd_jdesc = NULL;
6565
while (!list_empty(&list)) {
66-
jd = list_entry(list.next, struct gfs2_jdesc, jd_list);
66+
jd = list_first_entry(&list, struct gfs2_jdesc, jd_list);
6767
gfs2_free_journal_extents(jd);
6868
list_del(&jd->jd_list);
6969
iput(jd->jd_inode);
@@ -452,7 +452,7 @@ static int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp)
452452

453453
out:
454454
while (!list_empty(&list)) {
455-
lfcc = list_entry(list.next, struct lfcc, list);
455+
lfcc = list_first_entry(&list, struct lfcc, list);
456456
list_del(&lfcc->list);
457457
gfs2_glock_dq_uninit(&lfcc->gh);
458458
kfree(lfcc);

0 commit comments

Comments
 (0)