Blog

Simply put: something I do, read, care about and hopefully might interest somebody else too.

Test: BtrFS, Ext4, Ntfs - Simple file allocation tests

posted Feb 13, 2012 9:01 AM by Sami Lehtinen   [ updated Feb 13, 2012 9:55 AM ]

I did some simple file system file allocation comparison. How files are allocated when allocation happens differently. I did this just for fun. Results are quite interesting. Especially if you don't have time or will to repeat tests.

Initialization:
I1: I formatted multiple 100 gigabyte volumes systems, one using ext4, one using ntfs and one using ntfs.
I2: I copied about 300k randomly sized files to file system, totalling about 6.9 gigabytes.

Tests:
T1: Copied 3.1 gigabyte file to volume. Final size was known and therefore pre-allocation could be used.
T2: Quickly created same file, final size unknown to system (pre-allocation unavailable), file allocated when it grows quickly. (about 80Mbytes/s)
T3: Slowly created same file, final size unknown to system (pre-allocation unavailable), file allocated when it grows slowly. (about 2Mbytes/s)

Results for BtrFS:
B1: Excellent result, 7 extents.
B2: Strange result, 46 extents, which some are very small.
B3: Very strange result, 531 extens, which almost 1/3rd contain only 1 block.

Results for Ext4:
E1: Excellent result, 29 extents. Please note that Ext4 got maximum extent size limit, only three of extents (excluding last one) are smaller than maximum.
E2: Very good result, 37 extents.
E3: Excellent result, 29 extents.

Results for Ntfs:
N1: Perfect results, 1 contiguous file.
N2: Skipped.
N3: Bad result, 5063 fragments. 614 kilobytes/fragment and for comparison it makes about 157 blocks(clusters)/fragment.

Conclusions:

Ext4 is very good what comes to avoiding fragmentation in general.
BtrFS still got clear delayed allocation flaws, slow allocation is actually quite bad.
NTFS, it behaves just it has behaved in all of my previous tests. When using pre-allocation results are perfect and with growing files, data is scattered all over disk.

Notes:
NTFS allocation was done using 64bit Windows 7, not Linux NTFS allocator, so can't claim that it's just Linux NTFS allocator that would cause fragmentation.
There was plenty of free disk space during these tests. It really outlines how bad BtrFS is now with slow allocation.
Same file content was used for all tests. BtrFS supports zlib and lzo. Also file content was already compressed using LZMA2.
If you want to use exactly same files for similar tests, I do have deliverable as one large bittorrent file.

Here's more detailed results if you're really interested.

BtrFS copy allocation:
File size of copy is 3342903522 (816139 blocks, blocksize 4096)
 ext logical physical expected length flags
   0       0  3900207           40720
   1   40720  4086804  3940926  34784
   2   75504  4070400  4121587   2640
   3   78144  4157441  4073039 147936
   4  226080  4332544  4305376 248784
   5  474864  4594688  4581327 232448
   6  707312  4856832  4827135 108827 eof
copy: 7 extents found

BtrFS fast allocation:
File size of fast is 3342903522 (816139 blocks, blocksize 4096)
 ext logical physical expected length flags
   0       0  4957187               1
   1       1  4965660  4957187  77887
   2   77888  4856832  5043546  70688
   3  148576  4927521  4927519    480
   4  149056  4957186  4928000      1
   5  149057  4928002  4957186  29183
   6  178240  5043548  4957184   9696
   7  187936  5053245  5053243  40512
   8  228448  5093758  5093756   2048
   9  230496  3900207  5095805  44449
  10  274945  3958348  3944655  18047
  11  292992  4007289  3976394  29440
  12  322432  4037177  4036728  18880
  13  341312  4003250  4056056   3232
  14  344544  3977514  4006481   6176
  15  350720  3976396  3983689    320
  16  351040  3977502  3976715      1
  17  351041  3976717  3977502    671
  18  351712  3983690  3977387    193
  19  351905  3977388  3983882     31
  20  351936  3983883  3977418   1248
  21  353184  3985132  3985130    960
  22  354144  3991493  3986091      1
  23  354145  3986093  3991493   1823
  24  355968  3991494  3987915   5184
  25  361152  3987917  3996677   2112
  26  363264  3977419  3990028     32
  27  363296  3977503  3977450      1
  28  363297  4056058  3977503  13343
  29  376640  4467752  4069400  21184
  30  397824  4520448  4488935  10016
  31  407840  4538961  4530463  22400
  32  430240  4594688  4561360  12672
  33  442912  4638793  4607359  22432
  34  465344  4661226  4661224   5632
  35  470976  4703499  4666857  44160
  36  515136  4797420  4747658  15968
  37  531104  5118976  4813387  41280
  38  572384  5160257  5160255  20768
  39  593152  5181026  5181024  66656
  40  659808  5310731  5247681      1
  41  659809  5283659  5310731  17855
  42  677664  5301515  5301513   9216
  43  686880  5322247  5310730  58432
  44  745312  5381120  5380678  48768
  45  794080  5429889  5429887  22059 eof
fast: 46 extents found

