Commit Graph

344 Commits

Author SHA1 Message Date
Andy Grover
706fe9a30e Implement argp support for search-xattrs
Get fs path via normal methods, and make xattr an argument not an option.

Signed-off-by: Andy Grover <agrover@versity.com>
2021-01-12 10:47:47 -08:00
Andy Grover
0f17ecb9e3 Implement argp support for stage/release
Make offset and length optional. Allow size units (KMGTP) to be used
  for offset/length.

release: Since off/len no longer given in 4k blocks, round offset and
  length to to 4KiB, down and up respectively. Emit a message if rounding
  occurs.

Make version a required option.

stage: change ordering to src (the archive file) then the dest (the
  staged file).

Signed-off-by: Andy Grover <agrover@versity.com>
2021-01-12 10:47:47 -08:00
Andy Grover
10df01eb7a Implement argp support for ino-path
Signed-off-by: Andy Grover <agrover@versity.com>
2021-01-04 11:49:31 -08:00
Andy Grover
68b8e4098d Implement argp support for stat and statfs
Signed-off-by: Andy Grover <agrover@versity.com>
2021-01-04 11:49:31 -08:00
Andy Grover
5701184324 Implement argp support for df
Convert arg parsing to use argp. Use new get_path() helper fn.

Add -h human-readable option.

Signed-off-by: Andy Grover <agrover@versity.com>
2021-01-04 11:49:31 -08:00
Andy Grover
a3035582d3 Add strdup_or_error()
Add a helper function to handle the impossible event that strdup fails.

Signed-off-by: Andy Grover <agrover@versity.com>
2021-01-04 11:49:31 -08:00
Andy Grover
9e47a32257 Add get_path()
Implement a fallback mechanism for opening paths to a filesystem. If
explicitly given, use that. If env var is set, use that. Otherwise, use
current working directory.

Use wordexp to expand ~, $HOME, etc.

Signed-off-by: Andy Grover <agrover@versity.com>
2021-01-04 11:49:31 -08:00
Zach Brown
e386b900ee Remove README.md from utils
This was just boilerplate for the utils repo.

Signed-off-by: Zach Brown <zab@versity.com>
2020-12-07 10:39:20 -08:00
Zach Brown
86cf3ec4ab Remove format.h and ioctl.h from utils
Now that we're in one repo utils can get its format and ioctl headers
from the authoriative kmod files.   When we're building a dist tarball
we copy the files over so that the build from the dist tarball can use
them.

Signed-off-by: Zach Brown <zab@versity.com>
2020-12-07 10:39:20 -08:00
Andy Grover
9a647a98f1 scoutfs-utils: Header changes to match kmod PR 41
Signed-off-by: Andy Grover <agrover@versity.com>
2020-11-30 13:35:39 -08:00
Andy Grover
30668c1cdd scoutfs-utils: Fix df
Not initializing wid[] can cause incorrect output.

Also, we only need 6 columns if we reference the array from 0.

Signed-off-by: Andy Grover <agrover@versity.com>
2020-11-19 13:03:31 -08:00
Andy Grover
8f72d16609 scoutfs-utils: Use separate block devices for metadata and data
mkfs: Take two block devices as arguments. Write everything to metadata
dev, and the superblock to the data dev. UUIDs match. Differentiate by
checking a bit in a new "flags" field in the superblock.

Refactor device_size() a little. Convert spaces to tabs.

Move code to pretty-print sizes to dev.c so we can use it in error
messages there, as well as in mkfs.c.

print: Include flags in output.

Add -D and -M options for setting max dev sizes

Allow sizes to be specified using units like "K", "G" etc.

Note: -D option replaces -S option, and uses above units rather than
the number of 4k data blocks.

Update man pages for cmdline changes.

Signed-off-by: Andy Grover <agrover@versity.com>
2020-11-19 11:41:54 -08:00
Zach Brown
f46ab548a4 scoutfs-utils: format df in two rows
It was too tricky to pick out the difference between metadata and data
usage in the previous format.  This makes it much more clear which
values are for either metadata or data.

Signed-off-by: Zach Brown <zab@versity.com>
2020-11-10 15:23:14 -08:00
Zach Brown
66c6331131 scoutfs-utils: add max item vers to log trees
Add a field to the log_trees struct which records the greatest item
version seen in items in the tree.

Signed-off-by: Zach Brown <zab@versity.com>
2020-10-30 11:12:52 -07:00
Zach Brown
42bf0980b6 scoutfs-utils: remove scoutfs_log_trees_val
We're just using the one log_trees struct for both network messages and
persistent btree item values.

