Commit f16b5a1
committed
nfsd: fix handling of cached open files in nfsd4_open codepath
Bugzilla: https://bugzilla.redhat.com/2152473
commit 0b3a551
Author: Jeff Layton <jlayton@kernel.org>
Date: Thu Jan 5 14:55:56 2023 -0500
nfsd: fix handling of cached open files in nfsd4_open codepath
Commit fb70bf1 ("NFSD: Instantiate a struct file when creating a
regular NFSv4 file") added the ability to cache an open fd over a
compound. There are a couple of problems with the way this currently
works:
It's racy, as a newly-created nfsd_file can end up with its PENDING bit
cleared while the nf is hashed, and the nf_file pointer is still zeroed
out. Other tasks can find it in this state and they expect to see a
valid nf_file, and can oops if nf_file is NULL.
Also, there is no guarantee that we'll end up creating a new nfsd_file
if one is already in the hash. If an extant entry is in the hash with a
valid nf_file, nfs4_get_vfs_file will clobber its nf_file pointer with
the value of op_file and the old nf_file will leak.
Fix both issues by making a new nfsd_file_acquirei_opened variant that
takes an optional file pointer. If one is present when this is called,
we'll take a new reference to it instead of trying to open the file. If
the nfsd_file already has a valid nf_file, we'll just ignore the
optional file and pass the nfsd_file back as-is.
Also rework the tracepoints a bit to allow for an "opened" variant and
don't try to avoid counting acquisitions in the case where we already
have a cached open file.
Fixes: fb70bf1 ("NFSD: Instantiate a struct file when creating a regular NFSv4 file")
Cc: Trond Myklebust <trondmy@hammerspace.com>
Reported-by: Stanislav Saner <ssaner@redhat.com>
Reported-and-Tested-by: Ruben Vestergaard <rubenv@drcmr.dk>
Reported-and-Tested-by: Torkil Svensgaard <torkil@drcmr.dk>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Jeffrey Layton <jlayton@redhat.com>1 parent ced6654 commit f16b5a1
4 files changed
+42
-71
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1069 | 1069 | | |
1070 | 1070 | | |
1071 | 1071 | | |
1072 | | - | |
1073 | | - | |
| 1072 | + | |
| 1073 | + | |
1074 | 1074 | | |
1075 | 1075 | | |
1076 | 1076 | | |
| |||
1145 | 1145 | | |
1146 | 1146 | | |
1147 | 1147 | | |
1148 | | - | |
1149 | | - | |
| 1148 | + | |
1150 | 1149 | | |
1151 | 1150 | | |
1152 | 1151 | | |
| |||
1156 | 1155 | | |
1157 | 1156 | | |
1158 | 1157 | | |
1159 | | - | |
1160 | | - | |
| 1158 | + | |
1161 | 1159 | | |
1162 | 1160 | | |
1163 | 1161 | | |
1164 | 1162 | | |
1165 | 1163 | | |
1166 | 1164 | | |
1167 | | - | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
1168 | 1171 | | |
1169 | 1172 | | |
1170 | 1173 | | |
1171 | | - | |
1172 | | - | |
| 1174 | + | |
1173 | 1175 | | |
1174 | 1176 | | |
1175 | 1177 | | |
| |||
1205 | 1207 | | |
1206 | 1208 | | |
1207 | 1209 | | |
1208 | | - | |
| 1210 | + | |
1209 | 1211 | | |
1210 | 1212 | | |
1211 | 1213 | | |
| |||
1226 | 1228 | | |
1227 | 1229 | | |
1228 | 1230 | | |
1229 | | - | |
| 1231 | + | |
1230 | 1232 | | |
1231 | 1233 | | |
1232 | 1234 | | |
1233 | | - | |
| 1235 | + | |
1234 | 1236 | | |
1235 | 1237 | | |
1236 | 1238 | | |
| 1239 | + | |
1237 | 1240 | | |
1238 | 1241 | | |
1239 | | - | |
1240 | | - | |
1241 | | - | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
1242 | 1245 | | |
1243 | 1246 | | |
1244 | 1247 | | |
1245 | 1248 | | |
1246 | 1249 | | |
1247 | | - | |
1248 | | - | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
1249 | 1253 | | |
1250 | | - | |
| 1254 | + | |
1251 | 1255 | | |
1252 | 1256 | | |
1253 | 1257 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
64 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
65 | 66 | | |
66 | 67 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5042 | 5042 | | |
5043 | 5043 | | |
5044 | 5044 | | |
5045 | | - | |
5046 | | - | |
5047 | | - | |
5048 | | - | |
5049 | | - | |
5050 | | - | |
5051 | | - | |
5052 | | - | |
5053 | | - | |
5054 | | - | |
5055 | | - | |
5056 | | - | |
| 5045 | + | |
| 5046 | + | |
| 5047 | + | |
| 5048 | + | |
5057 | 5049 | | |
5058 | 5050 | | |
5059 | 5051 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
902 | 902 | | |
903 | 903 | | |
904 | 904 | | |
905 | | - | |
906 | | - | |
907 | | - | |
908 | | - | |
909 | | - | |
910 | | - | |
911 | | - | |
912 | | - | |
913 | | - | |
914 | | - | |
915 | | - | |
916 | | - | |
917 | | - | |
918 | | - | |
919 | | - | |
920 | | - | |
921 | | - | |
922 | | - | |
923 | | - | |
924 | | - | |
925 | | - | |
926 | | - | |
927 | | - | |
928 | | - | |
929 | | - | |
930 | | - | |
931 | | - | |
932 | | - | |
933 | | - | |
934 | | - | |
935 | | - | |
936 | | - | |
937 | | - | |
938 | | - | |
939 | | - | |
940 | | - | |
941 | | - | |
942 | 905 | | |
943 | 906 | | |
944 | 907 | | |
| |||
1000 | 963 | | |
1001 | 964 | | |
1002 | 965 | | |
1003 | | - | |
1004 | | - | |
| 966 | + | |
| 967 | + | |
1005 | 968 | | |
1006 | 969 | | |
1007 | 970 | | |
| |||
1025 | 988 | | |
1026 | 989 | | |
1027 | 990 | | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
1028 | 1002 | | |
1029 | 1003 | | |
1030 | 1004 | | |
| |||
0 commit comments