]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/ocfs2/file.c
ocfs2: pass ocfs2_super * into ocfs2_commit_trans()
[karo-tx-linux.git] / fs / ocfs2 / file.c
index d9ba0a931a03b89aa5c9a894b040470db459e05b..9eb60f21968dbf2b357ba882315fa12a3c3bbbc2 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/highmem.h>
 #include <linux/pagemap.h>
 #include <linux/uio.h>
+#include <linux/sched.h>
 
 #define MLOG_MASK_PREFIX ML_INODE
 #include <cluster/masklog.h>
@@ -177,7 +178,7 @@ static int ocfs2_simple_size_update(struct inode *inode,
        if (ret < 0)
                mlog_errno(ret);
 
-       ocfs2_commit_trans(handle);
+       ocfs2_commit_trans(osb, handle);
 out:
        return ret;
 }
@@ -206,7 +207,7 @@ static int ocfs2_orphan_for_truncate(struct ocfs2_super *osb,
        if (status < 0)
                mlog_errno(status);
 
-       ocfs2_commit_trans(handle);
+       ocfs2_commit_trans(osb, handle);
 out:
        mlog_exit(status);
        return status;
@@ -462,13 +463,6 @@ restart_all:
             (unsigned long long)OCFS2_I(inode)->ip_blkno, i_size_read(inode),
             fe->i_clusters, clusters_to_add);
 
-       handle = ocfs2_alloc_handle(osb);
-       if (handle == NULL) {
-               status = -ENOMEM;
-               mlog_errno(status);
-               goto leave;
-       }
-
        num_free_extents = ocfs2_num_free_extents(osb,
                                                  inode,
                                                  fe);
@@ -479,10 +473,7 @@ restart_all:
        }
 
        if (!num_free_extents) {
-               status = ocfs2_reserve_new_metadata(osb,
-                                                   handle,
-                                                   fe,
-                                                   &meta_ac);
+               status = ocfs2_reserve_new_metadata(osb, fe, &meta_ac);
                if (status < 0) {
                        if (status != -ENOSPC)
                                mlog_errno(status);
@@ -490,10 +481,7 @@ restart_all:
                }
        }
 
