Whamcloud - gitweb
landing b_cmobd_merge on HEAD
[fs/lustre-release.git] / lustre / include / linux / lustre_cmobd.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  * Data structures for Cache Manager 
22  *
23  */
24
25 #ifndef _LUSTRE_CMOBD_H
26 #define _LUSTRE_CMOBD_H
27
28 #include <linux/obd_class.h>
29
30 #define LUSTRE_CMOBD_NAME       "cmobd"
31
32 #define CMOBD_MAX_THREADS       32UL
33
34 #define CMOBD_NUM_THREADS       max(min_t(unsigned long, num_physpages / 8192, \
35                                           CMOBD_MAX_THREADS), 2UL)
36
37 #define CMOBD_MAX_EXTENT_SZ     PTLRPC_MAX_BRW_PAGES * PAGE_SIZE
38
39 #define CMOBD_MAX_EXTENTS       1024
40
41 /* for keeping the capacity of handle multi extents simultaneously */
42 struct cmobd_extent_set {
43         struct ldlm_extent       es_extent;
44         struct obdo              es_oa; 
45         
46         struct lov_stripe_md    *es_lsm;
47         struct obd_export       *es_exp;
48         
49         /* maximum length of per sub extent */ 
50         unsigned long            es_ext_sz;
51         /* sub extents count */
52         obd_count                es_count;
53         /* pages to be sent */
54         struct list_head         es_pages;        
55         /* protect the es_pages and es_count */
56         spinlock_t               es_lock;
57         
58         wait_queue_head_t        es_waitq;
59 };
60
61 struct cmobd_extent_info {
62         struct list_head         ei_link;
63         struct cmobd_extent_set *ei_set;
64         struct ldlm_extent       ei_extent;
65 };
66
67 struct cmobd_async_page {
68         struct list_head         cmap_link;
69         struct page             *cmap_page;
70         void                    *cmap_cookie;
71         struct cmobd_extent_set *cmap_es;
72 };
73
74 struct cmobd_write_service {
75         struct list_head        ws_threads;
76         int                     ws_nthreads;
77         spinlock_t              ws_thread_lock;
78
79         struct list_head        ws_extents;
80         int                     ws_nextents;
81         spinlock_t              ws_extent_lock;
82         wait_queue_head_t       ws_waitq_provider;      /* extent provider queue */
83         wait_queue_head_t       ws_waitq_consumer;      /* extent consumer queue */
84 };
85
86 #endif /* _LUSTRE_CMOBD_H */