Changeset 656 for trunk/kernel/fs
- Timestamp:
- Dec 6, 2019, 12:07:51 PM (5 years ago)
- Location:
- trunk/kernel/fs
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/fs/fatfs.c
r647 r656 850 850 851 851 } // end fatfs_recursive_release() 852 853 854 ////////////////////////////////////////////////////////////////////////////////////////// 855 // This static function access the FAT (File Allocation Table), stored in the FAT mapper, 856 // and returns in <searched_cluster_id> the FATFS cluster_id for a given page of a given 857 // inode, identified by the <searched_page_id> argument, that is the page index in file 858 // (i.e. the page index in file mapper). The entry point in the FAT is defined by the 859 // <first_cluster_id> argument, that is the cluster_id of an already allocated cluster. 860 // It can be the cluster_id of the first page of the file (always registered in the 861 // fatfs_inode extension), or any page of the file whose <first_page_id> argument 862 // is smaller than the searched <first_page_id> argument. 863 // This function can be called by a thread running in any cluster, as it uses remote 864 // access primitives when the FAT mapper is remote. 865 // The FAT mapper being a WRITE-THROUGH cache, this function updates the FAT mapper 866 // from informations stored on IOC device in case of miss when scanning the FAT mapper. 867 // The searched inode mapper being a WRITE-BACK cache, this function allocates a new 868 // cluster_id when the searched page exist in the inode mapper, and there is no FATFS 869 // cluster allocated yet for this page. It updates the FAT, but it does NOT copy the 870 // mapper page content to the File System. 871 ////////////////////////////////////////////////////////////////////////////////////////// 872 // @ first_page_id : [in] index in file mapper for an existing page. 873 // @ first_cluster_id : [in] cluster_id for this existing page. 874 // @ searched_page_id : [in] index in file mapper for the searched page. 875 // @ searched_cluster_id : [out] cluster_id for the searched page. 876 // @ return 0 if success / return -1 if a FAT mapper miss cannot be solved, 877 // or if a missing cluster_id cannot be allocated. 878 ////////////////////////////////////////////////////////////////////////////////////////// 879 static error_t fatfs_get_cluster( uint32_t first_page_id, 880 uint32_t first_cluster_id, 881 uint32_t searched_page_id, 882 uint32_t * searched_cluster_id ) 883 { 884 uint32_t current_page_id; // index of page in file mapper 885 uint32_t current_cluster_id; // index of cluster in FATFS 886 xptr_t lock_xp; // extended pointer on FAT lock 887 888 assert( (searched_page_id > first_page_id) , 889 "searched_page_id must be larger than first_page_id\n"); 890 891 #if DEBUG_FATFS_GET_CLUSTER 892 uint32_t cycle = (uint32_t)hal_get_cycles(); 893 thread_t * this = CURRENT_THREAD; 894 if( DEBUG_FATFS_GET_CLUSTER < cycle ) 895 printk("\n[%s] thread[%x,%x] enter / first_cluster_id %x / searched_page_id %d / cycle %d\n", 896 __FUNCTION__, this->process->pid, this->trdid, first_cluster_id, searched_page_id, cycle ); 897 #endif 898 899 // get local pointer on VFS context (same in all clusters) 900 vfs_ctx_t * vfs_ctx = &fs_context[FS_TYPE_FATFS]; 901 902 // get local pointer on local FATFS context 903 fatfs_ctx_t * loc_fatfs_ctx = vfs_ctx->extend; 904 905 // get extended pointer and cluster on FAT mapper 906 xptr_t fat_mapper_xp = loc_fatfs_ctx->fat_mapper_xp; 907 cxy_t fat_cxy = GET_CXY( fat_mapper_xp ); 908 909 // get local pointer on FATFS context in FAT cluster 910 fatfs_ctx_t * fat_fatfs_ctx = hal_remote_lpt( XPTR( fat_cxy , &vfs_ctx->extend ) ); 911 912 // build extended pointer on FAT lock in FAT cluster 913 lock_xp = XPTR( fat_cxy , &fat_fatfs_ctx->lock ); 914 915 // take FAT lock in read mode 916 remote_rwlock_rd_acquire( lock_xp ); 917 918 // initialize loop variables 919 current_page_id = first_page_id; 920 current_cluster_id = first_cluster_id; 921 922 // scan FAT mapper (i.e. traverse FAT linked list) 923 // starting from first_page_id until searched_page_id 924 // each iteration in this loop can change both 925 // the FAT page index and the slot index in FAT 926 while( current_page_id < searched_page_id ) 927 { 928 // FAT mapper page and slot indexes (1024 slots per FAT page) 929 uint32_t fat_page_index = current_cluster_id >> 10; 930 uint32_t fat_slot_index = current_cluster_id & 0x3FF; 931 932 // get pointer on current page descriptor in FAT mapper 933 xptr_t current_page_xp = mapper_remote_get_page( fat_mapper_xp , fat_page_index ); 934 935 if( current_page_xp == XPTR_NULL ) 936 { 937 printk("\n[ERROR] in %s : cannot get page %d from FAT mapper\n", 938 __FUNCTION__ , fat_page_index ); 939 remote_rwlock_rd_release( lock_xp ); 940 return -1; 941 } 942 943 // get pointer on buffer containing the FAT mapper page 944 xptr_t base_xp = ppm_page2base( current_page_xp ); 945 uint32_t * buffer = (uint32_t *)GET_PTR( base_xp ); 946 947 // get next_cluster_id from FAT slot 948 uint32_t next_cluster_id = hal_remote_l32( XPTR( fat_cxy, &buffer[fat_slot_index] ) ); 949 950 // allocate a new FAT cluster when there is no cluster 951 // allocated on device for the current page 952 if( next_cluster_id >= END_OF_CHAIN_CLUSTER_MIN ) 953 { 954 // release the FAT lock in read mode, 955 remote_rwlock_rd_release( lock_xp ); 956 957 // allocate a new cluster_id (and update both FAT mapper and FAT on device). 958 error_t error = fatfs_cluster_alloc( &next_cluster_id ); 959 960 if( error ) 961 { 962 printk("\n[ERROR] in %s : cannot allocate cluster on FAT32 for page %d\n", 963 __FUNCTION__ , current_page_id ); 964 remote_rwlock_wr_release( lock_xp ); 965 return -1; 966 } 967 968 #if (DEBUG_FATFS_GET_CLUSTER & 1) 969 if( DEBUG_FATFS_GET_CLUSTER < cycle ) 970 printk("\n[%s] allocated a new cluster_id %d in FATFS\n", 971 __FUNCTION__, next_cluster_id ); 972 #endif 973 // take the FAT lock in read mode, 974 remote_rwlock_rd_acquire( lock_xp ); 975 } 976 977 #if (DEBUG_FATFS_GET_CLUSTER & 1) 978 if( DEBUG_FATFS_GET_CLUSTER < cycle ) 979 printk("\n[%s] traverse FAT / fat_page_index %d / fat_slot_index %d / next_cluster_id %x\n", 980 __FUNCTION__, fat_page_index, fat_slot_index , next_cluster_id ); 981 #endif 982 983 // update loop variables 984 current_cluster_id = next_cluster_id; 985 current_page_id++; 986 } 987 988 // release FAT lock 989 remote_rwlock_rd_release( lock_xp ); 990 991 #if DEBUG_FATFS_GET_CLUSTER 992 if( DEBUG_FATFS_GET_CLUSTER < cycle ) 993 printk("\n[%s] thread[%x,%x] exit / searched_cluster_id = %d\n", 994 __FUNCTION__, this->process->pid, this->trdid, current_cluster_id ); 995 #endif 996 997 *searched_cluster_id = current_cluster_id; 998 return 0; 999 1000 } // end fatfs_get_cluster() 1001 1002 1003 852 1004 853 1005 … … 904 1056 ////////////////////////////////////////// 905 1057 void fatfs_display_fat( uint32_t page_id, 906 uint32_t nentries ) 1058 uint32_t min_slot, 1059 uint32_t nb_slots ) 907 1060 { 908 1061 uint32_t line; 909 uint32_t maxline;910 1062 911 1063 // compute number of lines to display 912 maxline = nentries>> 3;913 if( nentries & 0x7 ) maxline++;1064 uint32_t min_line = min_slot >> 3; 1065 uint32_t max_line = (min_slot + nb_slots - 1) >> 3; 914 1066 915 1067 // get pointer on local FATFS context … … 917 1069 fatfs_ctx_t * loc_fatfs_ctx = (fatfs_ctx_t *)vfs_ctx->extend; 918 1070 919 // get extended pointer on FAT mapper 920 xptr_t fat_mapper_xp = loc_fatfs_ctx->fat_mapper_xp; 921 922 // get FAT cluster identifier 923 cxy_t fat_cxy = GET_CXY( fat_mapper_xp ); 1071 // get pointers on FAT mapper (in FAT cluster) 1072 xptr_t mapper_xp = loc_fatfs_ctx->fat_mapper_xp; 1073 cxy_t mapper_cxy = GET_CXY( mapper_xp ); 924 1074 925 1075 // get pointer on FATFS context in FAT cluster 926 fatfs_ctx_t * fat_fatfs_ctx = hal_remote_lpt( XPTR( fat_cxy , &vfs_ctx->extend ) );1076 fatfs_ctx_t * fat_fatfs_ctx = hal_remote_lpt( XPTR( mapper_cxy , &vfs_ctx->extend ) ); 927 1077 928 1078 // get current value of hint and free_clusters 929 uint32_t hint = hal_remote_l32( XPTR( fat_cxy , &fat_fatfs_ctx->free_cluster_hint ) );930 uint32_t free = hal_remote_l32( XPTR( fat_cxy , &fat_fatfs_ctx->free_clusters ) );931 932 // get extended pointer on requested page in FAT mapper933 xptr_t page_xp = mapper_remote_get_page( fat_mapper_xp , page_id );934 935 // get extended pointeron requested page base1079 uint32_t hint = hal_remote_l32( XPTR( mapper_cxy , &fat_fatfs_ctx->free_cluster_hint ) ); 1080 uint32_t free = hal_remote_l32( XPTR( mapper_cxy , &fat_fatfs_ctx->free_clusters ) ); 1081 1082 // get extended pointer on requested page descriptor in FAT mapper 1083 xptr_t page_xp = mapper_remote_get_page( mapper_xp , page_id ); 1084 1085 // get pointers on requested page base 936 1086 xptr_t base_xp = ppm_page2base( page_xp ); 937 1087 void * base = GET_PTR( base_xp ); 938 1088 939 1089 printk("\n***** FAT mapper / cxy %x / page_id %d / base %x / free_clusters %x / hint %x\n", 940 fat_cxy, page_id, base, free, hint );941 942 for( line = 0 ; line < maxline ; line++ )943 { 944 printk("% x: %X | %X | %X | %X | %X | %X | %X | %X\n", (line<<3),1090 mapper_cxy, page_id, base, free, hint ); 1091 1092 for( line = min_line ; line <= max_line ; line++ ) 1093 { 1094 printk("%d : %X | %X | %X | %X | %X | %X | %X | %X\n", (line<<3), 945 1095 hal_remote_l32( base_xp + ((line<<5) ) ), 946 1096 hal_remote_l32( base_xp + ((line<<5) + 4 ) ), … … 954 1104 955 1105 } // end fatfs_display_fat() 956 957 ///////////////////////////////////////////////////////958 error_t fatfs_get_cluster( uint32_t first_cluster_id,959 uint32_t searched_page_index,960 uint32_t * searched_cluster_id )961 {962 xptr_t current_page_xp; // pointer on current page descriptor963 uint32_t * buffer; // pointer on current page (array of uint32_t)964 uint32_t current_page_index; // index of current page in FAT965 uint32_t current_slot_index; // index of slot in current page966 uint32_t page_count_in_file; // index of page in file (index in linked list)967 uint32_t next_cluster_id; // content of current FAT slot968 xptr_t lock_xp; // extended pointer on FAT lock969 970 assert( (searched_page_index > 0) ,971 "no FAT access required for first page\n");972 973 #if DEBUG_FATFS_GET_CLUSTER974 uint32_t cycle = (uint32_t)hal_get_cycles();975 thread_t * this = CURRENT_THREAD;976 if( DEBUG_FATFS_GET_CLUSTER < cycle )977 printk("\n[%s] thread[%x,%x] enter / first_cluster_id %d / searched_index %d / cycle %d\n",978 __FUNCTION__, this->process->pid, this->trdid, first_cluster_id, searched_page_index, cycle );979 #endif980 981 // get local pointer on VFS context (same in all clusters)982 vfs_ctx_t * vfs_ctx = &fs_context[FS_TYPE_FATFS];983 984 // get local pointer on local FATFS context985 fatfs_ctx_t * loc_fatfs_ctx = vfs_ctx->extend;986 987 // get extended pointer and cluster on FAT mapper988 xptr_t fat_mapper_xp = loc_fatfs_ctx->fat_mapper_xp;989 cxy_t fat_cxy = GET_CXY( fat_mapper_xp );990 991 // get local pointer on FATFS context in FAT cluster992 fatfs_ctx_t * fat_fatfs_ctx = hal_remote_lpt( XPTR( fat_cxy , &vfs_ctx->extend ) );993 994 // build extended pointer on FAT lock in FAT cluster995 lock_xp = XPTR( fat_cxy , &fat_fatfs_ctx->lock );996 997 // take FAT lock in read mode998 remote_rwlock_rd_acquire( lock_xp );999 1000 // initialize loop variable (1024 slots per page)1001 current_page_index = first_cluster_id >> 10;1002 current_slot_index = first_cluster_id & 0x3FF;1003 page_count_in_file = 0;1004 next_cluster_id = 0xFFFFFFFF;1005 1006 // scan FAT mapper (i.e. traverse FAT linked list)1007 while( page_count_in_file < searched_page_index )1008 {1009 // get pointer on current page descriptor in FAT mapper1010 current_page_xp = mapper_remote_get_page( fat_mapper_xp , current_page_index );1011 1012 if( current_page_xp == XPTR_NULL )1013 {1014 printk("\n[ERROR] in %s : cannot get next page from FAT mapper\n", __FUNCTION__);1015 remote_rwlock_rd_release( lock_xp );1016 return -1;1017 }1018 1019 // get pointer on buffer for current page1020 xptr_t base_xp = ppm_page2base( current_page_xp );1021 buffer = (uint32_t *)GET_PTR( base_xp );1022 1023 // get FAT slot content1024 next_cluster_id = hal_remote_l32( XPTR( fat_cxy, &buffer[current_slot_index] ) );1025 1026 #if (DEBUG_FATFS_GET_CLUSTER & 1)1027 if( DEBUG_FATFS_GET_CLUSTER < cycle )1028 printk("\n[%s] traverse FAT / current_page_index = %d\n"1029 "current_slot_index = %d / next_cluster_id = %d\n",1030 __FUNCTION__, current_page_index, current_slot_index , next_cluster_id );1031 #endif1032 // update loop variables1033 current_page_index = next_cluster_id >> 10;1034 current_slot_index = next_cluster_id & 0x3FF;1035 page_count_in_file++;1036 }1037 1038 if( next_cluster_id == 0xFFFFFFFF )1039 {1040 printk("\n[ERROR] in %s : searched_cluster_id not found in FAT\n", __FUNCTION__ );1041 remote_rwlock_rd_release( lock_xp );1042 return -1;1043 }1044 1045 // release FAT lock1046 remote_rwlock_rd_release( lock_xp );1047 1048 #if DEBUG_FATFS_GET_CLUSTER1049 cycle = (uint32_t)hal_get_cycles();1050 if( DEBUG_FATFS_GET_CLUSTER < cycle )1051 printk("\n[%s] thread[%x,%x] exit / searched_cluster_id = %d / cycle %d\n",1052 __FUNCTION__, this->process->pid, this->trdid, next_cluster_id / cycle );1053 #endif1054 1055 *searched_cluster_id = next_cluster_id;1056 return 0;1057 1058 } // end fatfs_get_cluster()1059 1106 1060 1107 … … 1691 1738 // by the <mapper> argument, to find the directory entry identified by the <name> argument, 1692 1739 // and return a pointer on the directory entry, described as and array of 32 bytes, and the 1693 // in cex of this entry in the FAT32 mapper, seen as an array of 32 bytes entries.1740 // index of this entry in the FAT32 mapper, seen as an array of 32 bytes entries. 1694 1741 // It is called by the fatfs_new_dentry() and fatfs_update_dentry() functions. 1695 1742 // It must be called by a thread running in the cluster containing the mapper. … … 1701 1748 // @ return 0 if found / return 1 if not found / return -1 if mapper access error. 1702 1749 ////////////////////////////////////////////////////////////////////////////////////////////// 1703 error_t fatfs_scan_directory( mapper_t * mapper,1704 char * name,1705 uint8_t ** entry,1706 uint32_t * index )1750 static error_t fatfs_scan_directory( mapper_t * mapper, 1751 char * name, 1752 uint8_t ** entry, 1753 uint32_t * index ) 1707 1754 { 1708 1755 // Two embedded loops to scan the directory mapper: … … 1725 1772 #endif 1726 1773 1727 char cname[CONFIG_VFS_MAX_NAME_LENGTH]; // name extracted from eachdirectory entry1774 char cname[CONFIG_VFS_MAX_NAME_LENGTH]; // name extracted from directory entry 1728 1775 1729 1776 char lfn1[16]; // buffer for one partial cname … … 1761 1808 #if (DEBUG_FATFS_SCAN_DIRECTORY & 0x1) 1762 1809 if( DEBUG_FATFS_SCAN_DIRECTORY < cycle ) 1763 mapper_display_page( mapper_xp , page_ id, 256 );1810 mapper_display_page( mapper_xp , page_xp , 256 ); 1764 1811 #endif 1765 1812 // scan this page until end of directory, end of page, or name found … … 1883 1930 error_t error; 1884 1931 1885 char dir_name[CONFIG_VFS_MAX_NAME_LENGTH];1932 char parent_name[CONFIG_VFS_MAX_NAME_LENGTH]; 1886 1933 1887 1934 // check arguments … … 1900 1947 assert( (xlist_is_empty( root_xp ) == false ), "child inode must have one parent\n"); 1901 1948 1902 #if DEBUG_FATFS_ GET_DENTRY1949 #if DEBUG_FATFS_NEW_DENTRY 1903 1950 uint32_t cycle = (uint32_t)hal_get_cycles(); 1904 1951 thread_t * this = CURRENT_THREAD; 1905 vfs_inode_get_name( XPTR( local_cxy , parent_inode ) , dir_name );1906 if( DEBUG_FATFS_ GET_DENTRY < cycle )1952 vfs_inode_get_name( XPTR( local_cxy , parent_inode ) , parent_name ); 1953 if( DEBUG_FATFS_NEW_DENTRY < cycle ) 1907 1954 printk("\n[%s] thread[%x,%x] enter for child <%s> in parent <%s> / cycle %d\n", 1908 __FUNCTION__, this->process->pid, this->trdid, name , dir_name , cycle );1955 __FUNCTION__, this->process->pid, this->trdid, name , parent_name , cycle ); 1909 1956 #endif 1910 1957 … … 1916 1963 1917 1964 // return non fatal error if not found 1918 if( error ) return -1; 1965 if( error ) 1966 { 1967 vfs_inode_get_name( XPTR( local_cxy , parent_inode ) , parent_name ); 1968 printk("\n[ERROR] in %s : cannot find <%s> entry in <%s> directory mapper\n", 1969 __FUNCTION__, name , parent_name, name ); 1970 return -1; 1971 } 1972 1919 1973 1920 1974 // get relevant infos from FAT32 directory entry … … 1946 2000 if( found == false ) 1947 2001 { 1948 vfs_inode_get_name( XPTR( local_cxy , parent_inode ) , dir_name );2002 vfs_inode_get_name( XPTR( local_cxy , parent_inode ) , parent_name ); 1949 2003 printk("\n[ERROR] in %s : cannot find <%s> directory in list of parents for <%s>\n", 1950 __FUNCTION__, dir_name, name );2004 __FUNCTION__, parent_name, name ); 1951 2005 return -1; 1952 2006 } … … 1962 2016 dentry_ptr->extend = (void *)(intptr_t)index; 1963 2017 1964 #if DEBUG_FATFS_ GET_DENTRY2018 #if DEBUG_FATFS_NEW_DENTRY 1965 2019 cycle = (uint32_t)hal_get_cycles(); 1966 if( DEBUG_FATFS_GET_DENTRY < cycle ) 1967 printk("\n[%s] thread[%x,%x] exit / intialised inode & dentry for <%s> in <%s> / cycle %d\n", 1968 __FUNCTION__, this->process->pid, this->trdid, name, dir_name, cycle ); 2020 if( DEBUG_FATFS_NEW_DENTRY < cycle ) 2021 printk("\n[%s] thread[%x,%x] exit for <%s> in <%s> / cluster_id %x / size %d / cycle %d\n", 2022 __FUNCTION__, this->process->pid, this->trdid, name, parent_name, cluster, size, cycle ); 2023 #endif 2024 2025 2026 #if (DEBUG_FATFS_NEW_DENTRY & 1) 2027 if( DEBUG_FATFS_NEW_DENTRY < cycle ) 2028 { 2029 fatfs_display_fat( 0 , 0 , 64 ); 2030 fatfs_display_fat( cluster >> 10 , (cluster & 0x3FF) , 32 ); 2031 } 1969 2032 #endif 1970 2033 … … 1988 2051 assert( (inode != NULL) , "inode is NULL\n" ); 1989 2052 assert( (dentry != NULL) , "dentry is NULL\n" ); 1990 assert( (size != 0 ) , "size is 0\n" );1991 2053 1992 2054 #if DEBUG_FATFS_UPDATE_DENTRY … … 2013 2075 } 2014 2076 2015 // set size in FAT32 directory entry 2016 fatfs_set_record( DIR_FILE_SIZE , entry , size ); 2017 2018 // get local pointer on modified page base 2019 void * base = (void *)((intptr_t)entry & (~CONFIG_PPM_PAGE_MASK)); 2020 2021 // get extended pointer on modified page descriptor 2022 xptr_t page_xp = ppm_base2page( XPTR( local_cxy , base ) ); 2023 2024 // synchronously update the modified page on device 2025 error = fatfs_move_page( page_xp , IOC_SYNC_WRITE ); 2026 2027 if( error ) 2028 { 2029 vfs_inode_get_name( XPTR( local_cxy , inode ) , dir_name ); 2030 printk("\n[ERROR] in %s : cannot update parent directory <%s> on device\n", 2031 __FUNCTION__, dir_name ); 2032 return -1; 2077 // get current size value 2078 uint32_t current_size = fatfs_get_record( DIR_FILE_SIZE , entry ); 2079 2080 // update dentry in mapper & device only if required 2081 if( size != current_size ) 2082 { 2083 // set size field in FAT32 directory entry 2084 fatfs_set_record( DIR_FILE_SIZE , entry , size ); 2085 2086 // get pointer on modified page base 2087 void * base = (void *)((intptr_t)entry & (~CONFIG_PPM_PAGE_MASK)); 2088 2089 // get extended pointer on modified page descriptor 2090 xptr_t page_xp = ppm_base2page( XPTR( local_cxy , base ) ); 2091 2092 // synchronously update the modified page on device 2093 error = fatfs_move_page( page_xp , IOC_SYNC_WRITE ); 2094 2095 if( error ) 2096 { 2097 vfs_inode_get_name( XPTR( local_cxy , inode ) , dir_name ); 2098 printk("\n[ERROR] in %s : cannot update parent directory <%s> on device\n", 2099 __FUNCTION__, dir_name ); 2100 return -1; 2101 } 2033 2102 } 2034 2103 … … 2586 2655 return 0; 2587 2656 2588 } // end fat _cluster_alloc()2657 } // end fatfs_cluster_alloc() 2589 2658 2590 2659 ////////////////////////////////////////////// … … 2737 2806 #endif 2738 2807 2739 // get page cluster an local pointer2808 // get page cluster and local pointer 2740 2809 cxy_t page_cxy = GET_CXY( page_xp ); 2741 2810 page_t * page_ptr = GET_PTR( page_xp ); … … 2754 2823 inode_ptr = hal_remote_lpt( XPTR( page_cxy , &mapper_ptr->inode ) ); 2755 2824 2825 ////////////////////////////// FAT mapper ///////////////////////////////////////// 2826 if( inode_ptr == NULL ) 2827 { 2828 2756 2829 #if DEBUG_FATFS_MOVE_PAGE 2757 2830 if( DEBUG_FATFS_MOVE_PAGE < cycle ) 2758 printk("\n[%s] thread[%x,%x] enters : %s / cxy %x / mapper %x / inode %x / page %x\n", 2759 __FUNCTION__, this->process->pid, this->trdid, 2760 dev_ioc_cmd_str( cmd_type ), page_cxy, mapper_ptr, inode_ptr, GET_PTR(buffer_xp) ); 2761 #endif 2762 2763 ////////////////////////////// FAT mapper 2764 if( inode_ptr == NULL ) 2765 { 2831 printk("\n[%s] thread[%x,%x] enters for %s / page %d in FAT mapper / cycle %d\n", 2832 __FUNCTION__, this->process->pid, this->trdid, dev_ioc_cmd_str(cmd_type), page_id, cycle ); 2833 #endif 2766 2834 // get lba from FATFS context and page_id 2767 2835 uint32_t lba = fatfs_ctx->fat_begin_lba + (page_id << 3); … … 2778 2846 #if DEBUG_FATFS_MOVE_PAGE 2779 2847 if( DEBUG_FATFS_MOVE_PAGE < cycle ) 2780 { 2781 if ( (cmd_type == IOC_READ) || (cmd_type == IOC_SYNC_READ) ) 2782 printk("\n[%s] thread[%x,%x] load FAT mapper page %d from IOC / cycle %d\n", 2783 __FUNCTION__, this->process->pid, this->trdid, page_id, cycle ); 2784 else 2785 printk("\n[%s] thread[%x,%x] sync FAT mapper page %d to IOC / cycle %d\n", 2786 __FUNCTION__, this->process->pid, this->trdid, page_id, cycle ); 2787 } 2788 #endif 2789 2790 } 2791 ///////////////////////// inode mapper 2848 printk("\n[%s] thread[%x,%x] exit / page %d in FAT mapper\n", 2849 __FUNCTION__, this->process->pid, this->trdid, page_id, cycle ); 2850 #endif 2851 2852 } 2853 ///////////////////////// inode mapper //////////////////////////////////////////// 2792 2854 else 2793 2855 { … … 2795 2857 #if DEBUG_FATFS_MOVE_PAGE 2796 2858 vfs_inode_get_name( XPTR( page_cxy , inode_ptr ) , name ); 2797 #endif 2798 2799 uint32_t searched_cluster; 2800 uint32_t first_cluster; 2801 2802 // get first_cluster from inode extension 2803 void * extend = hal_remote_lpt( XPTR( page_cxy , &inode_ptr->extend ) ); 2804 first_cluster = (uint32_t)(intptr_t)extend; 2805 2806 // compute searched_cluster 2859 if( DEBUG_FATFS_MOVE_PAGE < cycle ) 2860 printk("\n[%s] thread[%x,%x] enters for %s / page %d in <%s> mapper/ cycle %d\n", 2861 __FUNCTION__, this->process->pid, this->trdid, 2862 dev_ioc_cmd_str( cmd_type ), page_id, name, cycle ); 2863 #endif 2864 2865 uint32_t searched_cluster_id; 2866 uint32_t first_cluster_id; 2867 2868 // get first_cluster_id from inode extension 2869 void * extend = hal_remote_lpt( XPTR( page_cxy , &inode_ptr->extend ) ); 2870 first_cluster_id = (uint32_t)(intptr_t)extend; 2871 2872 // compute searched_cluster_id 2807 2873 if( page_id == 0 ) // no need to access FAT mapper 2808 2874 { 2809 2875 // searched cluster is first cluster 2810 searched_cluster = first_cluster;2876 searched_cluster_id = first_cluster_id; 2811 2877 } 2812 2878 else // FAT mapper access required 2813 2879 { 2814 // access FAT mapper to get searched cluster 2815 error = fatfs_get_cluster( first_cluster, 2880 // scan FAT mapper to get searched_cluster_id 2881 error = fatfs_get_cluster( 0, // first page in mapper 2882 first_cluster_id, 2816 2883 page_id, 2817 &searched_cluster );2884 &searched_cluster_id ); 2818 2885 if( error ) 2819 2886 { 2820 printk("\n[ERROR] in %s : cannot access FAT mapper\n", __FUNCTION__ );2887 printk("\n[ERROR] in %s : cannot get cluster_id\n", __FUNCTION__ ); 2821 2888 return -1; 2822 2889 } … … 2824 2891 2825 2892 // get lba for searched_cluster 2826 uint32_t lba = fatfs_lba_from_cluster( fatfs_ctx , searched_cluster );2827 2828 // access IOC device 2893 uint32_t lba = fatfs_lba_from_cluster( fatfs_ctx , searched_cluster_id ); 2894 2895 // access IOC device to move 8 blocks 2829 2896 error = dev_ioc_move_data( cmd_type , buffer_xp , lba , 8 ); 2830 2897 … … 2837 2904 #if DEBUG_FATFS_MOVE_PAGE 2838 2905 if( DEBUG_FATFS_MOVE_PAGE < cycle ) 2839 { 2840 if ( (cmd_type == IOC_READ) || (cmd_type == IOC_SYNC_READ) ) 2841 printk("\n[%s] thread[%x,%x] load page %d of <%s> / cluster_id %x / cycle %d\n", 2842 __FUNCTION__, this->process->pid, this->trdid, page_id, name, searched_cluster, cycle ); 2843 else 2844 printk("\n[%s] thread[%x,%x] sync page %d of <%s> / cluster_id %x / cycle %d\n", 2845 __FUNCTION__, this->process->pid, this->trdid, page_id, name, searched_cluster, cycle ); 2846 } 2906 vfs_inode_get_name( XPTR( page_cxy, inode_ptr ) , name ); 2907 printk("\n[%s] thread[%x,%x] exit / page %d in <%s> mapper / cluster_id %x\n", 2908 __FUNCTION__, this->process->pid, this->trdid, page_id, name, searched_cluster_id ); 2847 2909 #endif 2848 2910 -
trunk/kernel/fs/fatfs.h
r638 r656 32 32 33 33 34 /************************************************************************************** 34 /****************************************************************************************** 35 35 * The FATFS File System implements a FAT32 read/write file system. 36 36 * … … 43 43 * on the FAT mapper. 44 44 * 2) The vfs_inode_t "extend" contains, for each inode, 45 * the first FAT cluster index(after cast to intptr).45 * the first FAT32 cluster_id (after cast to intptr). 46 46 * 3) The vfs_dentry_t "extend" field contains, for each dentry, the entry index 47 * in the FATFS directory (32 bytes per FATFS entry). 48 *************************************************************************************/ 47 * in the FATFS directory (32 bytes per FATFS directory entry). 48 * 49 * In the FAT32 File System, the File Allocation Table is is actually an array 50 * of uint32_t slots. Each slot in this array contains the index (called cluster_id) 51 * of another slot in this array, to form one linked list for each file stored on 52 * device in the FAT32 File System. This index in the FAT array is also the index of 53 * the FATFS cluster on the device. One FATFS cluster is supposed to contain one PPM page. 54 * For a given file, the entry point in the FAT is the cluster_id of the FATFS cluster 55 * containing the first page of the file, but it can be any cluster_id already allocated 56 * to the file. 57 *****************************************************************************************/ 49 58 50 59 /////////////////////////////////////////////////////////////////////////////////////////// … … 213 222 214 223 /***************************************************************************************** 215 * This function access the FAT (File Allocation Table), stored in the FAT mapper, and 216 * returns in <searched_cluster> the FATFS cluster index for a given page of a given 217 * inode identified by the <first_cluster> and <page_id> arguments. 218 * It can be called by a thread running in any cluster, as it uses remote access 219 * primitives when the FAT mapper is remote. 220 * The FAT is actually an array of uint32_t slots. Each slot in this array contains the 221 * index of another slot in this array, to form one linked list for each file stored on 222 * device in the FATFS file system. This index in the FAT array is also the index of the 223 * FATFS cluster on the device. One FATFS cluster is supposed to contain one PPM page. 224 * For a given file, the entry point in the FAT is simply the index of the FATFS cluster 225 * containing the first page of the file. The FAT mapper being a cache, this function 226 * updates the FAT mapper from informations stored on IOC device in case of miss. 227 ***************************************************************************************** 228 * @ first_cluster : [in] index of first FATFS cluster allocated to the file. 229 * @ page_id : [in] index of searched page in file. 230 * @ searched_cluster : [out] found FATFS cluster index. 231 * @ return 0 if success / return -1 if a FAT mapper miss cannot be solved. 232 ****************************************************************************************/ 233 error_t fatfs_get_cluster( uint32_t first_cluster, 234 uint32_t page_id, 235 uint32_t * searched_cluster ); 236 237 /***************************************************************************************** 238 * This function display the content of the FATFS context copy in cluster identified 239 * by the <cxy> argument. 224 * This debug function display the content of the FATFS context copy in cluster 225 * identified by the <cxy> argument. 240 226 * This function can be called by a thread running in any cluster. 241 227 ***************************************************************************************** … … 245 231 246 232 /***************************************************************************************** 247 * This function access the FAT mapper to display one page of the File Allocation Table. 248 * It loads the requested page fom IOC device to FAT mapper if required. 233 * This debug function access the FAT mapper to display the current FAT state, 234 * as defined by the <page_id>, <min_slot>, and <nb_slots> arguments. 235 * It loads the missing pages from IOC to mapper if required. 249 236 * This function can be called by a thread running in any cluster. 250 237 ***************************************************************************************** 251 * @ page_id : page index in FAT mapper (one page is 4 Kbytes). 252 * @ nb_entries : number of entries (one entry is 4 bytes). 238 * @ page_id : page index in FAT mapper (one page is 4 Kbytes = 1024 slots). 239 * @ min_slot : first slot in page 240 * @ nb_slots : number of slots (one slot is 4 bytes). 253 241 ****************************************************************************************/ 254 242 void fatfs_display_fat( uint32_t page_id, 255 uint32_t nb_entries ); 243 uint32_t min_slot, 244 uint32_t nb_slots ); 256 245 257 246 … … 330 319 ***************************************************************************************** 331 320 * It scan a parent directory mapper, identified by the <parent_inode> argument to find 332 * a directory entry identified by the <name> argument. In case of success, it 333 * initializ es the inode/dentry couple, identified by the <child_inode_xp> argument334 * in the Inode Tree. The child inode descriptor, and the associated dentry descriptor335 * must have beenpreviously allocated by the caller.321 * a directory entry identified by the <name> argument. In case of success, it completes 322 * initialization the inode/dentry couple, identified by the <child_inode_xp> argument. 323 * The child inode descriptor, and the associated dentry descriptor must have been 324 * previously allocated by the caller. 336 325 * - It set the "type", "size", and "extend" fields in the child inode descriptor. 337 326 * - It set the " extend" field in the dentry descriptor. … … 421 410 * TODO : the current implementation check ALL pages in the FAT region, even if most 422 411 * pages are empty, and not copied in mapper. It is sub-optimal. 423 * - A firstsolution is to maintain in the FAT context two "dirty_min" and "dirty_max"424 * 412 * A solution is to maintain in the FAT context two "dirty_min" and "dirty_max" 413 * variables defining the smallest/largest dirty page index in FAT mapper... 425 414 ***************************************************************************************** 426 415 * @ return 0 if success / return -1 if failure during IOC device access. … … 448 437 * in <searched_cluster> the FATFS cluster index of a free cluster. 449 438 * It can be called by a thread running in any cluster, as it uses remote access 450 * primitives when the FAT mapper is remote. It takes the queuelock stored in the FATFS439 * primitives when the FAT mapper is remote. It takes the rwlock stored in the FATFS 451 440 * context located in the same cluster as the FAT mapper itself, to get exclusive 452 441 * access to the FAT. It uses and updates the <free_cluster_hint> and <free_clusters> … … 457 446 * - it returns the allocated cluster index. 458 447 ***************************************************************************************** 459 * @ searched_cluster : [out] found FATFS cluster index.448 * @ searched_cluster_id : [out] allocated FATFS cluster index. 460 449 * @ return 0 if success / return -1 if no more free clusters on IOC device. 461 450 ****************************************************************************************/ 462 error_t fatfs_cluster_alloc( uint32_t * searched_cluster );451 error_t fatfs_cluster_alloc( uint32_t * searched_cluster_id ); 463 452 464 453 /***************************************************************************************** 465 454 * This function implements the generic vfs_fs_release_inode() function for the FATFS. 466 ***************************************************************************************** 455 ***************************************************************************************** 456 * This function is used to remove a given file or directory from FATFS the file system. 467 457 * It releases all clusters allocated to a file/directory identified by the <inode_xp> 468 458 * argument. All released clusters are marked FREE_CLUSTER in the FAT mapper. … … 470 460 * the clusters in reverse order of the linked list (from last to first). 471 461 * When the FAT mapper has been updated, it calls the fatfs_sync_fat() function to 472 * synchronously update all dirtypages in the FAT mapper to the IOC device.462 * synchronously update all modified pages in the FAT mapper to the IOC device. 473 463 * Finally the FS-INFO sector on the IOC device is updated. 474 464 ***************************************************************************************** … … 485 475 * The pointer on the mapper and the page index in file are found in the page descriptor. 486 476 * It is used for both a regular file/directory mapper, and the FAT mapper. 487 * - For the FAT mapper, it updates the FAT region on IOC device. 488 * - For a regular file, it access the FAT mapper to get the cluster index on IOC device. 477 * - For the FAT mapper, it read/write the FAT region on IOC device. 478 * - For a regular file, it scan the FAT mapper to get the cluster_id on IOC device, 479 * and read/write this cluster. 489 480 * It can be called by any thread running in any cluster. 490 481 * 491 482 * WARNING : For the FAT mapper, the inode field in the mapper MUST be NULL, as this 492 * is used to indicate that the corresponding mapper is the FAT mapper. 483 * is used to indicate that the corresponding mapper is the FAT mapper. 484 * 485 * TODO : In this first implementation, the entry point in the FAT to get the cluster_id 486 * is always the cluster_id of the first page, registered in the inode extension. 487 * This can introduce a quadratic cost when trying of acessing all pages of a 488 * big file. An optimisation would be to introduce in the inode extension two 489 * new fields <other_page_id> & <other_cluster_id>, defining a second entry point 490 * in the FAT. 493 491 ***************************************************************************************** 494 492 * @ page_xp : extended pointer on page descriptor. -
trunk/kernel/fs/vfs.c
r651 r656 235 235 236 236 #if DEBUG_VFS_INODE_CREATE 237 char name[CONFIG_VFS_MAX_NAME_LENGTH];238 237 uint32_t cycle = (uint32_t)hal_get_cycles(); 239 238 thread_t * this = CURRENT_THREAD; 240 vfs_inode_get_name( *inode_xp , name );241 239 if( DEBUG_VFS_INODE_CREATE < cycle ) 242 printk("\n[%s] thread[%x,%x] created <%s> / inode [%x,%x]/ cycle %d\n",243 __FUNCTION__, this->process->pid, this->trdid, name,local_cxy, inode, cycle );240 printk("\n[%s] thread[%x,%x] created inode (%x,%x) / cycle %d\n", 241 __FUNCTION__, this->process->pid, this->trdid, local_cxy, inode, cycle ); 244 242 #endif 245 243 … … 513 511 uint32_t cycle = (uint32_t)hal_get_cycles(); 514 512 if( DEBUG_VFS_DENTRY_CREATE < cycle ) 515 printk("\n[%s] thread[%x,%x] created <%s> / dentry [%x,%x]/ cycle %d\n",513 printk("\n[%s] thread[%x,%x] created dentry <%s> : (%x,%x) / cycle %d\n", 516 514 __FUNCTION__, this->process->pid, this->trdid, name, local_cxy, dentry, cycle ); 517 515 #endif … … 777 775 } // end vfs_open() 778 776 779 ////////////////////////////////////// 780 int vfs_user_move( bool_t to_buffer, 781 xptr_t file_xp, 782 void * buffer, 783 uint32_t size ) 784 { 785 cxy_t file_cxy; // remote file descriptor cluster 786 vfs_file_t * file_ptr; // remote file descriptor local pointer 787 vfs_inode_type_t inode_type; 788 uint32_t file_offset; // current offset in file 789 mapper_t * mapper; 777 /////////////////////////////////////////// 778 uint32_t vfs_user_move( bool_t to_buffer, 779 xptr_t file_xp, 780 void * buffer, 781 uint32_t count ) 782 { 783 cxy_t file_cxy; // remote file descriptor cluster 784 vfs_file_t * file_ptr; // remote file descriptor local pointer 785 mapper_t * mapper; // local pointer on file mapper 786 vfs_inode_t * inode; // local pointer on file inode 787 vfs_inode_type_t type; // inode type 788 uint32_t offset; // current offset in file 789 uint32_t size; // current file size 790 uint32_t nbytes; // number of bytes actually transfered 790 791 error_t error; 791 792 … … 797 798 file_ptr = GET_PTR( file_xp ); 798 799 799 // get inode type from remote file descriptor 800 inode_type = hal_remote_l32( XPTR( file_cxy , &file_ptr->type ) ); 800 // get various infos from remote file descriptor 801 type = hal_remote_l32( XPTR( file_cxy , &file_ptr->type ) ); 802 offset = hal_remote_l32( XPTR( file_cxy , &file_ptr->offset ) ); 803 mapper = hal_remote_lpt( XPTR( file_cxy , &file_ptr->mapper ) ); 804 inode = hal_remote_lpt( XPTR( file_cxy , &file_ptr->inode ) ); 805 size = hal_remote_l32( XPTR( file_cxy , &inode->size ) ); 801 806 802 807 // check inode type 803 assert( (inode_type == INODE_TYPE_FILE), "bad inode type" ); 804 805 // get mapper pointer and file offset from file descriptor 806 file_offset = hal_remote_l32( XPTR( file_cxy , &file_ptr->offset ) ); 807 mapper = hal_remote_lpt( XPTR( file_cxy , &file_ptr->mapper ) ); 808 assert( (type == INODE_TYPE_FILE), "bad inode type" ); 808 809 809 810 #if DEBUG_VFS_USER_MOVE … … 811 812 uint32_t cycle = (uint32_t)hal_get_cycles(); 812 813 thread_t * this = CURRENT_THREAD; 813 vfs_inode_t * inode = hal_remote_lpt( XPTR( file_cxy , &file_ptr->inode ) );814 814 vfs_inode_get_name( XPTR( file_cxy , inode ) , name ); 815 815 if( cycle > DEBUG_VFS_USER_MOVE ) … … 817 817 if( to_buffer ) 818 818 printk("\n[%s] thread[%x,%x] enter / %d bytes / map(%s) -> buf(%x) / offset %d / cycle %d\n", 819 __FUNCTION__ , this->process->pid, this->trdid, size, name, buffer, file_offset, cycle );819 __FUNCTION__ , this->process->pid, this->trdid, count, name, buffer, offset, cycle ); 820 820 else 821 821 printk("\n[%s] thread[%x,%x] enter / %d bytes / buf(%x) -> map(%s) / offset %d / cycle %d\n", 822 __FUNCTION__ , this->process->pid, this->trdid, size, buffer, name, file_offset, cycle );822 __FUNCTION__ , this->process->pid, this->trdid, count, buffer, name, offset, cycle ); 823 823 } 824 824 #endif 825 825 826 // move data between mapper and buffer 827 error = mapper_move_user( XPTR( file_cxy , mapper ), 828 to_buffer, 829 file_offset, 830 buffer, 831 size ); 826 if( to_buffer ) // => compute the number of bytes to move and make the move 827 { 828 // compute number of bytes to move 829 if ( size <= offset ) nbytes = 0; 830 else if( size < offset + count ) nbytes = size - offset; 831 else nbytes = count; 832 833 // move data from mapper to buffer when required 834 if( nbytes > 0 ) 835 { 836 error = mapper_move_user( XPTR( file_cxy , mapper ), 837 to_buffer, 838 offset, 839 buffer, 840 nbytes ); 841 } 842 else 843 { 844 error = 0; 845 } 846 } 847 else // to mapper => make the move and update the file size if required 848 { 849 nbytes = count; 850 851 // move data from buffer to mapper 852 error = mapper_move_user( XPTR( file_cxy , mapper ), 853 to_buffer, 854 offset, 855 buffer, 856 count ); 857 858 // update file size in inode if required 859 if( offset + count > size ) 860 { 861 vfs_inode_update_size( XPTR( file_cxy , inode ) , offset + count ); 862 } 863 } 864 832 865 if( error ) 833 866 { … … 837 870 838 871 // update file offset in file descriptor 839 hal_remote_atomic_add( XPTR( file_cxy , &file_ptr->offset ) , size);872 hal_remote_atomic_add( XPTR( file_cxy , &file_ptr->offset ) , nbytes ); 840 873 841 874 #if DEBUG_VFS_USER_MOVE … … 844 877 { 845 878 if( to_buffer ) 846 printk("\n[%s] thread[%x,%x] exit / cycle %d\n",847 __FUNCTION__ , this->process->pid, cycle);879 printk("\n[%s] thread[%x,%x] exit / %d bytes moved from mapper to buffer\n", 880 __FUNCTION__ , this->process->pid, nbytes ); 848 881 else 849 printk("\n[%s] thread[%x,%x] exit / cycle %d\n",850 __FUNCTION__ , this->process->pid, cycle);882 printk("\n[%s] thread[%x,%x] exit / %d bytes moved from buffer to mapper / size %d\n", 883 __FUNCTION__ , this->process->pid, nbytes, hal_remote_l32(XPTR(file_cxy,&inode->size)) ); 851 884 } 852 885 #endif 853 886 854 return size;887 return nbytes; 855 888 856 889 } // end vfs_user_move() … … 2483 2516 #endif 2484 2517 2518 #if ( DEBUG_VFS_LOOKUP & 1 ) 2519 if( DEBUG_VFS_LOOKUP < cycle ) 2520 vfs_display( root_xp ); 2521 #endif 2522 2485 2523 // compute lookup flags 2486 2524 create = (lookup_mode & VFS_LOOKUP_CREATE) == VFS_LOOKUP_CREATE; … … 2527 2565 #endif 2528 2566 2529 // search the child dentry matching name in parent inode 2567 // search the child dentry matching name in parent inode XHTAB 2530 2568 found = vfs_get_child( parent_xp, 2531 2569 name, … … 2593 2631 #if (DEBUG_VFS_LOOKUP & 1) 2594 2632 if( DEBUG_VFS_LOOKUP < cycle ) 2595 printk("\n[%s] thread[%x,%x] created missing inode for<%s> in cluster %x\n",2633 printk("\n[%s] thread[%x,%x] created missing inode <%s> in cluster %x\n", 2596 2634 __FUNCTION__, process->pid, this->trdid, name, child_cxy ); 2597 2635 #endif … … 2771 2809 { 2772 2810 error_t error; 2773 uint32_t cluster ;2811 uint32_t cluster_id; 2774 2812 uint32_t child_type; 2775 2813 uint32_t child_size; … … 2798 2836 vfs_inode_t * child_ptr = GET_PTR( child_xp ); 2799 2837 2800 // 1. allocate one free cluster in file system to child inode,2838 // 1. allocate one free cluster_id in file system to child inode, 2801 2839 // and update the File Allocation Table in both the FAT mapper and IOC device. 2802 2840 // It depends on the child inode FS type. … … 2804 2842 2805 2843 error = vfs_fs_cluster_alloc( ctx->type, 2806 &cluster );2844 &cluster_id ); 2807 2845 if ( error ) 2808 2846 { 2809 printk("\n[ERROR] in %s : cannot find a free VFS cluster \n",2847 printk("\n[ERROR] in %s : cannot find a free VFS cluster_id\n", 2810 2848 __FUNCTION__ ); 2811 2849 return -1; … … 2814 2852 #if( DEBUG_VFS_NEW_DENTRY_INIT & 1) 2815 2853 if( DEBUG_VFS_NEW_DENTRY_INIT < cycle ) 2816 printk("\n[%s] thread[%x,%x] allocated FS cluster %x to <%s>\n",2817 __FUNCTION__ , this->process->pid, this->trdid, cluster , child_name );2854 printk("\n[%s] thread[%x,%x] allocated FS cluster_id %x to <%s>\n", 2855 __FUNCTION__ , this->process->pid, this->trdid, cluster_id, child_name ); 2818 2856 #endif 2819 2857 2820 2858 // 2. update the child inode descriptor size and extend 2821 2859 child_type = hal_remote_l32( XPTR( child_cxy , &child_ptr->type ) ); 2822 child_size = (child_type == INODE_TYPE_DIR) ? 4096 :0;2860 child_size = 0; 2823 2861 2824 2862 hal_remote_s32( XPTR( child_cxy , &child_ptr->size ) , child_size ); 2825 hal_remote_spt( XPTR( child_cxy , &child_ptr->extend ) , (void*)(intptr_t)cluster );2863 hal_remote_spt( XPTR( child_cxy , &child_ptr->extend ) , (void*)(intptr_t)cluster_id ); 2826 2864 2827 2865 // 3. update the parent inode mapper, and … … 3285 3323 #if(DEBUG_VFS_ADD_CHILD & 1) 3286 3324 if( DEBUG_VFS_ADD_CHILD < cycle ) 3287 printk("\n[%s] thread[%x,%x] / dentry <%s> created(%x,%x)\n",3325 printk("\n[%s] thread[%x,%x] created dentry <%s> : (%x,%x)\n", 3288 3326 __FUNCTION__, this->process->pid, this->trdid, name, parent_cxy, new_dentry_ptr ); 3289 3327 #endif … … 3332 3370 #if(DEBUG_VFS_ADD_CHILD & 1) 3333 3371 if( DEBUG_VFS_ADD_CHILD < cycle ) 3334 printk("\n[%s] thread[%x,%x] / inode <%s> created(%x,%x)\n",3372 printk("\n[%s] thread[%x,%x] created inode <%s> : (%x,%x)\n", 3335 3373 __FUNCTION__ , this->process->pid, this->trdid, name , child_cxy, new_inode_ptr ); 3336 3374 #endif … … 3345 3383 #if(DEBUG_VFS_ADD_CHILD & 1) 3346 3384 if( DEBUG_VFS_ADD_CHILD < cycle ) 3347 printk("\n[%s] thread[%x,%x] link dentry(%x,%x) to child inode(%x,%x)\n",3385 printk("\n[%s] thread[%x,%x] linked dentry(%x,%x) to child inode(%x,%x)\n", 3348 3386 __FUNCTION__, this->process->pid, this->trdid, 3349 3387 parent_cxy, new_dentry_ptr, child_cxy, new_inode_ptr ); … … 3357 3395 #if(DEBUG_VFS_ADD_CHILD & 1) 3358 3396 if( DEBUG_VFS_ADD_CHILD < cycle ) 3359 printk("\n[%s] thread[%x,%x] link dentry(%x,%x) to parent inode(%x,%x)\n",3397 printk("\n[%s] thread[%x,%x] linked dentry(%x,%x) to parent inode(%x,%x)\n", 3360 3398 __FUNCTION__, this->process->pid, this->trdid, 3361 3399 parent_cxy, new_dentry_ptr, parent_cxy, parent_inode_ptr ); … … 3814 3852 return error; 3815 3853 3816 } // end vfs_fs_ alloc_cluster()3854 } // end vfs_fs_cluster_alloc() 3817 3855 3818 3856 //////////////////////////////////////////////// -
trunk/kernel/fs/vfs.h
r635 r656 602 602 * and synchronously update the IOC device). 603 603 * 2. It set the "size", and "extend" fields in child inode descriptor. 604 * The size is 4096 for a directory, the size is 0 for a file. 604 605 * 3. It updates the parent directory mapper to introduce the new child, 605 606 * and synchronously update the IOC device. … … 660 661 * account the offset in <file_xp>. The transfer direction is defined by <to_buffer>. 661 662 * It is called by the sys_read() and sys_write() functions. 663 * - for a read, it checks the actual file size (registered in the inode descriptor), 664 * against the (offset + count), and moves only the significant bytes. 665 * - for a write, it updates the the file size in inode descriptor if required. 666 * In case of write to the mapper, the "inode.size" field is updated as required. 662 667 ****************************************************************************************** 663 668 * @ to_buffer : mapper -> buffer if true / buffer -> mapper if false. 664 669 * @ file_xp : extended pointer on the remote file descriptor. 665 670 * @ buffer : user space pointer on buffer (can be physically distributed). 666 * @ size: requested number of bytes from offset.671 * @ count : requested number of bytes from offset. 667 672 * @ returns number of bytes actually moved if success / -1 if error. 668 673 *****************************************************************************************/ 669 int vfs_user_move( bool_t to_buffer,670 xptr_t file_xp,671 void * buffer,672 uint32_t size);674 uint32_t vfs_user_move( bool_t to_buffer, 675 xptr_t file_xp, 676 void * buffer, 677 uint32_t count ); 673 678 674 679 /****************************************************************************************** … … 745 750 * to the file, and removes these pages from the dirty list, using an RPC if required. 746 751 * 2) It updates the file size in all parent directory mapper(s), and update the modified 747 * pages on the block device, using RPCs if required .752 * pages on the block device, using RPCs if required, only if the size is modified. 748 753 * 3) All entries in the fd_array copies are directly reset by the calling thread, 749 754 * using remote accesses. … … 895 900 * argument to/from the IOC device from/to the mapper, as defined by the <cmd_type>. 896 901 * Depending on the file system type, it calls the proper, FS specific function. 897 * It is used in case of MISS on the mapper , or when a dirty page in the mapper must898 * be updated in the File System.899 * The mapper pointer isobtained from the page descriptor.902 * It is used in case of MISS on the mapper (read), or when a dirty page in the mapper 903 * must be updated in the File System (write). 904 * The mapper pointer, and the page index in file are obtained from the page descriptor. 900 905 * It can be executed by any thread running in any cluster. 901 906 * This function does NOT take any lock.
Note: See TracChangeset
for help on using the changeset viewer.