@@ -1714,6 +1714,16 @@ static int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data)
if (IS_ERR(op_data))
return PTR_ERR(op_data);
+ /* If this is a chgrp of a regular file, we want to reserve enough
+ * quota to cover the entire file size.
+ */
+ if (S_ISREG(inode->i_mode) && op_data->op_attr.ia_valid & ATTR_GID &&
+ from_kgid(&init_user_ns, op_data->op_attr.ia_gid) !=
+ from_kgid(&init_user_ns, inode->i_gid)) {
+ op_data->op_xvalid |= OP_XVALID_BLOCKS;
+ op_data->op_attr_blocks = inode->i_blocks;
+ }
+
rc = md_setattr(sbi->ll_md_exp, op_data, NULL, 0, &request);
if (rc) {
ptlrpc_req_finished(request);