Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / llite / llite_fid.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Lustre Light Super operations
5  *
6  *  Copyright (c) 2006 Cluster File Systems, Inc.
7  *
8  *   This file is part of Lustre, http://www.lustre.org.
9  *
10  *   Lustre is free software; you can redistribute it and/or
11  *   modify it under the terms of version 2 of the GNU General Public
12  *   License as published by the Free Software Foundation.
13  *
14  *   Lustre is distributed in the hope that it will be useful,
15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *   GNU General Public License for more details.
18  *
19  *   You should have received a copy of the GNU General Public License
20  *   along with Lustre; if not, write to the Free Software
21  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  */
23
24 #define DEBUG_SUBSYSTEM S_LLITE
25
26 #include <linux/module.h>
27 #include <linux/types.h>
28 #include <linux/random.h>
29 #include <linux/version.h>
30
31 #include <lustre_fid.h>
32 #include <lustre_lite.h>
33 #include <lustre_ha.h>
34 #include <lustre_ver.h>
35 #include <lustre_dlm.h>
36 #include <lustre_disk.h>
37 #include "llite_internal.h"
38
39 /* Build inode number on passed @fid */
40 ino_t ll_fid_build_ino(struct ll_sb_info *sbi,
41                        struct lu_fid *fid)
42 {
43         ino_t ino;
44         ENTRY;
45
46         if (fid_is_igif(fid)) {
47                 ino = lu_igif_ino(fid);
48                 RETURN(ino);
49         }
50
51         /*
52          * Very stupid and having many downsides inode allocation algorithm
53          * based on fid.
54          */
55         ino = fid_flatten(fid);
56         ino = ino & 0x7fffffff;
57
58         if (unlikely(ino == 0))
59                 /* the first result ino is 0xFFC001, so this is rarely used */
60                 ino = 0xffbcde; 
61         RETURN(ino);
62 }