git: sbin/hammer: Make hammer history support per-path @offset, length

Tomohiro Kusumi tkusumi at crater.dragonflybsd.org
Thu Sep 24 07:46:34 PDT 2015


commit 8907a51b7b8f1eb4a5713beec0cf055e9b6ded31
Author: Tomohiro Kusumi <kusumi.tomohiro at gmail.com>
Date:   Mon Sep 14 08:00:26 2015 +0900

    sbin/hammer: Make hammer history support per-path @offset,length
    
    This commit allows each arg of the hammer history to take
    @offset,length attribute. It was strange behavior that the
    command takes a global @offset,length attribute while the
    command supports multiple paths to lookup history for.
    
    This commit doesn't break the existing behavior where one
    specifies @offset,length attribute as a part of the command
    name as "history at offset,length".
    
    If the old style attribute (history at offset,length) is used,
    then the command doesn't parse per-path attribute, but sees
    the whole string as a path. Otherwise the command parses
    per-path attribute and uses offset,length unique to each,
    unless the whole string including the attribute part exists
    as a path (can stat(2)).
    
    =====
      # touch /HAMMER/out1
      # touch /HAMMER/out2
      # for x in {1..5}; do
      > cat dragonfly/sys/vfs/hammer/hammer.h >> /HAMMER/out1
      > sync; sync; sync; sync; sleep 1
      > done
      # for x in {1..5}; do
      > cat dragonfly/sys/vfs/hammer/hammer.h >> /HAMMER/out2
      > sync; sync; sync; sync; sleep 1
      > done
      # hammer history /HAMMER/out1 /HAMMER/out2
      /HAMMER/out1    0000000184acac5e clean {
          0000000184b59b00 15-Sep-2015 03:56:46
          0000000184b59b20 15-Sep-2015 03:56:47
          0000000184b59c80 15-Sep-2015 03:56:48
          0000000184b59dc0 15-Sep-2015 03:56:49
          0000000184b59f20 15-Sep-2015 03:56:50
          0000000184b5a060 15-Sep-2015 03:56:51
      }
      /HAMMER/out2    0000000184acaca6 clean {
          0000000184b59b00 15-Sep-2015 03:56:46
          0000000184b5a1c0 15-Sep-2015 03:57:02
          0000000184b5a320 15-Sep-2015 03:57:03
          0000000184b5a460 15-Sep-2015 03:57:04
          0000000184b5a5c0 15-Sep-2015 03:57:05
          0000000184b5a700 15-Sep-2015 03:57:06
      }
      # hammer history at 50000,1000 /HAMMER/out1 /HAMMER/out2
      /HAMMER/out1    0000000184acac5e clean {
          0000000184b59b20 15-Sep-2015 03:56:47
          0000000184b59c80 15-Sep-2015 03:56:48
      }
      /HAMMER/out2    0000000184acaca6 clean {
          0000000184b5a1c0 15-Sep-2015 03:57:02
          0000000184b5a320 15-Sep-2015 03:57:03
      }
      # hammer history /HAMMER/out1 at 50000,1000 /HAMMER/out2 at 50000,1000
      /HAMMER/out1    0000000184acac5e clean {
          0000000184b59b20 15-Sep-2015 03:56:47
          0000000184b59c80 15-Sep-2015 03:56:48
      }
      /HAMMER/out2    0000000184acaca6 clean {
          0000000184b5a1c0 15-Sep-2015 03:57:02
          0000000184b5a320 15-Sep-2015 03:57:03
      }
      # hammer history /HAMMER/out1 at 50000,1000 /HAMMER/out2 at 200000,1000
      /HAMMER/out1    0000000184acac5e clean {
          0000000184b59b20 15-Sep-2015 03:56:47
          0000000184b59c80 15-Sep-2015 03:56:48
      }
      /HAMMER/out2    0000000184acaca6 clean {
          0000000184b5a5c0 15-Sep-2015 03:57:05
      }
      # hammer history at 50000,1000 /HAMMER/out1 at 50000,1000 /HAMMER/out2 at 200000,1000
      /HAMMER/out1 at 50000,1000 No such file or directory
      /HAMMER/out2 at 200000,1000        No such file or directory
      # touch /HAMMER/out1 at 50000,1000
      # sync; sync; sync; sync; sleep 1
      # touch /HAMMER/out2 at 200000,1000
      # sync; sync; sync; sync; sleep 1
      # hammer history /HAMMER/out1 at 50000,1000 /HAMMER/out2 at 200000,1000
      /HAMMER/out1 at 50000,1000 0000000184acaca7 clean {
          0000000184b6ae20 15-Sep-2015 04:05:09
      }
      /HAMMER/out2 at 200000,1000        0000000184acae20 clean {
          0000000184b6b180 15-Sep-2015 04:06:11
      }

Summary of changes:
 sbin/hammer/cmd_history.c | 113 +++++++++++++++++++++++++++++++++++-----------
 sbin/hammer/hammer.8      |  15 +++++-
 2 files changed, 100 insertions(+), 28 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/8907a51b7b8f1eb4a5713beec0cf055e9b6ded31


-- 
DragonFly BSD source repository



More information about the Commits mailing list