1. 20 Dec, 2012 40 commits
    • Jeff Layton's avatar
      vfs: fix renameat to retry on ESTALE errors · c6a94284
      Jeff Layton authored
      ...as always, rename is the messiest of the bunch. We have to track
      whether to retry or not via a separate flag since the error handling
      is already quite complex.
      Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      c6a94284
    • Jeff Layton's avatar
      5d18f813
    • Jeff Layton's avatar
      c6ee9206
    • Jeff Layton's avatar
      vfs: add a flags argument to user_path_parent · 9e790bd6
      Jeff Layton authored
      ...so we can pass in LOOKUP_REVAL. For now, nothing does yet.
      Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      9e790bd6
    • Jeff Layton's avatar
      442e31ca
    • Jeff Layton's avatar
      f46d3567
    • Jeff Layton's avatar
      b76d8b82
    • Jeff Layton's avatar
      vfs: fix mknodat to retry on ESTALE errors · 972567f1
      Jeff Layton authored
      Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      972567f1
    • Jeff Layton's avatar
      vfs: turn is_dir argument to kern_path_create into a lookup_flags arg · 1ac12b4b
      Jeff Layton authored
      Where we can pass in LOOKUP_DIRECTORY or LOOKUP_REVAL. Any other flags
      passed in here are currently ignored.
      Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      1ac12b4b
    • Jeff Layton's avatar
      vfs: fix readlinkat to retry on ESTALE · 7955119e
      Jeff Layton authored
      Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      7955119e
    • Jeff Layton's avatar
    • Jeff Layton's avatar
      vfs: add a retry_estale helper function to handle retries on ESTALE · b9d6ba94
      Jeff Layton authored
      This function is expected to be called from path-based syscalls to help
      them decide whether to try the lookup and call again in the event that
      they got an -ESTALE return back on an earier try.
      
      Currently, we only retry the call once on an ESTALE error, but in the
      event that we decide that that's not enough in the future, we should be
      able to change the logic in this helper without too much effort.
      Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      b9d6ba94
    • Al Viro's avatar
      Merge branch 'fscache' of... · 21e89c0c
      Al Viro authored
      Merge branch 'fscache' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs into for-linus
      21e89c0c
    • NeilBrown's avatar
      vfs: d_obtain_alias() needs to use "/" as default name. · b911a6bd
      NeilBrown authored
      NFS appears to use d_obtain_alias() to create the root dentry rather than
      d_make_root.  This can cause 'prepend_path()' to complain that the root
      has a weird name if an NFS filesystem is lazily unmounted.  e.g.  if
      "/mnt" is an NFS mount then
      
       { cd /mnt; umount -l /mnt ; ls -l /proc/self/cwd; }
      
      will cause a WARN message like
         WARNING: at /home/git/linux/fs/dcache.c:2624 prepend_path+0x1d7/0x1e0()
         ...
         Root dentry has weird name <>
      
      to appear in kernel logs.
      
      So change d_obtain_alias() to use "/" rather than "" as the anonymous
      name.
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      b911a6bd
    • Alessio Igor Bogani's avatar
      vfs: Remove useless function prototypes · 47166739
      Alessio Igor Bogani authored
      Commit 8e22cc88 removes the (un)lock_super
      function definitions but forgets to remove their prototypes.
      Signed-off-by: default avatarAlessio Igor Bogani <abogani@kernel.org>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      47166739
    • Marco Stornelli's avatar
      documentation: drop vmtruncate · b9f61c3c
      Marco Stornelli authored
      Removed vmtruncate
      Signed-off-by: default avatarMarco Stornelli <marco.stornelli@gmail.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      b9f61c3c
    • Marco Stornelli's avatar
      mm: drop vmtruncate · 7898575f
      Marco Stornelli authored
      Removed vmtruncate
      Signed-off-by: default avatarMarco Stornelli <marco.stornelli@gmail.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      7898575f
    • Marco Stornelli's avatar
      vfs: drop vmtruncate · d30357f2
      Marco Stornelli authored
      Removed vmtruncate
      Signed-off-by: default avatarMarco Stornelli <marco.stornelli@gmail.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      d30357f2
    • Marco Stornelli's avatar
      ntfs: drop vmtruncate · 9014da75
      Marco Stornelli authored
      Removed vmtruncate
      Signed-off-by: default avatarMarco Stornelli <marco.stornelli@gmail.com>
      Reviewed-by: default avatarAnton Altaparmakov <anton@tuxera.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      9014da75
    • Marco Stornelli's avatar
      nilfs2: drop vmtruncate · 2d1b399b
      Marco Stornelli authored
      Removed vmtruncate
      Signed-off-by: default avatarMarco Stornelli <marco.stornelli@gmail.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      2d1b399b
    • Marco Stornelli's avatar
      ncpfs: drop vmtruncate · 3e7a8069
      Marco Stornelli authored
      Removed vmtruncate
      Signed-off-by: default avatarMarco Stornelli <marco.stornelli@gmail.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      3e7a8069
    • Marco Stornelli's avatar
      minix: drop vmtruncate · 7fc7cd00
      Marco Stornelli authored
      Removed vmtruncate
      Signed-off-by: default avatarMarco Stornelli <marco.stornelli@gmail.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      7fc7cd00
    • Marco Stornelli's avatar
      logfs: drop vmtruncate · 5dfc2821
      Marco Stornelli authored
      Removed vmtruncate
      Signed-off-by: default avatarMarco Stornelli <marco.stornelli@gmail.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      5dfc2821
    • Marco Stornelli's avatar
      hfsplus: drop vmtruncate · d5068485
      Marco Stornelli authored
      Removed vmtruncate
      Signed-off-by: default avatarMarco Stornelli <marco.stornelli@gmail.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      d5068485
    • Marco Stornelli's avatar
      jfs: drop vmtruncate · 86dd07d6
      Marco Stornelli authored
      Removed vmtruncate
      Signed-off-by: default avatarMarco Stornelli <marco.stornelli@gmail.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      86dd07d6
    • Marco Stornelli's avatar
      hpfs: drop vmtruncate · 70b31c4c
      Marco Stornelli authored
      Removed vmtruncate
      Signed-off-by: default avatarMarco Stornelli <marco.stornelli@gmail.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      70b31c4c
    • David Howells's avatar
      FS-Cache: Clear remaining page count on retrieval cancellation · 91c7fbbf
      David Howells authored
      Provide fscache_cancel_op() with a pointer to a function it should invoke under
      lock if it cancels an operation.
      
      Use this to clear the remaining page count upon cancellation of a pending
      retrieval operation so that fscache_release_retrieval_op() doesn't get an
      assertion failure (see below).  This can happen when a signal occurs, say from
      CTRL-C being pressed during data retrieval.
      
      FS-Cache: Assertion failed
      3 == 0 is false
      ------------[ cut here ]------------
      kernel BUG at fs/fscache/page.c:237!
      invalid opcode: 0000 [#641] SMP
      Modules linked in: cachefiles(F) nfsv4(F) nfsv3(F) nfsv2(F) nfs(F) fscache(F) auth_rpcgss(F) nfs_acl(F) lockd(F) sunrpc(F)
      CPU 0
      Pid: 6075, comm: slurp-q Tainted: GF     D      3.7.0-rc8-fsdevel+ #411                  /DG965RY
      RIP: 0010:[<ffffffffa007f328>]  [<ffffffffa007f328>] fscache_release_retrieval_op+0x75/0xff [fscache]
      RSP: 0000:ffff88001c6d7988  EFLAGS: 00010296
      RAX: 000000000000000f RBX: ffff880014cdfe00 RCX: ffffffff6c102000
      RDX: ffffffff8102d1ad RSI: ffffffff6c102000 RDI: ffffffff8102d1d6
      RBP: ffff88001c6d7998 R08: 0000000000000002 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000000 R12: 00000000fffffe00
      R13: ffff88001c6d7ab4 R14: ffff88001a8638a0 R15: ffff88001552b190
      FS:  00007f877aaf0700(0000) GS:ffff88003bc00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
      CR2: 00007fff11378fd2 CR3: 000000001c6c6000 CR4: 00000000000007f0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
      Process slurp-q (pid: 6075, threadinfo ffff88001c6d6000, task ffff88001c6c4080)
      Stack:
       ffffffffa007ec07 ffff880014cdfe00 ffff88001c6d79c8 ffffffffa007db4d
       ffffffffa007ec07 ffff880014cdfe00 00000000fffffe00 ffff88001c6d7ab4
       ffff88001c6d7a38 ffffffffa008116d 0000000000000000 ffff88001c6c4080
      Call Trace:
       [<ffffffffa007ec07>] ? fscache_cancel_op+0x194/0x1cf [fscache]
       [<ffffffffa007db4d>] fscache_put_operation+0x135/0x2ed [fscache]
       [<ffffffffa007ec07>] ? fscache_cancel_op+0x194/0x1cf [fscache]
       [<ffffffffa008116d>] __fscache_read_or_alloc_pages+0x413/0x4bc [fscache]
       [<ffffffff810ac8ae>] ? __alloc_pages_nodemask+0x195/0x75c
       [<ffffffffa00aab0f>] __nfs_readpages_from_fscache+0x86/0x13d [nfs]
       [<ffffffffa00a5fe0>] nfs_readpages+0x186/0x1bd [nfs]
       [<ffffffff810d23c8>] ? alloc_pages_current+0xc7/0xe4
       [<ffffffff810a68b5>] ? __page_cache_alloc+0x84/0x91
       [<ffffffff810af912>] ? __do_page_cache_readahead+0xa6/0x2e0
       [<ffffffff810afaa3>] __do_page_cache_readahead+0x237/0x2e0
       [<ffffffff810af912>] ? __do_page_cache_readahead+0xa6/0x2e0
       [<ffffffff810afe3e>] ra_submit+0x1c/0x20
       [<ffffffff810b019b>] ondemand_readahead+0x359/0x382
       [<ffffffff810b0279>] page_cache_sync_readahead+0x38/0x3a
       [<ffffffff810a77b5>] generic_file_aio_read+0x26b/0x637
       [<ffffffffa00f1852>] ? nfs_mark_delegation_referenced+0xb/0xb [nfsv4]
       [<ffffffffa009cc85>] nfs_file_read+0xaa/0xcf [nfs]
       [<ffffffff810db5b3>] do_sync_read+0x91/0xd1
       [<ffffffff810dbb8b>] vfs_read+0x9b/0x144
       [<ffffffff810dbc78>] sys_read+0x44/0x75
       [<ffffffff81422892>] system_call_fastpath+0x16/0x1b
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      91c7fbbf
    • David Howells's avatar
      FS-Cache: Mark cancellation of in-progress operation · 1f372dff
      David Howells authored
      Mark as cancelled an operation that is in progress rather than pending at the
      time it is cancelled, and call fscache_complete_op() to cancel an operation so
      that blocked ops can be started.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      1f372dff
    • David Howells's avatar
      FS-Cache: One of the write operation paths doesn't set the object state · 7ef001e9
      David Howells authored
      In fscache_write_op(), if the object is determined to have become inactive or
      to have lost its cookie, we don't move the operation state from in-progress,
      and so an assertion in fscache_put_operation() fails with an assertion (see
      below).
      
      Instrumenting fscache_op_work_func() indicates that it called
      fscache_write_op() before calling fscache_put_operation() - where the assertion
      failed.  The assertion at line 433 indicates that the operation state is
      IN_PROGRESS rather than being COMPLETE or CANCELLED.
      
      Instrumenting fscache_write_op() showed that it was being called on an object
      that had had its cookie removed and that this was due to relinquishment of the
      cookie by the netfs.  At this point fscache no longer has access to the pages
      of netfs data that were requested to be written, and so simply cancelling the
      operation is the thing to do.
      
      FS-Cache: Assertion failed
      3 == 5 is false
      ------------[ cut here ]------------
      kernel BUG at fs/fscache/operation.c:433!
      invalid opcode: 0000 [#1] SMP
      Modules linked in: cachefiles(F) nfsv4(F) nfsv3(F) nfsv2(F) nfs(F) fscache(F) auth_rpcgss(F) nfs_acl(F) lockd(F) sunrpc(F)
      CPU 0
      Pid: 1035, comm: kworker/u:3 Tainted: GF            3.7.0-rc8-fsdevel+ #411                  /DG965RY
      RIP: 0010:[<ffffffffa007db22>]  [<ffffffffa007db22>] fscache_put_operation+0x11a/0x2ed [fscache]
      RSP: 0018:ffff88003e32bcf8  EFLAGS: 00010296
      RAX: 000000000000000f RBX: ffff88001818eb78 RCX: ffffffff6c102000
      RDX: ffffffff8102d1ad RSI: ffffffff6c102000 RDI: ffffffff8102d1d6
      RBP: ffff88003e32bd18 R08: 0000000000000002 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000000 R12: ffffffffa00811da
      R13: 0000000000000001 R14: 0000000100625d26 R15: 0000000000000000
      FS:  0000000000000000(0000) GS:ffff88003bc00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
      CR2: 00007fff7dd31c68 CR3: 000000003d730000 CR4: 00000000000007f0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
      Process kworker/u:3 (pid: 1035, threadinfo ffff88003e32a000, task ffff88003bb38080)
      Stack:
       ffffffff8102d1ad ffff88001818eb78 ffffffffa00811da 0000000000000001
       ffff88003e32bd48 ffffffffa007f0ad ffff88001818eb78 ffffffff819583c0
       ffff88003df24e00 ffff88003882c3e0 ffff88003e32bde8 ffffffff81042de0
      Call Trace:
       [<ffffffff8102d1ad>] ? vprintk_emit+0x3c6/0x41a
       [<ffffffffa00811da>] ? __fscache_read_or_alloc_pages+0x4bc/0x4bc [fscache]
       [<ffffffffa007f0ad>] fscache_op_work_func+0xec/0x123 [fscache]
       [<ffffffff81042de0>] process_one_work+0x21c/0x3b0
       [<ffffffff81042d82>] ? process_one_work+0x1be/0x3b0
       [<ffffffffa007efc1>] ? fscache_operation_gc+0x23e/0x23e [fscache]
       [<ffffffff8104332e>] worker_thread+0x202/0x2df
       [<ffffffff8104312c>] ? rescuer_thread+0x18e/0x18e
       [<ffffffff81047c1c>] kthread+0xd0/0xd8
       [<ffffffff81421bfa>] ? _raw_spin_unlock_irq+0x29/0x3e
       [<ffffffff81047b4c>] ? __init_kthread_worker+0x55/0x55
       [<ffffffff814227ec>] ret_from_fork+0x7c/0xb0
       [<ffffffff81047b4c>] ? __init_kthread_worker+0x55/0x55
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      7ef001e9
    • David Howells's avatar
      FS-Cache: Fix signal handling during waits · 9c04caa8
      David Howells authored
      wait_on_bit() with TASK_INTERRUPTIBLE returns 1 rather than a negative error
      code, so change what we check for.  This means that the signal handling in
      fscache_wait_for_retrieval_activation()  should now work properly.
      
      Without this, the following bug can be seen if CTRL-C is pressed during
      fscache read operation:
      
      FS-Cache: Assertion failed
      2 == 3 is false
      ------------[ cut here ]------------
      kernel BUG at fs/fscache/page.c:347!
      invalid opcode: 0000 [#1] SMP
      Modules linked in: cachefiles(F) nfsv4(F) nfsv3(F) nfsv2(F) nfs(F) fscache(F) auth_rpcgss(F) nfs_acl(F) lockd(F) sunrpc(F)
      CPU 1
      Pid: 15006, comm: slurp-q Tainted: GF            3.7.0-rc8-fsdevel+ #411                  /DG965RY
      RIP: 0010:[<ffffffffa007fcb4>]  [<ffffffffa007fcb4>] fscache_wait_for_retrieval_activation+0x167/0x177 [fscache]
      RSP: 0018:ffff88002a4c39a8  EFLAGS: 00010292
      RAX: 000000000000001a RBX: ffff88002d3dc158 RCX: 0000000000008685
      RDX: ffffffff8102ccd6 RSI: 0000000000000001 RDI: ffffffff8102d1d6
      RBP: ffff88002a4c39c8 R08: 0000000000000002 R09: 0000000000000000
      R10: ffffffff8163afa0 R11: ffff88003bd11900 R12: ffffffffa00868c8
      R13: ffff880028306458 R14: ffff88002d3dc1b0 R15: ffff88001372e538
      FS:  00007f17426a0700(0000) GS:ffff88003bd00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
      CR2: 00007f1742494a44 CR3: 0000000031bd7000 CR4: 00000000000007e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
      Process slurp-q (pid: 15006, threadinfo ffff88002a4c2000, task ffff880023de3040)
      Stack:
       ffff88002d3dc158 ffff88001372e538 ffff88002a4c3ab4 ffff8800283064e0
       ffff88002a4c3a38 ffffffffa0080f6d 0000000000000000 ffff880023de3040
       ffff88002a4c3ac8 ffffffff810ac8ae ffff880028306458 ffff88002a4c3bc8
      Call Trace:
       [<ffffffffa0080f6d>] __fscache_read_or_alloc_pages+0x24f/0x4bc [fscache]
       [<ffffffff810ac8ae>] ? __alloc_pages_nodemask+0x195/0x75c
       [<ffffffffa00aab0f>] __nfs_readpages_from_fscache+0x86/0x13d [nfs]
       [<ffffffffa00a5fe0>] nfs_readpages+0x186/0x1bd [nfs]
       [<ffffffff810d23c8>] ? alloc_pages_current+0xc7/0xe4
       [<ffffffff810a68b5>] ? __page_cache_alloc+0x84/0x91
       [<ffffffff810af912>] ? __do_page_cache_readahead+0xa6/0x2e0
       [<ffffffff810afaa3>] __do_page_cache_readahead+0x237/0x2e0
       [<ffffffff810af912>] ? __do_page_cache_readahead+0xa6/0x2e0
       [<ffffffff810afe3e>] ra_submit+0x1c/0x20
       [<ffffffff810b019b>] ondemand_readahead+0x359/0x382
       [<ffffffff810b0279>] page_cache_sync_readahead+0x38/0x3a
       [<ffffffff810a77b5>] generic_file_aio_read+0x26b/0x637
       [<ffffffffa00f1852>] ? nfs_mark_delegation_referenced+0xb/0xb [nfsv4]
       [<ffffffffa009cc85>] nfs_file_read+0xaa/0xcf [nfs]
       [<ffffffff810db5b3>] do_sync_read+0x91/0xd1
       [<ffffffff810dbb8b>] vfs_read+0x9b/0x144
       [<ffffffff810dbc78>] sys_read+0x44/0x75
       [<ffffffff81422892>] system_call_fastpath+0x16/0x1b
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      9c04caa8
    • David Howells's avatar
      NFS4: Open files for fscaching · a4ff1468
      David Howells authored
      nfs4_file_open() should open files for fscaching.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      a4ff1468
    • David Howells's avatar
      FS-Cache: Add transition to handle invalidate immediately after lookup · 96969521
      David Howells authored
      Add a missing transition to the FS-Cache object state machine to handle an
      invalidation event occuring between the back end completing the object lookup
      by calling fscache_obtained_object() (which moves to state OBJECT_AVAILABLE)
      and the backend returning to fscache_lookup_object() and thence to
      fscache_object_state_machine() which then does a goto lookup_transit to handle
      the transition - but lookup_transit doesn't handle EV_INVALIDATE.
      
      Without this, the following BUG can be logged:
      
      	FS-Cache: Unsupported event 2 [5/f7] in state OBJECT_AVAILABLE
      	------------[ cut here ]------------
      	kernel BUG at fs/fscache/object.c:357!
      
      Where event 2 is EV_INVALIDATE.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      96969521
    • David Howells's avatar
      NFS: nfs_migrate_page() does not wait for FS-Cache to finish with a page · 8c209ce7
      David Howells authored
      nfs_migrate_page() does not wait for FS-Cache to finish with a page, probably
      leading to the following bad-page-state:
      
       BUG: Bad page state in process python-bin  pfn:17d39b
       page:ffffea00053649e8 flags:004000000000100c count:0 mapcount:0 mapping:(null)
      index:38686 (Tainted: G    B      ---------------- )
       Pid: 31053, comm: python-bin Tainted: G    B      ----------------
      2.6.32-71.24.1.el6.x86_64 #1
       Call Trace:
       [<ffffffff8111bfe7>] bad_page+0x107/0x160
       [<ffffffff8111ee69>] free_hot_cold_page+0x1c9/0x220
       [<ffffffff8111ef19>] __pagevec_free+0x59/0xb0
       [<ffffffff8104b988>] ? flush_tlb_others_ipi+0x128/0x130
       [<ffffffff8112230c>] release_pages+0x21c/0x250
       [<ffffffff8115b92a>] ? remove_migration_pte+0x28a/0x2b0
       [<ffffffff8115f3f8>] ? mem_cgroup_get_reclaim_stat_from_page+0x18/0x70
       [<ffffffff81122687>] ____pagevec_lru_add+0x167/0x180
       [<ffffffff811226f8>] __lru_cache_add+0x58/0x70
       [<ffffffff81122731>] lru_cache_add_lru+0x21/0x40
       [<ffffffff81123f49>] putback_lru_page+0x69/0x100
       [<ffffffff8115c0bd>] migrate_pages+0x13d/0x5d0
       [<ffffffff81122687>] ? ____pagevec_lru_add+0x167/0x180
       [<ffffffff81152ab0>] ? compaction_alloc+0x0/0x370
       [<ffffffff8115255c>] compact_zone+0x4cc/0x600
       [<ffffffff8111cfac>] ? get_page_from_freelist+0x15c/0x820
       [<ffffffff810672f4>] ? check_preempt_wakeup+0x1c4/0x3c0
       [<ffffffff8115290e>] compact_zone_order+0x7e/0xb0
       [<ffffffff81152a49>] try_to_compact_pages+0x109/0x170
       [<ffffffff8111e94d>] __alloc_pages_nodemask+0x5ed/0x850
       [<ffffffff814c9136>] ? thread_return+0x4e/0x778
       [<ffffffff81150d43>] alloc_pages_vma+0x93/0x150
       [<ffffffff81167ea5>] do_huge_pmd_anonymous_page+0x135/0x340
       [<ffffffff814cb6f6>] ? rwsem_down_read_failed+0x26/0x30
       [<ffffffff81136755>] handle_mm_fault+0x245/0x2b0
       [<ffffffff814ce383>] do_page_fault+0x123/0x3a0
       [<ffffffff814cbdf5>] page_fault+0x25/0x30
      
      nfs_migrate_page() calls nfs_fscache_release_page() which doesn't actually wait
      - even if __GFP_WAIT is set.  The reason that doesn't wait is that
      fscache_maybe_release_page() might deadlock the allocator as the work threads
      writing to the cache may all end up sleeping on memory allocation.
      
      However, I wonder if that is actually a problem.  There are a number of things
      I can do to deal with this:
      
       (1) Make nfs_migrate_page() wait.
      
       (2) Make fscache_maybe_release_page() honour the __GFP_WAIT flag.
      
       (3) Set a timeout around the wait.
      
       (4) Make nfs_migrate_page() return an error if the page is still busy.
      
      For the moment, I'll select (2) and (4).
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarJeff Layton <jlayton@redhat.com>
      8c209ce7
    • David Howells's avatar
      FS-Cache: Exclusive op submission can BUG if there's been an I/O error · 8d76349d
      David Howells authored
      The function to submit an exclusive op (fscache_submit_exclusive_op()) can BUG
      if there's been an I/O error because it may see the parent cache object in an
      unexpected state.  It should only BUG if there hasn't been an I/O error.
      
      In this case the problem was produced by remounting the cache partition to be
      R/O.  The EROFS state was detected and the cache was aborted, but not
      everything handled the aborting correctly.
      
      SysRq : Emergency Remount R/O
      EXT4-fs (sda6): re-mounted. Opts: (null)
      Emergency Remount complete
      CacheFiles: I/O Error: Failed to update xattr with error -30
      FS-Cache: Cache cachefiles stopped due to I/O error
      ------------[ cut here ]------------
      kernel BUG at fs/fscache/operation.c:128!
      invalid opcode: 0000 [#1] SMP 
      CPU 0 
      Modules linked in: cachefiles nfs fscache auth_rpcgss nfs_acl lockd sunrpc
      
      Pid: 6612, comm: kworker/u:2 Not tainted 3.1.0-rc8-fsdevel+ #1093                  /DG965RY
      RIP: 0010:[<ffffffffa00739c0>]  [<ffffffffa00739c0>] fscache_submit_exclusive_op+0x2ad/0x2c2 [fscache]
      RSP: 0018:ffff880000853d40  EFLAGS: 00010206
      RAX: ffff880038ac72a8 RBX: ffff8800181f2260 RCX: ffffffff81f2b2b0
      RDX: 0000000000000001 RSI: ffffffff8179a478 RDI: ffff8800181f2280
      RBP: ffff880000853d60 R08: 0000000000000002 R09: 0000000000000000
      R10: 0000000000000001 R11: 0000000000000001 R12: ffff880038ac7268
      R13: ffff8800181f2280 R14: ffff88003a359190 R15: 000000010122b162
      FS:  0000000000000000(0000) GS:ffff88003bc00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
      CR2: 00000034cc4a77f0 CR3: 0000000010e96000 CR4: 00000000000006f0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
      Process kworker/u:2 (pid: 6612, threadinfo ffff880000852000, task ffff880014c3c040)
      Stack:
       ffff8800181f2260 ffff8800181f2310 ffff880038ac7268 ffff8800181f2260
       ffff880000853dc0 ffffffffa0072375 ffff880037ecfe00 ffff88003a359198
       ffff880000853dc0 0000000000000246 0000000000000000 ffff88000a91d308
      Call Trace:
       [<ffffffffa0072375>] fscache_object_work_func+0x792/0xe65 [fscache]
       [<ffffffff81047e44>] process_one_work+0x1eb/0x37f
       [<ffffffff81047de6>] ? process_one_work+0x18d/0x37f
       [<ffffffffa0071be3>] ? fscache_enqueue_dependents+0xd8/0xd8 [fscache]
       [<ffffffff810482e4>] worker_thread+0x15a/0x21a
       [<ffffffff8104818a>] ? rescuer_thread+0x188/0x188
       [<ffffffff8104bf96>] kthread+0x7f/0x87
       [<ffffffff813ad6f4>] kernel_thread_helper+0x4/0x10
       [<ffffffff81026b98>] ? finish_task_switch+0x45/0xc0
       [<ffffffff813abd1d>] ? retint_restore_args+0xe/0xe
       [<ffffffff8104bf17>] ? __init_kthread_worker+0x53/0x53
       [<ffffffff813ad6f0>] ? gs_change+0xb/0xb
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      8d76349d
    • David Howells's avatar
      FS-Cache: Limit the number of I/O error reports for a cache · 75bc4113
      David Howells authored
      Limit the number of I/O error reports for a cache to 1 to prevent massive
      amounts of noise.  After the first I/O error the cache is taken off line
      automatically, so must be restarted to resume caching.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      75bc4113
    • David Howells's avatar
      FS-Cache: Don't mask off the object event mask when printing it · c2d35bfe
      David Howells authored
      Don't mask off the object event mask when printing it.  That way it can be seen
      if threre are bits set that shouldn't be.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      c2d35bfe
    • David Howells's avatar
      FS-Cache: Initialise the object event mask with the calculated mask · 03acc4be
      David Howells authored
      Initialise the object event mask with the calculated mask rather than unmasking
      undefined events also.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      03acc4be
    • David Howells's avatar
      FS-Cache: Convert the object event ID #defines into an enum · 36a02de5
      David Howells authored
      Convert the fscache_object event IDs from #defines into an enum.  Also add an
      extra label to the enum to carry the event count and redefine the event mask
      in terms of that.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      36a02de5
    • David Howells's avatar
      CacheFiles: Add missing retrieval completions · b4cf1e08
      David Howells authored
      CacheFiles is missing some calls to fscache_retrieval_complete() in the error
      handling/collision paths of its reader functions.
      
      This can be seen by the following assertion tripping in fscache_put_operation()
      whereby the operation being destroyed is still in the in-progress state and has
      not been cancelled or completed:
      
      FS-Cache: Assertion failed
      3 == 5 is false
      ------------[ cut here ]------------
      kernel BUG at fs/fscache/operation.c:408!
      invalid opcode: 0000 [#1] SMP
      CPU 2
      Modules linked in: xfs ioatdma dca loop joydev evdev
      psmouse dcdbas pcspkr serio_raw i5000_edac edac_core i5k_amb shpchp
      pci_hotplug sg sr_mod]
      
      Pid: 8062, comm: httpd Not tainted 3.1.0-rc8 #1 Dell Inc. PowerEdge 1950/0DT097
      RIP: 0010:[<ffffffff81197b24>]  [<ffffffff81197b24>] fscache_put_operation+0x304/0x330
      RSP: 0018:ffff880062f739d8  EFLAGS: 00010296
      RAX: 0000000000000025 RBX: ffff8800c5122e84 RCX: ffffffff81ddf040
      RDX: 00000000ffffffff RSI: 0000000000000082 RDI: ffffffff81ddef30
      RBP: ffff880062f739f8 R08: 0000000000000005 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000003 R12: ffff8800c5122e40
      R13: ffff880037a2cd20 R14: ffff880087c7a058 R15: ffff880087c7a000
      FS:  00007f63dcf636e0(0000) GS:ffff88022fc80000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007f0c0a91f000 CR3: 0000000062ec2000 CR4: 00000000000006e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
      Process httpd (pid: 8062, threadinfo ffff880062f72000, task ffff880087e58000)
      Stack:
       ffff880062f73bf8 0000000000000000 ffff880062f73bf8 ffff880037a2cd20
       ffff880062f73a68 ffffffff8119aa7e ffff88006540e000 ffff880062f73ad4
       ffff88008e9a4308 ffff880037a2cd20 ffff880062f73a48 ffff8800c5122e40
      Call Trace:
       [<ffffffff8119aa7e>] __fscache_read_or_alloc_pages+0x1fe/0x530
       [<ffffffff81250780>] __nfs_readpages_from_fscache+0x70/0x1c0
       [<ffffffff8123142a>] nfs_readpages+0xca/0x1e0
       [<ffffffff815f3c06>] ? rpc_do_put_task+0x36/0x50
       [<ffffffff8122755b>] ? alloc_nfs_open_context+0x4b/0x110
       [<ffffffff815ecd1a>] ? rpc_call_sync+0x5a/0x70
       [<ffffffff810e7e9a>] __do_page_cache_readahead+0x1ca/0x270
       [<ffffffff810e7f61>] ra_submit+0x21/0x30
       [<ffffffff810e818d>] ondemand_readahead+0x11d/0x250
       [<ffffffff810e83b6>] page_cache_sync_readahead+0x36/0x60
       [<ffffffff810dffa4>] generic_file_aio_read+0x454/0x770
       [<ffffffff81224ce1>] nfs_file_read+0xe1/0x130
       [<ffffffff81121bd9>] do_sync_read+0xd9/0x120
       [<ffffffff8114088f>] ? mntput+0x1f/0x40
       [<ffffffff811238cb>] ? fput+0x1cb/0x260
       [<ffffffff81122938>] vfs_read+0xc8/0x180
       [<ffffffff81122af5>] sys_read+0x55/0x90
      Reported-by: default avatarMark Moseley <moseleymark@gmail.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      b4cf1e08
    • David Howells's avatar
      NFS: Use FS-Cache invalidation · de242c0b
      David Howells authored
      Use the new FS-Cache invalidation facility from NFS to deal with foreign
      changes being detected on the server rather than attempting to retire the old
      cookie and get a new one.
      
      The problem with the old method was that NFS did not wait for all outstanding
      storage and retrieval ops on the cache to complete.  There was no automatic
      wait between the calls to ->readpages() and calls to invalidate_inode_pages2()
      as the latter can only wait on locked pages that have been added to the
      pagecache (which they haven't yet on entry to ->readpages()).
      
      This was leading to oopses like the one below when an outstanding read got cut
      off from its cookie by a premature release.
      
      BUG: unable to handle kernel NULL pointer dereference at 00000000000000a8
      IP: [<ffffffffa0075118>] __fscache_read_or_alloc_pages+0x1dd/0x315 [fscache]
      PGD 15889067 PUD 15890067 PMD 0
      Oops: 0000 [#1] SMP
      CPU 0
      Modules linked in: cachefiles nfs fscache auth_rpcgss nfs_acl lockd sunrpc
      
      Pid: 4544, comm: tar Not tainted 3.1.0-rc4-fsdevel+ #1064                  /DG965RY
      RIP: 0010:[<ffffffffa0075118>]  [<ffffffffa0075118>] __fscache_read_or_alloc_pages+0x1dd/0x315 [fscache]
      RSP: 0018:ffff8800158799e8  EFLAGS: 00010246
      RAX: 0000000000000000 RBX: ffff8800070d41e0 RCX: ffff8800083dc1b0
      RDX: 0000000000000000 RSI: ffff880015879960 RDI: ffff88003e627b90
      RBP: ffff880015879a28 R08: 0000000000000002 R09: 0000000000000002
      R10: 0000000000000001 R11: ffff880015879950 R12: ffff880015879aa4
      R13: 0000000000000000 R14: ffff8800083dc158 R15: ffff880015879be8
      FS:  00007f671e9d87c0(0000) GS:ffff88003bc00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
      CR2: 00000000000000a8 CR3: 000000001587f000 CR4: 00000000000006f0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
      Process tar (pid: 4544, threadinfo ffff880015878000, task ffff880015875040)
      Stack:
       ffffffffa00b1759 ffff8800070dc158 ffff8800000213da ffff88002a286508
       ffff880015879aa4 ffff880015879be8 0000000000000001 ffff88002a2866e8
       ffff880015879a88 ffffffffa00b20be 00000000000200da ffff880015875040
      Call Trace:
       [<ffffffffa00b1759>] ? nfs_fscache_wait_bit+0xd/0xd [nfs]
       [<ffffffffa00b20be>] __nfs_readpages_from_fscache+0x7e/0x13f [nfs]
       [<ffffffff81095fe7>] ? __alloc_pages_nodemask+0x156/0x662
       [<ffffffffa0098763>] nfs_readpages+0xee/0x187 [nfs]
       [<ffffffff81098a5e>] __do_page_cache_readahead+0x1be/0x267
       [<ffffffff81098942>] ? __do_page_cache_readahead+0xa2/0x267
       [<ffffffff81098d7b>] ra_submit+0x1c/0x20
       [<ffffffff8109900a>] ondemand_readahead+0x28b/0x29a
       [<ffffffff810990ce>] page_cache_sync_readahead+0x38/0x3a
       [<ffffffff81091d8a>] generic_file_aio_read+0x2ab/0x67e
       [<ffffffffa008cfbe>] nfs_file_read+0xa4/0xc9 [nfs]
       [<ffffffff810c22c4>] do_sync_read+0xba/0xfa
       [<ffffffff810a62c9>] ? might_fault+0x4e/0x9e
       [<ffffffff81177a47>] ? security_file_permission+0x7b/0x84
       [<ffffffff810c25dd>] ? rw_verify_area+0xab/0xc8
       [<ffffffff810c29a4>] vfs_read+0xaa/0x13a
       [<ffffffff810c2a79>] sys_read+0x45/0x6c
       [<ffffffff813ac37b>] system_call_fastpath+0x16/0x1b
      Reported-by: default avatarMark Moseley <moseleymark@gmail.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      de242c0b