From: adilger Date: Wed, 29 Dec 1999 17:30:08 +0000 (+0000) Subject: ext2obd/ext2_obd.c, snap/snap.c: change parameters for create X-Git-Tag: v1_7_100~6149 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=d16c3e7f2fca7daad6398f7f0432358a056d82f4 ext2obd/ext2_obd.c, snap/snap.c: change parameters for create class/obdcontrol: update copy, migrate dst & src parameter order --- diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h index 639d221..ae618f7 100644 --- a/lustre/include/linux/obd_class.h +++ b/lustre/include/linux/obd_class.h @@ -84,17 +84,17 @@ struct obd_ops { int (*o_setattr)(struct obd_conn *, obdattr *oa); int (*o_getattr)(struct obd_conn *, obdattr *oa); int (*o_statfs)(struct obd_conn *, struct statfs *statfs); - int (*o_create)(struct obd_conn *, int prealloc_ino, int *er); + int (*o_create)(struct obd_conn *, int prealloc_obj, objid *id); int (*o_destroy)(struct obd_conn *, obdattr *oa); - int (*o_read)(struct obd_conn *, obdattr *ino, char *buf, unsigned long *count, loff_t offset); + int (*o_read)(struct obd_conn *, obdattr *oa, char *buf, unsigned long *count, loff_t offset); int (*o_read2)(struct obd_conn *, obdattr *oa, char *buf, unsigned long *count, loff_t offset); int (*o_write)(struct obd_conn *, obdattr *oa, char *buf, unsigned long *count, loff_t offset); - int (*o_brw)(int rw, struct obd_conn * conn, obdattr *obj, struct page *page, int create); + int (*o_brw)(int rw, struct obd_conn * conn, obdattr *oa, struct page *page, int create); int (*o_preallocate)(struct obd_conn *, unsigned long *req, long inodes[32]); - int (*o_get_info)(struct obd_conn *, int keylen, void *key, int *vallen, void **val); - 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_get_info)(struct obd_conn *, int keylen, void *key, int *vallen, void **val); + int (*o_set_info)(struct obd_conn *, int keylen, void *key, int vallen, void *val); + int (*o_migrate)(struct obd_conn *, obdattr *dst, obdattr *src); + int (*o_copy)(struct obd_conn *dev, obdattr *dst, obdattr *src); int (*o_iocontrol)(int cmd, struct obd_conn *, int len, void *karg, void *uarg); int (*o_iterate)(struct obd_conn *, int (*)(objid, void *), objid, void *); @@ -166,7 +166,7 @@ struct oic_attr_s { struct ioc_mv_s { unsigned int conn_id; objid src; - objid tgt; + objid dst; }; struct oic_rw_s { diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index a564ca7..09ae2e9 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -154,9 +154,9 @@ static int getdata(int len, void **data) static int obd_class_ioctl (struct inode * inode, struct file * filp, unsigned int cmd, unsigned long arg) { - int err, i_ino, dev; struct obd_device *obddev; struct obd_conn conn; + int err, dev; long int cli_id; /* connect, disconnect */ if (!inode) @@ -289,7 +289,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp, /* have we attached a type to this device */ if ( !obddev->obd_type ) { CDEBUG(D_IOCTL, "OBD Device %d has no type.\n", dev); - return -EINVAL; + return -ENODEV; } /* get main structure */ @@ -322,7 +322,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp, /* have we attached a type to this device */ if ( !obddev->obd_type ) { CDEBUG(D_IOCTL, "OBD Device %d has no type.\n", dev); - return -EINVAL; + return -ENODEV; } /* get main structure */ @@ -353,7 +353,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp, int part_datalen; void *part_data; } input; - obdattr *srcoa, *tgtoa; + obdattr *src, *dst; if ( (!(obddev->obd_flags & OBD_SET_UP)) || (!(obddev->obd_flags & OBD_ATTACHED))) { @@ -374,23 +374,23 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp, return -EOPNOTSUPP; /* do the partition */ - CDEBUG(D_IOCTL, "Copy %d, type %s src %ld tgt %ld\n", dev, - obddev->obd_type->typ_name, mvdata.src, mvdata.tgt); + CDEBUG(D_IOCTL, "Copy %d, type %s dst %ld src %ld\n", dev, + obddev->obd_type->typ_name, mvdata.dst, mvdata.src); conn.oc_id = mvdata.conn_id; - srcoa = obd_oa_fromid(&conn, mvdata.src); - if ( !srcoa ) + src = obd_oa_fromid(&conn, mvdata.src); + if ( !src ) return -ENOENT; - tgtoa = obd_oa_fromid(&conn, mvdata.tgt); - if ( ! tgtoa ) { - obd_free_oa(srcoa); + dst = obd_oa_fromid(&conn, mvdata.dst); + if ( ! dst ) { + obd_free_oa(src); return -ENOENT; } - err = OBP(obddev, copy)(&conn, srcoa, tgtoa); + err = OBP(obddev, copy)(&conn, dst, src); - obd_free_oa(srcoa); - obd_free_oa(tgtoa); + obd_free_oa(src); + obd_free_oa(dst); return err; } case OBD_IOC_MIGR: { @@ -399,7 +399,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp, int part_datalen; void *part_data; } input; - obdattr *srcoa, *tgtoa; + obdattr *src, *dst; if ( (!(obddev->obd_flags & OBD_SET_UP)) || (!(obddev->obd_flags & OBD_ATTACHED))) { @@ -422,27 +422,27 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp, return -EOPNOTSUPP; /* do the partition */ - CDEBUG(D_IOCTL, "Migrate %d, type %s conn %d src %ld tgt %ld\n", + CDEBUG(D_IOCTL, "Migrate %d, type %s conn %d src %ld dst %ld\n", dev, obddev->obd_type->typ_name, mvdata.conn_id, - mvdata.src, mvdata.tgt); + mvdata.src, mvdata.dst); - if ( ! (srcoa = obd_empty_oa()) ) + if ( ! (src = obd_empty_oa()) ) return -ENOMEM; - if ( ! (tgtoa = obd_empty_oa()) ) { - obd_free_oa(srcoa); + if ( ! (dst = obd_empty_oa()) ) { + obd_free_oa(src); return -ENOMEM; } - srcoa->i_ino = mvdata.src; - tgtoa->i_ino = mvdata.tgt; + src->i_ino = mvdata.src; + dst->i_ino = mvdata.dst; conn.oc_id = mvdata.conn_id; - err = OBP(obddev, migrate)(&conn, tgtoa, srcoa); + err = OBP(obddev, migrate)(&conn, dst, src); - obd_free_oa(srcoa); - obd_free_oa(tgtoa); + obd_free_oa(src); + obd_free_oa(dst); return err; } @@ -514,7 +514,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp, if (!obddev->obd_type) { CDEBUG(D_IOCTL, "OBD Device %d has no type.\n", dev); EXIT; - return -EINVAL; + return -ENODEV; } if ( !obddev->obd_type->typ_refcnt ) { @@ -560,8 +560,9 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp, if ( !OBT(obddev) || !OBP(obddev, connect) ) return -EOPNOTSUPP; - if (OBP(obddev, connect)(&conn)) - return -EINVAL; + err = OBP(obddev, connect)(&conn); + if ( err ) + return err; return copy_to_user((int *)arg, &conn.oc_id, sizeof(int)); @@ -570,7 +571,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp, /* frees data structures */ /* has this minor been registered? */ if (!obddev->obd_type) - return -EINVAL; + return -ENODEV; get_user(cli_id, (int *) arg); conn.oc_id = cli_id; @@ -587,7 +588,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp, * superblock that it needs. */ /* has this minor been registered? */ if (!obddev->obd_type) - return -EINVAL; + return -ENODEV; if (!obddev->u.ext2.ext2_sb || !obddev->u.ext2.ext2_sb->s_dev) { CDEBUG(D_IOCTL, "fatal: device not initialized.\n"); @@ -604,6 +605,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp, } case OBD_IOC_CREATE: { struct oic_create_s foo; + objid id; if ( copy_from_user(&foo, (const void *)arg, sizeof(foo)) ) return -EFAULT; @@ -619,14 +621,15 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp, if ( !OBT(obddev) || !OBP(obddev, create) ) return -EOPNOTSUPP; - i_ino = OBP(obddev, create)(&conn, foo.prealloc, &err); + err = OBP(obddev, create)(&conn, foo.prealloc, &id); if (err) { CDEBUG(D_IOCTL, "create: obd_inode_new failure\n"); /* 0 is the only error value */ - return put_user(0, (int *) arg); + put_user(0, (int *) arg); + return err; } - return put_user(i_ino, (int *) arg); + return put_user(id, (int *) arg); } case OBD_IOC_DESTROY: { struct destroy_s { @@ -640,7 +643,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp, /* has this minor been registered? */ if (!obddev->obd_type) - return -EINVAL; + return -ENODEV; copy_from_user(&destroy, (int *)arg, sizeof(struct destroy_s)); if ( !OBT(obddev) || !OBP(obddev, destroy) ) @@ -661,7 +664,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp, /* has this minor been registered? */ if (!obddev->obd_type) - return -EINVAL; + return -ENODEV; err = copy_from_user(&foo, (int *)arg, sizeof(foo)); if (err) @@ -765,7 +768,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp, /* has this minor been registered? */ if (!obddev->obd_type) - return -EINVAL; + return -ENODEV; err = copy_from_user(&prealloc, (int *)arg, sizeof(prealloc)); if (err) @@ -795,7 +798,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp, /* has this minor been registered? */ if (!obddev->obd_type) - return -EINVAL; + return -ENODEV; tmp = (void *)arg + sizeof(unsigned int); get_user(conn_id, (int *) arg); diff --git a/lustre/obdclass/obdcontrol b/lustre/obdclass/obdcontrol index 7486cc8..15eb769 100755 --- a/lustre/obdclass/obdcontrol +++ b/lustre/obdclass/obdcontrol @@ -103,7 +103,7 @@ my $arg; my %commands = ('device' => {func => "Device", doc => "device : open another OBD device"}, 'create' => {func => "Create", doc => "create: creates a new inode"}, - 'attach' => {func => "Attach", doc => "attach { ext2_obd | snap_obd snapdev snapidx tableno | scsi_obd adapter bus tid lun" }, + 'attach' => {func => "Attach", doc => "attach { ext2_obd | snap_obd snapdev snapidx tableno | scsi_obd adapter bus tid lun }" }, 'detach' => {func => "Detach", doc => "detach this device"}, 'testext2iterator' => {func => "TestExt2Iterator", doc => "test ext2 iterator function"}, 'snapset' => {func => "SnapSetTable", doc => "snapset : set the table (created with snaptable) as table #tableno" }, @@ -648,8 +648,11 @@ sub WriteSnapShotTable { sub Copy { my $err = 0; my $srcid = shift; - my $tgtid = shift; - my $data = pack("III", $::client_id, $srcid, $tgtid); + my $dstid = shift; + + # 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; my $packed = pack("ip", $datalen, $data); @@ -667,8 +670,11 @@ sub Copy { sub Migrate { my $err = 0; my $srcid = shift; - my $tgtid = shift; - my $data = pack("III", $::client_id, $srcid, $tgtid); + 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; my $packed = pack("ip", $datalen, $data); diff --git a/lustre/obdfs/namei.c b/lustre/obdfs/namei.c index 031910b..b874135 100644 --- a/lustre/obdfs/namei.c +++ b/lustre/obdfs/namei.c @@ -454,22 +454,21 @@ int obdfs_create (struct inode * dir, struct dentry * dentry, int mode) struct page *page; struct ext2_dir_entry_2 * de; int err = -EIO; - ino_t ino; + objid id; ENTRY; /* * N.B. Several error exits in ext2_new_inode don't set err. */ - ino = iops(dir)->o_create(iid(dir), 0, &err); + err = iops(dir)->o_create(iid(dir), 0, &id); if ( err ) return err; - err = -EIO; - inode = iget(dir->i_sb, ino); + inode = iget(dir->i_sb, (ino_t)id); if (!inode || !list_empty(&inode->i_dentry)) { - CDEBUG(D_INODE, "No inode, ino %ld\n", ino); + CDEBUG(D_INODE, "No inode, ino %ld\n", id); EXIT; - return err; + return -EIO; } inode->i_op = &obdfs_file_inode_operations; @@ -505,21 +504,21 @@ int obdfs_mknod (struct inode * dir, struct dentry *dentry, int mode, int rdev) struct inode * inode; struct page *page; struct ext2_dir_entry_2 * de; - int err = -EIO; + int err; - ino_t ino; + objid id; ENTRY; /* * N.B. Several error exits in ext2_new_inode don't set err. */ - ino = iops(dir)->o_create(iid(dir), 0, &err); - if ( ino == -1 ) - return -1; - inode = iget(dir->i_sb, ino); - if (!inode) + err = iops(dir)->o_create(iid(dir), 0, &id); + if ( err ) return err; + inode = iget(dir->i_sb, (ino_t)id); + if (!inode) + return -EIO; inode->i_uid = current->fsuid; init_special_inode(inode, mode, rdev); @@ -558,7 +557,7 @@ int obdfs_mkdir(struct inode * dir, struct dentry * dentry, int mode) struct page *page, *inode_page; struct ext2_dir_entry_2 * de; int err; - ino_t ino; + objid id; ENTRY; @@ -566,13 +565,12 @@ int obdfs_mkdir(struct inode * dir, struct dentry * dentry, int mode) if (dir->i_nlink >= EXT2_LINK_MAX) goto out; - err = -EIO; - ino = iops(dir)->o_create(iid(dir), 0, &err); - if ( ino == -1 ) - return -1; - inode = iget(dir->i_sb, ino); - if (!inode) + err = iops(dir)->o_create(iid(dir), 0, &id); + if ( err ) return err; + inode = iget(dir->i_sb, (ino_t)id); + if (!inode) + return -EIO; inode->i_op = &obdfs_dir_inode_operations; @@ -837,18 +835,18 @@ int obdfs_symlink (struct inode * dir, struct dentry *dentry, const char * symna char * link; int i, l, err = -EIO; char c; - ino_t ino; + objid id; ENTRY; /* * N.B. Several error exits in ext2_new_inode don't set err. */ - ino = iops(dir)->o_create(iid(dir), 0, &err); - if ( ino == -1 ) { + err = iops(dir)->o_create(iid(dir), 0, &id); + if ( err ) { EXIT; - return -1; + return err; } - inode = iget(dir->i_sb, ino); + inode = iget(dir->i_sb, (ino_t)id); if (!inode) { EXIT; return err;