Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

[LibOS] Rewrite rename* syscalls #943

Merged
merged 2 commits into from
Sep 3, 2019

Conversation

boryspoplawski
Copy link
Contributor

@boryspoplawski boryspoplawski commented Aug 20, 2019

Affected components

  • README and global configuration
  • Linux PAL
  • SGX PAL
  • FreeBSD PAL
  • Common PAL code
  • Library OS (i.e., SHIM), including GLIBC

Description of the changes

Unfortunately current implementation of fs does not allow for renaming anything but regular files.
Fixes some issues from #903 constrained by above statement.

How to test this PR?


This change is Reviewable

Copy link
Contributor

@yamahata yamahata left a comment

Choose a reason for hiding this comment

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

The logic seems racy. But other fs related codes (open, unlink, rmdir, mkdir) seem racy.
So I don't block this due to it.

Reviewable status: 0 of 9 files reviewed, all discussions resolved, not enough approvals from maintainers (3 more required), not enough approvals from different teams (2 more required, approved so far: )


LibOS/shim/src/fs/shim_namei.c, line 834 at r1 (raw file):

}

int get_dirfd_dentry(int dirfd, struct shim_dentry** dir) {

Except the last put_handle(), Is this just code cleanup?


LibOS/shim/src/fs/shim_namei.c, line 858 at r1 (raw file):

    get_dentry(hdl->dentry);
    *dir = hdl->dentry;
    put_handle(hdl);

good catch.


LibOS/shim/src/sys/shim_fs.c, line 605 at r1 (raw file):

        }

        if ((ret = new_dent->fs->d_ops->unlink(new_dent->parent,

+1 to drop unlink logic. It should be up to fs.


LibOS/shim/src/sys/shim_fs.c, line 622 at r1 (raw file):

        new_dent->state &= ~DENTRY_NEGATIVE;
        if (old_dent->state & DENTRY_ISDIRECTORY) {
            new_dent->state |= DENTRY_ISDIRECTORY;

Is there any reason why this isn't updated before rename method?

yamahata
yamahata previously approved these changes Aug 21, 2019
Copy link
Contributor

@yamahata yamahata left a comment

Choose a reason for hiding this comment

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

#944

Reviewed 9 of 9 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion, not enough approvals from maintainers (2 more required), not enough approvals from different teams (1 more required, approved so far: Intel) (waiting on @boryspoplawski)

Copy link
Contributor Author

@boryspoplawski boryspoplawski left a comment

Choose a reason for hiding this comment

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

I agree, but there are many more issues with current fs implementation and I don't think all of them can be fixed without major changes/reworks.

Reviewable status: all files reviewed, 1 unresolved discussion, not enough approvals from maintainers (2 more required), not enough approvals from different teams (1 more required, approved so far: Intel) (waiting on @yamahata)


LibOS/shim/src/fs/shim_namei.c, line 834 at r1 (raw file):

Previously, yamahata wrote…

Except the last put_handle(), Is this just code cleanup?

Yes, just wanted to change this function name, as previous was a bit missleading


LibOS/shim/src/sys/shim_fs.c, line 605 at r1 (raw file):

Previously, yamahata wrote…

+1 to drop unlink logic. It should be up to fs.

Exactly


LibOS/shim/src/sys/shim_fs.c, line 622 at r1 (raw file):

Previously, yamahata wrote…

Is there any reason why this isn't updated before rename method?

If rename fails, old_dent should stay in the same state as it was before.

Copy link
Contributor Author

@boryspoplawski boryspoplawski left a comment

Choose a reason for hiding this comment

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

Reviewable status: 8 of 9 files reviewed, 1 unresolved discussion, not enough approvals from maintainers (3 more required), not enough approvals from different teams (2 more required, approved so far: ) (waiting on @yamahata)


LibOS/shim/src/sys/shim_fs.c, line 622 at r1 (raw file):

Previously, boryspoplawski (Borys Popławski) wrote…

If rename fails, old_dent should stay in the same state as it was before.

Actually you are right. It was even updated above - so removed unneeded update here.

yamahata
yamahata previously approved these changes Aug 21, 2019
Copy link
Contributor

@yamahata yamahata left a comment

Choose a reason for hiding this comment

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

implementation and I don't think all of them can be fixed without major changes/reworks.

fully agreed.

Reviewable status: 8 of 9 files reviewed, all discussions resolved, not enough approvals from maintainers (2 more required), not enough approvals from different teams (1 more required, approved so far: Intel) (waiting on @yamahata)

mkow
mkow previously approved these changes Aug 25, 2019
Copy link
Member

@mkow mkow left a comment

Choose a reason for hiding this comment

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

Reviewed 8 of 9 files at r1, 1 of 1 files at r2.
Reviewable status: all files reviewed, all discussions resolved, not enough approvals from maintainers (1 more required)

Present implementation is utterly broken, does not work even
in simplest cases.
If `get_new_dentry` returns successfully, it increases returned dentry's
reference counter by one, which matches other similar functions' behavior.
@mkow mkow dismissed stale reviews from yamahata and themself via 289ac3a September 3, 2019 19:54
@mkow mkow force-pushed the borys/WIP/fix_rename branch from 0c3a5a9 to 289ac3a Compare September 3, 2019 19:54
@mkow
Copy link
Member

mkow commented Sep 3, 2019

Jenkins, test this please

Copy link
Member

@mkow mkow left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: all files reviewed, all discussions resolved, not enough approvals from maintainers (1 more required), not enough approvals from different teams (1 more required, approved so far: ITL)

Copy link
Contributor

@yamahata yamahata left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r2.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@mkow mkow merged commit 289ac3a into gramineproject:master Sep 3, 2019
@boryspoplawski boryspoplawski deleted the borys/WIP/fix_rename branch March 2, 2020 19:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants