Beispiel #1
0
int ShookRecoverById(const entry_id_t *p_id, file_status_t *p_status)
{
    int rc;
    shook_state st;

    rc = shook_recov_pending(get_fsname(), p_id, &st, 0);
    if (rc < 0)
        return rc;

    *p_status = shook2rbh_status(st);
    if (*p_status == (file_status_t)-1) {
        DisplayLog(LVL_CRIT, SHOOK_TAG,
                   "ERROR getting recovering " DFID ": unknown status %d",
                   PFID(p_id), (int)st);
        return -EINVAL;
    }
    return 0;
}
Beispiel #2
0
/** Retrieve pool usage info
 *  @return 0 on success
 */
int Get_pool_usage( const char *poolname, struct statfs *pool_statfs )
{
    struct statfs  ost_statfs;
    int            rc, i, count;
    char           pool[LOV_MAXPOOLNAME + 10];
#ifdef FIND_MAX_OSTS
    char          *ostlist[FIND_MAX_OSTS];
    char           buffer[4096];
#else /* no max OST count since Lustre 2.2 */
    unsigned int obdcount = 256;
    char        **ostlist = NULL;
    int          bufsize = sizeof(struct obd_uuid) * obdcount;
    char *buffer = MemAlloc(bufsize + (sizeof(*ostlist) * obdcount));
    ostlist = (char **)(buffer + bufsize);

    /* sanity check */
    if (!pool_statfs)
    {
        MemFree(buffer);
        return EFAULT;
    }
#endif

    memset( pool_statfs, 0, sizeof( struct statfs ) );

    /* retrieve list of OSTs in the pool */
    sprintf( pool, "%s.%s", get_fsname(), poolname );
#ifdef FIND_MAX_OSTS
    rc = llapi_get_poolmembers(pool, ostlist, FIND_MAX_OSTS, buffer, 4096);
#else
    do {
        rc = llapi_get_poolmembers(pool, ostlist, obdcount, buffer, bufsize);
        if (rc == -EOVERFLOW)
        {
            /* buffer too small, increase obdcount by 2 */
            obdcount *= 2;
            bufsize = sizeof(struct obd_uuid) * obdcount;
            buffer = MemRealloc(buffer, bufsize + (sizeof(*ostlist) * obdcount));
            if (buffer == NULL)
                return ENOMEM;
            ostlist = (char **)(buffer + bufsize);
        }
    } while (rc == -EOVERFLOW);
#endif

    if ( rc < 0 )
        return -rc;

    count = rc;

    /* get OST info and sum them */
    for ( i = 0; i < count; i++ )
    {
        char          *ost;
        int            index;
        /* get ost index in <fsname>-OST<index>_UUID */
        ost = strrchr( ostlist[i], '-' );
        if ( !ost )
        {
            DisplayLog( LVL_CRIT, TAG_POOLDF, "Invalid OST format: '%s'", ostlist[i] );
            return EINVAL;
        }

        /* skip '-' */
        ost++;
        if ( sscanf( ost, "OST%d", &index ) != 1 )
        {
            DisplayLog( LVL_CRIT, TAG_POOLDF, "Could not find OST index in"
                        " string '%s'", ost );
            return EINVAL;
        }

        rc = Get_OST_usage( get_mount_point(NULL), index, &ost_statfs );
        if ( rc )
            return rc;

        /* sum info to struct statfs */
        pool_statfs->f_blocks += ost_statfs.f_blocks;
        pool_statfs->f_bfree += ost_statfs.f_bfree;
        pool_statfs->f_bavail += ost_statfs.f_bavail;
        pool_statfs->f_bsize = ost_statfs.f_bsize;
    }

    return 0;
}