Whamcloud - gitweb
LU-3409 llite: silence lockdep warning in ll_md_blocking_ast
[fs/lustre-release.git] / lustre / include / lu_target.h
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
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.
9  *
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).
15  *
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
19  *
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
22  * have any questions.
23  *
24  * GPL HEADER END
25  */
26 /*
27  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
28  * Use is subject to license terms.
29  *
30  * Copyright (c) 2011, 2012, Intel Corporation.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  */
36
37 #ifndef _LUSTRE_LU_TARGET_H
38 #define _LUSTRE_LU_TARGET_H
39
40 #include <dt_object.h>
41 #include <lustre_disk.h>
42
43 struct lu_target {
44         struct obd_device       *lut_obd;
45         struct dt_device        *lut_bottom;
46         /** last_rcvd file */
47         struct dt_object        *lut_last_rcvd;
48         /* transaction callbacks */
49         struct dt_txn_callback   lut_txn_cb;
50         /** server data in last_rcvd file */
51         struct lr_server_data    lut_lsd;
52         /** Server last transaction number */
53         __u64                    lut_last_transno;
54         /** Lock protecting last transaction number */
55         spinlock_t               lut_translock;
56         /** Lock protecting client bitmap */
57         spinlock_t               lut_client_bitmap_lock;
58         /** Bitmap of known clients */
59         unsigned long           *lut_client_bitmap;
60 };
61
62 typedef void (*tgt_cb_t)(struct lu_target *lut, __u64 transno,
63                          void *data, int err);
64 struct tgt_commit_cb {
65         tgt_cb_t  tgt_cb_func;
66         void     *tgt_cb_data;
67 };
68
69 void tgt_boot_epoch_update(struct lu_target *lut);
70 int tgt_last_commit_cb_add(struct thandle *th, struct lu_target *lut,
71                            struct obd_export *exp, __u64 transno);
72 int tgt_new_client_cb_add(struct thandle *th, struct obd_export *exp);
73 int tgt_init(const struct lu_env *env, struct lu_target *lut,
74              struct obd_device *obd, struct dt_device *dt);
75 void tgt_fini(const struct lu_env *env, struct lu_target *lut);
76 int tgt_client_alloc(struct obd_export *exp);
77 void tgt_client_free(struct obd_export *exp);
78 int tgt_client_del(const struct lu_env *env, struct obd_export *exp);
79 int tgt_client_add(const struct lu_env *env, struct obd_export *exp, int);
80 int tgt_client_new(const struct lu_env *env, struct obd_export *exp);
81 int tgt_client_data_read(const struct lu_env *env, struct lu_target *tg,
82                          struct lsd_client_data *lcd, loff_t *off, int index);
83 int tgt_client_data_write(const struct lu_env *env, struct lu_target *tg,
84                           struct lsd_client_data *lcd, loff_t *off, struct thandle *th);
85 int tgt_server_data_read(const struct lu_env *env, struct lu_target *tg);
86 int tgt_server_data_write(const struct lu_env *env, struct lu_target *tg,
87                           struct thandle *th);
88 int tgt_server_data_update(const struct lu_env *env, struct lu_target *tg, int sync);
89 int tgt_truncate_last_rcvd(const struct lu_env *env, struct lu_target *tg, loff_t off);
90
91 #endif /* __LUSTRE_LU_TARGET_H */