aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/glock.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/gfs2/glock.c')
-rw-r--r--fs/gfs2/glock.c42
1 files changed, 27 insertions, 15 deletions
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index e6c2fd53cab2..992c5c0cb504 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -55,8 +55,6 @@ struct gfs2_glock_iter {
55 55
56typedef void (*glock_examiner) (struct gfs2_glock * gl); 56typedef void (*glock_examiner) (struct gfs2_glock * gl);
57 57
58static int __dump_glock(struct seq_file *seq, const struct gfs2_glock *gl);
59#define GLOCK_BUG_ON(gl,x) do { if (unlikely(x)) { __dump_glock(NULL, gl); BUG(); } } while(0)
60static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh, unsigned int target); 58static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh, unsigned int target);
61 59
62static struct dentry *gfs2_root; 60static struct dentry *gfs2_root;
@@ -107,10 +105,12 @@ static void gfs2_glock_dealloc(struct rcu_head *rcu)
107{ 105{
108 struct gfs2_glock *gl = container_of(rcu, struct gfs2_glock, gl_rcu); 106 struct gfs2_glock *gl = container_of(rcu, struct gfs2_glock, gl_rcu);
109 107
110 if (gl->gl_ops->go_flags & GLOF_ASPACE) 108 if (gl->gl_ops->go_flags & GLOF_ASPACE) {
111 kmem_cache_free(gfs2_glock_aspace_cachep, gl); 109 kmem_cache_free(gfs2_glock_aspace_cachep, gl);
112 else 110 } else {
111 kfree(gl->gl_lksb.sb_lvbptr);
113 kmem_cache_free(gfs2_glock_cachep, gl); 112 kmem_cache_free(gfs2_glock_cachep, gl);
113 }
114} 114}
115 115
116void gfs2_glock_free(struct gfs2_glock *gl) 116void gfs2_glock_free(struct gfs2_glock *gl)
@@ -537,8 +537,8 @@ __acquires(&gl->gl_spin)
537 (lck_flags & (LM_FLAG_TRY|LM_FLAG_TRY_1CB))) 537 (lck_flags & (LM_FLAG_TRY|LM_FLAG_TRY_1CB)))
538 clear_bit(GLF_BLOCKING, &gl->gl_flags); 538 clear_bit(GLF_BLOCKING, &gl->gl_flags);
539 spin_unlock(&gl->gl_spin); 539 spin_unlock(&gl->gl_spin);
540 if (glops->go_xmote_th) 540 if (glops->go_sync)
541 glops->go_xmote_th(gl); 541 glops->go_sync(gl);
542 if (test_bit(GLF_INVALIDATE_IN_PROGRESS, &gl->gl_flags)) 542 if (test_bit(GLF_INVALIDATE_IN_PROGRESS, &gl->gl_flags))
543 glops->go_inval(gl, target == LM_ST_DEFERRED ? 0 : DIO_METADATA); 543 glops->go_inval(gl, target == LM_ST_DEFERRED ? 0 : DIO_METADATA);
544 clear_bit(GLF_INVALIDATE_IN_PROGRESS, &gl->gl_flags); 544 clear_bit(GLF_INVALIDATE_IN_PROGRESS, &gl->gl_flags);
@@ -547,7 +547,10 @@ __acquires(&gl->gl_spin)
547 if (sdp->sd_lockstruct.ls_ops->lm_lock) { 547 if (sdp->sd_lockstruct.ls_ops->lm_lock) {
548 /* lock_dlm */ 548 /* lock_dlm */
549 ret = sdp->sd_lockstruct.ls_ops->lm_lock(gl, target, lck_flags); 549 ret = sdp->sd_lockstruct.ls_ops->lm_lock(gl, target, lck_flags);
550 GLOCK_BUG_ON(gl, ret); 550 if (ret) {
551 printk(KERN_ERR "GFS2: lm_lock ret %d\n", ret);
552 GLOCK_BUG_ON(gl, 1);
553 }
551 } else { /* lock_nolock */ 554 } else { /* lock_nolock */
552 finish_xmote(gl, target); 555 finish_xmote(gl, target);
553 if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0) 556 if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
@@ -736,6 +739,16 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
736 if (!gl) 739 if (!gl)
737 return -ENOMEM; 740 return -ENOMEM;
738 741
742 memset(&gl->gl_lksb, 0, sizeof(struct dlm_lksb));
743
744 if (glops->go_flags & GLOF_LVB) {
745 gl->gl_lksb.sb_lvbptr = kzalloc(GFS2_MIN_LVB_SIZE, GFP_KERNEL);
746 if (!gl->gl_lksb.sb_lvbptr) {
747 kmem_cache_free(cachep, gl);
748 return -ENOMEM;
749 }
750 }
751
739 atomic_inc(&sdp->sd_glock_disposal); 752 atomic_inc(&sdp->sd_glock_disposal);
740 gl->gl_sbd = sdp; 753 gl->gl_sbd = sdp;
741 gl->gl_flags = 0; 754 gl->gl_flags = 0;
@@ -753,9 +766,6 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
753 preempt_enable(); 766 preempt_enable();
754 gl->gl_stats.stats[GFS2_LKS_DCOUNT] = 0; 767 gl->gl_stats.stats[GFS2_LKS_DCOUNT] = 0;
755 gl->gl_stats.stats[GFS2_LKS_QCOUNT] = 0; 768 gl->gl_stats.stats[GFS2_LKS_QCOUNT] = 0;
756 memset(&gl->gl_lksb, 0, sizeof(struct dlm_lksb));
757 memset(gl->gl_lvb, 0, 32 * sizeof(char));
758 gl->gl_lksb.sb_lvbptr = gl->gl_lvb;
759 gl->gl_tchange = jiffies; 769 gl->gl_tchange = jiffies;
760 gl->gl_object = NULL; 770 gl->gl_object = NULL;
761 gl->gl_hold_time = GL_GLOCK_DFT_HOLD; 771 gl->gl_hold_time = GL_GLOCK_DFT_HOLD;
@@ -768,7 +778,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
768 mapping->host = s->s_bdev->bd_inode; 778 mapping->host = s->s_bdev->bd_inode;
769 mapping->flags = 0; 779 mapping->flags = 0;
770 mapping_set_gfp_mask(mapping, GFP_NOFS); 780 mapping_set_gfp_mask(mapping, GFP_NOFS);
771 mapping->assoc_mapping = NULL; 781 mapping->private_data = NULL;
772 mapping->backing_dev_info = s->s_bdi; 782 mapping->backing_dev_info = s->s_bdi;
773 mapping->writeback_index = 0; 783 mapping->writeback_index = 0;
774 } 784 }
@@ -777,6 +787,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
777 tmp = search_bucket(hash, sdp, &name); 787 tmp = search_bucket(hash, sdp, &name);
778 if (tmp) { 788 if (tmp) {
779 spin_unlock_bucket(hash); 789 spin_unlock_bucket(hash);
790 kfree(gl->gl_lksb.sb_lvbptr);
780 kmem_cache_free(cachep, gl); 791 kmem_cache_free(cachep, gl);
781 atomic_dec(&sdp->sd_glock_disposal); 792 atomic_dec(&sdp->sd_glock_disposal);
782 gl = tmp; 793 gl = tmp;
@@ -1013,7 +1024,7 @@ trap_recursive:
1013 printk(KERN_ERR "pid: %d\n", pid_nr(gh->gh_owner_pid)); 1024 printk(KERN_ERR "pid: %d\n", pid_nr(gh->gh_owner_pid));
1014 printk(KERN_ERR "lock type: %d req lock state : %d\n", 1025 printk(KERN_ERR "lock type: %d req lock state : %d\n",
1015 gh->gh_gl->gl_name.ln_type, gh->gh_state); 1026 gh->gh_gl->gl_name.ln_type, gh->gh_state);
1016 __dump_glock(NULL, gl); 1027 gfs2_dump_glock(NULL, gl);
1017 BUG(); 1028 BUG();
1018} 1029}
1019 1030
@@ -1508,7 +1519,7 @@ static int dump_glock(struct seq_file *seq, struct gfs2_glock *gl)
1508{ 1519{
1509 int ret; 1520 int ret;
1510 spin_lock(&gl->gl_spin); 1521 spin_lock(&gl->gl_spin);
1511 ret = __dump_glock(seq, gl); 1522 ret = gfs2_dump_glock(seq, gl);
1512 spin_unlock(&gl->gl_spin); 1523 spin_unlock(&gl->gl_spin);
1513 return ret; 1524 return ret;
1514} 1525}
@@ -1528,6 +1539,7 @@ static void dump_glock_func(struct gfs2_glock *gl)
1528 1539
1529void gfs2_gl_hash_clear(struct gfs2_sbd *sdp) 1540void gfs2_gl_hash_clear(struct gfs2_sbd *sdp)
1530{ 1541{
1542 set_bit(SDF_SKIP_DLM_UNLOCK, &sdp->sd_flags);
1531 glock_hash_walk(clear_glock, sdp); 1543 glock_hash_walk(clear_glock, sdp);
1532 flush_workqueue(glock_workqueue); 1544 flush_workqueue(glock_workqueue);
1533 wait_event(sdp->sd_glock_wait, atomic_read(&sdp->sd_glock_disposal) == 0); 1545 wait_event(sdp->sd_glock_wait, atomic_read(&sdp->sd_glock_disposal) == 0);
@@ -1655,7 +1667,7 @@ static const char *gflags2str(char *buf, const struct gfs2_glock *gl)
1655} 1667}
1656 1668
1657/** 1669/**
1658 * __dump_glock - print information about a glock 1670 * gfs2_dump_glock - print information about a glock
1659 * @seq: The seq_file struct 1671 * @seq: The seq_file struct
1660 * @gl: the glock 1672 * @gl: the glock
1661 * 1673 *
@@ -1672,7 +1684,7 @@ static const char *gflags2str(char *buf, const struct gfs2_glock *gl)
1672 * Returns: 0 on success, -ENOBUFS when we run out of space 1684 * Returns: 0 on success, -ENOBUFS when we run out of space
1673 */ 1685 */
1674 1686
1675static int __dump_glock(struct seq_file *seq, const struct gfs2_glock *gl) 1687int gfs2_dump_glock(struct seq_file *seq, const struct gfs2_glock *gl)
1676{ 1688{
1677 const struct gfs2_glock_operations *glops = gl->gl_ops; 1689 const struct gfs2_glock_operations *glops = gl->gl_ops;
1678 unsigned long long dtime; 1690 unsigned long long dtime;