05 Apr, 2016

1 commit

  • PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
    ago with promise that one day it will be possible to implement page
    cache with bigger chunks than PAGE_SIZE.

    This promise never materialized. And unlikely will.

    We have many places where PAGE_CACHE_SIZE assumed to be equal to
    PAGE_SIZE. And it's constant source of confusion on whether
    PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
    especially on the border between fs and mm.

    Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
    breakage to be doable.

    Let's stop pretending that pages in page cache are special. They are
    not.

    The changes are pretty straight-forward:

    - << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> ;

    - >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> ;

    - PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};

    - page_cache_get() -> get_page();

    - page_cache_release() -> put_page();

    This patch contains automated changes generated with coccinelle using
    script below. For some reason, coccinelle doesn't patch header files.
    I've called spatch for them manually.

    The only adjustment after coccinelle is revert of changes to
    PAGE_CAHCE_ALIGN definition: we are going to drop it later.

    There are few places in the code where coccinelle didn't reach. I'll
    fix them manually in a separate patch. Comments and documentation also
    will be addressed with the separate patch.

    virtual patch

    @@
    expression E;
    @@
    - E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
    + E

    @@
    expression E;
    @@
    - E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
    + E

    @@
    @@
    - PAGE_CACHE_SHIFT
    + PAGE_SHIFT

    @@
    @@
    - PAGE_CACHE_SIZE
    + PAGE_SIZE

    @@
    @@
    - PAGE_CACHE_MASK
    + PAGE_MASK

    @@
    expression E;
    @@
    - PAGE_CACHE_ALIGN(E)
    + PAGE_ALIGN(E)

    @@
    expression E;
    @@
    - page_cache_get(E)
    + get_page(E)

    @@
    expression E;
    @@
    - page_cache_release(E)
    + put_page(E)

    Signed-off-by: Kirill A. Shutemov
    Acked-by: Michal Hocko
    Signed-off-by: Linus Torvalds

    Kirill A. Shutemov
     

25 Mar, 2016

1 commit

  • Pull MTD updates from Brian Norris:
    "NAND:
    - Add sunxi_nand randomizer support
    - begin refactoring NAND ecclayout structs
    - fix pxa3xx_nand dmaengine usage
    - brcmnand: fix support for v7.1 controller
    - add Qualcomm NAND controller driver

    SPI NOR:
    - add new ls1021a, ls2080a support to Freescale QuadSPI
    - add new flash ID entries
    - support bottom-block protection for Winbond flash
    - support Status Register Write Protect
    - remove broken QPI support for Micron SPI flash

    JFFS2:
    - improve post-mount CRC scan efficiency

    General:
    - refactor bcm63xxpart parser, to later extend for NAND
    - add writebuf size parameter to mtdram

    Other minor code quality improvements"

    * tag 'for-linus-20160324' of git://git.infradead.org/linux-mtd: (72 commits)
    mtd: nand: remove kerneldoc for removed function parameter
    mtd: nand: Qualcomm NAND controller driver
    dt/bindings: qcom_nandc: Add DT bindings
    mtd: nand: don't select chip in nand_chip's block_bad op
    mtd: spi-nor: support lock/unlock for a few Winbond chips
    mtd: spi-nor: add TB (Top/Bottom) protect support
    mtd: spi-nor: add SPI_NOR_HAS_LOCK flag
    mtd: spi-nor: use BIT() for flash_info flags
    mtd: spi-nor: disallow further writes to SR if WP# is low
    mtd: spi-nor: make lock/unlock bounds checks more obvious and robust
    mtd: spi-nor: silently drop lock/unlock for already locked/unlocked region
    mtd: spi-nor: wait for SR_WIP to clear on initial unlock
    mtd: nand: simplify nand_bch_init() usage
    mtd: mtdswap: remove useless if (!mtd->ecclayout) test
    mtd: create an mtd_oobavail() helper and make use of it
    mtd: kill the ecclayout->oobavail field
    mtd: nand: check status before reporting timeout
    mtd: bcm63xxpart: give width specifier an 'int', not 'size_t'
    mtd: mtdram: Add parameter for setting writebuf size
    mtd: nand: pxa3xx_nand: kill unused field 'drcmr_cmd'
    ...

    Linus Torvalds
     

01 Mar, 2016

