Skip to content

Commit

Permalink
add vnode/dentry ref
Browse files Browse the repository at this point in the history
  • Loading branch information
zmshahaha committed Aug 9, 2024
1 parent d33afe7 commit 04b4889
Show file tree
Hide file tree
Showing 7 changed files with 181 additions and 194 deletions.
1 change: 0 additions & 1 deletion components/dfs/dfs_v2/include/dfs_pcache.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ struct dfs_aspace
rt_bool_t is_active;

struct rt_mutex lock;
rt_atomic_t ref_count;

struct dfs_vnode *vnode;
const struct dfs_aspace_ops *ops;
Expand Down
4 changes: 2 additions & 2 deletions components/dfs/dfs_v2/src/dfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ int dfs_fdtable_dup(struct dfs_fdtable *fdt_dst, struct dfs_fdtable *fdt_src, in
fdt_dst->fds[newfd]->flags = fdt_src->fds[fd_src]->flags;
fdt_dst->fds[newfd]->fops = fdt_src->fds[fd_src]->fops;
fdt_dst->fds[newfd]->dentry = dfs_dentry_ref(fdt_src->fds[fd_src]->dentry);
fdt_dst->fds[newfd]->vnode = fdt_src->fds[fd_src]->vnode;
fdt_dst->fds[newfd]->vnode = dfs_vnode_ref(fdt_src->fds[fd_src]->vnode);
fdt_dst->fds[newfd]->mmap_context = RT_NULL;
fdt_dst->fds[newfd]->data = fdt_src->fds[fd_src]->data;

Expand Down Expand Up @@ -638,7 +638,7 @@ int dfs_dup_from(int oldfd, struct dfs_fdtable *fdtab)
file->flags = fdtab->fds[oldfd]->flags;
file->fops = fdtab->fds[oldfd]->fops;
file->dentry = dfs_dentry_ref(fdtab->fds[oldfd]->dentry);
file->vnode = fdtab->fds[oldfd]->vnode;
file->vnode = dfs_vnode_ref(fdtab->fds[oldfd]->vnode);
file->mmap_context = RT_NULL;
file->data = fdtab->fds[oldfd]->data;
}
Expand Down
12 changes: 9 additions & 3 deletions components/dfs/dfs_v2/src/dfs_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ static int _try_readlink(const char *path, struct dfs_mnt *mnt, char *link)
}
}
}
dfs_dentry_unref(dentry);

if (dentry)
{
dfs_dentry_unref(dentry);
}

return ret;
}
Expand Down Expand Up @@ -256,7 +260,7 @@ static void _dfs_file_release(struct rt_ref *ref)

if (file->vnode)
{
dfs_vnode_unref(file->vnode);
//dfs_vnode_unref(file->vnode);
}

if (file->mmap_context)
Expand Down Expand Up @@ -720,7 +724,7 @@ int dfs_file_close(struct dfs_file *file)
{
DLOG(msg, "dfs_file", file->dentry->mnt->fs_ops->name, DLOG_MSG, "fops->close(file)");
#ifdef RT_USING_PAGECACHE
if (file->vnode->aspace)
if (file->vnode && file->vnode->aspace)
{
ret = dfs_aspace_flush(file->vnode->aspace);
}
Expand Down Expand Up @@ -1269,6 +1273,8 @@ int dfs_file_fcntl(int fd, int cmd, unsigned long arg)
ret = -EBADF;
}

dfs_file_put(file);

return ret;
}

Expand Down
Loading

0 comments on commit 04b4889

Please sign in to comment.