1. 10 4月, 2018 3 次提交
    • D
      afs: Prospectively look up extra files when doing a single lookup · 5cf9dd55
      David Howells 提交于
      When afs_lookup() is called, prospectively look up the next 50 uncached
      fids also from that same directory and cache the results, rather than just
      looking up the one file requested.
      
      This allows us to use the FS.InlineBulkStatus RPC op to increase efficiency
      by fetching up to 50 file statuses at a time.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      5cf9dd55
    • D
      afs: Don't over-increment the cell usage count when pinning it · 17814aef
      David Howells 提交于
      AFS cells that are added or set as the workstation cell through /proc are
      pinned against removal by setting the AFS_CELL_FL_NO_GC flag on them and
      taking a ref.  The ref should be only taken if the flag wasn't already set.
      
      Fix this by making it conditional.
      
      Without this an assertion failure will occur during module removal
      indicating that the refcount is too elevated.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      17814aef
    • D
      afs: Fix checker warnings · fe342cf7
      David Howells 提交于
      Fix warnings raised by checker, including:
      
       (*) Warnings raised by unequal comparison for the purposes of sorting,
           where the endianness doesn't matter:
      
      fs/afs/addr_list.c:246:21: warning: restricted __be16 degrades to integer
      fs/afs/addr_list.c:246:30: warning: restricted __be16 degrades to integer
      fs/afs/addr_list.c:248:21: warning: restricted __be32 degrades to integer
      fs/afs/addr_list.c:248:49: warning: restricted __be32 degrades to integer
      fs/afs/addr_list.c:283:21: warning: restricted __be16 degrades to integer
      fs/afs/addr_list.c:283:30: warning: restricted __be16 degrades to integer
      
       (*) afs_set_cb_interest() is not actually used and can be removed.
      
       (*) afs_cell_gc_delay() should be provided with a sysctl.
      
       (*) afs_cell_destroy() needs to use rcu_access_pointer() to read
           cell->vl_addrs.
      
       (*) afs_init_fs_cursor() should be static.
      
       (*) struct afs_vnode::permit_cache needs to be marked __rcu.
      
       (*) afs_server_rcu() needs to use rcu_access_pointer().
      
       (*) afs_destroy_server() should use rcu_access_pointer() on
           server->addresses as the server object is no longer accessible.
      
       (*) afs_find_server() casts __be16/__be32 values to int in order to
           directly compare them for the purpose of finding a match in a list,
           but is should also annotate the cast with __force to avoid checker
           warnings.
      
       (*) afs_check_permit() accesses vnode->permit_cache outside of the RCU
           readlock, though it doesn't then access the value; the extraneous
           access is deleted.
      
      False positives:
      
       (*) Conditional locking around the code in xdr_decode_AFSFetchStatus.  This
           can be dealt with in a separate patch.
      
      fs/afs/fsclient.c:148:9: warning: context imbalance in 'xdr_decode_AFSFetchStatus' - different lock contexts for basic block
      
       (*) Incorrect handling of seq-retry lock context balance:
      
      fs/afs/inode.c:455:38: warning: context imbalance in 'afs_getattr' - different
      lock contexts for basic block
      fs/afs/server.c:52:17: warning: context imbalance in 'afs_find_server' - different lock contexts for basic block
      fs/afs/server.c:128:17: warning: context imbalance in 'afs_find_server_by_uuid' - different lock contexts for basic block
      
      Errors:
      
       (*) afs_lookup_cell_rcu() needs to break out of the seq-retry loop, not go
           round again if it successfully found the workstation cell.
      
       (*) Fix UUID decode in afs_deliver_cb_probe_uuid().
      
       (*) afs_cache_permit() has a missing rcu_read_unlock() before one of the
           jumps to the someone_else_changed_it label.  Move the unlock to after
           the label.
      
       (*) afs_vl_get_addrs_u() is using ntohl() rather than htonl() when
           encoding to XDR.
      
       (*) afs_deliver_yfsvl_get_endpoints() is using htonl() rather than ntohl()
           when decoding from XDR.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      fe342cf7
  2. 06 4月, 2018 1 次提交
  3. 04 4月, 2018 4 次提交
    • D
      fscache: Attach the index key and aux data to the cookie · 402cb8dd
      David Howells 提交于
      Attach copies of the index key and auxiliary data to the fscache cookie so
      that:
      
       (1) The callbacks to the netfs for this stuff can be eliminated.  This
           can simplify things in the cache as the information is still
           available, even after the cache has relinquished the cookie.
      
       (2) Simplifies the locking requirements of accessing the information as we
           don't have to worry about the netfs object going away on us.
      
       (3) The cache can do lazy updating of the coherency information on disk.
           As long as the cache is flushed before reboot/poweroff, there's no
           need to update the coherency info on disk every time it changes.
      
       (4) Cookies can be hashed or put in a tree as the index key is easily
           available.  This allows:
      
           (a) Checks for duplicate cookies can be made at the top fscache layer
           	 rather than down in the bowels of the cache backend.
      
           (b) Caching can be added to a netfs object that has a cookie if the
           	 cache is brought online after the netfs object is allocated.
      
      A certain amount of space is made in the cookie for inline copies of the
      data, but if it won't fit there, extra memory will be allocated for it.
      
      The downside of this is that live cache operation requires more memory.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Acked-by: NAnna Schumaker <anna.schumaker@netapp.com>
      Tested-by: NSteve Dickson <steved@redhat.com>
      402cb8dd
    • D
      afs: Be more aggressive in retiring cached vnodes · 678edd09
      David Howells 提交于
      When relinquishing cookies, either due to iget failure or to inode
      eviction, retire a cookie if we think the corresponding vnode got deleted
      on the server rather than just letting it lie in the cache.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      678edd09
    • D
      afs: Use the vnode ID uniquifier in the cache key not the aux data · 27a3ee3a
      David Howells 提交于
      AFS vnodes (files) are referenced by a triplet of { volume ID, vnode ID,
      uniquifier }.  Currently, kafs is only using the vnode ID as the file key
      in the volume fscache index and checking the uniquifier on cookie
      acquisition against the contents of the auxiliary data stored in the cache.
      
      Unfortunately, this is subject to a race in which an FS.RemoveFile or
      FS.RemoveDir op is issued against the server but the local afs inode isn't
      torn down and disposed off before another thread issues something like
      FS.CreateFile.  The latter then gets given the vnode ID that just got
      removed, but with a new uniquifier and a cookie collision occurs in the
      cache because the cookie is only keyed on the vnode ID whereas the inode is
      keyed on the vnode ID plus the uniquifier.
      
      Fix this by keying the cookie on the uniquifier in addition to the vnode ID
      and dropping the uniquifier from the auxiliary data supplied.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      27a3ee3a
    • D
      afs: Invalidate cache on server data change · c1515999
      David Howells 提交于
      Invalidate any data stored in fscache for a vnode that changes on the
      server so that we don't end up with the cache in a bad state locally.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      c1515999
  4. 28 3月, 2018 1 次提交
    • D
      rxrpc, afs: Use debug_ids rather than pointers in traces · a25e21f0
      David Howells 提交于
      In rxrpc and afs, use the debug_ids that are monotonically allocated to
      various objects as they're allocated rather than pointers as kernel
      pointers are now hashed making them less useful.  Further, the debug ids
      aren't reused anywhere nearly as quickly.
      
      In addition, allow kernel services that use rxrpc, such as afs, to take
      numbers from the rxrpc counter, assign them to their own call struct and
      pass them in to rxrpc for both client and service calls so that the trace
      lines for each will have the same ID tag.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      a25e21f0
  5. 20 3月, 2018 1 次提交
  6. 06 2月, 2018 7 次提交
    • D
      afs: Support the AFS dynamic root · 4d673da1
      David Howells 提交于
      Support the AFS dynamic root which is a pseudo-volume that doesn't connect
      to any server resource, but rather is just a root directory that
      dynamically creates mountpoint directories where the name of such a
      directory is the name of the cell.
      
      Such a mount can be created thus:
      
      	mount -t afs none /afs -o dyn
      
      Dynamic root superblocks aren't shared except by bind mounts and
      propagation.  Cell root volumes can then be mounted by referring to them by
      name, e.g.:
      
      	ls /afs/grand.central.org/
      	ls /afs/.grand.central.org/
      
      The kernel will upcall to consult the DNS if the address wasn't supplied
      directly.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      4d673da1
    • D
      afs: Rearrange afs_select_fileserver() a little · 16280a15
      David Howells 提交于
      Rearrange afs_select_fileserver() a little to put the use_server chunk
      before the next_server chunk so that with the removal of a couple of gotos
      the main path through the function is all one sequence.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      16280a15
    • D
      afs: Remove unused code · 63dc4e4a
      David Howells 提交于
      Remove some old unused code.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      63dc4e4a
    • D
      afs: Fix server list handling · 45df8462
      David Howells 提交于
      Fix server list handling in the following ways:
      
       (1) In afs_alloc_volume(), remove duplicate server list build code.  This
           was already done by afs_alloc_server_list() which afs_alloc_volume()
           previously called.  This just results in twice as many VL RPCs.
      
       (2) In afs_deliver_vl_get_entry_by_name_u(), use the number of server
           records indicated by ->nServers in the UVLDB record returned by the
           VL.GetEntryByNameU RPC call rather than scanning all NMAXNSERVERS
           slots.  Unused slots may contain garbage.
      
       (3) In afs_alloc_server_list(), don't stop converting a UVLDB record into
           a server list just because we can't look up one of the servers.  Just
           skip that server and go on to the next.  If we can't look up any of
           the servers then we'll fail at the end.
      
      Without this patch, an attempt to view the umich.edu root cell using
      something like "ls /afs/umich.edu" on a dynamic root (future patch) mount
      or an autocell mount will result in ENOMEDIUM.  The failure is due to kafs
      not stopping after nServers'worth of records have been read, but then
      trying to access a server with a garbage UUID and getting an error, which
      aborts the server list build.
      
      Fixes: d2ddc776 ("afs: Overhaul volume and server record caching and fileserver rotation")
      Reported-by: NJonathan Billings <jsbillings@jsbillings.org>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      cc: stable@vger.kernel.org
      45df8462
    • D
      afs: Need to clear responded flag in addr cursor · 8305e579
      David Howells 提交于
      In afs_select_fileserver(), we need to clear the ->responded flag in the
      address list when reusing it.  We should also clear it in
      afs_select_current_fileserver().
      
      To this end, just memset() the object before initialising it.
      
      Fixes: d2ddc776 ("afs: Overhaul volume and server record caching and fileserver rotation")
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      cc: stable@vger.kernel.org
      8305e579
    • D
      afs: Fix missing cursor clearance · fe4d774c
      David Howells 提交于
      afs_select_fileserver() ends the address cursor it is using in the case in
      which we get some sort of network error and run out of addresses to iterate
      through, before it jumps to try the next server.  This also needs to be
      done when the server aborts with some sort of error that means we should
      try the next server.
      
      Fix this by:
      
       (1) Move the iterate_address afs_end_cursor() call to the next_server
           case.
      
       (2) End the cursor in the failed case.
      
       (3) Make afs_end_cursor() clear the ->begun flag and ->addr pointer in the
           address cursor.
      
       (4) Make afs_end_cursor() able to be called on an already cleared cursor.
      
      Without this, something like the following oops may occur:
      
      	AFS: Assertion failed
      	18446612134397189888 == 0 is false
      	0xffff88007c279f00 == 0x0 is false
      	------------[ cut here ]------------
      	kernel BUG at fs/afs/rotate.c:360!
      	RIP: 0010:afs_select_fileserver+0x79b/0xa30 [kafs]
      	Call Trace:
      	 afs_statfs+0xcc/0x180 [kafs]
      	 ? p9_client_statfs+0x9e/0x110 [9pnet]
      	 ? _cond_resched+0x19/0x40
      	 statfs_by_dentry+0x6d/0x90
      	 vfs_statfs+0x1b/0xc0
      	 user_statfs+0x4b/0x80
      	 SYSC_statfs+0x15/0x30
      	 SyS_statfs+0xe/0x10
      	 entry_SYSCALL_64_fastpath+0x20/0x83
      
      Fixes: d2ddc776 ("afs: Overhaul volume and server record caching and fileserver rotation")
      Reported-by: NMarc Dionne <marc.dionne@auristor.com>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      cc: stable@vger.kernel.org
      fe4d774c
    • D
      afs: Add missing afs_put_cell() · e4415015
      David Howells 提交于
      afs_alloc_volume() needs to release the cell ref it obtained in the case of
      an error.  Fix this by adding an afs_put_cell() call into the error path.
      
      This can triggered when a lookup for a cell in a dynamic root or an
      autocell mount returns an error whilst trying to look up the server (such
      as ENOMEDIUM).  This results in an assertion failure oops when the module
      is unloaded due to outstanding refs on a cell record.
      
      Fixes: d2ddc776 ("afs: Overhaul volume and server record caching and fileserver rotation")
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      cc: stable@vger.kernel.org
      e4415015
  7. 29 1月, 2018 1 次提交
    • J
      afs: convert to new i_version API · a01179e6
      Jeff Layton 提交于
      For AFS, it's generally treated as an opaque value, so we use the
      *_raw variants of the API here.
      
      Note that AFS has quite a different definition for this counter. AFS
      only increments it on changes to the data to the data in regular files
      and contents of the directories. Inode metadata changes do not result
      in a version increment.
      
      We'll need to reconcile that somehow if we ever want to present this to
      userspace via statx.
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      a01179e6
  8. 02 1月, 2018 3 次提交
  9. 01 12月, 2017 2 次提交
    • D
      afs: Properly reset afs_vnode (inode) fields · f8de483e
      David Howells 提交于
      When an AFS inode is allocated by afs_alloc_inode(), the allocated
      afs_vnode struct isn't necessarily reset from the last time it was used as
      an inode because the slab constructor is only invoked once when the memory
      is obtained from the page allocator.
      
      This means that information can leak from one inode to the next because
      we're not calling kmem_cache_zalloc().  Some of the information isn't
      reset, in particular the permit cache pointer.
      
      Bring the clearances up to date.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Tested-by: NMarc Dionne <marc.dionne@auristor.com>
      f8de483e
    • D
      afs: Fix permit refcounting · 1bcab125
      David Howells 提交于
      Fix four refcount bugs in afs_cache_permit():
      
       (1) When checking the result of the kzalloc(), we can't just return, but
           must put 'permits'.
      
       (2) We shouldn't put permits immediately after hashing a new permit as we
           need to keep the pointer stable so that we can check to see if
           vnode->permit_cache has changed before we decide whether to assign to
           it.
      
       (3) 'permits' is being put twice.
      
       (4) We need to put either the replacement or the thing replaced after the
           assignment to vnode->permit_cache.
      
      Without this, lots of the following are seen:
      
        Kernel BUG at ffffffffa039857b [verbose debug info unavailable]
        ------------[ cut here ]------------
        Kernel BUG at ffffffffa039858a [verbose debug info unavailable]
        ------------[ cut here ]------------
      
      The addresses are in the .text..refcount section of the kafs.ko module.
      Following the relocation records for the __ex_table section shows one to be
      due to the decrement in afs_put_permits() and the other to be key_get() in
      afs_cache_permit().
      
      Occasionally, the following is seen:
      
        refcount_t overflow at afs_cache_permit+0x57d/0x5c0 [kafs] in cc1[562], uid/euid: 0/0
        WARNING: CPU: 0 PID: 562 at kernel/panic.c:657 refcount_error_report+0x9c/0xac
        ...
      Reported-by: NMarc Dionne <marc.dionne@auristor.com>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Tested-by: NMarc Dionne <marc.dionne@auristor.com>
      1bcab125
  10. 28 11月, 2017 1 次提交
    • L
      Rename superblock flags (MS_xyz -> SB_xyz) · 1751e8a6
      Linus Torvalds 提交于
      This is a pure automated search-and-replace of the internal kernel
      superblock flags.
      
      The s_flags are now called SB_*, with the names and the values for the
      moment mirroring the MS_* flags that they're equivalent to.
      
      Note how the MS_xyz flags are the ones passed to the mount system call,
      while the SB_xyz flags are what we then use in sb->s_flags.
      
      The script to do this was:
      
          # places to look in; re security/*: it generally should *not* be
          # touched (that stuff parses mount(2) arguments directly), but
          # there are two places where we really deal with superblock flags.
          FILES="drivers/mtd drivers/staging/lustre fs ipc mm \
                  include/linux/fs.h include/uapi/linux/bfs_fs.h \
                  security/apparmor/apparmorfs.c security/apparmor/include/lib.h"
          # the list of MS_... constants
          SYMS="RDONLY NOSUID NODEV NOEXEC SYNCHRONOUS REMOUNT MANDLOCK \
                DIRSYNC NOATIME NODIRATIME BIND MOVE REC VERBOSE SILENT \
                POSIXACL UNBINDABLE PRIVATE SLAVE SHARED RELATIME KERNMOUNT \
                I_VERSION STRICTATIME LAZYTIME SUBMOUNT NOREMOTELOCK NOSEC BORN \
                ACTIVE NOUSER"
      
          SED_PROG=
          for i in $SYMS; do SED_PROG="$SED_PROG -e s/MS_$i/SB_$i/g"; done
      
          # we want files that contain at least one of MS_...,
          # with fs/namespace.c and fs/pnode.c excluded.
          L=$(for i in $SYMS; do git grep -w -l MS_$i $FILES; done| sort|uniq|grep -v '^fs/namespace.c'|grep -v '^fs/pnode.c')
      
          for f in $L; do sed -i $f $SED_PROG; done
      Requested-by: NAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      1751e8a6
  11. 24 11月, 2017 5 次提交
    • C
      afs: remove redundant assignment of dvnode to itself · 43dd388b
      Colin Ian King 提交于
      The assignment of dvnode to itself is redundant and can be removed.
      Cleans up warning detected by cppcheck:
      
      fs/afs/dir.c:975: (warning) Redundant assignment of 'dvnode' to itself.
      
      Fixes: d2ddc776 ("afs: Overhaul volume and server record caching and fileserver rotation")
      Signed-off-by: NColin Ian King <colin.king@canonical.com>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      43dd388b
    • G
      afs: cell: Remove unnecessary code in afs_lookup_cell · 68327951
      Gustavo A. R. Silva 提交于
      Due to recent changes this piece of code is no longer needed.
      
      Addresses-Coverity-ID: 1462033
      Link: https://lkml.kernel.org/r/4923.1510957307@warthog.procyon.org.ukSigned-off-by: NGustavo A. R. Silva <garsilva@embeddedor.com>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      68327951
    • D
      afs: Fix signal handling in some file ops · 4433b691
      David Howells 提交于
      afs_mkdir(), afs_create(), afs_link() and afs_symlink() all need to drop
      the target dentry if a signal causes the operation to be killed immediately
      before we try to contact the server.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      4433b691
    • D
      afs: Fix some dentry handling in dir ops and missing key_puts · bc1527dc
      David Howells 提交于
      Fix some of dentry handling in AFS directory ops:
      
       (1) Do d_drop() on the new_dentry before assigning a new inode to it in
           afs_vnode_new_inode().  It's fine to do this before calling afs_iget()
           because the operation has taken place on the server.
      
       (2) Replace d_instantiate()/d_rehash() with d_add().
      
       (3) Don't d_drop() the new_dentry in afs_rename() on error.
      
      Also fix afs_link() and afs_rename() to call key_put() on all error paths
      where the key is taken.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      bc1527dc
    • D
      afs: Make afs_write_begin() avoid writing to a page that's being stored · 5a039c32
      David Howells 提交于
      Make afs_write_begin() wait for a page that's marked PG_writeback because:
      
       (1) We need to avoid interference with the data being stored so that the
           data on the server ends up in a defined state.
      
       (2) page->private is used to track the window of dirty data within a page,
           but it's also used by the storage code to track what's being written,
           being cleared by the completion notification.  Ownership can't be
           relinquished by the storage code until completion because it a store
           fails, the data must be remarked dirty.
      
      Tracing shows something like the following (edited):
      
       x86_64-linux-gn-15940 [1] afs_page_dirty: vn=ffff8800bef33800 9c75 begin 0-125
          kworker/u8:3-114   [2] afs_page_dirty: vn=ffff8800bef33800 9c75 store+ 0-125
       x86_64-linux-gn-15940 [1] afs_page_dirty: vn=ffff8800bef33800 9c75 begin 0-2052
          kworker/u8:3-114   [2] afs_page_dirty: vn=ffff8800bef33800 9c75 clear 0-2052
          kworker/u8:3-114   [2] afs_page_dirty: vn=ffff8800bef33800 9c75 store 0-0
          kworker/u8:3-114   [2] afs_page_dirty: vn=ffff8800bef33800 9c75 WARN 0-0
      
      The clear (completion) corresponding to the store+ (store continuation from
      a previous page) happens between the second begin (afs_write_begin) and the
      store corresponding to that.  This results in the second store not seeing
      any data to write back, leading to the following warning:
      
      WARNING: CPU: 2 PID: 114 at ../fs/afs/write.c:403 afs_write_back_from_locked_page+0x19d/0x76c [kafs]
      Modules linked in: kafs(E)
      CPU: 2 PID: 114 Comm: kworker/u8:3 Tainted: G            E   4.14.0-fscache+ #242
      Hardware name: ASUS All Series/H97-PLUS, BIOS 2306 10/09/2014
      Workqueue: writeback wb_workfn (flush-afs-2)
      task: ffff8800cad72600 task.stack: ffff8800cad44000
      RIP: 0010:afs_write_back_from_locked_page+0x19d/0x76c [kafs]
      RSP: 0018:ffff8800cad47aa0 EFLAGS: 00010246
      RAX: 0000000000000001 RBX: ffff8800bef33a20 RCX: 0000000000000000
      RDX: 000000000000000f RSI: ffffffff81c5d0e0 RDI: ffff8800cad72e78
      RBP: ffff8800d31ea1e8 R08: ffff8800c1358000 R09: ffff8800ca00e400
      R10: ffff8800cad47a38 R11: ffff8800c5d9e400 R12: 0000000000000000
      R13: ffffea0002d9df00 R14: ffffffffa0023c1c R15: 0000000000007fdf
      FS:  0000000000000000(0000) GS:ffff8800ca700000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007f85ac6c4000 CR3: 0000000001c10001 CR4: 00000000001606e0
      Call Trace:
       ? clear_page_dirty_for_io+0x23a/0x267
       afs_writepages_region+0x1be/0x286 [kafs]
       afs_writepages+0x60/0x127 [kafs]
       do_writepages+0x36/0x70
       __writeback_single_inode+0x12f/0x635
       writeback_sb_inodes+0x2cc/0x452
       __writeback_inodes_wb+0x68/0x9f
       wb_writeback+0x208/0x470
       ? wb_workfn+0x22b/0x565
       wb_workfn+0x22b/0x565
       ? worker_thread+0x230/0x2ac
       process_one_work+0x2cc/0x517
       ? worker_thread+0x230/0x2ac
       worker_thread+0x1d4/0x2ac
       ? rescuer_thread+0x29b/0x29b
       kthread+0x15d/0x165
       ? kthread_create_on_node+0x3f/0x3f
       ? call_usermodehelper_exec_async+0x118/0x11f
       ret_from_fork+0x24/0x30
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      5a039c32
  12. 17 11月, 2017 1 次提交
    • D
      afs: Fix file locking · 0fafdc9f
      David Howells 提交于
      Fix the AFS file locking whereby the use of the big kernel lock (which
      could be slept with) was replaced by a spinlock (which couldn't).  The
      problem is that the AFS code was doing stuff inside the critical section
      that might call schedule(), so this is a broken transformation.
      
      Fix this by the following means:
      
       (1) Use a state machine with a proper state that can only be changed under
           the spinlock rather than using a collection of bit flags.
      
       (2) Cache the key used for the lock and the lock type in the afs_vnode
           struct so that the manager work function doesn't have to refer to a
           file_lock struct that's been dequeued.  This makes signal handling
           safer.
      
       (4) Move the unlock from afs_do_unlk() to afs_fl_release_private() which
           means that unlock is achieved in other circumstances too.
      
       (5) Unlock the file on the server before taking the next conflicting lock.
      
      Also change:
      
       (1) Check the permits on a file before actually trying the lock.
      
       (2) fsync the file before effecting an explicit unlock operation.  We
           don't fsync if the lock is erased otherwise as we might not be in a
           context where we can actually do that.
      
      Further fixes:
      
       (1) Fixed-fileserver address rotation is made to work.  It's only used by
           the locking functions, so couldn't be tested before.
      
      Fixes: 72f98e72 ("locks: turn lock_flocks into a spinlock")
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      cc: jlayton@redhat.com
      0fafdc9f
  13. 16 11月, 2017 2 次提交
  14. 13 11月, 2017 8 次提交
    • D
      afs: Protect call->state changes against signals · 98bf40cd
      David Howells 提交于
      Protect call->state changes against the call being prematurely terminated
      due to a signal.
      
      What can happen is that a signal causes afs_wait_for_call_to_complete() to
      abort an afs_call because it's not yet complete whilst afs_deliver_to_call()
      is delivering data to that call.
      
      If the data delivery causes the state to change, this may overwrite the state
      of the afs_call, making it not-yet-complete again - but no further
      notifications will be forthcoming from AF_RXRPC as the rxrpc call has been
      aborted and completed, so kAFS will just hang in various places waiting for
      that call or on page bits that need clearing by that call.
      
      A tracepoint to monitor call state changes is also provided.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      98bf40cd
    • D
      afs: Trace page dirty/clean · 13524ab3
      David Howells 提交于
      Add a trace event that logs the dirtying and cleaning of pages attached to
      AFS inodes.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      13524ab3
    • D
      afs: Implement shared-writeable mmap · 1cf7a151
      David Howells 提交于
      Implement shared-writeable mmap for AFS.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      1cf7a151
    • D
      afs: Get rid of the afs_writeback record · 4343d008
      David Howells 提交于
      Get rid of the afs_writeback record that kAFS is using to match keys with
      writes made by that key.
      
      Instead, keep a list of keys that have a file open for writing and/or
      sync'ing and iterate through those.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      4343d008
    • D
      afs: Introduce a file-private data record · 215804a9
      David Howells 提交于
      Introduce a file-private data record for kAFS and put the key into it
      rather than storing the key in file->private_data.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      215804a9
    • M
      afs: Use a dynamic port if 7001 is in use · 83732ec5
      Marc Dionne 提交于
      It is not required that the afs client operate on port 7001.
      The port could be in use because another kernel or userspace
      client has already bound to it.
      
      If the port is in use, just fallback to using a dynamic port.
      Signed-off-by: NMarc Dionne <marc.dionne@auristor.com>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      83732ec5
    • D
      afs: Fix directory read/modify race · dab17c1a
      David Howells 提交于
      Because parsing of the directory wasn't being done under any sort of lock,
      the pages holding the directory content can get invalidated whilst the
      parsing is ongoing.
      
      Further, the directory page check function gets called outside of the page
      lock, so if the page gets cleared or updated, this may return reports of
      bad magic numbers in the directory page.
      
      Also, the directory may change size whilst checking and parsing are
      ongoing, so more care needs to be taken here.
      
      Fix this by:
      
       (1) Perform the page check from the page filling function before we set
           PageUptodate and drop the page lock.
      
       (2) Check for the file having shrunk and the page having been abandoned
           before checking the page contents.
      
       (3) Lock the page whilst parsing it for the directory iterator.
      
      Whilst we're at it, add a tracepoint to report check failure.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      dab17c1a
    • D
      afs: Trace the sending of pages · 2c099014
      David Howells 提交于
      Add a pair of tracepoints to log the sending of pages for an FS.StoreData
      or FS.StoreData64 operation.
      
      Tracepoint afs_send_pages notes each set of pages added to the operation.
      There may be several of these per operation as we get up at most 8
      contiguous pages in one go because the bvec we're using is on the stack.
      
      Tracepoint afs_sent_pages notes the end of adding data from a whole run of
      pages to the operation and the completion of the request phase.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      2c099014