aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/slot_map.c
diff options
context:
space:
mode:
authorMark Fasheh <mfasheh@suse.com>2008-02-01 14:59:09 -0500
committerMark Fasheh <mfasheh@suse.com>2008-04-18 11:56:02 -0400
commit8e8a4603b5422c9145880e73b23bc4c2c4de0098 (patch)
tree4d388ae74ed9e5f8cfec19ff20d07d81ca742592 /fs/ocfs2/slot_map.c
parent4b119e21d0c66c22e8ca03df05d9de623d0eb50f (diff)
ocfs2: Move slot map access into slot_map.c
journal.c and dlmglue.c would refresh the slot map by hand. Instead, have the update and clear functions do the work inside slot_map.c. The eventual result is to make ocfs2_slot_info defined privately in slot_map.c Signed-off-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2/slot_map.c')
-rw-r--r--fs/ocfs2/slot_map.c62
1 files changed, 48 insertions, 14 deletions
diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c
index 3a50ce555e64..f5727b8cc913 100644
--- a/fs/ocfs2/slot_map.c
+++ b/fs/ocfs2/slot_map.c
@@ -49,7 +49,7 @@ static void __ocfs2_fill_slot(struct ocfs2_slot_info *si,
49 s16 node_num); 49 s16 node_num);
50 50
51/* post the slot information on disk into our slot_info struct. */ 51/* post the slot information on disk into our slot_info struct. */
52void ocfs2_update_slot_info(struct ocfs2_slot_info *si) 52static void ocfs2_update_slot_info(struct ocfs2_slot_info *si)
53{ 53{
54 int i; 54 int i;
55 __le16 *disk_info; 55 __le16 *disk_info;
@@ -65,10 +65,27 @@ void ocfs2_update_slot_info(struct ocfs2_slot_info *si)
65 spin_unlock(&si->si_lock); 65 spin_unlock(&si->si_lock);
66} 66}
67 67
68int ocfs2_refresh_slot_info(struct ocfs2_super *osb)
69{
70 int ret;
71 struct ocfs2_slot_info *si = osb->slot_info;
72 struct buffer_head *bh;
73
74 if (si == NULL)
75 return 0;
76
77 bh = si->si_bh;
78 ret = ocfs2_read_block(osb, bh->b_blocknr, &bh, 0, si->si_inode);
79 if (ret == 0)
80 ocfs2_update_slot_info(si);
81
82 return ret;
83}
84
68/* post the our slot info stuff into it's destination bh and write it 85/* post the our slot info stuff into it's destination bh and write it
69 * out. */ 86 * out. */
70int ocfs2_update_disk_slots(struct ocfs2_super *osb, 87static int ocfs2_update_disk_slots(struct ocfs2_super *osb,
71 struct ocfs2_slot_info *si) 88 struct ocfs2_slot_info *si)
72{ 89{
73 int status, i; 90 int status, i;
74 __le16 *disk_info = (__le16 *) si->si_bh->b_data; 91 __le16 *disk_info = (__le16 *) si->si_bh->b_data;
@@ -135,6 +152,19 @@ s16 ocfs2_node_num_to_slot(struct ocfs2_slot_info *si,
135 return ret; 152 return ret;
136} 153}
137 154
155static void __ocfs2_free_slot_info(struct ocfs2_slot_info *si)
156{
157 if (si == NULL)
158 return;
159
160 if (si->si_inode)
161 iput(si->si_inode);
162 if (si->si_bh)
163 brelse(si->si_bh);
164
165 kfree(si);
166}
167
138static void __ocfs2_fill_slot(struct ocfs2_slot_info *si, 168static void __ocfs2_fill_slot(struct ocfs2_slot_info *si,
139 s16 slot_num, 169 s16 slot_num,
140 s16 node_num) 170 s16 node_num)
@@ -147,12 +177,18 @@ static void __ocfs2_fill_slot(struct ocfs2_slot_info *si,
147 si->si_global_node_nums[slot_num] = node_num; 177 si->si_global_node_nums[slot_num] = node_num;
148} 178}
149 179
150void ocfs2_clear_slot(struct ocfs2_slot_info *si, 180int ocfs2_clear_slot(struct ocfs2_super *osb, s16 slot_num)
151 s16 slot_num)
152{ 181{
182 struct ocfs2_slot_info *si = osb->slot_info;
183
184 if (si == NULL)
185 return 0;
186
153 spin_lock(&si->si_lock); 187 spin_lock(&si->si_lock);
154 __ocfs2_fill_slot(si, slot_num, OCFS2_INVALID_SLOT); 188 __ocfs2_fill_slot(si, slot_num, OCFS2_INVALID_SLOT);
155 spin_unlock(&si->si_lock); 189 spin_unlock(&si->si_lock);
190
191 return ocfs2_update_disk_slots(osb, osb->slot_info);
156} 192}
157 193
158int ocfs2_init_slot_info(struct ocfs2_super *osb) 194int ocfs2_init_slot_info(struct ocfs2_super *osb)
@@ -202,18 +238,17 @@ int ocfs2_init_slot_info(struct ocfs2_super *osb)
202 osb->slot_info = si; 238 osb->slot_info = si;
203bail: 239bail:
204 if (status < 0 && si) 240 if (status < 0 && si)
205 ocfs2_free_slot_info(si); 241 __ocfs2_free_slot_info(si);
206 242
207 return status; 243 return status;
208} 244}
209 245
210void ocfs2_free_slot_info(struct ocfs2_slot_info *si) 246void ocfs2_free_slot_info(struct ocfs2_super *osb)
211{ 247{
212 if (si->si_inode) 248 struct ocfs2_slot_info *si = osb->slot_info;
213 iput(si->si_inode); 249
214 if (si->si_bh) 250 osb->slot_info = NULL;
215 brelse(si->si_bh); 251 __ocfs2_free_slot_info(si);
216 kfree(si);
217} 252}
218 253
219int ocfs2_find_slot(struct ocfs2_super *osb) 254int ocfs2_find_slot(struct ocfs2_super *osb)
@@ -285,7 +320,6 @@ void ocfs2_put_slot(struct ocfs2_super *osb)
285 } 320 }
286 321
287bail: 322bail:
288 osb->slot_info = NULL; 323 ocfs2_free_slot_info(osb);
289 ocfs2_free_slot_info(si);
290} 324}
291 325