1 // SPDX-License-Identifier: GPL-2.0
4 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
5 * Use is subject to license terms.
7 * Copyright (c) 2013, 2015, Intel Corporation.
11 * This file is part of Lustre, http://www.lustre.org/
13 * Implementation of cl_device and cl_device_type for LOVSUB layer.
15 * Author: Nikita Danilov <nikita.danilov@sun.com>
18 #define DEBUG_SUBSYSTEM S_LOV
20 #include "lov_cl_internal.h"
27 * Lov-sub device and device type functions.
29 static int lovsub_device_init(const struct lu_env *env, struct lu_device *d,
30 const char *name, struct lu_device *next)
32 struct lovsub_device *lsd = lu2lovsub_dev(d);
33 struct lu_device_type *ldt;
37 next->ld_site = d->ld_site;
40 rc = ldto_device_init(env, next, ldt->ldt_name, NULL);
47 lsd->acid_next = lu2cl_dev(next);
51 static struct lu_device *lovsub_device_fini(const struct lu_env *env,
54 struct lu_device *next;
55 struct lovsub_device *lsd;
58 lsd = lu2lovsub_dev(d);
59 next = cl2lu_dev(lsd->acid_next);
60 lsd->acid_next = NULL;
64 static struct lu_device *lovsub_device_free(const struct lu_env *env,
67 struct lovsub_device *lsd = lu2lovsub_dev(d);
68 struct lu_device *next = cl2lu_dev(lsd->acid_next);
70 lu_site_print(env, d->ld_site, &d->ld_ref, D_ERROR, lu_cdebug_printer);
71 cl_device_fini(lu2cl_dev(d));
76 static const struct lu_device_operations lovsub_lu_ops = {
77 .ldo_object_alloc = lovsub_object_alloc,
78 .ldo_process_config = NULL,
79 .ldo_recovery_complete = NULL
82 static struct lu_device *lovsub_device_alloc(const struct lu_env *env,
83 struct lu_device_type *t,
84 struct lustre_cfg *cfg)
87 struct lovsub_device *lsd;
93 result = cl_device_init(&lsd->acid_cl, t);
95 d = lovsub2lu_dev(lsd);
96 d->ld_ops = &lovsub_lu_ops;
100 d = ERR_PTR(-ENOMEM);
104 static const struct lu_device_type_operations lovsub_device_type_ops = {
105 .ldto_device_alloc = lovsub_device_alloc,
106 .ldto_device_free = lovsub_device_free,
108 .ldto_device_init = lovsub_device_init,
109 .ldto_device_fini = lovsub_device_fini
112 #define LUSTRE_LOVSUB_NAME "lovsub"
114 struct lu_device_type lovsub_device_type = {
115 .ldt_tags = LU_DEVICE_CL,
116 .ldt_name = LUSTRE_LOVSUB_NAME,
117 .ldt_ops = &lovsub_device_type_ops,
118 .ldt_ctx_tags = LCT_CL_THREAD