2021-10-20 06:06:34 -07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
/* Cache data I/O routines
|
|
|
|
*
|
|
|
|
* Copyright (C) 2021 Red Hat, Inc. All Rights Reserved.
|
|
|
|
* Written by David Howells (dhowells@redhat.com)
|
|
|
|
*/
|
|
|
|
#define FSCACHE_DEBUG_LEVEL OPERATION
|
|
|
|
#include <linux/fscache-cache.h>
|
|
|
|
#include <linux/uio.h>
|
|
|
|
#include <linux/bvec.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/uio.h>
|
|
|
|
#include "internal.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fscache_wait_for_operation - Wait for an object become accessible
|
|
|
|
* @cres: The cache resources for the operation being performed
|
|
|
|
* @want_state: The minimum state the object must be at
|
|
|
|
*
|
|
|
|
* See if the target cache object is at the specified minimum state of
|
|
|
|
* accessibility yet, and if not, wait for it.
|
|
|
|
*/
|
|
|
|
bool fscache_wait_for_operation(struct netfs_cache_resources *cres,
|
|
|
|
enum fscache_want_state want_state)
|
|
|
|
{
|
|
|
|
struct fscache_cookie *cookie = fscache_cres_cookie(cres);
|
|
|
|
enum fscache_cookie_state state;
|
|
|
|
|
|
|
|
again:
|
|
|
|
if (!fscache_cache_is_live(cookie->volume->cache)) {
|
2024-07-18 13:07:32 -07:00
|
|
|
_leave(" [broken]");
|
2021-10-20 06:06:34 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
state = fscache_cookie_state(cookie);
|
2024-07-18 13:07:32 -07:00
|
|
|
_enter("c=%08x{%u},%x", cookie->debug_id, state, want_state);
|
2021-10-20 06:06:34 -07:00
|
|
|
|
|
|
|
switch (state) {
|
|
|
|
case FSCACHE_COOKIE_STATE_CREATING:
|
|
|
|
case FSCACHE_COOKIE_STATE_INVALIDATING:
|
|
|
|
if (want_state == FSCACHE_WANT_PARAMS)
|
|
|
|
goto ready; /* There can be no content */
|
|
|
|
fallthrough;
|
|
|
|
case FSCACHE_COOKIE_STATE_LOOKING_UP:
|
|
|
|
case FSCACHE_COOKIE_STATE_LRU_DISCARDING:
|
|
|
|
wait_var_event(&cookie->state,
|
|
|
|
fscache_cookie_state(cookie) != state);
|
|
|
|
goto again;
|
|
|
|
|
|
|
|
case FSCACHE_COOKIE_STATE_ACTIVE:
|
|
|
|
goto ready;
|
|
|
|
case FSCACHE_COOKIE_STATE_DROPPED:
|
|
|
|
case FSCACHE_COOKIE_STATE_RELINQUISHING:
|
|
|
|
default:
|
2024-07-18 13:07:32 -07:00
|
|
|
_leave(" [not live]");
|
2021-10-20 06:06:34 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ready:
|
|
|
|
if (!cres->cache_priv2)
|
|
|
|
return cookie->volume->cache->ops->begin_operation(cres, want_state);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(fscache_wait_for_operation);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Begin an I/O operation on the cache, waiting till we reach the right state.
|
|
|
|
*
|
|
|
|
* Attaches the resources required to the operation resources record.
|
|
|
|
*/
|
|
|
|
static int fscache_begin_operation(struct netfs_cache_resources *cres,
|
|
|
|
struct fscache_cookie *cookie,
|
|
|
|
enum fscache_want_state want_state,
|
|
|
|
enum fscache_access_trace why)
|
|
|
|
{
|
|
|
|
enum fscache_cookie_state state;
|
|
|
|
long timeo;
|
|
|
|
bool once_only = false;
|
|
|
|
|
|
|
|
cres->ops = NULL;
|
|
|
|
cres->cache_priv = cookie;
|
|
|
|
cres->cache_priv2 = NULL;
|
|
|
|
cres->debug_id = cookie->debug_id;
|
|
|
|
cres->inval_counter = cookie->inval_counter;
|
|
|
|
|
2024-03-15 07:48:26 -07:00
|
|
|
if (!fscache_begin_cookie_access(cookie, why)) {
|
|
|
|
cres->cache_priv = NULL;
|
2021-10-20 06:06:34 -07:00
|
|
|
return -ENOBUFS;
|
2024-03-15 07:48:26 -07:00
|
|
|
}
|
2021-10-20 06:06:34 -07:00
|
|
|
|
|
|
|
again:
|
|
|
|
spin_lock(&cookie->lock);
|
|
|
|
|
|
|
|
state = fscache_cookie_state(cookie);
|
2024-07-18 13:07:32 -07:00
|
|
|
_enter("c=%08x{%u},%x", cookie->debug_id, state, want_state);
|
2021-10-20 06:06:34 -07:00
|
|
|
|
|
|
|
switch (state) {
|
|
|
|
case FSCACHE_COOKIE_STATE_LOOKING_UP:
|
|
|
|
case FSCACHE_COOKIE_STATE_LRU_DISCARDING:
|
|
|
|
case FSCACHE_COOKIE_STATE_INVALIDATING:
|
|
|
|
goto wait_for_file_wrangling;
|
|
|
|
case FSCACHE_COOKIE_STATE_CREATING:
|
|
|
|
if (want_state == FSCACHE_WANT_PARAMS)
|
|
|
|
goto ready; /* There can be no content */
|
|
|
|
goto wait_for_file_wrangling;
|
|
|
|
case FSCACHE_COOKIE_STATE_ACTIVE:
|
|
|
|
goto ready;
|
|
|
|
case FSCACHE_COOKIE_STATE_DROPPED:
|
|
|
|
case FSCACHE_COOKIE_STATE_RELINQUISHING:
|
|
|
|
WARN(1, "Can't use cookie in state %u\n", cookie->state);
|
|
|
|
goto not_live;
|
|
|
|
default:
|
|
|
|
goto not_live;
|
|
|
|
}
|
|
|
|
|
|
|
|
ready:
|
|
|
|
spin_unlock(&cookie->lock);
|
|
|
|
if (!cookie->volume->cache->ops->begin_operation(cres, want_state))
|
|
|
|
goto failed;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
wait_for_file_wrangling:
|
|
|
|
spin_unlock(&cookie->lock);
|
|
|
|
trace_fscache_access(cookie->debug_id, refcount_read(&cookie->ref),
|
|
|
|
atomic_read(&cookie->n_accesses),
|
|
|
|
fscache_access_io_wait);
|
|
|
|
timeo = wait_var_event_timeout(&cookie->state,
|
|
|
|
fscache_cookie_state(cookie) != state, 20 * HZ);
|
|
|
|
if (timeo <= 1 && !once_only) {
|
|
|
|
pr_warn("%s: cookie state change wait timed out: cookie->state=%u state=%u",
|
|
|
|
__func__, fscache_cookie_state(cookie), state);
|
|
|
|
fscache_print_cookie(cookie, 'O');
|
|
|
|
once_only = true;
|
|
|
|
}
|
|
|
|
goto again;
|
|
|
|
|
|
|
|
not_live:
|
|
|
|
spin_unlock(&cookie->lock);
|
|
|
|
failed:
|
|
|
|
cres->cache_priv = NULL;
|
|
|
|
cres->ops = NULL;
|
|
|
|
fscache_end_cookie_access(cookie, fscache_access_io_not_live);
|
2024-07-18 13:07:32 -07:00
|
|
|
_leave(" = -ENOBUFS");
|
2021-10-20 06:06:34 -07:00
|
|
|
return -ENOBUFS;
|
|
|
|
}
|
|
|
|
|
|
|
|
int __fscache_begin_read_operation(struct netfs_cache_resources *cres,
|
|
|
|
struct fscache_cookie *cookie)
|
|
|
|
{
|
|
|
|
return fscache_begin_operation(cres, cookie, FSCACHE_WANT_PARAMS,
|
|
|
|
fscache_access_io_read);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(__fscache_begin_read_operation);
|
fscache: Implement higher-level write I/O interface
Provide a higher-level function than fscache_write() to perform a write
from an inode's pagecache to the cache, whilst fending off concurrent
writes by means of the PG_fscache mark on a page:
void fscache_write_to_cache(struct fscache_cookie *cookie,
struct address_space *mapping,
loff_t start,
size_t len,
loff_t i_size,
netfs_io_terminated_t term_func,
void *term_func_priv,
bool caching);
If caching is false, this function does nothing except call (*term_func)()
if given. It assumes that, in such a case, PG_fscache will not have been
set on the pages.
Otherwise, if caching is true, this function requires the source pages to
have had PG_fscache set on them before calling. start and len define the
region of the file to be modified and i_size indicates the new file size.
The source pages are extracted from the mapping.
term_func and term_func_priv work as for fscache_write(). The PG_fscache
marks will be cleared at the end of the operation, before term_func is
called or the function otherwise returns.
There is an additonal helper function to clear the PG_fscache bits from a
range of pages:
void fscache_clear_page_bits(struct fscache_cookie *cookie,
struct address_space *mapping,
loff_t start, size_t len,
bool caching);
If caching is true, the pages to be managed are expected to be located on
mapping in the range defined by start and len. If caching is false, it
does nothing.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
cc: linux-cachefs@redhat.com
Link: https://lore.kernel.org/r/163819614155.215744.5528123235123721230.stgit@warthog.procyon.org.uk/ # v1
Link: https://lore.kernel.org/r/163906916346.143852.15632773570362489926.stgit@warthog.procyon.org.uk/ # v2
Link: https://lore.kernel.org/r/163967123599.1823006.12946816026724657428.stgit@warthog.procyon.org.uk/ # v3
Link: https://lore.kernel.org/r/164021522672.640689.4381958316198807813.stgit@warthog.procyon.org.uk/ # v4
2021-10-20 06:06:34 -07:00
|
|
|
|
2021-08-27 07:19:34 -07:00
|
|
|
int __fscache_begin_write_operation(struct netfs_cache_resources *cres,
|
|
|
|
struct fscache_cookie *cookie)
|
|
|
|
{
|
|
|
|
return fscache_begin_operation(cres, cookie, FSCACHE_WANT_PARAMS,
|
|
|
|
fscache_access_io_write);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(__fscache_begin_write_operation);
|
|
|
|
|
fscache: Implement higher-level write I/O interface
Provide a higher-level function than fscache_write() to perform a write
from an inode's pagecache to the cache, whilst fending off concurrent
writes by means of the PG_fscache mark on a page:
void fscache_write_to_cache(struct fscache_cookie *cookie,
struct address_space *mapping,
loff_t start,
size_t len,
loff_t i_size,
netfs_io_terminated_t term_func,
void *term_func_priv,
bool caching);
If caching is false, this function does nothing except call (*term_func)()
if given. It assumes that, in such a case, PG_fscache will not have been
set on the pages.
Otherwise, if caching is true, this function requires the source pages to
have had PG_fscache set on them before calling. start and len define the
region of the file to be modified and i_size indicates the new file size.
The source pages are extracted from the mapping.
term_func and term_func_priv work as for fscache_write(). The PG_fscache
marks will be cleared at the end of the operation, before term_func is
called or the function otherwise returns.
There is an additonal helper function to clear the PG_fscache bits from a
range of pages:
void fscache_clear_page_bits(struct fscache_cookie *cookie,
struct address_space *mapping,
loff_t start, size_t len,
bool caching);
If caching is true, the pages to be managed are expected to be located on
mapping in the range defined by start and len. If caching is false, it
does nothing.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
cc: linux-cachefs@redhat.com
Link: https://lore.kernel.org/r/163819614155.215744.5528123235123721230.stgit@warthog.procyon.org.uk/ # v1
Link: https://lore.kernel.org/r/163906916346.143852.15632773570362489926.stgit@warthog.procyon.org.uk/ # v2
Link: https://lore.kernel.org/r/163967123599.1823006.12946816026724657428.stgit@warthog.procyon.org.uk/ # v3
Link: https://lore.kernel.org/r/164021522672.640689.4381958316198807813.stgit@warthog.procyon.org.uk/ # v4
2021-10-20 06:06:34 -07:00
|
|
|
struct fscache_write_request {
|
|
|
|
struct netfs_cache_resources cache_resources;
|
|
|
|
struct address_space *mapping;
|
|
|
|
loff_t start;
|
|
|
|
size_t len;
|
|
|
|
bool set_bits;
|
netfs: Replace PG_fscache by setting folio->private and marking dirty
When dirty data is being written to the cache, setting/waiting on/clearing
the fscache flag is always done in tandem with setting/waiting on/clearing
the writeback flag. The netfslib buffered write routines wait on and set
both flags and the write request cleanup clears both flags, so the fscache
flag is almost superfluous.
The reason it isn't superfluous is because the fscache flag is also used to
indicate that data just read from the server is being written to the cache.
The flag is used to prevent a race involving overlapping direct-I/O writes
to the cache.
Change this to indicate that a page is in need of being copied to the cache
by placing a magic value in folio->private and marking the folios dirty.
Then when the writeback code sees a folio marked in this way, it only
writes it to the cache and not to the server.
If a folio that has this magic value set is modified, the value is just
replaced and the folio will then be uplodaded too.
With this, PG_fscache is no longer required by the netfslib core, 9p and
afs.
Ceph and nfs, however, still need to use the old PG_fscache-based tracking.
To deal with this, a flag, NETFS_ICTX_USE_PGPRIV2, now has to be set on the
flags in the netfs_inode struct for those filesystems. This reenables the
use of PG_fscache in that inode. 9p and afs use the netfslib write helpers
so get switched over; cifs, for the moment, does page-by-page manual access
to the cache, so doesn't use PG_fscache and is unaffected.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
cc: Matthew Wilcox (Oracle) <willy@infradead.org>
cc: Eric Van Hensbergen <ericvh@kernel.org>
cc: Latchesar Ionkov <lucho@ionkov.net>
cc: Dominique Martinet <asmadeus@codewreck.org>
cc: Christian Schoenebeck <linux_oss@crudebyte.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: Ilya Dryomov <idryomov@gmail.com>
cc: Xiubo Li <xiubli@redhat.com>
cc: Steve French <sfrench@samba.org>
cc: Paulo Alcantara <pc@manguebit.com>
cc: Ronnie Sahlberg <ronniesahlberg@gmail.com>
cc: Shyam Prasad N <sprasad@microsoft.com>
cc: Tom Talpey <tom@talpey.com>
cc: Bharath SM <bharathsm@microsoft.com>
cc: Trond Myklebust <trond.myklebust@hammerspace.com>
cc: Anna Schumaker <anna@kernel.org>
cc: netfs@lists.linux.dev
cc: v9fs@lists.linux.dev
cc: linux-afs@lists.infradead.org
cc: ceph-devel@vger.kernel.org
cc: linux-cifs@vger.kernel.org
cc: linux-nfs@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
cc: linux-mm@kvack.org
2024-03-19 03:00:09 -07:00
|
|
|
bool using_pgpriv2;
|
fscache: Implement higher-level write I/O interface
Provide a higher-level function than fscache_write() to perform a write
from an inode's pagecache to the cache, whilst fending off concurrent
writes by means of the PG_fscache mark on a page:
void fscache_write_to_cache(struct fscache_cookie *cookie,
struct address_space *mapping,
loff_t start,
size_t len,
loff_t i_size,
netfs_io_terminated_t term_func,
void *term_func_priv,
bool caching);
If caching is false, this function does nothing except call (*term_func)()
if given. It assumes that, in such a case, PG_fscache will not have been
set on the pages.
Otherwise, if caching is true, this function requires the source pages to
have had PG_fscache set on them before calling. start and len define the
region of the file to be modified and i_size indicates the new file size.
The source pages are extracted from the mapping.
term_func and term_func_priv work as for fscache_write(). The PG_fscache
marks will be cleared at the end of the operation, before term_func is
called or the function otherwise returns.
There is an additonal helper function to clear the PG_fscache bits from a
range of pages:
void fscache_clear_page_bits(struct fscache_cookie *cookie,
struct address_space *mapping,
loff_t start, size_t len,
bool caching);
If caching is true, the pages to be managed are expected to be located on
mapping in the range defined by start and len. If caching is false, it
does nothing.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
cc: linux-cachefs@redhat.com
Link: https://lore.kernel.org/r/163819614155.215744.5528123235123721230.stgit@warthog.procyon.org.uk/ # v1
Link: https://lore.kernel.org/r/163906916346.143852.15632773570362489926.stgit@warthog.procyon.org.uk/ # v2
Link: https://lore.kernel.org/r/163967123599.1823006.12946816026724657428.stgit@warthog.procyon.org.uk/ # v3
Link: https://lore.kernel.org/r/164021522672.640689.4381958316198807813.stgit@warthog.procyon.org.uk/ # v4
2021-10-20 06:06:34 -07:00
|
|
|
netfs_io_terminated_t term_func;
|
|
|
|
void *term_func_priv;
|
|
|
|
};
|
|
|
|
|
|
|
|
void __fscache_clear_page_bits(struct address_space *mapping,
|
|
|
|
loff_t start, size_t len)
|
|
|
|
{
|
|
|
|
pgoff_t first = start / PAGE_SIZE;
|
|
|
|
pgoff_t last = (start + len - 1) / PAGE_SIZE;
|
|
|
|
struct page *page;
|
|
|
|
|
|
|
|
if (len) {
|
|
|
|
XA_STATE(xas, &mapping->i_pages, first);
|
|
|
|
|
|
|
|
rcu_read_lock();
|
|
|
|
xas_for_each(&xas, page, last) {
|
2024-03-19 04:13:26 -07:00
|
|
|
folio_end_private_2(page_folio(page));
|
fscache: Implement higher-level write I/O interface
Provide a higher-level function than fscache_write() to perform a write
from an inode's pagecache to the cache, whilst fending off concurrent
writes by means of the PG_fscache mark on a page:
void fscache_write_to_cache(struct fscache_cookie *cookie,
struct address_space *mapping,
loff_t start,
size_t len,
loff_t i_size,
netfs_io_terminated_t term_func,
void *term_func_priv,
bool caching);
If caching is false, this function does nothing except call (*term_func)()
if given. It assumes that, in such a case, PG_fscache will not have been
set on the pages.
Otherwise, if caching is true, this function requires the source pages to
have had PG_fscache set on them before calling. start and len define the
region of the file to be modified and i_size indicates the new file size.
The source pages are extracted from the mapping.
term_func and term_func_priv work as for fscache_write(). The PG_fscache
marks will be cleared at the end of the operation, before term_func is
called or the function otherwise returns.
There is an additonal helper function to clear the PG_fscache bits from a
range of pages:
void fscache_clear_page_bits(struct fscache_cookie *cookie,
struct address_space *mapping,
loff_t start, size_t len,
bool caching);
If caching is true, the pages to be managed are expected to be located on
mapping in the range defined by start and len. If caching is false, it
does nothing.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
cc: linux-cachefs@redhat.com
Link: https://lore.kernel.org/r/163819614155.215744.5528123235123721230.stgit@warthog.procyon.org.uk/ # v1
Link: https://lore.kernel.org/r/163906916346.143852.15632773570362489926.stgit@warthog.procyon.org.uk/ # v2
Link: https://lore.kernel.org/r/163967123599.1823006.12946816026724657428.stgit@warthog.procyon.org.uk/ # v3
Link: https://lore.kernel.org/r/164021522672.640689.4381958316198807813.stgit@warthog.procyon.org.uk/ # v4
2021-10-20 06:06:34 -07:00
|
|
|
}
|
|
|
|
rcu_read_unlock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(__fscache_clear_page_bits);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Deal with the completion of writing the data to the cache.
|
|
|
|
*/
|
|
|
|
static void fscache_wreq_done(void *priv, ssize_t transferred_or_error,
|
|
|
|
bool was_async)
|
|
|
|
{
|
|
|
|
struct fscache_write_request *wreq = priv;
|
|
|
|
|
netfs: Replace PG_fscache by setting folio->private and marking dirty
When dirty data is being written to the cache, setting/waiting on/clearing
the fscache flag is always done in tandem with setting/waiting on/clearing
the writeback flag. The netfslib buffered write routines wait on and set
both flags and the write request cleanup clears both flags, so the fscache
flag is almost superfluous.
The reason it isn't superfluous is because the fscache flag is also used to
indicate that data just read from the server is being written to the cache.
The flag is used to prevent a race involving overlapping direct-I/O writes
to the cache.
Change this to indicate that a page is in need of being copied to the cache
by placing a magic value in folio->private and marking the folios dirty.
Then when the writeback code sees a folio marked in this way, it only
writes it to the cache and not to the server.
If a folio that has this magic value set is modified, the value is just
replaced and the folio will then be uplodaded too.
With this, PG_fscache is no longer required by the netfslib core, 9p and
afs.
Ceph and nfs, however, still need to use the old PG_fscache-based tracking.
To deal with this, a flag, NETFS_ICTX_USE_PGPRIV2, now has to be set on the
flags in the netfs_inode struct for those filesystems. This reenables the
use of PG_fscache in that inode. 9p and afs use the netfslib write helpers
so get switched over; cifs, for the moment, does page-by-page manual access
to the cache, so doesn't use PG_fscache and is unaffected.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
cc: Matthew Wilcox (Oracle) <willy@infradead.org>
cc: Eric Van Hensbergen <ericvh@kernel.org>
cc: Latchesar Ionkov <lucho@ionkov.net>
cc: Dominique Martinet <asmadeus@codewreck.org>
cc: Christian Schoenebeck <linux_oss@crudebyte.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: Ilya Dryomov <idryomov@gmail.com>
cc: Xiubo Li <xiubli@redhat.com>
cc: Steve French <sfrench@samba.org>
cc: Paulo Alcantara <pc@manguebit.com>
cc: Ronnie Sahlberg <ronniesahlberg@gmail.com>
cc: Shyam Prasad N <sprasad@microsoft.com>
cc: Tom Talpey <tom@talpey.com>
cc: Bharath SM <bharathsm@microsoft.com>
cc: Trond Myklebust <trond.myklebust@hammerspace.com>
cc: Anna Schumaker <anna@kernel.org>
cc: netfs@lists.linux.dev
cc: v9fs@lists.linux.dev
cc: linux-afs@lists.infradead.org
cc: ceph-devel@vger.kernel.org
cc: linux-cifs@vger.kernel.org
cc: linux-nfs@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
cc: linux-mm@kvack.org
2024-03-19 03:00:09 -07:00
|
|
|
if (wreq->using_pgpriv2)
|
|
|
|
fscache_clear_page_bits(wreq->mapping, wreq->start, wreq->len,
|
|
|
|
wreq->set_bits);
|
fscache: Implement higher-level write I/O interface
Provide a higher-level function than fscache_write() to perform a write
from an inode's pagecache to the cache, whilst fending off concurrent
writes by means of the PG_fscache mark on a page:
void fscache_write_to_cache(struct fscache_cookie *cookie,
struct address_space *mapping,
loff_t start,
size_t len,
loff_t i_size,
netfs_io_terminated_t term_func,
void *term_func_priv,
bool caching);
If caching is false, this function does nothing except call (*term_func)()
if given. It assumes that, in such a case, PG_fscache will not have been
set on the pages.
Otherwise, if caching is true, this function requires the source pages to
have had PG_fscache set on them before calling. start and len define the
region of the file to be modified and i_size indicates the new file size.
The source pages are extracted from the mapping.
term_func and term_func_priv work as for fscache_write(). The PG_fscache
marks will be cleared at the end of the operation, before term_func is
called or the function otherwise returns.
There is an additonal helper function to clear the PG_fscache bits from a
range of pages:
void fscache_clear_page_bits(struct fscache_cookie *cookie,
struct address_space *mapping,
loff_t start, size_t len,
bool caching);
If caching is true, the pages to be managed are expected to be located on
mapping in the range defined by start and len. If caching is false, it
does nothing.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
cc: linux-cachefs@redhat.com
Link: https://lore.kernel.org/r/163819614155.215744.5528123235123721230.stgit@warthog.procyon.org.uk/ # v1
Link: https://lore.kernel.org/r/163906916346.143852.15632773570362489926.stgit@warthog.procyon.org.uk/ # v2
Link: https://lore.kernel.org/r/163967123599.1823006.12946816026724657428.stgit@warthog.procyon.org.uk/ # v3
Link: https://lore.kernel.org/r/164021522672.640689.4381958316198807813.stgit@warthog.procyon.org.uk/ # v4
2021-10-20 06:06:34 -07:00
|
|
|
|
|
|
|
if (wreq->term_func)
|
|
|
|
wreq->term_func(wreq->term_func_priv, transferred_or_error,
|
|
|
|
was_async);
|
|
|
|
fscache_end_operation(&wreq->cache_resources);
|
|
|
|
kfree(wreq);
|
|
|
|
}
|
|
|
|
|
|
|
|
void __fscache_write_to_cache(struct fscache_cookie *cookie,
|
|
|
|
struct address_space *mapping,
|
|
|
|
loff_t start, size_t len, loff_t i_size,
|
|
|
|
netfs_io_terminated_t term_func,
|
|
|
|
void *term_func_priv,
|
netfs: Replace PG_fscache by setting folio->private and marking dirty
When dirty data is being written to the cache, setting/waiting on/clearing
the fscache flag is always done in tandem with setting/waiting on/clearing
the writeback flag. The netfslib buffered write routines wait on and set
both flags and the write request cleanup clears both flags, so the fscache
flag is almost superfluous.
The reason it isn't superfluous is because the fscache flag is also used to
indicate that data just read from the server is being written to the cache.
The flag is used to prevent a race involving overlapping direct-I/O writes
to the cache.
Change this to indicate that a page is in need of being copied to the cache
by placing a magic value in folio->private and marking the folios dirty.
Then when the writeback code sees a folio marked in this way, it only
writes it to the cache and not to the server.
If a folio that has this magic value set is modified, the value is just
replaced and the folio will then be uplodaded too.
With this, PG_fscache is no longer required by the netfslib core, 9p and
afs.
Ceph and nfs, however, still need to use the old PG_fscache-based tracking.
To deal with this, a flag, NETFS_ICTX_USE_PGPRIV2, now has to be set on the
flags in the netfs_inode struct for those filesystems. This reenables the
use of PG_fscache in that inode. 9p and afs use the netfslib write helpers
so get switched over; cifs, for the moment, does page-by-page manual access
to the cache, so doesn't use PG_fscache and is unaffected.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
cc: Matthew Wilcox (Oracle) <willy@infradead.org>
cc: Eric Van Hensbergen <ericvh@kernel.org>
cc: Latchesar Ionkov <lucho@ionkov.net>
cc: Dominique Martinet <asmadeus@codewreck.org>
cc: Christian Schoenebeck <linux_oss@crudebyte.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: Ilya Dryomov <idryomov@gmail.com>
cc: Xiubo Li <xiubli@redhat.com>
cc: Steve French <sfrench@samba.org>
cc: Paulo Alcantara <pc@manguebit.com>
cc: Ronnie Sahlberg <ronniesahlberg@gmail.com>
cc: Shyam Prasad N <sprasad@microsoft.com>
cc: Tom Talpey <tom@talpey.com>
cc: Bharath SM <bharathsm@microsoft.com>
cc: Trond Myklebust <trond.myklebust@hammerspace.com>
cc: Anna Schumaker <anna@kernel.org>
cc: netfs@lists.linux.dev
cc: v9fs@lists.linux.dev
cc: linux-afs@lists.infradead.org
cc: ceph-devel@vger.kernel.org
cc: linux-cifs@vger.kernel.org
cc: linux-nfs@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
cc: linux-mm@kvack.org
2024-03-19 03:00:09 -07:00
|
|
|
bool using_pgpriv2, bool cond)
|
fscache: Implement higher-level write I/O interface
Provide a higher-level function than fscache_write() to perform a write
from an inode's pagecache to the cache, whilst fending off concurrent
writes by means of the PG_fscache mark on a page:
void fscache_write_to_cache(struct fscache_cookie *cookie,
struct address_space *mapping,
loff_t start,
size_t len,
loff_t i_size,
netfs_io_terminated_t term_func,
void *term_func_priv,
bool caching);
If caching is false, this function does nothing except call (*term_func)()
if given. It assumes that, in such a case, PG_fscache will not have been
set on the pages.
Otherwise, if caching is true, this function requires the source pages to
have had PG_fscache set on them before calling. start and len define the
region of the file to be modified and i_size indicates the new file size.
The source pages are extracted from the mapping.
term_func and term_func_priv work as for fscache_write(). The PG_fscache
marks will be cleared at the end of the operation, before term_func is
called or the function otherwise returns.
There is an additonal helper function to clear the PG_fscache bits from a
range of pages:
void fscache_clear_page_bits(struct fscache_cookie *cookie,
struct address_space *mapping,
loff_t start, size_t len,
bool caching);
If caching is true, the pages to be managed are expected to be located on
mapping in the range defined by start and len. If caching is false, it
does nothing.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
cc: linux-cachefs@redhat.com
Link: https://lore.kernel.org/r/163819614155.215744.5528123235123721230.stgit@warthog.procyon.org.uk/ # v1
Link: https://lore.kernel.org/r/163906916346.143852.15632773570362489926.stgit@warthog.procyon.org.uk/ # v2
Link: https://lore.kernel.org/r/163967123599.1823006.12946816026724657428.stgit@warthog.procyon.org.uk/ # v3
Link: https://lore.kernel.org/r/164021522672.640689.4381958316198807813.stgit@warthog.procyon.org.uk/ # v4
2021-10-20 06:06:34 -07:00
|
|
|
{
|
|
|
|
struct fscache_write_request *wreq;
|
|
|
|
struct netfs_cache_resources *cres;
|
|
|
|
struct iov_iter iter;
|
|
|
|
int ret = -ENOBUFS;
|
|
|
|
|
|
|
|
if (len == 0)
|
|
|
|
goto abandon;
|
|
|
|
|
2024-07-18 13:07:32 -07:00
|
|
|
_enter("%llx,%zx", start, len);
|
fscache: Implement higher-level write I/O interface
Provide a higher-level function than fscache_write() to perform a write
from an inode's pagecache to the cache, whilst fending off concurrent
writes by means of the PG_fscache mark on a page:
void fscache_write_to_cache(struct fscache_cookie *cookie,
struct address_space *mapping,
loff_t start,
size_t len,
loff_t i_size,
netfs_io_terminated_t term_func,
void *term_func_priv,
bool caching);
If caching is false, this function does nothing except call (*term_func)()
if given. It assumes that, in such a case, PG_fscache will not have been
set on the pages.
Otherwise, if caching is true, this function requires the source pages to
have had PG_fscache set on them before calling. start and len define the
region of the file to be modified and i_size indicates the new file size.
The source pages are extracted from the mapping.
term_func and term_func_priv work as for fscache_write(). The PG_fscache
marks will be cleared at the end of the operation, before term_func is
called or the function otherwise returns.
There is an additonal helper function to clear the PG_fscache bits from a
range of pages:
void fscache_clear_page_bits(struct fscache_cookie *cookie,
struct address_space *mapping,
loff_t start, size_t len,
bool caching);
If caching is true, the pages to be managed are expected to be located on
mapping in the range defined by start and len. If caching is false, it
does nothing.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
cc: linux-cachefs@redhat.com
Link: https://lore.kernel.org/r/163819614155.215744.5528123235123721230.stgit@warthog.procyon.org.uk/ # v1
Link: https://lore.kernel.org/r/163906916346.143852.15632773570362489926.stgit@warthog.procyon.org.uk/ # v2
Link: https://lore.kernel.org/r/163967123599.1823006.12946816026724657428.stgit@warthog.procyon.org.uk/ # v3
Link: https://lore.kernel.org/r/164021522672.640689.4381958316198807813.stgit@warthog.procyon.org.uk/ # v4
2021-10-20 06:06:34 -07:00
|
|
|
|
|
|
|
wreq = kzalloc(sizeof(struct fscache_write_request), GFP_NOFS);
|
|
|
|
if (!wreq)
|
|
|
|
goto abandon;
|
|
|
|
wreq->mapping = mapping;
|
|
|
|
wreq->start = start;
|
|
|
|
wreq->len = len;
|
netfs: Replace PG_fscache by setting folio->private and marking dirty
When dirty data is being written to the cache, setting/waiting on/clearing
the fscache flag is always done in tandem with setting/waiting on/clearing
the writeback flag. The netfslib buffered write routines wait on and set
both flags and the write request cleanup clears both flags, so the fscache
flag is almost superfluous.
The reason it isn't superfluous is because the fscache flag is also used to
indicate that data just read from the server is being written to the cache.
The flag is used to prevent a race involving overlapping direct-I/O writes
to the cache.
Change this to indicate that a page is in need of being copied to the cache
by placing a magic value in folio->private and marking the folios dirty.
Then when the writeback code sees a folio marked in this way, it only
writes it to the cache and not to the server.
If a folio that has this magic value set is modified, the value is just
replaced and the folio will then be uplodaded too.
With this, PG_fscache is no longer required by the netfslib core, 9p and
afs.
Ceph and nfs, however, still need to use the old PG_fscache-based tracking.
To deal with this, a flag, NETFS_ICTX_USE_PGPRIV2, now has to be set on the
flags in the netfs_inode struct for those filesystems. This reenables the
use of PG_fscache in that inode. 9p and afs use the netfslib write helpers
so get switched over; cifs, for the moment, does page-by-page manual access
to the cache, so doesn't use PG_fscache and is unaffected.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
cc: Matthew Wilcox (Oracle) <willy@infradead.org>
cc: Eric Van Hensbergen <ericvh@kernel.org>
cc: Latchesar Ionkov <lucho@ionkov.net>
cc: Dominique Martinet <asmadeus@codewreck.org>
cc: Christian Schoenebeck <linux_oss@crudebyte.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: Ilya Dryomov <idryomov@gmail.com>
cc: Xiubo Li <xiubli@redhat.com>
cc: Steve French <sfrench@samba.org>
cc: Paulo Alcantara <pc@manguebit.com>
cc: Ronnie Sahlberg <ronniesahlberg@gmail.com>
cc: Shyam Prasad N <sprasad@microsoft.com>
cc: Tom Talpey <tom@talpey.com>
cc: Bharath SM <bharathsm@microsoft.com>
cc: Trond Myklebust <trond.myklebust@hammerspace.com>
cc: Anna Schumaker <anna@kernel.org>
cc: netfs@lists.linux.dev
cc: v9fs@lists.linux.dev
cc: linux-afs@lists.infradead.org
cc: ceph-devel@vger.kernel.org
cc: linux-cifs@vger.kernel.org
cc: linux-nfs@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
cc: linux-mm@kvack.org
2024-03-19 03:00:09 -07:00
|
|
|
wreq->using_pgpriv2 = using_pgpriv2;
|
fscache: Implement higher-level write I/O interface
Provide a higher-level function than fscache_write() to perform a write
from an inode's pagecache to the cache, whilst fending off concurrent
writes by means of the PG_fscache mark on a page:
void fscache_write_to_cache(struct fscache_cookie *cookie,
struct address_space *mapping,
loff_t start,
size_t len,
loff_t i_size,
netfs_io_terminated_t term_func,
void *term_func_priv,
bool caching);
If caching is false, this function does nothing except call (*term_func)()
if given. It assumes that, in such a case, PG_fscache will not have been
set on the pages.
Otherwise, if caching is true, this function requires the source pages to
have had PG_fscache set on them before calling. start and len define the
region of the file to be modified and i_size indicates the new file size.
The source pages are extracted from the mapping.
term_func and term_func_priv work as for fscache_write(). The PG_fscache
marks will be cleared at the end of the operation, before term_func is
called or the function otherwise returns.
There is an additonal helper function to clear the PG_fscache bits from a
range of pages:
void fscache_clear_page_bits(struct fscache_cookie *cookie,
struct address_space *mapping,
loff_t start, size_t len,
bool caching);
If caching is true, the pages to be managed are expected to be located on
mapping in the range defined by start and len. If caching is false, it
does nothing.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
cc: linux-cachefs@redhat.com
Link: https://lore.kernel.org/r/163819614155.215744.5528123235123721230.stgit@warthog.procyon.org.uk/ # v1
Link: https://lore.kernel.org/r/163906916346.143852.15632773570362489926.stgit@warthog.procyon.org.uk/ # v2
Link: https://lore.kernel.org/r/163967123599.1823006.12946816026724657428.stgit@warthog.procyon.org.uk/ # v3
Link: https://lore.kernel.org/r/164021522672.640689.4381958316198807813.stgit@warthog.procyon.org.uk/ # v4
2021-10-20 06:06:34 -07:00
|
|
|
wreq->set_bits = cond;
|
|
|
|
wreq->term_func = term_func;
|
|
|
|
wreq->term_func_priv = term_func_priv;
|
|
|
|
|
|
|
|
cres = &wreq->cache_resources;
|
|
|
|
if (fscache_begin_operation(cres, cookie, FSCACHE_WANT_WRITE,
|
|
|
|
fscache_access_io_write) < 0)
|
|
|
|
goto abandon_free;
|
|
|
|
|
2023-11-22 10:18:17 -07:00
|
|
|
ret = cres->ops->prepare_write(cres, &start, &len, len, i_size, false);
|
fscache: Implement higher-level write I/O interface
Provide a higher-level function than fscache_write() to perform a write
from an inode's pagecache to the cache, whilst fending off concurrent
writes by means of the PG_fscache mark on a page:
void fscache_write_to_cache(struct fscache_cookie *cookie,
struct address_space *mapping,
loff_t start,
size_t len,
loff_t i_size,
netfs_io_terminated_t term_func,
void *term_func_priv,
bool caching);
If caching is false, this function does nothing except call (*term_func)()
if given. It assumes that, in such a case, PG_fscache will not have been
set on the pages.
Otherwise, if caching is true, this function requires the source pages to
have had PG_fscache set on them before calling. start and len define the
region of the file to be modified and i_size indicates the new file size.
The source pages are extracted from the mapping.
term_func and term_func_priv work as for fscache_write(). The PG_fscache
marks will be cleared at the end of the operation, before term_func is
called or the function otherwise returns.
There is an additonal helper function to clear the PG_fscache bits from a
range of pages:
void fscache_clear_page_bits(struct fscache_cookie *cookie,
struct address_space *mapping,
loff_t start, size_t len,
bool caching);
If caching is true, the pages to be managed are expected to be located on
mapping in the range defined by start and len. If caching is false, it
does nothing.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
cc: linux-cachefs@redhat.com
Link: https://lore.kernel.org/r/163819614155.215744.5528123235123721230.stgit@warthog.procyon.org.uk/ # v1
Link: https://lore.kernel.org/r/163906916346.143852.15632773570362489926.stgit@warthog.procyon.org.uk/ # v2
Link: https://lore.kernel.org/r/163967123599.1823006.12946816026724657428.stgit@warthog.procyon.org.uk/ # v3
Link: https://lore.kernel.org/r/164021522672.640689.4381958316198807813.stgit@warthog.procyon.org.uk/ # v4
2021-10-20 06:06:34 -07:00
|
|
|
if (ret < 0)
|
|
|
|
goto abandon_end;
|
|
|
|
|
|
|
|
/* TODO: Consider clearing page bits now for space the write isn't
|
|
|
|
* covering. This is more complicated than it appears when THPs are
|
|
|
|
* taken into account.
|
|
|
|
*/
|
|
|
|
|
2022-09-15 17:25:47 -07:00
|
|
|
iov_iter_xarray(&iter, ITER_SOURCE, &mapping->i_pages, start, len);
|
fscache: Implement higher-level write I/O interface
Provide a higher-level function than fscache_write() to perform a write
from an inode's pagecache to the cache, whilst fending off concurrent
writes by means of the PG_fscache mark on a page:
void fscache_write_to_cache(struct fscache_cookie *cookie,
struct address_space *mapping,
loff_t start,
size_t len,
loff_t i_size,
netfs_io_terminated_t term_func,
void *term_func_priv,
bool caching);
If caching is false, this function does nothing except call (*term_func)()
if given. It assumes that, in such a case, PG_fscache will not have been
set on the pages.
Otherwise, if caching is true, this function requires the source pages to
have had PG_fscache set on them before calling. start and len define the
region of the file to be modified and i_size indicates the new file size.
The source pages are extracted from the mapping.
term_func and term_func_priv work as for fscache_write(). The PG_fscache
marks will be cleared at the end of the operation, before term_func is
called or the function otherwise returns.
There is an additonal helper function to clear the PG_fscache bits from a
range of pages:
void fscache_clear_page_bits(struct fscache_cookie *cookie,
struct address_space *mapping,
loff_t start, size_t len,
bool caching);
If caching is true, the pages to be managed are expected to be located on
mapping in the range defined by start and len. If caching is false, it
does nothing.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
cc: linux-cachefs@redhat.com
Link: https://lore.kernel.org/r/163819614155.215744.5528123235123721230.stgit@warthog.procyon.org.uk/ # v1
Link: https://lore.kernel.org/r/163906916346.143852.15632773570362489926.stgit@warthog.procyon.org.uk/ # v2
Link: https://lore.kernel.org/r/163967123599.1823006.12946816026724657428.stgit@warthog.procyon.org.uk/ # v3
Link: https://lore.kernel.org/r/164021522672.640689.4381958316198807813.stgit@warthog.procyon.org.uk/ # v4
2021-10-20 06:06:34 -07:00
|
|
|
fscache_write(cres, start, &iter, fscache_wreq_done, wreq);
|
|
|
|
return;
|
|
|
|
|
|
|
|
abandon_end:
|
|
|
|
return fscache_wreq_done(wreq, ret, false);
|
|
|
|
abandon_free:
|
|
|
|
kfree(wreq);
|
|
|
|
abandon:
|
netfs: Replace PG_fscache by setting folio->private and marking dirty
When dirty data is being written to the cache, setting/waiting on/clearing
the fscache flag is always done in tandem with setting/waiting on/clearing
the writeback flag. The netfslib buffered write routines wait on and set
both flags and the write request cleanup clears both flags, so the fscache
flag is almost superfluous.
The reason it isn't superfluous is because the fscache flag is also used to
indicate that data just read from the server is being written to the cache.
The flag is used to prevent a race involving overlapping direct-I/O writes
to the cache.
Change this to indicate that a page is in need of being copied to the cache
by placing a magic value in folio->private and marking the folios dirty.
Then when the writeback code sees a folio marked in this way, it only
writes it to the cache and not to the server.
If a folio that has this magic value set is modified, the value is just
replaced and the folio will then be uplodaded too.
With this, PG_fscache is no longer required by the netfslib core, 9p and
afs.
Ceph and nfs, however, still need to use the old PG_fscache-based tracking.
To deal with this, a flag, NETFS_ICTX_USE_PGPRIV2, now has to be set on the
flags in the netfs_inode struct for those filesystems. This reenables the
use of PG_fscache in that inode. 9p and afs use the netfslib write helpers
so get switched over; cifs, for the moment, does page-by-page manual access
to the cache, so doesn't use PG_fscache and is unaffected.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
cc: Matthew Wilcox (Oracle) <willy@infradead.org>
cc: Eric Van Hensbergen <ericvh@kernel.org>
cc: Latchesar Ionkov <lucho@ionkov.net>
cc: Dominique Martinet <asmadeus@codewreck.org>
cc: Christian Schoenebeck <linux_oss@crudebyte.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: Ilya Dryomov <idryomov@gmail.com>
cc: Xiubo Li <xiubli@redhat.com>
cc: Steve French <sfrench@samba.org>
cc: Paulo Alcantara <pc@manguebit.com>
cc: Ronnie Sahlberg <ronniesahlberg@gmail.com>
cc: Shyam Prasad N <sprasad@microsoft.com>
cc: Tom Talpey <tom@talpey.com>
cc: Bharath SM <bharathsm@microsoft.com>
cc: Trond Myklebust <trond.myklebust@hammerspace.com>
cc: Anna Schumaker <anna@kernel.org>
cc: netfs@lists.linux.dev
cc: v9fs@lists.linux.dev
cc: linux-afs@lists.infradead.org
cc: ceph-devel@vger.kernel.org
cc: linux-cifs@vger.kernel.org
cc: linux-nfs@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
cc: linux-mm@kvack.org
2024-03-19 03:00:09 -07:00
|
|
|
if (using_pgpriv2)
|
|
|
|
fscache_clear_page_bits(mapping, start, len, cond);
|
fscache: Implement higher-level write I/O interface
Provide a higher-level function than fscache_write() to perform a write
from an inode's pagecache to the cache, whilst fending off concurrent
writes by means of the PG_fscache mark on a page:
void fscache_write_to_cache(struct fscache_cookie *cookie,
struct address_space *mapping,
loff_t start,
size_t len,
loff_t i_size,
netfs_io_terminated_t term_func,
void *term_func_priv,
bool caching);
If caching is false, this function does nothing except call (*term_func)()
if given. It assumes that, in such a case, PG_fscache will not have been
set on the pages.
Otherwise, if caching is true, this function requires the source pages to
have had PG_fscache set on them before calling. start and len define the
region of the file to be modified and i_size indicates the new file size.
The source pages are extracted from the mapping.
term_func and term_func_priv work as for fscache_write(). The PG_fscache
marks will be cleared at the end of the operation, before term_func is
called or the function otherwise returns.
There is an additonal helper function to clear the PG_fscache bits from a
range of pages:
void fscache_clear_page_bits(struct fscache_cookie *cookie,
struct address_space *mapping,
loff_t start, size_t len,
bool caching);
If caching is true, the pages to be managed are expected to be located on
mapping in the range defined by start and len. If caching is false, it
does nothing.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
cc: linux-cachefs@redhat.com
Link: https://lore.kernel.org/r/163819614155.215744.5528123235123721230.stgit@warthog.procyon.org.uk/ # v1
Link: https://lore.kernel.org/r/163906916346.143852.15632773570362489926.stgit@warthog.procyon.org.uk/ # v2
Link: https://lore.kernel.org/r/163967123599.1823006.12946816026724657428.stgit@warthog.procyon.org.uk/ # v3
Link: https://lore.kernel.org/r/164021522672.640689.4381958316198807813.stgit@warthog.procyon.org.uk/ # v4
2021-10-20 06:06:34 -07:00
|
|
|
if (term_func)
|
|
|
|
term_func(term_func_priv, ret, false);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(__fscache_write_to_cache);
|
2021-10-20 06:06:34 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Change the size of a backing object.
|
|
|
|
*/
|
|
|
|
void __fscache_resize_cookie(struct fscache_cookie *cookie, loff_t new_size)
|
|
|
|
{
|
|
|
|
struct netfs_cache_resources cres;
|
|
|
|
|
|
|
|
trace_fscache_resize(cookie, new_size);
|
|
|
|
if (fscache_begin_operation(&cres, cookie, FSCACHE_WANT_WRITE,
|
|
|
|
fscache_access_io_resize) == 0) {
|
|
|
|
fscache_stat(&fscache_n_resizes);
|
|
|
|
set_bit(FSCACHE_COOKIE_NEEDS_UPDATE, &cookie->flags);
|
|
|
|
|
|
|
|
/* We cannot defer a resize as we need to do it inside the
|
|
|
|
* netfs's inode lock so that we're serialised with respect to
|
|
|
|
* writes.
|
|
|
|
*/
|
|
|
|
cookie->volume->cache->ops->resize_cookie(&cres, new_size);
|
|
|
|
fscache_end_operation(&cres);
|
|
|
|
} else {
|
|
|
|
fscache_stat(&fscache_n_resizes_null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(__fscache_resize_cookie);
|