1ccd979bdSMark Fasheh /* -*- mode: c; c-basic-offset: 8; -*- 2ccd979bdSMark Fasheh * vim: noexpandtab sw=8 ts=8 sts=0: 3ccd979bdSMark Fasheh * 4ccd979bdSMark Fasheh * ocfs2_lockid.h 5ccd979bdSMark Fasheh * 6ccd979bdSMark Fasheh * Defines OCFS2 lockid bits. 7ccd979bdSMark Fasheh * 8ccd979bdSMark Fasheh * Copyright (C) 2002, 2005 Oracle. All rights reserved. 9ccd979bdSMark Fasheh * 10ccd979bdSMark Fasheh * This program is free software; you can redistribute it and/or 11ccd979bdSMark Fasheh * modify it under the terms of the GNU General Public 12ccd979bdSMark Fasheh * License as published by the Free Software Foundation; either 13ccd979bdSMark Fasheh * version 2 of the License, or (at your option) any later version. 14ccd979bdSMark Fasheh * 15ccd979bdSMark Fasheh * This program is distributed in the hope that it will be useful, 16ccd979bdSMark Fasheh * but WITHOUT ANY WARRANTY; without even the implied warranty of 17ccd979bdSMark Fasheh * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18ccd979bdSMark Fasheh * General Public License for more details. 19ccd979bdSMark Fasheh * 20ccd979bdSMark Fasheh * You should have received a copy of the GNU General Public 21ccd979bdSMark Fasheh * License along with this program; if not, write to the 22ccd979bdSMark Fasheh * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 23ccd979bdSMark Fasheh * Boston, MA 021110-1307, USA. 24ccd979bdSMark Fasheh */ 25ccd979bdSMark Fasheh 26ccd979bdSMark Fasheh #ifndef OCFS2_LOCKID_H 27ccd979bdSMark Fasheh #define OCFS2_LOCKID_H 28ccd979bdSMark Fasheh 29ccd979bdSMark Fasheh /* lock ids are made up in the following manner: 30ccd979bdSMark Fasheh * name[0] --> type 31ccd979bdSMark Fasheh * name[1-6] --> 6 pad characters, reserved for now 32ccd979bdSMark Fasheh * name[7-22] --> block number, expressed in hex as 16 chars 33ccd979bdSMark Fasheh * name[23-30] --> i_generation, expressed in hex 8 chars 34ccd979bdSMark Fasheh * name[31] --> '\0' */ 35ccd979bdSMark Fasheh #define OCFS2_LOCK_ID_MAX_LEN 32 36ccd979bdSMark Fasheh #define OCFS2_LOCK_ID_PAD "000000" 37ccd979bdSMark Fasheh 38d680efe9SMark Fasheh #define OCFS2_DENTRY_LOCK_INO_START 18 39d680efe9SMark Fasheh 40ccd979bdSMark Fasheh enum ocfs2_lock_type { 41ccd979bdSMark Fasheh OCFS2_LOCK_TYPE_META = 0, 42ccd979bdSMark Fasheh OCFS2_LOCK_TYPE_DATA, 43ccd979bdSMark Fasheh OCFS2_LOCK_TYPE_SUPER, 44ccd979bdSMark Fasheh OCFS2_LOCK_TYPE_RENAME, 45ccd979bdSMark Fasheh OCFS2_LOCK_TYPE_RW, 46d680efe9SMark Fasheh OCFS2_LOCK_TYPE_DENTRY, 47*50008630STiger Yang OCFS2_LOCK_TYPE_OPEN, 48ccd979bdSMark Fasheh OCFS2_NUM_LOCK_TYPES 49ccd979bdSMark Fasheh }; 50ccd979bdSMark Fasheh 51ccd979bdSMark Fasheh static inline char ocfs2_lock_type_char(enum ocfs2_lock_type type) 52ccd979bdSMark Fasheh { 53ccd979bdSMark Fasheh char c; 54ccd979bdSMark Fasheh switch (type) { 55ccd979bdSMark Fasheh case OCFS2_LOCK_TYPE_META: 56ccd979bdSMark Fasheh c = 'M'; 57ccd979bdSMark Fasheh break; 58ccd979bdSMark Fasheh case OCFS2_LOCK_TYPE_DATA: 59ccd979bdSMark Fasheh c = 'D'; 60ccd979bdSMark Fasheh break; 61ccd979bdSMark Fasheh case OCFS2_LOCK_TYPE_SUPER: 62ccd979bdSMark Fasheh c = 'S'; 63ccd979bdSMark Fasheh break; 64ccd979bdSMark Fasheh case OCFS2_LOCK_TYPE_RENAME: 65ccd979bdSMark Fasheh c = 'R'; 66ccd979bdSMark Fasheh break; 67ccd979bdSMark Fasheh case OCFS2_LOCK_TYPE_RW: 68ccd979bdSMark Fasheh c = 'W'; 69ccd979bdSMark Fasheh break; 70d680efe9SMark Fasheh case OCFS2_LOCK_TYPE_DENTRY: 71d680efe9SMark Fasheh c = 'N'; 72d680efe9SMark Fasheh break; 73*50008630STiger Yang case OCFS2_LOCK_TYPE_OPEN: 74*50008630STiger Yang c = 'O'; 75*50008630STiger Yang break; 76ccd979bdSMark Fasheh default: 77ccd979bdSMark Fasheh c = '\0'; 78ccd979bdSMark Fasheh } 79ccd979bdSMark Fasheh 80ccd979bdSMark Fasheh return c; 81ccd979bdSMark Fasheh } 82ccd979bdSMark Fasheh 83d680efe9SMark Fasheh static char *ocfs2_lock_type_strings[] = { 84d680efe9SMark Fasheh [OCFS2_LOCK_TYPE_META] = "Meta", 85d680efe9SMark Fasheh [OCFS2_LOCK_TYPE_DATA] = "Data", 86d680efe9SMark Fasheh [OCFS2_LOCK_TYPE_SUPER] = "Super", 87d680efe9SMark Fasheh [OCFS2_LOCK_TYPE_RENAME] = "Rename", 88d680efe9SMark Fasheh /* Need to differntiate from [R]ename.. serializing writes is the 89d680efe9SMark Fasheh * important job it does, anyway. */ 90d680efe9SMark Fasheh [OCFS2_LOCK_TYPE_RW] = "Write/Read", 91d680efe9SMark Fasheh [OCFS2_LOCK_TYPE_DENTRY] = "Dentry", 92*50008630STiger Yang [OCFS2_LOCK_TYPE_OPEN] = "Open", 93d680efe9SMark Fasheh }; 94d680efe9SMark Fasheh 95d680efe9SMark Fasheh static inline const char *ocfs2_lock_type_string(enum ocfs2_lock_type type) 96d680efe9SMark Fasheh { 97d680efe9SMark Fasheh #ifdef __KERNEL__ 98d680efe9SMark Fasheh mlog_bug_on_msg(type >= OCFS2_NUM_LOCK_TYPES, "%d\n", type); 99d680efe9SMark Fasheh #endif 100d680efe9SMark Fasheh return ocfs2_lock_type_strings[type]; 101d680efe9SMark Fasheh } 102d680efe9SMark Fasheh 103ccd979bdSMark Fasheh #endif /* OCFS2_LOCKID_H */ 104