Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 142624
b: refs/heads/master
c: 3358b4a
h: refs/heads/master
v: v3
  • Loading branch information
Ryusuke Konishi authored and Linus Torvalds committed Apr 7, 2009
1 parent ca9d1a5 commit 08446d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0c4fb877641c5c72d4a3ce8921a256bfe44055c0
refs/heads/master: 3358b4aaa84fd4c1cdd64391875e92cbb8afeb29
20 changes: 8 additions & 12 deletions trunk/fs/nilfs2/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,27 @@
#include "dat.h"


#define KMALLOC_SIZE_MIN 4096 /* 4KB */
#define KMALLOC_SIZE_MAX 131072 /* 128 KB */

static int nilfs_ioctl_wrap_copy(struct the_nilfs *nilfs,
struct nilfs_argv *argv, int dir,
ssize_t (*dofunc)(struct the_nilfs *,
int, int,
void *, size_t, size_t))
{
void *buf;
size_t ksize, maxmembs, total, n;
size_t maxmembs, total, n;
ssize_t nr;
int ret, i;

if (argv->v_nmembs == 0)
return 0;

for (ksize = KMALLOC_SIZE_MAX; ksize >= KMALLOC_SIZE_MIN; ksize /= 2) {
buf = kmalloc(ksize, GFP_NOFS);
if (buf != NULL)
break;
}
if (ksize < KMALLOC_SIZE_MIN)
if (argv->v_size > PAGE_SIZE)
return -EINVAL;

buf = (void *)__get_free_pages(GFP_NOFS, 0);
if (unlikely(!buf))
return -ENOMEM;
maxmembs = ksize / argv->v_size;
maxmembs = PAGE_SIZE / argv->v_size;

ret = 0;
total = 0;
Expand Down Expand Up @@ -89,7 +85,7 @@ static int nilfs_ioctl_wrap_copy(struct the_nilfs *nilfs,
}
argv->v_nmembs = total;

kfree(buf);
free_pages((unsigned long)buf, 0);
return ret;
}

Expand Down

0 comments on commit 08446d8

Please sign in to comment.