All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: linux-fsdevel@vger.kernel.org
Cc: Marc Dionne <marc.dionne@auristor.com>,
	linux-afs@lists.infradead.org, linux-cachefs@redhat.com,
	dhowells@redhat.com,
	Trond Myklebust <trond.myklebust@hammerspace.com>,
	Anna Schumaker <anna.schumaker@netapp.com>,
	Steve French <sfrench@samba.org>,
	Dominique Martinet <asmadeus@codewreck.org>,
	Jeff Layton <jlayton@redhat.com>,
	David Wysochanski <dwysocha@redhat.com>,
	"Matthew Wilcox (Oracle)" <willy@infradead.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-cachefs@redhat.com, linux-afs@lists.infradead.org,
	linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org,
	ceph-devel@vger.kernel.org, v9fs-developer@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH v7 21/31] afs: Move key to afs_read struct
Date: Fri, 23 Apr 2021 14:32:49 +0100	[thread overview]
Message-ID: <161918476921.3145707.1207242314341789660.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <161918446704.3145707.14418606303992174310.stgit@warthog.procyon.org.uk>

Stash the key used to authenticate read operations in the afs_read struct.
This will be necessary to reissue the operation against the server if a
read from the cache fails in upcoming cache changes.

Signed-off-by: David Howells <dhowells@redhat.com>
Tested-By: Marc 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/158861248336.340223.1851189950710196001.stgit@warthog.procyon.org.uk/ # rfc
Link: https://lore.kernel.org/r/159465823899.1377938.11925978022348532049.stgit@warthog.procyon.org.uk/
Link: https://lore.kernel.org/r/160588529557.3465195.7303323479305254243.stgit@warthog.procyon.org.uk/ # rfc
Link: https://lore.kernel.org/r/161118147693.1232039.13780672951838643842.stgit@warthog.procyon.org.uk/ # rfc
Link: https://lore.kernel.org/r/161161043340.2537118.511899217704140722.stgit@warthog.procyon.org.uk/ # v2
Link: https://lore.kernel.org/r/161340406678.1303470.12676824086429446370.stgit@warthog.procyon.org.uk/ # v3
Link: https://lore.kernel.org/r/161539550819.286939.1268332875889175195.stgit@warthog.procyon.org.uk/ # v4
Link: https://lore.kernel.org/r/161653806683.2770958.11300984379283401542.stgit@warthog.procyon.org.uk/ # v5
Link: https://lore.kernel.org/r/161789089556.6155.14603302893431820997.stgit@warthog.procyon.org.uk/ # v6
---

 fs/afs/dir.c      |    3 ++-
 fs/afs/file.c     |   16 +++++++++-------
 fs/afs/internal.h |    3 ++-
 fs/afs/write.c    |   12 ++++++------
 4 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index 17548c1faf02..d8825ce63eba 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -241,6 +241,7 @@ static struct afs_read *afs_read_dir(struct afs_vnode *dvnode, struct key *key)
 		return ERR_PTR(-ENOMEM);
 
 	refcount_set(&req->usage, 1);
+	req->key = key_get(key);
 	req->nr_pages = nr_pages;
 	req->actual_len = i_size; /* May change */
 	req->len = nr_pages * PAGE_SIZE; /* We can ask for more than there is */
@@ -305,7 +306,7 @@ static struct afs_read *afs_read_dir(struct afs_vnode *dvnode, struct key *key)
 
 	if (!test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags)) {
 		trace_afs_reload_dir(dvnode);
-		ret = afs_fetch_data(dvnode, key, req);
+		ret = afs_fetch_data(dvnode, req);
 		if (ret < 0)
 			goto error_unlock;
 
diff --git a/fs/afs/file.c b/fs/afs/file.c
index f1bae0b0a9c0..af6471defec3 100644
--- a/fs/afs/file.c
+++ b/fs/afs/file.c
@@ -198,6 +198,7 @@ void afs_put_read(struct afs_read *req)
 			if (req->pages != req->array)
 				kfree(req->pages);
 		}
+		key_put(req->key);
 		kfree(req);
 	}
 }
