aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_reflink.c
diff options
context:
space:
mode:
authorBrian Foster <bfoster@redhat.com>2018-07-12 01:26:19 -0400
committerDarrick J. Wong <darrick.wong@oracle.com>2018-07-12 01:26:19 -0400
commit3ae2d89174e4ba581093320afb48421ca95191d2 (patch)
tree84a579f1a9dbbf37004c960ae579e7faa725c4dc /fs/xfs/xfs_reflink.c
parentbcd2c9f33559764e0d306e226a8aa88bc2e1e6fb (diff)
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 'fs/xfs/xfs_reflink.c')
-rw-r--r--fs/xfs/xfs_reflink.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index bef780171962..b1bc2eb54a14 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -314,7 +314,6 @@ xfs_reflink_convert_cow_extent(
314 xfs_fileoff_t offset_fsb, 314 xfs_fileoff_t offset_fsb,
315 xfs_filblks_t count_fsb) 315 xfs_filblks_t count_fsb)
316{ 316{
317 xfs_fsblock_t first_block = NULLFSBLOCK;
318 int nimaps = 1; 317 int nimaps = 1;
319 318
320 if (imap->br_state == XFS_EXT_NORM) 319 if (imap->br_state == XFS_EXT_NORM)
@@ -325,8 +324,8 @@ xfs_reflink_convert_cow_extent(
325 if (imap->br_blockcount == 0) 324 if (imap->br_blockcount == 0)
326 return 0; 325 return 0;
327 return xfs_bmapi_write(NULL, ip, imap->br_startoff, imap->br_blockcount, 326 return xfs_bmapi_write(NULL, ip, imap->br_startoff, imap->br_blockcount,
328 XFS_BMAPI_COWFORK | XFS_BMAPI_CONVERT, &first_block, 327 XFS_BMAPI_COWFORK | XFS_BMAPI_CONVERT, NULL, 0, imap,
329 0, imap, &nimaps); 328 &nimaps);
330} 329}
331 330
332/* Convert all of the unwritten CoW extents in a file's range to real ones. */ 331/* Convert all of the unwritten CoW extents in a file's range to real ones. */
@@ -341,7 +340,6 @@ xfs_reflink_convert_cow(
341 xfs_fileoff_t end_fsb = XFS_B_TO_FSB(mp, offset + count); 340 xfs_fileoff_t end_fsb = XFS_B_TO_FSB(mp, offset + count);
342 xfs_filblks_t count_fsb = end_fsb - offset_fsb; 341 xfs_filblks_t count_fsb = end_fsb - offset_fsb;
343 struct xfs_bmbt_irec imap; 342 struct xfs_bmbt_irec imap;
344 xfs_fsblock_t first_block = NULLFSBLOCK;
345 int nimaps = 1, error = 0; 343 int nimaps = 1, error = 0;
346 344
347 ASSERT(count != 0); 345 ASSERT(count != 0);
@@ -349,8 +347,7 @@ xfs_reflink_convert_cow(
349 xfs_ilock(ip, XFS_ILOCK_EXCL); 347 xfs_ilock(ip, XFS_ILOCK_EXCL);
350 error = xfs_bmapi_write(NULL, ip, offset_fsb, count_fsb, 348 error = xfs_bmapi_write(NULL, ip, offset_fsb, count_fsb,
351 XFS_BMAPI_COWFORK | XFS_BMAPI_CONVERT | 349 XFS_BMAPI_COWFORK | XFS_BMAPI_CONVERT |
352 XFS_BMAPI_CONVERT_ONLY, &first_block, 0, &imap, 350 XFS_BMAPI_CONVERT_ONLY, NULL, 0, &imap, &nimaps);
353 &nimaps);
354 xfs_iunlock(ip, XFS_ILOCK_EXCL); 351 xfs_iunlock(ip, XFS_ILOCK_EXCL);
355 return error; 352 return error;
356} 353}