Re: [PATCH 1/1 linux-next] pnfs/flexfiles: use swap() in ff_layout_sort_mirrors()

From: Fabian Frederick
Date: Sun Jun 14 2015 - 01:23:27 EST




> On 12 June 2015 at 19:17 Joe Perches <joe@xxxxxxxxxxx> wrote:
>
>
> On Fri, 2015-06-12 at 18:58 +0200, Fabian Frederick wrote:
> > Use kernel.h macro definition.
>
> A lot of these conversions seem to be for bubble sorts.
> Maybe it'd be useful to add a generic one somewhere.

Of course but those swap() conversions already do some smooth cleanup.
btw it will be easier to find sort occurences and replace them if necessary.

Regards,
Fabian
>
> > diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c
> > b/fs/nfs/flexfilelayout/flexfilelayout.c
> []
> > @@ -182,17 +182,14 @@ static void _ff_layout_free_lseg(struct
> > nfs4_ff_layout_segment *fls)
>
> >Â static void ff_layout_sort_mirrors(struct nfs4_ff_layout_segment *fls)
> >Â {
> > -Â Âstruct nfs4_ff_layout_mirror *tmp;
> >Â Â Âint i, j;
>
> >Â Â Âfor (i = 0; i < fls->mirror_array_cnt - 1; i++) {
> >Â Â Â Â Â Â Âfor (j = i + 1; j < fls->mirror_array_cnt; j++)
> >Â Â Â Â Â Â Â Â Â Â Âif (fls->mirror_array[i]->efficiency <
> > -Â Â Â Â Â Â Â Â Â Â Â Âfls->mirror_array[j]->efficiency) {
> > -Â Â Â Â Â Â Â Â Â Â Â Â Â Âtmp = fls->mirror_array[i];
> > -Â Â Â Â Â Â Â Â Â Â Â Â Â Âfls->mirror_array[i] = fls->mirror_array[j];
> > -Â Â Â Â Â Â Â Â Â Â Â Â Â Âfls->mirror_array[j] = tmp;
> > -Â Â Â Â Â Â Â Â Â Â}
> > +Â Â Â Â Â Â Â Â Â Â Â Âfls->mirror_array[j]->efficiency)
> > +Â Â Â Â Â Â Â Â Â Â Â Â Â Âswap(fls->mirror_array[i],
> > +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â fls->mirror_array[j]);
> >Â Â Â}
> >Â }
>
>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/