]>
Commit | Line | Data |
---|---|---|
00e5a55c BS |
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 | |
4 | Patch-mainline: 2.6.30 | |
5 | References: bnc#408304 | |
6 | ||
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 | |
10 | domain was created. | |
11 | ||
12 | The number of locally and remotely mastered counts can be computed using | |
13 | the locking_state output. | |
14 | ||
15 | Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com> | |
16 | Signed-off-by: Mark Fasheh <mfasheh@suse.com> | |
17 | --- | |
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(-) | |
23 | ||
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; | |
37 | ||
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) | |
45 | int out = 0; | |
46 | struct dlm_reco_node_data *node; | |
47 | char *state; | |
48 | - int lres, rres, ures, tres; | |
49 | - | |
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; | |
54 | ||
55 | spin_lock(&dlm->spinlock); | |
56 | ||
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"); | |
60 | ||
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); | |
66 | - | |
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, | |
75 | ||
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); | |
81 | ||
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, | |
92 | { | |
93 | assert_spin_locked(&res->spinlock); | |
94 | ||
95 | - mlog_entry("%.*s, %u\n", res->lockname.len, res->lockname.name, owner); | |
96 | - | |
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); | |
101 | - else | |
102 | - atomic_inc(&dlm->remote_resources); | |
103 | - | |
104 | res->owner = owner; | |
105 | } | |
106 | ||
107 | @@ -534,17 +525,8 @@ void dlm_change_lockres_owner(struct dlm_ctxt *dlm, | |
108 | { | |
109 | assert_spin_locked(&res->spinlock); | |
110 | ||
111 | - if (owner == res->owner) | |
112 | - return; | |
113 | - | |
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); | |
118 | - else | |
119 | - atomic_dec(&dlm->remote_resources); | |
120 | - | |
121 | - dlm_set_lockres_owner(dlm, res, owner); | |
122 | + if (owner != res->owner) | |
123 | + dlm_set_lockres_owner(dlm, res, owner); | |
124 | } | |
125 | ||
126 | ||
127 | @@ -573,6 +555,8 @@ static void dlm_lockres_release(struct kref *kref) | |
128 | } | |
129 | spin_unlock(&dlm->track_lock); | |
130 | ||
131 | + atomic_dec(&dlm->res_cur_count); | |
132 | + | |
133 | dlm_put(dlm); | |
134 | ||
135 | if (!hlist_unhashed(&res->hash_node) || | |
136 | @@ -653,6 +637,9 @@ static void dlm_init_lockres(struct dlm_ctxt *dlm, | |
137 | ||
138 | kref_init(&res->refs); | |
139 | ||
140 | + atomic_inc(&dlm->res_tot_count); | |
141 | + atomic_inc(&dlm->res_cur_count); | |
142 | + | |
143 | /* just for consistency */ | |
144 | spin_lock(&res->spinlock); | |
145 | dlm_set_lockres_owner(dlm, res, DLM_LOCK_RES_OWNER_UNKNOWN); | |
146 | -- | |
147 | 1.5.6 | |
148 |