Message ID | 20250303180234.3305018-1-willy@infradead.org (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | xfs: Use abs_diff instead of XFS_ABSDIFF | expand |
On 3/3/25 12:02 PM, Matthew Wilcox (Oracle) wrote: > We have a central definition for this function since 2023, used by > a number of different parts of the kernel. > > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> <random list drive-by> ;) Looks good to me; XFS_ABSDIFF was added in 2005 or earlier, abs_diff got moved to math.h in 2023. Makes sense. kernel version has better type checking, too. Reviewed-by: Eric Sandeen <sandeen@redhat.com> > --- > fs/xfs/libxfs/xfs_alloc.c | 8 +++----- > 1 file changed, 3 insertions(+), 5 deletions(-) > > diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c > index 3d33e17f2e5c..7839efe050bf 100644 > --- a/fs/xfs/libxfs/xfs_alloc.c > +++ b/fs/xfs/libxfs/xfs_alloc.c > @@ -33,8 +33,6 @@ struct kmem_cache *xfs_extfree_item_cache; > > struct workqueue_struct *xfs_alloc_wq; > > -#define XFS_ABSDIFF(a,b) (((a) <= (b)) ? ((b) - (a)) : ((a) - (b))) > - > #define XFSA_FIXUP_BNO_OK 1 > #define XFSA_FIXUP_CNT_OK 2 > > @@ -410,8 +408,8 @@ xfs_alloc_compute_diff( > if (newbno1 != NULLAGBLOCK && newbno2 != NULLAGBLOCK) { > if (newlen1 < newlen2 || > (newlen1 == newlen2 && > - XFS_ABSDIFF(newbno1, wantbno) > > - XFS_ABSDIFF(newbno2, wantbno))) > + abs_diff(newbno1, wantbno) > > + abs_diff(newbno2, wantbno))) > newbno1 = newbno2; > } else if (newbno2 != NULLAGBLOCK) > newbno1 = newbno2; > @@ -427,7 +425,7 @@ xfs_alloc_compute_diff( > } else > newbno1 = freeend - wantlen; > *newbnop = newbno1; > - return newbno1 == NULLAGBLOCK ? 0 : XFS_ABSDIFF(newbno1, wantbno); > + return newbno1 == NULLAGBLOCK ? 0 : abs_diff(newbno1, wantbno); > } > > /*
On Mon, Mar 03, 2025 at 06:02:32PM +0000, Matthew Wilcox (Oracle) wrote: > We have a central definition for this function since 2023, used by > a number of different parts of the kernel. > > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Looks good to me. Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> > --- > fs/xfs/libxfs/xfs_alloc.c | 8 +++----- > 1 file changed, 3 insertions(+), 5 deletions(-) > > diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c > index 3d33e17f2e5c..7839efe050bf 100644 > --- a/fs/xfs/libxfs/xfs_alloc.c > +++ b/fs/xfs/libxfs/xfs_alloc.c > @@ -33,8 +33,6 @@ struct kmem_cache *xfs_extfree_item_cache; > > struct workqueue_struct *xfs_alloc_wq; > > -#define XFS_ABSDIFF(a,b) (((a) <= (b)) ? ((b) - (a)) : ((a) - (b))) > - > #define XFSA_FIXUP_BNO_OK 1 > #define XFSA_FIXUP_CNT_OK 2 > > @@ -410,8 +408,8 @@ xfs_alloc_compute_diff( > if (newbno1 != NULLAGBLOCK && newbno2 != NULLAGBLOCK) { > if (newlen1 < newlen2 || > (newlen1 == newlen2 && > - XFS_ABSDIFF(newbno1, wantbno) > > - XFS_ABSDIFF(newbno2, wantbno))) > + abs_diff(newbno1, wantbno) > > + abs_diff(newbno2, wantbno))) > newbno1 = newbno2; > } else if (newbno2 != NULLAGBLOCK) > newbno1 = newbno2; > @@ -427,7 +425,7 @@ xfs_alloc_compute_diff( > } else > newbno1 = freeend - wantlen; > *newbnop = newbno1; > - return newbno1 == NULLAGBLOCK ? 0 : XFS_ABSDIFF(newbno1, wantbno); > + return newbno1 == NULLAGBLOCK ? 0 : abs_diff(newbno1, wantbno); > } > > /* > -- > 2.47.2 > >
On Mon, 03 Mar 2025 18:02:32 +0000, Matthew Wilcox (Oracle) wrote: > We have a central definition for this function since 2023, used by > a number of different parts of the kernel. > > Applied to for-next, thanks! [1/1] xfs: Use abs_diff instead of XFS_ABSDIFF commit: 5d138b6fb4da63b46981bca744f8f262d2524281 Best regards,
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c index 3d33e17f2e5c..7839efe050bf 100644 --- a/fs/xfs/libxfs/xfs_alloc.c +++ b/fs/xfs/libxfs/xfs_alloc.c @@ -33,8 +33,6 @@ struct kmem_cache *xfs_extfree_item_cache; struct workqueue_struct *xfs_alloc_wq; -#define XFS_ABSDIFF(a,b) (((a) <= (b)) ? ((b) - (a)) : ((a) - (b))) - #define XFSA_FIXUP_BNO_OK 1 #define XFSA_FIXUP_CNT_OK 2 @@ -410,8 +408,8 @@ xfs_alloc_compute_diff( if (newbno1 != NULLAGBLOCK && newbno2 != NULLAGBLOCK) { if (newlen1 < newlen2 || (newlen1 == newlen2 && - XFS_ABSDIFF(newbno1, wantbno) > - XFS_ABSDIFF(newbno2, wantbno))) + abs_diff(newbno1, wantbno) > + abs_diff(newbno2, wantbno))) newbno1 = newbno2; } else if (newbno2 != NULLAGBLOCK) newbno1 = newbno2; @@ -427,7 +425,7 @@ xfs_alloc_compute_diff( } else newbno1 = freeend - wantlen; *newbnop = newbno1; - return newbno1 == NULLAGBLOCK ? 0 : XFS_ABSDIFF(newbno1, wantbno); + return newbno1 == NULLAGBLOCK ? 0 : abs_diff(newbno1, wantbno); } /*
We have a central definition for this function since 2023, used by a number of different parts of the kernel. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> --- fs/xfs/libxfs/xfs_alloc.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)