1 commit

  • We need to finish doing the CRC checks before we can allow writes to
    happen, and we currently process the inodes in order. This means a call
    to jffs2_get_ino_cache() for each possible inode# up to c->highest_ino.

    There may be a lot of lookups which fail, if the inode# space is used
    sparsely. And the inode# space is *often* used sparsely, if a file
    system contains a lot of stuff that was put there in the original
    image, followed by lots of creation and deletion of new files.

    Instead of processing them numerically with a lookup each time, just
    walk the hash buckets instead.

    [fix locking typo reported by Dan Carpenter]
    Signed-off-by: David Woodhouse

    David Woodhouse
     

25 Feb, 2016

1 commit


08 May, 2012

1 commit

  • The locking policy is such that the erase_complete_block spinlock is
    nested within the alloc_sem mutex. This fixes a case in which the
    acquisition order was erroneously reversed. This issue was caught by
    the following lockdep splat:

    =======================================================
    [ INFO: possible circular locking dependency detected ]
    3.0.5 #1
    -------------------------------------------------------
    jffs2_gcd_mtd6/299 is trying to acquire lock:
    (&c->alloc_sem){+.+.+.}, at: [] jffs2_garbage_collect_pass+0x314/0x890

    but task is already holding lock:
    (&(&c->erase_completion_lock)->rlock){+.+...}, at: [] jffs2_garbage_collect_pass+0x308/0x890

    which lock already depends on the new lock.

    the existing dependency chain (in reverse order) is:

    -> #1 (&(&c->erase_completion_lock)->rlock){+.+...}:
    [] validate_chain+0xe6c/0x10bc
    [] __lock_acquire+0x54c/0xba4
    [] lock_acquire+0xa4/0x114
    [] _raw_spin_lock+0x3c/0x4c
    [] jffs2_garbage_collect_pass+0x4c/0x890
    [] jffs2_garbage_collect_thread+0x1b4/0x1cc
    [] kthread+0x98/0xa0
    [] kernel_thread_exit+0x0/0x8

    -> #0 (&c->alloc_sem){+.+.+.}:
    [] print_circular_bug+0x70/0x2c4
    [] validate_chain+0x1034/0x10bc
    [] __lock_acquire+0x54c/0xba4
    [] lock_acquire+0xa4/0x114
    [] mutex_lock_nested+0x74/0x33c
    [] jffs2_garbage_collect_pass+0x314/0x890
    [] jffs2_garbage_collect_thread+0x1b4/0x1cc
    [] kthread+0x98/0xa0
    [] kernel_thread_exit+0x0/0x8

    other info that might help us debug this:

    Possible unsafe locking scenario:

    CPU0 CPU1
    ---- ----
    lock(&(&c->erase_completion_lock)->rlock);
    lock(&c->alloc_sem);
    lock(&(&c->erase_completion_lock)->rlock);
    lock(&c->alloc_sem);

    *** DEADLOCK ***

    1 lock held by jffs2_gcd_mtd6/299:
    #0: (&(&c->erase_completion_lock)->rlock){+.+...}, at: [] jffs2_garbage_collect_pass+0x308/0x890

    stack backtrace:
    [] (unwind_backtrace+0x0/0x100) from [] (dump_stack+0x20/0x24)
    [] (dump_stack+0x20/0x24) from [] (print_circular_bug+0x1c8/0x2c4)
    [] (print_circular_bug+0x1c8/0x2c4) from [] (validate_chain+0x1034/0x10bc)
    [] (validate_chain+0x1034/0x10bc) from [] (__lock_acquire+0x54c/0xba4)
    [] (__lock_acquire+0x54c/0xba4) from [] (lock_acquire+0xa4/0x114)
    [] (lock_acquire+0xa4/0x114) from [] (mutex_lock_nested+0x74/0x33c)
    [] (mutex_lock_nested+0x74/0x33c) from [] (jffs2_garbage_collect_pass+0x314/0x890)
    [] (jffs2_garbage_collect_pass+0x314/0x890) from [] (jffs2_garbage_collect_thread+0x1b4/0x1cc)
    [] (jffs2_garbage_collect_thread+0x1b4/0x1cc) from [] (kthread+0x98/0xa0)
    [] (kthread+0x98/0xa0) from [] (kernel_thread_exit+0x0/0x8)

    This was introduce in '81cfc9f jffs2: Fix serious write stall due to erase'.

    Cc: stable@kernel.org [2.6.37+]
    Signed-off-by: Josh Cartwright
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Josh Cartwright
     

