1 From: Sunil Mushran <sunil.mushran@oracle.com>
2 Date: Thu, 26 Feb 2009 15:00:44 -0800
3 Subject: ocfs2/dlm: Improve lockres counts
7 This patch replaces the lockres counts that tracked the number number of
8 locally and remotely mastered lockres' with a current and total count. The
9 total count is the number of lockres' that have been created since the dlm
12 The number of locally and remotely mastered counts can be computed using
13 the locking_state output.
15 Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com>
16 Signed-off-by: Mark Fasheh <mfasheh@suse.com>
18 fs/ocfs2/dlm/dlmcommon.h | 5 ++---
19 fs/ocfs2/dlm/dlmdebug.c | 12 ------------
20 fs/ocfs2/dlm/dlmdomain.c | 5 ++---
21 fs/ocfs2/dlm/dlmmaster.c | 27 +++++++--------------------
22 4 files changed, 11 insertions(+), 38 deletions(-)
24 diff --git a/fs/ocfs2/dlm/dlmcommon.h b/fs/ocfs2/dlm/dlmcommon.h
25 index 67b3447..e5026ce 100644
26 --- a/fs/ocfs2/dlm/dlmcommon.h
27 +++ b/fs/ocfs2/dlm/dlmcommon.h
28 @@ -159,9 +159,8 @@ struct dlm_ctxt
29 /* these give a really vague idea of the system load */
30 atomic_t mle_tot_count[DLM_MLE_NUM_TYPES];
31 atomic_t mle_cur_count[DLM_MLE_NUM_TYPES];
32 - atomic_t local_resources;
33 - atomic_t remote_resources;
34 - atomic_t unknown_resources;
35 + atomic_t res_tot_count;
36 + atomic_t res_cur_count;
38 struct dlm_debug_ctxt *dlm_debug_ctxt;
39 struct dentry *dlm_debugfs_subroot;
40 diff --git a/fs/ocfs2/dlm/dlmdebug.c b/fs/ocfs2/dlm/dlmdebug.c
41 index 336a98e..d7decaa 100644
42 --- a/fs/ocfs2/dlm/dlmdebug.c
43 +++ b/fs/ocfs2/dlm/dlmdebug.c
44 @@ -763,12 +763,6 @@ static int debug_state_print(struct dlm_ctxt *dlm, struct debug_buffer *db)
46 struct dlm_reco_node_data *node;
48 - int lres, rres, ures, tres;
50 - lres = atomic_read(&dlm->local_resources);
51 - rres = atomic_read(&dlm->remote_resources);
52 - ures = atomic_read(&dlm->unknown_resources);
53 - tres = lres + rres + ures;
55 spin_lock(&dlm->spinlock);
57 @@ -811,12 +805,6 @@ static int debug_state_print(struct dlm_ctxt *dlm, struct debug_buffer *db)
58 db->buf + out, db->len - out);
59 out += snprintf(db->buf + out, db->len - out, "\n");
61 - /* Mastered Resources Total: xxx Locally: xxx Remotely: ... */
62 - out += snprintf(db->buf + out, db->len - out,
63 - "Mastered Resources Total: %d Locally: %d "
64 - "Remotely: %d Unknown: %d\n",
65 - tres, lres, rres, ures);
67 /* Lists: Dirty=Empty Purge=InUse PendingASTs=Empty ... */
68 out += snprintf(db->buf + out, db->len - out,
69 "Lists: Dirty=%s Purge=%s PendingASTs=%s "
70 diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c
71 index 0479bdf..4d9e6b2 100644
72 --- a/fs/ocfs2/dlm/dlmdomain.c
73 +++ b/fs/ocfs2/dlm/dlmdomain.c
74 @@ -1604,10 +1604,9 @@ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain,
76 dlm->reco.new_master = O2NM_INVALID_NODE_NUM;
77 dlm->reco.dead_node = O2NM_INVALID_NODE_NUM;
78 - atomic_set(&dlm->local_resources, 0);
79 - atomic_set(&dlm->remote_resources, 0);
80 - atomic_set(&dlm->unknown_resources, 0);
82 + atomic_set(&dlm->res_tot_count, 0);
83 + atomic_set(&dlm->res_cur_count, 0);
84 for (i = 0; i < DLM_MLE_NUM_TYPES; ++i) {
85 atomic_set(&dlm->mle_tot_count[i], 0);
86 atomic_set(&dlm->mle_cur_count[i], 0);
87 diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
88 index acfc928..d70cdd5 100644
89 --- a/fs/ocfs2/dlm/dlmmaster.c
90 +++ b/fs/ocfs2/dlm/dlmmaster.c
91 @@ -517,15 +517,6 @@ static void dlm_set_lockres_owner(struct dlm_ctxt *dlm,
93 assert_spin_locked(&res->spinlock);
95 - mlog_entry("%.*s, %u\n", res->lockname.len, res->lockname.name, owner);
97 - if (owner == dlm->node_num)
98 - atomic_inc(&dlm->local_resources);
99 - else if (owner == DLM_LOCK_RES_OWNER_UNKNOWN)
100 - atomic_inc(&dlm->unknown_resources);
102 - atomic_inc(&dlm->remote_resources);
107 @@ -534,17 +525,8 @@ void dlm_change_lockres_owner(struct dlm_ctxt *dlm,
109 assert_spin_locked(&res->spinlock);
111 - if (owner == res->owner)
114 - if (res->owner == dlm->node_num)
115 - atomic_dec(&dlm->local_resources);
116 - else if (res->owner == DLM_LOCK_RES_OWNER_UNKNOWN)
117 - atomic_dec(&dlm->unknown_resources);
119 - atomic_dec(&dlm->remote_resources);
121 - dlm_set_lockres_owner(dlm, res, owner);
122 + if (owner != res->owner)
123 + dlm_set_lockres_owner(dlm, res, owner);
127 @@ -573,6 +555,8 @@ static void dlm_lockres_release(struct kref *kref)
129 spin_unlock(&dlm->track_lock);
131 + atomic_dec(&dlm->res_cur_count);
135 if (!hlist_unhashed(&res->hash_node) ||
136 @@ -653,6 +637,9 @@ static void dlm_init_lockres(struct dlm_ctxt *dlm,
138 kref_init(&res->refs);
140 + atomic_inc(&dlm->res_tot_count);
141 + atomic_inc(&dlm->res_cur_count);
143 /* just for consistency */
144 spin_lock(&res->spinlock);
145 dlm_set_lockres_owner(dlm, res, DLM_LOCK_RES_OWNER_UNKNOWN);