From 6e13ecc0f3c1a86d09096a2512c183841588a656837c8e650276c0b92834c314 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Wed, 7 Aug 2024 12:31:42 +0300 Subject: [PATCH] Note about possible "out of sync" --- README | 6 +++--- USAGE | 6 ++++++ main.go | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README b/README index 150009a..f4cbecd 100644 --- a/README +++ b/README @@ -8,9 +8,9 @@ changes to existing database. Why I wrote it? I have got ~18M files ZFS data storage, where even "find /storage" takes considerable amount of time, up to an hour. So I have to use separate indexed database and search against it. -locate family of utilities does exactly that. But none of them are +"locate" family of utilities does exactly that. But none of them are able to detect a few seldom made changes to the dataset, without -traversing through the whole dataset anyway, taking much IO. +traversing through the whole dataset anyway, consuming much IO. Fortunately ZFS design with Merkle trees is able to show us the difference quickly and without notable IO. "zfs diff" command's @@ -18,7 +18,7 @@ output is very machine friendly. So locate-like utility has to be able to update its database with zfs-diff's output. Why this utility is so relatively complicated? Initially it kept all -database in memory, but that took 2-3 GiBs of memory, that is huge +database in memory, but that took 2-3 GiBs of memory, that is a huge amount. Moreover it fully loads it to perform any basic searches. So current implementation uses temporary files and heavy use of data streaming. Database in my case takes less than 128MiB of data. And diff --git a/USAGE b/USAGE index fb9e732..e9a05a0 100644 --- a/USAGE +++ b/USAGE @@ -45,3 +45,9 @@ snapshot and feed its diff to the command: Argument to -update is the prefix stripped from each filename of diff's output. + +Sometimes "+ and M lists are out of sync" error may be raised. +Unfortunately you have to fix it manually. It may arise when you create +completely new dataset and "zfs diff" shows "M"odification of its root +directory, but there was no its "+" (creation). You can manually add "+" +entry to the list you feed to stdin. diff --git a/main.go b/main.go index 39a41ab..1087f84 100644 --- a/main.go +++ b/main.go @@ -40,7 +40,7 @@ func (ent *Ent) IsDir() bool { func dbCommit(dbPath string, tmp *os.File) { umask := syscall.Umask(0) syscall.Umask(umask) - if err := os.Chmod(tmp.Name(), os.FileMode(0666&^umask)); err != nil { + if err := os.Chmod(tmp.Name(), os.FileMode(0o666&^umask)); err != nil { log.Fatalln(err) } if err := os.Rename(tmp.Name(), dbPath); err != nil { -- 2.44.0