summaryrefslogtreecommitdiffstats
path: root/sys/fs/tmpfs/tmpfs_vfsops.c
diff options
context:
space:
mode:
authorgleb <gleb@FreeBSD.org>2012-04-07 15:30:46 +0000
committergleb <gleb@FreeBSD.org>2012-04-07 15:30:46 +0000
commit75744aafa6065b399e52414e87808d1ab2bd5979 (patch)
tree17a7aa7f41002a199bcdb8e032d7e6849cb90bc8 /sys/fs/tmpfs/tmpfs_vfsops.c
parentfb452e77b0bf349c6f07fac7be964a846910018d (diff)
downloadFreeBSD-src-75744aafa6065b399e52414e87808d1ab2bd5979.zip
FreeBSD-src-75744aafa6065b399e52414e87808d1ab2bd5979.tar.gz
tmpfs supports only INT_MAX nodes due to limitations of unit number
allocator. Replace UINT32_MAX checks with INT_MAX. Keeping more than 2^31 nodes in memory is not likely to become possible in foreseeable feature and would require new unit number allocator. Discussed with: delphij MFC after: 2 weeks
Diffstat (limited to 'sys/fs/tmpfs/tmpfs_vfsops.c')
-rw-r--r--sys/fs/tmpfs/tmpfs_vfsops.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/fs/tmpfs/tmpfs_vfsops.c b/sys/fs/tmpfs/tmpfs_vfsops.c
index 6bb1a44..96d7321 100644
--- a/sys/fs/tmpfs/tmpfs_vfsops.c
+++ b/sys/fs/tmpfs/tmpfs_vfsops.c
@@ -130,6 +130,8 @@ tmpfs_node_fini(void *mem, int size)
static int
tmpfs_mount(struct mount *mp)
{
+ const size_t nodes_per_page = howmany(PAGE_SIZE,
+ sizeof(struct tmpfs_dirent) + sizeof(struct tmpfs_node));
struct tmpfs_mount *tmp;
struct tmpfs_node *root;
int error;
@@ -195,11 +197,13 @@ tmpfs_mount(struct mount *mp)
MPASS(pages > 0);
if (nodes_max <= 3) {
- if (pages > UINT32_MAX - 3)
- nodes_max = UINT32_MAX;
+ if (pages < INT_MAX / nodes_per_page)
+ nodes_max = pages * nodes_per_page;
else
- nodes_max = pages + 3;
+ nodes_max = INT_MAX;
}
+ if (nodes_max > INT_MAX)
+ nodes_max = INT_MAX;
MPASS(nodes_max >= 3);
/* Allocate the tmpfs mount structure and fill it. */
OpenPOWER on IntegriCloud