[Unionfs] [ANNOUNCE] Unionfs-ODF 2.1.10 release
Erez Zadok
ezk at cs.sunysb.edu
Thu Dec 6 22:04:45 EST 2007
In message <47548148.2060009 at ccs.nrl.navy.mil>, Jesse I Pollard writes:
> problem detected:
>
> make
> ....
> CC [M] fs/unionfs/copyup.o
> fs/unionfs/copyup.c: In function create_parents:
> fs/unionfs/copyup.c:694: error: malloc_sizes undeclared (first use in
> this function)
> fs/unionfs/copyup.c:694: error: (Each undeclared identifier is reported
> only once
> fs/unionfs/copyup.c:694: error: for each function it appears in.)
> make[2]: *** [fs/unionfs/copyup.o] Error 1
> make[1]: *** [fs/unionfs] Error 2
> make: *** [fs] Error 2
>
>
> This is from building with 2.6.24-rc3 and
> unionfs-2.1.10-odf_for_2.6.24-rc3 patch applied.
>
> Attached is the .config file used.
Thanks. Here's a fix.
Erez.
##############################################################################
Unionfs ODF: use krealloc() in create_parents()
Prevents compile error with CONFIG_SLUB:
$ make
fs/unionfs/copyup.c: In function 'create_parents':
fs/unionfs/copyup.c:694: error: 'malloc_sizes' undeclared (first use in this
function)
fs/unionfs/copyup.c:694: error: (Each undeclared identifier is reported only
once
Signed-off-by: Erez Zadok <ezk at cs.sunysb.edu>
diff --git a/fs/unionfs/copyup.c b/fs/unionfs/copyup.c
index 2ea88d9..4b4dda4 100644
--- a/fs/unionfs/copyup.c
+++ b/fs/unionfs/copyup.c
@@ -678,22 +678,15 @@ struct dentry *create_parents(struct inode *dir, struct dentry *dentry,
struct dentry *lower_dentry = NULL;
const char *childname;
unsigned int childnamelen;
- int old_kmalloc_size;
- int kmalloc_size;
- int num_dentry;
+ int nr_dentry;
int count = 0;
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 *);
-
err = is_robranch_super(dir->i_sb, bindex);
if (err) {
lower_dentry = ERR_PTR(err);
@@ -704,7 +697,10 @@ struct dentry *create_parents(struct inode *dir, struct dentry *dentry,
old_bend = dbend(dentry);
lower_dentry = ERR_PTR(-ENOMEM);
- path = kzalloc(kmalloc_size, GFP_KERNEL);
+
+ /* There is no sense allocating any less than the minimum. */
+ nr_dentry = 1;
+ path = kmalloc(nr_dentry * sizeof(struct dentry *), GFP_KERNEL);
if (unlikely(!path))
goto out;
@@ -731,26 +727,22 @@ struct dentry *create_parents(struct inode *dir, struct dentry *dentry,
lower_parent_dentry =
unionfs_lower_dentry_idx(parent_dentry, bindex);
- /* store the child dentry */
- path[count++] = child_dentry;
-
/* grow path table */
- if (count == num_dentry) {
- old_kmalloc_size = kmalloc_size;
- kmalloc_size *= 2;
- num_dentry = kmalloc_size / sizeof(struct dentry *);
+ if (count == nr_dentry) {
+ void *p;
- tmp_path = kzalloc(kmalloc_size, GFP_KERNEL);
- if (unlikely(!tmp_path)) {
+ nr_dentry *= 2;
+ p = krealloc(path, nr_dentry * sizeof(struct dentry *),
+ GFP_KERNEL);
+ if (unlikely(!p)) {
lower_dentry = ERR_PTR(-ENOMEM);
goto out;
}
- memcpy(tmp_path, path, old_kmalloc_size);
- kfree(path);
- path = tmp_path;
- tmp_path = NULL;
+ path = p;
}
+ /* store the child dentry */
+ path[count++] = child_dentry;
} while (!lower_parent_dentry);
count--;
More information about the unionfs
mailing list