blob: e1fcee0ac12d527422af1f714db9e61b8ed0eadc (
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
30
31
|
#include "logfsos.h"
#include "logfs.h"
#include "local.h"
long
logfsfindfreeblock(LogfsLowLevel *ll, AllocReason reason)
{
long b;
long total;
b = (*ll->findfreeblock)(ll, &total);
if(b < 0)
return b;
switch(reason) {
case AllocReasonReplace:
break;
case AllocReasonTransfer:
if(total <= Replacements)
return -1;
break;
case AllocReasonLogExtend:
if(total <= Replacements + Transfers)
return -1;
break;
case AllocReasonDataExtend:
if(total <= Replacements + Transfers + LogSlack)
return -1;
break;
}
//print("allocated free block %ld\n", b);
return b;
}
|