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_ha.h>
25 /* careful, this is easy to screw up */
26 #define PAGE_CACHE_MAXBYTES ((__u64)(~0UL) << CFS_PAGE_SHIFT)
30 #define LLAP_FROM_COOKIE(c) \
31 (LASSERT(((struct ll_async_page *)(c))->llap_magic == LLAP_MAGIC), \
32 (struct ll_async_page *)(c))
34 #define LL_MAX_BLKSIZE (4UL * 1024 * 1024)
36 #include <lustre/lustre_user.h>
39 struct lustre_rw_params {
41 ldlm_policy_data_t lrp_policy;
42 obd_flag lrp_brw_flags;
47 * XXX nikita: this function lives in the header because it is used by both
48 * llite kernel module and liblustre library, and there is no (?) better place
51 static inline void lustre_build_lock_params(int cmd, unsigned long open_flags,
53 loff_t pos, ssize_t len,
54 struct lustre_rw_params *params)
56 params->lrp_lock_mode = (cmd == OBD_BRW_READ) ? LCK_PR : LCK_PW;
57 params->lrp_brw_flags = 0;
59 params->lrp_policy.l_extent.start = pos;
60 params->lrp_policy.l_extent.end = pos + len - 1;
62 * for now O_APPEND always takes local locks.
64 if (cmd == OBD_BRW_WRITE && (open_flags & O_APPEND)) {
65 params->lrp_policy.l_extent.start = 0;
66 params->lrp_policy.l_extent.end = OBD_OBJECT_EOF;
67 } else if (LIBLUSTRE_CLIENT && (connect_flags & OBD_CONNECT_SRVLOCK)) {
69 * liblustre: OST-side locking for all non-O_APPEND
72 params->lrp_lock_mode = LCK_NL;
73 params->lrp_brw_flags = OBD_BRW_SRVLOCK;
76 * nothing special for the kernel. In the future llite may use
77 * OST-side locks for small writes into highly contended
81 params->lrp_ast_flags = (open_flags & O_NONBLOCK) ?
82 LDLM_FL_BLOCK_NOWAIT : 0;
86 * This is embedded into liblustre and llite super-blocks to keep track of
87 * connect flags (capabilities) supported by all imports given mount is
90 struct lustre_client_ocd {
92 * This is conjunction of connect_flags across all imports (LOVs) this
93 * mount is connected to. This field is updated by ll_ocd_update()
101 * This function is used as an upcall-callback hooked by liblustre and llite
102 * clients into obd_notify() listeners chain to handle notifications about
103 * change of import connect_flags. See llu_fsswop_mount() and
104 * lustre_common_fill_super().
106 * Again, it is dumped into this header for the lack of a better place.
108 static inline int ll_ocd_update(struct obd_device *host,
109 struct obd_device *watched,
110 enum obd_notify_event ev, void *owner)
112 struct lustre_client_ocd *lco;
113 struct client_obd *cli;
118 if (!strcmp(watched->obd_type->typ_name, LUSTRE_OSC_NAME)) {
119 cli = &watched->u.cli;
121 flags = cli->cl_import->imp_connect_data.ocd_connect_flags;
122 CDEBUG(D_SUPER, "Changing connect_flags: "LPX64" -> "LPX64"\n",
123 lco->lco_flags, flags);
124 spin_lock(&lco->lco_lock);
125 lco->lco_flags &= flags;
126 spin_unlock(&lco->lco_lock);
129 CERROR("unexpected notification from %s %s!\n",
130 watched->obd_type->typ_name,