]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs: move extent zeroing to xfs_bmapi_allocate
authorChristoph Hellwig <hch@lst.de>
Thu, 16 Jan 2020 22:13:33 +0000 (17:13 -0500)
committerEric Sandeen <sandeen@redhat.com>
Thu, 16 Jan 2020 22:13:33 +0000 (17:13 -0500)
Source kernel commit: fd638f1de1f3f736ea4debb3582999ea95506e0a

Move the extent zeroing case there for the XFS_BMAPI_ZERO flag outside
the low-level allocator and into xfs_bmapi_allocate, where is still
is in transaction context, but outside the very lowlevel code where
it doesn't belong.

Signed-off-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>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_alloc.c
libxfs/xfs_alloc.h
libxfs/xfs_bmap.c

index a552e4d9e99fbe5de98813eefd59b1614cedeeb3..571a13624246f4770fda6331abf88a73031e6d4f 100644 (file)
@@ -3079,13 +3079,6 @@ xfs_alloc_vextent(
                        args->len);
 #endif
 
-               /* Zero the extent if we were asked to do so */
-               if (args->datatype & XFS_ALLOC_USERDATA_ZERO) {
-                       error = xfs_zero_extent(args->ip, args->fsbno, args->len);
-                       if (error)
-                               goto error0;
-               }
-
        }
        xfs_perag_put(args->pag);
        return 0;
index d6ed5d2c07c210446e999f9a99bfd2984abfffc1..626384d75c9c1186fa8036d71a870f50b8f92f23 100644 (file)
@@ -54,7 +54,6 @@ typedef struct xfs_alloc_arg {
        struct xfs_mount *mp;           /* file system mount point */
        struct xfs_buf  *agbp;          /* buffer for a.g. freelist header */
        struct xfs_perag *pag;          /* per-ag struct for this agno */
-       struct xfs_inode *ip;           /* for userdata zeroing method */
        xfs_fsblock_t   fsbno;          /* file system block number */
        xfs_agnumber_t  agno;           /* allocation group number */
        xfs_agblock_t   agbno;          /* allocation group-relative block # */
@@ -83,8 +82,7 @@ typedef struct xfs_alloc_arg {
  */
 #define XFS_ALLOC_USERDATA             (1 << 0)/* allocation is for user data*/
 #define XFS_ALLOC_INITIAL_USER_DATA    (1 << 1)/* special case start of file */
-#define XFS_ALLOC_USERDATA_ZERO                (1 << 2)/* zero extent on allocation */
-#define XFS_ALLOC_NOBUSY               (1 << 3)/* Busy extents not allowed */
+#define XFS_ALLOC_NOBUSY               (1 << 2)/* Busy extents not allowed */
 
 static inline bool
 xfs_alloc_is_userdata(int datatype)
index d1cfdbc65e76e7a4425ae97da87e87b96170f211..cfa2a4b8e08eb16752d7431eaed1edbb4c1907f1 100644 (file)
@@ -3510,8 +3510,6 @@ xfs_bmap_btalloc(
        args.wasdel = ap->wasdel;
        args.resv = XFS_AG_RESV_NONE;
        args.datatype = ap->datatype;
-       if (ap->datatype & XFS_ALLOC_USERDATA_ZERO)
-               args.ip = ap->ip;
 
        error = xfs_alloc_vextent(&args);
        if (error)
@@ -3966,8 +3964,6 @@ xfs_bmap_alloc_userdata(
         * the busy list.
         */
        bma->datatype = XFS_ALLOC_NOBUSY;
-       if (bma->flags & XFS_BMAPI_ZERO)
-               bma->datatype |= XFS_ALLOC_USERDATA_ZERO;
        if (whichfork == XFS_DATA_FORK) {
                if (bma->offset == 0)
                        bma->datatype |= XFS_ALLOC_INITIAL_USER_DATA;
@@ -4026,6 +4022,12 @@ xfs_bmapi_allocate(
        if (error || bma->blkno == NULLFSBLOCK)
                return error;
 
+       if (bma->flags & XFS_BMAPI_ZERO) {
+               error = xfs_zero_extent(bma->ip, bma->blkno, bma->length);
+               if (error)
+                       return error;
+       }
+
        if ((ifp->if_flags & XFS_IFBROOT) && !bma->cur)
                bma->cur = xfs_bmbt_init_cursor(mp, bma->tp, bma->ip, whichfork);
        /*