bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 08/11] libdiskfs: add diskfs_make_node_alloc to allocate fat


From: Samuel Thibault
Subject: Re: [PATCH 08/11] libdiskfs: add diskfs_make_node_alloc to allocate fat nodes
Date: Fri, 23 May 2014 00:36:48 +0200
User-agent: Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30)

Samuel Thibault, le Fri 23 May 2014 00:28:41 +0200, a écrit :
> Justus Winter, le Thu 22 May 2014 22:13:30 +0200, a écrit :
> > libdiskfs has two kind of nodes, struct node and struct netnode.
> > struct node is used to store libdiskfs specific data, while struct
> > netnode contains user supplied data.  Previously, both objects were
> > allocated separatly, and a pointer from the node to the netnode
> > provided a mapping from the former to the latter.
> > 
> > Provide a function diskfs_make_node_alloc that allocates both nodes in
> > a contiguous region.
> > 
> > This reduces the memory allocation overhead when creating nodes.  It
> > also makes the relation between node and netnode a simple offset
> > calculation.  Provide two functions to compute the netnode address
> > from the node address and vice-versa.
> > 
> > Most notably, this makes implementing a cache on top of libdiskfs
> > easier.  Auxiliary data for the cache can be stored in the
> > user-defined netnode, and the fat node can be used as the value.
> 
> Ack!

Oops, no, wait, just one thing.

> > +/* Return the address of the disknode for NODE.  NODE must have been
> > +   allocated using diskfs_make_node_alloc.  */
> > +static inline struct disknode *
> > +diskfs_node_disknode (struct node *node)
> > +{
> > +  return (struct disknode *) ((char *) node + sizeof (struct node));
> > +}
> > +
> > +/* Return the address of the node for DISKNODE.  DISKNODE must have
> > +   been allocated using diskfs_make_node_alloc.  */
> > +static inline struct node *
> > +diskfs_disknode_node (struct disknode *disknode)
> > +{
> > +  return (struct node *) ((char *) disknode - sizeof (struct node));
> > +}

Making them inlines means that any user of libdiskfs has to be
recompiled whenever we add a field to struct node.  I understand that
inlining these is an important part of the optimization, but we'll
possibly extend struct node sooner or later. One way to keep them inline
would be to have an external variable which contains sizeof(struct
node).

Samuel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]