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