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/
30 * Lustre is a trademark of Sun Microsystems, Inc.
32 * lustre/obdclass/linux/linux-obdo.c
34 * Object Devices Class Driver
35 * These are the only exported functions, they provide some generic
36 * infrastructure for managing object devices
39 #define DEBUG_SUBSYSTEM S_CLASS
42 #include <linux/module.h>
43 #include <linux/pagemap.h> /* for PAGE_SIZE */
44 #include <obd_class.h>
46 /*FIXME: Just copy from obdo_from_inode*/
47 void obdo_from_la(struct obdo *dst, const struct lu_attr *la, u64 valid)
51 if (valid & LA_ATIME) {
52 dst->o_atime = la->la_atime;
53 newvalid |= OBD_MD_FLATIME;
55 if (valid & LA_MTIME) {
56 dst->o_mtime = la->la_mtime;
57 newvalid |= OBD_MD_FLMTIME;
59 if (valid & LA_CTIME) {
60 dst->o_ctime = la->la_ctime;
61 newvalid |= OBD_MD_FLCTIME;
63 if (valid & LA_SIZE) {
64 dst->o_size = la->la_size;
65 newvalid |= OBD_MD_FLSIZE;
67 if (valid & LA_BLOCKS) { /* allocation of space (x512 bytes) */
68 dst->o_blocks = la->la_blocks;
69 newvalid |= OBD_MD_FLBLOCKS;
71 if (valid & LA_TYPE) {
72 dst->o_mode = (dst->o_mode & S_IALLUGO) |
73 (la->la_mode & S_IFMT);
74 newvalid |= OBD_MD_FLTYPE;
76 if (valid & LA_MODE) {
77 dst->o_mode = (dst->o_mode & S_IFMT) |
78 (la->la_mode & S_IALLUGO);
79 newvalid |= OBD_MD_FLMODE;
82 dst->o_uid = la->la_uid;
83 newvalid |= OBD_MD_FLUID;
86 dst->o_gid = la->la_gid;
87 newvalid |= OBD_MD_FLGID;
89 if (valid & LA_PROJID) {
90 dst->o_projid = la->la_projid;
91 newvalid |= OBD_MD_FLPROJID;
93 if (valid & LA_FLAGS) {
94 dst->o_flags = la->la_flags;
95 newvalid |= OBD_MD_FLFLAGS;
97 dst->o_valid |= newvalid;
99 EXPORT_SYMBOL(obdo_from_la);
101 /*FIXME: Just copy from obdo_from_inode*/
102 void la_from_obdo(struct lu_attr *dst, const struct obdo *obdo, u64 valid)
106 valid &= obdo->o_valid;
108 if (valid & OBD_MD_FLATIME) {
109 dst->la_atime = obdo->o_atime;
110 newvalid |= LA_ATIME;
112 if (valid & OBD_MD_FLMTIME) {
113 dst->la_mtime = obdo->o_mtime;
114 newvalid |= LA_MTIME;
116 if (valid & OBD_MD_FLCTIME) {
117 dst->la_ctime = obdo->o_ctime;
118 newvalid |= LA_CTIME;
120 if (valid & OBD_MD_FLSIZE) {
121 dst->la_size = obdo->o_size;
124 if (valid & OBD_MD_FLBLOCKS) {
125 dst->la_blocks = obdo->o_blocks;
126 newvalid |= LA_BLOCKS;
128 if (valid & OBD_MD_FLTYPE) {
129 dst->la_mode = (dst->la_mode & S_IALLUGO) |
130 (obdo->o_mode & S_IFMT);
133 if (valid & OBD_MD_FLMODE) {
134 dst->la_mode = (dst->la_mode & S_IFMT) |
135 (obdo->o_mode & S_IALLUGO);
138 if (valid & OBD_MD_FLUID) {
139 dst->la_uid = obdo->o_uid;
142 if (valid & OBD_MD_FLGID) {
143 dst->la_gid = obdo->o_gid;
146 if (valid & OBD_MD_FLPROJID) {
147 dst->la_projid = obdo->o_projid;
148 newvalid |= LA_PROJID;
150 if (valid & OBD_MD_FLFLAGS) {
151 dst->la_flags = obdo->o_flags;
152 newvalid |= LA_FLAGS;
154 dst->la_valid = newvalid;
156 EXPORT_SYMBOL(la_from_obdo);