Skip to content

Commit 49ad227

Browse files
committed
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()
2 parents 59d4145 + 19d1c32 commit 49ad227

File tree

13 files changed

+71
-25
lines changed

13 files changed

+71
-25
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ F: drivers/net/ethernet/8390/
226226
M: Eric Van Hensbergen <[email protected]>
227227
M: Latchesar Ionkov <[email protected]>
228228
M: Dominique Martinet <[email protected]>
229+
R: Christian Schoenebeck <[email protected]>
229230
230231
S: Maintained
231232
W: http://swik.net/v9fs

fs/9p/vfs_addr.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ static void v9fs_req_issue_op(struct netfs_read_subrequest *subreq)
4343
iov_iter_xarray(&to, READ, &rreq->mapping->i_pages, pos, len);
4444

4545
total = p9_client_read(fid, pos, &to, &err);
46+
47+
/* if we just extended the file size, any portion not in
48+
* cache won't be on server and is zeroes */
49+
__set_bit(NETFS_SREQ_CLEAR_TAIL, &subreq->flags);
50+
4651
netfs_subreq_terminated(subreq, err ?: total, false);
4752
}
4853

fs/9p/vfs_file.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ int v9fs_file_open(struct inode *inode, struct file *file)
115115

116116
static int v9fs_file_lock(struct file *filp, int cmd, struct file_lock *fl)
117117
{
118-
int res = 0;
119118
struct inode *inode = file_inode(filp);
120119

121120
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)
125124
invalidate_mapping_pages(&inode->i_data, 0, -1);
126125
}
127126

128-
return res;
127+
return 0;
129128
}
130129

131130
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)
140139
fid = filp->private_data;
141140
BUG_ON(fid == NULL);
142141

143-
if ((fl->fl_flags & FL_POSIX) != FL_POSIX)
144-
BUG();
142+
BUG_ON((fl->fl_flags & FL_POSIX) != FL_POSIX);
145143

146144
res = locks_lock_file_wait(filp, fl);
147145
if (res < 0)

