Whamcloud - gitweb
LU-8510 dne: set osd_obj_ea_ops::dt_invalidate
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_handler.c
index 21bbdfc..c08f11b 100644 (file)
@@ -2313,23 +2313,19 @@ static int osd_inode_setattr(const struct lu_env *env,
        if (bits == 0)
                return 0;
 
-        if (bits & LA_ATIME)
-                inode->i_atime  = *osd_inode_time(env, inode, attr->la_atime);
-        if (bits & LA_CTIME)
-                inode->i_ctime  = *osd_inode_time(env, inode, attr->la_ctime);
-        if (bits & LA_MTIME)
-                inode->i_mtime  = *osd_inode_time(env, inode, attr->la_mtime);
-        if (bits & LA_SIZE) {
-                LDISKFS_I(inode)->i_disksize = attr->la_size;
-                i_size_write(inode, attr->la_size);
-        }
-
-#if 0
-        /* OSD should not change "i_blocks" which is used by quota.
-         * "i_blocks" should be changed by ldiskfs only. */
-        if (bits & LA_BLOCKS)
-                inode->i_blocks = attr->la_blocks;
-#endif
+       if (bits & LA_ATIME)
+               inode->i_atime  = *osd_inode_time(env, inode, attr->la_atime);
+       if (bits & LA_CTIME)
+               inode->i_ctime  = *osd_inode_time(env, inode, attr->la_ctime);
+       if (bits & LA_MTIME)
+               inode->i_mtime  = *osd_inode_time(env, inode, attr->la_mtime);
+       if (bits & LA_SIZE) {
+               LDISKFS_I(inode)->i_disksize = attr->la_size;
+               i_size_write(inode, attr->la_size);
+       }
+
+       /* OSD should not change "i_blocks" which is used by quota.
+        * "i_blocks" should be changed by ldiskfs only. */
        if (bits & LA_MODE)
                inode->i_mode = (inode->i_mode & S_IFMT) |
                                (attr->la_mode & ~S_IFMT);
@@ -2342,12 +2338,12 @@ static int osd_inode_setattr(const struct lu_env *env,
        if (bits & LA_RDEV)
                inode->i_rdev = attr->la_rdev;
 
-        if (bits & LA_FLAGS) {
-                /* always keep S_NOCMTIME */
-                inode->i_flags = ll_ext_to_inode_flags(attr->la_flags) |
-                                 S_NOCMTIME;
-        }
-        return 0;
+       if (bits & LA_FLAGS) {
+               /* always keep S_NOCMTIME */
+               inode->i_flags = ll_ext_to_inode_flags(attr->la_flags) |
+                                S_NOCMTIME;
+       }
+       return 0;
 }
 
 static int osd_quota_transfer(struct inode *inode, const struct lu_attr *attr)
@@ -3827,6 +3823,11 @@ static int osd_object_sync(const struct lu_env *env, struct dt_object *dt,
        RETURN(rc);
 }
 
+static int osd_invalidate(const struct lu_env *env, struct dt_object *dt)
+{
+       return 0;
+}
+
 /*
  * Index operations.
  */
@@ -3994,6 +3995,7 @@ static const struct dt_object_operations osd_obj_ops = {
         .do_xattr_del         = osd_xattr_del,
         .do_xattr_list        = osd_xattr_list,
         .do_object_sync       = osd_object_sync,
+       .do_invalidate        = osd_invalidate,
 };
 
 /**
@@ -4026,6 +4028,7 @@ static const struct dt_object_operations osd_obj_ea_ops = {
         .do_xattr_del         = osd_xattr_del,
         .do_xattr_list        = osd_xattr_list,
         .do_object_sync       = osd_object_sync,
+       .do_invalidate        = osd_invalidate,
 };
 
 static const struct dt_object_operations osd_obj_otable_it_ops = {
@@ -4223,7 +4226,7 @@ static int osd_index_ea_delete(const struct lu_env *env, struct dt_object *dt,
         }
 
         bh = osd_ldiskfs_find_entry(dir, &dentry->d_name, &de, NULL, hlock);
-        if (bh) {
+       if (!IS_ERR(bh)) {
                /* If this is not the ".." entry, it might be a remote DNE
                 * entry and  we need to check if the FID is for a remote
                 * MDT.  If the FID is  not in the directory entry (e.g.
@@ -4252,11 +4255,11 @@ static int osd_index_ea_delete(const struct lu_env *env, struct dt_object *dt,
                                                le32_to_cpu(de->inode));
                        }
                }
-                rc = ldiskfs_delete_entry(oh->ot_handle, dir, de, bh);
-                brelse(bh);
-        } else {
-                rc = -ENOENT;
-        }
+               rc = ldiskfs_delete_entry(oh->ot_handle, dir, de, bh);
+               brelse(bh);
+       } else {
+               rc = PTR_ERR(bh);
+       }
         if (hlock != NULL)
                 ldiskfs_htree_unlock(hlock);
         else
@@ -4482,7 +4485,7 @@ static int __osd_ea_add_rec(struct osd_thread_info *info,
 
                bh = osd_ldiskfs_find_entry(pobj->oo_inode, &child->d_name, &de,
                                            NULL, hlock);
-               if (bh != NULL) {
+               if (!IS_ERR(bh)) {
                        rc1 = ldiskfs_journal_get_write_access(oth->ot_handle,
                                                               bh);
                        if (rc1 == 0) {
@@ -4494,8 +4497,8 @@ static int __osd_ea_add_rec(struct osd_thread_info *info,
                                                        LDISKFS_FT_DIR;
                                ldiskfs_handle_dirty_metadata(oth->ot_handle,
                                                              NULL, bh);
-                               brelse(bh);
                        }
+                       brelse(bh);
                }
        }
 
@@ -4840,7 +4843,7 @@ static int osd_ea_lookup_rec(const struct lu_env *env, struct osd_object *obj,
        }
 
        bh = osd_ldiskfs_find_entry(dir, &dentry->d_name, &de, NULL, hlock);
-       if (bh) {
+       if (!IS_ERR(bh)) {
                struct osd_thread_info *oti = osd_oti_get(env);
                struct osd_inode_id *id = &oti->oti_id;
                struct osd_idmap_cache *oic = &oti->oti_cache;
@@ -4886,7 +4889,7 @@ static int osd_ea_lookup_rec(const struct lu_env *env, struct osd_object *obj,
                if (rc != 0)
                        fid_zero(&oic->oic_fid);
        } else {
-               rc = -ENOENT;
+               rc = PTR_ERR(bh);
        }
 
        GOTO(out, rc);
@@ -5872,7 +5875,7 @@ again:
         * For the whole directory, only dot/dotdot entry have no FID-in-dirent
         * and needs to get FID from LMA when readdir, it will not affect the
         * performance much. */
-       if ((bh == NULL) || (le32_to_cpu(de->inode) != inode->i_ino) ||
+       if (IS_ERR(bh) || (le32_to_cpu(de->inode) != inode->i_ino) ||
            (dot_dotdot != 0 && !osd_dot_dotdot_has_space(de, dot_dotdot))) {
                *attr |= LUDA_IGNORE;
 
@@ -6040,7 +6043,8 @@ again:
        GOTO(out, rc);
 
 out:
-       brelse(bh);
+       if (!IS_ERR(bh))
+               brelse(bh);
        if (hlock != NULL) {
                ldiskfs_htree_unlock(hlock);
        } else {
@@ -6523,7 +6527,7 @@ static int osd_mount(const struct lu_env *env,
        /* Glom up mount options */
        if (*options != '\0')
                strcat(options, ",");
-       strlcat(options, "no_mbcache", PAGE_CACHE_SIZE);
+       strlcat(options, "no_mbcache", PAGE_SIZE);
 
        type = get_fs_type("ldiskfs");
        if (!type) {