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 |
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",
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))