dmu_buf

2012/10/21

dmu_buf 定義

typedef struct dmu_buf {
        uint64_t db_object;         /* この buffer が所属する object */
        uint64_t db_offset;         /* この object 中の byte offset */
        uint64_t db_size;           /* buffer のサイズ(byte) */
       void *db_data;              /* buffer 中の data */
} dmu_buf_t;

dmu_buf_impl 定義

typedef struct dmu_buf_impl {
        /*
         * 以下のメンバーは db_mtx によって保護されており、
         * db.db_data を除いて、不変です。
         */

        /* 公開されるている構造体 */
        dmu_buf_t db;

        /* 所属する objset */
        struct objset *db_objset;

        /*
         * dnode に安全にアクセスするための handle (NULL when evicted)
         */
        struct dnode_handle *db_dnode_handle;

        /*
         * our parent buffer; if the dnode points to us directly,
         * db_parent == db_dnode_handle->dnh_dnode->dn_dbuf
         * only accessed by sync thread ???
         * (NULL when evicted)
         * May change from NULL to non-NULL under the protection of db_mtx
         * (see dbuf_check_blkptr())
         */
        struct dmu_buf_impl *db_parent;

        /*
         * link for hash table of all dmu_buf_impl_t's
         */
        struct dmu_buf_impl *db_hash_next;

        /* our block number */
        uint64_t db_blkid;

        /*
         * Pointer to the blkptr_t which points to us. May be NULL if we
         * don't have one yet. (NULL when evicted)
         */
        blkptr_t *db_blkptr;

        /*
         * Our indirection level.  Data buffers have db_level==0.
         * Indirect buffers which point to data buffers have
         * db_level==1. etc.  Buffers which contain dnodes have
         * db_level==0, since the dnodes are stored in a file.
         */
        uint8_t db_level;

        /* db_mtx protects the members below */
        kmutex_t db_mtx;

        /*
         * Current state of the buffer
         */
        dbuf_states_t db_state;

        /*
         * Refcount accessed by dmu_buf_{hold,rele}.
         * If nonzero, the buffer can't be destroyed.
         * Protected by db_mtx.
         */
        refcount_t db_holds;

        /* buffer holding our data */
        arc_buf_t *db_buf;

        kcondvar_t db_changed;
        dbuf_dirty_record_t *db_data_pending;

        /* pointer to most recent dirty record for this buffer */
        dbuf_dirty_record_t *db_last_dirty;

        /*
         * Our link on the owner dnodes's dn_dbufs list.
         * Protected by its dn_dbufs_mtx.
         */
        list_node_t db_link;

        /* Data which is unique to data (leaf) blocks: */

        /* stuff we store for the user (see dmu_buf_set_user) */
        void *db_user_ptr;
        void **db_user_data_ptr_ptr;
        dmu_buf_evict_func_t *db_evict_func;

        uint8_t db_immediate_evict;
        uint8_t db_freed_in_flight;

        uint8_t db_dirtycnt;
} dmu_buf_impl_t;

サンプルデータ

# mdb -k
> !ls -li /var/adm
total 14144
      1067 drwxrwxr-x   5 adm      adm            5 10月 21日 2011年 acct
      6155 -rw-------   1 uucp     bin            0 10月 21日 2011年 aculog
      1070 drwxr-xr-x   2 adm      adm            4  7月 25日  16:58 exacct
     12389 -r--r--r--   1 root     root          28 10月 19日  16:13 lastlog
      1068 drwxr-xr-x   2 adm      adm            2 10月 21日 2011年 log
    438616 -rw-r--r--   1 root     root           0 10月 17日  03:10 messages
    438556 -rw-r--r--   1 root     root        3566 10月 16日  11:35 messages.0
    438505 -rw-r--r--   1 root     root        1242 10月  9日  11:00 messages.1
    438452 -rw-r--r--   1 root     root         133  9月 28日  18:08 messages.2
    413763 -rw-r--r--   1 root     root      241942  9月 25日  16:24 messages.3
      1069 drwxr-xr-x   2 root     sys            2 10月 21日 2011年 pool
      1066 drwxrwxr-x   2 adm      sys            2 10月 21日 2011年 sa
      1064 drwxr-xr-x   2 root     sys            2 10月 21日 2011年 sm.bin
      1065 drwxr-xr-x   2 root     sys            2 10月 21日 2011年 streams
    315396 -rw-------   1 root     root        1366  3月 20日 2000年 sulog
      6154 lrwxrwxrwx   1 root     root          27  2月 21日 2012年 utmpx -> ../../system/volatile/utmpx
      6153 -rw-r--r--   1 adm      adm      6818760 10月 19日  16:13 wtmpx
> ::dbufs -n rpool/ROOT/solaris-4/var -o 0t438556
0x3001e0aa1c8
0x3082ab43e18
> 0x3001e0aa1c8::dbuf
        addr object lvl blkid holds os
3001e0aa1c8    6b11c 0     bonus  1 rpool/ROOT/solaris-4/var
> 3001e0aa1c8::print -a dmu_buf_impl_t
3001e0aa1c8 {
    3001e0aa1c8 db = {
        3001e0aa1c8 db_object = 0x6b11c
        3001e0aa1d0 db_offset = 0xffffffffffffffff
        3001e0aa1d8 db_size = 0x140
        3001e0aa1e0 db_data = 0x30010943800
    }
    3001e0aa1e8 db_objset = 0x300121fdb80
    3001e0aa1f0 db_dnode_handle = 0x3082b0650d0
    3001e0aa1f8 db_parent = 0x30a662dc9e0
    3001e0aa200 db_hash_next = 0
    3001e0aa208 db_blkid = 0xffffffffffffffff
    3001e0aa210 db_blkoff = 0
    3001e0aa214 db_level = 0
    3001e0aa218 db_mtx = {
        3001e0aa218 _opaque = [ 0 ]
    }
    3001e0aa220 db_birth = 0
    3001e0aa228 db_state = 4 (DB_CACHED)
    3001e0aa230 db_holds = {
        3001e0aa230 rc_count = 0x1
    }
    3001e0aa238 db_writers_waiting = 0
    3001e0aa240 db_ref = 0x3001200fdf0
    3001e0aa248 db_changed = {
        3001e0aa248 _opaque = 0
    }
    3001e0aa250 db_last_dirty = 0
    3001e0aa258 db_data_pending = 0
    3001e0aa260 db_link = {
        3001e0aa260 list_next = 0
        3001e0aa268 list_prev = 0
    }
    3001e0aa270 db_user_ptr = 0x300153f27d8
    3001e0aa278 db_user_data_ptr_ptr = 0
    3001e0aa280 db_evict_func = sa_evict
    3001e0aa288 db_immediate_evict = 0x1
    3001e0aa289 db_freed_in_flight = 0
    3001e0aa28a db_managed = 0x1
    3001e0aa28b db_dirtycnt = 0
}

0 件のコメント:

コメントを投稿