1328970deSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */ 2*fa60ce2cSMasahiro Yamada /* 3ccd979bdSMark Fasheh * dlmglue.h 4ccd979bdSMark Fasheh * 5ccd979bdSMark Fasheh * description here 6ccd979bdSMark Fasheh * 7ccd979bdSMark Fasheh * Copyright (C) 2002, 2004 Oracle. All rights reserved. 8ccd979bdSMark Fasheh */ 9ccd979bdSMark Fasheh 10ccd979bdSMark Fasheh 11ccd979bdSMark Fasheh #ifndef DLMGLUE_H 12ccd979bdSMark Fasheh #define DLMGLUE_H 13ccd979bdSMark Fasheh 14d680efe9SMark Fasheh #include "dcache.h" 15d680efe9SMark Fasheh 1615b1e36bSMark Fasheh #define OCFS2_LVB_VERSION 5 17ccd979bdSMark Fasheh 18ccd979bdSMark Fasheh struct ocfs2_meta_lvb { 194d3b83f7SMark Fasheh __u8 lvb_version; 2024c19ef4SMark Fasheh __u8 lvb_reserved0; 2115b1e36bSMark Fasheh __be16 lvb_idynfeatures; 22ccd979bdSMark Fasheh __be32 lvb_iclusters; 23ccd979bdSMark Fasheh __be32 lvb_iuid; 24ccd979bdSMark Fasheh __be32 lvb_igid; 25ccd979bdSMark Fasheh __be64 lvb_iatime_packed; 26ccd979bdSMark Fasheh __be64 lvb_ictime_packed; 27ccd979bdSMark Fasheh __be64 lvb_imtime_packed; 28ccd979bdSMark Fasheh __be64 lvb_isize; 29ccd979bdSMark Fasheh __be16 lvb_imode; 30ccd979bdSMark Fasheh __be16 lvb_inlink; 31ca4d147eSHerbert Poetzl __be32 lvb_iattr; 32f9e2d82eSMark Fasheh __be32 lvb_igeneration; 33f9e2d82eSMark Fasheh __be32 lvb_reserved2; 34ccd979bdSMark Fasheh }; 35ccd979bdSMark Fasheh 369e33d69fSJan Kara #define OCFS2_QINFO_LVB_VERSION 1 379e33d69fSJan Kara 389e33d69fSJan Kara struct ocfs2_qinfo_lvb { 399e33d69fSJan Kara __u8 lvb_version; 409e33d69fSJan Kara __u8 lvb_reserved[3]; 419e33d69fSJan Kara __be32 lvb_bgrace; 429e33d69fSJan Kara __be32 lvb_igrace; 439e33d69fSJan Kara __be32 lvb_syncms; 449e33d69fSJan Kara __be32 lvb_blocks; 459e33d69fSJan Kara __be32 lvb_free_blk; 469e33d69fSJan Kara __be32 lvb_free_entry; 479e33d69fSJan Kara }; 489e33d69fSJan Kara 4983273932SSrinivas Eeda #define OCFS2_ORPHAN_LVB_VERSION 1 5083273932SSrinivas Eeda 5183273932SSrinivas Eeda struct ocfs2_orphan_scan_lvb { 5283273932SSrinivas Eeda __u8 lvb_version; 5383273932SSrinivas Eeda __u8 lvb_reserved[3]; 5483273932SSrinivas Eeda __be32 lvb_os_seqno; 5583273932SSrinivas Eeda }; 5683273932SSrinivas Eeda 574882abebSGang He #define OCFS2_TRIMFS_LVB_VERSION 1 584882abebSGang He 594882abebSGang He struct ocfs2_trim_fs_lvb { 604882abebSGang He __u8 lvb_version; 614882abebSGang He __u8 lvb_success; 624882abebSGang He __u8 lvb_reserved[2]; 634882abebSGang He __be32 lvb_nodenum; 644882abebSGang He __be64 lvb_start; 654882abebSGang He __be64 lvb_len; 664882abebSGang He __be64 lvb_minlen; 674882abebSGang He __be64 lvb_trimlen; 684882abebSGang He }; 694882abebSGang He 704882abebSGang He struct ocfs2_trim_fs_info { 714882abebSGang He u8 tf_valid; /* lvb is valid, or not */ 724882abebSGang He u8 tf_success; /* trim is successful, or not */ 734882abebSGang He u32 tf_nodenum; /* osb node number */ 744882abebSGang He u64 tf_start; /* trim start offset in clusters */ 754882abebSGang He u64 tf_len; /* trim end offset in clusters */ 764882abebSGang He u64 tf_minlen; /* trim minimum contiguous free clusters */ 774882abebSGang He u64 tf_trimlen; /* trimmed length in bytes */ 784882abebSGang He }; 794882abebSGang He 80439a36b8SEric Ren struct ocfs2_lock_holder { 81439a36b8SEric Ren struct list_head oh_list; 82439a36b8SEric Ren struct pid *oh_owner_pid; 83133b81f2SLarry Chen int oh_ex; 84439a36b8SEric Ren }; 85439a36b8SEric Ren 86e63aecb6SMark Fasheh /* ocfs2_inode_lock_full() 'arg_flags' flags */ 87ccd979bdSMark Fasheh /* don't wait on recovery. */ 88ccd979bdSMark Fasheh #define OCFS2_META_LOCK_RECOVERY (0x01) 89ccd979bdSMark Fasheh /* Instruct the dlm not to queue ourselves on the other node. */ 90ccd979bdSMark Fasheh #define OCFS2_META_LOCK_NOQUEUE (0x02) 9134d024f8SMark Fasheh /* don't block waiting for the downconvert thread, instead return -EAGAIN */ 92ccd979bdSMark Fasheh #define OCFS2_LOCK_NONBLOCK (0x04) 93439a36b8SEric Ren /* just get back disk inode bh if we've got cluster lock. */ 94439a36b8SEric Ren #define OCFS2_META_LOCK_GETBH (0x08) 95ccd979bdSMark Fasheh 96cb25797dSJan Kara /* Locking subclasses of inode cluster lock */ 97cb25797dSJan Kara enum { 98cb25797dSJan Kara OI_LS_NORMAL = 0, 99cb25797dSJan Kara OI_LS_PARENT, 100cb25797dSJan Kara OI_LS_RENAME1, 101cb25797dSJan Kara OI_LS_RENAME2, 10207eaac94STao Ma OI_LS_REFLINK_TARGET, 103cb25797dSJan Kara }; 104cb25797dSJan Kara 105ccd979bdSMark Fasheh int ocfs2_dlm_init(struct ocfs2_super *osb); 106286eaa95SJoel Becker void ocfs2_dlm_shutdown(struct ocfs2_super *osb, int hangup_pending); 107ccd979bdSMark Fasheh void ocfs2_lock_res_init_once(struct ocfs2_lock_res *res); 108ccd979bdSMark Fasheh void ocfs2_inode_lock_res_init(struct ocfs2_lock_res *res, 109ccd979bdSMark Fasheh enum ocfs2_lock_type type, 11024c19ef4SMark Fasheh unsigned int generation, 111ccd979bdSMark Fasheh struct inode *inode); 112d680efe9SMark Fasheh void ocfs2_dentry_lock_res_init(struct ocfs2_dentry_lock *dl, 113d680efe9SMark Fasheh u64 parent, struct inode *inode); 114cf8e06f1SMark Fasheh struct ocfs2_file_private; 115cf8e06f1SMark Fasheh void ocfs2_file_lock_res_init(struct ocfs2_lock_res *lockres, 116cf8e06f1SMark Fasheh struct ocfs2_file_private *fp); 1179e33d69fSJan Kara struct ocfs2_mem_dqinfo; 1189e33d69fSJan Kara void ocfs2_qinfo_lock_res_init(struct ocfs2_lock_res *lockres, 1199e33d69fSJan Kara struct ocfs2_mem_dqinfo *info); 1208dec98edSTao Ma void ocfs2_refcount_lock_res_init(struct ocfs2_lock_res *lockres, 1218dec98edSTao Ma struct ocfs2_super *osb, u64 ref_blkno, 1228dec98edSTao Ma unsigned int generation); 123ccd979bdSMark Fasheh void ocfs2_lock_res_free(struct ocfs2_lock_res *res); 124ccd979bdSMark Fasheh int ocfs2_create_new_inode_locks(struct inode *inode); 125ccd979bdSMark Fasheh int ocfs2_drop_inode_locks(struct inode *inode); 126ccd979bdSMark Fasheh int ocfs2_rw_lock(struct inode *inode, int write); 12706e7f13dSGang He int ocfs2_try_rw_lock(struct inode *inode, int write); 128ccd979bdSMark Fasheh void ocfs2_rw_unlock(struct inode *inode, int write); 12950008630STiger Yang int ocfs2_open_lock(struct inode *inode); 13050008630STiger Yang int ocfs2_try_open_lock(struct inode *inode, int write); 13150008630STiger Yang void ocfs2_open_unlock(struct inode *inode); 132e63aecb6SMark Fasheh int ocfs2_inode_lock_atime(struct inode *inode, 1337f1a37e3STiger Yang struct vfsmount *vfsmnt, 134c4c2416aSGang He int *level, int wait); 135cb25797dSJan Kara int ocfs2_inode_lock_full_nested(struct inode *inode, 136ccd979bdSMark Fasheh struct buffer_head **ret_bh, 137ccd979bdSMark Fasheh int ex, 138cb25797dSJan Kara int arg_flags, 139cb25797dSJan Kara int subclass); 140e63aecb6SMark Fasheh int ocfs2_inode_lock_with_page(struct inode *inode, 141ccd979bdSMark Fasheh struct buffer_head **ret_bh, 142ccd979bdSMark Fasheh int ex, 143ccd979bdSMark Fasheh struct page *page); 144cb25797dSJan Kara /* Variants without special locking class or flags */ 145cb25797dSJan Kara #define ocfs2_inode_lock_full(i, r, e, f)\ 146cb25797dSJan Kara ocfs2_inode_lock_full_nested(i, r, e, f, OI_LS_NORMAL) 147cb25797dSJan Kara #define ocfs2_inode_lock_nested(i, b, e, s)\ 148cb25797dSJan Kara ocfs2_inode_lock_full_nested(i, b, e, 0, s) 149ccd979bdSMark Fasheh /* 99% of the time we don't want to supply any additional flags -- 150ccd979bdSMark Fasheh * those are for very specific cases only. */ 151cb25797dSJan Kara #define ocfs2_inode_lock(i, b, e) ocfs2_inode_lock_full_nested(i, b, e, 0, OI_LS_NORMAL) 15206e7f13dSGang He #define ocfs2_try_inode_lock(i, b, e)\ 15306e7f13dSGang He ocfs2_inode_lock_full_nested(i, b, e, OCFS2_META_LOCK_NOQUEUE,\ 15406e7f13dSGang He OI_LS_NORMAL) 155e63aecb6SMark Fasheh void ocfs2_inode_unlock(struct inode *inode, 156ccd979bdSMark Fasheh int ex); 157ccd979bdSMark Fasheh int ocfs2_super_lock(struct ocfs2_super *osb, 158ccd979bdSMark Fasheh int ex); 159ccd979bdSMark Fasheh void ocfs2_super_unlock(struct ocfs2_super *osb, 160ccd979bdSMark Fasheh int ex); 161df152c24SSunil Mushran int ocfs2_orphan_scan_lock(struct ocfs2_super *osb, u32 *seqno); 162df152c24SSunil Mushran void ocfs2_orphan_scan_unlock(struct ocfs2_super *osb, u32 seqno); 16383273932SSrinivas Eeda 164ccd979bdSMark Fasheh int ocfs2_rename_lock(struct ocfs2_super *osb); 165ccd979bdSMark Fasheh void ocfs2_rename_unlock(struct ocfs2_super *osb); 1666ca497a8Swengang wang int ocfs2_nfs_sync_lock(struct ocfs2_super *osb, int ex); 1676ca497a8Swengang wang void ocfs2_nfs_sync_unlock(struct ocfs2_super *osb, int ex); 1684882abebSGang He void ocfs2_trim_fs_lock_res_init(struct ocfs2_super *osb); 1694882abebSGang He void ocfs2_trim_fs_lock_res_uninit(struct ocfs2_super *osb); 1704882abebSGang He int ocfs2_trim_fs_lock(struct ocfs2_super *osb, 1714882abebSGang He struct ocfs2_trim_fs_info *info, int trylock); 1724882abebSGang He void ocfs2_trim_fs_unlock(struct ocfs2_super *osb, 1734882abebSGang He struct ocfs2_trim_fs_info *info); 174d680efe9SMark Fasheh int ocfs2_dentry_lock(struct dentry *dentry, int ex); 175d680efe9SMark Fasheh void ocfs2_dentry_unlock(struct dentry *dentry, int ex); 176cf8e06f1SMark Fasheh int ocfs2_file_lock(struct file *file, int ex, int trylock); 177cf8e06f1SMark Fasheh void ocfs2_file_unlock(struct file *file); 1789e33d69fSJan Kara int ocfs2_qinfo_lock(struct ocfs2_mem_dqinfo *oinfo, int ex); 1799e33d69fSJan Kara void ocfs2_qinfo_unlock(struct ocfs2_mem_dqinfo *oinfo, int ex); 1808dec98edSTao Ma struct ocfs2_refcount_tree; 1818dec98edSTao Ma int ocfs2_refcount_lock(struct ocfs2_refcount_tree *ref_tree, int ex); 1828dec98edSTao Ma void ocfs2_refcount_unlock(struct ocfs2_refcount_tree *ref_tree, int ex); 1839e33d69fSJan Kara 184d680efe9SMark Fasheh 18584d86f83SJan Kara void ocfs2_mark_lockres_freeing(struct ocfs2_super *osb, 18684d86f83SJan Kara struct ocfs2_lock_res *lockres); 187d680efe9SMark Fasheh void ocfs2_simple_drop_lockres(struct ocfs2_super *osb, 188d680efe9SMark Fasheh struct ocfs2_lock_res *lockres); 189ccd979bdSMark Fasheh 19034d024f8SMark Fasheh /* for the downconvert thread */ 19134d024f8SMark Fasheh void ocfs2_wake_downconvert_thread(struct ocfs2_super *osb); 192ccd979bdSMark Fasheh 193ccd979bdSMark Fasheh struct ocfs2_dlm_debug *ocfs2_new_dlm_debug(void); 194ccd979bdSMark Fasheh void ocfs2_put_dlm_debug(struct ocfs2_dlm_debug *dlm_debug); 195ccd979bdSMark Fasheh 19663e0c48aSJoel Becker /* To set the locking protocol on module initialization */ 19763e0c48aSJoel Becker void ocfs2_set_locking_protocol(void); 198439a36b8SEric Ren 199439a36b8SEric Ren /* The _tracker pair is used to avoid cluster recursive locking */ 200439a36b8SEric Ren int ocfs2_inode_lock_tracker(struct inode *inode, 201439a36b8SEric Ren struct buffer_head **ret_bh, 202439a36b8SEric Ren int ex, 203439a36b8SEric Ren struct ocfs2_lock_holder *oh); 204439a36b8SEric Ren void ocfs2_inode_unlock_tracker(struct inode *inode, 205439a36b8SEric Ren int ex, 206439a36b8SEric Ren struct ocfs2_lock_holder *oh, 207439a36b8SEric Ren int had_lock); 208439a36b8SEric Ren 209ccd979bdSMark Fasheh #endif /* DLMGLUE_H */ 210