Skip to content

Commit f89ce84

Browse files
committed
Merge tag '9p-for-5.16-rc1' of git://github.com/martinetd/linux
Pull 9p updates from Dominique Martinet: "Fixes, netfs read support and checkpatch rewrite: - fix syzcaller uninitialized value usage after missing error check - add module autoloading based on transport name - convert cached reads to use netfs helpers - adjust readahead based on transport msize - and many, many checkpatch.pl warning fixes..." * tag '9p-for-5.16-rc1' of git://github.com/martinetd/linux: 9p: fix a bunch of checkpatch warnings 9p: set readahead and io size according to maxsize 9p p9mode2perm: remove useless strlcpy and check sscanf return code 9p v9fs_parse_options: replace simple_strtoul with kstrtouint 9p: fix file headers fs/9p: fix indentation and Add missing a blank line after declaration fs/9p: fix warnings found by checkpatch.pl 9p: fix minor indentation and codestyle fs/9p: cleanup: opening brace at the beginning of the next line 9p: Convert to using the netfs helper lib to do reads and caching fscache_cookie_enabled: check cookie is valid before accessing it net/9p: autoload transport modules 9p/net: fix missing error check in p9_check_errors
2 parents 59a2cee + 6e195b0 commit f89ce84

33 files changed

+518
-779
lines changed

fs/9p/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
config 9P_FS
33
tristate "Plan 9 Resource Sharing Support (9P2000)"
44
depends on INET && NET_9P
5+
select NETFS_SUPPORT
56
help
67
If you say Y here, you will get experimental support for
78
Plan 9 resource sharing via the 9P2000 protocol.

fs/9p/acl.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1+
// SPDX-License-Identifier: LGPL-2.1
12
/*
23
* Copyright IBM Corporation, 2010
34
* Author Aneesh Kumar K.V <[email protected]>
4-
*
5-
* This program is free software; you can redistribute it and/or modify it
6-
* under the terms of version 2.1 of the GNU Lesser General Public License
7-
* as published by the Free Software Foundation.
8-
*
9-
* This program is distributed in the hope that it would be useful, but
10-
* WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12-
*
135
*/
146

157
#include <linux/module.h>
@@ -123,6 +115,7 @@ static int v9fs_set_acl(struct p9_fid *fid, int type, struct posix_acl *acl)
123115
char *name;
124116
size_t size;
125117
void *buffer;
118+
126119
if (!acl)
127120
return 0;
128121

fs/9p/acl.h

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
1+
/* SPDX-License-Identifier: LGPL-2.1 */
12
/*
23
* Copyright IBM Corporation, 2010
34
* Author Aneesh Kumar K.V <[email protected]>
4-
*
5-
* This program is free software; you can redistribute it and/or modify it
6-
* under the terms of version 2.1 of the GNU Lesser General Public License
7-
* as published by the Free Software Foundation.
8-
*
9-
* This program is distributed in the hope that it would be useful, but
10-
* WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12-
*
135
*/
146
#ifndef FS_9P_ACL_H
157
#define FS_9P_ACL_H
168

179
#ifdef CONFIG_9P_FS_POSIX_ACL
18-
extern int v9fs_get_acl(struct inode *, struct p9_fid *);
19-
extern struct posix_acl *v9fs_iop_get_acl(struct inode *inode, int type, bool rcu);
20-
extern int v9fs_acl_chmod(struct inode *, struct p9_fid *);
21-
extern int v9fs_set_create_acl(struct inode *, struct p9_fid *,
22-
struct posix_acl *, struct posix_acl *);
23-
extern int v9fs_acl_mode(struct inode *dir, umode_t *modep,
24-
struct posix_acl **dpacl, struct posix_acl **pacl);
25-
extern void v9fs_put_acl(struct posix_acl *dacl, struct posix_acl *acl);
10+
int v9fs_get_acl(struct inode *inode, struct p9_fid *fid);
11+
struct posix_acl *v9fs_iop_get_acl(struct inode *inode, int type,
12+
bool rcu);
13+
int v9fs_acl_chmod(struct inode *inode, struct p9_fid *fid);
14+
int v9fs_set_create_acl(struct inode *inode, struct p9_fid *fid,
15+
struct posix_acl *dacl, struct posix_acl *acl);
16+
int v9fs_acl_mode(struct inode *dir, umode_t *modep,
17+
struct posix_acl **dpacl, struct posix_acl **pacl);
18+
void v9fs_put_acl(struct posix_acl *dacl, struct posix_acl *acl);
2619
#else
2720
#define v9fs_iop_get_acl NULL
2821
static inline int v9fs_get_acl(struct inode *inode, struct p9_fid *fid)

fs/9p/cache.c

Lines changed: 2 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#define CACHETAG_LEN 11
2020

2121
struct fscache_netfs v9fs_cache_netfs = {
22-
.name = "9p",
23-
.version = 0,
22+
.name = "9p",
23+
.version = 0,
2424
};
2525

2626
/*
@@ -199,140 +199,3 @@ void v9fs_cache_inode_reset_cookie(struct inode *inode)
199199

200200
mutex_unlock(&v9inode->fscache_lock);
201201
}
202-
203-
int __v9fs_fscache_release_page(struct page *page, gfp_t gfp)
204-
{
205-
struct inode *inode = page->mapping->host;
206-
struct v9fs_inode *v9inode = V9FS_I(inode);
207-
208-
BUG_ON(!v9inode->fscache);
209-
210-
return fscache_maybe_release_page(v9inode->fscache, page, gfp);
211-
}
212-
213-
void __v9fs_fscache_invalidate_page(struct page *page)
214-
{
215-
struct inode *inode = page->mapping->host;
216-
struct v9fs_inode *v9inode = V9FS_I(inode);
217-
218-
BUG_ON(!v9inode->fscache);
219-
220-
if (PageFsCache(page)) {
221-
fscache_wait_on_page_write(v9inode->fscache, page);
222-
BUG_ON(!PageLocked(page));
223-
fscache_uncache_page(v9inode->fscache, page);
224-
}
225-
}
226-
227-
static void v9fs_vfs_readpage_complete(struct page *page, void *data,
228-
int error)
229-
{
230-
if (!error)
231-
SetPageUptodate(page);
232-
233-
unlock_page(page);
234-
}
235-
236-
/*
237-
* __v9fs_readpage_from_fscache - read a page from cache
238-
*
239-
* Returns 0 if the pages are in cache and a BIO is submitted,
240-
* 1 if the pages are not in cache and -error otherwise.
241-
*/
242-
243-
int __v9fs_readpage_from_fscache(struct inode *inode, struct page *page)
244-
{
245-
int ret;
246-
const struct v9fs_inode *v9inode = V9FS_I(inode);
247-
248-
p9_debug(P9_DEBUG_FSC, "inode %p page %p\n", inode, page);
249-
if (!v9inode->fscache)
250-
return -ENOBUFS;
251-
252-
ret = fscache_read_or_alloc_page(v9inode->fscache,
253-
page,
254-
v9fs_vfs_readpage_complete,
255-
NULL,
256-
GFP_KERNEL);
257-
switch (ret) {
258-
case -ENOBUFS:
259-
case -ENODATA:
260-
p9_debug(P9_DEBUG_FSC, "page/inode not in cache %d\n", ret);
261-
return 1;
262-
case 0:
263-
p9_debug(P9_DEBUG_FSC, "BIO submitted\n");
264-
return ret;
265-
default:
266-
p9_debug(P9_DEBUG_FSC, "ret %d\n", ret);
267-
return ret;
268-
}
269-
}
270-
271-
/*
272-
* __v9fs_readpages_from_fscache - read multiple pages from cache
273-
*
274-
* Returns 0 if the pages are in cache and a BIO is submitted,
275-
* 1 if the pages are not in cache and -error otherwise.
276-
*/
277-
278-
int __v9fs_readpages_from_fscache(struct inode *inode,
279-
struct address_space *mapping,
280-
struct list_head *pages,
281-
unsigned *nr_pages)
282-
{
283-
int ret;
284-
const struct v9fs_inode *v9inode = V9FS_I(inode);
285-
286-
p9_debug(P9_DEBUG_FSC, "inode %p pages %u\n", inode, *nr_pages);
287-
if (!v9inode->fscache)
288-
return -ENOBUFS;
289-
290-
ret = fscache_read_or_alloc_pages(v9inode->fscache,
291-
mapping, pages, nr_pages,
292-
v9fs_vfs_readpage_complete,
293-
NULL,
294-
mapping_gfp_mask(mapping));
295-
switch (ret) {
296-
case -ENOBUFS:
297-
case -ENODATA:
298-
p9_debug(P9_DEBUG_FSC, "pages/inodes not in cache %d\n", ret);
299-
return 1;
300-
case 0:
301-
BUG_ON(!list_empty(pages));
302-
BUG_ON(*nr_pages != 0);
303-
p9_debug(P9_DEBUG_FSC, "BIO submitted\n");
304-
return ret;
305-
default:
306-
p9_debug(P9_DEBUG_FSC, "ret %d\n", ret);
307-
return ret;
308-
}
309-
}
310-
311-
/*
312-
* __v9fs_readpage_to_fscache - write a page to the cache
313-
*
314-
*/
315-
316-
void __v9fs_readpage_to_fscache(struct inode *inode, struct page *page)
317-
{
318-
int ret;
319-
const struct v9fs_inode *v9inode = V9FS_I(inode);
320-
321-
p9_debug(P9_DEBUG_FSC, "inode %p page %p\n", inode, page);
322-
ret = fscache_write_page(v9inode->fscache, page,
323-
i_size_read(&v9inode->vfs_inode), GFP_KERNEL);
324-
p9_debug(P9_DEBUG_FSC, "ret = %d\n", ret);
325-
if (ret != 0)
326-
v9fs_uncache_page(inode, page);
327-
}
328-
329-
/*
330-
* wait for a page to complete writing to the cache
331-
*/
332-
void __v9fs_fscache_wait_on_page_write(struct inode *inode, struct page *page)
333-
{
334-
const struct v9fs_inode *v9inode = V9FS_I(inode);
335-
p9_debug(P9_DEBUG_FSC, "inode %p page %p\n", inode, page);
336-
if (PageFsCache(page))
337-
fscache_wait_on_page_write(v9inode->fscache, page);
338-
}