BtrFS slow allocation:
File size of slow is 3342903522 (816139 blocks, blocksize 4096)
 ext logical physical expected length flags
   0       0  2294997               1
   1       1  2255636  2294997    463
   2     464  2256100  2256098    128
   3     592  2257205  2256227      1
   4     593  2256229  2257205    367
   5     960  2257206  2256595      1
   6     961  2256597  2257206    319
   7    1280  2257207  2256915      1
   8    1281  2256917  2257207    287
   9    1568  2257208  2257203     64
  10    1632  2273468  2257271      1
  11    1633  2257273  2273468    335
  12    1968  2273469  2257607      1
  13    1969  2257609  2273469    287
  14    2256  2273470  2257895      1
  15    2257  2257897  2273470    335
  16    2592  2296777  2258231      1
  17    2593  2258233  2296777    287
  18    2880  2296778  2258519      1
  19    2881  2258521  2296778    287
  20    3168  2273289  2258807      1
  21    3169  2258809  2273289    287
  22    3456  2273290  2259095      1
  23    3457  2259097  2273290    287
  24    3744  2273291  2259383      1
  25    3745  2259385  2273291    287
  26    4032  2273292  2259671      1
  27    4033  2259673  2273292    303
  28    4336  2273293  2259975      1
  29    4337  2259977  2273293    303
  30    4640  2273294  2260279      1
  31    4641  2260281  2273294    287
  32    4928  2273295  2260567      1
  33    4929  2260569  2273295    271
  34    5200  2273296  2260839      1
  35    5201  2260841  2273296    303
  36    5504  2273297  2261143      1
  37    5505  2261145  2273297    255
  38    5760  2273298  2261399      1
  39    5761  2261401  2273298    255
  40    6016  2273299  2261655      1
  41    6017  2261657  2273299    271
  42    6288  2273300  2261927      1
  43    6289  2261929  2273300    287
  44    6576  2273301  2262215      1
  45    6577  2262217  2273301    255
  46    6832  2273302  2262471      1
  47    6833  2262473  2273302    271
  48    7104  2273303  2262743      1
  49    7105  2262745  2273303    287
  50    7392  2273304  2263031      1
  51    7393  2263033  2273304    271
  52    7664  2273305  2263303      1
  53    7665  2263305  2273305    287
  54    7952  2273306  2263591      1
  55    7953  2263593  2273306    271
  56    8224  2273307  2263863      1
  57    8225  2263865  2273307    271
  58    8496  2273308  2264135      1
  59    8497  2264137  2273308    287
  60    8784  2273309  2264423      1
  61    8785  2264425  2273309    255
  62    9040  2273310  2264679      1
  63    9041  2264681  2273310    287
  64    9328  2273311  2264967      1
  65    9329  2264969  2273311    303
  66    9632  2273312  2265271      1
  67    9633  2265273  2273312    271
  68    9904  2273313  2265543      1
  69    9905  2265545  2273313    271
  70   10176  2273314  2265815      1
  71   10177  2265817  2273314    287
  72   10464  2273315  2266103      1
  73   10465  2266105  2273315    271
  74   10736  2273316  2266375      1
  75   10737  2266377  2273316    271
  76   11008  2273317  2266647      1
  77   11009  2266649  2273317    271
  78   11280  2273318  2266919      1
  79   11281  2266921  2273318    271
  80   11552  2273319  2267191      1
  81   11553  2267193  2273319    271
  82   11824  2273320  2267463      1
  83   11825  2267465  2273320    287
  84   12112  2273321  2267751      1
  85   12113  2267753  2273321    287
  86   12400  2273322  2268039      1
  87   12401  2268041  2273322    303
  88   12704  2273323  2268343      1
  89   12705  2268345  2273323    271
  90   12976  2273324  2268615      1
  91   12977  2268617  2273324    223
  92   13200  2273325  2268839      1
  93   13201  2268841  2273325    255
  94   13456  2273326  2269095      1
  95   13457  2269097  2273326    255
  96   13712  2273327  2269351      1
  97   13713  2269353  2273327    271
  98   13984  2273328  2269623      1
  99   13985  2269625  2273328    287
 100   14272  2273329  2269911      1
 101   14273  2269913  2273329    271
 102   14544  2273330  2270183      1
 103   14545  2270185  2273330    271
 104   14816  2273331  2270455      1
 105   14817  2270457  2273331    319
 106   15136  2273332  2270775      1
 107   15137  2270777  2273332    271
 108   15408  2273333  2271047      1
 109   15409  2271049  2273333    271
 110   15680  2273334  2271319      1
 111   15681  2271321  2273334    287
 112   15968  2273335  2271607      1
 113   15969  2271609  2273335    287
 114   16256  2273336  2271895      1
 115   16257  2271897  2273336    239
 116   16496  2273337  2272135      1
 117   16497  2272137  2273337    303
 118   16800  2273338  2272439      1
 119   16801  2272441  2273338    287
 120   17088  2273339  2272727      1
 121   17089  2272729  2273339    287
 122   17376  2273340  2273015      1
 123   17377  2273017  2273340    271
 124   17648  2273341  2273287      1
 125   17649  2273471  2273341    287
 126   17936  2273342  2273757      1
 127   17937  2273759  2273342    303
 128   18240  2273343  2274061      1
 129   18241  2274063  2273343    271
 130   18512  2273344  2274333      1
 131   18513  2274335  2273344    255
 132   18768  2274591  2274589    160
 133   18928  2274752  2274750    144
 134   19072  2273345  2274895      1
 135   19073  2274897  2273345    319
 136   19392  2273346  2275215      1
 137   19393  2275217  2273346    287
 138   19680  2273347  2275503      1
 139   19681  2275505  2273347    303
 140   19984  2273348  2275807      1
 141   19985  2275809  2273348    271
 142   20256  2273349  2276079      1
 143   20257  2276081  2273349    287
 144   20544  2273350  2276367      1
 145   20545  2276369  2273350    287
 146   20832  2273351  2276655      1
 147   20833  2276657  2273351    271
 148   21104  2273352  2276927      1
 149   21105  2276929  2273352    303
 150   21408  2273353  2277231      1
 151   21409  2277233  2273353    271
 152   21680  2273354  2277503      1
 153   21681  2277505  2273354    255
 154   21936  2273355  2277759      1
 155   21937  2277761  2273355    255
 156   22192  2273356  2278015      1
 157   22193  2278017  2273356    431
 158   22624  2273357  2278447     16
 159   22640  2273374  2273372      1
 160   22641  2278449  2273374    207
 161   22848  2273375  2278655      1
 162   22849  2278657  2273375   1023
 163   23872  2279681  2279679    352
 164   24224  2273376  2280032     48
 165   24272  2273425  2273423      1
 166   24273  2280034  2273425    303
 167   24576  2273426  2280336      1
 168   24577  2280338  2273426    271
 169   24848  2273427  2280608      1
 170   24849  2280610  2273427    255
 171   25104  2273428  2280864      1
 172   25105  2280866  2273428    271
 173   25376  2273429  2281136      1
 174   25377  2281138  2273429    271
 175   25648  2273430  2281408      1
 176   25649  2281410  2273430    287
 177   25936  2273431  2281696      1
 178   25937  2281698  2273431    271
 179   26208  2273432  2281968      1
 180   26209  2281970  2273432    287
 181   26496  2273433  2282256      1
 182   26497  2282258  2273433    639
 183   27136  2273434  2282896      1
 184   27137  2282898  2273434    287
 185   27424  2273435  2283184      1
 186   27425  2283186  2273435    303
 187   27728  2273436  2283488      1
 188   27729  2283490  2273436    255
 189   27984  2273437  2283744      1
 190   27985  2283746  2273437    223
 191   28208  2273438  2283968      1
 192   28209  2283970  2273438    175
 193   28384  2273439  2284144      1
 194   28385  2284146  2273439    191
 195   28576  2273440  2284336      1
 196   28577  2284338  2273440    191
 197   28768  2273441  2284528      1
 198   28769  2284530  2273441    207
 199   28976  2273442  2284736      1
 200   28977  2284738  2273442    175
 201   29152  2273443  2284912     16
 202   29168  2284914  2273458     32
 203   29200  2284947  2284945     48
 204   29248  2273460  2284994      1
 205   29249  2284996  2273460    191
 206   29440  2273461  2285186      1
 207   29441  2285188  2273461    255
 208   29696  2273462  2285442      1
 209   29697  2285444  2273462    255
 210   29952  2273463  2285698      1
 211   29953  2285700  2273463    223
 212   30176  2273464  2285922      1
 213   30177  2285924  2273464    255
 214   30432  2273465  2286178      1
 215   30433  2286180  2273465    255
 216   30688  2273466  2286434      1
 217   30689  2286436  2273466   3279
 218   33968  2289716  2289714   5280
 219   39248  2273467  2294995      1
 220   39249  2296779  2273467   4207
 221   43456  2300987  2300985   3664
 222   47120  2317067  2304650      1
 223   47121  2304652  2317067   3775
 224   50896  2308428  2308426   4032
 225   54928  2317068  2312459      1
 226   54929  2312461  2317068   3903
 227   58832  2317070  2316363   4112
 228   62944  2316365  2321181      1
 229   62945  2321183  2316365   4127
 230   67072  2325311  2325309   3984
 231   71056  2316366  2329294      1
 232   71057  2329296  2316366   3983
 233   75040  2333280  2333278   3840
 234   78880  2316367  2337119      1
 235   78881  2337121  2316367   3919
 236   82800  2344050  2341039   4032
 237   86832  2363669  2348081      1
 238   86833  2348083  2363669   3791
 239   90624  2351875  2351873   3872
 240   94496  2341041  2355746      1
 241   94497  2355748  2341041   3839
 242   98336  2363670  2359586   4160
 243  102496  2341042  2367829      1
 244  102497  2367831  2341042   4271
 245  106768  2372103  2372101   4352
 246  111120  2380662  2376454      1
 247  111121  2376456  2380662   3887
 248  115008  2380665  2380342   3984
 249  118992  2397106  2384648      1
 250  118993  2384650  2397106   3711
 251  122704  2388362  2388360   3984
 252  126688  2397107  2392345      1
 253  126689  2392347  2397107   3791
 254  130480  2397110  2396137   3840
 255  134320  2380344  2400949      1
 256  134321  2400951  2380344   3999
 257  138320  2406842  2404949   4016
 258  142336  2419383  2410857      1
 259  142337  2410859  2419383   4031
 260  146368  2414891  2414889   3888
 261  150256  2419384  2418778      1
 262  150257  2419386  2419384   3823
 263  154080  2423210  2423208   4032
 264  158112  2404951  2427241      1
 265  158113  2427243  2404951   3903
 266  162016  2431147  2431145   4016
 267  166032  2404952  2435162      1
 268  166033  2438119  2404952   3615
 269  169648  2441735  2441733   4160
 270  173808  2453941  2445894      1
 271  173809  2445896  2453941   4063
 272  177872  2449960  2449958   3728
 273  181600  2458915  2453687      1
 274  181601  2453942  2458915   4031
 275  185632  2458918  2457972   3776
 276  189408  2435164  2462693      1
 277  189409  2462695  2435164   3887
 278  193296  2469315  2466581   3952
 279  197248  2495798  2473266      1
 280  197249  2473268  2495798   4063
 281  201312  2477332  2477330   4048
 282  205360  2466583  2481379      1
 283  205361  2481381  2466583   3903
 284  209264  2485285  2485283   3920
 285  213184  2466584  2489204      1
 286  213185  2489206  2466584   3791
 287  216976  2497536  2492996   4000
 288  220976  2505409  2501535      1
 289  220977  2501537  2505409   3871
 290  224848  2505410  2505407   4000
 291  228848  2513283  2509409      1
 292  228849  2509411  2513283   3871
 293  232720  2513284  2513281   3696
 294  236416  2520885  2516979      1
 295  236417  2516981  2520885   3903
 296  240320  2520886  2520883   3680
 297  244000  2528423  2524565      1
 298  244001  2524567  2528423   3855
 299  247856  2530304  2528421   3920
 300  251776  2538113  2534223      1
 301  251777  2534225  2538113   3887
 302  255664  2538114  2538111   4096
 303  259760  2546243  2542209      1
 304  259761  2542211  2546243   4031
 305  263792  2546244  2546241   3712
 306  267504  2554325  2549955      1
 307  267505  2549957  2554325   4367
 308  271872  2554326  2554323   3792
 309  275664  2562023  2558117      1
 310  275665  2558119  2562023   3903
 311  279568  2563072  2562021   3808
 312  283376  2570737  2566879      1
 313  283377  2566881  2570737   3855
 314  287232  2570738  2570735   3952
 315  291184  2578563  2574689      1
 316  291185  2574691  2578563   3871
 317  295056  2578564  2578561   3984
 318  299040  2586405  2582547      1
 319  299041  2582549  2586405   3855
 320  302896  2586406  2586403   3904
 321  306800  2594391  2590309      1
 322  306801  2590311  2594391   4079
 323  310880  2595840  2594389   3760
 324  314640  2603457  2599599      1
 325  314641  2599601  2603457   3855
 326  318496  2603458  2603455   4016
 327  322512  2611427  2607473      1
 328  322513  2607475  2611427   3951
 329  326464  2611428  2611425   3888
 330  330352  2619189  2615315      1
 331  330353  2615317  2619189   3871
 332  334224  2619190  2619187   4096
 333  338320  2623287  2623285      1
 334  338321  2359588  2623287   3775
 335  342096  2623288  2363362   3936
 336  346032  2627225  2627223      1
 337  346033  2628608  2627225   3871
 338  349904  2632480  2632478   3888
 339  353792  2640065  2636367      1
 340  353793  2636369  2640065   3695
 341  357488  2640066  2640063   3808
 342  361296  2648051  2643873      1
 343  361297  2643875  2648051   4175
 344  365472  2648052  2648049   3728
 345  369200  2655845  2651779      1
 346  369201  2651781  2655845   4063
 347  373264  2655846  2655843   4624
 348  377888  2660471  2660469      1
 349  377889  2661376  2660471   3839
 350  381728  2665216  2665214   3840
 351  385568  2672945  2669055      1
 352  385569  2669057  2672945   3887
 353  389456  2672946  2672943   3984
 354  393440  2681411  2676929      1
 355  393441  2676931  2681411   4479
 356  397920  2681412  2681409   4016
 357  401936  2689317  2685427      1
 358  401937  2685429  2689317   3887
 359  405824  2689318  2689315   4128
 360  409952  2693447  2693445      1
 361  409953  2694144  2693447   3903
 362  413856  2698048  2698046   3968
 363  417824  2706529  2702015      1
 364  417825  2702017  2706529   4511
 365  422336  2706530  2706527   3952
 366  426288  2714195  2710481      1
 367  426289  2710483  2714195   3711
 368  430000  2714196  2714193   3824
 369  433824  2721893  2718019      1
 370  433825  2718021  2721893   3871
 371  437696  2721894  2721891   3984
 372  441680  2725879  2725877      1
 373  441681  2726912  2725879   3951
 374  445632  2730864  2730862   4176
 375  449808  2739105  2735039      1
 376  449809  2735041  2739105   4063
 377  453872  2739106  2739103   3520
 378  457392  2746355  2742625      1
 379  457393  2742627  2746355   3727
 380  461120  2750118  2746353   4240
 381  465360  2758631  2754357      1
 382  465361  2754359  2758631   4271
 383  469632  2759680  2758629   3920
 384  473552  2768065  2763599      1
 385  473553  2763601  2768065   4463
 386  478016  2768066  2768063   4560
 387  482576  2772627  2772625      1
 388  482577  2746356  2772627   3743
 389  486320  2772628  2750098   3840
 390  490160  2780437  2776467      1
 391  490161  2776469  2780437   3967
 392  494128  2780438  2780435   4000
 393  498128  2788599  2784437      1
 394  498129  2784439  2788599   4159
 395  502288  2788600  2788597   3968
 396  506256  2795033  2792567      1
 397  506257  2810855  2795033   3631
 398  509888  2814487  2814485   3280
 399  513168  2820952  2817766      1
 400  513169  2817768  2820952   3183
 401  516352  2820953  2820950   3840
 402  520192  2824794  2824792      1
 403  520193  2796313  2824794   4175
 404  524368  2800489  2800487   3744
 405  528112  2824795  2804232      1
 406  528113  2804234  2824795   3487
 407  531600  2825584  2807720   4208
 408  535808  2839729  2829791      1
 409  535809  2829793  2839729   3839
 410  539648  2833633  2833631   3824
 411  543472  2839730  2837456      1
 412  543473  2842425  2839730   3775
 413  547248  2846201  2846199   3792
 414  551040  2837458  2849992      1
 415  551041  2849994  2837458   3999
 416  555040  2853994  2853992   4128
 417  559168  2837459  2858121      1
 418  559169  2858123  2837459   3871
 419  563040  2867391  2861993   3936
 420  566976  2880529  2871326      1
 421  566977  2871328  2880529   3855
 422  570832  2875184  2875182   3968
 423  574800  2880530  2879151      1
 424  574801  2861995  2880530   3807
 425  578608  2881987  2865801   4032
 426  582640  2865803  2886018      1
 427  582641  2887116  2865803   3807
 428  586448  2890924  2890922   4128
 429  590576  2918872  2895051      1
 430  590577  2895053  2918872   3935
 431  594512  2899516  2898987   3904
 432  598416  2918873  2903419      1
 433  598417  2903421  2918873   3839
 434  602256  2907261  2907259   3872
 435  606128  2918874  2911132      1
 436  606129  2911134  2918874   4031
 437  610160  2920347  2915164   4048
 438  614208  2898989  2924394      1
 439  614209  2926197  2898989   4319
 440  618528  2930517  2930515   3728
 441  622256  2944908  2934244      1
 442  622257  2934246  2944908   3727
 443  625984  2937974  2937972   4080
 444  630064  2944909  2942053      1
 445  630065  2946430  2944909   3791
 446  633856  2950222  2950220   3808
 447  637664  2924396  2954029      1
 448  637665  2979066  2924396   3983
 449  641648  2959587  2983048   4144
 450  645792  2954031  2963730      1
 451  645793  2963732  2954031   4255
 452  650048  2967988  2967986   4096
 453  654144  2983050  2972083      1
 454  654145  2954032  2983050   3663
 455  657808  2972085  2957694   3776
 456  661584  2983051  2975860      1
 457  661585  2985732  2983051   3855
 458  665440  3008302  2989586   4112
 459  669552  3016431  3012413      1
 460  669553  3012415  3016431   4015
 461  673568  2991465  3016429   4112
 462  677680  3000706  2995576      1
 463  677681  2995578  3000706   4207
 464  681888  3000709  2999784   3872
 465  685760  3016432  3004580      1
 466  685761  3021824  3016432   3983
 467  689744  3025808  3025806   3984
 468  693728  3033745  3029791      1
 469  693729  3029793  3033745   3951
 470  697680  3033746  3033743   4000
 471  701680  3041827  3037745      1
 472  701681  3037747  3041827   4079
 473  705760  3041828  3041825   4032
 474  709792  3050005  3045859      1
 475  709793  3045861  3050005   4143
 476  713936  3050006  3050003   3968
 477  717904  3053975  3053973      1
 478  717905  3054592  3053975   3871
 479  721776  3058464  3058462   4112
 480  725888  3066529  3062575      1
 481  725889  3062577  3066529   3951
 482  729840  3066530  3066527   4112
 483  733952  3074579  3070641      1
 484  733953  3070643  3074579   3935
 485  737888  3074580  3074577   3808
 486  741696  3082437  3078387      1
 487  741697  3078389  3082437   4047
 488  745744  3082438  3082435   3696
 489  749440  3086135  3086133      1
 490  749441  3087360  3086135   3679
 491  753120  3093064  3091038   3664
 492  756784  3100697  3096727      1
 493  756785  3096729  3100697   3967
 494  760752  3103733  3100695   4128
 495  764880  3093055  3107860      1
 496  764881  3107862  3093055   3903
 497  768784  3111766  3111764   3648
 498  772432  3093056  3115413      1
 499  772433  3115415  3093056   3791
 500  776224  3119207  3119205   3680
 501  779904  3093057  3122886      1
 502  779905  3123607  3093057   4031
 503  783936  3127639  3127637   4064
 504  788000  3131704  3131702      1
 505  788001  3140351  3131704   3215
 506  791216  3143567  3143565   3968
 507  795184  3151472  3147534      1
 508  795185  3147536  3151472   3935
 509  799120  3132254  3151470   3888
 510  803008  3151473  3136141      1
 511  803009  3136143  3151473   3967
 512  806976  3152896  3140109   4400
 513  811376  3158465  3157295      1
 514  811377  3157297  3158465   1167
 515  812544  3158466  3158463    224
 516  812768  3160976  3158689      1
 517  812769  3158691  3160976    239
 518  813008  3160977  3158929      1
 519  813009  3158931  3160977    223
 520  813232  3160978  3159153      1
 521  813233  3159155  3160978    271
 522  813504  3160979  3159425      1
 523  813505  3159427  3160979    239
 524  813744  3160980  3159665      1
 525  813745  3159667  3160980    223
 526  813968  3160981  3159889      1
 527  813969  3159891  3160981   1084
 528  815053  3160982  3160974   1072
 529  816125  3162068  3162053      1
 530  816126  3162055  3162068     13 eof
