Whamcloud - gitweb
b=14340
[fs/lustre-release.git] / lustre / lmv / lmv_fld.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Copyright (C) 2006 Cluster File Systems, Inc.
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
22 #ifndef EXPORT_SYMTAB
23 # define EXPORT_SYMTAB
24 #endif
25 #define DEBUG_SUBSYSTEM S_LMV
26 #ifdef __KERNEL__
27 #include <linux/slab.h>
28 #include <linux/module.h>
29 #include <linux/init.h>
30 #include <linux/slab.h>
31 #include <linux/pagemap.h>
32 #include <asm/div64.h>
33 #include <linux/seq_file.h>
34 #else
35 #include <liblustre.h>
36 #endif
37
38 #include <lustre/lustre_idl.h>
39 #include <obd_support.h>
40 #include <lustre_fid.h>
41 #include <lustre_lib.h>
42 #include <lustre_net.h>
43 #include <lustre_dlm.h>
44 #include <obd_class.h>
45 #include <lprocfs_status.h>
46 #include "lmv_internal.h"
47
48 int lmv_fld_lookup(struct lmv_obd *lmv,
49                    const struct lu_fid *fid,
50                    mdsno_t *mds)
51 {
52         int rc;
53         ENTRY;
54
55         LASSERT(fid_is_sane(fid));
56         rc = fld_client_lookup(&lmv->lmv_fld, fid_seq(fid), mds, NULL);
57         if (rc) {
58                 CERROR("Error while looking for mds number. Seq "LPU64
59                        ", err = %d\n", fid_seq(fid), rc);
60                 RETURN(rc);
61         }
62         
63         CDEBUG(D_INFO, "Got mds "LPU64" for sequence: "LPU64"\n",
64                *mds, fid_seq(fid));
65
66         if (*mds >= lmv->desc.ld_tgt_count) {
67                 CERROR("Got invalid mds: "LPU64" (max: %d)\n",
68                        *mds, lmv->desc.ld_tgt_count);
69                 rc = -EINVAL;
70         }
71         RETURN(rc);
72 }