/[gli]/trunk/src/GLIStorageDevice.py
Gentoo

Diff of /trunk/src/GLIStorageDevice.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 205 Revision 207
101 101
102 def remove_partition(self, minor): 102 def remove_partition(self, minor):
103 del self._partitions[int(minor)] 103 del self._partitions[int(minor)]
104 104
105 def get_free_space(self, start): 105 def get_free_space(self, start):
106 GAP_SIZE = 100
106 parts = self._partitions.keys() 107 parts = self._partitions.keys()
107 parts.sort() 108 parts.sort()
108 lastend_pri = 0 109 lastend_pri = 0
109 lastend_log = 0 110 lastend_log = 0
110 free_start = -1 111 free_start = -1
111 free_end = -1 112 free_end = -1
112 if start > self._total_sectors: return (-1, -1) 113 if start > self._total_sectors: return (-1, -1)
113 for part in parts: 114 for part in parts:
114 if part > 4: break 115 if part > 4: break
115 tmppart = self._partitions[part] 116 tmppart = self._partitions[part]
116 if (tmppart.get_start() > lastend_pri) and (lastend_pri >= start): 117 if (tmppart.get_start() > (lastend_pri + GAP_SIZE)) and (lastend_pri >= start):
117 free_start = lastend_pri 118 free_start = lastend_pri
118 free_end = tmppart.get_start() - 1 119 free_end = tmppart.get_start() - 1
119 break 120 break
120 if tmppart.is_extended() and start < tmppart.get_end(): 121 if tmppart.is_extended() and start < tmppart.get_end():
121 lastend_log = tmppart.get_start() 122 lastend_log = tmppart.get_start()
122 for part_log in parts: 123 for part_log in parts:
123 if part_log < 5: continue 124 if part_log < 5: continue
124 tmppart_log = self._partitions[part_log] 125 tmppart_log = self._partitions[part_log]
125 if (tmppart_log.get_start() > lastend_log) and (lastend_log >= start): 126 if (tmppart_log.get_start() > (lastend_log + GAP_SIZE)) and (lastend_log >= start):
126 free_start = lastend_log 127 free_start = lastend_log
127 free_end = tmppart_log.get_start() - 1 128 free_end = tmppart_log.get_start() - 1
128 break 129 break
129 lastend_log = tmppart_log.get_end() + 1 130 lastend_log = tmppart_log.get_end() + 1
130 if free_start == -1 and lastend_log < tmppart.get_end(): 131 if free_start == -1 and lastend_log < tmppart.get_end():

Legend:
Removed from v.205  
changed lines
  Added in v.207

  ViewVC Help
Powered by ViewVC 1.1.20