Skip to contentSkip to conversation

md: Remove the hash tables from raid0.

PATCH In review Andre Noll 2 participants 8 messages May 14, 2009 MD RAID

lore
Share & tools
lore

Andre Noll

author
#0 lore raw

cover md: Remove the hash tables from raid0.

As mentioned by Neil, the raid0 hash table code does probably not add any value. Moreover, it contains some rather strange sector_t manipulations which are needed to setup and maintain the table.

This patch series against Neil's for-next tree as of yesterday removes the hash table from the raid0 code.

Patch #1 replaces the hash table lookup by a simple function that loops over all strip zones to find the zone that holds a given sector. This change allows to get rid of the hash table itself (patch #2) and of related fields of struct raid0_private_data (patch #3).

Patch #4 makes raid0 return a proper error code rather than -ENOMEM in case the array could not be started for reasons other than memory shortage.

The remaining two patches are simple cleanups that further simplify the raid0 code a bit.

The patched kernel has been tested with a smallish raid0 array consisting of five devices of varying sizes (created and filled with contents by an unpatched kernel) and seems to work just fine. It passes the raid0 tests of the mdadm test suite.

Please consider for inclusion.

 drivers/md/raid0.c |  150 ++++++++++++++--------------------------------------
 drivers/md/raid0.h |    4 --
 2 files changed, 39 insertions(+), 115 deletions(-)

Thanks
Andre

author
#1 lore raw

PATCH 1/6 md: raid0: Replace hash table lookup by looping over all strip_zones.

The number of strip_zones of a raid0 array is bounded by the number of drives in the array and is in fact much smaller for typical setups. For example, any raid0 array containing identical disks will have only a single strip_zone.

Therefore, the hash tables which are used for quickly finding the strip_zone that holds a particular sector are of questionable value and add quite a bit of unnecessary complexity.

This patch replaces the hash table lookup by equivalent code which simply loops over all strip zones to find the zone that holds the given sector.

Subsequent cleanup patches will remove the hash table structure.

 drivers/md/raid0.c |   32 +++++++++++++++++++-------------
 1 files changed, 19 insertions(+), 13 deletions(-)
Signature · 1 line
1.5.4.3
author
#2 lore raw

PATCH 2/6 md: raid0: Remove hash table.

In reply to Andre Noll

The raid0 hash table has become unused due to the changes in the previous patch. This patch removes the hash table allocation and setup code and kills the hash_table field of struct raid0_private_data.

 drivers/md/raid0.c |   12 ------------
 drivers/md/raid0.h |    1 -
 2 files changed, 0 insertions(+), 13 deletions(-)
Signature · 1 line
1.5.4.3
author
#3 lore raw

PATCH 3/6 md: raid0: Remove hash spacing and sector shift.

In reply to Andre Noll

The "sector_shift" and "spacing" fields of struct raid0_private_data were only used for the hash table lookups. So the removal of the hash table allows get rid of these fields as well which simplifies create_strip_zones() and raid0_run() quite a bit.

 drivers/md/raid0.c |   63 +---------------------------------------------------
 drivers/md/raid0.h |    3 --
 2 files changed, 1 insertions(+), 65 deletions(-)
Signature · 1 line
1.5.4.3
author
#4 lore raw

PATCH 4/6 md: raid0: Make raid0_run() return a proper error code.

In reply to Andre Noll

Currently raid0_run() always returns -ENOMEM on errors. This is incorrect as running the array might fail for other reasons, for example because not all component devices were available.

This patch changes create_strip_zones() so that it returns a proper error code (either -ENOMEM or -EINVAL) rather than 1 on errors and makes raid0_run(), its single caller, return that value instead of -ENOMEM.

 drivers/md/raid0.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)
Signature · 1 line
1.5.4.3
author
#5 lore raw

PATCH 5/6 md: raid0: Kfree() strip_zone and devlist in create_strip_zones().

In reply to Andre Noll

It's cleaner to kfree() these in the same function where they are allocated. This allows to simplify raid0_run() a bit which will be done in the next patch.

 drivers/md/raid0.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
Signature · 1 line
1.5.4.3
#7 lore raw
In reply to Andre Noll

where are the patches ?

Quoted 32 lines · Andre Noll

As mentioned by Neil, the raid0 hash table code does probably not add any value. Moreover, it contains some rather strange sector_t manipulations which are needed to setup and maintain the table.

This patch series against Neil's for-next tree as of yesterday removes the hash table from the raid0 code.

Patch #1 replaces the hash table lookup by a simple function that loops over all strip zones to find the zone that holds a given sector. This change allows to get rid of the hash table itself (patch #2) and of related fields of struct raid0_private_data (patch #3).

Patch #4 makes raid0 return a proper error code rather than -ENOMEM in case the array could not be started for reasons other than memory shortage.

The remaining two patches are simple cleanups that further simplify the raid0 code a bit.

The patched kernel has been tested with a smallish raid0 array consisting of five devices of varying sizes (created and filled with contents by an unpatched kernel) and seems to work just fine. It passes the raid0 tests of the mdadm test suite.

Please consider for inclusion.

 drivers/md/raid0.c |  150 ++++++++++++++--------------------------------------
 drivers/md/raid0.h |    4 --
 2 files changed, 39 insertions(+), 115 deletions(-)

Thanks
Andre