Changes between Version 5 and Version 6 of file_system


Ignore:
Timestamp:
Jun 7, 2015, 11:38:25 AM (9 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • file_system

    v5 v6  
    1818Each slot in this array contains a cluster_ptr, that is the index of the cluster on the block device. The cluster_ptr value cannot be larger than 0x0FFFFFFF (i.e. 256 M). The max addressable storage capacity in the DATA region on the block device is therefore (256 M * 4 Kbytes) = 1 Tbytes.
    1919
    20 This implementation uses memory caches implemented in the distributed kernel heap.
    21 There is actually one cache per file (called '''file_cache'''), and one cache for the FAT itself (called '''fat_cache''').
    22 The cache size is not fixed: it is dynamically increased from the kernel heap as required by the read / write access to the files or to the FAT itself. The memory allocated to a given cache_file is only released when the file is closed.
     20This implementation uses define four data structures:
     21 * The '''File-Cache''' and '''Fat-Cache''' are dynamically allocated memory caches, implemented in the distributed kernel heap.
     22There is actually one cache per file (File_Cache), and one cache for the FAT itself (called '''Fat_Cache'''). The cache size is not fixed: it is dynamically increased from the kernel heap as required by the read / write access to the files or to the FAT itself. The memory allocated to a given cache_file is only released when the file is closed.
    2323
    24 In the present implementation, there is no rescue mechanism in case of heap overflow: The system crash
    25 with a nice error message on the kernel terminal...
     24 * The '''Inode-Tree''' is an internal representation of the FAT. It is a sub-tree of the File System tree. Each node define a file or a directory, and contains a pointer on the associated File-Cache. This Inode-Tree is dynamically increased from the distributed kernel heap when a file or a directory is accessed. The memory allocated to the Inode-Tree is only released in case of system crash.
     25
     26 * The '''File-Descriptor-Array''' is a statically defined array of file descriptors. According to the UNIX semantic, a private file descriptor is allocated to a task requiring to open a file, and contains mainly the current file pointer (called ''offset''). The max number of file descriptors is defined by the GIET_OPEN_FILES_MAX global variable (in the ''get_config.h'' file).
     27
     28 * The global Fat_Descriptor contains general information such as the FAT region lba and size, the DATA region lba and size, and pointers on the Fat-Cache or Inode-Tree.
     29
     30WARNING 1: A node name (file or directory) cannot be larger than 38 characters.
     31
     32WARNING 2: There is no rescue mechanism at the moment in case of heap overflow: The system crash with a nice error message on the kernel terminal...
    2633
    2734== 2) Cache Structure ==
     
    4350== 3) Write Policy ==
    4451
    45 For a '''file_cache''', the GIET_VM implements a WRITE-BACK policy. The data are always modified in the cache. In case of miss, new clusters are allocated to the target file, the cache is updated from the block device, and the data are modified in the cache, but not in the block device. The modified clusters are written on the block device only when the file is closed, using the dirty flag implemented in each cluster descriptor.
     52For the '''File_Cache''', the GIET_VM implements a WRITE-BACK policy. In case of write, the data are always modified in the cache. In case of miss, new clusters are allocated to the target file, the cache is updated from the block device, and the data are modified in the cache, but not on the block device. The modified clusters are written on the block device only when the file is closed, using the dirty flag implemented in each cluster descriptor.
    4653
    47 For the '''fat_cache''', the GIET_VM implements a WRITE-THROUGH policy. When the FAT content is modified
     54For the '''Fat_Cache''', the GIET_VM implements a WRITE-THROUGH policy. When the FAT content is modified
    4855(i.e. when new clusters are allocated to an existing file, or when a new file (or directory) is created, the modifications are written in the fat_cache (that must be updated in case of miss), and are immediately reported to the block device,
    4956for each modified block.
     
    5461
    5562=== int '''_fat_ioc_access'''( unsigned int use_irq ,  unsigned int to_mem ,  unsigned int lba , unsigned int buf_vaddr , unsigned int count ) ===
    56  * '''use_irq''' : boolean (RX transfer if non zero)
     63 * '''use_irq''' : boolean (use descheduling mode if supported by the IOC driver)
    5764 * '''to_mem''' : boolean (from block device to memory if non zero)
    5865 * '''lba''' : logical block address on block device
    5966 * '''buf_vaddr''' : memory buffer virtual address
    60  * ''' count''' : number of blocks to be transfered
     67 * ''' count''' : number of blocks to be transferred
     68
     69== 5) Access Functions ==
     70
     71=== int '''_fat_init'''( unsigned int use_irq ) ===
     72This function initializes the statically defined FAT structures:
     73 *  Fat-Descriptor
     74 *  File-Descriptors-Array
     75 *  Fat_Cache root
     76 *  Inode_Tree root
     77As is called by the boot-loader, and by the kernel_init, it does not use dynamic memory allocation.
     78The polling/descheduling mode is defined by the '''use_irq''' argument.
     79It use informations found in the boot sector and FS-INFO sector, that are loaded in the FAT 512 bytes buffer.
     80It returns 0 if success /  It returns -1 if failure.
     81
     82=== int '''_fat_open'''( unsigned int  use_irq , char* pathname ) ===
     83This function implements the giet_fat_open() system call.
     84The semantic is similar to the UNIX open() function, but the UNIX flags and access rights are not supported.
     85If the file does not exist in the specified directory, it is created, and both the Inode-Tree, the Fat-Cache and the FAT region
     86on device true are updated..
     87If the specified directory does not exist, an error is returned.
     88In case of success, It allocates a private file descriptor to the calling task, and the reference count is updated.
     89 * '''use_irq''' : boolean (use descheduling mode if supported by the IOC driver)
     90 * '''pathname''' : define both the specified directory and the file name.
     91It returns the file descriptor index if success / It returns -1 if failure.
     92
     93=== int '''_fat_close'''( unsigned int fd_id  ) ===
     94This function implements the "giet_fat_close()" system call.
     95The semantic is similar to the UNIX "close()" function.
     96It decrements the inode reference count, and release the fd_id entry in the file descriptors array.
     97If the reference count is zero, it writes all dirty clusters on block device, and releases the memory allocated to the file_cache.
     98 * '''fd_id''' : file descriptor index
     99It returns 0 if success /  It returns -1 if failure.
     100
     101