[PATCH 05/11] xfs: optimise xfs_iext_destroy
Christoph Hellwig
hch at infradead.org
Wed Apr 13 11:45:11 CDT 2016
> /*
> + * Remove all records from the indirection array.
> + */
> +STATIC void
> +xfs_iext_irec_remove_all(
> + struct xfs_ifork *ifp)
> +{
> + int nlists;
> + int i;
> +
> + ASSERT(ifp->if_flags & XFS_IFEXTIREC);
> + nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ;
> + for (i = 0; i < nlists; i++) {
> + xfs_ext_irec_t *erp = &ifp->if_u1.if_ext_irec[i];
Can we avoid the typedef for new code?
> + if (erp->er_extbuf)
> + kmem_free(erp->er_extbuf);
no need to check for NULL before a kmem_free, e.g. this whole loop could
just be:
for (i = 0; i < nlists; i++)
kmem_free(ifp->if_u1.if_ext_irec[i].er_extbuf);
> {
> if (ifp->if_flags & XFS_IFEXTIREC) {
> - int erp_idx;
> - int nlists;
> -
> - nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ;
> - for (erp_idx = nlists - 1; erp_idx >= 0 ; erp_idx--) {
> - xfs_iext_irec_remove(ifp, erp_idx);
> - }
> + xfs_iext_irec_remove_all(ifp);
> ifp->if_flags &= ~XFS_IFEXTIREC;
I'd be tempted to just move clearing of the flag into
xfs_iext_irec_remove_all if we change the patch anyway.
Otherwise this looks fine to me.
More information about the xfs
mailing list