1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
9 #include <linux/lustre_lite.h>
10 #elif defined(__APPLE__)
11 #include <darwin/lustre_lite.h>
12 #elif defined(__WINNT__)
13 #include <winnt/lustre_lite.h>
15 #error Unsupported operating system.
18 #include <obd_class.h>
20 #include <lustre_net.h>
21 #include <lustre_mds.h>
22 #include <lustre_ha.h>
26 /* careful, this is easy to screw up */
27 #define PAGE_CACHE_MAXBYTES ((__u64)(~0UL) << CFS_PAGE_SHIFT)
31 #define LLAP_FROM_COOKIE(c) \
32 (LASSERT(((struct ll_async_page *)(c))->llap_magic == LLAP_MAGIC), \
33 (struct ll_async_page *)(c))
35 /* 4UL * 1024 * 1024 */
36 #define LL_MAX_BLKSIZE_BITS (22)
37 #define LL_MAX_BLKSIZE (1UL<<LL_MAX_BLKSIZE_BITS)
39 #include <lustre/lustre_user.h>
42 struct lustre_rw_params {
44 ldlm_policy_data_t lrp_policy;
45 obd_flag lrp_brw_flags;
50 * XXX nikita: this function lives in the header because it is used by both
51 * llite kernel module and liblustre library, and there is no (?) better place
54 static inline void lustre_build_lock_params(int cmd, unsigned long open_flags,
56 loff_t pos, ssize_t len,
57 struct lustre_rw_params *params)
59 params->lrp_lock_mode = (cmd == OBD_BRW_READ) ? LCK_PR : LCK_PW;
60 params->lrp_brw_flags = 0;
62 params->lrp_policy.l_extent.start = pos;
63 params->lrp_policy.l_extent.end = pos + len - 1;
65 * for now O_APPEND always takes local locks.
67 if (cmd == OBD_BRW_WRITE && (open_flags & O_APPEND)) {
68 params->lrp_policy.l_extent.start = 0;
69 params->lrp_policy.l_extent.end = OBD_OBJECT_EOF;
70 } else if (LIBLUSTRE_CLIENT && (connect_flags & OBD_CONNECT_SRVLOCK)) {
72 * liblustre: OST-side locking for all non-O_APPEND
75 params->lrp_lock_mode = LCK_NL;
76 params->lrp_brw_flags = OBD_BRW_SRVLOCK;
79 * nothing special for the kernel. In the future llite may use
80 * OST-side locks for small writes into highly contended
84 params->lrp_ast_flags = (open_flags & O_NONBLOCK) ?
85 LDLM_FL_BLOCK_NOWAIT : 0;
89 * This is embedded into liblustre and llite super-blocks to keep track of
90 * connect flags (capabilities) supported by all imports given mount is
93 struct lustre_client_ocd {
95 * This is conjunction of connect_flags across all imports (LOVs) this
96 * mount is connected to. This field is updated by ll_ocd_update()
104 * This function is used as an upcall-callback hooked by liblustre and llite
105 * clients into obd_notify() listeners chain to handle notifications about
106 * change of import connect_flags. See llu_fsswop_mount() and
107 * lustre_common_fill_super().
109 * Again, it is dumped into this header for the lack of a better place.
111 static inline int ll_ocd_update(struct obd_device *host,
112 struct obd_device *watched,
113 enum obd_notify_event ev, void *owner)
115 struct lustre_client_ocd *lco;
116 struct client_obd *cli;
121 if (!strcmp(watched->obd_type->typ_name, LUSTRE_OSC_NAME)) {
122 cli = &watched->u.cli;
124 flags = cli->cl_import->imp_connect_data.ocd_connect_flags;
125 CDEBUG(D_SUPER, "Changing connect_flags: "LPX64" -> "LPX64"\n",
126 lco->lco_flags, flags);
127 spin_lock(&lco->lco_lock);
128 lco->lco_flags &= flags;
129 spin_unlock(&lco->lco_lock);
132 CERROR("unexpected notification from %s %s!\n",
133 watched->obd_type->typ_name,