Whamcloud - gitweb
0d4d62f75f66fdac974e2005cc344c3b7132be06
[fs/lustre-release.git] / lustre / fld / fld_iam.c
1 /* -*- MODE: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  fld/fld.c
5  *
6  *  Copyright (C) 2006 Cluster File Systems, Inc.
7  *   Author: WangDi <wangdi@clusterfs.com>
8  *
9  *   This file is part of the Lustre file system, http://www.lustre.org
10  *   Lustre is a trademark of Cluster File Systems, Inc.
11  *
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.
16  *
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.
21  *
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.
26  */
27 #ifndef EXPORT_SYMTAB
28 # define EXPORT_SYMTAB
29 #endif
30 #define DEBUG_SUBSYSTEM S_LLITE
31
32 #include <linux/module.h>
33 #include <linux/jbd.h>
34
35 #include <obd.h>
36 #include <obd_class.h>
37 #include <lustre_ver.h>
38 #include <obd_support.h>
39 #include <lprocfs_status.h>
40
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"
47
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 */
53         .id_root_gap = 0,
54
55 #if 0
56         .id_root_ptr   = iam_root_ptr, /* returns 0: root is always at the
57                                         * beginning of the file (as it
58                                         * htree) */
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,
63 #endif
64 };
65
66 int fld_handle_insert(const struct lu_context *ctx, struct fld *fld,
67                       fidseq_t seq_num, mdsno_t mdsno)
68 {
69         /*
70          * XXX Use ->dio_index_insert() from struct dt_index_operations. The
71          * same below.
72          */
73 #if 0
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);
78 #else
79         return 0;
80 #endif
81 }
82
83 int fld_handle_delete(const struct lu_context *ctx, struct fld *fld,
84                       fidseq_t seq_num, mdsno_t mds_num)
85 {
86 #if 0
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);
91 #else
92         return 0;
93 #endif
94 }
95
96 int fld_handle_lookup(const struct lu_context *ctx,
97                       struct fld *fld, fidseq_t seq_num, mdsno_t *mds_num)
98 {
99 #if 0
100         int size;
101
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,
106                                                   mds_num, &size);
107 #else
108         return 0;
109 #endif
110 }
111
112 int fld_info_init(struct fld_info *fld_info)
113 {
114         struct file *fld_file;
115         int rc;
116         ENTRY;
117
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)
122                 RETURN(-ENOMEM);
123
124         rc = iam_container_init(fld_info->fi_container, &fld_param,
125                                 fld_file->f_dentry->d_inode);
126         RETURN(rc);
127 }
128
129 void fld_info_fini(struct fld_info *fld_info)
130 {
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);
134 }