Skip to content
Snippets Groups Projects
Commit d387061f authored by bwzhou's avatar bwzhou
Browse files

Branch HEAD

b=14219
r=adilger, shadow

use obd_punch_rqset() instead of obd_setattr() to change size
parent e87e848d
No related branches found
No related tags found
No related merge requests found
......@@ -457,8 +457,6 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd,
memset(oinfo, 0, sizeof(*oinfo));
oa->o_size = la->la_size;
/* When setting attr to ost, FLBKSZ is not needed. */
oa->o_valid &= ~OBD_MD_FLBLKSZ;
obdo_from_la(oa, la, OBD_MD_FLTYPE | OBD_MD_FLATIME |
......@@ -476,10 +474,13 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd,
oinfo->oi_md = lsm;
oinfo->oi_capa = mdo_capa_get(env, child, NULL,
CAPA_OPC_MDS_DEFAULT);
oinfo->oi_policy.l_extent.start = la->la_size;
oinfo->oi_policy.l_extent.end = OBD_OBJECT_EOF;
if (IS_ERR(oinfo->oi_capa))
oinfo->oi_capa = NULL;
rc = obd_setattr(lov_exp, oinfo, oti);
rc = obd_punch_rqset(lov_exp, oinfo, oti);
capa_put(oinfo->oi_capa);
if (rc) {
CERROR("Error setting attrs for "DFID": rc %d\n",
......
......@@ -3134,6 +3134,26 @@ int filter_setattr(struct obd_export *exp, struct obd_info *oinfo,
if (rc)
RETURN(rc);
/* This would be very bad - accidentally truncating a file when
* changing the time or similar - bug 12203. */
if (oinfo->oi_oa->o_valid & OBD_MD_FLSIZE &&
oinfo->oi_policy.l_extent.end != OBD_OBJECT_EOF) {
static char mdsinum[48];
if (oinfo->oi_oa->o_valid & OBD_MD_FLFID)
snprintf(mdsinum, sizeof(mdsinum) - 1,
" of inode "LPU64"/%u", oinfo->oi_oa->o_fid,
oinfo->oi_oa->o_generation);
else
mdsinum[0] = '\0';
CERROR("%s: setattr from %s trying to truncate objid "LPU64
" %s\n",
exp->exp_obd->obd_name, obd_export_nid2str(exp),
oinfo->oi_oa->o_id, mdsinum);
RETURN(-EPERM);
}
dentry = __filter_oa2dentry(exp->exp_obd, oinfo->oi_oa,
__FUNCTION__, 1);
if (IS_ERR(dentry))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment