Skip to content

Commit 3d4d961

Browse files
Christoph Hellwiggregkh
authored andcommitted
xfs: return the allocated transaction from xfs_trans_alloc_empty
[ Upstream commit d8e1ea4 ] xfs_trans_alloc_empty can't return errors, so return the allocated transaction directly instead of an output double pointer argument. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org> Stable-dep-of: d284551 ("xfs: fully decouple XFS_IBULK* flags from XFS_IWALK* flags") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 69dbbfe commit 3d4d961

File tree

17 files changed

+31
-99
lines changed

17 files changed

+31
-99
lines changed

fs/xfs/libxfs/xfs_refcount.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2099,9 +2099,7 @@ xfs_refcount_recover_cow_leftovers(
20992099
* recording the CoW debris we cancel the (empty) transaction
21002100
* and everything goes away cleanly.
21012101
*/
2102-
error = xfs_trans_alloc_empty(mp, &tp);
2103-
if (error)
2104-
return error;
2102+
tp = xfs_trans_alloc_empty(mp);
21052103

21062104
if (isrt) {
21072105
xfs_rtgroup_lock(to_rtg(xg), XFS_RTGLOCK_REFCOUNT);

fs/xfs/scrub/common.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,8 @@ int
870870
xchk_trans_alloc_empty(
871871
struct xfs_scrub *sc)
872872
{
873-
return xfs_trans_alloc_empty(sc->mp, &sc->tp);
873+
sc->tp = xfs_trans_alloc_empty(sc->mp);
874+
return 0;
874875
}
875876

876877
/*

fs/xfs/scrub/repair.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,18 +1279,10 @@ xrep_trans_alloc_hook_dummy(
12791279
void **cookiep,
12801280
struct xfs_trans **tpp)
12811281
{
1282-
int error;
1283-
12841282
*cookiep = current->journal_info;
12851283
current->journal_info = NULL;
1286-
1287-
error = xfs_trans_alloc_empty(mp, tpp);
1288-
if (!error)
1289-
return 0;
1290-
1291-
current->journal_info = *cookiep;
1292-
*cookiep = NULL;
1293-
return error;
1284+
*tpp = xfs_trans_alloc_empty(mp);
1285+
return 0;
12941286
}
12951287

12961288
/* Cancel a dummy transaction used by a live update hook function. */

fs/xfs/scrub/scrub.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -876,10 +876,7 @@ xchk_scrubv_open_by_handle(
876876
struct xfs_inode *ip;
877877
int error;
878878

879-
error = xfs_trans_alloc_empty(mp, &tp);
880-
if (error)
881-
return NULL;
882-
879+
tp = xfs_trans_alloc_empty(mp);
883880
error = xfs_iget(mp, tp, head->svh_ino, XCHK_IGET_FLAGS, 0, &ip);
884881
xfs_trans_cancel(tp);
885882
if (error)

fs/xfs/xfs_attr_item.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -616,10 +616,7 @@ xfs_attri_iread_extents(
616616
struct xfs_trans *tp;
617617
int error;
618618

619-
error = xfs_trans_alloc_empty(ip->i_mount, &tp);
620-
if (error)
621-
return error;
622-
619+
tp = xfs_trans_alloc_empty(ip->i_mount);
623620
xfs_ilock(ip, XFS_ILOCK_EXCL);
624621
error = xfs_iread_extents(tp, ip, XFS_ATTR_FORK);
625622
xfs_iunlock(ip, XFS_ILOCK_EXCL);

fs/xfs/xfs_discard.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,7 @@ xfs_trim_gather_extents(
189189
*/
190190
xfs_log_force(mp, XFS_LOG_SYNC);
191191

192-
error = xfs_trans_alloc_empty(mp, &tp);
193-
if (error)
194-
return error;
192+
tp = xfs_trans_alloc_empty(mp);
195193

196194
error = xfs_alloc_read_agf(pag, tp, 0, &agbp);
197195
if (error)
@@ -583,9 +581,7 @@ xfs_trim_rtextents(
583581
struct xfs_trans *tp;
584582
int error;
585583

586-
error = xfs_trans_alloc_empty(mp, &tp);
587-
if (error)
588-
return error;
584+
tp = xfs_trans_alloc_empty(mp);
589585

590586
/*
591587
* Walk the free ranges between low and high. The query_range function
@@ -701,9 +697,7 @@ xfs_trim_rtgroup_extents(
701697
struct xfs_trans *tp;
702698
int error;
703699

704-
error = xfs_trans_alloc_empty(mp, &tp);
705-
if (error)
706-
return error;
700+
tp = xfs_trans_alloc_empty(mp);
707701

708702
/*
709703
* Walk the free ranges between low and high. The query_range function

fs/xfs/xfs_fsmap.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,9 +1270,7 @@ xfs_getfsmap(
12701270
* buffer locking abilities to detect cycles in the rmapbt
12711271
* without deadlocking.
12721272
*/
1273-
error = xfs_trans_alloc_empty(mp, &tp);
1274-
if (error)
1275-
break;
1273+
tp = xfs_trans_alloc_empty(mp);
12761274

12771275
info.dev = handlers[i].dev;
12781276
info.last = false;

fs/xfs/xfs_icache.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -893,10 +893,7 @@ xfs_metafile_iget(
893893
struct xfs_trans *tp;
894894
int error;
895895

896-
error = xfs_trans_alloc_empty(mp, &tp);
897-
if (error)
898-
return error;
899-
896+
tp = xfs_trans_alloc_empty(mp);
900897
error = xfs_trans_metafile_iget(tp, ino, metafile_type, ipp);
901898
xfs_trans_cancel(tp);
902899
return error;

fs/xfs/xfs_inode.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2932,12 +2932,9 @@ xfs_inode_reload_unlinked(
29322932
struct xfs_inode *ip)
29332933
{
29342934
struct xfs_trans *tp;
2935-
int error;
2936-
2937-
error = xfs_trans_alloc_empty(ip->i_mount, &tp);
2938-
if (error)
2939-
return error;
2935+
int error = 0;
29402936

2937+
tp = xfs_trans_alloc_empty(ip->i_mount);
29412938
xfs_ilock(ip, XFS_ILOCK_SHARED);
29422939
if (xfs_inode_unlinked_incomplete(ip))
29432940
error = xfs_inode_reload_unlinked_bucket(tp, ip);

fs/xfs/xfs_itable.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,10 @@ xfs_bulkstat_one(
239239
* Grab an empty transaction so that we can use its recursive buffer
240240
* locking abilities to detect cycles in the inobt without deadlocking.
241241
*/
242-
error = xfs_trans_alloc_empty(breq->mp, &tp);
243-
if (error)
244-
goto out;
245-
242+
tp = xfs_trans_alloc_empty(breq->mp);
246243
error = xfs_bulkstat_one_int(breq->mp, breq->idmap, tp,
247244
breq->startino, &bc);
248245
xfs_trans_cancel(tp);
249-
out:
250246
kfree(bc.buf);
251247

252248
/*
@@ -331,17 +327,13 @@ xfs_bulkstat(
331327
* Grab an empty transaction so that we can use its recursive buffer
332328
* locking abilities to detect cycles in the inobt without deadlocking.
333329
*/
334-
error = xfs_trans_alloc_empty(breq->mp, &tp);
335-
if (error)
336-
goto out;
337-
330+
tp = xfs_trans_alloc_empty(breq->mp);
338331
if (breq->flags & XFS_IBULK_SAME_AG)
339332
iwalk_flags |= XFS_IWALK_SAME_AG;
340333

341334
error = xfs_iwalk(breq->mp, tp, breq->startino, iwalk_flags,
342335
xfs_bulkstat_iwalk, breq->icount, &bc);
343336
xfs_trans_cancel(tp);
344-
out:
345337
kfree(bc.buf);
346338

347339
/*
@@ -464,14 +456,10 @@ xfs_inumbers(
464456
* Grab an empty transaction so that we can use its recursive buffer
465457
* locking abilities to detect cycles in the inobt without deadlocking.
466458
*/
467-
error = xfs_trans_alloc_empty(breq->mp, &tp);
468-
if (error)
469-
goto out;
470-
459+
tp = xfs_trans_alloc_empty(breq->mp);
471460
error = xfs_inobt_walk(breq->mp, tp, breq->startino, breq->flags,
472461
xfs_inumbers_walk, breq->icount, &ic);
473462
xfs_trans_cancel(tp);
474-
out:
475463

476464
/*
477465
* We found some inode groups, so clear the error status and return

0 commit comments

Comments
 (0)