1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
6 * This file is part of Lustre, http://www.lustre.org.
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.
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.
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.
21 * (Un)packing of OST requests
25 #define DEBUG_SUBSYSTEM S_OST
27 #include <liblustre.h>
30 #include <linux/obd_ost.h>
31 #include <linux/lustre_net.h>
33 void ost_pack_ioo(struct obd_ioobj **tmp, struct lov_stripe_md *lsm,int bufcnt)
35 struct obd_ioobj *ioo = *tmp;
38 ioo->ioo_id = HTON__u64(lsm->lsm_object_id);
39 ioo->ioo_gr = HTON__u64(0);
40 ioo->ioo_type = HTON__u32(S_IFREG);
41 ioo->ioo_bufcnt = HTON__u32(bufcnt);
42 *tmp = p + sizeof(*ioo);
45 void ost_unpack_ioo(struct obd_ioobj **tmp, struct obd_ioobj **ioop)
48 struct obd_ioobj *ioo = *tmp;
51 ioo->ioo_id = NTOH__u64(ioo->ioo_id);
52 ioo->ioo_gr = NTOH__u64(ioo->ioo_gr);
53 ioo->ioo_type = NTOH__u32(ioo->ioo_type);
54 ioo->ioo_bufcnt = NTOH__u32(ioo->ioo_bufcnt);
55 *tmp = p + sizeof(*ioo);
58 void ost_pack_niobuf(void **tmp, __u64 offset, __u32 len, __u32 flags,
61 struct niobuf_remote *nb = *tmp;
64 nb->offset = HTON__u64(offset);
65 nb->len = HTON__u32(len);
66 nb->flags = HTON__u32(flags);
67 nb->xid = HTON__u32(xid);
68 *tmp = c + sizeof(*nb);
71 void ost_unpack_niobuf(void **tmp, struct niobuf_remote **nbp)
74 struct niobuf_remote *nb = *tmp;
78 nb->offset = NTOH__u64(nb->offset);
79 nb->len = NTOH__u32(nb->len);
80 nb->flags = NTOH__u32(nb->flags);
82 *tmp = c + sizeof(*nb);