slow: 531 extents found

Ext4 copy allocation:
File size of copy.7z is 3342903522 (816139 blocks, blocksize 4096)
 ext logical physical expected length flags
   0       0   374784           18432
   1   18432   395264   393215  30720
   2   49152   428032   425983  30720
   3   79872   460800   458751  30720
   4  110592   493568   491519  30720
   5  141312   565248   524287  24576
   6  165888   591872   589823  30720
   7  196608   624640   622591  30720
   8  227328   657408   655359  30720
   9  258048   690176   688127  30720
  10  288768   722944   720895  30720
  11  319488   755712   753663  30720
  12  350208   788480   786431  30720
  13  380928   821248   819199  30720
  14  411648   854016   851967  30720
  15  442368   886784   884735  30720
  16  473088   919552   917503  30720
  17  503808   952320   950271  30720
  18  534528   985088   983039  30720
  19  565248  1017856  1015807  30720
  20  595968  1083392  1048575  30720
  21  626688  1116160  1114111  30720
  22  657408  1148928  1146879  30720
  23  688128  1181696  1179647  30720
  24  718848  1214464  1212415  30720
  25  749568  1247232  1245183  30720
  26  780288  1280000  1277951  30720
  27  811008  1312768  1310719   4096
  28  815104  1311233  1316863   1035 eof