Signed-off-by: Zach Brown <zab@versity.com>
2020-10-30 11:12:52 -07:00
Andy Grover
5701182665 scoutfs-utils: Enable -Wpadded
The compiler will complain if it sees any padding.

Fix a spot in print.c for this.

Signed-off-by: Andy Grover <agrover@versity.com>
2020-10-29 14:15:22 -07:00
Andy Grover
6fea9f90c4 scoutfs-utils: Sync latest headers with kernel code
__packed no longer used.

Signed-off-by: Andy Grover <agrover@versity.com>
2020-10-29 14:15:22 -07:00
Andy Grover
e78ba2b427 scoutfs-utils: specify types for some long constants
This avoids warnings on Centos 7 from gcc 4.8.5.
2020-10-29 14:15:22 -07:00
Andy Grover
8bd6646d9a scoutfs-utils: avoid redeclarations of __[be,le][16,32,64] in sparse.h
dev.c includes linux/fs.h which includes linux/types.h, which defines
these types, __be16 etc. These are also defined in sparse.h, but I don't
think these are needed.

Definitions in linux/types.h includes stuff to set attr(bitwise) if
__CHECKER__ is defined, so we can remove __sp_biwise.

Signed-off-by: Andy Grover <agrover@versity.com>
2020-10-29 14:15:22 -07:00
Zach Brown
6b1dd980f0 scoutfs-utils: remove btree item owner
We no longer have an owner offset trailing btree item values.

Signed-off-by: Zach Brown <zab@versity.com>
2020-10-29 14:15:22 -07:00
Zach Brown
ea7c41d876 scoutfs-utils: remove free_*_blocks super fields
The kernel is no longer storing the total free space in all allocators
in super block fields.

Signed-off-by: Zach Brown <zab@versity.com>
2020-10-26 15:19:41 -07:00
Zach Brown
669e7f733b scoutfs-utils: add -S to limit device size
Add an option to mkfs to have it limit the size of the device that's
used by mkfs.

Signed-off-by: Zach Brown <zab@versity.com>
2020-10-26 15:19:41 -07:00
Zach Brown
4bd86d1a00 scoutfs-utils: return error for small device
The check for a small device didn't return an error code because it was
copied from error tests of ret for an error code.  It has to generate
one, do so.

Signed-off-by: Zach Brown <zab@versity.com>
2020-10-26 15:19:41 -07:00
Zach Brown
b424208555 scoutfs-utils: remove unused packed extents
Signed-off-by: Zach Brown <zab@versity.com>
2020-10-26 15:19:41 -07:00
Zach Brown
4ca0b3ff74 scoutfs-utils: try compacting srch more frequently
Signed-off-by: Zach Brown <zab@versity.com>
2020-10-26 15:19:41 -07:00
Zach Brown
838e293413 scoutfs-utils: update compaction item printing
We now only use one srch file compaction struct and we store it in
PENDING and BUSY key types.

Signed-off-by: Zach Brown <zab@versity.com>
2020-10-26 15:19:41 -07:00
Zach Brown
a19e151277 scoutfs-utils: add fd which uses alloc_detail
Add the df command which uses the new alloc_detail ioctl to show df for
the metadata and data devices separately.

Signed-off-by: Zach Brown <zab@versity.com>
2020-10-26 15:19:41 -07:00
Zach Brown
36c426d555 scoutfs-utils: add total m/d blocks to statfs
Signed-off-by: Zach Brown <zab@versity.com>
2020-10-26 15:19:41 -07:00
Zach Brown
fddfde62e6 scoutfs-utils: add endian size swapping macros
Signed-off-by: Zach Brown <zab@versity.com>
2020-10-26 15:19:41 -07:00
Zach Brown
e6385784f5 scoutfs-utils: remove unused radix format
Signed-off-by: Zach Brown <zab@versity.com>
2020-10-26 15:19:41 -07:00
Zach Brown
23711f05f6 scoutfs-utils: alloc and data uses full extents
Signed-off-by: Zach Brown <zab@versity.com>
2020-10-26 15:19:41 -07:00
Zach Brown
d87e2e0166 scoutfs-utils: add btree insertion for mkfs
Use little helpers to insert items into new single block btrees for
mkfs.  We're about to insert a whole bunch more items.

Signed-off-by: Zach Brown <zab@versity.com>
2020-10-26 15:19:41 -07:00
Zach Brown
e2a919492d scoutfs-utils: remove unused xattr index items
We're now using the .srch. xattr tags.

