Whamcloud - gitweb
b=16150
[fs/lustre-release.git] / lustre / osc / osc_internal.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 only,
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License version 2 for more details (a copy is included
16  * in the LICENSE file that accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License
19  * version 2 along with this program; If not, see
20  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
21  *
22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23  * CA 95054 USA or visit www.sun.com if you need additional information or
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
30  * Use is subject to license terms.
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 OSC_INTERNAL_H
38 #define OSC_INTERNAL_H
39
40 #define OAP_MAGIC 8675309
41
42 struct osc_async_page {
43         int                     oap_magic;
44         unsigned short          oap_cmd;
45         unsigned short          oap_interrupted:1;
46
47         struct list_head        oap_pending_item;
48         struct list_head        oap_urgent_item;
49         struct list_head        oap_rpc_item;
50
51         obd_off                 oap_obj_off;
52         unsigned                oap_page_off;
53         enum async_flags        oap_async_flags;
54
55         struct brw_page         oap_brw_page;
56
57         struct oig_callback_context oap_occ;
58         struct obd_io_group     *oap_oig;
59         struct ptlrpc_request   *oap_request;
60         struct client_obd       *oap_cli;
61         struct lov_oinfo        *oap_loi;
62
63         struct obd_async_page_ops *oap_caller_ops;
64         void                    *oap_caller_data;
65         struct list_head         oap_page_list;
66         struct ldlm_lock        *oap_ldlm_lock;
67         spinlock_t               oap_lock;
68 };
69
70 #define oap_page        oap_brw_page.pg
71 #define oap_count       oap_brw_page.count
72 #define oap_brw_flags   oap_brw_page.flag
73
74 struct osc_cache_waiter {
75         struct list_head        ocw_entry;
76         cfs_waitq_t             ocw_waitq;
77         struct osc_async_page   *ocw_oap;
78         int                     ocw_rc;
79 };
80
81 #define OSCC_FLAG_RECOVERING         0x01
82 #define OSCC_FLAG_CREATING           0x02
83 #define OSCC_FLAG_NOSPC              0x04 /* can't create more objects on OST */
84 #define OSCC_FLAG_SYNC_IN_PROGRESS   0x08 /* only allow one thread to sync */
85 #define OSCC_FLAG_LOW                0x10
86 #define OSCC_FLAG_EXITING            0x20
87
88 int osc_precreate(struct obd_export *exp);
89 int osc_create(struct obd_export *exp, struct obdo *oa,
90                struct lov_stripe_md **ea, struct obd_trans_info *oti);
91 int osc_real_create(struct obd_export *exp, struct obdo *oa,
92                struct lov_stripe_md **ea, struct obd_trans_info *oti);
93 void oscc_init(struct obd_device *obd);
94 void osc_wake_cache_waiters(struct client_obd *cli);
95
96 #ifdef LPROCFS
97 int lproc_osc_attach_seqstat(struct obd_device *dev);
98 void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars);
99 #else
100 static inline int lproc_osc_attach_seqstat(struct obd_device *dev) {return 0;}
101 static inline void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars)
102 {
103         memset(lvars, 0, sizeof(*lvars));
104 }
105 #endif
106
107 static inline int osc_recoverable_error(int rc)
108 {
109         return (rc == -EIO || rc == -EROFS || rc == -ENOMEM || rc == -EAGAIN);
110 }
111
112 /* return 1 if osc should be resend request */
113 static inline int osc_should_resend(int resend, struct client_obd *cli)
114 {
115         return atomic_read(&cli->cl_resends) ? 
116                atomic_read(&cli->cl_resends) > resend : 1; 
117 }
118
119 #ifndef min_t
120 #define min_t(type,x,y) \
121         ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
122 #endif
123
124 #endif /* OSC_INTERNAL_H */