@@ -4978,7 +4978,8 @@ int ll_layout_refresh(struct inode *inode, u32 *gen)
* match it before grabbing layout lock mutex.
*/
mode = ll_take_md_lock(inode, MDS_INODELOCK_LAYOUT, &lockh, 0,
- LCK_CR | LCK_CW | LCK_PR | LCK_PW);
+ LCK_CR | LCK_CW | LCK_PR |
+ LCK_PW | LCK_EX);
if (mode != 0) { /* hit cached lock */
rc = ll_layout_lock_set(&lockh, mode, inode);
if (rc == -EAGAIN)
@@ -580,18 +580,26 @@ static struct ptlrpc_request *mdc_intent_layout_pack(struct obd_export *exp,
struct md_op_data *op_data)
{
struct obd_device *obd = class_exp2obd(exp);
+ struct list_head cancels = LIST_HEAD_INIT(cancels);
struct ptlrpc_request *req;
struct ldlm_intent *lit;
struct layout_intent *layout;
- int rc;
+ int count = 0, rc;
req = ptlrpc_request_alloc(class_exp2cliimp(exp),
&RQF_LDLM_INTENT_LAYOUT);
if (!req)
return ERR_PTR(-ENOMEM);
+ if (fid_is_sane(&op_data->op_fid2) && (it->it_op & IT_LAYOUT) &&
+ (it->it_flags & FMODE_WRITE)) {
+ count = mdc_resource_get_unused(exp, &op_data->op_fid2,
+ &cancels, LCK_EX,
+ MDS_INODELOCK_LAYOUT);
+ }
+
req_capsule_set_size(&req->rq_pill, &RMF_EADATA, RCL_CLIENT, 0);
- rc = ldlm_prep_enqueue_req(exp, req, NULL, 0);
+ rc = ldlm_prep_enqueue_req(exp, req, &cancels, count);
if (rc) {
ptlrpc_request_free(req);
return ERR_PTR(rc);