Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync update dfs v2. #8336

Merged
merged 1 commit into from
Dec 12, 2023
Merged

sync update dfs v2. #8336

merged 1 commit into from
Dec 12, 2023

Conversation

geniusgogo
Copy link
Contributor

拉取/合并请求描述:(PR description)

[

为什么提交这份PR (why to submit this PR)

你的解决方案是什么 (what is your solution)

请提供验证的bsp和config (provide the config and bsp)

  • BSP:
  • .config:
  • action:

]

当前拉取/合并请求的状态 Intent for your PR

必须选择一项 Choose one (Mandatory):

  • 本拉取/合并请求是一个草稿版本 This PR is for a code-review and is intended to get feedback
  • 本拉取/合并请求是一个成熟版本 This PR is mature, and ready to be integrated into the repo

代码质量 Code Quality:

我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:

  • 已经仔细查看过代码改动的对比 Already check the difference between PR and old code
  • 代码风格正确,包括缩进空格,命名及其他风格 Style guide is adhered to, including spacing, naming and other styles
  • 没有垃圾代码,代码尽量精简,不包含#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up
  • 所有变更均有原因及合理的,并且不会影响到其他软件组件代码或BSP All modifications are justified and not affect other components or BSP
  • 对难懂代码均提供对应的注释 I've commented appropriately where code is tricky
  • 代码是高质量的 Code in this PR is of high quality
  • 已经使用formatting 等源码格式化工具确保格式符合RT-Thread代码规范 This PR complies with RT-Thread code specification

@geniusgogo
Copy link
Contributor Author

#8334

*
* @return -1 on failed or the allocated file descriptor.
*/
int dfs_dup_to(int oldfd, struct dfs_fdtable *fdtab)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个没地方使用,不需要这部分的代码。

Copy link
Contributor Author

@geniusgogo geniusgogo Dec 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个原本是给uds或类似需要跨进程传递fd的时候用的,然后uds那边又自己把这个函数copy rename了一份。严格上来讲应该用这一份共用的才是吧?不然每种需要传fd的地方都需要再实现一份(例如dma-buf)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果是这样,那应该对这两个API进行比较好的命名,以反应出意义。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ddb4bde

dfs_dup_to_fdtab:将A进程的私有fd dup到fdtab中,如果fdtab没有指定则使用内核全局的fdtab.
dfs_dum_from_tdtab:进程B将进程A通过dfs_dup_to_fdtab dup得到的fd,从原fdtab中再dup一个属于自己进程的fd出来。
dfs_fdtab_drop_fd:从fdtab中释放一个fd。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int dfs_fdtab_drop_fd(int fd, struct dfs_fdtable *fdtab) 看起来并不是那么合规,包括这个文件前面还有dfs_fdtable_类型的API。如果是dfs_fdtable_类型的,那么这个api应该以fdtable为中心,即int dfs_fdtable_drop_fd(struct dfs_fdtable* fdt, int fd);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果是dup,总体来说,是不是也只有一种情况:
int dfs_fdtable_dup(struct dfs_fdtable *fdt, struct dfs_fdtable *fdt_src, int fd_src);

把源fdt_src中对应的fd_src,复制到fdt中。

源fdt可以是NULL,则代表当前的进程;如果fdt_dst是NULL,则代表当前的进程。

Copy link
Contributor Author

@geniusgogo geniusgogo Dec 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果是dup,总体来说,是不是也只有一种情况

大致原理相同,不过有点差异的考量:
原dfs_dup_to_fdtab是浅拷贝,不会正真去分配fds,只是将fds指向同一个源fd,并应用计数+1.等到dfs_dum_from_tdtab的时候才会深拷贝一次fds。

合并成一种情况来看的话,就不能使用浅拷贝了,整个传递fd的过程会分配两个fds并拷贝两次。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BernardXiong 改了,look look again.

@XYZ-20240101 也帮忙review一下。

components/dfs/dfs_v2/src/dfs_pcache.c Outdated Show resolved Hide resolved
@geniusgogo geniusgogo force-pushed the update_dfsv2 branch 4 times, most recently from 3e70eb2 to 6726cfe Compare December 11, 2023 09:43
@BernardXiong BernardXiong merged commit 304ce59 into RT-Thread:master Dec 12, 2023
37 checks passed
@geniusgogo geniusgogo deleted the update_dfsv2 branch December 18, 2023 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants