From: Bobi Jam Date: Sun, 2 Oct 2011 05:18:59 +0000 (+0800) Subject: LU-650 Max possible file size is mutable X-Git-Tag: 2.1.0~5 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=303f41aa0ff07a43a31e397a3d163a6b8b6e4864;p=fs%2Flustre-release.git LU-650 Max possible file size is mutable Move maxbytes fields out of wire data part of lov_stripe_md, it can change when OSTs change their status, e.g. disconnected or inactivated. Change-Id: I9fb1f2597df1e98d993792706ac94f469d23a78c Signed-off-by: Bobi Jam Reviewed-on: http://review.whamcloud.com/1327 Reviewed-by: Oleg Drokin Reviewed-by: Andreas Dilger Tested-by: Hudson Tested-by: Yu Jian Tested-by: Maloo --- diff --git a/lustre/include/obd.h b/lustre/include/obd.h index fcee1b0..9d7a61f 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -132,11 +132,13 @@ struct lov_stripe_md { cfs_spinlock_t lsm_lock; pid_t lsm_lock_owner; /* debugging */ + /* maximum possible file size, might change as OSTs status changes, + * e.g. disconnected, deactivated */ + __u64 lsm_maxbytes; struct { /* Public members. */ __u64 lw_object_id; /* lov object id */ __u64 lw_object_seq; /* lov object seq */ - __u64 lw_maxbytes; /* maximum possible file size */ /* LOV-private members start here -- only for use in lov/. */ __u32 lw_magic; @@ -151,7 +153,6 @@ struct lov_stripe_md { #define lsm_object_id lsm_wire.lw_object_id #define lsm_object_seq lsm_wire.lw_object_seq -#define lsm_maxbytes lsm_wire.lw_maxbytes #define lsm_magic lsm_wire.lw_magic #define lsm_stripe_size lsm_wire.lw_stripe_size #define lsm_pattern lsm_wire.lw_pattern diff --git a/lustre/lov/lov_ea.c b/lustre/lov/lov_ea.c index 11e2b07..25017a2 100755 --- a/lustre/lov/lov_ea.c +++ b/lustre/lov/lov_ea.c @@ -177,6 +177,29 @@ static int lsm_destroy_plain(struct lov_stripe_md *lsm, struct obdo *oa, return 0; } +/* Find minimum stripe maxbytes value. For inactive or + * reconnecting targets use LUSTRE_STRIPE_MAXBYTES. */ +static void lov_tgt_maxbytes(struct lov_tgt_desc *tgt, __u64 *stripe_maxbytes) +{ + struct obd_import *imp = tgt->ltd_obd->u.cli.cl_import; + + if (imp == NULL || !tgt->ltd_active) { + *stripe_maxbytes = LUSTRE_STRIPE_MAXBYTES; + return; + } + + cfs_spin_lock(&imp->imp_lock); + if (imp->imp_state == LUSTRE_IMP_FULL && + (imp->imp_connect_data.ocd_connect_flags & OBD_CONNECT_MAXBYTES) && + imp->imp_connect_data.ocd_maxbytes > 0) { + if (*stripe_maxbytes > imp->imp_connect_data.ocd_maxbytes) + *stripe_maxbytes = imp->imp_connect_data.ocd_maxbytes; + } else { + *stripe_maxbytes = LUSTRE_STRIPE_MAXBYTES; + } + cfs_spin_unlock(&imp->imp_lock); +} + static int lsm_lmm_verify_v1(struct lov_mds_md_v1 *lmm, int lmm_bytes, int *stripe_count) { @@ -208,8 +231,6 @@ int lsm_unpackmd_v1(struct lov_obd *lov, struct lov_stripe_md *lsm, lsm_unpackmd_common(lsm, lmm); for (i = 0; i < lsm->lsm_stripe_count; i++) { - struct obd_import *imp; - /* XXX LOV STACKING call down to osc_unpackmd() */ loi = lsm->lsm_oinfo[i]; loi->loi_id = le64_to_cpu(lmm->lmm_objects[i].l_object_id); @@ -228,23 +249,10 @@ int lsm_unpackmd_v1(struct lov_obd *lov, struct lov_stripe_md *lsm, return -EINVAL; } /* calculate the minimum stripe max bytes */ - imp = lov->lov_tgts[loi->loi_ost_idx]->ltd_obd->u.cli.cl_import; - if (imp != NULL) { - if (!(imp->imp_connect_data.ocd_connect_flags & - OBD_CONNECT_MAXBYTES)) { - imp->imp_connect_data.ocd_maxbytes = - LUSTRE_STRIPE_MAXBYTES; - } - if (stripe_maxbytes>imp->imp_connect_data.ocd_maxbytes){ - stripe_maxbytes = - imp->imp_connect_data.ocd_maxbytes; - } - } + lov_tgt_maxbytes(lov->lov_tgts[loi->loi_ost_idx], + &stripe_maxbytes); } - /* no ost connected yet */ - if (stripe_maxbytes == OBD_OBJECT_EOF) - stripe_maxbytes = LUSTRE_STRIPE_MAXBYTES; lsm->lsm_maxbytes = stripe_maxbytes * lsm->lsm_stripe_count; return 0; @@ -299,8 +307,6 @@ int lsm_unpackmd_v3(struct lov_obd *lov, struct lov_stripe_md *lsm, strncpy(lsm->lsm_pool_name, lmm->lmm_pool_name, LOV_MAXPOOLNAME); for (i = 0; i < lsm->lsm_stripe_count; i++) { - struct obd_import *imp; - /* XXX LOV STACKING call down to osc_unpackmd() */ loi = lsm->lsm_oinfo[i]; loi->loi_id = le64_to_cpu(lmm->lmm_objects[i].l_object_id); @@ -319,23 +325,10 @@ int lsm_unpackmd_v3(struct lov_obd *lov, struct lov_stripe_md *lsm, return -EINVAL; } /* calculate the minimum stripe max bytes */ - imp = lov->lov_tgts[loi->loi_ost_idx]->ltd_obd->u.cli.cl_import; - if (imp != NULL) { - if (!(imp->imp_connect_data.ocd_connect_flags & - OBD_CONNECT_MAXBYTES)) { - imp->imp_connect_data.ocd_maxbytes = - LUSTRE_STRIPE_MAXBYTES; - } - if (stripe_maxbytes>imp->imp_connect_data.ocd_maxbytes){ - stripe_maxbytes = - imp->imp_connect_data.ocd_maxbytes; - } - } + lov_tgt_maxbytes(lov->lov_tgts[loi->loi_ost_idx], + &stripe_maxbytes); } - /* no ost connected yet */ - if (stripe_maxbytes == OBD_OBJECT_EOF) - stripe_maxbytes = LUSTRE_STRIPE_MAXBYTES; lsm->lsm_maxbytes = stripe_maxbytes * lsm->lsm_stripe_count; return 0;