English Amiga Board


Go Back   English Amiga Board > Support > support.Hardware

 
 
Thread Tools
Old 03 July 2018, 09:28   #1
ShK
In carbonite
ShK's Avatar
 
Join Date: Mar 2013
Location: Lahti / Finland
Age: 47
Posts: 320
Format CompactFlash Card with 8 MB Aligned Partitions

CompactFlash generally have 2, 4, or 8 MB erase block size. When writing to memory card whole Erase block must be read, modified and write back to the drive. Because of this, partitions on CompactFlash card should be aligned so that they begin and end at the edges of the erase blocks.

Is this ideal way to do it on HDToolBox?

64 Heads
64 Blocks per Track
4096 Blocks per Cylinder ( = 2 MB )


Last edited by ShK; 03 July 2018 at 11:00.
ShK is offline  
Old 03 July 2018, 11:06   #2
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 3,397
I'm not entirely sure it makes that much of a difference since the OS will still place files arbitrarily within the partitioned space. If filesystems had a blocksize in the MB range, perhaps it would make more sense, but with such a huge difference in size between 8MB and even the largest blocksize of 32KB (with most other filesystems using just 512 bytes), I just can't see the benefit.

Is there some aspect I'm missing here?
Daedalus is offline  
Old 03 July 2018, 11:21   #3
ShK
In carbonite
ShK's Avatar
 
Join Date: Mar 2013
Location: Lahti / Finland
Age: 47
Posts: 320
I thought that each block gets more often erased and rewritten TWICE when misaligned?
ShK is offline  
Old 03 July 2018, 11:40   #4
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 3,397
Yes, that will happen, but every other 8MB border within the partitions (a 2GB partition has ~256 such borders) will also cause both blocks to be erased and rewritten if a block straddles them, so aligning the partition is the difference between having 256 such events and 254, assuming a full partition. But a 512 byte blocksize means that no block will ever straddle the 8MB border. The more worrying aspect is that writing in small block sizes of 512 bytes means that (worst case scenario) writing a 1MB file requires the page to be erased and rewritten potentially 2048 times. Hopefully caches etc. would significantly reduce that number. Increasing the blocksize to 32KB with FFS would reduce that number to 32 erase and rewrite operations, at the expense of introducing blocks that straddle the 8MB page border. In that case, aligning the partitions would eliminate the case where 1 in 32 written blocks required two pages to be erased instead of 1, but it's still far fewer cycles than the 512 byte worst case.
Daedalus is offline  
Old 03 July 2018, 11:53   #5
ShK
In carbonite
ShK's Avatar
 
Join Date: Mar 2013
Location: Lahti / Finland
Age: 47
Posts: 320
PFS3 seems to automatically flush all write cached buffers in few seconds after last write. How big is that cache?

e. It caches only index block(s), which are of pointers to the data blocks?

Last edited by ShK; 03 July 2018 at 13:35.
ShK is offline  
Old 03 July 2018, 14:10   #6
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 3,397
I honestly don't know what size the cache is, but most filesystems behave in a similar way. None of them will know of any alignment other than with their block size however, which for PFS is 512 bytes.
Daedalus is offline  
Old 03 July 2018, 16:04   #7
ShK
In carbonite
ShK's Avatar
 
Join Date: Mar 2013
Location: Lahti / Finland
Age: 47
Posts: 320
I ended up this type geometry to maximize lifespan of the standard Kingston CF Card 4GB (Flower image):

https://wiki.linaro.org/WorkingGroup...lashCardSurvey

(List of the CF cards characteristics is in end of the page)

Allocation Unit = 2 MB (2097152 b) 4096 blocks <--- ERASE SIZE
Write Size = 16 KB (16384 b) 32 blocks <--- FILE SYSTEM BLOCK SIZE

--

3997163520 b / 512 b = 7806960 blocks
7806960 blocks / 4096 blocks (2097152 b) = 1905,99609375 erase pages
1905 erase pages * 4096 blocks (2097152 b) = 7802880 blocks



7802880 blocks / 64 Heads (Tracks per cylinder) / 64 Blocks per Track = 1905 Cylinders

1905 Cylinders (cylinders per HDD or tracks per layer)
64 Heads (Tracks per cylinder)
64 Blocks per Track
4096 Blocks per Cylinder (64 Heads * 64 Blocks per Track = 4096 Blocks = 2 MB)



File system block size = Kingston CF Write Size 16 KB (16384 b)



128 buffers * File system block size 16384 B = 2097152 B = 2 MB



Each Cyl. is exact the same size as erase size.

Last edited by ShK; 05 July 2018 at 06:50.
ShK is offline  
Old 04 July 2018, 01:57   #8
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 3,665
What are you trying to accomplish?
idrougge is offline  
Old 04 July 2018, 09:20   #9
thomas
Registered User
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 5,710
Quote:
Originally Posted by ShK View Post
Heads (Sectors)
This is not true. Heads is not a synonym for sectors. Blocks is a synonym for sectors (at least in the context of HDToolbox. Actually the word blocks is used wrongly here).

Sectors = Sectors per track a.k.a. Blocks per track
Heads = Tracks per cylinder
Cylinders = cylinders per HDD or tracks per layer.

However, neither of these values has any meaning for modern harddrives, especially not for SSDs and flash memory drives.

Your approach to align a cylinder to an erasable block and a file system block to a writable page is a good method for SSDs and such.
thomas is offline  
Old 04 July 2018, 09:41   #10
ShK
In carbonite
ShK's Avatar
 
Join Date: Mar 2013
Location: Lahti / Finland
Age: 47
Posts: 320
Thanks for the clarification. I fixed those meanings to the my post.
ShK is offline  
Old 04 July 2018, 11:25   #11
ShK
In carbonite
ShK's Avatar
 
Join Date: Mar 2013
Location: Lahti / Finland
Age: 47
Posts: 320
I am not sure how these goes in HW level, but maybe it's even more ideal to have 'Blocks per Track' same as Kingston CF Write Size, which is 16 KB (16384 b) = 32 blocks. Would it sync better to all in real? Maybe not because these does not mean anything with CF...

1905 Cylinders (cylinders per HDD or tracks per layer)
128 Heads (Tracks per cylinder)
32 Blocks per Track (Kingston CF Write Size)
4096 Blocks per Cylinder (Kingston CF Erase Block Size)

File system block size = Kingston CF Write Size (16384 b)
128 buffers * File system block size 16384 B = Kingston CF Erase Block Size (2 MB)
ShK is offline  
Old 04 July 2018, 23:29   #12
thomas
Registered User
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 5,710
Heads and blocks per cylinder have no meaning at all. The only define the source values to calculate blocks per cylinder. So whether you use 128 * 32 or 32 * 128 or 1 * 4096 does not matter at all.

The only value which matters is the number of blocks per cylinder because partitions are aligned on cylinder boundary.

Also the number of buffers has no relation to the hardware. The file system uses buffers to store data temporarily. The more buffers you use the better for performance. But each buffer costs RAM. Especially with large block sizes you quickly eat up a lot of memory. In your example with 128 buffers of 16kb each you lose 2 MB memory per partitiion.

Buffers are used by the file system for many different purposes, but mainly for directory and meta data. You won't ever get it to write a 2 MB chunk at once.
thomas is offline  
Old 05 July 2018, 16:22   #13
ShK
In carbonite
ShK's Avatar
 
Join Date: Mar 2013
Location: Lahti / Finland
Age: 47
Posts: 320
IDE commands (ATA5 or lower) have "sector count" field which is 8-bits, so MaxTransfer can have a maximum value of 255 (e.g. 255 * 512 = 130560b = $1FE00). MaxTransfer must also be divisible by the sector size (512) due to a bug in the WorkBench format code.

Even targeting MaxTransfer of 0x7FFFFF with the real SCSI2SD to erase page's size does not bring an advantage, because no program would ever attempt to write 8MB at once.

But would it give any advantage to put the MaxTransfer size equal to the writable page size (in case of a Kingston $4000)? At least it should not slow down writing.
ShK is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
PC & Amiga Partitions on one CF Card amigoun support.Other 4 08 February 2015 06:47
PFS3 partitions full after format? emuola project.ClassicWB 3 19 August 2012 16:25
[FS] CF-CompactFlash Card - 1GB for AMIGA LTAC MarketPlace 0 25 March 2012 18:20
FS: 32 GB CompactFlash card DJBase MarketPlace 1 07 January 2009 11:12
Force AVI recording to start aligned to odd/even frames LocalH request.UAE Wishlist 0 16 September 2004 02:50

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 00:42.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.
Page generated in 0.07534 seconds with 13 queries