Skip to content

Commit cc3c92e

Browse files
Christoph HellwigChandan Babu R
authored andcommitted
xfs: xfs_quota_unreserve_blkres can't fail
Unreserving quotas can't fail due to quota limits, and we'll notice a shut down file system a bit later in all the callers anyway. Return void and remove the error checking and propagation in the callers. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: "Darrick J. Wong" <[email protected]> Signed-off-by: Chandan Babu R <[email protected]>
1 parent f7b9ee7 commit cc3c92e

File tree

8 files changed

+20
-37
lines changed

8 files changed

+20
-37
lines changed

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4928,7 +4928,7 @@ xfs_bmap_split_indlen(
49284928
*indlen2 = len2;
49294929
}
49304930

4931-
int
4931+
void
49324932
xfs_bmap_del_extent_delay(
49334933
struct xfs_inode *ip,
49344934
int whichfork,
@@ -4944,7 +4944,6 @@ xfs_bmap_del_extent_delay(
49444944
xfs_filblks_t got_indlen, new_indlen, stolen = 0;
49454945
uint32_t state = xfs_bmap_fork_to_state(whichfork);
49464946
uint64_t fdblocks;
4947-
int error = 0;
49484947
bool isrt;
49494948

49504949
XFS_STATS_INC(mp, xs_del_exlist);
@@ -4964,9 +4963,7 @@ xfs_bmap_del_extent_delay(
49644963
* sb counters as we might have to borrow some blocks for the
49654964
* indirect block accounting.
49664965
*/
4967-
error = xfs_quota_unreserve_blkres(ip, del->br_blockcount);
4968-
if (error)
4969-
return error;
4966+
xfs_quota_unreserve_blkres(ip, del->br_blockcount);
49704967
ip->i_delayed_blks -= del->br_blockcount;
49714968

49724969
if (got->br_startoff == del->br_startoff)
@@ -5064,7 +5061,6 @@ xfs_bmap_del_extent_delay(
50645061

50655062
xfs_add_fdblocks(mp, fdblocks);
50665063
xfs_mod_delalloc(ip, -(int64_t)del->br_blockcount, -da_diff);
5067-
return error;
50685064
}
50695065

50705066
void
@@ -5622,18 +5618,16 @@ __xfs_bunmapi(
56225618

56235619
delete:
56245620
if (wasdel) {
5625-
error = xfs_bmap_del_extent_delay(ip, whichfork, &icur,
5626-
&got, &del);
5621+
xfs_bmap_del_extent_delay(ip, whichfork, &icur, &got, &del);
56275622
} else {
56285623
error = xfs_bmap_del_extent_real(ip, tp, &icur, cur,
56295624
&del, &tmp_logflags, whichfork,
56305625
flags);
56315626
logflags |= tmp_logflags;
5627+
if (error)
5628+
goto error0;
56325629
}
56335630

5634-
if (error)
5635-
goto error0;
5636-
56375631
end = del.br_startoff - 1;
56385632
nodelete:
56395633
/*

fs/xfs/libxfs/xfs_bmap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ int xfs_bmapi_write(struct xfs_trans *tp, struct xfs_inode *ip,
202202
int xfs_bunmapi(struct xfs_trans *tp, struct xfs_inode *ip,
203203
xfs_fileoff_t bno, xfs_filblks_t len, uint32_t flags,
204204
xfs_extnum_t nexts, int *done);
205-
int xfs_bmap_del_extent_delay(struct xfs_inode *ip, int whichfork,
205+
void xfs_bmap_del_extent_delay(struct xfs_inode *ip, int whichfork,
206206
struct xfs_iext_cursor *cur, struct xfs_bmbt_irec *got,
207207
struct xfs_bmbt_irec *del);
208208
void xfs_bmap_del_extent_cow(struct xfs_inode *ip,

fs/xfs/xfs_aops.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,6 @@ xfs_discard_folio(
443443
{
444444
struct xfs_inode *ip = XFS_I(folio->mapping->host);
445445
struct xfs_mount *mp = ip->i_mount;
446-
int error;
447446

448447
if (xfs_is_shutdown(mp))
449448
return;
@@ -457,11 +456,8 @@ xfs_discard_folio(
457456
* byte of the next folio. Hence the end offset is only dependent on the
458457
* folio itself and not the start offset that is passed in.
459458
*/
460-
error = xfs_bmap_punch_delalloc_range(ip, pos,
459+
xfs_bmap_punch_delalloc_range(ip, pos,
461460
folio_pos(folio) + folio_size(folio));
462-
463-
if (error && !xfs_is_shutdown(mp))
464-
xfs_alert(mp, "page discard unable to remove delalloc mapping.");
465461
}
466462

467463
static const struct iomap_writeback_ops xfs_writeback_ops = {

fs/xfs/xfs_bmap_util.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ xfs_getbmap(
440440
* if the ranges only partially overlap them, so it is up to the caller to
441441
* ensure that partial blocks are not passed in.
442442
*/
443-
int
443+
void
444444
xfs_bmap_punch_delalloc_range(
445445
struct xfs_inode *ip,
446446
xfs_off_t start_byte,
@@ -452,7 +452,6 @@ xfs_bmap_punch_delalloc_range(
452452
xfs_fileoff_t end_fsb = XFS_B_TO_FSB(mp, end_byte);
453453
struct xfs_bmbt_irec got, del;
454454
struct xfs_iext_cursor icur;
455-
int error = 0;
456455

457456
ASSERT(!xfs_need_iread_extents(ifp));
458457

@@ -476,15 +475,13 @@ xfs_bmap_punch_delalloc_range(
476475
continue;
477476
}
478477

479-
error = xfs_bmap_del_extent_delay(ip, XFS_DATA_FORK, &icur,
480-
&got, &del);
481-
if (error || !xfs_iext_get_extent(ifp, &icur, &got))
478+
xfs_bmap_del_extent_delay(ip, XFS_DATA_FORK, &icur, &got, &del);
479+
if (!xfs_iext_get_extent(ifp, &icur, &got))
482480
break;
483481
}
484482

485483
out_unlock:
486484
xfs_iunlock(ip, XFS_ILOCK_EXCL);
487-
return error;
488485
}
489486

490487
/*

fs/xfs/xfs_bmap_util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ xfs_bmap_rtalloc(struct xfs_bmalloca *ap)
3030
}
3131
#endif /* CONFIG_XFS_RT */
3232

33-
int xfs_bmap_punch_delalloc_range(struct xfs_inode *ip,
33+
void xfs_bmap_punch_delalloc_range(struct xfs_inode *ip,
3434
xfs_off_t start_byte, xfs_off_t end_byte);
3535

3636
struct kgetbmap {

fs/xfs/xfs_iomap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,8 +1232,8 @@ xfs_buffered_write_delalloc_punch(
12321232
loff_t offset,
12331233
loff_t length)
12341234
{
1235-
return xfs_bmap_punch_delalloc_range(XFS_I(inode), offset,
1236-
offset + length);
1235+
xfs_bmap_punch_delalloc_range(XFS_I(inode), offset, offset + length);
1236+
return 0;
12371237
}
12381238

12391239
static int

fs/xfs/xfs_quota.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,11 @@ xfs_quota_reserve_blkres(struct xfs_inode *ip, int64_t blocks)
215215
return xfs_trans_reserve_quota_nblks(NULL, ip, blocks, 0, false);
216216
}
217217

218-
static inline int
219-
xfs_quota_unreserve_blkres(struct xfs_inode *ip, int64_t blocks)
218+
static inline void
219+
xfs_quota_unreserve_blkres(struct xfs_inode *ip, uint64_t blocks)
220220
{
221-
return xfs_quota_reserve_blkres(ip, -blocks);
221+
/* don't return an error as unreserving quotas can't fail */
222+
xfs_quota_reserve_blkres(ip, -(int64_t)blocks);
222223
}
223224

224225
extern int xfs_mount_reset_sbqflags(struct xfs_mount *);

fs/xfs/xfs_reflink.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -592,10 +592,8 @@ xfs_reflink_cancel_cow_blocks(
592592
trace_xfs_reflink_cancel_cow(ip, &del);
593593

594594
if (isnullstartblock(del.br_startblock)) {
595-
error = xfs_bmap_del_extent_delay(ip, XFS_COW_FORK,
596-
&icur, &got, &del);
597-
if (error)
598-
break;
595+
xfs_bmap_del_extent_delay(ip, XFS_COW_FORK, &icur, &got,
596+
&del);
599597
} else if (del.br_state == XFS_EXT_UNWRITTEN || cancel_real) {
600598
ASSERT((*tpp)->t_highest_agno == NULLAGNUMBER);
601599

@@ -618,10 +616,7 @@ xfs_reflink_cancel_cow_blocks(
618616
xfs_bmap_del_extent_cow(ip, &icur, &got, &del);
619617

620618
/* Remove the quota reservation */
621-
error = xfs_quota_unreserve_blkres(ip,
622-
del.br_blockcount);
623-
if (error)
624-
break;
619+
xfs_quota_unreserve_blkres(ip, del.br_blockcount);
625620
} else {
626621
/* Didn't do anything, push cursor back. */
627622
xfs_iext_prev(ifp, &icur);

0 commit comments

Comments
 (0)