Whamcloud - gitweb
LU-12137 osd-ldiskfs: trace the obd device used for osd lookup
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_oi.c
index 54265df..44d56d9 100644 (file)
@@ -126,7 +126,8 @@ static int osd_oi_index_create_one(struct osd_thread_info *info,
        if (IS_ERR(jh))
                return PTR_ERR(jh);
 
-       inode = ldiskfs_create_inode(jh, dir, (S_IFREG | S_IRUGO | S_IWUSR));
+       inode = ldiskfs_create_inode(jh, dir, (S_IFREG | S_IRUGO | S_IWUSR),
+                                    NULL);
        if (IS_ERR(inode)) {
                ldiskfs_journal_stop(jh);
                return PTR_ERR(inode);
@@ -160,9 +161,10 @@ static struct inode *osd_oi_index_open(struct osd_thread_info *info,
         struct inode  *inode;
         int            rc;
 
-        dentry = ll_lookup_one_len(name, osd_sb(osd)->s_root, strlen(name));
+       dentry = osd_lookup_one_len_unlocked(osd, name, osd_sb(osd)->s_root,
+                                            strlen(name));
         if (IS_ERR(dentry))
-                return (void *) dentry;
+               return ERR_CAST(dentry);
 
         if (dentry->d_inode) {
                 LASSERT(!is_bad_inode(dentry->d_inode));
@@ -182,9 +184,10 @@ static struct inode *osd_oi_index_open(struct osd_thread_info *info,
         if (rc)
                return ERR_PTR(rc);
 
-        dentry = ll_lookup_one_len(name, osd_sb(osd)->s_root, strlen(name));
+       dentry = osd_lookup_one_len_unlocked(osd, name, osd_sb(osd)->s_root,
+                                            strlen(name));
         if (IS_ERR(dentry))
-                return (void *) dentry;
+               return ERR_CAST(dentry);
 
         if (dentry->d_inode) {
                 LASSERT(!is_bad_inode(dentry->d_inode));
@@ -285,9 +288,9 @@ osd_oi_table_open(struct osd_thread_info *info, struct osd_device *osd,
                  struct osd_oi **oi_table, unsigned oi_count, bool create)
 {
        struct scrub_file *sf = &osd->od_scrub.os_scrub.os_file;
-       int                count = 0;
-       int                rc = 0;
-       int                i;
+       int count = 0;
+       int rc = 0;
+       int i;
        ENTRY;
 
        /* NB: oi_count != 0 means that we have already created/known all OIs
@@ -295,14 +298,14 @@ osd_oi_table_open(struct osd_thread_info *info, struct osd_device *osd,
        LASSERT(oi_count <= OSD_OI_FID_NR_MAX);
 
        for (i = 0; i < (oi_count != 0 ? oi_count : OSD_OI_FID_NR_MAX); i++) {
-               char name[12];
+               char name[sizeof(OSD_OI_NAME_BASE) + 3 * sizeof(i) + 1];
 
                if (oi_table[i] != NULL) {
                        count++;
                        continue;
                }
 
-               sprintf(name, "%s.%d", OSD_OI_NAME_BASE, i);
+               snprintf(name, sizeof(name), "%s.%d", OSD_OI_NAME_BASE, i);
                rc = osd_oi_open(info, osd, name, &oi_table[i], create);
                if (rc == 0) {
                        count++;
@@ -334,13 +337,13 @@ osd_oi_table_open(struct osd_thread_info *info, struct osd_device *osd,
        RETURN(count);
 }
 
-static int osd_remove_oi_one(struct dentry *parent, const char *name,
-                            int namelen)
+static int osd_remove_oi_one(struct osd_device *osd, struct dentry *parent,
+                            const char *name, int namelen)
 {
        struct dentry *child;
        int rc;
 
-       child = ll_lookup_one_len(name, parent, namelen);
+       child = osd_lookup_one_len_unlocked(osd, name, parent, namelen);
        if (IS_ERR(child)) {
                rc = PTR_ERR(child);
        } else {
@@ -364,7 +367,7 @@ static int osd_remove_ois(struct osd_thread_info *info, struct osd_device *osd)
        for (i = 0; i < OSD_OI_FID_NR_MAX; i++) {
                namelen = snprintf(name, sizeof(name), "%s.%d",
                                   OSD_OI_NAME_BASE, i);
-               rc = osd_remove_oi_one(osd_sb(osd)->s_root, name, namelen);
+               rc = osd_remove_oi_one(osd, osd_sb(osd)->s_root, name, namelen);
                if (rc != 0) {
                        CERROR("%s: fail to remove the stale OI file %s: "
                               "rc = %d\n", osd_dev2name(osd), name, rc);
@@ -373,7 +376,7 @@ static int osd_remove_ois(struct osd_thread_info *info, struct osd_device *osd)
        }
 
        namelen = snprintf(name, sizeof(name), "%s", OSD_OI_NAME_BASE);
-       rc = osd_remove_oi_one(osd_sb(osd)->s_root, name, namelen);
+       rc = osd_remove_oi_one(osd, osd_sb(osd)->s_root, name, namelen);
        if (rc != 0)
                CERROR("%s: fail to remove the stale OI file %s: rc = %d\n",
                       osd_dev2name(osd), name, rc);
@@ -431,8 +434,7 @@ int osd_oi_init(struct osd_thread_info *info, struct osd_device *osd,
                        sf->sf_oi_count = osd_oi_count;
                }
 
-               scrub_file_reset(scrub, LDISKFS_SB(osd_sb(osd))->s_es->s_uuid,
-                                SF_RECREATED);
+               scrub_file_reset(scrub, osd->od_uuid, SF_RECREATED);
                count = sf->sf_oi_count;
                goto create;
        }
@@ -453,9 +455,7 @@ int osd_oi_init(struct osd_thread_info *info, struct osd_device *osd,
                         *      and restored after former upgrading from 1.8
                         *      to 2.x. Fortunately, the osd_fid_lookup()can
                         *      verify the inode to decrease the risk. */
-                       scrub_file_reset(scrub,
-                                        LDISKFS_SB(osd_sb(osd))->s_es->s_uuid,
-                                        SF_UPGRADE);
+                       scrub_file_reset(scrub, osd->od_uuid, SF_UPGRADE);
                GOTO(out, rc = 1);
        } else if (rc != -ENOENT) {
                CERROR("%s: can't open %s: rc = %d\n",
@@ -470,8 +470,7 @@ int osd_oi_init(struct osd_thread_info *info, struct osd_device *osd,
                memset(sf->sf_oi_bitmap, 0, SCRUB_OI_BITMAP_SIZE);
                for (i = 0; i < count; i++)
                        ldiskfs_set_bit(i, sf->sf_oi_bitmap);
-               scrub_file_reset(scrub, LDISKFS_SB(osd_sb(osd))->s_es->s_uuid,
-                                SF_RECREATED);
+               scrub_file_reset(scrub, osd->od_uuid, SF_RECREATED);
        } else {
                count = sf->sf_oi_count = osd_oi_count;
        }
@@ -635,7 +634,7 @@ int osd_oi_lookup(struct osd_thread_info *info, struct osd_device *osd,
        if (unlikely(fid_is_last_id(fid)))
                return osd_obj_spec_lookup(info, osd, fid, id);
 
-       if (fid_is_on_ost(info, osd, fid, flags) || fid_is_llog(fid))
+       if (fid_is_llog(fid) || fid_is_on_ost(info, osd, fid, flags))
                return osd_obj_map_lookup(info, osd, fid, id);
 
 
@@ -675,7 +674,7 @@ static int osd_oi_iam_refresh(struct osd_thread_info *oti, struct osd_oi *oi,
 
        LASSERT(oi);
        LASSERT(oi->oi_inode);
-       ll_vfs_dq_init(oi->oi_inode);
+       dquot_initialize(oi->oi_inode);
 
        bag = &oi->oi_dir.od_container;
        ipd = osd_idx_ipd_get(oti->oti_env, bag);
@@ -706,7 +705,7 @@ int osd_oi_insert(struct osd_thread_info *info, struct osd_device *osd,
        if (unlikely(fid_is_last_id(fid)))
                return osd_obj_spec_insert(info, osd, fid, id, th);
 
-       if (fid_is_on_ost(info, osd, fid, flags) || fid_is_llog(fid))
+       if (fid_is_llog(fid) || fid_is_on_ost(info, osd, fid, flags))
                return osd_obj_map_insert(info, osd, fid, id, th);
 
        fid_cpu_to_be(oi_fid, fid);
@@ -789,7 +788,7 @@ static int osd_oi_iam_delete(struct osd_thread_info *oti, struct osd_oi *oi,
 
        LASSERT(oi);
        LASSERT(oi->oi_inode);
-       ll_vfs_dq_init(oi->oi_inode);
+       dquot_initialize(oi->oi_inode);
 
        bag = &oi->oi_dir.od_container;
        ipd = osd_idx_ipd_get(oti->oti_env, bag);
@@ -818,7 +817,7 @@ int osd_oi_delete(struct osd_thread_info *info,
        if (fid_is_last_id(fid))
                return 0;
 
-       if (fid_is_on_ost(info, osd, fid, flags) || fid_is_llog(fid))
+       if (fid_is_llog(fid) || fid_is_on_ost(info, osd, fid, flags))
                return osd_obj_map_delete(info, osd, fid, th);
 
        fid_cpu_to_be(oi_fid, fid);
@@ -837,7 +836,7 @@ int osd_oi_update(struct osd_thread_info *info, struct osd_device *osd,
        if (unlikely(fid_is_last_id(fid)))
                return osd_obj_spec_update(info, osd, fid, id, th);
 
-       if (fid_is_on_ost(info, osd, fid, flags) || fid_is_llog(fid))
+       if (fid_is_llog(fid) || fid_is_on_ost(info, osd, fid, flags))
                return osd_obj_map_update(info, osd, fid, id, th);
 
        fid_cpu_to_be(oi_fid, fid);