예제 #1
0
void test17(void)
{
	int rc;
	int fd;
	int osts_all;
	uint64_t osts_layout;
	struct llapi_layout *layout;
	char path[PATH_MAX];

	snprintf(path, sizeof(path), "%s/%s", lustre_dir, T17FILE);

	rc = unlink(path);
	ASSERTF(rc == 0 || errno == ENOENT, "errno = %d", errno);
	layout = llapi_layout_alloc();
	ASSERTF(layout != NULL, "errno = %d", errno);
	rc = llapi_layout_stripe_count_set(layout, LLAPI_LAYOUT_WIDE);
	ASSERTF(rc == 0, "errno = %d", errno);
	fd = llapi_layout_file_create(path, 0, 0640, layout);
	ASSERTF(fd >= 0, "errno = %d", errno);
	rc = close(fd);
	ASSERTF(rc == 0, "errno = %d", errno);
	llapi_layout_free(layout);

	/* Get number of available OSTs */
	fd = open(path, O_RDONLY);
	ASSERTF(fd >= 0, "errno = %d", errno);
	rc = llapi_lov_get_uuids(fd, NULL, &osts_all);
	ASSERTF(rc == 0, "rc = %d, errno = %d", rc, errno);
	rc = close(fd);
	ASSERTF(rc == 0, "errno = %d", errno);

	layout = llapi_layout_get_by_path(path, 0);
	ASSERTF(layout != NULL, "errno = %d", errno);
	rc = llapi_layout_stripe_count_get(layout, &osts_layout);
	ASSERTF(osts_layout == osts_all, "%"PRIu64" != %d", osts_layout,
		osts_all);

	llapi_layout_free(layout);
}
예제 #2
0
static int hioi_fs_query_lustre (const char *path, hio_fs_attr_t *fs_attr) {
  struct lov_user_md *lum;
  struct find_param param;
  char mountdir[PATH_MAX];
  int rc, fd, obd_count;

  rc = llapi_search_mounts (path, 0, mountdir, NULL);
  if (0 != rc) {
    return hioi_err_errno (-rc);
  }

#if !HAVE_LLAPI_GET_OBD_COUNT
  fd = open (mountdir, O_RDONLY);
  if (-1 == fd) {
    return hioi_err_errno (errno);
  }

  rc = llapi_lov_get_uuids (fd, NULL, &obd_count);
  close (fd);
#else
  rc = llapi_get_obd_count (mountdir, &obd_count, 0);
#endif

  if (0 != rc) {
    return hioi_err_errno (errno);
  }

  fs_attr->fs_flags |= HIO_FS_SUPPORTS_STRIPING | HIO_FS_SUPPORTS_RAID;
  fs_attr->fs_type        = HIO_FS_TYPE_LUSTRE;
  fs_attr->fs_sunit       = 64 * 1024;
  fs_attr->fs_smax_size   = 0x100000000ul;
  fs_attr->fs_smax_count  = obd_count;

  lum = hioi_alloc_lustre_data ();
  assert (NULL != lum);

  rc = llapi_file_get_stripe (path, lum);
  if (0 != rc) {
    /* assuming this is a directory try reading the default for the directory. this
     * should be updated to check the parent directory if path is a file. */
    fd = open (path, O_RDONLY);
    if (-1 == fd) {
      free (lum);
      return hioi_err_errno (errno);
    }

    rc = ioctl (fd, LL_IOC_LOV_GETSTRIPE, lum);
    close (fd);
    if (0 > rc) {
      free (lum);
      return hioi_err_errno (errno);
    }
  }

  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) {
  case LOV_PATTERN_RAID0:
    fs_attr->fs_raid_level = 0;
    break;
#if defined(LOV_PATTERN_RAID1)
  case LOV_PATTERN_RAID1:
    fs_attr->fs_raid_level = 1;
    break;
#endif
  default:
    fs_attr->fs_raid_level = -1;
    break;
  }

  free (lum);

  return HIO_SUCCESS;
}