aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/patches-4.4/551-ubifs-fix-default-compression-selection.patch
blob: 1b0f30718cf7f5549ce4e98f4e058e11e4a266d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
--- a/fs/ubifs/sb.c
+++ b/fs/ubifs/sb.c
@@ -63,6 +63,17 @@
 /* Default time granularity in nanoseconds */
 #define DEFAULT_TIME_GRAN 1000000000
 
+static int get_default_compressor(void)
+{
+	if (ubifs_compr_present(UBIFS_COMPR_LZO))
+		return UBIFS_COMPR_LZO;
+
+	if (ubifs_compr_present(UBIFS_COMPR_ZLIB))
+		return UBIFS_COMPR_ZLIB;
+
+	return UBIFS_COMPR_NONE;
+}
+
 /**
  * create_default_filesystem - format empty UBI volume.
  * @c: UBIFS file-system description object
@@ -183,7 +194,7 @@ static int create_default_filesystem(str
 	if (c->mount_opts.override_compr)
 		sup->default_compr = cpu_to_le16(c->mount_opts.compr_type);
 	else
-		sup->default_compr = cpu_to_le16(UBIFS_COMPR_LZO);
+		sup->default_compr = cpu_to_le16(get_default_compressor());
 
 	generate_random_uuid(sup->uuid);
 
gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/**CFile****************************************************************

  FileName    [sclBuff.c]

  SystemName  [ABC: Logic synthesis and verification system.]

  PackageName [Standard-cell library representation.]

  Synopsis    [Buffering algorithms.]

  Author      [Alan Mishchenko, Niklas Een]
  
  Affiliation [UC Berkeley]

  Date        [Ver. 1.0. Started - August 24, 2012.]

  Revision    [$Id: sclBuff.c,v 1.0 2012/08/24 00:00:00 alanmi Exp $]

***********************************************************************/

#include "sclSize.h"
#include "map/mio/mio.h"

ABC_NAMESPACE_IMPL_START


////////////////////////////////////////////////////////////////////////
///                        DECLARATIONS                              ///
////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////
///                     FUNCTION DEFINITIONS                         ///
////////////////////////////////////////////////////////////////////////

