Whamcloud - gitweb
Directly associate cached pages to lock that protect those pages,
[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
5 #ifndef OSC_INTERNAL_H
6 #define OSC_INTERNAL_H
7
8 #define OAP_MAGIC 8675309
9
10 struct osc_async_page {
11         int                     oap_magic;
12         unsigned short          oap_cmd;
13         unsigned short          oap_interrupted:1;
14
15         struct list_head        oap_pending_item;
16         struct list_head        oap_urgent_item;
17         struct list_head        oap_rpc_item;
18
19         obd_off                 oap_obj_off;
20         unsigned                oap_page_off;
21         enum async_flags        oap_async_flags;
22
23         struct brw_page         oap_brw_page;
24
25         struct oig_callback_context oap_occ;
26         struct obd_io_group     *oap_oig;
27         struct ptlrpc_request   *oap_request;
28         struct client_obd       *oap_cli;
29         struct lov_oinfo        *oap_loi;
30
31         struct obd_async_page_ops *oap_caller_ops;
32         void                    *oap_caller_data;
33         struct list_head         oap_page_list;
34         struct ldlm_lock        *oap_ldlm_lock;
35         spinlock_t               oap_lock;
36 };
37
38 #define oap_page        oap_brw_page.pg
39 #define oap_count       oap_brw_page.count
40 #define oap_brw_flags   oap_brw_page.flag
41
42 #define OAP_FROM_COOKIE(c)                                                    \
43         (LASSERT(((struct osc_async_page *)(c))->oap_magic == OAP_MAGIC),     \
44          (struct osc_async_page *)(c))
45
46 struct osc_cache_waiter {
47         struct list_head        ocw_entry;
48         cfs_waitq_t             ocw_waitq;
49         struct osc_async_page   *ocw_oap;
50         int                     ocw_rc;
51 };
52
53 #define OSCC_FLAG_RECOVERING         0x01
54 #define OSCC_FLAG_CREATING           0x02
55 #define OSCC_FLAG_NOSPC              0x04 /* can't create more objects on OST */
56 #define OSCC_FLAG_SYNC_IN_PROGRESS   0x08 /* only allow one thread to sync */
57 #define OSCC_FLAG_LOW                0x10
58 #define OSCC_FLAG_EXITING            0x20
59
60 int osc_precreate(struct obd_export *exp);
61 int osc_create(struct obd_export *exp, struct obdo *oa,
62                struct lov_stripe_md **ea, struct obd_trans_info *oti);
63 int osc_real_create(struct obd_export *exp, struct obdo *oa,
64                struct lov_stripe_md **ea, struct obd_trans_info *oti);
65 void oscc_init(struct obd_device *obd);
66 void osc_wake_cache_waiters(struct client_obd *cli);
67
68 #ifdef LPROCFS
69 int lproc_osc_attach_seqstat(struct obd_device *dev);
70 void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars);
71 #else
72 static inline int lproc_osc_attach_seqstat(struct obd_device *dev) {return 0;}
73 static inline void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars)
74 {
75         memset(lvars, 0, sizeof(*lvars));
76 }
77 #endif
78
79 static inline int osc_recoverable_error(int rc)
80 {
81         return (rc == -EIO || rc == -EROFS || rc == -ENOMEM || rc == -EAGAIN);
82 }
83
84 /* return 1 if osc should be resend request */
85 static inline int osc_should_resend(int resend, struct client_obd *cli)
86 {
87         return atomic_read(&cli->cl_resends) ? 
88                atomic_read(&cli->cl_resends) > resend : 1; 
89 }
90
91 #ifndef min_t
92 #define min_t(type,x,y) \
93         ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
94 #endif
95
96 #endif /* OSC_INTERNAL_H */