Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automount of root dataset snapshot goes to wrong directory (/root) #14383

Open
colmbuckley opened this issue Jan 12, 2023 · 6 comments
Open

Automount of root dataset snapshot goes to wrong directory (/root) #14383

colmbuckley opened this issue Jan 12, 2023 · 6 comments
Labels
Type: Defect Incorrect behavior (e.g. crash, hang)

Comments

@colmbuckley
Copy link
Contributor

colmbuckley commented Jan 12, 2023

System information

Type Version/Name
Distribution Name Debian
Distribution Version 11.6 Bullseye
Kernel Version 6.0.0-0.deb11.6-amd64
Architecture x86_64
OpenZFS Version 2.1.7

Describe the problem you're observing

Automatic mounting of snapshots of the root dataset is done in the wrong folder, causing confusion.

For example, cd /.zfs/snapshot/snapname causes the snapshot to be mounted under /root/.zfs/snapshot/snapname rather than /.zfs/snapshot/snapname.

As far as I can tell, only the root dataset is affected.

Describe how to reproduce the problem

For the root dataset; the snapshot is automounted under /root/.zfs/snapshot rather than /.zfs/snapshot as expected.

# zfs get mountpoint rpool/debian
NAME          PROPERTY    VALUE       SOURCE
rpool/debian  mountpoint  /           local
# zfs list -t snap rpool/debian | tail -1
rpool/debian@autosnap_2023-01-12_10:00:15_hourly    216K      -     4.03G  -
# cd /.zfs/snapshot/autosnap_2023-01-12_10:00:15_hourly
cd: too many levels of symbolic links: /.zfs/snapshot/autosnap_2023-01-12_10:00:15_hourly
# mount | grep autosnap_2023-01-12_10:00:15_hourly
rpool/debian@autosnap_2023-01-12_10:00:15_hourly on /root/.zfs/snapshot/autosnap_2023-01-12_10:00:15_hourly type zfs (ro,relatime,xattr,posixacl)
# ls /root/.zfs/snapshot/autosnap_2023-01-12_10:00:15_hourly
bin  boot  dev  etc  home  lib  lib64  libx32  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
# umount /root/.zfs/snapshot/autosnap_2023-01-12_10:00:15_hourly
# 

For another dataset, things seem to work as expected:

# zfs list -t snap rpool/usr/local | tail -1
rpool/usr/local@autosnap_2023-01-12_10:00:15_hourly      0B      -       14M  -
# cd /usr/local/.zfs/snapshot/autosnap_2023-01-12_10:00:15_hourly
# ls
bin  etc  games  lib  man  sbin  share  src
# mount | grep autosnap_2023-01-12_10:00:15_hourly
rpool/usr/local@autosnap_2023-01-12_10:00:15_hourly on /usr/local/.zfs/snapshot/autosnap_2023-01-12_10:00:15_hourly type zfs (ro,relatime,xattr,posixacl)
# cd /
# umount /usr/local/.zfs/snapshot/autosnap_2023-01-12_10:00:15_hourly
# 

One additional weirdness; a new snapshot doesn't seem to be automounted at all…

# zfs snap rpool/debian@testsnap
# cd /.zfs/snapshot/testsnap
# ls -l
total 0
# mount | grep test
# cd /
# mount -t zfs rpool/debian@testsnap /.zfs/snapshot/testsnap
# cd /.zfs/snapshot/testsnap
# ls
bin  boot  dev  etc  home  lib  lib64  libx32  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
# cd /
# umount /.zfs/snapshot/testsnap
# 

Any thoughts? This is stock Debian Bullseye + backports, with the kernel and ZFS (module built from DKMS) straight from Debian's repository.

@colmbuckley colmbuckley added the Type: Defect Incorrect behavior (e.g. crash, hang) label Jan 12, 2023
@colmbuckley
Copy link
Contributor Author

Again, other datasets seem to work fine:

# zfs snap rpool/usr/local@testsnap
# cd /usr/local/.zfs/snapshot/testsnap
# ls
bin  etc  games  lib  man  sbin  share  src
# cd /
# umount /usr/local/.zfs/snapshot/testsnap
# zfs destroy rpool/usr/local@testsnap
# 

