1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
5 * Miscellaneous fid functions.
7 * Copyright (c) 2006 Cluster File Systems, Inc.
8 * Author: Nikita Danilov <nikita@clusterfs.com>
9 * Yury Umanets <umka@clusterfs.com>
11 * This file is part of the Lustre file system, http://www.lustre.org
12 * Lustre is a trademark of Cluster File Systems, Inc.
14 * You may have signed or agreed to another license before downloading
15 * this software. If so, you are bound by the terms and conditions
16 * of that agreement, and the following does not apply to you. See the
17 * LICENSE file included with this distribution for more information.
19 * If you did not agree to a different license, then this copy of Lustre
20 * is open source software; you can redistribute it and/or modify it
21 * under the terms of version 2 of the GNU General Public License as
22 * published by the Free Software Foundation.
24 * In either case, Lustre is distributed in the hope that it will be
25 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
26 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * license text for more details.
31 # define EXPORT_SYMTAB
33 #define DEBUG_SUBSYSTEM S_FID
36 # include <libcfs/libcfs.h>
37 # include <linux/module.h>
38 #else /* __KERNEL__ */
39 # include <liblustre.h>
43 #include <lu_object.h>
44 #include <lustre_fid.h>
47 * Sequence space, starts from 0x100000000ULL to have first 0x100000000ULL
48 * sequences used for special purposes.
49 * Those fids are reserved for special purposes (igifs, etc.).
51 const struct lu_range LUSTRE_SEQ_SPACE_RANGE = {
55 EXPORT_SYMBOL(LUSTRE_SEQ_SPACE_RANGE);
57 /* Zero range, used for init and other purposes. */
58 const struct lu_range LUSTRE_SEQ_ZERO_RANGE = {
62 EXPORT_SYMBOL(LUSTRE_SEQ_ZERO_RANGE);
64 /* Lustre Big Fs Lock fid. */
65 const struct lu_fid LUSTRE_BFL_FID = { .f_seq = 0x0000000000000003,
66 .f_oid = 0x0000000000000001,
67 .f_ver = 0x0000000000000000 };
68 EXPORT_SYMBOL(LUSTRE_BFL_FID);
70 void range_cpu_to_le(struct lu_range *dst, const struct lu_range *src)
72 /* check that all fields are converted */
73 CLASSERT(sizeof *src ==
74 sizeof src->lr_start +
76 dst->lr_start = cpu_to_le64(src->lr_start);
77 dst->lr_end = cpu_to_le64(src->lr_end);
79 EXPORT_SYMBOL(range_cpu_to_le);
81 void range_le_to_cpu(struct lu_range *dst, const struct lu_range *src)
83 /* check that all fields are converted */
84 CLASSERT(sizeof *src ==
85 sizeof src->lr_start +
87 dst->lr_start = le64_to_cpu(src->lr_start);
88 dst->lr_end = le64_to_cpu(src->lr_end);
90 EXPORT_SYMBOL(range_le_to_cpu);
93 void range_cpu_to_be(struct lu_range *dst, const struct lu_range *src)
95 /* check that all fields are converted */
96 CLASSERT(sizeof *src ==
97 sizeof src->lr_start +
99 dst->lr_start = cpu_to_be64(src->lr_start);
100 dst->lr_end = cpu_to_be64(src->lr_end);
102 EXPORT_SYMBOL(range_cpu_to_be);
104 void range_be_to_cpu(struct lu_range *dst, const struct lu_range *src)
106 /* check that all fields are converted */
107 CLASSERT(sizeof *src ==
108 sizeof src->lr_start +
110 dst->lr_start = be64_to_cpu(src->lr_start);
111 dst->lr_end = be64_to_cpu(src->lr_end);
113 EXPORT_SYMBOL(range_be_to_cpu);