else
b->mbo_blocks = 1;
b->mbo_valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;
+ } else if (info->mti_som_valid) { /* som is valid */
+ b->mbo_valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;
}
}
rc = mo_attr_get(env, next, ma);
if (rc)
GOTO(out, rc);
+
+ if (S_ISREG(mode))
+ (void) mdt_get_som(info, o, &ma->ma_attr);
ma->ma_valid |= MA_INODE;
}
*
* \param[in] info thread environment
* \param[in] obj object
- * \param[in] layout layout intent
- * \param[in] buf buffer containing client's lovea, could be empty
+ * \param[in] layout layout change descriptor
*
* \retval 0 on success
* \retval < 0 error code
*/
static int mdt_layout_change(struct mdt_thread_info *info,
struct mdt_object *obj,
- struct layout_intent *layout,
- const struct lu_buf *buf)
+ struct md_layout_change *layout)
{
struct mdt_lock_handle *lh = &info->mti_lh[MDT_LH_LOCAL];
+ struct layout_intent *intent = layout->mlc_intent;
int rc;
ENTRY;
CDEBUG(D_INFO, "got layout change request from client: "
- "opc:%u flags:%#x extent[%#llx,%#llx)\n",
- layout->li_opc, layout->li_flags,
- layout->li_start, layout->li_end);
- if (layout->li_start >= layout->li_end) {
- CERROR("Recieved an invalid layout change range [%llu, %llu) "
- "for "DFID"\n", layout->li_start, layout->li_end,
- PFID(mdt_object_fid(obj)));
+ "opc:%u flags:%#x extent "DEXT"\n",
+ intent->li_opc, intent->li_flags, PEXT(&intent->li_extent));
+
+ if (intent->li_extent.e_start >= intent->li_extent.e_end) {
+ CERROR(DFID ":invalid range of layout change "DEXT"\n",
+ PFID(mdt_object_fid(obj)), PEXT(&intent->li_extent));
RETURN(-EINVAL);
}
+ if (!mdt_object_exists(obj))
+ GOTO(out, rc = -ENOENT);
+
if (!S_ISREG(lu_object_attr(&obj->mot_obj)))
GOTO(out, rc = -EINVAL);
/* take layout lock to prepare layout change */
mdt_lock_reg_init(lh, LCK_EX);
- rc = mdt_object_lock(info, obj, lh,
- MDS_INODELOCK_LAYOUT | MDS_INODELOCK_XATTR);
+ rc = mdt_object_lock(info, obj, lh, MDS_INODELOCK_LAYOUT);
if (rc)
GOTO(out, rc);
- rc = mo_layout_change(info->mti_env, mdt_object_child(obj), layout,
- buf);
+ rc = mo_layout_change(info->mti_env, mdt_object_child(obj), layout);
mdt_object_unlock(info, obj, lh, 1);
out:
info->mti_opdata = 0;
info->mti_big_lmm_used = 0;
info->mti_big_acl_used = 0;
+ info->mti_som_valid = 0;
info->mti_spec.no_create = 0;
info->mti_spec.sp_rm_entry = 0;
__u64 flags)
{
struct mdt_lock_handle *lhc = &info->mti_lh[MDT_LH_LAYOUT];
- struct layout_intent *layout;
+ struct md_layout_change layout = { .mlc_opc = MD_LAYOUT_NOP };
+ struct layout_intent *intent;
struct lu_fid *fid;
struct mdt_object *obj = NULL;
- bool layout_change = false;
int layout_size = 0;
int rc = 0;
ENTRY;
RETURN(-EINVAL);
}
- layout = req_capsule_client_get(info->mti_pill, &RMF_LAYOUT_INTENT);
- if (layout == NULL)
+ intent = req_capsule_client_get(info->mti_pill, &RMF_LAYOUT_INTENT);
+ if (intent == NULL)
RETURN(-EPROTO);
- switch (layout->li_opc) {
+ switch (intent->li_opc) {
case LAYOUT_INTENT_TRUNC:
case LAYOUT_INTENT_WRITE:
- layout_change = true;
+ layout.mlc_opc = MD_LAYOUT_WRITE;
+ layout.mlc_intent = intent;
break;
case LAYOUT_INTENT_ACCESS:
break;
case LAYOUT_INTENT_RELEASE:
case LAYOUT_INTENT_RESTORE:
CERROR("%s: Unsupported layout intent opc %d\n",
- mdt_obd_name(info->mti_mdt), layout->li_opc);
+ mdt_obd_name(info->mti_mdt), intent->li_opc);
rc = -ENOTSUPP;
break;
default:
CERROR("%s: Unknown layout intent opc %d\n",
- mdt_obd_name(info->mti_mdt), layout->li_opc);
+ mdt_obd_name(info->mti_mdt), intent->li_opc);
rc = -EINVAL;
break;
}
GOTO(out_obj, rc);
- if (layout_change) {
- struct lu_buf *buf = &info->mti_buf;
+ if (layout.mlc_opc != MD_LAYOUT_NOP) {
+ struct lu_buf *buf = &layout.mlc_buf;
/**
* mdt_layout_change is a reint operation, when the request
* lovea, then it's a replay of the layout intent write
* RPC.
*/
- rc = mdt_layout_change(info, obj, layout, buf);
+ rc = mdt_layout_change(info, obj, &layout);
if (rc)
GOTO(out_obj, rc);
}
static int mdt_postrecov(const struct lu_env *, struct mdt_device *);
static int mdt_init0(const struct lu_env *env, struct mdt_device *m,
- struct lu_device_type *ldt, struct lustre_cfg *cfg)
+ struct lu_device_type *ldt, struct lustre_cfg *cfg)
{
- struct mdt_thread_info *info;
- struct obd_device *obd;
+ const struct dt_device_param *dt_conf;
+ struct mdt_thread_info *info;
+ struct obd_device *obd;
+ const char *dev = lustre_cfg_string(cfg, 0);
+ const char *num = lustre_cfg_string(cfg, 2);
struct tg_grants_data *tgd = &m->mdt_lut.lut_tgd;
- const char *dev = lustre_cfg_string(cfg, 0);
- const char *num = lustre_cfg_string(cfg, 2);
- struct lustre_mount_info *lmi = NULL;
- struct lustre_sb_info *lsi;
- struct lu_site *s;
- struct seq_server_site *ss_site;
- const char *identity_upcall = "NONE";
- struct md_device *next;
- int rc;
- long node_id;
- mntopt_t mntopts;
- ENTRY;
+ struct lustre_mount_info *lmi = NULL;
+ struct lustre_sb_info *lsi;
+ struct lu_site *s;
+ struct seq_server_site *ss_site;
+ const char *identity_upcall = "NONE";
+ struct md_device *next;
+ int rc;
+ long node_id;
+ mntopt_t mntopts;
+ ENTRY;
lu_device_init(&m->mdt_lu_dev, ldt);
- /*
- * Environment (env) might be missing mdt_thread_key values at that
- * point, if device is allocated when mdt_thread_key is in QUIESCENT
- * mode.
- *
- * Usually device allocation path doesn't use module key values, but
- * mdt has to do a lot of work here, so allocate key value.
- */
- rc = lu_env_refill((struct lu_env *)env);
- if (rc != 0)
- RETURN(rc);
+ /*
+ * Environment (env) might be missing mdt_thread_key values at that
+ * point, if device is allocated when mdt_thread_key is in QUIESCENT
+ * mode.
+ *
+ * Usually device allocation path doesn't use module key values, but
+ * mdt has to do a lot of work here, so allocate key value.
+ */
+ rc = lu_env_refill((struct lu_env *)env);
+ if (rc != 0)
+ RETURN(rc);
- info = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
- LASSERT(info != NULL);
+ info = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
+ LASSERT(info != NULL);
- obd = class_name2obd(dev);
- LASSERT(obd != NULL);
+ obd = class_name2obd(dev);
+ LASSERT(obd != NULL);
- m->mdt_max_mdsize = MAX_MD_SIZE; /* 4 stripes */
+ m->mdt_max_mdsize = MAX_MD_SIZE; /* 4 stripes */
m->mdt_opts.mo_evict_tgt_nids = 1;
- m->mdt_opts.mo_cos = MDT_COS_DEFAULT;
+ m->mdt_opts.mo_cos = MDT_COS_DEFAULT;
lmi = server_get_mount(dev);
- if (lmi == NULL) {
- CERROR("Cannot get mount info for %s!\n", dev);
- RETURN(-EFAULT);
- } else {
- lsi = s2lsi(lmi->lmi_sb);
- /* CMD is supported only in IAM mode */
- LASSERT(num);
- node_id = simple_strtol(num, NULL, 10);
+ if (lmi == NULL) {
+ CERROR("Cannot get mount info for %s!\n", dev);
+ RETURN(-EFAULT);
+ } else {
+ lsi = s2lsi(lmi->lmi_sb);
+ /* CMD is supported only in IAM mode */
+ LASSERT(num);
+ node_id = simple_strtol(num, NULL, 10);
obd->u.obt.obt_magic = OBT_MAGIC;
if (lsi->lsi_lmd != NULL &&
lsi->lsi_lmd->lmd_flags & LMD_FLG_SKIP_LFSCK)
s->ld_seq_site = ss_site;
ss_site->ss_lu = s;
- /* set server index */
+ /* set server index */
ss_site->ss_node_id = node_id;
/* failover is the default
* FIXME: we do not failout mds0/mgs, which may cause some problems.
* assumed whose ss_node_id == 0 XXX
* */
- obd->obd_replayable = 1;
- /* No connection accepted until configurations will finish */
- obd->obd_no_conn = 1;
+ obd->obd_replayable = 1;
+ /* No connection accepted until configurations will finish */
+ obd->obd_no_conn = 1;
if (cfg->lcfg_bufcount > 4 && LUSTRE_CFG_BUFLEN(cfg, 4) > 0) {
char *str = lustre_cfg_string(cfg, 4);
snprintf(info->mti_u.ns_name, sizeof(info->mti_u.ns_name), "%s-%s",
LUSTRE_MDT_NAME, obd->obd_uuid.uuid);
- m->mdt_namespace = ldlm_namespace_new(obd, info->mti_u.ns_name,
- LDLM_NAMESPACE_SERVER,
- LDLM_NAMESPACE_GREEDY,
- LDLM_NS_TYPE_MDT);
- if (m->mdt_namespace == NULL)
- GOTO(err_fini_seq, rc = -ENOMEM);
+ m->mdt_namespace = ldlm_namespace_new(obd, info->mti_u.ns_name,
+ LDLM_NAMESPACE_SERVER,
+ LDLM_NAMESPACE_GREEDY,
+ LDLM_NS_TYPE_MDT);
+ if (m->mdt_namespace == NULL)
+ GOTO(err_fini_seq, rc = -ENOMEM);
m->mdt_namespace->ns_lvbp = m;
m->mdt_namespace->ns_lvbo = &mdt_lvbo;
- ldlm_register_intent(m->mdt_namespace, mdt_intent_policy);
- /* set obd_namespace for compatibility with old code */
- obd->obd_namespace = m->mdt_namespace;
+ ldlm_register_intent(m->mdt_namespace, mdt_intent_policy);
+ /* set obd_namespace for compatibility with old code */
+ obd->obd_namespace = m->mdt_namespace;
rc = mdt_hsm_cdt_init(m);
if (rc != 0) {
CERROR("%s: error initializing coordinator, rc %d\n",
mdt_obd_name(m), rc);
- GOTO(err_free_ns, rc);
+ GOTO(err_free_ns, rc);
}
rc = tgt_init(env, &m->mdt_lut, obd, m->mdt_bottom, mdt_common_slice,
tgt_adapt_sptlrpc_conf(&m->mdt_lut);
- next = m->mdt_child;
- rc = next->md_ops->mdo_iocontrol(env, next, OBD_IOC_GET_MNTOPT, 0,
- &mntopts);
- if (rc)
- GOTO(err_fs_cleanup, rc);
+ next = m->mdt_child;
+ dt_conf = next->md_ops->mdo_dtconf_get(env, next);
- if (mntopts & MNTOPT_USERXATTR)
- m->mdt_opts.mo_user_xattr = 1;
- else
- m->mdt_opts.mo_user_xattr = 0;
+ mntopts = dt_conf->ddp_mntopts;
- rc = next->md_ops->mdo_maxeasize_get(env, next, &m->mdt_max_ea_size);
- if (rc)
- GOTO(err_fs_cleanup, rc);
+ if (mntopts & MNTOPT_USERXATTR)
+ m->mdt_opts.mo_user_xattr = 1;
+ else
+ m->mdt_opts.mo_user_xattr = 0;
- if (mntopts & MNTOPT_ACL)
- m->mdt_opts.mo_acl = 1;
- else
- m->mdt_opts.mo_acl = 0;
+ m->mdt_max_ea_size = dt_conf->ddp_max_ea_size;
+
+ if (mntopts & MNTOPT_ACL)
+ m->mdt_opts.mo_acl = 1;
+ else
+ m->mdt_opts.mo_acl = 0;
/* XXX: to support suppgid for ACL, we enable identity_upcall
* by default, otherwise, maybe got unexpected -EACCESS. */
GOTO(err_fs_cleanup, rc);
}
- rc = mdt_procfs_init(m, dev);
- if (rc) {
- CERROR("Can't init MDT lprocfs, rc %d\n", rc);
- GOTO(err_recovery, rc);
- }
+ rc = mdt_procfs_init(m, dev);
+ if (rc) {
+ CERROR("Can't init MDT lprocfs, rc %d\n", rc);
+ GOTO(err_recovery, rc);
+ }
rc = mdt_quota_init(env, m, cfg);
if (rc)
* when the whole stack is complete and ready
* to serve the requests */
- /* Reduce the initial timeout on an MDS because it doesn't need such
- * a long timeout as an OST does. Adaptive timeouts will adjust this
- * value appropriately. */
- if (ldlm_timeout == LDLM_TIMEOUT_DEFAULT)
- ldlm_timeout = MDS_LDLM_TIMEOUT_DEFAULT;
+ /* Reduce the initial timeout on an MDS because it doesn't need such
+ * a long timeout as an OST does. Adaptive timeouts will adjust this
+ * value appropriately. */
+ if (ldlm_timeout == LDLM_TIMEOUT_DEFAULT)
+ ldlm_timeout = MDS_LDLM_TIMEOUT_DEFAULT;
- RETURN(0);
+ RETURN(0);
err_procfs:
mdt_procfs_fini(m);
err_recovery: