commit 6aca07cb40453769b790820499da64f759dcf995
Author: Yiannis Pericleous <[EMAIL PROTECTED]>
Date: Sat May 19 16:16:11 2007 -0400
fixed some rebase conflicts
diff --git a/fs/unionfs/copyup.c b/fs/unionfs/copyup.c
index 4a775b7..e0f637e 100644
--- a/fs/unionfs/copyup.c
+++ b/fs/unionfs/copyup.c
@@ -643,10 +643,15 @@ static struct dentry *create_parents_named(struct inode
*dir,
int old_bstart;
int old_bend;
struct dentry **path = NULL;
+ struct dentry **tmp_path;
struct super_block *sb;
verify_locked(dentry);
+ /* There is no sense allocating any less than the minimum. */
+ kmalloc_size = malloc_sizes[0].cs_size;
+ num_dentry = kmalloc_size / sizeof(struct dentry *);
+
if ((err = is_robranch_super(dir->i_sb, bindex))) {
hidden_dentry = ERR_PTR(err);
goto out;
@@ -656,10 +661,7 @@ static struct dentry *create_parents_named(struct inode
*dir,
old_bend = dbend(dentry);
hidden_dentry = ERR_PTR(-ENOMEM);
-
- /* There is no sense allocating any less than the minimum. */
- nr_dentry = 1;
- path = kmalloc(nr_dentry * sizeof(struct dentry *), GFP_KERNEL);
+ path = kzalloc(kmalloc_size, GFP_KERNEL);
if (!path)
goto out;
@@ -686,21 +688,26 @@ static struct dentry *create_parents_named(struct inode
*dir,
hidden_parent_dentry =
unionfs_lower_dentry_idx(parent_dentry, bindex);
+ /* store the child dentry */
+ path[count++] = child_dentry;
+
/* grow path table */
- if (count == nr_dentry) {
- void *p;
+ if (count == num_dentry) {
+ old_kmalloc_size = kmalloc_size;
+ kmalloc_size *= 2;
+ num_dentry = kmalloc_size / sizeof(struct dentry *);
- nr_dentry *= 2;
- p = krealloc(path, nr_dentry * sizeof(struct dentry *),
GFP_KERNEL);
- if (!p) {
+ tmp_path = kzalloc(kmalloc_size, GFP_KERNEL);
+ if (!tmp_path) {
hidden_dentry = ERR_PTR(-ENOMEM);
goto out;
}
- path = p;
+ memcpy(tmp_path, path, old_kmalloc_size);
+ kfree(path);
+ path = tmp_path;
+ tmp_path = NULL;
}
- /* store the child dentry */
- path[count++] = child_dentry;
} while (!hidden_parent_dentry);
count--;
diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c
index c7bcac1..b089898 100644
--- a/fs/unionfs/lookup.c
+++ b/fs/unionfs/lookup.c
@@ -391,8 +391,8 @@ void free_dentry_private_data(struct unionfs_dentry_info
*udi)
/* allocate new dentry private data, free old one if necessary */
int new_dentry_private_data(struct dentry *dentry)
{
- int new_size;
- int size;
+ int newsize;
+ int oldsize = 0;
struct unionfs_dentry_info *info = UNIONFS_D(dentry);
int unlock_on_err = 0;
@@ -410,9 +410,8 @@ int new_dentry_private_data(struct dentry *dentry)
unlock_on_err = 1;
info->lower_paths = NULL;
- size = 0;
} else
- size = sizeof(struct path) * info->bcount;
+ oldsize = sizeof(struct path) * info->bcount;
info->bstart = -1;
info->bend = -1;
@@ -420,21 +419,29 @@ int new_dentry_private_data(struct dentry *dentry)
info->odf_info = NULL;
atomic_set(&info->generation,
atomic_read(&UNIONFS_SB(dentry->d_sb)->generation));
+ newsize = sizeof(struct path) * sbmax(dentry->d_sb);
- new_size = sizeof(struct path) * sbmax(dentry->d_sb);
+ /*
+ * Don't reallocate when we already have enough space.
+ * It would be ideal if we could actually use the slab macros to
+ * determine what our object sizes is, but those are not exported.
+ */
+ if (oldsize) {
+ int minsize = malloc_sizes[0].cs_size;
- /* Don't reallocate when we already have enough space. */
- if (new_size > size) {
- void *p;
+ if (!newsize || ((oldsize < newsize) && (newsize > minsize))) {
+ kfree(info->lower_paths);
+ info->lower_paths = NULL;
+ }
+ }
- p = krealloc(info->lower_paths, new_size, GFP_ATOMIC);
- if (!p)
+ if (!info->lower_paths && newsize) {
+ info->lower_paths = kmalloc(newsize, GFP_ATOMIC);
+ if (!info->lower_paths)
goto out_free;
-
- info->lower_paths = p;
- size = new_size;
}
- memset(info->lower_paths, 0, size);
+
+ memset(info->lower_paths, 0, (oldsize > newsize ? oldsize : newsize));
spin_unlock(&dentry->d_lock);
return 0;
_______________________________________________
unionfs-cvs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs