Commit 71b26127 authored by Russell King's avatar Russell King Committed by Al Viro

fs/adfs: dir: rename bh_fplus to bhs

Rename bh_fplus to bhs in preparation to make some of the directory
handling code sharable between implementations.
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent f93793fd
......@@ -93,9 +93,7 @@ struct adfs_dir {
int nr_buffers;
struct buffer_head *bh[4];
/* big directories need allocated buffers */
struct buffer_head **bh_fplus;
struct buffer_head **bhs;
unsigned int pos;
__u32 parent_id;
......
......@@ -20,7 +20,7 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct
dir->nr_buffers = 0;
/* start off using fixed bh set - only alloc for big dirs */
dir->bh_fplus = &dir->bh[0];
dir->bhs = &dir->bh[0];
block = __adfs_block_map(sb, id, 0);
if (!block) {
......@@ -28,12 +28,12 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct
goto out;
}
dir->bh_fplus[0] = sb_bread(sb, block);
if (!dir->bh_fplus[0])
dir->bhs[0] = sb_bread(sb, block);
if (!dir->bhs[0])
goto out;
dir->nr_buffers += 1;
h = (struct adfs_bigdirheader *)dir->bh_fplus[0]->b_data;
h = (struct adfs_bigdirheader *)dir->bhs[0]->b_data;
size = le32_to_cpu(h->bigdirsize);
if (size != sz) {
adfs_msg(sb, KERN_WARNING,
......@@ -51,19 +51,19 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct
size >>= sb->s_blocksize_bits;
if (size > ARRAY_SIZE(dir->bh)) {
/* this directory is too big for fixed bh set, must allocate */
struct buffer_head **bh_fplus =
struct buffer_head **bhs =
kcalloc(size, sizeof(struct buffer_head *),
GFP_KERNEL);
if (!bh_fplus) {
if (!bhs) {
adfs_msg(sb, KERN_ERR,
"not enough memory for dir object %X (%d blocks)",
id, size);
ret = -ENOMEM;
goto out;
}
dir->bh_fplus = bh_fplus;
dir->bhs = bhs;
/* copy over the pointer to the block that we've already read */
dir->bh_fplus[0] = dir->bh[0];
dir->bhs[0] = dir->bh[0];
}
for (blk = 1; blk < size; blk++) {
......@@ -73,8 +73,8 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct
goto out;
}
dir->bh_fplus[blk] = sb_bread(sb, block);
if (!dir->bh_fplus[blk]) {
dir->bhs[blk] = sb_bread(sb, block);
if (!dir->bhs[blk]) {
adfs_error(sb, "dir object %x failed read for offset %d, mapped block %lX",
id, blk, block);
goto out;
......@@ -84,7 +84,7 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct
}
t = (struct adfs_bigdirtail *)
(dir->bh_fplus[size - 1]->b_data + (sb->s_blocksize - 8));
(dir->bhs[size - 1]->b_data + (sb->s_blocksize - 8));
if (t->bigdirendname != cpu_to_le32(BIGDIRENDNAME) ||
t->bigdirendmasseq != h->startmasseq ||
......@@ -98,14 +98,14 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct
return 0;
out:
if (dir->bh_fplus) {
if (dir->bhs) {
for (i = 0; i < dir->nr_buffers; i++)
brelse(dir->bh_fplus[i]);
brelse(dir->bhs[i]);
if (&dir->bh[0] != dir->bh_fplus)
kfree(dir->bh_fplus);
if (&dir->bh[0] != dir->bhs)
kfree(dir->bhs);
dir->bh_fplus = NULL;
dir->bhs = NULL;
}
dir->nr_buffers = 0;
......@@ -117,7 +117,7 @@ static int
adfs_fplus_setpos(struct adfs_dir *dir, unsigned int fpos)
{
struct adfs_bigdirheader *h =
(struct adfs_bigdirheader *) dir->bh_fplus[0]->b_data;
(struct adfs_bigdirheader *) dir->bhs[0]->b_data;
int ret = -ENOENT;
if (fpos <= le32_to_cpu(h->bigdirentries)) {
......@@ -140,18 +140,18 @@ dir_memcpy(struct adfs_dir *dir, unsigned int offset, void *to, int len)
partial = sb->s_blocksize - offset;
if (partial >= len)
memcpy(to, dir->bh_fplus[buffer]->b_data + offset, len);
memcpy(to, dir->bhs[buffer]->b_data + offset, len);
else {
char *c = (char *)to;
remainder = len - partial;
memcpy(c,
dir->bh_fplus[buffer]->b_data + offset,
dir->bhs[buffer]->b_data + offset,
partial);
memcpy(c + partial,
dir->bh_fplus[buffer + 1]->b_data,
dir->bhs[buffer + 1]->b_data,
remainder);
}
}
......@@ -160,7 +160,7 @@ static int
adfs_fplus_getnext(struct adfs_dir *dir, struct object_info *obj)
{
struct adfs_bigdirheader *h =
(struct adfs_bigdirheader *) dir->bh_fplus[0]->b_data;
(struct adfs_bigdirheader *) dir->bhs[0]->b_data;
struct adfs_bigdirentry bde;
unsigned int offset;
int ret = -ENOENT;
......@@ -202,7 +202,7 @@ adfs_fplus_sync(struct adfs_dir *dir)
int i;
for (i = dir->nr_buffers - 1; i >= 0; i--) {
struct buffer_head *bh = dir->bh_fplus[i];
struct buffer_head *bh = dir->bhs[i];
sync_dirty_buffer(bh);
if (buffer_req(bh) && !buffer_uptodate(bh))
err = -EIO;
......@@ -216,14 +216,14 @@ adfs_fplus_free(struct adfs_dir *dir)
{
int i;
if (dir->bh_fplus) {
if (dir->bhs) {
for (i = 0; i < dir->nr_buffers; i++)
brelse(dir->bh_fplus[i]);
brelse(dir->bhs[i]);
if (&dir->bh[0] != dir->bh_fplus)
kfree(dir->bh_fplus);
if (&dir->bh[0] != dir->bhs)
kfree(dir->bhs);
dir->bh_fplus = NULL;
dir->bhs = NULL;
}
dir->nr_buffers = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment