Skip to content
This repository was archived by the owner on Jul 8, 2024. It is now read-only.

Store projection metadata as extended attributes#60

Merged
chrisd8088 merged 9 commits intomasterfrom
xattr-metadata
Mar 15, 2019
Merged

Store projection metadata as extended attributes#60
chrisd8088 merged 9 commits intomasterfrom
xattr-metadata

Conversation

@chrisd8088
Copy link
Collaborator

@chrisd8088 chrisd8088 commented Mar 10, 2019

Hi @kivikakk -- I'm hoping you might take a look at the code so far in this branch and give me a review.

I'm not looking to merge this into master quite yet, as I'd really like to get me test suite additions included and I'm only halfway on those. But I thought I'd get your eyes on the code changes while I finish up the tests.

The corresponding PR for the VFSForGit code is github/VFSForGit#8 and again I'm hoping not to merge that quite yet, but would very much appreciate a review!

Copy link
Contributor

@kivikakk kivikakk left a comment

Choose a reason for hiding this comment

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

Looking good, some general comments.

@chrisd8088
Copy link
Collaborator Author

See what you think of the revisions in d36fb03, @kivikakk, and let me know! Thanks very much for the close review!

Copy link
Contributor

@kivikakk kivikakk left a comment

Choose a reason for hiding this comment

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

This is all looking excellent, and the matter re: make_user_xattr_name has reminded me of a video I'm going to link in Slack in a moment!

No implementation as yet; just defining the expected API changes
and additions.
Borrowing from overlayfs's internal overlayfs.h, we define a
common "user.projection." extended attribute namespace prefix,
and then define our private empty flag attribute using it.

We expect to prepend our prefix to all user-defined projection
attributes, e.g., "user.projection.vfsforgit.contentid", etc.
Refactor our handling of the "empty" projection flag extended
attribute into two common base utility functions which get or set/remove
xattrs, and a specialized set of wrappers of these common functions
which get, set, or remove our projection flag attribute.

The common base functions catch the the ENOATTR "attribute not found"
error when reading or removing an attribute, and in this case, return
success but reset the caller's 'size' argument to -1 to signal that the
attribute was not found.

We will subsequently use this common pair of base functions to manage
additional, user-provided projection attributes, as will be required
for VFSForGit support.
We introduce a common iteration function for parsing and
applying user-provider lists of attributes, and use it to store
such attributes when they are provided during a call to
create a projected file or directory.

The iteration function will also be useful when we add the ability
for callers to subsequently read or reset these attributes after
the initial time of creation.

We store the name/value user attributes as xattrs under our
library's "user.projection.*" namespace, unless they would conflict
with our reserved "user.projection.empty" attribute; we allow
clients to potentially read that attribute, but not overwrite
or remove it.
When a normal setxattr() or removexattr() file operation is
invoked via our FUSE event loop, we check if it might alter
or remove one of the attributes we are managing within our
"user.projection.*" namespace, and if so, we deny the request.

While it is still possible for these xattrs to be modified
through changes made directly against our lower storage filesystem,
these checks should prevent inadvertent changes made through
our mount point.
Complete the implementation of our attribute API with
projfs_get_attrs() and projfs_set_attrs() function that permit
a client to read, set, reset, or remove any of their user-provided
projection attributes subsequent to the initial projection of
a file or directory.
Ensure the constructed user-provided xattr name is always
freed and doesn't leak memory, and separate name string
construction from its validation and use, per advice from @kivikakk.
Rename and reverse the sense of the xattr name check functions
to improve readability and code flow, per advice from @kivikakk.
Clarify the purpose of our projection-flag xattr handling
functions (which get/set/remove the "user.projection.empty"
extended attribute) by renaming to avoid the confusing "_empty"
suffix, per @kivikakk's suggestion.

Also use sizeof() to define the length of our reserved
xattr namespace prefix string, and align some whitespace.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api libprojfs API projection Filesystem projection logic

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants