2019-05-28 19:57:16 +03:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2006-01-19 04:43:02 +03:00
|
|
|
/*
|
|
|
|
* This file contians vfs address (mmap) ops for 9P2000.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 by Eric Van Hensbergen <ericvh@gmail.com>
|
|
|
|
* Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/file.h>
|
|
|
|
#include <linux/stat.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/inet.h>
|
|
|
|
#include <linux/pagemap.h>
|
|
|
|
#include <linux/idr.h>
|
Detach sched.h from mm.h
First thing mm.h does is including sched.h solely for can_do_mlock() inline
function which has "current" dereference inside. By dealing with can_do_mlock()
mm.h can be detached from sched.h which is good. See below, why.
This patch
a) removes unconditional inclusion of sched.h from mm.h
b) makes can_do_mlock() normal function in mm/mlock.c
c) exports can_do_mlock() to not break compilation
d) adds sched.h inclusions back to files that were getting it indirectly.
e) adds less bloated headers to some files (asm/signal.h, jiffies.h) that were
getting them indirectly
Net result is:
a) mm.h users would get less code to open, read, preprocess, parse, ... if
they don't need sched.h
b) sched.h stops being dependency for significant number of files:
on x86_64 allmodconfig touching sched.h results in recompile of 4083 files,
after patch it's only 3744 (-8.3%).
Cross-compile tested on
all arm defconfigs, all mips defconfigs, all powerpc defconfigs,
alpha alpha-up
arm
i386 i386-up i386-defconfig i386-allnoconfig
ia64 ia64-up
m68k
mips
parisc parisc-up
powerpc powerpc-up
s390 s390-up
sparc sparc-up
sparc64 sparc64-up
um-x86_64
x86_64 x86_64-up x86_64-defconfig x86_64-allnoconfig
as well as my two usual configs.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-05-21 01:22:52 +04:00
|
|
|
#include <linux/sched.h>
|
2021-12-22 20:21:04 +03:00
|
|
|
#include <linux/swap.h>
|
2015-02-22 19:58:50 +03:00
|
|
|
#include <linux/uio.h>
|
2021-11-02 11:29:55 +03:00
|
|
|
#include <linux/netfs.h>
|
2007-07-11 02:57:28 +04:00
|
|
|
#include <net/9p/9p.h>
|
|
|
|
#include <net/9p/client.h>
|
2006-01-19 04:43:02 +03:00
|
|
|
|
|
|
|
#include "v9fs.h"
|
|
|
|
#include "v9fs_vfs.h"
|
2009-09-23 22:00:27 +04:00
|
|
|
#include "cache.h"
|
2011-02-28 14:33:58 +03:00
|
|
|
#include "fid.h"
|
2006-01-19 04:43:02 +03:00
|
|
|
|
|
|
|
/**
|
2022-02-17 13:14:32 +03:00
|
|
|
* v9fs_issue_read - Issue a read from 9P
|
2021-11-02 11:29:55 +03:00
|
|
|
* @subreq: The read to make
|
2006-01-19 04:43:02 +03:00
|
|
|
*/
|
2022-02-17 13:14:32 +03:00
|
|
|
static void v9fs_issue_read(struct netfs_io_subrequest *subreq)
|
2006-01-19 04:43:02 +03:00
|
|
|
{
|
2022-02-17 13:01:23 +03:00
|
|
|
struct netfs_io_request *rreq = subreq->rreq;
|
2021-11-02 11:29:55 +03:00
|
|
|
struct p9_fid *fid = rreq->netfs_priv;
|
2015-04-02 06:42:28 +03:00
|
|
|
struct iov_iter to;
|
2021-11-02 11:29:55 +03:00
|
|
|
loff_t pos = subreq->start + subreq->transferred;
|
|
|
|
size_t len = subreq->len - subreq->transferred;
|
|
|
|
int total, err;
|
2007-02-11 22:21:39 +03:00
|
|
|
|
2021-11-02 11:29:55 +03:00
|
|
|
iov_iter_xarray(&to, READ, &rreq->mapping->i_pages, pos, len);
|
2009-09-23 22:00:27 +04:00
|
|
|
|
2021-11-02 11:29:55 +03:00
|
|
|
total = p9_client_read(fid, pos, &to, &err);
|
2022-01-10 14:10:31 +03:00
|
|
|
|
|
|
|
/* if we just extended the file size, any portion not in
|
|
|
|
* cache won't be on server and is zeroes */
|
|
|
|
__set_bit(NETFS_SREQ_CLEAR_TAIL, &subreq->flags);
|
|
|
|
|
2021-11-02 11:29:55 +03:00
|
|
|
netfs_subreq_terminated(subreq, err ?: total, false);
|
|
|
|
}
|
2009-09-23 22:00:27 +04:00
|
|
|
|
2021-11-02 11:29:55 +03:00
|
|
|
/**
|
2022-02-17 13:01:23 +03:00
|
|
|
* v9fs_init_request - Initialise a read request
|
2021-11-02 11:29:55 +03:00
|
|
|
* @rreq: The read request
|
|
|
|
* @file: The file being read from
|
|
|
|
*/
|
2022-01-21 00:55:46 +03:00
|
|
|
static int v9fs_init_request(struct netfs_io_request *rreq, struct file *file)
|
2021-11-02 11:29:55 +03:00
|
|
|
{
|
|
|
|
struct p9_fid *fid = file->private_data;
|
2009-09-23 22:00:27 +04:00
|
|
|
|
2021-11-02 11:29:55 +03:00
|
|
|
refcount_inc(&fid->count);
|
|
|
|
rreq->netfs_priv = fid;
|
2022-01-21 00:55:46 +03:00
|
|
|
return 0;
|
2021-11-02 11:29:55 +03:00
|
|
|
}
|
2006-01-19 04:43:02 +03:00
|
|
|
|
2021-11-02 11:29:55 +03:00
|
|
|
/**
|
2022-02-17 13:01:23 +03:00
|
|
|
* v9fs_req_cleanup - Cleanup request initialized by v9fs_init_request
|
2021-11-02 11:29:55 +03:00
|
|
|
* @mapping: unused mapping of request to cleanup
|
|
|
|
* @priv: private data to cleanup, a fid, guaranted non-null.
|
|
|
|
*/
|
|
|
|
static void v9fs_req_cleanup(struct address_space *mapping, void *priv)
|
|
|
|
{
|
|
|
|
struct p9_fid *fid = priv;
|
2006-01-19 04:43:02 +03:00
|
|
|
|
2021-11-02 11:29:55 +03:00
|
|
|
p9_client_clunk(fid);
|
|
|
|
}
|
2009-09-23 22:00:27 +04:00
|
|
|
|
2021-11-02 11:29:55 +03:00
|
|
|
/**
|
|
|
|
* v9fs_begin_cache_operation - Begin a cache operation for a read
|
|
|
|
* @rreq: The read request
|
|
|
|
*/
|
2022-02-17 13:01:23 +03:00
|
|
|
static int v9fs_begin_cache_operation(struct netfs_io_request *rreq)
|
2021-11-02 11:29:55 +03:00
|
|
|
{
|
2021-10-25 23:53:44 +03:00
|
|
|
#ifdef CONFIG_9P_FSCACHE
|
2021-11-02 11:29:55 +03:00
|
|
|
struct fscache_cookie *cookie = v9fs_inode_cookie(V9FS_I(rreq->inode));
|
|
|
|
|
2020-11-18 12:06:42 +03:00
|
|
|
return fscache_begin_read_operation(&rreq->cache_resources, cookie);
|
2021-10-25 23:53:44 +03:00
|
|
|
#else
|
|
|
|
return -ENOBUFS;
|
|
|
|
#endif
|
2006-01-19 04:43:02 +03:00
|
|
|
}
|
|
|
|
|
2021-06-30 00:37:05 +03:00
|
|
|
const struct netfs_request_ops v9fs_req_ops = {
|
2022-02-17 13:01:23 +03:00
|
|
|
.init_request = v9fs_init_request,
|
2021-11-02 11:29:55 +03:00
|
|
|
.begin_cache_operation = v9fs_begin_cache_operation,
|
2022-02-17 13:14:32 +03:00
|
|
|
.issue_read = v9fs_issue_read,
|
2021-11-02 11:29:55 +03:00
|
|
|
.cleanup = v9fs_req_cleanup,
|
|
|
|
};
|
|
|
|
|
2009-09-23 22:00:27 +04:00
|
|
|
/**
|
2022-05-01 06:05:09 +03:00
|
|
|
* v9fs_release_folio - release the private state associated with a folio
|
|
|
|
* @folio: The folio to be released
|
2021-10-05 00:07:22 +03:00
|
|
|
* @gfp: The caller's allocation restrictions
|
2009-09-23 22:00:27 +04:00
|
|
|
*
|
2022-05-01 06:05:09 +03:00
|
|
|
* Returns true if the page can be released, false otherwise.
|
2009-09-23 22:00:27 +04:00
|
|
|
*/
|
|
|
|
|
2022-05-01 06:05:09 +03:00
|
|
|
static bool v9fs_release_folio(struct folio *folio, gfp_t gfp)
|
2009-09-23 22:00:27 +04:00
|
|
|
{
|
2020-11-18 12:06:42 +03:00
|
|
|
struct inode *inode = folio_inode(folio);
|
2021-08-11 11:49:13 +03:00
|
|
|
|
|
|
|
if (folio_test_private(folio))
|
2022-05-01 06:05:09 +03:00
|
|
|
return false;
|
2021-11-02 11:29:55 +03:00
|
|
|
#ifdef CONFIG_9P_FSCACHE
|
2021-08-11 11:49:13 +03:00
|
|
|
if (folio_test_fscache(folio)) {
|
2021-12-22 20:21:04 +03:00
|
|
|
if (current_is_kswapd() || !(gfp & __GFP_FS))
|
2022-05-01 06:05:09 +03:00
|
|
|
return false;
|
2021-08-11 11:49:13 +03:00
|
|
|
folio_wait_fscache(folio);
|
2021-11-02 11:29:55 +03:00
|
|
|
}
|
|
|
|
#endif
|
2020-11-18 12:06:42 +03:00
|
|
|
fscache_note_page_release(v9fs_inode_cookie(V9FS_I(inode)));
|
2022-05-01 06:05:09 +03:00
|
|
|
return true;
|
2009-09-23 22:00:27 +04:00
|
|
|
}
|
|
|
|
|
2022-02-09 23:21:36 +03:00
|
|
|
static void v9fs_invalidate_folio(struct folio *folio, size_t offset,
|
|
|
|
size_t length)
|
2009-09-23 22:00:27 +04:00
|
|
|
{
|
2021-08-11 11:49:13 +03:00
|
|
|
folio_wait_fscache(folio);
|
2009-09-23 22:00:27 +04:00
|
|
|
}
|
|
|
|
|
2020-11-18 12:06:42 +03:00
|
|
|
static void v9fs_write_to_cache_done(void *priv, ssize_t transferred_or_error,
|
|
|
|
bool was_async)
|
|
|
|
{
|
|
|
|
struct v9fs_inode *v9inode = priv;
|
|
|
|
__le32 version;
|
|
|
|
|
|
|
|
if (IS_ERR_VALUE(transferred_or_error) &&
|
|
|
|
transferred_or_error != -ENOBUFS) {
|
|
|
|
version = cpu_to_le32(v9inode->qid.version);
|
|
|
|
fscache_invalidate(v9fs_inode_cookie(v9inode), &version,
|
|
|
|
i_size_read(&v9inode->vfs_inode), 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-11 11:49:13 +03:00
|
|
|
static int v9fs_vfs_write_folio_locked(struct folio *folio)
|
2011-02-28 14:33:58 +03:00
|
|
|
{
|
2021-08-11 11:49:13 +03:00
|
|
|
struct inode *inode = folio_inode(folio);
|
2015-04-02 04:54:42 +03:00
|
|
|
struct v9fs_inode *v9inode = V9FS_I(inode);
|
2020-11-18 12:06:42 +03:00
|
|
|
struct fscache_cookie *cookie = v9fs_inode_cookie(v9inode);
|
2021-08-11 11:49:13 +03:00
|
|
|
loff_t start = folio_pos(folio);
|
|
|
|
loff_t i_size = i_size_read(inode);
|
2015-04-02 04:54:42 +03:00
|
|
|
struct iov_iter from;
|
2021-08-11 11:49:13 +03:00
|
|
|
size_t len = folio_size(folio);
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (start >= i_size)
|
|
|
|
return 0; /* Simultaneous truncation occurred */
|
2011-02-28 14:33:58 +03:00
|
|
|
|
2021-08-11 11:49:13 +03:00
|
|
|
len = min_t(loff_t, i_size - start, len);
|
2011-02-28 14:33:58 +03:00
|
|
|
|
2021-08-11 11:49:13 +03:00
|
|
|
iov_iter_xarray(&from, WRITE, &folio_mapping(folio)->i_pages, start, len);
|
2011-02-28 14:33:58 +03:00
|
|
|
|
2011-02-28 14:34:03 +03:00
|
|
|
/* We should have writeback_fid always set */
|
|
|
|
BUG_ON(!v9inode->writeback_fid);
|
2011-02-28 14:33:58 +03:00
|
|
|
|
2020-11-18 12:06:42 +03:00
|
|
|
folio_wait_fscache(folio);
|
2021-08-11 11:49:13 +03:00
|
|
|
folio_start_writeback(folio);
|
2015-04-02 04:54:42 +03:00
|
|
|
|
2021-11-02 11:29:55 +03:00
|
|
|
p9_client_write(v9inode->writeback_fid, start, &from, &err);
|
2011-02-28 14:33:58 +03:00
|
|
|
|
2020-11-18 12:06:42 +03:00
|
|
|
if (err == 0 &&
|
|
|
|
fscache_cookie_enabled(cookie) &&
|
|
|
|
test_bit(FSCACHE_COOKIE_IS_CACHING, &cookie->flags)) {
|
|
|
|
folio_start_fscache(folio);
|
|
|
|
fscache_write_to_cache(v9fs_inode_cookie(v9inode),
|
|
|
|
folio_mapping(folio), start, len, i_size,
|
|
|
|
v9fs_write_to_cache_done, v9inode,
|
|
|
|
true);
|
|
|
|
}
|
|
|
|
|
2021-08-11 11:49:13 +03:00
|
|
|
folio_end_writeback(folio);
|
2015-04-02 04:54:42 +03:00
|
|
|
return err;
|
2011-02-28 14:33:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int v9fs_vfs_writepage(struct page *page, struct writeback_control *wbc)
|
|
|
|
{
|
2021-08-11 11:49:13 +03:00
|
|
|
struct folio *folio = page_folio(page);
|
2011-02-28 14:33:58 +03:00
|
|
|
int retval;
|
|
|
|
|
2021-08-11 11:49:13 +03:00
|
|
|
p9_debug(P9_DEBUG_VFS, "folio %p\n", folio);
|
2014-01-10 16:44:09 +04:00
|
|
|
|
2021-08-11 11:49:13 +03:00
|
|
|
retval = v9fs_vfs_write_folio_locked(folio);
|
2011-02-28 14:33:58 +03:00
|
|
|
if (retval < 0) {
|
|
|
|
if (retval == -EAGAIN) {
|
2021-08-11 11:49:13 +03:00
|
|
|
folio_redirty_for_writepage(wbc, folio);
|
2011-02-28 14:33:58 +03:00
|
|
|
retval = 0;
|
|
|
|
} else {
|
2021-08-11 11:49:13 +03:00
|
|
|
mapping_set_error(folio_mapping(folio), retval);
|
2011-02-28 14:33:58 +03:00
|
|
|
}
|
|
|
|
} else
|
|
|
|
retval = 0;
|
|
|
|
|
2021-08-11 11:49:13 +03:00
|
|
|
folio_unlock(folio);
|
2011-02-28 14:33:58 +03:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2022-02-09 23:21:53 +03:00
|
|
|
static int v9fs_launder_folio(struct folio *folio)
|
2009-09-23 22:00:27 +04:00
|
|
|
{
|
2011-02-28 14:33:58 +03:00
|
|
|
int retval;
|
|
|
|
|
2021-08-11 11:49:13 +03:00
|
|
|
if (folio_clear_dirty_for_io(folio)) {
|
|
|
|
retval = v9fs_vfs_write_folio_locked(folio);
|
2011-02-28 14:33:58 +03:00
|
|
|
if (retval)
|
|
|
|
return retval;
|
|
|
|
}
|
2021-08-11 11:49:13 +03:00
|
|
|
folio_wait_fscache(folio);
|
2009-09-23 22:00:27 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-08-24 19:43:28 +04:00
|
|
|
/**
|
|
|
|
* v9fs_direct_IO - 9P address space operation for direct I/O
|
|
|
|
* @iocb: target I/O control block
|
2021-10-05 00:07:22 +03:00
|
|
|
* @iter: The data/buffer to use
|
2010-08-24 19:43:28 +04:00
|
|
|
*
|
|
|
|
* The presence of v9fs_direct_IO() in the address space ops vector
|
|
|
|
* allowes open() O_DIRECT flags which would have failed otherwise.
|
|
|
|
*
|
|
|
|
* In the non-cached mode, we shunt off direct read and write requests before
|
|
|
|
* the VFS gets them, so this method should never be called.
|
|
|
|
*
|
|
|
|
* Direct IO is not 'yet' supported in the cached mode. Hence when
|
|
|
|
* this routine is called through generic_file_aio_read(), the read/write fails
|
|
|
|
* with an error.
|
|
|
|
*
|
|
|
|
*/
|
2011-02-28 14:34:04 +03:00
|
|
|
static ssize_t
|
2016-04-07 18:51:58 +03:00
|
|
|
v9fs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
|
2010-08-24 19:43:28 +04:00
|
|
|
{
|
2015-04-02 05:32:23 +03:00
|
|
|
struct file *file = iocb->ki_filp;
|
2016-04-07 18:51:58 +03:00
|
|
|
loff_t pos = iocb->ki_pos;
|
2015-04-02 06:49:24 +03:00
|
|
|
ssize_t n;
|
|
|
|
int err = 0;
|
2021-11-02 16:16:43 +03:00
|
|
|
|
2015-03-16 14:33:52 +03:00
|
|
|
if (iov_iter_rw(iter) == WRITE) {
|
2015-04-02 06:49:24 +03:00
|
|
|
n = p9_client_write(file->private_data, pos, iter, &err);
|
|
|
|
if (n) {
|
2015-04-02 05:32:23 +03:00
|
|
|
struct inode *inode = file_inode(file);
|
|
|
|
loff_t i_size = i_size_read(inode);
|
2021-11-02 16:16:43 +03:00
|
|
|
|
2015-04-02 06:49:24 +03:00
|
|
|
if (pos + n > i_size)
|
|
|
|
inode_add_bytes(inode, pos + n - i_size);
|
2015-04-02 05:32:23 +03:00
|
|
|
}
|
2015-04-02 06:49:24 +03:00
|
|
|
} else {
|
|
|
|
n = p9_client_read(file->private_data, pos, iter, &err);
|
2015-04-02 05:32:23 +03:00
|
|
|
}
|
2015-04-02 06:49:24 +03:00
|
|
|
return n ? n : err;
|
2010-08-24 19:43:28 +04:00
|
|
|
}
|
2011-02-28 14:33:58 +03:00
|
|
|
|
|
|
|
static int v9fs_write_begin(struct file *filp, struct address_space *mapping,
|
2022-02-22 22:31:43 +03:00
|
|
|
loff_t pos, unsigned int len,
|
2021-08-11 11:49:13 +03:00
|
|
|
struct page **subpagep, void **fsdata)
|
2011-02-28 14:33:58 +03:00
|
|
|
{
|
2021-11-02 11:29:55 +03:00
|
|
|
int retval;
|
2021-08-11 11:49:13 +03:00
|
|
|
struct folio *folio;
|
2021-11-02 11:29:55 +03:00
|
|
|
struct v9fs_inode *v9inode = V9FS_I(mapping->host);
|
2014-01-10 16:44:09 +04:00
|
|
|
|
|
|
|
p9_debug(P9_DEBUG_VFS, "filp %p, mapping %p\n", filp, mapping);
|
|
|
|
|
2011-02-28 14:34:03 +03:00
|
|
|
BUG_ON(!v9inode->writeback_fid);
|
2011-02-28 14:33:58 +03:00
|
|
|
|
2021-11-02 11:29:55 +03:00
|
|
|
/* Prefetch area to be written into the cache if we're caching this
|
|
|
|
* file. We need to do this before we get a lock on the page in case
|
|
|
|
* there's more than one writer competing for the same cache block.
|
|
|
|
*/
|
2022-02-22 18:47:09 +03:00
|
|
|
retval = netfs_write_begin(filp, mapping, pos, len, &folio, fsdata);
|
2021-11-02 11:29:55 +03:00
|
|
|
if (retval < 0)
|
|
|
|
return retval;
|
2011-02-28 14:33:58 +03:00
|
|
|
|
2021-08-11 11:49:13 +03:00
|
|
|
*subpagep = &folio->page;
|
2011-02-28 14:33:58 +03:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int v9fs_write_end(struct file *filp, struct address_space *mapping,
|
2021-11-02 16:16:43 +03:00
|
|
|
loff_t pos, unsigned int len, unsigned int copied,
|
2021-08-11 11:49:13 +03:00
|
|
|
struct page *subpage, void *fsdata)
|
2011-02-28 14:33:58 +03:00
|
|
|
{
|
|
|
|
loff_t last_pos = pos + copied;
|
2021-08-11 11:49:13 +03:00
|
|
|
struct folio *folio = page_folio(subpage);
|
|
|
|
struct inode *inode = mapping->host;
|
2020-11-18 12:06:42 +03:00
|
|
|
struct v9fs_inode *v9inode = V9FS_I(inode);
|
2011-02-28 14:33:58 +03:00
|
|
|
|
2014-01-10 16:44:09 +04:00
|
|
|
p9_debug(P9_DEBUG_VFS, "filp %p, mapping %p\n", filp, mapping);
|
|
|
|
|
2021-08-11 11:49:13 +03:00
|
|
|
if (!folio_test_uptodate(folio)) {
|
2017-04-10 21:46:51 +03:00
|
|
|
if (unlikely(copied < len)) {
|
|
|
|
copied = 0;
|
|
|
|
goto out;
|
|
|
|
}
|
2021-11-02 11:29:55 +03:00
|
|
|
|
2021-08-11 11:49:13 +03:00
|
|
|
folio_mark_uptodate(folio);
|
2011-02-28 14:33:58 +03:00
|
|
|
}
|
2021-11-02 11:29:55 +03:00
|
|
|
|
2011-02-28 14:33:58 +03:00
|
|
|
/*
|
|
|
|
* No need to use i_size_read() here, the i_size
|
|
|
|
* cannot change under us because we hold the i_mutex.
|
|
|
|
*/
|
|
|
|
if (last_pos > inode->i_size) {
|
|
|
|
inode_add_bytes(inode, last_pos - inode->i_size);
|
|
|
|
i_size_write(inode, last_pos);
|
2020-11-18 12:06:42 +03:00
|
|
|
fscache_update_cookie(v9fs_inode_cookie(v9inode), NULL, &last_pos);
|
2011-02-28 14:33:58 +03:00
|
|
|
}
|
2021-08-11 11:49:13 +03:00
|
|
|
folio_mark_dirty(folio);
|
2016-08-30 03:56:35 +03:00
|
|
|
out:
|
2021-08-11 11:49:13 +03:00
|
|
|
folio_unlock(folio);
|
|
|
|
folio_put(folio);
|
2011-02-28 14:33:58 +03:00
|
|
|
|
|
|
|
return copied;
|
|
|
|
}
|
|
|
|
|
2020-11-18 12:06:42 +03:00
|
|
|
#ifdef CONFIG_9P_FSCACHE
|
|
|
|
/*
|
|
|
|
* Mark a page as having been made dirty and thus needing writeback. We also
|
|
|
|
* need to pin the cache object to write back to.
|
|
|
|
*/
|
2022-02-09 23:22:01 +03:00
|
|
|
static bool v9fs_dirty_folio(struct address_space *mapping, struct folio *folio)
|
2020-11-18 12:06:42 +03:00
|
|
|
{
|
2022-02-09 23:22:01 +03:00
|
|
|
struct v9fs_inode *v9inode = V9FS_I(mapping->host);
|
2020-11-18 12:06:42 +03:00
|
|
|
|
2022-02-09 23:22:01 +03:00
|
|
|
return fscache_dirty_folio(mapping, folio, v9fs_inode_cookie(v9inode));
|
2020-11-18 12:06:42 +03:00
|
|
|
}
|
|
|
|
#else
|
2022-02-09 23:22:01 +03:00
|
|
|
#define v9fs_dirty_folio filemap_dirty_folio
|
2020-11-18 12:06:42 +03:00
|
|
|
#endif
|
2011-02-28 14:33:58 +03:00
|
|
|
|
2006-06-28 15:26:44 +04:00
|
|
|
const struct address_space_operations v9fs_addr_operations = {
|
2022-04-29 15:49:28 +03:00
|
|
|
.read_folio = netfs_read_folio,
|
2021-06-30 00:37:05 +03:00
|
|
|
.readahead = netfs_readahead,
|
2022-02-09 23:22:01 +03:00
|
|
|
.dirty_folio = v9fs_dirty_folio,
|
2011-02-28 14:33:58 +03:00
|
|
|
.writepage = v9fs_vfs_writepage,
|
|
|
|
.write_begin = v9fs_write_begin,
|
|
|
|
.write_end = v9fs_write_end,
|
2022-05-01 06:05:09 +03:00
|
|
|
.release_folio = v9fs_release_folio,
|
2022-02-09 23:21:36 +03:00
|
|
|
.invalidate_folio = v9fs_invalidate_folio,
|
2022-02-09 23:21:53 +03:00
|
|
|
.launder_folio = v9fs_launder_folio,
|
2011-02-28 14:33:58 +03:00
|
|
|
.direct_IO = v9fs_direct_IO,
|
2006-01-19 04:43:02 +03:00
|
|
|
};
|