From 5bf6eb994ec6136b5fe64446d6bf673e4c3e7cbd Mon Sep 17 00:00:00 2001 From: adilger Date: Tue, 7 Dec 1999 00:55:01 +0000 Subject: [PATCH] snap/snap.c, snap/snaptable.c: Fixed up snapshot to work again with snaptables, added snap_iterate() calldown, snap_cleanup() to free a snapshot table entry ext2obd/ext2_obd.c: added iterator ext2obd_iterate() for all inodes class/class_obd.c: blocked TCGETS IOCTL, added connection ID to calls class/obdcontrol: added IOCTL for testing iterator, connection ID --- lustre/include/linux/obd_class.h | 4 +++- lustre/include/linux/obd_sim.h | 3 +++ lustre/include/linux/obd_snap.h | 1 - lustre/obdclass/class_obd.c | 10 ++++++--- lustre/obdclass/obdcontrol | 46 +++++++++++++++++++++++++++++++++------- 5 files changed, 51 insertions(+), 13 deletions(-) diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h index 73acad6..4dec562 100644 --- a/lustre/include/linux/obd_class.h +++ b/lustre/include/linux/obd_class.h @@ -95,7 +95,8 @@ struct obd_ops { int (*o_set_info)(struct obd_conn *, int keylen, void *key, int vallen, void *val); int (*o_migrate)(struct obd_conn *, obdattr *src, obdattr *dst); int (*o_copy)(struct obd_conn *dev, obdattr *source, obdattr *target); - int (*o_iocontrol)(int cmd, int len, void *karg, void *uarg); + int (*o_iocontrol)(int cmd, struct obd_conn *, int len, void *karg, void *uarg); + int (*o_iterate)(struct obd_conn *, objid, int (*)(objid, void *), void *); }; @@ -135,6 +136,7 @@ int gen_copy_data(struct obd_conn *, obdattr *source, obdattr *target); * ioctl commands */ struct oic_generic { + int att_connid; int att_typelen; void *att_type; int att_datalen; diff --git a/lustre/include/linux/obd_sim.h b/lustre/include/linux/obd_sim.h index 6943898..c95fb04 100644 --- a/lustre/include/linux/obd_sim.h +++ b/lustre/include/linux/obd_sim.h @@ -1,6 +1,9 @@ #ifndef _OBD_SIM #define _OBD_SIM +#define OBD_EXT2_RUNIT _IOWR('f', 61, long) + + struct ext2_obd { struct super_block * ext2_sb; }; diff --git a/lustre/include/linux/obd_snap.h b/lustre/include/linux/obd_snap.h index 95ea117..864dcd0 100644 --- a/lustre/include/linux/obd_snap.h +++ b/lustre/include/linux/obd_snap.h @@ -70,7 +70,6 @@ struct snap_object_data { #define this_snapidx(obd) (obd->u.snap.snap_index) -extern int snap_iocontrol(int cmd, int len, void *karg, void *uarg); void snap_use(int table_no, int snap_index) ; void snap_unuse(int table_no, int snap_index) ; int snap_is_used(int table_no, int snap_index) ; diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index eab54c9..f597be7 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -168,6 +168,8 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp, conn.oc_dev = obddev; switch (cmd) { + case TCGETS: + return -EINVAL; case OBD_IOC_ATTACH: { struct obd_type *type; struct oic_generic input; @@ -791,19 +793,21 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp, EXIT; return -EINVAL; } - + conn.oc_id = input.att_connid; CDEBUG(D_IOCTL, "Calling ioctl %x for type %s, len %d\n", cmd, type->typ_name, input.att_datalen); /* get the generic data */ + karg = input.att_data; if ( (err = getdata(input.att_datalen, &karg)) ) { EXIT; return err; } - err = type->typ_ops->o_iocontrol(cmd, input.att_datalen, - karg, input.att_data); + err = type->typ_ops->o_iocontrol + (cmd, &conn, input.att_datalen, + karg, input.att_data); OBD_FREE(karg, input.att_datalen); EXIT; diff --git a/lustre/obdclass/obdcontrol b/lustre/obdclass/obdcontrol index e4eebbe..8bdfd02 100755 --- a/lustre/obdclass/obdcontrol +++ b/lustre/obdclass/obdcontrol @@ -66,6 +66,9 @@ eval 'sub OBD_SNAP_SETTABLE () { &_IOC(3, ord(\'f\'), 40, 4);}' unless eval 'sub OBD_SNAP_PRINTTABLE () { &_IOC(3, ord(\'f\'), 41, 4);}' unless defined(&OBD_SNAP_PRINTTABLE); +eval 'sub OBD_EXT2_RUNIT () { &_IOC(3, ord(\'f\'), 61, 4);}' unless + defined(&OBD_EXT2_RUNIT); + eval 'sub ATTR_MODE () {1;}' unless defined(&ATTR_MODE); eval 'sub ATTR_UID () {2;}' unless defined(&ATTR_UID); eval 'sub ATTR_GID () {4;}' unless defined(&ATTR_GID); @@ -103,6 +106,8 @@ my %commands = 'snapset' => {func => "SnapSetTable", doc => "snapset tableno file" }, 'snapprint' => {func => "SnapPrint", doc => "snapprint tableno"}, + 'testiterator' => {func => "TestIterator", doc => ""}, + 'snaptable' => {func => "SnapShotTable", doc => "snaptable: build a snapshot table (interactive)"}, 'copy' => {func => "Copy", doc => "copy srcid tgtid"}, 'migrate' => {func => "Migrate", doc => "migrate srcid tgtid"}, @@ -267,7 +272,7 @@ sub Attach { $datalen = 4 * 4; } - my $packed = pack("ipip", length($type), $type, $datalen, $data); + my $packed = pack("Lipip", $::client_id, length($type), $type, $datalen, $data); my $rc = ioctl(DEV_OBD, &OBD_IOC_ATTACH, $packed); @@ -295,6 +300,31 @@ sub Detach { } + +sub TestIterator { + my $err = 0; + my $type = "ext2_obd"; + + $data = pack("i", 4711); + $datalen = 4; + + my $len = length($type); + my $cl = length($data); + my $add = pack("p", $data); + print "type $type (len $len), datalen $datalen ($cl)\n"; + my $packed = pack("Lipip", $::client_id, length($type), $type, $datalen, $data); + + my $rc = ioctl(DEV_OBD, &OBD_EXT2_RUNIT, $packed); + + if (!defined $rc) { + print STDERR "ioctl failed: $!\n"; + } elsif ($rc eq "0 but true") { + print "Finished (success)\n"; + } else { + print "ioctl returned error code $rc.\n"; + } +} + sub SnapPrint { my $err = 0; my $type = "snap_obd"; @@ -307,7 +337,7 @@ sub SnapPrint { my $cl = length($data); my $add = pack("p", $data); print "type $type (len $len), datalen $datalen ($cl)\n"; - my $packed = pack("ipip", length($type), $type, $datalen, $data); + my $packed = pack("Lipip", $::client_id, length($type), $type, $datalen, $data); my $rc = ioctl(DEV_OBD, &OBD_SNAP_PRINTTABLE, $packed); @@ -354,7 +384,7 @@ sub SnapSetTable { my $cl = length($data); my $add = pack("p", $data); print "type $type (len $len), datalen $datalen ($cl)\n"; - my $packed = pack("ipip", length($type), $type, $datalen, $data); + my $packed = pack("Lipip", $::client_id, length($type), $type, $datalen, $data); my $rc = ioctl(DEV_OBD, &OBD_SNAP_SETTABLE, $packed); @@ -378,11 +408,11 @@ sub SnapAttach { my $data; my $datalen = 0; - if ( ! -f $file ) { - print "No such file $file\n"; - } +# if ( ! -f $file ) { +# print "No such file $file\n"; +# } - $table = ReadSnapShotTable($file); +# $table = ReadSnapShotTable($file); $data = pack("iii", $snapdev, $snapno, $tableno); $datalen = 3 * 4; @@ -390,7 +420,7 @@ sub SnapAttach { my $cl = length($data); my $add = pack("p", $data); print "type $type (len $len), datalen $datalen ($cl)\n"; - my $packed = pack("ipip", length($type), $type, $datalen, $data); + my $packed = pack("Lipip", $::client_id, length($type), $type, $datalen, $data); my $rc = ioctl(DEV_OBD, &OBD_IOC_ATTACH, $packed); -- 1.8.3.1