fs/9p/cache.h

Lines changed: 3 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77

88
#ifndef _9P_CACHE_H
99
#define _9P_CACHE_H
10-
#ifdef CONFIG_9P_FSCACHE
10+
#define FSCACHE_USE_NEW_IO_API
1111
#include <linux/fscache.h>
12-
#include <linux/spinlock.h>
12+
13+
#ifdef CONFIG_9P_FSCACHE
1314

1415
extern struct fscache_netfs v9fs_cache_netfs;
1516
extern const struct fscache_cookie_def v9fs_cache_session_index_def;
@@ -27,64 +28,6 @@ extern void v9fs_cache_inode_reset_cookie(struct inode *inode);
2728
extern int __v9fs_cache_register(void);
2829
extern void __v9fs_cache_unregister(void);
2930

30-
extern int __v9fs_fscache_release_page(struct page *page, gfp_t gfp);
31-
extern void __v9fs_fscache_invalidate_page(struct page *page);
32-
extern int __v9fs_readpage_from_fscache(struct inode *inode,
33-
struct page *page);
34-
extern int __v9fs_readpages_from_fscache(struct inode *inode,
35-
struct address_space *mapping,
36-
struct list_head *pages,
37-
unsigned *nr_pages);
38-
extern void __v9fs_readpage_to_fscache(struct inode *inode, struct page *page);
39-
extern void __v9fs_fscache_wait_on_page_write(struct inode *inode,
40-
struct page *page);
41-
42-
static inline int v9fs_fscache_release_page(struct page *page,
43-
gfp_t gfp)
44-
{
45-
return __v9fs_fscache_release_page(page, gfp);
46-
}
47-
48-
static inline void v9fs_fscache_invalidate_page(struct page *page)
49-
{
50-
__v9fs_fscache_invalidate_page(page);
51-
}
52-
53-
static inline int v9fs_readpage_from_fscache(struct inode *inode,
54-
struct page *page)
55-
{
56-
return __v9fs_readpage_from_fscache(inode, page);
57-
}
58-
59-
static inline int v9fs_readpages_from_fscache(struct inode *inode,
60-
struct address_space *mapping,
61-
struct list_head *pages,
62-
unsigned *nr_pages)
63-
{
64-
return __v9fs_readpages_from_fscache(inode, mapping, pages,
65-
nr_pages);
66-
}
67-
68-
static inline void v9fs_readpage_to_fscache(struct inode *inode,
69-
struct page *page)
70-
{
71-
if (PageFsCache(page))
72-
__v9fs_readpage_to_fscache(inode, page);
73-
}
74-
75-
static inline void v9fs_uncache_page(struct inode *inode, struct page *page)
76-
{
77-
struct v9fs_inode *v9inode = V9FS_I(inode);
78-
fscache_uncache_page(v9inode->fscache, page);
79-
BUG_ON(PageFsCache(page));
80-
}
81-
82-
static inline void v9fs_fscache_wait_on_page_write(struct inode *inode,
83-
struct page *page)
84-
{
85-
return __v9fs_fscache_wait_on_page_write(inode, page);
86-
}
87-
8831
#else /* CONFIG_9P_FSCACHE */
8932

