X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Flod%2Flod_qos.c;h=51d66033cb91dac3413362be93189c7ef3c6cf3a;hb=7b124fef762f5adc4cf5fcf7fa21987655493e19;hp=5b05ec45d065c602152558839c34a4ac74c5ee48;hpb=5b91c09eb97c5d756e88d7278b7dd3fa68e54f7f;p=fs%2Flustre-release.git diff --git a/lustre/lod/lod_qos.c b/lustre/lod/lod_qos.c index 5b05ec4..51d6603 100644 --- a/lustre/lod/lod_qos.c +++ b/lustre/lod/lod_qos.c @@ -23,7 +23,7 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved * Use is subject to license terms. * - * Copyright (c) 2012, Intel Corporation. + * Copyright (c) 2012, 2013, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -159,6 +159,10 @@ static int lod_statfs_and_check(const struct lu_env *env, struct lod_device *d, if (rc && rc != -ENOTCONN) CERROR("%s: statfs: rc = %d\n", lod2obd(d)->obd_name, rc); + /* If the OST is readonly then we can't allocate objects there */ + if (sfs->os_state & OS_STATE_READONLY) + rc = -EROFS; + /* check whether device has changed state (active, inactive) */ if (rc != 0 && ost->ltd_active) { /* turned inactive? */ @@ -771,7 +775,7 @@ repeat_find: /* * try to use another OSP if this one is degraded */ - if (sfs->os_state == OS_STATE_DEGRADED && speed < 2) { + if (sfs->os_state & OS_STATE_DEGRADED && speed < 2) { QOS_DEBUG("#%d: degraded\n", ost_idx); continue; } @@ -1211,34 +1215,40 @@ static int lod_use_defined_striping(const struct lu_env *env, struct lod_object *mo, const struct lu_buf *buf) { - struct lod_device *d = lu2lod_dev(lod2lu_obj(mo)->lo_dev); struct lov_mds_md_v1 *v1 = buf->lb_buf; struct lov_mds_md_v3 *v3 = buf->lb_buf; struct lov_ost_data_v1 *objs; __u32 magic; - int rc; + int rc = 0; ENTRY; - rc = lod_verify_striping(d, buf, 1); - if (rc) - RETURN(rc); - magic = le32_to_cpu(v1->lmm_magic); if (magic == LOV_MAGIC_V1_DEF) { + magic = LOV_MAGIC_V1; objs = &v1->lmm_objects[0]; } else if (magic == LOV_MAGIC_V3_DEF) { + magic = LOV_MAGIC_V3; objs = &v3->lmm_objects[0]; lod_object_set_pool(mo, v3->lmm_pool_name); } else { GOTO(out, rc = -EINVAL); } + mo->ldo_pattern = le32_to_cpu(v1->lmm_pattern); mo->ldo_stripe_size = le32_to_cpu(v1->lmm_stripe_size); mo->ldo_stripenr = le16_to_cpu(v1->lmm_stripe_count); mo->ldo_layout_gen = le16_to_cpu(v1->lmm_layout_gen); + + /* fixup for released file before object initialization */ + if (mo->ldo_pattern & LOV_PATTERN_F_RELEASED) { + mo->ldo_released_stripenr = mo->ldo_stripenr; + mo->ldo_stripenr = 0; + } + LASSERT(buf->lb_len >= lov_mds_md_size(mo->ldo_stripenr, magic)); - rc = lod_initialize_objects(env, mo, objs); + if (mo->ldo_stripenr > 0) + rc = lod_initialize_objects(env, mo, objs); out: RETURN(rc); @@ -1282,10 +1292,14 @@ static int lod_qos_parse_config(const struct lu_env *env, RETURN(-EINVAL); } - if (v1->lmm_pattern != 0 && v1->lmm_pattern != LOV_PATTERN_RAID0) { + v1->lmm_magic = magic; + if (v1->lmm_pattern == 0) + v1->lmm_pattern = LOV_PATTERN_RAID0; + if (lov_pattern(v1->lmm_pattern) != LOV_PATTERN_RAID0) { CERROR("invalid pattern: %x\n", v1->lmm_pattern); RETURN(-EINVAL); } + lo->ldo_pattern = v1->lmm_pattern; if (v1->lmm_stripe_size) lo->ldo_stripe_size = v1->lmm_stripe_size; @@ -1339,6 +1353,12 @@ static int lod_qos_parse_config(const struct lu_env *env, } else lod_object_set_pool(lo, NULL); + /* fixup for released file */ + if (lo->ldo_pattern & LOV_PATTERN_F_RELEASED) { + lo->ldo_released_stripenr = lo->ldo_stripenr; + lo->ldo_stripenr = 0; + } + RETURN(0); } @@ -1376,6 +1396,10 @@ int lod_qos_prep_create(const struct lu_env *env, struct lod_object *lo, if (rc) GOTO(out, rc); + /* A released file is being created */ + if (lo->ldo_stripenr == 0) + GOTO(out, rc = 0); + if (likely(lo->ldo_stripe == NULL)) { /* * no striping has been created so far