X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Flov%2Flov_ea.c;h=9f7a4239c373ad85b85e90ac595aa5d36c1d2569;hb=58c997babb608f5ab26f326772574bfd34e8cdc3;hp=cb09efab556447663e34aaecd5bacc2620bf4ef7;hpb=cec72a356891eaa729314a7bc89c4b2aaef0a31b;p=fs%2Flustre-release.git diff --git a/lustre/lov/lov_ea.c b/lustre/lov/lov_ea.c old mode 100755 new mode 100644 index cb09efa..9f7a423 --- a/lustre/lov/lov_ea.c +++ b/lustre/lov/lov_ea.c @@ -1,6 +1,4 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * +/* * GPL HEADER START * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,6 +26,8 @@ /* * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. + * + * Copyright (c) 2011, 2012, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -38,9 +38,6 @@ * Author: Wang Di */ -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif #define DEBUG_SUBSYSTEM S_LOV #ifdef __KERNEL__ @@ -53,7 +50,6 @@ #include #include #include -#include #include "lov_internal.h" @@ -63,7 +59,7 @@ struct lovea_unpack_args { }; static int lsm_lmm_verify_common(struct lov_mds_md *lmm, int lmm_bytes, - int stripe_count) + __u16 stripe_count) { if (stripe_count == 0 || stripe_count > LOV_V1_INSANE_STRIPE_COUNT) { @@ -72,11 +68,11 @@ static int lsm_lmm_verify_common(struct lov_mds_md *lmm, int lmm_bytes, return -EINVAL; } - if (lmm->lmm_object_id == 0) { - CERROR("zero object id\n"); - lov_dump_lmm(D_WARNING, lmm); - return -EINVAL; - } + if (ostid_id(&lmm->lmm_oi) == 0) { + CERROR("zero object id\n"); + lov_dump_lmm(D_WARNING, lmm); + return -EINVAL; + } if (lmm->lmm_pattern != cpu_to_le32(LOV_PATTERN_RAID0)) { CERROR("bad striping pattern\n"); @@ -94,13 +90,13 @@ static int lsm_lmm_verify_common(struct lov_mds_md *lmm, int lmm_bytes, return 0; } -struct lov_stripe_md *lsm_alloc_plain(int stripe_count, int *size) +struct lov_stripe_md *lsm_alloc_plain(__u16 stripe_count, int *size) { struct lov_stripe_md *lsm; - int i, oinfo_ptrs_size; - struct lov_oinfo *loi; + struct lov_oinfo *loi; + int i, oinfo_ptrs_size; - LASSERT(stripe_count > 0); + LASSERT(stripe_count <= LOV_MAX_STRIPE_COUNT); oinfo_ptrs_size = sizeof(struct lov_oinfo *) * stripe_count; *size = sizeof(struct lov_stripe_md) + oinfo_ptrs_size; @@ -116,7 +112,6 @@ struct lov_stripe_md *lsm_alloc_plain(int stripe_count, int *size) lsm->lsm_oinfo[i] = loi; } lsm->lsm_stripe_count = stripe_count; - lsm->lsm_pool_name[0] = '\0'; return lsm; err: @@ -128,7 +123,7 @@ err: void lsm_free_plain(struct lov_stripe_md *lsm) { - int stripe_count = lsm->lsm_stripe_count; + __u16 stripe_count = lsm->lsm_stripe_count; int i; for (i = 0; i < stripe_count; i++) @@ -141,15 +136,15 @@ void lsm_free_plain(struct lov_stripe_md *lsm) static void lsm_unpackmd_common(struct lov_stripe_md *lsm, struct lov_mds_md *lmm) { - /* - * This supposes lov_mds_md_v1/v3 first fields are - * are the same - */ - lsm->lsm_object_id = le64_to_cpu(lmm->lmm_object_id); - lsm->lsm_object_seq = le64_to_cpu(lmm->lmm_object_seq); - lsm->lsm_stripe_size = le32_to_cpu(lmm->lmm_stripe_size); - lsm->lsm_pattern = le32_to_cpu(lmm->lmm_pattern); - lsm->lsm_pool_name[0] = '\0'; + /* + * This supposes lov_mds_md_v1/v3 first fields are + * are the same + */ + ostid_le_to_cpu(&lmm->lmm_oi, &lsm->lsm_oi); + lsm->lsm_stripe_size = le32_to_cpu(lmm->lmm_stripe_size); + lsm->lsm_pattern = le32_to_cpu(lmm->lmm_pattern); + lsm->lsm_layout_gen = le16_to_cpu(lmm->lmm_layout_gen); + lsm->lsm_pool_name[0] = '\0'; } static void @@ -174,8 +169,31 @@ 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; + } + + 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; + } + spin_unlock(&imp->imp_lock); +} + static int lsm_lmm_verify_v1(struct lov_mds_md_v1 *lmm, int lmm_bytes, - int *stripe_count) + __u16 *stripe_count) { if (lmm_bytes < sizeof(*lmm)) { CERROR("lov_mds_md_v1 too small: %d, need at least %d\n", @@ -183,7 +201,7 @@ static int lsm_lmm_verify_v1(struct lov_mds_md_v1 *lmm, int lmm_bytes, return -EINVAL; } - *stripe_count = le32_to_cpu(lmm->lmm_stripe_count); + *stripe_count = le16_to_cpu(lmm->lmm_stripe_count); if (lmm_bytes < lov_mds_md_size(*stripe_count, LOV_MAGIC_V1)) { CERROR("LOV EA V1 too small: %d, need %d\n", @@ -200,17 +218,17 @@ int lsm_unpackmd_v1(struct lov_obd *lov, struct lov_stripe_md *lsm, { struct lov_oinfo *loi; int i; + __u64 stripe_maxbytes = OBD_OBJECT_EOF; lsm_unpackmd_common(lsm, lmm); - for (i = 0; i < lsm->lsm_stripe_count; i++) { - /* 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); - loi->loi_seq = le64_to_cpu(lmm->lmm_objects[i].l_object_seq); - loi->loi_ost_idx = le32_to_cpu(lmm->lmm_objects[i].l_ost_idx); - loi->loi_ost_gen = le32_to_cpu(lmm->lmm_objects[i].l_ost_gen); - if (loi->loi_ost_idx >= lov->desc.ld_tgt_count) { + for (i = 0; i < lsm->lsm_stripe_count; i++) { + /* XXX LOV STACKING call down to osc_unpackmd() */ + loi = lsm->lsm_oinfo[i]; + ostid_le_to_cpu(&lmm->lmm_objects[i].l_ost_oi, &loi->loi_oi); + loi->loi_ost_idx = le32_to_cpu(lmm->lmm_objects[i].l_ost_idx); + loi->loi_ost_gen = le32_to_cpu(lmm->lmm_objects[i].l_ost_gen); + if (loi->loi_ost_idx >= lov->desc.ld_tgt_count) { CERROR("OST index %d more than OST count %d\n", loi->loi_ost_idx, lov->desc.ld_tgt_count); lov_dump_lmm_v1(D_WARNING, lmm); @@ -221,8 +239,13 @@ int lsm_unpackmd_v1(struct lov_obd *lov, struct lov_stripe_md *lsm, lov_dump_lmm_v1(D_WARNING, lmm); return -EINVAL; } + /* calculate the minimum stripe max bytes */ + lov_tgt_maxbytes(lov->lov_tgts[loi->loi_ost_idx], + &stripe_maxbytes); } + lsm->lsm_maxbytes = stripe_maxbytes * lsm->lsm_stripe_count; + return 0; } @@ -236,7 +259,7 @@ const struct lsm_operations lsm_v1_ops = { }; static int lsm_lmm_verify_v3(struct lov_mds_md *lmmv1, int lmm_bytes, - int *stripe_count) + __u16 *stripe_count) { struct lov_mds_md_v3 *lmm; @@ -248,7 +271,7 @@ static int lsm_lmm_verify_v3(struct lov_mds_md *lmmv1, int lmm_bytes, return -EINVAL; } - *stripe_count = le32_to_cpu(lmm->lmm_stripe_count); + *stripe_count = le16_to_cpu(lmm->lmm_stripe_count); if (lmm_bytes < lov_mds_md_size(*stripe_count, LOV_MAGIC_V3)) { CERROR("LOV EA V3 too small: %d, need %d\n", @@ -267,17 +290,21 @@ int lsm_unpackmd_v3(struct lov_obd *lov, struct lov_stripe_md *lsm, struct lov_mds_md_v3 *lmm; struct lov_oinfo *loi; int i; + __u64 stripe_maxbytes = OBD_OBJECT_EOF; + int cplen = 0; lmm = (struct lov_mds_md_v3 *)lmmv1; lsm_unpackmd_common(lsm, (struct lov_mds_md_v1 *)lmm); - strncpy(lsm->lsm_pool_name, lmm->lmm_pool_name, LOV_MAXPOOLNAME); + cplen = strlcpy(lsm->lsm_pool_name, lmm->lmm_pool_name, + sizeof(lsm->lsm_pool_name)); + if (cplen >= sizeof(lsm->lsm_pool_name)) + return -E2BIG; for (i = 0; i < lsm->lsm_stripe_count; i++) { /* 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); - loi->loi_seq = le64_to_cpu(lmm->lmm_objects[i].l_object_seq); + ostid_le_to_cpu(&lmm->lmm_objects[i].l_ost_oi, &loi->loi_oi); loi->loi_ost_idx = le32_to_cpu(lmm->lmm_objects[i].l_ost_idx); loi->loi_ost_gen = le32_to_cpu(lmm->lmm_objects[i].l_ost_gen); if (loi->loi_ost_idx >= lov->desc.ld_tgt_count) { @@ -291,8 +318,13 @@ int lsm_unpackmd_v3(struct lov_obd *lov, struct lov_stripe_md *lsm, lov_dump_lmm_v3(D_WARNING, lmm); return -EINVAL; } + /* calculate the minimum stripe max bytes */ + lov_tgt_maxbytes(lov->lov_tgts[loi->loi_ost_idx], + &stripe_maxbytes); } + lsm->lsm_maxbytes = stripe_maxbytes * lsm->lsm_stripe_count; + return 0; }