-       status = ocfs2_reserve_clusters(osb,
-                                       handle,
-                                       clusters_to_add,
-                                       &data_ac);
+       status = ocfs2_reserve_clusters(osb, clusters_to_add, &data_ac);
        if (status < 0) {
                if (status != -ENOSPC)
                        mlog_errno(status);
@@ -508,7 +496,7 @@ restart_all:
        drop_alloc_sem = 1;
 
        credits = ocfs2_calc_extend_credits(osb->sb, fe, clusters_to_add);
-       handle = ocfs2_start_trans(osb, handle, credits);
+       handle = ocfs2_start_trans(osb, NULL, credits);
        if (IS_ERR(handle)) {
                status = PTR_ERR(handle);
                handle = NULL;
@@ -565,7 +553,7 @@ restarted_transaction:
                        credits = ocfs2_calc_extend_credits(osb->sb,
                                                            fe,
                                                            clusters_to_add);
-                       status = ocfs2_extend_trans(handle, credits);
+                       status = ocfs2_extend_trans(handle->k_handle, credits);
                        if (status < 0) {
                                /* handle still has to be committed at
                                 * this point. */
@@ -588,7 +576,7 @@ leave:
                drop_alloc_sem = 0;
        }
        if (handle) {
-               ocfs2_commit_trans(handle);
+               ocfs2_commit_trans(osb, handle);
                handle = NULL;
        }
        if (data_ac) {
@@ -667,7 +655,7 @@ static int ocfs2_write_zero_page(struct inode *inode,
                ret = 0;
 
        if (handle)
-               ocfs2_commit_trans(handle);
+               ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle);
 out_unlock:
        unlock_page(page);
        page_cache_release(page);
@@ -691,6 +679,12 @@ static int ocfs2_zero_extend(struct inode *inode,
                }
 
                start_off += sb->s_blocksize;
+
+               /*
+                * Very large extends have the potential to lock up
+                * the cpu for extended periods of time.
+                */
+               cond_resched();
        }
 
 out:
@@ -728,31 +722,36 @@ static int ocfs2_extend_file(struct inode *inode,
        clusters_to_add = ocfs2_clusters_for_bytes(inode->i_sb, new_i_size) - 
                OCFS2_I(inode)->ip_clusters;
 
-       if (clusters_to_add) {
-               /* 
-                * protect the pages that ocfs2_zero_extend is going to
-                * be pulling into the page cache.. we do this before the
-                * metadata extend so that we don't get into the situation
-                * where we've extended the metadata but can't get the data
-                * lock to zero.
-                */
-               ret = ocfs2_data_lock(inode, 1);
-               if (ret < 0) {
-                       mlog_errno(ret);
-                       goto out;
-               }
+       /* 
+        * protect the pages that ocfs2_zero_extend is going to be
+        * pulling into the page cache.. we do this before the
+        * metadata extend so that we don't get into the situation
+        * where we've extended the metadata but can't get the data
+        * lock to zero.
+        */
+       ret = ocfs2_data_lock(inode, 1);
+       if (ret < 0) {
+               mlog_errno(ret);
+               goto out;
+       }
 
+       if (clusters_to_add) {
                ret = ocfs2_extend_allocation(inode, clusters_to_add);
                if (ret < 0) {
                        mlog_errno(ret);
                        goto out_unlock;
                }
+       }
 
-               ret = ocfs2_zero_extend(inode, (u64)new_i_size - tail_to_skip);
-               if (ret < 0) {
-                       mlog_errno(ret);
-                       goto out_unlock;
-               }
+       /*
+        * Call this even if we don't add any clusters to the tree. We
+        * still need to zero the area between the old i_size and the
+        * new i_size.
+        */
+       ret = ocfs2_zero_extend(inode, (u64)new_i_size - tail_to_skip);
+       if (ret < 0) {
+               mlog_errno(ret);
+               goto out_unlock;
        }
 
        if (!tail_to_skip) {
@@ -764,8 +763,7 @@ static int ocfs2_extend_file(struct inode *inode,
        }
 
 out_unlock:
-       if (clusters_to_add) /* this is the only case in which we lock */
-               ocfs2_data_unlock(inode, 1);
+       ocfs2_data_unlock(inode, 1);
 
 out:
        return ret;
@@ -814,7 +812,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
                }
        }
 
-       status = ocfs2_meta_lock(inode, NULL, &bh, 1);
+       status = ocfs2_meta_lock(inode, &bh, 1);
        if (status < 0) {
                if (status != -ENOENT)
                        mlog_errno(status);
@@ -852,7 +850,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
                mlog_errno(status);
 
 bail_commit:
-       ocfs2_commit_trans(handle);
+       ocfs2_commit_trans(osb, handle);
 bail_unlock:
        ocfs2_meta_unlock(inode, 1);
 bail_unlock_rw:
@@ -940,7 +938,7 @@ static int ocfs2_write_remove_suid(struct inode *inode)
 out_bh:
        brelse(bh);
 out_trans:
-       ocfs2_commit_trans(handle);
+       ocfs2_commit_trans(osb, handle);
 out:
        mlog_exit(ret);
        return ret;
@@ -1008,7 +1006,7 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
         */
        meta_level = (filp->f_flags & O_APPEND) ? 1 : 0;
        for(;;) {
-               ret = ocfs2_meta_lock(inode, NULL, NULL, meta_level);
+               ret = ocfs2_meta_lock(inode, NULL, meta_level);
                if (ret < 0) {
                        meta_level = -1;
                        mlog_errno(ret);
@@ -1176,7 +1174,7 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb,
         * like i_size. This allows the checks down below
         * generic_file_aio_read() a chance of actually working. 
         */
-       ret = ocfs2_meta_lock(inode, NULL, NULL, 0);
+       ret = ocfs2_meta_lock(inode, NULL, 0);
        if (ret < 0) {
                mlog_errno(ret);
                goto bail;