History

Merge tag 'afs-next-20200604' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs

Pull AFS updates from David Howells: "There's some core VFS changes which affect a couple of filesystems: - Make the inode hash table RCU safe and providing some RCU-safe accessor functions. The search can then be done without taking the inode_hash_lock. Care must be taken because the object may be being deleted and no wait is made. - Allow iunique() to avoid taking the inode_hash_lock. - Allow AFS's callback processing to avoid taking the inode_hash_lock when using the inode table to find an inode to notify. - Improve Ext4's time updating. Konstantin Khlebnikov said "For now, I've plugged this issue with try-lock in ext4 lazy time update. This solution is much better." Then there's a set of changes to make a number of improvements to the AFS driver: - Improve callback (ie. third party change notification) processing by: (a) Relying more on the fact we're doing this under RCU and by using fewer locks. This makes use of the RCU-based inode searching outlined above. (b) Moving to keeping volumes in a tree indexed by volume ID rather than a flat list. (c) Making the server and volume records logically part of the cell. This means that a server record now points directly at the cell and the tree of volumes is there. This removes an N:M mapping table, simplifying things. - Improve keeping NAT or firewall channels open for the server callbacks to reach the client by actively polling the fileserver on a timed basis, instead of only doing it when we have an operation to process. - Improving detection of delayed or lost callbacks by including the parent directory in the list of file IDs to be queried when doing a bulk status fetch from lookup. We can then check to see if our copy of the directory has changed under us without us getting notified. - Determine aliasing of cells (such as a cell that is pointed to be a DNS alias). This allows us to avoid having ambiguity due to apparently different cells using the same volume and file servers. - Improve the fileserver rotation to do more probing when it detects that all of the addresses to a server are listed as non-responsive. It's possible that an address that previously stopped responding has become responsive again. Beyond that, lay some foundations for making some calls asynchronous: - Turn the fileserver cursor struct into a general operation struct and hang the parameters off of that rather than keeping them in local variables and hang results off of that rather than the call struct. - Implement some general operation handling code and simplify the callers of operations that affect a volume or a volume component (such as a file). Most of the operation is now done by core code. - Operations are supplied with a table of operations to issue different variants of RPCs and to manage the completion, where all the required data is held in the operation object, thereby allowing these to be called from a workqueue. - Put the standard "if (begin), while(select), call op, end" sequence into a canned function that just emulates the current behaviour for now. There are also some fixes interspersed: - Don't let the EACCES from ICMP6 mapping reach the user as such, since it's confusing as to whether it's a filesystem error. Convert it to EHOSTUNREACH. - Don't use the epoch value acquired through probing a server. If we have two servers with the same UUID but in different cells, it's hard to draw conclusions from them having different epoch values. - Don't interpret the argument to the CB.ProbeUuid RPC as a fileserver UUID and look up a fileserver from it. - Deal with servers in different cells having the same UUIDs. In the event that a CB.InitCallBackState3 RPC is received, we have to break the callback promises for every server record matching that UUID. - Don't let afs_statfs return values that go below 0. - Don't use running fileserver probe state to make server selection and address selection decisions on. Only make decisions on final state as the running state is cleared at the start of probing" Acked-by: Al Viro <viro@zeniv.linux.org.uk> (fs/inode.c part) * tag 'afs-next-20200604' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs: (27 commits) afs: Adjust the fileserver rotation algorithm to reprobe/retry more quickly afs: Show more a bit more server state in /proc/net/afs/servers afs: Don't use probe running state to make decisions outside probe code afs: Fix afs_statfs() to not let the values go below zero afs: Fix the by-UUID server tree to allow servers with the same UUID afs: Reorganise volume and server trees to be rooted on the cell afs: Add a tracepoint to track the lifetime of the afs_volume struct afs: Detect cell aliases 3 - YFS Cells with a canonical cell name op afs: Detect cell aliases 2 - Cells with no root volumes afs: Detect cell aliases 1 - Cells with root volumes afs: Implement client support for the YFSVL.GetCellName RPC op afs: Retain more of the VLDB record for alias detection afs: Fix handling of CB.ProbeUuid cache manager op afs: Don't get epoch from a server because it may be ambiguous afs: Build an abstraction around an "operation" concept afs: Rename struct afs_fs_cursor to afs_operation afs: Remove the error argument from afs_protocol_error() afs: Set error flag rather than return error from file status decode afs: Make callback processing more efficient. afs: Show more information in /proc/net/afs/servers ...

Linus Torvalds committed 6 years ago

Commit 9daa0a22 parents 0b166a5 8409f6738 files · +4437 −3923Browse files

Unified · Split

38 files
  1. fs/afs/Makefile +2 −0
  2. fs/afs/afs.h +1 −2
  3. fs/afs/afs_vl.h +1 −0
  4. fs/afs/callback.c +96 −249
  5. fs/afs/cell.c +8 −2
  6. fs/afs/cmservice.c +11 −56
  7. fs/afs/dir.c +580 −673
  8. fs/afs/dir_silly.c +99 −91
  9. fs/afs/dynroot.c +93 −0
  10. fs/afs/file.c +32 −30
  11. fs/afs/flock.c +53 −61
  12. fs/afs/fs_operation.c +239 −0
  13. fs/afs/fs_probe.c +266 −73
  14. fs/afs/fsclient.c +511 −794
  15. fs/afs/inode.c +224 −267
  16. fs/afs/internal.h +299 −224
  17. fs/afs/main.c +5 −1
  18. fs/afs/proc.c +23 −19
  19. fs/afs/protocol_yfs.h +1 −1
  20. fs/afs/rotate.c +162 −285
  21. fs/afs/rxrpc.c +26 −19
  22. fs/afs/security.c +3 −5
  23. fs/afs/server.c +197 −102
  24. fs/afs/server_list.c +8 −32
  25. fs/afs/super.c +59 −48
  26. fs/afs/vl_alias.c +382 −0
  27. fs/afs/vl_rotate.c +4 −0
  28. fs/afs/vlclient.c +126 −20
  29. fs/afs/volume.c +119 −35
  30. fs/afs/write.c +90 −58
  31. fs/afs/xattr.c +127 −173
  32. fs/afs/yfsclient.c +375 −539
  33. fs/ext4/inode.c +22 −22
  34. fs/inode.c +96 −16
  35. include/linux/fs.h +3 −0
  36. include/trace/events/afs.h +88 −23
  37. net/rxrpc/peer_event.c +3 −0
  38. net/rxrpc/proc.c +3 −3
fs/afs/Makefile+2−0
@@ -18,6 +18,7 @@ kafs-y := \ · 17 unmodified lines
1818 file.o \
1919 flock.o \
2020 fsclient.o \
21+ fs_operation.o \
2122 fs_probe.o \
2223 inode.o \
2324 main.o \
@@ -30,6 +31,7 @@ kafs-y := \ · 6 unmodified lines
3031 server_list.o \
3132 super.o \
3233 vlclient.o \
34+ vl_alias.o \
3335 vl_list.o \
3436 vl_probe.o \
3537 vl_rotate.o \
fs/afs/afs.h+1−2
@@ -10,7 +10,7 @@ · 9 unmodified lines
1010
1111 #include <linux/in.h>
1212
13−#define AFS_MAXCELLNAME 64 /* Maximum length of a cell name */
13+#define AFS_MAXCELLNAME 256 /* Maximum length of a cell name */
1414 #define AFS_MAXVOLNAME 64 /* Maximum length of a volume name */
1515 #define AFS_MAXNSERVERS 8 /* Maximum servers in a basic volume record */
1616 #define AFS_NMAXNSERVERS 13 /* Maximum servers in a N/U-class volume record */
@@ -146,7 +146,6 @@ struct afs_file_status { · 129 unmodified lines
146146 struct afs_status_cb {
147147 struct afs_file_status status;
148148 struct afs_callback callback;
149− unsigned int cb_break; /* Pre-op callback break counter */
150149 bool have_status; /* True if status record was retrieved */
151150 bool have_cb; /* True if cb record was retrieved */
152151 bool have_error; /* True if status.abort_code indicates an error */
fs/afs/afs_vl.h+1−0
@@ -22,6 +22,7 @@ enum AFSVL_Operations { · 21 unmodified lines
2222 VLGETENTRYBYNAMEU = 527, /* AFS Get VLDB entry by name (UUID-variant) */
2323 VLGETADDRSU = 533, /* AFS Get addrs for fileserver */
2424 YVLGETENDPOINTS = 64002, /* YFS Get endpoints for file/volume server */
25+ YVLGETCELLNAME = 64014, /* YFS Get actual cell name */
2526 VLGETCAPABILITIES = 65537, /* AFS Get server capabilities */
2627 };
2728
fs/afs/callback.c+96−249
@@ -21,192 +21,17 @@ · 20 unmodified lines
2121 #include "internal.h"
2222
2323 /*
24− * Create volume and callback interests on a server.
25− */
26−static struct afs_cb_interest *afs_create_interest(struct afs_server *server,
27− struct afs_vnode *vnode)
28−{
29− struct afs_vol_interest *new_vi, *vi;
30− struct afs_cb_interest *new;
31− struct hlist_node **pp;
32−
33− new_vi = kzalloc(sizeof(struct afs_vol_interest), GFP_KERNEL);
34− if (!new_vi)
35− return NULL;
36−
37− new = kzalloc(sizeof(struct afs_cb_interest), GFP_KERNEL);
38− if (!new) {
39− kfree(new_vi);
40− return NULL;
41− }
42−
43− new_vi->usage = 1;
44− new_vi->vid = vnode->volume->vid;
45− INIT_HLIST_NODE(&new_vi->srv_link);
46− INIT_HLIST_HEAD(&new_vi->cb_interests);
47−
48− refcount_set(&new->usage, 1);
49− new->sb = vnode->vfs_inode.i_sb;
50− new->vid = vnode->volume->vid;
51− new->server = afs_get_server(server, afs_server_trace_get_new_cbi);
52− INIT_HLIST_NODE(&new->cb_vlink);
53−
54− write_lock(&server->cb_break_lock);
55−
56− for (pp = &server->cb_volumes.first; *pp; pp = &(*pp)->next) {
57− vi = hlist_entry(*pp, struct afs_vol_interest, srv_link);
58− if (vi->vid < new_vi->vid)
59− continue;
60− if (vi->vid > new_vi->vid)
61− break;
62− vi->usage++;
63− goto found_vi;
64− }
65−
66− new_vi->srv_link.pprev = pp;
67− new_vi->srv_link.next = *pp;
68− if (*pp)
69− (*pp)->pprev = &new_vi->srv_link.next;
70− *pp = &new_vi->srv_link;
71− vi = new_vi;
72− new_vi = NULL;
73−found_vi:
74−
75− new->vol_interest = vi;
76− hlist_add_head(&new->cb_vlink, &vi->cb_interests);
77−
78− write_unlock(&server->cb_break_lock);
79− kfree(new_vi);
80− return new;
81−}
82−
83−/*
84− * Set up an interest-in-callbacks record for a volume on a server and
85− * register it with the server.
86− * - Called with vnode->io_lock held.
87− */
88−int afs_register_server_cb_interest(struct afs_vnode *vnode,
89− struct afs_server_list *slist,
90− unsigned int index)
91−{
92− struct afs_server_entry *entry = &slist->servers[index];
93− struct afs_cb_interest *cbi, *vcbi, *new, *old;
94− struct afs_server *server = entry->server;
95−
96−again:
97− vcbi = rcu_dereference_protected(vnode->cb_interest,
98− lockdep_is_held(&vnode->io_lock));
99− if (vcbi && likely(vcbi == entry->cb_interest))
100− return 0;
101−
102− read_lock(&slist->lock);
103− cbi = afs_get_cb_interest(entry->cb_interest);
104− read_unlock(&slist->lock);
105−
106− if (vcbi) {
107− if (vcbi == cbi) {
108− afs_put_cb_interest(afs_v2net(vnode), cbi);
109− return 0;
110− }
111−
112− /* Use a new interest in the server list for the same server
113− * rather than an old one that's still attached to a vnode.
114− */
115− if (cbi && vcbi->server == cbi->server) {
116− write_seqlock(&vnode->cb_lock);
117− old = rcu_dereference_protected(vnode->cb_interest,
118− lockdep_is_held(&vnode->cb_lock.lock));
119− rcu_assign_pointer(vnode->cb_interest, cbi);
120− write_sequnlock(&vnode->cb_lock);
121− afs_put_cb_interest(afs_v2net(vnode), old);
122− return 0;
123− }
124−
125− /* Re-use the one attached to the vnode. */
126− if (!cbi && vcbi->server == server) {
127− write_lock(&slist->lock);
128− if (entry->cb_interest) {
129− write_unlock(&slist->lock);
130− afs_put_cb_interest(afs_v2net(vnode), cbi);
131− goto again;
132− }
133−
134− entry->cb_interest = cbi;
135− write_unlock(&slist->lock);
136− return 0;
137− }
138− }
139−
140− if (!cbi) {
141− new = afs_create_interest(server, vnode);
142− if (!new)
143− return -ENOMEM;
144−
145− write_lock(&slist->lock);
146− if (!entry->cb_interest) {
147− entry->cb_interest = afs_get_cb_interest(new);
148− cbi = new;
149− new = NULL;
150− } else {
151− cbi = afs_get_cb_interest(entry->cb_interest);
152− }
153− write_unlock(&slist->lock);
154− afs_put_cb_interest(afs_v2net(vnode), new);
155− }
156−
157− ASSERT(cbi);
158−
159− /* Change the server the vnode is using. This entails scrubbing any
160− * interest the vnode had in the previous server it was using.
161− */
162− write_seqlock(&vnode->cb_lock);
163−
164− old = rcu_dereference_protected(vnode->cb_interest,
165− lockdep_is_held(&vnode->cb_lock.lock));
166− rcu_assign_pointer(vnode->cb_interest, cbi);
167− vnode->cb_s_break = cbi->server->cb_s_break;
168− vnode->cb_v_break = vnode->volume->cb_v_break;
169− clear_bit(AFS_VNODE_CB_PROMISED, &vnode->flags);
170−
171− write_sequnlock(&vnode->cb_lock);
172− afs_put_cb_interest(afs_v2net(vnode), old);
173− return 0;
174−}
175−
176−/*
177− * Remove an interest on a server.
178− */
179−void afs_put_cb_interest(struct afs_net *net, struct afs_cb_interest *cbi)
180−{
181− struct afs_vol_interest *vi;
182−
183− if (cbi && refcount_dec_and_test(&cbi->usage)) {
184− if (!hlist_unhashed(&cbi->cb_vlink)) {
185− write_lock(&cbi->server->cb_break_lock);
186−
187− hlist_del_init(&cbi->cb_vlink);
188− vi = cbi->vol_interest;
189− cbi->vol_interest = NULL;
190− if (--vi->usage == 0)
191− hlist_del(&vi->srv_link);
192− else
193− vi = NULL;
194−
195− write_unlock(&cbi->server->cb_break_lock);
196− if (vi)
197− kfree_rcu(vi, rcu);
198− afs_put_server(net, cbi->server, afs_server_trace_put_cbi);
199− }
200− kfree_rcu(cbi, rcu);
201− }
202−}
203−
204−/*
205− * allow the fileserver to request callback state (re-)initialisation
24+ * Allow the fileserver to request callback state (re-)initialisation.
25+ * Unfortunately, UUIDs are not guaranteed unique.
20626 */
20727 void afs_init_callback_state(struct afs_server *server)
20828 {
209− server->cb_s_break++;
29+ rcu_read_lock();
30+ do {
31+ server->cb_s_break++;
32+ server = rcu_dereference(server->uuid_next);
33+ } while (0);
34+ rcu_read_unlock();
21035 }
21136
21237 /*
@@ -237,70 +62,110 @@ void afs_break_callback(struct afs_vnode *vnode, enum afs_cb_break_reason reason · 24 unmodified lines
23762 write_sequnlock(&vnode->cb_lock);
23863 }
23964
65+/*
66+ * Look up a volume by volume ID under RCU conditions.
67+ */
68+static struct afs_volume *afs_lookup_volume_rcu(struct afs_cell *cell,
69+ afs_volid_t vid)
70+{
71+ struct afs_volume *volume = NULL;
72+ struct rb_node *p;
73+ int seq = 0;
74+
75+ do {
76+ /* Unfortunately, rbtree walking doesn't give reliable results
77+ * under just the RCU read lock, so we have to check for
78+ * changes.
79+ */
80+ read_seqbegin_or_lock(&cell->volume_lock, &seq);
81+
82+ p = rcu_dereference_raw(cell->volumes.rb_node);
83+ while (p) {
84+ volume = rb_entry(p, struct afs_volume, cell_node);
85+
86+ if (volume->vid < vid)
87+ p = rcu_dereference_raw(p->rb_left);
88+ else if (volume->vid > vid)
89+ p = rcu_dereference_raw(p->rb_right);
90+ else
91+ break;
92+ volume = NULL;
93+ }
94+
95+ } while (need_seqretry(&cell->volume_lock, seq));
96+
97+ done_seqretry(&cell->volume_lock, seq);
98+ return volume;
99+}
100+
240101 /*
241102 * allow the fileserver to explicitly break one callback
242103 * - happens when
243104 * - the backing file is changed
244105 * - a lock is released
245106 */
246−static void afs_break_one_callback(struct afs_server *server,
107+static void afs_break_one_callback(struct afs_volume *volume,
247108 struct afs_fid *fid)
248109 {
249− struct afs_vol_interest *vi;
250− struct afs_cb_interest *cbi;
251− struct afs_iget_data data;
110+ struct super_block *sb;
252111 struct afs_vnode *vnode;
253112 struct inode *inode;
254113
255− read_lock(&server->cb_break_lock);
256− hlist_for_each_entry(vi, &server->cb_volumes, srv_link) {
257− if (vi->vid < fid->vid)
258− continue;
259− if (vi->vid > fid->vid) {
260− vi = NULL;
261− break;
262− }
263− //atomic_inc(&vi->usage);
264− break;
114+ if (fid->vnode == 0 && fid->unique == 0) {
115+ /* The callback break applies to an entire volume. */
116+ write_lock(&volume->cb_v_break_lock);
117+ volume->cb_v_break++;
118+ trace_afs_cb_break(fid, volume->cb_v_break,
119+ afs_cb_break_for_volume_callback, false);
120+ write_unlock(&volume->cb_v_break_lock);
121+ return;
265122 }
266123
267− /* TODO: Find all matching volumes if we couldn't match the server and
268− * break them anyway.
124+ /* See if we can find a matching inode - even an I_NEW inode needs to
125+ * be marked as it can have its callback broken before we finish
126+ * setting up the local inode.
269127 */
270− if (!vi)
271− goto out;
128+ sb = rcu_dereference(volume->sb);
129+ if (!sb)
130+ return;
131+
132+ inode = find_inode_rcu(sb, fid->vnode, afs_ilookup5_test_by_fid, fid);
133+ if (inode) {
134+ vnode = AFS_FS_I(inode);
135+ afs_break_callback(vnode, afs_cb_break_for_callback);
136+ } else {
137+ trace_afs_cb_miss(fid, afs_cb_break_for_callback);
138+ }
139+}
140+
141+static void afs_break_some_callbacks(struct afs_server *server,
142+ struct afs_callback_break *cbb,
143+ size_t *_count)
144+{
145+ struct afs_callback_break *residue = cbb;
146+ struct afs_volume *volume;
147+ afs_volid_t vid = cbb->fid.vid;
148+ size_t i;
272149
273− /* Step through all interested superblocks. There may be more than one
274− * because of cell aliasing.
150+ volume = afs_lookup_volume_rcu(server->cell, vid);
151+
152+ /* TODO: Find all matching volumes if we couldn't match the server and
153+ * break them anyway.
275154 */
276− hlist_for_each_entry(cbi, &vi->cb_interests, cb_vlink) {
277− if (fid->vnode == 0 && fid->unique == 0) {
278− /* The callback break applies to an entire volume. */
279− struct afs_super_info *as = AFS_FS_S(cbi->sb);
280− struct afs_volume *volume = as->volume;
281155
282− write_lock(&volume->cb_v_break_lock);
283− volume->cb_v_break++;
284− trace_afs_cb_break(fid, volume->cb_v_break,
285− afs_cb_break_for_volume_callback, false);
286− write_unlock(&volume->cb_v_break_lock);
156+ for (i = *_count; i > 0; cbb++, i--) {
157+ if (cbb->fid.vid == vid) {
158+ _debug("- Fid { vl=%08llx n=%llu u=%u }",
159+ cbb->fid.vid,
160+ cbb->fid.vnode,
161+ cbb->fid.unique);
162+ --*_count;
163+ if (volume)
164+ afs_break_one_callback(volume, &cbb->fid);
287165 } else {
288− data.volume = NULL;
289− data.fid = *fid;
290− inode = ilookup5_nowait(cbi->sb, fid->vnode,
291− afs_iget5_test, &data);
292− if (inode) {
293− vnode = AFS_FS_I(inode);
294− afs_break_callback(vnode, afs_cb_break_for_callback);
295− iput(inode);
296− } else {
297− trace_afs_cb_miss(fid, afs_cb_break_for_callback);
298− }
166+ *residue++ = *cbb;
299167 }
300168 }
301−
302−out:
303− read_unlock(&server->cb_break_lock);
304169 }
305170
306171 /*
@@ -313,29 +178,11 @@ void afs_break_callbacks(struct afs_server *server, size_t count, · 6 unmodified lines
313178
314179 ASSERT(server != NULL);
315180
316− /* TODO: Sort the callback break list by volume ID */
181+ rcu_read_lock();
317182
318− for (; count > 0; callbacks++, count--) {
319− _debug("- Fid { vl=%08llx n=%llu u=%u }",
320− callbacks->fid.vid,
321− callbacks->fid.vnode,
322− callbacks->fid.unique);
323− afs_break_one_callback(server, &callbacks->fid);
324− }
183+ while (count > 0)
184+ afs_break_some_callbacks(server, callbacks, &count);
325185
326− _leave("");
186+ rcu_read_unlock();
327187 return;
328188 }
329−
330−/*
331− * Clear the callback interests in a server list.
332− */
333−void afs_clear_callback_interests(struct afs_net *net, struct afs_server_list *slist)
334−{
335− int i;
336−
337− for (i = 0; i < slist->nr_servers; i++) {
338− afs_put_cb_interest(net, slist->servers[i].cb_interest);
339− slist->servers[i].cb_interest = NULL;
340− }
341−}
fs/afs/cell.c+8−2
@@ -161,9 +161,13 @@ static struct afs_cell *afs_alloc_cell(struct afs_net *net, · 160 unmodified lines
161161
162162 atomic_set(&cell->usage, 2);
163163 INIT_WORK(&cell->manager, afs_manage_cell);
164− INIT_LIST_HEAD(&cell->proc_volumes);
165− rwlock_init(&cell->proc_lock);
164+ cell->volumes = RB_ROOT;
165+ INIT_HLIST_HEAD(&cell->proc_volumes);
166+ seqlock_init(&cell->volume_lock);
167+ cell->fs_servers = RB_ROOT;
168+ seqlock_init(&cell->fs_lock);
166169 rwlock_init(&cell->vl_servers_lock);
170+ cell->flags = (1 << AFS_CELL_FL_CHECK_ALIAS);
167171
168172 /* Provide a VL server list, filling it in if we were given a list of
169173 * addresses to use.
@@ -481,7 +485,9 @@ static void afs_cell_destroy(struct rcu_head *rcu) · 311 unmodified lines
481485
482486 ASSERTCMP(atomic_read(&cell->usage), ==, 0);
483487
488+ afs_put_volume(cell->net, cell->root_volume, afs_volume_trace_put_cell_root);
484489 afs_put_vlserverlist(cell->net, rcu_access_pointer(cell->vl_servers));
490+ afs_put_cell(cell->net, cell->alias_of);
485491 key_put(cell->anonymous_key);
486492 kfree(cell);
487493
fs/afs/cmservice.c+11−56
@@ -118,8 +118,6 @@ bool afs_cm_incoming_call(struct afs_call *call) · 117 unmodified lines
118118 {
119119 _enter("{%u, CB.OP %u}", call->service_id, call->operation_ID);
120120
121− call->epoch = rxrpc_kernel_get_epoch(call->net->socket, call->rxcall);
122−
123121 switch (call->operation_ID) {
124122 case CBCallBack:
125123 call->type = &afs_SRXCBCallBack;
@@ -149,49 +147,6 @@ bool afs_cm_incoming_call(struct afs_call *call) · 23 unmodified lines
149147 }
150148 }
151149
152−/*
153− * Record a probe to the cache manager from a server.
154− */
155−static int afs_record_cm_probe(struct afs_call *call, struct afs_server *server)
156−{
157− _enter("");
158−
159− if (test_bit(AFS_SERVER_FL_HAVE_EPOCH, &server->flags) &&
160− !test_bit(AFS_SERVER_FL_PROBING, &server->flags)) {
161− if (server->cm_epoch == call->epoch)
162− return 0;
163−
164− if (!server->probe.said_rebooted) {
165− pr_notice("kAFS: FS rebooted %pU\n", &server->uuid);
166− server->probe.said_rebooted = true;
167− }
168− }
169−
170− spin_lock(&server->probe_lock);
171−
172− if (!test_and_set_bit(AFS_SERVER_FL_HAVE_EPOCH, &server->flags)) {
173− server->cm_epoch = call->epoch;
174− server->probe.cm_epoch = call->epoch;
175− goto out;
176− }
177−
178− if (server->probe.cm_probed &&
179− call->epoch != server->probe.cm_epoch &&
180− !server->probe.said_inconsistent) {
181− pr_notice("kAFS: FS endpoints inconsistent %pU\n",
182− &server->uuid);
183− server->probe.said_inconsistent = true;
184− }
185−
186− if (!server->probe.cm_probed || call->epoch == server->cm_epoch)
187− server->probe.cm_epoch = server->cm_epoch;
188−
189−out:
190− server->probe.cm_probed = true;
191− spin_unlock(&server->probe_lock);
192− return 0;
193−}
194−
195150 /*
196151 * Find the server record by peer address and record a probe to the cache
197152 * manager from a server.
@@ -210,7 +165,7 @@ static int afs_find_cm_server_by_peer(struct afs_call *call) · 12 unmodified lines
210165 }
211166
212167 call->server = server;
213− return afs_record_cm_probe(call, server);
168+ return 0;
214169 }
215170
216171 /*
@@ -231,7 +186,7 @@ static int afs_find_cm_server_by_uuid(struct afs_call *call, · 14 unmodified lines
231186 }
232187
233188 call->server = server;
234− return afs_record_cm_probe(call, server);
189+ return 0;
235190 }
236191
237192 /*
@@ -268,7 +223,9 @@ static void SRXAFSCB_CallBack(struct work_struct *work) · 30 unmodified lines
268223 * to maintain cache coherency.
269224 */
270225 if (call->server) {
271− trace_afs_server(call->server, atomic_read(&call->server->usage),
226+ trace_afs_server(call->server,
227+ atomic_read(&call->server->ref),
228+ atomic_read(&call->server->active),
272229 afs_server_trace_callback);
273230 afs_break_callbacks(call->server, call->count, call->request);
274231 }
@@ -305,8 +262,7 @@ static int afs_deliver_cb_callback(struct afs_call *call) · 30 unmodified lines
305262 call->count = ntohl(call->tmp);
306263 _debug("FID count: %u", call->count);
307264 if (call->count > AFSCBMAX)
308− return afs_protocol_error(call, -EBADMSG,
309− afs_eproto_cb_fid_count);
265+ return afs_protocol_error(call, afs_eproto_cb_fid_count);
310266
311267 call->buffer = kmalloc(array3_size(call->count, 3, 4),
312268 GFP_KERNEL);
@@ -351,8 +307,7 @@ static int afs_deliver_cb_callback(struct afs_call *call) · 38 unmodified lines
351307 call->count2 = ntohl(call->tmp);
352308 _debug("CB count: %u", call->count2);
353309 if (call->count2 != call->count && call->count2 != 0)
354− return afs_protocol_error(call, -EBADMSG,
355− afs_eproto_cb_count);
310+ return afs_protocol_error(call, afs_eproto_cb_count);
356311 call->iter = &call->def_iter;
357312 iov_iter_discard(&call->def_iter, READ, call->count2 * 3 * 4);
358313 call->unmarshall++;
@@ -509,7 +464,8 @@ static int afs_deliver_cb_probe(struct afs_call *call) · 150 unmodified lines
509464 }
510465
511466 /*
512− * allow the fileserver to quickly find out if the fileserver has been rebooted
467+ * Allow the fileserver to quickly find out if the cache manager has been
468+ * rebooted.
513469 */
514470 static void SRXAFSCB_ProbeUuid(struct work_struct *work)
515471 {
@@ -581,7 +537,7 @@ static int afs_deliver_cb_probe_uuid(struct afs_call *call) · 65 unmodified lines
581537
582538 if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING))
583539 return afs_io_error(call, afs_io_error_cm_reply);
584− return afs_find_cm_server_by_uuid(call, call->request);
540+ return afs_find_cm_server_by_peer(call);
585541 }
586542
587543 /*
@@ -672,8 +628,7 @@ static int afs_deliver_yfs_cb_callback(struct afs_call *call) · 84 unmodified lines
672628 call->count = ntohl(call->tmp);
673629 _debug("FID count: %u", call->count);
674630 if (call->count > YFSCBMAX)
675− return afs_protocol_error(call, -EBADMSG,
676− afs_eproto_cb_fid_count);
631+ return afs_protocol_error(call, afs_eproto_cb_fid_count);
677632
678633 size = array_size(call->count, sizeof(struct yfs_xdr_YFSFid));
679634 call->buffer = kmalloc(size, GFP_KERNEL);
fs/afs/dir.c+580−673
@@ -99,8 +99,6 @@ struct afs_lookup_cookie { · 98 unmodified lines
9999 bool found;
100100 bool one_only;
101101 unsigned short nr_fids;
102− struct inode **inodes;
103− struct afs_status_cb *statuses;
104102 struct afs_fid fids[50];
105103 };
106104
@@ -618,8 +616,8 @@ static int afs_lookup_filldir(struct dir_context *ctx, const char *name, · 511 unmodified lines
618616 }
619617 } else if (cookie->name.len == nlen &&
620618 memcmp(cookie->name.name, name, nlen) == 0) {
621− cookie->fids[0].vnode = ino;
622− cookie->fids[0].unique = dtype;
619+ cookie->fids[1].vnode = ino;
620+ cookie->fids[1].unique = dtype;
623621 cookie->found = 1;
624622 if (cookie->one_only)
625623 return -1;
@@ -630,6 +628,111 @@ static int afs_lookup_filldir(struct dir_context *ctx, const char *name, · 4 unmodified lines
630628 return ret;
631629 }
632630
631+/*
632+ * Deal with the result of a successful lookup operation. Turn all the files
633+ * into inodes and save the first one - which is the one we actually want.
634+ */
635+static void afs_do_lookup_success(struct afs_operation *op)
636+{
637+ struct afs_vnode_param *vp;
638+ struct afs_vnode *vnode;
639+ struct inode *inode;
640+ u32 abort_code;
641+ int i;
642+
643+ _enter("");
644+
645+ for (i = 0; i < op->nr_files; i++) {
646+ switch (i) {
647+ case 0:
648+ vp = &op->file[0];
649+ abort_code = vp->scb.status.abort_code;
650+ if (abort_code != 0) {
651+ op->abort_code = abort_code;
652+ op->error = afs_abort_to_error(abort_code);
653+ }
654+ break;
655+
656+ case 1:
657+ vp = &op->file[1];
658+ break;
659+
660+ default:
661+ vp = &op->more_files[i - 2];
662+ break;
663+ }
664+
665+ if (!vp->scb.have_status && !vp->scb.have_error)
666+ continue;
667+
668+ _debug("do [%u]", i);
669+ if (vp->vnode) {
670+ if (!test_bit(AFS_VNODE_UNSET, &vp->vnode->flags))
671+ afs_vnode_commit_status(op, vp);
672+ } else if (vp->scb.status.abort_code == 0) {
673+ inode = afs_iget(op, vp);
674+ if (!IS_ERR(inode)) {
675+ vnode = AFS_FS_I(inode);
676+ afs_cache_permit(vnode, op->key,
677+ 0 /* Assume vnode->cb_break is 0 */ +
678+ op->cb_v_break,
679+ &vp->scb);
680+ vp->vnode = vnode;
681+ vp->put_vnode = true;
682+ }
683+ } else {
684+ _debug("- abort %d %llx:%llx.%x",
685+ vp->scb.status.abort_code,
686+ vp->fid.vid, vp->fid.vnode, vp->fid.unique);
687+ }
688+ }
689+
690+ _leave("");
691+}
692+
693+static const struct afs_operation_ops afs_inline_bulk_status_operation = {
694+ .issue_afs_rpc = afs_fs_inline_bulk_status,
695+ .issue_yfs_rpc = yfs_fs_inline_bulk_status,
696+ .success = afs_do_lookup_success,
697+};
698+
699+static const struct afs_operation_ops afs_fetch_status_operation = {
700+ .issue_afs_rpc = afs_fs_fetch_status,
701+ .issue_yfs_rpc = yfs_fs_fetch_status,
702+ .success = afs_do_lookup_success,
703+};
704+
705+/*
706+ * See if we know that the server we expect to use doesn't support
707+ * FS.InlineBulkStatus.
708+ */
709+static bool afs_server_supports_ibulk(struct afs_vnode *dvnode)
710+{
711+ struct afs_server_list *slist;
712+ struct afs_volume *volume = dvnode->volume;
713+ struct afs_server *server;
714+ bool ret = true;
715+ int i;
716+
717+ if (!test_bit(AFS_VOLUME_MAYBE_NO_IBULK, &volume->flags))
718+ return true;
719+
720+ rcu_read_lock();
721+ slist = rcu_dereference(volume->servers);
722+
723+ for (i = 0; i < slist->nr_servers; i++) {
724+ server = slist->servers[i].server;
725+ if (server == dvnode->cb_server) {
726+ if (test_bit(AFS_SERVER_FL_NO_IBULK, &server->flags))
727+ ret = false;
728+ break;
729+ }
730+ }
731+
732+ rcu_read_unlock();
733+ return ret;
734+}
735+
633736 /*
634737 * Do a lookup in a directory. We make use of bulk lookup to query a slew of
635738 * files in one go and create inodes for them. The inode of the file we were
@@ -639,16 +742,13 @@ static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry, · 3 unmodified lines
639742 struct key *key)
640743 {
641744 struct afs_lookup_cookie *cookie;
642− struct afs_cb_interest *dcbi, *cbi = NULL;
643− struct afs_super_info *as = dir->i_sb->s_fs_info;
644− struct afs_status_cb *scb;
645− struct afs_iget_data iget_data;
646− struct afs_fs_cursor fc;
647− struct afs_server *server;
745+ struct afs_vnode_param *vp;
746+ struct afs_operation *op;
648747 struct afs_vnode *dvnode = AFS_FS_I(dir), *vnode;
649748 struct inode *inode = NULL, *ti;
650749 afs_dataversion_t data_version = READ_ONCE(dvnode->status.data_version);
651− int ret, i;
750+ long ret;
751+ int i;
652752
653753 _enter("{%lu},%p{%pd},", dir->i_ino, dentry, dentry);
654754
@@ -656,72 +756,74 @@ static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry, · 1 unmodified line
656756 if (!cookie)
657757 return ERR_PTR(-ENOMEM);
658758
759+ for (i = 0; i < ARRAY_SIZE(cookie->fids); i++)
760+ cookie->fids[i].vid = dvnode->fid.vid;
659761 cookie->ctx.actor = afs_lookup_filldir;
660762 cookie->name = dentry->d_name;
661− cookie->nr_fids = 1; /* slot 0 is saved for the fid we actually want */
662−
663− read_seqlock_excl(&dvnode->cb_lock);
664− dcbi = rcu_dereference_protected(dvnode->cb_interest,
665− lockdep_is_held(&dvnode->cb_lock.lock));
666− if (dcbi) {
667− server = dcbi->server;
668− if (server &&
669− test_bit(AFS_SERVER_FL_NO_IBULK, &server->flags))
670− cookie->one_only = true;
671− }
672− read_sequnlock_excl(&dvnode->cb_lock);
763+ cookie->nr_fids = 2; /* slot 0 is saved for the fid we actually want
764+ * and slot 1 for the directory */
673765
674− for (i = 0; i < 50; i++)
675− cookie->fids[i].vid = as->volume->vid;
766+ if (!afs_server_supports_ibulk(dvnode))
767+ cookie->one_only = true;
676768
677769 /* search the directory */
678770 ret = afs_dir_iterate(dir, &cookie->ctx, key, &data_version);
679− if (ret < 0) {
680− inode = ERR_PTR(ret);
771+ if (ret < 0)
681772 goto out;
682− }
683773
684774 dentry->d_fsdata = (void *)(unsigned long)data_version;
685775
686− inode = ERR_PTR(-ENOENT);
776+ ret = -ENOENT;
687777 if (!cookie->found)
688778 goto out;
689779
690780 /* Check to see if we already have an inode for the primary fid. */
691− iget_data.fid = cookie->fids[0];
692− iget_data.volume = dvnode->volume;
693− iget_data.cb_v_break = dvnode->volume->cb_v_break;
694− iget_data.cb_s_break = 0;
695− inode = ilookup5(dir->i_sb, cookie->fids[0].vnode,
696− afs_iget5_test, &iget_data);
781+ inode = ilookup5(dir->i_sb, cookie->fids[1].vnode,
782+ afs_ilookup5_test_by_fid, &cookie->fids[1]);
697783 if (inode)
698− goto out;
784+ goto out; /* We do */
699785
700− /* Need space for examining all the selected files */
701− inode = ERR_PTR(-ENOMEM);
702− cookie->statuses = kvcalloc(cookie->nr_fids, sizeof(struct afs_status_cb),
703− GFP_KERNEL);
704− if (!cookie->statuses)
786+ /* Okay, we didn't find it. We need to query the server - and whilst
787+ * we're doing that, we're going to attempt to look up a bunch of other
788+ * vnodes also.
789+ */
790+ op = afs_alloc_operation(NULL, dvnode->volume);
791+ if (IS_ERR(op)) {
792+ ret = PTR_ERR(op);
705793 goto out;
794+ }
706795
707− cookie->inodes = kcalloc(cookie->nr_fids, sizeof(struct inode *),
708− GFP_KERNEL);
709− if (!cookie->inodes)
710− goto out_s;
796+ afs_op_set_vnode(op, 0, dvnode);
797+ afs_op_set_fid(op, 1, &cookie->fids[1]);
711798
712− for (i = 1; i < cookie->nr_fids; i++) {
713− scb = &cookie->statuses[i];
799+ op->nr_files = cookie->nr_fids;
800+ _debug("nr_files %u", op->nr_files);
714801
715− /* Find any inodes that already exist and get their
716− * callback counters.
717− */
718− iget_data.fid = cookie->fids[i];
719− ti = ilookup5_nowait(dir->i_sb, iget_data.fid.vnode,
720− afs_iget5_test, &iget_data);
721− if (!IS_ERR_OR_NULL(ti)) {
722− vnode = AFS_FS_I(ti);
723− scb->cb_break = afs_calc_vnode_cb_break(vnode);
724− cookie->inodes[i] = ti;
802+ /* Need space for examining all the selected files */
803+ op->error = -ENOMEM;
804+ if (op->nr_files > 2) {
805+ op->more_files = kvcalloc(op->nr_files - 2,
806+ sizeof(struct afs_vnode_param),
807+ GFP_KERNEL);
808+ if (!op->more_files)
809+ goto out_op;
810+
811+ for (i = 2; i < op->nr_files; i++) {
812+ vp = &op->more_files[i - 2];
813+ vp->fid = cookie->fids[i];
814+
815+ /* Find any inodes that already exist and get their
816+ * callback counters.
817+ */
818+ ti = ilookup5_nowait(dir->i_sb, vp->fid.vnode,
819+ afs_ilookup5_test_by_fid, &vp->fid);
820+ if (!IS_ERR_OR_NULL(ti)) {
821+ vnode = AFS_FS_I(ti);
822+ vp->dv_before = vnode->status.data_version;
823+ vp->cb_break_before = afs_calc_vnode_cb_break(vnode);
824+ vp->vnode = vnode;
825+ vp->put_vnode = true;
826+ }
725827 }
726828 }
727829
@@ -729,120 +831,40 @@ static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry, · 1 unmodified line
729831 * lookups contained therein are stored in the reply without aborting
730832 * the whole operation.
731833 */
732− if (cookie->one_only)
733− goto no_inline_bulk_status;
734−
735− inode = ERR_PTR(-ERESTARTSYS);
736− if (afs_begin_vnode_operation(&fc, dvnode, key, true)) {
737− while (afs_select_fileserver(&fc)) {
738− if (test_bit(AFS_SERVER_FL_NO_IBULK,
739− &fc.cbi->server->flags)) {
740− fc.ac.abort_code = RX_INVALID_OPERATION;
741− fc.ac.error = -ECONNABORTED;
742− break;
743− }
744− iget_data.cb_v_break = dvnode->volume->cb_v_break;
745− iget_data.cb_s_break = fc.cbi->server->cb_s_break;
746− afs_fs_inline_bulk_status(&fc,
747− afs_v2net(dvnode),
748− cookie->fids,
749− cookie->statuses,
750− cookie->nr_fids, NULL);
751− }
752−
753− if (fc.ac.error == 0)
754− cbi = afs_get_cb_interest(fc.cbi);
755− if (fc.ac.abort_code == RX_INVALID_OPERATION)
756− set_bit(AFS_SERVER_FL_NO_IBULK, &fc.cbi->server->flags);
757− inode = ERR_PTR(afs_end_vnode_operation(&fc));
834+ op->error = -ENOTSUPP;
835+ if (!cookie->one_only) {
836+ op->ops = &afs_inline_bulk_status_operation;
837+ afs_begin_vnode_operation(op);
838+ afs_wait_for_operation(op);
758839 }
759840
760− if (!IS_ERR(inode))
761− goto success;
762− if (fc.ac.abort_code != RX_INVALID_OPERATION)
763− goto out_c;
764−
765−no_inline_bulk_status:
766− /* We could try FS.BulkStatus next, but this aborts the entire op if
767− * any of the lookups fails - so, for the moment, revert to
768− * FS.FetchStatus for just the primary fid.
769− */
770− inode = ERR_PTR(-ERESTARTSYS);
771− if (afs_begin_vnode_operation(&fc, dvnode, key, true)) {
772− while (afs_select_fileserver(&fc)) {
773− iget_data.cb_v_break = dvnode->volume->cb_v_break;
774− iget_data.cb_s_break = fc.cbi->server->cb_s_break;
775− scb = &cookie->statuses[0];
776− afs_fs_fetch_status(&fc,
777− afs_v2net(dvnode),
778− cookie->fids,
779− scb,
780− NULL);
781− }
782−
783− if (fc.ac.error == 0)
784− cbi = afs_get_cb_interest(fc.cbi);
785− inode = ERR_PTR(afs_end_vnode_operation(&fc));
841+ if (op->error == -ENOTSUPP) {
842+ /* We could try FS.BulkStatus next, but this aborts the entire
843+ * op if any of the lookups fails - so, for the moment, revert
844+ * to FS.FetchStatus for op->file[1].
845+ */
846+ op->fetch_status.which = 1;
847+ op->ops = &afs_fetch_status_operation;
848+ afs_begin_vnode_operation(op);
849+ afs_wait_for_operation(op);
786850 }
851+ inode = ERR_PTR(op->error);
787852
788− if (IS_ERR(inode))
789− goto out_c;
790−
791−success:
792− /* Turn all the files into inodes and save the first one - which is the
793− * one we actually want.
794− */
795− scb = &cookie->statuses[0];
796− if (scb->status.abort_code != 0)
797− inode = ERR_PTR(afs_abort_to_error(scb->status.abort_code));
798−
799− for (i = 0; i < cookie->nr_fids; i++) {
800− struct afs_status_cb *scb = &cookie->statuses[i];
801−
802− if (!scb->have_status && !scb->have_error)
803− continue;
804−
805− if (cookie->inodes[i]) {
806− struct afs_vnode *iv = AFS_FS_I(cookie->inodes[i]);
807−
808− if (test_bit(AFS_VNODE_UNSET, &iv->flags))
809− continue;
810−
811− afs_vnode_commit_status(&fc, iv,
812− scb->cb_break, NULL, scb);
813− continue;
814− }
815−
816− if (scb->status.abort_code != 0)
817− continue;
818−
819− iget_data.fid = cookie->fids[i];
820− ti = afs_iget(dir->i_sb, key, &iget_data, scb, cbi, dvnode);
821− if (!IS_ERR(ti))
822− afs_cache_permit(AFS_FS_I(ti), key,
823− 0 /* Assume vnode->cb_break is 0 */ +
824− iget_data.cb_v_break,
825− scb);
826− if (i == 0) {
827− inode = ti;
828− } else {
829− if (!IS_ERR(ti))
830− iput(ti);
831− }
853+out_op:
854+ if (op->error == 0) {
855+ inode = &op->file[1].vnode->vfs_inode;
856+ op->file[1].vnode = NULL;
832857 }
833858
834−out_c:
835− afs_put_cb_interest(afs_v2net(dvnode), cbi);
836− if (cookie->inodes) {
837− for (i = 0; i < cookie->nr_fids; i++)
838− iput(cookie->inodes[i]);
839− kfree(cookie->inodes);
840− }
841−out_s:
842− kvfree(cookie->statuses);
859+ if (op->file[0].scb.have_status)
860+ dentry->d_fsdata = (void *)(unsigned long)op->file[0].scb.status.data_version;
861+ else
862+ dentry->d_fsdata = (void *)(unsigned long)op->file[0].dv_before;
863+ ret = afs_put_operation(op);
843864 out:
844865 kfree(cookie);
845− return inode;
866+ _leave("");
867+ return inode ?: ERR_PTR(ret);
846868 }
847869
848870 /*
@@ -958,6 +980,7 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry, · 109 unmodified lines
958980 if (!IS_ERR_OR_NULL(inode))
959981 fid = AFS_FS_I(inode)->fid;
960982
983+ _debug("splice %px", dentry->d_inode);
961984 d = d_splice_alias(inode, dentry);
962985 if (!IS_ERR_OR_NULL(d)) {
963986 d->d_fsdata = dentry->d_fsdata;
@@ -965,6 +988,7 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry, · 1 unmodified line
965988 } else {
966989 trace_afs_lookup(dvnode, &dentry->d_name, &fid);
967990 }
991+ _leave("");
968992 return d;
969993 }
970994
@@ -1215,130 +1239,97 @@ void afs_d_release(struct dentry *dentry) · 244 unmodified lines
12151239 /*
12161240 * Create a new inode for create/mkdir/symlink
12171241 */
1218−static void afs_vnode_new_inode(struct afs_fs_cursor *fc,
1219− struct dentry *new_dentry,
1220− struct afs_iget_data *new_data,
1221− struct afs_status_cb *new_scb)
1242+static void afs_vnode_new_inode(struct afs_operation *op)
12221243 {
1244+ struct afs_vnode_param *vp = &op->file[1];
12231245 struct afs_vnode *vnode;
12241246 struct inode *inode;
12251247
1226− if (fc->ac.error < 0)
1227− return;
1248+ _enter("");
1249+
1250+ ASSERTCMP(op->error, ==, 0);
12281251
1229− inode = afs_iget(fc->vnode->vfs_inode.i_sb, fc->key,
1230− new_data, new_scb, fc->cbi, fc->vnode);
1252+ inode = afs_iget(op, vp);
12311253 if (IS_ERR(inode)) {
12321254 /* ENOMEM or EINTR at a really inconvenient time - just abandon
12331255 * the new directory on the server.
12341256 */
1235− fc->ac.error = PTR_ERR(inode);
1257+ op->error = PTR_ERR(inode);
12361258 return;
12371259 }
12381260
12391261 vnode = AFS_FS_I(inode);
12401262 set_bit(AFS_VNODE_NEW_CONTENT, &vnode->flags);
1241− if (fc->ac.error == 0)
1242− afs_cache_permit(vnode, fc->key, vnode->cb_break, new_scb);
1243− d_instantiate(new_dentry, inode);
1263+ if (!op->error)
1264+ afs_cache_permit(vnode, op->key, vnode->cb_break, &vp->scb);
1265+ d_instantiate(op->dentry, inode);
12441266 }
12451267
1246−static void afs_prep_for_new_inode(struct afs_fs_cursor *fc,
1247− struct afs_iget_data *iget_data)
1268+static void afs_create_success(struct afs_operation *op)
12481269 {
1249− iget_data->volume = fc->vnode->volume;
1250− iget_data->cb_v_break = fc->vnode->volume->cb_v_break;
1251− iget_data->cb_s_break = fc->cbi->server->cb_s_break;
1270+ _enter("op=%08x", op->debug_id);
1271+ afs_check_for_remote_deletion(op, op->file[0].vnode);
1272+ afs_vnode_commit_status(op, &op->file[0]);
1273+ afs_update_dentry_version(op, &op->file[0], op->dentry);
1274+ afs_vnode_new_inode(op);
12521275 }
12531276
1254−/*
1255− * Note that a dentry got changed. We need to set d_fsdata to the data version
1256− * number derived from the result of the operation. It doesn't matter if
1257− * d_fsdata goes backwards as we'll just revalidate.
1258− */
1259−static void afs_update_dentry_version(struct afs_fs_cursor *fc,
1260− struct dentry *dentry,
1261− struct afs_status_cb *scb)
1277+static void afs_create_edit_dir(struct afs_operation *op)
1278+{
1279+ struct afs_vnode_param *dvp = &op->file[0];
1280+ struct afs_vnode_param *vp = &op->file[1];
1281+ struct afs_vnode *dvnode = dvp->vnode;
1282+
1283+ _enter("op=%08x", op->debug_id);
1284+
1285+ down_write(&dvnode->validate_lock);
1286+ if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) &&
1287+ dvnode->status.data_version == dvp->dv_before + dvp->dv_delta)
1288+ afs_edit_dir_add(dvnode, &op->dentry->d_name, &vp->fid,
1289+ op->create.reason);
1290+ up_write(&dvnode->validate_lock);
1291+}
1292+
1293+static void afs_create_put(struct afs_operation *op)
12621294 {
1263− if (fc->ac.error == 0)
1264− dentry->d_fsdata =
1265− (void *)(unsigned long)scb->status.data_version;
1295+ _enter("op=%08x", op->debug_id);
1296+
1297+ if (op->error)
1298+ d_drop(op->dentry);
12661299 }
12671300
1301+static const struct afs_operation_ops afs_mkdir_operation = {
1302+ .issue_afs_rpc = afs_fs_make_dir,
1303+ .issue_yfs_rpc = yfs_fs_make_dir,
1304+ .success = afs_create_success,
1305+ .edit_dir = afs_create_edit_dir,
1306+ .put = afs_create_put,
1307+};
1308+
12681309 /*
12691310 * create a directory on an AFS filesystem
12701311 */
12711312 static int afs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
12721313 {
1273− struct afs_iget_data iget_data;
1274− struct afs_status_cb *scb;
1275− struct afs_fs_cursor fc;
1314+ struct afs_operation *op;
12761315 struct afs_vnode *dvnode = AFS_FS_I(dir);
1277− struct key *key;
1278− afs_dataversion_t data_version;
1279− int ret;
1280−
1281− mode |= S_IFDIR;
12821316
12831317 _enter("{%llx:%llu},{%pd},%ho",
12841318 dvnode->fid.vid, dvnode->fid.vnode, dentry, mode);
12851319
1286− ret = -ENOMEM;
1287− scb = kcalloc(2, sizeof(struct afs_status_cb), GFP_KERNEL);
1288− if (!scb)
1289− goto error;
1290−
1291− key = afs_request_key(dvnode->volume->cell);
1292− if (IS_ERR(key)) {
1293− ret = PTR_ERR(key);
1294− goto error_scb;
1320+ op = afs_alloc_operation(NULL, dvnode->volume);
1321+ if (IS_ERR(op)) {
1322+ d_drop(dentry);
1323+ return PTR_ERR(op);
12951324 }
12961325
1297− ret = -ERESTARTSYS;
1298− if (afs_begin_vnode_operation(&fc, dvnode, key, true)) {
1299− data_version = dvnode->status.data_version + 1;
1300−
1301− while (afs_select_fileserver(&fc)) {
1302− fc.cb_break = afs_calc_vnode_cb_break(dvnode);
1303− afs_prep_for_new_inode(&fc, &iget_data);
1304− afs_fs_create(&fc, dentry->d_name.name, mode,
1305− &scb[0], &iget_data.fid, &scb[1]);
1306− }
1307−
1308− afs_check_for_remote_deletion(&fc, dvnode);
1309− afs_vnode_commit_status(&fc, dvnode, fc.cb_break,
1310− &data_version, &scb[0]);
1311− afs_update_dentry_version(&fc, dentry, &scb[0]);
1312− afs_vnode_new_inode(&fc, dentry, &iget_data, &scb[1]);
1313− ret = afs_end_vnode_operation(&fc);
1314− if (ret < 0)
1315− goto error_key;
1316− } else {
1317− goto error_key;
1318− }
1319−
1320− if (ret == 0) {
1321− down_write(&dvnode->validate_lock);
1322− if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) &&
1323− dvnode->status.data_version == data_version)
1324− afs_edit_dir_add(dvnode, &dentry->d_name, &iget_data.fid,
1325− afs_edit_dir_for_create);
1326− up_write(&dvnode->validate_lock);
1327− }
1328−
1329− key_put(key);
1330− kfree(scb);
1331− _leave(" = 0");
1332− return 0;
1333−
1334−error_key:
1335− key_put(key);
1336−error_scb:
1337− kfree(scb);
1338−error:
1339− d_drop(dentry);
1340− _leave(" = %d", ret);
1341− return ret;
1326+ afs_op_set_vnode(op, 0, dvnode);
1327+ op->file[0].dv_delta = 1;
1328+ op->dentry = dentry;
1329+ op->create.mode = S_IFDIR | mode;
1330+ op->create.reason = afs_edit_dir_for_mkdir;
1331+ op->ops = &afs_mkdir_operation;
1332+ return afs_do_sync_operation(op);
13421333 }
13431334
13441335 /*
@@ -1356,76 +1347,86 @@ static void afs_dir_remove_subdir(struct dentry *dentry) · 11 unmodified lines
13561347 }
13571348 }
13581349
1350+static void afs_rmdir_success(struct afs_operation *op)
1351+{
1352+ _enter("op=%08x", op->debug_id);
1353+ afs_check_for_remote_deletion(op, op->file[0].vnode);
1354+ afs_vnode_commit_status(op, &op->file[0]);
1355+ afs_update_dentry_version(op, &op->file[0], op->dentry);
1356+}
1357+
1358+static void afs_rmdir_edit_dir(struct afs_operation *op)
1359+{
1360+ struct afs_vnode_param *dvp = &op->file[0];
1361+ struct afs_vnode *dvnode = dvp->vnode;
1362+
1363+ _enter("op=%08x", op->debug_id);
1364+ afs_dir_remove_subdir(op->dentry);
1365+
1366+ down_write(&dvnode->validate_lock);
1367+ if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) &&
1368+ dvnode->status.data_version == dvp->dv_before + dvp->dv_delta)
1369+ afs_edit_dir_remove(dvnode, &op->dentry->d_name,
1370+ afs_edit_dir_for_rmdir);
1371+ up_write(&dvnode->validate_lock);
1372+}
1373+
1374+static void afs_rmdir_put(struct afs_operation *op)
1375+{
1376+ _enter("op=%08x", op->debug_id);
1377+ if (op->file[1].vnode)
1378+ up_write(&op->file[1].vnode->rmdir_lock);
1379+}
1380+
1381+static const struct afs_operation_ops afs_rmdir_operation = {
1382+ .issue_afs_rpc = afs_fs_remove_dir,
1383+ .issue_yfs_rpc = yfs_fs_remove_dir,
1384+ .success = afs_rmdir_success,
1385+ .edit_dir = afs_rmdir_edit_dir,
1386+ .put = afs_rmdir_put,
1387+};
1388+
13591389 /*
13601390 * remove a directory from an AFS filesystem
13611391 */
13621392 static int afs_rmdir(struct inode *dir, struct dentry *dentry)
13631393 {
1364− struct afs_status_cb *scb;
1365− struct afs_fs_cursor fc;
1394+ struct afs_operation *op;
13661395 struct afs_vnode *dvnode = AFS_FS_I(dir), *vnode = NULL;
1367− struct key *key;
1368− afs_dataversion_t data_version;
13691396 int ret;
13701397
13711398 _enter("{%llx:%llu},{%pd}",
13721399 dvnode->fid.vid, dvnode->fid.vnode, dentry);
13731400
1374− scb = kzalloc(sizeof(struct afs_status_cb), GFP_KERNEL);
1375− if (!scb)
1376− return -ENOMEM;
1401+ op = afs_alloc_operation(NULL, dvnode->volume);
1402+ if (IS_ERR(op))
1403+ return PTR_ERR(op);
13771404
1378− key = afs_request_key(dvnode->volume->cell);
1379− if (IS_ERR(key)) {
1380− ret = PTR_ERR(key);
1381− goto error;
1382− }
1405+ afs_op_set_vnode(op, 0, dvnode);
1406+ op->file[0].dv_delta = 1;
1407+
1408+ op->dentry = dentry;
1409+ op->ops = &afs_rmdir_operation;
13831410
13841411 /* Try to make sure we have a callback promise on the victim. */
13851412 if (d_really_is_positive(dentry)) {
13861413 vnode = AFS_FS_I(d_inode(dentry));
1387− ret = afs_validate(vnode, key);
1414+ ret = afs_validate(vnode, op->key);
13881415 if (ret < 0)
1389− goto error_key;
1416+ goto error;
13901417 }
13911418
13921419 if (vnode) {
13931420 ret = down_write_killable(&vnode->rmdir_lock);
13941421 if (ret < 0)
1395− goto error_key;
1422+ goto error;
1423+ op->file[1].vnode = vnode;
13961424 }
13971425
1398− ret = -ERESTARTSYS;
1399− if (afs_begin_vnode_operation(&fc, dvnode, key, true)) {
1400− data_version = dvnode->status.data_version + 1;
1401−
1402− while (afs_select_fileserver(&fc)) {
1403− fc.cb_break = afs_calc_vnode_cb_break(dvnode);
1404− afs_fs_remove(&fc, vnode, dentry->d_name.name, true, scb);
1405− }
1406−
1407− afs_vnode_commit_status(&fc, dvnode, fc.cb_break,
1408− &data_version, scb);
1409− afs_update_dentry_version(&fc, dentry, scb);
1410− ret = afs_end_vnode_operation(&fc);
1411− if (ret == 0) {
1412− afs_dir_remove_subdir(dentry);
1413− down_write(&dvnode->validate_lock);
1414− if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) &&
1415− dvnode->status.data_version == data_version)
1416− afs_edit_dir_remove(dvnode, &dentry->d_name,
1417− afs_edit_dir_for_rmdir);
1418− up_write(&dvnode->validate_lock);
1419− }
1420− }
1426+ return afs_do_sync_operation(op);
14211427
1422− if (vnode)
1423− up_write(&vnode->rmdir_lock);
1424−error_key:
1425− key_put(key);
14261428 error:
1427− kfree(scb);
1428− return ret;
1429+ return afs_put_operation(op);
14291430 }
14301431
14311432 /*
@@ -1438,52 +1439,90 @@ error: · 6 unmodified lines
14381439 * However, if we didn't have a callback promise outstanding, or it was
14391440 * outstanding on a different server, then it won't break it either...
14401441 */
1441−static int afs_dir_remove_link(struct afs_vnode *dvnode, struct dentry *dentry,
1442− struct key *key)
1442+static void afs_dir_remove_link(struct afs_operation *op)
14431443 {
1444− int ret = 0;
1444+ struct afs_vnode *dvnode = op->file[0].vnode;
1445+ struct afs_vnode *vnode = op->file[1].vnode;
1446+ struct dentry *dentry = op->dentry;
1447+ int ret;
14451448
1446− if (d_really_is_positive(dentry)) {
1447− struct afs_vnode *vnode = AFS_FS_I(d_inode(dentry));
1449+ if (op->error != 0 ||
1450+ (op->file[1].scb.have_status && op->file[1].scb.have_error))
1451+ return;
1452+ if (d_really_is_positive(dentry))
1453+ return;
14481454
1449− if (test_bit(AFS_VNODE_DELETED, &vnode->flags)) {
1450− /* Already done */
1451− } else if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags)) {
1452− write_seqlock(&vnode->cb_lock);
1453− drop_nlink(&vnode->vfs_inode);
1454− if (vnode->vfs_inode.i_nlink == 0) {
1455− set_bit(AFS_VNODE_DELETED, &vnode->flags);
1456− __afs_break_callback(vnode, afs_cb_break_for_unlink);
1457− }
1458− write_sequnlock(&vnode->cb_lock);
1459− ret = 0;
1460− } else {
1461− afs_break_callback(vnode, afs_cb_break_for_unlink);
1455+ if (test_bit(AFS_VNODE_DELETED, &vnode->flags)) {
1456+ /* Already done */
1457+ } else if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags)) {
1458+ write_seqlock(&vnode->cb_lock);
1459+ drop_nlink(&vnode->vfs_inode);
1460+ if (vnode->vfs_inode.i_nlink == 0) {
1461+ set_bit(AFS_VNODE_DELETED, &vnode->flags);
1462+ __afs_break_callback(vnode, afs_cb_break_for_unlink);
1463+ }
1464+ write_sequnlock(&vnode->cb_lock);
1465+ } else {
1466+ afs_break_callback(vnode, afs_cb_break_for_unlink);
14621467
1463− if (test_bit(AFS_VNODE_DELETED, &vnode->flags))
1464− kdebug("AFS_VNODE_DELETED");
1468+ if (test_bit(AFS_VNODE_DELETED, &vnode->flags))
1469+ _debug("AFS_VNODE_DELETED");
14651470
1466− ret = afs_validate(vnode, key);
1467− if (ret == -ESTALE)
1468− ret = 0;
1469− }
1470− _debug("nlink %d [val %d]", vnode->vfs_inode.i_nlink, ret);
1471+ ret = afs_validate(vnode, op->key);
1472+ if (ret != -ESTALE)
1473+ op->error = ret;
14711474 }
14721475
1473− return ret;
1476+ _debug("nlink %d [val %d]", vnode->vfs_inode.i_nlink, op->error);
1477+}
1478+
1479+static void afs_unlink_success(struct afs_operation *op)
1480+{
1481+ _enter("op=%08x", op->debug_id);
1482+ afs_check_for_remote_deletion(op, op->file[0].vnode);
1483+ afs_vnode_commit_status(op, &op->file[0]);
1484+ afs_vnode_commit_status(op, &op->file[1]);
1485+ afs_update_dentry_version(op, &op->file[0], op->dentry);
1486+ afs_dir_remove_link(op);
1487+}
1488+
1489+static void afs_unlink_edit_dir(struct afs_operation *op)
1490+{
1491+ struct afs_vnode_param *dvp = &op->file[0];
1492+ struct afs_vnode *dvnode = dvp->vnode;
1493+
1494+ _enter("op=%08x", op->debug_id);
1495+ down_write(&dvnode->validate_lock);
1496+ if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) &&
1497+ dvnode->status.data_version == dvp->dv_before + dvp->dv_delta)
1498+ afs_edit_dir_remove(dvnode, &op->dentry->d_name,
1499+ afs_edit_dir_for_unlink);
1500+ up_write(&dvnode->validate_lock);
1501+}
1502+
1503+static void afs_unlink_put(struct afs_operation *op)
1504+{
1505+ _enter("op=%08x", op->debug_id);
1506+ if (op->unlink.need_rehash && op->error < 0 && op->error != -ENOENT)
1507+ d_rehash(op->dentry);
14741508 }
14751509
1510+static const struct afs_operation_ops afs_unlink_operation = {
1511+ .issue_afs_rpc = afs_fs_remove_file,
1512+ .issue_yfs_rpc = yfs_fs_remove_file,
1513+ .success = afs_unlink_success,
1514+ .edit_dir = afs_unlink_edit_dir,
1515+ .put = afs_unlink_put,
1516+};
1517+
14761518 /*
14771519 * Remove a file or symlink from an AFS filesystem.
14781520 */
14791521 static int afs_unlink(struct inode *dir, struct dentry *dentry)
14801522 {
1481− struct afs_fs_cursor fc;
1482− struct afs_status_cb *scb;
1523+ struct afs_operation *op;
14831524 struct afs_vnode *dvnode = AFS_FS_I(dir);
14841525 struct afs_vnode *vnode = AFS_FS_I(d_inode(dentry));
1485− struct key *key;
1486− bool need_rehash = false;
14871526 int ret;
14881527
14891528 _enter("{%llx:%llu},{%pd}",
@@ -1492,269 +1531,176 @@ static int afs_unlink(struct inode *dir, struct dentry *dentry) · 2 unmodified lines
14921531 if (dentry->d_name.len >= AFSNAMEMAX)
14931532 return -ENAMETOOLONG;
14941533
1495− ret = -ENOMEM;
1496− scb = kcalloc(2, sizeof(struct afs_status_cb), GFP_KERNEL);
1497− if (!scb)
1498− goto error;
1534+ op = afs_alloc_operation(NULL, dvnode->volume);
1535+ if (IS_ERR(op))
1536+ return PTR_ERR(op);
14991537
1500− key = afs_request_key(dvnode->volume->cell);
1501− if (IS_ERR(key)) {
1502− ret = PTR_ERR(key);
1503− goto error_scb;
1504− }
1538+ afs_op_set_vnode(op, 0, dvnode);
1539+ op->file[0].dv_delta = 1;
15051540
15061541 /* Try to make sure we have a callback promise on the victim. */
1507− ret = afs_validate(vnode, key);
1508− if (ret < 0)
1509− goto error_key;
1542+ ret = afs_validate(vnode, op->key);
1543+ if (ret < 0) {
1544+ op->error = ret;
1545+ goto error;
1546+ }
15101547
15111548 spin_lock(&dentry->d_lock);
15121549 if (d_count(dentry) > 1) {
15131550 spin_unlock(&dentry->d_lock);
15141551 /* Start asynchronous writeout of the inode */
15151552 write_inode_now(d_inode(dentry), 0);
1516− ret = afs_sillyrename(dvnode, vnode, dentry, key);
1517− goto error_key;
1553+ op->error = afs_sillyrename(dvnode, vnode, dentry, op->key);
1554+ goto error;
15181555 }
15191556 if (!d_unhashed(dentry)) {
15201557 /* Prevent a race with RCU lookup. */
15211558 __d_drop(dentry);
1522− need_rehash = true;
1559+ op->unlink.need_rehash = true;
15231560 }
15241561 spin_unlock(&dentry->d_lock);
15251562
1526− ret = -ERESTARTSYS;
1527− if (afs_begin_vnode_operation(&fc, dvnode, key, true)) {
1528− afs_dataversion_t data_version = dvnode->status.data_version + 1;
1529− afs_dataversion_t data_version_2 = vnode->status.data_version;
1530−
1531− while (afs_select_fileserver(&fc)) {
1532− fc.cb_break = afs_calc_vnode_cb_break(dvnode);
1533− fc.cb_break_2 = afs_calc_vnode_cb_break(vnode);
1534−
1535− if (test_bit(AFS_SERVER_FL_IS_YFS, &fc.cbi->server->flags) &&
1536− !test_bit(AFS_SERVER_FL_NO_RM2, &fc.cbi->server->flags)) {
1537− yfs_fs_remove_file2(&fc, vnode, dentry->d_name.name,
1538− &scb[0], &scb[1]);
1539− if (fc.ac.error != -ECONNABORTED ||
1540− fc.ac.abort_code != RXGEN_OPCODE)
1541− continue;
1542− set_bit(AFS_SERVER_FL_NO_RM2, &fc.cbi->server->flags);
1543− }
1544−
1545− afs_fs_remove(&fc, vnode, dentry->d_name.name, false, &scb[0]);
1546− }
1563+ op->file[1].vnode = vnode;
1564+ op->dentry = dentry;
1565+ op->ops = &afs_unlink_operation;
1566+ return afs_do_sync_operation(op);
15471567
1548− afs_vnode_commit_status(&fc, dvnode, fc.cb_break,
1549− &data_version, &scb[0]);
1550− afs_vnode_commit_status(&fc, vnode, fc.cb_break_2,
1551− &data_version_2, &scb[1]);
1552− afs_update_dentry_version(&fc, dentry, &scb[0]);
1553− ret = afs_end_vnode_operation(&fc);
1554− if (ret == 0 && !(scb[1].have_status || scb[1].have_error))
1555− ret = afs_dir_remove_link(dvnode, dentry, key);
1556−
1557− if (ret == 0) {
1558− down_write(&dvnode->validate_lock);
1559− if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) &&
1560− dvnode->status.data_version == data_version)
1561− afs_edit_dir_remove(dvnode, &dentry->d_name,
1562− afs_edit_dir_for_unlink);
1563− up_write(&dvnode->validate_lock);
1564− }
1565− }
1566−
1567− if (need_rehash && ret < 0 && ret != -ENOENT)
1568− d_rehash(dentry);
1569−
1570−error_key:
1571− key_put(key);
1572−error_scb:
1573− kfree(scb);
15741568 error:
1575− _leave(" = %d", ret);
1576− return ret;
1569+ return afs_put_operation(op);
15771570 }
15781571
1572+static const struct afs_operation_ops afs_create_operation = {
1573+ .issue_afs_rpc = afs_fs_create_file,
1574+ .issue_yfs_rpc = yfs_fs_create_file,
1575+ .success = afs_create_success,
1576+ .edit_dir = afs_create_edit_dir,
1577+ .put = afs_create_put,
1578+};
1579+
15791580 /*
15801581 * create a regular file on an AFS filesystem
15811582 */
15821583 static int afs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
15831584 bool excl)
15841585 {
1585− struct afs_iget_data iget_data;
1586− struct afs_fs_cursor fc;
1587− struct afs_status_cb *scb;
1586+ struct afs_operation *op;
15881587 struct afs_vnode *dvnode = AFS_FS_I(dir);
1589− struct key *key;
1590− afs_dataversion_t data_version;
1591− int ret;
1592−
1593− mode |= S_IFREG;
1588+ int ret = -ENAMETOOLONG;
15941589
1595− _enter("{%llx:%llu},{%pd},%ho,",
1590+ _enter("{%llx:%llu},{%pd},%ho",
15961591 dvnode->fid.vid, dvnode->fid.vnode, dentry, mode);
15971592
1598− ret = -ENAMETOOLONG;
15991593 if (dentry->d_name.len >= AFSNAMEMAX)
16001594 goto error;
16011595
1602− key = afs_request_key(dvnode->volume->cell);
1603− if (IS_ERR(key)) {
1604− ret = PTR_ERR(key);
1596+ op = afs_alloc_operation(NULL, dvnode->volume);
1597+ if (IS_ERR(op)) {
1598+ ret = PTR_ERR(op);
16051599 goto error;
16061600 }
16071601
1608− ret = -ENOMEM;
1609− scb = kcalloc(2, sizeof(struct afs_status_cb), GFP_KERNEL);
1610− if (!scb)
1611− goto error_scb;
1602+ afs_op_set_vnode(op, 0, dvnode);
1603+ op->file[0].dv_delta = 1;
16121604
1613− ret = -ERESTARTSYS;
1614− if (afs_begin_vnode_operation(&fc, dvnode, key, true)) {
1615− data_version = dvnode->status.data_version + 1;
1616−
1617− while (afs_select_fileserver(&fc)) {
1618− fc.cb_break = afs_calc_vnode_cb_break(dvnode);
1619− afs_prep_for_new_inode(&fc, &iget_data);
1620− afs_fs_create(&fc, dentry->d_name.name, mode,
1621− &scb[0], &iget_data.fid, &scb[1]);
1622− }
1605+ op->dentry = dentry;
1606+ op->create.mode = S_IFREG | mode;
1607+ op->create.reason = afs_edit_dir_for_create;
1608+ op->ops = &afs_create_operation;
1609+ return afs_do_sync_operation(op);
16231610
1624− afs_check_for_remote_deletion(&fc, dvnode);
1625− afs_vnode_commit_status(&fc, dvnode, fc.cb_break,
1626− &data_version, &scb[0]);
1627− afs_update_dentry_version(&fc, dentry, &scb[0]);
1628− afs_vnode_new_inode(&fc, dentry, &iget_data, &scb[1]);
1629− ret = afs_end_vnode_operation(&fc);
1630− if (ret < 0)
1631− goto error_key;
1632− } else {
1633− goto error_key;
1634− }
1635−
1636− down_write(&dvnode->validate_lock);
1637− if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) &&
1638− dvnode->status.data_version == data_version)
1639− afs_edit_dir_add(dvnode, &dentry->d_name, &iget_data.fid,
1640− afs_edit_dir_for_create);
1641− up_write(&dvnode->validate_lock);
1642−
1643− kfree(scb);
1644− key_put(key);
1645− _leave(" = 0");
1646− return 0;
1647−
1648−error_scb:
1649− kfree(scb);
1650−error_key:
1651− key_put(key);
16521611 error:
16531612 d_drop(dentry);
16541613 _leave(" = %d", ret);
16551614 return ret;
16561615 }
16571616
1617+static void afs_link_success(struct afs_operation *op)
1618+{
1619+ struct afs_vnode_param *dvp = &op->file[0];
1620+ struct afs_vnode_param *vp = &op->file[1];
1621+
1622+ _enter("op=%08x", op->debug_id);
1623+ afs_vnode_commit_status(op, dvp);
1624+ afs_vnode_commit_status(op, vp);
1625+ afs_update_dentry_version(op, dvp, op->dentry);
1626+ if (op->dentry_2->d_parent == op->dentry->d_parent)
1627+ afs_update_dentry_version(op, dvp, op->dentry_2);
1628+ ihold(&vp->vnode->vfs_inode);
1629+ d_instantiate(op->dentry, &vp->vnode->vfs_inode);
1630+}
1631+
1632+static void afs_link_put(struct afs_operation *op)
1633+{
1634+ _enter("op=%08x", op->debug_id);
1635+ if (op->error)
1636+ d_drop(op->dentry);
1637+}
1638+
1639+static const struct afs_operation_ops afs_link_operation = {
1640+ .issue_afs_rpc = afs_fs_link,
1641+ .issue_yfs_rpc = yfs_fs_link,
1642+ .success = afs_link_success,
1643+ .edit_dir = afs_create_edit_dir,
1644+ .put = afs_link_put,
1645+};
1646+
16581647 /*
16591648 * create a hard link between files in an AFS filesystem
16601649 */
16611650 static int afs_link(struct dentry *from, struct inode *dir,
16621651 struct dentry *dentry)
16631652 {
1664− struct afs_fs_cursor fc;
1665− struct afs_status_cb *scb;
1653+ struct afs_operation *op;
16661654 struct afs_vnode *dvnode = AFS_FS_I(dir);
16671655 struct afs_vnode *vnode = AFS_FS_I(d_inode(from));
1668− struct key *key;
1669− afs_dataversion_t data_version;
1670− int ret;
1656+ int ret = -ENAMETOOLONG;
16711657
16721658 _enter("{%llx:%llu},{%llx:%llu},{%pd}",
16731659 vnode->fid.vid, vnode->fid.vnode,
16741660 dvnode->fid.vid, dvnode->fid.vnode,
16751661 dentry);
16761662
1677− ret = -ENAMETOOLONG;
16781663 if (dentry->d_name.len >= AFSNAMEMAX)
16791664 goto error;
16801665
1681− ret = -ENOMEM;
1682− scb = kcalloc(2, sizeof(struct afs_status_cb), GFP_KERNEL);
1683− if (!scb)
1666+ op = afs_alloc_operation(NULL, dvnode->volume);
1667+ if (IS_ERR(op)) {
1668+ ret = PTR_ERR(op);
16841669 goto error;
1685−
1686− key = afs_request_key(dvnode->volume->cell);
1687− if (IS_ERR(key)) {
1688− ret = PTR_ERR(key);
1689− goto error_scb;
1690− }
1691−
1692− ret = -ERESTARTSYS;
1693− if (afs_begin_vnode_operation(&fc, dvnode, key, true)) {
1694− data_version = dvnode->status.data_version + 1;
1695−
1696− if (mutex_lock_interruptible_nested(&vnode->io_lock, 1) < 0) {
1697− afs_end_vnode_operation(&fc);
1698− goto error_key;
1699− }
1700−
1701− while (afs_select_fileserver(&fc)) {
1702− fc.cb_break = afs_calc_vnode_cb_break(dvnode);
1703− fc.cb_break_2 = afs_calc_vnode_cb_break(vnode);
1704− afs_fs_link(&fc, vnode, dentry->d_name.name,
1705− &scb[0], &scb[1]);
1706− }
1707−
1708− afs_vnode_commit_status(&fc, dvnode, fc.cb_break,
1709− &data_version, &scb[0]);
1710− afs_vnode_commit_status(&fc, vnode, fc.cb_break_2,
1711− NULL, &scb[1]);
1712− ihold(&vnode->vfs_inode);
1713− afs_update_dentry_version(&fc, dentry, &scb[0]);
1714− d_instantiate(dentry, &vnode->vfs_inode);
1715−
1716− mutex_unlock(&vnode->io_lock);
1717− ret = afs_end_vnode_operation(&fc);
1718− if (ret < 0)
1719− goto error_key;
1720− } else {
1721− goto error_key;
17221670 }
17231671
1724− down_write(&dvnode->validate_lock);
1725− if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) &&
1726− dvnode->status.data_version == data_version)
1727− afs_edit_dir_add(dvnode, &dentry->d_name, &vnode->fid,
1728− afs_edit_dir_for_link);
1729− up_write(&dvnode->validate_lock);
1672+ afs_op_set_vnode(op, 0, dvnode);
1673+ afs_op_set_vnode(op, 1, vnode);
1674+ op->file[0].dv_delta = 1;
17301675
1731− key_put(key);
1732− kfree(scb);
1733− _leave(" = 0");
1734− return 0;
1676+ op->dentry = dentry;
1677+ op->dentry_2 = from;
1678+ op->ops = &afs_link_operation;
1679+ op->create.reason = afs_edit_dir_for_link;
1680+ return afs_do_sync_operation(op);
17351681
1736−error_key:
1737− key_put(key);
1738−error_scb:
1739− kfree(scb);
17401682 error:
17411683 d_drop(dentry);
17421684 _leave(" = %d", ret);
17431685 return ret;
17441686 }
17451687
1688+static const struct afs_operation_ops afs_symlink_operation = {
1689+ .issue_afs_rpc = afs_fs_symlink,
1690+ .issue_yfs_rpc = yfs_fs_symlink,
1691+ .success = afs_create_success,
1692+ .edit_dir = afs_create_edit_dir,
1693+ .put = afs_create_put,
1694+};
1695+
17461696 /*
17471697 * create a symlink in an AFS filesystem
17481698 */
17491699 static int afs_symlink(struct inode *dir, struct dentry *dentry,
17501700 const char *content)
17511701 {
1752− struct afs_iget_data iget_data;
1753− struct afs_fs_cursor fc;
1754− struct afs_status_cb *scb;
1702+ struct afs_operation *op;
17551703 struct afs_vnode *dvnode = AFS_FS_I(dir);
1756− struct key *key;
1757− afs_dataversion_t data_version;
17581704 int ret;
17591705
17601706 _enter("{%llx:%llu},{%pd},%s",
@@ -1769,62 +1715,115 @@ static int afs_symlink(struct inode *dir, struct dentry *dentry, · 8 unmodified lines
17691715 if (strlen(content) >= AFSPATHMAX)
17701716 goto error;
17711717
1772− ret = -ENOMEM;
1773− scb = kcalloc(2, sizeof(struct afs_status_cb), GFP_KERNEL);
1774− if (!scb)
1718+ op = afs_alloc_operation(NULL, dvnode->volume);
1719+ if (IS_ERR(op)) {
1720+ ret = PTR_ERR(op);
17751721 goto error;
1776−
1777− key = afs_request_key(dvnode->volume->cell);
1778− if (IS_ERR(key)) {
1779− ret = PTR_ERR(key);
1780− goto error_scb;
17811722 }
17821723
1783− ret = -ERESTARTSYS;
1784− if (afs_begin_vnode_operation(&fc, dvnode, key, true)) {
1785− data_version = dvnode->status.data_version + 1;
1786−
1787− while (afs_select_fileserver(&fc)) {
1788− fc.cb_break = afs_calc_vnode_cb_break(dvnode);
1789− afs_prep_for_new_inode(&fc, &iget_data);
1790− afs_fs_symlink(&fc, dentry->d_name.name, content,
1791− &scb[0], &iget_data.fid, &scb[1]);
1792− }
1724+ afs_op_set_vnode(op, 0, dvnode);
1725+ op->file[0].dv_delta = 1;
17931726
1794− afs_check_for_remote_deletion(&fc, dvnode);
1795− afs_vnode_commit_status(&fc, dvnode, fc.cb_break,
1796− &data_version, &scb[0]);
1797− afs_update_dentry_version(&fc, dentry, &scb[0]);
1798− afs_vnode_new_inode(&fc, dentry, &iget_data, &scb[1]);
1799− ret = afs_end_vnode_operation(&fc);
1800− if (ret < 0)
1801− goto error_key;
1802− } else {
1803− goto error_key;
1804− }
1805−
1806− down_write(&dvnode->validate_lock);
1807− if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) &&
1808− dvnode->status.data_version == data_version)
1809− afs_edit_dir_add(dvnode, &dentry->d_name, &iget_data.fid,
1810− afs_edit_dir_for_symlink);
1811− up_write(&dvnode->validate_lock);
1727+ op->dentry = dentry;
1728+ op->ops = &afs_symlink_operation;
1729+ op->create.reason = afs_edit_dir_for_symlink;
1730+ op->create.symlink = content;
1731+ return afs_do_sync_operation(op);
18121732
1813− key_put(key);
1814− kfree(scb);
1815− _leave(" = 0");
1816− return 0;
1817−
1818−error_key:
1819− key_put(key);
1820−error_scb:
1821− kfree(scb);
18221733 error:
18231734 d_drop(dentry);
18241735 _leave(" = %d", ret);
18251736 return ret;
18261737 }
18271738
1739+static void afs_rename_success(struct afs_operation *op)
1740+{
1741+ _enter("op=%08x", op->debug_id);
1742+
1743+ afs_vnode_commit_status(op, &op->file[0]);
1744+ if (op->file[1].vnode != op->file[0].vnode)
1745+ afs_vnode_commit_status(op, &op->file[1]);
1746+}
1747+
1748+static void afs_rename_edit_dir(struct afs_operation *op)
1749+{
1750+ struct afs_vnode_param *orig_dvp = &op->file[0];
1751+ struct afs_vnode_param *new_dvp = &op->file[1];
1752+ struct afs_vnode *orig_dvnode = orig_dvp->vnode;
1753+ struct afs_vnode *new_dvnode = new_dvp->vnode;
1754+ struct afs_vnode *vnode = AFS_FS_I(d_inode(op->dentry));
1755+ struct dentry *old_dentry = op->dentry;
1756+ struct dentry *new_dentry = op->dentry_2;
1757+ struct inode *new_inode;
1758+
1759+ _enter("op=%08x", op->debug_id);
1760+
1761+ if (op->rename.rehash) {
1762+ d_rehash(op->rename.rehash);
1763+ op->rename.rehash = NULL;
1764+ }
1765+
1766+ down_write(&orig_dvnode->validate_lock);
1767+ if (test_bit(AFS_VNODE_DIR_VALID, &orig_dvnode->flags) &&
1768+ orig_dvnode->status.data_version == orig_dvp->dv_before + orig_dvp->dv_delta)
1769+ afs_edit_dir_remove(orig_dvnode, &old_dentry->d_name,
1770+ afs_edit_dir_for_rename_0);
1771+
1772+ if (new_dvnode != orig_dvnode) {
1773+ up_write(&orig_dvnode->validate_lock);
1774+ down_write(&new_dvnode->validate_lock);
1775+ }
1776+
1777+ if (test_bit(AFS_VNODE_DIR_VALID, &new_dvnode->flags) &&
1778+ new_dvnode->status.data_version == new_dvp->dv_before + new_dvp->dv_delta) {
1779+ if (!op->rename.new_negative)
1780+ afs_edit_dir_remove(new_dvnode, &new_dentry->d_name,
1781+ afs_edit_dir_for_rename_1);
1782+
1783+ afs_edit_dir_add(new_dvnode, &new_dentry->d_name,
1784+ &vnode->fid, afs_edit_dir_for_rename_2);
1785+ }
1786+
1787+ new_inode = d_inode(new_dentry);
1788+ if (new_inode) {
1789+ spin_lock(&new_inode->i_lock);
1790+ if (new_inode->i_nlink > 0)
1791+ drop_nlink(new_inode);
1792+ spin_unlock(&new_inode->i_lock);
1793+ }
1794+
1795+ /* Now we can update d_fsdata on the dentries to reflect their
1796+ * new parent's data_version.
1797+ *
1798+ * Note that if we ever implement RENAME_EXCHANGE, we'll have
1799+ * to update both dentries with opposing dir versions.
1800+ */
1801+ afs_update_dentry_version(op, new_dvp, op->dentry);
1802+ afs_update_dentry_version(op, new_dvp, op->dentry_2);
1803+
1804+ d_move(old_dentry, new_dentry);
1805+
1806+ up_write(&new_dvnode->validate_lock);
1807+}
1808+
1809+static void afs_rename_put(struct afs_operation *op)
1810+{
1811+ _enter("op=%08x", op->debug_id);
1812+ if (op->rename.rehash)
1813+ d_rehash(op->rename.rehash);
1814+ dput(op->rename.tmp);
1815+ if (op->error)
1816+ d_rehash(op->dentry);
1817+}
1818+
1819+static const struct afs_operation_ops afs_rename_operation = {
1820+ .issue_afs_rpc = afs_fs_rename,
1821+ .issue_yfs_rpc = yfs_fs_rename,
1822+ .success = afs_rename_success,
1823+ .edit_dir = afs_rename_edit_dir,
1824+ .put = afs_rename_put,
1825+};
1826+
18281827 /*
18291828 * rename a file in an AFS filesystem and/or move it between directories
18301829 */
@@ -1832,15 +1831,8 @@ static int afs_rename(struct inode *old_dir, struct dentry *old_dentry, · 1 unmodified line
18321831 struct inode *new_dir, struct dentry *new_dentry,
18331832 unsigned int flags)
18341833 {
1835− struct afs_fs_cursor fc;
1836− struct afs_status_cb *scb;
1834+ struct afs_operation *op;
18371835 struct afs_vnode *orig_dvnode, *new_dvnode, *vnode;
1838− struct dentry *tmp = NULL, *rehash = NULL;
1839− struct inode *new_inode;
1840− struct key *key;
1841− afs_dataversion_t orig_data_version;
1842− afs_dataversion_t new_data_version;
1843− bool new_negative = d_is_negative(new_dentry);
18441836 int ret;
18451837
18461838 if (flags)
@@ -1860,16 +1852,19 @@ static int afs_rename(struct inode *old_dir, struct dentry *old_dentry, · 13 unmodified lines
18601852 new_dvnode->fid.vid, new_dvnode->fid.vnode,
18611853 new_dentry);
18621854
1863− ret = -ENOMEM;
1864− scb = kcalloc(2, sizeof(struct afs_status_cb), GFP_KERNEL);
1865− if (!scb)
1866− goto error;
1855+ op = afs_alloc_operation(NULL, orig_dvnode->volume);
1856+ if (IS_ERR(op))
1857+ return PTR_ERR(op);
18671858
1868− key = afs_request_key(orig_dvnode->volume->cell);
1869− if (IS_ERR(key)) {
1870− ret = PTR_ERR(key);
1871− goto error_scb;
1872− }
1859+ afs_op_set_vnode(op, 0, orig_dvnode);
1860+ afs_op_set_vnode(op, 1, new_dvnode); /* May be same as orig_dvnode */
1861+ op->file[0].dv_delta = 1;
1862+ op->file[1].dv_delta = 1;
1863+
1864+ op->dentry = old_dentry;
1865+ op->dentry_2 = new_dentry;
1866+ op->rename.new_negative = d_is_negative(new_dentry);
1867+ op->ops = &afs_rename_operation;
18731868
18741869 /* For non-directories, check whether the target is busy and if so,
18751870 * make a copy of the dentry and then do a silly-rename. If the
@@ -1882,26 +1877,26 @@ static int afs_rename(struct inode *old_dir, struct dentry *old_dentry, · 6 unmodified lines
18821877 */
18831878 if (!d_unhashed(new_dentry)) {
18841879 d_drop(new_dentry);
1885− rehash = new_dentry;
1880+ op->rename.rehash = new_dentry;
18861881 }
18871882
18881883 if (d_count(new_dentry) > 2) {
18891884 /* copy the target dentry's name */
18901885 ret = -ENOMEM;
1891− tmp = d_alloc(new_dentry->d_parent,
1892− &new_dentry->d_name);
1893− if (!tmp)
1894− goto error_rehash;
1886+ op->rename.tmp = d_alloc(new_dentry->d_parent,
1887+ &new_dentry->d_name);
1888+ if (!op->rename.tmp)
1889+ goto error;
18951890
18961891 ret = afs_sillyrename(new_dvnode,
18971892 AFS_FS_I(d_inode(new_dentry)),
1898− new_dentry, key);
1893+ new_dentry, op->key);
18991894 if (ret)
1900− goto error_rehash;
1895+ goto error;
19011896
1902− new_dentry = tmp;
1903− rehash = NULL;
1904− new_negative = true;
1897+ op->dentry_2 = op->rename.tmp;
1898+ op->rename.rehash = NULL;
1899+ op->rename.new_negative = true;
19051900 }
19061901 }
19071902
@@ -1916,98 +1911,10 @@ static int afs_rename(struct inode *old_dir, struct dentry *old_dentry, · 8 unmodified lines
19161911 */
19171912 d_drop(old_dentry);
19181913
1919− ret = -ERESTARTSYS;
1920− if (afs_begin_vnode_operation(&fc, orig_dvnode, key, true)) {
1921− orig_data_version = orig_dvnode->status.data_version + 1;
1922−
1923− if (orig_dvnode != new_dvnode) {
1924− if (mutex_lock_interruptible_nested(&new_dvnode->io_lock, 1) < 0) {
1925− afs_end_vnode_operation(&fc);
1926− goto error_rehash_old;
1927− }
1928− new_data_version = new_dvnode->status.data_version + 1;
1929− } else {
1930− new_data_version = orig_data_version;
1931− }
1932−
1933− while (afs_select_fileserver(&fc)) {
1934− fc.cb_break = afs_calc_vnode_cb_break(orig_dvnode);
1935− fc.cb_break_2 = afs_calc_vnode_cb_break(new_dvnode);
1936− afs_fs_rename(&fc, old_dentry->d_name.name,
1937− new_dvnode, new_dentry->d_name.name,
1938− &scb[0], &scb[1]);
1939− }
1914+ return afs_do_sync_operation(op);
19401915
1941− afs_vnode_commit_status(&fc, orig_dvnode, fc.cb_break,
1942− &orig_data_version, &scb[0]);
1943− if (new_dvnode != orig_dvnode) {
1944− afs_vnode_commit_status(&fc, new_dvnode, fc.cb_break_2,
1945− &new_data_version, &scb[1]);
1946− mutex_unlock(&new_dvnode->io_lock);
1947− }
1948− ret = afs_end_vnode_operation(&fc);
1949− if (ret < 0)
1950− goto error_rehash_old;
1951− }
1952−
1953− if (ret == 0) {
1954− if (rehash)
1955− d_rehash(rehash);
1956− down_write(&orig_dvnode->validate_lock);
1957− if (test_bit(AFS_VNODE_DIR_VALID, &orig_dvnode->flags) &&
1958− orig_dvnode->status.data_version == orig_data_version)
1959− afs_edit_dir_remove(orig_dvnode, &old_dentry->d_name,
1960− afs_edit_dir_for_rename_0);
1961− if (orig_dvnode != new_dvnode) {
1962− up_write(&orig_dvnode->validate_lock);
1963−
1964− down_write(&new_dvnode->validate_lock);
1965− }
1966− if (test_bit(AFS_VNODE_DIR_VALID, &new_dvnode->flags) &&
1967− orig_dvnode->status.data_version == new_data_version) {
1968− if (!new_negative)
1969− afs_edit_dir_remove(new_dvnode, &new_dentry->d_name,
1970− afs_edit_dir_for_rename_1);
1971−
1972− afs_edit_dir_add(new_dvnode, &new_dentry->d_name,
1973− &vnode->fid, afs_edit_dir_for_rename_2);
1974− }
1975−
1976− new_inode = d_inode(new_dentry);
1977− if (new_inode) {
1978− spin_lock(&new_inode->i_lock);
1979− if (new_inode->i_nlink > 0)
1980− drop_nlink(new_inode);
1981− spin_unlock(&new_inode->i_lock);
1982− }
1983−
1984− /* Now we can update d_fsdata on the dentries to reflect their
1985− * new parent's data_version.
1986− *
1987− * Note that if we ever implement RENAME_EXCHANGE, we'll have
1988− * to update both dentries with opposing dir versions.
1989− */
1990− afs_update_dentry_version(&fc, old_dentry, &scb[1]);
1991− afs_update_dentry_version(&fc, new_dentry, &scb[1]);
1992− d_move(old_dentry, new_dentry);
1993− up_write(&new_dvnode->validate_lock);
1994− goto error_tmp;
1995− }
1996−
1997−error_rehash_old:
1998− d_rehash(new_dentry);
1999−error_rehash:
2000− if (rehash)
2001− d_rehash(rehash);
2002−error_tmp:
2003− if (tmp)
2004− dput(tmp);
2005− key_put(key);
2006−error_scb:
2007− kfree(scb);
20081916 error:
2009− _leave(" = %d", ret);
2010− return ret;
1917+ return afs_put_operation(op);
20111918 }
20121919
20131920 /*
fs/afs/dir_silly.c+99−91
@@ -12,6 +12,47 @@ · 11 unmodified lines
1212 #include <linux/fsnotify.h>
1313 #include "internal.h"
1414
15+static void afs_silly_rename_success(struct afs_operation *op)
16+{
17+ _enter("op=%08x", op->debug_id);
18+
19+ afs_vnode_commit_status(op, &op->file[0]);
20+}
21+
22+static void afs_silly_rename_edit_dir(struct afs_operation *op)
23+{
24+ struct afs_vnode_param *dvp = &op->file[0];
25+ struct afs_vnode *dvnode = dvp->vnode;
26+ struct afs_vnode *vnode = AFS_FS_I(d_inode(op->dentry));
27+ struct dentry *old = op->dentry;
28+ struct dentry *new = op->dentry_2;
29+
30+ spin_lock(&old->d_lock);
31+ old->d_flags |= DCACHE_NFSFS_RENAMED;
32+ spin_unlock(&old->d_lock);
33+ if (dvnode->silly_key != op->key) {
34+ key_put(dvnode->silly_key);
35+ dvnode->silly_key = key_get(op->key);
36+ }
37+
38+ down_write(&dvnode->validate_lock);
39+ if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) &&
40+ dvnode->status.data_version == dvp->dv_before + dvp->dv_delta) {
41+ afs_edit_dir_remove(dvnode, &old->d_name,
42+ afs_edit_dir_for_silly_0);
43+ afs_edit_dir_add(dvnode, &new->d_name,
44+ &vnode->fid, afs_edit_dir_for_silly_1);
45+ }
46+ up_write(&dvnode->validate_lock);
47+}
48+
49+static const struct afs_operation_ops afs_silly_rename_operation = {
50+ .issue_afs_rpc = afs_fs_rename,
51+ .issue_yfs_rpc = yfs_fs_rename,
52+ .success = afs_silly_rename_success,
53+ .edit_dir = afs_silly_rename_edit_dir,
54+};
55+
1556 /*
1657 * Actually perform the silly rename step.
1758 */
@@ -19,56 +60,22 @@ static int afs_do_silly_rename(struct afs_vnode *dvnode, struct afs_vnode *vnode · 1 unmodified line
1960 struct dentry *old, struct dentry *new,
2061 struct key *key)
2162 {
22− struct afs_fs_cursor fc;
23− struct afs_status_cb *scb;
24− afs_dataversion_t dir_data_version;
25− int ret = -ERESTARTSYS;
63+ struct afs_operation *op;
2664
2765 _enter("%pd,%pd", old, new);
2866
29− scb = kzalloc(sizeof(struct afs_status_cb), GFP_KERNEL);
30− if (!scb)
31− return -ENOMEM;
67+ op = afs_alloc_operation(key, dvnode->volume);
68+ if (IS_ERR(op))
69+ return PTR_ERR(op);
3270
33− trace_afs_silly_rename(vnode, false);
34− if (afs_begin_vnode_operation(&fc, dvnode, key, true)) {
35− dir_data_version = dvnode->status.data_version + 1;
36−
37− while (afs_select_fileserver(&fc)) {
38− fc.cb_break = afs_calc_vnode_cb_break(dvnode);
39− afs_fs_rename(&fc, old->d_name.name,
40− dvnode, new->d_name.name,
41− scb, scb);
42− }
43−
44− afs_vnode_commit_status(&fc, dvnode, fc.cb_break,
45− &dir_data_version, scb);
46− ret = afs_end_vnode_operation(&fc);
47− }
71+ afs_op_set_vnode(op, 0, dvnode);
4872
49− if (ret == 0) {
50− spin_lock(&old->d_lock);
51− old->d_flags |= DCACHE_NFSFS_RENAMED;
52− spin_unlock(&old->d_lock);
53− if (dvnode->silly_key != key) {
54− key_put(dvnode->silly_key);
55− dvnode->silly_key = key_get(key);
56− }
57−
58− down_write(&dvnode->validate_lock);
59− if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) &&
60− dvnode->status.data_version == dir_data_version) {
61− afs_edit_dir_remove(dvnode, &old->d_name,
62− afs_edit_dir_for_silly_0);
63− afs_edit_dir_add(dvnode, &new->d_name,
64− &vnode->fid, afs_edit_dir_for_silly_1);
65− }
66− up_write(&dvnode->validate_lock);
67− }
73+ op->dentry = old;
74+ op->dentry_2 = new;
75+ op->ops = &afs_silly_rename_operation;
6876
69− kfree(scb);
70− _leave(" = %d", ret);
71− return ret;
77+ trace_afs_silly_rename(vnode, false);
78+ return afs_do_sync_operation(op);
7279 }
7380
7481 /**
@@ -139,65 +146,66 @@ out: · 64 unmodified lines
139146 return ret;
140147 }
141148
149+static void afs_silly_unlink_success(struct afs_operation *op)
150+{
151+ struct afs_vnode *vnode = op->file[1].vnode;
152+
153+ _enter("op=%08x", op->debug_id);
154+ afs_check_for_remote_deletion(op, op->file[0].vnode);
155+ afs_vnode_commit_status(op, &op->file[0]);
156+ afs_vnode_commit_status(op, &op->file[1]);
157+ afs_update_dentry_version(op, &op->file[0], op->dentry);
158+
159+ drop_nlink(&vnode->vfs_inode);
160+ if (vnode->vfs_inode.i_nlink == 0) {
161+ set_bit(AFS_VNODE_DELETED, &vnode->flags);
162+ clear_bit(AFS_VNODE_CB_PROMISED, &vnode->flags);
163+ }
164+}
165+
166+static void afs_silly_unlink_edit_dir(struct afs_operation *op)
167+{
168+ struct afs_vnode_param *dvp = &op->file[0];
169+ struct afs_vnode *dvnode = dvp->vnode;
170+
171+ _enter("op=%08x", op->debug_id);
172+ down_write(&dvnode->validate_lock);
173+ if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) &&
174+ dvnode->status.data_version == dvp->dv_before + dvp->dv_delta)
175+ afs_edit_dir_remove(dvnode, &op->dentry->d_name,
176+ afs_edit_dir_for_unlink);
177+ up_write(&dvnode->validate_lock);
178+}
179+
180+static const struct afs_operation_ops afs_silly_unlink_operation = {
181+ .issue_afs_rpc = afs_fs_remove_file,
182+ .issue_yfs_rpc = yfs_fs_remove_file,
183+ .success = afs_silly_unlink_success,
184+ .edit_dir = afs_silly_unlink_edit_dir,
185+};
186+
142187 /*
143188 * Tell the server to remove a sillyrename file.
144189 */
145190 static int afs_do_silly_unlink(struct afs_vnode *dvnode, struct afs_vnode *vnode,
146191 struct dentry *dentry, struct key *key)
147192 {
148− struct afs_fs_cursor fc;
149− struct afs_status_cb *scb;
150− int ret = -ERESTARTSYS;
193+ struct afs_operation *op;
151194
152195 _enter("");
153196
154− scb = kcalloc(2, sizeof(struct afs_status_cb), GFP_KERNEL);
155− if (!scb)
156− return -ENOMEM;
197+ op = afs_alloc_operation(NULL, dvnode->volume);
198+ if (IS_ERR(op))
199+ return PTR_ERR(op);
157200
158− trace_afs_silly_rename(vnode, true);
159− if (afs_begin_vnode_operation(&fc, dvnode, key, false)) {
160− afs_dataversion_t dir_data_version = dvnode->status.data_version + 1;
161−
162− while (afs_select_fileserver(&fc)) {
163− fc.cb_break = afs_calc_vnode_cb_break(dvnode);
164−
165− if (test_bit(AFS_SERVER_FL_IS_YFS, &fc.cbi->server->flags) &&
166− !test_bit(AFS_SERVER_FL_NO_RM2, &fc.cbi->server->flags)) {
167− yfs_fs_remove_file2(&fc, vnode, dentry->d_name.name,
168− &scb[0], &scb[1]);
169− if (fc.ac.error != -ECONNABORTED ||
170− fc.ac.abort_code != RXGEN_OPCODE)
171− continue;
172− set_bit(AFS_SERVER_FL_NO_RM2, &fc.cbi->server->flags);
173− }
174−
175− afs_fs_remove(&fc, vnode, dentry->d_name.name, false, &scb[0]);
176− }
201+ afs_op_set_vnode(op, 0, dvnode);
202+ afs_op_set_vnode(op, 1, vnode);
177203
178− afs_vnode_commit_status(&fc, dvnode, fc.cb_break,
179− &dir_data_version, &scb[0]);
180− ret = afs_end_vnode_operation(&fc);
181− if (ret == 0) {
182− drop_nlink(&vnode->vfs_inode);
183− if (vnode->vfs_inode.i_nlink == 0) {
184− set_bit(AFS_VNODE_DELETED, &vnode->flags);
185− clear_bit(AFS_VNODE_CB_PROMISED, &vnode->flags);
186− }
187− }
188− if (ret == 0) {
189− down_write(&dvnode->validate_lock);
190− if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) &&
191− dvnode->status.data_version == dir_data_version)
192− afs_edit_dir_remove(dvnode, &dentry->d_name,
193− afs_edit_dir_for_unlink);
194− up_write(&dvnode->validate_lock);
195− }
196− }
204+ op->dentry = dentry;
205+ op->ops = &afs_silly_unlink_operation;
197206
198− kfree(scb);
199− _leave(" = %d", ret);
200− return ret;
207+ trace_afs_silly_rename(vnode, true);
208+ return afs_do_sync_operation(op);
201209 }
202210
203211 /*
fs/afs/dynroot.c+93−0
@@ -10,6 +10,99 @@ · 9 unmodified lines
1010 #include <linux/dns_resolver.h>
1111 #include "internal.h"
1212
13+static atomic_t afs_autocell_ino;
14+
15+/*
16+ * iget5() comparator for inode created by autocell operations
17+ *
18+ * These pseudo inodes don't match anything.
19+ */
20+static int afs_iget5_pseudo_test(struct inode *inode, void *opaque)
21+{
22+ return 0;
23+}
24+
25+/*
26+ * iget5() inode initialiser
27+ */
28+static int afs_iget5_pseudo_set(struct inode *inode, void *opaque)
29+{
30+ struct afs_super_info *as = AFS_FS_S(inode->i_sb);
31+ struct afs_vnode *vnode = AFS_FS_I(inode);
32+ struct afs_fid *fid = opaque;
33+
34+ vnode->volume = as->volume;
35+ vnode->fid = *fid;
36+ inode->i_ino = fid->vnode;
37+ inode->i_generation = fid->unique;
38+ return 0;
39+}
40+
41+/*
42+ * Create an inode for a dynamic root directory or an autocell dynamic
43+ * automount dir.
44+ */
45+struct inode *afs_iget_pseudo_dir(struct super_block *sb, bool root)
46+{
47+ struct afs_super_info *as = AFS_FS_S(sb);
48+ struct afs_vnode *vnode;
49+ struct inode *inode;
50+ struct afs_fid fid = {};
51+
52+ _enter("");
53+
54+ if (as->volume)
55+ fid.vid = as->volume->vid;
56+ if (root) {
57+ fid.vnode = 1;
58+ fid.unique = 1;
59+ } else {
60+ fid.vnode = atomic_inc_return(&afs_autocell_ino);
61+ fid.unique = 0;
62+ }
63+
64+ inode = iget5_locked(sb, fid.vnode,
65+ afs_iget5_pseudo_test, afs_iget5_pseudo_set, &fid);
66+ if (!inode) {
67+ _leave(" = -ENOMEM");
68+ return ERR_PTR(-ENOMEM);
69+ }
70+
71+ _debug("GOT INODE %p { ino=%lu, vl=%llx, vn=%llx, u=%x }",
72+ inode, inode->i_ino, fid.vid, fid.vnode, fid.unique);
73+
74+ vnode = AFS_FS_I(inode);
75+
76+ /* there shouldn't be an existing inode */
77+ BUG_ON(!(inode->i_state & I_NEW));
78+
79+ inode->i_size = 0;
80+ inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO;
81+ if (root) {
82+ inode->i_op = &afs_dynroot_inode_operations;
83+ inode->i_fop = &simple_dir_operations;
84+ } else {
85+ inode->i_op = &afs_autocell_inode_operations;
86+ }
87+ set_nlink(inode, 2);
88+ inode->i_uid = GLOBAL_ROOT_UID;
89+ inode->i_gid = GLOBAL_ROOT_GID;
90+ inode->i_ctime = inode->i_atime = inode->i_mtime = current_time(inode);
91+ inode->i_blocks = 0;
92+ inode->i_generation = 0;
93+
94+ set_bit(AFS_VNODE_PSEUDODIR, &vnode->flags);
95+ if (!root) {
96+ set_bit(AFS_VNODE_MOUNTPOINT, &vnode->flags);
97+ inode->i_flags |= S_AUTOMOUNT;
98+ }
99+
100+ inode->i_flags |= S_NOATIME;
101+ unlock_new_inode(inode);
102+ _leave(" = %p", inode);
103+ return inode;
104+}
105+
13106 /*
14107 * Probe to see if a cell may exist. This prevents positive dentries from
15108 * being created unnecessarily.
fs/afs/file.c+32−30
@@ -69,7 +69,7 @@ static const struct vm_operations_struct afs_vm_ops = { · 68 unmodified lines
6969 */
7070 void afs_put_wb_key(struct afs_wb_key *wbk)
7171 {
72− if (refcount_dec_and_test(&wbk->usage)) {
72+ if (wbk && refcount_dec_and_test(&wbk->usage)) {
7373 key_put(wbk->key);
7474 kfree(wbk);
7575 }
@@ -220,14 +220,35 @@ static void afs_file_readpage_read_complete(struct page *page, · 144 unmodified lines
220220 }
221221 #endif
222222
223+static void afs_fetch_data_success(struct afs_operation *op)
224+{
225+ struct afs_vnode *vnode = op->file[0].vnode;
226+
227+ _enter("op=%08x", op->debug_id);
228+ afs_check_for_remote_deletion(op, vnode);
229+ afs_vnode_commit_status(op, &op->file[0]);
230+ afs_stat_v(vnode, n_fetches);
231+ atomic_long_add(op->fetch.req->actual_len, &op->net->n_fetch_bytes);
232+}
233+
234+static void afs_fetch_data_put(struct afs_operation *op)
235+{
236+ afs_put_read(op->fetch.req);
237+}
238+
239+static const struct afs_operation_ops afs_fetch_data_operation = {
240+ .issue_afs_rpc = afs_fs_fetch_data,
241+ .issue_yfs_rpc = yfs_fs_fetch_data,
242+ .success = afs_fetch_data_success,
243+ .put = afs_fetch_data_put,
244+};
245+
223246 /*
224247 * Fetch file data from the volume.
225248 */
226249 int afs_fetch_data(struct afs_vnode *vnode, struct key *key, struct afs_read *req)
227250 {
228− struct afs_fs_cursor fc;
229− struct afs_status_cb *scb;
230− int ret;
251+ struct afs_operation *op;
231252
232253 _enter("%s{%llx:%llu.%u},%x,,,",
233254 vnode->volume->name,
@@ -236,34 +257,15 @@ int afs_fetch_data(struct afs_vnode *vnode, struct key *key, struct afs_read *re · 2 unmodified lines
236257 vnode->fid.unique,
237258 key_serial(key));
238259
239− scb = kzalloc(sizeof(struct afs_status_cb), GFP_KERNEL);
240− if (!scb)
241− return -ENOMEM;
242−
243− ret = -ERESTARTSYS;
244− if (afs_begin_vnode_operation(&fc, vnode, key, true)) {
245− afs_dataversion_t data_version = vnode->status.data_version;
260+ op = afs_alloc_operation(key, vnode->volume);
261+ if (IS_ERR(op))
262+ return PTR_ERR(op);
246263
247− while (afs_select_fileserver(&fc)) {
248− fc.cb_break = afs_calc_vnode_cb_break(vnode);
249− afs_fs_fetch_data(&fc, scb, req);
250− }
251−
252− afs_check_for_remote_deletion(&fc, vnode);
253− afs_vnode_commit_status(&fc, vnode, fc.cb_break,
254− &data_version, scb);
255− ret = afs_end_vnode_operation(&fc);
256− }
264+ afs_op_set_vnode(op, 0, vnode);
257265
258− if (ret == 0) {
259− afs_stat_v(vnode, n_fetches);
260− atomic_long_add(req->actual_len,
261− &afs_v2net(vnode)->n_fetch_bytes);
262− }
263−
264− kfree(scb);
265− _leave(" = %d", ret);
266− return ret;
266+ op->fetch.req = afs_get_read(req);
267+ op->ops = &afs_fetch_data_operation;
268+ return afs_do_sync_operation(op);
267269 }
268270
269271 /*
fs/afs/flock.c+53−61
@@ -70,7 +70,8 @@ static void afs_schedule_lock_extension(struct afs_vnode *vnode) · 69 unmodified lines
7070 */
7171 void afs_lock_op_done(struct afs_call *call)
7272 {
73− struct afs_vnode *vnode = call->lvnode;
73+ struct afs_operation *op = call->op;
74+ struct afs_vnode *vnode = op->lock.lvnode;
7475
7576 if (call->error == 0) {
7677 spin_lock(&vnode->lock);
@@ -172,15 +173,28 @@ static void afs_kill_lockers_enoent(struct afs_vnode *vnode) · 95 unmodified lines
172173 vnode->lock_key = NULL;
173174 }
174175
176+static void afs_lock_success(struct afs_operation *op)
177+{
178+ struct afs_vnode *vnode = op->file[0].vnode;
179+
180+ _enter("op=%08x", op->debug_id);
181+ afs_check_for_remote_deletion(op, vnode);
182+ afs_vnode_commit_status(op, &op->file[0]);
183+}
184+
185+static const struct afs_operation_ops afs_set_lock_operation = {
186+ .issue_afs_rpc = afs_fs_set_lock,
187+ .issue_yfs_rpc = yfs_fs_set_lock,
188+ .success = afs_lock_success,
189+};
190+
175191 /*
176192 * Get a lock on a file
177193 */
178194 static int afs_set_lock(struct afs_vnode *vnode, struct key *key,
179195 afs_lock_type_t type)
180196 {
181− struct afs_status_cb *scb;
182− struct afs_fs_cursor fc;
183− int ret;
197+ struct afs_operation *op;
184198
185199 _enter("%s{%llx:%llu.%u},%x,%u",
186200 vnode->volume->name,
@@ -189,35 +203,29 @@ static int afs_set_lock(struct afs_vnode *vnode, struct key *key, · 2 unmodified lines
189203 vnode->fid.unique,
190204 key_serial(key), type);
191205
192− scb = kzalloc(sizeof(struct afs_status_cb), GFP_KERNEL);
193− if (!scb)
194− return -ENOMEM;
206+ op = afs_alloc_operation(key, vnode->volume);
207+ if (IS_ERR(op))
208+ return PTR_ERR(op);
195209
196− ret = -ERESTARTSYS;
197− if (afs_begin_vnode_operation(&fc, vnode, key, true)) {
198− while (afs_select_fileserver(&fc)) {
199− fc.cb_break = afs_calc_vnode_cb_break(vnode);
200− afs_fs_set_lock(&fc, type, scb);
201− }
202−
203− afs_check_for_remote_deletion(&fc, vnode);
204− afs_vnode_commit_status(&fc, vnode, fc.cb_break, NULL, scb);
205− ret = afs_end_vnode_operation(&fc);
206− }
210+ afs_op_set_vnode(op, 0, vnode);
207211
208− kfree(scb);
209− _leave(" = %d", ret);
210− return ret;
212+ op->lock.type = type;
213+ op->ops = &afs_set_lock_operation;
214+ return afs_do_sync_operation(op);
211215 }
212216
217+static const struct afs_operation_ops afs_extend_lock_operation = {
218+ .issue_afs_rpc = afs_fs_extend_lock,
219+ .issue_yfs_rpc = yfs_fs_extend_lock,
220+ .success = afs_lock_success,
221+};
222+
213223 /*
214224 * Extend a lock on a file
215225 */
216226 static int afs_extend_lock(struct afs_vnode *vnode, struct key *key)
217227 {
218− struct afs_status_cb *scb;
219− struct afs_fs_cursor fc;
220− int ret;
228+ struct afs_operation *op;
221229
222230 _enter("%s{%llx:%llu.%u},%x",
223231 vnode->volume->name,
@@ -226,35 +234,29 @@ static int afs_extend_lock(struct afs_vnode *vnode, struct key *key) · 2 unmodified lines
226234 vnode->fid.unique,
227235 key_serial(key));
228236
229− scb = kzalloc(sizeof(struct afs_status_cb), GFP_KERNEL);
230− if (!scb)
231− return -ENOMEM;
232−
233− ret = -ERESTARTSYS;
234− if (afs_begin_vnode_operation(&fc, vnode, key, false)) {
235− while (afs_select_current_fileserver(&fc)) {
236− fc.cb_break = afs_calc_vnode_cb_break(vnode);
237− afs_fs_extend_lock(&fc, scb);
238− }
237+ op = afs_alloc_operation(key, vnode->volume);
238+ if (IS_ERR(op))
239+ return PTR_ERR(op);
239240
240− afs_check_for_remote_deletion(&fc, vnode);
241− afs_vnode_commit_status(&fc, vnode, fc.cb_break, NULL, scb);
242− ret = afs_end_vnode_operation(&fc);
243− }
241+ afs_op_set_vnode(op, 0, vnode);
244242
245− kfree(scb);
246− _leave(" = %d", ret);
247− return ret;
243+ op->flags |= AFS_OPERATION_UNINTR;
244+ op->ops = &afs_extend_lock_operation;
245+ return afs_do_sync_operation(op);
248246 }
249247
248+static const struct afs_operation_ops afs_release_lock_operation = {
249+ .issue_afs_rpc = afs_fs_release_lock,
250+ .issue_yfs_rpc = yfs_fs_release_lock,
251+ .success = afs_lock_success,
252+};
253+
250254 /*
251255 * Release a lock on a file
252256 */
253257 static int afs_release_lock(struct afs_vnode *vnode, struct key *key)
254258 {
255− struct afs_status_cb *scb;
256− struct afs_fs_cursor fc;
257− int ret;
259+ struct afs_operation *op;
258260
259261 _enter("%s{%llx:%llu.%u},%x",
260262 vnode->volume->name,
@@ -263,25 +265,15 @@ static int afs_release_lock(struct afs_vnode *vnode, struct key *key) · 2 unmodified lines
263265 vnode->fid.unique,
264266 key_serial(key));
265267
266− scb = kzalloc(sizeof(struct afs_status_cb), GFP_KERNEL);
267− if (!scb)
268− return -ENOMEM;
268+ op = afs_alloc_operation(key, vnode->volume);
269+ if (IS_ERR(op))
270+ return PTR_ERR(op);
269271
270− ret = -ERESTARTSYS;
271− if (afs_begin_vnode_operation(&fc, vnode, key, false)) {
272− while (afs_select_current_fileserver(&fc)) {
273− fc.cb_break = afs_calc_vnode_cb_break(vnode);
274− afs_fs_release_lock(&fc, scb);
275− }
272+ afs_op_set_vnode(op, 0, vnode);
276273
277− afs_check_for_remote_deletion(&fc, vnode);
278− afs_vnode_commit_status(&fc, vnode, fc.cb_break, NULL, scb);
279− ret = afs_end_vnode_operation(&fc);
280− }
281−
282− kfree(scb);
283− _leave(" = %d", ret);
284− return ret;
274+ op->flags |= AFS_OPERATION_UNINTR;
275+ op->ops = &afs_release_lock_operation;
276+ return afs_do_sync_operation(op);
285277 }
286278
287279 /*
fs/afs/fs_operation.c+239−0
@@ -0,0 +1,239 @@
1+// SPDX-License-Identifier: GPL-2.0-or-later
2+/* Fileserver-directed operation handling.
3+ *
4+ * Copyright (C) 2020 Red Hat, Inc. All Rights Reserved.
5+ * Written by David Howells (dhowells@redhat.com)
6+ */
7+
8+#include <linux/kernel.h>
9+#include <linux/slab.h>
10+#include <linux/fs.h>
11+#include "internal.h"
12+
13+static atomic_t afs_operation_debug_counter;
14+
15+/*
16+ * Create an operation against a volume.
17+ */
18+struct afs_operation *afs_alloc_operation(struct key *key, struct afs_volume *volume)
19+{
20+ struct afs_operation *op;
21+
22+ _enter("");
23+
24+ op = kzalloc(sizeof(*op), GFP_KERNEL);
25+ if (!op)
26+ return ERR_PTR(-ENOMEM);
27+
28+ if (!key) {
29+ key = afs_request_key(volume->cell);
30+ if (IS_ERR(key)) {
31+ kfree(op);
32+ return ERR_CAST(key);
33+ }
34+ } else {
35+ key_get(key);
36+ }
37+
38+ op->key = key;
39+ op->volume = afs_get_volume(volume, afs_volume_trace_get_new_op);
40+ op->net = volume->cell->net;
41+ op->cb_v_break = volume->cb_v_break;
42+ op->debug_id = atomic_inc_return(&afs_operation_debug_counter);
43+ op->error = -EDESTADDRREQ;
44+ op->ac.error = SHRT_MAX;
45+
46+ _leave(" = [op=%08x]", op->debug_id);
47+ return op;
48+}
49+
50+/*
51+ * Lock the vnode(s) being operated upon.
52+ */
53+static bool afs_get_io_locks(struct afs_operation *op)
54+{
55+ struct afs_vnode *vnode = op->file[0].vnode;
56+ struct afs_vnode *vnode2 = op->file[1].vnode;
57+
58+ _enter("");
59+
60+ if (op->flags & AFS_OPERATION_UNINTR) {
61+ mutex_lock(&vnode->io_lock);
62+ op->flags |= AFS_OPERATION_LOCK_0;
63+ _leave(" = t [1]");
64+ return true;
65+ }
66+
67+ if (!vnode2 || !op->file[1].need_io_lock || vnode == vnode2)
68+ vnode2 = NULL;
69+
70+ if (vnode2 > vnode)
71+ swap(vnode, vnode2);
72+
73+ if (mutex_lock_interruptible(&vnode->io_lock) < 0) {
74+ op->error = -EINTR;
75+ op->flags |= AFS_OPERATION_STOP;
76+ _leave(" = f [I 0]");
77+ return false;
78+ }
79+ op->flags |= AFS_OPERATION_LOCK_0;
80+
81+ if (vnode2) {
82+ if (mutex_lock_interruptible_nested(&vnode2->io_lock, 1) < 0) {
83+ op->error = -EINTR;
84+ op->flags |= AFS_OPERATION_STOP;
85+ mutex_unlock(&vnode->io_lock);
86+ op->flags &= ~AFS_OPERATION_LOCK_0;
87+ _leave(" = f [I 1]");
88+ return false;
89+ }
90+ op->flags |= AFS_OPERATION_LOCK_1;
91+ }
92+
93+ _leave(" = t [2]");
94+ return true;
95+}
96+
97+static void afs_drop_io_locks(struct afs_operation *op)
98+{
99+ struct afs_vnode *vnode = op->file[0].vnode;
100+ struct afs_vnode *vnode2 = op->file[1].vnode;
101+
102+ _enter("");
103+
104+ if (op->flags & AFS_OPERATION_LOCK_1)
105+ mutex_unlock(&vnode2->io_lock);
106+ if (op->flags & AFS_OPERATION_LOCK_0)
107+ mutex_unlock(&vnode->io_lock);
108+}
109+
110+static void afs_prepare_vnode(struct afs_operation *op, struct afs_vnode_param *vp,
111+ unsigned int index)
112+{
113+ struct afs_vnode *vnode = vp->vnode;
114+
115+ if (vnode) {
116+ vp->fid = vnode->fid;
117+ vp->dv_before = vnode->status.data_version;
118+ vp->cb_break_before = afs_calc_vnode_cb_break(vnode);
119+ if (vnode->lock_state != AFS_VNODE_LOCK_NONE)
120+ op->flags |= AFS_OPERATION_CUR_ONLY;
121+ }
122+
123+ if (vp->fid.vnode)
124+ _debug("PREP[%u] {%llx:%llu.%u}",
125+ index, vp->fid.vid, vp->fid.vnode, vp->fid.unique);
126+}
127+
128+/*
129+ * Begin an operation on the fileserver.
130+ *
131+ * Fileserver operations are serialised on the server by vnode, so we serialise
132+ * them here also using the io_lock.
133+ */
134+bool afs_begin_vnode_operation(struct afs_operation *op)
135+{
136+ struct afs_vnode *vnode = op->file[0].vnode;
137+
138+ ASSERT(vnode);
139+
140+ _enter("");
141+
142+ if (op->file[0].need_io_lock)
143+ if (!afs_get_io_locks(op))
144+ return false;
145+
146+ afs_prepare_vnode(op, &op->file[0], 0);
147+ afs_prepare_vnode(op, &op->file[1], 1);
148+ op->cb_v_break = op->volume->cb_v_break;
149+ _leave(" = true");
150+ return true;
151+}
152+
153+/*
154+ * Tidy up a filesystem cursor and unlock the vnode.
155+ */
156+static void afs_end_vnode_operation(struct afs_operation *op)
157+{
158+ _enter("");
159+
160+ if (op->error == -EDESTADDRREQ ||
161+ op->error == -EADDRNOTAVAIL ||
162+ op->error == -ENETUNREACH ||
163+ op->error == -EHOSTUNREACH)
164+ afs_dump_edestaddrreq(op);
165+
166+ afs_drop_io_locks(op);
167+
168+ if (op->error == -ECONNABORTED)
169+ op->error = afs_abort_to_error(op->ac.abort_code);
170+}
171+
172+/*
173+ * Wait for an in-progress operation to complete.
174+ */
175+void afs_wait_for_operation(struct afs_operation *op)
176+{
177+ _enter("");
178+
179+ while (afs_select_fileserver(op)) {
180+ op->cb_s_break = op->server->cb_s_break;
181+ if (test_bit(AFS_SERVER_FL_IS_YFS, &op->server->flags) &&
182+ op->ops->issue_yfs_rpc)
183+ op->ops->issue_yfs_rpc(op);
184+ else
185+ op->ops->issue_afs_rpc(op);
186+
187+ op->error = afs_wait_for_call_to_complete(op->call, &op->ac);
188+ }
189+
190+ if (op->error == 0) {
191+ _debug("success");
192+ op->ops->success(op);
193+ }
194+
195+ afs_end_vnode_operation(op);
196+
197+ if (op->error == 0 && op->ops->edit_dir) {
198+ _debug("edit_dir");
199+ op->ops->edit_dir(op);
200+ }
201+ _leave("");
202+}
203+
204+/*
205+ * Dispose of an operation.
206+ */
207+int afs_put_operation(struct afs_operation *op)
208+{
209+ int i, ret = op->error;
210+
211+ _enter("op=%08x,%d", op->debug_id, ret);
212+
213+ if (op->ops && op->ops->put)
214+ op->ops->put(op);
215+ if (op->file[0].put_vnode)
216+ iput(&op->file[0].vnode->vfs_inode);
217+ if (op->file[1].put_vnode)
218+ iput(&op->file[1].vnode->vfs_inode);
219+
220+ if (op->more_files) {
221+ for (i = 0; i < op->nr_files - 2; i++)
222+ if (op->more_files[i].put_vnode)
223+ iput(&op->more_files[i].vnode->vfs_inode);
224+ kfree(op->more_files);
225+ }
226+
227+ afs_end_cursor(&op->ac);
228+ afs_put_serverlist(op->net, op->server_list);
229+ afs_put_volume(op->net, op->volume, afs_volume_trace_put_put_op);
230+ kfree(op);
231+ return ret;
232+}
233+
234+int afs_do_sync_operation(struct afs_operation *op)
235+{
236+ afs_begin_vnode_operation(op);
237+ afs_wait_for_operation(op);
238+ return afs_put_operation(op);
239+}
fs/afs/fs_probe.c+266−73
@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: GPL-2.0-or-later
22 /* AFS fileserver probing
33 *
4− * Copyright (C) 2018 Red Hat, Inc. All Rights Reserved.
4+ * Copyright (C) 2018, 2020 Red Hat, Inc. All Rights Reserved.
55 * Written by David Howells (dhowells@redhat.com)
66 */
77
@@ -11,15 +11,86 @@ · 3 unmodified lines
1111 #include "internal.h"
1212 #include "protocol_yfs.h"
1313
14−static bool afs_fs_probe_done(struct afs_server *server)
14+static unsigned int afs_fs_probe_fast_poll_interval = 30 * HZ;
15+static unsigned int afs_fs_probe_slow_poll_interval = 5 * 60 * HZ;
16+
17+/*
18+ * Start the probe polling timer. We have to supply it with an inc on the
19+ * outstanding server count.
20+ */
21+static void afs_schedule_fs_probe(struct afs_net *net,
22+ struct afs_server *server, bool fast)
23+{
24+ unsigned long atj;
25+
26+ if (!net->live)
27+ return;
28+
29+ atj = server->probed_at;
30+ atj += fast ? afs_fs_probe_fast_poll_interval : afs_fs_probe_slow_poll_interval;
31+
32+ afs_inc_servers_outstanding(net);
33+ if (timer_reduce(&net->fs_probe_timer, atj))
34+ afs_dec_servers_outstanding(net);
35+}
36+
37+/*
38+ * Handle the completion of a set of probes.
39+ */
40+static void afs_finished_fs_probe(struct afs_net *net, struct afs_server *server)
41+{
42+ bool responded = server->probe.responded;
43+
44+ write_seqlock(&net->fs_lock);
45+ if (responded) {
46+ list_add_tail(&server->probe_link, &net->fs_probe_slow);
47+ } else {
48+ server->rtt = UINT_MAX;
49+ clear_bit(AFS_SERVER_FL_RESPONDING, &server->flags);
50+ list_add_tail(&server->probe_link, &net->fs_probe_fast);
51+ }
52+ write_sequnlock(&net->fs_lock);
53+
54+ afs_schedule_fs_probe(net, server, !responded);
55+}
56+
57+/*
58+ * Handle the completion of a probe.
59+ */
60+static void afs_done_one_fs_probe(struct afs_net *net, struct afs_server *server)
61+{
62+ _enter("");
63+
64+ if (atomic_dec_and_test(&server->probe_outstanding))
65+ afs_finished_fs_probe(net, server);
66+
67+ wake_up_all(&server->probe_wq);
68+}
69+
70+/*
71+ * Handle inability to send a probe due to ENOMEM when trying to allocate a
72+ * call struct.
73+ */
74+static void afs_fs_probe_not_done(struct afs_net *net,
75+ struct afs_server *server,
76+ struct afs_addr_cursor *ac)
1577 {
16− if (!atomic_dec_and_test(&server->probe_outstanding))
17− return false;
78+ struct afs_addr_list *alist = ac->alist;
79+ unsigned int index = ac->index;
80+
81+ _enter("");
82+
83+ trace_afs_io_error(0, -ENOMEM, afs_io_error_fs_probe_fail);
84+ spin_lock(&server->probe_lock);
1885
19− wake_up_var(&server->probe_outstanding);
20− clear_bit_unlock(AFS_SERVER_FL_PROBING, &server->flags);
21− wake_up_bit(&server->flags, AFS_SERVER_FL_PROBING);
22− return true;
86+ server->probe.local_failure = true;
87+ if (server->probe.error == 0)
88+ server->probe.error = -ENOMEM;
89+
90+ set_bit(index, &alist->failed);
91+
92+ spin_unlock(&server->probe_lock);
93+ return afs_done_one_fs_probe(net, server);
2394 }
2495
2596 /*
@@ -30,10 +101,8 @@ void afs_fileserver_probe_result(struct afs_call *call) · 4 unmodified lines
30101 {
31102 struct afs_addr_list *alist = call->alist;
32103 struct afs_server *server = call->server;
33− unsigned int server_index = call->server_index;
34104 unsigned int index = call->addr_ix;
35105 unsigned int rtt_us = 0;
36− bool have_result = false;
37106 int ret = call->error;
38107
39108 _enter("%pU,%u", &server->uuid, index);
@@ -52,8 +121,9 @@ void afs_fileserver_probe_result(struct afs_call *call) · 12 unmodified lines
52121 goto responded;
53122 case -ENOMEM:
54123 case -ENONET:
124+ clear_bit(index, &alist->responded);
55125 server->probe.local_failure = true;
56− afs_io_error(call, afs_io_error_fs_probe_fail);
126+ trace_afs_io_error(call->debug_id, ret, afs_io_error_fs_probe_fail);
57127 goto out;
58128 case -ECONNRESET: /* Responded, but call expired. */
59129 case -ERFKILL:
@@ -72,12 +142,11 @@ void afs_fileserver_probe_result(struct afs_call *call) · 12 unmodified lines
72142 server->probe.error == -ETIMEDOUT ||
73143 server->probe.error == -ETIME))
74144 server->probe.error = ret;
75− afs_io_error(call, afs_io_error_fs_probe_fail);
145+ trace_afs_io_error(call->debug_id, ret, afs_io_error_fs_probe_fail);
76146 goto out;
77147 }
78148
79149 responded:
80− set_bit(index, &alist->responded);
81150 clear_bit(index, &alist->failed);
82151
83152 if (call->service_id == YFS_FS_SERVICE) {
@@ -95,39 +164,34 @@ responded: · 11 unmodified lines
95164 rtt_us = rxrpc_kernel_get_srtt(call->net->socket, call->rxcall);
96165 if (rtt_us < server->probe.rtt) {
97166 server->probe.rtt = rtt_us;
167+ server->rtt = rtt_us;
98168 alist->preferred = index;
99− have_result = true;
100169 }
101170
102171 smp_wmb(); /* Set rtt before responded. */
103172 server->probe.responded = true;
104− set_bit(AFS_SERVER_FL_PROBED, &server->flags);
173+ set_bit(index, &alist->responded);
174+ set_bit(AFS_SERVER_FL_RESPONDING, &server->flags);
105175 out:
106176 spin_unlock(&server->probe_lock);
107177
108− _debug("probe [%u][%u] %pISpc rtt=%u ret=%d",
109− server_index, index, &alist->addrs[index].transport, rtt_us, ret);
178+ _debug("probe %pU [%u] %pISpc rtt=%u ret=%d",
179+ &server->uuid, index, &alist->addrs[index].transport,
180+ rtt_us, ret);
110181
111− have_result |= afs_fs_probe_done(server);
112− if (have_result)
113− wake_up_all(&server->probe_wq);
182+ return afs_done_one_fs_probe(call->net, server);
114183 }
115184
116185 /*
117− * Probe all of a fileserver's addresses to find out the best route and to
118− * query its capabilities.
186+ * Probe one or all of a fileserver's addresses to find out the best route and
187+ * to query its capabilities.
119188 */
120−static int afs_do_probe_fileserver(struct afs_net *net,
121− struct afs_server *server,
122− struct key *key,
123− unsigned int server_index,
124− struct afs_error *_e)
189+void afs_fs_probe_fileserver(struct afs_net *net, struct afs_server *server,
190+ struct key *key, bool all)
125191 {
126192 struct afs_addr_cursor ac = {
127193 .index = 0,
128194 };
129− struct afs_call *call;
130− bool in_progress = false;
131195
132196 _enter("%pU", &server->uuid);
133197
@@ -137,50 +201,25 @@ static int afs_do_probe_fileserver(struct afs_net *net, · 3 unmodified lines
137201 afs_get_addrlist(ac.alist);
138202 read_unlock(&server->fs_lock);
139203
140− atomic_set(&server->probe_outstanding, ac.alist->nr_addrs);
204+ server->probed_at = jiffies;
205+ atomic_set(&server->probe_outstanding, all ? ac.alist->nr_addrs : 1);
141206 memset(&server->probe, 0, sizeof(server->probe));
142207 server->probe.rtt = UINT_MAX;
143208
144− for (ac.index = 0; ac.index < ac.alist->nr_addrs; ac.index++) {
145− call = afs_fs_get_capabilities(net, server, &ac, key, server_index);
146− if (!IS_ERR(call)) {
147− afs_put_call(call);
148− in_progress = true;
149− } else {
150− afs_prioritise_error(_e, PTR_ERR(call), ac.abort_code);
151− }
152− }
153−
154− if (!in_progress)
155− afs_fs_probe_done(server);
156− afs_put_addrlist(ac.alist);
157− return in_progress;
158−}
209+ ac.index = ac.alist->preferred;
210+ if (ac.index < 0 || ac.index >= ac.alist->nr_addrs)
211+ all = true;
159212
160−/*
161− * Send off probes to all unprobed servers.
162− */
163−int afs_probe_fileservers(struct afs_net *net, struct key *key,
164− struct afs_server_list *list)
165−{
166− struct afs_server *server;
167− struct afs_error e;
168− bool in_progress = false;
169− int i;
170−
171− e.error = 0;
172− e.responded = false;
173− for (i = 0; i < list->nr_servers; i++) {
174− server = list->servers[i].server;
175− if (test_bit(AFS_SERVER_FL_PROBED, &server->flags))
176− continue;
177−
178− if (!test_and_set_bit_lock(AFS_SERVER_FL_PROBING, &server->flags) &&
179− afs_do_probe_fileserver(net, server, key, i, &e))
180− in_progress = true;
213+ if (all) {
214+ for (ac.index = 0; ac.index < ac.alist->nr_addrs; ac.index++)
215+ if (!afs_fs_get_capabilities(net, server, &ac, key))
216+ afs_fs_probe_not_done(net, server, &ac);
217+ } else {
218+ if (!afs_fs_get_capabilities(net, server, &ac, key))
219+ afs_fs_probe_not_done(net, server, &ac);
181220 }
182221
183− return in_progress ? 0 : e.error;
222+ afs_put_addrlist(ac.alist);
184223 }
185224
186225 /*
@@ -190,7 +229,7 @@ int afs_wait_for_fs_probes(struct afs_server_list *slist, unsigned long untried) · 3 unmodified lines
190229 {
191230 struct wait_queue_entry *waits;
192231 struct afs_server *server;
193− unsigned int rtt = UINT_MAX;
232+ unsigned int rtt = UINT_MAX, rtt_s;
194233 bool have_responders = false;
195234 int pref = -1, i;
196235
@@ -200,7 +239,7 @@ int afs_wait_for_fs_probes(struct afs_server_list *slist, unsigned long untried) · 3 unmodified lines
200239 for (i = 0; i < slist->nr_servers; i++) {
201240 if (test_bit(i, &untried)) {
202241 server = slist->servers[i].server;
203− if (!test_bit(AFS_SERVER_FL_PROBING, &server->flags))
242+ if (!atomic_read(&server->probe_outstanding))
204243 __clear_bit(i, &untried);
205244 if (server->probe.responded)
206245 have_responders = true;
@@ -230,7 +269,7 @@ int afs_wait_for_fs_probes(struct afs_server_list *slist, unsigned long untried) · 23 unmodified lines
230269 server = slist->servers[i].server;
231270 if (server->probe.responded)
232271 goto stop;
233− if (test_bit(AFS_SERVER_FL_PROBING, &server->flags))
272+ if (atomic_read(&server->probe_outstanding))
234273 still_probing = true;
235274 }
236275 }
@@ -246,10 +285,11 @@ stop: · 9 unmodified lines
246285 for (i = 0; i < slist->nr_servers; i++) {
247286 if (test_bit(i, &untried)) {
248287 server = slist->servers[i].server;
249− if (server->probe.responded &&
250− server->probe.rtt < rtt) {
288+ rtt_s = READ_ONCE(server->rtt);
289+ if (test_bit(AFS_SERVER_FL_RESPONDING, &server->flags) &&
290+ rtt_s < rtt) {
251291 pref = i;
252− rtt = server->probe.rtt;
292+ rtt = rtt_s;
253293 }
254294
255295 remove_wait_queue(&server->probe_wq, &waits[i]);
@@ -265,3 +305,156 @@ stop: · 9 unmodified lines
265305 slist->preferred = pref;
266306 return 0;
267307 }
308+
309+/*
310+ * Probe timer. We have an increment on fs_outstanding that we need to pass
311+ * along to the work item.
312+ */
313+void afs_fs_probe_timer(struct timer_list *timer)
314+{
315+ struct afs_net *net = container_of(timer, struct afs_net, fs_probe_timer);
316+
317+ if (!queue_work(afs_wq, &net->fs_prober))
318+ afs_dec_servers_outstanding(net);
319+}
320+
321+/*
322+ * Dispatch a probe to a server.
323+ */
324+static void afs_dispatch_fs_probe(struct afs_net *net, struct afs_server *server, bool all)
325+ __releases(&net->fs_lock)
326+{
327+ struct key *key = NULL;
328+
329+ /* We remove it from the queues here - it will be added back to
330+ * one of the queues on the completion of the probe.
331+ */
332+ list_del_init(&server->probe_link);
333+
334+ afs_get_server(server, afs_server_trace_get_probe);
335+ write_sequnlock(&net->fs_lock);
336+
337+ afs_fs_probe_fileserver(net, server, key, all);
338+ afs_put_server(net, server, afs_server_trace_put_probe);
339+}
340+
341+/*
342+ * Probe a server immediately without waiting for its due time to come
343+ * round. This is used when all of the addresses have been tried.
344+ */
345+void afs_probe_fileserver(struct afs_net *net, struct afs_server *server)
346+{
347+ write_seqlock(&net->fs_lock);
348+ if (!list_empty(&server->probe_link))
349+ return afs_dispatch_fs_probe(net, server, true);
350+ write_sequnlock(&net->fs_lock);
351+}
352+
353+/*
354+ * Probe dispatcher to regularly dispatch probes to keep NAT alive.
355+ */
356+void afs_fs_probe_dispatcher(struct work_struct *work)
357+{
358+ struct afs_net *net = container_of(work, struct afs_net, fs_prober);
359+ struct afs_server *fast, *slow, *server;
360+ unsigned long nowj, timer_at, poll_at;
361+ bool first_pass = true, set_timer = false;
362+
363+ if (!net->live)
364+ return;
365+
366+ _enter("");
367+
368+ if (list_empty(&net->fs_probe_fast) && list_empty(&net->fs_probe_slow)) {
369+ _leave(" [none]");
370+ return;
371+ }
372+
373+again:
374+ write_seqlock(&net->fs_lock);
375+
376+ fast = slow = server = NULL;
377+ nowj = jiffies;
378+ timer_at = nowj + MAX_JIFFY_OFFSET;
379+
380+ if (!list_empty(&net->fs_probe_fast)) {
381+ fast = list_first_entry(&net->fs_probe_fast, struct afs_server, probe_link);
382+ poll_at = fast->probed_at + afs_fs_probe_fast_poll_interval;
383+ if (time_before(nowj, poll_at)) {
384+ timer_at = poll_at;
385+ set_timer = true;
386+ fast = NULL;
387+ }
388+ }
389+
390+ if (!list_empty(&net->fs_probe_slow)) {
391+ slow = list_first_entry(&net->fs_probe_slow, struct afs_server, probe_link);
392+ poll_at = slow->probed_at + afs_fs_probe_slow_poll_interval;
393+ if (time_before(nowj, poll_at)) {
394+ if (time_before(poll_at, timer_at))
395+ timer_at = poll_at;
396+ set_timer = true;
397+ slow = NULL;
398+ }
399+ }
400+
401+ server = fast ?: slow;
402+ if (server)
403+ _debug("probe %pU", &server->uuid);
404+
405+ if (server && (first_pass || !need_resched())) {
406+ afs_dispatch_fs_probe(net, server, server == fast);
407+ first_pass = false;
408+ goto again;
409+ }
410+
411+ write_sequnlock(&net->fs_lock);
412+
413+ if (server) {
414+ if (!queue_work(afs_wq, &net->fs_prober))
415+ afs_dec_servers_outstanding(net);
416+ _leave(" [requeue]");
417+ } else if (set_timer) {
418+ if (timer_reduce(&net->fs_probe_timer, timer_at))
419+ afs_dec_servers_outstanding(net);
420+ _leave(" [timer]");
421+ } else {
422+ afs_dec_servers_outstanding(net);
423+ _leave(" [quiesce]");
424+ }
425+}
426+
427+/*
428+ * Wait for a probe on a particular fileserver to complete for 2s.
429+ */
430+int afs_wait_for_one_fs_probe(struct afs_server *server, bool is_intr)
431+{
432+ struct wait_queue_entry wait;
433+ unsigned long timo = 2 * HZ;
434+
435+ if (atomic_read(&server->probe_outstanding) == 0)
436+ goto dont_wait;
437+
438+ init_wait_entry(&wait, 0);
439+ for (;;) {
440+ prepare_to_wait_event(&server->probe_wq, &wait,
441+ is_intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE);
442+ if (timo == 0 ||
443+ server->probe.responded ||
444+ atomic_read(&server->probe_outstanding) == 0 ||
445+ (is_intr && signal_pending(current)))
446+ break;
447+ timo = schedule_timeout(timo);
448+ }
449+
450+ finish_wait(&server->probe_wq, &wait);
451+
452+dont_wait:
453+ if (server->probe.responded)
454+ return 0;
455+ if (is_intr && signal_pending(current))
456+ return -ERESTARTSYS;
457+ if (timo == 0)
458+ return -ETIME;
459+ return -EDESTADDRREQ;
460+}
fs/afs/fsclient.c+511−794
@@ -13,12 +13,6 @@ · 12 unmodified lines
1313 #include "internal.h"
1414 #include "afs_fs.h"
1515 #include "xdr_fs.h"
16−#include "protocol_yfs.h"
17−
18−static inline void afs_use_fs_server(struct afs_call *call, struct afs_cb_interest *cbi)
19−{
20− call->cbi = afs_get_cb_interest(cbi);
21−}
2216
2317 /*
2418 * decode an AFSFid block
@@ -56,16 +50,15 @@ static void xdr_dump_bad(const __be32 *bp) · 31 unmodified lines
5650 /*
5751 * decode an AFSFetchStatus block
5852 */
59−static int xdr_decode_AFSFetchStatus(const __be32 **_bp,
60− struct afs_call *call,
61− struct afs_status_cb *scb)
53+static void xdr_decode_AFSFetchStatus(const __be32 **_bp,
54+ struct afs_call *call,
55+ struct afs_status_cb *scb)
6256 {
6357 const struct afs_xdr_AFSFetchStatus *xdr = (const void *)*_bp;
6458 struct afs_file_status *status = &scb->status;
6559 bool inline_error = (call->operation_ID == afs_FS_InlineBulkStatus);
6660 u64 data_version, size;
6761 u32 type, abort_code;
68− int ret;
6962
7063 abort_code = ntohl(xdr->abort_code);
7164
@@ -79,7 +72,7 @@ static int xdr_decode_AFSFetchStatus(const __be32 **_bp, · 7 unmodified lines
7972 */
8073 status->abort_code = abort_code;
8174 scb->have_error = true;
82− goto good;
75+ goto advance;
8376 }
8477
8578 pr_warn("Unknown AFSFetchStatus version %u\n", ntohl(xdr->if_version));
@@ -89,7 +82,7 @@ static int xdr_decode_AFSFetchStatus(const __be32 **_bp, · 3 unmodified lines
8982 if (abort_code != 0 && inline_error) {
9083 status->abort_code = abort_code;
9184 scb->have_error = true;
92− goto good;
85+ goto advance;
9386 }
9487
9588 type = ntohl(xdr->type);
@@ -125,15 +118,13 @@ static int xdr_decode_AFSFetchStatus(const __be32 **_bp, · 29 unmodified lines
125118 data_version |= (u64)ntohl(xdr->data_version_hi) << 32;
126119 status->data_version = data_version;
127120 scb->have_status = true;
128−good:
129− ret = 0;
130121 advance:
131122 *_bp = (const void *)*_bp + sizeof(*xdr);
132− return ret;
123+ return;
133124
134125 bad:
135126 xdr_dump_bad(*_bp);
136− ret = afs_protocol_error(call, -EBADMSG, afs_eproto_bad_status);
127+ afs_protocol_error(call, afs_eproto_bad_status);
137128 goto advance;
138129 }
139130
@@ -243,8 +234,10 @@ static void xdr_decode_AFSFetchVolumeStatus(const __be32 **_bp, · 103 unmodified lines
243234 /*
244235 * deliver reply data to an FS.FetchStatus
245236 */
246−static int afs_deliver_fs_fetch_status_vnode(struct afs_call *call)
237+static int afs_deliver_fs_fetch_status(struct afs_call *call)
247238 {
239+ struct afs_operation *op = call->op;
240+ struct afs_vnode_param *vp = &op->file[op->fetch_status.which];
248241 const __be32 *bp;
249242 int ret;
250243
@@ -254,11 +247,9 @@ static int afs_deliver_fs_fetch_status_vnode(struct afs_call *call) · 3 unmodified lines
254247
255248 /* unmarshall the reply once we've received all of it */
256249 bp = call->buffer;
257− ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
258− if (ret < 0)
259− return ret;
260− xdr_decode_AFSCallBack(&bp, call, call->out_scb);
261− xdr_decode_AFSVolSync(&bp, call->out_volsync);
250+ xdr_decode_AFSFetchStatus(&bp, call, &vp->scb);
251+ xdr_decode_AFSCallBack(&bp, call, &vp->scb);
252+ xdr_decode_AFSVolSync(&bp, &op->volsync);
262253
263254 _leave(" = 0 [done]");
264255 return 0;
@@ -267,54 +258,39 @@ static int afs_deliver_fs_fetch_status_vnode(struct afs_call *call) · 2 unmodified lines
267258 /*
268259 * FS.FetchStatus operation type
269260 */
270−static const struct afs_call_type afs_RXFSFetchStatus_vnode = {
271− .name = "FS.FetchStatus(vnode)",
261+static const struct afs_call_type afs_RXFSFetchStatus = {
262+ .name = "FS.FetchStatus",
272263 .op = afs_FS_FetchStatus,
273− .deliver = afs_deliver_fs_fetch_status_vnode,
264+ .deliver = afs_deliver_fs_fetch_status,
274265 .destructor = afs_flat_call_destructor,
275266 };
276267
277268 /*
278269 * fetch the status information for a file
279270 */
280−int afs_fs_fetch_file_status(struct afs_fs_cursor *fc, struct afs_status_cb *scb,
281− struct afs_volsync *volsync)
271+void afs_fs_fetch_status(struct afs_operation *op)
282272 {
283− struct afs_vnode *vnode = fc->vnode;
273+ struct afs_vnode_param *vp = &op->file[op->fetch_status.which];
284274 struct afs_call *call;
285− struct afs_net *net = afs_v2net(vnode);
286275 __be32 *bp;
287276
288− if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
289− return yfs_fs_fetch_file_status(fc, scb, volsync);
290−
291277 _enter(",%x,{%llx:%llu},,",
292− key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
278+ key_serial(op->key), vp->fid.vid, vp->fid.vnode);
293279
294− call = afs_alloc_flat_call(net, &afs_RXFSFetchStatus_vnode,
280+ call = afs_alloc_flat_call(op->net, &afs_RXFSFetchStatus,
295281 16, (21 + 3 + 6) * 4);
296− if (!call) {
297− fc->ac.error = -ENOMEM;
298− return -ENOMEM;
299− }
300−
301− call->key = fc->key;
302− call->out_scb = scb;
303− call->out_volsync = volsync;
282+ if (!call)
283+ return afs_op_nomem(op);
304284
305285 /* marshall the parameters */
306286 bp = call->request;
307287 bp[0] = htonl(FSFETCHSTATUS);
308− bp[1] = htonl(vnode->fid.vid);
309− bp[2] = htonl(vnode->fid.vnode);
310− bp[3] = htonl(vnode->fid.unique);
288+ bp[1] = htonl(vp->fid.vid);
289+ bp[2] = htonl(vp->fid.vnode);
290+ bp[3] = htonl(vp->fid.unique);
311291
312− afs_use_fs_server(call, fc->cbi);
313− trace_afs_make_fs_call(call, &vnode->fid);
314−
315− afs_set_fc_call(call, fc);
316− afs_make_call(&fc->ac, call, GFP_NOFS);
317− return afs_wait_for_call_to_complete(call, &fc->ac);
292+ trace_afs_make_fs_call(call, &vp->fid);
293+ afs_make_op_call(op, call, GFP_NOFS);
318294 }
319295
320296 /*
@@ -322,7 +298,9 @@ int afs_fs_fetch_file_status(struct afs_fs_cursor *fc, struct afs_status_cb *scb · 1 unmodified line
322298 */
323299 static int afs_deliver_fs_fetch_data(struct afs_call *call)
324300 {
325− struct afs_read *req = call->read_request;
301+ struct afs_operation *op = call->op;
302+ struct afs_vnode_param *vp = &op->file[0];
303+ struct afs_read *req = op->fetch.req;
326304 const __be32 *bp;
327305 unsigned int size;
328306 int ret;
@@ -419,14 +397,12 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call) · 90 unmodified lines
419397 return ret;
420398
421399 bp = call->buffer;
422− ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
423− if (ret < 0)
424− return ret;
425− xdr_decode_AFSCallBack(&bp, call, call->out_scb);
426− xdr_decode_AFSVolSync(&bp, call->out_volsync);
400+ xdr_decode_AFSFetchStatus(&bp, call, &vp->scb);
401+ xdr_decode_AFSCallBack(&bp, call, &vp->scb);
402+ xdr_decode_AFSVolSync(&bp, &op->volsync);
427403
428− req->data_version = call->out_scb->status.data_version;
429− req->file_size = call->out_scb->status.size;
404+ req->data_version = vp->scb.status.data_version;
405+ req->file_size = vp->scb.status.size;
430406
431407 call->unmarshall++;
432408
@@ -449,14 +425,6 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call) · 16 unmodified lines
449425 return 0;
450426 }
451427
452−static void afs_fetch_data_destructor(struct afs_call *call)
453−{
454− struct afs_read *req = call->read_request;
455−
456− afs_put_read(req);
457− afs_flat_call_destructor(call);
458−}
459−
460428 /*
461429 * FS.FetchData operation type
462430 */
@@ -464,102 +432,79 @@ static const struct afs_call_type afs_RXFSFetchData = { · 1 unmodified line
464432 .name = "FS.FetchData",
465433 .op = afs_FS_FetchData,
466434 .deliver = afs_deliver_fs_fetch_data,
467− .destructor = afs_fetch_data_destructor,
435+ .destructor = afs_flat_call_destructor,
468436 };
469437
470438 static const struct afs_call_type afs_RXFSFetchData64 = {
471439 .name = "FS.FetchData64",
472440 .op = afs_FS_FetchData64,
473441 .deliver = afs_deliver_fs_fetch_data,
474− .destructor = afs_fetch_data_destructor,
442+ .destructor = afs_flat_call_destructor,
475443 };
476444
477445 /*
478446 * fetch data from a very large file
479447 */
480−static int afs_fs_fetch_data64(struct afs_fs_cursor *fc,
481− struct afs_status_cb *scb,
482− struct afs_read *req)
448+static void afs_fs_fetch_data64(struct afs_operation *op)
483449 {
484− struct afs_vnode *vnode = fc->vnode;
450+ struct afs_vnode_param *vp = &op->file[0];
451+ struct afs_read *req = op->fetch.req;
485452 struct afs_call *call;
486− struct afs_net *net = afs_v2net(vnode);
487453 __be32 *bp;
488454
489455 _enter("");
490456
491− call = afs_alloc_flat_call(net, &afs_RXFSFetchData64, 32, (21 + 3 + 6) * 4);
457+ call = afs_alloc_flat_call(op->net, &afs_RXFSFetchData64, 32, (21 + 3 + 6) * 4);
492458 if (!call)
493− return -ENOMEM;
494−
495− call->key = fc->key;
496− call->out_scb = scb;
497− call->out_volsync = NULL;
498− call->read_request = afs_get_read(req);
459+ return afs_op_nomem(op);
499460
500461 /* marshall the parameters */
501462 bp = call->request;
502463 bp[0] = htonl(FSFETCHDATA64);
503− bp[1] = htonl(vnode->fid.vid);
504− bp[2] = htonl(vnode->fid.vnode);
505− bp[3] = htonl(vnode->fid.unique);
464+ bp[1] = htonl(vp->fid.vid);
465+ bp[2] = htonl(vp->fid.vnode);
466+ bp[3] = htonl(vp->fid.unique);
506467 bp[4] = htonl(upper_32_bits(req->pos));
507468 bp[5] = htonl(lower_32_bits(req->pos));
508469 bp[6] = 0;
509470 bp[7] = htonl(lower_32_bits(req->len));
510471
511− afs_use_fs_server(call, fc->cbi);
512− trace_afs_make_fs_call(call, &vnode->fid);
513− afs_set_fc_call(call, fc);
514− afs_make_call(&fc->ac, call, GFP_NOFS);
515− return afs_wait_for_call_to_complete(call, &fc->ac);
472+ trace_afs_make_fs_call(call, &vp->fid);
473+ afs_make_op_call(op, call, GFP_NOFS);
516474 }
517475
518476 /*
519477 * fetch data from a file
520478 */
521−int afs_fs_fetch_data(struct afs_fs_cursor *fc,
522− struct afs_status_cb *scb,
523− struct afs_read *req)
479+void afs_fs_fetch_data(struct afs_operation *op)
524480 {
525− struct afs_vnode *vnode = fc->vnode;
481+ struct afs_vnode_param *vp = &op->file[0];
526482 struct afs_call *call;
527− struct afs_net *net = afs_v2net(vnode);
483+ struct afs_read *req = op->fetch.req;
528484 __be32 *bp;
529485
530− if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
531− return yfs_fs_fetch_data(fc, scb, req);
532−
533486 if (upper_32_bits(req->pos) ||
534487 upper_32_bits(req->len) ||
535488 upper_32_bits(req->pos + req->len))
536− return afs_fs_fetch_data64(fc, scb, req);
489+ return afs_fs_fetch_data64(op);
537490
538491 _enter("");
539492
540− call = afs_alloc_flat_call(net, &afs_RXFSFetchData, 24, (21 + 3 + 6) * 4);
493+ call = afs_alloc_flat_call(op->net, &afs_RXFSFetchData, 24, (21 + 3 + 6) * 4);
541494 if (!call)
542− return -ENOMEM;
543−
544− call->key = fc->key;
545− call->out_scb = scb;
546− call->out_volsync = NULL;
547− call->read_request = afs_get_read(req);
495+ return afs_op_nomem(op);
548496
549497 /* marshall the parameters */
550498 bp = call->request;
551499 bp[0] = htonl(FSFETCHDATA);
552− bp[1] = htonl(vnode->fid.vid);
553− bp[2] = htonl(vnode->fid.vnode);
554− bp[3] = htonl(vnode->fid.unique);
500+ bp[1] = htonl(vp->fid.vid);
501+ bp[2] = htonl(vp->fid.vnode);
502+ bp[3] = htonl(vp->fid.unique);
555503 bp[4] = htonl(lower_32_bits(req->pos));
556504 bp[5] = htonl(lower_32_bits(req->len));
557505
558− afs_use_fs_server(call, fc->cbi);
559− trace_afs_make_fs_call(call, &vnode->fid);
560− afs_set_fc_call(call, fc);
561− afs_make_call(&fc->ac, call, GFP_NOFS);
562− return afs_wait_for_call_to_complete(call, &fc->ac);
506+ trace_afs_make_fs_call(call, &vp->fid);
507+ afs_make_op_call(op, call, GFP_NOFS);
563508 }
564509
565510 /*
@@ -567,6 +512,9 @@ int afs_fs_fetch_data(struct afs_fs_cursor *fc, · 1 unmodified line
567512 */
568513 static int afs_deliver_fs_create_vnode(struct afs_call *call)
569514 {
515+ struct afs_operation *op = call->op;
516+ struct afs_vnode_param *dvp = &op->file[0];
517+ struct afs_vnode_param *vp = &op->file[1];
570518 const __be32 *bp;
571519 int ret;
572520
@@ -576,15 +524,11 @@ static int afs_deliver_fs_create_vnode(struct afs_call *call) · 3 unmodified lines
576524
577525 /* unmarshall the reply once we've received all of it */
578526 bp = call->buffer;
579− xdr_decode_AFSFid(&bp, call->out_fid);
580− ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
581− if (ret < 0)
582− return ret;
583− ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb);
584− if (ret < 0)
585− return ret;
586− xdr_decode_AFSCallBack(&bp, call, call->out_scb);
587− xdr_decode_AFSVolSync(&bp, call->out_volsync);
527+ xdr_decode_AFSFid(&bp, &op->file[1].fid);
528+ xdr_decode_AFSFetchStatus(&bp, call, &vp->scb);
529+ xdr_decode_AFSFetchStatus(&bp, call, &dvp->scb);
530+ xdr_decode_AFSCallBack(&bp, call, &vp->scb);
531+ xdr_decode_AFSVolSync(&bp, &op->volsync);
588532
589533 _leave(" = 0 [done]");
590534 return 0;
@@ -600,6 +544,52 @@ static const struct afs_call_type afs_RXFSCreateFile = { · 9 unmodified lines
600544 .destructor = afs_flat_call_destructor,
601545 };
602546
547+/*
548+ * Create a file.
549+ */
550+void afs_fs_create_file(struct afs_operation *op)
551+{
552+ const struct qstr *name = &op->dentry->d_name;
553+ struct afs_vnode_param *dvp = &op->file[0];
554+ struct afs_call *call;
555+ size_t namesz, reqsz, padsz;
556+ __be32 *bp;
557+
558+ _enter("");
559+
560+ namesz = name->len;
561+ padsz = (4 - (namesz & 3)) & 3;
562+ reqsz = (5 * 4) + namesz + padsz + (6 * 4);
563+
564+ call = afs_alloc_flat_call(op->net, &afs_RXFSCreateFile,
565+ reqsz, (3 + 21 + 21 + 3 + 6) * 4);
566+ if (!call)
567+ return afs_op_nomem(op);
568+
569+ /* marshall the parameters */
570+ bp = call->request;
571+ *bp++ = htonl(FSCREATEFILE);
572+ *bp++ = htonl(dvp->fid.vid);
573+ *bp++ = htonl(dvp->fid.vnode);
574+ *bp++ = htonl(dvp->fid.unique);
575+ *bp++ = htonl(namesz);
576+ memcpy(bp, name->name, namesz);
577+ bp = (void *) bp + namesz;
578+ if (padsz > 0) {
579+ memset(bp, 0, padsz);
580+ bp = (void *) bp + padsz;
581+ }
582+ *bp++ = htonl(AFS_SET_MODE | AFS_SET_MTIME);
583+ *bp++ = htonl(op->mtime.tv_sec); /* mtime */
584+ *bp++ = 0; /* owner */
585+ *bp++ = 0; /* group */
586+ *bp++ = htonl(op->create.mode & S_IALLUGO); /* unix mode */
587+ *bp++ = 0; /* segment size */
588+
589+ trace_afs_make_fs_call1(call, &dvp->fid, name);
590+ afs_make_op_call(op, call, GFP_NOFS);
591+}
592+
603593 static const struct afs_call_type afs_RXFSMakeDir = {
604594 .name = "FS.MakeDir",
605595 .op = afs_FS_MakeDir,
@@ -608,80 +598,58 @@ static const struct afs_call_type afs_RXFSMakeDir = { · 2 unmodified lines
608598 };
609599
610600 /*
611− * create a file or make a directory
601+ * Create a new directory
612602 */
613−int afs_fs_create(struct afs_fs_cursor *fc,
614− const char *name,
615− umode_t mode,
616− struct afs_status_cb *dvnode_scb,
617− struct afs_fid *newfid,
618− struct afs_status_cb *new_scb)
603+void afs_fs_make_dir(struct afs_operation *op)
619604 {
620− struct afs_vnode *dvnode = fc->vnode;
605+ const struct qstr *name = &op->dentry->d_name;
606+ struct afs_vnode_param *dvp = &op->file[0];
621607 struct afs_call *call;
622− struct afs_net *net = afs_v2net(dvnode);
623608 size_t namesz, reqsz, padsz;
624609 __be32 *bp;
625610
626− if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)){
627− if (S_ISDIR(mode))
628− return yfs_fs_make_dir(fc, name, mode, dvnode_scb,
629− newfid, new_scb);
630− else
631− return yfs_fs_create_file(fc, name, mode, dvnode_scb,
632− newfid, new_scb);
633− }
634−
635611 _enter("");
636612
637− namesz = strlen(name);
613+ namesz = name->len;
638614 padsz = (4 - (namesz & 3)) & 3;
639615 reqsz = (5 * 4) + namesz + padsz + (6 * 4);
640616
641− call = afs_alloc_flat_call(
642− net, S_ISDIR(mode) ? &afs_RXFSMakeDir : &afs_RXFSCreateFile,
643− reqsz, (3 + 21 + 21 + 3 + 6) * 4);
617+ call = afs_alloc_flat_call(op->net, &afs_RXFSMakeDir,
618+ reqsz, (3 + 21 + 21 + 3 + 6) * 4);
644619 if (!call)
645− return -ENOMEM;
646−
647− call->key = fc->key;
648− call->out_dir_scb = dvnode_scb;
649− call->out_fid = newfid;
650− call->out_scb = new_scb;
620+ return afs_op_nomem(op);
651621
652622 /* marshall the parameters */
653623 bp = call->request;
654− *bp++ = htonl(S_ISDIR(mode) ? FSMAKEDIR : FSCREATEFILE);
655− *bp++ = htonl(dvnode->fid.vid);
656− *bp++ = htonl(dvnode->fid.vnode);
657− *bp++ = htonl(dvnode->fid.unique);
624+ *bp++ = htonl(FSMAKEDIR);
625+ *bp++ = htonl(dvp->fid.vid);
626+ *bp++ = htonl(dvp->fid.vnode);
627+ *bp++ = htonl(dvp->fid.unique);
658628 *bp++ = htonl(namesz);
659− memcpy(bp, name, namesz);
629+ memcpy(bp, name->name, namesz);
660630 bp = (void *) bp + namesz;
661631 if (padsz > 0) {
662632 memset(bp, 0, padsz);
663633 bp = (void *) bp + padsz;
664634 }
665635 *bp++ = htonl(AFS_SET_MODE | AFS_SET_MTIME);
666− *bp++ = htonl(dvnode->vfs_inode.i_mtime.tv_sec); /* mtime */
636+ *bp++ = htonl(op->mtime.tv_sec); /* mtime */
667637 *bp++ = 0; /* owner */
668638 *bp++ = 0; /* group */
669− *bp++ = htonl(mode & S_IALLUGO); /* unix mode */
639+ *bp++ = htonl(op->create.mode & S_IALLUGO); /* unix mode */
670640 *bp++ = 0; /* segment size */
671641
672− afs_use_fs_server(call, fc->cbi);
673− trace_afs_make_fs_call1(call, &dvnode->fid, name);
674− afs_set_fc_call(call, fc);
675− afs_make_call(&fc->ac, call, GFP_NOFS);
676− return afs_wait_for_call_to_complete(call, &fc->ac);
642+ trace_afs_make_fs_call1(call, &dvp->fid, name);
643+ afs_make_op_call(op, call, GFP_NOFS);
677644 }
678645
679646 /*
680− * Deliver reply data to any operation that returns directory status and volume
681− * sync.
647+ * Deliver reply data to any operation that returns status and volume sync.
682648 */
683−static int afs_deliver_fs_dir_status_and_vol(struct afs_call *call)
649+static int afs_deliver_fs_file_status_and_vol(struct afs_call *call)
684650 {
651+ struct afs_operation *op = call->op;
652+ struct afs_vnode_param *vp = &op->file[0];
685653 const __be32 *bp;
686654 int ret;
687655
@@ -691,81 +659,108 @@ static int afs_deliver_fs_dir_status_and_vol(struct afs_call *call) · 3 unmodified lines
691659
692660 /* unmarshall the reply once we've received all of it */
693661 bp = call->buffer;
694− ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb);
695− if (ret < 0)
696− return ret;
697− xdr_decode_AFSVolSync(&bp, call->out_volsync);
662+ xdr_decode_AFSFetchStatus(&bp, call, &vp->scb);
663+ xdr_decode_AFSVolSync(&bp, &op->volsync);
698664
699665 _leave(" = 0 [done]");
700666 return 0;
701667 }
702668
703669 /*
704− * FS.RemoveDir/FS.RemoveFile operation type
670+ * FS.RemoveFile operation type
705671 */
706672 static const struct afs_call_type afs_RXFSRemoveFile = {
707673 .name = "FS.RemoveFile",
708674 .op = afs_FS_RemoveFile,
709− .deliver = afs_deliver_fs_dir_status_and_vol,
675+ .deliver = afs_deliver_fs_file_status_and_vol,
710676 .destructor = afs_flat_call_destructor,
711677 };
712678
679+/*
680+ * Remove a file.
681+ */
682+void afs_fs_remove_file(struct afs_operation *op)
683+{
684+ const struct qstr *name = &op->dentry->d_name;
685+ struct afs_vnode_param *dvp = &op->file[0];
686+ struct afs_call *call;
687+ size_t namesz, reqsz, padsz;
688+ __be32 *bp;
689+
690+ _enter("");
691+
692+ namesz = name->len;
693+ padsz = (4 - (namesz & 3)) & 3;
694+ reqsz = (5 * 4) + namesz + padsz;
695+
696+ call = afs_alloc_flat_call(op->net, &afs_RXFSRemoveFile,
697+ reqsz, (21 + 6) * 4);
698+ if (!call)
699+ return afs_op_nomem(op);
700+
701+ /* marshall the parameters */
702+ bp = call->request;
703+ *bp++ = htonl(FSREMOVEFILE);
704+ *bp++ = htonl(dvp->fid.vid);
705+ *bp++ = htonl(dvp->fid.vnode);
706+ *bp++ = htonl(dvp->fid.unique);
707+ *bp++ = htonl(namesz);
708+ memcpy(bp, name->name, namesz);
709+ bp = (void *) bp + namesz;
710+ if (padsz > 0) {
711+ memset(bp, 0, padsz);
712+ bp = (void *) bp + padsz;
713+ }
714+
715+ trace_afs_make_fs_call1(call, &dvp->fid, name);
716+ afs_make_op_call(op, call, GFP_NOFS);
717+}
718+
713719 static const struct afs_call_type afs_RXFSRemoveDir = {
714720 .name = "FS.RemoveDir",
715721 .op = afs_FS_RemoveDir,
716− .deliver = afs_deliver_fs_dir_status_and_vol,
722+ .deliver = afs_deliver_fs_file_status_and_vol,
717723 .destructor = afs_flat_call_destructor,
718724 };
719725
720726 /*
721− * remove a file or directory
727+ * Remove a directory.
722728 */
723−int afs_fs_remove(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
724− const char *name, bool isdir, struct afs_status_cb *dvnode_scb)
729+void afs_fs_remove_dir(struct afs_operation *op)
725730 {
726− struct afs_vnode *dvnode = fc->vnode;
731+ const struct qstr *name = &op->dentry->d_name;
732+ struct afs_vnode_param *dvp = &op->file[0];
727733 struct afs_call *call;
728− struct afs_net *net = afs_v2net(dvnode);
729734 size_t namesz, reqsz, padsz;
730735 __be32 *bp;
731736
732− if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
733− return yfs_fs_remove(fc, vnode, name, isdir, dvnode_scb);
734−
735737 _enter("");
736738
737− namesz = strlen(name);
739+ namesz = name->len;
738740 padsz = (4 - (namesz & 3)) & 3;
739741 reqsz = (5 * 4) + namesz + padsz;
740742
741− call = afs_alloc_flat_call(
742− net, isdir ? &afs_RXFSRemoveDir : &afs_RXFSRemoveFile,
743− reqsz, (21 + 6) * 4);
743+ call = afs_alloc_flat_call(op->net, &afs_RXFSRemoveDir,
744+ reqsz, (21 + 6) * 4);
744745 if (!call)
745− return -ENOMEM;
746−
747− call->key = fc->key;
748− call->out_dir_scb = dvnode_scb;
746+ return afs_op_nomem(op);
749747
750748 /* marshall the parameters */
751749 bp = call->request;
752− *bp++ = htonl(isdir ? FSREMOVEDIR : FSREMOVEFILE);
753− *bp++ = htonl(dvnode->fid.vid);
754− *bp++ = htonl(dvnode->fid.vnode);
755− *bp++ = htonl(dvnode->fid.unique);
750+ *bp++ = htonl(FSREMOVEDIR);
751+ *bp++ = htonl(dvp->fid.vid);
752+ *bp++ = htonl(dvp->fid.vnode);
753+ *bp++ = htonl(dvp->fid.unique);
756754 *bp++ = htonl(namesz);
757− memcpy(bp, name, namesz);
755+ memcpy(bp, name->name, namesz);
758756 bp = (void *) bp + namesz;
759757 if (padsz > 0) {
760758 memset(bp, 0, padsz);
761759 bp = (void *) bp + padsz;
762760 }
763761
764− afs_use_fs_server(call, fc->cbi);
765− trace_afs_make_fs_call1(call, &dvnode->fid, name);
766− afs_set_fc_call(call, fc);
767− afs_make_call(&fc->ac, call, GFP_NOFS);
768− return afs_wait_for_call_to_complete(call, &fc->ac);
762+ trace_afs_make_fs_call1(call, &dvp->fid, name);
763+ afs_make_op_call(op, call, GFP_NOFS);
769764 }
770765
771766 /*
@@ -773,6 +768,9 @@ int afs_fs_remove(struct afs_fs_cursor *fc, struct afs_vnode *vnode, · 1 unmodified line
773768 */
774769 static int afs_deliver_fs_link(struct afs_call *call)
775770 {
771+ struct afs_operation *op = call->op;
772+ struct afs_vnode_param *dvp = &op->file[0];
773+ struct afs_vnode_param *vp = &op->file[1];
776774 const __be32 *bp;
777775 int ret;
778776
@@ -784,13 +782,9 @@ static int afs_deliver_fs_link(struct afs_call *call) · 5 unmodified lines
784782
785783 /* unmarshall the reply once we've received all of it */
786784 bp = call->buffer;
787− ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
788− if (ret < 0)
789− return ret;
790− ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb);
791− if (ret < 0)
792− return ret;
793− xdr_decode_AFSVolSync(&bp, call->out_volsync);
785+ xdr_decode_AFSFetchStatus(&bp, call, &vp->scb);
786+ xdr_decode_AFSFetchStatus(&bp, call, &dvp->scb);
787+ xdr_decode_AFSVolSync(&bp, &op->volsync);
794788
795789 _leave(" = 0 [done]");
796790 return 0;
@@ -809,56 +803,44 @@ static const struct afs_call_type afs_RXFSLink = { · 12 unmodified lines
809803 /*
810804 * make a hard link
811805 */
812−int afs_fs_link(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
813− const char *name,
814− struct afs_status_cb *dvnode_scb,
815− struct afs_status_cb *vnode_scb)
806+void afs_fs_link(struct afs_operation *op)
816807 {
817− struct afs_vnode *dvnode = fc->vnode;
808+ const struct qstr *name = &op->dentry->d_name;
809+ struct afs_vnode_param *dvp = &op->file[0];
810+ struct afs_vnode_param *vp = &op->file[1];
818811 struct afs_call *call;
819− struct afs_net *net = afs_v2net(vnode);
820812 size_t namesz, reqsz, padsz;
821813 __be32 *bp;
822814
823− if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
824− return yfs_fs_link(fc, vnode, name, dvnode_scb, vnode_scb);
825−
826815 _enter("");
827816
828− namesz = strlen(name);
817+ namesz = name->len;
829818 padsz = (4 - (namesz & 3)) & 3;
830819 reqsz = (5 * 4) + namesz + padsz + (3 * 4);
831820
832− call = afs_alloc_flat_call(net, &afs_RXFSLink, reqsz, (21 + 21 + 6) * 4);
821+ call = afs_alloc_flat_call(op->net, &afs_RXFSLink, reqsz, (21 + 21 + 6) * 4);
833822 if (!call)
834− return -ENOMEM;
835−
836− call->key = fc->key;
837− call->out_dir_scb = dvnode_scb;
838− call->out_scb = vnode_scb;
823+ return afs_op_nomem(op);
839824
840825 /* marshall the parameters */
841826 bp = call->request;
842827 *bp++ = htonl(FSLINK);
843− *bp++ = htonl(dvnode->fid.vid);
844− *bp++ = htonl(dvnode->fid.vnode);
845− *bp++ = htonl(dvnode->fid.unique);
828+ *bp++ = htonl(dvp->fid.vid);
829+ *bp++ = htonl(dvp->fid.vnode);
830+ *bp++ = htonl(dvp->fid.unique);
846831 *bp++ = htonl(namesz);
847− memcpy(bp, name, namesz);
832+ memcpy(bp, name->name, namesz);
848833 bp = (void *) bp + namesz;
849834 if (padsz > 0) {
850835 memset(bp, 0, padsz);
851836 bp = (void *) bp + padsz;
852837 }
853− *bp++ = htonl(vnode->fid.vid);
854− *bp++ = htonl(vnode->fid.vnode);
855− *bp++ = htonl(vnode->fid.unique);
856−
857− afs_use_fs_server(call, fc->cbi);
858− trace_afs_make_fs_call1(call, &vnode->fid, name);
859− afs_set_fc_call(call, fc);
860− afs_make_call(&fc->ac, call, GFP_NOFS);
861− return afs_wait_for_call_to_complete(call, &fc->ac);
838+ *bp++ = htonl(vp->fid.vid);
839+ *bp++ = htonl(vp->fid.vnode);
840+ *bp++ = htonl(vp->fid.unique);
841+
842+ trace_afs_make_fs_call1(call, &vp->fid, name);
843+ afs_make_op_call(op, call, GFP_NOFS);
862844 }
863845
864846 /*
@@ -866,6 +848,9 @@ int afs_fs_link(struct afs_fs_cursor *fc, struct afs_vnode *vnode, · 1 unmodified line
866848 */
867849 static int afs_deliver_fs_symlink(struct afs_call *call)
868850 {
851+ struct afs_operation *op = call->op;
852+ struct afs_vnode_param *dvp = &op->file[0];
853+ struct afs_vnode_param *vp = &op->file[1];
869854 const __be32 *bp;
870855 int ret;
871856
@@ -877,14 +862,10 @@ static int afs_deliver_fs_symlink(struct afs_call *call) · 5 unmodified lines
877862
878863 /* unmarshall the reply once we've received all of it */
879864 bp = call->buffer;
880− xdr_decode_AFSFid(&bp, call->out_fid);
881− ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
882− if (ret < 0)
883− return ret;
884− ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb);
885− if (ret < 0)
886− return ret;
887− xdr_decode_AFSVolSync(&bp, call->out_volsync);
865+ xdr_decode_AFSFid(&bp, &vp->fid);
866+ xdr_decode_AFSFetchStatus(&bp, call, &vp->scb);
867+ xdr_decode_AFSFetchStatus(&bp, call, &dvp->scb);
868+ xdr_decode_AFSVolSync(&bp, &op->volsync);
888869
889870 _leave(" = 0 [done]");
890871 return 0;
@@ -903,75 +884,58 @@ static const struct afs_call_type afs_RXFSSymlink = { · 12 unmodified lines
903884 /*
904885 * create a symbolic link
905886 */
906−int afs_fs_symlink(struct afs_fs_cursor *fc,
907− const char *name,
908− const char *contents,
909− struct afs_status_cb *dvnode_scb,
910− struct afs_fid *newfid,
911− struct afs_status_cb *new_scb)
887+void afs_fs_symlink(struct afs_operation *op)
912888 {
913− struct afs_vnode *dvnode = fc->vnode;
889+ const struct qstr *name = &op->dentry->d_name;
890+ struct afs_vnode_param *dvp = &op->file[0];
914891 struct afs_call *call;
915− struct afs_net *net = afs_v2net(dvnode);
916892 size_t namesz, reqsz, padsz, c_namesz, c_padsz;
917893 __be32 *bp;
918894
919− if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
920− return yfs_fs_symlink(fc, name, contents, dvnode_scb,
921− newfid, new_scb);
922−
923895 _enter("");
924896
925− namesz = strlen(name);
897+ namesz = name->len;
926898 padsz = (4 - (namesz & 3)) & 3;
927899
928− c_namesz = strlen(contents);
900+ c_namesz = strlen(op->create.symlink);
929901 c_padsz = (4 - (c_namesz & 3)) & 3;
930902
931903 reqsz = (6 * 4) + namesz + padsz + c_namesz + c_padsz + (6 * 4);
932904
933− call = afs_alloc_flat_call(net, &afs_RXFSSymlink, reqsz,
905+ call = afs_alloc_flat_call(op->net, &afs_RXFSSymlink, reqsz,
934906 (3 + 21 + 21 + 6) * 4);
935907 if (!call)
936− return -ENOMEM;
937−
938− call->key = fc->key;
939− call->out_dir_scb = dvnode_scb;
940− call->out_fid = newfid;
941− call->out_scb = new_scb;
908+ return afs_op_nomem(op);
942909
943910 /* marshall the parameters */
944911 bp = call->request;
945912 *bp++ = htonl(FSSYMLINK);
946− *bp++ = htonl(dvnode->fid.vid);
947− *bp++ = htonl(dvnode->fid.vnode);
948− *bp++ = htonl(dvnode->fid.unique);
913+ *bp++ = htonl(dvp->fid.vid);
914+ *bp++ = htonl(dvp->fid.vnode);
915+ *bp++ = htonl(dvp->fid.unique);
949916 *bp++ = htonl(namesz);
950− memcpy(bp, name, namesz);
917+ memcpy(bp, name->name, namesz);
951918 bp = (void *) bp + namesz;
952919 if (padsz > 0) {
953920 memset(bp, 0, padsz);
954921 bp = (void *) bp + padsz;
955922 }
956923 *bp++ = htonl(c_namesz);
957− memcpy(bp, contents, c_namesz);
924+ memcpy(bp, op->create.symlink, c_namesz);
958925 bp = (void *) bp + c_namesz;
959926 if (c_padsz > 0) {
960927 memset(bp, 0, c_padsz);
961928 bp = (void *) bp + c_padsz;
962929 }
963930 *bp++ = htonl(AFS_SET_MODE | AFS_SET_MTIME);
964− *bp++ = htonl(dvnode->vfs_inode.i_mtime.tv_sec); /* mtime */
931+ *bp++ = htonl(op->mtime.tv_sec); /* mtime */
965932 *bp++ = 0; /* owner */
966933 *bp++ = 0; /* group */
967934 *bp++ = htonl(S_IRWXUGO); /* unix mode */
968935 *bp++ = 0; /* segment size */
969936
970− afs_use_fs_server(call, fc->cbi);
971− trace_afs_make_fs_call1(call, &dvnode->fid, name);
972− afs_set_fc_call(call, fc);
973− afs_make_call(&fc->ac, call, GFP_NOFS);
974− return afs_wait_for_call_to_complete(call, &fc->ac);
937+ trace_afs_make_fs_call1(call, &dvp->fid, name);
938+ afs_make_op_call(op, call, GFP_NOFS);
975939 }
976940
977941 /*
@@ -979,6 +943,9 @@ int afs_fs_symlink(struct afs_fs_cursor *fc, · 1 unmodified line
979943 */
980944 static int afs_deliver_fs_rename(struct afs_call *call)
981945 {
946+ struct afs_operation *op = call->op;
947+ struct afs_vnode_param *orig_dvp = &op->file[0];
948+ struct afs_vnode_param *new_dvp = &op->file[1];
982949 const __be32 *bp;
983950 int ret;
984951
@@ -986,17 +953,13 @@ static int afs_deliver_fs_rename(struct afs_call *call) · 1 unmodified line
986953 if (ret < 0)
987954 return ret;
988955
956+ bp = call->buffer;
989957 /* If the two dirs are the same, we have two copies of the same status
990958 * report, so we just decode it twice.
991959 */
992− bp = call->buffer;
993− ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb);
994− if (ret < 0)
995− return ret;
996− ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
997− if (ret < 0)
998− return ret;
999− xdr_decode_AFSVolSync(&bp, call->out_volsync);
960+ xdr_decode_AFSFetchStatus(&bp, call, &orig_dvp->scb);
961+ xdr_decode_AFSFetchStatus(&bp, call, &new_dvp->scb);
962+ xdr_decode_AFSVolSync(&bp, &op->volsync);
1000963
1001964 _leave(" = 0 [done]");
1002965 return 0;
@@ -1015,31 +978,22 @@ static const struct afs_call_type afs_RXFSRename = { · 12 unmodified lines
1015978 /*
1016979 * Rename/move a file or directory.
1017980 */
1018−int afs_fs_rename(struct afs_fs_cursor *fc,
1019− const char *orig_name,
1020− struct afs_vnode *new_dvnode,
1021− const char *new_name,
1022− struct afs_status_cb *orig_dvnode_scb,
1023− struct afs_status_cb *new_dvnode_scb)
981+void afs_fs_rename(struct afs_operation *op)
1024982 {
1025− struct afs_vnode *orig_dvnode = fc->vnode;
983+ struct afs_vnode_param *orig_dvp = &op->file[0];
984+ struct afs_vnode_param *new_dvp = &op->file[1];
985+ const struct qstr *orig_name = &op->dentry->d_name;
986+ const struct qstr *new_name = &op->dentry_2->d_name;
1026987 struct afs_call *call;
1027− struct afs_net *net = afs_v2net(orig_dvnode);
1028988 size_t reqsz, o_namesz, o_padsz, n_namesz, n_padsz;
1029989 __be32 *bp;
1030990
1031− if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1032− return yfs_fs_rename(fc, orig_name,
1033− new_dvnode, new_name,
1034− orig_dvnode_scb,
1035− new_dvnode_scb);
1036−
1037991 _enter("");
1038992
1039− o_namesz = strlen(orig_name);
993+ o_namesz = orig_name->len;
1040994 o_padsz = (4 - (o_namesz & 3)) & 3;
1041995
1042− n_namesz = strlen(new_name);
996+ n_namesz = new_name->len;
1043997 n_padsz = (4 - (n_namesz & 3)) & 3;
1044998
1045999 reqsz = (4 * 4) +
@@ -1047,51 +1001,46 @@ int afs_fs_rename(struct afs_fs_cursor *fc, · 1 unmodified line
10471001 (3 * 4) +
10481002 4 + n_namesz + n_padsz;
10491003
1050− call = afs_alloc_flat_call(net, &afs_RXFSRename, reqsz, (21 + 21 + 6) * 4);
1004+ call = afs_alloc_flat_call(op->net, &afs_RXFSRename, reqsz, (21 + 21 + 6) * 4);
10511005 if (!call)
1052− return -ENOMEM;
1053−
1054− call->key = fc->key;
1055− call->out_dir_scb = orig_dvnode_scb;
1056− call->out_scb = new_dvnode_scb;
1006+ return afs_op_nomem(op);
10571007
10581008 /* marshall the parameters */
10591009 bp = call->request;
10601010 *bp++ = htonl(FSRENAME);
1061− *bp++ = htonl(orig_dvnode->fid.vid);
1062− *bp++ = htonl(orig_dvnode->fid.vnode);
1063− *bp++ = htonl(orig_dvnode->fid.unique);
1011+ *bp++ = htonl(orig_dvp->fid.vid);
1012+ *bp++ = htonl(orig_dvp->fid.vnode);
1013+ *bp++ = htonl(orig_dvp->fid.unique);
10641014 *bp++ = htonl(o_namesz);
1065− memcpy(bp, orig_name, o_namesz);
1015+ memcpy(bp, orig_name->name, o_namesz);
10661016 bp = (void *) bp + o_namesz;
10671017 if (o_padsz > 0) {
10681018 memset(bp, 0, o_padsz);
10691019 bp = (void *) bp + o_padsz;
10701020 }
10711021
1072− *bp++ = htonl(new_dvnode->fid.vid);
1073− *bp++ = htonl(new_dvnode->fid.vnode);
1074− *bp++ = htonl(new_dvnode->fid.unique);
1022+ *bp++ = htonl(new_dvp->fid.vid);
1023+ *bp++ = htonl(new_dvp->fid.vnode);
1024+ *bp++ = htonl(new_dvp->fid.unique);
10751025 *bp++ = htonl(n_namesz);
1076− memcpy(bp, new_name, n_namesz);
1026+ memcpy(bp, new_name->name, n_namesz);
10771027 bp = (void *) bp + n_namesz;
10781028 if (n_padsz > 0) {
10791029 memset(bp, 0, n_padsz);
10801030 bp = (void *) bp + n_padsz;
10811031 }
10821032
1083− afs_use_fs_server(call, fc->cbi);
1084− trace_afs_make_fs_call2(call, &orig_dvnode->fid, orig_name, new_name);
1085− afs_set_fc_call(call, fc);
1086− afs_make_call(&fc->ac, call, GFP_NOFS);
1087− return afs_wait_for_call_to_complete(call, &fc->ac);
1033+ trace_afs_make_fs_call2(call, &orig_dvp->fid, orig_name, new_name);
1034+ afs_make_op_call(op, call, GFP_NOFS);
10881035 }
10891036
10901037 /*
1091− * deliver reply data to an FS.StoreData
1038+ * Deliver reply data to FS.StoreData or FS.StoreStatus
10921039 */
10931040 static int afs_deliver_fs_store_data(struct afs_call *call)
10941041 {
1042+ struct afs_operation *op = call->op;
1043+ struct afs_vnode_param *vp = &op->file[0];
10951044 const __be32 *bp;
10961045 int ret;
10971046
@@ -1103,10 +1052,8 @@ static int afs_deliver_fs_store_data(struct afs_call *call) · 5 unmodified lines
11031052
11041053 /* unmarshall the reply once we've received all of it */
11051054 bp = call->buffer;
1106− ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
1107− if (ret < 0)
1108− return ret;
1109− xdr_decode_AFSVolSync(&bp, call->out_volsync);
1055+ xdr_decode_AFSFetchStatus(&bp, call, &vp->scb);
1056+ xdr_decode_AFSVolSync(&bp, &op->volsync);
11101057
11111058 _leave(" = 0 [done]");
11121059 return 0;
@@ -1132,90 +1079,69 @@ static const struct afs_call_type afs_RXFSStoreData64 = { · 19 unmodified lines
11321079 /*
11331080 * store a set of pages to a very large file
11341081 */
1135−static int afs_fs_store_data64(struct afs_fs_cursor *fc,
1136− struct address_space *mapping,
1137− pgoff_t first, pgoff_t last,
1138− unsigned offset, unsigned to,
1139− loff_t size, loff_t pos, loff_t i_size,
1140− struct afs_status_cb *scb)
1082+static void afs_fs_store_data64(struct afs_operation *op,
1083+ loff_t pos, loff_t size, loff_t i_size)
11411084 {
1142− struct afs_vnode *vnode = fc->vnode;
1085+ struct afs_vnode_param *vp = &op->file[0];
11431086 struct afs_call *call;
1144− struct afs_net *net = afs_v2net(vnode);
11451087 __be32 *bp;
11461088
11471089 _enter(",%x,{%llx:%llu},,",
1148− key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
1090+ key_serial(op->key), vp->fid.vid, vp->fid.vnode);
11491091
1150− call = afs_alloc_flat_call(net, &afs_RXFSStoreData64,
1092+ call = afs_alloc_flat_call(op->net, &afs_RXFSStoreData64,
11511093 (4 + 6 + 3 * 2) * 4,
11521094 (21 + 6) * 4);
11531095 if (!call)
1154− return -ENOMEM;
1096+ return afs_op_nomem(op);
11551097
1156− call->key = fc->key;
1157− call->mapping = mapping;
1158− call->first = first;
1159− call->last = last;
1160− call->first_offset = offset;
1161− call->last_to = to;
11621098 call->send_pages = true;
1163− call->out_scb = scb;
11641099
11651100 /* marshall the parameters */
11661101 bp = call->request;
11671102 *bp++ = htonl(FSSTOREDATA64);
1168− *bp++ = htonl(vnode->fid.vid);
1169− *bp++ = htonl(vnode->fid.vnode);
1170− *bp++ = htonl(vnode->fid.unique);
1103+ *bp++ = htonl(vp->fid.vid);
1104+ *bp++ = htonl(vp->fid.vnode);
1105+ *bp++ = htonl(vp->fid.unique);
11711106
11721107 *bp++ = htonl(AFS_SET_MTIME); /* mask */
1173− *bp++ = htonl(vnode->vfs_inode.i_mtime.tv_sec); /* mtime */
1108+ *bp++ = htonl(op->mtime.tv_sec); /* mtime */
11741109 *bp++ = 0; /* owner */
11751110 *bp++ = 0; /* group */
11761111 *bp++ = 0; /* unix mode */
11771112 *bp++ = 0; /* segment size */
11781113
1179− *bp++ = htonl(pos >> 32);
1180− *bp++ = htonl((u32) pos);
1181− *bp++ = htonl(size >> 32);
1182− *bp++ = htonl((u32) size);
1183− *bp++ = htonl(i_size >> 32);
1184− *bp++ = htonl((u32) i_size);
1185−
1186− trace_afs_make_fs_call(call, &vnode->fid);
1187− afs_set_fc_call(call, fc);
1188− afs_make_call(&fc->ac, call, GFP_NOFS);
1189− return afs_wait_for_call_to_complete(call, &fc->ac);
1114+ *bp++ = htonl(upper_32_bits(pos));
1115+ *bp++ = htonl(lower_32_bits(pos));
1116+ *bp++ = htonl(upper_32_bits(size));
1117+ *bp++ = htonl(lower_32_bits(size));
1118+ *bp++ = htonl(upper_32_bits(i_size));
1119+ *bp++ = htonl(lower_32_bits(i_size));
1120+
1121+ trace_afs_make_fs_call(call, &vp->fid);
1122+ afs_make_op_call(op, call, GFP_NOFS);
11901123 }
11911124
11921125 /*
11931126 * store a set of pages
11941127 */
1195−int afs_fs_store_data(struct afs_fs_cursor *fc, struct address_space *mapping,
1196− pgoff_t first, pgoff_t last,
1197− unsigned offset, unsigned to,
1198− struct afs_status_cb *scb)
1128+void afs_fs_store_data(struct afs_operation *op)
11991129 {
1200− struct afs_vnode *vnode = fc->vnode;
1130+ struct afs_vnode_param *vp = &op->file[0];
12011131 struct afs_call *call;
1202− struct afs_net *net = afs_v2net(vnode);
12031132 loff_t size, pos, i_size;
12041133 __be32 *bp;
12051134
1206− if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1207− return yfs_fs_store_data(fc, mapping, first, last, offset, to, scb);
1208−
12091135 _enter(",%x,{%llx:%llu},,",
1210− key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
1136+ key_serial(op->key), vp->fid.vid, vp->fid.vnode);
12111137
1212− size = (loff_t)to - (loff_t)offset;
1213− if (first != last)
1214− size += (loff_t)(last - first) << PAGE_SHIFT;
1215− pos = (loff_t)first << PAGE_SHIFT;
1216− pos += offset;
1138+ size = (loff_t)op->store.last_to - (loff_t)op->store.first_offset;
1139+ if (op->store.first != op->store.last)
1140+ size += (loff_t)(op->store.last - op->store.first) << PAGE_SHIFT;
1141+ pos = (loff_t)op->store.first << PAGE_SHIFT;
1142+ pos += op->store.first_offset;
12171143
1218− i_size = i_size_read(&vnode->vfs_inode);
1144+ i_size = i_size_read(&vp->vnode->vfs_inode);
12191145 if (pos + size > i_size)
12201146 i_size = size + pos;
12211147
@@ -1223,73 +1149,38 @@ int afs_fs_store_data(struct afs_fs_cursor *fc, struct address_space *mapping, · 1 unmodified line
12231149 (unsigned long long) size, (unsigned long long) pos,
12241150 (unsigned long long) i_size);
12251151
1226− if (pos >> 32 || i_size >> 32 || size >> 32 || (pos + size) >> 32)
1227− return afs_fs_store_data64(fc, mapping, first, last, offset, to,
1228− size, pos, i_size, scb);
1152+ if (upper_32_bits(pos) || upper_32_bits(i_size) || upper_32_bits(size) ||
1153+ upper_32_bits(pos + size))
1154+ return afs_fs_store_data64(op, pos, size, i_size);
12291155
1230− call = afs_alloc_flat_call(net, &afs_RXFSStoreData,
1156+ call = afs_alloc_flat_call(op->net, &afs_RXFSStoreData,
12311157 (4 + 6 + 3) * 4,
12321158 (21 + 6) * 4);
12331159 if (!call)
1234− return -ENOMEM;
1160+ return afs_op_nomem(op);
12351161
1236− call->key = fc->key;
1237− call->mapping = mapping;
1238− call->first = first;
1239− call->last = last;
1240− call->first_offset = offset;
1241− call->last_to = to;
12421162 call->send_pages = true;
1243− call->out_scb = scb;
12441163
12451164 /* marshall the parameters */
12461165 bp = call->request;
12471166 *bp++ = htonl(FSSTOREDATA);
1248− *bp++ = htonl(vnode->fid.vid);
1249− *bp++ = htonl(vnode->fid.vnode);
1250− *bp++ = htonl(vnode->fid.unique);
1167+ *bp++ = htonl(vp->fid.vid);
1168+ *bp++ = htonl(vp->fid.vnode);
1169+ *bp++ = htonl(vp->fid.unique);
12511170
12521171 *bp++ = htonl(AFS_SET_MTIME); /* mask */
1253− *bp++ = htonl(vnode->vfs_inode.i_mtime.tv_sec); /* mtime */
1172+ *bp++ = htonl(op->mtime.tv_sec); /* mtime */
12541173 *bp++ = 0; /* owner */
12551174 *bp++ = 0; /* group */
12561175 *bp++ = 0; /* unix mode */
12571176 *bp++ = 0; /* segment size */
12581177
1259− *bp++ = htonl(pos);
1260− *bp++ = htonl(size);
1261− *bp++ = htonl(i_size);
1262−
1263− afs_use_fs_server(call, fc->cbi);
1264− trace_afs_make_fs_call(call, &vnode->fid);
1265− afs_set_fc_call(call, fc);
1266− afs_make_call(&fc->ac, call, GFP_NOFS);
1267− return afs_wait_for_call_to_complete(call, &fc->ac);
1268−}
1269−
1270−/*
1271− * deliver reply data to an FS.StoreStatus
1272− */
1273−static int afs_deliver_fs_store_status(struct afs_call *call)
1274−{
1275− const __be32 *bp;
1276− int ret;
1277−
1278− _enter("");
1178+ *bp++ = htonl(lower_32_bits(pos));
1179+ *bp++ = htonl(lower_32_bits(size));
1180+ *bp++ = htonl(lower_32_bits(i_size));
12791181
1280− ret = afs_transfer_reply(call);
1281− if (ret < 0)
1282− return ret;
1283−
1284− /* unmarshall the reply once we've received all of it */
1285− bp = call->buffer;
1286− ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
1287− if (ret < 0)
1288− return ret;
1289− xdr_decode_AFSVolSync(&bp, call->out_volsync);
1290−
1291− _leave(" = 0 [done]");
1292− return 0;
1182+ trace_afs_make_fs_call(call, &vp->fid);
1183+ afs_make_op_call(op, call, GFP_NOFS);
12931184 }
12941185
12951186 /*
@@ -1298,21 +1189,21 @@ static int afs_deliver_fs_store_status(struct afs_call *call) · 2 unmodified lines
12981189 static const struct afs_call_type afs_RXFSStoreStatus = {
12991190 .name = "FS.StoreStatus",
13001191 .op = afs_FS_StoreStatus,
1301− .deliver = afs_deliver_fs_store_status,
1192+ .deliver = afs_deliver_fs_store_data,
13021193 .destructor = afs_flat_call_destructor,
13031194 };
13041195
13051196 static const struct afs_call_type afs_RXFSStoreData_as_Status = {
13061197 .name = "FS.StoreData",
13071198 .op = afs_FS_StoreData,
1308− .deliver = afs_deliver_fs_store_status,
1199+ .deliver = afs_deliver_fs_store_data,
13091200 .destructor = afs_flat_call_destructor,
13101201 };
13111202
13121203 static const struct afs_call_type afs_RXFSStoreData64_as_Status = {
13131204 .name = "FS.StoreData64",
13141205 .op = afs_FS_StoreData64,
1315− .deliver = afs_deliver_fs_store_status,
1206+ .deliver = afs_deliver_fs_store_data,
13161207 .destructor = afs_flat_call_destructor,
13171208 };
13181209
@@ -1320,85 +1211,74 @@ static const struct afs_call_type afs_RXFSStoreData64_as_Status = { · 1 unmodified line
13201211 * set the attributes on a very large file, using FS.StoreData rather than
13211212 * FS.StoreStatus so as to alter the file size also
13221213 */
1323−static int afs_fs_setattr_size64(struct afs_fs_cursor *fc, struct iattr *attr,
1324− struct afs_status_cb *scb)
1214+static void afs_fs_setattr_size64(struct afs_operation *op)
13251215 {
1326− struct afs_vnode *vnode = fc->vnode;
1216+ struct afs_vnode_param *vp = &op->file[0];
13271217 struct afs_call *call;
1328− struct afs_net *net = afs_v2net(vnode);
1218+ struct iattr *attr = op->setattr.attr;
13291219 __be32 *bp;
13301220
13311221 _enter(",%x,{%llx:%llu},,",
1332− key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
1222+ key_serial(op->key), vp->fid.vid, vp->fid.vnode);
13331223
13341224 ASSERT(attr->ia_valid & ATTR_SIZE);
13351225
1336− call = afs_alloc_flat_call(net, &afs_RXFSStoreData64_as_Status,
1226+ call = afs_alloc_flat_call(op->net, &afs_RXFSStoreData64_as_Status,
13371227 (4 + 6 + 3 * 2) * 4,
13381228 (21 + 6) * 4);
13391229 if (!call)
1340− return -ENOMEM;
1341−
1342− call->key = fc->key;
1343− call->out_scb = scb;
1230+ return afs_op_nomem(op);
13441231
13451232 /* marshall the parameters */
13461233 bp = call->request;
13471234 *bp++ = htonl(FSSTOREDATA64);
1348− *bp++ = htonl(vnode->fid.vid);
1349− *bp++ = htonl(vnode->fid.vnode);
1350− *bp++ = htonl(vnode->fid.unique);
1235+ *bp++ = htonl(vp->fid.vid);
1236+ *bp++ = htonl(vp->fid.vnode);
1237+ *bp++ = htonl(vp->fid.unique);
13511238
13521239 xdr_encode_AFS_StoreStatus(&bp, attr);
13531240
1354− *bp++ = htonl(attr->ia_size >> 32); /* position of start of write */
1355− *bp++ = htonl((u32) attr->ia_size);
1356− *bp++ = 0; /* size of write */
1241+ *bp++ = htonl(upper_32_bits(attr->ia_size)); /* position of start of write */
1242+ *bp++ = htonl(lower_32_bits(attr->ia_size));
1243+ *bp++ = 0; /* size of write */
13571244 *bp++ = 0;
1358− *bp++ = htonl(attr->ia_size >> 32); /* new file length */
1359− *bp++ = htonl((u32) attr->ia_size);
1360−
1361− afs_use_fs_server(call, fc->cbi);
1362− trace_afs_make_fs_call(call, &vnode->fid);
1363− afs_set_fc_call(call, fc);
1364− afs_make_call(&fc->ac, call, GFP_NOFS);
1365− return afs_wait_for_call_to_complete(call, &fc->ac);
1245+ *bp++ = htonl(upper_32_bits(attr->ia_size)); /* new file length */
1246+ *bp++ = htonl(lower_32_bits(attr->ia_size));
1247+
1248+ trace_afs_make_fs_call(call, &vp->fid);
1249+ afs_make_op_call(op, call, GFP_NOFS);
13661250 }
13671251
13681252 /*
13691253 * set the attributes on a file, using FS.StoreData rather than FS.StoreStatus
13701254 * so as to alter the file size also
13711255 */
1372−static int afs_fs_setattr_size(struct afs_fs_cursor *fc, struct iattr *attr,
1373− struct afs_status_cb *scb)
1256+static void afs_fs_setattr_size(struct afs_operation *op)
13741257 {
1375− struct afs_vnode *vnode = fc->vnode;
1258+ struct afs_vnode_param *vp = &op->file[0];
13761259 struct afs_call *call;
1377− struct afs_net *net = afs_v2net(vnode);
1260+ struct iattr *attr = op->setattr.attr;
13781261 __be32 *bp;
13791262
13801263 _enter(",%x,{%llx:%llu},,",
1381− key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
1264+ key_serial(op->key), vp->fid.vid, vp->fid.vnode);
13821265
13831266 ASSERT(attr->ia_valid & ATTR_SIZE);
1384− if (attr->ia_size >> 32)
1385− return afs_fs_setattr_size64(fc, attr, scb);
1267+ if (upper_32_bits(attr->ia_size))
1268+ return afs_fs_setattr_size64(op);
13861269
1387− call = afs_alloc_flat_call(net, &afs_RXFSStoreData_as_Status,
1270+ call = afs_alloc_flat_call(op->net, &afs_RXFSStoreData_as_Status,
13881271 (4 + 6 + 3) * 4,
13891272 (21 + 6) * 4);
13901273 if (!call)
1391− return -ENOMEM;
1392−
1393− call->key = fc->key;
1394− call->out_scb = scb;
1274+ return afs_op_nomem(op);
13951275
13961276 /* marshall the parameters */
13971277 bp = call->request;
13981278 *bp++ = htonl(FSSTOREDATA);
1399− *bp++ = htonl(vnode->fid.vid);
1400− *bp++ = htonl(vnode->fid.vnode);
1401− *bp++ = htonl(vnode->fid.unique);
1279+ *bp++ = htonl(vp->fid.vid);
1280+ *bp++ = htonl(vp->fid.vnode);
1281+ *bp++ = htonl(vp->fid.unique);
14021282
14031283 xdr_encode_AFS_StoreStatus(&bp, attr);
14041284
@@ -1406,57 +1286,44 @@ static int afs_fs_setattr_size(struct afs_fs_cursor *fc, struct iattr *attr, · 1 unmodified line
14061286 *bp++ = 0; /* size of write */
14071287 *bp++ = htonl(attr->ia_size); /* new file length */
14081288
1409− afs_use_fs_server(call, fc->cbi);
1410− trace_afs_make_fs_call(call, &vnode->fid);
1411− afs_set_fc_call(call, fc);
1412− afs_make_call(&fc->ac, call, GFP_NOFS);
1413− return afs_wait_for_call_to_complete(call, &fc->ac);
1289+ trace_afs_make_fs_call(call, &vp->fid);
1290+ afs_make_op_call(op, call, GFP_NOFS);
14141291 }
14151292
14161293 /*
14171294 * set the attributes on a file, using FS.StoreData if there's a change in file
14181295 * size, and FS.StoreStatus otherwise
14191296 */
1420−int afs_fs_setattr(struct afs_fs_cursor *fc, struct iattr *attr,
1421− struct afs_status_cb *scb)
1297+void afs_fs_setattr(struct afs_operation *op)
14221298 {
1423− struct afs_vnode *vnode = fc->vnode;
1299+ struct afs_vnode_param *vp = &op->file[0];
14241300 struct afs_call *call;
1425− struct afs_net *net = afs_v2net(vnode);
1301+ struct iattr *attr = op->setattr.attr;
14261302 __be32 *bp;
14271303
1428− if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1429− return yfs_fs_setattr(fc, attr, scb);
1430−
14311304 if (attr->ia_valid & ATTR_SIZE)
1432− return afs_fs_setattr_size(fc, attr, scb);
1305+ return afs_fs_setattr_size(op);
14331306
14341307 _enter(",%x,{%llx:%llu},,",
1435− key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
1308+ key_serial(op->key), vp->fid.vid, vp->fid.vnode);
14361309
1437− call = afs_alloc_flat_call(net, &afs_RXFSStoreStatus,
1310+ call = afs_alloc_flat_call(op->net, &afs_RXFSStoreStatus,
14381311 (4 + 6) * 4,
14391312 (21 + 6) * 4);
14401313 if (!call)
1441− return -ENOMEM;
1442−
1443− call->key = fc->key;
1444− call->out_scb = scb;
1314+ return afs_op_nomem(op);
14451315
14461316 /* marshall the parameters */
14471317 bp = call->request;
14481318 *bp++ = htonl(FSSTORESTATUS);
1449− *bp++ = htonl(vnode->fid.vid);
1450− *bp++ = htonl(vnode->fid.vnode);
1451− *bp++ = htonl(vnode->fid.unique);
1319+ *bp++ = htonl(vp->fid.vid);
1320+ *bp++ = htonl(vp->fid.vnode);
1321+ *bp++ = htonl(vp->fid.unique);
14521322
1453− xdr_encode_AFS_StoreStatus(&bp, attr);
1323+ xdr_encode_AFS_StoreStatus(&bp, op->setattr.attr);
14541324
1455− afs_use_fs_server(call, fc->cbi);
1456− trace_afs_make_fs_call(call, &vnode->fid);
1457− afs_set_fc_call(call, fc);
1458− afs_make_call(&fc->ac, call, GFP_NOFS);
1459− return afs_wait_for_call_to_complete(call, &fc->ac);
1325+ trace_afs_make_fs_call(call, &vp->fid);
1326+ afs_make_op_call(op, call, GFP_NOFS);
14601327 }
14611328
14621329 /*
@@ -1464,6 +1331,7 @@ int afs_fs_setattr(struct afs_fs_cursor *fc, struct iattr *attr, · 1 unmodified line
14641331 */
14651332 static int afs_deliver_fs_get_volume_status(struct afs_call *call)
14661333 {
1334+ struct afs_operation *op = call->op;
14671335 const __be32 *bp;
14681336 char *p;
14691337 u32 size;
@@ -1485,7 +1353,7 @@ static int afs_deliver_fs_get_volume_status(struct afs_call *call) · 15 unmodified lines
14851353 return ret;
14861354
14871355 bp = call->buffer;
1488− xdr_decode_AFSFetchVolumeStatus(&bp, call->out_volstatus);
1356+ xdr_decode_AFSFetchVolumeStatus(&bp, &op->volstatus.vs);
14891357 call->unmarshall++;
14901358 afs_extract_to_tmp(call);
14911359 /* Fall through */
@@ -1499,8 +1367,7 @@ static int afs_deliver_fs_get_volume_status(struct afs_call *call) · 7 unmodified lines
14991367 call->count = ntohl(call->tmp);
15001368 _debug("volname length: %u", call->count);
15011369 if (call->count >= AFSNAMEMAX)
1502− return afs_protocol_error(call, -EBADMSG,
1503− afs_eproto_volname_len);
1370+ return afs_protocol_error(call, afs_eproto_volname_len);
15041371 size = (call->count + 3) & ~3; /* It's padded */
15051372 afs_extract_to_buf(call, size);
15061373 call->unmarshall++;
@@ -1529,8 +1396,7 @@ static int afs_deliver_fs_get_volume_status(struct afs_call *call) · 22 unmodified lines
15291396 call->count = ntohl(call->tmp);
15301397 _debug("offline msg length: %u", call->count);
15311398 if (call->count >= AFSNAMEMAX)
1532− return afs_protocol_error(call, -EBADMSG,
1533− afs_eproto_offline_msg_len);
1399+ return afs_protocol_error(call, afs_eproto_offline_msg_len);
15341400 size = (call->count + 3) & ~3; /* It's padded */
15351401 afs_extract_to_buf(call, size);
15361402 call->unmarshall++;
@@ -1560,8 +1426,7 @@ static int afs_deliver_fs_get_volume_status(struct afs_call *call) · 23 unmodified lines
15601426 call->count = ntohl(call->tmp);
15611427 _debug("motd length: %u", call->count);
15621428 if (call->count >= AFSNAMEMAX)
1563− return afs_protocol_error(call, -EBADMSG,
1564− afs_eproto_motd_len);
1429+ return afs_protocol_error(call, afs_eproto_motd_len);
15651430 size = (call->count + 3) & ~3; /* It's padded */
15661431 afs_extract_to_buf(call, size);
15671432 call->unmarshall++;
@@ -1601,37 +1466,26 @@ static const struct afs_call_type afs_RXFSGetVolumeStatus = { · 33 unmodified lines
16011466 /*
16021467 * fetch the status of a volume
16031468 */
1604−int afs_fs_get_volume_status(struct afs_fs_cursor *fc,
1605− struct afs_volume_status *vs)
1469+void afs_fs_get_volume_status(struct afs_operation *op)
16061470 {
1607− struct afs_vnode *vnode = fc->vnode;
1471+ struct afs_vnode_param *vp = &op->file[0];
16081472 struct afs_call *call;
1609− struct afs_net *net = afs_v2net(vnode);
16101473 __be32 *bp;
16111474
1612− if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1613− return yfs_fs_get_volume_status(fc, vs);
1614−
16151475 _enter("");
16161476
1617− call = afs_alloc_flat_call(net, &afs_RXFSGetVolumeStatus, 2 * 4,
1477+ call = afs_alloc_flat_call(op->net, &afs_RXFSGetVolumeStatus, 2 * 4,
16181478 max(12 * 4, AFSOPAQUEMAX + 1));
16191479 if (!call)
1620− return -ENOMEM;
1621−
1622− call->key = fc->key;
1623− call->out_volstatus = vs;
1480+ return afs_op_nomem(op);
16241481
16251482 /* marshall the parameters */
16261483 bp = call->request;
16271484 bp[0] = htonl(FSGETVOLUMESTATUS);
1628− bp[1] = htonl(vnode->fid.vid);
1485+ bp[1] = htonl(vp->fid.vid);
16291486
1630− afs_use_fs_server(call, fc->cbi);
1631− trace_afs_make_fs_call(call, &vnode->fid);
1632− afs_set_fc_call(call, fc);
1633− afs_make_call(&fc->ac, call, GFP_NOFS);
1634− return afs_wait_for_call_to_complete(call, &fc->ac);
1487+ trace_afs_make_fs_call(call, &vp->fid);
1488+ afs_make_op_call(op, call, GFP_NOFS);
16351489 }
16361490
16371491 /*
@@ -1639,6 +1493,7 @@ int afs_fs_get_volume_status(struct afs_fs_cursor *fc, · 1 unmodified line
16391493 */
16401494 static int afs_deliver_fs_xxxx_lock(struct afs_call *call)
16411495 {
1496+ struct afs_operation *op = call->op;
16421497 const __be32 *bp;
16431498 int ret;
16441499
@@ -1650,7 +1505,7 @@ static int afs_deliver_fs_xxxx_lock(struct afs_call *call) · 5 unmodified lines
16501505
16511506 /* unmarshall the reply once we've received all of it */
16521507 bp = call->buffer;
1653− xdr_decode_AFSVolSync(&bp, call->out_volsync);
1508+ xdr_decode_AFSVolSync(&bp, &op->volsync);
16541509
16551510 _leave(" = 0 [done]");
16561511 return 0;
@@ -1691,114 +1546,80 @@ static const struct afs_call_type afs_RXFSReleaseLock = { · 34 unmodified lines
16911546 /*
16921547 * Set a lock on a file
16931548 */
1694−int afs_fs_set_lock(struct afs_fs_cursor *fc, afs_lock_type_t type,
1695− struct afs_status_cb *scb)
1549+void afs_fs_set_lock(struct afs_operation *op)
16961550 {
1697− struct afs_vnode *vnode = fc->vnode;
1551+ struct afs_vnode_param *vp = &op->file[0];
16981552 struct afs_call *call;
1699− struct afs_net *net = afs_v2net(vnode);
17001553 __be32 *bp;
17011554
1702− if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1703− return yfs_fs_set_lock(fc, type, scb);
1704−
17051555 _enter("");
17061556
1707− call = afs_alloc_flat_call(net, &afs_RXFSSetLock, 5 * 4, 6 * 4);
1557+ call = afs_alloc_flat_call(op->net, &afs_RXFSSetLock, 5 * 4, 6 * 4);
17081558 if (!call)
1709− return -ENOMEM;
1710−
1711− call->key = fc->key;
1712− call->lvnode = vnode;
1713− call->out_scb = scb;
1559+ return afs_op_nomem(op);
17141560
17151561 /* marshall the parameters */
17161562 bp = call->request;
17171563 *bp++ = htonl(FSSETLOCK);
1718− *bp++ = htonl(vnode->fid.vid);
1719− *bp++ = htonl(vnode->fid.vnode);
1720− *bp++ = htonl(vnode->fid.unique);
1721− *bp++ = htonl(type);
1722−
1723− afs_use_fs_server(call, fc->cbi);
1724− trace_afs_make_fs_calli(call, &vnode->fid, type);
1725− afs_set_fc_call(call, fc);
1726− afs_make_call(&fc->ac, call, GFP_NOFS);
1727− return afs_wait_for_call_to_complete(call, &fc->ac);
1564+ *bp++ = htonl(vp->fid.vid);
1565+ *bp++ = htonl(vp->fid.vnode);
1566+ *bp++ = htonl(vp->fid.unique);
1567+ *bp++ = htonl(op->lock.type);
1568+
1569+ trace_afs_make_fs_calli(call, &vp->fid, op->lock.type);
1570+ afs_make_op_call(op, call, GFP_NOFS);
17281571 }
17291572
17301573 /*
17311574 * extend a lock on a file
17321575 */
1733−int afs_fs_extend_lock(struct afs_fs_cursor *fc, struct afs_status_cb *scb)
1576+void afs_fs_extend_lock(struct afs_operation *op)
17341577 {
1735− struct afs_vnode *vnode = fc->vnode;
1578+ struct afs_vnode_param *vp = &op->file[0];
17361579 struct afs_call *call;
1737− struct afs_net *net = afs_v2net(vnode);
17381580 __be32 *bp;
17391581
1740− if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1741− return yfs_fs_extend_lock(fc, scb);
1742−
17431582 _enter("");
17441583
1745− call = afs_alloc_flat_call(net, &afs_RXFSExtendLock, 4 * 4, 6 * 4);
1584+ call = afs_alloc_flat_call(op->net, &afs_RXFSExtendLock, 4 * 4, 6 * 4);
17461585 if (!call)
1747− return -ENOMEM;
1748−
1749− call->key = fc->key;
1750− call->lvnode = vnode;
1751− call->out_scb = scb;
1586+ return afs_op_nomem(op);
17521587
17531588 /* marshall the parameters */
17541589 bp = call->request;
17551590 *bp++ = htonl(FSEXTENDLOCK);
1756− *bp++ = htonl(vnode->fid.vid);
1757− *bp++ = htonl(vnode->fid.vnode);
1758− *bp++ = htonl(vnode->fid.unique);
1759−
1760− afs_use_fs_server(call, fc->cbi);
1761− trace_afs_make_fs_call(call, &vnode->fid);
1762− afs_set_fc_call(call, fc);
1763− afs_make_call(&fc->ac, call, GFP_NOFS);
1764− return afs_wait_for_call_to_complete(call, &fc->ac);
1591+ *bp++ = htonl(vp->fid.vid);
1592+ *bp++ = htonl(vp->fid.vnode);
1593+ *bp++ = htonl(vp->fid.unique);
1594+
1595+ trace_afs_make_fs_call(call, &vp->fid);
1596+ afs_make_op_call(op, call, GFP_NOFS);
17651597 }
17661598
17671599 /*
17681600 * release a lock on a file
17691601 */
1770−int afs_fs_release_lock(struct afs_fs_cursor *fc, struct afs_status_cb *scb)
1602+void afs_fs_release_lock(struct afs_operation *op)
17711603 {
1772− struct afs_vnode *vnode = fc->vnode;
1604+ struct afs_vnode_param *vp = &op->file[0];
17731605 struct afs_call *call;
1774− struct afs_net *net = afs_v2net(vnode);
17751606 __be32 *bp;
17761607
1777− if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1778− return yfs_fs_release_lock(fc, scb);
1779−
17801608 _enter("");
17811609
1782− call = afs_alloc_flat_call(net, &afs_RXFSReleaseLock, 4 * 4, 6 * 4);
1610+ call = afs_alloc_flat_call(op->net, &afs_RXFSReleaseLock, 4 * 4, 6 * 4);
17831611 if (!call)
1784− return -ENOMEM;
1785−
1786− call->key = fc->key;
1787− call->lvnode = vnode;
1788− call->out_scb = scb;
1612+ return afs_op_nomem(op);
17891613
17901614 /* marshall the parameters */
17911615 bp = call->request;
17921616 *bp++ = htonl(FSRELEASELOCK);
1793− *bp++ = htonl(vnode->fid.vid);
1794− *bp++ = htonl(vnode->fid.vnode);
1795− *bp++ = htonl(vnode->fid.unique);
1796−
1797− afs_use_fs_server(call, fc->cbi);
1798− trace_afs_make_fs_call(call, &vnode->fid);
1799− afs_set_fc_call(call, fc);
1800− afs_make_call(&fc->ac, call, GFP_NOFS);
1801− return afs_wait_for_call_to_complete(call, &fc->ac);
1617+ *bp++ = htonl(vp->fid.vid);
1618+ *bp++ = htonl(vp->fid.vnode);
1619+ *bp++ = htonl(vp->fid.unique);
1620+
1621+ trace_afs_make_fs_call(call, &vp->fid);
1622+ afs_make_op_call(op, call, GFP_NOFS);
18021623 }
18031624
18041625 /*
@@ -1842,7 +1663,7 @@ int afs_fs_give_up_all_callbacks(struct afs_net *net, · 37 unmodified lines
18421663 bp = call->request;
18431664 *bp++ = htonl(FSGIVEUPALLCALLBACKS);
18441665
1845− /* Can't take a ref on server */
1666+ call->server = afs_use_server(server, afs_server_trace_give_up_cb);
18461667 afs_make_call(ac, call, GFP_NOFS);
18471668 return afs_wait_for_call_to_complete(call, ac);
18481669 }
@@ -1905,14 +1726,13 @@ static const struct afs_call_type afs_RXFSGetCapabilities = { · 56 unmodified lines
19051726 };
19061727
19071728 /*
1908− * Probe a fileserver for the capabilities that it supports. This can
1909− * return up to 196 words.
1729+ * Probe a fileserver for the capabilities that it supports. This RPC can
1730+ * reply with up to 196 words. The operation is asynchronous and if we managed
1731+ * to allocate a call, true is returned the result is delivered through the
1732+ * ->done() - otherwise we return false to indicate we didn't even try.
19101733 */
1911−struct afs_call *afs_fs_get_capabilities(struct afs_net *net,
1912− struct afs_server *server,
1913− struct afs_addr_cursor *ac,
1914− struct key *key,
1915− unsigned int server_index)
1734+bool afs_fs_get_capabilities(struct afs_net *net, struct afs_server *server,
1735+ struct afs_addr_cursor *ac, struct key *key)
19161736 {
19171737 struct afs_call *call;
19181738 __be32 *bp;
@@ -1921,11 +1741,10 @@ struct afs_call *afs_fs_get_capabilities(struct afs_net *net, · 2 unmodified lines
19211741
19221742 call = afs_alloc_flat_call(net, &afs_RXFSGetCapabilities, 1 * 4, 16 * 4);
19231743 if (!call)
1924− return ERR_PTR(-ENOMEM);
1744+ return false;
19251745
19261746 call->key = key;
1927− call->server = afs_get_server(server, afs_server_trace_get_caps);
1928− call->server_index = server_index;
1747+ call->server = afs_use_server(server, afs_server_trace_get_caps);
19291748 call->upgrade = true;
19301749 call->async = true;
19311750 call->max_lifespan = AFS_PROBE_MAX_LIFESPAN;
@@ -1934,87 +1753,10 @@ struct afs_call *afs_fs_get_capabilities(struct afs_net *net, · 2 unmodified lines
19341753 bp = call->request;
19351754 *bp++ = htonl(FSGETCAPABILITIES);
19361755
1937− /* Can't take a ref on server */
19381756 trace_afs_make_fs_call(call, NULL);
19391757 afs_make_call(ac, call, GFP_NOFS);
1940− return call;
1941−}
1942−
1943−/*
1944− * Deliver reply data to an FS.FetchStatus with no vnode.
1945− */
1946−static int afs_deliver_fs_fetch_status(struct afs_call *call)
1947−{
1948− const __be32 *bp;
1949− int ret;
1950−
1951− ret = afs_transfer_reply(call);
1952− if (ret < 0)
1953− return ret;
1954−
1955− /* unmarshall the reply once we've received all of it */
1956− bp = call->buffer;
1957− ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
1958− if (ret < 0)
1959− return ret;
1960− xdr_decode_AFSCallBack(&bp, call, call->out_scb);
1961− xdr_decode_AFSVolSync(&bp, call->out_volsync);
1962−
1963− _leave(" = 0 [done]");
1964− return 0;
1965−}
1966−
1967−/*
1968− * FS.FetchStatus operation type
1969− */
1970−static const struct afs_call_type afs_RXFSFetchStatus = {
1971− .name = "FS.FetchStatus",
1972− .op = afs_FS_FetchStatus,
1973− .deliver = afs_deliver_fs_fetch_status,
1974− .destructor = afs_flat_call_destructor,
1975−};
1976−
1977−/*
1978− * Fetch the status information for a fid without needing a vnode handle.
1979− */
1980−int afs_fs_fetch_status(struct afs_fs_cursor *fc,
1981− struct afs_net *net,
1982− struct afs_fid *fid,
1983− struct afs_status_cb *scb,
1984− struct afs_volsync *volsync)
1985−{
1986− struct afs_call *call;
1987− __be32 *bp;
1988−
1989− if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1990− return yfs_fs_fetch_status(fc, net, fid, scb, volsync);
1991−
1992− _enter(",%x,{%llx:%llu},,",
1993− key_serial(fc->key), fid->vid, fid->vnode);
1994−
1995− call = afs_alloc_flat_call(net, &afs_RXFSFetchStatus, 16, (21 + 3 + 6) * 4);
1996− if (!call) {
1997− fc->ac.error = -ENOMEM;
1998− return -ENOMEM;
1999− }
2000−
2001− call->key = fc->key;
2002− call->out_fid = fid;
2003− call->out_scb = scb;
2004− call->out_volsync = volsync;
2005−
2006− /* marshall the parameters */
2007− bp = call->request;
2008− bp[0] = htonl(FSFETCHSTATUS);
2009− bp[1] = htonl(fid->vid);
2010− bp[2] = htonl(fid->vnode);
2011− bp[3] = htonl(fid->unique);
2012−
2013− afs_use_fs_server(call, fc->cbi);
2014− trace_afs_make_fs_call(call, fid);
2015− afs_set_fc_call(call, fc);
2016− afs_make_call(&fc->ac, call, GFP_NOFS);
2017− return afs_wait_for_call_to_complete(call, &fc->ac);
1758+ afs_put_call(call);
1759+ return true;
20181760 }
20191761
20201762 /*
@@ -2022,6 +1764,7 @@ int afs_fs_fetch_status(struct afs_fs_cursor *fc, · 1 unmodified line
20221764 */
20231765 static int afs_deliver_fs_inline_bulk_status(struct afs_call *call)
20241766 {
1767+ struct afs_operation *op = call->op;
20251768 struct afs_status_cb *scb;
20261769 const __be32 *bp;
20271770 u32 tmp;
@@ -2043,10 +1786,9 @@ static int afs_deliver_fs_inline_bulk_status(struct afs_call *call) · 15 unmodified lines
20431786 return ret;
20441787
20451788 tmp = ntohl(call->tmp);
2046− _debug("status count: %u/%u", tmp, call->count2);
2047− if (tmp != call->count2)
2048− return afs_protocol_error(call, -EBADMSG,
2049− afs_eproto_ibulkst_count);
1789+ _debug("status count: %u/%u", tmp, op->nr_files);
1790+ if (tmp != op->nr_files)
1791+ return afs_protocol_error(call, afs_eproto_ibulkst_count);
20501792
20511793 call->count = 0;
20521794 call->unmarshall++;
@@ -2060,14 +1802,23 @@ static int afs_deliver_fs_inline_bulk_status(struct afs_call *call) · 7 unmodified lines
20601802 if (ret < 0)
20611803 return ret;
20621804
1805+ switch (call->count) {
1806+ case 0:
1807+ scb = &op->file[0].scb;
1808+ break;
1809+ case 1:
1810+ scb = &op->file[1].scb;
1811+ break;
1812+ default:
1813+ scb = &op->more_files[call->count - 2].scb;
1814+ break;
1815+ }
1816+
20631817 bp = call->buffer;
2064− scb = &call->out_scb[call->count];
2065− ret = xdr_decode_AFSFetchStatus(&bp, call, scb);
2066− if (ret < 0)
2067− return ret;
1818+ xdr_decode_AFSFetchStatus(&bp, call, scb);
20681819
20691820 call->count++;
2070− if (call->count < call->count2)
1821+ if (call->count < op->nr_files)
20711822 goto more_counts;
20721823
20731824 call->count = 0;
@@ -2084,9 +1835,8 @@ static int afs_deliver_fs_inline_bulk_status(struct afs_call *call) · 10 unmodified lines
20841835
20851836 tmp = ntohl(call->tmp);
20861837 _debug("CB count: %u", tmp);
2087− if (tmp != call->count2)
2088− return afs_protocol_error(call, -EBADMSG,
2089− afs_eproto_ibulkst_cb_count);
1838+ if (tmp != op->nr_files)
1839+ return afs_protocol_error(call, afs_eproto_ibulkst_cb_count);
20901840 call->count = 0;
20911841 call->unmarshall++;
20921842 more_cbs:
@@ -2100,11 +1850,22 @@ static int afs_deliver_fs_inline_bulk_status(struct afs_call *call) · 7 unmodified lines
21001850 return ret;
21011851
21021852 _debug("unmarshall CB array");
1853+ switch (call->count) {
1854+ case 0:
1855+ scb = &op->file[0].scb;
1856+ break;
1857+ case 1:
1858+ scb = &op->file[1].scb;
1859+ break;
1860+ default:
1861+ scb = &op->more_files[call->count - 2].scb;
1862+ break;
1863+ }
1864+
21031865 bp = call->buffer;
2104− scb = &call->out_scb[call->count];
21051866 xdr_decode_AFSCallBack(&bp, call, scb);
21061867 call->count++;
2107− if (call->count < call->count2)
1868+ if (call->count < op->nr_files)
21081869 goto more_cbs;
21091870
21101871 afs_extract_to_buf(call, 6 * sizeof(__be32));
@@ -2117,7 +1878,7 @@ static int afs_deliver_fs_inline_bulk_status(struct afs_call *call) · 6 unmodified lines
21171878 return ret;
21181879
21191880 bp = call->buffer;
2120− xdr_decode_AFSVolSync(&bp, call->out_volsync);
1881+ xdr_decode_AFSVolSync(&bp, &op->volsync);
21211882
21221883 call->unmarshall++;
21231884
@@ -2129,6 +1890,16 @@ static int afs_deliver_fs_inline_bulk_status(struct afs_call *call) · 5 unmodified lines
21291890 return 0;
21301891 }
21311892
1893+static void afs_done_fs_inline_bulk_status(struct afs_call *call)
1894+{
1895+ if (call->error == -ECONNABORTED &&
1896+ call->abort_code == RX_INVALID_OPERATION) {
1897+ set_bit(AFS_SERVER_FL_NO_IBULK, &call->server->flags);
1898+ if (call->op)
1899+ set_bit(AFS_VOLUME_MAYBE_NO_IBULK, &call->op->volume->flags);
1900+ }
1901+}
1902+
21321903 /*
21331904 * FS.InlineBulkStatus operation type
21341905 */
@@ -2136,58 +1907,53 @@ static const struct afs_call_type afs_RXFSInlineBulkStatus = { · 1 unmodified line
21361907 .name = "FS.InlineBulkStatus",
21371908 .op = afs_FS_InlineBulkStatus,
21381909 .deliver = afs_deliver_fs_inline_bulk_status,
1910+ .done = afs_done_fs_inline_bulk_status,
21391911 .destructor = afs_flat_call_destructor,
21401912 };
21411913
21421914 /*
21431915 * Fetch the status information for up to 50 files
21441916 */
2145−int afs_fs_inline_bulk_status(struct afs_fs_cursor *fc,
2146− struct afs_net *net,
2147− struct afs_fid *fids,
2148− struct afs_status_cb *statuses,
2149− unsigned int nr_fids,
2150− struct afs_volsync *volsync)
1917+void afs_fs_inline_bulk_status(struct afs_operation *op)
21511918 {
1919+ struct afs_vnode_param *dvp = &op->file[0];
1920+ struct afs_vnode_param *vp = &op->file[1];
21521921 struct afs_call *call;
21531922 __be32 *bp;
21541923 int i;
21551924
2156− if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
2157− return yfs_fs_inline_bulk_status(fc, net, fids, statuses,
2158− nr_fids, volsync);
1925+ if (test_bit(AFS_SERVER_FL_NO_IBULK, &op->server->flags)) {
1926+ op->error = -ENOTSUPP;
1927+ return;
1928+ }
21591929
21601930 _enter(",%x,{%llx:%llu},%u",
2161− key_serial(fc->key), fids[0].vid, fids[1].vnode, nr_fids);
1931+ key_serial(op->key), vp->fid.vid, vp->fid.vnode, op->nr_files);
21621932
2163− call = afs_alloc_flat_call(net, &afs_RXFSInlineBulkStatus,
2164− (2 + nr_fids * 3) * 4,
1933+ call = afs_alloc_flat_call(op->net, &afs_RXFSInlineBulkStatus,
1934+ (2 + op->nr_files * 3) * 4,
21651935 21 * 4);
2166− if (!call) {
2167− fc->ac.error = -ENOMEM;
2168− return -ENOMEM;
2169− }
2170−
2171− call->key = fc->key;
2172− call->out_scb = statuses;
2173− call->out_volsync = volsync;
2174− call->count2 = nr_fids;
1936+ if (!call)
1937+ return afs_op_nomem(op);
21751938
21761939 /* marshall the parameters */
21771940 bp = call->request;
21781941 *bp++ = htonl(FSINLINEBULKSTATUS);
2179− *bp++ = htonl(nr_fids);
2180− for (i = 0; i < nr_fids; i++) {
2181− *bp++ = htonl(fids[i].vid);
2182− *bp++ = htonl(fids[i].vnode);
2183− *bp++ = htonl(fids[i].unique);
1942+ *bp++ = htonl(op->nr_files);
1943+ *bp++ = htonl(dvp->fid.vid);
1944+ *bp++ = htonl(dvp->fid.vnode);
1945+ *bp++ = htonl(dvp->fid.unique);
1946+ *bp++ = htonl(vp->fid.vid);
1947+ *bp++ = htonl(vp->fid.vnode);
1948+ *bp++ = htonl(vp->fid.unique);
1949+ for (i = 0; i < op->nr_files - 2; i++) {
1950+ *bp++ = htonl(op->more_files[i].fid.vid);
1951+ *bp++ = htonl(op->more_files[i].fid.vnode);
1952+ *bp++ = htonl(op->more_files[i].fid.unique);
21841953 }
21851954
2186− afs_use_fs_server(call, fc->cbi);
2187− trace_afs_make_fs_call(call, &fids[0]);
2188− afs_set_fc_call(call, fc);
2189− afs_make_call(&fc->ac, call, GFP_NOFS);
2190− return afs_wait_for_call_to_complete(call, &fc->ac);
1955+ trace_afs_make_fs_call(call, &vp->fid);
1956+ afs_make_op_call(op, call, GFP_NOFS);
21911957 }
21921958
21931959 /*
@@ -2195,6 +1961,8 @@ int afs_fs_inline_bulk_status(struct afs_fs_cursor *fc, · 1 unmodified line
21951961 */
21961962 static int afs_deliver_fs_fetch_acl(struct afs_call *call)
21971963 {
1964+ struct afs_operation *op = call->op;
1965+ struct afs_vnode_param *vp = &op->file[0];
21981966 struct afs_acl *acl;
21991967 const __be32 *bp;
22001968 unsigned int size;
@@ -2220,7 +1988,7 @@ static int afs_deliver_fs_fetch_acl(struct afs_call *call) · 19 unmodified lines
22201988 acl = kmalloc(struct_size(acl, data, size), GFP_KERNEL);
22211989 if (!acl)
22221990 return -ENOMEM;
2223− call->ret_acl = acl;
1991+ op->acl = acl;
22241992 acl->size = call->count2;
22251993 afs_extract_begin(call, acl->data, size);
22261994 call->unmarshall++;
@@ -2243,10 +2011,8 @@ static int afs_deliver_fs_fetch_acl(struct afs_call *call) · 16 unmodified lines
22432011 return ret;
22442012
22452013 bp = call->buffer;
2246− ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
2247− if (ret < 0)
2248− return ret;
2249− xdr_decode_AFSVolSync(&bp, call->out_volsync);
2014+ xdr_decode_AFSFetchStatus(&bp, call, &vp->scb);
2015+ xdr_decode_AFSVolSync(&bp, &op->volsync);
22502016
22512017 call->unmarshall++;
22522018
@@ -2258,12 +2024,6 @@ static int afs_deliver_fs_fetch_acl(struct afs_call *call) · 5 unmodified lines
22582024 return 0;
22592025 }
22602026
2261−static void afs_destroy_fs_fetch_acl(struct afs_call *call)
2262−{
2263− kfree(call->ret_acl);
2264− afs_flat_call_destructor(call);
2265−}
2266−
22672027 /*
22682028 * FS.FetchACL operation type
22692029 */
@@ -2271,68 +2031,33 @@ static const struct afs_call_type afs_RXFSFetchACL = { · 1 unmodified line
22712031 .name = "FS.FetchACL",
22722032 .op = afs_FS_FetchACL,
22732033 .deliver = afs_deliver_fs_fetch_acl,
2274− .destructor = afs_destroy_fs_fetch_acl,
22752034 };
22762035
22772036 /*
22782037 * Fetch the ACL for a file.
22792038 */
2280−struct afs_acl *afs_fs_fetch_acl(struct afs_fs_cursor *fc,
2281− struct afs_status_cb *scb)
2039+void afs_fs_fetch_acl(struct afs_operation *op)
22822040 {
2283− struct afs_vnode *vnode = fc->vnode;
2041+ struct afs_vnode_param *vp = &op->file[0];
22842042 struct afs_call *call;
2285− struct afs_net *net = afs_v2net(vnode);
22862043 __be32 *bp;
22872044
22882045 _enter(",%x,{%llx:%llu},,",
2289− key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
2046+ key_serial(op->key), vp->fid.vid, vp->fid.vnode);
22902047
2291− call = afs_alloc_flat_call(net, &afs_RXFSFetchACL, 16, (21 + 6) * 4);
2292− if (!call) {
2293− fc->ac.error = -ENOMEM;
2294− return ERR_PTR(-ENOMEM);
2295− }
2296−
2297− call->key = fc->key;
2298− call->ret_acl = NULL;
2299− call->out_scb = scb;
2300− call->out_volsync = NULL;
2048+ call = afs_alloc_flat_call(op->net, &afs_RXFSFetchACL, 16, (21 + 6) * 4);
2049+ if (!call)
2050+ return afs_op_nomem(op);
23012051
23022052 /* marshall the parameters */
23032053 bp = call->request;
23042054 bp[0] = htonl(FSFETCHACL);
2305− bp[1] = htonl(vnode->fid.vid);
2306− bp[2] = htonl(vnode->fid.vnode);
2307− bp[3] = htonl(vnode->fid.unique);
2308−
2309− afs_use_fs_server(call, fc->cbi);
2310− trace_afs_make_fs_call(call, &vnode->fid);
2311− afs_make_call(&fc->ac, call, GFP_KERNEL);
2312− return (struct afs_acl *)afs_wait_for_call_to_complete(call, &fc->ac);
2313−}
2314−
2315−/*
2316− * Deliver reply data to any operation that returns file status and volume
2317− * sync.
2318− */
2319−static int afs_deliver_fs_file_status_and_vol(struct afs_call *call)
2320−{
2321− const __be32 *bp;
2322− int ret;
2055+ bp[1] = htonl(vp->fid.vid);
2056+ bp[2] = htonl(vp->fid.vnode);
2057+ bp[3] = htonl(vp->fid.unique);
23232058
2324− ret = afs_transfer_reply(call);
2325− if (ret < 0)
2326− return ret;
2327−
2328− bp = call->buffer;
2329− ret = xdr_decode_AFSFetchStatus(&bp, call, call->out_scb);
2330− if (ret < 0)
2331− return ret;
2332− xdr_decode_AFSVolSync(&bp, call->out_volsync);
2333−
2334− _leave(" = 0 [done]");
2335− return 0;
2059+ trace_afs_make_fs_call(call, &vp->fid);
2060+ afs_make_op_call(op, call, GFP_KERNEL);
23362061 }
23372062
23382063 /*
@@ -2348,42 +2073,34 @@ static const struct afs_call_type afs_RXFSStoreACL = { · 9 unmodified lines
23482073 /*
23492074 * Fetch the ACL for a file.
23502075 */
2351−int afs_fs_store_acl(struct afs_fs_cursor *fc, const struct afs_acl *acl,
2352− struct afs_status_cb *scb)
2076+void afs_fs_store_acl(struct afs_operation *op)
23532077 {
2354− struct afs_vnode *vnode = fc->vnode;
2078+ struct afs_vnode_param *vp = &op->file[0];
23552079 struct afs_call *call;
2356− struct afs_net *net = afs_v2net(vnode);
2080+ const struct afs_acl *acl = op->acl;
23572081 size_t size;
23582082 __be32 *bp;
23592083
23602084 _enter(",%x,{%llx:%llu},,",
2361− key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
2085+ key_serial(op->key), vp->fid.vid, vp->fid.vnode);
23622086
23632087 size = round_up(acl->size, 4);
2364− call = afs_alloc_flat_call(net, &afs_RXFSStoreACL,
2088+ call = afs_alloc_flat_call(op->net, &afs_RXFSStoreACL,
23652089 5 * 4 + size, (21 + 6) * 4);
2366− if (!call) {
2367− fc->ac.error = -ENOMEM;
2368− return -ENOMEM;
2369− }
2370−
2371− call->key = fc->key;
2372− call->out_scb = scb;
2373− call->out_volsync = NULL;
2090+ if (!call)
2091+ return afs_op_nomem(op);
23742092
23752093 /* marshall the parameters */
23762094 bp = call->request;
23772095 bp[0] = htonl(FSSTOREACL);
2378− bp[1] = htonl(vnode->fid.vid);
2379− bp[2] = htonl(vnode->fid.vnode);
2380− bp[3] = htonl(vnode->fid.unique);
2096+ bp[1] = htonl(vp->fid.vid);
2097+ bp[2] = htonl(vp->fid.vnode);
2098+ bp[3] = htonl(vp->fid.unique);
23812099 bp[4] = htonl(acl->size);
23822100 memcpy(&bp[5], acl->data, acl->size);
23832101 if (acl->size != size)
23842102 memset((void *)&bp[5] + acl->size, 0, size - acl->size);
23852103
2386− trace_afs_make_fs_call(call, &vnode->fid);
2387− afs_make_call(&fc->ac, call, GFP_KERNEL);
2388− return afs_wait_for_call_to_complete(call, &fc->ac);
2104+ trace_afs_make_fs_call(call, &vp->fid);
2105+ afs_make_op_call(op, call, GFP_KERNEL);
23892106 }
fs/afs/inode.c+224−267
@@ -67,16 +67,18 @@ static void afs_set_i_size(struct afs_vnode *vnode, u64 size) · 66 unmodified lines
6767 /*
6868 * Initialise an inode from the vnode status.
6969 */
70−static int afs_inode_init_from_status(struct afs_vnode *vnode, struct key *key,
71− struct afs_cb_interest *cbi,
72− struct afs_vnode *parent_vnode,
73− struct afs_status_cb *scb)
70+static int afs_inode_init_from_status(struct afs_operation *op,
71+ struct afs_vnode_param *vp,
72+ struct afs_vnode *vnode)
7473 {
75− struct afs_cb_interest *old_cbi = NULL;
76− struct afs_file_status *status = &scb->status;
74+ struct afs_file_status *status = &vp->scb.status;
7775 struct inode *inode = AFS_VNODE_TO_I(vnode);
7876 struct timespec64 t;
7977
78+ _enter("{%llx:%llu.%u} %s",
79+ vp->fid.vid, vp->fid.vnode, vp->fid.unique,
80+ op->type ? op->type->name : "???");
81+
8082 _debug("FS: ft=%d lk=%d sz=%llu ver=%Lu mod=%hu",
8183 status->type,
8284 status->nlink,
@@ -86,12 +88,15 @@ static int afs_inode_init_from_status(struct afs_vnode *vnode, struct key *key, · 3 unmodified lines
8688
8789 write_seqlock(&vnode->cb_lock);
8890
91+ vnode->cb_v_break = op->cb_v_break;
92+ vnode->cb_s_break = op->cb_s_break;
8993 vnode->status = *status;
9094
9195 t = status->mtime_client;
9296 inode->i_ctime = t;
9397 inode->i_mtime = t;
9498 inode->i_atime = t;
99+ inode->i_flags |= S_NOATIME;
95100 inode->i_uid = make_kuid(&init_user_ns, status->owner);
96101 inode->i_gid = make_kgid(&init_user_ns, status->group);
97102 set_nlink(&vnode->vfs_inode, status->nlink);
@@ -128,9 +133,9 @@ static int afs_inode_init_from_status(struct afs_vnode *vnode, struct key *key, · 30 unmodified lines
128133 inode_nohighmem(inode);
129134 break;
130135 default:
131− dump_vnode(vnode, parent_vnode);
136+ dump_vnode(vnode, op->file[0].vnode != vnode ? op->file[0].vnode : NULL);
132137 write_sequnlock(&vnode->cb_lock);
133− return afs_protocol_error(NULL, -EBADMSG, afs_eproto_file_type);
138+ return afs_protocol_error(NULL, afs_eproto_file_type);
134139 }
135140
136141 afs_set_i_size(vnode, status->size);
@@ -138,39 +143,36 @@ static int afs_inode_init_from_status(struct afs_vnode *vnode, struct key *key, · 1 unmodified line
138143 vnode->invalid_before = status->data_version;
139144 inode_set_iversion_raw(&vnode->vfs_inode, status->data_version);
140145
141− if (!scb->have_cb) {
146+ if (!vp->scb.have_cb) {
142147 /* it's a symlink we just created (the fileserver
143148 * didn't give us a callback) */
144149 vnode->cb_expires_at = ktime_get_real_seconds();
145150 } else {
146− vnode->cb_expires_at = scb->callback.expires_at;
147− old_cbi = rcu_dereference_protected(vnode->cb_interest,
148− lockdep_is_held(&vnode->cb_lock.lock));
149− if (cbi != old_cbi)
150− rcu_assign_pointer(vnode->cb_interest, afs_get_cb_interest(cbi));
151− else
152− old_cbi = NULL;
151+ vnode->cb_expires_at = vp->scb.callback.expires_at;
152+ vnode->cb_server = op->server;
153153 set_bit(AFS_VNODE_CB_PROMISED, &vnode->flags);
154154 }
155155
156156 write_sequnlock(&vnode->cb_lock);
157− afs_put_cb_interest(afs_v2net(vnode), old_cbi);
158157 return 0;
159158 }
160159
161160 /*
162161 * Update the core inode struct from a returned status record.
163162 */
164−static void afs_apply_status(struct afs_fs_cursor *fc,
165− struct afs_vnode *vnode,
166− struct afs_status_cb *scb,
167− const afs_dataversion_t *expected_version)
163+static void afs_apply_status(struct afs_operation *op,
164+ struct afs_vnode_param *vp)
168165 {
169− struct afs_file_status *status = &scb->status;
166+ struct afs_file_status *status = &vp->scb.status;
167+ struct afs_vnode *vnode = vp->vnode;
170168 struct timespec64 t;
171169 umode_t mode;
172170 bool data_changed = false;
173171
172+ _enter("{%llx:%llu.%u} %s",
173+ vp->fid.vid, vp->fid.vnode, vp->fid.unique,
174+ op->type ? op->type->name : "???");
175+
174176 BUG_ON(test_bit(AFS_VNODE_UNSET, &vnode->flags));
175177
176178 if (status->type != vnode->status.type) {
@@ -179,7 +181,7 @@ static void afs_apply_status(struct afs_fs_cursor *fc, · 2 unmodified lines
179181 vnode->fid.vnode,
180182 vnode->fid.unique,
181183 status->type, vnode->status.type);
182− afs_protocol_error(NULL, -EBADMSG, afs_eproto_bad_status);
184+ afs_protocol_error(NULL, afs_eproto_bad_status);
183185 return;
184186 }
185187
@@ -209,14 +211,13 @@ static void afs_apply_status(struct afs_fs_cursor *fc, · 23 unmodified lines
209211
210212 vnode->status = *status;
211213
212− if (expected_version &&
213− *expected_version != status->data_version) {
214+ if (vp->dv_before + vp->dv_delta != status->data_version) {
214215 if (test_bit(AFS_VNODE_CB_PROMISED, &vnode->flags))
215216 pr_warn("kAFS: vnode modified {%llx:%llu} %llx->%llx %s\n",
216217 vnode->fid.vid, vnode->fid.vnode,
217− (unsigned long long)*expected_version,
218+ (unsigned long long)vp->dv_before + vp->dv_delta,
218219 (unsigned long long)status->data_version,
219− fc->type ? fc->type->name : "???");
220+ op->type ? op->type->name : "???");
220221
221222 vnode->invalid_before = status->data_version;
222223 if (vnode->status.type == AFS_FTYPE_DIR) {
@@ -243,22 +244,15 @@ static void afs_apply_status(struct afs_fs_cursor *fc, · 20 unmodified lines
243244 /*
244245 * Apply a callback to a vnode.
245246 */
246−static void afs_apply_callback(struct afs_fs_cursor *fc,
247− struct afs_vnode *vnode,
248− struct afs_status_cb *scb,
249− unsigned int cb_break)
247+static void afs_apply_callback(struct afs_operation *op,
248+ struct afs_vnode_param *vp)
250249 {
251− struct afs_cb_interest *old;
252− struct afs_callback *cb = &scb->callback;
250+ struct afs_callback *cb = &vp->scb.callback;
251+ struct afs_vnode *vnode = vp->vnode;
253252
254− if (!afs_cb_is_broken(cb_break, vnode, fc->cbi)) {
253+ if (!afs_cb_is_broken(vp->cb_break_before, vnode)) {
255254 vnode->cb_expires_at = cb->expires_at;
256− old = rcu_dereference_protected(vnode->cb_interest,
257− lockdep_is_held(&vnode->cb_lock.lock));
258− if (old != fc->cbi) {
259− rcu_assign_pointer(vnode->cb_interest, afs_get_cb_interest(fc->cbi));
260− afs_put_cb_interest(afs_v2net(vnode), old);
261− }
255+ vnode->cb_server = op->server;
262256 set_bit(AFS_VNODE_CB_PROMISED, &vnode->flags);
263257 }
264258 }
@@ -267,106 +261,108 @@ static void afs_apply_callback(struct afs_fs_cursor *fc, · 2 unmodified lines
267261 * Apply the received status and callback to an inode all in the same critical
268262 * section to avoid races with afs_validate().
269263 */
270−void afs_vnode_commit_status(struct afs_fs_cursor *fc,
271− struct afs_vnode *vnode,
272− unsigned int cb_break,
273− const afs_dataversion_t *expected_version,
274− struct afs_status_cb *scb)
264+void afs_vnode_commit_status(struct afs_operation *op, struct afs_vnode_param *vp)
275265 {
276− if (fc->ac.error != 0)
277− return;
266+ struct afs_vnode *vnode = vp->vnode;
267+
268+ _enter("");
269+
270+ ASSERTCMP(op->error, ==, 0);
278271
279272 write_seqlock(&vnode->cb_lock);
280273
281− if (scb->have_error) {
282− if (scb->status.abort_code == VNOVNODE) {
274+ if (vp->scb.have_error) {
275+ if (vp->scb.status.abort_code == VNOVNODE) {
283276 set_bit(AFS_VNODE_DELETED, &vnode->flags);
284277 clear_nlink(&vnode->vfs_inode);
285278 __afs_break_callback(vnode, afs_cb_break_for_deleted);
286279 }
287280 } else {
288− if (scb->have_status)
289− afs_apply_status(fc, vnode, scb, expected_version);
290− if (scb->have_cb)
291− afs_apply_callback(fc, vnode, scb, cb_break);
281+ if (vp->scb.have_status)
282+ afs_apply_status(op, vp);
283+ if (vp->scb.have_cb)
284+ afs_apply_callback(op, vp);
292285 }
293286
294287 write_sequnlock(&vnode->cb_lock);
295288
296− if (fc->ac.error == 0 && scb->have_status)
297− afs_cache_permit(vnode, fc->key, cb_break, scb);
289+ if (op->error == 0 && vp->scb.have_status)
290+ afs_cache_permit(vnode, op->key, vp->cb_break_before, &vp->scb);
298291 }
299292
293+static void afs_fetch_status_success(struct afs_operation *op)
294+{
295+ struct afs_vnode_param *vp = &op->file[0];
296+ struct afs_vnode *vnode = vp->vnode;
297+ int ret;
298+
299+ if (vnode->vfs_inode.i_state & I_NEW) {
300+ ret = afs_inode_init_from_status(op, vp, vnode);
301+ op->error = ret;
302+ if (ret == 0)
303+ afs_cache_permit(vnode, op->key, vp->cb_break_before, &vp->scb);
304+ } else {
305+ afs_vnode_commit_status(op, vp);
306+ }
307+}
308+
309+static const struct afs_operation_ops afs_fetch_status_operation = {
310+ .issue_afs_rpc = afs_fs_fetch_status,
311+ .issue_yfs_rpc = yfs_fs_fetch_status,
312+ .success = afs_fetch_status_success,
313+};
314+
300315 /*
301316 * Fetch file status from the volume.
302317 */
303318 int afs_fetch_status(struct afs_vnode *vnode, struct key *key, bool is_new,
304319 afs_access_t *_caller_access)
305320 {
306− struct afs_status_cb *scb;
307− struct afs_fs_cursor fc;
308− int ret;
321+ struct afs_operation *op;
309322
310323 _enter("%s,{%llx:%llu.%u,S=%lx}",
311324 vnode->volume->name,
312325 vnode->fid.vid, vnode->fid.vnode, vnode->fid.unique,
313326 vnode->flags);
314327
315− scb = kzalloc(sizeof(struct afs_status_cb), GFP_KERNEL);
316− if (!scb)
317− return -ENOMEM;
328+ op = afs_alloc_operation(key, vnode->volume);
329+ if (IS_ERR(op))
330+ return PTR_ERR(op);
318331
319− ret = -ERESTARTSYS;
320− if (afs_begin_vnode_operation(&fc, vnode, key, true)) {
321− afs_dataversion_t data_version = vnode->status.data_version;
332+ afs_op_set_vnode(op, 0, vnode);
322333
323− while (afs_select_fileserver(&fc)) {
324− fc.cb_break = afs_calc_vnode_cb_break(vnode);
325− afs_fs_fetch_file_status(&fc, scb, NULL);
326− }
327−
328− if (fc.error) {
329− /* Do nothing. */
330− } else if (is_new) {
331− ret = afs_inode_init_from_status(vnode, key, fc.cbi,
332− NULL, scb);
333− fc.error = ret;
334− if (ret == 0)
335− afs_cache_permit(vnode, key, fc.cb_break, scb);
336− } else {
337− afs_vnode_commit_status(&fc, vnode, fc.cb_break,
338− &data_version, scb);
339− }
340− afs_check_for_remote_deletion(&fc, vnode);
341− ret = afs_end_vnode_operation(&fc);
342− }
334+ op->nr_files = 1;
335+ op->ops = &afs_fetch_status_operation;
336+ afs_begin_vnode_operation(op);
337+ afs_wait_for_operation(op);
343338
344− if (ret == 0 && _caller_access)
345− *_caller_access = scb->status.caller_access;
346− kfree(scb);
347− _leave(" = %d", ret);
348− return ret;
339+ if (_caller_access)
340+ *_caller_access = op->file[0].scb.status.caller_access;
341+ return afs_put_operation(op);
349342 }
350343
351344 /*
352− * iget5() comparator
345+ * ilookup() comparator
353346 */
354−int afs_iget5_test(struct inode *inode, void *opaque)
347+int afs_ilookup5_test_by_fid(struct inode *inode, void *opaque)
355348 {
356− struct afs_iget_data *iget_data = opaque;
357349 struct afs_vnode *vnode = AFS_FS_I(inode);
350+ struct afs_fid *fid = opaque;
358351
359− return memcmp(&vnode->fid, &iget_data->fid, sizeof(iget_data->fid)) == 0;
352+ return (fid->vnode == vnode->fid.vnode &&
353+ fid->vnode_hi == vnode->fid.vnode_hi &&
354+ fid->unique == vnode->fid.unique);
360355 }
361356
362357 /*
363− * iget5() comparator for inode created by autocell operations
364− *
365− * These pseudo inodes don't match anything.
358+ * iget5() comparator
366359 */
367−static int afs_iget5_pseudo_dir_test(struct inode *inode, void *opaque)
360+static int afs_iget5_test(struct inode *inode, void *opaque)
368361 {
369− return 0;
362+ struct afs_vnode_param *vp = opaque;
363+ //struct afs_vnode *vnode = AFS_FS_I(inode);
364+
365+ return afs_ilookup5_test_by_fid(inode, &vp->fid);
370366 }
371367
372368 /*
@@ -374,98 +370,21 @@ static int afs_iget5_pseudo_dir_test(struct inode *inode, void *opaque) · 1 unmodified line
374370 */
375371 static int afs_iget5_set(struct inode *inode, void *opaque)
376372 {
377− struct afs_iget_data *iget_data = opaque;
373+ struct afs_vnode_param *vp = opaque;
374+ struct afs_super_info *as = AFS_FS_S(inode->i_sb);
378375 struct afs_vnode *vnode = AFS_FS_I(inode);
379376
380− vnode->fid = iget_data->fid;
381− vnode->volume = iget_data->volume;
382− vnode->cb_v_break = iget_data->cb_v_break;
383− vnode->cb_s_break = iget_data->cb_s_break;
377+ vnode->volume = as->volume;
378+ vnode->fid = vp->fid;
384379
385380 /* YFS supports 96-bit vnode IDs, but Linux only supports
386381 * 64-bit inode numbers.
387382 */
388− inode->i_ino = iget_data->fid.vnode;
389− inode->i_generation = iget_data->fid.unique;
383+ inode->i_ino = vnode->fid.vnode;
384+ inode->i_generation = vnode->fid.unique;
390385 return 0;
391386 }
392387
393−/*
394− * Create an inode for a dynamic root directory or an autocell dynamic
395− * automount dir.
396− */
397−struct inode *afs_iget_pseudo_dir(struct super_block *sb, bool root)
398−{
399− struct afs_super_info *as;
400− struct afs_vnode *vnode;
401− struct inode *inode;
402− static atomic_t afs_autocell_ino;
403−
404− struct afs_iget_data iget_data = {
405− .cb_v_break = 0,
406− .cb_s_break = 0,
407− };
408−
409− _enter("");
410−
411− as = sb->s_fs_info;
412− if (as->volume) {
413− iget_data.volume = as->volume;
414− iget_data.fid.vid = as->volume->vid;
415− }
416− if (root) {
417− iget_data.fid.vnode = 1;
418− iget_data.fid.unique = 1;
419− } else {
420− iget_data.fid.vnode = atomic_inc_return(&afs_autocell_ino);
421− iget_data.fid.unique = 0;
422− }
423−
424− inode = iget5_locked(sb, iget_data.fid.vnode,
425− afs_iget5_pseudo_dir_test, afs_iget5_set,
426− &iget_data);
427− if (!inode) {
428− _leave(" = -ENOMEM");
429− return ERR_PTR(-ENOMEM);
430− }
431−
432− _debug("GOT INODE %p { ino=%lu, vl=%llx, vn=%llx, u=%x }",
433− inode, inode->i_ino, iget_data.fid.vid, iget_data.fid.vnode,
434− iget_data.fid.unique);
435−
436− vnode = AFS_FS_I(inode);
437−
438− /* there shouldn't be an existing inode */
439− BUG_ON(!(inode->i_state & I_NEW));
440−
441− inode->i_size = 0;
442− inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO;
443− if (root) {
444− inode->i_op = &afs_dynroot_inode_operations;
445− inode->i_fop = &simple_dir_operations;
446− } else {
447− inode->i_op = &afs_autocell_inode_operations;
448− }
449− set_nlink(inode, 2);
450− inode->i_uid = GLOBAL_ROOT_UID;
451− inode->i_gid = GLOBAL_ROOT_GID;
452− inode->i_ctime = inode->i_atime = inode->i_mtime = current_time(inode);
453− inode->i_blocks = 0;
454− inode_set_iversion_raw(inode, 0);
455− inode->i_generation = 0;
456−
457− set_bit(AFS_VNODE_PSEUDODIR, &vnode->flags);
458− if (!root) {
459− set_bit(AFS_VNODE_MOUNTPOINT, &vnode->flags);
460− inode->i_flags |= S_AUTOMOUNT;
461− }
462−
463− inode->i_flags |= S_NOATIME;
464− unlock_new_inode(inode);
465− _leave(" = %p", inode);
466− return inode;
467−}
468−
469388 /*
470389 * Get a cache cookie for an inode.
471390 */
@@ -501,58 +420,41 @@ static void afs_get_inode_cache(struct afs_vnode *vnode) · 29 unmodified lines
501420 /*
502421 * inode retrieval
503422 */
504−struct inode *afs_iget(struct super_block *sb, struct key *key,
505− struct afs_iget_data *iget_data,
506− struct afs_status_cb *scb,
507− struct afs_cb_interest *cbi,
508− struct afs_vnode *parent_vnode)
423+struct inode *afs_iget(struct afs_operation *op, struct afs_vnode_param *vp)
509424 {
510− struct afs_super_info *as;
425+ struct afs_vnode_param *dvp = &op->file[0];
426+ struct super_block *sb = dvp->vnode->vfs_inode.i_sb;
511427 struct afs_vnode *vnode;
512− struct afs_fid *fid = &iget_data->fid;
513428 struct inode *inode;
514429 int ret;
515430
516− _enter(",{%llx:%llu.%u},,", fid->vid, fid->vnode, fid->unique);
431+ _enter(",{%llx:%llu.%u},,", vp->fid.vid, vp->fid.vnode, vp->fid.unique);
517432
518− as = sb->s_fs_info;
519− iget_data->volume = as->volume;
520−
521− inode = iget5_locked(sb, fid->vnode, afs_iget5_test, afs_iget5_set,
522− iget_data);
433+ inode = iget5_locked(sb, vp->fid.vnode, afs_iget5_test, afs_iget5_set, vp);
523434 if (!inode) {
524435 _leave(" = -ENOMEM");
525436 return ERR_PTR(-ENOMEM);
526437 }
527438
528− _debug("GOT INODE %p { vl=%llx vn=%llx, u=%x }",
529− inode, fid->vid, fid->vnode, fid->unique);
530−
531439 vnode = AFS_FS_I(inode);
532440
441+ _debug("GOT INODE %p { vl=%llx vn=%llx, u=%x }",
442+ inode, vnode->fid.vid, vnode->fid.vnode, vnode->fid.unique);
443+
533444 /* deal with an existing inode */
534445 if (!(inode->i_state & I_NEW)) {
535446 _leave(" = %p", inode);
536447 return inode;
537448 }
538449
539− if (!scb) {
540− /* it's a remotely extant inode */
541− ret = afs_fetch_status(vnode, key, true, NULL);
542− if (ret < 0)
543− goto bad_inode;
544− } else {
545− ret = afs_inode_init_from_status(vnode, key, cbi, parent_vnode,
546− scb);
547− if (ret < 0)
548− goto bad_inode;
549− }
450+ ret = afs_inode_init_from_status(op, vp, vnode);
451+ if (ret < 0)
452+ goto bad_inode;
550453
551454 afs_get_inode_cache(vnode);
552455
553456 /* success */
554457 clear_bit(AFS_VNODE_UNSET, &vnode->flags);
555− inode->i_flags |= S_NOATIME;
556458 unlock_new_inode(inode);
557459 _leave(" = %p", inode);
558460 return inode;
@@ -564,6 +466,74 @@ bad_inode: · 5 unmodified lines
564466 return ERR_PTR(ret);
565467 }
566468
469+static int afs_iget5_set_root(struct inode *inode, void *opaque)
470+{
471+ struct afs_super_info *as = AFS_FS_S(inode->i_sb);
472+ struct afs_vnode *vnode = AFS_FS_I(inode);
473+
474+ vnode->volume = as->volume;
475+ vnode->fid.vid = as->volume->vid,
476+ vnode->fid.vnode = 1;
477+ vnode->fid.unique = 1;
478+ inode->i_ino = 1;
479+ inode->i_generation = 1;
480+ return 0;
481+}
482+
483+/*
484+ * Set up the root inode for a volume. This is always vnode 1, unique 1 within
485+ * the volume.
486+ */
487+struct inode *afs_root_iget(struct super_block *sb, struct key *key)
488+{
489+ struct afs_super_info *as = AFS_FS_S(sb);
490+ struct afs_operation *op;
491+ struct afs_vnode *vnode;
492+ struct inode *inode;
493+ int ret;
494+
495+ _enter(",{%llx},,", as->volume->vid);
496+
497+ inode = iget5_locked(sb, 1, NULL, afs_iget5_set_root, NULL);
498+ if (!inode) {
499+ _leave(" = -ENOMEM");
500+ return ERR_PTR(-ENOMEM);
501+ }
502+
503+ _debug("GOT ROOT INODE %p { vl=%llx }", inode, as->volume->vid);
504+
505+ BUG_ON(!(inode->i_state & I_NEW));
506+
507+ vnode = AFS_FS_I(inode);
508+ vnode->cb_v_break = as->volume->cb_v_break,
509+
510+ op = afs_alloc_operation(key, as->volume);
511+ if (IS_ERR(op)) {
512+ ret = PTR_ERR(op);
513+ goto error;
514+ }
515+
516+ afs_op_set_vnode(op, 0, vnode);
517+
518+ op->nr_files = 1;
519+ op->ops = &afs_fetch_status_operation;
520+ ret = afs_do_sync_operation(op);
521+ if (ret < 0)
522+ goto error;
523+
524+ afs_get_inode_cache(vnode);
525+
526+ clear_bit(AFS_VNODE_UNSET, &vnode->flags);
527+ unlock_new_inode(inode);
528+ _leave(" = %p", inode);
529+ return inode;
530+
531+error:
532+ iget_failed(inode);
533+ _leave(" = %d [bad]", ret);
534+ return ERR_PTR(ret);
535+}
536+
567537 /*
568538 * mark the data attached to an inode as obsolete due to a write on the server
569539 * - might also want to ditch all the outstanding writes and dirty pages
@@ -585,13 +555,31 @@ void afs_zap_data(struct afs_vnode *vnode) · 15 unmodified lines
585555 invalidate_inode_pages2(vnode->vfs_inode.i_mapping);
586556 }
587557
558+/*
559+ * Get the server reinit counter for a vnode's current server.
560+ */
561+static bool afs_get_s_break_rcu(struct afs_vnode *vnode, unsigned int *_s_break)
562+{
563+ struct afs_server_list *slist = rcu_dereference(vnode->volume->servers);
564+ struct afs_server *server;
565+ int i;
566+
567+ for (i = 0; i < slist->nr_servers; i++) {
568+ server = slist->servers[i].server;
569+ if (server == vnode->cb_server) {
570+ *_s_break = READ_ONCE(server->cb_s_break);
571+ return true;
572+ }
573+ }
574+
575+ return false;
576+}
577+
588578 /*
589579 * Check the validity of a vnode/inode.
590580 */
591581 bool afs_check_validity(struct afs_vnode *vnode)
592582 {
593− struct afs_cb_interest *cbi;
594− struct afs_server *server;
595583 struct afs_volume *volume = vnode->volume;
596584 enum afs_cb_break_reason need_clear = afs_cb_break_no_break;
597585 time64_t now = ktime_get_real_seconds();
@@ -604,11 +592,8 @@ bool afs_check_validity(struct afs_vnode *vnode) · 6 unmodified lines
604592 cb_v_break = READ_ONCE(volume->cb_v_break);
605593 cb_break = vnode->cb_break;
606594
607− if (test_bit(AFS_VNODE_CB_PROMISED, &vnode->flags)) {
608− cbi = rcu_dereference(vnode->cb_interest);
609− server = rcu_dereference(cbi->server);
610− cb_s_break = READ_ONCE(server->cb_s_break);
611−
595+ if (test_bit(AFS_VNODE_CB_PROMISED, &vnode->flags) &&
596+ afs_get_s_break_rcu(vnode, &cb_s_break)) {
612597 if (vnode->cb_s_break != cb_s_break ||
613598 vnode->cb_v_break != cb_v_break) {
614599 vnode->cb_s_break = cb_s_break;
@@ -755,7 +740,6 @@ int afs_drop_inode(struct inode *inode) · 140 unmodified lines
755740 */
756741 void afs_evict_inode(struct inode *inode)
757742 {
758− struct afs_cb_interest *cbi;
759743 struct afs_vnode *vnode;
760744
761745 vnode = AFS_FS_I(inode);
@@ -772,15 +756,6 @@ void afs_evict_inode(struct inode *inode) · 10 unmodified lines
772756 truncate_inode_pages_final(&inode->i_data);
773757 clear_inode(inode);
774758
775− write_seqlock(&vnode->cb_lock);
776− cbi = rcu_dereference_protected(vnode->cb_interest,
777− lockdep_is_held(&vnode->cb_lock.lock));
778− if (cbi) {
779− afs_put_cb_interest(afs_i2net(inode), cbi);
780− rcu_assign_pointer(vnode->cb_interest, NULL);
781− }
782− write_sequnlock(&vnode->cb_lock);
783−
784759 while (!list_empty(&vnode->wb_keys)) {
785760 struct afs_wb_key *wbk = list_entry(vnode->wb_keys.next,
786761 struct afs_wb_key, vnode_link);
@@ -808,16 +783,24 @@ void afs_evict_inode(struct inode *inode) · 21 unmodified lines
808783 _leave("");
809784 }
810785
786+static void afs_setattr_success(struct afs_operation *op)
787+{
788+ afs_vnode_commit_status(op, &op->file[0]);
789+}
790+
791+static const struct afs_operation_ops afs_setattr_operation = {
792+ .issue_afs_rpc = afs_fs_setattr,
793+ .issue_yfs_rpc = yfs_fs_setattr,
794+ .success = afs_setattr_success,
795+};
796+
811797 /*
812798 * set the attributes of an inode
813799 */
814800 int afs_setattr(struct dentry *dentry, struct iattr *attr)
815801 {
816− struct afs_fs_cursor fc;
817− struct afs_status_cb *scb;
802+ struct afs_operation *op;
818803 struct afs_vnode *vnode = AFS_FS_I(d_inode(dentry));
819− struct key *key;
820− int ret = -ENOMEM;
821804
822805 _enter("{%llx:%llu},{n=%pd},%x",
823806 vnode->fid.vid, vnode->fid.vnode, dentry,
@@ -829,48 +812,22 @@ int afs_setattr(struct dentry *dentry, struct iattr *attr) · 5 unmodified lines
829812 return 0;
830813 }
831814
832− scb = kzalloc(sizeof(struct afs_status_cb), GFP_KERNEL);
833− if (!scb)
834− goto error;
835−
836815 /* flush any dirty data outstanding on a regular file */
837816 if (S_ISREG(vnode->vfs_inode.i_mode))
838817 filemap_write_and_wait(vnode->vfs_inode.i_mapping);
839818
840− if (attr->ia_valid & ATTR_FILE) {
841− key = afs_file_key(attr->ia_file);
842− } else {
843− key = afs_request_key(vnode->volume->cell);
844− if (IS_ERR(key)) {
845− ret = PTR_ERR(key);
846− goto error_scb;
847− }
848− }
849−
850− ret = -ERESTARTSYS;
851− if (afs_begin_vnode_operation(&fc, vnode, key, false)) {
852− afs_dataversion_t data_version = vnode->status.data_version;
819+ op = afs_alloc_operation(((attr->ia_valid & ATTR_FILE) ?
820+ afs_file_key(attr->ia_file) : NULL),
821+ vnode->volume);
822+ if (IS_ERR(op))
823+ return PTR_ERR(op);
853824
854− if (attr->ia_valid & ATTR_SIZE)
855− data_version++;
825+ afs_op_set_vnode(op, 0, vnode);
826+ op->setattr.attr = attr;
856827
857− while (afs_select_fileserver(&fc)) {
858− fc.cb_break = afs_calc_vnode_cb_break(vnode);
859− afs_fs_setattr(&fc, attr, scb);
860− }
861−
862− afs_check_for_remote_deletion(&fc, vnode);
863− afs_vnode_commit_status(&fc, vnode, fc.cb_break,
864− &data_version, scb);
865− ret = afs_end_vnode_operation(&fc);
866− }
828+ if (attr->ia_valid & ATTR_SIZE)
829+ op->file[0].dv_delta = 1;
867830
868− if (!(attr->ia_valid & ATTR_FILE))
869− key_put(key);
870−
871−error_scb:
872− kfree(scb);
873−error:
874− _leave(" = %d", ret);
875− return ret;
831+ op->ops = &afs_setattr_operation;
832+ return afs_do_sync_operation(op);
876833 }
fs/afs/internal.h+299−224
@@ -59,13 +59,6 @@ struct afs_fs_context { · 58 unmodified lines
5959 struct key *key; /* key to use for secure mounting */
6060 };
6161
62−struct afs_iget_data {
63− struct afs_fid fid;
64− struct afs_volume *volume; /* volume on which resides */
65− unsigned int cb_v_break; /* Pre-fetch volume break count */
66− unsigned int cb_s_break; /* Pre-fetch server break count */
67−};
68−
6962 enum afs_call_state {
7063 AFS_CALL_CL_REQUESTING, /* Client: Request is being sent */
7164 AFS_CALL_CL_AWAIT_REPLY, /* Client: Awaiting reply */
@@ -90,7 +83,6 @@ struct afs_addr_list { · 18 unmodified lines
9083 unsigned char nr_ipv4; /* Number of IPv4 addresses */
9184 enum dns_record_source source:8;
9285 enum dns_lookup_status status:8;
93− unsigned long probed; /* Mask of servers that have been probed */
9486 unsigned long failed; /* Mask of addrs that failed locally/ICMP */
9587 unsigned long responded; /* Mask of addrs that responded */
9688 struct sockaddr_rxrpc addrs[];
@@ -111,10 +103,7 @@ struct afs_call { · 14 unmodified lines
111103 struct afs_net *net; /* The network namespace */
112104 struct afs_server *server; /* The fileserver record if fs op (pins ref) */
113105 struct afs_vlserver *vlserver; /* The vlserver record if vl op */
114− struct afs_cb_interest *cbi; /* Callback interest for server used */
115− struct afs_vnode *lvnode; /* vnode being locked */
116106 void *request; /* request data (first part) */
117− struct address_space *mapping; /* Pages being written from */
118107 struct iov_iter def_iter; /* Default buffer/data iterator */
119108 struct iov_iter *iter; /* Iterator currently in use */
120109 union { /* Convenience for ->def_iter */
@@ -126,32 +115,19 @@ struct afs_call { · 5 unmodified lines
126115 long ret0; /* Value to reply with instead of 0 */
127116 struct afs_addr_list *ret_alist;
128117 struct afs_vldb_entry *ret_vldb;
129− struct afs_acl *ret_acl;
118+ char *ret_str;
130119 };
131− struct afs_fid *out_fid;
132− struct afs_status_cb *out_dir_scb;
133− struct afs_status_cb *out_scb;
134− struct yfs_acl *out_yacl;
135− struct afs_volsync *out_volsync;
136− struct afs_volume_status *out_volstatus;
137− struct afs_read *read_request;
120+ struct afs_operation *op;
138121 unsigned int server_index;
139− pgoff_t first; /* first page in mapping to deal with */
140− pgoff_t last; /* last page in mapping to deal with */
141122 atomic_t usage;
142123 enum afs_call_state state;
143124 spinlock_t state_lock;
144125 int error; /* error code */
145126 u32 abort_code; /* Remote abort ID or 0 */
146− u32 epoch;
147127 unsigned int max_lifespan; /* Maximum lifespan to set if not 0 */
148128 unsigned request_size; /* size of request data */
149129 unsigned reply_max; /* maximum size of reply */
150− unsigned first_offset; /* offset into mapping[first] */
151− union {
152− unsigned last_to; /* amount of mapping[last] */
153− unsigned count2; /* count used in unmarshalling */
154− };
130+ unsigned count2; /* count used in unmarshalling */
155131 unsigned char unmarshall; /* unmarshalling phase */
156132 unsigned char addr_ix; /* Address in ->alist */
157133 bool drop_ref; /* T if need to drop ref for incoming call */
@@ -161,6 +137,7 @@ struct afs_call { · 3 unmodified lines
161137 bool upgrade; /* T to request service upgrade */
162138 bool have_reply_time; /* T if have got reply_time */
163139 bool intr; /* T if interruptible */
140+ bool unmarshalling_error; /* T if an unmarshalling error occurred */
164141 u16 service_id; /* Actual service ID (after upgrade) */
165142 unsigned int debug_id; /* Trace ID */
166143 u32 operation_ID; /* operation ID for an incoming call */
@@ -291,6 +268,7 @@ struct afs_net { · 124 unmodified lines
291268 struct timer_list cells_timer;
292269 atomic_t cells_outstanding;
293270 seqlock_t cells_lock;
271+ struct mutex cells_alias_lock;
294272
295273 struct mutex proc_cells_lock;
296274 struct hlist_head proc_cells;
@@ -299,9 +277,10 @@ struct afs_net { · 2 unmodified lines
299277 * cell, but in practice, people create aliases and subsets and there's
300278 * no easy way to distinguish them.
301279 */
302− seqlock_t fs_lock; /* For fs_servers */
280+ seqlock_t fs_lock; /* For fs_servers, fs_probe_*, fs_proc */
303281 struct rb_root fs_servers; /* afs_server (by server UUID or address) */
304− struct list_head fs_updates; /* afs_server (by update_at) */
282+ struct list_head fs_probe_fast; /* List of afs_server to probe at 30s intervals */
283+ struct list_head fs_probe_slow; /* List of afs_server to probe at 5m intervals */
305284 struct hlist_head fs_proc; /* procfs servers list */
306285
307286 struct hlist_head fs_addresses4; /* afs_server (by lowest IPv4 addr) */
@@ -310,6 +289,9 @@ struct afs_net { · 2 unmodified lines
310289
311290 struct work_struct fs_manager;
312291 struct timer_list fs_timer;
292+
293+ struct work_struct fs_prober;
294+ struct timer_list fs_probe_timer;
313295 atomic_t servers_outstanding;
314296
315297 /* File locking renewal management */
@@ -360,8 +342,10 @@ enum afs_cell_state { · 44 unmodified lines
360342 * for authentication and encryption. The cell name is not typically used in
361343 * the protocol.
362344 *
363− * There is no easy way to determine if two cells are aliases or one is a
364− * subset of another.
345+ * Two cells are determined to be aliases if they have an explicit alias (YFS
346+ * only), share any VL servers in common or have at least one volume in common.
347+ * "In common" means that the address list of the VL servers or the fileservers
348+ * share at least one endpoint.
365349 */
366350 struct afs_cell {
367351 union {
@@ -369,6 +353,8 @@ struct afs_cell { · 1 unmodified line
369353 struct rb_node net_node; /* Node in net->cells */
370354 };
371355 struct afs_net *net;
356+ struct afs_cell *alias_of; /* The cell this is an alias of */
357+ struct afs_volume *root_volume; /* The root.cell volume if there is one */
372358 struct key *anonymous_key; /* anonymous user key for this cell */
373359 struct work_struct manager; /* Manager for init/deinit/dns */
374360 struct hlist_node proc_link; /* /proc cell list link */
@@ -381,15 +367,21 @@ struct afs_cell { · 6 unmodified lines
381367 unsigned long flags;
382368 #define AFS_CELL_FL_NO_GC 0 /* The cell was added manually, don't auto-gc */
383369 #define AFS_CELL_FL_DO_LOOKUP 1 /* DNS lookup requested */
370+#define AFS_CELL_FL_CHECK_ALIAS 2 /* Need to check for aliases */
384371 enum afs_cell_state state;
385372 short error;
386373 enum dns_record_source dns_source:8; /* Latest source of data from lookup */
387374 enum dns_lookup_status dns_status:8; /* Latest status of data from lookup */
388375 unsigned int dns_lookup_count; /* Counter of DNS lookups */
389376
377+ /* The volumes belonging to this cell */
378+ struct rb_root volumes; /* Tree of volumes on this server */
379+ struct hlist_head proc_volumes; /* procfs volume list */
380+ seqlock_t volume_lock; /* For volumes */
381+
390382 /* Active fileserver interaction state. */
391− struct list_head proc_volumes; /* procfs volume list */
392− rwlock_t proc_lock;
383+ struct rb_root fs_servers; /* afs_server (by server UUID) */
384+ seqlock_t fs_lock; /* For fs_servers */
393385
394386 /* VL server list. */
395387 rwlock_t vl_servers_lock; /* Lock on vl_servers */
@@ -471,6 +463,7 @@ struct afs_vldb_entry { · 75 unmodified lines
471463 #define AFS_VLDB_QUERY_ERROR 4 /* - VL server returned error */
472464
473465 uuid_t fs_server[AFS_NMAXNSERVERS];
466+ u32 addr_version[AFS_NMAXNSERVERS]; /* Registration change counters */
474467 u8 fs_mask[AFS_NMAXNSERVERS];
475468 #define AFS_VOL_VTM_RW 0x01 /* R/W version of the volume is available (on this server) */
476469 #define AFS_VOL_VTM_RO 0x02 /* R/O version of the volume is available (on this server) */
@@ -492,94 +485,64 @@ struct afs_server { · 15 unmodified lines
492485 };
493486
494487 struct afs_addr_list __rcu *addresses;
495− struct rb_node uuid_rb; /* Link in net->servers */
488+ struct afs_cell *cell; /* Cell to which belongs (pins ref) */
489+ struct rb_node uuid_rb; /* Link in net->fs_servers */
490+ struct afs_server __rcu *uuid_next; /* Next server with same UUID */
491+ struct afs_server *uuid_prev; /* Previous server with same UUID */
492+ struct list_head probe_link; /* Link in net->fs_probe_list */
496493 struct hlist_node addr4_link; /* Link in net->fs_addresses4 */
497494 struct hlist_node addr6_link; /* Link in net->fs_addresses6 */
498495 struct hlist_node proc_link; /* Link in net->fs_proc */
499496 struct afs_server *gc_next; /* Next server in manager's list */
500− time64_t put_time; /* Time at which last put */
501− time64_t update_at; /* Time at which to next update the record */
497+ time64_t unuse_time; /* Time at which last unused */
502498 unsigned long flags;
503−#define AFS_SERVER_FL_NOT_READY 1 /* The record is not ready for use */
504−#define AFS_SERVER_FL_NOT_FOUND 2 /* VL server says no such server */
505−#define AFS_SERVER_FL_VL_FAIL 3 /* Failed to access VL server */
506−#define AFS_SERVER_FL_UPDATING 4
507−#define AFS_SERVER_FL_PROBED 5 /* The fileserver has been probed */
508−#define AFS_SERVER_FL_PROBING 6 /* Fileserver is being probed */
509−#define AFS_SERVER_FL_NO_IBULK 7 /* Fileserver doesn't support FS.InlineBulkStatus */
499+#define AFS_SERVER_FL_RESPONDING 0 /* The server is responding */
500+#define AFS_SERVER_FL_UPDATING 1
501+#define AFS_SERVER_FL_NEEDS_UPDATE 2 /* Fileserver address list is out of date */
502+#define AFS_SERVER_FL_NOT_READY 4 /* The record is not ready for use */
503+#define AFS_SERVER_FL_NOT_FOUND 5 /* VL server says no such server */
504+#define AFS_SERVER_FL_VL_FAIL 6 /* Failed to access VL server */
510505 #define AFS_SERVER_FL_MAY_HAVE_CB 8 /* May have callbacks on this fileserver */
511−#define AFS_SERVER_FL_IS_YFS 9 /* Server is YFS not AFS */
512−#define AFS_SERVER_FL_NO_RM2 10 /* Fileserver doesn't support YFS.RemoveFile2 */
513−#define AFS_SERVER_FL_HAVE_EPOCH 11 /* ->epoch is valid */
514− atomic_t usage;
506+#define AFS_SERVER_FL_IS_YFS 16 /* Server is YFS not AFS */
507+#define AFS_SERVER_FL_NO_IBULK 17 /* Fileserver doesn't support FS.InlineBulkStatus */
508+#define AFS_SERVER_FL_NO_RM2 18 /* Fileserver doesn't support YFS.RemoveFile2 */
509+ atomic_t ref; /* Object refcount */
510+ atomic_t active; /* Active user count */
515511 u32 addr_version; /* Address list version */
516− u32 cm_epoch; /* Server RxRPC epoch */
512+ unsigned int rtt; /* Server's current RTT in uS */
517513 unsigned int debug_id; /* Debugging ID for traces */
518514
519515 /* file service access */
520516 rwlock_t fs_lock; /* access lock */
521517
522518 /* callback promise management */
523− struct hlist_head cb_volumes; /* List of volume interests on this server */
524519 unsigned cb_s_break; /* Break-everything counter. */
525− rwlock_t cb_break_lock; /* Volume finding lock */
526520
527521 /* Probe state */
522+ unsigned long probed_at; /* Time last probe was dispatched (jiffies) */
528523 wait_queue_head_t probe_wq;
529524 atomic_t probe_outstanding;
530525 spinlock_t probe_lock;
531526 struct {
532− unsigned int rtt; /* RTT as ktime/64 */
527+ unsigned int rtt; /* RTT in uS */
533528 u32 abort_code;
534− u32 cm_epoch;
535529 short error;
536530 bool responded:1;
537531 bool is_yfs:1;
538532 bool not_yfs:1;
539533 bool local_failure:1;
540− bool cm_probed:1;
541− bool said_rebooted:1;
542− bool said_inconsistent:1;
543534 } probe;
544535 };
545536
546537 /*
547− * Volume collation in the server's callback interest list.
548− */
549−struct afs_vol_interest {
550− struct hlist_node srv_link; /* Link in server->cb_volumes */
551− struct hlist_head cb_interests; /* List of callback interests on the server */
552− union {
553− struct rcu_head rcu;
554− afs_volid_t vid; /* Volume ID to match */
555− };
556− unsigned int usage;
557−};
558−
559−/*
560− * Interest by a superblock on a server.
561− */
562−struct afs_cb_interest {
563− struct hlist_node cb_vlink; /* Link in vol_interest->cb_interests */
564− struct afs_vol_interest *vol_interest;
565− struct afs_server *server; /* Server on which this interest resides */
566− struct super_block *sb; /* Superblock on which inodes reside */
567− union {
568− struct rcu_head rcu;
569− afs_volid_t vid; /* Volume ID to match */
570− };
571− refcount_t usage;
572−};
573−
574−/*
575− * Replaceable server list.
538+ * Replaceable volume server list.
576539 */
577540 struct afs_server_entry {
578541 struct afs_server *server;
579− struct afs_cb_interest *cb_interest;
580542 };
581543
582544 struct afs_server_list {
545+ afs_volid_t vids[AFS_MAXTYPES]; /* Volume IDs */
583546 refcount_t usage;
584547 unsigned char nr_servers;
585548 unsigned char preferred; /* Preferred server */
@@ -593,11 +556,16 @@ struct afs_server_list { · 7 unmodified lines
593556 * Live AFS volume management.
594557 */
595558 struct afs_volume {
596− afs_volid_t vid; /* volume ID */
559+ union {
560+ struct rcu_head rcu;
561+ afs_volid_t vid; /* volume ID */
562+ };
597563 atomic_t usage;
598564 time64_t update_at; /* Time at which to next update */
599565 struct afs_cell *cell; /* Cell to which belongs (pins ref) */
600− struct list_head proc_link; /* Link in cell->vl_proc */
566+ struct rb_node cell_node; /* Link in cell->volumes */
567+ struct hlist_node proc_link; /* Link in cell->proc_volumes */
568+ struct super_block __rcu *sb; /* Superblock on which inodes reside */
601569 unsigned long flags;
602570 #define AFS_VOLUME_NEEDS_UPDATE 0 /* - T if an update needs performing */
603571 #define AFS_VOLUME_UPDATING 1 /* - T if an update is in progress */
@@ -605,10 +573,11 @@ struct afs_volume { · 1 unmodified line
605573 #define AFS_VOLUME_DELETED 3 /* - T if volume appears deleted */
606574 #define AFS_VOLUME_OFFLINE 4 /* - T if volume offline notice given */
607575 #define AFS_VOLUME_BUSY 5 /* - T if volume busy notice given */
576+#define AFS_VOLUME_MAYBE_NO_IBULK 6 /* - T if some servers don't have InlineBulkStatus */
608577 #ifdef CONFIG_AFS_FSCACHE
609578 struct fscache_cookie *cache; /* caching cookie */
610579 #endif
611− struct afs_server_list *servers; /* List of servers on which volume resides */
580+ struct afs_server_list __rcu *servers; /* List of servers on which volume resides */
612581 rwlock_t servers_lock; /* Lock for ->servers */
613582 unsigned int servers_seq; /* Incremented each time ->servers changes */
614583
@@ -616,7 +585,6 @@ struct afs_volume { · 1 unmodified line
616585 rwlock_t cb_v_break_lock;
617586
618587 afs_voltype_t type; /* type of volume */
619− short error;
620588 char type_force; /* force volume type (suppress R/O -> R/W) */
621589 u8 name_len;
622590 u8 name[AFS_MAXVOLNAME + 1]; /* NUL-padded volume name */
@@ -677,11 +645,11 @@ struct afs_vnode { · 54 unmodified lines
677645 afs_lock_type_t lock_type : 8;
678646
679647 /* outstanding callback notification on this file */
680− struct afs_cb_interest __rcu *cb_interest; /* Server on which this resides */
648+ void *cb_server; /* Server with callback/filelock */
681649 unsigned int cb_s_break; /* Mass break counter on ->server */
682650 unsigned int cb_v_break; /* Mass break counter on ->volume */
683651 unsigned int cb_break; /* Break counter on vnode */
684− seqlock_t cb_lock; /* Lock for ->cb_interest, ->status, ->cb_*break */
652+ seqlock_t cb_lock; /* Lock for ->cb_server, ->status, ->cb_*break */
685653
686654 time64_t cb_expires_at; /* time at which callback expires */
687655 };
@@ -758,29 +726,118 @@ struct afs_vl_cursor { · 70 unmodified lines
758726 };
759727
760728 /*
761− * Cursor for iterating over a set of fileservers.
729+ * Fileserver operation methods.
730+ */
731+struct afs_operation_ops {
732+ void (*issue_afs_rpc)(struct afs_operation *op);
733+ void (*issue_yfs_rpc)(struct afs_operation *op);
734+ void (*success)(struct afs_operation *op);
735+ void (*aborted)(struct afs_operation *op);
736+ void (*edit_dir)(struct afs_operation *op);
737+ void (*put)(struct afs_operation *op);
738+};
739+
740+struct afs_vnode_param {
741+ struct afs_vnode *vnode;
742+ struct afs_fid fid; /* Fid to access */
743+ struct afs_status_cb scb; /* Returned status and callback promise */
744+ afs_dataversion_t dv_before; /* Data version before the call */
745+ unsigned int cb_break_before; /* cb_break + cb_s_break before the call */
746+ u8 dv_delta; /* Expected change in data version */
747+ bool put_vnode; /* T if we have a ref on the vnode */
748+ bool need_io_lock; /* T if we need the I/O lock on this */
749+};
750+
751+/*
752+ * Fileserver operation wrapper, handling server and address rotation
753+ * asynchronously. May make simultaneous calls to multiple servers.
762754 */
763−struct afs_fs_cursor {
755+struct afs_operation {
756+ struct afs_net *net; /* Network namespace */
757+ struct key *key; /* Key for the cell */
764758 const struct afs_call_type *type; /* Type of call done */
759+ const struct afs_operation_ops *ops;
760+
761+ /* Parameters/results for the operation */
762+ struct afs_volume *volume; /* Volume being accessed */
763+ struct afs_vnode_param file[2];
764+ struct afs_vnode_param *more_files;
765+ struct afs_volsync volsync;
766+ struct dentry *dentry; /* Dentry to be altered */
767+ struct dentry *dentry_2; /* Second dentry to be altered */
768+ struct timespec64 mtime; /* Modification time to record */
769+ short nr_files; /* Number of entries in file[], more_files */
770+ short error;
771+ unsigned int abort_code;
772+ unsigned int debug_id;
773+
774+ unsigned int cb_v_break; /* Volume break counter before op */
775+ unsigned int cb_s_break; /* Server break counter before op */
776+
777+ union {
778+ struct {
779+ int which; /* Which ->file[] to fetch for */
780+ } fetch_status;
781+ struct {
782+ int reason; /* enum afs_edit_dir_reason */
783+ mode_t mode;
784+ const char *symlink;
785+ } create;
786+ struct {
787+ bool need_rehash;
788+ } unlink;
789+ struct {
790+ struct dentry *rehash;
791+ struct dentry *tmp;
792+ bool new_negative;
793+ } rename;
794+ struct {
795+ struct afs_read *req;
796+ } fetch;
797+ struct {
798+ struct afs_vnode *lvnode; /* vnode being locked */
799+ afs_lock_type_t type;
800+ } lock;
801+ struct {
802+ struct address_space *mapping; /* Pages being written from */
803+ pgoff_t first; /* first page in mapping to deal with */
804+ pgoff_t last; /* last page in mapping to deal with */
805+ unsigned first_offset; /* offset into mapping[first] */
806+ unsigned last_to; /* amount of mapping[last] */
807+ } store;
808+ struct {
809+ struct iattr *attr;
810+ } setattr;
811+ struct afs_acl *acl;
812+ struct yfs_acl *yacl;
813+ struct {
814+ struct afs_volume_status vs;
815+ struct kstatfs *buf;
816+ } volstatus;
817+ };
818+
819+ /* Fileserver iteration state */
765820 struct afs_addr_cursor ac;
766− struct afs_vnode *vnode;
767821 struct afs_server_list *server_list; /* Current server list (pins ref) */
768− struct afs_cb_interest *cbi; /* Server on which this resides (pins ref) */
769− struct key *key; /* Key for the server */
822+ struct afs_server *server; /* Server we're using (ref pinned by server_list) */
823+ struct afs_call *call;
770824 unsigned long untried; /* Bitmask of untried servers */
771− unsigned int cb_break; /* cb_break + cb_s_break before the call */
772− unsigned int cb_break_2; /* cb_break + cb_s_break (2nd vnode) */
773825 short index; /* Current server */
774− short error;
775− unsigned short flags;
776−#define AFS_FS_CURSOR_STOP 0x0001 /* Set to cease iteration */
777−#define AFS_FS_CURSOR_VBUSY 0x0002 /* Set if seen VBUSY */
778−#define AFS_FS_CURSOR_VMOVED 0x0004 /* Set if seen VMOVED */
779−#define AFS_FS_CURSOR_VNOVOL 0x0008 /* Set if seen VNOVOL */
780−#define AFS_FS_CURSOR_CUR_ONLY 0x0010 /* Set if current server only (file lock held) */
781−#define AFS_FS_CURSOR_NO_VSLEEP 0x0020 /* Set to prevent sleep on VBUSY, VOFFLINE, ... */
782−#define AFS_FS_CURSOR_INTR 0x0040 /* Set if op is interruptible */
783826 unsigned short nr_iterations; /* Number of server iterations */
827+
828+ unsigned int flags;
829+#define AFS_OPERATION_STOP 0x0001 /* Set to cease iteration */
830+#define AFS_OPERATION_VBUSY 0x0002 /* Set if seen VBUSY */
831+#define AFS_OPERATION_VMOVED 0x0004 /* Set if seen VMOVED */
832+#define AFS_OPERATION_VNOVOL 0x0008 /* Set if seen VNOVOL */
833+#define AFS_OPERATION_CUR_ONLY 0x0010 /* Set if current server only (file lock held) */
834+#define AFS_OPERATION_NO_VSLEEP 0x0020 /* Set to prevent sleep on VBUSY, VOFFLINE, ... */
835+#define AFS_OPERATION_UNINTR 0x0040 /* Set if op is uninterruptible */
836+#define AFS_OPERATION_DOWNGRADE 0x0080 /* Set to retry with downgraded opcode */
837+#define AFS_OPERATION_LOCK_0 0x0100 /* Set if have io_lock on file[0] */
838+#define AFS_OPERATION_LOCK_1 0x0200 /* Set if have io_lock on file[1] */
839+#define AFS_OPERATION_TRIED_ALL 0x0400 /* Set if we've tried all the fileservers */
840+#define AFS_OPERATION_RETRY_SERVER 0x0800 /* Set if we should retry the current server */
784841 };
785842
786843 /*
@@ -838,29 +895,15 @@ extern void __afs_break_callback(struct afs_vnode *, enum afs_cb_break_reason); · 51 unmodified lines
838895 extern void afs_break_callback(struct afs_vnode *, enum afs_cb_break_reason);
839896 extern void afs_break_callbacks(struct afs_server *, size_t, struct afs_callback_break *);
840897
841−extern int afs_register_server_cb_interest(struct afs_vnode *,
842− struct afs_server_list *, unsigned int);
843−extern void afs_put_cb_interest(struct afs_net *, struct afs_cb_interest *);
844−extern void afs_clear_callback_interests(struct afs_net *, struct afs_server_list *);
845−
846−static inline struct afs_cb_interest *afs_get_cb_interest(struct afs_cb_interest *cbi)
847−{
848− if (cbi)
849− refcount_inc(&cbi->usage);
850− return cbi;
851−}
852−
853898 static inline unsigned int afs_calc_vnode_cb_break(struct afs_vnode *vnode)
854899 {
855900 return vnode->cb_break + vnode->cb_v_break;
856901 }
857902
858903 static inline bool afs_cb_is_broken(unsigned int cb_break,
859− const struct afs_vnode *vnode,
860− const struct afs_cb_interest *cbi)
904+ const struct afs_vnode *vnode)
861905 {
862− return !cbi || cb_break != (vnode->cb_break +
863− vnode->volume->cb_v_break);
906+ return cb_break != (vnode->cb_break + vnode->volume->cb_v_break);
864907 }
865908
866909 /*
@@ -952,71 +995,81 @@ extern int afs_flock(struct file *, int, struct file_lock *); · 85 unmodified lines
952995 /*
953996 * fsclient.c
954997 */
955−extern int afs_fs_fetch_file_status(struct afs_fs_cursor *, struct afs_status_cb *,
956− struct afs_volsync *);
957−extern int afs_fs_give_up_callbacks(struct afs_net *, struct afs_server *);
958−extern int afs_fs_fetch_data(struct afs_fs_cursor *, struct afs_status_cb *, struct afs_read *);
959−extern int afs_fs_create(struct afs_fs_cursor *, const char *, umode_t,
960− struct afs_status_cb *, struct afs_fid *, struct afs_status_cb *);
961−extern int afs_fs_remove(struct afs_fs_cursor *, struct afs_vnode *, const char *, bool,
962− struct afs_status_cb *);
963−extern int afs_fs_link(struct afs_fs_cursor *, struct afs_vnode *, const char *,
964− struct afs_status_cb *, struct afs_status_cb *);
965−extern int afs_fs_symlink(struct afs_fs_cursor *, const char *, const char *,
966− struct afs_status_cb *, struct afs_fid *, struct afs_status_cb *);
967−extern int afs_fs_rename(struct afs_fs_cursor *, const char *,
968− struct afs_vnode *, const char *,
969− struct afs_status_cb *, struct afs_status_cb *);
970−extern int afs_fs_store_data(struct afs_fs_cursor *, struct address_space *,
971− pgoff_t, pgoff_t, unsigned, unsigned, struct afs_status_cb *);
972−extern int afs_fs_setattr(struct afs_fs_cursor *, struct iattr *, struct afs_status_cb *);
973−extern int afs_fs_get_volume_status(struct afs_fs_cursor *, struct afs_volume_status *);
974−extern int afs_fs_set_lock(struct afs_fs_cursor *, afs_lock_type_t, struct afs_status_cb *);
975−extern int afs_fs_extend_lock(struct afs_fs_cursor *, struct afs_status_cb *);
976−extern int afs_fs_release_lock(struct afs_fs_cursor *, struct afs_status_cb *);
998+extern void afs_fs_fetch_status(struct afs_operation *);
999+extern void afs_fs_fetch_data(struct afs_operation *);
1000+extern void afs_fs_create_file(struct afs_operation *);
1001+extern void afs_fs_make_dir(struct afs_operation *);
1002+extern void afs_fs_remove_file(struct afs_operation *);
1003+extern void afs_fs_remove_dir(struct afs_operation *);
1004+extern void afs_fs_link(struct afs_operation *);
1005+extern void afs_fs_symlink(struct afs_operation *);
1006+extern void afs_fs_rename(struct afs_operation *);
1007+extern void afs_fs_store_data(struct afs_operation *);
1008+extern void afs_fs_setattr(struct afs_operation *);
1009+extern void afs_fs_get_volume_status(struct afs_operation *);
1010+extern void afs_fs_set_lock(struct afs_operation *);
1011+extern void afs_fs_extend_lock(struct afs_operation *);
1012+extern void afs_fs_release_lock(struct afs_operation *);
9771013 extern int afs_fs_give_up_all_callbacks(struct afs_net *, struct afs_server *,
9781014 struct afs_addr_cursor *, struct key *);
979−extern struct afs_call *afs_fs_get_capabilities(struct afs_net *, struct afs_server *,
980− struct afs_addr_cursor *, struct key *,
981− unsigned int);
982−extern int afs_fs_inline_bulk_status(struct afs_fs_cursor *, struct afs_net *,
983− struct afs_fid *, struct afs_status_cb *,
984− unsigned int, struct afs_volsync *);
985−extern int afs_fs_fetch_status(struct afs_fs_cursor *, struct afs_net *,
986− struct afs_fid *, struct afs_status_cb *,
987− struct afs_volsync *);
1015+extern bool afs_fs_get_capabilities(struct afs_net *, struct afs_server *,
1016+ struct afs_addr_cursor *, struct key *);
1017+extern void afs_fs_inline_bulk_status(struct afs_operation *);
9881018
9891019 struct afs_acl {
9901020 u32 size;
9911021 u8 data[];
9921022 };
9931023
994−extern struct afs_acl *afs_fs_fetch_acl(struct afs_fs_cursor *, struct afs_status_cb *);
995−extern int afs_fs_store_acl(struct afs_fs_cursor *, const struct afs_acl *,
996− struct afs_status_cb *);
1024+extern void afs_fs_fetch_acl(struct afs_operation *);
1025+extern void afs_fs_store_acl(struct afs_operation *);
1026+
1027+/*
1028+ * fs_operation.c
1029+ */
1030+extern struct afs_operation *afs_alloc_operation(struct key *, struct afs_volume *);
1031+extern int afs_put_operation(struct afs_operation *);
1032+extern bool afs_begin_vnode_operation(struct afs_operation *);
1033+extern void afs_wait_for_operation(struct afs_operation *);
1034+extern int afs_do_sync_operation(struct afs_operation *);
1035+
1036+static inline void afs_op_nomem(struct afs_operation *op)
1037+{
1038+ op->error = -ENOMEM;
1039+}
1040+
1041+static inline void afs_op_set_vnode(struct afs_operation *op, unsigned int n,
1042+ struct afs_vnode *vnode)
1043+{
1044+ op->file[n].vnode = vnode;
1045+ op->file[n].need_io_lock = true;
1046+}
1047+
1048+static inline void afs_op_set_fid(struct afs_operation *op, unsigned int n,
1049+ const struct afs_fid *fid)
1050+{
1051+ op->file[n].fid = *fid;
1052+}
9971053
9981054 /*
9991055 * fs_probe.c
10001056 */
10011057 extern void afs_fileserver_probe_result(struct afs_call *);
1002−extern int afs_probe_fileservers(struct afs_net *, struct key *, struct afs_server_list *);
1058+extern void afs_fs_probe_fileserver(struct afs_net *, struct afs_server *, struct key *, bool);
10031059 extern int afs_wait_for_fs_probes(struct afs_server_list *, unsigned long);
1060+extern void afs_probe_fileserver(struct afs_net *, struct afs_server *);
1061+extern void afs_fs_probe_dispatcher(struct work_struct *);
1062+extern int afs_wait_for_one_fs_probe(struct afs_server *, bool);
10041063
10051064 /*
10061065 * inode.c
10071066 */
1008−extern void afs_vnode_commit_status(struct afs_fs_cursor *,
1009− struct afs_vnode *,
1010− unsigned int,
1011− const afs_dataversion_t *,
1012− struct afs_status_cb *);
1067+extern void afs_vnode_commit_status(struct afs_operation *, struct afs_vnode_param *);
10131068 extern int afs_fetch_status(struct afs_vnode *, struct key *, bool, afs_access_t *);
1014−extern int afs_iget5_test(struct inode *, void *);
1069+extern int afs_ilookup5_test_by_fid(struct inode *, void *);
10151070 extern struct inode *afs_iget_pseudo_dir(struct super_block *, bool);
1016−extern struct inode *afs_iget(struct super_block *, struct key *,
1017− struct afs_iget_data *, struct afs_status_cb *,
1018− struct afs_cb_interest *,
1019− struct afs_vnode *);
1071+extern struct inode *afs_iget(struct afs_operation *, struct afs_vnode_param *);
1072+extern struct inode *afs_root_iget(struct super_block *, struct key *);
10201073 extern void afs_zap_data(struct afs_vnode *);
10211074 extern bool afs_check_validity(struct afs_vnode *);
10221075 extern int afs_validate(struct afs_vnode *, struct key *);
@@ -1104,11 +1157,8 @@ static inline void afs_put_sysnames(struct afs_sysnames *sysnames) {} · 81 unmodified lines
11041157 /*
11051158 * rotate.c
11061159 */
1107−extern bool afs_begin_vnode_operation(struct afs_fs_cursor *, struct afs_vnode *,
1108− struct key *, bool);
1109−extern bool afs_select_fileserver(struct afs_fs_cursor *);
1110−extern bool afs_select_current_fileserver(struct afs_fs_cursor *);
1111−extern int afs_end_vnode_operation(struct afs_fs_cursor *);
1160+extern bool afs_select_fileserver(struct afs_operation *);
1161+extern void afs_dump_edestaddrreq(const struct afs_operation *);
11121162
11131163 /*
11141164 * rxrpc.c
@@ -1128,12 +1178,17 @@ extern void afs_flat_call_destructor(struct afs_call *); · 13 unmodified lines
11281178 extern void afs_send_empty_reply(struct afs_call *);
11291179 extern void afs_send_simple_reply(struct afs_call *, const void *, size_t);
11301180 extern int afs_extract_data(struct afs_call *, bool);
1131−extern int afs_protocol_error(struct afs_call *, int, enum afs_eproto_cause);
1181+extern int afs_protocol_error(struct afs_call *, enum afs_eproto_cause);
11321182
1133−static inline void afs_set_fc_call(struct afs_call *call, struct afs_fs_cursor *fc)
1183+static inline void afs_make_op_call(struct afs_operation *op, struct afs_call *call,
1184+ gfp_t gfp)
11341185 {
1135− call->intr = fc->flags & AFS_FS_CURSOR_INTR;
1136− fc->type = call->type;
1186+ op->call = call;
1187+ op->type = call->type;
1188+ call->op = op;
1189+ call->key = op->key;
1190+ call->intr = !(op->flags & AFS_OPERATION_UNINTR);
1191+ afs_make_call(&op->ac, call, gfp);
11371192 }
11381193
11391194 static inline void afs_extract_begin(struct afs_call *call, void *buf, size_t size)
@@ -1241,13 +1296,33 @@ extern spinlock_t afs_server_peer_lock; · 101 unmodified lines
12411296 extern struct afs_server *afs_find_server(struct afs_net *,
12421297 const struct sockaddr_rxrpc *);
12431298 extern struct afs_server *afs_find_server_by_uuid(struct afs_net *, const uuid_t *);
1244−extern struct afs_server *afs_lookup_server(struct afs_cell *, struct key *, const uuid_t *);
1299+extern struct afs_server *afs_lookup_server(struct afs_cell *, struct key *, const uuid_t *, u32);
12451300 extern struct afs_server *afs_get_server(struct afs_server *, enum afs_server_trace);
1301+extern struct afs_server *afs_use_server(struct afs_server *, enum afs_server_trace);
1302+extern void afs_unuse_server(struct afs_net *, struct afs_server *, enum afs_server_trace);
1303+extern void afs_unuse_server_notime(struct afs_net *, struct afs_server *, enum afs_server_trace);
12461304 extern void afs_put_server(struct afs_net *, struct afs_server *, enum afs_server_trace);
12471305 extern void afs_manage_servers(struct work_struct *);
12481306 extern void afs_servers_timer(struct timer_list *);
1307+extern void afs_fs_probe_timer(struct timer_list *);
12491308 extern void __net_exit afs_purge_servers(struct afs_net *);
1250−extern bool afs_check_server_record(struct afs_fs_cursor *, struct afs_server *);
1309+extern bool afs_check_server_record(struct afs_operation *, struct afs_server *);
1310+
1311+static inline void afs_inc_servers_outstanding(struct afs_net *net)
1312+{
1313+ atomic_inc(&net->servers_outstanding);
1314+}
1315+
1316+static inline void afs_dec_servers_outstanding(struct afs_net *net)
1317+{
1318+ if (atomic_dec_and_test(&net->servers_outstanding))
1319+ wake_up_var(&net->servers_outstanding);
1320+}
1321+
1322+static inline bool afs_is_probing_server(struct afs_server *server)
1323+{
1324+ return list_empty(&server->probe_link);
1325+}
12511326
12521327 /*
12531328 * server_list.c
@@ -1279,6 +1354,12 @@ extern struct afs_addr_list *afs_vl_get_addrs_u(struct afs_vl_cursor *, const uu · 25 unmodified lines
12791354 extern struct afs_call *afs_vl_get_capabilities(struct afs_net *, struct afs_addr_cursor *,
12801355 struct key *, struct afs_vlserver *, unsigned int);
12811356 extern struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_vl_cursor *, const uuid_t *);
1357+extern char *afs_yfsvl_get_cell_name(struct afs_vl_cursor *);
1358+
1359+/*
1360+ * vl_alias.c
1361+ */
1362+extern int afs_cell_detect_alias(struct afs_cell *, struct key *);
12821363
12831364 /*
12841365 * vl_probe.c
@@ -1322,18 +1403,12 @@ extern struct afs_vlserver_list *afs_extract_vlserver_list(struct afs_cell *, · 37 unmodified lines
13221403 /*
13231404 * volume.c
13241405 */
1325−static inline struct afs_volume *__afs_get_volume(struct afs_volume *volume)
1326−{
1327− if (volume)
1328− atomic_inc(&volume->usage);
1329− return volume;
1330−}
1331−
13321406 extern struct afs_volume *afs_create_volume(struct afs_fs_context *);
13331407 extern void afs_activate_volume(struct afs_volume *);
13341408 extern void afs_deactivate_volume(struct afs_volume *);
1335−extern void afs_put_volume(struct afs_cell *, struct afs_volume *);
1336−extern int afs_check_volume_status(struct afs_volume *, struct afs_fs_cursor *);
1409+extern struct afs_volume *afs_get_volume(struct afs_volume *, enum afs_volume_trace);
1410+extern void afs_put_volume(struct afs_net *, struct afs_volume *, enum afs_volume_trace);
1411+extern int afs_check_volume_status(struct afs_volume *, struct afs_operation *);
13371412
13381413 /*
13391414 * write.c
@@ -1362,36 +1437,24 @@ extern ssize_t afs_listxattr(struct dentry *, char *, size_t); · 22 unmodified lines
13621437 /*
13631438 * yfsclient.c
13641439 */
1365−extern int yfs_fs_fetch_file_status(struct afs_fs_cursor *, struct afs_status_cb *,
1366− struct afs_volsync *);
1367−extern int yfs_fs_fetch_data(struct afs_fs_cursor *, struct afs_status_cb *, struct afs_read *);
1368−extern int yfs_fs_create_file(struct afs_fs_cursor *, const char *, umode_t, struct afs_status_cb *,
1369− struct afs_fid *, struct afs_status_cb *);
1370−extern int yfs_fs_make_dir(struct afs_fs_cursor *, const char *, umode_t, struct afs_status_cb *,
1371− struct afs_fid *, struct afs_status_cb *);
1372−extern int yfs_fs_remove_file2(struct afs_fs_cursor *, struct afs_vnode *, const char *,
1373− struct afs_status_cb *, struct afs_status_cb *);
1374−extern int yfs_fs_remove(struct afs_fs_cursor *, struct afs_vnode *, const char *, bool,
1375− struct afs_status_cb *);
1376−extern int yfs_fs_link(struct afs_fs_cursor *, struct afs_vnode *, const char *,
1377− struct afs_status_cb *, struct afs_status_cb *);
1378−extern int yfs_fs_symlink(struct afs_fs_cursor *, const char *, const char *,
1379− struct afs_status_cb *, struct afs_fid *, struct afs_status_cb *);
1380−extern int yfs_fs_rename(struct afs_fs_cursor *, const char *, struct afs_vnode *, const char *,
1381− struct afs_status_cb *, struct afs_status_cb *);
1382−extern int yfs_fs_store_data(struct afs_fs_cursor *, struct address_space *,
1383− pgoff_t, pgoff_t, unsigned, unsigned, struct afs_status_cb *);
1384−extern int yfs_fs_setattr(struct afs_fs_cursor *, struct iattr *, struct afs_status_cb *);
1385−extern int yfs_fs_get_volume_status(struct afs_fs_cursor *, struct afs_volume_status *);
1386−extern int yfs_fs_set_lock(struct afs_fs_cursor *, afs_lock_type_t, struct afs_status_cb *);
1387−extern int yfs_fs_extend_lock(struct afs_fs_cursor *, struct afs_status_cb *);
1388−extern int yfs_fs_release_lock(struct afs_fs_cursor *, struct afs_status_cb *);
1389−extern int yfs_fs_fetch_status(struct afs_fs_cursor *, struct afs_net *,
1390− struct afs_fid *, struct afs_status_cb *,
1391− struct afs_volsync *);
1392−extern int yfs_fs_inline_bulk_status(struct afs_fs_cursor *, struct afs_net *,
1393− struct afs_fid *, struct afs_status_cb *,
1394− unsigned int, struct afs_volsync *);
1440+extern void yfs_fs_fetch_file_status(struct afs_operation *);
1441+extern void yfs_fs_fetch_data(struct afs_operation *);
1442+extern void yfs_fs_create_file(struct afs_operation *);
1443+extern void yfs_fs_make_dir(struct afs_operation *);
1444+extern void yfs_fs_remove_file2(struct afs_operation *);
1445+extern void yfs_fs_remove_file(struct afs_operation *);
1446+extern void yfs_fs_remove_dir(struct afs_operation *);
1447+extern void yfs_fs_link(struct afs_operation *);
1448+extern void yfs_fs_symlink(struct afs_operation *);
1449+extern void yfs_fs_rename(struct afs_operation *);
1450+extern void yfs_fs_store_data(struct afs_operation *);
1451+extern void yfs_fs_setattr(struct afs_operation *);
1452+extern void yfs_fs_get_volume_status(struct afs_operation *);
1453+extern void yfs_fs_set_lock(struct afs_operation *);
1454+extern void yfs_fs_extend_lock(struct afs_operation *);
1455+extern void yfs_fs_release_lock(struct afs_operation *);
1456+extern void yfs_fs_fetch_status(struct afs_operation *);
1457+extern void yfs_fs_inline_bulk_status(struct afs_operation *);
13951458
13961459 struct yfs_acl {
13971460 struct afs_acl *acl; /* Dir/file/symlink ACL */
@@ -1404,10 +1467,8 @@ struct yfs_acl { · 6 unmodified lines
14041467 };
14051468
14061469 extern void yfs_free_opaque_acl(struct yfs_acl *);
1407−extern struct yfs_acl *yfs_fs_fetch_opaque_acl(struct afs_fs_cursor *, struct yfs_acl *,
1408− struct afs_status_cb *);
1409−extern int yfs_fs_store_opaque_acl2(struct afs_fs_cursor *, const struct afs_acl *,
1410− struct afs_status_cb *);
1470+extern void yfs_fs_fetch_opaque_acl(struct afs_operation *);
1471+extern void yfs_fs_store_opaque_acl2(struct afs_operation *);
14111472
14121473 /*
14131474 * Miscellaneous inline functions.
@@ -1422,15 +1483,29 @@ static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode) · 8 unmodified lines
14221483 return &vnode->vfs_inode;
14231484 }
14241485
1425−static inline void afs_check_for_remote_deletion(struct afs_fs_cursor *fc,
1486+static inline void afs_check_for_remote_deletion(struct afs_operation *op,
14261487 struct afs_vnode *vnode)
14271488 {
1428− if (fc->ac.error == -ENOENT) {
1489+ if (op->error == -ENOENT) {
14291490 set_bit(AFS_VNODE_DELETED, &vnode->flags);
14301491 afs_break_callback(vnode, afs_cb_break_for_deleted);
14311492 }
14321493 }
14331494
1495+/*
1496+ * Note that a dentry got changed. We need to set d_fsdata to the data version
1497+ * number derived from the result of the operation. It doesn't matter if
1498+ * d_fsdata goes backwards as we'll just revalidate.
1499+ */
1500+static inline void afs_update_dentry_version(struct afs_operation *op,
1501+ struct afs_vnode_param *dir_vp,
1502+ struct dentry *dentry)
1503+{
1504+ if (!op->error)
1505+ dentry->d_fsdata =
1506+ (void *)(unsigned long)dir_vp->scb.status.data_version;
1507+}
1508+
14341509 static inline int afs_io_error(struct afs_call *call, enum afs_io_error where)
14351510 {
14361511 trace_afs_io_error(call->debug_id, -EIO, where);
fs/afs/main.c+5−1
@@ -82,12 +82,14 @@ static int __net_init afs_net_init(struct net *net_ns) · 81 unmodified lines
8282 INIT_WORK(&net->cells_manager, afs_manage_cells);
8383 timer_setup(&net->cells_timer, afs_cells_timer, 0);
8484
85+ mutex_init(&net->cells_alias_lock);
8586 mutex_init(&net->proc_cells_lock);
8687 INIT_HLIST_HEAD(&net->proc_cells);
8788
8889 seqlock_init(&net->fs_lock);
8990 net->fs_servers = RB_ROOT;
90− INIT_LIST_HEAD(&net->fs_updates);
91+ INIT_LIST_HEAD(&net->fs_probe_fast);
92+ INIT_LIST_HEAD(&net->fs_probe_slow);
9193 INIT_HLIST_HEAD(&net->fs_proc);
9294
9395 INIT_HLIST_HEAD(&net->fs_addresses4);
@@ -96,6 +98,8 @@ static int __net_init afs_net_init(struct net *net_ns) · 2 unmodified lines
9698
9799 INIT_WORK(&net->fs_manager, afs_manage_servers);
98100 timer_setup(&net->fs_timer, afs_servers_timer, 0);
101+ INIT_WORK(&net->fs_prober, afs_fs_probe_dispatcher);
102+ timer_setup(&net->fs_probe_timer, afs_fs_probe_timer, 0);
99103
100104 ret = -ENOMEM;
101105 sysnames = kzalloc(sizeof(*sysnames), GFP_KERNEL);
fs/afs/proc.c+23−19
@@ -38,7 +38,7 @@ static int afs_proc_cells_show(struct seq_file *m, void *v) · 37 unmodified lines
3838
3939 if (v == SEQ_START_TOKEN) {
4040 /* display header on line 1 */
41− seq_puts(m, "USE TTL SV NAME\n");
41+ seq_puts(m, "USE TTL SV ST NAME\n");
4242 return 0;
4343 }
4444
@@ -46,10 +46,11 @@ static int afs_proc_cells_show(struct seq_file *m, void *v) · 1 unmodified line
4646 vllist = rcu_dereference(cell->vl_servers);
4747
4848 /* display one cell per line on subsequent lines */
49− seq_printf(m, "%3u %6lld %2u %s\n",
49+ seq_printf(m, "%3u %6lld %2u %2u %s\n",
5050 atomic_read(&cell->usage),
5151 cell->dns_expiry - ktime_get_real_seconds(),
5252 vllist->nr_servers,
53+ cell->state,
5354 cell->name);
5455 return 0;
5556 }
@@ -208,11 +209,10 @@ static const char afs_vol_types[3][3] = { · 152 unmodified lines
208209 */
209210 static int afs_proc_cell_volumes_show(struct seq_file *m, void *v)
210211 {
211− struct afs_cell *cell = PDE_DATA(file_inode(m->file));
212− struct afs_volume *vol = list_entry(v, struct afs_volume, proc_link);
212+ struct afs_volume *vol = hlist_entry(v, struct afs_volume, proc_link);
213213
214214 /* Display header on line 1 */
215− if (v == &cell->proc_volumes) {
215+ if (v == SEQ_START_TOKEN) {
216216 seq_puts(m, "USE VID TY NAME\n");
217217 return 0;
218218 }
@@ -230,8 +230,8 @@ static void *afs_proc_cell_volumes_start(struct seq_file *m, loff_t *_pos) · 11 unmodified lines
230230 {
231231 struct afs_cell *cell = PDE_DATA(file_inode(m->file));
232232
233− read_lock(&cell->proc_lock);
234− return seq_list_start_head(&cell->proc_volumes, *_pos);
233+ rcu_read_lock();
234+ return seq_hlist_start_head_rcu(&cell->proc_volumes, *_pos);
235235 }
236236
237237 static void *afs_proc_cell_volumes_next(struct seq_file *m, void *v,
@@ -239,15 +239,13 @@ static void *afs_proc_cell_volumes_next(struct seq_file *m, void *v, · 1 unmodified line
239239 {
240240 struct afs_cell *cell = PDE_DATA(file_inode(m->file));
241241
242− return seq_list_next(v, &cell->proc_volumes, _pos);
242+ return seq_hlist_next_rcu(v, &cell->proc_volumes, _pos);
243243 }
244244
245245 static void afs_proc_cell_volumes_stop(struct seq_file *m, void *v)
246246 __releases(cell->proc_lock)
247247 {
248− struct afs_cell *cell = PDE_DATA(file_inode(m->file));
249−
250− read_unlock(&cell->proc_lock);
248+ rcu_read_unlock();
251249 }
252250
253251 static const struct seq_operations afs_proc_cell_volumes_ops = {
@@ -378,20 +376,26 @@ static int afs_proc_servers_show(struct seq_file *m, void *v) · 124 unmodified lines
378376 int i;
379377
380378 if (v == SEQ_START_TOKEN) {
381− seq_puts(m, "UUID USE ADDR\n");
379+ seq_puts(m, "UUID REF ACT\n");
382380 return 0;
383381 }
384382
385383 server = list_entry(v, struct afs_server, proc_link);
386384 alist = rcu_dereference(server->addresses);
387− seq_printf(m, "%pU %3d %pISpc%s\n",
385+ seq_printf(m, "%pU %3d %3d\n",
388386 &server->uuid,
389− atomic_read(&server->usage),
390− &alist->addrs[0].transport,
391− alist->preferred == 0 ? "*" : "");
392− for (i = 1; i < alist->nr_addrs; i++)
393− seq_printf(m, " %pISpc%s\n",
394− &alist->addrs[i].transport,
387+ atomic_read(&server->ref),
388+ atomic_read(&server->active));
389+ seq_printf(m, " - info: fl=%lx rtt=%u brk=%x\n",
390+ server->flags, server->rtt, server->cb_s_break);
391+ seq_printf(m, " - probe: last=%d out=%d\n",
392+ (int)(jiffies - server->probed_at) / HZ,
393+ atomic_read(&server->probe_outstanding));
394+ seq_printf(m, " - ALIST v=%u rsp=%lx f=%lx\n",
395+ alist->version, alist->responded, alist->failed);
396+ for (i = 0; i < alist->nr_addrs; i++)
397+ seq_printf(m, " [%x] %pISpc%s\n",
398+ i, &alist->addrs[i].transport,
395399 alist->preferred == i ? "*" : "");
396400 return 0;
397401 }
fs/afs/protocol_yfs.h+1−1
@@ -8,7 +8,7 @@ · 7 unmodified lines
88 #define YFS_FS_SERVICE 2500
99 #define YFS_CM_SERVICE 2501
1010
11−#define YFSCBMAX 1024
11+#define YFSCBMAX 1024
1212
1313 enum YFS_CM_Operations {
1414 YFSCBProbe = 206, /* probe client */
fs/afs/rotate.c+162−285
@@ -14,61 +14,33 @@ · 13 unmodified lines
1414 #include "internal.h"
1515 #include "afs_fs.h"
1616
17−/*
18− * Begin an operation on the fileserver.
19− *
20− * Fileserver operations are serialised on the server by vnode, so we serialise
21− * them here also using the io_lock.
22− */
23−bool afs_begin_vnode_operation(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
24− struct key *key, bool intr)
25−{
26− memset(fc, 0, sizeof(*fc));
27− fc->vnode = vnode;
28− fc->key = key;
29− fc->ac.error = SHRT_MAX;
30− fc->error = -EDESTADDRREQ;
31−
32− if (intr) {
33− fc->flags |= AFS_FS_CURSOR_INTR;
34− if (mutex_lock_interruptible(&vnode->io_lock) < 0) {
35− fc->error = -EINTR;
36− fc->flags |= AFS_FS_CURSOR_STOP;
37− return false;
38− }
39− } else {
40− mutex_lock(&vnode->io_lock);
41− }
42−
43− if (vnode->lock_state != AFS_VNODE_LOCK_NONE)
44− fc->flags |= AFS_FS_CURSOR_CUR_ONLY;
45− return true;
46−}
47−
4817 /*
4918 * Begin iteration through a server list, starting with the vnode's last used
5019 * server if possible, or the last recorded good server if not.
5120 */
52−static bool afs_start_fs_iteration(struct afs_fs_cursor *fc,
21+static bool afs_start_fs_iteration(struct afs_operation *op,
5322 struct afs_vnode *vnode)
5423 {
55− struct afs_cb_interest *cbi;
24+ struct afs_server *server;
25+ void *cb_server;
5626 int i;
5727
58− read_lock(&vnode->volume->servers_lock);
59− fc->server_list = afs_get_serverlist(vnode->volume->servers);
60− read_unlock(&vnode->volume->servers_lock);
28+ read_lock(&op->volume->servers_lock);
29+ op->server_list = afs_get_serverlist(
30+ rcu_dereference_protected(op->volume->servers,
31+ lockdep_is_held(&op->volume->servers_lock)));
32+ read_unlock(&op->volume->servers_lock);
6133
62− fc->untried = (1UL << fc->server_list->nr_servers) - 1;
63− fc->index = READ_ONCE(fc->server_list->preferred);
34+ op->untried = (1UL << op->server_list->nr_servers) - 1;
35+ op->index = READ_ONCE(op->server_list->preferred);
6436
65− cbi = rcu_dereference_protected(vnode->cb_interest,
66− lockdep_is_held(&vnode->io_lock));
67− if (cbi) {
37+ cb_server = vnode->cb_server;
38+ if (cb_server) {
6839 /* See if the vnode's preferred record is still available */
69− for (i = 0; i < fc->server_list->nr_servers; i++) {
70− if (fc->server_list->servers[i].cb_interest == cbi) {
71− fc->index = i;
40+ for (i = 0; i < op->server_list->nr_servers; i++) {
41+ server = op->server_list->servers[i].server;
42+ if (server == cb_server) {
43+ op->index = i;
7244 goto found_interest;
7345 }
7446 }
@@ -77,21 +49,18 @@ static bool afs_start_fs_iteration(struct afs_fs_cursor *fc, · 2 unmodified lines
7749 * serving this vnode, then we can't switch to another server
7850 * and have to return an error.
7951 */
80− if (fc->flags & AFS_FS_CURSOR_CUR_ONLY) {
81− fc->error = -ESTALE;
52+ if (op->flags & AFS_OPERATION_CUR_ONLY) {
53+ op->error = -ESTALE;
8254 return false;
8355 }
8456
8557 /* Note that the callback promise is effectively broken */
8658 write_seqlock(&vnode->cb_lock);
87− ASSERTCMP(cbi, ==, rcu_access_pointer(vnode->cb_interest));
88− rcu_assign_pointer(vnode->cb_interest, NULL);
59+ ASSERTCMP(cb_server, ==, vnode->cb_server);
60+ vnode->cb_server = NULL;
8961 if (test_and_clear_bit(AFS_VNODE_CB_PROMISED, &vnode->flags))
9062 vnode->cb_break++;
9163 write_sequnlock(&vnode->cb_lock);
92−
93− afs_put_cb_interest(afs_v2net(vnode), cbi);
94− cbi = NULL;
9564 }
9665
9766 found_interest:
@@ -118,12 +87,12 @@ static void afs_busy(struct afs_volume *volume, u32 abort_code) · 20 unmodified lines
11887 /*
11988 * Sleep and retry the operation to the same fileserver.
12089 */
121−static bool afs_sleep_and_retry(struct afs_fs_cursor *fc)
90+static bool afs_sleep_and_retry(struct afs_operation *op)
12291 {
123− if (fc->flags & AFS_FS_CURSOR_INTR) {
92+ if (!(op->flags & AFS_OPERATION_UNINTR)) {
12493 msleep_interruptible(1000);
12594 if (signal_pending(current)) {
126− fc->error = -ERESTARTSYS;
95+ op->error = -ERESTARTSYS;
12796 return false;
12897 }
12998 } else {
@@ -137,26 +106,26 @@ static bool afs_sleep_and_retry(struct afs_fs_cursor *fc) · 7 unmodified lines
137106 * Select the fileserver to use. May be called multiple times to rotate
138107 * through the fileservers.
139108 */
140−bool afs_select_fileserver(struct afs_fs_cursor *fc)
109+bool afs_select_fileserver(struct afs_operation *op)
141110 {
142111 struct afs_addr_list *alist;
143112 struct afs_server *server;
144− struct afs_vnode *vnode = fc->vnode;
113+ struct afs_vnode *vnode = op->file[0].vnode;
145114 struct afs_error e;
146115 u32 rtt;
147− int error = fc->ac.error, i;
116+ int error = op->ac.error, i;
148117
149118 _enter("%lx[%d],%lx[%d],%d,%d",
150− fc->untried, fc->index,
151− fc->ac.tried, fc->ac.index,
152− error, fc->ac.abort_code);
119+ op->untried, op->index,
120+ op->ac.tried, op->ac.index,
121+ error, op->ac.abort_code);
153122
154− if (fc->flags & AFS_FS_CURSOR_STOP) {
123+ if (op->flags & AFS_OPERATION_STOP) {
155124 _leave(" = f [stopped]");
156125 return false;
157126 }
158127
159− fc->nr_iterations++;
128+ op->nr_iterations++;
160129
161130 /* Evaluate the result of the previous operation, if there was one. */
162131 switch (error) {
@@ -166,8 +135,8 @@ bool afs_select_fileserver(struct afs_fs_cursor *fc) · 3 unmodified lines
166135 case 0:
167136 default:
168137 /* Success or local failure. Stop. */
169− fc->error = error;
170− fc->flags |= AFS_FS_CURSOR_STOP;
138+ op->error = error;
139+ op->flags |= AFS_OPERATION_STOP;
171140 _leave(" = f [okay/local %d]", error);
172141 return false;
173142
@@ -175,42 +144,42 @@ bool afs_select_fileserver(struct afs_fs_cursor *fc) · 1 unmodified line
175144 /* The far side rejected the operation on some grounds. This
176145 * might involve the server being busy or the volume having been moved.
177146 */
178− switch (fc->ac.abort_code) {
147+ switch (op->ac.abort_code) {
179148 case VNOVOL:
180149 /* This fileserver doesn't know about the volume.
181150 * - May indicate that the VL is wrong - retry once and compare
182151 * the results.
183152 * - May indicate that the fileserver couldn't attach to the vol.
184153 */
185− if (fc->flags & AFS_FS_CURSOR_VNOVOL) {
186− fc->error = -EREMOTEIO;
154+ if (op->flags & AFS_OPERATION_VNOVOL) {
155+ op->error = -EREMOTEIO;
187156 goto next_server;
188157 }
189158
190− write_lock(&vnode->volume->servers_lock);
191− fc->server_list->vnovol_mask |= 1 << fc->index;
192− write_unlock(&vnode->volume->servers_lock);
159+ write_lock(&op->volume->servers_lock);
160+ op->server_list->vnovol_mask |= 1 << op->index;
161+ write_unlock(&op->volume->servers_lock);
193162
194− set_bit(AFS_VOLUME_NEEDS_UPDATE, &vnode->volume->flags);
195− error = afs_check_volume_status(vnode->volume, fc);
163+ set_bit(AFS_VOLUME_NEEDS_UPDATE, &op->volume->flags);
164+ error = afs_check_volume_status(op->volume, op);
196165 if (error < 0)
197166 goto failed_set_error;
198167
199− if (test_bit(AFS_VOLUME_DELETED, &vnode->volume->flags)) {
200− fc->error = -ENOMEDIUM;
168+ if (test_bit(AFS_VOLUME_DELETED, &op->volume->flags)) {
169+ op->error = -ENOMEDIUM;
201170 goto failed;
202171 }
203172
204173 /* If the server list didn't change, then assume that
205174 * it's the fileserver having trouble.
206175 */
207− if (vnode->volume->servers == fc->server_list) {
208− fc->error = -EREMOTEIO;
176+ if (rcu_access_pointer(op->volume->servers) == op->server_list) {
177+ op->error = -EREMOTEIO;
209178 goto next_server;
210179 }
211180
212181 /* Try again */
213− fc->flags |= AFS_FS_CURSOR_VNOVOL;
182+ op->flags |= AFS_OPERATION_VNOVOL;
214183 _leave(" = t [vnovol]");
215184 return true;
216185
@@ -220,20 +189,20 @@ bool afs_select_fileserver(struct afs_fs_cursor *fc) · 3 unmodified lines
220189 case VONLINE:
221190 case VDISKFULL:
222191 case VOVERQUOTA:
223− fc->error = afs_abort_to_error(fc->ac.abort_code);
192+ op->error = afs_abort_to_error(op->ac.abort_code);
224193 goto next_server;
225194
226195 case VOFFLINE:
227− if (!test_and_set_bit(AFS_VOLUME_OFFLINE, &vnode->volume->flags)) {
228− afs_busy(vnode->volume, fc->ac.abort_code);
229− clear_bit(AFS_VOLUME_BUSY, &vnode->volume->flags);
196+ if (!test_and_set_bit(AFS_VOLUME_OFFLINE, &op->volume->flags)) {
197+ afs_busy(op->volume, op->ac.abort_code);
198+ clear_bit(AFS_VOLUME_BUSY, &op->volume->flags);
230199 }
231− if (fc->flags & AFS_FS_CURSOR_NO_VSLEEP) {
232− fc->error = -EADV;
200+ if (op->flags & AFS_OPERATION_NO_VSLEEP) {
201+ op->error = -EADV;
233202 goto failed;
234203 }
235− if (fc->flags & AFS_FS_CURSOR_CUR_ONLY) {
236− fc->error = -ESTALE;
204+ if (op->flags & AFS_OPERATION_CUR_ONLY) {
205+ op->error = -ESTALE;
237206 goto failed;
238207 }
239208 goto busy;
@@ -244,17 +213,17 @@ bool afs_select_fileserver(struct afs_fs_cursor *fc) · 4 unmodified lines
244213 /* Retry after going round all the servers unless we
245214 * have a file lock we need to maintain.
246215 */
247− if (fc->flags & AFS_FS_CURSOR_NO_VSLEEP) {
248− fc->error = -EBUSY;
216+ if (op->flags & AFS_OPERATION_NO_VSLEEP) {
217+ op->error = -EBUSY;
249218 goto failed;
250219 }
251− if (!test_and_set_bit(AFS_VOLUME_BUSY, &vnode->volume->flags)) {
252− afs_busy(vnode->volume, fc->ac.abort_code);
253− clear_bit(AFS_VOLUME_OFFLINE, &vnode->volume->flags);
220+ if (!test_and_set_bit(AFS_VOLUME_BUSY, &op->volume->flags)) {
221+ afs_busy(op->volume, op->ac.abort_code);
222+ clear_bit(AFS_VOLUME_OFFLINE, &op->volume->flags);
254223 }
255224 busy:
256− if (fc->flags & AFS_FS_CURSOR_CUR_ONLY) {
257− if (!afs_sleep_and_retry(fc))
225+ if (op->flags & AFS_OPERATION_CUR_ONLY) {
226+ if (!afs_sleep_and_retry(op))
258227 goto failed;
259228
260229 /* Retry with same server & address */
@@ -262,7 +231,7 @@ bool afs_select_fileserver(struct afs_fs_cursor *fc) · 1 unmodified line
262231 return true;
263232 }
264233
265− fc->flags |= AFS_FS_CURSOR_VBUSY;
234+ op->flags |= AFS_OPERATION_VBUSY;
266235 goto next_server;
267236
268237 case VMOVED:
@@ -273,15 +242,15 @@ bool afs_select_fileserver(struct afs_fs_cursor *fc) · 4 unmodified lines
273242 * We also limit the number of VMOVED hops we will
274243 * honour, just in case someone sets up a loop.
275244 */
276− if (fc->flags & AFS_FS_CURSOR_VMOVED) {
277− fc->error = -EREMOTEIO;
245+ if (op->flags & AFS_OPERATION_VMOVED) {
246+ op->error = -EREMOTEIO;
278247 goto failed;
279248 }
280− fc->flags |= AFS_FS_CURSOR_VMOVED;
249+ op->flags |= AFS_OPERATION_VMOVED;
281250
282− set_bit(AFS_VOLUME_WAIT, &vnode->volume->flags);
283− set_bit(AFS_VOLUME_NEEDS_UPDATE, &vnode->volume->flags);
284− error = afs_check_volume_status(vnode->volume, fc);
251+ set_bit(AFS_VOLUME_WAIT, &op->volume->flags);
252+ set_bit(AFS_VOLUME_NEEDS_UPDATE, &op->volume->flags);
253+ error = afs_check_volume_status(op->volume, op);
285254 if (error < 0)
286255 goto failed_set_error;
287256
@@ -294,23 +263,23 @@ bool afs_select_fileserver(struct afs_fs_cursor *fc) · 6 unmodified lines
294263 *
295264 * TODO: Retry a few times with sleeps.
296265 */
297− if (vnode->volume->servers == fc->server_list) {
298− fc->error = -ENOMEDIUM;
266+ if (rcu_access_pointer(op->volume->servers) == op->server_list) {
267+ op->error = -ENOMEDIUM;
299268 goto failed;
300269 }
301270
302271 goto restart_from_beginning;
303272
304273 default:
305− clear_bit(AFS_VOLUME_OFFLINE, &vnode->volume->flags);
306− clear_bit(AFS_VOLUME_BUSY, &vnode->volume->flags);
307− fc->error = afs_abort_to_error(fc->ac.abort_code);
274+ clear_bit(AFS_VOLUME_OFFLINE, &op->volume->flags);
275+ clear_bit(AFS_VOLUME_BUSY, &op->volume->flags);
276+ op->error = afs_abort_to_error(op->ac.abort_code);
308277 goto failed;
309278 }
310279
311280 case -ETIMEDOUT:
312281 case -ETIME:
313− if (fc->error != -EDESTADDRREQ)
282+ if (op->error != -EDESTADDRREQ)
314283 goto iterate_address;
315284 /* Fall through */
316285 case -ERFKILL:
@@ -320,103 +289,94 @@ bool afs_select_fileserver(struct afs_fs_cursor *fc) · 3 unmodified lines
320289 case -EHOSTDOWN:
321290 case -ECONNREFUSED:
322291 _debug("no conn");
323− fc->error = error;
292+ op->error = error;
324293 goto iterate_address;
325294
326295 case -ECONNRESET:
327296 _debug("call reset");
328− fc->error = error;
297+ op->error = error;
329298 goto failed;
330299 }
331300
332301 restart_from_beginning:
333302 _debug("restart");
334− afs_end_cursor(&fc->ac);
335− afs_put_cb_interest(afs_v2net(vnode), fc->cbi);
336− fc->cbi = NULL;
337− afs_put_serverlist(afs_v2net(vnode), fc->server_list);
338− fc->server_list = NULL;
303+ afs_end_cursor(&op->ac);
304+ op->server = NULL;
305+ afs_put_serverlist(op->net, op->server_list);
306+ op->server_list = NULL;
339307 start:
340308 _debug("start");
341309 /* See if we need to do an update of the volume record. Note that the
342310 * volume may have moved or even have been deleted.
343311 */
344− error = afs_check_volume_status(vnode->volume, fc);
312+ error = afs_check_volume_status(op->volume, op);
345313 if (error < 0)
346314 goto failed_set_error;
347315
348− if (!afs_start_fs_iteration(fc, vnode))
316+ if (!afs_start_fs_iteration(op, vnode))
349317 goto failed;
350318
351− _debug("__ VOL %llx __", vnode->volume->vid);
352− error = afs_probe_fileservers(afs_v2net(vnode), fc->key, fc->server_list);
353− if (error < 0)
354− goto failed_set_error;
319+ _debug("__ VOL %llx __", op->volume->vid);
355320
356321 pick_server:
357− _debug("pick [%lx]", fc->untried);
322+ _debug("pick [%lx]", op->untried);
358323
359− error = afs_wait_for_fs_probes(fc->server_list, fc->untried);
324+ error = afs_wait_for_fs_probes(op->server_list, op->untried);
360325 if (error < 0)
361326 goto failed_set_error;
362327
363328 /* Pick the untried server with the lowest RTT. If we have outstanding
364329 * callbacks, we stick with the server we're already using if we can.
365330 */
366− if (fc->cbi) {
367− _debug("cbi %u", fc->index);
368− if (test_bit(fc->index, &fc->untried))
331+ if (op->server) {
332+ _debug("server %u", op->index);
333+ if (test_bit(op->index, &op->untried))
369334 goto selected_server;
370− afs_put_cb_interest(afs_v2net(vnode), fc->cbi);
371− fc->cbi = NULL;
372− _debug("nocbi");
335+ op->server = NULL;
336+ _debug("no server");
373337 }
374338
375− fc->index = -1;
339+ op->index = -1;
376340 rtt = U32_MAX;
377− for (i = 0; i < fc->server_list->nr_servers; i++) {
378− struct afs_server *s = fc->server_list->servers[i].server;
341+ for (i = 0; i < op->server_list->nr_servers; i++) {
342+ struct afs_server *s = op->server_list->servers[i].server;
379343
380− if (!test_bit(i, &fc->untried) || !s->probe.responded)
344+ if (!test_bit(i, &op->untried) ||
345+ !test_bit(AFS_SERVER_FL_RESPONDING, &s->flags))
381346 continue;
382347 if (s->probe.rtt < rtt) {
383− fc->index = i;
348+ op->index = i;
384349 rtt = s->probe.rtt;
385350 }
386351 }
387352
388− if (fc->index == -1)
353+ if (op->index == -1)
389354 goto no_more_servers;
390355
391356 selected_server:
392− _debug("use %d", fc->index);
393− __clear_bit(fc->index, &fc->untried);
357+ _debug("use %d", op->index);
358+ __clear_bit(op->index, &op->untried);
394359
395360 /* We're starting on a different fileserver from the list. We need to
396361 * check it, create a callback intercept, find its address list and
397362 * probe its capabilities before we use it.
398363 */
399− ASSERTCMP(fc->ac.alist, ==, NULL);
400− server = fc->server_list->servers[fc->index].server;
364+ ASSERTCMP(op->ac.alist, ==, NULL);
365+ server = op->server_list->servers[op->index].server;
401366
402− if (!afs_check_server_record(fc, server))
367+ if (!afs_check_server_record(op, server))
403368 goto failed;
404369
405370 _debug("USING SERVER: %pU", &server->uuid);
406371
407− /* Make sure we've got a callback interest record for this server. We
408− * have to link it in before we send the request as we can be sent a
409− * break request before we've finished decoding the reply and
410− * installing the vnode.
411− */
412− error = afs_register_server_cb_interest(vnode, fc->server_list,
413− fc->index);
414− if (error < 0)
415− goto failed_set_error;
416−
417− fc->cbi = afs_get_cb_interest(
418− rcu_dereference_protected(vnode->cb_interest,
419− lockdep_is_held(&vnode->io_lock)));
372+ op->flags |= AFS_OPERATION_RETRY_SERVER;
373+ op->server = server;
374+ if (vnode->cb_server != server) {
375+ vnode->cb_server = server;
376+ vnode->cb_s_break = server->cb_s_break;
377+ vnode->cb_v_break = vnode->volume->cb_v_break;
378+ clear_bit(AFS_VNODE_CB_PROMISED, &vnode->flags);
379+ }
420380
421381 read_lock(&server->fs_lock);
422382 alist = rcu_dereference_protected(server->addresses,
@@ -424,44 +384,68 @@ selected_server: · 1 unmodified line
424384 afs_get_addrlist(alist);
425385 read_unlock(&server->fs_lock);
426386
427− memset(&fc->ac, 0, sizeof(fc->ac));
387+retry_server:
388+ memset(&op->ac, 0, sizeof(op->ac));
428389
429− if (!fc->ac.alist)
430− fc->ac.alist = alist;
390+ if (!op->ac.alist)
391+ op->ac.alist = alist;
431392 else
432393 afs_put_addrlist(alist);
433394
434− fc->ac.index = -1;
395+ op->ac.index = -1;
435396
436397 iterate_address:
437− ASSERT(fc->ac.alist);
398+ ASSERT(op->ac.alist);
438399 /* Iterate over the current server's address list to try and find an
439400 * address on which it will respond to us.
440401 */
441− if (!afs_iterate_addresses(&fc->ac))
442− goto next_server;
402+ if (!afs_iterate_addresses(&op->ac))
403+ goto out_of_addresses;
443404
444− _debug("address [%u] %u/%u", fc->index, fc->ac.index, fc->ac.alist->nr_addrs);
405+ _debug("address [%u] %u/%u %pISp",
406+ op->index, op->ac.index, op->ac.alist->nr_addrs,
407+ &op->ac.alist->addrs[op->ac.index].transport);
445408
446409 _leave(" = t");
447410 return true;
448411
412+out_of_addresses:
413+ /* We've now had a failure to respond on all of a server's addresses -
414+ * immediately probe them again and consider retrying the server.
415+ */
416+ afs_probe_fileserver(op->net, op->server);
417+ if (op->flags & AFS_OPERATION_RETRY_SERVER) {
418+ alist = op->ac.alist;
419+ error = afs_wait_for_one_fs_probe(
420+ op->server, !(op->flags & AFS_OPERATION_UNINTR));
421+ switch (error) {
422+ case 0:
423+ op->flags &= ~AFS_OPERATION_RETRY_SERVER;
424+ goto retry_server;
425+ case -ERESTARTSYS:
426+ goto failed_set_error;
427+ case -ETIME:
428+ case -EDESTADDRREQ:
429+ goto next_server;
430+ }
431+ }
432+
449433 next_server:
450434 _debug("next");
451− afs_end_cursor(&fc->ac);
435+ afs_end_cursor(&op->ac);
452436 goto pick_server;
453437
454438 no_more_servers:
455439 /* That's all the servers poked to no good effect. Try again if some
456440 * of them were busy.
457441 */
458− if (fc->flags & AFS_FS_CURSOR_VBUSY)
442+ if (op->flags & AFS_OPERATION_VBUSY)
459443 goto restart_from_beginning;
460444
461445 e.error = -EDESTADDRREQ;
462446 e.responded = false;
463− for (i = 0; i < fc->server_list->nr_servers; i++) {
464− struct afs_server *s = fc->server_list->servers[i].server;
447+ for (i = 0; i < op->server_list->nr_servers; i++) {
448+ struct afs_server *s = op->server_list->servers[i].server;
465449
466450 afs_prioritise_error(&e, READ_ONCE(s->probe.error),
467451 s->probe.abort_code);
@@ -470,101 +454,18 @@ no_more_servers: · 2 unmodified lines
470454 error = e.error;
471455
472456 failed_set_error:
473− fc->error = error;
457+ op->error = error;
474458 failed:
475− fc->flags |= AFS_FS_CURSOR_STOP;
476− afs_end_cursor(&fc->ac);
477− _leave(" = f [failed %d]", fc->error);
478− return false;
479−}
480−
481−/*
482− * Select the same fileserver we used for a vnode before and only that
483− * fileserver. We use this when we have a lock on that file, which is backed
484− * only by the fileserver we obtained it from.
485− */
486−bool afs_select_current_fileserver(struct afs_fs_cursor *fc)
487−{
488− struct afs_vnode *vnode = fc->vnode;
489− struct afs_cb_interest *cbi;
490− struct afs_addr_list *alist;
491− int error = fc->ac.error;
492−
493− _enter("");
494−
495− cbi = rcu_dereference_protected(vnode->cb_interest,
496− lockdep_is_held(&vnode->io_lock));
497−
498− switch (error) {
499− case SHRT_MAX:
500− if (!cbi) {
501− fc->error = -ESTALE;
502− fc->flags |= AFS_FS_CURSOR_STOP;
503− return false;
504− }
505−
506− fc->cbi = afs_get_cb_interest(cbi);
507−
508− read_lock(&cbi->server->fs_lock);
509− alist = rcu_dereference_protected(cbi->server->addresses,
510− lockdep_is_held(&cbi->server->fs_lock));
511− afs_get_addrlist(alist);
512− read_unlock(&cbi->server->fs_lock);
513− if (!alist) {
514− fc->error = -ESTALE;
515− fc->flags |= AFS_FS_CURSOR_STOP;
516− return false;
517− }
518−
519− memset(&fc->ac, 0, sizeof(fc->ac));
520− fc->ac.alist = alist;
521− fc->ac.index = -1;
522− goto iterate_address;
523−
524− case 0:
525− default:
526− /* Success or local failure. Stop. */
527− fc->error = error;
528− fc->flags |= AFS_FS_CURSOR_STOP;
529− _leave(" = f [okay/local %d]", error);
530− return false;
531−
532− case -ECONNABORTED:
533− fc->error = afs_abort_to_error(fc->ac.abort_code);
534− fc->flags |= AFS_FS_CURSOR_STOP;
535− _leave(" = f [abort]");
536− return false;
537−
538− case -ERFKILL:
539− case -EADDRNOTAVAIL:
540− case -ENETUNREACH:
541− case -EHOSTUNREACH:
542− case -EHOSTDOWN:
543− case -ECONNREFUSED:
544− case -ETIMEDOUT:
545− case -ETIME:
546− _debug("no conn");
547− fc->error = error;
548− goto iterate_address;
549− }
550−
551−iterate_address:
552− /* Iterate over the current server's address list to try and find an
553− * address on which it will respond to us.
554− */
555− if (afs_iterate_addresses(&fc->ac)) {
556− _leave(" = t");
557− return true;
558− }
559−
560− afs_end_cursor(&fc->ac);
459+ op->flags |= AFS_OPERATION_STOP;
460+ afs_end_cursor(&op->ac);
461+ _leave(" = f [failed %d]", op->error);
561462 return false;
562463 }
563464
564465 /*
565466 * Dump cursor state in the case of the error being EDESTADDRREQ.
566467 */
567−static void afs_dump_edestaddrreq(const struct afs_fs_cursor *fc)
468+void afs_dump_edestaddrreq(const struct afs_operation *op)
568469 {
569470 static int count;
570471 int i;
@@ -576,13 +477,14 @@ static void afs_dump_edestaddrreq(const struct afs_fs_cursor *fc) · 5 unmodified lines
576477 rcu_read_lock();
577478
578479 pr_notice("EDESTADDR occurred\n");
579− pr_notice("FC: cbb=%x cbb2=%x fl=%hx err=%hd\n",
580− fc->cb_break, fc->cb_break_2, fc->flags, fc->error);
480+ pr_notice("FC: cbb=%x cbb2=%x fl=%x err=%hd\n",
481+ op->file[0].cb_break_before,
482+ op->file[1].cb_break_before, op->flags, op->error);
581483 pr_notice("FC: ut=%lx ix=%d ni=%u\n",
582− fc->untried, fc->index, fc->nr_iterations);
484+ op->untried, op->index, op->nr_iterations);
583485
584− if (fc->server_list) {
585− const struct afs_server_list *sl = fc->server_list;
486+ if (op->server_list) {
487+ const struct afs_server_list *sl = op->server_list;
586488 pr_notice("FC: SL nr=%u pr=%u vnov=%hx\n",
587489 sl->nr_servers, sl->preferred, sl->vnovol_mask);
588490 for (i = 0; i < sl->nr_servers; i++) {
@@ -596,41 +498,16 @@ static void afs_dump_edestaddrreq(const struct afs_fs_cursor *fc) · 7 unmodified lines
596498 a->version,
597499 a->nr_ipv4, a->nr_addrs, a->max_addrs,
598500 a->preferred);
599− pr_notice("FC: - pr=%lx R=%lx F=%lx\n",
600− a->probed, a->responded, a->failed);
601− if (a == fc->ac.alist)
501+ pr_notice("FC: - R=%lx F=%lx\n",
502+ a->responded, a->failed);
503+ if (a == op->ac.alist)
602504 pr_notice("FC: - current\n");
603505 }
604506 }
605507 }
606508
607509 pr_notice("AC: t=%lx ax=%u ac=%d er=%d r=%u ni=%u\n",
608− fc->ac.tried, fc->ac.index, fc->ac.abort_code, fc->ac.error,
609− fc->ac.responded, fc->ac.nr_iterations);
510+ op->ac.tried, op->ac.index, op->ac.abort_code, op->ac.error,
511+ op->ac.responded, op->ac.nr_iterations);
610512 rcu_read_unlock();
611513 }
612−
613−/*
614− * Tidy up a filesystem cursor and unlock the vnode.
615− */
616−int afs_end_vnode_operation(struct afs_fs_cursor *fc)
617−{
618− struct afs_net *net = afs_v2net(fc->vnode);
619−
620− if (fc->error == -EDESTADDRREQ ||
621− fc->error == -EADDRNOTAVAIL ||
622− fc->error == -ENETUNREACH ||
623− fc->error == -EHOSTUNREACH)
624− afs_dump_edestaddrreq(fc);
625−
626− mutex_unlock(&fc->vnode->io_lock);
627−
628− afs_end_cursor(&fc->ac);
629− afs_put_cb_interest(net, fc->cbi);
630− afs_put_serverlist(net, fc->server_list);
631−
632− if (fc->error == -ECONNABORTED)
633− fc->error = afs_abort_to_error(fc->ac.abort_code);
634−
635− return fc->error;
636−}
fs/afs/rxrpc.c+26−19
@@ -181,8 +181,7 @@ void afs_put_call(struct afs_call *call) · 180 unmodified lines
181181 if (call->type->destructor)
182182 call->type->destructor(call);
183183
184− afs_put_server(call->net, call->server, afs_server_trace_put_call);
185− afs_put_cb_interest(call->net, call->cbi);
184+ afs_unuse_server_notime(call->net, call->server, afs_server_trace_put_call);
186185 afs_put_addrlist(call->alist);
187186 kfree(call->request);
188187
@@ -281,18 +280,19 @@ static void afs_load_bvec(struct afs_call *call, struct msghdr *msg, · 92 unmodified lines
281280 struct bio_vec *bv, pgoff_t first, pgoff_t last,
282281 unsigned offset)
283282 {
283+ struct afs_operation *op = call->op;
284284 struct page *pages[AFS_BVEC_MAX];
285285 unsigned int nr, n, i, to, bytes = 0;
286286
287287 nr = min_t(pgoff_t, last - first + 1, AFS_BVEC_MAX);
288− n = find_get_pages_contig(call->mapping, first, nr, pages);
288+ n = find_get_pages_contig(op->store.mapping, first, nr, pages);
289289 ASSERTCMP(n, ==, nr);
290290
291291 msg->msg_flags |= MSG_MORE;
292292 for (i = 0; i < nr; i++) {
293293 to = PAGE_SIZE;
294294 if (first + i >= last) {
295− to = call->last_to;
295+ to = op->store.last_to;
296296 msg->msg_flags &= ~MSG_MORE;
297297 }
298298 bv[i].bv_page = pages[i];
@@ -322,13 +322,14 @@ static void afs_notify_end_request_tx(struct sock *sock, · 23 unmodified lines
322322 */
323323 static int afs_send_pages(struct afs_call *call, struct msghdr *msg)
324324 {
325+ struct afs_operation *op = call->op;
325326 struct bio_vec bv[AFS_BVEC_MAX];
326327 unsigned int bytes, nr, loop, offset;
327− pgoff_t first = call->first, last = call->last;
328+ pgoff_t first = op->store.first, last = op->store.last;
328329 int ret;
329330
330− offset = call->first_offset;
331− call->first_offset = 0;
331+ offset = op->store.first_offset;
332+ op->store.first_offset = 0;
332333
333334 do {
334335 afs_load_bvec(call, msg, bv, first, last, offset);
@@ -338,7 +339,7 @@ static int afs_send_pages(struct afs_call *call, struct msghdr *msg) · 3 unmodified lines
338339 bytes = msg->msg_iter.count;
339340 nr = msg->msg_iter.nr_segs;
340341
341− ret = rxrpc_kernel_send_data(call->net->socket, call->rxcall, msg,
342+ ret = rxrpc_kernel_send_data(op->net->socket, call->rxcall, msg,
342343 bytes, afs_notify_end_request_tx);
343344 for (loop = 0; loop < nr; loop++)
344345 put_page(bv[loop].bv_page);
@@ -348,7 +349,7 @@ static int afs_send_pages(struct afs_call *call, struct msghdr *msg) · 3 unmodified lines
348349 first += nr;
349350 } while (first <= last);
350351
351− trace_afs_sent_pages(call, call->first, last, first, ret);
352+ trace_afs_sent_pages(call, op->store.first, last, first, ret);
352353 return ret;
353354 }
354355
@@ -383,16 +384,18 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp) · 28 unmodified lines
383384 */
384385 tx_total_len = call->request_size;
385386 if (call->send_pages) {
386− if (call->last == call->first) {
387− tx_total_len += call->last_to - call->first_offset;
387+ struct afs_operation *op = call->op;
388+
389+ if (op->store.last == op->store.first) {
390+ tx_total_len += op->store.last_to - op->store.first_offset;
388391 } else {
389392 /* It looks mathematically like you should be able to
390393 * combine the following lines with the ones above, but
391394 * unsigned arithmetic is fun when it wraps...
392395 */
393− tx_total_len += PAGE_SIZE - call->first_offset;
394− tx_total_len += call->last_to;
395− tx_total_len += (call->last - call->first - 1) * PAGE_SIZE;
396+ tx_total_len += PAGE_SIZE - op->store.first_offset;
397+ tx_total_len += op->store.last_to;
398+ tx_total_len += (op->store.last - op->store.first - 1) * PAGE_SIZE;
396399 }
397400 }
398401
@@ -538,13 +541,15 @@ static void afs_deliver_to_call(struct afs_call *call) · 139 unmodified lines
538541
539542 ret = call->type->deliver(call);
540543 state = READ_ONCE(call->state);
544+ if (ret == 0 && call->unmarshalling_error)
545+ ret = -EBADMSG;
541546 switch (ret) {
542547 case 0:
543548 afs_queue_call_work(call);
544549 if (state == AFS_CALL_CL_PROC_REPLY) {
545− if (call->cbi)
550+ if (call->op)
546551 set_bit(AFS_SERVER_FL_MAY_HAVE_CB,
547− &call->cbi->server->flags);
552+ &call->op->server->flags);
548553 goto call_complete;
549554 }
550555 ASSERTCMP(state, >, AFS_CALL_CL_PROC_REPLY);
@@ -957,9 +962,11 @@ int afs_extract_data(struct afs_call *call, bool want_more) · 406 unmodified lines
957962 /*
958963 * Log protocol error production.
959964 */
960−noinline int afs_protocol_error(struct afs_call *call, int error,
965+noinline int afs_protocol_error(struct afs_call *call,
961966 enum afs_eproto_cause cause)
962967 {
963− trace_afs_protocol_error(call, error, cause);
964− return error;
968+ trace_afs_protocol_error(call, cause);
969+ if (call)
970+ call->unmarshalling_error = true;
971+ return -EBADMSG;
965972 }
fs/afs/security.c+3−5
@@ -170,8 +170,7 @@ void afs_cache_permit(struct afs_vnode *vnode, struct key *key, · 169 unmodified lines
170170 break;
171171 }
172172
173− if (afs_cb_is_broken(cb_break, vnode,
174− rcu_dereference(vnode->cb_interest))) {
173+ if (afs_cb_is_broken(cb_break, vnode)) {
175174 changed = true;
176175 break;
177176 }
@@ -201,7 +200,7 @@ void afs_cache_permit(struct afs_vnode *vnode, struct key *key, · 23 unmodified lines
201200 }
202201 }
203202
204− if (afs_cb_is_broken(cb_break, vnode, rcu_dereference(vnode->cb_interest)))
203+ if (afs_cb_is_broken(cb_break, vnode))
205204 goto someone_else_changed_it;
206205
207206 /* We need a ref on any permits list we want to copy as we'll have to
@@ -281,8 +280,7 @@ found: · 73 unmodified lines
281280 rcu_read_lock();
282281 spin_lock(&vnode->lock);
283282 zap = rcu_access_pointer(vnode->permit_cache);
284− if (!afs_cb_is_broken(cb_break, vnode, rcu_dereference(vnode->cb_interest)) &&
285− zap == permits)
283+ if (!afs_cb_is_broken(cb_break, vnode) && zap == permits)
286284 rcu_assign_pointer(vnode->permit_cache, replacement);
287285 else
288286 zap = replacement;
fs/afs/server.c+197−102
@@ -12,19 +12,11 @@ · 11 unmodified lines
1212 #include "protocol_yfs.h"
1313
1414 static unsigned afs_server_gc_delay = 10; /* Server record timeout in seconds */
15−static unsigned afs_server_update_delay = 30; /* Time till VLDB recheck in secs */
1615 static atomic_t afs_server_debug_id;
1716
18−static void afs_inc_servers_outstanding(struct afs_net *net)
19−{
20− atomic_inc(&net->servers_outstanding);
21−}
22−
23−static void afs_dec_servers_outstanding(struct afs_net *net)
24−{
25− if (atomic_dec_and_test(&net->servers_outstanding))
26− wake_up_var(&net->servers_outstanding);
27−}
17+static struct afs_server *afs_maybe_use_server(struct afs_server *,
18+ enum afs_server_trace);
19+static void __afs_put_server(struct afs_net *, struct afs_server *);
2820
2921 /*
3022 * Find a server by one of its addresses.
@@ -41,7 +33,7 @@ struct afs_server *afs_find_server(struct afs_net *net, · 10 unmodified lines
4133
4234 do {
4335 if (server)
44− afs_put_server(net, server, afs_server_trace_put_find_rsq);
36+ afs_unuse_server_notime(net, server, afs_server_trace_put_find_rsq);
4537 server = NULL;
4638 read_seqbegin_or_lock(&net->fs_addr_lock, &seq);
4739
@@ -79,9 +71,9 @@ struct afs_server *afs_find_server(struct afs_net *net, · 31 unmodified lines
7971 }
8072
8173 server = NULL;
74+ continue;
8275 found:
83− if (server && !atomic_inc_not_zero(&server->usage))
84− server = NULL;
76+ server = afs_maybe_use_server(server, afs_server_trace_get_by_addr);
8577
8678 } while (need_seqretry(&net->fs_addr_lock, seq));
8779
@@ -92,7 +84,7 @@ struct afs_server *afs_find_server(struct afs_net *net, · 4 unmodified lines
9284 }
9385
9486 /*
95− * Look up a server by its UUID
87+ * Look up a server by its UUID and mark it active.
9688 */
9789 struct afs_server *afs_find_server_by_uuid(struct afs_net *net, const uuid_t *uuid)
9890 {
@@ -108,7 +100,7 @@ struct afs_server *afs_find_server_by_uuid(struct afs_net *net, const uuid_t *uu · 9 unmodified lines
108100 * changes.
109101 */
110102 if (server)
111− afs_put_server(net, server, afs_server_trace_put_uuid_rsq);
103+ afs_unuse_server(net, server, afs_server_trace_put_uuid_rsq);
112104 server = NULL;
113105
114106 read_seqbegin_or_lock(&net->fs_lock, &seq);
@@ -123,7 +115,7 @@ struct afs_server *afs_find_server_by_uuid(struct afs_net *net, const uuid_t *uu · 8 unmodified lines
123115 } else if (diff > 0) {
124116 p = p->rb_right;
125117 } else {
126− afs_get_server(server, afs_server_trace_get_by_uuid);
118+ afs_use_server(server, afs_server_trace_get_by_uuid);
127119 break;
128120 }
129121
@@ -138,13 +130,16 @@ struct afs_server *afs_find_server_by_uuid(struct afs_net *net, const uuid_t *uu · 8 unmodified lines
138130 }
139131
140132 /*
141− * Install a server record in the namespace tree
133+ * Install a server record in the namespace tree. If there's a clash, we stick
134+ * it into a list anchored on whichever afs_server struct is actually in the
135+ * tree.
142136 */
143−static struct afs_server *afs_install_server(struct afs_net *net,
137+static struct afs_server *afs_install_server(struct afs_cell *cell,
144138 struct afs_server *candidate)
145139 {
146140 const struct afs_addr_list *alist;
147− struct afs_server *server;
141+ struct afs_server *server, *next;
142+ struct afs_net *net = cell->net;
148143 struct rb_node **pp, *p;
149144 int diff;
150145
@@ -160,12 +155,30 @@ static struct afs_server *afs_install_server(struct afs_net *net, · 9 unmodified lines
160155 _debug("- consider %p", p);
161156 server = rb_entry(p, struct afs_server, uuid_rb);
162157 diff = memcmp(&candidate->uuid, &server->uuid, sizeof(uuid_t));
163− if (diff < 0)
158+ if (diff < 0) {
164159 pp = &(*pp)->rb_left;
165− else if (diff > 0)
160+ } else if (diff > 0) {
166161 pp = &(*pp)->rb_right;
167− else
168− goto exists;
162+ } else {
163+ if (server->cell == cell)
164+ goto exists;
165+
166+ /* We have the same UUID representing servers in
167+ * different cells. Append the new server to the list.
168+ */
169+ for (;;) {
170+ next = rcu_dereference_protected(
171+ server->uuid_next,
172+ lockdep_is_held(&net->fs_lock.lock));
173+ if (!next)
174+ break;
175+ server = next;
176+ }
177+ rcu_assign_pointer(server->uuid_next, candidate);
178+ candidate->uuid_prev = server;
179+ server = candidate;
180+ goto added_dup;
181+ }
169182 }
170183
171184 server = candidate;
@@ -173,6 +186,7 @@ static struct afs_server *afs_install_server(struct afs_net *net, · 1 unmodified line
173186 rb_insert_color(&server->uuid_rb, &net->fs_servers);
174187 hlist_add_head_rcu(&server->proc_link, &net->fs_proc);
175188
189+added_dup:
176190 write_seqlock(&net->fs_addr_lock);
177191 alist = rcu_dereference_protected(server->addresses,
178192 lockdep_is_held(&net->fs_addr_lock.lock));
@@ -199,13 +213,14 @@ exists: · 20 unmodified lines
199213 }
200214
201215 /*
202− * allocate a new server record
216+ * Allocate a new server record and mark it active.
203217 */
204−static struct afs_server *afs_alloc_server(struct afs_net *net,
218+static struct afs_server *afs_alloc_server(struct afs_cell *cell,
205219 const uuid_t *uuid,
206220 struct afs_addr_list *alist)
207221 {
208222 struct afs_server *server;
223+ struct afs_net *net = cell->net;
209224
210225 _enter("");
211226
@@ -213,20 +228,21 @@ static struct afs_server *afs_alloc_server(struct afs_net *net, · 1 unmodified line
213228 if (!server)
214229 goto enomem;
215230
216− atomic_set(&server->usage, 1);
231+ atomic_set(&server->ref, 1);
232+ atomic_set(&server->active, 1);
217233 server->debug_id = atomic_inc_return(&afs_server_debug_id);
218234 RCU_INIT_POINTER(server->addresses, alist);
219235 server->addr_version = alist->version;
220236 server->uuid = *uuid;
221− server->update_at = ktime_get_real_seconds() + afs_server_update_delay;
222237 rwlock_init(&server->fs_lock);
223− INIT_HLIST_HEAD(&server->cb_volumes);
224− rwlock_init(&server->cb_break_lock);
225238 init_waitqueue_head(&server->probe_wq);
239+ INIT_LIST_HEAD(&server->probe_link);
226240 spin_lock_init(&server->probe_lock);
241+ server->cell = cell;
242+ server->rtt = UINT_MAX;
227243
228244 afs_inc_servers_outstanding(net);
229− trace_afs_server(server, 1, afs_server_trace_alloc);
245+ trace_afs_server(server, 1, 1, afs_server_trace_alloc);
230246 _leave(" = %p", server);
231247 return server;
232248
@@ -264,7 +280,7 @@ static struct afs_addr_list *afs_vl_lookup_addrs(struct afs_cell *cell, · 31 unmodified lines
264280 * Get or create a fileserver record.
265281 */
266282 struct afs_server *afs_lookup_server(struct afs_cell *cell, struct key *key,
267− const uuid_t *uuid)
283+ const uuid_t *uuid, u32 addr_version)
268284 {
269285 struct afs_addr_list *alist;
270286 struct afs_server *server, *candidate;
@@ -272,26 +288,34 @@ struct afs_server *afs_lookup_server(struct afs_cell *cell, struct key *key, · 1 unmodified line
272288 _enter("%p,%pU", cell->net, uuid);
273289
274290 server = afs_find_server_by_uuid(cell->net, uuid);
275− if (server)
291+ if (server) {
292+ if (server->addr_version != addr_version)
293+ set_bit(AFS_SERVER_FL_NEEDS_UPDATE, &server->flags);
276294 return server;
295+ }
277296
278297 alist = afs_vl_lookup_addrs(cell, key, uuid);
279298 if (IS_ERR(alist))
280299 return ERR_CAST(alist);
281300
282− candidate = afs_alloc_server(cell->net, uuid, alist);
301+ candidate = afs_alloc_server(cell, uuid, alist);
283302 if (!candidate) {
284303 afs_put_addrlist(alist);
285304 return ERR_PTR(-ENOMEM);
286305 }
287306
288− server = afs_install_server(cell->net, candidate);
307+ server = afs_install_server(cell, candidate);
289308 if (server != candidate) {
290309 afs_put_addrlist(alist);
291310 kfree(candidate);
311+ } else {
312+ /* Immediately dispatch an asynchronous probe to each interface
313+ * on the fileserver. This will make sure the repeat-probing
314+ * service is started.
315+ */
316+ afs_fs_probe_fileserver(cell->net, server, key, true);
292317 }
293318
294− _leave(" = %p{%d}", server, atomic_read(&server->usage));
295319 return server;
296320 }
297321
@@ -327,9 +351,38 @@ void afs_servers_timer(struct timer_list *timer) · 29 unmodified lines
327351 struct afs_server *afs_get_server(struct afs_server *server,
328352 enum afs_server_trace reason)
329353 {
330− unsigned int u = atomic_inc_return(&server->usage);
354+ unsigned int u = atomic_inc_return(&server->ref);
355+
356+ trace_afs_server(server, u, atomic_read(&server->active), reason);
357+ return server;
358+}
359+
360+/*
361+ * Try to get a reference on a server object.
362+ */
363+static struct afs_server *afs_maybe_use_server(struct afs_server *server,
364+ enum afs_server_trace reason)
365+{
366+ unsigned int r = atomic_fetch_add_unless(&server->ref, 1, 0);
367+ unsigned int a;
368+
369+ if (r == 0)
370+ return NULL;
371+
372+ a = atomic_inc_return(&server->active);
373+ trace_afs_server(server, r, a, reason);
374+ return server;
375+}
376+
377+/*
378+ * Get an active count on a server object.
379+ */
380+struct afs_server *afs_use_server(struct afs_server *server, enum afs_server_trace reason)
381+{
382+ unsigned int r = atomic_inc_return(&server->ref);
383+ unsigned int a = atomic_inc_return(&server->active);
331384
332− trace_afs_server(server, u, reason);
385+ trace_afs_server(server, r, a, reason);
333386 return server;
334387 }
335388
@@ -344,32 +397,57 @@ void afs_put_server(struct afs_net *net, struct afs_server *server, · 8 unmodified lines
344397 if (!server)
345398 return;
346399
347− server->put_time = ktime_get_real_seconds();
348−
349− usage = atomic_dec_return(&server->usage);
400+ usage = atomic_dec_return(&server->ref);
401+ trace_afs_server(server, usage, atomic_read(&server->active), reason);
402+ if (unlikely(usage == 0))
403+ __afs_put_server(net, server);
404+}
350405
351− trace_afs_server(server, usage, reason);
406+/*
407+ * Drop an active count on a server object without updating the last-unused
408+ * time.
409+ */
410+void afs_unuse_server_notime(struct afs_net *net, struct afs_server *server,
411+ enum afs_server_trace reason)
412+{
413+ if (server) {
414+ unsigned int active = atomic_dec_return(&server->active);
352415
353− if (likely(usage > 0))
354− return;
416+ if (active == 0)
417+ afs_set_server_timer(net, afs_server_gc_delay);
418+ afs_put_server(net, server, reason);
419+ }
420+}
355421
356− afs_set_server_timer(net, afs_server_gc_delay);
422+/*
423+ * Drop an active count on a server object.
424+ */
425+void afs_unuse_server(struct afs_net *net, struct afs_server *server,
426+ enum afs_server_trace reason)
427+{
428+ if (server) {
429+ server->unuse_time = ktime_get_real_seconds();
430+ afs_unuse_server_notime(net, server, reason);
431+ }
357432 }
358433
359434 static void afs_server_rcu(struct rcu_head *rcu)
360435 {
361436 struct afs_server *server = container_of(rcu, struct afs_server, rcu);
362437
363− trace_afs_server(server, atomic_read(&server->usage),
364− afs_server_trace_free);
438+ trace_afs_server(server, atomic_read(&server->ref),
439+ atomic_read(&server->active), afs_server_trace_free);
365440 afs_put_addrlist(rcu_access_pointer(server->addresses));
366441 kfree(server);
367442 }
368443
369−/*
370− * destroy a dead server
371− */
372−static void afs_destroy_server(struct afs_net *net, struct afs_server *server)
444+static void __afs_put_server(struct afs_net *net, struct afs_server *server)
445+{
446+ call_rcu(&server->rcu, afs_server_rcu);
447+ afs_dec_servers_outstanding(net);
448+}
449+
450+static void afs_give_up_callbacks(struct afs_net *net, struct afs_server *server)
373451 {
374452 struct afs_addr_list *alist = rcu_access_pointer(server->addresses);
375453 struct afs_addr_cursor ac = {
@@ -378,19 +456,18 @@ static void afs_destroy_server(struct afs_net *net, struct afs_server *server) · 2 unmodified lines
378456 .error = 0,
379457 };
380458
381− trace_afs_server(server, atomic_read(&server->usage),
382− afs_server_trace_give_up_cb);
459+ afs_fs_give_up_all_callbacks(net, server, &ac, NULL);
460+}
383461
462+/*
463+ * destroy a dead server
464+ */
465+static void afs_destroy_server(struct afs_net *net, struct afs_server *server)
466+{
384467 if (test_bit(AFS_SERVER_FL_MAY_HAVE_CB, &server->flags))
385− afs_fs_give_up_all_callbacks(net, server, &ac, NULL);
468+ afs_give_up_callbacks(net, server);
386469
387− wait_var_event(&server->probe_outstanding,
388− atomic_read(&server->probe_outstanding) == 0);
389−
390− trace_afs_server(server, atomic_read(&server->usage),
391− afs_server_trace_destroy);
392− call_rcu(&server->rcu, afs_server_rcu);
393− afs_dec_servers_outstanding(net);
470+ afs_put_server(net, server, afs_server_trace_destroy);
394471 }
395472
396473 /*
@@ -398,32 +475,49 @@ static void afs_destroy_server(struct afs_net *net, struct afs_server *server) · 1 unmodified line
398475 */
399476 static void afs_gc_servers(struct afs_net *net, struct afs_server *gc_list)
400477 {
401− struct afs_server *server;
402− bool deleted;
403− int usage;
478+ struct afs_server *server, *next, *prev;
479+ int active;
404480
405481 while ((server = gc_list)) {
406482 gc_list = server->gc_next;
407483
408484 write_seqlock(&net->fs_lock);
409− usage = 1;
410− deleted = atomic_try_cmpxchg(&server->usage, &usage, 0);
411− trace_afs_server(server, usage, afs_server_trace_gc);
412− if (deleted) {
413− rb_erase(&server->uuid_rb, &net->fs_servers);
414− hlist_del_rcu(&server->proc_link);
415− }
416− write_sequnlock(&net->fs_lock);
417485
418− if (deleted) {
419− write_seqlock(&net->fs_addr_lock);
486+ active = atomic_read(&server->active);
487+ if (active == 0) {
488+ trace_afs_server(server, atomic_read(&server->ref),
489+ active, afs_server_trace_gc);
490+ next = rcu_dereference_protected(
491+ server->uuid_next, lockdep_is_held(&net->fs_lock.lock));
492+ prev = server->uuid_prev;
493+ if (!prev) {
494+ /* The one at the front is in the tree */
495+ if (!next) {
496+ rb_erase(&server->uuid_rb, &net->fs_servers);
497+ } else {
498+ rb_replace_node_rcu(&server->uuid_rb,
499+ &next->uuid_rb,
500+ &net->fs_servers);
501+ next->uuid_prev = NULL;
502+ }
503+ } else {
504+ /* This server is not at the front */
505+ rcu_assign_pointer(prev->uuid_next, next);
506+ if (next)
507+ next->uuid_prev = prev;
508+ }
509+
510+ list_del(&server->probe_link);
511+ hlist_del_rcu(&server->proc_link);
420512 if (!hlist_unhashed(&server->addr4_link))
421513 hlist_del_rcu(&server->addr4_link);
422514 if (!hlist_unhashed(&server->addr6_link))
423515 hlist_del_rcu(&server->addr6_link);
424− write_sequnlock(&net->fs_addr_lock);
425− afs_destroy_server(net, server);
426516 }
517+ write_sequnlock(&net->fs_lock);
518+
519+ if (active == 0)
520+ afs_destroy_server(net, server);
427521 }
428522 }
429523
@@ -452,15 +546,14 @@ void afs_manage_servers(struct work_struct *work) · 22 unmodified lines
452546 for (cursor = rb_first(&net->fs_servers); cursor; cursor = rb_next(cursor)) {
453547 struct afs_server *server =
454548 rb_entry(cursor, struct afs_server, uuid_rb);
455− int usage = atomic_read(&server->usage);
549+ int active = atomic_read(&server->active);
456550
457− _debug("manage %pU %u", &server->uuid, usage);
551+ _debug("manage %pU %u", &server->uuid, active);
458552
459− ASSERTCMP(usage, >=, 1);
460− ASSERTIFCMP(purging, usage, ==, 1);
553+ ASSERTIFCMP(purging, active, ==, 0);
461554
462− if (usage == 1) {
463− time64_t expire_at = server->put_time;
555+ if (active == 0) {
556+ time64_t expire_at = server->unuse_time;
464557
465558 if (!test_bit(AFS_SERVER_FL_VL_FAIL, &server->flags) &&
466559 !test_bit(AFS_SERVER_FL_NOT_FOUND, &server->flags))
@@ -525,26 +618,27 @@ void afs_purge_servers(struct afs_net *net) · 58 unmodified lines
525618 /*
526619 * Get an update for a server's address list.
527620 */
528−static noinline bool afs_update_server_record(struct afs_fs_cursor *fc, struct afs_server *server)
621+static noinline bool afs_update_server_record(struct afs_operation *op,
622+ struct afs_server *server)
529623 {
530624 struct afs_addr_list *alist, *discard;
531625
532626 _enter("");
533627
534− trace_afs_server(server, atomic_read(&server->usage), afs_server_trace_update);
628+ trace_afs_server(server, atomic_read(&server->ref), atomic_read(&server->active),
629+ afs_server_trace_update);
535630
536− alist = afs_vl_lookup_addrs(fc->vnode->volume->cell, fc->key,
537− &server->uuid);
631+ alist = afs_vl_lookup_addrs(op->volume->cell, op->key, &server->uuid);
538632 if (IS_ERR(alist)) {
539633 if ((PTR_ERR(alist) == -ERESTARTSYS ||
540634 PTR_ERR(alist) == -EINTR) &&
541− !(fc->flags & AFS_FS_CURSOR_INTR) &&
635+ (op->flags & AFS_OPERATION_UNINTR) &&
542636 server->addresses) {
543637 _leave(" = t [intr]");
544638 return true;
545639 }
546− fc->error = PTR_ERR(alist);
547− _leave(" = f [%d]", fc->error);
640+ op->error = PTR_ERR(alist);
641+ _leave(" = f [%d]", op->error);
548642 return false;
549643 }
550644
@@ -558,7 +652,6 @@ static noinline bool afs_update_server_record(struct afs_fs_cursor *fc, struct a · 7 unmodified lines
558652 write_unlock(&server->fs_lock);
559653 }
560654
561− server->update_at = ktime_get_real_seconds() + afs_server_update_delay;
562655 afs_put_addrlist(discard);
563656 _leave(" = t");
564657 return true;
@@ -567,10 +660,8 @@ static noinline bool afs_update_server_record(struct afs_fs_cursor *fc, struct a · 2 unmodified lines
567660 /*
568661 * See if a server's address list needs updating.
569662 */
570−bool afs_check_server_record(struct afs_fs_cursor *fc, struct afs_server *server)
663+bool afs_check_server_record(struct afs_operation *op, struct afs_server *server)
571664 {
572− time64_t now = ktime_get_real_seconds();
573− long diff;
574665 bool success;
575666 int ret, retries = 0;
576667
@@ -579,25 +670,29 @@ bool afs_check_server_record(struct afs_fs_cursor *fc, struct afs_server *server · 2 unmodified lines
579670 ASSERT(server);
580671
581672 retry:
582− diff = READ_ONCE(server->update_at) - now;
583− if (diff > 0) {
584− _leave(" = t [not now %ld]", diff);
585− return true;
586− }
673+ if (test_bit(AFS_SERVER_FL_UPDATING, &server->flags))
674+ goto wait;
675+ if (test_bit(AFS_SERVER_FL_NEEDS_UPDATE, &server->flags))
676+ goto update;
677+ _leave(" = t [good]");
678+ return true;
587679
680+update:
588681 if (!test_and_set_bit_lock(AFS_SERVER_FL_UPDATING, &server->flags)) {
589− success = afs_update_server_record(fc, server);
682+ clear_bit(AFS_SERVER_FL_NEEDS_UPDATE, &server->flags);
683+ success = afs_update_server_record(op, server);
590684 clear_bit_unlock(AFS_SERVER_FL_UPDATING, &server->flags);
591685 wake_up_bit(&server->flags, AFS_SERVER_FL_UPDATING);
592686 _leave(" = %d", success);
593687 return success;
594688 }
595689
690+wait:
596691 ret = wait_on_bit(&server->flags, AFS_SERVER_FL_UPDATING,
597− (fc->flags & AFS_FS_CURSOR_INTR) ?
598− TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE);
692+ (op->flags & AFS_OPERATION_UNINTR) ?
693+ TASK_UNINTERRUPTIBLE : TASK_INTERRUPTIBLE);
599694 if (ret == -ERESTARTSYS) {
600− fc->error = ret;
695+ op->error = ret;
601696 _leave(" = f [intr]");
602697 return false;
603698 }
fs/afs/server_list.c+8−32
@@ -14,11 +14,9 @@ void afs_put_serverlist(struct afs_net *net, struct afs_server_list *slist) · 13 unmodified lines
1414 int i;
1515
1616 if (slist && refcount_dec_and_test(&slist->usage)) {
17− for (i = 0; i < slist->nr_servers; i++) {
18− afs_put_cb_interest(net, slist->servers[i].cb_interest);
19− afs_put_server(net, slist->servers[i].server,
20− afs_server_trace_put_slist);
21− }
17+ for (i = 0; i < slist->nr_servers; i++)
18+ afs_unuse_server(net, slist->servers[i].server,
19+ afs_server_trace_put_slist);
2220 kfree(slist);
2321 }
2422 }
@@ -46,12 +44,16 @@ struct afs_server_list *afs_alloc_server_list(struct afs_cell *cell, · 21 unmodified lines
4644 refcount_set(&slist->usage, 1);
4745 rwlock_init(&slist->lock);
4846
47+ for (i = 0; i < AFS_MAXTYPES; i++)
48+ slist->vids[i] = vldb->vid[i];
49+
4950 /* Make sure a records exists for each server in the list. */
5051 for (i = 0; i < vldb->nr_servers; i++) {
5152 if (!(vldb->fs_mask[i] & type_mask))
5253 continue;
5354
54− server = afs_lookup_server(cell, key, &vldb->fs_server[i]);
55+ server = afs_lookup_server(cell, key, &vldb->fs_server[i],
56+ vldb->addr_version[i]);
5557 if (IS_ERR(server)) {
5658 ret = PTR_ERR(server);
5759 if (ret == -ENOENT ||
@@ -123,31 +125,5 @@ changed: · 65 unmodified lines
123125 }
124126 }
125127
126− /* Keep the old callback interest records where possible so that we
127− * maintain callback interception.
128− */
129− i = 0;
130− j = 0;
131− while (i < old->nr_servers && j < new->nr_servers) {
132− if (new->servers[j].server == old->servers[i].server) {
133− struct afs_cb_interest *cbi = old->servers[i].cb_interest;
134− if (cbi) {
135− new->servers[j].cb_interest = cbi;
136− refcount_inc(&cbi->usage);
137− }
138− i++;
139− j++;
140− continue;
141− }
142−
143− if (new->servers[j].server < old->servers[i].server) {
144− j++;
145− continue;
146− }
147−
148− i++;
149− continue;
150− }
151−
152128 return true;
153129 }
fs/afs/super.c+59−48
@@ -352,7 +352,9 @@ static int afs_validate_fc(struct fs_context *fc) · 351 unmodified lines
352352 {
353353 struct afs_fs_context *ctx = fc->fs_private;
354354 struct afs_volume *volume;
355+ struct afs_cell *cell;
355356 struct key *key;
357+ int ret;
356358
357359 if (!ctx->dyn_root) {
358360 if (ctx->no_cell) {
@@ -365,6 +367,7 @@ static int afs_validate_fc(struct fs_context *fc) · 6 unmodified lines
365367 return -EDESTADDRREQ;
366368 }
367369
370+ reget_key:
368371 /* We try to do the mount securely. */
369372 key = afs_request_key(ctx->cell);
370373 if (IS_ERR(key))
@@ -373,10 +376,26 @@ static int afs_validate_fc(struct fs_context *fc) · 2 unmodified lines
373376 ctx->key = key;
374377
375378 if (ctx->volume) {
376− afs_put_volume(ctx->cell, ctx->volume);
379+ afs_put_volume(ctx->net, ctx->volume,
380+ afs_volume_trace_put_validate_fc);
377381 ctx->volume = NULL;
378382 }
379383
384+ if (test_bit(AFS_CELL_FL_CHECK_ALIAS, &ctx->cell->flags)) {
385+ ret = afs_cell_detect_alias(ctx->cell, key);
386+ if (ret < 0)
387+ return ret;
388+ if (ret == 1) {
389+ _debug("switch to alias");
390+ key_put(ctx->key);
391+ ctx->key = NULL;
392+ cell = afs_get_cell(ctx->cell->alias_of);
393+ afs_put_cell(ctx->net, ctx->cell);
394+ ctx->cell = cell;
395+ goto reget_key;
396+ }
397+ }
398+
380399 volume = afs_create_volume(ctx);
381400 if (IS_ERR(volume))
382401 return PTR_ERR(volume);
@@ -421,7 +440,6 @@ static int afs_set_super(struct super_block *sb, struct fs_context *fc) · 38 unmodified lines
421440 static int afs_fill_super(struct super_block *sb, struct afs_fs_context *ctx)
422441 {
423442 struct afs_super_info *as = AFS_FS_S(sb);
424− struct afs_iget_data iget_data;
425443 struct inode *inode = NULL;
426444 int ret;
427445
@@ -446,13 +464,7 @@ static int afs_fill_super(struct super_block *sb, struct afs_fs_context *ctx) · 18 unmodified lines
446464 } else {
447465 sprintf(sb->s_id, "%llu", as->volume->vid);
448466 afs_activate_volume(as->volume);
449− iget_data.fid.vid = as->volume->vid;
450− iget_data.fid.vnode = 1;
451− iget_data.fid.vnode_hi = 0;
452− iget_data.fid.unique = 1;
453− iget_data.cb_v_break = as->volume->cb_v_break;
454− iget_data.cb_s_break = 0;
455− inode = afs_iget(sb, ctx->key, &iget_data, NULL, NULL, NULL);
467+ inode = afs_root_iget(sb, ctx->key);
456468 }
457469
458470 if (IS_ERR(inode))
@@ -473,6 +485,7 @@ static int afs_fill_super(struct super_block *sb, struct afs_fs_context *ctx) · 14 unmodified lines
473485 goto error;
474486 } else {
475487 sb->s_d_op = &afs_fs_dentry_operations;
488+ rcu_assign_pointer(as->volume->sb, sb);
476489 }
477490
478491 _leave(" = 0");
@@ -496,7 +509,8 @@ static struct afs_super_info *afs_alloc_sbi(struct fs_context *fc) · 17 unmodified lines
496509 as->dyn_root = true;
497510 } else {
498511 as->cell = afs_get_cell(ctx->cell);
499− as->volume = __afs_get_volume(ctx->volume);
512+ as->volume = afs_get_volume(ctx->volume,
513+ afs_volume_trace_get_alloc_sbi);
500514 }
501515 }
502516 return as;
@@ -505,8 +519,9 @@ static struct afs_super_info *afs_alloc_sbi(struct fs_context *fc) · 2 unmodified lines
505519 static void afs_destroy_sbi(struct afs_super_info *as)
506520 {
507521 if (as) {
508− afs_put_volume(as->cell, as->volume);
509− afs_put_cell(afs_net(as->net_ns), as->cell);
522+ struct afs_net *net = afs_net(as->net_ns);
523+ afs_put_volume(net, as->volume, afs_volume_trace_put_destroy_sbi);
524+ afs_put_cell(net, as->cell);
510525 put_net(as->net_ns);
511526 kfree(as);
512527 }
@@ -515,7 +530,6 @@ static void afs_destroy_sbi(struct afs_super_info *as) · 2 unmodified lines
515530 static void afs_kill_super(struct super_block *sb)
516531 {
517532 struct afs_super_info *as = AFS_FS_S(sb);
518− struct afs_net *net = afs_net(as->net_ns);
519533
520534 if (as->dyn_root)
521535 afs_dynroot_depopulate(sb);
@@ -524,7 +538,7 @@ static void afs_kill_super(struct super_block *sb) · 2 unmodified lines
524538 * deactivating the superblock.
525539 */
526540 if (as->volume)
527− afs_clear_callback_interests(net, as->volume->servers);
541+ rcu_assign_pointer(as->volume->sb, NULL);
528542 kill_anon_super(sb);
529543 if (as->volume)
530544 afs_deactivate_volume(as->volume);
@@ -592,7 +606,7 @@ static void afs_free_fc(struct fs_context *fc) · 61 unmodified lines
592606 struct afs_fs_context *ctx = fc->fs_private;
593607
594608 afs_destroy_sbi(fc->s_fs_info);
595− afs_put_volume(ctx->cell, ctx->volume);
609+ afs_put_volume(ctx->net, ctx->volume, afs_volume_trace_put_free_fc);
596610 afs_put_cell(ctx->net, ctx->cell);
597611 key_put(ctx->key);
598612 kfree(ctx);
@@ -674,7 +688,6 @@ static struct inode *afs_alloc_inode(struct super_block *sb) · 75 unmodified lines
674688 vnode->volume = NULL;
675689 vnode->lock_key = NULL;
676690 vnode->permit_cache = NULL;
677− RCU_INIT_POINTER(vnode->cb_interest, NULL);
678691 #ifdef CONFIG_AFS_FSCACHE
679692 vnode->cache = NULL;
680693 #endif
@@ -704,22 +717,38 @@ static void afs_destroy_inode(struct inode *inode) · 23 unmodified lines
704717
705718 _debug("DESTROY INODE %p", inode);
706719
707− ASSERTCMP(rcu_access_pointer(vnode->cb_interest), ==, NULL);
708−
709720 atomic_dec(&afs_count_active_inodes);
710721 }
711722
723+static void afs_get_volume_status_success(struct afs_operation *op)
724+{
725+ struct afs_volume_status *vs = &op->volstatus.vs;
726+ struct kstatfs *buf = op->volstatus.buf;
727+
728+ if (vs->max_quota == 0)
729+ buf->f_blocks = vs->part_max_blocks;
730+ else
731+ buf->f_blocks = vs->max_quota;
732+
733+ if (buf->f_blocks > vs->blocks_in_use)
734+ buf->f_bavail = buf->f_bfree =
735+ buf->f_blocks - vs->blocks_in_use;
736+}
737+
738+static const struct afs_operation_ops afs_get_volume_status_operation = {
739+ .issue_afs_rpc = afs_fs_get_volume_status,
740+ .issue_yfs_rpc = yfs_fs_get_volume_status,
741+ .success = afs_get_volume_status_success,
742+};
743+
712744 /*
713745 * return information about an AFS volume
714746 */
715747 static int afs_statfs(struct dentry *dentry, struct kstatfs *buf)
716748 {
717749 struct afs_super_info *as = AFS_FS_S(dentry->d_sb);
718− struct afs_fs_cursor fc;
719− struct afs_volume_status vs;
750+ struct afs_operation *op;
720751 struct afs_vnode *vnode = AFS_FS_I(d_inode(dentry));
721− struct key *key;
722− int ret;
723752
724753 buf->f_type = dentry->d_sb->s_magic;
725754 buf->f_bsize = AFS_BLOCK_SIZE;
@@ -732,31 +761,13 @@ static int afs_statfs(struct dentry *dentry, struct kstatfs *buf) · 6 unmodified lines
732761 return 0;
733762 }
734763
735− key = afs_request_key(vnode->volume->cell);
736− if (IS_ERR(key))
737− return PTR_ERR(key);
764+ op = afs_alloc_operation(NULL, as->volume);
765+ if (IS_ERR(op))
766+ return PTR_ERR(op);
738767
739− ret = -ERESTARTSYS;
740− if (afs_begin_vnode_operation(&fc, vnode, key, true)) {
741− fc.flags |= AFS_FS_CURSOR_NO_VSLEEP;
742− while (afs_select_fileserver(&fc)) {
743− fc.cb_break = afs_calc_vnode_cb_break(vnode);
744− afs_fs_get_volume_status(&fc, &vs);
745− }
746−
747− afs_check_for_remote_deletion(&fc, fc.vnode);
748− ret = afs_end_vnode_operation(&fc);
749− }
750−
751− key_put(key);
752−
753− if (ret == 0) {
754− if (vs.max_quota == 0)
755− buf->f_blocks = vs.part_max_blocks;
756− else
757− buf->f_blocks = vs.max_quota;
758− buf->f_bavail = buf->f_bfree = buf->f_blocks - vs.blocks_in_use;
759− }
760−
761− return ret;
768+ afs_op_set_vnode(op, 0, vnode);
769+ op->nr_files = 1;
770+ op->volstatus.buf = buf;
771+ op->ops = &afs_get_volume_status_operation;
772+ return afs_do_sync_operation(op);
762773 }
fs/afs/vl_alias.c+382−0
@@ -0,0 +1,382 @@
1+// SPDX-License-Identifier: GPL-2.0-or-later
2+/* AFS cell alias detection
3+ *
4+ * Copyright (C) 2020 Red Hat, Inc. All Rights Reserved.
5+ * Written by David Howells (dhowells@redhat.com)
6+ */
7+
8+#include <linux/slab.h>
9+#include <linux/sched.h>
10+#include <linux/namei.h>
11+#include <keys/rxrpc-type.h>
12+#include "internal.h"
13+
14+/*
15+ * Sample a volume.
16+ */
17+static struct afs_volume *afs_sample_volume(struct afs_cell *cell, struct key *key,
18+ const char *name, unsigned int namelen)
19+{
20+ struct afs_volume *volume;
21+ struct afs_fs_context fc = {
22+ .type = 0, /* Explicitly leave it to the VLDB */
23+ .volnamesz = namelen,
24+ .volname = name,
25+ .net = cell->net,
26+ .cell = cell,
27+ .key = key, /* This might need to be something */
28+ };
29+
30+ volume = afs_create_volume(&fc);
31+ _leave(" = %px", volume);
32+ return volume;
33+}
34+
35+/*
36+ * Compare two addresses.
37+ */
38+static int afs_compare_addrs(const struct sockaddr_rxrpc *srx_a,
39+ const struct sockaddr_rxrpc *srx_b)
40+{
41+ short port_a, port_b;
42+ int addr_a, addr_b, diff;
43+
44+ diff = (short)srx_a->transport_type - (short)srx_b->transport_type;
45+ if (diff)
46+ goto out;
47+
48+ switch (srx_a->transport_type) {
49+ case AF_INET: {
50+ const struct sockaddr_in *a = &srx_a->transport.sin;
51+ const struct sockaddr_in *b = &srx_b->transport.sin;
52+ addr_a = ntohl(a->sin_addr.s_addr);
53+ addr_b = ntohl(b->sin_addr.s_addr);
54+ diff = addr_a - addr_b;
55+ if (diff == 0) {
56+ port_a = ntohs(a->sin_port);
57+ port_b = ntohs(b->sin_port);
58+ diff = port_a - port_b;
59+ }
60+ break;
61+ }
62+
63+ case AF_INET6: {
64+ const struct sockaddr_in6 *a = &srx_a->transport.sin6;
65+ const struct sockaddr_in6 *b = &srx_b->transport.sin6;
66+ diff = memcmp(&a->sin6_addr, &b->sin6_addr, 16);
67+ if (diff == 0) {
68+ port_a = ntohs(a->sin6_port);
69+ port_b = ntohs(b->sin6_port);
70+ diff = port_a - port_b;
71+ }
72+ break;
73+ }
74+
75+ default:
76+ BUG();
77+ }
78+
79+out:
80+ return diff;
81+}
82+
83+/*
84+ * Compare the address lists of a pair of fileservers.
85+ */
86+static int afs_compare_fs_alists(const struct afs_server *server_a,
87+ const struct afs_server *server_b)
88+{
89+ const struct afs_addr_list *la, *lb;
90+ int a = 0, b = 0, addr_matches = 0;
91+
92+ la = rcu_dereference(server_a->addresses);
93+ lb = rcu_dereference(server_b->addresses);
94+
95+ while (a < la->nr_addrs && b < lb->nr_addrs) {
96+ const struct sockaddr_rxrpc *srx_a = &la->addrs[a];
97+ const struct sockaddr_rxrpc *srx_b = &lb->addrs[b];
98+ int diff = afs_compare_addrs(srx_a, srx_b);
99+
100+ if (diff < 0) {
101+ a++;
102+ } else if (diff > 0) {
103+ b++;
104+ } else {
105+ addr_matches++;
106+ a++;
107+ b++;
108+ }
109+ }
110+
111+ return addr_matches;
112+}
113+
114+/*
115+ * Compare the fileserver lists of two volumes. The server lists are sorted in
116+ * order of ascending UUID.
117+ */
118+static int afs_compare_volume_slists(const struct afs_volume *vol_a,
119+ const struct afs_volume *vol_b)
120+{
121+ const struct afs_server_list *la, *lb;
122+ int i, a = 0, b = 0, uuid_matches = 0, addr_matches = 0;
123+
124+ la = rcu_dereference(vol_a->servers);
125+ lb = rcu_dereference(vol_b->servers);
126+
127+ for (i = 0; i < AFS_MAXTYPES; i++)
128+ if (la->vids[i] != lb->vids[i])
129+ return 0;
130+
131+ while (a < la->nr_servers && b < lb->nr_servers) {
132+ const struct afs_server *server_a = la->servers[a].server;
133+ const struct afs_server *server_b = lb->servers[b].server;
134+ int diff = memcmp(&server_a->uuid, &server_b->uuid, sizeof(uuid_t));
135+
136+ if (diff < 0) {
137+ a++;
138+ } else if (diff > 0) {
139+ b++;
140+ } else {
141+ uuid_matches++;
142+ addr_matches += afs_compare_fs_alists(server_a, server_b);
143+ a++;
144+ b++;
145+ }
146+ }
147+
148+ _leave(" = %d [um %d]", addr_matches, uuid_matches);
149+ return addr_matches;
150+}
151+
152+/*
153+ * Compare root.cell volumes.
154+ */
155+static int afs_compare_cell_roots(struct afs_cell *cell)
156+{
157+ struct afs_cell *p;
158+
159+ _enter("");
160+
161+ rcu_read_lock();
162+
163+ hlist_for_each_entry_rcu(p, &cell->net->proc_cells, proc_link) {
164+ if (p == cell || p->alias_of)
165+ continue;
166+ if (!p->root_volume)
167+ continue; /* Ignore cells that don't have a root.cell volume. */
168+
169+ if (afs_compare_volume_slists(cell->root_volume, p->root_volume) != 0)
170+ goto is_alias;
171+ }
172+
173+ rcu_read_unlock();
174+ _leave(" = 0");
175+ return 0;
176+
177+is_alias:
178+ rcu_read_unlock();
179+ cell->alias_of = afs_get_cell(p);
180+ return 1;
181+}
182+
183+/*
184+ * Query the new cell for a volume from a cell we're already using.
185+ */
186+static int afs_query_for_alias_one(struct afs_cell *cell, struct key *key,
187+ struct afs_cell *p)
188+{
189+ struct afs_volume *volume, *pvol = NULL;
190+ int ret;
191+
192+ /* Arbitrarily pick a volume from the list. */
193+ read_seqlock_excl(&p->volume_lock);
194+ if (!RB_EMPTY_ROOT(&p->volumes))
195+ pvol = afs_get_volume(rb_entry(p->volumes.rb_node,
196+ struct afs_volume, cell_node),
197+ afs_volume_trace_get_query_alias);
198+ read_sequnlock_excl(&p->volume_lock);
199+ if (!pvol)
200+ return 0;
201+
202+ _enter("%s:%s", cell->name, pvol->name);
203+
204+ /* And see if it's in the new cell. */
205+ volume = afs_sample_volume(cell, key, pvol->name, pvol->name_len);
206+ if (IS_ERR(volume)) {
207+ afs_put_volume(cell->net, pvol, afs_volume_trace_put_query_alias);
208+ if (PTR_ERR(volume) != -ENOMEDIUM)
209+ return PTR_ERR(volume);
210+ /* That volume is not in the new cell, so not an alias */
211+ return 0;
212+ }
213+
214+ /* The new cell has a like-named volume also - compare volume ID,
215+ * server and address lists.
216+ */
217+ ret = 0;
218+ if (pvol->vid == volume->vid) {
219+ rcu_read_lock();
220+ if (afs_compare_volume_slists(volume, pvol))
221+ ret = 1;
222+ rcu_read_unlock();
223+ }
224+
225+ afs_put_volume(cell->net, volume, afs_volume_trace_put_query_alias);
226+ afs_put_volume(cell->net, pvol, afs_volume_trace_put_query_alias);
227+ return ret;
228+}
229+
230+/*
231+ * Query the new cell for volumes we know exist in cells we're already using.
232+ */
233+static int afs_query_for_alias(struct afs_cell *cell, struct key *key)
234+{
235+ struct afs_cell *p;
236+
237+ _enter("%s", cell->name);
238+
239+ if (mutex_lock_interruptible(&cell->net->proc_cells_lock) < 0)
240+ return -ERESTARTSYS;
241+
242+ hlist_for_each_entry(p, &cell->net->proc_cells, proc_link) {
243+ if (p == cell || p->alias_of)
244+ continue;
245+ if (RB_EMPTY_ROOT(&p->volumes))
246+ continue;
247+ if (p->root_volume)
248+ continue; /* Ignore cells that have a root.cell volume. */
249+ afs_get_cell(p);
250+ mutex_unlock(&cell->net->proc_cells_lock);
251+
252+ if (afs_query_for_alias_one(cell, key, p) != 0)
253+ goto is_alias;
254+
255+ if (mutex_lock_interruptible(&cell->net->proc_cells_lock) < 0) {
256+ afs_put_cell(cell->net, p);
257+ return -ERESTARTSYS;
258+ }
259+
260+ afs_put_cell(cell->net, p);
261+ }
262+
263+ mutex_unlock(&cell->net->proc_cells_lock);
264+ _leave(" = 0");
265+ return 0;
266+
267+is_alias:
268+ cell->alias_of = p; /* Transfer our ref */
269+ return 1;
270+}
271+
272+/*
273+ * Look up a VLDB record for a volume.
274+ */
275+static char *afs_vl_get_cell_name(struct afs_cell *cell, struct key *key)
276+{
277+ struct afs_vl_cursor vc;
278+ char *cell_name = ERR_PTR(-EDESTADDRREQ);
279+ bool skipped = false, not_skipped = false;
280+ int ret;
281+
282+ if (!afs_begin_vlserver_operation(&vc, cell, key))
283+ return ERR_PTR(-ERESTARTSYS);
284+
285+ while (afs_select_vlserver(&vc)) {
286+ if (!test_bit(AFS_VLSERVER_FL_IS_YFS, &vc.server->flags)) {
287+ vc.ac.error = -EOPNOTSUPP;
288+ skipped = true;
289+ continue;
290+ }
291+ not_skipped = true;
292+ cell_name = afs_yfsvl_get_cell_name(&vc);
293+ }
294+
295+ ret = afs_end_vlserver_operation(&vc);
296+ if (skipped && !not_skipped)
297+ ret = -EOPNOTSUPP;
298+ return ret < 0 ? ERR_PTR(ret) : cell_name;
299+}
300+
301+static int yfs_check_canonical_cell_name(struct afs_cell *cell, struct key *key)
302+{
303+ struct afs_cell *master;
304+ char *cell_name;
305+
306+ cell_name = afs_vl_get_cell_name(cell, key);
307+ if (IS_ERR(cell_name))
308+ return PTR_ERR(cell_name);
309+
310+ if (strcmp(cell_name, cell->name) == 0) {
311+ kfree(cell_name);
312+ return 0;
313+ }
314+
315+ master = afs_lookup_cell(cell->net, cell_name, strlen(cell_name),
316+ NULL, false);
317+ kfree(cell_name);
318+ if (IS_ERR(master))
319+ return PTR_ERR(master);
320+
321+ cell->alias_of = master; /* Transfer our ref */
322+ return 1;
323+}
324+
325+static int afs_do_cell_detect_alias(struct afs_cell *cell, struct key *key)
326+{
327+ struct afs_volume *root_volume;
328+ int ret;
329+
330+ _enter("%s", cell->name);
331+
332+ ret = yfs_check_canonical_cell_name(cell, key);
333+ if (ret != -EOPNOTSUPP)
334+ return ret;
335+
336+ /* Try and get the root.cell volume for comparison with other cells */
337+ root_volume = afs_sample_volume(cell, key, "root.cell", 9);
338+ if (!IS_ERR(root_volume)) {
339+ cell->root_volume = root_volume;
340+ return afs_compare_cell_roots(cell);
341+ }
342+
343+ if (PTR_ERR(root_volume) != -ENOMEDIUM)
344+ return PTR_ERR(root_volume);
345+
346+ /* Okay, this cell doesn't have an root.cell volume. We need to
347+ * locate some other random volume and use that to check.
348+ */
349+ return afs_query_for_alias(cell, key);
350+}
351+
352+/*
353+ * Check to see if a new cell is an alias of a cell we already have. At this
354+ * point we have the cell's volume server list.
355+ *
356+ * Returns 0 if we didn't detect an alias, 1 if we found an alias and an error
357+ * if we had problems gathering the data required. In the case the we did
358+ * detect an alias, cell->alias_of is set to point to the assumed master.
359+ */
360+int afs_cell_detect_alias(struct afs_cell *cell, struct key *key)
361+{
362+ struct afs_net *net = cell->net;
363+ int ret;
364+
365+ if (mutex_lock_interruptible(&net->cells_alias_lock) < 0)
366+ return -ERESTARTSYS;
367+
368+ if (test_bit(AFS_CELL_FL_CHECK_ALIAS, &cell->flags)) {
369+ ret = afs_do_cell_detect_alias(cell, key);
370+ if (ret >= 0)
371+ clear_bit_unlock(AFS_CELL_FL_CHECK_ALIAS, &cell->flags);
372+ } else {
373+ ret = cell->alias_of ? 1 : 0;
374+ }
375+
376+ mutex_unlock(&net->cells_alias_lock);
377+
378+ if (ret == 1)
379+ pr_notice("kAFS: Cell %s is an alias of %s\n",
380+ cell->name, cell->alias_of->name);
381+ return ret;
382+}
fs/afs/vl_rotate.c+4−0
@@ -151,6 +151,10 @@ bool afs_select_vlserver(struct afs_vl_cursor *vc) · 150 unmodified lines
151151 vc->error = error;
152152 vc->flags |= AFS_VL_CURSOR_RETRY;
153153 goto next_server;
154+
155+ case -EOPNOTSUPP:
156+ _debug("notsupp");
157+ goto next_server;
154158 }
155159
156160 restart_from_beginning:
fs/afs/vlclient.c+126−20
@@ -82,6 +82,7 @@ static int afs_deliver_vl_get_entry_by_name_u(struct afs_call *call) · 81 unmodified lines
8282 for (j = 0; j < 6; j++)
8383 uuid->node[j] = (u8)ntohl(xdr->node[j]);
8484
85+ entry->addr_version[n] = ntohl(uvldb->serverUnique[i]);
8586 entry->nr_servers++;
8687 }
8788
@@ -447,8 +448,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call) · 359 unmodified lines
447448 call->count2 = ntohl(*bp); /* Type or next count */
448449
449450 if (call->count > YFS_MAXENDPOINTS)
450− return afs_protocol_error(call, -EBADMSG,
451− afs_eproto_yvl_fsendpt_num);
451+ return afs_protocol_error(call, afs_eproto_yvl_fsendpt_num);
452452
453453 alist = afs_alloc_addrlist(call->count, FS_SERVICE, AFS_FS_PORT);
454454 if (!alist)
@@ -468,8 +468,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call) · 13 unmodified lines
468468 size = sizeof(__be32) * (1 + 4 + 1);
469469 break;
470470 default:
471− return afs_protocol_error(call, -EBADMSG,
472− afs_eproto_yvl_fsendpt_type);
471+ return afs_protocol_error(call, afs_eproto_yvl_fsendpt_type);
473472 }
474473
475474 size += sizeof(__be32);
@@ -487,21 +486,20 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call) · 11 unmodified lines
487486 switch (call->count2) {
488487 case YFS_ENDPOINT_IPV4:
489488 if (ntohl(bp[0]) != sizeof(__be32) * 2)
490− return afs_protocol_error(call, -EBADMSG,
491− afs_eproto_yvl_fsendpt4_len);
489+ return afs_protocol_error(
490+ call, afs_eproto_yvl_fsendpt4_len);
492491 afs_merge_fs_addr4(alist, bp[1], ntohl(bp[2]));
493492 bp += 3;
494493 break;
495494 case YFS_ENDPOINT_IPV6:
496495 if (ntohl(bp[0]) != sizeof(__be32) * 5)
497− return afs_protocol_error(call, -EBADMSG,
498− afs_eproto_yvl_fsendpt6_len);
496+ return afs_protocol_error(
497+ call, afs_eproto_yvl_fsendpt6_len);
499498 afs_merge_fs_addr6(alist, bp + 1, ntohl(bp[5]));
500499 bp += 6;
501500 break;
502501 default:
503− return afs_protocol_error(call, -EBADMSG,
504− afs_eproto_yvl_fsendpt_type);
502+ return afs_protocol_error(call, afs_eproto_yvl_fsendpt_type);
505503 }
506504
507505 /* Got either the type of the next entry or the count of
@@ -519,8 +517,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call) · 11 unmodified lines
519517 if (!call->count)
520518 goto end;
521519 if (call->count > YFS_MAXENDPOINTS)
522− return afs_protocol_error(call, -EBADMSG,
523− afs_eproto_yvl_vlendpt_type);
520+ return afs_protocol_error(call, afs_eproto_yvl_vlendpt_type);
524521
525522 afs_extract_to_buf(call, 1 * sizeof(__be32));
526523 call->unmarshall = 3;
@@ -547,8 +544,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call) · 20 unmodified lines
547544 size = sizeof(__be32) * (1 + 4 + 1);
548545 break;
549546 default:
550− return afs_protocol_error(call, -EBADMSG,
551− afs_eproto_yvl_vlendpt_type);
547+ return afs_protocol_error(call, afs_eproto_yvl_vlendpt_type);
552548 }
553549
554550 if (call->count > 1)
@@ -566,19 +562,18 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call) · 11 unmodified lines
566562 switch (call->count2) {
567563 case YFS_ENDPOINT_IPV4:
568564 if (ntohl(bp[0]) != sizeof(__be32) * 2)
569− return afs_protocol_error(call, -EBADMSG,
570− afs_eproto_yvl_vlendpt4_len);
565+ return afs_protocol_error(
566+ call, afs_eproto_yvl_vlendpt4_len);
571567 bp += 3;
572568 break;
573569 case YFS_ENDPOINT_IPV6:
574570 if (ntohl(bp[0]) != sizeof(__be32) * 5)
575− return afs_protocol_error(call, -EBADMSG,
576− afs_eproto_yvl_vlendpt6_len);
571+ return afs_protocol_error(
572+ call, afs_eproto_yvl_vlendpt6_len);
577573 bp += 6;
578574 break;
579575 default:
580− return afs_protocol_error(call, -EBADMSG,
581− afs_eproto_yvl_vlendpt_type);
576+ return afs_protocol_error(call, afs_eproto_yvl_vlendpt_type);
582577 }
583578
584579 /* Got either the type of the next entry or the count of
@@ -650,3 +645,114 @@ struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_vl_cursor *vc, · 65 unmodified lines
650645 afs_make_call(&vc->ac, call, GFP_KERNEL);
651646 return (struct afs_addr_list *)afs_wait_for_call_to_complete(call, &vc->ac);
652647 }
648+
649+/*
650+ * Deliver reply data to a YFSVL.GetCellName operation.
651+ */
652+static int afs_deliver_yfsvl_get_cell_name(struct afs_call *call)
653+{
654+ char *cell_name;
655+ u32 namesz, paddedsz;
656+ int ret;
657+
658+ _enter("{%u,%zu/%u}",
659+ call->unmarshall, iov_iter_count(call->iter), call->count);
660+
661+ switch (call->unmarshall) {
662+ case 0:
663+ afs_extract_to_tmp(call);
664+ call->unmarshall++;
665+
666+ /* Fall through - and extract the cell name length */
667+ case 1:
668+ ret = afs_extract_data(call, true);
669+ if (ret < 0)
670+ return ret;
671+
672+ namesz = ntohl(call->tmp);
673+ if (namesz > AFS_MAXCELLNAME)
674+ return afs_protocol_error(call, afs_eproto_cellname_len);
675+ paddedsz = (namesz + 3) & ~3;
676+ call->count = namesz;
677+ call->count2 = paddedsz - namesz;
678+
679+ cell_name = kmalloc(namesz + 1, GFP_KERNEL);
680+ if (!cell_name)
681+ return -ENOMEM;
682+ cell_name[namesz] = 0;
683+ call->ret_str = cell_name;
684+
685+ afs_extract_begin(call, cell_name, namesz);
686+ call->unmarshall++;
687+
688+ /* Fall through - and extract cell name */
689+ case 2:
690+ ret = afs_extract_data(call, true);
691+ if (ret < 0)
692+ return ret;
693+
694+ afs_extract_discard(call, call->count2);
695+ call->unmarshall++;
696+
697+ /* Fall through - and extract padding */
698+ case 3:
699+ ret = afs_extract_data(call, false);
700+ if (ret < 0)
701+ return ret;
702+
703+ call->unmarshall++;
704+ break;
705+ }
706+
707+ _leave(" = 0 [done]");
708+ return 0;
709+}
710+
711+static void afs_destroy_yfsvl_get_cell_name(struct afs_call *call)
712+{
713+ kfree(call->ret_str);
714+ afs_flat_call_destructor(call);
715+}
716+
717+/*
718+ * VL.GetCapabilities operation type
719+ */
720+static const struct afs_call_type afs_YFSVLGetCellName = {
721+ .name = "YFSVL.GetCellName",
722+ .op = afs_YFSVL_GetCellName,
723+ .deliver = afs_deliver_yfsvl_get_cell_name,
724+ .destructor = afs_destroy_yfsvl_get_cell_name,
725+};
726+
727+/*
728+ * Probe a volume server for the capabilities that it supports. This can
729+ * return up to 196 words.
730+ *
731+ * We use this to probe for service upgrade to determine what the server at the
732+ * other end supports.
733+ */
734+char *afs_yfsvl_get_cell_name(struct afs_vl_cursor *vc)
735+{
736+ struct afs_call *call;
737+ struct afs_net *net = vc->cell->net;
738+ __be32 *bp;
739+
740+ _enter("");
741+
742+ call = afs_alloc_flat_call(net, &afs_YFSVLGetCellName, 1 * 4, 0);
743+ if (!call)
744+ return ERR_PTR(-ENOMEM);
745+
746+ call->key = vc->key;
747+ call->ret_str = NULL;
748+ call->max_lifespan = AFS_VL_MAX_LIFESPAN;
749+
750+ /* marshall the parameters */
751+ bp = call->request;
752+ *bp++ = htonl(YVLGETCELLNAME);
753+
754+ /* Can't take a ref on server */
755+ trace_afs_make_vl_call(call);
756+ afs_make_call(&vc->ac, call, GFP_KERNEL);
757+ return (char *)afs_wait_for_call_to_complete(call, &vc->ac);
758+}
fs/afs/volume.c+119−35
@@ -12,6 +12,56 @@ · 11 unmodified lines
1212 unsigned __read_mostly afs_volume_gc_delay = 10;
1313 unsigned __read_mostly afs_volume_record_life = 60 * 60;
1414
15+/*
16+ * Insert a volume into a cell. If there's an existing volume record, that is
17+ * returned instead with a ref held.
18+ */
19+static struct afs_volume *afs_insert_volume_into_cell(struct afs_cell *cell,
20+ struct afs_volume *volume)
21+{
22+ struct afs_volume *p;
23+ struct rb_node *parent = NULL, **pp;
24+
25+ write_seqlock(&cell->volume_lock);
26+
27+ pp = &cell->volumes.rb_node;
28+ while (*pp) {
29+ parent = *pp;
30+ p = rb_entry(parent, struct afs_volume, cell_node);
31+ if (p->vid < volume->vid) {
32+ pp = &(*pp)->rb_left;
33+ } else if (p->vid > volume->vid) {
34+ pp = &(*pp)->rb_right;
35+ } else {
36+ volume = afs_get_volume(p, afs_volume_trace_get_cell_insert);
37+ goto found;
38+ }
39+ }
40+
41+ rb_link_node_rcu(&volume->cell_node, parent, pp);
42+ rb_insert_color(&volume->cell_node, &cell->volumes);
43+ hlist_add_head_rcu(&volume->proc_link, &cell->proc_volumes);
44+
45+found:
46+ write_sequnlock(&cell->volume_lock);
47+ return volume;
48+
49+}
50+
51+static void afs_remove_volume_from_cell(struct afs_volume *volume)
52+{
53+ struct afs_cell *cell = volume->cell;
54+
55+ if (!hlist_unhashed(&volume->proc_link)) {
56+ trace_afs_volume(volume->vid, atomic_read(&volume->usage),
57+ afs_volume_trace_remove);
58+ write_seqlock(&cell->volume_lock);
59+ hlist_del_rcu(&volume->proc_link);
60+ rb_erase(&volume->cell_node, &cell->volumes);
61+ write_sequnlock(&cell->volume_lock);
62+ }
63+}
64+
1565 /*
1666 * Allocate a volume record and load it up from a vldb record.
1767 */
@@ -39,7 +89,7 @@ static struct afs_volume *afs_alloc_volume(struct afs_fs_context *params, · 21 unmodified lines
3989 volume->name_len = vldb->name_len;
4090
4191 atomic_set(&volume->usage, 1);
42− INIT_LIST_HEAD(&volume->proc_link);
92+ INIT_HLIST_NODE(&volume->proc_link);
4393 rwlock_init(&volume->servers_lock);
4494 rwlock_init(&volume->cb_v_break_lock);
4595 memcpy(volume->name, vldb->name, vldb->name_len + 1);
@@ -51,7 +101,8 @@ static struct afs_volume *afs_alloc_volume(struct afs_fs_context *params, · 5 unmodified lines
51101 }
52102
53103 refcount_set(&slist->usage, 1);
54− volume->servers = slist;
104+ rcu_assign_pointer(volume->servers, slist);
105+ trace_afs_volume(volume->vid, 1, afs_volume_trace_alloc);
55106 return volume;
56107
57108 error_1:
@@ -61,6 +112,25 @@ error_0: · 3 unmodified lines
61112 return ERR_PTR(ret);
62113 }
63114
115+/*
116+ * Look up or allocate a volume record.
117+ */
118+static struct afs_volume *afs_lookup_volume(struct afs_fs_context *params,
119+ struct afs_vldb_entry *vldb,
120+ unsigned long type_mask)
121+{
122+ struct afs_volume *candidate, *volume;
123+
124+ candidate = afs_alloc_volume(params, vldb, type_mask);
125+ if (IS_ERR(candidate))
126+ return candidate;
127+
128+ volume = afs_insert_volume_into_cell(params->cell, candidate);
129+ if (volume != candidate)
130+ afs_put_volume(params->net, candidate, afs_volume_trace_put_cell_dup);
131+ return volume;
132+}
133+
64134 /*
65135 * Look up a VLDB record for a volume.
66136 */
@@ -138,7 +208,7 @@ struct afs_volume *afs_create_volume(struct afs_fs_context *params) · 71 unmodified lines
138208 }
139209
140210 type_mask = 1UL << params->type;
141− volume = afs_alloc_volume(params, vldb, type_mask);
211+ volume = afs_lookup_volume(params, vldb, type_mask);
142212
143213 error:
144214 kfree(vldb);
@@ -156,23 +226,42 @@ static void afs_destroy_volume(struct afs_net *net, struct afs_volume *volume) · 11 unmodified lines
156226 ASSERTCMP(volume->cache, ==, NULL);
157227 #endif
158228
159− afs_put_serverlist(net, volume->servers);
229+ afs_remove_volume_from_cell(volume);
230+ afs_put_serverlist(net, rcu_access_pointer(volume->servers));
160231 afs_put_cell(net, volume->cell);
161− kfree(volume);
232+ trace_afs_volume(volume->vid, atomic_read(&volume->usage),
233+ afs_volume_trace_free);
234+ kfree_rcu(volume, rcu);
162235
163236 _leave(" [destroyed]");
164237 }
165238
166239 /*
167− * Drop a reference on a volume record.
240+ * Get a reference on a volume record.
168241 */
169−void afs_put_volume(struct afs_cell *cell, struct afs_volume *volume)
242+struct afs_volume *afs_get_volume(struct afs_volume *volume,
243+ enum afs_volume_trace reason)
170244 {
171245 if (volume) {
172− _enter("%s", volume->name);
246+ int u = atomic_inc_return(&volume->usage);
247+ trace_afs_volume(volume->vid, u, reason);
248+ }
249+ return volume;
250+}
251+
173252
174− if (atomic_dec_and_test(&volume->usage))
175− afs_destroy_volume(cell->net, volume);
253+/*
254+ * Drop a reference on a volume record.
255+ */
256+void afs_put_volume(struct afs_net *net, struct afs_volume *volume,
257+ enum afs_volume_trace reason)
258+{
259+ if (volume) {
260+ afs_volid_t vid = volume->vid;
261+ int u = atomic_dec_return(&volume->usage);
262+ trace_afs_volume(vid, u, reason);
263+ if (u == 0)
264+ afs_destroy_volume(net, volume);
176265 }
177266 }
178267
@@ -188,10 +277,6 @@ void afs_activate_volume(struct afs_volume *volume) · 9 unmodified lines
188277 NULL, 0,
189278 volume, 0, true);
190279 #endif
191−
192− write_lock(&volume->cell->proc_lock);
193− list_add_tail(&volume->proc_link, &volume->cell->proc_volumes);
194− write_unlock(&volume->cell->proc_lock);
195280 }
196281
197282 /*
@@ -201,10 +286,6 @@ void afs_deactivate_volume(struct afs_volume *volume) · 3 unmodified lines
201286 {
202287 _enter("%s", volume->name);
203288
204− write_lock(&volume->cell->proc_lock);
205− list_del_init(&volume->proc_link);
206− write_unlock(&volume->cell->proc_lock);
207−
208289 #ifdef CONFIG_AFS_FSCACHE
209290 fscache_relinquish_cookie(volume->cache, NULL,
210291 test_bit(AFS_VOLUME_DELETED, &volume->flags));
@@ -256,17 +337,17 @@ static int afs_update_volume_status(struct afs_volume *volume, struct key *key) · 45 unmodified lines
256337 write_lock(&volume->servers_lock);
257338
258339 discard = new;
259− old = volume->servers;
340+ old = rcu_dereference_protected(volume->servers,
341+ lockdep_is_held(&volume->servers_lock));
260342 if (afs_annotate_server_list(new, old)) {
261343 new->seq = volume->servers_seq + 1;
262− volume->servers = new;
344+ rcu_assign_pointer(volume->servers, new);
263345 smp_wmb();
264346 volume->servers_seq++;
265347 discard = old;
266348 }
267349
268350 volume->update_at = ktime_get_real_seconds() + afs_volume_record_life;
269− clear_bit(AFS_VOLUME_NEEDS_UPDATE, &volume->flags);
270351 write_unlock(&volume->servers_lock);
271352 ret = 0;
272353
@@ -281,25 +362,27 @@ error: · 8 unmodified lines
281362 /*
282363 * Make sure the volume record is up to date.
283364 */
284−int afs_check_volume_status(struct afs_volume *volume, struct afs_fs_cursor *fc)
365+int afs_check_volume_status(struct afs_volume *volume, struct afs_operation *op)
285366 {
286− time64_t now = ktime_get_real_seconds();
287367 int ret, retries = 0;
288368
289369 _enter("");
290370
291− if (volume->update_at <= now)
292− set_bit(AFS_VOLUME_NEEDS_UPDATE, &volume->flags);
293−
294371 retry:
295− if (!test_bit(AFS_VOLUME_NEEDS_UPDATE, &volume->flags) &&
296− !test_bit(AFS_VOLUME_WAIT, &volume->flags)) {
297− _leave(" = 0");
298− return 0;
299− }
300−
372+ if (test_bit(AFS_VOLUME_WAIT, &volume->flags))
373+ goto wait;
374+ if (volume->update_at <= ktime_get_real_seconds() ||
375+ test_bit(AFS_VOLUME_NEEDS_UPDATE, &volume->flags))
376+ goto update;
377+ _leave(" = 0");
378+ return 0;
379+
380+update:
301381 if (!test_and_set_bit_lock(AFS_VOLUME_UPDATING, &volume->flags)) {
302− ret = afs_update_volume_status(volume, fc->key);
382+ clear_bit(AFS_VOLUME_NEEDS_UPDATE, &volume->flags);
383+ ret = afs_update_volume_status(volume, op->key);
384+ if (ret < 0)
385+ set_bit(AFS_VOLUME_NEEDS_UPDATE, &volume->flags);
303386 clear_bit_unlock(AFS_VOLUME_WAIT, &volume->flags);
304387 clear_bit_unlock(AFS_VOLUME_UPDATING, &volume->flags);
305388 wake_up_bit(&volume->flags, AFS_VOLUME_WAIT);
@@ -307,14 +390,15 @@ retry: · 1 unmodified line
307390 return ret;
308391 }
309392
393+wait:
310394 if (!test_bit(AFS_VOLUME_WAIT, &volume->flags)) {
311395 _leave(" = 0 [no wait]");
312396 return 0;
313397 }
314398
315399 ret = wait_on_bit(&volume->flags, AFS_VOLUME_WAIT,
316− (fc->flags & AFS_FS_CURSOR_INTR) ?
317− TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE);
400+ (op->flags & AFS_OPERATION_UNINTR) ?
401+ TASK_UNINTERRUPTIBLE : TASK_INTERRUPTIBLE);
318402 if (ret == -ERESTARTSYS) {
319403 _leave(" = %d", ret);
320404 return ret;
fs/afs/write.c+90−58
@@ -349,82 +349,111 @@ static void afs_pages_written_back(struct afs_vnode *vnode, · 348 unmodified lines
349349 }
350350
351351 /*
352− * write to a file
352+ * Find a key to use for the writeback. We cached the keys used to author the
353+ * writes on the vnode. *_wbk will contain the last writeback key used or NULL
354+ * and we need to start from there if it's set.
353355 */
354−static int afs_store_data(struct address_space *mapping,
355− pgoff_t first, pgoff_t last,
356− unsigned offset, unsigned to)
356+static int afs_get_writeback_key(struct afs_vnode *vnode,
357+ struct afs_wb_key **_wbk)
357358 {
358− struct afs_vnode *vnode = AFS_FS_I(mapping->host);
359− struct afs_fs_cursor fc;
360− struct afs_status_cb *scb;
361359 struct afs_wb_key *wbk = NULL;
362360 struct list_head *p;
363361 int ret = -ENOKEY, ret2;
364362
365− _enter("%s{%llx:%llu.%u},%lx,%lx,%x,%x",
366− vnode->volume->name,
367− vnode->fid.vid,
368− vnode->fid.vnode,
369− vnode->fid.unique,
370− first, last, offset, to);
371−
372− scb = kzalloc(sizeof(struct afs_status_cb), GFP_NOFS);
373− if (!scb)
374− return -ENOMEM;
375−
376363 spin_lock(&vnode->wb_lock);
377− p = vnode->wb_keys.next;
364+ if (*_wbk)
365+ p = (*_wbk)->vnode_link.next;
366+ else
367+ p = vnode->wb_keys.next;
378368
379− /* Iterate through the list looking for a valid key to use. */
380−try_next_key:
381369 while (p != &vnode->wb_keys) {
382370 wbk = list_entry(p, struct afs_wb_key, vnode_link);
383371 _debug("wbk %u", key_serial(wbk->key));
384372 ret2 = key_validate(wbk->key);
385− if (ret2 == 0)
386− goto found_key;
373+ if (ret2 == 0) {
374+ refcount_inc(&wbk->usage);
375+ _debug("USE WB KEY %u", key_serial(wbk->key));
376+ break;
377+ }
378+
379+ wbk = NULL;
387380 if (ret == -ENOKEY)
388381 ret = ret2;
389382 p = p->next;
390383 }
391384
392385 spin_unlock(&vnode->wb_lock);
393− afs_put_wb_key(wbk);
394− kfree(scb);
395− _leave(" = %d [no keys]", ret);
396− return ret;
386+ if (*_wbk)
387+ afs_put_wb_key(*_wbk);
388+ *_wbk = wbk;
389+ return 0;
390+}
397391
398−found_key:
399− refcount_inc(&wbk->usage);
400− spin_unlock(&vnode->wb_lock);
392+static void afs_store_data_success(struct afs_operation *op)
393+{
394+ struct afs_vnode *vnode = op->file[0].vnode;
401395
402− _debug("USE WB KEY %u", key_serial(wbk->key));
396+ afs_vnode_commit_status(op, &op->file[0]);
397+ if (op->error == 0) {
398+ afs_pages_written_back(vnode, op->store.first, op->store.last);
399+ afs_stat_v(vnode, n_stores);
400+ atomic_long_add((op->store.last * PAGE_SIZE + op->store.last_to) -
401+ (op->store.first * PAGE_SIZE + op->store.first_offset),
402+ &afs_v2net(vnode)->n_store_bytes);
403+ }
404+}
403405
404− ret = -ERESTARTSYS;
405− if (afs_begin_vnode_operation(&fc, vnode, wbk->key, false)) {
406− afs_dataversion_t data_version = vnode->status.data_version + 1;
406+static const struct afs_operation_ops afs_store_data_operation = {
407+ .issue_afs_rpc = afs_fs_store_data,
408+ .issue_yfs_rpc = yfs_fs_store_data,
409+ .success = afs_store_data_success,
410+};
407411
408− while (afs_select_fileserver(&fc)) {
409− fc.cb_break = afs_calc_vnode_cb_break(vnode);
410− afs_fs_store_data(&fc, mapping, first, last, offset, to, scb);
411− }
412+/*
413+ * write to a file
414+ */
415+static int afs_store_data(struct address_space *mapping,
416+ pgoff_t first, pgoff_t last,
417+ unsigned offset, unsigned to)
418+{
419+ struct afs_vnode *vnode = AFS_FS_I(mapping->host);
420+ struct afs_operation *op;
421+ struct afs_wb_key *wbk = NULL;
422+ int ret;
412423
413− afs_check_for_remote_deletion(&fc, vnode);
414− afs_vnode_commit_status(&fc, vnode, fc.cb_break,
415− &data_version, scb);
416− if (fc.ac.error == 0)
417− afs_pages_written_back(vnode, first, last);
418− ret = afs_end_vnode_operation(&fc);
424+ _enter("%s{%llx:%llu.%u},%lx,%lx,%x,%x",
425+ vnode->volume->name,
426+ vnode->fid.vid,
427+ vnode->fid.vnode,
428+ vnode->fid.unique,
429+ first, last, offset, to);
430+
431+ ret = afs_get_writeback_key(vnode, &wbk);
432+ if (ret) {
433+ _leave(" = %d [no keys]", ret);
434+ return ret;
419435 }
420436
421− switch (ret) {
422− case 0:
423− afs_stat_v(vnode, n_stores);
424− atomic_long_add((last * PAGE_SIZE + to) -
425− (first * PAGE_SIZE + offset),
426− &afs_v2net(vnode)->n_store_bytes);
427− break;
437+ op = afs_alloc_operation(wbk->key, vnode->volume);
438+ if (IS_ERR(op)) {
439+ afs_put_wb_key(wbk);
440+ return -ENOMEM;
441+ }
442+
443+ afs_op_set_vnode(op, 0, vnode);
444+ op->file[0].dv_delta = 1;
445+ op->store.mapping = mapping;
446+ op->store.first = first;
447+ op->store.last = last;
448+ op->store.first_offset = offset;
449+ op->store.last_to = to;
450+ op->ops = &afs_store_data_operation;
451+
452+try_next_key:
453+ afs_begin_vnode_operation(op);
454+ afs_wait_for_operation(op);
455+
456+ switch (op->error) {
428457 case -EACCES:
429458 case -EPERM:
430459 case -ENOKEY:
@@ -432,16 +461,19 @@ found_key: · 1 unmodified line
432461 case -EKEYREJECTED:
433462 case -EKEYREVOKED:
434463 _debug("next");
435− spin_lock(&vnode->wb_lock);
436− p = wbk->vnode_link.next;
437− afs_put_wb_key(wbk);
438− goto try_next_key;
464+
465+ ret = afs_get_writeback_key(vnode, &wbk);
466+ if (ret == 0) {
467+ key_put(op->key);
468+ op->key = key_get(wbk->key);
469+ goto try_next_key;
470+ }
471+ break;
439472 }
440473
441474 afs_put_wb_key(wbk);
442− kfree(scb);
443− _leave(" = %d", ret);
444− return ret;
475+ _leave(" = %d", op->error);
476+ return afs_put_operation(op);
445477 }
446478
447479 /*
fs/afs/xattr.c+127−173
@@ -34,6 +34,25 @@ ssize_t afs_listxattr(struct dentry *dentry, char *buffer, size_t size) · 33 unmodified lines
3434 return sizeof(afs_xattr_list);
3535 }
3636
37+/*
38+ * Deal with the result of a successful fetch ACL operation.
39+ */
40+static void afs_acl_success(struct afs_operation *op)
41+{
42+ afs_vnode_commit_status(op, &op->file[0]);
43+}
44+
45+static void afs_acl_put(struct afs_operation *op)
46+{
47+ kfree(op->acl);
48+}
49+
50+static const struct afs_operation_ops afs_fetch_acl_operation = {
51+ .issue_afs_rpc = afs_fs_fetch_acl,
52+ .success = afs_acl_success,
53+ .put = afs_acl_put,
54+};
55+
3756 /*
3857 * Get a file's ACL.
3958 */
@@ -42,37 +61,23 @@ static int afs_xattr_get_acl(const struct xattr_handler *handler, · 2 unmodified lines
4261 struct inode *inode, const char *name,
4362 void *buffer, size_t size)
4463 {
45− struct afs_fs_cursor fc;
46− struct afs_status_cb *scb;
64+ struct afs_operation *op;
4765 struct afs_vnode *vnode = AFS_FS_I(inode);
4866 struct afs_acl *acl = NULL;
49− struct key *key;
50− int ret = -ENOMEM;
67+ int ret;
5168
52− scb = kzalloc(sizeof(struct afs_status_cb), GFP_NOFS);
53− if (!scb)
54− goto error;
55−
56− key = afs_request_key(vnode->volume->cell);
57− if (IS_ERR(key)) {
58− ret = PTR_ERR(key);
59− goto error_scb;
60− }
69+ op = afs_alloc_operation(NULL, vnode->volume);
70+ if (IS_ERR(op))
71+ return -ENOMEM;
6172
62− ret = -ERESTARTSYS;
63− if (afs_begin_vnode_operation(&fc, vnode, key, true)) {
64− afs_dataversion_t data_version = vnode->status.data_version;
65−
66− while (afs_select_fileserver(&fc)) {
67− fc.cb_break = afs_calc_vnode_cb_break(vnode);
68− acl = afs_fs_fetch_acl(&fc, scb);
69− }
73+ afs_op_set_vnode(op, 0, vnode);
74+ op->ops = &afs_fetch_acl_operation;
7075
71− afs_check_for_remote_deletion(&fc, fc.vnode);
72− afs_vnode_commit_status(&fc, vnode, fc.cb_break,
73− &data_version, scb);
74− ret = afs_end_vnode_operation(&fc);
75− }
76+ afs_begin_vnode_operation(op);
77+ afs_wait_for_operation(op);
78+ acl = op->acl;
79+ op->acl = NULL;
80+ ret = afs_put_operation(op);
7681
7782 if (ret == 0) {
7883 ret = acl->size;
@@ -80,18 +85,37 @@ static int afs_xattr_get_acl(const struct xattr_handler *handler, · 1 unmodified line
8085 if (acl->size <= size)
8186 memcpy(buffer, acl->data, acl->size);
8287 else
83− ret = -ERANGE;
88+ op->error = -ERANGE;
8489 }
85− kfree(acl);
8690 }
8791
88− key_put(key);
89−error_scb:
90− kfree(scb);
91−error:
92+ kfree(acl);
9293 return ret;
9394 }
9495
96+static bool afs_make_acl(struct afs_operation *op,
97+ const void *buffer, size_t size)
98+{
99+ struct afs_acl *acl;
100+
101+ acl = kmalloc(sizeof(*acl) + size, GFP_KERNEL);
102+ if (!acl) {
103+ afs_op_nomem(op);
104+ return false;
105+ }
106+
107+ acl->size = size;
108+ memcpy(acl->data, buffer, size);
109+ op->acl = acl;
110+ return true;
111+}
112+
113+static const struct afs_operation_ops afs_store_acl_operation = {
114+ .issue_afs_rpc = afs_fs_store_acl,
115+ .success = afs_acl_success,
116+ .put = afs_acl_put,
117+};
118+
95119 /*
96120 * Set a file's AFS3 ACL.
97121 */
@@ -100,55 +124,22 @@ static int afs_xattr_set_acl(const struct xattr_handler *handler, · 2 unmodified lines
100124 struct inode *inode, const char *name,
101125 const void *buffer, size_t size, int flags)
102126 {
103− struct afs_fs_cursor fc;
104− struct afs_status_cb *scb;
127+ struct afs_operation *op;
105128 struct afs_vnode *vnode = AFS_FS_I(inode);
106− struct afs_acl *acl = NULL;
107− struct key *key;
108− int ret = -ENOMEM;
109129
110130 if (flags == XATTR_CREATE)
111131 return -EINVAL;
112132
113− scb = kzalloc(sizeof(struct afs_status_cb), GFP_NOFS);
114− if (!scb)
115− goto error;
116−
117− acl = kmalloc(sizeof(*acl) + size, GFP_KERNEL);
118− if (!acl)
119− goto error_scb;
120−
121− key = afs_request_key(vnode->volume->cell);
122− if (IS_ERR(key)) {
123− ret = PTR_ERR(key);
124− goto error_acl;
125− }
126−
127− acl->size = size;
128− memcpy(acl->data, buffer, size);
129−
130− ret = -ERESTARTSYS;
131− if (afs_begin_vnode_operation(&fc, vnode, key, true)) {
132− afs_dataversion_t data_version = vnode->status.data_version;
133+ op = afs_alloc_operation(NULL, vnode->volume);
134+ if (IS_ERR(op))
135+ return -ENOMEM;
133136
134− while (afs_select_fileserver(&fc)) {
135− fc.cb_break = afs_calc_vnode_cb_break(vnode);
136− afs_fs_store_acl(&fc, acl, scb);
137− }
137+ afs_op_set_vnode(op, 0, vnode);
138+ if (!afs_make_acl(op, buffer, size))
139+ return afs_put_operation(op);
138140
139− afs_check_for_remote_deletion(&fc, fc.vnode);
140− afs_vnode_commit_status(&fc, vnode, fc.cb_break,
141− &data_version, scb);
142− ret = afs_end_vnode_operation(&fc);
143− }
144−
145− key_put(key);
146−error_acl:
147− kfree(acl);
148−error_scb:
149− kfree(scb);
150−error:
151− return ret;
141+ op->ops = &afs_store_acl_operation;
142+ return afs_do_sync_operation(op);
152143 }
153144
154145 static const struct xattr_handler afs_xattr_afs_acl_handler = {
@@ -157,6 +148,17 @@ static const struct xattr_handler afs_xattr_afs_acl_handler = { · 2 unmodified lines
157148 .set = afs_xattr_set_acl,
158149 };
159150
151+static void yfs_acl_put(struct afs_operation *op)
152+{
153+ yfs_free_opaque_acl(op->yacl);
154+}
155+
156+static const struct afs_operation_ops yfs_fetch_opaque_acl_operation = {
157+ .issue_yfs_rpc = yfs_fs_fetch_opaque_acl,
158+ .success = afs_acl_success,
159+ /* Don't free op->yacl in .put here */
160+};
161+
160162 /*
161163 * Get a file's YFS ACL.
162164 */
@@ -165,11 +167,9 @@ static int afs_xattr_get_yfs(const struct xattr_handler *handler, · 2 unmodified lines
165167 struct inode *inode, const char *name,
166168 void *buffer, size_t size)
167169 {
168− struct afs_fs_cursor fc;
169− struct afs_status_cb *scb;
170+ struct afs_operation *op;
170171 struct afs_vnode *vnode = AFS_FS_I(inode);
171172 struct yfs_acl *yacl = NULL;
172− struct key *key;
173173 char buf[16], *data;
174174 int which = 0, dsize, ret = -ENOMEM;
175175
@@ -193,75 +193,62 @@ static int afs_xattr_get_yfs(const struct xattr_handler *handler, · 17 unmodified lines
193193 else if (which == 3)
194194 yacl->flags |= YFS_ACL_WANT_VOL_ACL;
195195
196− scb = kzalloc(sizeof(struct afs_status_cb), GFP_NOFS);
197− if (!scb)
196+ op = afs_alloc_operation(NULL, vnode->volume);
197+ if (IS_ERR(op))
198198 goto error_yacl;
199199
200− key = afs_request_key(vnode->volume->cell);
201− if (IS_ERR(key)) {
202− ret = PTR_ERR(key);
203− goto error_scb;
204− }
200+ afs_op_set_vnode(op, 0, vnode);
201+ op->yacl = yacl;
202+ op->ops = &yfs_fetch_opaque_acl_operation;
205203
206− ret = -ERESTARTSYS;
207− if (afs_begin_vnode_operation(&fc, vnode, key, true)) {
208− afs_dataversion_t data_version = vnode->status.data_version;
204+ afs_begin_vnode_operation(op);
205+ afs_wait_for_operation(op);
206+ ret = afs_put_operation(op);
209207
210− while (afs_select_fileserver(&fc)) {
211− fc.cb_break = afs_calc_vnode_cb_break(vnode);
212− yfs_fs_fetch_opaque_acl(&fc, yacl, scb);
208+ if (ret == 0) {
209+ switch (which) {
210+ case 0:
211+ data = yacl->acl->data;
212+ dsize = yacl->acl->size;
213+ break;
214+ case 1:
215+ data = buf;
216+ dsize = scnprintf(buf, sizeof(buf), "%u", yacl->inherit_flag);
217+ break;
218+ case 2:
219+ data = buf;
220+ dsize = scnprintf(buf, sizeof(buf), "%u", yacl->num_cleaned);
221+ break;
222+ case 3:
223+ data = yacl->vol_acl->data;
224+ dsize = yacl->vol_acl->size;
225+ break;
226+ default:
227+ ret = -EOPNOTSUPP;
228+ goto error_yacl;
213229 }
214230
215− afs_check_for_remote_deletion(&fc, fc.vnode);
216− afs_vnode_commit_status(&fc, vnode, fc.cb_break,
217− &data_version, scb);
218− ret = afs_end_vnode_operation(&fc);
219− }
220−
221− if (ret < 0)
222− goto error_key;
223−
224− switch (which) {
225− case 0:
226− data = yacl->acl->data;
227− dsize = yacl->acl->size;
228− break;
229− case 1:
230− data = buf;
231− dsize = scnprintf(buf, sizeof(buf), "%u", yacl->inherit_flag);
232− break;
233− case 2:
234− data = buf;
235− dsize = scnprintf(buf, sizeof(buf), "%u", yacl->num_cleaned);
236− break;
237− case 3:
238− data = yacl->vol_acl->data;
239− dsize = yacl->vol_acl->size;
240− break;
241− default:
242− ret = -EOPNOTSUPP;
243− goto error_key;
244− }
245−
246− ret = dsize;
247− if (size > 0) {
248− if (dsize > size) {
249− ret = -ERANGE;
250− goto error_key;
231+ ret = dsize;
232+ if (size > 0) {
233+ if (dsize <= size)
234+ memcpy(buffer, data, dsize);
235+ else
236+ ret = -ERANGE;
251237 }
252− memcpy(buffer, data, dsize);
253238 }
254239
255−error_key:
256− key_put(key);
257−error_scb:
258− kfree(scb);
259240 error_yacl:
260241 yfs_free_opaque_acl(yacl);
261242 error:
262243 return ret;
263244 }
264245
246+static const struct afs_operation_ops yfs_store_opaque_acl2_operation = {
247+ .issue_yfs_rpc = yfs_fs_store_opaque_acl2,
248+ .success = afs_acl_success,
249+ .put = yfs_acl_put,
250+};
251+
265252 /*
266253 * Set a file's YFS ACL.
267254 */
@@ -270,56 +257,23 @@ static int afs_xattr_set_yfs(const struct xattr_handler *handler, · 2 unmodified lines
270257 struct inode *inode, const char *name,
271258 const void *buffer, size_t size, int flags)
272259 {
273− struct afs_fs_cursor fc;
274− struct afs_status_cb *scb;
260+ struct afs_operation *op;
275261 struct afs_vnode *vnode = AFS_FS_I(inode);
276− struct afs_acl *acl = NULL;
277− struct key *key;
278− int ret = -ENOMEM;
279262
280263 if (flags == XATTR_CREATE ||
281264 strcmp(name, "acl") != 0)
282265 return -EINVAL;
283266
284− scb = kzalloc(sizeof(struct afs_status_cb), GFP_NOFS);
285− if (!scb)
286− goto error;
287−
288− acl = kmalloc(sizeof(*acl) + size, GFP_KERNEL);
289− if (!acl)
290− goto error_scb;
267+ op = afs_alloc_operation(NULL, vnode->volume);
268+ if (IS_ERR(op))
269+ return -ENOMEM;
291270
292− acl->size = size;
293− memcpy(acl->data, buffer, size);
271+ afs_op_set_vnode(op, 0, vnode);
272+ if (!afs_make_acl(op, buffer, size))
273+ return afs_put_operation(op);
294274
295− key = afs_request_key(vnode->volume->cell);
296− if (IS_ERR(key)) {
297− ret = PTR_ERR(key);
298− goto error_acl;
299− }
300−
301− ret = -ERESTARTSYS;
302− if (afs_begin_vnode_operation(&fc, vnode, key, true)) {
303− afs_dataversion_t data_version = vnode->status.data_version;
304−
305− while (afs_select_fileserver(&fc)) {
306− fc.cb_break = afs_calc_vnode_cb_break(vnode);
307− yfs_fs_store_opaque_acl2(&fc, acl, scb);
308− }
309−
310− afs_check_for_remote_deletion(&fc, fc.vnode);
311− afs_vnode_commit_status(&fc, vnode, fc.cb_break,
312− &data_version, scb);
313− ret = afs_end_vnode_operation(&fc);
314− }
315−
316−error_acl:
317− kfree(acl);
318− key_put(key);
319−error_scb:
320− kfree(scb);
321−error:
322− return ret;
275+ op->ops = &yfs_store_opaque_acl2_operation;
276+ return afs_do_sync_operation(op);
323277 }
324278
325279 static const struct xattr_handler afs_xattr_yfs_handler = {
fs/afs/yfsclient.c+375−539
@@ -17,11 +17,6 @@ · 16 unmodified lines
1717
1818 static const struct afs_fid afs_zero_fid;
1919
20−static inline void afs_use_fs_server(struct afs_call *call, struct afs_cb_interest *cbi)
21−{
22− call->cbi = afs_get_cb_interest(cbi);
23−}
24−
2520 #define xdr_size(x) (sizeof(*x) / sizeof(__be32))
2621
2722 static void xdr_decode_YFSFid(const __be32 **_bp, struct afs_fid *fid)
@@ -79,6 +74,11 @@ static __be32 *xdr_encode_string(__be32 *bp, const char *p, unsigned int len) · 51 unmodified lines
7974 return bp + len / sizeof(__be32);
8075 }
8176
77+static __be32 *xdr_encode_name(__be32 *bp, const struct qstr *p)
78+{
79+ return xdr_encode_string(bp, p->name, p->len);
80+}
81+
8282 static s64 linux_to_yfs_time(const struct timespec64 *t)
8383 {
8484 /* Convert to 100ns intervals. */
@@ -179,21 +179,20 @@ static void xdr_dump_bad(const __be32 *bp) · 94 unmodified lines
179179 /*
180180 * Decode a YFSFetchStatus block
181181 */
182−static int xdr_decode_YFSFetchStatus(const __be32 **_bp,
183− struct afs_call *call,
184− struct afs_status_cb *scb)
182+static void xdr_decode_YFSFetchStatus(const __be32 **_bp,
183+ struct afs_call *call,
184+ struct afs_status_cb *scb)
185185 {
186186 const struct yfs_xdr_YFSFetchStatus *xdr = (const void *)*_bp;
187187 struct afs_file_status *status = &scb->status;
188188 u32 type;
189− int ret;
190189
191190 status->abort_code = ntohl(xdr->abort_code);
192191 if (status->abort_code != 0) {
193192 if (status->abort_code == VNOVNODE)
194193 status->nlink = 0;
195194 scb->have_error = true;
196− goto good;
195+ goto advance;
197196 }
198197
199198 type = ntohl(xdr->type);
@@ -221,15 +220,13 @@ static int xdr_decode_YFSFetchStatus(const __be32 **_bp, · 21 unmodified lines
221220 status->size = xdr_to_u64(xdr->size);
222221 status->data_version = xdr_to_u64(xdr->data_version);
223222 scb->have_status = true;
224−good:
225− ret = 0;
226223 advance:
227224 *_bp += xdr_size(xdr);
228− return ret;
225+ return;
229226
230227 bad:
231228 xdr_dump_bad(*_bp);
232− ret = afs_protocol_error(call, -EBADMSG, afs_eproto_bad_status);
229+ afs_protocol_error(call, afs_eproto_bad_status);
233230 goto advance;
234231 }
235232
@@ -339,6 +336,7 @@ static void xdr_decode_YFSFetchVolumeStatus(const __be32 **_bp, · 103 unmodified lines
339336 */
340337 static int yfs_deliver_fs_status_cb_and_volsync(struct afs_call *call)
341338 {
339+ struct afs_operation *op = call->op;
342340 const __be32 *bp;
343341 int ret;
344342
@@ -348,11 +346,9 @@ static int yfs_deliver_fs_status_cb_and_volsync(struct afs_call *call) · 3 unmodified lines
348346
349347 /* unmarshall the reply once we've received all of it */
350348 bp = call->buffer;
351− ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
352− if (ret < 0)
353− return ret;
354− xdr_decode_YFSCallBack(&bp, call, call->out_scb);
355− xdr_decode_YFSVolSync(&bp, call->out_volsync);
349+ xdr_decode_YFSFetchStatus(&bp, call, &op->file[0].scb);
350+ xdr_decode_YFSCallBack(&bp, call, &op->file[0].scb);
351+ xdr_decode_YFSVolSync(&bp, &op->volsync);
356352
357353 _leave(" = 0 [done]");
358354 return 0;
@@ -364,6 +360,7 @@ static int yfs_deliver_fs_status_cb_and_volsync(struct afs_call *call) · 5 unmodified lines
364360 */
365361 static int yfs_deliver_status_and_volsync(struct afs_call *call)
366362 {
363+ struct afs_operation *op = call->op;
367364 const __be32 *bp;
368365 int ret;
369366
@@ -372,10 +369,8 @@ static int yfs_deliver_status_and_volsync(struct afs_call *call) · 2 unmodified lines
372369 return ret;
373370
374371 bp = call->buffer;
375− ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
376− if (ret < 0)
377− return ret;
378− xdr_decode_YFSVolSync(&bp, call->out_volsync);
372+ xdr_decode_YFSFetchStatus(&bp, call, &op->file[0].scb);
373+ xdr_decode_YFSVolSync(&bp, &op->volsync);
379374
380375 _leave(" = 0 [done]");
381376 return 0;
@@ -394,44 +389,33 @@ static const struct afs_call_type yfs_RXYFSFetchStatus_vnode = { · 12 unmodified lines
394389 /*
395390 * Fetch the status information for a file.
396391 */
397−int yfs_fs_fetch_file_status(struct afs_fs_cursor *fc, struct afs_status_cb *scb,
398− struct afs_volsync *volsync)
392+void yfs_fs_fetch_file_status(struct afs_operation *op)
399393 {
400− struct afs_vnode *vnode = fc->vnode;
394+ struct afs_vnode_param *vp = &op->file[0];
401395 struct afs_call *call;
402− struct afs_net *net = afs_v2net(vnode);
403396 __be32 *bp;
404397
405398 _enter(",%x,{%llx:%llu},,",
406− key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
399+ key_serial(op->key), vp->fid.vid, vp->fid.vnode);
407400
408− call = afs_alloc_flat_call(net, &yfs_RXYFSFetchStatus_vnode,
401+ call = afs_alloc_flat_call(op->net, &yfs_RXYFSFetchStatus_vnode,
409402 sizeof(__be32) * 2 +
410403 sizeof(struct yfs_xdr_YFSFid),
411404 sizeof(struct yfs_xdr_YFSFetchStatus) +
412405 sizeof(struct yfs_xdr_YFSCallBack) +
413406 sizeof(struct yfs_xdr_YFSVolSync));
414− if (!call) {
415− fc->ac.error = -ENOMEM;
416− return -ENOMEM;
417− }
418−
419− call->key = fc->key;
420− call->out_scb = scb;
421− call->out_volsync = volsync;
407+ if (!call)
408+ return afs_op_nomem(op);
422409
423410 /* marshall the parameters */
424411 bp = call->request;
425412 bp = xdr_encode_u32(bp, YFSFETCHSTATUS);
426413 bp = xdr_encode_u32(bp, 0); /* RPC flags */
427− bp = xdr_encode_YFSFid(bp, &vnode->fid);
414+ bp = xdr_encode_YFSFid(bp, &vp->fid);
428415 yfs_check_req(call, bp);
429416
430− afs_use_fs_server(call, fc->cbi);
431− trace_afs_make_fs_call(call, &vnode->fid);
432− afs_set_fc_call(call, fc);
433− afs_make_call(&fc->ac, call, GFP_NOFS);
434− return afs_wait_for_call_to_complete(call, &fc->ac);
417+ trace_afs_make_fs_call(call, &vp->fid);
418+ afs_make_op_call(op, call, GFP_NOFS);
435419 }
436420
437421 /*
@@ -439,7 +423,9 @@ int yfs_fs_fetch_file_status(struct afs_fs_cursor *fc, struct afs_status_cb *scb · 1 unmodified line
439423 */
440424 static int yfs_deliver_fs_fetch_data64(struct afs_call *call)
441425 {
442− struct afs_read *req = call->read_request;
426+ struct afs_operation *op = call->op;
427+ struct afs_vnode_param *vp = &op->file[0];
428+ struct afs_read *req = op->fetch.req;
443429 const __be32 *bp;
444430 unsigned int size;
445431 int ret;
@@ -534,14 +520,12 @@ static int yfs_deliver_fs_fetch_data64(struct afs_call *call) · 88 unmodified lines
534520 return ret;
535521
536522 bp = call->buffer;
537− ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
538− if (ret < 0)
539− return ret;
540− xdr_decode_YFSCallBack(&bp, call, call->out_scb);
541− xdr_decode_YFSVolSync(&bp, call->out_volsync);
523+ xdr_decode_YFSFetchStatus(&bp, call, &vp->scb);
524+ xdr_decode_YFSCallBack(&bp, call, &vp->scb);
525+ xdr_decode_YFSVolSync(&bp, &op->volsync);
542526
543− req->data_version = call->out_scb->status.data_version;
544− req->file_size = call->out_scb->status.size;
527+ req->data_version = vp->scb.status.data_version;
528+ req->file_size = vp->scb.status.size;
545529
546530 call->unmarshall++;
547531 /* Fall through */
@@ -565,12 +549,6 @@ static int yfs_deliver_fs_fetch_data64(struct afs_call *call) · 17 unmodified lines
565549 return 0;
566550 }
567551
568−static void yfs_fetch_data_destructor(struct afs_call *call)
569−{
570− afs_put_read(call->read_request);
571− afs_flat_call_destructor(call);
572−}
573−
574552 /*
575553 * YFS.FetchData64 operation type
576554 */
@@ -578,25 +556,24 @@ static const struct afs_call_type yfs_RXYFSFetchData64 = { · 1 unmodified line
578556 .name = "YFS.FetchData64",
579557 .op = yfs_FS_FetchData64,
580558 .deliver = yfs_deliver_fs_fetch_data64,
581− .destructor = yfs_fetch_data_destructor,
559+ .destructor = afs_flat_call_destructor,
582560 };
583561
584562 /*
585563 * Fetch data from a file.
586564 */
587−int yfs_fs_fetch_data(struct afs_fs_cursor *fc, struct afs_status_cb *scb,
588− struct afs_read *req)
565+void yfs_fs_fetch_data(struct afs_operation *op)
589566 {
590− struct afs_vnode *vnode = fc->vnode;
567+ struct afs_vnode_param *vp = &op->file[0];
568+ struct afs_read *req = op->fetch.req;
591569 struct afs_call *call;
592− struct afs_net *net = afs_v2net(vnode);
593570 __be32 *bp;
594571
595572 _enter(",%x,{%llx:%llu},%llx,%llx",
596− key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode,
573+ key_serial(op->key), vp->fid.vid, vp->fid.vnode,
597574 req->pos, req->len);
598575
599− call = afs_alloc_flat_call(net, &yfs_RXYFSFetchData64,
576+ call = afs_alloc_flat_call(op->net, &yfs_RXYFSFetchData64,
600577 sizeof(__be32) * 2 +
601578 sizeof(struct yfs_xdr_YFSFid) +
602579 sizeof(struct yfs_xdr_u64) * 2,
@@ -604,27 +581,19 @@ int yfs_fs_fetch_data(struct afs_fs_cursor *fc, struct afs_status_cb *scb, · 1 unmodified line
604581 sizeof(struct yfs_xdr_YFSCallBack) +
605582 sizeof(struct yfs_xdr_YFSVolSync));
606583 if (!call)
607− return -ENOMEM;
608−
609− call->key = fc->key;
610− call->out_scb = scb;
611− call->out_volsync = NULL;
612− call->read_request = afs_get_read(req);
584+ return afs_op_nomem(op);
613585
614586 /* marshall the parameters */
615587 bp = call->request;
616588 bp = xdr_encode_u32(bp, YFSFETCHDATA64);
617589 bp = xdr_encode_u32(bp, 0); /* RPC flags */
618− bp = xdr_encode_YFSFid(bp, &vnode->fid);
590+ bp = xdr_encode_YFSFid(bp, &vp->fid);
619591 bp = xdr_encode_u64(bp, req->pos);
620592 bp = xdr_encode_u64(bp, req->len);
621593 yfs_check_req(call, bp);
622594
623− afs_use_fs_server(call, fc->cbi);
624− trace_afs_make_fs_call(call, &vnode->fid);
625− afs_set_fc_call(call, fc);
626− afs_make_call(&fc->ac, call, GFP_NOFS);
627− return afs_wait_for_call_to_complete(call, &fc->ac);
595+ trace_afs_make_fs_call(call, &vp->fid);
596+ afs_make_op_call(op, call, GFP_NOFS);
628597 }
629598
630599 /*
@@ -632,6 +601,9 @@ int yfs_fs_fetch_data(struct afs_fs_cursor *fc, struct afs_status_cb *scb, · 1 unmodified line
632601 */
633602 static int yfs_deliver_fs_create_vnode(struct afs_call *call)
634603 {
604+ struct afs_operation *op = call->op;
605+ struct afs_vnode_param *dvp = &op->file[0];
606+ struct afs_vnode_param *vp = &op->file[1];
635607 const __be32 *bp;
636608 int ret;
637609
@@ -643,15 +615,11 @@ static int yfs_deliver_fs_create_vnode(struct afs_call *call) · 5 unmodified lines
643615
644616 /* unmarshall the reply once we've received all of it */
645617 bp = call->buffer;
646− xdr_decode_YFSFid(&bp, call->out_fid);
647− ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
648− if (ret < 0)
649− return ret;
650− ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb);
651− if (ret < 0)
652− return ret;
653− xdr_decode_YFSCallBack(&bp, call, call->out_scb);
654− xdr_decode_YFSVolSync(&bp, call->out_volsync);
618+ xdr_decode_YFSFid(&bp, &op->file[1].fid);
619+ xdr_decode_YFSFetchStatus(&bp, call, &vp->scb);
620+ xdr_decode_YFSFetchStatus(&bp, call, &dvp->scb);
621+ xdr_decode_YFSCallBack(&bp, call, &vp->scb);
622+ xdr_decode_YFSVolSync(&bp, &op->volsync);
655623
656624 _leave(" = 0 [done]");
657625 return 0;
@@ -670,26 +638,20 @@ static const struct afs_call_type afs_RXFSCreateFile = { · 12 unmodified lines
670638 /*
671639 * Create a file.
672640 */
673−int yfs_fs_create_file(struct afs_fs_cursor *fc,
674− const char *name,
675− umode_t mode,
676− struct afs_status_cb *dvnode_scb,
677− struct afs_fid *newfid,
678− struct afs_status_cb *new_scb)
641+void yfs_fs_create_file(struct afs_operation *op)
679642 {
680− struct afs_vnode *dvnode = fc->vnode;
643+ const struct qstr *name = &op->dentry->d_name;
644+ struct afs_vnode_param *dvp = &op->file[0];
681645 struct afs_call *call;
682− struct afs_net *net = afs_v2net(dvnode);
683− size_t namesz, reqsz, rplsz;
646+ size_t reqsz, rplsz;
684647 __be32 *bp;
685648
686649 _enter("");
687650
688− namesz = strlen(name);
689651 reqsz = (sizeof(__be32) +
690652 sizeof(__be32) +
691653 sizeof(struct yfs_xdr_YFSFid) +
692− xdr_strlen(namesz) +
654+ xdr_strlen(name->len) +
693655 sizeof(struct yfs_xdr_YFSStoreStatus) +
694656 sizeof(__be32));
695657 rplsz = (sizeof(struct yfs_xdr_YFSFid) +
@@ -698,30 +660,22 @@ int yfs_fs_create_file(struct afs_fs_cursor *fc, · 2 unmodified lines
698660 sizeof(struct yfs_xdr_YFSCallBack) +
699661 sizeof(struct yfs_xdr_YFSVolSync));
700662
701− call = afs_alloc_flat_call(net, &afs_RXFSCreateFile, reqsz, rplsz);
663+ call = afs_alloc_flat_call(op->net, &afs_RXFSCreateFile, reqsz, rplsz);
702664 if (!call)
703− return -ENOMEM;
704−
705− call->key = fc->key;
706− call->out_dir_scb = dvnode_scb;
707− call->out_fid = newfid;
708− call->out_scb = new_scb;
665+ return afs_op_nomem(op);
709666
710667 /* marshall the parameters */
711668 bp = call->request;
712669 bp = xdr_encode_u32(bp, YFSCREATEFILE);
713670 bp = xdr_encode_u32(bp, 0); /* RPC flags */
714− bp = xdr_encode_YFSFid(bp, &dvnode->fid);
715− bp = xdr_encode_string(bp, name, namesz);
716− bp = xdr_encode_YFSStoreStatus_mode(bp, mode);
671+ bp = xdr_encode_YFSFid(bp, &dvp->fid);
672+ bp = xdr_encode_name(bp, name);
673+ bp = xdr_encode_YFSStoreStatus_mode(bp, op->create.mode);
717674 bp = xdr_encode_u32(bp, yfs_LockNone); /* ViceLockType */
718675 yfs_check_req(call, bp);
719676
720− afs_use_fs_server(call, fc->cbi);
721− trace_afs_make_fs_call1(call, &dvnode->fid, name);
722− afs_set_fc_call(call, fc);
723− afs_make_call(&fc->ac, call, GFP_NOFS);
724− return afs_wait_for_call_to_complete(call, &fc->ac);
677+ trace_afs_make_fs_call1(call, &dvp->fid, name);
678+ afs_make_op_call(op, call, GFP_NOFS);
725679 }
726680
727681 static const struct afs_call_type yfs_RXFSMakeDir = {
@@ -734,26 +688,20 @@ static const struct afs_call_type yfs_RXFSMakeDir = { · 6 unmodified lines
734688 /*
735689 * Make a directory.
736690 */
737−int yfs_fs_make_dir(struct afs_fs_cursor *fc,
738− const char *name,
739− umode_t mode,
740− struct afs_status_cb *dvnode_scb,
741− struct afs_fid *newfid,
742− struct afs_status_cb *new_scb)
691+void yfs_fs_make_dir(struct afs_operation *op)
743692 {
744− struct afs_vnode *dvnode = fc->vnode;
693+ const struct qstr *name = &op->dentry->d_name;
694+ struct afs_vnode_param *dvp = &op->file[0];
745695 struct afs_call *call;
746− struct afs_net *net = afs_v2net(dvnode);
747− size_t namesz, reqsz, rplsz;
696+ size_t reqsz, rplsz;
748697 __be32 *bp;
749698
750699 _enter("");
751700
752− namesz = strlen(name);
753701 reqsz = (sizeof(__be32) +
754702 sizeof(struct yfs_xdr_RPCFlags) +
755703 sizeof(struct yfs_xdr_YFSFid) +
756− xdr_strlen(namesz) +
704+ xdr_strlen(name->len) +
757705 sizeof(struct yfs_xdr_YFSStoreStatus));
758706 rplsz = (sizeof(struct yfs_xdr_YFSFid) +
759707 sizeof(struct yfs_xdr_YFSFetchStatus) +
@@ -761,29 +709,21 @@ int yfs_fs_make_dir(struct afs_fs_cursor *fc, · 1 unmodified line
761709 sizeof(struct yfs_xdr_YFSCallBack) +
762710 sizeof(struct yfs_xdr_YFSVolSync));
763711
764− call = afs_alloc_flat_call(net, &yfs_RXFSMakeDir, reqsz, rplsz);
712+ call = afs_alloc_flat_call(op->net, &yfs_RXFSMakeDir, reqsz, rplsz);
765713 if (!call)
766− return -ENOMEM;
767−
768− call->key = fc->key;
769− call->out_dir_scb = dvnode_scb;
770− call->out_fid = newfid;
771− call->out_scb = new_scb;
714+ return afs_op_nomem(op);
772715
773716 /* marshall the parameters */
774717 bp = call->request;
775718 bp = xdr_encode_u32(bp, YFSMAKEDIR);
776719 bp = xdr_encode_u32(bp, 0); /* RPC flags */
777− bp = xdr_encode_YFSFid(bp, &dvnode->fid);
778− bp = xdr_encode_string(bp, name, namesz);
779− bp = xdr_encode_YFSStoreStatus_mode(bp, mode);
720+ bp = xdr_encode_YFSFid(bp, &dvp->fid);
721+ bp = xdr_encode_name(bp, name);
722+ bp = xdr_encode_YFSStoreStatus_mode(bp, op->create.mode);
780723 yfs_check_req(call, bp);
781724
782− afs_use_fs_server(call, fc->cbi);
783− trace_afs_make_fs_call1(call, &dvnode->fid, name);
784− afs_set_fc_call(call, fc);
785− afs_make_call(&fc->ac, call, GFP_NOFS);
786− return afs_wait_for_call_to_complete(call, &fc->ac);
725+ trace_afs_make_fs_call1(call, &dvp->fid, name);
726+ afs_make_op_call(op, call, GFP_NOFS);
787727 }
788728
789729 /*
@@ -791,6 +731,9 @@ int yfs_fs_make_dir(struct afs_fs_cursor *fc, · 1 unmodified line
791731 */
792732 static int yfs_deliver_fs_remove_file2(struct afs_call *call)
793733 {
734+ struct afs_operation *op = call->op;
735+ struct afs_vnode_param *dvp = &op->file[0];
736+ struct afs_vnode_param *vp = &op->file[1];
794737 struct afs_fid fid;
795738 const __be32 *bp;
796739 int ret;
@@ -802,20 +745,24 @@ static int yfs_deliver_fs_remove_file2(struct afs_call *call) · 5 unmodified lines
802745 return ret;
803746
804747 bp = call->buffer;
805− ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb);
806− if (ret < 0)
807− return ret;
808−
748+ xdr_decode_YFSFetchStatus(&bp, call, &dvp->scb);
809749 xdr_decode_YFSFid(&bp, &fid);
810− ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
811− if (ret < 0)
812− return ret;
750+ xdr_decode_YFSFetchStatus(&bp, call, &vp->scb);
813751 /* Was deleted if vnode->status.abort_code == VNOVNODE. */
814752
815− xdr_decode_YFSVolSync(&bp, call->out_volsync);
753+ xdr_decode_YFSVolSync(&bp, &op->volsync);
816754 return 0;
817755 }
818756
757+static void yfs_done_fs_remove_file2(struct afs_call *call)
758+{
759+ if (call->error == -ECONNABORTED &&
760+ call->abort_code == RX_INVALID_OPERATION) {
761+ set_bit(AFS_SERVER_FL_NO_RM2, &call->server->flags);
762+ call->op->flags |= AFS_OPERATION_DOWNGRADE;
763+ }
764+}
765+
819766 /*
820767 * YFS.RemoveFile2 operation type.
821768 */
@@ -823,55 +770,44 @@ static const struct afs_call_type yfs_RXYFSRemoveFile2 = { · 1 unmodified line
823770 .name = "YFS.RemoveFile2",
824771 .op = yfs_FS_RemoveFile2,
825772 .deliver = yfs_deliver_fs_remove_file2,
773+ .done = yfs_done_fs_remove_file2,
826774 .destructor = afs_flat_call_destructor,
827775 };
828776
829777 /*
830778 * Remove a file and retrieve new file status.
831779 */
832−int yfs_fs_remove_file2(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
833− const char *name, struct afs_status_cb *dvnode_scb,
834− struct afs_status_cb *vnode_scb)
780+void yfs_fs_remove_file2(struct afs_operation *op)
835781 {
836− struct afs_vnode *dvnode = fc->vnode;
782+ struct afs_vnode_param *dvp = &op->file[0];
783+ const struct qstr *name = &op->dentry->d_name;
837784 struct afs_call *call;
838− struct afs_net *net = afs_v2net(dvnode);
839− size_t namesz;
840785 __be32 *bp;
841786
842787 _enter("");
843788
844− namesz = strlen(name);
845−
846− call = afs_alloc_flat_call(net, &yfs_RXYFSRemoveFile2,
789+ call = afs_alloc_flat_call(op->net, &yfs_RXYFSRemoveFile2,
847790 sizeof(__be32) +
848791 sizeof(struct yfs_xdr_RPCFlags) +
849792 sizeof(struct yfs_xdr_YFSFid) +
850− xdr_strlen(namesz),
793+ xdr_strlen(name->len),
851794 sizeof(struct yfs_xdr_YFSFetchStatus) +
852795 sizeof(struct yfs_xdr_YFSFid) +
853796 sizeof(struct yfs_xdr_YFSFetchStatus) +
854797 sizeof(struct yfs_xdr_YFSVolSync));
855798 if (!call)
856− return -ENOMEM;
857−
858− call->key = fc->key;
859− call->out_dir_scb = dvnode_scb;
860− call->out_scb = vnode_scb;
799+ return afs_op_nomem(op);
861800
862801 /* marshall the parameters */
863802 bp = call->request;
864803 bp = xdr_encode_u32(bp, YFSREMOVEFILE2);
865804 bp = xdr_encode_u32(bp, 0); /* RPC flags */
866− bp = xdr_encode_YFSFid(bp, &dvnode->fid);
867− bp = xdr_encode_string(bp, name, namesz);
805+ bp = xdr_encode_YFSFid(bp, &dvp->fid);
806+ bp = xdr_encode_name(bp, name);
868807 yfs_check_req(call, bp);
869808
870− afs_use_fs_server(call, fc->cbi);
871− trace_afs_make_fs_call1(call, &dvnode->fid, name);
872− afs_set_fc_call(call, fc);
873− afs_make_call(&fc->ac, call, GFP_NOFS);
874− return afs_wait_for_call_to_complete(call, &fc->ac);
809+ trace_afs_make_fs_call1(call, &dvp->fid, name);
810+ afs_make_op_call(op, call, GFP_NOFS);
875811 }
876812
877813 /*
@@ -879,6 +815,8 @@ int yfs_fs_remove_file2(struct afs_fs_cursor *fc, struct afs_vnode *vnode, · 1 unmodified line
879815 */
880816 static int yfs_deliver_fs_remove(struct afs_call *call)
881817 {
818+ struct afs_operation *op = call->op;
819+ struct afs_vnode_param *dvp = &op->file[0];
882820 const __be32 *bp;
883821 int ret;
884822
@@ -889,11 +827,8 @@ static int yfs_deliver_fs_remove(struct afs_call *call) · 4 unmodified lines
889827 return ret;
890828
891829 bp = call->buffer;
892− ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb);
893− if (ret < 0)
894− return ret;
895−
896− xdr_decode_YFSVolSync(&bp, call->out_volsync);
830+ xdr_decode_YFSFetchStatus(&bp, call, &dvp->scb);
831+ xdr_decode_YFSVolSync(&bp, &op->volsync);
897832 return 0;
898833 }
899834
@@ -907,6 +842,43 @@ static const struct afs_call_type yfs_RXYFSRemoveFile = { · 7 unmodified lines
907842 .destructor = afs_flat_call_destructor,
908843 };
909844
845+/*
846+ * Remove a file.
847+ */
848+void yfs_fs_remove_file(struct afs_operation *op)
849+{
850+ const struct qstr *name = &op->dentry->d_name;
851+ struct afs_vnode_param *dvp = &op->file[0];
852+ struct afs_call *call;
853+ __be32 *bp;
854+
855+ _enter("");
856+
857+ if (!test_bit(AFS_SERVER_FL_NO_RM2, &op->server->flags))
858+ return yfs_fs_remove_file2(op);
859+
860+ call = afs_alloc_flat_call(op->net, &yfs_RXYFSRemoveFile,
861+ sizeof(__be32) +
862+ sizeof(struct yfs_xdr_RPCFlags) +
863+ sizeof(struct yfs_xdr_YFSFid) +
864+ xdr_strlen(name->len),
865+ sizeof(struct yfs_xdr_YFSFetchStatus) +
866+ sizeof(struct yfs_xdr_YFSVolSync));
867+ if (!call)
868+ return afs_op_nomem(op);
869+
870+ /* marshall the parameters */
871+ bp = call->request;
872+ bp = xdr_encode_u32(bp, YFSREMOVEFILE);
873+ bp = xdr_encode_u32(bp, 0); /* RPC flags */
874+ bp = xdr_encode_YFSFid(bp, &dvp->fid);
875+ bp = xdr_encode_name(bp, name);
876+ yfs_check_req(call, bp);
877+
878+ trace_afs_make_fs_call1(call, &dvp->fid, name);
879+ afs_make_op_call(op, call, GFP_NOFS);
880+}
881+
910882 static const struct afs_call_type yfs_RXYFSRemoveDir = {
911883 .name = "YFS.RemoveDir",
912884 .op = yfs_FS_RemoveDir,
@@ -915,48 +887,37 @@ static const struct afs_call_type yfs_RXYFSRemoveDir = { · 2 unmodified lines
915887 };
916888
917889 /*
918− * remove a file or directory
890+ * Remove a directory.
919891 */
920−int yfs_fs_remove(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
921− const char *name, bool isdir,
922− struct afs_status_cb *dvnode_scb)
892+void yfs_fs_remove_dir(struct afs_operation *op)
923893 {
924− struct afs_vnode *dvnode = fc->vnode;
894+ const struct qstr *name = &op->dentry->d_name;
895+ struct afs_vnode_param *dvp = &op->file[0];
925896 struct afs_call *call;
926− struct afs_net *net = afs_v2net(dvnode);
927− size_t namesz;
928897 __be32 *bp;
929898
930899 _enter("");
931900
932− namesz = strlen(name);
933− call = afs_alloc_flat_call(
934− net, isdir ? &yfs_RXYFSRemoveDir : &yfs_RXYFSRemoveFile,
935− sizeof(__be32) +
936− sizeof(struct yfs_xdr_RPCFlags) +
937− sizeof(struct yfs_xdr_YFSFid) +
938− xdr_strlen(namesz),
939− sizeof(struct yfs_xdr_YFSFetchStatus) +
940− sizeof(struct yfs_xdr_YFSVolSync));
901+ call = afs_alloc_flat_call(op->net, &yfs_RXYFSRemoveDir,
902+ sizeof(__be32) +
903+ sizeof(struct yfs_xdr_RPCFlags) +
904+ sizeof(struct yfs_xdr_YFSFid) +
905+ xdr_strlen(name->len),
906+ sizeof(struct yfs_xdr_YFSFetchStatus) +
907+ sizeof(struct yfs_xdr_YFSVolSync));
941908 if (!call)
942− return -ENOMEM;
943−
944− call->key = fc->key;
945− call->out_dir_scb = dvnode_scb;
909+ return afs_op_nomem(op);
946910
947911 /* marshall the parameters */
948912 bp = call->request;
949− bp = xdr_encode_u32(bp, isdir ? YFSREMOVEDIR : YFSREMOVEFILE);
913+ bp = xdr_encode_u32(bp, YFSREMOVEDIR);
950914 bp = xdr_encode_u32(bp, 0); /* RPC flags */
951− bp = xdr_encode_YFSFid(bp, &dvnode->fid);
952− bp = xdr_encode_string(bp, name, namesz);
915+ bp = xdr_encode_YFSFid(bp, &dvp->fid);
916+ bp = xdr_encode_name(bp, name);
953917 yfs_check_req(call, bp);
954918
955− afs_use_fs_server(call, fc->cbi);
956− trace_afs_make_fs_call1(call, &dvnode->fid, name);
957− afs_set_fc_call(call, fc);
958− afs_make_call(&fc->ac, call, GFP_NOFS);
959− return afs_wait_for_call_to_complete(call, &fc->ac);
919+ trace_afs_make_fs_call1(call, &dvp->fid, name);
920+ afs_make_op_call(op, call, GFP_NOFS);
960921 }
961922
962923 /*
@@ -964,6 +925,9 @@ int yfs_fs_remove(struct afs_fs_cursor *fc, struct afs_vnode *vnode, · 1 unmodified line
964925 */
965926 static int yfs_deliver_fs_link(struct afs_call *call)
966927 {
928+ struct afs_operation *op = call->op;
929+ struct afs_vnode_param *dvp = &op->file[0];
930+ struct afs_vnode_param *vp = &op->file[1];
967931 const __be32 *bp;
968932 int ret;
969933
@@ -974,13 +938,9 @@ static int yfs_deliver_fs_link(struct afs_call *call) · 4 unmodified lines
974938 return ret;
975939
976940 bp = call->buffer;
977− ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
978− if (ret < 0)
979− return ret;
980− ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb);
981− if (ret < 0)
982− return ret;
983− xdr_decode_YFSVolSync(&bp, call->out_volsync);
941+ xdr_decode_YFSFetchStatus(&bp, call, &vp->scb);
942+ xdr_decode_YFSFetchStatus(&bp, call, &dvp->scb);
943+ xdr_decode_YFSVolSync(&bp, &op->volsync);
984944 _leave(" = 0 [done]");
985945 return 0;
986946 }
@@ -998,50 +958,39 @@ static const struct afs_call_type yfs_RXYFSLink = { · 11 unmodified lines
998958 /*
999959 * Make a hard link.
1000960 */
1001−int yfs_fs_link(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
1002− const char *name,
1003− struct afs_status_cb *dvnode_scb,
1004− struct afs_status_cb *vnode_scb)
961+void yfs_fs_link(struct afs_operation *op)
1005962 {
1006− struct afs_vnode *dvnode = fc->vnode;
963+ const struct qstr *name = &op->dentry->d_name;
964+ struct afs_vnode_param *dvp = &op->file[0];
965+ struct afs_vnode_param *vp = &op->file[1];
1007966 struct afs_call *call;
1008− struct afs_net *net = afs_v2net(vnode);
1009− size_t namesz;
1010967 __be32 *bp;
1011968
1012969 _enter("");
1013970
1014− namesz = strlen(name);
1015− call = afs_alloc_flat_call(net, &yfs_RXYFSLink,
971+ call = afs_alloc_flat_call(op->net, &yfs_RXYFSLink,
1016972 sizeof(__be32) +
1017973 sizeof(struct yfs_xdr_RPCFlags) +
1018974 sizeof(struct yfs_xdr_YFSFid) +
1019− xdr_strlen(namesz) +
975+ xdr_strlen(name->len) +
1020976 sizeof(struct yfs_xdr_YFSFid),
1021977 sizeof(struct yfs_xdr_YFSFetchStatus) +
1022978 sizeof(struct yfs_xdr_YFSFetchStatus) +
1023979 sizeof(struct yfs_xdr_YFSVolSync));
1024980 if (!call)
1025− return -ENOMEM;
1026−
1027− call->key = fc->key;
1028− call->out_dir_scb = dvnode_scb;
1029− call->out_scb = vnode_scb;
981+ return afs_op_nomem(op);
1030982
1031983 /* marshall the parameters */
1032984 bp = call->request;
1033985 bp = xdr_encode_u32(bp, YFSLINK);
1034986 bp = xdr_encode_u32(bp, 0); /* RPC flags */
1035− bp = xdr_encode_YFSFid(bp, &dvnode->fid);
1036− bp = xdr_encode_string(bp, name, namesz);
1037− bp = xdr_encode_YFSFid(bp, &vnode->fid);
987+ bp = xdr_encode_YFSFid(bp, &dvp->fid);
988+ bp = xdr_encode_name(bp, name);
989+ bp = xdr_encode_YFSFid(bp, &vp->fid);
1038990 yfs_check_req(call, bp);
1039991
1040− afs_use_fs_server(call, fc->cbi);
1041− trace_afs_make_fs_call1(call, &vnode->fid, name);
1042− afs_set_fc_call(call, fc);
1043− afs_make_call(&fc->ac, call, GFP_NOFS);
1044− return afs_wait_for_call_to_complete(call, &fc->ac);
992+ trace_afs_make_fs_call1(call, &vp->fid, name);
993+ afs_make_op_call(op, call, GFP_NOFS);
1045994 }
1046995
1047996 /*
@@ -1049,6 +998,9 @@ int yfs_fs_link(struct afs_fs_cursor *fc, struct afs_vnode *vnode, · 1 unmodified line
1049998 */
1050999 static int yfs_deliver_fs_symlink(struct afs_call *call)
10511000 {
1001+ struct afs_operation *op = call->op;
1002+ struct afs_vnode_param *dvp = &op->file[0];
1003+ struct afs_vnode_param *vp = &op->file[1];
10521004 const __be32 *bp;
10531005 int ret;
10541006
@@ -1060,14 +1012,10 @@ static int yfs_deliver_fs_symlink(struct afs_call *call) · 5 unmodified lines
10601012
10611013 /* unmarshall the reply once we've received all of it */
10621014 bp = call->buffer;
1063− xdr_decode_YFSFid(&bp, call->out_fid);
1064− ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
1065− if (ret < 0)
1066− return ret;
1067− ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb);
1068− if (ret < 0)
1069− return ret;
1070− xdr_decode_YFSVolSync(&bp, call->out_volsync);
1015+ xdr_decode_YFSFid(&bp, &vp->fid);
1016+ xdr_decode_YFSFetchStatus(&bp, call, &vp->scb);
1017+ xdr_decode_YFSFetchStatus(&bp, call, &dvp->scb);
1018+ xdr_decode_YFSVolSync(&bp, &op->volsync);
10711019
10721020 _leave(" = 0 [done]");
10731021 return 0;
@@ -1086,28 +1034,22 @@ static const struct afs_call_type yfs_RXYFSSymlink = { · 12 unmodified lines
10861034 /*
10871035 * Create a symbolic link.
10881036 */
1089−int yfs_fs_symlink(struct afs_fs_cursor *fc,
1090− const char *name,
1091− const char *contents,
1092− struct afs_status_cb *dvnode_scb,
1093− struct afs_fid *newfid,
1094− struct afs_status_cb *vnode_scb)
1037+void yfs_fs_symlink(struct afs_operation *op)
10951038 {
1096− struct afs_vnode *dvnode = fc->vnode;
1039+ const struct qstr *name = &op->dentry->d_name;
1040+ struct afs_vnode_param *dvp = &op->file[0];
10971041 struct afs_call *call;
1098− struct afs_net *net = afs_v2net(dvnode);
1099− size_t namesz, contents_sz;
1042+ size_t contents_sz;
11001043 __be32 *bp;
11011044
11021045 _enter("");
11031046
1104− namesz = strlen(name);
1105− contents_sz = strlen(contents);
1106− call = afs_alloc_flat_call(net, &yfs_RXYFSSymlink,
1047+ contents_sz = strlen(op->create.symlink);
1048+ call = afs_alloc_flat_call(op->net, &yfs_RXYFSSymlink,
11071049 sizeof(__be32) +
11081050 sizeof(struct yfs_xdr_RPCFlags) +
11091051 sizeof(struct yfs_xdr_YFSFid) +
1110− xdr_strlen(namesz) +
1052+ xdr_strlen(name->len) +
11111053 xdr_strlen(contents_sz) +
11121054 sizeof(struct yfs_xdr_YFSStoreStatus),
11131055 sizeof(struct yfs_xdr_YFSFid) +
@@ -1115,28 +1057,20 @@ int yfs_fs_symlink(struct afs_fs_cursor *fc, · 1 unmodified line
11151057 sizeof(struct yfs_xdr_YFSFetchStatus) +
11161058 sizeof(struct yfs_xdr_YFSVolSync));
11171059 if (!call)
1118− return -ENOMEM;
1119−
1120− call->key = fc->key;
1121− call->out_dir_scb = dvnode_scb;
1122− call->out_fid = newfid;
1123− call->out_scb = vnode_scb;
1060+ return afs_op_nomem(op);
11241061
11251062 /* marshall the parameters */
11261063 bp = call->request;
11271064 bp = xdr_encode_u32(bp, YFSSYMLINK);
11281065 bp = xdr_encode_u32(bp, 0); /* RPC flags */
1129− bp = xdr_encode_YFSFid(bp, &dvnode->fid);
1130− bp = xdr_encode_string(bp, name, namesz);
1131− bp = xdr_encode_string(bp, contents, contents_sz);
1066+ bp = xdr_encode_YFSFid(bp, &dvp->fid);
1067+ bp = xdr_encode_name(bp, name);
1068+ bp = xdr_encode_string(bp, op->create.symlink, contents_sz);
11321069 bp = xdr_encode_YFSStoreStatus_mode(bp, S_IRWXUGO);
11331070 yfs_check_req(call, bp);
11341071
1135− afs_use_fs_server(call, fc->cbi);
1136− trace_afs_make_fs_call1(call, &dvnode->fid, name);
1137− afs_set_fc_call(call, fc);
1138− afs_make_call(&fc->ac, call, GFP_NOFS);
1139− return afs_wait_for_call_to_complete(call, &fc->ac);
1072+ trace_afs_make_fs_call1(call, &dvp->fid, name);
1073+ afs_make_op_call(op, call, GFP_NOFS);
11401074 }
11411075
11421076 /*
@@ -1144,6 +1078,9 @@ int yfs_fs_symlink(struct afs_fs_cursor *fc, · 1 unmodified line
11441078 */
11451079 static int yfs_deliver_fs_rename(struct afs_call *call)
11461080 {
1081+ struct afs_operation *op = call->op;
1082+ struct afs_vnode_param *orig_dvp = &op->file[0];
1083+ struct afs_vnode_param *new_dvp = &op->file[1];
11471084 const __be32 *bp;
11481085 int ret;
11491086
@@ -1154,14 +1091,12 @@ static int yfs_deliver_fs_rename(struct afs_call *call) · 4 unmodified lines
11541091 return ret;
11551092
11561093 bp = call->buffer;
1157− ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb);
1158− if (ret < 0)
1159− return ret;
1160− ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
1161− if (ret < 0)
1162− return ret;
1163−
1164− xdr_decode_YFSVolSync(&bp, call->out_volsync);
1094+ /* If the two dirs are the same, we have two copies of the same status
1095+ * report, so we just decode it twice.
1096+ */
1097+ xdr_decode_YFSFetchStatus(&bp, call, &orig_dvp->scb);
1098+ xdr_decode_YFSFetchStatus(&bp, call, &new_dvp->scb);
1099+ xdr_decode_YFSVolSync(&bp, &op->volsync);
11651100 _leave(" = 0 [done]");
11661101 return 0;
11671102 }
@@ -1179,55 +1114,42 @@ static const struct afs_call_type yfs_RXYFSRename = { · 11 unmodified lines
11791114 /*
11801115 * Rename a file or directory.
11811116 */
1182−int yfs_fs_rename(struct afs_fs_cursor *fc,
1183− const char *orig_name,
1184− struct afs_vnode *new_dvnode,
1185− const char *new_name,
1186− struct afs_status_cb *orig_dvnode_scb,
1187− struct afs_status_cb *new_dvnode_scb)
1117+void yfs_fs_rename(struct afs_operation *op)
11881118 {
1189− struct afs_vnode *orig_dvnode = fc->vnode;
1119+ struct afs_vnode_param *orig_dvp = &op->file[0];
1120+ struct afs_vnode_param *new_dvp = &op->file[1];
1121+ const struct qstr *orig_name = &op->dentry->d_name;
1122+ const struct qstr *new_name = &op->dentry_2->d_name;
11901123 struct afs_call *call;
1191− struct afs_net *net = afs_v2net(orig_dvnode);
1192− size_t o_namesz, n_namesz;
11931124 __be32 *bp;
11941125
11951126 _enter("");
11961127
1197− o_namesz = strlen(orig_name);
1198− n_namesz = strlen(new_name);
1199− call = afs_alloc_flat_call(net, &yfs_RXYFSRename,
1128+ call = afs_alloc_flat_call(op->net, &yfs_RXYFSRename,
12001129 sizeof(__be32) +
12011130 sizeof(struct yfs_xdr_RPCFlags) +
12021131 sizeof(struct yfs_xdr_YFSFid) +
1203− xdr_strlen(o_namesz) +
1132+ xdr_strlen(orig_name->len) +
12041133 sizeof(struct yfs_xdr_YFSFid) +
1205− xdr_strlen(n_namesz),
1134+ xdr_strlen(new_name->len),
12061135 sizeof(struct yfs_xdr_YFSFetchStatus) +
12071136 sizeof(struct yfs_xdr_YFSFetchStatus) +
12081137 sizeof(struct yfs_xdr_YFSVolSync));
12091138 if (!call)
1210− return -ENOMEM;
1211−
1212− call->key = fc->key;
1213− call->out_dir_scb = orig_dvnode_scb;
1214− call->out_scb = new_dvnode_scb;
1139+ return afs_op_nomem(op);
12151140
12161141 /* marshall the parameters */
12171142 bp = call->request;
12181143 bp = xdr_encode_u32(bp, YFSRENAME);
12191144 bp = xdr_encode_u32(bp, 0); /* RPC flags */
1220− bp = xdr_encode_YFSFid(bp, &orig_dvnode->fid);
1221− bp = xdr_encode_string(bp, orig_name, o_namesz);
1222− bp = xdr_encode_YFSFid(bp, &new_dvnode->fid);
1223− bp = xdr_encode_string(bp, new_name, n_namesz);
1145+ bp = xdr_encode_YFSFid(bp, &orig_dvp->fid);
1146+ bp = xdr_encode_name(bp, orig_name);
1147+ bp = xdr_encode_YFSFid(bp, &new_dvp->fid);
1148+ bp = xdr_encode_name(bp, new_name);
12241149 yfs_check_req(call, bp);
12251150
1226− afs_use_fs_server(call, fc->cbi);
1227− trace_afs_make_fs_call2(call, &orig_dvnode->fid, orig_name, new_name);
1228− afs_set_fc_call(call, fc);
1229− afs_make_call(&fc->ac, call, GFP_NOFS);
1230− return afs_wait_for_call_to_complete(call, &fc->ac);
1151+ trace_afs_make_fs_call2(call, &orig_dvp->fid, orig_name, new_name);
1152+ afs_make_op_call(op, call, GFP_NOFS);
12311153 }
12321154
12331155 /*
@@ -1243,27 +1165,23 @@ static const struct afs_call_type yfs_RXYFSStoreData64 = { · 9 unmodified lines
12431165 /*
12441166 * Store a set of pages to a large file.
12451167 */
1246−int yfs_fs_store_data(struct afs_fs_cursor *fc, struct address_space *mapping,
1247− pgoff_t first, pgoff_t last,
1248− unsigned offset, unsigned to,
1249− struct afs_status_cb *scb)
1168+void yfs_fs_store_data(struct afs_operation *op)
12501169 {
1251− struct afs_vnode *vnode = fc->vnode;
1170+ struct afs_vnode_param *vp = &op->file[0];
12521171 struct afs_call *call;
1253− struct afs_net *net = afs_v2net(vnode);
12541172 loff_t size, pos, i_size;
12551173 __be32 *bp;
12561174
12571175 _enter(",%x,{%llx:%llu},,",
1258− key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
1176+ key_serial(op->key), vp->fid.vid, vp->fid.vnode);
12591177
1260− size = (loff_t)to - (loff_t)offset;
1261− if (first != last)
1262− size += (loff_t)(last - first) << PAGE_SHIFT;
1263− pos = (loff_t)first << PAGE_SHIFT;
1264− pos += offset;
1178+ size = (loff_t)op->store.last_to - (loff_t)op->store.first_offset;
1179+ if (op->store.first != op->store.last)
1180+ size += (loff_t)(op->store.last - op->store.first) << PAGE_SHIFT;
1181+ pos = (loff_t)op->store.first << PAGE_SHIFT;
1182+ pos += op->store.first_offset;
12651183
1266− i_size = i_size_read(&vnode->vfs_inode);
1184+ i_size = i_size_read(&vp->vnode->vfs_inode);
12671185 if (pos + size > i_size)
12681186 i_size = size + pos;
12691187
@@ -1271,7 +1189,7 @@ int yfs_fs_store_data(struct afs_fs_cursor *fc, struct address_space *mapping, · 1 unmodified line
12711189 (unsigned long long)size, (unsigned long long)pos,
12721190 (unsigned long long)i_size);
12731191
1274− call = afs_alloc_flat_call(net, &yfs_RXYFSStoreData64,
1192+ call = afs_alloc_flat_call(op->net, &yfs_RXYFSStoreData64,
12751193 sizeof(__be32) +
12761194 sizeof(__be32) +
12771195 sizeof(struct yfs_xdr_YFSFid) +
@@ -1280,33 +1198,24 @@ int yfs_fs_store_data(struct afs_fs_cursor *fc, struct address_space *mapping, · 2 unmodified lines
12801198 sizeof(struct yfs_xdr_YFSFetchStatus) +
12811199 sizeof(struct yfs_xdr_YFSVolSync));
12821200 if (!call)
1283− return -ENOMEM;
1284−
1285− call->key = fc->key;
1286− call->mapping = mapping;
1287− call->first = first;
1288− call->last = last;
1289− call->first_offset = offset;
1290− call->last_to = to;
1201+ return afs_op_nomem(op);
1202+
1203+ call->key = op->key;
12911204 call->send_pages = true;
1292− call->out_scb = scb;
12931205
12941206 /* marshall the parameters */
12951207 bp = call->request;
12961208 bp = xdr_encode_u32(bp, YFSSTOREDATA64);
12971209 bp = xdr_encode_u32(bp, 0); /* RPC flags */
1298− bp = xdr_encode_YFSFid(bp, &vnode->fid);
1299− bp = xdr_encode_YFSStoreStatus_mtime(bp, &vnode->vfs_inode.i_mtime);
1210+ bp = xdr_encode_YFSFid(bp, &vp->fid);
1211+ bp = xdr_encode_YFSStoreStatus_mtime(bp, &op->mtime);
13001212 bp = xdr_encode_u64(bp, pos);
13011213 bp = xdr_encode_u64(bp, size);
13021214 bp = xdr_encode_u64(bp, i_size);
13031215 yfs_check_req(call, bp);
13041216
1305− afs_use_fs_server(call, fc->cbi);
1306− trace_afs_make_fs_call(call, &vnode->fid);
1307− afs_set_fc_call(call, fc);
1308− afs_make_call(&fc->ac, call, GFP_NOFS);
1309− return afs_wait_for_call_to_complete(call, &fc->ac);
1217+ trace_afs_make_fs_call(call, &vp->fid);
1218+ afs_make_op_call(op, call, GFP_NOFS);
13101219 }
13111220
13121221 /*
@@ -1330,18 +1239,17 @@ static const struct afs_call_type yfs_RXYFSStoreData64_as_Status = { · 17 unmodified lines
13301239 * Set the attributes on a file, using YFS.StoreData64 rather than
13311240 * YFS.StoreStatus so as to alter the file size also.
13321241 */
1333−static int yfs_fs_setattr_size(struct afs_fs_cursor *fc, struct iattr *attr,
1334− struct afs_status_cb *scb)
1242+static void yfs_fs_setattr_size(struct afs_operation *op)
13351243 {
1336− struct afs_vnode *vnode = fc->vnode;
1244+ struct afs_vnode_param *vp = &op->file[0];
13371245 struct afs_call *call;
1338− struct afs_net *net = afs_v2net(vnode);
1246+ struct iattr *attr = op->setattr.attr;
13391247 __be32 *bp;
13401248
13411249 _enter(",%x,{%llx:%llu},,",
1342− key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
1250+ key_serial(op->key), vp->fid.vid, vp->fid.vnode);
13431251
1344− call = afs_alloc_flat_call(net, &yfs_RXYFSStoreData64_as_Status,
1252+ call = afs_alloc_flat_call(op->net, &yfs_RXYFSStoreData64_as_Status,
13451253 sizeof(__be32) * 2 +
13461254 sizeof(struct yfs_xdr_YFSFid) +
13471255 sizeof(struct yfs_xdr_YFSStoreStatus) +
@@ -1349,72 +1257,59 @@ static int yfs_fs_setattr_size(struct afs_fs_cursor *fc, struct iattr *attr, · 1 unmodified line
13491257 sizeof(struct yfs_xdr_YFSFetchStatus) +
13501258 sizeof(struct yfs_xdr_YFSVolSync));
13511259 if (!call)
1352− return -ENOMEM;
1353−
1354− call->key = fc->key;
1355− call->out_scb = scb;
1260+ return afs_op_nomem(op);
13561261
13571262 /* marshall the parameters */
13581263 bp = call->request;
13591264 bp = xdr_encode_u32(bp, YFSSTOREDATA64);
13601265 bp = xdr_encode_u32(bp, 0); /* RPC flags */
1361− bp = xdr_encode_YFSFid(bp, &vnode->fid);
1266+ bp = xdr_encode_YFSFid(bp, &vp->fid);
13621267 bp = xdr_encode_YFS_StoreStatus(bp, attr);
13631268 bp = xdr_encode_u64(bp, attr->ia_size); /* position of start of write */
13641269 bp = xdr_encode_u64(bp, 0); /* size of write */
13651270 bp = xdr_encode_u64(bp, attr->ia_size); /* new file length */
13661271 yfs_check_req(call, bp);
13671272
1368− afs_use_fs_server(call, fc->cbi);
1369− trace_afs_make_fs_call(call, &vnode->fid);
1370− afs_set_fc_call(call, fc);
1371− afs_make_call(&fc->ac, call, GFP_NOFS);
1372− return afs_wait_for_call_to_complete(call, &fc->ac);
1273+ trace_afs_make_fs_call(call, &vp->fid);
1274+ afs_make_op_call(op, call, GFP_NOFS);
13731275 }
13741276
13751277 /*
13761278 * Set the attributes on a file, using YFS.StoreData64 if there's a change in
13771279 * file size, and YFS.StoreStatus otherwise.
13781280 */
1379−int yfs_fs_setattr(struct afs_fs_cursor *fc, struct iattr *attr,
1380− struct afs_status_cb *scb)
1281+void yfs_fs_setattr(struct afs_operation *op)
13811282 {
1382− struct afs_vnode *vnode = fc->vnode;
1283+ struct afs_vnode_param *vp = &op->file[0];
13831284 struct afs_call *call;
1384− struct afs_net *net = afs_v2net(vnode);
1285+ struct iattr *attr = op->setattr.attr;
13851286 __be32 *bp;
13861287
13871288 if (attr->ia_valid & ATTR_SIZE)
1388− return yfs_fs_setattr_size(fc, attr, scb);
1289+ return yfs_fs_setattr_size(op);
13891290
13901291 _enter(",%x,{%llx:%llu},,",
1391− key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
1292+ key_serial(op->key), vp->fid.vid, vp->fid.vnode);
13921293
1393− call = afs_alloc_flat_call(net, &yfs_RXYFSStoreStatus,
1294+ call = afs_alloc_flat_call(op->net, &yfs_RXYFSStoreStatus,
13941295 sizeof(__be32) * 2 +
13951296 sizeof(struct yfs_xdr_YFSFid) +
13961297 sizeof(struct yfs_xdr_YFSStoreStatus),
13971298 sizeof(struct yfs_xdr_YFSFetchStatus) +
13981299 sizeof(struct yfs_xdr_YFSVolSync));
13991300 if (!call)
1400− return -ENOMEM;
1401−
1402− call->key = fc->key;
1403− call->out_scb = scb;
1301+ return afs_op_nomem(op);
14041302
14051303 /* marshall the parameters */
14061304 bp = call->request;
14071305 bp = xdr_encode_u32(bp, YFSSTORESTATUS);
14081306 bp = xdr_encode_u32(bp, 0); /* RPC flags */
1409− bp = xdr_encode_YFSFid(bp, &vnode->fid);
1307+ bp = xdr_encode_YFSFid(bp, &vp->fid);
14101308 bp = xdr_encode_YFS_StoreStatus(bp, attr);
14111309 yfs_check_req(call, bp);
14121310
1413− afs_use_fs_server(call, fc->cbi);
1414− trace_afs_make_fs_call(call, &vnode->fid);
1415− afs_set_fc_call(call, fc);
1416− afs_make_call(&fc->ac, call, GFP_NOFS);
1417− return afs_wait_for_call_to_complete(call, &fc->ac);
1311+ trace_afs_make_fs_call(call, &vp->fid);
1312+ afs_make_op_call(op, call, GFP_NOFS);
14181313 }
14191314
14201315 /*
@@ -1422,6 +1317,7 @@ int yfs_fs_setattr(struct afs_fs_cursor *fc, struct iattr *attr, · 1 unmodified line
14221317 */
14231318 static int yfs_deliver_fs_get_volume_status(struct afs_call *call)
14241319 {
1320+ struct afs_operation *op = call->op;
14251321 const __be32 *bp;
14261322 char *p;
14271323 u32 size;
@@ -1443,7 +1339,7 @@ static int yfs_deliver_fs_get_volume_status(struct afs_call *call) · 15 unmodified lines
14431339 return ret;
14441340
14451341 bp = call->buffer;
1446− xdr_decode_YFSFetchVolumeStatus(&bp, call->out_volstatus);
1342+ xdr_decode_YFSFetchVolumeStatus(&bp, &op->volstatus.vs);
14471343 call->unmarshall++;
14481344 afs_extract_to_tmp(call);
14491345 /* Fall through */
@@ -1457,8 +1353,7 @@ static int yfs_deliver_fs_get_volume_status(struct afs_call *call) · 7 unmodified lines
14571353 call->count = ntohl(call->tmp);
14581354 _debug("volname length: %u", call->count);
14591355 if (call->count >= AFSNAMEMAX)
1460− return afs_protocol_error(call, -EBADMSG,
1461− afs_eproto_volname_len);
1356+ return afs_protocol_error(call, afs_eproto_volname_len);
14621357 size = (call->count + 3) & ~3; /* It's padded */
14631358 afs_extract_to_buf(call, size);
14641359 call->unmarshall++;
@@ -1487,8 +1382,7 @@ static int yfs_deliver_fs_get_volume_status(struct afs_call *call) · 22 unmodified lines
14871382 call->count = ntohl(call->tmp);
14881383 _debug("offline msg length: %u", call->count);
14891384 if (call->count >= AFSNAMEMAX)
1490− return afs_protocol_error(call, -EBADMSG,
1491− afs_eproto_offline_msg_len);
1385+ return afs_protocol_error(call, afs_eproto_offline_msg_len);
14921386 size = (call->count + 3) & ~3; /* It's padded */
14931387 afs_extract_to_buf(call, size);
14941388 call->unmarshall++;
@@ -1518,8 +1412,7 @@ static int yfs_deliver_fs_get_volume_status(struct afs_call *call) · 23 unmodified lines
15181412 call->count = ntohl(call->tmp);
15191413 _debug("motd length: %u", call->count);
15201414 if (call->count >= AFSNAMEMAX)
1521− return afs_protocol_error(call, -EBADMSG,
1522− afs_eproto_motd_len);
1415+ return afs_protocol_error(call, afs_eproto_motd_len);
15231416 size = (call->count + 3) & ~3; /* It's padded */
15241417 afs_extract_to_buf(call, size);
15251418 call->unmarshall++;
@@ -1560,17 +1453,15 @@ static const struct afs_call_type yfs_RXYFSGetVolumeStatus = { · 34 unmodified lines
15601453 /*
15611454 * fetch the status of a volume
15621455 */
1563−int yfs_fs_get_volume_status(struct afs_fs_cursor *fc,
1564− struct afs_volume_status *vs)
1456+void yfs_fs_get_volume_status(struct afs_operation *op)
15651457 {
1566− struct afs_vnode *vnode = fc->vnode;
1458+ struct afs_vnode_param *vp = &op->file[0];
15671459 struct afs_call *call;
1568− struct afs_net *net = afs_v2net(vnode);
15691460 __be32 *bp;
15701461
15711462 _enter("");
15721463
1573− call = afs_alloc_flat_call(net, &yfs_RXYFSGetVolumeStatus,
1464+ call = afs_alloc_flat_call(op->net, &yfs_RXYFSGetVolumeStatus,
15741465 sizeof(__be32) * 2 +
15751466 sizeof(struct yfs_xdr_u64),
15761467 max_t(size_t,
@@ -1578,23 +1469,17 @@ int yfs_fs_get_volume_status(struct afs_fs_cursor *fc, · 1 unmodified line
15781469 sizeof(__be32),
15791470 AFSOPAQUEMAX + 1));
15801471 if (!call)
1581− return -ENOMEM;
1582−
1583− call->key = fc->key;
1584− call->out_volstatus = vs;
1472+ return afs_op_nomem(op);
15851473
15861474 /* marshall the parameters */
15871475 bp = call->request;
15881476 bp = xdr_encode_u32(bp, YFSGETVOLUMESTATUS);
15891477 bp = xdr_encode_u32(bp, 0); /* RPC flags */
1590− bp = xdr_encode_u64(bp, vnode->fid.vid);
1478+ bp = xdr_encode_u64(bp, vp->fid.vid);
15911479 yfs_check_req(call, bp);
15921480
1593− afs_use_fs_server(call, fc->cbi);
1594− trace_afs_make_fs_call(call, &vnode->fid);
1595− afs_set_fc_call(call, fc);
1596− afs_make_call(&fc->ac, call, GFP_NOFS);
1597− return afs_wait_for_call_to_complete(call, &fc->ac);
1481+ trace_afs_make_fs_call(call, &vp->fid);
1482+ afs_make_op_call(op, call, GFP_NOFS);
15981483 }
15991484
16001485 /*
@@ -1632,118 +1517,93 @@ static const struct afs_call_type yfs_RXYFSReleaseLock = { · 31 unmodified lines
16321517 /*
16331518 * Set a lock on a file
16341519 */
1635−int yfs_fs_set_lock(struct afs_fs_cursor *fc, afs_lock_type_t type,
1636− struct afs_status_cb *scb)
1520+void yfs_fs_set_lock(struct afs_operation *op)
16371521 {
1638− struct afs_vnode *vnode = fc->vnode;
1522+ struct afs_vnode_param *vp = &op->file[0];
16391523 struct afs_call *call;
1640− struct afs_net *net = afs_v2net(vnode);
16411524 __be32 *bp;
16421525
16431526 _enter("");
16441527
1645− call = afs_alloc_flat_call(net, &yfs_RXYFSSetLock,
1528+ call = afs_alloc_flat_call(op->net, &yfs_RXYFSSetLock,
16461529 sizeof(__be32) * 2 +
16471530 sizeof(struct yfs_xdr_YFSFid) +
16481531 sizeof(__be32),
16491532 sizeof(struct yfs_xdr_YFSFetchStatus) +
16501533 sizeof(struct yfs_xdr_YFSVolSync));
16511534 if (!call)
1652− return -ENOMEM;
1653−
1654− call->key = fc->key;
1655− call->lvnode = vnode;
1656− call->out_scb = scb;
1535+ return afs_op_nomem(op);
16571536
16581537 /* marshall the parameters */
16591538 bp = call->request;
16601539 bp = xdr_encode_u32(bp, YFSSETLOCK);
16611540 bp = xdr_encode_u32(bp, 0); /* RPC flags */
1662− bp = xdr_encode_YFSFid(bp, &vnode->fid);
1663− bp = xdr_encode_u32(bp, type);
1541+ bp = xdr_encode_YFSFid(bp, &vp->fid);
1542+ bp = xdr_encode_u32(bp, op->lock.type);
16641543 yfs_check_req(call, bp);
16651544
1666− afs_use_fs_server(call, fc->cbi);
1667− trace_afs_make_fs_calli(call, &vnode->fid, type);
1668− afs_set_fc_call(call, fc);
1669− afs_make_call(&fc->ac, call, GFP_NOFS);
1670− return afs_wait_for_call_to_complete(call, &fc->ac);
1545+ trace_afs_make_fs_calli(call, &vp->fid, op->lock.type);
1546+ afs_make_op_call(op, call, GFP_NOFS);
16711547 }
16721548
16731549 /*
16741550 * extend a lock on a file
16751551 */
1676−int yfs_fs_extend_lock(struct afs_fs_cursor *fc, struct afs_status_cb *scb)
1552+void yfs_fs_extend_lock(struct afs_operation *op)
16771553 {
1678− struct afs_vnode *vnode = fc->vnode;
1554+ struct afs_vnode_param *vp = &op->file[0];
16791555 struct afs_call *call;
1680− struct afs_net *net = afs_v2net(vnode);
16811556 __be32 *bp;
16821557
16831558 _enter("");
16841559
1685− call = afs_alloc_flat_call(net, &yfs_RXYFSExtendLock,
1560+ call = afs_alloc_flat_call(op->net, &yfs_RXYFSExtendLock,
16861561 sizeof(__be32) * 2 +
16871562 sizeof(struct yfs_xdr_YFSFid),
16881563 sizeof(struct yfs_xdr_YFSFetchStatus) +
16891564 sizeof(struct yfs_xdr_YFSVolSync));
16901565 if (!call)
1691− return -ENOMEM;
1692−
1693− call->key = fc->key;
1694− call->lvnode = vnode;
1695− call->out_scb = scb;
1566+ return afs_op_nomem(op);
16961567
16971568 /* marshall the parameters */
16981569 bp = call->request;
16991570 bp = xdr_encode_u32(bp, YFSEXTENDLOCK);
17001571 bp = xdr_encode_u32(bp, 0); /* RPC flags */
1701− bp = xdr_encode_YFSFid(bp, &vnode->fid);
1572+ bp = xdr_encode_YFSFid(bp, &vp->fid);
17021573 yfs_check_req(call, bp);
17031574
1704− afs_use_fs_server(call, fc->cbi);
1705− trace_afs_make_fs_call(call, &vnode->fid);
1706− afs_set_fc_call(call, fc);
1707− afs_make_call(&fc->ac, call, GFP_NOFS);
1708− return afs_wait_for_call_to_complete(call, &fc->ac);
1575+ trace_afs_make_fs_call(call, &vp->fid);
1576+ afs_make_op_call(op, call, GFP_NOFS);
17091577 }
17101578
17111579 /*
17121580 * release a lock on a file
17131581 */
1714−int yfs_fs_release_lock(struct afs_fs_cursor *fc, struct afs_status_cb *scb)
1582+void yfs_fs_release_lock(struct afs_operation *op)
17151583 {
1716− struct afs_vnode *vnode = fc->vnode;
1584+ struct afs_vnode_param *vp = &op->file[0];
17171585 struct afs_call *call;
1718− struct afs_net *net = afs_v2net(vnode);
17191586 __be32 *bp;
17201587
17211588 _enter("");
17221589
1723− call = afs_alloc_flat_call(net, &yfs_RXYFSReleaseLock,
1590+ call = afs_alloc_flat_call(op->net, &yfs_RXYFSReleaseLock,
17241591 sizeof(__be32) * 2 +
17251592 sizeof(struct yfs_xdr_YFSFid),
17261593 sizeof(struct yfs_xdr_YFSFetchStatus) +
17271594 sizeof(struct yfs_xdr_YFSVolSync));
17281595 if (!call)
1729− return -ENOMEM;
1730−
1731− call->key = fc->key;
1732− call->lvnode = vnode;
1733− call->out_scb = scb;
1596+ return afs_op_nomem(op);
17341597
17351598 /* marshall the parameters */
17361599 bp = call->request;
17371600 bp = xdr_encode_u32(bp, YFSRELEASELOCK);
17381601 bp = xdr_encode_u32(bp, 0); /* RPC flags */
1739− bp = xdr_encode_YFSFid(bp, &vnode->fid);
1602+ bp = xdr_encode_YFSFid(bp, &vp->fid);
17401603 yfs_check_req(call, bp);
17411604
1742− afs_use_fs_server(call, fc->cbi);
1743− trace_afs_make_fs_call(call, &vnode->fid);
1744− afs_set_fc_call(call, fc);
1745− afs_make_call(&fc->ac, call, GFP_NOFS);
1746− return afs_wait_for_call_to_complete(call, &fc->ac);
1605+ trace_afs_make_fs_call(call, &vp->fid);
1606+ afs_make_op_call(op, call, GFP_NOFS);
17471607 }
17481608
17491609 /*
@@ -1759,45 +1619,33 @@ static const struct afs_call_type yfs_RXYFSFetchStatus = { · 9 unmodified lines
17591619 /*
17601620 * Fetch the status information for a fid without needing a vnode handle.
17611621 */
1762−int yfs_fs_fetch_status(struct afs_fs_cursor *fc,
1763− struct afs_net *net,
1764− struct afs_fid *fid,
1765− struct afs_status_cb *scb,
1766− struct afs_volsync *volsync)
1622+void yfs_fs_fetch_status(struct afs_operation *op)
17671623 {
1624+ struct afs_vnode_param *vp = &op->file[0];
17681625 struct afs_call *call;
17691626 __be32 *bp;
17701627
17711628 _enter(",%x,{%llx:%llu},,",
1772− key_serial(fc->key), fid->vid, fid->vnode);
1629+ key_serial(op->key), vp->fid.vid, vp->fid.vnode);
17731630
1774− call = afs_alloc_flat_call(net, &yfs_RXYFSFetchStatus,
1631+ call = afs_alloc_flat_call(op->net, &yfs_RXYFSFetchStatus,
17751632 sizeof(__be32) * 2 +
17761633 sizeof(struct yfs_xdr_YFSFid),
17771634 sizeof(struct yfs_xdr_YFSFetchStatus) +
17781635 sizeof(struct yfs_xdr_YFSCallBack) +
17791636 sizeof(struct yfs_xdr_YFSVolSync));
1780− if (!call) {
1781− fc->ac.error = -ENOMEM;
1782− return -ENOMEM;
1783− }
1784−
1785− call->key = fc->key;
1786− call->out_scb = scb;
1787− call->out_volsync = volsync;
1637+ if (!call)
1638+ return afs_op_nomem(op);
17881639
17891640 /* marshall the parameters */
17901641 bp = call->request;
17911642 bp = xdr_encode_u32(bp, YFSFETCHSTATUS);
17921643 bp = xdr_encode_u32(bp, 0); /* RPC flags */
1793− bp = xdr_encode_YFSFid(bp, fid);
1644+ bp = xdr_encode_YFSFid(bp, &vp->fid);
17941645 yfs_check_req(call, bp);
17951646
1796− afs_use_fs_server(call, fc->cbi);
1797− trace_afs_make_fs_call(call, fid);
1798− afs_set_fc_call(call, fc);
1799− afs_make_call(&fc->ac, call, GFP_NOFS);
1800− return afs_wait_for_call_to_complete(call, &fc->ac);
1647+ trace_afs_make_fs_call(call, &vp->fid);
1648+ afs_make_op_call(op, call, GFP_NOFS);
18011649 }
18021650
18031651 /*
@@ -1805,6 +1653,7 @@ int yfs_fs_fetch_status(struct afs_fs_cursor *fc, · 1 unmodified line
18051653 */
18061654 static int yfs_deliver_fs_inline_bulk_status(struct afs_call *call)
18071655 {
1656+ struct afs_operation *op = call->op;
18081657 struct afs_status_cb *scb;
18091658 const __be32 *bp;
18101659 u32 tmp;
@@ -1826,10 +1675,9 @@ static int yfs_deliver_fs_inline_bulk_status(struct afs_call *call) · 15 unmodified lines
18261675 return ret;
18271676
18281677 tmp = ntohl(call->tmp);
1829− _debug("status count: %u/%u", tmp, call->count2);
1830− if (tmp != call->count2)
1831− return afs_protocol_error(call, -EBADMSG,
1832− afs_eproto_ibulkst_count);
1678+ _debug("status count: %u/%u", tmp, op->nr_files);
1679+ if (tmp != op->nr_files)
1680+ return afs_protocol_error(call, afs_eproto_ibulkst_count);
18331681
18341682 call->count = 0;
18351683 call->unmarshall++;
@@ -1843,14 +1691,23 @@ static int yfs_deliver_fs_inline_bulk_status(struct afs_call *call) · 7 unmodified lines
18431691 if (ret < 0)
18441692 return ret;
18451693
1694+ switch (call->count) {
1695+ case 0:
1696+ scb = &op->file[0].scb;
1697+ break;
1698+ case 1:
1699+ scb = &op->file[1].scb;
1700+ break;
1701+ default:
1702+ scb = &op->more_files[call->count - 2].scb;
1703+ break;
1704+ }
1705+
18461706 bp = call->buffer;
1847− scb = &call->out_scb[call->count];
1848− ret = xdr_decode_YFSFetchStatus(&bp, call, scb);
1849− if (ret < 0)
1850− return ret;
1707+ xdr_decode_YFSFetchStatus(&bp, call, scb);
18511708
18521709 call->count++;
1853− if (call->count < call->count2)
1710+ if (call->count < op->nr_files)
18541711 goto more_counts;
18551712
18561713 call->count = 0;
@@ -1867,9 +1724,8 @@ static int yfs_deliver_fs_inline_bulk_status(struct afs_call *call) · 10 unmodified lines
18671724
18681725 tmp = ntohl(call->tmp);
18691726 _debug("CB count: %u", tmp);
1870− if (tmp != call->count2)
1871− return afs_protocol_error(call, -EBADMSG,
1872− afs_eproto_ibulkst_cb_count);
1727+ if (tmp != op->nr_files)
1728+ return afs_protocol_error(call, afs_eproto_ibulkst_cb_count);
18731729 call->count = 0;
18741730 call->unmarshall++;
18751731 more_cbs:
@@ -1883,11 +1739,22 @@ static int yfs_deliver_fs_inline_bulk_status(struct afs_call *call) · 7 unmodified lines
18831739 return ret;
18841740
18851741 _debug("unmarshall CB array");
1742+ switch (call->count) {
1743+ case 0:
1744+ scb = &op->file[0].scb;
1745+ break;
1746+ case 1:
1747+ scb = &op->file[1].scb;
1748+ break;
1749+ default:
1750+ scb = &op->more_files[call->count - 2].scb;
1751+ break;
1752+ }
1753+
18861754 bp = call->buffer;
1887− scb = &call->out_scb[call->count];
18881755 xdr_decode_YFSCallBack(&bp, call, scb);
18891756 call->count++;
1890− if (call->count < call->count2)
1757+ if (call->count < op->nr_files)
18911758 goto more_cbs;
18921759
18931760 afs_extract_to_buf(call, sizeof(struct yfs_xdr_YFSVolSync));
@@ -1900,7 +1767,7 @@ static int yfs_deliver_fs_inline_bulk_status(struct afs_call *call) · 6 unmodified lines
19001767 return ret;
19011768
19021769 bp = call->buffer;
1903− xdr_decode_YFSVolSync(&bp, call->out_volsync);
1770+ xdr_decode_YFSVolSync(&bp, &op->volsync);
19041771
19051772 call->unmarshall++;
19061773 /* Fall through */
@@ -1926,50 +1793,39 @@ static const struct afs_call_type yfs_RXYFSInlineBulkStatus = { · 19 unmodified lines
19261793 /*
19271794 * Fetch the status information for up to 1024 files
19281795 */
1929−int yfs_fs_inline_bulk_status(struct afs_fs_cursor *fc,
1930− struct afs_net *net,
1931− struct afs_fid *fids,
1932− struct afs_status_cb *statuses,
1933− unsigned int nr_fids,
1934− struct afs_volsync *volsync)
1796+void yfs_fs_inline_bulk_status(struct afs_operation *op)
19351797 {
1798+ struct afs_vnode_param *dvp = &op->file[0];
1799+ struct afs_vnode_param *vp = &op->file[1];
19361800 struct afs_call *call;
19371801 __be32 *bp;
19381802 int i;
19391803
19401804 _enter(",%x,{%llx:%llu},%u",
1941− key_serial(fc->key), fids[0].vid, fids[1].vnode, nr_fids);
1805+ key_serial(op->key), vp->fid.vid, vp->fid.vnode, op->nr_files);
19421806
1943− call = afs_alloc_flat_call(net, &yfs_RXYFSInlineBulkStatus,
1807+ call = afs_alloc_flat_call(op->net, &yfs_RXYFSInlineBulkStatus,
19441808 sizeof(__be32) +
19451809 sizeof(__be32) +
19461810 sizeof(__be32) +
1947− sizeof(struct yfs_xdr_YFSFid) * nr_fids,
1811+ sizeof(struct yfs_xdr_YFSFid) * op->nr_files,
19481812 sizeof(struct yfs_xdr_YFSFetchStatus));
1949− if (!call) {
1950− fc->ac.error = -ENOMEM;
1951− return -ENOMEM;
1952− }
1953−
1954− call->key = fc->key;
1955− call->out_scb = statuses;
1956− call->out_volsync = volsync;
1957− call->count2 = nr_fids;
1813+ if (!call)
1814+ return afs_op_nomem(op);
19581815
19591816 /* marshall the parameters */
19601817 bp = call->request;
19611818 bp = xdr_encode_u32(bp, YFSINLINEBULKSTATUS);
19621819 bp = xdr_encode_u32(bp, 0); /* RPCFlags */
1963− bp = xdr_encode_u32(bp, nr_fids);
1964− for (i = 0; i < nr_fids; i++)
1965− bp = xdr_encode_YFSFid(bp, &fids[i]);
1820+ bp = xdr_encode_u32(bp, op->nr_files);
1821+ bp = xdr_encode_YFSFid(bp, &dvp->fid);
1822+ bp = xdr_encode_YFSFid(bp, &vp->fid);
1823+ for (i = 0; i < op->nr_files - 2; i++)
1824+ bp = xdr_encode_YFSFid(bp, &op->more_files[i].fid);
19661825 yfs_check_req(call, bp);
19671826
1968− afs_use_fs_server(call, fc->cbi);
1969− trace_afs_make_fs_call(call, &fids[0]);
1970− afs_set_fc_call(call, fc);
1971− afs_make_call(&fc->ac, call, GFP_NOFS);
1972− return afs_wait_for_call_to_complete(call, &fc->ac);
1827+ trace_afs_make_fs_call(call, &vp->fid);
1828+ afs_make_op_call(op, call, GFP_NOFS);
19731829 }
19741830
19751831 /*
@@ -1977,7 +1833,9 @@ int yfs_fs_inline_bulk_status(struct afs_fs_cursor *fc, · 1 unmodified line
19771833 */
19781834 static int yfs_deliver_fs_fetch_opaque_acl(struct afs_call *call)
19791835 {
1980− struct yfs_acl *yacl = call->out_yacl;
1836+ struct afs_operation *op = call->op;
1837+ struct afs_vnode_param *vp = &op->file[0];
1838+ struct yfs_acl *yacl = op->yacl;
19811839 struct afs_acl *acl;
19821840 const __be32 *bp;
19831841 unsigned int size;
@@ -2067,10 +1925,8 @@ static int yfs_deliver_fs_fetch_opaque_acl(struct afs_call *call) · 83 unmodified lines
20671925 bp = call->buffer;
20681926 yacl->inherit_flag = ntohl(*bp++);
20691927 yacl->num_cleaned = ntohl(*bp++);
2070− ret = xdr_decode_YFSFetchStatus(&bp, call, call->out_scb);
2071− if (ret < 0)
2072− return ret;
2073− xdr_decode_YFSVolSync(&bp, call->out_volsync);
1928+ xdr_decode_YFSFetchStatus(&bp, call, &vp->scb);
1929+ xdr_decode_YFSVolSync(&bp, &op->volsync);
20741930
20751931 call->unmarshall++;
20761932 /* Fall through */
@@ -2105,45 +1961,33 @@ static const struct afs_call_type yfs_RXYFSFetchOpaqueACL = { · 28 unmodified lines
21051961 /*
21061962 * Fetch the YFS advanced ACLs for a file.
21071963 */
2108−struct yfs_acl *yfs_fs_fetch_opaque_acl(struct afs_fs_cursor *fc,
2109− struct yfs_acl *yacl,
2110− struct afs_status_cb *scb)
1964+void yfs_fs_fetch_opaque_acl(struct afs_operation *op)
21111965 {
2112− struct afs_vnode *vnode = fc->vnode;
1966+ struct afs_vnode_param *vp = &op->file[0];
21131967 struct afs_call *call;
2114− struct afs_net *net = afs_v2net(vnode);
21151968 __be32 *bp;
21161969
21171970 _enter(",%x,{%llx:%llu},,",
2118− key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
1971+ key_serial(op->key), vp->fid.vid, vp->fid.vnode);
21191972
2120− call = afs_alloc_flat_call(net, &yfs_RXYFSFetchOpaqueACL,
1973+ call = afs_alloc_flat_call(op->net, &yfs_RXYFSFetchOpaqueACL,
21211974 sizeof(__be32) * 2 +
21221975 sizeof(struct yfs_xdr_YFSFid),
21231976 sizeof(__be32) * 2 +
21241977 sizeof(struct yfs_xdr_YFSFetchStatus) +
21251978 sizeof(struct yfs_xdr_YFSVolSync));
2126− if (!call) {
2127− fc->ac.error = -ENOMEM;
2128− return ERR_PTR(-ENOMEM);
2129− }
2130−
2131− call->key = fc->key;
2132− call->out_yacl = yacl;
2133− call->out_scb = scb;
2134− call->out_volsync = NULL;
1979+ if (!call)
1980+ return afs_op_nomem(op);
21351981
21361982 /* marshall the parameters */
21371983 bp = call->request;
21381984 bp = xdr_encode_u32(bp, YFSFETCHOPAQUEACL);
21391985 bp = xdr_encode_u32(bp, 0); /* RPC flags */
2140− bp = xdr_encode_YFSFid(bp, &vnode->fid);
1986+ bp = xdr_encode_YFSFid(bp, &vp->fid);
21411987 yfs_check_req(call, bp);
21421988
2143− afs_use_fs_server(call, fc->cbi);
2144− trace_afs_make_fs_call(call, &vnode->fid);
2145− afs_make_call(&fc->ac, call, GFP_KERNEL);
2146− return (struct yfs_acl *)afs_wait_for_call_to_complete(call, &fc->ac);
1989+ trace_afs_make_fs_call(call, &vp->fid);
1990+ afs_make_op_call(op, call, GFP_KERNEL);
21471991 }
21481992
21491993 /*
@@ -2159,46 +2003,38 @@ static const struct afs_call_type yfs_RXYFSStoreOpaqueACL2 = { · 9 unmodified lines
21592003 /*
21602004 * Fetch the YFS ACL for a file.
21612005 */
2162−int yfs_fs_store_opaque_acl2(struct afs_fs_cursor *fc, const struct afs_acl *acl,
2163− struct afs_status_cb *scb)
2006+void yfs_fs_store_opaque_acl2(struct afs_operation *op)
21642007 {
2165− struct afs_vnode *vnode = fc->vnode;
2008+ struct afs_vnode_param *vp = &op->file[0];
21662009 struct afs_call *call;
2167− struct afs_net *net = afs_v2net(vnode);
2010+ struct afs_acl *acl = op->acl;
21682011 size_t size;
21692012 __be32 *bp;
21702013
21712014 _enter(",%x,{%llx:%llu},,",
2172− key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
2015+ key_serial(op->key), vp->fid.vid, vp->fid.vnode);
21732016
21742017 size = round_up(acl->size, 4);
2175− call = afs_alloc_flat_call(net, &yfs_RXYFSStoreOpaqueACL2,
2018+ call = afs_alloc_flat_call(op->net, &yfs_RXYFSStoreOpaqueACL2,
21762019 sizeof(__be32) * 2 +
21772020 sizeof(struct yfs_xdr_YFSFid) +
21782021 sizeof(__be32) + size,
21792022 sizeof(struct yfs_xdr_YFSFetchStatus) +
21802023 sizeof(struct yfs_xdr_YFSVolSync));
2181− if (!call) {
2182− fc->ac.error = -ENOMEM;
2183− return -ENOMEM;
2184− }
2185−
2186− call->key = fc->key;
2187− call->out_scb = scb;
2188− call->out_volsync = NULL;
2024+ if (!call)
2025+ return afs_op_nomem(op);
21892026
21902027 /* marshall the parameters */
21912028 bp = call->request;
21922029 bp = xdr_encode_u32(bp, YFSSTOREOPAQUEACL2);
21932030 bp = xdr_encode_u32(bp, 0); /* RPC flags */
2194− bp = xdr_encode_YFSFid(bp, &vnode->fid);
2031+ bp = xdr_encode_YFSFid(bp, &vp->fid);
21952032 bp = xdr_encode_u32(bp, acl->size);
21962033 memcpy(bp, acl->data, acl->size);
21972034 if (acl->size != size)
21982035 memset((void *)bp + acl->size, 0, size - acl->size);
21992036 yfs_check_req(call, bp);
22002037
2201− trace_afs_make_fs_call(call, &vnode->fid);
2202− afs_make_call(&fc->ac, call, GFP_KERNEL);
2203− return afs_wait_for_call_to_complete(call, &fc->ac);
2038+ trace_afs_make_fs_call(call, &vp->fid);
2039+ afs_make_op_call(op, call, GFP_KERNEL);
22042040 }
fs/ext4/inode.c+22−22
@@ -4865,21 +4865,22 @@ static int ext4_inode_blocks_set(handle_t *handle, · 4864 unmodified lines
48654865 return 0;
48664866 }
48674867
4868−struct other_inode {
4869− unsigned long orig_ino;
4870− struct ext4_inode *raw_inode;
4871−};
4872−
4873−static int other_inode_match(struct inode * inode, unsigned long ino,
4874− void *data)
4868+static void __ext4_update_other_inode_time(struct super_block *sb,
4869+ unsigned long orig_ino,
4870+ unsigned long ino,
4871+ struct ext4_inode *raw_inode)
48754872 {
4876− struct other_inode *oi = (struct other_inode *) data;
4873+ struct inode *inode;
4874+
4875+ inode = find_inode_by_ino_rcu(sb, ino);
4876+ if (!inode)
4877+ return;
48774878
4878− if ((inode->i_ino != ino) ||
4879− (inode->i_state & (I_FREEING | I_WILL_FREE | I_NEW |
4879+ if ((inode->i_state & (I_FREEING | I_WILL_FREE | I_NEW |
48804880 I_DIRTY_INODE)) ||
48814881 ((inode->i_state & I_DIRTY_TIME) == 0))
4882− return 0;
4882+ return;
4883+
48834884 spin_lock(&inode->i_lock);
48844885 if (((inode->i_state & (I_FREEING | I_WILL_FREE | I_NEW |
48854886 I_DIRTY_INODE)) == 0) &&
@@ -4890,16 +4891,15 @@ static int other_inode_match(struct inode * inode, unsigned long ino, · 4 unmodified lines
48904891 spin_unlock(&inode->i_lock);
48914892
48924893 spin_lock(&ei->i_raw_lock);
4893− EXT4_INODE_SET_XTIME(i_ctime, inode, oi->raw_inode);
4894− EXT4_INODE_SET_XTIME(i_mtime, inode, oi->raw_inode);
4895− EXT4_INODE_SET_XTIME(i_atime, inode, oi->raw_inode);
4896− ext4_inode_csum_set(inode, oi->raw_inode, ei);
4894+ EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
4895+ EXT4_INODE_SET_XTIME(i_mtime, inode, raw_inode);
4896+ EXT4_INODE_SET_XTIME(i_atime, inode, raw_inode);
4897+ ext4_inode_csum_set(inode, raw_inode, ei);
48974898 spin_unlock(&ei->i_raw_lock);
4898− trace_ext4_other_inode_update_time(inode, oi->orig_ino);
4899− return -1;
4899+ trace_ext4_other_inode_update_time(inode, orig_ino);
4900+ return;
49004901 }
49014902 spin_unlock(&inode->i_lock);
4902− return -1;
49034903 }
49044904
49054905 /*
@@ -4909,24 +4909,24 @@ static int other_inode_match(struct inode * inode, unsigned long ino, · 3 unmodified lines
49094909 static void ext4_update_other_inodes_time(struct super_block *sb,
49104910 unsigned long orig_ino, char *buf)
49114911 {
4912− struct other_inode oi;
49134912 unsigned long ino;
49144913 int i, inodes_per_block = EXT4_SB(sb)->s_inodes_per_block;
49154914 int inode_size = EXT4_INODE_SIZE(sb);
49164915
4917− oi.orig_ino = orig_ino;
49184916 /*
49194917 * Calculate the first inode in the inode table block. Inode
49204918 * numbers are one-based. That is, the first inode in a block
49214919 * (assuming 4k blocks and 256 byte inodes) is (n*16 + 1).
49224920 */
49234921 ino = ((orig_ino - 1) & ~(inodes_per_block - 1)) + 1;
4922+ rcu_read_lock();
49244923 for (i = 0; i < inodes_per_block; i++, ino++, buf += inode_size) {
49254924 if (ino == orig_ino)
49264925 continue;
4927− oi.raw_inode = (struct ext4_inode *) buf;
4928− (void) find_inode_nowait(sb, ino, other_inode_match, &oi);
4926+ __ext4_update_other_inode_time(sb, orig_ino, ino,
4927+ (struct ext4_inode *)buf);
49294928 }
4929+ rcu_read_unlock();
49304930 }
49314931
49324932 /*
fs/inode.c+96−16
@@ -497,7 +497,7 @@ void __insert_inode_hash(struct inode *inode, unsigned long hashval) · 496 unmodified lines
497497
498498 spin_lock(&inode_hash_lock);
499499 spin_lock(&inode->i_lock);
500− hlist_add_head(&inode->i_hash, b);
500+ hlist_add_head_rcu(&inode->i_hash, b);
501501 spin_unlock(&inode->i_lock);
502502 spin_unlock(&inode_hash_lock);
503503 }
@@ -513,7 +513,7 @@ void __remove_inode_hash(struct inode *inode) · 9 unmodified lines
513513 {
514514 spin_lock(&inode_hash_lock);
515515 spin_lock(&inode->i_lock);
516− hlist_del_init(&inode->i_hash);
516+ hlist_del_init_rcu(&inode->i_hash);
517517 spin_unlock(&inode->i_lock);
518518 spin_unlock(&inode_hash_lock);
519519 }
@@ -1107,7 +1107,7 @@ again: · 587 unmodified lines
11071107 */
11081108 spin_lock(&inode->i_lock);
11091109 inode->i_state |= I_NEW;
1110− hlist_add_head(&inode->i_hash, head);
1110+ hlist_add_head_rcu(&inode->i_hash, head);
11111111 spin_unlock(&inode->i_lock);
11121112 if (!creating)
11131113 inode_sb_list_add(inode);
@@ -1201,7 +1201,7 @@ again: · 87 unmodified lines
12011201 inode->i_ino = ino;
12021202 spin_lock(&inode->i_lock);
12031203 inode->i_state = I_NEW;
1204− hlist_add_head(&inode->i_hash, head);
1204+ hlist_add_head_rcu(&inode->i_hash, head);
12051205 spin_unlock(&inode->i_lock);
12061206 inode_sb_list_add(inode);
12071207 spin_unlock(&inode_hash_lock);
@@ -1244,15 +1244,10 @@ static int test_inode_iunique(struct super_block *sb, unsigned long ino) · 36 unmodified lines
12441244 struct hlist_head *b = inode_hashtable + hash(sb, ino);
12451245 struct inode *inode;
12461246
1247− spin_lock(&inode_hash_lock);
1248− hlist_for_each_entry(inode, b, i_hash) {
1249− if (inode->i_ino == ino && inode->i_sb == sb) {
1250− spin_unlock(&inode_hash_lock);
1247+ hlist_for_each_entry_rcu(inode, b, i_hash) {
1248+ if (inode->i_ino == ino && inode->i_sb == sb)
12511249 return 0;
1252− }
12531250 }
1254− spin_unlock(&inode_hash_lock);
1255−
12561251 return 1;
12571252 }
12581253
@@ -1281,6 +1276,7 @@ ino_t iunique(struct super_block *sb, ino_t max_reserved) · 22 unmodified lines
12811276 static unsigned int counter;
12821277 ino_t res;
12831278
1279+ rcu_read_lock();
12841280 spin_lock(&iunique_lock);
12851281 do {
12861282 if (counter <= max_reserved)
@@ -1288,6 +1284,7 @@ ino_t iunique(struct super_block *sb, ino_t max_reserved) · 1 unmodified line
12881284 res = counter++;
12891285 } while (!test_inode_iunique(sb, res));
12901286 spin_unlock(&iunique_lock);
1287+ rcu_read_unlock();
12911288
12921289 return res;
12931290 }
@@ -1456,6 +1453,84 @@ out: · 162 unmodified lines
14561453 }
14571454 EXPORT_SYMBOL(find_inode_nowait);
14581455
1456+/**
1457+ * find_inode_rcu - find an inode in the inode cache
1458+ * @sb: Super block of file system to search
1459+ * @hashval: Key to hash
1460+ * @test: Function to test match on an inode
1461+ * @data: Data for test function
1462+ *
1463+ * Search for the inode specified by @hashval and @data in the inode cache,
1464+ * where the helper function @test will return 0 if the inode does not match
1465+ * and 1 if it does. The @test function must be responsible for taking the
1466+ * i_lock spin_lock and checking i_state for an inode being freed or being
1467+ * initialized.
1468+ *
1469+ * If successful, this will return the inode for which the @test function
1470+ * returned 1 and NULL otherwise.
1471+ *
1472+ * The @test function is not permitted to take a ref on any inode presented.
1473+ * It is also not permitted to sleep.
1474+ *
1475+ * The caller must hold the RCU read lock.
1476+ */
1477+struct inode *find_inode_rcu(struct super_block *sb, unsigned long hashval,
1478+ int (*test)(struct inode *, void *), void *data)
1479+{
1480+ struct hlist_head *head = inode_hashtable + hash(sb, hashval);
1481+ struct inode *inode;
1482+
1483+ RCU_LOCKDEP_WARN(!rcu_read_lock_held(),
1484+ "suspicious find_inode_rcu() usage");
1485+
1486+ hlist_for_each_entry_rcu(inode, head, i_hash) {
1487+ if (inode->i_sb == sb &&
1488+ !(READ_ONCE(inode->i_state) & (I_FREEING | I_WILL_FREE)) &&
1489+ test(inode, data))
1490+ return inode;
1491+ }
1492+ return NULL;
1493+}
1494+EXPORT_SYMBOL(find_inode_rcu);
1495+
1496+/**
1497+ * find_inode_by_rcu - Find an inode in the inode cache
1498+ * @sb: Super block of file system to search
1499+ * @ino: The inode number to match
1500+ *
1501+ * Search for the inode specified by @hashval and @data in the inode cache,
1502+ * where the helper function @test will return 0 if the inode does not match
1503+ * and 1 if it does. The @test function must be responsible for taking the
1504+ * i_lock spin_lock and checking i_state for an inode being freed or being
1505+ * initialized.
1506+ *
1507+ * If successful, this will return the inode for which the @test function
1508+ * returned 1 and NULL otherwise.
1509+ *
1510+ * The @test function is not permitted to take a ref on any inode presented.
1511+ * It is also not permitted to sleep.
1512+ *
1513+ * The caller must hold the RCU read lock.
1514+ */
1515+struct inode *find_inode_by_ino_rcu(struct super_block *sb,
1516+ unsigned long ino)
1517+{
1518+ struct hlist_head *head = inode_hashtable + hash(sb, ino);
1519+ struct inode *inode;
1520+
1521+ RCU_LOCKDEP_WARN(!rcu_read_lock_held(),
1522+ "suspicious find_inode_by_ino_rcu() usage");
1523+
1524+ hlist_for_each_entry_rcu(inode, head, i_hash) {
1525+ if (inode->i_ino == ino &&
1526+ inode->i_sb == sb &&
1527+ !(READ_ONCE(inode->i_state) & (I_FREEING | I_WILL_FREE)))
1528+ return inode;
1529+ }
1530+ return NULL;
1531+}
1532+EXPORT_SYMBOL(find_inode_by_ino_rcu);
1533+
14591534 int insert_inode_locked(struct inode *inode)
14601535 {
14611536 struct super_block *sb = inode->i_sb;
@@ -1480,7 +1555,7 @@ int insert_inode_locked(struct inode *inode) · 18 unmodified lines
14801555 if (likely(!old)) {
14811556 spin_lock(&inode->i_lock);
14821557 inode->i_state |= I_NEW | I_CREATING;
1483− hlist_add_head(&inode->i_hash, head);
1558+ hlist_add_head_rcu(&inode->i_hash, head);
14841559 spin_unlock(&inode->i_lock);
14851560 spin_unlock(&inode_hash_lock);
14861561 return 0;
@@ -1540,6 +1615,7 @@ static void iput_final(struct inode *inode) · 53 unmodified lines
15401615 {
15411616 struct super_block *sb = inode->i_sb;
15421617 const struct super_operations *op = inode->i_sb->s_op;
1618+ unsigned long state;
15431619 int drop;
15441620
15451621 WARN_ON(inode->i_state & I_NEW);
@@ -1555,16 +1631,20 @@ static void iput_final(struct inode *inode) · 9 unmodified lines
15551631 return;
15561632 }
15571633
1634+ state = inode->i_state;
15581635 if (!drop) {
1559− inode->i_state |= I_WILL_FREE;
1636+ WRITE_ONCE(inode->i_state, state | I_WILL_FREE);
15601637 spin_unlock(&inode->i_lock);
1638+
15611639 write_inode_now(inode, 1);
1640+
15621641 spin_lock(&inode->i_lock);
1563− WARN_ON(inode->i_state & I_NEW);
1564− inode->i_state &= ~I_WILL_FREE;
1642+ state = inode->i_state;
1643+ WARN_ON(state & I_NEW);
1644+ state &= ~I_WILL_FREE;
15651645 }
15661646
1567− inode->i_state |= I_FREEING;
1647+ WRITE_ONCE(inode->i_state, state | I_FREEING);
15681648 if (!list_empty(&inode->i_lru))
15691649 inode_lru_list_del(inode);
15701650 spin_unlock(&inode->i_lock);
include/linux/fs.h+3−0
@@ -3081,6 +3081,9 @@ extern struct inode *find_inode_nowait(struct super_block *, · 3080 unmodified lines
30813081 int (*match)(struct inode *,
30823082 unsigned long, void *),
30833083 void *data);
3084+extern struct inode *find_inode_rcu(struct super_block *, unsigned long,
3085+ int (*)(struct inode *, void *), void *);
3086+extern struct inode *find_inode_by_ino_rcu(struct super_block *, unsigned long);
30843087 extern int insert_inode_locked4(struct inode *, unsigned long, int (*test)(struct inode *, void *), void *);
30853088 extern int insert_inode_locked(struct inode *);
30863089 #ifdef CONFIG_DEBUG_LOCK_ALLOC
include/trace/events/afs.h+88−23
@@ -33,20 +33,40 @@ enum afs_server_trace { · 32 unmodified lines
3333 afs_server_trace_destroy,
3434 afs_server_trace_free,
3535 afs_server_trace_gc,
36+ afs_server_trace_get_by_addr,
3637 afs_server_trace_get_by_uuid,
3738 afs_server_trace_get_caps,
3839 afs_server_trace_get_install,
3940 afs_server_trace_get_new_cbi,
41+ afs_server_trace_get_probe,
4042 afs_server_trace_give_up_cb,
4143 afs_server_trace_put_call,
4244 afs_server_trace_put_cbi,
4345 afs_server_trace_put_find_rsq,
46+ afs_server_trace_put_probe,
4447 afs_server_trace_put_slist,
4548 afs_server_trace_put_slist_isort,
4649 afs_server_trace_put_uuid_rsq,
4750 afs_server_trace_update,
4851 };
4952
53+enum afs_volume_trace {
54+ afs_volume_trace_alloc,
55+ afs_volume_trace_free,
56+ afs_volume_trace_get_alloc_sbi,
57+ afs_volume_trace_get_cell_insert,
58+ afs_volume_trace_get_new_op,
59+ afs_volume_trace_get_query_alias,
60+ afs_volume_trace_put_cell_dup,
61+ afs_volume_trace_put_cell_root,
62+ afs_volume_trace_put_destroy_sbi,
63+ afs_volume_trace_put_free_fc,
64+ afs_volume_trace_put_put_op,
65+ afs_volume_trace_put_query_alias,
66+ afs_volume_trace_put_validate_fc,
67+ afs_volume_trace_remove,
68+};
69+
5070 enum afs_fs_operation {
5171 afs_FS_FetchData = 130, /* AFS Fetch file data */
5272 afs_FS_FetchACL = 131, /* AFS Fetch file ACL */
@@ -108,6 +128,7 @@ enum afs_vl_operation { · 55 unmodified lines
108128 afs_VL_GetEntryByNameU = 527, /* AFS Get Vol Entry By Name operation ID */
109129 afs_VL_GetAddrsU = 533, /* AFS Get FS server addresses */
110130 afs_YFSVL_GetEndpoints = 64002, /* YFS Get FS & Vol server addresses */
131+ afs_YFSVL_GetCellName = 64014, /* YFS Get actual cell name */
111132 afs_VL_GetCapabilities = 65537, /* AFS Get VL server capabilities */
112133 };
113134
@@ -140,6 +161,7 @@ enum afs_eproto_cause { · 26 unmodified lines
140161 afs_eproto_bad_status,
141162 afs_eproto_cb_count,
142163 afs_eproto_cb_fid_count,
164+ afs_eproto_cellname_len,
143165 afs_eproto_file_type,
144166 afs_eproto_ibulkst_cb_count,
145167 afs_eproto_ibulkst_count,
@@ -241,19 +263,38 @@ enum afs_cb_break_reason { · 95 unmodified lines
241263 EM(afs_server_trace_destroy, "DESTROY ") \
242264 EM(afs_server_trace_free, "FREE ") \
243265 EM(afs_server_trace_gc, "GC ") \
266+ EM(afs_server_trace_get_by_addr, "GET addr ") \
244267 EM(afs_server_trace_get_by_uuid, "GET uuid ") \
245268 EM(afs_server_trace_get_caps, "GET caps ") \
246269 EM(afs_server_trace_get_install, "GET inst ") \
247270 EM(afs_server_trace_get_new_cbi, "GET cbi ") \
271+ EM(afs_server_trace_get_probe, "GET probe") \
248272 EM(afs_server_trace_give_up_cb, "giveup-cb") \
249273 EM(afs_server_trace_put_call, "PUT call ") \
250274 EM(afs_server_trace_put_cbi, "PUT cbi ") \
251275 EM(afs_server_trace_put_find_rsq, "PUT f-rsq") \
276+ EM(afs_server_trace_put_probe, "PUT probe") \
252277 EM(afs_server_trace_put_slist, "PUT slist") \
253278 EM(afs_server_trace_put_slist_isort, "PUT isort") \
254279 EM(afs_server_trace_put_uuid_rsq, "PUT u-req") \
255280 E_(afs_server_trace_update, "UPDATE")
256281
282+#define afs_volume_traces \
283+ EM(afs_volume_trace_alloc, "ALLOC ") \
284+ EM(afs_volume_trace_free, "FREE ") \
285+ EM(afs_volume_trace_get_alloc_sbi, "GET sbi-alloc ") \
286+ EM(afs_volume_trace_get_cell_insert, "GET cell-insrt") \
287+ EM(afs_volume_trace_get_new_op, "GET op-new ") \
288+ EM(afs_volume_trace_get_query_alias, "GET cell-alias") \
289+ EM(afs_volume_trace_put_cell_dup, "PUT cell-dup ") \
290+ EM(afs_volume_trace_put_cell_root, "PUT cell-root ") \
291+ EM(afs_volume_trace_put_destroy_sbi, "PUT sbi-destry") \
292+ EM(afs_volume_trace_put_free_fc, "PUT fc-free ") \
293+ EM(afs_volume_trace_put_put_op, "PUT op-put ") \
294+ EM(afs_volume_trace_put_query_alias, "PUT cell-alias") \
295+ EM(afs_volume_trace_put_validate_fc, "PUT fc-validat") \
296+ E_(afs_volume_trace_remove, "REMOVE ")
297+
257298 #define afs_fs_operations \
258299 EM(afs_FS_FetchData, "FS.FetchData") \
259300 EM(afs_FS_FetchStatus, "FS.FetchStatus") \
@@ -310,6 +351,7 @@ enum afs_cb_break_reason { · 50 unmodified lines
310351 EM(afs_VL_GetEntryByNameU, "VL.GetEntryByNameU") \
311352 EM(afs_VL_GetAddrsU, "VL.GetAddrsU") \
312353 EM(afs_YFSVL_GetEndpoints, "YFSVL.GetEndpoints") \
354+ EM(afs_YFSVL_GetCellName, "YFSVL.GetCellName") \
313355 E_(afs_VL_GetCapabilities, "VL.GetCapabilities")
314356
315357 #define afs_edit_dir_ops \
@@ -339,6 +381,7 @@ enum afs_cb_break_reason { · 23 unmodified lines
339381 EM(afs_eproto_bad_status, "BadStatus") \
340382 EM(afs_eproto_cb_count, "CbCount") \
341383 EM(afs_eproto_cb_fid_count, "CbFidCount") \
384+ EM(afs_eproto_cellname_len, "CellNameLen") \
342385 EM(afs_eproto_file_type, "FileTYpe") \
343386 EM(afs_eproto_ibulkst_cb_count, "IBS.CbCount") \
344387 EM(afs_eproto_ibulkst_count, "IBS.FidCount") \
@@ -636,7 +679,7 @@ TRACE_EVENT(afs_make_fs_calli, · 291 unmodified lines
636679
637680 TRACE_EVENT(afs_make_fs_call1,
638681 TP_PROTO(struct afs_call *call, const struct afs_fid *fid,
639− const char *name),
682+ const struct qstr *name),
640683
641684 TP_ARGS(call, fid, name),
642685
@@ -648,8 +691,7 @@ TRACE_EVENT(afs_make_fs_call1, · 5 unmodified lines
648691 ),
649692
650693 TP_fast_assign(
651− int __len = strlen(name);
652− __len = min(__len, 23);
694+ unsigned int __len = min_t(unsigned int, name->len, 23);
653695 __entry->call = call->debug_id;
654696 __entry->op = call->operation_ID;
655697 if (fid) {
@@ -659,7 +701,7 @@ TRACE_EVENT(afs_make_fs_call1, · 3 unmodified lines
659701 __entry->fid.vnode = 0;
660702 __entry->fid.unique = 0;
661703 }
662− memcpy(__entry->name, name, __len);
704+ memcpy(__entry->name, name->name, __len);
663705 __entry->name[__len] = 0;
664706 ),
665707
@@ -674,7 +716,7 @@ TRACE_EVENT(afs_make_fs_call1, · 8 unmodified lines
674716
675717 TRACE_EVENT(afs_make_fs_call2,
676718 TP_PROTO(struct afs_call *call, const struct afs_fid *fid,
677− const char *name, const char *name2),
719+ const struct qstr *name, const struct qstr *name2),
678720
679721 TP_ARGS(call, fid, name, name2),
680722
@@ -687,10 +729,8 @@ TRACE_EVENT(afs_make_fs_call2, · 6 unmodified lines
687729 ),
688730
689731 TP_fast_assign(
690− int __len = strlen(name);
691− int __len2 = strlen(name2);
692− __len = min(__len, 23);
693− __len2 = min(__len2, 23);
732+ unsigned int __len = min_t(unsigned int, name->len, 23);
733+ unsigned int __len2 = min_t(unsigned int, name2->len, 23);
694734 __entry->call = call->debug_id;
695735 __entry->op = call->operation_ID;
696736 if (fid) {
@@ -700,9 +740,9 @@ TRACE_EVENT(afs_make_fs_call2, · 3 unmodified lines
700740 __entry->fid.vnode = 0;
701741 __entry->fid.unique = 0;
702742 }
703− memcpy(__entry->name, name, __len);
743+ memcpy(__entry->name, name->name, __len);
704744 __entry->name[__len] = 0;
705− memcpy(__entry->name2, name2, __len2);
745+ memcpy(__entry->name2, name2->name, __len2);
706746 __entry->name2[__len2] = 0;
707747 ),
708748
@@ -988,24 +1028,22 @@ TRACE_EVENT(afs_edit_dir, · 279 unmodified lines
9881028 );
9891029
9901030 TRACE_EVENT(afs_protocol_error,
991− TP_PROTO(struct afs_call *call, int error, enum afs_eproto_cause cause),
1031+ TP_PROTO(struct afs_call *call, enum afs_eproto_cause cause),
9921032
993− TP_ARGS(call, error, cause),
1033+ TP_ARGS(call, cause),
9941034
9951035 TP_STRUCT__entry(
9961036 __field(unsigned int, call )
997− __field(int, error )
9981037 __field(enum afs_eproto_cause, cause )
9991038 ),
10001039
10011040 TP_fast_assign(
10021041 __entry->call = call ? call->debug_id : 0;
1003− __entry->error = error;
10041042 __entry->cause = cause;
10051043 ),
10061044
1007− TP_printk("c=%08x r=%d %s",
1008− __entry->call, __entry->error,
1045+ TP_printk("c=%08x %s",
1046+ __entry->call,
10091047 __print_symbolic(__entry->cause, afs_eproto_causes))
10101048 );
10111049
@@ -1271,26 +1309,53 @@ TRACE_EVENT(afs_cb_miss, · 259 unmodified lines
12711309 );
12721310
12731311 TRACE_EVENT(afs_server,
1274− TP_PROTO(struct afs_server *server, int usage, enum afs_server_trace reason),
1312+ TP_PROTO(struct afs_server *server, int ref, int active,
1313+ enum afs_server_trace reason),
12751314
1276− TP_ARGS(server, usage, reason),
1315+ TP_ARGS(server, ref, active, reason),
12771316
12781317 TP_STRUCT__entry(
12791318 __field(unsigned int, server )
1280− __field(int, usage )
1319+ __field(int, ref )
1320+ __field(int, active )
12811321 __field(int, reason )
12821322 ),
12831323
12841324 TP_fast_assign(
12851325 __entry->server = server->debug_id;
1286− __entry->usage = usage;
1326+ __entry->ref = ref;
1327+ __entry->active = active;
12871328 __entry->reason = reason;
12881329 ),
12891330
1290− TP_printk("s=%08x %s u=%d",
1331+ TP_printk("s=%08x %s u=%d a=%d",
12911332 __entry->server,
12921333 __print_symbolic(__entry->reason, afs_server_traces),
1293− __entry->usage)
1334+ __entry->ref,
1335+ __entry->active)
1336+ );
1337+
1338+TRACE_EVENT(afs_volume,
1339+ TP_PROTO(afs_volid_t vid, int ref, enum afs_volume_trace reason),
1340+
1341+ TP_ARGS(vid, ref, reason),
1342+
1343+ TP_STRUCT__entry(
1344+ __field(afs_volid_t, vid )
1345+ __field(int, ref )
1346+ __field(enum afs_volume_trace, reason )
1347+ ),
1348+
1349+ TP_fast_assign(
1350+ __entry->vid = vid;
1351+ __entry->ref = ref;
1352+ __entry->reason = reason;
1353+ ),
1354+
1355+ TP_printk("V=%llx %s u=%d",
1356+ __entry->vid,
1357+ __print_symbolic(__entry->reason, afs_volume_traces),
1358+ __entry->ref)
12941359 );
12951360
12961361 #endif /* _TRACE_AFS_H */
net/rxrpc/peer_event.c+3−0
@@ -271,6 +271,9 @@ static void rxrpc_store_error(struct rxrpc_peer *peer, · 270 unmodified lines
271271 break;
272272
273273 case SO_EE_ORIGIN_ICMP6:
274+ if (err == EACCES)
275+ err = EHOSTUNREACH;
276+ /* Fall through */
274277 default:
275278 _proto("Rx Received error report { orig=%u }", ee->ee_origin);
276279 break;
net/rxrpc/proc.c+3−3
@@ -68,7 +68,7 @@ static int rxrpc_call_seq_show(struct seq_file *seq, void *v) · 67 unmodified lines
6868 "Proto Local "
6969 " Remote "
7070 " SvID ConnID CallID End Use State Abort "
71− " UserID TxSeq TW RxSeq RW RxSerial RxTimo\n");
71+ " DebugId TxSeq TW RxSeq RW RxSerial RxTimo\n");
7272 return 0;
7373 }
7474
@@ -100,7 +100,7 @@ static int rxrpc_call_seq_show(struct seq_file *seq, void *v) · 25 unmodified lines
100100 rx_hard_ack = READ_ONCE(call->rx_hard_ack);
101101 seq_printf(seq,
102102 "UDP %-47.47s %-47.47s %4x %08x %08x %s %3u"
103− " %-8.8s %08x %lx %08x %02x %08x %02x %08x %06lx\n",
103+ " %-8.8s %08x %08x %08x %02x %08x %02x %08x %06lx\n",
104104 lbuff,
105105 rbuff,
106106 call->service_id,
@@ -110,7 +110,7 @@ static int rxrpc_call_seq_show(struct seq_file *seq, void *v) · 3 unmodified lines
110110 atomic_read(&call->usage),
111111 rxrpc_call_states[call->state],
112112 call->abort_code,
113− call->user_call_ID,
113+ call->debug_id,
114114 tx_hard_ack, READ_ONCE(call->tx_top) - tx_hard_ack,
115115 rx_hard_ack, READ_ONCE(call->rx_top) - rx_hard_ack,
116116 call->rx_serial,