fs/9p/vfs_inode_dotl.c

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,10 @@ int v9fs_vfs_setattr_dotl(struct user_namespace *mnt_userns,
552552
{
553553
int retval, use_dentry = 0;
554554
struct p9_fid *fid = NULL;
555-
struct p9_iattr_dotl p9attr;
555+
struct p9_iattr_dotl p9attr = {
556+
.uid = INVALID_UID,
557+
.gid = INVALID_GID,
558+
};
556559
struct inode *inode = d_inode(dentry);
557560

558561
p9_debug(P9_DEBUG_VFS, "\n");
@@ -562,14 +565,22 @@ int v9fs_vfs_setattr_dotl(struct user_namespace *mnt_userns,
562565
return retval;
563566

564567
p9attr.valid = v9fs_mapped_iattr_valid(iattr->ia_valid);
565-
p9attr.mode = iattr->ia_mode;
566-
p9attr.uid = iattr->ia_uid;
567-
p9attr.gid = iattr->ia_gid;
568-
p9attr.size = iattr->ia_size;
569-
p9attr.atime_sec = iattr->ia_atime.tv_sec;
570-
p9attr.atime_nsec = iattr->ia_atime.tv_nsec;
571-
p9attr.mtime_sec = iattr->ia_mtime.tv_sec;
572-
p9attr.mtime_nsec = iattr->ia_mtime.tv_nsec;
568+
if (iattr->ia_valid & ATTR_MODE)
569+
p9attr.mode = iattr->ia_mode;
570+
if (iattr->ia_valid & ATTR_UID)
571+
p9attr.uid = iattr->ia_uid;
572+
if (iattr->ia_valid & ATTR_GID)
573+
p9attr.gid = iattr->ia_gid;
574+
if (iattr->ia_valid & ATTR_SIZE)
575+
p9attr.size = iattr->ia_size;
576+
if (iattr->ia_valid & ATTR_ATIME_SET) {
577+
p9attr.atime_sec = iattr->ia_atime.tv_sec;
578+
p9attr.atime_nsec = iattr->ia_atime.tv_nsec;
579+
}
580+
if (iattr->ia_valid & ATTR_MTIME_SET) {
581+
p9attr.mtime_sec = iattr->ia_mtime.tv_sec;
582+
p9attr.mtime_nsec = iattr->ia_mtime.tv_nsec;
583+
}
573584

574585
if (iattr->ia_valid & ATTR_FILE) {
575586
fid = iattr->ia_file->private_data;

include/net/9p/9p.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,4 @@ struct p9_fcall {
551551
int p9_errstr2errno(char *errstr, int len);
552552

553553
int p9_error_init(void);
554-
int p9_trans_fd_init(void);
555-
void p9_trans_fd_exit(void);
556554
#endif /* NET_9P_H */

include/net/9p/transport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ struct p9_trans_module {
5454

5555
void v9fs_register_trans(struct p9_trans_module *m);
5656
void v9fs_unregister_trans(struct p9_trans_module *m);
57-
struct p9_trans_module *v9fs_get_trans_by_name(char *s);
57+
struct p9_trans_module *v9fs_get_trans_by_name(const char *s);
5858
struct p9_trans_module *v9fs_get_default_trans(void);
5959
void v9fs_put_trans(struct p9_trans_module *m);
6060

net/9p/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ menuconfig NET_9P
1515

1616
if NET_9P
1717

18+
config NET_9P_FD
19+
default NET_9P
20+
tristate "9P FD Transport"
21+
help
22+
This builds support for transports over TCP, Unix sockets and
23+
filedescriptors.
24+
1825
config NET_9P_VIRTIO
1926
depends on VIRTIO
2027
tristate "9P Virtio Transport"

net/9p/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# SPDX-License-Identifier: GPL-2.0
22
obj-$(CONFIG_NET_9P) := 9pnet.o
3+
obj-$(CONFIG_NET_9P_FD) += 9pnet_fd.o
34
obj-$(CONFIG_NET_9P_XEN) += 9pnet_xen.o
45
obj-$(CONFIG_NET_9P_VIRTIO) += 9pnet_virtio.o
56
obj-$(CONFIG_NET_9P_RDMA) += 9pnet_rdma.o
@@ -9,9 +10,11 @@ obj-$(CONFIG_NET_9P_RDMA) += 9pnet_rdma.o
910
client.o \
1011
error.o \
1112
protocol.o \
12-
trans_fd.o \
1313
trans_common.o \
1414

15+
9pnet_fd-objs := \
16+
trans_fd.o \
17+
1518
9pnet_virtio-objs := \
1619
trans_virtio.o \
1720

net/9p/client.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,8 +1038,13 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
10381038
if (err)
10391039
goto put_trans;
10401040

1041-
if (clnt->msize > clnt->trans_mod->maxsize)
1041+
if (clnt->msize > clnt->trans_mod->maxsize) {
10421042
clnt->msize = clnt->trans_mod->maxsize;
1043+
pr_info("Limiting 'msize' to %d as this is the maximum "
1044+
"supported by transport %s\n",
1045+
clnt->msize, clnt->trans_mod->name
1046+
);
1047+
}
10431048

10441049
if (clnt->msize < 4096) {
10451050
p9_debug(P9_DEBUG_ERROR,

net/9p/mod.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void v9fs_unregister_trans(struct p9_trans_module *m)
8383
}
8484
EXPORT_SYMBOL(v9fs_unregister_trans);
8585

86-
static struct p9_trans_module *_p9_get_trans_by_name(char *s)
86+
static struct p9_trans_module *_p9_get_trans_by_name(const char *s)
8787
{
8888
struct p9_trans_module *t, *found = NULL;
8989

@@ -106,7 +106,7 @@ static struct p9_trans_module *_p9_get_trans_by_name(char *s)
106106
* @s: string identifying transport
107107
*
108108
*/
109-
struct p9_trans_module *v9fs_get_trans_by_name(char *s)
109+
struct p9_trans_module *v9fs_get_trans_by_name(const char *s)
110110
{
111111
struct p9_trans_module *found = NULL;
112112

@@ -123,6 +123,10 @@ struct p9_trans_module *v9fs_get_trans_by_name(char *s)
123123
}
124124
EXPORT_SYMBOL(v9fs_get_trans_by_name);
125125

126+
static const char * const v9fs_default_transports[] = {
127+
"virtio", "tcp", "fd", "unix", "xen", "rdma",
128+
};
129+
126130
/**
127131
* v9fs_get_default_trans - get the default transport
128132
*
@@ -131,6 +135,7 @@ EXPORT_SYMBOL(v9fs_get_trans_by_name);
131135
struct p9_trans_module *v9fs_get_default_trans(void)
132136
{
133137
struct p9_trans_module *t, *found = NULL;
138+
int i;
134139

135140
spin_lock(&v9fs_trans_lock);
136141

@@ -148,6 +153,10 @@ struct p9_trans_module *v9fs_get_default_trans(void)
148153
}
149154

150155
spin_unlock(&v9fs_trans_lock);
156+
157+
for (i = 0; !found && i < ARRAY_SIZE(v9fs_default_transports); i++)
158+
found = v9fs_get_trans_by_name(v9fs_default_transports[i]);
159+
151160
return found;
152161
}
153162
EXPORT_SYMBOL(v9fs_get_default_trans);
@@ -177,7 +186,6 @@ static int __init init_p9(void)
177186

178187
p9_error_init();
179188
pr_info("Installing 9P2000 support\n");
180-
p9_trans_fd_init();
181189

182190
return ret;
183191
}
@@ -191,7 +199,6 @@ static void __exit exit_p9(void)
191199
{
192200
pr_info("Unloading 9P2000 support\n");
193201

194-
p9_trans_fd_exit();
195202
p9_client_exit();
196203
}
197204

0 commit comments

Comments
 (0)