From 83f493145e53b804e045eaef23c473ce24cadc28 Mon Sep 17 00:00:00 2001 From: Nathan Hjelm Date: Fri, 10 Jun 2016 13:16:47 -0600 Subject: [PATCH] posix: set default stripe count This commit fixes a bug that occurs when the dataset directory is using the default striping count. In this case the ioctl may return lmm_stripe_count = 0. Since hio assumes a stripe count >= 1 this was triggering a problem when setting up the shared memory segment. To be safe always set the default to 1 (or larger if writing shared files). Signed-off-by: Nathan Hjelm --- src/builtin-posix_component.c | 7 +++++++ src/hio_dataset_shared.c | 4 ++-- src/hio_fs.c | 6 +++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/builtin-posix_component.c b/src/builtin-posix_component.c index 5c1b99a..43727c4 100644 --- a/src/builtin-posix_component.c +++ b/src/builtin-posix_component.c @@ -236,6 +236,13 @@ static int builtin_posix_module_dataset_open (struct hio_module_t *module, hio_d } if (fs_attr->fs_flags & HIO_FS_SUPPORTS_STRIPING) { + if (HIO_SET_ELEMENT_UNIQUE == dataset->ds_mode) { + /* set defaults striping count */ + fs_attr->fs_scount = 1; + } else { + fs_attr->fs_scount = max (1, (unsigned) ((float) fs_attr->fs_smax_count * 0.9)); + } + hioi_config_add (context, &dataset->ds_object, &fs_attr->fs_scount, "stripe_count", HIO_CONFIG_TYPE_UINT32, NULL, "Stripe count for all dataset " "data files", 0); diff --git a/src/hio_dataset_shared.c b/src/hio_dataset_shared.c index 9f227ce..911e0b5 100644 --- a/src/hio_dataset_shared.c +++ b/src/hio_dataset_shared.c @@ -74,7 +74,7 @@ int hioi_dataset_buffer_flush (hio_dataset_t dataset) { int hioi_dataset_shared_init (hio_dataset_t dataset) { hio_context_t context = hioi_object_context (&dataset->ds_object); - int stripes = dataset->ds_fsattr.fs_scount; + int stripes = max (1, dataset->ds_fsattr.fs_scount); size_t ds_buffer_size = 512 * 1024; size_t control_block_size; MPI_Win shared_win; @@ -109,7 +109,7 @@ int hioi_dataset_shared_init (hio_dataset_t dataset) { pthread_mutexattr_setpshared (&mutex_attr, PTHREAD_PROCESS_SHARED); /* fixme - not sure this is the right way to ensure stripe 0 mutex gets init'd */ - for (int i = 0 ; i < max(1, stripes) ; ++i) { + for (int i = 0 ; i < stripes ; ++i) { pthread_mutex_init (&dataset->ds_shared_control->s_stripes[i].s_mutex, &mutex_attr); atomic_init (&dataset->ds_shared_control->s_stripes[i].s_index, 0); } diff --git a/src/hio_fs.c b/src/hio_fs.c index bad2348..35c2dcf 100644 --- a/src/hio_fs.c +++ b/src/hio_fs.c @@ -218,7 +218,7 @@ static int hioi_fs_query_lustre (const char *path, hio_fs_attr_t *fs_attr) { } } - fs_attr->fs_scount = lum->lmm_stripe_count; + fs_attr->fs_scount = lum->lmm_stripe_count ? lum->lmm_stripe_count : 1; fs_attr->fs_ssize = lum->lmm_stripe_size; switch (lum->lmm_pattern) { @@ -276,6 +276,10 @@ int hioi_fs_query (hio_context_t context, const char *path, hio_fs_attr_t *fs_at fs_attr->fs_btotal = fsinfo.f_blocks; fs_attr->fs_bsize = fsinfo.f_bsize; + /* set some reasonable defaults for striping parameters */ + fs_attr->fs_scount = 1; + fs_attr->fs_ssize = fs_attr->fs_bsize; + /* get filesytem specific data */ switch (fsinfo.f_type) { #if defined(LL_SUPER_MAGIC)