Re: [PATCH] PAG support only

From: Muli Ben-Yehuda (mulix@mulix.org)
Date: Wed May 14 2003 - 07:35:24 EST


On Wed, May 14, 2003 at 10:54:36AM +0100, David Howells wrote:
>
> Muli Ben-Yehuda wrote:
>
> > > + * VFS session authentication token cache
> > ...
> >
> > If you know the type of the data, why keep it all in one binary blob,
> > instead of a struct? cache effects?
>
> No. We _don't_ know the type of the data. A filesystem entrusts us with a
> token to keep in the PAG on its behalf. However, since this is meant to be a
> generic mechanism, it's entirely dependent on the fs as to what's in
> the blob.

But you do know the type of the data in the blob... it's char* fsname,
const void* key and const void* data, according to your code.

You do

void* blob = kmalloc(fsname size + key size + data size)

memcpy(blob, fsname, fsname size)
memcpy(blob + fsname offset, key, key size)
mempcy(blob + fsname offset + key offset, data, data size)

I suggest

struct fsblob {
       const char* fsname;
       const void* key;
       size_t keysize;
       const void* data;
       size_t datasize;
};

struct fsblob b;

b->fsname = kmalloc(fsname size)
memcpy(b->fsname, fsname, fsname size)

etc.

Your method loses on additional complexity, and wins on
speed. However, unless it's really, really speed sensitive code, I
would go for KISS any day.

> > Nothing in this patch appears to be using it. You aren't taking a
> > reference to the token here, what's protecting it from disappearing
> > after the return and before the caller gets a chance to do something
> > with it?
>
> Thanks. Fixed.

My pleasure.

-- 
Muli Ben-Yehuda
http://www.mulix.org


- 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 : Thu May 15 2003 - 22:00:51 EST