Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 95540 - GLIStorageDevice.tidy_partitions() free space merging does not behave correctly, depending on order of deletion
Summary: GLIStorageDevice.tidy_partitions() free space merging does not behave correct...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Release Media
Classification: Unclassified
Component: Installer (show other bugs)
Hardware: All Other
: High major (vote)
Assignee: Gentoo Linux Installer
URL: http://research.iat.sfu.ca/~robbat2/g...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-09 03:33 UTC by Robin Johnson
Modified: 2006-03-24 13:46 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2005-06-09 03:33:25 UTC
The tidy_partitions() command does not work properly, depending on the order of partition deletion. The free space merging algoritm is the source of the problem. The function needs to be re-written to first assign a unique id to every item in the array, and then check for sequential free partitions. The current keys and minor numbers are NOT unique.

The lines below are generated with:
for part in self._partitions.keys().sort():
	tp = self._partitions[part]
	print str(part)+"-"+str(tp.get_minor())+"-"+tp.get_type()+"-"+str(tp.get_mb())
run at the top and bottom of tidy_partitions()

Initial layout:
---------------
1-1.0-ext3-8001
2-2.0-ext3-47183
3-3.0-linux-swap-2047
3.1-3.1-free-7

Last to first (3,2,1):
----------------------
# delete item 3 - result correct
Part table before tidy
1-1.0-ext3-8001
2-2.0-ext3-47183
2.1-2.1-free-2047
3.1-3.1-free-7
Part table after tidy
1-1.0-ext3-8001
2-2.0-ext3-47183
2.1-2.1-free-2054

# delete item 2 - result correct
Part table before tidy
1-1.0-ext3-8001
1.1-1.1-free-47183
2.1-2.1-free-2054
Part table after tidy
1-1.0-ext3-8001
1.1-1.1-free-49237

# delete item 1 - result correct
Part table before tidy
0.1-0.1-free-8001
1.1-1.1-free-49237
Part table after tidy
0.1-0.1-free-57238


First to last (1,2,3):
----------------------
# delete item 1 - result correct
Part table before tidy
0.1-0.1-free-8001
2-2.0-ext3-47183
3-3.0-linux-swap-2047
3.1-3.1-free-7
Part table after tidy
0.1-0.1-free-8001
1-1.0-ext3-47183
2-2.0-linux-swap-2047
3.1-3.1-free-7

# delete item 2 - both 0.1 items vanish
Part table before tidy
0.1-0.1-free-47183
0.1-0.1-free-8001
2-2.0-linux-swap-2047
3.1-3.1-free-7
Part table after tidy
1-1.0-linux-swap-2047
3.1-3.1-free-7


Crazy order: 2,1,3
------------------
# delete item 2 - result correct
1-1.0-ext3-8001
1.1-1.1-free-47183
3-3.0-linux-swap-2047
3.1-3.1-free-7
Part table after tidy
1-1.0-ext3-8001
1.1-1.1-free-47183
2-2.0-linux-swap-2047
3.1-3.1-free-7

# delete item 1 - result correct
Part table before tidy
0.1-0.1-free-8001
1.1-1.1-free-47183
2-2.0-linux-swap-2047
3.1-3.1-free-7
Part table after tidy
0.1-0.1-free-55184
1-1.0-linux-swap-2047
3.1-3.1-free-7

# delete item 3 - traceback!
Part table before tidy
0.1-0.1-free-2047
0.1-0.1-free-55184
3.1-3.1-free-7
Pause>
Traceback (most recent call last):
  File "/opt/installer/fe/dialog/dialogfe.py", line 809, in ?
    item['fn']()
  File "/opt/installer/fe/dialog/dialogfe.py", line 159, in set_partitions
    tmpdev.remove_partition(part_to_edit)
  File "/opt/installer/GLIStorageDevice.py", line 238, in remove_partition
    self.tidy_partitions()
  File "/opt/installer/GLIStorageDevice.py", line 153, in tidy_partitions
    self._partitions[last_free].set_mb(self._partitions[last_free].get_mb()+tmppart.get_mb())
KeyError: 0.10000000000000001

Crazy order: 2,3,1
------------------
# delete item 2 - result correct
Part table before tidy
1-1.0-ext3-8001
1.1-1.1-free-47183
3-3.0-linux-swap-2047
3.1-3.1-free-7
Part table after tidy
1-1.0-ext3-8001
1.1-1.1-free-47183
2-2.0-linux-swap-2047
3.1-3.1-free-7

# delete item 3 - note the 46gb partition is missing!
Part table before tidy
1-1.0-ext3-8001
1.1-1.1-free-2047
3.1-3.1-free-7
Part table after tidy
1-1.0-ext3-8001
1.1-1.1-free-2054

# delete item 1 - result correct
Part table before tidy
0.1-0.1-free-8001
1.1-1.1-free-2054
Part table after tidy
0.1-0.1-free-10055
Comment 1 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2005-06-09 19:03:06 UTC
Patch here:
http://research.iat.sfu.ca/~robbat2/gli-tidy-partitions.patch
Comment 2 Andrew Gaffney (RETIRED) gentoo-dev 2005-06-09 20:09:06 UTC
There was no need to rewrite tidy_partitions(). I fixed the free space merging
with a simple fix to remove_partition():

 		if tmppart.is_logical():
-			free_minor = minor-0.1
+			free_minor = int(minor-1)+FREE_MINOR_FRAC_LOG
+		else:
+			free_minor = int(minor-1)+FREE_MINOR_FRAC_PRI
+		if free_minor in self._partitions:
+			self._partitions[free_minor].set_mb(self._partitions[free_minor].get_mb() +
tmppart.get_mb())
 		else:
-			free_minor = minor-0.9
-		self._partitions[free_minor] = Partition(self, free_minor, tmppart.get_mb(),
0, 0, "free", format=False, existing=False)
+			self._partitions[free_minor] = Partition(self, free_minor, tmppart.get_mb(),
0, 0, "free", format=False, existing=False)
 		del self._partitions[int(minor)]
 		self.tidy_partitions()

I did apply all the FREE_MINOR_FRAC_LOG/PRI stuff, though.
Comment 3 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2005-06-09 21:14:08 UTC
Ok, I'm closing this now.
Comment 4 Jeffrey Forman (RETIRED) gentoo-dev 2006-03-24 13:46:30 UTC
Moving to Release Media/Installer.