Commit 4e45cca
smb/server: add ksmbd_vfs_kern_path()
The function ksmbd_vfs_kern_path_locked() seems to serve two functions
and as a result has an odd interface.
On success it returns with the parent directory locked and with write
access on that filesystem requested, but it may have crossed over a
mount point to return the path, which makes the lock and the write
access irrelevant.
This patches separates the functionality into two functions:
- ksmbd_vfs_kern_path() does not lock the parent, does not request
write access, but does cross mount points
- ksmbd_vfs_kern_path_locked() does not cross mount points but
does lock the parent and request write access.
The parent_path parameter is no longer needed. For the _locked case
the final path is sufficient to drop write access and to unlock the
parent (using path->dentry->d_parent which is safe while the lock is
held).
There were 3 caller of ksmbd_vfs_kern_path_locked().
- smb2_create_link() needs to remove the target if it existed and
needs the lock and the write-access, so it continues to use
ksmbd_vfs_kern_path_locked(). It would not make sense to
cross mount points in this case.
- smb2_open() is the only user that needs to cross mount points
and it has no need for the lock or write access, so it now uses
ksmbd_vfs_kern_path()
- smb2_creat() does not need to cross mountpoints as it is accessing
a file that it has just created on *this* filesystem. But also it
does not need the lock or write access because by the time
ksmbd_vfs_kern_path_locked() was called it has already created the
file. So it could use either interface. It is simplest to use
ksmbd_vfs_kern_path().
ksmbd_vfs_kern_path_unlock() is still needed after
ksmbd_vfs_kern_path_locked() but it doesn't require the parent_path any
more. After a successful call to ksmbd_vfs_kern_path(), only path_put()
is needed to release the path.
Signed-off-by: NeilBrown <neil@brown.name>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>1 parent d5fc140 commit 4e45cca
3 files changed
Lines changed: 111 additions & 71 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2581 | 2581 | | |
2582 | 2582 | | |
2583 | 2583 | | |
2584 | | - | |
| 2584 | + | |
2585 | 2585 | | |
2586 | 2586 | | |
2587 | 2587 | | |
| |||
2610 | 2610 | | |
2611 | 2611 | | |
2612 | 2612 | | |
2613 | | - | |
| 2613 | + | |
2614 | 2614 | | |
2615 | 2615 | | |
2616 | 2616 | | |
| |||
2860 | 2860 | | |
2861 | 2861 | | |
2862 | 2862 | | |
2863 | | - | |
| 2863 | + | |
2864 | 2864 | | |
2865 | 2865 | | |
2866 | 2866 | | |
| |||
3116 | 3116 | | |
3117 | 3117 | | |
3118 | 3118 | | |
3119 | | - | |
3120 | | - | |
| 3119 | + | |
| 3120 | + | |
3121 | 3121 | | |
3122 | 3122 | | |
3123 | 3123 | | |
| |||
3238 | 3238 | | |
3239 | 3239 | | |
3240 | 3240 | | |
3241 | | - | |
| 3241 | + | |
3242 | 3242 | | |
3243 | 3243 | | |
3244 | 3244 | | |
| |||
3443 | 3443 | | |
3444 | 3444 | | |
3445 | 3445 | | |
3446 | | - | |
| 3446 | + | |
3447 | 3447 | | |
3448 | 3448 | | |
3449 | 3449 | | |
| |||
3724 | 3724 | | |
3725 | 3725 | | |
3726 | 3726 | | |
3727 | | - | |
| 3727 | + | |
3728 | 3728 | | |
3729 | 3729 | | |
3730 | 3730 | | |
| |||
6036 | 6036 | | |
6037 | 6037 | | |
6038 | 6038 | | |
6039 | | - | |
| 6039 | + | |
6040 | 6040 | | |
6041 | 6041 | | |
6042 | 6042 | | |
| |||
6065 | 6065 | | |
6066 | 6066 | | |
6067 | 6067 | | |
6068 | | - | |
| 6068 | + | |
6069 | 6069 | | |
6070 | 6070 | | |
6071 | 6071 | | |
| |||
6083 | 6083 | | |
6084 | 6084 | | |
6085 | 6085 | | |
6086 | | - | |
| 6086 | + | |
6087 | 6087 | | |
6088 | 6088 | | |
6089 | 6089 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
73 | 72 | | |
74 | 73 | | |
75 | | - | |
| 74 | + | |
76 | 75 | | |
77 | 76 | | |
78 | 77 | | |
| |||
89 | 88 | | |
90 | 89 | | |
91 | 90 | | |
92 | | - | |
| 91 | + | |
93 | 92 | | |
94 | | - | |
95 | | - | |
| 93 | + | |
96 | 94 | | |
97 | | - | |
98 | 95 | | |
99 | 96 | | |
100 | | - | |
101 | | - | |
| 97 | + | |
102 | 98 | | |
103 | 99 | | |
104 | 100 | | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
109 | 119 | | |
110 | 120 | | |
111 | 121 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
117 | 132 | | |
118 | | - | |
119 | 133 | | |
120 | 134 | | |
121 | 135 | | |
122 | 136 | | |
123 | 137 | | |
124 | | - | |
| 138 | + | |
125 | 139 | | |
126 | 140 | | |
127 | | - | |
128 | | - | |
129 | 141 | | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | 142 | | |
138 | 143 | | |
139 | 144 | | |
| |||
1198 | 1203 | | |
1199 | 1204 | | |
1200 | 1205 | | |
1201 | | - | |
1202 | | - | |
1203 | | - | |
1204 | | - | |
1205 | | - | |
1206 | | - | |
1207 | | - | |
1208 | | - | |
1209 | | - | |
1210 | | - | |
1211 | | - | |
1212 | | - | |
1213 | | - | |
1214 | | - | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
1215 | 1210 | | |
1216 | 1211 | | |
| 1212 | + | |
1217 | 1213 | | |
1218 | 1214 | | |
1219 | 1215 | | |
1220 | 1216 | | |
1221 | | - | |
1222 | | - | |
| 1217 | + | |
1223 | 1218 | | |
1224 | 1219 | | |
1225 | 1220 | | |
1226 | 1221 | | |
1227 | 1222 | | |
1228 | 1223 | | |
1229 | | - | |
1230 | | - | |
| 1224 | + | |
| 1225 | + | |
1231 | 1226 | | |
1232 | | - | |
| 1227 | + | |
1233 | 1228 | | |
1234 | 1229 | | |
1235 | 1230 | | |
| |||
1238 | 1233 | | |
1239 | 1234 | | |
1240 | 1235 | | |
1241 | | - | |
| 1236 | + | |
1242 | 1237 | | |
1243 | 1238 | | |
1244 | | - | |
| 1239 | + | |
1245 | 1240 | | |
1246 | 1241 | | |
1247 | 1242 | | |
| |||
1254 | 1249 | | |
1255 | 1250 | | |
1256 | 1251 | | |
1257 | | - | |
| 1252 | + | |
1258 | 1253 | | |
1259 | 1254 | | |
1260 | 1255 | | |
| |||
1263 | 1258 | | |
1264 | 1259 | | |
1265 | 1260 | | |
1266 | | - | |
| 1261 | + | |
1267 | 1262 | | |
1268 | 1263 | | |
1269 | 1264 | | |
1270 | 1265 | | |
1271 | | - | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
1272 | 1309 | | |
1273 | | - | |
1274 | | - | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
1275 | 1313 | | |
1276 | | - | |
1277 | 1314 | | |
1278 | 1315 | | |
1279 | 1316 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
120 | 123 | | |
121 | | - | |
| 124 | + | |
122 | 125 | | |
123 | | - | |
| 126 | + | |
124 | 127 | | |
125 | 128 | | |
126 | 129 | | |
| |||
0 commit comments