#include <uapi/linux/lustre/lustre_param.h>
#include <lustre_update.h>
#include <lustre_log.h>
+#include <lustre_lmv.h>
#include "lod_internal.h"
RETURN(rc);
}
+/**
+ * Implementation of lu_device_operations::ldo_fid_alloc() for LOD
+ *
+ * Find corresponding device by passed parent and name, and allocate FID from
+ * there.
+ *
+ * see include/lu_object.h for the details.
+ */
+static int lod_fid_alloc(const struct lu_env *env, struct lu_device *d,
+ struct lu_fid *fid, struct lu_object *parent,
+ const struct lu_name *name)
+{
+ struct lod_device *lod = lu2lod_dev(d);
+ struct lod_object *lo = lu2lod_obj(parent);
+ struct dt_device *next;
+ int rc;
+
+ ENTRY;
+
+ /* if @parent is remote, we don't know whether its layout was changed,
+ * always reload layout.
+ */
+ if (lu_object_remote(parent))
+ lod_striping_free(env, lo);
+
+ rc = lod_striping_load(env, lo);
+ if (rc)
+ RETURN(rc);
+
+ if (lo->ldo_dir_stripe_count > 0 && name) {
+ struct dt_object *stripe;
+ int idx;
+
+ idx = __lmv_name_to_stripe_index(lo->ldo_dir_hash_type,
+ lo->ldo_dir_stripe_count,
+ lo->ldo_dir_migrate_hash,
+ lo->ldo_dir_migrate_offset,
+ name->ln_name,
+ name->ln_namelen, true);
+ if (idx < 0)
+ RETURN(idx);
+
+ stripe = lo->ldo_stripe[idx];
+ if (!stripe || !dt_object_exists(stripe))
+ RETURN(-ENODEV);
+
+ next = lu2dt_dev(stripe->do_lu.lo_dev);
+ } else {
+ next = lod->lod_child;
+ }
+
+ rc = dt_fid_alloc(env, next, fid, parent, name);
+
+ RETURN(rc);
+}
+
const struct lu_device_operations lod_lu_ops = {
.ldo_object_alloc = lod_object_alloc,
.ldo_process_config = lod_process_config,
.ldo_recovery_complete = lod_recovery_complete,
.ldo_prepare = lod_prepare,
+ .ldo_fid_alloc = lod_fid_alloc,
};
/**
(int)sfs->os_bsize, (int)ost_sfs.os_bsize);
}
lod_putref(lod, &lod->lod_ost_descs);
- sfs->os_state |= OS_STATE_SUM;
+ sfs->os_state |= OS_STATFS_SUM;
/* If we have _some_ OSTs, but don't have as many free objects on the
* OSTs as inodes on the MDTs, reduce the reported number of inodes
RETURN(rc);
}
+static int lod_lsfs_init(const struct lu_env *env, struct lod_device *d)
+{
+ struct obd_statfs sfs;
+ int rc;
+
+ rc = dt_statfs(env, d->lod_child, &sfs);
+ if (rc) {
+ CDEBUG(D_LAYOUT, "%s: failed to get OSD statfs, rc = %d\n",
+ lod2obd(d)->obd_name, rc);
+ return rc;
+ }
+
+ /* udpate local OSD cached statfs data */
+ spin_lock_init(&d->lod_lsfs_lock);
+ d->lod_lsfs_age = ktime_get_seconds();
+ d->lod_lsfs_total_mb = (sfs.os_blocks * sfs.os_bsize) >> 20;
+ d->lod_lsfs_free_mb = (sfs.os_bfree * sfs.os_bsize) >> 20;
+ return 0;
+}
+
/**
* Initialize LOD device at setup.
*
dt_conf_get(env, &lod->lod_dt_dev, &ddp);
lod->lod_osd_max_easize = ddp.ddp_max_ea_size;
- lod->lod_dom_max_stripesize = (1ULL << 20); /* 1Mb as default value */
+ lod->lod_dom_stripesize_max_kb = (1ULL << 10); /* 1Mb is default */
+
+ /* initialize local statfs cached values */
+ rc = lod_lsfs_init(env, lod);
+ if (rc)
+ GOTO(out_disconnect, rc);
+
+ /* default threshold as half of total space, in MiB */
+ lod->lod_dom_threshold_free_mb = lod->lod_lsfs_total_mb / 2;
+ /* set default DoM stripe size based on free space amount */
+ lod_dom_stripesize_recalc(lod);
/* setup obd to be used with old lov code */
rc = lod_pools_init(lod, cfg);
ENTRY;
- if (atomic_read(&lu->ld_ref) > 0 &&
- !cfs_hash_is_empty(lu->ld_site->ls_obj_hash)) {
- LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_ERROR, NULL);
- lu_site_print(env, lu->ld_site, &msgdata, lu_cdebug_printer);
+ if (atomic_read(&lu->ld_site->ls_obj_hash.nelems)) {
+ lu_site_print(env, lu->ld_site, &lu->ld_ref, D_ERROR,
+ lu_cdebug_printer);
}
LASSERTF(atomic_read(&lu->ld_ref) == 0, "lu is %p\n", lu);
dt_device_fini(&lod->lod_dt_dev);
static void lod_avoid_guide_fini(struct lod_avoid_guide *lag)
{
if (lag->lag_oss_avoid_array)
- OBD_FREE(lag->lag_oss_avoid_array,
- sizeof(u32) * lag->lag_oaa_size);
- if (lag->lag_ost_avoid_bitmap)
- CFS_FREE_BITMAP(lag->lag_ost_avoid_bitmap);
+ OBD_FREE_PTR_ARRAY(lag->lag_oss_avoid_array,
+ lag->lag_oaa_size);
+ bitmap_free(lag->lag_ost_avoid_bitmap);
}
/**
lod_free_def_comp_entries(&info->lti_def_striping);
if (info->lti_comp_size > 0)
- OBD_FREE(info->lti_comp_idx,
- info->lti_comp_size * sizeof(u32));
+ OBD_FREE_PTR_ARRAY(info->lti_comp_idx,
+ info->lti_comp_size);
lod_avoid_guide_fini(&info->lti_avoid);