diff options
author | Kurt Hackel <kurt.hackel@oracle.com> | 2006-12-01 17:47:20 -0500 |
---|---|---|
committer | Mark Fasheh <mark.fasheh@oracle.com> | 2007-02-07 14:53:07 -0500 |
commit | ba2bf2185121db74e075c703fbf986761733dd1d (patch) | |
tree | f7b90fa14db61fb6fc5d92d393b1d837e58a9faa /fs/ocfs2/dlm/dlmcommon.h | |
parent | 5331be090567d9335476f876b2d85427cd7c4426 (diff) |
ocfs2_dlm: fix cluster-wide refcounting of lock resources
This was previously broken and migration of some locks had to be temporarily
disabled. We use a new (and backward-incompatible) set of network messages
to account for all references to a lock resources held across the cluster.
once these are all freed, the master node may then free the lock resource
memory once its local references are dropped.
Signed-off-by: Kurt Hackel <kurt.hackel@oracle.com>
Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
Diffstat (limited to 'fs/ocfs2/dlm/dlmcommon.h')
-rw-r--r-- | fs/ocfs2/dlm/dlmcommon.h | 75 |
1 files changed, 71 insertions, 4 deletions
diff --git a/fs/ocfs2/dlm/dlmcommon.h b/fs/ocfs2/dlm/dlmcommon.h index 6b6ff76538c5..9fa427119a3c 100644 --- a/fs/ocfs2/dlm/dlmcommon.h +++ b/fs/ocfs2/dlm/dlmcommon.h | |||
@@ -222,6 +222,7 @@ static inline void __dlm_set_joining_node(struct dlm_ctxt *dlm, | |||
222 | #define DLM_LOCK_RES_DIRTY 0x00000008 | 222 | #define DLM_LOCK_RES_DIRTY 0x00000008 |
223 | #define DLM_LOCK_RES_IN_PROGRESS 0x00000010 | 223 | #define DLM_LOCK_RES_IN_PROGRESS 0x00000010 |
224 | #define DLM_LOCK_RES_MIGRATING 0x00000020 | 224 | #define DLM_LOCK_RES_MIGRATING 0x00000020 |
225 | #define DLM_LOCK_RES_DROPPING_REF 0x00000040 | ||
225 | 226 | ||
226 | /* max milliseconds to wait to sync up a network failure with a node death */ | 227 | /* max milliseconds to wait to sync up a network failure with a node death */ |
227 | #define DLM_NODE_DEATH_WAIT_MAX (5 * 1000) | 228 | #define DLM_NODE_DEATH_WAIT_MAX (5 * 1000) |
@@ -265,6 +266,8 @@ struct dlm_lock_resource | |||
265 | u8 owner; //node which owns the lock resource, or unknown | 266 | u8 owner; //node which owns the lock resource, or unknown |
266 | u16 state; | 267 | u16 state; |
267 | char lvb[DLM_LVB_LEN]; | 268 | char lvb[DLM_LVB_LEN]; |
269 | unsigned int inflight_locks; | ||
270 | unsigned long refmap[BITS_TO_LONGS(O2NM_MAX_NODES)]; | ||
268 | }; | 271 | }; |
269 | 272 | ||
270 | struct dlm_migratable_lock | 273 | struct dlm_migratable_lock |
@@ -367,7 +370,7 @@ enum { | |||
367 | DLM_CONVERT_LOCK_MSG, /* 504 */ | 370 | DLM_CONVERT_LOCK_MSG, /* 504 */ |
368 | DLM_PROXY_AST_MSG, /* 505 */ | 371 | DLM_PROXY_AST_MSG, /* 505 */ |
369 | DLM_UNLOCK_LOCK_MSG, /* 506 */ | 372 | DLM_UNLOCK_LOCK_MSG, /* 506 */ |
370 | DLM_UNUSED_MSG2, /* 507 */ | 373 | DLM_DEREF_LOCKRES_MSG, /* 507 */ |
371 | DLM_MIGRATE_REQUEST_MSG, /* 508 */ | 374 | DLM_MIGRATE_REQUEST_MSG, /* 508 */ |
372 | DLM_MIG_LOCKRES_MSG, /* 509 */ | 375 | DLM_MIG_LOCKRES_MSG, /* 509 */ |
373 | DLM_QUERY_JOIN_MSG, /* 510 */ | 376 | DLM_QUERY_JOIN_MSG, /* 510 */ |
@@ -417,6 +420,9 @@ struct dlm_master_request | |||
417 | u8 name[O2NM_MAX_NAME_LEN]; | 420 | u8 name[O2NM_MAX_NAME_LEN]; |
418 | }; | 421 | }; |
419 | 422 | ||
423 | #define DLM_ASSERT_RESPONSE_REASSERT 0x00000001 | ||
424 | #define DLM_ASSERT_RESPONSE_MASTERY_REF 0x00000002 | ||
425 | |||
420 | #define DLM_ASSERT_MASTER_MLE_CLEANUP 0x00000001 | 426 | #define DLM_ASSERT_MASTER_MLE_CLEANUP 0x00000001 |
421 | #define DLM_ASSERT_MASTER_REQUERY 0x00000002 | 427 | #define DLM_ASSERT_MASTER_REQUERY 0x00000002 |
422 | #define DLM_ASSERT_MASTER_FINISH_MIGRATION 0x00000004 | 428 | #define DLM_ASSERT_MASTER_FINISH_MIGRATION 0x00000004 |
@@ -430,6 +436,8 @@ struct dlm_assert_master | |||
430 | u8 name[O2NM_MAX_NAME_LEN]; | 436 | u8 name[O2NM_MAX_NAME_LEN]; |
431 | }; | 437 | }; |
432 | 438 | ||
439 | #define DLM_MIGRATE_RESPONSE_MASTERY_REF 0x00000001 | ||
440 | |||
433 | struct dlm_migrate_request | 441 | struct dlm_migrate_request |
434 | { | 442 | { |
435 | u8 master; | 443 | u8 master; |
@@ -648,6 +656,16 @@ struct dlm_finalize_reco | |||
648 | __be32 pad2; | 656 | __be32 pad2; |
649 | }; | 657 | }; |
650 | 658 | ||
659 | struct dlm_deref_lockres | ||
660 | { | ||
661 | u32 pad1; | ||
662 | u16 pad2; | ||
663 | u8 node_idx; | ||
664 | u8 namelen; | ||
665 | |||
666 | u8 name[O2NM_MAX_NAME_LEN]; | ||
667 | }; | ||
668 | |||
651 | static inline enum dlm_status | 669 | static inline enum dlm_status |
652 | __dlm_lockres_state_to_status(struct dlm_lock_resource *res) | 670 | __dlm_lockres_state_to_status(struct dlm_lock_resource *res) |
653 | { | 671 | { |
@@ -721,8 +739,8 @@ void __dlm_lockres_calc_usage(struct dlm_ctxt *dlm, | |||
721 | struct dlm_lock_resource *res); | 739 | struct dlm_lock_resource *res); |
722 | void dlm_lockres_calc_usage(struct dlm_ctxt *dlm, | 740 | void dlm_lockres_calc_usage(struct dlm_ctxt *dlm, |
723 | struct dlm_lock_resource *res); | 741 | struct dlm_lock_resource *res); |
724 | void dlm_purge_lockres(struct dlm_ctxt *dlm, | 742 | int dlm_purge_lockres(struct dlm_ctxt *dlm, |
725 | struct dlm_lock_resource *lockres); | 743 | struct dlm_lock_resource *lockres); |
726 | static inline void dlm_lockres_get(struct dlm_lock_resource *res) | 744 | static inline void dlm_lockres_get(struct dlm_lock_resource *res) |
727 | { | 745 | { |
728 | /* This is called on every lookup, so it might be worth | 746 | /* This is called on every lookup, so it might be worth |
@@ -733,6 +751,10 @@ void dlm_lockres_put(struct dlm_lock_resource *res); | |||
733 | void __dlm_unhash_lockres(struct dlm_lock_resource *res); | 751 | void __dlm_unhash_lockres(struct dlm_lock_resource *res); |
734 | void __dlm_insert_lockres(struct dlm_ctxt *dlm, | 752 | void __dlm_insert_lockres(struct dlm_ctxt *dlm, |
735 | struct dlm_lock_resource *res); | 753 | struct dlm_lock_resource *res); |
754 | struct dlm_lock_resource * __dlm_lookup_lockres_full(struct dlm_ctxt *dlm, | ||
755 | const char *name, | ||
756 | unsigned int len, | ||
757 | unsigned int hash); | ||
736 | struct dlm_lock_resource * __dlm_lookup_lockres(struct dlm_ctxt *dlm, | 758 | struct dlm_lock_resource * __dlm_lookup_lockres(struct dlm_ctxt *dlm, |
737 | const char *name, | 759 | const char *name, |
738 | unsigned int len, | 760 | unsigned int len, |
@@ -753,6 +775,47 @@ struct dlm_lock_resource *dlm_new_lockres(struct dlm_ctxt *dlm, | |||
753 | const char *name, | 775 | const char *name, |
754 | unsigned int namelen); | 776 | unsigned int namelen); |
755 | 777 | ||
778 | #define dlm_lockres_set_refmap_bit(bit,res) \ | ||
779 | __dlm_lockres_set_refmap_bit(bit,res,__FILE__,__LINE__) | ||
780 | #define dlm_lockres_clear_refmap_bit(bit,res) \ | ||
781 | __dlm_lockres_clear_refmap_bit(bit,res,__FILE__,__LINE__) | ||
782 | |||
783 | static inline void __dlm_lockres_set_refmap_bit(int bit, | ||
784 | struct dlm_lock_resource *res, | ||
785 | const char *file, | ||
786 | int line) | ||
787 | { | ||
788 | //printk("%s:%d:%.*s: setting bit %d\n", file, line, | ||
789 | // res->lockname.len, res->lockname.name, bit); | ||
790 | set_bit(bit, res->refmap); | ||
791 | } | ||
792 | |||
793 | static inline void __dlm_lockres_clear_refmap_bit(int bit, | ||
794 | struct dlm_lock_resource *res, | ||
795 | const char *file, | ||
796 | int line) | ||
797 | { | ||
798 | //printk("%s:%d:%.*s: clearing bit %d\n", file, line, | ||
799 | // res->lockname.len, res->lockname.name, bit); | ||
800 | clear_bit(bit, res->refmap); | ||
801 | } | ||
802 | |||
803 | void __dlm_lockres_drop_inflight_ref(struct dlm_ctxt *dlm, | ||
804 | struct dlm_lock_resource *res, | ||
805 | const char *file, | ||
806 | int line); | ||
807 | void __dlm_lockres_grab_inflight_ref(struct dlm_ctxt *dlm, | ||
808 | struct dlm_lock_resource *res, | ||
809 | int new_lockres, | ||
810 | const char *file, | ||
811 | int line); | ||
812 | #define dlm_lockres_drop_inflight_ref(d,r) \ | ||
813 | __dlm_lockres_drop_inflight_ref(d,r,__FILE__,__LINE__) | ||
814 | #define dlm_lockres_grab_inflight_ref(d,r) \ | ||
815 | __dlm_lockres_grab_inflight_ref(d,r,0,__FILE__,__LINE__) | ||
816 | #define dlm_lockres_grab_inflight_ref_new(d,r) \ | ||
817 | __dlm_lockres_grab_inflight_ref(d,r,1,__FILE__,__LINE__) | ||
818 | |||
756 | void dlm_queue_ast(struct dlm_ctxt *dlm, struct dlm_lock *lock); | 819 | void dlm_queue_ast(struct dlm_ctxt *dlm, struct dlm_lock *lock); |
757 | void dlm_queue_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock); | 820 | void dlm_queue_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock); |
758 | void dlm_do_local_ast(struct dlm_ctxt *dlm, | 821 | void dlm_do_local_ast(struct dlm_ctxt *dlm, |
@@ -805,6 +868,7 @@ int dlm_lockres_is_dirty(struct dlm_ctxt *dlm, struct dlm_lock_resource *res); | |||
805 | int dlm_migrate_lockres(struct dlm_ctxt *dlm, | 868 | int dlm_migrate_lockres(struct dlm_ctxt *dlm, |
806 | struct dlm_lock_resource *res, | 869 | struct dlm_lock_resource *res, |
807 | u8 target); | 870 | u8 target); |
871 | int dlm_empty_lockres(struct dlm_ctxt *dlm, struct dlm_lock_resource *res); | ||
808 | int dlm_finish_migration(struct dlm_ctxt *dlm, | 872 | int dlm_finish_migration(struct dlm_ctxt *dlm, |
809 | struct dlm_lock_resource *res, | 873 | struct dlm_lock_resource *res, |
810 | u8 old_master); | 874 | u8 old_master); |
@@ -814,6 +878,7 @@ void __dlm_lockres_reserve_ast(struct dlm_lock_resource *res); | |||
814 | 878 | ||
815 | int dlm_master_request_handler(struct o2net_msg *msg, u32 len, void *data); | 879 | int dlm_master_request_handler(struct o2net_msg *msg, u32 len, void *data); |
816 | int dlm_assert_master_handler(struct o2net_msg *msg, u32 len, void *data); | 880 | int dlm_assert_master_handler(struct o2net_msg *msg, u32 len, void *data); |
881 | int dlm_deref_lockres_handler(struct o2net_msg *msg, u32 len, void *data); | ||
817 | int dlm_migrate_request_handler(struct o2net_msg *msg, u32 len, void *data); | 882 | int dlm_migrate_request_handler(struct o2net_msg *msg, u32 len, void *data); |
818 | int dlm_mig_lockres_handler(struct o2net_msg *msg, u32 len, void *data); | 883 | int dlm_mig_lockres_handler(struct o2net_msg *msg, u32 len, void *data); |
819 | int dlm_master_requery_handler(struct o2net_msg *msg, u32 len, void *data); | 884 | int dlm_master_requery_handler(struct o2net_msg *msg, u32 len, void *data); |
@@ -856,10 +921,12 @@ static inline void __dlm_wait_on_lockres(struct dlm_lock_resource *res) | |||
856 | int dlm_init_mle_cache(void); | 921 | int dlm_init_mle_cache(void); |
857 | void dlm_destroy_mle_cache(void); | 922 | void dlm_destroy_mle_cache(void); |
858 | void dlm_hb_event_notify_attached(struct dlm_ctxt *dlm, int idx, int node_up); | 923 | void dlm_hb_event_notify_attached(struct dlm_ctxt *dlm, int idx, int node_up); |
924 | int dlm_drop_lockres_ref(struct dlm_ctxt *dlm, | ||
925 | struct dlm_lock_resource *res); | ||
859 | void dlm_clean_master_list(struct dlm_ctxt *dlm, | 926 | void dlm_clean_master_list(struct dlm_ctxt *dlm, |
860 | u8 dead_node); | 927 | u8 dead_node); |
861 | int dlm_lock_basts_flushed(struct dlm_ctxt *dlm, struct dlm_lock *lock); | 928 | int dlm_lock_basts_flushed(struct dlm_ctxt *dlm, struct dlm_lock *lock); |
862 | 929 | int __dlm_lockres_has_locks(struct dlm_lock_resource *res); | |
863 | int __dlm_lockres_unused(struct dlm_lock_resource *res); | 930 | int __dlm_lockres_unused(struct dlm_lock_resource *res); |
864 | 931 | ||
865 | static inline const char * dlm_lock_mode_name(int mode) | 932 | static inline const char * dlm_lock_mode_name(int mode) |