Whamcloud - gitweb
LU-3557 mdt: fix open existing file with O_CREAT for ro mount 93/6893/4
authorLi Dongyang <dongyang.li@anu.edu.au>
Thu, 4 Jul 2013 04:13:49 +0000 (14:13 +1000)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 17 Aug 2013 06:15:00 +0000 (06:15 +0000)
We should only return -EROFS for read only mount if we really
need to create the file in question.

Defer the check to mdt_reint_open() instead of mdt_intent_opc().

Signed-off-by: Li Dongyang <dongyang.li@anu.edu.au>
Change-Id: I68f34ef7abbae934cfc3564a67ff70e5ab8a12b1
Reviewed-on: http://review.whamcloud.com/6893
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Li Xi <pkuelelixi@gmail.com>
Reviewed-by: Emoly Liu <emoly.liu@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_open.c

index 15f6c4b..0de83de 100644 (file)
@@ -3537,7 +3537,14 @@ static struct mdt_it_flavor {
         },
         [MDT_IT_OCREAT]   = {
                 .it_fmt   = &RQF_LDLM_INTENT,
-                .it_flags = MUTABOR,
+               /*
+                * OCREAT is not a MUTABOR request as if the file
+                * already exists.
+                * We do the extra check of OBD_CONNECT_RDONLY in
+                * mdt_reint_open() when we really need to create
+                * the object.
+                */
+               .it_flags = 0,
                 .it_act   = mdt_intent_reint,
                 .it_reint = REINT_OPEN
         },
index 28eb0ca..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));