@@ -3510,6 +3510,48 @@ xfs_bmap_compute_alignments(
35103510 return stripe_align ;
35113511}
35123512
3513+ static void
3514+ xfs_bmap_process_allocated_extent (
3515+ struct xfs_bmalloca * ap ,
3516+ struct xfs_alloc_arg * args ,
3517+ xfs_fileoff_t orig_offset ,
3518+ xfs_extlen_t orig_length )
3519+ {
3520+ int nullfb ;
3521+
3522+ nullfb = ap -> tp -> t_firstblock == NULLFSBLOCK ;
3523+
3524+ /*
3525+ * check the allocation happened at the same or higher AG than
3526+ * the first block that was allocated.
3527+ */
3528+ ASSERT (nullfb ||
3529+ XFS_FSB_TO_AGNO (args -> mp , ap -> tp -> t_firstblock ) <=
3530+ XFS_FSB_TO_AGNO (args -> mp , args -> fsbno ));
3531+
3532+ ap -> blkno = args -> fsbno ;
3533+ if (nullfb )
3534+ ap -> tp -> t_firstblock = args -> fsbno ;
3535+ ap -> length = args -> len ;
3536+ /*
3537+ * If the extent size hint is active, we tried to round the
3538+ * caller's allocation request offset down to extsz and the
3539+ * length up to another extsz boundary. If we found a free
3540+ * extent we mapped it in starting at this new offset. If the
3541+ * newly mapped space isn't long enough to cover any of the
3542+ * range of offsets that was originally requested, move the
3543+ * mapping up so that we can fill as much of the caller's
3544+ * original request as possible. Free space is apparently
3545+ * very fragmented so we're unlikely to be able to satisfy the
3546+ * hints anyway.
3547+ */
3548+ if (ap -> length <= orig_length )
3549+ ap -> offset = orig_offset ;
3550+ else if (ap -> offset + ap -> length < orig_offset + orig_length )
3551+ ap -> offset = orig_offset + orig_length - ap -> length ;
3552+ xfs_bmap_btalloc_accounting (ap , args );
3553+ }
3554+
35133555STATIC int
35143556xfs_bmap_btalloc (
35153557 struct xfs_bmalloca * ap ) /* bmap alloc argument struct */
@@ -3702,36 +3744,10 @@ xfs_bmap_btalloc(
37023744 return error ;
37033745 ap -> tp -> t_flags |= XFS_TRANS_LOWMODE ;
37043746 }
3747+
37053748 if (args .fsbno != NULLFSBLOCK ) {
3706- /*
3707- * check the allocation happened at the same or higher AG than
3708- * the first block that was allocated.
3709- */
3710- ASSERT (ap -> tp -> t_firstblock == NULLFSBLOCK ||
3711- XFS_FSB_TO_AGNO (mp , ap -> tp -> t_firstblock ) <=
3712- XFS_FSB_TO_AGNO (mp , args .fsbno ));
3713-
3714- ap -> blkno = args .fsbno ;
3715- if (ap -> tp -> t_firstblock == NULLFSBLOCK )
3716- ap -> tp -> t_firstblock = args .fsbno ;
3717- ap -> length = args .len ;
3718- /*
3719- * If the extent size hint is active, we tried to round the
3720- * caller's allocation request offset down to extsz and the
3721- * length up to another extsz boundary. If we found a free
3722- * extent we mapped it in starting at this new offset. If the
3723- * newly mapped space isn't long enough to cover any of the
3724- * range of offsets that was originally requested, move the
3725- * mapping up so that we can fill as much of the caller's
3726- * original request as possible. Free space is apparently
3727- * very fragmented so we're unlikely to be able to satisfy the
3728- * hints anyway.
3729- */
3730- if (ap -> length <= orig_length )
3731- ap -> offset = orig_offset ;
3732- else if (ap -> offset + ap -> length < orig_offset + orig_length )
3733- ap -> offset = orig_offset + orig_length - ap -> length ;
3734- xfs_bmap_btalloc_accounting (ap , & args );
3749+ xfs_bmap_process_allocated_extent (ap , & args , orig_offset ,
3750+ orig_length );
37353751 } else {
37363752 ap -> blkno = NULLFSBLOCK ;
37373753 ap -> length = 0 ;
0 commit comments