Skip to content

Commit 95fbadb

Browse files
Russell KingAl Viro
authored andcommitted
fs/adfs: dir: add common dir object initialisation
Initialise the dir object before we pass it down to the directory format specific read handler. This allows us to get rid of the initialisation inside those handlers. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 71b2612 commit 95fbadb

3 files changed

Lines changed: 13 additions & 12 deletions

File tree

‎fs/adfs/dir.c‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@
1313
*/
1414
static DEFINE_RWLOCK(adfs_dir_lock);
1515

16+
static int adfs_dir_read(struct super_block *sb, u32 indaddr,
17+
unsigned int size, struct adfs_dir *dir)
18+
{
19+
dir->sb = sb;
20+
dir->bhs = dir->bh;
21+
dir->nr_buffers = 0;
22+
23+
return ADFS_SB(sb)->s_dir->read(sb, indaddr, size, dir);
24+
}
25+
1626
void adfs_object_fixup(struct adfs_dir *dir, struct object_info *obj)
1727
{
1828
unsigned int dots, i;
@@ -64,7 +74,7 @@ adfs_readdir(struct file *file, struct dir_context *ctx)
6474
if (ctx->pos >> 32)
6575
return 0;
6676

67-
ret = ops->read(sb, inode->i_ino, inode->i_size, &dir);
77+
ret = adfs_dir_read(sb, inode->i_ino, inode->i_size, &dir);
6878
if (ret)
6979
return ret;
7080

@@ -115,7 +125,7 @@ adfs_dir_update(struct super_block *sb, struct object_info *obj, int wait)
115125
goto out;
116126
}
117127

118-
ret = ops->read(sb, obj->parent_id, 0, &dir);
128+
ret = adfs_dir_read(sb, obj->parent_id, 0, &dir);
119129
if (ret)
120130
goto out;
121131

@@ -167,7 +177,7 @@ static int adfs_dir_lookup_byname(struct inode *inode, const struct qstr *qstr,
167177
u32 name_len;
168178
int ret;
169179

170-
ret = ops->read(sb, inode->i_ino, inode->i_size, &dir);
180+
ret = adfs_dir_read(sb, inode->i_ino, inode->i_size, &dir);
171181
if (ret)
172182
goto out;
173183

‎fs/adfs/dir_f.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,6 @@ static int adfs_dir_read(struct super_block *sb, u32 indaddr,
139139

140140
size >>= blocksize_bits;
141141

142-
dir->nr_buffers = 0;
143-
dir->sb = sb;
144-
145142
for (blk = 0; blk < size; blk++) {
146143
int phys;
147144

‎fs/adfs/dir_fplus.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct
1717
unsigned int blk, size;
1818
int i, ret = -EIO;
1919

20-
dir->nr_buffers = 0;
21-
22-
/* start off using fixed bh set - only alloc for big dirs */
23-
dir->bhs = &dir->bh[0];
24-
2520
block = __adfs_block_map(sb, id, 0);
2621
if (!block) {
2722
adfs_error(sb, "dir object %X has a hole at offset 0", id);
@@ -94,7 +89,6 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct
9489
}
9590

9691
dir->parent_id = le32_to_cpu(h->bigdirparent);
97-
dir->sb = sb;
9892
return 0;
9993

10094
out:

0 commit comments

Comments
 (0)