Commit 5cbf0398 authored by David Howells's avatar David Howells

afs: Use new netfs lib read helper API

Make AFS use the new netfs read helpers to implement the VM read
operations:

 - afs_readpage() now hands off responsibility to netfs_readpage().

 - afs_readpages() is gone and replaced with afs_readahead().

 - afs_readahead() just hands off responsibility to netfs_readahead().

These make use of the cache if a cookie is supplied, otherwise just call
the ->issue_op() method a sufficient number of times to complete the entire
request.

Changes:
v5:
- Use proper wait function for PG_fscache in afs_page_mkwrite()[1].
- Use killable wait for PG_writeback in afs_page_mkwrite()[1].

v4:
- Folded in error handling fixes to afs_req_issue_op().
- Added flag to netfs_subreq_terminated() to indicate that the caller may
  have been running async and stuff that might sleep needs punting to a
  workqueue.
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Tested-By: default avatarMarc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
cc: linux-cachefs@redhat.com
cc: linux-fsdevel@vger.kernel.org
Link: https://lore.kernel.org/r/2499407.1616505440@warthog.procyon.org.uk [1]
Link: https://lore.kernel.org/r/160588542733.3465195.7526541422073350302.stgit@warthog.procyon.org.uk/ # rfc
Link: https://lore.kernel.org/r/161118158436.1232039.3884845981224091996.stgit@warthog.procyon.org.uk/ # rfc
Link: https://lore.kernel.org/r/161161053540.2537118.14904446369309535330.stgit@warthog.procyon.org.uk/ # v2
Link: https://lore.kernel.org/r/161340418739.1303470.5908092911600241280.stgit@warthog.procyon.org.uk/ # v3
Link: https://lore.kernel.org/r/161539561926.286939.5729036262354802339.stgit@warthog.procyon.org.uk/ # v4
Link: https://lore.kernel.org/r/161653817977.2770958.17696456811587237197.stgit@warthog.procyon.org.uk/ # v5
Link: https://lore.kernel.org/r/161789101258.6155.3879271028895121537.stgit@warthog.procyon.org.uk/ # v6
parent dc419184
...@@ -4,6 +4,7 @@ config AFS_FS ...@@ -4,6 +4,7 @@ config AFS_FS
depends on INET depends on INET
select AF_RXRPC select AF_RXRPC
select DNS_RESOLVER select DNS_RESOLVER
select NETFS_SUPPORT
help help
If you say Y here, you will get an experimental Andrew File System If you say Y here, you will get an experimental Andrew File System
driver. It currently only supports unsecured read-only AFS access. driver. It currently only supports unsecured read-only AFS access.
......
This diff is collapsed.
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/circ_buf.h> #include <linux/circ_buf.h>
#include <linux/iversion.h> #include <linux/iversion.h>
#include <linux/netfs.h>
#include "internal.h" #include "internal.h"
#include "afs_fs.h" #include "afs_fs.h"
#include "xdr_fs.h" #include "xdr_fs.h"
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <linux/key.h> #include <linux/key.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/sched.h> #include <linux/sched.h>
#define FSCACHE_USE_NEW_IO_API
#include <linux/fscache.h> #include <linux/fscache.h>
#include <linux/backing-dev.h> #include <linux/backing-dev.h>
#include <linux/uuid.h> #include <linux/uuid.h>
...@@ -207,6 +208,7 @@ struct afs_read { ...@@ -207,6 +208,7 @@ struct afs_read {
loff_t file_size; /* File size returned by server */ loff_t file_size; /* File size returned by server */
struct key *key; /* The key to use to reissue the read */ struct key *key; /* The key to use to reissue the read */
struct afs_vnode *vnode; /* The file being read into. */ struct afs_vnode *vnode; /* The file being read into. */
struct netfs_read_subrequest *subreq; /* Fscache helper read request this belongs to */
afs_dataversion_t data_version; /* Version number returned by server */ afs_dataversion_t data_version; /* Version number returned by server */
refcount_t usage; refcount_t usage;
unsigned int call_debug_id; unsigned int call_debug_id;
...@@ -1049,6 +1051,7 @@ extern void afs_put_wb_key(struct afs_wb_key *); ...@@ -1049,6 +1051,7 @@ extern void afs_put_wb_key(struct afs_wb_key *);
extern int afs_open(struct inode *, struct file *); extern int afs_open(struct inode *, struct file *);
extern int afs_release(struct inode *, struct file *); extern int afs_release(struct inode *, struct file *);
extern int afs_fetch_data(struct afs_vnode *, struct afs_read *); extern int afs_fetch_data(struct afs_vnode *, struct afs_read *);
extern struct afs_read *afs_alloc_read(gfp_t);
extern void afs_put_read(struct afs_read *); extern void afs_put_read(struct afs_read *);
static inline struct afs_read *afs_get_read(struct afs_read *req) static inline struct afs_read *afs_get_read(struct afs_read *req)
......
...@@ -930,7 +930,7 @@ vm_fault_t afs_page_mkwrite(struct vm_fault *vmf) ...@@ -930,7 +930,7 @@ vm_fault_t afs_page_mkwrite(struct vm_fault *vmf)
*/ */
#ifdef CONFIG_AFS_FSCACHE #ifdef CONFIG_AFS_FSCACHE
if (PageFsCache(page) && if (PageFsCache(page) &&
wait_on_page_bit_killable(page, PG_fscache) < 0) wait_on_page_fscache_killable(page) < 0)
return VM_FAULT_RETRY; return VM_FAULT_RETRY;
#endif #endif
...@@ -944,7 +944,10 @@ vm_fault_t afs_page_mkwrite(struct vm_fault *vmf) ...@@ -944,7 +944,10 @@ vm_fault_t afs_page_mkwrite(struct vm_fault *vmf)
* details the portion of the page we need to write back and we might * details the portion of the page we need to write back and we might
* need to redirty the page if there's a problem. * need to redirty the page if there's a problem.
*/ */
wait_on_page_writeback(page); if (wait_on_page_writeback_killable(page) < 0) {
unlock_page(page);
return VM_FAULT_RETRY;
}
priv = afs_page_dirty(page, 0, thp_size(page)); priv = afs_page_dirty(page, 0, thp_size(page));
priv = afs_page_dirty_mmapped(priv); priv = afs_page_dirty_mmapped(priv);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment