commit bcb690c064b7e82ddce1d9eccedd17b3b312f5bc
Author: Yiannis Pericleous <[EMAIL PROTECTED]>
Date: Fri May 11 19:46:40 2007 -0400
moved dentry_stack declarations in union.h so it can be used by get_parent
diff --git a/fs/unionfs/dirhelper.c b/fs/unionfs/dirhelper.c
index 0a83675..aa9c317 100644
--- a/fs/unionfs/dirhelper.c
+++ b/fs/unionfs/dirhelper.c
@@ -25,15 +25,8 @@
#define STACK_SIZE 64 /* initial size of the dentry stack */
-/* a stack for dentries */
-struct dentry_stack {
- struct dentry **item;
- int n;
- int size;
-};
-
/* reallocs at double the size */
-int __resize_stack(struct dentry_stack *stack)
+int __ds_resize(struct dentry_stack *stack)
{
struct dentry **new_stack;
int new_sz = stack->size * 2;
@@ -119,9 +112,7 @@ static int cleanup_util_callback(void *dirent, const char
*name, int namelen,
goto out;
}
BUG_ON(!dentry->d_inode);
- buf->stack->item[buf->stack->n++] = dentry;
- if (buf->stack->n == buf->stack->size)
- err = __resize_stack(buf->stack);
+ err = __ds_push(buf->stack, dentry);
}
out:
buf->err = err;
@@ -566,9 +557,7 @@ int odf_cleanup(struct odf_sb_info *odf, int mode, u64 size)
loff_t bytes, isize;
int blocks;
- stack.size = STACK_SIZE;
- stack.n = 0;
- stack.item = kmalloc(stack.size * sizeof(struct dentry *), GFP_KERNEL);
+ __ds_init(&stack, STACK_SIZE);
if (!stack.item) {
err = -ENOMEM;
goto out;
@@ -597,7 +586,7 @@ cleanup_loop:
* odf/reclaim and pushing to the stack all directories
*/
while (err >= 0 && stack.n > 0 && !success) {
- dentry = stack.item[--stack.n]; /* pop */
+ dentry = __ds_pop(&stack);
/* we need to dget /reclaim dirs again since we need
* them after we close the file
@@ -676,7 +665,7 @@ cleanup_loop:
out:
BUG_ON(stack.n < 0);
while(stack.n)
- dput(stack.item[--stack.n]);
+ dput(__ds_pop(&stack));
kfree(buf);
kfree(stack.item);
diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index 6a93219..b6c98da 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -486,6 +486,37 @@ static inline void unionfs_mntput(struct dentry *dentry,
int bindex)
mntput(mnt);
}
+
+/* a stack for dentries amd its ops, used by odf cleanup thread and get_parent
*/
+struct dentry_stack {
+ struct dentry **item;
+ int n;
+ int size;
+};
+
+int __ds_resize(struct dentry_stack *stack);
+
+static inline void __ds_init(struct dentry_stack *stack, int size)
+{
+ stack->size = size;
+ stack->n = 0;
+ stack->item = kmalloc(stack->size * sizeof(struct dentry *),
GFP_KERNEL);
+}
+
+static inline int __ds_push(struct dentry_stack *stack, struct dentry *dentry)
+{
+ stack->item[stack->n++] = dentry;
+ if (stack->n == stack->size)
+ return __ds_resize(stack);
+ return 0;
+}
+
+static inline struct dentry *__ds_pop(struct dentry_stack *stack)
+{
+ return stack->item[--stack->n];
+}
+
+
/* keep everything odf related separate for now */
#include "odf.h"
_______________________________________________
unionfs-cvs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs