Skip to contentSkip to conversation

xfs: mark speculative prealloc CoW fork extents unwritten

bug report Dan Carpenter 2 participants 2 messages Feb 13, 2017 – Feb 14, 2017

lore
Share & tools
lore
#0 lore raw

Hello Darrick J. Wong,

The patch 5eda43000064: "xfs: mark speculative prealloc CoW fork extents unwritten" from Feb 2, 2017, leads to the following static checker warning:

	fs/xfs/xfs_reflink.c:381 xfs_reflink_convert_cow()
	error: uninitialized symbol 'error'.

fs/xfs/xfs_reflink.c

   350  /* Convert all of the unwritten CoW extents in a file's range to real ones. */
   351  int
   352  xfs_reflink_convert_cow(
   353          struct xfs_inode        *ip,
   354          xfs_off_t               offset,
   355          xfs_off_t               count)
   356  {
   357          struct xfs_bmbt_irec    got;
   358          struct xfs_defer_ops    dfops;
   359          struct xfs_mount        *mp = ip->i_mount;
   360          struct xfs_ifork        *ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK);
   361          xfs_fileoff_t           offset_fsb = XFS_B_TO_FSBT(mp, offset);
   362          xfs_fileoff_t           end_fsb = XFS_B_TO_FSB(mp, offset + count);
   363          xfs_extnum_t            idx;
   364          bool                    found;
   365          int                     error;
                                        ^^^^^
   366  
   367          xfs_ilock(ip, XFS_ILOCK_EXCL);
   368  
   369          /* Convert all the extents to real from unwritten. */
   370          for (found = xfs_iext_lookup_extent(ip, ifp, offset_fsb, &idx, &got);
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

What if found fails on the first iteration through the loop?

   371               found && got.br_startoff < end_fsb;
   372               found = xfs_iext_get_extent(ifp, ++idx, &got)) {
   373                  error = xfs_reflink_convert_cow_extent(ip, &got, offset_fsb,
   374                                  end_fsb - offset_fsb, &dfops);
   375                  if (error)
   376                          break;
   377          }
   378  
   379          /* Finish up. */
   380          xfs_iunlock(ip, XFS_ILOCK_EXCL);
   381          return error;
                ^^^^^^^^^^^^
   382  }

regards,
dan carpenter

#1 lore raw
Quoted 33 lines · Dan Carpenter

Hello Darrick J. Wong,

The patch 5eda43000064: "xfs: mark speculative prealloc CoW fork extents unwritten" from Feb 2, 2017, leads to the following static checker warning:

	fs/xfs/xfs_reflink.c:381 xfs_reflink_convert_cow()
	error: uninitialized symbol 'error'.

fs/xfs/xfs_reflink.c

   350  /* Convert all of the unwritten CoW extents in a file's range to real ones. */
   351  int
   352  xfs_reflink_convert_cow(
   353          struct xfs_inode        *ip,
   354          xfs_off_t               offset,
   355          xfs_off_t               count)
   356  {
   357          struct xfs_bmbt_irec    got;
   358          struct xfs_defer_ops    dfops;
   359          struct xfs_mount        *mp = ip->i_mount;
   360          struct xfs_ifork        *ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK);
   361          xfs_fileoff_t           offset_fsb = XFS_B_TO_FSBT(mp, offset);
   362          xfs_fileoff_t           end_fsb = XFS_B_TO_FSB(mp, offset + count);
   363          xfs_extnum_t            idx;
   364          bool                    found;
   365          int                     error;
                                        ^^^^^
   366  
   367          xfs_ilock(ip, XFS_ILOCK_EXCL);
   368  
   369          /* Convert all the extents to real from unwritten. */
   370          for (found = xfs_iext_lookup_extent(ip, ifp, offset_fsb, &idx, &got);
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 1 line

What if found fails on the first iteration through the loop?

Oops, that's a bug, will send patch.

--D

Quoted 21 lines
   371               found && got.br_startoff < end_fsb;
   372               found = xfs_iext_get_extent(ifp, ++idx, &got)) {
   373                  error = xfs_reflink_convert_cow_extent(ip, &got, offset_fsb,
   374                                  end_fsb - offset_fsb, &dfops);
   375                  if (error)
   376                          break;
   377          }
   378  
   379          /* Finish up. */
   380          xfs_iunlock(ip, XFS_ILOCK_EXCL);
   381          return error;
                ^^^^^^^^^^^^
   382  }

regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html