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.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
31 * This file is part of Lustre, http://www.lustre.org/
32 * Lustre is a trademark of Sun Microsystems, Inc.
34 * cl_object implementation for VVP layer.
36 * Author: Nikita Danilov <nikita.danilov@sun.com>
39 #define DEBUG_SUBSYSTEM S_LLITE
42 # error This file is kernel only.
45 #include <libcfs/libcfs.h>
48 #include <lustre_lite.h>
50 #include "vvp_internal.h"
52 /*****************************************************************************
58 static int vvp_object_print(const struct lu_env *env, void *cookie,
59 lu_printer_t p, const struct lu_object *o)
61 struct ccc_object *obj = lu2ccc(o);
62 struct inode *inode = obj->cob_inode;
63 struct ll_inode_info *lli;
65 (*p)(env, cookie, "(%s %d %d) inode: %p ",
66 cfs_list_empty(&obj->cob_pending_list) ? "-" : "+",
67 obj->cob_transient_pages, cfs_atomic_read(&obj->cob_mmap_cnt),
70 lli = ll_i2info(inode);
71 (*p)(env, cookie, "%lu/%u %o %u %d %p "DFID,
72 inode->i_ino, inode->i_generation, inode->i_mode,
73 inode->i_nlink, atomic_read(&inode->i_count),
74 lli->lli_clob, PFID(&lli->lli_fid));
79 static int vvp_attr_get(const struct lu_env *env, struct cl_object *obj,
82 struct inode *inode = ccc_object_inode(obj);
85 * lov overwrites most of these fields in
86 * lov_attr_get()->...lov_merge_lvb_kms(), except when inode
87 * attributes are newer.
90 attr->cat_size = i_size_read(inode);
91 attr->cat_mtime = LTIME_S(inode->i_mtime);
92 attr->cat_atime = LTIME_S(inode->i_atime);
93 attr->cat_ctime = LTIME_S(inode->i_ctime);
94 attr->cat_blocks = inode->i_blocks;
95 attr->cat_uid = inode->i_uid;
96 attr->cat_gid = inode->i_gid;
97 /* KMS is not known by this layer */
98 return 0; /* layers below have to fill in the rest */
101 static int vvp_attr_set(const struct lu_env *env, struct cl_object *obj,
102 const struct cl_attr *attr, unsigned valid)
104 struct inode *inode = ccc_object_inode(obj);
107 inode->i_uid = attr->cat_uid;
109 inode->i_gid = attr->cat_gid;
110 if (valid & CAT_ATIME)
111 LTIME_S(inode->i_atime) = attr->cat_atime;
112 if (valid & CAT_MTIME)
113 LTIME_S(inode->i_mtime) = attr->cat_mtime;
114 if (valid & CAT_CTIME)
115 LTIME_S(inode->i_ctime) = attr->cat_ctime;
116 if (0 && valid & CAT_SIZE)
117 cl_isize_write_nolock(inode, attr->cat_size);
118 /* not currently necessary */
119 if (0 && valid & (CAT_UID|CAT_GID|CAT_SIZE))
120 mark_inode_dirty(inode);
124 static const struct cl_object_operations vvp_ops = {
125 .coo_page_init = vvp_page_init,
126 .coo_lock_init = vvp_lock_init,
127 .coo_io_init = vvp_io_init,
128 .coo_attr_get = vvp_attr_get,
129 .coo_attr_set = vvp_attr_set,
130 .coo_conf_set = ccc_conf_set,
131 .coo_glimpse = ccc_object_glimpse
134 static const struct lu_object_operations vvp_lu_obj_ops = {
135 .loo_object_init = ccc_object_init,
136 .loo_object_free = ccc_object_free,
137 .loo_object_print = vvp_object_print
140 struct ccc_object *cl_inode2ccc(struct inode *inode)
142 struct cl_inode_info *lli = cl_i2info(inode);
143 struct cl_object *obj = lli->lli_clob;
144 struct lu_object *lu;
146 LASSERT(obj != NULL);
147 lu = lu_object_locate(obj->co_lu.lo_header, &vvp_device_type);
152 struct lu_object *vvp_object_alloc(const struct lu_env *env,
153 const struct lu_object_header *hdr,
154 struct lu_device *dev)
156 return ccc_object_alloc(env, hdr, dev, &vvp_ops, &vvp_lu_obj_ops);