Whamcloud - gitweb
LU-12635 build: Support for gcc -Wimplicit-fallthrough
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_compat.c
index ae42d2c..fed4238 100644 (file)
@@ -67,39 +67,48 @@ static void osd_push_ctxt(const struct osd_device *dev,
 }
 
 /**
- * osd_ios_lookup_one_len - lookup single pathname component
+ * osd_lookup_one_len_unlocked
  *
  * @name:      pathname component to lookup
  * @base:      base directory to lookup from
  * @len:       maximum length @len should be interpreted to
  *
- * Treat found dentry with NULL d_inode as an -ENOENT error so LFSCK
- * can repair the file.
+ * This should be called without the parent
+ * i_mutex held, and will take the i_mutex itself.
  */
-struct dentry *osd_ios_lookup_one_len(const char *name, struct dentry *base,
-                                     int len)
+struct dentry *osd_lookup_one_len_unlocked(const char *name,
+                                          struct dentry *base, int len)
 {
-       struct dentry *dentry;
+       struct dentry *dchild;
 
-       dentry = ll_lookup_one_len(name, base, len);
-       if (IS_ERR(dentry)) {
-               int rc = PTR_ERR(dentry);
+       inode_lock(base->d_inode);
+       dchild = lookup_one_len(name, base, len);
+       inode_unlock(base->d_inode);
 
-               if (rc != -ENOENT)
-                       CERROR("Fail to find %.*s in %.*s (%lu/%u): rc = %d\n",
-                              len, name, base->d_name.len,
-                              base->d_name.name, base->d_inode->i_ino,
-                              base->d_inode->i_generation, rc);
+       if (IS_ERR(dchild))
+               return dchild;
 
-               return dentry;
+       if (dchild->d_inode && unlikely(is_bad_inode(dchild->d_inode))) {
+               CERROR("bad inode returned %lu/%u\n",
+                      dchild->d_inode->i_ino, dchild->d_inode->i_generation);
+               dput(dchild);
+               dchild = ERR_PTR(-ENOENT);
        }
 
-       if (dentry->d_inode == NULL) {
-               dput(dentry);
-               return ERR_PTR(-ENOENT);
-       }
+       return dchild;
+}
 
-       return dentry;
+/**
+ * osd_ios_lookup_one_len - lookup single pathname component
+ *
+ * @name:      pathname component to lookup
+ * @base:      base directory to lookup from
+ * @len:       maximum length @len should be interpreted to
+ */
+struct dentry *osd_ios_lookup_one_len(const char *name, struct dentry *base,
+                                     int len)
+{
+       return osd_lookup_one_len_unlocked(name, base, len);
 }
 
 /* utility to make a directory */
@@ -118,7 +127,7 @@ simple_mkdir(const struct lu_env *env, struct osd_device *osd,
 
        // ASSERT_KERNEL_CTXT("kernel doing mkdir outside kernel context\n");
        CDEBUG(D_INODE, "creating directory %.*s\n", (int)strlen(name), name);
-       dchild = ll_lookup_one_len(name, dir, strlen(name));
+       dchild = osd_lookup_one_len_unlocked(name, dir, strlen(name));
        if (IS_ERR(dchild))
                RETURN(dchild);
 
@@ -198,8 +207,8 @@ static int osd_last_rcvd_subdir_count(struct osd_device *osd)
 
        ENTRY;
 
-       dlast = ll_lookup_one_len(LAST_RCVD, osd_sb(osd)->s_root,
-                                 strlen(LAST_RCVD));
+       dlast = osd_lookup_one_len_unlocked(LAST_RCVD, osd_sb(osd)->s_root,
+                                           strlen(LAST_RCVD));
        if (IS_ERR(dlast))
                return PTR_ERR(dlast);
        else if (dlast->d_inode == NULL)
@@ -674,7 +683,7 @@ static int osd_obj_update_entry(struct osd_thread_info *info,
        child->d_name.name = name;
        child->d_name.len = strlen(name);
 
-       ll_vfs_dq_init(parent);
+       dquot_initialize(parent);
        inode_lock(parent);
        bh = osd_ldiskfs_find_entry(parent, &child->d_name, &de, NULL, NULL);
        if (IS_ERR(bh))
@@ -815,7 +824,7 @@ static int osd_obj_del_entry(struct osd_thread_info *info,
        child->d_parent = dird;
        child->d_inode = NULL;
 
-       ll_vfs_dq_init(dir);
+       dquot_initialize(dir);
        inode_lock(dir);
        bh = osd_ldiskfs_find_entry(dir, &child->d_name, &de, NULL, NULL);
        if (IS_ERR(bh)) {
@@ -871,7 +880,7 @@ static int osd_obj_add_entry(struct osd_thread_info *info,
        if (OBD_FAIL_CHECK(OBD_FAIL_OSD_COMPAT_INVALID_ENTRY))
                inode->i_ino++;
 
-       ll_vfs_dq_init(dir->d_inode);
+       dquot_initialize(dir->d_inode);
        inode_lock(dir->d_inode);
        rc = osd_ldiskfs_add_entry(info, osd, th, child, inode, NULL);
        inode_unlock(dir->d_inode);
@@ -1257,8 +1266,8 @@ int osd_obj_map_recover(struct osd_thread_info *info,
        if (IS_ERR(jh))
                RETURN(PTR_ERR(jh));
 
-       ll_vfs_dq_init(src_parent);
-       ll_vfs_dq_init(dir);
+       dquot_initialize(src_parent);
+       dquot_initialize(dir);
 
        inode_lock(src_parent);
        inode_lock(dir);
@@ -1418,7 +1427,7 @@ int osd_obj_spec_lookup(struct osd_thread_info *info, struct osd_device *osd,
                        RETURN(-ENOENT);
        }
 
-       dentry = ll_lookup_one_len(name, root, strlen(name));
+       dentry = osd_lookup_one_len_unlocked(name, root, strlen(name));
        if (!IS_ERR(dentry)) {
                inode = dentry->d_inode;
                if (inode) {