Whamcloud - gitweb
LU-3903 osd-zfs: Remove dead property handling code
[fs/lustre-release.git] / lustre / osd-zfs / udmu.h
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; If not, see
18  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
19  *
20  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21  * CA 95054 USA or visit www.sun.com if you need additional information or
22  * have any questions.
23  *
24  * GPL HEADER END
25  */
26 /*
27  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
28  * Use is subject to license terms.
29  */
30 /*
31  * Copyright (c) 2012, Intel Corporation.
32  * Use is subject to license terms.
33  */
34 /*
35  * This file is part of Lustre, http://www.lustre.org/
36  * Lustre is a trademark of Sun Microsystems, Inc.
37  *
38  * lustre/osd-zfs/udmu.h
39  *
40  * Author: Alex Tomas <alex@clusterfs.com>
41  * Author: Atul Vidwansa <atul.vidwansa@sun.com>
42  * Author: Manoj Joseph <manoj.joseph@sun.com>
43  */
44
45 #ifndef _DMU_H
46 #define _DMU_H
47
48 #include <sys/zap.h>
49 #include <sys/mode.h>
50 #include <sys/sa.h>
51
52 #include <lustre/lustre_user.h>
53
54 typedef struct udmu_objset {
55         struct objset   *os;
56         uint64_t        root;  /* id of root znode */
57         spinlock_t      lock;  /* protects objects below */
58         uint64_t        objects; /* in-core counter of objects */
59         /* SA attr mapping->id,
60          * name is the same as in ZFS to use defines SA_ZPL_...*/
61         sa_attr_type_t *z_attr_table;
62 } udmu_objset_t;
63
64 #ifndef _SYS_TXG_H
65 #define TXG_WAIT        1ULL
66 #define TXG_NOWAIT      2ULL
67 #endif
68
69 #define ZFS_DIRENT_MAKE(type, obj) (((uint64_t)type << 60) | obj)
70
71 /* Statfs space reservation for grant, fragmentation, and unlink space. */
72 #define OSD_STATFS_RESERVED_BLKS  (1ULL << (22 - SPA_MAXBLOCKSHIFT)) /* 4MB */
73 #define OSD_STATFS_RESERVED_SHIFT (7)         /* reserve 0.78% of all space */
74
75 /* Statfs {minimum, safe estimate, and maximum} dnodes per block */
76 #define OSD_DNODE_MIN_BLKSHIFT (SPA_MAXBLOCKSHIFT - DNODE_SHIFT) /* 17-9 =8 */
77 #define OSD_DNODE_EST_BLKSHIFT (SPA_MAXBLOCKSHIFT - 12)          /* 17-12=5 */
78 #define OSD_DNODE_EST_COUNT    1024
79
80 #define OSD_GRANT_FOR_LOCAL_OIDS (2ULL << 20) /* 2MB for last_rcvd, ... */
81
82 void udmu_init(void);
83 void udmu_fini(void);
84
85 /* udmu object-set API */
86 int udmu_objset_open(char *osname, udmu_objset_t *uos);
87 void udmu_objset_close(udmu_objset_t *uos);
88 int udmu_objset_statfs(udmu_objset_t *uos, struct obd_statfs *osfs);
89 uint64_t udmu_objset_user_iused(udmu_objset_t *uos, uint64_t uidbytes);
90 int udmu_objset_root(udmu_objset_t *uos, dmu_buf_t **dbp, void *tag);
91 uint64_t udmu_get_txg(udmu_objset_t *uos, dmu_tx_t *tx);
92 int udmu_blk_insert_cost(void);
93
94 /* zap cursor apis */
95 int udmu_zap_cursor_init(zap_cursor_t **zc, udmu_objset_t *uos,
96                 uint64_t zapobj, uint64_t hash);
97
98 void udmu_zap_cursor_fini(zap_cursor_t *zc);
99
100 void udmu_zap_cursor_advance(zap_cursor_t *zc);
101
102 uint64_t udmu_zap_cursor_serialize(zap_cursor_t *zc);
103
104 int udmu_zap_cursor_move_to_key(zap_cursor_t *zc, const char *name);
105
106 /* Commit callbacks */
107 int udmu_object_is_zap(dmu_buf_t *);
108
109 #endif /* _DMU_H */