X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fobdclass%2Fobdcontrol;h=0e11f7805febc78c86e446345854c27084cd0bfc;hb=785d1cb36d8fab4c4750b0c65c92d92830acda8a;hp=295a7d11f4e834b5bcb5d28a41b63716961646f0;hpb=8c1e3ed09d09830bb6628d4e9b6f8ed37b4ec338;p=fs%2Flustre-release.git diff --git a/lustre/obdclass/obdcontrol b/lustre/obdclass/obdcontrol index 295a7d1..0e11f78 100755 --- a/lustre/obdclass/obdcontrol +++ b/lustre/obdclass/obdcontrol @@ -61,6 +61,8 @@ eval 'sub OBD_IOC_COPY () { &_IOC(3, ord(\'f\'), 22, 4);}' unless defined(&OBD_IOC_COPY); eval 'sub OBD_IOC_MIGR () { &_IOC(3, ord(\'f\'), 23, 4);}' unless defined(&OBD_IOC_MIGR); +eval 'sub OBD_IOC_PUNCH () { &_IOC(3, ord(\'f\'), 24, 4);}' unless + defined(&OBD_IOC_PUNCH); eval 'sub OBD_SNAP_SETTABLE () { &_IOC(3, ord(\'f\'), 40, 4);}' unless defined(&OBD_SNAP_SETTABLE); eval 'sub OBD_SNAP_PRINTTABLE () { &_IOC(3, ord(\'f\'), 41, 4);}' unless @@ -210,7 +212,7 @@ my $arg; my %commands = ('device' => {func => "Device", doc => "device : open another OBD device"}, 'create' => {func => "Create", doc => "create [ [ [quiet]]]: create new object(s) (files, unless mode is given)"}, - 'attach' => {func => "Attach", doc => "attach { ext2_obd | snap_obd snapdev snapidx tableno | scsi_obd adapter bus tid lun }: attach this minor device to the specified driver" }, + 'attach' => {func => "Attach", doc => "attach { obdext2 | obdsnap snapdev snapidx tableno | obdscsi adapter bus tid lun }: attach this minor device to the specified driver" }, 'detach' => {func => "Detach", doc => "detach this minor device"}, 'testext2iterator' => {func => "TestExt2Iterator", doc => "test ext2 iterator function"}, 'snapset' => {func => "SnapSetTable", doc => "snapset : set the table (created with snaptable) as table #tableno" }, @@ -222,7 +224,7 @@ my %commands = 'migrate' => {func => "Migrate", doc => "migrate : migrate data from one object to another"}, 'partition' => {func => "Partition", doc => "partition : create a partition"}, 'format' => {func => "Format", doc => "format : format a partition"}, - 'setup' => {func => "Setup", doc => "setup [type]: link this OBD device to the underlying device (default type ext2_obd)"}, + 'setup' => {func => "Setup", doc => "setup [type]: link this OBD device to the underlying device (default type obdext2)"}, 'connect' => {func => "Connect", doc => "connect: allocates client ID for this session"}, 'disconnect' => {func => "Disconnect", doc => "disconnect [id]: frees client resources"}, 'sync' => {func => "Sync", doc => "sync: flushes buffers to disk"}, @@ -232,6 +234,7 @@ my %commands = 'read' => {func => "Read", doc => "read [offset]: read data from object"}, 'fsread' => {func => "Read2", doc => "read [offset]: read data from object"}, 'write' => {func => "Write", doc => "write : write data to object"}, + 'punch' => {func => "Punch", doc => "punch : punch a hole in object"}, 'setattr' => {func => "Setattr", doc => "setattr [mode [uid [gid [size [atime [mtime [ctime]]]]]]]: sets object attributes"}, 'getattr' => {func => "Getattr", doc => "getattr : displays object attributes"}, 'preallocate' => {func => "Preallocate", doc => "preallocate [num]: requests preallocation of num objects."}, @@ -367,11 +370,11 @@ sub Attach { if ( ! $type ) { print "error: missing type\n"; usage: - print "usage: attach {ext2_obd | snap_obd | scsi_obd}\n"; + print "usage: attach {obdext2 | obdsnap | obdscsi}\n"; return; } - if ($type eq "scsi_obd" ) { + if ($type eq "obdscsi" ) { my $adapter = shift; my $bus = shift; my $tid = shift; @@ -379,14 +382,14 @@ usage: $data = pack("iiii", $adapter, $bus, $tid, $lun); $datalen = 4 * 4; - } elsif ($type eq "snap_obd" ) { + } elsif ($type eq "obdsnap" ) { my $snapdev = shift; my $snapidx = shift; my $tableno = shift; $data = pack("iii", $snapdev, $snapidx, $tableno); $datalen = 3 * 4; - } elsif ($type eq "ext2_obd") { + } elsif ($type eq "obdext2") { $data = pack("i", 4711); # bogus data $datalen = 0; } else { @@ -434,7 +437,7 @@ sub TestExt2Iterator { } my $err = 0; - my $type = "ext2_obd"; + my $type = "obdext2"; $data = pack("i", 4711); # bogus data $datalen = 4; @@ -463,7 +466,7 @@ sub SnapDelete { } my $err = 0; - my $type = "snap_obd"; + my $type = "obdsnap"; $data = pack("i", 4711); # bogus data $datalen = 4; @@ -538,7 +541,7 @@ sub SnapRestore { # ready for the ioctl my $err = 0; - my $type = "snap_obd"; + my $type = "obdsnap"; $data = pack("i", $currentindex); # slot of previous current snapshot $datalen = 4; @@ -581,7 +584,7 @@ sub FindSnapInTable { sub SnapPrint { my $err = 0; - my $type = "snap_obd"; + my $type = "obdsnap"; my $snaptableno = shift; $data = pack("i", $snaptableno); @@ -605,7 +608,7 @@ sub SnapPrint { sub SnapSetTable { my $err = 0; - my $type = "snap_obd"; + my $type = "obdsnap"; my $snaptableno = shift; my $file = shift; my $snapcount; @@ -1244,8 +1247,7 @@ sub Write { $count = 0; } - print("Writing $count bytes starting at byte $offset to object " . - "$id...\n"); + print("Writing $count bytes starting at byte $offset to object $id...\n"); my $obdo; $obdo->{id} = $id; @@ -1272,6 +1274,49 @@ sub Write { } } +sub Punch { + if (!defined($::client_id)) { + print "You must first ``connect''.\n"; + return; + } + + my $id = shift; + my $start = shift; + my $count = shift; + + if (!defined($id) || scalar($id) < 1 || !defined($start) || + scalar($start) < 0 || !defined($count) || scalar($count) < 0) { + print "invalid arguments; type \"help punch\" for a synopsis\n"; + return; + } + + print("Punching $count bytes starting at byte $start in object $id...\n"); + + my $obdo; + $obdo->{id} = $id; + + # the perl we're using doesn't support pack type Q + my $packed = pack("L", $::client_id) . obdo_pack($obdo) . + pack("p LL LL", $buf, $start, $count); + + my $rc = ioctl(DEV_OBD, &OBD_IOC_PUNCH, $packed); + + $retval = unpack("l", $packed); + + if (!defined $rc) { + print STDERR "ioctl failed: $!\n"; + } elsif ($rc eq "0 but true") { + if ($retval >= 0) { + print "\nPunched $retval of an attempted $count bytes.\n"; + print "Finished (success)\n"; + } else { + print "Finished (error $retval)\n"; + } + } else { + print "ioctl returned error code $rc.\n"; + } +} + sub Preallocate { my $num = shift;