ShingledFS 2.0
SMR-AwareFUSE-basedFileSystem
|
00001 #include <stdio.h> 00002 #include <sys/types.h> 00003 #include <sys/stat.h> 00004 #include <fcntl.h> 00005 00006 #define _XOPEN_SOURCE 500 00007 #include <unistd.h> 00008 00009 00010 #include "band_log.h" 00011 #include "band_bitmap.h" 00012 #include "cleaning_thread.h" 00013 #include "common.h" 00014 00015 00016 /* 00017 * @brief : Returns the band most appropriate to be cleaned. 00018 * 00019 * @return finalband : Band tobe cleaned. 00020 * 0 : If no band is selected. 00021 * 00022 */ 00023 00024 int select_fragband() 00025 { 00026 int i; 00027 int maxbandeff = 0; 00028 int finalband = 0; 00029 int curreff; 00030 int max_bandnum = SFSDATA.edi_bandcount; 00031 00032 for(i = 0; i < max_bandnum; i++) { 00033 if (test_bandusage(i + 1) != 1) { 00034 continue; 00035 } 00036 00037 curreff = calc_fragbandefficiency(i + 1); 00038 00039 if (maxbandeff < curreff) { 00040 maxbandeff = curreff; 00041 finalband = i + 1; 00042 } 00043 } 00044 00045 return finalband; 00046 } 00047 00048 00049 /* 00050 * @brief : Calculates the band efficiency for the band tobe selected for 00051 * cleaning. 00052 * 00053 * @param band_num : Band number. 00054 * 00055 * @return effiency : Band efficiency. 00056 * 00057 */ 00058 00059 int calc_fragbandefficiency(int band_num) 00060 { 00061 int efficiency; 00062 00063 efficiency = band_delentries(band_num); 00064 00065 return efficiency; 00066 } 00067 00068 00069 /* 00070 * @brief : returns the band selected to cleaned to. 00071 * 00072 * @param : None. 00073 * 00074 * @return finalband : Band selected to clean to. 00075 * 00076 */ 00077 00078 int select_cleanband(int size) 00079 { 00080 int i; 00081 00082 i = get_freebandnum(); 00083 if (i == 0) { 00084 return 0; 00085 } 00086 00087 return i; 00088 } 00089 00090 //int select_cleanband(int size) 00091 //{ 00092 // int i; 00093 // int maxbandeff = 0; 00094 // int finalband = 0; 00095 // int curreff; 00096 // int max_bandnum = get_maxbandnum(); 00097 // 00098 // for(i = 0; i < max_bandnum; i++) { 00099 // if (test_bandusage(i + 1) != 1) { 00100 // continue; 00101 // } 00102 // 00103 // //TODO: Check the size of the band with size variable. 00104 // 00105 // curreff = calc_cleanbandefficiency(i + 1); 00106 // 00107 // if (maxbandeff < curreff) { 00108 // maxbandeff = curreff; 00109 // finalband = i + 1; 00110 // } 00111 // } 00112 // return finalband; 00113 //} 00114 00115 00116 /* 00117 * @brief : Calculated the efficiency of the band to clean to. 00118 * 00119 * @param band_num : Band number. 00120 * 00121 * @return efficiency : Band efficiency. 00122 * 00123 */ 00124 00125 //int calc_cleanbandefficiency(int band_num) 00126 //{ 00127 // int size; 00128 // int age; 00129 // int percentage_size; 00130 // int percentage_age; 00131 // int efficiency; 00132 00133 // size = band_occupancy(band_num); 00134 // age = band_age(band_num); 00135 00136 //TODO: Dicuss the exact units with Anand. 00137 // 00138 00139 // return efficiency; 00140 //}