aboutsummaryrefslogtreecommitdiffstats
path: root/fs
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
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')
-rw-r--r--fs/ocfs2/dlmglue.c8
-rw-r--r--fs/ocfs2/journal.c3
-rw-r--r--fs/ocfs2/slot_map.c62
-rw-r--r--fs/ocfs2/slot_map.h11
-rw-r--r--fs/ocfs2/super.c3
5 files changed, 55 insertions, 32 deletions
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 1f1873bf41fb..1a80fa9e7c9a 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -2132,8 +2132,6 @@ int ocfs2_super_lock(struct ocfs2_super *osb,
2132 int status = 0; 2132 int status = 0;
2133 int level = ex ? LKM_EXMODE : LKM_PRMODE; 2133 int level = ex ? LKM_EXMODE : LKM_PRMODE;
2134 struct ocfs2_lock_res *lockres = &osb->osb_super_lockres; 2134 struct ocfs2_lock_res *lockres = &osb->osb_super_lockres;
2135 struct buffer_head *bh;
2136 struct ocfs2_slot_info *si = osb->slot_info;
2137 2135
2138 mlog_entry_void(); 2136 mlog_entry_void();
2139 2137
@@ -2159,11 +2157,7 @@ int ocfs2_super_lock(struct ocfs2_super *osb,
2159 goto bail; 2157 goto bail;
2160 } 2158 }
2161 if (status) { 2159 if (status) {
2162 bh = si->si_bh; 2160 status = ocfs2_refresh_slot_info(osb);
2163 status = ocfs2_read_block(osb, bh->b_blocknr, &bh, 0,
2164 si->si_inode);
2165 if (status == 0)
2166 ocfs2_update_slot_info(si);
2167 2161
2168 ocfs2_complete_lock_res_refresh(lockres, status); 2162 ocfs2_complete_lock_res_refresh(lockres, status);
2169 2163
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index f31c7e8c19c3..c2e654ee703a 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -1123,8 +1123,7 @@ static int ocfs2_recover_node(struct ocfs2_super *osb,
1123 1123
1124 /* Likewise, this would be a strange but ultimately not so 1124 /* Likewise, this would be a strange but ultimately not so
1125 * harmful place to get an error... */ 1125 * harmful place to get an error... */
1126 ocfs2_clear_slot(si, slot_num); 1126 status = ocfs2_clear_slot(osb, slot_num);
1127 status = ocfs2_update_disk_slots(osb, si);
1128 if (status < 0) 1127 if (status < 0)
1129 mlog_errno(status); 1128 mlog_errno(status);
1130 1129
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
diff --git a/fs/ocfs2/slot_map.h b/fs/ocfs2/slot_map.h
index 1025872aaade..b029ffdc8ea5 100644
--- a/fs/ocfs2/slot_map.h
+++ b/fs/ocfs2/slot_map.h
@@ -30,7 +30,7 @@
30struct ocfs2_slot_info { 30struct ocfs2_slot_info {
31 spinlock_t si_lock; 31 spinlock_t si_lock;
32 32
33 struct inode *si_inode; 33 struct inode *si_inode;
34 struct buffer_head *si_bh; 34 struct buffer_head *si_bh;
35 unsigned int si_num_slots; 35 unsigned int si_num_slots;
36 unsigned int si_size; 36 unsigned int si_size;
@@ -38,19 +38,16 @@ struct ocfs2_slot_info {
38}; 38};
39 39
40int ocfs2_init_slot_info(struct ocfs2_super *osb); 40int ocfs2_init_slot_info(struct ocfs2_super *osb);
41void ocfs2_free_slot_info(struct ocfs2_slot_info *si); 41void ocfs2_free_slot_info(struct ocfs2_super *osb);
42 42
43int ocfs2_find_slot(struct ocfs2_super *osb); 43int ocfs2_find_slot(struct ocfs2_super *osb);
44void ocfs2_put_slot(struct ocfs2_super *osb); 44void ocfs2_put_slot(struct ocfs2_super *osb);
45 45
46void ocfs2_update_slot_info(struct ocfs2_slot_info *si); 46int ocfs2_refresh_slot_info(struct ocfs2_super *osb);
47int ocfs2_update_disk_slots(struct ocfs2_super *osb,
48 struct ocfs2_slot_info *si);
49 47
50s16 ocfs2_node_num_to_slot(struct ocfs2_slot_info *si, 48s16 ocfs2_node_num_to_slot(struct ocfs2_slot_info *si,
51 s16 global); 49 s16 global);
52void ocfs2_clear_slot(struct ocfs2_slot_info *si, 50int ocfs2_clear_slot(struct ocfs2_super *osb, s16 slot_num);
53 s16 slot_num);
54 51
55static inline int ocfs2_is_empty_slot(struct ocfs2_slot_info *si, 52static inline int ocfs2_is_empty_slot(struct ocfs2_slot_info *si,
56 int slot_num) 53 int slot_num)
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index bec75aff3d9f..fad37af2af9c 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -1724,8 +1724,7 @@ static void ocfs2_delete_osb(struct ocfs2_super *osb)
1724 1724
1725 /* This function assumes that the caller has the main osb resource */ 1725 /* This function assumes that the caller has the main osb resource */
1726 1726
1727 if (osb->slot_info) 1727 ocfs2_free_slot_info(osb);
1728 ocfs2_free_slot_info(osb->slot_info);
1729 1728
1730 kfree(osb->osb_orphan_wipes); 1729 kfree(osb->osb_orphan_wipes);
1731 /* FIXME 1730 /* FIXME