Whamcloud - gitweb
LU-3557 mdt: fix open existing file with O_CREAT for ro mount
[fs/lustre-release.git] / lustre / mdt / mdt_handler.c
index c9dee86..0de83de 100644 (file)
@@ -411,8 +411,8 @@ void mdt_pack_attr2body(struct mdt_thread_info *info, struct mdt_body *b,
                 b->blocks = 0;
                 /* if no object is allocated on osts, the size on mds is valid. b=22272 */
                 b->valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;
-       } else if ((ma->ma_valid & MA_LOV) && ma->ma_lmm &&
-                  (ma->ma_lmm->lmm_pattern & LOV_PATTERN_F_RELEASED)) {
+       } else if ((ma->ma_valid & MA_LOV) && ma->ma_lmm != NULL &&
+                  ma->ma_lmm->lmm_pattern & LOV_PATTERN_F_RELEASED) {
                /* A released file stores its size on MDS. */
                b->blocks = 0;
                b->valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;
@@ -766,7 +766,7 @@ static int mdt_getattr_internal(struct mdt_thread_info *info,
        /* the Lustre protocol supposes to return default striping
         * on the user-visible root if explicitly requested */
        if ((ma->ma_valid & MA_LOV) == 0 && S_ISDIR(la->la_mode) &&
-           (ma->ma_need & MA_LOV_DEF && is_root) && (ma->ma_need & MA_LOV)) {
+           (ma->ma_need & MA_LOV_DEF && is_root) && ma->ma_need & MA_LOV) {
                struct lu_fid      rootfid;
                struct mdt_object *root;
                struct mdt_device *mdt = info->mti_mdt;
@@ -2561,7 +2561,7 @@ int mdt_remote_object_lock(struct mdt_thread_info *mti,
 
        LASSERT(mdt_object_remote(o));
 
-       LASSERT((ibits & MDS_INODELOCK_UPDATE));
+       LASSERT(ibits & MDS_INODELOCK_UPDATE);
 
        memset(einfo, 0, sizeof(*einfo));
        einfo->ei_type = LDLM_IBITS;
@@ -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
         },
@@ -4843,7 +4850,7 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m,
         const char                *identity_upcall = "NONE";
         struct md_device          *next;
         int                        rc;
-        int                        node_id;
+       long                       node_id;
         mntopt_t                   mntopts;
         ENTRY;
 
@@ -5857,8 +5864,8 @@ static int mdt_path_current(struct mdt_thread_info *info,
                linkea_entry_unpack(lee, &reclen, tmpname, tmpfid);
                /* If set, use link #linkno for path lookup, otherwise use
                   link #0.  Only do this for the final path element. */
-               if ((pli->pli_fidcount == 0) &&
-                   (pli->pli_linkno < leh->leh_reccount)) {
+               if (pli->pli_fidcount == 0 &&
+                   pli->pli_linkno < leh->leh_reccount) {
                        int count;
                        for (count = 0; count < pli->pli_linkno; count++) {
                                lee = (struct link_ea_entry *)