^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* -*- mode: c; c-basic-offset: 8; -*-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * vim: noexpandtab sw=8 ts=8 sts=0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * userdlm.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Userspace dlm defines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Copyright (C) 2002, 2004 Oracle. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #ifndef USERDLM_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #define USERDLM_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/workqueue.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) /* user_lock_res->l_flags flags. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define USER_LOCK_ATTACHED (0x00000001) /* we have initialized
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * the lvb */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define USER_LOCK_BUSY (0x00000002) /* we are currently in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * dlm_lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define USER_LOCK_BLOCKED (0x00000004) /* blocked waiting to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * downconvert*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define USER_LOCK_IN_TEARDOWN (0x00000008) /* we're currently
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * destroying this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * lock. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define USER_LOCK_QUEUED (0x00000010) /* lock is on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * workqueue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define USER_LOCK_IN_CANCEL (0x00000020)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) struct user_lock_res {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) spinlock_t l_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) int l_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #define USER_DLM_LOCK_ID_MAX_LEN 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) char l_name[USER_DLM_LOCK_ID_MAX_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) int l_namelen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) int l_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) unsigned int l_ro_holders;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) unsigned int l_ex_holders;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) struct ocfs2_dlm_lksb l_lksb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) int l_requested;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) int l_blocking;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) wait_queue_head_t l_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct work_struct l_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) extern struct workqueue_struct *user_dlm_worker;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) void user_dlm_lock_res_init(struct user_lock_res *lockres,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct dentry *dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) int user_dlm_destroy_lock(struct user_lock_res *lockres);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) int user_dlm_cluster_lock(struct user_lock_res *lockres,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) int level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) int lkm_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) void user_dlm_cluster_unlock(struct user_lock_res *lockres,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) int level);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) void user_dlm_write_lvb(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) const char *val,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) unsigned int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) bool user_dlm_read_lvb(struct inode *inode, char *val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) struct ocfs2_cluster_connection *user_dlm_register(const struct qstr *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) void user_dlm_unregister(struct ocfs2_cluster_connection *conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) void user_dlm_set_locking_protocol(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) struct dlmfs_inode_private {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) struct ocfs2_cluster_connection *ip_conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) struct user_lock_res ip_lockres; /* unused for directories. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) struct inode *ip_parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) struct inode ip_vfs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) static inline struct dlmfs_inode_private *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) DLMFS_I(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) return container_of(inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) struct dlmfs_inode_private,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) ip_vfs_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) struct dlmfs_filp_private {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) int fp_lock_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) #define DLMFS_MAGIC 0x76a9f425
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) #endif /* USERDLM_H */