]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/ocfs2/file.c
ocfs2: Better I/O error handling in heartbeat
[linux-2.6-omap-h63xx.git] / fs / ocfs2 / file.c
index 8a4048b55fdc41d5dda4dc5e8b9908e4a765cc64..581eb451a41a36796a2a2d55b7463028d4dae10e 100644 (file)
@@ -220,8 +220,9 @@ static int ocfs2_truncate_file(struct inode *inode,
        struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
        struct ocfs2_truncate_context *tc = NULL;
 
-       mlog_entry("(inode = %"MLFu64", new_i_size = %"MLFu64"\n",
-                  OCFS2_I(inode)->ip_blkno, new_i_size);
+       mlog_entry("(inode = %llu, new_i_size = %llu\n",
+                  (unsigned long long)OCFS2_I(inode)->ip_blkno,
+                  (unsigned long long)new_i_size);
 
        truncate_inode_pages(inode->i_mapping, new_i_size);
 
@@ -233,29 +234,43 @@ static int ocfs2_truncate_file(struct inode *inode,
        }
 
        mlog_bug_on_msg(le64_to_cpu(fe->i_size) != i_size_read(inode),
-                       "Inode %"MLFu64", inode i_size = %lld != di "
-                       "i_size = %"MLFu64", i_flags = 0x%x\n",
-                       OCFS2_I(inode)->ip_blkno,
+                       "Inode %llu, inode i_size = %lld != di "
+                       "i_size = %llu, i_flags = 0x%x\n",
+                       (unsigned long long)OCFS2_I(inode)->ip_blkno,
                        i_size_read(inode),
-                       le64_to_cpu(fe->i_size), le32_to_cpu(fe->i_flags));
+                       (unsigned long long)le64_to_cpu(fe->i_size),
+                       le32_to_cpu(fe->i_flags));
 
        if (new_i_size > le64_to_cpu(fe->i_size)) {
-               mlog(0, "asked to truncate file with size (%"MLFu64") "
-                    "to size (%"MLFu64")!\n",
-                    le64_to_cpu(fe->i_size), new_i_size);
+               mlog(0, "asked to truncate file with size (%llu) to size (%llu)!\n",
+                    (unsigned long long)le64_to_cpu(fe->i_size),
+                    (unsigned long long)new_i_size);
                status = -EINVAL;
                mlog_errno(status);
                goto bail;
        }
 
-       mlog(0, "inode %"MLFu64", i_size = %"MLFu64", new_i_size = %"MLFu64"\n",
-            le64_to_cpu(fe->i_blkno), le64_to_cpu(fe->i_size), new_i_size);
+       mlog(0, "inode %llu, i_size = %llu, new_i_size = %llu\n",
+            (unsigned long long)le64_to_cpu(fe->i_blkno),
+            (unsigned long long)le64_to_cpu(fe->i_size),
+            (unsigned long long)new_i_size);
 
        /* lets handle the simple truncate cases before doing any more
         * cluster locking. */
        if (new_i_size == le64_to_cpu(fe->i_size))
                goto bail;
 
+       /* This forces other nodes to sync and drop their pages. Do
+        * this even if we have a truncate without allocation change -
+        * ocfs2 cluster sizes can be much greater than page size, so
+        * we have to truncate them anyway.  */
+       status = ocfs2_data_lock(inode, 1);
+       if (status < 0) {
+               mlog_errno(status);
+               goto bail;
+       }
+       ocfs2_data_unlock(inode, 1);
+
        if (le32_to_cpu(fe->i_clusters) ==
            ocfs2_clusters_for_bytes(osb->sb, new_i_size)) {
                mlog(0, "fe->i_clusters = %u, so we do a simple truncate\n",
@@ -268,14 +283,6 @@ static int ocfs2_truncate_file(struct inode *inode,
                goto bail;
        }
 
-       /* This forces other nodes to sync and drop their pages */
-       status = ocfs2_data_lock(inode, 1);
-       if (status < 0) {
-               mlog_errno(status);
-               goto bail;
-       }
-       ocfs2_data_unlock(inode, 1);
-
        /* alright, we're going to need to do a full blown alloc size
         * change. Orphan the inode so that recovery can complete the
         * truncate if necessary. This does the task of marking
@@ -378,8 +385,8 @@ int ocfs2_do_extend_allocation(struct ocfs2_super *osb,
        }
 
        block = ocfs2_clusters_to_blocks(osb->sb, bit_off);
-       mlog(0, "Allocating %u clusters at block %u for inode %"MLFu64"\n",
-            num_bits, bit_off, OCFS2_I(inode)->ip_blkno);
+       mlog(0, "Allocating %u clusters at block %u for inode %llu\n",
+            num_bits, bit_off, (unsigned long long)OCFS2_I(inode)->ip_blkno);
        status = ocfs2_insert_extent(osb, handle, inode, fe_bh, block,
                                     num_bits, meta_ac);
        if (status < 0) {
@@ -449,9 +456,9 @@ static int ocfs2_extend_allocation(struct inode *inode,
 restart_all:
        BUG_ON(le32_to_cpu(fe->i_clusters) != OCFS2_I(inode)->ip_clusters);
 
-       mlog(0, "extend inode %"MLFu64", i_size = %lld, fe->i_clusters = %u, "
+       mlog(0, "extend inode %llu, i_size = %lld, fe->i_clusters = %u, "
             "clusters_to_add = %u\n",
-            OCFS2_I(inode)->ip_blkno, i_size_read(inode),
+            (unsigned long long)OCFS2_I(inode)->ip_blkno, i_size_read(inode),
             fe->i_clusters, clusters_to_add);
 
        handle = ocfs2_alloc_handle(osb);
@@ -569,8 +576,8 @@ restarted_transaction:
                }
        }
 
-       mlog(0, "fe: i_clusters = %u, i_size=%"MLFu64"\n",
-            fe->i_clusters, fe->i_size);
+       mlog(0, "fe: i_clusters = %u, i_size=%llu\n",
+            fe->i_clusters, (unsigned long long)fe->i_size);
        mlog(0, "inode: ip_clusters=%u, i_size=%lld\n",
             OCFS2_I(inode)->ip_clusters, i_size_read(inode));
 
@@ -865,8 +872,8 @@ static int ocfs2_write_remove_suid(struct inode *inode)
        struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
        struct ocfs2_dinode *di;
 
-       mlog_entry("(Inode %"MLFu64", mode 0%o)\n", oi->ip_blkno,
-                  inode->i_mode);
+       mlog_entry("(Inode %llu, mode 0%o)\n",
+                  (unsigned long long)oi->ip_blkno, inode->i_mode);
 
        handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS);
        if (handle == NULL) {
@@ -1172,7 +1179,7 @@ struct inode_operations ocfs2_special_file_iops = {
        .getattr        = ocfs2_getattr,
 };
 
-struct file_operations ocfs2_fops = {
+const struct file_operations ocfs2_fops = {
        .read           = do_sync_read,
        .write          = do_sync_write,
        .sendfile       = generic_file_sendfile,
@@ -1184,7 +1191,7 @@ struct file_operations ocfs2_fops = {
        .aio_write      = ocfs2_file_aio_write,
 };
 
-struct file_operations ocfs2_dops = {
+const struct file_operations ocfs2_dops = {
        .read           = generic_read_dir,
        .readdir        = ocfs2_readdir,
        .fsync          = ocfs2_sync_file,