/**Function*************************************************************

  Synopsis    [Make sure the network is in topo order without dangling nodes.]

  Description [Returns 1 iff the network is fine.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
int Abc_SclCheckNtk( Abc_Ntk_t * p, int fVerbose )
{
    Abc_Obj_t * pObj, * pFanin;
    int i, k, fFlag = 1;
    Abc_NtkIncrementTravId( p );        
    Abc_NtkForEachCi( p, pObj, i )
        Abc_NodeSetTravIdCurrent( pObj );
    Abc_NtkForEachNode( p, pObj, i )
    {
        Abc_ObjForEachFanin( pObj, pFanin, k )
            if ( !Abc_NodeIsTravIdCurrent( pFanin ) )
                printf( "obj %d and its fanin %d are not in the topo order\n", Abc_ObjId(pObj), Abc_ObjId(pFanin) ), fFlag = 0;
        Abc_NodeSetTravIdCurrent( pObj );
        if ( Abc_ObjFanoutNum(pObj) == 0 )
            printf( "node %d has no fanout\n", Abc_ObjId(pObj) ), fFlag = 0;
        if ( !fFlag )
            break;
    }
    if ( fFlag && fVerbose )
        printf( "The network is in topo order and no dangling nodes.\n" );
    return fFlag;
}

/**Function*************************************************************

  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
int Abc_SclCheckNtk2( Abc_Ntk_t * p )
{
    Abc_Obj_t * pObj, * pFanout;
    int i, k;
    Abc_NtkStartReverseLevels( p, 0 );
    Abc_NtkForEachNode( p, pObj, i )
    {
        if ( Abc_ObjFanoutNum(pObj) <= 3 )
            continue;
        printf( "Node %5d (%2d) : fans = %3d  ", i, Abc_ObjLevel(pObj), Abc_ObjFanoutNum(pObj) );
        Abc_ObjForEachFanout( pObj, pFanout, k )
            printf( "%d ", Abc_ObjReverseLevel(pFanout) );
        printf( "\n" );
    }
    return 1;
}

/**Function*************************************************************

  Synopsis    [Performs buffering of the mapped network.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
int Abc_NodeCompareLevels( Abc_Obj_t ** pp1, Abc_Obj_t ** pp2 )
{
    int Diff = Abc_ObjLevel(*pp1) - Abc_ObjLevel(*pp2);
    if ( Diff < 0 )
        return -1;
    if ( Diff > 0 ) 
        return 1;
    Diff = (*pp1)->Id - (*pp2)->Id; // needed to make qsort() platform-infependent
    if ( Diff < 0 )
        return -1;
    if ( Diff > 0 ) 
        return 1;
    return 0; 
}
int Abc_SclComputeReverseLevel( Abc_Obj_t * pObj )
{
    Abc_Obj_t * pFanout;
    int i, Level = 0;
    Abc_ObjForEachFanout( pObj, pFanout, i )
        Level = Abc_MaxInt( Level, pFanout->Level );
    return Level + 1;
}
Abc_Obj_t * Abc_SclPerformBufferingOne( Abc_Obj_t * pObj, int Degree, int fUseInvs, int fVerbose )
{
    Vec_Ptr_t * vFanouts;
    Abc_Obj_t * pBuffer, * pFanout;
    int i, Degree0 = Degree;
    assert( Abc_ObjFanoutNum(pObj) > Degree );
    // collect fanouts and sort by reverse level
    vFanouts = Vec_PtrAlloc( Abc_ObjFanoutNum(pObj) );
    Abc_NodeCollectFanouts( pObj, vFanouts );
    Vec_PtrSort( vFanouts, (int (*)(void))Abc_NodeCompareLevels );
    // select the first Degree fanouts
    if ( fUseInvs )
        pBuffer = Abc_NtkCreateNodeInv( pObj->pNtk, NULL );
    else
        pBuffer = Abc_NtkCreateNodeBuf( pObj->pNtk, NULL );
    // check if it is possible to not increase level
    if ( Vec_PtrSize(vFanouts) < 2 * Degree )
    {
        Abc_Obj_t * pFanPrev = (Abc_Obj_t *)Vec_PtrEntry(vFanouts, Vec_PtrSize(vFanouts)-1-Degree);
        Abc_Obj_t * pFanThis = (Abc_Obj_t *)Vec_PtrEntry(vFanouts, Degree-1);
        Abc_Obj_t * pFanLast = (Abc_Obj_t *)Vec_PtrEntryLast(vFanouts);
        if ( Abc_ObjLevel(pFanThis) == Abc_ObjLevel(pFanLast) &&
             Abc_ObjLevel(pFanPrev) <  Abc_ObjLevel(pFanThis) )
        {
            // find the first one whose level is the same as last
            Vec_PtrForEachEntry( Abc_Obj_t *, vFanouts, pFanout, i )
                if ( Abc_ObjLevel(pFanout) == Abc_ObjLevel(pFanLast) )
                    break;
            assert( i < Vec_PtrSize(vFanouts) );
            if ( i > 1 )
                Degree = i;
        }
        // make the last two more well-balanced
        if ( Degree == Degree0 && Degree > Vec_PtrSize(vFanouts) - Degree )
            Degree = Vec_PtrSize(vFanouts)/2 + (Vec_PtrSize(vFanouts) & 1);
        assert( Degree <= Degree0 );
    }
    // select fanouts
    Vec_PtrForEachEntryStop( Abc_Obj_t *, vFanouts, pFanout, i, Degree )
        Abc_ObjPatchFanin( pFanout, pObj, pBuffer );
    if ( fVerbose )
    {
        printf( "%5d : ", Abc_ObjId(pObj) );
        Vec_PtrForEachEntry( Abc_Obj_t *, vFanouts, pFanout, i )
            printf( "%d%s ", Abc_ObjLevel(pFanout), i == Degree-1 ? "  " : "" );
        printf( "\n" );
    }
    Vec_PtrFree( vFanouts );
    Abc_ObjAddFanin( pBuffer, pObj );
    pBuffer->Level = Abc_SclComputeReverseLevel( pBuffer );
    return pBuffer;
}
void Abc_SclPerformBuffering_rec( Abc_Obj_t * pObj, int Degree, int fUseInvs, int fVerbose )
{
    Abc_Obj_t * pFanout;
    int i;
    if ( Abc_NodeIsTravIdCurrent( pObj ) )
        return;
    Abc_NodeSetTravIdCurrent( pObj );
    pObj->Level = 0;
    if ( Abc_ObjIsCo(pObj) )
        return;
    assert( Abc_ObjIsCi(pObj) || Abc_ObjIsNode(pObj) );
    // buffer fanouts and collect reverse levels
    Abc_ObjForEachFanout( pObj, pFanout, i )
        Abc_SclPerformBuffering_rec( pFanout, Degree, fUseInvs, fVerbose );
    // perform buffering as long as needed
    while ( Abc_ObjFanoutNum(pObj) > Degree )
        Abc_SclPerformBufferingOne( pObj, Degree, fUseInvs, fVerbose );
    // compute the new level of the node
    pObj->Level = Abc_SclComputeReverseLevel( pObj );
}
Abc_Ntk_t * Abc_SclPerformBuffering( Abc_Ntk_t * p, int Degree, int fUseInvs, int fVerbose )
{
    Vec_Int_t * vCiLevs;
    Abc_Ntk_t * pNew;
    Abc_Obj_t * pObj;
    int i;
    assert( Abc_NtkHasMapping(p) );
    if ( fUseInvs )
        printf( "Warning!!! Using inverters instead of buffers.\n" );
    // remember CI levels
    vCiLevs = Vec_IntAlloc( Abc_NtkCiNum(p) );
    Abc_NtkForEachCi( p, pObj, i )
        Vec_IntPush( vCiLevs, Abc_ObjLevel(pObj) );
    // perform buffering
    Abc_NtkIncrementTravId( p );        
    Abc_NtkForEachCi( p, pObj, i )
        Abc_SclPerformBuffering_rec( pObj, Degree, fUseInvs, fVerbose );
    // recompute logic levels
    Abc_NtkForEachCi( p, pObj, i )
        pObj->Level = Vec_IntEntry( vCiLevs, i );
    Abc_NtkForEachNode( p, pObj, i )
        Abc_ObjLevelNew( pObj );
    Vec_IntFree( vCiLevs );
    // duplication in topo order
    pNew = Abc_NtkDupDfs( p );
    Abc_SclCheckNtk( pNew, fVerbose );
//    Abc_NtkDelete( pNew );
    return pNew;
}

////////////////////////////////////////////////////////////////////////
///                       END OF FILE                                ///
////////////////////////////////////////////////////////////////////////


ABC_NAMESPACE_IMPL_END