Skip to content

Commit dc41918

Browse files
committed
afs: Use the fs operation ops to handle FetchData completion
Use the 'success' and 'aborted' afs_operations_ops methods and add a 'failed' method to handle the completion of an AFS.FetchData, AFS.FetchData64 or YFS.FetchData64 RPC operation rather than directly calling the done func pointed to by the afs_read struct from the call delivery handler. This means the done function will be called back on error also, not just on successful completion. This allows motion towards asynchronous data reception on data fetch calls and allows any error to be handed off to the fscache read helper in the same place as a successful completion. Signed-off-by: David Howells <[email protected]> Tested-By: Marc Dionne <[email protected]> cc: [email protected] cc: [email protected] cc: [email protected] Link: https://lore.kernel.org/r/160588541471.3465195.8807019223378490810.stgit@warthog.procyon.org.uk/ # rfc Link: https://lore.kernel.org/r/161118157260.1232039.6549085372718234792.stgit@warthog.procyon.org.uk/ # rfc Link: https://lore.kernel.org/r/161161052647.2537118.12922380836599003659.stgit@warthog.procyon.org.uk/ # v2 Link: https://lore.kernel.org/r/161340417106.1303470.3502017303898569631.stgit@warthog.procyon.org.uk/ # v3 Link: https://lore.kernel.org/r/161539560673.286939.391310781674212229.stgit@warthog.procyon.org.uk/ # v4 Link: https://lore.kernel.org/r/161653816367.2770958.5856904574822446404.stgit@warthog.procyon.org.uk/ # v5 Link: https://lore.kernel.org/r/161789099994.6155.473719823490561190.stgit@warthog.procyon.org.uk/ # v6
1 parent e87b03f commit dc41918

File tree

5 files changed

+19
-7
lines changed

5 files changed

+19
-7
lines changed

fs/afs/file.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,19 @@ void afs_put_read(struct afs_read *req)
254254
}
255255
}
256256

257+
static void afs_fetch_data_notify(struct afs_operation *op)
258+
{
259+
struct afs_read *req = op->fetch.req;
260+
int error = op->error;
261+
262+
if (error == -ECONNABORTED)
263+
error = afs_abort_to_error(op->ac.abort_code);
264+
req->error = error;
265+
266+
if (req->done)
267+
req->done(req);
268+
}
269+
257270
static void afs_fetch_data_success(struct afs_operation *op)
258271
{
259272
struct afs_vnode *vnode = op->file[0].vnode;
@@ -262,6 +275,7 @@ static void afs_fetch_data_success(struct afs_operation *op)
262275
afs_vnode_commit_status(op, &op->file[0]);
263276
afs_stat_v(vnode, n_fetches);
264277
atomic_long_add(op->fetch.req->actual_len, &op->net->n_fetch_bytes);
278+
afs_fetch_data_notify(op);
265279
}
266280

267281
static void afs_fetch_data_put(struct afs_operation *op)
@@ -275,6 +289,7 @@ static const struct afs_operation_ops afs_fetch_data_operation = {
275289
.issue_yfs_rpc = yfs_fs_fetch_data,
276290
.success = afs_fetch_data_success,
277291
.aborted = afs_check_for_remote_deletion,
292+
.failed = afs_fetch_data_notify,
278293
.put = afs_fetch_data_put,
279294
};
280295

fs/afs/fs_operation.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,10 @@ void afs_wait_for_operation(struct afs_operation *op)
198198
case -ECONNABORTED:
199199
if (op->ops->aborted)
200200
op->ops->aborted(op);
201-
break;
201+
fallthrough;
202202
default:
203+
if (op->ops->failed)
204+
op->ops->failed(op);
203205
break;
204206
}
205207

fs/afs/fsclient.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,6 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call)
392392
break;
393393
}
394394

395-
if (req->done)
396-
req->done(req);
397-
398395
_leave(" = 0 [done]");
399396
return 0;
400397
}

fs/afs/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,7 @@ struct afs_operation_ops {
742742
void (*issue_yfs_rpc)(struct afs_operation *op);
743743
void (*success)(struct afs_operation *op);
744744
void (*aborted)(struct afs_operation *op);
745+
void (*failed)(struct afs_operation *op);
745746
void (*edit_dir)(struct afs_operation *op);
746747
void (*put)(struct afs_operation *op);
747748
};

fs/afs/yfsclient.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,9 +449,6 @@ static int yfs_deliver_fs_fetch_data64(struct afs_call *call)
449449
break;
450450
}
451451

452-
if (req->done)
453-
req->done(req);
454-
455452
_leave(" = 0 [done]");
456453
return 0;
457454
}

0 commit comments

Comments
 (0)