@colmbuckley
Copy link
Contributor Author

Properties from the pool and datasets:

# zpool get all rpool
NAME   PROPERTY                       VALUE                          SOURCE
rpool  size                           472G                           -
rpool  capacity                       14%                            -
rpool  altroot                        -                              default
rpool  health                         ONLINE                         -
rpool  guid                           13054706645591046332           -
rpool  version                        -                              default
rpool  bootfs                         -                              default
rpool  delegation                     on                             default
rpool  autoreplace                    off                            default
rpool  cachefile                      -                              default
rpool  failmode                       wait                           default
rpool  listsnapshots                  off                            default
rpool  autoexpand                     off                            default
rpool  dedupratio                     1.00x                          -
rpool  free                           404G                           -
rpool  allocated                      68.4G                          -
rpool  readonly                       off                            -
rpool  ashift                         12                             local
rpool  comment                        -                              default
rpool  expandsize                     -                              -
rpool  freeing                        0                              -
rpool  fragmentation                  1%                             -
rpool  leaked                         0                              -
rpool  multihost                      off                            default
rpool  checkpoint                     -                              -
rpool  load_guid                      9372855339947690343            -
rpool  autotrim                       on                             local
rpool  compatibility                  off                            default
rpool  feature@async_destroy          enabled                        local
rpool  feature@empty_bpobj            active                         local
rpool  feature@lz4_compress           active                         local
rpool  feature@multi_vdev_crash_dump  enabled                        local
rpool  feature@spacemap_histogram     active                         local
rpool  feature@enabled_txg            active                         local
rpool  feature@hole_birth             active                         local
rpool  feature@extensible_dataset     active                         local
rpool  feature@embedded_data          active                         local
rpool  feature@bookmarks              enabled                        local
rpool  feature@filesystem_limits      enabled                        local
rpool  feature@large_blocks           enabled                        local
rpool  feature@large_dnode            active                         local
rpool  feature@sha512                 enabled                        local
rpool  feature@skein                  enabled                        local
rpool  feature@edonr                  enabled                        local
rpool  feature@userobj_accounting     active                         local
rpool  feature@encryption             enabled                        local
rpool  feature@project_quota          active                         local
rpool  feature@device_removal         enabled                        local
rpool  feature@obsolete_counts        enabled                        local
rpool  feature@zpool_checkpoint       enabled                        local
rpool  feature@spacemap_v2            active                         local
rpool  feature@allocation_classes     enabled                        local
rpool  feature@resilver_defer         enabled                        local
rpool  feature@bookmark_v2            enabled                        local
rpool  feature@redaction_bookmarks    enabled                        local
rpool  feature@redacted_datasets      enabled                        local
rpool  feature@bookmark_written       enabled                        local
rpool  feature@log_spacemap           active                         local
rpool  feature@livelist               enabled                        local
rpool  feature@device_rebuild         enabled                        local
rpool  feature@zstd_compress          enabled                        local
rpool  feature@draid                  enabled                        local
# zfs get all rpool/debian
NAME          PROPERTY              VALUE                  SOURCE
rpool/debian  type                  filesystem             -
rpool/debian  creation              Thu Dec 22  9:53 2022  -
rpool/debian  used                  22.9G                  -
rpool/debian  available             372G                   -
rpool/debian  referenced            4.03G                  -
rpool/debian  compressratio         1.00x                  -
rpool/debian  mounted               yes                    -
rpool/debian  quota                 none                   default
rpool/debian  reservation           none                   default
rpool/debian  recordsize            128K                   default
rpool/debian  mountpoint            /                      local
rpool/debian  sharenfs              off                    default
rpool/debian  checksum              on                     default
rpool/debian  compression           off                    default
rpool/debian  atime                 on                     default
rpool/debian  devices               on                     default
rpool/debian  exec                  on                     default
rpool/debian  setuid                on                     default
rpool/debian  readonly              off                    default
rpool/debian  zoned                 off                    default
rpool/debian  snapdir               hidden                 default
rpool/debian  aclmode               discard                default
rpool/debian  aclinherit            restricted             default
rpool/debian  createtxg             6                      -
rpool/debian  canmount              on                     received
rpool/debian  xattr                 sa                     inherited from rpool
rpool/debian  copies                1                      default
rpool/debian  version               5                      -
rpool/debian  utf8only              off                    -
rpool/debian  normalization         none                   -
rpool/debian  casesensitivity       sensitive              -
rpool/debian  vscan                 off                    default
rpool/debian  nbmand                off                    default
rpool/debian  sharesmb              off                    default
rpool/debian  refquota              none                   default
rpool/debian  refreservation        none                   default
rpool/debian  guid                  14792304419369271078   -
rpool/debian  primarycache          all                    default
rpool/debian  secondarycache        all                    default
rpool/debian  usedbysnapshots       18.9G                  -
rpool/debian  usedbydataset         4.03G                  -
rpool/debian  usedbychildren        0B                     -
rpool/debian  usedbyrefreservation  0B                     -
rpool/debian  logbias               latency                default
rpool/debian  objsetid              272                    -
rpool/debian  dedup                 off                    default
rpool/debian  mlslabel              none                   default
rpool/debian  sync                  standard               default
rpool/debian  dnodesize             auto                   inherited from rpool
rpool/debian  refcompressratio      1.00x                  -
rpool/debian  written               120K                   -
rpool/debian  logicalused           20.6G                  -
rpool/debian  logicalreferenced     3.71G                  -
rpool/debian  volmode               default                default
rpool/debian  filesystem_limit      none                   default
rpool/debian  snapshot_limit        none                   default
rpool/debian  filesystem_count      none                   default
rpool/debian  snapshot_count        none                   default
rpool/debian  snapdev               hidden                 default
rpool/debian  acltype               posix                  inherited from rpool
rpool/debian  context               none                   default
rpool/debian  fscontext             none                   default
rpool/debian  defcontext            none                   default
rpool/debian  rootcontext           none                   default
rpool/debian  relatime              on                     inherited from rpool
rpool/debian  redundant_metadata    all                    default
rpool/debian  overlay               on                     default
rpool/debian  encryption            off                    default
rpool/debian  keylocation           none                   default
rpool/debian  keyformat             none                   default
rpool/debian  pbkdf2iters           0                      default
rpool/debian  special_small_blocks  0                      default
# zfs get all rpool/usr/local
NAME             PROPERTY              VALUE                  SOURCE
rpool/usr/local  type                  filesystem             -
rpool/usr/local  creation              Thu Dec 22  9:53 2022  -
rpool/usr/local  used                  23.1M                  -
rpool/usr/local  available             372G                   -
rpool/usr/local  referenced            14M                    -
rpool/usr/local  compressratio         1.00x                  -
rpool/usr/local  mounted               yes                    -
rpool/usr/local  quota                 none                   default
rpool/usr/local  reservation           none                   default
rpool/usr/local  recordsize            128K                   default
rpool/usr/local  mountpoint            /usr/local             inherited from rpool
rpool/usr/local  sharenfs              off                    default
rpool/usr/local  checksum              on                     default
rpool/usr/local  compression           off                    default
rpool/usr/local  atime                 on                     default
rpool/usr/local  devices               on                     default
rpool/usr/local  exec                  on                     default
rpool/usr/local  setuid                on                     default
rpool/usr/local  readonly              off                    default
rpool/usr/local  zoned                 off                    default
rpool/usr/local  snapdir               hidden                 default
rpool/usr/local  aclmode               discard                default
rpool/usr/local  aclinherit            restricted             default
rpool/usr/local  createtxg             44                     -
rpool/usr/local  canmount              on                     default
rpool/usr/local  xattr                 sa                     inherited from rpool
rpool/usr/local  copies                1                      default
rpool/usr/local  version               5                      -
rpool/usr/local  utf8only              on                     -
rpool/usr/local  normalization         formD                  -
rpool/usr/local  casesensitivity       sensitive              -
rpool/usr/local  vscan                 off                    default
rpool/usr/local  nbmand                off                    default
rpool/usr/local  sharesmb              off                    default
rpool/usr/local  refquota              none                   default
rpool/usr/local  refreservation        none                   default
rpool/usr/local  guid                  4994713609671713721    -
rpool/usr/local  primarycache          all                    default
rpool/usr/local  secondarycache        all                    default
rpool/usr/local  usedbysnapshots       9.11M                  -
rpool/usr/local  usedbydataset         14M                    -
rpool/usr/local  usedbychildren        0B                     -
rpool/usr/local  usedbyrefreservation  0B                     -
rpool/usr/local  logbias               latency                default
rpool/usr/local  objsetid              778                    -
rpool/usr/local  dedup                 off                    default
rpool/usr/local  mlslabel              none                   default
rpool/usr/local  sync                  standard               default
rpool/usr/local  dnodesize             auto                   inherited from rpool
rpool/usr/local  refcompressratio      1.00x                  -
rpool/usr/local  written               0                      -
rpool/usr/local  logicalused           22.0M                  -
rpool/usr/local  logicalreferenced     13.8M                  -
rpool/usr/local  volmode               default                default
rpool/usr/local  filesystem_limit      none                   default
rpool/usr/local  snapshot_limit        none                   default
rpool/usr/local  filesystem_count      none                   default
rpool/usr/local  snapshot_count        none                   default
rpool/usr/local  snapdev               hidden                 default
rpool/usr/local  acltype               posix                  inherited from rpool
rpool/usr/local  context               none                   default
rpool/usr/local  fscontext             none                   default
rpool/usr/local  defcontext            none                   default
rpool/usr/local  rootcontext           none                   default
rpool/usr/local  relatime              on                     inherited from rpool
rpool/usr/local  redundant_metadata    all                    default
rpool/usr/local  overlay               on                     default
rpool/usr/local  encryption            off                    default
rpool/usr/local  keylocation           none                   default
rpool/usr/local  keyformat             none                   default
rpool/usr/local  pbkdf2iters           0                      default
rpool/usr/local  special_small_blocks  0                      default

