1*34a9dd7eSJoel Becker /* -*- mode: c; c-basic-offset: 8; -*- 2*34a9dd7eSJoel Becker * vim: noexpandtab sw=8 ts=8 sts=0: 3*34a9dd7eSJoel Becker * 4*34a9dd7eSJoel Becker * userdlm.h 5*34a9dd7eSJoel Becker * 6*34a9dd7eSJoel Becker * Userspace dlm defines 7*34a9dd7eSJoel Becker * 8*34a9dd7eSJoel Becker * Copyright (C) 2002, 2004 Oracle. All rights reserved. 9*34a9dd7eSJoel Becker * 10*34a9dd7eSJoel Becker * This program is free software; you can redistribute it and/or 11*34a9dd7eSJoel Becker * modify it under the terms of the GNU General Public 12*34a9dd7eSJoel Becker * License as published by the Free Software Foundation; either 13*34a9dd7eSJoel Becker * version 2 of the License, or (at your option) any later version. 14*34a9dd7eSJoel Becker * 15*34a9dd7eSJoel Becker * This program is distributed in the hope that it will be useful, 16*34a9dd7eSJoel Becker * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*34a9dd7eSJoel Becker * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18*34a9dd7eSJoel Becker * General Public License for more details. 19*34a9dd7eSJoel Becker * 20*34a9dd7eSJoel Becker * You should have received a copy of the GNU General Public 21*34a9dd7eSJoel Becker * License along with this program; if not, write to the 22*34a9dd7eSJoel Becker * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 23*34a9dd7eSJoel Becker * Boston, MA 021110-1307, USA. 24*34a9dd7eSJoel Becker */ 25*34a9dd7eSJoel Becker 26*34a9dd7eSJoel Becker 27*34a9dd7eSJoel Becker #ifndef USERDLM_H 28*34a9dd7eSJoel Becker #define USERDLM_H 29*34a9dd7eSJoel Becker 30*34a9dd7eSJoel Becker #include <linux/module.h> 31*34a9dd7eSJoel Becker #include <linux/fs.h> 32*34a9dd7eSJoel Becker #include <linux/types.h> 33*34a9dd7eSJoel Becker #include <linux/workqueue.h> 34*34a9dd7eSJoel Becker 35*34a9dd7eSJoel Becker /* user_lock_res->l_flags flags. */ 36*34a9dd7eSJoel Becker #define USER_LOCK_ATTACHED (0x00000001) /* we have initialized 37*34a9dd7eSJoel Becker * the lvb */ 38*34a9dd7eSJoel Becker #define USER_LOCK_BUSY (0x00000002) /* we are currently in 39*34a9dd7eSJoel Becker * dlm_lock */ 40*34a9dd7eSJoel Becker #define USER_LOCK_BLOCKED (0x00000004) /* blocked waiting to 41*34a9dd7eSJoel Becker * downconvert*/ 42*34a9dd7eSJoel Becker #define USER_LOCK_IN_TEARDOWN (0x00000008) /* we're currently 43*34a9dd7eSJoel Becker * destroying this 44*34a9dd7eSJoel Becker * lock. */ 45*34a9dd7eSJoel Becker #define USER_LOCK_QUEUED (0x00000010) /* lock is on the 46*34a9dd7eSJoel Becker * workqueue */ 47*34a9dd7eSJoel Becker #define USER_LOCK_IN_CANCEL (0x00000020) 48*34a9dd7eSJoel Becker 49*34a9dd7eSJoel Becker struct user_lock_res { 50*34a9dd7eSJoel Becker spinlock_t l_lock; 51*34a9dd7eSJoel Becker 52*34a9dd7eSJoel Becker int l_flags; 53*34a9dd7eSJoel Becker 54*34a9dd7eSJoel Becker #define USER_DLM_LOCK_ID_MAX_LEN 32 55*34a9dd7eSJoel Becker char l_name[USER_DLM_LOCK_ID_MAX_LEN]; 56*34a9dd7eSJoel Becker int l_namelen; 57*34a9dd7eSJoel Becker int l_level; 58*34a9dd7eSJoel Becker unsigned int l_ro_holders; 59*34a9dd7eSJoel Becker unsigned int l_ex_holders; 60*34a9dd7eSJoel Becker struct dlm_lockstatus l_lksb; 61*34a9dd7eSJoel Becker 62*34a9dd7eSJoel Becker int l_requested; 63*34a9dd7eSJoel Becker int l_blocking; 64*34a9dd7eSJoel Becker 65*34a9dd7eSJoel Becker wait_queue_head_t l_event; 66*34a9dd7eSJoel Becker 67*34a9dd7eSJoel Becker struct work_struct l_work; 68*34a9dd7eSJoel Becker }; 69*34a9dd7eSJoel Becker 70*34a9dd7eSJoel Becker extern struct workqueue_struct *user_dlm_worker; 71*34a9dd7eSJoel Becker 72*34a9dd7eSJoel Becker void user_dlm_lock_res_init(struct user_lock_res *lockres, 73*34a9dd7eSJoel Becker struct dentry *dentry); 74*34a9dd7eSJoel Becker int user_dlm_destroy_lock(struct user_lock_res *lockres); 75*34a9dd7eSJoel Becker int user_dlm_cluster_lock(struct user_lock_res *lockres, 76*34a9dd7eSJoel Becker int level, 77*34a9dd7eSJoel Becker int lkm_flags); 78*34a9dd7eSJoel Becker void user_dlm_cluster_unlock(struct user_lock_res *lockres, 79*34a9dd7eSJoel Becker int level); 80*34a9dd7eSJoel Becker void user_dlm_write_lvb(struct inode *inode, 81*34a9dd7eSJoel Becker const char *val, 82*34a9dd7eSJoel Becker unsigned int len); 83*34a9dd7eSJoel Becker void user_dlm_read_lvb(struct inode *inode, 84*34a9dd7eSJoel Becker char *val, 85*34a9dd7eSJoel Becker unsigned int len); 86*34a9dd7eSJoel Becker struct dlm_ctxt *user_dlm_register_context(struct qstr *name, 87*34a9dd7eSJoel Becker struct dlm_protocol_version *proto); 88*34a9dd7eSJoel Becker void user_dlm_unregister_context(struct dlm_ctxt *dlm); 89*34a9dd7eSJoel Becker 90*34a9dd7eSJoel Becker struct dlmfs_inode_private { 91*34a9dd7eSJoel Becker struct dlm_ctxt *ip_dlm; 92*34a9dd7eSJoel Becker 93*34a9dd7eSJoel Becker struct user_lock_res ip_lockres; /* unused for directories. */ 94*34a9dd7eSJoel Becker struct inode *ip_parent; 95*34a9dd7eSJoel Becker 96*34a9dd7eSJoel Becker struct inode ip_vfs_inode; 97*34a9dd7eSJoel Becker }; 98*34a9dd7eSJoel Becker 99*34a9dd7eSJoel Becker static inline struct dlmfs_inode_private * 100*34a9dd7eSJoel Becker DLMFS_I(struct inode *inode) 101*34a9dd7eSJoel Becker { 102*34a9dd7eSJoel Becker return container_of(inode, 103*34a9dd7eSJoel Becker struct dlmfs_inode_private, 104*34a9dd7eSJoel Becker ip_vfs_inode); 105*34a9dd7eSJoel Becker } 106*34a9dd7eSJoel Becker 107*34a9dd7eSJoel Becker struct dlmfs_filp_private { 108*34a9dd7eSJoel Becker int fp_lock_level; 109*34a9dd7eSJoel Becker }; 110*34a9dd7eSJoel Becker 111*34a9dd7eSJoel Becker #define DLMFS_MAGIC 0x76a9f425 112*34a9dd7eSJoel Becker 113*34a9dd7eSJoel Becker #endif /* USERDLM_H */ 114