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 { ...@@ -93,9 +93,7 @@ struct adfs_dir {
int nr_buffers; int nr_buffers;
struct buffer_head *bh[4]; struct buffer_head *bh[4];
struct buffer_head **bhs;
/* big directories need allocated buffers */
struct buffer_head **bh_fplus;
unsigned int pos; unsigned int pos;
__u32 parent_id; __u32 parent_id;
......
...@@ -20,7 +20,7 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct ...@@ -20,7 +20,7 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct
dir->nr_buffers = 0; dir->nr_buffers = 0;
/* start off using fixed bh set - only alloc for big dirs */ /* 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); block = __adfs_block_map(sb, id, 0);
if (!block) { if (!block) {
...@@ -28,12 +28,12 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct ...@@ -28,12 +28,12 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct
goto out; goto out;
} }
dir->bh_fplus[0] = sb_bread(sb, block); dir->bhs[0] = sb_bread(sb, block);
if (!dir->bh_fplus[0]) if (!dir->bhs[0])
goto out; goto out;
dir->nr_buffers += 1; 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); size = le32_to_cpu(h->bigdirsize);
if (size != sz) { if (size != sz) {
adfs_msg(sb, KERN_WARNING, adfs_msg(sb, KERN_WARNING,
...@@ -51,19 +51,19 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct ...@@ -51,19 +51,19 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct
size >>= sb->s_blocksize_bits; size >>= sb->s_blocksize_bits;
if (size > ARRAY_SIZE(dir->bh)) { if (size > ARRAY_SIZE(dir->bh)) {
/* this directory is too big for fixed bh set, must allocate */ /* 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 *), kcalloc(size, sizeof(struct buffer_head *),
GFP_KERNEL); GFP_KERNEL);
if (!bh_fplus) { if (!bhs) {
adfs_msg(sb, KERN_ERR, adfs_msg(sb, KERN_ERR,
"not enough memory for dir object %X (%d blocks)", "not enough memory for dir object %X (%d blocks)",
id, size); id, size);
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
} }
dir->bh_fplus = bh_fplus; dir->bhs = bhs;
/* copy over the pointer to the block that we've already read */ /* 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++) { for (blk = 1; blk < size; blk++) {
...@@ -73,8 +73,8 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct ...@@ -73,8 +73,8 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct
goto out; goto out;
} }
dir->bh_fplus[blk] = sb_bread(sb, block); dir->bhs[blk] = sb_bread(sb, block);
if (!dir->bh_fplus[blk]) { if (!dir->bhs[blk]) {
adfs_error(sb, "dir object %x failed read for offset %d, mapped block %lX", adfs_error(sb, "dir object %x failed read for offset %d, mapped block %lX",
id, blk, block); id, blk, block);
goto out; goto out;
...@@ -84,7 +84,7 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct ...@@ -84,7 +84,7 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct
} }
t = (struct adfs_bigdirtail *) 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) || if (t->bigdirendname != cpu_to_le32(BIGDIRENDNAME) ||
t->bigdirendmasseq != h->startmasseq || t->bigdirendmasseq != h->startmasseq ||
...@@ -98,14 +98,14 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct ...@@ -98,14 +98,14 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct
return 0; return 0;
out: out:
if (dir->bh_fplus) { if (dir->bhs) {
for (i = 0; i < dir->nr_buffers; i++) for (i = 0; i < dir->nr_buffers; i++)
brelse(dir->bh_fplus[i]); brelse(dir->bhs[i]);
if (&dir->bh[0] != dir->bh_fplus) if (&dir->bh[0] != dir->bhs)
kfree(dir->bh_fplus); kfree(dir->bhs);
dir->bh_fplus = NULL; dir->bhs = NULL;
} }
dir->nr_buffers = 0; dir->nr_buffers = 0;
...@@ -117,7 +117,7 @@ static int ...@@ -117,7 +117,7 @@ static int
adfs_fplus_setpos(struct adfs_dir *dir, unsigned int fpos) adfs_fplus_setpos(struct adfs_dir *dir, unsigned int fpos)
{ {
struct adfs_bigdirheader *h = struct adfs_bigdirheader *h =
(struct adfs_bigdirheader *) dir->bh_fplus[0]->b_data; (struct adfs_bigdirheader *) dir->bhs[0]->b_data;
int ret = -ENOENT; int ret = -ENOENT;
if (fpos <= le32_to_cpu(h->bigdirentries)) { if (fpos <= le32_to_cpu(h->bigdirentries)) {
...@@ -140,18 +140,18 @@ dir_memcpy(struct adfs_dir *dir, unsigned int offset, void *to, int len) ...@@ -140,18 +140,18 @@ dir_memcpy(struct adfs_dir *dir, unsigned int offset, void *to, int len)
partial = sb->s_blocksize - offset; partial = sb->s_blocksize - offset;
if (partial >= len) if (partial >= len)
memcpy(to, dir->bh_fplus[buffer]->b_data + offset, len); memcpy(to, dir->bhs[buffer]->b_data + offset, len);
else { else {
char *c = (char *)to; char *c = (char *)to;
remainder = len - partial; remainder = len - partial;
memcpy(c, memcpy(c,
dir->bh_fplus[buffer]->b_data + offset, dir->bhs[buffer]->b_data + offset,
partial); partial);
memcpy(c + partial, memcpy(c + partial,
dir->bh_fplus[buffer + 1]->b_data, dir->bhs[buffer + 1]->b_data,
remainder); remainder);
} }
} }
...@@ -160,7 +160,7 @@ static int ...@@ -160,7 +160,7 @@ static int
adfs_fplus_getnext(struct adfs_dir *dir, struct object_info *obj) adfs_fplus_getnext(struct adfs_dir *dir, struct object_info *obj)
{ {
struct adfs_bigdirheader *h = 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; struct adfs_bigdirentry bde;
unsigned int offset; unsigned int offset;
int ret = -ENOENT; int ret = -ENOENT;
...@@ -202,7 +202,7 @@ adfs_fplus_sync(struct adfs_dir *dir) ...@@ -202,7 +202,7 @@ adfs_fplus_sync(struct adfs_dir *dir)
int i; int i;
for (i = dir->nr_buffers - 1; i >= 0; 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); sync_dirty_buffer(bh);
if (buffer_req(bh) && !buffer_uptodate(bh)) if (buffer_req(bh) && !buffer_uptodate(bh))
err = -EIO; err = -EIO;
...@@ -216,14 +216,14 @@ adfs_fplus_free(struct adfs_dir *dir) ...@@ -216,14 +216,14 @@ adfs_fplus_free(struct adfs_dir *dir)
{ {
int i; int i;
if (dir->bh_fplus) { if (dir->bhs) {
for (i = 0; i < dir->nr_buffers; i++) for (i = 0; i < dir->nr_buffers; i++)
brelse(dir->bh_fplus[i]); brelse(dir->bhs[i]);
if (&dir->bh[0] != dir->bh_fplus) if (&dir->bh[0] != dir->bhs)
kfree(dir->bh_fplus); kfree(dir->bhs);
dir->bh_fplus = NULL; dir->bhs = NULL;
} }
dir->nr_buffers = 0; 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