aboutsummaryrefslogtreecommitdiffstats
path: root/fs/afs
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2019-05-09 10:16:10 -0400
committerDavid Howells <dhowells@redhat.com>2019-05-16 11:25:21 -0400
commita58823ac458968f9fb3dbf97ee2749a62be12807 (patch)
tree97a455815d4ff7da8b946704604fe63aa1836b14 /fs/afs
parent4571577f16c82f8db8133b228cdca5fd61042c77 (diff)
afs: Fix application of status and callback to be under same lock
When applying the status and callback in the response of an operation, apply them in the same critical section so that there's no race between checking the callback state and checking status-dependent state (such as the data version). Fix this by: (1) Allocating a joint {status,callback} record (afs_status_cb) before calling the RPC function for each vnode for which the RPC reply contains a status or a status plus a callback. A flag is set in the record to indicate if a callback was actually received. (2) These records are passed into the RPC functions to be filled in. The afs_decode_status() and yfs_decode_status() functions are removed and the cb_lock is no longer taken. (3) xdr_decode_AFSFetchStatus() and xdr_decode_YFSFetchStatus() no longer update the vnode. (4) xdr_decode_AFSCallBack() and xdr_decode_YFSCallBack() no longer update the vnode. (5) vnodes, expected data-version numbers and callback break counters (cb_break) no longer need to be passed to the reply delivery functions. Note that, for the moment, the file locking functions still need access to both the call and the vnode at the same time. (6) afs_vnode_commit_status() is now given the cb_break value and the expected data_version and the task of applying the status and the callback to the vnode are now done here. This is done under a single taking of vnode->cb_lock. (7) afs_pages_written_back() is now called by afs_store_data() rather than by the reply delivery function. afs_pages_written_back() has been moved to before the call point and is now given the first and last page numbers rather than a pointer to the call. (8) The indicator from YFS.RemoveFile2 as to whether the target file actually got removed (status.abort_code == VNOVNODE) rather than merely dropping a link is now checked in afs_unlink rather than in xdr_decode_YFSFetchStatus(). Supplementary fixes: (*) afs_cache_permit() now gets the caller_access mask from the afs_status_cb object rather than picking it out of the vnode's status record. afs_fetch_status() returns caller_access through its argument list for this purpose also. (*) afs_inode_init_from_status() now uses a write lock on cb_lock rather than a read lock and now sets the callback inside the same critical section. Fixes: c435ee34551e ("afs: Overhaul the callback handling") Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'fs/afs')
-rw-r--r--fs/afs/dir.c204
-rw-r--r--fs/afs/dir_silly.c31
-rw-r--r--fs/afs/file.c20
-rw-r--r--fs/afs/flock.c40
-rw-r--r--fs/afs/fsclient.c465
-rw-r--r--fs/afs/inode.c286
-rw-r--r--fs/afs/internal.h134
-rw-r--r--fs/afs/security.c7
-rw-r--r--fs/afs/super.c3
-rw-r--r--fs/afs/write.c98
-rw-r--r--fs/afs/xattr.c103
-rw-r--r--fs/afs/yfsclient.c534
12 files changed, 921 insertions, 1004 deletions
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index 0f14bcfe233d..f7344b045799 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -18,6 +18,7 @@
18#include <linux/sched.h> 18#include <linux/sched.h>
19#include <linux/task_io_accounting_ops.h> 19#include <linux/task_io_accounting_ops.h>
20#include "internal.h" 20#include "internal.h"
21#include "afs_fs.h"
21#include "xdr_fs.h" 22#include "xdr_fs.h"
22 23
23static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry, 24static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
@@ -739,8 +740,7 @@ no_inline_bulk_status:
739 afs_fs_fetch_status(&fc, 740 afs_fs_fetch_status(&fc,
740 afs_v2net(dvnode), 741 afs_v2net(dvnode),
741 cookie->fids, 742 cookie->fids,
742 &scb->status, 743 scb,
743 &scb->callback,
744 NULL); 744 NULL);
745 } 745 }
746 746
@@ -771,9 +771,7 @@ success:
771 continue; 771 continue;
772 772
773 ti = afs_iget(dir->i_sb, key, &cookie->fids[i], 773 ti = afs_iget(dir->i_sb, key, &cookie->fids[i],
774 &scb->status, 774 scb, cbi, dvnode);
775 &scb->callback,
776 cbi, dvnode);
777 if (i == 0) { 775 if (i == 0) {
778 inode = ti; 776 inode = ti;
779 } else { 777 } else {
@@ -1110,8 +1108,7 @@ void afs_d_release(struct dentry *dentry)
1110static void afs_vnode_new_inode(struct afs_fs_cursor *fc, 1108static void afs_vnode_new_inode(struct afs_fs_cursor *fc,
1111 struct dentry *new_dentry, 1109 struct dentry *new_dentry,
1112 struct afs_fid *newfid, 1110 struct afs_fid *newfid,
1113 struct afs_file_status *newstatus, 1111 struct afs_status_cb *new_scb)
1114 struct afs_callback *newcb)
1115{ 1112{
1116 struct afs_vnode *vnode; 1113 struct afs_vnode *vnode;
1117 struct inode *inode; 1114 struct inode *inode;
@@ -1120,7 +1117,7 @@ static void afs_vnode_new_inode(struct afs_fs_cursor *fc,
1120 return; 1117 return;
1121 1118
1122 inode = afs_iget(fc->vnode->vfs_inode.i_sb, fc->key, 1119 inode = afs_iget(fc->vnode->vfs_inode.i_sb, fc->key,
1123 newfid, newstatus, newcb, fc->cbi, fc->vnode); 1120 newfid, new_scb, fc->cbi, fc->vnode);
1124 if (IS_ERR(inode)) { 1121 if (IS_ERR(inode)) {
1125 /* ENOMEM or EINTR at a really inconvenient time - just abandon 1122 /* ENOMEM or EINTR at a really inconvenient time - just abandon
1126 * the new directory on the server. 1123 * the new directory on the server.
@@ -1131,7 +1128,8 @@ static void afs_vnode_new_inode(struct afs_fs_cursor *fc,
1131 1128
1132 vnode = AFS_FS_I(inode); 1129 vnode = AFS_FS_I(inode);
1133 set_bit(AFS_VNODE_NEW_CONTENT, &vnode->flags); 1130 set_bit(AFS_VNODE_NEW_CONTENT, &vnode->flags);
1134 afs_vnode_commit_status(fc, vnode, 0); 1131 if (fc->ac.error == 0)
1132 afs_cache_permit(vnode, fc->key, vnode->cb_break, new_scb);
1135 d_instantiate(new_dentry, inode); 1133 d_instantiate(new_dentry, inode);
1136} 1134}
1137 1135
@@ -1140,13 +1138,11 @@ static void afs_vnode_new_inode(struct afs_fs_cursor *fc,
1140 */ 1138 */
1141static int afs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) 1139static int afs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
1142{ 1140{
1143 struct afs_file_status newstatus; 1141 struct afs_status_cb *scb;
1144 struct afs_fs_cursor fc; 1142 struct afs_fs_cursor fc;
1145 struct afs_callback newcb;
1146 struct afs_vnode *dvnode = AFS_FS_I(dir); 1143 struct afs_vnode *dvnode = AFS_FS_I(dir);
1147 struct afs_fid newfid; 1144 struct afs_fid newfid;
1148 struct key *key; 1145 struct key *key;
1149 u64 data_version = dvnode->status.data_version;
1150 int ret; 1146 int ret;
1151 1147
1152 mode |= S_IFDIR; 1148 mode |= S_IFDIR;
@@ -1154,23 +1150,31 @@ static int afs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
1154 _enter("{%llx:%llu},{%pd},%ho", 1150 _enter("{%llx:%llu},{%pd},%ho",
1155 dvnode->fid.vid, dvnode->fid.vnode, dentry, mode); 1151 dvnode->fid.vid, dvnode->fid.vnode, dentry, mode);
1156 1152
1153 ret = -ENOMEM;
1154 scb = kcalloc(2, sizeof(struct afs_status_cb), GFP_KERNEL);
1155 if (!scb)
1156 goto error;
1157
1157 key = afs_request_key(dvnode->volume->cell); 1158 key = afs_request_key(dvnode->volume->cell);
1158 if (IS_ERR(key)) { 1159 if (IS_ERR(key)) {
1159 ret = PTR_ERR(key); 1160 ret = PTR_ERR(key);
1160 goto error; 1161 goto error_scb;
1161 } 1162 }
1162 1163
1163 ret = -ERESTARTSYS; 1164 ret = -ERESTARTSYS;
1164 if (afs_begin_vnode_operation(&fc, dvnode, key, true)) { 1165 if (afs_begin_vnode_operation(&fc, dvnode, key, true)) {
1166 afs_dataversion_t data_version = dvnode->status.data_version + 1;
1167
1165 while (afs_select_fileserver(&fc)) { 1168 while (afs_select_fileserver(&fc)) {
1166 fc.cb_break = afs_calc_vnode_cb_break(dvnode); 1169 fc.cb_break = afs_calc_vnode_cb_break(dvnode);
1167 afs_fs_create(&fc, dentry->d_name.name, mode, data_version, 1170 afs_fs_create(&fc, dentry->d_name.name, mode,
1168 &newfid, &newstatus, &newcb); 1171 &scb[0], &newfid, &scb[1]);
1169 } 1172 }
1170 1173
1171 afs_check_for_remote_deletion(&fc, fc.vnode); 1174 afs_check_for_remote_deletion(&fc, dvnode);
1172 afs_vnode_commit_status(&fc, dvnode, fc.cb_break); 1175 afs_vnode_commit_status(&fc, dvnode, fc.cb_break,
1173 afs_vnode_new_inode(&fc, dentry, &newfid, &newstatus, &newcb); 1176 &data_version, &scb[0]);
1177 afs_vnode_new_inode(&fc, dentry, &newfid, &scb[1]);
1174 ret = afs_end_vnode_operation(&fc); 1178 ret = afs_end_vnode_operation(&fc);
1175 if (ret < 0) 1179 if (ret < 0)
1176 goto error_key; 1180 goto error_key;
@@ -1184,11 +1188,14 @@ static int afs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
1184 afs_edit_dir_for_create); 1188 afs_edit_dir_for_create);
1185 1189
1186 key_put(key); 1190 key_put(key);
1191 kfree(scb);
1187 _leave(" = 0"); 1192 _leave(" = 0");
1188 return 0; 1193 return 0;
1189 1194
1190error_key: 1195error_key:
1191 key_put(key); 1196 key_put(key);
1197error_scb:
1198 kfree(scb);
1192error: 1199error:
1193 d_drop(dentry); 1200 d_drop(dentry);
1194 _leave(" = %d", ret); 1201 _leave(" = %d", ret);
@@ -1215,15 +1222,19 @@ static void afs_dir_remove_subdir(struct dentry *dentry)
1215 */ 1222 */
1216static int afs_rmdir(struct inode *dir, struct dentry *dentry) 1223static int afs_rmdir(struct inode *dir, struct dentry *dentry)
1217{ 1224{
1225 struct afs_status_cb *scb;
1218 struct afs_fs_cursor fc; 1226 struct afs_fs_cursor fc;
1219 struct afs_vnode *dvnode = AFS_FS_I(dir), *vnode = NULL; 1227 struct afs_vnode *dvnode = AFS_FS_I(dir), *vnode = NULL;
1220 struct key *key; 1228 struct key *key;
1221 u64 data_version = dvnode->status.data_version;
1222 int ret; 1229 int ret;
1223 1230
1224 _enter("{%llx:%llu},{%pd}", 1231 _enter("{%llx:%llu},{%pd}",
1225 dvnode->fid.vid, dvnode->fid.vnode, dentry); 1232 dvnode->fid.vid, dvnode->fid.vnode, dentry);
1226 1233
1234 scb = kzalloc(sizeof(struct afs_status_cb), GFP_KERNEL);
1235 if (!scb)
1236 return -ENOMEM;
1237
1227 key = afs_request_key(dvnode->volume->cell); 1238 key = afs_request_key(dvnode->volume->cell);
1228 if (IS_ERR(key)) { 1239 if (IS_ERR(key)) {
1229 ret = PTR_ERR(key); 1240 ret = PTR_ERR(key);
@@ -1246,13 +1257,15 @@ static int afs_rmdir(struct inode *dir, struct dentry *dentry)
1246 1257
1247 ret = -ERESTARTSYS; 1258 ret = -ERESTARTSYS;
1248 if (afs_begin_vnode_operation(&fc, dvnode, key, true)) { 1259 if (afs_begin_vnode_operation(&fc, dvnode, key, true)) {
1260 afs_dataversion_t data_version = dvnode->status.data_version + 1;
1261
1249 while (afs_select_fileserver(&fc)) { 1262 while (afs_select_fileserver(&fc)) {
1250 fc.cb_break = afs_calc_vnode_cb_break(dvnode); 1263 fc.cb_break = afs_calc_vnode_cb_break(dvnode);
1251 afs_fs_remove(&fc, vnode, dentry->d_name.name, true, 1264 afs_fs_remove(&fc, vnode, dentry->d_name.name, true, scb);
1252 data_version);
1253 } 1265 }
1254 1266
1255 afs_vnode_commit_status(&fc, dvnode, fc.cb_break); 1267 afs_vnode_commit_status(&fc, dvnode, fc.cb_break,
1268 &data_version, scb);
1256 ret = afs_end_vnode_operation(&fc); 1269 ret = afs_end_vnode_operation(&fc);
1257 if (ret == 0) { 1270 if (ret == 0) {
1258 afs_dir_remove_subdir(dentry); 1271 afs_dir_remove_subdir(dentry);
@@ -1267,6 +1280,7 @@ static int afs_rmdir(struct inode *dir, struct dentry *dentry)
1267error_key: 1280error_key:
1268 key_put(key); 1281 key_put(key);
1269error: 1282error:
1283 kfree(scb);
1270 return ret; 1284 return ret;
1271} 1285}
1272 1286
@@ -1326,11 +1340,11 @@ int afs_dir_remove_link(struct dentry *dentry, struct key *key,
1326static int afs_unlink(struct inode *dir, struct dentry *dentry) 1340static int afs_unlink(struct inode *dir, struct dentry *dentry)
1327{ 1341{
1328 struct afs_fs_cursor fc; 1342 struct afs_fs_cursor fc;
1343 struct afs_status_cb *scb;
1329 struct afs_vnode *dvnode = AFS_FS_I(dir), *vnode = NULL; 1344 struct afs_vnode *dvnode = AFS_FS_I(dir), *vnode = NULL;
1330 struct key *key; 1345 struct key *key;
1331 unsigned long d_version = (unsigned long)dentry->d_fsdata; 1346 unsigned long d_version = (unsigned long)dentry->d_fsdata;
1332 bool need_rehash = false; 1347 bool need_rehash = false;
1333 u64 data_version = dvnode->status.data_version;
1334 int ret; 1348 int ret;
1335 1349
1336 _enter("{%llx:%llu},{%pd}", 1350 _enter("{%llx:%llu},{%pd}",
@@ -1339,10 +1353,15 @@ static int afs_unlink(struct inode *dir, struct dentry *dentry)
1339 if (dentry->d_name.len >= AFSNAMEMAX) 1353 if (dentry->d_name.len >= AFSNAMEMAX)
1340 return -ENAMETOOLONG; 1354 return -ENAMETOOLONG;
1341 1355
1356 ret = -ENOMEM;
1357 scb = kcalloc(2, sizeof(struct afs_status_cb), GFP_KERNEL);
1358 if (!scb)
1359 goto error;
1360
1342 key = afs_request_key(dvnode->volume->cell); 1361 key = afs_request_key(dvnode->volume->cell);
1343 if (IS_ERR(key)) { 1362 if (IS_ERR(key)) {
1344 ret = PTR_ERR(key); 1363 ret = PTR_ERR(key);
1345 goto error; 1364 goto error_scb;
1346 } 1365 }
1347 1366
1348 /* Try to make sure we have a callback promise on the victim. */ 1367 /* Try to make sure we have a callback promise on the victim. */
@@ -1370,24 +1389,32 @@ static int afs_unlink(struct inode *dir, struct dentry *dentry)
1370 1389
1371 ret = -ERESTARTSYS; 1390 ret = -ERESTARTSYS;
1372 if (afs_begin_vnode_operation(&fc, dvnode, key, true)) { 1391 if (afs_begin_vnode_operation(&fc, dvnode, key, true)) {
1392 afs_dataversion_t data_version = dvnode->status.data_version + 1;
1393
1373 while (afs_select_fileserver(&fc)) { 1394 while (afs_select_fileserver(&fc)) {
1374 fc.cb_break = afs_calc_vnode_cb_break(dvnode); 1395 fc.cb_break = afs_calc_vnode_cb_break(dvnode);
1375 1396
1376 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc.cbi->server->flags) && 1397 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc.cbi->server->flags) &&
1377 !test_bit(AFS_SERVER_FL_NO_RM2, &fc.cbi->server->flags)) { 1398 !test_bit(AFS_SERVER_FL_NO_RM2, &fc.cbi->server->flags)) {
1378 yfs_fs_remove_file2(&fc, vnode, dentry->d_name.name, 1399 yfs_fs_remove_file2(&fc, vnode, dentry->d_name.name,
1379 data_version); 1400 &scb[0], &scb[1]);
1401 if (fc.ac.error == 0 &&
1402 scb[1].status.abort_code == VNOVNODE) {
1403 set_bit(AFS_VNODE_DELETED, &vnode->flags);
1404 afs_break_callback(vnode);
1405 }
1406
1380 if (fc.ac.error != -ECONNABORTED || 1407 if (fc.ac.error != -ECONNABORTED ||
1381 fc.ac.abort_code != RXGEN_OPCODE) 1408 fc.ac.abort_code != RXGEN_OPCODE)
1382 continue; 1409 continue;
1383 set_bit(AFS_SERVER_FL_NO_RM2, &fc.cbi->server->flags); 1410 set_bit(AFS_SERVER_FL_NO_RM2, &fc.cbi->server->flags);
1384 } 1411 }
1385 1412
1386 afs_fs_remove(&fc, vnode, dentry->d_name.name, false, 1413 afs_fs_remove(&fc, vnode, dentry->d_name.name, false, &scb[0]);
1387 data_version);
1388 } 1414 }
1389 1415
1390 afs_vnode_commit_status(&fc, dvnode, fc.cb_break); 1416 afs_vnode_commit_status(&fc, dvnode, fc.cb_break,
1417 &data_version, &scb[0]);
1391 ret = afs_end_vnode_operation(&fc); 1418 ret = afs_end_vnode_operation(&fc);
1392 if (ret == 0) 1419 if (ret == 0)
1393 ret = afs_dir_remove_link( 1420 ret = afs_dir_remove_link(
@@ -1404,6 +1431,8 @@ static int afs_unlink(struct inode *dir, struct dentry *dentry)
1404 1431
1405error_key: 1432error_key:
1406 key_put(key); 1433 key_put(key);
1434error_scb:
1435 kfree(scb);
1407error: 1436error:
1408 _leave(" = %d", ret); 1437 _leave(" = %d", ret);
1409 return ret; 1438 return ret;
@@ -1416,12 +1445,10 @@ static int afs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
1416 bool excl) 1445 bool excl)
1417{ 1446{
1418 struct afs_fs_cursor fc; 1447 struct afs_fs_cursor fc;
1419 struct afs_file_status newstatus; 1448 struct afs_status_cb *scb;
1420 struct afs_callback newcb;
1421 struct afs_vnode *dvnode = AFS_FS_I(dir); 1449 struct afs_vnode *dvnode = AFS_FS_I(dir);
1422 struct afs_fid newfid; 1450 struct afs_fid newfid;
1423 struct key *key; 1451 struct key *key;
1424 u64 data_version = dvnode->status.data_version;
1425 int ret; 1452 int ret;
1426 1453
1427 mode |= S_IFREG; 1454 mode |= S_IFREG;
@@ -1439,17 +1466,25 @@ static int afs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
1439 goto error; 1466 goto error;
1440 } 1467 }
1441 1468
1469 ret = -ENOMEM;
1470 scb = kcalloc(2, sizeof(struct afs_status_cb), GFP_KERNEL);
1471 if (!scb)
1472 goto error_scb;
1473
1442 ret = -ERESTARTSYS; 1474 ret = -ERESTARTSYS;
1443 if (afs_begin_vnode_operation(&fc, dvnode, key, true)) { 1475 if (afs_begin_vnode_operation(&fc, dvnode, key, true)) {
1476 afs_dataversion_t data_version = dvnode->status.data_version + 1;
1477
1444 while (afs_select_fileserver(&fc)) { 1478 while (afs_select_fileserver(&fc)) {
1445 fc.cb_break = afs_calc_vnode_cb_break(dvnode); 1479 fc.cb_break = afs_calc_vnode_cb_break(dvnode);
1446 afs_fs_create(&fc, dentry->d_name.name, mode, data_version, 1480 afs_fs_create(&fc, dentry->d_name.name, mode,
1447 &newfid, &newstatus, &newcb); 1481 &scb[0], &newfid, &scb[1]);
1448 } 1482 }
1449 1483
1450 afs_check_for_remote_deletion(&fc, fc.vnode); 1484 afs_check_for_remote_deletion(&fc, dvnode);
1451 afs_vnode_commit_status(&fc, dvnode, fc.cb_break); 1485 afs_vnode_commit_status(&fc, dvnode, fc.cb_break,
1452 afs_vnode_new_inode(&fc, dentry, &newfid, &newstatus, &newcb); 1486 &data_version, &scb[0]);
1487 afs_vnode_new_inode(&fc, dentry, &newfid, &scb[1]);
1453 ret = afs_end_vnode_operation(&fc); 1488 ret = afs_end_vnode_operation(&fc);
1454 if (ret < 0) 1489 if (ret < 0)
1455 goto error_key; 1490 goto error_key;
@@ -1461,10 +1496,13 @@ static int afs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
1461 afs_edit_dir_add(dvnode, &dentry->d_name, &newfid, 1496 afs_edit_dir_add(dvnode, &dentry->d_name, &newfid,
1462 afs_edit_dir_for_create); 1497 afs_edit_dir_for_create);
1463 1498
1499 kfree(scb);
1464 key_put(key); 1500 key_put(key);
1465 _leave(" = 0"); 1501 _leave(" = 0");
1466 return 0; 1502 return 0;
1467 1503
1504error_scb:
1505 kfree(scb);
1468error_key: 1506error_key:
1469 key_put(key); 1507 key_put(key);
1470error: 1508error:
@@ -1480,15 +1518,12 @@ static int afs_link(struct dentry *from, struct inode *dir,
1480 struct dentry *dentry) 1518 struct dentry *dentry)
1481{ 1519{
1482 struct afs_fs_cursor fc; 1520 struct afs_fs_cursor fc;
1483 struct afs_vnode *dvnode, *vnode; 1521 struct afs_status_cb *scb;
1522 struct afs_vnode *dvnode = AFS_FS_I(dir);
1523 struct afs_vnode *vnode = AFS_FS_I(d_inode(from));
1484 struct key *key; 1524 struct key *key;
1485 u64 data_version;
1486 int ret; 1525 int ret;
1487 1526
1488 vnode = AFS_FS_I(d_inode(from));
1489 dvnode = AFS_FS_I(dir);
1490 data_version = dvnode->status.data_version;
1491
1492 _enter("{%llx:%llu},{%llx:%llu},{%pd}", 1527 _enter("{%llx:%llu},{%llx:%llu},{%pd}",
1493 vnode->fid.vid, vnode->fid.vnode, 1528 vnode->fid.vid, vnode->fid.vnode,
1494 dvnode->fid.vid, dvnode->fid.vnode, 1529 dvnode->fid.vid, dvnode->fid.vnode,
@@ -1498,14 +1533,21 @@ static int afs_link(struct dentry *from, struct inode *dir,
1498 if (dentry->d_name.len >= AFSNAMEMAX) 1533 if (dentry->d_name.len >= AFSNAMEMAX)
1499 goto error; 1534 goto error;
1500 1535
1536 ret = -ENOMEM;
1537 scb = kcalloc(2, sizeof(struct afs_status_cb), GFP_KERNEL);
1538 if (!scb)
1539 goto error;
1540
1501 key = afs_request_key(dvnode->volume->cell); 1541 key = afs_request_key(dvnode->volume->cell);
1502 if (IS_ERR(key)) { 1542 if (IS_ERR(key)) {
1503 ret = PTR_ERR(key); 1543 ret = PTR_ERR(key);
1504 goto error; 1544 goto error_scb;
1505 } 1545 }
1506 1546
1507 ret = -ERESTARTSYS; 1547 ret = -ERESTARTSYS;
1508 if (afs_begin_vnode_operation(&fc, dvnode, key, true)) { 1548 if (afs_begin_vnode_operation(&fc, dvnode, key, true)) {
1549 afs_dataversion_t data_version = dvnode->status.data_version + 1;
1550
1509 if (mutex_lock_interruptible_nested(&vnode->io_lock, 1) < 0) { 1551 if (mutex_lock_interruptible_nested(&vnode->io_lock, 1) < 0) {
1510 afs_end_vnode_operation(&fc); 1552 afs_end_vnode_operation(&fc);
1511 goto error_key; 1553 goto error_key;
@@ -1514,11 +1556,14 @@ static int afs_link(struct dentry *from, struct inode *dir,
1514 while (afs_select_fileserver(&fc)) { 1556 while (afs_select_fileserver(&fc)) {
1515 fc.cb_break = afs_calc_vnode_cb_break(dvnode); 1557 fc.cb_break = afs_calc_vnode_cb_break(dvnode);
1516 fc.cb_break_2 = afs_calc_vnode_cb_break(vnode); 1558 fc.cb_break_2 = afs_calc_vnode_cb_break(vnode);
1517 afs_fs_link(&fc, vnode, dentry->d_name.name, data_version); 1559 afs_fs_link(&fc, vnode, dentry->d_name.name,
1560 &scb[0], &scb[1]);
1518 } 1561 }
1519 1562
1520 afs_vnode_commit_status(&fc, dvnode, fc.cb_break); 1563 afs_vnode_commit_status(&fc, dvnode, fc.cb_break,
1521 afs_vnode_commit_status(&fc, vnode, fc.cb_break_2); 1564 &data_version, &scb[0]);
1565 afs_vnode_commit_status(&fc, vnode, fc.cb_break_2,
1566 NULL, &scb[1]);
1522 ihold(&vnode->vfs_inode); 1567 ihold(&vnode->vfs_inode);
1523 d_instantiate(dentry, &vnode->vfs_inode); 1568 d_instantiate(dentry, &vnode->vfs_inode);
1524 1569
@@ -1535,11 +1580,14 @@ static int afs_link(struct dentry *from, struct inode *dir,
1535 afs_edit_dir_for_link); 1580 afs_edit_dir_for_link);
1536 1581
1537 key_put(key); 1582 key_put(key);
1583 kfree(scb);
1538 _leave(" = 0"); 1584 _leave(" = 0");
1539 return 0; 1585 return 0;
1540 1586
1541error_key: 1587error_key:
1542 key_put(key); 1588 key_put(key);
1589error_scb:
1590 kfree(scb);
1543error: 1591error:
1544 d_drop(dentry); 1592 d_drop(dentry);
1545 _leave(" = %d", ret); 1593 _leave(" = %d", ret);
@@ -1553,11 +1601,10 @@ static int afs_symlink(struct inode *dir, struct dentry *dentry,
1553 const char *content) 1601 const char *content)
1554{ 1602{
1555 struct afs_fs_cursor fc; 1603 struct afs_fs_cursor fc;
1556 struct afs_file_status newstatus; 1604 struct afs_status_cb *scb;
1557 struct afs_vnode *dvnode = AFS_FS_I(dir); 1605 struct afs_vnode *dvnode = AFS_FS_I(dir);
1558 struct afs_fid newfid; 1606 struct afs_fid newfid;
1559 struct key *key; 1607 struct key *key;
1560 u64 data_version = dvnode->status.data_version;
1561 int ret; 1608 int ret;
1562 1609
1563 _enter("{%llx:%llu},{%pd},%s", 1610 _enter("{%llx:%llu},{%pd},%s",
@@ -1572,24 +1619,31 @@ static int afs_symlink(struct inode *dir, struct dentry *dentry,
1572 if (strlen(content) >= AFSPATHMAX) 1619 if (strlen(content) >= AFSPATHMAX)
1573 goto error; 1620 goto error;
1574 1621
1622 ret = -ENOMEM;
1623 scb = kcalloc(2, sizeof(struct afs_status_cb), GFP_KERNEL);
1624 if (!scb)
1625 goto error;
1626
1575 key = afs_request_key(dvnode->volume->cell); 1627 key = afs_request_key(dvnode->volume->cell);
1576 if (IS_ERR(key)) { 1628 if (IS_ERR(key)) {
1577 ret = PTR_ERR(key); 1629 ret = PTR_ERR(key);
1578 goto error; 1630 goto error_scb;
1579 } 1631 }
1580 1632
1581 ret = -ERESTARTSYS; 1633 ret = -ERESTARTSYS;
1582 if (afs_begin_vnode_operation(&fc, dvnode, key, true)) { 1634 if (afs_begin_vnode_operation(&fc, dvnode, key, true)) {
1635 afs_dataversion_t data_version = dvnode->status.data_version + 1;
1636
1583 while (afs_select_fileserver(&fc)) { 1637 while (afs_select_fileserver(&fc)) {
1584 fc.cb_break = afs_calc_vnode_cb_break(dvnode); 1638 fc.cb_break = afs_calc_vnode_cb_break(dvnode);
1585 afs_fs_symlink(&fc, dentry->d_name.name, 1639 afs_fs_symlink(&fc, dentry->d_name.name, content,
1586 content, data_version, 1640 &scb[0], &newfid, &scb[1]);
1587 &newfid, &newstatus);
1588 } 1641 }
1589 1642
1590 afs_check_for_remote_deletion(&fc, fc.vnode); 1643 afs_check_for_remote_deletion(&fc, dvnode);
1591 afs_vnode_commit_status(&fc, dvnode, fc.cb_break); 1644 afs_vnode_commit_status(&fc, dvnode, fc.cb_break,
1592 afs_vnode_new_inode(&fc, dentry, &newfid, &newstatus, NULL); 1645 &data_version, &scb[0]);
1646 afs_vnode_new_inode(&fc, dentry, &newfid, &scb[1]);
1593 ret = afs_end_vnode_operation(&fc); 1647 ret = afs_end_vnode_operation(&fc);
1594 if (ret < 0) 1648 if (ret < 0)
1595 goto error_key; 1649 goto error_key;
@@ -1602,11 +1656,14 @@ static int afs_symlink(struct inode *dir, struct dentry *dentry,
1602 afs_edit_dir_for_symlink); 1656 afs_edit_dir_for_symlink);
1603 1657
1604 key_put(key); 1658 key_put(key);
1659 kfree(scb);
1605 _leave(" = 0"); 1660 _leave(" = 0");
1606 return 0; 1661 return 0;
1607 1662
1608error_key: 1663error_key:
1609 key_put(key); 1664 key_put(key);
1665error_scb:
1666 kfree(scb);
1610error: 1667error:
1611 d_drop(dentry); 1668 d_drop(dentry);
1612 _leave(" = %d", ret); 1669 _leave(" = %d", ret);
@@ -1621,11 +1678,11 @@ static int afs_rename(struct inode *old_dir, struct dentry *old_dentry,
1621 unsigned int flags) 1678 unsigned int flags)
1622{ 1679{
1623 struct afs_fs_cursor fc; 1680 struct afs_fs_cursor fc;
1681 struct afs_status_cb *scb;
1624 struct afs_vnode *orig_dvnode, *new_dvnode, *vnode; 1682 struct afs_vnode *orig_dvnode, *new_dvnode, *vnode;
1625 struct dentry *tmp = NULL, *rehash = NULL; 1683 struct dentry *tmp = NULL, *rehash = NULL;
1626 struct inode *new_inode; 1684 struct inode *new_inode;
1627 struct key *key; 1685 struct key *key;
1628 u64 orig_data_version, new_data_version;
1629 bool new_negative = d_is_negative(new_dentry); 1686 bool new_negative = d_is_negative(new_dentry);
1630 int ret; 1687 int ret;
1631 1688
@@ -1639,8 +1696,6 @@ static int afs_rename(struct inode *old_dir, struct dentry *old_dentry,
1639 vnode = AFS_FS_I(d_inode(old_dentry)); 1696 vnode = AFS_FS_I(d_inode(old_dentry));
1640 orig_dvnode = AFS_FS_I(old_dir); 1697 orig_dvnode = AFS_FS_I(old_dir);
1641 new_dvnode = AFS_FS_I(new_dir); 1698 new_dvnode = AFS_FS_I(new_dir);
1642 orig_data_version = orig_dvnode->status.data_version;
1643 new_data_version = new_dvnode->status.data_version;
1644 1699
1645 _enter("{%llx:%llu},{%llx:%llu},{%llx:%llu},{%pd}", 1700 _enter("{%llx:%llu},{%llx:%llu},{%llx:%llu},{%pd}",
1646 orig_dvnode->fid.vid, orig_dvnode->fid.vnode, 1701 orig_dvnode->fid.vid, orig_dvnode->fid.vnode,
@@ -1648,10 +1703,15 @@ static int afs_rename(struct inode *old_dir, struct dentry *old_dentry,
1648 new_dvnode->fid.vid, new_dvnode->fid.vnode, 1703 new_dvnode->fid.vid, new_dvnode->fid.vnode,
1649 new_dentry); 1704 new_dentry);
1650 1705
1706 ret = -ENOMEM;
1707 scb = kcalloc(2, sizeof(struct afs_status_cb), GFP_KERNEL);
1708 if (!scb)
1709 goto error;
1710
1651 key = afs_request_key(orig_dvnode->volume->cell); 1711 key = afs_request_key(orig_dvnode->volume->cell);
1652 if (IS_ERR(key)) { 1712 if (IS_ERR(key)) {
1653 ret = PTR_ERR(key); 1713 ret = PTR_ERR(key);
1654 goto error; 1714 goto error_scb;
1655 } 1715 }
1656 1716
1657 /* For non-directories, check whether the target is busy and if so, 1717 /* For non-directories, check whether the target is busy and if so,
@@ -1685,31 +1745,43 @@ static int afs_rename(struct inode *old_dir, struct dentry *old_dentry,
1685 new_dentry = tmp; 1745 new_dentry = tmp;
1686 rehash = NULL; 1746 rehash = NULL;
1687 new_negative = true; 1747 new_negative = true;
1688 orig_data_version = orig_dvnode->status.data_version;
1689 new_data_version = new_dvnode->status.data_version;
1690 } 1748 }
1691 } 1749 }
1692 1750
1693 ret = -ERESTARTSYS; 1751 ret = -ERESTARTSYS;
1694 if (afs_begin_vnode_operation(&fc, orig_dvnode, key, true)) { 1752 if (afs_begin_vnode_operation(&fc, orig_dvnode, key, true)) {
1753 afs_dataversion_t orig_data_version;
1754 afs_dataversion_t new_data_version;
1755 struct afs_status_cb *new_scb = &scb[1];
1756
1757 orig_data_version = orig_dvnode->status.data_version + 1;
1758
1695 if (orig_dvnode != new_dvnode) { 1759 if (orig_dvnode != new_dvnode) {
1696 if (mutex_lock_interruptible_nested(&new_dvnode->io_lock, 1) < 0) { 1760 if (mutex_lock_interruptible_nested(&new_dvnode->io_lock, 1) < 0) {
1697 afs_end_vnode_operation(&fc); 1761 afs_end_vnode_operation(&fc);
1698 goto error_rehash; 1762 goto error_rehash;
1699 } 1763 }
1764 new_data_version = new_dvnode->status.data_version;
1765 } else {
1766 new_data_version = orig_data_version;
1767 new_scb = &scb[0];
1700 } 1768 }
1769
1701 while (afs_select_fileserver(&fc)) { 1770 while (afs_select_fileserver(&fc)) {
1702 fc.cb_break = afs_calc_vnode_cb_break(orig_dvnode); 1771 fc.cb_break = afs_calc_vnode_cb_break(orig_dvnode);
1703 fc.cb_break_2 = afs_calc_vnode_cb_break(new_dvnode); 1772 fc.cb_break_2 = afs_calc_vnode_cb_break(new_dvnode);
1704 afs_fs_rename(&fc, old_dentry->d_name.name, 1773 afs_fs_rename(&fc, old_dentry->d_name.name,
1705 new_dvnode, new_dentry->d_name.name, 1774 new_dvnode, new_dentry->d_name.name,
1706 orig_data_version, new_data_version); 1775 &scb[0], new_scb);
1707 } 1776 }
1708 1777
1709 afs_vnode_commit_status(&fc, orig_dvnode, fc.cb_break); 1778 afs_vnode_commit_status(&fc, orig_dvnode, fc.cb_break,
1710 afs_vnode_commit_status(&fc, new_dvnode, fc.cb_break_2); 1779 &orig_data_version, &scb[0]);
1711 if (orig_dvnode != new_dvnode) 1780 if (new_dvnode != orig_dvnode) {
1781 afs_vnode_commit_status(&fc, new_dvnode, fc.cb_break_2,
1782 &new_data_version, &scb[1]);
1712 mutex_unlock(&new_dvnode->io_lock); 1783 mutex_unlock(&new_dvnode->io_lock);
1784 }
1713 ret = afs_end_vnode_operation(&fc); 1785 ret = afs_end_vnode_operation(&fc);
1714 if (ret < 0) 1786 if (ret < 0)
1715 goto error_rehash; 1787 goto error_rehash;
@@ -1749,6 +1821,8 @@ error_tmp:
1749 if (tmp) 1821 if (tmp)
1750 dput(tmp); 1822 dput(tmp);
1751 key_put(key); 1823 key_put(key);
1824error_scb:
1825 kfree(scb);
1752error: 1826error:
1753 _leave(" = %d", ret); 1827 _leave(" = %d", ret);
1754 return ret; 1828 return ret;
diff --git a/fs/afs/dir_silly.c b/fs/afs/dir_silly.c
index fbc2d301ffe8..28f4aa015229 100644
--- a/fs/afs/dir_silly.c
+++ b/fs/afs/dir_silly.c
@@ -24,21 +24,28 @@ static int afs_do_silly_rename(struct afs_vnode *dvnode, struct afs_vnode *vnode
24 struct key *key) 24 struct key *key)
25{ 25{
26 struct afs_fs_cursor fc; 26 struct afs_fs_cursor fc;
27 u64 dir_data_version = dvnode->status.data_version; 27 struct afs_status_cb *scb;
28 int ret = -ERESTARTSYS; 28 int ret = -ERESTARTSYS;
29 29
30 _enter("%pd,%pd", old, new); 30 _enter("%pd,%pd", old, new);
31 31
32 scb = kzalloc(sizeof(struct afs_status_cb), GFP_KERNEL);
33 if (!scb)
34 return -ENOMEM;
35
32 trace_afs_silly_rename(vnode, false); 36 trace_afs_silly_rename(vnode, false);
33 if (afs_begin_vnode_operation(&fc, dvnode, key, true)) { 37 if (afs_begin_vnode_operation(&fc, dvnode, key, true)) {
38 afs_dataversion_t dir_data_version = dvnode->status.data_version + 1;
39
34 while (afs_select_fileserver(&fc)) { 40 while (afs_select_fileserver(&fc)) {
35 fc.cb_break = afs_calc_vnode_cb_break(dvnode); 41 fc.cb_break = afs_calc_vnode_cb_break(dvnode);
36 afs_fs_rename(&fc, old->d_name.name, 42 afs_fs_rename(&fc, old->d_name.name,
37 dvnode, new->d_name.name, 43 dvnode, new->d_name.name,
38 dir_data_version, dir_data_version); 44 scb, scb);
39 } 45 }
40 46
41 afs_vnode_commit_status(&fc, dvnode, fc.cb_break); 47 afs_vnode_commit_status(&fc, dvnode, fc.cb_break,
48 &dir_data_version, scb);
42 ret = afs_end_vnode_operation(&fc); 49 ret = afs_end_vnode_operation(&fc);
43 } 50 }
44 51
@@ -64,6 +71,7 @@ static int afs_do_silly_rename(struct afs_vnode *dvnode, struct afs_vnode *vnode
64 fsnotify_nameremove(old, 0); 71 fsnotify_nameremove(old, 0);
65 } 72 }
66 73
74 kfree(scb);
67 _leave(" = %d", ret); 75 _leave(" = %d", ret);
68 return ret; 76 return ret;
69} 77}
@@ -143,31 +151,37 @@ static int afs_do_silly_unlink(struct afs_vnode *dvnode, struct afs_vnode *vnode
143 struct dentry *dentry, struct key *key) 151 struct dentry *dentry, struct key *key)
144{ 152{
145 struct afs_fs_cursor fc; 153 struct afs_fs_cursor fc;
146 u64 dir_data_version = dvnode->status.data_version; 154 struct afs_status_cb *scb;
147 int ret = -ERESTARTSYS; 155 int ret = -ERESTARTSYS;
148 156
149 _enter(""); 157 _enter("");
150 158
159 scb = kcalloc(2, sizeof(struct afs_status_cb), GFP_KERNEL);
160 if (!scb)
161 return -ENOMEM;
162
151 trace_afs_silly_rename(vnode, true); 163 trace_afs_silly_rename(vnode, true);
152 if (afs_begin_vnode_operation(&fc, dvnode, key, false)) { 164 if (afs_begin_vnode_operation(&fc, dvnode, key, false)) {
165 afs_dataversion_t dir_data_version = dvnode->status.data_version + 1;
166
153 while (afs_select_fileserver(&fc)) { 167 while (afs_select_fileserver(&fc)) {
154 fc.cb_break = afs_calc_vnode_cb_break(dvnode); 168 fc.cb_break = afs_calc_vnode_cb_break(dvnode);
155 169
156 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc.cbi->server->flags) && 170 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc.cbi->server->flags) &&
157 !test_bit(AFS_SERVER_FL_NO_RM2, &fc.cbi->server->flags)) { 171 !test_bit(AFS_SERVER_FL_NO_RM2, &fc.cbi->server->flags)) {
158 yfs_fs_remove_file2(&fc, vnode, dentry->d_name.name, 172 yfs_fs_remove_file2(&fc, vnode, dentry->d_name.name,
159 dir_data_version); 173 &scb[0], &scb[1]);
160 if (fc.ac.error != -ECONNABORTED || 174 if (fc.ac.error != -ECONNABORTED ||
161 fc.ac.abort_code != RXGEN_OPCODE) 175 fc.ac.abort_code != RXGEN_OPCODE)
162 continue; 176 continue;
163 set_bit(AFS_SERVER_FL_NO_RM2, &fc.cbi->server->flags); 177 set_bit(AFS_SERVER_FL_NO_RM2, &fc.cbi->server->flags);
164 } 178 }
165 179
166 afs_fs_remove(&fc, vnode, dentry->d_name.name, false, 180 afs_fs_remove(&fc, vnode, dentry->d_name.name, false, &scb[0]);
167 dir_data_version);
168 } 181 }
169 182
170 afs_vnode_commit_status(&fc, dvnode, fc.cb_break); 183 afs_vnode_commit_status(&fc, dvnode, fc.cb_break,
184 &dir_data_version, &scb[0]);
171 ret = afs_end_vnode_operation(&fc); 185 ret = afs_end_vnode_operation(&fc);
172 if (ret == 0) { 186 if (ret == 0) {
173 drop_nlink(&vnode->vfs_inode); 187 drop_nlink(&vnode->vfs_inode);
@@ -182,6 +196,7 @@ static int afs_do_silly_unlink(struct afs_vnode *dvnode, struct afs_vnode *vnode
182 afs_edit_dir_for_unlink); 196 afs_edit_dir_for_unlink);
183 } 197 }
184 198
199 kfree(scb);
185 _leave(" = %d", ret); 200 _leave(" = %d", ret);
186 return ret; 201 return ret;
187} 202}
diff --git a/fs/afs/file.c b/fs/afs/file.c
index 415c84dddb89..11e69c5fb7ab 100644
--- a/fs/afs/file.c
+++ b/fs/afs/file.c
@@ -228,6 +228,7 @@ static void afs_file_readpage_read_complete(struct page *page,
228int afs_fetch_data(struct afs_vnode *vnode, struct key *key, struct afs_read *desc) 228int afs_fetch_data(struct afs_vnode *vnode, struct key *key, struct afs_read *desc)
229{ 229{
230 struct afs_fs_cursor fc; 230 struct afs_fs_cursor fc;
231 struct afs_status_cb *scb;
231 int ret; 232 int ret;
232 233
233 _enter("%s{%llx:%llu.%u},%x,,,", 234 _enter("%s{%llx:%llu.%u},%x,,,",
@@ -237,15 +238,22 @@ int afs_fetch_data(struct afs_vnode *vnode, struct key *key, struct afs_read *de
237 vnode->fid.unique, 238 vnode->fid.unique,
238 key_serial(key)); 239 key_serial(key));
239 240
241 scb = kzalloc(sizeof(struct afs_status_cb), GFP_KERNEL);
242 if (!scb)
243 return -ENOMEM;
244
240 ret = -ERESTARTSYS; 245 ret = -ERESTARTSYS;
241 if (afs_begin_vnode_operation(&fc, vnode, key, true)) { 246 if (afs_begin_vnode_operation(&fc, vnode, key, true)) {
247 afs_dataversion_t data_version = vnode->status.data_version;
248
242 while (afs_select_fileserver(&fc)) { 249 while (afs_select_fileserver(&fc)) {
243 fc.cb_break = afs_calc_vnode_cb_break(vnode); 250 fc.cb_break = afs_calc_vnode_cb_break(vnode);
244 afs_fs_fetch_data(&fc, desc); 251 afs_fs_fetch_data(&fc, scb, desc);
245 } 252 }
246 253
247 afs_check_for_remote_deletion(&fc, fc.vnode); 254 afs_check_for_remote_deletion(&fc, vnode);
248 afs_vnode_commit_status(&fc, vnode, fc.cb_break); 255 afs_vnode_commit_status(&fc, vnode, fc.cb_break,
256 &data_version, scb);
249 ret = afs_end_vnode_operation(&fc); 257 ret = afs_end_vnode_operation(&fc);
250 } 258 }
251 259
@@ -255,6 +263,7 @@ int afs_fetch_data(struct afs_vnode *vnode, struct key *key, struct afs_read *de
255 &afs_v2net(vnode)->n_fetch_bytes); 263 &afs_v2net(vnode)->n_fetch_bytes);
256 } 264 }
257 265
266 kfree(scb);
258 _leave(" = %d", ret); 267 _leave(" = %d", ret);
259 return ret; 268 return ret;
260} 269}
@@ -405,10 +414,10 @@ static int afs_readpage(struct file *file, struct page *page)
405/* 414/*
406 * Make pages available as they're filled. 415 * Make pages available as they're filled.
407 */ 416 */
408static void afs_readpages_page_done(struct afs_call *call, struct afs_read *req) 417static void afs_readpages_page_done(struct afs_read *req)
409{ 418{
410#ifdef CONFIG_AFS_FSCACHE 419#ifdef CONFIG_AFS_FSCACHE
411 struct afs_vnode *vnode = call->xvnode; 420 struct afs_vnode *vnode = req->vnode;
412#endif 421#endif
413 struct page *page = req->pages[req->index]; 422 struct page *page = req->pages[req->index];
414 423
@@ -462,6 +471,7 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,
462 return -ENOMEM; 471 return -ENOMEM;
463 472
464 refcount_set(&req->usage, 1); 473 refcount_set(&req->usage, 1);
474 req->vnode = vnode;
465 req->page_done = afs_readpages_page_done; 475 req->page_done = afs_readpages_page_done;
466 req->pos = first->index; 476 req->pos = first->index;
467 req->pos <<= PAGE_SHIFT; 477 req->pos <<= PAGE_SHIFT;
diff --git a/fs/afs/flock.c b/fs/afs/flock.c
index ce8275940b99..ed3ac03682d7 100644
--- a/fs/afs/flock.c
+++ b/fs/afs/flock.c
@@ -74,7 +74,7 @@ static void afs_schedule_lock_extension(struct afs_vnode *vnode)
74 */ 74 */
75void afs_lock_op_done(struct afs_call *call) 75void afs_lock_op_done(struct afs_call *call)
76{ 76{
77 struct afs_vnode *vnode = call->xvnode; 77 struct afs_vnode *vnode = call->lvnode;
78 78
79 if (call->error == 0) { 79 if (call->error == 0) {
80 spin_lock(&vnode->lock); 80 spin_lock(&vnode->lock);
@@ -182,6 +182,7 @@ static void afs_kill_lockers_enoent(struct afs_vnode *vnode)
182static int afs_set_lock(struct afs_vnode *vnode, struct key *key, 182static int afs_set_lock(struct afs_vnode *vnode, struct key *key,
183 afs_lock_type_t type) 183 afs_lock_type_t type)
184{ 184{
185 struct afs_status_cb *scb;
185 struct afs_fs_cursor fc; 186 struct afs_fs_cursor fc;
186 int ret; 187 int ret;
187 188
@@ -192,18 +193,23 @@ static int afs_set_lock(struct afs_vnode *vnode, struct key *key,
192 vnode->fid.unique, 193 vnode->fid.unique,
193 key_serial(key), type); 194 key_serial(key), type);
194 195
196 scb = kzalloc(sizeof(struct afs_status_cb), GFP_KERNEL);
197 if (!scb)
198 return -ENOMEM;
199
195 ret = -ERESTARTSYS; 200 ret = -ERESTARTSYS;
196 if (afs_begin_vnode_operation(&fc, vnode, key, true)) { 201 if (afs_begin_vnode_operation(&fc, vnode, key, true)) {
197 while (afs_select_fileserver(&fc)) { 202 while (afs_select_fileserver(&fc)) {
198 fc.cb_break = afs_calc_vnode_cb_break(vnode); 203 fc.cb_break = afs_calc_vnode_cb_break(vnode);
199 afs_fs_set_lock(&fc, type); 204 afs_fs_set_lock(&fc, type, scb);
200 } 205 }
201 206
202 afs_check_for_remote_deletion(&fc, fc.vnode); 207 afs_check_for_remote_deletion(&fc, vnode);
203 afs_vnode_commit_status(&fc, vnode, fc.cb_break); 208 afs_vnode_commit_status(&fc, vnode, fc.cb_break, NULL, scb);
204 ret = afs_end_vnode_operation(&fc); 209 ret = afs_end_vnode_operation(&fc);
205 } 210 }
206 211
212 kfree(scb);
207 _leave(" = %d", ret); 213 _leave(" = %d", ret);
208 return ret; 214 return ret;
209} 215}
@@ -213,6 +219,7 @@ static int afs_set_lock(struct afs_vnode *vnode, struct key *key,
213 */ 219 */
214static int afs_extend_lock(struct afs_vnode *vnode, struct key *key) 220static int afs_extend_lock(struct afs_vnode *vnode, struct key *key)
215{ 221{
222 struct afs_status_cb *scb;
216 struct afs_fs_cursor fc; 223 struct afs_fs_cursor fc;
217 int ret; 224 int ret;
218 225
@@ -223,18 +230,23 @@ static int afs_extend_lock(struct afs_vnode *vnode, struct key *key)
223 vnode->fid.unique, 230 vnode->fid.unique,
224 key_serial(key)); 231 key_serial(key));
225 232
233 scb = kzalloc(sizeof(struct afs_status_cb), GFP_KERNEL);
234 if (!scb)
235 return -ENOMEM;
236
226 ret = -ERESTARTSYS; 237 ret = -ERESTARTSYS;
227 if (afs_begin_vnode_operation(&fc, vnode, key, false)) { 238 if (afs_begin_vnode_operation(&fc, vnode, key, false)) {
228 while (afs_select_current_fileserver(&fc)) { 239 while (afs_select_current_fileserver(&fc)) {
229 fc.cb_break = afs_calc_vnode_cb_break(vnode); 240 fc.cb_break = afs_calc_vnode_cb_break(vnode);
230 afs_fs_extend_lock(&fc); 241 afs_fs_extend_lock(&fc, scb);
231 } 242 }
232 243
233 afs_check_for_remote_deletion(&fc, fc.vnode); 244 afs_check_for_remote_deletion(&fc, vnode);
234 afs_vnode_commit_status(&fc, vnode, fc.cb_break); 245 afs_vnode_commit_status(&fc, vnode, fc.cb_break, NULL, scb);
235 ret = afs_end_vnode_operation(&fc); 246 ret = afs_end_vnode_operation(&fc);
236 } 247 }
237 248
249 kfree(scb);
238 _leave(" = %d", ret); 250 _leave(" = %d", ret);
239 return ret; 251 return ret;
240} 252}
@@ -244,6 +256,7 @@ static int afs_extend_lock(struct afs_vnode *vnode, struct key *key)
244 */ 256 */
245static int afs_release_lock(struct afs_vnode *vnode, struct key *key) 257static int afs_release_lock(struct afs_vnode *vnode, struct key *key)
246{ 258{
259 struct afs_status_cb *scb;
247 struct afs_fs_cursor fc; 260 struct afs_fs_cursor fc;
248 int ret; 261 int ret;
249 262
@@ -254,18 +267,23 @@ static int afs_release_lock(struct afs_vnode *vnode, struct key *key)
254 vnode->fid.unique, 267 vnode->fid.unique,
255 key_serial(key)); 268 key_serial(key));
256 269
270 scb = kzalloc(sizeof(struct afs_status_cb), GFP_KERNEL);
271 if (!scb)
272 return -ENOMEM;
273
257 ret = -ERESTARTSYS; 274 ret = -ERESTARTSYS;
258 if (afs_begin_vnode_operation(&fc, vnode, key, false)) { 275 if (afs_begin_vnode_operation(&fc, vnode, key, false)) {
259 while (afs_select_current_fileserver(&fc)) { 276 while (afs_select_current_fileserver(&fc)) {
260 fc.cb_break = afs_calc_vnode_cb_break(vnode); 277 fc.cb_break = afs_calc_vnode_cb_break(vnode);
261 afs_fs_release_lock(&fc); 278 afs_fs_release_lock(&fc, scb);
262 } 279 }
263 280
264 afs_check_for_remote_deletion(&fc, fc.vnode); 281 afs_check_for_remote_deletion(&fc, vnode);
265 afs_vnode_commit_status(&fc, vnode, fc.cb_break); 282 afs_vnode_commit_status(&fc, vnode, fc.cb_break, NULL, scb);
266 ret = afs_end_vnode_operation(&fc); 283 ret = afs_end_vnode_operation(&fc);
267 } 284 }
268 285
286 kfree(scb);
269 _leave(" = %d", ret); 287 _leave(" = %d", ret);
270 return ret; 288 return ret;
271} 289}
@@ -733,7 +751,7 @@ static int afs_do_getlk(struct file *file, struct file_lock *fl)
733 posix_test_lock(file, fl); 751 posix_test_lock(file, fl);
734 if (fl->fl_type == F_UNLCK) { 752 if (fl->fl_type == F_UNLCK) {
735 /* no local locks; consult the server */ 753 /* no local locks; consult the server */
736 ret = afs_fetch_status(vnode, key, false); 754 ret = afs_fetch_status(vnode, key, false, NULL);
737 if (ret < 0) 755 if (ret < 0)
738 goto error; 756 goto error;
739 757
diff --git a/fs/afs/fsclient.c b/fs/afs/fsclient.c
index d4bce3816978..5c1b7a031509 100644
--- a/fs/afs/fsclient.c
+++ b/fs/afs/fsclient.c
@@ -60,78 +60,17 @@ static void xdr_dump_bad(const __be32 *bp)
60} 60}
61 61
62/* 62/*
63 * Update the core inode struct from a returned status record.
64 */
65void afs_update_inode_from_status(struct afs_vnode *vnode,
66 struct afs_file_status *status,
67 const afs_dataversion_t *expected_version,
68 u8 flags)
69{
70 struct timespec64 t;
71 umode_t mode;
72
73 t = status->mtime_client;
74 vnode->vfs_inode.i_ctime = t;
75 vnode->vfs_inode.i_mtime = t;
76 vnode->vfs_inode.i_atime = t;
77
78 if (flags & (AFS_VNODE_META_CHANGED | AFS_VNODE_NOT_YET_SET)) {
79 vnode->vfs_inode.i_uid = make_kuid(&init_user_ns, status->owner);
80 vnode->vfs_inode.i_gid = make_kgid(&init_user_ns, status->group);
81 set_nlink(&vnode->vfs_inode, status->nlink);
82
83 mode = vnode->vfs_inode.i_mode;
84 mode &= ~S_IALLUGO;
85 mode |= status->mode;
86 barrier();
87 vnode->vfs_inode.i_mode = mode;
88 }
89
90 if (!(flags & AFS_VNODE_NOT_YET_SET)) {
91 if (expected_version &&
92 *expected_version != status->data_version) {
93 _debug("vnode modified %llx on {%llx:%llu} [exp %llx]",
94 (unsigned long long) status->data_version,
95 vnode->fid.vid, vnode->fid.vnode,
96 (unsigned long long) *expected_version);
97 vnode->invalid_before = status->data_version;
98 if (vnode->status.type == AFS_FTYPE_DIR) {
99 if (test_and_clear_bit(AFS_VNODE_DIR_VALID, &vnode->flags))
100 afs_stat_v(vnode, n_inval);
101 } else {
102 set_bit(AFS_VNODE_ZAP_DATA, &vnode->flags);
103 }
104 } else if (vnode->status.type == AFS_FTYPE_DIR) {
105 /* Expected directory change is handled elsewhere so
106 * that we can locally edit the directory and save on a
107 * download.
108 */
109 if (test_bit(AFS_VNODE_DIR_VALID, &vnode->flags))
110 flags &= ~AFS_VNODE_DATA_CHANGED;
111 }
112 }
113
114 if (flags & (AFS_VNODE_DATA_CHANGED | AFS_VNODE_NOT_YET_SET)) {
115 inode_set_iversion_raw(&vnode->vfs_inode, status->data_version);
116 i_size_write(&vnode->vfs_inode, status->size);
117 }
118}
119
120/*
121 * decode an AFSFetchStatus block 63 * decode an AFSFetchStatus block
122 */ 64 */
123static int xdr_decode_AFSFetchStatus(struct afs_call *call, 65static int xdr_decode_AFSFetchStatus(const __be32 **_bp,
124 const __be32 **_bp, 66 struct afs_call *call,
125 struct afs_file_status *status, 67 struct afs_status_cb *scb)
126 struct afs_vnode *vnode,
127 const afs_dataversion_t *expected_version,
128 struct afs_read *read_req)
129{ 68{
130 const struct afs_xdr_AFSFetchStatus *xdr = (const void *)*_bp; 69 const struct afs_xdr_AFSFetchStatus *xdr = (const void *)*_bp;
70 struct afs_file_status *status = &scb->status;
131 bool inline_error = (call->operation_ID == afs_FS_InlineBulkStatus); 71 bool inline_error = (call->operation_ID == afs_FS_InlineBulkStatus);
132 u64 data_version, size; 72 u64 data_version, size;
133 u32 type, abort_code; 73 u32 type, abort_code;
134 u8 flags = 0;
135 74
136 abort_code = ntohl(xdr->abort_code); 75 abort_code = ntohl(xdr->abort_code);
137 76
@@ -161,44 +100,25 @@ static int xdr_decode_AFSFetchStatus(struct afs_call *call,
161 case AFS_FTYPE_FILE: 100 case AFS_FTYPE_FILE:
162 case AFS_FTYPE_DIR: 101 case AFS_FTYPE_DIR:
163 case AFS_FTYPE_SYMLINK: 102 case AFS_FTYPE_SYMLINK:
164 if (type != status->type &&
165 vnode &&
166 !test_bit(AFS_VNODE_UNSET, &vnode->flags)) {
167 pr_warning("Vnode %llx:%llx:%x changed type %u to %u\n",
168 vnode->fid.vid,
169 vnode->fid.vnode,
170 vnode->fid.unique,
171 status->type, type);
172 goto bad;
173 }
174 status->type = type; 103 status->type = type;
175 break; 104 break;
176 default: 105 default:
177 goto bad; 106 goto bad;
178 } 107 }
179 108
180#define EXTRACT_M(FIELD) \ 109 status->nlink = ntohl(xdr->nlink);
181 do { \ 110 status->author = ntohl(xdr->author);
182 u32 x = ntohl(xdr->FIELD); \ 111 status->owner = ntohl(xdr->owner);
183 if (status->FIELD != x) { \ 112 status->caller_access = ntohl(xdr->caller_access); /* Ticket dependent */
184 flags |= AFS_VNODE_META_CHANGED; \ 113 status->anon_access = ntohl(xdr->anon_access);
185 status->FIELD = x; \ 114 status->mode = ntohl(xdr->mode) & S_IALLUGO;
186 } \ 115 status->group = ntohl(xdr->group);
187 } while (0) 116 status->lock_count = ntohl(xdr->lock_count);
188
189 EXTRACT_M(nlink);
190 EXTRACT_M(author);
191 EXTRACT_M(owner);
192 EXTRACT_M(caller_access); /* call ticket dependent */
193 EXTRACT_M(anon_access);
194 EXTRACT_M(mode);
195 EXTRACT_M(group);
196 117
197 status->mtime_client.tv_sec = ntohl(xdr->mtime_client); 118 status->mtime_client.tv_sec = ntohl(xdr->mtime_client);
198 status->mtime_client.tv_nsec = 0; 119 status->mtime_client.tv_nsec = 0;
199 status->mtime_server.tv_sec = ntohl(xdr->mtime_server); 120 status->mtime_server.tv_sec = ntohl(xdr->mtime_server);
200 status->mtime_server.tv_nsec = 0; 121 status->mtime_server.tv_nsec = 0;
201 status->lock_count = ntohl(xdr->lock_count);
202 122
203 size = (u64)ntohl(xdr->size_lo); 123 size = (u64)ntohl(xdr->size_lo);
204 size |= (u64)ntohl(xdr->size_hi) << 32; 124 size |= (u64)ntohl(xdr->size_hi) << 32;
@@ -206,25 +126,9 @@ static int xdr_decode_AFSFetchStatus(struct afs_call *call,
206 126
207 data_version = (u64)ntohl(xdr->data_version_lo); 127 data_version = (u64)ntohl(xdr->data_version_lo);
208 data_version |= (u64)ntohl(xdr->data_version_hi) << 32; 128 data_version |= (u64)ntohl(xdr->data_version_hi) << 32;
209 if (data_version != status->data_version) { 129 status->data_version = data_version;
210 status->data_version = data_version;
211 flags |= AFS_VNODE_DATA_CHANGED;
212 }
213
214 if (read_req) {
215 read_req->data_version = data_version;
216 read_req->file_size = size;
217 }
218 130
219 *_bp = (const void *)*_bp + sizeof(*xdr); 131 *_bp = (const void *)*_bp + sizeof(*xdr);
220
221 if (vnode) {
222 if (test_bit(AFS_VNODE_UNSET, &vnode->flags))
223 flags |= AFS_VNODE_NOT_YET_SET;
224 afs_update_inode_from_status(vnode, status, expected_version,
225 flags);
226 }
227
228 return 0; 132 return 0;
229 133
230bad: 134bad:
@@ -232,78 +136,26 @@ bad:
232 return afs_protocol_error(call, -EBADMSG, afs_eproto_bad_status); 136 return afs_protocol_error(call, -EBADMSG, afs_eproto_bad_status);
233} 137}
234 138
235/*
236 * Decode the file status. We need to lock the target vnode if we're going to
237 * update its status so that stat() sees the attributes update atomically.
238 */
239static int afs_decode_status(struct afs_call *call,
240 const __be32 **_bp,
241 struct afs_file_status *status,
242 struct afs_vnode *vnode,
243 const afs_dataversion_t *expected_version,
244 struct afs_read *read_req)
245{
246 int ret;
247
248 if (!vnode)
249 return xdr_decode_AFSFetchStatus(call, _bp, status, vnode,
250 expected_version, read_req);
251
252 write_seqlock(&vnode->cb_lock);
253 ret = xdr_decode_AFSFetchStatus(call, _bp, status, vnode,
254 expected_version, read_req);
255 write_sequnlock(&vnode->cb_lock);
256 return ret;
257}
258
259static time64_t xdr_decode_expiry(struct afs_call *call, u32 expiry) 139static time64_t xdr_decode_expiry(struct afs_call *call, u32 expiry)
260{ 140{
261 return ktime_divns(call->reply_time, NSEC_PER_SEC) + expiry; 141 return ktime_divns(call->reply_time, NSEC_PER_SEC) + expiry;
262} 142}
263 143
264static void xdr_decode_AFSCallBack_raw(struct afs_call *call, 144static void xdr_decode_AFSCallBack(const __be32 **_bp,
265 struct afs_callback *cb, 145 struct afs_call *call,
266 const __be32 **_bp) 146 struct afs_status_cb *scb)
267{ 147{
148 struct afs_callback *cb = &scb->callback;
268 const __be32 *bp = *_bp; 149 const __be32 *bp = *_bp;
269 150
270 cb->version = ntohl(*bp++); 151 cb->version = ntohl(*bp++);
271 cb->expires_at = xdr_decode_expiry(call, ntohl(*bp++)); 152 cb->expires_at = xdr_decode_expiry(call, ntohl(*bp++));
272 cb->type = ntohl(*bp++); 153 cb->type = ntohl(*bp++);
154 scb->have_cb = true;
273 *_bp = bp; 155 *_bp = bp;
274} 156}
275 157
276/* 158/*
277 * decode an AFSCallBack block
278 */
279static void xdr_decode_AFSCallBack(struct afs_call *call,
280 struct afs_vnode *vnode,
281 const __be32 **_bp)
282{
283 struct afs_cb_interest *old, *cbi = call->cbi;
284 struct afs_callback cb;
285
286 xdr_decode_AFSCallBack_raw(call, &cb, _bp);
287
288 write_seqlock(&vnode->cb_lock);
289
290 if (!afs_cb_is_broken(call->cb_break, vnode, cbi)) {
291 vnode->cb_version = cb.version;
292 vnode->cb_type = cb.type;
293 vnode->cb_expires_at = cb.expires_at;
294 old = vnode->cb_interest;
295 if (old != call->cbi) {
296 vnode->cb_interest = cbi;
297 cbi = old;
298 }
299 set_bit(AFS_VNODE_CB_PROMISED, &vnode->flags);
300 }
301
302 write_sequnlock(&vnode->cb_lock);
303 call->cbi = cbi;
304}
305
306/*
307 * decode an AFSVolSync block 159 * decode an AFSVolSync block
308 */ 160 */
309static void xdr_decode_AFSVolSync(const __be32 **_bp, 161static void xdr_decode_AFSVolSync(const __be32 **_bp,
@@ -392,7 +244,6 @@ static void xdr_decode_AFSFetchVolumeStatus(const __be32 **_bp,
392 */ 244 */
393static int afs_deliver_fs_fetch_status_vnode(struct afs_call *call) 245static int afs_deliver_fs_fetch_status_vnode(struct afs_call *call)
394{ 246{
395 struct afs_vnode *vnode = call->xvnode;
396 const __be32 *bp; 247 const __be32 *bp;
397 int ret; 248 int ret;
398 249
@@ -400,15 +251,12 @@ static int afs_deliver_fs_fetch_status_vnode(struct afs_call *call)
400 if (ret < 0) 251 if (ret < 0)
401 return ret; 252 return ret;
402 253
403 _enter("{%llx:%llu}", vnode->fid.vid, vnode->fid.vnode);
404
405 /* unmarshall the reply once we've received all of it */ 254 /* unmarshall the reply once we've received all of it */
406 bp = call->buffer; 255 bp = call->buffer;
407 ret = afs_decode_status(call, &bp, &vnode->status, vnode, 256 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
408 &call->expected_version, NULL);
409 if (ret < 0) 257 if (ret < 0)
410 return ret; 258 return ret;
411 xdr_decode_AFSCallBack(call, vnode, &bp); 259 xdr_decode_AFSCallBack(&bp, call, call->out_scb);
412 xdr_decode_AFSVolSync(&bp, call->out_volsync); 260 xdr_decode_AFSVolSync(&bp, call->out_volsync);
413 261
414 _leave(" = 0 [done]"); 262 _leave(" = 0 [done]");
@@ -428,8 +276,8 @@ static const struct afs_call_type afs_RXFSFetchStatus_vnode = {
428/* 276/*
429 * fetch the status information for a file 277 * fetch the status information for a file
430 */ 278 */
431int afs_fs_fetch_file_status(struct afs_fs_cursor *fc, struct afs_volsync *volsync, 279int afs_fs_fetch_file_status(struct afs_fs_cursor *fc, struct afs_status_cb *scb,
432 bool new_inode) 280 struct afs_volsync *volsync)
433{ 281{
434 struct afs_vnode *vnode = fc->vnode; 282 struct afs_vnode *vnode = fc->vnode;
435 struct afs_call *call; 283 struct afs_call *call;
@@ -437,7 +285,7 @@ int afs_fs_fetch_file_status(struct afs_fs_cursor *fc, struct afs_volsync *volsy
437 __be32 *bp; 285 __be32 *bp;
438 286
439 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)) 287 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
440 return yfs_fs_fetch_file_status(fc, volsync, new_inode); 288 return yfs_fs_fetch_file_status(fc, scb, volsync);
441 289
442 _enter(",%x,{%llx:%llu},,", 290 _enter(",%x,{%llx:%llu},,",
443 key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode); 291 key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
@@ -450,9 +298,8 @@ int afs_fs_fetch_file_status(struct afs_fs_cursor *fc, struct afs_volsync *volsy
450 } 298 }
451 299
452 call->key = fc->key; 300 call->key = fc->key;
453 call->xvnode = vnode; 301 call->out_scb = scb;
454 call->out_volsync = volsync; 302 call->out_volsync = volsync;
455 call->expected_version = new_inode ? 1 : vnode->status.data_version;
456 303
457 /* marshall the parameters */ 304 /* marshall the parameters */
458 bp = call->request; 305 bp = call->request;
@@ -461,7 +308,6 @@ int afs_fs_fetch_file_status(struct afs_fs_cursor *fc, struct afs_volsync *volsy
461 bp[2] = htonl(vnode->fid.vnode); 308 bp[2] = htonl(vnode->fid.vnode);
462 bp[3] = htonl(vnode->fid.unique); 309 bp[3] = htonl(vnode->fid.unique);
463 310
464 call->cb_break = fc->cb_break;
465 afs_use_fs_server(call, fc->cbi); 311 afs_use_fs_server(call, fc->cbi);
466 trace_afs_make_fs_call(call, &vnode->fid); 312 trace_afs_make_fs_call(call, &vnode->fid);
467 313
@@ -475,7 +321,6 @@ int afs_fs_fetch_file_status(struct afs_fs_cursor *fc, struct afs_volsync *volsy
475 */ 321 */
476static int afs_deliver_fs_fetch_data(struct afs_call *call) 322static int afs_deliver_fs_fetch_data(struct afs_call *call)
477{ 323{
478 struct afs_vnode *vnode = call->xvnode;
479 struct afs_read *req = call->read_request; 324 struct afs_read *req = call->read_request;
480 const __be32 *bp; 325 const __be32 *bp;
481 unsigned int size; 326 unsigned int size;
@@ -538,7 +383,7 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call)
538 if (req->offset == PAGE_SIZE) { 383 if (req->offset == PAGE_SIZE) {
539 req->offset = 0; 384 req->offset = 0;
540 if (req->page_done) 385 if (req->page_done)
541 req->page_done(call, req); 386 req->page_done(req);
542 req->index++; 387 req->index++;
543 if (req->remain > 0) 388 if (req->remain > 0)
544 goto begin_page; 389 goto begin_page;
@@ -572,13 +417,15 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call)
572 return ret; 417 return ret;
573 418
574 bp = call->buffer; 419 bp = call->buffer;
575 ret = afs_decode_status(call, &bp, &vnode->status, vnode, 420 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
576 &vnode->status.data_version, req);
577 if (ret < 0) 421 if (ret < 0)
578 return ret; 422 return ret;
579 xdr_decode_AFSCallBack(call, vnode, &bp); 423 xdr_decode_AFSCallBack(&bp, call, call->out_scb);
580 xdr_decode_AFSVolSync(&bp, call->out_volsync); 424 xdr_decode_AFSVolSync(&bp, call->out_volsync);
581 425
426 req->data_version = call->out_scb->status.data_version;
427 req->file_size = call->out_scb->status.size;
428
582 call->unmarshall++; 429 call->unmarshall++;
583 430
584 case 5: 431 case 5:
@@ -590,7 +437,7 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call)
590 zero_user_segment(req->pages[req->index], 437 zero_user_segment(req->pages[req->index],
591 req->offset, PAGE_SIZE); 438 req->offset, PAGE_SIZE);
592 if (req->page_done) 439 if (req->page_done)
593 req->page_done(call, req); 440 req->page_done(req);
594 req->offset = 0; 441 req->offset = 0;
595 } 442 }
596 443
@@ -626,7 +473,9 @@ static const struct afs_call_type afs_RXFSFetchData64 = {
626/* 473/*
627 * fetch data from a very large file 474 * fetch data from a very large file
628 */ 475 */
629static int afs_fs_fetch_data64(struct afs_fs_cursor *fc, struct afs_read *req) 476static int afs_fs_fetch_data64(struct afs_fs_cursor *fc,
477 struct afs_status_cb *scb,
478 struct afs_read *req)
630{ 479{
631 struct afs_vnode *vnode = fc->vnode; 480 struct afs_vnode *vnode = fc->vnode;
632 struct afs_call *call; 481 struct afs_call *call;
@@ -640,10 +489,9 @@ static int afs_fs_fetch_data64(struct afs_fs_cursor *fc, struct afs_read *req)
640 return -ENOMEM; 489 return -ENOMEM;
641 490
642 call->key = fc->key; 491 call->key = fc->key;
643 call->xvnode = vnode; 492 call->out_scb = scb;
644 call->out_volsync = NULL; 493 call->out_volsync = NULL;
645 call->read_request = req; 494 call->read_request = req;
646 call->expected_version = vnode->status.data_version;
647 495
648 /* marshall the parameters */ 496 /* marshall the parameters */
649 bp = call->request; 497 bp = call->request;
@@ -657,7 +505,6 @@ static int afs_fs_fetch_data64(struct afs_fs_cursor *fc, struct afs_read *req)
657 bp[7] = htonl(lower_32_bits(req->len)); 505 bp[7] = htonl(lower_32_bits(req->len));
658 506
659 refcount_inc(&req->usage); 507 refcount_inc(&req->usage);
660 call->cb_break = fc->cb_break;
661 afs_use_fs_server(call, fc->cbi); 508 afs_use_fs_server(call, fc->cbi);
662 trace_afs_make_fs_call(call, &vnode->fid); 509 trace_afs_make_fs_call(call, &vnode->fid);
663 afs_set_fc_call(call, fc); 510 afs_set_fc_call(call, fc);
@@ -668,7 +515,9 @@ static int afs_fs_fetch_data64(struct afs_fs_cursor *fc, struct afs_read *req)
668/* 515/*
669 * fetch data from a file 516 * fetch data from a file
670 */ 517 */
671int afs_fs_fetch_data(struct afs_fs_cursor *fc, struct afs_read *req) 518int afs_fs_fetch_data(struct afs_fs_cursor *fc,
519 struct afs_status_cb *scb,
520 struct afs_read *req)
672{ 521{
673 struct afs_vnode *vnode = fc->vnode; 522 struct afs_vnode *vnode = fc->vnode;
674 struct afs_call *call; 523 struct afs_call *call;
@@ -676,12 +525,12 @@ int afs_fs_fetch_data(struct afs_fs_cursor *fc, struct afs_read *req)
676 __be32 *bp; 525 __be32 *bp;
677 526
678 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)) 527 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
679 return yfs_fs_fetch_data(fc, req); 528 return yfs_fs_fetch_data(fc, scb, req);
680 529
681 if (upper_32_bits(req->pos) || 530 if (upper_32_bits(req->pos) ||
682 upper_32_bits(req->len) || 531 upper_32_bits(req->len) ||
683 upper_32_bits(req->pos + req->len)) 532 upper_32_bits(req->pos + req->len))
684 return afs_fs_fetch_data64(fc, req); 533 return afs_fs_fetch_data64(fc, scb, req);
685 534
686 _enter(""); 535 _enter("");
687 536
@@ -690,10 +539,9 @@ int afs_fs_fetch_data(struct afs_fs_cursor *fc, struct afs_read *req)
690 return -ENOMEM; 539 return -ENOMEM;
691 540
692 call->key = fc->key; 541 call->key = fc->key;
693 call->xvnode = vnode; 542 call->out_scb = scb;
694 call->out_volsync = NULL; 543 call->out_volsync = NULL;
695 call->read_request = req; 544 call->read_request = req;
696 call->expected_version = vnode->status.data_version;
697 545
698 /* marshall the parameters */ 546 /* marshall the parameters */
699 bp = call->request; 547 bp = call->request;
@@ -705,7 +553,6 @@ int afs_fs_fetch_data(struct afs_fs_cursor *fc, struct afs_read *req)
705 bp[5] = htonl(lower_32_bits(req->len)); 553 bp[5] = htonl(lower_32_bits(req->len));
706 554
707 refcount_inc(&req->usage); 555 refcount_inc(&req->usage);
708 call->cb_break = fc->cb_break;
709 afs_use_fs_server(call, fc->cbi); 556 afs_use_fs_server(call, fc->cbi);
710 trace_afs_make_fs_call(call, &vnode->fid); 557 trace_afs_make_fs_call(call, &vnode->fid);
711 afs_set_fc_call(call, fc); 558 afs_set_fc_call(call, fc);
@@ -718,12 +565,9 @@ int afs_fs_fetch_data(struct afs_fs_cursor *fc, struct afs_read *req)
718 */ 565 */
719static int afs_deliver_fs_create_vnode(struct afs_call *call) 566static int afs_deliver_fs_create_vnode(struct afs_call *call)
720{ 567{
721 struct afs_vnode *dvnode = call->dvnode;
722 const __be32 *bp; 568 const __be32 *bp;
723 int ret; 569 int ret;
724 570
725 _enter("{%u}", call->unmarshall);
726
727 ret = afs_transfer_reply(call); 571 ret = afs_transfer_reply(call);
728 if (ret < 0) 572 if (ret < 0)
729 return ret; 573 return ret;
@@ -731,14 +575,13 @@ static int afs_deliver_fs_create_vnode(struct afs_call *call)
731 /* unmarshall the reply once we've received all of it */ 575 /* unmarshall the reply once we've received all of it */
732 bp = call->buffer; 576 bp = call->buffer;
733 xdr_decode_AFSFid(&bp, call->out_fid); 577 xdr_decode_AFSFid(&bp, call->out_fid);
734 ret = afs_decode_status(call, &bp, call->out_extra_status, NULL, NULL, NULL); 578 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
735 if (ret < 0) 579 if (ret < 0)
736 return ret; 580 return ret;
737 ret = afs_decode_status(call, &bp, &dvnode->status, dvnode, 581 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb);
738 &call->expected_version, NULL);
739 if (ret < 0) 582 if (ret < 0)
740 return ret; 583 return ret;
741 xdr_decode_AFSCallBack_raw(call, call->out_cb, &bp); 584 xdr_decode_AFSCallBack(&bp, call, call->out_scb);
742 xdr_decode_AFSVolSync(&bp, call->out_volsync); 585 xdr_decode_AFSVolSync(&bp, call->out_volsync);
743 586
744 _leave(" = 0 [done]"); 587 _leave(" = 0 [done]");
@@ -768,10 +611,9 @@ static const struct afs_call_type afs_RXFSMakeDir = {
768int afs_fs_create(struct afs_fs_cursor *fc, 611int afs_fs_create(struct afs_fs_cursor *fc,
769 const char *name, 612 const char *name,
770 umode_t mode, 613 umode_t mode,
771 u64 current_data_version, 614 struct afs_status_cb *dvnode_scb,
772 struct afs_fid *newfid, 615 struct afs_fid *newfid,
773 struct afs_file_status *newstatus, 616 struct afs_status_cb *new_scb)
774 struct afs_callback *newcb)
775{ 617{
776 struct afs_vnode *dvnode = fc->vnode; 618 struct afs_vnode *dvnode = fc->vnode;
777 struct afs_call *call; 619 struct afs_call *call;
@@ -781,11 +623,11 @@ int afs_fs_create(struct afs_fs_cursor *fc,
781 623
782 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)){ 624 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)){
783 if (S_ISDIR(mode)) 625 if (S_ISDIR(mode))
784 return yfs_fs_make_dir(fc, name, mode, current_data_version, 626 return yfs_fs_make_dir(fc, name, mode, dvnode_scb,
785 newfid, newstatus, newcb); 627 newfid, new_scb);
786 else 628 else
787 return yfs_fs_create_file(fc, name, mode, current_data_version, 629 return yfs_fs_create_file(fc, name, mode, dvnode_scb,
788 newfid, newstatus, newcb); 630 newfid, new_scb);
789 } 631 }
790 632
791 _enter(""); 633 _enter("");
@@ -801,11 +643,9 @@ int afs_fs_create(struct afs_fs_cursor *fc,
801 return -ENOMEM; 643 return -ENOMEM;
802 644
803 call->key = fc->key; 645 call->key = fc->key;
804 call->dvnode = dvnode; 646 call->out_dir_scb = dvnode_scb;
805 call->out_fid = newfid; 647 call->out_fid = newfid;
806 call->out_extra_status = newstatus; 648 call->out_scb = new_scb;
807 call->out_cb = newcb;
808 call->expected_version = current_data_version + 1;
809 649
810 /* marshall the parameters */ 650 /* marshall the parameters */
811 bp = call->request; 651 bp = call->request;
@@ -840,20 +680,16 @@ int afs_fs_create(struct afs_fs_cursor *fc,
840 */ 680 */
841static int afs_deliver_fs_dir_status_and_vol(struct afs_call *call) 681static int afs_deliver_fs_dir_status_and_vol(struct afs_call *call)
842{ 682{
843 struct afs_vnode *dvnode = call->dvnode;
844 const __be32 *bp; 683 const __be32 *bp;
845 int ret; 684 int ret;
846 685
847 _enter("{%u}", call->unmarshall);
848
849 ret = afs_transfer_reply(call); 686 ret = afs_transfer_reply(call);
850 if (ret < 0) 687 if (ret < 0)
851 return ret; 688 return ret;
852 689
853 /* unmarshall the reply once we've received all of it */ 690 /* unmarshall the reply once we've received all of it */
854 bp = call->buffer; 691 bp = call->buffer;
855 ret = afs_decode_status(call, &bp, &dvnode->status, dvnode, 692 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb);
856 &call->expected_version, NULL);
857 if (ret < 0) 693 if (ret < 0)
858 return ret; 694 return ret;
859 xdr_decode_AFSVolSync(&bp, call->out_volsync); 695 xdr_decode_AFSVolSync(&bp, call->out_volsync);
@@ -883,7 +719,7 @@ static const struct afs_call_type afs_RXFSRemoveDir = {
883 * remove a file or directory 719 * remove a file or directory
884 */ 720 */
885int afs_fs_remove(struct afs_fs_cursor *fc, struct afs_vnode *vnode, 721int afs_fs_remove(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
886 const char *name, bool isdir, u64 current_data_version) 722 const char *name, bool isdir, struct afs_status_cb *dvnode_scb)
887{ 723{
888 struct afs_vnode *dvnode = fc->vnode; 724 struct afs_vnode *dvnode = fc->vnode;
889 struct afs_call *call; 725 struct afs_call *call;
@@ -892,7 +728,7 @@ int afs_fs_remove(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
892 __be32 *bp; 728 __be32 *bp;
893 729
894 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)) 730 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
895 return yfs_fs_remove(fc, vnode, name, isdir, current_data_version); 731 return yfs_fs_remove(fc, vnode, name, isdir, dvnode_scb);
896 732
897 _enter(""); 733 _enter("");
898 734
@@ -907,9 +743,7 @@ int afs_fs_remove(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
907 return -ENOMEM; 743 return -ENOMEM;
908 744
909 call->key = fc->key; 745 call->key = fc->key;
910 call->dvnode = dvnode; 746 call->out_dir_scb = dvnode_scb;
911 call->xvnode = vnode;
912 call->expected_version = current_data_version + 1;
913 747
914 /* marshall the parameters */ 748 /* marshall the parameters */
915 bp = call->request; 749 bp = call->request;
@@ -937,7 +771,6 @@ int afs_fs_remove(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
937 */ 771 */
938static int afs_deliver_fs_link(struct afs_call *call) 772static int afs_deliver_fs_link(struct afs_call *call)
939{ 773{
940 struct afs_vnode *dvnode = call->dvnode, *vnode = call->xvnode;
941 const __be32 *bp; 774 const __be32 *bp;
942 int ret; 775 int ret;
943 776
@@ -949,11 +782,10 @@ static int afs_deliver_fs_link(struct afs_call *call)
949 782
950 /* unmarshall the reply once we've received all of it */ 783 /* unmarshall the reply once we've received all of it */
951 bp = call->buffer; 784 bp = call->buffer;
952 ret = afs_decode_status(call, &bp, &vnode->status, vnode, NULL, NULL); 785 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
953 if (ret < 0) 786 if (ret < 0)
954 return ret; 787 return ret;
955 ret = afs_decode_status(call, &bp, &dvnode->status, dvnode, 788 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb);
956 &call->expected_version, NULL);
957 if (ret < 0) 789 if (ret < 0)
958 return ret; 790 return ret;
959 xdr_decode_AFSVolSync(&bp, call->out_volsync); 791 xdr_decode_AFSVolSync(&bp, call->out_volsync);
@@ -976,7 +808,9 @@ static const struct afs_call_type afs_RXFSLink = {
976 * make a hard link 808 * make a hard link
977 */ 809 */
978int afs_fs_link(struct afs_fs_cursor *fc, struct afs_vnode *vnode, 810int afs_fs_link(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
979 const char *name, u64 current_data_version) 811 const char *name,
812 struct afs_status_cb *dvnode_scb,
813 struct afs_status_cb *vnode_scb)
980{ 814{
981 struct afs_vnode *dvnode = fc->vnode; 815 struct afs_vnode *dvnode = fc->vnode;
982 struct afs_call *call; 816 struct afs_call *call;
@@ -985,7 +819,7 @@ int afs_fs_link(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
985 __be32 *bp; 819 __be32 *bp;
986 820
987 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)) 821 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
988 return yfs_fs_link(fc, vnode, name, current_data_version); 822 return yfs_fs_link(fc, vnode, name, dvnode_scb, vnode_scb);
989 823
990 _enter(""); 824 _enter("");
991 825
@@ -998,9 +832,8 @@ int afs_fs_link(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
998 return -ENOMEM; 832 return -ENOMEM;
999 833
1000 call->key = fc->key; 834 call->key = fc->key;
1001 call->dvnode = dvnode; 835 call->out_dir_scb = dvnode_scb;
1002 call->xvnode = vnode; 836 call->out_scb = vnode_scb;
1003 call->expected_version = current_data_version + 1;
1004 837
1005 /* marshall the parameters */ 838 /* marshall the parameters */
1006 bp = call->request; 839 bp = call->request;
@@ -1031,7 +864,6 @@ int afs_fs_link(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
1031 */ 864 */
1032static int afs_deliver_fs_symlink(struct afs_call *call) 865static int afs_deliver_fs_symlink(struct afs_call *call)
1033{ 866{
1034 struct afs_vnode *dvnode = call->dvnode;
1035 const __be32 *bp; 867 const __be32 *bp;
1036 int ret; 868 int ret;
1037 869
@@ -1044,11 +876,10 @@ static int afs_deliver_fs_symlink(struct afs_call *call)
1044 /* unmarshall the reply once we've received all of it */ 876 /* unmarshall the reply once we've received all of it */
1045 bp = call->buffer; 877 bp = call->buffer;
1046 xdr_decode_AFSFid(&bp, call->out_fid); 878 xdr_decode_AFSFid(&bp, call->out_fid);
1047 ret = afs_decode_status(call, &bp, call->out_extra_status, NULL, NULL, NULL); 879 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
1048 if (ret < 0) 880 if (ret < 0)
1049 return ret; 881 return ret;
1050 ret = afs_decode_status(call, &bp, &dvnode->status, dvnode, 882 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb);
1051 &call->expected_version, NULL);
1052 if (ret < 0) 883 if (ret < 0)
1053 return ret; 884 return ret;
1054 xdr_decode_AFSVolSync(&bp, call->out_volsync); 885 xdr_decode_AFSVolSync(&bp, call->out_volsync);
@@ -1073,9 +904,9 @@ static const struct afs_call_type afs_RXFSSymlink = {
1073int afs_fs_symlink(struct afs_fs_cursor *fc, 904int afs_fs_symlink(struct afs_fs_cursor *fc,
1074 const char *name, 905 const char *name,
1075 const char *contents, 906 const char *contents,
1076 u64 current_data_version, 907 struct afs_status_cb *dvnode_scb,
1077 struct afs_fid *newfid, 908 struct afs_fid *newfid,
1078 struct afs_file_status *newstatus) 909 struct afs_status_cb *new_scb)
1079{ 910{
1080 struct afs_vnode *dvnode = fc->vnode; 911 struct afs_vnode *dvnode = fc->vnode;
1081 struct afs_call *call; 912 struct afs_call *call;
@@ -1084,8 +915,8 @@ int afs_fs_symlink(struct afs_fs_cursor *fc,
1084 __be32 *bp; 915 __be32 *bp;
1085 916
1086 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)) 917 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1087 return yfs_fs_symlink(fc, name, contents, current_data_version, 918 return yfs_fs_symlink(fc, name, contents, dvnode_scb,
1088 newfid, newstatus); 919 newfid, new_scb);
1089 920
1090 _enter(""); 921 _enter("");
1091 922
@@ -1103,10 +934,9 @@ int afs_fs_symlink(struct afs_fs_cursor *fc,
1103 return -ENOMEM; 934 return -ENOMEM;
1104 935
1105 call->key = fc->key; 936 call->key = fc->key;
1106 call->dvnode = dvnode; 937 call->out_dir_scb = dvnode_scb;
1107 call->out_fid = newfid; 938 call->out_fid = newfid;
1108 call->out_extra_status = newstatus; 939 call->out_scb = new_scb;
1109 call->expected_version = current_data_version + 1;
1110 940
1111 /* marshall the parameters */ 941 /* marshall the parameters */
1112 bp = call->request; 942 bp = call->request;
@@ -1147,25 +977,20 @@ int afs_fs_symlink(struct afs_fs_cursor *fc,
1147 */ 977 */
1148static int afs_deliver_fs_rename(struct afs_call *call) 978static int afs_deliver_fs_rename(struct afs_call *call)
1149{ 979{
1150 struct afs_vnode *orig_dvnode = call->dvnode, *new_dvnode = call->xvnode;
1151 const __be32 *bp; 980 const __be32 *bp;
1152 int ret; 981 int ret;
1153 982
1154 _enter("{%u}", call->unmarshall);
1155
1156 ret = afs_transfer_reply(call); 983 ret = afs_transfer_reply(call);
1157 if (ret < 0) 984 if (ret < 0)
1158 return ret; 985 return ret;
1159 986
1160 /* unmarshall the reply once we've received all of it */ 987 /* unmarshall the reply once we've received all of it */
1161 bp = call->buffer; 988 bp = call->buffer;
1162 ret = afs_decode_status(call, &bp, &orig_dvnode->status, orig_dvnode, 989 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb);
1163 &call->expected_version, NULL);
1164 if (ret < 0) 990 if (ret < 0)
1165 return ret; 991 return ret;
1166 if (new_dvnode != orig_dvnode) { 992 if (call->out_dir_scb != call->out_scb) {
1167 ret = afs_decode_status(call, &bp, &new_dvnode->status, new_dvnode, 993 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
1168 &call->expected_version_2, NULL);
1169 if (ret < 0) 994 if (ret < 0)
1170 return ret; 995 return ret;
1171 } 996 }
@@ -1186,14 +1011,14 @@ static const struct afs_call_type afs_RXFSRename = {
1186}; 1011};
1187 1012
1188/* 1013/*
1189 * create a symbolic link 1014 * Rename/move a file or directory.
1190 */ 1015 */
1191int afs_fs_rename(struct afs_fs_cursor *fc, 1016int afs_fs_rename(struct afs_fs_cursor *fc,
1192 const char *orig_name, 1017 const char *orig_name,
1193 struct afs_vnode *new_dvnode, 1018 struct afs_vnode *new_dvnode,
1194 const char *new_name, 1019 const char *new_name,
1195 u64 current_orig_data_version, 1020 struct afs_status_cb *orig_dvnode_scb,
1196 u64 current_new_data_version) 1021 struct afs_status_cb *new_dvnode_scb)
1197{ 1022{
1198 struct afs_vnode *orig_dvnode = fc->vnode; 1023 struct afs_vnode *orig_dvnode = fc->vnode;
1199 struct afs_call *call; 1024 struct afs_call *call;
@@ -1204,8 +1029,8 @@ int afs_fs_rename(struct afs_fs_cursor *fc,
1204 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)) 1029 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1205 return yfs_fs_rename(fc, orig_name, 1030 return yfs_fs_rename(fc, orig_name,
1206 new_dvnode, new_name, 1031 new_dvnode, new_name,
1207 current_orig_data_version, 1032 orig_dvnode_scb,
1208 current_new_data_version); 1033 new_dvnode_scb);
1209 1034
1210 _enter(""); 1035 _enter("");
1211 1036
@@ -1225,10 +1050,8 @@ int afs_fs_rename(struct afs_fs_cursor *fc,
1225 return -ENOMEM; 1050 return -ENOMEM;
1226 1051
1227 call->key = fc->key; 1052 call->key = fc->key;
1228 call->dvnode = orig_dvnode; 1053 call->out_dir_scb = orig_dvnode_scb;
1229 call->xvnode = new_dvnode; 1054 call->out_scb = new_dvnode_scb;
1230 call->expected_version = current_orig_data_version + 1;
1231 call->expected_version_2 = current_new_data_version + 1;
1232 1055
1233 /* marshall the parameters */ 1056 /* marshall the parameters */
1234 bp = call->request; 1057 bp = call->request;
@@ -1267,7 +1090,6 @@ int afs_fs_rename(struct afs_fs_cursor *fc,
1267 */ 1090 */
1268static int afs_deliver_fs_store_data(struct afs_call *call) 1091static int afs_deliver_fs_store_data(struct afs_call *call)
1269{ 1092{
1270 struct afs_vnode *vnode = call->xvnode;
1271 const __be32 *bp; 1093 const __be32 *bp;
1272 int ret; 1094 int ret;
1273 1095
@@ -1279,14 +1101,11 @@ static int afs_deliver_fs_store_data(struct afs_call *call)
1279 1101
1280 /* unmarshall the reply once we've received all of it */ 1102 /* unmarshall the reply once we've received all of it */
1281 bp = call->buffer; 1103 bp = call->buffer;
1282 ret = afs_decode_status(call, &bp, &vnode->status, vnode, 1104 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
1283 &call->expected_version, NULL);
1284 if (ret < 0) 1105 if (ret < 0)
1285 return ret; 1106 return ret;
1286 xdr_decode_AFSVolSync(&bp, call->out_volsync); 1107 xdr_decode_AFSVolSync(&bp, call->out_volsync);
1287 1108
1288 afs_pages_written_back(vnode, call);
1289
1290 _leave(" = 0 [done]"); 1109 _leave(" = 0 [done]");
1291 return 0; 1110 return 0;
1292} 1111}
@@ -1315,7 +1134,8 @@ static int afs_fs_store_data64(struct afs_fs_cursor *fc,
1315 struct address_space *mapping, 1134 struct address_space *mapping,
1316 pgoff_t first, pgoff_t last, 1135 pgoff_t first, pgoff_t last,
1317 unsigned offset, unsigned to, 1136 unsigned offset, unsigned to,
1318 loff_t size, loff_t pos, loff_t i_size) 1137 loff_t size, loff_t pos, loff_t i_size,
1138 struct afs_status_cb *scb)
1319{ 1139{
1320 struct afs_vnode *vnode = fc->vnode; 1140 struct afs_vnode *vnode = fc->vnode;
1321 struct afs_call *call; 1141 struct afs_call *call;
@@ -1333,13 +1153,12 @@ static int afs_fs_store_data64(struct afs_fs_cursor *fc,
1333 1153
1334 call->key = fc->key; 1154 call->key = fc->key;
1335 call->mapping = mapping; 1155 call->mapping = mapping;
1336 call->xvnode = vnode;
1337 call->first = first; 1156 call->first = first;
1338 call->last = last; 1157 call->last = last;
1339 call->first_offset = offset; 1158 call->first_offset = offset;
1340 call->last_to = to; 1159 call->last_to = to;
1341 call->send_pages = true; 1160 call->send_pages = true;
1342 call->expected_version = vnode->status.data_version + 1; 1161 call->out_scb = scb;
1343 1162
1344 /* marshall the parameters */ 1163 /* marshall the parameters */
1345 bp = call->request; 1164 bp = call->request;
@@ -1373,7 +1192,8 @@ static int afs_fs_store_data64(struct afs_fs_cursor *fc,
1373 */ 1192 */
1374int afs_fs_store_data(struct afs_fs_cursor *fc, struct address_space *mapping, 1193int afs_fs_store_data(struct afs_fs_cursor *fc, struct address_space *mapping,
1375 pgoff_t first, pgoff_t last, 1194 pgoff_t first, pgoff_t last,
1376 unsigned offset, unsigned to) 1195 unsigned offset, unsigned to,
1196 struct afs_status_cb *scb)
1377{ 1197{
1378 struct afs_vnode *vnode = fc->vnode; 1198 struct afs_vnode *vnode = fc->vnode;
1379 struct afs_call *call; 1199 struct afs_call *call;
@@ -1382,7 +1202,7 @@ int afs_fs_store_data(struct afs_fs_cursor *fc, struct address_space *mapping,
1382 __be32 *bp; 1202 __be32 *bp;
1383 1203
1384 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)) 1204 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1385 return yfs_fs_store_data(fc, mapping, first, last, offset, to); 1205 return yfs_fs_store_data(fc, mapping, first, last, offset, to, scb);
1386 1206
1387 _enter(",%x,{%llx:%llu},,", 1207 _enter(",%x,{%llx:%llu},,",
1388 key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode); 1208 key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
@@ -1403,7 +1223,7 @@ int afs_fs_store_data(struct afs_fs_cursor *fc, struct address_space *mapping,
1403 1223
1404 if (pos >> 32 || i_size >> 32 || size >> 32 || (pos + size) >> 32) 1224 if (pos >> 32 || i_size >> 32 || size >> 32 || (pos + size) >> 32)
1405 return afs_fs_store_data64(fc, mapping, first, last, offset, to, 1225 return afs_fs_store_data64(fc, mapping, first, last, offset, to,
1406 size, pos, i_size); 1226 size, pos, i_size, scb);
1407 1227
1408 call = afs_alloc_flat_call(net, &afs_RXFSStoreData, 1228 call = afs_alloc_flat_call(net, &afs_RXFSStoreData,
1409 (4 + 6 + 3) * 4, 1229 (4 + 6 + 3) * 4,
@@ -1413,13 +1233,12 @@ int afs_fs_store_data(struct afs_fs_cursor *fc, struct address_space *mapping,
1413 1233
1414 call->key = fc->key; 1234 call->key = fc->key;
1415 call->mapping = mapping; 1235 call->mapping = mapping;
1416 call->xvnode = vnode;
1417 call->first = first; 1236 call->first = first;
1418 call->last = last; 1237 call->last = last;
1419 call->first_offset = offset; 1238 call->first_offset = offset;
1420 call->last_to = to; 1239 call->last_to = to;
1421 call->send_pages = true; 1240 call->send_pages = true;
1422 call->expected_version = vnode->status.data_version + 1; 1241 call->out_scb = scb;
1423 1242
1424 /* marshall the parameters */ 1243 /* marshall the parameters */
1425 bp = call->request; 1244 bp = call->request;
@@ -1451,7 +1270,6 @@ int afs_fs_store_data(struct afs_fs_cursor *fc, struct address_space *mapping,
1451 */ 1270 */
1452static int afs_deliver_fs_store_status(struct afs_call *call) 1271static int afs_deliver_fs_store_status(struct afs_call *call)
1453{ 1272{
1454 struct afs_vnode *vnode = call->xvnode;
1455 const __be32 *bp; 1273 const __be32 *bp;
1456 int ret; 1274 int ret;
1457 1275
@@ -1463,8 +1281,7 @@ static int afs_deliver_fs_store_status(struct afs_call *call)
1463 1281
1464 /* unmarshall the reply once we've received all of it */ 1282 /* unmarshall the reply once we've received all of it */
1465 bp = call->buffer; 1283 bp = call->buffer;
1466 ret = afs_decode_status(call, &bp, &vnode->status, vnode, 1284 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
1467 &call->expected_version, NULL);
1468 if (ret < 0) 1285 if (ret < 0)
1469 return ret; 1286 return ret;
1470 xdr_decode_AFSVolSync(&bp, call->out_volsync); 1287 xdr_decode_AFSVolSync(&bp, call->out_volsync);
@@ -1501,7 +1318,8 @@ static const struct afs_call_type afs_RXFSStoreData64_as_Status = {
1501 * set the attributes on a very large file, using FS.StoreData rather than 1318 * set the attributes on a very large file, using FS.StoreData rather than
1502 * FS.StoreStatus so as to alter the file size also 1319 * FS.StoreStatus so as to alter the file size also
1503 */ 1320 */
1504static int afs_fs_setattr_size64(struct afs_fs_cursor *fc, struct iattr *attr) 1321static int afs_fs_setattr_size64(struct afs_fs_cursor *fc, struct iattr *attr,
1322 struct afs_status_cb *scb)
1505{ 1323{
1506 struct afs_vnode *vnode = fc->vnode; 1324 struct afs_vnode *vnode = fc->vnode;
1507 struct afs_call *call; 1325 struct afs_call *call;
@@ -1520,8 +1338,7 @@ static int afs_fs_setattr_size64(struct afs_fs_cursor *fc, struct iattr *attr)
1520 return -ENOMEM; 1338 return -ENOMEM;
1521 1339
1522 call->key = fc->key; 1340 call->key = fc->key;
1523 call->xvnode = vnode; 1341 call->out_scb = scb;
1524 call->expected_version = vnode->status.data_version + 1;
1525 1342
1526 /* marshall the parameters */ 1343 /* marshall the parameters */
1527 bp = call->request; 1344 bp = call->request;
@@ -1550,7 +1367,8 @@ static int afs_fs_setattr_size64(struct afs_fs_cursor *fc, struct iattr *attr)
1550 * set the attributes on a file, using FS.StoreData rather than FS.StoreStatus 1367 * set the attributes on a file, using FS.StoreData rather than FS.StoreStatus
1551 * so as to alter the file size also 1368 * so as to alter the file size also
1552 */ 1369 */
1553static int afs_fs_setattr_size(struct afs_fs_cursor *fc, struct iattr *attr) 1370static int afs_fs_setattr_size(struct afs_fs_cursor *fc, struct iattr *attr,
1371 struct afs_status_cb *scb)
1554{ 1372{
1555 struct afs_vnode *vnode = fc->vnode; 1373 struct afs_vnode *vnode = fc->vnode;
1556 struct afs_call *call; 1374 struct afs_call *call;
@@ -1562,7 +1380,7 @@ static int afs_fs_setattr_size(struct afs_fs_cursor *fc, struct iattr *attr)
1562 1380
1563 ASSERT(attr->ia_valid & ATTR_SIZE); 1381 ASSERT(attr->ia_valid & ATTR_SIZE);
1564 if (attr->ia_size >> 32) 1382 if (attr->ia_size >> 32)
1565 return afs_fs_setattr_size64(fc, attr); 1383 return afs_fs_setattr_size64(fc, attr, scb);
1566 1384
1567 call = afs_alloc_flat_call(net, &afs_RXFSStoreData_as_Status, 1385 call = afs_alloc_flat_call(net, &afs_RXFSStoreData_as_Status,
1568 (4 + 6 + 3) * 4, 1386 (4 + 6 + 3) * 4,
@@ -1571,8 +1389,7 @@ static int afs_fs_setattr_size(struct afs_fs_cursor *fc, struct iattr *attr)
1571 return -ENOMEM; 1389 return -ENOMEM;
1572 1390
1573 call->key = fc->key; 1391 call->key = fc->key;
1574 call->xvnode = vnode; 1392 call->out_scb = scb;
1575 call->expected_version = vnode->status.data_version + 1;
1576 1393
1577 /* marshall the parameters */ 1394 /* marshall the parameters */
1578 bp = call->request; 1395 bp = call->request;
@@ -1598,7 +1415,8 @@ static int afs_fs_setattr_size(struct afs_fs_cursor *fc, struct iattr *attr)
1598 * set the attributes on a file, using FS.StoreData if there's a change in file 1415 * set the attributes on a file, using FS.StoreData if there's a change in file
1599 * size, and FS.StoreStatus otherwise 1416 * size, and FS.StoreStatus otherwise
1600 */ 1417 */
1601int afs_fs_setattr(struct afs_fs_cursor *fc, struct iattr *attr) 1418int afs_fs_setattr(struct afs_fs_cursor *fc, struct iattr *attr,
1419 struct afs_status_cb *scb)
1602{ 1420{
1603 struct afs_vnode *vnode = fc->vnode; 1421 struct afs_vnode *vnode = fc->vnode;
1604 struct afs_call *call; 1422 struct afs_call *call;
@@ -1606,10 +1424,10 @@ int afs_fs_setattr(struct afs_fs_cursor *fc, struct iattr *attr)
1606 __be32 *bp; 1424 __be32 *bp;
1607 1425
1608 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)) 1426 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1609 return yfs_fs_setattr(fc, attr); 1427 return yfs_fs_setattr(fc, attr, scb);
1610 1428
1611 if (attr->ia_valid & ATTR_SIZE) 1429 if (attr->ia_valid & ATTR_SIZE)
1612 return afs_fs_setattr_size(fc, attr); 1430 return afs_fs_setattr_size(fc, attr, scb);
1613 1431
1614 _enter(",%x,{%llx:%llu},,", 1432 _enter(",%x,{%llx:%llu},,",
1615 key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode); 1433 key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
@@ -1621,8 +1439,7 @@ int afs_fs_setattr(struct afs_fs_cursor *fc, struct iattr *attr)
1621 return -ENOMEM; 1439 return -ENOMEM;
1622 1440
1623 call->key = fc->key; 1441 call->key = fc->key;
1624 call->xvnode = vnode; 1442 call->out_scb = scb;
1625 call->expected_version = vnode->status.data_version;
1626 1443
1627 /* marshall the parameters */ 1444 /* marshall the parameters */
1628 bp = call->request; 1445 bp = call->request;
@@ -1865,7 +1682,8 @@ static const struct afs_call_type afs_RXFSReleaseLock = {
1865/* 1682/*
1866 * Set a lock on a file 1683 * Set a lock on a file
1867 */ 1684 */
1868int afs_fs_set_lock(struct afs_fs_cursor *fc, afs_lock_type_t type) 1685int afs_fs_set_lock(struct afs_fs_cursor *fc, afs_lock_type_t type,
1686 struct afs_status_cb *scb)
1869{ 1687{
1870 struct afs_vnode *vnode = fc->vnode; 1688 struct afs_vnode *vnode = fc->vnode;
1871 struct afs_call *call; 1689 struct afs_call *call;
@@ -1873,7 +1691,7 @@ int afs_fs_set_lock(struct afs_fs_cursor *fc, afs_lock_type_t type)
1873 __be32 *bp; 1691 __be32 *bp;
1874 1692
1875 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)) 1693 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1876 return yfs_fs_set_lock(fc, type); 1694 return yfs_fs_set_lock(fc, type, scb);
1877 1695
1878 _enter(""); 1696 _enter("");
1879 1697
@@ -1882,7 +1700,8 @@ int afs_fs_set_lock(struct afs_fs_cursor *fc, afs_lock_type_t type)
1882 return -ENOMEM; 1700 return -ENOMEM;
1883 1701
1884 call->key = fc->key; 1702 call->key = fc->key;
1885 call->xvnode = vnode; 1703 call->lvnode = vnode;
1704 call->out_scb = scb;
1886 1705
1887 /* marshall the parameters */ 1706 /* marshall the parameters */
1888 bp = call->request; 1707 bp = call->request;
@@ -1902,7 +1721,7 @@ int afs_fs_set_lock(struct afs_fs_cursor *fc, afs_lock_type_t type)
1902/* 1721/*
1903 * extend a lock on a file 1722 * extend a lock on a file
1904 */ 1723 */
1905int afs_fs_extend_lock(struct afs_fs_cursor *fc) 1724int afs_fs_extend_lock(struct afs_fs_cursor *fc, struct afs_status_cb *scb)
1906{ 1725{
1907 struct afs_vnode *vnode = fc->vnode; 1726 struct afs_vnode *vnode = fc->vnode;
1908 struct afs_call *call; 1727 struct afs_call *call;
@@ -1910,7 +1729,7 @@ int afs_fs_extend_lock(struct afs_fs_cursor *fc)
1910 __be32 *bp; 1729 __be32 *bp;
1911 1730
1912 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)) 1731 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1913 return yfs_fs_extend_lock(fc); 1732 return yfs_fs_extend_lock(fc, scb);
1914 1733
1915 _enter(""); 1734 _enter("");
1916 1735
@@ -1919,7 +1738,8 @@ int afs_fs_extend_lock(struct afs_fs_cursor *fc)
1919 return -ENOMEM; 1738 return -ENOMEM;
1920 1739
1921 call->key = fc->key; 1740 call->key = fc->key;
1922 call->xvnode = vnode; 1741 call->lvnode = vnode;
1742 call->out_scb = scb;
1923 1743
1924 /* marshall the parameters */ 1744 /* marshall the parameters */
1925 bp = call->request; 1745 bp = call->request;
@@ -1938,7 +1758,7 @@ int afs_fs_extend_lock(struct afs_fs_cursor *fc)
1938/* 1758/*
1939 * release a lock on a file 1759 * release a lock on a file
1940 */ 1760 */
1941int afs_fs_release_lock(struct afs_fs_cursor *fc) 1761int afs_fs_release_lock(struct afs_fs_cursor *fc, struct afs_status_cb *scb)
1942{ 1762{
1943 struct afs_vnode *vnode = fc->vnode; 1763 struct afs_vnode *vnode = fc->vnode;
1944 struct afs_call *call; 1764 struct afs_call *call;
@@ -1946,7 +1766,7 @@ int afs_fs_release_lock(struct afs_fs_cursor *fc)
1946 __be32 *bp; 1766 __be32 *bp;
1947 1767
1948 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)) 1768 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1949 return yfs_fs_release_lock(fc); 1769 return yfs_fs_release_lock(fc, scb);
1950 1770
1951 _enter(""); 1771 _enter("");
1952 1772
@@ -1955,7 +1775,8 @@ int afs_fs_release_lock(struct afs_fs_cursor *fc)
1955 return -ENOMEM; 1775 return -ENOMEM;
1956 1776
1957 call->key = fc->key; 1777 call->key = fc->key;
1958 call->xvnode = vnode; 1778 call->lvnode = vnode;
1779 call->out_scb = scb;
1959 1780
1960 /* marshall the parameters */ 1781 /* marshall the parameters */
1961 bp = call->request; 1782 bp = call->request;
@@ -2113,10 +1934,6 @@ struct afs_call *afs_fs_get_capabilities(struct afs_net *net,
2113 */ 1934 */
2114static int afs_deliver_fs_fetch_status(struct afs_call *call) 1935static int afs_deliver_fs_fetch_status(struct afs_call *call)
2115{ 1936{
2116 struct afs_file_status *status = call->out_vnode_status;
2117 struct afs_callback *callback = call->out_cb;
2118 struct afs_volsync *volsync = call->out_volsync;
2119 struct afs_fid *fid = call->out_fid;
2120 const __be32 *bp; 1937 const __be32 *bp;
2121 int ret; 1938 int ret;
2122 1939
@@ -2124,16 +1941,13 @@ static int afs_deliver_fs_fetch_status(struct afs_call *call)
2124 if (ret < 0) 1941 if (ret < 0)
2125 return ret; 1942 return ret;
2126 1943
2127 _enter("{%llx:%llu}", fid->vid, fid->vnode);
2128
2129 /* unmarshall the reply once we've received all of it */ 1944 /* unmarshall the reply once we've received all of it */
2130 bp = call->buffer; 1945 bp = call->buffer;
2131 ret = afs_decode_status(call, &bp, status, NULL, 1946 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
2132 &call->expected_version, NULL);
2133 if (ret < 0) 1947 if (ret < 0)
2134 return ret; 1948 return ret;
2135 xdr_decode_AFSCallBack_raw(call, callback, &bp); 1949 xdr_decode_AFSCallBack(&bp, call, call->out_scb);
2136 xdr_decode_AFSVolSync(&bp, volsync); 1950 xdr_decode_AFSVolSync(&bp, call->out_volsync);
2137 1951
2138 _leave(" = 0 [done]"); 1952 _leave(" = 0 [done]");
2139 return 0; 1953 return 0;
@@ -2155,15 +1969,14 @@ static const struct afs_call_type afs_RXFSFetchStatus = {
2155int afs_fs_fetch_status(struct afs_fs_cursor *fc, 1969int afs_fs_fetch_status(struct afs_fs_cursor *fc,
2156 struct afs_net *net, 1970 struct afs_net *net,
2157 struct afs_fid *fid, 1971 struct afs_fid *fid,
2158 struct afs_file_status *status, 1972 struct afs_status_cb *scb,
2159 struct afs_callback *callback,
2160 struct afs_volsync *volsync) 1973 struct afs_volsync *volsync)
2161{ 1974{
2162 struct afs_call *call; 1975 struct afs_call *call;
2163 __be32 *bp; 1976 __be32 *bp;
2164 1977
2165 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)) 1978 if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
2166 return yfs_fs_fetch_status(fc, net, fid, status, callback, volsync); 1979 return yfs_fs_fetch_status(fc, net, fid, scb, volsync);
2167 1980
2168 _enter(",%x,{%llx:%llu},,", 1981 _enter(",%x,{%llx:%llu},,",
2169 key_serial(fc->key), fid->vid, fid->vnode); 1982 key_serial(fc->key), fid->vid, fid->vnode);
@@ -2176,10 +1989,8 @@ int afs_fs_fetch_status(struct afs_fs_cursor *fc,
2176 1989
2177 call->key = fc->key; 1990 call->key = fc->key;
2178 call->out_fid = fid; 1991 call->out_fid = fid;
2179 call->out_vnode_status = status; 1992 call->out_scb = scb;
2180 call->out_cb = callback;
2181 call->out_volsync = volsync; 1993 call->out_volsync = volsync;
2182 call->expected_version = 1; /* vnode->status.data_version */
2183 1994
2184 /* marshall the parameters */ 1995 /* marshall the parameters */
2185 bp = call->request; 1996 bp = call->request;
@@ -2188,7 +1999,6 @@ int afs_fs_fetch_status(struct afs_fs_cursor *fc,
2188 bp[2] = htonl(fid->vnode); 1999 bp[2] = htonl(fid->vnode);
2189 bp[3] = htonl(fid->unique); 2000 bp[3] = htonl(fid->unique);
2190 2001
2191 call->cb_break = fc->cb_break;
2192 afs_use_fs_server(call, fc->cbi); 2002 afs_use_fs_server(call, fc->cbi);
2193 trace_afs_make_fs_call(call, fid); 2003 trace_afs_make_fs_call(call, fid);
2194 afs_set_fc_call(call, fc); 2004 afs_set_fc_call(call, fc);
@@ -2241,8 +2051,7 @@ static int afs_deliver_fs_inline_bulk_status(struct afs_call *call)
2241 2051
2242 bp = call->buffer; 2052 bp = call->buffer;
2243 scb = &call->out_scb[call->count]; 2053 scb = &call->out_scb[call->count];
2244 ret = afs_decode_status(call, &bp, &scb->status, 2054 ret = xdr_decode_AFSFetchStatus(&bp, call, scb);
2245 NULL, NULL, NULL);
2246 if (ret < 0) 2055 if (ret < 0)
2247 return ret; 2056 return ret;
2248 2057
@@ -2282,8 +2091,7 @@ static int afs_deliver_fs_inline_bulk_status(struct afs_call *call)
2282 _debug("unmarshall CB array"); 2091 _debug("unmarshall CB array");
2283 bp = call->buffer; 2092 bp = call->buffer;
2284 scb = &call->out_scb[call->count]; 2093 scb = &call->out_scb[call->count];
2285 xdr_decode_AFSCallBack_raw(call, &scb->callback, &bp); 2094 xdr_decode_AFSCallBack(&bp, call, scb);
2286 scb->have_cb = true;
2287 call->count++; 2095 call->count++;
2288 if (call->count < call->count2) 2096 if (call->count < call->count2)
2289 goto more_cbs; 2097 goto more_cbs;
@@ -2364,7 +2172,6 @@ int afs_fs_inline_bulk_status(struct afs_fs_cursor *fc,
2364 *bp++ = htonl(fids[i].unique); 2172 *bp++ = htonl(fids[i].unique);
2365 } 2173 }
2366 2174
2367 call->cb_break = fc->cb_break;
2368 afs_use_fs_server(call, fc->cbi); 2175 afs_use_fs_server(call, fc->cbi);
2369 trace_afs_make_fs_call(call, &fids[0]); 2176 trace_afs_make_fs_call(call, &fids[0]);
2370 afs_set_fc_call(call, fc); 2177 afs_set_fc_call(call, fc);
@@ -2377,7 +2184,6 @@ int afs_fs_inline_bulk_status(struct afs_fs_cursor *fc,
2377 */ 2184 */
2378static int afs_deliver_fs_fetch_acl(struct afs_call *call) 2185static int afs_deliver_fs_fetch_acl(struct afs_call *call)
2379{ 2186{
2380 struct afs_vnode *vnode = call->xvnode;
2381 struct afs_acl *acl; 2187 struct afs_acl *acl;
2382 const __be32 *bp; 2188 const __be32 *bp;
2383 unsigned int size; 2189 unsigned int size;
@@ -2423,8 +2229,7 @@ static int afs_deliver_fs_fetch_acl(struct afs_call *call)
2423 return ret; 2229 return ret;
2424 2230
2425 bp = call->buffer; 2231 bp = call->buffer;
2426 ret = afs_decode_status(call, &bp, &vnode->status, vnode, 2232 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
2427 &vnode->status.data_version, NULL);
2428 if (ret < 0) 2233 if (ret < 0)
2429 return ret; 2234 return ret;
2430 xdr_decode_AFSVolSync(&bp, call->out_volsync); 2235 xdr_decode_AFSVolSync(&bp, call->out_volsync);
@@ -2458,7 +2263,8 @@ static const struct afs_call_type afs_RXFSFetchACL = {
2458/* 2263/*
2459 * Fetch the ACL for a file. 2264 * Fetch the ACL for a file.
2460 */ 2265 */
2461struct afs_acl *afs_fs_fetch_acl(struct afs_fs_cursor *fc) 2266struct afs_acl *afs_fs_fetch_acl(struct afs_fs_cursor *fc,
2267 struct afs_status_cb *scb)
2462{ 2268{
2463 struct afs_vnode *vnode = fc->vnode; 2269 struct afs_vnode *vnode = fc->vnode;
2464 struct afs_call *call; 2270 struct afs_call *call;
@@ -2476,7 +2282,7 @@ struct afs_acl *afs_fs_fetch_acl(struct afs_fs_cursor *fc)
2476 2282
2477 call->key = fc->key; 2283 call->key = fc->key;
2478 call->ret_acl = NULL; 2284 call->ret_acl = NULL;
2479 call->xvnode = vnode; 2285 call->out_scb = scb;
2480 call->out_volsync = NULL; 2286 call->out_volsync = NULL;
2481 2287
2482 /* marshall the parameters */ 2288 /* marshall the parameters */
@@ -2486,7 +2292,6 @@ struct afs_acl *afs_fs_fetch_acl(struct afs_fs_cursor *fc)
2486 bp[2] = htonl(vnode->fid.vnode); 2292 bp[2] = htonl(vnode->fid.vnode);
2487 bp[3] = htonl(vnode->fid.unique); 2293 bp[3] = htonl(vnode->fid.unique);
2488 2294
2489 call->cb_break = fc->cb_break;
2490 afs_use_fs_server(call, fc->cbi); 2295 afs_use_fs_server(call, fc->cbi);
2491 trace_afs_make_fs_call(call, &vnode->fid); 2296 trace_afs_make_fs_call(call, &vnode->fid);
2492 afs_make_call(&fc->ac, call, GFP_KERNEL); 2297 afs_make_call(&fc->ac, call, GFP_KERNEL);
@@ -2499,20 +2304,15 @@ struct afs_acl *afs_fs_fetch_acl(struct afs_fs_cursor *fc)
2499 */ 2304 */
2500static int afs_deliver_fs_file_status_and_vol(struct afs_call *call) 2305static int afs_deliver_fs_file_status_and_vol(struct afs_call *call)
2501{ 2306{
2502 struct afs_vnode *vnode = call->xvnode;
2503 const __be32 *bp; 2307 const __be32 *bp;
2504 int ret; 2308 int ret;
2505 2309
2506 _enter("{%u}", call->unmarshall);
2507
2508 ret = afs_transfer_reply(call); 2310 ret = afs_transfer_reply(call);
2509 if (ret < 0) 2311 if (ret < 0)
2510 return ret; 2312 return ret;
2511 2313
2512 /* unmarshall the reply once we've received all of it */
2513 bp = call->buffer; 2314 bp = call->buffer;
2514 ret = afs_decode_status(call, &bp, &vnode->status, vnode, 2315 ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
2515 &call->expected_version, NULL);
2516 if (ret < 0) 2316 if (ret < 0)
2517 return ret; 2317 return ret;
2518 xdr_decode_AFSVolSync(&bp, call->out_volsync); 2318 xdr_decode_AFSVolSync(&bp, call->out_volsync);
@@ -2534,7 +2334,8 @@ static const struct afs_call_type afs_RXFSStoreACL = {
2534/* 2334/*
2535 * Fetch the ACL for a file. 2335 * Fetch the ACL for a file.
2536 */ 2336 */
2537int afs_fs_store_acl(struct afs_fs_cursor *fc, const struct afs_acl *acl) 2337int afs_fs_store_acl(struct afs_fs_cursor *fc, const struct afs_acl *acl,
2338 struct afs_status_cb *scb)
2538{ 2339{
2539 struct afs_vnode *vnode = fc->vnode; 2340 struct afs_vnode *vnode = fc->vnode;
2540 struct afs_call *call; 2341 struct afs_call *call;
@@ -2554,7 +2355,7 @@ int afs_fs_store_acl(struct afs_fs_cursor *fc, const struct afs_acl *acl)
2554 } 2355 }
2555 2356
2556 call->key = fc->key; 2357 call->key = fc->key;
2557 call->xvnode = vnode; 2358 call->out_scb = scb;
2558 call->out_volsync = NULL; 2359 call->out_volsync = NULL;
2559 2360
2560 /* marshall the parameters */ 2361 /* marshall the parameters */
diff --git a/fs/afs/inode.c b/fs/afs/inode.c
index bf8f56e851df..4a9004b9ac5f 100644
--- a/fs/afs/inode.c
+++ b/fs/afs/inode.c
@@ -58,38 +58,50 @@ static noinline void dump_vnode(struct afs_vnode *vnode, struct afs_vnode *paren
58 * Initialise an inode from the vnode status. 58 * Initialise an inode from the vnode status.
59 */ 59 */
60static int afs_inode_init_from_status(struct afs_vnode *vnode, struct key *key, 60static int afs_inode_init_from_status(struct afs_vnode *vnode, struct key *key,
61 struct afs_vnode *parent_vnode) 61 struct afs_cb_interest *cbi,
62 struct afs_vnode *parent_vnode,
63 struct afs_status_cb *scb)
62{ 64{
65 struct afs_cb_interest *old_cbi = NULL;
66 struct afs_file_status *status = &scb->status;
63 struct inode *inode = AFS_VNODE_TO_I(vnode); 67 struct inode *inode = AFS_VNODE_TO_I(vnode);
68 struct timespec64 t;
64 69
65 _debug("FS: ft=%d lk=%d sz=%llu ver=%Lu mod=%hu", 70 _debug("FS: ft=%d lk=%d sz=%llu ver=%Lu mod=%hu",
66 vnode->status.type, 71 status->type,
67 vnode->status.nlink, 72 status->nlink,
68 (unsigned long long) vnode->status.size, 73 (unsigned long long) status->size,
69 vnode->status.data_version, 74 status->data_version,
70 vnode->status.mode); 75 status->mode);
71 76
72 read_seqlock_excl(&vnode->cb_lock); 77 write_seqlock(&vnode->cb_lock);
78
79 vnode->status = *status;
73 80
74 afs_update_inode_from_status(vnode, &vnode->status, NULL, 81 t = status->mtime_client;
75 AFS_VNODE_NOT_YET_SET); 82 inode->i_ctime = t;
83 inode->i_mtime = t;
84 inode->i_atime = t;
85 inode->i_uid = make_kuid(&init_user_ns, status->owner);
86 inode->i_gid = make_kgid(&init_user_ns, status->group);
87 set_nlink(&vnode->vfs_inode, status->nlink);
76 88
77 switch (vnode->status.type) { 89 switch (status->type) {
78 case AFS_FTYPE_FILE: 90 case AFS_FTYPE_FILE:
79 inode->i_mode = S_IFREG | vnode->status.mode; 91 inode->i_mode = S_IFREG | status->mode;
80 inode->i_op = &afs_file_inode_operations; 92 inode->i_op = &afs_file_inode_operations;
81 inode->i_fop = &afs_file_operations; 93 inode->i_fop = &afs_file_operations;
82 inode->i_mapping->a_ops = &afs_fs_aops; 94 inode->i_mapping->a_ops = &afs_fs_aops;
83 break; 95 break;
84 case AFS_FTYPE_DIR: 96 case AFS_FTYPE_DIR:
85 inode->i_mode = S_IFDIR | vnode->status.mode; 97 inode->i_mode = S_IFDIR | status->mode;
86 inode->i_op = &afs_dir_inode_operations; 98 inode->i_op = &afs_dir_inode_operations;
87 inode->i_fop = &afs_dir_file_operations; 99 inode->i_fop = &afs_dir_file_operations;
88 inode->i_mapping->a_ops = &afs_dir_aops; 100 inode->i_mapping->a_ops = &afs_dir_aops;
89 break; 101 break;
90 case AFS_FTYPE_SYMLINK: 102 case AFS_FTYPE_SYMLINK:
91 /* Symlinks with a mode of 0644 are actually mountpoints. */ 103 /* Symlinks with a mode of 0644 are actually mountpoints. */
92 if ((vnode->status.mode & 0777) == 0644) { 104 if ((status->mode & 0777) == 0644) {
93 inode->i_flags |= S_AUTOMOUNT; 105 inode->i_flags |= S_AUTOMOUNT;
94 106
95 set_bit(AFS_VNODE_MOUNTPOINT, &vnode->flags); 107 set_bit(AFS_VNODE_MOUNTPOINT, &vnode->flags);
@@ -99,7 +111,7 @@ static int afs_inode_init_from_status(struct afs_vnode *vnode, struct key *key,
99 inode->i_fop = &afs_mntpt_file_operations; 111 inode->i_fop = &afs_mntpt_file_operations;
100 inode->i_mapping->a_ops = &afs_fs_aops; 112 inode->i_mapping->a_ops = &afs_fs_aops;
101 } else { 113 } else {
102 inode->i_mode = S_IFLNK | vnode->status.mode; 114 inode->i_mode = S_IFLNK | status->mode;
103 inode->i_op = &afs_symlink_inode_operations; 115 inode->i_op = &afs_symlink_inode_operations;
104 inode->i_mapping->a_ops = &afs_fs_aops; 116 inode->i_mapping->a_ops = &afs_fs_aops;
105 } 117 }
@@ -107,7 +119,7 @@ static int afs_inode_init_from_status(struct afs_vnode *vnode, struct key *key,
107 break; 119 break;
108 default: 120 default:
109 dump_vnode(vnode, parent_vnode); 121 dump_vnode(vnode, parent_vnode);
110 read_sequnlock_excl(&vnode->cb_lock); 122 write_sequnlock(&vnode->cb_lock);
111 return afs_protocol_error(NULL, -EBADMSG, afs_eproto_file_type); 123 return afs_protocol_error(NULL, -EBADMSG, afs_eproto_file_type);
112 } 124 }
113 125
@@ -116,17 +128,170 @@ static int afs_inode_init_from_status(struct afs_vnode *vnode, struct key *key,
116 * for consistency with other AFS clients. 128 * for consistency with other AFS clients.
117 */ 129 */
118 inode->i_blocks = ((i_size_read(inode) + 1023) >> 10) << 1; 130 inode->i_blocks = ((i_size_read(inode) + 1023) >> 10) << 1;
119 vnode->invalid_before = vnode->status.data_version; 131 i_size_write(&vnode->vfs_inode, status->size);
120 132
121 read_sequnlock_excl(&vnode->cb_lock); 133 vnode->invalid_before = status->data_version;
134 inode_set_iversion_raw(&vnode->vfs_inode, status->data_version);
135
136 if (!scb->have_cb) {
137 /* it's a symlink we just created (the fileserver
138 * didn't give us a callback) */
139 vnode->cb_version = 0;
140 vnode->cb_type = 0;
141 vnode->cb_expires_at = ktime_get_real_seconds();
142 } else {
143 vnode->cb_version = scb->callback.version;
144 vnode->cb_type = scb->callback.type;
145 vnode->cb_expires_at = scb->callback.expires_at;
146 old_cbi = vnode->cb_interest;
147 if (cbi != old_cbi)
148 vnode->cb_interest = afs_get_cb_interest(cbi);
149 else
150 old_cbi = NULL;
151 set_bit(AFS_VNODE_CB_PROMISED, &vnode->flags);
152 }
153
154 write_sequnlock(&vnode->cb_lock);
155 afs_put_cb_interest(afs_v2net(vnode), old_cbi);
122 return 0; 156 return 0;
123} 157}
124 158
125/* 159/*
160 * Update the core inode struct from a returned status record.
161 */
162static void afs_apply_status(struct afs_fs_cursor *fc,
163 struct afs_vnode *vnode,
164 struct afs_status_cb *scb,
165 const afs_dataversion_t *expected_version)
166{
167 struct afs_file_status *status = &scb->status;
168 struct timespec64 t;
169 umode_t mode;
170 bool data_changed = false;
171
172 BUG_ON(test_bit(AFS_VNODE_UNSET, &vnode->flags));
173
174 if (status->type != vnode->status.type) {
175 pr_warning("Vnode %llx:%llx:%x changed type %u to %u\n",
176 vnode->fid.vid,
177 vnode->fid.vnode,
178 vnode->fid.unique,
179 status->type, vnode->status.type);
180 afs_protocol_error(NULL, -EBADMSG, afs_eproto_bad_status);
181 return;
182 }
183
184 if (status->nlink != vnode->status.nlink)
185 set_nlink(&vnode->vfs_inode, status->nlink);
186
187 if (status->owner != vnode->status.owner)
188 vnode->vfs_inode.i_uid = make_kuid(&init_user_ns, status->owner);
189
190 if (status->group != vnode->status.group)
191 vnode->vfs_inode.i_gid = make_kgid(&init_user_ns, status->group);
192
193 if (status->mode != vnode->status.mode) {
194 mode = vnode->vfs_inode.i_mode;
195 mode &= ~S_IALLUGO;
196 mode |= status->mode;
197 WRITE_ONCE(vnode->vfs_inode.i_mode, mode);
198 }
199
200 t = status->mtime_client;
201 vnode->vfs_inode.i_ctime = t;
202 vnode->vfs_inode.i_mtime = t;
203 vnode->vfs_inode.i_atime = t;
204
205 if (vnode->status.data_version != status->data_version)
206 data_changed = true;
207
208 vnode->status = *status;
209
210 if (expected_version &&
211 *expected_version != status->data_version) {
212 kdebug("vnode modified %llx on {%llx:%llu} [exp %llx] %s",
213 (unsigned long long) status->data_version,
214 vnode->fid.vid, vnode->fid.vnode,
215 (unsigned long long) *expected_version,
216 fc->type ? fc->type->name : "???");
217 vnode->invalid_before = status->data_version;
218 if (vnode->status.type == AFS_FTYPE_DIR) {
219 if (test_and_clear_bit(AFS_VNODE_DIR_VALID, &vnode->flags))
220 afs_stat_v(vnode, n_inval);
221 } else {
222 set_bit(AFS_VNODE_ZAP_DATA, &vnode->flags);
223 }
224 } else if (vnode->status.type == AFS_FTYPE_DIR) {
225 /* Expected directory change is handled elsewhere so
226 * that we can locally edit the directory and save on a
227 * download.
228 */
229 if (test_bit(AFS_VNODE_DIR_VALID, &vnode->flags))
230 data_changed = false;
231 }
232
233 if (data_changed) {
234 inode_set_iversion_raw(&vnode->vfs_inode, status->data_version);
235 i_size_write(&vnode->vfs_inode, status->size);
236 }
237}
238
239/*
240 * Apply a callback to a vnode.
241 */
242static void afs_apply_callback(struct afs_fs_cursor *fc,
243 struct afs_vnode *vnode,
244 struct afs_status_cb *scb,
245 unsigned int cb_break)
246{
247 struct afs_cb_interest *old;
248 struct afs_callback *cb = &scb->callback;
249
250 if (!afs_cb_is_broken(cb_break, vnode, fc->cbi)) {
251 vnode->cb_version = cb->version;
252 vnode->cb_type = cb->type;
253 vnode->cb_expires_at = cb->expires_at;
254 old = vnode->cb_interest;
255 if (old != fc->cbi) {
256 vnode->cb_interest = afs_get_cb_interest(fc->cbi);
257 afs_put_cb_interest(afs_v2net(vnode), old);
258 }
259 set_bit(AFS_VNODE_CB_PROMISED, &vnode->flags);
260 }
261}
262
263/*
264 * Apply the received status and callback to an inode all in the same critical
265 * section to avoid races with afs_validate().
266 */
267void afs_vnode_commit_status(struct afs_fs_cursor *fc,
268 struct afs_vnode *vnode,
269 unsigned int cb_break,
270 const afs_dataversion_t *expected_version,
271 struct afs_status_cb *scb)
272{
273 if (fc->ac.error != 0)
274 return;
275
276 write_seqlock(&vnode->cb_lock);
277
278 afs_apply_status(fc, vnode, scb, expected_version);
279 if (scb->have_cb)
280 afs_apply_callback(fc, vnode, scb, cb_break);
281
282 write_sequnlock(&vnode->cb_lock);
283
284 if (fc->ac.error == 0)
285 afs_cache_permit(vnode, fc->key, cb_break, scb);
286}
287
288/*
126 * Fetch file status from the volume. 289 * Fetch file status from the volume.
127 */ 290 */
128int afs_fetch_status(struct afs_vnode *vnode, struct key *key, bool new_inode) 291int afs_fetch_status(struct afs_vnode *vnode, struct key *key, bool is_new,
292 afs_access_t *_caller_access)
129{ 293{
294 struct afs_status_cb *scb;
130 struct afs_fs_cursor fc; 295 struct afs_fs_cursor fc;
131 int ret; 296 int ret;
132 297
@@ -135,18 +300,38 @@ int afs_fetch_status(struct afs_vnode *vnode, struct key *key, bool new_inode)
135 vnode->fid.vid, vnode->fid.vnode, vnode->fid.unique, 300 vnode->fid.vid, vnode->fid.vnode, vnode->fid.unique,
136 vnode->flags); 301 vnode->flags);
137 302
303 scb = kzalloc(sizeof(struct afs_status_cb), GFP_KERNEL);
304 if (!scb)
305 return -ENOMEM;
306
138 ret = -ERESTARTSYS; 307 ret = -ERESTARTSYS;
139 if (afs_begin_vnode_operation(&fc, vnode, key, true)) { 308 if (afs_begin_vnode_operation(&fc, vnode, key, true)) {
309 afs_dataversion_t data_version = vnode->status.data_version;
310
140 while (afs_select_fileserver(&fc)) { 311 while (afs_select_fileserver(&fc)) {
141 fc.cb_break = afs_calc_vnode_cb_break(vnode); 312 fc.cb_break = afs_calc_vnode_cb_break(vnode);
142 afs_fs_fetch_file_status(&fc, NULL, new_inode); 313 afs_fs_fetch_file_status(&fc, scb, NULL);
143 } 314 }
144 315
145 afs_check_for_remote_deletion(&fc, fc.vnode); 316 if (fc.error) {
146 afs_vnode_commit_status(&fc, vnode, fc.cb_break); 317 /* Do nothing. */
318 } else if (is_new) {
319 ret = afs_inode_init_from_status(vnode, key, fc.cbi,
320 NULL, scb);
321 fc.error = ret;
322 if (ret == 0)
323 afs_cache_permit(vnode, key, fc.cb_break, scb);
324 } else {
325 afs_vnode_commit_status(&fc, vnode, fc.cb_break,
326 &data_version, scb);
327 }
328 afs_check_for_remote_deletion(&fc, vnode);
147 ret = afs_end_vnode_operation(&fc); 329 ret = afs_end_vnode_operation(&fc);
148 } 330 }
149 331
332 if (ret == 0 && _caller_access)
333 *_caller_access = scb->status.caller_access;
334 kfree(scb);
150 _leave(" = %d", ret); 335 _leave(" = %d", ret);
151 return ret; 336 return ret;
152} 337}
@@ -299,8 +484,8 @@ static void afs_get_inode_cache(struct afs_vnode *vnode)
299 * inode retrieval 484 * inode retrieval
300 */ 485 */
301struct inode *afs_iget(struct super_block *sb, struct key *key, 486struct inode *afs_iget(struct super_block *sb, struct key *key,
302 struct afs_fid *fid, struct afs_file_status *status, 487 struct afs_fid *fid, struct afs_status_cb *scb,
303 struct afs_callback *cb, struct afs_cb_interest *cbi, 488 struct afs_cb_interest *cbi,
304 struct afs_vnode *parent_vnode) 489 struct afs_vnode *parent_vnode)
305{ 490{
306 struct afs_iget_data data = { .fid = *fid }; 491 struct afs_iget_data data = { .fid = *fid };
@@ -332,36 +517,18 @@ struct inode *afs_iget(struct super_block *sb, struct key *key,
332 return inode; 517 return inode;
333 } 518 }
334 519
335 if (!status) { 520 if (!scb) {
336 /* it's a remotely extant inode */ 521 /* it's a remotely extant inode */
337 ret = afs_fetch_status(vnode, key, true); 522 ret = afs_fetch_status(vnode, key, true, NULL);
338 if (ret < 0) 523 if (ret < 0)
339 goto bad_inode; 524 goto bad_inode;
340 } else { 525 } else {
341 /* it's an inode we just created */ 526 ret = afs_inode_init_from_status(vnode, key, cbi, parent_vnode,
342 memcpy(&vnode->status, status, sizeof(vnode->status)); 527 scb);
343 528 if (ret < 0)
344 if (!cb) { 529 goto bad_inode;
345 /* it's a symlink we just created (the fileserver
346 * didn't give us a callback) */
347 vnode->cb_version = 0;
348 vnode->cb_type = 0;
349 vnode->cb_expires_at = ktime_get();
350 } else {
351 vnode->cb_version = cb->version;
352 vnode->cb_type = cb->type;
353 vnode->cb_expires_at = cb->expires_at;
354 vnode->cb_interest = afs_get_cb_interest(cbi);
355 set_bit(AFS_VNODE_CB_PROMISED, &vnode->flags);
356 }
357
358 vnode->cb_expires_at += ktime_get_real_seconds();
359 } 530 }
360 531
361 ret = afs_inode_init_from_status(vnode, key, parent_vnode);
362 if (ret < 0)
363 goto bad_inode;
364
365 afs_get_inode_cache(vnode); 532 afs_get_inode_cache(vnode);
366 533
367 /* success */ 534 /* success */
@@ -460,7 +627,7 @@ int afs_validate(struct afs_vnode *vnode, struct key *key)
460 * access */ 627 * access */
461 if (!test_bit(AFS_VNODE_CB_PROMISED, &vnode->flags)) { 628 if (!test_bit(AFS_VNODE_CB_PROMISED, &vnode->flags)) {
462 _debug("not promised"); 629 _debug("not promised");
463 ret = afs_fetch_status(vnode, key, false); 630 ret = afs_fetch_status(vnode, key, false, NULL);
464 if (ret < 0) { 631 if (ret < 0) {
465 if (ret == -ENOENT) { 632 if (ret == -ENOENT) {
466 set_bit(AFS_VNODE_DELETED, &vnode->flags); 633 set_bit(AFS_VNODE_DELETED, &vnode->flags);
@@ -585,9 +752,10 @@ void afs_evict_inode(struct inode *inode)
585int afs_setattr(struct dentry *dentry, struct iattr *attr) 752int afs_setattr(struct dentry *dentry, struct iattr *attr)
586{ 753{
587 struct afs_fs_cursor fc; 754 struct afs_fs_cursor fc;
755 struct afs_status_cb *scb;
588 struct afs_vnode *vnode = AFS_FS_I(d_inode(dentry)); 756 struct afs_vnode *vnode = AFS_FS_I(d_inode(dentry));
589 struct key *key; 757 struct key *key;
590 int ret; 758 int ret = -ENOMEM;
591 759
592 _enter("{%llx:%llu},{n=%pd},%x", 760 _enter("{%llx:%llu},{n=%pd},%x",
593 vnode->fid.vid, vnode->fid.vnode, dentry, 761 vnode->fid.vid, vnode->fid.vnode, dentry,
@@ -599,6 +767,10 @@ int afs_setattr(struct dentry *dentry, struct iattr *attr)
599 return 0; 767 return 0;
600 } 768 }
601 769
770 scb = kzalloc(sizeof(struct afs_status_cb), GFP_KERNEL);
771 if (!scb)
772 goto error;
773
602 /* flush any dirty data outstanding on a regular file */ 774 /* flush any dirty data outstanding on a regular file */
603 if (S_ISREG(vnode->vfs_inode.i_mode)) 775 if (S_ISREG(vnode->vfs_inode.i_mode))
604 filemap_write_and_wait(vnode->vfs_inode.i_mapping); 776 filemap_write_and_wait(vnode->vfs_inode.i_mapping);
@@ -609,25 +781,33 @@ int afs_setattr(struct dentry *dentry, struct iattr *attr)
609 key = afs_request_key(vnode->volume->cell); 781 key = afs_request_key(vnode->volume->cell);
610 if (IS_ERR(key)) { 782 if (IS_ERR(key)) {
611 ret = PTR_ERR(key); 783 ret = PTR_ERR(key);
612 goto error; 784 goto error_scb;
613 } 785 }
614 } 786 }
615 787
616 ret = -ERESTARTSYS; 788 ret = -ERESTARTSYS;
617 if (afs_begin_vnode_operation(&fc, vnode, key, false)) { 789 if (afs_begin_vnode_operation(&fc, vnode, key, false)) {
790 afs_dataversion_t data_version = vnode->status.data_version;
791
792 if (attr->ia_valid & ATTR_SIZE)
793 data_version++;
794
618 while (afs_select_fileserver(&fc)) { 795 while (afs_select_fileserver(&fc)) {
619 fc.cb_break = afs_calc_vnode_cb_break(vnode); 796 fc.cb_break = afs_calc_vnode_cb_break(vnode);
620 afs_fs_setattr(&fc, attr); 797 afs_fs_setattr(&fc, attr, scb);
621 } 798 }
622 799
623 afs_check_for_remote_deletion(&fc, fc.vnode); 800 afs_check_for_remote_deletion(&fc, vnode);
624 afs_vnode_commit_status(&fc, vnode, fc.cb_break); 801 afs_vnode_commit_status(&fc, vnode, fc.cb_break,
802 &data_version, scb);
625 ret = afs_end_vnode_operation(&fc); 803 ret = afs_end_vnode_operation(&fc);
626 } 804 }
627 805
628 if (!(attr->ia_valid & ATTR_FILE)) 806 if (!(attr->ia_valid & ATTR_FILE))
629 key_put(key); 807 key_put(key);
630 808
809error_scb:
810 kfree(scb);
631error: 811error:
632 _leave(" = %d", ret); 812 _leave(" = %d", ret);
633 return ret; 813 return ret;
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index 9b44307bd934..6ed7d4df4ec6 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -116,8 +116,7 @@ struct afs_call {
116 struct afs_vlserver *vlserver; 116 struct afs_vlserver *vlserver;
117 }; 117 };
118 struct afs_cb_interest *cbi; /* Callback interest for server used */ 118 struct afs_cb_interest *cbi; /* Callback interest for server used */
119 struct afs_vnode *dvnode; /* Directory vnode of call */ 119 struct afs_vnode *lvnode; /* vnode being locked */
120 struct afs_vnode *xvnode; /* Other vnode of call */
121 void *request; /* request data (first part) */ 120 void *request; /* request data (first part) */
122 struct address_space *mapping; /* Pages being written from */ 121 struct address_space *mapping; /* Pages being written from */
123 struct iov_iter iter; /* Buffer iterator */ 122 struct iov_iter iter; /* Buffer iterator */
@@ -134,9 +133,7 @@ struct afs_call {
134 struct afs_acl *ret_acl; 133 struct afs_acl *ret_acl;
135 }; 134 };
136 struct afs_fid *out_fid; 135 struct afs_fid *out_fid;
137 struct afs_file_status *out_vnode_status; 136 struct afs_status_cb *out_dir_scb;
138 struct afs_file_status *out_extra_status;
139 struct afs_callback *out_cb;
140 struct afs_status_cb *out_scb; 137 struct afs_status_cb *out_scb;
141 struct yfs_acl *out_yacl; 138 struct yfs_acl *out_yacl;
142 struct afs_volsync *out_volsync; 139 struct afs_volsync *out_volsync;
@@ -155,7 +152,6 @@ struct afs_call {
155 unsigned request_size; /* size of request data */ 152 unsigned request_size; /* size of request data */
156 unsigned reply_max; /* maximum size of reply */ 153 unsigned reply_max; /* maximum size of reply */
157 unsigned first_offset; /* offset into mapping[first] */ 154 unsigned first_offset; /* offset into mapping[first] */
158 unsigned int cb_break; /* cb_break + cb_s_break before the call */
159 union { 155 union {
160 unsigned last_to; /* amount of mapping[last] */ 156 unsigned last_to; /* amount of mapping[last] */
161 unsigned count2; /* count used in unmarshalling */ 157 unsigned count2; /* count used in unmarshalling */
@@ -180,8 +176,6 @@ struct afs_call {
180 } __attribute__((packed)); 176 } __attribute__((packed));
181 __be64 tmp64; 177 __be64 tmp64;
182 }; 178 };
183 afs_dataversion_t expected_version; /* Updated version expected from store */
184 afs_dataversion_t expected_version_2; /* 2nd updated version expected from store */
185 ktime_t reply_time; /* Time of first reply packet */ 179 ktime_t reply_time; /* Time of first reply packet */
186}; 180};
187 181
@@ -242,7 +236,8 @@ struct afs_read {
242 unsigned int index; /* Which page we're reading into */ 236 unsigned int index; /* Which page we're reading into */
243 unsigned int nr_pages; 237 unsigned int nr_pages;
244 unsigned int offset; /* offset into current page */ 238 unsigned int offset; /* offset into current page */
245 void (*page_done)(struct afs_call *, struct afs_read *); 239 struct afs_vnode *vnode;
240 void (*page_done)(struct afs_read *);
246 struct page **pages; 241 struct page **pages;
247 struct page *array[]; 242 struct page *array[];
248}; 243};
@@ -776,6 +771,7 @@ struct afs_vl_cursor {
776 * Cursor for iterating over a set of fileservers. 771 * Cursor for iterating over a set of fileservers.
777 */ 772 */
778struct afs_fs_cursor { 773struct afs_fs_cursor {
774 const struct afs_call_type *type; /* Type of call done */
779 struct afs_addr_cursor ac; 775 struct afs_addr_cursor ac;
780 struct afs_vnode *vnode; 776 struct afs_vnode *vnode;
781 struct afs_server_list *server_list; /* Current server list (pins ref) */ 777 struct afs_server_list *server_list; /* Current server list (pins ref) */
@@ -962,30 +958,28 @@ extern int afs_flock(struct file *, int, struct file_lock *);
962/* 958/*
963 * fsclient.c 959 * fsclient.c
964 */ 960 */
965#define AFS_VNODE_NOT_YET_SET 0x01 961extern int afs_fs_fetch_file_status(struct afs_fs_cursor *, struct afs_status_cb *,
966#define AFS_VNODE_META_CHANGED 0x02 962 struct afs_volsync *);
967#define AFS_VNODE_DATA_CHANGED 0x04
968extern void afs_update_inode_from_status(struct afs_vnode *, struct afs_file_status *,
969 const afs_dataversion_t *, u8);
970
971extern int afs_fs_fetch_file_status(struct afs_fs_cursor *, struct afs_volsync *, bool);
972extern int afs_fs_give_up_callbacks(struct afs_net *, struct afs_server *); 963extern int afs_fs_give_up_callbacks(struct afs_net *, struct afs_server *);
973extern int afs_fs_fetch_data(struct afs_fs_cursor *, struct afs_read *); 964extern int afs_fs_fetch_data(struct afs_fs_cursor *, struct afs_status_cb *, struct afs_read *);
974extern int afs_fs_create(struct afs_fs_cursor *, const char *, umode_t, u64, 965extern int afs_fs_create(struct afs_fs_cursor *, const char *, umode_t,
975 struct afs_fid *, struct afs_file_status *, struct afs_callback *); 966 struct afs_status_cb *, struct afs_fid *, struct afs_status_cb *);
976extern int afs_fs_remove(struct afs_fs_cursor *, struct afs_vnode *, const char *, bool, u64); 967extern int afs_fs_remove(struct afs_fs_cursor *, struct afs_vnode *, const char *, bool,
977extern int afs_fs_link(struct afs_fs_cursor *, struct afs_vnode *, const char *, u64); 968 struct afs_status_cb *);
978extern int afs_fs_symlink(struct afs_fs_cursor *, const char *, const char *, u64, 969extern int afs_fs_link(struct afs_fs_cursor *, struct afs_vnode *, const char *,
979 struct afs_fid *, struct afs_file_status *); 970 struct afs_status_cb *, struct afs_status_cb *);
971extern int afs_fs_symlink(struct afs_fs_cursor *, const char *, const char *,
972 struct afs_status_cb *, struct afs_fid *, struct afs_status_cb *);
980extern int afs_fs_rename(struct afs_fs_cursor *, const char *, 973extern int afs_fs_rename(struct afs_fs_cursor *, const char *,
981 struct afs_vnode *, const char *, u64, u64); 974 struct afs_vnode *, const char *,
975 struct afs_status_cb *, struct afs_status_cb *);
982extern int afs_fs_store_data(struct afs_fs_cursor *, struct address_space *, 976extern int afs_fs_store_data(struct afs_fs_cursor *, struct address_space *,
983 pgoff_t, pgoff_t, unsigned, unsigned); 977 pgoff_t, pgoff_t, unsigned, unsigned, struct afs_status_cb *);
984extern int afs_fs_setattr(struct afs_fs_cursor *, struct iattr *); 978extern int afs_fs_setattr(struct afs_fs_cursor *, struct iattr *, struct afs_status_cb *);
985extern int afs_fs_get_volume_status(struct afs_fs_cursor *, struct afs_volume_status *); 979extern int afs_fs_get_volume_status(struct afs_fs_cursor *, struct afs_volume_status *);
986extern int afs_fs_set_lock(struct afs_fs_cursor *, afs_lock_type_t); 980extern int afs_fs_set_lock(struct afs_fs_cursor *, afs_lock_type_t, struct afs_status_cb *);
987extern int afs_fs_extend_lock(struct afs_fs_cursor *); 981extern int afs_fs_extend_lock(struct afs_fs_cursor *, struct afs_status_cb *);
988extern int afs_fs_release_lock(struct afs_fs_cursor *); 982extern int afs_fs_release_lock(struct afs_fs_cursor *, struct afs_status_cb *);
989extern int afs_fs_give_up_all_callbacks(struct afs_net *, struct afs_server *, 983extern int afs_fs_give_up_all_callbacks(struct afs_net *, struct afs_server *,
990 struct afs_addr_cursor *, struct key *); 984 struct afs_addr_cursor *, struct key *);
991extern struct afs_call *afs_fs_get_capabilities(struct afs_net *, struct afs_server *, 985extern struct afs_call *afs_fs_get_capabilities(struct afs_net *, struct afs_server *,
@@ -995,16 +989,17 @@ extern int afs_fs_inline_bulk_status(struct afs_fs_cursor *, struct afs_net *,
995 struct afs_fid *, struct afs_status_cb *, 989 struct afs_fid *, struct afs_status_cb *,
996 unsigned int, struct afs_volsync *); 990 unsigned int, struct afs_volsync *);
997extern int afs_fs_fetch_status(struct afs_fs_cursor *, struct afs_net *, 991extern int afs_fs_fetch_status(struct afs_fs_cursor *, struct afs_net *,
998 struct afs_fid *, struct afs_file_status *, 992 struct afs_fid *, struct afs_status_cb *,
999 struct afs_callback *, struct afs_volsync *); 993 struct afs_volsync *);
1000 994
1001struct afs_acl { 995struct afs_acl {
1002 u32 size; 996 u32 size;
1003 u8 data[]; 997 u8 data[];
1004}; 998};
1005 999
1006extern struct afs_acl *afs_fs_fetch_acl(struct afs_fs_cursor *); 1000extern struct afs_acl *afs_fs_fetch_acl(struct afs_fs_cursor *, struct afs_status_cb *);
1007extern int afs_fs_store_acl(struct afs_fs_cursor *, const struct afs_acl *); 1001extern int afs_fs_store_acl(struct afs_fs_cursor *, const struct afs_acl *,
1002 struct afs_status_cb *);
1008 1003
1009/* 1004/*
1010 * fs_probe.c 1005 * fs_probe.c
@@ -1016,12 +1011,16 @@ extern int afs_wait_for_fs_probes(struct afs_server_list *, unsigned long);
1016/* 1011/*
1017 * inode.c 1012 * inode.c
1018 */ 1013 */
1019extern int afs_fetch_status(struct afs_vnode *, struct key *, bool); 1014extern void afs_vnode_commit_status(struct afs_fs_cursor *,
1015 struct afs_vnode *,
1016 unsigned int,
1017 const afs_dataversion_t *,
1018 struct afs_status_cb *);
1019extern int afs_fetch_status(struct afs_vnode *, struct key *, bool, afs_access_t *);
1020extern int afs_iget5_test(struct inode *, void *); 1020extern int afs_iget5_test(struct inode *, void *);
1021extern struct inode *afs_iget_pseudo_dir(struct super_block *, bool); 1021extern struct inode *afs_iget_pseudo_dir(struct super_block *, bool);
1022extern struct inode *afs_iget(struct super_block *, struct key *, 1022extern struct inode *afs_iget(struct super_block *, struct key *,
1023 struct afs_fid *, struct afs_file_status *, 1023 struct afs_fid *, struct afs_status_cb *,
1024 struct afs_callback *,
1025 struct afs_cb_interest *, 1024 struct afs_cb_interest *,
1026 struct afs_vnode *); 1025 struct afs_vnode *);
1027extern void afs_zap_data(struct afs_vnode *); 1026extern void afs_zap_data(struct afs_vnode *);
@@ -1145,6 +1144,7 @@ extern int afs_protocol_error(struct afs_call *, int, enum afs_eproto_cause);
1145static inline void afs_set_fc_call(struct afs_call *call, struct afs_fs_cursor *fc) 1144static inline void afs_set_fc_call(struct afs_call *call, struct afs_fs_cursor *fc)
1146{ 1145{
1147 call->intr = fc->flags & AFS_FS_CURSOR_INTR; 1146 call->intr = fc->flags & AFS_FS_CURSOR_INTR;
1147 fc->type = call->type;
1148} 1148}
1149 1149
1150static inline void afs_extract_begin(struct afs_call *call, void *buf, size_t size) 1150static inline void afs_extract_begin(struct afs_call *call, void *buf, size_t size)
@@ -1227,7 +1227,8 @@ static inline void afs_set_call_complete(struct afs_call *call,
1227 */ 1227 */
1228extern void afs_put_permits(struct afs_permits *); 1228extern void afs_put_permits(struct afs_permits *);
1229extern void afs_clear_permits(struct afs_vnode *); 1229extern void afs_clear_permits(struct afs_vnode *);
1230extern void afs_cache_permit(struct afs_vnode *, struct key *, unsigned int); 1230extern void afs_cache_permit(struct afs_vnode *, struct key *, unsigned int,
1231 struct afs_status_cb *);
1231extern void afs_zap_permits(struct rcu_head *); 1232extern void afs_zap_permits(struct rcu_head *);
1232extern struct key *afs_request_key(struct afs_cell *); 1233extern struct key *afs_request_key(struct afs_cell *);
1233extern int afs_check_permit(struct afs_vnode *, struct key *, afs_access_t *); 1234extern int afs_check_permit(struct afs_vnode *, struct key *, afs_access_t *);
@@ -1353,7 +1354,6 @@ extern int afs_write_end(struct file *file, struct address_space *mapping,
1353 struct page *page, void *fsdata); 1354 struct page *page, void *fsdata);
1354extern int afs_writepage(struct page *, struct writeback_control *); 1355extern int afs_writepage(struct page *, struct writeback_control *);
1355extern int afs_writepages(struct address_space *, struct writeback_control *); 1356extern int afs_writepages(struct address_space *, struct writeback_control *);
1356extern void afs_pages_written_back(struct afs_vnode *, struct afs_call *);
1357extern ssize_t afs_file_write(struct kiocb *, struct iov_iter *); 1357extern ssize_t afs_file_write(struct kiocb *, struct iov_iter *);
1358extern int afs_fsync(struct file *, loff_t, loff_t, int); 1358extern int afs_fsync(struct file *, loff_t, loff_t, int);
1359extern vm_fault_t afs_page_mkwrite(struct vm_fault *vmf); 1359extern vm_fault_t afs_page_mkwrite(struct vm_fault *vmf);
@@ -1369,29 +1369,33 @@ extern ssize_t afs_listxattr(struct dentry *, char *, size_t);
1369/* 1369/*
1370 * yfsclient.c 1370 * yfsclient.c
1371 */ 1371 */
1372extern int yfs_fs_fetch_file_status(struct afs_fs_cursor *, struct afs_volsync *, bool); 1372extern int yfs_fs_fetch_file_status(struct afs_fs_cursor *, struct afs_status_cb *,
1373extern int yfs_fs_fetch_data(struct afs_fs_cursor *, struct afs_read *); 1373 struct afs_volsync *);
1374extern int yfs_fs_create_file(struct afs_fs_cursor *, const char *, umode_t, u64, 1374extern int yfs_fs_fetch_data(struct afs_fs_cursor *, struct afs_status_cb *, struct afs_read *);
1375 struct afs_fid *, struct afs_file_status *, struct afs_callback *); 1375extern int yfs_fs_create_file(struct afs_fs_cursor *, const char *, umode_t, struct afs_status_cb *,
1376extern int yfs_fs_make_dir(struct afs_fs_cursor *, const char *, umode_t, u64, 1376 struct afs_fid *, struct afs_status_cb *);
1377 struct afs_fid *, struct afs_file_status *, struct afs_callback *); 1377extern int yfs_fs_make_dir(struct afs_fs_cursor *, const char *, umode_t, struct afs_status_cb *,
1378extern int yfs_fs_remove_file2(struct afs_fs_cursor *, struct afs_vnode *, const char *, u64); 1378 struct afs_fid *, struct afs_status_cb *);
1379extern int yfs_fs_remove(struct afs_fs_cursor *, struct afs_vnode *, const char *, bool, u64); 1379extern int yfs_fs_remove_file2(struct afs_fs_cursor *, struct afs_vnode *, const char *,
1380extern int yfs_fs_link(struct afs_fs_cursor *, struct afs_vnode *, const char *, u64); 1380 struct afs_status_cb *, struct afs_status_cb *);
1381extern int yfs_fs_symlink(struct afs_fs_cursor *, const char *, const char *, u64, 1381extern int yfs_fs_remove(struct afs_fs_cursor *, struct afs_vnode *, const char *, bool,
1382 struct afs_fid *, struct afs_file_status *); 1382 struct afs_status_cb *);
1383extern int yfs_fs_rename(struct afs_fs_cursor *, const char *, 1383extern int yfs_fs_link(struct afs_fs_cursor *, struct afs_vnode *, const char *,
1384 struct afs_vnode *, const char *, u64, u64); 1384 struct afs_status_cb *, struct afs_status_cb *);
1385extern int yfs_fs_symlink(struct afs_fs_cursor *, const char *, const char *,
1386 struct afs_status_cb *, struct afs_fid *, struct afs_status_cb *);
1387extern int yfs_fs_rename(struct afs_fs_cursor *, const char *, struct afs_vnode *, const char *,
1388 struct afs_status_cb *, struct afs_status_cb *);
1385extern int yfs_fs_store_data(struct afs_fs_cursor *, struct address_space *, 1389extern int yfs_fs_store_data(struct afs_fs_cursor *, struct address_space *,
1386 pgoff_t, pgoff_t, unsigned, unsigned); 1390 pgoff_t, pgoff_t, unsigned, unsigned, struct afs_status_cb *);
1387extern int yfs_fs_setattr(struct afs_fs_cursor *, struct iattr *); 1391extern int yfs_fs_setattr(struct afs_fs_cursor *, struct iattr *, struct afs_status_cb *);
1388extern int yfs_fs_get_volume_status(struct afs_fs_cursor *, struct afs_volume_status *); 1392extern int yfs_fs_get_volume_status(struct afs_fs_cursor *, struct afs_volume_status *);
1389extern int yfs_fs_set_lock(struct afs_fs_cursor *, afs_lock_type_t); 1393extern int yfs_fs_set_lock(struct afs_fs_cursor *, afs_lock_type_t, struct afs_status_cb *);
1390extern int yfs_fs_extend_lock(struct afs_fs_cursor *); 1394extern int yfs_fs_extend_lock(struct afs_fs_cursor *, struct afs_status_cb *);
1391extern int yfs_fs_release_lock(struct afs_fs_cursor *); 1395extern int yfs_fs_release_lock(struct afs_fs_cursor *, struct afs_status_cb *);
1392extern int yfs_fs_fetch_status(struct afs_fs_cursor *, struct afs_net *, 1396extern int yfs_fs_fetch_status(struct afs_fs_cursor *, struct afs_net *,
1393 struct afs_fid *, struct afs_file_status *, 1397 struct afs_fid *, struct afs_status_cb *,
1394 struct afs_callback *, struct afs_volsync *); 1398 struct afs_volsync *);
1395extern int yfs_fs_inline_bulk_status(struct afs_fs_cursor *, struct afs_net *, 1399extern int yfs_fs_inline_bulk_status(struct afs_fs_cursor *, struct afs_net *,
1396 struct afs_fid *, struct afs_status_cb *, 1400 struct afs_fid *, struct afs_status_cb *,
1397 unsigned int, struct afs_volsync *); 1401 unsigned int, struct afs_volsync *);
@@ -1407,8 +1411,10 @@ struct yfs_acl {
1407}; 1411};
1408 1412
1409extern void yfs_free_opaque_acl(struct yfs_acl *); 1413extern void yfs_free_opaque_acl(struct yfs_acl *);
1410extern struct yfs_acl *yfs_fs_fetch_opaque_acl(struct afs_fs_cursor *, struct yfs_acl *); 1414extern struct yfs_acl *yfs_fs_fetch_opaque_acl(struct afs_fs_cursor *, struct yfs_acl *,
1411extern int yfs_fs_store_opaque_acl2(struct afs_fs_cursor *, const struct afs_acl *); 1415 struct afs_status_cb *);
1416extern int yfs_fs_store_opaque_acl2(struct afs_fs_cursor *, const struct afs_acl *,
1417 struct afs_status_cb *);
1412 1418
1413/* 1419/*
1414 * Miscellaneous inline functions. 1420 * Miscellaneous inline functions.
@@ -1423,14 +1429,6 @@ static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode)
1423 return &vnode->vfs_inode; 1429 return &vnode->vfs_inode;
1424} 1430}
1425 1431
1426static inline void afs_vnode_commit_status(struct afs_fs_cursor *fc,
1427 struct afs_vnode *vnode,
1428 unsigned int cb_break)
1429{
1430 if (fc->ac.error == 0)
1431 afs_cache_permit(vnode, fc->key, cb_break);
1432}
1433
1434static inline void afs_check_for_remote_deletion(struct afs_fs_cursor *fc, 1432static inline void afs_check_for_remote_deletion(struct afs_fs_cursor *fc,
1435 struct afs_vnode *vnode) 1433 struct afs_vnode *vnode)
1436{ 1434{
diff --git a/fs/afs/security.c b/fs/afs/security.c
index db5529e47eb8..857f09d09ee9 100644
--- a/fs/afs/security.c
+++ b/fs/afs/security.c
@@ -116,10 +116,10 @@ static void afs_hash_permits(struct afs_permits *permits)
116 * as the ACL *may* have changed. 116 * as the ACL *may* have changed.
117 */ 117 */
118void afs_cache_permit(struct afs_vnode *vnode, struct key *key, 118void afs_cache_permit(struct afs_vnode *vnode, struct key *key,
119 unsigned int cb_break) 119 unsigned int cb_break, struct afs_status_cb *scb)
120{ 120{
121 struct afs_permits *permits, *xpermits, *replacement, *zap, *new = NULL; 121 struct afs_permits *permits, *xpermits, *replacement, *zap, *new = NULL;
122 afs_access_t caller_access = READ_ONCE(vnode->status.caller_access); 122 afs_access_t caller_access = scb->status.caller_access;
123 size_t size = 0; 123 size_t size = 0;
124 bool changed = false; 124 bool changed = false;
125 int i, j; 125 int i, j;
@@ -320,13 +320,12 @@ int afs_check_permit(struct afs_vnode *vnode, struct key *key,
320 */ 320 */
321 _debug("no valid permit"); 321 _debug("no valid permit");
322 322
323 ret = afs_fetch_status(vnode, key, false); 323 ret = afs_fetch_status(vnode, key, false, _access);
324 if (ret < 0) { 324 if (ret < 0) {
325 *_access = 0; 325 *_access = 0;
326 _leave(" = %d", ret); 326 _leave(" = %d", ret);
327 return ret; 327 return ret;
328 } 328 }
329 *_access = vnode->status.caller_access;
330 } 329 }
331 330
332 _leave(" = 0 [access %x]", *_access); 331 _leave(" = 0 [access %x]", *_access);
diff --git a/fs/afs/super.c b/fs/afs/super.c
index 3df11eede7f4..f45a95eea237 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -455,7 +455,7 @@ static int afs_fill_super(struct super_block *sb, struct afs_fs_context *ctx)
455 fid.vnode = 1; 455 fid.vnode = 1;
456 fid.vnode_hi = 0; 456 fid.vnode_hi = 0;
457 fid.unique = 1; 457 fid.unique = 1;
458 inode = afs_iget(sb, ctx->key, &fid, NULL, NULL, NULL, NULL); 458 inode = afs_iget(sb, ctx->key, &fid, NULL, NULL, NULL);
459 } 459 }
460 460
461 if (IS_ERR(inode)) 461 if (IS_ERR(inode))
@@ -749,7 +749,6 @@ static int afs_statfs(struct dentry *dentry, struct kstatfs *buf)
749 } 749 }
750 750
751 afs_check_for_remote_deletion(&fc, fc.vnode); 751 afs_check_for_remote_deletion(&fc, fc.vnode);
752 afs_vnode_commit_status(&fc, vnode, fc.cb_break);
753 ret = afs_end_vnode_operation(&fc); 752 ret = afs_end_vnode_operation(&fc);
754 } 753 }
755 754
diff --git a/fs/afs/write.c b/fs/afs/write.c
index e669f2fae873..8bcab95f1127 100644
--- a/fs/afs/write.c
+++ b/fs/afs/write.c
@@ -314,6 +314,46 @@ static void afs_redirty_pages(struct writeback_control *wbc,
314} 314}
315 315
316/* 316/*
317 * completion of write to server
318 */
319static void afs_pages_written_back(struct afs_vnode *vnode,
320 pgoff_t first, pgoff_t last)
321{
322 struct pagevec pv;
323 unsigned long priv;
324 unsigned count, loop;
325
326 _enter("{%llx:%llu},{%lx-%lx}",
327 vnode->fid.vid, vnode->fid.vnode, first, last);
328
329 pagevec_init(&pv);
330
331 do {
332 _debug("done %lx-%lx", first, last);
333
334 count = last - first + 1;
335 if (count > PAGEVEC_SIZE)
336 count = PAGEVEC_SIZE;
337 pv.nr = find_get_pages_contig(vnode->vfs_inode.i_mapping,
338 first, count, pv.pages);
339 ASSERTCMP(pv.nr, ==, count);
340
341 for (loop = 0; loop < count; loop++) {
342 priv = page_private(pv.pages[loop]);
343 trace_afs_page_dirty(vnode, tracepoint_string("clear"),
344 pv.pages[loop]->index, priv);
345 set_page_private(pv.pages[loop], 0);
346 end_page_writeback(pv.pages[loop]);
347 }
348 first += count;
349 __pagevec_release(&pv);
350 } while (first <= last);
351
352 afs_prune_wb_keys(vnode);
353 _leave("");
354}
355
356/*
317 * write to a file 357 * write to a file
318 */ 358 */
319static int afs_store_data(struct address_space *mapping, 359static int afs_store_data(struct address_space *mapping,
@@ -322,6 +362,7 @@ static int afs_store_data(struct address_space *mapping,
322{ 362{
323 struct afs_vnode *vnode = AFS_FS_I(mapping->host); 363 struct afs_vnode *vnode = AFS_FS_I(mapping->host);
324 struct afs_fs_cursor fc; 364 struct afs_fs_cursor fc;
365 struct afs_status_cb *scb;
325 struct afs_wb_key *wbk = NULL; 366 struct afs_wb_key *wbk = NULL;
326 struct list_head *p; 367 struct list_head *p;
327 int ret = -ENOKEY, ret2; 368 int ret = -ENOKEY, ret2;
@@ -333,6 +374,10 @@ static int afs_store_data(struct address_space *mapping,
333 vnode->fid.unique, 374 vnode->fid.unique,
334 first, last, offset, to); 375 first, last, offset, to);
335 376
377 scb = kzalloc(sizeof(struct afs_status_cb), GFP_NOFS);
378 if (!scb)
379 return -ENOMEM;
380
336 spin_lock(&vnode->wb_lock); 381 spin_lock(&vnode->wb_lock);
337 p = vnode->wb_keys.next; 382 p = vnode->wb_keys.next;
338 383
@@ -351,6 +396,7 @@ try_next_key:
351 396
352 spin_unlock(&vnode->wb_lock); 397 spin_unlock(&vnode->wb_lock);
353 afs_put_wb_key(wbk); 398 afs_put_wb_key(wbk);
399 kfree(scb);
354 _leave(" = %d [no keys]", ret); 400 _leave(" = %d [no keys]", ret);
355 return ret; 401 return ret;
356 402
@@ -362,13 +408,18 @@ found_key:
362 408
363 ret = -ERESTARTSYS; 409 ret = -ERESTARTSYS;
364 if (afs_begin_vnode_operation(&fc, vnode, wbk->key, false)) { 410 if (afs_begin_vnode_operation(&fc, vnode, wbk->key, false)) {
411 afs_dataversion_t data_version = vnode->status.data_version + 1;
412
365 while (afs_select_fileserver(&fc)) { 413 while (afs_select_fileserver(&fc)) {
366 fc.cb_break = afs_calc_vnode_cb_break(vnode); 414 fc.cb_break = afs_calc_vnode_cb_break(vnode);
367 afs_fs_store_data(&fc, mapping, first, last, offset, to); 415 afs_fs_store_data(&fc, mapping, first, last, offset, to, scb);
368 } 416 }
369 417
370 afs_check_for_remote_deletion(&fc, fc.vnode); 418 afs_check_for_remote_deletion(&fc, vnode);
371 afs_vnode_commit_status(&fc, vnode, fc.cb_break); 419 afs_vnode_commit_status(&fc, vnode, fc.cb_break,
420 &data_version, scb);
421 if (fc.ac.error == 0)
422 afs_pages_written_back(vnode, first, last);
372 ret = afs_end_vnode_operation(&fc); 423 ret = afs_end_vnode_operation(&fc);
373 } 424 }
374 425
@@ -393,6 +444,7 @@ found_key:
393 } 444 }
394 445
395 afs_put_wb_key(wbk); 446 afs_put_wb_key(wbk);
447 kfree(scb);
396 _leave(" = %d", ret); 448 _leave(" = %d", ret);
397 return ret; 449 return ret;
398} 450}
@@ -679,46 +731,6 @@ int afs_writepages(struct address_space *mapping,
679} 731}
680 732
681/* 733/*
682 * completion of write to server
683 */
684void afs_pages_written_back(struct afs_vnode *vnode, struct afs_call *call)
685{
686 struct pagevec pv;
687 unsigned long priv;
688 unsigned count, loop;
689 pgoff_t first = call->first, last = call->last;
690
691 _enter("{%llx:%llu},{%lx-%lx}",
692 vnode->fid.vid, vnode->fid.vnode, first, last);
693
694 pagevec_init(&pv);
695
696 do {
697 _debug("done %lx-%lx", first, last);
698
699 count = last - first + 1;
700 if (count > PAGEVEC_SIZE)
701 count = PAGEVEC_SIZE;
702 pv.nr = find_get_pages_contig(vnode->vfs_inode.i_mapping,
703 first, count, pv.pages);
704 ASSERTCMP(pv.nr, ==, count);
705
706 for (loop = 0; loop < count; loop++) {
707 priv = page_private(pv.pages[loop]);
708 trace_afs_page_dirty(vnode, tracepoint_string("clear"),
709 pv.pages[loop]->index, priv);
710 set_page_private(pv.pages[loop], 0);
711 end_page_writeback(pv.pages[loop]);
712 }
713 first += count;
714 __pagevec_release(&pv);
715 } while (first <= last);
716
717 afs_prune_wb_keys(vnode);
718 _leave("");
719}
720
721/*
722 * write to an AFS file 734 * write to an AFS file
723 */ 735 */
724ssize_t afs_file_write(struct kiocb *iocb, struct iov_iter *from) 736ssize_t afs_file_write(struct kiocb *iocb, struct iov_iter *from)
diff --git a/fs/afs/xattr.c b/fs/afs/xattr.c
index e13b005fac42..17f58fea7ec1 100644
--- a/fs/afs/xattr.c
+++ b/fs/afs/xattr.c
@@ -47,24 +47,34 @@ static int afs_xattr_get_acl(const struct xattr_handler *handler,
47 void *buffer, size_t size) 47 void *buffer, size_t size)
48{ 48{
49 struct afs_fs_cursor fc; 49 struct afs_fs_cursor fc;
50 struct afs_status_cb *scb;
50 struct afs_vnode *vnode = AFS_FS_I(inode); 51 struct afs_vnode *vnode = AFS_FS_I(inode);
51 struct afs_acl *acl = NULL; 52 struct afs_acl *acl = NULL;
52 struct key *key; 53 struct key *key;
53 int ret; 54 int ret = -ENOMEM;
55
56 scb = kzalloc(sizeof(struct afs_status_cb), GFP_NOFS);
57 if (!scb)
58 goto error;
54 59
55 key = afs_request_key(vnode->volume->cell); 60 key = afs_request_key(vnode->volume->cell);
56 if (IS_ERR(key)) 61 if (IS_ERR(key)) {
57 return PTR_ERR(key); 62 ret = PTR_ERR(key);
63 goto error_scb;
64 }
58 65
59 ret = -ERESTARTSYS; 66 ret = -ERESTARTSYS;
60 if (afs_begin_vnode_operation(&fc, vnode, key, true)) { 67 if (afs_begin_vnode_operation(&fc, vnode, key, true)) {
68 afs_dataversion_t data_version = vnode->status.data_version;
69
61 while (afs_select_fileserver(&fc)) { 70 while (afs_select_fileserver(&fc)) {
62 fc.cb_break = afs_calc_vnode_cb_break(vnode); 71 fc.cb_break = afs_calc_vnode_cb_break(vnode);
63 acl = afs_fs_fetch_acl(&fc); 72 acl = afs_fs_fetch_acl(&fc, scb);
64 } 73 }
65 74
66 afs_check_for_remote_deletion(&fc, fc.vnode); 75 afs_check_for_remote_deletion(&fc, fc.vnode);
67 afs_vnode_commit_status(&fc, vnode, fc.cb_break); 76 afs_vnode_commit_status(&fc, vnode, fc.cb_break,
77 &data_version, scb);
68 ret = afs_end_vnode_operation(&fc); 78 ret = afs_end_vnode_operation(&fc);
69 } 79 }
70 80
@@ -80,6 +90,9 @@ static int afs_xattr_get_acl(const struct xattr_handler *handler,
80 } 90 }
81 91
82 key_put(key); 92 key_put(key);
93error_scb:
94 kfree(scb);
95error:
83 return ret; 96 return ret;
84} 97}
85 98
@@ -92,22 +105,27 @@ static int afs_xattr_set_acl(const struct xattr_handler *handler,
92 const void *buffer, size_t size, int flags) 105 const void *buffer, size_t size, int flags)
93{ 106{
94 struct afs_fs_cursor fc; 107 struct afs_fs_cursor fc;
108 struct afs_status_cb *scb;
95 struct afs_vnode *vnode = AFS_FS_I(inode); 109 struct afs_vnode *vnode = AFS_FS_I(inode);
96 struct afs_acl *acl = NULL; 110 struct afs_acl *acl = NULL;
97 struct key *key; 111 struct key *key;
98 int ret; 112 int ret = -ENOMEM;
99 113
100 if (flags == XATTR_CREATE) 114 if (flags == XATTR_CREATE)
101 return -EINVAL; 115 return -EINVAL;
102 116
103 key = afs_request_key(vnode->volume->cell); 117 scb = kzalloc(sizeof(struct afs_status_cb), GFP_NOFS);
104 if (IS_ERR(key)) 118 if (!scb)
105 return PTR_ERR(key); 119 goto error;
106 120
107 acl = kmalloc(sizeof(*acl) + size, GFP_KERNEL); 121 acl = kmalloc(sizeof(*acl) + size, GFP_KERNEL);
108 if (!acl) { 122 if (!acl)
109 key_put(key); 123 goto error_scb;
110 return -ENOMEM; 124
125 key = afs_request_key(vnode->volume->cell);
126 if (IS_ERR(key)) {
127 ret = PTR_ERR(key);
128 goto error_acl;
111 } 129 }
112 130
113 acl->size = size; 131 acl->size = size;
@@ -115,18 +133,25 @@ static int afs_xattr_set_acl(const struct xattr_handler *handler,
115 133
116 ret = -ERESTARTSYS; 134 ret = -ERESTARTSYS;
117 if (afs_begin_vnode_operation(&fc, vnode, key, true)) { 135 if (afs_begin_vnode_operation(&fc, vnode, key, true)) {
136 afs_dataversion_t data_version = vnode->status.data_version;
137
118 while (afs_select_fileserver(&fc)) { 138 while (afs_select_fileserver(&fc)) {
119 fc.cb_break = afs_calc_vnode_cb_break(vnode); 139 fc.cb_break = afs_calc_vnode_cb_break(vnode);
120 afs_fs_store_acl(&fc, acl); 140 afs_fs_store_acl(&fc, acl, scb);
121 } 141 }
122 142
123 afs_check_for_remote_deletion(&fc, fc.vnode); 143 afs_check_for_remote_deletion(&fc, fc.vnode);
124 afs_vnode_commit_status(&fc, vnode, fc.cb_break); 144 afs_vnode_commit_status(&fc, vnode, fc.cb_break,
145 &data_version, scb);
125 ret = afs_end_vnode_operation(&fc); 146 ret = afs_end_vnode_operation(&fc);
126 } 147 }
127 148
128 kfree(acl);
129 key_put(key); 149 key_put(key);
150error_acl:
151 kfree(acl);
152error_scb:
153 kfree(scb);
154error:
130 return ret; 155 return ret;
131} 156}
132 157
@@ -145,6 +170,7 @@ static int afs_xattr_get_yfs(const struct xattr_handler *handler,
145 void *buffer, size_t size) 170 void *buffer, size_t size)
146{ 171{
147 struct afs_fs_cursor fc; 172 struct afs_fs_cursor fc;
173 struct afs_status_cb *scb;
148 struct afs_vnode *vnode = AFS_FS_I(inode); 174 struct afs_vnode *vnode = AFS_FS_I(inode);
149 struct yfs_acl *yacl = NULL; 175 struct yfs_acl *yacl = NULL;
150 struct key *key; 176 struct key *key;
@@ -171,21 +197,28 @@ static int afs_xattr_get_yfs(const struct xattr_handler *handler,
171 else if (which == 3) 197 else if (which == 3)
172 yacl->flags |= YFS_ACL_WANT_VOL_ACL; 198 yacl->flags |= YFS_ACL_WANT_VOL_ACL;
173 199
200 scb = kzalloc(sizeof(struct afs_status_cb), GFP_NOFS);
201 if (!scb)
202 goto error_yacl;
203
174 key = afs_request_key(vnode->volume->cell); 204 key = afs_request_key(vnode->volume->cell);
175 if (IS_ERR(key)) { 205 if (IS_ERR(key)) {
176 ret = PTR_ERR(key); 206 ret = PTR_ERR(key);
177 goto error_yacl; 207 goto error_scb;
178 } 208 }
179 209
180 ret = -ERESTARTSYS; 210 ret = -ERESTARTSYS;
181 if (afs_begin_vnode_operation(&fc, vnode, key, true)) { 211 if (afs_begin_vnode_operation(&fc, vnode, key, true)) {
212 afs_dataversion_t data_version = vnode->status.data_version;
213
182 while (afs_select_fileserver(&fc)) { 214 while (afs_select_fileserver(&fc)) {
183 fc.cb_break = afs_calc_vnode_cb_break(vnode); 215 fc.cb_break = afs_calc_vnode_cb_break(vnode);
184 yfs_fs_fetch_opaque_acl(&fc, yacl); 216 yfs_fs_fetch_opaque_acl(&fc, yacl, scb);
185 } 217 }
186 218
187 afs_check_for_remote_deletion(&fc, fc.vnode); 219 afs_check_for_remote_deletion(&fc, fc.vnode);
188 afs_vnode_commit_status(&fc, vnode, fc.cb_break); 220 afs_vnode_commit_status(&fc, vnode, fc.cb_break,
221 &data_version, scb);
189 ret = afs_end_vnode_operation(&fc); 222 ret = afs_end_vnode_operation(&fc);
190 } 223 }
191 224
@@ -225,6 +258,8 @@ static int afs_xattr_get_yfs(const struct xattr_handler *handler,
225 258
226error_key: 259error_key:
227 key_put(key); 260 key_put(key);
261error_scb:
262 kfree(scb);
228error_yacl: 263error_yacl:
229 yfs_free_opaque_acl(yacl); 264 yfs_free_opaque_acl(yacl);
230error: 265error:
@@ -240,42 +275,54 @@ static int afs_xattr_set_yfs(const struct xattr_handler *handler,
240 const void *buffer, size_t size, int flags) 275 const void *buffer, size_t size, int flags)
241{ 276{
242 struct afs_fs_cursor fc; 277 struct afs_fs_cursor fc;
278 struct afs_status_cb *scb;
243 struct afs_vnode *vnode = AFS_FS_I(inode); 279 struct afs_vnode *vnode = AFS_FS_I(inode);
244 struct afs_acl *acl = NULL; 280 struct afs_acl *acl = NULL;
245 struct key *key; 281 struct key *key;
246 int ret; 282 int ret = -ENOMEM;
247 283
248 if (flags == XATTR_CREATE || 284 if (flags == XATTR_CREATE ||
249 strcmp(name, "acl") != 0) 285 strcmp(name, "acl") != 0)
250 return -EINVAL; 286 return -EINVAL;
251 287
252 key = afs_request_key(vnode->volume->cell); 288 scb = kzalloc(sizeof(struct afs_status_cb), GFP_NOFS);
253 if (IS_ERR(key)) 289 if (!scb)
254 return PTR_ERR(key); 290 goto error;
255 291
256 acl = kmalloc(sizeof(*acl) + size, GFP_KERNEL); 292 acl = kmalloc(sizeof(*acl) + size, GFP_KERNEL);
257 if (!acl) { 293 if (!acl)
258 key_put(key); 294 goto error_scb;
259 return -ENOMEM;
260 }
261 295
262 acl->size = size; 296 acl->size = size;
263 memcpy(acl->data, buffer, size); 297 memcpy(acl->data, buffer, size);
264 298
299 key = afs_request_key(vnode->volume->cell);
300 if (IS_ERR(key)) {
301 ret = PTR_ERR(key);
302 goto error_acl;
303 }
304
265 ret = -ERESTARTSYS; 305 ret = -ERESTARTSYS;
266 if (afs_begin_vnode_operation(&fc, vnode, key, true)) { 306 if (afs_begin_vnode_operation(&fc, vnode, key, true)) {
307 afs_dataversion_t data_version = vnode->status.data_version;
308
267 while (afs_select_fileserver(&fc)) { 309 while (afs_select_fileserver(&fc)) {
268 fc.cb_break = afs_calc_vnode_cb_break(vnode); 310 fc.cb_break = afs_calc_vnode_cb_break(vnode);
269 yfs_fs_store_opaque_acl2(&fc, acl); 311 yfs_fs_store_opaque_acl2(&fc, acl, scb);
270 } 312 }
271 313
272 afs_check_for_remote_deletion(&fc, fc.vnode); 314 afs_check_for_remote_deletion(&fc, fc.vnode);
273 afs_vnode_commit_status(&fc, vnode, fc.cb_break); 315 afs_vnode_commit_status(&fc, vnode, fc.cb_break,
316 &data_version, scb);
274 ret = afs_end_vnode_operation(&fc); 317 ret = afs_end_vnode_operation(&fc);
275 } 318 }
276 319
320error_acl:
277 kfree(acl); 321 kfree(acl);
278 key_put(key); 322 key_put(key);
323error_scb:
324 kfree(scb);
325error:
279 return ret; 326 return ret;
280} 327}
281 328
diff --git a/fs/afs/yfsclient.c b/fs/afs/yfsclient.c
index b3ee99972d2f..80f579594660 100644
--- a/fs/afs/yfsclient.c
+++ b/fs/afs/yfsclient.c
@@ -183,24 +183,18 @@ static void xdr_dump_bad(const __be32 *bp)
183/* 183/*
184 * Decode a YFSFetchStatus block 184 * Decode a YFSFetchStatus block
185 */ 185 */
186static int xdr_decode_YFSFetchStatus(struct afs_call *call, 186static int xdr_decode_YFSFetchStatus(const __be32 **_bp,
187 const __be32 **_bp, 187 struct afs_call *call,
188 struct afs_file_status *status, 188 struct afs_status_cb *scb)
189 struct afs_vnode *vnode,
190 const afs_dataversion_t *expected_version,
191 struct afs_read *read_req)
192{ 189{
193 const struct yfs_xdr_YFSFetchStatus *xdr = (const void *)*_bp; 190 const struct yfs_xdr_YFSFetchStatus *xdr = (const void *)*_bp;
191 struct afs_file_status *status = &scb->status;
194 u32 type; 192 u32 type;
195 u8 flags = 0;
196 193
197 status->abort_code = ntohl(xdr->abort_code); 194 status->abort_code = ntohl(xdr->abort_code);
198 if (status->abort_code != 0) { 195 if (status->abort_code != 0) {
199 if (vnode && status->abort_code == VNOVNODE) { 196 if (status->abort_code == VNOVNODE)
200 set_bit(AFS_VNODE_DELETED, &vnode->flags);
201 status->nlink = 0; 197 status->nlink = 0;
202 __afs_break_callback(vnode);
203 }
204 return 0; 198 return 0;
205 } 199 }
206 200
@@ -209,77 +203,27 @@ static int xdr_decode_YFSFetchStatus(struct afs_call *call,
209 case AFS_FTYPE_FILE: 203 case AFS_FTYPE_FILE:
210 case AFS_FTYPE_DIR: 204 case AFS_FTYPE_DIR:
211 case AFS_FTYPE_SYMLINK: 205 case AFS_FTYPE_SYMLINK:
212 if (type != status->type &&
213 vnode &&
214 !test_bit(AFS_VNODE_UNSET, &vnode->flags)) {
215 pr_warning("Vnode %llx:%llx:%x changed type %u to %u\n",
216 vnode->fid.vid,
217 vnode->fid.vnode,
218 vnode->fid.unique,
219 status->type, type);
220 goto bad;
221 }
222 status->type = type; 206 status->type = type;
223 break; 207 break;
224 default: 208 default:
225 goto bad; 209 goto bad;
226 } 210 }
227 211
228#define EXTRACT_M4(FIELD) \ 212 status->nlink = ntohl(xdr->nlink);
229 do { \ 213 status->author = xdr_to_u64(xdr->author);
230 u32 x = ntohl(xdr->FIELD); \ 214 status->owner = xdr_to_u64(xdr->owner);
231 if (status->FIELD != x) { \ 215 status->caller_access = ntohl(xdr->caller_access); /* Ticket dependent */
232 flags |= AFS_VNODE_META_CHANGED; \ 216 status->anon_access = ntohl(xdr->anon_access);
233 status->FIELD = x; \ 217 status->mode = ntohl(xdr->mode) & S_IALLUGO;
234 } \ 218 status->group = xdr_to_u64(xdr->group);
235 } while (0) 219 status->lock_count = ntohl(xdr->lock_count);
236
237#define EXTRACT_M8(FIELD) \
238 do { \
239 u64 x = xdr_to_u64(xdr->FIELD); \
240 if (status->FIELD != x) { \
241 flags |= AFS_VNODE_META_CHANGED; \
242 status->FIELD = x; \
243 } \
244 } while (0)
245
246#define EXTRACT_D8(FIELD) \
247 do { \
248 u64 x = xdr_to_u64(xdr->FIELD); \
249 if (status->FIELD != x) { \
250 flags |= AFS_VNODE_DATA_CHANGED; \
251 status->FIELD = x; \
252 } \
253 } while (0)
254
255 EXTRACT_M4(nlink);
256 EXTRACT_D8(size);
257 EXTRACT_D8(data_version);
258 EXTRACT_M8(author);
259 EXTRACT_M8(owner);
260 EXTRACT_M8(group);
261 EXTRACT_M4(mode);
262 EXTRACT_M4(caller_access); /* call ticket dependent */
263 EXTRACT_M4(anon_access);
264
265 status->mtime_client = xdr_to_time(xdr->mtime_client);
266 status->mtime_server = xdr_to_time(xdr->mtime_server);
267 status->lock_count = ntohl(xdr->lock_count);
268
269 if (read_req) {
270 read_req->data_version = status->data_version;
271 read_req->file_size = status->size;
272 }
273
274 *_bp += xdr_size(xdr);
275 220
276 if (vnode) { 221 status->mtime_client = xdr_to_time(xdr->mtime_client);
277 if (test_bit(AFS_VNODE_UNSET, &vnode->flags)) 222 status->mtime_server = xdr_to_time(xdr->mtime_server);
278 flags |= AFS_VNODE_NOT_YET_SET; 223 status->size = xdr_to_u64(xdr->size);
279 afs_update_inode_from_status(vnode, status, expected_version, 224 status->data_version = xdr_to_u64(xdr->data_version);
280 flags);
281 }
282 225
226 *_bp += xdr_size(xdr);
283 return 0; 227 return 0;
284 228
285bad: 229bad:
@@ -288,34 +232,14 @@ bad:
288} 232}
289 233
290/* 234/*
291 * Decode the file status. We need to lock the target vnode if we're going to 235 * Decode a YFSCallBack block
292 * update its status so that stat() sees the attributes update atomically.
293 */ 236 */
294static int yfs_decode_status(struct afs_call *call, 237static void xdr_decode_YFSCallBack(const __be32 **_bp,
295 const __be32 **_bp, 238 struct afs_call *call,
296 struct afs_file_status *status, 239 struct afs_status_cb *scb)
297 struct afs_vnode *vnode,
298 const afs_dataversion_t *expected_version,
299 struct afs_read *read_req)
300{
301 int ret;
302
303 if (!vnode)
304 return xdr_decode_YFSFetchStatus(call, _bp, status, vnode,
305 expected_version, read_req);
306
307 write_seqlock(&vnode->cb_lock);
308 ret = xdr_decode_YFSFetchStatus(call, _bp, status, vnode,
309 expected_version, read_req);
310 write_sequnlock(&vnode->cb_lock);
311 return ret;
312}
313
314static void xdr_decode_YFSCallBack_raw(struct afs_call *call,
315 struct afs_callback *cb,
316 const __be32 **_bp)
317{ 240{
318 struct yfs_xdr_YFSCallBack *x = (void *)*_bp; 241 struct yfs_xdr_YFSCallBack *x = (void *)*_bp;
242 struct afs_callback *cb = &scb->callback;
319 ktime_t cb_expiry; 243 ktime_t cb_expiry;
320 244
321 cb_expiry = call->reply_time; 245 cb_expiry = call->reply_time;
@@ -323,41 +247,11 @@ static void xdr_decode_YFSCallBack_raw(struct afs_call *call,
323 cb->expires_at = ktime_divns(cb_expiry, NSEC_PER_SEC); 247 cb->expires_at = ktime_divns(cb_expiry, NSEC_PER_SEC);
324 cb->version = ntohl(x->version); 248 cb->version = ntohl(x->version);
325 cb->type = ntohl(x->type); 249 cb->type = ntohl(x->type);
326 250 scb->have_cb = true;
327 *_bp += xdr_size(x); 251 *_bp += xdr_size(x);
328} 252}
329 253
330/* 254/*
331 * Decode a YFSCallBack block
332 */
333static void xdr_decode_YFSCallBack(struct afs_call *call,
334 struct afs_vnode *vnode,
335 const __be32 **_bp)
336{
337 struct afs_cb_interest *old, *cbi = call->cbi;
338 struct afs_callback cb;
339
340 xdr_decode_YFSCallBack_raw(call, &cb, _bp);
341
342 write_seqlock(&vnode->cb_lock);
343
344 if (!afs_cb_is_broken(call->cb_break, vnode, cbi)) {
345 vnode->cb_version = cb.version;
346 vnode->cb_type = cb.type;
347 vnode->cb_expires_at = cb.expires_at;
348 old = vnode->cb_interest;
349 if (old != call->cbi) {
350 vnode->cb_interest = cbi;
351 cbi = old;
352 }
353 set_bit(AFS_VNODE_CB_PROMISED, &vnode->flags);
354 }
355
356 write_sequnlock(&vnode->cb_lock);
357 call->cbi = cbi;
358}
359
360/*
361 * Decode a YFSVolSync block 255 * Decode a YFSVolSync block
362 */ 256 */
363static void xdr_decode_YFSVolSync(const __be32 **_bp, 257static void xdr_decode_YFSVolSync(const __be32 **_bp,
@@ -441,11 +335,10 @@ static void xdr_decode_YFSFetchVolumeStatus(const __be32 **_bp,
441} 335}
442 336
443/* 337/*
444 * deliver reply data to an FS.FetchStatus 338 * Deliver a reply that's a status, callback and volsync.
445 */ 339 */
446static int yfs_deliver_fs_fetch_status_vnode(struct afs_call *call) 340static int yfs_deliver_fs_status_cb_and_volsync(struct afs_call *call)
447{ 341{
448 struct afs_vnode *vnode = call->xvnode;
449 const __be32 *bp; 342 const __be32 *bp;
450 int ret; 343 int ret;
451 344
@@ -453,15 +346,35 @@ static int yfs_deliver_fs_fetch_status_vnode(struct afs_call *call)
453 if (ret < 0) 346 if (ret < 0)
454 return ret; 347 return ret;
455 348
456 _enter("{%llx:%llu}", vnode->fid.vid, vnode->fid.vnode);
457
458 /* unmarshall the reply once we've received all of it */ 349 /* unmarshall the reply once we've received all of it */
459 bp = call->buffer; 350 bp = call->buffer;
460 ret = yfs_decode_status(call, &bp, &vnode->status, vnode, 351 ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
461 &call->expected_version, NULL); 352 if (ret < 0)
353 return ret;
354 xdr_decode_YFSCallBack(&bp, call, call->out_scb);
355 xdr_decode_YFSVolSync(&bp, call->out_volsync);
356
357 _leave(" = 0 [done]");
358 return 0;
359}
360
361/*
362 * Deliver reply data to operations that just return a file status and a volume
363 * sync record.
364 */
365static int yfs_deliver_status_and_volsync(struct afs_call *call)
366{
367 const __be32 *bp;
368 int ret;
369
370 ret = afs_transfer_reply(call);
371 if (ret < 0)
372 return ret;
373
374 bp = call->buffer;
375 ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
462 if (ret < 0) 376 if (ret < 0)
463 return ret; 377 return ret;
464 xdr_decode_YFSCallBack(call, vnode, &bp);
465 xdr_decode_YFSVolSync(&bp, call->out_volsync); 378 xdr_decode_YFSVolSync(&bp, call->out_volsync);
466 379
467 _leave(" = 0 [done]"); 380 _leave(" = 0 [done]");
@@ -474,15 +387,15 @@ static int yfs_deliver_fs_fetch_status_vnode(struct afs_call *call)
474static const struct afs_call_type yfs_RXYFSFetchStatus_vnode = { 387static const struct afs_call_type yfs_RXYFSFetchStatus_vnode = {
475 .name = "YFS.FetchStatus(vnode)", 388 .name = "YFS.FetchStatus(vnode)",
476 .op = yfs_FS_FetchStatus, 389 .op = yfs_FS_FetchStatus,
477 .deliver = yfs_deliver_fs_fetch_status_vnode, 390 .deliver = yfs_deliver_fs_status_cb_and_volsync,
478 .destructor = afs_flat_call_destructor, 391 .destructor = afs_flat_call_destructor,
479}; 392};
480 393
481/* 394/*
482 * Fetch the status information for a file. 395 * Fetch the status information for a file.
483 */ 396 */
484int yfs_fs_fetch_file_status(struct afs_fs_cursor *fc, struct afs_volsync *volsync, 397int yfs_fs_fetch_file_status(struct afs_fs_cursor *fc, struct afs_status_cb *scb,
485 bool new_inode) 398 struct afs_volsync *volsync)
486{ 399{
487 struct afs_vnode *vnode = fc->vnode; 400 struct afs_vnode *vnode = fc->vnode;
488 struct afs_call *call; 401 struct afs_call *call;
@@ -504,9 +417,8 @@ int yfs_fs_fetch_file_status(struct afs_fs_cursor *fc, struct afs_volsync *volsy
504 } 417 }
505 418
506 call->key = fc->key; 419 call->key = fc->key;
507 call->xvnode = vnode; 420 call->out_scb = scb;
508 call->out_volsync = volsync; 421 call->out_volsync = volsync;
509 call->expected_version = new_inode ? 1 : vnode->status.data_version;
510 422
511 /* marshall the parameters */ 423 /* marshall the parameters */
512 bp = call->request; 424 bp = call->request;
@@ -515,7 +427,6 @@ int yfs_fs_fetch_file_status(struct afs_fs_cursor *fc, struct afs_volsync *volsy
515 bp = xdr_encode_YFSFid(bp, &vnode->fid); 427 bp = xdr_encode_YFSFid(bp, &vnode->fid);
516 yfs_check_req(call, bp); 428 yfs_check_req(call, bp);
517 429
518 call->cb_break = fc->cb_break;
519 afs_use_fs_server(call, fc->cbi); 430 afs_use_fs_server(call, fc->cbi);
520 trace_afs_make_fs_call(call, &vnode->fid); 431 trace_afs_make_fs_call(call, &vnode->fid);
521 afs_set_fc_call(call, fc); 432 afs_set_fc_call(call, fc);
@@ -528,7 +439,6 @@ int yfs_fs_fetch_file_status(struct afs_fs_cursor *fc, struct afs_volsync *volsy
528 */ 439 */
529static int yfs_deliver_fs_fetch_data64(struct afs_call *call) 440static int yfs_deliver_fs_fetch_data64(struct afs_call *call)
530{ 441{
531 struct afs_vnode *vnode = call->xvnode;
532 struct afs_read *req = call->read_request; 442 struct afs_read *req = call->read_request;
533 const __be32 *bp; 443 const __be32 *bp;
534 unsigned int size; 444 unsigned int size;
@@ -586,7 +496,7 @@ static int yfs_deliver_fs_fetch_data64(struct afs_call *call)
586 if (req->offset == PAGE_SIZE) { 496 if (req->offset == PAGE_SIZE) {
587 req->offset = 0; 497 req->offset = 0;
588 if (req->page_done) 498 if (req->page_done)
589 req->page_done(call, req); 499 req->page_done(req);
590 req->index++; 500 req->index++;
591 if (req->remain > 0) 501 if (req->remain > 0)
592 goto begin_page; 502 goto begin_page;
@@ -623,13 +533,15 @@ static int yfs_deliver_fs_fetch_data64(struct afs_call *call)
623 return ret; 533 return ret;
624 534
625 bp = call->buffer; 535 bp = call->buffer;
626 ret = yfs_decode_status(call, &bp, &vnode->status, vnode, 536 ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
627 &vnode->status.data_version, req);
628 if (ret < 0) 537 if (ret < 0)
629 return ret; 538 return ret;
630 xdr_decode_YFSCallBack(call, vnode, &bp); 539 xdr_decode_YFSCallBack(&bp, call, call->out_scb);
631 xdr_decode_YFSVolSync(&bp, call->out_volsync); 540 xdr_decode_YFSVolSync(&bp, call->out_volsync);
632 541
542 req->data_version = call->out_scb->status.data_version;
543 req->file_size = call->out_scb->status.size;
544
633 call->unmarshall++; 545 call->unmarshall++;
634 546
635 /* Fall through */ 547 /* Fall through */
@@ -642,7 +554,7 @@ static int yfs_deliver_fs_fetch_data64(struct afs_call *call)
642 zero_user_segment(req->pages[req->index], 554 zero_user_segment(req->pages[req->index],
643 req->offset, PAGE_SIZE); 555 req->offset, PAGE_SIZE);
644 if (req->page_done) 556 if (req->page_done)
645 req->page_done(call, req); 557 req->page_done(req);
646 req->offset = 0; 558 req->offset = 0;
647 } 559 }
648 560
@@ -669,7 +581,8 @@ static const struct afs_call_type yfs_RXYFSFetchData64 = {
669/* 581/*
670 * Fetch data from a file. 582 * Fetch data from a file.
671 */ 583 */
672int yfs_fs_fetch_data(struct afs_fs_cursor *fc, struct afs_read *req) 584int yfs_fs_fetch_data(struct afs_fs_cursor *fc, struct afs_status_cb *scb,
585 struct afs_read *req)
673{ 586{
674 struct afs_vnode *vnode = fc->vnode; 587 struct afs_vnode *vnode = fc->vnode;
675 struct afs_call *call; 588 struct afs_call *call;
@@ -691,10 +604,9 @@ int yfs_fs_fetch_data(struct afs_fs_cursor *fc, struct afs_read *req)
691 return -ENOMEM; 604 return -ENOMEM;
692 605
693 call->key = fc->key; 606 call->key = fc->key;
694 call->xvnode = vnode; 607 call->out_scb = scb;
695 call->out_volsync = NULL; 608 call->out_volsync = NULL;
696 call->read_request = req; 609 call->read_request = req;
697 call->expected_version = vnode->status.data_version;
698 610
699 /* marshall the parameters */ 611 /* marshall the parameters */
700 bp = call->request; 612 bp = call->request;
@@ -706,7 +618,6 @@ int yfs_fs_fetch_data(struct afs_fs_cursor *fc, struct afs_read *req)
706 yfs_check_req(call, bp); 618 yfs_check_req(call, bp);
707 619
708 refcount_inc(&req->usage); 620 refcount_inc(&req->usage);
709 call->cb_break = fc->cb_break;
710 afs_use_fs_server(call, fc->cbi); 621 afs_use_fs_server(call, fc->cbi);
711 trace_afs_make_fs_call(call, &vnode->fid); 622 trace_afs_make_fs_call(call, &vnode->fid);
712 afs_set_fc_call(call, fc); 623 afs_set_fc_call(call, fc);
@@ -719,7 +630,6 @@ int yfs_fs_fetch_data(struct afs_fs_cursor *fc, struct afs_read *req)
719 */ 630 */
720static int yfs_deliver_fs_create_vnode(struct afs_call *call) 631static int yfs_deliver_fs_create_vnode(struct afs_call *call)
721{ 632{
722 struct afs_vnode *dvnode = call->dvnode;
723 const __be32 *bp; 633 const __be32 *bp;
724 int ret; 634 int ret;
725 635
@@ -732,15 +642,14 @@ static int yfs_deliver_fs_create_vnode(struct afs_call *call)
732 /* unmarshall the reply once we've received all of it */ 642 /* unmarshall the reply once we've received all of it */
733 bp = call->buffer; 643 bp = call->buffer;
734 xdr_decode_YFSFid(&bp, call->out_fid); 644 xdr_decode_YFSFid(&bp, call->out_fid);
735 ret = yfs_decode_status(call, &bp, call->out_extra_status, NULL, NULL, NULL); 645 ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
736 if (ret < 0) 646 if (ret < 0)
737 return ret; 647 return ret;
738 ret = yfs_decode_status(call, &bp, &dvnode->status, dvnode, 648 ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb);
739 &call->expected_version, NULL);
740 if (ret < 0) 649 if (ret < 0)
741 return ret; 650 return ret;
742 xdr_decode_YFSCallBack_raw(call, call->out_cb, &bp); 651 xdr_decode_YFSCallBack(&bp, call, call->out_scb);
743 xdr_decode_YFSVolSync(&bp, NULL); 652 xdr_decode_YFSVolSync(&bp, call->out_volsync);
744 653
745 _leave(" = 0 [done]"); 654 _leave(" = 0 [done]");
746 return 0; 655 return 0;
@@ -762,10 +671,9 @@ static const struct afs_call_type afs_RXFSCreateFile = {
762int yfs_fs_create_file(struct afs_fs_cursor *fc, 671int yfs_fs_create_file(struct afs_fs_cursor *fc,
763 const char *name, 672 const char *name,
764 umode_t mode, 673 umode_t mode,
765 u64 current_data_version, 674 struct afs_status_cb *dvnode_scb,
766 struct afs_fid *newfid, 675 struct afs_fid *newfid,
767 struct afs_file_status *newstatus, 676 struct afs_status_cb *new_scb)
768 struct afs_callback *newcb)
769{ 677{
770 struct afs_vnode *dvnode = fc->vnode; 678 struct afs_vnode *dvnode = fc->vnode;
771 struct afs_call *call; 679 struct afs_call *call;
@@ -793,11 +701,9 @@ int yfs_fs_create_file(struct afs_fs_cursor *fc,
793 return -ENOMEM; 701 return -ENOMEM;
794 702
795 call->key = fc->key; 703 call->key = fc->key;
796 call->dvnode = dvnode; 704 call->out_dir_scb = dvnode_scb;
797 call->out_fid = newfid; 705 call->out_fid = newfid;
798 call->out_extra_status = newstatus; 706 call->out_scb = new_scb;
799 call->out_cb = newcb;
800 call->expected_version = current_data_version + 1;
801 707
802 /* marshall the parameters */ 708 /* marshall the parameters */
803 bp = call->request; 709 bp = call->request;
@@ -829,10 +735,9 @@ static const struct afs_call_type yfs_RXFSMakeDir = {
829int yfs_fs_make_dir(struct afs_fs_cursor *fc, 735int yfs_fs_make_dir(struct afs_fs_cursor *fc,
830 const char *name, 736 const char *name,
831 umode_t mode, 737 umode_t mode,
832 u64 current_data_version, 738 struct afs_status_cb *dvnode_scb,
833 struct afs_fid *newfid, 739 struct afs_fid *newfid,
834 struct afs_file_status *newstatus, 740 struct afs_status_cb *new_scb)
835 struct afs_callback *newcb)
836{ 741{
837 struct afs_vnode *dvnode = fc->vnode; 742 struct afs_vnode *dvnode = fc->vnode;
838 struct afs_call *call; 743 struct afs_call *call;
@@ -859,11 +764,9 @@ int yfs_fs_make_dir(struct afs_fs_cursor *fc,
859 return -ENOMEM; 764 return -ENOMEM;
860 765
861 call->key = fc->key; 766 call->key = fc->key;
862 call->dvnode = dvnode; 767 call->out_dir_scb = dvnode_scb;
863 call->out_fid = newfid; 768 call->out_fid = newfid;
864 call->out_extra_status = newstatus; 769 call->out_scb = new_scb;
865 call->out_cb = newcb;
866 call->expected_version = current_data_version + 1;
867 770
868 /* marshall the parameters */ 771 /* marshall the parameters */
869 bp = call->request; 772 bp = call->request;
@@ -886,8 +789,6 @@ int yfs_fs_make_dir(struct afs_fs_cursor *fc,
886 */ 789 */
887static int yfs_deliver_fs_remove_file2(struct afs_call *call) 790static int yfs_deliver_fs_remove_file2(struct afs_call *call)
888{ 791{
889 struct afs_vnode *dvnode = call->dvnode;
890 struct afs_vnode *vnode = call->xvnode;
891 struct afs_fid fid; 792 struct afs_fid fid;
892 const __be32 *bp; 793 const __be32 *bp;
893 int ret; 794 int ret;
@@ -898,20 +799,18 @@ static int yfs_deliver_fs_remove_file2(struct afs_call *call)
898 if (ret < 0) 799 if (ret < 0)
899 return ret; 800 return ret;
900 801
901 /* unmarshall the reply once we've received all of it */
902 bp = call->buffer; 802 bp = call->buffer;
903 ret = yfs_decode_status(call, &bp, &dvnode->status, dvnode, 803 ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb);
904 &call->expected_version, NULL);
905 if (ret < 0) 804 if (ret < 0)
906 return ret; 805 return ret;
907 806
908 xdr_decode_YFSFid(&bp, &fid); 807 xdr_decode_YFSFid(&bp, &fid);
909 ret = yfs_decode_status(call, &bp, &vnode->status, vnode, NULL, NULL); 808 ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
910 if (ret < 0) 809 if (ret < 0)
911 return ret; 810 return ret;
912 /* Was deleted if vnode->status.abort_code == VNOVNODE. */ 811 /* Was deleted if vnode->status.abort_code == VNOVNODE. */
913 812
914 xdr_decode_YFSVolSync(&bp, NULL); 813 xdr_decode_YFSVolSync(&bp, call->out_volsync);
915 return 0; 814 return 0;
916} 815}
917 816
@@ -929,7 +828,8 @@ static const struct afs_call_type yfs_RXYFSRemoveFile2 = {
929 * Remove a file and retrieve new file status. 828 * Remove a file and retrieve new file status.
930 */ 829 */
931int yfs_fs_remove_file2(struct afs_fs_cursor *fc, struct afs_vnode *vnode, 830int yfs_fs_remove_file2(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
932 const char *name, u64 current_data_version) 831 const char *name, struct afs_status_cb *dvnode_scb,
832 struct afs_status_cb *vnode_scb)
933{ 833{
934 struct afs_vnode *dvnode = fc->vnode; 834 struct afs_vnode *dvnode = fc->vnode;
935 struct afs_call *call; 835 struct afs_call *call;
@@ -954,9 +854,8 @@ int yfs_fs_remove_file2(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
954 return -ENOMEM; 854 return -ENOMEM;
955 855
956 call->key = fc->key; 856 call->key = fc->key;
957 call->dvnode = dvnode; 857 call->out_dir_scb = dvnode_scb;
958 call->xvnode = vnode; 858 call->out_scb = vnode_scb;
959 call->expected_version = current_data_version + 1;
960 859
961 /* marshall the parameters */ 860 /* marshall the parameters */
962 bp = call->request; 861 bp = call->request;
@@ -978,7 +877,6 @@ int yfs_fs_remove_file2(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
978 */ 877 */
979static int yfs_deliver_fs_remove(struct afs_call *call) 878static int yfs_deliver_fs_remove(struct afs_call *call)
980{ 879{
981 struct afs_vnode *dvnode = call->dvnode;
982 const __be32 *bp; 880 const __be32 *bp;
983 int ret; 881 int ret;
984 882
@@ -988,14 +886,12 @@ static int yfs_deliver_fs_remove(struct afs_call *call)
988 if (ret < 0) 886 if (ret < 0)
989 return ret; 887 return ret;
990 888
991 /* unmarshall the reply once we've received all of it */
992 bp = call->buffer; 889 bp = call->buffer;
993 ret = yfs_decode_status(call, &bp, &dvnode->status, dvnode, 890 ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb);
994 &call->expected_version, NULL);
995 if (ret < 0) 891 if (ret < 0)
996 return ret; 892 return ret;
997 893
998 xdr_decode_YFSVolSync(&bp, NULL); 894 xdr_decode_YFSVolSync(&bp, call->out_volsync);
999 return 0; 895 return 0;
1000} 896}
1001 897
@@ -1020,7 +916,8 @@ static const struct afs_call_type yfs_RXYFSRemoveDir = {
1020 * remove a file or directory 916 * remove a file or directory
1021 */ 917 */
1022int yfs_fs_remove(struct afs_fs_cursor *fc, struct afs_vnode *vnode, 918int yfs_fs_remove(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
1023 const char *name, bool isdir, u64 current_data_version) 919 const char *name, bool isdir,
920 struct afs_status_cb *dvnode_scb)
1024{ 921{
1025 struct afs_vnode *dvnode = fc->vnode; 922 struct afs_vnode *dvnode = fc->vnode;
1026 struct afs_call *call; 923 struct afs_call *call;
@@ -1043,9 +940,7 @@ int yfs_fs_remove(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
1043 return -ENOMEM; 940 return -ENOMEM;
1044 941
1045 call->key = fc->key; 942 call->key = fc->key;
1046 call->dvnode = dvnode; 943 call->out_dir_scb = dvnode_scb;
1047 call->xvnode = vnode;
1048 call->expected_version = current_data_version + 1;
1049 944
1050 /* marshall the parameters */ 945 /* marshall the parameters */
1051 bp = call->request; 946 bp = call->request;
@@ -1067,7 +962,6 @@ int yfs_fs_remove(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
1067 */ 962 */
1068static int yfs_deliver_fs_link(struct afs_call *call) 963static int yfs_deliver_fs_link(struct afs_call *call)
1069{ 964{
1070 struct afs_vnode *dvnode = call->dvnode, *vnode = call->xvnode;
1071 const __be32 *bp; 965 const __be32 *bp;
1072 int ret; 966 int ret;
1073 967
@@ -1077,16 +971,14 @@ static int yfs_deliver_fs_link(struct afs_call *call)
1077 if (ret < 0) 971 if (ret < 0)
1078 return ret; 972 return ret;
1079 973
1080 /* unmarshall the reply once we've received all of it */
1081 bp = call->buffer; 974 bp = call->buffer;
1082 ret = yfs_decode_status(call, &bp, &vnode->status, vnode, NULL, NULL); 975 ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
1083 if (ret < 0) 976 if (ret < 0)
1084 return ret; 977 return ret;
1085 ret = yfs_decode_status(call, &bp, &dvnode->status, dvnode, 978 ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb);
1086 &call->expected_version, NULL);
1087 if (ret < 0) 979 if (ret < 0)
1088 return ret; 980 return ret;
1089 xdr_decode_YFSVolSync(&bp, NULL); 981 xdr_decode_YFSVolSync(&bp, call->out_volsync);
1090 _leave(" = 0 [done]"); 982 _leave(" = 0 [done]");
1091 return 0; 983 return 0;
1092} 984}
@@ -1105,7 +997,9 @@ static const struct afs_call_type yfs_RXYFSLink = {
1105 * Make a hard link. 997 * Make a hard link.
1106 */ 998 */
1107int yfs_fs_link(struct afs_fs_cursor *fc, struct afs_vnode *vnode, 999int yfs_fs_link(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
1108 const char *name, u64 current_data_version) 1000 const char *name,
1001 struct afs_status_cb *dvnode_scb,
1002 struct afs_status_cb *vnode_scb)
1109{ 1003{
1110 struct afs_vnode *dvnode = fc->vnode; 1004 struct afs_vnode *dvnode = fc->vnode;
1111 struct afs_call *call; 1005 struct afs_call *call;
@@ -1129,9 +1023,8 @@ int yfs_fs_link(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
1129 return -ENOMEM; 1023 return -ENOMEM;
1130 1024
1131 call->key = fc->key; 1025 call->key = fc->key;
1132 call->dvnode = dvnode; 1026 call->out_dir_scb = dvnode_scb;
1133 call->xvnode = vnode; 1027 call->out_scb = vnode_scb;
1134 call->expected_version = current_data_version + 1;
1135 1028
1136 /* marshall the parameters */ 1029 /* marshall the parameters */
1137 bp = call->request; 1030 bp = call->request;
@@ -1154,7 +1047,6 @@ int yfs_fs_link(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
1154 */ 1047 */
1155static int yfs_deliver_fs_symlink(struct afs_call *call) 1048static int yfs_deliver_fs_symlink(struct afs_call *call)
1156{ 1049{
1157 struct afs_vnode *dvnode = call->dvnode;
1158 const __be32 *bp; 1050 const __be32 *bp;
1159 int ret; 1051 int ret;
1160 1052
@@ -1167,14 +1059,13 @@ static int yfs_deliver_fs_symlink(struct afs_call *call)
1167 /* unmarshall the reply once we've received all of it */ 1059 /* unmarshall the reply once we've received all of it */
1168 bp = call->buffer; 1060 bp = call->buffer;
1169 xdr_decode_YFSFid(&bp, call->out_fid); 1061 xdr_decode_YFSFid(&bp, call->out_fid);
1170 ret = yfs_decode_status(call, &bp, call->out_extra_status, NULL, NULL, NULL); 1062 ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
1171 if (ret < 0) 1063 if (ret < 0)
1172 return ret; 1064 return ret;
1173 ret = yfs_decode_status(call, &bp, &dvnode->status, dvnode, 1065 ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb);
1174 &call->expected_version, NULL);
1175 if (ret < 0) 1066 if (ret < 0)
1176 return ret; 1067 return ret;
1177 xdr_decode_YFSVolSync(&bp, NULL); 1068 xdr_decode_YFSVolSync(&bp, call->out_volsync);
1178 1069
1179 _leave(" = 0 [done]"); 1070 _leave(" = 0 [done]");
1180 return 0; 1071 return 0;
@@ -1196,9 +1087,9 @@ static const struct afs_call_type yfs_RXYFSSymlink = {
1196int yfs_fs_symlink(struct afs_fs_cursor *fc, 1087int yfs_fs_symlink(struct afs_fs_cursor *fc,
1197 const char *name, 1088 const char *name,
1198 const char *contents, 1089 const char *contents,
1199 u64 current_data_version, 1090 struct afs_status_cb *dvnode_scb,
1200 struct afs_fid *newfid, 1091 struct afs_fid *newfid,
1201 struct afs_file_status *newstatus) 1092 struct afs_status_cb *vnode_scb)
1202{ 1093{
1203 struct afs_vnode *dvnode = fc->vnode; 1094 struct afs_vnode *dvnode = fc->vnode;
1204 struct afs_call *call; 1095 struct afs_call *call;
@@ -1225,10 +1116,9 @@ int yfs_fs_symlink(struct afs_fs_cursor *fc,
1225 return -ENOMEM; 1116 return -ENOMEM;
1226 1117
1227 call->key = fc->key; 1118 call->key = fc->key;
1228 call->dvnode = dvnode; 1119 call->out_dir_scb = dvnode_scb;
1229 call->out_fid = newfid; 1120 call->out_fid = newfid;
1230 call->out_extra_status = newstatus; 1121 call->out_scb = vnode_scb;
1231 call->expected_version = current_data_version + 1;
1232 1122
1233 /* marshall the parameters */ 1123 /* marshall the parameters */
1234 bp = call->request; 1124 bp = call->request;
@@ -1252,8 +1142,6 @@ int yfs_fs_symlink(struct afs_fs_cursor *fc,
1252 */ 1142 */
1253static int yfs_deliver_fs_rename(struct afs_call *call) 1143static int yfs_deliver_fs_rename(struct afs_call *call)
1254{ 1144{
1255 struct afs_vnode *orig_dvnode = call->dvnode;
1256 struct afs_vnode *new_dvnode = call->xvnode;
1257 const __be32 *bp; 1145 const __be32 *bp;
1258 int ret; 1146 int ret;
1259 1147
@@ -1263,20 +1151,17 @@ static int yfs_deliver_fs_rename(struct afs_call *call)
1263 if (ret < 0) 1151 if (ret < 0)
1264 return ret; 1152 return ret;
1265 1153
1266 /* unmarshall the reply once we've received all of it */
1267 bp = call->buffer; 1154 bp = call->buffer;
1268 ret = yfs_decode_status(call, &bp, &orig_dvnode->status, orig_dvnode, 1155 ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb);
1269 &call->expected_version, NULL);
1270 if (ret < 0) 1156 if (ret < 0)
1271 return ret; 1157 return ret;
1272 if (new_dvnode != orig_dvnode) { 1158 if (call->out_dir_scb != call->out_scb) {
1273 ret = yfs_decode_status(call, &bp, &new_dvnode->status, new_dvnode, 1159 ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
1274 &call->expected_version_2, NULL);
1275 if (ret < 0) 1160 if (ret < 0)
1276 return ret; 1161 return ret;
1277 } 1162 }
1278 1163
1279 xdr_decode_YFSVolSync(&bp, NULL); 1164 xdr_decode_YFSVolSync(&bp, call->out_volsync);
1280 _leave(" = 0 [done]"); 1165 _leave(" = 0 [done]");
1281 return 0; 1166 return 0;
1282} 1167}
@@ -1298,8 +1183,8 @@ int yfs_fs_rename(struct afs_fs_cursor *fc,
1298 const char *orig_name, 1183 const char *orig_name,
1299 struct afs_vnode *new_dvnode, 1184 struct afs_vnode *new_dvnode,
1300 const char *new_name, 1185 const char *new_name,
1301 u64 current_orig_data_version, 1186 struct afs_status_cb *orig_dvnode_scb,
1302 u64 current_new_data_version) 1187 struct afs_status_cb *new_dvnode_scb)
1303{ 1188{
1304 struct afs_vnode *orig_dvnode = fc->vnode; 1189 struct afs_vnode *orig_dvnode = fc->vnode;
1305 struct afs_call *call; 1190 struct afs_call *call;
@@ -1325,10 +1210,8 @@ int yfs_fs_rename(struct afs_fs_cursor *fc,
1325 return -ENOMEM; 1210 return -ENOMEM;
1326 1211
1327 call->key = fc->key; 1212 call->key = fc->key;
1328 call->dvnode = orig_dvnode; 1213 call->out_dir_scb = orig_dvnode_scb;
1329 call->xvnode = new_dvnode; 1214 call->out_scb = new_dvnode_scb;
1330 call->expected_version = current_orig_data_version + 1;
1331 call->expected_version_2 = current_new_data_version + 1;
1332 1215
1333 /* marshall the parameters */ 1216 /* marshall the parameters */
1334 bp = call->request; 1217 bp = call->request;
@@ -1348,41 +1231,12 @@ int yfs_fs_rename(struct afs_fs_cursor *fc,
1348} 1231}
1349 1232
1350/* 1233/*
1351 * Deliver reply data to a YFS.StoreData64 operation.
1352 */
1353static int yfs_deliver_fs_store_data(struct afs_call *call)
1354{
1355 struct afs_vnode *vnode = call->xvnode;
1356 const __be32 *bp;
1357 int ret;
1358
1359 _enter("");
1360
1361 ret = afs_transfer_reply(call);
1362 if (ret < 0)
1363 return ret;
1364
1365 /* unmarshall the reply once we've received all of it */
1366 bp = call->buffer;
1367 ret = yfs_decode_status(call, &bp, &vnode->status, vnode,
1368 &call->expected_version, NULL);
1369 if (ret < 0)
1370 return ret;
1371 xdr_decode_YFSVolSync(&bp, NULL);
1372
1373 afs_pages_written_back(vnode, call);
1374
1375 _leave(" = 0 [done]");
1376 return 0;
1377}
1378
1379/*
1380 * YFS.StoreData64 operation type. 1234 * YFS.StoreData64 operation type.
1381 */ 1235 */
1382static const struct afs_call_type yfs_RXYFSStoreData64 = { 1236static const struct afs_call_type yfs_RXYFSStoreData64 = {
1383 .name = "YFS.StoreData64", 1237 .name = "YFS.StoreData64",
1384 .op = yfs_FS_StoreData64, 1238 .op = yfs_FS_StoreData64,
1385 .deliver = yfs_deliver_fs_store_data, 1239 .deliver = yfs_deliver_status_and_volsync,
1386 .destructor = afs_flat_call_destructor, 1240 .destructor = afs_flat_call_destructor,
1387}; 1241};
1388 1242
@@ -1391,7 +1245,8 @@ static const struct afs_call_type yfs_RXYFSStoreData64 = {
1391 */ 1245 */
1392int yfs_fs_store_data(struct afs_fs_cursor *fc, struct address_space *mapping, 1246int yfs_fs_store_data(struct afs_fs_cursor *fc, struct address_space *mapping,
1393 pgoff_t first, pgoff_t last, 1247 pgoff_t first, pgoff_t last,
1394 unsigned offset, unsigned to) 1248 unsigned offset, unsigned to,
1249 struct afs_status_cb *scb)
1395{ 1250{
1396 struct afs_vnode *vnode = fc->vnode; 1251 struct afs_vnode *vnode = fc->vnode;
1397 struct afs_call *call; 1252 struct afs_call *call;
@@ -1429,13 +1284,12 @@ int yfs_fs_store_data(struct afs_fs_cursor *fc, struct address_space *mapping,
1429 1284
1430 call->key = fc->key; 1285 call->key = fc->key;
1431 call->mapping = mapping; 1286 call->mapping = mapping;
1432 call->xvnode = vnode;
1433 call->first = first; 1287 call->first = first;
1434 call->last = last; 1288 call->last = last;
1435 call->first_offset = offset; 1289 call->first_offset = offset;
1436 call->last_to = to; 1290 call->last_to = to;
1437 call->send_pages = true; 1291 call->send_pages = true;
1438 call->expected_version = vnode->status.data_version + 1; 1292 call->out_scb = scb;
1439 1293
1440 /* marshall the parameters */ 1294 /* marshall the parameters */
1441 bp = call->request; 1295 bp = call->request;
@@ -1456,46 +1310,19 @@ int yfs_fs_store_data(struct afs_fs_cursor *fc, struct address_space *mapping,
1456} 1310}
1457 1311
1458/* 1312/*
1459 * deliver reply data to an FS.StoreStatus
1460 */
1461static int yfs_deliver_fs_store_status(struct afs_call *call)
1462{
1463 struct afs_vnode *vnode = call->xvnode;
1464 const __be32 *bp;
1465 int ret;
1466
1467 _enter("");
1468
1469 ret = afs_transfer_reply(call);
1470 if (ret < 0)
1471 return ret;
1472
1473 /* unmarshall the reply once we've received all of it */
1474 bp = call->buffer;
1475 ret = yfs_decode_status(call, &bp, &vnode->status, vnode,
1476 &call->expected_version, NULL);
1477 if (ret < 0)
1478 return ret;
1479 xdr_decode_YFSVolSync(&bp, NULL);
1480
1481 _leave(" = 0 [done]");
1482 return 0;
1483}
1484
1485/*
1486 * YFS.StoreStatus operation type 1313 * YFS.StoreStatus operation type
1487 */ 1314 */
1488static const struct afs_call_type yfs_RXYFSStoreStatus = { 1315static const struct afs_call_type yfs_RXYFSStoreStatus = {
1489 .name = "YFS.StoreStatus", 1316 .name = "YFS.StoreStatus",
1490 .op = yfs_FS_StoreStatus, 1317 .op = yfs_FS_StoreStatus,
1491 .deliver = yfs_deliver_fs_store_status, 1318 .deliver = yfs_deliver_status_and_volsync,
1492 .destructor = afs_flat_call_destructor, 1319 .destructor = afs_flat_call_destructor,
1493}; 1320};
1494 1321
1495static const struct afs_call_type yfs_RXYFSStoreData64_as_Status = { 1322static const struct afs_call_type yfs_RXYFSStoreData64_as_Status = {
1496 .name = "YFS.StoreData64", 1323 .name = "YFS.StoreData64",
1497 .op = yfs_FS_StoreData64, 1324 .op = yfs_FS_StoreData64,
1498 .deliver = yfs_deliver_fs_store_status, 1325 .deliver = yfs_deliver_status_and_volsync,
1499 .destructor = afs_flat_call_destructor, 1326 .destructor = afs_flat_call_destructor,
1500}; 1327};
1501 1328
@@ -1503,7 +1330,8 @@ static const struct afs_call_type yfs_RXYFSStoreData64_as_Status = {
1503 * Set the attributes on a file, using YFS.StoreData64 rather than 1330 * Set the attributes on a file, using YFS.StoreData64 rather than
1504 * YFS.StoreStatus so as to alter the file size also. 1331 * YFS.StoreStatus so as to alter the file size also.
1505 */ 1332 */
1506static int yfs_fs_setattr_size(struct afs_fs_cursor *fc, struct iattr *attr) 1333static int yfs_fs_setattr_size(struct afs_fs_cursor *fc, struct iattr *attr,
1334 struct afs_status_cb *scb)
1507{ 1335{
1508 struct afs_vnode *vnode = fc->vnode; 1336 struct afs_vnode *vnode = fc->vnode;
1509 struct afs_call *call; 1337 struct afs_call *call;
@@ -1524,8 +1352,7 @@ static int yfs_fs_setattr_size(struct afs_fs_cursor *fc, struct iattr *attr)
1524 return -ENOMEM; 1352 return -ENOMEM;
1525 1353
1526 call->key = fc->key; 1354 call->key = fc->key;
1527 call->xvnode = vnode; 1355 call->out_scb = scb;
1528 call->expected_version = vnode->status.data_version + 1;
1529 1356
1530 /* marshall the parameters */ 1357 /* marshall the parameters */
1531 bp = call->request; 1358 bp = call->request;
@@ -1549,7 +1376,8 @@ static int yfs_fs_setattr_size(struct afs_fs_cursor *fc, struct iattr *attr)
1549 * Set the attributes on a file, using YFS.StoreData64 if there's a change in 1376 * Set the attributes on a file, using YFS.StoreData64 if there's a change in
1550 * file size, and YFS.StoreStatus otherwise. 1377 * file size, and YFS.StoreStatus otherwise.
1551 */ 1378 */
1552int yfs_fs_setattr(struct afs_fs_cursor *fc, struct iattr *attr) 1379int yfs_fs_setattr(struct afs_fs_cursor *fc, struct iattr *attr,
1380 struct afs_status_cb *scb)
1553{ 1381{
1554 struct afs_vnode *vnode = fc->vnode; 1382 struct afs_vnode *vnode = fc->vnode;
1555 struct afs_call *call; 1383 struct afs_call *call;
@@ -1557,7 +1385,7 @@ int yfs_fs_setattr(struct afs_fs_cursor *fc, struct iattr *attr)
1557 __be32 *bp; 1385 __be32 *bp;
1558 1386
1559 if (attr->ia_valid & ATTR_SIZE) 1387 if (attr->ia_valid & ATTR_SIZE)
1560 return yfs_fs_setattr_size(fc, attr); 1388 return yfs_fs_setattr_size(fc, attr, scb);
1561 1389
1562 _enter(",%x,{%llx:%llu},,", 1390 _enter(",%x,{%llx:%llu},,",
1563 key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode); 1391 key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
@@ -1572,8 +1400,7 @@ int yfs_fs_setattr(struct afs_fs_cursor *fc, struct iattr *attr)
1572 return -ENOMEM; 1400 return -ENOMEM;
1573 1401
1574 call->key = fc->key; 1402 call->key = fc->key;
1575 call->xvnode = vnode; 1403 call->out_scb = scb;
1576 call->expected_version = vnode->status.data_version;
1577 1404
1578 /* marshall the parameters */ 1405 /* marshall the parameters */
1579 bp = call->request; 1406 bp = call->request;
@@ -1764,34 +1591,6 @@ int yfs_fs_get_volume_status(struct afs_fs_cursor *fc,
1764} 1591}
1765 1592
1766/* 1593/*
1767 * Deliver reply data to operations that just return a file status and a volume
1768 * sync record.
1769 */
1770static int yfs_deliver_status_and_volsync(struct afs_call *call)
1771{
1772 struct afs_vnode *vnode = call->xvnode;
1773 const __be32 *bp;
1774 int ret;
1775
1776 _enter("{%u}", call->unmarshall);
1777
1778 ret = afs_transfer_reply(call);
1779 if (ret < 0)
1780 return ret;
1781
1782 /* unmarshall the reply once we've received all of it */
1783 bp = call->buffer;
1784 ret = yfs_decode_status(call, &bp, &vnode->status, vnode,
1785 &call->expected_version, NULL);
1786 if (ret < 0)
1787 return ret;
1788 xdr_decode_YFSVolSync(&bp, NULL);
1789
1790 _leave(" = 0 [done]");
1791 return 0;
1792}
1793
1794/*
1795 * YFS.SetLock operation type 1594 * YFS.SetLock operation type
1796 */ 1595 */
1797static const struct afs_call_type yfs_RXYFSSetLock = { 1596static const struct afs_call_type yfs_RXYFSSetLock = {
@@ -1826,7 +1625,8 @@ static const struct afs_call_type yfs_RXYFSReleaseLock = {
1826/* 1625/*
1827 * Set a lock on a file 1626 * Set a lock on a file
1828 */ 1627 */
1829int yfs_fs_set_lock(struct afs_fs_cursor *fc, afs_lock_type_t type) 1628int yfs_fs_set_lock(struct afs_fs_cursor *fc, afs_lock_type_t type,
1629 struct afs_status_cb *scb)
1830{ 1630{
1831 struct afs_vnode *vnode = fc->vnode; 1631 struct afs_vnode *vnode = fc->vnode;
1832 struct afs_call *call; 1632 struct afs_call *call;
@@ -1845,7 +1645,8 @@ int yfs_fs_set_lock(struct afs_fs_cursor *fc, afs_lock_type_t type)
1845 return -ENOMEM; 1645 return -ENOMEM;
1846 1646
1847 call->key = fc->key; 1647 call->key = fc->key;
1848 call->xvnode = vnode; 1648 call->lvnode = vnode;
1649 call->out_scb = scb;
1849 1650
1850 /* marshall the parameters */ 1651 /* marshall the parameters */
1851 bp = call->request; 1652 bp = call->request;
@@ -1865,7 +1666,7 @@ int yfs_fs_set_lock(struct afs_fs_cursor *fc, afs_lock_type_t type)
1865/* 1666/*
1866 * extend a lock on a file 1667 * extend a lock on a file
1867 */ 1668 */
1868int yfs_fs_extend_lock(struct afs_fs_cursor *fc) 1669int yfs_fs_extend_lock(struct afs_fs_cursor *fc, struct afs_status_cb *scb)
1869{ 1670{
1870 struct afs_vnode *vnode = fc->vnode; 1671 struct afs_vnode *vnode = fc->vnode;
1871 struct afs_call *call; 1672 struct afs_call *call;
@@ -1883,7 +1684,8 @@ int yfs_fs_extend_lock(struct afs_fs_cursor *fc)
1883 return -ENOMEM; 1684 return -ENOMEM;
1884 1685
1885 call->key = fc->key; 1686 call->key = fc->key;
1886 call->xvnode = vnode; 1687 call->lvnode = vnode;
1688 call->out_scb = scb;
1887 1689
1888 /* marshall the parameters */ 1690 /* marshall the parameters */
1889 bp = call->request; 1691 bp = call->request;
@@ -1902,7 +1704,7 @@ int yfs_fs_extend_lock(struct afs_fs_cursor *fc)
1902/* 1704/*
1903 * release a lock on a file 1705 * release a lock on a file
1904 */ 1706 */
1905int yfs_fs_release_lock(struct afs_fs_cursor *fc) 1707int yfs_fs_release_lock(struct afs_fs_cursor *fc, struct afs_status_cb *scb)
1906{ 1708{
1907 struct afs_vnode *vnode = fc->vnode; 1709 struct afs_vnode *vnode = fc->vnode;
1908 struct afs_call *call; 1710 struct afs_call *call;
@@ -1920,7 +1722,8 @@ int yfs_fs_release_lock(struct afs_fs_cursor *fc)
1920 return -ENOMEM; 1722 return -ENOMEM;
1921 1723
1922 call->key = fc->key; 1724 call->key = fc->key;
1923 call->xvnode = vnode; 1725 call->lvnode = vnode;
1726 call->out_scb = scb;
1924 1727
1925 /* marshall the parameters */ 1728 /* marshall the parameters */
1926 bp = call->request; 1729 bp = call->request;
@@ -1937,42 +1740,12 @@ int yfs_fs_release_lock(struct afs_fs_cursor *fc)
1937} 1740}
1938 1741
1939/* 1742/*
1940 * Deliver reply data to an FS.FetchStatus with no vnode.
1941 */
1942static int yfs_deliver_fs_fetch_status(struct afs_call *call)
1943{
1944 struct afs_file_status *status = call->out_extra_status;
1945 struct afs_callback *callback = call->out_cb;
1946 struct afs_volsync *volsync = call->out_volsync;
1947 const __be32 *bp;
1948 int ret;
1949
1950 ret = afs_transfer_reply(call);
1951 if (ret < 0)
1952 return ret;
1953
1954 _enter("");
1955
1956 /* unmarshall the reply once we've received all of it */
1957 bp = call->buffer;
1958 ret = yfs_decode_status(call, &bp, status, NULL,
1959 &call->expected_version, NULL);
1960 if (ret < 0)
1961 return ret;
1962 xdr_decode_YFSCallBack_raw(call, callback, &bp);
1963 xdr_decode_YFSVolSync(&bp, volsync);
1964
1965 _leave(" = 0 [done]");
1966 return 0;
1967}
1968
1969/*
1970 * YFS.FetchStatus operation type 1743 * YFS.FetchStatus operation type
1971 */ 1744 */
1972static const struct afs_call_type yfs_RXYFSFetchStatus = { 1745static const struct afs_call_type yfs_RXYFSFetchStatus = {
1973 .name = "YFS.FetchStatus", 1746 .name = "YFS.FetchStatus",
1974 .op = yfs_FS_FetchStatus, 1747 .op = yfs_FS_FetchStatus,
1975 .deliver = yfs_deliver_fs_fetch_status, 1748 .deliver = yfs_deliver_fs_status_cb_and_volsync,
1976 .destructor = afs_flat_call_destructor, 1749 .destructor = afs_flat_call_destructor,
1977}; 1750};
1978 1751
@@ -1982,8 +1755,7 @@ static const struct afs_call_type yfs_RXYFSFetchStatus = {
1982int yfs_fs_fetch_status(struct afs_fs_cursor *fc, 1755int yfs_fs_fetch_status(struct afs_fs_cursor *fc,
1983 struct afs_net *net, 1756 struct afs_net *net,
1984 struct afs_fid *fid, 1757 struct afs_fid *fid,
1985 struct afs_file_status *status, 1758 struct afs_status_cb *scb,
1986 struct afs_callback *callback,
1987 struct afs_volsync *volsync) 1759 struct afs_volsync *volsync)
1988{ 1760{
1989 struct afs_call *call; 1761 struct afs_call *call;
@@ -2004,10 +1776,8 @@ int yfs_fs_fetch_status(struct afs_fs_cursor *fc,
2004 } 1776 }
2005 1777
2006 call->key = fc->key; 1778 call->key = fc->key;
2007 call->out_extra_status = status; 1779 call->out_scb = scb;
2008 call->out_cb = callback;
2009 call->out_volsync = volsync; 1780 call->out_volsync = volsync;
2010 call->expected_version = 1; /* vnode->status.data_version */
2011 1781
2012 /* marshall the parameters */ 1782 /* marshall the parameters */
2013 bp = call->request; 1783 bp = call->request;
@@ -2016,7 +1786,6 @@ int yfs_fs_fetch_status(struct afs_fs_cursor *fc,
2016 bp = xdr_encode_YFSFid(bp, fid); 1786 bp = xdr_encode_YFSFid(bp, fid);
2017 yfs_check_req(call, bp); 1787 yfs_check_req(call, bp);
2018 1788
2019 call->cb_break = fc->cb_break;
2020 afs_use_fs_server(call, fc->cbi); 1789 afs_use_fs_server(call, fc->cbi);
2021 trace_afs_make_fs_call(call, fid); 1790 trace_afs_make_fs_call(call, fid);
2022 afs_set_fc_call(call, fc); 1791 afs_set_fc_call(call, fc);
@@ -2069,8 +1838,7 @@ static int yfs_deliver_fs_inline_bulk_status(struct afs_call *call)
2069 1838
2070 bp = call->buffer; 1839 bp = call->buffer;
2071 scb = &call->out_scb[call->count]; 1840 scb = &call->out_scb[call->count];
2072 ret = yfs_decode_status(call, &bp, &scb->status, 1841 ret = xdr_decode_YFSFetchStatus(&bp, call, scb);
2073 NULL, NULL, NULL);
2074 if (ret < 0) 1842 if (ret < 0)
2075 return ret; 1843 return ret;
2076 1844
@@ -2110,8 +1878,7 @@ static int yfs_deliver_fs_inline_bulk_status(struct afs_call *call)
2110 _debug("unmarshall CB array"); 1878 _debug("unmarshall CB array");
2111 bp = call->buffer; 1879 bp = call->buffer;
2112 scb = &call->out_scb[call->count]; 1880 scb = &call->out_scb[call->count];
2113 xdr_decode_YFSCallBack_raw(call, &scb->callback, &bp); 1881 xdr_decode_YFSCallBack(&bp, call, scb);
2114 scb->have_cb = true;
2115 call->count++; 1882 call->count++;
2116 if (call->count < call->count2) 1883 if (call->count < call->count2)
2117 goto more_cbs; 1884 goto more_cbs;
@@ -2191,7 +1958,6 @@ int yfs_fs_inline_bulk_status(struct afs_fs_cursor *fc,
2191 bp = xdr_encode_YFSFid(bp, &fids[i]); 1958 bp = xdr_encode_YFSFid(bp, &fids[i]);
2192 yfs_check_req(call, bp); 1959 yfs_check_req(call, bp);
2193 1960
2194 call->cb_break = fc->cb_break;
2195 afs_use_fs_server(call, fc->cbi); 1961 afs_use_fs_server(call, fc->cbi);
2196 trace_afs_make_fs_call(call, &fids[0]); 1962 trace_afs_make_fs_call(call, &fids[0]);
2197 afs_set_fc_call(call, fc); 1963 afs_set_fc_call(call, fc);
@@ -2204,8 +1970,6 @@ int yfs_fs_inline_bulk_status(struct afs_fs_cursor *fc,
2204 */ 1970 */
2205static int yfs_deliver_fs_fetch_opaque_acl(struct afs_call *call) 1971static int yfs_deliver_fs_fetch_opaque_acl(struct afs_call *call)
2206{ 1972{
2207 struct afs_volsync *volsync = call->out_volsync;
2208 struct afs_vnode *vnode = call->xvnode;
2209 struct yfs_acl *yacl = call->out_yacl; 1973 struct yfs_acl *yacl = call->out_yacl;
2210 struct afs_acl *acl; 1974 struct afs_acl *acl;
2211 const __be32 *bp; 1975 const __be32 *bp;
@@ -2291,11 +2055,10 @@ static int yfs_deliver_fs_fetch_opaque_acl(struct afs_call *call)
2291 bp = call->buffer; 2055 bp = call->buffer;
2292 yacl->inherit_flag = ntohl(*bp++); 2056 yacl->inherit_flag = ntohl(*bp++);
2293 yacl->num_cleaned = ntohl(*bp++); 2057 yacl->num_cleaned = ntohl(*bp++);
2294 ret = yfs_decode_status(call, &bp, &vnode->status, vnode, 2058 ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
2295 &call->expected_version, NULL);
2296 if (ret < 0) 2059 if (ret < 0)
2297 return ret; 2060 return ret;
2298 xdr_decode_YFSVolSync(&bp, volsync); 2061 xdr_decode_YFSVolSync(&bp, call->out_volsync);
2299 2062
2300 call->unmarshall++; 2063 call->unmarshall++;
2301 2064
@@ -2330,7 +2093,8 @@ static const struct afs_call_type yfs_RXYFSFetchOpaqueACL = {
2330 * Fetch the YFS advanced ACLs for a file. 2093 * Fetch the YFS advanced ACLs for a file.
2331 */ 2094 */
2332struct yfs_acl *yfs_fs_fetch_opaque_acl(struct afs_fs_cursor *fc, 2095struct yfs_acl *yfs_fs_fetch_opaque_acl(struct afs_fs_cursor *fc,
2333 struct yfs_acl *yacl) 2096 struct yfs_acl *yacl,
2097 struct afs_status_cb *scb)
2334{ 2098{
2335 struct afs_vnode *vnode = fc->vnode; 2099 struct afs_vnode *vnode = fc->vnode;
2336 struct afs_call *call; 2100 struct afs_call *call;
@@ -2353,8 +2117,8 @@ struct yfs_acl *yfs_fs_fetch_opaque_acl(struct afs_fs_cursor *fc,
2353 2117
2354 call->key = fc->key; 2118 call->key = fc->key;
2355 call->out_yacl = yacl; 2119 call->out_yacl = yacl;
2356 call->xvnode = vnode; 2120 call->out_scb = scb;
2357 call->out_volsync = NULL; /* volsync */ 2121 call->out_volsync = NULL;
2358 2122
2359 /* marshall the parameters */ 2123 /* marshall the parameters */
2360 bp = call->request; 2124 bp = call->request;
@@ -2363,7 +2127,6 @@ struct yfs_acl *yfs_fs_fetch_opaque_acl(struct afs_fs_cursor *fc,
2363 bp = xdr_encode_YFSFid(bp, &vnode->fid); 2127 bp = xdr_encode_YFSFid(bp, &vnode->fid);
2364 yfs_check_req(call, bp); 2128 yfs_check_req(call, bp);
2365 2129
2366 call->cb_break = fc->cb_break;
2367 afs_use_fs_server(call, fc->cbi); 2130 afs_use_fs_server(call, fc->cbi);
2368 trace_afs_make_fs_call(call, &vnode->fid); 2131 trace_afs_make_fs_call(call, &vnode->fid);
2369 afs_make_call(&fc->ac, call, GFP_KERNEL); 2132 afs_make_call(&fc->ac, call, GFP_KERNEL);
@@ -2383,7 +2146,8 @@ static const struct afs_call_type yfs_RXYFSStoreOpaqueACL2 = {
2383/* 2146/*
2384 * Fetch the YFS ACL for a file. 2147 * Fetch the YFS ACL for a file.
2385 */ 2148 */
2386int yfs_fs_store_opaque_acl2(struct afs_fs_cursor *fc, const struct afs_acl *acl) 2149int yfs_fs_store_opaque_acl2(struct afs_fs_cursor *fc, const struct afs_acl *acl,
2150 struct afs_status_cb *scb)
2387{ 2151{
2388 struct afs_vnode *vnode = fc->vnode; 2152 struct afs_vnode *vnode = fc->vnode;
2389 struct afs_call *call; 2153 struct afs_call *call;
@@ -2407,7 +2171,7 @@ int yfs_fs_store_opaque_acl2(struct afs_fs_cursor *fc, const struct afs_acl *acl
2407 } 2171 }
2408 2172
2409 call->key = fc->key; 2173 call->key = fc->key;
2410 call->xvnode = vnode; 2174 call->out_scb = scb;
2411 call->out_volsync = NULL; 2175 call->out_volsync = NULL;
2412 2176
2413 /* marshall the parameters */ 2177 /* marshall the parameters */