Skip to content

fuse-waked: for CAS, hardlinks backed by hardlinks, share virtual mode.#1836

Draft
Will Dietz (dtzSiFive) wants to merge 2 commits into
sifiveinc:masterfrom
dtzSiFive:fix/hardlink-shared-mode
Draft

fuse-waked: for CAS, hardlinks backed by hardlinks, share virtual mode.#1836
Will Dietz (dtzSiFive) wants to merge 2 commits into
sifiveinc:masterfrom
dtzSiFive:fix/hardlink-shared-mode

Conversation

@dtzSiFive
Copy link
Copy Markdown
Contributor

Modify hardlink test to run with CAS enabled, which before this change would cause it to fail (cannot write through hardlinks).

Extend test to check mode changes on one are observed on the other.

Comment thread tools/fuse-waked/main.cpp

if (it->second.is_visible(keyt.second)) return -EEXIST;

if (it->second.is_visible(keyf.second)) return -EACCES;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Drive-by: ban hardlinks originating from visible files for lack of structure presently to enforce RO access this way.

Fixes existing bug where you can modify visible files through a hardlink.

Wake snippet demonstrating:

export def datFile Unit =
    write "datFile" "hello world"

export def modLink Unit =
    require Pass dat =
        datFile Unit
    makeExecPlan ("sh", "-c", "ln datFile modLink; echo asdf >> modLink; cat datFile", Nil) (dat, Nil)
    | setPlanLabel "test (hardlink): modLink"
    | setPlanShare False
    | runJobWith defaultRunner
    | getJobOutput

export def test _ =
  require Pass out = modLink Unit
  Pass Unit

Note that since we -- before this PR -- block writes through hardlinks in CAS mode, this issue today only exists in non-CAS wake.

cc #1593 .

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This change might deny benign jobs from performing reasonable behavior and should be considered carefully and perhaps separately 👍 .

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah I think this change is right, but don't know if there is any fallout due to this, so agreed that maybe we test and evaluate this in a separate PR

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually, I think today attempts to hardlink visible "succeed" but fall through and don't do this in the staging directory but write through to workspace? The new -EEXIST check prevents this, as does the tentative is_visible explicit guard discussed here.

Comment thread tools/fuse-waked/main.cpp
hardlinks.insert(std::string(to));
return 0;
}
return -EEXIST;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In CAS mode: never fallback to workspace!

This may be unreachable, it should be, but just be explicit here to avoid surprise behaviors while supporting both.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would ENONET or EPERM be a better return for if a file is not staged?

@dtzSiFive
Copy link
Copy Markdown
Contributor Author

Dare we set st_nlink based on this? 😉

Copy link
Copy Markdown
Collaborator

@ag-eitilt Sam May (ag-eitilt) left a comment

Choose a reason for hiding this comment

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

This all looks good to me!

trap 'rm link_file_src.txt link_file_dst.txt' EXIT

STDOUT=$(${1}/wakebox -p input.json)
export WAKE_CAS=1
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Probably don't want to hardcode this in the test? I know we were saying that we'd rather push toward getting everything unified rather than supporting multiple code paths, but make test ; WAKE_CAS=1 make test should still leave us testing both paths over the full suite.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ah, I see what you're getting at with this guard -- this is a breaking change between CAS and non-CAS. Can't say I like the different behaviour, but it's unlikely enough to not cause any issue. Instead of setting WAKE_CAS, though, can we instead check it, print a stderr warning about skipping the test, and then exit 0? (Also applies to #1838)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Mainline WAKE doesn't propagate WAKE_CAS=1 into the tests, whether this is a bug or not I am not sure. If I was certain I'd have addressed it.

But okay that works for me. I removed it in the multi-wake variant.

Good call!

Comment thread tools/fuse-waked/main.cpp
Comment on lines 80 to 85
struct StagedFileData {
std::string staging_path;
mode_t mode;
std::shared_ptr<mode_t> mode;

bool is_hardlink() const { return mode.use_count() > 1; }
};
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't like this C++ design choice... struct should be data, and if you want methods you reach for class/interface. But that's me getting grumpy at the language, not at this implementation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll hoist it out to is_hardlink on StagedItem, that fits the current organization/style better anyway. Meant to revisit this, thanks!

Copy link
Copy Markdown
Contributor

@AbrarQuazi Abrar Quazi (AbrarQuazi) left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

We should merge this to master and then maybe cherry pick to the feature/multi-wake branch so we can get to a beta release faster

Comment thread tools/fuse-waked/main.cpp
hardlinks.insert(std::string(to));
return 0;
}
return -EEXIST;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would ENONET or EPERM be a better return for if a file is not staged?

Comment thread tools/fuse-waked/main.cpp

if (it->second.is_visible(keyt.second)) return -EEXIST;

if (it->second.is_visible(keyf.second)) return -EACCES;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah I think this change is right, but don't know if there is any fallout due to this, so agreed that maybe we test and evaluate this in a separate PR

Comment thread tools/fuse-waked/main.cpp
it->second.files_wrote.insert(keyt.second);
// Both hardlink paths need direct_io to prevent kernel caching issues
hardlinks.insert(std::string(from));
hardlinks.insert(std::string(to));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can the hardlinks set be completely removed? Or its still needed because the non-CAS mode still depends on it? If thats the case, maybe add a comment to remove this structure

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's for non-CAS. I'll add a comment.

@dtzSiFive
Copy link
Copy Markdown
Contributor Author

Mixed signals on where we want to send these changes hahaha.

Applied y'all's feedback to multi-wake version. I'll sync those changes back here later.

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.

3 participants