aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/dlmglue.c
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2008-01-29 20:37:32 -0500
committerMark Fasheh <mfasheh@suse.com>2008-04-18 11:56:03 -0400
commit24ef1815e5e13e50196eb1ab8ddc0d783443bdf8 (patch)
tree4c44e87b1a80d4745416c9973258c40db8433829 /fs/ocfs2/dlmglue.c
parent386a2ef8576e966076c293f6496b9e3d7e3d9035 (diff)
ocfs2: Separate out dlm lock functions.
This is the first in a series of patches to isolate ocfs2 from the underlying cluster stack. Here we wrap the dlm locking functions with ocfs2-specific calls. Because ocfs2 always uses the same dlm lock status callbacks, we can eliminate the callbacks from the filesystem visible functions. Signed-off-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2/dlmglue.c')
-rw-r--r--fs/ocfs2/dlmglue.c110
1 files changed, 61 insertions, 49 deletions
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 15a5167e0513..aea3bef19171 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -53,6 +53,7 @@
53#include "heartbeat.h" 53#include "heartbeat.h"
54#include "inode.h" 54#include "inode.h"
55#include "journal.h" 55#include "journal.h"
56#include "stackglue.h"
56#include "slot_map.h" 57#include "slot_map.h"
57#include "super.h" 58#include "super.h"
58#include "uptodate.h" 59#include "uptodate.h"
@@ -888,22 +889,21 @@ static int ocfs2_lock_create(struct ocfs2_super *osb,
888 lockres_or_flags(lockres, OCFS2_LOCK_BUSY); 889 lockres_or_flags(lockres, OCFS2_LOCK_BUSY);
889 spin_unlock_irqrestore(&lockres->l_lock, flags); 890 spin_unlock_irqrestore(&lockres->l_lock, flags);
890 891
891 status = dlmlock(osb->dlm, 892 status = ocfs2_dlm_lock(osb->dlm,
892 level, 893 level,
893 &lockres->l_lksb, 894 &lockres->l_lksb,
894 dlm_flags, 895 dlm_flags,
895 lockres->l_name, 896 lockres->l_name,
896 OCFS2_LOCK_ID_MAX_LEN - 1, 897 OCFS2_LOCK_ID_MAX_LEN - 1,
897 ocfs2_locking_ast, 898 lockres);
898 lockres,
899 ocfs2_blocking_ast);
900 if (status != DLM_NORMAL) { 899 if (status != DLM_NORMAL) {
901 ocfs2_log_dlm_error("dlmlock", status, lockres); 900 ocfs2_log_dlm_error("ocfs2_dlm_lock", status, lockres);
902 ret = -EINVAL; 901 ret = -EINVAL;
903 ocfs2_recover_from_dlm_error(lockres, 1); 902 ocfs2_recover_from_dlm_error(lockres, 1);
904 } 903 }
905 904
906 mlog(0, "lock %s, successfull return from dlmlock\n", lockres->l_name); 905 mlog(0, "lock %s, successfull return from ocfs2_dlm_lock\n",
906 lockres->l_name);
907 907
908bail: 908bail:
909 mlog_exit(ret); 909 mlog_exit(ret);
@@ -1091,29 +1091,27 @@ again:
1091 lockres->l_name, lockres->l_level, level); 1091 lockres->l_name, lockres->l_level, level);
1092 1092
1093 /* call dlm_lock to upgrade lock now */ 1093 /* call dlm_lock to upgrade lock now */
1094 status = dlmlock(osb->dlm, 1094 status = ocfs2_dlm_lock(osb->dlm,
1095 level, 1095 level,
1096 &lockres->l_lksb, 1096 &lockres->l_lksb,
1097 lkm_flags, 1097 lkm_flags,
1098 lockres->l_name, 1098 lockres->l_name,
1099 OCFS2_LOCK_ID_MAX_LEN - 1, 1099 OCFS2_LOCK_ID_MAX_LEN - 1,
1100 ocfs2_locking_ast, 1100 lockres);
1101 lockres,
1102 ocfs2_blocking_ast);
1103 if (status != DLM_NORMAL) { 1101 if (status != DLM_NORMAL) {
1104 if ((lkm_flags & LKM_NOQUEUE) && 1102 if ((lkm_flags & LKM_NOQUEUE) &&
1105 (status == DLM_NOTQUEUED)) 1103 (status == DLM_NOTQUEUED))
1106 ret = -EAGAIN; 1104 ret = -EAGAIN;
1107 else { 1105 else {
1108 ocfs2_log_dlm_error("dlmlock", status, 1106 ocfs2_log_dlm_error("ocfs2_dlm_lock",
1109 lockres); 1107 status, lockres);
1110 ret = -EINVAL; 1108 ret = -EINVAL;
1111 } 1109 }
1112 ocfs2_recover_from_dlm_error(lockres, 1); 1110 ocfs2_recover_from_dlm_error(lockres, 1);
1113 goto out; 1111 goto out;
1114 } 1112 }
1115 1113
1116 mlog(0, "lock %s, successfull return from dlmlock\n", 1114 mlog(0, "lock %s, successfull return from ocfs2_dlm_lock\n",
1117 lockres->l_name); 1115 lockres->l_name);
1118 1116
1119 /* At this point we've gone inside the dlm and need to 1117 /* At this point we've gone inside the dlm and need to
@@ -1503,14 +1501,14 @@ int ocfs2_file_lock(struct file *file, int ex, int trylock)
1503 lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_BUSY, 0); 1501 lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_BUSY, 0);
1504 spin_unlock_irqrestore(&lockres->l_lock, flags); 1502 spin_unlock_irqrestore(&lockres->l_lock, flags);
1505 1503
1506 ret = dlmlock(osb->dlm, level, &lockres->l_lksb, lkm_flags, 1504 ret = ocfs2_dlm_lock(osb->dlm, level, &lockres->l_lksb, lkm_flags,
1507 lockres->l_name, OCFS2_LOCK_ID_MAX_LEN - 1, 1505 lockres->l_name, OCFS2_LOCK_ID_MAX_LEN - 1,
1508 ocfs2_locking_ast, lockres, ocfs2_blocking_ast); 1506 lockres);
1509 if (ret != DLM_NORMAL) { 1507 if (ret != DLM_NORMAL) {
1510 if (trylock && ret == DLM_NOTQUEUED) 1508 if (trylock && ret == DLM_NOTQUEUED)
1511 ret = -EAGAIN; 1509 ret = -EAGAIN;
1512 else { 1510 else {
1513 ocfs2_log_dlm_error("dlmlock", ret, lockres); 1511 ocfs2_log_dlm_error("ocfs2_dlm_lock", ret, lockres);
1514 ret = -EINVAL; 1512 ret = -EINVAL;
1515 } 1513 }
1516 1514
@@ -2699,15 +2697,15 @@ static int ocfs2_drop_lock(struct ocfs2_super *osb,
2699 2697
2700 mlog(0, "lock %s\n", lockres->l_name); 2698 mlog(0, "lock %s\n", lockres->l_name);
2701 2699
2702 status = dlmunlock(osb->dlm, &lockres->l_lksb, lkm_flags, 2700 status = ocfs2_dlm_unlock(osb->dlm, &lockres->l_lksb, lkm_flags,
2703 ocfs2_unlock_ast, lockres); 2701 lockres);
2704 if (status != DLM_NORMAL) { 2702 if (status != DLM_NORMAL) {
2705 ocfs2_log_dlm_error("dlmunlock", status, lockres); 2703 ocfs2_log_dlm_error("ocfs2_dlm_unlock", status, lockres);
2706 mlog(ML_ERROR, "lockres flags: %lu\n", lockres->l_flags); 2704 mlog(ML_ERROR, "lockres flags: %lu\n", lockres->l_flags);
2707 dlm_print_one_lock(lockres->l_lksb.lockid); 2705 dlm_print_one_lock(lockres->l_lksb.lockid);
2708 BUG(); 2706 BUG();
2709 } 2707 }
2710 mlog(0, "lock %s, successfull return from dlmunlock\n", 2708 mlog(0, "lock %s, successfull return from ocfs2_dlm_unlock\n",
2711 lockres->l_name); 2709 lockres->l_name);
2712 2710
2713 ocfs2_wait_on_busy_lock(lockres); 2711 ocfs2_wait_on_busy_lock(lockres);
@@ -2832,17 +2830,15 @@ static int ocfs2_downconvert_lock(struct ocfs2_super *osb,
2832 if (lvb) 2830 if (lvb)
2833 dlm_flags |= LKM_VALBLK; 2831 dlm_flags |= LKM_VALBLK;
2834 2832
2835 status = dlmlock(osb->dlm, 2833 status = ocfs2_dlm_lock(osb->dlm,
2836 new_level, 2834 new_level,
2837 &lockres->l_lksb, 2835 &lockres->l_lksb,
2838 dlm_flags, 2836 dlm_flags,
2839 lockres->l_name, 2837 lockres->l_name,
2840 OCFS2_LOCK_ID_MAX_LEN - 1, 2838 OCFS2_LOCK_ID_MAX_LEN - 1,
2841 ocfs2_locking_ast, 2839 lockres);
2842 lockres,
2843 ocfs2_blocking_ast);
2844 if (status != DLM_NORMAL) { 2840 if (status != DLM_NORMAL) {
2845 ocfs2_log_dlm_error("dlmlock", status, lockres); 2841 ocfs2_log_dlm_error("ocfs2_dlm_lock", status, lockres);
2846 ret = -EINVAL; 2842 ret = -EINVAL;
2847 ocfs2_recover_from_dlm_error(lockres, 1); 2843 ocfs2_recover_from_dlm_error(lockres, 1);
2848 goto bail; 2844 goto bail;
@@ -2854,7 +2850,7 @@ bail:
2854 return ret; 2850 return ret;
2855} 2851}
2856 2852
2857/* returns 1 when the caller should unlock and call dlmunlock */ 2853/* returns 1 when the caller should unlock and call ocfs2_dlm_unlock */
2858static int ocfs2_prepare_cancel_convert(struct ocfs2_super *osb, 2854static int ocfs2_prepare_cancel_convert(struct ocfs2_super *osb,
2859 struct ocfs2_lock_res *lockres) 2855 struct ocfs2_lock_res *lockres)
2860{ 2856{
@@ -2896,18 +2892,17 @@ static int ocfs2_cancel_convert(struct ocfs2_super *osb,
2896 mlog(0, "lock %s\n", lockres->l_name); 2892 mlog(0, "lock %s\n", lockres->l_name);
2897 2893
2898 ret = 0; 2894 ret = 0;
2899 status = dlmunlock(osb->dlm, 2895 status = ocfs2_dlm_unlock(osb->dlm,
2900 &lockres->l_lksb, 2896 &lockres->l_lksb,
2901 LKM_CANCEL, 2897 LKM_CANCEL,
2902 ocfs2_unlock_ast, 2898 lockres);
2903 lockres);
2904 if (status != DLM_NORMAL) { 2899 if (status != DLM_NORMAL) {
2905 ocfs2_log_dlm_error("dlmunlock", status, lockres); 2900 ocfs2_log_dlm_error("ocfs2_dlm_unlock", status, lockres);
2906 ret = -EINVAL; 2901 ret = -EINVAL;
2907 ocfs2_recover_from_dlm_error(lockres, 0); 2902 ocfs2_recover_from_dlm_error(lockres, 0);
2908 } 2903 }
2909 2904
2910 mlog(0, "lock %s return from dlmunlock\n", lockres->l_name); 2905 mlog(0, "lock %s return from ocfs2_dlm_unlock\n", lockres->l_name);
2911 2906
2912 mlog_exit(ret); 2907 mlog_exit(ret);
2913 return ret; 2908 return ret;
@@ -3211,6 +3206,23 @@ static int ocfs2_dentry_convert_worker(struct ocfs2_lock_res *lockres,
3211 return UNBLOCK_CONTINUE_POST; 3206 return UNBLOCK_CONTINUE_POST;
3212} 3207}
3213 3208
3209static struct ocfs2_locking_protocol lproto = {
3210 .lp_lock_ast = ocfs2_locking_ast,
3211 .lp_blocking_ast = ocfs2_blocking_ast,
3212 .lp_unlock_ast = ocfs2_unlock_ast,
3213};
3214
3215/* This interface isn't the final one, hence the less-than-perfect names */
3216void dlmglue_init_stack(void)
3217{
3218 o2cb_get_stack(&lproto);
3219}
3220
3221void dlmglue_exit_stack(void)
3222{
3223 o2cb_put_stack();
3224}
3225
3214static void ocfs2_process_blocked_lock(struct ocfs2_super *osb, 3226static void ocfs2_process_blocked_lock(struct ocfs2_super *osb,
3215 struct ocfs2_lock_res *lockres) 3227 struct ocfs2_lock_res *lockres)
3216{ 3228{