copy.7z: 29 extents found

Ext4 fast allocation:
File size of fast is 3342903522 (816139 blocks, blocksize 4096)
 ext logical physical expected length flags
   0       0  2230272           30720
   1   30720  2263040  2260991  30720
   2   61440  2295808  2293759  30720
   3   92160  2328576  2326527  30720
   4  122880  2361344  2359295  30720
   5  153600  2394112  2392063  30720
   6  184320  2426880  2424831  30720
   7  215040  2459648  2457599  30720
   8  245760  2492416  2490367  30720
   9  276480  2525184  2523135  30720
  10  307200  2557952  2555903  30720
  11  337920  2590720  2588671  28672
  12  366592   253952  2619391   2048
  13  368640   258048   255999   2048
  14  370688   280576   260095   2048
  15  372736   286720   282623   2048
  16  374784   270336   288767   4096
  17  378880   290816   274431   4096
  18  382976   301056   294911   2048
  19  385024   313344   303103   2048
  20  387072   321536   315391   4096
  21  391168   374784   325631  18432
  22  409600   395264   393215  30720
  23  440320   428032   425983  30720
  24  471040   460800   458751  30720
  25  501760   493568   491519  30720
  26  532480   565248   524287  24576
  27  557056   591872   589823  30720
  28  587776   624640   622591  30720
  29  618496   657408   655359  30720
  30  649216   690176   688127  30720
  31  679936   722944   720895  30720
  32  710656   755712   753663  30720
  33  741376   788480   786431  30720
  34  772096   821248   819199  30720
  35  802816   854016   851967  24576
  36  827392   852481   878591     45 eof
