1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Lustre Light Super operations
6 * Copyright (c) 2006 Cluster File Systems, Inc.
8 * This file is part of Lustre, http://www.lustre.org.
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.
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.
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.
24 #define DEBUG_SUBSYSTEM S_LLITE
26 #include <linux/module.h>
27 #include <linux/types.h>
28 #include <linux/random.h>
29 #include <linux/version.h>
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"
39 static int ll_fid_alloc(struct obd_export *exp, struct lu_fid *fid,
40 struct lu_placement_hint *hint)
45 rc = obd_fid_alloc(exp, fid, hint);
47 CERROR("Can't allocate new fid, rc %d\n", rc);
51 LASSERT(fid_is_sane(fid));
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)
60 RETURN(ll_fid_alloc(sbi->ll_md_exp, fid, hint));
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)
68 RETURN(ll_fid_alloc(sbi->ll_dt_exp, fid, hint));
71 /* build inode number on passed @fid */
72 ino_t ll_fid_build_ino(struct ll_sb_info *sbi,
79 * Very stupid and having many downsides inode allocation algorithm
82 ino = (fid_seq(fid) - 1) * LUSTRE_SEQ_MAX_WIDTH + fid_oid(fid);
83 RETURN(ino & 0x7fffffff);