⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lov_pack.c

📁 lustre 1.6.5 source code
💻 C
📖 第 1 页 / 共 2 页
字号:
                LASSERT(lsm_op_find(lsm->lsm_magic) != NULL);        lsm_op_find(lsm->lsm_magic)->lsm_free(lsm);                *lsmp = NULL;}/* Unpack LOV object metadata from disk storage.  It is packed in LE byte * order and is opaque to the networking layer. */int lov_unpackmd(struct obd_export *exp,  struct lov_stripe_md **lsmp,                  struct lov_mds_md *lmm, int lmm_bytes){        struct obd_device *obd = class_exp2obd(exp);        struct lov_obd *lov = &obd->u.lov;        int rc = 0, stripe_count, lsm_size;        __u32 magic;        ENTRY;        /* If passed an MDS struct use values from there, otherwise defaults */        if (lmm) {                rc = lov_verify_lmm(lmm, lmm_bytes, &stripe_count);                if (rc)                        RETURN(rc);                magic = le32_to_cpu(lmm->lmm_magic);        } else {                stripe_count = lov_get_stripecnt(lov, 0);                magic = LOV_MAGIC;        }        /* If we aren't passed an lsmp struct, we just want the size */        if (!lsmp) {                /* XXX LOV STACKING call into osc for sizes */                LBUG();                RETURN(lov_stripe_md_size(stripe_count));        }        /* If we are passed an allocated struct but nothing to unpack, free */        if (*lsmp && !lmm) {                lov_free_memmd(lsmp);                RETURN(0);        }        lsm_size = lov_alloc_memmd(lsmp, stripe_count, LOV_PATTERN_RAID0,                                    magic);        if (lsm_size < 0)                RETURN(lsm_size);        /* If we are passed a pointer but nothing to unpack, we only alloc */        if (!lmm)                RETURN(lsm_size);        LASSERT(lsm_op_find(magic) != NULL);        rc = lsm_op_find(magic)->lsm_unpackmd(lov, *lsmp, lmm);        if (rc) {                lov_free_memmd(lsmp);                RETURN(rc);        }        RETURN(lsm_size);}/* Configure object striping information on a new file. * * @lmmu is a pointer to a user struct with one or more of the fields set to * indicate the application preference: lmm_stripe_count, lmm_stripe_size, * lmm_stripe_offset, and lmm_stripe_pattern.  lmm_magic must be LOV_MAGIC. * @lsmp is a pointer to an in-core stripe MD that needs to be filled in. */int lov_setstripe(struct obd_export *exp, struct lov_stripe_md **lsmp,                  struct lov_user_md *lump){        struct obd_device *obd = class_exp2obd(exp);        struct lov_obd *lov = &obd->u.lov;        struct lov_user_md lum;        int stripe_count;        int rc;        ENTRY;        rc = copy_from_user(&lum, lump, sizeof(lum));        if (rc)                RETURN(-EFAULT);        if (lum.lmm_magic != LOV_USER_MAGIC) {                if (lum.lmm_magic == __swab32(LOV_USER_MAGIC)) {                        lustre_swab_lov_user_md(&lum);                } else {                        CDEBUG(D_IOCTL, "bad userland LOV MAGIC:"                               " %#08x != %#08x\n",                               lum.lmm_magic, LOV_USER_MAGIC);                        RETURN(-EINVAL);                }        }        if (lum.lmm_pattern == 0) {                lum.lmm_pattern = lov->desc.ld_pattern ?                        lov->desc.ld_pattern : LOV_PATTERN_RAID0;        }        if (lum.lmm_pattern != LOV_PATTERN_RAID0) {                CDEBUG(D_IOCTL, "bad userland stripe pattern: %#x\n",                       lum.lmm_pattern);                RETURN(-EINVAL);        }        /* 64kB is the largest common page size we see (ia64), and matches the         * check in lfs */        if (lum.lmm_stripe_size & (LOV_MIN_STRIPE_SIZE - 1)) {                CDEBUG(D_IOCTL, "stripe size %u not multiple of %u, fixing\n",                       lum.lmm_stripe_size, LOV_MIN_STRIPE_SIZE);                lum.lmm_stripe_size = LOV_MIN_STRIPE_SIZE;        }        if ((lum.lmm_stripe_offset >= lov->desc.ld_tgt_count) &&            (lum.lmm_stripe_offset != (typeof(lum.lmm_stripe_offset))(-1))) {                CDEBUG(D_IOCTL, "stripe offset %u > number of OSTs %u\n",                       lum.lmm_stripe_offset, lov->desc.ld_tgt_count);                RETURN(-EINVAL);        }        stripe_count = lov_get_stripecnt(lov, lum.lmm_stripe_count);        if ((__u64)lum.lmm_stripe_size * stripe_count > ~0U) {                CDEBUG(D_IOCTL, "stripe width %ux%u exceeds %u bytes\n",                       lum.lmm_stripe_size, (int)lum.lmm_stripe_count, ~0U);                RETURN(-EINVAL);        }        rc = lov_alloc_memmd(lsmp, stripe_count, lum.lmm_pattern, LOV_MAGIC);        if (rc < 0)                RETURN(rc);        (*lsmp)->lsm_oinfo[0]->loi_ost_idx = lum.lmm_stripe_offset;        (*lsmp)->lsm_stripe_size = lum.lmm_stripe_size;        RETURN(0);}int lov_setea(struct obd_export *exp, struct lov_stripe_md **lsmp,              struct lov_user_md *lump){        int i;        int rc;        struct obd_export *oexp;        struct lov_obd *lov = &exp->exp_obd->u.lov;        obd_id last_id = 0;        ENTRY;        for (i = 0; i < lump->lmm_stripe_count; i++) {                __u32 len = sizeof(last_id);                oexp = lov->lov_tgts[lump->lmm_objects[i].l_ost_idx]->ltd_exp;                rc = obd_get_info(oexp, strlen("last_id"), "last_id",                                  &len, &last_id);                if (rc)                        RETURN(rc);                if (lump->lmm_objects[i].l_object_id > last_id) {                        CERROR("Setting EA for object > than last id on "                               "ost idx %d "LPD64" > "LPD64" \n",                               lump->lmm_objects[i].l_ost_idx,                               lump->lmm_objects[i].l_object_id, last_id);                        RETURN(-EINVAL);                }        }        rc = lov_setstripe(exp, lsmp, lump);        if (rc)                RETURN(rc);        for (i = 0; i < lump->lmm_stripe_count; i++) {                (*lsmp)->lsm_oinfo[i]->loi_ost_idx =                        lump->lmm_objects[i].l_ost_idx;                (*lsmp)->lsm_oinfo[i]->loi_id = lump->lmm_objects[i].l_object_id;                (*lsmp)->lsm_oinfo[i]->loi_gr = lump->lmm_objects[i].l_object_gr;        }        RETURN(0);}/* Retrieve object striping information. * * @lump is a pointer to an in-core struct with lmm_ost_count indicating * the maximum number of OST indices which will fit in the user buffer. * lmm_magic must be LOV_USER_MAGIC. */int lov_getstripe(struct obd_export *exp, struct lov_stripe_md *lsm,                  struct lov_user_md *lump){        struct lov_user_md lum;        struct lov_mds_md *lmmk = NULL;        int rc, lmm_size;        ENTRY;        if (!lsm)                RETURN(-ENODATA);        rc = copy_from_user(&lum, lump, sizeof(lum));        if (rc)                RETURN(-EFAULT);        if (lum.lmm_magic != LOV_USER_MAGIC)                RETURN(-EINVAL);        rc = lov_packmd(exp, &lmmk, lsm);        if (rc < 0)                RETURN(rc);        lmm_size = rc;        rc = 0;        /* FIXME: Bug 1185 - copy fields properly when structs change */        LASSERT(sizeof(lum) == sizeof(*lmmk));        LASSERT(sizeof(lum.lmm_objects[0]) == sizeof(lmmk->lmm_objects[0]));        /* User wasn't expecting this many OST entries */        if (lum.lmm_stripe_count == 0) {                if (copy_to_user(lump, lmmk, sizeof(lum)))                        rc = -EFAULT;        } else if (lum.lmm_stripe_count < lmmk->lmm_stripe_count) {                rc = -EOVERFLOW;        } else if (copy_to_user(lump, lmmk, lmm_size)) {                rc = -EFAULT;        }        obd_free_diskmd(exp, &lmmk);        RETURN(rc);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -