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 #define OAP_FROM_COOKIE(c) \
75 (LASSERT(((struct osc_async_page *)(c))->oap_magic == OAP_MAGIC), \
76 (struct osc_async_page *)(c))
78 struct osc_cache_waiter {
79 struct list_head ocw_entry;
80 cfs_waitq_t ocw_waitq;
81 struct osc_async_page *ocw_oap;
85 #define OSCC_FLAG_RECOVERING 0x01
86 #define OSCC_FLAG_CREATING 0x02
87 #define OSCC_FLAG_NOSPC 0x04 /* can't create more objects on OST */
88 #define OSCC_FLAG_SYNC_IN_PROGRESS 0x08 /* only allow one thread to sync */
89 #define OSCC_FLAG_LOW 0x10
90 #define OSCC_FLAG_EXITING 0x20
92 int osc_precreate(struct obd_export *exp);
93 int osc_create(struct obd_export *exp, struct obdo *oa,
94 struct lov_stripe_md **ea, struct obd_trans_info *oti);
95 int osc_create_async(struct obd_export *exp, struct obd_info *oinfo,
96 struct lov_stripe_md **ea, struct obd_trans_info *oti);
97 int osc_real_create(struct obd_export *exp, struct obdo *oa,
98 struct lov_stripe_md **ea, struct obd_trans_info *oti);
99 void oscc_init(struct obd_device *obd);
100 void osc_wake_cache_waiters(struct client_obd *cli);
101 int osc_shrink_grant_to_target(struct client_obd *cli, long target);
104 int lproc_osc_attach_seqstat(struct obd_device *dev);
105 void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars);
107 static inline int lproc_osc_attach_seqstat(struct obd_device *dev) {return 0;}
108 static inline void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars)
110 memset(lvars, 0, sizeof(*lvars));
115 #define min_t(type,x,y) \
116 ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
119 static inline int osc_recoverable_error(int rc)
121 return (rc == -EIO || rc == -EROFS || rc == -ENOMEM || rc == -EAGAIN);
124 /* return 1 if osc should be resend request */
125 static inline int osc_should_resend(int resend, struct client_obd *cli)
127 return atomic_read(&cli->cl_resends) ?
128 atomic_read(&cli->cl_resends) > resend : 1;
131 static inline int osc_exp_is_2_0_server(struct obd_export *exp) {
133 return !!(exp->exp_connect_flags & OBD_CONNECT_FID);
136 #define OSC_FILE2MEM_OFF(fileoff,pshift) ((fileoff) + (pshift))
137 #endif /* OSC_INTERNAL_H */