fast: 37 extents found

Ext4 slow allocation:
File size of slow is 3342903522 (816139 blocks, blocksize 4096)
 ext logical physical expected length flags
   0       0   374784           18432
   1   18432   395264   393215  30720
   2   49152   428032   425983  30720
   3   79872   460800   458751  30720
   4  110592   493568   491519  30720
   5  141312   565248   524287  24576
   6  165888   591872   589823  30720
   7  196608   624640   622591  30720
   8  227328   657408   655359  30720
   9  258048   690176   688127  30720
  10  288768   722944   720895  30720
  11  319488   755712   753663  30720
  12  350208   788480   786431  30720
  13  380928   821248   819199  30720
  14  411648   854016   851967  30720
  15  442368   886784   884735  30720
  16  473088   919552   917503  30720
  17  503808   952320   950271  30720
  18  534528   985088   983039  30720
  19  565248  1017856  1015807  30720
  20  595968  1083392  1048575  30720
  21  626688  1116160  1114111  30720
  22  657408  1148928  1146879  30720
  23  688128  1181696  1179647  30720
  24  718848  1214464  1212415  30720
  25  749568  1247232  1245183  30720
  26  780288  1280000  1277951  30720
  27  811008  1312768  1310719  16384
  28  827392  1311233  1329151    116 eof
slow: 29 extents found

NTFS, incremental allocation:
File is 816139 physical clusters in length.
File is in 5063 fragment(s).

NTFS, copy with pre-allocation:
File is 816139 physical clusters in length.
File is in 1 fragment(s).

Using pre-allocation with NTFS file system is very important. It should be used when ever it is possible (when final file size is known). Unfortunately many applications aren't using this important feature.

Linux kernel used: 2.6.38-8-server

RFID, BtrFS, DHCP, obfsproxy, GAE/python27, sql pivot, ext4, extents, SSD, ncq, ntfs

