@@ -137,10 +137,6 @@ static int xdr_decode_AFSFetchStatus(struct afs_call *call,
137
137
u64 data_version , size ;
138
138
u32 type , abort_code ;
139
139
u8 flags = 0 ;
140
- int ret ;
141
-
142
- if (vnode )
143
- write_seqlock (& vnode -> cb_lock );
144
140
145
141
if (xdr -> if_version != htonl (AFS_FSTATUS_VERSION )) {
146
142
pr_warn ("Unknown AFSFetchStatus version %u\n" , ntohl (xdr -> if_version ));
@@ -168,8 +164,7 @@ static int xdr_decode_AFSFetchStatus(struct afs_call *call,
168
164
case AFS_FTYPE_INVALID :
169
165
if (abort_code != 0 ) {
170
166
status -> abort_code = abort_code ;
171
- ret = 0 ;
172
- goto out ;
167
+ return 0 ;
173
168
}
174
169
/* Fall through */
175
170
default :
@@ -222,17 +217,35 @@ static int xdr_decode_AFSFetchStatus(struct afs_call *call,
222
217
flags );
223
218
}
224
219
225
- ret = 0 ;
226
-
227
- out :
228
- if (vnode )
229
- write_sequnlock (& vnode -> cb_lock );
230
- return ret ;
220
+ return 0 ;
231
221
232
222
bad :
233
223
xdr_dump_bad (* _bp );
234
- ret = afs_protocol_error (call , - EBADMSG );
235
- goto out ;
224
+ return afs_protocol_error (call , - EBADMSG );
225
+ }
226
+
227
+ /*
228
+ * Decode the file status. We need to lock the target vnode if we're going to
229
+ * update its status so that stat() sees the attributes update atomically.
230
+ */
231
+ static int afs_decode_status (struct afs_call * call ,
232
+ const __be32 * * _bp ,
233
+ struct afs_file_status * status ,
234
+ struct afs_vnode * vnode ,
235
+ const afs_dataversion_t * expected_version ,
236
+ struct afs_read * read_req )
237
+ {
238
+ int ret ;
239
+
240
+ if (!vnode )
241
+ return xdr_decode_AFSFetchStatus (call , _bp , status , vnode ,
242
+ expected_version , read_req );
243
+
244
+ write_seqlock (& vnode -> cb_lock );
245
+ ret = xdr_decode_AFSFetchStatus (call , _bp , status , vnode ,
246
+ expected_version , read_req );
247
+ write_sequnlock (& vnode -> cb_lock );
248
+ return ret ;
236
249
}
237
250
238
251
/*
@@ -374,8 +387,8 @@ static int afs_deliver_fs_fetch_status_vnode(struct afs_call *call)
374
387
375
388
/* unmarshall the reply once we've received all of it */
376
389
bp = call -> buffer ;
377
- if (xdr_decode_AFSFetchStatus (call , & bp , & vnode -> status , vnode ,
378
- & call -> expected_version , NULL ) < 0 )
390
+ if (afs_decode_status (call , & bp , & vnode -> status , vnode ,
391
+ & call -> expected_version , NULL ) < 0 )
379
392
return afs_protocol_error (call , - EBADMSG );
380
393
xdr_decode_AFSCallBack (call , vnode , & bp );
381
394
if (call -> reply [1 ])
@@ -555,8 +568,8 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call)
555
568
return ret ;
556
569
557
570
bp = call -> buffer ;
558
- if (xdr_decode_AFSFetchStatus (call , & bp , & vnode -> status , vnode ,
559
- & vnode -> status .data_version , req ) < 0 )
571
+ if (afs_decode_status (call , & bp , & vnode -> status , vnode ,
572
+ & vnode -> status .data_version , req ) < 0 )
560
573
return afs_protocol_error (call , - EBADMSG );
561
574
xdr_decode_AFSCallBack (call , vnode , & bp );
562
575
if (call -> reply [1 ])
@@ -708,9 +721,9 @@ static int afs_deliver_fs_create_vnode(struct afs_call *call)
708
721
/* unmarshall the reply once we've received all of it */
709
722
bp = call -> buffer ;
710
723
xdr_decode_AFSFid (& bp , call -> reply [1 ]);
711
- if (xdr_decode_AFSFetchStatus (call , & bp , call -> reply [2 ], NULL , NULL , NULL ) < 0 ||
712
- xdr_decode_AFSFetchStatus (call , & bp , & vnode -> status , vnode ,
713
- & call -> expected_version , NULL ) < 0 )
724
+ if (afs_decode_status (call , & bp , call -> reply [2 ], NULL , NULL , NULL ) < 0 ||
725
+ afs_decode_status (call , & bp , & vnode -> status , vnode ,
726
+ & call -> expected_version , NULL ) < 0 )
714
727
return afs_protocol_error (call , - EBADMSG );
715
728
xdr_decode_AFSCallBack_raw (& bp , call -> reply [3 ]);
716
729
/* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
@@ -814,8 +827,8 @@ static int afs_deliver_fs_remove(struct afs_call *call)
814
827
815
828
/* unmarshall the reply once we've received all of it */
816
829
bp = call -> buffer ;
817
- if (xdr_decode_AFSFetchStatus (call , & bp , & vnode -> status , vnode ,
818
- & call -> expected_version , NULL ) < 0 )
830
+ if (afs_decode_status (call , & bp , & vnode -> status , vnode ,
831
+ & call -> expected_version , NULL ) < 0 )
819
832
return afs_protocol_error (call , - EBADMSG );
820
833
/* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
821
834
@@ -904,9 +917,9 @@ static int afs_deliver_fs_link(struct afs_call *call)
904
917
905
918
/* unmarshall the reply once we've received all of it */
906
919
bp = call -> buffer ;
907
- if (xdr_decode_AFSFetchStatus (call , & bp , & vnode -> status , vnode , NULL , NULL ) < 0 ||
908
- xdr_decode_AFSFetchStatus (call , & bp , & dvnode -> status , dvnode ,
909
- & call -> expected_version , NULL ) < 0 )
920
+ if (afs_decode_status (call , & bp , & vnode -> status , vnode , NULL , NULL ) < 0 ||
921
+ afs_decode_status (call , & bp , & dvnode -> status , dvnode ,
922
+ & call -> expected_version , NULL ) < 0 )
910
923
return afs_protocol_error (call , - EBADMSG );
911
924
/* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
912
925
@@ -991,9 +1004,9 @@ static int afs_deliver_fs_symlink(struct afs_call *call)
991
1004
/* unmarshall the reply once we've received all of it */
992
1005
bp = call -> buffer ;
993
1006
xdr_decode_AFSFid (& bp , call -> reply [1 ]);
994
- if (xdr_decode_AFSFetchStatus (call , & bp , call -> reply [2 ], NULL , NULL , NULL ) ||
995
- xdr_decode_AFSFetchStatus (call , & bp , & vnode -> status , vnode ,
996
- & call -> expected_version , NULL ) < 0 )
1007
+ if (afs_decode_status (call , & bp , call -> reply [2 ], NULL , NULL , NULL ) ||
1008
+ afs_decode_status (call , & bp , & vnode -> status , vnode ,
1009
+ & call -> expected_version , NULL ) < 0 )
997
1010
return afs_protocol_error (call , - EBADMSG );
998
1011
/* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
999
1012
@@ -1097,12 +1110,12 @@ static int afs_deliver_fs_rename(struct afs_call *call)
1097
1110
1098
1111
/* unmarshall the reply once we've received all of it */
1099
1112
bp = call -> buffer ;
1100
- if (xdr_decode_AFSFetchStatus (call , & bp , & orig_dvnode -> status , orig_dvnode ,
1101
- & call -> expected_version , NULL ) < 0 )
1113
+ if (afs_decode_status (call , & bp , & orig_dvnode -> status , orig_dvnode ,
1114
+ & call -> expected_version , NULL ) < 0 )
1102
1115
return afs_protocol_error (call , - EBADMSG );
1103
1116
if (new_dvnode != orig_dvnode &&
1104
- xdr_decode_AFSFetchStatus (call , & bp , & new_dvnode -> status , new_dvnode ,
1105
- & call -> expected_version_2 , NULL ) < 0 )
1117
+ afs_decode_status (call , & bp , & new_dvnode -> status , new_dvnode ,
1118
+ & call -> expected_version_2 , NULL ) < 0 )
1106
1119
return afs_protocol_error (call , - EBADMSG );
1107
1120
/* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
1108
1121
@@ -1206,8 +1219,8 @@ static int afs_deliver_fs_store_data(struct afs_call *call)
1206
1219
1207
1220
/* unmarshall the reply once we've received all of it */
1208
1221
bp = call -> buffer ;
1209
- if (xdr_decode_AFSFetchStatus (call , & bp , & vnode -> status , vnode ,
1210
- & call -> expected_version , NULL ) < 0 )
1222
+ if (afs_decode_status (call , & bp , & vnode -> status , vnode ,
1223
+ & call -> expected_version , NULL ) < 0 )
1211
1224
return afs_protocol_error (call , - EBADMSG );
1212
1225
/* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
1213
1226
@@ -1382,8 +1395,8 @@ static int afs_deliver_fs_store_status(struct afs_call *call)
1382
1395
1383
1396
/* unmarshall the reply once we've received all of it */
1384
1397
bp = call -> buffer ;
1385
- if (xdr_decode_AFSFetchStatus (call , & bp , & vnode -> status , vnode ,
1386
- & call -> expected_version , NULL ) < 0 )
1398
+ if (afs_decode_status (call , & bp , & vnode -> status , vnode ,
1399
+ & call -> expected_version , NULL ) < 0 )
1387
1400
return afs_protocol_error (call , - EBADMSG );
1388
1401
/* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
1389
1402
@@ -2084,8 +2097,8 @@ static int afs_deliver_fs_fetch_status(struct afs_call *call)
2084
2097
2085
2098
/* unmarshall the reply once we've received all of it */
2086
2099
bp = call -> buffer ;
2087
- xdr_decode_AFSFetchStatus (call , & bp , status , vnode ,
2088
- & call -> expected_version , NULL );
2100
+ afs_decode_status (call , & bp , status , vnode ,
2101
+ & call -> expected_version , NULL );
2089
2102
callback [call -> count ].version = ntohl (bp [0 ]);
2090
2103
callback [call -> count ].expiry = ntohl (bp [1 ]);
2091
2104
callback [call -> count ].type = ntohl (bp [2 ]);
@@ -2196,9 +2209,9 @@ static int afs_deliver_fs_inline_bulk_status(struct afs_call *call)
2196
2209
2197
2210
bp = call -> buffer ;
2198
2211
statuses = call -> reply [1 ];
2199
- if (xdr_decode_AFSFetchStatus (call , & bp , & statuses [call -> count ],
2200
- call -> count == 0 ? vnode : NULL ,
2201
- NULL , NULL ) < 0 )
2212
+ if (afs_decode_status (call , & bp , & statuses [call -> count ],
2213
+ call -> count == 0 ? vnode : NULL ,
2214
+ NULL , NULL ) < 0 )
2202
2215
return afs_protocol_error (call , - EBADMSG );
2203
2216
2204
2217
call -> count ++ ;
0 commit comments