blob: b4be84956bc102fa5413d86b93251f6a8bc83439 [file] [log] [blame]
Thomas Gleixner328970d2019-05-24 12:04:05 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Mark Fashehccd979b2005-12-15 14:31:24 -08002/* -*- mode: c; c-basic-offset: 8; -*-
3 * vim: noexpandtab sw=8 ts=8 sts=0:
4 *
5 * ocfs2_lockid.h
6 *
7 * Defines OCFS2 lockid bits.
8 *
9 * Copyright (C) 2002, 2005 Oracle. All rights reserved.
Mark Fashehccd979b2005-12-15 14:31:24 -080010 */
11
12#ifndef OCFS2_LOCKID_H
13#define OCFS2_LOCKID_H
14
15/* lock ids are made up in the following manner:
16 * name[0] --> type
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"
23
Mark Fashehd680efe2006-09-08 14:14:34 -070024#define OCFS2_DENTRY_LOCK_INO_START 18
25
Mark Fashehccd979b2005-12-15 14:31:24 -080026enum ocfs2_lock_type {
27 OCFS2_LOCK_TYPE_META = 0,
28 OCFS2_LOCK_TYPE_DATA,
29 OCFS2_LOCK_TYPE_SUPER,
30 OCFS2_LOCK_TYPE_RENAME,
31 OCFS2_LOCK_TYPE_RW,
Mark Fashehd680efe2006-09-08 14:14:34 -070032 OCFS2_LOCK_TYPE_DENTRY,
Tiger Yang50008632007-03-20 16:01:38 -070033 OCFS2_LOCK_TYPE_OPEN,
Mark Fashehcf8e06f2007-12-20 16:43:10 -080034 OCFS2_LOCK_TYPE_FLOCK,
Jan Kara9e33d692008-08-25 19:56:50 +020035 OCFS2_LOCK_TYPE_QINFO,
wengang wang6ca497a2009-03-06 21:29:10 +080036 OCFS2_LOCK_TYPE_NFS_SYNC,
Srinivas Eeda83273932009-06-03 17:02:55 -070037 OCFS2_LOCK_TYPE_ORPHAN_SCAN,
Tao Ma8dec98e2009-08-18 11:19:58 +080038 OCFS2_LOCK_TYPE_REFCOUNT,
Gang He4882abe2018-01-31 16:15:10 -080039 OCFS2_LOCK_TYPE_TRIM_FS,
Mark Fashehccd979b2005-12-15 14:31:24 -080040 OCFS2_NUM_LOCK_TYPES
41};
42
43static inline char ocfs2_lock_type_char(enum ocfs2_lock_type type)
44{
45 char c;
46 switch (type) {
47 case OCFS2_LOCK_TYPE_META:
48 c = 'M';
49 break;
50 case OCFS2_LOCK_TYPE_DATA:
51 c = 'D';
52 break;
53 case OCFS2_LOCK_TYPE_SUPER:
54 c = 'S';
55 break;
56 case OCFS2_LOCK_TYPE_RENAME:
57 c = 'R';
58 break;
59 case OCFS2_LOCK_TYPE_RW:
60 c = 'W';
61 break;
Mark Fashehd680efe2006-09-08 14:14:34 -070062 case OCFS2_LOCK_TYPE_DENTRY:
63 c = 'N';
64 break;
Tiger Yang50008632007-03-20 16:01:38 -070065 case OCFS2_LOCK_TYPE_OPEN:
66 c = 'O';
67 break;
Mark Fashehcf8e06f2007-12-20 16:43:10 -080068 case OCFS2_LOCK_TYPE_FLOCK:
69 c = 'F';
70 break;
Jan Kara9e33d692008-08-25 19:56:50 +020071 case OCFS2_LOCK_TYPE_QINFO:
72 c = 'Q';
73 break;
wengang wang6ca497a2009-03-06 21:29:10 +080074 case OCFS2_LOCK_TYPE_NFS_SYNC:
75 c = 'Y';
76 break;
Srinivas Eeda83273932009-06-03 17:02:55 -070077 case OCFS2_LOCK_TYPE_ORPHAN_SCAN:
78 c = 'P';
79 break;
Tao Ma8dec98e2009-08-18 11:19:58 +080080 case OCFS2_LOCK_TYPE_REFCOUNT:
81 c = 'T';
82 break;
Gang He4882abe2018-01-31 16:15:10 -080083 case OCFS2_LOCK_TYPE_TRIM_FS:
84 c = 'I';
85 break;
Mark Fashehccd979b2005-12-15 14:31:24 -080086 default:
87 c = '\0';
88 }
89
90 return c;
91}
92
Mark Fashehd680efe2006-09-08 14:14:34 -070093static 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",
Tiger Yang50008632007-03-20 16:01:38 -0700102 [OCFS2_LOCK_TYPE_OPEN] = "Open",
Mark Fashehcf8e06f2007-12-20 16:43:10 -0800103 [OCFS2_LOCK_TYPE_FLOCK] = "Flock",
Jan Kara9e33d692008-08-25 19:56:50 +0200104 [OCFS2_LOCK_TYPE_QINFO] = "Quota",
Jan Karaa8b88d32009-08-20 18:26:52 +0200105 [OCFS2_LOCK_TYPE_NFS_SYNC] = "NFSSync",
Srinivas Eeda83273932009-06-03 17:02:55 -0700106 [OCFS2_LOCK_TYPE_ORPHAN_SCAN] = "OrphanScan",
Tao Ma8dec98e2009-08-18 11:19:58 +0800107 [OCFS2_LOCK_TYPE_REFCOUNT] = "Refcount",
Gang He4882abe2018-01-31 16:15:10 -0800108 [OCFS2_LOCK_TYPE_TRIM_FS] = "TrimFs",
Mark Fashehd680efe2006-09-08 14:14:34 -0700109};
110
111static inline const char *ocfs2_lock_type_string(enum ocfs2_lock_type type)
112{
113#ifdef __KERNEL__
Joel Becker8f318312008-03-04 16:09:39 -0800114 BUG_ON(type >= OCFS2_NUM_LOCK_TYPES);
Mark Fashehd680efe2006-09-08 14:14:34 -0700115#endif
116 return ocfs2_lock_type_strings[type];
117}
118
Mark Fashehccd979b2005-12-15 14:31:24 -0800119#endif /* OCFS2_LOCKID_H */