[PATCH] Document changed semantics of tmpfs mount option in mount(8) man page.

kevin granade kevin.granade at gmail.com
Tue Jul 28 21:00:32 UTC 2009


I ran across a bug in linux's handling of tmpfs mount options in an old
kernel, but it seems to have been fixed.  I then discovered however, that
the semantics of the option no longer matched what was written in the
mount(8) man page.  Here's a patch to make them $

--- usr/share/man/man8/mount.8  2009-05-29 06:06:27.000000000 -0500
+++ usr/share/man/man8/mount.8  2009-07-28 15:45:07.000000000 -0500
@@ -1821,7 +1821,7 @@
 .TP
 .BI size= nbytes
 Override default maximum size of the filesystem.
-The size is given in bytes, and rounded down to entire pages.
+The size is given in bytes, and rounded up to entire pages.
 The default is half of the memory. The size parameter also accepts a suffix
%
 to limit this tmpfs instance to that percentage of your physical RAM:
 the default, when neither size nor nr_blocks is specified, is size=50%

Specifically, the old code did this:
                if (!strcmp(this_char,"size")) {
                        unsigned long long size;
                        size = memparse(value,&rest);
                        if (*rest == '%') {
                                size <<= PAGE_SHIFT;
                                size *= totalram_pages;
                                do_div(size, 100);
                                rest++;
                        }
                        if (*rest)
                                goto bad_val;
                        *blocks = size >> PAGE_CACHE_SHIFT;

Which of course truncates the value (aka rounding it down)

and the new code does this:
                if (!strcmp(this_char,"size")) {
                        unsigned long long size;
                        size = memparse(value,&rest);
                        if (*rest == '%') {
                                size <<= PAGE_SHIFT;
                                size *= totalram_pages;
                                do_div(size, 100);
                                rest++;
                        }
                        if (*rest)
                                goto bad_val;
                        sbinfo->max_blocks =
                                DIV_ROUND_UP(size, PAGE_CACHE_SIZE)

In order to avoid problems when the user specifies a size < page size, with
the side effect that now it rounds the value UP to the nearest page size.

Please CC me if you have any questions as I'm not subscribed to this list.

Please also CC anyone else who might need this (redhat, suse, etc...
maintainer, for example)

Kevin Granade
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-devel-discuss/attachments/20090728/57aed0a3/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mount_diff
Type: application/octet-stream
Size: 575 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/ubuntu-devel-discuss/attachments/20090728/57aed0a3/attachment.obj>


More information about the Ubuntu-devel-discuss mailing list