Whamcloud - gitweb
LU-14393 protocol: basic batching processing framework
[fs/lustre-release.git] / lustre / mdc / mdc_batch.c
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; If not, see
18  * http://www.gnu.org/licenses/gpl-2.0.html
19  *
20  * GPL HEADER END
21  */
22 /*
23  * Copyright (c) 2020, 2022, DDN Storage Corporation.
24  */
25 /*
26  * This file is part of Lustre, http://www.lustre.org/
27  */
28 /*
29  * lustre/mdc/mdc_batch.c
30  *
31  * Batch Metadata Updating on the client (MDC)
32  *
33  * Author: Qian Yingjin <qian@ddn.com>
34  */
35
36 #define DEBUG_SUBSYSTEM S_MDC
37
38 #include <linux/module.h>
39 #include <lustre_update.h>
40 #include <lustre_acl.h>
41
42 #include "mdc_internal.h"
43
44
45 static md_update_pack_t mdc_update_packers[MD_OP_MAX];
46
47 static object_update_interpret_t mdc_update_interpreters[MD_OP_MAX];
48
49 int mdc_batch_add(struct obd_export *exp, struct lu_batch *bh,
50                   struct md_op_item *item)
51 {
52         enum md_item_opcode opc = item->mop_opc;
53
54         ENTRY;
55
56         if (opc >= MD_OP_MAX || mdc_update_packers[opc] == NULL ||
57             mdc_update_interpreters[opc] == NULL) {
58                 CERROR("%s: unexpected opcode %d\n",
59                        exp->exp_obd->obd_name, opc);
60                 RETURN(-EFAULT);
61         }
62
63         RETURN(cli_batch_add(exp, bh, item, mdc_update_packers[opc],
64                              mdc_update_interpreters[opc]));
65 }