1 /* -*- MODE: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * Copyright (C) 2006 Cluster File Systems, Inc.
7 * Author: WangDi <wangdi@clusterfs.com>
9 * This file is part of the Lustre file system, http://www.lustre.org
10 * Lustre is a trademark of Cluster File Systems, Inc.
12 * You may have signed or agreed to another license before downloading
13 * this software. If so, you are bound by the terms and conditions
14 * of that agreement, and the following does not apply to you. See the
15 * LICENSE file included with this distribution for more information.
17 * If you did not agree to a different license, then this copy of Lustre
18 * is open source software; you can redistribute it and/or modify it
19 * under the terms of version 2 of the GNU General Public License as
20 * published by the Free Software Foundation.
22 * In either case, Lustre is distributed in the hope that it will be
23 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
24 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * license text for more details.
28 # define EXPORT_SYMTAB
30 #define DEBUG_SUBSYSTEM S_LLITE
32 #include <linux/module.h>
33 #include <linux/jbd.h>
36 #include <obd_class.h>
37 #include <lustre_ver.h>
38 #include <obd_support.h>
39 #include <lprocfs_status.h>
41 #include <dt_object.h>
42 #include <md_object.h>
43 #include <lustre_mdc.h>
44 #include <lustre_fid.h>
45 #include <linux/lustre_iam.h>
46 #include "fld_internal.h"
48 struct iam_descr fld_param = {
49 .id_key_size = sizeof ((struct lu_fid *)0)->f_seq,
50 .id_ptr_size = 4, /* 32 bit block numbers for now */
51 .id_rec_size = sizeof(mdsno_t),
52 .id_node_gap = 0, /* no gaps in index nodes */
56 .id_root_ptr = iam_root_ptr, /* returns 0: root is always at the
57 * beginning of the file (as it
59 .id_node_read = iam_node_read,
60 .id_node_check = iam_node_check,
61 .id_node_init = iam_node_init,
62 .id_keycmp = iam_keycmp,
66 int fld_handle_insert(const struct lu_context *ctx, struct fld *fld,
67 fidseq_t seq_num, mdsno_t mdsno)
70 * XXX Use ->dio_index_insert() from struct dt_index_operations. The
74 return fld->fld_dt->dd_ops->dt_iam_insert(&lctx, fld->fld_dt,
75 fld->fld_info->fi_container,
76 &seq_num, fld_param.id_key_size,
77 &mdsno, fld_param.id_rec_size);
83 int fld_handle_delete(const struct lu_context *ctx, struct fld *fld,
84 fidseq_t seq_num, mdsno_t mds_num)
87 return fld->fld_dt->dd_ops->dt_iam_delete(&lctx, fld->fld_dt,
88 fld->fld_info->fi_container,
89 &seq_num, fld_param.id_key_size,
90 &mds_num, fld_param.id_rec_size);
96 int fld_handle_lookup(const struct lu_context *ctx,
97 struct fld *fld, fidseq_t seq_num, mdsno_t *mds_num)
102 size = fld_param.id_rec_size;
103 return fld->fld_dt->dd_ops->dt_iam_lookup(&lctx, fld->fld_dt,
104 fld->fld_info->fi_container,
105 &seq_num, fld_param.id_key_size,
112 int fld_info_init(struct fld_info *fld_info)
114 struct file *fld_file;
118 fld_file = filp_open("/dev/null", O_RDWR, S_IRWXU);
119 /* sanity and security checks... */
120 OBD_ALLOC(fld_info->fi_container, sizeof(struct iam_container));
121 if (!fld_info->fi_container)
124 rc = iam_container_init(fld_info->fi_container, &fld_param,
125 fld_file->f_dentry->d_inode);
129 void fld_info_fini(struct fld_info *fld_info)
131 iam_container_fini(fld_info->fi_container);
132 OBD_FREE(fld_info->fi_container, sizeof(struct iam_container));
133 OBD_FREE_PTR(fld_info);