1. 12 Sep, 2024 1 commit
    • David Howells's avatar
      netfs: Speed up buffered reading · ee4cdf7b
      David Howells authored
      
      Improve the efficiency of buffered reads in a number of ways:
      
       (1) Overhaul the algorithm in general so that it's a lot more compact and
           split the read submission code between buffered and unbuffered
           versions.  The unbuffered version can be vastly simplified.
      
       (2) Read-result collection is handed off to a work queue rather than being
           done in the I/O thread.  Multiple subrequests can be processes
           simultaneously.
      
       (3) When a subrequest is collected, any folios it fully spans are
           collected and "spare" data on either side is donated to either the
           previous or the next subrequest in the sequence.
      
      Notes:
      
       (*) Readahead expansion is massively slows down fio, presumably because it
           causes a load of extra allocations, both folio and xarray, up front
           before RPC requests can be transmitted.
      
       (*) RDMA with cifs does appear to work, both with SIW and RXE.
      
       (*) PG_private_2-based reading and copy-to-cache is split out into its own
           file and altered to use folio_queue.  Note that the copy to the cache
           now creates a new write transaction against the cache and adds the
           folios to be copied into it.  This allows it to use part of the
           writeback I/O code.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Jeff Layton <jlayton@kernel.org>
      cc: netfs@lists.linux.dev
      cc: linux-fsdevel@vger.kernel.org
      Link: https://lore.kernel.org/r/20240814203850.2240469-20-dhowells@redhat.com/
      
       # v2
      Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
      ee4cdf7b
  2. 01 Jan, 2024 3 commits
    • David Howells's avatar
      afs: trace: Log afs_make_call(), including server address · abcbd3bf
      David Howells authored
      
      Add a tracepoint to log calls to afs_make_call(), including the destination
      server address.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      abcbd3bf
    • David Howells's avatar
      afs: Parse the VolSync record in the reply of a number of RPC ops · 16069e13
      David Howells authored
      
      A number of fileserver RPC operations return a VolSync record as part of
      their reply that gives some information about the state of the volume being
      accessed, including:
      
       (1) A volume Creation timestamp.  For an RW volume, this is the time at
           which the volume was created; if it changes, the RW volume was
           presumably restored from a backup and all cached data should be
           scrubbed as Data Version numbers could regress on the files in the
           volume.
      
           For an RO volume, this is the time it was last snapshotted from the RW
           volume.  It is expected to advance each time this happens; if it
           regresses, cached data should be scrubbed.
      
       (2) A volume Update timestamp (Auristor only).  For an RW volume, this is
           updated any time any change is made to a volume or its contents.  If
           it regresses, all cached data must be scrubbed.
      
           For an RO volume, this is a copy of the RW volume's Update timestamp
           at the point of snapshotting.  It can be used as a version number when
           checking to see if a callback on a RO volume was due to a snapshot.
           If it regresses, all cached data must be scrubbed.
      
      but this is currently not made use of by the in-kernel afs filesystem.
      
      Make the afs filesystem use this by:
      
       (1) Add an update time field to the afs_volsync struct and use a value of
           TIME64_MIN in both that and the creation time to indicate that they
           are unset.
      
       (2) Add creation and update time fields to the afs_volume struct and use
           this to track the two timestamps.
      
       (3) Add a volsync_lock mutex to the afs_volume struct to control
           modification access for when we detect a change in these values.
      
       (3) Add a 'pre-op volsync' struct to the afs_operation struct to record
           the state of the volume tracking before the op.
      
       (4) Add a new counter, cb_scrub, to the afs_volume struct to count events
           that require all data to be scrubbed.  A copy is placed in the
           afs_vnode struct (inode) and if they no longer match, a scrub takes
           place.
      
       (5) When the result of an operation is being parsed, parse the VolSync
           data too, if it is provided.  Note that the two timestamps are handled
           separately, since they don't work in quite the same way.
      
           - If the afs_volume tracking is unset, just set it and do nothing
             else.
      
           - If the result timestamps are the same as the ones in afs_volume, do
             nothing.
      
           - If the timestamps regress, increment cb_scrub if not already done
             so.
      
           - If the creation timestamp on a RW volume changes, increment cb_scrub
             if not already done so.
      
           - If the creation timestamp on a RO volume advances, update the server
             list and see if the current server has been excluded, if so reissue
             the op.  Once over half of the replication sites have been updated,
             increment cb_ro_snapshot to indicate updates may be required and
             switch over to excluding unupdated replication sites.
      
           - If the creation timestamp on a Backup volume advances, just
             increment cb_ro_snapshot to trigger updates.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      16069e13
    • David Howells's avatar
      afs: Keep a record of the current fileserver endpoint state · f49b594d
      David Howells authored
      
      Keep a record of the current fileserver endpoint state, including the probe
      state, and replace it when a new probe is started rather than just
      squelching the old state and overwriting it.  Clearance of the old state
      can cause a race if there's another thread also currently trying to
      communicate with that server.
      
      It appears that this race might be the culprit for some occasions where
      kafs complains about invalid data in the RPC reply because the rotation
      algorithm fell all the way through without actually issuing an RPC call and
      the error return got filled in from the probe state (which has a zero error
      recorded).  Whatever happens to be in the caller's reply buffer is then
      taken as the response.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      f49b594d
  3. 24 Dec, 2023 5 commits
    • David Howells's avatar
      afs: Fold the afs_addr_cursor struct in · 98f9fda2
      David Howells authored
      
      Fold the afs_addr_cursor struct into the afs_operation struct and the
      afs_vl_cursor struct and fold its operations into their callers also.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      98f9fda2
    • David Howells's avatar
      afs: Use peer + service_id as call address · e38f299e
      David Howells authored
      
      Use the rxrpc_peer plus the service ID as the call address instead of
      passing in a sockaddr_srx down to rxrpc.  The peer record is obtained by
      using rxrpc_kernel_get_peer().  This avoids the need to repeatedly look up
      the peer and allows rxrpc to hold on to resources for it.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      e38f299e
    • David Howells's avatar
      afs: Simplify error handling · aa453bec
      David Howells authored
      
      Simplify error handling a bit by moving it from the afs_addr_cursor struct
      to the afs_operation and afs_vl_cursor structs and using the error
      prioritisation function for accumulating errors from multiple sources (AFS
      tries to rotate between multiple fileservers, some of which may be
      inaccessible or in some state of offlinedness).
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      aa453bec
    • David Howells's avatar
      afs: Don't put afs_call in afs_wait_for_call_to_complete() · 6f2ff7e8
      David Howells authored
      
      Don't put the afs_call struct in afs_wait_for_call_to_complete() but rather
      have the caller do it.  This will allow the caller to fish stuff out of the
      afs_call struct rather than the afs_addr_cursor struct, thereby allowing a
      subsequent patch to subsume it.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      6f2ff7e8
    • David Howells's avatar
      afs: Wrap most op->error accesses with inline funcs · 2de5599f
      David Howells authored
      
      Wrap most op->error accesses with inline funcs which will make it easier
      for a subsequent patch to replace op->error with something else.  Two
      functions are added to this end:
      
       (1) afs_op_error() - Get the error code.
      
       (2) afs_op_set_error() - Set the error code.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      2de5599f
  4. 01 Sep, 2022 1 commit
    • David Howells's avatar
      afs: Use the operation issue time instead of the reply time for callbacks · 7903192c
      David Howells authored
      rxrpc and kafs between them try to use the receive timestamp on the first
      data packet (ie. the one with sequence number 1) as a base from which to
      calculate the time at which callback promise and lock expiration occurs.
      
      However, we don't know how long it took for the server to send us the reply
      from it having completed the basic part of the operation - it might then,
      for instance, have to send a bunch of a callback breaks, depending on the
      particular operation.
      
      Fix this by using the time at which the operation is issued on the client
      as a base instead.  That should never be longer than the server's idea of
      the expiry time.
      
      Fixes: 78107055 ("afs: Fix calculation of callback expiry time")
      Fixes: 2070a3e4
      
       ("rxrpc: Allow the reply time to be obtained on a client call")
      Suggested-by: default avatarJeffrey E Altman <jaltman@auristor.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      7903192c
  5. 13 Sep, 2021 1 commit
    • David Howells's avatar
      afs: Fix corruption in reads at fpos 2G-4G from an OpenAFS server · b537a3c2
      David Howells authored
      AFS-3 has two data fetch RPC variants, FS.FetchData and FS.FetchData64, and
      Linux's afs client switches between them when talking to a non-YFS server
      if the read size, the file position or the sum of the two have the upper 32
      bits set of the 64-bit value.
      
      This is a problem, however, since the file position and length fields of
      FS.FetchData are *signed* 32-bit values.
      
      Fix this by capturing the capability bits obtained from the fileserver when
      it's sent an FS.GetCapabilities RPC, rather than just discarding them, and
      then picking out the VICED_CAPABILITY_64BITFILES flag.  This can then be
      used to decide whether to use FS.FetchData or FS.FetchData64 - and also
      FS.StoreData or FS.StoreData64 - rather than using upper_32_bits() to
      switch on the parameter values.
      
      This capabilities flag could also be used to limit the maximum size of the
      file, but all servers must be checked for that.
      
      Note that the issue does not exist with FS.StoreData - that uses *unsigned*
      32-bit values.  It's also not a problem with Auristor servers as its
      YFS.FetchData64 op uses unsigned 64-bit values.
      
      This can be tested by cloning a git repo through an OpenAFS client to an
      OpenAFS server and then doing "git status" on it from a Linux afs
      client[1].  Provided the clone has a pack file that's in the 2G-4G range,
      the git status will show errors like:
      
      	error: packfile .git/objects/pack/pack-5e813c51d12b6847bbc0fcd97c2bca66da50079c.pack does not match index
      	error: packfile .git/objects/pack/pack-5e813c51d12b6847bbc0fcd97c2bca66da50079c.pack does not match index
      
      This can be observed in the server's FileLog with something like the
      following appearing:
      
      Sun Aug 29 19:31:39 2021 SRXAFS_FetchData, Fid = 2303380852.491776.3263114, Host 192.168.11.201:7001, Id 1001
      Sun Aug 29 19:31:39 2021 CheckRights: len=0, for host=192.168.11.201:7001
      Sun Aug 29 19:31:39 2021 FetchData_RXStyle: Pos 18446744071815340032, Len 3154
      Sun Aug 29 19:31:39 2021 FetchData_RXStyle: file size 2400758866
      ...
      Sun Aug 29 19:31:40 2021 SRXAFS_FetchData returns 5
      
      Note the file position of 18446744071815340032.  This is the requested file
      position sign-extended.
      
      Fixes: b9b1f8d5
      
       ("AFS: write support fixes")
      Reported-by: default avatarMarkus Suvanto <markus.suvanto@gmail.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Reviewed-by: default avatarMarc Dionne <marc.dionne@auristor.com>
      Tested-by: default avatarMarkus Suvanto <markus.suvanto@gmail.com>
      cc: linux-afs@lists.infradead.org
      cc: openafs-devel@openafs.org
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=214217#c9 [1]
      Link: https://lore.kernel.org/r/951332.1631308745@warthog.procyon.org.uk/
      b537a3c2
  6. 25 May, 2021 1 commit
  7. 23 Apr, 2021 5 commits
  8. 23 Aug, 2020 1 commit
  9. 04 Jun, 2020 2 commits
    • David Howells's avatar
      afs: Reorganise volume and server trees to be rooted on the cell · 20325960
      David Howells authored
      
      Reorganise afs_volume objects such that they're in a tree keyed on volume
      ID, rooted at on an afs_cell object rather than being in multiple trees,
      each of which is rooted on an afs_server object.
      
      afs_server structs become per-cell and acquire a pointer to the cell.
      
      The process of breaking a callback then starts with finding the server by
      its network address, following that to the cell and then looking up each
      volume ID in the volume tree.
      
      This is simpler than the afs_vol_interest/afs_cb_interest N:M mapping web
      and allows those structs and the code for maintaining them to be simplified
      or removed.
      
      It does make a couple of things a bit more tricky, though:
      
       (1) Operations now start with a volume, not a server, so there can be more
           than one answer as to whether or not the server we'll end up using
           supports the FS.InlineBulkStatus RPC.
      
       (2) CB RPC operations that specify the server UUID.  There's still a tree
           of servers by UUID on the afs_net struct, but the UUIDs in it aren't
           guaranteed unique.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      20325960
    • David Howells's avatar
      afs: Build an abstraction around an "operation" concept · e49c7b2f
      David Howells authored
      
      Turn the afs_operation struct into the main way that most fileserver
      operations are managed.  Various things are added to the struct, including
      the following:
      
       (1) All the parameters and results of the relevant operations are moved
           into it, removing corresponding fields from the afs_call struct.
           afs_call gets a pointer to the op.
      
       (2) The target volume is made the main focus of the operation, rather than
           the target vnode(s), and a bunch of op->vnode->volume are made
           op->volume instead.
      
       (3) Two vnode records are defined (op->file[]) for the vnode(s) involved
           in most operations.  The vnode record (struct afs_vnode_param)
           contains:
      
      	- The vnode pointer.
      
      	- The fid of the vnode to be included in the parameters or that was
                returned in the reply (eg. FS.MakeDir).
      
      	- The status and callback information that may be returned in the
           	  reply about the vnode.
      
      	- Callback break and data version tracking for detecting
                simultaneous third-parth changes.
      
       (4) Pointers to dentries to be updated with new inodes.
      
       (5) An operations table pointer.  The table includes pointers to functions
           for issuing AFS and YFS-variant RPCs, handling the success and abort
           of an operation and handling post-I/O-lock local editing of a
           directory.
      
      To make this work, the following function restructuring is made:
      
       (A) The rotation loop that issues calls to fileservers that can be found
           in each function that wants to issue an RPC (such as afs_mkdir()) is
           extracted out into common code, in a new file called fs_operation.c.
      
       (B) The rotation loops, such as the one in afs_mkdir(), are replaced with
           a much smaller piece of code that allocates an operation, sets the
           parameters and then calls out to the common code to do the actual
           work.
      
       (C) The code for handling the success and failure of an operation are
           moved into operation functions (as (5) above) and these are called
           from the core code at appropriate times.
      
       (D) The pseudo inode getting stuff used by the dynamic root code is moved
           over into dynroot.c.
      
       (E) struct afs_iget_data is absorbed into the operation struct and
           afs_iget() expects to be given an op pointer and a vnode record.
      
       (F) Point (E) doesn't work for the root dir of a volume, but we know the
           FID in advance (it's always vnode 1, unique 1), so a separate inode
           getter, afs_root_iget(), is provided to special-case that.
      
       (G) The inode status init/update functions now also take an op and a vnode
           record.
      
       (H) The RPC marshalling functions now, for the most part, just take an
           afs_operation struct as their only argument.  All the data they need
           is held there.  The result delivery functions write their answers
           there as well.
      
       (I) The call is attached to the operation and then the operation core does
           the waiting.
      
      And then the new operation code is, for the moment, made to just initialise
      the operation, get the appropriate vnode I/O locks and do the same rotation
      loop as before.
      
      This lays the foundation for the following changes in the future:
      
       (*) Overhauling the rotation (again).
      
       (*) Support for asynchronous I/O, where the fileserver rotation must be
           done asynchronously also.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      e49c7b2f
  10. 31 May, 2020 5 commits
    • David Howells's avatar
      afs: Rename struct afs_fs_cursor to afs_operation · a310082f
      David Howells authored
      
      As a prelude to implementing asynchronous fileserver operations in the afs
      filesystem, rename struct afs_fs_cursor to afs_operation.
      
      This struct is going to form the core of the operation management and is
      going to acquire more members in later.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      a310082f
    • David Howells's avatar
      afs: Remove the error argument from afs_protocol_error() · 7126ead9
      David Howells authored
      
      Remove the error argument from afs_protocol_error() as it's always
      -EBADMSG.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      7126ead9
    • David Howells's avatar
      afs: Set error flag rather than return error from file status decode · 38355eec
      David Howells authored
      
      Set a flag in the call struct to indicate an unmarshalling error rather
      than return and handle an error from the decoding of file statuses.  This
      flag is checked on a successful return from the delivery function.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      38355eec
    • David Howells's avatar
      afs: Actively poll fileservers to maintain NAT or firewall openings · f6cbb368
      David Howells authored
      When an AFS client accesses a file, it receives a limited-duration callback
      promise that the server will notify it if another client changes a file.
      This callback duration can be a few hours in length.
      
      If a client mounts a volume and then an application prevents it from being
      unmounted, say by chdir'ing into it, but then does nothing for some time,
      the rxrpc_peer record will expire and rxrpc-level keepalive will cease.
      
      If there is NAT or a firewall between the client and the server, the route
      back for the server may close after a comparatively short duration, meaning
      that attempts by the server to notify the client may then bounce.
      
      The client, however, may (so far as it knows) still have a valid unexpired
      promise and will then rely on its cached data and will not see changes made
      on the server by a third party until it incidentally rechecks the status or
      the promise needs renewal.
      
      To deal with this, the client needs to regularly probe the server.  This
      has two effects: firstly, it keeps a route open back for the server, and
      secondly, it causes the server to disgorge any notifications that got
      queued up because they couldn't be sent.
      
      Fix this by adding a mechanism to emit regular probes.
      
      Two levels of probing are made available: Under normal circumstances the
      'slow' queue will be used for a fileserver - this just probes the preferred
      address once every 5 mins or so; however, if server fails to respond to any
      probes, the server will shift to the 'fast' queue from which all its
      interfaces will be probed every 30s.  When it finally responds, the record
      will switch back to the slow queue.
      
      Further notes:
      
       (1) Probing is now no longer driven from the fileserver rotation
           algorithm.
      
       (2) Probes are dispatched to all interfaces on a fileserver when that an
           afs_server object is set up to record it.
      
       (3) The afs_server object is removed from the probe queues when we start
           to probe it.  afs_is_probing_server() returns true if it's not listed
           - ie. it's undergoing probing.
      
       (4) The afs_server object is added back on to the probe queue when the
           final outstanding probe completes, but the probed_at time is set when
           we're about to launch a probe so that it's not dependent on the probe
           duration.
      
       (5) The timer and the work item added for this must be handed a count on
           net->servers_outstanding, which they hand on or release.  This makes
           sure that network namespace cleanup waits for them.
      
      Fixes: d2ddc776
      
       ("afs: Overhaul volume and server record caching and fileserver rotation")
      Reported-by: default avatarDave Botsch <botsch@cnf.cornell.edu>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      f6cbb368
    • David Howells's avatar
      afs: Split the usage count on struct afs_server · 977e5f8e
      David Howells authored
      
      Split the usage count on the afs_server struct to have an active count that
      registers who's actually using it separately from the reference count on
      the object.
      
      This allows a future patch to dispatch polling probes without advancing the
      "unuse" time into the future each time we emit a probe, which would
      otherwise prevent unused server records from expiring.
      
      Included in this:
      
       (1) The latter part of afs_destroy_server() in which the RCU destruction
           of afs_server objects is invoked and the outstanding server count is
           decremented is split out into __afs_put_server().
      
       (2) afs_put_server() now calls __afs_put_server() rather then setting the
           management timer.
      
       (3) The calls begun by afs_fs_give_up_all_callbacks() and
           afs_fs_get_capabilities() can now take a ref on the server record, so
           afs_destroy_server() can just drop its ref and needn't wait for the
           completion of these calls.  They'll put the ref when they're done.
      
       (4) Because of (3), afs_fs_probe_done() no longer needs to wake up
           afs_destroy_server() with server->probe_outstanding.
      
       (5) afs_gc_servers can be simplified.  It only needs to check if
           server->active is 0 rather than playing games with the refcount.
      
       (6) afs_manage_servers() can propose a server for gc if usage == 0 rather
           than if ref == 1.  The gc is effected by (5).
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      977e5f8e
  11. 18 May, 2020 1 commit
    • David Howells's avatar
      afs: Don't unlock fetched data pages until the op completes successfully · 9d1be4f4
      David Howells authored
      Don't call req->page_done() on each page as we finish filling it with
      the data coming from the network.  Whilst this might speed up the
      application a bit, it's a problem if there's a network failure and the
      operation has to be reissued.
      
      If this happens, an oops occurs because afs_readpages_page_done() clears
      the pointer to each page it unlocks and when a retry happens, the
      pointers to the pages it wants to fill are now NULL (and the pages have
      been unlocked anyway).
      
      Instead, wait till the operation completes successfully and only then
      release all the pages after clearing any terminal gap (the server can
      give us less data than we requested as we're allowed to ask for more
      than is available).
      
      KASAN produces a bug like the following, and even without KASAN, it can
      oops and panic.
      
          BUG: KASAN: wild-memory-access in _copy_to_iter+0x323/0x5f4
          Write of size 1404 at addr 0005088000000000 by task md5sum/5235
      
          CPU: 0 PID: 5235 Comm: md5sum Not tainted 5.7.0-rc3-fscache+ #250
          Hardware name: ASUS All Series/H97-PLUS, BIOS 2306 10/09/2014
          Call Trace:
           memcpy+0x39/0x58
           _copy_to_iter+0x323/0x5f4
           __skb_datagram_iter+0x89/0x2a6
           skb_copy_datagram_iter+0x129/0x135
           rxrpc_recvmsg_data.isra.0+0x615/0xd42
           rxrpc_kernel_recv_data+0x1e9/0x3ae
           afs_extract_data+0x139/0x33a
           yfs_deliver_fs_fetch_data64+0x47a/0x91b
           afs_deliver_to_call+0x304/0x709
           afs_wait_for_call_to_complete+0x1cc/0x4ad
           yfs_fs_fetch_data+0x279/0x288
           afs_fetch_data+0x1e1/0x38d
           afs_readpages+0x593/0x72e
           read_pages+0xf5/0x21e
           __do_page_cache_readahead+0x128/0x23f
           ondemand_readahead+0x36e/0x37f
           generic_file_buffered_read+0x234/0x680
           new_sync_read+0x109/0x17e
           vfs_read+0xe6/0x138
           ksys_read+0xd8/0x14d
           do_syscall_64+0x6e/0x8a
           entry_SYSCALL_64_after_hwframe+0x49/0xb3
      
      Fixes: 196ee9cd ("afs: Make afs_fs_fetch_data() take a list of pages")
      Fixes: 30062bd1
      
       ("afs: Implement YFS support in the fs client")
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Reviewed-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9d1be4f4
  12. 13 Apr, 2020 3 commits
    • David Howells's avatar
      afs: Fix rename operation status delivery · b98f0ec9
      David Howells authored
      The afs_deliver_fs_rename() and yfs_deliver_fs_rename() functions both only
      decode the second file status returned unless the parent directories are
      different - unfortunately, this means that the xdr pointer isn't advanced
      and the volsync record will be read incorrectly in such an instance.
      
      Fix this by always decoding the second status into the second
      status/callback block which wasn't being used if the dirs were the same.
      
      The afs_update_dentry_version() calls that update the directory data
      version numbers on the dentries can then unconditionally use the second
      status record as this will always reflect the state of the destination dir
      (the two records will be identical if the destination dir is the same as
      the source dir)
      
      Fixes: 260a9803 ("[AFS]: Add "directory write" support.")
      Fixes: 30062bd1
      
       ("afs: Implement YFS support in the fs client")
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      b98f0ec9
    • David Howells's avatar
      afs: Fix decoding of inline abort codes from version 1 status records · 3e0d9892
      David Howells authored
      If we're decoding an AFSFetchStatus record and we see that the version is 1
      and the abort code is set and we're expecting inline errors, then we store
      the abort code and ignore the remaining status record (which is correct),
      but we don't set the flag to say we got a valid abort code.
      
      This can affect operation of YFS.RemoveFile2 when removing a file and the
      operation of {,Y}FS.InlineBulkStatus when prospectively constructing or
      updating of a set of inodes during a lookup.
      
      Fix this to indicate the reception of a valid abort code.
      
      Fixes: a38a7558
      
       ("afs: Fix unlink to handle YFS.RemoveFile2 better")
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      3e0d9892
    • David Howells's avatar
      afs: Fix missing XDR advance in xdr_decode_{AFS,YFS}FSFetchStatus() · c72057b5
      David Howells authored
      If we receive a status record that has VNOVNODE set in the abort field,
      xdr_decode_AFSFetchStatus() and xdr_decode_YFSFetchStatus() don't advance
      the XDR pointer, thereby corrupting anything subsequent decodes from the
      same block of data.
      
      This has the potential to affect AFS.InlineBulkStatus and
      YFS.InlineBulkStatus operation, but probably doesn't since the status
      records are extracted as individual blocks of data and the buffer pointer
      is reset between blocks.
      
      It does affect YFS.RemoveFile2 operation, corrupting the volsync record -
      though that is not currently used.
      
      Other operations abort the entire operation rather than returning an error
      inline, in which case there is no decoding to be done.
      
      Fix this by unconditionally advancing the xdr pointer.
      
      Fixes: 684b0f68
      
       ("afs: Fix AFSFetchStatus decoder to provide OpenAFS compatibility")
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      c72057b5
  13. 21 Nov, 2019 3 commits
  14. 02 Sep, 2019 2 commits
  15. 26 Jul, 2019 1 commit
    • Gustavo A. R. Silva's avatar
      afs: fsclient: Mark expected switch fall-throughs · 29881608
      Gustavo A. R. Silva authored
      
      In preparation to enabling -Wimplicit-fallthrough, mark switch
      cases where we are expecting to fall through.
      
      This patch fixes the following warnings:
      
      Warning level 3 was used: -Wimplicit-fallthrough=3
      
      fs/afs/fsclient.c: In function ‘afs_deliver_fs_fetch_acl’:
      fs/afs/fsclient.c:2199:19: warning: this statement may fall through [-Wimplicit-fallthrough=]
         call->unmarshall++;
         ~~~~~~~~~~~~~~~~^~
      fs/afs/fsclient.c:2202:2: note: here
        case 1:
        ^~~~
      fs/afs/fsclient.c:2216:19: warning: this statement may fall through [-Wimplicit-fallthrough=]
         call->unmarshall++;
         ~~~~~~~~~~~~~~~~^~
      fs/afs/fsclient.c:2219:2: note: here
        case 2:
        ^~~~
      fs/afs/fsclient.c:2225:19: warning: this statement may fall through [-Wimplicit-fallthrough=]
         call->unmarshall++;
         ~~~~~~~~~~~~~~~~^~
      fs/afs/fsclient.c:2228:2: note: here
        case 3:
        ^~~~
      
      This patch is part of the ongoing efforts to enable
      -Wimplicit-fallthrough.
      Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
      29881608
  16. 20 Jun, 2019 1 commit
  17. 30 May, 2019 1 commit
  18. 16 May, 2019 3 commits
    • David Howells's avatar
      afs: Fix unlink to handle YFS.RemoveFile2 better · a38a7558
      David Howells authored
      Make use of the status update for the target file that the YFS.RemoveFile2
      RPC op returns to correctly update the vnode as to whether the file was
      actually deleted or just had nlink reduced.
      
      Fixes: 30062bd1
      
       ("afs: Implement YFS support in the fs client")
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      a38a7558
    • David Howells's avatar
      afs: Don't save callback version and type fields · 7c712458
      David Howells authored
      
      Don't save callback version and type fields as the version is about the
      format of the callback information and the type is relative to the
      particular RPC call.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      7c712458
    • David Howells's avatar
      afs: Fix application of status and callback to be under same lock · a58823ac
      David Howells authored
      When applying the status and callback in the response of an operation,
      apply them in the same critical section so that there's no race between
      checking the callback state and checking status-dependent state (such as
      the data version).
      
      Fix this by:
      
       (1) Allocating a joint {status,callback} record (afs_status_cb) before
           calling the RPC function for each vnode for which the RPC reply
           contains a status or a status plus a callback.  A flag is set in the
           record to indicate if a callback was actually received.
      
       (2) These records are passed into the RPC functions to be filled in.  The
           afs_decode_status() and yfs_decode_status() functions are removed and
           the cb_lock is no longer taken.
      
       (3) xdr_decode_AFSFetchStatus() and xdr_decode_YFSFetchStatus() no longer
           update the vnode.
      
       (4) xdr_decode_AFSCallBack() and xdr_decode_YFSCallBack() no longer update
           the vnode.
      
       (5) vnodes, expected data-version numbers and callback break counters
           (cb_break) no longer need to be passed to the reply delivery
           functions.
      
           Note that, for the moment, the file locking functions still need
           access to both the call and the vnode at the same time.
      
       (6) afs_vnode_commit_status() is now given the cb_break value and the
           expected data_version and the task of applying the status and the
           callback to the vnode are now done here.
      
           This is done under a single taking of vnode->cb_lock.
      
       (7) afs_pages_written_back() is now called by afs_store_data() rather than
           by the reply delivery function.
      
           afs_pages_written_back() has been moved to before the call point and
           is now given the first and last page numbers rather than a pointer to
           the call.
      
       (8) The indicator from YFS.RemoveFile2 as to whether the target file
           actually got removed (status.abort_code == VNOVNODE) rather than
           merely dropping a link is now checked in afs_unlink rather than in
           xdr_decode_YFSFetchStatus().
      
      Supplementary fixes:
      
       (*) afs_cache_permit() now gets the caller_access mask from the
           afs_status_cb object rather than picking it out of the vnode's status
           record.  afs_fetch_status() returns caller_access through its argument
           list for this purpose also.
      
       (*) afs_inode_init_from_status() now uses a write lock on cb_lock rather
           than a read lock and now sets the callback inside the same critical
           section.
      
      Fixes: c435ee34
      
       ("afs: Overhaul the callback handling")
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      a58823ac