Whamcloud - gitweb
LU-7991 quota: project quota against ZFS backend
[fs/lustre-release.git] / lustre / include / uapi / linux / lustre / 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 /*
42  * This is due to us being out of kernel and the way the OpenSFS branch
43  * handles CFLAGS.
44  */
45 #ifdef __KERNEL__
46 #include <uapi/linux/lustre/lustre_fid.h>
47 #else
48 #include <linux/lustre/lustre_fid.h>
49 #endif
50
51 /*  Lustre logs use FIDs constructed from oi_id and oi_seq directly,
52  *  without attempting to use the IGIF and IDIF ranges as is done
53  *  elsewhere, because of compatibility concerns (see lu-2888).
54  */
55
56 static inline void logid_to_fid(struct llog_logid *id, struct lu_fid *fid)
57 {
58         /* For compatibility purposes we identify pre-OSD (~< 2.3.51 MDS)
59          * logid's by non-zero ogen (inode generation) and convert them
60          * into IGIF */
61         if (id->lgl_ogen == 0) {
62                 fid->f_seq = id->lgl_oi.oi.oi_seq;
63                 fid->f_oid = id->lgl_oi.oi.oi_id;
64                 fid->f_ver = 0;
65         } else {
66                 lu_igif_build(fid, id->lgl_oi.oi.oi_id, id->lgl_ogen);
67         }
68 }
69
70 static inline void fid_to_logid(struct lu_fid *fid, struct llog_logid *id)
71 {
72         id->lgl_oi.oi.oi_seq = fid->f_seq;
73         id->lgl_oi.oi.oi_id = fid->f_oid;
74         id->lgl_ogen = 0;
75 }
76
77 static inline void logid_set_id(struct llog_logid *log_id, __u64 id)
78 {
79         log_id->lgl_oi.oi.oi_id = id;
80 }
81
82 static inline __u64 logid_id(struct llog_logid *log_id)
83 {
84         return log_id->lgl_oi.oi.oi_id;
85 }
86
87 #endif /* ifndef _LUSTRE_LOG_USER_H */