aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ufs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-06-19 00:10:00 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2015-07-06 17:39:55 -0400
commitbbb3eb9d3432ce55a620778ecf5670fa7942090e (patch)
tree48680d5446f2c4c7df7492a66f2e7cf6d57ab719 /fs/ufs
parent71dd42846ffb2bd1a90e9ac2c52df0cc2ed92307 (diff)
ufs_inode_get{frag,block}(): consolidate success exits
These calling conventions are rudiments of pre-2.3 times; they really need to be sanitized. This is the first step; next will be _always_ returning a block number, instead of this "return a pointer to buffer_head, except when we get to the actual data" crap. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ufs')
-rw-r--r--fs/ufs/inode.c50
1 files changed, 22 insertions, 28 deletions
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index 5c4a4abae652..d65a89030c91 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -226,7 +226,6 @@ ufs_inode_getfrag(struct inode *inode, u64 fragment,
226 struct ufs_inode_info *ufsi = UFS_I(inode); 226 struct ufs_inode_info *ufsi = UFS_I(inode);
227 struct super_block *sb = inode->i_sb; 227 struct super_block *sb = inode->i_sb;
228 struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; 228 struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
229 struct buffer_head * result;
230 unsigned blockoff, lastblockoff; 229 unsigned blockoff, lastblockoff;
231 u64 tmp, goal, lastfrag, block, lastblock; 230 u64 tmp, goal, lastfrag, block, lastblock;
232 void *p, *p2; 231 void *p, *p2;
@@ -249,14 +248,8 @@ ufs_inode_getfrag(struct inode *inode, u64 fragment,
249 tmp = ufs_data_ptr_to_cpu(sb, p); 248 tmp = ufs_data_ptr_to_cpu(sb, p);
250 249
251 lastfrag = ufsi->i_lastfrag; 250 lastfrag = ufsi->i_lastfrag;
252 if (tmp && fragment < lastfrag) { 251 if (tmp && fragment < lastfrag)
253 if (!phys) { 252 goto out;
254 return sb_getblk(sb, uspi->s_sbbase + tmp + blockoff);
255 } else {
256 *phys = uspi->s_sbbase + tmp + blockoff;
257 return NULL;
258 }
259 }
260 253
261 lastblock = ufs_fragstoblks (lastfrag); 254 lastblock = ufs_fragstoblks (lastfrag);
262 lastblockoff = ufs_fragnum (lastfrag); 255 lastblockoff = ufs_fragnum (lastfrag);
@@ -314,20 +307,22 @@ ufs_inode_getfrag(struct inode *inode, u64 fragment,
314 return NULL; 307 return NULL;
315 } 308 }
316 309
317 if (!phys) { 310 if (phys) {
318 result = sb_getblk(sb, uspi->s_sbbase + tmp + blockoff);
319 } else {
320 *phys = uspi->s_sbbase + tmp + blockoff;
321 result = NULL;
322 *err = 0; 311 *err = 0;
323 *new = 1; 312 *new = 1;
324 } 313 }
325
326 inode->i_ctime = CURRENT_TIME_SEC; 314 inode->i_ctime = CURRENT_TIME_SEC;
327 if (IS_SYNC(inode)) 315 if (IS_SYNC(inode))
328 ufs_sync_inode (inode); 316 ufs_sync_inode (inode);
329 mark_inode_dirty(inode); 317 mark_inode_dirty(inode);
330 return result; 318out:
319 tmp += uspi->s_sbbase + blockoff;
320 if (!phys) {
321 return sb_getblk(sb, tmp);
322 } else {
323 *phys = tmp;
324 return NULL;
325 }
331 326
332 /* This part : To be implemented .... 327 /* This part : To be implemented ....
333 Required only for writing, not required for READ-ONLY. 328 Required only for writing, not required for READ-ONLY.
@@ -367,7 +362,7 @@ ufs_inode_getblock(struct inode *inode, struct buffer_head *bh,
367 struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; 362 struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
368 struct buffer_head * result; 363 struct buffer_head * result;
369 unsigned blockoff; 364 unsigned blockoff;
370 u64 tmp, goal, block; 365 u64 tmp = 0, goal, block;
371 void *p; 366 void *p;
372 367
373 block = ufs_fragstoblks (fragment); 368 block = ufs_fragstoblks (fragment);
@@ -392,13 +387,8 @@ ufs_inode_getblock(struct inode *inode, struct buffer_head *bh,
392 p = (__fs32 *)bh->b_data + block; 387 p = (__fs32 *)bh->b_data + block;
393 388
394 tmp = ufs_data_ptr_to_cpu(sb, p); 389 tmp = ufs_data_ptr_to_cpu(sb, p);
395 if (tmp) { 390 if (tmp)
396 if (!phys)
397 result = sb_getblk(sb, uspi->s_sbbase + tmp + blockoff);
398 else
399 *phys = uspi->s_sbbase + tmp + blockoff;
400 goto out; 391 goto out;
401 }
402 392
403 if (block && (uspi->fs_magic == UFS2_MAGIC ? 393 if (block && (uspi->fs_magic == UFS2_MAGIC ?
404 (tmp = fs64_to_cpu(sb, ((__fs64 *)bh->b_data)[block-1])) : 394 (tmp = fs64_to_cpu(sb, ((__fs64 *)bh->b_data)[block-1])) :
@@ -411,12 +401,8 @@ ufs_inode_getblock(struct inode *inode, struct buffer_head *bh,
411 if (!tmp) 401 if (!tmp)
412 goto out; 402 goto out;
413 403
414 if (!phys) { 404 if (new)
415 result = sb_getblk(sb, uspi->s_sbbase + tmp + blockoff);
416 } else {
417 *phys = uspi->s_sbbase + tmp + blockoff;
418 *new = 1; 405 *new = 1;
419 }
420 406
421 mark_buffer_dirty(bh); 407 mark_buffer_dirty(bh);
422 if (IS_SYNC(inode)) 408 if (IS_SYNC(inode))
@@ -425,6 +411,14 @@ ufs_inode_getblock(struct inode *inode, struct buffer_head *bh,
425 mark_inode_dirty(inode); 411 mark_inode_dirty(inode);
426out: 412out:
427 brelse (bh); 413 brelse (bh);
414 if (tmp) {
415 tmp += uspi->s_sbbase + blockoff;
416 if (phys) {
417 *phys = tmp;
418 } else {
419 result = sb_getblk(sb, tmp);
420 }
421 }
428 UFSD("EXIT\n"); 422 UFSD("EXIT\n");
429 return result; 423 return result;
430} 424}