aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/libxfs/xfs_bmap.c
diff options
context:
space:
mode:
authorBrian Foster <bfoster@redhat.com>2018-07-11 22:26:19 -0700
committerDarrick J. Wong <darrick.wong@oracle.com>2018-07-11 22:26:19 -0700
commit3ae2d89174e4ba581093320afb48421ca95191d2 (patch)
tree84a579f1a9dbbf37004c960ae579e7faa725c4dc /fs/xfs/libxfs/xfs_bmap.c
parentxfs: refactor dfops init to attach to transaction (diff)
downloadlinux-dev-3ae2d89174e4ba581093320afb48421ca95191d2.tar.xz
linux-dev-3ae2d89174e4ba581093320afb48421ca95191d2.zip
xfs: allow null firstblock in xfs_bmapi_write() when tp is null
xfs_bmapi_write() always expects a valid firstblock pointer. It immediately dereferences the pointer to help determine how to initialize the bma.minleft field. The remaining accesses are related to modifying btree format forks, which is only relevant for !COW fork callers. The reflink code passes a NULL transaction to xfs_bmapi_write() in a couple places that do COW fork unwritten conversion. The purpose of the firstblock field is to track the first block allocation in the current transaction, so technically firstblock should not be required for these callers either. Tweak xfs_bmapi_write() to initialize the bma correctly without accessing the firstblock pointer if no transaction is provided in the first place. Update the reflink callers to pass NULL instead of otherwise unused firstblock references. Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to '')
-rw-r--r--fs/xfs/libxfs/xfs_bmap.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index dfff840c79f9..0b476a8e751c 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -4302,7 +4302,7 @@ xfs_bmapi_write(
XFS_STATS_INC(mp, xs_blk_mapw);
- if (*firstblock == NULLFSBLOCK) {
+ if (!tp || *firstblock == NULLFSBLOCK) {
if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE)
bma.minleft = be16_to_cpu(ifp->if_broot->bb_level) + 1;
else