diff options
Diffstat (limited to 'fs/xfs/xfs_utils.c')
-rw-r--r-- | fs/xfs/xfs_utils.c | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/fs/xfs/xfs_utils.c b/fs/xfs/xfs_utils.c index 102ce4898ab7..b7d5769d2df0 100644 --- a/fs/xfs/xfs_utils.c +++ b/fs/xfs/xfs_utils.c | |||
@@ -320,86 +320,3 @@ xfs_bumplink( | |||
320 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | 320 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); |
321 | return 0; | 321 | return 0; |
322 | } | 322 | } |
323 | |||
324 | /* | ||
325 | * Try to truncate the given file to 0 length. Currently called | ||
326 | * only out of xfs_remove when it has to truncate a file to free | ||
327 | * up space for the remove to proceed. | ||
328 | */ | ||
329 | int | ||
330 | xfs_truncate_file( | ||
331 | xfs_mount_t *mp, | ||
332 | xfs_inode_t *ip) | ||
333 | { | ||
334 | xfs_trans_t *tp; | ||
335 | int error; | ||
336 | |||
337 | #ifdef QUOTADEBUG | ||
338 | /* | ||
339 | * This is called to truncate the quotainodes too. | ||
340 | */ | ||
341 | if (XFS_IS_UQUOTA_ON(mp)) { | ||
342 | if (ip->i_ino != mp->m_sb.sb_uquotino) | ||
343 | ASSERT(ip->i_udquot); | ||
344 | } | ||
345 | if (XFS_IS_OQUOTA_ON(mp)) { | ||
346 | if (ip->i_ino != mp->m_sb.sb_gquotino) | ||
347 | ASSERT(ip->i_gdquot); | ||
348 | } | ||
349 | #endif | ||
350 | /* | ||
351 | * Make the call to xfs_itruncate_start before starting the | ||
352 | * transaction, because we cannot make the call while we're | ||
353 | * in a transaction. | ||
354 | */ | ||
355 | xfs_ilock(ip, XFS_IOLOCK_EXCL); | ||
356 | error = xfs_itruncate_start(ip, XFS_ITRUNC_DEFINITE, (xfs_fsize_t)0); | ||
357 | if (error) { | ||
358 | xfs_iunlock(ip, XFS_IOLOCK_EXCL); | ||
359 | return error; | ||
360 | } | ||
361 | |||
362 | tp = xfs_trans_alloc(mp, XFS_TRANS_TRUNCATE_FILE); | ||
363 | if ((error = xfs_trans_reserve(tp, 0, XFS_ITRUNCATE_LOG_RES(mp), 0, | ||
364 | XFS_TRANS_PERM_LOG_RES, | ||
365 | XFS_ITRUNCATE_LOG_COUNT))) { | ||
366 | xfs_trans_cancel(tp, 0); | ||
367 | xfs_iunlock(ip, XFS_IOLOCK_EXCL); | ||
368 | return error; | ||
369 | } | ||
370 | |||
371 | /* | ||
372 | * Follow the normal truncate locking protocol. Since we | ||
373 | * hold the inode in the transaction, we know that its number | ||
374 | * of references will stay constant. | ||
375 | */ | ||
376 | xfs_ilock(ip, XFS_ILOCK_EXCL); | ||
377 | xfs_trans_ijoin(tp, ip); | ||
378 | |||
379 | /* | ||
380 | * Signal a sync xaction. The only case where that isn't | ||
381 | * the case is if we're truncating an already unlinked file | ||
382 | * on a wsync fs. In that case, we know the blocks can't | ||
383 | * reappear in the file because the links to file are | ||
384 | * permanently toast. Currently, we're always going to | ||
385 | * want a sync transaction because this code is being | ||
386 | * called from places where nlink is guaranteed to be 1 | ||
387 | * but I'm leaving the tests in to protect against future | ||
388 | * changes -- rcc. | ||
389 | */ | ||
390 | error = xfs_itruncate_finish(&tp, ip, (xfs_fsize_t)0, | ||
391 | XFS_DATA_FORK, | ||
392 | ((ip->i_d.di_nlink != 0 || | ||
393 | !(mp->m_flags & XFS_MOUNT_WSYNC)) | ||
394 | ? 1 : 0)); | ||
395 | if (error) { | ||
396 | xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | | ||
397 | XFS_TRANS_ABORT); | ||
398 | } else { | ||
399 | xfs_ichgtime(ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); | ||
400 | error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); | ||
401 | } | ||
402 | xfs_iunlock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); | ||
403 | |||
404 | return error; | ||
405 | } | ||