9033
static inline void v9fs_cache_inode_get_cookie(struct inode *inode)
@@ -99,39 +42,5 @@ static inline void v9fs_cache_inode_set_cookie(struct inode *inode, struct file
9942
{
10043
}
10144

102-
static inline int v9fs_fscache_release_page(struct page *page,
103-
gfp_t gfp) {
104-
return 1;
105-
}
106-
107-
static inline void v9fs_fscache_invalidate_page(struct page *page) {}
108-
109-
static inline int v9fs_readpage_from_fscache(struct inode *inode,
110-
struct page *page)
111-
{
112-
return -ENOBUFS;
113-
}
114-
115-
static inline int v9fs_readpages_from_fscache(struct inode *inode,
116-
struct address_space *mapping,
117-
struct list_head *pages,
118-
unsigned *nr_pages)
119-
{
120-
return -ENOBUFS;
121-
}
122-
123-
static inline void v9fs_readpage_to_fscache(struct inode *inode,
124-
struct page *page)
125-
{}
126-
127-
static inline void v9fs_uncache_page(struct inode *inode, struct page *page)
128-
{}
129-
130-
static inline void v9fs_fscache_wait_on_page_write(struct inode *inode,
131-
struct page *page)
132-
{
133-
return;
134-
}
135-
13645
#endif /* CONFIG_9P_FSCACHE */
13746
#endif /* _9P_CACHE_H */

fs/9p/fid.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ static struct p9_fid *v9fs_fid_find(struct dentry *dentry, kuid_t uid, int any)
103103
/* we'll recheck under lock if there's anything to look in */
104104
if (!ret && dentry->d_fsdata) {
105105
struct hlist_head *h = (struct hlist_head *)&dentry->d_fsdata;
106+
106107
spin_lock(&dentry->d_lock);
107108
hlist_for_each_entry(fid, h, dlist) {
108109
if (any || uid_eq(fid->uid, uid)) {
@@ -185,7 +186,7 @@ static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry,
185186
return ERR_PTR(-EPERM);
186187

187188
if (v9fs_proto_dotu(v9ses) || v9fs_proto_dotl(v9ses))
188-
uname = NULL;
189+
uname = NULL;
189190
else
190191
uname = v9ses->uname;
191192

0 commit comments

Comments
 (0)