diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2015-06-18 22:39:46 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-07-06 17:39:52 -0400 |
commit | 5a39c25562aa5eab5a798919855cf41ddeed8b0d (patch) | |
tree | 93d8998d91be23821e4e1e0f90c633f967f75927 /fs/ufs | |
parent | f53bd1421b3eb84375e9e6964665d23d4190400d (diff) |
ufs_inode_get{frag,block}(): get rid of retries
We are holding ->truncate_mutex, so nobody else can alter our
block pointers. Rechecks/retries were needed back when we
only held BKL there, and had to cope with write_begin/writepage
and writepage/truncate races. Can't happen anymore...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ufs')
-rw-r--r-- | fs/ufs/inode.c | 43 |
1 files changed, 8 insertions, 35 deletions
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c index 86cc1eea0fb2..95cb0a8f5ec9 100644 --- a/fs/ufs/inode.c +++ b/fs/ufs/inode.c | |||
@@ -248,20 +248,12 @@ ufs_inode_getfrag(struct inode *inode, u64 fragment, | |||
248 | 248 | ||
249 | goal = 0; | 249 | goal = 0; |
250 | 250 | ||
251 | repeat: | ||
252 | tmp = ufs_data_ptr_to_cpu(sb, p); | 251 | tmp = ufs_data_ptr_to_cpu(sb, p); |
253 | 252 | ||
254 | lastfrag = ufsi->i_lastfrag; | 253 | lastfrag = ufsi->i_lastfrag; |
255 | if (tmp && fragment < lastfrag) { | 254 | if (tmp && fragment < lastfrag) { |
256 | if (!phys) { | 255 | if (!phys) { |
257 | result = sb_getblk(sb, uspi->s_sbbase + tmp + blockoff); | 256 | return sb_getblk(sb, uspi->s_sbbase + tmp + blockoff); |
258 | if (tmp == ufs_data_ptr_to_cpu(sb, p)) { | ||
259 | UFSD("EXIT, result %llu\n", | ||
260 | (unsigned long long)tmp + blockoff); | ||
261 | return result; | ||
262 | } | ||
263 | brelse (result); | ||
264 | goto repeat; | ||
265 | } else { | 257 | } else { |
266 | *phys = uspi->s_sbbase + tmp + blockoff; | 258 | *phys = uspi->s_sbbase + tmp + blockoff; |
267 | return NULL; | 259 | return NULL; |
@@ -283,14 +275,9 @@ repeat: | |||
283 | ufs_data_ptr_to_cpu(sb, p2), | 275 | ufs_data_ptr_to_cpu(sb, p2), |
284 | uspi->s_fpb - lastblockoff, | 276 | uspi->s_fpb - lastblockoff, |
285 | err, locked_page); | 277 | err, locked_page); |
286 | if (!tmp) { | 278 | if (!tmp) |
287 | if (lastfrag != ufsi->i_lastfrag) | 279 | return NULL; |
288 | goto repeat; | ||
289 | else | ||
290 | return NULL; | ||
291 | } | ||
292 | lastfrag = ufsi->i_lastfrag; | 280 | lastfrag = ufsi->i_lastfrag; |
293 | |||
294 | } | 281 | } |
295 | tmp = ufs_data_ptr_to_cpu(sb, | 282 | tmp = ufs_data_ptr_to_cpu(sb, |
296 | ufs_get_direct_data_ptr(uspi, ufsi, | 283 | ufs_get_direct_data_ptr(uspi, ufsi, |
@@ -325,9 +312,6 @@ repeat: | |||
325 | phys != NULL ? locked_page : NULL); | 312 | phys != NULL ? locked_page : NULL); |
326 | } | 313 | } |
327 | if (!tmp) { | 314 | if (!tmp) { |
328 | if ((!blockoff && ufs_data_ptr_to_cpu(sb, p)) || | ||
329 | (blockoff && lastfrag != ufsi->i_lastfrag)) | ||
330 | goto repeat; | ||
331 | *err = -ENOSPC; | 315 | *err = -ENOSPC; |
332 | return NULL; | 316 | return NULL; |
333 | } | 317 | } |
@@ -345,7 +329,6 @@ repeat: | |||
345 | if (IS_SYNC(inode)) | 329 | if (IS_SYNC(inode)) |
346 | ufs_sync_inode (inode); | 330 | ufs_sync_inode (inode); |
347 | mark_inode_dirty(inode); | 331 | mark_inode_dirty(inode); |
348 | UFSD("EXIT, result %llu\n", (unsigned long long)tmp + blockoff); | ||
349 | return result; | 332 | return result; |
350 | 333 | ||
351 | /* This part : To be implemented .... | 334 | /* This part : To be implemented .... |
@@ -409,19 +392,14 @@ ufs_inode_getblock(struct inode *inode, struct buffer_head *bh, | |||
409 | p = (__fs64 *)bh->b_data + block; | 392 | p = (__fs64 *)bh->b_data + block; |
410 | else | 393 | else |
411 | p = (__fs32 *)bh->b_data + block; | 394 | p = (__fs32 *)bh->b_data + block; |
412 | repeat: | 395 | |
413 | tmp = ufs_data_ptr_to_cpu(sb, p); | 396 | tmp = ufs_data_ptr_to_cpu(sb, p); |
414 | if (tmp) { | 397 | if (tmp) { |
415 | if (!phys) { | 398 | if (!phys) |
416 | result = sb_getblk(sb, uspi->s_sbbase + tmp + blockoff); | 399 | result = sb_getblk(sb, uspi->s_sbbase + tmp + blockoff); |
417 | if (tmp == ufs_data_ptr_to_cpu(sb, p)) | 400 | else |
418 | goto out; | ||
419 | brelse (result); | ||
420 | goto repeat; | ||
421 | } else { | ||
422 | *phys = uspi->s_sbbase + tmp + blockoff; | 401 | *phys = uspi->s_sbbase + tmp + blockoff; |
423 | goto out; | 402 | goto out; |
424 | } | ||
425 | } | 403 | } |
426 | 404 | ||
427 | if (block && (uspi->fs_magic == UFS2_MAGIC ? | 405 | if (block && (uspi->fs_magic == UFS2_MAGIC ? |
@@ -432,12 +410,8 @@ repeat: | |||
432 | goal = bh->b_blocknr + uspi->s_fpb; | 410 | goal = bh->b_blocknr + uspi->s_fpb; |
433 | tmp = ufs_new_fragments(inode, p, ufs_blknum(new_fragment), goal, | 411 | tmp = ufs_new_fragments(inode, p, ufs_blknum(new_fragment), goal, |
434 | uspi->s_fpb, err, locked_page); | 412 | uspi->s_fpb, err, locked_page); |
435 | if (!tmp) { | 413 | if (!tmp) |
436 | if (ufs_data_ptr_to_cpu(sb, p)) | ||
437 | goto repeat; | ||
438 | goto out; | 414 | goto out; |
439 | } | ||
440 | |||
441 | 415 | ||
442 | if (!phys) { | 416 | if (!phys) { |
443 | result = sb_getblk(sb, uspi->s_sbbase + tmp + blockoff); | 417 | result = sb_getblk(sb, uspi->s_sbbase + tmp + blockoff); |
@@ -451,7 +425,6 @@ repeat: | |||
451 | sync_dirty_buffer(bh); | 425 | sync_dirty_buffer(bh); |
452 | inode->i_ctime = CURRENT_TIME_SEC; | 426 | inode->i_ctime = CURRENT_TIME_SEC; |
453 | mark_inode_dirty(inode); | 427 | mark_inode_dirty(inode); |
454 | UFSD("result %llu\n", (unsigned long long)tmp + blockoff); | ||
455 | out: | 428 | out: |
456 | brelse (bh); | 429 | brelse (bh); |
457 | UFSD("EXIT\n"); | 430 | UFSD("EXIT\n"); |