1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (c) 2006 Cluster File Systems, Inc.
5 * Author: Alex Tomas <alex@clusterfs.com>
6 * Author: Atul Vidwansa <atul.vidwansa@sun.com>
7 * Author: Manoj Joseph <manoj.joseph@sun.com>
9 * This file is part of the Lustre file system, http://www.lustre.org
10 * Lustre is a trademark of Cluster File Systems, Inc.
12 * You may have signed or agreed to another license before downloading
13 * this software. If so, you are bound by the terms and conditions
14 * of that agreement, and the following does not apply to you. See the
15 * LICENSE file included with this distribution for more information.
17 * If you did not agree to a different license, then this copy of Lustre
18 * is open source software; you can redistribute it and/or modify it
19 * under the terms of version 2 of the GNU General Public License as
20 * published by the Free Software Foundation.
22 * In either case, Lustre is distributed in the hope that it will be
23 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
24 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * license text for more details.
37 #define LUSTRE_ZPL_VERSION 1ULL
40 #define AT_TYPE 0x0001
41 #define AT_MODE 0x0002
44 #define AT_FSID 0x0010
45 #define AT_NODEID 0x0020
46 #define AT_NLINK 0x0040
47 #define AT_SIZE 0x0080
48 #define AT_ATIME 0x0100
49 #define AT_MTIME 0x0200
50 #define AT_CTIME 0x0400
51 #define AT_RDEV 0x0800
52 #define AT_BLKSIZE 0x1000
53 #define AT_NBLOCKS 0x2000
57 #define ACCESSED (AT_ATIME)
58 #define STATE_CHANGED (AT_CTIME)
59 #define CONTENT_MODIFIED (AT_MTIME | AT_CTIME)
61 #define LOOKUP_DIR 0x01 /* want parent dir vp */
62 #define LOOKUP_XATTR 0x02 /* lookup up extended attr dir */
63 #define CREATE_XATTR_DIR 0x04 /* Create extended attr dir */
65 #define S_IFDOOR 0xD000 /* door */
66 #define S_IFPORT 0xE000 /* event port */
70 /* Data structures required for Solaris ZFS compatability */
73 #ifndef _SOL_SYS_TIME_H
74 typedef struct timespec timestruc_t;
94 typedef struct vnattr {
95 unsigned int va_mask; /* bit-mask of attributes */
96 vtype_t va_type; /* vnode type (for create) */
97 mode_t va_mode; /* file access mode */
98 uid_t va_uid; /* owner user id */
99 gid_t va_gid; /* owner group id */
100 dev_t va_fsid; /* file system id (dev for now) */
101 unsigned long long va_nodeid; /* node id */
102 nlink_t va_nlink; /* number of references to file */
103 off_t va_size; /* file size in bytes */
104 timestruc_t va_atime; /* time of last access */
105 timestruc_t va_mtime; /* time of last modification */
106 timestruc_t va_ctime; /* time of last status change */
107 dev_t va_rdev; /* device the file represents */
108 unsigned int va_blksize; /* fundamental block size */
109 unsigned int va_blkbits;
110 unsigned long long va_nblocks; /* # of blocks allocated */
111 unsigned int va_seq; /* sequence number */
114 typedef struct udmu_objset {
117 uint64_t root; /* id of root znode */
118 uint64_t unlinkedobj;
122 /* definitions from dmu.h */
125 typedef struct objset objset_t;
126 typedef struct dmu_tx dmu_tx_t;
127 typedef struct dmu_buf dmu_buf_t;
129 #define DMU_NEW_OBJECT (-1ULL)
130 #define DMU_OBJECT_END (-1ULL)
135 #define TXG_WAIT 1ULL
136 #define TXG_NOWAIT 2ULL
139 #define ZFS_DIRENT_MAKE(type, obj) (((uint64_t)type << 60) | obj)
141 #define FTAG ((char *)__func__)
147 void udmu_debug(int level);
149 /* udmu object-set API */
151 int udmu_objset_open(char *osname, char *import_dir, int import, int force, udmu_objset_t *uos);
153 void udmu_objset_close(udmu_objset_t *uos, int export_pool);
155 int udmu_objset_statvfs(udmu_objset_t *uos, struct statvfs64 *statp);
157 int udmu_objset_root(udmu_objset_t *uos, dmu_buf_t **dbp, void *tag);
159 void udmu_wait_synced(udmu_objset_t *uos, dmu_tx_t *tx);
163 int udmu_zap_lookup(udmu_objset_t *uos, dmu_buf_t *zap_db, const char *name,
164 void *value, int value_size, int intsize);
166 void udmu_zap_create(udmu_objset_t *uos, dmu_buf_t **zap_dbp, dmu_tx_t *tx, void *tag);
168 int udmu_zap_insert(udmu_objset_t *uos, dmu_buf_t *zap_db, dmu_tx_t *tx,
169 const char *name, void *value, int len);
171 int udmu_zap_delete(udmu_objset_t *uos, dmu_buf_t *zap_db, dmu_tx_t *tx,
174 /* udmu object API */
176 void udmu_object_create(udmu_objset_t *uos, dmu_buf_t **dbp, dmu_tx_t *tx, void *tag);
178 int udmu_object_get_dmu_buf(udmu_objset_t *uos, uint64_t object,
179 dmu_buf_t **dbp, void *tag);
181 void udmu_object_put_dmu_buf(dmu_buf_t *db, void *tag);
183 uint64_t udmu_object_get_id(dmu_buf_t *db);
185 int udmu_object_read(udmu_objset_t *uos, dmu_buf_t *db, uint64_t offset,
186 uint64_t size, void *buf);
188 void udmu_object_write(udmu_objset_t *uos, dmu_buf_t *db, struct dmu_tx *tx,
189 uint64_t offset, uint64_t size, void *buf);
191 void udmu_object_getattr(dmu_buf_t *db, vnattr_t *vap);
193 void udmu_object_setattr(dmu_buf_t *db, dmu_tx_t *tx, vnattr_t *vap);
195 void udmu_object_punch(udmu_objset_t *uos, dmu_buf_t *db, dmu_tx_t *tx,
196 uint64_t offset, uint64_t len);
198 int udmu_object_delete(udmu_objset_t *uos, dmu_buf_t **db, dmu_tx_t *tx, void *tag);
200 /*udmu transaction API */
202 dmu_tx_t *udmu_tx_create(udmu_objset_t *uos);
204 void udmu_tx_hold_write(dmu_tx_t *tx, uint64_t object, uint64_t off, int len);
206 void udmu_tx_hold_free(dmu_tx_t *tx, uint64_t object, uint64_t off,
209 void udmu_tx_hold_zap(dmu_tx_t *tx, uint64_t object, int add, char *name);
211 void udmu_tx_hold_bonus(dmu_tx_t *tx, uint64_t object);
213 void udmu_tx_abort(dmu_tx_t *tx);
215 int udmu_tx_assign(dmu_tx_t *tx, uint64_t txg_how);
217 void udmu_tx_wait(dmu_tx_t *tx);
219 int udmu_indblk_overhead(dmu_buf_t *db, unsigned long *used,
220 unsigned long *overhead);
222 void udmu_tx_commit(dmu_tx_t *tx);
224 void * udmu_tx_cb_create(size_t bytes);
226 int udmu_tx_cb_add(dmu_tx_t *tx, void *func, void *data);
228 int udmu_tx_cb_destroy(void *data);
230 int udmu_object_is_zap(dmu_buf_t *);
232 int udmu_indblk_overhead(dmu_buf_t *db, unsigned long *used, unsigned
235 int udmu_get_blocksize(dmu_buf_t *db, long *blksz);