Whamcloud - gitweb
obdsyncd: removed from CVS
authoradilger <adilger>
Tue, 11 Jan 2000 21:30:28 +0000 (21:30 +0000)
committeradilger <adilger>
Tue, 11 Jan 2000 21:30:28 +0000 (21:30 +0000)
demos/obdfsclean.sh: now stops pupd before trying to unload obdfs module
class/obdcontrol: corrected packing for COPY, MIGR IOCTL methods

12 files changed:
lustre/demos/basesetup.sh
lustre/demos/config.sh
lustre/demos/obdfsclean.sh
lustre/demos/obdfssetup.sh
lustre/demos/obdtest.sh
lustre/demos/snapsetup.sh
lustre/include/linux/obd_class.h
lustre/obdclass/class_obd.c
lustre/obdclass/genops.c
lustre/obdclass/obdcontrol
lustre/obdfs/namei.c
lustre/obdfs/rw.c

index fcf382f..86c65e8 100755 (executable)
@@ -25,7 +25,7 @@ if [ "$LOOPDEV" -a "`losetup $LOOPDEV 2> /dev/null`" ]; then
     exit 2
 fi
 
-[ "$LOOPDEV" ] && losetup $LOOPDEV $TMPFILE
+[ "$LOOPDEV" ] && plog losetup $LOOPDEV $TMPFILE
 # Ensure that we have the correct devices for OBD to work
 [ ! -c /dev/obd0 ] && mknod /dev/obd0 c $OBDMAJ 0
 [ ! -c /dev/obd1 ] && mknod /dev/obd1 c $OBDMAJ 1
index 713a199..3bdd707 100644 (file)
@@ -27,6 +27,8 @@ SNAPTABLE="/tmp/obdfs.snaptable"
 # A simple routine called by most of the scripts to help debugging.  The
 # kernel code has a lot of debugging statements, so this helps us keep
 # track of what is going on in user-land to generate the kernel messages.
+# We append directly to the messages file instead of using logger so that
+# our checkpoints are not lost when the syslogd is very busy.
 plog () {
     if [ "$1" = "log" ]; then
        shift
index 4723394..19fc321 100755 (executable)
@@ -3,9 +3,11 @@
 OBDDIR="`dirname $0`/.."
 . $OBDDIR/demos/config.sh
 
-umount $MNTOBD
+plog umount $MNTOBD
+plog killall pupd      # stop the OBDFS flush daemon
 rmmod obdfs
 
+plog log "CLEANUP/DETACH"
 $OBDDIR/class/obdcontrol -f << EOF
 cleanup
 detach
index 6b992f7..0c1dd5d 100755 (executable)
@@ -14,7 +14,7 @@ insmod $OBDDIR/class/obdclass.o
 insmod $OBDDIR/ext2obd/obdext2.o
 insmod $OBDDIR/obdfs/obdfs.o
 
-plog log "ATTACHING /dev/obd0"
+plog log "ATTACHING /dev/obd0, SETUP $BASEDEV"
 $OBDDIR/class/obdcontrol -f << EOF
 attach ext2_obd 
 setup $BASEDEV
index 89a003f..c30a0fe 100755 (executable)
@@ -7,7 +7,9 @@ OBDDIR="`dirname $0`/.."
 
 [ ! -d $MNTOBD/lost+found ] && $OBDDIR/demos/obdfssetup.sh
 
-echo "yesterday" > $MNTOBD/hello       # create a file
-echo "testing" > $MNTOBD/goodbye       # create a file
-ln -s hello $MNTOBD/link               # create a symbolic link
-cd $MNTOBD ; touch a b c ; cd -                # create a file
+echo "echo yesterday >> $MNTOBD/hello" # create a file
+echo "yesterday" > $MNTOBD/hello
+echo "echo testing > $MNTOBD/goodbye"  # create a file
+echo "testing" > $MNTOBD/goodbye
+plog ln -s hello $MNTOBD/link          # create a symbolic link
+cd $MNTOBD ; plog touch a b c ; cd -           # create a file
index c1fee96..d2e7f73 100755 (executable)
@@ -7,12 +7,6 @@ OBDDIR="`dirname $0`/.."
 
 
 # prepare the snapshot drive with a file to be COW'd
-mount | grep "$MNTOBD " > /dev/null 2>&1
-if [ x$? = x0 ]; then 
-    echo "Stuff still mounted on $MNTOBD; clean up first."
-    exit 
-fi
-
 if [ ! -d /mnt/obd/lost+found ]; then 
     $OBDDIR/demos/obdfssetup.sh
     if [ x$? != x0 ]; then 
@@ -29,9 +23,9 @@ if [ ! -f $MNTOBD/hello ]; then
     fi
 fi
 
-umount $MNTOBD
+plog umount $MNTOBD
 
-insmod $OBDDIR/snap/obdsnap.o
+plog insmod $OBDDIR/snap/obdsnap.o
 
 rm -f $SNAPTABLE
 
index 804d66a..dfbf7c7 100644 (file)
@@ -440,11 +440,11 @@ int gen_copy_data(struct obd_conn *dst_conn, struct obdo *dst,
  *  ======== OBD IOCL Declarations ===========
  */
 struct oic_generic {
-       int  att_connid;
-       int  att_typelen;
-       void *att_type;
-       int  att_datalen;
-       void *att_data;
+       long     att_connid;
+       int      att_typelen;
+       void    *att_type;
+       int      att_datalen;
+       void    *att_data;
 };
 
 
index f32917a..a0ae994 100644 (file)
@@ -156,8 +156,8 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
 {
        struct obd_device *obddev;
        /* NOTE this must be larger than any of the ioctl data structs */
-       char buff[1024];
-       void *karg = buff;
+       char buf[1024];
+       void *tmp_buf = buf;
        struct obd_conn conn;
        int err, dev;
        long int cli_id; /* connect, disconnect */
@@ -176,7 +176,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                return -EINVAL;
        case OBD_IOC_ATTACH: {
                struct obd_type *type;
-               struct oic_generic *input = karg;
+               struct oic_generic *input = tmp_buf;
 
                ENTRY;
                /* have we attached a type to this device */
@@ -290,7 +290,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                        int setup_datalen;
                        void *setup_data;
                } *setup;
-               setup = karg;
+               setup = tmp_buf;
 
                ENTRY;
                /* have we attached a type to this device */
@@ -423,7 +423,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                return 0;
 
        case OBD_IOC_SYNC: {
-               struct oic_range_s *range = karg;
+               struct oic_range_s *range = tmp_buf;
 
                if (!obddev->obd_type)
                        return -ENODEV;
@@ -453,7 +453,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                return put_user(err, (int *) arg);
        }
        case OBD_IOC_CREATE: {
-               struct oic_attr_s *attr = karg;
+               struct oic_attr_s *attr = tmp_buf;
 
                err = copy_from_user(attr, (const void *)arg,  sizeof(*attr));
                if (err) {
@@ -484,7 +484,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
        }
 
        case OBD_IOC_DESTROY: {
-               struct oic_attr_s *attr = karg;
+               struct oic_attr_s *attr = tmp_buf;
                
                /* has this minor been registered? */
                if (!obddev->obd_type)
@@ -506,7 +506,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
        }
 
        case OBD_IOC_SETATTR: {
-               struct oic_attr_s *attr = karg;
+               struct oic_attr_s *attr = tmp_buf;
 
                /* has this minor been registered? */
                if (!obddev->obd_type)
@@ -526,7 +526,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
        }
 
        case OBD_IOC_GETATTR: {
-               struct oic_attr_s *attr = karg;
+               struct oic_attr_s *attr = tmp_buf;
 
                err = copy_from_user(attr, (int *)arg, sizeof(*attr));
                if (err)
@@ -546,7 +546,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
 
        case OBD_IOC_READ: {
                int err;
-               struct oic_rw_s *rw_s = karg;  /* read, write ioctl str */
+               struct oic_rw_s *rw_s = tmp_buf;  /* read, write ioctl str */
 
                err = copy_from_user(rw_s, (int *)arg, sizeof(*rw_s));
                if ( err ) {
@@ -575,7 +575,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
        }
 
        case OBD_IOC_WRITE: {
-               struct oic_rw_s *rw_s = karg;  /* read, write ioctl str */
+               struct oic_rw_s *rw_s = tmp_buf;  /* read, write ioctl str */
 
                err = copy_from_user(rw_s, (int *)arg, sizeof(*rw_s));
                if ( err ) {
@@ -602,7 +602,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                return err;
        }
        case OBD_IOC_PREALLOCATE: {
-               struct oic_prealloc_s *prealloc = karg;
+               struct oic_prealloc_s *prealloc = tmp_buf;
 
                /* has this minor been registered? */
                if (!obddev->obd_type)
@@ -660,7 +660,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                
        }
        case OBD_IOC_COPY: {
-               struct ioc_mv_s *mvdata = karg;
+               struct ioc_mv_s *mvdata = tmp_buf;
 
                if ( (!(obddev->obd_flags & OBD_SET_UP)) ||
                     (!(obddev->obd_flags & OBD_ATTACHED))) {
@@ -692,7 +692,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
        }
 
        case OBD_IOC_MIGR: {
-               struct ioc_mv_s *mvdata = karg;
+               struct ioc_mv_s *mvdata = tmp_buf;
 
                if ( (!(obddev->obd_flags & OBD_SET_UP)) ||
                     (!(obddev->obd_flags & OBD_ATTACHED))) {
@@ -706,7 +706,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                        return err;
                }
 
-               CDEBUG(D_IOCTL, "Migrate copying %d\n", sizeof(*mvdata));
+               CDEBUG(D_IOCTL, "Migrate copying %d bytes\n", sizeof(*mvdata));
 
                if ( !OBT(obddev) || !OBP(obddev, migrate) )
                        return -EOPNOTSUPP;
@@ -718,7 +718,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
 
                conn.oc_id = mvdata->src_conn_id;
                err = OBP(obddev, migrate)(&conn, &mvdata->dst, &mvdata->src, 
-                                          mvdata->dst.o_size, 0);
+                                          mvdata->src.o_size, 0);
 
                return err;
        }
@@ -761,7 +761,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
 
                /* get the generic data */
                karg = input.att_data;
-               err = getdata(input.att_datalen, karg);
+               err = getdata(input.att_datalen, &karg);
                if ( err ) {
                        EXIT;
                        return err;
index fc79194..ada4632 100644 (file)
@@ -60,11 +60,9 @@ void obd_cleanup_obdo_cache(void)
 {
        ENTRY;
        if (obdo_cachep != NULL) {
-               /*
-               CDEBUG(D_INODE, "shrinking obdo_cache at %p\n", obdo_cachep);
-               if (kmem_cache_shrink(obdo_cachep))
+               CDEBUG(D_INODE, "destroying obdo_cache at %p\n", obdo_cachep);
+               if (kmem_cache_destroy(obdo_cachep))
                        printk(KERN_INFO "obd_cleanup_obdo_cache: unable to free all of cache\n");
-               */
        } else
                printk(KERN_INFO "obd_cleanup_obdo_cache: called with NULL cache pointer\n");
 
index 642bed6..1b6317c 100755 (executable)
@@ -358,7 +358,6 @@ sub Device {
 }
 
 
-
 sub Attach {
     my $err = 0;
     my $type = shift;
@@ -412,6 +411,7 @@ usage:
     }
 }
 
+
 sub Detach {
     my $err = 0;
     my $data = "";
@@ -441,7 +441,6 @@ sub TestExt2Iterator {
 
     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);
 
@@ -471,7 +470,6 @@ sub SnapDelete {
 
     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);
 
@@ -591,7 +589,6 @@ sub SnapPrint {
 
     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);
 
@@ -632,13 +629,13 @@ sub SnapSetTable {
     $data = pack("ii", $snaptableno, $snapcount);
     $datalen = 2 * 4;
     foreach my $time (sort keys %{$table}) {
+       # XXX we should change to pack LL instead of I for times
        $data .= pack("Ii", $time, $table->{$time});
        $datalen += 8;
     }
 
     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);
 
@@ -755,15 +752,18 @@ sub WriteSnapShotTable {
 
 sub Copy {
     my $err = 0;
-    my $srcid = shift;
-    my $dstid = shift;
+    my $src_obdo;
+    my $dst_obdo;
 
     # Note: _copy IOCTL takes parameters as dst, src.
     #       Copy function takes parameters as src, dst.
-    my $data = pack("III", $::client_id, $dstid, $srcid);
-    my $datalen = 12;
+    $src_obdo->{id} = shift;
+    $dst_obdo->{id} = shift;
+    $src_obdo->{valid} = &OBD_MD_FLALL;
+
+    # XXX need to fix copy so we can have 2 client IDs here
+    my $packed = pack("L", $::client_id) . obdo_pack($dst_obdo) . pack("L", $::client_id) . obdo_pack($src_obdo);
 
-    my $packed = pack("ip", $datalen, $data);
     my $rc = ioctl(DEV_OBD, &OBD_IOC_COPY, $packed);
 
     if (!defined $rc) {
@@ -777,15 +777,16 @@ sub Copy {
 
 sub Migrate {
     my $err = 0;
-    my $srcid = shift;
-    my $dstid = shift;
 
     # Note: _migr IOCTL takes parameters as dst, src.
     #       Migrate function takes parameters as src, dst.
-    my $data = pack("III", $::client_id, $dstid, $srcid);
-    my $datalen = 12;
+    $src_obdo->{id} = shift;
+    $dst_obdo->{id} = shift;
+    $src_obdo->{valid} = &OBD_MD_FLALL;
+
+    # We pack a dummy connection ID here
+    my $packed = pack("L", $::client_id) . obdo_pack($dst_obdo) . pack("L", $::client_id) . obdo_pack($src_obdo);
 
-    my $packed = pack("ip", $datalen, $data);
     my $rc = ioctl(DEV_OBD, &OBD_IOC_MIGR, $packed);
 
     if (!defined $rc) {
@@ -1017,20 +1018,19 @@ sub Getattr {
        return;
     }
 
-    my $inode = shift;
+    my $id = shift;
 
-    if (!defined($inode) || scalar($inode) < 1) {
+    if (!defined($id) || scalar($id) < 1) {
        print "invalid arguments; type \"help getattr\" for a synopsis\n";
        return;
     }
 
     # see Setattr
     my $obdo;
-    $obdo->{id} = $inode;
+    $obdo->{id} = $id;
     $obdo->{valid} = &OBD_MD_FLALL;
     my $packed = pack("L", $::client_id) . obdo_pack($obdo);
     my $rc = ioctl(DEV_OBD, &OBD_IOC_GETATTR, $packed);
-
     
     if (!defined $rc) {
        print STDERR "ioctl failed: $!\n";
@@ -1048,16 +1048,16 @@ sub Setattr {
        return;
     }
 
-    my $inode = shift;
+    my $id = shift;
 
-    if (!defined($inode) || scalar($inode) < 1) {
+    if (!defined($id) || scalar($id) < 1) {
        print "invalid arguments; type \"help setattr\" for a synopsis\n";
        return;
     }
 
     # XXX we do not currently set all of the fields in the obdo
     my $obdo;
-    $obdo->{id} = $inode;
+    $obdo->{id} = $id;
     $obdo->{mode} = oct(shift);
     $obdo->{uid} = shift;
     $obdo->{gid} = shift;
index 4c8419f..4ffdbaa 100644 (file)
@@ -446,7 +446,7 @@ static void show_dentry(struct list_head * dlist, int subdirs)
 #endif
 
 
-struct inode *obdfs_new_inode(struct inode *dir)
+static struct inode *obdfs_new_inode(struct inode *dir, int mode)
 {
        struct obdo *oa;
        struct inode *inode;
@@ -459,6 +459,10 @@ struct inode *obdfs_new_inode(struct inode *dir)
                return ERR_PTR(-ENOMEM);
        }
 
+       /* Send a hint to the create method on the type of file created */
+       oa->o_mode = mode;
+       oa->o_valid |= OBD_MD_FLMODE;
+
        err = IOPS(dir, create)(IID(dir), oa);
 
        if ( err ) {
@@ -476,6 +480,8 @@ struct inode *obdfs_new_inode(struct inode *dir)
                return ERR_PTR(-EIO);
        }
 
+       inode->i_mode = mode; /* XXX not sure if we need this or iget does it */
+
        if (!list_empty(&inode->i_dentry)) {
                CDEBUG(D_INODE, "New inode (%ld) has aliases!\n", inode->i_ino);
                IOPS(dir, destroy)(IID(dir), oa);
@@ -509,14 +515,13 @@ int obdfs_create (struct inode * dir, struct dentry * dentry, int mode)
        int err = -EIO;
 
         ENTRY;
-       inode = obdfs_new_inode(dir);
+       inode = obdfs_new_inode(dir, mode);
        if ( IS_ERR(inode) ) {
                EXIT;
                return PTR_ERR(inode);
        }
 
        inode->i_op = &obdfs_file_inode_operations;
-       inode->i_mode = mode;
        mark_inode_dirty(inode);
        page = obdfs_add_entry (dir, dentry->d_name.name, dentry->d_name.len, &de, &err);
        if (!page) {
@@ -548,7 +553,7 @@ int obdfs_mknod (struct inode * dir, struct dentry *dentry, int mode, int rdev)
 
         ENTRY;
 
-       inode = obdfs_new_inode(dir);
+       inode = obdfs_new_inode(dir, mode);
        if ( IS_ERR(inode) ) {
                EXIT;
                return PTR_ERR(inode);
@@ -593,7 +598,11 @@ int obdfs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
        if (dir->i_nlink >= EXT2_LINK_MAX)
                goto out;
 
-       inode = obdfs_new_inode(dir);
+       mode |= S_IFDIR;
+       if (dir->i_mode & S_ISGID)
+               mode |= S_ISGID;
+
+       inode = obdfs_new_inode(dir, mode);
        if ( IS_ERR(inode) ) {
                EXIT;
                return PTR_ERR(inode);
@@ -632,9 +641,6 @@ int obdfs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
        page_cache_release(inode_page);
 
        inode->i_nlink = 2;
-       inode->i_mode = S_IFDIR | mode;
-       if (dir->i_mode & S_ISGID)
-               inode->i_mode |= S_ISGID;
        mark_inode_dirty(inode);
 
        /* now deal with the parent */
@@ -856,19 +862,19 @@ int obdfs_symlink (struct inode * dir, struct dentry *dentry,
        char c;
 
         ENTRY;
-       inode = obdfs_new_inode(dir);
-       oinfo = OBDFS_INFO(inode);
+       inode = obdfs_new_inode(dir, S_IFLNK | S_IRWXUGO);
        if ( IS_ERR(inode) ) {
                EXIT;
                return PTR_ERR(inode);
        }
 
-       inode->i_mode = S_IFLNK | S_IRWXUGO;
        inode->i_op = &obdfs_symlink_inode_operations;
        for (l = 0; l < inode->i_sb->s_blocksize - 1 && symname [l]; l++)
                ;
 
-       if (l >= sizeof(OBDFS_INFO(inode)->oi_inline)) {
+       oinfo = OBDFS_INFO(inode);
+
+       if (l >= sizeof(oinfo->oi_inline)) {
                CDEBUG(D_INODE, "l=%d, normal symlink\n", l);
 
                name_page = obdfs_getpage(inode, 0, 1, LOCKED);
@@ -901,7 +907,8 @@ int obdfs_symlink (struct inode * dir, struct dentry *dentry,
        inode->i_size = i;
        mark_inode_dirty(inode);
 
-       page = obdfs_add_entry (dir, dentry->d_name.name, dentry->d_name.len, &de, &err);
+       page = obdfs_add_entry (dir, dentry->d_name.name, dentry->d_name.len,
+                               &de, &err);
        if (!page)
                goto out_no_entry;
        de->inode = cpu_to_le32(inode->i_ino);
index e72d1b8..9e19ee1 100644 (file)
@@ -111,12 +111,10 @@ void obdfs_cleanup_pgrqcache(void)
 {
        ENTRY;
        if (obdfs_pgrq_cachep != NULL) {
-               /*
-               CDEBUG(D_INODE, "shrinking obdfs_pgrqcache at %p\n",
+               CDEBUG(D_INODE, "destroying obdfs_pgrqcache at %p\n",
                       obdfs_pgrq_cachep);
-               if (kmem_cache_shrink(obdfs_pgrq_cachep))
+               if (kmem_cache_destroy(obdfs_pgrq_cachep))
                        printk(KERN_INFO "obd_cleanup_pgrqcache: unable to free all of cache\n");
-               */
        } else
                printk(KERN_INFO "obd_cleanup_pgrqcache: called with NULL cache pointer\n");