Whamcloud - gitweb
file llobdstat.pl was initially added on branch b_devel.
[fs/lustre-release.git] / lustre / lib / obd_pack.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  * (Un)packing of OST requests
22  *
23  */
24
25 #define DEBUG_SUBSYSTEM S_OST
26 #ifndef __KERNEL__
27 #include <liblustre.h>
28 #endif
29
30 #include <linux/obd_ost.h>
31 #include <linux/lustre_net.h>
32
33 void ost_pack_ioo(struct obd_ioobj *ioo, struct lov_stripe_md *lsm, int bufcnt)
34 {
35         ioo->ioo_id = HTON__u64(lsm->lsm_object_id);
36         ioo->ioo_gr = HTON__u64(0);
37         ioo->ioo_type = HTON__u32(S_IFREG);
38         ioo->ioo_bufcnt = HTON__u32(bufcnt);
39 }
40
41 void ost_unpack_ioo(struct obd_ioobj *dst, struct obd_ioobj *src)
42 {
43         dst->ioo_id = NTOH__u64(src->ioo_id);
44         dst->ioo_gr = NTOH__u64(src->ioo_gr);
45         dst->ioo_type = NTOH__u32(src->ioo_type);
46         dst->ioo_bufcnt = NTOH__u32(src->ioo_bufcnt);
47 }
48
49 void ost_pack_niobuf(struct niobuf_remote *nb, __u64 offset, __u32 len,
50                      __u32 flags, __u32 xid)
51 {
52         nb->offset = HTON__u64(offset);
53         nb->len = HTON__u32(len);
54         nb->xid = HTON__u32(xid);
55         nb->flags = HTON__u32(flags);
56 }
57
58 void ost_unpack_niobuf(struct niobuf_remote *dst, struct niobuf_remote *src)
59 {
60         dst->offset = NTOH__u64(src->offset);
61         dst->len = NTOH__u32(src->len);
62         dst->xid = NTOH__u32(src->xid);
63         dst->flags = NTOH__u32(src->flags);
64 }