@siv0
Copy link
Contributor

siv0 commented Jan 12, 2023

Seems like the behavior seen in:
#9461 (comment)

@colmbuckley
Copy link
Contributor Author

colmbuckley commented Jan 12, 2023

Yes, I suspect it is the same root (ha) issue. Suggest marking this as a duplicate.

@rincebrain
Copy link
Contributor

rincebrain commented Jan 13, 2023

I think I might have seen someone cut a PR for 2.1.8 about this? Let me look...

e: Nope, was thinking of f28c730

colmbuckley referenced this issue Feb 25, 2023
A followup to d7a6740

For `mount -t zfs -o opts ds mp` command line
some implementations of `mount(8)`, e. g. Busybox in Debian
work as follows:

```
newfstatat(AT_FDCWD, "ds", 0x7fff826f4ab0, 0) = -1
mount("ds", "mp", "zfs", MS_SILENT, NULL) = 0
```

The logic above skips completely `mount.zfs` and prevents us
from reading filesystem properties and applying mount options.

For comparison, the coreutils `mount(8)` implementation does:

```
openat(AT_FDCWD, "/proc/filesystems", O_RDONLY|O_CLOEXEC) = 3
// figure out that zfs is a `nodev` filesystem and look for a helper
newfstatat(AT_FDCWD, "/sbin/mount.zfs" ...) = 0
execve("/sbin/mount.zfs" ...) = 0
```

Using `mount.zfs` in initramfs would help circumvent deficiencies
of some of `mount(8)` implementations. `mount -t zfs` translates
to `mount.zfs` invocation, except for cases when explicitly disabled
by `-i`.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes #13305
(cherry picked from commit 35d81a7)
@RichieB2B
Copy link

RichieB2B commented Jul 20, 2023

I'm seeing this issue after upgrading my system to Debian 12 (bookworm) that includes OpenZFS 2.1.11. Is there a fix or patch that can be applied?

Edit: looks like this is fixed in 2.1.12. I will need to test this to confirm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Defect Incorrect behavior (e.g. crash, hang)
Projects
None yet
Development

No branches or pull requests

4 participants