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) 2013, 2015, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
31 * Implementation of cl_device and cl_device_type for LOVSUB layer.
33 * Author: Nikita Danilov <nikita.danilov@sun.com>
36 #define DEBUG_SUBSYSTEM S_LOV
38 #include "lov_cl_internal.h"
45 * Lov-sub device and device type functions.
47 static int lovsub_device_init(const struct lu_env *env, struct lu_device *d,
48 const char *name, struct lu_device *next)
50 struct lovsub_device *lsd = lu2lovsub_dev(d);
51 struct lu_device_type *ldt;
55 next->ld_site = d->ld_site;
58 rc = ldt->ldt_ops->ldto_device_init(env, next, ldt->ldt_name, NULL);
65 lsd->acid_next = lu2cl_dev(next);
69 static struct lu_device *lovsub_device_fini(const struct lu_env *env,
72 struct lu_device *next;
73 struct lovsub_device *lsd;
76 lsd = lu2lovsub_dev(d);
77 next = cl2lu_dev(lsd->acid_next);
78 lsd->acid_next = NULL;
82 static struct lu_device *lovsub_device_free(const struct lu_env *env,
85 struct lovsub_device *lsd = lu2lovsub_dev(d);
86 struct lu_device *next = cl2lu_dev(lsd->acid_next);
88 lu_site_print(env, d->ld_site, &d->ld_ref, D_ERROR, lu_cdebug_printer);
89 cl_device_fini(lu2cl_dev(d));
94 static const struct lu_device_operations lovsub_lu_ops = {
95 .ldo_object_alloc = lovsub_object_alloc,
96 .ldo_process_config = NULL,
97 .ldo_recovery_complete = NULL
100 static struct lu_device *lovsub_device_alloc(const struct lu_env *env,
101 struct lu_device_type *t,
102 struct lustre_cfg *cfg)
105 struct lovsub_device *lsd;
111 result = cl_device_init(&lsd->acid_cl, t);
113 d = lovsub2lu_dev(lsd);
114 d->ld_ops = &lovsub_lu_ops;
118 d = ERR_PTR(-ENOMEM);
122 static const struct lu_device_type_operations lovsub_device_type_ops = {
123 .ldto_device_alloc = lovsub_device_alloc,
124 .ldto_device_free = lovsub_device_free,
126 .ldto_device_init = lovsub_device_init,
127 .ldto_device_fini = lovsub_device_fini
130 #define LUSTRE_LOVSUB_NAME "lovsub"
132 struct lu_device_type lovsub_device_type = {
133 .ldt_tags = LU_DEVICE_CL,
134 .ldt_name = LUSTRE_LOVSUB_NAME,
135 .ldt_ops = &lovsub_device_type_ops,
136 .ldt_ctx_tags = LCT_CL_THREAD