]> git.saurik.com Git - apple/xnu.git/blob - bsd/hfs/hfs_hotfiles.h
xnu-792.12.6.tar.gz
[apple/xnu.git] / bsd / hfs / hfs_hotfiles.h
1 /*
2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 #ifndef __HFS_HOTFILES__
31 #define __HFS_HOTFILES__
32
33 #include <sys/appleapiopts.h>
34
35 #ifdef KERNEL
36 #ifdef __APPLE_API_PRIVATE
37
38
39 #define HFC_FILENAME ".hotfiles.btree"
40
41
42 /*
43 * Temperature measurement constraints.
44 */
45 #define HFC_DEFAULT_FILE_COUNT 1000
46 #define HFC_DEFAULT_DURATION (3600 * 60)
47 #define HFC_CUMULATIVE_CYCLES 4
48 #define HFC_MAXIMUM_FILE_COUNT 5000
49 #define HFC_MAXIMUM_FILESIZE (10 * 1024 * 1024)
50 #define HFC_MINIMUM_TEMPERATURE 24
51
52
53 /*
54 * Sync constraints.
55 */
56 #define HFC_BLKSPERSYNC 300
57 #define HFC_FILESPERSYNC 50
58
59
60 /*
61 * Hot file clustering stages.
62 */
63 enum hfc_stage {
64 HFC_DISABLED,
65 HFC_IDLE,
66 HFC_BUSY,
67 HFC_RECORDING,
68 HFC_EVALUATION,
69 HFC_EVICTION,
70 HFC_ADOPTION,
71 };
72
73
74 /*
75 * B-tree file key format (on-disk).
76 */
77 struct HotFileKey {
78 u_int16_t keyLength; /* length of key, excluding this field */
79 u_int8_t forkType; /* 0 = data fork, FF = resource fork */
80 u_int8_t pad; /* make the other fields align on 32-bit boundary */
81 u_int32_t temperature; /* temperature recorded */
82 u_int32_t fileID; /* file ID */
83 };
84 typedef struct HotFileKey HotFileKey;
85
86 #define HFC_LOOKUPTAG 0xFFFFFFFF
87 #define HFC_KEYLENGTH (sizeof(HotFileKey) - sizeof(u_int16_t))
88
89 /*
90 * B-tree header node user info (on-disk).
91 */
92 struct HotFilesInfo {
93 u_int32_t magic;
94 u_int32_t version;
95 u_int32_t duration; /* duration of sample period */
96 u_int32_t timebase; /* recording period start time */
97 u_int32_t timeleft; /* recording period stop time */
98 u_int32_t threshold;
99 u_int32_t maxfileblks;
100 u_int32_t maxfilecnt;
101 u_int8_t tag[32];
102 };
103 typedef struct HotFilesInfo HotFilesInfo;
104
105 #define HFC_MAGIC 0xFF28FF26
106 #define HFC_VERSION 1
107
108
109 struct hfsmount;
110 struct proc;
111 struct vnode;
112
113 /*
114 * Hot File interface functions.
115 */
116 int hfs_hotfilesync (struct hfsmount *, struct proc *);
117
118 int hfs_recording_init(struct hfsmount *);
119 int hfs_recording_suspend (struct hfsmount *);
120
121 int hfs_addhotfile (struct vnode *);
122 int hfs_removehotfile (struct vnode *);
123
124 int hfs_relocate(struct vnode *, u_int32_t, kauth_cred_t, struct proc *);
125
126
127 #endif /* __APPLE_API_PRIVATE */
128 #endif /* KERNEL */
129 #endif /* __HFS_HOTFILES__ */