1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Collect leaked inode references in extfs.

This commit is contained in:
Jonas 'Sortie' Termansen 2015-08-14 16:23:38 +00:00
parent 01ee906d25
commit 52007a1793
2 changed files with 18 additions and 3 deletions

View file

@ -781,12 +781,19 @@ int fsmarshall_main(const char* argv0,
}
}
// Garbage collect all open inode references.
while ( fs->mru_inode )
{
Inode* inode = fs->mru_inode;
if ( inode->remote_reference_count )
inode->RemoteUnref();
else if ( inode->reference_count )
inode->Unref();
}
// Sync the filesystem before shutting down.
if ( dev->write )
{
// TODO: Need to close all open inodes here, and in the fuse backend too.
fs->Sync();
}
close(serverfd);

View file

@ -67,6 +67,14 @@ void* ext2_fuse_init(struct fuse_conn_info* /*conn*/)
void ext2_fuse_destroy(void* fs_private)
{
struct ext2_fuse_ctx* ext2_fuse_ctx = (struct ext2_fuse_ctx*) fs_private;
while ( ext2_fuse_ctx->fs->mru_inode )
{
Inode* inode = ext2_fuse_ctx->fs->mru_inode;
if ( inode->remote_reference_count )
inode->RemoteUnref();
else if ( inode->reference_count )
inode->Unref();
}
ext2_fuse_ctx->fs->Sync();
ext2_fuse_ctx->dev->Sync();
delete ext2_fuse_ctx->fs; ext2_fuse_ctx->fs = NULL;