diff options
Diffstat (limited to 'fs/ufs/util.h')
-rw-r--r-- | fs/ufs/util.h | 107 |
1 files changed, 36 insertions, 71 deletions
diff --git a/fs/ufs/util.h b/fs/ufs/util.h index 48d6d9bcc157..406981fff5e7 100644 --- a/fs/ufs/util.h +++ b/fs/ufs/util.h | |||
@@ -17,10 +17,16 @@ | |||
17 | #define in_range(b,first,len) ((b)>=(first)&&(b)<(first)+(len)) | 17 | #define in_range(b,first,len) ((b)>=(first)&&(b)<(first)+(len)) |
18 | 18 | ||
19 | /* | 19 | /* |
20 | * macros used for retyping | 20 | * functions used for retyping |
21 | */ | 21 | */ |
22 | #define UCPI_UBH ((struct ufs_buffer_head *)ucpi) | 22 | static inline struct ufs_buffer_head *UCPI_UBH(struct ufs_cg_private_info *cpi) |
23 | #define USPI_UBH ((struct ufs_buffer_head *)uspi) | 23 | { |
24 | return &cpi->c_ubh; | ||
25 | } | ||
26 | static inline struct ufs_buffer_head *USPI_UBH(struct ufs_sb_private_info *spi) | ||
27 | { | ||
28 | return &spi->s_ubh; | ||
29 | } | ||
24 | 30 | ||
25 | 31 | ||
26 | 32 | ||
@@ -33,12 +39,12 @@ ufs_get_fs_state(struct super_block *sb, struct ufs_super_block_first *usb1, | |||
33 | { | 39 | { |
34 | switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { | 40 | switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { |
35 | case UFS_ST_SUN: | 41 | case UFS_ST_SUN: |
36 | return fs32_to_cpu(sb, usb3->fs_u2.fs_sun.fs_state); | 42 | return fs32_to_cpu(sb, usb3->fs_un2.fs_sun.fs_state); |
37 | case UFS_ST_SUNx86: | 43 | case UFS_ST_SUNx86: |
38 | return fs32_to_cpu(sb, usb1->fs_u1.fs_sunx86.fs_state); | 44 | return fs32_to_cpu(sb, usb1->fs_u1.fs_sunx86.fs_state); |
39 | case UFS_ST_44BSD: | 45 | case UFS_ST_44BSD: |
40 | default: | 46 | default: |
41 | return fs32_to_cpu(sb, usb3->fs_u2.fs_44.fs_state); | 47 | return fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_state); |
42 | } | 48 | } |
43 | } | 49 | } |
44 | 50 | ||
@@ -48,13 +54,13 @@ ufs_set_fs_state(struct super_block *sb, struct ufs_super_block_first *usb1, | |||
48 | { | 54 | { |
49 | switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { | 55 | switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { |
50 | case UFS_ST_SUN: | 56 | case UFS_ST_SUN: |
51 | usb3->fs_u2.fs_sun.fs_state = cpu_to_fs32(sb, value); | 57 | usb3->fs_un2.fs_sun.fs_state = cpu_to_fs32(sb, value); |
52 | break; | 58 | break; |
53 | case UFS_ST_SUNx86: | 59 | case UFS_ST_SUNx86: |
54 | usb1->fs_u1.fs_sunx86.fs_state = cpu_to_fs32(sb, value); | 60 | usb1->fs_u1.fs_sunx86.fs_state = cpu_to_fs32(sb, value); |
55 | break; | 61 | break; |
56 | case UFS_ST_44BSD: | 62 | case UFS_ST_44BSD: |
57 | usb3->fs_u2.fs_44.fs_state = cpu_to_fs32(sb, value); | 63 | usb3->fs_un2.fs_44.fs_state = cpu_to_fs32(sb, value); |
58 | break; | 64 | break; |
59 | } | 65 | } |
60 | } | 66 | } |
@@ -64,7 +70,7 @@ ufs_get_fs_npsect(struct super_block *sb, struct ufs_super_block_first *usb1, | |||
64 | struct ufs_super_block_third *usb3) | 70 | struct ufs_super_block_third *usb3) |
65 | { | 71 | { |
66 | if ((UFS_SB(sb)->s_flags & UFS_ST_MASK) == UFS_ST_SUNx86) | 72 | if ((UFS_SB(sb)->s_flags & UFS_ST_MASK) == UFS_ST_SUNx86) |
67 | return fs32_to_cpu(sb, usb3->fs_u2.fs_sunx86.fs_npsect); | 73 | return fs32_to_cpu(sb, usb3->fs_un2.fs_sunx86.fs_npsect); |
68 | else | 74 | else |
69 | return fs32_to_cpu(sb, usb1->fs_u1.fs_sun.fs_npsect); | 75 | return fs32_to_cpu(sb, usb1->fs_u1.fs_sun.fs_npsect); |
70 | } | 76 | } |
@@ -76,16 +82,16 @@ ufs_get_fs_qbmask(struct super_block *sb, struct ufs_super_block_third *usb3) | |||
76 | 82 | ||
77 | switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { | 83 | switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { |
78 | case UFS_ST_SUN: | 84 | case UFS_ST_SUN: |
79 | ((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_sun.fs_qbmask[0]; | 85 | ((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_sun.fs_qbmask[0]; |
80 | ((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_sun.fs_qbmask[1]; | 86 | ((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_sun.fs_qbmask[1]; |
81 | break; | 87 | break; |
82 | case UFS_ST_SUNx86: | 88 | case UFS_ST_SUNx86: |
83 | ((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_sunx86.fs_qbmask[0]; | 89 | ((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_sunx86.fs_qbmask[0]; |
84 | ((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_sunx86.fs_qbmask[1]; | 90 | ((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_sunx86.fs_qbmask[1]; |
85 | break; | 91 | break; |
86 | case UFS_ST_44BSD: | 92 | case UFS_ST_44BSD: |
87 | ((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_44.fs_qbmask[0]; | 93 | ((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_44.fs_qbmask[0]; |
88 | ((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_44.fs_qbmask[1]; | 94 | ((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_44.fs_qbmask[1]; |
89 | break; | 95 | break; |
90 | } | 96 | } |
91 | 97 | ||
@@ -99,16 +105,16 @@ ufs_get_fs_qfmask(struct super_block *sb, struct ufs_super_block_third *usb3) | |||
99 | 105 | ||
100 | switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { | 106 | switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { |
101 | case UFS_ST_SUN: | 107 | case UFS_ST_SUN: |
102 | ((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_sun.fs_qfmask[0]; | 108 | ((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_sun.fs_qfmask[0]; |
103 | ((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_sun.fs_qfmask[1]; | 109 | ((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_sun.fs_qfmask[1]; |
104 | break; | 110 | break; |
105 | case UFS_ST_SUNx86: | 111 | case UFS_ST_SUNx86: |
106 | ((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_sunx86.fs_qfmask[0]; | 112 | ((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_sunx86.fs_qfmask[0]; |
107 | ((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_sunx86.fs_qfmask[1]; | 113 | ((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_sunx86.fs_qfmask[1]; |
108 | break; | 114 | break; |
109 | case UFS_ST_44BSD: | 115 | case UFS_ST_44BSD: |
110 | ((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_44.fs_qfmask[0]; | 116 | ((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_44.fs_qfmask[0]; |
111 | ((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_44.fs_qfmask[1]; | 117 | ((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_44.fs_qfmask[1]; |
112 | break; | 118 | break; |
113 | } | 119 | } |
114 | 120 | ||
@@ -236,9 +242,8 @@ extern void ubh_brelse (struct ufs_buffer_head *); | |||
236 | extern void ubh_brelse_uspi (struct ufs_sb_private_info *); | 242 | extern void ubh_brelse_uspi (struct ufs_sb_private_info *); |
237 | extern void ubh_mark_buffer_dirty (struct ufs_buffer_head *); | 243 | extern void ubh_mark_buffer_dirty (struct ufs_buffer_head *); |
238 | extern void ubh_mark_buffer_uptodate (struct ufs_buffer_head *, int); | 244 | extern void ubh_mark_buffer_uptodate (struct ufs_buffer_head *, int); |
239 | extern void ubh_ll_rw_block (int, unsigned, struct ufs_buffer_head **); | 245 | extern void ubh_ll_rw_block(int, struct ufs_buffer_head *); |
240 | extern void ubh_wait_on_buffer (struct ufs_buffer_head *); | 246 | extern void ubh_wait_on_buffer (struct ufs_buffer_head *); |
241 | extern unsigned ubh_max_bcount (struct ufs_buffer_head *); | ||
242 | extern void ubh_bforget (struct ufs_buffer_head *); | 247 | extern void ubh_bforget (struct ufs_buffer_head *); |
243 | extern int ubh_buffer_dirty (struct ufs_buffer_head *); | 248 | extern int ubh_buffer_dirty (struct ufs_buffer_head *); |
244 | #define ubh_ubhcpymem(mem,ubh,size) _ubh_ubhcpymem_(uspi,mem,ubh,size) | 249 | #define ubh_ubhcpymem(mem,ubh,size) _ubh_ubhcpymem_(uspi,mem,ubh,size) |
@@ -297,40 +302,26 @@ static inline void *get_usb_offset(struct ufs_sb_private_info *uspi, | |||
297 | #define ubh_blkmap(ubh,begin,bit) \ | 302 | #define ubh_blkmap(ubh,begin,bit) \ |
298 | ((*ubh_get_addr(ubh, (begin) + ((bit) >> 3)) >> ((bit) & 7)) & (0xff >> (UFS_MAXFRAG - uspi->s_fpb))) | 303 | ((*ubh_get_addr(ubh, (begin) + ((bit) >> 3)) >> ((bit) & 7)) & (0xff >> (UFS_MAXFRAG - uspi->s_fpb))) |
299 | 304 | ||
300 | |||
301 | /* | ||
302 | * Macros for access to superblock array structures | ||
303 | */ | ||
304 | #define ubh_postbl(ubh,cylno,i) \ | ||
305 | ((uspi->s_postblformat != UFS_DYNAMICPOSTBLFMT) \ | ||
306 | ? (*(__s16*)(ubh_get_addr(ubh, \ | ||
307 | (unsigned)(&((struct ufs_super_block *)0)->fs_opostbl) \ | ||
308 | + (((cylno) * 16 + (i)) << 1) ) )) \ | ||
309 | : (*(__s16*)(ubh_get_addr(ubh, \ | ||
310 | uspi->s_postbloff + (((cylno) * uspi->s_nrpos + (i)) << 1) )))) | ||
311 | |||
312 | #define ubh_rotbl(ubh,i) \ | ||
313 | ((uspi->s_postblformat != UFS_DYNAMICPOSTBLFMT) \ | ||
314 | ? (*(__u8*)(ubh_get_addr(ubh, \ | ||
315 | (unsigned)(&((struct ufs_super_block *)0)->fs_space) + (i)))) \ | ||
316 | : (*(__u8*)(ubh_get_addr(ubh, uspi->s_rotbloff + (i))))) | ||
317 | |||
318 | /* | 305 | /* |
319 | * Determine the number of available frags given a | 306 | * Determine the number of available frags given a |
320 | * percentage to hold in reserve. | 307 | * percentage to hold in reserve. |
321 | */ | 308 | */ |
322 | #define ufs_freespace(usb, percentreserved) \ | 309 | static inline u64 |
323 | (ufs_blkstofrags(fs32_to_cpu(sb, (usb)->fs_cstotal.cs_nbfree)) + \ | 310 | ufs_freespace(struct ufs_sb_private_info *uspi, int percentreserved) |
324 | fs32_to_cpu(sb, (usb)->fs_cstotal.cs_nffree) - (uspi->s_dsize * (percentreserved) / 100)) | 311 | { |
312 | return ufs_blkstofrags(uspi->cs_total.cs_nbfree) + | ||
313 | uspi->cs_total.cs_nffree - | ||
314 | (uspi->s_dsize * (percentreserved) / 100); | ||
315 | } | ||
325 | 316 | ||
326 | /* | 317 | /* |
327 | * Macros to access cylinder group array structures | 318 | * Macros to access cylinder group array structures |
328 | */ | 319 | */ |
329 | #define ubh_cg_blktot(ucpi,cylno) \ | 320 | #define ubh_cg_blktot(ucpi,cylno) \ |
330 | (*((__fs32*)ubh_get_addr(UCPI_UBH, (ucpi)->c_btotoff + ((cylno) << 2)))) | 321 | (*((__fs32*)ubh_get_addr(UCPI_UBH(ucpi), (ucpi)->c_btotoff + ((cylno) << 2)))) |
331 | 322 | ||
332 | #define ubh_cg_blks(ucpi,cylno,rpos) \ | 323 | #define ubh_cg_blks(ucpi,cylno,rpos) \ |
333 | (*((__fs16*)ubh_get_addr(UCPI_UBH, \ | 324 | (*((__fs16*)ubh_get_addr(UCPI_UBH(ucpi), \ |
334 | (ucpi)->c_boff + (((cylno) * uspi->s_nrpos + (rpos)) << 1 )))) | 325 | (ucpi)->c_boff + (((cylno) * uspi->s_nrpos + (rpos)) << 1 )))) |
335 | 326 | ||
336 | /* | 327 | /* |
@@ -508,29 +499,3 @@ static inline void ufs_fragacct (struct super_block * sb, unsigned blockmap, | |||
508 | if (fragsize > 0 && fragsize < uspi->s_fpb) | 499 | if (fragsize > 0 && fragsize < uspi->s_fpb) |
509 | fs32_add(sb, &fraglist[fragsize], cnt); | 500 | fs32_add(sb, &fraglist[fragsize], cnt); |
510 | } | 501 | } |
511 | |||
512 | #define ubh_scanc(ubh,begin,size,table,mask) _ubh_scanc_(uspi,ubh,begin,size,table,mask) | ||
513 | static inline unsigned _ubh_scanc_(struct ufs_sb_private_info * uspi, struct ufs_buffer_head * ubh, | ||
514 | unsigned begin, unsigned size, unsigned char * table, unsigned char mask) | ||
515 | { | ||
516 | unsigned rest, offset; | ||
517 | unsigned char * cp; | ||
518 | |||
519 | |||
520 | offset = begin & ~uspi->s_fmask; | ||
521 | begin >>= uspi->s_fshift; | ||
522 | for (;;) { | ||
523 | if ((offset + size) < uspi->s_fsize) | ||
524 | rest = size; | ||
525 | else | ||
526 | rest = uspi->s_fsize - offset; | ||
527 | size -= rest; | ||
528 | cp = ubh->bh[begin]->b_data + offset; | ||
529 | while ((table[*cp++] & mask) == 0 && --rest); | ||
530 | if (rest || !size) | ||
531 | break; | ||
532 | begin++; | ||
533 | offset = 0; | ||
534 | } | ||
535 | return (size + rest); | ||
536 | } | ||