From 03a4082c9ec183c76b672477dd0e551ae506c319 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 24 Feb 2009 19:43:29 +0000 Subject: [PATCH] - minor fixes around objset declaration - stubs for osd_label_{get|set} - osd_oi_init() creates and opens fid-to-dnode mapping - osd_mount() opens objset - number of minor fixes in udmu routines --- lustre/dmu-osd/osd_handler.c | 170 ++++++++++++++++++++++++++----------------- lustre/dmu-osd/udmu.c | 133 +++++++++++++++------------------ lustre/dmu-osd/udmu.h | 14 ++-- lustre/dmu-osd/udmu_util.c | 2 + 4 files changed, 173 insertions(+), 146 deletions(-) diff --git a/lustre/dmu-osd/osd_handler.c b/lustre/dmu-osd/osd_handler.c index 2e4fc86..5506d26 100644 --- a/lustre/dmu-osd/osd_handler.c +++ b/lustre/dmu-osd/osd_handler.c @@ -104,8 +104,7 @@ struct osd_device { /* super-class */ struct dt_device od_dt_dev; /* information about underlying file system */ - udmu_objset_t *od_objset; - //struct lustre_mount_info *od_mount; + udmu_objset_t od_objset; /* Environment for transaction commit callback. * Currently, OSD is based on ext3/JBD. Transaction commit in ext3/JBD @@ -201,8 +200,6 @@ static struct lu_device *osd_device_alloc (const struct lu_env *env, static struct lu_object *osd_object_alloc (const struct lu_env *env, const struct lu_object_header *hdr, struct lu_device *d); -extern struct lustre_mount_info *server_get_mount(const char *name); -extern int server_put_mount(const char *name, struct vfsmount *mnt); static struct lu_device_type_operations osd_device_type_ops; static struct lu_device_type osd_device_type; @@ -594,7 +591,7 @@ static int osd_object_destroy(const struct lu_env *env, struct osd_object *obj) osd_trans_start(env, &osd->od_dt_dev, th); /* remove obj ref from main obj. dir */ - rc = udmu_zap_delete(osd->od_objset, zapdb, oh->ot_tx, buf); + rc = udmu_zap_delete(&osd->od_objset, zapdb, oh->ot_tx, buf); if (rc) { CERROR("udmu_zap_delete() failed with error %d", rc); RETURN (rc); @@ -602,7 +599,7 @@ static int osd_object_destroy(const struct lu_env *env, struct osd_object *obj) udmu_object_getattr(obj->oo_db, &va); /* kill object */ - rc = udmu_object_delete(osd->od_objset, &obj->oo_db, + rc = udmu_object_delete(&osd->od_objset, &obj->oo_db, oh->ot_tx, osd_object_tag); if (rc) { CERROR("udmu_object_delete() failed with error %d", rc); @@ -671,7 +668,7 @@ static int osd_statfs(const struct lu_env *env, spin_lock(&osd->od_osfs_lock); /* cache 1 second */ if (cfs_time_before_64(osd->od_osfs_age, cfs_time_shift_64(-1))) { - rc = udmu_objset_statvfs(osd->od_objset, (struct statvfs64 *)kfs); + rc = udmu_objset_statfs(&osd->od_objset, (struct statfs64 *) kfs); /* Reserve 64MB for ZFS COW symantics so that grants won't * consume all available space. COW needs space to duplicate @@ -758,7 +755,7 @@ static struct thandle *osd_trans_create(const struct lu_env *env, dmu_tx_t *tx; int hook_res, rc; ENTRY; - tx = udmu_tx_create(osd->od_objset); + tx = udmu_tx_create(&osd->od_objset); if (tx == NULL) RETURN(ERR_PTR(-ENOMEM)); @@ -824,7 +821,7 @@ static void osd_trans_stop(const struct lu_env *env, struct thandle *th) udmu_tx_commit(oh->ot_tx); if (oh->ot_sync) - udmu_wait_synced(osd->od_objset, oh->ot_tx); + udmu_wait_synced(&osd->od_objset, oh->ot_tx); EXIT; } @@ -835,7 +832,7 @@ static int osd_sync(const struct lu_env *env, struct dt_device *d) { struct osd_device *osd = osd_dt_dev(d); CDEBUG(D_HA, "syncing OSD %s\n", LUSTRE_OSD_NAME); - udmu_wait_synced(osd->od_objset, NULL); + udmu_wait_synced(&osd->od_objset, NULL); return 0; } @@ -869,6 +866,21 @@ static int osd_init_capa_ctxt(const struct lu_env *env, struct dt_device *d, RETURN(0); } +static char *osd_label_get(const struct lu_env *env, const struct dt_device *d) +{ + struct osd_device *dev = osd_dt_dev(d); + LBUG(); + RETURN(NULL); +} + +static int osd_label_set(const struct lu_env *env, const struct dt_device *d, + char *name) +{ + struct osd_device *dev = osd_dt_dev(d); + LBUG(); + RETURN(0); +} + static struct dt_device_operations osd_dt_ops = { .dt_root_get = osd_root_get, .dt_statfs = osd_statfs, @@ -878,7 +890,9 @@ static struct dt_device_operations osd_dt_ops = { .dt_conf_get = osd_conf_get, .dt_sync = osd_sync, .dt_ro = osd_ro, - .dt_init_capa_ctxt = osd_init_capa_ctxt + .dt_init_capa_ctxt = osd_init_capa_ctxt, + .dt_label_get = osd_label_get, + .dt_label_set = osd_label_set }; static void osd_object_read_lock(const struct lu_env *env, @@ -1033,7 +1047,7 @@ static int osd_punch(const struct lu_env *env, struct dt_object *dt, start, len ? len : DMU_OBJECT_END); */ - udmu_object_punch(osd->od_objset, obj->oo_db, oh->ot_tx, start, len); + udmu_object_punch(&osd->od_objset, obj->oo_db, oh->ot_tx, start, len); /* set new size */ #if 0 @@ -1127,7 +1141,7 @@ static dmu_buf_t * osd_mkdir(struct osd_thread_info *info, struct osd_device *o dmu_buf_t * db; LASSERT(S_ISDIR(attr->la_mode)); - udmu_zap_create(osd->od_objset, &db, oh->ot_tx, osd_object_tag); + udmu_zap_create(&osd->od_objset, &db, oh->ot_tx, osd_object_tag); return db; } @@ -1138,7 +1152,7 @@ static dmu_buf_t* osd_mkreg(struct osd_thread_info *info, struct osd_device *os { dmu_buf_t * db; LASSERT(S_ISREG(attr->la_mode)); - udmu_object_create(osd->od_objset, &db, oh->ot_tx, osd_object_tag); + udmu_object_create(&osd->od_objset, &db, oh->ot_tx, osd_object_tag); return db; } @@ -1149,7 +1163,7 @@ static dmu_buf_t* osd_mksym(struct osd_thread_info *info, struct osd_device *os dmu_buf_t * db; LASSERT(S_ISLNK(attr->la_mode)); - udmu_object_create(osd->od_objset, &db, oh->ot_tx, osd_object_tag); + udmu_object_create(&osd->od_objset, &db, oh->ot_tx, osd_object_tag); return db; } @@ -1164,7 +1178,7 @@ static dmu_buf_t* osd_mknod(struct osd_thread_info *info, struct osd_device *os LASSERT(S_ISCHR(mode) || S_ISBLK(mode) || S_ISFIFO(mode) || S_ISSOCK(mode)); - udmu_object_create(osd->od_objset, &db, oh->ot_tx, osd_object_tag); + udmu_object_create(&osd->od_objset, &db, oh->ot_tx, osd_object_tag); if (db && (S_ISCHR(mode)||S_ISBLK(mode))) { vap.va_mask = DMU_AT_RDEV; @@ -1251,7 +1265,7 @@ static int osd_object_create(const struct lu_env *env, struct dt_object *dt, oid = udmu_object_get_id(db); /* XXX: zapdb should be replaced with zap-mapping-fids-to-dnode */ - rc = udmu_zap_insert(osd->od_objset, zapdb, oh->ot_tx, buf, + rc = udmu_zap_insert(&osd->od_objset, zapdb, oh->ot_tx, buf, &oid, sizeof (oid)); if(rc) goto out; @@ -1301,7 +1315,7 @@ static struct dt_it *osd_zap_it_init(const struct lu_env *env, OBD_ALLOC_PTR(it); if (it != NULL) { - if (udmu_zap_cursor_init(&it->ozi_zc, osd->od_objset, + if (udmu_zap_cursor_init(&it->ozi_zc, &osd->od_objset, udmu_object_get_id(obj->oo_db))) RETURN(ERR_PTR(-ENOMEM)); @@ -1463,7 +1477,7 @@ static int osd_zap_it_load(const struct lu_env *env, LBUG(); RETURN(0); #if 0 - udmu_zap_cursor_init_serialized(it->ozi_zc, osd_obj2dev(obj)->od_objset, + udmu_zap_cursor_init_serialized(it->ozi_zc, &osd_obj2dev(obj)->od_objset, udmu_object_get_id(obj->oo_db), hash); /* same as osd_zap_it_next()*/ @@ -1494,7 +1508,7 @@ static int osd_index_lookup(const struct lu_env *env, struct dt_object *dt, LASSERT(udmu_object_is_zap(obj->oo_db)); if (osd_object_is_root(obj)) { - rc = udmu_zap_lookup(osd->od_objset, zapdb, (char *) key, &oid, + rc = udmu_zap_lookup(&osd->od_objset, zapdb, (char *) key, &oid, sizeof(uint64_t), sizeof(uint64_t)); if (rc) { RETURN(-rc); @@ -1507,7 +1521,7 @@ static int osd_index_lookup(const struct lu_env *env, struct dt_object *dt, fid->f_seq = LUSTRE_FID_INIT_OID; fid->f_oid = oid; /* XXX: f_oid is 32bit, oid - 64bit */ } else { - rc = udmu_zap_lookup(osd->od_objset, zapdb, (char *) key, + rc = udmu_zap_lookup(&osd->od_objset, zapdb, (char *) key, rec, 17, 1); } RETURN(-rc); @@ -1574,7 +1588,7 @@ static int osd_index_insert(const struct lu_env *env, struct dt_object *dt, pack = (struct lu_fid_pack *) rec; /* Insert (key,oid) into ZAP */ - rc = udmu_zap_insert(osd->od_objset, zap_db, oh->ot_tx, + rc = udmu_zap_insert(&osd->od_objset, zap_db, oh->ot_tx, (char *) key, pack, pack->fp_len); RETURN(-rc); @@ -1627,7 +1641,7 @@ static int osd_index_delete(const struct lu_env *env, struct dt_object *dt, LASSERT(oh->ot_tx != NULL); /* Remove key from the ZAP */ - rc = udmu_zap_delete(osd->od_objset, zap_db, oh->ot_tx, (char *) key); + rc = udmu_zap_delete(&osd->od_objset, zap_db, oh->ot_tx, (char *) key); if (rc) { CERROR("udmu_zap_delete() failed with error %d", rc); @@ -2048,7 +2062,7 @@ static ssize_t osd_read(const struct lu_env *env, struct dt_object *dt, //loff_t offset = *pos; int rc; - rc = udmu_object_read(osd->od_objset, obj->oo_db, (uint64_t)(*pos), + rc = udmu_object_read(&osd->od_objset, obj->oo_db, (uint64_t)(*pos), (uint64_t)buf->lb_len, buf->lb_buf); if (rc > 0) *pos += rc;//buf->lb_len; @@ -2094,7 +2108,7 @@ static ssize_t osd_write(const struct lu_env *env, struct dt_object *dt, udmu_object_getattr(obj->oo_db, &va); - udmu_object_write(osd->od_objset, obj->oo_db, oh->ot_tx, offset, + udmu_object_write(&osd->od_objset, obj->oo_db, oh->ot_tx, offset, (uint64_t)buf->lb_len, buf->lb_buf); if (va.va_size < offset + buf->lb_len) { va.va_size = offset + buf->lb_len; @@ -2238,7 +2252,7 @@ static int osd_write_commit(const struct lu_env *env, struct dt_object *dt, CDEBUG(D_OTHER, "write %u bytes at %u\n", (unsigned) lb->len, (unsigned) lb->file_offset); - udmu_object_write(osd->od_objset, obj->oo_db, oh->ot_tx, + udmu_object_write(&osd->od_objset, obj->oo_db, oh->ot_tx, lb->file_offset, lb->len,kmap(lb->page)); kunmap(lb->page); if (new_size < lb->file_offset + lb->len) @@ -2389,58 +2403,83 @@ static int osd_shutdown(const struct lu_env *env, struct osd_device *o) RETURN(0); } +#define DMU_OSD_OI_NAME "OBJ" + +static int osd_oi_init(const struct lu_env *env, struct osd_device *o) +{ + dmu_buf_t *objdb; + uint64_t objid; + int rc; + ENTRY; + + rc = udmu_zap_lookup(&o->od_objset, o->od_root_db, DMU_OSD_OI_NAME, &objid, + sizeof(uint64_t), sizeof(uint64_t)); + if (rc == 0) { + rc = udmu_object_get_dmu_buf(&o->od_objset, objid, + &objdb, objdir_tag); + } else { + /* create fid-to-dnode index */ + dmu_tx_t *tx = udmu_tx_create(&o->od_objset); + if (tx == NULL) + RETURN(-ENOMEM); + + udmu_tx_hold_zap(tx, DMU_NEW_OBJECT, 1, NULL); + udmu_tx_hold_bonus(tx, udmu_object_get_id(o->od_root_db)); + udmu_tx_hold_zap(tx, udmu_object_get_id(o->od_root_db), + TRUE, DMU_OSD_OI_NAME); + + rc = udmu_tx_assign(tx, TXG_WAIT); + LASSERT(rc == 0); + + udmu_zap_create(&o->od_objset, &objdb, tx, osd_object_tag); + objid = udmu_object_get_id(objdb); + + rc = udmu_zap_insert(&o->od_objset, o->od_root_db, tx, + DMU_OSD_OI_NAME, &objid, sizeof(objid)); + LASSERT(rc == 0); + + udmu_tx_commit(tx); + + RETURN(-rc); + } + + o->od_objdir_db = objdb; +} + static int osd_mount(const struct lu_env *env, struct osd_device *o, struct lustre_cfg *cfg) { - //struct lustre_mount_info *lmi; - const char *dev = lustre_cfg_string(cfg, 0); - dmu_buf_t *rootdb; - dmu_buf_t *objdb; - uint64_t rootid; - uint64_t objid; - int rc; + char *dev = lustre_cfg_string(cfg, 0); + dmu_buf_t *rootdb; + int rc; ENTRY; - if (o->od_objset != NULL) { + if (o->od_objset.os != NULL) { CERROR("Already mounted (%s) (dev %p, lu %p)\n", dev, o, osd2lu_dev(o)); RETURN(-EEXIST); } -#if 0 - /* get mount */ - lmi = server_get_mount(dev); - if (lmi == NULL) { - CERROR("Cannot get mount info for %s!\n", dev); - RETURN(-EFAULT); - } - - LASSERT(lmi != NULL); - /* save lustre_mount_info in dt_device */ - o->od_mount = lmi; -#endif + while (*dev && *dev == '/') + dev++; - rc = udmu_objset_root(o->od_objset, &rootdb, root_tag); + rc = udmu_objset_open(dev, NULL, 0, 0, &o->od_objset); if (rc) { - CERROR("udmu_objset_root() failed with error %d\n", rc); - return (-rc); + CERROR("can't open objset %s: %d\n", dev, rc); + RETURN(-rc); } - rootid = udmu_object_get_id(rootdb); - rc = udmu_zap_lookup(o->od_objset, rootdb, "OBJ", &objid, - sizeof(uint64_t), sizeof(uint64_t)); - if (rc == 0) { - rc = udmu_object_get_dmu_buf(o->od_objset, objid, - &objdb, objdir_tag); - } else { - CERROR("Cannot find OBJ directory (%d)\n", rc); - return (-rc); + rc = udmu_objset_root(&o->od_objset, &rootdb, root_tag); + if (rc) { + CERROR("udmu_objset_root() failed with error %d\n", rc); + RETURN(-rc); } - - o->od_objdir_db = objdb; o->od_root_db = rootdb; + rc = osd_oi_init(env, o); + LASSERT(rc == 0); + RETURN(rc); } @@ -2559,14 +2598,14 @@ static int osd_fid_lookup(const struct lu_env *env, } else { osd_fid2str(buf, fid); - rc = udmu_zap_lookup(dev->od_objset, dev->od_objdir_db, + rc = udmu_zap_lookup(&dev->od_objset, dev->od_objdir_db, buf, &oid, sizeof(uint64_t), sizeof(uint64_t)); if (rc) RETURN(-rc); } - rc = udmu_object_get_dmu_buf(dev->od_objset, oid, &obj->oo_db, + rc = udmu_object_get_dmu_buf(&dev->od_objset, oid, &obj->oo_db, osd_object_tag); if (rc == 0) { LASSERT(obj->oo_db != NULL); @@ -2655,7 +2694,7 @@ static struct lu_device_type_operations osd_device_type_ops = { static struct lu_device_type osd_device_type = { .ldt_tags = LU_DEVICE_DT, - .ldt_name = LUSTRE_OSD_NAME, + .ldt_name = LUSTRE_DMU_NAME, .ldt_ops = &osd_device_type_ops, .ldt_ctx_tags = LCT_MD_THREAD|LCT_DT_THREAD }; @@ -2694,13 +2733,14 @@ int __init osd_init(void) lprocfs_osd_init_vars(&lvars); return class_register_type(&osd_obd_device_ops, NULL, lvars.module_vars, - LUSTRE_OSD_NAME, &osd_device_type); + LUSTRE_DMU_NAME, &osd_device_type); + } #ifdef __KERNEL__ void __exit osd_exit(void) { - class_unregister_type(LUSTRE_OSD_NAME); + class_unregister_type(LUSTRE_DMU_NAME); } MODULE_AUTHOR("Cluster File Systems, Inc. "); diff --git a/lustre/dmu-osd/udmu.c b/lustre/dmu-osd/udmu.c index c54a734..f554de2 100644 --- a/lustre/dmu-osd/udmu.c +++ b/lustre/dmu-osd/udmu.c @@ -1,3 +1,4 @@ +#if 1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * @@ -34,16 +35,13 @@ #include #include #include -#include #include #include #include #include #include -#include -#include -#include -#include +#include "udmu.h" +#include enum vtype iftovt_tab[] = { VNON, VFIFO, VCHR, VNON, VDIR, VNON, VBLK, VNON, @@ -71,14 +69,17 @@ ushort_t vttoif_tab[] = { static int debug_level = LEVEL_CRITICAL; #define CONFIG_DIR "/var/run/zfs/udmu" -static char config_path[MAXPATHLEN]; +//static char config_path[MAXPATHLEN]; static void udmu_gethrestime(struct timespec *tp) { + struct timeval time; + do_gettimeofday(&time); tp->tv_nsec = 0; - time(&tp->tv_sec); + tp->tv_sec = time.tv_sec; } +#if 0 static void udmu_printf(int level, FILE *stream, char *message, ...) { va_list args; @@ -89,73 +90,33 @@ static void udmu_printf(int level, FILE *stream, char *message, ...) va_end(args); } } +#else +#define udmu_printf(level,stream,msg, a...) \ + printk(msg, ## a) +#endif void udmu_debug(int level) { debug_level = level; } -void udmu_init() -{ - char tmp[MAXPATHLEN]; - struct rlimit rl = { 1024, 1024 }; - int rc; - - /* - * Set spa_config_path to /var/run/zfs/udmu/$pid/zpool.cache. - */ - snprintf(config_path, MAXPATHLEN, "%s/%d", CONFIG_DIR, (int)getpid()); - - snprintf(tmp, MAXPATHLEN, "mkdir -p %s", config_path); - system(tmp); - - /* Never hurts to be careful */ - strncpy(tmp, config_path, MAXPATHLEN - 1); - tmp[MAXPATHLEN - 1] = '\0'; - - snprintf(config_path, MAXPATHLEN, "%s/zpool.cache", tmp); - spa_config_path = config_path; - - (void) setvbuf(stdout, NULL, _IOLBF, 0); - (void) setrlimit(RLIMIT_NOFILE, &rl); - - /* Initialize the emulation of kernel services in userland. */ - kernel_init(FREAD | FWRITE); - - rc = dctl_server_init(tmp, 2, 2); - if (rc != 0) - fprintf(stderr, "Error calling dctl_server_init(): %i\n" - "lzpool and lzfs will not be functional!\n", rc); -} - -void udmu_fini() -{ - int rc; - - rc = dctl_server_fini(); - if (rc != 0) - fprintf(stderr, "Error calling dctl_server_fini(): %i!\n", rc); - - kernel_fini(); -} - int udmu_objset_open(char *osname, char *import_dir, int import, int force, udmu_objset_t *uos) { int error; - char cmd[MAXPATHLEN]; + //char cmd[MAXPATHLEN]; char *c; uint64_t version = ZPL_VERSION; - int tried_import = FALSE; + //int tried_import = FALSE; memset(uos, 0, sizeof(udmu_objset_t)); c = strchr(osname, '/'); -top: /* Let's try to open the objset */ error = dmu_objset_open(osname, DMU_OST_ZFS, DS_MODE_OWNER, &uos->os); +#if 0 if (error == ENOENT && import && !tried_import) { /* objset not found, let's try to import the pool */ udmu_printf(LEVEL_INFO, stdout, "Importing pool %s\n", osname); @@ -181,6 +142,7 @@ top: tried_import = TRUE; goto top; } +#endif if (error) { uos->os = NULL; @@ -199,6 +161,7 @@ top: */ error = EIO; goto out; +#if 0 } else if (version != LUSTRE_ZPL_VERSION) { udmu_printf(LEVEL_CRITICAL, stderr, "Mismatched versions: File system " @@ -207,6 +170,7 @@ top: (u_longlong_t)version, LUSTRE_ZPL_VERSION); error = ENOTSUP; goto out; +#endif } error = zap_lookup(uos->os, MASTER_NODE_OBJ, ZFS_ROOT_OBJ, @@ -220,6 +184,7 @@ top: ASSERT(uos->root != 0); out: +#if 0 if (error) { if (uos->os == NULL && tried_import) { if (c != NULL) @@ -230,6 +195,7 @@ out: } else if(uos->os != NULL) udmu_objset_close(uos, tried_import); } +#endif return (error); } @@ -243,15 +209,17 @@ void udmu_wait_synced(udmu_objset_t *uos, dmu_tx_t *tx) void udmu_objset_close(udmu_objset_t *uos, int export_pool) { - spa_t *spa; - char pool_name[MAXPATHLEN]; ASSERT(uos->os != NULL); - spa = uos->os->os->os_spa; +#if 0 + spa_t *spa; + char pool_name[MAXPATHLEN]; + spa = uos->os->os->os_spa; spa_config_enter(spa, RW_READER, FTAG); strncpy(pool_name, spa_name(spa), sizeof(pool_name)); spa_config_exit(spa, FTAG); +#endif udmu_wait_synced(uos, NULL); /* close the object set */ @@ -259,11 +227,13 @@ void udmu_objset_close(udmu_objset_t *uos, int export_pool) uos->os = NULL; +#if 0 if (export_pool) spa_export(pool_name, NULL, B_TRUE); +#endif } -int udmu_objset_statvfs(udmu_objset_t *uos, struct statvfs64 *statp) +int udmu_objset_statfs(udmu_objset_t *uos, struct statfs64 *statp) { uint64_t refdbytes, availbytes, usedobjs, availobjs; @@ -297,7 +267,7 @@ int udmu_objset_statvfs(udmu_objset_t *uos, struct statvfs64 *statp) * and the number of blocks (each object will take at least a block). */ statp->f_ffree = MIN(availobjs, statp->f_bfree); - statp->f_favail = statp->f_ffree; /* no "root reservation" */ + //statp->f_favail = statp->f_ffree; /* no "root reservation" */ statp->f_files = statp->f_ffree + usedobjs; /* ZFSFUSE: not necessary? see 'man statfs' */ @@ -312,7 +282,7 @@ int udmu_objset_statvfs(udmu_objset_t *uos, struct statvfs64 *statp) statp->f_flag = vf_to_stf(vfsp->vfs_flag);*/ - statp->f_namemax = 256; + statp->f_namelen = 256; return (0); } @@ -525,7 +495,7 @@ int udmu_zap_cursor_retrieve_key(zap_cursor_t *zc, char *key) int err; zap_attribute_t za; - if (err = zap_cursor_retrieve(zc, &za)) + if ((err = zap_cursor_retrieve(zc, &za))) return err; if (key) @@ -546,7 +516,7 @@ int udmu_zap_cursor_retrieve_value(zap_cursor_t *zc, char *buf, zap_attribute_t za; - if (err = zap_cursor_retrieve(zc, &za)) + if ((err = zap_cursor_retrieve(zc, &za))) return err; if (za.za_integer_length <= 0) @@ -585,10 +555,10 @@ int udmu_zap_cursor_move_to_key(zap_cursor_t *zc, const char *name) return zap_cursor_move_to_key(zc, name, MT_EXACT); } -void udmu_zap_cursor_init_serialized(zap_cursor_t *zc, objset_t *ds, +void udmu_zap_cursor_init_serialized(zap_cursor_t *zc, udmu_objset_t *uos, uint64_t zapobj, uint64_t serialized) { - zap_cursor_init_serialized(zc, ds, zapobj, serialized); + zap_cursor_init_serialized(zc, uos->os, zapobj, serialized); } @@ -876,17 +846,20 @@ void udmu_tx_commit(dmu_tx_t *tx) /* commit callback API */ void * udmu_tx_cb_create(size_t bytes) { - return dmu_tx_callback_data_create(bytes); + return NULL; + //return dmu_tx_callback_data_create(bytes); } int udmu_tx_cb_add(dmu_tx_t *tx, void *func, void *data) { - return dmu_tx_callback_commit_add(tx, func, data); + return 0; + //return dmu_tx_callback_commit_add(tx, func, data); } int udmu_tx_cb_destroy(void *data) { - return dmu_tx_callback_data_destroy(data); + return 0; + //return dmu_tx_callback_data_destroy(data); } int udmu_indblk_overhead(dmu_buf_t *db, unsigned long *used, @@ -908,25 +881,33 @@ int udmu_get_blocksize(dmu_buf_t *db, long *blksz) return 0; } -int udmu_object_get_links(dmu_buf_t *db) +uint64_t udmu_object_get_links(dmu_buf_t *db) { - /* XXX: not implemented yet */ - BUG_ON(1); - return 0; + znode_phys_t *zp = db->db_data; + + return zp->zp_links; } void udmu_object_links_inc(dmu_buf_t *db, dmu_tx_t *tx) { - /* XXX: not implemented yet */ - BUG_ON(1); + znode_phys_t *zp = db->db_data; + + if(tx) + dmu_buf_will_dirty(db, tx); + zp->zp_links++; } void udmu_object_links_dec(dmu_buf_t *db, dmu_tx_t *tx) { - /* XXX: not implemented yet */ - BUG_ON(1); + znode_phys_t *zp = db->db_data; + + ASSERT(zp->zp_links!=0); + if(tx) + dmu_buf_will_dirty(db, tx); + zp->zp_links--; } + int udmu_get_xattr(dmu_buf_t *db, void *val, int vallen, const char *name) { /* XXX: not implemented yet */ @@ -956,4 +937,4 @@ int udmu_list_xattr(dmu_buf_t *db, void *val, int vallen) return 0; } - +#endif diff --git a/lustre/dmu-osd/udmu.h b/lustre/dmu-osd/udmu.h index 9ef88d5..ce3e059 100644 --- a/lustre/dmu-osd/udmu.h +++ b/lustre/dmu-osd/udmu.h @@ -52,9 +52,11 @@ extern "C" { #define DMU_AT_SEQ 0x8000 #endif +#if 0 #define ACCESSED (DMU_AT_ATIME) #define STATE_CHANGED (DMU_AT_CTIME) #define CONTENT_MODIFIED (DMU_AT_MTIME | DMU_AT_CTIME) +#endif #define LOOKUP_DIR 0x01 /* want parent dir vp */ #define LOOKUP_XATTR 0x02 /* lookup up extended attr dir */ @@ -63,17 +65,18 @@ extern "C" { #define S_IFDOOR 0xD000 /* door */ #define S_IFPORT 0xE000 /* event port */ -struct statvfs64; +struct statfs64; /* Data structures required for Solaris ZFS compatability */ #if !defined(__sun__) -#ifndef _SOL_SYS_TIME_H +#ifndef _SPL_TYPES_H typedef struct timespec timestruc_t; #endif #endif +#ifndef _SPL_VNODE_H typedef enum vtype { VNON = 0, VREG = 1, @@ -88,10 +91,11 @@ typedef enum vtype { VPORT = 10, VBAD = 11 } vtype_t; +#endif typedef struct vnattr { unsigned int va_mask; /* bit-mask of attributes */ - vtype_t va_type; /* vnode type (for create) */ + enum vtype va_type; /* vnode type (for create) */ mode_t va_mode; /* file access mode */ uid_t va_uid; /* owner user id */ gid_t va_gid; /* owner group id */ @@ -151,7 +155,7 @@ int udmu_objset_open(char *osname, char *import_dir, int import, int force, udmu void udmu_objset_close(udmu_objset_t *uos, int export_pool); -int udmu_objset_statvfs(udmu_objset_t *uos, struct statvfs64 *statp); +int udmu_objset_statfs(udmu_objset_t *uos, struct statfs64 *statp); int udmu_objset_root(udmu_objset_t *uos, dmu_buf_t **dbp, void *tag); @@ -252,7 +256,7 @@ int udmu_indblk_overhead(dmu_buf_t *db, unsigned long *used, unsigned int udmu_get_blocksize(dmu_buf_t *db, long *blksz); -int udmu_object_get_links(dmu_buf_t *db); +uint64_t udmu_object_get_links(dmu_buf_t *db); void udmu_object_links_inc(dmu_buf_t *db, dmu_tx_t *tx); void udmu_object_links_dec(dmu_buf_t *db, dmu_tx_t *tx); diff --git a/lustre/dmu-osd/udmu_util.c b/lustre/dmu-osd/udmu_util.c index 93b7e86..768098e 100644 --- a/lustre/dmu-osd/udmu_util.c +++ b/lustre/dmu-osd/udmu_util.c @@ -1,3 +1,4 @@ +#if 0 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * @@ -239,3 +240,4 @@ int udmu_util_write(udmu_objset_t *uos, dmu_buf_t *db, return (len); } +#endif -- 1.8.3.1