git: sys/vfs/hammer: Fix volume-del issue with >1 pfs

Tomohiro Kusumi tkusumi at crater.dragonflybsd.org
Mon Aug 17 09:06:31 PDT 2015


commit 16ed94f05bc8aeeab14bda9f83494e5b432fdb97
Author: Tomohiro Kusumi <kusumi.tomohiro at gmail.com>
Date:   Sun Aug 9 12:29:12 2015 +0900

    sys/vfs/hammer: Fix volume-del issue with >1 pfs
    
    Since 5e1e1454 hammer reblock supports a new option that
    can reblock all pfses within filesystem.
    
    hammer volume-del needs to use this when it finds the volume
    not empty and needs to reblock. Otherwise it only reblocks a
    single pfs (pfs 0 in this case) and may end up ignoring data
    in other pfses that should have been reblocked from that volume
    (remember that pfs has nothing to do with which volume pfs
    data/inodes/etc are stored in).
    
    As the following examples show, hammer volume-del results in
    failure if the above situation occurs. It fails because data
    in non-pfs0 remains in that volume without being reblocked.
    If one is lucky that the volume doesn't have non-pfs0 data,
    then hammer volume-del won't fail even without allpfs=1 set
    (of course given that the whole filesystem has enough space
    for reblock to succeed).
    
    --
    Create filesystem that consists of 3 volumes and >1 pfses.
    The root volume can't be removed, so fill up non-zero pfses
    till it gets to the second volume while keeping enough space
    for reblock to succeed. Then try to remove a non-root volume
    that isn't empty which is /dev/da2 in this case.
    
      # hammer volume-blkdevs /HAMMER
      /dev/da1:/dev/da2:/dev/da3    /* /dev/da1 is root volume */
      # ls -l /HAMMER               /* data exists in pfs 1 to 12 */
      total 0
      lrwxr-xr-x  1 root  wheel  10 Aug  9 13:24 master1 -> @@-1:00001
      lrwxr-xr-x  1 root  wheel  10 Aug  9 13:31 master10 -> @@-1:00010
      lrwxr-xr-x  1 root  wheel  10 Aug  9 13:32 master11 -> @@-1:00011
      lrwxr-xr-x  1 root  wheel  10 Aug  9 13:33 master12 -> @@-1:00012
      lrwxr-xr-x  1 root  wheel  10 Aug  9 13:25 master2 -> @@-1:00002
      lrwxr-xr-x  1 root  wheel  10 Aug  9 13:26 master3 -> @@-1:00003
      lrwxr-xr-x  1 root  wheel  10 Aug  9 13:27 master4 -> @@-1:00004
      lrwxr-xr-x  1 root  wheel  10 Aug  9 13:28 master5 -> @@-1:00005
      lrwxr-xr-x  1 root  wheel  10 Aug  9 13:29 master6 -> @@-1:00006
      lrwxr-xr-x  1 root  wheel  10 Aug  9 13:29 master7 -> @@-1:00007
      lrwxr-xr-x  1 root  wheel  10 Aug  9 13:30 master8 -> @@-1:00008
      lrwxr-xr-x  1 root  wheel  10 Aug  9 13:31 master9 -> @@-1:00009
      # df -Th /HAMMER
      Filesystem  Type     Size   Used  Avail Capacity  Mounted on
      TEST        hammer   334G   118G   216G    35%    /HAMMER
      # hammer -f /dev/da1:/dev/da2:/dev/da3 blockmap | grep -A2 layer1
        layer1 4000000000000000 @2000000000800000 blocks-free 0
              4000000000000000 zone=4  app=8388608 free=0
              4000000000800000 zone=4  app=8388608 free=0
      --
        layer1 4010000000000000 @2010000000000000 blocks-free 13449
              4010000000000000 zone=4  app=8388608 free=0
              4010000000800000 zone=10 app=8388608 free=0
      --
        layer1 4020000000000000 @2020000000000000 blocks-free 14268
              4020000000000000 zone=4  app=8388608 free=0
              4020000000800000 zone=0  app=0       free=8388608
    		/* /dev/da1 is 100% used,
    		   /dev/da2 is partially used,
    		   /dev/da3 is 0% used */
    
    Example 1. - without allpfs=1 fails in a second because
    there isn't really anything it can do as there's no data
    in pfs0 except for some inodes and btree nodes, etc.
      # time hammer volume-del /dev/da2 /HAMMER
      hammer volume-del ioctl: Device busy
    
      real    0m0.017s
      user    0m0.000s
      sys     0m0.000s
      # dmesg | tail -2
      reblock started
      Failed to free volume: Volume 1 not empty
    
    Example 2. - this commit with allpfs=1 takes 15 min because
    it reblocks all the data in all pfses (mostly from non-pfs0),
    but successfully removes /dev/da2.
      # time hammer volume-del /dev/da2 /HAMMER
    
      real    15m7.664s
      user    0m0.000s
      sys     7m36.270s
      # hammer volume-blkdevs /HAMMER
      /dev/da1:/dev/da3

Summary of changes:
 sys/vfs/hammer/hammer_volume.c | 1 +
 1 file changed, 1 insertion(+)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/16ed94f05bc8aeeab14bda9f83494e5b432fdb97


-- 
DragonFly BSD source repository



More information about the Commits mailing list