Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/fs/ufs/inode.c |
| 3 | * |
| 4 | * Copyright (C) 1998 |
| 5 | * Daniel Pirkl <daniel.pirkl@email.cz> |
| 6 | * Charles University, Faculty of Mathematics and Physics |
| 7 | * |
| 8 | * from |
| 9 | * |
| 10 | * linux/fs/ext2/inode.c |
| 11 | * |
| 12 | * Copyright (C) 1992, 1993, 1994, 1995 |
| 13 | * Remy Card (card@masi.ibp.fr) |
| 14 | * Laboratoire MASI - Institut Blaise Pascal |
| 15 | * Universite Pierre et Marie Curie (Paris VI) |
| 16 | * |
| 17 | * from |
| 18 | * |
| 19 | * linux/fs/minix/inode.c |
| 20 | * |
| 21 | * Copyright (C) 1991, 1992 Linus Torvalds |
| 22 | * |
| 23 | * Goal-directed block allocation by Stephen Tweedie (sct@dcs.ed.ac.uk), 1993 |
| 24 | * Big-endian to little-endian byte-swapping/bitmaps by |
| 25 | * David S. Miller (davem@caip.rutgers.edu), 1995 |
| 26 | */ |
| 27 | |
| 28 | #include <asm/uaccess.h> |
| 29 | #include <asm/system.h> |
| 30 | |
| 31 | #include <linux/errno.h> |
| 32 | #include <linux/fs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #include <linux/time.h> |
| 34 | #include <linux/stat.h> |
| 35 | #include <linux/string.h> |
| 36 | #include <linux/mm.h> |
| 37 | #include <linux/smp_lock.h> |
| 38 | #include <linux/buffer_head.h> |
| 39 | |
Mike Frysinger | e542059 | 2008-02-08 04:21:31 -0800 | [diff] [blame] | 40 | #include "ufs_fs.h" |
Christoph Hellwig | bcd6d4e | 2007-10-16 23:26:51 -0700 | [diff] [blame] | 41 | #include "ufs.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #include "swab.h" |
| 43 | #include "util.h" |
| 44 | |
Adrian Bunk | 138bb68 | 2006-06-25 05:47:32 -0700 | [diff] [blame] | 45 | static u64 ufs_frag_map(struct inode *inode, sector_t frag); |
| 46 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | static int ufs_block_to_path(struct inode *inode, sector_t i_block, sector_t offsets[4]) |
| 48 | { |
| 49 | struct ufs_sb_private_info *uspi = UFS_SB(inode->i_sb)->s_uspi; |
| 50 | int ptrs = uspi->s_apb; |
| 51 | int ptrs_bits = uspi->s_apbshift; |
| 52 | const long direct_blocks = UFS_NDADDR, |
| 53 | indirect_blocks = ptrs, |
| 54 | double_blocks = (1 << (ptrs_bits * 2)); |
| 55 | int n = 0; |
| 56 | |
| 57 | |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 58 | UFSD("ptrs=uspi->s_apb = %d,double_blocks=%ld \n",ptrs,double_blocks); |
Roel Kluin | 37044c8 | 2009-06-17 16:26:28 -0700 | [diff] [blame] | 59 | if (i_block < direct_blocks) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | offsets[n++] = i_block; |
| 61 | } else if ((i_block -= direct_blocks) < indirect_blocks) { |
| 62 | offsets[n++] = UFS_IND_BLOCK; |
| 63 | offsets[n++] = i_block; |
| 64 | } else if ((i_block -= indirect_blocks) < double_blocks) { |
| 65 | offsets[n++] = UFS_DIND_BLOCK; |
| 66 | offsets[n++] = i_block >> ptrs_bits; |
| 67 | offsets[n++] = i_block & (ptrs - 1); |
| 68 | } else if (((i_block -= double_blocks) >> (ptrs_bits * 2)) < ptrs) { |
| 69 | offsets[n++] = UFS_TIND_BLOCK; |
| 70 | offsets[n++] = i_block >> (ptrs_bits * 2); |
| 71 | offsets[n++] = (i_block >> ptrs_bits) & (ptrs - 1); |
| 72 | offsets[n++] = i_block & (ptrs - 1); |
| 73 | } else { |
| 74 | ufs_warning(inode->i_sb, "ufs_block_to_path", "block > big"); |
| 75 | } |
| 76 | return n; |
| 77 | } |
| 78 | |
| 79 | /* |
| 80 | * Returns the location of the fragment from |
| 81 | * the begining of the filesystem. |
| 82 | */ |
| 83 | |
Adrian Bunk | 138bb68 | 2006-06-25 05:47:32 -0700 | [diff] [blame] | 84 | static u64 ufs_frag_map(struct inode *inode, sector_t frag) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | { |
| 86 | struct ufs_inode_info *ufsi = UFS_I(inode); |
| 87 | struct super_block *sb = inode->i_sb; |
| 88 | struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; |
| 89 | u64 mask = (u64) uspi->s_apbmask>>uspi->s_fpbshift; |
| 90 | int shift = uspi->s_apbshift-uspi->s_fpbshift; |
| 91 | sector_t offsets[4], *p; |
| 92 | int depth = ufs_block_to_path(inode, frag >> uspi->s_fpbshift, offsets); |
| 93 | u64 ret = 0L; |
| 94 | __fs32 block; |
| 95 | __fs64 u2_block = 0L; |
| 96 | unsigned flags = UFS_SB(sb)->s_flags; |
| 97 | u64 temp = 0L; |
| 98 | |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 99 | UFSD(": frag = %llu depth = %d\n", (unsigned long long)frag, depth); |
Andrew Morton | 7256d81 | 2006-06-29 02:24:29 -0700 | [diff] [blame] | 100 | UFSD(": uspi->s_fpbshift = %d ,uspi->s_apbmask = %x, mask=%llx\n", |
| 101 | uspi->s_fpbshift, uspi->s_apbmask, |
| 102 | (unsigned long long)mask); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | |
| 104 | if (depth == 0) |
| 105 | return 0; |
| 106 | |
| 107 | p = offsets; |
| 108 | |
| 109 | lock_kernel(); |
| 110 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) |
| 111 | goto ufs2; |
| 112 | |
| 113 | block = ufsi->i_u1.i_data[*p++]; |
| 114 | if (!block) |
| 115 | goto out; |
| 116 | while (--depth) { |
| 117 | struct buffer_head *bh; |
| 118 | sector_t n = *p++; |
| 119 | |
| 120 | bh = sb_bread(sb, uspi->s_sbbase + fs32_to_cpu(sb, block)+(n>>shift)); |
| 121 | if (!bh) |
| 122 | goto out; |
| 123 | block = ((__fs32 *) bh->b_data)[n & mask]; |
| 124 | brelse (bh); |
| 125 | if (!block) |
| 126 | goto out; |
| 127 | } |
| 128 | ret = (u64) (uspi->s_sbbase + fs32_to_cpu(sb, block) + (frag & uspi->s_fpbmask)); |
| 129 | goto out; |
| 130 | ufs2: |
| 131 | u2_block = ufsi->i_u1.u2_i_data[*p++]; |
| 132 | if (!u2_block) |
| 133 | goto out; |
| 134 | |
| 135 | |
| 136 | while (--depth) { |
| 137 | struct buffer_head *bh; |
| 138 | sector_t n = *p++; |
| 139 | |
| 140 | |
| 141 | temp = (u64)(uspi->s_sbbase) + fs64_to_cpu(sb, u2_block); |
| 142 | bh = sb_bread(sb, temp +(u64) (n>>shift)); |
| 143 | if (!bh) |
| 144 | goto out; |
| 145 | u2_block = ((__fs64 *)bh->b_data)[n & mask]; |
| 146 | brelse(bh); |
| 147 | if (!u2_block) |
| 148 | goto out; |
| 149 | } |
| 150 | temp = (u64)uspi->s_sbbase + fs64_to_cpu(sb, u2_block); |
| 151 | ret = temp + (u64) (frag & uspi->s_fpbmask); |
| 152 | |
| 153 | out: |
| 154 | unlock_kernel(); |
| 155 | return ret; |
| 156 | } |
| 157 | |
Evgeniy Dushistov | 022a6dc | 2006-06-25 05:47:27 -0700 | [diff] [blame] | 158 | /** |
| 159 | * ufs_inode_getfrag() - allocate new fragment(s) |
| 160 | * @inode - pointer to inode |
| 161 | * @fragment - number of `fragment' which hold pointer |
| 162 | * to new allocated fragment(s) |
| 163 | * @new_fragment - number of new allocated fragment(s) |
| 164 | * @required - how many fragment(s) we require |
| 165 | * @err - we set it if something wrong |
| 166 | * @phys - pointer to where we save physical number of new allocated fragments, |
| 167 | * NULL if we allocate not data(indirect blocks for example). |
| 168 | * @new - we set it if we allocate new block |
| 169 | * @locked_page - for ufs_new_fragments() |
| 170 | */ |
| 171 | static struct buffer_head * |
Evgeniy Dushistov | 54fb996 | 2007-02-12 00:54:32 -0800 | [diff] [blame] | 172 | ufs_inode_getfrag(struct inode *inode, u64 fragment, |
Evgeniy Dushistov | 022a6dc | 2006-06-25 05:47:27 -0700 | [diff] [blame] | 173 | sector_t new_fragment, unsigned int required, int *err, |
| 174 | long *phys, int *new, struct page *locked_page) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | { |
| 176 | struct ufs_inode_info *ufsi = UFS_I(inode); |
Evgeniy Dushistov | 022a6dc | 2006-06-25 05:47:27 -0700 | [diff] [blame] | 177 | struct super_block *sb = inode->i_sb; |
| 178 | struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | struct buffer_head * result; |
Evgeniy Dushistov | 54fb996 | 2007-02-12 00:54:32 -0800 | [diff] [blame] | 180 | unsigned blockoff, lastblockoff; |
| 181 | u64 tmp, goal, lastfrag, block, lastblock; |
| 182 | void *p, *p2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | |
Evgeniy Dushistov | 54fb996 | 2007-02-12 00:54:32 -0800 | [diff] [blame] | 184 | UFSD("ENTER, ino %lu, fragment %llu, new_fragment %llu, required %u, " |
| 185 | "metadata %d\n", inode->i_ino, (unsigned long long)fragment, |
Evgeniy Dushistov | 022a6dc | 2006-06-25 05:47:27 -0700 | [diff] [blame] | 186 | (unsigned long long)new_fragment, required, !phys); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | /* TODO : to be done for write support |
| 189 | if ( (flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) |
| 190 | goto ufs2; |
| 191 | */ |
| 192 | |
| 193 | block = ufs_fragstoblks (fragment); |
| 194 | blockoff = ufs_fragnum (fragment); |
Evgeniy Dushistov | 54fb996 | 2007-02-12 00:54:32 -0800 | [diff] [blame] | 195 | p = ufs_get_direct_data_ptr(uspi, ufsi, block); |
| 196 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | goal = 0; |
| 198 | |
| 199 | repeat: |
Evgeniy Dushistov | 54fb996 | 2007-02-12 00:54:32 -0800 | [diff] [blame] | 200 | tmp = ufs_data_ptr_to_cpu(sb, p); |
| 201 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | lastfrag = ufsi->i_lastfrag; |
| 203 | if (tmp && fragment < lastfrag) { |
Evgeniy Dushistov | 022a6dc | 2006-06-25 05:47:27 -0700 | [diff] [blame] | 204 | if (!phys) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | result = sb_getblk(sb, uspi->s_sbbase + tmp + blockoff); |
Evgeniy Dushistov | 54fb996 | 2007-02-12 00:54:32 -0800 | [diff] [blame] | 206 | if (tmp == ufs_data_ptr_to_cpu(sb, p)) { |
| 207 | UFSD("EXIT, result %llu\n", |
| 208 | (unsigned long long)tmp + blockoff); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | return result; |
| 210 | } |
| 211 | brelse (result); |
| 212 | goto repeat; |
| 213 | } else { |
Evgeniy Dushistov | 4b25a37 | 2007-03-16 13:38:09 -0800 | [diff] [blame] | 214 | *phys = uspi->s_sbbase + tmp + blockoff; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | return NULL; |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | lastblock = ufs_fragstoblks (lastfrag); |
| 220 | lastblockoff = ufs_fragnum (lastfrag); |
| 221 | /* |
| 222 | * We will extend file into new block beyond last allocated block |
| 223 | */ |
| 224 | if (lastblock < block) { |
| 225 | /* |
| 226 | * We must reallocate last allocated block |
| 227 | */ |
| 228 | if (lastblockoff) { |
Evgeniy Dushistov | 54fb996 | 2007-02-12 00:54:32 -0800 | [diff] [blame] | 229 | p2 = ufs_get_direct_data_ptr(uspi, ufsi, lastblock); |
| 230 | tmp = ufs_new_fragments(inode, p2, lastfrag, |
| 231 | ufs_data_ptr_to_cpu(sb, p2), |
| 232 | uspi->s_fpb - lastblockoff, |
| 233 | err, locked_page); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | if (!tmp) { |
| 235 | if (lastfrag != ufsi->i_lastfrag) |
| 236 | goto repeat; |
| 237 | else |
| 238 | return NULL; |
| 239 | } |
| 240 | lastfrag = ufsi->i_lastfrag; |
| 241 | |
| 242 | } |
Evgeniy Dushistov | 54fb996 | 2007-02-12 00:54:32 -0800 | [diff] [blame] | 243 | tmp = ufs_data_ptr_to_cpu(sb, |
| 244 | ufs_get_direct_data_ptr(uspi, ufsi, |
| 245 | lastblock)); |
Evgeniy Dushistov | c37336b | 2006-08-27 01:23:45 -0700 | [diff] [blame] | 246 | if (tmp) |
| 247 | goal = tmp + uspi->s_fpb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | tmp = ufs_new_fragments (inode, p, fragment - blockoff, |
Evgeniy Dushistov | 6ef4d6b | 2006-06-25 05:47:20 -0700 | [diff] [blame] | 249 | goal, required + blockoff, |
Evgeniy Dushistov | a685e26 | 2007-01-29 13:19:54 -0800 | [diff] [blame] | 250 | err, |
| 251 | phys != NULL ? locked_page : NULL); |
Evgeniy Dushistov | 54fb996 | 2007-02-12 00:54:32 -0800 | [diff] [blame] | 252 | } else if (lastblock == block) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | /* |
| 254 | * We will extend last allocated block |
| 255 | */ |
Evgeniy Dushistov | 54fb996 | 2007-02-12 00:54:32 -0800 | [diff] [blame] | 256 | tmp = ufs_new_fragments(inode, p, fragment - |
| 257 | (blockoff - lastblockoff), |
| 258 | ufs_data_ptr_to_cpu(sb, p), |
| 259 | required + (blockoff - lastblockoff), |
Evgeniy Dushistov | a685e26 | 2007-01-29 13:19:54 -0800 | [diff] [blame] | 260 | err, phys != NULL ? locked_page : NULL); |
Evgeniy Dushistov | c37336b | 2006-08-27 01:23:45 -0700 | [diff] [blame] | 261 | } else /* (lastblock > block) */ { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | /* |
| 263 | * We will allocate new block before last allocated block |
| 264 | */ |
Evgeniy Dushistov | c37336b | 2006-08-27 01:23:45 -0700 | [diff] [blame] | 265 | if (block) { |
Evgeniy Dushistov | 54fb996 | 2007-02-12 00:54:32 -0800 | [diff] [blame] | 266 | tmp = ufs_data_ptr_to_cpu(sb, |
| 267 | ufs_get_direct_data_ptr(uspi, ufsi, block - 1)); |
Evgeniy Dushistov | c37336b | 2006-08-27 01:23:45 -0700 | [diff] [blame] | 268 | if (tmp) |
| 269 | goal = tmp + uspi->s_fpb; |
| 270 | } |
Evgeniy Dushistov | 6ef4d6b | 2006-06-25 05:47:20 -0700 | [diff] [blame] | 271 | tmp = ufs_new_fragments(inode, p, fragment - blockoff, |
Evgeniy Dushistov | a685e26 | 2007-01-29 13:19:54 -0800 | [diff] [blame] | 272 | goal, uspi->s_fpb, err, |
| 273 | phys != NULL ? locked_page : NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | } |
| 275 | if (!tmp) { |
Evgeniy Dushistov | 54fb996 | 2007-02-12 00:54:32 -0800 | [diff] [blame] | 276 | if ((!blockoff && ufs_data_ptr_to_cpu(sb, p)) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | (blockoff && lastfrag != ufsi->i_lastfrag)) |
| 278 | goto repeat; |
| 279 | *err = -ENOSPC; |
| 280 | return NULL; |
| 281 | } |
| 282 | |
Evgeniy Dushistov | 022a6dc | 2006-06-25 05:47:27 -0700 | [diff] [blame] | 283 | if (!phys) { |
Evgeniy Dushistov | 4b25a37 | 2007-03-16 13:38:09 -0800 | [diff] [blame] | 284 | result = sb_getblk(sb, uspi->s_sbbase + tmp + blockoff); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | } else { |
Evgeniy Dushistov | 4b25a37 | 2007-03-16 13:38:09 -0800 | [diff] [blame] | 286 | *phys = uspi->s_sbbase + tmp + blockoff; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | result = NULL; |
| 288 | *err = 0; |
| 289 | *new = 1; |
| 290 | } |
| 291 | |
| 292 | inode->i_ctime = CURRENT_TIME_SEC; |
| 293 | if (IS_SYNC(inode)) |
| 294 | ufs_sync_inode (inode); |
| 295 | mark_inode_dirty(inode); |
Evgeniy Dushistov | 54fb996 | 2007-02-12 00:54:32 -0800 | [diff] [blame] | 296 | UFSD("EXIT, result %llu\n", (unsigned long long)tmp + blockoff); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | return result; |
| 298 | |
| 299 | /* This part : To be implemented .... |
| 300 | Required only for writing, not required for READ-ONLY. |
| 301 | ufs2: |
| 302 | |
| 303 | u2_block = ufs_fragstoblks(fragment); |
| 304 | u2_blockoff = ufs_fragnum(fragment); |
| 305 | p = ufsi->i_u1.u2_i_data + block; |
| 306 | goal = 0; |
| 307 | |
| 308 | repeat2: |
| 309 | tmp = fs32_to_cpu(sb, *p); |
| 310 | lastfrag = ufsi->i_lastfrag; |
| 311 | |
| 312 | */ |
| 313 | } |
| 314 | |
Evgeniy Dushistov | 022a6dc | 2006-06-25 05:47:27 -0700 | [diff] [blame] | 315 | /** |
| 316 | * ufs_inode_getblock() - allocate new block |
| 317 | * @inode - pointer to inode |
| 318 | * @bh - pointer to block which hold "pointer" to new allocated block |
| 319 | * @fragment - number of `fragment' which hold pointer |
| 320 | * to new allocated block |
| 321 | * @new_fragment - number of new allocated fragment |
| 322 | * (block will hold this fragment and also uspi->s_fpb-1) |
| 323 | * @err - see ufs_inode_getfrag() |
| 324 | * @phys - see ufs_inode_getfrag() |
| 325 | * @new - see ufs_inode_getfrag() |
| 326 | * @locked_page - see ufs_inode_getfrag() |
| 327 | */ |
| 328 | static struct buffer_head * |
| 329 | ufs_inode_getblock(struct inode *inode, struct buffer_head *bh, |
Evgeniy Dushistov | 54fb996 | 2007-02-12 00:54:32 -0800 | [diff] [blame] | 330 | u64 fragment, sector_t new_fragment, int *err, |
Evgeniy Dushistov | 022a6dc | 2006-06-25 05:47:27 -0700 | [diff] [blame] | 331 | long *phys, int *new, struct page *locked_page) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | { |
Evgeniy Dushistov | 022a6dc | 2006-06-25 05:47:27 -0700 | [diff] [blame] | 333 | struct super_block *sb = inode->i_sb; |
| 334 | struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | struct buffer_head * result; |
Evgeniy Dushistov | 54fb996 | 2007-02-12 00:54:32 -0800 | [diff] [blame] | 336 | unsigned blockoff; |
| 337 | u64 tmp, goal, block; |
| 338 | void *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | block = ufs_fragstoblks (fragment); |
| 341 | blockoff = ufs_fragnum (fragment); |
| 342 | |
Evgeniy Dushistov | 54fb996 | 2007-02-12 00:54:32 -0800 | [diff] [blame] | 343 | UFSD("ENTER, ino %lu, fragment %llu, new_fragment %llu, metadata %d\n", |
| 344 | inode->i_ino, (unsigned long long)fragment, |
| 345 | (unsigned long long)new_fragment, !phys); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | |
| 347 | result = NULL; |
| 348 | if (!bh) |
| 349 | goto out; |
| 350 | if (!buffer_uptodate(bh)) { |
| 351 | ll_rw_block (READ, 1, &bh); |
| 352 | wait_on_buffer (bh); |
| 353 | if (!buffer_uptodate(bh)) |
| 354 | goto out; |
| 355 | } |
Evgeniy Dushistov | 54fb996 | 2007-02-12 00:54:32 -0800 | [diff] [blame] | 356 | if (uspi->fs_magic == UFS2_MAGIC) |
| 357 | p = (__fs64 *)bh->b_data + block; |
| 358 | else |
| 359 | p = (__fs32 *)bh->b_data + block; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | repeat: |
Evgeniy Dushistov | 54fb996 | 2007-02-12 00:54:32 -0800 | [diff] [blame] | 361 | tmp = ufs_data_ptr_to_cpu(sb, p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | if (tmp) { |
Evgeniy Dushistov | 022a6dc | 2006-06-25 05:47:27 -0700 | [diff] [blame] | 363 | if (!phys) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | result = sb_getblk(sb, uspi->s_sbbase + tmp + blockoff); |
Evgeniy Dushistov | 54fb996 | 2007-02-12 00:54:32 -0800 | [diff] [blame] | 365 | if (tmp == ufs_data_ptr_to_cpu(sb, p)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | goto out; |
| 367 | brelse (result); |
| 368 | goto repeat; |
| 369 | } else { |
Evgeniy Dushistov | 4b25a37 | 2007-03-16 13:38:09 -0800 | [diff] [blame] | 370 | *phys = uspi->s_sbbase + tmp + blockoff; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | goto out; |
| 372 | } |
| 373 | } |
| 374 | |
Evgeniy Dushistov | 54fb996 | 2007-02-12 00:54:32 -0800 | [diff] [blame] | 375 | if (block && (uspi->fs_magic == UFS2_MAGIC ? |
| 376 | (tmp = fs64_to_cpu(sb, ((__fs64 *)bh->b_data)[block-1])) : |
| 377 | (tmp = fs32_to_cpu(sb, ((__fs32 *)bh->b_data)[block-1])))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | goal = tmp + uspi->s_fpb; |
| 379 | else |
| 380 | goal = bh->b_blocknr + uspi->s_fpb; |
Evgeniy Dushistov | 6ef4d6b | 2006-06-25 05:47:20 -0700 | [diff] [blame] | 381 | tmp = ufs_new_fragments(inode, p, ufs_blknum(new_fragment), goal, |
| 382 | uspi->s_fpb, err, locked_page); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | if (!tmp) { |
Evgeniy Dushistov | 54fb996 | 2007-02-12 00:54:32 -0800 | [diff] [blame] | 384 | if (ufs_data_ptr_to_cpu(sb, p)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 385 | goto repeat; |
| 386 | goto out; |
| 387 | } |
| 388 | |
Evgeniy Dushistov | c9a27b5 | 2006-06-25 05:47:19 -0700 | [diff] [blame] | 389 | |
Evgeniy Dushistov | 022a6dc | 2006-06-25 05:47:27 -0700 | [diff] [blame] | 390 | if (!phys) { |
Evgeniy Dushistov | 4b25a37 | 2007-03-16 13:38:09 -0800 | [diff] [blame] | 391 | result = sb_getblk(sb, uspi->s_sbbase + tmp + blockoff); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | } else { |
Evgeniy Dushistov | 4b25a37 | 2007-03-16 13:38:09 -0800 | [diff] [blame] | 393 | *phys = uspi->s_sbbase + tmp + blockoff; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | *new = 1; |
| 395 | } |
| 396 | |
| 397 | mark_buffer_dirty(bh); |
| 398 | if (IS_SYNC(inode)) |
| 399 | sync_dirty_buffer(bh); |
| 400 | inode->i_ctime = CURRENT_TIME_SEC; |
| 401 | mark_inode_dirty(inode); |
Evgeniy Dushistov | 54fb996 | 2007-02-12 00:54:32 -0800 | [diff] [blame] | 402 | UFSD("result %llu\n", (unsigned long long)tmp + blockoff); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | out: |
| 404 | brelse (bh); |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 405 | UFSD("EXIT\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | return result; |
| 407 | } |
| 408 | |
Evgeniy Dushistov | 022a6dc | 2006-06-25 05:47:27 -0700 | [diff] [blame] | 409 | /** |
| 410 | * ufs_getfrag_bloc() - `get_block_t' function, interface between UFS and |
| 411 | * readpage, writepage and so on |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | */ |
| 413 | |
Evgeniy Dushistov | 022a6dc | 2006-06-25 05:47:27 -0700 | [diff] [blame] | 414 | int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buffer_head *bh_result, int create) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | { |
| 416 | struct super_block * sb = inode->i_sb; |
| 417 | struct ufs_sb_private_info * uspi = UFS_SB(sb)->s_uspi; |
| 418 | struct buffer_head * bh; |
| 419 | int ret, err, new; |
| 420 | unsigned long ptr,phys; |
| 421 | u64 phys64 = 0; |
| 422 | |
| 423 | if (!create) { |
| 424 | phys64 = ufs_frag_map(inode, fragment); |
Andrew Morton | 7256d81 | 2006-06-29 02:24:29 -0700 | [diff] [blame] | 425 | UFSD("phys64 = %llu\n", (unsigned long long)phys64); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | if (phys64) |
| 427 | map_bh(bh_result, sb, phys64); |
| 428 | return 0; |
| 429 | } |
| 430 | |
| 431 | /* This code entered only while writing ....? */ |
| 432 | |
| 433 | err = -EIO; |
| 434 | new = 0; |
| 435 | ret = 0; |
| 436 | bh = NULL; |
| 437 | |
| 438 | lock_kernel(); |
| 439 | |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 440 | UFSD("ENTER, ino %lu, fragment %llu\n", inode->i_ino, (unsigned long long)fragment); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | if (fragment > |
| 442 | ((UFS_NDADDR + uspi->s_apb + uspi->s_2apb + uspi->s_3apb) |
| 443 | << uspi->s_fpbshift)) |
| 444 | goto abort_too_big; |
| 445 | |
| 446 | err = 0; |
| 447 | ptr = fragment; |
| 448 | |
| 449 | /* |
| 450 | * ok, these macros clean the logic up a bit and make |
| 451 | * it much more readable: |
| 452 | */ |
| 453 | #define GET_INODE_DATABLOCK(x) \ |
Evgeniy Dushistov | a685e26 | 2007-01-29 13:19:54 -0800 | [diff] [blame] | 454 | ufs_inode_getfrag(inode, x, fragment, 1, &err, &phys, &new,\ |
| 455 | bh_result->b_page) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | #define GET_INODE_PTR(x) \ |
Evgeniy Dushistov | a685e26 | 2007-01-29 13:19:54 -0800 | [diff] [blame] | 457 | ufs_inode_getfrag(inode, x, fragment, uspi->s_fpb, &err, NULL, NULL,\ |
| 458 | bh_result->b_page) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | #define GET_INDIRECT_DATABLOCK(x) \ |
Evgeniy Dushistov | 022a6dc | 2006-06-25 05:47:27 -0700 | [diff] [blame] | 460 | ufs_inode_getblock(inode, bh, x, fragment, \ |
Evgeniy Dushistov | d63b709 | 2007-01-05 16:37:04 -0800 | [diff] [blame] | 461 | &err, &phys, &new, bh_result->b_page) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | #define GET_INDIRECT_PTR(x) \ |
Evgeniy Dushistov | 022a6dc | 2006-06-25 05:47:27 -0700 | [diff] [blame] | 463 | ufs_inode_getblock(inode, bh, x, fragment, \ |
Evgeniy Dushistov | d63b709 | 2007-01-05 16:37:04 -0800 | [diff] [blame] | 464 | &err, NULL, NULL, NULL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | |
| 466 | if (ptr < UFS_NDIR_FRAGMENT) { |
| 467 | bh = GET_INODE_DATABLOCK(ptr); |
| 468 | goto out; |
| 469 | } |
| 470 | ptr -= UFS_NDIR_FRAGMENT; |
| 471 | if (ptr < (1 << (uspi->s_apbshift + uspi->s_fpbshift))) { |
| 472 | bh = GET_INODE_PTR(UFS_IND_FRAGMENT + (ptr >> uspi->s_apbshift)); |
| 473 | goto get_indirect; |
| 474 | } |
| 475 | ptr -= 1 << (uspi->s_apbshift + uspi->s_fpbshift); |
| 476 | if (ptr < (1 << (uspi->s_2apbshift + uspi->s_fpbshift))) { |
| 477 | bh = GET_INODE_PTR(UFS_DIND_FRAGMENT + (ptr >> uspi->s_2apbshift)); |
| 478 | goto get_double; |
| 479 | } |
| 480 | ptr -= 1 << (uspi->s_2apbshift + uspi->s_fpbshift); |
| 481 | bh = GET_INODE_PTR(UFS_TIND_FRAGMENT + (ptr >> uspi->s_3apbshift)); |
| 482 | bh = GET_INDIRECT_PTR((ptr >> uspi->s_2apbshift) & uspi->s_apbmask); |
| 483 | get_double: |
| 484 | bh = GET_INDIRECT_PTR((ptr >> uspi->s_apbshift) & uspi->s_apbmask); |
| 485 | get_indirect: |
| 486 | bh = GET_INDIRECT_DATABLOCK(ptr & uspi->s_apbmask); |
| 487 | |
| 488 | #undef GET_INODE_DATABLOCK |
| 489 | #undef GET_INODE_PTR |
| 490 | #undef GET_INDIRECT_DATABLOCK |
| 491 | #undef GET_INDIRECT_PTR |
| 492 | |
| 493 | out: |
| 494 | if (err) |
| 495 | goto abort; |
| 496 | if (new) |
| 497 | set_buffer_new(bh_result); |
| 498 | map_bh(bh_result, sb, phys); |
| 499 | abort: |
| 500 | unlock_kernel(); |
| 501 | return err; |
| 502 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | abort_too_big: |
| 504 | ufs_warning(sb, "ufs_get_block", "block > big"); |
| 505 | goto abort; |
| 506 | } |
| 507 | |
Adrian Bunk | 138bb68 | 2006-06-25 05:47:32 -0700 | [diff] [blame] | 508 | static struct buffer_head *ufs_getfrag(struct inode *inode, |
| 509 | unsigned int fragment, |
| 510 | int create, int *err) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | { |
| 512 | struct buffer_head dummy; |
| 513 | int error; |
| 514 | |
| 515 | dummy.b_state = 0; |
| 516 | dummy.b_blocknr = -1000; |
| 517 | error = ufs_getfrag_block(inode, fragment, &dummy, create); |
| 518 | *err = error; |
| 519 | if (!error && buffer_mapped(&dummy)) { |
| 520 | struct buffer_head *bh; |
| 521 | bh = sb_getblk(inode->i_sb, dummy.b_blocknr); |
| 522 | if (buffer_new(&dummy)) { |
| 523 | memset(bh->b_data, 0, inode->i_sb->s_blocksize); |
| 524 | set_buffer_uptodate(bh); |
| 525 | mark_buffer_dirty(bh); |
| 526 | } |
| 527 | return bh; |
| 528 | } |
| 529 | return NULL; |
| 530 | } |
| 531 | |
| 532 | struct buffer_head * ufs_bread (struct inode * inode, unsigned fragment, |
| 533 | int create, int * err) |
| 534 | { |
| 535 | struct buffer_head * bh; |
| 536 | |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 537 | UFSD("ENTER, ino %lu, fragment %u\n", inode->i_ino, fragment); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | bh = ufs_getfrag (inode, fragment, create, err); |
| 539 | if (!bh || buffer_uptodate(bh)) |
| 540 | return bh; |
| 541 | ll_rw_block (READ, 1, &bh); |
| 542 | wait_on_buffer (bh); |
| 543 | if (buffer_uptodate(bh)) |
| 544 | return bh; |
| 545 | brelse (bh); |
| 546 | *err = -EIO; |
| 547 | return NULL; |
| 548 | } |
| 549 | |
| 550 | static int ufs_writepage(struct page *page, struct writeback_control *wbc) |
| 551 | { |
| 552 | return block_write_full_page(page,ufs_getfrag_block,wbc); |
| 553 | } |
Nick Piggin | 82b9d1d | 2007-10-16 01:25:19 -0700 | [diff] [blame] | 554 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | static int ufs_readpage(struct file *file, struct page *page) |
| 556 | { |
| 557 | return block_read_full_page(page,ufs_getfrag_block); |
| 558 | } |
Nick Piggin | 82b9d1d | 2007-10-16 01:25:19 -0700 | [diff] [blame] | 559 | |
| 560 | int __ufs_write_begin(struct file *file, struct address_space *mapping, |
| 561 | loff_t pos, unsigned len, unsigned flags, |
| 562 | struct page **pagep, void **fsdata) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | { |
Nick Piggin | 82b9d1d | 2007-10-16 01:25:19 -0700 | [diff] [blame] | 564 | return block_write_begin(file, mapping, pos, len, flags, pagep, fsdata, |
| 565 | ufs_getfrag_block); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 566 | } |
Nick Piggin | 82b9d1d | 2007-10-16 01:25:19 -0700 | [diff] [blame] | 567 | |
| 568 | static int ufs_write_begin(struct file *file, struct address_space *mapping, |
| 569 | loff_t pos, unsigned len, unsigned flags, |
| 570 | struct page **pagep, void **fsdata) |
| 571 | { |
| 572 | *pagep = NULL; |
| 573 | return __ufs_write_begin(file, mapping, pos, len, flags, pagep, fsdata); |
| 574 | } |
| 575 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 576 | static sector_t ufs_bmap(struct address_space *mapping, sector_t block) |
| 577 | { |
| 578 | return generic_block_bmap(mapping,block,ufs_getfrag_block); |
| 579 | } |
Nick Piggin | 82b9d1d | 2007-10-16 01:25:19 -0700 | [diff] [blame] | 580 | |
Christoph Hellwig | f5e54d6 | 2006-06-28 04:26:44 -0700 | [diff] [blame] | 581 | const struct address_space_operations ufs_aops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 582 | .readpage = ufs_readpage, |
| 583 | .writepage = ufs_writepage, |
| 584 | .sync_page = block_sync_page, |
Nick Piggin | 82b9d1d | 2007-10-16 01:25:19 -0700 | [diff] [blame] | 585 | .write_begin = ufs_write_begin, |
| 586 | .write_end = generic_write_end, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | .bmap = ufs_bmap |
| 588 | }; |
| 589 | |
Evgeniy Dushistov | 826843a | 2006-06-25 05:47:21 -0700 | [diff] [blame] | 590 | static void ufs_set_inode_ops(struct inode *inode) |
| 591 | { |
| 592 | if (S_ISREG(inode->i_mode)) { |
| 593 | inode->i_op = &ufs_file_inode_operations; |
| 594 | inode->i_fop = &ufs_file_operations; |
| 595 | inode->i_mapping->a_ops = &ufs_aops; |
| 596 | } else if (S_ISDIR(inode->i_mode)) { |
| 597 | inode->i_op = &ufs_dir_inode_operations; |
| 598 | inode->i_fop = &ufs_dir_operations; |
| 599 | inode->i_mapping->a_ops = &ufs_aops; |
| 600 | } else if (S_ISLNK(inode->i_mode)) { |
| 601 | if (!inode->i_blocks) |
| 602 | inode->i_op = &ufs_fast_symlink_inode_operations; |
| 603 | else { |
| 604 | inode->i_op = &page_symlink_inode_operations; |
| 605 | inode->i_mapping->a_ops = &ufs_aops; |
| 606 | } |
| 607 | } else |
| 608 | init_special_inode(inode, inode->i_mode, |
| 609 | ufs_get_inode_dev(inode->i_sb, UFS_I(inode))); |
| 610 | } |
| 611 | |
Evgeniy Dushistov | 07a0cfe | 2007-04-16 22:53:24 -0700 | [diff] [blame] | 612 | static int ufs1_read_inode(struct inode *inode, struct ufs_inode *ufs_inode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | { |
| 614 | struct ufs_inode_info *ufsi = UFS_I(inode); |
Evgeniy Dushistov | 05f225d | 2006-06-27 02:53:59 -0700 | [diff] [blame] | 615 | struct super_block *sb = inode->i_sb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | mode_t mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | |
| 618 | /* |
| 619 | * Copy data to the in-core inode. |
| 620 | */ |
| 621 | inode->i_mode = mode = fs16_to_cpu(sb, ufs_inode->ui_mode); |
| 622 | inode->i_nlink = fs16_to_cpu(sb, ufs_inode->ui_nlink); |
Evgeniy Dushistov | 07a0cfe | 2007-04-16 22:53:24 -0700 | [diff] [blame] | 623 | if (inode->i_nlink == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | ufs_error (sb, "ufs_read_inode", "inode %lu has zero nlink\n", inode->i_ino); |
Evgeniy Dushistov | 07a0cfe | 2007-04-16 22:53:24 -0700 | [diff] [blame] | 625 | return -1; |
| 626 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | |
| 628 | /* |
| 629 | * Linux now has 32-bit uid and gid, so we can support EFT. |
| 630 | */ |
| 631 | inode->i_uid = ufs_get_inode_uid(sb, ufs_inode); |
| 632 | inode->i_gid = ufs_get_inode_gid(sb, ufs_inode); |
| 633 | |
| 634 | inode->i_size = fs64_to_cpu(sb, ufs_inode->ui_size); |
| 635 | inode->i_atime.tv_sec = fs32_to_cpu(sb, ufs_inode->ui_atime.tv_sec); |
| 636 | inode->i_ctime.tv_sec = fs32_to_cpu(sb, ufs_inode->ui_ctime.tv_sec); |
| 637 | inode->i_mtime.tv_sec = fs32_to_cpu(sb, ufs_inode->ui_mtime.tv_sec); |
| 638 | inode->i_mtime.tv_nsec = 0; |
| 639 | inode->i_atime.tv_nsec = 0; |
| 640 | inode->i_ctime.tv_nsec = 0; |
| 641 | inode->i_blocks = fs32_to_cpu(sb, ufs_inode->ui_blocks); |
Evgeniy Dushistov | 3313e29 | 2007-02-12 00:54:31 -0800 | [diff] [blame] | 642 | inode->i_generation = fs32_to_cpu(sb, ufs_inode->ui_gen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | ufsi->i_flags = fs32_to_cpu(sb, ufs_inode->ui_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 644 | ufsi->i_shadow = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_shadow); |
| 645 | ufsi->i_oeftflag = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_oeftflag); |
Evgeniy Dushistov | 05f225d | 2006-06-27 02:53:59 -0700 | [diff] [blame] | 646 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | |
| 648 | if (S_ISCHR(mode) || S_ISBLK(mode) || inode->i_blocks) { |
Duane Griffin | f33219b | 2009-01-08 22:43:49 +0000 | [diff] [blame] | 649 | memcpy(ufsi->i_u1.i_data, &ufs_inode->ui_u2.ui_addr, |
| 650 | sizeof(ufs_inode->ui_u2.ui_addr)); |
Evgeniy Dushistov | dd187a2 | 2006-06-25 05:47:25 -0700 | [diff] [blame] | 651 | } else { |
Duane Griffin | f33219b | 2009-01-08 22:43:49 +0000 | [diff] [blame] | 652 | memcpy(ufsi->i_u1.i_symlink, ufs_inode->ui_u2.ui_symlink, |
Duane Griffin | b12903f | 2009-01-08 22:43:50 +0000 | [diff] [blame] | 653 | sizeof(ufs_inode->ui_u2.ui_symlink) - 1); |
| 654 | ufsi->i_u1.i_symlink[sizeof(ufs_inode->ui_u2.ui_symlink) - 1] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | } |
Evgeniy Dushistov | 07a0cfe | 2007-04-16 22:53:24 -0700 | [diff] [blame] | 656 | return 0; |
Evgeniy Dushistov | 05f225d | 2006-06-27 02:53:59 -0700 | [diff] [blame] | 657 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | |
Evgeniy Dushistov | 07a0cfe | 2007-04-16 22:53:24 -0700 | [diff] [blame] | 659 | static int ufs2_read_inode(struct inode *inode, struct ufs2_inode *ufs2_inode) |
Evgeniy Dushistov | 05f225d | 2006-06-27 02:53:59 -0700 | [diff] [blame] | 660 | { |
| 661 | struct ufs_inode_info *ufsi = UFS_I(inode); |
| 662 | struct super_block *sb = inode->i_sb; |
| 663 | mode_t mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 664 | |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 665 | UFSD("Reading ufs2 inode, ino %lu\n", inode->i_ino); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 | /* |
| 667 | * Copy data to the in-core inode. |
| 668 | */ |
| 669 | inode->i_mode = mode = fs16_to_cpu(sb, ufs2_inode->ui_mode); |
| 670 | inode->i_nlink = fs16_to_cpu(sb, ufs2_inode->ui_nlink); |
Evgeniy Dushistov | 07a0cfe | 2007-04-16 22:53:24 -0700 | [diff] [blame] | 671 | if (inode->i_nlink == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 672 | ufs_error (sb, "ufs_read_inode", "inode %lu has zero nlink\n", inode->i_ino); |
Evgeniy Dushistov | 07a0cfe | 2007-04-16 22:53:24 -0700 | [diff] [blame] | 673 | return -1; |
| 674 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | |
| 676 | /* |
| 677 | * Linux now has 32-bit uid and gid, so we can support EFT. |
| 678 | */ |
| 679 | inode->i_uid = fs32_to_cpu(sb, ufs2_inode->ui_uid); |
| 680 | inode->i_gid = fs32_to_cpu(sb, ufs2_inode->ui_gid); |
| 681 | |
| 682 | inode->i_size = fs64_to_cpu(sb, ufs2_inode->ui_size); |
Evgeniy Dushistov | 2189850 | 2007-03-16 13:38:07 -0800 | [diff] [blame] | 683 | inode->i_atime.tv_sec = fs64_to_cpu(sb, ufs2_inode->ui_atime); |
| 684 | inode->i_ctime.tv_sec = fs64_to_cpu(sb, ufs2_inode->ui_ctime); |
| 685 | inode->i_mtime.tv_sec = fs64_to_cpu(sb, ufs2_inode->ui_mtime); |
| 686 | inode->i_atime.tv_nsec = fs32_to_cpu(sb, ufs2_inode->ui_atimensec); |
| 687 | inode->i_ctime.tv_nsec = fs32_to_cpu(sb, ufs2_inode->ui_ctimensec); |
| 688 | inode->i_mtime.tv_nsec = fs32_to_cpu(sb, ufs2_inode->ui_mtimensec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | inode->i_blocks = fs64_to_cpu(sb, ufs2_inode->ui_blocks); |
Evgeniy Dushistov | 3313e29 | 2007-02-12 00:54:31 -0800 | [diff] [blame] | 690 | inode->i_generation = fs32_to_cpu(sb, ufs2_inode->ui_gen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | ufsi->i_flags = fs32_to_cpu(sb, ufs2_inode->ui_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 692 | /* |
| 693 | ufsi->i_shadow = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_shadow); |
| 694 | ufsi->i_oeftflag = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_oeftflag); |
| 695 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | |
| 697 | if (S_ISCHR(mode) || S_ISBLK(mode) || inode->i_blocks) { |
Duane Griffin | f33219b | 2009-01-08 22:43:49 +0000 | [diff] [blame] | 698 | memcpy(ufsi->i_u1.u2_i_data, &ufs2_inode->ui_u2.ui_addr, |
| 699 | sizeof(ufs2_inode->ui_u2.ui_addr)); |
Evgeniy Dushistov | 05f225d | 2006-06-27 02:53:59 -0700 | [diff] [blame] | 700 | } else { |
Duane Griffin | f33219b | 2009-01-08 22:43:49 +0000 | [diff] [blame] | 701 | memcpy(ufsi->i_u1.i_symlink, ufs2_inode->ui_u2.ui_symlink, |
Duane Griffin | b12903f | 2009-01-08 22:43:50 +0000 | [diff] [blame] | 702 | sizeof(ufs2_inode->ui_u2.ui_symlink) - 1); |
| 703 | ufsi->i_u1.i_symlink[sizeof(ufs2_inode->ui_u2.ui_symlink) - 1] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 704 | } |
Evgeniy Dushistov | 07a0cfe | 2007-04-16 22:53:24 -0700 | [diff] [blame] | 705 | return 0; |
Evgeniy Dushistov | 05f225d | 2006-06-27 02:53:59 -0700 | [diff] [blame] | 706 | } |
| 707 | |
David Howells | b55c460 | 2008-02-07 00:15:48 -0800 | [diff] [blame] | 708 | struct inode *ufs_iget(struct super_block *sb, unsigned long ino) |
Evgeniy Dushistov | 05f225d | 2006-06-27 02:53:59 -0700 | [diff] [blame] | 709 | { |
David Howells | b55c460 | 2008-02-07 00:15:48 -0800 | [diff] [blame] | 710 | struct ufs_inode_info *ufsi; |
| 711 | struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; |
Evgeniy Dushistov | 05f225d | 2006-06-27 02:53:59 -0700 | [diff] [blame] | 712 | struct buffer_head * bh; |
David Howells | b55c460 | 2008-02-07 00:15:48 -0800 | [diff] [blame] | 713 | struct inode *inode; |
Evgeniy Dushistov | 07a0cfe | 2007-04-16 22:53:24 -0700 | [diff] [blame] | 714 | int err; |
Evgeniy Dushistov | 05f225d | 2006-06-27 02:53:59 -0700 | [diff] [blame] | 715 | |
David Howells | b55c460 | 2008-02-07 00:15:48 -0800 | [diff] [blame] | 716 | UFSD("ENTER, ino %lu\n", ino); |
Evgeniy Dushistov | 05f225d | 2006-06-27 02:53:59 -0700 | [diff] [blame] | 717 | |
David Howells | b55c460 | 2008-02-07 00:15:48 -0800 | [diff] [blame] | 718 | if (ino < UFS_ROOTINO || ino > (uspi->s_ncg * uspi->s_ipg)) { |
Evgeniy Dushistov | 05f225d | 2006-06-27 02:53:59 -0700 | [diff] [blame] | 719 | ufs_warning(sb, "ufs_read_inode", "bad inode number (%lu)\n", |
David Howells | b55c460 | 2008-02-07 00:15:48 -0800 | [diff] [blame] | 720 | ino); |
| 721 | return ERR_PTR(-EIO); |
Evgeniy Dushistov | 05f225d | 2006-06-27 02:53:59 -0700 | [diff] [blame] | 722 | } |
| 723 | |
David Howells | b55c460 | 2008-02-07 00:15:48 -0800 | [diff] [blame] | 724 | inode = iget_locked(sb, ino); |
| 725 | if (!inode) |
| 726 | return ERR_PTR(-ENOMEM); |
| 727 | if (!(inode->i_state & I_NEW)) |
| 728 | return inode; |
| 729 | |
| 730 | ufsi = UFS_I(inode); |
| 731 | |
Evgeniy Dushistov | 05f225d | 2006-06-27 02:53:59 -0700 | [diff] [blame] | 732 | bh = sb_bread(sb, uspi->s_sbbase + ufs_inotofsba(inode->i_ino)); |
| 733 | if (!bh) { |
| 734 | ufs_warning(sb, "ufs_read_inode", "unable to read inode %lu\n", |
| 735 | inode->i_ino); |
| 736 | goto bad_inode; |
| 737 | } |
| 738 | if ((UFS_SB(sb)->s_flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) { |
| 739 | struct ufs2_inode *ufs2_inode = (struct ufs2_inode *)bh->b_data; |
| 740 | |
Evgeniy Dushistov | 07a0cfe | 2007-04-16 22:53:24 -0700 | [diff] [blame] | 741 | err = ufs2_read_inode(inode, |
| 742 | ufs2_inode + ufs_inotofsbo(inode->i_ino)); |
Evgeniy Dushistov | 05f225d | 2006-06-27 02:53:59 -0700 | [diff] [blame] | 743 | } else { |
| 744 | struct ufs_inode *ufs_inode = (struct ufs_inode *)bh->b_data; |
| 745 | |
Evgeniy Dushistov | 07a0cfe | 2007-04-16 22:53:24 -0700 | [diff] [blame] | 746 | err = ufs1_read_inode(inode, |
| 747 | ufs_inode + ufs_inotofsbo(inode->i_ino)); |
Evgeniy Dushistov | 05f225d | 2006-06-27 02:53:59 -0700 | [diff] [blame] | 748 | } |
| 749 | |
Evgeniy Dushistov | 07a0cfe | 2007-04-16 22:53:24 -0700 | [diff] [blame] | 750 | if (err) |
| 751 | goto bad_inode; |
Evgeniy Dushistov | 05f225d | 2006-06-27 02:53:59 -0700 | [diff] [blame] | 752 | inode->i_version++; |
| 753 | ufsi->i_lastfrag = |
| 754 | (inode->i_size + uspi->s_fsize - 1) >> uspi->s_fshift; |
| 755 | ufsi->i_dir_start_lookup = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 756 | ufsi->i_osync = 0; |
| 757 | |
Evgeniy Dushistov | 826843a | 2006-06-25 05:47:21 -0700 | [diff] [blame] | 758 | ufs_set_inode_ops(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 759 | |
| 760 | brelse(bh); |
| 761 | |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 762 | UFSD("EXIT\n"); |
David Howells | b55c460 | 2008-02-07 00:15:48 -0800 | [diff] [blame] | 763 | unlock_new_inode(inode); |
| 764 | return inode; |
Evgeniy Dushistov | 05f225d | 2006-06-27 02:53:59 -0700 | [diff] [blame] | 765 | |
| 766 | bad_inode: |
David Howells | b55c460 | 2008-02-07 00:15:48 -0800 | [diff] [blame] | 767 | iget_failed(inode); |
| 768 | return ERR_PTR(-EIO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 769 | } |
| 770 | |
Evgeniy Dushistov | 3313e29 | 2007-02-12 00:54:31 -0800 | [diff] [blame] | 771 | static void ufs1_update_inode(struct inode *inode, struct ufs_inode *ufs_inode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 772 | { |
Evgeniy Dushistov | 3313e29 | 2007-02-12 00:54:31 -0800 | [diff] [blame] | 773 | struct super_block *sb = inode->i_sb; |
| 774 | struct ufs_inode_info *ufsi = UFS_I(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 775 | |
| 776 | ufs_inode->ui_mode = cpu_to_fs16(sb, inode->i_mode); |
| 777 | ufs_inode->ui_nlink = cpu_to_fs16(sb, inode->i_nlink); |
| 778 | |
| 779 | ufs_set_inode_uid(sb, ufs_inode, inode->i_uid); |
| 780 | ufs_set_inode_gid(sb, ufs_inode, inode->i_gid); |
| 781 | |
| 782 | ufs_inode->ui_size = cpu_to_fs64(sb, inode->i_size); |
| 783 | ufs_inode->ui_atime.tv_sec = cpu_to_fs32(sb, inode->i_atime.tv_sec); |
| 784 | ufs_inode->ui_atime.tv_usec = 0; |
| 785 | ufs_inode->ui_ctime.tv_sec = cpu_to_fs32(sb, inode->i_ctime.tv_sec); |
| 786 | ufs_inode->ui_ctime.tv_usec = 0; |
| 787 | ufs_inode->ui_mtime.tv_sec = cpu_to_fs32(sb, inode->i_mtime.tv_sec); |
| 788 | ufs_inode->ui_mtime.tv_usec = 0; |
| 789 | ufs_inode->ui_blocks = cpu_to_fs32(sb, inode->i_blocks); |
| 790 | ufs_inode->ui_flags = cpu_to_fs32(sb, ufsi->i_flags); |
Evgeniy Dushistov | 3313e29 | 2007-02-12 00:54:31 -0800 | [diff] [blame] | 791 | ufs_inode->ui_gen = cpu_to_fs32(sb, inode->i_generation); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 792 | |
Evgeniy Dushistov | 3313e29 | 2007-02-12 00:54:31 -0800 | [diff] [blame] | 793 | if ((UFS_SB(sb)->s_flags & UFS_UID_MASK) == UFS_UID_EFT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 794 | ufs_inode->ui_u3.ui_sun.ui_shadow = cpu_to_fs32(sb, ufsi->i_shadow); |
| 795 | ufs_inode->ui_u3.ui_sun.ui_oeftflag = cpu_to_fs32(sb, ufsi->i_oeftflag); |
| 796 | } |
| 797 | |
| 798 | if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { |
| 799 | /* ufs_inode->ui_u2.ui_addr.ui_db[0] = cpu_to_fs32(sb, inode->i_rdev); */ |
| 800 | ufs_inode->ui_u2.ui_addr.ui_db[0] = ufsi->i_u1.i_data[0]; |
| 801 | } else if (inode->i_blocks) { |
Duane Griffin | f33219b | 2009-01-08 22:43:49 +0000 | [diff] [blame] | 802 | memcpy(&ufs_inode->ui_u2.ui_addr, ufsi->i_u1.i_data, |
| 803 | sizeof(ufs_inode->ui_u2.ui_addr)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 804 | } |
| 805 | else { |
Duane Griffin | f33219b | 2009-01-08 22:43:49 +0000 | [diff] [blame] | 806 | memcpy(&ufs_inode->ui_u2.ui_symlink, ufsi->i_u1.i_symlink, |
| 807 | sizeof(ufs_inode->ui_u2.ui_symlink)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 808 | } |
| 809 | |
| 810 | if (!inode->i_nlink) |
| 811 | memset (ufs_inode, 0, sizeof(struct ufs_inode)); |
Evgeniy Dushistov | 3313e29 | 2007-02-12 00:54:31 -0800 | [diff] [blame] | 812 | } |
| 813 | |
| 814 | static void ufs2_update_inode(struct inode *inode, struct ufs2_inode *ufs_inode) |
| 815 | { |
| 816 | struct super_block *sb = inode->i_sb; |
| 817 | struct ufs_inode_info *ufsi = UFS_I(inode); |
Evgeniy Dushistov | 3313e29 | 2007-02-12 00:54:31 -0800 | [diff] [blame] | 818 | |
| 819 | UFSD("ENTER\n"); |
| 820 | ufs_inode->ui_mode = cpu_to_fs16(sb, inode->i_mode); |
| 821 | ufs_inode->ui_nlink = cpu_to_fs16(sb, inode->i_nlink); |
| 822 | |
| 823 | ufs_inode->ui_uid = cpu_to_fs32(sb, inode->i_uid); |
| 824 | ufs_inode->ui_gid = cpu_to_fs32(sb, inode->i_gid); |
| 825 | |
| 826 | ufs_inode->ui_size = cpu_to_fs64(sb, inode->i_size); |
Evgeniy Dushistov | 2189850 | 2007-03-16 13:38:07 -0800 | [diff] [blame] | 827 | ufs_inode->ui_atime = cpu_to_fs64(sb, inode->i_atime.tv_sec); |
| 828 | ufs_inode->ui_atimensec = cpu_to_fs32(sb, inode->i_atime.tv_nsec); |
| 829 | ufs_inode->ui_ctime = cpu_to_fs64(sb, inode->i_ctime.tv_sec); |
| 830 | ufs_inode->ui_ctimensec = cpu_to_fs32(sb, inode->i_ctime.tv_nsec); |
| 831 | ufs_inode->ui_mtime = cpu_to_fs64(sb, inode->i_mtime.tv_sec); |
| 832 | ufs_inode->ui_mtimensec = cpu_to_fs32(sb, inode->i_mtime.tv_nsec); |
Evgeniy Dushistov | 3313e29 | 2007-02-12 00:54:31 -0800 | [diff] [blame] | 833 | |
| 834 | ufs_inode->ui_blocks = cpu_to_fs64(sb, inode->i_blocks); |
| 835 | ufs_inode->ui_flags = cpu_to_fs32(sb, ufsi->i_flags); |
| 836 | ufs_inode->ui_gen = cpu_to_fs32(sb, inode->i_generation); |
| 837 | |
| 838 | if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { |
| 839 | /* ufs_inode->ui_u2.ui_addr.ui_db[0] = cpu_to_fs32(sb, inode->i_rdev); */ |
| 840 | ufs_inode->ui_u2.ui_addr.ui_db[0] = ufsi->i_u1.u2_i_data[0]; |
| 841 | } else if (inode->i_blocks) { |
Duane Griffin | f33219b | 2009-01-08 22:43:49 +0000 | [diff] [blame] | 842 | memcpy(&ufs_inode->ui_u2.ui_addr, ufsi->i_u1.u2_i_data, |
| 843 | sizeof(ufs_inode->ui_u2.ui_addr)); |
Evgeniy Dushistov | 3313e29 | 2007-02-12 00:54:31 -0800 | [diff] [blame] | 844 | } else { |
Duane Griffin | f33219b | 2009-01-08 22:43:49 +0000 | [diff] [blame] | 845 | memcpy(&ufs_inode->ui_u2.ui_symlink, ufsi->i_u1.i_symlink, |
| 846 | sizeof(ufs_inode->ui_u2.ui_symlink)); |
Evgeniy Dushistov | 3313e29 | 2007-02-12 00:54:31 -0800 | [diff] [blame] | 847 | } |
| 848 | |
| 849 | if (!inode->i_nlink) |
| 850 | memset (ufs_inode, 0, sizeof(struct ufs2_inode)); |
| 851 | UFSD("EXIT\n"); |
| 852 | } |
| 853 | |
| 854 | static int ufs_update_inode(struct inode * inode, int do_sync) |
| 855 | { |
| 856 | struct super_block *sb = inode->i_sb; |
| 857 | struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; |
| 858 | struct buffer_head * bh; |
| 859 | |
| 860 | UFSD("ENTER, ino %lu\n", inode->i_ino); |
| 861 | |
| 862 | if (inode->i_ino < UFS_ROOTINO || |
| 863 | inode->i_ino > (uspi->s_ncg * uspi->s_ipg)) { |
| 864 | ufs_warning (sb, "ufs_read_inode", "bad inode number (%lu)\n", inode->i_ino); |
| 865 | return -1; |
| 866 | } |
| 867 | |
| 868 | bh = sb_bread(sb, ufs_inotofsba(inode->i_ino)); |
| 869 | if (!bh) { |
| 870 | ufs_warning (sb, "ufs_read_inode", "unable to read inode %lu\n", inode->i_ino); |
| 871 | return -1; |
| 872 | } |
| 873 | if (uspi->fs_magic == UFS2_MAGIC) { |
| 874 | struct ufs2_inode *ufs2_inode = (struct ufs2_inode *)bh->b_data; |
| 875 | |
| 876 | ufs2_update_inode(inode, |
| 877 | ufs2_inode + ufs_inotofsbo(inode->i_ino)); |
| 878 | } else { |
| 879 | struct ufs_inode *ufs_inode = (struct ufs_inode *) bh->b_data; |
| 880 | |
| 881 | ufs1_update_inode(inode, ufs_inode + ufs_inotofsbo(inode->i_ino)); |
| 882 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 883 | |
| 884 | mark_buffer_dirty(bh); |
| 885 | if (do_sync) |
| 886 | sync_dirty_buffer(bh); |
| 887 | brelse (bh); |
| 888 | |
Evgeniy Dushistov | abf5d15 | 2006-06-25 05:47:24 -0700 | [diff] [blame] | 889 | UFSD("EXIT\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 890 | return 0; |
| 891 | } |
| 892 | |
| 893 | int ufs_write_inode (struct inode * inode, int wait) |
| 894 | { |
| 895 | int ret; |
| 896 | lock_kernel(); |
| 897 | ret = ufs_update_inode (inode, wait); |
| 898 | unlock_kernel(); |
| 899 | return ret; |
| 900 | } |
| 901 | |
| 902 | int ufs_sync_inode (struct inode *inode) |
| 903 | { |
| 904 | return ufs_update_inode (inode, 1); |
| 905 | } |
| 906 | |
| 907 | void ufs_delete_inode (struct inode * inode) |
| 908 | { |
Evgeniy Dushistov | 10e5dce | 2006-07-01 04:36:24 -0700 | [diff] [blame] | 909 | loff_t old_i_size; |
| 910 | |
Mark Fasheh | fef2665 | 2005-09-09 13:01:31 -0700 | [diff] [blame] | 911 | truncate_inode_pages(&inode->i_data, 0); |
Evgeniy Dushistov | 07a0cfe | 2007-04-16 22:53:24 -0700 | [diff] [blame] | 912 | if (is_bad_inode(inode)) |
| 913 | goto no_delete; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 914 | /*UFS_I(inode)->i_dtime = CURRENT_TIME;*/ |
| 915 | lock_kernel(); |
| 916 | mark_inode_dirty(inode); |
| 917 | ufs_update_inode(inode, IS_SYNC(inode)); |
Evgeniy Dushistov | 10e5dce | 2006-07-01 04:36:24 -0700 | [diff] [blame] | 918 | old_i_size = inode->i_size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 919 | inode->i_size = 0; |
Evgeniy Dushistov | 10e5dce | 2006-07-01 04:36:24 -0700 | [diff] [blame] | 920 | if (inode->i_blocks && ufs_truncate(inode, old_i_size)) |
Harvey Harrison | 9746077a7 | 2008-04-28 02:16:17 -0700 | [diff] [blame] | 921 | ufs_warning(inode->i_sb, __func__, "ufs_truncate failed\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 922 | ufs_free_inode (inode); |
| 923 | unlock_kernel(); |
Evgeniy Dushistov | 07a0cfe | 2007-04-16 22:53:24 -0700 | [diff] [blame] | 924 | return; |
| 925 | no_delete: |
| 926 | clear_inode(inode); /* We must guarantee clearing of inode... */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 927 | } |