summaryrefslogtreecommitdiff
path: root/debian/patches/0001-libdiskfs-add-diskfs_make_node_alloc-to-allocate-fat.patch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches/0001-libdiskfs-add-diskfs_make_node_alloc-to-allocate-fat.patch')
-rw-r--r--debian/patches/0001-libdiskfs-add-diskfs_make_node_alloc-to-allocate-fat.patch141
1 files changed, 141 insertions, 0 deletions
diff --git a/debian/patches/0001-libdiskfs-add-diskfs_make_node_alloc-to-allocate-fat.patch b/debian/patches/0001-libdiskfs-add-diskfs_make_node_alloc-to-allocate-fat.patch
new file mode 100644
index 00000000..e4e7179f
--- /dev/null
+++ b/debian/patches/0001-libdiskfs-add-diskfs_make_node_alloc-to-allocate-fat.patch
@@ -0,0 +1,141 @@
+From dbe60bff776af39833b50cf6ead4ac0f58805fda Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Fri, 16 May 2014 23:06:33 +0200
+Subject: [PATCH 01/27] libdiskfs: add diskfs_make_node_alloc to allocate fat
+ nodes
+
+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.
+
+* libdiskfs/node-make.c (init_node): Move initialization here.
+(diskfs_make_node): Use init_node.
+(diskfs_make_node_alloc): New function to allocate fat nodes.
+* libdiskfs/diskfs.h (diskfs_make_node_alloc): New declaration.
+(diskfs_node_netnode): Compute netnode address from node address.
+(diskfs_netnode_node): And vice-versa.
+---
+ libdiskfs/diskfs.h | 29 +++++++++++++++++++++++++++--
+ libdiskfs/node-make.c | 39 ++++++++++++++++++++++++++++++---------
+ 2 files changed, 57 insertions(+), 11 deletions(-)
+
+diff --git a/libdiskfs/diskfs.h b/libdiskfs/diskfs.h
+index 8151ddc..a3f860d 100644
+--- a/libdiskfs/diskfs.h
++++ b/libdiskfs/diskfs.h
+@@ -116,9 +116,12 @@ struct node
+
+ loff_t allocsize;
+
+- ino64_t cache_id;
+-
+ int author_tracks_uid;
++
++ /* This is the last field. We do this so that if the node is
++ allocated with the disknode in an contiguous block, it sits right
++ next to the user supplied data. */
++ ino64_t cache_id;
+ };
+
+ struct diskfs_control
+@@ -685,6 +688,28 @@ diskfs_notice_filechange (struct node *np, enum file_changed_type type,
+ The new node will have one hard reference and no light references. */
+ struct node *diskfs_make_node (struct disknode *dn);
+
++/* Create a new node structure. Also allocate SIZE bytes for the
++ disknode. The address of the disknode can be obtained using
++ diskfs_node_disknode. The new node will have one hard reference
++ and no light references. */
++struct node *diskfs_make_node_alloc (size_t size);
++
++/* 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));
++}
++
+
+ /* The library also exports the following functions; they are not generally
+ useful unless you are redefining other functions the library provides. */
+diff --git a/libdiskfs/node-make.c b/libdiskfs/node-make.c
+index 2b6ef2a..ff0cc0d 100644
+--- a/libdiskfs/node-make.c
++++ b/libdiskfs/node-make.c
+@@ -19,16 +19,9 @@
+ #include <fcntl.h>
+
+
+-/* Create a and return new node structure with DN as its physical disknode.
+- The node will have one hard reference and no light references. */
+-struct node *
+-diskfs_make_node (struct disknode *dn)
++static struct node *
++init_node (struct node *np, struct disknode *dn)
+ {
+- struct node *np = malloc (sizeof (struct node));
+-
+- if (np == 0)
+- return 0;
+-
+ np->dn = dn;
+ np->dn_set_ctime = 0;
+ np->dn_set_atime = 0;
+@@ -52,3 +45,31 @@ diskfs_make_node (struct disknode *dn)
+
+ return np;
+ }
++
++/* Create a and return new node structure with DN as its physical disknode.
++ The node will have one hard reference and no light references. */
++struct node *
++diskfs_make_node (struct disknode *dn)
++{
++ struct node *np = malloc (sizeof (struct node));
++
++ if (np == 0)
++ return 0;
++
++ return init_node (np, dn);
++}
++
++/* Create a new node structure. Also allocate SIZE bytes for the
++ disknode. The address of the disknode can be obtained using
++ diskfs_node_disknode. The new node will have one hard reference
++ and no light references. */
++struct node *
++diskfs_make_node_alloc (size_t size)
++{
++ struct node *np = malloc (sizeof (struct node) + size);
++
++ if (np == NULL)
++ return NULL;
++
++ return init_node (np, diskfs_node_disknode (np));
++}
+--
+2.0.0.rc2
+