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) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2011, 2016, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
32 * Implementation of cl_page for LOV layer.
34 * Author: Nikita Danilov <nikita.danilov@sun.com>
35 * Author: Jinshan Xiong <jinshan.xiong@intel.com>
38 #define DEBUG_SUBSYSTEM S_LOV
40 #include "lov_cl_internal.h"
46 /*****************************************************************************
48 * Lov page operations.
52 static int lov_raid0_page_print(const struct lu_env *env,
53 const struct cl_page_slice *slice,
54 void *cookie, lu_printer_t printer)
56 struct lov_page *lp = cl2lov_page(slice);
58 return (*printer)(env, cookie, LUSTRE_LOV_NAME"-page@%p, raid0\n", lp);
61 static const struct cl_page_operations lov_raid0_page_ops = {
62 .cpo_print = lov_raid0_page_print
65 int lov_page_init_raid0(const struct lu_env *env, struct cl_object *obj,
66 struct cl_page *page, pgoff_t index)
68 struct lov_object *loo = cl2lov(obj);
69 struct lov_layout_raid0 *r0 = lov_r0(loo);
70 struct lov_io *lio = lov_env_io(env);
71 struct cl_object *subobj;
73 struct lov_io_sub *sub;
74 struct lov_page *lpg = cl_object_page_slice(obj, page);
81 offset = cl_offset(obj, index);
82 stripe = lov_stripe_number(loo->lo_lsm, offset);
83 LASSERT(stripe < r0->lo_nr);
84 rc = lov_stripe_offset(loo->lo_lsm, offset, stripe,
88 lpg->lps_stripe = stripe;
89 cl_page_slice_add(page, &lpg->lps_cl, obj, index, &lov_raid0_page_ops);
91 sub = lov_sub_get(env, lio, stripe);
95 subobj = lovsub2cl(r0->lo_sub[stripe]);
96 list_for_each_entry(o, &subobj->co_lu.lo_header->loh_layers,
98 if (o->co_ops->coo_page_init != NULL) {
99 rc = o->co_ops->coo_page_init(sub->sub_env, o, page,
100 cl_index(subobj, suboff));
109 static int lov_empty_page_print(const struct lu_env *env,
110 const struct cl_page_slice *slice,
111 void *cookie, lu_printer_t printer)
113 struct lov_page *lp = cl2lov_page(slice);
115 return (*printer)(env, cookie, LUSTRE_LOV_NAME"-page@%p, empty.\n", lp);
118 static const struct cl_page_operations lov_empty_page_ops = {
119 .cpo_print = lov_empty_page_print
122 int lov_page_init_empty(const struct lu_env *env, struct cl_object *obj,
123 struct cl_page *page, pgoff_t index)
125 struct lov_page *lpg = cl_object_page_slice(obj, page);
129 cl_page_slice_add(page, &lpg->lps_cl, obj, index, &lov_empty_page_ops);
130 addr = kmap(page->cp_vmpage);
131 memset(addr, 0, cl_page_size(obj));
132 kunmap(page->cp_vmpage);
133 cl_page_export(env, page, 1);