mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-12-08 00:00:12 +03:00
Some checks failed
build / bcachefs-tools-deb (ubuntu-24.04) (push) Has been cancelled
build / bcachefs-tools-rpm (push) Has been cancelled
build / bcachefs-tools-msrv (push) Has been cancelled
Nix Flake actions / nix-matrix (push) Has been cancelled
Nix Flake actions / ${{ matrix.name }} (${{ matrix.system }}) (push) Has been cancelled
bcachefs uses 64 bit inode numbers by default, which overflow genradix keys when we multiply the inode number by the object size for the actual genradix lookup. Switch to a rhashtable, and only index files that actually have hardlinks. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
63 lines
2.0 KiB
C
63 lines
2.0 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _POSIX_TO_BCACHEFS_H
|
|
#define _POSIX_TO_BCACHEFS_H
|
|
|
|
/*
|
|
* This header exports the functionality needed for copying data from existing
|
|
* posix compliant filesystems to bcachefs. There are two use cases:
|
|
* 1. Creating a new bcachefs filesystem using `bcachefs format`, we can
|
|
* specify a source directory tree which will be copied over the new
|
|
* bcachefs filesytem.
|
|
* 2. Migrating an existing filesystem in place, with `bcachefs migrate`.
|
|
* This will allocate space for the bcachefs metadata, but the actual data
|
|
* represented by the extents will not be duplicated. The bcachefs metadata
|
|
* will simply point to the existing extents.
|
|
*
|
|
* To avoid code duplication, `copy_fs` deals with both cases. See the function
|
|
* documentation for more details.
|
|
*/
|
|
|
|
#include "libbcachefs.h"
|
|
|
|
enum bch_migrate_type {
|
|
BCH_MIGRATE_copy,
|
|
BCH_MIGRATE_migrate
|
|
};
|
|
|
|
/*
|
|
* The migrate action uses all the fields in this struct.
|
|
* The copy action only uses the `hardlinks` field. Since `hardlinks` is
|
|
* initialized with zeroes, an empty `copy_fs_state` struct can be passed.
|
|
*/
|
|
struct copy_fs_state {
|
|
u64 bcachefs_inum;
|
|
dev_t dev;
|
|
|
|
struct rhashtable hardlinks;
|
|
ranges extents;
|
|
enum bch_migrate_type type;
|
|
unsigned verbosity;
|
|
|
|
u64 reserve_start;
|
|
|
|
u64 total_files;
|
|
u64 total_input;
|
|
u64 total_wrote;
|
|
u64 total_linked;
|
|
};
|
|
|
|
/*
|
|
* The `copy_fs` function is used for both copying a directory tree to a new
|
|
* bcachefs filesystem and migrating an existing one, depending on the value
|
|
* from the `type` field in `copy_fs_state` struct.
|
|
*
|
|
* In case of copy, an empty `copy_fs_state` structure is passed to `copy_fs`
|
|
* (only the `hardlinks` field is used, and that is initialized with zeroes).
|
|
*
|
|
* In the migrate case, all the fields from `copy_fs_state` need to be
|
|
* initialized (`hardlinks` is initialized with zeroes).
|
|
*/
|
|
int copy_fs(struct bch_fs *, struct copy_fs_state *, int, const char *);
|
|
|
|
#endif /* _LIBBCACHE_H */
|