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
# 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
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
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
[ ! -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
# 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
fi
fi
-umount $MNTOBD
+plog umount $MNTOBD
-insmod $OBDDIR/snap/obdsnap.o
+plog insmod $OBDDIR/snap/obdsnap.o
rm -f $SNAPTABLE
* ======== 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;
};
{
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 */
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 */
int setup_datalen;
void *setup_data;
} *setup;
- setup = karg;
+ setup = tmp_buf;
ENTRY;
/* have we attached a type to this device */
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;
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) {
}
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)
}
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)
}
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)
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 ) {
}
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 ) {
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)
}
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))) {
}
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))) {
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;
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;
}
/* 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;
{
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");
}
-
sub Attach {
my $err = 0;
my $type = shift;
}
}
+
sub Detach {
my $err = 0;
my $data = "";
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 $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 $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);
$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);
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) {
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) {
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";
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;
#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;
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 ) {
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);
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) {
ENTRY;
- inode = obdfs_new_inode(dir);
+ inode = obdfs_new_inode(dir, mode);
if ( IS_ERR(inode) ) {
EXIT;
return PTR_ERR(inode);
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);
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 */
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);
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);
{
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");