]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
afs: Use the fs operation ops to handle FetchData completion
authorDavid Howells <dhowells@redhat.com>
Fri, 18 Sep 2020 08:11:15 +0000 (09:11 +0100)
committerDavid Howells <dhowells@redhat.com>
Thu, 28 Jan 2021 10:57:12 +0000 (10:57 +0000)
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 <dhowells@redhat.com>
fs/afs/file.c
fs/afs/fs_operation.c
fs/afs/fsclient.c
fs/afs/internal.h
fs/afs/yfsclient.c

index f6282ac0d222f908be50f11df611df80cdbc3227..231e9fd7882b6019517bca92a7cc9953ed9c6dcb 100644 (file)
@@ -255,6 +255,19 @@ void afs_put_read(struct afs_read *req)
        }
 }
 
+static void afs_fetch_data_notify(struct afs_operation *op)
+{
+       struct afs_read *req = op->fetch.req;
+       int error = op->error;
+
+       if (error == -ECONNABORTED)
+               error = afs_abort_to_error(op->ac.abort_code);
+       req->error = error;
+
+       if (req->done)
+               req->done(req);
+}
+
 static void afs_fetch_data_success(struct afs_operation *op)
 {
        struct afs_vnode *vnode = op->file[0].vnode;
@@ -263,6 +276,7 @@ static void afs_fetch_data_success(struct afs_operation *op)
        afs_vnode_commit_status(op, &op->file[0]);
        afs_stat_v(vnode, n_fetches);
        atomic_long_add(op->fetch.req->actual_len, &op->net->n_fetch_bytes);
+       afs_fetch_data_notify(op);
 }
 
 static void afs_fetch_data_put(struct afs_operation *op)
@@ -276,6 +290,7 @@ static const struct afs_operation_ops afs_fetch_data_operation = {
        .issue_yfs_rpc  = yfs_fs_fetch_data,
        .success        = afs_fetch_data_success,
        .aborted        = afs_check_for_remote_deletion,
+       .failed         = afs_fetch_data_notify,
        .put            = afs_fetch_data_put,
 };
 
index 97cab12b0a6c252380e3f317eac3aaba4878e894..938e28a00101db075cbcae37569f76586785f7b3 100644 (file)
@@ -195,8 +195,10 @@ void afs_wait_for_operation(struct afs_operation *op)
        case -ECONNABORTED:
                if (op->ops->aborted)
                        op->ops->aborted(op);
-               break;
+               fallthrough;
        default:
+               if (op->ops->failed)
+                       op->ops->failed(op);
                break;
        }
 
index 31e6b3635541d8d54c885f2a5f913da0a91afdde..5e34f4dbd385b4bc39253f26eb6564d462c378bd 100644 (file)
@@ -392,9 +392,6 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call)
                break;
        }
 
-       if (req->done)
-               req->done(req);
-
        _leave(" = 0 [done]");
        return 0;
 }
index daf5339ae31673f1d27d5ed11bb03a8da27283b0..d46389406021a4ae75dddac7301643232e7b841c 100644 (file)
@@ -742,6 +742,7 @@ struct afs_operation_ops {
        void (*issue_yfs_rpc)(struct afs_operation *op);
        void (*success)(struct afs_operation *op);
        void (*aborted)(struct afs_operation *op);
+       void (*failed)(struct afs_operation *op);
        void (*edit_dir)(struct afs_operation *op);
        void (*put)(struct afs_operation *op);
 };
index 363d6dd276c0d5929719391432dd1d2d2d831440..2b35cba8ad62b7f801405643ba1657b654062c2e 100644 (file)
@@ -449,9 +449,6 @@ static int yfs_deliver_fs_fetch_data64(struct afs_call *call)
                break;
        }
 
-       if (req->done)
-               req->done(req);
-
        _leave(" = 0 [done]");
        return 0;
 }