Commit 647b7e87 authored by Evgeniy Dushistov's avatar Evgeniy Dushistov Committed by Linus Torvalds

[PATCH] ufs: one way to access super block

Super block of UFS usually has size >512, because of fragment size may be 512,
this cause some problems.

Currently, there are two methods to work with ufs super block:

1) split structure which describes ufs super blocks into structures with
   size <=512

2) use one structure which describes ufs super block, and hope that array
   of "buffer_head" which holds "super block", has such construction:

	bh[n]->b_data + bh[n]->b_size == bh[n + 1]->b_data

The second variant may cause some problems in the future, and usage of two
variants cause unnecessary code duplication.

This patch remove the second variant.  Also patch contains some CodingStyle
fixes.
Signed-off-by: default avatarEvgeniy Dushistov <dushistov@mail.ru>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f3914758
This diff is collapsed.
...@@ -39,12 +39,12 @@ ufs_get_fs_state(struct super_block *sb, struct ufs_super_block_first *usb1, ...@@ -39,12 +39,12 @@ ufs_get_fs_state(struct super_block *sb, struct ufs_super_block_first *usb1,
{ {
switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) {
case UFS_ST_SUN: case UFS_ST_SUN:
return fs32_to_cpu(sb, usb3->fs_u2.fs_sun.fs_state); return fs32_to_cpu(sb, usb3->fs_un2.fs_sun.fs_state);
case UFS_ST_SUNx86: case UFS_ST_SUNx86:
return fs32_to_cpu(sb, usb1->fs_u1.fs_sunx86.fs_state); return fs32_to_cpu(sb, usb1->fs_u1.fs_sunx86.fs_state);
case UFS_ST_44BSD: case UFS_ST_44BSD:
default: default:
return fs32_to_cpu(sb, usb3->fs_u2.fs_44.fs_state); return fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_state);
} }
} }
...@@ -54,13 +54,13 @@ ufs_set_fs_state(struct super_block *sb, struct ufs_super_block_first *usb1, ...@@ -54,13 +54,13 @@ ufs_set_fs_state(struct super_block *sb, struct ufs_super_block_first *usb1,
{ {
switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) {
case UFS_ST_SUN: case UFS_ST_SUN:
usb3->fs_u2.fs_sun.fs_state = cpu_to_fs32(sb, value); usb3->fs_un2.fs_sun.fs_state = cpu_to_fs32(sb, value);
break; break;
case UFS_ST_SUNx86: case UFS_ST_SUNx86:
usb1->fs_u1.fs_sunx86.fs_state = cpu_to_fs32(sb, value); usb1->fs_u1.fs_sunx86.fs_state = cpu_to_fs32(sb, value);
break; break;
case UFS_ST_44BSD: case UFS_ST_44BSD:
usb3->fs_u2.fs_44.fs_state = cpu_to_fs32(sb, value); usb3->fs_un2.fs_44.fs_state = cpu_to_fs32(sb, value);
break; break;
} }
} }
...@@ -70,7 +70,7 @@ ufs_get_fs_npsect(struct super_block *sb, struct ufs_super_block_first *usb1, ...@@ -70,7 +70,7 @@ ufs_get_fs_npsect(struct super_block *sb, struct ufs_super_block_first *usb1,
struct ufs_super_block_third *usb3) struct ufs_super_block_third *usb3)
{ {
if ((UFS_SB(sb)->s_flags & UFS_ST_MASK) == UFS_ST_SUNx86) if ((UFS_SB(sb)->s_flags & UFS_ST_MASK) == UFS_ST_SUNx86)
return fs32_to_cpu(sb, usb3->fs_u2.fs_sunx86.fs_npsect); return fs32_to_cpu(sb, usb3->fs_un2.fs_sunx86.fs_npsect);
else else
return fs32_to_cpu(sb, usb1->fs_u1.fs_sun.fs_npsect); return fs32_to_cpu(sb, usb1->fs_u1.fs_sun.fs_npsect);
} }
...@@ -82,16 +82,16 @@ ufs_get_fs_qbmask(struct super_block *sb, struct ufs_super_block_third *usb3) ...@@ -82,16 +82,16 @@ ufs_get_fs_qbmask(struct super_block *sb, struct ufs_super_block_third *usb3)
switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) {
case UFS_ST_SUN: case UFS_ST_SUN:
((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_sun.fs_qbmask[0]; ((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_sun.fs_qbmask[0];
((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_sun.fs_qbmask[1]; ((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_sun.fs_qbmask[1];
break; break;
case UFS_ST_SUNx86: case UFS_ST_SUNx86:
((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_sunx86.fs_qbmask[0]; ((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_sunx86.fs_qbmask[0];
((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_sunx86.fs_qbmask[1]; ((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_sunx86.fs_qbmask[1];
break; break;
case UFS_ST_44BSD: case UFS_ST_44BSD:
((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_44.fs_qbmask[0]; ((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_44.fs_qbmask[0];
((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_44.fs_qbmask[1]; ((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_44.fs_qbmask[1];
break; break;
} }
...@@ -105,16 +105,16 @@ ufs_get_fs_qfmask(struct super_block *sb, struct ufs_super_block_third *usb3) ...@@ -105,16 +105,16 @@ ufs_get_fs_qfmask(struct super_block *sb, struct ufs_super_block_third *usb3)
switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) {
case UFS_ST_SUN: case UFS_ST_SUN:
((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_sun.fs_qfmask[0]; ((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_sun.fs_qfmask[0];
((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_sun.fs_qfmask[1]; ((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_sun.fs_qfmask[1];
break; break;
case UFS_ST_SUNx86: case UFS_ST_SUNx86:
((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_sunx86.fs_qfmask[0]; ((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_sunx86.fs_qfmask[0];
((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_sunx86.fs_qfmask[1]; ((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_sunx86.fs_qfmask[1];
break; break;
case UFS_ST_44BSD: case UFS_ST_44BSD:
((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_44.fs_qfmask[0]; ((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_44.fs_qfmask[0];
((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_44.fs_qfmask[1]; ((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_44.fs_qfmask[1];
break; break;
} }
...@@ -302,24 +302,6 @@ static inline void *get_usb_offset(struct ufs_sb_private_info *uspi, ...@@ -302,24 +302,6 @@ static inline void *get_usb_offset(struct ufs_sb_private_info *uspi,
#define ubh_blkmap(ubh,begin,bit) \ #define ubh_blkmap(ubh,begin,bit) \
((*ubh_get_addr(ubh, (begin) + ((bit) >> 3)) >> ((bit) & 7)) & (0xff >> (UFS_MAXFRAG - uspi->s_fpb))) ((*ubh_get_addr(ubh, (begin) + ((bit) >> 3)) >> ((bit) & 7)) & (0xff >> (UFS_MAXFRAG - uspi->s_fpb)))
/*
* Macros for access to superblock array structures
*/
#define ubh_postbl(ubh,cylno,i) \
((uspi->s_postblformat != UFS_DYNAMICPOSTBLFMT) \
? (*(__s16*)(ubh_get_addr(ubh, \
(unsigned)(&((struct ufs_super_block *)0)->fs_opostbl) \
+ (((cylno) * 16 + (i)) << 1) ) )) \
: (*(__s16*)(ubh_get_addr(ubh, \
uspi->s_postbloff + (((cylno) * uspi->s_nrpos + (i)) << 1) ))))
#define ubh_rotbl(ubh,i) \
((uspi->s_postblformat != UFS_DYNAMICPOSTBLFMT) \
? (*(__u8*)(ubh_get_addr(ubh, \
(unsigned)(&((struct ufs_super_block *)0)->fs_space) + (i)))) \
: (*(__u8*)(ubh_get_addr(ubh, uspi->s_rotbloff + (i)))))
/* /*
* Determine the number of available frags given a * Determine the number of available frags given a
* percentage to hold in reserve. * percentage to hold in reserve.
......
...@@ -351,8 +351,12 @@ struct ufs2_csum_total { ...@@ -351,8 +351,12 @@ struct ufs2_csum_total {
__fs64 cs_spare[3]; /* future expansion */ __fs64 cs_spare[3]; /* future expansion */
}; };
#if 0
/* /*
* This is the actual superblock, as it is laid out on the disk. * This is the actual superblock, as it is laid out on the disk.
* Do NOT use this structure, because of sizeof(ufs_super_block) > 512 and
* it may occupy several blocks, use
* struct ufs_super_block_(first,second,third) instead.
*/ */
struct ufs_super_block { struct ufs_super_block {
__fs32 fs_link; /* UNUSED */ __fs32 fs_link; /* UNUSED */
...@@ -498,6 +502,7 @@ struct ufs_super_block { ...@@ -498,6 +502,7 @@ struct ufs_super_block {
__fs32 fs_magic; /* magic number */ __fs32 fs_magic; /* magic number */
__u8 fs_space[1]; /* list of blocks for each rotation */ __u8 fs_space[1]; /* list of blocks for each rotation */
}; };
#endif/*struct ufs_super_block*/
/* /*
* Preference for optimization. * Preference for optimization.
...@@ -837,16 +842,54 @@ struct ufs_super_block_first { ...@@ -837,16 +842,54 @@ struct ufs_super_block_first {
}; };
struct ufs_super_block_second { struct ufs_super_block_second {
__s8 fs_fsmnt[212]; union {
__fs32 fs_cgrotor; struct {
__fs32 fs_csp[UFS_MAXCSBUFS]; __s8 fs_fsmnt[212];
__fs32 fs_maxcluster; __fs32 fs_cgrotor;
__fs32 fs_cpc; __fs32 fs_csp[UFS_MAXCSBUFS];
__fs16 fs_opostbl[82]; __fs32 fs_maxcluster;
}; __fs32 fs_cpc;
__fs16 fs_opostbl[82];
} fs_u1;
struct {
__s8 fs_fsmnt[UFS2_MAXMNTLEN - UFS_MAXMNTLEN + 212];
__u8 fs_volname[UFS2_MAXVOLLEN];
__fs64 fs_swuid;
__fs32 fs_pad;
__fs32 fs_cgrotor;
__fs32 fs_ocsp[UFS2_NOCSPTRS];
__fs32 fs_contigdirs;
__fs32 fs_csp;
__fs32 fs_maxcluster;
__fs32 fs_active;
__fs32 fs_old_cpc;
__fs32 fs_maxbsize;
__fs64 fs_sparecon64[17];
__fs64 fs_sblockloc;
__fs64 cs_ndir;
__fs64 cs_nbfree;
} fs_u2;
} fs_un;
};
struct ufs_super_block_third { struct ufs_super_block_third {
__fs16 fs_opostbl[46]; union {
struct {
__fs16 fs_opostbl[46];
} fs_u1;
struct {
__fs64 cs_nifree; /* number of free inodes */
__fs64 cs_nffree; /* number of free frags */
__fs64 cs_numclusters; /* number of free clusters */
__fs64 cs_spare[3]; /* future expansion */
struct ufs_timeval fs_time; /* last time written */
__fs64 fs_size; /* number of blocks in fs */
__fs64 fs_dsize; /* number of data blocks in fs */
__fs64 fs_csaddr; /* blk addr of cyl grp summary area */
__fs64 fs_pendingblocks;/* blocks in process of being freed */
__fs32 fs_pendinginodes;/*inodes in process of being freed */
} fs_u2;
} fs_un1;
union { union {
struct { struct {
__fs32 fs_sparecon[53];/* reserved for future constants */ __fs32 fs_sparecon[53];/* reserved for future constants */
...@@ -874,7 +917,7 @@ struct ufs_super_block_third { ...@@ -874,7 +917,7 @@ struct ufs_super_block_third {
__fs32 fs_qfmask[2]; /* ~usb_fmask */ __fs32 fs_qfmask[2]; /* ~usb_fmask */
__fs32 fs_state; /* file system state time stamp */ __fs32 fs_state; /* file system state time stamp */
} fs_44; } fs_44;
} fs_u2; } fs_un2;
__fs32 fs_postblformat; __fs32 fs_postblformat;
__fs32 fs_nrpos; __fs32 fs_nrpos;
__fs32 fs_postbloff; __fs32 fs_postbloff;
......
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