]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
fs/adfs: dir: add common dir object initialisation
authorRussell King <rmk+kernel@armlinux.org.uk>
Mon, 9 Dec 2019 11:09:15 +0000 (11:09 +0000)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 21 Jan 2020 01:12:40 +0000 (20:12 -0500)
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>
fs/adfs/dir.c
fs/adfs/dir_f.c
fs/adfs/dir_fplus.c

index a54c53244992f67f60735d4313ca57564b40855c..c1b8b5bccbec761ea3b73fc9bb5c68d277947e20 100644 (file)
  */
 static DEFINE_RWLOCK(adfs_dir_lock);
 
+static int adfs_dir_read(struct super_block *sb, u32 indaddr,
+                        unsigned int size, struct adfs_dir *dir)
+{
+       dir->sb = sb;
+       dir->bhs = dir->bh;
+       dir->nr_buffers = 0;
+
+       return ADFS_SB(sb)->s_dir->read(sb, indaddr, size, dir);
+}
+
 void adfs_object_fixup(struct adfs_dir *dir, struct object_info *obj)
 {
        unsigned int dots, i;
@@ -64,7 +74,7 @@ adfs_readdir(struct file *file, struct dir_context *ctx)
        if (ctx->pos >> 32)
                return 0;
 
-       ret = ops->read(sb, inode->i_ino, inode->i_size, &dir);
+       ret = adfs_dir_read(sb, inode->i_ino, inode->i_size, &dir);
        if (ret)
                return ret;
 
@@ -115,7 +125,7 @@ adfs_dir_update(struct super_block *sb, struct object_info *obj, int wait)
                goto out;
        }
 
-       ret = ops->read(sb, obj->parent_id, 0, &dir);
+       ret = adfs_dir_read(sb, obj->parent_id, 0, &dir);
        if (ret)
                goto out;
 
@@ -167,7 +177,7 @@ static int adfs_dir_lookup_byname(struct inode *inode, const struct qstr *qstr,
        u32 name_len;
        int ret;
 
-       ret = ops->read(sb, inode->i_ino, inode->i_size, &dir);
+       ret = adfs_dir_read(sb, inode->i_ino, inode->i_size, &dir);
        if (ret)
                goto out;
 
index c1a950c7400a6b21f4b84a40df9077f34b27067b..e62f35eb77894b7627e28f31935f82154125ef90 100644 (file)
@@ -139,9 +139,6 @@ static int adfs_dir_read(struct super_block *sb, u32 indaddr,
 
        size >>= blocksize_bits;
 
-       dir->nr_buffers = 0;
-       dir->sb = sb;
-
        for (blk = 0; blk < size; blk++) {
                int phys;
 
index 5f5420c9b94386baa51f5a83769b3b4206b30811..52c42a9986d99b77e2611398784f0cfd7ca1c62b 100644 (file)
@@ -17,11 +17,6 @@ adfs_fplus_read(struct super_block *sb, unsigned int id, unsigned int sz, struct
        unsigned int blk, size;
        int i, ret = -EIO;
 
-       dir->nr_buffers = 0;
-
-       /* start off using fixed bh set - only alloc for big dirs */
-       dir->bhs = &dir->bh[0];
-
        block = __adfs_block_map(sb, id, 0);
        if (!block) {
                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
        }
 
        dir->parent_id = le32_to_cpu(h->bigdirparent);
-       dir->sb = sb;
        return 0;
 
 out: