]> git.karo-electronics.de Git - linux-beck.git/blobdiff - fs/ocfs2/file.c
Merge branch 'linus' into test
[linux-beck.git] / fs / ocfs2 / file.c
index 7bb4fde70054b72ffdbb79e281c6de3f81a39c8a..8d3225a78073f86c682ed21e9b3098a1fef6b843 100644 (file)
@@ -55,6 +55,7 @@
 #include "mmap.h"
 #include "suballoc.h"
 #include "super.h"
+#include "xattr.h"
 
 #include "buffer_head_io.h"
 
@@ -184,7 +185,7 @@ static int ocfs2_sync_file(struct file *file,
                goto bail;
 
        journal = osb->journal->j_journal;
-       err = journal_force_commit(journal);
+       err = jbd2_journal_force_commit(journal);
 
 bail:
        mlog_exit(err);
@@ -508,14 +509,16 @@ int ocfs2_add_inode_data(struct ocfs2_super *osb,
                         struct ocfs2_alloc_context *meta_ac,
                         enum ocfs2_alloc_restarted *reason_ret)
 {
-       struct ocfs2_dinode *fe = (struct ocfs2_dinode *) fe_bh->b_data;
-       struct ocfs2_extent_list *el = &fe->id2.i_list;
+       int ret;
+       struct ocfs2_extent_tree et;
 
-       return ocfs2_add_clusters_in_btree(osb, inode, logical_offset,
+       ocfs2_init_dinode_extent_tree(&et, inode, fe_bh);
+       ret = ocfs2_add_clusters_in_btree(osb, inode, logical_offset,
                                           clusters_to_add, mark_unwritten,
-                                          fe_bh, el, handle,
-                                          data_ac, meta_ac, reason_ret,
-                                          OCFS2_DINODE_EXTENT);
+                                          &et, handle,
+                                          data_ac, meta_ac, reason_ret);
+
+       return ret;
 }
 
 static int __ocfs2_extend_allocation(struct inode *inode, u32 logical_start,
@@ -532,6 +535,7 @@ static int __ocfs2_extend_allocation(struct inode *inode, u32 logical_start,
        struct ocfs2_alloc_context *meta_ac = NULL;
        enum ocfs2_alloc_restarted why;
        struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+       struct ocfs2_extent_tree et;
 
        mlog_entry("(clusters_to_add = %u)\n", clusters_to_add);
 
@@ -541,8 +545,7 @@ static int __ocfs2_extend_allocation(struct inode *inode, u32 logical_start,
         */
        BUG_ON(mark_unwritten && !ocfs2_sparse_alloc(osb));
 
-       status = ocfs2_read_block(osb, OCFS2_I(inode)->ip_blkno, &bh,
-                                 OCFS2_BH_CACHED, inode);
+       status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &bh);
        if (status < 0) {
                mlog_errno(status);
                goto leave;
@@ -563,9 +566,9 @@ restart_all:
             (unsigned long long)OCFS2_I(inode)->ip_blkno,
             (long long)i_size_read(inode), le32_to_cpu(fe->i_clusters),
             clusters_to_add);
-       status = ocfs2_lock_allocators(inode, bh, &fe->id2.i_list,
-                                      clusters_to_add, 0, &data_ac,
-                                      &meta_ac);
+       ocfs2_init_dinode_extent_tree(&et, inode, bh);
+       status = ocfs2_lock_allocators(inode, &et, clusters_to_add, 0,
+                                      &data_ac, &meta_ac);
        if (status) {
                mlog_errno(status);
                goto leave;
@@ -667,10 +670,8 @@ leave:
                restart_func = 0;
                goto restart_all;
        }
-       if (bh) {
-               brelse(bh);
-               bh = NULL;
-       }
+       brelse(bh);
+       bh = NULL;
 
        mlog_exit(status);
        return status;
@@ -937,9 +938,15 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
                        goto bail_unlock;
                }
 
-               if (i_size_read(inode) > attr->ia_size)
+               if (i_size_read(inode) > attr->ia_size) {
+                       if (ocfs2_should_order_data(inode)) {
+                               status = ocfs2_begin_ordered_truncate(inode,
+                                                                     attr->ia_size);
+                               if (status)
+                                       goto bail_unlock;
+                       }
                        status = ocfs2_truncate_file(inode, bh, attr->ia_size);
-               else
+               else
                        status = ocfs2_extend_file(inode, bh, attr->ia_size);
                if (status < 0) {
                        if (status != -ENOSPC)
@@ -981,8 +988,7 @@ bail_unlock_rw:
        if (size_change)
                ocfs2_rw_unlock(inode, 1);
 bail:
-       if (bh)
-               brelse(bh);
+       brelse(bh);
 
        mlog_exit(status);
        return status;
@@ -1125,8 +1131,7 @@ static int ocfs2_write_remove_suid(struct inode *inode)
        struct buffer_head *bh = NULL;
        struct ocfs2_inode_info *oi = OCFS2_I(inode);
 
-       ret = ocfs2_read_block(OCFS2_SB(inode->i_sb),
-                              oi->ip_blkno, &bh, OCFS2_BH_CACHED, inode);
+       ret = ocfs2_read_block(inode, oi->ip_blkno, &bh);
        if (ret < 0) {
                mlog_errno(ret);
                goto out;
@@ -1152,9 +1157,8 @@ static int ocfs2_allocate_unwritten_extents(struct inode *inode,
        struct buffer_head *di_bh = NULL;
 
        if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) {
-               ret = ocfs2_read_block(OCFS2_SB(inode->i_sb),
-                                      OCFS2_I(inode)->ip_blkno, &di_bh,
-                                      OCFS2_BH_CACHED, inode);
+               ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno,
+                                      &di_bh);
                if (ret) {
                        mlog_errno(ret);
                        goto out;
@@ -1235,9 +1239,11 @@ static int __ocfs2_remove_inode_range(struct inode *inode,
        handle_t *handle;
        struct ocfs2_alloc_context *meta_ac = NULL;
        struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data;
+       struct ocfs2_extent_tree et;
+
+       ocfs2_init_dinode_extent_tree(&et, inode, di_bh);
 
-       ret = ocfs2_lock_allocators(inode, di_bh, &di->id2.i_list,
-                                   0, 1, NULL, &meta_ac);
+       ret = ocfs2_lock_allocators(inode, &et, 0, 1, NULL, &meta_ac);
        if (ret) {
                mlog_errno(ret);
                return ret;
@@ -1267,8 +1273,8 @@ static int __ocfs2_remove_inode_range(struct inode *inode,
                goto out;
        }
 
-       ret = ocfs2_remove_extent(inode, di_bh, cpos, len, handle, meta_ac,
-                                 dealloc, OCFS2_DINODE_EXTENT);
+       ret = ocfs2_remove_extent(inode, &et, cpos, len, handle, meta_ac,
+                                 dealloc);
        if (ret) {
                mlog_errno(ret);
                goto out_commit;
@@ -1882,7 +1888,7 @@ out_dio:
                 */
                if (old_size != i_size_read(inode) ||
                    old_clusters != OCFS2_I(inode)->ip_clusters) {
-                       ret = journal_force_commit(osb->journal->j_journal);
+                       ret = jbd2_journal_force_commit(osb->journal->j_journal);
                        if (ret < 0)
                                written = ret;
                }
@@ -2069,6 +2075,10 @@ const struct inode_operations ocfs2_file_iops = {
        .setattr        = ocfs2_setattr,
        .getattr        = ocfs2_getattr,
        .permission     = ocfs2_permission,
+       .setxattr       = generic_setxattr,
+       .getxattr       = generic_getxattr,
+       .listxattr      = ocfs2_listxattr,
+       .removexattr    = generic_removexattr,
        .fallocate      = ocfs2_fallocate,
        .fiemap         = ocfs2_fiemap,
 };