diff options
Diffstat (limited to 'cmd/btrfs-rec')
-rw-r--r-- | cmd/btrfs-rec/inspect_scandevices.go | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/cmd/btrfs-rec/inspect_scandevices.go b/cmd/btrfs-rec/inspect_scandevices.go index f5caadb..a7a7fb2 100644 --- a/cmd/btrfs-rec/inspect_scandevices.go +++ b/cmd/btrfs-rec/inspect_scandevices.go @@ -6,18 +6,14 @@ package main import ( "bufio" - "context" "os" - "sync" "git.lukeshu.com/go/lowmemjson" - "github.com/datawire/dlib/dgroup" "github.com/datawire/dlib/dlog" "github.com/datawire/ocibuild/pkg/cliutil" "github.com/spf13/cobra" "git.lukeshu.com/btrfs-progs-ng/lib/btrfs" - "git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsvol" "git.lukeshu.com/btrfs-progs-ng/lib/btrfsprogs/btrfsinspect" ) @@ -35,26 +31,8 @@ func init() { } ctx := cmd.Context() - var resultsMu sync.Mutex - results := make(map[btrfsvol.DeviceID]btrfsinspect.ScanOneDeviceResult) - grp := dgroup.NewGroup(ctx, dgroup.GroupConfig{}) - for _, dev := range fs.LV.PhysicalVolumes() { - dev := dev - grp.Go(dev.Name(), func(ctx context.Context) error { - superblock, err := dev.Superblock() - if err != nil { - return err - } - dlog.Infof(ctx, "dev[%q] Scanning for unreachable nodes...", dev.Name()) - devResult, err := btrfsinspect.ScanOneDevice(ctx, dev, *superblock) - dlog.Infof(ctx, "dev[%q] Finished scanning", dev.Name()) - resultsMu.Lock() - results[superblock.DevItem.DevID] = devResult - resultsMu.Unlock() - return err - }) - } - if err := grp.Wait(); err != nil { + results, err := btrfsinspect.ScanDevices(ctx, fs) + if err != nil { return err } @@ -64,8 +42,11 @@ func init() { maybeSetErr(buffer.Flush()) }() return lowmemjson.Encode(&lowmemjson.ReEncoder{ - Out: buffer, - Indent: "\t", + Out: buffer, + + Indent: "\t", + ForceTrailingNewlines: true, + CompactIfUnder: 16, }, results) }, }) |