__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);
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;
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;
}
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;
}
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);
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) {
}
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))
* 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.
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);
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;
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);
&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));