27 Mar, 2012

3 commits

  • Use pr_fmt to prefix KBUILD_MODNAME to appropriate logging messages.

    Remove now unnecessary internal prefixes from formats.

    Signed-off-by: Joe Perches
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Joe Perches
     
  • Use the more current logging style.

    Coalesce formats, align arguments.
    Convert uses of embedded function names to %s, __func__.

    A couple of long line checkpatch errors I don't care about exist.

    Signed-off-by: Joe Perches
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Joe Perches
     
  • D1 and D2 macros are mostly uses to emit debugging messages.

    Convert the logging uses of D1 & D2 to jffs2_dbg(level, fmt, ...)
    to be a bit more consistent style with the rest of the kernel.

    All jffs2_dbg output is now at KERN_DEBUG where some of
    the previous uses were emitted at various KERN_s.

    Signed-off-by: Joe Perches
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Joe Perches
     

25 Oct, 2010

1 commit


08 Aug, 2010

1 commit


20 May, 2010

1 commit


19 May, 2010

1 commit

  • jffs2_garbage_collect_pass() would previously return -EAGAIN if it
    couldn't find anything to garbage collect from, and there were blocks on
    the erase_pending_list. If the blocks were actually in the process of
    being erased, though, then they wouldn't be on that list. Check for
    nr_erasing_blocks being non-zero instead.

    Fix jffs2_reserve_space() to wait for the in-progress erases to
    complete, when jffs2_garbage_collect_pass() returns -EAGAIN.

    And fix jffs2_erase_succeeded() to actually wake up the erase_wait wq
    that jffs2_reserve_space() is now using.

    Signed-off-by: David Woodhouse

    David Woodhouse
     

16 Dec, 2009

1 commit

  • Ever since jffs2_garbage_collect_metadata() was first half-written in
    February 2001, it's been broken on architectures where 'char' is signed.
    When garbage collecting a symlink with target length above 127, the payload
    length would end up negative, causing interesting and bad things to happen.

    Cc: stable@kernel.org
    Signed-off-by: David Woodhouse

    David Woodhouse
     

02 May, 2008

2 commits


23 Apr, 2008

1 commit

  • When _all_ the blocks were on the erase_pending_list, we could't find a
    block to GC from but there was no _actually_ free space, and
    jffs2_reserve_space() would get a little unhappy.

    Handle this case by returning -EAGAIN from jffs2_garbage_collect_pass().
    There are two callers of that function -- jffs2_flush_wbuf_gc(), which
    will interpret it as an error and flush the writebuffer by other means,
    and jffs2_reserve_space(), which we modify to respond to -EAGAIN with an
    immediate call to jffs2_erase_pending_blocks() and another run round the
    loop.

    Signed-off-by: David Woodhouse

    David Woodhouse
     

22 Apr, 2008

2 commits


13 Oct, 2007

3 commits


10 Jul, 2007

1 commit


25 Apr, 2007

1 commit

  • In particular, remove the bit in the LICENCE file about contacting
    Red Hat for alternative arrangements. Their errant IS department broke
    that arrangement a long time ago -- the policy of collecting copyright
    assignments from contributors came to an end when the plug was pulled on
    the servers hosting the project, without notice or reason.

    We do still dual-license it for use with eCos, with the GPL+exception
    licence approved by the FSF as being GPL-compatible. It's just that nobody
    has the right to license it differently.

    Signed-off-by: David Woodhouse

    David Woodhouse
     

23 Apr, 2007

1 commit


19 Dec, 2006

1 commit


27 Jun, 2006

2 commits

  • If xattr_ref is associated with an orphan inode_cache
    on filesystem mounting, those xattr_refs are not
    released even if this inode_cache is released.

    This patch enables to call jffs2_xattr_delete_inode()
    for such a irregular inode_cachde too.

    Signed-off-by: KaiGai Kohei
    Signed-off-by: David Woodhouse

    KaiGai Kohei
     
  • - When xdatum is removed, a new xdatum with 'delete marker' is
    written. (version==0xffffffff means 'delete marker')
    - When xref is removed, a new xref with 'delete marker' is written.
    (odd-numbered xseqno means 'delete marker')

    - delete_xattr_(datum/xref)_delay() are new deletion functions
    are added. We can only use them if we can detect the target
    obsolete xdatum/xref as a orphan or errir one.
    (e.g when inode deletion, or detecting crc error)

    [1/3] jffs2-xattr-v6-01-delete_marker.patch

    Signed-off-by: KaiGai Kohei
    Signed-off-by: David Woodhouse

    KaiGai Kohei
     

