From c31f8d712c0fbb2c43b92beef34f8cd5c65a95e4 Mon Sep 17 00:00:00 2001 From: adilger Date: Thu, 9 Dec 1999 05:08:48 +0000 Subject: [PATCH] snap/snap.c: snap_do_cow() fixed case with existing indirect object snap/snap.c: snap_delsnap() removes (partly) a snapshot ext2obd/ext2_obd.c: fixed ext2obd_iterate() to handle reserved inodes ext2obd/ext2_obd.c: fixed direct_brw() to handle > 0 block offset class/obdcontrol: added testsnapiterator command/ioctl class/setup.sh: added creation of /tmp/fs, 4k block size obdfs/namei.c: fixed new directory size after write --- lustre/include/linux/obd_snap.h | 7 ++++--- lustre/obdclass/genops.c | 13 +++++++------ lustre/obdclass/obdcontrol | 41 ++++++++++++++++++++++++++++++++--------- lustre/obdclass/setup.sh | 4 +++- lustre/obdfs/namei.c | 4 ++-- 5 files changed, 48 insertions(+), 21 deletions(-) diff --git a/lustre/include/linux/obd_snap.h b/lustre/include/linux/obd_snap.h index 864dcd0..53f8986 100644 --- a/lustre/include/linux/obd_snap.h +++ b/lustre/include/linux/obd_snap.h @@ -13,9 +13,10 @@ #define SNAP_MAX 8 -/* ioctls for manipulating snapshots 40 - 50 */ -#define OBD_SNAP_SETTABLE _IOWR('f', 40, long) -#define OBD_SNAP_PRINTTABLE _IOWR('f', 41, long) +/* ioctls for manipulating snapshots 40 - 60 */ +#define OBD_SNAP_SETTABLE _IOWR('f', 40, long) +#define OBD_SNAP_PRINTTABLE _IOWR('f', 41, long) +#define OBD_SNAP_RUNIT _IOWR('f', 42, long) diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index bfc3499..3a12443 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -200,7 +200,7 @@ void lck_page(struct page *page) } /* XXX this should return errors correctly, so should migrate!!! */ -int gen_copy_data(struct obd_conn *conn, obdattr *tgt, obdattr *src) +int gen_copy_data(struct obd_conn *conn, obdattr *dst, obdattr *src) { struct page *page; unsigned long index = 0; @@ -208,7 +208,7 @@ int gen_copy_data(struct obd_conn *conn, obdattr *tgt, obdattr *src) ENTRY; CDEBUG(D_INODE, "src: ino %ld blocks %ld, size %Ld, dst: ino %ld\n", - src->i_ino, src->i_blocks, src->i_size, tgt->i_ino); + src->i_ino, src->i_blocks, src->i_size, dst->i_ino); page = alloc_page(GFP_USER); if ( !page ) { EXIT; @@ -224,17 +224,18 @@ int gen_copy_data(struct obd_conn *conn, obdattr *tgt, obdattr *src) if ( rc != PAGE_SIZE ) break; + CDEBUG(D_INODE, "Read page %ld ...\n", page->index); - rc = OBP(conn->oc_dev,brw)(WRITE, conn, tgt, page, 1); + rc = OBP(conn->oc_dev, brw)(WRITE, conn, dst, page, 1); if ( rc != PAGE_SIZE) break; - CDEBUG(D_INODE, "Copied page %d ...\n", index); + CDEBUG(D_INODE, "Wrote page %ld ...\n", page->index); index ++; } - tgt->i_size = src->i_size; - tgt->i_blocks = src->i_blocks; + dst->i_size = src->i_size; + dst->i_blocks = src->i_blocks; UnlockPage(page); __free_page(page); diff --git a/lustre/obdclass/obdcontrol b/lustre/obdclass/obdcontrol index 8bdfd02..51f63df 100755 --- a/lustre/obdclass/obdcontrol +++ b/lustre/obdclass/obdcontrol @@ -66,6 +66,8 @@ 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_SNAP_RUNIT () { &_IOC(3, ord(\'f\'), 42, 4);}' unless + defined(&OBD_SNAP_RUNIT); eval 'sub OBD_EXT2_RUNIT () { &_IOC(3, ord(\'f\'), 61, 4);}' unless defined(&OBD_EXT2_RUNIT); @@ -106,7 +108,8 @@ my %commands = 'snapset' => {func => "SnapSetTable", doc => "snapset tableno file" }, 'snapprint' => {func => "SnapPrint", doc => "snapprint tableno"}, - 'testiterator' => {func => "TestIterator", doc => ""}, + 'testext2iterator' => {func => "TestExt2Iterator", doc => ""}, + 'testsnapiterator' => {func => "TestSnapIterator", doc => ""}, 'snaptable' => {func => "SnapShotTable", doc => "snaptable: build a snapshot table (interactive)"}, 'copy' => {func => "Copy", doc => "copy srcid tgtid"}, @@ -300,12 +303,11 @@ sub Detach { } - -sub TestIterator { +sub TestExt2Iterator { my $err = 0; my $type = "ext2_obd"; - $data = pack("i", 4711); + $data = pack("i", 4711); # bogus data $datalen = 4; my $len = length($type); @@ -325,6 +327,32 @@ sub TestIterator { } } + +sub TestSnapIterator { + my $err = 0; + my $type = "snap_obd"; + + $data = pack("i", 4711); # bogus data + $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_SNAP_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"; @@ -408,11 +436,6 @@ sub SnapAttach { my $data; my $datalen = 0; -# if ( ! -f $file ) { -# print "No such file $file\n"; -# } - -# $table = ReadSnapShotTable($file); $data = pack("iii", $snapdev, $snapno, $tableno); $datalen = 3 * 4; diff --git a/lustre/obdclass/setup.sh b/lustre/obdclass/setup.sh index 64fe579..f905f81 100755 --- a/lustre/obdclass/setup.sh +++ b/lustre/obdclass/setup.sh @@ -1,8 +1,10 @@ #! /bin/bash +dd if=/dev/zero of=/tmp/fs bs=1k count=10000 + insmod loop losetup /dev/loop0 /tmp/fs -mke2fs /dev/loop0 +mke2fs -b 4096 /dev/loop0 insmod ../class/obdclass.o insmod ../ext2obd/obdext2.o diff --git a/lustre/obdfs/namei.c b/lustre/obdfs/namei.c index 6624e7b..0eec7c8 100644 --- a/lustre/obdfs/namei.c +++ b/lustre/obdfs/namei.c @@ -577,7 +577,6 @@ int obdfs_mkdir(struct inode * dir, struct dentry * dentry, int mode) child->i_op = &obdfs_inode_ops; - child->i_size = PAGE_SIZE; child->i_blocks = 0; child_page = obdfs_getpage(child, 0, 1, LOCKED); if (!child_page) { @@ -586,7 +585,6 @@ int obdfs_mkdir(struct inode * dir, struct dentry * dentry, int mode) iput (child); return err; } - child->i_blocks = PAGE_SIZE/child->i_sb->s_blocksize; /* create . and .. */ de = (struct ext2_dir_entry_2 *) page_address(child_page); @@ -604,6 +602,8 @@ int obdfs_mkdir(struct inode * dir, struct dentry * dentry, int mode) ext2_set_de_type(dir->i_sb, de, S_IFDIR); iops(dir)->o_brw(WRITE, iid(dir), child, child_page, 1); + child->i_blocks = PAGE_SIZE/child->i_sb->s_blocksize; + child->i_size = PAGE_SIZE; UnlockPage(child_page); page_cache_release(child_page); -- 1.8.3.1