Re: [RFC] Directory index for Ext2 - the pagecache version

From: Alexander Viro (viro@math.psu.edu)
Date: Fri Mar 09 2001 - 22:45:00 EST

  • Next message: Justin T. Gibbs: "Version 6.1.6 of the aic7xxx driver availalbe"

    On Fri, 9 Mar 2001, Daniel Phillips wrote:

    > Why does read_cache_page unlock the page just before returning? I'd

    Because it may find the thing in cache. Uptodate and unlocked. Since you
    want the same result on all ways out of the function, you get to unlock
    the thing if you had locked it - just to match the fast path.

            I have one serious problem with the patch: maybe_lock_page().
    I can understand why you might want to wait on page, I can understand
    why you might want to lock page2 iff page2 != page1, but...

            Aside of that - several bad problems with the style.

    > +#ifndef COMBSORT
    > +#define COMBSORT(size, i, j, COMPARE, EXCHANGE) { \
    > + unsigned gap = size, more, i; \
    > + do { \
    > + if (gap > 1) gap = gap*10/13; \
    > + if (gap - 9 < 2) gap = 11; \
    > + for (i = size - 1, more = gap > 1; i >= gap; i--) { \
    > + int j = i - gap; \
    > + if (COMPARE) { EXCHANGE; more = 1; } } \
    > + } while (more); }
    > +#endif

    Don't. Do. That. C is not Algol 60. Please, cut down on preprocessor
    abuse. I'm quite serious - you are using the thing once, so there is
    no possible reason to write it that way. It's not cute, it's really,
    really ugly. Make it an inline function if you think that it's
    critical to keep it in-line, but for $DEITY sake, make it a C function.

    > +#ifndef exchange
    > +#define exchange(x, y) do { typeof(x) z = x; x = y; y = z; } while (0)
    > +#endif

    Ditto. I would simply kill this one off.

    > +#define dx_hash(s,n) (dx_hack_hash(s,n) << 1)

    Ugh. And the point of that would be? I.e. why not shift in the
    function itself?

            OK, I'll go and do incremental over my variant and do some
    tweaking on my side. Then I'll put both on ftp. I _really_ don't
    like the maybe_{un,}lock_page() logics. I'll try to come up
    with cleaner variant, but I think that you are trying to use the
    same function in situations of really different nature.
            Off to diffing the thing...
                                                    Cheers,
                                                            Al

    PS: Call me a style fascist, but _please_ get rid of preprocessor
    abuse. Code should be readable. Especially in the core kernel
    and frequently used filesystems.

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/



    This archive was generated by hypermail 2b29 : Fri Mar 09 2001 - 22:50:54 EST