git: usr.sbin/makefs: Add HAMMER2 offline bulkfree support

Tomohiro Kusumi tkusumi at crater.dragonflybsd.org
Sat Jun 3 23:33:43 PDT 2023


commit a63188c81886f62d9f7d45b8fad235eef99b7c05
Author: Tomohiro Kusumi <tkusumi at netbsd.org>
Date:   Sat Jun 3 00:12:15 2023 -0700

    usr.sbin/makefs: Add HAMMER2 offline bulkfree support
    
    Since makefs HAMMER2 implements the entire HAMMER2 logic in userspace
    with selected vops using single threaded xops, it's actually trivial
    to support other operations, e.g. HAMMER2 ioctls.
    
    This commit adds bulkfree (free unreferenced blocks by scanning the
    entire data chains from vchain) option to makefs. Unlike the existing
    hammer2(8) "bulkfree" directive which requires live filesystem, this
    option enables offline bulkfree against unmounted HAMMER2 image.
    
    The offline bulkfree takes HAMMER2 specific "-o B" option. When this
    option is specified, makefs runs offline bulkfree against `image-file`
    argument instead of creating one, hence it must be a valid HAMMER2
    image. `image-file` can be either a regular file or block device.
    Unlike normal use case, `directory` argument is unused, but it's
    still required. It can be any valid path or simply "--".
    
    e.g.
    $ makefs -t hammer2 -o B /dev/adx --
    $ makefs -t hammer2 -o B /path/to/hammer2.img --
    
    Technically, all HAMMER2 ioctls can be implemented in makefs as
    offline version, but "bulkfree" and "growfs" are probably the only
    hammer2(8) directives that make sense to exist as offline version.
    
    Note that the limitation regarding OOM mentioned in 2d60b848f2 also
    applies to bulkfree, i.e. makefs(8) could fail with partially written
    `image-file` if it contains insane number of files or directories.

Summary of changes:
 usr.sbin/makefs/hammer2.c                          | 72 +++++++++++++++++-----
 usr.sbin/makefs/hammer2.h                          |  1 +
 usr.sbin/makefs/hammer2/Makefile.inc               |  2 +-
 usr.sbin/makefs/hammer2/hammer2.h                  | 16 +----
 .../makefs}/hammer2/hammer2_bulkfree.c             | 23 +++++--
 .../makefs}/hammer2/hammer2_ioctl.c                | 13 ++--
 usr.sbin/makefs/hammer2/hammer2_ondisk.c           | 36 +++++++----
 usr.sbin/makefs/hammer2/hammer2_subr.c             |  5 +-
 usr.sbin/makefs/makefs.8                           |  8 ++-
 usr.sbin/makefs/makefs.c                           | 14 +++--
 usr.sbin/makefs/walk.c                             |  4 +-
 11 files changed, 136 insertions(+), 58 deletions(-)
 copy {sys/vfs => usr.sbin/makefs}/hammer2/hammer2_bulkfree.c (99%)
 copy {sys/vfs => usr.sbin/makefs}/hammer2/hammer2_ioctl.c (99%)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/a63188c81886f62d9f7d45b8fad235eef99b7c05


-- 
DragonFly BSD source repository


More information about the Commits mailing list