Whamcloud - gitweb
LU-5092 nodemap: save nodemaps to targets for caching
[fs/lustre-release.git] / lustre / include / lustre_log_user.h
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) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Use is subject to license terms.
25  *
26  * Copyright (c) 2012, 2014, Intel Corporation.
27  */
28 /*
29  * This file is part of Lustre, http://www.lustre.org/
30  *
31  * lustre/include/lustre_log_user.h
32  *
33  * Userspace-usable portion of Generic infrastructure for managing
34  * a collection of logs.
35  * See lustre_log.h for more details.
36  */
37
38 #ifndef _LUSTRE_LOG_USER_H
39 #define _LUSTRE_LOG_USER_H
40
41 /*  Lustre logs use FIDs constructed from oi_id and oi_seq directly,
42  *  without attempting to use the IGIF and IDIF ranges as is done
43  *  elsewhere, because of compatibility concerns (see lu-2888).
44  */
45
46 static inline void logid_to_fid(struct llog_logid *id, struct lu_fid *fid)
47 {
48         /* For compatibility purposes we identify pre-OSD (~< 2.3.51 MDS)
49          * logid's by non-zero ogen (inode generation) and convert them
50          * into IGIF */
51         if (id->lgl_ogen == 0) {
52                 fid->f_seq = id->lgl_oi.oi.oi_seq;
53                 fid->f_oid = id->lgl_oi.oi.oi_id;
54                 fid->f_ver = 0;
55         } else {
56                 lu_igif_build(fid, id->lgl_oi.oi.oi_id, id->lgl_ogen);
57         }
58 }
59
60 static inline void fid_to_logid(struct lu_fid *fid, struct llog_logid *id)
61 {
62         id->lgl_oi.oi.oi_seq = fid->f_seq;
63         id->lgl_oi.oi.oi_id = fid->f_oid;
64         id->lgl_ogen = 0;
65 }
66
67 static inline void logid_set_id(struct llog_logid *log_id, __u64 id)
68 {
69         log_id->lgl_oi.oi.oi_id = id;
70 }
71
72 static inline __u64 logid_id(struct llog_logid *log_id)
73 {
74         return log_id->lgl_oi.oi.oi_id;
75 }
76
77 #endif /* ifndef _LUSTRE_LOG_USER_H */