1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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
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
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
37 #ifndef OSC_INTERNAL_H
38 #define OSC_INTERNAL_H
40 #define OAP_MAGIC 8675309
42 struct osc_async_page {
44 unsigned short oap_cmd;
45 unsigned short oap_interrupted:1;
47 struct list_head oap_pending_item;
48 struct list_head oap_urgent_item;
49 struct list_head oap_rpc_item;
52 unsigned oap_page_off;
53 enum async_flags oap_async_flags;
55 struct brw_page oap_brw_page;
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;
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;
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
74 struct osc_cache_waiter {
75 struct list_head ocw_entry;
76 cfs_waitq_t ocw_waitq;
77 struct osc_async_page *ocw_oap;
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
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);
97 int lproc_osc_attach_seqstat(struct obd_device *dev);
98 void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars);
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)
103 memset(lvars, 0, sizeof(*lvars));
107 static inline int osc_recoverable_error(int rc)
109 return (rc == -EIO || rc == -EROFS || rc == -ENOMEM || rc == -EAGAIN);
112 /* return 1 if osc should be resend request */
113 static inline int osc_should_resend(int resend, struct client_obd *cli)
115 return atomic_read(&cli->cl_resends) ?
116 atomic_read(&cli->cl_resends) > resend : 1;
120 #define min_t(type,x,y) \
121 ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
124 #endif /* OSC_INTERNAL_H */