Commit 8e8a4603 authored by Mark Fasheh's avatar Mark Fasheh

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: default avatarJoel Becker <joel.becker@oracle.com>
Signed-off-by: default avatarMark Fasheh <mfasheh@suse.com>
parent 4b119e21
...@@ -2132,8 +2132,6 @@ int ocfs2_super_lock(struct ocfs2_super *osb, ...@@ -2132,8 +2132,6 @@ int ocfs2_super_lock(struct ocfs2_super *osb,
int status = 0; int status = 0;
int level = ex ? LKM_EXMODE : LKM_PRMODE; int level = ex ? LKM_EXMODE : LKM_PRMODE;
struct ocfs2_lock_res *lockres = &osb->osb_super_lockres; struct ocfs2_lock_res *lockres = &osb->osb_super_lockres;
struct buffer_head *bh;
struct ocfs2_slot_info *si = osb->slot_info;
mlog_entry_void(); mlog_entry_void();
...@@ -2159,11 +2157,7 @@ int ocfs2_super_lock(struct ocfs2_super *osb, ...@@ -2159,11 +2157,7 @@ int ocfs2_super_lock(struct ocfs2_super *osb,
goto bail; goto bail;
} }
if (status) { if (status) {
bh = si->si_bh; status = ocfs2_refresh_slot_info(osb);
status = ocfs2_read_block(osb, bh->b_blocknr, &bh, 0,
si->si_inode);
if (status == 0)
ocfs2_update_slot_info(si);
ocfs2_complete_lock_res_refresh(lockres, status); ocfs2_complete_lock_res_refresh(lockres, status);
......
...@@ -1123,8 +1123,7 @@ static int ocfs2_recover_node(struct ocfs2_super *osb, ...@@ -1123,8 +1123,7 @@ static int ocfs2_recover_node(struct ocfs2_super *osb,
/* Likewise, this would be a strange but ultimately not so /* Likewise, this would be a strange but ultimately not so
* harmful place to get an error... */ * harmful place to get an error... */
ocfs2_clear_slot(si, slot_num); status = ocfs2_clear_slot(osb, slot_num);
status = ocfs2_update_disk_slots(osb, si);
if (status < 0) if (status < 0)
mlog_errno(status); mlog_errno(status);
......
...@@ -49,7 +49,7 @@ static void __ocfs2_fill_slot(struct ocfs2_slot_info *si, ...@@ -49,7 +49,7 @@ static void __ocfs2_fill_slot(struct ocfs2_slot_info *si,
s16 node_num); s16 node_num);
/* post the slot information on disk into our slot_info struct. */ /* post the slot information on disk into our slot_info struct. */
void ocfs2_update_slot_info(struct ocfs2_slot_info *si) static void ocfs2_update_slot_info(struct ocfs2_slot_info *si)
{ {
int i; int i;
__le16 *disk_info; __le16 *disk_info;
...@@ -65,9 +65,26 @@ void ocfs2_update_slot_info(struct ocfs2_slot_info *si) ...@@ -65,9 +65,26 @@ void ocfs2_update_slot_info(struct ocfs2_slot_info *si)
spin_unlock(&si->si_lock); spin_unlock(&si->si_lock);
} }
int ocfs2_refresh_slot_info(struct ocfs2_super *osb)
{
int ret;
struct ocfs2_slot_info *si = osb->slot_info;
struct buffer_head *bh;
if (si == NULL)
return 0;
bh = si->si_bh;
ret = ocfs2_read_block(osb, bh->b_blocknr, &bh, 0, si->si_inode);
if (ret == 0)
ocfs2_update_slot_info(si);
return ret;
}
/* post the our slot info stuff into it's destination bh and write it /* post the our slot info stuff into it's destination bh and write it
* out. */ * out. */
int ocfs2_update_disk_slots(struct ocfs2_super *osb, static int ocfs2_update_disk_slots(struct ocfs2_super *osb,
struct ocfs2_slot_info *si) struct ocfs2_slot_info *si)
{ {
int status, i; int status, i;
...@@ -135,6 +152,19 @@ s16 ocfs2_node_num_to_slot(struct ocfs2_slot_info *si, ...@@ -135,6 +152,19 @@ s16 ocfs2_node_num_to_slot(struct ocfs2_slot_info *si,
return ret; return ret;
} }
static void __ocfs2_free_slot_info(struct ocfs2_slot_info *si)
{
if (si == NULL)
return;
if (si->si_inode)
iput(si->si_inode);
if (si->si_bh)
brelse(si->si_bh);
kfree(si);
}
static void __ocfs2_fill_slot(struct ocfs2_slot_info *si, static void __ocfs2_fill_slot(struct ocfs2_slot_info *si,
s16 slot_num, s16 slot_num,
s16 node_num) s16 node_num)
...@@ -147,12 +177,18 @@ static void __ocfs2_fill_slot(struct ocfs2_slot_info *si, ...@@ -147,12 +177,18 @@ static void __ocfs2_fill_slot(struct ocfs2_slot_info *si,
si->si_global_node_nums[slot_num] = node_num; si->si_global_node_nums[slot_num] = node_num;
} }
void ocfs2_clear_slot(struct ocfs2_slot_info *si, int ocfs2_clear_slot(struct ocfs2_super *osb, s16 slot_num)
s16 slot_num)
{ {
struct ocfs2_slot_info *si = osb->slot_info;
if (si == NULL)
return 0;
spin_lock(&si->si_lock); spin_lock(&si->si_lock);
__ocfs2_fill_slot(si, slot_num, OCFS2_INVALID_SLOT); __ocfs2_fill_slot(si, slot_num, OCFS2_INVALID_SLOT);
spin_unlock(&si->si_lock); spin_unlock(&si->si_lock);
return ocfs2_update_disk_slots(osb, osb->slot_info);
} }
int ocfs2_init_slot_info(struct ocfs2_super *osb) int ocfs2_init_slot_info(struct ocfs2_super *osb)
...@@ -202,18 +238,17 @@ int ocfs2_init_slot_info(struct ocfs2_super *osb) ...@@ -202,18 +238,17 @@ int ocfs2_init_slot_info(struct ocfs2_super *osb)
osb->slot_info = si; osb->slot_info = si;
bail: bail:
if (status < 0 && si) if (status < 0 && si)
ocfs2_free_slot_info(si); __ocfs2_free_slot_info(si);
return status; return status;
} }
void ocfs2_free_slot_info(struct ocfs2_slot_info *si) void ocfs2_free_slot_info(struct ocfs2_super *osb)
{ {
if (si->si_inode) struct ocfs2_slot_info *si = osb->slot_info;
iput(si->si_inode);
if (si->si_bh) osb->slot_info = NULL;
brelse(si->si_bh); __ocfs2_free_slot_info(si);
kfree(si);
} }
int ocfs2_find_slot(struct ocfs2_super *osb) int ocfs2_find_slot(struct ocfs2_super *osb)
...@@ -285,7 +320,6 @@ void ocfs2_put_slot(struct ocfs2_super *osb) ...@@ -285,7 +320,6 @@ void ocfs2_put_slot(struct ocfs2_super *osb)
} }
bail: bail:
osb->slot_info = NULL; ocfs2_free_slot_info(osb);
ocfs2_free_slot_info(si);
} }
...@@ -38,19 +38,16 @@ struct ocfs2_slot_info { ...@@ -38,19 +38,16 @@ struct ocfs2_slot_info {
}; };
int ocfs2_init_slot_info(struct ocfs2_super *osb); int ocfs2_init_slot_info(struct ocfs2_super *osb);
void ocfs2_free_slot_info(struct ocfs2_slot_info *si); void ocfs2_free_slot_info(struct ocfs2_super *osb);
int ocfs2_find_slot(struct ocfs2_super *osb); int ocfs2_find_slot(struct ocfs2_super *osb);
void ocfs2_put_slot(struct ocfs2_super *osb); void ocfs2_put_slot(struct ocfs2_super *osb);
void ocfs2_update_slot_info(struct ocfs2_slot_info *si); int ocfs2_refresh_slot_info(struct ocfs2_super *osb);
int ocfs2_update_disk_slots(struct ocfs2_super *osb,
struct ocfs2_slot_info *si);
s16 ocfs2_node_num_to_slot(struct ocfs2_slot_info *si, s16 ocfs2_node_num_to_slot(struct ocfs2_slot_info *si,
s16 global); s16 global);
void ocfs2_clear_slot(struct ocfs2_slot_info *si, int ocfs2_clear_slot(struct ocfs2_super *osb, s16 slot_num);
s16 slot_num);
static inline int ocfs2_is_empty_slot(struct ocfs2_slot_info *si, static inline int ocfs2_is_empty_slot(struct ocfs2_slot_info *si,
int slot_num) int slot_num)
......
...@@ -1724,8 +1724,7 @@ static void ocfs2_delete_osb(struct ocfs2_super *osb) ...@@ -1724,8 +1724,7 @@ static void ocfs2_delete_osb(struct ocfs2_super *osb)
/* This function assumes that the caller has the main osb resource */ /* This function assumes that the caller has the main osb resource */
if (osb->slot_info) ocfs2_free_slot_info(osb);
ocfs2_free_slot_info(osb->slot_info);
kfree(osb->osb_orphan_wipes); kfree(osb->osb_orphan_wipes);
/* FIXME /* FIXME
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment