Beispiel #1
0
int EntryProc_get_attr( struct entry_proc_op_t *p_op, lmgr_t * p_lmgr )
#endif
{
    int            rc;
    entry_id_t     id;
    const pipeline_stage_t *stage_info = &entry_proc_pipeline[p_op->pipeline_stage];

    /* set id */
#ifdef _HAVE_FID
    id.f_seq = myrand( 1000 );
    id.f_oid = myrand( 1000 );
    id.f_ver = p_op->extra_info.log_record.record_id;
#else
    id.device = myrand( 1000 );
    id.inode = myrand( 1000 );
#endif
    EntryProcessor_SetEntryId( p_op, &id );

#ifdef DEBUG
    printf( "stage %s - record #%u - id=[%llu,%u] - thread %lx\n",
            stage_info->stage_name, ( unsigned int ) p_op->entry_id.f_ver,
            p_op->entry_id.f_seq, p_op->entry_id.f_oid, pthread_self(  ) );

    EntryProcessor_DumpCurrentStages(  );
#endif

    /* acknowledge */
    rc = EntryProcessor_Acknowledge( p_op, p_op->pipeline_stage + 1, FALSE );
    if ( rc )
        printf( "Error acknowledging stage %s\n", stage_info->stage_name );

    /* if processing is async, simulate a long operation */
    if ( stage_info->stage_flags & STAGE_FLAG_ASYNC )
    {
        /* do this for 1 entry out of 1000 */
        if ( myrand( 1000 ) == 0 )
        {
            usleep( 10000 );
            DisplayLog( LVL_DEBUG, "CheckExist", "End of async processing for stage %s",
                        stage_info->stage_name );
        }
    }

    return 0;
}
Beispiel #2
0
/**
 * For entries from FS scan, we must get the associated entry ID.
 */
int EntryProc_get_fid( struct entry_proc_op_t *p_op, lmgr_t * lmgr )
{
#ifdef _HAVE_FID
    int            rc;
    entry_id_t     tmp_id;
    char buff[RBH_PATH_MAX];
    char * path;

    /* 2 possible options: get fid using parent_fid/name or from fullpath */
    if (ATTR_MASK_TEST(&p_op->fs_attrs, parent_id)
        && ATTR_MASK_TEST(&p_op->fs_attrs, name))
    {
        BuildFidPath( &ATTR(&p_op->fs_attrs, parent_id), buff );
        long len = strlen(buff);
        sprintf(buff+len, "/%s", ATTR(&p_op->fs_attrs, name));
        path = buff;
    }
    else if (ATTR_MASK_TEST( &p_op->fs_attrs, fullpath))
    {
        path = ATTR(&p_op->fs_attrs, fullpath);
    }
    else
    {
        DisplayLog( LVL_CRIT, ENTRYPROC_TAG,
                    "Error: not enough information to get fid: parent_id/name or fullpath needed");
        EntryProcessor_Acknowledge(p_op, -1, true);
        return EINVAL;
    }

    /* perform path2fid */
    rc = Lustre_GetFidFromPath( path, &tmp_id );

    /* Workaround for Lustre 2.3: if parent is root, llapi_path2fid returns EINVAL (see LU-3245).
     * In this case, get fid from full path.
     */
    if ((rc == -EINVAL) && ATTR_MASK_TEST( &p_op->fs_attrs, fullpath))
    {
        path = ATTR(&p_op->fs_attrs, fullpath);
        rc =  Lustre_GetFidFromPath( path, &tmp_id );
    }

    if ( rc )
    {
        /* remove the operation from pipeline */
        rc = EntryProcessor_Acknowledge(p_op, -1, true);
        if ( rc )
            DisplayLog( LVL_CRIT, ENTRYPROC_TAG,
                        "Error %d acknowledging stage STAGE_GET_FID.", rc );
    }
    else
    {
        EntryProcessor_SetEntryId( p_op, &tmp_id );

        /* go to GET_INFO_DB stage */
        rc = EntryProcessor_Acknowledge(p_op, STAGE_GET_INFO_DB, false);
        if ( rc )
            DisplayLog( LVL_CRIT, ENTRYPROC_TAG,
                        "Error %d acknowledging stage STAGE_GET_FID.", rc );
    }
    return rc;
#else
    DisplayLog( LVL_CRIT, ENTRYPROC_TAG, "Error: unexpected stage in a filesystem with no fid: STAGE_GET_FID.");
    EntryProcessor_Acknowledge(p_op, -1, true);
    return EINVAL;
#endif
}