1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /* -*- mode: c; c-basic-offset: 8; -*-
3 * vim: noexpandtab sw=8 ts=8 sts=0:
7 * Defines OCFS2 lockid bits.
9 * Copyright (C) 2002, 2005 Oracle. All rights reserved.
12 #ifndef OCFS2_LOCKID_H
13 #define OCFS2_LOCKID_H
15 /* lock ids are made up in the following manner:
17 * name[1-6] --> 6 pad characters, reserved for now
18 * name[7-22] --> block number, expressed in hex as 16 chars
19 * name[23-30] --> i_generation, expressed in hex 8 chars
20 * name[31] --> '\0' */
21 #define OCFS2_LOCK_ID_MAX_LEN 32
22 #define OCFS2_LOCK_ID_PAD "000000"
24 #define OCFS2_DENTRY_LOCK_INO_START 18
26 enum ocfs2_lock_type
{
27 OCFS2_LOCK_TYPE_META
= 0,
29 OCFS2_LOCK_TYPE_SUPER
,
30 OCFS2_LOCK_TYPE_RENAME
,
32 OCFS2_LOCK_TYPE_DENTRY
,
34 OCFS2_LOCK_TYPE_FLOCK
,
35 OCFS2_LOCK_TYPE_QINFO
,
36 OCFS2_LOCK_TYPE_NFS_SYNC
,
37 OCFS2_LOCK_TYPE_ORPHAN_SCAN
,
38 OCFS2_LOCK_TYPE_REFCOUNT
,
39 OCFS2_LOCK_TYPE_TRIM_FS
,
43 static inline char ocfs2_lock_type_char(enum ocfs2_lock_type type
)
47 case OCFS2_LOCK_TYPE_META
:
50 case OCFS2_LOCK_TYPE_DATA
:
53 case OCFS2_LOCK_TYPE_SUPER
:
56 case OCFS2_LOCK_TYPE_RENAME
:
59 case OCFS2_LOCK_TYPE_RW
:
62 case OCFS2_LOCK_TYPE_DENTRY
:
65 case OCFS2_LOCK_TYPE_OPEN
:
68 case OCFS2_LOCK_TYPE_FLOCK
:
71 case OCFS2_LOCK_TYPE_QINFO
:
74 case OCFS2_LOCK_TYPE_NFS_SYNC
:
77 case OCFS2_LOCK_TYPE_ORPHAN_SCAN
:
80 case OCFS2_LOCK_TYPE_REFCOUNT
:
83 case OCFS2_LOCK_TYPE_TRIM_FS
:
93 static char *ocfs2_lock_type_strings
[] = {
94 [OCFS2_LOCK_TYPE_META
] = "Meta",
95 [OCFS2_LOCK_TYPE_DATA
] = "Data",
96 [OCFS2_LOCK_TYPE_SUPER
] = "Super",
97 [OCFS2_LOCK_TYPE_RENAME
] = "Rename",
98 /* Need to differntiate from [R]ename.. serializing writes is the
99 * important job it does, anyway. */
100 [OCFS2_LOCK_TYPE_RW
] = "Write/Read",
101 [OCFS2_LOCK_TYPE_DENTRY
] = "Dentry",
102 [OCFS2_LOCK_TYPE_OPEN
] = "Open",
103 [OCFS2_LOCK_TYPE_FLOCK
] = "Flock",
104 [OCFS2_LOCK_TYPE_QINFO
] = "Quota",
105 [OCFS2_LOCK_TYPE_NFS_SYNC
] = "NFSSync",
106 [OCFS2_LOCK_TYPE_ORPHAN_SCAN
] = "OrphanScan",
107 [OCFS2_LOCK_TYPE_REFCOUNT
] = "Refcount",
108 [OCFS2_LOCK_TYPE_TRIM_FS
] = "TrimFs",
111 static inline const char *ocfs2_lock_type_string(enum ocfs2_lock_type type
)
114 BUG_ON(type
>= OCFS2_NUM_LOCK_TYPES
);
116 return ocfs2_lock_type_strings
[type
];
119 #endif /* OCFS2_LOCKID_H */