mirror of
https://github.com/torvalds/linux.git
synced 2024-11-25 05:32:00 +00:00
netfs support library extra
-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEqG5UsNXhtOCrfGQP+7dXa6fLC2sFAmWWr6QACgkQ+7dXa6fL C2s8tw//TIJLeD0C07IAilhpC+0AAeyYGICRFRHF/vBYRqSs4T3xUQaDhxSrOB7g i4v+mvifJ6U2nCn8ARyqO3Ffu2wYV8ydONV5grpajltgQxv1SCEiOxV4ewUnCGBk tjLCguur+Ld9wg02MFJzQeD9TWe9eLTOoywdSysc0S5/QwbS5UoKduUAw/armF4s Qh9BiOXdNgVFui9KizEunuDVDtnwZ6KWM8u8k9xg2xiZ61eUxheaWkAZ9X3dkF/O gCtuHFUWzUfiNkFOpGQJvp4yZFPNxLMRblBdbn9bcrhJiVfOxBHleDkUR0jTRqID jLuFaXnB1XAlUPRxSjuLlHfzIPpQ9/IVoQGBWoxWL0ZkzmhPq9d7fXkaMCAnHTkZ ZWPdslz52JcVT9KbdtP901MyHGb+xpTvyhZWNIlIODxVywWfFOS2fFUj9s5HAszI bE0VNTBbvqYgg169idKo6BfgR3sOTEa6vYhWv9PfCZ0aIf1imk+XiGd88whcP8gw de2CVi1URAj1NebplmdRzn5HCZbY8wNbgosc46zemL6jiJCWc39CgdWL24nMMsKJ XprFHv3pccyk98nHdRVo0bGEK99KXiLZOsLKt55gkimKlpS3/f3ADujJOV4gAP8K iTrc2dfsZd4b3UWRcXWtATtndAo3dHKIaahrrIcu7I1QlOHToms= =jnKU -----END PGP SIGNATURE----- gpgsig -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRAhzRXHqcMeLMyaSiRxhvAZXjcogUCZZbDtQAKCRCRxhvAZXjc oj5CAQCIORC7W7xUAjX9SAmi/Hk5VC3DVUoC9jDYti0wF7oIdQD+NZd8kt8amjZW 78VzyHLtEpsQak3q2ekMBy6t1TcLgwA= =QAQL -----END PGP SIGNATURE----- Merge tag 'netfs-lib-20240104' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs Pull netfs updates from David Howells: A few follow-up fixes for the netfs work for this cycle. * tag 'netfs-lib-20240104' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs: netfs: Fix proc/fs/fscache symlink to point to "netfs" not "../netfs" netfs: Rearrange netfs_io_subrequest to put request pointer first 9p: Use length of data written to the server in preference to error 9p: Do a couple of cleanups 9p: Fix initialisation of netfs_inode for 9p cachefiles: Fix __cachefiles_prepare_write() Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
commit
d271c4b406
@ -42,6 +42,7 @@ struct inode *v9fs_alloc_inode(struct super_block *sb);
|
||||
void v9fs_free_inode(struct inode *inode);
|
||||
struct inode *v9fs_get_inode(struct super_block *sb, umode_t mode,
|
||||
dev_t rdev);
|
||||
void v9fs_set_netfs_context(struct inode *inode);
|
||||
int v9fs_init_inode(struct v9fs_session_info *v9ses,
|
||||
struct inode *inode, umode_t mode, dev_t rdev);
|
||||
void v9fs_evict_inode(struct inode *inode);
|
||||
|
@ -28,15 +28,12 @@
|
||||
|
||||
static void v9fs_upload_to_server(struct netfs_io_subrequest *subreq)
|
||||
{
|
||||
struct inode *inode = subreq->rreq->inode;
|
||||
struct v9fs_inode __maybe_unused *v9inode = V9FS_I(inode);
|
||||
struct p9_fid *fid = subreq->rreq->netfs_priv;
|
||||
int err;
|
||||
int err, len;
|
||||
|
||||
trace_netfs_sreq(subreq, netfs_sreq_trace_submit);
|
||||
p9_client_write(fid, subreq->start, &subreq->io_iter, &err);
|
||||
netfs_write_subrequest_terminated(subreq, err < 0 ? err : subreq->len,
|
||||
false);
|
||||
len = p9_client_write(fid, subreq->start, &subreq->io_iter, &err);
|
||||
netfs_write_subrequest_terminated(subreq, len ?: err, false);
|
||||
}
|
||||
|
||||
static void v9fs_upload_to_server_worker(struct work_struct *work)
|
||||
@ -98,15 +95,13 @@ static int v9fs_init_request(struct netfs_io_request *rreq, struct file *file)
|
||||
|
||||
if (file) {
|
||||
fid = file->private_data;
|
||||
BUG_ON(!fid);
|
||||
if (!fid)
|
||||
goto no_fid;
|
||||
p9_fid_get(fid);
|
||||
} else {
|
||||
fid = v9fs_fid_find_inode(rreq->inode, writing, INVALID_UID, true);
|
||||
if (!fid) {
|
||||
WARN_ONCE(1, "folio expected an open fid inode->i_private=%p\n",
|
||||
rreq->inode->i_private);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!fid)
|
||||
goto no_fid;
|
||||
}
|
||||
|
||||
/* we might need to read from a fid that was opened write-only
|
||||
@ -115,6 +110,11 @@ static int v9fs_init_request(struct netfs_io_request *rreq, struct file *file)
|
||||
WARN_ON(rreq->origin == NETFS_READ_FOR_WRITE && !(fid->mode & P9_ORDWR));
|
||||
rreq->netfs_priv = fid;
|
||||
return 0;
|
||||
|
||||
no_fid:
|
||||
WARN_ONCE(1, "folio expected an open fid inode->i_ino=%lx\n",
|
||||
rreq->inode->i_ino);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -246,7 +246,7 @@ void v9fs_free_inode(struct inode *inode)
|
||||
/*
|
||||
* Set parameters for the netfs library
|
||||
*/
|
||||
static void v9fs_set_netfs_context(struct inode *inode)
|
||||
void v9fs_set_netfs_context(struct inode *inode)
|
||||
{
|
||||
struct v9fs_inode *v9inode = V9FS_I(inode);
|
||||
netfs_inode_init(&v9inode->netfs, &v9fs_req_ops, true);
|
||||
@ -326,8 +326,6 @@ int v9fs_init_inode(struct v9fs_session_info *v9ses,
|
||||
err = -EINVAL;
|
||||
goto error;
|
||||
}
|
||||
|
||||
v9fs_set_netfs_context(inode);
|
||||
error:
|
||||
return err;
|
||||
|
||||
@ -359,6 +357,7 @@ struct inode *v9fs_get_inode(struct super_block *sb, umode_t mode, dev_t rdev)
|
||||
iput(inode);
|
||||
return ERR_PTR(err);
|
||||
}
|
||||
v9fs_set_netfs_context(inode);
|
||||
return inode;
|
||||
}
|
||||
|
||||
@ -461,6 +460,7 @@ static struct inode *v9fs_qid_iget(struct super_block *sb,
|
||||
goto error;
|
||||
|
||||
v9fs_stat2inode(st, inode, sb, 0);
|
||||
v9fs_set_netfs_context(inode);
|
||||
v9fs_cache_inode_get_cookie(inode);
|
||||
unlock_new_inode(inode);
|
||||
return inode;
|
||||
|
@ -128,6 +128,7 @@ static struct inode *v9fs_qid_iget_dotl(struct super_block *sb,
|
||||
goto error;
|
||||
|
||||
v9fs_stat2inode_dotl(st, inode, 0);
|
||||
v9fs_set_netfs_context(inode);
|
||||
v9fs_cache_inode_get_cookie(inode);
|
||||
retval = v9fs_get_acl(inode, fid);
|
||||
if (retval)
|
||||
|
@ -522,16 +522,22 @@ int __cachefiles_prepare_write(struct cachefiles_object *object,
|
||||
bool no_space_allocated_yet)
|
||||
{
|
||||
struct cachefiles_cache *cache = object->volume->cache;
|
||||
loff_t start = *_start, pos;
|
||||
size_t len = *_len, down;
|
||||
unsigned long long start = *_start, pos;
|
||||
size_t len = *_len;
|
||||
int ret;
|
||||
|
||||
/* Round to DIO size */
|
||||
down = start - round_down(start, PAGE_SIZE);
|
||||
*_start = start - down;
|
||||
*_len = round_up(down + len, PAGE_SIZE);
|
||||
if (down < start || *_len > upper_len)
|
||||
start = round_down(*_start, PAGE_SIZE);
|
||||
if (start != *_start) {
|
||||
kleave(" = -ENOBUFS [down]");
|
||||
return -ENOBUFS;
|
||||
}
|
||||
if (*_len > upper_len) {
|
||||
kleave(" = -ENOBUFS [up]");
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
*_len = round_up(len, PAGE_SIZE);
|
||||
|
||||
/* We need to work out whether there's sufficient disk space to perform
|
||||
* the write - but we can skip that check if we have space already
|
||||
@ -542,7 +548,7 @@ int __cachefiles_prepare_write(struct cachefiles_object *object,
|
||||
|
||||
pos = cachefiles_inject_read_error();
|
||||
if (pos == 0)
|
||||
pos = vfs_llseek(file, *_start, SEEK_DATA);
|
||||
pos = vfs_llseek(file, start, SEEK_DATA);
|
||||
if (pos < 0 && pos >= (loff_t)-MAX_ERRNO) {
|
||||
if (pos == -ENXIO)
|
||||
goto check_space; /* Unallocated tail */
|
||||
@ -550,7 +556,7 @@ int __cachefiles_prepare_write(struct cachefiles_object *object,
|
||||
cachefiles_trace_seek_error);
|
||||
return pos;
|
||||
}
|
||||
if ((u64)pos >= (u64)*_start + *_len)
|
||||
if (pos >= start + *_len)
|
||||
goto check_space; /* Unallocated region */
|
||||
|
||||
/* We have a block that's at least partially filled - if we're low on
|
||||
@ -563,13 +569,13 @@ int __cachefiles_prepare_write(struct cachefiles_object *object,
|
||||
|
||||
pos = cachefiles_inject_read_error();
|
||||
if (pos == 0)
|
||||
pos = vfs_llseek(file, *_start, SEEK_HOLE);
|
||||
pos = vfs_llseek(file, start, SEEK_HOLE);
|
||||
if (pos < 0 && pos >= (loff_t)-MAX_ERRNO) {
|
||||
trace_cachefiles_io_error(object, file_inode(file), pos,
|
||||
cachefiles_trace_seek_error);
|
||||
return pos;
|
||||
}
|
||||
if ((u64)pos >= (u64)*_start + *_len)
|
||||
if (pos >= start + *_len)
|
||||
return 0; /* Fully allocated */
|
||||
|
||||
/* Partially allocated, but insufficient space: cull. */
|
||||
@ -577,7 +583,7 @@ int __cachefiles_prepare_write(struct cachefiles_object *object,
|
||||
ret = cachefiles_inject_remove_error();
|
||||
if (ret == 0)
|
||||
ret = vfs_fallocate(file, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
|
||||
*_start, *_len);
|
||||
start, *_len);
|
||||
if (ret < 0) {
|
||||
trace_cachefiles_io_error(object, file_inode(file), ret,
|
||||
cachefiles_trace_fallocate_error);
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
int __init fscache_proc_init(void)
|
||||
{
|
||||
if (!proc_symlink("fs/fscache", NULL, "../netfs"))
|
||||
if (!proc_symlink("fs/fscache", NULL, "netfs"))
|
||||
goto error_sym;
|
||||
|
||||
if (!proc_create_seq("fs/netfs/caches", S_IFREG | 0444, NULL,
|
||||
|
@ -204,8 +204,8 @@ struct netfs_cache_resources {
|
||||
* the pages it points to can be relied on to exist for the duration.
|
||||
*/
|
||||
struct netfs_io_subrequest {
|
||||
struct work_struct work;
|
||||
struct netfs_io_request *rreq; /* Supervising I/O request */
|
||||
struct work_struct work;
|
||||
struct list_head rreq_link; /* Link in rreq->subrequests */
|
||||
struct iov_iter io_iter; /* Iterator for this subrequest */
|
||||
loff_t start; /* Where to start the I/O */
|
||||
|
Loading…
Reference in New Issue
Block a user