Whamcloud - gitweb
LU-6401 headers: move lu_fid, ost_id funcs out of lustre_idl.h
[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 #include <lustre/lustre_fid.h>
42
43 /*  Lustre logs use FIDs constructed from oi_id and oi_seq directly,
44  *  without attempting to use the IGIF and IDIF ranges as is done
45  *  elsewhere, because of compatibility concerns (see lu-2888).
46  */
47
48 static inline void logid_to_fid(struct llog_logid *id, struct lu_fid *fid)
49 {
50         /* For compatibility purposes we identify pre-OSD (~< 2.3.51 MDS)
51          * logid's by non-zero ogen (inode generation) and convert them
52          * into IGIF */
53         if (id->lgl_ogen == 0) {
54                 fid->f_seq = id->lgl_oi.oi.oi_seq;
55                 fid->f_oid = id->lgl_oi.oi.oi_id;
56                 fid->f_ver = 0;
57         } else {
58                 lu_igif_build(fid, id->lgl_oi.oi.oi_id, id->lgl_ogen);
59         }
60 }
61
62 static inline void fid_to_logid(struct lu_fid *fid, struct llog_logid *id)
63 {
64         id->lgl_oi.oi.oi_seq = fid->f_seq;
65         id->lgl_oi.oi.oi_id = fid->f_oid;
66         id->lgl_ogen = 0;
67 }
68
69 static inline void logid_set_id(struct llog_logid *log_id, __u64 id)
70 {
71         log_id->lgl_oi.oi.oi_id = id;
72 }
73
74 static inline __u64 logid_id(struct llog_logid *log_id)
75 {
76         return log_id->lgl_oi.oi.oi_id;
77 }
78
79 #endif /* ifndef _LUSTRE_LOG_USER_H */