Update core ZFS code from build 121 to build 141.
[zfs.git] / module / zfs / include / sys / dnode.h
index 48e4da8..8bae160 100644 (file)
@@ -19,8 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 #ifndef        _SYS_DNODE_H
@@ -63,6 +62,18 @@ extern "C" {
 #define        DN_MAX_OFFSET_SHIFT     64      /* 2^64 bytes in a dnode */
 
 /*
+ * dnode id flags
+ *
+ * Note: a file will never ever have its
+ * ids moved from bonus->spill
+ * and only in a crypto environment would it be on spill
+ */
+#define        DN_ID_CHKED_BONUS       0x1
+#define        DN_ID_CHKED_SPILL       0x2
+#define        DN_ID_OLD_EXIST         0x4
+#define        DN_ID_NEW_EXIST         0x8
+
+/*
  * Derived constants.
  */
 #define        DNODE_SIZE      (1 << DNODE_SHIFT)
@@ -70,10 +81,12 @@ extern "C" {
 #define        DN_MAX_BONUSLEN (DNODE_SIZE - DNODE_CORE_SIZE - (1 << SPA_BLKPTRSHIFT))
 #define        DN_MAX_OBJECT   (1ULL << DN_MAX_OBJECT_SHIFT)
 #define        DN_ZERO_BONUSLEN        (DN_MAX_BONUSLEN + 1)
+#define        DN_KILL_SPILLBLK (1)
 
 #define        DNODES_PER_BLOCK_SHIFT  (DNODE_BLOCK_SHIFT - DNODE_SHIFT)
 #define        DNODES_PER_BLOCK        (1ULL << DNODES_PER_BLOCK_SHIFT)
 #define        DNODES_PER_LEVEL_SHIFT  (DN_MAX_INDBLKSHIFT - SPA_BLKPTRSHIFT)
+#define        DNODES_PER_LEVEL        (1ULL << DNODES_PER_LEVEL_SHIFT)
 
 /* The +2 here is a cheesy way to round up */
 #define        DN_MAX_LEVELS   (2 + ((DN_MAX_OFFSET_SHIFT - SPA_MINBLOCKSHIFT) / \
@@ -88,7 +101,7 @@ extern "C" {
 #define        EPB(blkshift, typeshift)        (1 << (blkshift - typeshift))
 
 struct dmu_buf_impl;
-struct objset_impl;
+struct objset;
 struct zio;
 
 enum dnode_dirtycontext {
@@ -101,6 +114,9 @@ enum dnode_dirtycontext {
 #define        DNODE_FLAG_USED_BYTES           (1<<0)
 #define        DNODE_FLAG_USERUSED_ACCOUNTED   (1<<1)
 
+/* Does dnode have a SA spill blkptr in bonus? */
+#define        DNODE_FLAG_SPILL_BLKPTR (1<<2)
+
 typedef struct dnode_phys {
        uint8_t dn_type;                /* dmu_object_type_t */
        uint8_t dn_indblkshift;         /* ln2(indirect block size) */
@@ -121,7 +137,8 @@ typedef struct dnode_phys {
        uint64_t dn_pad3[4];
 
        blkptr_t dn_blkptr[1];
-       uint8_t dn_bonus[DN_MAX_BONUSLEN];
+       uint8_t dn_bonus[DN_MAX_BONUSLEN - sizeof (blkptr_t)];
+       blkptr_t dn_spill;
 } dnode_phys_t;
 
 typedef struct dnode {
@@ -136,7 +153,7 @@ typedef struct dnode {
        list_node_t dn_link;
 
        /* immutable: */
-       struct objset_impl *dn_objset;
+       struct objset *dn_objset;
        uint64_t dn_object;
        struct dmu_buf_impl *dn_dbuf;
        dnode_phys_t *dn_phys; /* pointer into dn->dn_dbuf->db.db_data */
@@ -161,6 +178,8 @@ typedef struct dnode {
        uint8_t dn_next_nblkptr[TXG_SIZE];
        uint8_t dn_next_nlevels[TXG_SIZE];
        uint8_t dn_next_indblkshift[TXG_SIZE];
+       uint8_t dn_next_bonustype[TXG_SIZE];
+       uint8_t dn_rm_spillblk[TXG_SIZE];       /* for removing spill blk */
        uint16_t dn_next_bonuslen[TXG_SIZE];
        uint32_t dn_next_blksz[TXG_SIZE];       /* next block size in bytes */
 
@@ -185,12 +204,17 @@ typedef struct dnode {
        kmutex_t dn_dbufs_mtx;
        list_t dn_dbufs;                /* linked list of descendent dbuf_t's */
        struct dmu_buf_impl *dn_bonus;  /* bonus buffer dbuf */
+       boolean_t dn_have_spill;        /* have spill or are spilling */
 
        /* parent IO for current sync write */
        zio_t *dn_zio;
 
        /* used in syncing context */
-       dnode_phys_t *dn_oldphys;
+       uint64_t dn_oldused;    /* old phys used bytes */
+       uint64_t dn_oldflags;   /* old phys dn_flags */
+       uint64_t dn_olduid, dn_oldgid;
+       uint64_t dn_newuid, dn_newgid;
+       int dn_id_flags;
 
        /* holds prefetch structure */
        struct zfetch   dn_zfetch;
@@ -202,14 +226,17 @@ typedef struct free_range {
        uint64_t fr_nblks;
 } free_range_t;
 
-dnode_t *dnode_special_open(struct objset_impl *dd, dnode_phys_t *dnp,
+dnode_t *dnode_special_open(struct objset *dd, dnode_phys_t *dnp,
     uint64_t object);
 void dnode_special_close(dnode_t *dn);
 
 void dnode_setbonuslen(dnode_t *dn, int newsize, dmu_tx_t *tx);
-int dnode_hold(struct objset_impl *dd, uint64_t object,
+void dnode_setbonus_type(dnode_t *dn, dmu_object_type_t, dmu_tx_t *tx);
+void dnode_rm_spill(dnode_t *dn, dmu_tx_t *tx);
+
+int dnode_hold(struct objset *dd, uint64_t object,
     void *ref, dnode_t **dnp);
-int dnode_hold_impl(struct objset_impl *dd, uint64_t object, int flag,
+int dnode_hold_impl(struct objset *dd, uint64_t object, int flag,
     void *ref, dnode_t **dnp);
 boolean_t dnode_add_ref(dnode_t *dn, void *ref);
 void dnode_rele(dnode_t *dn, void *ref);