4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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
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
27 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
31 * Copyright (c) 2012, Intel Corporation.
32 * Use is subject to license terms.
35 * This file is part of Lustre, http://www.lustre.org/
36 * Lustre is a trademark of Sun Microsystems, Inc.
38 * lustre/osd-zfs/udmu.h
40 * Author: Alex Tomas <alex@clusterfs.com>
41 * Author: Atul Vidwansa <atul.vidwansa@sun.com>
42 * Author: Manoj Joseph <manoj.joseph@sun.com>
52 #include <lustre/lustre_user.h>
54 typedef struct udmu_objset {
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;
66 #define TXG_NOWAIT 2ULL
69 #define ZFS_DIRENT_MAKE(type, obj) (((uint64_t)type << 60) | obj)
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 */
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
80 #define OSD_GRANT_FOR_LOCAL_OIDS (2ULL << 20) /* 2MB for last_rcvd, ... */
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);
95 int udmu_zap_cursor_init(zap_cursor_t **zc, udmu_objset_t *uos,
96 uint64_t zapobj, uint64_t hash);
98 void udmu_zap_cursor_fini(zap_cursor_t *zc);
100 void udmu_zap_cursor_advance(zap_cursor_t *zc);
102 uint64_t udmu_zap_cursor_serialize(zap_cursor_t *zc);
104 int udmu_zap_cursor_move_to_key(zap_cursor_t *zc, const char *name);
106 /* Commit callbacks */
107 int udmu_object_is_zap(dmu_buf_t *);