hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/9p/vfs_inode.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * linux/fs/9p/vfs_inode.c
34 *
....@@ -5,22 +6,6 @@
56 *
67 * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com>
78 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
8
- *
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License version 2
11
- * as published by the Free Software Foundation.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU General Public License
19
- * along with this program; if not, write to:
20
- * Free Software Foundation
21
- * 51 Franklin Street, Fifth Floor
22
- * Boston, MA 02111-1301 USA
23
- *
249 */
2510
2611 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
....@@ -158,7 +143,7 @@
158143 default:
159144 p9_debug(P9_DEBUG_ERROR, "Unknown special type %c %s\n",
160145 type, stat->extension);
161
- };
146
+ }
162147 *rdev = MKDEV(major, minor);
163148 } else
164149 res |= S_IFREG;
....@@ -238,8 +223,7 @@
238223 struct inode *v9fs_alloc_inode(struct super_block *sb)
239224 {
240225 struct v9fs_inode *v9inode;
241
- v9inode = (struct v9fs_inode *)kmem_cache_alloc(v9fs_inode_cache,
242
- GFP_KERNEL);
226
+ v9inode = kmem_cache_alloc(v9fs_inode_cache, GFP_KERNEL);
243227 if (!v9inode)
244228 return NULL;
245229 #ifdef CONFIG_9P_FSCACHE
....@@ -253,19 +237,13 @@
253237 }
254238
255239 /**
256
- * v9fs_destroy_inode - destroy an inode
240
+ * v9fs_free_inode - destroy an inode
257241 *
258242 */
259243
260
-static void v9fs_i_callback(struct rcu_head *head)
244
+void v9fs_free_inode(struct inode *inode)
261245 {
262
- struct inode *inode = container_of(head, struct inode, i_rcu);
263246 kmem_cache_free(v9fs_inode_cache, V9FS_I(inode));
264
-}
265
-
266
-void v9fs_destroy_inode(struct inode *inode)
267
-{
268
- call_rcu(&inode->i_rcu, v9fs_i_callback);
269247 }
270248
271249 int v9fs_init_inode(struct v9fs_session_info *v9ses,
....@@ -389,59 +367,6 @@
389367 return inode;
390368 }
391369
392
-/*
393
-static struct v9fs_fid*
394
-v9fs_clone_walk(struct v9fs_session_info *v9ses, u32 fid, struct dentry *dentry)
395
-{
396
- int err;
397
- int nfid;
398
- struct v9fs_fid *ret;
399
- struct v9fs_fcall *fcall;
400
-
401
- nfid = v9fs_get_idpool(&v9ses->fidpool);
402
- if (nfid < 0) {
403
- eprintk(KERN_WARNING, "no free fids available\n");
404
- return ERR_PTR(-ENOSPC);
405
- }
406
-
407
- err = v9fs_t_walk(v9ses, fid, nfid, (char *) dentry->d_name.name,
408
- &fcall);
409
-
410
- if (err < 0) {
411
- if (fcall && fcall->id == RWALK)
412
- goto clunk_fid;
413
-
414
- PRINT_FCALL_ERROR("walk error", fcall);
415
- v9fs_put_idpool(nfid, &v9ses->fidpool);
416
- goto error;
417
- }
418
-
419
- kfree(fcall);
420
- fcall = NULL;
421
- ret = v9fs_fid_create(v9ses, nfid);
422
- if (!ret) {
423
- err = -ENOMEM;
424
- goto clunk_fid;
425
- }
426
-
427
- err = v9fs_fid_insert(ret, dentry);
428
- if (err < 0) {
429
- v9fs_fid_destroy(ret);
430
- goto clunk_fid;
431
- }
432
-
433
- return ret;
434
-
435
-clunk_fid:
436
- v9fs_t_clunk(v9ses, nfid);
437
-
438
-error:
439
- kfree(fcall);
440
- return ERR_PTR(err);
441
-}
442
-*/
443
-
444
-
445370 /**
446371 * v9fs_clear_inode - release an inode
447372 * @inode: inode to release
....@@ -473,7 +398,7 @@
473398
474399 umode = p9mode2unixmode(v9ses, st, &rdev);
475400 /* don't match inode of different type */
476
- if ((inode->i_mode & S_IFMT) != (umode & S_IFMT))
401
+ if (inode_wrong_type(inode, umode))
477402 return 0;
478403
479404 /* compare qid details */
....@@ -1111,7 +1036,7 @@
11111036 {
11121037 int retval;
11131038 struct v9fs_session_info *v9ses;
1114
- struct p9_fid *fid;
1039
+ struct p9_fid *fid = NULL;
11151040 struct p9_wstat wstat;
11161041
11171042 p9_debug(P9_DEBUG_VFS, "\n");
....@@ -1121,7 +1046,12 @@
11211046
11221047 retval = -EPERM;
11231048 v9ses = v9fs_dentry2v9ses(dentry);
1124
- fid = v9fs_fid_lookup(dentry);
1049
+ if (iattr->ia_valid & ATTR_FILE) {
1050
+ fid = iattr->ia_file->private_data;
1051
+ WARN_ON(!fid);
1052
+ }
1053
+ if (!fid)
1054
+ fid = v9fs_fid_lookup(dentry);
11251055 if(IS_ERR(fid))
11261056 return PTR_ERR(fid);
11271057
....@@ -1430,7 +1360,7 @@
14301360 * Don't update inode if the file type is different
14311361 */
14321362 umode = p9mode2unixmode(v9ses, st, &rdev);
1433
- if ((inode->i_mode & S_IFMT) != (umode & S_IFMT))
1363
+ if (inode_wrong_type(inode, umode))
14341364 goto out;
14351365
14361366 /*