mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
xfs: reflink find shared should take a transaction
Adapt _reflink_find_shared to take an optional transaction pointer. The inode scrubber code will need to decide (within transaction context) if a file has shared blocks. To avoid buffer deadlocks, we must pass the tp through to this function's utility calls. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com>
This commit is contained in:
parent
378f681c4b
commit
92ff7285f1
3 changed files with 13 additions and 12 deletions
|
@ -455,8 +455,8 @@ xfs_getbmap_adjust_shared(
|
||||||
|
|
||||||
agno = XFS_FSB_TO_AGNO(mp, map->br_startblock);
|
agno = XFS_FSB_TO_AGNO(mp, map->br_startblock);
|
||||||
agbno = XFS_FSB_TO_AGBNO(mp, map->br_startblock);
|
agbno = XFS_FSB_TO_AGBNO(mp, map->br_startblock);
|
||||||
error = xfs_reflink_find_shared(mp, agno, agbno, map->br_blockcount,
|
error = xfs_reflink_find_shared(mp, NULL, agno, agbno,
|
||||||
&ebno, &elen, true);
|
map->br_blockcount, &ebno, &elen, true);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
|
|
|
@ -155,6 +155,7 @@
|
||||||
int
|
int
|
||||||
xfs_reflink_find_shared(
|
xfs_reflink_find_shared(
|
||||||
struct xfs_mount *mp,
|
struct xfs_mount *mp,
|
||||||
|
struct xfs_trans *tp,
|
||||||
xfs_agnumber_t agno,
|
xfs_agnumber_t agno,
|
||||||
xfs_agblock_t agbno,
|
xfs_agblock_t agbno,
|
||||||
xfs_extlen_t aglen,
|
xfs_extlen_t aglen,
|
||||||
|
@ -166,18 +167,18 @@ xfs_reflink_find_shared(
|
||||||
struct xfs_btree_cur *cur;
|
struct xfs_btree_cur *cur;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = xfs_alloc_read_agf(mp, NULL, agno, 0, &agbp);
|
error = xfs_alloc_read_agf(mp, tp, agno, 0, &agbp);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
cur = xfs_refcountbt_init_cursor(mp, NULL, agbp, agno, NULL);
|
cur = xfs_refcountbt_init_cursor(mp, tp, agbp, agno, NULL);
|
||||||
|
|
||||||
error = xfs_refcount_find_shared(cur, agbno, aglen, fbno, flen,
|
error = xfs_refcount_find_shared(cur, agbno, aglen, fbno, flen,
|
||||||
find_end_of_shared);
|
find_end_of_shared);
|
||||||
|
|
||||||
xfs_btree_del_cursor(cur, error ? XFS_BTREE_ERROR : XFS_BTREE_NOERROR);
|
xfs_btree_del_cursor(cur, error ? XFS_BTREE_ERROR : XFS_BTREE_NOERROR);
|
||||||
|
|
||||||
xfs_buf_relse(agbp);
|
xfs_trans_brelse(tp, agbp);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +218,7 @@ xfs_reflink_trim_around_shared(
|
||||||
agbno = XFS_FSB_TO_AGBNO(ip->i_mount, irec->br_startblock);
|
agbno = XFS_FSB_TO_AGBNO(ip->i_mount, irec->br_startblock);
|
||||||
aglen = irec->br_blockcount;
|
aglen = irec->br_blockcount;
|
||||||
|
|
||||||
error = xfs_reflink_find_shared(ip->i_mount, agno, agbno,
|
error = xfs_reflink_find_shared(ip->i_mount, NULL, agno, agbno,
|
||||||
aglen, &fbno, &flen, true);
|
aglen, &fbno, &flen, true);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
@ -1373,8 +1374,8 @@ xfs_reflink_dirty_extents(
|
||||||
agbno = XFS_FSB_TO_AGBNO(mp, map[1].br_startblock);
|
agbno = XFS_FSB_TO_AGBNO(mp, map[1].br_startblock);
|
||||||
aglen = map[1].br_blockcount;
|
aglen = map[1].br_blockcount;
|
||||||
|
|
||||||
error = xfs_reflink_find_shared(mp, agno, agbno, aglen,
|
error = xfs_reflink_find_shared(mp, NULL, agno, agbno,
|
||||||
&rbno, &rlen, true);
|
aglen, &rbno, &rlen, true);
|
||||||
if (error)
|
if (error)
|
||||||
goto out;
|
goto out;
|
||||||
if (rbno == NULLAGBLOCK)
|
if (rbno == NULLAGBLOCK)
|
||||||
|
@ -1445,7 +1446,7 @@ xfs_reflink_clear_inode_flag(
|
||||||
agbno = XFS_FSB_TO_AGBNO(mp, map.br_startblock);
|
agbno = XFS_FSB_TO_AGBNO(mp, map.br_startblock);
|
||||||
aglen = map.br_blockcount;
|
aglen = map.br_blockcount;
|
||||||
|
|
||||||
error = xfs_reflink_find_shared(mp, agno, agbno, aglen,
|
error = xfs_reflink_find_shared(mp, *tpp, agno, agbno, aglen,
|
||||||
&rbno, &rlen, false);
|
&rbno, &rlen, false);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
|
|
@ -20,9 +20,9 @@
|
||||||
#ifndef __XFS_REFLINK_H
|
#ifndef __XFS_REFLINK_H
|
||||||
#define __XFS_REFLINK_H 1
|
#define __XFS_REFLINK_H 1
|
||||||
|
|
||||||
extern int xfs_reflink_find_shared(struct xfs_mount *mp, xfs_agnumber_t agno,
|
extern int xfs_reflink_find_shared(struct xfs_mount *mp, struct xfs_trans *tp,
|
||||||
xfs_agblock_t agbno, xfs_extlen_t aglen, xfs_agblock_t *fbno,
|
xfs_agnumber_t agno, xfs_agblock_t agbno, xfs_extlen_t aglen,
|
||||||
xfs_extlen_t *flen, bool find_maximal);
|
xfs_agblock_t *fbno, xfs_extlen_t *flen, bool find_maximal);
|
||||||
extern int xfs_reflink_trim_around_shared(struct xfs_inode *ip,
|
extern int xfs_reflink_trim_around_shared(struct xfs_inode *ip,
|
||||||
struct xfs_bmbt_irec *irec, bool *shared, bool *trimmed);
|
struct xfs_bmbt_irec *irec, bool *shared, bool *trimmed);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue