4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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
23 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2012, 2017, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
31 * lustre/obdclass/linux/linux-obdo.c
33 * Object Devices Class Driver
34 * These are the only exported functions, they provide some generic
35 * infrastructure for managing object devices
38 #define DEBUG_SUBSYSTEM S_CLASS
41 #include <linux/module.h>
42 #include <linux/pagemap.h> /* for PAGE_SIZE */
43 #include <obd_class.h>
45 /*FIXME: Just copy from obdo_from_inode*/
46 void obdo_from_la(struct obdo *dst, const struct lu_attr *la, u64 valid)
50 if (valid & LA_ATIME) {
51 dst->o_atime = la->la_atime;
52 newvalid |= OBD_MD_FLATIME;
54 if (valid & LA_MTIME) {
55 dst->o_mtime = la->la_mtime;
56 newvalid |= OBD_MD_FLMTIME;
58 if (valid & LA_CTIME) {
59 dst->o_ctime = la->la_ctime;
60 newvalid |= OBD_MD_FLCTIME;
62 if (valid & LA_SIZE) {
63 dst->o_size = la->la_size;
64 newvalid |= OBD_MD_FLSIZE;
66 if (valid & LA_BLOCKS) { /* allocation of space (x512 bytes) */
67 dst->o_blocks = la->la_blocks;
68 newvalid |= OBD_MD_FLBLOCKS;
70 if (valid & LA_TYPE) {
71 dst->o_mode = (dst->o_mode & S_IALLUGO) |
72 (la->la_mode & S_IFMT);
73 newvalid |= OBD_MD_FLTYPE;
75 if (valid & LA_MODE) {
76 dst->o_mode = (dst->o_mode & S_IFMT) |
77 (la->la_mode & S_IALLUGO);
78 newvalid |= OBD_MD_FLMODE;
81 dst->o_uid = la->la_uid;
82 newvalid |= OBD_MD_FLUID;
85 dst->o_gid = la->la_gid;
86 newvalid |= OBD_MD_FLGID;
88 if (valid & LA_PROJID) {
89 dst->o_projid = la->la_projid;
90 newvalid |= OBD_MD_FLPROJID;
92 if (valid & LA_FLAGS) {
93 dst->o_flags = la->la_flags;
94 newvalid |= OBD_MD_FLFLAGS;
96 if (valid & LA_NLINK) {
97 dst->o_nlink = la->la_nlink;
98 newvalid |= OBD_MD_FLNLINK;
100 dst->o_valid |= newvalid;
102 EXPORT_SYMBOL(obdo_from_la);
104 /*FIXME: Just copy from obdo_from_inode*/
105 void la_from_obdo(struct lu_attr *dst, const struct obdo *obdo, u64 valid)
109 valid &= obdo->o_valid;
111 if (valid & OBD_MD_FLATIME) {
112 dst->la_atime = obdo->o_atime;
113 newvalid |= LA_ATIME;
115 if (valid & OBD_MD_FLMTIME) {
116 dst->la_mtime = obdo->o_mtime;
117 newvalid |= LA_MTIME;
119 if (valid & OBD_MD_FLCTIME) {
120 dst->la_ctime = obdo->o_ctime;
121 newvalid |= LA_CTIME;
123 if (valid & OBD_MD_FLSIZE) {
124 dst->la_size = obdo->o_size;
127 if (valid & OBD_MD_FLBLOCKS) {
128 dst->la_blocks = obdo->o_blocks;
129 newvalid |= LA_BLOCKS;
131 if (valid & OBD_MD_FLTYPE) {
132 dst->la_mode = (dst->la_mode & S_IALLUGO) |
133 (obdo->o_mode & S_IFMT);
136 if (valid & OBD_MD_FLMODE) {
137 dst->la_mode = (dst->la_mode & S_IFMT) |
138 (obdo->o_mode & S_IALLUGO);
141 if (valid & OBD_MD_FLUID) {
142 dst->la_uid = obdo->o_uid;
145 if (valid & OBD_MD_FLGID) {
146 dst->la_gid = obdo->o_gid;
149 if (valid & OBD_MD_FLPROJID) {
150 dst->la_projid = obdo->o_projid;
151 newvalid |= LA_PROJID;
153 if (valid & OBD_MD_FLFLAGS) {
154 dst->la_flags = obdo->o_flags;
155 newvalid |= LA_FLAGS;
157 if (valid & OBD_MD_FLNLINK) {
158 dst->la_nlink = obdo->o_nlink;
159 newvalid |= LA_NLINK;
161 dst->la_valid = newvalid;
163 EXPORT_SYMBOL(la_from_obdo);