Get rid of sd_statfs_mutex
PATCH 4/10 Get rid of sd_statfs_mutex
Hi,
This patch eliminates the sd_statfs_mutex variable when doing updates to local statfs change files. The new code uses the sd_statfs_spin spin_lock that's already taken to get the same effect.
Regards,
Bob Peterson
Red Hat GFS
--
.../fs/gfs2/incore.h | 1 - .../fs/gfs2/ops_fstype.c | 1 - .../fs/gfs2/super.c | 10 ++-------- 3 files changed, 2 insertions(+), 10 deletions(-)
gfs2-2.6.git.patch4/fs/gfs2/incore.h renamed from gfs2-2.6.git.patch3/fs/gfs2/incore.h +0 -1
@@ -527,7 +527,6 @@ struct gfs2_sbd {/* StatFS stuff */ spinlock_t sd_statfs_spin; -struct mutex sd_statfs_mutex;struct gfs2_statfs_change_host sd_statfs_master;struct gfs2_statfs_change_host sd_statfs_local;unsigned long sd_statfs_sync_time;
gfs2-2.6.git.patch4/fs/gfs2/ops_fstype.c renamed from gfs2-2.6.git.patch3/fs/gfs2/ops_fstype.c +0 -1
@@ -60,7 +60,6 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)mutex_init (&sdp->sd_inum_mutex);spin_lock_init (&sdp->sd_statfs_spin); -mutex_init (&sdp->sd_statfs_mutex);spin_lock_init (&sdp->sd_rindex_spin);mutex_init (&sdp->sd_rindex_mutex);
gfs2-2.6.git.patch4/fs/gfs2/super.c renamed from gfs2-2.6.git.patch3/fs/gfs2/super.c +2 -8
@@ -686,11 +686,8 @@ void gfs2_statfs_change(struct gfs2_sbd *sdp, s64 total, s64 free,if (error)return ; -mutex_lock (&sdp->sd_statfs_mutex); -gfs2_trans_add_bh (l_ip->i_gl, l_bh,1 ); -mutex_unlock (&sdp->sd_statfs_mutex); -spin_lock (&sdp->sd_statfs_spin); +gfs2_trans_add_bh (l_ip->i_gl, l_bh,1 ); l_sc->sc_total += total; l_sc->sc_free += free; l_sc->sc_dinodes += dinodes;
@@ -736,11 +733,8 @@ int gfs2_statfs_sync(struct gfs2_sbd *sdp)if (error) goto out_bh2; -mutex_lock (&sdp->sd_statfs_mutex); -gfs2_trans_add_bh (l_ip->i_gl, l_bh,1 ); -mutex_unlock (&sdp->sd_statfs_mutex); -spin_lock (&sdp->sd_statfs_spin); +gfs2_trans_add_bh (l_ip->i_gl, l_bh,1 ); m_sc->sc_total += l_sc->sc_total; m_sc->sc_free += l_sc->sc_free; m_sc->sc_dinodes += l_sc->sc_dinodes;
PATCH 4/10 Get rid of sd_statfs_mutex
Hi,
Quoted 48 lines · Bob Peterson
Hi,
This patch eliminates the
sd_statfs_mutexvariable when doing updates to local statfs change files. The new code uses thesd_statfs_spinspin_lockthat's already taken to get the same effect.Regards,
Bob Peterson
Red Hat GFSSigned-off-by Bob Peterson <[email protected]>--
.../fs/gfs2/incore.h | 1 - .../fs/gfs2/ops_fstype.c | 1 - .../fs/gfs2/super.c | 10 ++-------- 3 files changed, 2 insertions(+), 10 deletions(-)gfs2-2.6.git.patch4/fs/gfs2/incore.h renamed from gfs2-2.6.git.patch3/fs/gfs2/incore.h +0
-1@@ -527,7 +527,6 @@ struct gfs2_sbd {/* StatFS stuff */ spinlock_t sd_statfs_spin; -struct mutex sd_statfs_mutex;struct gfs2_statfs_change_host sd_statfs_master;struct gfs2_statfs_change_host sd_statfs_local;unsigned long sd_statfs_sync_time;gfs2-2.6.git.patch4/fs/gfs2/ops_fstype.c renamed from gfs2-2.6.git.patch3/fs/gfs2/ops_fstype.c +0
-1@@ -60,7 +60,6 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)mutex_init (&sdp->sd_inum_mutex);spin_lock_init (&sdp->sd_statfs_spin); -mutex_init (&sdp->sd_statfs_mutex);spin_lock_init (&sdp->sd_rindex_spin);mutex_init (&sdp->sd_rindex_mutex);gfs2-2.6.git.patch4/fs/gfs2/super.c renamed from gfs2-2.6.git.patch3/fs/gfs2/super.c +0
-0
gfs2-2.6.git.patch4/fs/gfs2/super.c void gfs2_statfs_change(struct gfs2_sbd *sdp, s64 total, s64 free, · line 690
Quoted 9 lines
gfs2-2.6.git.patch4/fs/gfs2/super.c renamed from gfs2-2.6.git.patch3/fs/gfs2/super.c +1
-4@@ -686,11 +686,8 @@ void gfs2_statfs_change(struct gfs2_sbd *sdp, s64 total, s64 free,if (error)return ; -mutex_lock (&sdp->sd_statfs_mutex); -gfs2_trans_add_bh (l_ip->i_gl, l_bh,1 ); -mutex_unlock (&sdp->sd_statfs_mutex); -spin_lock (&sdp->sd_statfs_spin); +gfs2_trans_add_bh (l_ip->i_gl, l_bh,1 );
You can't do gfs2_trans_add_bh under a spinlock, but there is no reason why you can't just reverse the order of these two statements to fix it,
Steve.
PATCH 4/10 Get rid of sd_statfs_mutex
Quoted 4 lines · Steven Whitehouse
You can't do
gfs2_trans_add_bhunder a spinlock, but there is no reason why you can't just reverse the order of these two statements to fix it,Steve.
Hi Steve,
If we reverse the two statements, the trans_add_bh is not protected at all, which I assume was the purpose of the mutex in the first place. I'm not sure this is buying us much anyway, so perhaps we should forget it.
Regards,
Bob Peterson
PATCH 4/10 Get rid of sd_statfs_mutex
Hi,
Quoted 8 lines · Bob Peterson
Quoted 4 lines · Steven Whitehouse
You can't do
gfs2_trans_add_bhunder a spinlock, but there is no reason why you can't just reverse the order of these two statements to fix it,Steve.
Hi Steve,
Quoted 10 lines
If we reverse the two statements, the
trans_add_bhis not protected at all, which I assume was the purpose of the mutex in the first place. I'm not sure this is buying us much anyway, so perhaps we should forget it.Regards,
Bob Peterson
I don't see why it needs to be "protected", I think that mutex is just a bug in that case unless you can prove otherwise... it seems to be doing nothing,
Steve.
PATCH 4/10 Get rid of sd_statfs_mutex
Quoted 5 lines · Steven Whitehouse
I don't see why it needs to be "protected", I think that mutex is just a bug in that case unless you can prove otherwise... it seems to be doing nothing,
Steve.
Hi,
In that case, here is my revision:
Regards,
Bob Peterson
--
fs/gfs2/super.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
fs/gfs2/super.c +4 -2
@@ -686,8 +686,9 @@ void gfs2_statfs_change(struct gfs2_sbdif (error)return ; -spin_lock (&sdp->sd_statfs_spin);gfs2_trans_add_bh (l_ip->i_gl, l_bh,1 ); + +spin_lock (&sdp->sd_statfs_spin); l_sc->sc_total += total; l_sc->sc_free += free; l_sc->sc_dinodes += dinodes;
@@ -733,8 +734,9 @@ int gfs2_statfs_sync(struct gfs2_sbd *sdif (error) goto out_bh2; -spin_lock (&sdp->sd_statfs_spin);gfs2_trans_add_bh (l_ip->i_gl, l_bh,1 ); + +spin_lock (&sdp->sd_statfs_spin); m_sc->sc_total += l_sc->sc_total; m_sc->sc_free += l_sc->sc_free; m_sc->sc_dinodes += l_sc->sc_dinodes;