Whamcloud - gitweb
Removes all traces of mds_req, mds_rep, ost_req, and ost_rep. All subsystems
[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
27 #include <linux/obd_ost.h>
28 #include <linux/lustre_net.h>
29
30 void ost_pack_ioo(void **tmp, struct obdo *oa, int bufcnt)
31 {
32         struct obd_ioobj *ioo = *tmp;
33         char *c = *tmp;
34
35         ioo->ioo_id = HTON__u64(oa->o_id); 
36         ioo->ioo_gr = HTON__u64(oa->o_gr); 
37         ioo->ioo_type = HTON__u64(oa->o_mode); 
38         ioo->ioo_bufcnt = HTON__u32(bufcnt); 
39         *tmp = c + sizeof(*ioo); 
40 }
41
42 void ost_unpack_ioo(void **tmp, struct obd_ioobj **ioop)
43 {
44         char *c = *tmp;
45         struct obd_ioobj *ioo = *tmp;
46         *ioop = *tmp;
47
48         ioo->ioo_id = NTOH__u64(ioo->ioo_id); 
49         ioo->ioo_gr = NTOH__u64(ioo->ioo_gr); 
50         ioo->ioo_type = NTOH__u64(ioo->ioo_type); 
51         ioo->ioo_bufcnt = NTOH__u32(ioo->ioo_bufcnt); 
52         *tmp = c + sizeof(*ioo); 
53 }
54
55 void ost_pack_niobuf(void **tmp, void *addr, __u64 offset, __u32 len, 
56                      __u32 flags, __u32 xid)
57 {
58         struct niobuf *ioo = *tmp;
59         char *c = *tmp;
60
61         ioo->addr = HTON__u64((__u64)(unsigned long)addr); 
62         ioo->offset = HTON__u64(offset); 
63         ioo->len = HTON__u32(len); 
64         ioo->flags = HTON__u32(flags); 
65         ioo->xid = HTON__u32(xid);
66         *tmp = c + sizeof(*ioo); 
67 }
68
69 void ost_unpack_niobuf(void **tmp, struct niobuf **nbp)
70 {
71         char *c = *tmp;
72         struct niobuf *nb = *tmp;
73
74         *nbp = *tmp;
75
76         nb->addr = NTOH__u64(nb->addr); 
77         nb->offset = NTOH__u64(nb->offset); 
78         nb->len = NTOH__u32(nb->len); 
79         nb->flags = NTOH__u32(nb->flags); 
80
81         *tmp = c + sizeof(*nb); 
82 }