summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@armlinux.org.uk>2019-12-09 11:08:49 +0000
committerAl Viro <viro@zeniv.linux.org.uk>2020-01-20 20:12:40 -0500
commit197ba3c519312a0bed91aeaf34095b2c09c6431a (patch)
treebe6067609c33ffdadfd27bacf3816094fcac7224
parent7b1952676256d2cdc03d0415a4c0e6bfb64e00ff (diff)
fs/adfs: map: incorporate map offsets into layout
lookup_zone() and scan_free_map() cope in different ways with the location of the map data within a zone: 1. lookup_zone() adds a four byte offset to the map data pointer to skip over the check and free link bytes. 2. scan_free_map() needs to use the free link pointer, which is an offset from itself, so we end up adding a 32-bit offset to the end pointer (aka mapsize) which is really confusing. Rename mapsize to endbit as this is really what it is, and incorporate the 32-bit offset into the map layout. This means that both dm_startbit and dm_endbit are now bit offsets from the start of the buffer, rather than four bytes in to the buffer. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/adfs/map.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/fs/adfs/map.c b/fs/adfs/map.c
index 8ba8877110ff..55bd7c20158c 100644
--- a/fs/adfs/map.c
+++ b/fs/adfs/map.c
@@ -68,9 +68,9 @@ static DEFINE_RWLOCK(adfs_map_lock);
static int lookup_zone(const struct adfs_discmap *dm, const unsigned int idlen,
const u32 frag_id, unsigned int *offset)
{
- const unsigned int mapsize = dm->dm_endbit;
+ const unsigned int endbit = dm->dm_endbit;
const u32 idmask = (1 << idlen) - 1;
- unsigned char *map = dm->dm_bh->b_data + 4;
+ unsigned char *map = dm->dm_bh->b_data;
unsigned int start = dm->dm_startbit;
unsigned int mapptr;
u32 frag;
@@ -87,7 +87,7 @@ static int lookup_zone(const struct adfs_discmap *dm, const unsigned int idlen,
u32 v = le32_to_cpu(_map[mapptr >> 5]) >> (mapptr & 31);
while (v == 0) {
mapptr = (mapptr & ~31) + 32;
- if (mapptr >= mapsize)
+ if (mapptr >= endbit)
goto error;
v = le32_to_cpu(_map[mapptr >> 5]);
}
@@ -99,7 +99,7 @@ static int lookup_zone(const struct adfs_discmap *dm, const unsigned int idlen,
goto found;
again:
start = mapptr;
- } while (mapptr < mapsize);
+ } while (mapptr < endbit);
return -1;
error:
@@ -127,7 +127,7 @@ found:
static unsigned int
scan_free_map(struct adfs_sb_info *asb, struct adfs_discmap *dm)
{
- const unsigned int mapsize = dm->dm_endbit + 32;
+ const unsigned int endbit = dm->dm_endbit;
const unsigned int idlen = asb->s_idlen;
const unsigned int frag_idlen = idlen <= 15 ? idlen : 15;
const u32 idmask = (1 << frag_idlen) - 1;
@@ -165,7 +165,7 @@ scan_free_map(struct adfs_sb_info *asb, struct adfs_discmap *dm)
u32 v = le32_to_cpu(_map[mapptr >> 5]) >> (mapptr & 31);
while (v == 0) {
mapptr = (mapptr & ~31) + 32;
- if (mapptr >= mapsize)
+ if (mapptr >= endbit)
goto error;
v = le32_to_cpu(_map[mapptr >> 5]);
}
@@ -345,19 +345,19 @@ static void adfs_map_layout(struct adfs_discmap *dm, unsigned int nzones,
dm[0].dm_bh = NULL;
dm[0].dm_startblk = 0;
- dm[0].dm_startbit = ADFS_DR_SIZE_BITS;
- dm[0].dm_endbit = zone_size;
+ dm[0].dm_startbit = 32 + ADFS_DR_SIZE_BITS;
+ dm[0].dm_endbit = 32 + zone_size;
for (zone = 1; zone < nzones; zone++) {
dm[zone].dm_bh = NULL;
dm[zone].dm_startblk = zone * zone_size - ADFS_DR_SIZE_BITS;
- dm[zone].dm_startbit = 0;
- dm[zone].dm_endbit = zone_size;
+ dm[zone].dm_startbit = 32;
+ dm[zone].dm_endbit = 32 + zone_size;
}
size = adfs_disc_size(dr) >> dr->log2bpmb;
size -= (nzones - 1) * zone_size - ADFS_DR_SIZE_BITS;
- dm[nzones - 1].dm_endbit = size;
+ dm[nzones - 1].dm_endbit = 32 + size;
}
static int adfs_map_read(struct adfs_discmap *dm, struct super_block *sb,