Whamcloud - gitweb
LU-3557 mdt: fix open existing file with O_CREAT for ro mount
[fs/lustre-release.git] / lustre / mdt / mdt_open.c
index a967c44..686a76f 100644 (file)
@@ -1696,6 +1696,8 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc)
                 }
                 if (!(create_flags & MDS_OPEN_CREAT))
                         GOTO(out_parent, result);
+               if (exp_connect_flags(req->rq_export) & OBD_CONNECT_RDONLY)
+                       GOTO(out_parent, result = -EROFS);
                 *child_fid = *info->mti_rr.rr_fid2;
                 LASSERTF(fid_is_sane(child_fid), "fid="DFID"\n",
                          PFID(child_fid));
@@ -1966,7 +1968,7 @@ static int mdt_hsm_release(struct mdt_thread_info *info, struct mdt_object *o,
        /* try to hold open_sem so that nobody else can open the file */
        if (!down_write_trylock(&o->mot_open_sem)) {
                ldlm_lock_cancel(lease);
-               ldlm_lock_put(lease);
+               LDLM_LOCK_PUT(lease);
                RETURN(-EBUSY);
        }
 
@@ -1982,7 +1984,7 @@ static int mdt_hsm_release(struct mdt_thread_info *info, struct mdt_object *o,
         * have been cancelled. It's okay to cancel it now as we've
         * held mot_open_sem. */
        ldlm_lock_cancel(lease);
-       ldlm_lock_put(lease);
+       LDLM_LOCK_PUT(lease);
 
        if (lease_broken) /* don't perform release task */
                GOTO(out_unlock, rc = -ESTALE);