@@ -228,7 +229,7 @@ static const struct afs_operation_ops afs_fetch_data_operation = {
 /*
  * Fetch file data from the volume.
  */
-int afs_fetch_data(struct afs_vnode *vnode, struct key *key, struct afs_read *req)
+int afs_fetch_data(struct afs_vnode *vnode, struct afs_read *req)
 {
 	struct afs_operation *op;
 
@@ -237,9 +238,9 @@ int afs_fetch_data(struct afs_vnode *vnode, struct key *key, struct afs_read *re
 	       vnode->fid.vid,
 	       vnode->fid.vnode,
 	       vnode->fid.unique,
-	       key_serial(key));
+	       key_serial(req->key));
 
-	op = afs_alloc_operation(key, vnode->volume);
+	op = afs_alloc_operation(req->key, vnode->volume);
 	if (IS_ERR(op))
 		return PTR_ERR(op);
 
@@ -278,6 +279,7 @@ int afs_page_filler(void *data, struct page *page)
 	 * unmarshalling code will clear the unfilled space.
 	 */
 	refcount_set(&req->usage, 1);
+	req->key = key_get(key);
 	req->pos = (loff_t)page->index << PAGE_SHIFT;
 	req->len = PAGE_SIZE;
 	req->nr_pages = 1;
@@ -287,7 +289,7 @@ int afs_page_filler(void *data, struct page *page)
 
 	/* read the contents of the file from the server into the
 	 * page */
-	ret = afs_fetch_data(vnode, key, req);
+	ret = afs_fetch_data(vnode, req);
 	afs_put_read(req);
 
 	if (ret < 0) {
@@ -372,7 +374,6 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,
 	struct afs_read *req;
 	struct list_head *p;
 	struct page *first, *page;
-	struct key *key = afs_file_key(file);
 	pgoff_t index;
 	int ret, n, i;
 
@@ -396,6 +397,7 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,
 
 	refcount_set(&req->usage, 1);
 	req->vnode = vnode;
+	req->key = key_get(afs_file_key(file));
 	req->page_done = afs_readpages_page_done;
 	req->pos = first->index;
 	req->pos <<= PAGE_SHIFT;
@@ -425,11 +427,11 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,
 	} while (req->nr_pages < n);
 
 	if (req->nr_pages == 0) {
-		kfree(req);
+		afs_put_read(req);
 		return 0;
 	}
 
-	ret = afs_fetch_data(vnode, key, req);
+	ret = afs_fetch_data(vnode, req);
 	if (ret < 0)
 		goto error;
 
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index fd437d4722b5..995fef267be7 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -204,6 +204,7 @@ struct afs_read {
 	loff_t			actual_len;	/* How much we're actually getting */
 	loff_t			remain;		/* Amount remaining */
 	loff_t			file_size;	/* File size returned by server */
+	struct key		*key;		/* The key to use to reissue the read */
 	afs_dataversion_t	data_version;	/* Version number returned by server */
 	refcount_t		usage;
 	unsigned int		index;		/* Which page we're reading into */
@@ -1045,7 +1046,7 @@ extern int afs_cache_wb_key(struct afs_vnode *, struct afs_file *);
 extern void afs_put_wb_key(struct afs_wb_key *);
 extern int afs_open(struct inode *, struct file *);
 extern int afs_release(struct inode *, struct file *);
-extern int afs_fetch_data(struct afs_vnode *, struct key *, struct afs_read *);
+extern int afs_fetch_data(struct afs_vnode *, struct afs_read *);
 extern int afs_page_filler(void *, struct page *);
 extern void afs_put_read(struct afs_read *);
 
diff --git a/fs/afs/write.c b/fs/afs/write.c
index babc84dd9719..a91da2e680da 100644
--- a/fs/afs/write.c
+++ b/fs/afs/write.c
@@ -25,9 +25,10 @@ int afs_set_page_dirty(struct page *page)
 /*
  * partly or wholly fill a page that's under preparation for writing
  */
-static int afs_fill_page(struct afs_vnode *vnode, struct key *key,
+static int afs_fill_page(struct file *file,
 			 loff_t pos, unsigned int len, struct page *page)
 {
+	struct afs_vnode *vnode = AFS_FS_I(file_inode(file));
 	struct afs_read *req;
 	size_t p;
 	void *data;
@@ -49,6 +50,7 @@ static int afs_fill_page(struct afs_vnode *vnode, struct key *key,
 		return -ENOMEM;
 
 	refcount_set(&req->usage, 1);
+	req->key = key_get(afs_file_key(file));
 	req->pos = pos;
 	req->len = len;
 	req->nr_pages = 1;
@@ -56,7 +58,7 @@ static int afs_fill_page(struct afs_vnode *vnode, struct key *key,
 	req->pages[0] = page;
 	get_page(page);
 
-	ret = afs_fetch_data(vnode, key, req);
+	ret = afs_fetch_data(vnode, req);
 	afs_put_read(req);
 	if (ret < 0) {
 		if (ret == -ENOENT) {
@@ -80,7 +82,6 @@ int afs_write_begin(struct file *file, struct address_space *mapping,
 {
 	struct afs_vnode *vnode = AFS_FS_I(file_inode(file));
 	struct page *page;
-	struct key *key = afs_file_key(file);
 	unsigned long priv;
 	unsigned f, from = pos & (PAGE_SIZE - 1);
 	unsigned t, to = from + len;
@@ -95,7 +96,7 @@ int afs_write_begin(struct file *file, struct address_space *mapping,
 		return -ENOMEM;
 
 	if (!PageUptodate(page) && len != PAGE_SIZE) {
-		ret = afs_fill_page(vnode, key, pos & PAGE_MASK, PAGE_SIZE, page);
+		ret = afs_fill_page(file, pos & PAGE_MASK, PAGE_SIZE, page);
 		if (ret < 0) {
 			unlock_page(page);
 			put_page(page);
@@ -163,7 +164,6 @@ int afs_write_end(struct file *file, struct address_space *mapping,
 		  struct page *page, void *fsdata)
 {
 	struct afs_vnode *vnode = AFS_FS_I(file_inode(file));
-	struct key *key = afs_file_key(file);
 	unsigned long priv;
 	unsigned int f, from = pos & (PAGE_SIZE - 1);
 	unsigned int t, to = from + copied;
@@ -193,7 +193,7 @@ int afs_write_end(struct file *file, struct address_space *mapping,
 			 * unmarshalling routine will take care of clearing any
 			 * bits that are beyond the EOF.
 			 */
-			ret = afs_fill_page(vnode, key, pos + copied,
+			ret = afs_fill_page(file, pos + copied,
 					    len - copied, page);
 			if (ret < 0)
 				goto out;



  parent reply	other threads:[~2021-04-23 13:33 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-23 13:27 [PATCH v7 00/31] Network fs helper library & fscache kiocb API David Howells
2021-04-23 13:28 ` [PATCH v7 01/31] iov_iter: Add ITER_XARRAY David Howells
2021-04-23 14:06   ` Matthew Wilcox
2021-04-23 14:33   ` David Howells
2021-04-25 13:14   ` Al Viro
2021-04-25 13:58   ` David Howells
2021-04-25 14:16     ` Al Viro
2021-04-26 18:54   ` Al Viro
2021-04-26 19:15     ` Jeff Layton
2021-04-26 19:15       ` Jeff Layton
2021-04-26 19:23   ` David Howells
2021-04-26 19:52     ` Al Viro
2021-04-23 13:28 ` [PATCH v7 02/31] mm: Add set/end/wait functions for PG_private_2 David Howells
2021-04-23 13:28 ` [PATCH v7 03/31] mm/filemap: Pass the file_ra_state in the ractl David Howells
2021-04-23 13:28 ` [PATCH v7 04/31] fs: Document file_ra_state David Howells
2021-04-23 13:28 ` [PATCH v7 05/31] mm/readahead: Handle ractl nr_pages being modified David Howells
2021-04-23 13:29 ` [PATCH v7 06/31] mm: Implement readahead_control pageset expansion David Howells
2021-04-23 13:29 ` [PATCH v7 07/31] netfs: Make a netfs helper module David Howells
2021-04-29  8:04   ` Geert Uytterhoeven
2021-04-29  8:04     ` Geert Uytterhoeven
2021-04-29  8:41   ` David Howells
2021-04-29  8:43     ` Dominique Martinet
2021-04-23 13:29 ` [PATCH v7 08/31] netfs: Documentation for helper library David Howells
2021-04-23 13:29 ` [PATCH v7 09/31] netfs, mm: Move PG_fscache helper funcs to linux/netfs.h David Howells
2021-04-23 13:29 ` [PATCH v7 10/31] netfs, mm: Add set/end/wait_on_page_fscache() aliases David Howells
2021-04-23 13:30 ` [PATCH v7 11/31] netfs: Provide readahead and readpage netfs helpers David Howells
2021-04-23 13:30 ` [PATCH v7 12/31] netfs: Add tracepoints David Howells
2021-04-23 13:30 ` [PATCH v7 13/31] netfs: Gather stats David Howells
2021-04-23 13:30 ` [PATCH v7 14/31] netfs: Add write_begin helper David Howells
2021-04-23 13:31 ` [PATCH v7 15/31] netfs: Define an interface to talk to a cache David Howells
2021-04-23 13:31 ` [PATCH v7 16/31] netfs: Add a tracepoint to log failures that would be otherwise unseen David Howells
2021-04-23 13:31 ` [PATCH v7 17/31] fscache, cachefiles: Add alternate API to use kiocb for read/write to cache David Howells
2021-04-23 13:32 ` [PATCH v7 18/31] afs: Disable use of the fscache I/O routines David Howells
2021-04-23 13:32 ` [PATCH v7 19/31] afs: Pass page into dirty region helpers to provide THP size David Howells
2021-04-23 13:32 ` [PATCH v7 20/31] afs: Print the operation debug_id when logging an unexpected data version David Howells
2021-04-23 13:32 ` David Howells [this message]
2021-04-23 13:33 ` [PATCH v7 22/31] afs: Don't truncate iter during data fetch David Howells
2021-04-23 13:33 ` [PATCH v7 23/31] afs: Log remote unmarshalling errors David Howells
2021-04-23 13:33 ` [PATCH v7 24/31] afs: Set up the iov_iter before calling afs_extract_data() David Howells
2021-04-23 13:33 ` [PATCH v7 25/31] afs: Use ITER_XARRAY for writing David Howells
2021-04-23 13:33 ` [PATCH v7 26/31] afs: Wait on PG_fscache before modifying/releasing a page David Howells
2021-04-23 13:34 ` [PATCH v7 27/31] afs: Extract writeback extension into its own function David Howells
2021-04-23 13:34 ` [PATCH v7 28/31] afs: Prepare for use of THPs David Howells
2021-04-23 13:34 ` [PATCH v7 29/31] afs: Use the fs operation ops to handle FetchData completion David Howells
2021-04-23 13:34 ` [PATCH v7 30/31] afs: Use new netfs lib read helper API David Howells
2021-04-23 13:34 ` [PATCH v7 31/31] afs: Use the netfs_write_begin() helper David Howells
2021-04-25 23:14 ` [PATCH] iov_iter: Four fixes for ITER_XARRAY David Howells
2021-04-26 17:14   ` Al Viro
2021-04-26 19:02   ` Jeff Layton
2021-04-26 19:02     ` Jeff Layton
2021-04-26 21:38   ` David Wysochanski
2021-04-26 21:38     ` David Wysochanski
2021-04-26 21:06 ` [PATCH] netfs: Miscellaneous fixes David Howells
2021-04-26 21:09   ` Matthew Wilcox
2021-04-26 21:20   ` [PATCH v2] " David Howells
2021-04-26 22:06     ` Matthew Wilcox
2021-04-26 22:17     ` Jeff Layton
2021-04-26 22:17       ` Jeff Layton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=161918476921.3145707.1207242314341789660.stgit@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=anna.schumaker@netapp.com \
    --cc=asmadeus@codewreck.org \
    --cc=ceph-devel@vger.kernel.org \
    --cc=dwysocha@redhat.com \
    --cc=jlayton@redhat.com \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-cachefs@redhat.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=marc.dionne@auristor.com \
    --cc=sfrench@samba.org \
    --cc=trond.myklebust@hammerspace.com \
    --cc=v9fs-developer@lists.sourceforge.net \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.