perf(zfs): optimise pool listing for pools with many datasets (#440)

Restricting the `zfs list` command to depth 1 saves a lot of time for
pools with many datasets/zvols.

In my case, before:
```
$ time zfs list -s name -o name,guid,available -H -p >/dev/null
real    0m3.853s
user    0m0.171s
sys     0m3.539s
```

After:
```
$ time zfs list -d 1 -s name -o name,guid,available -H -p >/dev/null
real    0m0.027s
user    0m0.002s
sys     0m0.026s
```

Signed-off-by: Joel Low <joel@joelsplace.sg>
This commit is contained in:
Joel Low 2023-05-29 11:47:28 +08:00 committed by GitHub
parent 4b059dbfaa
commit ba0e1749ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View file

@ -0,0 +1 @@
optimise pool listing for pools with many datasets

View file

@ -921,7 +921,7 @@ func CreateRestore(rstr *apis.ZFSRestore) error {
// pools in the node. // pools in the node.
func ListZFSPool() ([]apis.Pool, error) { func ListZFSPool() ([]apis.Pool, error) {
args := []string{ args := []string{
ZFSListArg, "-s", "name", ZFSListArg, "-d", "1", "-s", "name",
"-o", "name,guid,available", "-o", "name,guid,available",
"-H", "-p", "-H", "-p",
} }