Whamcloud - gitweb
Drop unnecessary check, update remote perm anyway.
[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 static int ll_fid_alloc(struct obd_export *exp, struct lu_fid *fid,
40                         struct lu_placement_hint *hint)
41 {
42         int rc;
43         ENTRY;
44
45         rc = obd_fid_alloc(exp, fid, hint);
46         if (rc) {
47                 CERROR("Can't allocate new fid, rc %d\n", rc);
48                 RETURN(rc);
49         }
50
51         LASSERT(fid_is_sane(fid));
52         RETURN(rc);
53 }
54
55 /* allocates passed fid, that is assigns f_num and f_seq to the @fid */
56 int ll_fid_md_alloc(struct ll_sb_info *sbi, struct lu_fid *fid,
57                     struct lu_placement_hint *hint)
58 {
59         ENTRY;
60         RETURN(ll_fid_alloc(sbi->ll_md_exp, fid, hint));
61 }
62
63 /* allocates passed fid, that is assigns f_num and f_seq to the @fid */
64 int ll_fid_dt_alloc(struct ll_sb_info *sbi, struct lu_fid *fid,
65                     struct lu_placement_hint *hint)
66 {
67         ENTRY;
68         RETURN(ll_fid_alloc(sbi->ll_dt_exp, fid, hint));
69 }
70
71 /* build inode number on passed @fid */
72 ino_t ll_fid_build_ino(struct ll_sb_info *sbi,
73                        struct lu_fid *fid)
74 {
75         ino_t ino;
76         ENTRY;
77
78         /*
79          * Very stupid and having many downsides inode allocation algorithm
80          * based on fid.
81          */
82         ino = (fid_seq(fid) - 1) * LUSTRE_SEQ_MAX_WIDTH + fid_oid(fid);
83         RETURN(ino & 0x7fffffff);
84 }