[PATCH] ufs2 write: inodes write
This patch adds into write inode path function to write UFS2 inode, and modifys allocate inode path to allocate and init additional inode chunks. Also some cleanups: - remove not used parameters in some functions - remove i_gen field from ufs_inode_info structure, there is i_generation in inode structure with same purposes. Signed-off-by: Evgeniy Dushistov <dushistov@mail.ru> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Родитель
cbcae39fa1
Коммит
3313e29267
112
fs/ufs/ialloc.c
112
fs/ufs/ialloc.c
|
@ -18,6 +18,9 @@
|
||||||
* Stephen Tweedie (sct@dcs.ed.ac.uk), 1993
|
* Stephen Tweedie (sct@dcs.ed.ac.uk), 1993
|
||||||
* Big-endian to little-endian byte-swapping/bitmaps by
|
* Big-endian to little-endian byte-swapping/bitmaps by
|
||||||
* David S. Miller (davem@caip.rutgers.edu), 1995
|
* David S. Miller (davem@caip.rutgers.edu), 1995
|
||||||
|
*
|
||||||
|
* UFS2 write support added by
|
||||||
|
* Evgeniy Dushistov <dushistov@mail.ru>, 2007
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/fs.h>
|
#include <linux/fs.h>
|
||||||
|
@ -125,6 +128,47 @@ void ufs_free_inode (struct inode * inode)
|
||||||
UFSD("EXIT\n");
|
UFSD("EXIT\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Nullify new chunk of inodes,
|
||||||
|
* BSD people also set ui_gen field of inode
|
||||||
|
* during nullification, but we not care about
|
||||||
|
* that because of linux ufs do not support NFS
|
||||||
|
*/
|
||||||
|
static void ufs2_init_inodes_chunk(struct super_block *sb,
|
||||||
|
struct ufs_cg_private_info *ucpi,
|
||||||
|
struct ufs_cylinder_group *ucg)
|
||||||
|
{
|
||||||
|
struct buffer_head *bh;
|
||||||
|
struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
|
||||||
|
sector_t beg = uspi->s_sbbase +
|
||||||
|
ufs_inotofsba(ucpi->c_cgx * uspi->s_ipg +
|
||||||
|
fs32_to_cpu(sb, ucg->cg_u.cg_u2.cg_initediblk));
|
||||||
|
sector_t end = beg + uspi->s_fpb;
|
||||||
|
|
||||||
|
UFSD("ENTER cgno %d\n", ucpi->c_cgx);
|
||||||
|
|
||||||
|
for (; beg < end; ++beg) {
|
||||||
|
bh = sb_getblk(sb, beg);
|
||||||
|
lock_buffer(bh);
|
||||||
|
memset(bh->b_data, 0, sb->s_blocksize);
|
||||||
|
set_buffer_uptodate(bh);
|
||||||
|
mark_buffer_dirty(bh);
|
||||||
|
unlock_buffer(bh);
|
||||||
|
if (sb->s_flags & MS_SYNCHRONOUS)
|
||||||
|
sync_dirty_buffer(bh);
|
||||||
|
brelse(bh);
|
||||||
|
}
|
||||||
|
|
||||||
|
fs32_add(sb, &ucg->cg_u.cg_u2.cg_initediblk, uspi->s_inopb);
|
||||||
|
ubh_mark_buffer_dirty(UCPI_UBH(ucpi));
|
||||||
|
if (sb->s_flags & MS_SYNCHRONOUS) {
|
||||||
|
ubh_ll_rw_block(SWRITE, UCPI_UBH(ucpi));
|
||||||
|
ubh_wait_on_buffer(UCPI_UBH(ucpi));
|
||||||
|
}
|
||||||
|
|
||||||
|
UFSD("EXIT\n");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* There are two policies for allocating an inode. If the new inode is
|
* There are two policies for allocating an inode. If the new inode is
|
||||||
* a directory, then a forward search is made for a block group with both
|
* a directory, then a forward search is made for a block group with both
|
||||||
|
@ -146,6 +190,7 @@ struct inode * ufs_new_inode(struct inode * dir, int mode)
|
||||||
struct inode * inode;
|
struct inode * inode;
|
||||||
unsigned cg, bit, i, j, start;
|
unsigned cg, bit, i, j, start;
|
||||||
struct ufs_inode_info *ufsi;
|
struct ufs_inode_info *ufsi;
|
||||||
|
int err = -ENOSPC;
|
||||||
|
|
||||||
UFSD("ENTER\n");
|
UFSD("ENTER\n");
|
||||||
|
|
||||||
|
@ -203,8 +248,10 @@ struct inode * ufs_new_inode(struct inode * dir, int mode)
|
||||||
|
|
||||||
cg_found:
|
cg_found:
|
||||||
ucpi = ufs_load_cylinder (sb, cg);
|
ucpi = ufs_load_cylinder (sb, cg);
|
||||||
if (!ucpi)
|
if (!ucpi) {
|
||||||
|
err = -EIO;
|
||||||
goto failed;
|
goto failed;
|
||||||
|
}
|
||||||
ucg = ubh_get_ucg(UCPI_UBH(ucpi));
|
ucg = ubh_get_ucg(UCPI_UBH(ucpi));
|
||||||
if (!ufs_cg_chkmagic(sb, ucg))
|
if (!ufs_cg_chkmagic(sb, ucg))
|
||||||
ufs_panic (sb, "ufs_new_inode", "internal error, bad cg magic number");
|
ufs_panic (sb, "ufs_new_inode", "internal error, bad cg magic number");
|
||||||
|
@ -216,6 +263,7 @@ cg_found:
|
||||||
if (!(bit < start)) {
|
if (!(bit < start)) {
|
||||||
ufs_error (sb, "ufs_new_inode",
|
ufs_error (sb, "ufs_new_inode",
|
||||||
"cylinder group %u corrupted - error in inode bitmap\n", cg);
|
"cylinder group %u corrupted - error in inode bitmap\n", cg);
|
||||||
|
err = -EIO;
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -224,9 +272,18 @@ cg_found:
|
||||||
ubh_setbit (UCPI_UBH(ucpi), ucpi->c_iusedoff, bit);
|
ubh_setbit (UCPI_UBH(ucpi), ucpi->c_iusedoff, bit);
|
||||||
else {
|
else {
|
||||||
ufs_panic (sb, "ufs_new_inode", "internal error");
|
ufs_panic (sb, "ufs_new_inode", "internal error");
|
||||||
|
err = -EIO;
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (uspi->fs_magic == UFS2_MAGIC) {
|
||||||
|
u32 initediblk = fs32_to_cpu(sb, ucg->cg_u.cg_u2.cg_initediblk);
|
||||||
|
|
||||||
|
if (bit + uspi->s_inopb > initediblk &&
|
||||||
|
initediblk < fs32_to_cpu(sb, ucg->cg_u.cg_u2.cg_niblk))
|
||||||
|
ufs2_init_inodes_chunk(sb, ucpi, ucg);
|
||||||
|
}
|
||||||
|
|
||||||
fs32_sub(sb, &ucg->cg_cs.cs_nifree, 1);
|
fs32_sub(sb, &ucg->cg_cs.cs_nifree, 1);
|
||||||
uspi->cs_total.cs_nifree--;
|
uspi->cs_total.cs_nifree--;
|
||||||
fs32_sub(sb, &sbi->fs_cs(cg).cs_nifree, 1);
|
fs32_sub(sb, &sbi->fs_cs(cg).cs_nifree, 1);
|
||||||
|
@ -236,7 +293,6 @@ cg_found:
|
||||||
uspi->cs_total.cs_ndir++;
|
uspi->cs_total.cs_ndir++;
|
||||||
fs32_add(sb, &sbi->fs_cs(cg).cs_ndir, 1);
|
fs32_add(sb, &sbi->fs_cs(cg).cs_ndir, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ubh_mark_buffer_dirty (USPI_UBH(uspi));
|
ubh_mark_buffer_dirty (USPI_UBH(uspi));
|
||||||
ubh_mark_buffer_dirty (UCPI_UBH(ucpi));
|
ubh_mark_buffer_dirty (UCPI_UBH(ucpi));
|
||||||
if (sb->s_flags & MS_SYNCHRONOUS) {
|
if (sb->s_flags & MS_SYNCHRONOUS) {
|
||||||
|
@ -245,6 +301,7 @@ cg_found:
|
||||||
}
|
}
|
||||||
sb->s_dirt = 1;
|
sb->s_dirt = 1;
|
||||||
|
|
||||||
|
inode->i_ino = cg * uspi->s_ipg + bit;
|
||||||
inode->i_mode = mode;
|
inode->i_mode = mode;
|
||||||
inode->i_uid = current->fsuid;
|
inode->i_uid = current->fsuid;
|
||||||
if (dir->i_mode & S_ISGID) {
|
if (dir->i_mode & S_ISGID) {
|
||||||
|
@ -254,39 +311,72 @@ cg_found:
|
||||||
} else
|
} else
|
||||||
inode->i_gid = current->fsgid;
|
inode->i_gid = current->fsgid;
|
||||||
|
|
||||||
inode->i_ino = cg * uspi->s_ipg + bit;
|
|
||||||
inode->i_blocks = 0;
|
inode->i_blocks = 0;
|
||||||
|
inode->i_generation = 0;
|
||||||
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
|
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
|
||||||
ufsi->i_flags = UFS_I(dir)->i_flags;
|
ufsi->i_flags = UFS_I(dir)->i_flags;
|
||||||
ufsi->i_lastfrag = 0;
|
ufsi->i_lastfrag = 0;
|
||||||
ufsi->i_gen = 0;
|
|
||||||
ufsi->i_shadow = 0;
|
ufsi->i_shadow = 0;
|
||||||
ufsi->i_osync = 0;
|
ufsi->i_osync = 0;
|
||||||
ufsi->i_oeftflag = 0;
|
ufsi->i_oeftflag = 0;
|
||||||
ufsi->i_dir_start_lookup = 0;
|
ufsi->i_dir_start_lookup = 0;
|
||||||
memset(&ufsi->i_u1, 0, sizeof(ufsi->i_u1));
|
memset(&ufsi->i_u1, 0, sizeof(ufsi->i_u1));
|
||||||
|
|
||||||
insert_inode_hash(inode);
|
insert_inode_hash(inode);
|
||||||
mark_inode_dirty(inode);
|
mark_inode_dirty(inode);
|
||||||
|
|
||||||
|
if (uspi->fs_magic == UFS2_MAGIC) {
|
||||||
|
struct buffer_head *bh;
|
||||||
|
struct ufs2_inode *ufs2_inode;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* setup birth date, we do it here because of there is no sense
|
||||||
|
* to hold it in struct ufs_inode_info, and lose 64 bit
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
err = -EIO;
|
||||||
|
goto fail_remove_inode;
|
||||||
|
}
|
||||||
|
lock_buffer(bh);
|
||||||
|
ufs2_inode = (struct ufs2_inode *)bh->b_data;
|
||||||
|
ufs2_inode += ufs_inotofsbo(inode->i_ino);
|
||||||
|
ufs2_inode->ui_birthtime.tv_sec =
|
||||||
|
cpu_to_fs32(sb, CURRENT_TIME_SEC.tv_sec);
|
||||||
|
ufs2_inode->ui_birthtime.tv_usec = 0;
|
||||||
|
mark_buffer_dirty(bh);
|
||||||
|
unlock_buffer(bh);
|
||||||
|
if (sb->s_flags & MS_SYNCHRONOUS)
|
||||||
|
sync_dirty_buffer(bh);
|
||||||
|
brelse(bh);
|
||||||
|
}
|
||||||
|
|
||||||
unlock_super (sb);
|
unlock_super (sb);
|
||||||
|
|
||||||
if (DQUOT_ALLOC_INODE(inode)) {
|
if (DQUOT_ALLOC_INODE(inode)) {
|
||||||
DQUOT_DROP(inode);
|
DQUOT_DROP(inode);
|
||||||
inode->i_flags |= S_NOQUOTA;
|
err = -EDQUOT;
|
||||||
inode->i_nlink = 0;
|
goto fail_without_unlock;
|
||||||
iput(inode);
|
|
||||||
return ERR_PTR(-EDQUOT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UFSD("allocating inode %lu\n", inode->i_ino);
|
UFSD("allocating inode %lu\n", inode->i_ino);
|
||||||
UFSD("EXIT\n");
|
UFSD("EXIT\n");
|
||||||
return inode;
|
return inode;
|
||||||
|
|
||||||
|
fail_remove_inode:
|
||||||
|
unlock_super(sb);
|
||||||
|
fail_without_unlock:
|
||||||
|
inode->i_flags |= S_NOQUOTA;
|
||||||
|
inode->i_nlink = 0;
|
||||||
|
iput(inode);
|
||||||
|
UFSD("EXIT (FAILED): err %d\n", err);
|
||||||
|
return ERR_PTR(err);
|
||||||
failed:
|
failed:
|
||||||
unlock_super (sb);
|
unlock_super (sb);
|
||||||
make_bad_inode(inode);
|
make_bad_inode(inode);
|
||||||
iput (inode);
|
iput (inode);
|
||||||
UFSD("EXIT (FAILED)\n");
|
UFSD("EXIT (FAILED): err %d\n", err);
|
||||||
return ERR_PTR(-ENOSPC);
|
return ERR_PTR(err);
|
||||||
}
|
}
|
||||||
|
|
111
fs/ufs/inode.c
111
fs/ufs/inode.c
|
@ -616,8 +616,8 @@ static void ufs1_read_inode(struct inode *inode, struct ufs_inode *ufs_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_generation = fs32_to_cpu(sb, ufs_inode->ui_gen);
|
||||||
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_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);
|
||||||
|
|
||||||
|
@ -661,8 +661,8 @@ static void ufs2_read_inode(struct inode *inode, struct ufs2_inode *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_generation = fs32_to_cpu(sb, ufs2_inode->ui_gen);
|
||||||
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_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);
|
||||||
|
@ -731,34 +731,11 @@ bad_inode:
|
||||||
make_bad_inode(inode);
|
make_bad_inode(inode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ufs_update_inode(struct inode * inode, int do_sync)
|
static void ufs1_update_inode(struct inode *inode, struct ufs_inode *ufs_inode)
|
||||||
{
|
{
|
||||||
struct ufs_inode_info *ufsi = UFS_I(inode);
|
struct super_block *sb = inode->i_sb;
|
||||||
struct super_block * sb;
|
struct ufs_inode_info *ufsi = UFS_I(inode);
|
||||||
struct ufs_sb_private_info * uspi;
|
unsigned i;
|
||||||
struct buffer_head * bh;
|
|
||||||
struct ufs_inode * ufs_inode;
|
|
||||||
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);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bh = sb_bread(sb, ufs_inotofsba(inode->i_ino));
|
|
||||||
if (!bh) {
|
|
||||||
ufs_warning (sb, "ufs_read_inode", "unable to read inode %lu\n", inode->i_ino);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
ufs_inode = (struct ufs_inode *) (bh->b_data + ufs_inotofsbo(inode->i_ino) * sizeof(struct ufs_inode));
|
|
||||||
|
|
||||||
ufs_inode->ui_mode = cpu_to_fs16(sb, inode->i_mode);
|
ufs_inode->ui_mode = cpu_to_fs16(sb, inode->i_mode);
|
||||||
ufs_inode->ui_nlink = cpu_to_fs16(sb, inode->i_nlink);
|
ufs_inode->ui_nlink = cpu_to_fs16(sb, inode->i_nlink);
|
||||||
|
@ -775,9 +752,9 @@ static int ufs_update_inode(struct inode * inode, int do_sync)
|
||||||
ufs_inode->ui_mtime.tv_usec = 0;
|
ufs_inode->ui_mtime.tv_usec = 0;
|
||||||
ufs_inode->ui_blocks = cpu_to_fs32(sb, inode->i_blocks);
|
ufs_inode->ui_blocks = cpu_to_fs32(sb, inode->i_blocks);
|
||||||
ufs_inode->ui_flags = cpu_to_fs32(sb, ufsi->i_flags);
|
ufs_inode->ui_flags = cpu_to_fs32(sb, ufsi->i_flags);
|
||||||
ufs_inode->ui_gen = cpu_to_fs32(sb, ufsi->i_gen);
|
ufs_inode->ui_gen = cpu_to_fs32(sb, inode->i_generation);
|
||||||
|
|
||||||
if ((flags & UFS_UID_MASK) == UFS_UID_EFT) {
|
if ((UFS_SB(sb)->s_flags & UFS_UID_MASK) == UFS_UID_EFT) {
|
||||||
ufs_inode->ui_u3.ui_sun.ui_shadow = cpu_to_fs32(sb, ufsi->i_shadow);
|
ufs_inode->ui_u3.ui_sun.ui_shadow = cpu_to_fs32(sb, ufsi->i_shadow);
|
||||||
ufs_inode->ui_u3.ui_sun.ui_oeftflag = cpu_to_fs32(sb, ufsi->i_oeftflag);
|
ufs_inode->ui_u3.ui_sun.ui_oeftflag = cpu_to_fs32(sb, ufsi->i_oeftflag);
|
||||||
}
|
}
|
||||||
|
@ -796,6 +773,78 @@ static int ufs_update_inode(struct inode * inode, int do_sync)
|
||||||
|
|
||||||
if (!inode->i_nlink)
|
if (!inode->i_nlink)
|
||||||
memset (ufs_inode, 0, sizeof(struct ufs_inode));
|
memset (ufs_inode, 0, sizeof(struct ufs_inode));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ufs2_update_inode(struct inode *inode, struct ufs2_inode *ufs_inode)
|
||||||
|
{
|
||||||
|
struct super_block *sb = inode->i_sb;
|
||||||
|
struct ufs_inode_info *ufsi = UFS_I(inode);
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
|
UFSD("ENTER\n");
|
||||||
|
ufs_inode->ui_mode = cpu_to_fs16(sb, inode->i_mode);
|
||||||
|
ufs_inode->ui_nlink = cpu_to_fs16(sb, inode->i_nlink);
|
||||||
|
|
||||||
|
ufs_inode->ui_uid = cpu_to_fs32(sb, inode->i_uid);
|
||||||
|
ufs_inode->ui_gid = cpu_to_fs32(sb, inode->i_gid);
|
||||||
|
|
||||||
|
ufs_inode->ui_size = cpu_to_fs64(sb, inode->i_size);
|
||||||
|
ufs_inode->ui_atime.tv_sec = cpu_to_fs32(sb, inode->i_atime.tv_sec);
|
||||||
|
ufs_inode->ui_atime.tv_usec = 0;
|
||||||
|
ufs_inode->ui_ctime.tv_sec = cpu_to_fs32(sb, inode->i_ctime.tv_sec);
|
||||||
|
ufs_inode->ui_ctime.tv_usec = 0;
|
||||||
|
ufs_inode->ui_mtime.tv_sec = cpu_to_fs32(sb, inode->i_mtime.tv_sec);
|
||||||
|
ufs_inode->ui_mtime.tv_usec = 0;
|
||||||
|
|
||||||
|
ufs_inode->ui_blocks = cpu_to_fs64(sb, inode->i_blocks);
|
||||||
|
ufs_inode->ui_flags = cpu_to_fs32(sb, ufsi->i_flags);
|
||||||
|
ufs_inode->ui_gen = cpu_to_fs32(sb, inode->i_generation);
|
||||||
|
|
||||||
|
if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) {
|
||||||
|
/* ufs_inode->ui_u2.ui_addr.ui_db[0] = cpu_to_fs32(sb, inode->i_rdev); */
|
||||||
|
ufs_inode->ui_u2.ui_addr.ui_db[0] = ufsi->i_u1.u2_i_data[0];
|
||||||
|
} else if (inode->i_blocks) {
|
||||||
|
for (i = 0; i < (UFS_NDADDR + UFS_NINDIR); i++)
|
||||||
|
ufs_inode->ui_u2.ui_addr.ui_db[i] = ufsi->i_u1.u2_i_data[i];
|
||||||
|
} else {
|
||||||
|
for (i = 0; i < (UFS_NDADDR + UFS_NINDIR) * 4; i++)
|
||||||
|
ufs_inode->ui_u2.ui_symlink[i] = ufsi->i_u1.i_symlink[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!inode->i_nlink)
|
||||||
|
memset (ufs_inode, 0, sizeof(struct ufs2_inode));
|
||||||
|
UFSD("EXIT\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ufs_update_inode(struct inode * inode, int do_sync)
|
||||||
|
{
|
||||||
|
struct super_block *sb = inode->i_sb;
|
||||||
|
struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
|
||||||
|
struct buffer_head * bh;
|
||||||
|
|
||||||
|
UFSD("ENTER, ino %lu\n", inode->i_ino);
|
||||||
|
|
||||||
|
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);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bh = sb_bread(sb, ufs_inotofsba(inode->i_ino));
|
||||||
|
if (!bh) {
|
||||||
|
ufs_warning (sb, "ufs_read_inode", "unable to read inode %lu\n", inode->i_ino);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (uspi->fs_magic == UFS2_MAGIC) {
|
||||||
|
struct ufs2_inode *ufs2_inode = (struct ufs2_inode *)bh->b_data;
|
||||||
|
|
||||||
|
ufs2_update_inode(inode,
|
||||||
|
ufs2_inode + ufs_inotofsbo(inode->i_ino));
|
||||||
|
} else {
|
||||||
|
struct ufs_inode *ufs_inode = (struct ufs_inode *) bh->b_data;
|
||||||
|
|
||||||
|
ufs1_update_inode(inode, ufs_inode + ufs_inotofsbo(inode->i_ino));
|
||||||
|
}
|
||||||
|
|
||||||
mark_buffer_dirty(bh);
|
mark_buffer_dirty(bh);
|
||||||
if (do_sync)
|
if (do_sync)
|
||||||
|
|
|
@ -95,14 +95,16 @@
|
||||||
/*
|
/*
|
||||||
* Print contents of ufs_super_block, useful for debugging
|
* Print contents of ufs_super_block, useful for debugging
|
||||||
*/
|
*/
|
||||||
static void ufs_print_super_stuff(struct super_block *sb, unsigned flags,
|
static void ufs_print_super_stuff(struct super_block *sb,
|
||||||
struct ufs_super_block_first *usb1,
|
struct ufs_super_block_first *usb1,
|
||||||
struct ufs_super_block_second *usb2,
|
struct ufs_super_block_second *usb2,
|
||||||
struct ufs_super_block_third *usb3)
|
struct ufs_super_block_third *usb3)
|
||||||
{
|
{
|
||||||
|
u32 magic = fs32_to_cpu(sb, usb3->fs_magic);
|
||||||
|
|
||||||
printk("ufs_print_super_stuff\n");
|
printk("ufs_print_super_stuff\n");
|
||||||
printk(" magic: 0x%x\n", fs32_to_cpu(sb, usb3->fs_magic));
|
printk(" magic: 0x%x\n", magic);
|
||||||
if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) {
|
if (fs32_to_cpu(sb, usb3->fs_magic) == UFS2_MAGIC) {
|
||||||
printk(" fs_size: %llu\n", (unsigned long long)
|
printk(" fs_size: %llu\n", (unsigned long long)
|
||||||
fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_size));
|
fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_size));
|
||||||
printk(" fs_dsize: %llu\n", (unsigned long long)
|
printk(" fs_dsize: %llu\n", (unsigned long long)
|
||||||
|
@ -119,6 +121,12 @@ static void ufs_print_super_stuff(struct super_block *sb, unsigned flags,
|
||||||
printk(" cs_nbfree(No of free blocks): %llu\n",
|
printk(" cs_nbfree(No of free blocks): %llu\n",
|
||||||
(unsigned long long)
|
(unsigned long long)
|
||||||
fs64_to_cpu(sb, usb2->fs_un.fs_u2.cs_nbfree));
|
fs64_to_cpu(sb, usb2->fs_un.fs_u2.cs_nbfree));
|
||||||
|
printk(KERN_INFO" cs_nifree(Num of free inodes): %llu\n",
|
||||||
|
(unsigned long long)
|
||||||
|
fs64_to_cpu(sb, usb3->fs_un1.fs_u2.cs_nifree));
|
||||||
|
printk(KERN_INFO" cs_nffree(Num of free frags): %llu\n",
|
||||||
|
(unsigned long long)
|
||||||
|
fs64_to_cpu(sb, usb3->fs_un1.fs_u2.cs_nffree));
|
||||||
} else {
|
} else {
|
||||||
printk(" sblkno: %u\n", fs32_to_cpu(sb, usb1->fs_sblkno));
|
printk(" sblkno: %u\n", fs32_to_cpu(sb, usb1->fs_sblkno));
|
||||||
printk(" cblkno: %u\n", fs32_to_cpu(sb, usb1->fs_cblkno));
|
printk(" cblkno: %u\n", fs32_to_cpu(sb, usb1->fs_cblkno));
|
||||||
|
@ -201,7 +209,7 @@ static void ufs_print_cylinder_stuff(struct super_block *sb,
|
||||||
printk("\n");
|
printk("\n");
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define ufs_print_super_stuff(sb, flags, usb1, usb2, usb3) /**/
|
# define ufs_print_super_stuff(sb, usb1, usb2, usb3) /**/
|
||||||
# define ufs_print_cylinder_stuff(sb, cg) /**/
|
# define ufs_print_cylinder_stuff(sb, cg) /**/
|
||||||
#endif /* CONFIG_UFS_DEBUG */
|
#endif /* CONFIG_UFS_DEBUG */
|
||||||
|
|
||||||
|
@ -424,7 +432,6 @@ static int ufs_read_cylinder_structures(struct super_block *sb)
|
||||||
{
|
{
|
||||||
struct ufs_sb_info *sbi = UFS_SB(sb);
|
struct ufs_sb_info *sbi = UFS_SB(sb);
|
||||||
struct ufs_sb_private_info *uspi = sbi->s_uspi;
|
struct ufs_sb_private_info *uspi = sbi->s_uspi;
|
||||||
unsigned flags = sbi->s_flags;
|
|
||||||
struct ufs_buffer_head * ubh;
|
struct ufs_buffer_head * ubh;
|
||||||
unsigned char * base, * space;
|
unsigned char * base, * space;
|
||||||
unsigned size, blks, i;
|
unsigned size, blks, i;
|
||||||
|
@ -448,11 +455,7 @@ static int ufs_read_cylinder_structures(struct super_block *sb)
|
||||||
if (i + uspi->s_fpb > blks)
|
if (i + uspi->s_fpb > blks)
|
||||||
size = (blks - i) * uspi->s_fsize;
|
size = (blks - i) * uspi->s_fsize;
|
||||||
|
|
||||||
if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2)
|
ubh = ubh_bread(sb, uspi->s_csaddr + i, size);
|
||||||
ubh = ubh_bread(sb,
|
|
||||||
fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_csaddr) + i, size);
|
|
||||||
else
|
|
||||||
ubh = ubh_bread(sb, uspi->s_csaddr + i, size);
|
|
||||||
|
|
||||||
if (!ubh)
|
if (!ubh)
|
||||||
goto failed;
|
goto failed;
|
||||||
|
@ -547,6 +550,7 @@ static void ufs_put_cstotal(struct super_block *sb)
|
||||||
cpu_to_fs32(sb, uspi->cs_total.cs_nffree);
|
cpu_to_fs32(sb, uspi->cs_total.cs_nffree);
|
||||||
}
|
}
|
||||||
ubh_mark_buffer_dirty(USPI_UBH(uspi));
|
ubh_mark_buffer_dirty(USPI_UBH(uspi));
|
||||||
|
ufs_print_super_stuff(sb, usb1, usb2, usb3);
|
||||||
UFSD("EXIT\n");
|
UFSD("EXIT\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -574,7 +578,9 @@ static void ufs_put_super_internal(struct super_block *sb)
|
||||||
size = uspi->s_bsize;
|
size = uspi->s_bsize;
|
||||||
if (i + uspi->s_fpb > blks)
|
if (i + uspi->s_fpb > blks)
|
||||||
size = (blks - i) * uspi->s_fsize;
|
size = (blks - i) * uspi->s_fsize;
|
||||||
|
|
||||||
ubh = ubh_bread(sb, uspi->s_csaddr + i, size);
|
ubh = ubh_bread(sb, uspi->s_csaddr + i, size);
|
||||||
|
|
||||||
ubh_memcpyubh (ubh, space, size);
|
ubh_memcpyubh (ubh, space, size);
|
||||||
space += size;
|
space += size;
|
||||||
ubh_mark_buffer_uptodate (ubh, 1);
|
ubh_mark_buffer_uptodate (ubh, 1);
|
||||||
|
@ -888,7 +894,7 @@ magic_found:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ufs_print_super_stuff(sb, flags, usb1, usb2, usb3);
|
ufs_print_super_stuff(sb, usb1, usb2, usb3);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check, if file system was correctly unmounted.
|
* Check, if file system was correctly unmounted.
|
||||||
|
@ -971,7 +977,12 @@ magic_found:
|
||||||
uspi->s_npsect = ufs_get_fs_npsect(sb, usb1, usb3);
|
uspi->s_npsect = ufs_get_fs_npsect(sb, usb1, usb3);
|
||||||
uspi->s_interleave = fs32_to_cpu(sb, usb1->fs_interleave);
|
uspi->s_interleave = fs32_to_cpu(sb, usb1->fs_interleave);
|
||||||
uspi->s_trackskew = fs32_to_cpu(sb, usb1->fs_trackskew);
|
uspi->s_trackskew = fs32_to_cpu(sb, usb1->fs_trackskew);
|
||||||
uspi->s_csaddr = fs32_to_cpu(sb, usb1->fs_csaddr);
|
|
||||||
|
if (uspi->fs_magic == UFS2_MAGIC)
|
||||||
|
uspi->s_csaddr = fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_csaddr);
|
||||||
|
else
|
||||||
|
uspi->s_csaddr = fs32_to_cpu(sb, usb1->fs_csaddr);
|
||||||
|
|
||||||
uspi->s_cssize = fs32_to_cpu(sb, usb1->fs_cssize);
|
uspi->s_cssize = fs32_to_cpu(sb, usb1->fs_cssize);
|
||||||
uspi->s_cgsize = fs32_to_cpu(sb, usb1->fs_cgsize);
|
uspi->s_cgsize = fs32_to_cpu(sb, usb1->fs_cgsize);
|
||||||
uspi->s_ntrak = fs32_to_cpu(sb, usb1->fs_ntrak);
|
uspi->s_ntrak = fs32_to_cpu(sb, usb1->fs_ntrak);
|
||||||
|
@ -1058,7 +1069,6 @@ static void ufs_write_super(struct super_block *sb)
|
||||||
unsigned flags;
|
unsigned flags;
|
||||||
|
|
||||||
lock_kernel();
|
lock_kernel();
|
||||||
|
|
||||||
UFSD("ENTER\n");
|
UFSD("ENTER\n");
|
||||||
flags = UFS_SB(sb)->s_flags;
|
flags = UFS_SB(sb)->s_flags;
|
||||||
uspi = UFS_SB(sb)->s_uspi;
|
uspi = UFS_SB(sb)->s_uspi;
|
||||||
|
|
|
@ -263,7 +263,7 @@ typedef __u16 __bitwise __fs16;
|
||||||
*/
|
*/
|
||||||
#define ufs_inotocg(x) ((x) / uspi->s_ipg)
|
#define ufs_inotocg(x) ((x) / uspi->s_ipg)
|
||||||
#define ufs_inotocgoff(x) ((x) % uspi->s_ipg)
|
#define ufs_inotocgoff(x) ((x) % uspi->s_ipg)
|
||||||
#define ufs_inotofsba(x) (ufs_cgimin(ufs_inotocg(x)) + ufs_inotocgoff(x) / uspi->s_inopf)
|
#define ufs_inotofsba(x) (((u64)ufs_cgimin(ufs_inotocg(x))) + ufs_inotocgoff(x) / uspi->s_inopf)
|
||||||
#define ufs_inotofsbo(x) ((x) % uspi->s_inopf)
|
#define ufs_inotofsbo(x) ((x) % uspi->s_inopf)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -756,7 +756,7 @@ struct ufs_sb_private_info {
|
||||||
__u32 s_npsect; /* # sectors/track including spares */
|
__u32 s_npsect; /* # sectors/track including spares */
|
||||||
__u32 s_interleave; /* hardware sector interleave */
|
__u32 s_interleave; /* hardware sector interleave */
|
||||||
__u32 s_trackskew; /* sector 0 skew, per track */
|
__u32 s_trackskew; /* sector 0 skew, per track */
|
||||||
__u32 s_csaddr; /* blk addr of cyl grp summary area */
|
__u64 s_csaddr; /* blk addr of cyl grp summary area */
|
||||||
__u32 s_cssize; /* size of cyl grp summary area */
|
__u32 s_cssize; /* size of cyl grp summary area */
|
||||||
__u32 s_cgsize; /* cylinder group size */
|
__u32 s_cgsize; /* cylinder group size */
|
||||||
__u32 s_ntrak; /* tracks per cylinder */
|
__u32 s_ntrak; /* tracks per cylinder */
|
||||||
|
|
|
@ -20,7 +20,6 @@ struct ufs_inode_info {
|
||||||
__fs64 u2_i_data[15];
|
__fs64 u2_i_data[15];
|
||||||
} i_u1;
|
} i_u1;
|
||||||
__u32 i_flags;
|
__u32 i_flags;
|
||||||
__u32 i_gen;
|
|
||||||
__u32 i_shadow;
|
__u32 i_shadow;
|
||||||
__u32 i_unused1;
|
__u32 i_unused1;
|
||||||
__u32 i_unused2;
|
__u32 i_unused2;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче