Whamcloud - gitweb
- fixes in lov to make it a bit more parallel creates friendly.
authoryury <yury>
Wed, 15 Nov 2006 14:14:51 +0000 (14:14 +0000)
committeryury <yury>
Wed, 15 Nov 2006 14:14:51 +0000 (14:14 +0000)
lustre/lov/lov_qos.c
lustre/mdd/mdd_dir.c
lustre/mdt/mdt_open.c
lustre/mdt/mdt_reint.c

index 2bc909c..616b2b8 100644 (file)
@@ -150,10 +150,10 @@ static int qos_calc_ppo(struct obd_device *obd)
         __u32 num_active;
         int rc, i, prio_wide;
         ENTRY;
-        
+
         if (!lov->lov_qos.lq_dirty) 
                 GOTO(out, rc = 0);
-                
+
         num_active = lov->desc.ld_active_tgt_count - 1; 
         if (num_active < 1)
                 GOTO(out, rc = -EAGAIN);
@@ -327,11 +327,19 @@ static int qos_calc_rr(struct lov_obd *lov)
         int i;
         ENTRY;
 
+        /*
+         * Check for dirtiness first under read lock to make it as parallel as
+         * possible.
+         */
+        down_read(&lov->lov_qos.lq_rw_sem);
         if (!lov->lov_qos.lq_dirty_rr) {
                 LASSERT(lov->lov_qos.lq_rr_size);
+                up_read(&lov->lov_qos.lq_rw_sem);
                 RETURN(0);
         }
+        up_read(&lov->lov_qos.lq_rw_sem);
 
+        /* Do actuall allocation. */
         down_write(&lov->lov_qos.lq_rw_sem);
         ost_count = lov->desc.ld_tgt_count;
 
@@ -571,16 +579,28 @@ static int alloc_qos(struct obd_export *exp, int *idx_arr, int *stripe_cnt)
         ENTRY;
         
         lov_getref(exp->exp_obd);
-        down_write(&lov->lov_qos.lq_rw_sem);
 
+        /* 
+         * Quick check for dirtriness first, use read lock to make this parallel
+         * as much as possible.
+         */
+        down_read(&lov->lov_qos.lq_rw_sem);
+        if (!lov->lov_qos.lq_dirty) {
+                up_read(&lov->lov_qos.lq_rw_sem);
+                GOTO(out, rc = -EAGAIN);
+        }
+        up_read(&lov->lov_qos.lq_rw_sem);
+        
+        /* Do actuall allocation, use write lock here. */
+        down_write(&lov->lov_qos.lq_rw_sem);
         ost_count = lov->desc.ld_tgt_count;
 
         if (lov->desc.ld_active_tgt_count < 2) 
-                GOTO(out, rc = -EAGAIN);
+                GOTO(out_up_write, rc = -EAGAIN);
 
         rc = qos_calc_ppo(exp->exp_obd);
         if (rc) 
-                GOTO(out, rc);
+                GOTO(out_up_write, rc);
         
         total_bavail = 0;
         good_osts = 0;
@@ -618,14 +638,14 @@ static int alloc_qos(struct obd_export *exp, int *idx_arr, int *stripe_cnt)
         }
         
         if (!total_bavail)
-                GOTO(out, rc = -ENOSPC);
+                GOTO(out_up_write, rc = -ENOSPC);
        
         /* if we don't have enough good OSTs, we reduce the stripe count. */
         if (good_osts < *stripe_cnt)
                 *stripe_cnt = good_osts;
 
         if (!*stripe_cnt) 
-                GOTO(out, rc = -EAGAIN);
+                GOTO(out_up_write, rc = -EAGAIN);
         
         /* Find enough OSTs with weighted random allocation. */
         nfound = 0;
@@ -668,9 +688,10 @@ static int alloc_qos(struct obd_export *exp, int *idx_arr, int *stripe_cnt)
         }
         LASSERT(nfound == *stripe_cnt);
         