posted Feb 12, 2012 8:22 AM by Sami Lehtinen   [ updated Feb 12, 2012 8:23 AM ]

  • Tested and installed RFID end client identification system.
  • Tested and compared BtrFS none / lzo / zlib compression algorithms and disk performance on virtual servers.
  • e4defrag is finally becoming ready, just when BtrFS is becoming slowly ready for production use? BtrFS provides autodefrag mount option.
  • Closed case with Clonzeilla and TFTPDS32 DHCP protocol issue. It's now clear that Clonezilla sends invalid request packets and are being ignored by DHCP server application. To find out all the details, tried both Wireshark and (MS) Network Monitor.
  • There is also strange issue with Clonezilla, Linux, pxelinux network driver. When using one Realtek Gigabit Ethernet adapter with pxelinux, it seems that something goes so badly wrong that network card is "permanently disabled". Even booting computer to Windows, where it did work before this boot attempt doesn't fix the situation. Some engineers thought that it's better to send those computers for warranty repair, but before they were able to send those. I told them that have they really rebooted those computers? They said yes. Then I unplugged the power cord, pressed power button a few times, and plugged cable back in. - Yup, now you got working network adapter again. No, it's not real cold reboot, if you keep motherboard powered all the time. Unfortunately even latest pxelinux.0 file won't fix this issue. Yes, I have reported it.
  • Compiled and installed obfsproxy to virtual server. I think information flow should be free and available to everyone. There are now over 20 users using it all the time.
  • Created new (git) branch for 9oxnet project. Plan is to make required changes, so I can use python27 runtime with Google App Engine. After very quick testing I found out that upgrading from 2.5 runtime to 2.7 requires more changes than I initially thought. I also need to confirm that application is truly threadsafe, otherwise interesting issues could arise.
  • I had to produce one report, there were multiple options how to collect data for it. But I decided that it's not bad idea to be able to fully master pivot queries, so I used a few hours to learn it throught and managed to pull all required information with one query including all required multitable joins etc.
  • Listened just a few too many Social Engineering podcasts, those weren't that good. Won't listen more.
  • Checked what are the actual fragmenting effects of sparsely allocated files on ext4 filesystem. It seems that even if large file is created as sparse file, and filled up in fully random order, ext4 manages to create in average 2 megabyte extents. Files are of course fragment up between extents, but that's not excessive. Without extent feature, results could be very much worse. Like they are when doing similar test is executed using NTFS file system. It leads to incredibly many fragments, just a few contiguous blocks here and there. If you want even worse results, fill up compressed NTFS file in random order. It seems that 7-zip doesn't pre-allocate files even when extracting data. It would be smart to pre-allocate space for file because final file size is of naturally known.
  • During doing that I found out that there is currently failure in Ubuntu power management. It sets ext4 commit time always to 0 if AC power is being used. I had to modify /usr/lib/pm-utils/power.d/journal-commit file to get 60 second commit time. That's what though I would have been using all the time. When I checked mounts I found out that there was commit=60,commit=0 entries on ext4 mount rows. Unfortunately I haven't been able to enable NCQ (and AHCI) with my Intel P35 Express motherboard and Linux kernel. I have tried all basic tricks.
  • Checked out (again) latest info about SSD drives and issues realated to those: file systems designed for SSD drives (log filesystem), flash file system, wear leveling, write amplification, data remanence, trim. Low level wear leveling can caused serious drive fragmentation which isn't visible at all to operating system. Performance of some Intel drives suffer very badly. Running OS file system level defrag only makes this situation often worse. (ubifs, logfs, jffs2, ahci, ncq, trim, lba)

WPS, APE Payments, Nordnet, GAE SDK, FS, HAProxy, iLOQ S10, port knocking

posted Feb 5, 2012 3:31 AM by Sami Lehtinen   [ updated Feb 5, 2012 4:27 AM ]

  • WPS is absolutely broken by bad design. It's very important to disable WPS completely from your WLAN / Wi-Fi router / station. Check out Reaver cracking tool. PIN and Push Button features are highly vulnerable, future NFC or USB based modes could be better.
  • APE Payment: They instruct users to globally enable all 3rd party cookies. Just to allow use of their services. Why? After quick testing at least Firefox easily allows to enable 3rd party cookies just for one specified domain. Which is enough in this case. I IE worked just fine too. But with Google Chrome there was strange thing. It was possible to block 3rd party cookies from certain domains, but there wasn't option to allow 3rd party cookies only from specified domain(s). That's quite a problem in this case. So 3rd party cookies must be globally enabled to use APE Payment.
  • Nordnet Bank doesn't use 2FA/SMS authentication. Their system is already capable of sending SMS messages and they could even charge for authentication messages. But they still refuse to do this. It's interesting to see how banking sector handles security suggestions from customers. They're hadling large sums of money, because they're major nordic stock broker. But customer security isn't that important, right?
  • Updated to latest Google App Engine SDK 1.6.2 and tested that my projects work perfectly with it. I still should upgrade from Python 2.5 runtime to Python 2.7, but might be too early.
  • Checked latest file system develoment. What are the problems with larger ext4 and XFS file systems and how those issues can be solved.
  • I'm often checking routing, AS numbers and stuff. Nice and easy to use tools for anyone are route.im and robtex.com. But this TPB trace is really strange.
  • Tried HAProxy, it's very exellent load balancing tool.
  • Checked out iLOQ S10 locking system. I got installation offer from them. It seems that this solution got hardware design flaw, that can be used by attacker using several different exploits. Unfortunately I didn't have time to check out the digital part of this lock. Keys are using DS2432 1Kb 1-Wire chips with SHA512 engine. I'm pretty sure that electric part of the lock could be also exploitable, but its propably  much more complex and time consuming than those simple physical attacks. I personally would like to try those physical attacks, because those seem to pretty simple to do.
  • Installed port knocking software knockd to my private communication server.

Of course I also did lots of less interesting stuff.

Wireless, Privacy, Faster TCP, UpCloud, LoadStorm etc.

posted Jan 29, 2012 8:38 AM by Sami Lehtinen   [ updated Jan 31, 2012 7:51 AM ]

