Date: Sat, 7 Apr 2012 15:30:46 +0000 (UTC) From: Gleb Kurtsou <gleb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r234000 - head/sys/fs/tmpfs Message-ID: <201204071530.q37FUkqi067948@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: gleb Date: Sat Apr 7 15:30:46 2012 New Revision: 234000 URL: http://svn.freebsd.org/changeset/base/234000 Log: 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 Modified: head/sys/fs/tmpfs/tmpfs_vfsops.c Modified: head/sys/fs/tmpfs/tmpfs_vfsops.c ============================================================================== --- head/sys/fs/tmpfs/tmpfs_vfsops.c Sat Apr 7 15:27:34 2012 (r233999) +++ head/sys/fs/tmpfs/tmpfs_vfsops.c Sat Apr 7 15:30:46 2012 (r234000) @@ -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. */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201204071530.q37FUkqi067948>