gfs2: eliminate GIF_ORDERED in favor of list_empty
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 gfs2: eliminate GIF_ORDERED in favor of list_empty
Hi,
In several places, we used the GIF_ORDERED inode flag to determine if an inode was on the ordered writes list. However, since we always held the sd_ordered_lock spin_lock during the manipulation, we can just as easily check list_empty(&ip->i_ordered) instead. This allows us to keep more than one ordered writes list to make journal writing improvements.
This patch eliminates GIF_ORDERED in favor of checking list_empty.
Signed-off-by Bob Peterson <[email protected]>
--- fs/gfs2/incore.h | 1 - fs/gfs2/log.c | 15 +++++++++------ fs/gfs2/log.h | 4 ++-- fs/gfs2/main.c | 1 + 4 files changed, 12 insertions(+), 9 deletions(-)
fs/gfs2/incore.h +0 -1
@@ -402,7 +402,6 @@ enum {GIF_QD_LOCKED =1 ,GIF_ALLOC_FAILED =2 ,GIF_SW_PAGED =3 , -GIF_ORDERED =4 ,GIF_FREE_VFS_INODE =5 ,GIF_GLOP_PENDING =6 , GIF_DEFERRED_DELETE = 7,
fs/gfs2/log.c +9 -6
@@ -625,6 +625,12 @@ static int ip_cmp(void *priv, struct list_head *a, struct list_head *b)return 0 ; } +static void __ordered_del_inode (struct gfs2_inode *ip) +{ +if (!list_empty (&ip->i_ordered)) +list_del_init (&ip->i_ordered); +} +static void gfs2_ordered_write (struct gfs2_sbd *sdp) {struct gfs2_inode *ip;
@@ -635,8 +641,7 @@ static void gfs2_ordered_write(struct gfs2_sbd *sdp)while (!list_empty (&sdp->sd_log_ordered)) { ip = list_first_entry(&sdp->sd_log_ordered, struct gfs2_inode, i_ordered);if (ip->i_inode.i_mapping->nrpages ==0 ) { -test_and_clear_bit (GIF_ORDERED , &ip->i_flags); -list_del (&ip->i_ordered); +__ordered_del_inode (ip);continue ; }list_move (&ip->i_ordered, &written);
@@ -655,8 +660,7 @@ static void gfs2_ordered_wait(struct gfs2_sbd *sdp)spin_lock (&sdp->sd_ordered_lock);while (!list_empty (&sdp->sd_log_ordered)) { ip = list_first_entry(&sdp->sd_log_ordered, struct gfs2_inode, i_ordered); -list_del (&ip->i_ordered); -WARN_ON (!test_and_clear_bit (GIF_ORDERED , &ip->i_flags)); +__ordered_del_inode (ip);if (ip->i_inode.i_mapping->nrpages ==0 )continue ;spin_unlock (&sdp->sd_ordered_lock);
@@ -671,8 +675,7 @@ void gfs2_ordered_del_inode(struct gfs2_inode *ip)struct gfs2_sbd *sdp =GFS2_SB (&ip->i_inode);spin_lock (&sdp->sd_ordered_lock); -if (test_and_clear_bit (GIF_ORDERED , &ip->i_flags)) -list_del (&ip->i_ordered); +__ordered_del_inode (ip);spin_unlock (&sdp->sd_ordered_lock); }
fs/gfs2/log.h +2 -2
@@ -53,9 +53,9 @@ static inline void gfs2_ordered_add_inode(struct gfs2_inode *ip)if (gfs2_is_jdata (ip) || !gfs2_is_ordered (sdp))return ; -if (!test_bit (GIF_ORDERED , &ip->i_flags)) { +if (list_empty (&ip->i_ordered)) {spin_lock (&sdp->sd_ordered_lock); -if (!test_and_set_bit (GIF_ORDERED , &ip->i_flags)) +if (list_empty (&ip->i_ordered))list_add (&ip->i_ordered, &sdp->sd_log_ordered);spin_unlock (&sdp->sd_ordered_lock); }
fs/gfs2/main.c +1 -0
@@ -39,6 +39,7 @@ static void gfs2_init_inode_once(void *foo)atomic_set (&ip->i_sizehint,0 );init_rwsem (&ip->i_rw_mutex);INIT_LIST_HEAD (&ip->i_trunc_list); +INIT_LIST_HEAD (&ip->i_ordered); ip->i_qadata =NULL ;gfs2_holder_mark_uninitialized (&ip->i_rgd_gh);memset (&ip->i_res,0 ,sizeof (ip->i_res));