Commit Graph

208 Commits

Author SHA1 Message Date
Wolfgang Bumiller 2179359f40 move src/pxar.rs -> src/pxar/mod.rs
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-09 10:49:59 +02:00
Wolfgang Bumiller 7eacdc765b pxar: split assert_relative_path
the check for a single component is only required in the dir
stack atm

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-08 15:02:52 +02:00
Wolfgang Bumiller c443f58b09 switch to external pxar and fuse crates
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-06-08 13:56:58 +02:00
Thomas Lamprecht add5861e8d typo fixes all over the place
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-05-30 16:39:08 +02:00
Dietmar Maurer 07ce44a633 avoid compiler warnings 2020-05-19 07:03:41 +02:00
Wolfgang Bumiller 9094186a57 xattr: cleanup: don't use pxar types in the API
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-04-24 11:23:48 +02:00
Wolfgang Bumiller 27a3decbfe xattr: api cleanup
Make `flistxattr()` return a `ListXAttr` helper which
provides an iterator over `&CStr`.

This exposes the property that xattr names are a
zero-terminated string without simply being an opaque
"byte vector". Using &[u8] as a type here is too lax.

Also let `fgetxattr` take a `CStr`. While this may be a
burden on the caller, we usually already have
zero-terminated strings on the call site. Currently we only
use this method coming from `flistxattr` after all.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-04-24 10:56:52 +02:00
Wolfgang Bumiller f7d4e4b506 switch from failure to anyhow
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-04-17 18:43:30 +02:00
Christian Ebner 351b913d1e pxar::decoder: Return the correct symlink target size.
This eliminates also repeated calls to readlink in fuse, which occur when the
preallocated buffer to store the symlink target path is to small.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2020-02-28 08:38:56 +01:00
Christian Ebner 189996cf4a proxmox-backup-client: expose exclude match patterns to cli.
Allows to pass exclude match patterns to the 'backup' command.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2020-02-28 07:56:09 +01:00
Christian Ebner 75c2ee7bab tools::lru_cache: Make key generic.
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2020-02-27 06:55:16 +01:00
Christian Ebner 495b238bc1 pxar: Change text of warning for files matched by exclude patterns.
In addition to the .pxarexclude files, glob match patterns can be passed to pxar
also via cli parameters.
Therefore the warning is rephrased to be more ambiguous.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2020-02-25 10:47:24 +01:00
Christian Ebner 9ff9a00572 pxar::fuse: cleanup: Remove unused code.
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-02-03 13:43:11 +01:00
Christian Ebner 3e69abef02 pxar::fuse: Refactor lookup in order to cache accessed entries.
Context::find_goodbye_entry() is removed and incorporated into the lookup
callback in order to take advantage of the entry_cache and since it is only used
inside this callback.
All entries read on lookup are cached.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-02-03 13:43:06 +01:00
Christian Ebner 63698e720c pxar: Improve read performance for fuse.
By storing the payload start offset in the `DirectoryEntry` and passing this
information to `Decoder::read()`, the payload can be read directly and a repeated
re-reading of the entry information is avoided.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-02-03 12:08:03 +01:00
Christian Ebner 93a9eb284e pxar::fuse: Do not return fcaps value on listxattr.
listxattr must only return the name list, no extended attribute values.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-29 09:35:09 +01:00
Christian Ebner 5d2158e89a pxar::fuse: return ACL names in listxattr if present
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-29 09:35:03 +01:00
Christian Ebner 72677fb0a5 pxar::fuse: add support to read ACLs.
ACLs are stored separately in the pxar archive. This implements the functionality
needed to read the ACLs and return them as extended attributes in the getxattr
callback.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-29 09:35:00 +01:00
Christian Ebner bcf0d452c9 pxar: move acl helper functions to src/tools/acl.rs
They are not only needed by the pxar::sequential_decoder but also for the fuse
xattr impl, so it makes more sense to have them there.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-29 09:34:54 +01:00
Christian Ebner 3e56c4abd7 pxar::fuse: Introduce LRU caching for goodbye table and directory entries.
The goodbye table of directory entries is cached in a LRU cache to speed up
subsequent accesses.
This is especially important for directories with many entries, as then the
readdirplus callback is called repeatedly because of the limited reply buffer
size.

`DirectoryEntry`s are cached for subsequent access in their own LRU cache,
independent of the goodbye tables.

In order to avoid borrow conflicts, the `Context` provides a fn as_mut_refs
as well as a fn run_with_context_refs.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-28 10:06:53 +01:00
Christian Ebner cc552754c8 pxar::fuse: refactor fn stat
By passing `&DirectoryEntry` to stat, the function interface is simplified.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-28 10:06:51 +01:00
Christian Ebner aac9dbf635 pxar::fuse: remove open, opendir and releasedir callbacks
They are not needed as there is no internal state which needs to be tracked.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2020-01-20 12:56:21 +01:00
Christian Ebner a8aff3535d pxar: Include symlink target in DirectoryEntry
This allows to read the target path of a symbolic link in the
Decoder::read_directory_entry() function and stores it in the DirectoryEntry.
By this the Decoder::read_link() function becomes obsolete and is therefore
removed.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2020-01-20 12:56:10 +01:00
Christian Ebner 2bbbade367 pxar: Refactor fuse and remove unused code.
By ambiguously using the Decoder::read_directory_entry() the code is simplified
and reading of the DirectoryEntry is concentrated into Context::run_in_context().

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2020-01-17 09:40:39 +01:00
Christian Ebner 95c9460c4a pxar::fuse: Always use start offset of entries as inode.
Previously it was disciminated based on the entry mode.
For directories, the inode was the offset of the corresponding
goodbye tail mark while for all others it was the offset of the filename.

By simply using the start offset as calculated from the corresponding
goodbye table entry (which yields the archive offset of the filename),
the code is simplified and the more ambiguous read_directory_entry()
function can be used.
The disatvantage of this approach is the need to keep track of the
start and end offsets for each entry, as the end offset is needed in
order to access the goodbye table of directory entries.
The root node still has to be treated special, as it's inode is 1 as per fuse
definition and it has no filename as per the pxar file format definition.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2020-01-17 09:40:39 +01:00
Christian Ebner 6744440714 pxar::decoder: refactor Decoder::lookup()
Use Decoder::read_directory_entry() instead of Decoder::attributes() as this
already returns the needed DirectoryEntry.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2020-01-17 09:40:39 +01:00
Christian Ebner ef2d7f2f96 pxar::fuse: remove readdir implementation
By not implementing readdir but only readdirplus, the FUSE_CAP_READDIRPLUS flag
is set while the FUSE_CAP_READDIRPLUS_AUTO flag is not set.
Thereby the kernel will issue only readdirplus calls.
Documentation at:
https://libfuse.github.io/doxygen/fuse-3_88_80_2include_2fuse__common_8h.html#a9b90333ad08d0e1c2ed0134d9305ee87

As the expensive part for accessing and reading the attributes is seeking and
decoding each directory entry, it is usefull to force readdirplus calls.
By this a struct `EntryParam` is returned for each entry, therebye avoiding a
subsequent lookup call.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2020-01-15 14:44:53 +01:00
Christian Ebner ea5061979b pxar::fuse: Avoid macro to generate filler function, use closure instead.
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2020-01-15 10:25:16 +01:00
Christian Ebner 6de36b94b1 pxar::fuse: impl readdirplus callback
readdirplus returns the entries together with their `EntryParam`, so subsequent
lookups for each of the entries are avoided.
In order to reduce code duplication, the code for filling the reply buffer is
moved into a macro.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2020-01-13 11:17:34 +01:00
Christian Ebner caa201d895 pxar::fuse: Get rid of broken cacheing
Remove the current caching of attrs and goodbye tables as it is broken anyway.
This will be replaced with a LRU cache.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2020-01-13 11:16:06 +01:00
Christian Ebner c7257c5539 pxar::fuse: refactor HashMap to store child parent inode relation.
By moving the HashMap into `Context`, the use of lazy_static as well as the
additional Mutex can be avoided (`Context` is already guarded by a Mutex).

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2020-01-10 13:45:58 +01:00
Christian Ebner 90fc97af6a pxar::decoder::Decoder: include xattrs and payload size in `DirectoryEntry`.
By reading and including xattrs and payload size in struct `DirectoryEntry`,
the tuple of return types is avoided and the code is simpler.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2020-01-10 13:45:40 +01:00
Christian Ebner 6fc053ed85 pxar: encoder: limit number of max entries held at once in memory during archive creation.
Limit the total number of entries and therefore the approximate memory
consumption instead of doing this on a per directory basis as it was previously.
This makes more sense as it limits not only the width but also the depth of the
directory tree.