24 May, 2006

2 commits


23 May, 2006

1 commit


22 May, 2006

1 commit


21 May, 2006

3 commits


19 May, 2006

1 commit

  • Device node major/minor numbers are just stored in the payload of a single
    data node. Just extend that to 4 bytes and use new_encode_dev() for it.

    We only use the 4-byte format if we _need_ to, if !old_valid_dev(foo).
    This preserves backwards compatibility with older code as much as
    possible. If we do make devices with major or minor numbers above 255, and
    then mount the file system with the old code, it'll just read the first
    two bytes and get the numbers wrong. If it comes to garbage-collect it,
    it'll then write back those wrong numbers. But that's about the best we
    can expect.

    Signed-off-by: David Woodhouse

    David Woodhouse
     

13 May, 2006

2 commits

  • Remove jffs2_garbage_collect_xattr(c, ic).
    jffs2_garbage_collect_xattr_datum/ref() are called from gc.c directly.

    In original implementation, jffs2_garbage_collect_xattr(c, ic) returns
    with holding a spinlock if 'ic' is inode_cache. But it returns after
    releasing a spinlock if 'ic' is xattr_datum/ref.
    It looks so confusable behavior. Thus, this patch makes caller manage
    locking/unlocking.

    [5/10] jffs2-xattr-v5.1-05-update_xattr_gc.patch

    Signed-off-by: KaiGai Kohei

    KaiGai Kohei
     
  • This attached patches provide xattr support including POSIX-ACL and
    SELinux support on JFFS2 (version.5).

    There are some significant differences from previous version posted
    at last December.
    The biggest change is addition of EBS(Erase Block Summary) support.
    Currently, both kernel and usermode utility (sumtool) can recognize
    xattr nodes which have JFFS2_NODETYPE_XATTR/_XREF nodetype.

    In addition, some bugs are fixed.
    - A potential race condition was fixed.
    - Unexpected fail when updating a xattr by same name/value pair was fixed.
    - A bug when removing xattr name/value pair was fixed.

    The fundamental structures (such as using two new nodetypes and exclusion
    mechanism by rwsem) are unchanged. But most of implementation were reviewed
    and updated if necessary.
    Espacially, we had to change several internal implementations related to
    load_xattr_datum() to avoid a potential race condition.

    [1/2] xattr_on_jffs2.kernel.version-5.patch
    [2/2] xattr_on_jffs2.utils.version-5.patch

    Signed-off-by: KaiGai Kohei
    Signed-off-by: David Woodhouse

    KaiGai Kohei
     

17 Apr, 2006

1 commit

  • For a while now, we've postponed CRC-checking of data nodes to be done
    by the GC thread, instead of being done while the user is waiting for
    mount to finish. The GC thread would iterate through all the inodes on
    the system and check each of their data nodes. It would skip over inodes
    which had already been used or were already being read in by
    read_inode(), because their data nodes would have been examined anyway.

    However, we could sometimes reach the end of the for-each-inode loop and
    still have some unchecked space left, if an inode we'd skipped was
    _still_ in the process of being read. This fixes that race by actually
    waiting for read_inode() to finish rather than just moving on.

    Thanks to Ladislav Michl for coming up with a reproducible test case and
    helping to track it down.

    Signed-off-by: David Woodhouse

    David Woodhouse
     

07 Nov, 2005

2 commits

  • Signed-off-by: Thomas Gleixner

    Thomas Gleixner
     
  • The goal of summary is to speed up the mount time. Erase block summary (EBS)
    stores summary information at the end of every (closed) erase block. It is
    no longer necessary to scan all nodes separetly (and read all pages of them)
    just read this "small" summary, where every information is stored which is
    needed at mount time.

    This summary information is stored in a JFFS2_FEATURE_RWCOMPAT_DELETE. During
    the mount process if there is no summary info the orignal scan process will
    be executed. EBS works with NAND and NOR flashes, too.

    There is a user space tool called sumtool to generate this summary
    information for a JFFS2 image.

    Signed-off-by: Ferenc Havasi
    Signed-off-by: Thomas Gleixner

    Ferenc Havasi