diff options
author | David Teigland <teigland@redhat.com> | 2013-01-07 12:03:42 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2013-01-07 13:02:49 -0500 |
commit | f11722834605a155022a8098ad7d8adacf44b22f (patch) | |
tree | 9a2004fa6c4a925971c338db5af8f643a990f2d8 | |
parent | 2318aa272072f6906de8e00a332da1485506b3c5 (diff) |
dlm: avoid scanning unchanged toss lists
Keep track of whether a toss list contains any
shrinkable rsbs. If not, dlm_scand can avoid
scanning the list for rsbs to shrink. Unnecessary
scanning can otherwise waste a lot of time because
the toss lists can contain a large number of rsbs
that are non-shrinkable (directory records).
Signed-off-by: David Teigland <teigland@redhat.com>
-rw-r--r-- | fs/dlm/dlm_internal.h | 3 | ||||
-rw-r--r-- | fs/dlm/lock.c | 15 |
2 files changed, 18 insertions, 0 deletions
diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h index 77c0f70f8fe8..e7665c31f7b1 100644 --- a/fs/dlm/dlm_internal.h +++ b/fs/dlm/dlm_internal.h | |||
@@ -96,10 +96,13 @@ do { \ | |||
96 | } | 96 | } |
97 | 97 | ||
98 | 98 | ||
99 | #define DLM_RTF_SHRINK 0x00000001 | ||
100 | |||
99 | struct dlm_rsbtable { | 101 | struct dlm_rsbtable { |
100 | struct rb_root keep; | 102 | struct rb_root keep; |
101 | struct rb_root toss; | 103 | struct rb_root toss; |
102 | spinlock_t lock; | 104 | spinlock_t lock; |
105 | uint32_t flags; | ||
103 | }; | 106 | }; |
104 | 107 | ||
105 | 108 | ||
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c index a579f30f237d..f7501651762d 100644 --- a/fs/dlm/lock.c +++ b/fs/dlm/lock.c | |||
@@ -1132,6 +1132,7 @@ static void toss_rsb(struct kref *kref) | |||
1132 | rb_erase(&r->res_hashnode, &ls->ls_rsbtbl[r->res_bucket].keep); | 1132 | rb_erase(&r->res_hashnode, &ls->ls_rsbtbl[r->res_bucket].keep); |
1133 | rsb_insert(r, &ls->ls_rsbtbl[r->res_bucket].toss); | 1133 | rsb_insert(r, &ls->ls_rsbtbl[r->res_bucket].toss); |
1134 | r->res_toss_time = jiffies; | 1134 | r->res_toss_time = jiffies; |
1135 | ls->ls_rsbtbl[r->res_bucket].flags |= DLM_RTF_SHRINK; | ||
1135 | if (r->res_lvbptr) { | 1136 | if (r->res_lvbptr) { |
1136 | dlm_free_lvb(r->res_lvbptr); | 1137 | dlm_free_lvb(r->res_lvbptr); |
1137 | r->res_lvbptr = NULL; | 1138 | r->res_lvbptr = NULL; |
@@ -1659,11 +1660,18 @@ static void shrink_bucket(struct dlm_ls *ls, int b) | |||
1659 | char *name; | 1660 | char *name; |
1660 | int our_nodeid = dlm_our_nodeid(); | 1661 | int our_nodeid = dlm_our_nodeid(); |
1661 | int remote_count = 0; | 1662 | int remote_count = 0; |
1663 | int need_shrink = 0; | ||
1662 | int i, len, rv; | 1664 | int i, len, rv; |
1663 | 1665 | ||
1664 | memset(&ls->ls_remove_lens, 0, sizeof(int) * DLM_REMOVE_NAMES_MAX); | 1666 | memset(&ls->ls_remove_lens, 0, sizeof(int) * DLM_REMOVE_NAMES_MAX); |
1665 | 1667 | ||
1666 | spin_lock(&ls->ls_rsbtbl[b].lock); | 1668 | spin_lock(&ls->ls_rsbtbl[b].lock); |
1669 | |||
1670 | if (!(ls->ls_rsbtbl[b].flags & DLM_RTF_SHRINK)) { | ||
1671 | spin_unlock(&ls->ls_rsbtbl[b].lock); | ||
1672 | return; | ||
1673 | } | ||
1674 | |||
1667 | for (n = rb_first(&ls->ls_rsbtbl[b].toss); n; n = next) { | 1675 | for (n = rb_first(&ls->ls_rsbtbl[b].toss); n; n = next) { |
1668 | next = rb_next(n); | 1676 | next = rb_next(n); |
1669 | r = rb_entry(n, struct dlm_rsb, res_hashnode); | 1677 | r = rb_entry(n, struct dlm_rsb, res_hashnode); |
@@ -1679,6 +1687,8 @@ static void shrink_bucket(struct dlm_ls *ls, int b) | |||
1679 | continue; | 1687 | continue; |
1680 | } | 1688 | } |
1681 | 1689 | ||
1690 | need_shrink = 1; | ||
1691 | |||
1682 | if (!time_after_eq(jiffies, r->res_toss_time + | 1692 | if (!time_after_eq(jiffies, r->res_toss_time + |
1683 | dlm_config.ci_toss_secs * HZ)) { | 1693 | dlm_config.ci_toss_secs * HZ)) { |
1684 | continue; | 1694 | continue; |
@@ -1710,6 +1720,11 @@ static void shrink_bucket(struct dlm_ls *ls, int b) | |||
1710 | rb_erase(&r->res_hashnode, &ls->ls_rsbtbl[b].toss); | 1720 | rb_erase(&r->res_hashnode, &ls->ls_rsbtbl[b].toss); |
1711 | dlm_free_rsb(r); | 1721 | dlm_free_rsb(r); |
1712 | } | 1722 | } |
1723 | |||
1724 | if (need_shrink) | ||
1725 | ls->ls_rsbtbl[b].flags |= DLM_RTF_SHRINK; | ||
1726 | else | ||
1727 | ls->ls_rsbtbl[b].flags &= ~DLM_RTF_SHRINK; | ||
1713 | spin_unlock(&ls->ls_rsbtbl[b].lock); | 1728 | spin_unlock(&ls->ls_rsbtbl[b].lock); |
1714 | 1729 | ||
1715 | /* | 1730 | /* |