Further, instead of hardcoding this value, allow to pass this information as
additional optional parameter 'entires-max'.
By this, creation of the archive with directories containing a large number of
entries is possible.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2020-01-10 13:45:08 +01:00
Christian Ebner ecbc62261c pxar: encoder: warn on lacking read permissions instead of fail.
If during creation of the archive, files/dirs with lacking read permissions are
encountered, the user is displayed a warning and the archive is created without
including the file/dir.
Previously this resulted in an error and the archive creation failed.

In order to implement this also for the .pxarexclude files, the Error type of
MatchPattern::from_file() and MatchPattern::from_line() was adopted accordingly.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2020-01-09 10:41:19 +01:00
Christian Ebner 88cee60bad pxar: encoder: fix incorrect goodbye table entries and update displayed path.
If nodes are excluded by feature flags, they must not appear in the goodbye table.
This is fixed by continuing with the next entry in the for loop.

Further the relative path buffer is now poped in order to correctly display the path.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2020-01-09 10:39:41 +01:00
Christian Ebner ec906dcf19 src/pxar/encoder.rs: avoid use of macro and initialize Vec with known capacity.
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2020-01-09 10:38:58 +01:00
Christian Ebner ebfb2df22b binary_search_tree: add additional doctest for search_binary_tree_by()
Make sure a start indexes larger or equal to the array size results in a return
value of `None`.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-12-17 15:37:02 +01:00
Christian Ebner 48f6d67764 binary_search_tree: fix off by one error in search_binary_tree_by()
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-12-17 14:57:34 +01:00
Christian Ebner a333b4ccea pxar: match_pattern: impl invert() to switch the match type of a MatchPattern.
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-12-17 11:12:34 +01:00
Christian Ebner 48af80b3ab pxar: match_pattern: impl traits needed for MatchPattern to be comparable.
In order to check if two MatchPattern are identical, which will be used to avoid
duplicates.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-12-17 11:12:34 +01:00
Christian Ebner 255bb86030 pxar: match_pattern: refactor MatchPattern and introduce MatchPatternSlice.
The MatchPattern impl heavily used copies and therefore was inefficient regarding
memory management.
This patch intoduces MatchPatternSlice as struct to avoid copies and perform the
same pattern matching functionality.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-12-17 11:12:34 +01:00
Dietmar Maurer b9799012cf src/pxar/decoder.rs: require Send 2019-12-16 10:01:51 +01:00
Christian Ebner d3dbe52f37 pxar: match_pattern: refactor match_filename
The match_filename() in sequentail_decoder and encoder are moved to be static
functions of MatchPattern.
This allows to reuse the code also in the catalog find implementation.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-12-11 10:55:01 +01:00
Christian Ebner fa0b950070 pxar: fuse: add support for list- and getxattr
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-12-06 16:44:15 +01:00
Christian Ebner 25ad4cbf63 pxar: fuse: cache goodbye table for each directory on opendir and release it on releasedir
Cache not only the goodbye table for the last directory but for each opened
directory.
The opendir fuse callback will fill the cache with the goodbye table and
releasedir will remove it from the cache.
This should reduce the number of chuncks fetched from the server in some cases.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-12-06 16:43:59 +01:00
Christian Ebner 02491b8fc6 pxar: fuse: use binary search instead of linear search in goodbye table.
The goodbye table is layed out as binary search tree based on the hash, so use
this to be more efficient when looking up a hash in the table for directories
with a large number of entries.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-12-06 16:42:01 +01:00
Christian Ebner de0aa53174 pxar: decoder: fix incorrect read for hardlinks.
Decoders read must check if the file is a hardlink and read data from the
corresponding offset if so.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-12-03 12:08:23 +01:00
Christian Ebner b7e18004a2 pxar: decoder: return original name in attributes()
The returned filename should be the one of the file given at the offset, not of
the one the hardlink points to.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-12-03 12:08:07 +01:00
Dietmar Maurer 2f2b87e659 src/pxar/fuse.rs: add impl Context 2019-11-26 11:16:46 +01:00
Dietmar Maurer eedd1f95eb src/pxar/fuse.rs: move init and destroy into Session 2019-11-26 11:08:55 +01:00