Signed-off-by: Zach Brown <zab@versity.com>
2020-08-26 14:39:28 -07:00
Zach Brown
1e2dc6c1df scoutfs-utils: add committed_seq to statfs_more
Signed-off-by: Zach Brown <zab@versity.com>
2020-08-26 14:39:28 -07:00
Zach Brown
f04a636229 scoutfs-utils: add support for srch
Signed-off-by: Zach Brown <zab@versity.com>
2020-08-26 14:39:28 -07:00
Zach Brown
e82cce36d9 scoutfs-utils: rework get_fs_roots to get_roots
Signed-off-by: Zach Brown <zab@versity.com>
2020-08-26 14:39:28 -07:00
Zach Brown
e85fc5b1a7 scoutfs-utils: increase btree item value limit
Signed-off-by: Zach Brown <zab@versity.com>
2020-08-26 14:39:28 -07:00
Zach Brown
c0fdd37e5a scoutfs-utils: add get_unaligned helpers
Signed-off-by: Zach Brown <zab@versity.com>
2020-08-26 14:39:28 -07:00
Zach Brown
35d1ad1422 scoutfs-utils: switch to using fnv1a for hashing
Track the scoutfs module's switch to FNV1a for hashing.

Signed-off-by: Zach Brown <zab@versity.com>
2020-08-26 14:39:28 -07:00
Zach Brown
9bb32b8003 scoutfs-utils: fix last data blkno
The calculation of the last valid data blkno was off by one.  It was
calculating the total number of small blocks that fit in the device
size.

Signed-off-by: Zach Brown <zab@versity.com>
2020-08-26 14:39:28 -07:00
Zach Brown
5f0dbc5f85 scoutfs-utils: remove radix _first fields
The recent cleanup of the radix allocator included removing tracking of
the first set bits or references in blocks.

Signed-off-by: Zach Brown <zab@versity.com>
2020-08-26 14:39:28 -07:00
Zach Brown
ffc1e5aa86 scoutfs-utils: update net root format
Track the changes in the kernel to communicate btree roots over the
network.

Signed-off-by: Zach Brown <zab@versity.com>
2020-08-26 14:39:28 -07:00
Zach Brown
39993d8b5f scoutfs-utils: use larger metadata blocks
Signed-off-by: Zach Brown <zab@versity.com>
2020-08-26 14:39:28 -07:00
Zach Brown
b86a1bebbb scoutfs-utils: support btree avl and hash
Update the internal structure of btree blocks to use the avl item index
and hash table direct item lookup.

Signed-off-by: Zach Brown <zab@versity.com>
2020-08-26 14:39:28 -07:00
Zach Brown
aa84f7c601 scoutfs-utils: use scoutfs_key as btree key
Track the kernel changes to use the scoutfs_key struct as the btree key
instead of a big-endian binary blob.

Signed-off-by: Zach Brown <zab@versity.com>
2020-08-26 14:39:28 -07:00
Zach Brown
ac2d465b66 scoutfs-utils: print key zone and type numerically
The kernel has long sinced moved away from symbolic printing of key
cones and types, and it just removed the MAX values from the format
header.  Let's follow suit and get rid of the zone and type strings.

Signed-off-by: Zach Brown <zab@versity.com>
2020-08-26 14:39:28 -07:00
Zach Brown
4e546b2e7c scoutfs-utils: generate end_size_add_cpu()
We had manually implemented a few of the functions to add values to
specific endian types.  Make a macro to generate the function and
generate them for all the endian types we use.

Signed-off-by: Zach Brown <zab@versity.com>
2020-08-26 14:39:28 -07:00
Benjamin LaHaise
74f85ff93d scoutfs: add data_wait_err for reporting errors
Add support for reporting errors to data waiters via a new
SCOUTFS_IOC_DATA_WAIT_ERR ioctl.  This allows waiters to return an error
to readers when staging fails.

Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>
[zab: renamed to data_wait_err, took ino arg]
Signed-off-by: Zach Brown <zab@versity.com>
2020-05-29 13:50:25 -07:00
Zach Brown
79e235af6e scoutfs-utils: fix argv typo in error message
The data_waiting ioctl used the wrong argv index when printing the path
arg string that it failed to open.

Signed-off-by: Zach Brown <zab@versity.com>
2020-05-29 13:50:25 -07:00
Zach Brown
0a8faf3e94 scoutfs-utils: add parse_s64()
Signed-off-by: Zach Brown <zab@versity.com>
2020-05-29 13:50:25 -07:00