04 Jan, 2012

4 commits


03 Nov, 2011

1 commit


15 Apr, 2011

1 commit

  • On no-mmu arch, there is a memleak during shmem test. The cause of this
    memleak is ramfs_nommu_expand_for_mapping() added page refcount to 2
    which makes iput() can't free that pages.

    The simple test file is like this:

    int main(void)
    {
    int i;
    key_t k = ftok("/etc", 42);

    for ( i=0; i free
    total used free shared buffers
    Mem: 60320 17912 42408 0 0
    -/+ buffers: 17912 42408
    root:/> shmem
    run ok...
    root:/> free
    total used free shared buffers
    Mem: 60320 19096 41224 0 0
    -/+ buffers: 19096 41224
    root:/> shmem
    run ok...
    root:/> free
    total used free shared buffers
    Mem: 60320 20296 40024 0 0
    -/+ buffers: 20296 40024
    ...

    After this patch the test result is:(no memleak anymore)

    root:/> free
    total used free shared buffers
    Mem: 60320 16668 43652 0 0
    -/+ buffers: 16668 43652
    root:/> shmem
    run ok...
    root:/> free
    total used free shared buffers
    Mem: 60320 16668 43652 0 0
    -/+ buffers: 16668 43652

    Signed-off-by: Bob Liu
    Acked-by: Hugh Dickins
    Signed-off-by: David Howells
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Bob Liu
     

29 Oct, 2010

1 commit


26 Oct, 2010

1 commit

  • Instead of always assigning an increasing inode number in new_inode
    move the call to assign it into those callers that actually need it.
    For now callers that need it is estimated conservatively, that is
    the call is added to all filesystems that do not assign an i_ino
    by themselves. For a few more filesystems we can avoid assigning
    any inode number given that they aren't user visible, and for others
    it could be done lazily when an inode number is actually needed,
    but that's left for later patches.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Dave Chinner
    Signed-off-by: Al Viro

    Christoph Hellwig
     

10 Aug, 2010

2 commits

  • Make sure we check the truncate constraints early on in ->setattr by adding
    those checks to inode_change_ok. Also clean up and document inode_change_ok
    to make this obvious.

    As a fallout we don't have to call inode_newsize_ok from simple_setsize and
    simplify it down to a truncate_setsize which doesn't return an error. This
    simplifies a lot of setattr implementations and means we use truncate_setsize
    almost everywhere. Get rid of fat_setsize now that it's trivial and mark
    ext2_setsize static to make the calling convention obvious.

    Keep the inode_newsize_ok in vmtruncate for now as all callers need an
    audit for its removal anyway.

    Note: setattr code in ecryptfs doesn't call inode_change_ok at all and
    needs a deeper audit, but that is left for later.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Al Viro

    Christoph Hellwig
     
  • Despite its name it's now a generic implementation of ->setattr, but
    rather a helper to copy attributes from a struct iattr to the inode.
    Rename it to setattr_copy to reflect this fact.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Al Viro

    Christoph Hellwig
     

28 May, 2010

2 commits

  • Convert simple filesystems: ramfs, configfs, sysfs, block_dev to new truncate
    sequence.

    Cc: Christoph Hellwig
    Signed-off-by: Nick Piggin
    Signed-off-by: Al Viro

    Nick Piggin
     
  • We don't name our generic fsync implementations very well currently.
    The no-op implementation for in-memory filesystems currently is called
    simple_sync_file which doesn't make too much sense to start with,
    the the generic one for simple filesystems is called simple_fsync
    which can lead to some confusion.

    This patch renames the generic file fsync method to generic_file_fsync
    to match the other generic_file_* routines it is supposed to be used
    with, and the no-op implementation to noop_fsync to make it obvious
    what to expect. In addition add some documentation for both methods.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Al Viro

    Christoph Hellwig
     

22 May, 2010

2 commits


30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

17 Jan, 2010

2 commits

  • Fix a problem in NOMMU mmap with ramfs whereby a shared mmap can happen
    over the end of a truncation. The problem is that
    ramfs_nommu_check_mappings() checks that the reduced file size against the
    VMA tree, but not the vm_region tree.

    The following sequence of events can cause the problem:

    fd = open("/tmp/x", O_RDWR|O_TRUNC|O_CREAT, 0600);
    ftruncate(fd, 32 * 1024);
    a = mmap(NULL, 32 * 1024, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
    b = mmap(NULL, 16 * 1024, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
    munmap(a, 32 * 1024);
    ftruncate(fd, 16 * 1024);
    c = mmap(NULL, 32 * 1024, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);

    Mapping 'a' creates a vm_region covering 32KB of the file. Mapping 'b'
    sees that the vm_region from 'a' is covering the region it wants and so
    shares it, pinning it in memory.

    Mapping 'a' then goes away and the file is truncated to the end of VMA
    'b'. However, the region allocated by 'a' is still in effect, and has
    _not_ been reduced.

    Mapping 'c' is then created, and because there's a vm_region covering the
    desired region, get_unmapped_area() is _not_ called to repeat the check,
    and the mapping is granted, even though the pages from the latter half of
    the mapping have been discarded.

    However:

    d = mmap(NULL, 16 * 1024, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);

    Mapping 'd' should work, and should end up sharing the region allocated by
    'a'.

    To deal with this, we shrink the vm_region struct during the truncation,
    lest do_mmap_pgoff() take it as licence to share the full region
    automatically without calling the get_unmapped_area() file op again.

    Signed-off-by: David Howells
    Acked-by: Al Viro
    Cc: Greg Ungerer
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Howells
     
  • Fix the race between the truncation of a ramfs file and an attempt to make
    a shared mmap of region of that file.

    The problem is that do_mmap_pgoff() calls f_op->get_unmapped_area() to
    verify that the file region is made of contiguous pages and to find its
    base address - but there isn't any locking to guarantee this region until
    vma_prio_tree_insert() is called by add_vma_to_mm().

    Note that moving the functionality into f_op->mmap() doesn't help as that
    is also called before vma_prio_tree_insert().

    Instead make ramfs_nommu_check_mappings() grab nommu_region_sem whilst it
    does its checks. This means that this function will wait whilst mmaps
    take place.

    Signed-off-by: David Howells
    Acked-by: Al Viro
    Cc: Greg Ungerer
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Howells
     

18 Dec, 2009

1 commit


24 Sep, 2009

1 commit

  • Update some fs code to make use of new helper functions introduced
    in the previous patch. Should be no significant change in behaviour
    (except CIFS now calls send_sig under i_lock, via inode_newsize_ok).

    Reviewed-by: Christoph Hellwig
    Acked-by: Miklos Szeredi
    Cc: linux-nfs@vger.kernel.org
    Cc: Trond.Myklebust@netapp.com
    Cc: linux-cifs-client@lists.samba.org
    Cc: sfrench@samba.org
    Signed-off-by: Nick Piggin
    Signed-off-by: Al Viro

    npiggin@suse.de
     

23 Sep, 2009

1 commit


11 Sep, 2009

1 commit


30 Jul, 2009

1 commit

  • This file makes use of various macros defined in files like asm/current.h
    or asm-generic/resource.h. All these files can be included via sched.h.
    The building of the !MMU ARM kernel (with additional patches) fails
    without this change.

    Signed-off-by: Catalin Marinas
    Acked-by: David Howells
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Catalin Marinas
     

15 Jun, 2009

1 commit

  • On systems where CONFIG_SHMEM is disabled, mounting tmpfs filesystems can
    fail when tmpfs options are used. This is because tmpfs creates a small
    wrapper around ramfs which rejects unknown options, and ramfs itself only
    supports a tiny subset of what tmpfs supports. This makes it pretty hard
    to use the same userspace systems across different configuration systems.
    As such, ramfs should ignore the tmpfs options when tmpfs is merely a
    wrapper around ramfs.

    This used to work before commit c3b1b1cbf0 as previously, ramfs would
    ignore all options. But now, we get:
    ramfs: bad mount option: size=10M
    mount: mounting mdev on /dev failed: Invalid argument

    Another option might be to restore the previous behavior, where ramfs
    simply ignored all unknown mount options ... which is what Hugh prefers.

    Signed-off-by: Mike Frysinger
    Signed-off-by: Hugh Dickins
    Acked-by: Matt Mackall
    Acked-by: Wu Fengguang
    Cc: stable@kernel.org
    Signed-off-by: Linus Torvalds

    Mike Frysinger
     

07 Apr, 2009

1 commit

  • If ramfs mount fails, s_fs_info will be freed twice in ramfs_fill_super()
    and ramfs_kill_sb(), leading to kernel oops.

    Consolidate and beautify the code.
    Make sure s_fs_info and s_root are in known good states.

    Acked-by: Wu Fengguang
    Signed-off-by: Ingo Molnar
    Signed-off-by: Linus Torvalds

    Ingo Molnar
     

01 Apr, 2009

2 commits

  • Addresses http://bugzilla.kernel.org/show_bug.cgi?id=12843

    "I use ramfs instead of tmpfs for /tmp because I don't use swap on my
    laptop. Some apps need 1777 mode for /tmp directory, but ramfs does not
    support 'mode=' mount option."

    Reported-by: Avan Anishchuk
    Signed-off-by: Wu Fengguang
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Wu Fengguang
     
  • Instead of open-coding the lru-list-add pagevec batching when expanding a
    file mapping from zero, defer to the appropriate page cache function that
    also takes care of adding the page to the lru list.

    This is cleaner, saves code and reduces the stack footprint by 16 words
    worth of pagevec.

    Signed-off-by: Johannes Weiner
    Acked-by: David Howells
    Cc: Nick Piggin
    Acked-by: KOSAKI Motohiro
    Cc: Rik van Riel
    Cc: Peter Zijlstra
    Cc: MinChan Kim
    Cc: Lee Schermerhorn
    Cc: Greg Ungerer
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Johannes Weiner
     

26 Mar, 2009

1 commit


15 Mar, 2009

2 commits

  • When a ramfs nommu mapping is expanded, contiguous pages are allocated
    and added to the pagecache. The caller's reference is then passed on
    by moving whole pagevecs to the file lru list.

    If the page cache adding fails, make sure that the error path also
    moves the pagevec contents which might still contain up to PAGEVEC_SIZE
    successfully added pages, of which we would leak references otherwise.

    Signed-off-by: Johannes Weiner
    Cc: David Howells
    Cc: Enrik Berkhan
    Cc: Nick Piggin
    Cc: Peter Zijlstra
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Johannes Weiner
     
  • The pages attached to a ramfs inode's pagecache by truncation from nothing
    - as done by SYSV SHM for example - may get discarded under memory
    pressure.

    The problem is that the pages are not marked dirty. Anything that creates
    data in an MMU-based ramfs will cause the pages holding that data will
    cause the set_page_dirty() aop to be called.

    For the NOMMU-based mmap, set_page_dirty() may be called by write(), but
    it won't be called by page-writing faults on writable mmaps, and it isn't
    called by ramfs_nommu_expand_for_mapping() when a file is being truncated
    from nothing to allocate a contiguous run.

    The solution is to mark the pages dirty at the point of allocation by the
    truncation code.

    Signed-off-by: Enrik Berkhan
    Signed-off-by: David Howells
    Cc: Peter Zijlstra
    Cc: Nick Piggin
    Cc: Johannes Weiner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Enrik Berkhan
     

08 Jan, 2009

1 commit

  • Fix cleanup handling in ramfs_nommu_get_umapped_area() by only freeing the
    number of pages that find_get_pages() said it had returned (nr) rather than
    attempting to free the number of pages we asked for (lpages) - thus avoiding
    the situation whereby put_page() may be handed NULL pointers if
    find_get_pages() returned fewer pages that were requested.

    Also avoid a warning about nr being uninitialised and the need for an
    if-statement in the cleanup path by using appropriate gotos.

    Signed-off-by: David Howells

    David Howells
     

06 Jan, 2009

1 commit


14 Nov, 2008

1 commit

  • Wrap access to task credentials so that they can be separated more easily from
    the task_struct during the introduction of COW creds.

    Change most current->(|e|s|fs)[ug]id to current_(|e|s|fs)[ug]id().

    Change some task->e?[ug]id to task_e?[ug]id(). In some places it makes more
    sense to use RCU directly rather than a convenient wrapper; these will be
    addressed by later patches.

    Signed-off-by: David Howells
    Reviewed-by: James Morris
    Acked-by: Serge Hallyn
    Signed-off-by: James Morris

    David Howells
     

20 Oct, 2008

2 commits

  • Christoph Lameter pointed out that ram disk pages also clutter the LRU
    lists. When vmscan finds them dirty and tries to clean them, the ram disk
    writeback function just redirties the page so that it goes back onto the
    active list. Round and round she goes...

    With the ram disk driver [rd.c] replaced by the newer 'brd.c', this is no
    longer the case, as ram disk pages are no longer maintained on the lru.
    [This makes them unmigratable for defrag or memory hot remove, but that
    can be addressed by a separate patch series.] However, the ramfs pages
    behave like ram disk pages used to, so:

    Define new address_space flag [shares address_space flags member with
    mapping's gfp mask] to indicate that the address space contains all
    unevictable pages. This will provide for efficient testing of ramfs pages
    in page_evictable().

    Also provide wrapper functions to set/test the unevictable state to
    minimize #ifdefs in ramfs driver and any other users of this facility.

    Set the unevictable state on address_space structures for new ramfs
    inodes. Test the unevictable state in page_evictable() to cull
    unevictable pages.

    These changes depend on [CONFIG_]UNEVICTABLE_LRU.

    [riel@redhat.com: undo the brd.c part]
    Signed-off-by: Lee Schermerhorn
    Signed-off-by: Rik van Riel
    Debugged-by: Nick Piggin
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Lee Schermerhorn
     
  • Split the LRU lists in two, one set for pages that are backed by real file
    systems ("file") and one for pages that are backed by memory and swap
    ("anon"). The latter includes tmpfs.

    The advantage of doing this is that the VM will not have to scan over lots
    of anonymous pages (which we generally do not want to swap out), just to
    find the page cache pages that it should evict.

    This patch has the infrastructure and a basic policy to balance how much
    we scan the anon lists and how much we scan the file lists. The big
    policy changes are in separate patches.

    [lee.schermerhorn@hp.com: collect lru meminfo statistics from correct offset]
    [kosaki.motohiro@jp.fujitsu.com: prevent incorrect oom under split_lru]
    [kosaki.motohiro@jp.fujitsu.com: fix pagevec_move_tail() doesn't treat unevictable page]
    [hugh@veritas.com: memcg swapbacked pages active]
    [hugh@veritas.com: splitlru: BDI_CAP_SWAP_BACKED]
    [akpm@linux-foundation.org: fix /proc/vmstat units]
    [nishimura@mxp.nes.nec.co.jp: memcg: fix handling of shmem migration]
    [kosaki.motohiro@jp.fujitsu.com: adjust Quicklists field of /proc/meminfo]
    [kosaki.motohiro@jp.fujitsu.com: fix style issue of get_scan_ratio()]
    Signed-off-by: Rik van Riel
    Signed-off-by: Lee Schermerhorn
    Signed-off-by: KOSAKI Motohiro
    Signed-off-by: Hugh Dickins
    Signed-off-by: Daisuke Nishimura
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rik van Riel
     

03 Oct, 2008

1 commit

  • The previous patch db203d53d474aa068984e409d807628f5841da1b ("mm:
    tiny-shmem fix lock ordering: mmap_sem vs i_mutex") to fix the lock
    ordering in tiny-shmem breaks shared anonymous and IPC memory on NOMMU
    architectures because it was using the expanding truncate to signal ramfs
    to allocate a physically contiguous RAM backing the inode (otherwise it is
    unusable for "memory mapping" it to userspace).

    However do_truncate is what caused the lock ordering error, due to it
    taking i_mutex. In this case, we can actually just call ramfs directly to
    allocate memory for the mapping, rather than go via truncate.

    Acked-by: David Howells
    Acked-by: Hugh Dickins
    Signed-off-by: Nick Piggin
    Cc: Matt Mackall
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Nick Piggin
     

04 Jul, 2008

1 commit


30 Apr, 2008

1 commit

  • Add a new BDI capability flag: BDI_CAP_NO_ACCT_WB. If this flag is
    set, then don't update the per-bdi writeback stats from
    test_set_page_writeback() and test_clear_page_writeback().

    Misc cleanups:

    - convert bdi_cap_writeback_dirty() and friends to static inline functions
    - create a flag that includes all three dirty/writeback related flags,
    since almst all users will want to have them toghether

    Signed-off-by: Miklos Szeredi
    Cc: Peter Zijlstra
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     

29 Apr, 2008

1 commit

  • - internal.h shouldn't duplicate the extern declaration for
    ramfs_file_operations already in include/linux/ramfs.h
    - file-mmu.c needs two #include's for seeing the extern declarations
    of it's global struct's

    Signed-off-by: Adrian Bunk
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Adrian Bunk
     

17 Oct, 2007

2 commits

  • Since CONFIG_RAMFS is currently hard-selected to "y", and since
    Documentation/filesystems/ramfs-rootfs-initramfs.txt reads as follows:

    "The amount of code required to implement ramfs is tiny, because all the
    work is done by the existing Linux caching infrastructure. Basically,
    you're mounting the disk cache as a filesystem. Because of this, ramfs is
    not an optional component removable via menuconfig, since there would be
    negligible space savings."

    It seems pointless to leave this as a Kconfig entry.

    Signed-off-by: Robert P. J. Day
    Cc: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Robert P. J. Day
     
  • provide BDI constructor/destructor hooks

    [akpm@linux-foundation.org: compile fix]
    Signed-off-by: Peter Zijlstra
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Peter Zijlstra