Whamcloud - gitweb
LU-2725 ost: ost_rw_hpreq_check should return 0 or 1
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_oi.c
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; If not, see
18  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
19  *
20  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21  * CA 95054 USA or visit www.sun.com if you need additional information or
22  * have any questions.
23  *
24  * GPL HEADER END
25  */
26 /*
27  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28  * Use is subject to license terms.
29  *
30  * Copyright (c) 2011, 2012, Intel Corporation.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  *
36  * lustre/osd/osd_oi.c
37  *
38  * Object Index.
39  *
40  * Author: Nikita Danilov <nikita@clusterfs.com>
41  */
42
43 /*
44  * oi uses two mechanisms to implement fid->cookie mapping:
45  *
46  *     - persistent index, where cookie is a record and fid is a key, and
47  *
48  *     - algorithmic mapping for "igif" fids.
49  *
50  */
51
52 #define DEBUG_SUBSYSTEM S_MDS
53
54 #include <linux/module.h>
55
56 /* LUSTRE_VERSION_CODE */
57 #include <lustre_ver.h>
58 /*
59  * struct OBD_{ALLOC,FREE}*()
60  * OBD_FAIL_CHECK
61  */
62 #include <obd.h>
63 #include <obd_support.h>
64
65 /* fid_cpu_to_be() */
66 #include <lustre_fid.h>
67 #include <dt_object.h>
68
69 #include "osd_oi.h"
70 /* osd_lookup(), struct osd_thread_info */
71 #include "osd_internal.h"
72 #include "osd_scrub.h"
73
74 static unsigned int osd_oi_count = OSD_OI_FID_NR;
75 CFS_MODULE_PARM(osd_oi_count, "i", int, 0444,
76                 "Number of Object Index containers to be created, "
77                 "it's only valid for new filesystem.");
78
79 /** to serialize concurrent OI index initialization */
80 static struct mutex oi_init_lock;
81
82 static struct dt_index_features oi_feat = {
83         .dif_flags       = DT_IND_UPDATE,
84         .dif_recsize_min = sizeof(struct osd_inode_id),
85         .dif_recsize_max = sizeof(struct osd_inode_id),
86         .dif_ptrsize     = 4
87 };
88
89 #define OSD_OI_NAME_BASE        "oi.16"
90
91 static void osd_oi_table_put(struct osd_thread_info *info,
92                              struct osd_oi **oi_table, unsigned oi_count)
93 {
94         struct iam_container *bag;
95         int                   i;
96
97         for (i = 0; i < oi_count; i++) {
98                 if (oi_table[i] == NULL)
99                         continue;
100
101                 LASSERT(oi_table[i]->oi_inode != NULL);
102
103                 bag = &(oi_table[i]->oi_dir.od_container);
104                 if (bag->ic_object == oi_table[i]->oi_inode)
105                         iam_container_fini(bag);
106                 iput(oi_table[i]->oi_inode);
107                 oi_table[i]->oi_inode = NULL;
108                 OBD_FREE_PTR(oi_table[i]);
109                 oi_table[i] = NULL;
110         }
111 }
112
113 static int osd_oi_index_create_one(struct osd_thread_info *info,
114                                    struct osd_device *osd, const char *name,
115                                    struct dt_index_features *feat)
116 {
117         const struct lu_env             *env = info->oti_env;
118         struct osd_inode_id             *id  = &info->oti_id;
119         struct buffer_head              *bh;
120         struct inode                    *inode;
121         struct ldiskfs_dir_entry_2      *de;
122         struct dentry                   *dentry;
123         struct super_block              *sb  = osd_sb(osd);
124         struct inode                    *dir = sb->s_root->d_inode;
125         handle_t                        *jh;
126         int                              rc;
127
128         dentry = osd_child_dentry_by_inode(env, dir, name, strlen(name));
129         bh = osd_ldiskfs_find_entry(dir, dentry, &de, NULL);
130         if (bh) {
131                 osd_id_gen(id, le32_to_cpu(de->inode), OSD_OII_NOGEN);
132                 brelse(bh);
133                 inode = osd_iget(info, osd, id);
134                 if (!IS_ERR(inode)) {
135                         iput(inode);
136                         inode = ERR_PTR(-EEXIST);
137                 }
138                 return PTR_ERR(inode);
139         }
140
141         jh = ldiskfs_journal_start_sb(sb, 100);
142         if (IS_ERR(jh))
143                 return PTR_ERR(jh);
144
145         inode = ldiskfs_create_inode(jh, dir, (S_IFREG | S_IRUGO | S_IWUSR));
146         if (IS_ERR(inode)) {
147                 ldiskfs_journal_stop(jh);
148                 return PTR_ERR(inode);
149         }
150
151         if (feat->dif_flags & DT_IND_VARKEY)
152                 rc = iam_lvar_create(inode, feat->dif_keysize_max,
153                                      feat->dif_ptrsize, feat->dif_recsize_max,
154                                      jh);
155         else
156                 rc = iam_lfix_create(inode, feat->dif_keysize_max,
157                                      feat->dif_ptrsize, feat->dif_recsize_max,
158                                      jh);
159         dentry = osd_child_dentry_by_inode(env, dir, name, strlen(name));
160         rc = osd_ldiskfs_add_entry(jh, dentry, inode, NULL);
161         ldiskfs_journal_stop(jh);
162         iput(inode);
163         return rc;
164 }
165
166 static struct inode *osd_oi_index_open(struct osd_thread_info *info,
167                                        struct osd_device *osd,
168                                        const char *name,
169                                        struct dt_index_features *f,
170                                        bool create)
171 {
172         struct dentry *dentry;
173         struct inode  *inode;
174         int            rc;
175
176         dentry = ll_lookup_one_len(name, osd_sb(osd)->s_root, strlen(name));
177         if (IS_ERR(dentry))
178                 return (void *) dentry;
179
180         if (dentry->d_inode) {
181                 LASSERT(!is_bad_inode(dentry->d_inode));
182                 inode = dentry->d_inode;
183                 atomic_inc(&inode->i_count);
184                 dput(dentry);
185                 return inode;
186         }
187
188         /* create */
189         dput(dentry);
190         shrink_dcache_parent(osd_sb(osd)->s_root);
191         if (!create)
192                 return ERR_PTR(-ENOENT);
193
194         rc = osd_oi_index_create_one(info, osd, name, f);
195         if (rc)
196                 return ERR_PTR(rc);
197
198         dentry = ll_lookup_one_len(name, osd_sb(osd)->s_root, strlen(name));
199         if (IS_ERR(dentry))
200                 return (void *) dentry;
201
202         if (dentry->d_inode) {
203                 LASSERT(!is_bad_inode(dentry->d_inode));
204                 inode = dentry->d_inode;
205                 atomic_inc(&inode->i_count);
206                 dput(dentry);
207                 return inode;
208         }
209
210         return ERR_PTR(-ENOENT);
211 }
212
213 /**
214  * Open an OI(Ojbect Index) container.
215  *
216  * \param       name    Name of OI container
217  * \param       objp    Pointer of returned OI
218  *
219  * \retval      0       success
220  * \retval      -ve     failure
221  */
222 static int osd_oi_open(struct osd_thread_info *info, struct osd_device *osd,
223                        char *name, struct osd_oi **oi_slot, bool create)
224 {
225         struct osd_directory *dir;
226         struct iam_container *bag;
227         struct inode         *inode;
228         struct osd_oi        *oi;
229         int                   rc;
230
231         ENTRY;
232
233         oi_feat.dif_keysize_min = sizeof(struct lu_fid);
234         oi_feat.dif_keysize_max = sizeof(struct lu_fid);
235
236         inode = osd_oi_index_open(info, osd, name, &oi_feat, create);
237         if (IS_ERR(inode))
238                 RETURN(PTR_ERR(inode));
239
240         OBD_ALLOC_PTR(oi);
241         if (oi == NULL)
242                 GOTO(out_inode, rc = -ENOMEM);
243
244         oi->oi_inode = inode;
245         dir = &oi->oi_dir;
246
247         bag = &dir->od_container;
248         rc = iam_container_init(bag, &dir->od_descr, inode);
249         if (rc < 0)
250                 GOTO(out_free, rc);
251
252         rc = iam_container_setup(bag);
253         if (rc < 0)
254                 GOTO(out_container, rc);
255
256         *oi_slot = oi;
257         RETURN(0);
258
259 out_container:
260         iam_container_fini(bag);
261 out_free:
262         OBD_FREE_PTR(oi);
263 out_inode:
264         iput(inode);
265         return rc;
266 }
267
268 /**
269  * Open OI(Object Index) table.
270  * If \a oi_count is zero, which means caller doesn't know how many OIs there
271  * will be, this function can either return 0 for new filesystem, or number
272  * of OIs on existed filesystem.
273  *
274  * If \a oi_count is non-zero, which means caller does know number of OIs on
275  * filesystem, this function should return the exactly same number on
276  * success, or error code in failure.
277  *
278  * \param     oi_count  Number of expected OI containers
279  * \param     create    Create OIs if doesn't exist
280  *
281  * \retval    +ve       number of opened OI containers
282  * \retval      0       no OI containers found
283  * \retval    -ve       failure
284  */
285 static int
286 osd_oi_table_open(struct osd_thread_info *info, struct osd_device *osd,
287                   struct osd_oi **oi_table, unsigned oi_count, bool create)
288 {
289         struct scrub_file *sf = &osd->od_scrub.os_file;
290         int                count = 0;
291         int                rc = 0;
292         int                i;
293         ENTRY;
294
295         /* NB: oi_count != 0 means that we have already created/known all OIs
296          * and have known exact number of OIs. */
297         LASSERT(oi_count <= OSD_OI_FID_NR_MAX);
298
299         for (i = 0; i < (oi_count != 0 ? oi_count : OSD_OI_FID_NR_MAX); i++) {
300                 char name[12];
301
302                 if (oi_table[i] != NULL) {
303                         count++;
304                         continue;
305                 }
306
307                 sprintf(name, "%s.%d", OSD_OI_NAME_BASE, i);
308                 rc = osd_oi_open(info, osd, name, &oi_table[i], create);
309                 if (rc == 0) {
310                         count++;
311                         continue;
312                 }
313
314                 if (rc == -ENOENT && create == false) {
315                         if (oi_count == 0)
316                                 return count;
317
318                         rc = 0;
319                         ldiskfs_set_bit(i, sf->sf_oi_bitmap);
320                         continue;
321                 }
322
323                 CERROR("%.16s: can't open %s: rc = %d\n",
324                        LDISKFS_SB(osd_sb(osd))->s_es->s_volume_name, name, rc);
325                 if (oi_count > 0)
326                         CERROR("%.16s: expect to open total %d OI files.\n",
327                                LDISKFS_SB(osd_sb(osd))->s_es->s_volume_name,
328                                oi_count);
329                 break;
330         }
331
332         if (rc < 0) {
333                 osd_oi_table_put(info, oi_table, oi_count > 0 ? oi_count : i);
334                 count = rc;
335         }
336
337         RETURN(count);
338 }
339
340 int osd_oi_init(struct osd_thread_info *info, struct osd_device *osd)
341 {
342         struct osd_scrub  *scrub = &osd->od_scrub;
343         struct scrub_file *sf = &scrub->os_file;
344         struct osd_oi    **oi;
345         int                rc;
346         ENTRY;
347
348         OBD_ALLOC(oi, sizeof(*oi) * OSD_OI_FID_NR_MAX);
349         if (oi == NULL)
350                 RETURN(-ENOMEM);
351
352         mutex_lock(&oi_init_lock);
353         /* try to open existing multiple OIs first */
354         rc = osd_oi_table_open(info, osd, oi, sf->sf_oi_count, false);
355         if (rc < 0)
356                 GOTO(out, rc);
357
358         if (rc > 0) {
359                 if (rc == sf->sf_oi_count || sf->sf_oi_count == 0)
360                         GOTO(out, rc);
361
362                 osd_scrub_file_reset(scrub,
363                                      LDISKFS_SB(osd_sb(osd))->s_es->s_uuid,
364                                      SF_RECREATED);
365                 osd_oi_count = sf->sf_oi_count;
366                 goto create;
367         }
368
369         /* if previous failed then try found single OI from old filesystem */
370         rc = osd_oi_open(info, osd, OSD_OI_NAME_BASE, &oi[0], false);
371         if (rc == 0) { /* found single OI from old filesystem */
372                 GOTO(out, rc = 1);
373         } else if (rc != -ENOENT) {
374                 CERROR("%.16s: can't open %s: rc = %d\n",
375                        LDISKFS_SB(osd_sb(osd))->s_es->s_volume_name,
376                        OSD_OI_NAME_BASE, rc);
377                 GOTO(out, rc);
378         }
379
380         if (sf->sf_oi_count > 0) {
381                 int i;
382
383                 memset(sf->sf_oi_bitmap, 0, SCRUB_OI_BITMAP_SIZE);
384                 for (i = 0; i < osd_oi_count; i++)
385                         ldiskfs_set_bit(i, sf->sf_oi_bitmap);
386                 osd_scrub_file_reset(scrub,
387                                      LDISKFS_SB(osd_sb(osd))->s_es->s_uuid,
388                                      SF_RECREATED);
389         }
390         sf->sf_oi_count = osd_oi_count;
391
392 create:
393         rc = osd_scrub_file_store(scrub);
394         if (rc < 0) {
395                 osd_oi_table_put(info, oi, sf->sf_oi_count);
396                 GOTO(out, rc);
397         }
398
399         /* No OIs exist, new filesystem, create OI objects */
400         rc = osd_oi_table_open(info, osd, oi, osd_oi_count, true);
401         LASSERT(ergo(rc >= 0, rc == osd_oi_count));
402
403         GOTO(out, rc);
404
405 out:
406         if (rc < 0) {
407                 OBD_FREE(oi, sizeof(*oi) * OSD_OI_FID_NR_MAX);
408         } else {
409                 LASSERT((rc & (rc - 1)) == 0);
410                 osd->od_oi_table = oi;
411                 osd->od_oi_count = rc;
412                 rc = 0;
413         }
414
415         mutex_unlock(&oi_init_lock);
416         return rc;
417 }
418
419 void osd_oi_fini(struct osd_thread_info *info, struct osd_device *osd)
420 {
421         if (unlikely(osd->od_oi_table == NULL))
422                 return;
423
424         osd_oi_table_put(info, osd->od_oi_table, osd->od_oi_count);
425
426         OBD_FREE(osd->od_oi_table,
427                  sizeof(*(osd->od_oi_table)) * OSD_OI_FID_NR_MAX);
428         osd->od_oi_table = NULL;
429 }
430
431 static inline int fid_is_fs_root(const struct lu_fid *fid)
432 {
433         /* Map root inode to special local object FID */
434         return (unlikely(fid_seq(fid) == FID_SEQ_LOCAL_FILE &&
435                          fid_oid(fid) == OSD_FS_ROOT_OID));
436 }
437
438 static int osd_oi_iam_lookup(struct osd_thread_info *oti,
439                              struct osd_oi *oi, struct dt_rec *rec,
440                              const struct dt_key *key)
441 {
442         struct iam_container  *bag;
443         struct iam_iterator   *it = &oti->oti_idx_it;
444         struct iam_rec        *iam_rec;
445         struct iam_path_descr *ipd;
446         int                    rc;
447         ENTRY;
448
449         LASSERT(oi);
450         LASSERT(oi->oi_inode);
451
452         bag = &oi->oi_dir.od_container;
453         ipd = osd_idx_ipd_get(oti->oti_env, bag);
454         if (IS_ERR(ipd))
455                 RETURN(-ENOMEM);
456
457         /* got ipd now we can start iterator. */
458         iam_it_init(it, bag, 0, ipd);
459
460         rc = iam_it_get(it, (struct iam_key *)key);
461         if (rc >= 0) {
462                 if (S_ISDIR(oi->oi_inode->i_mode))
463                         iam_rec = (struct iam_rec *)oti->oti_ldp;
464                 else
465                         iam_rec = (struct iam_rec *)rec;
466
467                 iam_reccpy(&it->ii_path.ip_leaf, (struct iam_rec *)iam_rec);
468                 if (S_ISDIR(oi->oi_inode->i_mode))
469                         osd_fid_unpack((struct lu_fid *)rec,
470                                        (struct osd_fid_pack *)iam_rec);
471         }
472         iam_it_put(it);
473         iam_it_fini(it);
474         osd_ipd_put(oti->oti_env, bag, ipd);
475
476         LINVRNT(osd_invariant(obj));
477
478         RETURN(rc);
479 }
480
481 int fid_is_on_ost(struct osd_thread_info *info, struct osd_device *osd,
482                   const struct lu_fid *fid)
483 {
484         struct lu_seq_range *range = &info->oti_seq_range;
485         int rc;
486         ENTRY;
487
488         if (fid_is_idif(fid) || fid_is_last_id(fid))
489                 RETURN(1);
490
491         rc = osd_fld_lookup(info->oti_env, osd, fid, range);
492         if (rc != 0) {
493                 CERROR("%s: Can not lookup fld for "DFID"\n",
494                        osd2lu_dev(osd)->ld_obd->obd_name, PFID(fid));
495                 RETURN(rc);
496         }
497
498         CDEBUG(D_INFO, "fid "DFID" range "DRANGE"\n", PFID(fid),
499                PRANGE(range));
500
501         if (range->lsr_flags == LU_SEQ_RANGE_OST)
502                 RETURN(1);
503
504         RETURN(0);
505 }
506
507 int __osd_oi_lookup(struct osd_thread_info *info, struct osd_device *osd,
508                     const struct lu_fid *fid, struct osd_inode_id *id)
509 {
510         struct lu_fid *oi_fid = &info->oti_fid2;
511         int            rc;
512
513         fid_cpu_to_be(oi_fid, fid);
514         rc = osd_oi_iam_lookup(info, osd_fid2oi(osd, fid), (struct dt_rec *)id,
515                                (const struct dt_key *)oi_fid);
516         if (rc > 0) {
517                 osd_id_unpack(id, id);
518                 rc = 0;
519         } else if (rc == 0) {
520                 rc = -ENOENT;
521         }
522         return rc;
523 }
524
525 int osd_oi_lookup(struct osd_thread_info *info, struct osd_device *osd,
526                   const struct lu_fid *fid, struct osd_inode_id *id)
527 {
528         int                  rc = 0;
529
530         if ((!fid_is_last_id(fid) && fid_is_on_ost(info, osd, fid)) ||
531              fid_is_llog(fid)) {
532                 /* old OSD obj id */
533                 /* FIXME: actually for all of the OST object */
534                 rc = osd_obj_map_lookup(info, osd, fid, id);
535         } else if (fid_is_igif(fid)) {
536                 osd_id_gen(id, lu_igif_ino(fid), lu_igif_gen(fid));
537         } else if (fid_is_fs_root(fid)) {
538                 osd_id_gen(id, osd_sb(osd)->s_root->d_inode->i_ino,
539                            osd_sb(osd)->s_root->d_inode->i_generation);
540         } else {
541                 if (unlikely(fid_is_acct(fid)))
542                         return osd_acct_obj_lookup(info, osd, fid, id);
543                 else if (unlikely(fid_seq(fid) == FID_SEQ_LOCAL_FILE) ||
544                          fid_is_last_id(fid))
545                         return osd_obj_spec_lookup(info, osd, fid, id);
546
547                 rc = __osd_oi_lookup(info, osd, fid, id);
548         }
549         return rc;
550 }
551
552 static int osd_oi_iam_insert(struct osd_thread_info *oti, struct osd_oi *oi,
553                              const struct dt_rec *rec, const struct dt_key *key,
554                              struct thandle *th)
555 {
556         struct iam_container  *bag;
557         struct iam_rec        *iam_rec = (struct iam_rec *)oti->oti_ldp;
558         struct iam_path_descr *ipd;
559         struct osd_thandle    *oh;
560         int                    rc;
561         ENTRY;
562
563         LASSERT(oi);
564         LASSERT(oi->oi_inode);
565         ll_vfs_dq_init(oi->oi_inode);
566
567         bag = &oi->oi_dir.od_container;
568         ipd = osd_idx_ipd_get(oti->oti_env, bag);
569         if (unlikely(ipd == NULL))
570                 RETURN(-ENOMEM);
571
572         oh = container_of0(th, struct osd_thandle, ot_super);
573         LASSERT(oh->ot_handle != NULL);
574         LASSERT(oh->ot_handle->h_transaction != NULL);
575         if (S_ISDIR(oi->oi_inode->i_mode))
576                 osd_fid_pack((struct osd_fid_pack *)iam_rec, rec,
577                              &oti->oti_fid);
578         else
579                 iam_rec = (struct iam_rec *) rec;
580         rc = iam_insert(oh->ot_handle, bag, (const struct iam_key *)key,
581                         iam_rec, ipd);
582         osd_ipd_put(oti->oti_env, bag, ipd);
583         LINVRNT(osd_invariant(obj));
584         RETURN(rc);
585 }
586
587 int osd_oi_insert(struct osd_thread_info *info, struct osd_device *osd,
588                   const struct lu_fid *fid, const struct osd_inode_id *id,
589                   struct thandle *th)
590 {
591         struct lu_fid       *oi_fid = &info->oti_fid2;
592         struct osd_inode_id *oi_id = &info->oti_id2;
593
594         if (fid_is_igif(fid) || unlikely(fid_seq(fid) == FID_SEQ_DOT_LUSTRE))
595                 return 0;
596
597         if ((fid_is_on_ost(info, osd, fid) && !fid_is_last_id(fid)) ||
598              fid_is_llog(fid))
599                 return osd_obj_map_insert(info, osd, fid, id, th);
600
601         /* Server mount should not depends on OI files */
602         if (unlikely(fid_seq(fid) == FID_SEQ_LOCAL_FILE) ||
603             fid_is_last_id(fid))
604                 return osd_obj_spec_insert(info, osd, fid, id, th);
605
606         fid_cpu_to_be(oi_fid, fid);
607         osd_id_pack(oi_id, id);
608         return osd_oi_iam_insert(info, osd_fid2oi(osd, fid),
609                                  (const struct dt_rec *)oi_id,
610                                  (const struct dt_key *)oi_fid, th);
611 }
612
613 static int osd_oi_iam_delete(struct osd_thread_info *oti, struct osd_oi *oi,
614                              const struct dt_key *key, struct thandle *handle)
615 {
616         struct iam_container  *bag;
617         struct iam_path_descr *ipd;
618         struct osd_thandle    *oh;
619         int                    rc;
620         ENTRY;
621
622         LASSERT(oi);
623         LASSERT(oi->oi_inode);
624         ll_vfs_dq_init(oi->oi_inode);
625
626         bag = &oi->oi_dir.od_container;
627         ipd = osd_idx_ipd_get(oti->oti_env, bag);
628         if (unlikely(ipd == NULL))
629                 RETURN(-ENOMEM);
630
631         oh = container_of0(handle, struct osd_thandle, ot_super);
632         LASSERT(oh->ot_handle != NULL);
633         LASSERT(oh->ot_handle->h_transaction != NULL);
634
635         rc = iam_delete(oh->ot_handle, bag, (const struct iam_key *)key, ipd);
636         osd_ipd_put(oti->oti_env, bag, ipd);
637         LINVRNT(osd_invariant(obj));
638         RETURN(rc);
639 }
640
641 int osd_oi_delete(struct osd_thread_info *info,
642                   struct osd_device *osd, const struct lu_fid *fid,
643                   struct thandle *th)
644 {
645         struct lu_fid *oi_fid = &info->oti_fid2;
646
647         if (fid_is_igif(fid) || fid_is_last_id(fid))
648                 return 0;
649
650         LASSERT(fid_seq(fid) != FID_SEQ_LOCAL_FILE);
651
652         if (fid_is_on_ost(info, osd, fid) || fid_is_llog(fid))
653                 return osd_obj_map_delete(info, osd, fid, th);
654
655         fid_cpu_to_be(oi_fid, fid);
656         return osd_oi_iam_delete(info, osd_fid2oi(osd, fid),
657                                  (const struct dt_key *)oi_fid, th);
658 }
659
660 int osd_oi_mod_init(void)
661 {
662         if (osd_oi_count == 0 || osd_oi_count > OSD_OI_FID_NR_MAX)
663                 osd_oi_count = OSD_OI_FID_NR;
664
665         if ((osd_oi_count & (osd_oi_count - 1)) != 0) {
666                 LCONSOLE_WARN("Round up oi_count %d to power2 %d\n",
667                               osd_oi_count, size_roundup_power2(osd_oi_count));
668                 osd_oi_count = size_roundup_power2(osd_oi_count);
669         }
670
671         mutex_init(&oi_init_lock);
672         return 0;
673 }