1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
5 * Lustre Metadata Target (mdt) request unpacking helper.
7 * Copyright (c) 2006 Cluster File Systems, Inc.
8 * Author: Peter Braam <braam@clusterfs.com>
9 * Author: Andreas Dilger <adilger@clusterfs.com>
10 * Author: Phil Schwan <phil@clusterfs.com>
11 * Author: Mike Shaver <shaver@clusterfs.com>
12 * Author: Nikita Danilov <nikita@clusterfs.com>
13 * Author: Huang Hua <huanghua@clusterfs.com>
16 * This file is part of the Lustre file system, http://www.lustre.org
17 * Lustre is a trademark of Cluster File Systems, Inc.
19 * You may have signed or agreed to another license before downloading
20 * this software. If so, you are bound by the terms and conditions
21 * of that agreement, and the following does not apply to you. See the
22 * LICENSE file included with this distribution for more information.
24 * If you did not agree to a different license, then this copy of Lustre
25 * is open source software; you can redistribute it and/or modify it
26 * under the terms of version 2 of the GNU General Public License as
27 * published by the Free Software Foundation.
29 * In either case, Lustre is distributed in the hope that it will be
30 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
31 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * license text for more details.
37 # define EXPORT_SYMTAB
39 #define DEBUG_SUBSYSTEM S_MDS
41 #include "mdt_internal.h"
45 static int mdt_setattr_unpack(struct mdt_thread_info *info)
51 static int mdt_create_unpack(struct mdt_thread_info *info)
53 struct mdt_rec_create *rec;
54 struct lu_attr *attr = &info->mti_attr;
55 struct mdt_reint_record *rr = &info->mti_rr;
56 struct req_capsule *pill = &info->mti_pill;
60 rec = req_capsule_client_get(pill, &RMF_REC_CREATE);
62 rr->rr_fid1 = &rec->cr_fid1;
63 rr->rr_fid2 = &rec->cr_fid2;
64 attr->la_mode = rec->cr_mode;
66 rr->rr_name = req_capsule_client_get(pill, &RMF_NAME);
73 static int mdt_link_unpack(struct mdt_thread_info *info)
79 static int mdt_unlink_unpack(struct mdt_thread_info *info)
85 static int mdt_rename_unpack(struct mdt_thread_info *info)
91 static int mdt_open_unpack(struct mdt_thread_info *info)
93 struct mdt_rec_create *rec;
94 struct lu_attr *attr = &info->mti_attr;
95 struct req_capsule *pill = &info->mti_pill;
96 struct mdt_reint_record *rr = &info->mti_rr;
100 rec = req_capsule_client_get(pill, &RMF_REC_CREATE);
102 rr->rr_fid1 = &rec->cr_fid1;
103 rr->rr_fid2 = &rec->cr_fid2;
104 attr->la_mode = rec->cr_mode;
105 rr->rr_flags = rec->cr_flags;
107 rr->rr_name = req_capsule_client_get(pill, &RMF_NAME);
108 if (rr->rr_name == NULL)
118 typedef int (*reint_unpacker)(struct mdt_thread_info *info);
120 static reint_unpacker mdt_reint_unpackers[REINT_MAX] = {
121 [REINT_SETATTR] = mdt_setattr_unpack,
122 [REINT_CREATE] = mdt_create_unpack,
123 [REINT_LINK] = mdt_link_unpack,
124 [REINT_UNLINK] = mdt_unlink_unpack,
125 [REINT_RENAME] = mdt_rename_unpack,
126 [REINT_OPEN] = mdt_open_unpack
129 int mdt_reint_unpack(struct mdt_thread_info *info, __u32 op)
135 if (op < REINT_MAX && mdt_reint_unpackers[op] != NULL) {
136 info->mti_rr.rr_opcode = op;
137 rc = mdt_reint_unpackers[op](info);
139 CERROR("Unexpected opcode %d\n", op);