I have been glued to computer and my mobile terminal. And I have managed to to following stuff during this week.

  • Refresing memory and catching up with latest development around: mimo, ofdm, ssb, qam, lte, 3g, 4g, hspa+, umts, dual carrier (dual cell)
  • Read about possibly upcoming new EU privacy / data protection law. It might be very hard hit for  small web sites. Would anyone really expect those to follow this kind of legalization?
  • Checked out Google's new privacy policy & terms of service
  • I have always loved optimizing TCP protocol by tweaking parameters. Now there is nice article about making Internet faster by tweaking TCP functionality and parameters.
  • Tried out UpCloud, new cloud service. Details of the service are not yet public, therefore I can't tell too much about it. But let's hope service is soon available for everyone.
  • Quickly tested load testing service LoadStorm.
  • Lots of discussion in LinkedIn IT Security, Startup, SaaS, Cloud Computing groups.
  • Read tons of news, and magazines about tech stuff, developers tools and startups.

Yahoo Mail - What's wrong with it

posted Jan 29, 2012 3:51 AM by Sami Lehtinen   [ updated Feb 6, 2012 9:00 AM ]

Here's my little rant about Yahoo! Mail. It's clearly not a good choice as your primary email provider.
  • There is daily message quota, when you have sent enough messages, it says that you can send more messages tomorrow. Limit is quite low. Because I have set it often when having my "email day", when I take care of all my queued mails. I assume that limit is something like ~200 mails. +/- 50 mails. Maybe number of recipients also affects it. But limit is very annoying for active email user.When daily send quota is full, it seems that some messages just disappear and aren't left in outbox to be sent tomorrow. This is really really bad thing.
  • When receiving larger quantities of email, service starts  blocking mail traffic.
    Diagnostic-Code: X-Postfix; delivery temporarily suspended: host
        mx1.mail.eu.yahoo.com[77.238.177.9] refused to talk to me: 421 4.7.0 [TS02]
        Messages from 205.251.134.191 temporarily deferred - 4.16.56.1; see
  • IMAP+ (imap/idle) often times out or doesn't respond to ping. Connecting simply dies. Simple tasks like moving message to another folder, can take several minutes.
  • SMTP servers do not allow parallel SMTP sessions. Making delivering larger email batches slow.
  • Asks way too often to solve CAPTCHA code, if email contains link(s).
  • Several encryption / security issues:
    • Web interface doesn't use HTTPS  (after password is given) or IP-address change checkes. Stealing session cookie is absolutely possible and using it from other IP allowing session hijacking attack.
    • Yahoo's SMTPS server and IMAP servers got at times invalid TLS certificates. If I can't verify certificate everytime, it means that I have to accept invalid certificates, making MITM attack very easy. This kind of MITM attack allows easy way to steal passwords when travelling or using unknown WLAN.
    • MTA's do not use TLS at all. So all email is actually being transported in clear for inbound and outbound traffic.
    • No 2FA support.
    • Even if I have configured my Yahoo sessions to expire in 24 hours, my mobile sessions last longer. This is quite interesting. It shoulnd't be unclear that 24 hour session should last max 24 hours.
Are there any positive things? - Yep, a few.
  • Web interface is pretty much working one.
  • European services are run from European based servers.
  • Temporary email addresses, I just love those. Of course you can get similar service from TrashMail or SpamGourmet. But using these services adds proxies, complexity, unreliability to incoming and outgoing email handling.

Based on these issues, I wouldn't recommend Yahoo Mail as email provider for anyone. Except if you use it for secondary purposes, and do not transfer any private information using it.

Data compression, hashing, file systems, web casts, networking, cloud hosting, networking etc...

posted Jan 22, 2012 10:26 AM by Sami Lehtinen   [ updated Jan 22, 2012 10:28 AM ]

I have been studying every day, several hours a day. Study subjects like:

  • Encryption & Hashing: Threefish, OCB mode, Skein, Jenkins, Pearson - Nice article about hashing
  • Compression: LZ77, LZMA2, LZMA, Huffman, Burrows Wheeler
  • File system: Refreshed my memory about BtrFS and it's latest development
  • Cloud hosting: IBM SmartCloud, I also tried Nodester - Didn't like it, beacause I'm not familiar enough with JavaScript
  • Web casts: Risky Business and plenty of stuff from TED
  • Networking: DCCP, ECN, NAT66 / NPT66, shim6, IPv6 multihoming using NAT without BGP.
    World IPv6 launch is here!
    IPv6 + NAT, please no! NAT breaks Internet connectivity!
    SCTP: At least for my apps SCTP would be far superior compared to TCP and also would make communication faster. Packets also can be received out of order if order doesn't matter further saving bandwidth. If ECN (removes packet loss) is used with SCTP it's real killer solution compared to plain old TCP. Less data to be sent faster and more reliable delivery. SCTP keeps message boundaries clear and allows multiple parallel streams with one negotiation. TCP's sliding window adds overhead by delivering partitial messages. Also SCTP uses CRC32 instead of CRC16. I have experienced issues with bad links and huge files while using TCP, received file / data is simply corrupted. Not completely, but even one corrupted block is enough to completely destroy compressed file.
  • Reading: Good to know about data security and Google. Good to know information in easy to understand package. - I really recommend reading this.
  • Other stuff: Squid cache eviction algorithms and configuration parameters, more SaaS and Virtualization stuff, Magnet URI scheme
  • Writings: I wrote long article about two factor authentication (2FA) and practical ways to implement it. I recommended that the authorization key should be directly related to the transaction being confirmed. Using OTP passwords without payload parameters is just bad design. In those cases user does not know what they're actually confirming. Any MITM or Trojan could modify messages in real-time. So tokens aren't good solution, SMS messages with enough information to confirm transaction and single use code for that is pretty good. But we shouldn't forget that there are many technical and not so technical ways to attack that implementation too. GSM/2G networks aren't so secure, if attacker got  high value target. Also phone software could be modified and can be rogue applications or whole operating system can be replaced to further deceive user.

I couldn't list everything, but that's small part of stuff I have done. There is also long rant coming about Yahoo Mail, listing all the dirty facts.

BBS systems, file transfer protocols, design issues - Nostalgic moment, good old times

posted Jan 21, 2012 11:04 PM by Sami Lehtinen   [ updated Jan 21, 2012 11:31 PM ]

Today some protocol discussion in one forum reminded my self about old good times as SysOp of BBS system.

