aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorMark Fasheh <mark.fasheh@oracle.com>2006-09-13 00:34:35 -0400
committerMark Fasheh <mark.fasheh@oracle.com>2006-09-24 16:50:46 -0400
commite92d57df273a3a7e57688e1d4f5a894870d550d2 (patch)
tree9334beeeac74a2aad2a98a5dcf73e7dc2d57b65b /fs
parentf625c9793b6cc64aeb1b6387039d09019c214352 (diff)
ocfs2: combine inode and generic AST functions
There is extremely little difference between the two now. We can remove the callback from ocfs2_lock_res_ops as well. Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/ocfs2/dlmglue.c120
1 files changed, 10 insertions, 110 deletions
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index c1891787fb9d..7eb40a02c5af 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -67,16 +67,12 @@ struct ocfs2_mask_waiter {
67 unsigned long mw_goal; 67 unsigned long mw_goal;
68}; 68};
69 69
70static void ocfs2_inode_ast_func(void *opaque);
71static void ocfs2_inode_bast_func(void *opaque, 70static void ocfs2_inode_bast_func(void *opaque,
72 int level); 71 int level);
73static void ocfs2_dentry_ast_func(void *opaque);
74static void ocfs2_dentry_bast_func(void *opaque, 72static void ocfs2_dentry_bast_func(void *opaque,
75 int level); 73 int level);
76static void ocfs2_super_ast_func(void *opaque);
77static void ocfs2_super_bast_func(void *opaque, 74static void ocfs2_super_bast_func(void *opaque,
78 int level); 75 int level);
79static void ocfs2_rename_ast_func(void *opaque);
80static void ocfs2_rename_bast_func(void *opaque, 76static void ocfs2_rename_bast_func(void *opaque,
81 int level); 77 int level);
82 78
@@ -123,7 +119,6 @@ static void ocfs2_dentry_post_unlock(struct ocfs2_super *osb,
123 * These fine tune the behavior of the generic dlmglue locking infrastructure. 119 * These fine tune the behavior of the generic dlmglue locking infrastructure.
124 */ 120 */
125struct ocfs2_lock_res_ops { 121struct ocfs2_lock_res_ops {
126 void (*ast)(void *);
127 void (*bast)(void *, int); 122 void (*bast)(void *, int);
128 void (*unlock_ast)(void *, enum dlm_status); 123 void (*unlock_ast)(void *, enum dlm_status);
129 int (*unblock)(struct ocfs2_lock_res *, struct ocfs2_unblock_ctl *); 124 int (*unblock)(struct ocfs2_lock_res *, struct ocfs2_unblock_ctl *);
@@ -153,7 +148,6 @@ static int ocfs2_generic_unblock_lock(struct ocfs2_super *osb,
153 ocfs2_convert_worker_t *worker); 148 ocfs2_convert_worker_t *worker);
154 149
155static struct ocfs2_lock_res_ops ocfs2_inode_rw_lops = { 150static struct ocfs2_lock_res_ops ocfs2_inode_rw_lops = {
156 .ast = ocfs2_inode_ast_func,
157 .bast = ocfs2_inode_bast_func, 151 .bast = ocfs2_inode_bast_func,
158 .unlock_ast = ocfs2_unlock_ast_func, 152 .unlock_ast = ocfs2_unlock_ast_func,
159 .unblock = ocfs2_unblock_inode_lock, 153 .unblock = ocfs2_unblock_inode_lock,
@@ -161,7 +155,6 @@ static struct ocfs2_lock_res_ops ocfs2_inode_rw_lops = {
161}; 155};
162 156
163static struct ocfs2_lock_res_ops ocfs2_inode_meta_lops = { 157static struct ocfs2_lock_res_ops ocfs2_inode_meta_lops = {
164 .ast = ocfs2_inode_ast_func,
165 .bast = ocfs2_inode_bast_func, 158 .bast = ocfs2_inode_bast_func,
166 .unlock_ast = ocfs2_unlock_ast_func, 159 .unlock_ast = ocfs2_unlock_ast_func,
167 .unblock = ocfs2_unblock_meta, 160 .unblock = ocfs2_unblock_meta,
@@ -169,7 +162,6 @@ static struct ocfs2_lock_res_ops ocfs2_inode_meta_lops = {
169}; 162};
170 163
171static struct ocfs2_lock_res_ops ocfs2_inode_data_lops = { 164static struct ocfs2_lock_res_ops ocfs2_inode_data_lops = {
172 .ast = ocfs2_inode_ast_func,
173 .bast = ocfs2_inode_bast_func, 165 .bast = ocfs2_inode_bast_func,
174 .unlock_ast = ocfs2_unlock_ast_func, 166 .unlock_ast = ocfs2_unlock_ast_func,
175 .unblock = ocfs2_unblock_data, 167 .unblock = ocfs2_unblock_data,
@@ -177,7 +169,6 @@ static struct ocfs2_lock_res_ops ocfs2_inode_data_lops = {
177}; 169};
178 170
179static struct ocfs2_lock_res_ops ocfs2_super_lops = { 171static struct ocfs2_lock_res_ops ocfs2_super_lops = {
180 .ast = ocfs2_super_ast_func,
181 .bast = ocfs2_super_bast_func, 172 .bast = ocfs2_super_bast_func,
182 .unlock_ast = ocfs2_unlock_ast_func, 173 .unlock_ast = ocfs2_unlock_ast_func,
183 .unblock = ocfs2_unblock_osb_lock, 174 .unblock = ocfs2_unblock_osb_lock,
@@ -185,7 +176,6 @@ static struct ocfs2_lock_res_ops ocfs2_super_lops = {
185}; 176};
186 177
187static struct ocfs2_lock_res_ops ocfs2_rename_lops = { 178static struct ocfs2_lock_res_ops ocfs2_rename_lops = {
188 .ast = ocfs2_rename_ast_func,
189 .bast = ocfs2_rename_bast_func, 179 .bast = ocfs2_rename_bast_func,
190 .unlock_ast = ocfs2_unlock_ast_func, 180 .unlock_ast = ocfs2_unlock_ast_func,
191 .unblock = ocfs2_unblock_osb_lock, 181 .unblock = ocfs2_unblock_osb_lock,
@@ -193,7 +183,6 @@ static struct ocfs2_lock_res_ops ocfs2_rename_lops = {
193}; 183};
194 184
195static struct ocfs2_lock_res_ops ocfs2_dentry_lops = { 185static struct ocfs2_lock_res_ops ocfs2_dentry_lops = {
196 .ast = ocfs2_dentry_ast_func,
197 .bast = ocfs2_dentry_bast_func, 186 .bast = ocfs2_dentry_bast_func,
198 .unlock_ast = ocfs2_unlock_ast_func, 187 .unlock_ast = ocfs2_unlock_ast_func,
199 .unblock = ocfs2_unblock_dentry_lock, 188 .unblock = ocfs2_unblock_dentry_lock,
@@ -625,64 +614,6 @@ static inline void ocfs2_generic_handle_attach_action(struct ocfs2_lock_res *loc
625 mlog_exit_void(); 614 mlog_exit_void();
626} 615}
627 616
628static void ocfs2_inode_ast_func(void *opaque)
629{
630 struct ocfs2_lock_res *lockres = opaque;
631 struct inode *inode;
632 struct dlm_lockstatus *lksb;
633 unsigned long flags;
634
635 mlog_entry_void();
636
637 inode = ocfs2_lock_res_inode(lockres);
638
639 mlog(0, "AST fired for inode %llu, l_action = %u, type = %s\n",
640 (unsigned long long)OCFS2_I(inode)->ip_blkno, lockres->l_action,
641 ocfs2_lock_type_string(lockres->l_type));
642
643 BUG_ON(!ocfs2_is_inode_lock(lockres));
644
645 spin_lock_irqsave(&lockres->l_lock, flags);
646
647 lksb = &(lockres->l_lksb);
648 if (lksb->status != DLM_NORMAL) {
649 mlog(ML_ERROR, "ocfs2_inode_ast_func: lksb status value of %u "
650 "on inode %llu\n", lksb->status,
651 (unsigned long long)OCFS2_I(inode)->ip_blkno);
652 spin_unlock_irqrestore(&lockres->l_lock, flags);
653 mlog_exit_void();
654 return;
655 }
656
657 switch(lockres->l_action) {
658 case OCFS2_AST_ATTACH:
659 ocfs2_generic_handle_attach_action(lockres);
660 lockres_clear_flags(lockres, OCFS2_LOCK_LOCAL);
661 break;
662 case OCFS2_AST_CONVERT:
663 ocfs2_generic_handle_convert_action(lockres);
664 break;
665 case OCFS2_AST_DOWNCONVERT:
666 ocfs2_generic_handle_downconvert_action(lockres);
667 break;
668 default:
669 mlog(ML_ERROR, "lockres %s: ast fired with invalid action: %u "
670 "lockres flags = 0x%lx, unlock action: %u\n",
671 lockres->l_name, lockres->l_action, lockres->l_flags,
672 lockres->l_unlock_action);
673
674 BUG();
675 }
676
677 /* set it to something invalid so if we get called again we
678 * can catch it. */
679 lockres->l_action = OCFS2_AST_INVALID;
680 spin_unlock_irqrestore(&lockres->l_lock, flags);
681 wake_up(&lockres->l_event);
682
683 mlog_exit_void();
684}
685
686static int ocfs2_generic_handle_bast(struct ocfs2_lock_res *lockres, 617static int ocfs2_generic_handle_bast(struct ocfs2_lock_res *lockres,
687 int level) 618 int level)
688{ 619{
@@ -755,8 +686,9 @@ static void ocfs2_inode_bast_func(void *opaque, int level)
755 mlog_exit_void(); 686 mlog_exit_void();
756} 687}
757 688
758static void ocfs2_generic_ast_func(struct ocfs2_lock_res *lockres) 689static void ocfs2_locking_ast(void *opaque)
759{ 690{
691 struct ocfs2_lock_res *lockres = opaque;
760 struct dlm_lockstatus *lksb = &lockres->l_lksb; 692 struct dlm_lockstatus *lksb = &lockres->l_lksb;
761 unsigned long flags; 693 unsigned long flags;
762 694
@@ -772,6 +704,7 @@ static void ocfs2_generic_ast_func(struct ocfs2_lock_res *lockres)
772 switch(lockres->l_action) { 704 switch(lockres->l_action) {
773 case OCFS2_AST_ATTACH: 705 case OCFS2_AST_ATTACH:
774 ocfs2_generic_handle_attach_action(lockres); 706 ocfs2_generic_handle_attach_action(lockres);
707 lockres_clear_flags(lockres, OCFS2_LOCK_LOCAL);
775 break; 708 break;
776 case OCFS2_AST_CONVERT: 709 case OCFS2_AST_CONVERT:
777 ocfs2_generic_handle_convert_action(lockres); 710 ocfs2_generic_handle_convert_action(lockres);
@@ -780,6 +713,10 @@ static void ocfs2_generic_ast_func(struct ocfs2_lock_res *lockres)
780 ocfs2_generic_handle_downconvert_action(lockres); 713 ocfs2_generic_handle_downconvert_action(lockres);
781 break; 714 break;
782 default: 715 default:
716 mlog(ML_ERROR, "lockres %s: ast fired with invalid action: %u "
717 "lockres flags = 0x%lx, unlock action: %u\n",
718 lockres->l_name, lockres->l_action, lockres->l_flags,
719 lockres->l_unlock_action);
783 BUG(); 720 BUG();
784 } 721 }
785 722
@@ -791,19 +728,6 @@ static void ocfs2_generic_ast_func(struct ocfs2_lock_res *lockres)
791 spin_unlock_irqrestore(&lockres->l_lock, flags); 728 spin_unlock_irqrestore(&lockres->l_lock, flags);
792} 729}
793 730
794static void ocfs2_super_ast_func(void *opaque)
795{
796 struct ocfs2_lock_res *lockres = opaque;
797
798 mlog_entry_void();
799 mlog(0, "Superblock AST fired\n");
800
801 BUG_ON(!ocfs2_is_super_lock(lockres));
802 ocfs2_generic_ast_func(lockres);
803
804 mlog_exit_void();
805}
806
807static void ocfs2_super_bast_func(void *opaque, 731static void ocfs2_super_bast_func(void *opaque,
808 int level) 732 int level)
809{ 733{
@@ -820,21 +744,6 @@ static void ocfs2_super_bast_func(void *opaque,
820 mlog_exit_void(); 744 mlog_exit_void();
821} 745}
822 746
823static void ocfs2_rename_ast_func(void *opaque)
824{
825 struct ocfs2_lock_res *lockres = opaque;
826
827 mlog_entry_void();
828
829 mlog(0, "Rename AST fired\n");
830
831 BUG_ON(!ocfs2_is_rename_lock(lockres));
832
833 ocfs2_generic_ast_func(lockres);
834
835 mlog_exit_void();
836}
837
838static void ocfs2_rename_bast_func(void *opaque, 747static void ocfs2_rename_bast_func(void *opaque,
839 int level) 748 int level)
840{ 749{
@@ -853,15 +762,6 @@ static void ocfs2_rename_bast_func(void *opaque,
853 mlog_exit_void(); 762 mlog_exit_void();
854} 763}
855 764
856static void ocfs2_dentry_ast_func(void *opaque)
857{
858 struct ocfs2_lock_res *lockres = opaque;
859
860 BUG_ON(!lockres);
861
862 ocfs2_generic_ast_func(lockres);
863}
864
865static void ocfs2_dentry_bast_func(void *opaque, int level) 765static void ocfs2_dentry_bast_func(void *opaque, int level)
866{ 766{
867 struct ocfs2_lock_res *lockres = opaque; 767 struct ocfs2_lock_res *lockres = opaque;
@@ -928,7 +828,7 @@ static int ocfs2_lock_create(struct ocfs2_super *osb,
928 dlm_flags, 828 dlm_flags,
929 lockres->l_name, 829 lockres->l_name,
930 OCFS2_LOCK_ID_MAX_LEN - 1, 830 OCFS2_LOCK_ID_MAX_LEN - 1,
931 lockres->l_ops->ast, 831 ocfs2_locking_ast,
932 lockres, 832 lockres,
933 lockres->l_ops->bast); 833 lockres->l_ops->bast);
934 if (status != DLM_NORMAL) { 834 if (status != DLM_NORMAL) {
@@ -1118,7 +1018,7 @@ again:
1118 lkm_flags|LKM_CONVERT|LKM_VALBLK, 1018 lkm_flags|LKM_CONVERT|LKM_VALBLK,
1119 lockres->l_name, 1019 lockres->l_name,
1120 OCFS2_LOCK_ID_MAX_LEN - 1, 1020 OCFS2_LOCK_ID_MAX_LEN - 1,
1121 lockres->l_ops->ast, 1021 ocfs2_locking_ast,
1122 lockres, 1022 lockres,
1123 lockres->l_ops->bast); 1023 lockres->l_ops->bast);
1124 if (status != DLM_NORMAL) { 1024 if (status != DLM_NORMAL) {
@@ -2599,7 +2499,7 @@ static int ocfs2_downconvert_lock(struct ocfs2_super *osb,
2599 dlm_flags, 2499 dlm_flags,
2600 lockres->l_name, 2500 lockres->l_name,
2601 OCFS2_LOCK_ID_MAX_LEN - 1, 2501 OCFS2_LOCK_ID_MAX_LEN - 1,
2602 lockres->l_ops->ast, 2502 ocfs2_locking_ast,
2603 lockres, 2503 lockres,
2604 lockres->l_ops->bast); 2504 lockres->l_ops->bast);
2605 if (status != DLM_NORMAL) { 2505 if (status != DLM_NORMAL) {