aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2/file.c')
-rw-r--r--fs/ocfs2/file.c350
1 files changed, 178 insertions, 172 deletions
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 9a03c151b5ce..b1e35a392ca5 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -38,7 +38,6 @@
38#include <linux/quotaops.h> 38#include <linux/quotaops.h>
39#include <linux/blkdev.h> 39#include <linux/blkdev.h>
40 40
41#define MLOG_MASK_PREFIX ML_INODE
42#include <cluster/masklog.h> 41#include <cluster/masklog.h>
43 42
44#include "ocfs2.h" 43#include "ocfs2.h"
@@ -61,15 +60,10 @@
61#include "acl.h" 60#include "acl.h"
62#include "quota.h" 61#include "quota.h"
63#include "refcounttree.h" 62#include "refcounttree.h"
63#include "ocfs2_trace.h"
64 64
65#include "buffer_head_io.h" 65#include "buffer_head_io.h"
66 66
67static int ocfs2_sync_inode(struct inode *inode)
68{
69 filemap_fdatawrite(inode->i_mapping);
70 return sync_mapping_buffers(inode->i_mapping);
71}
72
73static int ocfs2_init_file_private(struct inode *inode, struct file *file) 67static int ocfs2_init_file_private(struct inode *inode, struct file *file)
74{ 68{
75 struct ocfs2_file_private *fp; 69 struct ocfs2_file_private *fp;
@@ -105,8 +99,10 @@ static int ocfs2_file_open(struct inode *inode, struct file *file)
105 int mode = file->f_flags; 99 int mode = file->f_flags;
106 struct ocfs2_inode_info *oi = OCFS2_I(inode); 100 struct ocfs2_inode_info *oi = OCFS2_I(inode);
107 101
108 mlog_entry("(0x%p, 0x%p, '%.*s')\n", inode, file, 102 trace_ocfs2_file_open(inode, file, file->f_path.dentry,
109 file->f_path.dentry->d_name.len, file->f_path.dentry->d_name.name); 103 (unsigned long long)OCFS2_I(inode)->ip_blkno,
104 file->f_path.dentry->d_name.len,
105 file->f_path.dentry->d_name.name, mode);
110 106
111 if (file->f_mode & FMODE_WRITE) 107 if (file->f_mode & FMODE_WRITE)
112 dquot_initialize(inode); 108 dquot_initialize(inode);
@@ -141,7 +137,6 @@ static int ocfs2_file_open(struct inode *inode, struct file *file)
141 } 137 }
142 138
143leave: 139leave:
144 mlog_exit(status);
145 return status; 140 return status;
146} 141}
147 142
@@ -149,19 +144,19 @@ static int ocfs2_file_release(struct inode *inode, struct file *file)
149{ 144{
150 struct ocfs2_inode_info *oi = OCFS2_I(inode); 145 struct ocfs2_inode_info *oi = OCFS2_I(inode);
151 146
152 mlog_entry("(0x%p, 0x%p, '%.*s')\n", inode, file,
153 file->f_path.dentry->d_name.len,
154 file->f_path.dentry->d_name.name);
155
156 spin_lock(&oi->ip_lock); 147 spin_lock(&oi->ip_lock);
157 if (!--oi->ip_open_count) 148 if (!--oi->ip_open_count)
158 oi->ip_flags &= ~OCFS2_INODE_OPEN_DIRECT; 149 oi->ip_flags &= ~OCFS2_INODE_OPEN_DIRECT;
150
151 trace_ocfs2_file_release(inode, file, file->f_path.dentry,
152 oi->ip_blkno,
153 file->f_path.dentry->d_name.len,
154 file->f_path.dentry->d_name.name,
155 oi->ip_open_count);
159 spin_unlock(&oi->ip_lock); 156 spin_unlock(&oi->ip_lock);
160 157
161 ocfs2_free_file_private(inode, file); 158 ocfs2_free_file_private(inode, file);
162 159
163 mlog_exit(0);
164
165 return 0; 160 return 0;
166} 161}
167 162
@@ -180,16 +175,14 @@ static int ocfs2_sync_file(struct file *file, int datasync)
180{ 175{
181 int err = 0; 176 int err = 0;
182 journal_t *journal; 177 journal_t *journal;
183 struct dentry *dentry = file->f_path.dentry;
184 struct inode *inode = file->f_mapping->host; 178 struct inode *inode = file->f_mapping->host;
185 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 179 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
186 180
187 mlog_entry("(0x%p, 0x%p, %d, '%.*s')\n", file, dentry, datasync, 181 trace_ocfs2_sync_file(inode, file, file->f_path.dentry,
188 dentry->d_name.len, dentry->d_name.name); 182 OCFS2_I(inode)->ip_blkno,
189 183 file->f_path.dentry->d_name.len,
190 err = ocfs2_sync_inode(dentry->d_inode); 184 file->f_path.dentry->d_name.name,
191 if (err) 185 (unsigned long long)datasync);
192 goto bail;
193 186
194 if (datasync && !(inode->i_state & I_DIRTY_DATASYNC)) { 187 if (datasync && !(inode->i_state & I_DIRTY_DATASYNC)) {
195 /* 188 /*
@@ -197,8 +190,7 @@ static int ocfs2_sync_file(struct file *file, int datasync)
197 * platter 190 * platter
198 */ 191 */
199 if (osb->s_mount_opt & OCFS2_MOUNT_BARRIER) 192 if (osb->s_mount_opt & OCFS2_MOUNT_BARRIER)
200 blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, 193 blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
201 NULL, BLKDEV_IFL_WAIT);
202 goto bail; 194 goto bail;
203 } 195 }
204 196
@@ -206,7 +198,8 @@ static int ocfs2_sync_file(struct file *file, int datasync)
206 err = jbd2_journal_force_commit(journal); 198 err = jbd2_journal_force_commit(journal);
207 199
208bail: 200bail:
209 mlog_exit(err); 201 if (err)
202 mlog_errno(err);
210 203
211 return (err < 0) ? -EIO : 0; 204 return (err < 0) ? -EIO : 0;
212} 205}
@@ -262,8 +255,6 @@ int ocfs2_update_inode_atime(struct inode *inode,
262 handle_t *handle; 255 handle_t *handle;
263 struct ocfs2_dinode *di = (struct ocfs2_dinode *) bh->b_data; 256 struct ocfs2_dinode *di = (struct ocfs2_dinode *) bh->b_data;
264 257
265 mlog_entry_void();
266
267 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); 258 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
268 if (IS_ERR(handle)) { 259 if (IS_ERR(handle)) {
269 ret = PTR_ERR(handle); 260 ret = PTR_ERR(handle);
@@ -291,7 +282,6 @@ int ocfs2_update_inode_atime(struct inode *inode,
291out_commit: 282out_commit:
292 ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle); 283 ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle);
293out: 284out:
294 mlog_exit(ret);
295 return ret; 285 return ret;
296} 286}
297 287
@@ -302,7 +292,6 @@ static int ocfs2_set_inode_size(handle_t *handle,
302{ 292{
303 int status; 293 int status;
304 294
305 mlog_entry_void();
306 i_size_write(inode, new_i_size); 295 i_size_write(inode, new_i_size);
307 inode->i_blocks = ocfs2_inode_sector_count(inode); 296 inode->i_blocks = ocfs2_inode_sector_count(inode);
308 inode->i_ctime = inode->i_mtime = CURRENT_TIME; 297 inode->i_ctime = inode->i_mtime = CURRENT_TIME;
@@ -314,7 +303,6 @@ static int ocfs2_set_inode_size(handle_t *handle,
314 } 303 }
315 304
316bail: 305bail:
317 mlog_exit(status);
318 return status; 306 return status;
319} 307}
320 308
@@ -370,7 +358,7 @@ static int ocfs2_cow_file_pos(struct inode *inode,
370 if (!(ext_flags & OCFS2_EXT_REFCOUNTED)) 358 if (!(ext_flags & OCFS2_EXT_REFCOUNTED))
371 goto out; 359 goto out;
372 360
373 return ocfs2_refcount_cow(inode, fe_bh, cpos, 1, cpos+1); 361 return ocfs2_refcount_cow(inode, NULL, fe_bh, cpos, 1, cpos+1);
374 362
375out: 363out:
376 return status; 364 return status;
@@ -386,8 +374,6 @@ static int ocfs2_orphan_for_truncate(struct ocfs2_super *osb,
386 struct ocfs2_dinode *di; 374 struct ocfs2_dinode *di;
387 u64 cluster_bytes; 375 u64 cluster_bytes;
388 376
389 mlog_entry_void();
390
391 /* 377 /*
392 * We need to CoW the cluster contains the offset if it is reflinked 378 * We need to CoW the cluster contains the offset if it is reflinked
393 * since we will call ocfs2_zero_range_for_truncate later which will 379 * since we will call ocfs2_zero_range_for_truncate later which will
@@ -440,8 +426,6 @@ static int ocfs2_orphan_for_truncate(struct ocfs2_super *osb,
440out_commit: 426out_commit:
441 ocfs2_commit_trans(osb, handle); 427 ocfs2_commit_trans(osb, handle);
442out: 428out:
443
444 mlog_exit(status);
445 return status; 429 return status;
446} 430}
447 431
@@ -453,14 +437,14 @@ static int ocfs2_truncate_file(struct inode *inode,
453 struct ocfs2_dinode *fe = NULL; 437 struct ocfs2_dinode *fe = NULL;
454 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 438 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
455 439
456 mlog_entry("(inode = %llu, new_i_size = %llu\n",
457 (unsigned long long)OCFS2_I(inode)->ip_blkno,
458 (unsigned long long)new_i_size);
459
460 /* We trust di_bh because it comes from ocfs2_inode_lock(), which 440 /* We trust di_bh because it comes from ocfs2_inode_lock(), which
461 * already validated it */ 441 * already validated it */
462 fe = (struct ocfs2_dinode *) di_bh->b_data; 442 fe = (struct ocfs2_dinode *) di_bh->b_data;
463 443
444 trace_ocfs2_truncate_file((unsigned long long)OCFS2_I(inode)->ip_blkno,
445 (unsigned long long)le64_to_cpu(fe->i_size),
446 (unsigned long long)new_i_size);
447
464 mlog_bug_on_msg(le64_to_cpu(fe->i_size) != i_size_read(inode), 448 mlog_bug_on_msg(le64_to_cpu(fe->i_size) != i_size_read(inode),
465 "Inode %llu, inode i_size = %lld != di " 449 "Inode %llu, inode i_size = %lld != di "
466 "i_size = %llu, i_flags = 0x%x\n", 450 "i_size = %llu, i_flags = 0x%x\n",
@@ -470,19 +454,14 @@ static int ocfs2_truncate_file(struct inode *inode,
470 le32_to_cpu(fe->i_flags)); 454 le32_to_cpu(fe->i_flags));
471 455
472 if (new_i_size > le64_to_cpu(fe->i_size)) { 456 if (new_i_size > le64_to_cpu(fe->i_size)) {
473 mlog(0, "asked to truncate file with size (%llu) to size (%llu)!\n", 457 trace_ocfs2_truncate_file_error(
474 (unsigned long long)le64_to_cpu(fe->i_size), 458 (unsigned long long)le64_to_cpu(fe->i_size),
475 (unsigned long long)new_i_size); 459 (unsigned long long)new_i_size);
476 status = -EINVAL; 460 status = -EINVAL;
477 mlog_errno(status); 461 mlog_errno(status);
478 goto bail; 462 goto bail;
479 } 463 }
480 464
481 mlog(0, "inode %llu, i_size = %llu, new_i_size = %llu\n",
482 (unsigned long long)le64_to_cpu(fe->i_blkno),
483 (unsigned long long)le64_to_cpu(fe->i_size),
484 (unsigned long long)new_i_size);
485
486 /* lets handle the simple truncate cases before doing any more 465 /* lets handle the simple truncate cases before doing any more
487 * cluster locking. */ 466 * cluster locking. */
488 if (new_i_size == le64_to_cpu(fe->i_size)) 467 if (new_i_size == le64_to_cpu(fe->i_size))
@@ -536,7 +515,6 @@ bail:
536 if (!status && OCFS2_I(inode)->ip_clusters == 0) 515 if (!status && OCFS2_I(inode)->ip_clusters == 0)
537 status = ocfs2_try_remove_refcount_tree(inode, di_bh); 516 status = ocfs2_try_remove_refcount_tree(inode, di_bh);
538 517
539 mlog_exit(status);
540 return status; 518 return status;
541} 519}
542 520
@@ -589,8 +567,6 @@ static int __ocfs2_extend_allocation(struct inode *inode, u32 logical_start,
589 struct ocfs2_extent_tree et; 567 struct ocfs2_extent_tree et;
590 int did_quota = 0; 568 int did_quota = 0;
591 569
592 mlog_entry("(clusters_to_add = %u)\n", clusters_to_add);
593
594 /* 570 /*
595 * This function only exists for file systems which don't 571 * This function only exists for file systems which don't
596 * support holes. 572 * support holes.
@@ -607,11 +583,6 @@ static int __ocfs2_extend_allocation(struct inode *inode, u32 logical_start,
607restart_all: 583restart_all:
608 BUG_ON(le32_to_cpu(fe->i_clusters) != OCFS2_I(inode)->ip_clusters); 584 BUG_ON(le32_to_cpu(fe->i_clusters) != OCFS2_I(inode)->ip_clusters);
609 585
610 mlog(0, "extend inode %llu, i_size = %lld, di->i_clusters = %u, "
611 "clusters_to_add = %u\n",
612 (unsigned long long)OCFS2_I(inode)->ip_blkno,
613 (long long)i_size_read(inode), le32_to_cpu(fe->i_clusters),
614 clusters_to_add);
615 ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(inode), bh); 586 ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(inode), bh);
616 status = ocfs2_lock_allocators(inode, &et, clusters_to_add, 0, 587 status = ocfs2_lock_allocators(inode, &et, clusters_to_add, 0,
617 &data_ac, &meta_ac); 588 &data_ac, &meta_ac);
@@ -631,6 +602,12 @@ restart_all:
631 } 602 }
632 603
633restarted_transaction: 604restarted_transaction:
605 trace_ocfs2_extend_allocation(
606 (unsigned long long)OCFS2_I(inode)->ip_blkno,
607 (unsigned long long)i_size_read(inode),
608 le32_to_cpu(fe->i_clusters), clusters_to_add,
609 why, restart_func);
610
634 status = dquot_alloc_space_nodirty(inode, 611 status = dquot_alloc_space_nodirty(inode,
635 ocfs2_clusters_to_bytes(osb->sb, clusters_to_add)); 612 ocfs2_clusters_to_bytes(osb->sb, clusters_to_add));
636 if (status) 613 if (status)
@@ -677,13 +654,11 @@ restarted_transaction:
677 654
678 if (why != RESTART_NONE && clusters_to_add) { 655 if (why != RESTART_NONE && clusters_to_add) {
679 if (why == RESTART_META) { 656 if (why == RESTART_META) {
680 mlog(0, "restarting function.\n");
681 restart_func = 1; 657 restart_func = 1;
682 status = 0; 658 status = 0;
683 } else { 659 } else {
684 BUG_ON(why != RESTART_TRANS); 660 BUG_ON(why != RESTART_TRANS);
685 661
686 mlog(0, "restarting transaction.\n");
687 /* TODO: This can be more intelligent. */ 662 /* TODO: This can be more intelligent. */
688 credits = ocfs2_calc_extend_credits(osb->sb, 663 credits = ocfs2_calc_extend_credits(osb->sb,
689 &fe->id2.i_list, 664 &fe->id2.i_list,
@@ -700,11 +675,11 @@ restarted_transaction:
700 } 675 }
701 } 676 }
702 677
703 mlog(0, "fe: i_clusters = %u, i_size=%llu\n", 678 trace_ocfs2_extend_allocation_end(OCFS2_I(inode)->ip_blkno,
704 le32_to_cpu(fe->i_clusters), 679 le32_to_cpu(fe->i_clusters),
705 (unsigned long long)le64_to_cpu(fe->i_size)); 680 (unsigned long long)le64_to_cpu(fe->i_size),
706 mlog(0, "inode: ip_clusters=%u, i_size=%lld\n", 681 OCFS2_I(inode)->ip_clusters,
707 OCFS2_I(inode)->ip_clusters, (long long)i_size_read(inode)); 682 (unsigned long long)i_size_read(inode));
708 683
709leave: 684leave:
710 if (status < 0 && did_quota) 685 if (status < 0 && did_quota)
@@ -729,7 +704,6 @@ leave:
729 brelse(bh); 704 brelse(bh);
730 bh = NULL; 705 bh = NULL;
731 706
732 mlog_exit(status);
733 return status; 707 return status;
734} 708}
735 709
@@ -796,10 +770,11 @@ static int ocfs2_write_zero_page(struct inode *inode, u64 abs_from,
796 if (!zero_to) 770 if (!zero_to)
797 zero_to = PAGE_CACHE_SIZE; 771 zero_to = PAGE_CACHE_SIZE;
798 772
799 mlog(0, 773 trace_ocfs2_write_zero_page(
800 "abs_from = %llu, abs_to = %llu, index = %lu, zero_from = %u, zero_to = %u\n", 774 (unsigned long long)OCFS2_I(inode)->ip_blkno,
801 (unsigned long long)abs_from, (unsigned long long)abs_to, 775 (unsigned long long)abs_from,
802 index, zero_from, zero_to); 776 (unsigned long long)abs_to,
777 index, zero_from, zero_to);
803 778
804 /* We know that zero_from is block aligned */ 779 /* We know that zero_from is block aligned */
805 for (block_start = zero_from; block_start < zero_to; 780 for (block_start = zero_from; block_start < zero_to;
@@ -807,13 +782,12 @@ static int ocfs2_write_zero_page(struct inode *inode, u64 abs_from,
807 block_end = block_start + (1 << inode->i_blkbits); 782 block_end = block_start + (1 << inode->i_blkbits);
808 783
809 /* 784 /*
810 * block_start is block-aligned. Bump it by one to 785 * block_start is block-aligned. Bump it by one to force
811 * force ocfs2_{prepare,commit}_write() to zero the 786 * __block_write_begin and block_commit_write to zero the
812 * whole block. 787 * whole block.
813 */ 788 */
814 ret = ocfs2_prepare_write_nolock(inode, page, 789 ret = __block_write_begin(page, block_start + 1, 0,
815 block_start + 1, 790 ocfs2_get_block);
816 block_start + 1);
817 if (ret < 0) { 791 if (ret < 0) {
818 mlog_errno(ret); 792 mlog_errno(ret);
819 goto out_unlock; 793 goto out_unlock;
@@ -913,8 +887,8 @@ static int ocfs2_zero_extend_get_range(struct inode *inode,
913 zero_clusters = last_cpos - zero_cpos; 887 zero_clusters = last_cpos - zero_cpos;
914 888
915 if (needs_cow) { 889 if (needs_cow) {
916 rc = ocfs2_refcount_cow(inode, di_bh, zero_cpos, zero_clusters, 890 rc = ocfs2_refcount_cow(inode, NULL, di_bh, zero_cpos,
917 UINT_MAX); 891 zero_clusters, UINT_MAX);
918 if (rc) { 892 if (rc) {
919 mlog_errno(rc); 893 mlog_errno(rc);
920 goto out; 894 goto out;
@@ -940,9 +914,10 @@ static int ocfs2_zero_extend_range(struct inode *inode, u64 range_start,
940 u64 next_pos; 914 u64 next_pos;
941 u64 zero_pos = range_start; 915 u64 zero_pos = range_start;
942 916
943 mlog(0, "range_start = %llu, range_end = %llu\n", 917 trace_ocfs2_zero_extend_range(
944 (unsigned long long)range_start, 918 (unsigned long long)OCFS2_I(inode)->ip_blkno,
945 (unsigned long long)range_end); 919 (unsigned long long)range_start,
920 (unsigned long long)range_end);
946 BUG_ON(range_start >= range_end); 921 BUG_ON(range_start >= range_end);
947 922
948 while (zero_pos < range_end) { 923 while (zero_pos < range_end) {
@@ -974,9 +949,9 @@ int ocfs2_zero_extend(struct inode *inode, struct buffer_head *di_bh,
974 struct super_block *sb = inode->i_sb; 949 struct super_block *sb = inode->i_sb;
975 950
976 zero_start = ocfs2_align_bytes_to_blocks(sb, i_size_read(inode)); 951 zero_start = ocfs2_align_bytes_to_blocks(sb, i_size_read(inode));
977 mlog(0, "zero_start %llu for i_size %llu\n", 952 trace_ocfs2_zero_extend((unsigned long long)OCFS2_I(inode)->ip_blkno,
978 (unsigned long long)zero_start, 953 (unsigned long long)zero_start,
979 (unsigned long long)i_size_read(inode)); 954 (unsigned long long)i_size_read(inode));
980 while (zero_start < zero_to_size) { 955 while (zero_start < zero_to_size) {
981 ret = ocfs2_zero_extend_get_range(inode, di_bh, zero_start, 956 ret = ocfs2_zero_extend_get_range(inode, di_bh, zero_start,
982 zero_to_size, 957 zero_to_size,
@@ -1125,30 +1100,20 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
1125 struct dquot *transfer_to[MAXQUOTAS] = { }; 1100 struct dquot *transfer_to[MAXQUOTAS] = { };
1126 int qtype; 1101 int qtype;
1127 1102
1128 mlog_entry("(0x%p, '%.*s')\n", dentry, 1103 trace_ocfs2_setattr(inode, dentry,
1129 dentry->d_name.len, dentry->d_name.name); 1104 (unsigned long long)OCFS2_I(inode)->ip_blkno,
1105 dentry->d_name.len, dentry->d_name.name,
1106 attr->ia_valid, attr->ia_mode,
1107 attr->ia_uid, attr->ia_gid);
1130 1108
1131 /* ensuring we don't even attempt to truncate a symlink */ 1109 /* ensuring we don't even attempt to truncate a symlink */
1132 if (S_ISLNK(inode->i_mode)) 1110 if (S_ISLNK(inode->i_mode))
1133 attr->ia_valid &= ~ATTR_SIZE; 1111 attr->ia_valid &= ~ATTR_SIZE;
1134 1112
1135 if (attr->ia_valid & ATTR_MODE)
1136 mlog(0, "mode change: %d\n", attr->ia_mode);
1137 if (attr->ia_valid & ATTR_UID)
1138 mlog(0, "uid change: %d\n", attr->ia_uid);
1139 if (attr->ia_valid & ATTR_GID)
1140 mlog(0, "gid change: %d\n", attr->ia_gid);
1141 if (attr->ia_valid & ATTR_SIZE)
1142 mlog(0, "size change...\n");
1143 if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
1144 mlog(0, "time change...\n");
1145
1146#define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \ 1113#define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
1147 | ATTR_GID | ATTR_UID | ATTR_MODE) 1114 | ATTR_GID | ATTR_UID | ATTR_MODE)
1148 if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) { 1115 if (!(attr->ia_valid & OCFS2_VALID_ATTRS))
1149 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
1150 return 0; 1116 return 0;
1151 }
1152 1117
1153 status = inode_change_ok(inode, attr); 1118 status = inode_change_ok(inode, attr);
1154 if (status) 1119 if (status)
@@ -1286,7 +1251,6 @@ bail:
1286 mlog_errno(status); 1251 mlog_errno(status);
1287 } 1252 }
1288 1253
1289 mlog_exit(status);
1290 return status; 1254 return status;
1291} 1255}
1292 1256
@@ -1299,8 +1263,6 @@ int ocfs2_getattr(struct vfsmount *mnt,
1299 struct ocfs2_super *osb = sb->s_fs_info; 1263 struct ocfs2_super *osb = sb->s_fs_info;
1300 int err; 1264 int err;
1301 1265
1302 mlog_entry_void();
1303
1304 err = ocfs2_inode_revalidate(dentry); 1266 err = ocfs2_inode_revalidate(dentry);
1305 if (err) { 1267 if (err) {
1306 if (err != -ENOENT) 1268 if (err != -ENOENT)
@@ -1314,16 +1276,15 @@ int ocfs2_getattr(struct vfsmount *mnt,
1314 stat->blksize = osb->s_clustersize; 1276 stat->blksize = osb->s_clustersize;
1315 1277
1316bail: 1278bail:
1317 mlog_exit(err);
1318
1319 return err; 1279 return err;
1320} 1280}
1321 1281
1322int ocfs2_permission(struct inode *inode, int mask) 1282int ocfs2_permission(struct inode *inode, int mask, unsigned int flags)
1323{ 1283{
1324 int ret; 1284 int ret;
1325 1285
1326 mlog_entry_void(); 1286 if (flags & IPERM_FLAG_RCU)
1287 return -ECHILD;
1327 1288
1328 ret = ocfs2_inode_lock(inode, NULL, 0); 1289 ret = ocfs2_inode_lock(inode, NULL, 0);
1329 if (ret) { 1290 if (ret) {
@@ -1332,11 +1293,10 @@ int ocfs2_permission(struct inode *inode, int mask)
1332 goto out; 1293 goto out;
1333 } 1294 }
1334 1295
1335 ret = generic_permission(inode, mask, ocfs2_check_acl); 1296 ret = generic_permission(inode, mask, flags, ocfs2_check_acl);
1336 1297
1337 ocfs2_inode_unlock(inode, 0); 1298 ocfs2_inode_unlock(inode, 0);
1338out: 1299out:
1339 mlog_exit(ret);
1340 return ret; 1300 return ret;
1341} 1301}
1342 1302
@@ -1348,8 +1308,9 @@ static int __ocfs2_write_remove_suid(struct inode *inode,
1348 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 1308 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1349 struct ocfs2_dinode *di; 1309 struct ocfs2_dinode *di;
1350 1310
1351 mlog_entry("(Inode %llu, mode 0%o)\n", 1311 trace_ocfs2_write_remove_suid(
1352 (unsigned long long)OCFS2_I(inode)->ip_blkno, inode->i_mode); 1312 (unsigned long long)OCFS2_I(inode)->ip_blkno,
1313 inode->i_mode);
1353 1314
1354 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); 1315 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
1355 if (IS_ERR(handle)) { 1316 if (IS_ERR(handle)) {
@@ -1377,7 +1338,6 @@ static int __ocfs2_write_remove_suid(struct inode *inode,
1377out_trans: 1338out_trans:
1378 ocfs2_commit_trans(osb, handle); 1339 ocfs2_commit_trans(osb, handle);
1379out: 1340out:
1380 mlog_exit(ret);
1381 return ret; 1341 return ret;
1382} 1342}
1383 1343
@@ -1556,8 +1516,9 @@ static int ocfs2_zero_partial_clusters(struct inode *inode,
1556 * partial clusters here. There's no need to worry about 1516 * partial clusters here. There's no need to worry about
1557 * physical allocation - the zeroing code knows to skip holes. 1517 * physical allocation - the zeroing code knows to skip holes.
1558 */ 1518 */
1559 mlog(0, "byte start: %llu, end: %llu\n", 1519 trace_ocfs2_zero_partial_clusters(
1560 (unsigned long long)start, (unsigned long long)end); 1520 (unsigned long long)OCFS2_I(inode)->ip_blkno,
1521 (unsigned long long)start, (unsigned long long)end);
1561 1522
1562 /* 1523 /*
1563 * If both edges are on a cluster boundary then there's no 1524 * If both edges are on a cluster boundary then there's no
@@ -1581,8 +1542,8 @@ static int ocfs2_zero_partial_clusters(struct inode *inode,
1581 if (tmpend > end) 1542 if (tmpend > end)
1582 tmpend = end; 1543 tmpend = end;
1583 1544
1584 mlog(0, "1st range: start: %llu, tmpend: %llu\n", 1545 trace_ocfs2_zero_partial_clusters_range1((unsigned long long)start,
1585 (unsigned long long)start, (unsigned long long)tmpend); 1546 (unsigned long long)tmpend);
1586 1547
1587 ret = ocfs2_zero_range_for_truncate(inode, handle, start, tmpend); 1548 ret = ocfs2_zero_range_for_truncate(inode, handle, start, tmpend);
1588 if (ret) 1549 if (ret)
@@ -1596,8 +1557,8 @@ static int ocfs2_zero_partial_clusters(struct inode *inode,
1596 */ 1557 */
1597 start = end & ~(osb->s_clustersize - 1); 1558 start = end & ~(osb->s_clustersize - 1);
1598 1559
1599 mlog(0, "2nd range: start: %llu, end: %llu\n", 1560 trace_ocfs2_zero_partial_clusters_range2(
1600 (unsigned long long)start, (unsigned long long)end); 1561 (unsigned long long)start, (unsigned long long)end);
1601 1562
1602 ret = ocfs2_zero_range_for_truncate(inode, handle, start, end); 1563 ret = ocfs2_zero_range_for_truncate(inode, handle, start, end);
1603 if (ret) 1564 if (ret)
@@ -1646,6 +1607,9 @@ static void ocfs2_calc_trunc_pos(struct inode *inode,
1646 range = le32_to_cpu(rec->e_cpos) + ocfs2_rec_clusters(el, rec); 1607 range = le32_to_cpu(rec->e_cpos) + ocfs2_rec_clusters(el, rec);
1647 1608
1648 if (le32_to_cpu(rec->e_cpos) >= trunc_start) { 1609 if (le32_to_cpu(rec->e_cpos) >= trunc_start) {
1610 /*
1611 * remove an entire extent record.
1612 */
1649 *trunc_cpos = le32_to_cpu(rec->e_cpos); 1613 *trunc_cpos = le32_to_cpu(rec->e_cpos);
1650 /* 1614 /*
1651 * Skip holes if any. 1615 * Skip holes if any.
@@ -1656,7 +1620,16 @@ static void ocfs2_calc_trunc_pos(struct inode *inode,
1656 *blkno = le64_to_cpu(rec->e_blkno); 1620 *blkno = le64_to_cpu(rec->e_blkno);
1657 *trunc_end = le32_to_cpu(rec->e_cpos); 1621 *trunc_end = le32_to_cpu(rec->e_cpos);
1658 } else if (range > trunc_start) { 1622 } else if (range > trunc_start) {
1623 /*
1624 * remove a partial extent record, which means we're
1625 * removing the last extent record.
1626 */
1659 *trunc_cpos = trunc_start; 1627 *trunc_cpos = trunc_start;
1628 /*
1629 * skip hole if any.
1630 */
1631 if (range < *trunc_end)
1632 *trunc_end = range;
1660 *trunc_len = *trunc_end - trunc_start; 1633 *trunc_len = *trunc_end - trunc_start;
1661 coff = trunc_start - le32_to_cpu(rec->e_cpos); 1634 coff = trunc_start - le32_to_cpu(rec->e_cpos);
1662 *blkno = le64_to_cpu(rec->e_blkno) + 1635 *blkno = le64_to_cpu(rec->e_blkno) +
@@ -1697,6 +1670,11 @@ static int ocfs2_remove_inode_range(struct inode *inode,
1697 ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(inode), di_bh); 1670 ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(inode), di_bh);
1698 ocfs2_init_dealloc_ctxt(&dealloc); 1671 ocfs2_init_dealloc_ctxt(&dealloc);
1699 1672
1673 trace_ocfs2_remove_inode_range(
1674 (unsigned long long)OCFS2_I(inode)->ip_blkno,
1675 (unsigned long long)byte_start,
1676 (unsigned long long)byte_len);
1677
1700 if (byte_len == 0) 1678 if (byte_len == 0)
1701 return 0; 1679 return 0;
1702 1680
@@ -1743,11 +1721,6 @@ static int ocfs2_remove_inode_range(struct inode *inode,
1743 trunc_end = (byte_start + byte_len) >> osb->s_clustersize_bits; 1721 trunc_end = (byte_start + byte_len) >> osb->s_clustersize_bits;
1744 cluster_in_el = trunc_end; 1722 cluster_in_el = trunc_end;
1745 1723
1746 mlog(0, "Inode: %llu, start: %llu, len: %llu, cstart: %u, cend: %u\n",
1747 (unsigned long long)OCFS2_I(inode)->ip_blkno,
1748 (unsigned long long)byte_start,
1749 (unsigned long long)byte_len, trunc_start, trunc_end);
1750
1751 ret = ocfs2_zero_partial_clusters(inode, byte_start, byte_len); 1724 ret = ocfs2_zero_partial_clusters(inode, byte_start, byte_len);
1752 if (ret) { 1725 if (ret) {
1753 mlog_errno(ret); 1726 mlog_errno(ret);
@@ -1998,28 +1971,32 @@ int ocfs2_change_file_space(struct file *file, unsigned int cmd,
1998 return __ocfs2_change_file_space(file, inode, file->f_pos, cmd, sr, 0); 1971 return __ocfs2_change_file_space(file, inode, file->f_pos, cmd, sr, 0);
1999} 1972}
2000 1973
2001static long ocfs2_fallocate(struct inode *inode, int mode, loff_t offset, 1974static long ocfs2_fallocate(struct file *file, int mode, loff_t offset,
2002 loff_t len) 1975 loff_t len)
2003{ 1976{
1977 struct inode *inode = file->f_path.dentry->d_inode;
2004 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 1978 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2005 struct ocfs2_space_resv sr; 1979 struct ocfs2_space_resv sr;
2006 int change_size = 1; 1980 int change_size = 1;
1981 int cmd = OCFS2_IOC_RESVSP64;
2007 1982
1983 if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
1984 return -EOPNOTSUPP;
2008 if (!ocfs2_writes_unwritten_extents(osb)) 1985 if (!ocfs2_writes_unwritten_extents(osb))
2009 return -EOPNOTSUPP; 1986 return -EOPNOTSUPP;
2010 1987
2011 if (S_ISDIR(inode->i_mode))
2012 return -ENODEV;
2013
2014 if (mode & FALLOC_FL_KEEP_SIZE) 1988 if (mode & FALLOC_FL_KEEP_SIZE)
2015 change_size = 0; 1989 change_size = 0;
2016 1990
1991 if (mode & FALLOC_FL_PUNCH_HOLE)
1992 cmd = OCFS2_IOC_UNRESVSP64;
1993
2017 sr.l_whence = 0; 1994 sr.l_whence = 0;
2018 sr.l_start = (s64)offset; 1995 sr.l_start = (s64)offset;
2019 sr.l_len = (s64)len; 1996 sr.l_len = (s64)len;
2020 1997
2021 return __ocfs2_change_file_space(NULL, inode, offset, 1998 return __ocfs2_change_file_space(NULL, inode, offset, cmd, &sr,
2022 OCFS2_IOC_RESVSP64, &sr, change_size); 1999 change_size);
2023} 2000}
2024 2001
2025int ocfs2_check_range_for_refcount(struct inode *inode, loff_t pos, 2002int ocfs2_check_range_for_refcount(struct inode *inode, loff_t pos,
@@ -2062,6 +2039,7 @@ out:
2062} 2039}
2063 2040
2064static int ocfs2_prepare_inode_for_refcount(struct inode *inode, 2041static int ocfs2_prepare_inode_for_refcount(struct inode *inode,
2042 struct file *file,
2065 loff_t pos, size_t count, 2043 loff_t pos, size_t count,
2066 int *meta_level) 2044 int *meta_level)
2067{ 2045{
@@ -2079,7 +2057,7 @@ static int ocfs2_prepare_inode_for_refcount(struct inode *inode,
2079 2057
2080 *meta_level = 1; 2058 *meta_level = 1;
2081 2059
2082 ret = ocfs2_refcount_cow(inode, di_bh, cpos, clusters, UINT_MAX); 2060 ret = ocfs2_refcount_cow(inode, file, di_bh, cpos, clusters, UINT_MAX);
2083 if (ret) 2061 if (ret)
2084 mlog_errno(ret); 2062 mlog_errno(ret);
2085out: 2063out:
@@ -2087,7 +2065,7 @@ out:
2087 return ret; 2065 return ret;
2088} 2066}
2089 2067
2090static int ocfs2_prepare_inode_for_write(struct dentry *dentry, 2068static int ocfs2_prepare_inode_for_write(struct file *file,
2091 loff_t *ppos, 2069 loff_t *ppos,
2092 size_t count, 2070 size_t count,
2093 int appending, 2071 int appending,
@@ -2095,8 +2073,9 @@ static int ocfs2_prepare_inode_for_write(struct dentry *dentry,
2095 int *has_refcount) 2073 int *has_refcount)
2096{ 2074{
2097 int ret = 0, meta_level = 0; 2075 int ret = 0, meta_level = 0;
2076 struct dentry *dentry = file->f_path.dentry;
2098 struct inode *inode = dentry->d_inode; 2077 struct inode *inode = dentry->d_inode;
2099 loff_t saved_pos, end; 2078 loff_t saved_pos = 0, end;
2100 2079
2101 /* 2080 /*
2102 * We start with a read level meta lock and only jump to an ex 2081 * We start with a read level meta lock and only jump to an ex
@@ -2135,12 +2114,10 @@ static int ocfs2_prepare_inode_for_write(struct dentry *dentry,
2135 2114
2136 /* work on a copy of ppos until we're sure that we won't have 2115 /* work on a copy of ppos until we're sure that we won't have
2137 * to recalculate it due to relocking. */ 2116 * to recalculate it due to relocking. */
2138 if (appending) { 2117 if (appending)
2139 saved_pos = i_size_read(inode); 2118 saved_pos = i_size_read(inode);
2140 mlog(0, "O_APPEND: inode->i_size=%llu\n", saved_pos); 2119 else
2141 } else {
2142 saved_pos = *ppos; 2120 saved_pos = *ppos;
2143 }
2144 2121
2145 end = saved_pos + count; 2122 end = saved_pos + count;
2146 2123
@@ -2150,6 +2127,7 @@ static int ocfs2_prepare_inode_for_write(struct dentry *dentry,
2150 meta_level = -1; 2127 meta_level = -1;
2151 2128
2152 ret = ocfs2_prepare_inode_for_refcount(inode, 2129 ret = ocfs2_prepare_inode_for_refcount(inode,
2130 file,
2153 saved_pos, 2131 saved_pos,
2154 count, 2132 count,
2155 &meta_level); 2133 &meta_level);
@@ -2210,6 +2188,10 @@ static int ocfs2_prepare_inode_for_write(struct dentry *dentry,
2210 *ppos = saved_pos; 2188 *ppos = saved_pos;
2211 2189
2212out_unlock: 2190out_unlock:
2191 trace_ocfs2_prepare_inode_for_write(OCFS2_I(inode)->ip_blkno,
2192 saved_pos, appending, count,
2193 direct_io, has_refcount);
2194
2213 if (meta_level >= 0) 2195 if (meta_level >= 0)
2214 ocfs2_inode_unlock(inode, meta_level); 2196 ocfs2_inode_unlock(inode, meta_level);
2215 2197
@@ -2232,11 +2214,14 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
2232 struct file *file = iocb->ki_filp; 2214 struct file *file = iocb->ki_filp;
2233 struct inode *inode = file->f_path.dentry->d_inode; 2215 struct inode *inode = file->f_path.dentry->d_inode;
2234 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 2216 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2217 int full_coherency = !(osb->s_mount_opt &
2218 OCFS2_MOUNT_COHERENCY_BUFFERED);
2235 2219
2236 mlog_entry("(0x%p, %u, '%.*s')\n", file, 2220 trace_ocfs2_file_aio_write(inode, file, file->f_path.dentry,
2237 (unsigned int)nr_segs, 2221 (unsigned long long)OCFS2_I(inode)->ip_blkno,
2238 file->f_path.dentry->d_name.len, 2222 file->f_path.dentry->d_name.len,
2239 file->f_path.dentry->d_name.name); 2223 file->f_path.dentry->d_name.name,
2224 (unsigned int)nr_segs);
2240 2225
2241 if (iocb->ki_left == 0) 2226 if (iocb->ki_left == 0)
2242 return 0; 2227 return 0;
@@ -2248,23 +2233,50 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
2248 2233
2249 mutex_lock(&inode->i_mutex); 2234 mutex_lock(&inode->i_mutex);
2250 2235
2236 ocfs2_iocb_clear_sem_locked(iocb);
2237
2251relock: 2238relock:
2252 /* to match setattr's i_mutex -> i_alloc_sem -> rw_lock ordering */ 2239 /* to match setattr's i_mutex -> i_alloc_sem -> rw_lock ordering */
2253 if (direct_io) { 2240 if (direct_io) {
2254 down_read(&inode->i_alloc_sem); 2241 down_read(&inode->i_alloc_sem);
2255 have_alloc_sem = 1; 2242 have_alloc_sem = 1;
2243 /* communicate with ocfs2_dio_end_io */
2244 ocfs2_iocb_set_sem_locked(iocb);
2256 } 2245 }
2257 2246
2258 /* concurrent O_DIRECT writes are allowed */ 2247 /*
2259 rw_level = !direct_io; 2248 * Concurrent O_DIRECT writes are allowed with
2249 * mount_option "coherency=buffered".
2250 */
2251 rw_level = (!direct_io || full_coherency);
2252
2260 ret = ocfs2_rw_lock(inode, rw_level); 2253 ret = ocfs2_rw_lock(inode, rw_level);
2261 if (ret < 0) { 2254 if (ret < 0) {
2262 mlog_errno(ret); 2255 mlog_errno(ret);
2263 goto out_sems; 2256 goto out_sems;
2264 } 2257 }
2265 2258
2259 /*
2260 * O_DIRECT writes with "coherency=full" need to take EX cluster
2261 * inode_lock to guarantee coherency.
2262 */
2263 if (direct_io && full_coherency) {
2264 /*
2265 * We need to take and drop the inode lock to force
2266 * other nodes to drop their caches. Buffered I/O
2267 * already does this in write_begin().
2268 */
2269 ret = ocfs2_inode_lock(inode, NULL, 1);
2270 if (ret < 0) {
2271 mlog_errno(ret);
2272 goto out_sems;
2273 }
2274
2275 ocfs2_inode_unlock(inode, 1);
2276 }
2277
2266 can_do_direct = direct_io; 2278 can_do_direct = direct_io;
2267 ret = ocfs2_prepare_inode_for_write(file->f_path.dentry, ppos, 2279 ret = ocfs2_prepare_inode_for_write(file, ppos,
2268 iocb->ki_left, appending, 2280 iocb->ki_left, appending,
2269 &can_do_direct, &has_refcount); 2281 &can_do_direct, &has_refcount);
2270 if (ret < 0) { 2282 if (ret < 0) {
@@ -2312,17 +2324,6 @@ relock:
2312 written = generic_file_direct_write(iocb, iov, &nr_segs, *ppos, 2324 written = generic_file_direct_write(iocb, iov, &nr_segs, *ppos,
2313 ppos, count, ocount); 2325 ppos, count, ocount);
2314 if (written < 0) { 2326 if (written < 0) {
2315 /*
2316 * direct write may have instantiated a few
2317 * blocks outside i_size. Trim these off again.
2318 * Don't need i_size_read because we hold i_mutex.
2319 *
2320 * XXX(truncate): this looks buggy because ocfs2 did not
2321 * actually implement ->truncate. Take a look at
2322 * the new truncate sequence and update this accordingly
2323 */
2324 if (*ppos + count > inode->i_size)
2325 truncate_setsize(inode, inode->i_size);
2326 ret = written; 2327 ret = written;
2327 goto out_dio; 2328 goto out_dio;
2328 } 2329 }
@@ -2377,14 +2378,15 @@ out:
2377 ocfs2_rw_unlock(inode, rw_level); 2378 ocfs2_rw_unlock(inode, rw_level);
2378 2379
2379out_sems: 2380out_sems:
2380 if (have_alloc_sem) 2381 if (have_alloc_sem) {
2381 up_read(&inode->i_alloc_sem); 2382 up_read(&inode->i_alloc_sem);
2383 ocfs2_iocb_clear_sem_locked(iocb);
2384 }
2382 2385
2383 mutex_unlock(&inode->i_mutex); 2386 mutex_unlock(&inode->i_mutex);
2384 2387
2385 if (written) 2388 if (written)
2386 ret = written; 2389 ret = written;
2387 mlog_exit(ret);
2388 return ret; 2390 return ret;
2389} 2391}
2390 2392
@@ -2394,7 +2396,7 @@ static int ocfs2_splice_to_file(struct pipe_inode_info *pipe,
2394{ 2396{
2395 int ret; 2397 int ret;
2396 2398
2397 ret = ocfs2_prepare_inode_for_write(out->f_path.dentry, &sd->pos, 2399 ret = ocfs2_prepare_inode_for_write(out, &sd->pos,
2398 sd->total_len, 0, NULL, NULL); 2400 sd->total_len, 0, NULL, NULL);
2399 if (ret < 0) { 2401 if (ret < 0) {
2400 mlog_errno(ret); 2402 mlog_errno(ret);
@@ -2420,10 +2422,11 @@ static ssize_t ocfs2_file_splice_write(struct pipe_inode_info *pipe,
2420 .u.file = out, 2422 .u.file = out,
2421 }; 2423 };
2422 2424
2423 mlog_entry("(0x%p, 0x%p, %u, '%.*s')\n", out, pipe, 2425
2424 (unsigned int)len, 2426 trace_ocfs2_file_splice_write(inode, out, out->f_path.dentry,
2425 out->f_path.dentry->d_name.len, 2427 (unsigned long long)OCFS2_I(inode)->ip_blkno,
2426 out->f_path.dentry->d_name.name); 2428 out->f_path.dentry->d_name.len,
2429 out->f_path.dentry->d_name.name, len);
2427 2430
2428 if (pipe->inode) 2431 if (pipe->inode)
2429 mutex_lock_nested(&pipe->inode->i_mutex, I_MUTEX_PARENT); 2432 mutex_lock_nested(&pipe->inode->i_mutex, I_MUTEX_PARENT);
@@ -2467,7 +2470,6 @@ static ssize_t ocfs2_file_splice_write(struct pipe_inode_info *pipe,
2467 balance_dirty_pages_ratelimited_nr(mapping, nr_pages); 2470 balance_dirty_pages_ratelimited_nr(mapping, nr_pages);
2468 } 2471 }
2469 2472
2470 mlog_exit(ret);
2471 return ret; 2473 return ret;
2472} 2474}
2473 2475
@@ -2480,10 +2482,10 @@ static ssize_t ocfs2_file_splice_read(struct file *in,
2480 int ret = 0, lock_level = 0; 2482 int ret = 0, lock_level = 0;
2481 struct inode *inode = in->f_path.dentry->d_inode; 2483 struct inode *inode = in->f_path.dentry->d_inode;
2482 2484
2483 mlog_entry("(0x%p, 0x%p, %u, '%.*s')\n", in, pipe, 2485 trace_ocfs2_file_splice_read(inode, in, in->f_path.dentry,
2484 (unsigned int)len, 2486 (unsigned long long)OCFS2_I(inode)->ip_blkno,
2485 in->f_path.dentry->d_name.len, 2487 in->f_path.dentry->d_name.len,
2486 in->f_path.dentry->d_name.name); 2488 in->f_path.dentry->d_name.name, len);
2487 2489
2488 /* 2490 /*
2489 * See the comment in ocfs2_file_aio_read() 2491 * See the comment in ocfs2_file_aio_read()
@@ -2498,7 +2500,6 @@ static ssize_t ocfs2_file_splice_read(struct file *in,
2498 ret = generic_file_splice_read(in, ppos, pipe, len, flags); 2500 ret = generic_file_splice_read(in, ppos, pipe, len, flags);
2499 2501
2500bail: 2502bail:
2501 mlog_exit(ret);
2502 return ret; 2503 return ret;
2503} 2504}
2504 2505
@@ -2511,10 +2512,11 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb,
2511 struct file *filp = iocb->ki_filp; 2512 struct file *filp = iocb->ki_filp;
2512 struct inode *inode = filp->f_path.dentry->d_inode; 2513 struct inode *inode = filp->f_path.dentry->d_inode;
2513 2514
2514 mlog_entry("(0x%p, %u, '%.*s')\n", filp, 2515 trace_ocfs2_file_aio_read(inode, filp, filp->f_path.dentry,
2515 (unsigned int)nr_segs, 2516 (unsigned long long)OCFS2_I(inode)->ip_blkno,
2516 filp->f_path.dentry->d_name.len, 2517 filp->f_path.dentry->d_name.len,
2517 filp->f_path.dentry->d_name.name); 2518 filp->f_path.dentry->d_name.name, nr_segs);
2519
2518 2520
2519 if (!inode) { 2521 if (!inode) {
2520 ret = -EINVAL; 2522 ret = -EINVAL;
@@ -2522,6 +2524,8 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb,
2522 goto bail; 2524 goto bail;
2523 } 2525 }
2524 2526
2527 ocfs2_iocb_clear_sem_locked(iocb);
2528
2525 /* 2529 /*
2526 * buffered reads protect themselves in ->readpage(). O_DIRECT reads 2530 * buffered reads protect themselves in ->readpage(). O_DIRECT reads
2527 * need locks to protect pending reads from racing with truncate. 2531 * need locks to protect pending reads from racing with truncate.
@@ -2529,6 +2533,7 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb,
2529 if (filp->f_flags & O_DIRECT) { 2533 if (filp->f_flags & O_DIRECT) {
2530 down_read(&inode->i_alloc_sem); 2534 down_read(&inode->i_alloc_sem);
2531 have_alloc_sem = 1; 2535 have_alloc_sem = 1;
2536 ocfs2_iocb_set_sem_locked(iocb);
2532 2537
2533 ret = ocfs2_rw_lock(inode, 0); 2538 ret = ocfs2_rw_lock(inode, 0);
2534 if (ret < 0) { 2539 if (ret < 0) {
@@ -2557,8 +2562,7 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb,
2557 ocfs2_inode_unlock(inode, lock_level); 2562 ocfs2_inode_unlock(inode, lock_level);
2558 2563
2559 ret = generic_file_aio_read(iocb, iov, nr_segs, iocb->ki_pos); 2564 ret = generic_file_aio_read(iocb, iov, nr_segs, iocb->ki_pos);
2560 if (ret == -EINVAL) 2565 trace_generic_file_aio_read_ret(ret);
2561 mlog(0, "generic_file_aio_read returned -EINVAL\n");
2562 2566
2563 /* buffered aio wouldn't have proper lock coverage today */ 2567 /* buffered aio wouldn't have proper lock coverage today */
2564 BUG_ON(ret == -EIOCBQUEUED && !(filp->f_flags & O_DIRECT)); 2568 BUG_ON(ret == -EIOCBQUEUED && !(filp->f_flags & O_DIRECT));
@@ -2570,11 +2574,12 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb,
2570 } 2574 }
2571 2575
2572bail: 2576bail:
2573 if (have_alloc_sem) 2577 if (have_alloc_sem) {
2574 up_read(&inode->i_alloc_sem); 2578 up_read(&inode->i_alloc_sem);
2579 ocfs2_iocb_clear_sem_locked(iocb);
2580 }
2575 if (rw_level != -1) 2581 if (rw_level != -1)
2576 ocfs2_rw_unlock(inode, rw_level); 2582 ocfs2_rw_unlock(inode, rw_level);
2577 mlog_exit(ret);
2578 2583
2579 return ret; 2584 return ret;
2580} 2585}
@@ -2587,7 +2592,6 @@ const struct inode_operations ocfs2_file_iops = {
2587 .getxattr = generic_getxattr, 2592 .getxattr = generic_getxattr,
2588 .listxattr = ocfs2_listxattr, 2593 .listxattr = ocfs2_listxattr,
2589 .removexattr = generic_removexattr, 2594 .removexattr = generic_removexattr,
2590 .fallocate = ocfs2_fallocate,
2591 .fiemap = ocfs2_fiemap, 2595 .fiemap = ocfs2_fiemap,
2592}; 2596};
2593 2597
@@ -2619,6 +2623,7 @@ const struct file_operations ocfs2_fops = {
2619 .flock = ocfs2_flock, 2623 .flock = ocfs2_flock,
2620 .splice_read = ocfs2_file_splice_read, 2624 .splice_read = ocfs2_file_splice_read,
2621 .splice_write = ocfs2_file_splice_write, 2625 .splice_write = ocfs2_file_splice_write,
2626 .fallocate = ocfs2_fallocate,
2622}; 2627};
2623 2628
2624const struct file_operations ocfs2_dops = { 2629const struct file_operations ocfs2_dops = {
@@ -2665,6 +2670,7 @@ const struct file_operations ocfs2_fops_no_plocks = {
2665 .flock = ocfs2_flock, 2670 .flock = ocfs2_flock,
2666 .splice_read = ocfs2_file_splice_read, 2671 .splice_read = ocfs2_file_splice_read,
2667 .splice_write = ocfs2_file_splice_write, 2672 .splice_write = ocfs2_file_splice_write,
2673 .fallocate = ocfs2_fallocate,
2668}; 2674};
2669 2675
2670const struct file_operations ocfs2_dops_no_plocks = { 2676const struct file_operations ocfs2_dops_no_plocks = {