-/* -*- 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.
/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
- */
-/*
- * Copyright (c) 2011 Whamcloud, Inc.
+ *
+ * Copyright (c) 2011, 2012, Whamcloud, Inc.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
* Author: Wang Di <wangdi@clusterfs.com>
*/
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
#define DEBUG_SUBSYSTEM S_LOV
#ifdef __KERNEL__
};
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) {
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;
lsm->lsm_oinfo[i] = loi;
}
lsm->lsm_stripe_count = stripe_count;
- lsm->lsm_pool_name[0] = '\0';
return lsm;
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++)
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_layout_gen = le16_to_cpu(lmm->lmm_layout_gen);
lsm->lsm_pool_name[0] = '\0';
}
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)
+ __u16 *stripe_count)
{
if (lmm_bytes < sizeof(*lmm)) {
CERROR("lov_mds_md_v1 too small: %d, need at least %d\n",
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",
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);
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;
};
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;
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",
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);
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;