DragonFly hammer List (threaded) for 2009-05
DragonFly BSD
DragonFly hammer List (threaded) for 2009-05
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: Resolving data_offset and data_len


From: Matthew Dillon <dillon@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 27 May 2009 14:38:51 -0700 (PDT)

:Hello,
:
:I am currently implementing the `read' call in Linux VFS.
:
:I have a variable of type `struct hammer_inode' and I would like to get
:the file's offset and length, so I can fetch it from disk using sb_bread().
:
:The field `ino_leaf' contains `data_offset' and `data_len', which is
:what I am looking for. But these fields currently contain incorrect data.
:
:I am retrieving the `struct hammer_inode' using a call to
:hammer_get_inode(). I tried inserting hammer_ip_resolve_data(&cursor)
:somewhere into that function, but that didn't help and `ino_leaf' still
:contains incorrect data.
:
:Any hints or advice?
:
:Daniel

    The code you want to examine is hammer_vop_strategy_read().  This
    is the core function used by DragonFly to read data from a file.  It
    performs the B-Tree operations necessary to collect the data into
    a buffer.

    Reading the data via the B-Tree is a bit confusing because data_offset 
    in a B-Tree element is *NOT* the base offset for the data block but
    instead the ending offset for the data block.  i.e. the offset in
    the file for the data is actually (cursor.leaf->data_offset -
    cursor.leaf->data_len).

    The other confusing bit is that HAMMER uses data extents.  Even though
    they aren't completely dynamic they must still be considered
    variable-length, so collecting a buffer requires a B-Tree traversal
    for the offset range.

    You should be able to adapt the hammer_vop_strategy_read() code for
    linux, it does all the hard work.

					-Matt
					Matthew Dillon 
					<dillon@backplane.com>



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]