How mar-file-system/gufi works
Purpose and Build Surface
GUFI (Grand Unified File-Index) is a native filesystem-indexing and query toolkit, part of MarFS. It builds primarily as C executables and shared core code through CMake. The top-level build defines the product; executable targets and common library composition are organized under:
• CMakeLists.txt
• src/CMakeLists.txt
• config/CMakeLists.txt
Primary Entry Points
The principal operational pipeline is filesystem/trace ingestion into an index, followed by SQL-oriented traversal and reporting. Core command entry points include:
• src/gufi_dir2index.c — walk a live directory tree and create an index.
• src/gufi_trace2index.c and src/gufi_dir2trace.c — convert between filesystem trees, traces, and indexes.
• src/gufi_query/main.c — query indexed trees.
Additional lifecycle tools include src/gufi_incremental_update/main.c, src/gufi_rollup.c, src/gufi_unrollup.c, and src/gufi_index2dir.c.
Indexing and Metadata Capture
Index construction traverses directory trees, collects file metadata, extended attributes, and optional filesystem-specific data, then materializes per-directory index databases. Traversal and worker primitives establish the parallel boundary:
• src/gufi_dir2index.c
• src/descend.c
• src/QueuePerThreadPool.c
Metadata/database concerns are separated into reusable modules:
• src/dbutils.c
• src/xattrs.c
• src/template_db.c
Query Execution
gufi_query accepts SQL-like work and executes it across indexed directories, with directory processing parallelized and results aggregated or buffered for output. Query parsing/replacement, SQL handling, and traversal are distinct stages:
• src/gufi_query/main.c
• src/gufi_query/process_queries.c
• src/gufi_query/processdir.c
• src/gufi_query/handle_sql.c
The system also exposes indexed data to SQLite-oriented clients and virtual-table workflows through:
• src/gufi_sqlite3.c
• src/gufi_vt.c
• src/run_vt.c
Aggregation, Rollups, and Incremental Maintenance
GUFI supports summarized tree metadata (“rollups”), top-down or bottom-up aggregation, and later reversal/recomputation. Incremental update detects and reindexes changed directories rather than requiring a full rebuild:
• src/rollup.c
• src/gufi_rollup_topdown.c
• src/gufi_incremental_update/incremental_update.c
• src/gufi_incremental_update/reindex_dir.c
This is a key boundary between immutable/indexed historical state and changing live filesystem state.
Deployment, Distribution, and Integrations
Local C binaries are complemented by shell/Python front ends for common operations and distributed scheduling. Distributed wrappers coordinate remote execution, likely using SSH and Slurm-style batch submission templates:
• scripts/distributed/gufi_distributed.py
• scripts/distributed/template.sbatch.in
• scripts/gufi_query.py
External infrastructure includes SQLite and extensions/patches, PCRE support, optional jemalloc, and MarFS-related integration:
• contrib/deps/sqlite3.sh
• contrib/deps/sqlite-vec.sh
• contrib/plugins/marfs_plugin.c
Plugins provide an extension boundary for indexing/querying and storage-system-specific metadata:
• src/plugin.c
• contrib/plugins/dsi_indexing.c
• contrib/plugins/lustre_plugin.c
Outputs and Consumers
Results can be emitted via native command-line programs, scripts implementing familiar filesystem views (find, ls, du, stat), FUSE-related binaries, and optional example interfaces. Representative consumer-facing layers are:
• scripts/gufi_find
• scripts/gufi_ls
• src/bffuse.c
• examples/gui/open-ondemand/app.py
Main entry points: template_db.c Index databases · dbutils.c Metadata DB layer · main.c Query CLI · CMakeLists.txt Core targets
Components 22
Build surface
- Top-level build · Defines the native product build.
CMakeLists.txt - Core targets
src/CMakeLists.txt - Build configuration
config/CMakeLists.txt
Indexing pipeline
- Directory indexer · Walks live filesystem trees into indexes.
src/gufi_dir2index.c - Trace conversion · Converts directory trees, traces, and indexes.
src/gufi_trace2index.c - Traversal engine
src/descend.c - Worker pool · Per-thread queue parallelism boundary.
src/QueuePerThreadPool.c - Metadata DB layer · Captures metadata and materializes per-directory databases.
src/dbutils.c - Extended attributes
src/xattrs.c - Index databases · Persistent per-directory indexed state.
src/template_db.c
Query execution
- Query CLI · Runs SQL-oriented traversal over index trees.
src/gufi_query/main.c - Query processing · Parses and substitutes query work.
src/gufi_query/process_queries.c - Directory execution · Parallel per-directory query processing.
src/gufi_query/processdir.c - SQL handler
src/gufi_query/handle_sql.c - SQLite interface · Exposes indexed data to SQLite clients.
src/gufi_sqlite3.c - Virtual-table runner
src/run_vt.c
Maintenance
- Rollup aggregation · Computes summarized tree metadata.
src/rollup.c - Incremental update · Reindexes changed directories without a full rebuild.
src/gufi_incremental_update/incremental_update.c
Integrations and consumers
- Plugin boundary · Extends indexing and storage metadata handling.
src/plugin.c - Distributed scheduler · Coordinates remote and batch execution.
scripts/distributed/gufi_distributed.py - Filesystem-style views · Consumer commands such as find and ls.
scripts/gufi_find - FUSE interface
src/bffuse.c
Connections 24
- Top-level build → Core targets: includes
- Top-level build → Build configuration: includes
- Core targets → Directory indexer: builds
- Core targets → Query CLI: builds
- Directory indexer → Traversal engine: walks through
- Directory indexer → Worker pool: parallelizes with
- Traversal engine → Metadata DB layer: captures
- Metadata DB layer → Extended attributes: collects
- Metadata DB layer → Index databases: writes
- Trace conversion → Index databases: creates or consumes
- Query CLI → Query processing: parses work with
- Query processing → Directory execution: dispatches
- Directory execution → Worker pool: parallelizes with
- Directory execution → SQL handler: executes
- SQL handler → Index databases: queries
- SQLite interface → Virtual-table runner: supports
- Virtual-table runner → Index databases: reads
- Rollup aggregation → Index databases: aggregates
- Incremental update → Traversal engine: detects and rewalks changes
- Incremental update → Index databases: updates
- Plugin boundary → Metadata DB layer: extends
- Distributed scheduler → Query CLI: runs remotely
- Filesystem-style views → Query CLI: presents
- FUSE interface → SQLite interface: accesses