Whamcloud - gitweb
LU-8648 all: remove all Sun license and URL references
[fs/lustre-release.git] / lustre / obdclass / linux / linux-obdo.c
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  * Lustre is a trademark of Sun Microsystems, Inc.
31  *
32  * lustre/obdclass/linux/linux-obdo.c
33  *
34  * Object Devices Class Driver
35  * These are the only exported functions, they provide some generic
36  * infrastructure for managing object devices
37  */
38
39 #define DEBUG_SUBSYSTEM S_CLASS
40
41 #include <linux/fs.h>
42 #include <linux/module.h>
43 #include <linux/pagemap.h> /* for PAGE_SIZE */
44 #include <lustre/lustre_idl.h>
45 #include <obd_class.h>
46
47 /*FIXME: Just copy from obdo_from_inode*/
48 void obdo_from_la(struct obdo *dst, const struct lu_attr *la, u64 valid)
49 {
50         u64 newvalid = 0;
51
52         if (valid & LA_ATIME) {
53                 dst->o_atime = la->la_atime;
54                 newvalid |= OBD_MD_FLATIME;
55         }
56         if (valid & LA_MTIME) {
57                 dst->o_mtime = la->la_mtime;
58                 newvalid |= OBD_MD_FLMTIME;
59         }
60         if (valid & LA_CTIME) {
61                 dst->o_ctime = la->la_ctime;
62                 newvalid |= OBD_MD_FLCTIME;
63         }
64         if (valid & LA_SIZE) {
65                 dst->o_size = la->la_size;
66                 newvalid |= OBD_MD_FLSIZE;
67         }
68         if (valid & LA_BLOCKS) {  /* allocation of space (x512 bytes) */
69                 dst->o_blocks = la->la_blocks;
70                 newvalid |= OBD_MD_FLBLOCKS;
71         }
72         if (valid & LA_TYPE) {
73                 dst->o_mode = (dst->o_mode & S_IALLUGO) |
74                               (la->la_mode & S_IFMT);
75                 newvalid |= OBD_MD_FLTYPE;
76         }
77         if (valid & LA_MODE) {
78                 dst->o_mode = (dst->o_mode & S_IFMT) |
79                               (la->la_mode & S_IALLUGO);
80                 newvalid |= OBD_MD_FLMODE;
81         }
82         if (valid & LA_UID) {
83                 dst->o_uid = la->la_uid;
84                 newvalid |= OBD_MD_FLUID;
85         }
86         if (valid & LA_GID) {
87                 dst->o_gid = la->la_gid;
88                 newvalid |= OBD_MD_FLGID;
89         }
90         if (valid & LA_FLAGS) {
91                 dst->o_flags = la->la_flags;
92                 newvalid |= OBD_MD_FLFLAGS;
93         }
94         dst->o_valid |= newvalid;
95 }
96 EXPORT_SYMBOL(obdo_from_la);
97
98 /*FIXME: Just copy from obdo_from_inode*/
99 void la_from_obdo(struct lu_attr *dst, const struct obdo *obdo, u64 valid)
100 {
101         u64 newvalid = 0;
102
103         valid &= obdo->o_valid;
104
105         if (valid & OBD_MD_FLATIME) {
106                 dst->la_atime = obdo->o_atime;
107                 newvalid |= LA_ATIME;
108         }
109         if (valid & OBD_MD_FLMTIME) {
110                 dst->la_mtime = obdo->o_mtime;
111                 newvalid |= LA_MTIME;
112         }
113         if (valid & OBD_MD_FLCTIME) {
114                 dst->la_ctime = obdo->o_ctime;
115                 newvalid |= LA_CTIME;
116         }
117         if (valid & OBD_MD_FLSIZE) {
118                 dst->la_size = obdo->o_size;
119                 newvalid |= LA_SIZE;
120         }
121         if (valid & OBD_MD_FLBLOCKS) {
122                 dst->la_blocks = obdo->o_blocks;
123                 newvalid |= LA_BLOCKS;
124         }
125         if (valid & OBD_MD_FLTYPE) {
126                 dst->la_mode = (dst->la_mode & S_IALLUGO) |
127                                (obdo->o_mode & S_IFMT);
128                 newvalid |= LA_TYPE;
129         }
130         if (valid & OBD_MD_FLMODE) {
131                 dst->la_mode = (dst->la_mode & S_IFMT) |
132                                (obdo->o_mode & S_IALLUGO);
133                 newvalid |= LA_MODE;
134         }
135         if (valid & OBD_MD_FLUID) {
136                 dst->la_uid = obdo->o_uid;
137                 newvalid |= LA_UID;
138         }
139         if (valid & OBD_MD_FLGID) {
140                 dst->la_gid = obdo->o_gid;
141                 newvalid |= LA_GID;
142         }
143         if (valid & OBD_MD_FLFLAGS) {
144                 dst->la_flags = obdo->o_flags;
145                 newvalid |= LA_FLAGS;
146         }
147         dst->la_valid = newvalid;
148 }
149 EXPORT_SYMBOL(la_from_obdo);