Systems and protocols like: PCBoard, FidoCom, Rcom, Opus, SBBS, QBBS and file transfer protocols like Kermit, Xmodem, Ymodem, Zmodem, Smodem, HS/Link, BiModem and Hydracom came right back to my mind. Also with all their design issues.

BBS systems

PCBoard used index and message data files per board, it was pretty good design. FidoCom and Rcom stored each message in separate file, which was really bad thing for larger systems because of fat 16 limited number of files on disk. This also made collecting messages for QWK or BlueWave off-line message reader formats very slow.

SBBS and QBBS used one message database file for all messages. It caused huge problems when systems were connected to global fidonet, which replicated messages to systems all over the world. I assume that the designers of the system never realized how many messages there actually could be and therefore they used 16 bit message id. Maximum number of messages in database could be only 65536 messages. That caused message backlog to be really short for very active systems. Of course that was huge number of messages if you thought to have local system, with only one phoneline and single user at time. That is exactly how times change. When you design something, design it so that it won't run out. Eh, like IPv4. Benefits of having all messages in single file with index was that picking required messages for off-line reading was really super fast compared to other designs I mentioned ealier which required opening large number of individual files instead of using fast seeks in file.

File transfer protocols

HS/Link was near perfect with bidirectional transfers and full streaming. Except it didn not use adaptive block size. This critical issue caused big block size to discard almost all data on noisy line. Of course smaller block size could have been chosen when starting transfer. But if line was good using small block size was really inefficient. So lack of automatic adaption to line conditions made this protocol unusable at least for me.

Zmodem was nice, but it didn't have fully streaming error correction (causing every error to stop transfer and discard lots of perfectly good data.) BiModem just wasn't supported by any systems as well as Hydracom was poorly supported.  But then came Smodem which was simply great. With adaptive blocksize and multiplexed simple ack/nak channels it was clearly superior to any other protocol implemented that far. Other older protocols like Xmodem were inefficient and also slow, no sliding window, simple single ack/nak syled transfer causing latency to cause wasted idle time. Smodem was actually so extremely good compared to competition that I was really bit sad that we didn't have it years before.

Modem protocols

Other protocols which were integrated to modem software directly came very familiar. v.42 error correction, v.42bis data compression and older MNP4 (EC) and MNP5 (DC). Not forgetting SREJ (Selective Reject) which allowed only corrupted frames to be resent. Working efficiently and very similarly (as end result) to Smodem, although technical approach and implementation was very different. Some terminal programs like Transend were able to implement MNP4 and MNP5 error correction and compression in terminal software, there fore you didn't need more expensive modem having those features. (1200 bps / 2400 bps era)

Terminal emulation

VT102 and ANSI were ruling terminal protocols for long time. But after that came Avatar, it was drastically faster and more efficient than those protocols. Which was especially needed for colorful SBBS systems. Avatar used one escape char and binary payload after that to give commands, so it was much more compact and efficient compared to ansicodes which were easily 5-10 characters long.

Some terminal apps I personally used: Kermit, ProComm, Transend, Telemate, Telix, Terminate.

End of BBS era

Well well, that was nice nostalgic moment. It was year 1995 when I completely stopped using BBS systems and Internet had fully replaced those for me as communication method. Some Finnish BBS continued running for a very long time after that. Most notable one was MikroBitti magazines PCBoard based system called MBnet. Also some BBS systems allowed connecting those over internet using telnet, but for me there was no reason to use those "closed and slow" systems anymore.



Want to read more? Check out: FidoNet, BBS, Zmodem, Smodem want broader description in form of documentary? Watch BBC's BBS documentary.

My Opera Mini feature wishlist

posted Jan 21, 2012 11:06 AM by Sami Lehtinen   [ updated Jan 21, 2012 11:08 AM ]

Here's my Opera Mini wishlist (S60 platform) and comments:

1. IDNA whitelist doesn't contain fi tld-domain, oh why?

2. Some times left marging is completely missing and it requires screen to me scrolled to left constantly to see left most letters. If I stop scrolling to left, half or full first letter of each row is outside screen. It's also very annoying. Mostly this feature occures with mobile Wikipedia.

3. Opera often returns empty pages. Hitting reload several times fixes the problem. But why it's required.

4. If screen orientation has been switched, Opera doesn't recognize touch screen clicks correctly. This is old, but very annoying when you have device which turns screen orientation when using keyboard. One way to deal with this, is opening keyboard and using landscape mode all the time. Which naturally isn't what I want to do.

5. Some times links or page requests and responces are mixed between tabs. That's actually pretty strange. But all pages still are pages that I have visited or have links on pages I have visited, so at least it's not mixing data between users as far as I know. Some times system gets really messed up, when using 10+ tabs and Opera Mini for longer time. After that wrong pages are returned almost every time. Only way to fix that nasty situation is to restart Opera.

6. Opera should have internal PDF reader. It also  also should be able to re-wrap text to make it well readable on phone screen. Technically it could  preprocess PDF files on server and transfer and present those using Opera Mini's standard transport and UI. It would result as best possible UX. Therefore PDF files should not be any different from any other web-content. Now downloading files and opening those using slow native application isn't user friendly at all.

7. Option to clear privacy information on application exit.

8. IPv6 support (very low priority) - http://www.worldipv6launch.org/

9. Positive feedback: It was really nice to be able to disable that annyoing automatic phone number detection.

I'll be posing more stuff soon. I have just been really really busy with new technologies, testing, studying, etc.

GoDaddy/SOPA, Cloud Security Alliance

posted Dec 25, 2011 6:40 AM by Sami Lehtinen   [ updated Dec 25, 2011 6:41 AM ]

First of all, I have been enjoying great Xmas food and sleeping. But I have managed to get something else done too.


9ox.net: Google Safe Browsing API

posted Dec 18, 2011 5:18 AM by Sami Lehtinen   [ updated Dec 18, 2011 5:24 AM ]

9ox.net now uses Google Safe Browsing API to reject phishing and malware sites. It's already using SURBL and WOT. I guess I don't do any changes before converting to Python 2.7. All changes this far which I have made, haven't affected database structure. Therefore it has been relatively safe to do these changes.

When I'll implement Python 2.7 and multithreading, that's right time to fix the database structure. I have one known performance bottlenecks which is caused by bit bad implementation, and it's directly related to bad database structure design.

Now it's good time to study something else for a while. I think I'll check out some compression and hashing & encryption algorithms.

1-10 of 27