-out:
+out_up_write:
         up_write(&lov->lov_qos.lq_rw_sem);
         
+out:
         if (rc == -EAGAIN)
                 rc = alloc_rr(lov, idx_arr, stripe_cnt);
         
index 7b6562b..7d365de 100644 (file)
@@ -1006,8 +1006,8 @@ static int mdd_create_sanity_check(const struct lu_env *env,
                 RETURN(-ENOENT);
 
         /*
-         * In some cases this lookup is not needed - we know before that if name
-         * exists or not.
+         * In some cases this lookup is not needed - we know before if name
+         * exists or not because MDT performs lookup for it.
          */
         /* XXX disable that lookup temporary */
         if (0 && lookup) {
index e27fc96..e7e6205 100644 (file)
@@ -791,13 +791,9 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc)
         }
 
         lh = &info->mti_lh[MDT_LH_PARENT];
-        if (!(create_flags & MDS_OPEN_CREAT)) {
-                mdt_lock_pdo_init(lh, LCK_PR, rr->rr_name,
-                                  rr->rr_namelen);
-        } else {
-                mdt_lock_pdo_init(lh, LCK_PW, rr->rr_name,
-                                  rr->rr_namelen);
-        }
+        mdt_lock_pdo_init(lh, (create_flags & MDS_OPEN_CREAT) ?
+                          LCK_PW : LCK_PR, rr->rr_name, rr->rr_namelen);
+        
         parent = mdt_object_find_lock(info, rr->rr_fid1, lh,
                                       MDS_INODELOCK_UPDATE);
         if (IS_ERR(parent))
index 2ad6f41..e7c4cf5 100644 (file)
@@ -9,6 +9,7 @@
  *   Author: Andreas Dilger <adilger@clusterfs.com>
  *   Author: Phil Schwan <phil@clusterfs.com>
  *   Author: Huang Hua <huanghua@clusterfs.com>
+ *   Author: Yury Umanets <umka@clusterfs.com>
  *
  *   This file is part of the Lustre file system, http://www.lustre.org
  *   Lustre is a trademark of Cluster File Systems, Inc.
@@ -48,7 +49,7 @@ static int mdt_md_create(struct mdt_thread_info *info)
         int rc;
         ENTRY;
 
-        DEBUG_REQ(D_INODE, mdt_info_req(info), "create  (%s->"DFID") in "DFID,
+        DEBUG_REQ(D_INODE, mdt_info_req(info), "Create  (%s->"DFID") in "DFID,
                   rr->rr_name, PFID(rr->rr_fid2), PFID(rr->rr_fid1));
 
         repbody = req_capsule_server_get(&info->mti_pill, &RMF_MDT_BODY);
@@ -96,7 +97,7 @@ static int mdt_md_create(struct mdt_thread_info *info)
         RETURN(rc);
 }
 
-/* partial request to create object only */
+/* Partial request to create object only */
 static int mdt_md_mkobj(struct mdt_thread_info *info)
 {
         struct mdt_device      *mdt = info->mti_mdt;
@@ -106,7 +107,7 @@ static int mdt_md_mkobj(struct mdt_thread_info *info)
         int rc;
         ENTRY;
 
-        DEBUG_REQ(D_INODE, mdt_info_req(info), "partial create "DFID"\n",
+        DEBUG_REQ(D_INODE, mdt_info_req(info), "Partial create "DFID"\n",
                   PFID(info->mti_rr.rr_fid2));
 
         repbody = req_capsule_server_get(&info->mti_pill, &RMF_MDT_BODY);
@@ -129,7 +130,7 @@ static int mdt_md_mkobj(struct mdt_thread_info *info)
                                               &info->mti_spec, ma);
                 }
                 if (rc == 0) {
-                        /* return fid & attr to client. */
+                        /* Return fid & attr to client. */
                         if (ma->ma_valid & MA_INODE)
                                 mdt_pack_attr2body(info, repbody, &ma->ma_attr,
                                                    mdt_object_fid(o));