Commit 49ad227d authored by Linus Torvalds's avatar Linus Torvalds

Merge tag '9p-for-5.17-rc1' of git://github.com/martinetd/linux

Pull 9p updates from Dominique Martinet:
 "Fixes, split 9p_net_fd, and new reviewer:

   - fix possible uninitialized memory usage for setattr

   - fix fscache reading hole in a file just after it's been grown

   - split net/9p/trans_fd.c in its own module like other transports.

     The new transport module defaults to 9P_NET and is autoloaded if
     required so users should not be impacted

   - add Christian Schoenebeck to 9p reviewers

   - some more trivial cleanup"

* tag '9p-for-5.17-rc1' of git://github.com/martinetd/linux:
  9p: fix enodata when reading growing file
  net/9p: show error message if user 'msize' cannot be satisfied
  MAINTAINERS: 9p: add Christian Schoenebeck as reviewer
  9p: only copy valid iattrs in 9P2000.L setattr implementation
  9p: Use BUG_ON instead of if condition followed by BUG.
  net/p9: load default transports
  9p/xen: autoload when xenbus service is available
  9p/trans_fd: split into dedicated module
  fs: 9p: remove unneeded variable
  9p/trans_virtio: Fix typo in the comment for p9_virtio_create()
parents 59d41458 19d1c326
...@@ -226,6 +226,7 @@ F: drivers/net/ethernet/8390/ ...@@ -226,6 +226,7 @@ F: drivers/net/ethernet/8390/
M: Eric Van Hensbergen <ericvh@gmail.com> M: Eric Van Hensbergen <ericvh@gmail.com>
M: Latchesar Ionkov <lucho@ionkov.net> M: Latchesar Ionkov <lucho@ionkov.net>
M: Dominique Martinet <asmadeus@codewreck.org> M: Dominique Martinet <asmadeus@codewreck.org>
R: Christian Schoenebeck <linux_oss@crudebyte.com>
L: v9fs-developer@lists.sourceforge.net L: v9fs-developer@lists.sourceforge.net
S: Maintained S: Maintained
W: http://swik.net/v9fs W: http://swik.net/v9fs
......
...@@ -43,6 +43,11 @@ static void v9fs_req_issue_op(struct netfs_read_subrequest *subreq) ...@@ -43,6 +43,11 @@ static void v9fs_req_issue_op(struct netfs_read_subrequest *subreq)
iov_iter_xarray(&to, READ, &rreq->mapping->i_pages, pos, len); iov_iter_xarray(&to, READ, &rreq->mapping->i_pages, pos, len);
total = p9_client_read(fid, pos, &to, &err); total = p9_client_read(fid, pos, &to, &err);
/* 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);
netfs_subreq_terminated(subreq, err ?: total, false); netfs_subreq_terminated(subreq, err ?: total, false);
} }
......
...@@ -115,7 +115,6 @@ int v9fs_file_open(struct inode *inode, struct file *file) ...@@ -115,7 +115,6 @@ int v9fs_file_open(struct inode *inode, struct file *file)
static int v9fs_file_lock(struct file *filp, int cmd, struct file_lock *fl) static int v9fs_file_lock(struct file *filp, int cmd, struct file_lock *fl)
{ {
int res = 0;
struct inode *inode = file_inode(filp); struct inode *inode = file_inode(filp);
p9_debug(P9_DEBUG_VFS, "filp: %p lock: %p\n", filp, fl); p9_debug(P9_DEBUG_VFS, "filp: %p lock: %p\n", filp, fl);
...@@ -125,7 +124,7 @@ static int v9fs_file_lock(struct file *filp, int cmd, struct file_lock *fl) ...@@ -125,7 +124,7 @@ static int v9fs_file_lock(struct file *filp, int cmd, struct file_lock *fl)
invalidate_mapping_pages(&inode->i_data, 0, -1); invalidate_mapping_pages(&inode->i_data, 0, -1);
} }
return res; return 0;
} }
static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl) static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
...@@ -140,8 +139,7 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl) ...@@ -140,8 +139,7 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
fid = filp->private_data; fid = filp->private_data;
BUG_ON(fid == NULL); BUG_ON(fid == NULL);
if ((fl->fl_flags & FL_POSIX) != FL_POSIX) BUG_ON((fl->fl_flags & FL_POSIX) != FL_POSIX);
BUG();
res = locks_lock_file_wait(filp, fl); res = locks_lock_file_wait(filp, fl);
if (res < 0) if (res < 0)
......
...@@ -552,7 +552,10 @@ int v9fs_vfs_setattr_dotl(struct user_namespace *mnt_userns, ...@@ -552,7 +552,10 @@ int v9fs_vfs_setattr_dotl(struct user_namespace *mnt_userns,
{ {
int retval, use_dentry = 0; int retval, use_dentry = 0;
struct p9_fid *fid = NULL; struct p9_fid *fid = NULL;
struct p9_iattr_dotl p9attr; struct p9_iattr_dotl p9attr = {
.uid = INVALID_UID,
.gid = INVALID_GID,
};
struct inode *inode = d_inode(dentry); struct inode *inode = d_inode(dentry);
p9_debug(P9_DEBUG_VFS, "\n"); p9_debug(P9_DEBUG_VFS, "\n");
...@@ -562,14 +565,22 @@ int v9fs_vfs_setattr_dotl(struct user_namespace *mnt_userns, ...@@ -562,14 +565,22 @@ int v9fs_vfs_setattr_dotl(struct user_namespace *mnt_userns,
return retval; return retval;
p9attr.valid = v9fs_mapped_iattr_valid(iattr->ia_valid); p9attr.valid = v9fs_mapped_iattr_valid(iattr->ia_valid);
if (iattr->ia_valid & ATTR_MODE)
p9attr.mode = iattr->ia_mode; p9attr.mode = iattr->ia_mode;
if (iattr->ia_valid & ATTR_UID)
p9attr.uid = iattr->ia_uid; p9attr.uid = iattr->ia_uid;
if (iattr->ia_valid & ATTR_GID)
p9attr.gid = iattr->ia_gid; p9attr.gid = iattr->ia_gid;
if (iattr->ia_valid & ATTR_SIZE)
p9attr.size = iattr->ia_size; p9attr.size = iattr->ia_size;
if (iattr->ia_valid & ATTR_ATIME_SET) {
p9attr.atime_sec = iattr->ia_atime.tv_sec; p9attr.atime_sec = iattr->ia_atime.tv_sec;
p9attr.atime_nsec = iattr->ia_atime.tv_nsec; p9attr.atime_nsec = iattr->ia_atime.tv_nsec;
}
if (iattr->ia_valid & ATTR_MTIME_SET) {
p9attr.mtime_sec = iattr->ia_mtime.tv_sec; p9attr.mtime_sec = iattr->ia_mtime.tv_sec;
p9attr.mtime_nsec = iattr->ia_mtime.tv_nsec; p9attr.mtime_nsec = iattr->ia_mtime.tv_nsec;
}
if (iattr->ia_valid & ATTR_FILE) { if (iattr->ia_valid & ATTR_FILE) {
fid = iattr->ia_file->private_data; fid = iattr->ia_file->private_data;
......
...@@ -551,6 +551,4 @@ struct p9_fcall { ...@@ -551,6 +551,4 @@ struct p9_fcall {
int p9_errstr2errno(char *errstr, int len); int p9_errstr2errno(char *errstr, int len);
int p9_error_init(void); int p9_error_init(void);
int p9_trans_fd_init(void);
void p9_trans_fd_exit(void);
#endif /* NET_9P_H */ #endif /* NET_9P_H */
...@@ -54,7 +54,7 @@ struct p9_trans_module { ...@@ -54,7 +54,7 @@ struct p9_trans_module {
void v9fs_register_trans(struct p9_trans_module *m); void v9fs_register_trans(struct p9_trans_module *m);
void v9fs_unregister_trans(struct p9_trans_module *m); void v9fs_unregister_trans(struct p9_trans_module *m);
struct p9_trans_module *v9fs_get_trans_by_name(char *s); struct p9_trans_module *v9fs_get_trans_by_name(const char *s);
struct p9_trans_module *v9fs_get_default_trans(void); struct p9_trans_module *v9fs_get_default_trans(void);
void v9fs_put_trans(struct p9_trans_module *m); void v9fs_put_trans(struct p9_trans_module *m);
......
...@@ -15,6 +15,13 @@ menuconfig NET_9P ...@@ -15,6 +15,13 @@ menuconfig NET_9P
if NET_9P if NET_9P
config NET_9P_FD
default NET_9P
tristate "9P FD Transport"
help
This builds support for transports over TCP, Unix sockets and
filedescriptors.
config NET_9P_VIRTIO config NET_9P_VIRTIO
depends on VIRTIO depends on VIRTIO
tristate "9P Virtio Transport" tristate "9P Virtio Transport"
......
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_NET_9P) := 9pnet.o obj-$(CONFIG_NET_9P) := 9pnet.o
obj-$(CONFIG_NET_9P_FD) += 9pnet_fd.o
obj-$(CONFIG_NET_9P_XEN) += 9pnet_xen.o obj-$(CONFIG_NET_9P_XEN) += 9pnet_xen.o
obj-$(CONFIG_NET_9P_VIRTIO) += 9pnet_virtio.o obj-$(CONFIG_NET_9P_VIRTIO) += 9pnet_virtio.o
obj-$(CONFIG_NET_9P_RDMA) += 9pnet_rdma.o obj-$(CONFIG_NET_9P_RDMA) += 9pnet_rdma.o
...@@ -9,9 +10,11 @@ obj-$(CONFIG_NET_9P_RDMA) += 9pnet_rdma.o ...@@ -9,9 +10,11 @@ obj-$(CONFIG_NET_9P_RDMA) += 9pnet_rdma.o
client.o \ client.o \
error.o \ error.o \
protocol.o \ protocol.o \
trans_fd.o \
trans_common.o \ trans_common.o \
9pnet_fd-objs := \
trans_fd.o \
9pnet_virtio-objs := \ 9pnet_virtio-objs := \
trans_virtio.o \ trans_virtio.o \
......
...@@ -1038,8 +1038,13 @@ struct p9_client *p9_client_create(const char *dev_name, char *options) ...@@ -1038,8 +1038,13 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
if (err) if (err)
goto put_trans; goto put_trans;
if (clnt->msize > clnt->trans_mod->maxsize) if (clnt->msize > clnt->trans_mod->maxsize) {
clnt->msize = clnt->trans_mod->maxsize; clnt->msize = clnt->trans_mod->maxsize;
pr_info("Limiting 'msize' to %d as this is the maximum "
"supported by transport %s\n",
clnt->msize, clnt->trans_mod->name
);
}
if (clnt->msize < 4096) { if (clnt->msize < 4096) {
p9_debug(P9_DEBUG_ERROR, p9_debug(P9_DEBUG_ERROR,
......
...@@ -83,7 +83,7 @@ void v9fs_unregister_trans(struct p9_trans_module *m) ...@@ -83,7 +83,7 @@ void v9fs_unregister_trans(struct p9_trans_module *m)
} }
EXPORT_SYMBOL(v9fs_unregister_trans); EXPORT_SYMBOL(v9fs_unregister_trans);
static struct p9_trans_module *_p9_get_trans_by_name(char *s) static struct p9_trans_module *_p9_get_trans_by_name(const char *s)
{ {
struct p9_trans_module *t, *found = NULL; struct p9_trans_module *t, *found = NULL;
...@@ -106,7 +106,7 @@ static struct p9_trans_module *_p9_get_trans_by_name(char *s) ...@@ -106,7 +106,7 @@ static struct p9_trans_module *_p9_get_trans_by_name(char *s)
* @s: string identifying transport * @s: string identifying transport
* *
*/ */
struct p9_trans_module *v9fs_get_trans_by_name(char *s) struct p9_trans_module *v9fs_get_trans_by_name(const char *s)
{ {
struct p9_trans_module *found = NULL; struct p9_trans_module *found = NULL;
...@@ -123,6 +123,10 @@ struct p9_trans_module *v9fs_get_trans_by_name(char *s) ...@@ -123,6 +123,10 @@ struct p9_trans_module *v9fs_get_trans_by_name(char *s)
} }
EXPORT_SYMBOL(v9fs_get_trans_by_name); EXPORT_SYMBOL(v9fs_get_trans_by_name);
static const char * const v9fs_default_transports[] = {
"virtio", "tcp", "fd", "unix", "xen", "rdma",
};
/** /**
* v9fs_get_default_trans - get the default transport * v9fs_get_default_trans - get the default transport
* *
...@@ -131,6 +135,7 @@ EXPORT_SYMBOL(v9fs_get_trans_by_name); ...@@ -131,6 +135,7 @@ EXPORT_SYMBOL(v9fs_get_trans_by_name);
struct p9_trans_module *v9fs_get_default_trans(void) struct p9_trans_module *v9fs_get_default_trans(void)
{ {
struct p9_trans_module *t, *found = NULL; struct p9_trans_module *t, *found = NULL;
int i;
spin_lock(&v9fs_trans_lock); spin_lock(&v9fs_trans_lock);
...@@ -148,6 +153,10 @@ struct p9_trans_module *v9fs_get_default_trans(void) ...@@ -148,6 +153,10 @@ struct p9_trans_module *v9fs_get_default_trans(void)
} }
spin_unlock(&v9fs_trans_lock); spin_unlock(&v9fs_trans_lock);
for (i = 0; !found && i < ARRAY_SIZE(v9fs_default_transports); i++)
found = v9fs_get_trans_by_name(v9fs_default_transports[i]);
return found; return found;
} }
EXPORT_SYMBOL(v9fs_get_default_trans); EXPORT_SYMBOL(v9fs_get_default_trans);
...@@ -177,7 +186,6 @@ static int __init init_p9(void) ...@@ -177,7 +186,6 @@ static int __init init_p9(void)
p9_error_init(); p9_error_init();
pr_info("Installing 9P2000 support\n"); pr_info("Installing 9P2000 support\n");
p9_trans_fd_init();
return ret; return ret;
} }
...@@ -191,7 +199,6 @@ static void __exit exit_p9(void) ...@@ -191,7 +199,6 @@ static void __exit exit_p9(void)
{ {
pr_info("Unloading 9P2000 support\n"); pr_info("Unloading 9P2000 support\n");
p9_trans_fd_exit();
p9_client_exit(); p9_client_exit();
} }
......
...@@ -1090,6 +1090,7 @@ static struct p9_trans_module p9_tcp_trans = { ...@@ -1090,6 +1090,7 @@ static struct p9_trans_module p9_tcp_trans = {
.show_options = p9_fd_show_options, .show_options = p9_fd_show_options,
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
MODULE_ALIAS_9P("tcp");
static struct p9_trans_module p9_unix_trans = { static struct p9_trans_module p9_unix_trans = {
.name = "unix", .name = "unix",
...@@ -1103,6 +1104,7 @@ static struct p9_trans_module p9_unix_trans = { ...@@ -1103,6 +1104,7 @@ static struct p9_trans_module p9_unix_trans = {
.show_options = p9_fd_show_options, .show_options = p9_fd_show_options,
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
MODULE_ALIAS_9P("unix");
static struct p9_trans_module p9_fd_trans = { static struct p9_trans_module p9_fd_trans = {
.name = "fd", .name = "fd",
...@@ -1116,6 +1118,7 @@ static struct p9_trans_module p9_fd_trans = { ...@@ -1116,6 +1118,7 @@ static struct p9_trans_module p9_fd_trans = {
.show_options = p9_fd_show_options, .show_options = p9_fd_show_options,
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
MODULE_ALIAS_9P("fd");
/** /**
* p9_poll_workfn - poll worker thread * p9_poll_workfn - poll worker thread
...@@ -1149,7 +1152,7 @@ static void p9_poll_workfn(struct work_struct *work) ...@@ -1149,7 +1152,7 @@ static void p9_poll_workfn(struct work_struct *work)
p9_debug(P9_DEBUG_TRANS, "finish\n"); p9_debug(P9_DEBUG_TRANS, "finish\n");
} }
int p9_trans_fd_init(void) static int __init p9_trans_fd_init(void)
{ {
v9fs_register_trans(&p9_tcp_trans); v9fs_register_trans(&p9_tcp_trans);
v9fs_register_trans(&p9_unix_trans); v9fs_register_trans(&p9_unix_trans);
...@@ -1158,10 +1161,17 @@ int p9_trans_fd_init(void) ...@@ -1158,10 +1161,17 @@ int p9_trans_fd_init(void)
return 0; return 0;
} }
void p9_trans_fd_exit(void) static void __exit p9_trans_fd_exit(void)
{ {
flush_work(&p9_poll_work); flush_work(&p9_poll_work);
v9fs_unregister_trans(&p9_tcp_trans); v9fs_unregister_trans(&p9_tcp_trans);
v9fs_unregister_trans(&p9_unix_trans); v9fs_unregister_trans(&p9_unix_trans);
v9fs_unregister_trans(&p9_fd_trans); v9fs_unregister_trans(&p9_fd_trans);
} }
module_init(p9_trans_fd_init);
module_exit(p9_trans_fd_exit);
MODULE_AUTHOR("Eric Van Hensbergen <ericvh@gmail.com>");
MODULE_DESCRIPTION("Filedescriptor Transport for 9P");
MODULE_LICENSE("GPL");
...@@ -648,7 +648,7 @@ static int p9_virtio_probe(struct virtio_device *vdev) ...@@ -648,7 +648,7 @@ static int p9_virtio_probe(struct virtio_device *vdev)
* @args: args passed from sys_mount() for per-transport options (unused) * @args: args passed from sys_mount() for per-transport options (unused)
* *
* This sets up a transport channel for 9p communication. Right now * This sets up a transport channel for 9p communication. Right now
* we only match the first available channel, but eventually we couldlook up * we only match the first available channel, but eventually we could look up
* alternate channels by matching devname versus a virtio_config entry. * alternate channels by matching devname versus a virtio_config entry.
* We use a simple reference count mechanism to ensure that only a single * We use a simple reference count mechanism to ensure that only a single
* mount has a channel open at a time. * mount has a channel open at a time.
......
...@@ -538,6 +538,7 @@ static void p9_trans_xen_exit(void) ...@@ -538,6 +538,7 @@ static void p9_trans_xen_exit(void)
} }
module_exit(p9_trans_xen_exit); module_exit(p9_trans_xen_exit);
MODULE_ALIAS("xen:9pfs");
MODULE_AUTHOR("Stefano Stabellini <stefano@aporeto.com>"); MODULE_AUTHOR("Stefano Stabellini <stefano@aporeto.com>");
MODULE_DESCRIPTION("Xen Transport for 9P"); MODULE_DESCRIPTION("Xen Transport for 9P");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
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