[PATCH] ufs: ufs_read_inode cleanup

Add missed ufsi->i_dir_start_lookup initialization in ufs_read_inode in
UFS2 case.  Also it cleans ufs_read_inode function to prevent such kind of
situation in the future: it move depend on UFS type parts of code into
separate functions and leaves in ufs_read_inode only generic code.  It
cleans code and avoids duplication.

Signed-off-by: Evgeniy Dushistov <dushistov@mail.ru>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Evgeniy Dushistov 2006-06-27 02:53:59 -07:00 committed by Linus Torvalds
parent 0ca0666490
commit 05f225dc87

View File

@ -605,39 +605,12 @@ static void ufs_set_inode_ops(struct inode *inode)
ufs_get_inode_dev(inode->i_sb, UFS_I(inode))); ufs_get_inode_dev(inode->i_sb, UFS_I(inode)));
} }
void ufs_read_inode (struct inode * inode) static void ufs1_read_inode(struct inode *inode, struct ufs_inode *ufs_inode)
{ {
struct ufs_inode_info *ufsi = UFS_I(inode); struct ufs_inode_info *ufsi = UFS_I(inode);
struct super_block * sb; struct super_block *sb = inode->i_sb;
struct ufs_sb_private_info * uspi;
struct ufs_inode * ufs_inode;
struct ufs2_inode *ufs2_inode;
struct buffer_head * bh;
mode_t mode; mode_t mode;
unsigned i; unsigned i;
unsigned flags;
UFSD("ENTER, ino %lu\n", inode->i_ino);
sb = inode->i_sb;
uspi = UFS_SB(sb)->s_uspi;
flags = UFS_SB(sb)->s_flags;
if (inode->i_ino < UFS_ROOTINO ||
inode->i_ino > (uspi->s_ncg * uspi->s_ipg)) {
ufs_warning (sb, "ufs_read_inode", "bad inode number (%lu)\n", inode->i_ino);
goto bad_inode;
}
bh = sb_bread(sb, uspi->s_sbbase + ufs_inotofsba(inode->i_ino));
if (!bh) {
ufs_warning (sb, "ufs_read_inode", "unable to read inode %lu\n", inode->i_ino);
goto bad_inode;
}
if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2)
goto ufs2_inode;
ufs_inode = (struct ufs_inode *) (bh->b_data + sizeof(struct ufs_inode) * ufs_inotofsbo(inode->i_ino));
/* /*
* Copy data to the in-core inode. * Copy data to the in-core inode.
@ -661,14 +634,11 @@ void ufs_read_inode (struct inode * inode)
inode->i_atime.tv_nsec = 0; inode->i_atime.tv_nsec = 0;
inode->i_ctime.tv_nsec = 0; inode->i_ctime.tv_nsec = 0;
inode->i_blocks = fs32_to_cpu(sb, ufs_inode->ui_blocks); inode->i_blocks = fs32_to_cpu(sb, ufs_inode->ui_blocks);
inode->i_blksize = PAGE_SIZE; /* This is the optimal IO size (for stat) */
inode->i_version++;
ufsi->i_flags = fs32_to_cpu(sb, ufs_inode->ui_flags); ufsi->i_flags = fs32_to_cpu(sb, ufs_inode->ui_flags);
ufsi->i_gen = fs32_to_cpu(sb, ufs_inode->ui_gen); ufsi->i_gen = fs32_to_cpu(sb, ufs_inode->ui_gen);
ufsi->i_shadow = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_shadow); ufsi->i_shadow = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_shadow);
ufsi->i_oeftflag = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_oeftflag); ufsi->i_oeftflag = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_oeftflag);
ufsi->i_lastfrag = (inode->i_size + uspi->s_fsize - 1) >> uspi->s_fshift;
ufsi->i_dir_start_lookup = 0;
if (S_ISCHR(mode) || S_ISBLK(mode) || inode->i_blocks) { if (S_ISCHR(mode) || S_ISBLK(mode) || inode->i_blocks) {
for (i = 0; i < (UFS_NDADDR + UFS_NINDIR); i++) for (i = 0; i < (UFS_NDADDR + UFS_NINDIR); i++)
@ -677,24 +647,16 @@ void ufs_read_inode (struct inode * inode)
for (i = 0; i < (UFS_NDADDR + UFS_NINDIR) * 4; i++) for (i = 0; i < (UFS_NDADDR + UFS_NINDIR) * 4; i++)
ufsi->i_u1.i_symlink[i] = ufs_inode->ui_u2.ui_symlink[i]; ufsi->i_u1.i_symlink[i] = ufs_inode->ui_u2.ui_symlink[i];
} }
ufsi->i_osync = 0; }
ufs_set_inode_ops(inode); static void ufs2_read_inode(struct inode *inode, struct ufs2_inode *ufs2_inode)
{
struct ufs_inode_info *ufsi = UFS_I(inode);
struct super_block *sb = inode->i_sb;
mode_t mode;
unsigned i;
brelse (bh);
UFSD("EXIT\n");
return;
bad_inode:
make_bad_inode(inode);
return;
ufs2_inode :
UFSD("Reading ufs2 inode, ino %lu\n", inode->i_ino); UFSD("Reading ufs2 inode, ino %lu\n", inode->i_ino);
ufs2_inode = (struct ufs2_inode *)(bh->b_data + sizeof(struct ufs2_inode) * ufs_inotofsbo(inode->i_ino));
/* /*
* Copy data to the in-core inode. * Copy data to the in-core inode.
*/ */
@ -717,26 +679,64 @@ ufs2_inode :
inode->i_atime.tv_nsec = 0; inode->i_atime.tv_nsec = 0;
inode->i_ctime.tv_nsec = 0; inode->i_ctime.tv_nsec = 0;
inode->i_blocks = fs64_to_cpu(sb, ufs2_inode->ui_blocks); inode->i_blocks = fs64_to_cpu(sb, ufs2_inode->ui_blocks);
inode->i_blksize = PAGE_SIZE; /*This is the optimal IO size(for stat)*/
inode->i_version++;
ufsi->i_flags = fs32_to_cpu(sb, ufs2_inode->ui_flags); ufsi->i_flags = fs32_to_cpu(sb, ufs2_inode->ui_flags);
ufsi->i_gen = fs32_to_cpu(sb, ufs2_inode->ui_gen); ufsi->i_gen = fs32_to_cpu(sb, ufs2_inode->ui_gen);
/* /*
ufsi->i_shadow = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_shadow); ufsi->i_shadow = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_shadow);
ufsi->i_oeftflag = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_oeftflag); ufsi->i_oeftflag = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_oeftflag);
*/ */
ufsi->i_lastfrag= (inode->i_size + uspi->s_fsize- 1) >> uspi->s_fshift;
if (S_ISCHR(mode) || S_ISBLK(mode) || inode->i_blocks) { if (S_ISCHR(mode) || S_ISBLK(mode) || inode->i_blocks) {
for (i = 0; i < (UFS_NDADDR + UFS_NINDIR); i++) for (i = 0; i < (UFS_NDADDR + UFS_NINDIR); i++)
ufsi->i_u1.u2_i_data[i] = ufsi->i_u1.u2_i_data[i] =
ufs2_inode->ui_u2.ui_addr.ui_db[i]; ufs2_inode->ui_u2.ui_addr.ui_db[i];
} } else {
else {
for (i = 0; i < (UFS_NDADDR + UFS_NINDIR) * 4; i++) for (i = 0; i < (UFS_NDADDR + UFS_NINDIR) * 4; i++)
ufsi->i_u1.i_symlink[i] = ufs2_inode->ui_u2.ui_symlink[i]; ufsi->i_u1.i_symlink[i] = ufs2_inode->ui_u2.ui_symlink[i];
} }
}
void ufs_read_inode(struct inode * inode)
{
struct ufs_inode_info *ufsi = UFS_I(inode);
struct super_block * sb;
struct ufs_sb_private_info * uspi;
struct buffer_head * bh;
UFSD("ENTER, ino %lu\n", inode->i_ino);
sb = inode->i_sb;
uspi = UFS_SB(sb)->s_uspi;
if (inode->i_ino < UFS_ROOTINO ||
inode->i_ino > (uspi->s_ncg * uspi->s_ipg)) {
ufs_warning(sb, "ufs_read_inode", "bad inode number (%lu)\n",
inode->i_ino);
goto bad_inode;
}
bh = sb_bread(sb, uspi->s_sbbase + ufs_inotofsba(inode->i_ino));
if (!bh) {
ufs_warning(sb, "ufs_read_inode", "unable to read inode %lu\n",
inode->i_ino);
goto bad_inode;
}
if ((UFS_SB(sb)->s_flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) {
struct ufs2_inode *ufs2_inode = (struct ufs2_inode *)bh->b_data;
ufs2_read_inode(inode,
ufs2_inode + ufs_inotofsbo(inode->i_ino));
} else {
struct ufs_inode *ufs_inode = (struct ufs_inode *)bh->b_data;
ufs1_read_inode(inode, ufs_inode + ufs_inotofsbo(inode->i_ino));
}
inode->i_blksize = PAGE_SIZE;/*This is the optimal IO size (for stat)*/
inode->i_version++;
ufsi->i_lastfrag =
(inode->i_size + uspi->s_fsize - 1) >> uspi->s_fshift;
ufsi->i_dir_start_lookup = 0;
ufsi->i_osync = 0; ufsi->i_osync = 0;
ufs_set_inode_ops(inode); ufs_set_inode_ops(inode);
@ -745,6 +745,9 @@ ufs2_inode :
UFSD("EXIT\n"); UFSD("EXIT\n");
return; return;
bad_inode:
make_bad_inode(inode);
} }
static int ufs_update_inode(struct inode * inode, int do_sync) static int ufs_update_inode(struct inode * inode, int do_sync)