class VnodeMinfs

Defined at line 53 of file ../../src/storage/minfs/vnode.h

An abstract Vnode class contains the following:

- A VMO, holding the in-memory representation of data stored persistently.

- An inode, holding the root of this node's metadata.

This class is capable of writing, reading, and truncating the node's data

in a linear block-address space.

Public Methods

bool IsUnlinked ()

Defined at line 74 of file ../../src/storage/minfs/vnode.h

const Inode * GetInode ()

Defined at line 76 of file ../../src/storage/minfs/vnode.h

Inode * GetMutableInode ()

Defined at line 77 of file ../../src/storage/minfs/vnode.h

ino_t GetIno ()

Defined at line 78 of file ../../src/storage/minfs/vnode.h

ino_t GetKey ()

Defined at line 80 of file ../../src/storage/minfs/vnode.h

void SetNextInode (ino_t ino)

Defined at line 84 of file ../../src/storage/minfs/vnode.h

void SetLastInode (ino_t ino)

Defined at line 85 of file ../../src/storage/minfs/vnode.h

void MarkPurged ()

Defined at line 89 of file ../../src/storage/minfs/vnode.h

size_t GetHash (ino_t key)

Defined at line 91 of file ../../src/storage/minfs/vnode.h

void fbl_recycle ()

Required for memory management, see the class comment above Vnode for more.

Defined at line 96 of file ../../src/storage/minfs/vnode.h

zx::unowned_vmo vmo ()

Returns a copy of unowned vmo.

Defined at line 164 of file ../../src/storage/minfs/vnode.h

Minfs * Vfs ()

Defined at line 173 of file ../../src/storage/minfs/vnode.h

void VnodeMinfs (Minfs * fs)

Defined at line 605 of file ../../src/storage/minfs/vnode.cc

void ~VnodeMinfs ()

Defined at line 308 of file ../../src/storage/minfs/vnode.cc

void Allocate (Minfs * fs, uint32_t type, fbl::RefPtr<VnodeMinfs> * out)

Allocates a new Vnode and initializes the in-memory inode structure given the type, where

type is one of:

- kMinfsTypeFile

- kMinfsTypeDir

Sets create / modify times of the new node.

Does not allocate an inode number for the Vnode.

Defined at line 619 of file ../../src/storage/minfs/vnode.cc

void Recreate (Minfs * fs, ino_t ino, fbl::RefPtr<VnodeMinfs> * out)

Allocates a Vnode, loading |ino| from storage.

Doesn't update create / modify times of the node.

Defined at line 637 of file ../../src/storage/minfs/vnode.cc

void SetIno (ino_t ino)

Should only be called once for the VnodeMinfs lifecycle.

Defined at line 40 of file ../../src/storage/minfs/vnode.cc

void AddLink ()

Defined at line 45 of file ../../src/storage/minfs/vnode.cc

zx::result<> CanUnlink ()

Queries the underlying vnode to ask if it may be unlinked.

If the response is not ZX_OK, operations to unlink (or rename on top of) this

vnode will fail.

zx::result<> RemoveUnlinked ()

Removes from disk an unlinked and closed vnode. Asserts that inode IsUnlinked().

Defined at line 340 of file ../../src/storage/minfs/vnode.cc

zx::result<> FlushCachedWrites ()

Issues a write on all dirty bytes within a vnode.

void DropCachedWrites ()

Discards all the dirty bytes within a vnode.

This also drops any inode or block reservation a vnode might have.

blk_t GetBlockCount ()

Returns the current block count of the vnode.

uint64_t GetSize ()

Returns the total size of the vnode.

bool IsDirectory ()

Returns if the node is a directory.

void SetSize (uint32_t new_size)

Sets the new size of the vnode.

Should update the in-memory representation of the Vnode, but not necessarily

write it out to persistent storage.

TODO(unknown): Upgrade internal size to 64-bit integer.

void AcquireWritableBlock (Transaction * transaction, blk_t vmo_offset, blk_t dev_offset, blk_t * out_dev_offset)

Accesses a block in the vnode at |vmo_offset| relative to the start of the file,

which was previously at the device offset |dev_offset|.

If the block was not previously allocated, |dev_offset| is zero.

|*out_dev_offset| must contain the new value of the device offset to use when writing

to this part of the Vnode. By default, it is set to |dev_offset|.

|*out_dev_offset| may be passed to |IssueWriteback| as |dev_offset|.

void DeleteBlock (PendingWork * transaction, blk_t vmo_offset, blk_t dev_offset, bool indirect)

Deletes the block at |vmo_offset| within the file, corresponding to on-disk block

|dev_offset| (zero if unallocated). |indirect| specifies whether the block is a direct or

indirect block.

void IssueWriteback (Transaction * transaction, blk_t vmo_offset, blk_t dev_offset, blk_t count)

Instructs the Vnode to write out |count| blocks of the vnode, starting at local

offset |vmo_offset|, corresponding to on-disk offset |dev_offset|.

bool HasPendingAllocation (blk_t vmo_offset)

Queries the node, returning |true| if the node has an in-flight operation on |vmo_offset|

that has not yet been enqueued to the writeback pipeline.

void CancelPendingWriteback ()

Instructs the node to cancel all pending writeback operations that have not yet been

enqueued to the writeback pipeline.

This method is used exclusively when deleting nodes.

bool DirtyCacheEnabled ()

Returns true if dirty pages can be cached.

bool IsDirty ()

Returns true if the vnode needs to be flushed.

zx::result<> ReadInternal (PendingWork * transaction, void * data, size_t len, size_t off, size_t * actual)

Internal read. Usable on directories.

Defined at line 387 of file ../../src/storage/minfs/vnode.cc

zx::result<> ReadExactInternal (PendingWork * transaction, void * data, size_t len, size_t off)

Defined at line 208 of file ../../src/storage/minfs/vnode.cc

zx::result<> WriteInternal (Transaction * transaction, const uint8_t * data, size_t len, size_t off, size_t * actual)

Internal write. Usable on directories.

Defined at line 447 of file ../../src/storage/minfs/vnode.cc

zx::result<> WriteExactInternal (Transaction * transaction, const void * data, size_t len, size_t off)

Defined at line 221 of file ../../src/storage/minfs/vnode.cc

zx::result<> TruncateInternal (Transaction * transaction, size_t len)

Defined at line 651 of file ../../src/storage/minfs/vnode.cc

void InodeSync (PendingWork * transaction, uint32_t flags)

Update the vnode's inode and write it to disk.

Defined at line 49 of file ../../src/storage/minfs/vnode.cc

zx::result<> RemoveInodeLink (Transaction * transaction)

Decrements the inode link count to a vnode.

Writes the inode back to |transaction|.

If the link count becomes zero, the node either:

1) Calls |Purge()| (if no open fds exist), or

2) Adds itself to the "unlinked list", to be purged later.

Defined at line 235 of file ../../src/storage/minfs/vnode.cc

void AllocateIndirect (PendingWork * transaction, blk_t * block)

Allocates an indirect block.

Defined at line 174 of file ../../src/storage/minfs/vnode.cc

zx::result<LazyBuffer *> GetIndirectFile ()

Initializes (if necessary) and returns the indirect file.

Defined at line 109 of file ../../src/storage/minfs/vnode.cc

zx::result<> BlocksShrink (PendingWork * transaction, blk_t start)

Delete all blocks (relative to a file) from "start" (inclusive) to the end of

the file. Does not update mtime/atime.

Defined at line 67 of file ../../src/storage/minfs/vnode.cc

Protected Methods

void RecycleNode ()

fs::Vnode protected interface.

Defined at line 289 of file ../../src/storage/minfs/vnode.cc