Whamcloud - gitweb
19b830156d7882f3b6eebc986a11aa1ee8bfeb14
[fs/lustre-release.git] / lustre / lib / lov_pack.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2002 Cluster File Systems, Inc. <adilger@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/MDS requests
22  *
23  */
24
25 #define DEBUG_SUBSYSTEM S_LLITE
26
27 #include <linux/lustre_net.h>
28 #include <linux/obd.h>
29 #include <linux/obd_support.h>
30
31 void lov_packdesc(struct lov_desc *ld)
32 {
33         ld->ld_tgt_count = HTON__u32(ld->ld_tgt_count);
34         ld->ld_default_stripe_count = HTON__u32(ld->ld_default_stripe_count);
35         ld->ld_default_stripe_size = HTON__u32(ld->ld_default_stripe_size);
36         ld->ld_pattern = HTON__u32(ld->ld_pattern);
37 }
38
39 void lov_unpackdesc(struct lov_desc *ld)
40 {
41         ld->ld_tgt_count = NTOH__u32(ld->ld_tgt_count);
42         ld->ld_default_stripe_count = HTON__u32(ld->ld_default_stripe_count);
43         ld->ld_default_stripe_size = HTON__u32(ld->ld_default_stripe_size);
44         ld->ld_pattern = HTON__u32(ld->ld_pattern);
45 }
46
47 void lov_packmd(struct lov_mds_md *mdsmd, struct lov_stripe_md *md)
48 {
49         int i;
50         mdsmd->lmd_magic = md->lmd_magic;
51         mdsmd->lmd_easize = md->lmd_mds_easize;
52         mdsmd->lmd_object_id = md->lmd_object_id;
53         mdsmd->lmd_stripe_offset = md->lmd_stripe_offset;
54         mdsmd->lmd_stripe_count = md->lmd_stripe_count;
55         mdsmd->lmd_stripe_size = md->lmd_stripe_size;
56         mdsmd->lmd_stripe_pattern = md->lmd_stripe_pattern;
57
58         for (i = 0; i < md->lmd_stripe_count; i++)
59                 mdsmd->lmd_objects[i].l_object_id = md->lmd_oinfo[i].loi_id;
60 }
61
62 void lov_unpackmd(struct lov_stripe_md *md, struct lov_mds_md *mdsmd)
63 {
64         int i;
65         md->lmd_magic = mdsmd->lmd_magic;
66         md->lmd_mds_easize = mdsmd->lmd_easize;
67         md->lmd_object_id = mdsmd->lmd_object_id;
68         md->lmd_stripe_offset = mdsmd->lmd_stripe_offset;
69         md->lmd_stripe_count = mdsmd->lmd_stripe_count;
70         md->lmd_stripe_size = mdsmd->lmd_stripe_size;
71         md->lmd_stripe_pattern = mdsmd->lmd_stripe_pattern;
72
73         for (i = 0; i < md->lmd_stripe_count; i++) {
74                 md->lmd_oinfo[i].loi_id = mdsmd->lmd_objects[i].l_object_id;
75                 md->lmd_oinfo[i].loi_size = 0;
76         }
77 }
78
79
80
81