diff options
Diffstat (limited to 'fs/xfs/xfs_utils.c')
-rw-r--r-- | fs/xfs/xfs_utils.c | 96 |
1 files changed, 4 insertions, 92 deletions
diff --git a/fs/xfs/xfs_utils.c b/fs/xfs/xfs_utils.c index 4d88616bde91..8b32d1a4c5a1 100644 --- a/fs/xfs/xfs_utils.c +++ b/fs/xfs/xfs_utils.c | |||
@@ -25,18 +25,14 @@ | |||
25 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
26 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
27 | #include "xfs_dir2.h" | 27 | #include "xfs_dir2.h" |
28 | #include "xfs_dmapi.h" | ||
29 | #include "xfs_mount.h" | 28 | #include "xfs_mount.h" |
30 | #include "xfs_bmap_btree.h" | 29 | #include "xfs_bmap_btree.h" |
31 | #include "xfs_dir2_sf.h" | ||
32 | #include "xfs_attr_sf.h" | ||
33 | #include "xfs_dinode.h" | 30 | #include "xfs_dinode.h" |
34 | #include "xfs_inode.h" | 31 | #include "xfs_inode.h" |
35 | #include "xfs_inode_item.h" | 32 | #include "xfs_inode_item.h" |
36 | #include "xfs_bmap.h" | 33 | #include "xfs_bmap.h" |
37 | #include "xfs_error.h" | 34 | #include "xfs_error.h" |
38 | #include "xfs_quota.h" | 35 | #include "xfs_quota.h" |
39 | #include "xfs_rw.h" | ||
40 | #include "xfs_itable.h" | 36 | #include "xfs_itable.h" |
41 | #include "xfs_utils.h" | 37 | #include "xfs_utils.h" |
42 | 38 | ||
@@ -60,7 +56,6 @@ xfs_dir_ialloc( | |||
60 | mode_t mode, | 56 | mode_t mode, |
61 | xfs_nlink_t nlink, | 57 | xfs_nlink_t nlink, |
62 | xfs_dev_t rdev, | 58 | xfs_dev_t rdev, |
63 | cred_t *credp, | ||
64 | prid_t prid, /* project id */ | 59 | prid_t prid, /* project id */ |
65 | int okalloc, /* ok to allocate new space */ | 60 | int okalloc, /* ok to allocate new space */ |
66 | xfs_inode_t **ipp, /* pointer to inode; it will be | 61 | xfs_inode_t **ipp, /* pointer to inode; it will be |
@@ -97,7 +92,7 @@ xfs_dir_ialloc( | |||
97 | * transaction commit so that no other process can steal | 92 | * transaction commit so that no other process can steal |
98 | * the inode(s) that we've just allocated. | 93 | * the inode(s) that we've just allocated. |
99 | */ | 94 | */ |
100 | code = xfs_ialloc(tp, dp, mode, nlink, rdev, credp, prid, okalloc, | 95 | code = xfs_ialloc(tp, dp, mode, nlink, rdev, prid, okalloc, |
101 | &ialloc_context, &call_again, &ip); | 96 | &ialloc_context, &call_again, &ip); |
102 | 97 | ||
103 | /* | 98 | /* |
@@ -201,7 +196,7 @@ xfs_dir_ialloc( | |||
201 | * other allocations in this allocation group, | 196 | * other allocations in this allocation group, |
202 | * this call should always succeed. | 197 | * this call should always succeed. |
203 | */ | 198 | */ |
204 | code = xfs_ialloc(tp, dp, mode, nlink, rdev, credp, prid, | 199 | code = xfs_ialloc(tp, dp, mode, nlink, rdev, prid, |
205 | okalloc, &ialloc_context, &call_again, &ip); | 200 | okalloc, &ialloc_context, &call_again, &ip); |
206 | 201 | ||
207 | /* | 202 | /* |
@@ -239,7 +234,7 @@ xfs_droplink( | |||
239 | { | 234 | { |
240 | int error; | 235 | int error; |
241 | 236 | ||
242 | xfs_ichgtime(ip, XFS_ICHGTIME_CHG); | 237 | xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG); |
243 | 238 | ||
244 | ASSERT (ip->i_d.di_nlink > 0); | 239 | ASSERT (ip->i_d.di_nlink > 0); |
245 | ip->i_d.di_nlink--; | 240 | ip->i_d.di_nlink--; |
@@ -303,7 +298,7 @@ xfs_bumplink( | |||
303 | { | 298 | { |
304 | if (ip->i_d.di_nlink >= XFS_MAXLINK) | 299 | if (ip->i_d.di_nlink >= XFS_MAXLINK) |
305 | return XFS_ERROR(EMLINK); | 300 | return XFS_ERROR(EMLINK); |
306 | xfs_ichgtime(ip, XFS_ICHGTIME_CHG); | 301 | xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG); |
307 | 302 | ||
308 | ASSERT(ip->i_d.di_nlink > 0); | 303 | ASSERT(ip->i_d.di_nlink > 0); |
309 | ip->i_d.di_nlink++; | 304 | ip->i_d.di_nlink++; |
@@ -324,86 +319,3 @@ xfs_bumplink( | |||
324 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | 319 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); |
325 | return 0; | 320 | return 0; |
326 | } | 321 | } |
327 | |||
328 | /* | ||
329 | * Try to truncate the given file to 0 length. Currently called | ||
330 | * only out of xfs_remove when it has to truncate a file to free | ||
331 | * up space for the remove to proceed. | ||
332 | */ | ||
333 | int | ||
334 | xfs_truncate_file( | ||
335 | xfs_mount_t *mp, | ||
336 | xfs_inode_t *ip) | ||
337 | { | ||
338 | xfs_trans_t *tp; | ||
339 | int error; | ||
340 | |||
341 | #ifdef QUOTADEBUG | ||
342 | /* | ||
343 | * This is called to truncate the quotainodes too. | ||
344 | */ | ||
345 | if (XFS_IS_UQUOTA_ON(mp)) { | ||
346 | if (ip->i_ino != mp->m_sb.sb_uquotino) | ||
347 | ASSERT(ip->i_udquot); | ||
348 | } | ||
349 | if (XFS_IS_OQUOTA_ON(mp)) { | ||
350 | if (ip->i_ino != mp->m_sb.sb_gquotino) | ||
351 | ASSERT(ip->i_gdquot); | ||
352 | } | ||
353 | #endif | ||
354 | /* | ||
355 | * Make the call to xfs_itruncate_start before starting the | ||
356 | * transaction, because we cannot make the call while we're | ||
357 | * in a transaction. | ||
358 | */ | ||
359 | xfs_ilock(ip, XFS_IOLOCK_EXCL); | ||
360 | error = xfs_itruncate_start(ip, XFS_ITRUNC_DEFINITE, (xfs_fsize_t)0); | ||
361 | if (error) { | ||
362 | xfs_iunlock(ip, XFS_IOLOCK_EXCL); | ||
363 | return error; | ||
364 | } | ||
365 | |||
366 | tp = xfs_trans_alloc(mp, XFS_TRANS_TRUNCATE_FILE); | ||
367 | if ((error = xfs_trans_reserve(tp, 0, XFS_ITRUNCATE_LOG_RES(mp), 0, | ||
368 | XFS_TRANS_PERM_LOG_RES, | ||
369 | XFS_ITRUNCATE_LOG_COUNT))) { | ||
370 | xfs_trans_cancel(tp, 0); | ||
371 | xfs_iunlock(ip, XFS_IOLOCK_EXCL); | ||
372 | return error; | ||
373 | } | ||
374 | |||
375 | /* | ||
376 | * Follow the normal truncate locking protocol. Since we | ||
377 | * hold the inode in the transaction, we know that its number | ||
378 | * of references will stay constant. | ||
379 | */ | ||
380 | xfs_ilock(ip, XFS_ILOCK_EXCL); | ||
381 | xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); | ||
382 | xfs_trans_ihold(tp, ip); | ||
383 | /* | ||
384 | * Signal a sync xaction. The only case where that isn't | ||
385 | * the case is if we're truncating an already unlinked file | ||
386 | * on a wsync fs. In that case, we know the blocks can't | ||
387 | * reappear in the file because the links to file are | ||
388 | * permanently toast. Currently, we're always going to | ||
389 | * want a sync transaction because this code is being | ||
390 | * called from places where nlink is guaranteed to be 1 | ||
391 | * but I'm leaving the tests in to protect against future | ||
392 | * changes -- rcc. | ||
393 | */ | ||
394 | error = xfs_itruncate_finish(&tp, ip, (xfs_fsize_t)0, | ||
395 | XFS_DATA_FORK, | ||
396 | ((ip->i_d.di_nlink != 0 || | ||
397 | !(mp->m_flags & XFS_MOUNT_WSYNC)) | ||
398 | ? 1 : 0)); | ||
399 | if (error) { | ||
400 | xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | | ||
401 | XFS_TRANS_ABORT); | ||
402 | } else { | ||
403 | xfs_ichgtime(ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); | ||
404 | error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); | ||
405 | } | ||
406 | xfs_iunlock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); | ||
407 | |||
408 | return error; | ||
409 | } | ||