hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/gfs2/dentry.c
....@@ -1,10 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
34 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
4
- *
5
- * This copyrighted material is made available to anyone wishing to use,
6
- * modify, copy, or redistribute it subject to the terms and conditions
7
- * of the GNU General Public License version 2.
85 */
96
107 #include <linux/spinlock.h>
....@@ -41,7 +38,7 @@
4138 struct inode *inode;
4239 struct gfs2_holder d_gh;
4340 struct gfs2_inode *ip = NULL;
44
- int error;
41
+ int error, valid = 0;
4542 int had_lock = 0;
4643
4744 if (flags & LOOKUP_RCU)
....@@ -54,53 +51,30 @@
5451
5552 if (inode) {
5653 if (is_bad_inode(inode))
57
- goto invalid;
54
+ goto out;
5855 ip = GFS2_I(inode);
5956 }
6057
61
- if (sdp->sd_lockstruct.ls_ops->lm_mount == NULL)
62
- goto valid;
58
+ if (sdp->sd_lockstruct.ls_ops->lm_mount == NULL) {
59
+ valid = 1;
60
+ goto out;
61
+ }
6362
6463 had_lock = (gfs2_glock_is_locked_by_me(dip->i_gl) != NULL);
6564 if (!had_lock) {
6665 error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, 0, &d_gh);
6766 if (error)
68
- goto fail;
69
- }
70
-
71
- error = gfs2_dir_check(d_inode(parent), &dentry->d_name, ip);
72
- switch (error) {
73
- case 0:
74
- if (!inode)
75
- goto invalid_gunlock;
76
- break;
77
- case -ENOENT:
78
- if (!inode)
79
- goto valid_gunlock;
80
- goto invalid_gunlock;
81
- default:
82
- goto fail_gunlock;
67
+ goto out;
8368 }
8469
85
-valid_gunlock:
70
+ error = gfs2_dir_check(d_inode(parent), &dentry->d_name, ip);
71
+ valid = inode ? !error : (error == -ENOENT);
72
+
8673 if (!had_lock)
8774 gfs2_glock_dq_uninit(&d_gh);
88
-valid:
75
+out:
8976 dput(parent);
90
- return 1;
91
-
92
-invalid_gunlock:
93
- if (!had_lock)
94
- gfs2_glock_dq_uninit(&d_gh);
95
-invalid:
96
- dput(parent);
97
- return 0;
98
-
99
-fail_gunlock:
100
- gfs2_glock_dq_uninit(&d_gh);
101
-fail:
102
- dput(parent);
103
- return 0;
77
+ return valid;
10478 }
10579
10680 static int gfs2_dhash(const struct dentry *dentry, struct qstr *str)