sbin/hammer: Don't downgrade when failed to destroy pfs
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Wed, 1 Apr 2015 12:41:31 +0000 (21:41 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Wed, 1 Apr 2015 21:13:23 +0000 (06:13 +0900)
commit750beaefb3ab1644d082583be24cab28388ced0f
treef7ad6fe143d25cbaaa918653c8ff124c21dc511f
parent949403b9a63f5117e5596722d46a6ccd2c21b031
sbin/hammer: Don't downgrade when failed to destroy pfs

- hammer pfs-destroy command downgrades (and change some other params)
  ondisk pfs data before it attempts to destroy the pfs. This leads to
  unexpected result if it fails to destroy because that pfs is left
  with downgraded info. This commit restores the original ondisk pfs
  data on failure in order to keep status (this does generate a new
  ondisk pfs record too).

  ==========
  example1 - using existing /sbin/hammer

  # mount | grep TEST
  TEST on /HAMMER (hammer, local)
  # pwd
  /HAMMER
  # mkdir -p ./mnt
  # hammer pfs-master ./test1 | grep "operating as"
      operating as a MASTER
  # mount_null ./test1 ./mnt
  # mount | grep mnt
  /HAMMER/@@-1:00001 on /HAMMER/mnt (null, local)
  # hammer pfs-destroy ./test1
  You have requested that PFS#1 () be destroyed
  <snip>
  Destroying PFS #1 () in  5 4 3 2 1.. starting destruction pass
  pfs-destroy of PFS#1 failed: Directory not empty
  # hammer pfs-status ./test1 | grep "operating as"
      operating as a SLAVE

  ==========
  example2 - using this commit

  # mount | grep TEST
  TEST on /HAMMER (hammer, local)
  # pwd
  /HAMMER
  # mkdir -p ./mnt
  # hammer pfs-master ./test1 | grep "operating as"
      operating as a MASTER
  # mount_null ./test1 ./mnt
  # mount | grep mnt
  /HAMMER/@@-1:00001 on /HAMMER/mnt (null, local)
  # hammer pfs-destroy ./test1
  You have requested that PFS#1 () be destroyed
  <snip>
  Destroying PFS #1 () in  5 4 3 2 1.. starting destruction pass
  pfs-destroy of PFS#1 failed: Directory not empty
  # hammer pfs-status ./test1 | grep "operating as"
      operating as a MASTER
sbin/hammer/cmd_pseudofs.c